@vpxa/kb 0.1.13 → 0.1.16

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 (490) hide show
  1. package/README.md +65 -12
  2. package/package.json +14 -7
  3. package/packages/analyzers/dist/blast-radius-analyzer.d.ts +17 -21
  4. package/packages/analyzers/dist/blast-radius-analyzer.js +5 -12
  5. package/packages/analyzers/dist/dependency-analyzer.d.ts +31 -28
  6. package/packages/analyzers/dist/dependency-analyzer.js +6 -9
  7. package/packages/analyzers/dist/diagram-generator.d.ts +12 -9
  8. package/packages/analyzers/dist/diagram-generator.js +2 -4
  9. package/packages/analyzers/dist/entry-point-analyzer.d.ts +39 -36
  10. package/packages/analyzers/dist/entry-point-analyzer.js +4 -6
  11. package/packages/analyzers/dist/index.d.ts +12 -14
  12. package/packages/analyzers/dist/index.js +1 -1
  13. package/packages/analyzers/dist/knowledge-producer.d.ts +34 -26
  14. package/packages/analyzers/dist/knowledge-producer.js +17 -15
  15. package/packages/analyzers/dist/pattern-analyzer.d.ts +14 -11
  16. package/packages/analyzers/dist/pattern-analyzer.js +2 -5
  17. package/packages/analyzers/dist/regex-call-graph.d.ts +6 -13
  18. package/packages/analyzers/dist/regex-call-graph.js +1 -1
  19. package/packages/analyzers/dist/structure-analyzer.d.ts +13 -10
  20. package/packages/analyzers/dist/structure-analyzer.js +2 -4
  21. package/packages/analyzers/dist/symbol-analyzer.d.ts +13 -9
  22. package/packages/analyzers/dist/symbol-analyzer.js +9 -13
  23. package/packages/analyzers/dist/ts-call-graph.d.ts +16 -14
  24. package/packages/analyzers/dist/ts-call-graph.js +1 -1
  25. package/packages/analyzers/dist/types.d.ts +82 -80
  26. package/packages/analyzers/dist/types.js +1 -0
  27. package/packages/chunker/dist/call-graph-extractor.d.ts +15 -12
  28. package/packages/chunker/dist/call-graph-extractor.js +1 -1
  29. package/packages/chunker/dist/chunker-factory.d.ts +16 -4
  30. package/packages/chunker/dist/chunker-factory.js +1 -1
  31. package/packages/chunker/dist/chunker.interface.d.ts +8 -5
  32. package/packages/chunker/dist/chunker.interface.js +1 -0
  33. package/packages/chunker/dist/code-chunker.d.ts +16 -13
  34. package/packages/chunker/dist/code-chunker.js +11 -14
  35. package/packages/chunker/dist/extractors/call-extractor.d.ts +24 -0
  36. package/packages/chunker/dist/extractors/call-extractor.js +1 -0
  37. package/packages/chunker/dist/extractors/entry-point-detector.d.ts +14 -0
  38. package/packages/chunker/dist/extractors/entry-point-detector.js +1 -0
  39. package/packages/chunker/dist/extractors/import-extractor.d.ts +14 -0
  40. package/packages/chunker/dist/extractors/import-extractor.js +1 -0
  41. package/packages/chunker/dist/extractors/pattern-detector.d.ts +14 -0
  42. package/packages/chunker/dist/extractors/pattern-detector.js +1 -0
  43. package/packages/chunker/dist/extractors/scope-resolver.d.ts +26 -0
  44. package/packages/chunker/dist/extractors/scope-resolver.js +1 -0
  45. package/packages/chunker/dist/extractors/symbol-extractor.d.ts +14 -0
  46. package/packages/chunker/dist/extractors/symbol-extractor.js +1 -0
  47. package/packages/chunker/dist/extractors/types.d.ts +36 -0
  48. package/packages/chunker/dist/extractors/types.js +1 -0
  49. package/packages/chunker/dist/generic-chunker.d.ts +14 -11
  50. package/packages/chunker/dist/generic-chunker.js +5 -5
  51. package/packages/chunker/dist/index.d.ts +19 -8
  52. package/packages/chunker/dist/index.js +1 -1
  53. package/packages/chunker/dist/markdown-chunker.d.ts +16 -13
  54. package/packages/chunker/dist/markdown-chunker.js +3 -10
  55. package/packages/chunker/dist/wasm/languages.d.ts +18 -0
  56. package/packages/chunker/dist/wasm/languages.js +1 -0
  57. package/packages/chunker/dist/wasm/query-executor.d.ts +70 -0
  58. package/packages/chunker/dist/wasm/query-executor.js +1 -0
  59. package/packages/chunker/dist/wasm/runtime.d.ts +44 -0
  60. package/packages/chunker/dist/wasm/runtime.js +1 -0
  61. package/packages/chunker/dist/wasm/types.d.ts +84 -0
  62. package/packages/chunker/dist/wasm/types.js +1 -0
  63. package/packages/chunker/dist/wasm-chunker.d.ts +23 -0
  64. package/packages/chunker/dist/wasm-chunker.js +6 -0
  65. package/packages/chunker/src/queries/go/calls.scm +11 -0
  66. package/packages/chunker/src/queries/go/entry-points.scm +20 -0
  67. package/packages/chunker/src/queries/go/imports.scm +6 -0
  68. package/packages/chunker/src/queries/go/patterns.scm +25 -0
  69. package/packages/chunker/src/queries/go/symbols.scm +26 -0
  70. package/packages/chunker/src/queries/java/calls.scm +10 -0
  71. package/packages/chunker/src/queries/java/entry-points.scm +27 -0
  72. package/packages/chunker/src/queries/java/imports.scm +11 -0
  73. package/packages/chunker/src/queries/java/patterns.scm +27 -0
  74. package/packages/chunker/src/queries/java/symbols.scm +28 -0
  75. package/packages/chunker/src/queries/javascript/calls.scm +21 -0
  76. package/packages/chunker/src/queries/javascript/entry-points.scm +31 -0
  77. package/packages/chunker/src/queries/javascript/imports.scm +32 -0
  78. package/packages/chunker/src/queries/javascript/patterns.scm +28 -0
  79. package/packages/chunker/src/queries/javascript/symbols.scm +52 -0
  80. package/packages/chunker/src/queries/python/calls.scm +11 -0
  81. package/packages/chunker/src/queries/python/entry-points.scm +21 -0
  82. package/packages/chunker/src/queries/python/imports.scm +14 -0
  83. package/packages/chunker/src/queries/python/patterns.scm +25 -0
  84. package/packages/chunker/src/queries/python/symbols.scm +17 -0
  85. package/packages/chunker/src/queries/rust/calls.scm +20 -0
  86. package/packages/chunker/src/queries/rust/entry-points.scm +7 -0
  87. package/packages/chunker/src/queries/rust/imports.scm +26 -0
  88. package/packages/chunker/src/queries/rust/patterns.scm +18 -0
  89. package/packages/chunker/src/queries/rust/symbols.scm +73 -0
  90. package/packages/chunker/src/queries/typescript/calls.scm +21 -0
  91. package/packages/chunker/src/queries/typescript/entry-points.scm +48 -0
  92. package/packages/chunker/src/queries/typescript/imports.scm +35 -0
  93. package/packages/chunker/src/queries/typescript/patterns.scm +47 -0
  94. package/packages/chunker/src/queries/typescript/symbols.scm +79 -0
  95. package/packages/chunker/wasm/tree-sitter-go.wasm +0 -0
  96. package/packages/chunker/wasm/tree-sitter-java.wasm +0 -0
  97. package/packages/chunker/wasm/tree-sitter-javascript.wasm +0 -0
  98. package/packages/chunker/wasm/tree-sitter-python.wasm +0 -0
  99. package/packages/chunker/wasm/tree-sitter-rust.wasm +0 -0
  100. package/packages/chunker/wasm/tree-sitter-typescript.wasm +0 -0
  101. package/packages/chunker/wasm/tree-sitter.wasm +0 -0
  102. package/packages/cli/dist/commands/analyze.d.ts +6 -3
  103. package/packages/cli/dist/commands/analyze.js +2 -3
  104. package/packages/cli/dist/commands/context-cmds.d.ts +6 -3
  105. package/packages/cli/dist/commands/context-cmds.js +1 -1
  106. package/packages/cli/dist/commands/environment.d.ts +6 -3
  107. package/packages/cli/dist/commands/environment.js +1 -2
  108. package/packages/cli/dist/commands/execution.d.ts +6 -3
  109. package/packages/cli/dist/commands/execution.js +1 -1
  110. package/packages/cli/dist/commands/graph.d.ts +6 -3
  111. package/packages/cli/dist/commands/graph.js +5 -6
  112. package/packages/cli/dist/commands/init/adapters.d.ts +28 -0
  113. package/packages/cli/dist/commands/init/adapters.js +1 -0
  114. package/packages/cli/dist/commands/init/config.d.ts +10 -0
  115. package/packages/cli/dist/commands/init/config.js +3 -0
  116. package/packages/cli/dist/commands/init/constants.d.ts +18 -0
  117. package/packages/cli/dist/commands/init/constants.js +1 -0
  118. package/packages/cli/dist/commands/init/curated.d.ts +7 -0
  119. package/packages/cli/dist/commands/init/curated.js +1 -0
  120. package/packages/cli/dist/commands/init/global.d.ts +34 -0
  121. package/packages/cli/dist/commands/init/global.js +5 -0
  122. package/packages/cli/dist/commands/init/index.d.ts +28 -0
  123. package/packages/cli/dist/commands/init/index.js +5 -0
  124. package/packages/cli/dist/commands/init/scaffold.d.ts +23 -0
  125. package/packages/cli/dist/commands/init/scaffold.js +1 -0
  126. package/packages/cli/dist/commands/init/templates.d.ts +9 -0
  127. package/packages/cli/dist/commands/init/templates.js +165 -0
  128. package/packages/cli/dist/commands/knowledge.d.ts +6 -3
  129. package/packages/cli/dist/commands/knowledge.js +1 -1
  130. package/packages/cli/dist/commands/search.d.ts +6 -3
  131. package/packages/cli/dist/commands/search.js +1 -8
  132. package/packages/cli/dist/commands/system.d.ts +6 -3
  133. package/packages/cli/dist/commands/system.js +4 -7
  134. package/packages/cli/dist/commands/workspace.d.ts +6 -3
  135. package/packages/cli/dist/commands/workspace.js +1 -2
  136. package/packages/cli/dist/context.d.ts +7 -5
  137. package/packages/cli/dist/context.js +1 -1
  138. package/packages/cli/dist/helpers.d.ts +51 -48
  139. package/packages/cli/dist/helpers.js +5 -5
  140. package/packages/cli/dist/index.d.ts +4 -2
  141. package/packages/cli/dist/index.js +2 -2
  142. package/packages/cli/dist/kb-init.d.ts +48 -51
  143. package/packages/cli/dist/kb-init.js +1 -1
  144. package/packages/cli/dist/types.d.ts +8 -6
  145. package/packages/cli/dist/types.js +1 -0
  146. package/packages/core/dist/constants.d.ts +58 -34
  147. package/packages/core/dist/constants.js +1 -1
  148. package/packages/core/dist/content-detector.d.ts +8 -8
  149. package/packages/core/dist/content-detector.js +1 -1
  150. package/packages/core/dist/errors.d.ts +15 -13
  151. package/packages/core/dist/errors.js +1 -1
  152. package/packages/core/dist/global-registry.d.ts +62 -0
  153. package/packages/core/dist/global-registry.js +1 -0
  154. package/packages/core/dist/index.d.ts +7 -6
  155. package/packages/core/dist/index.js +1 -1
  156. package/packages/core/dist/logger.d.ts +19 -8
  157. package/packages/core/dist/logger.js +1 -1
  158. package/packages/core/dist/types.d.ts +107 -92
  159. package/packages/core/dist/types.js +1 -0
  160. package/packages/embeddings/dist/embedder.interface.d.ts +22 -20
  161. package/packages/embeddings/dist/embedder.interface.js +1 -0
  162. package/packages/embeddings/dist/index.d.ts +3 -3
  163. package/packages/embeddings/dist/index.js +1 -1
  164. package/packages/embeddings/dist/onnx-embedder.d.ts +21 -23
  165. package/packages/embeddings/dist/onnx-embedder.js +1 -1
  166. package/packages/enterprise-bridge/dist/cache.d.ts +28 -0
  167. package/packages/enterprise-bridge/dist/cache.js +1 -0
  168. package/packages/enterprise-bridge/dist/er-client.d.ts +37 -0
  169. package/packages/enterprise-bridge/dist/er-client.js +1 -0
  170. package/packages/enterprise-bridge/dist/evolution-collector.d.ts +62 -0
  171. package/packages/enterprise-bridge/dist/evolution-collector.js +1 -0
  172. package/packages/enterprise-bridge/dist/index.d.ts +8 -0
  173. package/packages/enterprise-bridge/dist/index.js +1 -0
  174. package/packages/enterprise-bridge/dist/policy-store.d.ts +45 -0
  175. package/packages/enterprise-bridge/dist/policy-store.js +1 -0
  176. package/packages/enterprise-bridge/dist/push-adapter.d.ts +23 -0
  177. package/packages/enterprise-bridge/dist/push-adapter.js +1 -0
  178. package/packages/enterprise-bridge/dist/result-merger.d.ts +14 -0
  179. package/packages/enterprise-bridge/dist/result-merger.js +1 -0
  180. package/packages/enterprise-bridge/dist/types.d.ts +81 -0
  181. package/packages/enterprise-bridge/dist/types.js +1 -0
  182. package/packages/indexer/dist/file-hasher.d.ts +5 -3
  183. package/packages/indexer/dist/file-hasher.js +1 -1
  184. package/packages/indexer/dist/filesystem-crawler.d.ts +23 -21
  185. package/packages/indexer/dist/filesystem-crawler.js +1 -1
  186. package/packages/indexer/dist/graph-extractor.d.ts +9 -13
  187. package/packages/indexer/dist/graph-extractor.js +1 -1
  188. package/packages/indexer/dist/incremental-indexer.d.ts +49 -44
  189. package/packages/indexer/dist/incremental-indexer.js +1 -1
  190. package/packages/indexer/dist/index.d.ts +5 -5
  191. package/packages/indexer/dist/index.js +1 -1
  192. package/packages/server/dist/api.d.ts +3 -8
  193. package/packages/server/dist/api.js +1 -1
  194. package/packages/server/dist/config.d.ts +6 -3
  195. package/packages/server/dist/config.js +1 -1
  196. package/packages/server/dist/cross-workspace.d.ts +43 -0
  197. package/packages/server/dist/cross-workspace.js +1 -0
  198. package/packages/server/dist/curated-manager.d.ts +80 -78
  199. package/packages/server/dist/curated-manager.js +5 -10
  200. package/packages/server/dist/index.d.ts +1 -2
  201. package/packages/server/dist/index.js +1 -1
  202. package/packages/server/dist/replay-interceptor.d.ts +6 -7
  203. package/packages/server/dist/replay-interceptor.js +1 -1
  204. package/packages/server/dist/resources/resources.d.ts +7 -4
  205. package/packages/server/dist/resources/resources.js +2 -2
  206. package/packages/server/dist/server.d.ts +37 -25
  207. package/packages/server/dist/server.js +1 -1
  208. package/packages/server/dist/tools/analyze.tools.d.ts +14 -11
  209. package/packages/server/dist/tools/analyze.tools.js +1 -3
  210. package/packages/server/dist/tools/audit.tool.d.ts +8 -5
  211. package/packages/server/dist/tools/audit.tool.js +1 -4
  212. package/packages/server/dist/tools/bridge.tools.d.ts +34 -0
  213. package/packages/server/dist/tools/bridge.tools.js +15 -0
  214. package/packages/server/dist/tools/evolution.tools.d.ts +7 -0
  215. package/packages/server/dist/tools/evolution.tools.js +5 -0
  216. package/packages/server/dist/tools/forge.tools.d.ts +13 -12
  217. package/packages/server/dist/tools/forge.tools.js +10 -13
  218. package/packages/server/dist/tools/forget.tool.d.ts +7 -4
  219. package/packages/server/dist/tools/forget.tool.js +1 -7
  220. package/packages/server/dist/tools/graph.tool.d.ts +7 -4
  221. package/packages/server/dist/tools/graph.tool.js +4 -5
  222. package/packages/server/dist/tools/list.tool.d.ts +7 -4
  223. package/packages/server/dist/tools/list.tool.js +2 -8
  224. package/packages/server/dist/tools/lookup.tool.d.ts +7 -4
  225. package/packages/server/dist/tools/lookup.tool.js +2 -9
  226. package/packages/server/dist/tools/onboard.tool.d.ts +8 -5
  227. package/packages/server/dist/tools/onboard.tool.js +2 -2
  228. package/packages/server/dist/tools/policy.tools.d.ts +7 -0
  229. package/packages/server/dist/tools/policy.tools.js +2 -0
  230. package/packages/server/dist/tools/produce.tool.d.ts +6 -3
  231. package/packages/server/dist/tools/produce.tool.js +2 -2
  232. package/packages/server/dist/tools/read.tool.d.ts +7 -4
  233. package/packages/server/dist/tools/read.tool.js +2 -6
  234. package/packages/server/dist/tools/reindex.tool.d.ts +10 -7
  235. package/packages/server/dist/tools/reindex.tool.js +3 -2
  236. package/packages/server/dist/tools/remember.tool.d.ts +8 -4
  237. package/packages/server/dist/tools/remember.tool.js +3 -5
  238. package/packages/server/dist/tools/replay.tool.d.ts +6 -3
  239. package/packages/server/dist/tools/replay.tool.js +2 -6
  240. package/packages/server/dist/tools/search.tool.d.ts +10 -5
  241. package/packages/server/dist/tools/search.tool.js +6 -22
  242. package/packages/server/dist/tools/status.tool.d.ts +12 -4
  243. package/packages/server/dist/tools/status.tool.js +2 -3
  244. package/packages/server/dist/tools/toolkit.tools.d.ts +36 -35
  245. package/packages/server/dist/tools/toolkit.tools.js +20 -24
  246. package/packages/server/dist/tools/update.tool.d.ts +7 -4
  247. package/packages/server/dist/tools/update.tool.js +1 -6
  248. package/packages/server/dist/tools/utility.tools.d.ts +15 -15
  249. package/packages/server/dist/tools/utility.tools.js +10 -23
  250. package/packages/server/dist/version-check.d.ts +5 -2
  251. package/packages/server/dist/version-check.js +1 -1
  252. package/packages/store/dist/graph-store.interface.d.ts +89 -87
  253. package/packages/store/dist/graph-store.interface.js +1 -0
  254. package/packages/store/dist/index.d.ts +6 -6
  255. package/packages/store/dist/index.js +1 -1
  256. package/packages/store/dist/lance-store.d.ts +37 -31
  257. package/packages/store/dist/lance-store.js +1 -1
  258. package/packages/store/dist/sqlite-graph-store.d.ts +43 -47
  259. package/packages/store/dist/sqlite-graph-store.js +13 -13
  260. package/packages/store/dist/store-factory.d.ts +11 -8
  261. package/packages/store/dist/store-factory.js +1 -1
  262. package/packages/store/dist/store.interface.d.ts +47 -47
  263. package/packages/store/dist/store.interface.js +1 -0
  264. package/packages/tools/dist/audit.d.ts +61 -62
  265. package/packages/tools/dist/audit.js +4 -5
  266. package/packages/tools/dist/batch.d.ts +20 -18
  267. package/packages/tools/dist/batch.js +1 -1
  268. package/packages/tools/dist/changelog.d.ts +29 -27
  269. package/packages/tools/dist/changelog.js +2 -2
  270. package/packages/tools/dist/check.d.ts +42 -39
  271. package/packages/tools/dist/check.js +2 -2
  272. package/packages/tools/dist/checkpoint.d.ts +17 -15
  273. package/packages/tools/dist/checkpoint.js +1 -2
  274. package/packages/tools/dist/codemod.d.ts +35 -33
  275. package/packages/tools/dist/codemod.js +2 -2
  276. package/packages/tools/dist/compact.d.ts +34 -38
  277. package/packages/tools/dist/compact.js +2 -2
  278. package/packages/tools/dist/data-transform.d.ts +10 -8
  279. package/packages/tools/dist/data-transform.js +1 -1
  280. package/packages/tools/dist/dead-symbols.d.ts +29 -26
  281. package/packages/tools/dist/dead-symbols.js +2 -2
  282. package/packages/tools/dist/delegate.d.ts +26 -24
  283. package/packages/tools/dist/delegate.js +1 -5
  284. package/packages/tools/dist/diff-parse.d.ts +24 -22
  285. package/packages/tools/dist/diff-parse.js +3 -3
  286. package/packages/tools/dist/digest.d.ts +43 -46
  287. package/packages/tools/dist/digest.js +4 -5
  288. package/packages/tools/dist/dogfood-log.d.ts +49 -0
  289. package/packages/tools/dist/dogfood-log.js +2 -0
  290. package/packages/tools/dist/encode.d.ts +11 -9
  291. package/packages/tools/dist/encode.js +1 -1
  292. package/packages/tools/dist/env-info.d.ts +25 -23
  293. package/packages/tools/dist/env-info.js +1 -1
  294. package/packages/tools/dist/eval.d.ts +13 -11
  295. package/packages/tools/dist/eval.js +2 -3
  296. package/packages/tools/dist/evidence-map.d.ts +64 -62
  297. package/packages/tools/dist/evidence-map.js +2 -3
  298. package/packages/tools/dist/file-cache.d.ts +41 -0
  299. package/packages/tools/dist/file-cache.js +3 -0
  300. package/packages/tools/dist/file-summary.d.ts +50 -30
  301. package/packages/tools/dist/file-summary.js +2 -2
  302. package/packages/tools/dist/file-walk.d.ts +6 -4
  303. package/packages/tools/dist/file-walk.js +1 -1
  304. package/packages/tools/dist/find-examples.d.ts +26 -22
  305. package/packages/tools/dist/find-examples.js +3 -3
  306. package/packages/tools/dist/find.d.ts +39 -41
  307. package/packages/tools/dist/find.js +1 -1
  308. package/packages/tools/dist/forge-classify.d.ts +35 -39
  309. package/packages/tools/dist/forge-classify.js +2 -2
  310. package/packages/tools/dist/forge-ground.d.ts +58 -61
  311. package/packages/tools/dist/forge-ground.js +1 -1
  312. package/packages/tools/dist/git-context.d.ts +22 -20
  313. package/packages/tools/dist/git-context.js +3 -3
  314. package/packages/tools/dist/graph-query.d.ts +75 -79
  315. package/packages/tools/dist/graph-query.js +1 -1
  316. package/packages/tools/dist/guide.d.ts +14 -12
  317. package/packages/tools/dist/guide.js +1 -1
  318. package/packages/tools/dist/health.d.ts +13 -11
  319. package/packages/tools/dist/health.js +2 -2
  320. package/packages/tools/dist/http-request.d.ts +20 -18
  321. package/packages/tools/dist/http-request.js +1 -1
  322. package/packages/tools/dist/index.d.ts +55 -53
  323. package/packages/tools/dist/index.js +1 -1
  324. package/packages/tools/dist/lane.d.ts +28 -26
  325. package/packages/tools/dist/lane.js +6 -7
  326. package/packages/tools/dist/measure.d.ts +34 -30
  327. package/packages/tools/dist/measure.js +2 -2
  328. package/packages/tools/dist/onboard.d.ts +29 -27
  329. package/packages/tools/dist/onboard.js +17 -41
  330. package/packages/tools/dist/parse-output.d.ts +48 -46
  331. package/packages/tools/dist/parse-output.js +2 -2
  332. package/packages/tools/dist/path-resolver.d.ts +4 -2
  333. package/packages/tools/dist/path-resolver.js +1 -1
  334. package/packages/tools/dist/process-manager.d.ts +18 -16
  335. package/packages/tools/dist/process-manager.js +1 -1
  336. package/packages/tools/dist/queue.d.ts +28 -26
  337. package/packages/tools/dist/queue.js +1 -2
  338. package/packages/tools/dist/regex-test.d.ts +26 -24
  339. package/packages/tools/dist/regex-test.js +1 -1
  340. package/packages/tools/dist/rename.d.ts +28 -26
  341. package/packages/tools/dist/rename.js +2 -2
  342. package/packages/tools/dist/replay.d.ts +33 -31
  343. package/packages/tools/dist/replay.js +4 -6
  344. package/packages/tools/dist/response-envelope.d.ts +32 -30
  345. package/packages/tools/dist/response-envelope.js +1 -1
  346. package/packages/tools/dist/schema-validate.d.ts +15 -13
  347. package/packages/tools/dist/schema-validate.js +1 -1
  348. package/packages/tools/dist/scope-map.d.ts +45 -48
  349. package/packages/tools/dist/scope-map.js +1 -1
  350. package/packages/tools/dist/snippet.d.ts +26 -25
  351. package/packages/tools/dist/snippet.js +1 -1
  352. package/packages/tools/dist/stash.d.ts +13 -11
  353. package/packages/tools/dist/stash.js +1 -2
  354. package/packages/tools/dist/stratum-card.d.ts +27 -28
  355. package/packages/tools/dist/stratum-card.js +3 -5
  356. package/packages/tools/dist/symbol.d.ts +31 -26
  357. package/packages/tools/dist/symbol.js +3 -3
  358. package/packages/tools/dist/test-run.d.ts +19 -16
  359. package/packages/tools/dist/test-run.js +2 -2
  360. package/packages/tools/dist/text-utils.d.ts +6 -4
  361. package/packages/tools/dist/text-utils.js +2 -2
  362. package/packages/tools/dist/time-utils.d.ts +15 -13
  363. package/packages/tools/dist/time-utils.js +1 -1
  364. package/packages/tools/dist/trace.d.ts +26 -21
  365. package/packages/tools/dist/trace.js +2 -2
  366. package/packages/tools/dist/truncation.d.ts +6 -4
  367. package/packages/tools/dist/truncation.js +6 -13
  368. package/packages/tools/dist/watch.d.ts +28 -26
  369. package/packages/tools/dist/watch.js +1 -1
  370. package/packages/tools/dist/web-fetch.d.ts +35 -33
  371. package/packages/tools/dist/web-fetch.js +6 -12
  372. package/packages/tools/dist/web-search.d.ts +16 -14
  373. package/packages/tools/dist/web-search.js +1 -1
  374. package/packages/tools/dist/workset.d.ts +19 -17
  375. package/packages/tools/dist/workset.js +1 -2
  376. package/packages/tui/dist/App-CYLNJLr6.js +2 -0
  377. package/packages/tui/dist/App.d.ts +11 -6
  378. package/packages/tui/dist/App.js +1 -450
  379. package/packages/tui/dist/CuratedPanel-sYdZAICX.js +2 -0
  380. package/packages/tui/dist/LogPanel-DtMnoyXT.js +3 -0
  381. package/packages/tui/dist/SearchPanel-DREo6zgt.js +2 -0
  382. package/packages/tui/dist/StatusPanel-2ex8fLOO.js +2 -0
  383. package/packages/tui/dist/chunk-D6axbAb-.js +2 -0
  384. package/packages/tui/dist/devtools-DUyj952l.js +7 -0
  385. package/packages/tui/dist/embedder.interface-D4ew0HPW.d.ts +28 -0
  386. package/packages/tui/dist/index-B9VpfVPP.d.ts +13 -0
  387. package/packages/tui/dist/index.d.ts +3 -19
  388. package/packages/tui/dist/index.js +1 -476
  389. package/packages/tui/dist/jsx-runtime-Cof-kwFn.js +316 -0
  390. package/packages/tui/dist/panels/CuratedPanel.d.ts +11 -6
  391. package/packages/tui/dist/panels/CuratedPanel.js +1 -371
  392. package/packages/tui/dist/panels/LogPanel.d.ts +7 -3
  393. package/packages/tui/dist/panels/LogPanel.js +1 -449
  394. package/packages/tui/dist/panels/SearchPanel.d.ts +14 -8
  395. package/packages/tui/dist/panels/SearchPanel.js +1 -372
  396. package/packages/tui/dist/panels/StatusPanel.d.ts +11 -6
  397. package/packages/tui/dist/panels/StatusPanel.js +1 -371
  398. package/packages/tui/dist/store.interface-CnY6SPOH.d.ts +150 -0
  399. package/scaffold/adapters/claude-code.mjs +20 -0
  400. package/scaffold/adapters/copilot.mjs +320 -0
  401. package/scaffold/copilot/agents/Architect-Reviewer-Alpha.agent.md +21 -0
  402. package/scaffold/copilot/agents/Architect-Reviewer-Beta.agent.md +21 -0
  403. package/scaffold/copilot/agents/Documenter.agent.md +42 -0
  404. package/scaffold/copilot/agents/Orchestrator.agent.md +104 -0
  405. package/scaffold/copilot/agents/Planner.agent.md +54 -0
  406. package/scaffold/copilot/agents/Refactor.agent.md +36 -0
  407. package/scaffold/copilot/agents/Researcher-Alpha.agent.md +20 -0
  408. package/scaffold/copilot/agents/Researcher-Beta.agent.md +20 -0
  409. package/scaffold/copilot/agents/Researcher-Delta.agent.md +20 -0
  410. package/scaffold/copilot/agents/Researcher-Gamma.agent.md +20 -0
  411. package/scaffold/definitions/agents.mjs +165 -0
  412. package/scaffold/definitions/bodies.mjs +292 -0
  413. package/scaffold/definitions/hooks.mjs +43 -0
  414. package/scaffold/definitions/models.mjs +56 -0
  415. package/scaffold/definitions/plugins.mjs +24 -0
  416. package/scaffold/definitions/prompts.mjs +145 -0
  417. package/scaffold/definitions/protocols.mjs +322 -0
  418. package/scaffold/definitions/tools.mjs +176 -0
  419. package/scaffold/general/agents/Architect-Reviewer-Alpha.agent.md +21 -0
  420. package/scaffold/general/agents/Architect-Reviewer-Beta.agent.md +21 -0
  421. package/scaffold/general/agents/Code-Reviewer-Alpha.agent.md +12 -0
  422. package/scaffold/general/agents/Code-Reviewer-Beta.agent.md +12 -0
  423. package/scaffold/general/agents/Debugger.agent.md +31 -0
  424. package/scaffold/general/agents/Documenter.agent.md +42 -0
  425. package/scaffold/general/agents/Explorer.agent.md +50 -0
  426. package/scaffold/general/agents/Frontend.agent.md +29 -0
  427. package/scaffold/general/agents/Implementer.agent.md +31 -0
  428. package/scaffold/general/agents/Orchestrator.agent.md +104 -0
  429. package/scaffold/general/agents/Planner.agent.md +55 -0
  430. package/scaffold/general/agents/README.md +57 -0
  431. package/scaffold/general/agents/Refactor.agent.md +36 -0
  432. package/scaffold/general/agents/Researcher-Alpha.agent.md +20 -0
  433. package/scaffold/general/agents/Researcher-Beta.agent.md +20 -0
  434. package/scaffold/general/agents/Researcher-Delta.agent.md +20 -0
  435. package/scaffold/general/agents/Researcher-Gamma.agent.md +20 -0
  436. package/scaffold/general/agents/Security.agent.md +42 -0
  437. package/scaffold/general/agents/_shared/adr-protocol.md +91 -0
  438. package/scaffold/general/agents/_shared/architect-reviewer-base.md +50 -0
  439. package/scaffold/general/agents/_shared/code-agent-base.md +88 -0
  440. package/scaffold/general/agents/_shared/code-reviewer-base.md +54 -0
  441. package/scaffold/general/agents/_shared/decision-protocol.md +27 -0
  442. package/scaffold/general/agents/_shared/forge-protocol.md +46 -0
  443. package/scaffold/general/agents/_shared/researcher-base.md +61 -0
  444. package/scaffold/general/agents/templates/adr-template.md +27 -0
  445. package/scaffold/general/agents/templates/execution-state.md +25 -0
  446. package/scaffold/general/prompts/ask.prompt.md +20 -0
  447. package/scaffold/general/prompts/debug.prompt.md +25 -0
  448. package/scaffold/general/prompts/design.prompt.md +22 -0
  449. package/scaffold/general/prompts/implement.prompt.md +26 -0
  450. package/scaffold/general/prompts/plan.prompt.md +24 -0
  451. package/scaffold/general/prompts/review.prompt.md +31 -0
  452. package/scaffold/generate.mjs +74 -0
  453. package/skills/adr-skill/SKILL.md +329 -0
  454. package/skills/adr-skill/assets/templates/adr-madr.md +89 -0
  455. package/skills/adr-skill/assets/templates/adr-readme.md +20 -0
  456. package/skills/adr-skill/assets/templates/adr-simple.md +46 -0
  457. package/skills/adr-skill/references/adr-conventions.md +95 -0
  458. package/skills/adr-skill/references/examples.md +193 -0
  459. package/skills/adr-skill/references/review-checklist.md +77 -0
  460. package/skills/adr-skill/references/template-variants.md +52 -0
  461. package/skills/adr-skill/scripts/bootstrap_adr.js +259 -0
  462. package/skills/adr-skill/scripts/new_adr.js +391 -0
  463. package/skills/adr-skill/scripts/set_adr_status.js +169 -0
  464. package/skills/brainstorming/SKILL.md +259 -0
  465. package/skills/brainstorming/scripts/frame-template.html +365 -0
  466. package/skills/brainstorming/scripts/helper.js +216 -0
  467. package/skills/brainstorming/scripts/server.cjs +9 -0
  468. package/skills/brainstorming/scripts/server.src.cjs +249 -0
  469. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  470. package/skills/brainstorming/visual-companion.md +430 -0
  471. package/skills/c4-architecture/SKILL.md +295 -0
  472. package/skills/c4-architecture/references/advanced-patterns.md +552 -0
  473. package/skills/c4-architecture/references/c4-syntax.md +492 -0
  474. package/skills/c4-architecture/references/common-mistakes.md +437 -0
  475. package/skills/knowledge-base/SKILL.md +100 -10
  476. package/skills/lesson-learned/SKILL.md +105 -0
  477. package/skills/lesson-learned/references/anti-patterns.md +55 -0
  478. package/skills/lesson-learned/references/se-principles.md +109 -0
  479. package/skills/requirements-clarity/SKILL.md +324 -0
  480. package/skills/session-handoff/SKILL.md +189 -0
  481. package/skills/session-handoff/references/handoff-template.md +139 -0
  482. package/skills/session-handoff/references/resume-checklist.md +80 -0
  483. package/skills/session-handoff/scripts/check_staleness.js +269 -0
  484. package/skills/session-handoff/scripts/create_handoff.js +299 -0
  485. package/skills/session-handoff/scripts/list_handoffs.js +113 -0
  486. package/skills/session-handoff/scripts/validate_handoff.js +241 -0
  487. package/packages/chunker/dist/treesitter-chunker.d.ts +0 -47
  488. package/packages/chunker/dist/treesitter-chunker.js +0 -8
  489. package/packages/cli/dist/commands/init.d.ts +0 -10
  490. package/packages/cli/dist/commands/init.js +0 -308
