@vpxa/kb 0.1.13 → 0.1.15

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 (383) hide show
  1. package/README.md +8 -2
  2. package/package.json +10 -7
  3. package/packages/analyzers/dist/blast-radius-analyzer.d.ts +17 -20
  4. package/packages/analyzers/dist/blast-radius-analyzer.js +6 -12
  5. package/packages/analyzers/dist/dependency-analyzer.d.ts +31 -27
  6. package/packages/analyzers/dist/dependency-analyzer.js +7 -9
  7. package/packages/analyzers/dist/diagram-generator.d.ts +12 -8
  8. package/packages/analyzers/dist/diagram-generator.js +3 -4
  9. package/packages/analyzers/dist/entry-point-analyzer.d.ts +39 -35
  10. package/packages/analyzers/dist/entry-point-analyzer.js +5 -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 +29 -25
  14. package/packages/analyzers/dist/knowledge-producer.js +16 -15
  15. package/packages/analyzers/dist/pattern-analyzer.d.ts +14 -10
  16. package/packages/analyzers/dist/pattern-analyzer.js +3 -5
  17. package/packages/analyzers/dist/regex-call-graph.d.ts +6 -12
  18. package/packages/analyzers/dist/regex-call-graph.js +2 -1
  19. package/packages/analyzers/dist/structure-analyzer.d.ts +13 -9
  20. package/packages/analyzers/dist/structure-analyzer.js +3 -4
  21. package/packages/analyzers/dist/symbol-analyzer.d.ts +12 -8
  22. package/packages/analyzers/dist/symbol-analyzer.js +8 -13
  23. package/packages/analyzers/dist/ts-call-graph.d.ts +16 -13
  24. package/packages/analyzers/dist/ts-call-graph.js +2 -1
  25. package/packages/analyzers/dist/types.d.ts +82 -79
  26. package/packages/analyzers/dist/types.js +1 -0
  27. package/packages/chunker/dist/call-graph-extractor.d.ts +13 -10
  28. package/packages/chunker/dist/call-graph-extractor.js +2 -1
  29. package/packages/chunker/dist/chunker-factory.d.ts +6 -2
  30. package/packages/chunker/dist/chunker-factory.js +2 -1
  31. package/packages/chunker/dist/chunker.interface.d.ts +8 -4
  32. package/packages/chunker/dist/chunker.interface.js +1 -0
  33. package/packages/chunker/dist/code-chunker.d.ts +16 -12
  34. package/packages/chunker/dist/code-chunker.js +12 -14
  35. package/packages/chunker/dist/generic-chunker.d.ts +14 -10
  36. package/packages/chunker/dist/generic-chunker.js +6 -5
  37. package/packages/chunker/dist/index.d.ts +8 -8
  38. package/packages/chunker/dist/index.js +1 -1
  39. package/packages/chunker/dist/markdown-chunker.d.ts +16 -12
  40. package/packages/chunker/dist/markdown-chunker.js +4 -10
  41. package/packages/chunker/dist/treesitter-chunker.d.ts +28 -31
  42. package/packages/chunker/dist/treesitter-chunker.js +7 -8
  43. package/packages/cli/dist/commands/analyze.d.ts +6 -2
  44. package/packages/cli/dist/commands/analyze.js +3 -3
  45. package/packages/cli/dist/commands/context-cmds.d.ts +6 -2
  46. package/packages/cli/dist/commands/context-cmds.js +2 -1
  47. package/packages/cli/dist/commands/environment.d.ts +6 -2
  48. package/packages/cli/dist/commands/environment.js +2 -2
  49. package/packages/cli/dist/commands/execution.d.ts +6 -2
  50. package/packages/cli/dist/commands/execution.js +2 -1
  51. package/packages/cli/dist/commands/graph.d.ts +6 -2
  52. package/packages/cli/dist/commands/graph.js +6 -6
  53. package/packages/cli/dist/commands/init/adapters.d.ts +27 -0
  54. package/packages/cli/dist/commands/init/adapters.js +2 -0
  55. package/packages/cli/dist/commands/init/config.d.ts +11 -0
  56. package/packages/cli/dist/commands/init/config.js +4 -0
  57. package/packages/cli/dist/commands/init/curated.d.ts +8 -0
  58. package/packages/cli/dist/commands/init/curated.js +2 -0
  59. package/packages/cli/dist/commands/init/index.d.ts +23 -0
  60. package/packages/cli/dist/commands/init/index.js +3 -0
  61. package/packages/cli/dist/commands/init/scaffold.d.ts +24 -0
  62. package/packages/cli/dist/commands/init/scaffold.js +2 -0
  63. package/packages/cli/dist/commands/init/templates.d.ts +10 -0
  64. package/packages/cli/dist/commands/init/templates.js +302 -0
  65. package/packages/cli/dist/commands/init.d.ts +8 -3
  66. package/packages/cli/dist/commands/init.js +120 -123
  67. package/packages/cli/dist/commands/knowledge.d.ts +6 -2
  68. package/packages/cli/dist/commands/knowledge.js +2 -1
  69. package/packages/cli/dist/commands/search.d.ts +6 -2
  70. package/packages/cli/dist/commands/search.js +2 -8
  71. package/packages/cli/dist/commands/system.d.ts +6 -2
  72. package/packages/cli/dist/commands/system.js +5 -7
  73. package/packages/cli/dist/commands/workspace.d.ts +6 -2
  74. package/packages/cli/dist/commands/workspace.js +2 -2
  75. package/packages/cli/dist/context.d.ts +7 -4
  76. package/packages/cli/dist/context.js +2 -1
  77. package/packages/cli/dist/helpers.d.ts +51 -47
  78. package/packages/cli/dist/helpers.js +6 -5
  79. package/packages/cli/dist/index.d.ts +4 -1
  80. package/packages/cli/dist/index.js +3 -2
  81. package/packages/cli/dist/kb-init.d.ts +48 -50
  82. package/packages/cli/dist/kb-init.js +2 -1
  83. package/packages/cli/dist/types.d.ts +8 -5
  84. package/packages/cli/dist/types.js +1 -0
  85. package/packages/core/dist/constants.d.ts +36 -33
  86. package/packages/core/dist/constants.js +2 -1
  87. package/packages/core/dist/content-detector.d.ts +8 -7
  88. package/packages/core/dist/content-detector.js +2 -1
  89. package/packages/core/dist/errors.d.ts +15 -12
  90. package/packages/core/dist/errors.js +2 -1
  91. package/packages/core/dist/index.d.ts +6 -6
  92. package/packages/core/dist/index.js +1 -1
  93. package/packages/core/dist/logger.d.ts +16 -7
  94. package/packages/core/dist/logger.js +2 -1
  95. package/packages/core/dist/types.d.ts +107 -91
  96. package/packages/core/dist/types.js +2 -0
  97. package/packages/embeddings/dist/embedder.interface.d.ts +22 -19
  98. package/packages/embeddings/dist/embedder.interface.js +1 -0
  99. package/packages/embeddings/dist/index.d.ts +3 -3
  100. package/packages/embeddings/dist/index.js +1 -1
  101. package/packages/embeddings/dist/onnx-embedder.d.ts +21 -22
  102. package/packages/embeddings/dist/onnx-embedder.js +2 -1
  103. package/packages/enterprise-bridge/dist/cache.d.ts +29 -0
  104. package/packages/enterprise-bridge/dist/cache.js +2 -0
  105. package/packages/enterprise-bridge/dist/er-client.d.ts +38 -0
  106. package/packages/enterprise-bridge/dist/er-client.js +2 -0
  107. package/packages/enterprise-bridge/dist/evolution-collector.d.ts +63 -0
  108. package/packages/enterprise-bridge/dist/evolution-collector.js +2 -0
  109. package/packages/enterprise-bridge/dist/index.d.ts +8 -0
  110. package/packages/enterprise-bridge/dist/index.js +1 -0
  111. package/packages/enterprise-bridge/dist/policy-store.d.ts +46 -0
  112. package/packages/enterprise-bridge/dist/policy-store.js +2 -0
  113. package/packages/enterprise-bridge/dist/push-adapter.d.ts +24 -0
  114. package/packages/enterprise-bridge/dist/push-adapter.js +2 -0
  115. package/packages/enterprise-bridge/dist/result-merger.d.ts +15 -0
  116. package/packages/enterprise-bridge/dist/result-merger.js +2 -0
  117. package/packages/enterprise-bridge/dist/types.d.ts +82 -0
  118. package/packages/enterprise-bridge/dist/types.js +2 -0
  119. package/packages/indexer/dist/file-hasher.d.ts +5 -2
  120. package/packages/indexer/dist/file-hasher.js +2 -1
  121. package/packages/indexer/dist/filesystem-crawler.d.ts +23 -20
  122. package/packages/indexer/dist/filesystem-crawler.js +2 -1
  123. package/packages/indexer/dist/graph-extractor.d.ts +9 -12
  124. package/packages/indexer/dist/graph-extractor.js +2 -1
  125. package/packages/indexer/dist/incremental-indexer.d.ts +49 -43
  126. package/packages/indexer/dist/incremental-indexer.js +2 -1
  127. package/packages/indexer/dist/index.d.ts +5 -5
  128. package/packages/indexer/dist/index.js +1 -1
  129. package/packages/server/dist/api.d.ts +3 -8
  130. package/packages/server/dist/api.js +1 -1
  131. package/packages/server/dist/config.d.ts +6 -2
  132. package/packages/server/dist/config.js +2 -1
  133. package/packages/server/dist/curated-manager.d.ts +79 -76
  134. package/packages/server/dist/curated-manager.js +6 -10
  135. package/packages/server/dist/index.d.ts +1 -2
  136. package/packages/server/dist/index.js +2 -1
  137. package/packages/server/dist/replay-interceptor.d.ts +6 -6
  138. package/packages/server/dist/replay-interceptor.js +2 -1
  139. package/packages/server/dist/resources/resources.d.ts +7 -3
  140. package/packages/server/dist/resources/resources.js +3 -2
  141. package/packages/server/dist/server.d.ts +34 -24
  142. package/packages/server/dist/server.js +2 -1
  143. package/packages/server/dist/tools/analyze.tools.d.ts +14 -10
  144. package/packages/server/dist/tools/analyze.tools.js +2 -3
  145. package/packages/server/dist/tools/audit.tool.d.ts +8 -4
  146. package/packages/server/dist/tools/audit.tool.js +2 -4
  147. package/packages/server/dist/tools/bridge.tools.d.ts +35 -0
  148. package/packages/server/dist/tools/bridge.tools.js +16 -0
  149. package/packages/server/dist/tools/evolution.tools.d.ts +8 -0
  150. package/packages/server/dist/tools/evolution.tools.js +6 -0
  151. package/packages/server/dist/tools/forge.tools.d.ts +13 -11
  152. package/packages/server/dist/tools/forge.tools.js +11 -13
  153. package/packages/server/dist/tools/forget.tool.d.ts +7 -3
  154. package/packages/server/dist/tools/forget.tool.js +2 -7
  155. package/packages/server/dist/tools/graph.tool.d.ts +7 -3
  156. package/packages/server/dist/tools/graph.tool.js +5 -5
  157. package/packages/server/dist/tools/list.tool.d.ts +7 -3
  158. package/packages/server/dist/tools/list.tool.js +3 -8
  159. package/packages/server/dist/tools/lookup.tool.d.ts +7 -3
  160. package/packages/server/dist/tools/lookup.tool.js +3 -9
  161. package/packages/server/dist/tools/onboard.tool.d.ts +8 -4
  162. package/packages/server/dist/tools/onboard.tool.js +3 -2
  163. package/packages/server/dist/tools/policy.tools.d.ts +8 -0
  164. package/packages/server/dist/tools/policy.tools.js +3 -0
  165. package/packages/server/dist/tools/produce.tool.d.ts +6 -2
  166. package/packages/server/dist/tools/produce.tool.js +3 -2
  167. package/packages/server/dist/tools/read.tool.d.ts +7 -3
  168. package/packages/server/dist/tools/read.tool.js +3 -6
  169. package/packages/server/dist/tools/reindex.tool.d.ts +10 -6
  170. package/packages/server/dist/tools/reindex.tool.js +3 -2
  171. package/packages/server/dist/tools/remember.tool.d.ts +8 -3
  172. package/packages/server/dist/tools/remember.tool.js +4 -5
  173. package/packages/server/dist/tools/replay.tool.d.ts +6 -2
  174. package/packages/server/dist/tools/replay.tool.js +3 -6
  175. package/packages/server/dist/tools/search.tool.d.ts +10 -4
  176. package/packages/server/dist/tools/search.tool.js +7 -22
  177. package/packages/server/dist/tools/status.tool.d.ts +7 -3
  178. package/packages/server/dist/tools/status.tool.js +3 -3
  179. package/packages/server/dist/tools/toolkit.tools.d.ts +36 -34
  180. package/packages/server/dist/tools/toolkit.tools.js +20 -24
  181. package/packages/server/dist/tools/update.tool.d.ts +7 -3
  182. package/packages/server/dist/tools/update.tool.js +2 -6
  183. package/packages/server/dist/tools/utility.tools.d.ts +15 -14
  184. package/packages/server/dist/tools/utility.tools.js +11 -23
  185. package/packages/server/dist/version-check.d.ts +5 -1
  186. package/packages/server/dist/version-check.js +2 -1
  187. package/packages/store/dist/graph-store.interface.d.ts +89 -86
  188. package/packages/store/dist/graph-store.interface.js +1 -0
  189. package/packages/store/dist/index.d.ts +6 -6
  190. package/packages/store/dist/index.js +1 -1
  191. package/packages/store/dist/lance-store.d.ts +37 -30
  192. package/packages/store/dist/lance-store.js +2 -1
  193. package/packages/store/dist/sqlite-graph-store.d.ts +43 -46
  194. package/packages/store/dist/sqlite-graph-store.js +14 -13
  195. package/packages/store/dist/store-factory.d.ts +11 -7
  196. package/packages/store/dist/store-factory.js +2 -1
  197. package/packages/store/dist/store.interface.d.ts +47 -46
  198. package/packages/store/dist/store.interface.js +1 -0
  199. package/packages/tools/dist/audit.d.ts +61 -61
  200. package/packages/tools/dist/audit.js +5 -5
  201. package/packages/tools/dist/batch.d.ts +20 -17
  202. package/packages/tools/dist/batch.js +2 -1
  203. package/packages/tools/dist/changelog.d.ts +29 -26
  204. package/packages/tools/dist/changelog.js +3 -2
  205. package/packages/tools/dist/check.d.ts +42 -38
  206. package/packages/tools/dist/check.js +3 -2
  207. package/packages/tools/dist/checkpoint.d.ts +17 -14
  208. package/packages/tools/dist/checkpoint.js +2 -2
  209. package/packages/tools/dist/codemod.d.ts +35 -32
  210. package/packages/tools/dist/codemod.js +3 -2
  211. package/packages/tools/dist/compact.d.ts +34 -37
  212. package/packages/tools/dist/compact.js +3 -2
  213. package/packages/tools/dist/data-transform.d.ts +10 -7
  214. package/packages/tools/dist/data-transform.js +2 -1
  215. package/packages/tools/dist/dead-symbols.d.ts +29 -25
  216. package/packages/tools/dist/dead-symbols.js +3 -2
  217. package/packages/tools/dist/delegate.d.ts +26 -23
  218. package/packages/tools/dist/delegate.js +2 -5
  219. package/packages/tools/dist/diff-parse.d.ts +24 -21
  220. package/packages/tools/dist/diff-parse.js +4 -3
  221. package/packages/tools/dist/digest.d.ts +43 -45
  222. package/packages/tools/dist/digest.js +5 -5
  223. package/packages/tools/dist/encode.d.ts +11 -8
  224. package/packages/tools/dist/encode.js +2 -1
  225. package/packages/tools/dist/env-info.d.ts +25 -22
  226. package/packages/tools/dist/env-info.js +2 -1
  227. package/packages/tools/dist/eval.d.ts +13 -10
  228. package/packages/tools/dist/eval.js +3 -3
  229. package/packages/tools/dist/evidence-map.d.ts +64 -61
  230. package/packages/tools/dist/evidence-map.js +3 -3
  231. package/packages/tools/dist/file-cache.d.ts +42 -0
  232. package/packages/tools/dist/file-cache.js +4 -0
  233. package/packages/tools/dist/file-summary.d.ts +34 -29
  234. package/packages/tools/dist/file-summary.js +3 -2
  235. package/packages/tools/dist/file-walk.d.ts +6 -3
  236. package/packages/tools/dist/file-walk.js +2 -1
  237. package/packages/tools/dist/find-examples.d.ts +26 -21
  238. package/packages/tools/dist/find-examples.js +4 -3
  239. package/packages/tools/dist/find.d.ts +39 -40
  240. package/packages/tools/dist/find.js +2 -1
  241. package/packages/tools/dist/forge-classify.d.ts +35 -38
  242. package/packages/tools/dist/forge-classify.js +3 -2
  243. package/packages/tools/dist/forge-ground.d.ts +58 -60
  244. package/packages/tools/dist/forge-ground.js +2 -1
  245. package/packages/tools/dist/git-context.d.ts +22 -19
  246. package/packages/tools/dist/git-context.js +4 -3
  247. package/packages/tools/dist/graph-query.d.ts +75 -78
  248. package/packages/tools/dist/graph-query.js +2 -1
  249. package/packages/tools/dist/guide.d.ts +14 -11
  250. package/packages/tools/dist/guide.js +2 -1
  251. package/packages/tools/dist/health.d.ts +13 -10
  252. package/packages/tools/dist/health.js +3 -2
  253. package/packages/tools/dist/http-request.d.ts +20 -17
  254. package/packages/tools/dist/http-request.js +2 -1
  255. package/packages/tools/dist/index.d.ts +54 -53
  256. package/packages/tools/dist/index.js +1 -1
  257. package/packages/tools/dist/lane.d.ts +28 -25
  258. package/packages/tools/dist/lane.js +7 -7
  259. package/packages/tools/dist/measure.d.ts +32 -29
  260. package/packages/tools/dist/measure.js +3 -2
  261. package/packages/tools/dist/onboard.d.ts +29 -26
  262. package/packages/tools/dist/onboard.js +18 -41
  263. package/packages/tools/dist/parse-output.d.ts +48 -45
  264. package/packages/tools/dist/parse-output.js +3 -2
  265. package/packages/tools/dist/path-resolver.d.ts +4 -1
  266. package/packages/tools/dist/path-resolver.js +2 -1
  267. package/packages/tools/dist/process-manager.d.ts +18 -15
  268. package/packages/tools/dist/process-manager.js +2 -1
  269. package/packages/tools/dist/queue.d.ts +28 -25
  270. package/packages/tools/dist/queue.js +2 -2
  271. package/packages/tools/dist/regex-test.d.ts +26 -23
  272. package/packages/tools/dist/regex-test.js +2 -1
  273. package/packages/tools/dist/rename.d.ts +28 -25
  274. package/packages/tools/dist/rename.js +3 -2
  275. package/packages/tools/dist/replay.d.ts +32 -29
  276. package/packages/tools/dist/replay.js +5 -6
  277. package/packages/tools/dist/response-envelope.d.ts +32 -29
  278. package/packages/tools/dist/response-envelope.js +2 -1
  279. package/packages/tools/dist/schema-validate.d.ts +15 -12
  280. package/packages/tools/dist/schema-validate.js +2 -1
  281. package/packages/tools/dist/scope-map.d.ts +45 -47
  282. package/packages/tools/dist/scope-map.js +2 -1
  283. package/packages/tools/dist/snippet.d.ts +26 -24
  284. package/packages/tools/dist/snippet.js +2 -1
  285. package/packages/tools/dist/stash.d.ts +13 -10
  286. package/packages/tools/dist/stash.js +2 -2
  287. package/packages/tools/dist/stratum-card.d.ts +27 -27
  288. package/packages/tools/dist/stratum-card.js +4 -5
  289. package/packages/tools/dist/symbol.d.ts +29 -25
  290. package/packages/tools/dist/symbol.js +4 -3
  291. package/packages/tools/dist/test-run.d.ts +19 -15
  292. package/packages/tools/dist/test-run.js +3 -2
  293. package/packages/tools/dist/text-utils.d.ts +6 -3
  294. package/packages/tools/dist/text-utils.js +3 -2
  295. package/packages/tools/dist/time-utils.d.ts +15 -12
  296. package/packages/tools/dist/time-utils.js +2 -1
  297. package/packages/tools/dist/trace.d.ts +24 -20
  298. package/packages/tools/dist/trace.js +3 -2
  299. package/packages/tools/dist/truncation.d.ts +6 -3
  300. package/packages/tools/dist/truncation.js +8 -14
  301. package/packages/tools/dist/watch.d.ts +28 -25
  302. package/packages/tools/dist/watch.js +2 -1
  303. package/packages/tools/dist/web-fetch.d.ts +35 -32
  304. package/packages/tools/dist/web-fetch.js +7 -12
  305. package/packages/tools/dist/web-search.d.ts +16 -13
  306. package/packages/tools/dist/web-search.js +2 -1
  307. package/packages/tools/dist/workset.d.ts +19 -16
  308. package/packages/tools/dist/workset.js +2 -2
  309. package/packages/tui/dist/App-BAlmxCCw.js +3 -0
  310. package/packages/tui/dist/App.d.ts +11 -5
  311. package/packages/tui/dist/App.js +1 -450
  312. package/packages/tui/dist/CuratedPanel-sYdZAICX.js +3 -0
  313. package/packages/tui/dist/LogPanel-DVB8Sv46.js +4 -0
  314. package/packages/tui/dist/SearchPanel-DREo6zgt.js +3 -0
  315. package/packages/tui/dist/StatusPanel-2ex8fLOO.js +3 -0
  316. package/packages/tui/dist/chunk-D6axbAb-.js +2 -0
  317. package/packages/tui/dist/devtools-DUyj952l.js +8 -0
  318. package/packages/tui/dist/embedder.interface-D4ew0HPW.d.ts +29 -0
  319. package/packages/tui/dist/index-B9VpfVPP.d.ts +14 -0
  320. package/packages/tui/dist/index.d.ts +3 -19
  321. package/packages/tui/dist/index.js +2 -476
  322. package/packages/tui/dist/jsx-runtime-Cof-kwFn.js +317 -0
  323. package/packages/tui/dist/panels/CuratedPanel.d.ts +11 -5
  324. package/packages/tui/dist/panels/CuratedPanel.js +1 -371
  325. package/packages/tui/dist/panels/LogPanel.d.ts +7 -2
  326. package/packages/tui/dist/panels/LogPanel.js +1 -449
  327. package/packages/tui/dist/panels/SearchPanel.d.ts +14 -7
  328. package/packages/tui/dist/panels/SearchPanel.js +1 -372
  329. package/packages/tui/dist/panels/StatusPanel.d.ts +11 -5
  330. package/packages/tui/dist/panels/StatusPanel.js +1 -371
  331. package/packages/tui/dist/store.interface-CnY6SPOH.d.ts +151 -0
  332. package/scaffold/adapters/claude-code.mjs +20 -0
  333. package/scaffold/adapters/copilot.mjs +320 -0
  334. package/scaffold/copilot/agents/Architect-Reviewer-Alpha.agent.md +14 -0
  335. package/scaffold/copilot/agents/Architect-Reviewer-Beta.agent.md +14 -0
  336. package/scaffold/copilot/agents/Code-Reviewer-Alpha.agent.md +12 -0
  337. package/scaffold/copilot/agents/Code-Reviewer-Beta.agent.md +12 -0
  338. package/scaffold/copilot/agents/Debugger.agent.md +31 -0
  339. package/scaffold/copilot/agents/Documenter.agent.md +35 -0
  340. package/scaffold/copilot/agents/Explorer.agent.md +50 -0
  341. package/scaffold/copilot/agents/Frontend.agent.md +29 -0
  342. package/scaffold/copilot/agents/Implementer.agent.md +31 -0
  343. package/scaffold/copilot/agents/Orchestrator.agent.md +96 -0
  344. package/scaffold/copilot/agents/Planner.agent.md +45 -0
  345. package/scaffold/copilot/agents/README.md +57 -0
  346. package/scaffold/copilot/agents/Refactor.agent.md +30 -0
  347. package/scaffold/copilot/agents/Researcher-Alpha.agent.md +12 -0
  348. package/scaffold/copilot/agents/Researcher-Beta.agent.md +12 -0
  349. package/scaffold/copilot/agents/Researcher-Delta.agent.md +12 -0
  350. package/scaffold/copilot/agents/Researcher-Gamma.agent.md +12 -0
  351. package/scaffold/copilot/agents/Security.agent.md +42 -0
  352. package/scaffold/copilot/agents/_shared/adr-protocol.md +91 -0
  353. package/scaffold/copilot/agents/_shared/architect-reviewer-base.md +50 -0
  354. package/scaffold/copilot/agents/_shared/code-agent-base.md +70 -0
  355. package/scaffold/copilot/agents/_shared/code-reviewer-base.md +54 -0
  356. package/scaffold/copilot/agents/_shared/decision-protocol.md +27 -0
  357. package/scaffold/copilot/agents/_shared/forge-protocol.md +46 -0
  358. package/scaffold/copilot/agents/_shared/researcher-base.md +61 -0
  359. package/scaffold/copilot/agents/templates/adr-template.md +27 -0
  360. package/scaffold/copilot/agents/templates/execution-state.md +25 -0
  361. package/scaffold/copilot/prompts/ask.prompt.md +20 -0
  362. package/scaffold/copilot/prompts/debug.prompt.md +25 -0
  363. package/scaffold/copilot/prompts/design.prompt.md +22 -0
  364. package/scaffold/copilot/prompts/implement.prompt.md +26 -0
  365. package/scaffold/copilot/prompts/plan.prompt.md +24 -0
  366. package/scaffold/copilot/prompts/review.prompt.md +31 -0
  367. package/scaffold/definitions/agents.mjs +165 -0
  368. package/scaffold/definitions/bodies.mjs +292 -0
  369. package/scaffold/definitions/hooks.mjs +43 -0
  370. package/scaffold/definitions/models.mjs +56 -0
  371. package/scaffold/definitions/plugins.mjs +24 -0
  372. package/scaffold/definitions/prompts.mjs +145 -0
  373. package/scaffold/definitions/protocols.mjs +322 -0
  374. package/scaffold/definitions/tools.mjs +176 -0
  375. package/scaffold/generate.mjs +74 -0
  376. package/skills/brainstorming/SKILL.md +259 -0
  377. package/skills/brainstorming/scripts/frame-template.html +365 -0
  378. package/skills/brainstorming/scripts/helper.js +216 -0
  379. package/skills/brainstorming/scripts/server.cjs +9 -0
  380. package/skills/brainstorming/scripts/server.src.cjs +249 -0
  381. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  382. package/skills/brainstorming/visual-companion.md +430 -0
  383. package/skills/knowledge-base/SKILL.md +22 -9
