fix(coding-agent): parse multiline prompt template args

closes #4553
This commit is contained in:
Mario Zechner
2026-05-16 23:36:25 +02:00
parent 22a9c484e7
commit d0fe8570e9
3 changed files with 63 additions and 6 deletions

View File

@@ -37,7 +37,7 @@ export function parseCommandArgs(argsString: string): string[] {
}
} else if (char === '"' || char === "'") {
inQuote = char;
} else if (char === " " || char === "\t") {
} else if (/\s/.test(char)) {
if (current) {
args.push(current);
current = "";
@@ -282,9 +282,11 @@ export function loadPromptTemplates(options: LoadPromptTemplatesOptions): Prompt
export function expandPromptTemplate(text: string, templates: PromptTemplate[]): string {
if (!text.startsWith("/")) return text;
const spaceIndex = text.indexOf(" ");
const templateName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);
const argsString = spaceIndex === -1 ? "" : text.slice(spaceIndex + 1);
const match = text.match(/^\/([^\s]+)(?:\s+([\s\S]*))?$/);
if (!match) return text;
const templateName = match[1];
const argsString = match[2] ?? "";
const template = templates.find((t) => t.name === templateName);
if (template) {