mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-01-04 07:59:13 +00:00
28 lines
847 B
TypeScript
28 lines
847 B
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { appendToLastTextPart } from '@qwen-code/qwen-code-core';
|
|
import type { IPromptProcessor, PromptPipelineContent } from './types.js';
|
|
import type { 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.
|
|
*
|
|
* This processor is only used if the prompt does NOT contain {{args}}.
|
|
*/
|
|
export class DefaultArgumentProcessor implements IPromptProcessor {
|
|
async process(
|
|
prompt: PromptPipelineContent,
|
|
context: CommandContext,
|
|
): Promise<PromptPipelineContent> {
|
|
if (context.invocation?.args) {
|
|
return appendToLastTextPart(prompt, context.invocation.raw);
|
|
}
|
|
return prompt;
|
|
}
|
|
}
|