1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import { BaseAgent, type AgentContext, type AgentResult } from './base-agent.js';
import type { ClaudeResponse } from '../services/claude.service.js';
export class PlannerAgent extends BaseAgent {
name = 'planner';
templateFile = 'planner.md';
model = 'claude-opus-4-20250514';
protected getSystemPrompt(): string {
return 'You are a meticulous software architect who creates clear, actionable implementation plans. Be thorough but concise. Focus on practical steps, not theory.';
}
protected getMaxTokens(): number {
return 16384;
}
protected parseResponse(response: ClaudeResponse, _ctx: AgentContext): AgentResult {
const content = response.content;
// Extract sections
const plan = content;
const doneWhen = extractSection(content, 'Done When') || '';
const decisionLog = extractSection(content, 'Decisions') || '';
return {
success: true,
content,
tokensUsed: response.tokensUsed,
model: response.model,
updates: {
plan,
done_when: doneWhen,
decision_log: decisionLog,
status: 'plan_review',
},
message: 'Generated implementation plan',
};
}
}
function extractSection(text: string, heading: string): string | null {
const regex = new RegExp(`###\\s*${heading}\\s*\\n([\\s\\S]*?)(?=###|$)`, 'i');
const match = text.match(regex);
return match ? match[1].trim() : null;
}
|