kirograph 0.23.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -5
- package/dist/bin/commands/configure-mcp.js +104 -0
- package/dist/bin/commands/configure-mcp.js.map +7 -0
- package/dist/bin/commands/memory.js +334 -2
- package/dist/bin/commands/memory.js.map +2 -2
- package/dist/bin/commands/uninit.js +12 -5
- package/dist/bin/commands/uninit.js.map +2 -2
- package/dist/bin/commands/wiki.js +307 -0
- package/dist/bin/commands/wiki.js.map +7 -0
- package/dist/bin/installer/common.js +9 -0
- package/dist/bin/installer/common.js.map +2 -2
- package/dist/bin/installer/config-prompt.js +96 -5
- package/dist/bin/installer/config-prompt.js.map +2 -2
- package/dist/bin/installer/hooks.js +182 -88
- package/dist/bin/installer/hooks.js.map +2 -2
- package/dist/bin/installer/index.js +30 -12
- package/dist/bin/installer/index.js.map +2 -2
- package/dist/bin/installer/instructions.js +27 -1
- package/dist/bin/installer/instructions.js.map +2 -2
- package/dist/bin/installer/mcp.js +37 -4
- package/dist/bin/installer/mcp.js.map +2 -2
- package/dist/bin/installer/prompts.js +3 -3
- package/dist/bin/installer/prompts.js.map +2 -2
- package/dist/bin/installer/steering.js +633 -291
- package/dist/bin/installer/steering.js.map +2 -2
- package/dist/bin/installer/targets/index.js.map +1 -1
- package/dist/bin/installer/targets/kiro.js +7 -6
- package/dist/bin/installer/targets/kiro.js.map +2 -2
- package/dist/bin/kirograph.js +3 -1
- package/dist/bin/kirograph.js.map +3 -3
- package/dist/config.js +52 -5
- package/dist/config.js.map +2 -2
- package/dist/db/database.js +11 -0
- package/dist/db/database.js.map +2 -2
- package/dist/db/memory-schema.sql +34 -1
- package/dist/db/wiki-schema.sql +40 -0
- package/dist/mcp/server.js +35 -11
- package/dist/mcp/server.js.map +2 -2
- package/dist/mcp/tool-names.js +112 -1
- package/dist/mcp/tool-names.js.map +2 -2
- package/dist/mcp/tools.js +458 -3
- package/dist/mcp/tools.js.map +2 -2
- package/dist/memory/database.js +131 -7
- package/dist/memory/database.js.map +2 -2
- package/dist/memory/index.js +130 -4
- package/dist/memory/index.js.map +3 -3
- package/dist/memory/types.js.map +1 -1
- package/dist/watchmen/synthesize.js +2 -0
- package/dist/watchmen/synthesize.js.map +2 -2
- package/dist/wiki/database.js +143 -0
- package/dist/wiki/database.js.map +7 -0
- package/dist/wiki/index.js +149 -0
- package/dist/wiki/index.js.map +7 -0
- package/dist/wiki/ingest.js +259 -0
- package/dist/wiki/ingest.js.map +7 -0
- package/dist/wiki/lint.js +93 -0
- package/dist/wiki/lint.js.map +7 -0
- package/dist/wiki/schema.js +148 -0
- package/dist/wiki/schema.js.map +7 -0
- package/dist/wiki/synthesize.js +104 -0
- package/dist/wiki/synthesize.js.map +7 -0
- package/dist/wiki/types.js +17 -0
- package/dist/wiki/types.js.map +7 -0
- package/package.json +6 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/bin/installer/config-prompt.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * KiroGraph Installer \u2014 configuration prompting\n */\n\nimport * as readline from 'readline';\nimport { KiroGraphConfig } from '../../config';\ntype CavemanMode = 'lite' | 'full' | 'ultra';\nimport { ask, askToggle, arrowSelect, printSection, printSeparator, dim, reset, violet } from './prompts';\nexport type ConfigPatch = Pick<KiroGraphConfig, 'enableEmbeddings' | 'useVecIndex' | 'semanticEngine' | 'turboquantMemDocs' | 'turboquantBits' | 'turbovecMemDocs' | 'turbovecBits' | 'typesenseDashboard' | 'qdrantDashboard' | 'extractDocstrings' | 'trackCallSites' | 'enableArchitecture' | 'cavemanMode' | 'shellCompressionLevel' | 'enableMemory' | 'enableWatchmen' | 'watchmenThreshold' | 'watchmenSynthesisMode' | 'watchmenLocalModel' | 'enableDocs' | 'docsContextLimit' | 'enableData' | 'dataContextLimit' | 'enableSecurity' | 'enablePatterns'> & { embeddingModel?: string; embeddingDim?: number };\nexport type SemanticEngine = KiroGraphConfig['semanticEngine'];\n\nexport const DEFAULT_EMBEDDING_MODEL = 'nomic-ai/nomic-embed-text-v1.5';\n\n/** Well-known embedding models with their output dimensions. */\nconst PRESET_MODELS = [\n {\n value: 'nomic-ai/nomic-embed-text-v1.5',\n label: 'nomic-embed-text-v1.5',\n dim: 768,\n description: '768-dim \u00B7 ~130MB \u00B7 Best quality for code search (recommended)',\n },\n {\n value: 'onnx-community/embeddinggemma-300m-ONNX',\n label: 'embeddinggemma-300m',\n dim: 768,\n description: '768-dim \u00B7 ~300MB \u00B7 Google Gemma-based, multilingual, 2048-token context',\n },\n {\n value: 'Xenova/all-MiniLM-L6-v2',\n label: 'all-MiniLM-L6-v2',\n dim: 384,\n description: '384-dim \u00B7 ~23MB \u00B7 Fast and lightweight, lower accuracy',\n },\n {\n value: 'BAAI/bge-base-en-v1.5',\n label: 'bge-base-en-v1.5',\n dim: 768,\n description: '768-dim \u00B7 ~110MB \u00B7 Strong general-purpose alternative to nomic',\n },\n {\n value: '__other__',\n label: 'Other',\n dim: 768,\n description: 'Enter a custom HuggingFace model ID and embedding dimension',\n },\n] as const;\n\nexport async function promptConfigOptions(rl: readline.Interface): Promise<ConfigPatch> {\n // \u2500\u2500 Semantic Search \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDD0D', 'Semantic Search');\n\n const enableEmbeddings = await askToggle(\n rl,\n 'Semantic embeddings (similarity search):',\n 'Enables natural-language code search via vector embeddings. A local model (~130MB) is downloaded on first use.',\n );\n\n const patch: ConfigPatch = { enableEmbeddings, useVecIndex: false, semanticEngine: 'cosine', turboquantMemDocs: false, turboquantBits: 3, turbovecMemDocs: false, turbovecBits: 4, typesenseDashboard: false, qdrantDashboard: false, extractDocstrings: true, trackCallSites: true, enableArchitecture: false, cavemanMode: 'off', shellCompressionLevel: 'normal', enableMemory: false, enableWatchmen: false, watchmenThreshold: 5, watchmenSynthesisMode: 'local', watchmenLocalModel: 'onnx-community/gemma-4-E4B-it-ONNX', enableDocs: false, docsContextLimit: 0, enableData: false, dataContextLimit: 0, enableSecurity: false, enablePatterns: false };\n\n if (enableEmbeddings) {\n // \u2500\u2500 Model selection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const modelChoice = await arrowSelect<string>(\n rl,\n 'Embedding model:',\n PRESET_MODELS.map(m => ({ value: m.value, label: m.label, description: m.description })),\n );\n\n let embeddingModel: string;\n let embeddingDim: number;\n\n if (modelChoice === '__other__') {\n console.log(`\\n ${dim}Enter a HuggingFace model ID in the format org/model-name.${reset}`);\n while (true) {\n const raw = (await ask(rl, ` ${violet}Model identifier:${reset} `)).trim();\n if (raw.includes('/')) { embeddingModel = raw; break; }\n console.log(` Expected a HuggingFace model ID in the format org/model-name (e.g. nomic-ai/nomic-embed-text-v1.5).`);\n }\n console.log(`\\n ${dim}Enter the embedding output dimension for this model (check the model card on HuggingFace).${reset}`);\n while (true) {\n const raw = (await ask(rl, ` ${violet}Embedding dimension (e.g. 768, 384):${reset} `)).trim();\n const n = parseInt(raw, 10);\n if (!isNaN(n) && n > 0) { embeddingDim = n; break; }\n console.log(` Expected a positive integer (e.g. 768, 384, 1536).`);\n }\n } else {\n const preset = PRESET_MODELS.find(m => m.value === modelChoice)!;\n embeddingModel = preset.value;\n embeddingDim = preset.dim;\n }\n\n patch.embeddingModel = embeddingModel;\n patch.embeddingDim = embeddingDim;\n\n // \u2500\u2500 Engine selection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const semanticEngine = await arrowSelect<SemanticEngine>(rl, 'Vector search engine:', [\n { value: 'cosine', label: 'cosine', description: 'In-process cosine similarity. No extra deps. Best for small/medium projects.' },\n { value: 'turboquant', label: 'turboquant', description: 'ANN index, zero native deps. Compresses embeddings 20\u201330\u00D7 (Google TurboQuant). ANN without native binaries \u2014 ideal for CI, ARM, restricted envs. Optional: npm install turboquant-js.' },\n { value: 'turbovec', label: 'turbovec', description: 'ANN search via Rust/SIMD (napi-rs). Same TurboQuant algorithm but NEON on ARM and AVX-512BW on x86 \u2014 faster than turboquant-js at the cost of a one-time Rust build. Requires Rust toolchain. Build: cd native/turbovec-node && npm install && npm run build.' },\n { value: 'sqlite-vec', label: 'sqlite-vec', description: 'ANN index. Sub-linear search. Best for large codebases. Needs: better-sqlite3, sqlite-vec (native).' },\n { value: 'orama', label: 'orama', description: 'Hybrid search (full-text + vector). Pure JS. Needs: @orama/orama, @orama/plugin-data-persistence.' },\n { value: 'pglite', label: 'pglite', description: 'Hybrid search via PostgreSQL + pgvector. Exact results. Pure WASM. Needs: @electric-sql/pglite.' },\n { value: 'lancedb', label: 'lancedb', description: 'ANN search via LanceDB (Apache Lance columnar format). Pure JS. Needs: @lancedb/lancedb.' },\n { value: 'qdrant', label: 'qdrant', description: 'ANN search via Qdrant embedded binary (HNSW index, Cosine). Needs: qdrant-local.' },\n { value: 'typesense', label: 'typesense', description: 'ANN search via Typesense (auto-downloaded binary, HNSW, Cosine). Needs: typesense.' },\n ]);\n patch.semanticEngine = semanticEngine;\n patch.useVecIndex = semanticEngine === 'sqlite-vec';\n\n // TurboQuant for memory & docs: offer when cosine or turboquant is the code-node engine\n if (semanticEngine === 'cosine' || semanticEngine === 'turboquant') {\n patch.turboquantMemDocs = await askToggle(rl,\n 'TurboQuant for memory & docs search (optional):',\n 'Replaces the default linear cosine scan in memory observations and doc sections with a compressed ANN index \u2014 no native deps required. Most useful when you accumulate many observations or large doc sets (1 000+ entries).',\n false,\n );\n }\n\n // TurboVec bit width\n if (semanticEngine === 'turbovec') {\n patch.turbovecBits = await arrowSelect<number>(rl, 'TurboVec bits per coordinate:', [\n { value: 4, label: '4 bits (recommended)', description: 'Best quality, ~19\u00D7 compression vs raw Float32. Default.' },\n { value: 3, label: '3 bits', description: 'Balanced \u2014 ~25\u00D7 compression, slight quality drop.' },\n { value: 2, label: '2 bits', description: 'Highest compression (~38\u00D7), lowest accuracy.' },\n ]);\n patch.turbovecMemDocs = await askToggle(rl,\n 'TurboVec for memory & docs search (optional):',\n 'Replaces the default linear cosine scan in memory observations and doc sections with the TurboVec ANN index. Requires the addon to be built.',\n false,\n );\n }\n\n if (semanticEngine === 'typesense') {\n patch.typesenseDashboard = await askToggle(rl,\n 'Typesense dashboard:',\n 'Serves the Typesense Dashboard locally and opens it in your browser after indexing completes.',\n false,\n );\n }\n\n if (semanticEngine === 'qdrant') {\n patch.qdrantDashboard = await askToggle(rl,\n 'Qdrant dashboard:',\n 'Downloads the Qdrant Web UI (first time only) and opens it in your browser after indexing completes.',\n false,\n );\n }\n }\n\n // \u2500\u2500 Graph Features \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDCCA', 'Graph Features');\n\n patch.extractDocstrings = await askToggle(rl,\n 'Docstring extraction:',\n 'Enriches symbol metadata and improves context quality. Slightly increases indexing time.',\n );\n\n patch.trackCallSites = await askToggle(rl,\n 'Call site tracking (caller/callee graph):',\n 'Enables kirograph_callers and kirograph_callees MCP tools. Increases index size.',\n );\n\n patch.enableArchitecture = await askToggle(rl,\n 'Architecture analysis (packages + layers):',\n 'Detects packages from manifests and architectural layers. Enables kirograph_architecture, kirograph_coupling, kirograph_package.',\n false,\n );\n\n // \u2500\u2500 Security \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDD12', 'Security');\n\n patch.enableSecurity = await askToggle(rl,\n 'Security analysis (vulnerability scanning + reachability):',\n 'Scans dependency manifests for known vulnerabilities and performs reachability analysis. Requires Architecture analysis (will be auto-enabled). Enables kirograph_security, kirograph_vulns, kirograph_sbom, kirograph_vex, kirograph_reachability MCP tools.',\n false,\n );\n\n if (patch.enableSecurity && !patch.enableArchitecture) {\n patch.enableArchitecture = true;\n console.log(' \u2139 Architecture analysis auto-enabled (required by Security module)');\n }\n\n // \u2500\u2500 Pattern Matching \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDD0D', 'Pattern Matching');\n\n patch.enablePatterns = await askToggle(rl,\n 'Precise SAST with ast-grep?',\n 'Runs AST structural pattern matching during indexing using @ast-grep/napi (~15MB native binding). Unlike heuristic symbol-name analysis, matches real code structure \u2014 precise SQL injection, path traversal, eval detection. Requires @ast-grep/napi (will be installed automatically if you answer yes).',\n false,\n );\n\n // \u2500\u2500 Documentation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDCD6', 'Documentation');\n\n (patch as any).enableDocs = await askToggle(rl,\n 'Documentation indexing (section-level retrieval):',\n 'Indexes docs by heading structure. Enables kirograph_docs_toc, kirograph_docs_search, kirograph_docs_section, kirograph_docs_outline, kirograph_docs_refs.',\n false,\n );\n\n if ((patch as any).enableDocs) {\n const contextChoice = await arrowSelect<number>(rl, 'Include doc sections in kirograph_context results?', [\n { value: 0, label: '0 (disabled)', description: 'Docs stay separate \u2014 use kirograph_docs_* tools explicitly (recommended)' },\n { value: 3, label: '3 sections', description: 'Include up to 3 relevant doc sections in context results' },\n { value: 5, label: '5 sections', description: 'Include up to 5 relevant doc sections in context results' },\n { value: 10, label: '10 sections', description: 'Include up to 10 relevant doc sections in context results' },\n ]);\n (patch as any).docsContextLimit = contextChoice;\n }\n\n // \u2500\u2500 Data \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDCCA', 'Data');\n\n (patch as any).enableData = await askToggle(rl,\n 'Tabular data indexing (CSV/TSV/JSONL/JSON/Excel/Parquet):',\n 'Indexes data files for structured querying. Enables kirograph_data_list, kirograph_data_describe, kirograph_data_query, kirograph_data_aggregate, kirograph_data_search.',\n false,\n );\n\n if ((patch as any).enableData) {\n (patch as any).dataInstallExcel = await askToggle(rl,\n 'Install Excel support (xlsx package)?',\n 'Required for .xlsx/.xls files. CSV/TSV/JSONL/JSON are always supported without extra deps.',\n false,\n );\n\n (patch as any).dataInstallParquet = await askToggle(rl,\n 'Install Parquet support (parquetjs-lite package)?',\n 'Required for .parquet files. CSV/TSV/JSONL/JSON are always supported without extra deps.',\n false,\n );\n\n (patch as any).dataInstallPdf = await askToggle(rl,\n 'Install PDF support (@firecrawl/pdf-inspector package)?',\n 'Required for .pdf files. Rust/NAPI binary \u2014 prebuilts for linux-x64 and macOS ARM64.',\n false,\n );\n\n const contextChoice = await arrowSelect<number>(rl, 'Include dataset schemas in kirograph_context results?', [\n { value: 0, label: '0 (disabled)', description: 'Data stays separate \u2014 use kirograph_data_* tools explicitly (recommended)' },\n { value: 2, label: '2 datasets', description: 'Include up to 2 relevant dataset schemas in context results' },\n { value: 5, label: '5 datasets', description: 'Include up to 5 relevant dataset schemas in context results' },\n ]);\n (patch as any).dataContextLimit = contextChoice;\n }\n\n // \u2500\u2500 Agent Behavior \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83E\uDD16', 'Agent Behavior');\n\n const cavemanChoice = await arrowSelect(rl, 'Communication style (caveman mode):', [\n { value: 'off', label: 'off', description: 'Normal responses \u2014 no compression' },\n { value: 'lite', label: 'lite', description: 'Compact, no filler, full sentences' },\n { value: 'full', label: 'full', description: 'Fragments, no articles, short synonyms' },\n { value: 'ultra', label: 'ultra', description: 'Max compression, abbreviations, \u2192 for causality' },\n ]);\n patch.cavemanMode = cavemanChoice as CavemanMode | 'off';\n\n const compressionChoice = await arrowSelect(rl, 'Shell compression (kirograph_exec default level):', [\n { value: 'off', label: 'off', description: 'No compression hook or steering (tool still available)' },\n { value: 'normal', label: 'normal', description: 'Balanced: removes noise, keeps structure (recommended)' },\n { value: 'aggressive', label: 'aggressive', description: 'More compact: groups by category, limits output' },\n { value: 'ultra', label: 'ultra', description: 'Maximum compression: counts and summaries only' },\n ]);\n patch.shellCompressionLevel = compressionChoice as KiroGraphConfig['shellCompressionLevel'];\n\n // \u2500\u2500 Memory \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83E\uDDE0', 'Memory');\n\n patch.enableMemory = await askToggle(rl,\n 'Persistent memory (cross-session observations):',\n 'Stores decisions, errors, and patterns across sessions. Compressed (if caveman is on), linked to code symbols, searchable via kirograph_mem_* tools. Zero LLM tokens on write.',\n false,\n );\n\n if (patch.enableMemory) {\n patch.enableWatchmen = await askToggle(rl,\n 'Watchmen (auto-synthesize workspace briefs from memory):',\n 'When enough observations accumulate (default: 5), synthesizes them into .kiro/steering/kirograph-watchmen.md, CLAUDE.md, AGENTS.md, or the equivalent for your tool.',\n false,\n );\n\n if (patch.enableWatchmen) {\n // \u2500\u2500 Synthesis mode \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const synthesisMode = await arrowSelect<KiroGraphConfig['watchmenSynthesisMode']>(\n rl,\n 'Watchmen synthesis mode:',\n [\n {\n value: 'local',\n label: 'Local model',\n description: 'Runs a local HuggingFace model via @huggingface/transformers. Zero API cost, no data leaves your machine. Model downloaded once to ~/.kirograph/models/. Works for all tools via runCommand hook.',\n },\n {\n value: 'agent',\n label: 'Active agent',\n description: '\u26A0 Kiro only. Uses the active Kiro agent to synthesize. Consumes API tokens/credits on every synthesis. Not supported for other tools.',\n },\n ],\n );\n patch.watchmenSynthesisMode = synthesisMode;\n\n if (synthesisMode === 'local') {\n // \u2500\u2500 Local model selection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const LOCAL_MODELS = [\n {\n value: 'onnx-community/gemma-4-E4B-it-ONNX',\n label: 'Gemma 4 E4B (recommended)',\n description: '~3\u20134 GB \u00B7 Google DeepMind Gemma 4 \u00B7 4.5B params \u00B7 128K context \u00B7 Best quality \u00B7 Apache 2.0',\n },\n {\n value: 'onnx-community/Qwen2.5-1.5B-Instruct',\n label: 'Qwen2.5-1.5B',\n description: '~1.5 GB \u00B7 Lighter option if RAM is limited \u00B7 Acceptable quality',\n },\n {\n value: 'HuggingFaceTB/SmolLM2-1.7B-Instruct',\n label: 'SmolLM2-1.7B',\n description: '~1.7 GB \u00B7 HuggingFace compact model \u00B7 Good at following structured formats',\n },\n {\n value: '__other__',\n label: 'Other',\n description: 'Enter a custom HuggingFace model ID (must have ONNX weights on onnx-community)',\n },\n ] as const;\n\n const modelChoice = await arrowSelect<string>(rl, 'Local synthesis model:', LOCAL_MODELS.map(m => ({ value: m.value, label: m.label, description: m.description })));\n\n if (modelChoice === '__other__') {\n console.log(`\\n ${dim}Enter a HuggingFace model ID (e.g. onnx-community/gemma-4-E4B-it-ONNX).${reset}`);\n while (true) {\n const raw = (await ask(rl, ` ${violet}Model identifier:${reset} `)).trim();\n if (raw.includes('/')) { patch.watchmenLocalModel = raw; break; }\n console.log(` Expected a HuggingFace model ID in the format org/model-name.`);\n }\n } else {\n patch.watchmenLocalModel = modelChoice;\n }\n }\n }\n }\n\n return patch;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,qBAA8F;AAIvF,MAAM,0BAA0B;AAGvC,MAAM,gBAAgB;AAAA,EACpB;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,KAAK;AAAA,IACL,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,KAAK;AAAA,IACL,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,KAAK;AAAA,IACL,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,KAAK;AAAA,IACL,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,KAAK;AAAA,IACL,aAAa;AAAA,EACf;AACF;AAEA,eAAsB,oBAAoB,IAA8C;AAEtF,mCAAa,aAAM,iBAAiB;AAEpC,QAAM,mBAAmB,UAAM;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,QAAqB,EAAE,kBAAkB,aAAa,OAAO,gBAAgB,UAAU,mBAAmB,OAAO,gBAAgB,GAAG,iBAAiB,OAAO,cAAc,GAAG,oBAAoB,OAAO,iBAAiB,OAAO,mBAAmB,
|
|
4
|
+
"sourcesContent": ["/**\n * KiroGraph Installer \u2014 configuration prompting\n */\n\nimport * as readline from 'readline';\nimport { KiroGraphConfig } from '../../config';\ntype CavemanMode = 'lite' | 'full' | 'ultra';\nimport { ask, askToggle, arrowSelect, printSection, printSeparator, dim, reset, violet } from './prompts';\nexport type ConfigPatch = Pick<KiroGraphConfig, 'enableEmbeddings' | 'useVecIndex' | 'semanticEngine' | 'turboquantMemDocs' | 'turboquantBits' | 'turbovecMemDocs' | 'turbovecBits' | 'typesenseDashboard' | 'qdrantDashboard' | 'extractDocstrings' | 'trackCallSites' | 'enableArchitecture' | 'cavemanMode' | 'shellCompressionLevel' | 'enableMemory' | 'enableWatchmen' | 'watchmenThreshold' | 'watchmenSynthesisMode' | 'watchmenLocalModel' | 'enableDocs' | 'docsContextLimit' | 'enableData' | 'dataContextLimit' | 'enableSecurity' | 'enablePatterns' | 'enableWiki' | 'wikiSynthesisMode' | 'wikiLocalModel' | 'enableCodeHealth' | 'enableAdvancedAnalysis' | 'enableAgentUtils'> & { embeddingModel?: string; embeddingDim?: number };\nexport type SemanticEngine = KiroGraphConfig['semanticEngine'];\n\nexport const DEFAULT_EMBEDDING_MODEL = 'nomic-ai/nomic-embed-text-v1.5';\n\n/** Well-known embedding models with their output dimensions. */\nconst PRESET_MODELS = [\n {\n value: 'nomic-ai/nomic-embed-text-v1.5',\n label: 'nomic-embed-text-v1.5',\n dim: 768,\n description: '768-dim \u00B7 ~130MB \u00B7 Best quality for code search (recommended)',\n },\n {\n value: 'onnx-community/embeddinggemma-300m-ONNX',\n label: 'embeddinggemma-300m',\n dim: 768,\n description: '768-dim \u00B7 ~300MB \u00B7 Google Gemma-based, multilingual, 2048-token context',\n },\n {\n value: 'Xenova/all-MiniLM-L6-v2',\n label: 'all-MiniLM-L6-v2',\n dim: 384,\n description: '384-dim \u00B7 ~23MB \u00B7 Fast and lightweight, lower accuracy',\n },\n {\n value: 'BAAI/bge-base-en-v1.5',\n label: 'bge-base-en-v1.5',\n dim: 768,\n description: '768-dim \u00B7 ~110MB \u00B7 Strong general-purpose alternative to nomic',\n },\n {\n value: '__other__',\n label: 'Other',\n dim: 768,\n description: 'Enter a custom HuggingFace model ID and embedding dimension',\n },\n] as const;\n\nexport async function promptConfigOptions(rl: readline.Interface): Promise<ConfigPatch> {\n // \u2500\u2500 Semantic Search \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDD0D', 'Semantic Search');\n\n const enableEmbeddings = await askToggle(\n rl,\n 'Semantic embeddings (similarity search):',\n 'Enables natural-language code search via vector embeddings. A local model (~130MB) is downloaded on first use.',\n );\n\n const patch: ConfigPatch = { enableEmbeddings, useVecIndex: false, semanticEngine: 'cosine', turboquantMemDocs: false, turboquantBits: 3, turbovecMemDocs: false, turbovecBits: 4, typesenseDashboard: false, qdrantDashboard: false, extractDocstrings: false, trackCallSites: false, enableArchitecture: false, cavemanMode: 'off', shellCompressionLevel: 'normal', enableMemory: false, enableWatchmen: false, watchmenThreshold: 5, watchmenSynthesisMode: 'local', watchmenLocalModel: 'onnx-community/gemma-4-E4B-it-ONNX', enableDocs: false, docsContextLimit: 0, enableData: false, dataContextLimit: 0, enableSecurity: false, enablePatterns: false, enableWiki: false, wikiSynthesisMode: 'agent', wikiLocalModel: 'onnx-community/gemma-4-E4B-it-ONNX', enableCodeHealth: false, enableAdvancedAnalysis: false, enableAgentUtils: false };\n\n if (enableEmbeddings) {\n // \u2500\u2500 Model selection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const modelChoice = await arrowSelect<string>(\n rl,\n 'Embedding model:',\n PRESET_MODELS.map(m => ({ value: m.value, label: m.label, description: m.description })),\n );\n\n let embeddingModel: string;\n let embeddingDim: number;\n\n if (modelChoice === '__other__') {\n console.log(`\\n ${dim}Enter a HuggingFace model ID in the format org/model-name.${reset}`);\n while (true) {\n const raw = (await ask(rl, ` ${violet}Model identifier:${reset} `)).trim();\n if (raw.includes('/')) { embeddingModel = raw; break; }\n console.log(` Expected a HuggingFace model ID in the format org/model-name (e.g. nomic-ai/nomic-embed-text-v1.5).`);\n }\n console.log(`\\n ${dim}Enter the embedding output dimension for this model (check the model card on HuggingFace).${reset}`);\n while (true) {\n const raw = (await ask(rl, ` ${violet}Embedding dimension (e.g. 768, 384):${reset} `)).trim();\n const n = parseInt(raw, 10);\n if (!isNaN(n) && n > 0) { embeddingDim = n; break; }\n console.log(` Expected a positive integer (e.g. 768, 384, 1536).`);\n }\n } else {\n const preset = PRESET_MODELS.find(m => m.value === modelChoice)!;\n embeddingModel = preset.value;\n embeddingDim = preset.dim;\n }\n\n patch.embeddingModel = embeddingModel;\n patch.embeddingDim = embeddingDim;\n\n // \u2500\u2500 Engine selection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const semanticEngine = await arrowSelect<SemanticEngine>(rl, 'Vector search engine:', [\n { value: 'cosine', label: 'cosine', description: 'In-process cosine similarity. No extra deps. Best for small/medium projects.' },\n { value: 'turboquant', label: 'turboquant', description: 'ANN index, zero native deps. Compresses embeddings 20\u201330\u00D7 (Google TurboQuant). ANN without native binaries \u2014 ideal for CI, ARM, restricted envs. Optional: npm install turboquant-js.' },\n { value: 'turbovec', label: 'turbovec', description: 'ANN search via Rust/SIMD (napi-rs). Same TurboQuant algorithm but NEON on ARM and AVX-512BW on x86 \u2014 faster than turboquant-js at the cost of a one-time Rust build. Requires Rust toolchain. Build: cd native/turbovec-node && npm install && npm run build.' },\n { value: 'sqlite-vec', label: 'sqlite-vec', description: 'ANN index. Sub-linear search. Best for large codebases. Needs: better-sqlite3, sqlite-vec (native).' },\n { value: 'orama', label: 'orama', description: 'Hybrid search (full-text + vector). Pure JS. Needs: @orama/orama, @orama/plugin-data-persistence.' },\n { value: 'pglite', label: 'pglite', description: 'Hybrid search via PostgreSQL + pgvector. Exact results. Pure WASM. Needs: @electric-sql/pglite.' },\n { value: 'lancedb', label: 'lancedb', description: 'ANN search via LanceDB (Apache Lance columnar format). Pure JS. Needs: @lancedb/lancedb.' },\n { value: 'qdrant', label: 'qdrant', description: 'ANN search via Qdrant embedded binary (HNSW index, Cosine). Needs: qdrant-local.' },\n { value: 'typesense', label: 'typesense', description: 'ANN search via Typesense (auto-downloaded binary, HNSW, Cosine). Needs: typesense.' },\n ]);\n patch.semanticEngine = semanticEngine;\n patch.useVecIndex = semanticEngine === 'sqlite-vec';\n\n // TurboQuant for memory & docs: offer when cosine or turboquant is the code-node engine\n if (semanticEngine === 'cosine' || semanticEngine === 'turboquant') {\n patch.turboquantMemDocs = await askToggle(rl,\n 'TurboQuant for memory & docs search (optional):',\n 'Replaces the default linear cosine scan in memory observations and doc sections with a compressed ANN index \u2014 no native deps required. Most useful when you accumulate many observations or large doc sets (1 000+ entries).',\n false,\n );\n }\n\n // TurboVec bit width\n if (semanticEngine === 'turbovec') {\n patch.turbovecBits = await arrowSelect<number>(rl, 'TurboVec bits per coordinate:', [\n { value: 4, label: '4 bits (recommended)', description: 'Best quality, ~19\u00D7 compression vs raw Float32. Default.' },\n { value: 3, label: '3 bits', description: 'Balanced \u2014 ~25\u00D7 compression, slight quality drop.' },\n { value: 2, label: '2 bits', description: 'Highest compression (~38\u00D7), lowest accuracy.' },\n ]);\n patch.turbovecMemDocs = await askToggle(rl,\n 'TurboVec for memory & docs search (optional):',\n 'Replaces the default linear cosine scan in memory observations and doc sections with the TurboVec ANN index. Requires the addon to be built.',\n false,\n );\n }\n\n if (semanticEngine === 'typesense') {\n patch.typesenseDashboard = await askToggle(rl,\n 'Typesense dashboard:',\n 'Serves the Typesense Dashboard locally and opens it in your browser after indexing completes.',\n false,\n );\n }\n\n if (semanticEngine === 'qdrant') {\n patch.qdrantDashboard = await askToggle(rl,\n 'Qdrant dashboard:',\n 'Downloads the Qdrant Web UI (first time only) and opens it in your browser after indexing completes.',\n false,\n );\n }\n }\n\n // \u2500\u2500 Graph Features \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDCCA', 'Graph Features');\n\n patch.extractDocstrings = await askToggle(rl,\n 'Docstring extraction:',\n 'Enriches symbol metadata and improves context quality. Slightly increases indexing time.',\n false,\n );\n\n patch.trackCallSites = await askToggle(rl,\n 'Call site tracking (caller/callee graph):',\n 'Enables kirograph_callers and kirograph_callees MCP tools. Increases index size.',\n false,\n );\n\n patch.enableArchitecture = await askToggle(rl,\n 'Architecture analysis (packages + layers):',\n 'Detects packages from manifests and architectural layers. Enables kirograph_architecture, kirograph_coupling, kirograph_package.',\n false,\n );\n\n if (patch.enableArchitecture) {\n patch.enableAdvancedAnalysis = await askToggle(rl,\n 'Advanced graph analysis (type hierarchies, flows, communities, refactor):',\n 'Enables kirograph_type_hierarchy, kirograph_flows, kirograph_communities, kirograph_refactor. Most useful alongside architecture analysis.',\n false,\n );\n }\n\n // \u2500\u2500 Graph Tools \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDCCA', 'Graph Tools');\n\n patch.enableCodeHealth = await askToggle(rl,\n 'Code health tools (hotspots, dead code, change tracking):',\n 'Enables kirograph_hotspots, kirograph_surprising, kirograph_diff, kirograph_dead_code, kirograph_circular_deps.',\n false,\n );\n\n patch.enableAgentUtils = await askToggle(rl,\n 'Agent utilities (file caching, budget tracking):',\n 'Enables kirograph_read, kirograph_gain, kirograph_budget.',\n false,\n );\n\n // \u2500\u2500 Security \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDD12', 'Security');\n\n patch.enableSecurity = await askToggle(rl,\n 'Security analysis (vulnerability scanning + reachability):',\n 'Scans dependency manifests for known vulnerabilities and performs reachability analysis. Requires Architecture analysis (will be auto-enabled). Enables kirograph_security, kirograph_vulns, kirograph_sbom, kirograph_vex, kirograph_reachability MCP tools.',\n false,\n );\n\n if (patch.enableSecurity && !patch.enableArchitecture) {\n patch.enableArchitecture = true;\n console.log(' \u2139 Architecture analysis auto-enabled (required by Security module)');\n }\n\n // \u2500\u2500 Pattern Matching \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDD0D', 'Pattern Matching');\n\n patch.enablePatterns = await askToggle(rl,\n 'Precise SAST with ast-grep?',\n 'Runs AST structural pattern matching during indexing using @ast-grep/napi (~15MB native binding). Unlike heuristic symbol-name analysis, matches real code structure \u2014 precise SQL injection, path traversal, eval detection. Requires @ast-grep/napi (will be installed automatically if you answer yes).',\n false,\n );\n\n // \u2500\u2500 Documentation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDCD6', 'Documentation');\n\n (patch as any).enableDocs = await askToggle(rl,\n 'Documentation indexing (section-level retrieval):',\n 'Indexes docs by heading structure. Enables kirograph_docs_toc, kirograph_docs_search, kirograph_docs_section, kirograph_docs_outline, kirograph_docs_refs.',\n false,\n );\n\n if ((patch as any).enableDocs) {\n const contextChoice = await arrowSelect<number>(rl, 'Include doc sections in kirograph_context results?', [\n { value: 0, label: '0 (disabled)', description: 'Docs stay separate \u2014 use kirograph_docs_* tools explicitly (recommended)' },\n { value: 3, label: '3 sections', description: 'Include up to 3 relevant doc sections in context results' },\n { value: 5, label: '5 sections', description: 'Include up to 5 relevant doc sections in context results' },\n { value: 10, label: '10 sections', description: 'Include up to 10 relevant doc sections in context results' },\n ]);\n (patch as any).docsContextLimit = contextChoice;\n }\n\n // \u2500\u2500 Data \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDCCA', 'Data');\n\n (patch as any).enableData = await askToggle(rl,\n 'Tabular data indexing (CSV/TSV/JSONL/JSON/Excel/Parquet):',\n 'Indexes data files for structured querying. Enables kirograph_data_list, kirograph_data_describe, kirograph_data_query, kirograph_data_aggregate, kirograph_data_search.',\n false,\n );\n\n if ((patch as any).enableData) {\n (patch as any).dataInstallExcel = await askToggle(rl,\n 'Install Excel support (xlsx package)?',\n 'Required for .xlsx/.xls files. CSV/TSV/JSONL/JSON are always supported without extra deps.',\n false,\n );\n\n (patch as any).dataInstallParquet = await askToggle(rl,\n 'Install Parquet support (parquetjs-lite package)?',\n 'Required for .parquet files. CSV/TSV/JSONL/JSON are always supported without extra deps.',\n false,\n );\n\n (patch as any).dataInstallPdf = await askToggle(rl,\n 'Install PDF support (@firecrawl/pdf-inspector package)?',\n 'Required for .pdf files. Rust/NAPI binary \u2014 prebuilts for linux-x64 and macOS ARM64.',\n false,\n );\n\n const contextChoice = await arrowSelect<number>(rl, 'Include dataset schemas in kirograph_context results?', [\n { value: 0, label: '0 (disabled)', description: 'Data stays separate \u2014 use kirograph_data_* tools explicitly (recommended)' },\n { value: 2, label: '2 datasets', description: 'Include up to 2 relevant dataset schemas in context results' },\n { value: 5, label: '5 datasets', description: 'Include up to 5 relevant dataset schemas in context results' },\n ]);\n (patch as any).dataContextLimit = contextChoice;\n }\n\n // \u2500\u2500 Agent Behavior \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83E\uDD16', 'Agent Behavior');\n\n const cavemanChoice = await arrowSelect(rl, 'Communication style (caveman mode):', [\n { value: 'off', label: 'off', description: 'Normal responses \u2014 no compression' },\n { value: 'lite', label: 'lite', description: 'Compact, no filler, full sentences' },\n { value: 'full', label: 'full', description: 'Fragments, no articles, short synonyms' },\n { value: 'ultra', label: 'ultra', description: 'Max compression, abbreviations, \u2192 for causality' },\n ]);\n patch.cavemanMode = cavemanChoice as CavemanMode | 'off';\n\n const compressionChoice = await arrowSelect(rl, 'Shell compression (kirograph_exec):', [\n { value: 'off', label: 'off', description: 'Disables kirograph_exec entirely' },\n { value: 'normal', label: 'normal', description: 'Balanced: removes noise, keeps structure (recommended)' },\n { value: 'aggressive', label: 'aggressive', description: 'More compact: groups by category, limits output' },\n { value: 'ultra', label: 'ultra', description: 'Maximum compression: counts and summaries only' },\n ]);\n patch.shellCompressionLevel = compressionChoice as KiroGraphConfig['shellCompressionLevel'];\n if (compressionChoice === 'off') {\n console.log(' \u2139 kirograph_exec disabled (shell compression is off)');\n }\n\n // \u2500\u2500 Memory \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83E\uDDE0', 'Memory');\n\n patch.enableMemory = await askToggle(rl,\n 'Persistent memory (cross-session observations):',\n 'Stores decisions, errors, and patterns across sessions. Compressed (if caveman is on), linked to code symbols, searchable via kirograph_mem_* tools. Zero LLM tokens on write.',\n false,\n );\n\n if (patch.enableMemory) {\n patch.enableWatchmen = await askToggle(rl,\n 'Watchmen (auto-synthesize workspace briefs from memory):',\n 'When enough observations accumulate (default: 5), synthesizes them into .kiro/steering/kirograph-watchmen.md, CLAUDE.md, AGENTS.md, or the equivalent for your tool.',\n false,\n );\n\n if (patch.enableWatchmen) {\n // \u2500\u2500 Synthesis mode \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const synthesisMode = await arrowSelect<KiroGraphConfig['watchmenSynthesisMode']>(\n rl,\n 'Watchmen synthesis mode:',\n [\n {\n value: 'local',\n label: 'Local model',\n description: 'Runs a local HuggingFace model via @huggingface/transformers. Zero API cost, no data leaves your machine. Model downloaded once to ~/.kirograph/models/. Works for all tools via runCommand hook.',\n },\n {\n value: 'agent',\n label: 'Active agent',\n description: '\u26A0 Kiro only. Uses the active Kiro agent to synthesize. Consumes API tokens/credits on every synthesis. Not supported for other tools.',\n },\n ],\n );\n patch.watchmenSynthesisMode = synthesisMode;\n\n if (synthesisMode === 'local') {\n // \u2500\u2500 Local model selection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const LOCAL_MODELS = [\n {\n value: 'onnx-community/gemma-4-E4B-it-ONNX',\n label: 'Gemma 4 E4B (recommended)',\n description: '~3\u20134 GB \u00B7 Google DeepMind Gemma 4 \u00B7 4.5B params \u00B7 128K context \u00B7 Best quality \u00B7 Apache 2.0',\n },\n {\n value: 'onnx-community/Qwen2.5-1.5B-Instruct',\n label: 'Qwen2.5-1.5B',\n description: '~1.5 GB \u00B7 Lighter option if RAM is limited \u00B7 Acceptable quality',\n },\n {\n value: 'HuggingFaceTB/SmolLM2-1.7B-Instruct',\n label: 'SmolLM2-1.7B',\n description: '~1.7 GB \u00B7 HuggingFace compact model \u00B7 Good at following structured formats',\n },\n {\n value: '__other__',\n label: 'Other',\n description: 'Enter a custom HuggingFace model ID (must have ONNX weights on onnx-community)',\n },\n ] as const;\n\n const modelChoice = await arrowSelect<string>(rl, 'Local synthesis model:', LOCAL_MODELS.map(m => ({ value: m.value, label: m.label, description: m.description })));\n\n if (modelChoice === '__other__') {\n console.log(`\\n ${dim}Enter a HuggingFace model ID (e.g. onnx-community/gemma-4-E4B-it-ONNX).${reset}`);\n while (true) {\n const raw = (await ask(rl, ` ${violet}Model identifier:${reset} `)).trim();\n if (raw.includes('/')) { patch.watchmenLocalModel = raw; break; }\n console.log(` Expected a HuggingFace model ID in the format org/model-name.`);\n }\n } else {\n patch.watchmenLocalModel = modelChoice;\n }\n }\n }\n }\n\n // \u2500\u2500 Wiki \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n printSection('\uD83D\uDCD6', 'Wiki');\n\n patch.enableWiki = await askToggle(rl,\n 'LLM Wiki (Karpathy-style structured knowledge base):',\n 'Maintains a set of markdown pages that compound knowledge across sessions. Supports search, ingest (two-tool flow), conflict resolution, and health checks via kirograph_wiki_* tools.',\n false,\n );\n\n if (patch.enableWiki) {\n const wikiMode = await arrowSelect<KiroGraphConfig['wikiSynthesisMode']>(\n rl,\n 'Wiki synthesis mode:',\n [\n {\n value: 'agent',\n label: 'Active agent (recommended)',\n description: 'Uses the active LLM agent to generate WIKI_DIFF blocks. Works with any AI tool. Consumes API tokens on ingest.',\n },\n {\n value: 'local',\n label: 'Local model',\n description: 'Runs a local HuggingFace model to generate diffs. Zero API cost, no data leaves your machine. Same infra as Watchmen.',\n },\n ],\n );\n patch.wikiSynthesisMode = wikiMode;\n\n if (wikiMode === 'local') {\n // \u2500\u2500 Local model selection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const WIKI_LOCAL_MODELS = [\n {\n value: 'onnx-community/gemma-4-E4B-it-ONNX',\n label: 'Gemma 4 E4B (recommended)',\n description: '~3\u20134 GB \u00B7 Google DeepMind Gemma 4 \u00B7 4.5B params \u00B7 128K context \u00B7 Best quality \u00B7 Apache 2.0',\n },\n {\n value: 'onnx-community/Qwen2.5-1.5B-Instruct',\n label: 'Qwen2.5-1.5B',\n description: '~1.5 GB \u00B7 Lighter option if RAM is limited \u00B7 Acceptable quality',\n },\n {\n value: 'HuggingFaceTB/SmolLM2-1.7B-Instruct',\n label: 'SmolLM2-1.7B',\n description: '~1.7 GB \u00B7 HuggingFace compact model \u00B7 Good at following structured formats',\n },\n {\n value: '__other__',\n label: 'Other',\n description: 'Enter a custom HuggingFace model ID (must have ONNX weights on onnx-community)',\n },\n ] as const;\n\n const wikiModelChoice = await arrowSelect<string>(rl, 'Local wiki synthesis model:', WIKI_LOCAL_MODELS.map(m => ({ value: m.value, label: m.label, description: m.description })));\n\n if (wikiModelChoice === '__other__') {\n console.log(`\\n ${dim}Enter a HuggingFace model ID (e.g. onnx-community/gemma-4-E4B-it-ONNX).${reset}`);\n while (true) {\n const raw = (await ask(rl, ` ${violet}Model identifier:${reset} `)).trim();\n if (raw.includes('/')) { patch.wikiLocalModel = raw; break; }\n console.log(` Expected a HuggingFace model ID in the format org/model-name.`);\n }\n } else {\n patch.wikiLocalModel = wikiModelChoice;\n }\n }\n }\n\n return patch;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;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AA0E,oBAAK,EAAE;AACvG,eAAO,MAAM;AACX,gBAAM,OAAO,UAAM,oBAAI,IAAI,KAAK,qBAAM,oBAAoB,oBAAK,GAAG,GAAG,KAAK;AAC1E,cAAI,IAAI,SAAS,GAAG,GAAG;AAAE,kBAAM,iBAAiB;AAAK;AAAA,UAAO;AAC5D,kBAAQ,IAAI,iEAAiE;AAAA,QAC/E;AAAA,MACF,OAAO;AACL,cAAM,iBAAiB;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -33,39 +33,70 @@ __export(hooks_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(hooks_exports);
|
|
34
34
|
var fs = __toESM(require("fs"));
|
|
35
35
|
var path = __toESM(require("path"));
|
|
36
|
-
|
|
37
|
-
const
|
|
36
|
+
const V2_EXT = ".json";
|
|
37
|
+
const V1_EXT = ".kiro.hook";
|
|
38
38
|
function buildWatchmenHook(synthesisMode) {
|
|
39
39
|
if (synthesisMode === "local") {
|
|
40
40
|
return {
|
|
41
|
-
|
|
42
|
-
version: "1.0.0",
|
|
41
|
+
id: "kirograph-watchmen",
|
|
43
42
|
description: "After memory capture, run local model synthesis if enough observations have accumulated.",
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
v2: {
|
|
44
|
+
version: "v1",
|
|
45
|
+
hooks: [{
|
|
46
|
+
name: "KiroGraph Watchmen",
|
|
47
|
+
trigger: "Stop",
|
|
48
|
+
action: { type: "command", command: "kirograph mem watchmen synthesize --quiet 2>&1 || true" }
|
|
49
|
+
}]
|
|
50
|
+
},
|
|
51
|
+
v1: {
|
|
52
|
+
name: "KiroGraph Watchmen",
|
|
53
|
+
version: "1.0.0",
|
|
54
|
+
description: "After memory capture, run local model synthesis if enough observations have accumulated.",
|
|
55
|
+
when: { type: "agentStop" },
|
|
56
|
+
then: { type: "runCommand", command: "kirograph mem watchmen synthesize --quiet 2>&1 || true" }
|
|
57
|
+
}
|
|
46
58
|
};
|
|
47
59
|
}
|
|
48
|
-
|
|
49
|
-
name: "KiroGraph Watchmen",
|
|
50
|
-
version: "1.0.0",
|
|
51
|
-
description: "After memory capture, check if enough observations have accumulated. If so, synthesize them into workspace brief files.",
|
|
52
|
-
when: { type: "agentStop" },
|
|
53
|
-
then: {
|
|
54
|
-
type: "askAgent",
|
|
55
|
-
prompt: `Check if KiroGraph Watchmen synthesis should run: call kirograph_mem_store with kind='note' and content='watchmen check'. If the response does not include watchmenReady: true, do nothing and stop.
|
|
60
|
+
const watchmenPrompt = `Check if KiroGraph Watchmen synthesis should run: call kirograph_mem_store with kind='note' and content='watchmen check'. If the response does not include watchmenReady: true, do nothing and stop.
|
|
56
61
|
|
|
57
62
|
If watchmenReady: true:
|
|
58
63
|
1. Call kirograph_mem_search for each kind (decision, error, pattern, architecture, note) with limit 20.
|
|
59
64
|
2. Write or update the workspace brief: upsert the ## KiroGraph Watchmen section in each file listed in targetFiles. For .kiro/steering/kirograph-watchmen.md use inclusion: always frontmatter with sections for Decisions, Known Errors & Fixes, Recurring Patterns, and Architecture Notes. For all other files write a compact ## KiroGraph Watchmen block.
|
|
60
65
|
3. Generate skill files: if skillTargetDir is present in the response, identify recurring procedures (any procedure appearing in 3+ observations). For each, write a .kiro/steering/watchmen-<slug>.md file with inclusion: manual frontmatter, a short title, a "When to use" line with trigger phrases, and numbered steps. Prefix all generated files with watchmen- so they are distinguishable from hand-written steering files. Remove any .kiro/steering/watchmen-*.md files from previous runs that no longer match current patterns. If skillTargetDir is absent, embed a ## Recurring Procedures section in each targetFile instead, listing each procedure with trigger context and steps.
|
|
61
|
-
4. Store a kind='summary' observation briefly describing what was synthesized (e.g. "Synthesized 8 observations: updated kirograph-watchmen.md, wrote watchmen-auth-flow.md and watchmen-test-pattern.md")
|
|
66
|
+
4. Store a kind='summary' observation briefly describing what was synthesized (e.g. "Synthesized 8 observations: updated kirograph-watchmen.md, wrote watchmen-auth-flow.md and watchmen-test-pattern.md").`;
|
|
67
|
+
return {
|
|
68
|
+
id: "kirograph-watchmen",
|
|
69
|
+
description: "After memory capture, check if enough observations have accumulated. If so, synthesize them into workspace brief files.",
|
|
70
|
+
v2: {
|
|
71
|
+
version: "v1",
|
|
72
|
+
hooks: [{
|
|
73
|
+
name: "KiroGraph Watchmen",
|
|
74
|
+
trigger: "Stop",
|
|
75
|
+
action: { type: "agent", prompt: watchmenPrompt }
|
|
76
|
+
}]
|
|
77
|
+
},
|
|
78
|
+
v1: {
|
|
79
|
+
name: "KiroGraph Watchmen",
|
|
80
|
+
version: "1.0.0",
|
|
81
|
+
description: "After memory capture, check if enough observations have accumulated. If so, synthesize them into workspace brief files.",
|
|
82
|
+
when: { type: "agentStop" },
|
|
83
|
+
then: { type: "askAgent", prompt: watchmenPrompt }
|
|
62
84
|
}
|
|
63
85
|
};
|
|
64
86
|
}
|
|
65
87
|
const HOOKS = [
|
|
66
88
|
{
|
|
67
|
-
|
|
68
|
-
|
|
89
|
+
id: "kirograph-sync-if-dirty",
|
|
90
|
+
description: "Sync the KiroGraph index when the agent stops, picking up any file edits, creates, or deletes from the session.",
|
|
91
|
+
v2: {
|
|
92
|
+
version: "v1",
|
|
93
|
+
hooks: [{
|
|
94
|
+
name: "KiroGraph Sync on Agent Stop",
|
|
95
|
+
trigger: "Stop",
|
|
96
|
+
action: { type: "command", command: "kirograph sync --quiet 2>&1 > /dev/null" }
|
|
97
|
+
}]
|
|
98
|
+
},
|
|
99
|
+
v1: {
|
|
69
100
|
name: "KiroGraph Sync on Agent Stop",
|
|
70
101
|
version: "1.0.0",
|
|
71
102
|
description: "Sync the KiroGraph index when the agent stops, picking up any file edits, creates, or deletes from the session.",
|
|
@@ -74,11 +105,24 @@ const HOOKS = [
|
|
|
74
105
|
}
|
|
75
106
|
},
|
|
76
107
|
{
|
|
77
|
-
|
|
78
|
-
|
|
108
|
+
id: "kirograph-compress-hint",
|
|
109
|
+
description: "Remind the agent to use kirograph_exec for shell commands that benefit from token compression.",
|
|
110
|
+
v2: {
|
|
111
|
+
version: "v1",
|
|
112
|
+
hooks: [{
|
|
113
|
+
name: "KiroGraph Compression Hint",
|
|
114
|
+
trigger: "PreToolUse",
|
|
115
|
+
matcher: "execute_bash",
|
|
116
|
+
action: {
|
|
117
|
+
type: "agent",
|
|
118
|
+
prompt: "If this shell command is a git operation, GitHub CLI, test runner, linter, build tool, file listing, grep/rg, docker/kubectl, AWS CLI, or package manager command, consider using the kirograph_exec MCP tool instead for 60-90% token savings. The tool compresses output automatically while preserving error details."
|
|
119
|
+
}
|
|
120
|
+
}]
|
|
121
|
+
},
|
|
122
|
+
v1: {
|
|
79
123
|
name: "KiroGraph Compression Hint",
|
|
80
124
|
version: "1.0.0",
|
|
81
|
-
description: "Remind the agent to use kirograph_exec for shell commands that benefit from token compression
|
|
125
|
+
description: "Remind the agent to use kirograph_exec for shell commands that benefit from token compression.",
|
|
82
126
|
when: { type: "preToolUse", toolTypes: ["shell"] },
|
|
83
127
|
then: {
|
|
84
128
|
type: "askAgent",
|
|
@@ -87,8 +131,20 @@ const HOOKS = [
|
|
|
87
131
|
}
|
|
88
132
|
},
|
|
89
133
|
{
|
|
90
|
-
|
|
91
|
-
|
|
134
|
+
id: "kirograph-mem-capture",
|
|
135
|
+
description: "Prompt the agent to store important observations in memory at the end of each session.",
|
|
136
|
+
v2: {
|
|
137
|
+
version: "v1",
|
|
138
|
+
hooks: [{
|
|
139
|
+
name: "KiroGraph Memory Capture",
|
|
140
|
+
trigger: "Stop",
|
|
141
|
+
action: {
|
|
142
|
+
type: "agent",
|
|
143
|
+
prompt: "Before ending, review what happened in this session. If there were any important decisions, bug root causes, architecture insights, error patterns, or lessons learned, store them using kirograph_mem_store with the appropriate kind (decision, error, pattern, architecture, note). Keep observations concise \u2014 one fact per observation. Skip if nothing noteworthy happened."
|
|
144
|
+
}
|
|
145
|
+
}]
|
|
146
|
+
},
|
|
147
|
+
v1: {
|
|
92
148
|
name: "KiroGraph Memory Capture",
|
|
93
149
|
version: "1.0.0",
|
|
94
150
|
description: "Prompt the agent to store important observations in memory at the end of each session.",
|
|
@@ -106,95 +162,133 @@ function ensureDir(p) {
|
|
|
106
162
|
function writeJson(p, data) {
|
|
107
163
|
fs.writeFileSync(p, JSON.stringify(data, null, 2) + "\n");
|
|
108
164
|
}
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
165
|
+
function writeHookDual(hooksDir, def) {
|
|
166
|
+
writeJson(path.join(hooksDir, `${def.id}${V2_EXT}`), def.v2);
|
|
167
|
+
writeJson(path.join(hooksDir, `${def.id}${V1_EXT}`), def.v1);
|
|
168
|
+
}
|
|
169
|
+
function writeHookForFormat(hooksDir, def, format) {
|
|
170
|
+
if (format === "v2") {
|
|
171
|
+
writeJson(path.join(hooksDir, `${def.id}${V2_EXT}`), def.v2);
|
|
172
|
+
const legacyPath = path.join(hooksDir, `${def.id}${V1_EXT}`);
|
|
173
|
+
if (fs.existsSync(legacyPath)) fs.unlinkSync(legacyPath);
|
|
174
|
+
} else {
|
|
175
|
+
writeJson(path.join(hooksDir, `${def.id}${V1_EXT}`), def.v1);
|
|
176
|
+
const v2Path = path.join(hooksDir, `${def.id}${V2_EXT}`);
|
|
177
|
+
if (fs.existsSync(v2Path)) fs.unlinkSync(v2Path);
|
|
116
178
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
} catch {
|
|
123
|
-
(0, import_errors.logWarn)(`KiroGraph installer: could not read hook file ${filePath}`);
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
let obj;
|
|
127
|
-
try {
|
|
128
|
-
obj = JSON.parse(raw);
|
|
129
|
-
} catch {
|
|
130
|
-
(0, import_errors.logWarn)(`KiroGraph installer: could not parse hook file ${filePath}`);
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
let changed = false;
|
|
134
|
-
if (obj?.when?.type === "onIdle") {
|
|
135
|
-
obj.when.type = "agentStop";
|
|
136
|
-
changed = true;
|
|
137
|
-
}
|
|
138
|
-
if (file.endsWith(".json") && file.startsWith("kirograph-")) {
|
|
139
|
-
const newName = file.replace(/\.json$/, HOOK_EXT);
|
|
140
|
-
const newPath = path.join(hooksDir, newName);
|
|
141
|
-
try {
|
|
142
|
-
fs.writeFileSync(newPath, JSON.stringify(obj, null, 2) + "\n");
|
|
143
|
-
fs.unlinkSync(filePath);
|
|
144
|
-
} catch {
|
|
145
|
-
(0, import_errors.logWarn)(`KiroGraph installer: could not migrate hook file ${filePath} \u2192 ${newName}`);
|
|
146
|
-
}
|
|
147
|
-
} else if (changed) {
|
|
148
|
-
try {
|
|
149
|
-
fs.writeFileSync(filePath, JSON.stringify(obj, null, 2) + "\n");
|
|
150
|
-
} catch {
|
|
151
|
-
(0, import_errors.logWarn)(`KiroGraph installer: could not write migrated hook file ${filePath}`);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
179
|
+
}
|
|
180
|
+
function removeHookDual(hooksDir, id) {
|
|
181
|
+
for (const ext of [V2_EXT, V1_EXT]) {
|
|
182
|
+
const p = path.join(hooksDir, `${id}${ext}`);
|
|
183
|
+
if (fs.existsSync(p)) fs.unlinkSync(p);
|
|
154
184
|
}
|
|
155
185
|
}
|
|
156
186
|
function writeHooks(kiroDir, opts) {
|
|
157
187
|
const hooksDir = path.join(kiroDir, "hooks");
|
|
158
188
|
ensureDir(hooksDir);
|
|
159
|
-
|
|
160
|
-
const
|
|
189
|
+
const format = opts?.kiroHookFormat ?? "v2";
|
|
190
|
+
const obsoleteFiles = [
|
|
161
191
|
"kirograph-sync-on-save.json",
|
|
162
192
|
"kirograph-sync-on-create.json",
|
|
163
|
-
// Legacy .json versions (migrated to .kiro.hook)
|
|
164
193
|
"kirograph-mark-dirty-on-save.json",
|
|
165
194
|
"kirograph-mark-dirty-on-create.json",
|
|
166
195
|
"kirograph-sync-on-delete.json",
|
|
167
|
-
"kirograph-
|
|
168
|
-
"kirograph-
|
|
169
|
-
"kirograph-
|
|
170
|
-
// Removed per-file hooks (consolidated into agentStop sync)
|
|
171
|
-
`kirograph-mark-dirty-on-save${HOOK_EXT}`,
|
|
172
|
-
`kirograph-mark-dirty-on-create${HOOK_EXT}`,
|
|
173
|
-
`kirograph-sync-on-delete${HOOK_EXT}`
|
|
196
|
+
"kirograph-mark-dirty-on-save.kiro.hook",
|
|
197
|
+
"kirograph-mark-dirty-on-create.kiro.hook",
|
|
198
|
+
"kirograph-sync-on-delete.kiro.hook"
|
|
174
199
|
];
|
|
175
|
-
for (const old of
|
|
200
|
+
for (const old of obsoleteFiles) {
|
|
176
201
|
const p = path.join(hooksDir, old);
|
|
177
202
|
if (fs.existsSync(p)) fs.unlinkSync(p);
|
|
178
203
|
}
|
|
179
|
-
for (const
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
if (fs.existsSync(p)) fs.unlinkSync(p);
|
|
204
|
+
for (const def of HOOKS) {
|
|
205
|
+
if (def.id === "kirograph-compress-hint" && opts?.enableCompression === false) {
|
|
206
|
+
removeHookDual(hooksDir, def.id);
|
|
183
207
|
continue;
|
|
184
208
|
}
|
|
185
|
-
if (
|
|
186
|
-
|
|
187
|
-
if (fs.existsSync(p)) fs.unlinkSync(p);
|
|
209
|
+
if (def.id === "kirograph-mem-capture" && !opts?.enableMemory) {
|
|
210
|
+
removeHookDual(hooksDir, def.id);
|
|
188
211
|
continue;
|
|
189
212
|
}
|
|
190
|
-
|
|
213
|
+
writeHookForFormat(hooksDir, def, format);
|
|
191
214
|
}
|
|
192
|
-
const watchmenHookPath = path.join(hooksDir, `kirograph-watchmen${HOOK_EXT}`);
|
|
193
215
|
if (opts?.enableWatchmen) {
|
|
194
216
|
const mode = opts.watchmenSynthesisMode ?? "local";
|
|
195
|
-
|
|
217
|
+
writeHookForFormat(hooksDir, buildWatchmenHook(mode), format);
|
|
218
|
+
} else {
|
|
219
|
+
removeHookDual(hooksDir, "kirograph-watchmen");
|
|
220
|
+
}
|
|
221
|
+
if (opts?.enableWiki) {
|
|
222
|
+
const lintFreq = opts.wikiLintFrequency ?? 10;
|
|
223
|
+
const wikiMode = opts.wikiSynthesisMode ?? "agent";
|
|
224
|
+
const wikiIngestPrompt = `If this session produced durable knowledge (design decisions, architecture insights, API contracts, process steps, domain facts), consider updating the wiki:
|
|
225
|
+
1. Call kirograph_wiki_ingest with the key findings as source text.
|
|
226
|
+
2. The tool returns a structured prompt. Pass it to yourself to generate a WIKI_DIFF.
|
|
227
|
+
3. Call kirograph_wiki_apply_diff with your generated diff.
|
|
228
|
+
Skip if the session was trivial (simple bug fix, no new knowledge).`;
|
|
229
|
+
if (wikiMode === "local") {
|
|
230
|
+
writeHookForFormat(hooksDir, {
|
|
231
|
+
id: "kirograph-wiki-ingest",
|
|
232
|
+
description: "After each session, run local-model wiki synthesis over queued sources.",
|
|
233
|
+
v2: {
|
|
234
|
+
version: "v1",
|
|
235
|
+
hooks: [{
|
|
236
|
+
name: "KiroGraph Wiki Synthesize",
|
|
237
|
+
trigger: "Stop",
|
|
238
|
+
action: { type: "command", command: "kirograph wiki synthesize --quiet 2>&1 || true" }
|
|
239
|
+
}]
|
|
240
|
+
},
|
|
241
|
+
v1: {
|
|
242
|
+
name: "KiroGraph Wiki Synthesize",
|
|
243
|
+
version: "1.0.0",
|
|
244
|
+
description: "After each session, run local-model wiki synthesis over queued sources.",
|
|
245
|
+
when: { type: "agentStop" },
|
|
246
|
+
then: { type: "runCommand", command: "kirograph wiki synthesize --quiet 2>&1 || true" }
|
|
247
|
+
}
|
|
248
|
+
}, format);
|
|
249
|
+
} else {
|
|
250
|
+
writeHookForFormat(hooksDir, {
|
|
251
|
+
id: "kirograph-wiki-ingest",
|
|
252
|
+
description: "At the end of each session, prompt the agent to ingest any relevant knowledge into the wiki.",
|
|
253
|
+
v2: {
|
|
254
|
+
version: "v1",
|
|
255
|
+
hooks: [{
|
|
256
|
+
name: "KiroGraph Wiki Ingest",
|
|
257
|
+
trigger: "Stop",
|
|
258
|
+
action: { type: "agent", prompt: wikiIngestPrompt }
|
|
259
|
+
}]
|
|
260
|
+
},
|
|
261
|
+
v1: {
|
|
262
|
+
name: "KiroGraph Wiki Ingest",
|
|
263
|
+
version: "1.0.0",
|
|
264
|
+
description: "At the end of each session, prompt the agent to ingest any relevant knowledge into the wiki.",
|
|
265
|
+
when: { type: "agentStop" },
|
|
266
|
+
then: { type: "askAgent", prompt: wikiIngestPrompt }
|
|
267
|
+
}
|
|
268
|
+
}, format);
|
|
269
|
+
}
|
|
270
|
+
writeHookForFormat(hooksDir, {
|
|
271
|
+
id: "kirograph-wiki-lint",
|
|
272
|
+
description: `Run wiki health check every ${lintFreq} sessions to catch broken links, orphan pages, and contradictions.`,
|
|
273
|
+
v2: {
|
|
274
|
+
version: "v1",
|
|
275
|
+
hooks: [{
|
|
276
|
+
name: "KiroGraph Wiki Lint",
|
|
277
|
+
trigger: "Stop",
|
|
278
|
+
action: { type: "command", command: "kirograph wiki lint 2>&1 || true" }
|
|
279
|
+
}]
|
|
280
|
+
},
|
|
281
|
+
v1: {
|
|
282
|
+
name: "KiroGraph Wiki Lint",
|
|
283
|
+
version: "1.0.0",
|
|
284
|
+
description: `Run wiki health check every ${lintFreq} sessions to catch broken links, orphan pages, and contradictions.`,
|
|
285
|
+
when: { type: "agentStop" },
|
|
286
|
+
then: { type: "runCommand", command: "kirograph wiki lint 2>&1 || true" }
|
|
287
|
+
}
|
|
288
|
+
}, format);
|
|
196
289
|
} else {
|
|
197
|
-
|
|
290
|
+
removeHookDual(hooksDir, "kirograph-wiki-ingest");
|
|
291
|
+
removeHookDual(hooksDir, "kirograph-wiki-lint");
|
|
198
292
|
}
|
|
199
293
|
console.log(` \u2713 Auto-sync hooks written to ${hooksDir}`);
|
|
200
294
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/bin/installer/hooks.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * KiroGraph Installer \u2014 Kiro hook file management\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { logWarn } from '../../errors';\n\n// \u2500\u2500 Constants \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst HOOK_EXT = '.kiro.hook';\n\n// \u2500\u2500 Hook builders \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction buildWatchmenHook(synthesisMode: 'local' | 'agent'): object {\n if (synthesisMode === 'local') {\n return {\n name: 'KiroGraph Watchmen',\n version: '1.0.0',\n description: 'After memory capture, run local model synthesis if enough observations have accumulated.',\n when: { type: 'agentStop' },\n then: { type: 'runCommand', command: 'kirograph mem watchmen synthesize --quiet 2>&1 || true' },\n };\n }\n return {\n name: 'KiroGraph Watchmen',\n version: '1.0.0',\n description: 'After memory capture, check if enough observations have accumulated. If so, synthesize them into workspace brief files.',\n when: { type: 'agentStop' },\n then: {\n type: 'askAgent',\n prompt: `Check if KiroGraph Watchmen synthesis should run: call kirograph_mem_store with kind='note' and content='watchmen check'. If the response does not include watchmenReady: true, do nothing and stop.\n\nIf watchmenReady: true:\n1. Call kirograph_mem_search for each kind (decision, error, pattern, architecture, note) with limit 20.\n2. Write or update the workspace brief: upsert the ## KiroGraph Watchmen section in each file listed in targetFiles. For .kiro/steering/kirograph-watchmen.md use inclusion: always frontmatter with sections for Decisions, Known Errors & Fixes, Recurring Patterns, and Architecture Notes. For all other files write a compact ## KiroGraph Watchmen block.\n3. Generate skill files: if skillTargetDir is present in the response, identify recurring procedures (any procedure appearing in 3+ observations). For each, write a .kiro/steering/watchmen-<slug>.md file with inclusion: manual frontmatter, a short title, a \"When to use\" line with trigger phrases, and numbered steps. Prefix all generated files with watchmen- so they are distinguishable from hand-written steering files. Remove any .kiro/steering/watchmen-*.md files from previous runs that no longer match current patterns. If skillTargetDir is absent, embed a ## Recurring Procedures section in each targetFile instead, listing each procedure with trigger context and steps.\n4. Store a kind='summary' observation briefly describing what was synthesized (e.g. \"Synthesized 8 observations: updated kirograph-watchmen.md, wrote watchmen-auth-flow.md and watchmen-test-pattern.md\").`,\n },\n };\n}\n\nconst HOOKS: Array<{ filename: string; hook: object }> = [\n {\n filename: `kirograph-sync-if-dirty${HOOK_EXT}`,\n hook: {\n name: 'KiroGraph Sync on Agent Stop',\n version: '1.0.0',\n description: 'Sync the KiroGraph index when the agent stops, picking up any file edits, creates, or deletes from the session.',\n when: { type: 'agentStop' },\n then: { type: 'runCommand', command: 'kirograph sync --quiet 2>&1 > /dev/null' },\n },\n },\n {\n filename: `kirograph-compress-hint${HOOK_EXT}`,\n hook: {\n name: 'KiroGraph Compression Hint',\n version: '1.0.0',\n description: 'Remind the agent to use kirograph_exec for shell commands that benefit from token compression (git, gh, test, lint, build, docker, aws, grep).',\n when: { type: 'preToolUse', toolTypes: ['shell'] },\n then: {\n type: 'askAgent',\n prompt: 'If this shell command is a git operation, GitHub CLI, test runner, linter, build tool, file listing, grep/rg, docker/kubectl, AWS CLI, or package manager command, consider using the kirograph_exec MCP tool instead for 60-90% token savings. The tool compresses output automatically while preserving error details.',\n },\n },\n },\n {\n filename: `kirograph-mem-capture${HOOK_EXT}`,\n hook: {\n name: 'KiroGraph Memory Capture',\n version: '1.0.0',\n description: 'Prompt the agent to store important observations in memory at the end of each session.',\n when: { type: 'agentStop' },\n then: {\n type: 'askAgent',\n prompt: 'Before ending, review what happened in this session. If there were any important decisions, bug root causes, architecture insights, error patterns, or lessons learned, store them using kirograph_mem_store with the appropriate kind (decision, error, pattern, architecture, note). Keep observations concise \u2014 one fact per observation. Skip if nothing noteworthy happened.',\n },\n },\n },\n];\n\n// \u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction ensureDir(p: string): void {\n fs.mkdirSync(p, { recursive: true });\n}\n\nfunction writeJson(p: string, data: unknown): void {\n fs.writeFileSync(p, JSON.stringify(data, null, 2) + '\\n');\n}\n\nfunction migrateOnIdleHooks(hooksDir: string): void {\n if (!fs.existsSync(hooksDir)) return;\n let files: string[];\n try {\n files = fs.readdirSync(hooksDir).filter(f => f.endsWith('.json') || f.endsWith(HOOK_EXT));\n } catch {\n return;\n }\n for (const file of files) {\n const filePath = path.join(hooksDir, file);\n let raw: string;\n try {\n raw = fs.readFileSync(filePath, 'utf8');\n } catch {\n logWarn(`KiroGraph installer: could not read hook file ${filePath}`);\n continue;\n }\n let obj: any;\n try {\n obj = JSON.parse(raw);\n } catch {\n logWarn(`KiroGraph installer: could not parse hook file ${filePath}`);\n continue;\n }\n let changed = false;\n if (obj?.when?.type === 'onIdle') {\n obj.when.type = 'agentStop';\n changed = true;\n }\n // Migrate .json \u2192 .kiro.hook extension\n if (file.endsWith('.json') && file.startsWith('kirograph-')) {\n const newName = file.replace(/\\.json$/, HOOK_EXT);\n const newPath = path.join(hooksDir, newName);\n try {\n fs.writeFileSync(newPath, JSON.stringify(obj, null, 2) + '\\n');\n fs.unlinkSync(filePath);\n } catch {\n logWarn(`KiroGraph installer: could not migrate hook file ${filePath} \u2192 ${newName}`);\n }\n } else if (changed) {\n try {\n fs.writeFileSync(filePath, JSON.stringify(obj, null, 2) + '\\n');\n } catch {\n logWarn(`KiroGraph installer: could not write migrated hook file ${filePath}`);\n }\n }\n }\n}\n\n// \u2500\u2500 Public \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport function writeHooks(kiroDir: string, opts?: { enableCompression?: boolean; enableMemory?: boolean; enableWatchmen?: boolean; watchmenSynthesisMode?: 'local' | 'agent' }): void {\n const hooksDir = path.join(kiroDir, 'hooks');\n ensureDir(hooksDir);\n\n migrateOnIdleHooks(hooksDir);\n\n const oldHooks = [\n 'kirograph-sync-on-save.json', 'kirograph-sync-on-create.json',\n // Legacy .json versions (migrated to .kiro.hook)\n 'kirograph-mark-dirty-on-save.json', 'kirograph-mark-dirty-on-create.json',\n 'kirograph-sync-on-delete.json', 'kirograph-sync-if-dirty.json',\n 'kirograph-compress-hint.json', 'kirograph-mem-capture.json',\n // Removed per-file hooks (consolidated into agentStop sync)\n `kirograph-mark-dirty-on-save${HOOK_EXT}`,\n `kirograph-mark-dirty-on-create${HOOK_EXT}`,\n `kirograph-sync-on-delete${HOOK_EXT}`,\n ];\n for (const old of oldHooks) {\n const p = path.join(hooksDir, old);\n if (fs.existsSync(p)) fs.unlinkSync(p);\n }\n\n for (const { filename, hook } of HOOKS) {\n // Skip compression hook if compression is disabled\n if (filename === `kirograph-compress-hint${HOOK_EXT}` && opts?.enableCompression === false) {\n const p = path.join(hooksDir, filename);\n if (fs.existsSync(p)) fs.unlinkSync(p);\n continue;\n }\n // Skip memory hook if memory is disabled\n if (filename === `kirograph-mem-capture${HOOK_EXT}` && !opts?.enableMemory) {\n const p = path.join(hooksDir, filename);\n if (fs.existsSync(p)) fs.unlinkSync(p);\n continue;\n }\n writeJson(path.join(hooksDir, filename), hook);\n }\n\n // Watchmen hook \u2014 built dynamically based on synthesis mode\n const watchmenHookPath = path.join(hooksDir, `kirograph-watchmen${HOOK_EXT}`);\n if (opts?.enableWatchmen) {\n const mode = opts.watchmenSynthesisMode ?? 'local';\n writeJson(watchmenHookPath, buildWatchmenHook(mode));\n } else {\n if (fs.existsSync(watchmenHookPath)) fs.unlinkSync(watchmenHookPath);\n }\n\n console.log(` \u2713 Auto-sync hooks written to ${hooksDir}`);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * KiroGraph Installer \u2014 Kiro hook file management\n *\n * Generates hooks in BOTH formats for compatibility:\n *\n * v2 (new Kiro IDE): `.kiro/hooks/<id>.json`\n * { \"version\": \"v1\", \"hooks\": [{ \"name\", \"trigger\", \"matcher?\", \"action\": { type, command|prompt } }] }\n *\n * v1 (legacy Kiro IDE): `.kiro/hooks/<id>.kiro.hook`\n * { \"name\", \"version\", \"description\", \"when\": { type, toolTypes? }, \"then\": { type, command|prompt } }\n *\n * Old Kiro ignores .json files; new Kiro ignores .kiro.hook files.\n * Writing both ensures KiroGraph works regardless of which IDE version the user runs.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\n// \u2500\u2500 Constants \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst V2_EXT = '.json';\nconst V1_EXT = '.kiro.hook';\n\n// \u2500\u2500 Hook builders \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\ninterface HookDef {\n id: string;\n description: string;\n v2: object; // new Kiro IDE format\n v1: object; // legacy Kiro IDE format\n}\n\nfunction buildWatchmenHook(synthesisMode: 'local' | 'agent'): HookDef {\n if (synthesisMode === 'local') {\n return {\n id: 'kirograph-watchmen',\n description: 'After memory capture, run local model synthesis if enough observations have accumulated.',\n v2: {\n version: 'v1',\n hooks: [{\n name: 'KiroGraph Watchmen',\n trigger: 'Stop',\n action: { type: 'command', command: 'kirograph mem watchmen synthesize --quiet 2>&1 || true' },\n }],\n },\n v1: {\n name: 'KiroGraph Watchmen',\n version: '1.0.0',\n description: 'After memory capture, run local model synthesis if enough observations have accumulated.',\n when: { type: 'agentStop' },\n then: { type: 'runCommand', command: 'kirograph mem watchmen synthesize --quiet 2>&1 || true' },\n },\n };\n }\n\n const watchmenPrompt = `Check if KiroGraph Watchmen synthesis should run: call kirograph_mem_store with kind='note' and content='watchmen check'. If the response does not include watchmenReady: true, do nothing and stop.\n\nIf watchmenReady: true:\n1. Call kirograph_mem_search for each kind (decision, error, pattern, architecture, note) with limit 20.\n2. Write or update the workspace brief: upsert the ## KiroGraph Watchmen section in each file listed in targetFiles. For .kiro/steering/kirograph-watchmen.md use inclusion: always frontmatter with sections for Decisions, Known Errors & Fixes, Recurring Patterns, and Architecture Notes. For all other files write a compact ## KiroGraph Watchmen block.\n3. Generate skill files: if skillTargetDir is present in the response, identify recurring procedures (any procedure appearing in 3+ observations). For each, write a .kiro/steering/watchmen-<slug>.md file with inclusion: manual frontmatter, a short title, a \"When to use\" line with trigger phrases, and numbered steps. Prefix all generated files with watchmen- so they are distinguishable from hand-written steering files. Remove any .kiro/steering/watchmen-*.md files from previous runs that no longer match current patterns. If skillTargetDir is absent, embed a ## Recurring Procedures section in each targetFile instead, listing each procedure with trigger context and steps.\n4. Store a kind='summary' observation briefly describing what was synthesized (e.g. \"Synthesized 8 observations: updated kirograph-watchmen.md, wrote watchmen-auth-flow.md and watchmen-test-pattern.md\").`;\n\n return {\n id: 'kirograph-watchmen',\n description: 'After memory capture, check if enough observations have accumulated. If so, synthesize them into workspace brief files.',\n v2: {\n version: 'v1',\n hooks: [{\n name: 'KiroGraph Watchmen',\n trigger: 'Stop',\n action: { type: 'agent', prompt: watchmenPrompt },\n }],\n },\n v1: {\n name: 'KiroGraph Watchmen',\n version: '1.0.0',\n description: 'After memory capture, check if enough observations have accumulated. If so, synthesize them into workspace brief files.',\n when: { type: 'agentStop' },\n then: { type: 'askAgent', prompt: watchmenPrompt },\n },\n };\n}\n\nconst HOOKS: HookDef[] = [\n {\n id: 'kirograph-sync-if-dirty',\n description: 'Sync the KiroGraph index when the agent stops, picking up any file edits, creates, or deletes from the session.',\n v2: {\n version: 'v1',\n hooks: [{\n name: 'KiroGraph Sync on Agent Stop',\n trigger: 'Stop',\n action: { type: 'command', command: 'kirograph sync --quiet 2>&1 > /dev/null' },\n }],\n },\n v1: {\n name: 'KiroGraph Sync on Agent Stop',\n version: '1.0.0',\n description: 'Sync the KiroGraph index when the agent stops, picking up any file edits, creates, or deletes from the session.',\n when: { type: 'agentStop' },\n then: { type: 'runCommand', command: 'kirograph sync --quiet 2>&1 > /dev/null' },\n },\n },\n {\n id: 'kirograph-compress-hint',\n description: 'Remind the agent to use kirograph_exec for shell commands that benefit from token compression.',\n v2: {\n version: 'v1',\n hooks: [{\n name: 'KiroGraph Compression Hint',\n trigger: 'PreToolUse',\n matcher: 'execute_bash',\n action: {\n type: 'agent',\n prompt: 'If this shell command is a git operation, GitHub CLI, test runner, linter, build tool, file listing, grep/rg, docker/kubectl, AWS CLI, or package manager command, consider using the kirograph_exec MCP tool instead for 60-90% token savings. The tool compresses output automatically while preserving error details.',\n },\n }],\n },\n v1: {\n name: 'KiroGraph Compression Hint',\n version: '1.0.0',\n description: 'Remind the agent to use kirograph_exec for shell commands that benefit from token compression.',\n when: { type: 'preToolUse', toolTypes: ['shell'] },\n then: {\n type: 'askAgent',\n prompt: 'If this shell command is a git operation, GitHub CLI, test runner, linter, build tool, file listing, grep/rg, docker/kubectl, AWS CLI, or package manager command, consider using the kirograph_exec MCP tool instead for 60-90% token savings. The tool compresses output automatically while preserving error details.',\n },\n },\n },\n {\n id: 'kirograph-mem-capture',\n description: 'Prompt the agent to store important observations in memory at the end of each session.',\n v2: {\n version: 'v1',\n hooks: [{\n name: 'KiroGraph Memory Capture',\n trigger: 'Stop',\n action: {\n type: 'agent',\n prompt: 'Before ending, review what happened in this session. If there were any important decisions, bug root causes, architecture insights, error patterns, or lessons learned, store them using kirograph_mem_store with the appropriate kind (decision, error, pattern, architecture, note). Keep observations concise \u2014 one fact per observation. Skip if nothing noteworthy happened.',\n },\n }],\n },\n v1: {\n name: 'KiroGraph Memory Capture',\n version: '1.0.0',\n description: 'Prompt the agent to store important observations in memory at the end of each session.',\n when: { type: 'agentStop' },\n then: {\n type: 'askAgent',\n prompt: 'Before ending, review what happened in this session. If there were any important decisions, bug root causes, architecture insights, error patterns, or lessons learned, store them using kirograph_mem_store with the appropriate kind (decision, error, pattern, architecture, note). Keep observations concise \u2014 one fact per observation. Skip if nothing noteworthy happened.',\n },\n },\n },\n];\n\n// \u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction ensureDir(p: string): void {\n fs.mkdirSync(p, { recursive: true });\n}\n\nfunction writeJson(p: string, data: unknown): void {\n fs.writeFileSync(p, JSON.stringify(data, null, 2) + '\\n');\n}\n\n/** Write a hook in both v2 (.json) and v1 (.kiro.hook) formats */\nfunction writeHookDual(hooksDir: string, def: HookDef): void {\n writeJson(path.join(hooksDir, `${def.id}${V2_EXT}`), def.v2);\n writeJson(path.join(hooksDir, `${def.id}${V1_EXT}`), def.v1);\n}\n\n/** Write a hook in the specified format only, removing the other */\nfunction writeHookForFormat(hooksDir: string, def: HookDef, format: KiroHookFormat): void {\n if (format === 'v2') {\n writeJson(path.join(hooksDir, `${def.id}${V2_EXT}`), def.v2);\n // Remove legacy file if it exists\n const legacyPath = path.join(hooksDir, `${def.id}${V1_EXT}`);\n if (fs.existsSync(legacyPath)) fs.unlinkSync(legacyPath);\n } else {\n writeJson(path.join(hooksDir, `${def.id}${V1_EXT}`), def.v1);\n // Remove v2 file if it exists\n const v2Path = path.join(hooksDir, `${def.id}${V2_EXT}`);\n if (fs.existsSync(v2Path)) fs.unlinkSync(v2Path);\n }\n}\n\n/** Remove both format files for a given hook id */\nfunction removeHookDual(hooksDir: string, id: string): void {\n for (const ext of [V2_EXT, V1_EXT]) {\n const p = path.join(hooksDir, `${id}${ext}`);\n if (fs.existsSync(p)) fs.unlinkSync(p);\n }\n}\n\n// \u2500\u2500 Public \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport type KiroHookFormat = 'v1-legacy' | 'v2';\n\nexport function writeHooks(kiroDir: string, opts?: { enableCompression?: boolean; enableMemory?: boolean; enableWatchmen?: boolean; watchmenSynthesisMode?: 'local' | 'agent'; enableWiki?: boolean; wikiSynthesisMode?: 'local' | 'agent'; wikiLintFrequency?: number; kiroHookFormat?: KiroHookFormat }): void {\n const hooksDir = path.join(kiroDir, 'hooks');\n ensureDir(hooksDir);\n\n const format = opts?.kiroHookFormat ?? 'v2';\n\n // Remove obsolete hook files from earlier versions\n const obsoleteFiles = [\n 'kirograph-sync-on-save.json', 'kirograph-sync-on-create.json',\n 'kirograph-mark-dirty-on-save.json', 'kirograph-mark-dirty-on-create.json',\n 'kirograph-sync-on-delete.json',\n 'kirograph-mark-dirty-on-save.kiro.hook',\n 'kirograph-mark-dirty-on-create.kiro.hook',\n 'kirograph-sync-on-delete.kiro.hook',\n ];\n for (const old of obsoleteFiles) {\n const p = path.join(hooksDir, old);\n if (fs.existsSync(p)) fs.unlinkSync(p);\n }\n\n for (const def of HOOKS) {\n // Skip compression hook if compression is disabled\n if (def.id === 'kirograph-compress-hint' && opts?.enableCompression === false) {\n removeHookDual(hooksDir, def.id);\n continue;\n }\n // Skip memory hook if memory is disabled\n if (def.id === 'kirograph-mem-capture' && !opts?.enableMemory) {\n removeHookDual(hooksDir, def.id);\n continue;\n }\n writeHookForFormat(hooksDir, def, format);\n }\n\n // Watchmen hook \u2014 built dynamically based on synthesis mode\n if (opts?.enableWatchmen) {\n const mode = opts.watchmenSynthesisMode ?? 'local';\n writeHookForFormat(hooksDir, buildWatchmenHook(mode), format);\n } else {\n removeHookDual(hooksDir, 'kirograph-watchmen');\n }\n\n // Wiki hooks \u2014 ingest trigger + periodic lint\n if (opts?.enableWiki) {\n const lintFreq = opts.wikiLintFrequency ?? 10;\n const wikiMode = opts.wikiSynthesisMode ?? 'agent';\n\n const wikiIngestPrompt = `If this session produced durable knowledge (design decisions, architecture insights, API contracts, process steps, domain facts), consider updating the wiki:\n1. Call kirograph_wiki_ingest with the key findings as source text.\n2. The tool returns a structured prompt. Pass it to yourself to generate a WIKI_DIFF.\n3. Call kirograph_wiki_apply_diff with your generated diff.\nSkip if the session was trivial (simple bug fix, no new knowledge).`;\n\n if (wikiMode === 'local') {\n writeHookForFormat(hooksDir, {\n id: 'kirograph-wiki-ingest',\n description: 'After each session, run local-model wiki synthesis over queued sources.',\n v2: {\n version: 'v1',\n hooks: [{\n name: 'KiroGraph Wiki Synthesize',\n trigger: 'Stop',\n action: { type: 'command', command: 'kirograph wiki synthesize --quiet 2>&1 || true' },\n }],\n },\n v1: {\n name: 'KiroGraph Wiki Synthesize',\n version: '1.0.0',\n description: 'After each session, run local-model wiki synthesis over queued sources.',\n when: { type: 'agentStop' },\n then: { type: 'runCommand', command: 'kirograph wiki synthesize --quiet 2>&1 || true' },\n },\n }, format);\n } else {\n writeHookForFormat(hooksDir, {\n id: 'kirograph-wiki-ingest',\n description: 'At the end of each session, prompt the agent to ingest any relevant knowledge into the wiki.',\n v2: {\n version: 'v1',\n hooks: [{\n name: 'KiroGraph Wiki Ingest',\n trigger: 'Stop',\n action: { type: 'agent', prompt: wikiIngestPrompt },\n }],\n },\n v1: {\n name: 'KiroGraph Wiki Ingest',\n version: '1.0.0',\n description: 'At the end of each session, prompt the agent to ingest any relevant knowledge into the wiki.',\n when: { type: 'agentStop' },\n then: { type: 'askAgent', prompt: wikiIngestPrompt },\n },\n }, format);\n }\n\n writeHookForFormat(hooksDir, {\n id: 'kirograph-wiki-lint',\n description: `Run wiki health check every ${lintFreq} sessions to catch broken links, orphan pages, and contradictions.`,\n v2: {\n version: 'v1',\n hooks: [{\n name: 'KiroGraph Wiki Lint',\n trigger: 'Stop',\n action: { type: 'command', command: 'kirograph wiki lint 2>&1 || true' },\n }],\n },\n v1: {\n name: 'KiroGraph Wiki Lint',\n version: '1.0.0',\n description: `Run wiki health check every ${lintFreq} sessions to catch broken links, orphan pages, and contradictions.`,\n when: { type: 'agentStop' },\n then: { type: 'runCommand', command: 'kirograph wiki lint 2>&1 || true' },\n },\n }, format);\n } else {\n removeHookDual(hooksDir, 'kirograph-wiki-ingest');\n removeHookDual(hooksDir, 'kirograph-wiki-lint');\n }\n\n console.log(` \u2713 Auto-sync hooks written to ${hooksDir}`);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,SAAoB;AACpB,WAAsB;AAItB,MAAM,SAAS;AACf,MAAM,SAAS;AAWf,SAAS,kBAAkB,eAA2C;AACpE,MAAI,kBAAkB,SAAS;AAC7B,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,aAAa;AAAA,MACb,IAAI;AAAA,QACF,SAAS;AAAA,QACT,OAAO,CAAC;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,QAAQ,EAAE,MAAM,WAAW,SAAS,yDAAyD;AAAA,QAC/F,CAAC;AAAA,MACH;AAAA,MACA,IAAI;AAAA,QACF,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,QACb,MAAM,EAAE,MAAM,YAAY;AAAA,QAC1B,MAAM,EAAE,MAAM,cAAc,SAAS,yDAAyD;AAAA,MAChG;AAAA,IACF;AA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