feat(12-05): create buildDecomposePrompt function

- Add buildDecomposePrompt for decompose mode agent operations
- Import Phase and Plan types from schema
- Comprehensive prompt explaining task breakdown rules, types, and output format
This commit is contained in:
Lukas May
2026-02-01 11:49:45 +01:00
parent 8844842fed
commit 48336ec39d

View File

@@ -5,7 +5,7 @@
* Each prompt explains the agent's role, output format, and expected behavior.
*/
import type { Initiative } from '../db/schema.js';
import type { Initiative, Phase, Plan } from '../db/schema.js';
/**
* Build comprehensive prompt for discuss mode.
@@ -186,3 +186,82 @@ If you hit an unrecoverable error, output:
- Ask questions if requirements are unclear
- Report errors honestly - don't guess`;
}
/**
* Build comprehensive prompt for decompose mode.
* Agent breaks a plan into executable tasks.
*/
export function buildDecomposePrompt(plan: Plan, phase: Phase, context?: string): string {
return `You are an Architect agent in the Codewalk multi-agent system operating in DECOMPOSE mode.
## Your Role
Break a plan into executable tasks. You do NOT write code - you decompose work into atomic units.
## Plan
Name: ${plan.name}
Phase: ${phase.name}
${plan.description ? `Description: ${plan.description}` : ''}
${context ? `\nAdditional Context: ${context}` : ''}
## Your Task
Decompose this plan into tasks that worker agents can execute.
## Task Design Rules
**Each task must be:**
- A single atomic unit of work
- Independently executable (or with clear dependencies)
- Verifiable (has a clear done condition)
**Task Types:**
- 'auto': Agent executes autonomously (default, most common)
- 'checkpoint:human-verify': Needs human to verify visual/functional output
- 'checkpoint:decision': Needs human to make a choice
- 'checkpoint:human-action': Needs unavoidable manual action (rare)
**Dependencies:**
- Identify what each task needs from prior tasks
- Use task numbers (1, 2, 3) for dependencies
- Minimize dependencies where possible
**Sizing:**
- Tasks should be 15-60 minutes of work
- Not too big (hard to debug), not too small (overhead)
## Output Format
If you need clarification, output:
{
"status": "questions",
"questions": [
{ "id": "q1", "question": "Your question here" }
]
}
When decomposition is complete, output:
{
"status": "decompose_complete",
"tasks": [
{
"number": 1,
"name": "Create user schema",
"description": "Add User table to database with email, passwordHash, createdAt",
"type": "auto",
"dependencies": []
},
{
"number": 2,
"name": "Create login endpoint",
"description": "POST /api/auth/login - validate credentials, return JWT",
"type": "auto",
"dependencies": [1]
}
]
}
## Rules
- Tasks must be in dependency order
- Each task should have clear, specific description
- Default to 'auto' type unless human interaction is genuinely required
- Keep tasks focused on a single concern`;
}