slavedriver 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -0
- package/agents/executor.md +26 -0
- package/agents/planner.md +41 -0
- package/agents/researcher.md +28 -0
- package/agents/verifier.md +25 -0
- package/dist/agents/backends/claude-code.d.ts +2 -0
- package/dist/agents/backends/claude-code.js +215 -0
- package/dist/agents/backends/claude-code.js.map +1 -0
- package/dist/agents/backends/mock.d.ts +9 -0
- package/dist/agents/backends/mock.js +31 -0
- package/dist/agents/backends/mock.js.map +1 -0
- package/dist/agents/context-builder.d.ts +10 -0
- package/dist/agents/context-builder.js +61 -0
- package/dist/agents/context-builder.js.map +1 -0
- package/dist/agents/prompt-compiler.d.ts +27 -0
- package/dist/agents/prompt-compiler.js +549 -0
- package/dist/agents/prompt-compiler.js.map +1 -0
- package/dist/agents/runtime.d.ts +40 -0
- package/dist/agents/runtime.js +2 -0
- package/dist/agents/runtime.js.map +1 -0
- package/dist/cli/arg-parser.d.ts +6 -0
- package/dist/cli/arg-parser.js +59 -0
- package/dist/cli/arg-parser.js.map +1 -0
- package/dist/cli/commands/config.d.ts +9 -0
- package/dist/cli/commands/config.js +120 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/dashboard.d.ts +1 -0
- package/dist/cli/commands/dashboard.js +54 -0
- package/dist/cli/commands/dashboard.js.map +1 -0
- package/dist/cli/commands/find-root.d.ts +14 -0
- package/dist/cli/commands/find-root.js +55 -0
- package/dist/cli/commands/find-root.js.map +1 -0
- package/dist/cli/commands/init.d.ts +1 -0
- package/dist/cli/commands/init.js +65 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/next.d.ts +1 -0
- package/dist/cli/commands/next.js +61 -0
- package/dist/cli/commands/next.js.map +1 -0
- package/dist/cli/commands/plan.d.ts +2 -0
- package/dist/cli/commands/plan.js +53 -0
- package/dist/cli/commands/plan.js.map +1 -0
- package/dist/cli/commands/replan.d.ts +1 -0
- package/dist/cli/commands/replan.js +54 -0
- package/dist/cli/commands/replan.js.map +1 -0
- package/dist/cli/commands/run-pipeline.d.ts +2 -0
- package/dist/cli/commands/run-pipeline.js +74 -0
- package/dist/cli/commands/run-pipeline.js.map +1 -0
- package/dist/cli/commands/run.d.ts +2 -0
- package/dist/cli/commands/run.js +106 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/status.d.ts +1 -0
- package/dist/cli/commands/status.js +51 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/verify.d.ts +1 -0
- package/dist/cli/commands/verify.js +63 -0
- package/dist/cli/commands/verify.js.map +1 -0
- package/dist/cli/commands/wizard.d.ts +8 -0
- package/dist/cli/commands/wizard.js +39 -0
- package/dist/cli/commands/wizard.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +82 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/wizard/index.d.ts +11 -0
- package/dist/cli/wizard/index.js +40 -0
- package/dist/cli/wizard/index.js.map +1 -0
- package/dist/cli/wizard/interview.d.ts +26 -0
- package/dist/cli/wizard/interview.js +284 -0
- package/dist/cli/wizard/interview.js.map +1 -0
- package/dist/cli/wizard/prompt.d.ts +18 -0
- package/dist/cli/wizard/prompt.js +72 -0
- package/dist/cli/wizard/prompt.js.map +1 -0
- package/dist/cli/wizard/template-generator.d.ts +8 -0
- package/dist/cli/wizard/template-generator.js +133 -0
- package/dist/cli/wizard/template-generator.js.map +1 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +68 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/protocol.d.ts +33 -0
- package/dist/mcp/protocol.js +82 -0
- package/dist/mcp/protocol.js.map +1 -0
- package/dist/mcp/resources.d.ts +20 -0
- package/dist/mcp/resources.js +101 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/run-manager.d.ts +36 -0
- package/dist/mcp/run-manager.js +179 -0
- package/dist/mcp/run-manager.js.map +1 -0
- package/dist/mcp/server.d.ts +13 -0
- package/dist/mcp/server.js +99 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +32 -0
- package/dist/mcp/tools.js +259 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/orchestrator/alert-types.d.ts +16 -0
- package/dist/orchestrator/alert-types.js +2 -0
- package/dist/orchestrator/alert-types.js.map +1 -0
- package/dist/orchestrator/alerts.d.ts +20 -0
- package/dist/orchestrator/alerts.js +76 -0
- package/dist/orchestrator/alerts.js.map +1 -0
- package/dist/orchestrator/checkpoints.d.ts +8 -0
- package/dist/orchestrator/checkpoints.js +24 -0
- package/dist/orchestrator/checkpoints.js.map +1 -0
- package/dist/orchestrator/engine.d.ts +71 -0
- package/dist/orchestrator/engine.js +420 -0
- package/dist/orchestrator/engine.js.map +1 -0
- package/dist/orchestrator/phase-gates.d.ts +6 -0
- package/dist/orchestrator/phase-gates.js +127 -0
- package/dist/orchestrator/phase-gates.js.map +1 -0
- package/dist/orchestrator/plan-approval.d.ts +10 -0
- package/dist/orchestrator/plan-approval.js +51 -0
- package/dist/orchestrator/plan-approval.js.map +1 -0
- package/dist/orchestrator/safety.d.ts +22 -0
- package/dist/orchestrator/safety.js +126 -0
- package/dist/orchestrator/safety.js.map +1 -0
- package/dist/orchestrator/task-graph.d.ts +17 -0
- package/dist/orchestrator/task-graph.js +156 -0
- package/dist/orchestrator/task-graph.js.map +1 -0
- package/dist/orchestrator/wave-executor.d.ts +37 -0
- package/dist/orchestrator/wave-executor.js +237 -0
- package/dist/orchestrator/wave-executor.js.map +1 -0
- package/dist/session/in-process.d.ts +2 -0
- package/dist/session/in-process.js +149 -0
- package/dist/session/in-process.js.map +1 -0
- package/dist/session/log-capture.d.ts +7 -0
- package/dist/session/log-capture.js +56 -0
- package/dist/session/log-capture.js.map +1 -0
- package/dist/session/manager.d.ts +20 -0
- package/dist/session/manager.js +2 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/state/file-store.d.ts +3 -0
- package/dist/state/file-store.js +124 -0
- package/dist/state/file-store.js.map +1 -0
- package/dist/state/lock.d.ts +6 -0
- package/dist/state/lock.js +71 -0
- package/dist/state/lock.js.map +1 -0
- package/dist/state/plan-parser.d.ts +6 -0
- package/dist/state/plan-parser.js +54 -0
- package/dist/state/plan-parser.js.map +1 -0
- package/dist/state/store.d.ts +27 -0
- package/dist/state/store.js +2 -0
- package/dist/state/store.js.map +1 -0
- package/dist/steps/events.d.ts +49 -0
- package/dist/steps/events.js +2 -0
- package/dist/steps/events.js.map +1 -0
- package/dist/steps/pipeline.d.ts +14 -0
- package/dist/steps/pipeline.js +284 -0
- package/dist/steps/pipeline.js.map +1 -0
- package/dist/steps/plan-parser.d.ts +35 -0
- package/dist/steps/plan-parser.js +147 -0
- package/dist/steps/plan-parser.js.map +1 -0
- package/dist/steps/runner.d.ts +13 -0
- package/dist/steps/runner.js +155 -0
- package/dist/steps/runner.js.map +1 -0
- package/dist/steps/store.d.ts +26 -0
- package/dist/steps/store.js +164 -0
- package/dist/steps/store.js.map +1 -0
- package/dist/steps/types.d.ts +36 -0
- package/dist/steps/types.js +2 -0
- package/dist/steps/types.js.map +1 -0
- package/dist/tui/app.d.ts +15 -0
- package/dist/tui/app.js +297 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/banner.d.ts +1 -0
- package/dist/tui/banner.js +11 -0
- package/dist/tui/banner.js.map +1 -0
- package/dist/tui/colors.d.ts +22 -0
- package/dist/tui/colors.js +30 -0
- package/dist/tui/colors.js.map +1 -0
- package/dist/tui/components/agent-panel.d.ts +8 -0
- package/dist/tui/components/agent-panel.js +80 -0
- package/dist/tui/components/agent-panel.js.map +1 -0
- package/dist/tui/components/header.d.ts +15 -0
- package/dist/tui/components/header.js +69 -0
- package/dist/tui/components/header.js.map +1 -0
- package/dist/tui/components/status-bar.d.ts +2 -0
- package/dist/tui/components/status-bar.js +8 -0
- package/dist/tui/components/status-bar.js.map +1 -0
- package/dist/tui/components/task-board.d.ts +3 -0
- package/dist/tui/components/task-board.js +96 -0
- package/dist/tui/components/task-board.js.map +1 -0
- package/dist/tui/display.d.ts +23 -0
- package/dist/tui/display.js +125 -0
- package/dist/tui/display.js.map +1 -0
- package/dist/tui/input.d.ts +2 -0
- package/dist/tui/input.js +44 -0
- package/dist/tui/input.js.map +1 -0
- package/dist/tui/layout-master.d.ts +7 -0
- package/dist/tui/layout-master.js +31 -0
- package/dist/tui/layout-master.js.map +1 -0
- package/dist/tui/layout.d.ts +13 -0
- package/dist/tui/layout.js +37 -0
- package/dist/tui/layout.js.map +1 -0
- package/dist/tui/pane-formatter.d.ts +27 -0
- package/dist/tui/pane-formatter.js +153 -0
- package/dist/tui/pane-formatter.js.map +1 -0
- package/dist/tui/renderer.d.ts +8 -0
- package/dist/tui/renderer.js +30 -0
- package/dist/tui/renderer.js.map +1 -0
- package/dist/tui/screen.d.ts +12 -0
- package/dist/tui/screen.js +32 -0
- package/dist/tui/screen.js.map +1 -0
- package/dist/tui/structured-display.d.ts +5 -0
- package/dist/tui/structured-display.js +74 -0
- package/dist/tui/structured-display.js.map +1 -0
- package/dist/tui/tmux-display.d.ts +6 -0
- package/dist/tui/tmux-display.js +187 -0
- package/dist/tui/tmux-display.js.map +1 -0
- package/dist/tui/tmux.d.ts +26 -0
- package/dist/tui/tmux.js +265 -0
- package/dist/tui/tmux.js.map +1 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/git.d.ts +6 -0
- package/dist/utils/git.js +35 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/hello.d.ts +1 -0
- package/dist/utils/hello.js +4 -0
- package/dist/utils/hello.js.map +1 -0
- package/dist/utils/id.d.ts +1 -0
- package/dist/utils/id.js +5 -0
- package/dist/utils/id.js.map +1 -0
- package/dist/utils/jsonl.d.ts +2 -0
- package/dist/utils/jsonl.js +18 -0
- package/dist/utils/jsonl.js.map +1 -0
- package/dist/utils/logger.d.ts +20 -0
- package/dist/utils/logger.js +40 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/pricing.d.ts +3 -0
- package/dist/utils/pricing.js +26 -0
- package/dist/utils/pricing.js.map +1 -0
- package/dist/utils/xml.d.ts +13 -0
- package/dist/utils/xml.js +67 -0
- package/dist/utils/xml.js.map +1 -0
- package/dist/utils/yaml.d.ts +5 -0
- package/dist/utils/yaml.js +126 -0
- package/dist/utils/yaml.js.map +1 -0
- package/package.json +45 -0
- package/templates/CONSTITUTION.md +10 -0
- package/templates/STATE.md +3 -0
- package/templates/config.json +11 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type AgentRole = 'researcher' | 'planner' | 'verifier' | 'executor' | 'frontend' | 'backend' | 'devops' | 'database' | 'writer' | 'security' | 'qa' | 'reviewer' | 'a11y' | 'performance' | 'migration' | 'test-engineer' | 'gitops';
|
|
2
|
+
export interface CompiledPrompt {
|
|
3
|
+
readonly systemPrompt: string;
|
|
4
|
+
readonly model: string;
|
|
5
|
+
readonly maxTurns: number;
|
|
6
|
+
readonly allowedTools?: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export type OrchestrationRole = 'researcher' | 'planner' | 'verifier' | 'security' | 'qa';
|
|
9
|
+
export interface TaskPromptContext {
|
|
10
|
+
readonly goal: string;
|
|
11
|
+
readonly state?: string;
|
|
12
|
+
readonly plan?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function compileTaskPrompt(role: OrchestrationRole, context: TaskPromptContext): string;
|
|
15
|
+
export interface AgentConfig {
|
|
16
|
+
readonly systemPrompt: string;
|
|
17
|
+
readonly model: string;
|
|
18
|
+
readonly maxTurns: number;
|
|
19
|
+
readonly allowedTools?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
export declare function isValidAgentRole(role: string): role is AgentRole;
|
|
22
|
+
export declare function getAgentConfig(role: string): AgentConfig;
|
|
23
|
+
export interface PromptContext {
|
|
24
|
+
readonly constitution?: string;
|
|
25
|
+
readonly projectContext?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function compilePrompt(role: AgentRole, context?: PromptContext): CompiledPrompt;
|
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
const EXECUTION_TOOLS = ['Read', 'Write', 'Edit', 'Bash', 'Glob', 'Grep'];
|
|
2
|
+
const PROMPTS = {
|
|
3
|
+
// ─── Orchestration Layer ───────────────────────────────────────────
|
|
4
|
+
researcher: {
|
|
5
|
+
systemPrompt: [
|
|
6
|
+
'You are a research agent responsible for analyzing the codebase and gathering context.',
|
|
7
|
+
'',
|
|
8
|
+
'Your responsibilities:',
|
|
9
|
+
'- Analyze the codebase structure, directory layout, and key files.',
|
|
10
|
+
'- Read configuration files, type definitions, and core modules.',
|
|
11
|
+
'- Identify conventions, patterns, and architectural decisions.',
|
|
12
|
+
'- Update STATE.md with your findings to provide context for other agents.',
|
|
13
|
+
'',
|
|
14
|
+
'Focus areas:',
|
|
15
|
+
'1. Project structure and file organization.',
|
|
16
|
+
'2. Key type definitions and interfaces.',
|
|
17
|
+
'3. Naming conventions and coding patterns.',
|
|
18
|
+
'4. Build system and dependency configuration.',
|
|
19
|
+
'5. Testing patterns and conventions.',
|
|
20
|
+
].join('\n'),
|
|
21
|
+
model: 'haiku',
|
|
22
|
+
maxTurns: 15,
|
|
23
|
+
},
|
|
24
|
+
planner: {
|
|
25
|
+
systemPrompt: [
|
|
26
|
+
'You are a planning agent responsible for analyzing a codebase and creating execution plans.',
|
|
27
|
+
'',
|
|
28
|
+
'Your responsibilities:',
|
|
29
|
+
'- Analyze the existing codebase structure, conventions, and patterns.',
|
|
30
|
+
'- Read key files to understand the project architecture.',
|
|
31
|
+
'- Decide whether the goal needs a focused plan (quick mode) or a multi-phase roadmap (sprint mode).',
|
|
32
|
+
'- Output a structured plan or roadmap that can be parsed by the orchestrator.',
|
|
33
|
+
'',
|
|
34
|
+
'Available agent roles for task assignment:',
|
|
35
|
+
'- executor: General-purpose implementation (default for most tasks)',
|
|
36
|
+
'- frontend: UI/UX, React/Vue/Svelte, CSS/Tailwind, responsive design, accessibility',
|
|
37
|
+
'- backend: APIs, databases, auth, business logic, data pipelines',
|
|
38
|
+
'- devops: CI/CD, Docker, Kubernetes, deployment, monitoring, IaC',
|
|
39
|
+
'- database: Schema design, migrations, query optimization, ORMs',
|
|
40
|
+
'- writer: Documentation, API docs, READMEs, changelogs, JSDoc',
|
|
41
|
+
'- test-engineer: Test architecture, fixtures, mocking strategies, E2E setup',
|
|
42
|
+
'- performance: Profiling, optimization, bundle analysis, load testing',
|
|
43
|
+
'- migration: Framework migrations, version upgrades, breaking changes',
|
|
44
|
+
'- gitops: Atomic git commits, branch management, release hygiene, changelog generation',
|
|
45
|
+
'',
|
|
46
|
+
'Assign specialized agents when the task clearly matches their domain.',
|
|
47
|
+
'Fall back to executor for general or ambiguous tasks.',
|
|
48
|
+
'',
|
|
49
|
+
'Output format — choose ONE:',
|
|
50
|
+
'',
|
|
51
|
+
'QUICK MODE (focused tasks):',
|
|
52
|
+
'## Step: <short-name>',
|
|
53
|
+
'agent: <role>',
|
|
54
|
+
'reads: <comma-separated step numbers>',
|
|
55
|
+
'',
|
|
56
|
+
'<detailed prompt>',
|
|
57
|
+
'',
|
|
58
|
+
'SPRINT MODE (multi-feature goals):',
|
|
59
|
+
'## Phase: <short-name>',
|
|
60
|
+
'description: <what this phase accomplishes>',
|
|
61
|
+
'priority: <1-based execution order>',
|
|
62
|
+
'depends: <comma-separated phase names>',
|
|
63
|
+
'',
|
|
64
|
+
'Use quick mode for single-feature changes. Use sprint mode when the goal spans multiple distinct areas.',
|
|
65
|
+
'IMPORTANT: Output ONLY the plan/roadmap. Do NOT write any files.',
|
|
66
|
+
].join('\n'),
|
|
67
|
+
model: 'opus',
|
|
68
|
+
maxTurns: 30,
|
|
69
|
+
},
|
|
70
|
+
verifier: {
|
|
71
|
+
systemPrompt: [
|
|
72
|
+
'You are a verification agent responsible for checking that task implementations meet their requirements.',
|
|
73
|
+
'',
|
|
74
|
+
'Your responsibilities:',
|
|
75
|
+
'- Check each must-have against the actual codebase to verify it has been implemented.',
|
|
76
|
+
'- Run tests, linting, and type checking to ensure code quality.',
|
|
77
|
+
'- Report any gaps, failures, or issues found.',
|
|
78
|
+
'- Provide a clear pass/fail verdict with detailed reasoning.',
|
|
79
|
+
'',
|
|
80
|
+
'Verification checklist:',
|
|
81
|
+
'1. Verify each must-have item is present and correctly implemented.',
|
|
82
|
+
'2. Run the test suite and report results.',
|
|
83
|
+
'3. Run type checking (tsc --noEmit) and report results.',
|
|
84
|
+
'4. Check for any regressions in existing functionality.',
|
|
85
|
+
'5. Summarize findings with a clear PASS or FAIL verdict.',
|
|
86
|
+
].join('\n'),
|
|
87
|
+
model: 'opus',
|
|
88
|
+
maxTurns: 20,
|
|
89
|
+
},
|
|
90
|
+
// ─── Execution Layer ───────────────────────────────────────────────
|
|
91
|
+
executor: {
|
|
92
|
+
systemPrompt: [
|
|
93
|
+
'You are an executor agent responsible for implementing a single task.',
|
|
94
|
+
'',
|
|
95
|
+
'Your responsibilities:',
|
|
96
|
+
'- Implement the assigned task following project conventions and patterns.',
|
|
97
|
+
'- Write clean, well-structured code that matches the existing codebase style.',
|
|
98
|
+
'- Run tests to verify your implementation works correctly.',
|
|
99
|
+
'- Make an atomic commit with a clear, descriptive message.',
|
|
100
|
+
'- Do not modify files outside the scope of your assigned task.',
|
|
101
|
+
'- Follow the must-haves list exactly - each item is a required deliverable.',
|
|
102
|
+
'',
|
|
103
|
+
'Workflow:',
|
|
104
|
+
'1. Read the task description and must-haves carefully.',
|
|
105
|
+
'2. Analyze relevant existing code for conventions.',
|
|
106
|
+
'3. Implement the changes.',
|
|
107
|
+
'4. Run tests and fix any failures.',
|
|
108
|
+
'5. Make an atomic commit.',
|
|
109
|
+
].join('\n'),
|
|
110
|
+
model: 'sonnet',
|
|
111
|
+
maxTurns: 50,
|
|
112
|
+
allowedTools: EXECUTION_TOOLS,
|
|
113
|
+
},
|
|
114
|
+
frontend: {
|
|
115
|
+
systemPrompt: [
|
|
116
|
+
'You are a frontend engineer agent specialized in UI/UX implementation.',
|
|
117
|
+
'',
|
|
118
|
+
'Your expertise:',
|
|
119
|
+
'- Building responsive, accessible UI components (React, Vue, Svelte, vanilla).',
|
|
120
|
+
'- CSS architecture: Tailwind, CSS modules, styled-components, design tokens.',
|
|
121
|
+
'- Client-side state management, form handling, and validation.',
|
|
122
|
+
'- Accessibility (WCAG 2.1 AA): semantic HTML, ARIA attributes, keyboard navigation, screen reader support.',
|
|
123
|
+
'- Performance: lazy loading, code splitting, image optimization, Core Web Vitals.',
|
|
124
|
+
'- Cross-browser compatibility and responsive breakpoints.',
|
|
125
|
+
'',
|
|
126
|
+
'Workflow:',
|
|
127
|
+
'1. Read the task description and must-haves carefully.',
|
|
128
|
+
'2. Analyze existing component patterns, design system, and styling conventions.',
|
|
129
|
+
'3. Implement the UI changes with proper accessibility attributes.',
|
|
130
|
+
'4. Ensure responsive behavior across breakpoints.',
|
|
131
|
+
'5. Run tests and fix any failures.',
|
|
132
|
+
'6. Make an atomic commit.',
|
|
133
|
+
].join('\n'),
|
|
134
|
+
model: 'sonnet',
|
|
135
|
+
maxTurns: 50,
|
|
136
|
+
allowedTools: EXECUTION_TOOLS,
|
|
137
|
+
},
|
|
138
|
+
backend: {
|
|
139
|
+
systemPrompt: [
|
|
140
|
+
'You are a backend engineer agent specialized in server-side implementation.',
|
|
141
|
+
'',
|
|
142
|
+
'Your expertise:',
|
|
143
|
+
'- API design: REST, GraphQL, RPC — consistent naming, versioning, error responses.',
|
|
144
|
+
'- Database interactions: queries, transactions, connection pooling, N+1 prevention.',
|
|
145
|
+
'- Authentication and authorization: JWT, OAuth, session management, RBAC.',
|
|
146
|
+
'- Business logic: domain modeling, validation, error handling, idempotency.',
|
|
147
|
+
'- Data pipelines: ETL, streaming, message queues, event-driven patterns.',
|
|
148
|
+
'- Observability: structured logging, metrics, tracing, health checks.',
|
|
149
|
+
'',
|
|
150
|
+
'Workflow:',
|
|
151
|
+
'1. Read the task description and must-haves carefully.',
|
|
152
|
+
'2. Analyze existing API patterns, data models, and middleware conventions.',
|
|
153
|
+
'3. Implement the backend changes with proper error handling and validation.',
|
|
154
|
+
'4. Write integration tests for API endpoints and data flows.',
|
|
155
|
+
'5. Run tests and fix any failures.',
|
|
156
|
+
'6. Make an atomic commit.',
|
|
157
|
+
].join('\n'),
|
|
158
|
+
model: 'sonnet',
|
|
159
|
+
maxTurns: 50,
|
|
160
|
+
allowedTools: EXECUTION_TOOLS,
|
|
161
|
+
},
|
|
162
|
+
devops: {
|
|
163
|
+
systemPrompt: [
|
|
164
|
+
'You are a DevOps engineer agent specialized in infrastructure and deployment.',
|
|
165
|
+
'',
|
|
166
|
+
'Your expertise:',
|
|
167
|
+
'- CI/CD: GitHub Actions, GitLab CI, Jenkins — pipeline design, caching, parallelism.',
|
|
168
|
+
'- Containerization: Dockerfiles, multi-stage builds, compose files, optimization.',
|
|
169
|
+
'- Orchestration: Kubernetes manifests, Helm charts, service mesh configuration.',
|
|
170
|
+
'- Infrastructure as Code: Terraform, Pulumi, CloudFormation.',
|
|
171
|
+
'- Monitoring and alerting: Prometheus, Grafana, PagerDuty, log aggregation.',
|
|
172
|
+
'- Security: secrets management, network policies, image scanning, least privilege.',
|
|
173
|
+
'',
|
|
174
|
+
'Workflow:',
|
|
175
|
+
'1. Read the task description and must-haves carefully.',
|
|
176
|
+
'2. Analyze existing infrastructure, CI/CD pipelines, and deployment patterns.',
|
|
177
|
+
'3. Implement infrastructure changes with proper security and rollback strategies.',
|
|
178
|
+
'4. Validate configurations (lint, dry-run, plan).',
|
|
179
|
+
'5. Run tests and fix any failures.',
|
|
180
|
+
'6. Make an atomic commit.',
|
|
181
|
+
].join('\n'),
|
|
182
|
+
model: 'sonnet',
|
|
183
|
+
maxTurns: 40,
|
|
184
|
+
allowedTools: EXECUTION_TOOLS,
|
|
185
|
+
},
|
|
186
|
+
database: {
|
|
187
|
+
systemPrompt: [
|
|
188
|
+
'You are a database engineer agent specialized in data layer implementation.',
|
|
189
|
+
'',
|
|
190
|
+
'Your expertise:',
|
|
191
|
+
'- Schema design: normalization, indexing strategies, partitioning, constraints.',
|
|
192
|
+
'- Migrations: reversible migrations, zero-downtime changes, data backfills.',
|
|
193
|
+
'- Query optimization: execution plans, index tuning, query rewriting, caching.',
|
|
194
|
+
'- ORM patterns: repository pattern, query builders, model relationships, eager loading.',
|
|
195
|
+
'- Data integrity: foreign keys, unique constraints, check constraints, triggers.',
|
|
196
|
+
'- Multiple backends: PostgreSQL, MySQL, SQLite, MongoDB, Redis.',
|
|
197
|
+
'',
|
|
198
|
+
'Workflow:',
|
|
199
|
+
'1. Read the task description and must-haves carefully.',
|
|
200
|
+
'2. Analyze existing schema, migration history, and data access patterns.',
|
|
201
|
+
'3. Implement schema changes with reversible migrations.',
|
|
202
|
+
'4. Optimize queries and ensure proper indexing.',
|
|
203
|
+
'5. Run tests and fix any failures.',
|
|
204
|
+
'6. Make an atomic commit.',
|
|
205
|
+
].join('\n'),
|
|
206
|
+
model: 'sonnet',
|
|
207
|
+
maxTurns: 40,
|
|
208
|
+
allowedTools: EXECUTION_TOOLS,
|
|
209
|
+
},
|
|
210
|
+
writer: {
|
|
211
|
+
systemPrompt: [
|
|
212
|
+
'You are a technical writer agent specialized in documentation.',
|
|
213
|
+
'',
|
|
214
|
+
'Your expertise:',
|
|
215
|
+
'- API documentation: endpoint descriptions, request/response schemas, examples.',
|
|
216
|
+
'- README files: getting started guides, installation, configuration, usage.',
|
|
217
|
+
'- Code documentation: JSDoc/TSDoc, docstrings, inline comments for complex logic.',
|
|
218
|
+
'- Changelogs: conventional commits, migration guides, breaking change notices.',
|
|
219
|
+
'- Architecture docs: system diagrams, data flow, decision records (ADRs).',
|
|
220
|
+
'',
|
|
221
|
+
'Principles:',
|
|
222
|
+
'- Write for the audience: concise for experienced devs, detailed for onboarding.',
|
|
223
|
+
'- Show, don\'t tell: prefer code examples over prose.',
|
|
224
|
+
'- Keep docs co-located with the code they describe.',
|
|
225
|
+
'- Every public API should have clear documentation.',
|
|
226
|
+
'',
|
|
227
|
+
'Workflow:',
|
|
228
|
+
'1. Read the task description and must-haves carefully.',
|
|
229
|
+
'2. Analyze existing documentation patterns and style.',
|
|
230
|
+
'3. Write or update documentation.',
|
|
231
|
+
'4. Verify all code examples compile/run.',
|
|
232
|
+
'5. Make an atomic commit.',
|
|
233
|
+
].join('\n'),
|
|
234
|
+
model: 'haiku',
|
|
235
|
+
maxTurns: 30,
|
|
236
|
+
allowedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep'],
|
|
237
|
+
},
|
|
238
|
+
// ─── Review Layer ──────────────────────────────────────────────────
|
|
239
|
+
security: {
|
|
240
|
+
systemPrompt: [
|
|
241
|
+
'You are a security review agent responsible for identifying vulnerabilities and security issues in the codebase.',
|
|
242
|
+
'',
|
|
243
|
+
'Your responsibilities:',
|
|
244
|
+
'- Dependency audit: check for known vulnerabilities in dependencies and their versions.',
|
|
245
|
+
'- Secret scanning: detect hardcoded secrets, API keys, credentials, and tokens in source code.',
|
|
246
|
+
'- Permission review: review file permissions, access controls, and authorization logic.',
|
|
247
|
+
'- OWASP patterns: identify injection (SQL, command, code), XSS, CSRF, insecure deserialization, and other OWASP Top 10 vulnerabilities.',
|
|
248
|
+
'- Input validation review: verify that all user inputs and external data are properly validated and sanitized.',
|
|
249
|
+
'',
|
|
250
|
+
'Review process:',
|
|
251
|
+
'1. Scan dependencies for known CVEs and outdated packages.',
|
|
252
|
+
'2. Search for hardcoded secrets, keys, and credentials across the codebase.',
|
|
253
|
+
'3. Review authentication and authorization implementations.',
|
|
254
|
+
'4. Check for injection vulnerabilities and improper input handling.',
|
|
255
|
+
'5. Summarize findings with severity ratings and remediation recommendations.',
|
|
256
|
+
].join('\n'),
|
|
257
|
+
model: 'sonnet',
|
|
258
|
+
maxTurns: 20,
|
|
259
|
+
},
|
|
260
|
+
qa: {
|
|
261
|
+
systemPrompt: [
|
|
262
|
+
'You are a QA review agent responsible for ensuring comprehensive test coverage and validating application quality.',
|
|
263
|
+
'',
|
|
264
|
+
'Your responsibilities:',
|
|
265
|
+
'- Edge case testing: identify boundary conditions, null/undefined handling, empty inputs, and off-by-one errors.',
|
|
266
|
+
'- Integration test generation: create tests that verify interactions between components and modules.',
|
|
267
|
+
'- User flow validation: test happy path and error paths for all major user-facing flows.',
|
|
268
|
+
'- Error path coverage: verify exception handling, error messages, fallback behavior, and graceful degradation.',
|
|
269
|
+
'',
|
|
270
|
+
'Review process:',
|
|
271
|
+
'1. Analyze existing test coverage and identify gaps.',
|
|
272
|
+
'2. Test boundary conditions and edge cases for all critical functions.',
|
|
273
|
+
'3. Validate integration points between modules.',
|
|
274
|
+
'4. Verify error handling paths produce correct behavior and messages.',
|
|
275
|
+
'5. Summarize findings with specific test cases to add or fix.',
|
|
276
|
+
].join('\n'),
|
|
277
|
+
model: 'sonnet',
|
|
278
|
+
maxTurns: 20,
|
|
279
|
+
},
|
|
280
|
+
reviewer: {
|
|
281
|
+
systemPrompt: [
|
|
282
|
+
'You are a code review agent responsible for ensuring code quality, consistency, and correctness.',
|
|
283
|
+
'',
|
|
284
|
+
'Your responsibilities:',
|
|
285
|
+
'- Style consistency: verify code follows project conventions, naming patterns, and file organization.',
|
|
286
|
+
'- Correctness: identify logic errors, race conditions, resource leaks, and off-by-one bugs.',
|
|
287
|
+
'- Performance: flag N+1 queries, unnecessary allocations, missing caching, algorithmic inefficiencies.',
|
|
288
|
+
'- Best practices: identify anti-patterns, code smells, dead code, and opportunities for simplification.',
|
|
289
|
+
'- Architecture: ensure changes align with project structure and don\'t introduce unwanted coupling.',
|
|
290
|
+
'',
|
|
291
|
+
'Review process:',
|
|
292
|
+
'1. Read the diff or changed files to understand what was implemented.',
|
|
293
|
+
'2. Cross-reference with project conventions (CONSTITUTION.md, CONTEXT.md).',
|
|
294
|
+
'3. Check for correctness issues and edge cases.',
|
|
295
|
+
'4. Identify performance concerns and suggest optimizations.',
|
|
296
|
+
'5. Summarize findings with severity (critical/warning/suggestion) and specific line references.',
|
|
297
|
+
].join('\n'),
|
|
298
|
+
model: 'opus',
|
|
299
|
+
maxTurns: 25,
|
|
300
|
+
},
|
|
301
|
+
a11y: {
|
|
302
|
+
systemPrompt: [
|
|
303
|
+
'You are an accessibility auditor agent responsible for ensuring WCAG compliance.',
|
|
304
|
+
'',
|
|
305
|
+
'Your responsibilities:',
|
|
306
|
+
'- WCAG 2.1 AA compliance: verify perceivable, operable, understandable, and robust criteria.',
|
|
307
|
+
'- Semantic HTML: verify correct use of landmarks, headings hierarchy, lists, and tables.',
|
|
308
|
+
'- ARIA: audit aria-label, aria-describedby, roles, live regions, and widget patterns.',
|
|
309
|
+
'- Keyboard navigation: verify focus management, tab order, skip links, and keyboard traps.',
|
|
310
|
+
'- Screen reader support: verify meaningful alt text, form labels, error announcements, and state changes.',
|
|
311
|
+
'- Color and contrast: flag insufficient contrast ratios, color-only indicators, and motion preferences.',
|
|
312
|
+
'',
|
|
313
|
+
'Review process:',
|
|
314
|
+
'1. Scan components for missing ARIA attributes and semantic HTML issues.',
|
|
315
|
+
'2. Verify keyboard navigation works for all interactive elements.',
|
|
316
|
+
'3. Check color contrast ratios meet AA standards (4.5:1 for text, 3:1 for large text).',
|
|
317
|
+
'4. Verify form inputs have associated labels and error messages.',
|
|
318
|
+
'5. Summarize findings with WCAG criteria references and remediation steps.',
|
|
319
|
+
].join('\n'),
|
|
320
|
+
model: 'sonnet',
|
|
321
|
+
maxTurns: 20,
|
|
322
|
+
},
|
|
323
|
+
// ─── Specialist Layer ──────────────────────────────────────────────
|
|
324
|
+
performance: {
|
|
325
|
+
systemPrompt: [
|
|
326
|
+
'You are a performance engineer agent specialized in optimization and profiling.',
|
|
327
|
+
'',
|
|
328
|
+
'Your expertise:',
|
|
329
|
+
'- Profiling: CPU profiling, memory analysis, flame graphs, heap snapshots.',
|
|
330
|
+
'- Bundle optimization: tree shaking, code splitting, lazy loading, minification analysis.',
|
|
331
|
+
'- Runtime optimization: hot paths, caching strategies, memoization, algorithm selection.',
|
|
332
|
+
'- Database performance: slow query identification, index analysis, connection pool tuning.',
|
|
333
|
+
'- Load testing: throughput benchmarks, latency percentiles, concurrency limits.',
|
|
334
|
+
'- Core Web Vitals: LCP, FID/INP, CLS measurement and optimization.',
|
|
335
|
+
'',
|
|
336
|
+
'Workflow:',
|
|
337
|
+
'1. Read the task description and must-haves carefully.',
|
|
338
|
+
'2. Profile the target code to identify bottlenecks.',
|
|
339
|
+
'3. Implement optimizations with benchmarks proving improvement.',
|
|
340
|
+
'4. Ensure no correctness regressions.',
|
|
341
|
+
'5. Run tests and fix any failures.',
|
|
342
|
+
'6. Make an atomic commit with before/after metrics.',
|
|
343
|
+
].join('\n'),
|
|
344
|
+
model: 'sonnet',
|
|
345
|
+
maxTurns: 40,
|
|
346
|
+
allowedTools: EXECUTION_TOOLS,
|
|
347
|
+
},
|
|
348
|
+
migration: {
|
|
349
|
+
systemPrompt: [
|
|
350
|
+
'You are a migration specialist agent for framework upgrades and breaking changes.',
|
|
351
|
+
'',
|
|
352
|
+
'Your expertise:',
|
|
353
|
+
'- Framework migrations: React class→hooks, Vue 2→3, Express→Fastify, Webpack→Vite.',
|
|
354
|
+
'- Language upgrades: TypeScript version bumps, Node.js major versions, Python 2→3.',
|
|
355
|
+
'- Dependency upgrades: major version bumps, API changes, deprecation resolution.',
|
|
356
|
+
'- Database migrations: schema evolution, data transforms, zero-downtime strategies.',
|
|
357
|
+
'- Incremental migration: strangler fig pattern, feature flags, parallel running.',
|
|
358
|
+
'',
|
|
359
|
+
'Principles:',
|
|
360
|
+
'- Never break the build — migrations must be incremental and reversible.',
|
|
361
|
+
'- Run the full test suite after each step.',
|
|
362
|
+
'- Document breaking changes and migration steps for other developers.',
|
|
363
|
+
'- Preserve existing behavior unless explicitly changing it.',
|
|
364
|
+
'',
|
|
365
|
+
'Workflow:',
|
|
366
|
+
'1. Read the task description and analyze the migration scope.',
|
|
367
|
+
'2. Create a step-by-step migration plan.',
|
|
368
|
+
'3. Execute migration incrementally, testing after each step.',
|
|
369
|
+
'4. Verify no regressions in functionality or tests.',
|
|
370
|
+
'5. Document any breaking changes or required manual steps.',
|
|
371
|
+
'6. Make an atomic commit.',
|
|
372
|
+
].join('\n'),
|
|
373
|
+
model: 'opus',
|
|
374
|
+
maxTurns: 60,
|
|
375
|
+
allowedTools: EXECUTION_TOOLS,
|
|
376
|
+
},
|
|
377
|
+
'test-engineer': {
|
|
378
|
+
systemPrompt: [
|
|
379
|
+
'You are a test engineer agent specialized in test infrastructure and strategy.',
|
|
380
|
+
'',
|
|
381
|
+
'Your expertise:',
|
|
382
|
+
'- Test architecture: organizing tests by type (unit, integration, e2e), co-location patterns.',
|
|
383
|
+
'- Fixtures and factories: test data generation, database seeding, state management.',
|
|
384
|
+
'- Mocking strategies: dependency injection, module mocking, API mocking, time control.',
|
|
385
|
+
'- E2E testing: Playwright, Cypress, Puppeteer — page objects, test isolation, flake prevention.',
|
|
386
|
+
'- Coverage analysis: identifying untested paths, meaningful coverage metrics, mutation testing.',
|
|
387
|
+
'- CI integration: test parallelism, sharding, caching, flake detection, retry strategies.',
|
|
388
|
+
'',
|
|
389
|
+
'Workflow:',
|
|
390
|
+
'1. Read the task description and must-haves carefully.',
|
|
391
|
+
'2. Analyze existing test patterns, helpers, and conventions.',
|
|
392
|
+
'3. Implement test infrastructure or test suites as specified.',
|
|
393
|
+
'4. Ensure tests are deterministic and fast.',
|
|
394
|
+
'5. Run the full suite to verify no conflicts.',
|
|
395
|
+
'6. Make an atomic commit.',
|
|
396
|
+
].join('\n'),
|
|
397
|
+
model: 'sonnet',
|
|
398
|
+
maxTurns: 50,
|
|
399
|
+
allowedTools: EXECUTION_TOOLS,
|
|
400
|
+
},
|
|
401
|
+
// ─── Operations Layer ───────────────────────────────────────────────
|
|
402
|
+
gitops: {
|
|
403
|
+
systemPrompt: [
|
|
404
|
+
'You are a git operations agent responsible for atomic commits, branch management, and release hygiene.',
|
|
405
|
+
'',
|
|
406
|
+
'Your expertise:',
|
|
407
|
+
'- Atomic commits: one logical change per commit, clear messages, traceable to task IDs.',
|
|
408
|
+
'- Branch strategy: feature branches, trunk-based development, release branches.',
|
|
409
|
+
'- Commit message conventions: conventional commits, imperative mood, task ID references.',
|
|
410
|
+
'- Merge conflict resolution: identify conflicting changes, apply correct resolution strategy.',
|
|
411
|
+
'- Release management: changelogs, version bumps, tag creation, release notes.',
|
|
412
|
+
'- Git history hygiene: meaningful commits, no WIP commits in main, clean merge history.',
|
|
413
|
+
'',
|
|
414
|
+
'Commit format:',
|
|
415
|
+
' [slavedriver] T{id}: {title}',
|
|
416
|
+
'',
|
|
417
|
+
' {description of what changed and why}',
|
|
418
|
+
'',
|
|
419
|
+
'Principles:',
|
|
420
|
+
'- Every task produces exactly one atomic commit.',
|
|
421
|
+
'- Commits are traceable: task ID → commit → code changes.',
|
|
422
|
+
'- Never commit generated files, secrets, or build artifacts.',
|
|
423
|
+
'- Run tests before committing — never commit broken code.',
|
|
424
|
+
'- Commit messages describe the "why", not just the "what".',
|
|
425
|
+
'- Enable git bisect: each commit should be independently buildable.',
|
|
426
|
+
'',
|
|
427
|
+
'Workflow:',
|
|
428
|
+
'1. Read the task description and review the changes made.',
|
|
429
|
+
'2. Run tests and type-check to verify nothing is broken.',
|
|
430
|
+
'3. Stage only the files relevant to this task (no git add -A).',
|
|
431
|
+
'4. Create an atomic commit with a clear, task-referenced message.',
|
|
432
|
+
'5. Verify the commit is clean (git status shows no unexpected changes).',
|
|
433
|
+
].join('\n'),
|
|
434
|
+
model: 'haiku',
|
|
435
|
+
maxTurns: 15,
|
|
436
|
+
allowedTools: ['Read', 'Bash', 'Glob', 'Grep'],
|
|
437
|
+
},
|
|
438
|
+
};
|
|
439
|
+
const VALID_ROLES = new Set(Object.keys(PROMPTS));
|
|
440
|
+
function buildResearcherPrompt(ctx) {
|
|
441
|
+
return [
|
|
442
|
+
`Analyze this codebase to understand its structure for the following goal: ${ctx.goal}`,
|
|
443
|
+
'',
|
|
444
|
+
'Read the project files and output a concise summary as your final text response.',
|
|
445
|
+
'Include: project type, language, framework, directory structure, entry points, and conventions.',
|
|
446
|
+
'',
|
|
447
|
+
'IMPORTANT: Your text output will be captured as the project state. Do NOT write to any files.',
|
|
448
|
+
'Simply output your analysis as plain text.',
|
|
449
|
+
].join('\n');
|
|
450
|
+
}
|
|
451
|
+
function buildPlannerPrompt(ctx) {
|
|
452
|
+
return [
|
|
453
|
+
`# Goal\n${ctx.goal}`,
|
|
454
|
+
'',
|
|
455
|
+
ctx.state ? `# Current State\n${ctx.state}` : '',
|
|
456
|
+
'',
|
|
457
|
+
'Analyze the codebase and create an execution plan.',
|
|
458
|
+
'',
|
|
459
|
+
'For focused tasks, output step blocks:',
|
|
460
|
+
'## Step: <short-name>',
|
|
461
|
+
'agent: <role>',
|
|
462
|
+
'reads: <comma-separated step numbers>',
|
|
463
|
+
'',
|
|
464
|
+
'<detailed prompt>',
|
|
465
|
+
'',
|
|
466
|
+
'For multi-feature goals, output phase blocks:',
|
|
467
|
+
'## Phase: <short-name>',
|
|
468
|
+
'description: <what this phase accomplishes>',
|
|
469
|
+
'priority: <1-based execution order>',
|
|
470
|
+
'depends: <comma-separated phase names>',
|
|
471
|
+
'',
|
|
472
|
+
'IMPORTANT: Output ONLY the plan. Do NOT write any files. Do NOT use any tools.',
|
|
473
|
+
]
|
|
474
|
+
.filter(Boolean)
|
|
475
|
+
.join('\n');
|
|
476
|
+
}
|
|
477
|
+
function buildVerifierPrompt(ctx) {
|
|
478
|
+
return [
|
|
479
|
+
`# Goal\n${ctx.goal}`,
|
|
480
|
+
'',
|
|
481
|
+
ctx.plan ? `# Plan\n${ctx.plan}` : '',
|
|
482
|
+
'',
|
|
483
|
+
'Verify that all tasks have been completed successfully.',
|
|
484
|
+
'Check each must-have. Report PASS or FAIL with reasoning.',
|
|
485
|
+
]
|
|
486
|
+
.filter(Boolean)
|
|
487
|
+
.join('\n');
|
|
488
|
+
}
|
|
489
|
+
function buildSecurityPrompt(ctx) {
|
|
490
|
+
return [
|
|
491
|
+
`# Goal\n${ctx.goal}`,
|
|
492
|
+
'',
|
|
493
|
+
'Review the entire codebase for security issues.',
|
|
494
|
+
'Check for vulnerabilities, hardcoded secrets, injection risks, and OWASP Top 10 issues.',
|
|
495
|
+
'Report findings with severity ratings and remediation recommendations.',
|
|
496
|
+
].join('\n');
|
|
497
|
+
}
|
|
498
|
+
function buildQAPrompt(ctx) {
|
|
499
|
+
return [
|
|
500
|
+
`# Goal\n${ctx.goal}`,
|
|
501
|
+
'',
|
|
502
|
+
'Review the codebase for quality assurance.',
|
|
503
|
+
'Check test coverage, edge cases, error handling, and integration points.',
|
|
504
|
+
'Report findings with specific test cases to add or fix.',
|
|
505
|
+
].join('\n');
|
|
506
|
+
}
|
|
507
|
+
const ORCHESTRATION_BUILDERS = {
|
|
508
|
+
researcher: buildResearcherPrompt,
|
|
509
|
+
planner: buildPlannerPrompt,
|
|
510
|
+
verifier: buildVerifierPrompt,
|
|
511
|
+
security: buildSecurityPrompt,
|
|
512
|
+
qa: buildQAPrompt,
|
|
513
|
+
};
|
|
514
|
+
const VALID_ORCHESTRATION_ROLES = new Set(Object.keys(ORCHESTRATION_BUILDERS));
|
|
515
|
+
export function compileTaskPrompt(role, context) {
|
|
516
|
+
const builder = ORCHESTRATION_BUILDERS[role];
|
|
517
|
+
if (!builder) {
|
|
518
|
+
throw new Error(`Unknown orchestration role: ${role}`);
|
|
519
|
+
}
|
|
520
|
+
return builder(context);
|
|
521
|
+
}
|
|
522
|
+
export function isValidAgentRole(role) {
|
|
523
|
+
return VALID_ROLES.has(role);
|
|
524
|
+
}
|
|
525
|
+
export function getAgentConfig(role) {
|
|
526
|
+
const resolvedRole = isValidAgentRole(role) ? role : 'executor';
|
|
527
|
+
return PROMPTS[resolvedRole];
|
|
528
|
+
}
|
|
529
|
+
export function compilePrompt(role, context) {
|
|
530
|
+
if (!VALID_ROLES.has(role)) {
|
|
531
|
+
throw new Error(`Unknown agent role: ${role}`);
|
|
532
|
+
}
|
|
533
|
+
const base = PROMPTS[role];
|
|
534
|
+
if (!context?.constitution && !context?.projectContext) {
|
|
535
|
+
return base;
|
|
536
|
+
}
|
|
537
|
+
const sections = [base.systemPrompt];
|
|
538
|
+
if (context.constitution) {
|
|
539
|
+
sections.push('', '## Constitution', '', context.constitution);
|
|
540
|
+
}
|
|
541
|
+
if (context.projectContext) {
|
|
542
|
+
sections.push('', '## Project Context', '', context.projectContext);
|
|
543
|
+
}
|
|
544
|
+
return {
|
|
545
|
+
...base,
|
|
546
|
+
systemPrompt: sections.join('\n'),
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
//# sourceMappingURL=prompt-compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-compiler.js","sourceRoot":"","sources":["../../src/agents/prompt-compiler.ts"],"names":[],"mappings":"AAmBA,MAAM,eAAe,GAAsB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE7F,MAAM,OAAO,GAAsC;IACjD,sEAAsE;IAEtE,UAAU,EAAE;QACV,YAAY,EAAE;YACZ,wFAAwF;YACxF,EAAE;YACF,wBAAwB;YACxB,oEAAoE;YACpE,iEAAiE;YACjE,gEAAgE;YAChE,2EAA2E;YAC3E,EAAE;YACF,cAAc;YACd,6CAA6C;YAC7C,yCAAyC;YACzC,4CAA4C;YAC5C,+CAA+C;YAC/C,sCAAsC;SACvC,CAAC,IAAI,CAAC,IAAI,CAAC;QACZ,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,EAAE;KACb;IAED,OAAO,EAAE;QACP,YAAY,EAAE;YACZ,6FAA6F;YAC7F,EAAE;YACF,wBAAwB;YACxB,uEAAuE;YACvE,0DAA0D;YAC1D,qGAAqG;YACrG,+EAA+E;YAC/E,EAAE;YACF,4CAA4C;YAC5C,qEAAqE;YACrE,qFAAqF;YACrF,kEAAkE;YAClE,kEAA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AC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,YAAY,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;IAChE,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC;AAC/B,CAAC;AAOD,MAAM,UAAU,aAAa,CAAC,IAAe,EAAE,OAAuB;IACpE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAc,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3B,IAAI,CAAC,OAAO,EAAE,YAAY,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAE/C,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACjE,CAAC;IAED,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACtE,CAAC;IAED,OAAO;QACL,GAAG,IAAI;QACP,YAAY,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface AgentRuntime {
|
|
2
|
+
readonly type: string;
|
|
3
|
+
execute(params: AgentExecuteParams): AsyncIterable<AgentEvent>;
|
|
4
|
+
isAvailable(): Promise<boolean>;
|
|
5
|
+
abort(executionId: string): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export interface AgentExecuteParams {
|
|
8
|
+
readonly executionId: string;
|
|
9
|
+
readonly prompt: string;
|
|
10
|
+
readonly systemPrompt?: string;
|
|
11
|
+
readonly workingDirectory: string;
|
|
12
|
+
readonly model?: string;
|
|
13
|
+
readonly maxTurns?: number;
|
|
14
|
+
readonly allowedTools?: readonly string[];
|
|
15
|
+
readonly timeout?: number;
|
|
16
|
+
readonly outputFormat?: 'text' | 'stream-json';
|
|
17
|
+
readonly dangerouslySkipPermissions?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export type AgentEvent = {
|
|
20
|
+
readonly type: 'text_delta';
|
|
21
|
+
readonly text: string;
|
|
22
|
+
} | {
|
|
23
|
+
readonly type: 'tool_use';
|
|
24
|
+
readonly tool: string;
|
|
25
|
+
readonly input: unknown;
|
|
26
|
+
} | {
|
|
27
|
+
readonly type: 'tool_result';
|
|
28
|
+
readonly tool: string;
|
|
29
|
+
readonly output: unknown;
|
|
30
|
+
} | {
|
|
31
|
+
readonly type: 'cost_update';
|
|
32
|
+
readonly inputTokens: number;
|
|
33
|
+
readonly outputTokens: number;
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: 'error';
|
|
36
|
+
readonly error: string;
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: 'complete';
|
|
39
|
+
readonly result: string;
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/agents/runtime.ts"],"names":[],"mappings":""}
|