Skip to content

Commit 0bf2af0

Browse files
committed
Merge branch 'dev' of github.com:robertpiosik/CodeWebChat into dev
2 parents b759ec9 + 6ef5914 commit 0bf2af0

1 file changed

Lines changed: 23 additions & 29 deletions

File tree

  • apps/editor/src/views/prompt/backend/message-handlers/handle-agentic-search/agents

‎apps/editor/src/views/prompt/backend/message-handlers/handle-agentic-search/agents/claude.ts‎

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,27 @@
11
import { CodingAgent } from '../types'
2-
import { build_agent_prompt, check_command_exists } from '../utils'
2+
import {
3+
build_agent_prompt,
4+
check_command_exists,
5+
get_progress_dots
6+
} from '../utils'
7+
8+
let last_action_name = ''
9+
let action_count = 0
310

411
const report_tool_progress = (
512
tool_name: string,
6-
input: any,
713
report_progress: (msg: string) => void
814
) => {
9-
const formatted_name = tool_name.toLowerCase()
10-
let msg: string | undefined
15+
const action_name = tool_name.replace(/_/g, ' ').toLowerCase()
1116

12-
if (
13-
formatted_name.includes('bash') ||
14-
formatted_name.includes('command') ||
15-
formatted_name.includes('run')
16-
) {
17-
msg = input?.command || input?.cmd || input?.CommandLine
18-
} else if (
19-
formatted_name.includes('read') ||
20-
formatted_name.includes('write') ||
21-
formatted_name.includes('edit') ||
22-
formatted_name.includes('list')
23-
) {
24-
msg = input?.file_path || input?.path
25-
} else if (
26-
formatted_name.includes('grep') ||
27-
formatted_name.includes('search') ||
28-
formatted_name.includes('find')
29-
) {
30-
msg = input?.pattern || input?.query
17+
if (action_name === last_action_name) {
18+
action_count++
3119
} else {
32-
msg = input?.file_path || input?.path || tool_name
20+
last_action_name = action_name
21+
action_count = 1
3322
}
3423

35-
if (msg) {
36-
report_progress(msg)
37-
}
24+
report_progress(`${action_name}${get_progress_dots(action_count)}`)
3825
}
3926

4027
export const claude_agent: CodingAgent = {
@@ -61,7 +48,7 @@ export const claude_agent: CodingAgent = {
6148
) {
6249
const tool = parsed.event.content_block
6350
if (tool.name) {
64-
report_tool_progress(tool.name, tool.input, report_progress)
51+
report_tool_progress(tool.name, report_progress)
6552
}
6653
}
6754
} else if (parsed.type == 'assistant' && parsed.message?.content) {
@@ -71,17 +58,21 @@ export const claude_agent: CodingAgent = {
7158

7259
for (const block of content) {
7360
if (block?.type == 'tool_use' && block.name) {
74-
report_tool_progress(block.name, block.input, report_progress)
61+
report_tool_progress(block.name, report_progress)
7562
}
7663
}
7764
} else if (parsed.type == 'result' && parsed.result) {
65+
last_action_name = ''
66+
action_count = 0
7867
return {
7968
output:
8069
typeof parsed.result == 'string'
8170
? parsed.result
8271
: parsed.result.text || ''
8372
}
8473
} else if (parsed.result) {
74+
last_action_name = ''
75+
action_count = 0
8576
return {
8677
output:
8778
typeof parsed.result == 'string'
@@ -91,6 +82,9 @@ export const claude_agent: CodingAgent = {
9182
}
9283
},
9384
parse_final_output: (parsed, current_output) => {
85+
last_action_name = ''
86+
action_count = 0
87+
9488
if (parsed.type == 'result' && parsed.result) {
9589
return typeof parsed.result == 'string'
9690
? parsed.result

0 commit comments

Comments
 (0)