Skip to content

Commit 86efd8f

Browse files
committed
Initial base layer
1 parent 8519dba commit 86efd8f

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-0
lines changed

.agents/base2/base-layer.ts

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import { publisher } from '../constants'
2+
import {
3+
PLACEHOLDER,
4+
type SecretAgentDefinition,
5+
} from '../types/secret-agent-definition'
6+
7+
const definition: SecretAgentDefinition = {
8+
id: 'base-layer',
9+
publisher,
10+
model: 'anthropic/claude-sonnet-4.5',
11+
displayName: 'Orchestrator',
12+
spawnerPrompt:
13+
'Advanced base agent that orchestrates planning, editing, and reviewing for complex coding tasks',
14+
inputSchema: {
15+
prompt: {
16+
type: 'string',
17+
description: 'A coding task to complete',
18+
},
19+
params: {
20+
type: 'object',
21+
properties: {
22+
maxContextLength: {
23+
type: 'number',
24+
},
25+
},
26+
required: [],
27+
},
28+
},
29+
outputMode: 'last_message',
30+
includeMessageHistory: true,
31+
toolNames: ['spawn_agents', 'read_files'],
32+
spawnableAgents: [
33+
'read-only-commander',
34+
'file-picker',
35+
'code-searcher',
36+
'researcher-web',
37+
'researcher-docs',
38+
'thinker',
39+
'editor',
40+
'reviewer',
41+
'context-pruner',
42+
],
43+
44+
systemPrompt: `You are Buffy, a strategic coding assistant that orchestrates complex coding tasks through specialized sub-agents.
45+
46+
# Core Mandates
47+
48+
- **Tone:** Adopt a professional, direct, and concise tone suitable for a CLI environment.
49+
- **Orchestrate only:** Coordinate between agents but do not implement code yourself.
50+
- **Understand first, act second:** Always gather context and read relevant files BEFORE spawning code-drafters or editors.
51+
- **Quality over speed:** Prioritize correctness over appearing productive. Fewer, well-informed agents are better than many rushed ones.
52+
- **Spawn mentioned agents:** If the user uses "@AgentName" in their message, you must spawn that agent.
53+
- **No final summary:** When the task is complete, inform the user in one sentence.
54+
- **Validate assumptions:** Use researchers, file pickers, and the read_files tool to verify assumptions about libraries and APIs before implementing.
55+
- **Proactiveness:** Fulfill the user's request thoroughly, including reasonable, directly implied follow-up actions.
56+
- **Confirm Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request without confirming with the user. If asked *how* to do something, explain first, don't just do it.
57+
58+
${PLACEHOLDER.FILE_TREE_PROMPT_SMALL}
59+
${PLACEHOLDER.KNOWLEDGE_FILES_CONTENTS}
60+
61+
# Starting Git Changes
62+
63+
The following is the state of the git repository at the start of the conversation. Note that it is not updated to reflect any subsequent changes made by the user or the agents.
64+
65+
${PLACEHOLDER.GIT_CHANGES_PROMPT}
66+
`,
67+
68+
instructionsPrompt: `Orchestrate the completion of the user's request using your specialized sub-agents.
69+
70+
You spawn agents in "layers". Each layer is one spawn_agents tool call composed of multiple agents that answer your questions, do research, think, edit, and review.
71+
72+
In between layers, you are encouraged to use the read_files tool to read files that you think are relevant to the user's request.
73+
74+
Continue to spawn layers of agents until have completed the user's request or require more information from the user.
75+
76+
## Example layers
77+
78+
The user asks you to implement a new feature. You respond in multiple steps:
79+
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+
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+
2a. Read all the relevant files using the read_files tool.
84+
4. Spawn 2 editors to implement all the changes.
85+
5. Spawn a reviewer to review the changes made by the editors.
86+
87+
88+
## Guidelines
89+
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.
91+
- **Spawn editors later** Only spawn editors after gathering all the context.
92+
- **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.
93+
- **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.
94+
- **Be careful about terminal commands:** Be careful about instructing subagents to run terminal commands that could be destructive or have effects that are hard to undo (e.g. git push, running scripts that could alter production environments, installing packages globally, etc). Don't do any of these unless the user explicitly asks you to.
95+
`,
96+
97+
stepPrompt: `Don't forget to spawn agents that could help, especially: the file-explorer to get codebase context, the thinker to think about key decisions, and the reviewer to review code changes made by the editor.`,
98+
99+
handleSteps: function* ({ prompt, params }) {
100+
let steps = 0
101+
while (true) {
102+
steps++
103+
// Run context-pruner before each step
104+
yield {
105+
toolName: 'spawn_agent_inline',
106+
input: {
107+
agent_type: 'context-pruner',
108+
params: params ?? {},
109+
},
110+
includeToolCall: false,
111+
} as any
112+
113+
const { stepsComplete } = yield 'STEP'
114+
if (stepsComplete) break
115+
}
116+
},
117+
}
118+
119+
export default definition
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { publisher } from '../constants'
2+
3+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
4+
5+
interface SearchQuery {
6+
pattern: string
7+
flags?: string
8+
cwd?: string
9+
maxResults?: number
10+
}
11+
12+
const paramsSchema = {
13+
type: 'object' as const,
14+
properties: {
15+
searchQueries: {
16+
type: 'array' as const,
17+
items: {
18+
type: 'object' as const,
19+
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 },
24+
},
25+
required: ['pattern'],
26+
},
27+
description: 'Array of code search queries to execute',
28+
},
29+
},
30+
required: ['searchQueries'],
31+
}
32+
33+
const codeSearcher: SecretAgentDefinition = {
34+
id: 'code-searcher',
35+
displayName: 'Code Searcher',
36+
spawnerPrompt:
37+
'Mechanically runs multiple code search queries and returns all results',
38+
model: 'anthropic/claude-sonnet-4.5',
39+
publisher,
40+
outputMode: 'all_messages',
41+
includeMessageHistory: false,
42+
toolNames: ['code_search'],
43+
spawnableAgents: [],
44+
inputSchema: {
45+
params: paramsSchema,
46+
},
47+
systemPrompt:
48+
'You are a code searcher agent that executes multiple code search queries and compiles the results. Your goal is to systematically search the codebase using the provided patterns and report all findings.',
49+
instructionsPrompt: `
50+
Execute each code search query provided in the parameters and compile all results.
51+
52+
For each search query, run the code_search tool with the specified pattern, flags, cwd, and maxResults.
53+
54+
After all searches complete, provide a comprehensive summary of the findings, organizing results by search query.
55+
`.trim(),
56+
57+
handleSteps: function* ({ params }) {
58+
const searchQueries: SearchQuery[] = params?.searchQueries ?? []
59+
60+
for (const query of searchQueries) {
61+
yield {
62+
toolName: 'code_search',
63+
input: {
64+
pattern: query.pattern,
65+
flags: query.flags,
66+
cwd: query.cwd,
67+
maxResults: query.maxResults,
68+
},
69+
}
70+
}
71+
},
72+
}
73+
74+
export default codeSearcher

0 commit comments

Comments
 (0)