Skip to content

Commit c9de9cd

Browse files
committed
Revert some whitespace changes
1 parent fe22d1f commit c9de9cd

File tree

6 files changed

+194
-188
lines changed

6 files changed

+194
-188
lines changed

src/core/Cline.ts

Lines changed: 75 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ export class Cline {
205205
const taskMessage = this.clineMessages[0] // first message is always the task say
206206
const lastRelevantMessage =
207207
this.clineMessages[
208-
findLastIndex(
209-
this.clineMessages,
210-
(m) => !(m.ask === "resume_task" || m.ask === "resume_completed_task"),
211-
)
208+
findLastIndex(
209+
this.clineMessages,
210+
(m) => !(m.ask === "resume_task" || m.ask === "resume_completed_task"),
211+
)
212212
]
213213
await this.providerRef.deref()?.updateTaskHistory({
214214
id: this.taskId,
@@ -390,7 +390,8 @@ export class Cline {
390390
async sayAndCreateMissingParamError(toolName: ToolUseName, paramName: string, relPath?: string) {
391391
await this.say(
392392
"error",
393-
`Cline tried to use ${toolName}${relPath ? ` for '${relPath.toPosix()}'` : ""
393+
`Cline tried to use ${toolName}${
394+
relPath ? ` for '${relPath.toPosix()}'` : ""
394395
} without value for required parameter '${paramName}'. Retrying...`,
395396
)
396397
return formatResponse.toolError(formatResponse.missingToolParameterError(paramName))
@@ -448,7 +449,7 @@ export class Cline {
448449
// need to make sure that the api conversation history can be resumed by the api, even if it goes out of sync with cline messages
449450

450451
let existingApiConversationHistory: Anthropic.Messages.MessageParam[] =
451-
await this.getSavedApiConversationHistory()
452+
await this.getSavedApiConversationHistory()
452453

453454
// Now present the cline messages to the user and ask if they want to resume
454455

@@ -559,8 +560,8 @@ export class Cline {
559560
: [{ type: "text", text: lastMessage.content }]
560561
if (previousAssistantMessage && previousAssistantMessage.role === "assistant") {
561562
const assistantContent = Array.isArray(previousAssistantMessage.content)
562-
? previousAssistantMessage.content
563-
: [{ type: "text", text: previousAssistantMessage.content }]
563+
? previousAssistantMessage.content
564+
: [{ type: "text", text: previousAssistantMessage.content }]
564565

565566
const toolUseBlocks = assistantContent.filter(
566567
(block) => block.type === "tool_use",
@@ -625,9 +626,10 @@ export class Cline {
625626
newUserContent.push({
626627
type: "text",
627628
text:
628-
`[TASK RESUMPTION] This task was interrupted ${agoText}. It may or may not be complete, so please reassess the task context. Be aware that the project state may have changed since then. The current working directory is now '${cwd.toPosix()}'. If the task has not been completed, retry the last step before interruption and proceed with completing the task.\n\nNote: If you previously attempted a tool use that the user did not provide a result for, you should assume the tool use was not successful and assess whether you should retry. If the last tool was a browser_action, the browser has been closed and you must launch a new browser if needed.${wasRecent
629-
? "\n\nIMPORTANT: If the last tool use was a write_to_file that was interrupted, the file was reverted back to its original state before the interrupted edit, and you do NOT need to re-read the file as you already have its up-to-date contents."
630-
: ""
629+
`[TASK RESUMPTION] This task was interrupted ${agoText}. It may or may not be complete, so please reassess the task context. Be aware that the project state may have changed since then. The current working directory is now '${cwd.toPosix()}'. If the task has not been completed, retry the last step before interruption and proceed with completing the task.\n\nNote: If you previously attempted a tool use that the user did not provide a result for, you should assume the tool use was not successful and assess whether you should retry. If the last tool was a browser_action, the browser has been closed and you must launch a new browser if needed.${
630+
wasRecent
631+
? "\n\nIMPORTANT: If the last tool use was a write_to_file that was interrupted, the file was reverted back to its original state before the interrupted edit, and you do NOT need to re-read the file as you already have its up-to-date contents."
632+
: ""
631633
}` +
632634
(responseText
633635
? `\n\nNew instructions for task continuation:\n<user_message>\n${responseText}\n</user_message>`
@@ -741,7 +743,8 @@ export class Cline {
741743
return [
742744
true,
743745
formatResponse.toolResult(
744-
`Command is still running in the user's terminal.${result.length > 0 ? `\nHere's the output so far:\n${result}` : ""
746+
`Command is still running in the user's terminal.${
747+
result.length > 0 ? `\nHere's the output so far:\n${result}` : ""
745748
}\n\nThe user provided the following feedback:\n<feedback>\n${userFeedback.text}\n</feedback>`,
746749
userFeedback.images,
747750
),
@@ -753,7 +756,8 @@ export class Cline {
753756
} else {
754757
return [
755758
false,
756-
`Command is still running in the user's terminal.${result.length > 0 ? `\nHere's the output so far:\n${result}` : ""
759+
`Command is still running in the user's terminal.${
760+
result.length > 0 ? `\nHere's the output so far:\n${result}` : ""
757761
}\n\nYou will be updated on the terminal status and new output in the future.`,
758762
]
759763
}
@@ -931,8 +935,9 @@ export class Cline {
931935
case "apply_diff":
932936
return `[${block.name} for '${block.params.path}']`
933937
case "search_files":
934-
return `[${block.name} for '${block.params.regex}'${block.params.file_pattern ? ` in '${block.params.file_pattern}'` : ""
935-
}]`
938+
return `[${block.name} for '${block.params.regex}'${
939+
block.params.file_pattern ? ` in '${block.params.file_pattern}'` : ""
940+
}]`
936941
case "list_files":
937942
return `[${block.name} for '${block.params.path}']`
938943
case "list_code_definition_names":
@@ -1118,7 +1123,7 @@ export class Cline {
11181123
if (block.partial) {
11191124
// update gui message
11201125
const partialMessage = JSON.stringify(sharedMessageProps)
1121-
await this.ask("tool", partialMessage, block.partial).catch(() => { })
1126+
await this.ask("tool", partialMessage, block.partial).catch(() => {})
11221127
// update editor
11231128
if (!this.diffViewProvider.isEditing) {
11241129
// open the editor and prepare to stream content in
@@ -1154,7 +1159,7 @@ export class Cline {
11541159
if (!this.diffViewProvider.isEditing) {
11551160
// show gui message before showing edit animation
11561161
const partialMessage = JSON.stringify(sharedMessageProps)
1157-
await this.ask("tool", partialMessage, true).catch(() => { }) // sending true for partial even though it's not a partial, this shows the edit row before the content is streamed into the editor
1162+
await this.ask("tool", partialMessage, true).catch(() => {}) // sending true for partial even though it's not a partial, this shows the edit row before the content is streamed into the editor
11581163
await this.diffViewProvider.open(relPath)
11591164
}
11601165
await this.diffViewProvider.update(everyLineHasLineNumbers(newContent) ? stripLineNumbers(newContent) : newContent, true)
@@ -1192,10 +1197,10 @@ export class Cline {
11921197
content: fileExists ? undefined : newContent,
11931198
diff: fileExists
11941199
? formatResponse.createPrettyPatch(
1195-
relPath,
1196-
this.diffViewProvider.originalContent,
1197-
newContent,
1198-
)
1200+
relPath,
1201+
this.diffViewProvider.originalContent,
1202+
newContent,
1203+
)
11991204
: undefined,
12001205
} satisfies ClineSayTool)
12011206
const didApprove = await askApproval("tool", completeMessage)
@@ -1217,13 +1222,13 @@ export class Cline {
12171222
)
12181223
pushToolResult(
12191224
`The user made the following updates to your content:\n\n${userEdits}\n\n` +
1220-
`The updated content, which includes both your original modifications and the user's edits, has been successfully saved to ${relPath.toPosix()}. Here is the full, updated content of the file, including line numbers:\n\n` +
1221-
`<final_file_content path="${relPath.toPosix()}">\n${addLineNumbers(finalContent || '')}\n</final_file_content>\n\n` +
1222-
`Please note:\n` +
1223-
`1. You do not need to re-write the file with these changes, as they have already been applied.\n` +
1224-
`2. Proceed with the task using this updated file content as the new baseline.\n` +
1225-
`3. If the user's edits have addressed part of the task or changed the requirements, adjust your approach accordingly.` +
1226-
`${newProblemsMessage}`,
1225+
`The updated content, which includes both your original modifications and the user's edits, has been successfully saved to ${relPath.toPosix()}. Here is the full, updated content of the file, including line numbers:\n\n` +
1226+
`<final_file_content path="${relPath.toPosix()}">\n${addLineNumbers(finalContent || '')}\n</final_file_content>\n\n` +
1227+
`Please note:\n` +
1228+
`1. You do not need to re-write the file with these changes, as they have already been applied.\n` +
1229+
`2. Proceed with the task using this updated file content as the new baseline.\n` +
1230+
`3. If the user's edits have addressed part of the task or changed the requirements, adjust your approach accordingly.` +
1231+
`${newProblemsMessage}`,
12271232
)
12281233
} else {
12291234
pushToolResult(
@@ -1252,7 +1257,7 @@ export class Cline {
12521257
if (block.partial) {
12531258
// update gui message
12541259
const partialMessage = JSON.stringify(sharedMessageProps)
1255-
await this.ask("tool", partialMessage, block.partial).catch(() => { })
1260+
await this.ask("tool", partialMessage, block.partial).catch(() => {})
12561261
break
12571262
} else {
12581263
if (!relPath) {
@@ -1281,9 +1286,9 @@ export class Cline {
12811286

12821287
// Apply the diff to the original content
12831288
const diffResult = this.diffStrategy?.applyDiff(
1284-
originalContent,
1285-
diffContent,
1286-
parseInt(block.params.start_line ?? ''),
1289+
originalContent,
1290+
diffContent,
1291+
parseInt(block.params.start_line ?? ''),
12871292
parseInt(block.params.end_line ?? '')
12881293
) ?? {
12891294
success: false,
@@ -1335,13 +1340,13 @@ export class Cline {
13351340
)
13361341
pushToolResult(
13371342
`The user made the following updates to your content:\n\n${userEdits}\n\n` +
1338-
`The updated content, which includes both your original modifications and the user's edits, has been successfully saved to ${relPath.toPosix()}. Here is the full, updated content of the file, including line numbers:\n\n` +
1339-
`<final_file_content path="${relPath.toPosix()}">\n${addLineNumbers(finalContent || '')}\n</final_file_content>\n\n` +
1340-
`Please note:\n` +
1341-
`1. You do not need to re-write the file with these changes, as they have already been applied.\n` +
1342-
`2. Proceed with the task using this updated file content as the new baseline.\n` +
1343-
`3. If the user's edits have addressed part of the task or changed the requirements, adjust your approach accordingly.` +
1344-
`${newProblemsMessage}`,
1343+
`The updated content, which includes both your original modifications and the user's edits, has been successfully saved to ${relPath.toPosix()}. Here is the full, updated content of the file, including line numbers:\n\n` +
1344+
`<final_file_content path="${relPath.toPosix()}">\n${addLineNumbers(finalContent || '')}\n</final_file_content>\n\n` +
1345+
`Please note:\n` +
1346+
`1. You do not need to re-write the file with these changes, as they have already been applied.\n` +
1347+
`2. Proceed with the task using this updated file content as the new baseline.\n` +
1348+
`3. If the user's edits have addressed part of the task or changed the requirements, adjust your approach accordingly.` +
1349+
`${newProblemsMessage}`,
13451350
)
13461351
} else {
13471352
pushToolResult(`Changes successfully applied to ${relPath.toPosix()}:\n\n${newProblemsMessage}`)
@@ -1367,7 +1372,7 @@ export class Cline {
13671372
...sharedMessageProps,
13681373
content: undefined,
13691374
} satisfies ClineSayTool)
1370-
await this.ask("tool", partialMessage, block.partial).catch(() => { })
1375+
await this.ask("tool", partialMessage, block.partial).catch(() => {})
13711376
break
13721377
} else {
13731378
if (!relPath) {
@@ -1409,7 +1414,7 @@ export class Cline {
14091414
...sharedMessageProps,
14101415
content: "",
14111416
} satisfies ClineSayTool)
1412-
await this.ask("tool", partialMessage, block.partial).catch(() => { })
1417+
await this.ask("tool", partialMessage, block.partial).catch(() => {})
14131418
break
14141419
} else {
14151420
if (!relDirPath) {
@@ -1449,7 +1454,7 @@ export class Cline {
14491454
...sharedMessageProps,
14501455
content: "",
14511456
} satisfies ClineSayTool)
1452-
await this.ask("tool", partialMessage, block.partial).catch(() => { })
1457+
await this.ask("tool", partialMessage, block.partial).catch(() => {})
14531458
break
14541459
} else {
14551460
if (!relDirPath) {
@@ -1494,7 +1499,7 @@ export class Cline {
14941499
...sharedMessageProps,
14951500
content: "",
14961501
} satisfies ClineSayTool)
1497-
await this.ask("tool", partialMessage, block.partial).catch(() => { })
1502+
await this.ask("tool", partialMessage, block.partial).catch(() => {})
14981503
break
14991504
} else {
15001505
if (!relDirPath) {
@@ -1549,7 +1554,7 @@ export class Cline {
15491554
"browser_action_launch",
15501555
removeClosingTag("url", url),
15511556
block.partial
1552-
).catch(() => { })
1557+
).catch(() => {})
15531558
} else {
15541559
await this.say(
15551560
"browser_action",
@@ -1649,7 +1654,8 @@ export class Cline {
16491654
await this.say("browser_action_result", JSON.stringify(browserActionResult))
16501655
pushToolResult(
16511656
formatResponse.toolResult(
1652-
`The browser action has been executed. The console logs and screenshot have been captured for your analysis.\n\nConsole logs:\n${browserActionResult.logs || "(No new logs)"
1657+
`The browser action has been executed. The console logs and screenshot have been captured for your analysis.\n\nConsole logs:\n${
1658+
browserActionResult.logs || "(No new logs)"
16531659
}\n\n(REMEMBER: if you need to proceed to using non-\`browser_action\` tools or launch a new browser, you MUST first close this browser. For example, if after analyzing the logs and screenshot you need to edit a file, you must first close the browser before you can use the write_to_file tool.)`,
16541660
browserActionResult.screenshot ? [browserActionResult.screenshot] : [],
16551661
),
@@ -1676,7 +1682,7 @@ export class Cline {
16761682
try {
16771683
if (block.partial) {
16781684
await this.ask("command", removeClosingTag("command", command), block.partial).catch(
1679-
() => { }
1685+
() => {}
16801686
)
16811687
break
16821688
} else {
@@ -1717,7 +1723,7 @@ export class Cline {
17171723
toolName: removeClosingTag("tool_name", tool_name),
17181724
arguments: removeClosingTag("arguments", mcp_arguments),
17191725
} satisfies ClineAskUseMcpServer)
1720-
await this.ask("use_mcp_server", partialMessage, block.partial).catch(() => { })
1726+
await this.ask("use_mcp_server", partialMessage, block.partial).catch(() => {})
17211727
break
17221728
} else {
17231729
if (!server_name) {
@@ -1778,19 +1784,19 @@ export class Cline {
17781784
// TODO: add progress indicator and ability to parse images and non-text responses
17791785
const toolResultPretty =
17801786
(toolResult?.isError ? "Error:\n" : "") +
1781-
toolResult?.content
1782-
.map((item) => {
1783-
if (item.type === "text") {
1784-
return item.text
1785-
}
1786-
if (item.type === "resource") {
1787-
const { blob, ...rest } = item.resource
1788-
return JSON.stringify(rest, null, 2)
1789-
}
1790-
return ""
1791-
})
1792-
.filter(Boolean)
1793-
.join("\n\n") || "(No response)"
1787+
toolResult?.content
1788+
.map((item) => {
1789+
if (item.type === "text") {
1790+
return item.text
1791+
}
1792+
if (item.type === "resource") {
1793+
const { blob, ...rest } = item.resource
1794+
return JSON.stringify(rest, null, 2)
1795+
}
1796+
return ""
1797+
})
1798+
.filter(Boolean)
1799+
.join("\n\n") || "(No response)"
17941800
await this.say("mcp_server_response", toolResultPretty)
17951801
pushToolResult(formatResponse.toolResult(toolResultPretty))
17961802
break
@@ -1810,7 +1816,7 @@ export class Cline {
18101816
serverName: removeClosingTag("server_name", server_name),
18111817
uri: removeClosingTag("uri", uri),
18121818
} satisfies ClineAskUseMcpServer)
1813-
await this.ask("use_mcp_server", partialMessage, block.partial).catch(() => { })
1819+
await this.ask("use_mcp_server", partialMessage, block.partial).catch(() => {})
18141820
break
18151821
} else {
18161822
if (!server_name) {
@@ -1866,7 +1872,7 @@ export class Cline {
18661872
try {
18671873
if (block.partial) {
18681874
await this.ask("followup", removeClosingTag("question", question), block.partial).catch(
1869-
() => { },
1875+
() => {},
18701876
)
18711877
break
18721878
} else {
@@ -1925,7 +1931,7 @@ export class Cline {
19251931
"command",
19261932
removeClosingTag("command", command),
19271933
block.partial,
1928-
).catch(() => { })
1934+
).catch(() => {})
19291935
} else {
19301936
// last message is completion_result
19311937
// we have command string, which means we have the result as well, so finish it (doesnt have to exist yet)
@@ -1939,7 +1945,7 @@ export class Cline {
19391945
"command",
19401946
removeClosingTag("command", command),
19411947
block.partial,
1942-
).catch(() => { })
1948+
).catch(() => {})
19431949
}
19441950
} else {
19451951
// no command, still outputting partial result
@@ -2165,9 +2171,10 @@ export class Cline {
21652171
type: "text",
21662172
text:
21672173
assistantMessage +
2168-
`\n\n[${cancelReason === "streaming_failed"
2169-
? "Response interrupted by API Error"
2170-
: "Response interrupted by user"
2174+
`\n\n[${
2175+
cancelReason === "streaming_failed"
2176+
? "Response interrupted by API Error"
2177+
: "Response interrupted by user"
21712178
}]`,
21722179
},
21732180
],
@@ -2421,7 +2428,7 @@ export class Cline {
24212428
await pWaitFor(() => busyTerminals.every((t) => !this.terminalManager.isProcessHot(t.id)), {
24222429
interval: 100,
24232430
timeout: 15_000,
2424-
}).catch(() => { })
2431+
}).catch(() => {})
24252432
}
24262433

24272434
// we want to get diagnostics AFTER terminal cools down for a few reasons: terminal could be scaffolding a project, dev servers (compilers like webpack) will first re-compile and then send diagnostics, etc

0 commit comments

Comments
 (0)