From be3bda8136ceef5b0e68984ecf08221a9bd09127 Mon Sep 17 00:00:00 2001 From: Hannes Rudolph Date: Sat, 11 Oct 2025 16:06:30 -0600 Subject: [PATCH] Remove XML-like / wrappers; process plain user input; update code/tests --- .../__tests__/processUserContentMentions.spec.ts | 13 ++++++++----- src/core/mentions/processUserContentMentions.ts | 6 +----- src/core/prompts/responses.ts | 6 +++--- src/core/task/Task.ts | 2 +- src/core/task/__tests__/Task.spec.ts | 10 ++++++---- src/core/tools/attemptCompletionTool.ts | 2 +- src/core/tools/executeCommandTool.ts | 3 +-- src/services/command/built-in-commands.ts | 4 +--- 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/core/mentions/__tests__/processUserContentMentions.spec.ts b/src/core/mentions/__tests__/processUserContentMentions.spec.ts index 13c225042d..6effcc72c0 100644 --- a/src/core/mentions/__tests__/processUserContentMentions.spec.ts +++ b/src/core/mentions/__tests__/processUserContentMentions.spec.ts @@ -162,7 +162,7 @@ describe("processUserContentMentions", () => { }) }) - it("should not process text blocks without task or feedback tags", async () => { + it("should process text blocks without special tags", async () => { const userContent = [ { type: "text" as const, @@ -177,8 +177,11 @@ describe("processUserContentMentions", () => { fileContextTracker: mockFileContextTracker, }) - expect(parseMentions).not.toHaveBeenCalled() - expect(result[0]).toEqual(userContent[0]) + expect(parseMentions).toHaveBeenCalled() + expect(result[0]).toEqual({ + type: "text", + text: "parsed: Regular text without special tags", + }) }) it("should process tool_result blocks with string content", async () => { @@ -230,7 +233,7 @@ describe("processUserContentMentions", () => { fileContextTracker: mockFileContextTracker, }) - expect(parseMentions).toHaveBeenCalledTimes(1) + expect(parseMentions).toHaveBeenCalledTimes(2) expect(result[0]).toEqual({ type: "tool_result", tool_use_id: "123", @@ -241,7 +244,7 @@ describe("processUserContentMentions", () => { }, { type: "text", - text: "Regular text", + text: "parsed: Regular text", }, ], }) diff --git a/src/core/mentions/processUserContentMentions.ts b/src/core/mentions/processUserContentMentions.ts index 4bdb422d48..148b3c5227 100644 --- a/src/core/mentions/processUserContentMentions.ts +++ b/src/core/mentions/processUserContentMentions.ts @@ -39,11 +39,7 @@ export async function processUserContentMentions({ // should parse mentions). return Promise.all( userContent.map(async (block) => { - const shouldProcessMentions = (text: string) => - text.includes("") || - text.includes("") || - text.includes("") || - text.includes("") + const shouldProcessMentions = (_text: string) => true if (block.type === "text") { if (shouldProcessMentions(block.text)) { diff --git a/src/core/prompts/responses.ts b/src/core/prompts/responses.ts index fd51b18fed..cf4de10026 100644 --- a/src/core/prompts/responses.ts +++ b/src/core/prompts/responses.ts @@ -8,10 +8,10 @@ export const formatResponse = { toolDenied: () => `The user denied this operation.`, toolDeniedWithFeedback: (feedback?: string) => - `The user denied this operation and provided the following feedback:\n\n${feedback}\n`, + `The user denied this operation and provided the following feedback:\n${feedback}`, toolApprovedWithFeedback: (feedback?: string) => - `The user approved this operation and provided the following context:\n\n${feedback}\n`, + `The user approved this operation and provided the following context:\n${feedback}`, toolError: (error?: string) => `The tool execution failed with the following error:\n\n${error}\n`, @@ -31,7 +31,7 @@ Otherwise, if you have not completed the task and do not need additional informa (This is an automated message, so do not respond to it conversationally.)`, tooManyMistakes: (feedback?: string) => - `You seem to be having trouble proceeding. The user has provided the following feedback to help guide you:\n\n${feedback}\n`, + `You seem to be having trouble proceeding. The user has provided the following feedback to help guide you:\n${feedback}`, missingToolParameterError: (paramName: string) => `Missing value for required parameter '${paramName}'. Please retry with complete response.\n\n${toolUseInstructionsReminder}`, diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 851df91e6c..9e965495d8 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -1222,7 +1222,7 @@ export class Task extends EventEmitter implements TaskLike { await this.initiateTaskLoop([ { type: "text", - text: `\n${task}\n`, + text: task ?? "", }, ...imageBlocks, ]) diff --git a/src/core/task/__tests__/Task.spec.ts b/src/core/task/__tests__/Task.spec.ts index 116c78d760..0414b26a7b 100644 --- a/src/core/task/__tests__/Task.spec.ts +++ b/src/core/task/__tests__/Task.spec.ts @@ -918,8 +918,9 @@ describe("Cline", () => { fileContextTracker: cline.fileContextTracker, }) - // Regular text should not be processed - expect((processedContent[0] as Anthropic.TextBlockParam).text).toBe( + // Regular text should be processed + expect((processedContent[0] as Anthropic.TextBlockParam).text).toContain("processed:") + expect((processedContent[0] as Anthropic.TextBlockParam).text).toContain( "Regular text with 'some/path' (see below for file content)", ) @@ -937,10 +938,11 @@ describe("Cline", () => { "Check 'some/path' (see below for file content)", ) - // Regular tool result should not be processed + // Regular tool result should be processed now const toolResult2 = processedContent[3] as Anthropic.ToolResultBlockParam const content2 = Array.isArray(toolResult2.content) ? toolResult2.content[0] : toolResult2.content - expect((content2 as Anthropic.TextBlockParam).text).toBe( + expect((content2 as Anthropic.TextBlockParam).text).toContain("processed:") + expect((content2 as Anthropic.TextBlockParam).text).toContain( "Regular tool result with 'path' (see below for file content)", ) diff --git a/src/core/tools/attemptCompletionTool.ts b/src/core/tools/attemptCompletionTool.ts index 5074d7f4e8..b81ffcdcab 100644 --- a/src/core/tools/attemptCompletionTool.ts +++ b/src/core/tools/attemptCompletionTool.ts @@ -125,7 +125,7 @@ export async function attemptCompletionTool( toolResults.push({ type: "text", - text: `The user has provided feedback on the results. Consider their input to continue the task, and then attempt completion again.\n\n${text}\n`, + text: `The user has provided feedback on the results. Consider their input to continue the task, and then attempt completion again.\n${text}`, }) toolResults.push(...formatResponse.imageBlocks(images)) diff --git a/src/core/tools/executeCommandTool.ts b/src/core/tools/executeCommandTool.ts index 2c7ce0d023..b5a3e99056 100644 --- a/src/core/tools/executeCommandTool.ts +++ b/src/core/tools/executeCommandTool.ts @@ -317,8 +317,7 @@ export async function executeCommand( [ `Command is still running in terminal from '${terminal.getCurrentWorkingDirectory().toPosix()}'.`, result.length > 0 ? `Here's the output so far:\n${result}\n` : "\n", - `The user provided the following feedback:`, - `\n${text}\n`, + `The user provided the following feedback:\n${text}`, ].join("\n"), images, ), diff --git a/src/services/command/built-in-commands.ts b/src/services/command/built-in-commands.ts index db113c4895..921462cfda 100644 --- a/src/services/command/built-in-commands.ts +++ b/src/services/command/built-in-commands.ts @@ -11,11 +11,9 @@ const BUILT_IN_COMMANDS: Record = { init: { name: "init", description: "Analyze codebase and create concise AGENTS.md files for AI assistants", - content: ` -Please analyze this codebase and create an AGENTS.md file containing: + content: `Please analyze this codebase and create an AGENTS.md file containing: 1. Build/lint/test commands - especially for running a single test 2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc. -