Skip to content

Commit 72ddf95

Browse files
committed
Add Grok Build coding agent support to agent search mode
- add support for 'Grok Build' [Pasted text] (https://docs.x.ai/build/cli/headless-scripting) └── apps └── editor └── src └── features └── search-files └── search-modes └── perform-agent-search-mode ├── agents │ ├── antigravity.ts │ ├── claude.ts │ ├── codex.ts │ ├── cursor.ts │ ├── grok.ts │ └── opencode.ts ├── index.ts ├── types.ts └── utils.ts
1 parent 39b4100 commit 72ddf95

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

  • apps/editor/src/features/search-files/search-modes/perform-agent-search-mode
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { agentic_file_search_instructions } from '@/constants/instructions'
2+
import { CodingAgent } from '../types'
3+
import { check_command_exists } from '../utils'
4+
5+
let accumulated_output = ''
6+
7+
export const grok_agent: CodingAgent = {
8+
id: 'grok',
9+
label: 'Grok Build',
10+
cmd: 'grok',
11+
is_installed: () => check_command_exists('grok'),
12+
get_documentation_url: () => 'https://docs.x.ai/build/cli/headless-scripting',
13+
get_args: (query: string) => {
14+
accumulated_output = ''
15+
return [
16+
'-p',
17+
`${agentic_file_search_instructions}\n\n${query}`,
18+
'--output-format',
19+
'streaming-json',
20+
'--always-approve',
21+
'--no-auto-update'
22+
]
23+
},
24+
parse_stream_line: (parsed, report_progress) => {
25+
if (parsed.type === 'tool_call' && parsed.tool) {
26+
report_progress(parsed.tool)
27+
} else if (parsed.type === 'step_update' && parsed.step) {
28+
report_progress(parsed.step)
29+
} else if (parsed.method === 'session/update') {
30+
const update = parsed.params?.update
31+
if (update?.sessionUpdate === 'tool_call' && update.toolName) {
32+
report_progress(update.toolName)
33+
} else if (
34+
update?.sessionUpdate === 'agent_message_chunk' &&
35+
update.content?.text
36+
) {
37+
accumulated_output += update.content.text
38+
return { output: accumulated_output }
39+
}
40+
} else if (parsed.type === 'message_chunk' && parsed.text) {
41+
accumulated_output += parsed.text
42+
return { output: accumulated_output }
43+
} else if (parsed.type === 'message' && parsed.text) {
44+
accumulated_output += parsed.text
45+
return { output: accumulated_output }
46+
}
47+
48+
if (parsed.type === 'result' && parsed.result) {
49+
return {
50+
output:
51+
typeof parsed.result === 'string'
52+
? parsed.result
53+
: parsed.result.text || parsed.result.response || ''
54+
}
55+
} else if (parsed.text && typeof parsed.text === 'string' && !parsed.type) {
56+
// Possible fallback for plain objects
57+
accumulated_output += parsed.text
58+
return { output: accumulated_output }
59+
}
60+
},
61+
parse_final_output: (parsed, current_output) => {
62+
if (parsed.type === 'result' && parsed.result) {
63+
return typeof parsed.result === 'string'
64+
? parsed.result
65+
: parsed.result.text || parsed.result.response || ''
66+
} else if (parsed.text) {
67+
return parsed.text
68+
} else if (parsed.response) {
69+
return parsed.response
70+
} else if (parsed.output) {
71+
return typeof parsed.output === 'string'
72+
? parsed.output
73+
: parsed.output.text || ''
74+
}
75+
return current_output || accumulated_output
76+
}
77+
}

‎apps/editor/src/features/search-files/search-modes/perform-agent-search-mode/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { claude_agent } from './agents/claude'
1919
import { codex_agent } from './agents/codex'
2020
import { cursor_agent } from './agents/cursor'
2121
import { opencode_agent } from './agents/opencode'
22+
import { grok_agent } from './agents/grok'
2223
import { CodingAgent } from './types'
2324
import { format_duration } from './utils'
2425

@@ -27,6 +28,7 @@ const AGENTS: CodingAgent[] = [
2728
codex_agent,
2829
claude_agent,
2930
cursor_agent,
31+
grok_agent,
3032
opencode_agent
3133
]
3234

0 commit comments

Comments
 (0)