@vpxa/kb 0.1.1 → 0.1.3

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 (138) hide show
  1. package/README.md +3 -3
  2. package/package.json +1 -1
  3. package/packages/analyzers/dist/blast-radius-analyzer.js +13 -114
  4. package/packages/analyzers/dist/dependency-analyzer.js +11 -425
  5. package/packages/analyzers/dist/diagram-generator.js +4 -86
  6. package/packages/analyzers/dist/entry-point-analyzer.js +5 -239
  7. package/packages/analyzers/dist/index.js +1 -23
  8. package/packages/analyzers/dist/knowledge-producer.js +24 -113
  9. package/packages/analyzers/dist/pattern-analyzer.js +5 -359
  10. package/packages/analyzers/dist/regex-call-graph.js +1 -428
  11. package/packages/analyzers/dist/structure-analyzer.js +4 -258
  12. package/packages/analyzers/dist/symbol-analyzer.js +13 -442
  13. package/packages/analyzers/dist/ts-call-graph.js +1 -160
  14. package/packages/analyzers/dist/types.js +0 -1
  15. package/packages/chunker/dist/call-graph-extractor.js +1 -90
  16. package/packages/chunker/dist/chunker-factory.js +1 -36
  17. package/packages/chunker/dist/chunker.interface.js +0 -1
  18. package/packages/chunker/dist/code-chunker.js +14 -134
  19. package/packages/chunker/dist/generic-chunker.js +5 -72
  20. package/packages/chunker/dist/index.js +1 -21
  21. package/packages/chunker/dist/markdown-chunker.js +7 -119
  22. package/packages/chunker/dist/treesitter-chunker.js +8 -234
  23. package/packages/cli/dist/commands/analyze.js +3 -112
  24. package/packages/cli/dist/commands/context-cmds.js +1 -155
  25. package/packages/cli/dist/commands/environment.js +2 -204
  26. package/packages/cli/dist/commands/execution.js +1 -137
  27. package/packages/cli/dist/commands/graph.js +7 -81
  28. package/packages/cli/dist/commands/init.js +9 -87
  29. package/packages/cli/dist/commands/knowledge.js +1 -139
  30. package/packages/cli/dist/commands/search.js +8 -267
  31. package/packages/cli/dist/commands/system.js +4 -241
  32. package/packages/cli/dist/commands/workspace.js +2 -388
  33. package/packages/cli/dist/context.js +1 -14
  34. package/packages/cli/dist/helpers.js +3 -458
  35. package/packages/cli/dist/index.d.ts +1 -1
  36. package/packages/cli/dist/index.js +3 -69
  37. package/packages/cli/dist/kb-init.js +1 -82
  38. package/packages/cli/dist/types.js +0 -1
  39. package/packages/core/dist/constants.js +1 -43
  40. package/packages/core/dist/content-detector.js +1 -79
  41. package/packages/core/dist/errors.js +1 -40
  42. package/packages/core/dist/index.js +1 -9
  43. package/packages/core/dist/logger.js +1 -34
  44. package/packages/core/dist/types.js +0 -1
  45. package/packages/embeddings/dist/embedder.interface.js +0 -1
  46. package/packages/embeddings/dist/index.js +1 -5
  47. package/packages/embeddings/dist/onnx-embedder.js +1 -82
  48. package/packages/indexer/dist/file-hasher.js +1 -13
  49. package/packages/indexer/dist/filesystem-crawler.js +1 -125
  50. package/packages/indexer/dist/graph-extractor.js +1 -111
  51. package/packages/indexer/dist/incremental-indexer.js +1 -278
  52. package/packages/indexer/dist/index.js +1 -14
  53. package/packages/server/dist/api.js +1 -9
  54. package/packages/server/dist/config.js +1 -75
  55. package/packages/server/dist/curated-manager.js +9 -356
  56. package/packages/server/dist/index.js +1 -134
  57. package/packages/server/dist/replay-interceptor.js +1 -38
  58. package/packages/server/dist/resources/resources.js +2 -40
  59. package/packages/server/dist/server.js +1 -247
  60. package/packages/server/dist/tools/analyze.tools.js +1 -288
  61. package/packages/server/dist/tools/forge.tools.js +11 -499
  62. package/packages/server/dist/tools/forget.tool.js +3 -39
  63. package/packages/server/dist/tools/graph.tool.js +5 -110
  64. package/packages/server/dist/tools/list.tool.js +5 -53
  65. package/packages/server/dist/tools/lookup.tool.js +8 -51
  66. package/packages/server/dist/tools/onboard.tool.js +2 -112
  67. package/packages/server/dist/tools/produce.tool.js +4 -74
  68. package/packages/server/dist/tools/read.tool.js +4 -47
  69. package/packages/server/dist/tools/reindex.tool.js +2 -70
  70. package/packages/server/dist/tools/remember.tool.js +3 -42
  71. package/packages/server/dist/tools/replay.tool.js +6 -88
  72. package/packages/server/dist/tools/search.tool.js +17 -327
  73. package/packages/server/dist/tools/status.tool.js +3 -68
  74. package/packages/server/dist/tools/toolkit.tools.js +20 -1673
  75. package/packages/server/dist/tools/update.tool.js +3 -39
  76. package/packages/server/dist/tools/utility.tools.js +19 -456
  77. package/packages/store/dist/graph-store.interface.js +0 -1
  78. package/packages/store/dist/index.js +1 -9
  79. package/packages/store/dist/lance-store.js +1 -258
  80. package/packages/store/dist/sqlite-graph-store.js +8 -309
  81. package/packages/store/dist/store-factory.js +1 -14
  82. package/packages/store/dist/store.interface.js +0 -1
  83. package/packages/tools/dist/batch.js +1 -45
  84. package/packages/tools/dist/changelog.js +2 -112
  85. package/packages/tools/dist/check.js +2 -59
  86. package/packages/tools/dist/checkpoint.js +2 -43
  87. package/packages/tools/dist/codemod.js +2 -69
  88. package/packages/tools/dist/compact.js +3 -60
  89. package/packages/tools/dist/data-transform.js +1 -124
  90. package/packages/tools/dist/dead-symbols.js +2 -71
  91. package/packages/tools/dist/delegate.js +3 -128
  92. package/packages/tools/dist/diff-parse.js +3 -153
  93. package/packages/tools/dist/digest.js +7 -242
  94. package/packages/tools/dist/encode.js +1 -46
  95. package/packages/tools/dist/env-info.js +1 -58
  96. package/packages/tools/dist/eval.js +3 -79
  97. package/packages/tools/dist/evidence-map.js +3 -203
  98. package/packages/tools/dist/file-summary.js +2 -106
  99. package/packages/tools/dist/file-walk.js +1 -75
  100. package/packages/tools/dist/find-examples.js +3 -48
  101. package/packages/tools/dist/find.js +1 -120
  102. package/packages/tools/dist/forge-classify.js +2 -319
  103. package/packages/tools/dist/forge-ground.js +1 -184
  104. package/packages/tools/dist/git-context.js +3 -46
  105. package/packages/tools/dist/graph-query.js +1 -194
  106. package/packages/tools/dist/health.js +1 -118
  107. package/packages/tools/dist/http-request.js +1 -58
  108. package/packages/tools/dist/index.js +1 -273
  109. package/packages/tools/dist/lane.js +7 -227
  110. package/packages/tools/dist/measure.js +2 -119
  111. package/packages/tools/dist/onboard.js +42 -1136
  112. package/packages/tools/dist/parse-output.js +2 -158
  113. package/packages/tools/dist/process-manager.js +1 -69
  114. package/packages/tools/dist/queue.js +2 -126
  115. package/packages/tools/dist/regex-test.js +1 -39
  116. package/packages/tools/dist/rename.js +2 -70
  117. package/packages/tools/dist/replay.js +6 -108
  118. package/packages/tools/dist/schema-validate.js +1 -141
  119. package/packages/tools/dist/scope-map.js +1 -72
  120. package/packages/tools/dist/snippet.js +1 -80
  121. package/packages/tools/dist/stash.js +2 -60
  122. package/packages/tools/dist/stratum-card.js +5 -238
  123. package/packages/tools/dist/symbol.js +3 -87
  124. package/packages/tools/dist/test-run.js +2 -55
  125. package/packages/tools/dist/text-utils.js +2 -31
  126. package/packages/tools/dist/time-utils.js +1 -135
  127. package/packages/tools/dist/trace.js +2 -114
  128. package/packages/tools/dist/truncation.js +10 -41
  129. package/packages/tools/dist/watch.js +1 -61
  130. package/packages/tools/dist/web-fetch.js +9 -244
  131. package/packages/tools/dist/web-search.js +1 -46
  132. package/packages/tools/dist/workset.js +2 -77
  133. package/packages/tui/dist/App.js +260 -52468
  134. package/packages/tui/dist/index.js +286 -54551
  135. package/packages/tui/dist/panels/CuratedPanel.js +211 -34291
  136. package/packages/tui/dist/panels/LogPanel.js +259 -51703
  137. package/packages/tui/dist/panels/SearchPanel.js +212 -34824
  138. package/packages/tui/dist/panels/StatusPanel.js +211 -34304
