@vpxa/aikit 0.1.350 → 0.1.351

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 (26) hide show
  1. package/package.json +1 -1
  2. package/packages/cli/dist/index.js +1 -1
  3. package/packages/server/dist/bin.js +1 -1
  4. package/packages/server/dist/index.js +1 -1
  5. package/packages/server/dist/prelude-Clxlztkk.js +1 -0
  6. package/packages/server/dist/prelude-Dn7jTsqe.js +2 -0
  7. package/packages/server/dist/sampling-giGWyrcO.js +1 -0
  8. package/packages/server/dist/sampling-nivAea83.js +2 -0
  9. package/packages/server/dist/{server-BtRv0mbH.js → server-Ct4BK2hi.js} +169 -169
  10. package/packages/server/dist/{server-BYZo2XjK.js → server-Dc2XtS92.js} +169 -169
  11. package/packages/server/dist/{server-http-CatdRS-N.js → server-http-BNC9qZBj.js} +1 -1
  12. package/packages/server/dist/{server-http-L_WQ9v_b.js → server-http-DBmzukZH.js} +1 -1
  13. package/packages/server/dist/{server-stdio-avLmmdEi.js → server-stdio-DkDdZI98.js} +1 -1
  14. package/packages/server/dist/{server-stdio-CZuGZR4e.js → server-stdio-JHWimdo9.js} +1 -1
  15. package/packages/store/dist/index.d.ts +3 -0
  16. package/packages/store/dist/index.js +8 -8
  17. package/packages/tools/dist/index.d.ts +36 -2
  18. package/packages/tools/dist/index.js +45 -45
  19. package/scaffold/dist/definitions/agents.mjs +1 -1
  20. package/scaffold/dist/definitions/bodies.mjs +48 -3
  21. package/scaffold/dist/definitions/skills/c4-architecture.mjs +23 -1
  22. package/scaffold/dist/definitions/skills/docs.mjs +151 -12
  23. package/packages/server/dist/prelude-DpX0QnqF.js +0 -2
  24. package/packages/server/dist/prelude-pJPHXvnQ.js +0 -1
  25. package/packages/server/dist/sampling-9GcILoHr.js +0 -2
  26. package/packages/server/dist/sampling-DuXB6-rK.js +0 -1
@@ -24,6 +24,6 @@ ${l}
24
24
  ${e(a)}
25
25
 
26
26
  ${o}
