2025-07-23 16:11:23 -04:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-08-17 00:02:54 -04:00
|
|
|
import { IPromptProcessor } from './types.js';
|
2025-07-23 16:11:23 -04:00
|
|
|
import { CommandContext } from '../../ui/commands/types.js';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Appends the user's full command invocation to the prompt if arguments are
|
|
|
|
|
* provided, allowing the model to perform its own argument parsing.
|
2025-08-17 00:02:54 -04:00
|
|
|
*
|
|
|
|
|
* This processor is only used if the prompt does NOT contain {{args}}.
|
2025-07-23 16:11:23 -04:00
|
|
|
*/
|
|
|
|
|
export class DefaultArgumentProcessor implements IPromptProcessor {
|
|
|
|
|
async process(prompt: string, context: CommandContext): Promise<string> {
|
|
|
|
|
if (context.invocation!.args) {
|
|
|
|
|
return `${prompt}\n\n${context.invocation!.raw}`;
|
|
|
|
|
}
|
|
|
|
|
return prompt;
|
|
|
|
|
}
|
|
|
|
|
}
|