@@ -1,458 +1,3 @@
1
- import { readFile } from "node:fs/promises";
2
- import { resolve } from "node:path";
3
- import {
4
- check,
5
- find
6
- } from "@kb/tools";
7
- function extractNumFlag(args, flag, defaultValue) {
8
- const idx = args.indexOf(flag);
9
- if (idx === -1 || idx + 1 >= args.length) return defaultValue;
10
- const val = Number.parseInt(args.splice(idx, 2)[1], 10);
11
- return Number.isNaN(val) ? defaultValue : val;
12
- }
13
- function extractStrFlag(args, flag, defaultValue) {
14
- const idx = args.indexOf(flag);
15
- if (idx === -1 || idx + 1 >= args.length) return defaultValue;
16
- return args.splice(idx, 2)[1];
17
- }
18
- function extractBoolFlag(args, flag) {
19
- const idx = args.indexOf(flag);
20
- if (idx === -1) return false;
21
- args.splice(idx, 1);
22
- return true;
23
- }
24
- async function readStdin() {
25
- if (process.stdin.isTTY) return "";
26
- const chunks = [];
27
- for await (const chunk of process.stdin) chunks.push(chunk);
28
- return Buffer.concat(chunks).toString("utf-8");
29
- }
30
- async function readInput(filePath) {
31
- if (filePath) return readFile(resolve(filePath), "utf-8");
32
- return readStdin();
33
- }
34
- function splitCsv(value) {
35
- return value.split(",").map((item) => item.trim()).filter(Boolean);
36
- }
37
- function parseBatchPayload(input) {
38
- const parsed = JSON.parse(input);
39
- if (Array.isArray(parsed)) {
40
- return { operations: validateBatchOperations(parsed) };
41
- }
42
- if (parsed && typeof parsed === "object" && "operations" in parsed) {
43
- const payload = parsed;
44
- return {
45
- operations: validateBatchOperations(payload.operations),
46
- concurrency: typeof payload.concurrency === "number" ? payload.concurrency : void 0
47
- };
48
- }
49
- throw new Error(
50
- "Batch input must be an array of operations or an object with an operations array."
51
- );
52
- }
53
- function validateBatchOperations(value) {
54
- if (!Array.isArray(value)) {
55
- throw new Error("Batch operations must be an array.");
56
- }
57
- return value.map((item, index) => {
58
- if (!item || typeof item !== "object") {
59
- throw new Error(`Batch operation at index ${index} must be an object.`);
60
- }
61
- const candidate = item;
62
- if (typeof candidate.id !== "string" || candidate.id.length === 0) {
63
- throw new Error(`Batch operation at index ${index} is missing a valid id.`);
64
- }
65
- if (typeof candidate.type !== "string" || candidate.type.length === 0) {
66
- throw new Error(`Batch operation ${candidate.id} is missing a valid type.`);
67
- }
68
- if (!candidate.args || typeof candidate.args !== "object" || Array.isArray(candidate.args)) {
69
- throw new Error(`Batch operation ${candidate.id} must include an args object.`);
70
- }
71
- return {
72
- id: candidate.id,
73
- type: candidate.type,
74
- args: candidate.args
75
- };
76
- });
77
- }
78
- function formatFocusRanges(ranges) {
79
- return ranges.map((range) => {
80
- const heading = range.heading ? ` ${range.heading}` : "";
81
- return `${range.start}-${range.end}${heading}`;
82
- }).join(", ");
83
- }
84
- function printParsedOutput(result) {
85
- switch (result.tool) {
86
- case "tsc":
87
- case "biome": {
88
- console.log(`${result.tool} errors: ${result.errors.length}`);
89
- for (const error of result.errors) {
90
- const location = [error.line, error.column].filter((value) => value !== void 0).join(":");
91
- const prefix = location ? `${error.file}:${location}` : error.file;
92
- const code = error.code ? ` ${error.code}` : "";
93
- console.log(`- ${prefix} [${error.severity}${code}] ${error.message}`);
94
- }
95
- return;
96
- }
97
- case "vitest":
98
- console.log("Vitest summary");
99
- console.log(` Passed: ${result.summary.passed}`);
100
- console.log(` Failed: ${result.summary.failed}`);
101
- console.log(` Skipped: ${result.summary.skipped}`);
102
- if (result.summary.duration !== void 0) {
103
- console.log(` Duration: ${result.summary.duration}ms`);
104
- }
105
- for (const test of result.summary.tests) {
106
- if (test.status !== "fail") continue;
107
- console.log(`- ${test.name}${test.file ? ` (${test.file})` : ""}`);
108
- if (test.error) console.log(` ${test.error}`);
109
- }
110
- return;
111
- case "git-status":
112
- console.log(`Branch: ${result.status.branch ?? "unknown"}`);
113
- console.log(`Staged: ${result.status.staged.length}`);
114
- for (const item of result.status.staged) console.log(` ${item.status} ${item.file}`);
115
- console.log(`Unstaged: ${result.status.unstaged.length}`);
116
- for (const item of result.status.unstaged) console.log(` ${item.status} ${item.file}`);
117
- console.log(`Untracked: ${result.status.untracked.length}`);
118
- for (const item of result.status.untracked) console.log(` ?? ${item}`);
119
- return;
120
- }
121
- }
122
- function printCheckResult(result) {
123
- console.log(`Overall: ${result.passed ? "passed" : "failed"}`);
124
- printCheckSection("tsc", result.tsc.passed, result.tsc.errors);
125
- printCheckSection("biome", result.biome.passed, result.biome.errors);
126
- }
127
- function printCheckSection(label, passed, errors) {
128
- console.log(`${label}: ${passed ? "passed" : `${errors.length} issue(s)`}`);
129
- for (const error of errors) {
130
- const location = [error.line, error.column].filter((value) => value !== void 0).join(":");
131
- const prefix = location ? `${error.file}:${location}` : error.file;
132
- const code = error.code ? ` ${error.code}` : "";
133
- console.log(` - ${prefix} [${error.severity}${code}] ${error.message}`);
134
- }
135
- }
136
- function printTestRunResult(result) {
137
- console.log(`Vitest: ${result.passed ? "passed" : "failed"}`);
138
- console.log(` Duration: ${result.durationMs}ms`);
139
- console.log(` Passed: ${result.summary.passed}`);
140
- console.log(` Failed: ${result.summary.failed}`);
141
- console.log(` Skipped: ${result.summary.skipped}`);
142
- if (result.summary.suites !== void 0) {
143
- console.log(` Suites: ${result.summary.suites}`);
144
- }
145
- const failedTests = result.summary.tests.filter((test) => test.status === "fail");
146
- if (failedTests.length === 0) return;
147
- console.log("Failed tests:");
148
- for (const test of failedTests) {
149
- console.log(` - ${test.name}${test.file ? ` (${test.file})` : ""}`);
150
- if (test.error) console.log(` ${test.error}`);
151
- }
152
- }
153
- function printGitContext(result) {
154
- console.log(`Branch: ${result.branch}`);
155
- console.log(`Staged: ${result.status.staged.length}`);
156
- for (const file of result.status.staged) console.log(` - ${file}`);
157
- console.log(`Modified: ${result.status.modified.length}`);
158
- for (const file of result.status.modified) console.log(` - ${file}`);
159
- console.log(`Untracked: ${result.status.untracked.length}`);
160
- for (const file of result.status.untracked) console.log(` - ${file}`);
161
- console.log("");
162
- console.log("Recent commits:");
163
- if (result.recentCommits.length === 0) {
164
- console.log(" none");
165
- } else {
166
- for (const commit of result.recentCommits) {
167
- console.log(` - ${commit.hash} ${commit.message}`);
168
- console.log(` ${commit.author} @ ${commit.date}`);
169
- }
170
- }
171
- if (result.diff) {
172
- console.log("");
173
- console.log("Diff stat:");
174
- console.log(result.diff);
175
- }
176
- }
177
- function printDiffFiles(files) {
178
- if (files.length === 0) {
179
- console.log("No diff files found.");
180
- return;
181
- }
182
- for (const file of files) {
183
- const renameInfo = file.oldPath ? ` (from ${file.oldPath})` : "";
184
- console.log(`${file.path}${renameInfo}`);
185
- console.log(` Status: ${file.status}`);
186
- console.log(` Changes: +${file.additions} -${file.deletions}`);
187
- console.log(` Hunks: ${file.hunks.length}`);
188
- for (const hunk of file.hunks) {
189
- const header = hunk.header ? ` ${hunk.header}` : "";
190
- console.log(
191
- ` @@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@${header}`
192
- );
193
- }
194
- }
195
- }
196
- function printTraceResult(result) {
197
- console.log(`Start: ${result.start}`);
198
- console.log(`Direction: ${result.direction}`);
199
- console.log(`Depth reached: ${result.depth}`);
200
- console.log(`Nodes: ${result.nodes.length}`);
201
- if (result.nodes.length === 0) {
202
- console.log("No trace nodes found.");
203
- return;
204
- }
205
- for (const node of result.nodes) {
206
- console.log(` - [${node.relationship}] ${node.path}:${node.line} ${node.symbol}`);
207
- }
208
- }
209
- function printExamplesResult(result) {
210
- console.log(`Query: ${result.query}`);
211
- console.log(`Examples: ${result.examples.length} shown (${result.totalFound} total)`);
212
- if (result.examples.length === 0) {
213
- console.log("No matching examples found.");
214
- return;
215
- }
216
- for (const example of result.examples) {
217
- console.log("");
218
- console.log(`${example.path}:${example.startLine}-${example.endLine}`);
219
- console.log(` Context: ${example.context}`);
220
- console.log(` Relevance: ${(example.relevance * 100).toFixed(1)}%`);
221
- for (const line of example.content.split("\n")) {
222
- console.log(` ${line}`);
223
- }
224
- }
225
- }
226
- function printManagedProcess(info) {
227
- console.log(info.id);
228
- console.log(` Command: ${info.command}${info.args.length > 0 ? ` ${info.args.join(" ")}` : ""}`);
229
- console.log(` PID: ${info.pid ?? "unknown"}`);
230
- console.log(` Status: ${info.status}`);
231
- console.log(` Started: ${info.startedAt}`);
232
- if (info.exitCode !== void 0) console.log(` Exit code: ${info.exitCode}`);
233
- console.log(` Logs: ${info.logs.length}`);
234
- }
235
- function printDeadSymbolsResult(result) {
236
- console.log(`Exports scanned: ${result.totalExports}`);
237
- console.log(`Potentially dead: ${result.totalDead}`);
238
- if (result.deadSymbols.length === 0) {
239
- console.log("No dead symbols found.");
240
- return;
241
- }
242
- for (const symbolInfo of result.deadSymbols) {
243
- console.log(` - ${symbolInfo.path}:${symbolInfo.line} ${symbolInfo.kind} ${symbolInfo.name}`);
244
- }
245
- }
246
- function printFileSummary(summary) {
247
- console.log(summary.path);
248
- console.log(` Language: ${summary.language}`);
249
- console.log(` Lines: ${summary.lines}`);
250
- console.log(` Estimated tokens: ~${summary.estimatedTokens}`);
251
- console.log("");
252
- printSection("Imports", summary.imports);
253
- printSection("Exports", summary.exports);
254
- printSection(
255
- "Functions",
256
- summary.functions.map(
257
- (item) => `${item.name} @ line ${item.line}${item.exported ? " [exported]" : ""}`
258
- )
259
- );
260
- printSection(
261
- "Classes",
262
- summary.classes.map(
263
- (item) => `${item.name} @ line ${item.line}${item.exported ? " [exported]" : ""}`
264
- )
265
- );
266
- printSection(
267
- "Interfaces",
268
- summary.interfaces.map((item) => `${item.name} @ line ${item.line}`)
269
- );
270
- printSection(
271
- "Types",
272
- summary.types.map((item) => `${item.name} @ line ${item.line}`)
273
- );
274
- }
275
- function printSymbolInfo(result) {
276
- console.log(`Symbol: ${result.name}`);
277
- if (result.definedIn) {
278
- console.log(
279
- `Defined in: ${result.definedIn.path}:${result.definedIn.line} (${result.definedIn.kind})`
280
- );
281
- } else {
282
- console.log("Defined in: not found");
283
- }
284
- console.log("");
285
- console.log("Imported by:");
286
- if (result.importedBy.length === 0) {
287
- console.log(" none");
288
- } else {
289
- for (const item of result.importedBy) {
290
- console.log(` - ${item.path}:${item.line} ${item.importStatement}`);
291
- }
292
- }
293
- console.log("");
294
- console.log("Referenced in:");
295
- if (result.referencedIn.length === 0) {
296
- console.log(" none");
297
- } else {
298
- for (const item of result.referencedIn) {
299
- console.log(` - ${item.path}:${item.line} ${item.context}`);
300
- }
301
- }
302
- }
303
- function printWorkset(workset) {
304
- console.log(workset.name);
305
- console.log(` Files: ${workset.files.length}`);
306
- console.log(` Updated: ${workset.updated}`);
307
- if (workset.description) console.log(` Description: ${workset.description}`);
308
- for (const file of workset.files) console.log(` - ${file}`);
309
- }
310
- function printCheckpoint(checkpoint) {
311
- console.log(checkpoint.id);
312
- console.log(` Label: ${checkpoint.label}`);
313
- console.log(` Created: ${checkpoint.createdAt}`);
314
- if (checkpoint.notes) console.log(` Notes: ${checkpoint.notes}`);
315
- if (checkpoint.files?.length) {
316
- console.log(` Files: ${checkpoint.files.length}`);
317
- for (const file of checkpoint.files) console.log(` - ${file}`);
318
- }
319
- console.log(" Data:");
320
- for (const line of JSON.stringify(checkpoint.data, null, 2).split("\n")) {
321
- console.log(` ${line}`);
322
- }
323
- }
324
- function printSection(label, items) {
325
- console.log(`${label}:`);
326
- if (items.length === 0) {
327
- console.log(" none");
328
- console.log("");
329
- return;
330
- }
331
- for (const item of items) console.log(` - ${item}`);
332
- console.log("");
333
- }
334
- function parseMaybeJsonString(value) {
335
- const trimmed = value.trim();
336
- if (!trimmed) return "";
337
- try {
338
- return JSON.parse(trimmed);
339
- } catch {
340
- return value;
341
- }
342
- }
343
- function parseRecordString(value) {
344
- const trimmed = value.trim();
345
- if (!trimmed) return {};
346
- const parsed = JSON.parse(trimmed);
347
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
348
- throw new Error("Checkpoint data must be a JSON object.");
349
- }
350
- return parsed;
351
- }
352
- function rrf(vecResults, ftsResults, k = 60) {
353
- const merged = /* @__PURE__ */ new Map();
354
- for (let i = 0; i < vecResults.length; i++) {
355
- const r = vecResults[i];
356
- merged.set(r.record.id, { record: r.record, score: 1 / (k + i + 1) });
357
- }
358
- for (let i = 0; i < ftsResults.length; i++) {
359
- const r = ftsResults[i];
360
- const existing = merged.get(r.record.id);
361
- if (existing) existing.score += 1 / (k + i + 1);
362
- else merged.set(r.record.id, { record: r.record, score: 1 / (k + i + 1) });
363
- }
364
- return [...merged.values()].sort((a, b) => b.score - a.score);
365
- }
366
- async function executeCliBatchOperation(operation, context) {
367
- switch (operation.type) {
368
- case "search": {
369
- if (!context) throw new Error("search operation requires knowledge base context");
370
- const query = typeof operation.args.query === "string" ? operation.args.query.trim() : "";
371
- if (!query) throw new Error("search operation requires a query");
372
- const limit = typeof operation.args.limit === "number" ? operation.args.limit : 5;
373
- const searchMode = operation.args.search_mode === "semantic" || operation.args.search_mode === "keyword" ? operation.args.search_mode : "hybrid";
374
- const contentType = typeof operation.args.content_type === "string" ? operation.args.content_type : void 0;
375
- const minScore = typeof operation.args.min_score === "number" ? operation.args.min_score : 0.25;
376
- if (searchMode === "keyword") {
377
- return (await context.store.ftsSearch(query, { limit, contentType, minScore })).slice(
378
- 0,
379
- limit
380
- );
381
- }
382
- const queryVector = await context.embedder.embedQuery(query);
383
- if (searchMode === "semantic") {
384
- return context.store.search(queryVector, { limit, contentType, minScore });
385
- }
386
- const [vectorResults, ftsResults] = await Promise.all([
387
- context.store.search(queryVector, { limit: limit * 2, contentType, minScore }),
388
- context.store.ftsSearch(query, { limit: limit * 2, contentType, minScore }).catch(() => [])
389
- ]);
390
- return rrf(vectorResults, ftsResults).slice(0, limit);
391
- }
392
- case "find": {
393
- if (!context) throw new Error("find operation requires knowledge base context");
394
- const query = typeof operation.args.query === "string" ? operation.args.query : void 0;
395
- const glob = typeof operation.args.glob === "string" ? operation.args.glob : void 0;
396
- const pattern = typeof operation.args.pattern === "string" ? operation.args.pattern : void 0;
397
- const limit = typeof operation.args.limit === "number" ? operation.args.limit : 10;
398
- const contentType = typeof operation.args.content_type === "string" ? operation.args.content_type : void 0;
399
- const cwd = typeof operation.args.cwd === "string" ? operation.args.cwd : void 0;
400
- if (!query && !glob && !pattern) {
401
- throw new Error("find operation requires query, glob, or pattern");
402
- }
403
- return find(context.embedder, context.store, {
404
- query,
405
- glob,
406
- pattern,
407
- limit,
408
- contentType,
409
- cwd
410
- });
411
- }
412
- case "check": {
413
- const files = Array.isArray(operation.args.files) ? operation.args.files.filter((item) => typeof item === "string") : void 0;
414
- const cwd = typeof operation.args.cwd === "string" ? operation.args.cwd : void 0;
415
- const skipTypes = operation.args.skip_types === true;
416
- const skipLint = operation.args.skip_lint === true;
417
- return check({
418
- files,
419
- cwd,
420
- skipTypes,
421
- skipLint
422
- });
423
- }
424
- default:
425
- throw new Error(`Unsupported batch operation type: ${operation.type}`);
426
- }
427
- }
428
- export {
429
- executeCliBatchOperation,
430
- extractBoolFlag,
431
- extractNumFlag,
432
- extractStrFlag,
433
- formatFocusRanges,
434
- parseBatchPayload,
435
- parseMaybeJsonString,
436
- parseRecordString,
437
- printCheckResult,
438
- printCheckSection,
439
- printCheckpoint,
440
- printDeadSymbolsResult,
441
- printDiffFiles,
442
- printExamplesResult,
443
- printFileSummary,
444
- printGitContext,
445
- printManagedProcess,
446
- printParsedOutput,
447
- printSection,
448
- printSymbolInfo,
449
- printTestRunResult,
450
- printTraceResult,
451
- printWorkset,
452
- readInput,
453
- readStdin,
454
- rrf,
455
- splitCsv,
456
- validateBatchOperations
457
- };
458
- //# sourceMappingURL=helpers.js.map
1
+ import{readFile as p}from"node:fs/promises";import{resolve as u}from"node:path";import{check as m,find as $}from"../../tools/dist/index.js";function S(e,o,n){const t=e.indexOf(o);if(t===-1||t+1>=e.length)return n;const s=Number.parseInt(e.splice(t,2)[1],10);return Number.isNaN(s)?n:s}function k(e,o,n){const t=e.indexOf(o);return t===-1||t+1>=e.length?n:e.splice(t,2)[1]}function R(e,o){const n=e.indexOf(o);return n===-1?!1:(e.splice(n,1),!0)}async function y(){if(process.stdin.isTTY)return"";const e=[];for await(const o of process.stdin)e.push(o);return Buffer.concat(e).toString("utf-8")}async function v(e){return e?p(u(e),"utf-8"):y()}function B(e){return e.split(",").map(o=>o.trim()).filter(Boolean)}function A(e){const o=JSON.parse(e);if(Array.isArray(o))return{operations:l(o)};if(o&&typeof o=="object"&&"operations"in o){const n=o;return{operations:l(n.operations),concurrency:typeof n.concurrency=="number"?n.concurrency:void 0}}throw new Error("Batch input must be an array of operations or an object with an operations array.")}function l(e){if(!Array.isArray(e))throw new Error("Batch operations must be an array.");return e.map((o,n)=>{if(!o||typeof o!="object")throw new Error(`Batch operation at index ${n} must be an object.`);const t=o;if(typeof t.id!="string"||t.id.length===0)throw new Error(`Batch operation at index ${n} is missing a valid id.`);if(typeof t.type!="string"||t.type.length===0)throw new Error(`Batch operation ${t.id} is missing a valid type.`);if(!t.args||typeof t.args!="object"||Array.isArray(t.args))throw new Error(`Batch operation ${t.id} must include an args object.`);return{id:t.id,type:t.type,args:t.args}})}function E(e){return e.map(o=>{const n=o.heading?` ${o.heading}`:"";return`${o.start}-${o.end}${n}`}).join(", ")}function T(e){switch(e.tool){case"tsc":case"biome":{console.log(`${e.tool} errors: ${e.errors.length}`);for(const o of e.errors){const n=[o.line,o.column].filter(r=>r!==void 0).join(":"),t=n?`${o.file}:${n}`:o.file,s=o.code?` ${o.code}`:"";console.log(`- ${t} [${o.severity}${s}] ${o.message}`)}return}case"vitest":console.log("Vitest summary"),console.log(` Passed: ${e.summary.passed}`),console.log(` Failed: ${e.summary.failed}`),console.log(` Skipped: ${e.summary.skipped}`),e.summary.duration!==void 0&&console.log(` Duration: ${e.summary.duration}ms`);for(const o of e.summary.tests)o.status==="fail"&&(console.log(`- ${o.name}${o.file?` (${o.file})`:""}`),o.error&&console.log(` ${o.error}`));return;case"git-status":console.log(`Branch: ${e.status.branch??"unknown"}`),console.log(`Staged: ${e.status.staged.length}`);for(const o of e.status.staged)console.log(` ${o.status} ${o.file}`);console.log(`Unstaged: ${e.status.unstaged.length}`);for(const o of e.status.unstaged)console.log(` ${o.status} ${o.file}`);console.log(`Untracked: ${e.status.untracked.length}`);for(const o of e.status.untracked)console.log(` ?? ${o}`);return}}function C(e){console.log(`Overall: ${e.passed?"passed":"failed"}`),d("tsc",e.tsc.passed,e.tsc.errors),d("biome",e.biome.passed,e.biome.errors)}function d(e,o,n){console.log(`${e}: ${o?"passed":`${n.length} issue(s)`}`);for(const t of n){const s=[t.line,t.column].filter(c=>c!==void 0).join(":"),r=s?`${t.file}:${s}`:t.file,i=t.code?` ${t.code}`:"";console.log(` - ${r} [${t.severity}${i}] ${t.message}`)}}function O(e){console.log(`Vitest: ${e.passed?"passed":"failed"}`),console.log(` Duration: ${e.durationMs}ms`),console.log(` Passed: ${e.summary.passed}`),console.log(` Failed: ${e.summary.failed}`),console.log(` Skipped: ${e.summary.skipped}`),e.summary.suites!==void 0&&console.log(` Suites: ${e.summary.suites}`);const o=e.summary.tests.filter(n=>n.status==="fail");if(o.length!==0){console.log("Failed tests:");for(const n of o)console.log(` - ${n.name}${n.file?` (${n.file})`:""}`),n.error&&console.log(` ${n.error}`)}}function P(e){console.log(`Branch: ${e.branch}`),console.log(`Staged: ${e.status.staged.length}`);for(const o of e.status.staged)console.log(` - ${o}`);console.log(`Modified: ${e.status.modified.length}`);for(const o of e.status.modified)console.log(` - ${o}`);console.log(`Untracked: ${e.status.untracked.length}`);for(const o of e.status.untracked)console.log(` - ${o}`);if(console.log(""),console.log("Recent commits:"),e.recentCommits.length===0)console.log(" none");else for(const o of e.recentCommits)console.log(` - ${o.hash} ${o.message}`),console.log(` ${o.author} @ ${o.date}`);e.diff&&(console.log(""),console.log("Diff stat:"),console.log(e.diff))}function N(e){if(e.length===0){console.log("No diff files found.");return}for(const o of e){const n=o.oldPath?` (from ${o.oldPath})`:"";console.log(`${o.path}${n}`),console.log(` Status: ${o.status}`),console.log(` Changes: +${o.additions} -${o.deletions}`),console.log(` Hunks: ${o.hunks.length}`);for(const t of o.hunks){const s=t.header?` ${t.header}`:"";console.log(` @@ -${t.oldStart},${t.oldLines} +${t.newStart},${t.newLines} @@${s}`)}}}function D(e){if(console.log(`Start: ${e.start}`),console.log(`Direction: ${e.direction}`),console.log(`Depth reached: ${e.depth}`),console.log(`Nodes: ${e.nodes.length}`),e.nodes.length===0){console.log("No trace nodes found.");return}for(const o of e.nodes)console.log(` - [${o.relationship}] ${o.path}:${o.line} ${o.symbol}`)}function F(e){if(console.log(`Query: ${e.query}`),console.log(`Examples: ${e.examples.length} shown (${e.totalFound} total)`),e.examples.length===0){console.log("No matching examples found.");return}for(const o of e.examples){console.log(""),console.log(`${o.path}:${o.startLine}-${o.endLine}`),console.log(` Context: ${o.context}`),console.log(` Relevance: ${(o.relevance*100).toFixed(1)}%`);for(const n of o.content.split(`
2
+ `))console.log(` ${n}`)}}function I(e){console.log(e.id),console.log(` Command: ${e.command}${e.args.length>0?` ${e.args.join(" ")}`:""}`),console.log(` PID: ${e.pid??"unknown"}`),console.log(` Status: ${e.status}`),console.log(` Started: ${e.startedAt}`),e.exitCode!==void 0&&console.log(` Exit code: ${e.exitCode}`),console.log(` Logs: ${e.logs.length}`)}function j(e){if(console.log(`Exports scanned: ${e.totalExports}`),console.log(`Potentially dead: ${e.totalDead}`),e.deadSymbols.length===0){console.log("No dead symbols found.");return}for(const o of e.deadSymbols)console.log(` - ${o.path}:${o.line} ${o.kind} ${o.name}`)}function q(e){console.log(e.path),console.log(` Language: ${e.language}`),console.log(` Lines: ${e.lines}`),console.log(` Estimated tokens: ~${e.estimatedTokens}`),console.log(""),a("Imports",e.imports),a("Exports",e.exports),a("Functions",e.functions.map(o=>`${o.name} @ line ${o.line}${o.exported?" [exported]":""}`)),a("Classes",e.classes.map(o=>`${o.name} @ line ${o.line}${o.exported?" [exported]":""}`)),a("Interfaces",e.interfaces.map(o=>`${o.name} @ line ${o.line}`)),a("Types",e.types.map(o=>`${o.name} @ line ${o.line}`))}function _(e){if(console.log(`Symbol: ${e.name}`),e.definedIn?console.log(`Defined in: ${e.definedIn.path}:${e.definedIn.line} (${e.definedIn.kind})`):console.log("Defined in: not found"),console.log(""),console.log("Imported by:"),e.importedBy.length===0)console.log(" none");else for(const o of e.importedBy)console.log(` - ${o.path}:${o.line} ${o.importStatement}`);if(console.log(""),console.log("Referenced in:"),e.referencedIn.length===0)console.log(" none");else for(const o of e.referencedIn)console.log(` - ${o.path}:${o.line} ${o.context}`)}function L(e){console.log(e.name),console.log(` Files: ${e.files.length}`),console.log(` Updated: ${e.updated}`),e.description&&console.log(` Description: ${e.description}`);for(const o of e.files)console.log(` - ${o}`)}function M(e){if(console.log(e.id),console.log(` Label: ${e.label}`),console.log(` Created: ${e.createdAt}`),e.notes&&console.log(` Notes: ${e.notes}`),e.files?.length){console.log(` Files: ${e.files.length}`);for(const o of e.files)console.log(` - ${o}`)}console.log(" Data:");for(const o of JSON.stringify(e.data,null,2).split(`
3
+ `))console.log(` ${o}`)}function a(e,o){if(console.log(`${e}:`),o.length===0){console.log(" none"),console.log("");return}for(const n of o)console.log(` - ${n}`);console.log("")}function J(e){const o=e.trim();if(!o)return"";try{return JSON.parse(o)}catch{return e}}function U(e){const o=e.trim();if(!o)return{};const n=JSON.parse(o);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Checkpoint data must be a JSON object.");return n}function h(e,o,n=60){const t=new Map;for(let s=0;s<e.length;s++){const r=e[s];t.set(r.record.id,{record:r.record,score:1/(n+s+1)})}for(let s=0;s<o.length;s++){const r=o[s],i=t.get(r.record.id);i?i.score+=1/(n+s+1):t.set(r.record.id,{record:r.record,score:1/(n+s+1)})}return[...t.values()].sort((s,r)=>r.score-s.score)}async function K(e,o){switch(e.type){case"search":{if(!o)throw new Error("search operation requires knowledge base context");const n=typeof e.args.query=="string"?e.args.query.trim():"";if(!n)throw new Error("search operation requires a query");const t=typeof e.args.limit=="number"?e.args.limit:5,s=e.args.search_mode==="semantic"||e.args.search_mode==="keyword"?e.args.search_mode:"hybrid",r=typeof e.args.content_type=="string"?e.args.content_type:void 0,i=typeof e.args.min_score=="number"?e.args.min_score:.25;if(s==="keyword")return(await o.store.ftsSearch(n,{limit:t,contentType:r,minScore:i})).slice(0,t);const c=await o.embedder.embedQuery(n);if(s==="semantic")return o.store.search(c,{limit:t,contentType:r,minScore:i});const[f,g]=await Promise.all([o.store.search(c,{limit:t*2,contentType:r,minScore:i}),o.store.ftsSearch(n,{limit:t*2,contentType:r,minScore:i}).catch(()=>[])]);return h(f,g).slice(0,t)}case"find":{if(!o)throw new Error("find operation requires knowledge base context");const n=typeof e.args.query=="string"?e.args.query:void 0,t=typeof e.args.glob=="string"?e.args.glob:void 0,s=typeof e.args.pattern=="string"?e.args.pattern:void 0,r=typeof e.args.limit=="number"?e.args.limit:10,i=typeof e.args.content_type=="string"?e.args.content_type:void 0,c=typeof e.args.cwd=="string"?e.args.cwd:void 0;if(!n&&!t&&!s)throw new Error("find operation requires query, glob, or pattern");return $(o.embedder,o.store,{query:n,glob:t,pattern:s,limit:r,contentType:i,cwd:c})}case"check":{const n=Array.isArray(e.args.files)?e.args.files.filter(i=>typeof i=="string"):void 0,t=typeof e.args.cwd=="string"?e.args.cwd:void 0,s=e.args.skip_types===!0,r=e.args.skip_lint===!0;return m({files:n,cwd:t,skipTypes:s,skipLint:r})}default:throw new Error(`Unsupported batch operation type: ${e.type}`)}}export{K as executeCliBatchOperation,R as extractBoolFlag,S as extractNumFlag,k as extractStrFlag,E as formatFocusRanges,A as parseBatchPayload,J as parseMaybeJsonString,U as parseRecordString,C as printCheckResult,d as printCheckSection,M as printCheckpoint,j as printDeadSymbolsResult,N as printDiffFiles,F as printExamplesResult,q as printFileSummary,P as printGitContext,I as printManagedProcess,T as printParsedOutput,a as printSection,_ as printSymbolInfo,O as printTestRunResult,D as printTraceResult,L as printWorkset,v as readInput,y as readStdin,h as rrf,B as splitCsv,l as validateBatchOperations};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @anvpx/kb CLI — command-line interface for the knowledge base toolkit.
2
+ * @vpxa/kb CLI — command-line interface for the knowledge base toolkit.
3
3
  *
4
4
  * Thin adapter: arg parsing + output formatting.
5
5
  * All core logic lives in @kb/core, @kb/store, @kb/embeddings, etc.
@@ -1,69 +1,3 @@
1
- import { analyzeCommands } from "./commands/analyze.js";
2
- import { contextCommands } from "./commands/context-cmds.js";
3
- import { environmentCommands } from "./commands/environment.js";
4
- import { executionCommands } from "./commands/execution.js";
5
- import { graphCommands } from "./commands/graph.js";
6
- import { knowledgeCommands } from "./commands/knowledge.js";
7
- import { searchCommands } from "./commands/search.js";
8
- import { systemCommands } from "./commands/system.js";
9
- import { workspaceCommands } from "./commands/workspace.js";
10
- import { getCtx } from "./context.js";
11
- const commands = [
12
- ...searchCommands,
13
- ...knowledgeCommands,
14
- ...analyzeCommands,
15
- ...graphCommands,
16
- ...systemCommands,
17
- ...executionCommands,
18
- ...contextCommands,
19
- ...workspaceCommands,
20
- ...environmentCommands
21
- ];
22
- commands.push({
23
- name: "help",
24
- description: "Show available commands",
25
- run: async () => {
26
- printHelp();
27
- }
28
- });
29
- async function run(argv) {
30
- const args = [...argv];
31
- const commandName = args.shift();
32
- if (!commandName || commandName === "--help" || commandName === "-h") {
33
- printHelp();
34
- return;
35
- }
36
- if (commandName === "--version" || commandName === "-v") {
37
- console.log("0.1.0");
38
- return;
39
- }
40
- const command = commands.find((candidate) => candidate.name === commandName);
41
- if (!command) {
42
- console.error(`Unknown command: ${commandName}`);
43
- printHelp();
44
- process.exit(1);
45
- }
46
- try {
47
- await command.run(args);
48
- } finally {
49
- const kbContext = getCtx();
50
- if (kbContext) await kbContext.store.close();
51
- }
52
- }
53
- function printHelp() {
54
- console.log("@anvpx/kb \u2014 Local-first AI developer toolkit\n");
55
- console.log("Usage: kb <command> [options]\n");
56
- console.log("Commands:");
57
- const maxLen = Math.max(...commands.map((command) => command.name.length));
58
- for (const command of commands) {
59
- console.log(` ${command.name.padEnd(maxLen + 2)}${command.description}`);
60
- }
61
- console.log("");
62
- console.log("Options:");
63
- console.log(" --help, -h Show this help");
64
- console.log(" --version, -v Show version");
65
- }
66
- export {
67
- run
68
- };
69
- //# sourceMappingURL=index.js.map
1
+ import{analyzeCommands as a}from"./commands/analyze.js";import{contextCommands as i}from"./commands/context-cmds.js";import{environmentCommands as c}from"./commands/environment.js";import{executionCommands as l}from"./commands/execution.js";import{graphCommands as p}from"./commands/graph.js";import{knowledgeCommands as d}from"./commands/knowledge.js";import{searchCommands as f}from"./commands/search.js";import{systemCommands as g}from"./commands/system.js";import{workspaceCommands as h}from"./commands/workspace.js";import{getCtx as C}from"./context.js";const e=[...f,...d,...a,...p,...g,...l,...i,...h,...c];e.push({name:"help",description:"Show available commands",run:async()=>{r()}});async function U(s){const o=[...s],n=o.shift();if(!n||n==="--help"||n==="-h"){r();return}if(n==="--version"||n==="-v"){console.log("0.1.0");return}const t=e.find(m=>m.name===n);t||(console.error(`Unknown command: ${n}`),r(),process.exit(1));try{await t.run(o)}finally{const m=C();m&&await m.store.close()}}function r(){console.log(`@vpxa/kb \u2014 Local-first AI developer toolkit
2
+ `),console.log(`Usage: kb <command> [options]
3
+ `),console.log("Commands:");const s=Math.max(...e.map(o=>o.name.length));for(const o of e)console.log(` ${o.name.padEnd(s+2)}${o.description}`);console.log(""),console.log("Options:"),console.log(" --help, -h Show this help"),console.log(" --version, -v Show version")}export{U as run};
@@ -1,82 +1 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { dirname, resolve } from "node:path";
3
- import { initializeTreeSitter } from "@kb/chunker";
4
- import { OnnxEmbedder } from "@kb/embeddings";
5
- import { IncrementalIndexer } from "@kb/indexer";
6
- import { createStore, SqliteGraphStore } from "@kb/store";
7
- function loadConfig() {
8
- const configPath = process.env.KB_CONFIG_PATH ?? (existsSync(resolve(process.cwd(), "kb.config.json")) ? resolve(process.cwd(), "kb.config.json") : null);
9
- if (!configPath) {
10
- console.error("No kb.config.json found in current directory.");
11
- console.error("Run `kb init` to create one, or set KB_CONFIG_PATH.");
12
- process.exit(1);
13
- }
14
- const raw = readFileSync(configPath, "utf-8");
15
- const config = JSON.parse(raw);
16
- const root = dirname(configPath);
17
- config.sources = config.sources.map((s) => ({
18
- ...s,
19
- path: resolve(root, s.path)
20
- }));
21
- config.store.path = resolve(root, config.store.path);
22
- config.curated = config.curated ?? { path: "curated" };
23
- config.curated.path = resolve(root, config.curated.path);
24
- return config;
25
- }
26
- async function initKB() {
27
- const config = loadConfig();
28
- const embedder = new OnnxEmbedder({
29
- model: config.embedding.model,
30
- dimensions: config.embedding.dimensions
31
- });
32
- await embedder.initialize();
33
- const store = await createStore({
34
- backend: config.store.backend,
35
- path: config.store.path
36
- });
37
- await store.initialize();
38
- const indexer = new IncrementalIndexer(embedder, store);
39
- const { CuratedKnowledgeManager } = await import("@kb/server/curated-manager");
40
- const curated = new CuratedKnowledgeManager(config.curated.path, store, embedder);
41
- let graphStore;
42
- try {
43
- const gs = new SqliteGraphStore({ path: config.store.path });
44
- await gs.initialize();
45
- graphStore = gs;
46
- indexer.setGraphStore(graphStore);
47
- } catch (err) {
48
- console.error(`[kb] Graph store init failed (non-fatal): ${err.message}`);
49
- graphStore = {
50
- initialize: async () => {
51
- },
52
- upsertNode: async () => {
53
- },
54
- upsertEdge: async () => {
55
- },
56
- upsertNodes: async () => {
57
- },
58
- upsertEdges: async () => {
59
- },
60
- getNode: async () => null,
61
- getNeighbors: async () => ({ nodes: [], edges: [] }),
62
- traverse: async () => ({ nodes: [], edges: [] }),
63
- findNodes: async () => [],
64
- findEdges: async () => [],
65
- deleteNode: async () => {
66
- },
67
- deleteBySourcePath: async () => 0,
68
- clear: async () => {
69
- },
70
- getStats: async () => ({ nodeCount: 0, edgeCount: 0, nodeTypes: {}, edgeTypes: {} }),
71
- close: async () => {
72
- }
73
- };
74
- }
75
- await initializeTreeSitter().catch(() => {
76
- });
77
- return { config, embedder, store, graphStore, indexer, curated };
78
- }
79
- export {
80
- initKB
81
- };
82
- //# sourceMappingURL=kb-init.js.map
1
+ import{existsSync as d,readFileSync as g}from"node:fs";import{dirname as p,resolve as o}from"node:path";import{initializeTreeSitter as m}from"../../chunker/dist/index.js";import{OnnxEmbedder as l}from"../../embeddings/dist/index.js";import{IncrementalIndexer as u}from"../../indexer/dist/index.js";import{createStore as f,SqliteGraphStore as h}from"../../store/dist/index.js";function y(){const t=process.env.KB_CONFIG_PATH??(d(o(process.cwd(),"kb.config.json"))?o(process.cwd(),"kb.config.json"):null);t||(console.error("No kb.config.json found in current directory."),console.error("Run `kb init` to create one, or set KB_CONFIG_PATH."),process.exit(1));const r=g(t,"utf-8"),e=JSON.parse(r),n=p(t);return e.sources=e.sources.map(s=>({...s,path:o(n,s.path)})),e.store.path=o(n,e.store.path),e.curated=e.curated??{path:"curated"},e.curated.path=o(n,e.curated.path),e}async function x(){const t=y(),r=new l({model:t.embedding.model,dimensions:t.embedding.dimensions});await r.initialize();const e=await f({backend:t.store.backend,path:t.store.path});await e.initialize();const n=new u(r,e),{CuratedKnowledgeManager:s}=await import("../../server/dist/curated-manager.js"),c=new s(t.curated.path,e,r);let i;try{const a=new h({path:t.store.path});await a.initialize(),i=a,n.setGraphStore(i)}catch(a){console.error(`[kb] Graph store init failed (non-fatal): ${a.message}`),i={initialize:async()=>{},upsertNode:async()=>{},upsertEdge:async()=>{},upsertNodes:async()=>{},upsertEdges:async()=>{},getNode:async()=>null,getNeighbors:async()=>({nodes:[],edges:[]}),traverse:async()=>({nodes:[],edges:[]}),findNodes:async()=>[],findEdges:async()=>[],deleteNode:async()=>{},deleteBySourcePath:async()=>0,clear:async()=>{},getStats:async()=>({nodeCount:0,edgeCount:0,nodeTypes:{},edgeTypes:{}}),close:async()=>{}}}return await m().catch(()=>{}),{config:t,embedder:r,store:e,graphStore:i,indexer:n,curated:c}}export{x as initKB};
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.js.map