@@ -1,32 +1,36 @@
1
- import type { DependencyAnalyzer } from './dependency-analyzer.js';
2
- import type { DiagramGenerator } from './diagram-generator.js';
3
- import type { EntryPointAnalyzer } from './entry-point-analyzer.js';
4
- import type { PatternAnalyzer } from './pattern-analyzer.js';
5
- import type { StructureAnalyzer } from './structure-analyzer.js';
6
- import type { SymbolAnalyzer } from './symbol-analyzer.js';
7
- import type { ExtractionBaselines } from './types.js';
8
- export interface Analyzers {
9
- structure: StructureAnalyzer;
10
- dependencies: DependencyAnalyzer;
11
- symbols: SymbolAnalyzer;
12
- patterns: PatternAnalyzer;
13
- entryPoints: EntryPointAnalyzer;
14
- diagrams: DiagramGenerator;
1
+ import { ExtractionBaselines } from "./types.js";
2
+ import { DependencyAnalyzer } from "./dependency-analyzer.js";
3
+ import { DiagramGenerator } from "./diagram-generator.js";
4
+ import { EntryPointAnalyzer } from "./entry-point-analyzer.js";
5
+ import { PatternAnalyzer } from "./pattern-analyzer.js";
6
+ import { StructureAnalyzer } from "./structure-analyzer.js";
7
+ import { SymbolAnalyzer } from "./symbol-analyzer.js";
8
+
9
+ //#region packages/analyzers/src/knowledge-producer.d.ts
10
+ interface Analyzers {
11
+ structure: StructureAnalyzer;
12
+ dependencies: DependencyAnalyzer;
13
+ symbols: SymbolAnalyzer;
14
+ patterns: PatternAnalyzer;
15
+ entryPoints: EntryPointAnalyzer;
16
+ diagrams: DiagramGenerator;
15
17
  }
16
18
  /**
17
19
  * Orchestrates Tier 1 deterministic extraction and prepares
18
20
  * synthesis instructions for the LLM to produce knowledge.
19
21
  */
20
- export declare class KnowledgeProducer {
21
- private readonly analyzers;
22
- constructor(analyzers: Analyzers);
23
- /**
24
- * Run Tier 1 deterministic extraction for specified aspects.
25
- */
26
- runExtraction(scope: string, aspects: string[]): Promise<ExtractionBaselines>;
27
- /**
28
- * Build synthesis instructions from baselines for the LLM.
29
- */
30
- buildSynthesisInstructions(baselines: ExtractionBaselines, _aspects: string[]): string;
22
+ declare class KnowledgeProducer {
23
+ private readonly analyzers;
24
+ constructor(analyzers: Analyzers);
25
+ /**
26
+ * Run Tier 1 deterministic extraction for specified aspects.
27
+ */
28
+ runExtraction(scope: string, aspects: string[]): Promise<ExtractionBaselines>;
29
+ /**
30
+ * Build synthesis instructions from baselines for the LLM.
31
+ */
32
+ buildSynthesisInstructions(baselines: ExtractionBaselines, _aspects: string[]): string;
31
33
  }
34
+ //#endregion
35
+ export { Analyzers, KnowledgeProducer };
32
36
  //# sourceMappingURL=knowledge-producer.d.ts.map
@@ -1,24 +1,25 @@
1
- const u={structure:"structure",dependencies:"dependencies",symbols:"symbols",patterns:"patterns","entry-points":"entryPoints",diagrams:"diagrams"},p=Object.keys(u);class l{constructor(t){this.analyzers=t}async runExtraction(t,o){const e=o.includes("all")?p:o,s={},i=[];for(const r of e){const a=u[r];if(!a)continue;const n=this.analyzers[a];n&&(r==="diagrams"?i.push({key:"diagrams",promise:n.analyze(t,{diagramType:"architecture"})}):i.push({key:r,promise:n.analyze(t)}))}const c=await Promise.allSettled(i.map(async r=>({key:r.key,result:await r.promise})));for(const r of c){if(r.status!=="fulfilled")continue;const{key:a,result:n}=r.value;a==="diagrams"?s.diagrams=[n]:s[a]=n}return s}buildSynthesisInstructions(t,o){const e=[];if(e.push(`## Knowledge Production Results
2
- `),e.push(`### Extraction Baselines (auto-generated)
3
- `),t.structure&&(e.push(`#### File Structure
4
- `),e.push(t.structure.output),e.push("")),t.dependencies&&(e.push(`#### Dependencies
5
- `),e.push(t.dependencies.output),e.push("")),t.symbols&&(e.push(`#### Symbols
6
- `),e.push(t.symbols.output),e.push("")),t.patterns&&(e.push(`#### Detected Patterns
7
- `),e.push(t.patterns.output),e.push("")),t.entryPoints&&(e.push(`#### Entry Points
8
- `),e.push(t.entryPoints.output),e.push("")),t.diagrams&&t.diagrams.length>0){e.push(`#### Architecture Diagram
9
- `);for(const s of t.diagrams)e.push(s.output);e.push("")}return e.push(`### Your Task: Synthesize Knowledge
10
- `),e.push("Based on the baselines above and your reading of the source files, produce"),e.push("the following knowledge documents using `kb_remember`:\n"),e.push(`1. **Domain Overview** (category: \`architecture\`)
1
+ const e={structure:`structure`,dependencies:`dependencies`,symbols:`symbols`,patterns:`patterns`,"entry-points":`entryPoints`,diagrams:`diagrams`},t=Object.keys(e);var n=class{constructor(e){this.analyzers=e}async runExtraction(n,r){let i=r.includes(`all`)?t:r,a={},o=[];for(let t of i){let r=e[t];if(!r)continue;let i=this.analyzers[r];i&&(t===`diagrams`?o.push({key:`diagrams`,promise:i.analyze(n,{diagramType:`architecture`})}):o.push({key:t,promise:i.analyze(n)}))}let s=await Promise.allSettled(o.map(async e=>({key:e.key,result:await e.promise})));for(let e of s){if(e.status!==`fulfilled`)continue;let{key:t,result:n}=e.value;t===`diagrams`?a.diagrams=[n]:a[t]=n}return a}buildSynthesisInstructions(e,t){let n=[];if(n.push(`## Knowledge Production Results
2
+ `),n.push(`### Extraction Baselines (auto-generated)
3
+ `),e.structure&&(n.push(`#### File Structure
4
+ `),n.push(e.structure.output),n.push(``)),e.dependencies&&(n.push(`#### Dependencies
5
+ `),n.push(e.dependencies.output),n.push(``)),e.symbols&&(n.push(`#### Symbols
6
+ `),n.push(e.symbols.output),n.push(``)),e.patterns&&(n.push(`#### Detected Patterns
7
+ `),n.push(e.patterns.output),n.push(``)),e.entryPoints&&(n.push(`#### Entry Points
8
+ `),n.push(e.entryPoints.output),n.push(``)),e.diagrams&&e.diagrams.length>0){n.push(`#### Architecture Diagram
9
+ `);for(let t of e.diagrams)n.push(t.output);n.push(``)}return n.push(`### Your Task: Synthesize Knowledge
10
+ `),n.push(`Based on the baselines above and your reading of the source files, produce`),n.push("the following knowledge documents using `kb_remember`:\n"),n.push(`1. **Domain Overview** (category: \`architecture\`)
11
11
  - What this service does, boundary with other services
12
12
  - Key entities and their lifecycle
13
- `),e.push(`2. **Architecture Summary** (category: \`architecture\`)
13
+ `),n.push(`2. **Architecture Summary** (category: \`architecture\`)
14
14
  - Layer structure, dependency flow
15
15
  - Key design decisions
16
- `),e.push(`3. **Pattern Usage** (category: \`patterns\`)
16
+ `),n.push(`3. **Pattern Usage** (category: \`patterns\`)
17
17
  - Which patterns are used and why
18
18
  - Where to find examples
19
- `),e.push(`4. **Conventions** (category: \`conventions\`)
19
+ `),n.push(`4. **Conventions** (category: \`conventions\`)
20
20
  - Naming conventions observed
21
21
  - File organization rules
22
22
  - Testing patterns
23
- `),e.push("Store each as a separate `kb_remember` call with descriptive titles.\n"),e.join(`
24
- `)}}export{l as KnowledgeProducer};
23
+ `),n.push("Store each as a separate `kb_remember` call with descriptive titles.\n"),n.join(`
24
+ `)}};export{n as KnowledgeProducer};
25
+ //# sourceMappingURL=knowledge-producer.js.map
@@ -1,12 +1,16 @@
1
- import type { AnalysisResult, AnalyzerOptions, IAnalyzer } from './types.js';
2
- export declare class PatternAnalyzer implements IAnalyzer<AnalyzerOptions> {
3
- readonly name = "patterns";
4
- analyze(rootPath: string, _options?: AnalyzerOptions): Promise<AnalysisResult>;
5
- private collectDirectories;
6
- private collectCodeFiles;
7
- private detectDirectoryPatterns;
8
- private detectCodePatterns;
9
- private detectConfigPatterns;
10
- private formatMarkdown;
1
+ import { AnalysisResult, AnalyzerOptions, IAnalyzer } from "./types.js";
2
+
3
+ //#region packages/analyzers/src/pattern-analyzer.d.ts
4
+ declare class PatternAnalyzer implements IAnalyzer<AnalyzerOptions> {
5
+ readonly name = "patterns";
6
+ analyze(rootPath: string, _options?: AnalyzerOptions): Promise<AnalysisResult>;
7
+ private collectDirectories;
8
+ private collectCodeFiles;
9
+ private detectDirectoryPatterns;
10
+ private detectCodePatterns;
11
+ private detectConfigPatterns;
12
+ private formatMarkdown;
11
13
  }
14
+ //#endregion
15
+ export { PatternAnalyzer };
12
16
  //# sourceMappingURL=pattern-analyzer.d.ts.map
@@ -1,5 +1,3 @@
1
- import{access as P,readdir as h,readFile as C}from"node:fs/promises";import{extname as m,join as f,relative as S}from"node:path";const w=new Set(["node_modules",".git","dist","build","coverage",".turbo",".cache","cdk.out","__pycache__",".venv","target","bin","obj",".gradle","venv","env"]),v=[{dirs:["adapters","ports"],pattern:"Hexagonal Architecture",description:"Ports & adapters (hexagonal) separation"},{dirs:["domain","infrastructure","application"],pattern:"Clean Architecture",description:"Layered with domain/infrastructure separation"},{dirs:["controllers","models"],pattern:"MVC Pattern",description:"Model-View-Controller structure"},{dirs:["repositories"],pattern:"Repository Pattern",description:"Data access abstraction via repositories"},{dirs:["factories"],pattern:"Factory Pattern",description:"Object creation via factories"},{dirs:["handlers"],pattern:"Handler Pattern",description:"Event/request handler separation"},{dirs:["middleware"],pattern:"Middleware Pattern",description:"Request pipeline middleware"},{dirs:["hooks"],pattern:"React Hooks",description:"Custom React hooks for logic reuse"},{dirs:["components"],pattern:"Component Architecture",description:"UI component-based structure"},{dirs:["stacks","constructs"],pattern:"CDK IaC",description:"AWS CDK infrastructure as code"},{dirs:["lambdas","functions"],pattern:"Serverless",description:"Serverless function architecture"}];function x(g){if(g.length<=3)return g;const r=new Map;for(const e of g){const t=e.split("/"),n=t.length>1?t.slice(0,-1).join("/"):".",a=r.get(n);a?a.push(e):r.set(n,[e])}const o=[];for(const[e,t]of r)t.length>=3?o.push(`${e}/ (${t.length} files)`):o.push(...t);return o.slice(0,5)}const y=[{regex:/container\.register|@injectable|@inject/i,pattern:"Dependency Injection",description:"IoC container or DI decorators"},{regex:/\.pipe\(|Observable|BehaviorSubject/i,pattern:"Reactive (RxJS)",description:"Reactive programming with observables",lang:"js"},{regex:/createContext|useContext/i,pattern:"React Context",description:"React Context API for state sharing",lang:"js"},{regex:/createSlice|configureStore/i,pattern:"Redux Toolkit",description:"Redux state management",lang:"js"},{regex:/defineStore|usePinia/i,pattern:"Pinia Store",description:"Vue Pinia state management",lang:"js"},{regex:/\.(test|spec)\.[jt]sx?|describe\s*\(|\bit\s*\([\s'"]/i,pattern:"Test Suite",description:"Unit/integration test files"},{regex:/@SpringBootApplication|@EnableAutoConfiguration/,pattern:"Spring Boot",description:"Spring Boot application framework",lang:"java",definitive:!0},{regex:/@Autowired|@Component|@Service|@Repository|@Controller/,pattern:"Spring DI",description:"Spring dependency injection",lang:"java"},{regex:/@RestController|@RequestMapping|@GetMapping|@PostMapping/,pattern:"Spring REST",description:"Spring REST API controllers",lang:"java"},{regex:/app\s*=\s*Flask\s*\(|@app\.route/,pattern:"Flask",description:"Flask web framework",lang:"python"},{regex:/app\s*=\s*FastAPI\s*\(|@app\.get|@app\.post/,pattern:"FastAPI",description:"FastAPI web framework",lang:"python"},{regex:/func\s+main\s*\(\s*\)|http\.ListenAndServe/,pattern:"Go Application",description:"Go main application",lang:"go"},{regex:/export\s+(?:async\s+)?function\s+create[A-Z]\w+/,pattern:"Factory",description:"Object creation via create*() functions",lang:"js"},{regex:/(?:export\s+)?function\s+wrap[A-Z]\w+/,pattern:"Wrapper/Decorator",description:"Higher-order function wrapping",lang:"js"},{regex:/(?:const|let)\s+\w+\s*=\s*new\s+(?:Map|WeakMap)\s*[<(]/,pattern:"Singleton Cache",description:"Module-level cache with lazy initialization",lang:"js"},{regex:/Record<string,\s*(?:\w+)?Handler>|\.(?:get|post|put|delete)\s*\(/,pattern:"Router/Dispatcher",description:"Request routing/dispatch table",lang:"js"},{regex:/export\s+(?:default\s+)?class\s+\w+\s+extends\s+(?:Construct|Stack|NestedStack|Stage)/,pattern:"CDK Construct",description:"AWS CDK infrastructure construct",lang:"js",definitive:!0}];class D{name="patterns";async analyze(r,o={}){const e=Date.now(),t=await this.collectDirectories(r),n=this.detectDirectoryPatterns(t,r),a=await this.collectCodeFiles(r),i=await this.detectCodePatterns(a,r),s=[...n,...i],c=await this.detectConfigPatterns(r),p=c.find(l=>l.pattern==="Maven"||l.pattern==="Gradle"||l.pattern==="Gradle (Kotlin DSL)"||l.pattern==="Node.js Project"||l.pattern==="Go Module"||l.pattern==="Rust (Cargo)"),u=new Set(["Ruby (Bundler)","PHP (Composer)","Swift Package","SBT"]);for(const l of c)p&&u.has(l.pattern)||s.push(l);return{output:this.formatMarkdown(s,r),data:{patterns:s,total:s.length},meta:{analyzedAt:new Date().toISOString(),scope:r,fileCount:a.length,durationMs:Date.now()-e}}}async collectDirectories(r){const o=[],e=async(t,n)=>{if(n>5)return;const a=await h(t,{withFileTypes:!0});for(const i of a){if(!i.isDirectory()||w.has(i.name)||i.name.startsWith("."))continue;const s=f(t,i.name);o.push(i.name),await e(s,n+1)}};return await e(r,0),o}async collectCodeFiles(r){const o=[],e=new Set([".ts",".tsx",".js",".jsx",".java",".py",".go",".cs",".kt",".scala",".rb",".rs",".php",".swift"]),t=async n=>{const a=await h(n,{withFileTypes:!0});for(const i of a){if(w.has(i.name)||i.name.startsWith("."))continue;const s=f(n,i.name);i.isDirectory()?await t(s):e.has(m(i.name))&&o.push(s)}};return await t(r),o}detectDirectoryPatterns(r,o){const e=new Set(r.map(n=>n.toLowerCase())),t=[];for(const n of v){const a=n.dirs.filter(i=>e.has(i));a.length!==0&&(n.dirs.length>1&&a.length<2||t.push({pattern:n.pattern,description:n.description,locations:a.map(i=>`${i}/`),confidence:a.length===n.dirs.length?"high":"medium"}))}return t}async detectCodePatterns(r,o){const e=[],t={},n=r.filter(s=>/Application\.\w+$|Main\.\w+$|app\.\w+$|main\.\w+$/i.test(s)||/Controller|Service|Handler|Router/i.test(s)),a=r.filter(s=>!n.includes(s)),i=[...n.slice(0,50),...a.slice(0,150)];for(const s of i)try{const c=await C(s,"utf-8"),p=m(s).toLowerCase(),u=p===".java"||p===".kt"||p===".scala"?"java":p===".py"?"python":p===".go"?"go":"js";for(const d of y)d.lang&&d.lang!==u||d.regex.test(c)&&(t[d.pattern]||(t[d.pattern]=new Set),t[d.pattern].add(S(o,s).replace(/\\/g,"/")))}catch{}for(const s of y){const c=t[s.pattern];if(c&&c.size>0){const p=x([...c]);e.push({pattern:s.pattern,description:s.description,locations:p,confidence:s.definitive||c.size>=3?"high":c.size>=2?"medium":"low"})}}return e}async detectConfigPatterns(r){const o=[],e=[{file:"Dockerfile",pattern:"Docker",description:"Containerized application"},{file:"docker-compose.yml",pattern:"Docker Compose",description:"Container orchestration"},{file:"cdk.json",pattern:"AWS CDK",description:"AWS CDK infrastructure as code"},{file:"terraform.tf",pattern:"Terraform",description:"Terraform IaC"},{file:"main.tf",pattern:"Terraform",description:"Terraform IaC"}];for(const t of e)try{await P(f(r,t.file)),o.push({pattern:t.pattern,description:t.description,locations:[t.file],confidence:"high"})}catch{}return o}formatMarkdown(r,o){const e=[];e.push(`## Patterns Detected: ${o}
2
- `),e.push(`**${r.length} patterns** found
3
- `);const t={high:[],medium:[],low:[]};for(const n of r)t[n.confidence].push(n);for(const[n,a]of Object.entries(t))if(a.length!==0){e.push(`### ${n.charAt(0).toUpperCase()+n.slice(1)} Confidence
4
- `);for(const i of a)e.push(`- **${i.pattern}**: ${i.description}`),e.push(` Locations: ${i.locations.slice(0,5).join(", ")}`);e.push("")}return e.join(`
5
- `)}}export{D as PatternAnalyzer};
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}from"node:path";const o=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,`__pycache__`,`.venv`,`target`,`bin`,`obj`,`.gradle`,`venv`,`env`]),s=[{dirs:[`adapters`,`ports`],pattern:`Hexagonal Architecture`,description:`Ports & adapters (hexagonal) separation`},{dirs:[`domain`,`infrastructure`,`application`],pattern:`Clean Architecture`,description:`Layered with domain/infrastructure separation`},{dirs:[`controllers`,`models`],pattern:`MVC Pattern`,description:`Model-View-Controller structure`},{dirs:[`repositories`],pattern:`Repository Pattern`,description:`Data access abstraction via repositories`},{dirs:[`factories`],pattern:`Factory Pattern`,description:`Object creation via factories`},{dirs:[`handlers`],pattern:`Handler Pattern`,description:`Event/request handler separation`},{dirs:[`middleware`],pattern:`Middleware Pattern`,description:`Request pipeline middleware`},{dirs:[`hooks`],pattern:`React Hooks`,description:`Custom React hooks for logic reuse`},{dirs:[`components`],pattern:`Component Architecture`,description:`UI component-based structure`},{dirs:[`stacks`,`constructs`],pattern:`CDK IaC`,description:`AWS CDK infrastructure as code`},{dirs:[`lambdas`,`functions`],pattern:`Serverless`,description:`Serverless function architecture`}];function c(e){if(e.length<=3)return e;let t=new Map;for(let n of e){let e=n.split(`/`),r=e.length>1?e.slice(0,-1).join(`/`):`.`,i=t.get(r);i?i.push(n):t.set(r,[n])}let n=[];for(let[e,r]of t)r.length>=3?n.push(`${e}/ (${r.length} files)`):n.push(...r);return n.slice(0,5)}const l=[{regex:/container\.register|@injectable|@inject/i,pattern:`Dependency Injection`,description:`IoC container or DI decorators`},{regex:/\.pipe\(|Observable|BehaviorSubject/i,pattern:`Reactive (RxJS)`,description:`Reactive programming with observables`,lang:`js`},{regex:/createContext|useContext/i,pattern:`React Context`,description:`React Context API for state sharing`,lang:`js`},{regex:/createSlice|configureStore/i,pattern:`Redux Toolkit`,description:`Redux state management`,lang:`js`},{regex:/defineStore|usePinia/i,pattern:`Pinia Store`,description:`Vue Pinia state management`,lang:`js`},{regex:/\.(test|spec)\.[jt]sx?|describe\s*\(|\bit\s*\([\s'"]/i,pattern:`Test Suite`,description:`Unit/integration test files`},{regex:/@SpringBootApplication|@EnableAutoConfiguration/,pattern:`Spring Boot`,description:`Spring Boot application framework`,lang:`java`,definitive:!0},{regex:/@Autowired|@Component|@Service|@Repository|@Controller/,pattern:`Spring DI`,description:`Spring dependency injection`,lang:`java`},{regex:/@RestController|@RequestMapping|@GetMapping|@PostMapping/,pattern:`Spring REST`,description:`Spring REST API controllers`,lang:`java`},{regex:/app\s*=\s*Flask\s*\(|@app\.route/,pattern:`Flask`,description:`Flask web framework`,lang:`python`},{regex:/app\s*=\s*FastAPI\s*\(|@app\.get|@app\.post/,pattern:`FastAPI`,description:`FastAPI web framework`,lang:`python`},{regex:/func\s+main\s*\(\s*\)|http\.ListenAndServe/,pattern:`Go Application`,description:`Go main application`,lang:`go`},{regex:/export\s+(?:async\s+)?function\s+create[A-Z]\w+/,pattern:`Factory`,description:`Object creation via create*() functions`,lang:`js`},{regex:/(?:export\s+)?function\s+wrap[A-Z]\w+/,pattern:`Wrapper/Decorator`,description:`Higher-order function wrapping`,lang:`js`},{regex:/(?:const|let)\s+\w+\s*=\s*new\s+(?:Map|WeakMap)\s*[<(]/,pattern:`Singleton Cache`,description:`Module-level cache with lazy initialization`,lang:`js`},{regex:/Record<string,\s*(?:\w+)?Handler>|\.(?:get|post|put|delete)\s*\(/,pattern:`Router/Dispatcher`,description:`Request routing/dispatch table`,lang:`js`},{regex:/export\s+(?:default\s+)?class\s+\w+\s+extends\s+(?:Construct|Stack|NestedStack|Stage)/,pattern:`CDK Construct`,description:`AWS CDK infrastructure construct`,lang:`js`,definitive:!0}];var u=class{name=`patterns`;async analyze(e,t={}){let n=Date.now(),r=await this.collectDirectories(e),i=this.detectDirectoryPatterns(r,e),a=await this.collectCodeFiles(e),o=await this.detectCodePatterns(a,e),s=[...i,...o],c=await this.detectConfigPatterns(e),l=c.find(e=>e.pattern===`Maven`||e.pattern===`Gradle`||e.pattern===`Gradle (Kotlin DSL)`||e.pattern===`Node.js Project`||e.pattern===`Go Module`||e.pattern===`Rust (Cargo)`),u=new Set([`Ruby (Bundler)`,`PHP (Composer)`,`Swift Package`,`SBT`]);for(let e of c)l&&u.has(e.pattern)||s.push(e);return{output:this.formatMarkdown(s,e),data:{patterns:s,total:s.length},meta:{analyzedAt:new Date().toISOString(),scope:e,fileCount:a.length,durationMs:Date.now()-n}}}async collectDirectories(e){let t=[],r=async(e,a)=>{if(a>5)return;let s=await n(e,{withFileTypes:!0});for(let n of s){if(!n.isDirectory()||o.has(n.name)||n.name.startsWith(`.`))continue;let s=i(e,n.name);t.push(n.name),await r(s,a+1)}};return await r(e,0),t}async collectCodeFiles(e){let t=[],a=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.java`,`.py`,`.go`,`.cs`,`.kt`,`.scala`,`.rb`,`.rs`,`.php`,`.swift`]),s=async e=>{let c=await n(e,{withFileTypes:!0});for(let n of c){if(o.has(n.name)||n.name.startsWith(`.`))continue;let c=i(e,n.name);n.isDirectory()?await s(c):a.has(r(n.name))&&t.push(c)}};return await s(e),t}detectDirectoryPatterns(e,t){let n=new Set(e.map(e=>e.toLowerCase())),r=[];for(let e of s){let t=e.dirs.filter(e=>n.has(e));t.length!==0&&(e.dirs.length>1&&t.length<2||r.push({pattern:e.pattern,description:e.description,locations:t.map(e=>`${e}/`),confidence:t.length===e.dirs.length?`high`:`medium`}))}return r}async detectCodePatterns(e,n){let i=[],o={},s=e.filter(e=>/Application\.\w+$|Main\.\w+$|app\.\w+$|main\.\w+$/i.test(e)||/Controller|Service|Handler|Router/i.test(e)),u=e.filter(e=>!s.includes(e)),d=[...s.slice(0,50),...u.slice(0,150)];for(let e of d)try{let i=await t(e,`utf-8`),s=r(e).toLowerCase(),c=s===`.java`||s===`.kt`||s===`.scala`?`java`:s===`.py`?`python`:s===`.go`?`go`:`js`;for(let t of l)t.lang&&t.lang!==c||t.regex.test(i)&&(o[t.pattern]||(o[t.pattern]=new Set),o[t.pattern].add(a(n,e).replace(/\\/g,`/`)))}catch{}for(let e of l){let t=o[e.pattern];if(t&&t.size>0){let n=c([...t]);i.push({pattern:e.pattern,description:e.description,locations:n,confidence:e.definitive||t.size>=3?`high`:t.size>=2?`medium`:`low`})}}return i}async detectConfigPatterns(t){let n=[];for(let r of[{file:`Dockerfile`,pattern:`Docker`,description:`Containerized application`},{file:`docker-compose.yml`,pattern:`Docker Compose`,description:`Container orchestration`},{file:`cdk.json`,pattern:`AWS CDK`,description:`AWS CDK infrastructure as code`},{file:`terraform.tf`,pattern:`Terraform`,description:`Terraform IaC`},{file:`main.tf`,pattern:`Terraform`,description:`Terraform IaC`}])try{await e(i(t,r.file)),n.push({pattern:r.pattern,description:r.description,locations:[r.file],confidence:`high`})}catch{}return n}formatMarkdown(e,t){let n=[];n.push(`## Patterns Detected: ${t}\n`),n.push(`**${e.length} patterns** found\n`);let r={high:[],medium:[],low:[]};for(let t of e)r[t.confidence].push(t);for(let[e,t]of Object.entries(r))if(t.length!==0){n.push(`### ${e.charAt(0).toUpperCase()+e.slice(1)} Confidence\n`);for(let e of t)n.push(`- **${e.pattern}**: ${e.description}`),n.push(` Locations: ${e.locations.slice(0,5).join(`, `)}`);n.push(``)}return n.join(`
2
+ `)}};export{u as PatternAnalyzer};
3
+ //# sourceMappingURL=pattern-analyzer.js.map
@@ -1,17 +1,11 @@
1
- /**
2
- * Regex-based call graph extractor for all languages.
3
- *
4
- * Parses import statements to extract imported symbol names and source modules,
5
- * then scans the file body for usage of those symbols to build module-level
6
- * call edges. Works for TS/JS, Java, Python, Go, C#, Rust, PHP, Ruby, Kotlin, Scala.
7
- *
8
- * Less precise than the TypeScript Compiler API version (ts-call-graph.ts) but
9
- * works across all languages without requiring language-specific compilers.
10
- */
11
- import type { CallGraphResult } from './ts-call-graph.js';
1
+ import { CallGraphResult } from "./ts-call-graph.js";
2
+
3
+ //#region packages/analyzers/src/regex-call-graph.d.ts
12
4
  /**
13
5
  * Extract regex-based call graph for any supported language.
14
6
  * Returns null if no source files found.
15
7
  */
