spectra-cli 4.1.1 → 4.2.0

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 (422) hide show
  1. package/README.md +1 -1
  2. package/dist/adapters/go-adapter.d.ts.map +1 -1
  3. package/dist/adapters/go-adapter.js +2 -0
  4. package/dist/adapters/go-adapter.js.map +1 -1
  5. package/dist/adapters/index.d.ts +1 -1
  6. package/dist/adapters/index.d.ts.map +1 -1
  7. package/dist/adapters/java-adapter.d.ts.map +1 -1
  8. package/dist/adapters/java-adapter.js +2 -0
  9. package/dist/adapters/java-adapter.js.map +1 -1
  10. package/dist/adapters/language-adapter.d.ts +47 -9
  11. package/dist/adapters/language-adapter.d.ts.map +1 -1
  12. package/dist/adapters/python-adapter.d.ts +34 -6
  13. package/dist/adapters/python-adapter.d.ts.map +1 -1
  14. package/dist/adapters/python-adapter.js +157 -59
  15. package/dist/adapters/python-adapter.js.map +1 -1
  16. package/dist/adapters/ts-js-adapter.d.ts +13 -5
  17. package/dist/adapters/ts-js-adapter.d.ts.map +1 -1
  18. package/dist/adapters/ts-js-adapter.js +55 -14
  19. package/dist/adapters/ts-js-adapter.js.map +1 -1
  20. package/dist/batch/batch-orchestrator.d.ts +30 -4
  21. package/dist/batch/batch-orchestrator.d.ts.map +1 -1
  22. package/dist/batch/batch-orchestrator.js +284 -7
  23. package/dist/batch/batch-orchestrator.js.map +1 -1
  24. package/dist/batch/delta-regenerator.d.ts +2 -2
  25. package/dist/batch/delta-regenerator.d.ts.map +1 -1
  26. package/dist/batch/delta-regenerator.js.map +1 -1
  27. package/dist/batch/module-grouper.d.ts +2 -2
  28. package/dist/batch/module-grouper.d.ts.map +1 -1
  29. package/dist/batch/module-grouper.js +1 -1
  30. package/dist/batch/module-grouper.js.map +1 -1
  31. package/dist/cli/commands/graph.js +1 -1
  32. package/dist/cli/commands/graph.js.map +1 -1
  33. package/dist/cli/commands/index.d.ts +8 -0
  34. package/dist/cli/commands/index.d.ts.map +1 -0
  35. package/dist/cli/commands/index.js +274 -0
  36. package/dist/cli/commands/index.js.map +1 -0
  37. package/dist/cli/commands/query.d.ts.map +1 -1
  38. package/dist/cli/commands/query.js +3 -1
  39. package/dist/cli/commands/query.js.map +1 -1
  40. package/dist/cli/index.js +9 -9
  41. package/dist/cli/index.js.map +1 -1
  42. package/dist/cli/utils/parse-args.d.ts +13 -1
  43. package/dist/cli/utils/parse-args.d.ts.map +1 -1
  44. package/dist/cli/utils/parse-args.js +79 -2
  45. package/dist/cli/utils/parse-args.js.map +1 -1
  46. package/dist/core/ast-analyzer.d.ts.map +1 -1
  47. package/dist/core/ast-analyzer.js +79 -5
  48. package/dist/core/ast-analyzer.js.map +1 -1
  49. package/dist/core/import-resolver.d.ts +90 -0
  50. package/dist/core/import-resolver.d.ts.map +1 -0
  51. package/dist/core/import-resolver.js +273 -0
  52. package/dist/core/import-resolver.js.map +1 -0
  53. package/dist/core/query-mappers/base-mapper.d.ts +13 -0
  54. package/dist/core/query-mappers/base-mapper.d.ts.map +1 -1
  55. package/dist/core/query-mappers/go-mapper.d.ts +68 -0
  56. package/dist/core/query-mappers/go-mapper.d.ts.map +1 -1
  57. package/dist/core/query-mappers/go-mapper.js +421 -0
  58. package/dist/core/query-mappers/go-mapper.js.map +1 -1
  59. package/dist/core/query-mappers/java-mapper.d.ts +196 -0
  60. package/dist/core/query-mappers/java-mapper.d.ts.map +1 -1
  61. package/dist/core/query-mappers/java-mapper.js +600 -0
  62. package/dist/core/query-mappers/java-mapper.js.map +1 -1
  63. package/dist/core/query-mappers/python-mapper.d.ts +55 -0
  64. package/dist/core/query-mappers/python-mapper.d.ts.map +1 -1
  65. package/dist/core/query-mappers/python-mapper.js +273 -0
  66. package/dist/core/query-mappers/python-mapper.js.map +1 -1
  67. package/dist/core/query-mappers/typescript-mapper.d.ts +102 -0
  68. package/dist/core/query-mappers/typescript-mapper.d.ts.map +1 -1
  69. package/dist/core/query-mappers/typescript-mapper.js +470 -0
  70. package/dist/core/query-mappers/typescript-mapper.js.map +1 -1
  71. package/dist/core/single-spec-orchestrator.d.ts.map +1 -1
  72. package/dist/core/single-spec-orchestrator.js +146 -9
  73. package/dist/core/single-spec-orchestrator.js.map +1 -1
  74. package/dist/core/tree-sitter-analyzer.d.ts +6 -0
  75. package/dist/core/tree-sitter-analyzer.d.ts.map +1 -1
  76. package/dist/core/tree-sitter-analyzer.js +33 -1
  77. package/dist/core/tree-sitter-analyzer.js.map +1 -1
  78. package/dist/core/tree-sitter-fallback.d.ts +7 -4
  79. package/dist/core/tree-sitter-fallback.d.ts.map +1 -1
  80. package/dist/core/tree-sitter-fallback.js +157 -12
  81. package/dist/core/tree-sitter-fallback.js.map +1 -1
  82. package/dist/extraction/extraction-types.d.ts +25 -25
  83. package/dist/generator/index-generator.d.ts +3 -3
  84. package/dist/generator/index-generator.d.ts.map +1 -1
  85. package/dist/generator/index-generator.js +1 -1
  86. package/dist/generator/index-generator.js.map +1 -1
  87. package/dist/graph/directory-graph.d.ts +14 -4
  88. package/dist/graph/directory-graph.d.ts.map +1 -1
  89. package/dist/graph/directory-graph.js +71 -128
  90. package/dist/graph/directory-graph.js.map +1 -1
  91. package/dist/graph/mermaid-renderer.d.ts +8 -5
  92. package/dist/graph/mermaid-renderer.d.ts.map +1 -1
  93. package/dist/graph/mermaid-renderer.js +3 -3
  94. package/dist/graph/mermaid-renderer.js.map +1 -1
  95. package/dist/graph/topological-sort.d.ts +13 -6
  96. package/dist/graph/topological-sort.d.ts.map +1 -1
  97. package/dist/graph/topological-sort.js +2 -2
  98. package/dist/graph/topological-sort.js.map +1 -1
  99. package/dist/knowledge-graph/call-resolver.d.ts +64 -0
  100. package/dist/knowledge-graph/call-resolver.d.ts.map +1 -0
  101. package/dist/knowledge-graph/call-resolver.js +323 -0
  102. package/dist/knowledge-graph/call-resolver.js.map +1 -0
  103. package/dist/knowledge-graph/import-resolver.d.ts +114 -0
  104. package/dist/knowledge-graph/import-resolver.d.ts.map +1 -0
  105. package/dist/knowledge-graph/import-resolver.js +537 -0
  106. package/dist/knowledge-graph/import-resolver.js.map +1 -0
  107. package/dist/knowledge-graph/incremental.d.ts +110 -0
  108. package/dist/knowledge-graph/incremental.d.ts.map +1 -0
  109. package/dist/knowledge-graph/incremental.js +410 -0
  110. package/dist/knowledge-graph/incremental.js.map +1 -0
  111. package/dist/knowledge-graph/index.d.ts +74 -0
  112. package/dist/knowledge-graph/index.d.ts.map +1 -0
  113. package/dist/knowledge-graph/index.js +156 -0
  114. package/dist/knowledge-graph/index.js.map +1 -0
  115. package/dist/knowledge-graph/module-derivation.d.ts +238 -0
  116. package/dist/knowledge-graph/module-derivation.d.ts.map +1 -0
  117. package/dist/knowledge-graph/module-derivation.js +418 -0
  118. package/dist/knowledge-graph/module-derivation.js.map +1 -0
  119. package/dist/knowledge-graph/persistence.d.ts +270 -0
  120. package/dist/knowledge-graph/persistence.d.ts.map +1 -0
  121. package/dist/knowledge-graph/persistence.js +226 -0
  122. package/dist/knowledge-graph/persistence.js.map +1 -0
  123. package/dist/knowledge-graph/query-helpers.d.ts +164 -0
  124. package/dist/knowledge-graph/query-helpers.d.ts.map +1 -0
  125. package/dist/knowledge-graph/query-helpers.js +394 -0
  126. package/dist/knowledge-graph/query-helpers.js.map +1 -0
  127. package/dist/knowledge-graph/unified-graph.d.ts +310 -0
  128. package/dist/knowledge-graph/unified-graph.d.ts.map +1 -0
  129. package/dist/knowledge-graph/unified-graph.js +182 -0
  130. package/dist/knowledge-graph/unified-graph.js.map +1 -0
  131. package/dist/mcp/agent-context-tools.d.ts +104 -0
  132. package/dist/mcp/agent-context-tools.d.ts.map +1 -0
  133. package/dist/mcp/agent-context-tools.js +854 -0
  134. package/dist/mcp/agent-context-tools.js.map +1 -0
  135. package/dist/mcp/graph-tools.d.ts +20 -0
  136. package/dist/mcp/graph-tools.d.ts.map +1 -1
  137. package/dist/mcp/graph-tools.js +71 -11
  138. package/dist/mcp/graph-tools.js.map +1 -1
  139. package/dist/mcp/lib/response-helpers.d.ts +67 -0
  140. package/dist/mcp/lib/response-helpers.d.ts.map +1 -0
  141. package/dist/mcp/lib/response-helpers.js +103 -0
  142. package/dist/mcp/lib/response-helpers.js.map +1 -0
  143. package/dist/mcp/server.d.ts +3 -1
  144. package/dist/mcp/server.d.ts.map +1 -1
  145. package/dist/mcp/server.js +9 -10
  146. package/dist/mcp/server.js.map +1 -1
  147. package/dist/models/call-site.d.ts +68 -0
  148. package/dist/models/call-site.d.ts.map +1 -0
  149. package/dist/models/call-site.js +60 -0
  150. package/dist/models/call-site.js.map +1 -0
  151. package/dist/models/code-skeleton.d.ts +78 -6
  152. package/dist/models/code-skeleton.d.ts.map +1 -1
  153. package/dist/models/code-skeleton.js +29 -0
  154. package/dist/models/code-skeleton.js.map +1 -1
  155. package/dist/models/drift-item.d.ts +4 -4
  156. package/dist/models/module-spec.d.ts +155 -94
  157. package/dist/models/module-spec.d.ts.map +1 -1
  158. package/dist/panoramic/adr-decision-pipeline.d.ts +53 -0
  159. package/dist/panoramic/adr-decision-pipeline.d.ts.map +1 -0
  160. package/dist/panoramic/adr-decision-pipeline.js +685 -0
  161. package/dist/panoramic/adr-decision-pipeline.js.map +1 -0
  162. package/dist/panoramic/api-surface-generator.d.ts +56 -0
  163. package/dist/panoramic/api-surface-generator.d.ts.map +1 -0
  164. package/dist/panoramic/api-surface-generator.js +1671 -0
  165. package/dist/panoramic/api-surface-generator.js.map +1 -0
  166. package/dist/panoramic/architecture-ir-builder.d.ts +19 -0
  167. package/dist/panoramic/architecture-ir-builder.d.ts.map +1 -0
  168. package/dist/panoramic/architecture-ir-builder.js +561 -0
  169. package/dist/panoramic/architecture-ir-builder.js.map +1 -0
  170. package/dist/panoramic/architecture-ir-exporters.d.ts +7 -0
  171. package/dist/panoramic/architecture-ir-exporters.d.ts.map +1 -0
  172. package/dist/panoramic/architecture-ir-exporters.js +183 -0
  173. package/dist/panoramic/architecture-ir-exporters.js.map +1 -0
  174. package/dist/panoramic/architecture-ir-generator.d.ts +36 -0
  175. package/dist/panoramic/architecture-ir-generator.d.ts.map +1 -0
  176. package/dist/panoramic/architecture-ir-generator.js +51 -0
  177. package/dist/panoramic/architecture-ir-generator.js.map +1 -0
  178. package/dist/panoramic/architecture-ir-mermaid-adapter.d.ts +6 -0
  179. package/dist/panoramic/architecture-ir-mermaid-adapter.d.ts.map +1 -0
  180. package/dist/panoramic/architecture-ir-mermaid-adapter.js +98 -0
  181. package/dist/panoramic/architecture-ir-mermaid-adapter.js.map +1 -0
  182. package/dist/panoramic/architecture-ir-model.d.ts +87 -0
  183. package/dist/panoramic/architecture-ir-model.d.ts.map +1 -0
  184. package/dist/panoramic/architecture-ir-model.js +20 -0
  185. package/dist/panoramic/architecture-ir-model.js.map +1 -0
  186. package/dist/panoramic/architecture-narrative.d.ts +68 -0
  187. package/dist/panoramic/architecture-narrative.d.ts.map +1 -0
  188. package/dist/panoramic/architecture-narrative.js +401 -0
  189. package/dist/panoramic/architecture-narrative.js.map +1 -0
  190. package/dist/panoramic/architecture-overview-generator.d.ts +31 -0
  191. package/dist/panoramic/architecture-overview-generator.d.ts.map +1 -0
  192. package/dist/panoramic/architecture-overview-generator.js +454 -0
  193. package/dist/panoramic/architecture-overview-generator.js.map +1 -0
  194. package/dist/panoramic/architecture-overview-model.d.ts +77 -0
  195. package/dist/panoramic/architecture-overview-model.d.ts.map +1 -0
  196. package/dist/panoramic/architecture-overview-model.js +31 -0
  197. package/dist/panoramic/architecture-overview-model.js.map +1 -0
  198. package/dist/panoramic/batch-project-docs.d.ts.map +1 -1
  199. package/dist/panoramic/batch-project-docs.js +4 -2
  200. package/dist/panoramic/batch-project-docs.js.map +1 -1
  201. package/dist/panoramic/builders/component-view-builder.d.ts +25 -1
  202. package/dist/panoramic/builders/component-view-builder.d.ts.map +1 -1
  203. package/dist/panoramic/builders/component-view-builder.js +83 -3
  204. package/dist/panoramic/builders/component-view-builder.js.map +1 -1
  205. package/dist/panoramic/builders/doc-graph-builder.d.ts +2 -2
  206. package/dist/panoramic/builders/doc-graph-builder.d.ts.map +1 -1
  207. package/dist/panoramic/builders/doc-graph-builder.js.map +1 -1
  208. package/dist/panoramic/component-view-builder.d.ts +17 -0
  209. package/dist/panoramic/component-view-builder.d.ts.map +1 -0
  210. package/dist/panoramic/component-view-builder.js +652 -0
  211. package/dist/panoramic/component-view-builder.js.map +1 -0
  212. package/dist/panoramic/component-view-model.d.ts +127 -0
  213. package/dist/panoramic/component-view-model.d.ts.map +1 -0
  214. package/dist/panoramic/component-view-model.js +65 -0
  215. package/dist/panoramic/component-view-model.js.map +1 -0
  216. package/dist/panoramic/config-reference-generator.d.ts +78 -0
  217. package/dist/panoramic/config-reference-generator.d.ts.map +1 -0
  218. package/dist/panoramic/config-reference-generator.js +199 -0
  219. package/dist/panoramic/config-reference-generator.js.map +1 -0
  220. package/dist/panoramic/coverage-auditor.d.ts +95 -0
  221. package/dist/panoramic/coverage-auditor.d.ts.map +1 -0
  222. package/dist/panoramic/coverage-auditor.js +290 -0
  223. package/dist/panoramic/coverage-auditor.js.map +1 -0
  224. package/dist/panoramic/cross-package-analyzer.d.ts +112 -0
  225. package/dist/panoramic/cross-package-analyzer.d.ts.map +1 -0
  226. package/dist/panoramic/cross-package-analyzer.js +258 -0
  227. package/dist/panoramic/cross-package-analyzer.js.map +1 -0
  228. package/dist/panoramic/data-model-generator.d.ts +528 -0
  229. package/dist/panoramic/data-model-generator.d.ts.map +1 -0
  230. package/dist/panoramic/data-model-generator.js +647 -0
  231. package/dist/panoramic/data-model-generator.js.map +1 -0
  232. package/dist/panoramic/doc-graph-builder.d.ts +80 -0
  233. package/dist/panoramic/doc-graph-builder.d.ts.map +1 -0
  234. package/dist/panoramic/doc-graph-builder.js +352 -0
  235. package/dist/panoramic/doc-graph-builder.js.map +1 -0
  236. package/dist/panoramic/docs-bundle-manifest-reader.d.ts +26 -0
  237. package/dist/panoramic/docs-bundle-manifest-reader.d.ts.map +1 -0
  238. package/dist/panoramic/docs-bundle-manifest-reader.js +106 -0
  239. package/dist/panoramic/docs-bundle-manifest-reader.js.map +1 -0
  240. package/dist/panoramic/docs-bundle-orchestrator.d.ts +14 -0
  241. package/dist/panoramic/docs-bundle-orchestrator.d.ts.map +1 -0
  242. package/dist/panoramic/docs-bundle-orchestrator.js +538 -0
  243. package/dist/panoramic/docs-bundle-orchestrator.js.map +1 -0
  244. package/dist/panoramic/docs-bundle-profiles.d.ts +4 -0
  245. package/dist/panoramic/docs-bundle-profiles.d.ts.map +1 -0
  246. package/dist/panoramic/docs-bundle-profiles.js +82 -0
  247. package/dist/panoramic/docs-bundle-profiles.js.map +1 -0
  248. package/dist/panoramic/docs-bundle-types.d.ts +94 -0
  249. package/dist/panoramic/docs-bundle-types.d.ts.map +1 -0
  250. package/dist/panoramic/docs-bundle-types.js +10 -0
  251. package/dist/panoramic/docs-bundle-types.js.map +1 -0
  252. package/dist/panoramic/docs-quality-evaluator.d.ts +31 -0
  253. package/dist/panoramic/docs-quality-evaluator.d.ts.map +1 -0
  254. package/dist/panoramic/docs-quality-evaluator.js +941 -0
  255. package/dist/panoramic/docs-quality-evaluator.js.map +1 -0
  256. package/dist/panoramic/docs-quality-model.d.ts +125 -0
  257. package/dist/panoramic/docs-quality-model.d.ts.map +1 -0
  258. package/dist/panoramic/docs-quality-model.js +166 -0
  259. package/dist/panoramic/docs-quality-model.js.map +1 -0
  260. package/dist/panoramic/dynamic-scenarios-builder.d.ts +18 -0
  261. package/dist/panoramic/dynamic-scenarios-builder.d.ts.map +1 -0
  262. package/dist/panoramic/dynamic-scenarios-builder.js +316 -0
  263. package/dist/panoramic/dynamic-scenarios-builder.js.map +1 -0
  264. package/dist/panoramic/event-surface-generator.d.ts +52 -0
  265. package/dist/panoramic/event-surface-generator.d.ts.map +1 -0
  266. package/dist/panoramic/event-surface-generator.js +507 -0
  267. package/dist/panoramic/event-surface-generator.js.map +1 -0
  268. package/dist/panoramic/generator-registry.d.ts +1 -1
  269. package/dist/panoramic/generator-registry.d.ts.map +1 -1
  270. package/dist/panoramic/generator-registry.js +5 -2
  271. package/dist/panoramic/generator-registry.js.map +1 -1
  272. package/dist/panoramic/generators/cross-package-analyzer.d.ts +5 -5
  273. package/dist/panoramic/generators/cross-package-analyzer.d.ts.map +1 -1
  274. package/dist/panoramic/generators/cross-package-analyzer.js +1 -1
  275. package/dist/panoramic/generators/cross-package-analyzer.js.map +1 -1
  276. package/dist/panoramic/generators/data-model-generator.d.ts +27 -27
  277. package/dist/panoramic/graph/confidence-mapper.d.ts +18 -0
  278. package/dist/panoramic/graph/confidence-mapper.d.ts.map +1 -1
  279. package/dist/panoramic/graph/confidence-mapper.js +26 -0
  280. package/dist/panoramic/graph/confidence-mapper.js.map +1 -1
  281. package/dist/panoramic/graph/graph-builder.d.ts.map +1 -1
  282. package/dist/panoramic/graph/graph-builder.js +78 -0
  283. package/dist/panoramic/graph/graph-builder.js.map +1 -1
  284. package/dist/panoramic/graph/graph-paths.d.ts +8 -0
  285. package/dist/panoramic/graph/graph-paths.d.ts.map +1 -1
  286. package/dist/panoramic/graph/graph-paths.js +10 -0
  287. package/dist/panoramic/graph/graph-paths.js.map +1 -1
  288. package/dist/panoramic/graph/graph-query.d.ts +33 -2
  289. package/dist/panoramic/graph/graph-query.d.ts.map +1 -1
  290. package/dist/panoramic/graph/graph-query.js +69 -19
  291. package/dist/panoramic/graph/graph-query.js.map +1 -1
  292. package/dist/panoramic/graph/graph-types.d.ts +32 -3
  293. package/dist/panoramic/graph/graph-types.d.ts.map +1 -1
  294. package/dist/panoramic/hyperedges/schema.d.ts +6 -6
  295. package/dist/panoramic/interface-surface-generator.d.ts +50 -0
  296. package/dist/panoramic/interface-surface-generator.d.ts.map +1 -0
  297. package/dist/panoramic/interface-surface-generator.js +388 -0
  298. package/dist/panoramic/interface-surface-generator.js.map +1 -0
  299. package/dist/panoramic/interfaces.d.ts +2 -2
  300. package/dist/panoramic/mock-readme-generator.d.ts +90 -0
  301. package/dist/panoramic/mock-readme-generator.d.ts.map +1 -0
  302. package/dist/panoramic/mock-readme-generator.js +111 -0
  303. package/dist/panoramic/mock-readme-generator.js.map +1 -0
  304. package/dist/panoramic/models/component-view-model.d.ts +1 -1
  305. package/dist/panoramic/models/component-view-model.d.ts.map +1 -1
  306. package/dist/panoramic/models/component-view-model.js.map +1 -1
  307. package/dist/panoramic/narrative-provenance-adapter.d.ts +8 -0
  308. package/dist/panoramic/narrative-provenance-adapter.d.ts.map +1 -0
  309. package/dist/panoramic/narrative-provenance-adapter.js +99 -0
  310. package/dist/panoramic/narrative-provenance-adapter.js.map +1 -0
  311. package/dist/panoramic/parser-registry.d.ts +1 -1
  312. package/dist/panoramic/parser-registry.js +1 -1
  313. package/dist/panoramic/parsers/types.d.ts +6 -6
  314. package/dist/panoramic/pattern-hints-generator.d.ts +28 -0
  315. package/dist/panoramic/pattern-hints-generator.d.ts.map +1 -0
  316. package/dist/panoramic/pattern-hints-generator.js +218 -0
  317. package/dist/panoramic/pattern-hints-generator.js.map +1 -0
  318. package/dist/panoramic/pattern-hints-model.d.ts +89 -0
  319. package/dist/panoramic/pattern-hints-model.d.ts.map +1 -0
  320. package/dist/panoramic/pattern-hints-model.js +61 -0
  321. package/dist/panoramic/pattern-hints-model.js.map +1 -0
  322. package/dist/panoramic/pattern-knowledge-base.d.ts +31 -0
  323. package/dist/panoramic/pattern-knowledge-base.d.ts.map +1 -0
  324. package/dist/panoramic/pattern-knowledge-base.js +407 -0
  325. package/dist/panoramic/pattern-knowledge-base.js.map +1 -0
  326. package/dist/panoramic/pipelines/coverage-auditor.d.ts.map +1 -1
  327. package/dist/panoramic/pipelines/coverage-auditor.js +4 -2
  328. package/dist/panoramic/pipelines/coverage-auditor.js.map +1 -1
  329. package/dist/panoramic/pipelines/docs-bundle-orchestrator.js +13 -6
  330. package/dist/panoramic/pipelines/docs-bundle-orchestrator.js.map +1 -1
  331. package/dist/panoramic/pipelines/product-ux-docs.d.ts +5 -0
  332. package/dist/panoramic/pipelines/product-ux-docs.d.ts.map +1 -1
  333. package/dist/panoramic/pipelines/product-ux-docs.js +34 -6
  334. package/dist/panoramic/pipelines/product-ux-docs.js.map +1 -1
  335. package/dist/panoramic/product-ux-docs.d.ts +104 -0
  336. package/dist/panoramic/product-ux-docs.d.ts.map +1 -0
  337. package/dist/panoramic/product-ux-docs.js +817 -0
  338. package/dist/panoramic/product-ux-docs.js.map +1 -0
  339. package/dist/panoramic/qa/__tests__/citation.test.d.ts +2 -0
  340. package/dist/panoramic/qa/__tests__/citation.test.d.ts.map +1 -0
  341. package/dist/panoramic/qa/__tests__/citation.test.js +193 -0
  342. package/dist/panoramic/qa/__tests__/citation.test.js.map +1 -0
  343. package/dist/panoramic/qa/__tests__/debt-context.test.d.ts +2 -0
  344. package/dist/panoramic/qa/__tests__/debt-context.test.d.ts.map +1 -0
  345. package/dist/panoramic/qa/__tests__/debt-context.test.js +154 -0
  346. package/dist/panoramic/qa/__tests__/debt-context.test.js.map +1 -0
  347. package/dist/panoramic/qa/__tests__/graph-retriever.test.d.ts +2 -0
  348. package/dist/panoramic/qa/__tests__/graph-retriever.test.d.ts.map +1 -0
  349. package/dist/panoramic/qa/__tests__/graph-retriever.test.js +148 -0
  350. package/dist/panoramic/qa/__tests__/graph-retriever.test.js.map +1 -0
  351. package/dist/panoramic/qa/__tests__/index.test.d.ts +2 -0
  352. package/dist/panoramic/qa/__tests__/index.test.d.ts.map +1 -0
  353. package/dist/panoramic/qa/__tests__/index.test.js +246 -0
  354. package/dist/panoramic/qa/__tests__/index.test.js.map +1 -0
  355. package/dist/panoramic/qa/__tests__/llm-caller.test.d.ts +2 -0
  356. package/dist/panoramic/qa/__tests__/llm-caller.test.d.ts.map +1 -0
  357. package/dist/panoramic/qa/__tests__/llm-caller.test.js +168 -0
  358. package/dist/panoramic/qa/__tests__/llm-caller.test.js.map +1 -0
  359. package/dist/panoramic/qa/__tests__/prompt-builder.test.d.ts +2 -0
  360. package/dist/panoramic/qa/__tests__/prompt-builder.test.d.ts.map +1 -0
  361. package/dist/panoramic/qa/__tests__/prompt-builder.test.js +150 -0
  362. package/dist/panoramic/qa/__tests__/prompt-builder.test.js.map +1 -0
  363. package/dist/panoramic/qa/__tests__/qa-integration.test.d.ts +2 -0
  364. package/dist/panoramic/qa/__tests__/qa-integration.test.d.ts.map +1 -0
  365. package/dist/panoramic/qa/__tests__/qa-integration.test.js +296 -0
  366. package/dist/panoramic/qa/__tests__/qa-integration.test.js.map +1 -0
  367. package/dist/panoramic/qa/__tests__/rag-reranker.test.d.ts +2 -0
  368. package/dist/panoramic/qa/__tests__/rag-reranker.test.d.ts.map +1 -0
  369. package/dist/panoramic/qa/__tests__/rag-reranker.test.js +136 -0
  370. package/dist/panoramic/qa/__tests__/rag-reranker.test.js.map +1 -0
  371. package/dist/panoramic/qa/index.d.ts.map +1 -1
  372. package/dist/panoramic/qa/index.js +10 -3
  373. package/dist/panoramic/qa/index.js.map +1 -1
  374. package/dist/panoramic/runtime-topology-generator.d.ts +77 -0
  375. package/dist/panoramic/runtime-topology-generator.d.ts.map +1 -0
  376. package/dist/panoramic/runtime-topology-generator.js +676 -0
  377. package/dist/panoramic/runtime-topology-generator.js.map +1 -0
  378. package/dist/panoramic/runtime-topology-model.d.ts +145 -0
  379. package/dist/panoramic/runtime-topology-model.d.ts.map +1 -0
  380. package/dist/panoramic/runtime-topology-model.js +300 -0
  381. package/dist/panoramic/runtime-topology-model.js.map +1 -0
  382. package/dist/panoramic/troubleshooting-generator.d.ts +51 -0
  383. package/dist/panoramic/troubleshooting-generator.d.ts.map +1 -0
  384. package/dist/panoramic/troubleshooting-generator.js +451 -0
  385. package/dist/panoramic/troubleshooting-generator.js.map +1 -0
  386. package/dist/panoramic/utils/text-segmenter.d.ts +15 -0
  387. package/dist/panoramic/utils/text-segmenter.d.ts.map +1 -1
  388. package/dist/panoramic/utils/text-segmenter.js +38 -0
  389. package/dist/panoramic/utils/text-segmenter.js.map +1 -1
  390. package/dist/panoramic/workspace-index-generator.d.ts +148 -0
  391. package/dist/panoramic/workspace-index-generator.d.ts.map +1 -0
  392. package/dist/panoramic/workspace-index-generator.js +497 -0
  393. package/dist/panoramic/workspace-index-generator.js.map +1 -0
  394. package/dist/runtime-bootstrap.d.ts +9 -0
  395. package/dist/runtime-bootstrap.d.ts.map +1 -0
  396. package/dist/runtime-bootstrap.js +33 -0
  397. package/dist/runtime-bootstrap.js.map +1 -0
  398. package/dist/utils/file-scanner.js +1 -1
  399. package/dist/utils/file-scanner.js.map +1 -1
  400. package/package.json +12 -2
  401. package/plugins/spec-driver/.claude-plugin/plugin.json +1 -1
  402. package/plugins/spec-driver/README.md +18 -1
  403. package/plugins/spec-driver/agents/implement.md +20 -1
  404. package/plugins/spec-driver/agents/plan.md +20 -1
  405. package/plugins/spec-driver/agents/quality-review.md +20 -1
  406. package/plugins/spec-driver/agents/spec-review.md +20 -1
  407. package/plugins/spec-driver/agents/verify.md +20 -1
  408. package/plugins/spec-driver/docs/customization.md +134 -0
  409. package/plugins/spec-driver/docs/spectra-mcp-integration.md +165 -0
  410. package/plugins/spec-driver/lib/preference-rules.mjs +96 -0
  411. package/plugins/spec-driver/scripts/postinstall.sh +1 -1
  412. package/plugins/spec-driver/scripts/sync-preference-rules.mjs +148 -0
  413. package/plugins/spec-driver/skills/spec-driver-feature/SKILL.md +10 -0
  414. package/plugins/spec-driver/skills/spec-driver-fix/SKILL.md +10 -0
  415. package/plugins/spec-driver/skills/spec-driver-implement/SKILL.md +10 -0
  416. package/plugins/spec-driver/skills/spec-driver-refactor/SKILL.md +10 -0
  417. package/plugins/spec-driver/skills/spec-driver-story/SKILL.md +10 -0
  418. package/plugins/spec-driver/templates/preference-rules.md +39 -0
  419. package/plugins/spectra/.claude-plugin/plugin.json +1 -1
  420. package/plugins/spectra/README.md +48 -1
  421. package/plugins/spectra/hooks/post-commit.sh +40 -0
  422. package/templates/product-overview.hbs +1 -1
