kirograph 0.27.1 → 0.27.2
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 +27 -1
- package/dist/bin/commands/callees.js +76 -0
- package/dist/bin/commands/callees.js.map +7 -0
- package/dist/bin/commands/callers.js +76 -0
- package/dist/bin/commands/callers.js.map +7 -0
- package/dist/bin/commands/circular-deps.js +68 -0
- package/dist/bin/commands/circular-deps.js.map +7 -0
- package/dist/bin/commands/impact.js +76 -0
- package/dist/bin/commands/impact.js.map +7 -0
- package/dist/bin/commands/type-hierarchy.js +76 -0
- package/dist/bin/commands/type-hierarchy.js.map +7 -0
- package/dist/bin/installer/common.js +15 -9
- package/dist/bin/installer/common.js.map +2 -2
- package/dist/bin/installer/config-prompt.js +8 -2
- package/dist/bin/installer/config-prompt.js.map +2 -2
- package/dist/bin/installer/index.js +25 -1
- package/dist/bin/installer/index.js.map +2 -2
- package/dist/bin/installer/instructions.js +14 -21
- package/dist/bin/installer/instructions.js.map +2 -2
- package/dist/bin/installer/mcp.js.map +2 -2
- package/dist/bin/installer/steering.js +38 -0
- package/dist/bin/installer/steering.js.map +2 -2
- package/dist/bin/installer/targets/aider.js +3 -3
- package/dist/bin/installer/targets/aider.js.map +2 -2
- package/dist/bin/installer/targets/amp.js +3 -3
- package/dist/bin/installer/targets/amp.js.map +2 -2
- package/dist/bin/installer/targets/antigravity.js +4 -4
- package/dist/bin/installer/targets/antigravity.js.map +2 -2
- package/dist/bin/installer/targets/augment.js +3 -3
- package/dist/bin/installer/targets/augment.js.map +2 -2
- package/dist/bin/installer/targets/claude.js +3 -3
- package/dist/bin/installer/targets/claude.js.map +2 -2
- package/dist/bin/installer/targets/cline.js +4 -4
- package/dist/bin/installer/targets/cline.js.map +2 -2
- package/dist/bin/installer/targets/codex.js +4 -4
- package/dist/bin/installer/targets/codex.js.map +2 -2
- package/dist/bin/installer/targets/continue.js +4 -4
- package/dist/bin/installer/targets/continue.js.map +2 -2
- package/dist/bin/installer/targets/copilot-cli.js +4 -4
- package/dist/bin/installer/targets/copilot-cli.js.map +2 -2
- package/dist/bin/installer/targets/copilot.js +4 -4
- package/dist/bin/installer/targets/copilot.js.map +2 -2
- package/dist/bin/installer/targets/cursor.js +5 -5
- package/dist/bin/installer/targets/cursor.js.map +2 -2
- package/dist/bin/installer/targets/devin.js +4 -4
- package/dist/bin/installer/targets/devin.js.map +2 -2
- package/dist/bin/installer/targets/gemini-cli.js +4 -4
- package/dist/bin/installer/targets/gemini-cli.js.map +2 -2
- package/dist/bin/installer/targets/generic.js +2 -2
- package/dist/bin/installer/targets/generic.js.map +2 -2
- package/dist/bin/installer/targets/goose.js +3 -4
- package/dist/bin/installer/targets/goose.js.map +3 -3
- package/dist/bin/installer/targets/index.js.map +1 -1
- package/dist/bin/installer/targets/junie.js +4 -4
- package/dist/bin/installer/targets/junie.js.map +2 -2
- package/dist/bin/installer/targets/kilo.js +4 -4
- package/dist/bin/installer/targets/kilo.js.map +2 -2
- package/dist/bin/installer/targets/kiro.js +23 -3
- package/dist/bin/installer/targets/kiro.js.map +2 -2
- package/dist/bin/installer/targets/opencode.js +3 -3
- package/dist/bin/installer/targets/opencode.js.map +2 -2
- package/dist/bin/installer/targets/openhands.js +3 -3
- package/dist/bin/installer/targets/openhands.js.map +2 -2
- package/dist/bin/installer/targets/qoder.js +2 -2
- package/dist/bin/installer/targets/qoder.js.map +2 -2
- package/dist/bin/installer/targets/qwen.js +2 -2
- package/dist/bin/installer/targets/qwen.js.map +2 -2
- package/dist/bin/installer/targets/replit.js +3 -3
- package/dist/bin/installer/targets/replit.js.map +2 -2
- package/dist/bin/installer/targets/roo.js +4 -4
- package/dist/bin/installer/targets/roo.js.map +2 -2
- package/dist/bin/installer/targets/tabnine.js +3 -3
- package/dist/bin/installer/targets/tabnine.js.map +2 -2
- package/dist/bin/installer/targets/trae.js +3 -3
- package/dist/bin/installer/targets/trae.js.map +2 -2
- package/dist/bin/installer/targets/warp.js +4 -4
- package/dist/bin/installer/targets/warp.js.map +2 -2
- package/dist/bin/installer/targets/windsurf.js +4 -4
- package/dist/bin/installer/targets/windsurf.js.map +2 -2
- package/dist/bin/kirograph.js +11 -1
- package/dist/bin/kirograph.js.map +3 -3
- package/dist/config.js +4 -0
- package/dist/config.js.map +2 -2
- package/dist/mcp/cache.js +1 -1
- package/dist/mcp/cache.js.map +2 -2
- package/dist/mcp/tool-names.js +43 -4
- package/dist/mcp/tool-names.js.map +2 -2
- package/dist/mcp/tools.js +774 -182
- package/dist/mcp/tools.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,10 +51,34 @@ The result is fewer tool calls, less context used, and faster responses on compl
|
|
|
51
51
|
| <h4>Token Optimization</h4> | |
|
|
52
52
|
| 🗜️ **Shell Compression (KiroGraph-RTK opt-in module)** | Token-optimized command output (git, tests, linters, docker, AWS) — 60-90% savings |
|
|
53
53
|
| 🪨 **Caveman Mode (KiroGraph-Caveman opt-in module)** 🪨 | Agent prose compression (lite → ultra) — fewer tokens on explanations without touching code |
|
|
54
|
+
| 📦 **General-purpose Compression (`kirograph_compress`, opt-in)** | On-demand compression tool for arbitrary text. Two engines: rtk-style structural filters for shell output (command-hinted), caveman grammar for prose. Five levels (lite → ultra). Reports inline savings. Inspired by [headroom](https://github.com/chopratejas/headroom). |
|
|
55
|
+
| 📥 **File Read Cache + CCR (`kirograph_read` / `kirograph_retrieve`, opt-in)** | `kirograph_read` caches files on first read — unchanged files return a ~13-token marker on subsequent reads. `kirograph_retrieve` (CCR) recovers the cached full content without a filesystem re-read. Prefix-stable markers enable KV cache hits on conversation context. Inspired by [lean-ctx](https://github.com/yvgude/lean-ctx) and [headroom](https://github.com/chopratejas/headroom). |
|
|
54
56
|
| 📈 **Token Analytics (KiroGraph-Gain core module)** | Track cumulative savings from graph tools and shell compression over time |
|
|
55
57
|
| <h4>Integration (KiroGraph-Integration core module)</h4> | |
|
|
56
58
|
| 🔌 **Multi-tool Support** | Native Kiro + 32 experimental targets (Cursor, Copilot, Claude Code, Codex, Windsurf, Cline, and more) |
|
|
57
59
|
|
|
60
|
+
## MCP Tool List Token Budget
|
|
61
|
+
|
|
62
|
+
Each enabled flag adds tools to the model context on every MCP call. Total with all flags: **92 tools · ~4,367 tok**.
|
|
63
|
+
|
|
64
|
+
| Flag | Tools | ~Tokens |
|
|
65
|
+
|------|------:|--------:|
|
|
66
|
+
| core (always-on) | 8 | ~472 |
|
|
67
|
+
| `enableMemory` | 16 | ~746 |
|
|
68
|
+
| `enableSecurity` | 15 | ~675 |
|
|
69
|
+
| `enableData` | 10 | ~519 |
|
|
70
|
+
| `enableWiki` | 10 | ~319 |
|
|
71
|
+
| `enableCodeHealth` | 7 | ~309 |
|
|
72
|
+
| `enableAgentUtils` | 4 | ~278 |
|
|
73
|
+
| `enableAdvancedAnalysis` | 4 | ~210 |
|
|
74
|
+
| `enableArchitecture` | 3 | ~142 |
|
|
75
|
+
| `enableWatchmen` | 3 | ~140 |
|
|
76
|
+
| `enablePatterns` | 3 | ~93 |
|
|
77
|
+
| `trackCallSites` | 2 | ~84 |
|
|
78
|
+
| `enableShellExec` | 1 | ~71 |
|
|
79
|
+
| `enableGeneralCompression` | 1 | ~68 |
|
|
80
|
+
| **Total** | **92** | **~4,367** |
|
|
81
|
+
|
|
58
82
|
## Quick Start
|
|
59
83
|
|
|
60
84
|
```bash
|
|
@@ -152,6 +176,7 @@ KiroGraph is inspired by [CodeGraph](https://github.com/colbymchenry/codegraph)
|
|
|
152
176
|
- [rtk](https://github.com/rtk-ai/rtk) by [rtk-ai](https://github.com/rtk-ai): the shell compression module's command-family approach and token-optimized output patterns.
|
|
153
177
|
- [code-review-graph](https://github.com/tirth8205/code-review-graph) by [Tirth Kanani](https://github.com/tirth8205): community detection, execution flow tracing, refactoring tools, and multi-platform auto-detection patterns.
|
|
154
178
|
- [lean-ctx](https://github.com/yvgude/lean-ctx) by [Yves Gugger](https://github.com/yvgude): file read caching, multiple read modes, and context budget governance concepts.
|
|
179
|
+
- [headroom](https://github.com/chopratejas/headroom) by [Tejas Chopra](https://github.com/chopratejas): the CCR (Cached Content Retrieval) pattern (`kirograph_retrieve`), dual-engine on-demand compression (`kirograph_compress`), and KV cache prefix stability via deterministic marker strings.
|
|
155
180
|
- [turboquant-js](https://github.com/danilodevhub/turboquant-js) by [Danilo Dev](https://github.com/danilodevhub): the TurboQuant engine — TypeScript implementation of Google's Walsh-Hadamard + Lloyd-Max quantization algorithm used for embedding compression.
|
|
156
181
|
- [turbovec](https://github.com/RyanCodrai/turbovec) by [Ryan Codrai](https://github.com/RyanCodrai): the TurboVec engine — Rust implementation of TurboQuant with SIMD acceleration, exposed to Node.js via a napi-rs native addon.
|
|
157
182
|
- [pdf-inspector](https://github.com/firecrawl/pdf-inspector) by [Firecrawl](https://github.com/firecrawl): the PDF parser used in the data module — pure Rust, no OCR, no network, prebuilt binaries for linux-x64 and macOS ARM64.
|
|
@@ -163,7 +188,7 @@ KiroGraph is inspired by [CodeGraph](https://github.com/colbymchenry/codegraph)
|
|
|
163
188
|
|
|
164
189
|
## How It Compares
|
|
165
190
|
|
|
166
|
-
KiroGraph combines capabilities from
|
|
191
|
+
KiroGraph combines capabilities from 14 separate projects into one integrated MCP server:
|
|
167
192
|
|
|
168
193
|
| Capability | Inspired by | What KiroGraph adds |
|
|
169
194
|
|-----------|-------------|---------------------|
|
|
@@ -177,6 +202,7 @@ KiroGraph combines capabilities from 13 separate projects into one integrated MC
|
|
|
177
202
|
| PDF parsing | [pdf-inspector](https://github.com/firecrawl/pdf-inspector) | Pure Rust, no OCR/network, prebuilt binaries, piped into data module |
|
|
178
203
|
| Shell compression | [rtk](https://github.com/rtk-ai/rtk) | Integrated as MCP tool, no separate binary |
|
|
179
204
|
| Prose compression | [caveman](https://github.com/JuliusBrussee/caveman) | Multi-level (lite/full/ultra) via steering |
|
|
205
|
+
| On-demand compression + CCR | [headroom](https://github.com/chopratejas/headroom) | Dual-engine (rtk shell + caveman prose) via `kirograph_compress`; CCR pattern via `kirograph_retrieve`; KV-cache prefix stability |
|
|
180
206
|
| Embedding compression | [turboquant-js](https://github.com/danilodevhub/turboquant-js) | 9 engine options, SIMD Rust variant, 20–30× RAM savings |
|
|
181
207
|
| SIMD vector search | [turbovec](https://github.com/RyanCodrai/turbovec) | NEON on ARM64, AVX-512BW on x86, auto-built by installer |
|
|
182
208
|
| Context layer | [lean-ctx](https://github.com/yvgude/lean-ctx) | File caching, read modes, budget governance |
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var callees_exports = {};
|
|
30
|
+
__export(callees_exports, {
|
|
31
|
+
register: () => register
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(callees_exports);
|
|
34
|
+
var path = __toESM(require("path"));
|
|
35
|
+
var import_ui = require("../ui");
|
|
36
|
+
function register(program) {
|
|
37
|
+
program.command("callees <symbol>").description("List symbols called by a given function or method").option("--limit <n>", "Max results (default: 20)", "20").option("-j, --json", "Output as JSON").option("-p, --path <path>", "Project path").action(async (symbol, opts) => {
|
|
38
|
+
const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
|
|
39
|
+
const target = path.resolve(opts.path ?? process.cwd());
|
|
40
|
+
const cg = await KiroGraph.open(target);
|
|
41
|
+
const results = cg.searchNodes(symbol, void 0, 5);
|
|
42
|
+
if (results.length === 0) {
|
|
43
|
+
console.error(` \u2716 Symbol "${symbol}" not found in index.`);
|
|
44
|
+
cg.close();
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const node = results[0].node;
|
|
48
|
+
const limit = Math.max(1, Math.min(100, parseInt(opts.limit) || 20));
|
|
49
|
+
const callees = await cg.getCallees(node.id, limit);
|
|
50
|
+
if (opts.json) {
|
|
51
|
+
console.log(JSON.stringify({ symbol: node.name, callees }));
|
|
52
|
+
cg.close();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (callees.length === 0) {
|
|
56
|
+
console.log(`
|
|
57
|
+
${import_ui.dim}\`${node.name}\` doesn't call any indexed symbols.${import_ui.reset}
|
|
58
|
+
`);
|
|
59
|
+
cg.close();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
console.log(`
|
|
63
|
+
${import_ui.violet}${import_ui.bold}\`${node.name}\` calls${import_ui.reset} ${import_ui.dim}(${callees.length})${import_ui.reset}
|
|
64
|
+
`);
|
|
65
|
+
for (const n of callees) {
|
|
66
|
+
console.log(` ${import_ui.violet}${n.name}${import_ui.reset} ${import_ui.dim}${n.kind} ${n.filePath}:${n.startLine}${import_ui.reset}`);
|
|
67
|
+
}
|
|
68
|
+
console.log();
|
|
69
|
+
cg.close();
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
register
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=callees.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/bin/commands/callees.ts"],
|
|
4
|
+
"sourcesContent": ["import * as path from 'path';\nimport { Command } from 'commander';\nimport { bold, dim, reset, violet } from '../ui';\n\nexport function register(program: Command): void {\n program\n .command('callees <symbol>')\n .description('List symbols called by a given function or method')\n .option('--limit <n>', 'Max results (default: 20)', '20')\n .option('-j, --json', 'Output as JSON')\n .option('-p, --path <path>', 'Project path')\n .action(async (symbol: string, opts: { limit: string; json?: boolean; path?: string }) => {\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n const target = path.resolve(opts.path ?? process.cwd());\n const cg = await KiroGraph.open(target);\n\n const results = cg.searchNodes(symbol, undefined, 5);\n if (results.length === 0) {\n console.error(` \u2716 Symbol \"${symbol}\" not found in index.`);\n cg.close(); process.exit(1);\n }\n\n const node = results[0].node;\n const limit = Math.max(1, Math.min(100, parseInt(opts.limit) || 20));\n const callees = await cg.getCallees(node.id, limit);\n\n if (opts.json) {\n console.log(JSON.stringify({ symbol: node.name, callees }));\n cg.close(); return;\n }\n\n if (callees.length === 0) {\n console.log(`\\n ${dim}\\`${node.name}\\` doesn't call any indexed symbols.${reset}\\n`);\n cg.close(); return;\n }\n\n console.log(`\\n ${violet}${bold}\\`${node.name}\\` calls${reset} ${dim}(${callees.length})${reset}\\n`);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AAM;AAAG;AAAA,IACd;AAEA,YAAQ,IAAI;AAAA,IAAO,gBAAM,GAAG,cAAI,KAAK,KAAK,IAAI,WAAW,eAAK,KAAK,aAAG,IAAI,QAAQ,MAAM,IAAI,eAAK;AAAA,CAAI;AACrG,eAAW,KAAK,SAAS;AACvB,cAAQ,IAAI,KAAK,gBAAM,GAAG,EAAE,IAAI,GAAG,eAAK,KAAK,aAAG,GAAG,EAAE,IAAI,KAAK,EAAE,QAAQ,IAAI,EAAE,SAAS,GAAG,eAAK,EAAE;AAAA,IACnG;AACA,YAAQ,IAAI;AACZ,OAAG,MAAM;AAAA,EACX,CAAC;AACL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var callers_exports = {};
|
|
30
|
+
__export(callers_exports, {
|
|
31
|
+
register: () => register
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(callers_exports);
|
|
34
|
+
var path = __toESM(require("path"));
|
|
35
|
+
var import_ui = require("../ui");
|
|
36
|
+
function register(program) {
|
|
37
|
+
program.command("callers <symbol>").description("List symbols that call a given function or method").option("--limit <n>", "Max results (default: 20)", "20").option("-j, --json", "Output as JSON").option("-p, --path <path>", "Project path").action(async (symbol, opts) => {
|
|
38
|
+
const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
|
|
39
|
+
const target = path.resolve(opts.path ?? process.cwd());
|
|
40
|
+
const cg = await KiroGraph.open(target);
|
|
41
|
+
const results = cg.searchNodes(symbol, void 0, 5);
|
|
42
|
+
if (results.length === 0) {
|
|
43
|
+
console.error(` \u2716 Symbol "${symbol}" not found in index.`);
|
|
44
|
+
cg.close();
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const node = results[0].node;
|
|
48
|
+
const limit = Math.max(1, Math.min(100, parseInt(opts.limit) || 20));
|
|
49
|
+
const callers = await cg.getCallers(node.id, limit);
|
|
50
|
+
if (opts.json) {
|
|
51
|
+
console.log(JSON.stringify({ symbol: node.name, callers }));
|
|
52
|
+
cg.close();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (callers.length === 0) {
|
|
56
|
+
console.log(`
|
|
57
|
+
${import_ui.dim}No callers found for \`${node.name}\`.${import_ui.reset}
|
|
58
|
+
`);
|
|
59
|
+
cg.close();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
console.log(`
|
|
63
|
+
${import_ui.violet}${import_ui.bold}Callers of \`${node.name}\`${import_ui.reset} ${import_ui.dim}(${callers.length})${import_ui.reset}
|
|
64
|
+
`);
|
|
65
|
+
for (const n of callers) {
|
|
66
|
+
console.log(` ${import_ui.violet}${n.name}${import_ui.reset} ${import_ui.dim}${n.kind} ${n.filePath}:${n.startLine}${import_ui.reset}`);
|
|
67
|
+
}
|
|
68
|
+
console.log();
|
|
69
|
+
cg.close();
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
register
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=callers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/bin/commands/callers.ts"],
|
|
4
|
+
"sourcesContent": ["import * as path from 'path';\nimport { Command } from 'commander';\nimport { bold, dim, reset, violet } from '../ui';\n\nexport function register(program: Command): void {\n program\n .command('callers <symbol>')\n .description('List symbols that call a given function or method')\n .option('--limit <n>', 'Max results (default: 20)', '20')\n .option('-j, --json', 'Output as JSON')\n .option('-p, --path <path>', 'Project path')\n .action(async (symbol: string, opts: { limit: string; json?: boolean; path?: string }) => {\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n const target = path.resolve(opts.path ?? process.cwd());\n const cg = await KiroGraph.open(target);\n\n const results = cg.searchNodes(symbol, undefined, 5);\n if (results.length === 0) {\n console.error(` \u2716 Symbol \"${symbol}\" not found in index.`);\n cg.close(); process.exit(1);\n }\n\n const node = results[0].node;\n const limit = Math.max(1, Math.min(100, parseInt(opts.limit) || 20));\n const callers = await cg.getCallers(node.id, limit);\n\n if (opts.json) {\n console.log(JSON.stringify({ symbol: node.name, callers }));\n cg.close(); return;\n }\n\n if (callers.length === 0) {\n console.log(`\\n ${dim}No callers found for \\`${node.name}\\`.${reset}\\n`);\n cg.close(); return;\n }\n\n console.log(`\\n ${violet}${bold}Callers of \\`${node.name}\\`${reset} ${dim}(${callers.length})${reset}\\n`);\n for (const n of callers) {\n console.log(` ${violet}${n.name}${reset} ${dim}${n.kind} ${n.filePath}:${n.startLine}${reset}`);\n }\n console.log();\n cg.close();\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;AAEtB,gBAAyC;AAElC,SAAS,SAAS,SAAwB;AAC/C,UACG,QAAQ,kBAAkB,EAC1B,YAAY,mDAAmD,EAC/D,OAAO,eAAe,6BAA6B,IAAI,EACvD,OAAO,cAAc,gBAAgB,EACrC,OAAO,qBAAqB,cAAc,EAC1C,OAAO,OAAO,QAAgB,SAA2D;AACxF,UAAM,aAAa,MAAM,QAAQ,QAAQ,EAAE,KAAK,MAAM,QAAQ,gBAAgB,CAAC,GAAG;AAClF,UAAM,SAAS,KAAK,QAAQ,KAAK,QAAQ,QAAQ,IAAI,CAAC;AACtD,UAAM,KAAK,MAAM,UAAU,KAAK,MAAM;AAEtC,UAAM,UAAU,GAAG,YAAY,QAAQ,QAAW,CAAC;AACnD,QAAI,QAAQ,WAAW,GAAG;AACxB,cAAQ,MAAM,oBAAe,MAAM,uBAAuB;AAC1D,SAAG,MAAM;AAAG,cAAQ,KAAK,CAAC;AAAA,IAC5B;AAEA,UAAM,OAAO,QAAQ,CAAC,EAAE;AACxB,UAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,SAAS,KAAK,KAAK,KAAK,EAAE,CAAC;AACnE,UAAM,UAAU,MAAM,GAAG,WAAW,KAAK,IAAI,KAAK;AAElD,QAAI,KAAK,MAAM;AACb,cAAQ,IAAI,KAAK,UAAU,EAAE,QAAQ,KAAK,MAAM,QAAQ,CAAC,CAAC;AAC1D,SAAG,MAAM;AAAG;AAAA,IACd;AAEA,QAAI,QAAQ,WAAW,GAAG;AACxB,cAAQ,IAAI;AAAA,IAAO,aAAG,0BAA0B,KAAK,IAAI,MAAM,eAAK;AAAA,CAAI;AACxE,SAAG,MAAM;AAAG;AAAA,IACd;AAEA,YAAQ,IAAI;AAAA,IAAO,gBAAM,GAAG,cAAI,gBAAgB,KAAK,IAAI,KAAK,eAAK,KAAK,aAAG,IAAI,QAAQ,MAAM,IAAI,eAAK;AAAA,CAAI;AAC1G,eAAW,KAAK,SAAS;AACvB,cAAQ,IAAI,KAAK,gBAAM,GAAG,EAAE,IAAI,GAAG,eAAK,KAAK,aAAG,GAAG,EAAE,IAAI,KAAK,EAAE,QAAQ,IAAI,EAAE,SAAS,GAAG,eAAK,EAAE;AAAA,IACnG;AACA,YAAQ,IAAI;AACZ,OAAG,MAAM;AAAA,EACX,CAAC;AACL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var circular_deps_exports = {};
|
|
30
|
+
__export(circular_deps_exports, {
|
|
31
|
+
register: () => register
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(circular_deps_exports);
|
|
34
|
+
var path = __toESM(require("path"));
|
|
35
|
+
var import_ui = require("../ui");
|
|
36
|
+
function register(program) {
|
|
37
|
+
program.command("circular-deps [projectPath]").description("Find circular dependency cycles in the codebase").option("-j, --json", "Output as JSON").action(async (projectPath, opts) => {
|
|
38
|
+
const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
|
|
39
|
+
const target = path.resolve(projectPath ?? process.cwd());
|
|
40
|
+
const cg = await KiroGraph.open(target);
|
|
41
|
+
const cycles = cg.findCircularDependencies();
|
|
42
|
+
if (opts.json) {
|
|
43
|
+
console.log(JSON.stringify({ cycles }));
|
|
44
|
+
cg.close();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (cycles.length === 0) {
|
|
48
|
+
console.log(`
|
|
49
|
+
${import_ui.dim}No circular dependencies found.${import_ui.reset}
|
|
50
|
+
`);
|
|
51
|
+
cg.close();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
console.log(`
|
|
55
|
+
${import_ui.violet}${import_ui.bold}Circular Dependencies${import_ui.reset} ${import_ui.dim}(${cycles.length} cycle(s))${import_ui.reset}
|
|
56
|
+
`);
|
|
57
|
+
for (let i = 0; i < cycles.length; i++) {
|
|
58
|
+
console.log(` ${import_ui.dim}Cycle ${i + 1}:${import_ui.reset} ${cycles[i].map((s) => `${import_ui.violet}${s}${import_ui.reset}`).join(` ${import_ui.dim}\u2192${import_ui.reset} `)}`);
|
|
59
|
+
}
|
|
60
|
+
console.log();
|
|
61
|
+
cg.close();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
register
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=circular-deps.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/bin/commands/circular-deps.ts"],
|
|
4
|
+
"sourcesContent": ["import * as path from 'path';\nimport { Command } from 'commander';\nimport { bold, dim, reset, violet } from '../ui';\n\nexport function register(program: Command): void {\n program\n .command('circular-deps [projectPath]')\n .description('Find circular dependency cycles in the codebase')\n .option('-j, --json', 'Output as JSON')\n .action(async (projectPath: string | undefined, opts: { json?: boolean }) => {\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n const target = path.resolve(projectPath ?? process.cwd());\n const cg = await KiroGraph.open(target);\n\n const cycles = cg.findCircularDependencies();\n\n if (opts.json) {\n console.log(JSON.stringify({ cycles }));\n cg.close(); return;\n }\n\n if (cycles.length === 0) {\n console.log(`\\n ${dim}No circular dependencies found.${reset}\\n`);\n cg.close(); return;\n }\n\n console.log(`\\n ${violet}${bold}Circular Dependencies${reset} ${dim}(${cycles.length} cycle(s))${reset}\\n`);\n for (let i = 0; i < cycles.length; i++) {\n console.log(` ${dim}Cycle ${i + 1}:${reset} ${cycles[i].map(s => `${violet}${s}${reset}`).join(` ${dim}\u2192${reset} `)}`);\n }\n console.log();\n cg.close();\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;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defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var impact_exports = {};
|
|
30
|
+
__export(impact_exports, {
|
|
31
|
+
register: () => register
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(impact_exports);
|
|
34
|
+
var path = __toESM(require("path"));
|
|
35
|
+
var import_ui = require("../ui");
|
|
36
|
+
function register(program) {
|
|
37
|
+
program.command("impact <symbol>").description("Show symbols that would be affected by changing a given symbol").option("-d, --depth <n>", "Max traversal depth (default: 2)", "2").option("-j, --json", "Output as JSON").option("-p, --path <path>", "Project path").action(async (symbol, opts) => {
|
|
38
|
+
const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
|
|
39
|
+
const target = path.resolve(opts.path ?? process.cwd());
|
|
40
|
+
const cg = await KiroGraph.open(target);
|
|
41
|
+
const results = cg.searchNodes(symbol, void 0, 5);
|
|
42
|
+
if (results.length === 0) {
|
|
43
|
+
console.error(` \u2716 Symbol "${symbol}" not found in index.`);
|
|
44
|
+
cg.close();
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const node = results[0].node;
|
|
48
|
+
const depth = Math.max(1, Math.min(10, parseInt(opts.depth) || 2));
|
|
49
|
+
const affected = await cg.getImpactRadius(node.id, depth);
|
|
50
|
+
if (opts.json) {
|
|
51
|
+
console.log(JSON.stringify({ symbol: node.name, depth, affected }));
|
|
52
|
+
cg.close();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (affected.length === 0) {
|
|
56
|
+
console.log(`
|
|
57
|
+
${import_ui.dim}No dependents found for \`${node.name}\`.${import_ui.reset}
|
|
58
|
+
`);
|
|
59
|
+
cg.close();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
console.log(`
|
|
63
|
+
${import_ui.violet}${import_ui.bold}Impact of \`${node.name}\`${import_ui.reset} ${import_ui.dim}(${affected.length} symbol(s) affected, depth: ${depth})${import_ui.reset}
|
|
64
|
+
`);
|
|
65
|
+
for (const n of affected) {
|
|
66
|
+
console.log(` ${import_ui.violet}${n.name}${import_ui.reset} ${import_ui.dim}${n.kind} ${n.filePath}:${n.startLine}${import_ui.reset}`);
|
|
67
|
+
}
|
|
68
|
+
console.log();
|
|
69
|
+
cg.close();
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
register
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=impact.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/bin/commands/impact.ts"],
|
|
4
|
+
"sourcesContent": ["import * as path from 'path';\nimport { Command } from 'commander';\nimport { bold, dim, reset, violet } from '../ui';\n\nexport function register(program: Command): void {\n program\n .command('impact <symbol>')\n .description('Show symbols that would be affected by changing a given symbol')\n .option('-d, --depth <n>', 'Max traversal depth (default: 2)', '2')\n .option('-j, --json', 'Output as JSON')\n .option('-p, --path <path>', 'Project path')\n .action(async (symbol: string, opts: { depth: string; json?: boolean; path?: string }) => {\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n const target = path.resolve(opts.path ?? process.cwd());\n const cg = await KiroGraph.open(target);\n\n const results = cg.searchNodes(symbol, undefined, 5);\n if (results.length === 0) {\n console.error(` \u2716 Symbol \"${symbol}\" not found in index.`);\n cg.close(); process.exit(1);\n }\n\n const node = results[0].node;\n const depth = Math.max(1, Math.min(10, parseInt(opts.depth) || 2));\n const affected = await cg.getImpactRadius(node.id, depth);\n\n if (opts.json) {\n console.log(JSON.stringify({ symbol: node.name, depth, affected }));\n cg.close(); return;\n }\n\n if (affected.length === 0) {\n console.log(`\\n ${dim}No dependents found for \\`${node.name}\\`.${reset}\\n`);\n cg.close(); return;\n }\n\n console.log(`\\n ${violet}${bold}Impact of \\`${node.name}\\`${reset} ${dim}(${affected.length} symbol(s) affected, depth: ${depth})${reset}\\n`);\n for (const n of affected) {\n console.log(` ${violet}${n.name}${reset} ${dim}${n.kind} ${n.filePath}:${n.startLine}${reset}`);\n }\n console.log();\n cg.close();\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;AAEtB,gBAAyC;AAElC,SAAS,SAAS,SAAwB;AAC/C,UACG,QAAQ,iBAAiB,EACzB,YAAY,gEAAgE,EA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AK,EAAE,QAAQ,IAAI,EAAE,SAAS,GAAG,eAAK,EAAE;AAAA,IACnG;AACA,YAAQ,IAAI;AACZ,OAAG,MAAM;AAAA,EACX,CAAC;AACL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var type_hierarchy_exports = {};
|
|
30
|
+
__export(type_hierarchy_exports, {
|
|
31
|
+
register: () => register
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(type_hierarchy_exports);
|
|
34
|
+
var path = __toESM(require("path"));
|
|
35
|
+
var import_ui = require("../ui");
|
|
36
|
+
function register(program) {
|
|
37
|
+
program.command("type-hierarchy <symbol>").description("Traverse the type hierarchy of a class or interface (base types and derived types)").option("--direction <dir>", "Direction: up (base types), down (derived types), both (default)", "both").option("-j, --json", "Output as JSON").option("-p, --path <path>", "Project path").action(async (symbol, opts) => {
|
|
38
|
+
const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
|
|
39
|
+
const target = path.resolve(opts.path ?? process.cwd());
|
|
40
|
+
const cg = await KiroGraph.open(target);
|
|
41
|
+
const results = cg.searchNodes(symbol, void 0, 5);
|
|
42
|
+
if (results.length === 0) {
|
|
43
|
+
console.error(` \u2716 Symbol "${symbol}" not found in index.`);
|
|
44
|
+
cg.close();
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const node = results[0].node;
|
|
48
|
+
const direction = ["up", "down", "both"].includes(opts.direction) ? opts.direction : "both";
|
|
49
|
+
const hierarchy = cg.getTypeHierarchy(node.id, direction);
|
|
50
|
+
if (opts.json) {
|
|
51
|
+
console.log(JSON.stringify({ symbol: node.name, direction, hierarchy }));
|
|
52
|
+
cg.close();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (hierarchy.length === 0) {
|
|
56
|
+
console.log(`
|
|
57
|
+
${import_ui.dim}No type hierarchy found for \`${node.name}\`.${import_ui.reset}
|
|
58
|
+
`);
|
|
59
|
+
cg.close();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
console.log(`
|
|
63
|
+
${import_ui.violet}${import_ui.bold}Type hierarchy of \`${node.name}\`${import_ui.reset} ${import_ui.dim}(direction: ${direction})${import_ui.reset}
|
|
64
|
+
`);
|
|
65
|
+
for (const n of hierarchy) {
|
|
66
|
+
console.log(` ${import_ui.violet}${n.name}${import_ui.reset} ${import_ui.dim}${n.kind} ${n.filePath}:${n.startLine}${import_ui.reset}`);
|
|
67
|
+
}
|
|
68
|
+
console.log();
|
|
69
|
+
cg.close();
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
register
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=type-hierarchy.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/bin/commands/type-hierarchy.ts"],
|
|
4
|
+
"sourcesContent": ["import * as path from 'path';\nimport { Command } from 'commander';\nimport { bold, dim, reset, violet } from '../ui';\n\nexport function register(program: Command): void {\n program\n .command('type-hierarchy <symbol>')\n .description('Traverse the type hierarchy of a class or interface (base types and derived types)')\n .option('--direction <dir>', 'Direction: up (base types), down (derived types), both (default)', 'both')\n .option('-j, --json', 'Output as JSON')\n .option('-p, --path <path>', 'Project path')\n .action(async (symbol: string, opts: { direction: string; json?: boolean; path?: string }) => {\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n const target = path.resolve(opts.path ?? process.cwd());\n const cg = await KiroGraph.open(target);\n\n const results = cg.searchNodes(symbol, undefined, 5);\n if (results.length === 0) {\n console.error(` \u2716 Symbol \"${symbol}\" not found in index.`);\n cg.close(); process.exit(1);\n }\n\n const node = results[0].node;\n const direction = (['up', 'down', 'both'].includes(opts.direction) ? opts.direction : 'both') as 'up' | 'down' | 'both';\n const hierarchy = cg.getTypeHierarchy(node.id, direction);\n\n if (opts.json) {\n console.log(JSON.stringify({ symbol: node.name, direction, hierarchy }));\n cg.close(); return;\n }\n\n if (hierarchy.length === 0) {\n console.log(`\\n ${dim}No type hierarchy found for \\`${node.name}\\`.${reset}\\n`);\n cg.close(); return;\n }\n\n console.log(`\\n ${violet}${bold}Type hierarchy of \\`${node.name}\\`${reset} ${dim}(direction: ${direction})${reset}\\n`);\n for (const n of hierarchy) {\n console.log(` ${violet}${n.name}${reset} ${dim}${n.kind} ${n.filePath}:${n.startLine}${reset}`);\n }\n console.log();\n cg.close();\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;AAEtB,gBAAyC;AAElC,SAAS,SAAS,SAAwB;AAC/C,UACG,QAAQ,yBAAyB,EACjC,YAAY,oFAAoF,EAChG,OAAO,qBAAqB,oEAAoE,MAAM,EACtG,OAAO,cAAc,gBAAgB,EACrC,OAAO,qBAAqB,cAAc,EAC1C,OAAO,OAAO,QAAgB,SAA+D;AAC5F,UAAM,aAAa,MAAM,QAAQ,QAAQ,EAAE,KAAK,MAAM,QAAQ,gBAAgB,CAAC,GAAG;AAClF,UAAM,SAAS,KAAK,QAAQ,KAAK,QAAQ,QAAQ,IAAI,CAAC;AACtD,UAAM,KAAK,MAAM,UAAU,KAAK,MAAM;AAEtC,UAAM,UAAU,GAAG,YAAY,QAAQ,QAAW,CAAC;AACnD,QAAI,QAAQ,WAAW,GAAG;AACxB,cAAQ,MAAM,oBAAe,MAAM,uBAAuB;AAC1D,SAAG,MAAM;AAAG,cAAQ,KAAK,CAAC;AAAA,IAC5B;AAEA,UAAM,OAAO,QAAQ,CAAC,EAAE;AACxB,UAAM,YAAa,CAAC,MAAM,QAAQ,MAAM,EAAE,SAAS,KAAK,SAAS,IAAI,KAAK,YAAY;AACtF,UAAM,YAAY,GAAG,iBAAiB,KAAK,IAAI,SAAS;AAExD,QAAI,KAAK,MAAM;AACb,cAAQ,IAAI,KAAK,UAAU,EAAE,QAAQ,KAAK,MAAM,WAAW,UAAU,CAAC,CAAC;AACvE,SAAG,MAAM;AAAG;AAAA,IACd;AAEA,QAAI,UAAU,WAAW,GAAG;AAC1B,cAAQ,IAAI;AAAA,IAAO,aAAG,iCAAiC,KAAK,IAAI,MAAM,eAAK;AAAA,CAAI;AAC/E,SAAG,MAAM;AAAG;AAAA,IACd;AAEA,YAAQ,IAAI;AAAA,IAAO,gBAAM,GAAG,cAAI,uBAAuB,KAAK,IAAI,KAAK,eAAK,KAAK,aAAG,eAAe,SAAS,IAAI,eAAK;AAAA,CAAI;AACvH,eAAW,KAAK,WAAW;AACzB,cAAQ,IAAI,KAAK,gBAAM,GAAG,EAAE,IAAI,GAAG,eAAK,KAAK,aAAG,GAAG,EAAE,IAAI,KAAK,EAAE,QAAQ,IAAI,EAAE,SAAS,GAAG,eAAK,EAAE;AAAA,IACnG;AACA,YAAQ,IAAI;AACZ,OAAG,MAAM;AAAA,EACX,CAAC;AACL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -148,16 +148,22 @@ function removeGeneratedBlock(filePath, blockId) {
|
|
|
148
148
|
function escapeRegExp(s) {
|
|
149
149
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
150
150
|
}
|
|
151
|
-
function buildInstructionOpts(
|
|
151
|
+
function buildInstructionOpts(opts, hasHooks) {
|
|
152
152
|
return {
|
|
153
|
-
cavemanMode,
|
|
154
|
-
shellCompressionLevel: shellCompressionLevel ?? void 0,
|
|
155
|
-
enableArchitecture: enableArchitecture ?? false,
|
|
156
|
-
enableMemory: enableMemory ?? false,
|
|
157
|
-
enableDocs: enableDocs ?? false,
|
|
158
|
-
enableData: enableData ?? false,
|
|
159
|
-
enableSecurity: enableSecurity ?? false,
|
|
160
|
-
enablePatterns: enablePatterns ?? false,
|
|
153
|
+
cavemanMode: opts.cavemanMode,
|
|
154
|
+
shellCompressionLevel: opts.shellCompressionLevel ?? void 0,
|
|
155
|
+
enableArchitecture: opts.enableArchitecture ?? false,
|
|
156
|
+
enableMemory: opts.enableMemory ?? false,
|
|
157
|
+
enableDocs: opts.enableDocs ?? false,
|
|
158
|
+
enableData: opts.enableData ?? false,
|
|
159
|
+
enableSecurity: opts.enableSecurity ?? false,
|
|
160
|
+
enablePatterns: opts.enablePatterns ?? false,
|
|
161
|
+
enableWiki: opts.enableWiki ?? false,
|
|
162
|
+
enableCodeHealth: opts.enableCodeHealth ?? false,
|
|
163
|
+
enableAdvancedAnalysis: opts.enableAdvancedAnalysis ?? false,
|
|
164
|
+
enableAgentUtils: opts.enableAgentUtils ?? false,
|
|
165
|
+
enableGeneralCompression: opts.enableGeneralCompression ?? false,
|
|
166
|
+
trackCallSites: opts.trackCallSites ?? false,
|
|
161
167
|
hasHooks: hasHooks ?? false
|
|
162
168
|
};
|
|
163
169
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/bin/installer/common.ts"],
|
|
4
|
-
"sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport { KIROGRAPH_TOOL_NAMES } from '../../mcp/tool-names';\nimport type { InstructionOptions } from './instructions';\nimport type { CavemanMode } from './caveman';\n\nexport type InstallTarget = 'kiro' | 'claude' | 'codex' | 'cursor' | 'antigravity' | 'opencode' | 'windsurf' | 'cline' | 'copilot' | 'copilot-cli' | 'junie' | 'gemini-cli' | 'continue' | 'roo' | 'warp' | 'aider' | 'trae' | 'augment' | 'kilo' | 'amp' | 'devin' | 'replit' | 'goose' | 'openhands' | 'tabnine' | 'mistral-vibe' | 'ibm-bob' | 'crush' | 'droid-factory' | 'forgecode' | 'iflow' | 'qwen' | 'rovo' | 'qoder';\n\nexport const KIROGRAPH_SERVER_NAME = 'kirograph';\nexport const KIROGRAPH_COMMAND = 'kirograph';\nexport const KIROGRAPH_MCP_ARGS = ['serve', '--mcp'];\nexport const KIROGRAPH_SYNC_CMD = 'kirograph sync-if-dirty --quiet 2>/dev/null || true';\nexport const KIROGRAPH_TOOLS = KIROGRAPH_TOOL_NAMES;\nexport const KIROGRAPH_SCOPED_TOOLS = KIROGRAPH_TOOL_NAMES.map(name => `@kirograph/${name}`);\n\nexport function ensureDir(p: string): void {\n fs.mkdirSync(p, { recursive: true });\n}\n\nexport function readJson(p: string): any {\n try { return JSON.parse(fs.readFileSync(p, 'utf8')); } catch { return {}; }\n}\n\nexport function writeJson(p: string, data: unknown): void {\n fs.writeFileSync(p, JSON.stringify(data, null, 2) + '\\n');\n}\n\n/**\n * Write MCP server config to a JSON file under the mcpServers key.\n * Returns true if the config was written, false if already configured (idempotent).\n */\nexport function writeMcpServersConfig(configPath: string, serverConfig: object): boolean {\n ensureDir(path.dirname(configPath));\n const existing = readJson(configPath);\n existing.mcpServers = existing.mcpServers ?? {};\n if (existing.mcpServers[KIROGRAPH_SERVER_NAME]) {\n return false; // Already configured\n }\n existing.mcpServers[KIROGRAPH_SERVER_NAME] = serverConfig;\n writeJson(configPath, existing);\n return true;\n}\n\n/**\n * Always write (overwrite) the MCP server config entry, regardless of whether it already exists.\n * Used when the final state is known upfront and idempotency would cause stale data.\n */\nexport function overwriteMcpServersConfig(configPath: string, serverConfig: object): void {\n ensureDir(path.dirname(configPath));\n const existing = readJson(configPath);\n existing.mcpServers = existing.mcpServers ?? {};\n existing.mcpServers[KIROGRAPH_SERVER_NAME] = serverConfig;\n writeJson(configPath, existing);\n}\n\nexport function removeMcpServersConfig(configPath: string): boolean {\n if (!fs.existsSync(configPath)) return false;\n const existing = readJson(configPath);\n if (!existing.mcpServers?.[KIROGRAPH_SERVER_NAME]) return false;\n delete existing.mcpServers[KIROGRAPH_SERVER_NAME];\n writeJson(configPath, existing);\n return true;\n}\n\nexport function appendImportLine(filePath: string, line: string, heading: string): boolean {\n const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : '';\n if (existing.includes(line)) return false;\n\n const prefix = existing.length > 0 && !existing.endsWith('\\n') ? '\\n' : '';\n const separator = existing.trim().length > 0 ? '\\n' : '';\n fs.writeFileSync(filePath, existing + prefix + separator + heading + '\\n' + line + '\\n');\n return true;\n}\n\nexport function removeImportLine(filePath: string, line: string): boolean {\n if (!fs.existsSync(filePath)) return false;\n const original = fs.readFileSync(filePath, 'utf8');\n const next = original\n .split('\\n')\n .filter(l => l.trim() !== line)\n .join('\\n')\n .replace(/\\n{3,}/g, '\\n\\n');\n if (next === original) return false;\n fs.writeFileSync(filePath, next.endsWith('\\n') ? next : next + '\\n');\n return true;\n}\n\nexport function upsertGeneratedBlock(filePath: string, blockId: string, heading: string, content: string): boolean {\n const start = `<!-- kirograph:${blockId}:start -->`;\n const end = `<!-- kirograph:${blockId}:end -->`;\n const block = `${start}\\n${heading}\\n\\n${content.trim()}\\n${end}`;\n const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : '';\n const pattern = new RegExp(`${escapeRegExp(start)}[\\\\s\\\\S]*?${escapeRegExp(end)}`);\n\n if (pattern.test(existing)) {\n const next = existing.replace(pattern, block);\n if (next === existing) return false;\n fs.writeFileSync(filePath, next.endsWith('\\n') ? next : next + '\\n');\n return true;\n }\n\n const prefix = existing.length > 0 && !existing.endsWith('\\n') ? '\\n' : '';\n const separator = existing.trim().length > 0 ? '\\n' : '';\n fs.writeFileSync(filePath, existing + prefix + separator + block + '\\n');\n return true;\n}\n\nexport function removeGeneratedBlock(filePath: string, blockId: string): boolean {\n if (!fs.existsSync(filePath)) return false;\n const start = `<!-- kirograph:${blockId}:start -->`;\n const end = `<!-- kirograph:${blockId}:end -->`;\n const original = fs.readFileSync(filePath, 'utf8');\n const pattern = new RegExp(`\\\\n?${escapeRegExp(start)}[\\\\s\\\\S]*?${escapeRegExp(end)}\\\\n?`);\n const next = original.replace(pattern, '\\n').replace(/\\n{3,}/g, '\\n\\n');\n if (next === original) return false;\n fs.writeFileSync(filePath, next.endsWith('\\n') ? next : next + '\\n');\n return true;\n}\n\nfunction escapeRegExp(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Build InstructionOptions from the installLate parameters.\n * Used by all targets to pass full feature config to buildAgentInstructions.\n */\nexport function buildInstructionOpts(
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AACtB,wBAAqC;
|
|
4
|
+
"sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport { KIROGRAPH_TOOL_NAMES } from '../../mcp/tool-names';\nimport type { InstructionOptions } from './instructions';\nimport type { CavemanMode } from './caveman';\n\n/** Single options object passed to every target's installLate(). */\nexport interface LateInstallOptions {\n cavemanMode?: CavemanMode | 'off';\n shellCompressionLevel?: string;\n enableMemory?: boolean;\n enableDocs?: boolean;\n enableData?: boolean;\n enableSecurity?: boolean;\n enableArchitecture?: boolean;\n enablePatterns?: boolean;\n enableWatchmen?: boolean;\n watchmenSynthesisMode?: 'local' | 'agent';\n enableWiki?: boolean;\n wikiSynthesisMode?: 'local' | 'agent';\n wikiLocalModel?: string;\n enableCodeHealth?: boolean;\n enableAdvancedAnalysis?: boolean;\n enableAgentUtils?: boolean;\n enableGeneralCompression?: boolean;\n trackCallSites?: boolean;\n kiroHookFormat?: 'v1-legacy' | 'v2';\n}\n\nexport type InstallTarget = 'kiro' | 'claude' | 'codex' | 'cursor' | 'antigravity' | 'opencode' | 'windsurf' | 'cline' | 'copilot' | 'copilot-cli' | 'junie' | 'gemini-cli' | 'continue' | 'roo' | 'warp' | 'aider' | 'trae' | 'augment' | 'kilo' | 'amp' | 'devin' | 'replit' | 'goose' | 'openhands' | 'tabnine' | 'mistral-vibe' | 'ibm-bob' | 'crush' | 'droid-factory' | 'forgecode' | 'iflow' | 'qwen' | 'rovo' | 'qoder';\n\nexport const KIROGRAPH_SERVER_NAME = 'kirograph';\nexport const KIROGRAPH_COMMAND = 'kirograph';\nexport const KIROGRAPH_MCP_ARGS = ['serve', '--mcp'];\nexport const KIROGRAPH_SYNC_CMD = 'kirograph sync-if-dirty --quiet 2>/dev/null || true';\nexport const KIROGRAPH_TOOLS = KIROGRAPH_TOOL_NAMES;\nexport const KIROGRAPH_SCOPED_TOOLS = KIROGRAPH_TOOL_NAMES.map(name => `@kirograph/${name}`);\n\nexport function ensureDir(p: string): void {\n fs.mkdirSync(p, { recursive: true });\n}\n\nexport function readJson(p: string): any {\n try { return JSON.parse(fs.readFileSync(p, 'utf8')); } catch { return {}; }\n}\n\nexport function writeJson(p: string, data: unknown): void {\n fs.writeFileSync(p, JSON.stringify(data, null, 2) + '\\n');\n}\n\n/**\n * Write MCP server config to a JSON file under the mcpServers key.\n * Returns true if the config was written, false if already configured (idempotent).\n */\nexport function writeMcpServersConfig(configPath: string, serverConfig: object): boolean {\n ensureDir(path.dirname(configPath));\n const existing = readJson(configPath);\n existing.mcpServers = existing.mcpServers ?? {};\n if (existing.mcpServers[KIROGRAPH_SERVER_NAME]) {\n return false; // Already configured\n }\n existing.mcpServers[KIROGRAPH_SERVER_NAME] = serverConfig;\n writeJson(configPath, existing);\n return true;\n}\n\n/**\n * Always write (overwrite) the MCP server config entry, regardless of whether it already exists.\n * Used when the final state is known upfront and idempotency would cause stale data.\n */\nexport function overwriteMcpServersConfig(configPath: string, serverConfig: object): void {\n ensureDir(path.dirname(configPath));\n const existing = readJson(configPath);\n existing.mcpServers = existing.mcpServers ?? {};\n existing.mcpServers[KIROGRAPH_SERVER_NAME] = serverConfig;\n writeJson(configPath, existing);\n}\n\nexport function removeMcpServersConfig(configPath: string): boolean {\n if (!fs.existsSync(configPath)) return false;\n const existing = readJson(configPath);\n if (!existing.mcpServers?.[KIROGRAPH_SERVER_NAME]) return false;\n delete existing.mcpServers[KIROGRAPH_SERVER_NAME];\n writeJson(configPath, existing);\n return true;\n}\n\nexport function appendImportLine(filePath: string, line: string, heading: string): boolean {\n const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : '';\n if (existing.includes(line)) return false;\n\n const prefix = existing.length > 0 && !existing.endsWith('\\n') ? '\\n' : '';\n const separator = existing.trim().length > 0 ? '\\n' : '';\n fs.writeFileSync(filePath, existing + prefix + separator + heading + '\\n' + line + '\\n');\n return true;\n}\n\nexport function removeImportLine(filePath: string, line: string): boolean {\n if (!fs.existsSync(filePath)) return false;\n const original = fs.readFileSync(filePath, 'utf8');\n const next = original\n .split('\\n')\n .filter(l => l.trim() !== line)\n .join('\\n')\n .replace(/\\n{3,}/g, '\\n\\n');\n if (next === original) return false;\n fs.writeFileSync(filePath, next.endsWith('\\n') ? next : next + '\\n');\n return true;\n}\n\nexport function upsertGeneratedBlock(filePath: string, blockId: string, heading: string, content: string): boolean {\n const start = `<!-- kirograph:${blockId}:start -->`;\n const end = `<!-- kirograph:${blockId}:end -->`;\n const block = `${start}\\n${heading}\\n\\n${content.trim()}\\n${end}`;\n const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : '';\n const pattern = new RegExp(`${escapeRegExp(start)}[\\\\s\\\\S]*?${escapeRegExp(end)}`);\n\n if (pattern.test(existing)) {\n const next = existing.replace(pattern, block);\n if (next === existing) return false;\n fs.writeFileSync(filePath, next.endsWith('\\n') ? next : next + '\\n');\n return true;\n }\n\n const prefix = existing.length > 0 && !existing.endsWith('\\n') ? '\\n' : '';\n const separator = existing.trim().length > 0 ? '\\n' : '';\n fs.writeFileSync(filePath, existing + prefix + separator + block + '\\n');\n return true;\n}\n\nexport function removeGeneratedBlock(filePath: string, blockId: string): boolean {\n if (!fs.existsSync(filePath)) return false;\n const start = `<!-- kirograph:${blockId}:start -->`;\n const end = `<!-- kirograph:${blockId}:end -->`;\n const original = fs.readFileSync(filePath, 'utf8');\n const pattern = new RegExp(`\\\\n?${escapeRegExp(start)}[\\\\s\\\\S]*?${escapeRegExp(end)}\\\\n?`);\n const next = original.replace(pattern, '\\n').replace(/\\n{3,}/g, '\\n\\n');\n if (next === original) return false;\n fs.writeFileSync(filePath, next.endsWith('\\n') ? next : next + '\\n');\n return true;\n}\n\nfunction escapeRegExp(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Build InstructionOptions from the installLate parameters.\n * Used by all targets to pass full feature config to buildAgentInstructions.\n */\nexport function buildInstructionOpts(opts: LateInstallOptions, hasHooks?: boolean): InstructionOptions {\n return {\n cavemanMode: opts.cavemanMode,\n shellCompressionLevel: (opts.shellCompressionLevel as InstructionOptions['shellCompressionLevel']) ?? undefined,\n enableArchitecture: opts.enableArchitecture ?? false,\n enableMemory: opts.enableMemory ?? false,\n enableDocs: opts.enableDocs ?? false,\n enableData: opts.enableData ?? false,\n enableSecurity: opts.enableSecurity ?? false,\n enablePatterns: opts.enablePatterns ?? false,\n enableWiki: opts.enableWiki ?? false,\n enableCodeHealth: opts.enableCodeHealth ?? false,\n enableAdvancedAnalysis: opts.enableAdvancedAnalysis ?? false,\n enableAgentUtils: opts.enableAgentUtils ?? false,\n enableGeneralCompression: opts.enableGeneralCompression ?? false,\n trackCallSites: opts.trackCallSites ?? false,\n hasHooks: hasHooks ?? false,\n };\n}\n\nconst violet = '\\x1b[38;5;99m';\nconst resetAnsi = '\\x1b[0m';\nconst dimAnsi = '\\x1b[2m';\nconst boldAnsi = '\\x1b[1m';\n\n/**\n * Print a highlighted MCP config JSON block for targets that need user-scoped setup.\n */\nexport function printMcpSetup(configPath: string, projectRoot: string): void {\n const escapedPath = projectRoot.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n console.log(`\\n ${dimAnsi}Add the MCP server manually:${resetAnsi}`);\n console.log(` ${dimAnsi}Edit${resetAnsi} ${violet}${boldAnsi}${configPath}${resetAnsi} ${dimAnsi}and add:${resetAnsi}`);\n console.log(` ${violet}{${resetAnsi}`);\n console.log(` ${violet} \"mcpServers\": {${resetAnsi}`);\n console.log(` ${violet} \"kirograph\": {${resetAnsi}`);\n console.log(` ${violet} \"command\": \"kirograph\",${resetAnsi}`);\n console.log(` ${violet} \"args\": [\"serve\", \"--mcp\", \"--path\", \"${escapedPath}\"]${resetAnsi}`);\n console.log(` ${violet} }${resetAnsi}`);\n console.log(` ${violet} }${resetAnsi}`);\n console.log(` ${violet}}${resetAnsi}\\n`);\n}\n\n/**\n * Print a highlighted CLI command for MCP registration.\n */\nexport function printMcpCommand(command: string): void {\n console.log(`\\n ${dimAnsi}Add the MCP server with:${resetAnsi}`);\n console.log(` ${violet}${boldAnsi}${command}${resetAnsi}\\n`);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AACtB,wBAAqC;AA6B9B,MAAM,wBAAwB;AAC9B,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB,CAAC,SAAS,OAAO;AAC5C,MAAM,qBAAqB;AAC3B,MAAM,kBAAkB;AACxB,MAAM,yBAAyB,uCAAqB,IAAI,UAAQ,cAAc,IAAI,EAAE;AAEpF,SAAS,UAAU,GAAiB;AACzC,KAAG,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;AACrC;AAEO,SAAS,SAAS,GAAgB;AACvC,MAAI;AAAE,WAAO,KAAK,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC;AAAA,EAAG,QAAQ;AAAE,WAAO,CAAC;AAAA,EAAG;AAC5E;AAEO,SAAS,UAAU,GAAW,MAAqB;AACxD,KAAG,cAAc,GAAG,KAAK,UAAU,MAAM,MAAM,CAAC,IAAI,IAAI;AAC1D;AAMO,SAAS,sBAAsB,YAAoB,cAA+B;AACvF,YAAU,KAAK,QAAQ,UAAU,CAAC;AAClC,QAAM,WAAW,SAAS,UAAU;AACpC,WAAS,aAAa,SAAS,cAAc,CAAC;AAC9C,MAAI,SAAS,WAAW,qBAAqB,GAAG;AAC9C,WAAO;A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