package/README.md CHANGED
@@ -29,24 +29,74 @@ The KB auto-indexes configured source directories on startup, stores embeddings
29
29
 
30
30
  ## Quick Start
31
31
 
32
+ ### Global Install (recommended for multi-project setups)
33
+
32
34
  ```bash
33
- # Install
34
- pnpm add -D @vpxa/kb
35
+ # Install once, works across all your projects
36
+ npx @vpxa/kb init --global
35
37
 
36
- # Initialize in your project
38
+ # Then in any workspace, scaffold instructions only
37
39
  npx @vpxa/kb init
40
+ ```
38
41
 
39
- # Index your codebase
40
- npx @vpxa/kb reindex
42
+ ### Local Install (per-project, self-contained)
41
43
 
42
- # Search
43
- npx @vpxa/kb search "authentication middleware"
44
+ ```bash
45
+ # Full local initialization
46
+ npx @vpxa/kb init --local
44
47
 
45
- # Start MCP server for AI agents
48
+ # Index and search
49
+ npx @vpxa/kb reindex
50
+ npx @vpxa/kb search "authentication middleware"
46
51
  npx @vpxa/kb serve
47
52
  ```
48
53
 
49
- > **Note:** Once `@vpxa/kb` is installed locally, you can use the short `kb` command (e.g. `kb search`, `kb serve`) since the local binary takes precedence.
54
+ ### After upgrading
55
+
56
+ ```bash
57
+ npx @vpxa/kb init --force # Overwrite all scaffold/skill files
58
+ npx @vpxa/kb init --guide # Check which files are outdated
59
+ ```
60
+
61
+ > **Note:** In local mode, once `@vpxa/kb` is installed locally, you can use the short `kb` command (e.g. `kb search`, `kb serve`) since the local binary takes precedence.
62
+
63
+ ## Global vs Local Mode
64
+
65
+ KB supports two installation modes:
66
+
67
+ | | Global | Local |
68
+ |---|---|---|
69
+ | **Install** | `kb init --global` (once) | `kb init --local` (per project) |
70
+ | **MCP config** | User-level (IDE-wide) | `.vscode/mcp.json` (workspace) |
71
+ | **Data store** | `~/.kb-data/<partition>/` | `.kb-data/store/` (in project) |
72
+ | **Skills** | `~/.kb-data/skills/` | `.github/skills/` (in project) |
73
+ | **Config** | Auto defaults per workspace | `kb.config.json` (in project) |
74
+
75
+ ### How it works
76
+
77
+ - **`kb init --global`** — Installs the MCP server in your user-level IDE config (VS Code, Cursor, Claude Code). Creates `~/.kb-data/` for data. Skills are shared. The server auto-indexes each workspace it's opened in.
78
+ - **`kb init`** (smart default) — If global is installed, scaffolds workspace-only files (AGENTS.md, instructions, curated directories). If not, does a full local install.
79
+ - **`kb init --local`** — Traditional per-project install with full local config and data store.
80
+
81
+ ### Checking your mode
82
+
83
+ ```bash
84
+ kb status
85
+ # Mode: global (workspace scaffolded)
86
+ # Data: ~/.kb-data/my-project-a1b2c3d4/
87
+ # Registry: 3 workspace(s) enrolled
88
+ ```
89
+
90
+ ### Cross-workspace search (global mode only)
91
+
92
+ ```
93
+ search({ query: "error handling", workspaces: ["*"] }) # All workspaces
94
+ search({ query: "CircuitBreaker", workspaces: ["other-project"] }) # Specific workspace
95
+ symbol({ name: "MyService", workspaces: ["*"] }) # Find symbol across all
96
+ find({ query: "retry logic", workspaces: ["backend", "shared"] }) # Multiple workspaces
97
+ ```
98
+
99
+ Tools supporting `workspaces` param: `search`, `find`, `symbol`.
50
100
 
