@vpxa/aikit 0.1.106 → 0.1.108

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.
@@ -1704,7 +1704,568 @@ Notes:
1704
1704
  - Scripts auto-detect ADR directory and filename strategy.
1705
1705
  - Use \`--dir\` and \`--strategy\` to override.
1706
1706
  - Use \`--json\` to emit machine-readable output.
1707
- `}],aikit:[{file:`SKILL.md`,content:'---\nname: aikit\ndescription: "Use the @vpxa/aikit AI Kit MCP server for codebase search, analysis, and persistent memory. Load this skill when using aikit_search, aikit_analyze, aikit_knowledge, or any aikit_* tool. Covers all 82 MCP tools: search (hybrid/semantic/keyword), code analysis (analyze aspects for structure, dependencies, symbols, patterns, entry points, diagrams, plus blast radius), knowledge graph (auto-populated module/symbol/import graph with traversal), context management (worksets, stash, checkpoints, restore, lanes), code manipulation (rename, codemod, eval), knowledge management (knowledge actions: remember/read/update/forget/list), web access (fetch, search, http), FORGE protocol (ground, classify, evidence map, stratum cards, digest), brainstorming (interactive ideation sessions), presentation (rich dashboards via present tool), onboarding (full codebase analysis in one call), and developer utilities (regex, encode, measure, changelog, schema-validate, snippet, env, time)."\nmetadata:\n category: cross-cutting\n domain: general\n applicability: always\n inputs: [codebase]\n outputs: [search-results, analysis, knowledge]\n relatedSkills: [present]\n---\n\n# @vpxa/aikit — AI Kit\n\nLocal-first AI developer toolkit — 82 MCP tools for search, analysis, context compression, FORGE quality gates, knowledge management, code manipulation, execution, web access, brainstorming, presentation, and developer utilities.\n\n## When to Use\n\n- You need long-term memory across coding sessions\n- You want to search a codebase semantically (by meaning, not just keywords)\n- You need to compress large contexts to focus on what matters\n- You want structured output from build tools (tsc, vitest, biome, git)\n- You need to plan which files to read for a task\n- You want to safely explore refactors in isolated lanes\n- You need to rename symbols, apply codemods, or run code transformations\n- You want to fetch and read web pages or search the web\n- You need to make HTTP requests, test APIs, or debug endpoints\n- You want to test regex patterns, encode/decode data, or validate JSON schemas\n- You need code complexity metrics or a git changelog\n- You want to save and reuse code snippets across sessions\n\n## Skills Reference\n\n| Context | Skill | Load when |\n|---------|-------|----------|\n| Repository access recovery | `repo-access` | When encountering git auth failures, accessing private/enterprise repos, or when `web_fetch`/`http` returns auth errors on repository URLs. |\n\n## Architecture\n\n10-package monorepo published as a single npm package:\n\n```\ncore → store → embeddings → chunker → indexer → analyzers → tools → server → cli → tui\n```\n\n- **MCP server**: 82 tools + 2 resources (via `@modelcontextprotocol/sdk`)\n- **CLI**: 45 commands (thin dispatcher + 10 command groups)\n- **Search**: Hybrid vector + keyword + RRF fusion\n- **Embeddings**: ONNX local (mxbai-embed-large-v1, 1024 dimensions)\n- **Vector store**: LanceDB (embedded, zero infrastructure)\n- **Chunking**: Tree-sitter AST (TS/JS/Python/Go/Rust/Java) + regex fallback\n- **TUI**: Ink/React dashboard for human monitoring (search, status, curated, activity log)\n\n## Session Protocol (MANDATORY)\n\n### Start (do ALL)\n```\nflow_status({}) # Check/resume active flow FIRST\n# If flow active → flow_read_instruction({ step }) → follow step instructions\nstatus({}) # Check AI Kit health + onboard state\n# If onboard not run → onboard({ path: "." }) # First-time codebase analysis\nflow_list({}) # See available flows\n# Select flow based on task → flow_start({ flow: "<name>", topic: "<task>" }) # Start — creates .flows/{topic}/\nknowledge({ action: "list" }) # See stored knowledge\nsearch({ query: "SESSION CHECKPOINT", origin: "curated" }) # Resume prior work\n```\n\n### During Session\n```\nsearch → scope_map → symbol → trace (orient)\ncheck → test_run (validate changes)\nknowledge({ action: "remember", ... }) (capture insights)\n```\n\n### End of Session\n```\nsession_digest({ persist: true }) # Auto-capture session activity\nknowledge({ action: "remember", title: "Session checkpoint: <topic>", content: "<what was done, decisions made, next steps>", category: "conventions" })\n```\n\n## Tool Catalog (82 tools)\n\n### Search & Discovery (8)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `search` | `aikit search` | Hybrid/semantic/keyword search with `search_mode` param |\n| `find` | `aikit find` | Federated search: vector + FTS + glob + regex in one call. Use `mode: \'examples\'` to find usage examples. |\n| `symbol` | `aikit symbol` | Resolve symbol definition, imports, and references |\n| `lookup` | `aikit lookup` | Full-file retrieval by path or record ID |\n| `scope_map` | `aikit scope-map` | Task-scoped reading plan with token estimates |\n| `trace` | `aikit trace` | Forward/backward flow tracing through call chains |\n| `dead_symbols` | `aikit dead-symbols` | Find exported symbols never imported — separates source (actionable) from docs (informational). Accepts `path` to scope the search. |\n| `file_summary` | `aikit summarize` | Structural overview of a file (exports, imports, functions) |\n\n### Code Analysis (2)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `analyze` | `aikit analyze <aspect>` | Unified analyzer for structure, dependencies, symbols, patterns, entry_points, and diagram aspects |\n| `blast_radius` | `aikit analyze blast-radius` | Change impact analysis |\n\n### Context Management (6)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `compact` | `aikit compact` | Compress text to relevant sections using embeddings (no LLM). Accepts `path` for server-side file read. |\n| `workset` | `aikit workset` | Named file set management (save/load/add/remove) |\n| `stash` | `aikit stash` | Named key-value store for session data |\n| `checkpoint` | `aikit checkpoint` | Save/restore session checkpoints |\n| `restore` | `aikit restore` | Restore a previously saved checkpoint |\n| `parse_output` | `aikit parse-output` | Parse tsc/vitest/biome/git output → structured JSON |\n\n### Code Manipulation (4)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `rename` | `aikit rename` | Smart whole-word symbol rename across files (dry-run supported) |\n| `codemod` | `aikit codemod` | Regex-based code transformations with rules (dry-run supported) |\n| `diff_parse` | `aikit diff` | Parse unified diff → structured changes |\n| `data_transform` | `aikit transform` | JQ-like JSON transformations |\n\n### Execution & Validation (5)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `eval` | `aikit eval` | Sandboxed JavaScript/TypeScript execution |\n| `check` | `aikit check` | Incremental typecheck + lint. `detail` param: efficient (default, minimal), normal (parsed errors), full (includes raw) |\n| `test_run` | `aikit test` | Run tests with structured pass/fail results |\n| `batch` | `aikit batch` | Execute multiple operations in parallel |\n| `audit` | `aikit audit` | Unified project audit: structure, deps, patterns, health, dead symbols, check, entry points → synthesized report with score and recommendations. 6 round-trips → 1. |\n\n### Knowledge Management (2)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `knowledge` | `aikit knowledge <action>` | Unified knowledge tool for remember, read, update, forget, and list actions |\n| `produce_knowledge` | — | Auto-generate knowledge from analysis |\n\n### Auto-Knowledge (automatic)\n\nTool outputs are automatically analyzed after every call. Useful facts (conventions, test patterns, build commands, errors) are extracted and stored as curated entries. Quality gate (score >= 0.3), deduplication, TTL for transient facts, max 50/session.\n\nSearch auto-knowledge with: `search({ query: "...", origin: "curated" })` or `knowledge({ action: "list", category: "conventions" })`\n\n### Verified Lanes (1 tool, 6 actions)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `lane` | `aikit lane` | Manage isolated file copies for parallel exploration |\n\nLane actions: `create` (copy files to lane), `list`, `status` (modified/added/deleted), `diff` (line-level diff), `merge` (apply back to originals), `discard`.\n\n### Git & Environment (4)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `git_context` | `aikit git` | Branch, status, recent commits |\n| `process` | `aikit proc` | Process supervisor (start/stop/logs) |\n| `watch` | `aikit watch` | Filesystem watcher |\n| `delegate` | `aikit delegate` | Delegate subtask to local Ollama model |\n\n### Web & Network (3)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `web_fetch` | — | Fetch web page → markdown/raw/links/outline for LLM consumption |\n| `web_search` | — | Search the web via DuckDuckGo (no API key needed) |\n| `http` | — | Make HTTP requests for API testing/debugging |\n\n### Developer Utilities (8)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `regex_test` | — | Test regex patterns with match/replace/split modes |\n| `encode` | — | Base64, URL, SHA-256, MD5, hex encode/decode, JWT decode |\n| `measure` | — | Code complexity metrics (cyclomatic, cognitive complexity, lines, functions) |\n| `changelog` | — | Generate changelog from git history (conventional commits) |\n| `schema_validate` | — | Validate JSON data against JSON Schema |\n| `snippet` | — | Save/get/search/delete persistent code snippets |\n| `env` | — | System and runtime environment info (sensitive values redacted) |\n| `time` | — | Date parsing, timezone conversion, duration math |\n\n### FORGE Quality Gates (5)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `forge_ground` | — | Full Ground phase: classify tier, scope map, unknowns, constraints |\n| `forge_classify` | — | Quick tier classification (Floor/Standard/Critical) |\n| `evidence_map` | — | CRUD + Gate evaluation for verified/assumed/unknown claims. Safety gate tags (`provenance`/`commitment`/`coverage`) enable mandatory pre-YIELD checks |\n| `stratum_card` | — | Generate T1/T2 compressed context cards from files (10-100x token reduction) |\n| `digest` | — | Compress N text sources into token-budgeted summary |\n\n### System (9)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `config` | `aikit config` | View or update project configuration (kb.config.json) |\n| `status` | `aikit status` | Index statistics |\n| `reindex` | `aikit reindex` | Rebuild index |\n| `health` | `aikit health` | Project health checks (package.json, tsconfig, lockfile, circular deps) |\n| `guide` | `aikit guide` | Tool discovery — given a goal, recommends tools and workflow order |\n| `onboard` | `aikit onboard` | Full codebase onboarding in one call (structure + deps + patterns + knowledge) |\n| `graph` | `aikit graph` | Query the auto-populated knowledge graph (modules, symbols, imports) |\n| `queue` | `aikit queue` | Task queue for sequential agent operations (create/push/next/done/fail) |\n| `replay` | `aikit replay` | View or clear the audit trail of tool invocations (action: list/clear) |\n\n### Flows (11)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `flow_list` | `aikit flow list` | List available flows and active run |\n| `flow_info` | `aikit flow info` | Get flow details including steps and skill paths |\n| `flow_start` | `aikit flow start` | Start a flow with topic — creates `.flows/{topic-slug}/` run directory |\n| `flow_step` | `aikit flow step` | Advance, skip, or redo the current step |\n| `flow_status` | `aikit flow status` | Check active run including slug, runDir, artifactsPath |\n| `flow_read_instruction` | `aikit flow read-instruction` | Read instruction with `{{artifacts_path}}` and `{{run_dir}}` resolved |\n| `flow_reset` | `aikit flow reset` | Abandon the active flow (preserves run directory) |\n| `flow_runs` | `aikit flow runs` | List all flow runs (current and past) |\n| `flow_add` | `aikit flow add` | Add a custom flow from a directory |\n| `flow_update` | `aikit flow update` | Update an existing custom flow |\n| `flow_remove` | `aikit flow remove` | Remove a custom flow |\n\n### Presentation (1)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `present` | — | Rich dashboards, charts, tables, timelines. Use `format: "browser"` then `openBrowserPage` to display. **In CLI mode (no VS Code chat), always use `format: "browser"`** — `html` UIResource is invisible in terminal. |\n\n### Brainstorming (1)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `brainstorm` | — | Interactive brainstorming and ideation sessions with structured output |\n\n### Meta-Tools — Tool Discovery (3)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `list_tools` | — | List all active AI Kit tools with names, titles, and categories. Accepts optional `category` filter. Use for initial tool discovery. |\n| `describe_tool` | — | Get detailed metadata for a specific tool (title, categories, annotations). Use after `list_tools` to understand a tool before calling it. |\n| `search_tools` | — | Search active tools by keyword across names, titles, and categories. Use when you know what you need but not the tool name. |\n\n### Session Management (1)\n| Tool | CLI | Purpose |\n|------|-----|---------|\n| `session_digest` | — | Generate a compressed digest of session activity (replay log, stash, checkpoints). Options: `scope` (tools/stash/all), `since`, `last`, `focus`, `mode` (deterministic/sampling), `tokenBudget`, `persist`. Use at session end for handoff or mid-session to review what happened. |\n\n## Flow System\n\nFlows are multi-step guided workflows that structure complex tasks. Each step has a skill file with detailed instructions, required artifacts, and agent assignments.\n\n### Built-in Flows\n\n| Flow | Steps | Use When |\n|------|-------|----------|\n| `aikit:basic` | assess → implement → verify | Bug fixes, config changes, small features |\n| `aikit:advanced` | spec → plan → task → execute → verify | New modules, cross-service changes, architectural work |\n\n### Flow Lifecycle\n\n```text\nflow_list() # See available flows\nflow_info({ flow: "aikit:basic" }) # View steps, skills, agents\nflow_start({ flow: "aikit:basic", topic: "Fix login bug" }) # Start — creates .flows/fix-login-bug/\nflow_read_instruction() # Read current step\'s instructions ({{artifacts_path}} resolved)\n# ... do the work described in the instruction ...\nflow_step({ action: "next" }) # Advance to next step\nflow_step({ action: "skip" }) # Skip current step\nflow_step({ action: "redo" }) # Redo current step\nflow_status() # Check progress (includes slug, runDir, artifactsPath, phase, isEpilogue)\nflow_reset() # Abandon active flow\nflow_runs() # List all runs (current + past)\n# Epilogue steps (mandatory, injected after every flow):\n# After last flow step → _docs-sync epilogue runs automatically\n# flow_status() shows phase: \'after\', isEpilogue: true during epilogue\n```\n\nCustom flow lifecycle management:\n\n```text\nflow_add({ source: ".github/flows/my-flow" })\nflow_update({ name: "my-flow" })\nflow_remove({ name: "my-flow" })\n```\n\n## CRITICAL: Use AI Kit Tools Instead of Native IDE Tools\n\nAI Kit tools provide **10x richer output** than native IDE tools — with AST-analyzed call graphs, scope context, import classification, and cognitive complexity. **You MUST use AI Kit tools instead of native read/search tools.**\n\n### ⛔ PROHIBITED: Native File Reading\n\n**`read_file` / `read_file_raw` MUST NOT be used to understand code.** They waste tokens and miss structural information.\n\nThe **ONLY** acceptable use of `read_file`: getting exact lines immediately before an edit (to verify the `old_str` for replacement). Even then, use `file_summary` first to identify which lines to read.\n\n### Tool Replacement Table\n\n| ❌ NEVER do this | ✅ Use AI Kit Tool | Why |\n|---|---|---|\n| `read_file` (full file) | `file_summary` | Exports, imports, call edges — **10x fewer tokens** |\n| `read_file` (specific section) | `compact({ path, query })` | Server-side read + extract — **5-20x reduction** |\n| `grep_search` / `textSearch` | `search` | Semantic + keyword hybrid across all indexed content |\n| `grep_search` for a symbol | `symbol` | Definition + references **with scope context** |\n| Multiple `read_file` calls | `digest` | Compresses multiple sources into token-budgeted summary |\n| `listDirectory` + `read_file` | `scope_map` | Identifies relevant files for a task automatically |\n| Manual code tracing | `trace` | AST call-graph traversal with scope context |\n| Line counting / `wc` | `measure` | Lines, complexity, **cognitive complexity**, functions |\n| Grep for unused exports | `dead_symbols` | AST-powered export detection with regex fallback |\n| Repeated file reads | `stratum_card` | Reusable compressed context — **10-100x reduction** |\n| `fetch_webpage` | `web_fetch` | Readability extract + token budget — richer output |\n| Web research / browsing | `web_search` | Structured web results without browser — **unique to KB** |\n\n### Decision Tree — How to Read Code\n\n```\nNeed to understand a file?\n├─ Just structure? → file_summary (exports, imports, call edges — ~50 tokens)\n├─ Specific section? → compact({ path, query }) — 5-20x reduction\n├─ Multiple files? → digest (multi-source compression — token-budgeted)\n├─ Repeated reference? → stratum_card (T1/T2 card — 10-100x reduction)\n├─ Need exact lines to EDIT? → read_file (the ONLY acceptable use)\n└─ "I want to read the whole file" → ⛔ STOP. Use file_summary or compact instead.\n```\n\n### Decision Tree — Need Structural Relationships?\n\nWhen vector search and file reads don\'t answer the question (e.g. "who imports this?",\n"what does this depend on?", "how are these files connected?"), use `graph`:\n\n```\nNeed to understand relationships between code?\n├─ Who imports / calls this? → graph({action:\'find_nodes\', name_pattern}) → graph({action:\'neighbors\', node_id, direction:\'incoming\'})\n├─ What does this depend on? → graph({action:\'neighbors\', node_id, direction:\'outgoing\'})\n├─ Full context for a symbol? → graph({action:\'symbol360\', name})\n├─ Related files within N hops? → graph({action:\'traverse\', node_id, max_depth:2})\n├─ Layer/module isolation check? → graph({action:\'depth_traverse\', node_id, max_depth:3})\n└─ Graph size/health? → graph({action:\'stats\'})\n```\n\n**Use this BEFORE** reaching for `analyze({ aspect: "dependencies", ... })` (slower, less precise) or manually\ntracing via `symbol` + `trace` chains. The graph is auto-populated during indexing.\n\n### What AI Kit Tools Return (AST-Enhanced)\n\nThese tools use Tree-sitter WASM to analyze source code at the AST level, providing structured data that raw file reads cannot:\n\n| Tool | Rich Output |\n|------|-------------|\n| `file_summary` | Imports classified as **external vs internal** (`isExternal` flag). **Call edges** between functions (e.g., `handleRequest() → validateInput() @ line 42`). `exported` flag on interfaces and types. Import count breakdown. |\n| `symbol` | References include **scope** — which function/class/method contains each usage (e.g., `referenced in processOrder() at auth-service.ts:55`). |\n| `trace` | **Call-graph edges** discovered via AST syntax tree, not text matching. Supports forward (who does X call?) and backward (who calls X?) tracing. Scope context on each node. |\n| `measure` | **Cognitive complexity** — weights nesting depth (nested `if` inside `for` inside `try` scores higher). More useful than cyclomatic complexity for understanding code difficulty. |\n| `dead_symbols` | **AST export enumeration** — catches `export default`, barrel re-exports (`export { x } from`), `export =`, and `export type`. Regex fallback for non-AST-supported languages. |\n\n### Example: `file_summary` Output\n\n```\nsrc/auth-service.ts\nLanguage: typescript | Lines: 180 | Estimated tokens: ~1400\n\nImports (6): 3 external, 3 internal\n - import { hash } from \'bcrypt\' [external]\n - import { UserRepo } from \'./user-repo\' [internal]\n\nFunctions (4):\n - authenticate @ line 22 [exported]\n - validateToken @ line 55 [exported]\n - hashPassword @ line 90\n - generateJwt @ line 110\n\nCall edges (12 intra-file):\n - authenticate() → hashPassword() @ line 35\n - authenticate() → generateJwt() @ line 42\n - validateToken() → UserRepo.findById() @ line 68\n\nInterfaces (2):\n - AuthResult @ line 8 [exported]\n - TokenPayload @ line 14\n```\n\nCompare: `read_file` would cost ~1400 tokens for raw text. `file_summary` gives structured data in ~120 tokens — **12x reduction** with richer information.\n\n## Token Efficiency\n\n`config.tokenBudget` controls output verbosity globally:\n\n| Level | Output | Compression | Context Strategy |\n|-------|--------|-------------|------------------|\n| `efficient` (default) | Minimal output, score + top issues only | threshold 2000, budget 1000 | `stratum_card(T1)` |\n| `normal` | Standard output with parsed errors/pattern names | threshold 4000, budget 2000 | `compact()` |\n| `full` | Maximum detail with raw output/full tables | No compression | `digest()` |\n\nSet via: `config({ action: \'update\', updates: { tokenBudget: \'normal\' } })`\n\nTools with `detail` param inherit from `config.tokenBudget` when not explicitly set.\nCompression middleware applies to ALL tool responses automatically.\n\n## Search Strategy\n\n1. **Start broad**: `search({ query: "topic", search_mode: "hybrid" })`\n2. **Narrow**: Add `content_type`, `origin`, or `category` filters\n3. **Exact match**: Use `search_mode: "keyword"` for identifiers\n4. **Federated**: Use `find` to combine vector + glob + regex\n\n## Workflow Chains\n\n### Codebase Onboarding\n```\nanalyze({ aspect: "structure", path: "src/" })\n→ analyze({ aspect: "dependencies", path: "src/" })\n→ analyze({ aspect: "entry_points", path: "src/" })\n→ produce_knowledge({ path: "src/" })\n→ knowledge({ action: "remember", title: "Codebase onboarding complete", ... })\n```\n\n### Planning a Task\n```\nscope_map({ task: "implement user auth" })\n→ compact({ path: "src/auth.ts", query: "auth flow" })\n→ workset({ action: "save", name: "auth-task", files: [...] })\n```\n\n### Bug Investigation\n```\nparse_output({ output: <error> }) → symbol({ name: "failingFn" })\n→ trace({ symbol: "failingFn", direction: "backward" })\n→ blast_radius({ changed_files: ["suspect.ts"] })\n→ eval({ code: "hypothesis test" }) → check({ files: ["suspect.ts"] })\n```\n\n### Multi-Task Orchestration (DAG Queue)\n```\nqueue({ action: "create", name: "my-tasks" })\n→ queue({ action: "push", name: "my-tasks", title: "Task 1", data: { deps: [] } })\n→ queue({ action: "push", name: "my-tasks", title: "Task 2", data: { deps: ["task-1-id"] } })\n→ queue({ action: "next", name: "my-tasks" }) # Gets next ready task\n→ [do work]\n→ queue({ action: "done", name: "my-tasks", id: "<id>" })\n```\n\n### Safe Refactor with Lanes\n```\nscope_map({ task: "rename UserService" })\n→ lane({ action: "create", name: "refactor", files: [...] })\n→ [make changes in lane files]\n→ lane({ action: "diff", name: "refactor" })\n→ check({}) → test_run({})\n→ lane({ action: "merge", name: "refactor" })\n```\n\n### Lane — isolated read-only exploration\n\n`lane({ action:\'create\', name })` creates an isolated copy of the workspace. Use to try approach A vs B WITHOUT touching canonical source. Other actions: `list`, `diff`, `delete`. Compare with `lane({ action:\'diff\', names:[\'a\',\'b\'] })`. Do NOT use `lane` for actual refactors — use `checkpoint` instead (`checkpoint` = reversible on canonical source; `lane` = isolated copies for comparison).\n\n### After Making Changes\n```\nblast_radius({ changed_files: ["src/auth.ts"] })\n→ check({}) → test_run({ grep: "auth" })\n→ reindex()\n→ knowledge({ action: "remember", title: "Implemented auth", content: "..." })\n```\n\n### Pre-Commit Validation\n```\ngit_context({ diff: true })\n→ diff_parse({ diff: <staged diff> })\n→ blast_radius({ changed_files: [...] })\n→ check({}) → test_run({})\n```\n\n---\n\n## Persistent Memory\n\n| Action | Tool | Category |\n|--------|------|----------|\n| Store | `knowledge({ action: "remember", title, content, category })` | conventions, decisions, patterns, context, session |\n| Search | `search({ query, origin: "curated" })` | — |\n| Browse | `knowledge({ action: "list" })` or `knowledge({ action: "list", category })` | — |\n| Read | `knowledge({ action: "read", id })` | — |\n| Update | `knowledge({ action: "update", id, content })` | — |\n| Remove | `knowledge({ action: "forget", id })` | — |\n\n**Session checkpoint** (end of session): `knowledge({ action: "remember", title: "Session checkpoint: <topic>", content: "Done/Decisions/Next/Blockers", category: "session" })`\n\n## CLI Quick Reference\n\n```bash\naikit init # Scaffold AI Kit in current directory\naikit init --force # Overwrite all scaffold/skill files\naikit init --guide # JSON report of stale files for LLM-driven updates\naikit serve # Start MCP server (stdio or HTTP)\naikit search <q> # Hybrid search\naikit find <q> # Federated search\naikit symbol <name> # Resolve symbol\naikit scope-map <t> # Task reading plan\naikit compact <q> # Context compression (--path file or stdin)\naikit check # Typecheck + lint (--detail efficient|normal|full)\naikit test # Run tests\naikit rename <old> <new> <path> # Rename symbol\naikit lane create <name> --files f1,f2 # Create lane\naikit lane diff <name> # View lane changes\naikit lane merge <name> # Merge lane back\naikit status # Index stats\naikit reindex # Rebuild index\n```\n\n## Configuration\n\n`kb.config.json` in project root:\n```json\n{\n "sources": [{ "path": ".", "excludePatterns": ["node_modules/**", "**/node_modules/**", "dist/**", "coverage/**", ".aikit-data/**"] }],\n "indexing": { "chunkSize": 1500, "chunkOverlap": 200, "minChunkSize": 100, "concurrency": 5 },\n "embedding": { "model": "mixedbread-ai/mxbai-embed-large-v1", "dimensions": 1024 },\n "store": { "backend": "lancedb", "path": ".aikit-data" },\n "curated": { "path": "curated", "adapter": "filesystem" }\n}\n```\n\n## Tool Profiles\n\nTool profiles control which subset of the 82 tools are active. Profiles reduce token overhead by exposing only relevant tools for a given task.\n\n### Built-in Profiles\n\n| Profile | Description | Use When |\n|---------|-------------|----------|\n| `full` | All tools enabled (default) | General development, orchestration |\n| `safe` | Read-only tools — no file/state modifications | Code review, analysis, research |\n| `research` | Search, analysis, knowledge, web access | Investigation, documentation |\n| `minimal` | Essential tools only — search, check, test | Simple tasks, low-token budgets |\n| `discovery` | Full toolset + meta-tools for guided exploration | New users, onboarding, tool learning |\n\n### Activating a Profile\n\nSet `toolProfile` in `kb.config.json`:\n\n```json\n{\n "toolProfile": "research"\n}\n```\n\nBase tools (`status`, `config`, `guide`, `health`) are **always available** regardless of profile.\n\n## Development (Self-Dogfooding)\n\nWhen developing @vpxa/aikit itself: always `pnpm build` before using CLI/server (runs from `dist/`), always `reindex` after structural code changes, and don\'t run CLI and HTTP server simultaneously (LanceDB is single-process).\n\n---\n\n## Flows\n\nFlows are structured multi-step workflows that guide agents through complex tasks. They are the **primary workflow system** — use them instead of ad-hoc planning when a matching flow exists.\n\n### Flow Tools\n\n| Tool | Purpose |\n|------|---------|\n| `flow_status` | Check if a flow is active + current step + phase (before/flow/after) + isEpilogue |\n| `flow_list` | List available flows |\n| `flow_info` | Get flow details including steps and skill paths |\n| `flow_start` | Start a named flow |\n| `flow_step` | Advance: `next`, `skip`, or `redo` current step |\n| `flow_read_instruction` | Read the current step\'s instruction file content directly |\n| `flow_reset` | Clear flow state to start over |\n| `flow_add` | Add a custom flow from a directory |\n| `flow_update` | Update an existing custom flow |\n| `flow_remove` | Remove a custom flow |\n\n### Flow Selection\n\n| Task Type | Flow | Why |\n|-----------|------|-----|\n| Bug fix, config change, small refactor | `aikit:basic` | Known scope, low risk |\n| New feature in existing module | `aikit:basic` | Clear boundaries |\n| New system/service/module | `aikit:advanced` | Needs spec + planning |\n| Cross-service changes | `aikit:advanced` | Multiple boundaries |\n| Architectural change | `aikit:advanced` | High impact |\n| Unclear scope or exploratory | No flow | Use agent\'s native workflow |\n\n### Flow Lifecycle\n\n1. **Start**: `flow_list({})` → choose flow → `flow_start({ flow: "<name>", topic: "<task>" })`\n2. **Each step**: `flow_read_instruction({ step: "<name>" })` → follow step instructions → complete work\n3. **Advance**: `flow_step({ action: "next" })` → repeat from step 2\n4. **Epilogue**: After last flow step, mandatory epilogue steps run (e.g., `_docs-sync` updates `docs/`)\n5. **Resume**: `flow_status({})` → if active, `flow_read_instruction` for current step → continue\n6. **Reset**: `flow_reset({})` if you need to start over\n\n---\n\n## Reference Documentation\n\nFor detailed patterns on specific topics, load these reference files:\n\n| Topic | File | When to load |\n|-------|------|-------------|\n| Multi-task orchestration | `references/coordination.md` | Queue, DAG, lanes, worksets, stash, checkpoints |\n| Quality gates (FORGE) | `references/forge-protocol.md` | Complex tasks, evidence maps, tier classification |\n| Search & relationships | `references/search-patterns.md` | Finding code, tracing data flow, graph traversal |\n'},{file:`references/coordination.md`,content:`# Coordination & Multi-Task Orchestration
1707
+ `}],aikit:[{file:`SKILL.md`,content:`---
1708
+ name: aikit
1709
+ description: "Use the @vpxa/aikit AI Kit MCP server for codebase search, analysis, and persistent memory. Load this skill when using aikit_search, aikit_analyze, aikit_knowledge, or any aikit_* tool. Covers all 82 MCP tools: search (hybrid/semantic/keyword), code analysis (analyze aspects for structure, dependencies, symbols, patterns, entry points, diagrams, plus blast radius), knowledge graph (auto-populated module/symbol/import graph with traversal), context management (worksets, stash, checkpoints, restore, lanes), code manipulation (rename, codemod, eval), knowledge management (knowledge actions: remember/read/update/forget/list), web access (fetch, search, http), FORGE protocol (ground, classify, evidence map, stratum cards, digest), brainstorming (interactive ideation sessions), presentation (rich dashboards via present tool), onboarding (full codebase analysis in one call), and developer utilities (regex, encode, measure, changelog, schema-validate, snippet, env, time)."
1710
+ metadata:
1711
+ category: cross-cutting
1712
+ domain: general
1713
+ applicability: always
1714
+ inputs: [codebase]
1715
+ outputs: [search-results, analysis, knowledge]
1716
+ relatedSkills: [present]
1717
+ ---
1718
+
1719
+ # @vpxa/aikit — AI Kit
1720
+
1721
+ Local-first AI developer toolkit — 82 MCP tools for search, analysis, context compression, FORGE quality gates, knowledge management, code manipulation, execution, web access, brainstorming, presentation, and developer utilities.
1722
+
1723
+ ## When to Use
1724
+
1725
+ - You need long-term memory across coding sessions
1726
+ - You want to search a codebase semantically (by meaning, not just keywords)
1727
+ - You need to compress large contexts to focus on what matters
1728
+ - You want structured output from build tools (tsc, vitest, biome, git)
1729
+ - You need to plan which files to read for a task
1730
+ - You want to safely explore refactors in isolated lanes
1731
+ - You need to rename symbols, apply codemods, or run code transformations
1732
+ - You want to fetch and read web pages or search the web
1733
+ - You need to make HTTP requests, test APIs, or debug endpoints
1734
+ - You want to test regex patterns, encode/decode data, or validate JSON schemas
1735
+ - You need code complexity metrics or a git changelog
1736
+ - You want to save and reuse code snippets across sessions
1737
+
1738
+ ## Skills Reference
1739
+
1740
+ | Context | Skill | Load when |
1741
+ |---------|-------|----------|
1742
+ | Repository access recovery | \`repo-access\` | When encountering git auth failures, accessing private/enterprise repos, or when \`web_fetch\`/\`http\` returns auth errors on repository URLs. |
1743
+
1744
+ ## Architecture
1745
+
1746
+ 10-package monorepo published as a single npm package:
1747
+
1748
+ \`\`\`
1749
+ core → store → embeddings → chunker → indexer → analyzers → tools → server → cli → tui
1750
+ \`\`\`
1751
+
1752
+ - **MCP server**: 82 tools + 2 resources (via \`@modelcontextprotocol/sdk\`)
1753
+ - **CLI**: 45 commands (thin dispatcher + 10 command groups)
1754
+ - **Search**: Hybrid vector + keyword + RRF fusion
1755
+ - **Embeddings**: ONNX local (mxbai-embed-large-v1, 1024 dimensions)
1756
+ - **Vector store**: LanceDB (embedded, zero infrastructure)
1757
+ - **Chunking**: Tree-sitter AST (TS/JS/Python/Go/Rust/Java) + regex fallback
1758
+ - **TUI**: Ink/React dashboard for human monitoring (search, status, curated, activity log)
1759
+
1760
+ ## Session Protocol (MANDATORY)
1761
+
1762
+ ### Start (do ALL)
1763
+ \`\`\`
1764
+ flow({ action: 'status' }) # Check/resume active flow FIRST
1765
+ # If flow active → flow({ action: 'read', step }) → follow step instructions
1766
+ status({}) # Check AI Kit health + onboard state
1767
+ # If onboard not run → onboard({ path: "." }) # First-time codebase analysis
1768
+ flow({ action: 'list' }) # See available flows
1769
+ # Select flow based on task → flow({ action: 'start', name: "<name>", topic: "<task>" }) # Start — creates .flows/{topic}/
1770
+ knowledge({ action: "list" }) # See stored knowledge
1771
+ search({ query: "SESSION CHECKPOINT", origin: "curated" }) # Resume prior work
1772
+ \`\`\`
1773
+
1774
+ ### During Session
1775
+ \`\`\`
1776
+ search → scope_map → symbol → trace (orient)
1777
+ check → test_run (validate changes)
1778
+ knowledge({ action: "remember", ... }) (capture insights)
1779
+ \`\`\`
1780
+
1781
+ ### End of Session
1782
+ \`\`\`
1783
+ session_digest({ persist: true }) # Auto-capture session activity
1784
+ knowledge({ action: "remember", title: "Session checkpoint: <topic>", content: "<what was done, decisions made, next steps>", category: "conventions" })
1785
+ \`\`\`
1786
+
1787
+ ## Tool Catalog
1788
+
1789
+ ### Search & Discovery (8)
1790
+ | Tool | CLI | Purpose |
1791
+ |------|-----|---------|
1792
+ | \`search\` | \`aikit search\` | Hybrid/semantic/keyword search with \`search_mode\` param |
1793
+ | \`find\` | \`aikit find\` | Federated search: vector + FTS + glob + regex in one call. Use \`mode: 'examples'\` to find usage examples. |
1794
+ | \`symbol\` | \`aikit symbol\` | Resolve symbol definition, imports, and references |
1795
+ | \`lookup\` | \`aikit lookup\` | Full-file retrieval by path or record ID |
1796
+ | \`scope_map\` | \`aikit scope-map\` | Task-scoped reading plan with token estimates |
1797
+ | \`trace\` | \`aikit trace\` | Forward/backward flow tracing through call chains |
1798
+ | \`dead_symbols\` | \`aikit dead-symbols\` | Find exported symbols never imported — separates source (actionable) from docs (informational). Accepts \`path\` to scope the search. |
1799
+ | \`file_summary\` | \`aikit summarize\` | Structural overview of a file (exports, imports, functions) |
1800
+
1801
+ ### Code Analysis (2)
1802
+ | Tool | CLI | Purpose |
1803
+ |------|-----|---------|
1804
+ | \`analyze\` | \`aikit analyze <aspect>\` | Unified analyzer for structure, dependencies, symbols, patterns, entry_points, and diagram aspects |
1805
+ | \`blast_radius\` | \`aikit analyze blast-radius\` | Change impact analysis |
1806
+
1807
+ ### Context Management (6)
1808
+ | Tool | CLI | Purpose |
1809
+ |------|-----|---------|
1810
+ | \`compact\` | \`aikit compact\` | Compress text to relevant sections using embeddings (no LLM). Accepts \`path\` for server-side file read. |
1811
+ | \`workset\` | \`aikit workset\` | Named file set management (save/load/add/remove) |
1812
+ | \`stash\` | \`aikit stash\` | Named key-value store for session data |
1813
+ | \`checkpoint\` | \`aikit checkpoint\` | Save/restore session checkpoints |
1814
+ | \`restore\` | \`aikit restore\` | Restore a previously saved checkpoint |
1815
+ | \`parse_output\` | \`aikit parse-output\` | Parse tsc/vitest/biome/git output → structured JSON |
1816
+
1817
+ ### Code Manipulation (4)
1818
+ | Tool | CLI | Purpose |
1819
+ |------|-----|---------|
1820
+ | \`rename\` | \`aikit rename\` | Smart whole-word symbol rename across files (dry-run supported) |
1821
+ | \`codemod\` | \`aikit codemod\` | Regex-based code transformations with rules (dry-run supported) |
1822
+ | \`diff_parse\` | \`aikit diff\` | Parse unified diff → structured changes |
1823
+ | \`data_transform\` | \`aikit transform\` | JQ-like JSON transformations |
1824
+
1825
+ ### Execution & Validation (4)
1826
+ | Tool | CLI | Purpose |
1827
+ |------|-----|---------|
1828
+ | \`eval\` | \`aikit eval\` | Sandboxed JavaScript/TypeScript execution |
1829
+ | \`check\` | \`aikit check\` | Incremental typecheck + lint. \`detail\` param: efficient (default, minimal), normal (parsed errors), full (includes raw) |
1830
+ | \`test_run\` | \`aikit test\` | Run tests with structured pass/fail results |
1831
+ | \`audit\` | \`aikit audit\` | Unified project audit: structure, deps, patterns, health, dead symbols, check, entry points → synthesized report with score and recommendations. 6 round-trips → 1. |
1832
+
1833
+ ### Knowledge Management (2)
1834
+ | Tool | CLI | Purpose |
1835
+ |------|-----|---------|
1836
+ | \`knowledge\` | \`aikit knowledge <action>\` | Unified knowledge tool for remember, read, update, forget, and list actions |
1837
+ | \`produce_knowledge\` | — | Auto-generate knowledge from analysis |
1838
+
1839
+ ### Auto-Knowledge (automatic)
1840
+
1841
+ Tool outputs are automatically analyzed after every call. Useful facts (conventions, test patterns, build commands, errors) are extracted and stored as curated entries. Quality gate (score >= 0.3), deduplication, TTL for transient facts, max 50/session.
1842
+
1843
+ Search auto-knowledge with: \`search({ query: "...", origin: "curated" })\` or \`knowledge({ action: "list", category: "conventions" })\`
1844
+
1845
+ ### Verified Lanes (1 tool, 6 actions)
1846
+ | Tool | CLI | Purpose |
1847
+ |------|-----|---------|
1848
+ | \`lane\` | \`aikit lane\` | Manage isolated file copies for parallel exploration |
1849
+
1850
+ Lane actions: \`create\` (copy files to lane), \`list\`, \`status\` (modified/added/deleted), \`diff\` (line-level diff), \`merge\` (apply back to originals), \`discard\`.
1851
+
1852
+ ### Git & Environment (4)
1853
+ | Tool | CLI | Purpose |
1854
+ |------|-----|---------|
1855
+ | \`git_context\` | \`aikit git\` | Branch, status, recent commits |
1856
+ | \`process\` | \`aikit proc\` | Process supervisor (start/stop/logs) |
1857
+ | \`watch\` | \`aikit watch\` | Filesystem watcher |
1858
+ | \`delegate\` | \`aikit delegate\` | Delegate subtask to local Ollama model |
1859
+
1860
+ ### Web & Network (3)
1861
+ | Tool | CLI | Purpose |
1862
+ |------|-----|---------|
1863
+ | \`web_fetch\` | — | Fetch web page → markdown/raw/links/outline for LLM consumption |
1864
+ | \`web_search\` | — | Search the web via DuckDuckGo (no API key needed) |
1865
+ | \`http\` | — | Make HTTP requests for API testing/debugging |
1866
+
1867
+ ### Developer Utilities (7)
1868
+ | Tool | CLI | Purpose |
1869
+ |------|-----|---------|
1870
+ | \`regex_test\` | — | Test regex patterns with match/replace/split modes |
1871
+ | \`encode\` | — | Base64, URL, SHA-256, MD5, hex encode/decode, JWT decode |
1872
+ | \`measure\` | — | Code complexity metrics (cyclomatic, cognitive complexity, lines, functions) |
1873
+ | \`changelog\` | — | Generate changelog from git history (conventional commits) |
1874
+ | \`schema_validate\` | — | Validate JSON data against JSON Schema |
1875
+ | \`env\` | — | System and runtime environment info (sensitive values redacted) |
1876
+ | \`time\` | — | Date parsing, timezone conversion, duration math |
1877
+
1878
+ ### FORGE Quality Gates (5)
1879
+ | Tool | CLI | Purpose |
1880
+ |------|-----|---------|
1881
+ | \`forge_ground\` | — | Full Ground phase: classify tier, scope map, unknowns, constraints |
1882
+ | \`forge_classify\` | — | Quick tier classification (Floor/Standard/Critical) |
1883
+ | \`evidence_map\` | — | CRUD + Gate evaluation for verified/assumed/unknown claims. Safety gate tags (\`provenance\`/\`commitment\`/\`coverage\`) enable mandatory pre-YIELD checks |
1884
+ | \`stratum_card\` | — | Generate T1/T2 compressed context cards from files (10-100x token reduction) |
1885
+ | \`digest\` | — | Compress N text sources into token-budgeted summary |
1886
+
1887
+ ### System (9)
1888
+ | Tool | CLI | Purpose |
1889
+ |------|-----|---------|
1890
+ | \`config\` | \`aikit config\` | View or update project configuration (kb.config.json) |
1891
+ | \`status\` | \`aikit status\` | Index statistics |
1892
+ | \`reindex\` | \`aikit reindex\` | Rebuild index |
1893
+ | \`health\` | \`aikit health\` | Project health checks (package.json, tsconfig, lockfile, circular deps) |
1894
+ | \`guide\` | \`aikit guide\` | Tool discovery — given a goal, recommends tools and workflow order |
1895
+ | \`onboard\` | \`aikit onboard\` | Full codebase onboarding in one call (structure + deps + patterns + knowledge) |
1896
+ | \`graph\` | \`aikit graph\` | Query the auto-populated knowledge graph (modules, symbols, imports) |
1897
+ | \`queue\` | \`aikit queue\` | Task queue for sequential agent operations (create/push/next/done/fail) |
1898
+ | \`replay\` | \`aikit replay\` | View or clear the audit trail of tool invocations (action: list/clear) |
1899
+
1900
+ ### Flows (1)
1901
+ | Tool | CLI | Purpose |
1902
+ |------|-----|---------|
1903
+ | \`flow\` | \`aikit flow <action>\` | Manage flows — list, inspect, start, navigate steps, read instructions, inspect runs, and add/remove/update custom flows. |
1904
+
1905
+ ### Presentation (1)
1906
+ | Tool | CLI | Purpose |
1907
+ |------|-----|---------|
1908
+ | \`present\` | — | Rich dashboards, charts, tables, timelines. Use \`format: "browser"\` then \`openBrowserPage\` to display. **In CLI mode (no VS Code chat), always use \`format: "browser"\`** — \`html\` UIResource is invisible in terminal. |
1909
+
1910
+ ### Meta-Tools — Tool Discovery (3)
1911
+ | Tool | CLI | Purpose |
1912
+ |------|-----|---------|
1913
+ | \`list_tools\` | — | List all active AI Kit tools with names, titles, and categories. Accepts optional \`category\` filter. Use for initial tool discovery. |
1914
+ | \`describe_tool\` | — | Get detailed metadata for a specific tool (title, categories, annotations). Use after \`list_tools\` to understand a tool before calling it. |
1915
+ | \`search_tools\` | — | Search active tools by keyword across names, titles, and categories. Use when you know what you need but not the tool name. |
1916
+
1917
+ ### Session Management (1)
1918
+ | Tool | CLI | Purpose |
1919
+ |------|-----|---------|
1920
+ | \`session_digest\` | — | Generate a compressed digest of session activity (replay log, stash, checkpoints). Options: \`scope\` (tools/stash/all), \`since\`, \`last\`, \`focus\`, \`mode\` (deterministic/sampling), \`tokenBudget\`, \`persist\`. Use at session end for handoff or mid-session to review what happened. |
1921
+
1922
+ ## Flow System
1923
+
1924
+ Flows are multi-step guided workflows that structure complex tasks. Each step has a skill file with detailed instructions, required artifacts, and agent assignments.
1925
+
1926
+ ### Built-in Flows
1927
+
1928
+ | Flow | Steps | Use When |
1929
+ |------|-------|----------|
1930
+ | \`aikit:basic\` | assess → implement → verify | Bug fixes, config changes, small features |
1931
+ | \`aikit:advanced\` | spec → plan → task → execute → verify | New modules, cross-service changes, architectural work |
1932
+
1933
+ ### Flow Lifecycle
1934
+
1935
+ \`\`\`text
1936
+ flow({ action: 'list' }) # See available flows
1937
+ flow({ action: 'info', name: 'aikit:basic' }) # View steps, skills, agents
1938
+ flow({ action: 'start', name: 'aikit:basic', topic: 'Fix login bug' }) # Start — creates .flows/fix-login-bug/
1939
+ flow({ action: 'read' }) # Read current step's instructions ({{artifacts_path}} resolved)
1940
+ # ... do the work described in the instruction ...
1941
+ flow({ action: 'step', advance: 'next' }) # Advance to next step
1942
+ flow({ action: 'step', advance: 'skip' }) # Skip current step
1943
+ flow({ action: 'step', advance: 'redo' }) # Redo current step
1944
+ flow({ action: 'status' }) # Check progress (includes slug, runDir, artifactsPath, phase, isEpilogue)
1945
+ flow({ action: 'reset' }) # Abandon active flow
1946
+ flow({ action: 'runs' }) # List all runs (current + past)
1947
+ # Epilogue steps (mandatory, injected after every flow):
1948
+ # After last flow step → _docs-sync epilogue runs automatically
1949
+ # flow({ action: 'status' }) shows phase: 'after', isEpilogue: true during epilogue
1950
+ \`\`\`
1951
+
1952
+ Custom flow lifecycle management:
1953
+
1954
+ \`\`\`text
1955
+ flow({ action: 'add', source: '.github/flows/my-flow' })
1956
+ flow({ action: 'update', name: 'my-flow' })
1957
+ flow({ action: 'remove', name: 'my-flow' })
1958
+ \`\`\`
1959
+
1960
+ ## CRITICAL: Use AI Kit Tools Instead of Native IDE Tools
1961
+
1962
+ AI Kit tools provide **10x richer output** than native IDE tools — with AST-analyzed call graphs, scope context, import classification, and cognitive complexity. **You MUST use AI Kit tools instead of native read/search tools.**
1963
+
1964
+ ### ⛔ PROHIBITED: Native File Reading
1965
+
1966
+ **\`read_file\` / \`read_file_raw\` MUST NOT be used to understand code.** They waste tokens and miss structural information.
1967
+
1968
+ The **ONLY** acceptable use of \`read_file\`: getting exact lines immediately before an edit (to verify the \`old_str\` for replacement). Even then, use \`file_summary\` first to identify which lines to read.
1969
+
1970
+ ### Tool Replacement Table
1971
+
1972
+ | ❌ NEVER do this | ✅ Use AI Kit Tool | Why |
1973
+ |---|---|---|
1974
+ | \`read_file\` (full file) | \`file_summary\` | Exports, imports, call edges — **10x fewer tokens** |
1975
+ | \`read_file\` (specific section) | \`compact({ path, query })\` | Server-side read + extract — **5-20x reduction** |
1976
+ | \`grep_search\` / \`textSearch\` | \`search\` | Semantic + keyword hybrid across all indexed content |
1977
+ | \`grep_search\` for a symbol | \`symbol\` | Definition + references **with scope context** |
1978
+ | Multiple \`read_file\` calls | \`digest\` | Compresses multiple sources into token-budgeted summary |
1979
+ | \`listDirectory\` + \`read_file\` | \`scope_map\` | Identifies relevant files for a task automatically |
1980
+ | Manual code tracing | \`trace\` | AST call-graph traversal with scope context |
1981
+ | Line counting / \`wc\` | \`measure\` | Lines, complexity, **cognitive complexity**, functions |
1982
+ | Grep for unused exports | \`dead_symbols\` | AST-powered export detection with regex fallback |
1983
+ | Repeated file reads | \`stratum_card\` | Reusable compressed context — **10-100x reduction** |
1984
+ | \`fetch_webpage\` | \`web_fetch\` | Readability extract + token budget — richer output |
1985
+ | Web research / browsing | \`web_search\` | Structured web results without browser — **unique to KB** |
1986
+
1987
+ ### Decision Tree — How to Read Code
1988
+
1989
+ \`\`\`
1990
+ Need to understand a file?
1991
+ ├─ Just structure? → file_summary (exports, imports, call edges — ~50 tokens)
1992
+ ├─ Specific section? → compact({ path, query }) — 5-20x reduction
1993
+ ├─ Multiple files? → digest (multi-source compression — token-budgeted)
1994
+ ├─ Repeated reference? → stratum_card (T1/T2 card — 10-100x reduction)
1995
+ ├─ Need exact lines to EDIT? → read_file (the ONLY acceptable use)
1996
+ └─ "I want to read the whole file" → ⛔ STOP. Use file_summary or compact instead.
1997
+ \`\`\`
1998
+
1999
+ ### Decision Tree — Need Structural Relationships?
2000
+
2001
+ When vector search and file reads don't answer the question (e.g. "who imports this?",
2002
+ "what does this depend on?", "how are these files connected?"), use \`graph\`:
2003
+
2004
+ \`\`\`
2005
+ Need to understand relationships between code?
2006
+ ├─ Who imports / calls this? → graph({action:'find_nodes', name_pattern}) → graph({action:'neighbors', node_id, direction:'incoming'})
2007
+ ├─ What does this depend on? → graph({action:'neighbors', node_id, direction:'outgoing'})
2008
+ ├─ Full context for a symbol? → graph({action:'symbol360', name})
2009
+ ├─ Related files within N hops? → graph({action:'traverse', node_id, max_depth:2})
2010
+ ├─ Layer/module isolation check? → graph({action:'depth_traverse', node_id, max_depth:3})
2011
+ └─ Graph size/health? → graph({action:'stats'})
2012
+ \`\`\`
2013
+
2014
+ **Use this BEFORE** reaching for \`analyze({ aspect: "dependencies", ... })\` (slower, less precise) or manually
2015
+ tracing via \`symbol\` + \`trace\` chains. The graph is auto-populated during indexing.
2016
+
2017
+ ### What AI Kit Tools Return (AST-Enhanced)
2018
+
2019
+ These tools use Tree-sitter WASM to analyze source code at the AST level, providing structured data that raw file reads cannot:
2020
+
2021
+ | Tool | Rich Output |
2022
+ |------|-------------|
2023
+ | \`file_summary\` | Imports classified as **external vs internal** (\`isExternal\` flag). **Call edges** between functions (e.g., \`handleRequest() → validateInput() @ line 42\`). \`exported\` flag on interfaces and types. Import count breakdown. |
2024
+ | \`symbol\` | References include **scope** — which function/class/method contains each usage (e.g., \`referenced in processOrder() at auth-service.ts:55\`). |
2025
+ | \`trace\` | **Call-graph edges** discovered via AST syntax tree, not text matching. Supports forward (who does X call?) and backward (who calls X?) tracing. Scope context on each node. |
2026
+ | \`measure\` | **Cognitive complexity** — weights nesting depth (nested \`if\` inside \`for\` inside \`try\` scores higher). More useful than cyclomatic complexity for understanding code difficulty. |
2027
+ | \`dead_symbols\` | **AST export enumeration** — catches \`export default\`, barrel re-exports (\`export { x } from\`), \`export =\`, and \`export type\`. Regex fallback for non-AST-supported languages. |
2028
+
2029
+ ### Example: \`file_summary\` Output
2030
+
2031
+ \`\`\`
2032
+ src/auth-service.ts
2033
+ Language: typescript | Lines: 180 | Estimated tokens: ~1400
2034
+
2035
+ Imports (6): 3 external, 3 internal
2036
+ - import { hash } from 'bcrypt' [external]
2037
+ - import { UserRepo } from './user-repo' [internal]
2038
+
2039
+ Functions (4):
2040
+ - authenticate @ line 22 [exported]
2041
+ - validateToken @ line 55 [exported]
2042
+ - hashPassword @ line 90
2043
+ - generateJwt @ line 110
2044
+
2045
+ Call edges (12 intra-file):
2046
+ - authenticate() → hashPassword() @ line 35
2047
+ - authenticate() → generateJwt() @ line 42
2048
+ - validateToken() → UserRepo.findById() @ line 68
2049
+
2050
+ Interfaces (2):
2051
+ - AuthResult @ line 8 [exported]
2052
+ - TokenPayload @ line 14
2053
+ \`\`\`
2054
+
2055
+ Compare: \`read_file\` would cost ~1400 tokens for raw text. \`file_summary\` gives structured data in ~120 tokens — **12x reduction** with richer information.
2056
+
2057
+ ## Token Efficiency
2058
+
2059
+ \`config.tokenBudget\` controls output verbosity globally:
2060
+
2061
+ | Level | Output | Compression | Context Strategy |
2062
+ |-------|--------|-------------|------------------|
2063
+ | \`efficient\` (default) | Minimal output, score + top issues only | threshold 2000, budget 1000 | \`stratum_card(T1)\` |
2064
+ | \`normal\` | Standard output with parsed errors/pattern names | threshold 4000, budget 2000 | \`compact()\` |
2065
+ | \`full\` | Maximum detail with raw output/full tables | No compression | \`digest()\` |
2066
+
2067
+ Set via: \`config({ action: 'update', updates: { tokenBudget: 'normal' } })\`
2068
+
2069
+ Tools with \`detail\` param inherit from \`config.tokenBudget\` when not explicitly set.
2070
+ Compression middleware applies to ALL tool responses automatically.
2071
+
2072
+ ## Search Strategy
2073
+
2074
+ 1. **Start broad**: \`search({ query: "topic", search_mode: "hybrid" })\`
2075
+ 2. **Narrow**: Add \`content_type\`, \`origin\`, or \`category\` filters
2076
+ 3. **Exact match**: Use \`search_mode: "keyword"\` for identifiers
2077
+ 4. **Federated**: Use \`find\` to combine vector + glob + regex
2078
+
2079
+ ## Workflow Chains
2080
+
2081
+ ### Codebase Onboarding
2082
+ \`\`\`
2083
+ analyze({ aspect: "structure", path: "src/" })
2084
+ → analyze({ aspect: "dependencies", path: "src/" })
2085
+ → analyze({ aspect: "entry_points", path: "src/" })
2086
+ → produce_knowledge({ path: "src/" })
2087
+ → knowledge({ action: "remember", title: "Codebase onboarding complete", ... })
2088
+ \`\`\`
2089
+
2090
+ ### Planning a Task
2091
+ \`\`\`
2092
+ scope_map({ task: "implement user auth" })
2093
+ → compact({ path: "src/auth.ts", query: "auth flow" })
2094
+ → workset({ action: "save", name: "auth-task", files: [...] })
2095
+ \`\`\`
2096
+
2097
+ ### Bug Investigation
2098
+ \`\`\`
2099
+ parse_output({ output: <error> }) → symbol({ name: "failingFn" })
2100
+ → trace({ symbol: "failingFn", direction: "backward" })
2101
+ → blast_radius({ changed_files: ["suspect.ts"] })
2102
+ → eval({ code: "hypothesis test" }) → check({ files: ["suspect.ts"] })
2103
+ \`\`\`
2104
+
2105
+ ### Multi-Task Orchestration (DAG Queue)
2106
+ \`\`\`
2107
+ queue({ action: "create", name: "my-tasks" })
2108
+ → queue({ action: "push", name: "my-tasks", title: "Task 1", data: { deps: [] } })
2109
+ → queue({ action: "push", name: "my-tasks", title: "Task 2", data: { deps: ["task-1-id"] } })
2110
+ → queue({ action: "next", name: "my-tasks" }) # Gets next ready task
2111
+ → [do work]
2112
+ → queue({ action: "done", name: "my-tasks", id: "<id>" })
2113
+ \`\`\`
2114
+
2115
+ ### Safe Refactor with Lanes
2116
+ \`\`\`
2117
+ scope_map({ task: "rename UserService" })
2118
+ → lane({ action: "create", name: "refactor", files: [...] })
2119
+ → [make changes in lane files]
2120
+ → lane({ action: "diff", name: "refactor" })
2121
+ → check({}) → test_run({})
2122
+ → lane({ action: "merge", name: "refactor" })
2123
+ \`\`\`
2124
+
2125
+ ### Lane — isolated read-only exploration
2126
+
2127
+ \`lane({ action:'create', name })\` creates an isolated copy of the workspace. Use to try approach A vs B WITHOUT touching canonical source. Other actions: \`list\`, \`diff\`, \`delete\`. Compare with \`lane({ action:'diff', names:['a','b'] })\`. Do NOT use \`lane\` for actual refactors — use \`checkpoint\` instead (\`checkpoint\` = reversible on canonical source; \`lane\` = isolated copies for comparison).
2128
+
2129
+ ### After Making Changes
2130
+ \`\`\`
2131
+ blast_radius({ changed_files: ["src/auth.ts"] })
2132
+ → check({}) → test_run({ grep: "auth" })
2133
+ → reindex()
2134
+ → knowledge({ action: "remember", title: "Implemented auth", content: "..." })
2135
+ \`\`\`
2136
+
2137
+ ### Pre-Commit Validation
2138
+ \`\`\`
2139
+ git_context({ diff: true })
2140
+ → diff_parse({ diff: <staged diff> })
2141
+ → blast_radius({ changed_files: [...] })
2142
+ → check({}) → test_run({})
2143
+ \`\`\`
2144
+
2145
+ ---
2146
+
2147
+ ## Persistent Memory
2148
+
2149
+ | Action | Tool | Category |
2150
+ |--------|------|----------|
2151
+ | Store | \`knowledge({ action: "remember", title, content, category })\` | conventions, decisions, patterns, context, session |
2152
+ | Search | \`search({ query, origin: "curated" })\` | — |
2153
+ | Browse | \`knowledge({ action: "list" })\` or \`knowledge({ action: "list", category })\` | — |
2154
+ | Read | \`knowledge({ action: "read", id })\` | — |
2155
+ | Update | \`knowledge({ action: "update", id, content })\` | — |
2156
+ | Remove | \`knowledge({ action: "forget", id })\` | — |
2157
+
2158
+ **Session checkpoint** (end of session): \`knowledge({ action: "remember", title: "Session checkpoint: <topic>", content: "Done/Decisions/Next/Blockers", category: "session" })\`
2159
+
2160
+ ## CLI Quick Reference
2161
+
2162
+ \`\`\`bash
2163
+ aikit init # Scaffold AI Kit in current directory
2164
+ aikit init --force # Overwrite all scaffold/skill files
2165
+ aikit init --guide # JSON report of stale files for LLM-driven updates
2166
+ aikit serve # Start MCP server (stdio or HTTP)
2167
+ aikit search <q> # Hybrid search
2168
+ aikit find <q> # Federated search
2169
+ aikit symbol <name> # Resolve symbol
2170
+ aikit scope-map <t> # Task reading plan
2171
+ aikit compact <q> # Context compression (--path file or stdin)
2172
+ aikit check # Typecheck + lint (--detail efficient|normal|full)
2173
+ aikit test # Run tests
2174
+ aikit rename <old> <new> <path> # Rename symbol
2175
+ aikit lane create <name> --files f1,f2 # Create lane
2176
+ aikit lane diff <name> # View lane changes
2177
+ aikit lane merge <name> # Merge lane back
2178
+ aikit status # Index stats
2179
+ aikit reindex # Rebuild index
2180
+ \`\`\`
2181
+
2182
+ ## Configuration
2183
+
2184
+ \`kb.config.json\` in project root:
2185
+ \`\`\`json
2186
+ {
2187
+ "sources": [{ "path": ".", "excludePatterns": ["node_modules/**", "**/node_modules/**", "dist/**", "coverage/**", ".aikit-data/**"] }],
2188
+ "indexing": { "chunkSize": 1500, "chunkOverlap": 200, "minChunkSize": 100, "concurrency": 5 },
2189
+ "embedding": { "model": "mixedbread-ai/mxbai-embed-large-v1", "dimensions": 1024 },
2190
+ "store": { "backend": "lancedb", "path": ".aikit-data" },
2191
+ "curated": { "path": "curated", "adapter": "filesystem" }
2192
+ }
2193
+ \`\`\`
2194
+
2195
+ ## Tool Profiles
2196
+
2197
+ Tool profiles control which subset of the 82 tools are active. Profiles reduce token overhead by exposing only relevant tools for a given task.
2198
+
2199
+ ### Built-in Profiles
2200
+
2201
+ | Profile | Description | Use When |
2202
+ |---------|-------------|----------|
2203
+ | \`full\` | All tools enabled (default) | General development, orchestration |
2204
+ | \`safe\` | Read-only tools — no file/state modifications | Code review, analysis, research |
2205
+ | \`research\` | Search, analysis, knowledge, web access | Investigation, documentation |
2206
+ | \`minimal\` | Essential tools only — search, check, test | Simple tasks, low-token budgets |
2207
+ | \`discovery\` | Full toolset + meta-tools for guided exploration | New users, onboarding, tool learning |
2208
+
2209
+ ### Activating a Profile
2210
+
2211
+ Set \`toolProfile\` in \`kb.config.json\`:
2212
+
2213
+ \`\`\`json
2214
+ {
2215
+ "toolProfile": "research"
2216
+ }
2217
+ \`\`\`
2218
+
2219
+ Base tools (\`status\`, \`config\`, \`guide\`, \`health\`) are **always available** regardless of profile.
2220
+
2221
+ ## Development (Self-Dogfooding)
2222
+
2223
+ When developing @vpxa/aikit itself: always \`pnpm build\` before using CLI/server (runs from \`dist/\`), always \`reindex\` after structural code changes, and don't run CLI and HTTP server simultaneously (LanceDB is single-process).
2224
+
2225
+ ---
2226
+
2227
+ ## Flows
2228
+
2229
+ Flows are structured multi-step workflows that guide agents through complex tasks. They are the **primary workflow system** — use them instead of ad-hoc planning when a matching flow exists.
2230
+
2231
+ ### Flow Tools
2232
+
2233
+ | Tool | Purpose |
2234
+ |------|---------|
2235
+ | \`flow\` | Manage flow state and lifecycle actions — status, list, info, start, step, read, reset, add, update, and remove. Use the \`action\` parameter. |
2236
+
2237
+ ### Flow Selection
2238
+
2239
+ | Task Type | Flow | Why |
2240
+ |-----------|------|-----|
2241
+ | Bug fix, config change, small refactor | \`aikit:basic\` | Known scope, low risk |
2242
+ | New feature in existing module | \`aikit:basic\` | Clear boundaries |
2243
+ | New system/service/module | \`aikit:advanced\` | Needs spec + planning |
2244
+ | Cross-service changes | \`aikit:advanced\` | Multiple boundaries |
2245
+ | Architectural change | \`aikit:advanced\` | High impact |
2246
+ | Unclear scope or exploratory | No flow | Use agent's native workflow |
2247
+
2248
+ ### Flow Lifecycle
2249
+
2250
+ 1. **Start**: \`flow({ action: 'list' })\` → choose flow → \`flow({ action: 'start', name: "<name>", topic: "<task>" })\`
2251
+ 2. **Each step**: \`flow({ action: 'read', step: "<name>" })\` → follow step instructions → complete work
2252
+ 3. **Advance**: \`flow({ action: 'step', advance: 'next' })\` → repeat from step 2
2253
+ 4. **Epilogue**: After last flow step, mandatory epilogue steps run (e.g., \`_docs-sync\` updates \`docs/\`)
2254
+ 5. **Resume**: \`flow({ action: 'status' })\` → if active, \`flow({ action: 'read' })\` for current step → continue
2255
+ 6. **Reset**: \`flow({ action: 'reset' })\` if you need to start over
2256
+
2257
+ ---
2258
+
2259
+ ## Reference Documentation
2260
+
2261
+ For detailed patterns on specific topics, load these reference files:
2262
+
2263
+ | Topic | File | When to load |
2264
+ |-------|------|-------------|
2265
+ | Multi-task orchestration | \`references/coordination.md\` | Queue, DAG, lanes, worksets, stash, checkpoints |
2266
+ | Quality gates (FORGE) | \`references/forge-protocol.md\` | Complex tasks, evidence maps, tier classification |
2267
+ | Search & relationships | \`references/search-patterns.md\` | Finding code, tracing data flow, graph traversal |
2268
+ `},{file:`references/coordination.md`,content:`# Coordination & Multi-Task Orchestration
1708
2269
 
1709
2270
  Patterns for managing multiple tasks, parallel exploration, and session state.
1710
2271
 
@@ -4943,7 +5504,7 @@ type: explanation
4943
5504
 
4944
5505
  ---
4945
5506
 
4946
- *Templates follow the Diátaxis documentation framework (CC-BY-SA 4.0, Daniele Procida).*`},{file:`references/flow-artifacts-guide.md`,content:'# Flow Artifacts Guide\n\n## What Are Flow Artifacts\n\nFlows produce structured markdown artifacts in `{{artifacts_path}}/`. These files capture requirements, decisions, plan shape, implementation progress, and verification results for the completed flow.\n\nUse artifacts to document the why behind changes. Code diffs still matter, but artifacts usually contain the rationale, constraints, risks, and review findings that should shape durable documentation.\n\n## How to Discover Artifacts\n\n```text\nflow_status() # Get artifactsPath\nfind({ pattern: "*.md", path: "<artifactsPath>" }) # Discover artifact files\ndigest({ sources: [ # Compress into working context\n { path: "<found-artifact-1>" },\n { path: "<found-artifact-2>" },\n ...\n]})\n```\n\nRead every artifact `find()` returns. Different flows produce different files — do not assume specific filenames exist.\n\n## Artifact Catalog\n\n| Artifact | Flow | Contains |\n|---|---|---|\n| `design-decisions.md` | `aikit:basic`, `aikit:advanced` | FORGE tier, approach, key decisions, constraints, and risks |\n| `assessment.md` | `aikit:basic` | Goal, affected files, approach steps, risks, and open questions |\n| `spec.md` | `aikit:advanced` | Requirements, acceptance criteria, and scope boundaries |\n| `plan.md` | `aikit:advanced` | Phased implementation plan and architecture decisions |\n| `tasks.md` | `aikit:advanced` | Atomic task list, dependencies, and agent assignments |\n| `progress.md` | `aikit:basic`, `aikit:advanced` | Changes made, tests, deviations, and validation results |\n| `verify-report.md` | `aikit:basic`, `aikit:advanced` | Verdict, quality gates, review findings, security, and recommendation |\n\n## Artifact-to-Documentation Mapping\n\n| Artifact | Contains | Documentation Target | Action |\n|---|---|---|---|\n| `design-decisions.md` | FORGE tier, approach, key decisions | `docs/decisions/` | Create or update ADRs via `adr-skill` for each key decision |\n| `design-decisions.md` | Architecture approach, constraints | `docs/architecture/overview.md` | Update the design rationale section |\n| `spec.md` | Requirements, acceptance criteria | `docs/reference/` | Update API or component reference when public surface changed |\n| `plan.md` | Architecture decisions, phase design | `docs/architecture/` | Update architecture docs with structural changes |\n| `tasks.md` | Task breakdown, dependencies | Usually skip | Only document if it reveals new component boundaries |\n| `progress.md` | Files changed, deviations, tests | `docs/guides/testing.md` | Update when testing strategy changed |\n| `progress.md` | Deviations from plan | `docs/decisions/` | Document significant deviations as ADRs |\n| `verify-report.md` | Code review findings, security | `docs/architecture/overview.md` | Update if findings reveal architectural patterns |\n| `verify-report.md` | Security concerns | `docs/guides/` | Create or update security guidance when concerns are material |\n\n## Reading Strategy\n\nRead every artifact `find()` returns. Triage by content type:\n\n| Content Signal | Documentation Value | Action |\n|---|---|---|\n| Decisions, rationale, constraints | High — durable knowledge | Extract into `docs/decisions/` or architecture docs |\n| Requirements, scope, acceptance criteria | High — defines intent | Update reference docs if public surface changed |\n| Review findings, security concerns, quality gates | Medium — surfaces issues | Update architecture or guides if findings are material |\n| Implementation progress, task lists | Low — transient | Document only meaningful deviations from the plan |\n\nSkip artifacts that only repeat completed work with no insights beyond the code diff.\n\n> The catalog and mapping tables above list artifacts from built-in flows (`aikit:basic`, `aikit:advanced`). Custom flows may produce entirely different artifacts — always discover dynamically with `find()` and classify by content, not by filename.\n\n## What Not to Document\n\n| Avoid | Do Instead |\n|---|---|\n| Copying artifact text verbatim into `docs/` | Extract decisions, rationale, constraints, and stable guidance |\n| Documenting every task or progress update | Keep only durable insights that help future readers |\n| Mirroring temporary planning details | Preserve the final reasoning, not the transient workflow chatter |'},{file:`references/project-knowledge-gotchas.md`,content:'# Project Knowledge — Gotchas\n\nCommon pitfalls when documenting project knowledge. Reference this during Phase 2 (Investigate) and Phase 4 (Validate).\n\n## Environment Gotchas\n\n**Monorepos:** Root `package.json` may have no source — check for `workspaces`, `packages/`, or `apps/` directories. Each workspace may have independent dependencies and conventions. Map each sub-package separately.\n\n**Outdated README:** README often describes intended architecture, not the current one. Cross-reference with actual file structure before treating any README claim as fact.\n\n**TypeScript path aliases:** `tsconfig.json` `paths` config means imports like `@/foo` don\'t map directly to the filesystem. Map aliases to real paths before documenting structure.\n\n**Generated/compiled output:** Never document patterns from `dist/`, `build/`, `generated/`, `.next/`, `out/`, or `__pycache__/`. These are artefacts — document source conventions only.\n\n**`.env.example` reveals required config:** Secrets are never committed. Read `.env.example`, `.env.template`, or `.env.sample` to discover required environment variables.\n\n**`devDependencies` ≠ production stack:** Only `dependencies` (or equivalent) runs in production. Document linters, formatters, and test frameworks separately as dev tooling in `stack.md`.\n\n**Test TODOs ≠ production debt:** TODOs inside test directories are coverage gaps, not production technical debt. Separate them in `concerns.md`.\n\n**High-churn files = fragile areas:** Files appearing most in recent `git_context({})` output have the highest modification rate and likely hidden complexity. Always note them in `concerns.md`.\n\n## Anti-Pattern Table\n\n| ❌ Don\'t | ✅ Do instead |\n|---------|--------------|\n| "Uses Clean Architecture with Domain/Data layers" (when no such directories exist) | State only what directory structure actually shows |\n| "This is a Next.js project" (without checking `package.json`) | Check `dependencies` first. State what\'s actually there |\n| Guess the database from a variable name like `dbUrl` | Check manifest for `pg`, `mysql2`, `mongoose`, `prisma`, etc. |\n| Document `dist/` or `build/` naming patterns as conventions | Source files only |\n| Assume README describes current architecture | Cross-reference with actual file structure via `analyze({ aspect: "structure", ... })` |\n| Treat test TODOs as production tech debt | Separate coverage gaps from production concerns in `concerns.md` |'},{file:`references/project-knowledge-templates.md`,content:`# Project Knowledge Templates
5507
+ *Templates follow the Diátaxis documentation framework (CC-BY-SA 4.0, Daniele Procida).*`},{file:`references/flow-artifacts-guide.md`,content:'# Flow Artifacts Guide\n\n## What Are Flow Artifacts\n\nFlows produce structured markdown artifacts in `{{artifacts_path}}/`. These files capture requirements, decisions, plan shape, implementation progress, and verification results for the completed flow.\n\nUse artifacts to document the why behind changes. Code diffs still matter, but artifacts usually contain the rationale, constraints, risks, and review findings that should shape durable documentation.\n\n## How to Discover Artifacts\n\n```text\nflow({ action: \'status\' }) # Get artifactsPath\nfind({ pattern: "*.md", path: "<artifactsPath>" }) # Discover artifact files\ndigest({ sources: [ # Compress into working context\n { path: "<found-artifact-1>" },\n { path: "<found-artifact-2>" },\n ...\n]})\n```\n\nRead every artifact `find()` returns. Different flows produce different files — do not assume specific filenames exist.\n\n## Artifact Catalog\n\n| Artifact | Flow | Contains |\n|---|---|---|\n| `design-decisions.md` | `aikit:basic`, `aikit:advanced` | FORGE tier, approach, key decisions, constraints, and risks |\n| `assessment.md` | `aikit:basic` | Goal, affected files, approach steps, risks, and open questions |\n| `spec.md` | `aikit:advanced` | Requirements, acceptance criteria, and scope boundaries |\n| `plan.md` | `aikit:advanced` | Phased implementation plan and architecture decisions |\n| `tasks.md` | `aikit:advanced` | Atomic task list, dependencies, and agent assignments |\n| `progress.md` | `aikit:basic`, `aikit:advanced` | Changes made, tests, deviations, and validation results |\n| `verify-report.md` | `aikit:basic`, `aikit:advanced` | Verdict, quality gates, review findings, security, and recommendation |\n\n## Artifact-to-Documentation Mapping\n\n| Artifact | Contains | Documentation Target | Action |\n|---|---|---|---|\n| `design-decisions.md` | FORGE tier, approach, key decisions | `docs/decisions/` | Create or update ADRs via `adr-skill` for each key decision |\n| `design-decisions.md` | Architecture approach, constraints | `docs/architecture/overview.md` | Update the design rationale section |\n| `spec.md` | Requirements, acceptance criteria | `docs/reference/` | Update API or component reference when public surface changed |\n| `plan.md` | Architecture decisions, phase design | `docs/architecture/` | Update architecture docs with structural changes |\n| `tasks.md` | Task breakdown, dependencies | Usually skip | Only document if it reveals new component boundaries |\n| `progress.md` | Files changed, deviations, tests | `docs/guides/testing.md` | Update when testing strategy changed |\n| `progress.md` | Deviations from plan | `docs/decisions/` | Document significant deviations as ADRs |\n| `verify-report.md` | Code review findings, security | `docs/architecture/overview.md` | Update if findings reveal architectural patterns |\n| `verify-report.md` | Security concerns | `docs/guides/` | Create or update security guidance when concerns are material |\n\n## Reading Strategy\n\nRead every artifact `find()` returns. Triage by content type:\n\n| Content Signal | Documentation Value | Action |\n|---|---|---|\n| Decisions, rationale, constraints | High — durable knowledge | Extract into `docs/decisions/` or architecture docs |\n| Requirements, scope, acceptance criteria | High — defines intent | Update reference docs if public surface changed |\n| Review findings, security concerns, quality gates | Medium — surfaces issues | Update architecture or guides if findings are material |\n| Implementation progress, task lists | Low — transient | Document only meaningful deviations from the plan |\n\nSkip artifacts that only repeat completed work with no insights beyond the code diff.\n\n> The catalog and mapping tables above list artifacts from built-in flows (`aikit:basic`, `aikit:advanced`). Custom flows may produce entirely different artifacts — always discover dynamically with `find()` and classify by content, not by filename.\n\n## What Not to Document\n\n| Avoid | Do Instead |\n|---|---|\n| Copying artifact text verbatim into `docs/` | Extract decisions, rationale, constraints, and stable guidance |\n| Documenting every task or progress update | Keep only durable insights that help future readers |\n| Mirroring temporary planning details | Preserve the final reasoning, not the transient workflow chatter |'},{file:`references/project-knowledge-gotchas.md`,content:'# Project Knowledge — Gotchas\n\nCommon pitfalls when documenting project knowledge. Reference this during Phase 2 (Investigate) and Phase 4 (Validate).\n\n## Environment Gotchas\n\n**Monorepos:** Root `package.json` may have no source — check for `workspaces`, `packages/`, or `apps/` directories. Each workspace may have independent dependencies and conventions. Map each sub-package separately.\n\n**Outdated README:** README often describes intended architecture, not the current one. Cross-reference with actual file structure before treating any README claim as fact.\n\n**TypeScript path aliases:** `tsconfig.json` `paths` config means imports like `@/foo` don\'t map directly to the filesystem. Map aliases to real paths before documenting structure.\n\n**Generated/compiled output:** Never document patterns from `dist/`, `build/`, `generated/`, `.next/`, `out/`, or `__pycache__/`. These are artefacts — document source conventions only.\n\n**`.env.example` reveals required config:** Secrets are never committed. Read `.env.example`, `.env.template`, or `.env.sample` to discover required environment variables.\n\n**`devDependencies` ≠ production stack:** Only `dependencies` (or equivalent) runs in production. Document linters, formatters, and test frameworks separately as dev tooling in `stack.md`.\n\n**Test TODOs ≠ production debt:** TODOs inside test directories are coverage gaps, not production technical debt. Separate them in `concerns.md`.\n\n**High-churn files = fragile areas:** Files appearing most in recent `git_context({})` output have the highest modification rate and likely hidden complexity. Always note them in `concerns.md`.\n\n## Anti-Pattern Table\n\n| ❌ Don\'t | ✅ Do instead |\n|---------|--------------|\n| "Uses Clean Architecture with Domain/Data layers" (when no such directories exist) | State only what directory structure actually shows |\n| "This is a Next.js project" (without checking `package.json`) | Check `dependencies` first. State what\'s actually there |\n| Guess the database from a variable name like `dbUrl` | Check manifest for `pg`, `mysql2`, `mongoose`, `prisma`, etc. |\n| Document `dist/` or `build/` naming patterns as conventions | Source files only |\n| Assume README describes current architecture | Cross-reference with actual file structure via `analyze({ aspect: "structure", ... })` |\n| Treat test TODOs as production tech debt | Separate coverage gaps from production concerns in `concerns.md` |'},{file:`references/project-knowledge-templates.md`,content:`# Project Knowledge Templates
4947
5508
 
4948
5509
  Templates for the seven project knowledge documents in \`docs/architecture/\`. Use these to ensure consistent structure across projects.
4949
5510
 
@@ -5348,7 +5909,7 @@ Flow artifacts are the most valuable documentation input — they capture the *w
5348
5909
 
5349
5910
  **Artifact reading sequence:**
5350
5911
  \`\`\`
5351
- flow_status() # Get artifactsPath
5912
+ flow({ action: 'status' }) # Get artifactsPath
5352
5913
  find({ pattern: "*.md", path: "<artifactsPath>" }) # Discover all artifacts
5353
5914
  digest({ sources: [ # Compress into working context
5354
5915
  { path: "<found-artifact-1>" },
@@ -5701,7 +6262,7 @@ When this skill is loaded during the \`_docs-sync\` epilogue:
5701
6262
  Read all available artifacts from the completed flow before assessing code changes:
5702
6263
 
5703
6264
  \`\`\`
5704
- flow_status() # Get artifactsPath, topic, phase
6265
+ flow({ action: 'status' }) # Get artifactsPath, topic, phase
5705
6266
  find({ pattern: "*.md", path: "<artifactsPath>" }) # Discover all flow artifacts
5706
6267
  digest({ sources: [ # Compress artifacts for context
5707
6268
  { path: "<found-artifact-1>" },
@@ -5714,7 +6275,7 @@ Map each discovered artifact to documentation actions using [references/flow-art
5714
6275
 
5715
6276
  Read every artifact \`find()\` returns — different flows produce different files. Focus on artifacts that contain decisions, requirements, and verification results; skip artifacts that only repeat completed work.
5716
6277
 
5717
- If \`flow_status()\` returns no active flow or no artifacts directory exists, skip this step (source-only mode).
6278
+ If \`flow({ action: 'status' })\` returns no active flow or no artifacts directory exists, skip this step (source-only mode).
5718
6279
 
5719
6280
  ### 1. Assess Changes (tool-driven)
5720
6281