@@ -0,0 +1,652 @@
1
+ /**
2
+ * Component view builder
3
+ *
4
+ * 基于 ArchitectureIR + stored module specs 生成关键组件视图。
5
+ */
6
+ import * as path from 'node:path';
7
+ import { dedupeComponentEvidence, summarizeComponentView, } from './component-view-model.js';
8
+ import { loadTemplate } from './utils/template-loader.js';
9
+ import { sanitizeMermaidId } from './utils/mermaid-helpers.js';
10
+ const CLASSLIKE_KINDS = new Set(['class', 'interface', 'type', 'data_class', 'struct', 'protocol']);
11
+ const CORE_METHOD_RE = /(query|connect|request|stream|send|receive|parse|publish|subscribe|load|save|persist|session|interrupt|control|run|execute|process)/i;
12
+ const HIGH_SIGNAL_NAME_RE = /(query|client|transport|parser|session|store|adapter|service|runtime|protocol|message|gateway|manager)/i;
13
+ export function buildComponentView(options) {
14
+ const maxComponents = options.maxComponents ?? 12;
15
+ const warnings = new Set();
16
+ const narrativeNames = collectNarrativeNames(options.architectureNarrative);
17
+ const packageElements = options.architectureIR.elements.filter((element) => element.id.startsWith('package:'));
18
+ const groupElements = options.architectureIR.elements.filter((element) => element.id.startsWith('group:'));
19
+ if (options.storedModules.length === 0) {
20
+ warnings.add('未找到可用的 stored module specs,无法生成细粒度组件视图。');
21
+ }
22
+ const rankedComponents = options.storedModules
23
+ .flatMap((module) => buildRankedComponents(module, packageElements, groupElements, narrativeNames))
24
+ .filter((component, index, components) => components.findIndex((candidate) => candidate.id === component.id) === index)
25
+ .sort((left, right) => {
26
+ const scoreDiff = right.score - left.score;
27
+ return scoreDiff !== 0 ? scoreDiff : left.id.localeCompare(right.id);
28
+ })
29
+ .slice(0, maxComponents);
30
+ if (rankedComponents.length === 0 && options.storedModules.length > 0) {
31
+ warnings.add('未识别到高信号组件,组件视图将以 warnings 形式降级。');
32
+ }
33
+ const components = rankedComponents.map((component) => finalizeComponent(component));
34
+ const relationships = buildComponentRelationships(rankedComponents, options.storedModules, options.architectureIR, options.eventSurface);
35
+ const groups = buildComponentGroups(rankedComponents);
36
+ const mermaidDiagram = buildComponentMermaid(groups, components, relationships);
37
+ const relevantIrWarnings = options.architectureIR.views
38
+ .filter((view) => view.kind === 'component' || view.kind === 'system-context')
39
+ .flatMap((view) => view.warnings);
40
+ for (const warning of relevantIrWarnings) {
41
+ warnings.add(warning);
42
+ }
43
+ for (const relationship of relationships) {
44
+ if (relationship.confidence === 'low') {
45
+ warnings.add(`低置信组件关系: ${relationship.label}`);
46
+ }
47
+ }
48
+ const summary = buildSummaryLines(components, relationships);
49
+ const model = {
50
+ projectName: options.architectureIR.projectName,
51
+ generatedAt: new Date().toISOString(),
52
+ summary,
53
+ groups,
54
+ components,
55
+ relationships,
56
+ mermaidDiagram,
57
+ warnings: [...warnings].sort((a, b) => a.localeCompare(b)),
58
+ stats: summarizeComponentView({ components, relationships }),
59
+ };
60
+ return {
61
+ title: `组件视图: ${options.architectureIR.projectName}`,
62
+ generatedAt: model.generatedAt,
63
+ model,
64
+ warnings: model.warnings,
65
+ mermaidDiagram,
66
+ };
67
+ }
68
+ export function renderComponentView(output) {
69
+ const template = loadTemplate('component-view.hbs', import.meta.url);
70
+ return template(output);
71
+ }
72
+ function buildRankedComponents(module, packageElements, groupElements, narrativeNames) {
73
+ const exports = module.baselineSkeleton?.exports ?? [];
74
+ const rankedCandidates = [];
75
+ const moduleRole = classifyModuleRole(module.sourceTarget);
76
+ const packageMatch = findMatchingPackage(module, packageElements);
77
+ const groupMatch = findMatchingGroup(packageMatch, groupElements);
78
+ const subsystem = inferSubsystem(module, packageMatch, groupMatch);
79
+ for (const symbol of exports) {
80
+ const category = classifyComponentCategory(symbol.name, module.sourceTarget);
81
+ const score = scoreExportSymbol(symbol, category, moduleRole, narrativeNames);
82
+ const shouldKeep = CLASSLIKE_KINDS.has(symbol.kind) || score >= 7;
83
+ if (!shouldKeep || isLowSignalSymbol(symbol.name, moduleRole)) {
84
+ continue;
85
+ }
86
+ rankedCandidates.push({
87
+ id: sanitizeComponentId(module.sourceTarget, symbol.name),
88
+ name: symbol.name,
89
+ category,
90
+ subsystem,
91
+ summary: summarizeComponentSummary(module, symbol),
92
+ responsibilities: dedupeStrings([
93
+ module.intentSummary,
94
+ module.businessSummary,
95
+ symbol.jsDoc ?? undefined,
96
+ ]),
97
+ relatedFiles: module.relatedFiles,
98
+ keyMethods: collectKeyMethods(symbol, module),
99
+ upstreamIds: [],
100
+ downstreamIds: [],
101
+ confidence: deriveConfidence(score, module.confidence),
102
+ inferred: module.confidence === 'low',
103
+ evidence: dedupeComponentEvidence([
104
+ createModuleEvidence(module),
105
+ createSkeletonEvidence(module, symbol.name, symbol.signature, module.confidence === 'low'),
106
+ ]),
107
+ score,
108
+ sourceTarget: module.sourceTarget,
109
+ packageId: packageMatch?.id,
110
+ groupId: groupMatch?.id,
111
+ });
112
+ }
113
+ if (rankedCandidates.length === 0 && moduleRole !== 'validation') {
114
+ rankedCandidates.push(createFallbackModuleComponent(module, subsystem, packageMatch?.id, groupMatch?.id));
115
+ }
116
+ const primaryCandidate = rankedCandidates[0];
117
+ if (primaryCandidate) {
118
+ attachTopLevelFunctionMethods(primaryCandidate, exports, module);
119
+ }
120
+ return rankedCandidates
121
+ .sort((left, right) => {
122
+ const scoreDiff = right.score - left.score;
123
+ return scoreDiff !== 0 ? scoreDiff : left.name.localeCompare(right.name);
124
+ })
125
+ .slice(0, moduleRole === 'core' ? 2 : 1);
126
+ }
127
+ function finalizeComponent(component) {
128
+ return {
129
+ id: component.id,
130
+ name: component.name,
131
+ category: component.category,
132
+ subsystem: component.subsystem,
133
+ summary: component.summary,
134
+ responsibilities: component.responsibilities,
135
+ relatedFiles: component.relatedFiles,
136
+ keyMethods: component.keyMethods,
137
+ upstreamIds: component.upstreamIds,
138
+ downstreamIds: component.downstreamIds,
139
+ confidence: component.confidence,
140
+ inferred: component.inferred,
141
+ evidence: component.evidence,
142
+ };
143
+ }
144
+ function buildComponentRelationships(rankedComponents, storedModules, architectureIR, eventSurface) {
145
+ const relationships = new Map();
146
+ const primaryByModule = new Map();
147
+ for (const component of rankedComponents) {
148
+ if (!primaryByModule.has(component.sourceTarget)) {
149
+ primaryByModule.set(component.sourceTarget, component);
150
+ }
151
+ }
152
+ const componentById = new Map(rankedComponents.map((component) => [component.id, component]));
153
+ for (const module of storedModules) {
154
+ const sourceComponent = primaryByModule.get(module.sourceTarget);
155
+ if (!sourceComponent) {
156
+ continue;
157
+ }
158
+ for (const targetModule of resolveImportedModules(module, storedModules)) {
159
+ const targetComponent = primaryByModule.get(targetModule.sourceTarget);
160
+ if (!targetComponent || targetComponent.id === sourceComponent.id) {
161
+ continue;
162
+ }
163
+ upsertRelationship(relationships, {
164
+ fromId: sourceComponent.id,
165
+ toId: targetComponent.id,
166
+ kind: 'calls',
167
+ label: `${sourceComponent.name} imports ${targetComponent.name}`,
168
+ confidence: 'medium',
169
+ evidence: [createModuleEvidence(module)],
170
+ });
171
+ }
172
+ }
173
+ for (const relationship of architectureIR.relationships) {
174
+ if (relationship.kind !== 'depends-on') {
175
+ continue;
176
+ }
177
+ const mapped = mapIrRelationshipToComponents(relationship, rankedComponents);
178
+ if (!mapped) {
179
+ continue;
180
+ }
181
+ upsertRelationship(relationships, mapped);
182
+ }
183
+ const queryComponent = findTopComponent(rankedComponents, ['query', 'client', 'service', 'module']);
184
+ const transportComponent = findTopComponent(rankedComponents, ['transport']);
185
+ const parserComponent = findTopComponent(rankedComponents, ['parser']);
186
+ const sessionComponent = findTopComponent(rankedComponents, ['session', 'store']);
187
+ if (queryComponent && transportComponent && queryComponent.id !== transportComponent.id) {
188
+ upsertRelationship(relationships, {
189
+ fromId: queryComponent.id,
190
+ toId: transportComponent.id,
191
+ kind: 'uses-transport',
192
+ label: `${queryComponent.name} delegates to ${transportComponent.name}`,
193
+ confidence: 'high',
194
+ evidence: mergeEvidence(queryComponent.evidence, transportComponent.evidence),
195
+ });
196
+ }
197
+ if (transportComponent && parserComponent && transportComponent.id !== parserComponent.id) {
198
+ upsertRelationship(relationships, {
199
+ fromId: transportComponent.id,
200
+ toId: parserComponent.id,
201
+ kind: 'parses',
202
+ label: `${transportComponent.name} hands off to ${parserComponent.name}`,
203
+ confidence: 'high',
204
+ evidence: mergeEvidence(transportComponent.evidence, parserComponent.evidence),
205
+ });
206
+ }
207
+ else if (queryComponent && parserComponent && queryComponent.id !== parserComponent.id) {
208
+ upsertRelationship(relationships, {
209
+ fromId: queryComponent.id,
210
+ toId: parserComponent.id,
211
+ kind: 'parses',
212
+ label: `${queryComponent.name} relies on ${parserComponent.name}`,
213
+ confidence: 'medium',
214
+ evidence: mergeEvidence(queryComponent.evidence, parserComponent.evidence),
215
+ });
216
+ }
217
+ if (queryComponent && sessionComponent && queryComponent.id !== sessionComponent.id) {
218
+ upsertRelationship(relationships, {
219
+ fromId: queryComponent.id,
220
+ toId: sessionComponent.id,
221
+ kind: 'manages-session',
222
+ label: `${queryComponent.name} updates ${sessionComponent.name}`,
223
+ confidence: 'medium',
224
+ evidence: mergeEvidence(queryComponent.evidence, sessionComponent.evidence),
225
+ });
226
+ }
227
+ if (eventSurface) {
228
+ for (const channel of eventSurface.channels) {
229
+ const publisher = channel.publishers[0];
230
+ const subscriber = channel.subscribers[0];
231
+ if (!publisher || !subscriber) {
232
+ continue;
233
+ }
234
+ const publisherComponent = findComponentByEvidence(rankedComponents, publisher.symbolName, publisher.sourceFile);
235
+ const subscriberComponent = findComponentByEvidence(rankedComponents, subscriber.symbolName, subscriber.sourceFile);
236
+ if (!publisherComponent || !subscriberComponent || publisherComponent.id === subscriberComponent.id) {
237
+ continue;
238
+ }
239
+ upsertRelationship(relationships, {
240
+ fromId: publisherComponent.id,
241
+ toId: subscriberComponent.id,
242
+ kind: 'publishes',
243
+ label: `${publisherComponent.name} emits ${channel.channelName}`,
244
+ confidence: 'medium',
245
+ evidence: [{
246
+ sourceType: 'event-surface',
247
+ ref: channel.channelName,
248
+ note: channel.kind,
249
+ }],
250
+ });
251
+ }
252
+ }
253
+ const finalized = [...relationships.values()]
254
+ .filter((relationship) => relationship.fromId !== relationship.toId)
255
+ .sort((left, right) => `${left.fromId}|${left.kind}|${left.toId}`.localeCompare(`${right.fromId}|${right.kind}|${right.toId}`));
256
+ for (const relationship of finalized) {
257
+ componentById.get(relationship.fromId)?.downstreamIds.push(relationship.toId);
258
+ componentById.get(relationship.toId)?.upstreamIds.push(relationship.fromId);
259
+ }
260
+ for (const component of componentById.values()) {
261
+ component.upstreamIds = dedupeStrings(component.upstreamIds);
262
+ component.downstreamIds = dedupeStrings(component.downstreamIds);
263
+ }
264
+ return finalized;
265
+ }
266
+ function buildComponentGroups(components) {
267
+ const groups = new Map();
268
+ for (const component of components) {
269
+ const id = sanitizeMermaidId(`group_${component.subsystem}`);
270
+ if (!groups.has(id)) {
271
+ groups.set(id, {
272
+ id,
273
+ name: component.subsystem,
274
+ componentIds: [],
275
+ summary: `${component.subsystem} 子系统`,
276
+ });
277
+ }
278
+ groups.get(id).componentIds.push(component.id);
279
+ }
280
+ return [...groups.values()]
281
+ .map((group) => ({
282
+ ...group,
283
+ componentIds: dedupeStrings(group.componentIds),
284
+ }))
285
+ .sort((left, right) => left.name.localeCompare(right.name));
286
+ }
287
+ function buildComponentMermaid(groups, components, relationships) {
288
+ if (components.length === 0) {
289
+ return undefined;
290
+ }
291
+ const lines = ['flowchart LR'];
292
+ const componentById = new Map(components.map((component) => [component.id, component]));
293
+ for (const group of groups) {
294
+ lines.push(` subgraph ${sanitizeMermaidId(group.id)}["${escapeMermaidLabel(group.name)}"]`);
295
+ for (const componentId of group.componentIds) {
296
+ const component = componentById.get(componentId);
297
+ if (!component) {
298
+ continue;
299
+ }
300
+ const nodeId = sanitizeMermaidId(component.id);
301
+ lines.push(` ${nodeId}["${escapeMermaidLabel(`${component.name}\\n${component.category}`)}"]`);
302
+ }
303
+ lines.push(' end');
304
+ }
305
+ for (const relationship of relationships) {
306
+ const fromId = sanitizeMermaidId(relationship.fromId);
307
+ const toId = sanitizeMermaidId(relationship.toId);
308
+ lines.push(` ${fromId} -->|${escapeMermaidLabel(relationship.kind)}| ${toId}`);
309
+ }
310
+ return lines.join('\n');
311
+ }
312
+ function buildSummaryLines(components, relationships) {
313
+ const lines = [];
314
+ if (components.length > 0) {
315
+ lines.push(`识别到 ${components.length} 个关键组件,优先聚焦 ${components.slice(0, 4).map((component) => `\`${component.name}\``).join('、')}。`);
316
+ }
317
+ else {
318
+ lines.push('当前批次未识别到可稳定命名的关键组件。');
319
+ }
320
+ const transports = components.filter((component) => component.category === 'transport');
321
+ const parsers = components.filter((component) => component.category === 'parser');
322
+ const sessions = components.filter((component) => component.category === 'session' || component.category === 'store');
323
+ if (transports.length > 0 || parsers.length > 0 || sessions.length > 0) {
324
+ lines.push(`检测到 transport/parser/session 边界:transport=${transports.length},parser=${parsers.length},session/store=${sessions.length}。`);
325
+ }
326
+ if (relationships.length > 0) {
327
+ lines.push(`组件关系共 ${relationships.length} 条,包含 imports、transport hand-off 或 session 管理等关键连接。`);
328
+ }
329
+ return lines;
330
+ }
331
+ function collectNarrativeNames(narrative) {
332
+ const names = new Set();
333
+ if (!narrative) {
334
+ return names;
335
+ }
336
+ for (const symbol of narrative.keySymbols) {
337
+ names.add(symbol.name);
338
+ }
339
+ for (const method of narrative.keyMethods) {
340
+ names.add(method.name);
341
+ }
342
+ for (const module of narrative.keyModules) {
343
+ names.add(module.displayName);
344
+ }
345
+ return names;
346
+ }
347
+ function scoreExportSymbol(symbol, category, moduleRole, narrativeNames) {
348
+ let score = 0;
349
+ if (CLASSLIKE_KINDS.has(symbol.kind))
350
+ score += 6;
351
+ if (HIGH_SIGNAL_NAME_RE.test(symbol.name))
352
+ score += 6;
353
+ if (category !== 'module')
354
+ score += 4;
355
+ if ((symbol.members ?? []).some((member) => CORE_METHOD_RE.test(member.name)))
356
+ score += 3;
357
+ if (CORE_METHOD_RE.test(symbol.name))
358
+ score += 3;
359
+ if (narrativeNames.has(symbol.name))
360
+ score += 3;
361
+ if (moduleRole === 'core')
362
+ score += 3;
363
+ if (moduleRole === 'support')
364
+ score -= 1;
365
+ if (moduleRole === 'validation')
366
+ score -= 6;
367
+ return score;
368
+ }
369
+ function deriveConfidence(score, moduleConfidence) {
370
+ if (moduleConfidence === 'low') {
371
+ return score >= 12 ? 'medium' : 'low';
372
+ }
373
+ if (score >= 14) {
374
+ return 'high';
375
+ }
376
+ if (score >= 8) {
377
+ return 'medium';
378
+ }
379
+ return 'low';
380
+ }
381
+ function collectKeyMethods(symbol, module) {
382
+ const methods = [];
383
+ for (const member of symbol.members ?? []) {
384
+ if (isLowSignalMethod(member.name, module.sourceTarget)) {
385
+ continue;
386
+ }
387
+ methods.push({
388
+ ownerName: symbol.name,
389
+ name: member.name,
390
+ kind: classifyMethodKind(member.name),
391
+ signature: member.signature,
392
+ evidence: [createSkeletonEvidence(module, `${symbol.name}.${member.name}`, member.signature, module.confidence === 'low')],
393
+ });
394
+ }
395
+ return methods
396
+ .sort((left, right) => left.name.localeCompare(right.name))
397
+ .slice(0, 6);
398
+ }
399
+ function attachTopLevelFunctionMethods(component, exports, module) {
400
+ const methods = exports
401
+ .filter((symbol) => symbol.kind === 'function' && CORE_METHOD_RE.test(symbol.name))
402
+ .map((symbol) => ({
403
+ ownerName: undefined,
404
+ name: symbol.name,
405
+ kind: classifyMethodKind(symbol.name),
406
+ signature: symbol.signature,
407
+ evidence: [createSkeletonEvidence(module, symbol.name, symbol.signature, module.confidence === 'low')],
408
+ }));
409
+ component.keyMethods = dedupeMethods([...component.keyMethods, ...methods]);
410
+ }
411
+ function createFallbackModuleComponent(module, subsystem, packageId, groupId) {
412
+ const fallbackName = path.posix.basename(module.sourceTarget).replace(/\.[^/.]+$/, '');
413
+ return {
414
+ id: sanitizeComponentId(module.sourceTarget, fallbackName),
415
+ name: fallbackName,
416
+ category: classifyComponentCategory(fallbackName, module.sourceTarget),
417
+ subsystem,
418
+ summary: module.intentSummary,
419
+ responsibilities: dedupeStrings([module.intentSummary, module.businessSummary]),
420
+ relatedFiles: module.relatedFiles,
421
+ keyMethods: [],
422
+ upstreamIds: [],
423
+ downstreamIds: [],
424
+ confidence: module.confidence === 'low' ? 'low' : 'medium',
425
+ inferred: module.confidence === 'low',
426
+ evidence: [createModuleEvidence(module)],
427
+ score: module.confidence === 'low' ? 2 : 6,
428
+ sourceTarget: module.sourceTarget,
429
+ packageId,
430
+ groupId,
431
+ };
432
+ }
433
+ function createModuleEvidence(module) {
434
+ return {
435
+ sourceType: 'module-spec',
436
+ ref: module.sourceTarget,
437
+ note: module.intentSummary,
438
+ inferred: module.confidence === 'low',
439
+ };
440
+ }
441
+ function createSkeletonEvidence(module, refName, signature, inferred) {
442
+ return {
443
+ sourceType: 'baseline-skeleton',
444
+ ref: `${module.sourceTarget}:${refName}`,
445
+ note: signature,
446
+ inferred,
447
+ };
448
+ }
449
+ function classifyComponentCategory(name, sourceTarget) {
450
+ const lower = `${name} ${sourceTarget}`.toLowerCase();
451
+ if (/(transport|stdin|stdout)/.test(lower))
452
+ return 'transport';
453
+ if (/(parser|parse|codec|serializer|message)/.test(lower))
454
+ return 'parser';
455
+ if (/(session|conversation|transcript)/.test(lower))
456
+ return 'session';
457
+ if (/(store|cache|repository)/.test(lower))
458
+ return 'store';
459
+ if (/(adapter)/.test(lower))
460
+ return 'adapter';
461
+ if (/(client|sdk)/.test(lower))
462
+ return 'client';
463
+ if (/(query|request)/.test(lower))
464
+ return 'query';
465
+ if (/(service|runtime|manager|controller|gateway)/.test(lower))
466
+ return 'service';
467
+ return 'module';
468
+ }
469
+ function classifyMethodKind(name) {
470
+ const lower = name.toLowerCase();
471
+ if (/(query|request|connect|send|stream|run|execute|process|interrupt|control)/.test(lower))
472
+ return 'entrypoint';
473
+ if (/(transport|dispatch|emit|publish|subscribe|listen)/.test(lower))
474
+ return 'transport';
475
+ if (/(parse|decode|encode|serialize)/.test(lower))
476
+ return 'parser';
477
+ if (/(session|persist|store|load|save|resume)/.test(lower))
478
+ return 'session';
479
+ if (/(event|handle|on[A-Z_])/.test(name) || /(event|handle)/.test(lower))
480
+ return 'event-handler';
481
+ return 'supporting';
482
+ }
483
+ function summarizeComponentSummary(module, symbol) {
484
+ const doc = symbol.jsDoc?.trim();
485
+ if (doc) {
486
+ return summarizeLine(doc, module.intentSummary);
487
+ }
488
+ return summarizeLine(module.intentSummary, symbol.signature);
489
+ }
490
+ function summarizeLine(content, fallback) {
491
+ const value = content
492
+ .split(/\r?\n/)
493
+ .map((line) => line.replace(/^[-*]\s+/, '').trim())
494
+ .find((line) => line.length > 0);
495
+ return value ?? fallback;
496
+ }
497
+ function classifyModuleRole(sourceTarget) {
498
+ if (sourceTarget === 'tests' || sourceTarget.startsWith('tests/') || sourceTarget.includes('/tests/')) {
499
+ return 'validation';
500
+ }
501
+ if (sourceTarget.startsWith('examples/') || sourceTarget.startsWith('scripts/')) {
502
+ return 'support';
503
+ }
504
+ return 'core';
505
+ }
506
+ function isLowSignalSymbol(name, moduleRole) {
507
+ return moduleRole === 'validation' && /^test/i.test(name);
508
+ }
509
+ function isLowSignalMethod(name, sourceTarget) {
510
+ return classifyModuleRole(sourceTarget) === 'validation' && /^test/i.test(name);
511
+ }
512
+ function sanitizeComponentId(sourceTarget, name) {
513
+ return sanitizeMermaidId(`component_${sourceTarget}_${name}`);
514
+ }
515
+ function findMatchingPackage(module, packageElements) {
516
+ return packageElements.find((element) => {
517
+ const elementPath = getMetadataString(element, 'path');
518
+ return typeof elementPath === 'string' && module.relatedFiles.some((filePath) => filePath.startsWith(`${elementPath}/`) || filePath === elementPath);
519
+ });
520
+ }
521
+ function findMatchingGroup(packageElement, groupElements) {
522
+ if (!packageElement) {
523
+ return undefined;
524
+ }
525
+ const groupName = getMetadataString(packageElement, 'group');
526
+ if (!groupName) {
527
+ return undefined;
528
+ }
529
+ return groupElements.find((element) => element.id === `group:${groupName}`);
530
+ }
531
+ function inferSubsystem(module, packageElement, groupElement) {
532
+ const packagePath = getMetadataString(packageElement, 'path');
533
+ if (packagePath) {
534
+ return packagePath;
535
+ }
536
+ if (groupElement?.name) {
537
+ return groupElement.name;
538
+ }
539
+ const parts = module.sourceTarget.split('/').filter(Boolean);
540
+ if (parts.length >= 3 && (parts[0] === 'src' || parts[0] === 'tests')) {
541
+ return parts.slice(1, parts.length - 1).join('/') || parts[1];
542
+ }
543
+ if (parts.length >= 2) {
544
+ return parts.slice(0, parts.length - 1).join('/');
545
+ }
546
+ return module.sourceTarget;
547
+ }
548
+ function resolveImportedModules(module, storedModules) {
549
+ const imports = module.baselineSkeleton?.imports ?? [];
550
+ const matches = new Set();
551
+ for (const item of imports) {
552
+ const resolved = item.resolvedPath?.split(path.sep).join('/');
553
+ for (const candidate of storedModules) {
554
+ if (candidate.sourceTarget === module.sourceTarget) {
555
+ continue;
556
+ }
557
+ if (resolved && candidate.relatedFiles.some((filePath) => resolved.endsWith(filePath) || filePath.endsWith(resolved))) {
558
+ matches.add(candidate);
559
+ continue;
560
+ }
561
+ const specifier = item.moduleSpecifier.replace(/^\.\//, '');
562
+ if (specifier.length > 0 && candidate.sourceTarget.endsWith(specifier)) {
563
+ matches.add(candidate);
564
+ }
565
+ }
566
+ }
567
+ return [...matches];
568
+ }
569
+ function mapIrRelationshipToComponents(relationship, rankedComponents) {
570
+ const fromCandidates = rankedComponents.filter((component) => component.packageId === relationship.sourceId || component.groupId === relationship.sourceId);
571
+ const toCandidates = rankedComponents.filter((component) => component.packageId === relationship.destinationId || component.groupId === relationship.destinationId);
572
+ const fromComponent = fromCandidates[0];
573
+ const toComponent = toCandidates[0];
574
+ if (!fromComponent || !toComponent || fromComponent.id === toComponent.id) {
575
+ return undefined;
576
+ }
577
+ return {
578
+ fromId: fromComponent.id,
579
+ toId: toComponent.id,
580
+ kind: relationship.kind === 'depends-on' ? 'depends-on' : 'calls',
581
+ label: `${fromComponent.name} ${relationship.kind} ${toComponent.name}`,
582
+ confidence: 'medium',
583
+ evidence: relationship.evidence.map(mapIrEvidence),
584
+ };
585
+ }
586
+ function mapIrEvidence(evidence) {
587
+ return {
588
+ sourceType: 'architecture-ir',
589
+ ref: evidence.ref,
590
+ note: evidence.note,
591
+ };
592
+ }
593
+ function findTopComponent(components, categories) {
594
+ return components.find((component) => categories.includes(component.category));
595
+ }
596
+ function findComponentByEvidence(components, symbolName, sourceFile) {
597
+ const normalizedFile = sourceFile.split(path.sep).join('/');
598
+ return components.find((component) => component.name === symbolName
599
+ || component.keyMethods.some((method) => method.ownerName === symbolName || method.name === symbolName)
600
+ || component.relatedFiles.some((filePath) => filePath === normalizedFile || filePath.endsWith(normalizedFile)));
601
+ }
602
+ function upsertRelationship(relationships, relationship) {
603
+ const key = `${relationship.fromId}|${relationship.kind}|${relationship.toId}`;
604
+ const existing = relationships.get(key);
605
+ if (!existing) {
606
+ relationships.set(key, {
607
+ ...relationship,
608
+ evidence: dedupeComponentEvidence(relationship.evidence),
609
+ });
610
+ return;
611
+ }
612
+ existing.label = existing.label || relationship.label;
613
+ existing.confidence = maxConfidence(existing.confidence, relationship.confidence);
614
+ existing.evidence = dedupeComponentEvidence([...existing.evidence, ...relationship.evidence]);
615
+ }
616
+ function maxConfidence(left, right) {
617
+ const order = ['low', 'medium', 'high'];
618
+ return order[Math.max(order.indexOf(left), order.indexOf(right))] ?? 'low';
619
+ }
620
+ function mergeEvidence(left, right) {
621
+ return dedupeComponentEvidence([...left, ...right]);
622
+ }
623
+ function dedupeMethods(methods) {
624
+ const seen = new Set();
625
+ const result = [];
626
+ for (const method of methods) {
627
+ const key = `${method.ownerName ?? ''}|${method.name}|${method.signature ?? ''}`;
628
+ if (seen.has(key)) {
629
+ continue;
630
+ }
631
+ seen.add(key);
632
+ result.push(method);
633
+ }
634
+ return result
635
+ .sort((left, right) => left.name.localeCompare(right.name))
636
+ .slice(0, 8);
637
+ }
638
+ function dedupeStrings(values) {
639
+ return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]
640
+ .sort((a, b) => a.localeCompare(b));
641
+ }
642
+ function getMetadataString(element, key) {
643
+ if (!element) {
644
+ return undefined;
645
+ }
646
+ const value = element.metadata[key];
647
+ return typeof value === 'string' ? value : undefined;
648
+ }
649
+ function escapeMermaidLabel(value) {
650
+ return value.replace(/"/g, '\\"');
651
+ }
652
+ //# sourceMappingURL=component-view-builder.js.map