refactor: Add context management to plan/detail prompts, update docs
Add CONTEXT_MANAGEMENT shared block to plan and detail mode prompts so architect agents also benefit from compaction awareness and parallel execution hints. Update index.ts re-exports and agent docs.
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
| `accounts/` | Account discovery, config dir setup, credential management, usage API |
|
||||
| `credentials/` | `AccountCredentialManager` — credential injection per account |
|
||||
| `lifecycle/` | `LifecycleController` — retry policy, signal recovery, missing signal instructions |
|
||||
| `prompts/` | Mode-specific prompt builders (execute, discuss, plan, detail, refine) + shared inter-agent communication instructions |
|
||||
| `prompts/` | Mode-specific prompt builders (execute, discuss, plan, detail, refine) + shared blocks (codebase verification, deviation rules, git workflow) + inter-agent communication instructions |
|
||||
|
||||
## Key Flows
|
||||
|
||||
@@ -166,3 +166,34 @@ Agents can communicate with each other via the `conversations` table, coordinate
|
||||
|
||||
**`cw answer <answer> --conversation-id <id>`**
|
||||
- Calls `answerConversation`, prints `{ conversationId, status: "answered" }`
|
||||
|
||||
## Prompt Architecture
|
||||
|
||||
Mode-specific prompts in `prompts/` are composed from shared blocks and mode-specific sections.
|
||||
|
||||
### Shared Blocks (`prompts/shared.ts`)
|
||||
|
||||
| Constant | Content |
|
||||
|----------|---------|
|
||||
| `SIGNAL_FORMAT` | Signal output format (done/questions/error via `.cw/output/signal.json`) |
|
||||
| `INPUT_FILES` | Input file structure (manifest, assignment files, context files) |
|
||||
| `ID_GENERATION` | `cw id` usage for generating entity IDs |
|
||||
| `CODEBASE_VERIFICATION` | "Training as hypothesis" pattern — read before writing, verify imports, follow patterns, check git log |
|
||||
| `DEVIATION_RULES` | Decision tree for handling unexpected situations (typo→fix, bug→fix if small, missing dep→coordinate, architectural mismatch→STOP) |
|
||||
| `GIT_WORKFLOW` | Worktree-aware git guidance with rationale (frequent commits as recovery checkpoints, descriptive messages, specific staging to avoid cross-agent conflicts, no force-push) |
|
||||
| `CONTEXT_MANAGEMENT` | Context compaction awareness (don't stop early, commit as checkpoints, parallel file reads) |
|
||||
| `buildInterAgentCommunication()` | Per-agent CLI instructions for `cw listen`, `cw ask`, `cw answer` (compact format with usage pattern summary) |
|
||||
|
||||
### Mode Prompts
|
||||
|
||||
| Mode | File | Key Sections |
|
||||
|------|------|-------------|
|
||||
| **execute** | `execute.ts` | Execution protocol (read→orient→test first→implement→verify→commit→signal), scope rules with rationale (7+ files = overscoping), codebase verification, deviation rules, git workflow, context management, anti-patterns (including anti-hardcoding) |
|
||||
| **plan** | `plan.ts` | Dependency graph with wave analysis, file ownership for parallelism, specificity test ("Could a detail agent break this down?") |
|
||||
| **detail** | `detail.ts` | Specificity test with good/bad examples, file ownership constraints, task sizing (1-5 files good, 7+ split), checkpoint guidance |
|
||||
| **discuss** | `discuss.ts` | Goal-backward analysis (outcome→artifacts→wiring→failure points), question quality examples, decision quality examples, read-before-asking |
|
||||
| **refine** | `refine.ts` | Improvement hierarchy (ambiguity > missing details > contradictions > unverifiable > missing edge cases), don't refine style, signal done if nothing to improve |
|
||||
|
||||
### Execute Prompt Dispatch
|
||||
|
||||
`buildExecutePrompt(taskDescription?)` accepts an optional task description that's inlined into the prompt. The dispatch manager (`src/dispatch/manager.ts`) wraps `task.description || task.name` in `buildExecutePrompt()` so execute agents receive full system context (execution protocol, scope rules, anti-patterns) alongside their task description. The workspace layout and inter-agent communication blocks are appended by the agent manager at spawn time.
|
||||
|
||||
Reference in New Issue
Block a user