@vpxa/aikit 0.1.308 → 0.1.310

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.
Files changed (52) hide show
  1. package/package.json +1 -1
  2. package/packages/blocks-core/dist/index.mjs +5 -5
  3. package/packages/blocks-interactive/dist/index.d.mts +1 -1
  4. package/packages/blocks-interactive/dist/index.mjs +2 -2
  5. package/packages/browser/dist/index.js +8 -7
  6. package/packages/cli/dist/index.js +3 -3
  7. package/packages/cli/dist/{init-CyjUXjQw.js → init-DokIBPoi.js} +1 -1
  8. package/packages/cli/dist/{templates-BQ1J4HzY.js → templates-WMcV7ag2.js} +8 -8
  9. package/packages/present/dist/index.html +137 -93
  10. package/packages/server/dist/bin.js +1 -1
  11. package/packages/server/dist/index.js +1 -1
  12. package/packages/server/dist/repair-json-B6Q_HRoP.js +3 -0
  13. package/packages/server/dist/repair-json-D4mft_HA.js +4 -0
  14. package/packages/server/dist/{server-D6sJEw0I.js → server-CUEJEod-.js} +162 -164
  15. package/packages/server/dist/{server-http-B1ixOw2x.js → server-http-C2Vv-0lq.js} +1 -1
  16. package/packages/server/dist/{server-http-BurquBLf.js → server-http-DLqbe1NN.js} +1 -1
  17. package/packages/server/dist/server-stdio-RjYFfC_c.js +1 -0
  18. package/packages/server/dist/server-stdio-h8m_nhNo.js +2 -0
  19. package/packages/server/dist/{server-BSvqfFcK.js → server-uxrUzJ0L.js} +162 -164
  20. package/packages/server/viewers/c4-viewer.html +1 -1
  21. package/packages/server/viewers/canvas.html +4 -4
  22. package/packages/server/viewers/report-template.html +52 -52
  23. package/packages/server/viewers/task-plan-static.html +1 -1
  24. package/packages/server/viewers/tour-viewer.html +4 -4
  25. package/packages/tools/dist/index.d.ts +7 -0
  26. package/packages/tools/dist/index.js +71 -71
  27. package/scaffold/INSTRUCTIONS.md +273 -0
  28. package/scaffold/dist/adapters/copilot.mjs +2 -9
  29. package/scaffold/dist/adapters/hermes-agent.mjs +2 -2
  30. package/scaffold/dist/adapters/hermes.mjs +8 -4
  31. package/scaffold/dist/adapters/intellij.mjs +7 -3
  32. package/scaffold/dist/adapters/skills.mjs +3 -1
  33. package/scaffold/dist/adapters/zed.mjs +6 -2
  34. package/scaffold/dist/definitions/agents.mjs +2 -2
  35. package/scaffold/dist/definitions/bodies.mjs +100 -362
  36. package/scaffold/dist/definitions/protocols.mjs +109 -549
  37. package/scaffold/dist/definitions/skills/adr-skill.mjs +41 -197
  38. package/scaffold/dist/definitions/skills/aikit.mjs +52 -205
  39. package/scaffold/dist/definitions/skills/brainstorming.mjs +74 -112
  40. package/scaffold/dist/definitions/skills/browser-use.mjs +128 -184
  41. package/scaffold/dist/definitions/skills/c4-architecture.mjs +46 -107
  42. package/scaffold/dist/definitions/skills/docs.mjs +70 -214
  43. package/scaffold/dist/definitions/skills/frontend-design.mjs +96 -193
  44. package/scaffold/dist/definitions/skills/lesson-learned.mjs +57 -184
  45. package/scaffold/dist/definitions/skills/multi-agents-development.mjs +98 -408
  46. package/scaffold/dist/definitions/skills/present.mjs +193 -1
  47. package/scaffold/dist/definitions/skills/react.mjs +68 -111
  48. package/scaffold/dist/definitions/skills/repo-access.mjs +24 -169
  49. package/scaffold/dist/definitions/skills/requirements-clarity.mjs +45 -94
  50. package/scaffold/dist/definitions/skills/typescript.mjs +162 -230
  51. package/packages/server/dist/server-stdio-CBmXDMpq.js +0 -1
  52. package/packages/server/dist/server-stdio-z3_zG1HF.js +0 -2
