Skip to content

Commit 813d287

Browse files
committed
core: add explore agent for fast codebase navigation and improve task UI display
1 parent a4f3aec commit 813d287

File tree

5 files changed

+60
-2
lines changed

5 files changed

+60
-2
lines changed

.opencode/opencode.jsonc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,12 @@
1616
"type": "remote",
1717
"url": "https://mcp.exa.ai/mcp",
1818
},
19+
"morph": {
20+
"type": "local",
21+
"command": ["bunx", "@morphllm/morphmcp"],
22+
"environment": {
23+
"ENABLED_TOOLS": "warp_grep",
24+
},
25+
},
1926
},
2027
}

packages/opencode/src/agent/agent.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,41 @@ export namespace Agent {
114114
mode: "subagent",
115115
builtIn: true,
116116
},
117+
explore: {
118+
name: "explore",
119+
tools: {
120+
todoread: false,
121+
todowrite: false,
122+
edit: false,
123+
write: false,
124+
...defaultTools,
125+
},
126+
description: `Fast agent specialized for exploring codebases. Use this when you need to quickly find files by patterns (eg. "src/components/**/*.tsx"), search code for keywords (eg. "API endpoints"), or answer questions about the codebase (eg. "how do API endpoints work?"). When calling this agent, specify the desired thoroughness level: "quick" for basic searches, "medium" for moderate exploration, or "very thorough" for comprehensive analysis across multiple locations and naming conventions. (Tools: All tools)`,
127+
prompt: [
128+
`You are a file search specialist. You excel at thoroughly navigating and exploring codebases.`,
129+
``,
130+
`Your strengths:`,
131+
`- Rapidly finding files using glob patterns`,
132+
`- Searching code and text with powerful regex patterns`,
133+
`- Reading and analyzing file contents`,
134+
``,
135+
`Guidelines:`,
136+
`- Use Glob for broad file pattern matching`,
137+
`- Use Grep for searching file contents with regex`,
138+
`- Use Read when you know the specific file path you need to read`,
139+
`- Use Bash for file operations like copying, moving, or listing directory contents`,
140+
`- Adapt your search approach based on the thoroughness level specified by the caller`,
141+
`- Return file paths as absolute paths in your final response`,
142+
`- For clear communication, avoid using emojis`,
143+
`- Do not create any files, or run bash commands that modify the user's system state in any way`,
144+
``,
145+
`Complete the user's search request efficiently and report your findings clearly.`,
146+
].join("\n"),
147+
options: {},
148+
permission: agentPermission,
149+
mode: "subagent",
150+
builtIn: true,
151+
},
117152
build: {
118153
name: "build",
119154
tools: { ...defaultTools },

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,8 +1405,8 @@ ToolRegistry.register<typeof TaskTool>({
14051405

14061406
return (
14071407
<>
1408-
<ToolTitle icon="%" fallback="Delegating..." when={props.input.subagent_type ?? props.input.description}>
1409-
Task [{props.input.subagent_type ?? "unknown"}] {props.input.description}
1408+
<ToolTitle icon="" fallback="Delegating..." when={props.input.subagent_type ?? props.input.description}>
1409+
{Locale.titlecase(props.input.subagent_type ?? "unknown")} Task "{props.input.description}"
14101410
</ToolTitle>
14111411
<Show when={props.metadata.summary?.length}>
14121412
<box>

packages/opencode/src/config/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ export namespace Config {
527527
plan: Agent.optional(),
528528
build: Agent.optional(),
529529
general: Agent.optional(),
530+
explore: Agent.optional(),
530531
})
531532
.catchall(Agent)
532533
.optional()

packages/opencode/src/provider/provider.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,21 @@ export namespace Provider {
677677
}
678678
}
679679

680+
export async function closest(providerID: string, query: string[]) {
681+
const s = await state()
682+
const provider = s.providers[providerID]
683+
if (!provider) return undefined
684+
for (const item of query) {
685+
for (const modelID of Object.keys(provider.info.models)) {
686+
if (modelID.includes(item))
687+
return {
688+
providerID,
689+
modelID,
690+
}
691+
}
692+
}
693+
}
694+
680695
export async function getSmallModel(providerID: string) {
681696
const cfg = await Config.get()
682697

0 commit comments

Comments
 (0)