Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/core/mentions/__tests__/processUserContentMentions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("processUserContentMentions", () => {
const userContent = [
{
type: "text" as const,
text: "<task>Read file with limit</task>",
text: "<feedback>Read file with limit</feedback>",
},
]

Expand All @@ -45,7 +45,7 @@ describe("processUserContentMentions", () => {
})

expect(parseMentions).toHaveBeenCalledWith(
"<task>Read file with limit</task>",
"<feedback>Read file with limit</feedback>",
"/test",
mockUrlContentFetcher,
mockFileContextTracker,
Expand All @@ -61,7 +61,7 @@ describe("processUserContentMentions", () => {
const userContent = [
{
type: "text" as const,
text: "<task>Read file without limit</task>",
text: "<feedback>Read file without limit</feedback>",
},
]

Expand All @@ -74,7 +74,7 @@ describe("processUserContentMentions", () => {
})

expect(parseMentions).toHaveBeenCalledWith(
"<task>Read file without limit</task>",
"<feedback>Read file without limit</feedback>",
"/test",
mockUrlContentFetcher,
mockFileContextTracker,
Expand All @@ -90,7 +90,7 @@ describe("processUserContentMentions", () => {
const userContent = [
{
type: "text" as const,
text: "<task>Read unlimited lines</task>",
text: "<feedback>Read unlimited lines</feedback>",
},
]

Expand All @@ -104,7 +104,7 @@ describe("processUserContentMentions", () => {
})

expect(parseMentions).toHaveBeenCalledWith(
"<task>Read unlimited lines</task>",
"<feedback>Read unlimited lines</feedback>",
"/test",
mockUrlContentFetcher,
mockFileContextTracker,
Expand All @@ -118,11 +118,11 @@ describe("processUserContentMentions", () => {
})

describe("content processing", () => {
it("should process text blocks with <task> tags", async () => {
it("should process text blocks with <feedback> tags", async () => {
const userContent = [
{
type: "text" as const,
text: "<task>Do something</task>",
text: "<feedback>Do something</feedback>",
},
]

Expand All @@ -136,7 +136,7 @@ describe("processUserContentMentions", () => {
expect(parseMentions).toHaveBeenCalled()
expect(result[0]).toEqual({
type: "text",
text: "parsed: <task>Do something</task>",
text: "parsed: <feedback>Do something</feedback>",
})
})

Expand Down Expand Up @@ -213,7 +213,7 @@ describe("processUserContentMentions", () => {
content: [
{
type: "text" as const,
text: "<task>Array task</task>",
text: "<feedback>Array task</feedback>",
},
{
type: "text" as const,
Expand All @@ -237,7 +237,7 @@ describe("processUserContentMentions", () => {
content: [
{
type: "text",
text: "parsed: <task>Array task</task>",
text: "parsed: <feedback>Array task</feedback>",
},
{
type: "text",
Expand All @@ -251,7 +251,7 @@ describe("processUserContentMentions", () => {
const userContent = [
{
type: "text" as const,
text: "<task>First task</task>",
text: "<feedback>First task</feedback>",
},
{
type: "image" as const,
Expand Down Expand Up @@ -280,7 +280,7 @@ describe("processUserContentMentions", () => {
expect(result).toHaveLength(3)
expect(result[0]).toEqual({
type: "text",
text: "parsed: <task>First task</task>",
text: "parsed: <feedback>First task</feedback>",
})
expect(result[1]).toEqual(userContent[1]) // Image block unchanged
expect(result[2]).toEqual({
Expand All @@ -296,7 +296,7 @@ describe("processUserContentMentions", () => {
const userContent = [
{
type: "text" as const,
text: "<task>Test default</task>",
text: "<feedback>Test default</feedback>",
},
]

Expand All @@ -308,7 +308,7 @@ describe("processUserContentMentions", () => {
})

expect(parseMentions).toHaveBeenCalledWith(
"<task>Test default</task>",
"<feedback>Test default</feedback>",
"/test",
mockUrlContentFetcher,
mockFileContextTracker,
Expand All @@ -324,7 +324,7 @@ describe("processUserContentMentions", () => {
const userContent = [
{
type: "text" as const,
text: "<task>Test explicit false</task>",
text: "<feedback>Test explicit false</feedback>",
},
]

Expand All @@ -337,7 +337,7 @@ describe("processUserContentMentions", () => {
})

expect(parseMentions).toHaveBeenCalledWith(
"<task>Test explicit false</task>",
"<feedback>Test explicit false</feedback>",
"/test",
mockUrlContentFetcher,
mockFileContextTracker,
Expand Down
7 changes: 2 additions & 5 deletions src/core/mentions/processUserContentMentions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function processUserContentMentions({
// Process userContent array, which contains various block types:
// TextBlockParam, ImageBlockParam, ToolUseBlockParam, and ToolResultBlockParam.
// We need to apply parseMentions() to:
// 1. All TextBlockParam's text (first user message with task)
// 1. All TextBlockParam's text (first user message with feedback)
// 2. ToolResultBlockParam's content/context text arrays if it contains
// "<feedback>" (see formatToolDeniedFeedback, attemptCompletion,
// executeCommand, and consecutiveMistakeCount >= 3) or "<answer>"
Expand All @@ -40,10 +40,7 @@ export async function processUserContentMentions({
return Promise.all(
userContent.map(async (block) => {
const shouldProcessMentions = (text: string) =>
text.includes("<task>") ||
text.includes("<feedback>") ||
text.includes("<answer>") ||
text.includes("<user_message>")
text.includes("<feedback>") || text.includes("<answer>") || text.includes("<user_message>")

if (block.type === "text") {
if (shouldProcessMentions(block.text)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
await this.initiateTaskLoop([
{
type: "text",
text: `<task>\n${task}\n</task>`,
text: `<feedback>\n${task}\n</feedback>`,
},
...imageBlocks,
])
Expand Down
4 changes: 2 additions & 2 deletions src/core/task/__tests__/Task.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ describe("Cline", () => {
} as const,
{
type: "text",
text: "<task>Text with 'some/path' (see below for file content) in task tags</task>",
text: "<feedback>Text with 'some/path' (see below for file content) in task tags</feedback>",
} as const,
{
type: "tool_result",
Expand Down Expand Up @@ -934,7 +934,7 @@ describe("Cline", () => {
// Text within task tags should be processed
expect((processedContent[1] as Anthropic.TextBlockParam).text).toContain("processed:")
expect((processedContent[1] as Anthropic.TextBlockParam).text).toContain(
"<task>Text with 'some/path' (see below for file content) in task tags</task>",
"<feedback>Text with 'some/path' (see below for file content) in task tags</feedback>",
)

// Feedback tag content should be processed
Expand Down
Loading