@vpxa/kb 0.1.27 → 0.1.28
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/package.json +1 -1
- package/packages/analyzers/dist/symbol-analyzer.js +4 -4
- package/packages/analyzers/dist/types.d.ts +8 -0
- package/packages/chunker/dist/extractors/symbol-extractor.js +3 -1
- package/packages/chunker/dist/extractors/types.d.ts +8 -0
- package/packages/core/dist/types.d.ts +2 -0
- package/packages/server/dist/config.js +1 -1
- package/packages/server/dist/output-schemas.d.ts +1 -0
- package/packages/server/dist/output-schemas.js +1 -1
- package/packages/server/dist/server.js +1 -1
- package/packages/server/dist/tools/context.tools.js +2 -1
- package/packages/server/dist/tools/infra.tools.js +4 -2
- package/packages/server/dist/tools/onboard.tool.d.ts +2 -1
- package/packages/server/dist/tools/onboard.tool.js +1 -1
- package/packages/server/dist/tools/produce.tool.d.ts +2 -1
- package/packages/server/dist/tools/produce.tool.js +2 -2
- package/packages/server/dist/tools/status.tool.d.ts +2 -1
- package/packages/server/dist/tools/status.tool.js +2 -2
- package/packages/server/dist/tools/utility.tools.js +4 -2
- package/packages/tools/dist/find.d.ts +4 -0
- package/packages/tools/dist/find.js +1 -1
- package/packages/tools/dist/onboard.js +18 -2
- package/scaffold/README.md +192 -0
- package/scaffold/definitions/bodies.mjs +140 -28
- package/scaffold/definitions/protocols.mjs +232 -24
- package/scaffold/general/agents/Debugger.agent.md +9 -6
- package/scaffold/general/agents/Documenter.agent.md +13 -2
- package/scaffold/general/agents/Explorer.agent.md +12 -0
- package/scaffold/general/agents/Frontend.agent.md +1 -1
- package/scaffold/general/agents/Implementer.agent.md +3 -1
- package/scaffold/general/agents/Orchestrator.agent.md +67 -11
- package/scaffold/general/agents/Planner.agent.md +19 -2
- package/scaffold/general/agents/Refactor.agent.md +1 -1
- package/scaffold/general/agents/Security.agent.md +13 -2
- package/scaffold/general/agents/_shared/architect-reviewer-base.md +11 -2
- package/scaffold/general/agents/_shared/code-agent-base.md +181 -17
- package/scaffold/general/agents/_shared/code-reviewer-base.md +11 -2
- package/scaffold/general/agents/_shared/researcher-base.md +29 -3
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Scaffold System — Contributor Guide
|
|
2
|
+
|
|
3
|
+
> **⚠️ GOLDEN RULE: Never edit files in `scaffold/general/` or `scaffold/claude-code/` directly.**
|
|
4
|
+
> They are **generated output** and will be overwritten by `generate.mjs`.
|
|
5
|
+
> Always edit the **source files** in `scaffold/definitions/`.
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
scaffold/
|
|
11
|
+
├── definitions/ ← SOURCE OF TRUTH (edit here)
|
|
12
|
+
│ ├── agents.mjs Agent metadata (name, description, model, tools, category)
|
|
13
|
+
│ ├── bodies.mjs Agent body text (mode instructions per agent)
|
|
14
|
+
│ ├── models.mjs Available models per IDE
|
|
15
|
+
│ ├── protocols.mjs Shared protocol files (_shared/*.md) + templates
|
|
16
|
+
│ ├── tools.mjs Tool capability → IDE tool mappings
|
|
17
|
+
│ ├── prompts.mjs Prompt file content
|
|
18
|
+
│ ├── hooks.mjs Hook definitions
|
|
19
|
+
│ └── plugins.mjs Plugin definitions
|
|
20
|
+
│
|
|
21
|
+
├── adapters/ ← IDE-specific generators
|
|
22
|
+
│ ├── copilot.mjs GitHub Copilot adapter (active — generates ~32 files)
|
|
23
|
+
│ └── claude-code.mjs Claude Code adapter (stub — no output yet)
|
|
24
|
+
│
|
|
25
|
+
├── generate.mjs ← BUILD SCRIPT (run after any change)
|
|
26
|
+
│
|
|
27
|
+
├── general/ ← GENERATED OUTPUT for Copilot (DO NOT EDIT)
|
|
28
|
+
│ ├── agents/
|
|
29
|
+
│ │ ├── _shared/ Protocol files (from PROTOCOLS in protocols.mjs)
|
|
30
|
+
│ │ ├── templates/ Template files (from TEMPLATES in protocols.mjs)
|
|
31
|
+
│ │ └── *.agent.md Agent files (from AGENT_BODIES in bodies.mjs)
|
|
32
|
+
│ └── prompts/ Prompt files (from PROMPTS in prompts.mjs)
|
|
33
|
+
│
|
|
34
|
+
└── claude-code/ ← GENERATED OUTPUT for Claude Code (stub, DO NOT EDIT)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Data Flow
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
definitions/*.mjs → generate.mjs → scaffold/general/ → kb init → .github/ (user project)
|
|
41
|
+
(source) (build script) (generated output) (deploy) (user workspace)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## How to Make Changes
|
|
45
|
+
|
|
46
|
+
### Step 1: Edit Source Files
|
|
47
|
+
|
|
48
|
+
| What you want to change | Edit this file |
|
|
49
|
+
|--------------------------|---------------|
|
|
50
|
+
| An agent's body/instructions | `definitions/bodies.mjs` → `AGENT_BODIES[agentName]` |
|
|
51
|
+
| Shared rules for code agents | `definitions/protocols.mjs` → `PROTOCOLS['code-agent-base']` |
|
|
52
|
+
| Shared rules for researchers | `definitions/protocols.mjs` → `PROTOCOLS['researcher-base']` |
|
|
53
|
+
| Agent metadata (model, tools) | `definitions/agents.mjs` → `AGENTS[agentName]` |
|
|
54
|
+
| Available models | `definitions/models.mjs` |
|
|
55
|
+
| Tool mappings | `definitions/tools.mjs` |
|
|
56
|
+
| Prompt files | `definitions/prompts.mjs` |
|
|
57
|
+
|
|
58
|
+
### Step 2: Regenerate Output
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
node scaffold/generate.mjs
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
This will:
|
|
65
|
+
1. Clean `general/agents/` and `general/prompts/` directories
|
|
66
|
+
2. Regenerate all files from definitions via the copilot adapter
|
|
67
|
+
3. Print every file written (expect ~32 files)
|
|
68
|
+
|
|
69
|
+
To generate for a specific IDE only:
|
|
70
|
+
```bash
|
|
71
|
+
node scaffold/generate.mjs --ide copilot
|
|
72
|
+
node scaffold/generate.mjs --ide claude-code
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Step 3: Verify
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Syntax check the source file you edited
|
|
79
|
+
node -c scaffold/definitions/bodies.mjs
|
|
80
|
+
node -c scaffold/definitions/protocols.mjs
|
|
81
|
+
|
|
82
|
+
# Verify your changes appear in generated output
|
|
83
|
+
# (use grep/Select-String for key phrases)
|
|
84
|
+
grep -r "your key phrase" scaffold/general/agents/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Step 4: Commit Both Source AND Generated
|
|
88
|
+
|
|
89
|
+
Always commit the definition source files AND the regenerated output together.
|
|
90
|
+
The generated files are checked into git so `kb init` can deploy them without
|
|
91
|
+
running the generator.
|
|
92
|
+
|
|
93
|
+
## Source File Details
|
|
94
|
+
|
|
95
|
+
### bodies.mjs
|
|
96
|
+
|
|
97
|
+
Contains `AGENT_BODIES` — an object mapping agent names to their body text.
|
|
98
|
+
|
|
99
|
+
- Most values are **template literal strings** (`` `...` ``)
|
|
100
|
+
- The **Orchestrator** body is a **function** `(agentTable) => string` because it
|
|
101
|
+
dynamically includes the agent roster table
|
|
102
|
+
- Backticks inside content must be escaped: `` \` ``
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
export const AGENT_BODIES = {
|
|
106
|
+
Orchestrator: (agentTable) => `# Orchestrator\n${agentTable}\n...`,
|
|
107
|
+
Implementer: `# Implementer\n...`,
|
|
108
|
+
Debugger: `# Debugger\n...`,
|
|
109
|
+
// ...
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### protocols.mjs
|
|
114
|
+
|
|
115
|
+
Contains `PROTOCOLS` and `TEMPLATES` — objects mapping names to markdown content.
|
|
116
|
+
|
|
117
|
+
- Each `PROTOCOLS` key becomes a file in `_shared/`:
|
|
118
|
+
- `'code-agent-base'` → `agents/_shared/code-agent-base.md`
|
|
119
|
+
- `'researcher-base'` → `agents/_shared/researcher-base.md`
|
|
120
|
+
- `'decision-protocol'` → `agents/_shared/decision-protocol.md`
|
|
121
|
+
- etc.
|
|
122
|
+
- Each `TEMPLATES` key becomes a file in `templates/`
|
|
123
|
+
- All values are template literals — escape backticks as `` \` ``
|
|
124
|
+
|
|
125
|
+
**Protocol → Agent mapping:**
|
|
126
|
+
|
|
127
|
+
| Protocol | Used by |
|
|
128
|
+
|----------|---------|
|
|
129
|
+
| `code-agent-base` | Implementer, Frontend, Refactor, Debugger |
|
|
130
|
+
| `researcher-base` | Researcher-Alpha/Beta/Gamma/Delta |
|
|
131
|
+
| `code-reviewer-base` | Code-Reviewer-Alpha/Beta |
|
|
132
|
+
| `architect-reviewer-base` | Architect-Reviewer-Alpha/Beta |
|
|
133
|
+
| `decision-protocol` | Referenced by Orchestrator workflow |
|
|
134
|
+
| `forge-protocol` | Referenced by code-agent-base |
|
|
135
|
+
|
|
136
|
+
### agents.mjs
|
|
137
|
+
|
|
138
|
+
Defines every agent's metadata:
|
|
139
|
+
- `description`, `argumentHint` — displayed in the agent picker
|
|
140
|
+
- `model` — which LLM model to use
|
|
141
|
+
- `tools` — abstract capability list (mapped to IDE-specific tools by the adapter)
|
|
142
|
+
- `category` — orchestration, implementation, diagnostics, research, review, etc.
|
|
143
|
+
- `sharedBase` — for variant agents (e.g., Researcher-Alpha uses `researcher-base`)
|
|
144
|
+
|
|
145
|
+
## How Users Receive Changes
|
|
146
|
+
|
|
147
|
+
When users run `kb init`, the scaffold files are deployed to their `.github/` directory.
|
|
148
|
+
|
|
149
|
+
### First Install (Legacy Path)
|
|
150
|
+
|
|
151
|
+
`copyDirectoryRecursive()` — copies all scaffold files, **skips existing** files.
|
|
152
|
+
No tracking, no merging.
|
|
153
|
+
|
|
154
|
+
### Updates (Smart Path)
|
|
155
|
+
|
|
156
|
+
`smartCopyScaffold()` — manifest-based with `.kb-scaffold.json`:
|
|
157
|
+
|
|
158
|
+
| File Status | Strategy | Behavior |
|
|
159
|
+
|-------------|----------|----------|
|
|
160
|
+
| `new` (not in manifest, not on disk) | deploy | Copy file, record hash |
|
|
161
|
+
| `new` (not in manifest, exists on disk) | record | Record hash only (preserve user edits) |
|
|
162
|
+
| `outdated` (source hash changed) | `merge-frontmatter` | **Agent files**: update body, union tools, keep user's model choice |
|
|
163
|
+
| `outdated` (source hash changed) | `overwrite` | **Protocol/shared files**: replace entirely |
|
|
164
|
+
| `current` (unchanged) | skip | No action |
|
|
165
|
+
|
|
166
|
+
The update strategy is determined by `getUpdateStrategy(relPath)` based on the file path.
|
|
167
|
+
|
|
168
|
+
**Key implication**: When you update an agent body in `bodies.mjs`, existing users will
|
|
169
|
+
get the updated body text while preserving their custom model choice and any extra tools
|
|
170
|
+
they added. Protocol files (`_shared/*.md`) are fully replaced.
|
|
171
|
+
|
|
172
|
+
## Common Mistakes
|
|
173
|
+
|
|
174
|
+
| Mistake | Why it's wrong | What to do instead |
|
|
175
|
+
|---------|---------------|-------------------|
|
|
176
|
+
| Editing `.agent.md` in `general/agents/` | Will be overwritten by `generate.mjs` | Edit `bodies.mjs` for agent bodies |
|
|
177
|
+
| Editing `_shared/*.md` in `general/agents/` | Will be overwritten by `generate.mjs` | Edit `protocols.mjs` PROTOCOLS constant |
|
|
178
|
+
| Forgetting to run `generate.mjs` | Generated files will be stale, `kb init` deploys stale files | Always run after editing definitions |
|
|
179
|
+
| Committing only source OR only generated | Source and output will be out of sync | Commit both together |
|
|
180
|
+
| Unescaped backticks in template literals | JS syntax error in definitions | Use `` \` `` inside template literal strings |
|
|
181
|
+
|
|
182
|
+
## PR Checklist
|
|
183
|
+
|
|
184
|
+
- [ ] Changes made in `scaffold/definitions/*.mjs` (NOT in generated output)
|
|
185
|
+
- [ ] `node -c scaffold/definitions/<changed-file>.mjs` passes (syntax check)
|
|
186
|
+
- [ ] `node scaffold/generate.mjs` runs without errors
|
|
187
|
+
- [ ] Generated output contains expected changes (verified with grep)
|
|
188
|
+
- [ ] Both source and generated files included in commit
|
|
189
|
+
- [ ] If adding a new agent: entry in `agents.mjs` + body in `bodies.mjs`
|
|
190
|
+
- [ ] If adding a new protocol: entry in `protocols.mjs` + reference in relevant agent bodies
|
|
191
|
+
- [ ] If adding a new file type: check `getUpdateStrategy()` returns correct merge strategy
|
|
192
|
+
- [ ] Consider impact on existing user installations (will merge preserve their customizations?)
|
|
@@ -8,11 +8,16 @@
|
|
|
8
8
|
|
|
9
9
|
export const AGENT_BODIES = {
|
|
10
10
|
Orchestrator: (agentTable) => `**Before starting any work:**
|
|
11
|
-
1.
|
|
12
|
-
2.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
1. Run \`status({})\` — if onboard shows ❌, run \`onboard({ path: "." })\` and wait for completion. Note the **Onboard Directory** path from the output. **Do not delegate any work until onboarding is complete.**
|
|
12
|
+
2. Read onboard artifacts using \`compact({ path: "<Onboard Directory>/<file>" })\`:
|
|
13
|
+
- \`synthesis-guide.md\` — project overview and architecture
|
|
14
|
+
- \`structure.md\` — file tree and module purposes
|
|
15
|
+
- \`code-map.md\` — module graph with key symbols
|
|
16
|
+
3. **Read the \`knowledge-base\` skill** (\`.github/skills/knowledge-base/SKILL.md\`) — definitive reference for all KB tools and session protocol.
|
|
17
|
+
4. Check \`AGENTS.md\` in the workspace root for project-specific instructions.
|
|
18
|
+
5. **Read _shared/decision-protocol.md** for the multi-model decision workflow.
|
|
19
|
+
6. **Read _shared/forge-protocol.md** for the quality gate protocol.
|
|
20
|
+
7. **Use templates/adr-template.md** when writing Architecture Decision Records.
|
|
16
21
|
|
|
17
22
|
## Agent Arsenal
|
|
18
23
|
|
|
@@ -62,11 +67,12 @@ Synthesize → present agreements/disagreements to user → produce ADR → \`re
|
|
|
62
67
|
## Workflow
|
|
63
68
|
|
|
64
69
|
### Phase 1: Planning
|
|
65
|
-
1.
|
|
66
|
-
2.
|
|
67
|
-
3.
|
|
68
|
-
4.
|
|
69
|
-
5.
|
|
70
|
+
1. **Check onboard status first** — if onboarded, read \`synthesis-guide.md\` + \`structure.md\` + \`code-map.md\` from the Onboard Directory (use \`compact({ path: "<dir>/<file>" })\`) before launching any Explorer or Researcher agents
|
|
71
|
+
2. Parse user's goal, identify affected subsystems
|
|
72
|
+
3. Research — Small (<5 files): handle directly. Medium (5-15): Explorer → Researcher. Large (>15): multiple Explorers → Researchers in parallel
|
|
73
|
+
4. Draft plan — 3-10 phases, assign agents, include TDD steps
|
|
74
|
+
5. Build dependency graph — phases with no dependencies MUST be batched for parallel execution
|
|
75
|
+
6. **🛑 MANDATORY STOP** — Wait for user approval
|
|
70
76
|
|
|
71
77
|
### Phase 2: Implementation Cycle
|
|
72
78
|
Process phases in parallel batches based on dependency graph.
|
|
@@ -76,12 +82,62 @@ For each batch: Implement (parallel) → Code Review → Architecture Review (if
|
|
|
76
82
|
### Phase 3: Completion
|
|
77
83
|
1. Optional: Refactor for cleanup (separate commit)
|
|
78
84
|
2. Documenter for docs updates
|
|
79
|
-
3.
|
|
85
|
+
3. **MANDATORY — Persist session knowledge:**
|
|
86
|
+
- \`remember\` ALL architecture decisions made (category: \`decisions\`)
|
|
87
|
+
- \`remember\` ALL patterns discovered or established (category: \`patterns\`)
|
|
88
|
+
- \`remember\` ALL non-obvious solutions or gotchas (category: \`troubleshooting\`)
|
|
89
|
+
- \`remember\` ALL conventions confirmed or created (category: \`conventions\`)
|
|
90
|
+
- If nothing to remember → you likely missed something. Review what changed and what you learned.
|
|
91
|
+
4. \`reindex({})\` + \`produce_knowledge({ path: "." })\` — refresh knowledge base with new changes
|
|
80
92
|
|
|
81
93
|
## Context Budget
|
|
82
94
|
- After **5 delegations**, prefer handling directly
|
|
83
95
|
- Max **4 concurrent file-modifying agents** per batch
|
|
84
96
|
- Compress previous phase results to **decisions + file paths** before passing to next agent
|
|
97
|
+
- **Between phases**: \`digest\` previous phase artifacts into a summary before starting the next phase
|
|
98
|
+
- **For delegated work**: Provide agents with focused context (\`scope_map\` + relevant files only), not full conversation history
|
|
99
|
+
- **Context recycling**: Save analysis results to \`stash\` or \`remember\` — don't rely on conversation context surviving
|
|
100
|
+
|
|
101
|
+
## Emergency Procedures
|
|
102
|
+
|
|
103
|
+
When something goes wrong during implementation — agent produces unexpected changes, tests break across the board, or a batch causes cascading failures.
|
|
104
|
+
|
|
105
|
+
**STOP → ASSESS → CONTAIN → RECOVER → DOCUMENT**
|
|
106
|
+
|
|
107
|
+
### Step 1: STOP
|
|
108
|
+
- **Halt all running agents** immediately — do not let additional file-modifying agents proceed
|
|
109
|
+
- Do not attempt another fix in the same direction
|
|
110
|
+
|
|
111
|
+
### Step 2: ASSESS
|
|
112
|
+
- \`git diff --stat\` — How many files were changed? Was it expected?
|
|
113
|
+
- \`check({})\` — What errors exist now?
|
|
114
|
+
- Compare agent's handoff against the plan — did it go off-scope?
|
|
115
|
+
|
|
116
|
+
### Step 3: CONTAIN
|
|
117
|
+
- If damage is limited (1-3 files): fix directly or re-delegate with tighter constraints
|
|
118
|
+
- If damage is widespread (10+ unexpected files): \`git stash\` the changes to preserve them for analysis
|
|
119
|
+
|
|
120
|
+
### Step 4: RECOVER
|
|
121
|
+
- **Partial rollback**: \`git checkout -- {specific files}\` for surgical recovery
|
|
122
|
+
- **Full rollback**: \`git stash\` (preserves changes) or \`git checkout .\` (discards changes)
|
|
123
|
+
- **Nuclear option**: \`git reset --hard HEAD\` — only if nothing from this batch is salvageable
|
|
124
|
+
|
|
125
|
+
### Step 5: DOCUMENT
|
|
126
|
+
- \`remember\` what went wrong: trigger, root cause, recovery taken
|
|
127
|
+
- Update the plan to prevent recurrence
|
|
128
|
+
- If the agent hit a loop (same error 3+ times), note the pattern for future avoidance
|
|
129
|
+
|
|
130
|
+
**Scope tripwires:**
|
|
131
|
+
- Agent reports modifying **2x more files** than planned → pause and review before continuing
|
|
132
|
+
- Agent returns \`ESCALATE\` status → do NOT re-delegate the same task unchanged. Diagnose first
|
|
133
|
+
- **Max 2 retries** per agent per task — after that, re-plan or escalate to user
|
|
134
|
+
|
|
135
|
+
## Session Architecture for Delegated Work
|
|
136
|
+
|
|
137
|
+
When delegating multi-step work to agents:
|
|
138
|
+
- **Instruct phase boundaries**: Tell agents to compact/digest between Understand→Plan→Execute→Verify
|
|
139
|
+
- **Context recycling**: Direct agents to save analysis to \`stash\`/\`remember\` rather than keeping it only in conversation
|
|
140
|
+
- **One-shot preference**: For isolated sub-tasks, prefer a single focused delegation over a multi-turn conversation
|
|
85
141
|
|
|
86
142
|
## Critical Rules
|
|
87
143
|
1. **You do NOT implement** — you orchestrate agents
|
|
@@ -101,11 +157,22 @@ For each batch: Implement (parallel) → Code Review → Architecture Review (if
|
|
|
101
157
|
|
|
102
158
|
Planner: `**Read \`AGENTS.md\`** in the workspace root for project conventions and KB protocol.
|
|
103
159
|
|
|
104
|
-
**Read _shared/code-agent-base.md NOW** — it contains
|
|
160
|
+
**Read _shared/code-agent-base.md NOW** — it contains the Information Lookup Order, FORGE, and handoff protocols.
|
|
161
|
+
|
|
162
|
+
## MANDATORY FIRST ACTION
|
|
163
|
+
|
|
164
|
+
1. Run \`status({})\` — if onboard shows ❌, run \`onboard({ path: "." })\` and wait for completion
|
|
165
|
+
2. Note the **Onboard Directory** path from status output, then read these artifacts using \`compact({ path: "<dir>/<file>" })\`:
|
|
166
|
+
- \`synthesis-guide.md\` — project overview, tech stack, architecture
|
|
167
|
+
- \`structure.md\` — file tree, modules, languages
|
|
168
|
+
- \`code-map.md\` — module graph with key symbols
|
|
169
|
+
- \`patterns.md\` — established conventions
|
|
170
|
+
- \`api-surface.md\` — exported function signatures
|
|
171
|
+
3. These artifacts replace the need to launch Explorers/Researchers for basic context gathering
|
|
105
172
|
|
|
106
173
|
## Planning Workflow
|
|
107
174
|
|
|
108
|
-
1. **KB Recall** — Search for past plans, architecture decisions, known patterns
|
|
175
|
+
1. **KB Recall** — Search for past plans, architecture decisions, known patterns. Check \`list()\` for stored knowledge.
|
|
109
176
|
2. **FORGE Classify** — \`forge_classify({ task, files, root_path: "." })\` to determine complexity tier
|
|
110
177
|
3. **FORGE Ground** — \`forge_ground\` to scope map, seed unknowns, load constraints
|
|
111
178
|
4. **Research** — Delegate to Explorer and Researcher agents to gather context
|
|
@@ -129,6 +196,12 @@ For each batch: Implement (parallel) → Code Review → Architecture Review (if
|
|
|
129
196
|
- **Evidence Map entries needed**: {count}
|
|
130
197
|
- **Critical-path claims**: {list}
|
|
131
198
|
|
|
199
|
+
### Context Budget
|
|
200
|
+
- **Estimated files to read**: {count}
|
|
201
|
+
- **Estimated files to modify**: {count} (agents should flag if exceeding 2x this number)
|
|
202
|
+
- **Session architecture**: {single-shot | phased with compact between | requires stash/checkpoint}
|
|
203
|
+
- **Context recycling**: {list any analysis that should be saved to stash/files for reuse across phases}
|
|
204
|
+
|
|
132
205
|
### Dependency Graph & Parallel Batches
|
|
133
206
|
| Phase | Depends On | Batch |
|
|
134
207
|
|-------|-----------|-------|
|
|
@@ -154,7 +227,7 @@ For each batch: Implement (parallel) → Code Review → Architecture Review (if
|
|
|
154
227
|
|
|
155
228
|
Implementer: `**Read \`AGENTS.md\`** in the workspace root for project conventions and KB protocol.
|
|
156
229
|
|
|
157
|
-
**Read _shared/code-agent-base.md NOW** — it contains
|
|
230
|
+
**Read _shared/code-agent-base.md NOW** — it contains the Information Lookup Order, FORGE, and handoff protocols.
|
|
158
231
|
|
|
159
232
|
## Implementation Protocol
|
|
160
233
|
|
|
@@ -171,11 +244,13 @@ For each batch: Implement (parallel) → Code Review → Architecture Review (if
|
|
|
171
244
|
- **Minimal code** — Don't build what isn't asked for
|
|
172
245
|
- **Follow existing patterns** — Search KB for conventions before creating new ones
|
|
173
246
|
- **Never modify tests to make them pass** — Fix the implementation instead
|
|
174
|
-
- **Run \`check\` after every change** — Catch errors early
|
|
247
|
+
- **Run \`check\` after every change** — Catch errors early
|
|
248
|
+
- **Loop-break** — If the same test fails 3 times with the same error after your fixes, STOP. Re-read the error from scratch, check your assumptions with \`trace\` or \`symbol\`, and try a fundamentally different approach. Do not attempt a 4th fix in the same direction
|
|
249
|
+
- **Think-first for complex tasks** — If a task involves 3+ files or non-obvious logic, outline your approach before writing code. Check existing patterns with \`search\` first. Design, then implement`,
|
|
175
250
|
|
|
176
251
|
Frontend: `**Read \`AGENTS.md\`** in the workspace root for project conventions and KB protocol.
|
|
177
252
|
|
|
178
|
-
**Read _shared/code-agent-base.md NOW** — it contains
|
|
253
|
+
**Read _shared/code-agent-base.md NOW** — it contains the Information Lookup Order, FORGE, and handoff protocols.
|
|
179
254
|
|
|
180
255
|
## Frontend Protocol
|
|
181
256
|
|
|
@@ -194,28 +269,31 @@ For each batch: Implement (parallel) → Code Review → Architecture Review (if
|
|
|
194
269
|
|
|
195
270
|
Debugger: `**Read \`AGENTS.md\`** in the workspace root for project conventions and KB protocol.
|
|
196
271
|
|
|
197
|
-
**Read _shared/code-agent-base.md NOW** — it contains
|
|
272
|
+
**Read _shared/code-agent-base.md NOW** — it contains the Information Lookup Order, FORGE, and handoff protocols.
|
|
198
273
|
|
|
199
274
|
## Debugging Protocol
|
|
200
275
|
|
|
201
276
|
1. **KB Recall** — Search for known issues matching this error pattern
|
|
202
277
|
2. **Reproduce** — Confirm the error, use \`parse_output\` on stack traces and build errors for structured analysis
|
|
203
|
-
3. **
|
|
204
|
-
4. **
|
|
205
|
-
5. **
|
|
206
|
-
6. **
|
|
207
|
-
7. **
|
|
278
|
+
3. **Verify targets exist** — Before tracing, confirm the files and functions mentioned in the error actually exist. Use \`find\` or \`symbol\` to verify paths and signatures. **Never trace into a file you haven't confirmed exists**
|
|
279
|
+
4. **Trace** — \`symbol\`, \`trace\`, follow call chains backwards
|
|
280
|
+
5. **Diagnose** — Form hypothesis, gather evidence, identify root cause
|
|
281
|
+
6. **Fix** — Implement the fix, verify with tests
|
|
282
|
+
7. **Validate** — \`check\`, \`test_run\` to confirm no regressions
|
|
283
|
+
8. **Persist** — \`remember\` the fix with category \`troubleshooting\`
|
|
208
284
|
|
|
209
285
|
## Rules
|
|
210
286
|
|
|
211
287
|
- **Never guess** — Always trace the actual execution path
|
|
212
288
|
- **Reproduce first** — Confirm the error before attempting a fix
|
|
213
289
|
- **Minimal fix** — Fix the root cause, don't add workarounds
|
|
214
|
-
- **Test the fix** — Every fix must have a test that would have caught the bug
|
|
290
|
+
- **Test the fix** — Every fix must have a test that would have caught the bug
|
|
291
|
+
- **Verify before asserting** — Don't claim a function has a certain signature without checking via \`symbol\`. Don't reference a config option without confirming it exists in the codebase
|
|
292
|
+
- **Break debug loops** — If you apply a fix, test, and get the same error 3 times: your hypothesis is wrong. STOP, discard your current theory, re-examine the error output and trace from a different entry point. Return \`ESCALATE\` if a fresh approach also fails`,
|
|
215
293
|
|
|
216
294
|
Refactor: `**Read \`AGENTS.md\`** in the workspace root for project conventions and KB protocol.
|
|
217
295
|
|
|
218
|
-
**Read _shared/code-agent-base.md NOW** — it contains
|
|
296
|
+
**Read _shared/code-agent-base.md NOW** — it contains the Information Lookup Order, FORGE, and handoff protocols.
|
|
219
297
|
|
|
220
298
|
## Refactoring Protocol
|
|
221
299
|
|
|
@@ -241,9 +319,20 @@ For each batch: Implement (parallel) → Code Review → Architecture Review (if
|
|
|
241
319
|
|
|
242
320
|
Security: `**Read \`AGENTS.md\`** in the workspace root for project conventions and KB protocol.
|
|
243
321
|
|
|
322
|
+
**Read _shared/code-agent-base.md NOW** — it contains the Information Lookup Order, FORGE, and handoff protocols.
|
|
323
|
+
|
|
324
|
+
## MANDATORY FIRST ACTION
|
|
325
|
+
|
|
326
|
+
1. Run \`status({})\` — if onboard shows ❌, run \`onboard({ path: "." })\` and wait for completion
|
|
327
|
+
2. Note the **Onboard Directory** path from status output, then read relevant artifacts using \`compact({ path: "<dir>/<file>" })\`:
|
|
328
|
+
- \`synthesis-guide.md\` — project overview and architecture
|
|
329
|
+
- \`patterns.md\` — established conventions (check for security-related patterns)
|
|
330
|
+
- \`api-surface.md\` — exported function signatures (attack surface)
|
|
331
|
+
3. \`search("security vulnerabilities conventions")\` + \`list()\` for past findings
|
|
332
|
+
|
|
244
333
|
## Security Review Protocol
|
|
245
334
|
|
|
246
|
-
1. **KB Recall** —
|
|
335
|
+
1. **KB Recall** — \`search("security findings <area>")\` + \`list()\` for past security decisions and known issues
|
|
247
336
|
2. **Audit** — Run \`audit\` for a comprehensive project health check, then \`find\` for specific vulnerability patterns
|
|
248
337
|
3. **OWASP Top 10 Scan** — Check each category systematically
|
|
249
338
|
4. **Dependency Audit** — Check for known CVEs in dependencies
|
|
@@ -252,7 +341,7 @@ For each batch: Implement (parallel) → Code Review → Architecture Review (if
|
|
|
252
341
|
7. **Input Validation** — Check all user inputs for injection vectors
|
|
253
342
|
8. **Impact Analysis** — Use \`trace\` on sensitive functions, \`blast_radius\` on security-critical files
|
|
254
343
|
9. **Report** — Severity-ranked findings with remediation guidance
|
|
255
|
-
10. **Persist** — \`remember
|
|
344
|
+
10. **Persist** — \`remember({ title: "Security: <finding>", content: "<details, severity, remediation>", category: "troubleshooting" })\` for each significant finding
|
|
256
345
|
|
|
257
346
|
## Severity Levels
|
|
258
347
|
|
|
@@ -275,13 +364,24 @@ For each batch: Implement (parallel) → Code Review → Architecture Review (if
|
|
|
275
364
|
|
|
276
365
|
Documenter: `**Read \`AGENTS.md\`** in the workspace root for project conventions and KB protocol.
|
|
277
366
|
|
|
367
|
+
**Read _shared/code-agent-base.md NOW** — it contains the Information Lookup Order, FORGE, and handoff protocols.
|
|
368
|
+
|
|
369
|
+
## MANDATORY FIRST ACTION
|
|
370
|
+
|
|
371
|
+
1. Run \`status({})\` — if onboard shows ❌, run \`onboard({ path: "." })\` and wait for completion
|
|
372
|
+
2. Note the **Onboard Directory** path from status output, then read relevant artifacts using \`compact({ path: "<dir>/<file>" })\`:
|
|
373
|
+
- \`synthesis-guide.md\` — project overview and architecture
|
|
374
|
+
- \`structure.md\` — file tree and module purposes
|
|
375
|
+
- \`patterns.md\` — established conventions
|
|
376
|
+
3. \`search("documentation conventions")\` + \`list()\` for existing docs and standards
|
|
377
|
+
|
|
278
378
|
## Documentation Protocol
|
|
279
379
|
|
|
280
|
-
1. **KB Recall** —
|
|
380
|
+
1. **KB Recall** — \`search("documentation <area>")\` + \`list()\` for existing docs, conventions, architecture decisions
|
|
281
381
|
2. **Analyze** — \`analyze_structure\`, \`analyze_entry_points\`, \`file_summary\`
|
|
282
382
|
3. **Draft** — Write documentation following project conventions
|
|
283
383
|
4. **Cross-reference** — Link to related docs, ensure consistency
|
|
284
|
-
5. **Persist** — \`remember\` documentation standards
|
|
384
|
+
5. **Persist** — \`remember({ title: "Docs: <standard>", content: "<details>", category: "conventions" })\` for new documentation standards
|
|
285
385
|
|
|
286
386
|
## Documentation Types
|
|
287
387
|
|
|
@@ -307,6 +407,18 @@ For each batch: Implement (parallel) → Code Review → Architecture Review (if
|
|
|
307
407
|
|
|
308
408
|
Explorer: `**Read \`AGENTS.md\`** in the workspace root for project conventions and KB protocol.
|
|
309
409
|
|
|
410
|
+
## MANDATORY FIRST ACTION
|
|
411
|
+
|
|
412
|
+
1. Run \`status({})\` — if onboard shows ❌, run \`onboard({ path: "." })\` and wait for completion
|
|
413
|
+
2. Note the **Onboard Directory** path from status output
|
|
414
|
+
3. **Before exploring**, read relevant onboard artifacts using \`compact({ path: "<dir>/<file>" })\`:
|
|
415
|
+
- \`synthesis-guide.md\` — project overview and architecture
|
|
416
|
+
- \`structure.md\` — file tree and module purposes
|
|
417
|
+
- \`symbols.md\` + \`api-surface.md\` — exported symbols
|
|
418
|
+
- \`dependencies.md\` — import relationships
|
|
419
|
+
- \`code-map.md\` — module graph
|
|
420
|
+
4. Only use \`find\`, \`symbol\`, \`trace\` for details NOT covered by artifacts
|
|
421
|
+
|
|
310
422
|
## Exploration Protocol
|
|
311
423
|
|
|
312
424
|
1. **KB Recall** — \`search\` for existing analysis on this area
|