Skip to content

Commit e798184

Browse files
committed
Add codebase commands explorer
1 parent be19d45 commit e798184

File tree

3 files changed

+246
-3
lines changed

3 files changed

+246
-3
lines changed
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
import type { AgentDefinition } from './types/agent-definition'
2+
3+
const definition: AgentDefinition = {
4+
id: 'codebase-commands-explorer',
5+
displayName: 'Codebase Commands Explorer',
6+
publisher: 'james',
7+
model: 'openai/gpt-5',
8+
reasoningOptions: {
9+
enabled: true,
10+
effort: 'low',
11+
exclude: true,
12+
},
13+
14+
spawnerPrompt: `Analyzes any project's codebase to comprehensively discover all commands needed to build, test, and run the project. Provides detailed analysis of project structure, tech stack, and working commands with confidence scores.`,
15+
16+
toolNames: ['spawn_agents', 'set_output'],
17+
spawnableAgents: ['codebuff/file-explorer@0.0.4', 'codebuff/read-only-commander-lite@0.0.1'],
18+
19+
inputSchema: {
20+
prompt: {
21+
type: 'string',
22+
description:
23+
'Optional specific focus areas or requirements for the codebase analysis (e.g., "focus on test commands" or "include CI/CD analysis")',
24+
},
25+
},
26+
27+
outputMode: 'structured_output',
28+
outputSchema: {
29+
type: 'object',
30+
properties: {
31+
projectOverview: {
32+
type: 'object',
33+
properties: {
34+
projectType: {
35+
type: 'string',
36+
description:
37+
'Primary project type (e.g., Node.js, Python, Rust, Go, etc.)',
38+
},
39+
techStack: {
40+
type: 'array',
41+
items: { type: 'string' },
42+
description: 'List of technologies, frameworks, and tools detected',
43+
},
44+
packageManagers: {
45+
type: 'array',
46+
items: { type: 'string' },
47+
description:
48+
'Package managers found (npm, yarn, pnpm, pip, cargo, etc.)',
49+
},
50+
buildSystems: {
51+
type: 'array',
52+
items: { type: 'string' },
53+
description:
54+
'Build systems detected (webpack, vite, make, cmake, etc.)',
55+
},
56+
keyFiles: {
57+
type: 'array',
58+
items: { type: 'string' },
59+
description: 'Key configuration files found',
60+
},
61+
},
62+
required: [
63+
'projectType',
64+
'techStack',
65+
'packageManagers',
66+
'buildSystems',
67+
'keyFiles',
68+
],
69+
},
70+
workingCommands: {
71+
type: 'array',
72+
items: {
73+
type: 'object',
74+
properties: {
75+
command: { type: 'string', description: 'The working command' },
76+
description: {
77+
type: 'string',
78+
description: 'What this command does',
79+
},
80+
category: {
81+
type: 'string',
82+
enum: [
83+
'build',
84+
'test',
85+
'run',
86+
'lint',
87+
'format',
88+
'install',
89+
'clean',
90+
'dev',
91+
],
92+
description: 'Command category',
93+
},
94+
confidenceScore: {
95+
type: 'number',
96+
minimum: 0,
97+
maximum: 1,
98+
description: 'Confidence that this command works (0-1)',
99+
},
100+
workingDirectory: {
101+
type: 'string',
102+
description: 'Directory where command should be run',
103+
},
104+
prerequisites: {
105+
type: 'array',
106+
items: { type: 'string' },
107+
description: 'Commands that should be run first',
108+
},
109+
environment: {
110+
type: 'string',
111+
description: 'Required environment or conditions',
112+
},
113+
},
114+
required: ['command', 'description', 'category', 'confidenceScore'],
115+
},
116+
},
117+
setupRequirements: {
118+
type: 'array',
119+
items: {
120+
type: 'object',
121+
properties: {
122+
requirement: {
123+
type: 'string',
124+
description: 'Setup requirement description',
125+
},
126+
commands: {
127+
type: 'array',
128+
items: { type: 'string' },
129+
description: 'Commands to fulfill this requirement',
130+
},
131+
priority: {
132+
type: 'string',
133+
enum: ['critical', 'recommended', 'optional'],
134+
description: 'Priority level',
135+
},
136+
},
137+
required: ['requirement', 'commands', 'priority'],
138+
},
139+
},
140+
cicdAnalysis: {
141+
type: 'object',
142+
properties: {
143+
ciFilesFound: {
144+
type: 'array',
145+
items: { type: 'string' },
146+
description: 'CI/CD configuration files detected',
147+
},
148+
officialCommands: {
149+
type: 'array',
150+
items: { type: 'string' },
151+
description: 'Commands found in CI/CD files',
152+
},
153+
platforms: {
154+
type: 'array',
155+
items: { type: 'string' },
156+
description:
157+
'CI/CD platforms detected (GitHub Actions, GitLab CI, etc.)',
158+
},
159+
},
160+
required: ['ciFilesFound', 'officialCommands', 'platforms'],
161+
},
162+
},
163+
required: [
164+
'projectOverview',
165+
'workingCommands',
166+
'setupRequirements',
167+
'cicdAnalysis',
168+
],
169+
},
170+
171+
systemPrompt: `You are an expert codebase explorer that comprehensively analyzes any software project to discover all build, test, and run commands. You orchestrate multiple specialized agents to explore the project structure and test commands in parallel for maximum efficiency.`,
172+
173+
instructionsPrompt: `Your mission is to provide a comprehensive analysis of any codebase to discover all working commands for building, testing, and running the project.
174+
175+
## Analysis Strategy:
176+
177+
1. **Project Structure Exploration**: First spawn file-explorer to understand the project layout, key files, and technology stack.
178+
179+
2. **Build and Testing Exploration**: Spawn a second file-explorer to learn about the build, lint, and testing processes across the codebase.
180+
181+
3. **Massive Parallel Command Testing**: Only after completing steps 1 and 2, spawn MANY (10-15) read-only-commander agents simultaneously to test different command combinations, including for any relevant sub-directories if this is a monorepo.
182+
Look for commands for the following project types:
183+
- Web apps: next.js, react, vue, etc. commands (build, test, start, dev, lint, etc.)
184+
- Node.js projects: npm/yarn/pnpm commands (build, test, start, dev, lint, etc.)
185+
- Python projects: pip, pytest, setup.py, tox commands
186+
- Rust projects: cargo commands (build, test, run, check, etc.)
187+
...And so on for all project types
188+
189+
Include CI/CD Analysis: Have agents examine CI/CD files (.github/workflows, .gitlab-ci.yml, etc.) to discover official build processes
190+
191+
4. **Final Analysis**: Use the set_output tool to output the results of the analysis. Rate each working command based on:
192+
- Success rate of execution
193+
- Presence in official documentation/CI
194+
- Standard conventions for the project type
195+
- Output quality and expected behavior
196+
197+
## Command Categories to Test:
198+
- **install**: Dependency installation commands
199+
- **build**: Compilation and build commands
200+
- **test**: All types of testing (unit, integration, e2e)
201+
- **run**: Application execution commands
202+
- **dev**: Development server/watch commands
203+
- **lint**: Code linting and static analysis
204+
- **format**: Code formatting commands
205+
- **clean**: Cleanup and reset commands
206+
207+
## Be Extremely Thorough:
208+
- Try multiple package managers if multiple are detected
209+
- Test both short and long command forms
210+
- Check for custom scripts in package.json, Makefile, etc.
211+
- Test commands with different flags and options
212+
- Verify commands work from different directories
213+
- Check for environment-specific requirements
214+
215+
## Special Focus Areas:
216+
- Look for monorepo structures and workspace commands
217+
- Detect containerized setups and associated commands
218+
- Find database setup/migration commands
219+
- Identify development vs production commands
220+
- Discover deployment and release commands
221+
222+
Provide a comprehensive, structured output that gives developers everything they need to understand and work with the codebase immediately.`,
223+
}
224+
225+
export default definition
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { publisher } from './constants'
2+
import {
3+
PLACEHOLDER,
4+
type SecretAgentDefinition,
5+
} from './types/secret-agent-definition'
6+
import readOnlyCommander from './read-only-commander'
7+
8+
const readOnlyCommanderLite: SecretAgentDefinition = {
9+
...readOnlyCommander,
10+
id: 'read-only-commander-lite',
11+
displayName: 'ReadOnly Commander Lite',
12+
publisher,
13+
model: 'x-ai/grok-code-fast-1',
14+
spawnerPrompt:
15+
'Can run quick read-only terminal commands and report back on the results. Has a basic understanding of the codebase. Is speedy and low-cost,',
16+
}
17+
18+
export default readOnlyCommanderLite
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { publisher } from '../constants'
1+
import { publisher } from './constants'
22
import {
33
PLACEHOLDER,
44
type SecretAgentDefinition,
5-
} from '../types/secret-agent-definition'
5+
} from './types/secret-agent-definition'
66

77
const readOnlyCommander: SecretAgentDefinition = {
88
id: 'read-only-commander',
@@ -15,7 +15,7 @@ const readOnlyCommander: SecretAgentDefinition = {
1515
},
1616
displayName: 'ReadOnly Commander',
1717
spawnerPrompt:
18-
'Can run quick read-only terminal commands and report back on the results. Has a basic understanding of the codebase.',
18+
'Can run quick read-only terminal commands and report back on the results. Has a decent understanding of the codebase.',
1919
inputSchema: {
2020
prompt: {
2121
type: 'string',

0 commit comments

Comments
 (0)