51
101
  ## Tools by Category
52
102
 
@@ -191,6 +241,8 @@ After `kb init`, your `.vscode/mcp.json` is configured automatically:
191
241
  }
192
242
  ```
193
243
 
244
+ > **Global mode:** When installed with `kb init --global`, the MCP server is configured at the user level — no per-project `mcp.json` needed. The server auto-detects and indexes each workspace.
245
+
194
246
  ## CLI Usage
195
247
 
196
248
  ```bash
@@ -261,7 +313,7 @@ kb status
261
313
  kb reindex [--full]
262
314
  kb onboard <path> [--generate] [--out-dir <dir>]
263
315
  kb serve [--transport stdio|http] [--port N]
264
- kb init [--force]
316
+ kb init [--global|--local] [--force] [--guide]
265
317
  ```
266
318
 
267
319
  ## Configuration
@@ -290,7 +342,7 @@ kb init [--force]
290
342
  ```text
291
343
  @vpxa/kb
292
344
  ├── packages/
293
- │ ├── core/ — types, config, logger, constants
345
+ │ ├── core/ — types, config, logger, constants, global registry
294
346
  │ ├── store/ — LanceDB vector store
295
347
  │ ├── embeddings/ — ONNX local embeddings
296
348
  │ ├── chunker/ — tree-sitter + regex code chunking