27
- ${s}`}}const i={Orchestrator:{title:`The Master Conductor`,description:`Master conductor that orchestrates the full development lifecycle: Planning → Implementation → Review → Recovery → Commit`,argumentHint:null,toolRole:`orchestrator`,sharedBase:null,sharedProtocols:[`layered-knowledge-operating-policy`],category:`orchestration`,skills:[[`aikit`,`**Always** — AI Kit recall, flow status, search, and ctx ref reuse`],[`multi-agents-development`,`Before delegation — decomposition, dispatch envelope, review pipeline`],[`present`,`For plans, reviews, evidence maps, approvals, and non-tiny user output`],[`brainstorming`,`For design forks, trade-offs, or creative requirements`],[`requirements-clarity`,`For vague, large, or cross-team requirements before planning`],[`c4-architecture`,`For architecture diagrams, boundary questions, or structure docs`],[`adr-skill`,`For non-trivial technical decisions and ADR lifecycle`],[`docs`,`For docs-sync, durable docs, PRDs, tours, and architecture docs`],[`lesson-learned`,`After implementation/review work — persist reusable engineering lessons`],[`session-handoff`,`When context pressure rises or work must pause/resume`],[`repo-access`,`For private/self-hosted repo access failures`],[`browser-use`,`For browser auth, JS-rendered pages, visual verification, web automation`]],subagentConstraints:["Do NOT use the `present` tool — return all findings as structured text.","Do NOT call `get_changed_files` — it returns ALL uncommitted diffs (100K+ tokens). Use `git diff <file>` if needed.",`No flow advancement. Only Orchestrator advances the flow.`,"Return status: `DONE` | `DONE_WITH_CONCERNS` | `NEEDS_CONTEXT` | `BLOCKED`. ≤200 words for normal status; full detail only if BLOCKED.",`Stay inside assigned files and boundary. Do not modify files outside scope.`]},Planner:{title:`The Strategic Architect`,description:`Autonomous planner that researches codebases and writes comprehensive TDD implementation plans`,compactRole:`TDD implementation plans`,argumentHint:null,toolRole:`planner`,sharedBase:`code-agent-base`,sharedProtocols:[`thinking-principles`,`planning-principles`,`layered-knowledge-operating-policy`],category:`orchestration`,skills:[[`aikit`,`**Always** — AI Kit reading plans, recall, and compressed context reuse`],[`multi-agents-development`,`For decomposition, dependency batches, and dispatch envelopes`],[`brainstorming`,`For new feature/behavior planning and design alternatives`],[`requirements-clarity`,`For vague or large requirements before planning`],[`present`,`For plan, dependency graph, risk matrix, and approval display`],[`c4-architecture`,`For architecture changes and C4 diagrams`],[`adr-skill`,`For non-trivial technical decisions and ADRs`],[`session-handoff`,`For context pressure or session end`],[`repo-access`,`For private or self-hosted repo access`],[`browser-use`,`For auth recovery or browser workflows`]]},Implementer:{title:`The Code Builder`,description:`Persistent implementation agent that writes code following TDD practices until all tasks are complete`,compactRole:`New features, wire up, build`,argumentHint:`Implementation task, feature, or phase from plan`,toolRole:`codeAgent`,sharedBase:`code-agent-base`,sharedProtocols:[`engineering-principles`,`layered-knowledge-operating-policy`],category:`implementation`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`typescript`,`When writing TypeScript code — type patterns, generics, utility types`],[`react`,`When implementing React components, hooks, or pages`],[`lesson-learned`,`After completing non-obvious implementation work`]]},Frontend:{title:`The UI Specialist`,description:`UI/UX specialist for React, styling, responsive design, and frontend implementation`,compactRole:`UI/UX, React, styling, responsive`,argumentHint:`UI component, styling task, or frontend feature`,toolRole:`codeAgent`,sharedBase:`code-agent-base`,sharedProtocols:[`engineering-principles`,`layered-knowledge-operating-policy`],category:`implementation`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`react`,`When building React components — hooks, patterns, Server Components`],[`typescript`,`When writing TypeScript code — type patterns, generics, utility types`],[`frontend-design`,`When implementing UI/UX — design systems, accessibility, responsive patterns`],[`browser-use`,`When visual/browser verification is needed`],[`lesson-learned`,`After completing non-obvious frontend implementation work`]]},Refactor:{title:`The Code Sculptor`,description:`Code refactoring specialist that improves structure, readability, and maintainability`,compactRole:`Cleanup, simplify, DRY, extract`,argumentHint:`Code, component, or pattern to refactor`,toolRole:`refactor`,sharedBase:`code-agent-base`,sharedProtocols:[`engineering-principles`,`layered-knowledge-operating-policy`],category:`implementation`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`typescript`,`When refactoring TypeScript code — type patterns, generics, utility types`],[`lesson-learned`,`After completing refactor — extract principles from before/after diff`]]},Debugger:{title:`The Problem Solver`,description:`Expert debugger that diagnoses issues, traces errors, and provides solutions using AI Kit traces and compressed context before raw file reads`,compactRole:`Bug diagnosis, error tracing`,argumentHint:`Error message, stack trace, or description of issue`,toolRole:`debugger`,sharedBase:`code-agent-base`,sharedProtocols:[`engineering-principles`,`layered-knowledge-operating-policy`],category:`diagnostics`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`typescript`,`When writing TypeScript code — type patterns, generics, utility types`],[`browser-use`,`For browser/UI reproduction loops and JS-rendered failures`],[`repo-access`,`When debugging depends on private or enterprise repo access`],[`lesson-learned`,`After a non-obvious root cause or fix`]]},Security:{title:`The Vulnerability Hunter`,description:`Security specialist that analyzes code for vulnerabilities and compliance`,compactRole:`Vulnerability analysis, auth hardening`,argumentHint:`Code, feature, or component to security review`,toolRole:`security`,sharedBase:`code-agent-base`,sharedProtocols:[`engineering-principles`,`layered-knowledge-operating-policy`],category:`diagnostics`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`typescript`,`When reviewing code — security patterns, type safety`],[`repo-access`,`When security review requires private/enterprise repo access`],[`browser-use`,`When reviewing browser auth, sessions, cookies, or web security flows`]]},Documenter:{title:`The Knowledge Keeper`,description:`Documentation specialist that creates and maintains comprehensive project documentation`,compactRole:`Project documentation`,argumentHint:`Component, API, feature, or area to document`,toolRole:`documenter`,sharedBase:`code-agent-base`,sharedProtocols:[`thinking-principles`,`documentation-principles`,`layered-knowledge-operating-policy`],category:`documentation`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`docs`,`When creating or updating project documentation — docs/ convention, architecture blueprints, Diátaxis framework`],[`present`,`When presenting documentation previews or architecture visuals to the user`],[`c4-architecture`,`When documenting architecture, containers, components, or deployment`],[`adr-skill`,`When docs involve technical decisions or ADR updates`],[`typescript`,`When documenting TypeScript APIs, public types, or generated docs`],[`session-handoff`,`When docs work spans sessions or context pressure rises`]]},Explorer:{title:`The Rapid Scout`,description:`Rapid codebase exploration to find files, usages, dependencies, and structural context`,compactRole:`Rapid codebase navigation`,argumentHint:`Find files, usages, and context related to: {topic or goal}`,toolRole:`explorer`,sharedBase:null,sharedProtocols:[`thinking-principles`,`layered-knowledge-operating-policy`],category:`exploration`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`]]},Researcher:{title:`The Context Gatherer`,description:`Deep analysis, architecture review, and multi-model decision protocol participant`,compactRole:`Multi-model deep research`,argumentHint:`Research question, problem statement, or subsystem to investigate`,toolRole:`researcher`,sharedBase:`researcher-base`,sharedProtocols:[`thinking-principles`,`layered-knowledge-operating-policy`],category:`research`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`lesson-learned`,`When analyzing past changes to extract engineering principles`],[`c4-architecture`,`When researching system architecture — produce C4 diagrams`],[`adr-skill`,`When the research involves a technical decision — draft an ADR`],[`repo-access`,`When research needs private or enterprise repository access`],[`browser-use`,`When web research needs login, JS rendering, or browser automation`]],variants:{Alpha:n({description:`Primary deep research agent — also serves as default Researcher`,lensName:`Contrarian`,lensDescription:`deep research`,lensPrompt:`actively look for flaws, fatal assumptions, and hidden risks in every approach. The best ideas survive adversarial pressure.`,identityIntro:`, the primary deep research agent. During multi-model decision sessions, you provide deep reasoning and nuanced system design.`,requiredOutputSection:`Depth Analysis`,requiredOutputItems:[`Deep-dive into ONE chosen subsystem (most structurally central to the question)`,`Full evidence chain: file:line citations for every structural claim`,"At least 2 `file_summary` extracts woven into the narrative"],focusAreas:[`For every proposed approach, actively seek the fatal flaw or hidden assumption`,`Ask: "Under what conditions does this approach fail catastrophically?"`,`Prefer uncomfortable truths over comfortable consensus`],variantSummary:`You are the DEFAULT researcher. When the Orchestrator needs breadth + depth, they
27
+ ${s}`}}const i={Orchestrator:{title:`The Master Conductor`,description:`Master conductor that orchestrates the full development lifecycle: Planning → Implementation → Review → Recovery → Commit`,argumentHint:null,toolRole:`orchestrator`,sharedBase:null,sharedProtocols:[`layered-knowledge-operating-policy`],category:`orchestration`,skills:[[`aikit`,`**Always** — AI Kit recall, flow status, search, and ctx ref reuse`],[`multi-agents-development`,`Before delegation — decomposition, dispatch envelope, review pipeline`],[`present`,`For plans, reviews, evidence maps, approvals, and non-tiny user output`],[`brainstorming`,`For design forks, trade-offs, or creative requirements`],[`requirements-clarity`,`For vague, large, or cross-team requirements before planning`],[`c4-architecture`,`For architecture diagrams, boundary questions, or structure docs`],[`adr-skill`,`For non-trivial technical decisions and ADR lifecycle`],[`docs`,`For docs-sync, durable docs, PRDs, tours, and architecture docs`],[`lesson-learned`,`After implementation/review work — persist reusable engineering lessons`],[`session-handoff`,`When context pressure rises or work must pause/resume`],[`repo-access`,`For private/self-hosted repo access failures`],[`browser-use`,`For browser auth, JS-rendered pages, visual verification, web automation`]],subagentConstraints:["Do NOT use the `present` tool — return all findings as structured text.","Do NOT call `get_changed_files` — it returns ALL uncommitted diffs (100K+ tokens). Use `git diff <file>` if needed.",`No flow advancement. Only Orchestrator advances the flow.`,"Return status: `DONE` | `DONE_WITH_CONCERNS` | `NEEDS_CONTEXT` | `BLOCKED`. ≤200 words for normal status; full detail only if BLOCKED.",`Stay inside assigned files and boundary. Do not modify files outside scope.`,"Respect `readonly: true|false` flag in dispatch envelope. When readonly=true, do NOT modify files. When readonly=false, follow normal file-modification scope."]},Planner:{title:`The Strategic Architect`,description:`Autonomous planner that researches codebases and writes comprehensive TDD implementation plans`,compactRole:`TDD implementation plans`,argumentHint:null,toolRole:`planner`,sharedBase:`code-agent-base`,sharedProtocols:[`thinking-principles`,`planning-principles`,`layered-knowledge-operating-policy`],category:`orchestration`,skills:[[`aikit`,`**Always** — AI Kit reading plans, recall, and compressed context reuse`],[`multi-agents-development`,`For decomposition, dependency batches, and dispatch envelopes`],[`brainstorming`,`For new feature/behavior planning and design alternatives`],[`requirements-clarity`,`For vague or large requirements before planning`],[`present`,`For plan, dependency graph, risk matrix, and approval display`],[`c4-architecture`,`For architecture changes and C4 diagrams`],[`adr-skill`,`For non-trivial technical decisions and ADRs`],[`session-handoff`,`For context pressure or session end`],[`repo-access`,`For private or self-hosted repo access`],[`browser-use`,`For auth recovery or browser workflows`]]},Implementer:{title:`The Code Builder`,description:`Persistent implementation agent that writes code following TDD practices until all tasks are complete`,compactRole:`New features, wire up, build`,argumentHint:`Implementation task, feature, or phase from plan`,toolRole:`codeAgent`,sharedBase:`code-agent-base`,sharedProtocols:[`engineering-principles`,`layered-knowledge-operating-policy`],category:`implementation`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`typescript`,`When writing TypeScript code — type patterns, generics, utility types`],[`react`,`When implementing React components, hooks, or pages`],[`lesson-learned`,`After completing non-obvious implementation work`]]},Frontend:{title:`The UI Specialist`,description:`UI/UX specialist for React, styling, responsive design, and frontend implementation`,compactRole:`UI/UX, React, styling, responsive`,argumentHint:`UI component, styling task, or frontend feature`,toolRole:`codeAgent`,sharedBase:`code-agent-base`,sharedProtocols:[`engineering-principles`,`layered-knowledge-operating-policy`],category:`implementation`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`react`,`When building React components — hooks, patterns, Server Components`],[`typescript`,`When writing TypeScript code — type patterns, generics, utility types`],[`frontend-design`,`When implementing UI/UX — design systems, accessibility, responsive patterns`],[`browser-use`,`When visual/browser verification is needed`],[`lesson-learned`,`After completing non-obvious frontend implementation work`]]},Refactor:{title:`The Code Sculptor`,description:`Code refactoring specialist that improves structure, readability, and maintainability`,compactRole:`Cleanup, simplify, DRY, extract`,argumentHint:`Code, component, or pattern to refactor`,toolRole:`refactor`,sharedBase:`code-agent-base`,sharedProtocols:[`engineering-principles`,`layered-knowledge-operating-policy`],category:`implementation`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`typescript`,`When refactoring TypeScript code — type patterns, generics, utility types`],[`lesson-learned`,`After completing refactor — extract principles from before/after diff`]]},Debugger:{title:`The Problem Solver`,description:`Expert debugger that diagnoses issues, traces errors, and provides solutions using AI Kit traces and compressed context before raw file reads`,compactRole:`Bug diagnosis, error tracing`,argumentHint:`Error message, stack trace, or description of issue`,toolRole:`debugger`,sharedBase:`code-agent-base`,sharedProtocols:[`engineering-principles`,`layered-knowledge-operating-policy`],category:`diagnostics`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`typescript`,`When writing TypeScript code — type patterns, generics, utility types`],[`browser-use`,`For browser/UI reproduction loops and JS-rendered failures`],[`repo-access`,`When debugging depends on private or enterprise repo access`],[`lesson-learned`,`After a non-obvious root cause or fix`]]},Security:{title:`The Vulnerability Hunter`,description:`Security specialist that analyzes code for vulnerabilities and compliance`,compactRole:`Vulnerability analysis, auth hardening`,argumentHint:`Code, feature, or component to security review`,toolRole:`security`,sharedBase:`code-agent-base`,sharedProtocols:[`engineering-principles`,`layered-knowledge-operating-policy`],category:`diagnostics`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`typescript`,`When reviewing code — security patterns, type safety`],[`repo-access`,`When security review requires private/enterprise repo access`],[`browser-use`,`When reviewing browser auth, sessions, cookies, or web security flows`]]},Documenter:{title:`The Knowledge Keeper`,description:`Documentation specialist that creates and maintains comprehensive project documentation`,compactRole:`Project documentation`,argumentHint:`Component, API, feature, or area to document`,toolRole:`documenter`,sharedBase:`code-agent-base`,sharedProtocols:[`thinking-principles`,`documentation-principles`,`layered-knowledge-operating-policy`],category:`documentation`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`docs`,`When creating or updating project documentation — docs/ convention, architecture blueprints, Diátaxis framework`],[`present`,`When presenting documentation previews or architecture visuals to the user`],[`c4-architecture`,`When documenting architecture, containers, components, or deployment`],[`adr-skill`,`When docs involve technical decisions or ADR updates`],[`typescript`,`When documenting TypeScript APIs, public types, or generated docs`],[`session-handoff`,`When docs work spans sessions or context pressure rises`]]},Explorer:{title:`The Rapid Scout`,description:`Rapid codebase exploration to find files, usages, dependencies, and structural context`,compactRole:`Rapid codebase navigation`,argumentHint:`Find files, usages, and context related to: {topic or goal}`,toolRole:`explorer`,sharedBase:null,sharedProtocols:[`thinking-principles`,`layered-knowledge-operating-policy`],category:`exploration`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`]]},Researcher:{title:`The Context Gatherer`,description:`Deep analysis, architecture review, and multi-model decision protocol participant`,compactRole:`Multi-model deep research`,argumentHint:`Research question, problem statement, or subsystem to investigate`,toolRole:`researcher`,sharedBase:`researcher-base`,sharedProtocols:[`thinking-principles`,`layered-knowledge-operating-policy`],category:`research`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`lesson-learned`,`When analyzing past changes to extract engineering principles`],[`c4-architecture`,`When researching system architecture — produce C4 diagrams`],[`adr-skill`,`When the research involves a technical decision — draft an ADR`],[`repo-access`,`When research needs private or enterprise repository access`],[`browser-use`,`When web research needs login, JS rendering, or browser automation`]],variants:{Alpha:n({description:`Primary deep research agent — also serves as default Researcher`,lensName:`Contrarian`,lensDescription:`deep research`,lensPrompt:`actively look for flaws, fatal assumptions, and hidden risks in every approach. The best ideas survive adversarial pressure.`,identityIntro:`, the primary deep research agent. During multi-model decision sessions, you provide deep reasoning and nuanced system design.`,requiredOutputSection:`Depth Analysis`,requiredOutputItems:[`Deep-dive into ONE chosen subsystem (most structurally central to the question)`,`Full evidence chain: file:line citations for every structural claim`,"At least 2 `file_summary` extracts woven into the narrative"],focusAreas:[`For every proposed approach, actively seek the fatal flaw or hidden assumption`,`Ask: "Under what conditions does this approach fail catastrophically?"`,`Prefer uncomfortable truths over comfortable consensus`],variantSummary:`You are the DEFAULT researcher. When the Orchestrator needs breadth + depth, they
28
28
  dispatch you alone. Your lens: thorough, evidence-first, exhaustive + contrarian.`}),Beta:n({description:`Research variant — pragmatic analysis with focus on trade-offs and edge cases`,lensName:`First Principles`,lensDescription:`pragmatic analysis`,lensPrompt:`strip away assumptions, decompose to ground truths, and rebuild reasoning from scratch.`,identityIntro:`, a variant of the Researcher agent optimized for **pragmatic analysis**. Focus on trade-offs, edge cases, and practical constraints. Challenge assumptions and highlight risks the primary researcher may overlook.`,requiredOutputSection:`Failure Modes & Counter-Evidence`,requiredOutputItems:[`At least 3 adversarial claims challenging your own primary finding`,`For each counter-claim: the condition under which it would be TRUE, and the
29
29
  evidence (file:line or search receipt) that currently falsifies it`,"Any unresolved counter-evidence flagged as `⚠ UNRESOLVED`"],focusAreas:[`Strip every assumption: "Is this truly required, or just inherited convention?"`,`Decompose to ground truths, then rebuild the reasoning from scratch`,`If the current approach exists only because "that's how it's always been done", flag it`],variantSummary:"Your lens: pragmatic skepticism + first principles. Mark competing claims as `A` (Assumed)\nby default; challenge before promoting to `V`."}),Gamma:n({description:`Research variant — broad pattern matching across domains and technologies`,lensName:`Expansionist`,lensDescription:`cross-domain pattern matching`,lensPrompt:`look for the bigger opportunity, find what's undervalued, and identify patterns others dismiss.`,identityIntro:`, a variant of the Researcher agent optimized for **cross-domain pattern matching**. Draw connections from other domains, frameworks, and industries. Bring breadth where Alpha brings depth.`,requiredOutputSection:`Cross-Domain Analogies`,requiredOutputItems:[`At least 2 patterns from other tools/frameworks/domains that apply to the question`,"For each: the external source (cite via `web_search` or `web_fetch` receipt) and\n how it maps to our codebase",`One "missing pattern we should adopt" recommendation`],focusAreas:[`Ask: "What's the bigger opportunity everyone else is ignoring?"`,`Seek undervalued approaches and non-obvious connections across domains`,`Challenge narrow framing: "Is this really just an X problem, or is it also a Y problem?"`],variantSummary:"Your lens: cross-domain pattern matching + expansionist. Weight `web_search` + `web_fetch`\nhigher than peers. Assume the LLM's training data is stale — verify with fresh searches."}),Delta:n({description:`Research variant — implementation feasibility and performance implications`,lensName:`Executor`,lensDescription:`implementation feasibility`,lensPrompt:`focus on what can actually be built, the fastest path to value, and real-world constraints.`,identityIntro:`, a variant of the Researcher agent optimized for **implementation feasibility**. Focus on performance implications, scaling concerns, and concrete implementation paths. Ground theoretical proposals in practical reality.`,requiredOutputSection:`Implementation Cost & Feasibility`,requiredOutputItems:["Complexity snapshot: you MUST call `measure({ path })` on any file ≥ 50 LOC in the\n target subsystem at least once and quote the `cognitiveComplexity` result","Blast radius estimate: `blast_radius({ changed_files })` on the proposed edits",`Time/risk table: | Change | Lines | Risk | Effort |`,`Feasibility verdict: SAFE / RISKY / INFEASIBLE with one-line justification`],focusAreas:[`Ask: "Can this actually be built? What's the fastest path to a working version?"`,`Ground every proposal in concrete effort: lines of code, files changed, risk`,`Reject elegant theory that can't survive contact with the codebase`],variantSummary:'Your lens: implementation feasibility + executor. Prefer `measure` + `blast_radius` +\n`analyze({ items: [{aspect: "patterns", ...}] })` over abstract reasoning.'})}},"Code-Reviewer":{title:`The Quality Guardian`,description:`Code review specialist analyzing code for quality, security, performance, and maintainability`,compactRole:`Dual-perspective code review`,argumentHint:`File path, PR, or code to review`,toolRole:`reviewer`,sharedBase:`code-reviewer-base`,sharedProtocols:[`thinking-principles`,`review-principles`,`layered-knowledge-operating-policy`],category:`review`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`typescript`,`When reviewing TypeScript code — type patterns, best practices`],[`lesson-learned`,`When review exposes a reusable engineering lesson`]],variants:{Alpha:r({roleName:`Code-Reviewer`,description:`Primary code reviewer`,lensName:`Compliance & Red-Team`,lensDescription:`compliance and red-teaming`,lensPrompt:`you hunt for correctness bugs, security holes, and contract violations that will break in production.`,identityIntro:`, the primary Code-Reviewer agent.`,focusAreas:[`**Correctness** — Logic errors, race conditions, null/undefined paths, off-by-one`,`**Security** — OWASP Top 10, input validation, secrets, injection vectors`,`**Contract compliance** — Does this honor its type signatures, API contracts, and invariants?`,`**Error handling** — What happens on the unhappy path? Missing try/catch, swallowed errors`],instinct:`Your instinct: "How does this break?" Think like an attacker and a pessimist.`,closing:`When in doubt, flag it — false positives are cheaper than missed bugs in production.`}),Beta:r({roleName:`Code-Reviewer`,description:`Code reviewer variant — different LLM perspective for dual review`,lensName:`Quality & Engineering Excellence`,lensDescription:`quality and engineering excellence`,lensPrompt:`you focus on maintainability, performance, testing, and whether the code will age well.`,identityIntro:`, the secondary Code-Reviewer agent.`,focusAreas:[`**Maintainability** — Naming clarity, single responsibility, cognitive complexity, DRY`,`**Performance** — N+1 queries, unnecessary allocations, missing caching, O(n²) where O(n) suffices`,`**Testing** — Coverage for new/changed logic, edge cases, test readability`,`**Patterns** — Consistency with existing codebase conventions, idiomatic usage`],instinct:`Your instinct: "Will a new team member understand this in 6 months?" Think like a mentor.`,closing:`Prefer actionable suggestions over vague concerns. Show the better version when possible.`})}},"Architect-Reviewer":{title:`The Structural Guardian`,description:`Reviews architecture for pattern adherence, SOLID compliance, dependency direction, and structural integrity`,compactRole:`Architecture review`,argumentHint:`Files, PR, or subsystem to architecture-review`,toolRole:`reviewer`,sharedBase:`architect-reviewer-base`,sharedProtocols:[`thinking-principles`,`review-principles`,`layered-knowledge-operating-policy`],category:`review`,skills:[[`aikit`,`**Always** — AI Kit tool signatures, search, analysis`],[`c4-architecture`,`When reviewing architectural diagrams or boundary changes`],[`adr-skill`,`When the review involves architecture decisions — reference or create ADRs`],[`docs`,`When architecture review should update durable documentation`]],extraBody:`You are **not** the Code-Reviewer agent. Code-Reviewer handles correctness, testing, security, and code quality. You handle the big picture: service boundaries, dependency direction, pattern adherence, and structural health.`,variants:{Alpha:r({roleName:`Architect-Reviewer`,description:`Primary architecture reviewer`,lensName:`Structural Prosecutor`,lensDescription:`structural prosecution`,lensPrompt:`you challenge architectural choices, find boundary violations, and test whether the design survives growth.`,identityIntro:`, the primary Architect-Reviewer agent.`,focusHeading:`Your primary focus areas:`,focusAreas:[`**Boundary violations** — Does this cross package/module boundaries it shouldn't?`,`**Dependency direction** — Are dependencies flowing inward? Any layer leakage?`,`**Hidden coupling** — Shared mutable state, implicit contracts, temporal coupling`,`**Scalability stress** — What breaks at 10x load, 10x data, 10x features?`],instinct:`Your instinct: "This design will fail when..." Challenge every architectural assumption.`,closing:`If a boundary is crossed, require justification or block.`}),Beta:r({roleName:`Architect-Reviewer`,description:`Architecture reviewer variant — different LLM perspective for dual review`,lensName:`Pragmatic Defense`,lensDescription:`pragmatic defense`,lensPrompt:`you evaluate whether the architecture is proportional to the problem, and defend reasonable trade-offs.`,identityIntro:`, the secondary Architect-Reviewer agent.`,focusHeading:`Your primary focus areas:`,focusAreas:[`**Proportionality** — Is the architecture proportional to the problem? Over-engineering is a defect.`,`**Trade-off validity** — Are the trade-offs explicitly acknowledged and reasonable?`,`**Migration path** — Can this evolve without a rewrite? Is there a clear upgrade path?`,`**Team ergonomics** — Can the team actually maintain this? Does it match their skills?`],instinct:`Your instinct: "Is this the simplest architecture that solves the actual problem?"`,closing:`Push back on unnecessary complexity. Defend working solutions against premature abstraction.`})}}};export{i as AGENTS};
@@ -26,6 +26,7 @@ When dispatching subagents, include this line: "Communication style: terse like
26
26
 
27
27
  ## Bootstrap
28
28
  1. status({ includePrelude: true }) -> onboard({ path: "." }) if needed.
29
+ 1a. For flow dispatch: status({ includePrelude: true }) → if onboard missing or workspace stale, onboard({ path: ".", update: true }) before any subagent dispatch.
29
30
  2. Apply layered knowledge protocol (see below).<!-- layered-header -->
30
31
  3. search({ query: "SESSION CHECKPOINT", origin: "curated" }) before planning.
31
32
  5. Load skills by trigger: aikit always; multi-agents-development before delegation; present before non-tiny output (check Transport section for preferBrowser); brainstorming for design decisions.
@@ -37,6 +38,30 @@ Critical: Standard + dual code review + architecture review + security review.
37
38
 
38
39
  Floor skips flow activation, evidence map, dual review, decision protocol. Standard+ uses them.
39
40
 
41
+ Floor short-circuit: if changeManifest shows only NONE/COSMETIC (no STRUCTURAL/NEW/REMOVED), skip specialist dispatch entirely. Saves context + dispatch slot.
42
+
43
+ ## Flow-Aware Dispatch Classification
44
+
45
+ ### Flow Types
46
+ Classify each flow to determine guard and re-onboard behavior:
47
+
48
+ | Type | Examples | Guard fires? | Re-onboard after? |
49
+ |------|----------|-------------|-------------------|
50
+ | Read-only | Research, Analysis, Review | No | No |
51
+ | Write | Implementation, Refactor, Fix | Yes | Yes |
52
+ | Epilogue-only | Docs-sync, Lesson-learned | No | No |
53
+ | Mixed | Orchestrator full cycle | Yes (on write steps only) | Yes |
54
+
55
+ ### Agent Dispatch Classification
56
+ Classify each step by agent role:
57
+ - **Read-only agents**: Explorer, Researcher*, Code-Reviewer*, Architect-Reviewer*, Planner, Documenter, Security
58
+ - **Write-capable agents**: Implementer, Refactor, Frontend, Debugger (when fixing)
59
+
60
+ For Mixed flows, each step inherits classification from its dispatched agent. Write-capable agents get \`readonly: false\`; all others \`readonly: true\`.
61
+
62
+ ### Pre-Dispatch Staleness Check
63
+ Before dispatching a write-capable agent, run \`status({ includePrelude: true })\` to verify onboard freshness. If workspace structure changed since last onboard (new/deleted/modified files), run \`onboard({ path: ".", update: true })\` first. Read-only dispatches skip this check (0 token cost). The \`readonly\` flag is a contractual convention, not runtime enforcement — subagents retain full MCP tool access.
64
+
40
65
  ## Protocol Coverage Map
41
66
  - conversation-compression: before each dispatch batch, withdraw/profile context; after each batch, deposit status/files/decisions/blockers; never echo raw subagent output.
42
67
  - decision-protocol: Standard+ trade-off/design work gets independent research, synthesis verdict, recommendation, confidence, blind spots; Critical adds wider review.
@@ -75,12 +100,13 @@ Every \`runSubagent\` prompt includes all of:
75
100
  3. **Arch Context** — Pre-compress with AI Kit tools before including in prompt. pick by token budget: efficient → \`file_summary\` (T1=structure, T2=content), full → \`digest\`. Default efficient. **Never pass raw file contents — always compress first.** This eliminates subagent need for \`read_file\`.
76
101
  4. **Prior Knowledge** — \`knowledge({ action: "lesson", subAction: "list-lessons", topic: "<2-3 keywords>", minConfidence: 70 })\` + \`search({ query: "<task area>", category: "conventions", limit: 3 })\`. Include high-confidence results. Skip for Floor.
77
102
  5. **Artifacts Path** — active flow's run dir / artifacts path from \`flow({ action: 'status' })\`.
78
- 6. **FORGE** — tier, task_id, evidence requirements. Reviewers add CRITICAL/HIGH claims into your task_id; never create their own.
103
+ 6. **FORGE** — tier (from forge_classify), task_id, evidence requirements. Pass tier directly; Documenter/SKILL.md maps tier to docs generation depth internally. Reviewers add CRITICAL/HIGH claims into your task_id; never create their own.
79
104
  7. **Flow Context** — "Call \`knowledge({ action: 'withdraw', scope: 'flow', profile: '<role>', budget: 6000 })\` as your FIRST action. Reuse withdrawn refs and L0 card refs before broad retrieval. Do NOT independently reload workspace-core or architecture cards when dispatch already carries applicable refs."
80
105
  8. ${a().replace(/\n/g,`
81
106
  `)}
82
107
  9. **Self-Review** — checklist before declaring status: scope respected? tests pass? conventions followed?
83
108
  10. **Return contract** — \`DONE\` | \`DONE_WITH_CONCERNS\` | \`NEEDS_CONTEXT\` | \`BLOCKED\`. ≤200 words: status, files, decisions. Full detail only if BLOCKED.
109
+ 11. **Read-Only Mode** — \`readonly: true|false\`. Controls whether agent may modify files. Derived from flow type + step classification. Write-capable agents (Implementer, Refactor, Frontend, Debugger) receive \`false\`; all others \`true\`. Contractual convention — no runtime enforcement.
84
110
 
85
111
  Always pass \`agentName\`. Missing/empty is a dispatch bug.
86
112
 
@@ -107,6 +133,7 @@ ${r({audience:`agent`})}
107
133
  ## Evidence + Validation
108
134
  Use forge_classify for tier. Standard+ creates one Orchestrator-owned evidence_map task_id; reviewers add CRITICAL/HIGH claims into it; only Orchestrator runs gate.
109
135
  After implementation batches: check({}) + test_run({}) once, then blast_radius for shared/public changes.
136
+ After write flow completion: onboard({ path, update: true }) → reindex({}) → produce_knowledge({}) to sync L0 cards and vector index. Verify with status({}). Read-only/Epilogue-only flows skip (0 token cost). If re-onboard fails, log warning and surface in flow status — do not block.
110
137
 
111
138
  ## Presentation
112
139
  Use present for summaries, reports, evidence maps, task plans, batch results, verdicts, progress, reviews, approval gates. Plain chat only for <=2 short status sentences or one simple question.
@@ -125,8 +152,9 @@ Use present for summaries, reports, evidence maps, task plans, batch results, ve
125
152
  Use web_fetch/http first. On auth failure, load repo-access; if exhausted, use AI Kit browser. Do not use system browser for agent-visible verification.
126
153
 
127
154
  ## End
128
- - reindex after structural changes; produce_knowledge for durable updates; remember non-trivial decisions.
129
- - L0 card maintenance: changed topics after flow completion schedule L0 card regeneration via \`briefing-card-compiler\`.
155
+ - After write flows: onboard({ path, update: true }) → reindex({}) → produce_knowledge({}). L0 card regen via \`briefing-card-compiler\` if structural change detected.
156
+ - After read-only/epilogue-only flows: no reindex (0 token cost). remember decisions as normal.
157
+ - If re-onboard/reindex fails: log warning, surface in flow status, do not block.
130
158
  - Flow-derived promotion: evidence-backed promotion candidates from final consolidation; confidence alone never promotes.
131
159
  - session_digest({ persist: true }).`,Planner:`${i()}
132
160
 
@@ -462,9 +490,26 @@ After shared bootstrap, run \`search({ query: "security vulnerabilities conventi
462
490
 
463
491
  > **Reminder:** Follow ## MANDATORY FIRST ACTION from your shared base protocol.
464
492
 
493
+ ## Tier Composition: Evidence × Docs Generation
494
+
495
+ Two independent tier dimensions compose: **evidence protocol** (who you report to) and **docs generation** (what you produce). Both use the same FORGE \`tier\` value, but govern different behaviors.
496
+
497
+ | Tier | Evidence Protocol | Docs Generation | Short-circuit Gate |
498
+ |------|------------------|----------------|-------------------|
499
+ | Floor | file:line citations only. No \`evidence_map\`. | State tracking only. Skip generation. See SKILL.md ┬╗ Tier Branch Table. | Orchestrator may skip dispatch if changeManifest = NONE/COSMETIC only |
500
+ | Standard | Add 2-4 CRITICAL/HIGH findings with receipts. | Surgical: regenerate only affected docs + cross-ref validation. | N/A — dispatch always runs |
501
+ | Critical | All CRITICAL/HIGH findings; tag contract/security claims with \`safety_gate\`. | Full Phase 1-7 + phases matching change type. | N/A — dispatch always runs |
502
+
503
+ **Docs generation branching is defined in SKILL.md ┬╗ Tier Branching — not duplicated here.** This file controls evidence protocol only.
504
+
465
505
  ## Documentation Protocol
466
506
 
467
507
  1. **AI Kit Recall** — \`search({ query: "documentation <area>" })\` + \`knowledge({ action: "list" })\`
508
+ 1a. **Freshness check** (E4 Knowledge↔Docs Bridge): After recall, check L2 lessons against existing docs for staleness. Session-level dedup per topic.
509
+ - \`search({ query: "recent lessons about <target domain>" })\`
510
+ - \`knowledge({ action: 'lesson', subAction: 'list-lessons', topic: '<target domain>' })\`
511
+ - If any \`lesson.updatedAt > doc._lastSynced.syncedAt\`: emit \`[FRESHNESS WARNING]\` in output
512
+ - Run BEFORE Analyze step so freshness signals inform evidence gathering
468
513
  2. **Analyze** — \`analyze({ items: [{aspect: "structure", ...}] })\`, \`analyze({ items: [{aspect: "entry_points", ...}] })\`, \`file_summary({ files, tier: 'T1' })\`
469
514
  3. **Draft** — write docs following project conventions
470
515
  4. **Cross-reference** — link related docs, keep consistency
@@ -139,7 +139,29 @@ Default: Context + Container. Add Component only for a complex container and a c
139
139
 
140
140
  1. **Study examples first**: Load references/ example files to understand visual patterns, label density, and layout conventions before generating.
141
141
  2. Identify audience and decision the diagram supports.
142
- 3. Gather evidence with AI Kit: analyze/graph/search/file_summary.
142
+ 3. **Gather evidence with AI Kit - check onboard cache FIRST:**
143
+ a. **Check onboard cache:**
144
+ - Run status({ includePrelude: true }) - if workspaceCore shows onboard data available:
145
+ - Read cache from ~/.aikit/workspaces/<hash>/onboard/:
146
+ - structure.md - module tree, layers, directory shape
147
+ - dependencies.md - internal/external dependency graph
148
+ - symbols.md - exported symbols, type signatures
149
+ - entry-points.md - API surface, CLI entry points
150
+ - Freshness: cache fresh if status().onboarded == true and index recent.
151
+ For finer control: compare git diff --stat pending change count.
152
+ Default: <50 pending changes -> serve from cache | >=50 -> refresh.
153
+ b. **Use cache data for C4:**
154
+ - Extract layers from structure analysis (layer-detector classifications)
155
+ - Extract modules/containers from directory tree
156
+ - Extract dependency arrows from cross-module imports
157
+ - Identify external systems from external dependency listing
158
+ c. **Fallback (if cache missing or stale):**
159
+ - analyze({ items: [{aspect: "structure"}, {aspect: "dependencies"}, {aspect: "entry_points"}] })
160
+ - 3 aspects instead of 6 - symbols + patterns + diagram aspects add cost but not essential for C4 topology
161
+ d. **Supplementary context (always runs):**
162
+ - graph({ action: find_nodes, name_pattern: <system> }) for relationship graph
163
+ - search({ query: <system> technology stack }) for tech details
164
+ - file_summary({ files, tier: T1 }) for individual file structure when needed
143
165
  4. Pick level(s); avoid mixing levels in one diagram.
144
166
  5. **Generate structured diagram JSON** conforming to the centralized diagram schema (see ~/.aikit/resources/renderers/schemas/). Render via CLI:
145
167
 
@@ -181,7 +181,7 @@ Use Phase 1 tool outputs to answer questions for each of the seven documents. Ru
181
181
  | conventions.md | \`analyze({ items: [{aspect: "patterns", ...}] })\` → naming, formatting; \`search({ query: "conventions" })\` → detected conventions |
182
182
  | integrations.md | \`analyze({ items: [{aspect: "dependencies", ...}] })\` → external deps; \`search({ query: "API\\|database\\|auth\\|webhook" })\` → integration points |
183
183
  | testing.md | \`analyze({ items: [{aspect: "patterns", ...}] })\` → test patterns; \`search({ query: "test framework" })\` → test setup; \`test_run({})\` → test health |
184
- | concerns.md | \`audit({ path: "." })\` → health issues; \`dead_symbols({})\` → dead code; \`git_context({})\` → high-churn files |
184
+ | concerns.md | \`audit({ path: "." })\` → health issues; \`dead_symbols({})\` → dead code; \`git_context({})\` → high-churn files; freshness check (Step 1a) before data gathering |
185
185
 
186
186
  ### Phase 3: Populate Documents
187
187
 
@@ -776,9 +776,12 @@ Use this template for any generated section that includes factual claims:
776
776
  Committed state file for incremental documentation updates. L0 regeneratable cache,
777
777
  committed to git so clones have warm cache.
778
778
 
779
+ **Design: extends existing schema (backward compatible).** NO parallel \`_lastSynced\` block.
780
+ Adds \`signatureHash\`, \`contractHash\` (optional), and \`syncedAt\` to the existing \`sourceFiles[path]\` entry.
781
+
779
782
  \`\`\`json
780
783
  {
781
- "version": "1.0",
784
+ "version": "1.1",
782
785
  "layer": "l0",
783
786
  "timestamp": "ISO-8601",
784
787
  "lastCommitSha": "git rev-parse HEAD of last documented commit",
@@ -793,7 +796,10 @@ committed to git so clones have warm cache.
793
796
  "src/auth/login.ts": {
794
797
  "contentHash": "sha256-abc...",
795
798
  "signatures": ["login(credentials: Credentials): Promise<Session>"],
796
- "changeClass": "NONE|COSMETIC|STRUCTURAL|NEW|REMOVED"
799
+ "signatureHash": "sha256-of-signatures-array",
800
+ "contractHash": "sha256-of-function-body+jsdoc",
801
+ "changeClass": "NONE|COSMETIC|STRUCTURAL|CONTRACT_CHANGE|NEW|REMOVED",
802
+ "syncedAt": "2026-06-22T12:00:00Z"
797
803
  }
798
804
  },
799
805
 
@@ -807,6 +813,28 @@ committed to git so clones have warm cache.
807
813
  }
808
814
  \`\`\`
809
815
 
816
+ ### Per-Doc Frontmatter (minimal \`_lastSynced\`)
817
+
818
+ For each generated doc, include a lightweight frontmatter with only the fields LLMs consume:
819
+
820
+ \`\`\`yaml
821
+ ---
822
+ _lastSynced:
823
+ sourceHash: sha256-abc...
824
+ syncedAt: "2026-06-22T12:00:00Z"
825
+ _generation:
826
+ tier: standard
827
+ trigger: signature-change
828
+ changeClass: STRUCTURAL
829
+ ---
830
+ \`\`\`
831
+
832
+ - \`sourceHash\` — LLM can compare against current code hash to detect staleness
833
+ - \`syncedAt\` — LLM can assess freshness relative to knowledge cutoff
834
+ - \`_generation\` block — provides provenance for LLM context awareness
835
+ - Full state fields (\`signatureHash\`, \`contractHash\`) stay in \`.docs-state.json\` only
836
+ - Avoids 375-500 token per-run cost of duplicating full state in frontmatter
837
+
810
838
  ### Release Notes Template (\`docs/releases/v{version}.md\`)
811
839
 
812
840
  \`\`\`markdown
@@ -1706,10 +1734,59 @@ Step 1: Check \`docs/.docs-state.json\` (the Committed Docs IR):
1706
1734
  - If present: compare \`lastCommitSha\` vs \`git rev-parse HEAD\`
1707
1735
  - SHA + onboardRef fresh → IR is fresh, use as-is (no re-run)
1708
1736
  - Stale → re-run \`onboard({update:true})\`, recompute change manifest, update IR
1709
- - Change classification per file:
1710
- - Hash identical NONE | New NEW | Removed → REMOVED
1711
- - Hash diff, sigs match COSMETIC (via \`analyze({ items: [{aspect: "symbols", path: "."}] })\`)
1712
- - Hash diff, sigs diff STRUCTURAL
1737
+
1738
+ Step 2: Compute current fingerprints (deterministic pre-step, not LLM work):
1739
+ - For each source file in scope:
1740
+ - Skip binary files: \`.png\`, \`.jpg\`, \`.ico\`, \`.gif\`, \`.svg\`, \`.woff\`, \`.woff2\`, \`.eot\`, \`.ttf\`, \`.ico\`
1741
+ - Compute \`contentHash\` via \`git hash-object <file>\` (preferred — no LLM context needed) or \`aikit_encode({ operation: 'sha256', input: readFile })\` (fallback)
1742
+ - Extract signatures via tier-appropriate method:
1743
+ - **Floor tier**: regex-based (cheap, fast-path) — \`/(?:export\\s+)?(?:default\\s+)?(?:async\\s+)?(?:function\\s+(\\w+)|(?:const|let|var)\\s+(\\w+)\\s*[=(:]|class\\s+(\\w+)|interface\\s+(\\w+)|type\\s+(\\w+)|abstract\\s+class\\s+(\\w+))/gm\`
1744
+ - **Standard/Critical**: AST-based via \`analyze({ items: [{aspect: "symbols", path: "<file>"}] })\` — higher accuracy, catches re-exports, decorators, complex signatures
1745
+ - Filter signatures to exported-only (non-exported symbols don't affect public API docs)
1746
+
1747
+ Step 3: Classify Change per file:
1748
+ - File NOT in priorState → \`NEW\`
1749
+ - File in priorState but NOT on disk (ENOENT) → \`REMOVED\` (catch before hashing)
1750
+ - Hash identical, sigs match → \`NONE\`
1751
+ - Hash changed, sigs match → \`COSMETIC\` (content changed but public API unchanged)
1752
+ - Hash changed, exported sigs differ → \`STRUCTURAL\` (public API changed — requires doc update)
1753
+ - Hash changed, exported sigs same but contract markers changed → \`CONTRACT_CHANGE\` (behavior changed, sigs same — see note below)
1754
+
1755
+ **Edge case: changed implementation, same signature.**
1756
+ A function's body may change (bug fix, perf optimization, new error handling) while its signature stays identical. The algorithm classifies this as COSMETIC, but docs describing behavior, preconditions, postconditions, or error states ARE stale. Mitigation:
1757
+ - Track \`contractHash\` — hash of function body + JSDoc/comments (optional, Standard/Critical only)
1758
+ - If \`contractHash\` differs but sigs match → flag as \`CONTRACT_CHANGE\` for human review
1759
+ - Known blind spot: this is not perfect. Documented as deferred improvement.
1760
+
1761
+ Step 4: Special Triggers (run before final classification):
1762
+ - Config files (\`package.json\`, \`tsconfig.json\`, \`biome.json\`) → always \`STRUCTURAL\` regardless of hash/sig analysis
1763
+ - CI/CD config (\`.github/\`, \`.gitlab-ci.yml\`) → always \`STRUCTURAL\`
1764
+ - Removed files → \`REMOVED\` (ensure dependent docs are flagged)
1765
+
1766
+ Step 5: Output changeManifest:
1767
+ \`\`\`json
1768
+ {
1769
+ "files": {
1770
+ "src/auth/login.ts": {
1771
+ "changeClass": "STRUCTURAL",
1772
+ "contentHash": "abc...",
1773
+ "signatureHash": "def...",
1774
+ "contractHash": "ghi...",
1775
+ "syncedAt": "2026-06-22T12:00:00Z"
1776
+ }
1777
+ },
1778
+ "summary": {
1779
+ "none": 42,
1780
+ "cosmetic": 3,
1781
+ "structural": 1,
1782
+ "contractChange": 0,
1783
+ "new": 2,
1784
+ "removed": 1,
1785
+ "totalChanged": 7
1786
+ },
1787
+ "needsDocUpdate": true
1788
+ }
1789
+ \`\`\`
1713
1790
 
1714
1791
  Step 2: Doc inventory (always runs, not cached):
1715
1792
  - \`find({ glob: "docs/**/*.md" })\` — doc inventory
@@ -1720,9 +1797,9 @@ The IR (\`docs/.docs-state.json\`) stores:
1720
1797
  - \`version\` + \`layer: "l0"\` (regeneratable cache, not curated; committed to git)
1721
1798
  - \`lastCommitSha\` (committed = warm clones, no cold starts)
1722
1799
  - \`onboardRef\` (pointer to onboard cache, NO duplicated analysis data)
1723
- - \`sourceFiles\` (per-file contentHash, signatures, changeClass)
1724
- - \`docReverseIndex\` (schema reserved for E3 blast_radius integration)
1725
- - \`_concurrency.version\` (compare-and-swap for multi-session safety)
1800
+ - \`sourceFiles\` (per-file contentHash, signatureHash, contractHash, syncedAt, changeClass)
1801
+ - \`docReverseIndex\` (schema reserved for E3 blast_radius integration — required for Standard tier)
1802
+ - \`_concurrency.version\` (compare-and-saw for multi-session safety, implement atomic write via write+rename)
1726
1803
 
1727
1804
  **Consumer pattern (all later phases):**
1728
1805
  - If IR fresh: read changeManifest + onboard cache, skip fresh analyze()
@@ -2017,6 +2094,16 @@ find({ pattern: "orgId|tenantId|teamId|workspaceId" })
2017
2094
  3. Cross-reference tour steps with actual files
2018
2095
  4. check({}) to ensure no build breaks
2019
2096
  5. Verify all interactive HTML files open correctly and contain valid JSON data
2097
+
2098
+ # Cross-reference validation (Standard tier — R7)
2099
+ # Validate references FROM unchanged docs TO changed docs
2100
+ # Without this, doc A mentioning component B becomes stale when B is regenerated
2101
+ 6a. blast_radius({ files: regeneratedDocFiles }) → find docs affected by regenerated content
2102
+ 6b. For each affected doc:
2103
+ - Check internal links to regenerated docs still resolve
2104
+ - Verify code references (file:line) still exist
2105
+ - Flag stale refs with ⚠️ Needs review — do NOT regenerate unchanged docs automatically
2106
+ 6c. Store updated reference map in .docs-state.json
2020
2107
  \`\`\`
2021
2108
 
2022
2109
  #### SBC Completeness Scoring Detail
@@ -3224,6 +3311,46 @@ L3 (Evidence Archive) ──→ docs/reference/ — Verified claims with tool re
3224
3311
  4. Generate doc with evidence annotations (✓ verified / 🔍 inferred / ⚠ assumed)
3225
3312
  5. Promote verified claims as candidate L2 entries
3226
3313
 
3314
+ ## Tier Branching (FORGE-aware)
3315
+
3316
+ Docs generation depth is driven by FORGE tier (passed as \`tier\` from Orchestrator). This is the single source of truth — Documenter.md cross-references here.
3317
+
3318
+ ### Step 0: Check docs_tier
3319
+ - Read \`tier\` from dispatch envelope (maps directly from FORGE classification)
3320
+ - \`docs_tier\` = FORGE \`tier\` — always 1:1 by default
3321
+ - Override only when Orchestrator explicitly passes \`tierOverride\`
3322
+
3323
+ ### Tier Branch Table
3324
+
3325
+ | Tier | Pipeline Execution | Fingerprinting | Evidence Protocol | Output |
3326
+ |------|-------------------|---------------|-------------------|--------|
3327
+ | Floor | Skip entirely | State tracking only (deterministic pre-step, not LLM) | file:line citations only | "No documentation updates needed" + state one-liner: \`state: { filesTracked, filesChanged, docsCurrent }\` |
3328
+ | Standard | Surgical: changed docs only + cross-ref validation | Change classification (AST-based for accuracy) | Add 2-4 CRITICAL/HIGH findings | Affected docs regenerated with \`_generation: { tier, trigger, changeClass }\` frontmatter |
3329
+ | Critical | Full Phase 1-7 (plus any phases matching change type) | Staleness tracking | All CRITICAL/HIGH + safety_gate | Full 7 docs + C4 + tours + interactive companions |
3330
+
3331
+ **Note:** Standard tier requires E3 \`docReverseIndex\` for doc-to-file mapping — blocked until E3 ships. Without E3, Standard falls back to heuristic (file path matching + \`find\` glob).
3332
+
3333
+ ### Cross-Reference Validation (Standard tier)
3334
+
3335
+ When Standard tier regenerates specific docs, validate references from ALL docs (not just changed ones):
3336
+ 1. \`blast_radius({ files: regeneratedDocFiles })\` → find docs that reference changed content
3337
+ 2. For each affected doc: check internal links resolve, verify code references still exist
3338
+ 3. Flag stale references with \`⚠️ Needs review\` banner — do NOT regenerate unchanged docs automatically
3339
+ 4. Store updated reference map in \`.docs-state.json\`
3340
+
3341
+ ### Doc-Type Sensitivity
3342
+
3343
+ Not all doc types need the same tier. When change classification detects signature/STRUCTURAL changes, auto-escalate Reference docs to Critical-tier regeneration:
3344
+
3345
+ | Change Type | Minimum Docs Tier |
3346
+ |-------------|------------------|
3347
+ | Signature/API change (STRUCTURAL) | Critical (for Reference docs) |
3348
+ | Content change (COSMETIC) | Standard |
3349
+ | Configuration/package change | Critical (always STRUCTURAL) |
3350
+ | New file/module | Standard |
3351
+ | Internal refactor (no public API change) | Floor |
3352
+ | Comment/whitespace only | Floor |
3353
+
3227
3354
  ## Scenario Detection
3228
3355
 
3229
3356
  | Condition | Mode |
@@ -3236,15 +3363,27 @@ L3 (Evidence Archive) ──→ docs/reference/ — Verified claims with tool re
3236
3363
 
3237
3364
  ## Workflow
3238
3365
 
3366
+ 0. **Check docs_tier** — Read FORGE \`tier\` from dispatch. Map to Tier Branch Table above. Floor tier → skip to step 9 (state tracking only).
3239
3367
  1. **Study existing documentation first**: Load reference examples from references/ directory and existing project docs/ to understand conventions, tone, and structure before generating new content.
3368
+ 1a. **Freshness check** (Knowledge↔Docs Bridge): Before loading layered context, check if recent L2 lessons contradict studied docs. Session-level dedup (checked topic Set) prevents repeat checks:
3369
+ - \`search({ query: "recent lessons about <target domain>" })\`
3370
+ - \`knowledge({ action: 'lesson', subAction: 'list-lessons', topic: '<target domain>' })\`
3371
+ - For each lesson found: if \`lesson.updatedAt > doc._lastSynced.syncedAt\`:
3372
+ Flag: \`[FRESHNESS WARNING] Knowledge entry "<title>" updated <date>, may affect <doc path>\`
3373
+ - If \`syncedAt\` missing on doc → treat as stale (conservative), emit warning
3374
+ - If no recent lessons match → continue silently
3375
+ - Session dedup: maintain \`Set<string>\` of checked topic+entry IDs per session; skip if already checked
3240
3376
  2. **Load layered context**: \`status({ includePrelude: true })\` → L0. \`knowledge({ action: 'withdraw', scope: 'flow', profile: 'documenter', budget: 6000 })\` → L1.
3241
3377
  3. Gather intent/evidence from flow artifacts, git diff, blast_radius, produce_knowledge, analyze, changelog, or search.
3242
3378
  4. Classify target docs with Diataxis or extended doc type table.
3243
3379
  5. Map changed capability to doc action.
3244
- 6. Generate/update surgically; preserve valid human text.
3380
+ 6. Generate/update surgically; preserve valid human text. Branch by tier:
3381
+ - **Floor**: Skip generation. Update \`.docs-state.json\` hashes only. Emit \`state: { filesTracked, filesChanged, docsCurrent }\`.
3382
+ - **Standard**: Generate/update only affected docs + cross-ref validation (see Cross-Reference Validation section).
3383
+ - **Critical**: Full regeneration — execute applicable pipeline phases.
3245
3384
  7. **Generate interactive companions**: C4 viewers, tour viewers, present dashboards.
3246
3385
  8. Validate claims, links, references, and generated assets. Use \`browser\` to screenshots.
3247
- 9. If nothing durable changed, report: "No documentation updates needed."
3386
+ 9. If nothing durable changed (or Floor tier), report: "No documentation updates needed."
3248
3387
 
3249
3388
  ## Change -> Doc Action
3250
3389
 
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{n as e,t}from"./server-BtRv0mbH.js";export{t as buildPreludeInjection,e as generatePrelude};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./server-BYZo2XjK.js";export{t as buildPreludeInjection,e as generatePrelude};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{r as e}from"./server-BtRv0mbH.js";export{e as createSamplingClient};
@@ -1 +0,0 @@
1
- import{r as e}from"./server-BYZo2XjK.js";export{e as createSamplingClient};