16
- export declare function extractRegexCallGraph(rootPath: string): Promise<CallGraphResult | null>;
8
+ declare function extractRegexCallGraph(rootPath: string): Promise<CallGraphResult | null>;
9
+ //#endregion
10
+ export { extractRegexCallGraph };
17
11
  //# sourceMappingURL=regex-call-graph.d.ts.map
@@ -1 +1,2 @@
1
- import{readdirSync as _,readFileSync as R}from"node:fs";import{extname as x,join as E,relative as y}from"node:path";const S=new Set(["node_modules",".git","dist","build","coverage",".turbo",".cache","cdk.out",".venv","venv","__pycache__","target","vendor","bin","obj"]),k=new Set([".ts",".tsx",".js",".jsx",".java",".py",".go",".cs",".kt",".scala",".rs",".rb",".php",".swift"]);async function q(e){const a=Date.now(),t=T(e);if(t.length===0)return null;const n=t.slice(0,800),s=new Map,r=new Map;for(const l of n){const g=y(e,l).replace(/\\/g,"/"),p=R(l,"utf-8"),u=x(l).toLowerCase(),m=I(p,u);s.set(g,m);const h=W(p,u);r.set(g,h)}const i=M(n,e),c=new Map;for(const[l,g]of s){if($(l))continue;const p=R(E(e,l),"utf-8"),u=C(p,x(l));for(const m of g){if(!m.isRelative)continue;const h=D(l,m.source,i,x(l));if(h.length===0)continue;const d=h[0];if($(d)||l===d)continue;let f;if(m.symbols.length>0?f=m.symbols.filter(w=>new RegExp(`\\b${A(w)}\\b`).test(u)):f=["*"],f.length===0)continue;const b=`${l}|${d}`,v=c.get(b);if(v)for(const w of f)v.add(w);else c.set(b,new Set(f))}}const o=[];for(const[l,g]of c){const[p,u]=l.split("|");o.push({from:p,to:u,symbols:[...g].sort().slice(0,10)})}return o.sort((l,g)=>g.symbols.length-l.symbols.length),{edges:o,fileCount:n.length,edgeCount:o.length,durationMs:Date.now()-a}}function I(e,a){const t=[];switch(a){case".ts":case".tsx":case".js":case".jsx":{const n=/import\s+(?:type\s+)?\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g;let s;for(;(s=n.exec(e))!==null;){const c=s[1].split(",").map(o=>{const l=o.trim().split(/\s+as\s+/);return(l[l.length-1]||"").trim()}).filter(Boolean);t.push({source:s[2],symbols:c,isRelative:s[2].startsWith(".")})}const r=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g;for(;(s=r.exec(e))!==null;)s[1]!=="type"&&t.push({source:s[2],symbols:[s[1]],isRelative:s[2].startsWith(".")});const i=/(?:const|let|var)\s+\{([^}]+)\}\s*=\s*require\(\s*['"]([^'"]+)['"]\s*\)/g;for(;(s=i.exec(e))!==null;){const c=s[1].split(",").map(o=>o.trim().split(":")[0].trim()).filter(Boolean);t.push({source:s[2],symbols:c,isRelative:s[2].startsWith(".")})}break}case".java":case".kt":case".scala":{const n=/^import\s+(?:static\s+)?([\w.]+)\s*;/gm;let s;for(;(s=n.exec(e))!==null;){const r=s[1].split("."),i=r[r.length-1];i==="*"?t.push({source:s[1],symbols:[],isRelative:P(s[1],e)}):t.push({source:s[1],symbols:[i],isRelative:P(s[1],e)})}break}case".py":{const n=/^from\s+([\w.]+)\s+import\s+(.+)$/gm;let s;for(;(s=n.exec(e))!==null;){const i=s[2].split(",").map(c=>{const o=c.trim().split(/\s+as\s+/);return(o[o.length-1]||"").trim()}).filter(c=>c&&c!=="(");t.push({source:s[1],symbols:i,isRelative:s[1].startsWith(".")})}const r=/^import\s+([\w.]+)(?:\s+as\s+(\w+))?\s*$/gm;for(;(s=r.exec(e))!==null;){const i=s[1].split("."),c=s[2]||i[i.length-1];t.push({source:s[1],symbols:[c],isRelative:s[1].startsWith(".")})}break}case".go":{const n=/import\s+(?:(\w+)\s+)?[""]([^""]+)[""]/g;let s;for(;(s=n.exec(e))!==null;){const i=s[2].split("/"),c=s[1]||i[i.length-1];t.push({source:s[2],symbols:[c],isRelative:!s[2].includes(".")&&!s[2].startsWith("github.com")})}const r=/import\s*\(([\s\S]*?)\)/g;for(;(s=r.exec(e))!==null;){const i=s[1],c=/(?:(\w+)\s+)?[""]([^""]+)[""]/g;let o;for(;(o=c.exec(i))!==null;){const l=o[2].split("/"),g=o[1]||l[l.length-1];t.push({source:o[2],symbols:[g],isRelative:!o[2].includes(".")&&!o[2].startsWith("github.com")})}}break}case".cs":{const n=/^using\s+(?:static\s+)?([\w.]+)\s*;/gm;let s;for(;(s=n.exec(e))!==null;){const r=s[1].split(".");t.push({source:s[1],symbols:[r[r.length-1]],isRelative:!0})}break}case".rs":{const n=/^use\s+([\w:]+(?:::\w+)*)/gm;let s;for(;(s=n.exec(e))!==null;){const r=s[1].split("::"),i=r[r.length-1];t.push({source:s[1],symbols:i==="*"?[]:[i],isRelative:s[1].startsWith("crate")||s[1].startsWith("super")})}break}}return t}function W(e,a){const t=new Set;switch(a){case".ts":case".tsx":case".js":case".jsx":{const n=/export\s+(?:default\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\s+(\w+)/g;let s;for(;(s=n.exec(e))!==null;)t.add(s[1]);break}case".java":case".kt":case".scala":{const n=/(?:public|protected)\s+(?:static\s+)?(?:abstract\s+)?(?:final\s+)?(?:class|interface|enum|record|@interface)\s+(\w+)/g;let s;for(;(s=n.exec(e))!==null;)t.add(s[1]);const r=/(?:public|protected)\s+(?:static\s+)?(?:abstract\s+)?(?:final\s+)?\w+(?:<[^>]+>)?\s+(\w+)\s*\(/g;for(;(s=r.exec(e))!==null;)["if","for","while","switch","catch","return","class","interface","enum","new"].includes(s[1])||t.add(s[1]);break}case".py":{const n=/^(?:def|class)\s+([A-Z_]\w*)/gm;let s;for(;(s=n.exec(e))!==null;)s[1].startsWith("_")||t.add(s[1]);break}case".go":{const n=/^(?:func|type|var|const)\s+(\(?[A-Z]\w*)/gm;let s;for(;(s=n.exec(e))!==null;)t.add(s[1].replace("(",""));break}}return t}function P(e,a){const t=a.match(/^package\s+([\w.]+)\s*;/m);if(!t)return!1;const s=t[1].split("."),r=e.split(".");return s.length>=2&&r.length>=2&&s[0]===r[0]&&s[1]===r[1]}function A(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function C(e,a){switch(a){case".ts":case".tsx":case".js":case".jsx":return e.replace(/^import\s+.+$/gm,"").replace(/^const\s+.+=\s*require\(.+$/gm,"");case".java":case".kt":case".scala":return e.replace(/^import\s+.+;$/gm,"");case".py":return e.replace(/^(?:from\s+.+import\s+.+|import\s+.+)$/gm,"");case".go":return e.replace(/^import\s+.+$/gm,"").replace(/import\s*\([\s\S]*?\)/g,"");case".cs":return e.replace(/^using\s+.+;$/gm,"");case".rs":return e.replace(/^use\s+.+;$/gm,"");default:return e}}function M(e,a){const t=new Map;for(const n of e){const s=y(a,n).replace(/\\/g,"/"),r=s.replace(/\.[^.]+$/,"");j(t,r,s);const i=r.split("/"),c=i[i.length-1];j(t,c,s)}return t}function j(e,a,t){const n=e.get(a);n?n.push(t):e.set(a,[t])}function D(e,a,t,n){switch(n){case".ts":case".tsx":case".js":case".jsx":{if(!a.startsWith("."))return[];const s=e.split("/").slice(0,-1).join("/"),r=N(s?`${s}/${a}`:a);for(const c of["",".ts",".tsx",".js",".jsx","/index.ts","/index.js"]){const o=t.get(r+c)||t.get((r+c).replace(/\.[^.]+$/,""));if(o&&o.length>0)return[o[0]]}const i=t.get(r.replace(/\.[^.]+$/,""));return i?[i[0]]:[]}case".java":case".kt":case".scala":{const s=a.split("."),r=s[s.length-1];if(r==="*")return[];const i=t.get(r);return i?[i[0]]:[]}case".py":{if(a.startsWith(".")){const i=e.split("/").slice(0,-1).join("/"),c=a.replace(/^\.+/,"").replace(/\./g,"/"),o=i?`${i}/${c}`:c,l=o.split("/"),g=t.get(o)||t.get(l[l.length-1]);if(g)return[g[0]]}const s=a.replace(/\./g,"/"),r=t.get(s);return r?[r[0]]:[]}case".go":{const s=a.split("/"),r=s[s.length-1],i=t.get(r);return i?[i[0]]:[]}default:return[]}}function N(e){const a=e.split("/"),t=[];for(const n of a)if(!(n==="."||n==="")){if(n===".."){t.pop();continue}t.push(n)}return t.join("/")}function $(e){return e.split("/").some(t=>t==="test"||t==="tests"||t==="__tests__"||t==="spec"||t==="test_"||t==="__test__")||/\.(test|spec)\.[^.]+$/.test(e)}function T(e){const a=[],t=(n,s)=>{if(!(s>10))try{for(const r of _(n,{withFileTypes:!0})){if(S.has(r.name)||r.name.startsWith("."))continue;const i=E(n,r.name);if(r.isDirectory())t(i,s+1);else{const c=x(r.name).toLowerCase();if(!k.has(c)||r.name.endsWith(".d.ts")||/\.(test|spec)\.[^.]+$/.test(r.name)||y(e,n).replace(/\\/g,"/").split("/").some(l=>l==="test"||l==="tests"||l==="__tests__"||l==="spec"))continue;a.push(i)}}}catch{}};return t(e,0),a}export{q as extractRegexCallGraph};
1
+ import{extname as e,join as t,relative as n}from"node:path";import{readFileSync as r,readdirSync as i}from"node:fs";const a=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,`.venv`,`venv`,`__pycache__`,`target`,`vendor`,`bin`,`obj`]),o=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.java`,`.py`,`.go`,`.cs`,`.kt`,`.scala`,`.rs`,`.rb`,`.php`,`.swift`]);async function s(i){let a=Date.now(),o=v(i);if(o.length===0)return null;let s=o.slice(0,800),u=new Map,m=new Map;for(let t of s){let a=n(i,t).replace(/\\/g,`/`),o=r(t,`utf-8`),s=e(t).toLowerCase(),d=c(o,s);u.set(a,d);let f=l(o,s);m.set(a,f)}let g=p(s,i),y=new Map;for(let[n,a]of u){if(_(n))continue;let o=f(r(t(i,n),`utf-8`),e(n));for(let t of a){if(!t.isRelative)continue;let r=h(n,t.source,g,e(n));if(r.length===0)continue;let i=r[0];if(_(i)||n===i)continue;let a;if(a=t.symbols.length>0?t.symbols.filter(e=>RegExp(`\\b${d(e)}\\b`).test(o)):[`*`],a.length===0)continue;let s=`${n}|${i}`,c=y.get(s);if(c)for(let e of a)c.add(e);else y.set(s,new Set(a))}}let b=[];for(let[e,t]of y){let[n,r]=e.split(`|`);b.push({from:n,to:r,symbols:[...t].sort().slice(0,10)})}return b.sort((e,t)=>t.symbols.length-e.symbols.length),{edges:b,fileCount:s.length,edgeCount:b.length,durationMs:Date.now()-a}}function c(e,t){let n=[];switch(t){case`.ts`:case`.tsx`:case`.js`:case`.jsx`:{let t=/import\s+(?:type\s+)?\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g,r;for(;(r=t.exec(e))!==null;){let e=r[1].split(`,`).map(e=>{let t=e.trim().split(/\s+as\s+/);return(t[t.length-1]||``).trim()}).filter(Boolean);n.push({source:r[2],symbols:e,isRelative:r[2].startsWith(`.`)})}let i=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g;for(;(r=i.exec(e))!==null;)r[1]!==`type`&&n.push({source:r[2],symbols:[r[1]],isRelative:r[2].startsWith(`.`)});let a=/(?:const|let|var)\s+\{([^}]+)\}\s*=\s*require\(\s*['"]([^'"]+)['"]\s*\)/g;for(;(r=a.exec(e))!==null;){let e=r[1].split(`,`).map(e=>e.trim().split(`:`)[0].trim()).filter(Boolean);n.push({source:r[2],symbols:e,isRelative:r[2].startsWith(`.`)})}break}case`.java`:case`.kt`:case`.scala`:{let t=/^import\s+(?:static\s+)?([\w.]+)\s*;/gm,r;for(;(r=t.exec(e))!==null;){let t=r[1].split(`.`),i=t[t.length-1];i===`*`?n.push({source:r[1],symbols:[],isRelative:u(r[1],e)}):n.push({source:r[1],symbols:[i],isRelative:u(r[1],e)})}break}case`.py`:{let t=/^from\s+([\w.]+)\s+import\s+(.+)$/gm,r;for(;(r=t.exec(e))!==null;){let e=r[2].split(`,`).map(e=>{let t=e.trim().split(/\s+as\s+/);return(t[t.length-1]||``).trim()}).filter(e=>e&&e!==`(`);n.push({source:r[1],symbols:e,isRelative:r[1].startsWith(`.`)})}let i=/^import\s+([\w.]+)(?:\s+as\s+(\w+))?\s*$/gm;for(;(r=i.exec(e))!==null;){let e=r[1].split(`.`),t=r[2]||e[e.length-1];n.push({source:r[1],symbols:[t],isRelative:r[1].startsWith(`.`)})}break}case`.go`:{let t=/import\s+(?:(\w+)\s+)?[""]([^""]+)[""]/g,r;for(;(r=t.exec(e))!==null;){let e=r[2].split(`/`),t=r[1]||e[e.length-1];n.push({source:r[2],symbols:[t],isRelative:!r[2].includes(`.`)&&!r[2].startsWith(`github.com`)})}let i=/import\s*\(([\s\S]*?)\)/g;for(;(r=i.exec(e))!==null;){let e=r[1],t=/(?:(\w+)\s+)?[""]([^""]+)[""]/g,i;for(;(i=t.exec(e))!==null;){let e=i[2].split(`/`),t=i[1]||e[e.length-1];n.push({source:i[2],symbols:[t],isRelative:!i[2].includes(`.`)&&!i[2].startsWith(`github.com`)})}}break}case`.cs`:{let t=/^using\s+(?:static\s+)?([\w.]+)\s*;/gm,r;for(;(r=t.exec(e))!==null;){let e=r[1].split(`.`);n.push({source:r[1],symbols:[e[e.length-1]],isRelative:!0})}break}case`.rs`:{let t=/^use\s+([\w:]+(?:::\w+)*)/gm,r;for(;(r=t.exec(e))!==null;){let e=r[1].split(`::`),t=e[e.length-1];n.push({source:r[1],symbols:t===`*`?[]:[t],isRelative:r[1].startsWith(`crate`)||r[1].startsWith(`super`)})}break}}return n}function l(e,t){let n=new Set;switch(t){case`.ts`:case`.tsx`:case`.js`:case`.jsx`:{let t=/export\s+(?:default\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\s+(\w+)/g,r;for(;(r=t.exec(e))!==null;)n.add(r[1]);break}case`.java`:case`.kt`:case`.scala`:{let t=/(?:public|protected)\s+(?:static\s+)?(?:abstract\s+)?(?:final\s+)?(?:class|interface|enum|record|@interface)\s+(\w+)/g,r;for(;(r=t.exec(e))!==null;)n.add(r[1]);let i=/(?:public|protected)\s+(?:static\s+)?(?:abstract\s+)?(?:final\s+)?\w+(?:<[^>]+>)?\s+(\w+)\s*\(/g;for(;(r=i.exec(e))!==null;)[`if`,`for`,`while`,`switch`,`catch`,`return`,`class`,`interface`,`enum`,`new`].includes(r[1])||n.add(r[1]);break}case`.py`:{let t=/^(?:def|class)\s+([A-Z_]\w*)/gm,r;for(;(r=t.exec(e))!==null;)r[1].startsWith(`_`)||n.add(r[1]);break}case`.go`:{let t=/^(?:func|type|var|const)\s+(\(?[A-Z]\w*)/gm,r;for(;(r=t.exec(e))!==null;)n.add(r[1].replace(`(`,``));break}}return n}function u(e,t){let n=t.match(/^package\s+([\w.]+)\s*;/m);if(!n)return!1;let r=n[1].split(`.`),i=e.split(`.`);return r.length>=2&&i.length>=2&&r[0]===i[0]&&r[1]===i[1]}function d(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function f(e,t){switch(t){case`.ts`:case`.tsx`:case`.js`:case`.jsx`:return e.replace(/^import\s+.+$/gm,``).replace(/^const\s+.+=\s*require\(.+$/gm,``);case`.java`:case`.kt`:case`.scala`:return e.replace(/^import\s+.+;$/gm,``);case`.py`:return e.replace(/^(?:from\s+.+import\s+.+|import\s+.+)$/gm,``);case`.go`:return e.replace(/^import\s+.+$/gm,``).replace(/import\s*\([\s\S]*?\)/g,``);case`.cs`:return e.replace(/^using\s+.+;$/gm,``);case`.rs`:return e.replace(/^use\s+.+;$/gm,``);default:return e}}function p(e,t){let r=new Map;for(let i of e){let e=n(t,i).replace(/\\/g,`/`),a=e.replace(/\.[^.]+$/,``);m(r,a,e);let o=a.split(`/`),s=o[o.length-1];m(r,s,e)}return r}function m(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function h(e,t,n,r){switch(r){case`.ts`:case`.tsx`:case`.js`:case`.jsx`:{if(!t.startsWith(`.`))return[];let r=e.split(`/`).slice(0,-1).join(`/`),i=g(r?`${r}/${t}`:t);for(let e of[``,`.ts`,`.tsx`,`.js`,`.jsx`,`/index.ts`,`/index.js`]){let t=n.get(i+e)||n.get((i+e).replace(/\.[^.]+$/,``));if(t&&t.length>0)return[t[0]]}let a=n.get(i.replace(/\.[^.]+$/,``));return a?[a[0]]:[]}case`.java`:case`.kt`:case`.scala`:{let e=t.split(`.`),r=e[e.length-1];if(r===`*`)return[];let i=n.get(r);return i?[i[0]]:[]}case`.py`:{if(t.startsWith(`.`)){let r=e.split(`/`).slice(0,-1).join(`/`),i=t.replace(/^\.+/,``).replace(/\./g,`/`),a=r?`${r}/${i}`:i,o=a.split(`/`),s=n.get(a)||n.get(o[o.length-1]);if(s)return[s[0]]}let r=t.replace(/\./g,`/`),i=n.get(r);return i?[i[0]]:[]}case`.go`:{let e=t.split(`/`),r=e[e.length-1],i=n.get(r);return i?[i[0]]:[]}default:return[]}}function g(e){let t=e.split(`/`),n=[];for(let e of t)if(!(e===`.`||e===``)){if(e===`..`){n.pop();continue}n.push(e)}return n.join(`/`)}function _(e){return e.split(`/`).some(e=>e===`test`||e===`tests`||e===`__tests__`||e===`spec`||e===`test_`||e===`__test__`)||/\.(test|spec)\.[^.]+$/.test(e)}function v(r){let s=[],c=(l,u)=>{if(!(u>10))try{for(let d of i(l,{withFileTypes:!0})){if(a.has(d.name)||d.name.startsWith(`.`))continue;let i=t(l,d.name);if(d.isDirectory())c(i,u+1);else{let t=e(d.name).toLowerCase();if(!o.has(t)||d.name.endsWith(`.d.ts`)||/\.(test|spec)\.[^.]+$/.test(d.name)||n(r,l).replace(/\\/g,`/`).split(`/`).some(e=>e===`test`||e===`tests`||e===`__tests__`||e===`spec`))continue;s.push(i)}}}catch{}};return c(r,0),s}export{s as extractRegexCallGraph};
2
+ //# sourceMappingURL=regex-call-graph.js.map
@@ -1,11 +1,15 @@
1
- import type { AnalysisResult, IAnalyzer, StructureAnalyzerOptions } from './types.js';
2
- export declare class StructureAnalyzer implements IAnalyzer<StructureAnalyzerOptions> {
3
- readonly name = "structure";
4
- analyze(rootPath: string, options?: StructureAnalyzerOptions): Promise<AnalysisResult>;
5
- private buildTree;
6
- private computeStats;
7
- private formatMarkdown;
8
- private renderTree;
9
- private countFiles;
1
+ import { AnalysisResult, IAnalyzer, StructureAnalyzerOptions } from "./types.js";
2
+
3
+ //#region packages/analyzers/src/structure-analyzer.d.ts
4
+ declare class StructureAnalyzer implements IAnalyzer<StructureAnalyzerOptions> {
5
+ readonly name = "structure";
6
+ analyze(rootPath: string, options?: StructureAnalyzerOptions): Promise<AnalysisResult>;
7
+ private buildTree;
8
+ private computeStats;
9
+ private formatMarkdown;
10
+ private renderTree;
11
+ private countFiles;
10
12
  }
13
+ //#endregion
14
+ export { StructureAnalyzer };
11
15
  //# sourceMappingURL=structure-analyzer.d.ts.map
@@ -1,4 +1,3 @@
1
- import{readdir as p,stat as m}from"node:fs/promises";import{extname as d,join as f}from"node:path";const h={src:"Application source",lib:"Library code",dist:"Build output",build:"Build output",test:"Tests",tests:"Tests",spec:"Tests",__tests__:"Tests",docs:"Documentation",scripts:"Build/utility scripts",config:"Configuration",handlers:"Entry point handlers",controllers:"HTTP controllers",routes:"API routes",middleware:"Middleware",services:"Business logic services",domain:"Domain/business logic",infrastructure:"External integrations",adapters:"Adapter implementations",ports:"Port interfaces",models:"Data models",entities:"Domain entities",repositories:"Data access",utils:"Utilities",helpers:"Helper functions",types:"Type definitions",interfaces:"Interface definitions",constants:"Constants",cdk:"CDK infrastructure",stacks:"CDK stacks",constructs:"CDK constructs",lambdas:"Lambda functions",components:"UI components",hooks:"React hooks",pages:"Page components",layouts:"Layout components",store:"State management",assets:"Static assets",styles:"Stylesheets",fixtures:"Test fixtures",mocks:"Test mocks",migrations:"Database migrations"},g={".ts":"TypeScript",".tsx":"React TSX",".js":"JavaScript",".jsx":"React JSX",".mjs":"ES Module",".cjs":"CommonJS",".json":"JSON",".yaml":"YAML",".yml":"YAML",".md":"Markdown",".mdx":"MDX",".py":"Python",".go":"Go",".rs":"Rust",".java":"Java",".sh":"Shell",".ps1":"PowerShell",".css":"CSS",".scss":"SCSS",".html":"HTML",".sql":"SQL",".graphql":"GraphQL",".proto":"Protocol Buffers",".toml":"TOML",".env":"Environment"},y=new Set(["node_modules",".git","dist","build",".next",".nuxt","coverage",".turbo",".cache","__pycache__",".venv",".terraform","cdk.out"]),S=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".java",".kt",".kts",".scala",".py",".go",".rs",".rb",".php",".swift",".cs",".c",".cpp",".h",".hpp",".sh",".bash",".ps1",".sql",".graphql",".gql",".proto",".json",".yaml",".yml",".toml",".env",".ini",".cfg",".xml",".pom",".gradle",".tf",".hcl",".lock",".mjs"]),T=new Set(["__tests__","test","tests","spec","__mocks__","__fixtures__","fixtures","mocks"]);class b{name="structure";async analyze(t,e={}){const{format:r="markdown",maxDepth:s=6,sourceOnly:c=!1}=e,n=Date.now(),i=await this.buildTree(t,0,s,c),o=this.computeStats(i);return{output:r==="json"?JSON.stringify({tree:i,stats:o},null,2):this.formatMarkdown(i,o,t),data:{tree:i,stats:o},meta:{analyzedAt:new Date().toISOString(),scope:t,fileCount:o.totalFiles,durationMs:Date.now()-n}}}async buildTree(t,e,r,s){const c=await p(t,{withFileTypes:!0}),n=[];for(const o of c.sort((l,a)=>l.name.localeCompare(a.name))){if(y.has(o.name)||o.name.startsWith(".")&&o.name!==".env.example")continue;const l=f(t,o.name);if(o.isDirectory()&&e<r){const a=await this.buildTree(l,e+1,r,s);if(s&&(!a.children||a.children.length===0))continue;n.push(a)}else if(o.isFile()){const a=d(o.name).toLowerCase();if(s&&a&&!S.has(a)||s&&!a)continue;const u=await m(l);n.push({name:o.name,type:"file",language:g[a]??(a||"unknown"),size:u.size})}}const i=t.split(/[/\\]/).pop()??t;return{name:i,type:"directory",purpose:h[i.toLowerCase()],children:n}}computeStats(t){const e={};let r=0,s=0;const c=n=>{if(n.type==="file"){r++,s+=n.size??0;const i=n.language??"unknown";e[i]=(e[i]??0)+1}n.children?.forEach(c)};return c(t),{totalFiles:r,totalSize:s,languages:e}}formatMarkdown(t,e,r){const s=[];return s.push(`## Project Structure: ${r}
2
- `),s.push(`**${e.totalFiles} files** | Languages: ${Object.entries(e.languages).map(([c,n])=>`${c} (${n})`).join(", ")}
3
- `),s.push("```"),this.renderTree(t,"",s),s.push("```"),s.join(`
4
- `)}renderTree(t,e,r){const s=t.purpose?` \u2500\u2500 ${t.purpose}`:"";if(t.type==="directory"){const c=t.name.toLowerCase();if(T.has(c)&&t.children){const n=this.countFiles(t);r.push(`${e}${t.name}/${s} (${n} files)`);return}r.push(`${e}${t.name}/${s}`),t.children?.forEach((n,i)=>{const o=i===(t.children?.length??0)-1,l=o?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",a=e+(o?" ":"\u2502 ");n.type==="directory"?this.renderTree(n,a,r):r.push(`${e}${l}${n.name}`)})}else r.push(`${e}${t.name}`)}countFiles(t){return t.type==="file"?1:(t.children??[]).reduce((e,r)=>e+this.countFiles(r),0)}}export{b as StructureAnalyzer};
1
+ import{readdir as e,stat as t}from"node:fs/promises";import{extname as n,join as r}from"node:path";const i={src:`Application source`,lib:`Library code`,dist:`Build output`,build:`Build output`,test:`Tests`,tests:`Tests`,spec:`Tests`,__tests__:`Tests`,docs:`Documentation`,scripts:`Build/utility scripts`,config:`Configuration`,handlers:`Entry point handlers`,controllers:`HTTP controllers`,routes:`API routes`,middleware:`Middleware`,services:`Business logic services`,domain:`Domain/business logic`,infrastructure:`External integrations`,adapters:`Adapter implementations`,ports:`Port interfaces`,models:`Data models`,entities:`Domain entities`,repositories:`Data access`,utils:`Utilities`,helpers:`Helper functions`,types:`Type definitions`,interfaces:`Interface definitions`,constants:`Constants`,cdk:`CDK infrastructure`,stacks:`CDK stacks`,constructs:`CDK constructs`,lambdas:`Lambda functions`,components:`UI components`,hooks:`React hooks`,pages:`Page components`,layouts:`Layout components`,store:`State management`,assets:`Static assets`,styles:`Stylesheets`,fixtures:`Test fixtures`,mocks:`Test mocks`,migrations:`Database migrations`},a={".ts":`TypeScript`,".tsx":`React TSX`,".js":`JavaScript`,".jsx":`React JSX`,".mjs":`ES Module`,".cjs":`CommonJS`,".json":`JSON`,".yaml":`YAML`,".yml":`YAML`,".md":`Markdown`,".mdx":`MDX`,".py":`Python`,".go":`Go`,".rs":`Rust`,".java":`Java`,".sh":`Shell`,".ps1":`PowerShell`,".css":`CSS`,".scss":`SCSS`,".html":`HTML`,".sql":`SQL`,".graphql":`GraphQL`,".proto":`Protocol Buffers`,".toml":`TOML`,".env":`Environment`},o=new Set([`node_modules`,`.git`,`dist`,`build`,`.next`,`.nuxt`,`coverage`,`.turbo`,`.cache`,`__pycache__`,`.venv`,`.terraform`,`cdk.out`]),s=new Set(`.ts,.tsx,.js,.jsx,.mjs,.cjs,.java,.kt,.kts,.scala,.py,.go,.rs,.rb,.php,.swift,.cs,.c,.cpp,.h,.hpp,.sh,.bash,.ps1,.sql,.graphql,.gql,.proto,.json,.yaml,.yml,.toml,.env,.ini,.cfg,.xml,.pom,.gradle,.tf,.hcl,.lock,.mjs`.split(`,`)),c=new Set([`__tests__`,`test`,`tests`,`spec`,`__mocks__`,`__fixtures__`,`fixtures`,`mocks`]);var l=class{name=`structure`;async analyze(e,t={}){let{format:n=`markdown`,maxDepth:r=6,sourceOnly:i=!1}=t,a=Date.now(),o=await this.buildTree(e,0,r,i),s=this.computeStats(o);return{output:n===`json`?JSON.stringify({tree:o,stats:s},null,2):this.formatMarkdown(o,s,e),data:{tree:o,stats:s},meta:{analyzedAt:new Date().toISOString(),scope:e,fileCount:s.totalFiles,durationMs:Date.now()-a}}}async buildTree(c,l,u,d){let f=await e(c,{withFileTypes:!0}),p=[];for(let e of f.sort((e,t)=>e.name.localeCompare(t.name))){if(o.has(e.name)||e.name.startsWith(`.`)&&e.name!==`.env.example`)continue;let i=r(c,e.name);if(e.isDirectory()&&l<u){let e=await this.buildTree(i,l+1,u,d);if(d&&(!e.children||e.children.length===0))continue;p.push(e)}else if(e.isFile()){let r=n(e.name).toLowerCase();if(d&&r&&!s.has(r)||d&&!r)continue;let o=await t(i);p.push({name:e.name,type:`file`,language:a[r]??(r||`unknown`),size:o.size})}}let m=c.split(/[/\\]/).pop()??c;return{name:m,type:`directory`,purpose:i[m.toLowerCase()],children:p}}computeStats(e){let t={},n=0,r=0,i=e=>{if(e.type===`file`){n++,r+=e.size??0;let i=e.language??`unknown`;t[i]=(t[i]??0)+1}e.children?.forEach(i)};return i(e),{totalFiles:n,totalSize:r,languages:t}}formatMarkdown(e,t,n){let r=[];return r.push(`## Project Structure: ${n}\n`),r.push(`**${t.totalFiles} files** | Languages: ${Object.entries(t.languages).map(([e,t])=>`${e} (${t})`).join(`, `)}\n`),r.push("```"),this.renderTree(e,``,r),r.push("```"),r.join(`
2
+ `)}renderTree(e,t,n){let r=e.purpose?` ── ${e.purpose}`:``;if(e.type===`directory`){let i=e.name.toLowerCase();if(c.has(i)&&e.children){let i=this.countFiles(e);n.push(`${t}${e.name}/${r} (${i} files)`);return}n.push(`${t}${e.name}/${r}`),e.children?.forEach((r,i)=>{let a=i===(e.children?.length??0)-1,o=a?`└── `:`├── `,s=t+(a?` `:`│ `);r.type===`directory`?this.renderTree(r,s,n):n.push(`${t}${o}${r.name}`)})}else n.push(`${t}${e.name}`)}countFiles(e){return e.type===`file`?1:(e.children??[]).reduce((e,t)=>e+this.countFiles(t),0)}};export{l as StructureAnalyzer};
3
+ //# sourceMappingURL=structure-analyzer.js.map
@@ -1,10 +1,14 @@
1
- import type { AnalysisResult, IAnalyzer, SymbolAnalyzerOptions } from './types.js';
2
- export declare class SymbolAnalyzer implements IAnalyzer<SymbolAnalyzerOptions> {
3
- readonly name = "symbols";
4
- analyze(rootPath: string, options?: SymbolAnalyzerOptions): Promise<AnalysisResult>;
5
- private collectFiles;
6
- private extractSymbols;
7
- private groupByKind;
8
- private formatMarkdown;
1
+ import { AnalysisResult, IAnalyzer, SymbolAnalyzerOptions } from "./types.js";
2
+
3
+ //#region packages/analyzers/src/symbol-analyzer.d.ts
4
+ declare class SymbolAnalyzer implements IAnalyzer<SymbolAnalyzerOptions> {
5
+ readonly name = "symbols";
6
+ analyze(rootPath: string, options?: SymbolAnalyzerOptions): Promise<AnalysisResult>;
7
+ private collectFiles;
8
+ private extractSymbols;
9
+ private groupByKind;
10
+ private formatMarkdown;
9
11
  }
12
+ //#endregion
13
+ export { SymbolAnalyzer };
10
14
  //# sourceMappingURL=symbol-analyzer.d.ts.map
@@ -1,13 +1,8 @@
1
- import{readdir as S,readFile as A}from"node:fs/promises";import{extname as y,join as T,relative as P}from"node:path";const v=new Set([".ts",".tsx",".js",".jsx",".java",".py",".go",".cs",".rb",".kt",".scala",".rs",".php",".swift"]),E=new Set(["node_modules",".git","dist","build","coverage",".turbo",".cache","cdk.out","__pycache__",".venv","target","bin","obj",".gradle","venv","env"]),b={exported:[{pattern:/^export\s+(?:async\s+)?function\s+(\w+)/gm,kind:"function"},{pattern:/^export\s+(?:default\s+)?class\s+(\w+)/gm,kind:"class"},{pattern:/^export\s+interface\s+(\w+)/gm,kind:"interface"},{pattern:/^export\s+type\s+(\w+)/gm,kind:"type"},{pattern:/^export\s+(?:const|let)\s+(\w+)/gm,kind:"const"},{pattern:/^export\s+enum\s+(\w+)/gm,kind:"enum"}],local:[{pattern:/^(?:async\s+)?function\s+(\w+)/gm,kind:"function"},{pattern:/^class\s+(\w+)/gm,kind:"class"},{pattern:/^interface\s+(\w+)/gm,kind:"interface"},{pattern:/^type\s+(\w+)/gm,kind:"type"},{pattern:/^(?:const|let)\s+(\w+)\s*=/gm,kind:"const"},{pattern:/^enum\s+(\w+)/gm,kind:"enum"}]},I={exported:[{pattern:/^[ \t]*public\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:"class"},{pattern:/^[ \t]*public\s+(?:static\s+)?interface\s+(\w+)/gm,kind:"interface"},{pattern:/^[ \t]*public\s+(?:static\s+)?enum\s+(\w+)/gm,kind:"enum"},{pattern:/^[ \t]*public\s+(?:static\s+)?(?:synchronized\s+)?(?:final\s+)?(?:abstract\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])*)\s+(\w+)\s*\(/gm,kind:"function"}],local:[{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:"class"},{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:synchronized\s+)?(?:final\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])*)\s+(\w+)\s*\(/gm,kind:"function"},{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:final\s+)?(?:\w+(?:<[^>]*>)?)\s+(\w+)\s*[;=]/gm,kind:"variable"}],skipIndentFilter:!0},R={exported:[{pattern:/^def\s+(\w+)\s*\(/gm,kind:"function"},{pattern:/^async\s+def\s+(\w+)\s*\(/gm,kind:"function"},{pattern:/^class\s+(\w+)/gm,kind:"class"}],local:[{pattern:/^[ \t]+def\s+(\w+)\s*\(/gm,kind:"function"},{pattern:/^[ \t]+async\s+def\s+(\w+)\s*\(/gm,kind:"function"}],skipIndentFilter:!0},_={exported:[{pattern:/^func\s+([A-Z]\w*)\s*\(/gm,kind:"function"},{pattern:/^func\s+\([^)]+\)\s+([A-Z]\w*)\s*\(/gm,kind:"function"},{pattern:/^type\s+([A-Z]\w*)\s+struct\b/gm,kind:"class"},{pattern:/^type\s+([A-Z]\w*)\s+interface\b/gm,kind:"interface"},{pattern:/^type\s+([A-Z]\w*)\s+/gm,kind:"type"}],local:[{pattern:/^func\s+([a-z]\w*)\s*\(/gm,kind:"function"},{pattern:/^func\s+\([^)]+\)\s+([a-z]\w*)\s*\(/gm,kind:"function"},{pattern:/^type\s+([a-z]\w*)\s+struct\b/gm,kind:"class"},{pattern:/^type\s+([a-z]\w*)\s+/gm,kind:"type"}],skipIndentFilter:!0},F={exported:[{pattern:/^[ \t]*public\s+(?:static\s+)?(?:partial\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:"class"},{pattern:/^[ \t]*public\s+(?:static\s+)?interface\s+(\w+)/gm,kind:"interface"},{pattern:/^[ \t]*public\s+(?:static\s+)?enum\s+(\w+)/gm,kind:"enum"},{pattern:/^[ \t]*public\s+(?:static\s+)?(?:virtual\s+)?(?:override\s+)?(?:async\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])?)\s+(\w+)\s*\(/gm,kind:"function"}],local:[{pattern:/^[ \t]*(?:private|protected|internal)\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:"class"},{pattern:/^[ \t]*(?:private|protected|internal)\s+(?:static\s+)?(?:async\s+)?(?:\w+(?:<[^>]*>)?)\s+(\w+)\s*\(/gm,kind:"function"}],skipIndentFilter:!0},L={exported:[{pattern:/^(?:open\s+|data\s+|sealed\s+)?class\s+(\w+)/gm,kind:"class"},{pattern:/^(?:fun|suspend\s+fun)\s+(\w+)\s*[(<]/gm,kind:"function"},{pattern:/^interface\s+(\w+)/gm,kind:"interface"},{pattern:/^object\s+(\w+)/gm,kind:"class"},{pattern:/^enum\s+class\s+(\w+)/gm,kind:"enum"}],local:[{pattern:/^[ \t]+(?:private|internal)\s+(?:fun|suspend\s+fun)\s+(\w+)/gm,kind:"function"},{pattern:/^[ \t]+(?:private|internal)\s+(?:val|var)\s+(\w+)/gm,kind:"variable"}],skipIndentFilter:!0},j={exported:[{pattern:/^class\s+(\w+)/gm,kind:"class"},{pattern:/^module\s+(\w+)/gm,kind:"class"},{pattern:/^[ \t]+def\s+self\.(\w+)/gm,kind:"function"}],local:[{pattern:/^[ \t]+def\s+(\w+)/gm,kind:"function"}],skipIndentFilter:!0},$={exported:[{pattern:/^pub\s+(?:async\s+)?fn\s+(\w+)/gm,kind:"function"},{pattern:/^pub\s+struct\s+(\w+)/gm,kind:"class"},{pattern:/^pub\s+trait\s+(\w+)/gm,kind:"interface"},{pattern:/^pub\s+enum\s+(\w+)/gm,kind:"enum"},{pattern:/^pub\s+type\s+(\w+)/gm,kind:"type"}],local:[{pattern:/^(?:async\s+)?fn\s+(\w+)/gm,kind:"function"},{pattern:/^struct\s+(\w+)/gm,kind:"class"},{pattern:/^trait\s+(\w+)/gm,kind:"interface"},{pattern:/^enum\s+(\w+)/gm,kind:"enum"}],skipIndentFilter:!0},O={exported:[{pattern:/^[ \t]*(?:abstract\s+)?class\s+(\w+)/gm,kind:"class"},{pattern:/^[ \t]*interface\s+(\w+)/gm,kind:"interface"},{pattern:/^[ \t]*public\s+(?:static\s+)?function\s+(\w+)/gm,kind:"function"},{pattern:/^function\s+(\w+)\s*\(/gm,kind:"function"}],local:[{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?function\s+(\w+)/gm,kind:"function"}],skipIndentFilter:!0},N={exported:[{pattern:/^[ \t]*(?:open|public)\s+class\s+(\w+)/gm,kind:"class"},{pattern:/^[ \t]*(?:open|public)\s+struct\s+(\w+)/gm,kind:"class"},{pattern:/^[ \t]*(?:open|public)\s+protocol\s+(\w+)/gm,kind:"interface"},{pattern:/^[ \t]*(?:open|public)\s+enum\s+(\w+)/gm,kind:"enum"},{pattern:/^[ \t]*(?:open|public)\s+func\s+(\w+)/gm,kind:"function"}],local:[{pattern:/^[ \t]*(?:private|fileprivate|internal)\s+func\s+(\w+)/gm,kind:"function"},{pattern:/^[ \t]*(?:private|fileprivate|internal)\s+class\s+(\w+)/gm,kind:"class"}],skipIndentFilter:!0},z={exported:[{pattern:/^[ \t]*(?:case\s+)?class\s+(\w+)/gm,kind:"class"},{pattern:/^[ \t]*object\s+(\w+)/gm,kind:"class"},{pattern:/^[ \t]*trait\s+(\w+)/gm,kind:"interface"},{pattern:/^[ \t]*def\s+(\w+)/gm,kind:"function"}],local:[],skipIndentFilter:!0};function C(k){switch(k){case".ts":case".tsx":case".js":case".jsx":return b;case".java":return I;case".py":return R;case".go":return _;case".cs":return F;case".kt":return L;case".rb":return j;case".rs":return $;case".php":return O;case".swift":return N;case".scala":return z;default:return b}}function h(k,s){let r="",e=0,c=!1;for(let o=s;o<Math.min(s+5,k.length);o++){const i=k[o].trim();r+=(r?" ":"")+i;for(const n of i)n==="("&&(e++,c=!0),n===")"&&e--;if(c&&e<=0)return r.replace(/\s*\{.*$/,"").replace(/\s*:\s*$/,"").trim()}return r.trim()||void 0}class U{name="symbols";async analyze(s,r={}){const{format:e="markdown",filter:c}=r,o=Date.now(),i=await this.collectFiles(s);let n=[];for(const a of i){const d=await A(a,"utf-8"),t=this.extractSymbols(d,P(s,a).replace(/\\/g,"/"));n.push(...t)}if(c){const a=c.toLowerCase();n=n.filter(d=>d.name.toLowerCase().includes(a))}return{output:e==="json"?JSON.stringify(n,null,2):this.formatMarkdown(n,s),data:{symbols:n,byKind:this.groupByKind(n),exportedCount:n.filter(a=>a.exported).length,totalCount:n.length},meta:{analyzedAt:new Date().toISOString(),scope:s,fileCount:i.length,durationMs:Date.now()-o}}}async collectFiles(s){const r=[],e=async c=>{const o=await S(c,{withFileTypes:!0});for(const i of o){if(E.has(i.name)||i.name.startsWith("."))continue;const n=T(c,i.name);i.isDirectory()?await e(n):v.has(y(i.name))&&r.push(n)}};return await e(s),r}extractSymbols(s,r){const e=[],c=s.split(`
2
- `),o=new Set,i=y(r),n=C(i);for(const{pattern:u,kind:a}of n.exported){const d=new RegExp(u.source,u.flags);let t;for(;(t=d.exec(s))!==null;){const l=t[1];o.add(l);const p=s.slice(0,t.index).split(`
3
- `).length,f=a==="function"||a==="method"?h(c,p-1):void 0;e.push({name:l,kind:a,exported:!0,filePath:r,line:p,signature:f})}}for(const{pattern:u,kind:a}of n.local){const d=new RegExp(u.source,u.flags);let t;for(;(t=d.exec(s))!==null;){const l=t[1];if(o.has(l))continue;if(!n.skipIndentFilter){const m=s.slice(0,t.index).split(`
4
- `).length-1,w=c[m]??"";if(w.startsWith(" ")||w.startsWith(" "))continue}const p=s.slice(0,t.index).split(`
5
- `).length,f=a==="function"||a==="method"?h(c,p-1):void 0;e.push({name:l,kind:a,exported:!1,filePath:r,line:p,signature:f})}}return e}groupByKind(s){const r={};for(const e of s)r[e.kind]=(r[e.kind]??0)+1;return r}formatMarkdown(s,r){const e=[],c=s.filter(t=>t.exported).length;e.push(`## Symbols: ${r}
6
- `),e.push(`**${s.length} symbols** (${c} exported)
7
- `);const o={};for(const t of s)o[t.kind]=(o[t.kind]??0)+1;const i=Object.entries(o).sort((t,l)=>l[1]-t[1]).map(([t,l])=>{const p=t==="class"?"classes":`${t}s`;return`${l} ${p}`}).join(", ");e.push(`**Breakdown**: ${i}
8
- `);const n={};for(const t of s)n[t.filePath]||(n[t.filePath]=[]),n[t.filePath].push(t);e.push(`**${Object.keys(n).length} files** with symbols
9
- `);let u=0;const a=80*1024,d=Object.entries(n).sort((t,l)=>{const p=t[1].filter(m=>m.exported).length;return l[1].filter(m=>m.exported).length-p});for(const[t,l]of d){const p=l.filter(g=>g.exported);if(p.length===0)continue;const f=[`### ${t}
10
- `];for(const g of p){const x=g.signature?` \u2014 \`${g.signature}\``:"";f.push(`- \u{1F4E4} \`${g.kind}\` **${g.name}** (line ${g.line})${x}`)}const m=l.length-p.length;m>0&&f.push(`- _${m} internal ${m===1?"symbol":"symbols"}_`),f.push("");const w=f.join(`
11
- `);if(u+=w.length,u>a){e.push(`
12
- _Output truncated at 80KB. ${Object.keys(n).length-e.filter(g=>g.startsWith("### ")).length} files omitted._`);break}e.push(w)}return e.join(`
13
- `)}}export{U as SymbolAnalyzer};
1
+ import{readFile as e,readdir as t}from"node:fs/promises";import{extname as n,join as r,relative as i}from"node:path";const a=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.java`,`.py`,`.go`,`.cs`,`.rb`,`.kt`,`.scala`,`.rs`,`.php`,`.swift`]),o=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,`__pycache__`,`.venv`,`target`,`bin`,`obj`,`.gradle`,`venv`,`env`]),s={exported:[{pattern:/^export\s+(?:async\s+)?function\s+(\w+)/gm,kind:`function`},{pattern:/^export\s+(?:default\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^export\s+interface\s+(\w+)/gm,kind:`interface`},{pattern:/^export\s+type\s+(\w+)/gm,kind:`type`},{pattern:/^export\s+(?:const|let)\s+(\w+)/gm,kind:`const`},{pattern:/^export\s+enum\s+(\w+)/gm,kind:`enum`}],local:[{pattern:/^(?:async\s+)?function\s+(\w+)/gm,kind:`function`},{pattern:/^class\s+(\w+)/gm,kind:`class`},{pattern:/^interface\s+(\w+)/gm,kind:`interface`},{pattern:/^type\s+(\w+)/gm,kind:`type`},{pattern:/^(?:const|let)\s+(\w+)\s*=/gm,kind:`const`},{pattern:/^enum\s+(\w+)/gm,kind:`enum`}]},c={exported:[{pattern:/^[ \t]*public\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*public\s+(?:static\s+)?interface\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*public\s+(?:static\s+)?enum\s+(\w+)/gm,kind:`enum`},{pattern:/^[ \t]*public\s+(?:static\s+)?(?:synchronized\s+)?(?:final\s+)?(?:abstract\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])*)\s+(\w+)\s*\(/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:synchronized\s+)?(?:final\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])*)\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:final\s+)?(?:\w+(?:<[^>]*>)?)\s+(\w+)\s*[;=]/gm,kind:`variable`}],skipIndentFilter:!0},l={exported:[{pattern:/^def\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^async\s+def\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^class\s+(\w+)/gm,kind:`class`}],local:[{pattern:/^[ \t]+def\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^[ \t]+async\s+def\s+(\w+)\s*\(/gm,kind:`function`}],skipIndentFilter:!0},u={exported:[{pattern:/^func\s+([A-Z]\w*)\s*\(/gm,kind:`function`},{pattern:/^func\s+\([^)]+\)\s+([A-Z]\w*)\s*\(/gm,kind:`function`},{pattern:/^type\s+([A-Z]\w*)\s+struct\b/gm,kind:`class`},{pattern:/^type\s+([A-Z]\w*)\s+interface\b/gm,kind:`interface`},{pattern:/^type\s+([A-Z]\w*)\s+/gm,kind:`type`}],local:[{pattern:/^func\s+([a-z]\w*)\s*\(/gm,kind:`function`},{pattern:/^func\s+\([^)]+\)\s+([a-z]\w*)\s*\(/gm,kind:`function`},{pattern:/^type\s+([a-z]\w*)\s+struct\b/gm,kind:`class`},{pattern:/^type\s+([a-z]\w*)\s+/gm,kind:`type`}],skipIndentFilter:!0},d={exported:[{pattern:/^[ \t]*public\s+(?:static\s+)?(?:partial\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*public\s+(?:static\s+)?interface\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*public\s+(?:static\s+)?enum\s+(\w+)/gm,kind:`enum`},{pattern:/^[ \t]*public\s+(?:static\s+)?(?:virtual\s+)?(?:override\s+)?(?:async\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])?)\s+(\w+)\s*\(/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|protected|internal)\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:private|protected|internal)\s+(?:static\s+)?(?:async\s+)?(?:\w+(?:<[^>]*>)?)\s+(\w+)\s*\(/gm,kind:`function`}],skipIndentFilter:!0},f={exported:[{pattern:/^(?:open\s+|data\s+|sealed\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^(?:fun|suspend\s+fun)\s+(\w+)\s*[(<]/gm,kind:`function`},{pattern:/^interface\s+(\w+)/gm,kind:`interface`},{pattern:/^object\s+(\w+)/gm,kind:`class`},{pattern:/^enum\s+class\s+(\w+)/gm,kind:`enum`}],local:[{pattern:/^[ \t]+(?:private|internal)\s+(?:fun|suspend\s+fun)\s+(\w+)/gm,kind:`function`},{pattern:/^[ \t]+(?:private|internal)\s+(?:val|var)\s+(\w+)/gm,kind:`variable`}],skipIndentFilter:!0},p={exported:[{pattern:/^class\s+(\w+)/gm,kind:`class`},{pattern:/^module\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]+def\s+self\.(\w+)/gm,kind:`function`}],local:[{pattern:/^[ \t]+def\s+(\w+)/gm,kind:`function`}],skipIndentFilter:!0},m={exported:[{pattern:/^pub\s+(?:async\s+)?fn\s+(\w+)/gm,kind:`function`},{pattern:/^pub\s+struct\s+(\w+)/gm,kind:`class`},{pattern:/^pub\s+trait\s+(\w+)/gm,kind:`interface`},{pattern:/^pub\s+enum\s+(\w+)/gm,kind:`enum`},{pattern:/^pub\s+type\s+(\w+)/gm,kind:`type`}],local:[{pattern:/^(?:async\s+)?fn\s+(\w+)/gm,kind:`function`},{pattern:/^struct\s+(\w+)/gm,kind:`class`},{pattern:/^trait\s+(\w+)/gm,kind:`interface`},{pattern:/^enum\s+(\w+)/gm,kind:`enum`}],skipIndentFilter:!0},h={exported:[{pattern:/^[ \t]*(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*interface\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*public\s+(?:static\s+)?function\s+(\w+)/gm,kind:`function`},{pattern:/^function\s+(\w+)\s*\(/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?function\s+(\w+)/gm,kind:`function`}],skipIndentFilter:!0},g={exported:[{pattern:/^[ \t]*(?:open|public)\s+class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:open|public)\s+struct\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:open|public)\s+protocol\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*(?:open|public)\s+enum\s+(\w+)/gm,kind:`enum`},{pattern:/^[ \t]*(?:open|public)\s+func\s+(\w+)/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|fileprivate|internal)\s+func\s+(\w+)/gm,kind:`function`},{pattern:/^[ \t]*(?:private|fileprivate|internal)\s+class\s+(\w+)/gm,kind:`class`}],skipIndentFilter:!0},_={exported:[{pattern:/^[ \t]*(?:case\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*object\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*trait\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*def\s+(\w+)/gm,kind:`function`}],local:[],skipIndentFilter:!0};function v(e){switch(e){case`.ts`:case`.tsx`:case`.js`:case`.jsx`:return s;case`.java`:return c;case`.py`:return l;case`.go`:return u;case`.cs`:return d;case`.kt`:return f;case`.rb`:return p;case`.rs`:return m;case`.php`:return h;case`.swift`:return g;case`.scala`:return _;default:return s}}function y(e,t){let n=``,r=0,i=!1;for(let a=t;a<Math.min(t+5,e.length);a++){let t=e[a].trim();n+=(n?` `:``)+t;for(let e of t)e===`(`&&(r++,i=!0),e===`)`&&r--;if(i&&r<=0)return n.replace(/\s*\{.*$/,``).replace(/\s*:\s*$/,``).trim()}return n.trim()||void 0}var b=class{name=`symbols`;async analyze(t,n={}){let{format:r=`markdown`,filter:a}=n,o=Date.now(),s=await this.collectFiles(t),c=[];for(let n of s){let r=await e(n,`utf-8`),a=this.extractSymbols(r,i(t,n).replace(/\\/g,`/`));c.push(...a)}if(a){let e=a.toLowerCase();c=c.filter(t=>t.name.toLowerCase().includes(e))}return{output:r===`json`?JSON.stringify(c,null,2):this.formatMarkdown(c,t),data:{symbols:c,byKind:this.groupByKind(c),exportedCount:c.filter(e=>e.exported).length,totalCount:c.length},meta:{analyzedAt:new Date().toISOString(),scope:t,fileCount:s.length,durationMs:Date.now()-o}}}async collectFiles(e){let i=[],s=async e=>{let c=await t(e,{withFileTypes:!0});for(let t of c){if(o.has(t.name)||t.name.startsWith(`.`))continue;let c=r(e,t.name);t.isDirectory()?await s(c):a.has(n(t.name))&&i.push(c)}};return await s(e),i}extractSymbols(e,t){let r=[],i=e.split(`
2
+ `),a=new Set,o=v(n(t));for(let{pattern:n,kind:s}of o.exported){let o=new RegExp(n.source,n.flags),c;for(;(c=o.exec(e))!==null;){let n=c[1];a.add(n);let o=e.slice(0,c.index).split(`
3
+ `).length,l=s===`function`||s===`method`?y(i,o-1):void 0;r.push({name:n,kind:s,exported:!0,filePath:t,line:o,signature:l})}}for(let{pattern:n,kind:s}of o.local){let c=new RegExp(n.source,n.flags),l;for(;(l=c.exec(e))!==null;){let n=l[1];if(a.has(n))continue;if(!o.skipIndentFilter){let t=i[e.slice(0,l.index).split(`
4
+ `).length-1]??``;if(t.startsWith(` `)||t.startsWith(` `))continue}let c=e.slice(0,l.index).split(`
5
+ `).length,u=s===`function`||s===`method`?y(i,c-1):void 0;r.push({name:n,kind:s,exported:!1,filePath:t,line:c,signature:u})}}return r}groupByKind(e){let t={};for(let n of e)t[n.kind]=(t[n.kind]??0)+1;return t}formatMarkdown(e,t){let n=[],r=e.filter(e=>e.exported).length;n.push(`## Symbols: ${t}\n`),n.push(`**${e.length} symbols** (${r} exported)\n`);let i={};for(let t of e)i[t.kind]=(i[t.kind]??0)+1;let a=Object.entries(i).sort((e,t)=>t[1]-e[1]).map(([e,t])=>`${t} ${e===`class`?`classes`:`${e}s`}`).join(`, `);n.push(`**Breakdown**: ${a}\n`);let o={};for(let t of e)o[t.filePath]||(o[t.filePath]=[]),o[t.filePath].push(t);n.push(`**${Object.keys(o).length} files** with symbols\n`);let s=0,c=Object.entries(o).sort((e,t)=>{let n=e[1].filter(e=>e.exported).length;return t[1].filter(e=>e.exported).length-n});for(let[e,t]of c){let r=t.filter(e=>e.exported);if(r.length===0)continue;let i=[`### ${e}\n`];for(let e of r){let t=e.signature?` — \`${e.signature}\``:``;i.push(`- 📤 \`${e.kind}\` **${e.name}** (line ${e.line})${t}`)}let a=t.length-r.length;a>0&&i.push(`- _${a} internal ${a===1?`symbol`:`symbols`}_`),i.push(``);let c=i.join(`
6
+ `);if(s+=c.length,s>81920){n.push(`\n_Output truncated at 80KB. ${Object.keys(o).length-n.filter(e=>e.startsWith(`### `)).length} files omitted._`);break}n.push(c)}return n.join(`
7
+ `)}};export{b as SymbolAnalyzer};
8
+ //# sourceMappingURL=symbol-analyzer.js.map
@@ -1,3 +1,4 @@
1
+ //#region packages/analyzers/src/ts-call-graph.d.ts
1
2
  /**
2
3
  * TypeScript Compiler API-based call graph extractor.
3
4
  *
@@ -5,23 +6,25 @@
5
6
  * the AST to find function call sites and resolve them to their declaration files.
6
7
  * Produces module-level call edges: which modules call functions in which other modules.
7
8
  */
8
- export interface ModuleCallEdge {
9
- /** Caller module (relative path) */
10
- from: string;
11
- /** Callee module (relative path) */
12
- to: string;
13
- /** Function/symbol names called across this edge */
14
- symbols: string[];
9
+ interface ModuleCallEdge {
10
+ /** Caller module (relative path) */
11
+ from: string;
12
+ /** Callee module (relative path) */
13
+ to: string;
14
+ /** Function/symbol names called across this edge */
15
+ symbols: string[];
15
16
  }
16
- export interface CallGraphResult {
17
- edges: ModuleCallEdge[];
18
- fileCount: number;
19
- edgeCount: number;
20
- durationMs: number;
17
+ interface CallGraphResult {
18
+ edges: ModuleCallEdge[];
19
+ fileCount: number;
20
+ edgeCount: number;
21
+ durationMs: number;
21
22
  }
22
23
  /**
23
24
  * Extract module-level call graph from a TypeScript/JavaScript project.
24
25
  * Returns null if TypeScript compiler is unavailable or no TS files found.
25
26
  */
26
- export declare function extractTsCallGraph(rootPath: string): Promise<CallGraphResult | null>;
27
+ declare function extractTsCallGraph(rootPath: string): Promise<CallGraphResult | null>;
28
+ //#endregion
29
+ export { CallGraphResult, ModuleCallEdge, extractTsCallGraph };
27
30
  //# sourceMappingURL=ts-call-graph.d.ts.map
@@ -1 +1,2 @@
1
- import{existsSync as m,readdirSync as y,readFileSync as b}from"node:fs";import{extname as F,join as g,relative as d}from"node:path";const S=new Set(["node_modules",".git","dist","build","coverage",".turbo",".cache","cdk.out"]);async function _(e){const t=Date.now();if(!T(e))return null;let s;try{s=await import("typescript")}catch{return null}const i=w(e);if(i.length===0)return null;const r=i.slice(0,800),c=x(s,e),n=s.createProgram(r,{...c,noEmit:!0,skipLibCheck:!0,allowJs:!0,target:s.ScriptTarget.ESNext,module:s.ModuleKind.ESNext,moduleResolution:s.ModuleResolutionKind.Bundler}),o=n.getTypeChecker(),f=new Map;for(const l of n.getSourceFiles()){const a=l.fileName;if(l.isDeclarationFile||a.includes("node_modules"))continue;const p=d(e,a).replace(/\\/g,"/");p.startsWith("..")||h(s,l,l,o,e,p,f)}const u=[];for(const[l,a]of f){const[p,C]=l.split("|");u.push({from:p,to:C,symbols:[...a].sort().slice(0,10)})}return u.sort((l,a)=>a.symbols.length-l.symbols.length),{edges:u,fileCount:r.length,edgeCount:u.length,durationMs:Date.now()-t}}function T(e){if(m(g(e,"tsconfig.json"))||m(g(e,"tsconfig.build.json")))return!0;try{for(const t of y(e,{withFileTypes:!0}))if(t.isDirectory()&&!S.has(t.name)&&!t.name.startsWith(".")&&m(g(e,t.name,"tsconfig.json")))return!0}catch{}return!1}function x(e,t){const s=g(t,"tsconfig.json");if(!m(s))return{};try{const i=e.readConfigFile(s,c=>b(c,"utf-8"));return i.error?{}:e.parseJsonConfigFileContent(i.config,e.sys,t).options}catch{return{}}}function w(e){const t=[],s=new Set([".ts",".tsx"]),i=(r,c)=>{if(!(c>10))try{for(const n of y(r,{withFileTypes:!0})){if(S.has(n.name)||n.name.startsWith("."))continue;const o=g(r,n.name);if(n.isDirectory())i(o,c+1);else if(s.has(F(n.name))){if(n.name.endsWith(".d.ts")||/\.(test|spec)\.[jt]sx?$/.test(n.name)||d(e,r).replace(/\\/g,"/").split("/").some(u=>u==="test"||u==="tests"||u==="__tests__"||u==="spec"))continue;t.push(o)}}}catch{}};return i(e,0),t}function h(e,t,s,i,r,c,n){if(e.isCallExpression(t)||e.isNewExpression(t)){const o=t.expression;D(e,o,i,r,c,n)}e.forEachChild(t,o=>{h(e,o,s,i,r,c,n)})}function E(e){const t=e.match(/^(.+?)\/dist\/(.+)$/);if(!t)return e;const[,s,i]=t,r=i.replace(/\.d\.(m?ts|cts)$/,".ts");return`${s}/src/${r}`}function D(e,t,s,i,r,c){try{let n,o;if(e.isIdentifier(t)?(n=s.getSymbolAtLocation(t),o=t.text):e.isPropertyAccessExpression(t)&&(n=s.getSymbolAtLocation(t.name),o=t.name.text),!n||!o)return;n.flags&e.SymbolFlags.Alias&&(n=s.getAliasedSymbol(n));const f=n.getDeclarations();if(!f||f.length===0)return;const u=f[0].getSourceFile().fileName;if(u.includes("node_modules"))return;let l=d(i,u).replace(/\\/g,"/");if(l=E(l),l===r||l.startsWith(".."))return;const a=`${r}|${l}`,p=c.get(a);p?p.add(o):c.set(a,new Set([o]))}catch{}}export{_ as extractTsCallGraph};
1
+ import{extname as e,join as t,relative as n}from"node:path";import{existsSync as r,readFileSync as i,readdirSync as a}from"node:fs";const o=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`]);async function s(e){let t=Date.now();if(!c(e))return null;let r;try{r=await import(`typescript`)}catch{return null}let i=u(e);if(i.length===0)return null;let a=i.slice(0,800),o=l(r,e),s=r.createProgram(a,{...o,noEmit:!0,skipLibCheck:!0,allowJs:!0,target:r.ScriptTarget.ESNext,module:r.ModuleKind.ESNext,moduleResolution:r.ModuleResolutionKind.Bundler}),f=s.getTypeChecker(),p=new Map;for(let t of s.getSourceFiles()){let i=t.fileName;if(t.isDeclarationFile||i.includes(`node_modules`))continue;let a=n(e,i).replace(/\\/g,`/`);a.startsWith(`..`)||d(r,t,t,f,e,a,p)}let m=[];for(let[e,t]of p){let[n,r]=e.split(`|`);m.push({from:n,to:r,symbols:[...t].sort().slice(0,10)})}return m.sort((e,t)=>t.symbols.length-e.symbols.length),{edges:m,fileCount:a.length,edgeCount:m.length,durationMs:Date.now()-t}}function c(e){if(r(t(e,`tsconfig.json`))||r(t(e,`tsconfig.build.json`)))return!0;try{for(let n of a(e,{withFileTypes:!0}))if(n.isDirectory()&&!o.has(n.name)&&!n.name.startsWith(`.`)&&r(t(e,n.name,`tsconfig.json`)))return!0}catch{}return!1}function l(e,n){let a=t(n,`tsconfig.json`);if(!r(a))return{};try{let t=e.readConfigFile(a,e=>i(e,`utf-8`));return t.error?{}:e.parseJsonConfigFileContent(t.config,e.sys,n).options}catch{return{}}}function u(r){let i=[],s=new Set([`.ts`,`.tsx`]),c=(l,u)=>{if(!(u>10))try{for(let d of a(l,{withFileTypes:!0})){if(o.has(d.name)||d.name.startsWith(`.`))continue;let a=t(l,d.name);if(d.isDirectory())c(a,u+1);else if(s.has(e(d.name))){if(d.name.endsWith(`.d.ts`)||/\.(test|spec)\.[jt]sx?$/.test(d.name)||n(r,l).replace(/\\/g,`/`).split(`/`).some(e=>e===`test`||e===`tests`||e===`__tests__`||e===`spec`))continue;i.push(a)}}}catch{}};return c(r,0),i}function d(e,t,n,r,i,a,o){if(e.isCallExpression(t)||e.isNewExpression(t)){let n=t.expression;p(e,n,r,i,a,o)}e.forEachChild(t,t=>{d(e,t,n,r,i,a,o)})}function f(e){let t=e.match(/^(.+?)\/dist\/(.+)$/);if(!t)return e;let[,n,r]=t;return`${n}/src/${r.replace(/\.d\.(m?ts|cts)$/,`.ts`)}`}function p(e,t,r,i,a,o){try{let s,c;if(e.isIdentifier(t)?(s=r.getSymbolAtLocation(t),c=t.text):e.isPropertyAccessExpression(t)&&(s=r.getSymbolAtLocation(t.name),c=t.name.text),!s||!c)return;s.flags&e.SymbolFlags.Alias&&(s=r.getAliasedSymbol(s));let l=s.getDeclarations();if(!l||l.length===0)return;let u=l[0].getSourceFile().fileName;if(u.includes(`node_modules`))return;let d=n(i,u).replace(/\\/g,`/`);if(d=f(d),d===a||d.startsWith(`..`))return;let p=`${a}|${d}`,m=o.get(p);m?m.add(c):o.set(p,new Set([c]))}catch{}}export{s as extractTsCallGraph};
2
+ //# sourceMappingURL=ts-call-graph.js.map