@@ -335,6 +387,7 @@ Find relevant code, docs, patterns, and curated knowledge using hybrid (vector +
335
387
  | `origin` | enum | no | — | Filter: `indexed` (from files), `curated` (agent memory), `produced` (auto-generated) |
336
388
  | `category` | string | no | — | Filter by curated category (e.g., `decisions`, `patterns`) |
337
389
  | `tags` | string[] | no | — | Filter by tags (OR matching) |
390
+ | `workspaces` | string[] | no | — | Cross-workspace search: partition names, folder basenames, or `["*"]` for all. Global mode only. |
338
391
  | `min_score` | number (0–1) | no | 0.25 | Minimum similarity score threshold |
339
392
 
340
393
  **Returns**: Ranked results with score, source path, content type, line range, heading path, origin, tags, and full content text. Each response includes a `_Next:` hint suggesting logical follow-up tools.
@@ -1149,6 +1202,6 @@ Every tool response includes a `_Next:` suggestion at the bottom. Follow these h
1149
1202
  - **Workflow Hints**: Every tool response includes `_Next:` suggestions for logical follow-up actions
1150
1203
  - **MCP SDK**: `@modelcontextprotocol/sdk` (stdio + StreamableHTTP transports)
1151
1204
  - **Runtime**: Node.js ≥ 24, TypeScript, ESM, pnpm workspaces
1152
- - **Build**: esbuild with tsc for declarations
1205
+ - **Build**: tsdown with integrated dts generation
1153
1206
  - **Lint**: Biome
1154
1207
  - **Test**: Vitest
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpxa/kb",
3
- "version": "0.1.13",
3
+ "version": "0.1.16",
4
4
  "type": "module",
5
5
  "description": "Local-first AI developer toolkit — knowledge base, code analysis, context management, and developer tools for LLM agents",
6
6
  "license": "MIT",
@@ -23,6 +23,9 @@
23
23
  "bin/",
24
24
  "packages/*/dist/**/*.js",
25
25
  "packages/*/dist/**/*.d.ts",
26
+ "packages/chunker/wasm/*.wasm",
27
+ "packages/chunker/src/queries/**/*.scm",
28
+ "scaffold/",
26
29
  "skills/",
27
30
  "README.md",
28
31
  "LICENSE"
@@ -31,7 +34,8 @@
31
34
  ".": "./packages/core/dist/index.js",
32
35
  "./tools": "./packages/tools/dist/index.js",
33
36
  "./store": "./packages/store/dist/index.js",
34
- "./embeddings": "./packages/embeddings/dist/index.js"
37
+ "./embeddings": "./packages/embeddings/dist/index.js",
38
+ "./enterprise-bridge": "./packages/enterprise-bridge/dist/index.js"
35
39
  },
36
40
  "types": "./packages/core/dist/index.d.ts",
37
41
  "bin": {
@@ -45,17 +49,20 @@
45
49
  "linkedom": "^0.x",
46
50
  "minimatch": "^10.x",
47
51
  "sql.js": "^1.x",
52
+ "tree-sitter-wasms": "^0.x",
48
53
  "turndown": "^7.x",
54
+ "web-tree-sitter": "^0.x",
49
55
  "zod": "^4.x"
50
56
  },
51
57
  "devDependencies": {
52
58
  "@biomejs/biome": "^2.x",
53
59
  "@types/node": "^24.x",
54
- "esbuild": "^0.x",
55
- "glob": "^13.x",
56
60
  "rimraf": "^6.x",
57
- "typescript": "^5.x",
58
- "vitest": "^4.x"
61
+ "tsdown": "^0.x",
62
+ "turbo": "^2.x",
63
+ "typescript": "^6.x",
64
+ "vitest": "^4.x",
65
+ "ws": "^8.20.0"
59
66
  },
