@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,42 +1,6 @@
1
- import { z } from "zod";
2
- function registerUpdateTool(server, curated) {
3
- server.registerTool(
4
- "update",
5
- {
6
- description: "Update an existing curated knowledge entry. Increments version and records the reason in the changelog.",
7
- inputSchema: {
8
- path: z.string().describe('Relative path within curated/ (e.g., "decisions/use-lancedb.md")'),
9
- content: z.string().min(10).describe("New markdown content to replace existing content"),
10
- reason: z.string().min(3).describe("Why this update is being made (recorded in changelog)")
11
- }
12
- },
13
- async ({ path, content, reason }) => {
14
- try {
15
- const result = await curated.update(path, content, reason);
16
- return {
17
- content: [
18
- {
19
- type: "text",
20
- text: `Updated: \`curated/${result.path}\` \u2192 version ${result.version}
1
+ import{z as t}from"zod";function d(n,o){n.registerTool("update",{description:"Update an existing curated knowledge entry. Increments version and records the reason in the changelog.",inputSchema:{path:t.string().describe('Relative path within curated/ (e.g., "decisions/use-lancedb.md")'),content:t.string().min(10).describe("New markdown content to replace existing content"),reason:t.string().min(3).describe("Why this update is being made (recorded in changelog)")}},async({path:a,content:s,reason:r})=>{try{const e=await o.update(a,s,r);return{content:[{type:"text",text:`Updated: \`curated/${e.path}\` \u2192 version ${e.version}
21
2
 
22
- Reason: ${reason}
3
+ Reason: ${r}
23
4
 
24
5
  ---
25
- _Next: Use \`read\` to verify the updated content, or \`search\` to test searchability._`
26
- }
27
- ]
28
- };
29
- } catch (err) {
30
- console.error("[KB] Update failed:", err);
31
- return {
32
- content: [{ type: "text", text: `Update failed: ${err.message}` }],
33
- isError: true
34
- };
35
- }
36
- }
37
- );
38
- }
39
- export {
40
- registerUpdateTool
41
- };
42
- //# sourceMappingURL=update.tool.js.map
6
+ _Next: Use \`read\` to verify the updated content, or \`search\` to test searchability._`}]}}catch(e){return console.error("[KB] Update failed:",e),{content:[{type:"text",text:`Update failed: ${e.message}`}],isError:!0}}})}export{d as registerUpdateTool};
@@ -1,461 +1,24 @@
1
- import {
2
- changelog,
3
- encode,
4
- envInfo,
5
- httpRequest,
6
- measure,
7
- regexTest,
8
- schemaValidate,
9
- snippet,
10
- timeUtils,
11
- webSearch
12
- } from "@kb/tools";
13
- import { z } from "zod";
14
- function registerWebSearchTool(server) {
15
- server.registerTool(
16
- "web_search",
17
- {
18
- description: "PREFERRED web search \u2014 search the web via DuckDuckGo (no API key). Returns structured results with title, URL, and snippet.",
19
- inputSchema: {
20
- query: z.string().describe("Search query"),
21
- limit: z.number().min(1).max(20).default(5).describe("Max results to return"),
22
- site: z.string().optional().describe('Restrict to domain (e.g., "docs.aws.amazon.com")')
23
- }
24
- },
25
- async ({ query, limit, site }) => {
26
- try {
27
- const result = await webSearch({ query, limit, site });
28
- const lines = [`## Search: ${result.query}`, ""];
29
- if (result.results.length === 0) {
30
- lines.push("No results found.");
31
- } else {
32
- for (const r of result.results) {
33
- lines.push(`### [${r.title}](${r.url})`, r.snippet, "");
34
- }
35
- }
36
- lines.push("---", "_Next: Use `web_fetch` to read any of these pages in full._");
37
- return { content: [{ type: "text", text: lines.join("\n") }] };
38
- } catch (err) {
39
- return {
40
- content: [
41
- { type: "text", text: `Web search failed: ${err.message}` }
42
- ],
43
- isError: true
44
- };
45
- }
46
- }
47
- );
48
- }
49
- function registerHttpTool(server) {
50
- server.registerTool(
51
- "http",
52
- {
53
- description: "Make HTTP requests (GET/POST/PUT/PATCH/DELETE/HEAD) for API testing. Returns status, headers, and formatted body with timing info.",
54
- inputSchema: {
55
- url: z.string().url().describe("Request URL (http/https only)"),
56
- method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]).default("GET").describe("HTTP method"),
57
- headers: z.record(z.string(), z.string()).optional().describe("Request headers as key-value pairs"),
58
- body: z.string().optional().describe("Request body (for POST/PUT/PATCH)"),
59
- timeout: z.number().min(1e3).max(6e4).default(15e3).describe("Timeout in milliseconds")
60
- }
61
- },
62
- async ({ url, method, headers, body, timeout }) => {
63
- try {
64
- const result = await httpRequest({
65
- url,
66
- method,
67
- headers,
68
- body,
69
- timeout
70
- });
71
- const lines = [
72
- `## ${method} ${url}`,
73
- "",
74
- `**Status:** ${result.status} ${result.statusText}`,
75
- `**Time:** ${result.durationMs}ms`,
76
- `**Size:** ${result.sizeBytes} bytes`,
77
- `**Content-Type:** ${result.contentType}`,
78
- "",
79
- "### Headers",
80
- "```json",
81
- JSON.stringify(result.headers, null, 2),
82
- "```",
83
- "",
84
- "### Body",
85
- result.contentType.includes("json") ? "```json" : "```",
86
- result.body,
87
- "```"
88
- ];
89
- if (result.truncated) {
90
- lines.push("", `_Response truncated \u2014 total size: ${result.sizeBytes} bytes_`);
91
- }
92
- return { content: [{ type: "text", text: lines.join("\n") }] };
93
- } catch (err) {
94
- return {
95
- content: [
96
- { type: "text", text: `HTTP request failed: ${err.message}` }
97
- ],
98
- isError: true
99
- };
100
- }
101
- }
102
- );
103
- }
104
- function registerRegexTestTool(server) {
105
- server.registerTool(
106
- "regex_test",
107
- {
108
- description: "Test a regex pattern against sample strings. Supports match, replace, and split modes.",
109
- inputSchema: {
110
- pattern: z.string().describe("Regex pattern (without delimiters)"),
111
- flags: z.string().default("").describe("Regex flags (g, i, m, s, etc.)"),
112
- test_strings: z.array(z.string()).describe("Strings to test the pattern against"),
113
- mode: z.enum(["match", "replace", "split"]).default("match").describe("Test mode"),
114
- replacement: z.string().optional().describe("Replacement string (for replace mode)")
115
- }
116
- },
117
- async ({ pattern, flags, test_strings, mode, replacement }) => {
118
- const result = regexTest({
119
- pattern,
120
- flags,
121
- testStrings: test_strings,
122
- mode,
123
- replacement
124
- });
125
- if (!result.valid) {
126
- return {
127
- content: [{ type: "text", text: `Invalid regex: ${result.error}` }],
128
- isError: true
129
- };
130
- }
131
- const lines = [`## Regex: \`/${result.pattern}/${result.flags}\``, "", `Mode: ${mode}`, ""];
132
- for (const r of result.results) {
133
- lines.push(`**Input:** \`${r.input}\``);
134
- lines.push(`**Matched:** ${r.matched}`);
135
- if (r.matches) {
136
- for (const m of r.matches) {
137
- const groups = m.groups.length > 0 ? ` groups: [${m.groups.join(", ")}]` : "";
138
- lines.push(` - "${m.full}" at index ${m.index}${groups}`);
139
- }
140
- }
141
- if (r.replaced !== void 0) lines.push(`**Result:** \`${r.replaced}\``);
142
- if (r.split) lines.push(`**Split:** ${JSON.stringify(r.split)}`);
143
- lines.push("");
144
- }
145
- return { content: [{ type: "text", text: lines.join("\n") }] };
146
- }
147
- );
148
- }
149
- function registerEncodeTool(server) {
150
- server.registerTool(
151
- "encode",
152
- {
153
- description: "Encode, decode, or hash text. Supports base64, URL encoding, SHA-256, MD5, JWT decode, hex.",
154
- inputSchema: {
155
- operation: z.enum([
156
- "base64_encode",
157
- "base64_decode",
158
- "url_encode",
159
- "url_decode",
160
- "sha256",
161
- "md5",
162
- "jwt_decode",
163
- "hex_encode",
164
- "hex_decode"
165
- ]).describe("Operation to perform"),
166
- input: z.string().describe("Input text")
167
- }
168
- },
169
- async ({ operation, input }) => {
170
- try {
171
- const result = encode({ operation, input });
172
- return {
173
- content: [
174
- {
175
- type: "text",
176
- text: `## ${operation}
1
+ import{changelog as g,encode as f,envInfo as h,httpRequest as y,measure as x,regexTest as $,schemaValidate as b,snippet as S,timeUtils as v,webSearch as T}from"../../../tools/dist/index.js";import{z as e}from"zod";function _(c){c.registerTool("web_search",{description:"PREFERRED web search \u2014 search the web via DuckDuckGo (no API key). Returns structured results with title, URL, and snippet.",inputSchema:{query:e.string().describe("Search query"),limit:e.number().min(1).max(20).default(5).describe("Max results to return"),site:e.string().optional().describe('Restrict to domain (e.g., "docs.aws.amazon.com")')}},async({query:a,limit:i,site:r})=>{try{const s=await T({query:a,limit:i,site:r}),t=[`## Search: ${s.query}`,""];if(s.results.length===0)t.push("No results found.");else for(const n of s.results)t.push(`### [${n.title}](${n.url})`,n.snippet,"");return t.push("---","_Next: Use `web_fetch` to read any of these pages in full._"),{content:[{type:"text",text:t.join(`
2
+ `)}]}}catch(s){return{content:[{type:"text",text:`Web search failed: ${s.message}`}],isError:!0}}})}function M(c){c.registerTool("http",{description:"Make HTTP requests (GET/POST/PUT/PATCH/DELETE/HEAD) for API testing. Returns status, headers, and formatted body with timing info.",inputSchema:{url:e.string().url().describe("Request URL (http/https only)"),method:e.enum(["GET","POST","PUT","PATCH","DELETE","HEAD"]).default("GET").describe("HTTP method"),headers:e.record(e.string(),e.string()).optional().describe("Request headers as key-value pairs"),body:e.string().optional().describe("Request body (for POST/PUT/PATCH)"),timeout:e.number().min(1e3).max(6e4).default(15e3).describe("Timeout in milliseconds")}},async({url:a,method:i,headers:r,body:s,timeout:t})=>{try{const n=await y({url:a,method:i,headers:r,body:s,timeout:t}),o=[`## ${i} ${a}`,"",`**Status:** ${n.status} ${n.statusText}`,`**Time:** ${n.durationMs}ms`,`**Size:** ${n.sizeBytes} bytes`,`**Content-Type:** ${n.contentType}`,"","### Headers","```json",JSON.stringify(n.headers,null,2),"```","","### Body",n.contentType.includes("json")?"```json":"```",n.body,"```"];return n.truncated&&o.push("",`_Response truncated \u2014 total size: ${n.sizeBytes} bytes_`),{content:[{type:"text",text:o.join(`
3
+ `)}]}}catch(n){return{content:[{type:"text",text:`HTTP request failed: ${n.message}`}],isError:!0}}})}function R(c){c.registerTool("regex_test",{description:"Test a regex pattern against sample strings. Supports match, replace, and split modes.",inputSchema:{pattern:e.string().describe("Regex pattern (without delimiters)"),flags:e.string().default("").describe("Regex flags (g, i, m, s, etc.)"),test_strings:e.array(e.string()).describe("Strings to test the pattern against"),mode:e.enum(["match","replace","split"]).default("match").describe("Test mode"),replacement:e.string().optional().describe("Replacement string (for replace mode)")}},async({pattern:a,flags:i,test_strings:r,mode:s,replacement:t})=>{const n=$({pattern:a,flags:i,testStrings:r,mode:s,replacement:t});if(!n.valid)return{content:[{type:"text",text:`Invalid regex: ${n.error}`}],isError:!0};const o=[`## Regex: \`/${n.pattern}/${n.flags}\``,"",`Mode: ${s}`,""];for(const d of n.results){if(o.push(`**Input:** \`${d.input}\``),o.push(`**Matched:** ${d.matched}`),d.matches)for(const p of d.matches){const l=p.groups.length>0?` groups: [${p.groups.join(", ")}]`:"";o.push(` - "${p.full}" at index ${p.index}${l}`)}d.replaced!==void 0&&o.push(`**Result:** \`${d.replaced}\``),d.split&&o.push(`**Split:** ${JSON.stringify(d.split)}`),o.push("")}return{content:[{type:"text",text:o.join(`
4
+ `)}]}})}function j(c){c.registerTool("encode",{description:"Encode, decode, or hash text. Supports base64, URL encoding, SHA-256, MD5, JWT decode, hex.",inputSchema:{operation:e.enum(["base64_encode","base64_decode","url_encode","url_decode","sha256","md5","jwt_decode","hex_encode","hex_decode"]).describe("Operation to perform"),input:e.string().describe("Input text")}},async({operation:a,input:i})=>{try{const r=f({operation:a,input:i});return{content:[{type:"text",text:`## ${a}
177
5
 
178
- **Input:** \`${input.length > 100 ? `${input.slice(0, 100)}...` : input}\`
6
+ **Input:** \`${i.length>100?`${i.slice(0,100)}...`:i}\`
179
7
  **Output:**
180
8
  \`\`\`
181
- ${result.output}
182
- \`\`\``
183
- }
184
- ]
185
- };
186
- } catch (err) {
187
- return {
188
- content: [{ type: "text", text: `Encode failed: ${err.message}` }],
189
- isError: true
190
- };
191
- }
192
- }
193
- );
194
- }
195
- function registerMeasureTool(server) {
196
- server.registerTool(
197
- "measure",
198
- {
199
- description: "Measure code complexity, line counts, and function counts for a file or directory. Returns per-file metrics sorted by complexity.",
200
- inputSchema: {
201
- path: z.string().describe("File or directory path to measure"),
202
- extensions: z.array(z.string()).optional().describe("File extensions to include (default: .ts,.tsx,.js,.jsx)")
203
- }
204
- },
205
- async ({ path, extensions }) => {
206
- try {
207
- const result = measure({ path, extensions });
208
- const lines = [
209
- "## Code Metrics",
210
- "",
211
- `**Files:** ${result.summary.totalFiles}`,
212
- `**Total lines:** ${result.summary.totalLines} (${result.summary.totalCodeLines} code)`,
213
- `**Functions:** ${result.summary.totalFunctions}`,
214
- `**Avg complexity:** ${result.summary.avgComplexity}`,
215
- `**Max complexity:** ${result.summary.maxComplexity.value} (${result.summary.maxComplexity.file})`,
216
- "",
217
- "### Top files by complexity",
218
- "",
219
- "| File | Lines | Code | Complexity | Functions | Imports |",
220
- "|------|-------|------|------------|-----------|---------|"
221
- ];
222
- for (const f of result.files.slice(0, 20)) {
223
- lines.push(
224
- `| ${f.path} | ${f.lines.total} | ${f.lines.code} | ${f.complexity} | ${f.functions} | ${f.imports} |`
225
- );
226
- }
227
- if (result.files.length > 20) {
228
- lines.push(``, `_...and ${result.files.length - 20} more files_`);
229
- }
230
- return { content: [{ type: "text", text: lines.join("\n") }] };
231
- } catch (err) {
232
- return {
233
- content: [{ type: "text", text: `Measure failed: ${err.message}` }],
234
- isError: true
235
- };
236
- }
237
- }
238
- );
239
- }
240
- function registerChangelogTool(server) {
241
- server.registerTool(
242
- "changelog",
243
- {
244
- description: "Generate a changelog from git history between two refs. Groups by conventional commit type.",
245
- inputSchema: {
246
- from: z.string().describe("Start ref (tag, SHA, HEAD~N)"),
247
- to: z.string().default("HEAD").describe("End ref (default: HEAD)"),
248
- format: z.enum(["grouped", "chronological", "per-scope"]).default("grouped").describe("Output format"),
249
- include_breaking: z.boolean().default(true).describe("Highlight breaking changes")
250
- }
251
- },
252
- async ({ from, to, format, include_breaking }) => {
253
- try {
254
- const result = changelog({ from, to, format, includeBreaking: include_breaking });
255
- const stats = `${result.stats.total} commits (${Object.entries(result.stats.types).map(([k, v]) => `${v} ${k}`).join(", ")})`;
256
- return {
257
- content: [
258
- {
259
- type: "text",
260
- text: `${result.markdown}
9
+ ${r.output}
10
+ \`\`\``}]}}catch(r){return{content:[{type:"text",text:`Encode failed: ${r.message}`}],isError:!0}}})}function O(c){c.registerTool("measure",{description:"Measure code complexity, line counts, and function counts for a file or directory. Returns per-file metrics sorted by complexity.",inputSchema:{path:e.string().describe("File or directory path to measure"),extensions:e.array(e.string()).optional().describe("File extensions to include (default: .ts,.tsx,.js,.jsx)")}},async({path:a,extensions:i})=>{try{const r=x({path:a,extensions:i}),s=["## Code Metrics","",`**Files:** ${r.summary.totalFiles}`,`**Total lines:** ${r.summary.totalLines} (${r.summary.totalCodeLines} code)`,`**Functions:** ${r.summary.totalFunctions}`,`**Avg complexity:** ${r.summary.avgComplexity}`,`**Max complexity:** ${r.summary.maxComplexity.value} (${r.summary.maxComplexity.file})`,"","### Top files by complexity","","| File | Lines | Code | Complexity | Functions | Imports |","|------|-------|------|------------|-----------|---------|"];for(const t of r.files.slice(0,20))s.push(`| ${t.path} | ${t.lines.total} | ${t.lines.code} | ${t.complexity} | ${t.functions} | ${t.imports} |`);return r.files.length>20&&s.push("",`_...and ${r.files.length-20} more files_`),{content:[{type:"text",text:s.join(`
11
+ `)}]}}catch(r){return{content:[{type:"text",text:`Measure failed: ${r.message}`}],isError:!0}}})}function P(c){c.registerTool("changelog",{description:"Generate a changelog from git history between two refs. Groups by conventional commit type.",inputSchema:{from:e.string().describe("Start ref (tag, SHA, HEAD~N)"),to:e.string().default("HEAD").describe("End ref (default: HEAD)"),format:e.enum(["grouped","chronological","per-scope"]).default("grouped").describe("Output format"),include_breaking:e.boolean().default(!0).describe("Highlight breaking changes")}},async({from:a,to:i,format:r,include_breaking:s})=>{try{const t=g({from:a,to:i,format:r,includeBreaking:s}),n=`${t.stats.total} commits (${Object.entries(t.stats.types).map(([o,d])=>`${d} ${o}`).join(", ")})`;return{content:[{type:"text",text:`${t.markdown}
261
12
  ---
262
- _${stats}_`
263
- }
264
- ]
265
- };
266
- } catch (err) {
267
- return {
268
- content: [{ type: "text", text: `Changelog failed: ${err.message}` }],
269
- isError: true
270
- };
271
- }
272
- }
273
- );
274
- }
275
- function registerSchemaValidateTool(server) {
276
- server.registerTool(
277
- "schema_validate",
278
- {
279
- description: "Validate JSON data against a JSON Schema. Supports type, required, properties, items, enum, pattern, min/max.",
280
- inputSchema: {
281
- data: z.string().describe("JSON data to validate (as string)"),
282
- schema: z.string().describe("JSON Schema to validate against (as string)")
283
- }
284
- },
285
- async ({ data, schema }) => {
286
- try {
287
- const parsedData = JSON.parse(data);
288
- const parsedSchema = JSON.parse(schema);
289
- const result = schemaValidate({ data: parsedData, schema: parsedSchema });
290
- if (result.valid) {
291
- return {
292
- content: [
293
- { type: "text", text: "## Validation: PASSED\n\nData matches the schema." }
294
- ]
295
- };
296
- }
297
- const lines = ["## Validation: FAILED", "", `**${result.errors.length} error(s):**`, ""];
298
- for (const e of result.errors) {
299
- const detail = e.expected ? ` (expected: ${e.expected}, got: ${e.received})` : "";
300
- lines.push(`- \`${e.path}\`: ${e.message}${detail}`);
301
- }
302
- return { content: [{ type: "text", text: lines.join("\n") }] };
303
- } catch (err) {
304
- return {
305
- content: [
306
- { type: "text", text: `Schema validation failed: ${err.message}` }
307
- ],
308
- isError: true
309
- };
310
- }
311
- }
312
- );
313
- }
314
- function registerSnippetTool(server) {
315
- server.registerTool(
316
- "snippet",
317
- {
318
- description: "Save, retrieve, search, and manage persistent code snippets/templates.",
319
- inputSchema: {
320
- action: z.enum(["save", "get", "list", "search", "delete"]).describe("Operation to perform"),
321
- name: z.string().optional().describe("Snippet name (required for save/get/delete)"),
322
- language: z.string().optional().describe("Language tag (for save)"),
323
- code: z.string().optional().describe("Code content (for save)"),
324
- tags: z.array(z.string()).optional().describe("Tags for categorization (for save)"),
325
- query: z.string().optional().describe("Search query (for search)")
326
- }
327
- },
328
- async ({ action, name, language, code, tags, query }) => {
329
- try {
330
- const result = snippet({ action, name, language, code, tags, query });
331
- if ("deleted" in result) {
332
- return {
333
- content: [
334
- {
335
- type: "text",
336
- text: result.deleted ? `Snippet "${name}" deleted.` : `Snippet "${name}" not found.`
337
- }
338
- ]
339
- };
340
- }
341
- if ("snippets" in result) {
342
- if (result.snippets.length === 0) {
343
- return { content: [{ type: "text", text: "No snippets found." }] };
344
- }
345
- const lines = ["## Snippets", ""];
346
- for (const s2 of result.snippets) {
347
- const tagStr2 = s2.tags.length > 0 ? ` [${s2.tags.join(", ")}]` : "";
348
- lines.push(`- **${s2.name}** (${s2.language})${tagStr2}`);
349
- }
350
- return { content: [{ type: "text", text: lines.join("\n") }] };
351
- }
352
- const s = result;
353
- const tagStr = s.tags.length > 0 ? `
354
- Tags: ${s.tags.join(", ")}` : "";
355
- return {
356
- content: [
357
- {
358
- type: "text",
359
- text: `## ${s.name} (${s.language})${tagStr}
13
+ _${n}_`}]}}catch(t){return{content:[{type:"text",text:`Changelog failed: ${t.message}`}],isError:!0}}})}function D(c){c.registerTool("schema_validate",{description:"Validate JSON data against a JSON Schema. Supports type, required, properties, items, enum, pattern, min/max.",inputSchema:{data:e.string().describe("JSON data to validate (as string)"),schema:e.string().describe("JSON Schema to validate against (as string)")}},async({data:a,schema:i})=>{try{const r=JSON.parse(a),s=JSON.parse(i),t=b({data:r,schema:s});if(t.valid)return{content:[{type:"text",text:`## Validation: PASSED
360
14
 
361
- \`\`\`${s.language}
362
- ${s.code}
363
- \`\`\``
364
- }
365
- ]
366
- };
367
- } catch (err) {
368
- return {
369
- content: [{ type: "text", text: `Snippet failed: ${err.message}` }],
370
- isError: true
371
- };
372
- }
373
- }
374
- );
375
- }
376
- function registerEnvTool(server) {
377
- server.registerTool(
378
- "env",
379
- {
380
- description: "Get system and runtime environment info. Sensitive env vars are redacted by default.",
381
- inputSchema: {
382
- include_env: z.boolean().default(false).describe("Include environment variables"),
383
- filter_env: z.string().optional().describe("Filter env vars by name substring"),
384
- show_sensitive: z.boolean().default(false).describe("Show sensitive values (keys, tokens, etc.) \u2014 redacted by default")
385
- }
386
- },
387
- async ({ include_env, filter_env, show_sensitive }) => {
388
- const result = envInfo({
389
- includeEnv: include_env,
390
- filterEnv: filter_env,
391
- showSensitive: show_sensitive
392
- });
393
- const lines = [
394
- "## Environment",
395
- "",
396
- `**Platform:** ${result.system.platform} ${result.system.arch}`,
397
- `**OS:** ${result.system.type} ${result.system.release}`,
398
- `**Host:** ${result.system.hostname}`,
399
- `**CPUs:** ${result.system.cpus}`,
400
- `**Memory:** ${result.system.memoryFreeGb}GB free / ${result.system.memoryTotalGb}GB total`,
401
- "",
402
- `**Node:** ${result.runtime.node}`,
403
- `**V8:** ${result.runtime.v8}`,
404
- `**CWD:** ${result.cwd}`
405
- ];
406
- if (result.env) {
407
- lines.push("", "### Environment Variables", "");
408
- for (const [key, value] of Object.entries(result.env)) {
409
- lines.push(`- \`${key}\`: ${value}`);
410
- }
411
- }
412
- return { content: [{ type: "text", text: lines.join("\n") }] };
413
- }
414
- );
415
- }
416
- function registerTimeTool(server) {
417
- server.registerTool(
418
- "time",
419
- {
420
- description: "Parse dates, convert timezones, calculate durations, add time. Supports ISO 8601, unix timestamps, and human-readable formats.",
421
- inputSchema: {
422
- operation: z.enum(["now", "parse", "convert", "diff", "add"]).describe(
423
- "now: current time | parse: parse a date string | convert: timezone conversion | diff: duration between two dates | add: add duration to date"
424
- ),
425
- input: z.string().optional().describe(
426
- "Date input (ISO, unix timestamp, or parseable string). For diff: two comma-separated dates"
427
- ),
428
- timezone: z.string().optional().describe('Target timezone (e.g., "America/New_York", "Asia/Tokyo")'),
429
- duration: z.string().optional().describe('Duration to add (e.g., "2h30m", "1d", "30s") \u2014 for add operation')
430
- }
431
- },
432
- async ({ operation, input, timezone, duration }) => {
433
- try {
434
- const result = timeUtils({ operation, input, timezone, duration });
435
- const lines = [`**${result.output}**`, "", `ISO: ${result.iso}`, `Unix: ${result.unix}`];
436
- if (result.details) {
437
- lines.push("", "```json", JSON.stringify(result.details, null, 2), "```");
438
- }
439
- return { content: [{ type: "text", text: lines.join("\n") }] };
440
- } catch (err) {
441
- return {
442
- content: [{ type: "text", text: `Time failed: ${err.message}` }],
443
- isError: true
444
- };
445
- }
446
- }
447
- );
448
- }
449
- export {
450
- registerChangelogTool,
451
- registerEncodeTool,
452
- registerEnvTool,
453
- registerHttpTool,
454
- registerMeasureTool,
455
- registerRegexTestTool,
456
- registerSchemaValidateTool,
457
- registerSnippetTool,
458
- registerTimeTool,
459
- registerWebSearchTool
460
- };
461
- //# sourceMappingURL=utility.tools.js.map
15
+ Data matches the schema.`}]};const n=["## Validation: FAILED","",`**${t.errors.length} error(s):**`,""];for(const o of t.errors){const d=o.expected?` (expected: ${o.expected}, got: ${o.received})`:"";n.push(`- \`${o.path}\`: ${o.message}${d}`)}return{content:[{type:"text",text:n.join(`
16
+ `)}]}}catch(r){return{content:[{type:"text",text:`Schema validation failed: ${r.message}`}],isError:!0}}})}function k(c){c.registerTool("snippet",{description:"Save, retrieve, search, and manage persistent code snippets/templates.",inputSchema:{action:e.enum(["save","get","list","search","delete"]).describe("Operation to perform"),name:e.string().optional().describe("Snippet name (required for save/get/delete)"),language:e.string().optional().describe("Language tag (for save)"),code:e.string().optional().describe("Code content (for save)"),tags:e.array(e.string()).optional().describe("Tags for categorization (for save)"),query:e.string().optional().describe("Search query (for search)")}},async({action:a,name:i,language:r,code:s,tags:t,query:n})=>{try{const o=S({action:a,name:i,language:r,code:s,tags:t,query:n});if("deleted"in o)return{content:[{type:"text",text:o.deleted?`Snippet "${i}" deleted.`:`Snippet "${i}" not found.`}]};if("snippets"in o){if(o.snippets.length===0)return{content:[{type:"text",text:"No snippets found."}]};const l=["## Snippets",""];for(const u of o.snippets){const m=u.tags.length>0?` [${u.tags.join(", ")}]`:"";l.push(`- **${u.name}** (${u.language})${m}`)}return{content:[{type:"text",text:l.join(`
17
+ `)}]}}const d=o,p=d.tags.length>0?`
18
+ Tags: ${d.tags.join(", ")}`:"";return{content:[{type:"text",text:`## ${d.name} (${d.language})${p}
19
+
20
+ \`\`\`${d.language}
21
+ ${d.code}
22
+ \`\`\``}]}}catch(o){return{content:[{type:"text",text:`Snippet failed: ${o.message}`}],isError:!0}}})}function A(c){c.registerTool("env",{description:"Get system and runtime environment info. Sensitive env vars are redacted by default.",inputSchema:{include_env:e.boolean().default(!1).describe("Include environment variables"),filter_env:e.string().optional().describe("Filter env vars by name substring"),show_sensitive:e.boolean().default(!1).describe("Show sensitive values (keys, tokens, etc.) \u2014 redacted by default")}},async({include_env:a,filter_env:i,show_sensitive:r})=>{const s=h({includeEnv:a,filterEnv:i,showSensitive:r}),t=["## Environment","",`**Platform:** ${s.system.platform} ${s.system.arch}`,`**OS:** ${s.system.type} ${s.system.release}`,`**Host:** ${s.system.hostname}`,`**CPUs:** ${s.system.cpus}`,`**Memory:** ${s.system.memoryFreeGb}GB free / ${s.system.memoryTotalGb}GB total`,"",`**Node:** ${s.runtime.node}`,`**V8:** ${s.runtime.v8}`,`**CWD:** ${s.cwd}`];if(s.env){t.push("","### Environment Variables","");for(const[n,o]of Object.entries(s.env))t.push(`- \`${n}\`: ${o}`)}return{content:[{type:"text",text:t.join(`
23
+ `)}]}})}function H(c){c.registerTool("time",{description:"Parse dates, convert timezones, calculate durations, add time. Supports ISO 8601, unix timestamps, and human-readable formats.",inputSchema:{operation:e.enum(["now","parse","convert","diff","add"]).describe("now: current time | parse: parse a date string | convert: timezone conversion | diff: duration between two dates | add: add duration to date"),input:e.string().optional().describe("Date input (ISO, unix timestamp, or parseable string). For diff: two comma-separated dates"),timezone:e.string().optional().describe('Target timezone (e.g., "America/New_York", "Asia/Tokyo")'),duration:e.string().optional().describe('Duration to add (e.g., "2h30m", "1d", "30s") \u2014 for add operation')}},async({operation:a,input:i,timezone:r,duration:s})=>{try{const t=v({operation:a,input:i,timezone:r,duration:s}),n=[`**${t.output}**`,"",`ISO: ${t.iso}`,`Unix: ${t.unix}`];return t.details&&n.push("","```json",JSON.stringify(t.details,null,2),"```"),{content:[{type:"text",text:n.join(`
24
+ `)}]}}catch(t){return{content:[{type:"text",text:`Time failed: ${t.message}`}],isError:!0}}})}export{P as registerChangelogTool,j as registerEncodeTool,A as registerEnvTool,M as registerHttpTool,O as registerMeasureTool,R as registerRegexTestTool,D as registerSchemaValidateTool,k as registerSnippetTool,H as registerTimeTool,_ as registerWebSearchTool};
@@ -1 +0,0 @@
1
- //# sourceMappingURL=graph-store.interface.js.map
@@ -1,9 +1 @@
1
- import { LanceStore } from "./lance-store.js";
2
- import { SqliteGraphStore } from "./sqlite-graph-store.js";
3
- import { createStore } from "./store-factory.js";
4
- export {
5
- LanceStore,
6
- SqliteGraphStore,
7
- createStore
8
- };
9
- //# sourceMappingURL=index.js.map
1
+ import{LanceStore as t}from"./lance-store.js";import{SqliteGraphStore as a}from"./sqlite-graph-store.js";import{createStore as s}from"./store-factory.js";export{t as LanceStore,a as SqliteGraphStore,s as createStore};