@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,194 +1 @@
1
- import { createHash } from "node:crypto";
2
- function generateId(prefix, ...parts) {
3
- return `${prefix}_${createHash("sha256").update(parts.join("|")).digest("hex").slice(0, 12)}`;
4
- }
5
- async function graphQuery(graphStore, options) {
6
- const { action } = options;
7
- switch (action) {
8
- case "find_nodes": {
9
- const nodes = await graphStore.findNodes({
10
- type: options.nodeType,
11
- namePattern: options.namePattern,
12
- sourcePath: options.sourcePath,
13
- limit: options.limit
14
- });
15
- return {
16
- action,
17
- nodes,
18
- summary: `Found ${nodes.length} node(s)${options.nodeType ? ` of type "${options.nodeType}"` : ""}${options.namePattern ? ` matching "${options.namePattern}"` : ""}`
19
- };
20
- }
21
- case "find_edges": {
22
- const edges = await graphStore.findEdges({
23
- type: options.edgeType,
24
- fromId: options.fromId,
25
- toId: options.toId,
26
- limit: options.limit
27
- });
28
- return {
29
- action,
30
- edges,
31
- summary: `Found ${edges.length} edge(s)${options.edgeType ? ` of type "${options.edgeType}"` : ""}`
32
- };
33
- }
34
- case "neighbors": {
35
- if (!options.nodeId) {
36
- return { action, summary: "Error: nodeId is required for neighbors action" };
37
- }
38
- const result = await graphStore.getNeighbors(options.nodeId, {
39
- edgeType: options.edgeType,
40
- direction: options.direction,
41
- limit: options.limit
42
- });
43
- return {
44
- action,
45
- nodes: result.nodes,
46
- edges: result.edges,
47
- summary: `Found ${result.nodes.length} neighbor(s) and ${result.edges.length} edge(s) for node "${options.nodeId}"`
48
- };
49
- }
50
- case "traverse": {
51
- if (!options.nodeId) {
52
- return { action, summary: "Error: nodeId is required for traverse action" };
53
- }
54
- const result = await graphStore.traverse(options.nodeId, {
55
- edgeType: options.edgeType,
56
- maxDepth: options.maxDepth,
57
- direction: options.direction,
58
- limit: options.limit
59
- });
60
- return {
61
- action,
62
- nodes: result.nodes,
63
- edges: result.edges,
64
- summary: `Traversed ${result.nodes.length} node(s) and ${result.edges.length} edge(s) from "${options.nodeId}" (depth=${options.maxDepth ?? 2})`
65
- };
66
- }
67
- case "stats": {
68
- const stats = await graphStore.getStats();
69
- return {
70
- action,
71
- stats,
72
- summary: `Graph: ${stats.nodeCount} nodes, ${stats.edgeCount} edges. Types: ${Object.entries(stats.nodeTypes).map(([t, c]) => `${t}(${c})`).join(", ") || "none"}`
73
- };
74
- }
75
- case "add": {
76
- let nodesAdded = 0;
77
- let edgesAdded = 0;
78
- if (options.nodes && options.nodes.length > 0) {
79
- const graphNodes = options.nodes.map((n) => ({
80
- id: n.id ?? generateId("node", n.type, n.name),
81
- type: n.type,
82
- name: n.name,
83
- properties: n.properties ?? {},
84
- sourceRecordId: n.sourceRecordId,
85
- sourcePath: n.sourcePath,
86
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
87
- }));
88
- await graphStore.upsertNodes(graphNodes);
89
- nodesAdded = graphNodes.length;
90
- }
91
- if (options.edges && options.edges.length > 0) {
92
- const graphEdges = options.edges.map((e) => ({
93
- id: e.id ?? generateId("edge", e.fromId, e.toId, e.type),
94
- fromId: e.fromId,
95
- toId: e.toId,
96
- type: e.type,
97
- weight: e.weight,
98
- properties: e.properties
99
- }));
100
- await graphStore.upsertEdges(graphEdges);
101
- edgesAdded = graphEdges.length;
102
- }
103
- return {
104
- action,
105
- nodesAdded,
106
- edgesAdded,
107
- summary: `Added ${nodesAdded} node(s) and ${edgesAdded} edge(s) to the graph`
108
- };
109
- }
110
- case "delete": {
111
- if (options.nodeId) {
112
- await graphStore.deleteNode(options.nodeId);
113
- return { action, deleted: 1, summary: `Deleted node "${options.nodeId}" and its edges` };
114
- }
115
- if (options.sourcePath) {
116
- const count = await graphStore.deleteBySourcePath(options.sourcePath);
117
- return {
118
- action,
119
- deleted: count,
120
- summary: `Deleted ${count} node(s) from source "${options.sourcePath}"`
121
- };
122
- }
123
- return { action, summary: "Error: nodeId or sourcePath required for delete action" };
124
- }
125
- case "clear": {
126
- const stats = await graphStore.getStats();
127
- await graphStore.clear();
128
- return {
129
- action,
130
- deleted: stats.nodeCount,
131
- summary: `Cleared graph: removed ${stats.nodeCount} node(s) and ${stats.edgeCount} edge(s)`
132
- };
133
- }
134
- default:
135
- return { action, summary: `Unknown action: ${action}` };
136
- }
137
- }
138
- async function graphAugmentSearch(graphStore, hits, options) {
139
- const hops = options?.hops ?? 1;
140
- const maxPerHit = options?.maxPerHit ?? 5;
141
- const results = [];
142
- for (const hit of hits) {
143
- try {
144
- const linkedNodes = await graphStore.findNodes({ sourcePath: hit.sourcePath });
145
- const allNodes = [];
146
- const allEdges = [];
147
- const seenNodeIds = /* @__PURE__ */ new Set();
148
- const seenEdgeIds = /* @__PURE__ */ new Set();
149
- for (const node of linkedNodes.slice(0, maxPerHit)) {
150
- if (seenNodeIds.has(node.id)) continue;
151
- seenNodeIds.add(node.id);
152
- allNodes.push(node);
153
- if (hops > 0) {
154
- const traversal = await graphStore.traverse(node.id, {
155
- maxDepth: hops,
156
- edgeType: options?.edgeType,
157
- limit: maxPerHit
158
- });
159
- for (const n of traversal.nodes) {
160
- if (!seenNodeIds.has(n.id)) {
161
- seenNodeIds.add(n.id);
162
- allNodes.push(n);
163
- }
164
- }
165
- for (const e of traversal.edges) {
166
- if (!seenEdgeIds.has(e.id)) {
167
- seenEdgeIds.add(e.id);
168
- allEdges.push(e);
169
- }
170
- }
171
- }
172
- }
173
- results.push({
174
- recordId: hit.recordId,
175
- score: hit.score,
176
- sourcePath: hit.sourcePath,
177
- graphContext: { nodes: allNodes, edges: allEdges }
178
- });
179
- } catch {
180
- results.push({
181
- recordId: hit.recordId,
182
- score: hit.score,
183
- sourcePath: hit.sourcePath,
184
- graphContext: { nodes: [], edges: [] }
185
- });
186
- }
187
- }
188
- return results;
189
- }
190
- export {
191
- graphAugmentSearch,
192
- graphQuery
193
- };
194
- //# sourceMappingURL=graph-query.js.map
1
+ import{createHash as p}from"node:crypto";function l(s,...e){return`${s}_${p("sha256").update(e.join("|")).digest("hex").slice(0,12)}`}async function I(s,e){const{action:t}=e;switch(t){case"find_nodes":{const r=await s.findNodes({type:e.nodeType,namePattern:e.namePattern,sourcePath:e.sourcePath,limit:e.limit});return{action:t,nodes:r,summary:`Found ${r.length} node(s)${e.nodeType?` of type "${e.nodeType}"`:""}${e.namePattern?` matching "${e.namePattern}"`:""}`}}case"find_edges":{const r=await s.findEdges({type:e.edgeType,fromId:e.fromId,toId:e.toId,limit:e.limit});return{action:t,edges:r,summary:`Found ${r.length} edge(s)${e.edgeType?` of type "${e.edgeType}"`:""}`}}case"neighbors":{if(!e.nodeId)return{action:t,summary:"Error: nodeId is required for neighbors action"};const r=await s.getNeighbors(e.nodeId,{edgeType:e.edgeType,direction:e.direction,limit:e.limit});return{action:t,nodes:r.nodes,edges:r.edges,summary:`Found ${r.nodes.length} neighbor(s) and ${r.edges.length} edge(s) for node "${e.nodeId}"`}}case"traverse":{if(!e.nodeId)return{action:t,summary:"Error: nodeId is required for traverse action"};const r=await s.traverse(e.nodeId,{edgeType:e.edgeType,maxDepth:e.maxDepth,direction:e.direction,limit:e.limit});return{action:t,nodes:r.nodes,edges:r.edges,summary:`Traversed ${r.nodes.length} node(s) and ${r.edges.length} edge(s) from "${e.nodeId}" (depth=${e.maxDepth??2})`}}case"stats":{const r=await s.getStats();return{action:t,stats:r,summary:`Graph: ${r.nodeCount} nodes, ${r.edgeCount} edges. Types: ${Object.entries(r.nodeTypes).map(([a,n])=>`${a}(${n})`).join(", ")||"none"}`}}case"add":{let r=0,a=0;if(e.nodes&&e.nodes.length>0){const n=e.nodes.map(d=>({id:d.id??l("node",d.type,d.name),type:d.type,name:d.name,properties:d.properties??{},sourceRecordId:d.sourceRecordId,sourcePath:d.sourcePath,createdAt:new Date().toISOString()}));await s.upsertNodes(n),r=n.length}if(e.edges&&e.edges.length>0){const n=e.edges.map(d=>({id:d.id??l("edge",d.fromId,d.toId,d.type),fromId:d.fromId,toId:d.toId,type:d.type,weight:d.weight,properties:d.properties}));await s.upsertEdges(n),a=n.length}return{action:t,nodesAdded:r,edgesAdded:a,summary:`Added ${r} node(s) and ${a} edge(s) to the graph`}}case"delete":{if(e.nodeId)return await s.deleteNode(e.nodeId),{action:t,deleted:1,summary:`Deleted node "${e.nodeId}" and its edges`};if(e.sourcePath){const r=await s.deleteBySourcePath(e.sourcePath);return{action:t,deleted:r,summary:`Deleted ${r} node(s) from source "${e.sourcePath}"`}}return{action:t,summary:"Error: nodeId or sourcePath required for delete action"}}case"clear":{const r=await s.getStats();return await s.clear(),{action:t,deleted:r.nodeCount,summary:`Cleared graph: removed ${r.nodeCount} node(s) and ${r.edgeCount} edge(s)`}}default:return{action:t,summary:`Unknown action: ${t}`}}}async function $(s,e,t){const r=t?.hops??1,a=t?.maxPerHit??5,n=[];for(const d of e)try{const y=await s.findNodes({sourcePath:d.sourcePath}),u=[],c=[],i=new Set,m=new Set;for(const g of y.slice(0,a))if(!i.has(g.id)&&(i.add(g.id),u.push(g),r>0)){const h=await s.traverse(g.id,{maxDepth:r,edgeType:t?.edgeType,limit:a});for(const o of h.nodes)i.has(o.id)||(i.add(o.id),u.push(o));for(const o of h.edges)m.has(o.id)||(m.add(o.id),c.push(o))}n.push({recordId:d.recordId,score:d.score,sourcePath:d.sourcePath,graphContext:{nodes:u,edges:c}})}catch{n.push({recordId:d.recordId,score:d.score,sourcePath:d.sourcePath,graphContext:{nodes:[],edges:[]}})}return n}export{$ as graphAugmentSearch,I as graphQuery};
@@ -1,118 +1 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { join, resolve } from "node:path";
3
- function health(rootPath) {
4
- const root = resolve(rootPath ?? process.cwd());
5
- const checks = [];
6
- const pkgPath = join(root, "package.json");
7
- if (existsSync(pkgPath)) {
8
- checks.push({ name: "package.json", status: "pass", message: "Found" });
9
- try {
10
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
11
- if (!pkg.name) {
12
- checks.push({ name: "package.name", status: "warn", message: "Missing package name" });
13
- } else {
14
- checks.push({ name: "package.name", status: "pass", message: pkg.name });
15
- }
16
- const scripts = pkg.scripts ?? {};
17
- for (const script of ["build", "test", "lint"]) {
18
- if (scripts[script]) {
19
- checks.push({ name: `script:${script}`, status: "pass", message: scripts[script] });
20
- } else {
21
- checks.push({
22
- name: `script:${script}`,
23
- status: "warn",
24
- message: `No "${script}" script defined`
25
- });
26
- }
27
- }
28
- if (pkg.type === "module") {
29
- checks.push({ name: "esm", status: "pass", message: 'ESM ("type": "module")' });
30
- } else if (pkg.type === "commonjs") {
31
- checks.push({ name: "esm", status: "pass", message: 'CJS ("type": "commonjs")' });
32
- } else {
33
- checks.push({ name: "esm", status: "warn", message: 'No "type" field \u2014 defaults to CJS' });
34
- }
35
- if (pkg.engines?.node) {
36
- checks.push({ name: "engines.node", status: "pass", message: pkg.engines.node });
37
- } else {
38
- checks.push({
39
- name: "engines.node",
40
- status: "warn",
41
- message: "No Node.js engine constraint"
42
- });
43
- }
44
- } catch {
45
- checks.push({
46
- name: "package.json",
47
- status: "fail",
48
- message: "Failed to parse package.json"
49
- });
50
- }
51
- } else {
52
- checks.push({
53
- name: "package.json",
54
- status: "fail",
55
- message: "Missing \u2014 not a Node.js project"
56
- });
57
- }
58
- const tsconfigPath = join(root, "tsconfig.json");
59
- if (existsSync(tsconfigPath)) {
60
- checks.push({ name: "tsconfig.json", status: "pass", message: "Found" });
61
- } else {
62
- checks.push({ name: "tsconfig.json", status: "warn", message: "Missing" });
63
- }
64
- const gitignorePath = join(root, ".gitignore");
65
- if (existsSync(gitignorePath)) {
66
- const content = readFileSync(gitignorePath, "utf-8");
67
- const hasNodeModules = content.includes("node_modules");
68
- const hasDist = content.includes("dist");
69
- if (hasNodeModules && hasDist) {
70
- checks.push({
71
- name: ".gitignore",
72
- status: "pass",
73
- message: "Includes node_modules and dist"
74
- });
75
- } else {
76
- checks.push({
77
- name: ".gitignore",
78
- status: "warn",
79
- message: `Missing: ${!hasNodeModules ? "node_modules " : ""}${!hasDist ? "dist" : ""}`.trim()
80
- });
81
- }
82
- } else {
83
- checks.push({ name: ".gitignore", status: "warn", message: "Missing" });
84
- }
85
- const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
86
- const foundLock = lockFiles.find((f) => existsSync(join(root, f)));
87
- if (foundLock) {
88
- checks.push({ name: "lockfile", status: "pass", message: foundLock });
89
- } else {
90
- checks.push({ name: "lockfile", status: "warn", message: "No lock file found" });
91
- }
92
- const readmePath = join(root, "README.md");
93
- if (existsSync(readmePath)) {
94
- const size = readFileSync(readmePath, "utf-8").length;
95
- checks.push({
96
- name: "README.md",
97
- status: size > 100 ? "pass" : "warn",
98
- message: size > 100 ? `Found (${size} chars)` : "Found but very short"
99
- });
100
- } else {
101
- checks.push({ name: "README.md", status: "warn", message: "Missing" });
102
- }
103
- if (existsSync(join(root, "LICENSE")) || existsSync(join(root, "LICENSE.md"))) {
104
- checks.push({ name: "LICENSE", status: "pass", message: "Found" });
105
- } else {
106
- checks.push({ name: "LICENSE", status: "warn", message: "Missing" });
107
- }
108
- const total = checks.length;
109
- const passed = checks.filter((c) => c.status === "pass").length;
110
- const failed = checks.filter((c) => c.status === "fail").length;
111
- const score = Math.round(passed / total * 100);
112
- const summary = failed > 0 ? `${failed} critical issue(s), ${total - passed - failed} warning(s)` : total - passed > 0 ? `${total - passed} warning(s)` : "All checks passed";
113
- return { path: root, checks, score, summary };
114
- }
115
- export {
116
- health
117
- };
118
- //# sourceMappingURL=health.js.map
1
+ import{existsSync as n,readFileSync as p}from"node:fs";import{join as o,resolve as w}from"node:path";function N(d){const a=w(d??process.cwd()),s=[],g=o(a,"package.json");if(n(g)){s.push({name:"package.json",status:"pass",message:"Found"});try{const e=JSON.parse(p(g,"utf-8"));e.name?s.push({name:"package.name",status:"pass",message:e.name}):s.push({name:"package.name",status:"warn",message:"Missing package name"});const i=e.scripts??{};for(const t of["build","test","lint"])i[t]?s.push({name:`script:${t}`,status:"pass",message:i[t]}):s.push({name:`script:${t}`,status:"warn",message:`No "${t}" script defined`});e.type==="module"?s.push({name:"esm",status:"pass",message:'ESM ("type": "module")'}):e.type==="commonjs"?s.push({name:"esm",status:"pass",message:'CJS ("type": "commonjs")'}):s.push({name:"esm",status:"warn",message:'No "type" field \u2014 defaults to CJS'}),e.engines?.node?s.push({name:"engines.node",status:"pass",message:e.engines.node}):s.push({name:"engines.node",status:"warn",message:"No Node.js engine constraint"})}catch{s.push({name:"package.json",status:"fail",message:"Failed to parse package.json"})}}else s.push({name:"package.json",status:"fail",message:"Missing \u2014 not a Node.js project"});const f=o(a,"tsconfig.json");n(f)?s.push({name:"tsconfig.json",status:"pass",message:"Found"}):s.push({name:"tsconfig.json",status:"warn",message:"Missing"});const l=o(a,".gitignore");if(n(l)){const e=p(l,"utf-8"),i=e.includes("node_modules"),t=e.includes("dist");i&&t?s.push({name:".gitignore",status:"pass",message:"Includes node_modules and dist"}):s.push({name:".gitignore",status:"warn",message:`Missing: ${i?"":"node_modules "}${t?"":"dist"}`.trim()})}else s.push({name:".gitignore",status:"warn",message:"Missing"});const r=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock"].find(e=>n(o(a,e)));r?s.push({name:"lockfile",status:"pass",message:r}):s.push({name:"lockfile",status:"warn",message:"No lock file found"});const h=o(a,"README.md");if(n(h)){const e=p(h,"utf-8").length;s.push({name:"README.md",status:e>100?"pass":"warn",message:e>100?`Found (${e} chars)`:"Found but very short"})}else s.push({name:"README.md",status:"warn",message:"Missing"});n(o(a,"LICENSE"))||n(o(a,"LICENSE.md"))?s.push({name:"LICENSE",status:"pass",message:"Found"}):s.push({name:"LICENSE",status:"warn",message:"Missing"});const m=s.length,u=s.filter(e=>e.status==="pass").length,c=s.filter(e=>e.status==="fail").length,k=Math.round(u/m*100),j=c>0?`${c} critical issue(s), ${m-u-c} warning(s)`:m-u>0?`${m-u} warning(s)`:"All checks passed";return{path:a,checks:s,score:k,summary:j}}export{N as health};
@@ -1,58 +1 @@
1
- import { headTailTruncate } from "./truncation.js";
2
- const MAX_BODY_SIZE = 5e4;
3
- const DEFAULT_TIMEOUT = 15e3;
4
- async function httpRequest(options) {
5
- const { url, method = "GET", headers = {}, body, timeout = DEFAULT_TIMEOUT } = options;
6
- const parsed = new URL(url);
7
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
8
- throw new Error(`Unsupported protocol: ${parsed.protocol} \u2014 only http/https allowed`);
9
- }
10
- const controller = new AbortController();
11
- const timer = setTimeout(() => controller.abort(), timeout);
12
- const start = Date.now();
13
- let response;
14
- try {
15
- response = await fetch(url, {
16
- method,
17
- headers: { "User-Agent": "kb-http/1.0", ...headers },
18
- body: method !== "GET" && method !== "HEAD" ? body : void 0,
19
- signal: controller.signal,
20
- redirect: "follow"
21
- });
22
- } finally {
23
- clearTimeout(timer);
24
- }
25
- const durationMs = Date.now() - start;
26
- const responseText = await response.text();
27
- const contentType = response.headers.get("content-type") ?? "";
28
- let formattedBody = responseText;
29
- if (contentType.includes("json")) {
30
- try {
31
- formattedBody = JSON.stringify(JSON.parse(responseText), null, 2);
32
- } catch {
33
- }
34
- }
35
- let truncated = false;
36
- if (formattedBody.length > MAX_BODY_SIZE) {
37
- formattedBody = headTailTruncate(formattedBody, MAX_BODY_SIZE);
38
- truncated = true;
39
- }
40
- const responseHeaders = {};
41
- response.headers.forEach((value, key) => {
42
- responseHeaders[key] = value;
43
- });
44
- return {
45
- status: response.status,
46
- statusText: response.statusText,
47
- headers: responseHeaders,
48
- body: formattedBody,
49
- durationMs,
50
- contentType,
51
- sizeBytes: responseText.length,
52
- truncated
53
- };
54
- }
55
- export {
56
- httpRequest
57
- };
58
- //# sourceMappingURL=http-request.js.map
1
+ import{headTailTruncate as E}from"./truncation.js";const u=5e4,R=15e3;async function H(d){const{url:n,method:s="GET",headers:l={},body:h,timeout:T=R}=d,o=new URL(n);if(o.protocol!=="http:"&&o.protocol!=="https:")throw new Error(`Unsupported protocol: ${o.protocol} \u2014 only http/https allowed`);const a=new AbortController,g=setTimeout(()=>a.abort(),T),y=Date.now();let t;try{t=await fetch(n,{method:s,headers:{"User-Agent":"kb-http/1.0",...l},body:s!=="GET"&&s!=="HEAD"?h:void 0,signal:a.signal,redirect:"follow"})}finally{clearTimeout(g)}const f=Date.now()-y,r=await t.text(),i=t.headers.get("content-type")??"";let e=r;if(i.includes("json"))try{e=JSON.stringify(JSON.parse(r),null,2)}catch{}let c=!1;e.length>u&&(e=E(e,u),c=!0);const p={};return t.headers.forEach((m,b)=>{p[b]=m}),{status:t.status,statusText:t.statusText,headers:p,body:e,durationMs:f,contentType:i,sizeBytes:r.length,truncated:c}}export{H as httpRequest};
@@ -1,273 +1 @@
1
- import {
2
- batch
3
- } from "./batch.js";
4
- import {
5
- changelog,
6
- formatChangelog
7
- } from "./changelog.js";
8
- import { check } from "./check.js";
9
- import {
10
- checkpointLatest,
11
- checkpointList,
12
- checkpointLoad,
13
- checkpointSave
14
- } from "./checkpoint.js";
15
- import {
16
- codemod
17
- } from "./codemod.js";
18
- import { compact } from "./compact.js";
19
- import {
20
- dataTransform
21
- } from "./data-transform.js";
22
- import {
23
- findDeadSymbols
24
- } from "./dead-symbols.js";
25
- import {
26
- delegate,
27
- delegateListModels
28
- } from "./delegate.js";
29
- import {
30
- diffParse
31
- } from "./diff-parse.js";
32
- import {
33
- digest
34
- } from "./digest.js";
35
- import {
36
- encode
37
- } from "./encode.js";
38
- import {
39
- envInfo
40
- } from "./env-info.js";
41
- import { evaluate } from "./eval.js";
42
- import {
43
- evidenceMap
44
- } from "./evidence-map.js";
45
- import {
46
- fileSummary
47
- } from "./file-summary.js";
48
- import { find } from "./find.js";
49
- import {
50
- findExamples
51
- } from "./find-examples.js";
52
- import {
53
- forgeClassify
54
- } from "./forge-classify.js";
55
- import {
56
- forgeGround
57
- } from "./forge-ground.js";
58
- import {
59
- gitContext
60
- } from "./git-context.js";
61
- import {
62
- graphAugmentSearch,
63
- graphQuery
64
- } from "./graph-query.js";
65
- import {
66
- health
67
- } from "./health.js";
68
- import {
69
- httpRequest
70
- } from "./http-request.js";
71
- import {
72
- laneCreate,
73
- laneDiff,
74
- laneDiscard,
75
- laneList,
76
- laneMerge,
77
- laneStatus
78
- } from "./lane.js";
79
- import {
80
- analyzeFile,
81
- measure
82
- } from "./measure.js";
83
- import {
84
- onboard
85
- } from "./onboard.js";
86
- import {
87
- parseBiome,
88
- parseGitStatus,
89
- parseOutput,
90
- parseTsc,
91
- parseVitest
92
- } from "./parse-output.js";
93
- import {
94
- processList,
95
- processLogs,
96
- processStart,
97
- processStatus,
98
- processStop
99
- } from "./process-manager.js";
100
- import {
101
- queueClear,
102
- queueCreate,
103
- queueDelete,
104
- queueDone,
105
- queueFail,
106
- queueGet,
107
- queueList,
108
- queueNext,
109
- queuePush
110
- } from "./queue.js";
111
- import {
112
- regexTest
113
- } from "./regex-test.js";
114
- import {
115
- rename
116
- } from "./rename.js";
117
- import {
118
- replayAppend,
119
- replayCapture,
120
- replayClear,
121
- replayList,
122
- replayTrim
123
- } from "./replay.js";
124
- import {
125
- schemaValidate
126
- } from "./schema-validate.js";
127
- import {
128
- scopeMap
129
- } from "./scope-map.js";
130
- import {
131
- snippet
132
- } from "./snippet.js";
133
- import {
134
- stashClear,
135
- stashDelete,
136
- stashGet,
137
- stashList,
138
- stashSet
139
- } from "./stash.js";
140
- import {
141
- stratumCard
142
- } from "./stratum-card.js";
143
- import { symbol } from "./symbol.js";
144
- import { classifyExitCode, testRun } from "./test-run.js";
145
- import {
146
- cosineSimilarity,
147
- estimateTokens,
148
- segment
149
- } from "./text-utils.js";
150
- import {
151
- timeUtils
152
- } from "./time-utils.js";
153
- import { trace } from "./trace.js";
154
- import { headTailTruncate, paragraphTruncate } from "./truncation.js";
155
- import {
156
- watchList,
157
- watchStart,
158
- watchStop
159
- } from "./watch.js";
160
- import {
161
- webFetch
162
- } from "./web-fetch.js";
163
- import {
164
- parseSearchResults,
165
- webSearch
166
- } from "./web-search.js";
167
- import {
168
- addToWorkset,
169
- deleteWorkset,
170
- getWorkset,
171
- listWorksets,
172
- removeFromWorkset,
173
- saveWorkset
174
- } from "./workset.js";
175
- export {
176
- addToWorkset,
177
- analyzeFile,
178
- batch,
179
- changelog,
180
- check,
181
- checkpointLatest,
182
- checkpointList,
183
- checkpointLoad,
184
- checkpointSave,
185
- classifyExitCode,
186
- codemod,
187
- compact,
188
- cosineSimilarity,
189
- dataTransform,
190
- delegate,
191
- delegateListModels,
192
- deleteWorkset,
193
- diffParse,
194
- digest,
195
- encode,
196
- envInfo,
197
- estimateTokens,
198
- evaluate,
199
- evidenceMap,
200
- fileSummary,
201
- find,
202
- findDeadSymbols,
203
- findExamples,
204
- forgeClassify,
205
- forgeGround,
206
- formatChangelog,
207
- getWorkset,
208
- gitContext,
209
- graphAugmentSearch,
210
- graphQuery,
211
- headTailTruncate,
212
- health,
213
- httpRequest,
214
- laneCreate,
215
- laneDiff,
216
- laneDiscard,
217
- laneList,
218
- laneMerge,
219
- laneStatus,
220
- listWorksets,
221
- measure,
222
- onboard,
223
- paragraphTruncate,
224
- parseBiome,
225
- parseGitStatus,
226
- parseOutput,
227
- parseSearchResults,
228
- parseTsc,
229
- parseVitest,
230
- processList,
231
- processLogs,
232
- processStart,
233
- processStatus,
234
- processStop,
235
- queueClear,
236
- queueCreate,
237
- queueDelete,
238
- queueDone,
239
- queueFail,
240
- queueGet,
241
- queueList,
242
- queueNext,
243
- queuePush,
244
- regexTest,
245
- removeFromWorkset,
246
- rename,
247
- replayAppend,
248
- replayCapture,
249
- replayClear,
250
- replayList,
251
- replayTrim,
252
- saveWorkset,
253
- schemaValidate,
254
- scopeMap,
255
- segment,
256
- snippet,
257
- stashClear,
258
- stashDelete,
259
- stashGet,
260
- stashList,
261
- stashSet,
262
- stratumCard,
263
- symbol,
264
- testRun,
265
- timeUtils,
266
- trace,
267
- watchList,
268
- watchStart,
269
- watchStop,
270
- webFetch,
271
- webSearch
272
- };
273
- //# sourceMappingURL=index.js.map
1
+ import{batch as p}from"./batch.js";import{changelog as r,formatChangelog as s}from"./changelog.js";import{check as y}from"./check.js";import{checkpointLatest as i,checkpointList as l,checkpointLoad as u,checkpointSave as m}from"./checkpoint.js";import{codemod as c}from"./codemod.js";import{compact as h}from"./compact.js";import{dataTransform as R}from"./data-transform.js";import{findDeadSymbols as O}from"./dead-symbols.js";import{delegate as C,delegateListModels as E}from"./delegate.js";import{diffParse as F}from"./diff-parse.js";import{digest as b}from"./digest.js";import{encode as M}from"./encode.js";import{envInfo as W}from"./env-info.js";import{evaluate as L}from"./eval.js";import{evidenceMap as P}from"./evidence-map.js";import{fileSummary as H}from"./file-summary.js";import{find as I}from"./find.js";import{findExamples as V}from"./find-examples.js";import{forgeClassify as U}from"./forge-classify.js";import{forgeGround as z}from"./forge-ground.js";import{gitContext as J}from"./git-context.js";import{graphAugmentSearch as X,graphQuery as Y}from"./graph-query.js";import{health as _}from"./health.js";import{httpRequest as ee}from"./http-request.js";import{laneCreate as pe,laneDiff as oe,laneDiscard as re,laneList as se,laneMerge as ae,laneStatus as ye}from"./lane.js";import{analyzeFile as ie,measure as le}from"./measure.js";import{onboard as me}from"./onboard.js";import{parseBiome as ce,parseGitStatus as de,parseOutput as he,parseTsc as xe,parseVitest as Re}from"./parse-output.js";import{processList as Oe,processLogs as Se,processStart as Ce,processStatus as Ee,processStop as Te}from"./process-manager.js";import{queueClear as De,queueCreate as be,queueDelete as ke,queueDone as Me,queueFail as ve,queueGet as We,queueList as Ge,queueNext as Le,queuePush as qe}from"./queue.js";import{regexTest as we}from"./regex-test.js";import{rename as Ae}from"./rename.js";import{replayAppend as Qe,replayCapture as Ve,replayClear as Be,replayList as Ue,replayTrim as Ne}from"./replay.js";import{schemaValidate as je}from"./schema-validate.js";import{scopeMap as Ke}from"./scope-map.js";import{snippet as Ye}from"./snippet.js";import{stashClear as _e,stashDelete as $e,stashGet as et,stashList as tt,stashSet as pt}from"./stash.js";import{stratumCard as rt}from"./stratum-card.js";import{symbol as at}from"./symbol.js";import{classifyExitCode as nt,testRun as it}from"./test-run.js";import{cosineSimilarity as ut,estimateTokens as mt,segment as ft}from"./text-utils.js";import{timeUtils as dt}from"./time-utils.js";import{trace as xt}from"./trace.js";import{headTailTruncate as gt,paragraphTruncate as Ot}from"./truncation.js";import{watchList as Ct,watchStart as Et,watchStop as Tt}from"./watch.js";import{webFetch as Dt}from"./web-fetch.js";import{parseSearchResults as kt,webSearch as Mt}from"./web-search.js";import{addToWorkset as Wt,deleteWorkset as Gt,getWorkset as Lt,listWorksets as qt,removeFromWorkset as Pt,saveWorkset as wt}from"./workset.js";export{Wt as addToWorkset,ie as analyzeFile,p as batch,r as changelog,y as check,i as checkpointLatest,l as checkpointList,u as checkpointLoad,m as checkpointSave,nt as classifyExitCode,c as codemod,h as compact,ut as cosineSimilarity,R as dataTransform,C as delegate,E as delegateListModels,Gt as deleteWorkset,F as diffParse,b as digest,M as encode,W as envInfo,mt as estimateTokens,L as evaluate,P as evidenceMap,H as fileSummary,I as find,O as findDeadSymbols,V as findExamples,U as forgeClassify,z as forgeGround,s as formatChangelog,Lt as getWorkset,J as gitContext,X as graphAugmentSearch,Y as graphQuery,gt as headTailTruncate,_ as health,ee as httpRequest,pe as laneCreate,oe as laneDiff,re as laneDiscard,se as laneList,ae as laneMerge,ye as laneStatus,qt as listWorksets,le as measure,me as onboard,Ot as paragraphTruncate,ce as parseBiome,de as parseGitStatus,he as parseOutput,kt as parseSearchResults,xe as parseTsc,Re as parseVitest,Oe as processList,Se as processLogs,Ce as processStart,Ee as processStatus,Te as processStop,De as queueClear,be as queueCreate,ke as queueDelete,Me as queueDone,ve as queueFail,We as queueGet,Ge as queueList,Le as queueNext,qe as queuePush,we as regexTest,Pt as removeFromWorkset,Ae as rename,Qe as replayAppend,Ve as replayCapture,Be as replayClear,Ue as replayList,Ne as replayTrim,wt as saveWorkset,je as schemaValidate,Ke as scopeMap,ft as segment,Ye as snippet,_e as stashClear,$e as stashDelete,et as stashGet,tt as stashList,pt as stashSet,rt as stratumCard,at as symbol,it as testRun,dt as timeUtils,xt as trace,Ct as watchList,Et as watchStart,Tt as watchStop,Dt as webFetch,Mt as webSearch};