Skip to content

Commit 91dca8b

Browse files
committed
Update codebase-explorer, add file-q-and-a agent
1 parent 9596ffe commit 91dca8b

File tree

4 files changed

+93
-35
lines changed

4 files changed

+93
-35
lines changed

.agents/base2/base-layer.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const definition: SecretAgentDefinition = {
3636
'researcher-web',
3737
'researcher-docs',
3838
'thinker',
39+
'decomposing-thinker',
3940
'editor',
4041
'reviewer',
4142
'context-pruner',
@@ -77,17 +78,21 @@ Continue to spawn layers of agents until have completed the user's request or re
7778
7879
The user asks you to implement a new feature. You respond in multiple steps:
7980
80-
1. Spawn a 3 file pickers with different prompts to find relevant files; spawn 1 code searcher with a few search queries; spawn 1 docs research to find relevant docs;
81+
1. Spawn 2 file pickers with different prompts to find relevant files; spawn 2 codebase explorers to find more relevant files and answer questions about the codebase; spawn 1 docs research to find relevant docs;
8182
1a. Read all the relevant files using the read_files tool.
82-
2. Spawn 2 more file pickers with different prompts to find relevant files; spawn 1 more code searcher with a few search queries; spawn a thinker with a question on a key decision; spawn a thinker to plan a tricky step.
83+
2. Spawn 1 more file picker and one more codebase explorer with different prompts to find relevant files; spawn a decomposing thinker with a question on a key decision; spawn a decomposing thinker to plan out the feature part-by-part.
8384
2a. Read all the relevant files using the read_files tool.
85+
3. Spawn a decomposing thinker to answer final design and implementation questions.
8486
4. Spawn 2 editors to implement all the changes.
8587
5. Spawn a reviewer to review the changes made by the editors.
8688
8789
8890
## Guidelines
8991
90-
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents: spawn a file picker or researcher before a thinker because then the thinker can use the file picker's results to come up with a better conclusions. Reviewers should be spawned after editors.
92+
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents:
93+
- Spawn file pickers, codebase explorers, and researchers before thinkers because then the thinkers can use the file/research results to come up with a better conclusions
94+
- Spawn thinkers before editors so editors can use the insights from the thinkers.
95+
- Reviewers should be spawned after editors.
9196
- **Spawn editors later** Only spawn editors after gathering all the context.
9297
- **Stop and ask for guidance:** You should feel free to stop and ask the user for guidance if you're stuck or don't know what to try next, or need a clarification.
9398
- **No need to include context:** When prompting an agent, realize that many agents can already see the entire conversation history, so you can be brief in prompting them without needing to include context.

.agents/file-explorer/code-searcher.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,25 @@ const paramsSchema = {
1717
items: {
1818
type: 'object' as const,
1919
properties: {
20-
pattern: { type: 'string' as const },
21-
flags: { type: 'string' as const },
22-
cwd: { type: 'string' as const },
23-
maxResults: { type: 'number' as const },
20+
pattern: {
21+
type: 'string' as const,
22+
description: 'The pattern to search for',
23+
},
24+
flags: {
25+
type: 'string' as const,
26+
description:
27+
'Optional ripgrep flags to customize the search (e.g., "-i" for case-insensitive, "-t ts" for TypeScript files only, "-A 3" for 3 lines after match, "-B 2" for 2 lines before match, "--type-not test" to exclude test files)',
28+
},
29+
cwd: {
30+
type: 'string' as const,
31+
description:
32+
'Optional working directory to search within, relative to the project root. Defaults to searching the entire project',
33+
},
34+
maxResults: {
35+
type: 'number' as const,
36+
description:
37+
'Maximum number of results to return per file. Defaults to 15. There is also a global limit of 250 results across all files',
38+
},
2439
},
2540
required: ['pattern'],
2641
},

.agents/file-explorer/codebase-explorer.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const codebaseExplorer: SecretAgentDefinition = {
1717
'code-searcher',
1818
'directory-lister',
1919
'glob-matcher',
20+
'file-q-and-a',
2021
],
2122
inputSchema: {
2223
prompt: {
@@ -26,36 +27,12 @@ const codebaseExplorer: SecretAgentDefinition = {
2627
},
2728
systemPrompt: `You are a codebase exploration orchestrator. Your job is to spawn multiple specialized agents in parallel waves to comprehensively explore the codebase and answer the user's question.
2829
29-
You have access to these agents:
30-
31-
1. **file-explorer** - Spawns multiple file-picker agents to find relevant files
32-
- Takes a prompt and a "prompts" param with 1-4 specific focus areas
33-
- Example: { prompts: ["authentication logic", "API endpoints", "database models"] }
34-
35-
2. **code-searcher** - Runs multiple ripgrep searches to find code patterns
36-
- Takes a "searchQueries" param with array of search queries
37-
- Each query has: pattern (required), flags, cwd, maxResults
38-
- Example: { searchQueries: [{ pattern: "class.*Auth", flags: "-t ts" }] }
39-
40-
3. **directory-lister** - Lists contents of multiple directories
41-
- Takes a "directories" param with array of directory paths
42-
- Each has: path (required)
43-
- Example: { directories: [{ path: "src/auth" }, { path: "src/api" }] }
44-
45-
4. **glob-matcher** - Matches multiple glob patterns to find files
46-
- Takes a "patterns" param with array of glob patterns
47-
- Each has: pattern (required), cwd (optional)
48-
- Example: { patterns: [{ pattern: "**/*test*.ts" }, { pattern: "*.config.js" }] }
49-
5030
Strategy:
51-
1. Analyze the user's question to determine what exploration approach would be most effective
52-
2. Spawn multiple agents in parallel in the first wave to gather information from different angles
53-
3. Based on the results, you can spawn additional agents in subsequent waves if needed to fill gaps
54-
4. Synthesize all findings into a comprehensive answer`,
55-
56-
instructionsPrompt: `Analyze the user's prompt and spawn appropriate exploration agents in parallel.
31+
1. Analyze the user's question to determine what exploration approach would be most effective.
32+
2. You may spawn agents to help you answer the user's question. Feel free to spawn multiple agents in parallel to gather information from different angles.
33+
3. Synthesize all findings into a comprehensive answer.`,
5734

58-
After reviewing the results, spawn additional agents if needed to fill gaps.
35+
instructionsPrompt: `Analyze the user's prompt and spawn appropriate exploration agents.
5936
6037
Finally, synthesize all findings into a comprehensive answer.`,
6138
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { publisher } from '../constants'
2+
3+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
4+
import type { ToolCall } from 'types/agent-definition'
5+
6+
const paramsSchema = {
7+
type: 'object' as const,
8+
properties: {
9+
filePath: {
10+
type: 'string' as const,
11+
description: 'Path to the file to ask questions about',
12+
},
13+
},
14+
required: ['filePath'],
15+
}
16+
17+
const fileQAndA: SecretAgentDefinition = {
18+
id: 'file-q-and-a',
19+
displayName: 'Quinn the File Q&A',
20+
spawnerPrompt:
21+
'Reads a single file and answers questions about it - can summarize, explain specific parts, or excerpt portions of the file',
22+
model: 'x-ai/grok-4-fast',
23+
publisher,
24+
outputMode: 'last_message',
25+
includeMessageHistory: false,
26+
toolNames: ['read_files'],
27+
spawnableAgents: [],
28+
inputSchema: {
29+
prompt: {
30+
type: 'string',
31+
description:
32+
'A question about the file - can ask for a summary, explanation of specific functionality, or an excerpt of a particular section',
33+
},
34+
params: paramsSchema,
35+
},
36+
systemPrompt:
37+
'You are an expert at reading and analyzing code files. Answer questions about files clearly and accurately. You can provide summaries, explain specific functionality, or excerpt portions of the file. When excerpting, reproduce the code exactly as it appears in the file.',
38+
instructionsPrompt: `
39+
Read the file and answer the user's question about it. Depending on what they're asking:
40+
- For summaries: explain the main purpose, key functions/classes/exports, and important patterns
41+
- For specific questions: focus on the relevant parts and provide clear explanations
42+
- For excerpts: reproduce the requested code exactly as it appears in the file
43+
`.trim(),
44+
stepPrompt: 'Do not use any tools again. Just answer the question about the file.',
45+
46+
handleSteps: function* ({ prompt, params }) {
47+
const filePath = params?.filePath
48+
if (!filePath) {
49+
throw new Error('filePath parameter is required')
50+
}
51+
52+
yield {
53+
toolName: 'read_files',
54+
input: { paths: [filePath] },
55+
} satisfies ToolCall
56+
57+
yield 'STEP_ALL'
58+
},
59+
}
60+
61+
export default fileQAndA

0 commit comments

Comments
 (0)