@@ -20,597 +20,157 @@ ${e===`<PROFILE>`?`**Profile:** Check your role → implementer | documenter | r
20
20
  ---`}function n(){return"\n## Evidence Citation Protocol (tier-aware)\n\nNo FORGE `task_id` → skip `evidence_map`; use `file:line` citations only.\nDo not create your own `task_id` or run the gate.\n\n| Tier | Your responsibility |\n|------|---------------------|\n| Floor | Findings with `file.ts#Lxx` citations. No `evidence_map`. |\n| Standard | Add 2-4 CRITICAL/HIGH findings with receipts. |\n| Critical | Add all CRITICAL/HIGH findings; tag contract/security claims with `safety_gate`. |\n\n**Every response MUST include:**\n- `**FORGE Task ID:** <task_id>` (passed in by Orchestrator, or state \"not provided\")\n- `**Tier applied:** Floor | Standard | Critical`\n- `**Findings:** <list>` with `file:line` receipts\n- Verdict: `APPROVED` | `CHANGES_REQUESTED` | `BLOCKED`\n\nDo NOT create a new `evidence_map`, run `evidence_map({action:'gate'})`, or add non-critical noise."}function r(...e){return e.filter(Boolean).join(`
21
21
 
22
22
  `)}function i({title:e=`Knowledge Recall`,intro:t,commands:n,followUp:i}={}){return r(`## Pre-Task: ${e} (MANDATORY)`,t,["```",...(Array.isArray(n)?n:[n]).filter(Boolean),"```"].join(`
23
- `),i)}function a(){return r(`## Post-Task: Capture Lesson`,`**HARD RULE:** Before DONE, capture 1-2 lessons unless change is pure config/formatting.`,'Quick capture:\n```\nknowledge({ action: "lesson", subAction: "create", context: "<what situation you faced>", insight: "<what principle the solution demonstrates>", evidence: "<file:line or commit that proves it>", confidence: 65 })\n```',"If recalled lesson was confirmed/invalid, use `confirm` or `contradict`.")}const o=r(`## Output Rules (HARD RULE)`,`**Plain text is allowed only when ALL are true:**`,` - Response is 1-2 short sentences.`,` - No table, list, checklist, plan, report, verdict, review, summary, progress, evidence map, or batch result is being returned.`,` - No user approval, mandatory stop, or choice is needed.`,"Follow the **Presentation Priority** (1st Inline Visual - `present({ schemaVersion: 1, title, blocks })` → 2nd Interactive - `present({ schemaVersion: 1, title, blocks, actions })` → 3rd Plain Text). Only tiny status/questions that pass the gate above → plain text (Priority 3). Prefer `present` for all others, especially summaries, comparisons, reports, task plans, verdicts, and progress."),s=r(`## AI Kit Recovery`,"If AI Kit tools are unavailable or missing, run `npx -y @vpxa/aikit@latest init --user`, then reload the client so the `aikit` MCP server and user instructions become available."),c={"code-agent-base":`# Code Agent Shared Base Instructions
23
+ `),i)}function a(){return r(`## Post-Task: Capture Lesson`,`**HARD RULE:** Before DONE, capture 1-2 lessons unless change is pure config/formatting.`,'Quick capture:\n```\nknowledge({ action: "lesson", subAction: "create", context: "<what situation you faced>", insight: "<what principle the solution demonstrates>", evidence: "<file:line or commit that proves it>", confidence: 65 })\n```',"If recalled lesson was confirmed/invalid, use `confirm` or `contradict`.")}const o=r(`## Output Rules (HARD RULE)`,`**Plain text is allowed only when ALL are true:**`,` - Response is 1-2 short sentences.`,` - No table, list, checklist, plan, report, verdict, review, summary, progress, evidence map, or batch result is being returned.`,` - No user approval, mandatory stop, or choice is needed.`,"Follow the **Presentation Priority** (1st Inline Visual - `present({ schemaVersion: 1, title, blocks })` → 2nd Interactive - `present({ schemaVersion: 1, title, blocks, actions })` → 3rd Plain Text). Only tiny status/questions that pass the gate above → plain text (Priority 3). Prefer `present` for all others, especially summaries, comparisons, reports, task plans, verdicts, and progress.");function s(){return"## Tool Preference — AI Kit First (HARD RULE)\n\n**Never start with `read_file`, `grep_search`, `semantic_search`, or `run_in_terminal`. AI Kit tools replace all of these.**\n\n| Need | Use | NEVER |\n|------|-----|-------|\n| Structure of a file | `file_summary({ path })` | `read_file` to \"understand\" it |\n| Find specific code | `compact({ path, query })` | `read_file` to search |\n| Multiple files | `digest({ sources, query })` | Multiple `read_file` calls |\n| Reuse previous output | `compact({ ref, query? })` with `enrich:true` | Re-reading same file |\n| Search codebase | `search({ query })` | `grep_search` / `semantic_search` |\n| Find a symbol | `symbol({ name })` | `grep_search` |\n| Trace data flow | `trace({ items: [{start, direction}] })` | Manual code tracing |\n| Module relationships | `graph({action:'neighbors', node_id})` | Manual import tracing |\n| Typecheck + lint | `check({})` | `run_in_terminal tsc` / biome |\n| Run tests | `test_run({})` | `run_in_terminal vitest` |\n| Impact analysis | `blast_radius({ changed_files })` | Manual caller tracing |\n| Complexity metrics | `measure({ path })` | Line counting / wc |\n| Web research | `web_search({ queries })` + `web_fetch({ urls })` | `fetch_webpage` |\n\n`read_file` is ONLY acceptable when you need exact line content FOR EDITING (before `replace_string_in_file`).\n\nEven then, use `file_summary` first to identify which lines to read."}const c=r(`## AI Kit Recovery`,"If AI Kit tools are unavailable or missing, run `npx -y @vpxa/aikit@latest init --user`, then reload the client so the `aikit` MCP server and user instructions become available."),l={"code-agent-base":`# Code Agent - Shared Kernel
24
24
 
25
- > Shared protocol for code-writing agents. Agent-specific files should not duplicate it.
25
+ > Shared protocol for code-writing agents. Role files add only role-specific behavior.
26
26
 
27
- ## Invocation Mode Detection
27
+ ## Mode
28
+ - Direct: full AI Kit access.
29
+ - Subagent: prompt includes \`runSubagent\`, \`## Prior AI Kit Context\`, or \`### Current Code Context\`; use provided context first and return structured text only.
28
30
 
29
- Two modes:
30
- 1. **Direct** full AI Kit access. Follow **Information Lookup Order**.
31
- 2. **Sub-agent** — limited tools possible. If prompt includes "## Prior AI Kit Context" or "### Current Code Context", use that context and do not re-read it.
31
+ ## Bootstrap
32
+ 1. \`status({ includePrelude: true })\`; onboard if needed.
33
+ 2. If dispatched in a flow, \`flow({ action: 'status' })\` and \`flow({ action: 'read' })\`; do not advance the flow.
34
+ 3. Use Orchestrator-provided context before new searches.
32
35
 
33
- **Detection:** "## Prior AI Kit Context" OR "### Current Code Context" OR \`runSubagent\` → sub-agent mode. Return structured text only.
36
+ ## Orchestrator Contract
37
+ - Stay inside assigned files and boundary.
38
+ - No \`present\`; subagent visual output is invisible.
39
+ - No flow advance, no broad changed-file dumps, no unrelated refactors.
40
+ - Use terse style if requested by Orchestrator.
41
+ - End with one status: \`DONE\` | \`DONE_WITH_CONCERNS\` | \`NEEDS_CONTEXT\` | \`BLOCKED\`.
34
42
 
35
- ---
43
+ ${s()}
36
44
 
37
- ## MANDATORY FIRST ACTION — AI Kit Initialization
38
-
39
- Before other work:
40
- 1. Run \`status({})\`. Record **Onboard Directory**.
41
- 2. If onboard is ❌, run \`onboard({ path: "." })\` and wait.
42
- 3. If onboard is ✅, continue.
43
-
44
- ---
45
-
46
- ## AI Kit Tool Discipline
47
-
48
- Use AI Kit retrieval/compression first. Native tools are fallback only.
45
+ ## Protocol Coverage
46
+ - conversation-compression: prefer provided compressed context; stash/remember concise findings before context changes; never paste raw long output.
47
+ - decision-protocol: when requirements conflict or design fork appears, return options, recommendation, confidence, and unresolved unknowns instead of guessing.
48
+ - forge-protocol: respect tier/task_id, add only verified CRITICAL/HIGH evidence, leave gate ownership to Orchestrator.
49
+ - thinking-principles: name assumptions, verify local facts, surface contradictions, fail loud when evidence is missing.
50
+ - access protocol: \`401\`/\`403\`/\`404\`/\`407\`, login HTML, CAPTCHA, SSO, or repo auth failure -> \`NEEDS_CONTEXT\` with receipt.
51
+ - context-cache protocol: search/reuse \`ctxc_...\`, stash, or flow withdrawal before rereading same path/topic.
49
52
 
50
53
  ${e()}
51
54
 
52
- > **Path Note:** \`compact({ items: [{path, query}] })\` and \`file_summary({ items: [{path}] })\` accept any absolute path. Cached \`ctxc_...\` values are reversible refs passed as \`ref\` to \`compact({ ref })\` or \`compact({ ref, query? })\`; do not invent a separate \`read\`/\`id\` contract.
53
-
54
- **\`read_file\` is ONLY for exact edit lines.** Use \`file_summary\` or \`compact\` first.
55
-
56
- ## compact() Failure Recovery
57
-
58
- \`compact()\` <200 bytes or empty usually means unindexed file:
59
- 1. Do not retry.
60
- 2. Use one large \`read_file\` range.
61
- 3. Cache findings with \`stash()\`.
62
- 4. Check \`status()\` before another \`compact\`.
63
-
64
- ---
65
-
66
- ## Context Caching (MANDATORY for multi-step tasks)
67
-
68
- After first \`file_summary\` or \`compact\` on a file, cache it:
69
- \`\`\`
70
- stash({ action: 'set', key: 'ctx:<filename>', value: '<summary result>' })
71
- \`\`\`
72
-
73
- Before reading same file again, check cache:
74
- \`\`\`
75
- stash({ action: 'get', key: 'ctx:<filename>' })
76
- \`\`\`
77
-
78
- If cached → reuse. If not → fetch and cache. Never \`read_file\` same file twice without checking \`stash\`.
79
-
80
- ---
81
-
82
- ## Access Failure Detection
83
-
84
- When \`web_fetch\` or \`http\` hits access issues, report immediately.
85
-
86
- **Detection signals:**
87
- - \`web_fetch\` returns HTML containing: \`login\`, \`sign in\`, \`sign-in\`, \`saml\`, \`sso\`, \`captcha\`, \`verify\`, \`cloudflare\`, \`challenge\`
88
- - \`http\` returns status 401, 403, or 407
89
- - \`web_fetch\` returns a redirect to a different domain (SSO redirect)
90
-
91
- **Action:** Report \`NEEDS_CONTEXT\` with URL, trigger, and short quote/status. Do not self-escalate.
92
-
93
- ## Present + Browser Coordination
94
-
95
- When \`present()\` opens browser transport, default browser handles user view. Open in controlled browser only if you must inspect it programmatically.
96
-
97
-
98
- ## Domain Skills
99
-
100
- Check agent **Skills**. If task matches, load that skill first.
101
- **\`aikit\`** is foundational; do not re-load it.
102
-
103
- ## Skills NOT Permitted for Code Agents
104
-
105
- Planning-only skills: \`brainstorming\`, \`requirements-clarity\`, \`multi-agents-development\`, \`c4-architecture\`, \`adr-skill\`, \`present\`.
106
- If reqs/design are unclear, return \`NEEDS_CONTEXT\`.
107
-
108
- ---
109
-
110
- ## Information Lookup Order (MANDATORY)
111
-
112
- Follow this order. Do not skip to step 3 before checking steps 1-2.
113
- Use \`compact({ items: [{path: "<dir>/<file>"}] })\` for onboard artifacts.
114
-
115
- ### Step 1: Onboard Artifacts (pre-analyzed, fastest)
116
-
117
- | Need to understand... | Read this artifact |
118
- |---|---|
119
- | Project overview, tech stack | \`synthesis-guide.md\` |
120
- | File tree, module purposes | \`structure.md\` |
121
- | Import graph, dependencies | \`dependencies.md\` |
122
- | Exported functions, classes | \`symbols.md\` |
123
- | Function signatures, JSDoc, decorators | \`api-surface.md\` |
124
- | Interface/type/enum definitions | \`type-inventory.md\` |
125
- | Architecture patterns, conventions | \`patterns.md\` |
126
- | CLI bins, route handlers, main exports | \`entry-points.md\` |
127
- | C4 architecture diagram | \`diagram.md\` |
128
- | Module graph with key symbols | \`code-map.md\` |
129
-
130
- ### Step 2: Knowledge Recall (MANDATORY before implementation)
131
-
132
- Before writing code, check prior decisions and flow context.
133
-
134
- \`\`\`
135
- search({ query: "<feature/area keywords>", limit: 5 }) // check past decisions + auto-knowledge
136
- knowledge({ action: "list", category: "decisions" }) // scan recent decisions that might apply
137
- knowledge({ action: "list", category: "conventions" }) // see project conventions (includes auto-captured)
138
- knowledge({ action: "lesson", subAction: "list-lessons", topic: "<2-3 task keywords>", minConfidence: 70 }) // topic-scoped lessons
139
-
140
- // Lesson lifecycle management
141
- knowledge({ action: "lesson", subAction: "prune" }) // dry-run: review stale candidates
142
- knowledge({ action: "lesson", subAction: "prune", dryRun: false }) // execute prune
143
- knowledge({ action: "lesson", subAction: "group" }) // dry-run: show clusters
144
- knowledge({ action: "lesson", subAction: "group", dryRun: false }) // execute grouping
145
- knowledge({ action: "lesson", subAction: "promote" }) // dry-run: cross-workspace scan
146
- knowledge({ action: "lesson", subAction: "promote", dryRun: false }) // promote to global
147
- knowledge({ action: "lesson", subAction: "demote", path: "<path>" }) // remove from global
148
-
149
- // Session prelude (at session start)
150
- status({ includePrelude: true }) // top 3 lessons + top 2 conventions + checkpoint
151
-
152
- scope_map({ task: "what you need" }) // generates a reading plan
153
-
154
- // If running as sub-agent with flow context:
155
- knowledge({ action: "withdraw", scope: "flow", profile: "<your-role>", budget: 6000 }) // get pre-analyzed context from prior agents
156
- \`\`\`
157
-
158
- **Rules:**
159
- - Scope recalls.
160
- - Results exist → follow them or surface conflict.
161
- - Reuse flow/stash/checkpoint/workset context before re-running tools.
162
- - No results → proceed, then persist decisions.
163
-
164
- #### Role-Specific Auto-Knowledge Recall
165
-
166
- Use targeted searches before expensive work:
167
-
168
- **Passive recall:** Most tools accept \`enrich: true\` — this automatically appends previously captured facts relevant to your query. Use it on analysis tools (\`search\`, \`symbol\`, \`trace\`, \`graph\`, \`file_summary\`, \`compact\`, \`scope_map\`, \`blast_radius\`).
169
-
170
- **Active recall (for specific needs):**
171
-
172
- | Your Role | Before doing... | Search for auto-knowledge first |
173
- |-----------|-----------------|--------------------------------|
174
- | Debugger | Retrying failed tool | \`search({ query: "<tool-name> error", content_type: "curated-knowledge", limit: 3 })\` |
175
- | Implementer / Frontend | Creating tests | \`search({ query: "testing convention naming", content_type: "curated-knowledge", limit: 3 })\` |
176
- | Researcher | Fetching web docs | \`search({ query: "<domain-or-topic>", content_type: "curated-knowledge", limit: 3 })\` |
177
- | Any agent | Expensive analysis | Check withdrawn flow-context + \`stash\` first |
178
-
179
- ### Step 3: Real-time Exploration (only if steps 1-2 don't cover it)
180
-
181
- | Tool | Use for |
182
- |---|---|
183
- | \`graph({ action: 'neighbors', node_id })\` | Module relationships |
184
- | \`find({ pattern })\` | Locate files by name/glob |
185
- | \`symbol({ items: [{name}] })\` | Definition + refs |
186
- | \`trace({ items: [{start, direction}] })\` | Call/data flow |
187
- | \`compact({ items: [{path, query}] })\` | Read specific section of a file |
188
- | \`compact({ ref, query? })\` | Reuse cached search/find/knowledge/compact output |
189
- | \`read_file\` | **ONLY** when you need exact lines for a pending edit |
190
-
191
- ### Step 4: Tool Discovery
192
-
193
- If unsure which AI Kit tool to use → run \`guide({ goal: "what you need" })\` for recommendations.
194
-
195
- ---
196
-
197
- ## FORGE Protocol (Quality Gate)
198
-
199
- 1. Use Orchestrator-provided FORGE tier or run \`forge_classify\`.
200
- 2. Floor → implement directly.
201
- 3. Standard/Critical → track key claims in \`evidence_map\`.
202
- 4. Orchestrator owns the final gate.
203
-
204
- ---
205
-
206
- ## Loop Detection & Tooling Failure Modes
207
-
208
- Repeated failure → stop and change strategy.
209
-
210
- | Signal | Action |
211
- |--------|--------|
212
- | Same error **3 times** | Stop. New approach. |
213
- | Same test output after change | Re-read error. Change approach. |
214
- | Fix→test→same error | Re-diagnose with \`trace\`. |
215
- | \`read_file\`→edit→same state | Verify file/position with \`check\`. |
216
-
217
- **Escalation ladder:**
218
- 1. Strikes 1-2 → retry with changed assumptions.
219
- 2. Strike 3 → stop current approach.
220
- 3. Still stuck → return \`ESCALATE\` with what was tried and why it failed.
221
-
222
- ### Tooling failure exits
223
- | Signal | Stop condition | Exit action |
224
- |--------|---------------|-------------|
225
- | \`evidence_map\` returns HOLD | Missing evidence | Surface gaps |
226
- | Sub-agent returns BLOCKED | Cannot proceed | Escalate |
227
- | \`onboard\` reports stale index (>7 days) | Index stale | Run \`reindex({})\` once |
228
- | \`check\` or \`test_run\` fails 3x identical | Same failure | Stop and surface output |
229
- | \`compact\` returns < 50% reduction | Poor compression | Use \`file_summary\` or \`stratum_card\` |
230
-
231
- ## Sub-agent Context Budget
232
-
233
- Choose tier by task size:
234
-
235
- | Tier | Budget | Tools | Use For |
236
- |------|--------|-------|---------|
237
- | **Floor** | T1 stratum_card only | Read-only | Quick lookups, single-file Q&A |
238
- | **Standard** | compact() + T2 stratum_card | Read-only + search | Multi-file analysis, research |
239
- | **Critical** | digest() + stratum_card + flow context | Full | Implementation, decisions, multi-step |
240
-
241
- Always tell the subagent: profile, tier, and what they should NOT do.
242
-
243
- ---
244
-
245
- ## Hallucination Self-Check
246
-
247
- Verify before asserting.
248
-
249
- | Before you... | First verify with... |
250
- |---------------|---------------------|
251
- | Reference a file path | \`find({ pattern })\` or \`file_summary({ items: [{path}] })\` |
252
- | Call a function/method | \`symbol({ items: [{name}] })\` |
253
- | Claim a dependency exists | \`search({ query: "package-name" })\` or check \`package.json\` |
254
- | Assert a fix works | \`check({})\` + \`test_run({})\` |
255
- | Describe behavior | \`compact({ items: [{path, query}] })\` |
256
-
257
- **Rule:** Not verified this session → unverified.
258
-
259
- ---
260
-
261
- ## Ambiguity Resolution Protocol
262
-
263
- If ≥2 valid interpretations:
264
- 1. Name them.
265
- 2. Pick highest-harm assumption.
266
- 3. Ask one disambiguating question.
267
-
268
- ## Scope Guard
269
-
270
- Set expected file count before changes. If scope doubles, stop and reassess.
271
-
272
- ---
273
-
274
- ## MANDATORY: Memory Persistence Before Completing
275
-
276
- Before finishing, call \`knowledge({ action: "remember", ... })\` if you discovered a non-obvious pattern, decision, workaround, or gotcha.
277
-
278
- How to persist knowledge:
279
- \`\`\`
280
- knowledge({
281
- action: "remember",
282
- title: "Short descriptive title",
283
- content: "Detailed finding with context",
284
- category: "patterns" | "conventions" | "decisions" | "troubleshooting"
285
- })
286
- \`\`\`
287
-
288
- For outdated entries → \`knowledge({ action: "update", path, content, reason })\`.
289
-
290
- ---
291
-
292
- ## Guidelines
293
-
294
- Use these rules when writing, reviewing, or refactoring.
295
-
296
- ### 1. Think Before Coding
297
-
298
- - State assumptions.
299
- - Multiple interpretations → surface them.
300
- - Simpler path exists → say so.
301
- - Unclear → stop and ask.
302
- - Read nearby patterns first.
303
-
304
- ### 2. Simplicity First
305
-
306
- - Minimum code that solves the task.
307
- - No speculative abstractions, flexibility, or impossible-scenario handling.
308
- - If 200 lines could be 50, rewrite it.
309
-
310
- ### 3. Surgical Changes
311
-
312
- - Touch only required lines.
313
- - Match existing style.
314
- - Remove only dead code you create.
315
- - Every changed line should trace to request.
316
-
317
- ### 4. Goal-Driven Execution
318
-
319
- Define success criteria and verify them.
320
-
321
- For multi-step tasks, state a brief plan:
322
- \`\`\`
323
- 1. [Step] → verify: [check]
324
- 2. [Step] → verify: [check]
325
- 3. [Step] → verify: [check]
326
- \`\`\`
327
-
328
- ### 5. Quality Dimensions
329
-
330
- Verify each before returning handoff:
331
-
332
- | Dimension | Check |
333
- |-----------|-------|
334
- | **Correctness** | Does it do what was asked? Tests pass? |
335
- | **Standards** | Follows project conventions? Lint-clean? |
336
- | **Architecture** | Fits existing patterns? No unnecessary coupling? |
337
- | **Robustness** | Handles edge cases? No obvious failure modes? |
338
- | **Maintainability** | Clear naming? Minimal complexity? Understandable to another developer? |
339
-
340
- ### 6. Test-Driven Development
341
-
342
- - Vertical slices, not horizontal layers.
343
- - One test → make it pass → repeat.
344
- - Start with tracer bullet.
345
- - Test public behavior, not implementation detail.
55
+ ${n()}
346
56
 
347
- ---
57
+ ## Work Loop
58
+ 1. Restate scope and success criteria.
59
+ 2. Reproduce or write the smallest relevant test when code behavior changes.
60
+ 3. Implement minimal change; match local style.
61
+ 4. Run \`check({})\` + relevant \`test_run({})\`.
62
+ 5. Add evidence to Orchestrator-provided \`task_id\`; do not run gate.
63
+ 6. Capture a lesson only for non-obvious code changes.
348
64
 
349
- ${t(`<PROFILE>`)}
350
65
 
351
- ## Handoff Format
352
66
 
353
- Always return this structure when invoked as a sub-agent:
67
+ ## Failure Handling
68
+ - Access/auth failure -> \`NEEDS_CONTEXT\` with URL/status/trigger.
69
+ - Same error twice -> change approach or return \`BLOCKED\`.
70
+ - Scope doubles or boundary unclear -> stop and report.
354
71
 
72
+ ## Output
355
73
  \`\`\`markdown
356
- <handoff>
357
- <status>SUCCESS | PARTIAL | FAILED | ESCALATE</status>
358
- <summary>{1 sentence summary}</summary>
359
- <artifacts>
360
- - Created: {files}
361
- - Modified: {files}
362
- - Deleted: {files}
363
- </artifacts>
364
- <context>{what the next agent needs to know}</context>
365
- <blockers>{any blocking issues}</blockers>
366
- </handoff>
74
+ ## Status: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED
75
+ Files: <changed/read files>
76
+ Tests: <commands/results or not run + reason>
77
+ Evidence: <claims + receipts>
78
+ Decisions: <important choices>
79
+ Blockers: <only if any>
367
80
  \`\`\`
368
81
 
369
- ## AI Kit MCP Tool Naming Convention
82
+ Keep normal status under 200 words; include full detail only for \`BLOCKED\`.
370
83
 
371
- Tool references use short names (e.g. \`status\`, \`compact\`, \`search\`). Runtime names are usually prefixed:
84
+ ## Tool Names
85
+ Instructions use short names such as \`status\`, \`compact\`, \`search\`. Runtime may prefix names by client, e.g. \`mcp_aikit_status\` or \`mcp__aikit__status\`. Call the tool whose name ends with the requested short name.
86
+ `,"researcher-base":`# Researcher - Shared Kernel
372
87
 
373
- | Client | Tool naming pattern | Example |
374
- |--------|-------------------|---------|
375
- | VS Code Copilot | \`mcp_<serverName>_<tool>\` | \`mcp_aikit_status\` |
376
- | Claude Code | \`mcp__<serverName>__<tool>\` | \`mcp__aikit__status\` |
377
- | Other MCP clients | \`<serverName>_<tool>\` or bare \`<tool>\` | \`aikit_status\` or \`status\` |
378
-
379
- Server name is \`aikit\`.
380
- **When these instructions say** \`status({})\` **→ call the tool whose name ends with** \`_status\`.
381
- If tools are deferred/lazy-loaded, load them first (for example \`tool_search_tool_regex({ pattern: "aikit" })\`).
382
- `,"researcher-base":`# Researcher — Shared Base Instructions
383
-
384
- > Shared methodology for Researcher variants. Do not duplicate it in variant files.
385
-
386
-
387
- ## MANDATORY FIRST ACTION
388
-
389
- Follow **MANDATORY FIRST ACTION** and **Information Lookup Order** from code-agent-base:
390
- 1. Run \`status({})\` — check Onboard Status and note the **Onboard Directory** path
391
- 2. If onboard shows ❌ → Run \`onboard({ path: '.' })\` and wait for completion
392
- 3. If onboard shows ✅ → Read relevant onboard artifacts using \`compact({ items: [{path: '<Onboard Directory>/<file>'}] })\` before exploring
393
-
394
- Start with pre-analyzed artifacts.
88
+ > Researchers are read-only subagents for discovery, trade-offs, and decision input.
395
89
 
396
90
  ${t(`researcher`)}
397
91
 
398
- ## Research Methodology
399
-
400
- ### Phase 1: AI Kit Recall (BLOCKING)
401
- \`\`\`
402
- search({ query: "task keywords" })
403
- scope_map({ task: "what you need to investigate" })
404
- \`\`\`
405
-
406
- ### Phase 2: Exploration
407
- - Use \`graph\`, \`symbol\`, \`trace\`, \`find\` for code exploration.
408
- - Use \`file_summary\` and \`compact\` for reading.
409
- - Use \`analyze\` for package-level structure/deps.
410
- - Use \`web_search\` and \`web_fetch\` for external docs.
92
+ ${s()}
411
93
 
412
- ### Phase 3: Synthesis
413
- - Use \`digest\` and \`stratum_card\` to compress findings.
94
+ ## Method
95
+ 1. Start from Orchestrator question + provided context.
96
+ 2. Recall: \`search({ query })\` + relevant lessons/conventions.
97
+ 3. Explore with \`graph\`, \`symbol\`, \`trace\`, \`find\`, \`file_summary\`, \`compact\`, \`analyze\`; web tools only for external facts.
98
+ 4. Synthesize into recommendation, trade-offs, risks, confidence.
99
+ 5. Persist only durable non-obvious findings.
414
100
 
415
- ### Phase 4: Report
416
- Return structured findings. Include:
417
- 1. **Summary** — 1-3 sentence overview
418
- 2. **Key Findings** — Bullet list of important discoveries
419
- 3. **Files Examined** — Paths with brief purpose notes
420
- 4. **Recommendation** — Your suggested approach with reasoning
421
- 5. **Trade-offs** — Pros and cons of alternatives
422
- 6. **Risks** — What could go wrong
101
+ ## Decision Work
102
+ Commit to a recommendation. Cite evidence. Name blind spots. State confidence.
423
103
 
424
- ### Phase 5: MANDATORY — Persist Discoveries
425
-
426
- Before returning, call \`knowledge({ action: "remember", ... })\` for non-obvious findings, decisions, gotchas, or external research worth keeping.
427
-
428
- \`\`\`
429
- knowledge({
430
- action: "remember",
431
- title: "Short descriptive title",
432
- content: "Detailed finding with context",
433
- category: "patterns" | "conventions" | "decisions" | "troubleshooting"
434
- })
104
+ ## Output
105
+ \`\`\`markdown
106
+ ## Research: <question>
107
+ Summary: <1-3 sentences>
108
+ Findings:
109
+ - <claim> — <receipt>
110
+ Recommendation: <choice + why>
111
+ Trade-offs: <costs>
112
+ Risks: <risks/unknowns>
113
+ Confidence: <low|medium|high>
114
+ Status: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED
435
115
  \`\`\`
116
+ `,"code-reviewer-base":`# Code-Reviewer - Shared Kernel
436
117
 
437
- ---
438
-
439
- ## FORGE-Aware Research
440
-
441
- For code-change research:
442
- 1. Run \`forge_classify({ task, files, root_path })\`.
443
- 2. Standard+ → record key findings in \`evidence_map\`.
444
- 3. Report tier/risk implications.
445
-
446
- ---
447
-
448
- ## Multi-Model Decision Context
449
-
450
- When invoked for decision analysis, you receive a specific question. You MUST:
451
- 1. Commit to a recommendation.
452
- 2. Cite concrete evidence.
453
- 3. Acknowledge trade-offs.
454
- 4. State confidence.
455
-
456
- ---
457
-
458
- ## Invocation Mode Detection
459
-
460
- > **Mode:** Researchers always run as subagents — no Direct mode.
461
-
462
- ---
463
-
464
- ## Context Efficiency
465
-
466
- > Prefer \`compact\`/\`digest\`/\`file_summary\` over raw \`read_file\`.
467
-
468
- ## Parallel Exploration via \`lane\`
469
-
470
- For questions that require trying approach A vs approach B in isolation:
471
- 1. \`lane({ action:'create', name:'approach-a' })\` — isolated file copies
472
- 2. Evaluate approach A; record observations
473
- 3. \`lane({ action:'create', name:'approach-b' })\` — second isolate
474
- 4. Evaluate approach B; record observations
475
- 5. \`lane({ action:'diff', names:['approach-a','approach-b'] })\` — compare
476
- 6. Include the diff summary in your output; do NOT merge lanes back (read-only role)
477
- `,"code-reviewer-base":`# Code-Reviewer — Shared Base Instructions
478
-
479
- > Shared methodology for Code-Reviewer variants. Do not duplicate.
480
-
481
-
482
- ## MANDATORY FIRST ACTION
483
-
484
- Follow **MANDATORY FIRST ACTION** and **Information Lookup Order** from code-agent-base:
485
- 1. Run \`status({})\` — check Onboard Status and note the **Onboard Directory** path
486
- 2. If onboard shows ❌ → Run \`onboard({ path: '.' })\` and wait for completion
487
- 3. If onboard shows ✅ → Read relevant onboard artifacts using \`compact({ items: [{path: '<Onboard Directory>/<file>'}] })\` — especially \`patterns.md\` and \`api-surface.md\` for review context
118
+ > Review changed behavior, tests, correctness, security, maintainability, patterns, and type safety.
488
119
 
489
120
  ${t(`reviewer`)}
490
121
 
491
- ## Review Workflow
492
-
493
- 1. Recall patterns.
494
- 2. Run \`blast_radius\`.
495
- 3. Run \`forge_classify\`.
496
- 4. Review dimensions below.
497
- 5. Validate with \`check\` and \`test_run\`.
498
- 6. Report.
499
- 7. Persist recurring findings.
122
+ ${s()}
500
123
 
501
- ## Review Dimensions
124
+ ## Method
125
+ 1. Use provided diff/context first; run \`blast_radius\` when scope is unclear.
126
+ 2. Recall local patterns and review changed code against acceptance criteria.
127
+ 3. Validate with \`check({})\` and targeted \`test_run({})\` when available.
128
+ 4. Add only CRITICAL/HIGH claims to Orchestrator-provided \`task_id\`; do not gate.
502
129
 
503
- | Dimension | What to Check |
504
- |-----------|---------------|
505
- | **Correctness** | Logic errors, off-by-one, null handling, async/await |
506
- | **Security** | OWASP Top 10, input validation, secrets exposure |
507
- | **Performance** | N+1 queries, unnecessary allocations, missing caching |
508
- | **Maintainability** | Naming, complexity, DRY, single responsibility |
509
- | **Testing** | Coverage for new/changed logic, edge cases |
510
- | **Patterns** | Consistency with existing codebase conventions |
511
- | **Types** | Proper typing, no \`any\`, generics where useful |
512
-
513
- ## Output Format
130
+ ## Severity
131
+ - CRITICAL: runtime/data/security failure.
132
+ - HIGH: likely bug, exploitable issue, broken contract.
133
+ - MEDIUM: maintainability/performance/test gap.
134
+ - LOW: style/naming.
514
135
 
136
+ ## Output
515
137
  \`\`\`markdown
516
- ## Code Review: {scope}
517
- **Verdict: APPROVED | NEEDS_REVISION | FAILED**
518
- **Severity: {count by level}**
519
-
520
- ### Findings
521
- 1. **[SEVERITY]** {file}:{line}Description and fix
522
-
523
- ### Summary
524
- {Overall assessment, key concerns}
138
+ ## Code Review: <scope>
139
+ FORGE Task ID: <id or not provided>
140
+ Tier applied: Floor | Standard | Critical
141
+ Verdict: APPROVED | CHANGES_REQUESTED | BLOCKED
142
+ Findings:
143
+ 1. [SEVERITY] file:line — issue; fix
144
+ Summary: <brief>
525
145
  \`\`\`
526
146
 
527
- ## Severity Levels
528
-
529
- - **CRITICAL** — Correctness bug that will cause runtime failure
530
- - **HIGH** — Security issue or major design flaw
531
- - **MEDIUM** — Code quality concern that should be fixed
532
- - **LOW** — Style/naming suggestion
533
-
534
- ## Rules
147
+ Approve only with zero CRITICAL/HIGH findings.
148
+ `,"architect-reviewer-base":`# Architect-Reviewer - Shared Kernel
535
149
 
536
- - **APPROVED** requires zero CRITICAL/HIGH findings
537
- - **NEEDS_REVISION** for any HIGH finding
538
- - **FAILED** for any CRITICAL finding
539
- - Check test coverage on changed code
540
-
541
- ${n()}
542
- `,"architect-reviewer-base":`# Architect-Reviewer — Shared Base Instructions
543
-
544
- > Shared methodology for Architect-Reviewer variants. Do not duplicate.
545
-
546
-
547
- ## MANDATORY FIRST ACTION
548
-
549
- Follow **MANDATORY FIRST ACTION** and **Information Lookup Order** from code-agent-base:
550
- 1. Run \`status({})\` — check Onboard Status and note the **Onboard Directory** path
551
- 2. If onboard shows ❌ → Run \`onboard({ path: '.' })\` and wait for completion
552
- 3. If onboard shows ✅ → Read relevant onboard artifacts using \`compact({ items: [{path: '<Onboard Directory>/<file>'}] })\` — especially \`structure.md\`, \`dependencies.md\`, and \`diagram.md\` for architecture context
150
+ > Review structure: dependency direction, boundaries, public contracts, pattern fit, testability.
553
151
 
554
152
  ${t(`reviewer`)}
555
153
 
556
- ## Review Workflow
557
-
558
- 1. Recall architecture patterns.
559
- 2. Analyze structure/deps and blast radius.
560
- 3. Evaluate dimensions below.
561
- 4. Report.
562
- 5. Persist structural findings.
154
+ ${s()}
563
155
 
564
- ## Review Dimensions
565
-
566
- | Dimension | What to Check |
567
- |-----------|---------------|
568
- | **Dependency Direction** | Dependencies flow inward (domain services ← infra) |
569
- | **Boundary Respect** | No cross-cutting between unrelated packages |
570
- | **SOLID Compliance** | Single responsibility, dependency inversion |
571
- | **Pattern Adherence** | Consistent with established patterns in codebase |
572
- | **Interface Stability** | Public APIs don't break existing consumers |
573
- | **Scalability** | Design handles growth (data, users, features) |
574
- | **Testability** | Dependencies injectable, side effects isolated |
575
-
576
- ## Output Format
156
+ ## Method
157
+ 1. Use provided design/diff/context first.
158
+ 2. Check graph with \`graph({action:'find_nodes'})\` then \`graph({action:'neighbors', node_id})\`.
159
+ 3. Review boundary changes, new modules, public APIs, dependency direction.
160
+ 4. Add CRITICAL/HIGH structural claims to Orchestrator \`task_id\`; do not gate.
577
161
 
162
+ ## Output
578
163
  \`\`\`markdown
579
- ## Architecture Review: {scope}
580
- **Verdict: APPROVED | NEEDS_CHANGES | BLOCKED**
581
-
582
- ### Boundary Analysis
583
- {dependency direction, package boundaries}
584
-
585
- ### Pattern Compliance
586
- {consistency with existing patterns}
587
-
588
- ### Findings
589
- 1. **[SEVERITY]** {description} — Impact and recommendation
590
-
591
- ### Summary
592
- {Overall structural assessment}
164
+ ## Architecture Review: <scope>
165
+ FORGE Task ID: <id or not provided>
166
+ Tier applied: Floor | Standard | Critical
167
+ Verdict: APPROVED | CHANGES_REQUESTED | BLOCKED
168
+ Boundary Analysis: <brief>
169
+ Pattern Fit: <brief>
170
+ Findings:
171
+ 1. [SEVERITY] file:line — issue; impact; fix
172
+ Summary: <brief>
593
173
  \`\`\`
594
-
595
- ## Rules
596
-
597
- - **APPROVED** — No structural issues
598
- - **NEEDS_CHANGES** — Fixable structural issues
599
- - **BLOCKED** — Fundamental design flaw requiring rethink
600
- - Validate dependency direction
601
-
602
- ${n()}
603
-
604
- ## Graph-Assisted Layer Verification
605
-
606
- For each significantly changed module:
607
-
608
- 1. **Discover node**: \`graph({action:'find_nodes', name_pattern:'<module-path>'})\` → get node_id
609
- 2. **Incoming deps**: \`graph({action:'neighbors', node_id, direction:'incoming'})\`
610
- 3. **Outgoing deps**: \`graph({action:'neighbors', node_id, direction:'outgoing'})\`
611
- 4. **Isolation**: \`graph({action:'depth_traverse', node_id, max_depth:3})\`
612
-
613
- Cite layer violations with \`file:line\` receipts. Do not use \`shortest_path\`.
614
174
  `,"decision-protocol":`# Multi-Model Decision Protocol
615
175
 
616
176
  Use for non-trivial technical decisions with multiple viable approaches.
@@ -925,7 +485,7 @@ Reduces per-request token consumption by 40-70% (from ~85K to ~25-50K). Cache hi
925
485
  - ALWAYS deposit findings BEFORE compressing
926
486
  - Keep each step-summary under 2000 characters
927
487
  - If a step produced errors or blockers, include those verbatim (do not compress)
928
- - On completion: knowledge({action: flush, scope: flow:<run-id>})`},l={"execution-state":`# Execution State: {Task Title}
488
+ - On completion: knowledge({action: flush, scope: flow:<run-id>})`},u={"execution-state":`# Execution State: {Task Title}
929
489
 
930
490
  **Status:** PLANNING | IN_PROGRESS | REVIEW | COMPLETED | BLOCKED
931
491
  **Started:** {timestamp}
@@ -977,4 +537,4 @@ Reduces per-request token consumption by 40-70% (from ~85K to ~25-50K). Cache hi
977
537
 
978
538
  ## Alternatives Considered
979
539
  {Other approaches evaluated and why they were rejected - keeps the "why not" alongside the "why"}
980
- `};export{s as AIKIT_INSTALL_HINT_SECTION,o as PLATFORM_OUTPUT_RULES_SECTION,c as PROTOCOLS,l as TEMPLATES,a as postTaskLesson,i as preTaskKnowledgeRecall};
540
+ `};export{c as AIKIT_INSTALL_HINT_SECTION,o as PLATFORM_OUTPUT_RULES_SECTION,l as PROTOCOLS,u as TEMPLATES,s as aiKitToolPreference,a as postTaskLesson,i as preTaskKnowledgeRecall};