60
67
  "engines": {
61
68
  "node": ">=24"
@@ -63,7 +70,7 @@
63
70
  "scripts": {
64
71
  "build": "node scripts/build.mjs",
65
72
  "typecheck": "tsc -b tsconfig.build.json --emitDeclarationOnly",
66
- "clean": "rimraf --glob packages/*/dist packages/*/*.tsbuildinfo",
73
+ "clean": "turbo run clean && rimraf --glob node_modules \"packages/*/node_modules\"",
67
74
  "lint": "biome check .",
68
75
  "lint:fix": "biome check --write .",
69
76
  "format": "biome format --write .",
@@ -1,23 +1,19 @@
1
- /**
2
- * Blast-radius analyzer.
3
- *
4
- * Given a set of changed files, traces the dependency graph to find all
5
- * affected files (direct + transitive importers) and their associated tests.
6
- * Returns a minimal review context optimized for token efficiency.
7
- */
8
- import type { AnalysisResult } from './types.js';
9
- export interface BlastRadiusOptions {
10
- /** Changed file paths (relative to root) */
11
- files: string[];
12
- /** Maximum depth of transitive dependency traversal (default: 5) */
13
- maxDepth?: number;
14
- /** Output format */
15
- format?: 'json' | 'markdown';
1
+ import { AnalysisResult } from "./types.js";
2
+
3
+ //#region packages/analyzers/src/blast-radius-analyzer.d.ts
4
+ interface BlastRadiusOptions {
5
+ /** Changed file paths (relative to root) */
6
+ files: string[];
7
+ /** Maximum depth of transitive dependency traversal (default: 5) */
8
+ maxDepth?: number;
9
+ /** Output format */
10
+ format?: 'json' | 'markdown';
16
11
  }
17
- export declare class BlastRadiusAnalyzer {
18
- readonly name = "blast-radius";
19
- private depAnalyzer;
20
- analyze(rootPath: string, options: BlastRadiusOptions): Promise<AnalysisResult>;
21
- private formatMarkdown;
12
+ declare class BlastRadiusAnalyzer {
13
+ readonly name = "blast-radius";
14
+ private depAnalyzer;
15
+ analyze(rootPath: string, options: BlastRadiusOptions): Promise<AnalysisResult>;
16
+ private formatMarkdown;
22
17
  }
23
- //# sourceMappingURL=blast-radius-analyzer.d.ts.map
18
+ //#endregion
19
+ export { BlastRadiusAnalyzer, BlastRadiusOptions };
@@ -1,13 +1,6 @@
1
- import{DependencyAnalyzer as A}from"./dependency-analyzer.js";class j{name="blast-radius";depAnalyzer=new A;async analyze(d,n){const{files:c,maxDepth:t=5,format:f="markdown"}=n,p=Date.now(),o=(await this.depAnalyzer.analyze(d,{format:"json"})).data,e=o.reverseGraph??{},y=o.testCoverage??{},a=new Map,g=[];for(const s of c){a.set(s,{path:s,reason:"changed",depth:0});const i=s.replace(/\.[jt]sx?$/,"");g.push({path:i,depth:0})}for(;g.length>0;){const s=g.shift();if(!s)break;const{path:i,depth:h}=s;if(h>=t)continue;const l=e[i]??[];for(const m of l){if(a.has(m))continue;const v=h===0?"direct-importer":"transitive-importer";a.set(m,{path:m,reason:v,depth:h+1});const w=m.replace(/\.[jt]sx?$/,"");g.push({path:w,depth:h+1})}}const $=new Set;for(const[s]of a){const i=s.replace(/\.[jt]sx?$/,""),h=y[i]??[];for(const l of h)a.has(l)||($.add(l),a.set(l,{path:l,reason:"test",depth:999}))}const u=[...a.values()].sort((s,i)=>s.depth-i.depth);return{output:f==="json"?JSON.stringify({changedFiles:c,affected:u},null,2):this.formatMarkdown(c,u,e),data:{changedFiles:c,affected:u},meta:{analyzedAt:new Date().toISOString(),scope:d,fileCount:u.length,durationMs:Date.now()-p}}}formatMarkdown(d,n,c){const t=[];t.push(`## Blast Radius Analysis
2
- `),t.push(`**Changed files:** ${d.length}`),t.push(`**Total affected:** ${n.length}
3
- `);const f=n.filter(e=>e.reason==="changed");if(f.length>0){t.push(`### Changed Files
4
- `);for(const e of f)t.push(`- \`${e.path}\``)}const p=n.filter(e=>e.reason==="direct-importer");if(p.length>0){t.push(`
5
- ### Direct Importers (${p.length} files)
6
- `);for(const e of p)t.push(`- \`${e.path}\``)}const r=n.filter(e=>e.reason==="transitive-importer");if(r.length>0){t.push(`
7
- ### Transitive Importers (${r.length} files)
8
- `);for(const e of r.slice(0,20))t.push(`- \`${e.path}\` (depth ${e.depth})`);r.length>20&&t.push(`- ... and ${r.length-20} more`)}const o=n.filter(e=>e.reason==="test");if(o.length>0){t.push(`
9
- ### Affected Tests (${o.length} files)
10
- `);for(const e of o)t.push(`- \`${e.path}\``)}return t.push(`
1
+ import{DependencyAnalyzer as e}from"./dependency-analyzer.js";var t=class{name=`blast-radius`;depAnalyzer=new e;async analyze(e,t){let{files:n,maxDepth:r=5,format:i=`markdown`}=t,a=Date.now(),o=(await this.depAnalyzer.analyze(e,{format:`json`})).data,s=o.reverseGraph??{},c=o.testCoverage??{},l=new Map,u=[];for(let e of n){l.set(e,{path:e,reason:`changed`,depth:0});let t=e.replace(/\.[jt]sx?$/,``);u.push({path:t,depth:0})}for(;u.length>0;){let e=u.shift();if(!e)break;let{path:t,depth:n}=e;if(n>=r)continue;let i=s[t]??[];for(let e of i){if(l.has(e))continue;let t=n===0?`direct-importer`:`transitive-importer`;l.set(e,{path:e,reason:t,depth:n+1});let r=e.replace(/\.[jt]sx?$/,``);u.push({path:r,depth:n+1})}}let d=new Set;for(let[e]of l){let t=c[e.replace(/\.[jt]sx?$/,``)]??[];for(let e of t)l.has(e)||(d.add(e),l.set(e,{path:e,reason:`test`,depth:999}))}let f=[...l.values()].sort((e,t)=>e.depth-t.depth);return{output:i===`json`?JSON.stringify({changedFiles:n,affected:f},null,2):this.formatMarkdown(n,f,s),data:{changedFiles:n,affected:f},meta:{analyzedAt:new Date().toISOString(),scope:e,fileCount:f.length,durationMs:Date.now()-a}}}formatMarkdown(e,t,n){let r=[];r.push(`## Blast Radius Analysis
2
+ `),r.push(`**Changed files:** ${e.length}`),r.push(`**Total affected:** ${t.length}\n`);let i=t.filter(e=>e.reason===`changed`);if(i.length>0){r.push(`### Changed Files
3
+ `);for(let e of i)r.push(`- \`${e.path}\``)}let a=t.filter(e=>e.reason===`direct-importer`);if(a.length>0){r.push(`\n### Direct Importers (${a.length} files)\n`);for(let e of a)r.push(`- \`${e.path}\``)}let o=t.filter(e=>e.reason===`transitive-importer`);if(o.length>0){r.push(`\n### Transitive Importers (${o.length} files)\n`);for(let e of o.slice(0,20))r.push(`- \`${e.path}\` (depth ${e.depth})`);o.length>20&&r.push(`- ... and ${o.length-20} more`)}let s=t.filter(e=>e.reason===`test`);if(s.length>0){r.push(`\n### Affected Tests (${s.length} files)\n`);for(let e of s)r.push(`- \`${e.path}\``)}return r.push(`
11
4
  ### Review Summary
12
- `),t.push("| Category | Count |"),t.push("|----------|-------|"),t.push(`| Changed | ${f.length} |`),t.push(`| Direct importers | ${p.length} |`),t.push(`| Transitive importers | ${r.length} |`),t.push(`| Affected tests | ${o.length} |`),t.push(`| **Total review scope** | **${n.length}** |`),t.join(`
13
- `)}}export{j as BlastRadiusAnalyzer};
5
+ `),r.push(`| Category | Count |`),r.push(`|----------|-------|`),r.push(`| Changed | ${i.length} |`),r.push(`| Direct importers | ${a.length} |`),r.push(`| Transitive importers | ${o.length} |`),r.push(`| Affected tests | ${s.length} |`),r.push(`| **Total review scope** | **${t.length}** |`),r.join(`
6
+ `)}};export{t as BlastRadiusAnalyzer};
@@ -1,29 +1,32 @@
1
- import type { AnalysisResult, DependencyAnalyzerOptions, IAnalyzer, ImportInfo } from './types.js';
2
- export declare class DependencyAnalyzer implements IAnalyzer<DependencyAnalyzerOptions> {
3
- readonly name = "dependencies";
4
- /** Map of workspace package names to their relative entry point paths */
5
- private workspacePackages;
6
- analyze(rootPath: string, options?: DependencyAnalyzerOptions): Promise<AnalysisResult>;
7
- private collectFiles;
8
- private extractImports;
9
- private groupExternalDeps;
10
- private groupInternalDeps;
11
- /**
12
- * Build reverse graph: for each source file, who imports it?
13
- */
14
- buildReverseGraph(imports: ImportInfo[], _rootPath: string): Record<string, string[]>;
15
- /**
16
- * Build test coverage map: for each source file, which test files exercise it?
17
- */
18
- buildTestCoverage(imports: ImportInfo[], _rootPath: string): Record<string, string[]>;
19
- /** Resolve a relative import path to a normalized file path (best-effort). */
20
- private resolveImportPath;
21
- /**
22
- * Build a map of workspace package names → relative entry point paths.
23
- * Scans for package.json files in common workspace dirs.
24
- */
25
- private buildWorkspaceMap;
26
- private formatMarkdown;
27
- private formatMermaid;
1
+ import { AnalysisResult, DependencyAnalyzerOptions, IAnalyzer, ImportInfo } from "./types.js";
2
+
3
+ //#region packages/analyzers/src/dependency-analyzer.d.ts
4
+ declare class DependencyAnalyzer implements IAnalyzer<DependencyAnalyzerOptions> {
5
+ readonly name = "dependencies";
6
+ /** Map of workspace package names to their relative entry point paths */
7
+ private workspacePackages;
8
+ analyze(rootPath: string, options?: DependencyAnalyzerOptions): Promise<AnalysisResult>;
9
+ private collectFiles;
10
+ private extractImportsRegex;
11
+ private groupExternalDeps;
12
+ private groupInternalDeps;
13
+ /**
14
+ * Build reverse graph: for each source file, who imports it?
15
+ */
16
+ buildReverseGraph(imports: ImportInfo[], _rootPath: string): Record<string, string[]>;
17
+ /**
18
+ * Build test coverage map: for each source file, which test files exercise it?
19
+ */
20
+ buildTestCoverage(imports: ImportInfo[], _rootPath: string): Record<string, string[]>;
21
+ /** Resolve a relative import path to a normalized file path (best-effort). */
22
+ private resolveImportPath;
23
+ /**
24
+ * Build a map of workspace package names → relative entry point paths.
25
+ * Scans for package.json files in common workspace dirs.
26
+ */
27
+ private buildWorkspaceMap;
28
+ private formatMarkdown;
29
+ private formatMermaid;
28
30
  }
29
- //# sourceMappingURL=dependency-analyzer.d.ts.map
31
+ //#endregion
32
+ export { DependencyAnalyzer };
@@ -1,11 +1,8 @@
1
- import{readdir as w,readFile as j}from"node:fs/promises";import{dirname as x,extname as m,join as u,relative as v,resolve as R}from"node:path";const $=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".java",".go",".cs",".kt",".scala",".rb",".rs",".php",".swift"]),P=[{regex:/import\s+(?:(?:type\s+)?(?:(?:\{[^}]*\}|[\w*]+)\s+from\s+)?)['"]([^'"]+)['"]/g,confidence:"high"},{regex:/import\(\s*['"]([^'"]+)['"]\s*\)/g,confidence:"medium"},{regex:/require\(\s*['"]([^'"]+)['"]\s*\)/g,confidence:"medium"},{regex:/^from\s+([\w.]+)\s+import\b/gm,confidence:"high",lang:"python"},{regex:/^import\s+([\w.]+)\s*$/gm,confidence:"high",lang:"python"},{regex:/^import\s+(?:static\s+)?([\w.]+(?:\.\*)?)\s*;/gm,confidence:"high",lang:"java"},{regex:/(?:^import\s+|^\s+)[""]([^""]+)[""]/gm,confidence:"high",lang:"go"},{regex:/^using\s+(?:static\s+)?([\w.]+)\s*;/gm,confidence:"high",lang:"csharp"},{regex:/^use\s+([\w:]+(?:::\w+)*)/gm,confidence:"high",lang:"rust"},{regex:/^use\s+([\w\\]+)\s*;/gm,confidence:"high",lang:"php"},{regex:/require(?:_relative)?\s+['"]([^'"]+)['"]/g,confidence:"medium",lang:"ruby"},{regex:/^import\s+(\w+)\s*$/gm,confidence:"high",lang:"swift"}],I=new Set(["node_modules",".git","dist","build","coverage",".turbo",".cache","cdk.out"]),E=[/\.(test|spec)\.[jt]sx?$/,/\/__tests__\//,/\/test\//,/\/tests\//],b={".ts":"js",".tsx":"js",".js":"js",".jsx":"js",".mjs":"js",".cjs":"js",".py":"python",".java":"java",".kt":"java",".scala":"java",".go":"go",".cs":"csharp",".rs":"rust",".php":"php",".rb":"ruby",".swift":"swift"};function S(a,n){return!n||n==="js"?!a.startsWith(".")&&!a.startsWith("/"):n==="python"?!a.startsWith("."):n==="java"?!a.startsWith("com.")||a.startsWith("com.amazonaws")||a.startsWith("com.google")||a.startsWith("com.fasterxml"):n==="go"?a.includes(".")&&!a.startsWith("."):n==="csharp"?a.startsWith("System")||a.startsWith("Microsoft")||a.startsWith("Newtonsoft")||a.startsWith("Amazon"):n==="rust"?!a.startsWith("crate::")&&!a.startsWith("self::")&&!a.startsWith("super::"):!0}function y(a){return E.some(n=>n.test(a))}class W{name="dependencies";workspacePackages=new Map;async analyze(n,o={}){const{format:i="markdown"}=o,t=Date.now();this.workspacePackages=await this.buildWorkspaceMap(n);const e=await this.collectFiles(n),r=[];for(const d of e){const f=await j(d,"utf-8"),h=this.extractImports(f,d,n);r.push(...h)}const s=this.groupExternalDeps(r),c=this.groupInternalDeps(r,n),g=this.buildReverseGraph(r,n),l=this.buildTestCoverage(r,n);return{output:i==="json"?JSON.stringify({external:s,internal:c,reverseGraph:g,testCoverage:l},null,2):i==="mermaid"?this.formatMermaid(c):this.formatMarkdown(s,c,n,l),data:{external:s,internal:c,reverseGraph:g,testCoverage:l,totalImports:r.length},meta:{analyzedAt:new Date().toISOString(),scope:n,fileCount:e.length,durationMs:Date.now()-t}}}async collectFiles(n){const o=[],i=async t=>{const e=await w(t,{withFileTypes:!0});for(const r of e){if(I.has(r.name)||r.name.startsWith("."))continue;const s=u(t,r.name);r.isDirectory()?await i(s):$.has(m(r.name))&&o.push(s)}};return await i(n),o}extractImports(n,o,i){const t=[],e=m(o).toLowerCase(),r=b[e];for(const s of P){if(s.lang&&s.lang!==r||!s.lang&&r&&r!=="js")continue;const c=new RegExp(s.regex.source,s.regex.flags);let g;for(;(g=c.exec(n))!==null;){const l=g[1],p=S(l,r);t.push({source:l,specifiers:[],filePath:v(i,o).replace(/\\/g,"/"),isExternal:p,confidence:s.confidence})}}return t}groupExternalDeps(n){const o={};for(const t of n){if(!t.isExternal)continue;const e=m(t.filePath).toLowerCase(),r=b[e];let s;if(r==="java"){const c=t.source.split(".");for(;c.length>1;){const g=c[c.length-1];if(g==="*"||/^[A-Z]/.test(g))c.pop();else break}c.length>=2?s=c.slice(0,2).join("."):s=c.join(".")}else if(r==="python")s=t.source.split(".")[0];else if(r==="go")s=t.source;else if(r==="csharp"){const c=t.source.split(".");s=c.length>=2?c.slice(0,2).join("."):t.source}else s=t.source.startsWith("@")?t.source.split("/").slice(0,2).join("/"):t.source.split("/")[0];o[s]||(o[s]={count:0,confidence:t.confidence,usedBy:new Set}),o[s].count++,o[s].usedBy.add(t.filePath),t.confidence==="high"?o[s].confidence="high":t.confidence==="medium"&&o[s].confidence==="low"&&(o[s].confidence="medium")}const i={};for(const[t,e]of Object.entries(o))i[t]={count:e.count,confidence:e.confidence,usedBy:[...e.usedBy]};return i}groupInternalDeps(n,o){const i={};for(const e of n)e.isExternal||(i[e.filePath]||(i[e.filePath]=new Set),i[e.filePath].add(e.source));const t={};for(const[e,r]of Object.entries(i))t[e]=[...r];return t}buildReverseGraph(n,o){const i={};for(const e of n){const r=x(e.filePath),s=this.resolveImportPath(e.source,r);s&&(i[s]||(i[s]=new Set),i[s].add(e.filePath))}const t={};for(const[e,r]of Object.entries(i))t[e]=[...r];return t}buildTestCoverage(n,o){const i={};for(const e of n){if(!y(e.filePath))continue;const r=x(e.filePath),s=this.resolveImportPath(e.source,r);!s||y(s)||(i[s]||(i[s]=new Set),i[s].add(e.filePath))}const t={};for(const[e,r]of Object.entries(i))t[e]=[...r];return t}resolveImportPath(n,o){if(n.startsWith("."))return u(o,n).replace(/\\/g,"/").replace(/\.[jt]sx?$/,"");const i=n.startsWith("@")?n.split("/").slice(0,2).join("/"):n.split("/")[0],t=this.workspacePackages.get(i);return t?t.replace(/\.[jt]sx?$/,""):null}async buildWorkspaceMap(n){const o=new Map,i=["packages","functions","libs","apps","cdk"];for(const t of i){const e=u(n,t);try{const r=await w(e,{withFileTypes:!0});for(const s of r)if(!(!s.isDirectory()||I.has(s.name)))try{const c=u(e,s.name,"package.json"),g=JSON.parse(await j(c,"utf-8"));if(g.name){const l=g.main??g.exports?.["."]??"src/index.ts",p=v(n,R(e,s.name,l)).replace(/\\/g,"/");o.set(g.name,p)}}catch{}}catch{}}return o}formatMarkdown(n,o,i,t){const e=[];e.push(`## Dependencies: ${i}
2
- `);const r=Object.entries(n).sort((l,p)=>p[1].count-l[1].count),s=r.length,c=r.reduce((l,[,p])=>l+p.count,0),g=r.slice(0,5).map(([l])=>l);e.push(`**${s} external packages**, **${c} total imports**, **${Object.keys(o).length} files** with internal imports.
3
- `),g.length>0&&e.push(`**Top dependencies**: ${g.join(", ")}
4
- `),e.push(`### External Dependencies
5
- `),e.push("| Package | Imports | Used By |"),e.push("|---------|---------|---------|");for(const[l,p]of r)e.push(`| ${l} | ${p.count} | ${p.usedBy.length} ${p.usedBy.length===1?"file":"files"} |`);if(t&&Object.keys(t).length>0){const l=Object.keys(t).length,p=Object.keys(o).filter(f=>!y(f)&&!t[f.replace(/\\.[jt]sx?$/,"")]);e.push(`
1
+ import{readFile as e,readdir as t}from"node:fs/promises";import{dirname as n,extname as r,join as i,relative as a,resolve as o}from"node:path";import{SUPPORTED_EXTENSIONS as s,WasmRuntime as c,extractImports as l}from"../../chunker/dist/index.js";const u=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.py`,`.java`,`.go`,`.cs`,`.kt`,`.scala`,`.rb`,`.rs`,`.php`,`.swift`]),d=[{regex:/import\s+(?:(?:type\s+)?(?:(?:\{[^}]*\}|[\w*]+)\s+from\s+)?)['"]([^'"]+)['"]/g,confidence:`high`},{regex:/import\(\s*['"]([^'"]+)['"]\s*\)/g,confidence:`medium`},{regex:/require\(\s*['"]([^'"]+)['"]\s*\)/g,confidence:`medium`},{regex:/^from\s+([\w.]+)\s+import\b/gm,confidence:`high`,lang:`python`},{regex:/^import\s+([\w.]+)\s*$/gm,confidence:`high`,lang:`python`},{regex:/^import\s+(?:static\s+)?([\w.]+(?:\.\*)?)\s*;/gm,confidence:`high`,lang:`java`},{regex:/(?:^import\s+|^\s+)[""]([^""]+)[""]/gm,confidence:`high`,lang:`go`},{regex:/^using\s+(?:static\s+)?([\w.]+)\s*;/gm,confidence:`high`,lang:`csharp`},{regex:/^use\s+([\w:]+(?:::\w+)*)/gm,confidence:`high`,lang:`rust`},{regex:/^use\s+([\w\\]+)\s*;/gm,confidence:`high`,lang:`php`},{regex:/require(?:_relative)?\s+['"]([^'"]+)['"]/g,confidence:`medium`,lang:`ruby`},{regex:/^import\s+(\w+)\s*$/gm,confidence:`high`,lang:`swift`}],f=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`]),p=[/\.(test|spec)\.[jt]sx?$/,/\/__tests__\//,/\/test\//,/\/tests\//],m={".ts":`js`,".tsx":`js`,".js":`js`,".jsx":`js`,".mjs":`js`,".cjs":`js`,".py":`python`,".java":`java`,".kt":`java`,".scala":`java`,".go":`go`,".cs":`csharp`,".rs":`rust`,".php":`php`,".rb":`ruby`,".swift":`swift`};function h(e,t){return!t||t===`js`?!e.startsWith(`.`)&&!e.startsWith(`/`):t===`python`?!e.startsWith(`.`):t===`java`?!e.startsWith(`com.`)||e.startsWith(`com.amazonaws`)||e.startsWith(`com.google`)||e.startsWith(`com.fasterxml`):t===`go`?e.includes(`.`)&&!e.startsWith(`.`):t===`csharp`?e.startsWith(`System`)||e.startsWith(`Microsoft`)||e.startsWith(`Newtonsoft`)||e.startsWith(`Amazon`):t===`rust`?!e.startsWith(`crate::`)&&!e.startsWith(`self::`)&&!e.startsWith(`super::`):!0}function g(e){return p.some(t=>t.test(e))}var _=class{name=`dependencies`;workspacePackages=new Map;async analyze(t,n={}){let{format:i=`markdown`}=n,o=Date.now();this.workspacePackages=await this.buildWorkspaceMap(t);let u=!1;try{await c.ensure(),u=!0}catch{}let d=await this.collectFiles(t),f=[];for(let n of d){let i=await e(n,`utf-8`),o=r(n).toLowerCase(),c=a(t,n).replace(/\\/g,`/`);if(u&&s.has(o)){let e=await l(i,o,c);if(e.length>0)f.push(...e);else{let e=this.extractImportsRegex(i,n,t);f.push(...e)}}else{let e=this.extractImportsRegex(i,n,t);f.push(...e)}}let p=this.groupExternalDeps(f),m=this.groupInternalDeps(f,t),h=this.buildReverseGraph(f,t),g=this.buildTestCoverage(f,t);return{output:i===`json`?JSON.stringify({external:p,internal:m,reverseGraph:h,testCoverage:g},null,2):i===`mermaid`?this.formatMermaid(m):this.formatMarkdown(p,m,t,g),data:{external:p,internal:m,reverseGraph:h,testCoverage:g,totalImports:f.length},meta:{analyzedAt:new Date().toISOString(),scope:t,fileCount:d.length,durationMs:Date.now()-o}}}async collectFiles(e){let n=[],a=async e=>{let o=await t(e,{withFileTypes:!0});for(let t of o){if(f.has(t.name)||t.name.startsWith(`.`))continue;let o=i(e,t.name);t.isDirectory()?await a(o):u.has(r(t.name))&&n.push(o)}};return await a(e),n}extractImportsRegex(e,t,n){let i=[],o=m[r(t).toLowerCase()];for(let r of d){if(r.lang&&r.lang!==o||!r.lang&&o&&o!==`js`)continue;let s=new RegExp(r.regex.source,r.regex.flags),c;for(;(c=s.exec(e))!==null;){let e=c[1],s=h(e,o);i.push({source:e,specifiers:[],filePath:a(n,t).replace(/\\/g,`/`),isExternal:s,confidence:r.confidence})}}return i}groupExternalDeps(e){let t={};for(let n of e){if(!n.isExternal)continue;let e=m[r(n.filePath).toLowerCase()],i;if(e===`java`){let e=n.source.split(`.`);for(;e.length>1;){let t=e[e.length-1];if(t===`*`||/^[A-Z]/.test(t))e.pop();else break}i=e.length>=2?e.slice(0,2).join(`.`):e.join(`.`)}else if(e===`python`)i=n.source.split(`.`)[0];else if(e===`go`)i=n.source;else if(e===`csharp`){let e=n.source.split(`.`);i=e.length>=2?e.slice(0,2).join(`.`):n.source}else i=n.source.startsWith(`@`)?n.source.split(`/`).slice(0,2).join(`/`):n.source.split(`/`)[0];t[i]||(t[i]={count:0,confidence:n.confidence,usedBy:new Set}),t[i].count++,t[i].usedBy.add(n.filePath),n.confidence===`high`?t[i].confidence=`high`:n.confidence===`medium`&&t[i].confidence===`low`&&(t[i].confidence=`medium`)}let n={};for(let[e,r]of Object.entries(t))n[e]={count:r.count,confidence:r.confidence,usedBy:[...r.usedBy]};return n}groupInternalDeps(e,t){let n={};for(let t of e)t.isExternal||(n[t.filePath]||(n[t.filePath]=new Set),n[t.filePath].add(t.source));let r={};for(let[e,t]of Object.entries(n))r[e]=[...t];return r}buildReverseGraph(e,t){let r={};for(let t of e){let e=n(t.filePath),i=this.resolveImportPath(t.source,e);i&&(r[i]||(r[i]=new Set),r[i].add(t.filePath))}let i={};for(let[e,t]of Object.entries(r))i[e]=[...t];return i}buildTestCoverage(e,t){let r={};for(let t of e){if(!g(t.filePath))continue;let e=n(t.filePath),i=this.resolveImportPath(t.source,e);!i||g(i)||(r[i]||(r[i]=new Set),r[i].add(t.filePath))}let i={};for(let[e,t]of Object.entries(r))i[e]=[...t];return i}resolveImportPath(e,t){if(e.startsWith(`.`))return i(t,e).replace(/\\/g,`/`).replace(/\.[jt]sx?$/,``);let n=e.startsWith(`@`)?e.split(`/`).slice(0,2).join(`/`):e.split(`/`)[0],r=this.workspacePackages.get(n);return r?r.replace(/\.[jt]sx?$/,``):null}async buildWorkspaceMap(n){let r=new Map;for(let s of[`packages`,`functions`,`libs`,`apps`,`cdk`]){let c=i(n,s);try{let s=await t(c,{withFileTypes:!0});for(let t of s)if(!(!t.isDirectory()||f.has(t.name)))try{let s=i(c,t.name,`package.json`),l=JSON.parse(await e(s,`utf-8`));if(l.name){let e=l.main??l.exports?.[`.`]??`src/index.ts`,i=a(n,o(c,t.name,e)).replace(/\\/g,`/`);r.set(l.name,i)}}catch{}}catch{}}return r}formatMarkdown(e,t,n,r){let i=[];i.push(`## Dependencies: ${n}\n`);let a=Object.entries(e).sort((e,t)=>t[1].count-e[1].count),o=a.length,s=a.reduce((e,[,t])=>e+t.count,0),c=a.slice(0,5).map(([e])=>e);i.push(`**${o} external packages**, **${s} total imports**, **${Object.keys(t).length} files** with internal imports.\n`),c.length>0&&i.push(`**Top dependencies**: ${c.join(`, `)}\n`),i.push(`### External Dependencies
2
+ `),i.push(`| Package | Imports | Used By |`),i.push(`|---------|---------|---------|`);for(let[e,t]of a)i.push(`| ${e} | ${t.count} | ${t.usedBy.length} ${t.usedBy.length===1?`file`:`files`} |`);if(r&&Object.keys(r).length>0){let e=Object.keys(r).length,n=Object.keys(t).filter(e=>!g(e)&&!r[e.replace(/\\.[jt]sx?$/,``)]);i.push(`
6
3
  ### Test Coverage Summary
7
- `),e.push(`**${l} source modules** with test coverage.`),p.length>0&&e.push(`**${p.length} source files** with no detected test coverage.`);const d=Object.entries(t).sort((f,h)=>h[1].length-f[1].length);e.push(`
4
+ `),i.push(`**${e} source modules** with test coverage.`),n.length>0&&i.push(`**${n.length} source files** with no detected test coverage.`);let a=Object.entries(r).sort((e,t)=>t[1].length-e[1].length);i.push(`
8
5
  **Most-tested modules:**
9
- `);for(const[f,h]of d.slice(0,10)){const k=f.replace(/\/dist\/[^/]*$/,"/src/index").replace(/\.mjs$/,".ts");e.push(`- ${k} (${h.length} ${h.length===1?"test":"tests"})`)}}return e.join(`
10
- `)}formatMermaid(n){const o=["graph LR"],i=t=>t.replace(/[^a-zA-Z0-9]/g,"_");for(const[t,e]of Object.entries(n).slice(0,40)){const r=i(t);for(const s of e){const c=i(s);o.push(` ${r}["${t}"] --> ${c}["${s}"]`)}}return o.join(`
11
- `)}}export{W as DependencyAnalyzer};
6
+ `);for(let[e,t]of a.slice(0,10)){let n=e.replace(/\/dist\/[^/]*$/,`/src/index`).replace(/\.mjs$/,`.ts`);i.push(`- ${n} (${t.length} ${t.length===1?`test`:`tests`})`)}}return i.join(`
7
+ `)}formatMermaid(e){let t=[`graph LR`],n=e=>e.replace(/[^a-zA-Z0-9]/g,`_`);for(let[r,i]of Object.entries(e).slice(0,40)){let e=n(r);for(let a of i){let i=n(a);t.push(` ${e}["${r}"] --> ${i}["${a}"]`)}}return t.join(`
8
+ `)}};export{_ as DependencyAnalyzer};
@@ -1,13 +1,16 @@
1
- import type { AnalysisResult, DiagramOptions, IAnalyzer } from './types.js';
1
+ import { AnalysisResult, DiagramOptions, IAnalyzer } from "./types.js";
2
+
3
+ //#region packages/analyzers/src/diagram-generator.d.ts
2
4
  /**
3
5
  * Generates Mermaid diagrams by combining output from other analyzers.
4
6
  */
