kirograph 0.15.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +114 -1
  3. package/dist/bin/commands/docs.js +357 -0
  4. package/dist/bin/commands/docs.js.map +7 -0
  5. package/dist/bin/installer/config-prompt.js +17 -1
  6. package/dist/bin/installer/config-prompt.js.map +2 -2
  7. package/dist/bin/installer/index.js +6 -1
  8. package/dist/bin/installer/index.js.map +2 -2
  9. package/dist/bin/installer/steering.js +21 -0
  10. package/dist/bin/installer/steering.js.map +2 -2
  11. package/dist/bin/installer/targets/index.js.map +1 -1
  12. package/dist/bin/installer/targets/kiro.js +2 -2
  13. package/dist/bin/installer/targets/kiro.js.map +2 -2
  14. package/dist/bin/kirograph.js +3 -1
  15. package/dist/bin/kirograph.js.map +3 -3
  16. package/dist/compression/naive-cost.js +19 -0
  17. package/dist/compression/naive-cost.js.map +2 -2
  18. package/dist/compression/tracker.js +11 -2
  19. package/dist/compression/tracker.js.map +2 -2
  20. package/dist/compression/types.js.map +1 -1
  21. package/dist/config.js +34 -1
  22. package/dist/config.js.map +2 -2
  23. package/dist/core/pipeline.js +23 -0
  24. package/dist/core/pipeline.js.map +2 -2
  25. package/dist/db/database.js +11 -0
  26. package/dist/db/database.js.map +2 -2
  27. package/dist/db/docs-schema.sql +50 -0
  28. package/dist/docs/formats/asciidoc.js +108 -0
  29. package/dist/docs/formats/asciidoc.js.map +7 -0
  30. package/dist/docs/formats/html.js +100 -0
  31. package/dist/docs/formats/html.js.map +7 -0
  32. package/dist/docs/formats/index.js +81 -0
  33. package/dist/docs/formats/index.js.map +7 -0
  34. package/dist/docs/formats/markdown.js +146 -0
  35. package/dist/docs/formats/markdown.js.map +7 -0
  36. package/dist/docs/formats/openapi.js +228 -0
  37. package/dist/docs/formats/openapi.js.map +7 -0
  38. package/dist/docs/formats/org.js +117 -0
  39. package/dist/docs/formats/org.js.map +7 -0
  40. package/dist/docs/formats/plaintext.js +119 -0
  41. package/dist/docs/formats/plaintext.js.map +7 -0
  42. package/dist/docs/formats/rdoc.js +105 -0
  43. package/dist/docs/formats/rdoc.js.map +7 -0
  44. package/dist/docs/formats/rst.js +121 -0
  45. package/dist/docs/formats/rst.js.map +7 -0
  46. package/dist/docs/indexer.js +340 -0
  47. package/dist/docs/indexer.js.map +7 -0
  48. package/dist/docs/linker.js +151 -0
  49. package/dist/docs/linker.js.map +7 -0
  50. package/dist/docs/lint.js +92 -0
  51. package/dist/docs/lint.js.map +7 -0
  52. package/dist/docs/queries.js +295 -0
  53. package/dist/docs/queries.js.map +7 -0
  54. package/dist/docs/section-id.js +57 -0
  55. package/dist/docs/section-id.js.map +7 -0
  56. package/dist/docs/summarizer.js +55 -0
  57. package/dist/docs/summarizer.js.map +7 -0
  58. package/dist/docs/types.js +17 -0
  59. package/dist/docs/types.js.map +7 -0
  60. package/dist/docs/vectors.js +217 -0
  61. package/dist/docs/vectors.js.map +7 -0
  62. package/dist/mcp/tool-names.js +6 -1
  63. package/dist/mcp/tool-names.js.map +2 -2
  64. package/dist/mcp/tools.js +245 -1
  65. package/dist/mcp/tools.js.map +2 -2
  66. package/package.json +1 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Davide De Sio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -82,7 +82,7 @@ See the [Architecture Analysis](#architecture-analysis-opt-in-1) section below f
82
82
 
83
83
  ### Memory (opt-in)
84
84
 
85
- When `enableMemory: true` is set, KiroGraph stores persistent observations across sessions — decisions, errors, patterns, and architecture notes. Observations are:
85
+ When `enableMemory: true` is set, KiroGraph stores persistent observations across sessions — decisions, errors, patterns, and architecture notes. Inspired by [cavemem](https://github.com/JuliusBrussee/cavemem) by [Julius Brussee](https://www.linkedin.com/in/julius-brussee/). Observations are:
86
86
 
87
87
  - **Compressed** with the caveman grammar (if caveman mode is enabled) — deterministic, no LLM tokens spent
88
88
  - **Linked to code symbols** — identifiers in observation text are matched against the graph and stored as stable `qualified_name` references
@@ -103,6 +103,26 @@ Enable via `kirograph install` or directly in `.kirograph/config.json`:
103
103
 
104
104
  See the [Memory](#memory-requires-enablememory-true) section below for full details.
105
105
 
106
+ ### Documentation indexing (opt-in)
107
+
108
+ When `enableDocs: true` is set, KiroGraph indexes project documentation by heading hierarchy and section structure. Instead of reading entire doc files, agents retrieve exactly the section they need via stable section IDs. Inspired by [jDocMunch-MCP](https://github.com/jgravelle/jdocmunch-mcp) by [J. Gravelle](https://www.linkedin.com/in/j-gravelle-2778223/).
109
+
110
+ - **9 format parsers**: Markdown, MDX, reStructuredText, AsciiDoc, RDoc, Org-mode, HTML, plain text, OpenAPI/Swagger
111
+ - **Code ↔ docs cross-references**: Backtick references, CamelCase identifiers, and snake_case patterns in docs are resolved against the code graph
112
+ - **Section-level FTS search**: Independent from code search (`kirograph_docs_search`)
113
+ - **Stable section IDs**: `{file_path}::{ancestor-chain/slug}#{level}` — stable across re-indexing
114
+ - **Token savings**: 92–97% reduction vs reading full doc files (tracked in `kirograph_gain`)
115
+
116
+ Enable via `kirograph install` or directly in `.kirograph/config.json`:
117
+
118
+ ```json
119
+ {
120
+ "enableDocs": true
121
+ }
122
+ ```
123
+
124
+ See the [Documentation](#documentation-requires-enabledocs-true) section below for full details.
125
+
106
126
  ## Installation
107
127
 
108
128
  ### From npm (not yet available on npm registry)
@@ -597,6 +617,56 @@ Memory subsystem health: session count, observations, embedding coverage, model
597
617
  |-----------|------|---------|-------------|
598
618
  | `projectPath` | string | cwd | Project root path |
599
619
 
620
+ ### `kirograph_docs_toc` *(requires `enableDocs: true`)*
621
+
622
+ Get table of contents for a documentation file or the whole project. Returns section IDs, titles, levels, and summaries.
623
+
624
+ | Parameter | Type | Default | Description |
625
+ |-----------|------|---------|-------------|
626
+ | `file` | string | - | Filter to a specific doc file (relative path). Omit for project-wide TOC. |
627
+ | `tree` | boolean | false | Return nested tree structure |
628
+ | `projectPath` | string | cwd | Project root path |
629
+
630
+ ### `kirograph_docs_search` *(requires `enableDocs: true`)*
631
+
632
+ Search documentation sections by query. Returns matching sections ranked by relevance. Independent from `kirograph_search` (code-only).
633
+
634
+ | Parameter | Type | Default | Description |
635
+ |-----------|------|---------|-------------|
636
+ | `query` | string | required | Search query (natural language or keywords) |
637
+ | `file` | string | - | Narrow search to a specific doc file |
638
+ | `limit` | number | 10 | Max results |
639
+ | `projectPath` | string | cwd | Project root path |
640
+
641
+ ### `kirograph_docs_section` *(requires `enableDocs: true`)*
642
+
643
+ Retrieve full content of a documentation section by its stable ID. Use `context=true` to also get ancestor headings and child summaries.
644
+
645
+ | Parameter | Type | Default | Description |
646
+ |-----------|------|---------|-------------|
647
+ | `id` | string | required | Section ID (from `kirograph_docs_toc` or `kirograph_docs_search` results) |
648
+ | `context` | boolean | false | Include ancestor heading chain and child summaries |
649
+ | `projectPath` | string | cwd | Project root path |
650
+
651
+ ### `kirograph_docs_outline` *(requires `enableDocs: true`)*
652
+
653
+ Get the heading hierarchy for a single documentation file. Lighter than full TOC when you know which file is relevant.
654
+
655
+ | Parameter | Type | Default | Description |
656
+ |-----------|------|---------|-------------|
657
+ | `file` | string | required | Relative path to the doc file |
658
+ | `projectPath` | string | cwd | Project root path |
659
+
660
+ ### `kirograph_docs_refs` *(requires `enableDocs: true`)*
661
+
662
+ Find code symbols referenced by a doc section, or doc sections that reference a code symbol. Bidirectional lookup.
663
+
664
+ | Parameter | Type | Default | Description |
665
+ |-----------|------|---------|-------------|
666
+ | `sectionId` | string | - | Doc section ID (find code symbols it references) |
667
+ | `nodeId` | string | - | Code symbol qualified name (find doc sections that reference it) |
668
+ | `projectPath` | string | cwd | Project root path |
669
+
600
670
  ## CLI Reference
601
671
 
602
672
  ### Setup
@@ -725,6 +795,8 @@ Caveman mode never touches code blocks, file paths, URLs, or technical terms, on
725
795
 
726
796
  ### Shell Compression (`kirograph_exec`)
727
797
 
798
+ ![KiroGraph caveman](https://raw.githubusercontent.com/davide-desio-eleva/kirograph/main/assets/rtk.png)
799
+
728
800
  KiroGraph includes a built-in shell compression engine inspired by [rtk](https://github.com/rtk-ai/rtk). The `kirograph_exec` MCP tool runs shell commands and returns token-optimized output, saving 60-90% of tokens on verbose commands like git, test runners, linters, and build tools.
729
801
 
730
802
  **Why it's useful:** LLM context is expensive. A raw `git status` might be 2,000 tokens; compressed it's 200. A passing test suite might be 25,000 tokens of noise; compressed it's a single "PASSED: 42/42 tests" line. The compression engine knows how to extract the signal from each command family.
@@ -1038,6 +1110,42 @@ kirograph mem lint --fix # auto-repair issues
1038
1110
 
1039
1111
  **How observations surface:** `kirograph_context` and `kirograph_impact` automatically include relevant memory observations (max 3, above relevance threshold 0.3) when memory is enabled. No extra tool call needed.
1040
1112
 
1113
+ ### Documentation *(requires `enableDocs: true`)*
1114
+
1115
+ Section-level documentation navigation — search, browse, and retrieve doc sections from the CLI.
1116
+
1117
+ ```bash
1118
+ # Table of contents
1119
+ kirograph docs toc # whole project
1120
+ kirograph docs toc README.md # single file
1121
+ kirograph docs toc README.md --tree # nested tree structure
1122
+ kirograph docs toc --json # JSON output
1123
+
1124
+ # Search (mirrors kirograph_docs_search)
1125
+ kirograph docs search "authentication"
1126
+ kirograph docs search "config" --file docs/guide.md
1127
+ kirograph docs search "install" --limit 5
1128
+
1129
+ # Retrieve a section (mirrors kirograph_docs_section)
1130
+ kirograph docs section "README.md::installation#1"
1131
+ kirograph docs section "README.md::installation#1" --context
1132
+
1133
+ # Outline (mirrors kirograph_docs_outline)
1134
+ kirograph docs outline docs/api.md
1135
+
1136
+ # Cross-references (mirrors kirograph_docs_refs)
1137
+ kirograph docs refs "docs/auth.md::oauth/token-refresh#2"
1138
+
1139
+ # Maintenance
1140
+ kirograph docs reindex # force full re-index
1141
+ kirograph docs lint # health checks (broken refs, stale sections)
1142
+ kirograph docs reembed # re-embed with current model
1143
+ ```
1144
+
1145
+ **How sections are identified:** Each section gets a stable ID in the format `{file_path}::{ancestor-chain/slug}#{level}`. IDs remain stable across re-indexing as long as the file path, heading text, heading level, and parent chain don't change.
1146
+
1147
+ **How code linking works:** When `docsLinkCode: true` (default), the indexer scans section content for backtick references (`` `functionName` ``), CamelCase identifiers, and snake_case patterns, then resolves them against the code graph. Matches are stored as `doc_code_refs` using `qualified_name` (stable across reindex).
1148
+
1041
1149
  ### Graph Export
1042
1150
 
1043
1151
  Export the full graph as an interactive dashboard. three files served from a local directory, no server required, works offline.
@@ -1556,6 +1664,11 @@ Detected frameworks are stored in config and used to improve symbol extraction a
1556
1664
 
1557
1665
  KiroGraph is inspired by [CodeGraph](https://github.com/colbymchenry/codegraph) by [Colby McHenry](https://www.linkedin.com/in/colby-mchenry/). the original concept of building a semantic code graph for AI coding agents comes from his work.
1558
1666
 
1667
+ ### Inspirations
1668
+
1669
+ - [cavemem](https://github.com/JuliusBrussee/cavemem) by [Julius Brussee](https://www.linkedin.com/in/julius-brussee/): the memory module's hook-based observation capture, deterministic compression, and SQLite storage pattern.
1670
+ - [jDocMunch-MCP](https://github.com/jgravelle/jdocmunch-mcp) by [J. Gravelle](https://www.linkedin.com/in/j-gravelle-2778223/): the documentation module's section-first retrieval approach, stable section IDs, and byte-offset addressing.
1671
+
1559
1672
  ### Contributors
1560
1673
 
1561
1674
  - [Alessandro Franceschi](https://www.linkedin.com/in/alessandrofranceschi/). Claude Code and Codex integration, Elixir/Phoenix language and framework support.
@@ -0,0 +1,357 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var docs_exports = {};
20
+ __export(docs_exports, {
21
+ register: () => register
22
+ });
23
+ module.exports = __toCommonJS(docs_exports);
24
+ var import_config = require("../../config");
25
+ var import_ui = require("../ui");
26
+ function safeCloseAndExit(cg, code = 0) {
27
+ try {
28
+ cg.close();
29
+ } catch {
30
+ }
31
+ try {
32
+ const fs = require("fs");
33
+ if (process.stdout.writableEnded === false) process.stdout.write("");
34
+ if (process.stderr.writableEnded === false) process.stderr.write("");
35
+ fs.closeSync(2);
36
+ fs.closeSync(1);
37
+ } catch {
38
+ }
39
+ process.exit(code);
40
+ }
41
+ function register(program) {
42
+ const docs = program.command("docs").description("Documentation navigation (requires enableDocs: true)");
43
+ docs.command("toc [file]").description("Print table of contents for a file or the whole project").option("--tree", "Show nested tree structure").option("--json", "Output as JSON").action(async (file, opts) => {
44
+ const cwd = process.cwd();
45
+ const config = await (0, import_config.loadConfig)(cwd);
46
+ if (!config.enableDocs) {
47
+ console.error(` \u2716 Documentation indexing is not enabled. Set ${import_ui.violet}${import_ui.bold}enableDocs: true${import_ui.reset} in .kirograph/config.json`);
48
+ console.error(` ${import_ui.dim}Then re-run:${import_ui.reset} ${import_ui.violet}${import_ui.bold}kirograph index${import_ui.reset}`);
49
+ process.exit(1);
50
+ }
51
+ const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
52
+ if (!KiroGraph.isInitialized(cwd)) {
53
+ console.error(" \u2716 KiroGraph not initialized. Run: kirograph init");
54
+ process.exit(1);
55
+ }
56
+ const cg = await KiroGraph.open(cwd);
57
+ const db = cg.getDatabase();
58
+ db.applyDocsSchema();
59
+ const { DocsQueries } = await Promise.resolve().then(() => require("../../docs/queries.js"));
60
+ const queries = new DocsQueries(db.getRawDb(), cwd);
61
+ const toc = queries.getToc({ file, tree: opts.tree });
62
+ if (toc.length === 0) {
63
+ console.log(` ${import_ui.dim}No documentation sections found.${import_ui.reset} Run ${import_ui.violet}${import_ui.bold}kirograph index${import_ui.reset} first.`);
64
+ cg.close();
65
+ return;
66
+ }
67
+ if (opts.json) {
68
+ console.log(JSON.stringify(toc, null, 2));
69
+ } else {
70
+ for (const entry of toc) {
71
+ const prefix = "#".repeat(entry.level || 1);
72
+ const summary = entry.summary ? ` ${import_ui.dim}\u2014 ${entry.summary}${import_ui.reset}` : "";
73
+ console.log(` ${prefix} ${import_ui.bold}${entry.title}${import_ui.reset}${summary}`);
74
+ console.log(` ${import_ui.dim}${entry.id}${import_ui.reset}`);
75
+ }
76
+ }
77
+ cg.close();
78
+ });
79
+ docs.command("search <query>").description("Search documentation sections").option("--file <path>", "Narrow search to a specific file").option("--limit <n>", "Max results", "10").option("--json", "Output as JSON").action(async (query, opts) => {
80
+ const cwd = process.cwd();
81
+ const config = await (0, import_config.loadConfig)(cwd);
82
+ if (!config.enableDocs) {
83
+ console.error(` \u2716 Documentation indexing is not enabled. Set ${import_ui.violet}${import_ui.bold}enableDocs: true${import_ui.reset} in .kirograph/config.json`);
84
+ process.exit(1);
85
+ }
86
+ const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
87
+ if (!KiroGraph.isInitialized(cwd)) {
88
+ console.error(" \u2716 KiroGraph not initialized.");
89
+ process.exit(1);
90
+ }
91
+ const cg = await KiroGraph.open(cwd);
92
+ const db = cg.getDatabase();
93
+ db.applyDocsSchema();
94
+ const { DocsQueries } = await Promise.resolve().then(() => require("../../docs/queries.js"));
95
+ const queries = new DocsQueries(db.getRawDb(), cwd, config);
96
+ const results = await queries.searchSections(query, { file: opts.file, limit: parseInt(opts.limit ?? "10", 10) });
97
+ if (results.length === 0) {
98
+ console.log(` ${import_ui.dim}No sections found matching "${query}".${import_ui.reset}`);
99
+ cg.close();
100
+ return;
101
+ }
102
+ if (opts.json) {
103
+ console.log(JSON.stringify(results, null, 2));
104
+ } else {
105
+ for (const r of results) {
106
+ const summary = r.section.summary ? `
107
+ ${import_ui.dim}${r.section.summary}${import_ui.reset}` : "";
108
+ console.log(` ${import_ui.green}\u25CF${import_ui.reset} ${import_ui.bold}${r.section.title}${import_ui.reset} ${import_ui.dim}[${r.section.filePath}]${import_ui.reset}${summary}`);
109
+ console.log(` ${import_ui.dim}ID: ${r.section.id}${import_ui.reset}`);
110
+ }
111
+ }
112
+ cg.close();
113
+ });
114
+ docs.command("section <id>").description("Print full content of a section by ID").option("--context", "Include ancestor headings and child summaries").action(async (id, opts) => {
115
+ const cwd = process.cwd();
116
+ const config = await (0, import_config.loadConfig)(cwd);
117
+ if (!config.enableDocs) {
118
+ console.error(` \u2716 Documentation indexing is not enabled. Set ${import_ui.violet}${import_ui.bold}enableDocs: true${import_ui.reset} in .kirograph/config.json`);
119
+ process.exit(1);
120
+ }
121
+ const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
122
+ if (!KiroGraph.isInitialized(cwd)) {
123
+ console.error(" \u2716 KiroGraph not initialized.");
124
+ process.exit(1);
125
+ }
126
+ const cg = await KiroGraph.open(cwd);
127
+ const db = cg.getDatabase();
128
+ db.applyDocsSchema();
129
+ const { DocsQueries } = await Promise.resolve().then(() => require("../../docs/queries.js"));
130
+ const queries = new DocsQueries(db.getRawDb(), cwd);
131
+ const result = queries.getSection(id, { context: opts.context });
132
+ if (!result) {
133
+ const rawDb = db.getRawDb();
134
+ const idParts = id.split("::");
135
+ const filePath = idParts[0] ?? "";
136
+ const searchSlug = (idParts[1] ?? "").replace(/#\d+$/, "").split("/").pop() ?? "";
137
+ let suggestions = [];
138
+ if (searchSlug) {
139
+ suggestions = rawDb.all(
140
+ `SELECT id, title FROM doc_sections WHERE file_path = ? AND id LIKE ? LIMIT 5`,
141
+ [filePath, `%${searchSlug}%`]
142
+ );
143
+ }
144
+ if (suggestions.length === 0 && filePath) {
145
+ suggestions = rawDb.all(
146
+ `SELECT id, title FROM doc_sections WHERE file_path = ? ORDER BY position LIMIT 5`,
147
+ [filePath]
148
+ );
149
+ }
150
+ console.error(` \u2716 Section "${id}" not found.`);
151
+ if (suggestions.length > 0) {
152
+ console.error(`
153
+ ${import_ui.dim}Did you mean:${import_ui.reset}`);
154
+ for (const s of suggestions) {
155
+ console.error(` ${s.id} ${import_ui.dim}(${s.title})${import_ui.reset}`);
156
+ }
157
+ } else {
158
+ console.error(`
159
+ ${import_ui.dim}Use ${import_ui.violet}kirograph docs toc${import_ui.reset}${import_ui.dim} to list available section IDs.${import_ui.reset}`);
160
+ }
161
+ safeCloseAndExit(cg, 1);
162
+ }
163
+ if (result.ancestors?.length) {
164
+ console.log(` ${import_ui.dim}${result.ancestors.map((a) => a.title).join(" > ")} > ${result.section.title}${import_ui.reset}
165
+ `);
166
+ }
167
+ console.log(result.content);
168
+ if (result.children?.length) {
169
+ console.log(`
170
+ ${import_ui.dim}Child sections:${import_ui.reset}`);
171
+ for (const child of result.children) {
172
+ const summary = child.summary ? ` \u2014 ${child.summary}` : "";
173
+ console.log(` ${import_ui.dim}\u2022${import_ui.reset} ${child.title}${summary}`);
174
+ }
175
+ }
176
+ cg.close();
177
+ });
178
+ docs.command("outline <file>").description("Print heading hierarchy for a document").action(async (file) => {
179
+ const cwd = process.cwd();
180
+ const config = await (0, import_config.loadConfig)(cwd);
181
+ if (!config.enableDocs) {
182
+ console.error(` \u2716 Documentation indexing is not enabled. Set ${import_ui.violet}${import_ui.bold}enableDocs: true${import_ui.reset} in .kirograph/config.json`);
183
+ process.exit(1);
184
+ }
185
+ const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
186
+ if (!KiroGraph.isInitialized(cwd)) {
187
+ console.error(" \u2716 KiroGraph not initialized.");
188
+ process.exit(1);
189
+ }
190
+ const cg = await KiroGraph.open(cwd);
191
+ const db = cg.getDatabase();
192
+ db.applyDocsSchema();
193
+ const { DocsQueries } = await Promise.resolve().then(() => require("../../docs/queries.js"));
194
+ const queries = new DocsQueries(db.getRawDb(), cwd);
195
+ const outline = queries.getOutline(file);
196
+ if (outline.length === 0) {
197
+ console.log(` ${import_ui.dim}No sections found in "${file}".${import_ui.reset}`);
198
+ cg.close();
199
+ return;
200
+ }
201
+ console.log(`
202
+ ${import_ui.bold}${file}${import_ui.reset}
203
+ `);
204
+ const render = (entries, indent) => {
205
+ for (const entry of entries) {
206
+ const summary = entry.summary ? ` ${import_ui.dim}\u2014 ${entry.summary}${import_ui.reset}` : "";
207
+ console.log(`${indent} ${"#".repeat(entry.level || 1)} ${entry.title}${summary}`);
208
+ if (entry.children?.length) render(entry.children, indent + " ");
209
+ }
210
+ };
211
+ render(outline, "");
212
+ cg.close();
213
+ });
214
+ docs.command("refs <id>").description("Show code \u2194 doc cross-references").action(async (id) => {
215
+ const cwd = process.cwd();
216
+ const config = await (0, import_config.loadConfig)(cwd);
217
+ if (!config.enableDocs) {
218
+ console.error(` \u2716 Documentation indexing is not enabled. Set ${import_ui.violet}${import_ui.bold}enableDocs: true${import_ui.reset} in .kirograph/config.json`);
219
+ process.exit(1);
220
+ }
221
+ const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
222
+ if (!KiroGraph.isInitialized(cwd)) {
223
+ console.error(" \u2716 KiroGraph not initialized.");
224
+ process.exit(1);
225
+ }
226
+ const cg = await KiroGraph.open(cwd);
227
+ const db = cg.getDatabase();
228
+ db.applyDocsSchema();
229
+ const { DocsQueries } = await Promise.resolve().then(() => require("../../docs/queries.js"));
230
+ const queries = new DocsQueries(db.getRawDb(), cwd);
231
+ let refs = queries.getRefs({ sectionId: id });
232
+ if (refs.length === 0) {
233
+ refs = queries.getRefs({ qualifiedName: id });
234
+ }
235
+ if (refs.length === 0) {
236
+ console.log(` ${import_ui.dim}No cross-references found for "${id}".${import_ui.reset}`);
237
+ cg.close();
238
+ return;
239
+ }
240
+ for (const r of refs) {
241
+ console.log(` [${r.refType}] ${r.qualifiedName} ${import_ui.dim}(confidence: ${r.confidence.toFixed(2)})${import_ui.reset}`);
242
+ }
243
+ cg.close();
244
+ });
245
+ docs.command("reindex").description("Force re-index all documentation files").action(async () => {
246
+ const cwd = process.cwd();
247
+ const config = await (0, import_config.loadConfig)(cwd);
248
+ if (!config.enableDocs) {
249
+ console.error(` \u2716 Documentation indexing is not enabled. Set ${import_ui.violet}${import_ui.bold}enableDocs: true${import_ui.reset} in .kirograph/config.json`);
250
+ process.exit(1);
251
+ }
252
+ const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
253
+ if (!KiroGraph.isInitialized(cwd)) {
254
+ console.error(" \u2716 KiroGraph not initialized.");
255
+ process.exit(1);
256
+ }
257
+ const cg = await KiroGraph.open(cwd);
258
+ const db = cg.getDatabase();
259
+ db.applyDocsSchema();
260
+ const { DocsIndexer } = await Promise.resolve().then(() => require("../../docs/indexer.js"));
261
+ const indexer = new DocsIndexer(db.getRawDb(), config, cwd);
262
+ console.log(` ${import_ui.dim}Re-indexing documentation...${import_ui.reset}`);
263
+ const result = await indexer.indexAll({ force: true, onProgress: (msg) => console.log(` ${import_ui.dim}${msg}${import_ui.reset}`) });
264
+ console.log(` ${import_ui.green}\u2713${import_ui.reset} ${(0, import_ui.value)(String(result.filesIndexed))} ${import_ui.dim}files,${import_ui.reset} ${(0, import_ui.value)(String(result.sectionsCreated))} ${import_ui.dim}sections created,${import_ui.reset} ${(0, import_ui.value)(String(result.sectionsUpdated))} ${import_ui.dim}updated,${import_ui.reset} ${(0, import_ui.value)(String(result.sectionsRemoved))} ${import_ui.dim}removed${import_ui.reset} ${import_ui.dim}(${result.duration}ms)${import_ui.reset}`);
265
+ if (result.errors.length) {
266
+ console.warn(` \x1B[33m\u26A0 ${result.errors.length} error(s)\x1B[0m`);
267
+ for (const err of result.errors.slice(0, 5)) console.warn(` ${err}`);
268
+ }
269
+ cg.close();
270
+ });
271
+ docs.command("lint").description("Find broken refs, stale sections, FTS desync").action(async () => {
272
+ const cwd = process.cwd();
273
+ const config = await (0, import_config.loadConfig)(cwd);
274
+ if (!config.enableDocs) {
275
+ console.error(` \u2716 Documentation indexing is not enabled. Set ${import_ui.violet}${import_ui.bold}enableDocs: true${import_ui.reset} in .kirograph/config.json`);
276
+ process.exit(1);
277
+ }
278
+ const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
279
+ if (!KiroGraph.isInitialized(cwd)) {
280
+ console.error(" \u2716 KiroGraph not initialized.");
281
+ process.exit(1);
282
+ }
283
+ const cg = await KiroGraph.open(cwd);
284
+ const db = cg.getDatabase();
285
+ db.applyDocsSchema();
286
+ const { docsLint } = await Promise.resolve().then(() => require("../../docs/lint.js"));
287
+ const result = docsLint(db.getRawDb(), cwd);
288
+ if (result.totalIssues === 0) {
289
+ console.log(` ${import_ui.green}\u2713${import_ui.reset} No issues found.`);
290
+ cg.close();
291
+ return;
292
+ }
293
+ console.log(` Found ${result.totalIssues} issue(s):
294
+ `);
295
+ if (result.brokenRefs.length > 0) {
296
+ console.log(` ${import_ui.bold}Broken code refs:${import_ui.reset} ${result.brokenRefs.length}`);
297
+ for (const ref of result.brokenRefs.slice(0, 10)) {
298
+ console.log(` ${import_ui.dim}${ref.sectionId} \u2192 ${ref.qualifiedName}${import_ui.reset}`);
299
+ }
300
+ if (result.brokenRefs.length > 10) console.log(` ${import_ui.dim}\u2026and ${result.brokenRefs.length - 10} more${import_ui.reset}`);
301
+ }
302
+ if (result.staleSections.length > 0) {
303
+ console.log(` ${import_ui.bold}Stale sections:${import_ui.reset} ${result.staleSections.length}`);
304
+ for (const s of result.staleSections.slice(0, 10)) {
305
+ console.log(` ${import_ui.dim}${s.filePath} \u2014 ${s.id}${import_ui.reset}`);
306
+ }
307
+ if (result.staleSections.length > 10) console.log(` ${import_ui.dim}\u2026and ${result.staleSections.length - 10} more${import_ui.reset}`);
308
+ }
309
+ if (result.ftsDesync) {
310
+ console.log(` ${import_ui.bold}FTS desync:${import_ui.reset} ${result.ftsDesync.sections} sections vs ${result.ftsDesync.ftsRows} FTS rows`);
311
+ }
312
+ if (result.orphanRefs > 0) {
313
+ console.log(` ${import_ui.bold}Orphan refs:${import_ui.reset} ${result.orphanRefs}`);
314
+ }
315
+ console.log(`
316
+ ${import_ui.dim}Run ${import_ui.violet}${import_ui.bold}kirograph docs reindex${import_ui.reset}${import_ui.dim} to fix stale sections.${import_ui.reset}`);
317
+ cg.close();
318
+ });
319
+ docs.command("reembed").description("Re-embed all doc sections with the current model").action(async () => {
320
+ const cwd = process.cwd();
321
+ const config = await (0, import_config.loadConfig)(cwd);
322
+ if (!config.enableDocs) {
323
+ console.error(` \u2716 Documentation indexing is not enabled. Set ${import_ui.violet}${import_ui.bold}enableDocs: true${import_ui.reset} in .kirograph/config.json`);
324
+ process.exit(1);
325
+ }
326
+ if (!config.enableEmbeddings) {
327
+ console.error(` \u2716 Embeddings are not enabled. Set ${import_ui.violet}${import_ui.bold}enableEmbeddings: true${import_ui.reset} in .kirograph/config.json`);
328
+ process.exit(1);
329
+ }
330
+ const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
331
+ if (!KiroGraph.isInitialized(cwd)) {
332
+ console.error(" \u2716 KiroGraph not initialized.");
333
+ process.exit(1);
334
+ }
335
+ const cg = await KiroGraph.open(cwd);
336
+ const db = cg.getDatabase();
337
+ db.applyDocsSchema();
338
+ const rawDb = db.getRawDb();
339
+ const sections = rawDb.all("SELECT id, title, summary FROM doc_sections");
340
+ if (sections.length === 0) {
341
+ console.log(` ${import_ui.dim}No doc sections to embed. Run ${import_ui.violet}${import_ui.bold}kirograph docs reindex${import_ui.reset}${import_ui.dim} first.${import_ui.reset}`);
342
+ cg.close();
343
+ return;
344
+ }
345
+ console.log(` ${import_ui.dim}Re-embedding ${sections.length} doc sections...${import_ui.reset}`);
346
+ const { DocsVectorManager } = await Promise.resolve().then(() => require("../../docs/vectors.js"));
347
+ const vectorMgr = new DocsVectorManager(config, rawDb);
348
+ const embedded = await vectorMgr.reembed();
349
+ console.log(` ${import_ui.green}\u2713${import_ui.reset} Embedded ${(0, import_ui.value)(String(embedded))} doc sections with model ${import_ui.dim}${config.embeddingModel}${import_ui.reset}`);
350
+ cg.close();
351
+ });
352
+ }
353
+ // Annotate the CommonJS export names for ESM import in node:
354
+ 0 && (module.exports = {
355
+ register
356
+ });
357
+ //# sourceMappingURL=docs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/bin/commands/docs.ts"],
4
+ "sourcesContent": ["import { Command } from 'commander';\nimport * as path from 'path';\nimport { loadConfig } from '../../config';\nimport { dim, reset, violet, bold, green, value } from '../ui';\n\n/** Safely close KiroGraph and exit cleanly. */\nfunction safeCloseAndExit(cg: any, code = 0): never {\n try { cg.close(); } catch { /* ignore */ }\n // Suppress any post-exit WASM crash output and exit cleanly\n try {\n const fs = require('fs');\n // Flush stdout/stderr, then close fd 2 to suppress libc++abi messages\n if (process.stdout.writableEnded === false) process.stdout.write('');\n if (process.stderr.writableEnded === false) process.stderr.write('');\n fs.closeSync(2);\n fs.closeSync(1);\n } catch { /* ignore */ }\n process.exit(code);\n}\n\nexport function register(program: Command): void {\n const docs = program\n .command('docs')\n .description('Documentation navigation (requires enableDocs: true)');\n\n // \u2500\u2500 toc \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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 docs\n .command('toc [file]')\n .description('Print table of contents for a file or the whole project')\n .option('--tree', 'Show nested tree structure')\n .option('--json', 'Output as JSON')\n .action(async (file: string | undefined, opts: { tree?: boolean; json?: boolean }) => {\n const cwd = process.cwd();\n const config = await loadConfig(cwd);\n if (!config.enableDocs) {\n console.error(` \u2716 Documentation indexing is not enabled. Set ${violet}${bold}enableDocs: true${reset} in .kirograph/config.json`);\n console.error(` ${dim}Then re-run:${reset} ${violet}${bold}kirograph index${reset}`);\n process.exit(1);\n }\n\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n if (!KiroGraph.isInitialized(cwd)) { console.error(' \u2716 KiroGraph not initialized. Run: kirograph init'); process.exit(1); }\n const cg = await KiroGraph.open(cwd);\n const db = cg.getDatabase();\n db.applyDocsSchema();\n\n const { DocsQueries } = await Promise.resolve().then(() => require('../../docs/queries.js'));\n const queries = new DocsQueries(db.getRawDb(), cwd);\n const toc = queries.getToc({ file, tree: opts.tree });\n\n if (toc.length === 0) {\n console.log(` ${dim}No documentation sections found.${reset} Run ${violet}${bold}kirograph index${reset} first.`);\n cg.close(); return;\n }\n\n if (opts.json) {\n console.log(JSON.stringify(toc, null, 2));\n } else {\n for (const entry of toc) {\n const prefix = '#'.repeat(entry.level || 1);\n const summary = entry.summary ? ` ${dim}\u2014 ${entry.summary}${reset}` : '';\n console.log(` ${prefix} ${bold}${entry.title}${reset}${summary}`);\n console.log(` ${dim}${entry.id}${reset}`);\n }\n }\n cg.close();\n });\n\n // \u2500\u2500 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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n docs\n .command('search <query>')\n .description('Search documentation sections')\n .option('--file <path>', 'Narrow search to a specific file')\n .option('--limit <n>', 'Max results', '10')\n .option('--json', 'Output as JSON')\n .action(async (query: string, opts: { file?: string; limit?: string; json?: boolean }) => {\n const cwd = process.cwd();\n const config = await loadConfig(cwd);\n if (!config.enableDocs) {\n console.error(` \u2716 Documentation indexing is not enabled. Set ${violet}${bold}enableDocs: true${reset} in .kirograph/config.json`);\n process.exit(1);\n }\n\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n if (!KiroGraph.isInitialized(cwd)) { console.error(' \u2716 KiroGraph not initialized.'); process.exit(1); }\n const cg = await KiroGraph.open(cwd);\n const db = cg.getDatabase();\n db.applyDocsSchema();\n\n const { DocsQueries } = await Promise.resolve().then(() => require('../../docs/queries.js'));\n const queries = new DocsQueries(db.getRawDb(), cwd, config);\n const results = await queries.searchSections(query, { file: opts.file, limit: parseInt(opts.limit ?? '10', 10) });\n\n if (results.length === 0) {\n console.log(` ${dim}No sections found matching \"${query}\".${reset}`);\n cg.close(); return;\n }\n\n if (opts.json) {\n console.log(JSON.stringify(results, null, 2));\n } else {\n for (const r of results) {\n const summary = r.section.summary ? `\\n ${dim}${r.section.summary}${reset}` : '';\n console.log(` ${green}\u25CF${reset} ${bold}${r.section.title}${reset} ${dim}[${r.section.filePath}]${reset}${summary}`);\n console.log(` ${dim}ID: ${r.section.id}${reset}`);\n }\n }\n cg.close();\n });\n\n // \u2500\u2500 section \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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 docs\n .command('section <id>')\n .description('Print full content of a section by ID')\n .option('--context', 'Include ancestor headings and child summaries')\n .action(async (id: string, opts: { context?: boolean }) => {\n const cwd = process.cwd();\n const config = await loadConfig(cwd);\n if (!config.enableDocs) {\n console.error(` \u2716 Documentation indexing is not enabled. Set ${violet}${bold}enableDocs: true${reset} in .kirograph/config.json`);\n process.exit(1);\n }\n\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n if (!KiroGraph.isInitialized(cwd)) { console.error(' \u2716 KiroGraph not initialized.'); process.exit(1); }\n const cg = await KiroGraph.open(cwd);\n const db = cg.getDatabase();\n db.applyDocsSchema();\n\n const { DocsQueries } = await Promise.resolve().then(() => require('../../docs/queries.js'));\n const queries = new DocsQueries(db.getRawDb(), cwd);\n const result = queries.getSection(id, { context: opts.context });\n\n if (!result) {\n // Suggest similar section IDs\n const rawDb = db.getRawDb();\n const idParts = id.split('::');\n const filePath = idParts[0] ?? '';\n const searchSlug = (idParts[1] ?? '').replace(/#\\d+$/, '').split('/').pop() ?? '';\n\n let suggestions: Array<{ id: string; title: string }> = [];\n if (searchSlug) {\n suggestions = rawDb.all(\n `SELECT id, title FROM doc_sections WHERE file_path = ? AND id LIKE ? LIMIT 5`,\n [filePath, `%${searchSlug}%`],\n ) as Array<{ id: string; title: string }>;\n }\n if (suggestions.length === 0 && filePath) {\n suggestions = rawDb.all(\n `SELECT id, title FROM doc_sections WHERE file_path = ? ORDER BY position LIMIT 5`,\n [filePath],\n ) as Array<{ id: string; title: string }>;\n }\n\n console.error(` \u2716 Section \"${id}\" not found.`);\n if (suggestions.length > 0) {\n console.error(`\\n ${dim}Did you mean:${reset}`);\n for (const s of suggestions) {\n console.error(` ${s.id} ${dim}(${s.title})${reset}`);\n }\n } else {\n console.error(`\\n ${dim}Use ${violet}kirograph docs toc${reset}${dim} to list available section IDs.${reset}`);\n }\n safeCloseAndExit(cg, 1);\n }\n\n if (result.ancestors?.length) {\n console.log(` ${dim}${result.ancestors.map(a => a.title).join(' > ')} > ${result.section.title}${reset}\\n`);\n }\n\n console.log(result.content);\n\n if (result.children?.length) {\n console.log(`\\n ${dim}Child sections:${reset}`);\n for (const child of result.children) {\n const summary = child.summary ? ` \u2014 ${child.summary}` : '';\n console.log(` ${dim}\u2022${reset} ${child.title}${summary}`);\n }\n }\n cg.close();\n });\n\n // \u2500\u2500 outline \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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 docs\n .command('outline <file>')\n .description('Print heading hierarchy for a document')\n .action(async (file: string) => {\n const cwd = process.cwd();\n const config = await loadConfig(cwd);\n if (!config.enableDocs) {\n console.error(` \u2716 Documentation indexing is not enabled. Set ${violet}${bold}enableDocs: true${reset} in .kirograph/config.json`);\n process.exit(1);\n }\n\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n if (!KiroGraph.isInitialized(cwd)) { console.error(' \u2716 KiroGraph not initialized.'); process.exit(1); }\n const cg = await KiroGraph.open(cwd);\n const db = cg.getDatabase();\n db.applyDocsSchema();\n\n const { DocsQueries } = await Promise.resolve().then(() => require('../../docs/queries.js'));\n const queries = new DocsQueries(db.getRawDb(), cwd);\n const outline = queries.getOutline(file);\n\n if (outline.length === 0) {\n console.log(` ${dim}No sections found in \"${file}\".${reset}`);\n cg.close(); return;\n }\n\n console.log(`\\n ${bold}${file}${reset}\\n`);\n const render = (entries: any[], indent: string) => {\n for (const entry of entries) {\n const summary = entry.summary ? ` ${dim}\u2014 ${entry.summary}${reset}` : '';\n console.log(`${indent} ${'#'.repeat(entry.level || 1)} ${entry.title}${summary}`);\n if (entry.children?.length) render(entry.children, indent + ' ');\n }\n };\n render(outline, '');\n cg.close();\n });\n\n // \u2500\u2500 refs \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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 docs\n .command('refs <id>')\n .description('Show code \u2194 doc cross-references')\n .action(async (id: string) => {\n const cwd = process.cwd();\n const config = await loadConfig(cwd);\n if (!config.enableDocs) {\n console.error(` \u2716 Documentation indexing is not enabled. Set ${violet}${bold}enableDocs: true${reset} in .kirograph/config.json`);\n process.exit(1);\n }\n\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n if (!KiroGraph.isInitialized(cwd)) { console.error(' \u2716 KiroGraph not initialized.'); process.exit(1); }\n const cg = await KiroGraph.open(cwd);\n const db = cg.getDatabase();\n db.applyDocsSchema();\n\n const { DocsQueries } = await Promise.resolve().then(() => require('../../docs/queries.js'));\n const queries = new DocsQueries(db.getRawDb(), cwd);\n\n // Try as section ID first, then as qualified name\n let refs = queries.getRefs({ sectionId: id });\n if (refs.length === 0) {\n refs = queries.getRefs({ qualifiedName: id });\n }\n\n if (refs.length === 0) {\n console.log(` ${dim}No cross-references found for \"${id}\".${reset}`);\n cg.close(); return;\n }\n\n for (const r of refs) {\n console.log(` [${r.refType}] ${r.qualifiedName} ${dim}(confidence: ${r.confidence.toFixed(2)})${reset}`);\n }\n cg.close();\n });\n\n // \u2500\u2500 reindex \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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 docs\n .command('reindex')\n .description('Force re-index all documentation files')\n .action(async () => {\n const cwd = process.cwd();\n const config = await loadConfig(cwd);\n if (!config.enableDocs) {\n console.error(` \u2716 Documentation indexing is not enabled. Set ${violet}${bold}enableDocs: true${reset} in .kirograph/config.json`);\n process.exit(1);\n }\n\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n if (!KiroGraph.isInitialized(cwd)) { console.error(' \u2716 KiroGraph not initialized.'); process.exit(1); }\n const cg = await KiroGraph.open(cwd);\n const db = cg.getDatabase();\n db.applyDocsSchema();\n\n const { DocsIndexer } = await Promise.resolve().then(() => require('../../docs/indexer.js'));\n const indexer = new DocsIndexer(db.getRawDb(), config, cwd);\n\n console.log(` ${dim}Re-indexing documentation...${reset}`);\n const result = await indexer.indexAll({ force: true, onProgress: msg => console.log(` ${dim}${msg}${reset}`) });\n\n console.log(` ${green}\u2713${reset} ${value(String(result.filesIndexed))} ${dim}files,${reset} ${value(String(result.sectionsCreated))} ${dim}sections created,${reset} ${value(String(result.sectionsUpdated))} ${dim}updated,${reset} ${value(String(result.sectionsRemoved))} ${dim}removed${reset} ${dim}(${result.duration}ms)${reset}`);\n if (result.errors.length) {\n console.warn(` \\x1b[33m\u26A0 ${result.errors.length} error(s)\\x1b[0m`);\n for (const err of result.errors.slice(0, 5)) console.warn(` ${err}`);\n }\n cg.close();\n });\n\n // \u2500\u2500 lint \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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 docs\n .command('lint')\n .description('Find broken refs, stale sections, FTS desync')\n .action(async () => {\n const cwd = process.cwd();\n const config = await loadConfig(cwd);\n if (!config.enableDocs) {\n console.error(` \u2716 Documentation indexing is not enabled. Set ${violet}${bold}enableDocs: true${reset} in .kirograph/config.json`);\n process.exit(1);\n }\n\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n if (!KiroGraph.isInitialized(cwd)) { console.error(' \u2716 KiroGraph not initialized.'); process.exit(1); }\n const cg = await KiroGraph.open(cwd);\n const db = cg.getDatabase();\n db.applyDocsSchema();\n\n const { docsLint } = await Promise.resolve().then(() => require('../../docs/lint.js'));\n const result = docsLint(db.getRawDb(), cwd);\n\n if (result.totalIssues === 0) {\n console.log(` ${green}\u2713${reset} No issues found.`);\n cg.close(); return;\n }\n\n console.log(` Found ${result.totalIssues} issue(s):\\n`);\n\n if (result.brokenRefs.length > 0) {\n console.log(` ${bold}Broken code refs:${reset} ${result.brokenRefs.length}`);\n for (const ref of result.brokenRefs.slice(0, 10)) {\n console.log(` ${dim}${ref.sectionId} \u2192 ${ref.qualifiedName}${reset}`);\n }\n if (result.brokenRefs.length > 10) console.log(` ${dim}\u2026and ${result.brokenRefs.length - 10} more${reset}`);\n }\n\n if (result.staleSections.length > 0) {\n console.log(` ${bold}Stale sections:${reset} ${result.staleSections.length}`);\n for (const s of result.staleSections.slice(0, 10)) {\n console.log(` ${dim}${s.filePath} \u2014 ${s.id}${reset}`);\n }\n if (result.staleSections.length > 10) console.log(` ${dim}\u2026and ${result.staleSections.length - 10} more${reset}`);\n }\n\n if (result.ftsDesync) {\n console.log(` ${bold}FTS desync:${reset} ${result.ftsDesync.sections} sections vs ${result.ftsDesync.ftsRows} FTS rows`);\n }\n\n if (result.orphanRefs > 0) {\n console.log(` ${bold}Orphan refs:${reset} ${result.orphanRefs}`);\n }\n\n console.log(`\\n ${dim}Run ${violet}${bold}kirograph docs reindex${reset}${dim} to fix stale sections.${reset}`);\n cg.close();\n });\n\n // \u2500\u2500 reembed \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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 docs\n .command('reembed')\n .description('Re-embed all doc sections with the current model')\n .action(async () => {\n const cwd = process.cwd();\n const config = await loadConfig(cwd);\n if (!config.enableDocs) {\n console.error(` \u2716 Documentation indexing is not enabled. Set ${violet}${bold}enableDocs: true${reset} in .kirograph/config.json`);\n process.exit(1);\n }\n if (!config.enableEmbeddings) {\n console.error(` \u2716 Embeddings are not enabled. Set ${violet}${bold}enableEmbeddings: true${reset} in .kirograph/config.json`);\n process.exit(1);\n }\n\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n if (!KiroGraph.isInitialized(cwd)) { console.error(' \u2716 KiroGraph not initialized.'); process.exit(1); }\n const cg = await KiroGraph.open(cwd);\n const db = cg.getDatabase();\n db.applyDocsSchema();\n\n const rawDb = db.getRawDb();\n const sections = rawDb.all('SELECT id, title, summary FROM doc_sections') as Array<{ id: string; title: string; summary: string | null }>;\n\n if (sections.length === 0) {\n console.log(` ${dim}No doc sections to embed. Run ${violet}${bold}kirograph docs reindex${reset}${dim} first.${reset}`);\n cg.close(); return;\n }\n\n console.log(` ${dim}Re-embedding ${sections.length} doc sections...${reset}`);\n const { DocsVectorManager } = await Promise.resolve().then(() => require('../../docs/vectors.js'));\n const vectorMgr = new DocsVectorManager(config, rawDb);\n const embedded = await vectorMgr.reembed();\n console.log(` ${green}\u2713${reset} Embedded ${value(String(embedded))} doc sections with model ${dim}${config.embeddingModel}${reset}`);\n cg.close();\n });\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA2B;AAC3B,gBAAuD;AAGvD,SAAS,iBAAiB,IAAS,OAAO,GAAU;AAClD,MAAI;AAAE,OAAG,MAAM;AAAA,EAAG,QAAQ;AAAA,EAAe;AAEzC,MAAI;AACF,UAAM,KAAK,QAAQ,IAAI;AAEvB,QAAI,QAAQ,OAAO,kBAAkB,MAAO,SAAQ,OAAO,MAAM,EAAE;AACnE,QAAI,QAAQ,OAAO,kBAAkB,MAAO,SAAQ,OAAO,MAAM,EAAE;AACnE,OAAG,UAAU,CAAC;AACd,OAAG,UAAU,CAAC;AAAA,EAChB,QAAQ;AAAA,EAAe;AACvB,UAAQ,KAAK,IAAI;AACnB;AAEO,SAAS,S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AI,KAAK,aAAG,iCAAiC,gBAAM,GAAG,cAAI,yBAAyB,eAAK,GAAG,aAAG,UAAU,eAAK,EAAE;AACvH,SAAG,MAAM;AAAG;AAAA,IACd;AAEA,YAAQ,IAAI,KAAK,aAAG,gBAAgB,SAAS,MAAM,mBAAmB,eAAK,EAAE;AAC7E,UAAM,EAAE,kBAAkB,IAAI,MAAM,QAAQ,QAAQ,EAAE,KAAK,MAAM,QAAQ,uBAAuB,CAAC;AACjG,UAAM,YAAY,IAAI,kBAAkB,QAAQ,KAAK;AACrD,UAAM,WAAW,MAAM,UAAU,QAAQ;AACzC,YAAQ,IAAI,KAAK,eAAK,SAAI,eAAK,iBAAa,iBAAM,OAAO,QAAQ,CAAC,CAAC,4BAA4B,aAAG,GAAG,OAAO,cAAc,GAAG,eAAK,EAAE;AACpI,OAAG,MAAM;AAAA,EACX,CAAC;AACL;",
6
+ "names": []
7
+ }
@@ -63,7 +63,7 @@ async function promptConfigOptions(rl) {
63
63
  "Semantic embeddings (similarity search):",
64
64
  "Enables natural-language code search via vector embeddings. A local model (~130MB) is downloaded on first use."
65
65
  );
66
- const patch = { enableEmbeddings, useVecIndex: false, semanticEngine: "cosine", typesenseDashboard: false, qdrantDashboard: false, extractDocstrings: true, trackCallSites: true, enableArchitecture: false, cavemanMode: "off", shellCompressionLevel: "normal", enableMemory: false };
66
+ const patch = { enableEmbeddings, useVecIndex: false, semanticEngine: "cosine", typesenseDashboard: false, qdrantDashboard: false, extractDocstrings: true, trackCallSites: true, enableArchitecture: false, cavemanMode: "off", shellCompressionLevel: "normal", enableMemory: false, enableDocs: false, docsContextLimit: 0 };
67
67
  if (enableEmbeddings) {
68
68
  const modelChoice = await (0, import_prompts.arrowSelect)(
69
69
  rl,
@@ -146,6 +146,22 @@ async function promptConfigOptions(rl) {
146
146
  "Detects packages from manifests and architectural layers. Enables kirograph_architecture, kirograph_coupling, kirograph_package.",
147
147
  false
148
148
  );
149
+ (0, import_prompts.printSection)("\u{1F4D6}", "Documentation");
150
+ patch.enableDocs = await (0, import_prompts.askToggle)(
151
+ rl,
152
+ "Documentation indexing (section-level retrieval):",
153
+ "Indexes docs by heading structure. Enables kirograph_docs_toc, kirograph_docs_search, kirograph_docs_section, kirograph_docs_outline, kirograph_docs_refs.",
154
+ false
155
+ );
156
+ if (patch.enableDocs) {
157
+ const contextChoice = await (0, import_prompts.arrowSelect)(rl, "Include doc sections in kirograph_context results?", [
158
+ { value: 0, label: "0 (disabled)", description: "Docs stay separate \u2014 use kirograph_docs_* tools explicitly (recommended)" },
159
+ { value: 3, label: "3 sections", description: "Include up to 3 relevant doc sections in context results" },
160
+ { value: 5, label: "5 sections", description: "Include up to 5 relevant doc sections in context results" },
161
+ { value: 10, label: "10 sections", description: "Include up to 10 relevant doc sections in context results" }
162
+ ]);
163
+ patch.docsContextLimit = contextChoice;
164
+ }
149
165
  (0, import_prompts.printSection)("\u{1F916}", "Agent Behavior");
150
166
  const cavemanChoice = await (0, import_prompts.arrowSelect)(rl, "Communication style (caveman mode):", [
151
167
  { value: "off", label: "off", description: "Normal responses \u2014 no compression" },