5
- export declare class DiagramGenerator implements IAnalyzer<DiagramOptions> {
6
- readonly name = "diagrams";
7
- private readonly structureAnalyzer;
8
- private readonly dependencyAnalyzer;
9
- analyze(rootPath: string, options?: DiagramOptions): Promise<AnalysisResult>;
10
- private generateArchitectureDiagram;
11
- private generateDependencyDiagram;
7
+ declare class DiagramGenerator implements IAnalyzer<DiagramOptions> {
8
+ readonly name = "diagrams";
9
+ private readonly structureAnalyzer;
10
+ private readonly dependencyAnalyzer;
11
+ analyze(rootPath: string, options?: DiagramOptions): Promise<AnalysisResult>;
12
+ private generateArchitectureDiagram;
13
+ private generateDependencyDiagram;
12
14
  }
13
- //# sourceMappingURL=diagram-generator.d.ts.map
15
+ //#endregion
16
+ export { DiagramGenerator };
@@ -1,4 +1,2 @@
1
- import{DependencyAnalyzer as u}from"./dependency-analyzer.js";import{StructureAnalyzer as g}from"./structure-analyzer.js";class D{name="diagrams";structureAnalyzer=new g;dependencyAnalyzer=new u;async analyze(r,d={}){const{diagramType:o="architecture"}=d,p=Date.now();let s;return o==="dependencies"?s=await this.generateDependencyDiagram(r):s=await this.generateArchitectureDiagram(r),{output:s,data:{diagramType:o},meta:{analyzedAt:new Date().toISOString(),scope:r,fileCount:0,durationMs:Date.now()-p}}}async generateArchitectureDiagram(r){const o=(await this.structureAnalyzer.analyze(r,{format:"json",maxDepth:4})).data.tree,s=(await this.dependencyAnalyzer.analyze(r,{format:"json"})).data,n=["```mermaid","graph TB"],y=(o.children??[]).filter(t=>t.type==="directory").slice(0,15);for(const t of y){const c=t.name.replace(/[^a-zA-Z0-9]/g,"_"),a=(t.children??[]).filter(e=>e.type==="directory");if(a.length>0){n.push(` subgraph ${c}["${t.name}/"]`);for(const e of a.slice(0,12)){const i=`${c}_${e.name.replace(/[^a-zA-Z0-9]/g,"_")}`,l=Array.isArray(e.children)?e.children.length:0;n.push(` ${i}["${e.name}/ (${l})"]`)}n.push(" end")}else{const e=Array.isArray(t.children)?t.children.length:0;n.push(` ${c}["${t.name}/ (${e} files)"]`)}}const m=new Set;if(s.internal)for(const[t,c]of Object.entries(s.internal)){const a=t.split("/")[0]?.replace(/[^a-zA-Z0-9]/g,"_");for(const e of c){if(e.startsWith("."))continue;const i=e.split("/")[0]?.replace(/[^a-zA-Z0-9]/g,"_");if(a&&i&&a!==i){const l=`${a}->${i}`;m.has(l)||(m.add(l),n.push(` ${a} --> ${i}`))}}}return n.push("```"),n.join(`
2
- `)}async generateDependencyDiagram(r){return`\`\`\`mermaid
3
- ${(await this.dependencyAnalyzer.analyze(r,{format:"mermaid"})).output}
4
- \`\`\``}}export{D as DiagramGenerator};
1
+ import{DependencyAnalyzer as e}from"./dependency-analyzer.js";import{StructureAnalyzer as t}from"./structure-analyzer.js";var n=class{name=`diagrams`;structureAnalyzer=new t;dependencyAnalyzer=new e;async analyze(e,t={}){let{diagramType:n=`architecture`}=t,r=Date.now(),i;switch(n){case`dependencies`:i=await this.generateDependencyDiagram(e);break;default:i=await this.generateArchitectureDiagram(e);break}return{output:i,data:{diagramType:n},meta:{analyzedAt:new Date().toISOString(),scope:e,fileCount:0,durationMs:Date.now()-r}}}async generateArchitectureDiagram(e){let t=(await this.structureAnalyzer.analyze(e,{format:`json`,maxDepth:4})).data.tree,n=(await this.dependencyAnalyzer.analyze(e,{format:`json`})).data,r=["```mermaid",`graph TB`],i=(t.children??[]).filter(e=>e.type===`directory`).slice(0,15);for(let e of i){let t=e.name.replace(/[^a-zA-Z0-9]/g,`_`),n=(e.children??[]).filter(e=>e.type===`directory`);if(n.length>0){r.push(` subgraph ${t}["${e.name}/"]`);for(let e of n.slice(0,12)){let n=`${t}_${e.name.replace(/[^a-zA-Z0-9]/g,`_`)}`,i=Array.isArray(e.children)?e.children.length:0;r.push(` ${n}["${e.name}/ (${i})"]`)}r.push(` end`)}else{let n=Array.isArray(e.children)?e.children.length:0;r.push(` ${t}["${e.name}/ (${n} files)"]`)}}let a=new Set;if(n.internal)for(let[e,t]of Object.entries(n.internal)){let n=e.split(`/`)[0]?.replace(/[^a-zA-Z0-9]/g,`_`);for(let e of t){if(e.startsWith(`.`))continue;let t=e.split(`/`)[0]?.replace(/[^a-zA-Z0-9]/g,`_`);if(n&&t&&n!==t){let e=`${n}->${t}`;a.has(e)||(a.add(e),r.push(` ${n} --> ${t}`))}}}return r.push("```"),r.join(`
2
+ `)}async generateDependencyDiagram(e){return`\`\`\`mermaid\n${(await this.dependencyAnalyzer.analyze(e,{format:`mermaid`})).output}\n\`\`\``}};export{n as DiagramGenerator};
@@ -1,37 +1,40 @@
1
- import type { AnalysisResult, AnalyzerOptions, IAnalyzer } from './types.js';
2
- export declare class EntryPointAnalyzer implements IAnalyzer<AnalyzerOptions> {
3
- readonly name = "entry-points";
4
- analyze(rootPath: string, _options?: AnalyzerOptions): Promise<AnalysisResult>;
5
- private fromPackageJson;
6
- /** Parse package.json `exports` field into entry points. */
7
- private parseExportsField;
8
- /** Resolve export value through condition maps (import > default > first string). */
9
- private resolveExportValue;
10
- /**
11
- * Find all workspace package directories in a monorepo.
12
- * Supports pnpm-workspace.yaml and package.json#workspaces.
13
- */
14
- private findWorkspacePackages;
15
- /** Simple YAML parser for pnpm-workspace.yaml — extracts packages list. */
16
- private parsePnpmWorkspaceYaml;
17
- /**
18
- * Expand a workspace glob like "packages/*" into actual directories
19
- * that contain package.json files.
20
- */
21
- private expandWorkspaceGlob;
22
- private fromHandlerExports;
23
- /** Check if a file is a test suite. */
24
- private isTestFile;
25
- /** Extract a meaningful name from the file path for non-JS entry points */
26
- private inferNameFromFile;
27
- /**
28
- * Derive a contextual name from the directory path for generic handler/main files.
29
- * E.g., "services/channels/email/delivery/src/handler.ts" → "email-delivery"
30
- */
31
- private deriveContextualName;
32
- private inferEntryType;
33
- private detectTrigger;
34
- private collectFiles;
35
- private formatMarkdown;
1
+ import { AnalysisResult, AnalyzerOptions, IAnalyzer } from "./types.js";
2
+
3
+ //#region packages/analyzers/src/entry-point-analyzer.d.ts
4
+ declare class EntryPointAnalyzer implements IAnalyzer<AnalyzerOptions> {
5
+ readonly name = "entry-points";
6
+ analyze(rootPath: string, _options?: AnalyzerOptions): Promise<AnalysisResult>;
7
+ private fromPackageJson;
8
+ /** Parse package.json `exports` field into entry points. */
9
+ private parseExportsField;
10
+ /** Resolve export value through condition maps (import > default > first string). */
11
+ private resolveExportValue;
12
+ /**
13
+ * Find all workspace package directories in a monorepo.
14
+ * Supports pnpm-workspace.yaml and package.json#workspaces.
15
+ */
16
+ private findWorkspacePackages;
17
+ /** Simple YAML parser for pnpm-workspace.yaml — extracts packages list. */
18
+ private parsePnpmWorkspaceYaml;
19
+ /**
20
+ * Expand a workspace glob like "packages/*" into actual directories
21
+ * that contain package.json files.
22
+ */
23
+ private expandWorkspaceGlob;
24
+ private fromHandlerExports;
25
+ /** Check if a file is a test suite. */
26
+ private isTestFile;
27
+ /** Extract a meaningful name from the file path for non-JS entry points */
28
+ private inferNameFromFile;
29
+ /**
30
+ * Derive a contextual name from the directory path for generic handler/main files.
31
+ * E.g., "services/channels/email/delivery/src/handler.ts" → "email-delivery"
32
+ */
33
+ private deriveContextualName;
34
+ private inferEntryType;
35
+ private detectTrigger;
36
+ private collectFiles;
37
+ private formatMarkdown;
36
38
  }
37
- //# sourceMappingURL=entry-point-analyzer.d.ts.map
39
+ //#endregion
40
+ export { EntryPointAnalyzer };
@@ -1,6 +1,4 @@
1
- import{access as f,readdir as h,readFile as u}from"node:fs/promises";import{extname as S,join as p,relative as d,resolve as y}from"node:path";const k=new Set(["node_modules",".git","dist","build","coverage",".turbo",".cache","cdk.out","__pycache__",".venv","target","bin","obj",".gradle","venv","env"]),w=new Set(["test","tests","__tests__","spec","specs","test-utils"]),v=[/export\s+const\s+(handler|main)\s*(?::[^=]*)?\s*=/,/export\s+(?:async\s+)?function\s+(handler|main)\s*\(/,/export\s+const\s+(\w+Handler)\s*(?::[^=]*)?\s*=/,/export\s+default\s+app/,/^app\s*=\s*(?:Flask|FastAPI)\s*\(/m,/^urlpatterns\s*=\s*\[/m,/^if\s+__name__\s*==\s*['"]__main__['"]:/m,/public\s+static\s+void\s+main\s*\(\s*String/,/@SpringBootApplication/,/^func\s+main\s*\(\s*\)/m],P=/export\s+(?:default\s+)?class\s+(\w+)\s+extends\s+(?:Construct|Stack|NestedStack|Stage)/,x=[/from\s+['"]vitest['"]/,/from\s+['"]jest['"]/,/from\s+['"]mocha['"]/,/import\s+.*['"]@jest\/globals['"]/,/require\s*\(\s*['"](?:vitest|jest|mocha)['"]\s*\)/],T=[{regex:/SqsEventSource|SQSEvent|sqs/i,trigger:"SQS"},{regex:/SnsEventSource|SNSEvent|sns/i,trigger:"SNS"},{regex:/ApiGateway|APIGatewayEvent|httpApi|restApi/i,trigger:"API Gateway"},{regex:/ScheduleExpression|EventBridgeRule|schedule/i,trigger:"EventBridge Schedule"},{regex:/S3EventSource|S3Event|s3/i,trigger:"S3"},{regex:/DynamoEventSource|DynamoDBStream/i,trigger:"DynamoDB Stream"},{regex:/@RequestMapping|@GetMapping|@PostMapping/i,trigger:"HTTP Endpoint"},{regex:/http\.ListenAndServe|gin\.Default|echo\.New/i,trigger:"HTTP Server"},{regex:/app\.route\(|@app\.get|@app\.post|@router\./i,trigger:"HTTP Route"}];class ${name="entry-points";async analyze(t,e={}){const s=Date.now(),n=[],i=await this.findWorkspacePackages(t);if(i.length>0)for(const a of i){const c=await this.fromPackageJson(a,t);n.push(...c)}else{const a=await this.fromPackageJson(t,t);n.push(...a)}const r=await this.fromHandlerExports(t);return n.push(...r),{output:this.formatMarkdown(n,t),data:{entryPoints:n,total:n.length},meta:{analyzedAt:new Date().toISOString(),scope:t,fileCount:n.length,durationMs:Date.now()-s}}}async fromPackageJson(t,e){const s=[],n=d(e,t).replace(/\\/g,"/")||".";try{const i=p(t,"package.json");await f(i);const r=JSON.parse(await u(i,"utf-8")),o=n==="."?"":`${n}/`;if(r.main&&s.push({name:r.name?`${r.name}:main`:"main",type:"main",filePath:`${o}${r.main}`}),r.bin){const a=typeof r.bin=="string"?{[r.name??"cli"]:r.bin}:r.bin;for(const[c,g]of Object.entries(a))s.push({name:c,type:"cli",filePath:`${o}${g}`})}if(r.exports){const a=this.parseExportsField(r.exports,r.name??n,o);s.push(...a)}r.scripts?.start&&s.push({name:r.name?`${r.name}:start`:"start",type:"server",filePath:r.scripts.start,trigger:"npm start"})}catch{}return s}parseExportsField(t,e,s){const n=[];if(typeof t=="string")return n.push({name:e,type:"main",filePath:`${s}${t}`}),n;if(typeof t!="object"||t===null)return n;for(const[i,r]of Object.entries(t)){if(!i.startsWith("."))continue;const o=i==="."?e:`${e}/${i.slice(2)}`,a=this.resolveExportValue(r);a&&n.push({name:o,type:"main",filePath:`${s}${a}`})}return n}resolveExportValue(t){if(typeof t=="string")return t;if(typeof t!="object"||t===null)return;const e=t;for(const s of["import","default","require"])if(typeof e[s]=="string")return e[s];for(const s of Object.values(e))if(typeof s=="string")return s}async findWorkspacePackages(t){const e=[];try{const s=p(t,"pnpm-workspace.yaml");await f(s);const n=await u(s,"utf-8"),i=this.parsePnpmWorkspaceYaml(n);for(const r of i){const o=await this.expandWorkspaceGlob(t,r);e.push(...o)}if(e.length>0)return e}catch{}try{const s=p(t,"package.json"),n=JSON.parse(await u(s,"utf-8")),i=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages??[];for(const r of i){const o=await this.expandWorkspaceGlob(t,r);e.push(...o)}}catch{}return e}parsePnpmWorkspaceYaml(t){const e=[];let s=!1;for(const n of t.split(`
2
- `)){const i=n.trim();if(i==="packages:"){s=!0;continue}if(s){if(i.startsWith("- "))e.push(i.slice(2).replace(/^['"]|['"]$/g,""));else if(i&&!i.startsWith("#"))break}}return e}async expandWorkspaceGlob(t,e){const s=[],n=e.indexOf("*");if(n===-1){const r=y(t,e);try{await f(p(r,"package.json")),s.push(r)}catch{}return s}const i=y(t,e.slice(0,n));try{const r=await h(i,{withFileTypes:!0});for(const o of r){if(!o.isDirectory()||k.has(o.name))continue;const a=p(i,o.name);try{await f(p(a,"package.json")),s.push(a)}catch{}}}catch{}return s}async fromHandlerExports(t){const e=[],s=await this.collectFiles(t);for(const n of s)try{const i=await u(n,"utf-8"),r=d(t,n).replace(/\\/g,"/");if(!r.split("/").some(c=>w.has(c))){let c=!1;for(const g of v){const m=i.match(g);if(m){let l=m[1]??this.inferNameFromFile(r);(l==="handler"||l==="main")&&(l=this.deriveContextualName(r)??l);const E=/@SpringBootApplication/.test(i)?"HTTP Server":this.detectTrigger(i);e.push({name:l,type:this.inferEntryType(m[1]??l,r),filePath:r,trigger:E}),c=!0;break}}if(!c){const g=i.match(P);g&&e.push({name:g[1],type:"cdk-construct",filePath:r,trigger:"CDK Construct"})}}this.isTestFile(r,i)&&e.push({name:this.inferNameFromFile(r),type:"test",filePath:r,trigger:"Test Suite"})}catch{}return e}isTestFile(t,e){return/\.(test|spec)\.[jt]sx?$/.test(t)?x.some(s=>s.test(e)):!1}inferNameFromFile(t){return(t.split(/[/\\]/).pop()??"default").replace(/\.\w+$/,"")}deriveContextualName(t){const e=t.split("/").filter(i=>i!=="src"&&i!=="lib");if(e.pop(),e.length===0)return;const s=e.filter(i=>!["services","functions","lambdas","handlers","packages","apps"].includes(i));if(s.length===0)return;const n=s.slice(-2);return n.length===2&&n[1].startsWith(n[0])?n[1]:n.join("-")}inferEntryType(t,e){return t==="handler"||t==="main"||e.includes("handler")||/functions[/]/.test(e)||t.endsWith("Handler")?"lambda-handler":(e.endsWith(".py")||e.endsWith(".go")||e.endsWith(".java"),"main")}detectTrigger(t){for(const e of T)if(e.regex.test(t))return e.trigger}async collectFiles(t){const e=[],s=new Set([".ts",".tsx",".js",".jsx",".java",".py",".go",".cs",".kt",".rb",".rs",".php",".swift"]),n=async(i,r)=>{if(r>10)return;const o=await h(i,{withFileTypes:!0});for(const a of o){if(k.has(a.name)||a.name.startsWith("."))continue;const c=p(i,a.name);a.isDirectory()?await n(c,r+1):s.has(S(a.name))&&e.push(c)}};return await n(t,0),e}formatMarkdown(t,e){const s=[];if(s.push(`## Entry Points: ${e}
3
- `),s.push(`**${t.length} entry ${t.length===1?"point":"points"}** found
4
- `),t.length===0)return s.push("No entry points detected."),s.join(`
5
- `);const n=new Map;for(const o of t){const a=n.get(o.type)??[];a.push(o),n.set(o.type,a)}const i=["lambda-handler","main","server","cli","bin","cdk-construct","test"],r=[...n.entries()].sort((o,a)=>i.indexOf(o[0])-i.indexOf(a[0]));s.push("| Name | Type | File | Trigger |"),s.push("|------|------|------|---------|");for(const[,o]of r)for(const a of o)s.push(`| ${a.name} | ${a.type} | ${a.filePath} | ${a.trigger??"\u2014"} |`);return s.join(`
6
- `)}}export{$ as EntryPointAnalyzer};
1
+ import{access as e,readFile as t,readdir as n}from"node:fs/promises";import{extname as r,join as i,relative as a,resolve as o}from"node:path";import{SUPPORTED_EXTENSIONS as s,WasmRuntime as c,detectEntryPoints as l}from"../../chunker/dist/index.js";const u=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,`__pycache__`,`.venv`,`target`,`bin`,`obj`,`.gradle`,`venv`,`env`]),d=new Set([`test`,`tests`,`__tests__`,`spec`,`specs`,`test-utils`]),f=[/export\s+const\s+(handler|main)\s*(?::[^=]*)?\s*=/,/export\s+(?:async\s+)?function\s+(handler|main)\s*\(/,/export\s+const\s+(\w+Handler)\s*(?::[^=]*)?\s*=/,/export\s+default\s+app/,/^app\s*=\s*(?:Flask|FastAPI)\s*\(/m,/^urlpatterns\s*=\s*\[/m,/^if\s+__name__\s*==\s*['"]__main__['"]:/m,/public\s+static\s+void\s+main\s*\(\s*String/,/@SpringBootApplication/,/^func\s+main\s*\(\s*\)/m],p=/export\s+(?:default\s+)?class\s+(\w+)\s+extends\s+(?:Construct|Stack|NestedStack|Stage)/,m=[/from\s+['"]vitest['"]/,/from\s+['"]jest['"]/,/from\s+['"]mocha['"]/,/import\s+.*['"]@jest\/globals['"]/,/require\s*\(\s*['"](?:vitest|jest|mocha)['"]\s*\)/],h=[{regex:/SqsEventSource|SQSEvent|sqs/i,trigger:`SQS`},{regex:/SnsEventSource|SNSEvent|sns/i,trigger:`SNS`},{regex:/ApiGateway|APIGatewayEvent|httpApi|restApi/i,trigger:`API Gateway`},{regex:/ScheduleExpression|EventBridgeRule|schedule/i,trigger:`EventBridge Schedule`},{regex:/S3EventSource|S3Event|s3/i,trigger:`S3`},{regex:/DynamoEventSource|DynamoDBStream/i,trigger:`DynamoDB Stream`},{regex:/@RequestMapping|@GetMapping|@PostMapping/i,trigger:`HTTP Endpoint`},{regex:/http\.ListenAndServe|gin\.Default|echo\.New/i,trigger:`HTTP Server`},{regex:/app\.route\(|@app\.get|@app\.post|@router\./i,trigger:`HTTP Route`}];var g=class{name=`entry-points`;async analyze(e,t={}){let n=Date.now(),r=[],i=await this.findWorkspacePackages(e);if(i.length>0)for(let t of i){let n=await this.fromPackageJson(t,e);r.push(...n)}else{let t=await this.fromPackageJson(e,e);r.push(...t)}let a=await this.fromHandlerExports(e);return r.push(...a),{output:this.formatMarkdown(r,e),data:{entryPoints:r,total:r.length},meta:{analyzedAt:new Date().toISOString(),scope:e,fileCount:r.length,durationMs:Date.now()-n}}}async fromPackageJson(n,r){let o=[],s=a(r,n).replace(/\\/g,`/`)||`.`;try{let r=i(n,`package.json`);await e(r);let a=JSON.parse(await t(r,`utf-8`)),c=s===`.`?``:`${s}/`;if(a.main&&o.push({name:a.name?`${a.name}:main`:`main`,type:`main`,filePath:`${c}${a.main}`}),a.bin){let e=typeof a.bin==`string`?{[a.name??`cli`]:a.bin}:a.bin;for(let[t,n]of Object.entries(e))o.push({name:t,type:`cli`,filePath:`${c}${n}`})}if(a.exports){let e=this.parseExportsField(a.exports,a.name??s,c);o.push(...e)}a.scripts?.start&&o.push({name:a.name?`${a.name}:start`:`start`,type:`server`,filePath:a.scripts.start,trigger:`npm start`})}catch{}return o}parseExportsField(e,t,n){let r=[];if(typeof e==`string`)return r.push({name:t,type:`main`,filePath:`${n}${e}`}),r;if(typeof e!=`object`||!e)return r;for(let[i,a]of Object.entries(e)){if(!i.startsWith(`.`))continue;let e=i===`.`?t:`${t}/${i.slice(2)}`,o=this.resolveExportValue(a);o&&r.push({name:e,type:`main`,filePath:`${n}${o}`})}return r}resolveExportValue(e){if(typeof e==`string`)return e;if(typeof e!=`object`||!e)return;let t=e;for(let e of[`import`,`default`,`require`])if(typeof t[e]==`string`)return t[e];for(let e of Object.values(t))if(typeof e==`string`)return e}async findWorkspacePackages(n){let r=[];try{let a=i(n,`pnpm-workspace.yaml`);await e(a);let o=await t(a,`utf-8`),s=this.parsePnpmWorkspaceYaml(o);for(let e of s){let t=await this.expandWorkspaceGlob(n,e);r.push(...t)}if(r.length>0)return r}catch{}try{let e=i(n,`package.json`),a=JSON.parse(await t(e,`utf-8`)),o=Array.isArray(a.workspaces)?a.workspaces:a.workspaces?.packages??[];for(let e of o){let t=await this.expandWorkspaceGlob(n,e);r.push(...t)}}catch{}return r}parsePnpmWorkspaceYaml(e){let t=[],n=!1;for(let r of e.split(`
2
+ `)){let e=r.trim();if(e===`packages:`){n=!0;continue}if(n){if(e.startsWith(`- `))t.push(e.slice(2).replace(/^['"]|['"]$/g,``));else if(e&&!e.startsWith(`#`))break}}return t}async expandWorkspaceGlob(t,r){let a=[],s=r.indexOf(`*`);if(s===-1){let n=o(t,r);try{await e(i(n,`package.json`)),a.push(n)}catch{}return a}let c=o(t,r.slice(0,s));try{let t=await n(c,{withFileTypes:!0});for(let n of t){if(!n.isDirectory()||u.has(n.name))continue;let t=i(c,n.name);try{await e(i(t,`package.json`)),a.push(t)}catch{}}}catch{}return a}async fromHandlerExports(e){let n=[],i=await this.collectFiles(e),o=!1;try{await c.ensure(),o=!0}catch{}for(let c of i)try{let i=await t(c,`utf-8`),u=a(e,c).replace(/\\/g,`/`),m=r(c);if(!u.split(`/`).some(e=>d.has(e))){let e=!1;if(o&&s.has(m)){let t=await l(i,m,u);for(let r of t)r.trigger||(r.type===`cdk-construct`?r.trigger=`CDK Construct`:r.trigger=this.detectTrigger(i)),n.push(r),e=!0}if(!e)for(let t of f){let r=i.match(t);if(r){let t=r[1]??this.inferNameFromFile(u);(t===`handler`||t===`main`)&&(t=this.deriveContextualName(u)??t);let a=/@SpringBootApplication/.test(i)?`HTTP Server`:this.detectTrigger(i);n.push({name:t,type:this.inferEntryType(r[1]??t,u),filePath:u,trigger:a}),e=!0;break}}if(!e){let e=i.match(p);e&&n.push({name:e[1],type:`cdk-construct`,filePath:u,trigger:`CDK Construct`})}}this.isTestFile(u,i)&&n.push({name:this.inferNameFromFile(u),type:`test`,filePath:u,trigger:`Test Suite`})}catch{}return n}isTestFile(e,t){return/\.(test|spec)\.[jt]sx?$/.test(e)?m.some(e=>e.test(t)):!1}inferNameFromFile(e){return(e.split(/[/\\]/).pop()??`default`).replace(/\.\w+$/,``)}deriveContextualName(e){let t=e.split(`/`).filter(e=>e!==`src`&&e!==`lib`);if(t.pop(),t.length===0)return;let n=t.filter(e=>![`services`,`functions`,`lambdas`,`handlers`,`packages`,`apps`].includes(e));if(n.length===0)return;let r=n.slice(-2);return r.length===2&&r[1].startsWith(r[0])?r[1]:r.join(`-`)}inferEntryType(e,t){return e===`handler`||e===`main`||t.includes(`handler`)||/functions[/]/.test(t)||e.endsWith(`Handler`)?`lambda-handler`:(t.endsWith(`.py`)||t.endsWith(`.go`)||t.endsWith(`.java`),`main`)}detectTrigger(e){for(let t of h)if(t.regex.test(e))return t.trigger}async collectFiles(e){let t=[],a=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.java`,`.py`,`.go`,`.cs`,`.kt`,`.rb`,`.rs`,`.php`,`.swift`]),o=async(e,s)=>{if(s>10)return;let c=await n(e,{withFileTypes:!0});for(let n of c){if(u.has(n.name)||n.name.startsWith(`.`))continue;let c=i(e,n.name);n.isDirectory()?await o(c,s+1):a.has(r(n.name))&&t.push(c)}};return await o(e,0),t}formatMarkdown(e,t){let n=[];if(n.push(`## Entry Points: ${t}\n`),n.push(`**${e.length} entry ${e.length===1?`point`:`points`}** found\n`),e.length===0)return n.push(`No entry points detected.`),n.join(`
3
+ `);let r=new Map;for(let t of e){let e=r.get(t.type)??[];e.push(t),r.set(t.type,e)}let i=[`lambda-handler`,`main`,`server`,`cli`,`bin`,`cdk-construct`,`test`],a=[...r.entries()].sort((e,t)=>i.indexOf(e[0])-i.indexOf(t[0]));n.push(`| Name | Type | File | Trigger |`),n.push(`|------|------|------|---------|`);for(let[,e]of a)for(let t of e)n.push(`| ${t.name} | ${t.type} | ${t.filePath} | ${t.trigger??`—`} |`);return n.join(`
4
+ `)}};export{g as EntryPointAnalyzer};