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
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import type Parser from 'web-tree-sitter';
6
6
  import type { ExportSymbol, ImportReference, ParseError, Language } from '../../models/code-skeleton.js';
7
+ import type { CallSite } from '../../models/call-site.js';
7
8
  import type { QueryMapper, MapperOptions } from './base-mapper.js';
8
9
  export declare class TypeScriptMapper implements QueryMapper {
9
10
  readonly language: Language;
@@ -14,8 +15,31 @@ export declare class TypeScriptMapper implements QueryMapper {
14
15
  extractExports(tree: Parser.Tree, _source: string, _options?: MapperOptions): ExportSymbol[];
15
16
  /**
16
17
  * 从 AST tree 提取导入引用
18
+ *
19
+ * Feature 156 W1.0 v2 / CRIT-3:除 `import_statement` 外,还要遍历 AST 找
20
+ * - `call_expression` callee = `import` keyword → dynamic import
21
+ * - `call_expression` callee = `require` Identifier → commonjs-require
22
+ *
23
+ * 这样 tree-sitter 降级路径下 AC-11 的 dynamic / commonjs-require 边也能产出
24
+ * (ts-morph 主路径已在 ast-analyzer.ts 覆盖)。
17
25
  */
18
26
  extractImports(tree: Parser.Tree, _source: string): ImportReference[];
27
+ /**
28
+ * 递归遍历 AST,识别 dynamic import / commonjs-require 调用并产出对应 ImportReference。
29
+ *
30
+ * 仅识别 AST 结构上的 call_expression 节点 — 不是文本正则,因此能避免 WARN-2 类
31
+ * 字符串 / 注释中的 "require('./x')" 误命中(tree-sitter parser 会把它们标识为
32
+ * string / comment 节点,不会形成 call_expression 子树)。
33
+ */
34
+ private _collectCallExpressionImports;
35
+ /**
36
+ * 从 call_expression 节点派生 ImportReference(仅当 callee 为 `import` keyword 或
37
+ * `require` Identifier 时)。
38
+ *
39
+ * tree-sitter-typescript grammar 把动态 import callee 标识为 `import` 节点(type==='import'),
40
+ * require 调用则是 type==='identifier' && text==='require'。
41
+ */
42
+ private _extractCallExpressionImport;
19
43
  /**
20
44
  * 从 AST tree 提取解析错误
21
45
  */
@@ -50,5 +74,83 @@ export declare class TypeScriptMapper implements QueryMapper {
50
74
  private _extractImportStatement;
51
75
  /** 递归收集 AST 中的 ERROR 节点 */
52
76
  private _collectErrors;
77
+ /**
78
+ * 从 AST tree 提取函数调用点(Feature 152 P1)。
79
+ *
80
+ * 覆盖 6 种 calleeKind:free / member / cross-module / super / decorator / unresolved。
81
+ * TS extractor 不产出 dunder kind(CL-08)。
82
+ * 大文件 size guard(EC-14):source.length > 1MB 直接返回空数组。
83
+ */
84
+ extractCallSites(tree: Parser.Tree, source: string): CallSite[];
85
+ /**
86
+ * 递归遍历 AST 抽取 call sites。
87
+ * callerContextStack 维护当前 function/class 嵌套作用域,进入 SCOPE_DEFINING_TYPES 时压栈。
88
+ * W-3 修复:handleDecorator 返回需跳过的子树节点,walker 在递归前跳过该节点。
89
+ */
90
+ private _walkCallSites;
91
+ /**
92
+ * 推导当前节点的 callerContext 字符串。
93
+ *
94
+ * C-4 修复:匿名 arrow_function / function 也产生 `<arrow:line:col>` / `<fn:line:col>`,
95
+ * 确保内层 callback 不会错误归属外层 class method。
96
+ */
97
+ private _deriveCallerContext;
98
+ /**
99
+ * 向上遍历 AST 找到最近的 class_declaration 节点,返回类名。
100
+ * 用于 method_definition 推导 callerContext(如 "Foo.bar")。
101
+ */
102
+ private _findAncestorClassName;
103
+ /**
104
+ * 处理 call_expression 节点,分流 7 种形态(T-008):
105
+ * 1. dynamic import(`import('./x')`) → unresolved,calleeName='import'
106
+ * 2. super() 自调用 → super
107
+ * 3. eval/Function identifier → unresolved
108
+ * 4. 普通 identifier 调用 → free
109
+ * 5. C-3 修复:import().then() 链式 — 检测并跳过外层 .then 防双计数
110
+ * 6. member_expression → handleMemberCall
111
+ * 7. optional chain 等复杂形式 → 尽力提取 member_expression
112
+ *
113
+ * C-8 修复:mkCallSite 不接受 dynamicReason 参数(CallSite schema 仅 6 字段)。
114
+ */
115
+ private _handleCallExpression;
116
+ /**
117
+ * 处理 member_expression / optional_member_expression 中的调用(严格与 PythonMapper L943-953 对齐):
118
+ * - this.method() → member(无 qualifier)
119
+ * - super.method() → super
120
+ * - 首字母大写 qualifier(Class.method)→ member + qualifier
121
+ * - 首字母小写 qualifier(mod.fn)→ cross-module + qualifier(关键:不是 member)
122
+ */
123
+ private _handleMemberCall;
124
+ /**
125
+ * 处理 new_expression 节点(T-009)。
126
+ * - new Foo() → free,calleeName='Foo'(FR-1.3)
127
+ * - new Function('code') → unresolved(W-2 修复,避免误判为本地构造)
128
+ * - new Foo.Sub() → 委派 handleMemberCall
129
+ * C-8 修复:不向 CallSite schema 添加 viaNew 元数据字段。
130
+ */
131
+ private _handleNewExpression;
132
+ /**
133
+ * 处理 decorator 节点(T-010)。
134
+ * - 带参 decorator `@Foo()` → decorator kind
135
+ * - bare decorator `@Foo`(无括号)→ 不产出(与 Python CL-04 对齐)
136
+ *
137
+ * W-3 修复:找到带参 decorator 的 call_expression 后产出 callSite,
138
+ * 返回该 call_expression 节点作为跳过标记,walker 不再递归进入,
139
+ * 避免 call_expression 子节点被 walker 再次产出 free/member callSite(双计数)。
140
+ *
141
+ * @returns 需要跳过的子树节点(call_expression),或 null(bare decorator 不产出)
142
+ */
143
+ private _handleDecorator;
144
+ /**
145
+ * 处理 tagged_template_expression 节点(T-010)。
146
+ * - tag 为 identifier → free
147
+ * - tag 为 member_expression → 委派 handleMemberCall
148
+ */
149
+ private _handleTaggedTemplate;
150
+ /**
151
+ * 构造单个 CallSite 记录(6 字段,C-8 修复:不接受 dynamicReason / viaNew 参数)。
152
+ * 字段:calleeName / calleeKind / line / column / callerContext / calleeQualifier
153
+ */
154
+ private _mkCallSite;
53
155
  }
54
156
  //# sourceMappingURL=typescript-mapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typescript-mapper.d.ts","sourceRoot":"","sources":["../../../src/core/query-mappers/typescript-mapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EACf,UAAU,EAGV,QAAQ,EAET,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AA2KnE,qBAAa,gBAAiB,YAAW,WAAW;IAClD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAgB;IAE3C;;;OAGG;IACH,cAAc,CACZ,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,aAAkB,GAC3B,YAAY,EAAE;IAmBjB;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE;IAiBrE;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,UAAU,EAAE;IAUnD,0BAA0B;IAC1B,OAAO,CAAC,uBAAuB;IAsD/B,8BAA8B;IAC9B,OAAO,CAAC,2BAA2B;IAqBnC,2BAA2B;IAC3B,OAAO,CAAC,wBAAwB;IA6BhC,+BAA+B;IAC/B,OAAO,CAAC,4BAA4B;IA2CpC,gCAAgC;IAChC,OAAO,CAAC,4BAA4B;IA0BpC,0BAA0B;IAC1B,OAAO,CAAC,uBAAuB;IAoB/B,4CAA4C;IAC5C,OAAO,CAAC,0BAA0B;IAuClC,mCAAmC;IACnC,OAAO,CAAC,oBAAoB;IAqC5B,kBAAkB;IAClB,OAAO,CAAC,oBAAoB;IAgB5B,oBAAoB;IACpB,OAAO,CAAC,mBAAmB;IAiB3B,aAAa;IACb,OAAO,CAAC,wBAAwB;IA6ChC,aAAa;IACb,OAAO,CAAC,uBAAuB;IAwB/B,sBAAsB;IACtB,OAAO,CAAC,wBAAwB;IAkDhC,0BAA0B;IAC1B,OAAO,CAAC,uBAAuB;IAkG/B,2BAA2B;IAC3B,OAAO,CAAC,cAAc;CAkBvB"}
1
+ {"version":3,"file":"typescript-mapper.d.ts","sourceRoot":"","sources":["../../../src/core/query-mappers/typescript-mapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EACf,UAAU,EAGV,QAAQ,EAET,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAc,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAoMnE,qBAAa,gBAAiB,YAAW,WAAW;IAClD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAgB;IAE3C;;;OAGG;IACH,cAAc,CACZ,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,aAAkB,GAC3B,YAAY,EAAE;IAmBjB;;;;;;;;;OASG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE;IAoBrE;;;;;;OAMG;IACH,OAAO,CAAC,6BAA6B;IAcrC;;;;;;OAMG;IACH,OAAO,CAAC,4BAA4B;IAiDpC;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,UAAU,EAAE;IAUnD,0BAA0B;IAC1B,OAAO,CAAC,uBAAuB;IAsD/B,8BAA8B;IAC9B,OAAO,CAAC,2BAA2B;IAqBnC,2BAA2B;IAC3B,OAAO,CAAC,wBAAwB;IA6BhC,+BAA+B;IAC/B,OAAO,CAAC,4BAA4B;IA2CpC,gCAAgC;IAChC,OAAO,CAAC,4BAA4B;IA0BpC,0BAA0B;IAC1B,OAAO,CAAC,uBAAuB;IAoB/B,4CAA4C;IAC5C,OAAO,CAAC,0BAA0B;IAuClC,mCAAmC;IACnC,OAAO,CAAC,oBAAoB;IAqC5B,kBAAkB;IAClB,OAAO,CAAC,oBAAoB;IAgB5B,oBAAoB;IACpB,OAAO,CAAC,mBAAmB;IAiB3B,aAAa;IACb,OAAO,CAAC,wBAAwB;IA6ChC,aAAa;IACb,OAAO,CAAC,uBAAuB;IAwB/B,sBAAsB;IACtB,OAAO,CAAC,wBAAwB;IAkDhC,0BAA0B;IAC1B,OAAO,CAAC,uBAAuB;IAkG/B,2BAA2B;IAC3B,OAAO,CAAC,cAAc;IAuBtB;;;;;;OAMG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE;IAa/D;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAuDtB;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAsD5B;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAqB9B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,qBAAqB;IA0D7B;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAyCzB;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IA4B5B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB;IAgCxB;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAmB7B;;;OAGG;IACH,OAAO,CAAC,WAAW;CAmBpB"}
@@ -1,4 +1,25 @@
1
1
  // ============================================================
2
+ // Feature 152 — call site 抽取常量(与 PythonMapper 对齐)
3
+ // ============================================================
4
+ /** 文件大小上限:超过 1MB 跳过 callSites 抽取(与 PythonMapper 对齐) */
5
+ const CALLSITES_MAX_FILE_BYTES = 1_000_000;
6
+ /** 动态调用名集合:这些 identifier 调用产出 unresolved(C-8 修复,无 dynamicReason 元数据) */
7
+ const DYNAMIC_CALL_NAMES = new Set(['eval', 'Function']);
8
+ /**
9
+ * 作用域定义节点类型集合。
10
+ * 进入这些节点时将 callerContext 压栈,离开时弹栈。
11
+ * C-4 修复:匿名 arrow/function 也必须入栈,避免内层 callback 归属错外层 class method。
12
+ */
13
+ const SCOPE_DEFINING_TYPES = new Set([
14
+ 'function_declaration', // function foo() {}
15
+ 'function', // const f = function() {}
16
+ 'arrow_function', // const f = () => {}
17
+ 'method_definition', // class Foo { bar() {} }
18
+ // Codex final W-3 修复:generator function 也定义独立 callerContext
19
+ 'generator_function_declaration', // function* gen() {}
20
+ 'generator_function', // const gen = function*() {}
21
+ ]);
22
+ // ============================================================
2
23
  // 辅助工具
3
24
  // ============================================================
4
25
  /** 获取节点的命名字段文本 */
@@ -188,6 +209,13 @@ export class TypeScriptMapper {
188
209
  }
189
210
  /**
190
211
  * 从 AST tree 提取导入引用
212
+ *
213
+ * Feature 156 W1.0 v2 / CRIT-3:除 `import_statement` 外,还要遍历 AST 找
214
+ * - `call_expression` callee = `import` keyword → dynamic import
215
+ * - `call_expression` callee = `require` Identifier → commonjs-require
216
+ *
217
+ * 这样 tree-sitter 降级路径下 AC-11 的 dynamic / commonjs-require 边也能产出
218
+ * (ts-morph 主路径已在 ast-analyzer.ts 覆盖)。
191
219
  */
192
220
  extractImports(tree, _source) {
193
221
  const rootNode = tree.rootNode;
@@ -202,8 +230,86 @@ export class TypeScriptMapper {
202
230
  if (ref)
203
231
  imports.push(ref);
204
232
  }
233
+ // CRIT-3:遍历整棵 AST 找 dynamic import / commonjs-require
234
+ this._collectCallExpressionImports(rootNode, imports);
205
235
  return imports;
206
236
  }
237
+ /**
238
+ * 递归遍历 AST,识别 dynamic import / commonjs-require 调用并产出对应 ImportReference。
239
+ *
240
+ * 仅识别 AST 结构上的 call_expression 节点 — 不是文本正则,因此能避免 WARN-2 类
241
+ * 字符串 / 注释中的 "require('./x')" 误命中(tree-sitter parser 会把它们标识为
242
+ * string / comment 节点,不会形成 call_expression 子树)。
243
+ */
244
+ _collectCallExpressionImports(node, imports) {
245
+ if (node.type === 'call_expression') {
246
+ const ref = this._extractCallExpressionImport(node);
247
+ if (ref)
248
+ imports.push(ref);
249
+ }
250
+ for (let i = 0; i < node.childCount; i++) {
251
+ const child = node.child(i);
252
+ if (child)
253
+ this._collectCallExpressionImports(child, imports);
254
+ }
255
+ }
256
+ /**
257
+ * 从 call_expression 节点派生 ImportReference(仅当 callee 为 `import` keyword 或
258
+ * `require` Identifier 时)。
259
+ *
260
+ * tree-sitter-typescript grammar 把动态 import callee 标识为 `import` 节点(type==='import'),
261
+ * require 调用则是 type==='identifier' && text==='require'。
262
+ */
263
+ _extractCallExpressionImport(call) {
264
+ const fn = call.childForFieldName('function');
265
+ if (!fn)
266
+ return null;
267
+ let kind = null;
268
+ if (fn.type === 'import') {
269
+ kind = 'dynamic';
270
+ }
271
+ else if (fn.type === 'identifier' && fn.text === 'require') {
272
+ kind = 'commonjs-require';
273
+ }
274
+ if (!kind)
275
+ return null;
276
+ // 取第一个参数(必须是字符串字面量)
277
+ const args = call.childForFieldName('arguments');
278
+ if (!args)
279
+ return null;
280
+ let firstStringArg = null;
281
+ for (let i = 0; i < args.childCount; i++) {
282
+ const arg = args.child(i);
283
+ if (!arg)
284
+ continue;
285
+ if (arg.type === 'string') {
286
+ firstStringArg = arg;
287
+ break;
288
+ }
289
+ }
290
+ if (!firstStringArg)
291
+ return null;
292
+ // 提取 string 字面量的文本内容(剥首尾引号 / 取 string_fragment 子节点)
293
+ let moduleSpecifier = firstStringArg.text.replace(/^['"`]|['"`]$/g, '');
294
+ // tree-sitter 把 string 节点细分为 ' / string_fragment / ';优先用 fragment 子节点更稳
295
+ for (let i = 0; i < firstStringArg.childCount; i++) {
296
+ const child = firstStringArg.child(i);
297
+ if (child?.type === 'string_fragment') {
298
+ moduleSpecifier = child.text;
299
+ break;
300
+ }
301
+ }
302
+ if (!moduleSpecifier)
303
+ return null;
304
+ const isRelative = moduleSpecifier.startsWith('.') || moduleSpecifier.startsWith('/');
305
+ return {
306
+ moduleSpecifier,
307
+ isRelative,
308
+ resolvedPath: null,
309
+ isTypeOnly: false,
310
+ importType: kind,
311
+ };
312
+ }
207
313
  /**
208
314
  * 从 AST tree 提取解析错误
209
315
  */
@@ -702,5 +808,369 @@ export class TypeScriptMapper {
702
808
  }
703
809
  }
704
810
  }
811
+ // ============================================================
812
+ // Feature 152 — call site 抽取(FR-1.1 ~ FR-1.5)
813
+ // ============================================================
814
+ /**
815
+ * 从 AST tree 提取函数调用点(Feature 152 P1)。
816
+ *
817
+ * 覆盖 6 种 calleeKind:free / member / cross-module / super / decorator / unresolved。
818
+ * TS extractor 不产出 dunder kind(CL-08)。
819
+ * 大文件 size guard(EC-14):source.length > 1MB 直接返回空数组。
820
+ */
821
+ extractCallSites(tree, source) {
822
+ // size guard:文件超过 1MB 跳过,避免内存/性能问题
823
+ if (source.length > CALLSITES_MAX_FILE_BYTES) {
824
+ return [];
825
+ }
826
+ const out = [];
827
+ const callerContextStack = [];
828
+ this._walkCallSites(tree.rootNode, callerContextStack, out);
829
+ return out;
830
+ }
831
+ /**
832
+ * 递归遍历 AST 抽取 call sites。
833
+ * callerContextStack 维护当前 function/class 嵌套作用域,进入 SCOPE_DEFINING_TYPES 时压栈。
834
+ * W-3 修复:handleDecorator 返回需跳过的子树节点,walker 在递归前跳过该节点。
835
+ */
836
+ _walkCallSites(node, callerContextStack, out) {
837
+ // 进入作用域定义节点时推入 callerContext(C-4 修复:匿名 arrow/function 也入栈)
838
+ let pushedCtx = false;
839
+ if (SCOPE_DEFINING_TYPES.has(node.type)) {
840
+ const ctx = this._deriveCallerContext(node);
841
+ if (ctx != null) {
842
+ callerContextStack.push(ctx);
843
+ pushedCtx = true;
844
+ }
845
+ }
846
+ // 获取当前 callerContext(栈顶)
847
+ const callerCtx = callerContextStack.length > 0
848
+ ? callerContextStack[callerContextStack.length - 1]
849
+ : undefined;
850
+ // 核心分发:产出 callSite
851
+ let skipSubtree = null;
852
+ switch (node.type) {
853
+ case 'call_expression':
854
+ this._handleCallExpression(node, callerCtx, out);
855
+ break;
856
+ case 'new_expression':
857
+ this._handleNewExpression(node, callerCtx, out);
858
+ break;
859
+ case 'decorator':
860
+ skipSubtree = this._handleDecorator(node, callerCtx, out);
861
+ break;
862
+ case 'tagged_template_expression':
863
+ this._handleTaggedTemplate(node, callerCtx, out);
864
+ break;
865
+ default:
866
+ break;
867
+ }
868
+ // 递归子节点(W-3 修复:跳过 decorator 内 call_expression 子树,避免双计数)
869
+ for (let i = 0; i < node.childCount; i++) {
870
+ const child = node.child(i);
871
+ if (!child)
872
+ continue;
873
+ // 如果当前节点的 handleDecorator 标记了要跳过的子树,则跳过该子树
874
+ if (skipSubtree != null && child.id === skipSubtree.id)
875
+ continue;
876
+ this._walkCallSites(child, callerContextStack, out);
877
+ }
878
+ // 出栈
879
+ if (pushedCtx) {
880
+ callerContextStack.pop();
881
+ }
882
+ }
883
+ /**
884
+ * 推导当前节点的 callerContext 字符串。
885
+ *
886
+ * C-4 修复:匿名 arrow_function / function 也产生 `<arrow:line:col>` / `<fn:line:col>`,
887
+ * 确保内层 callback 不会错误归属外层 class method。
888
+ */
889
+ _deriveCallerContext(node) {
890
+ switch (node.type) {
891
+ case 'function_declaration': {
892
+ const name = fieldText(node, 'name');
893
+ if (name)
894
+ return name;
895
+ // 匿名函数声明(理论上少见)
896
+ return `<fn:${node.startPosition.row + 1}:${node.startPosition.column}>`;
897
+ }
898
+ case 'method_definition': {
899
+ const name = fieldText(node, 'name');
900
+ const className = this._findAncestorClassName(node);
901
+ if (className && name)
902
+ return `${className}.${name}`;
903
+ return name ?? null;
904
+ }
905
+ case 'arrow_function': {
906
+ // 尝试从 variable_declarator 父节点获取变量名
907
+ const parent = node.parent;
908
+ if (parent?.type === 'variable_declarator') {
909
+ const varName = fieldText(parent, 'name');
910
+ if (varName)
911
+ return varName;
912
+ }
913
+ // C-4 修复:匿名 arrow function 用位置唯一化
914
+ return `<arrow:${node.startPosition.row + 1}:${node.startPosition.column}>`;
915
+ }
916
+ case 'function': {
917
+ // 函数表达式(const f = function() {})
918
+ const parent = node.parent;
919
+ if (parent?.type === 'variable_declarator') {
920
+ const varName = fieldText(parent, 'name');
921
+ if (varName)
922
+ return varName;
923
+ }
924
+ // C-4 修复:匿名 function 表达式用位置唯一化
925
+ return `<fn:${node.startPosition.row + 1}:${node.startPosition.column}>`;
926
+ }
927
+ case 'generator_function_declaration': {
928
+ // Codex final W-3 修复:generator function 声明 function* gen() {}
929
+ const name = fieldText(node, 'name');
930
+ if (name)
931
+ return name;
932
+ return `<gen:${node.startPosition.row + 1}:${node.startPosition.column}>`;
933
+ }
934
+ case 'generator_function': {
935
+ // generator function 表达式:const gen = function*() {}
936
+ const parent = node.parent;
937
+ if (parent?.type === 'variable_declarator') {
938
+ const varName = fieldText(parent, 'name');
939
+ if (varName)
940
+ return varName;
941
+ }
942
+ return `<gen:${node.startPosition.row + 1}:${node.startPosition.column}>`;
943
+ }
944
+ default:
945
+ return null;
946
+ }
947
+ }
948
+ /**
949
+ * 向上遍历 AST 找到最近的 class_declaration 节点,返回类名。
950
+ * 用于 method_definition 推导 callerContext(如 "Foo.bar")。
951
+ */
952
+ _findAncestorClassName(node) {
953
+ let current = node.parent;
954
+ while (current != null) {
955
+ if (current.type === 'class_body' || current.type === 'class_declaration' || current.type === 'class') {
956
+ // class_body 的父节点才是 class_declaration
957
+ if (current.type === 'class_body') {
958
+ const classDecl = current.parent;
959
+ if (classDecl) {
960
+ const name = fieldText(classDecl, 'name');
961
+ if (name)
962
+ return name;
963
+ }
964
+ }
965
+ else {
966
+ const name = fieldText(current, 'name');
967
+ if (name)
968
+ return name;
969
+ }
970
+ }
971
+ current = current.parent;
972
+ }
973
+ return null;
974
+ }
975
+ /**
976
+ * 处理 call_expression 节点,分流 7 种形态(T-008):
977
+ * 1. dynamic import(`import('./x')`) → unresolved,calleeName='import'
978
+ * 2. super() 自调用 → super
979
+ * 3. eval/Function identifier → unresolved
980
+ * 4. 普通 identifier 调用 → free
981
+ * 5. C-3 修复:import().then() 链式 — 检测并跳过外层 .then 防双计数
982
+ * 6. member_expression → handleMemberCall
983
+ * 7. optional chain 等复杂形式 → 尽力提取 member_expression
984
+ *
985
+ * C-8 修复:mkCallSite 不接受 dynamicReason 参数(CallSite schema 仅 6 字段)。
986
+ */
987
+ _handleCallExpression(node, callerCtx, out) {
988
+ const funcNode = node.childForFieldName('function');
989
+ if (!funcNode)
990
+ return;
991
+ // dynamic import:`import('./x')` — funcNode.type 为 'import'
992
+ if (funcNode.type === 'import') {
993
+ out.push(this._mkCallSite('import', 'unresolved', node, callerCtx));
994
+ return;
995
+ }
996
+ // super() 构造器自调用(call_expression 中 func 为 super)
997
+ if (funcNode.type === 'super') {
998
+ out.push(this._mkCallSite('super', 'super', node, callerCtx));
999
+ return;
1000
+ }
1001
+ // identifier 形式:foo() / eval() / Function()
1002
+ if (funcNode.type === 'identifier') {
1003
+ const name = funcNode.text;
1004
+ // eval / Function → unresolved(C-8 修复:无 dynamicReason 元数据)
1005
+ if (DYNAMIC_CALL_NAMES.has(name)) {
1006
+ out.push(this._mkCallSite(name, 'unresolved', node, callerCtx));
1007
+ return;
1008
+ }
1009
+ // 普通 free 调用
1010
+ out.push(this._mkCallSite(name, 'free', node, callerCtx));
1011
+ return;
1012
+ }
1013
+ // member_expression 形式:obj.method() / Class.method()
1014
+ if (funcNode.type === 'member_expression') {
1015
+ // C-3 修复:检测链式 `import('./x').then(cb)` 模式,避免 .then 被双计数
1016
+ // 模式:call_expression(function=member_expression(object=call_expression(function=import)))
1017
+ const objectNode = funcNode.childForFieldName('object');
1018
+ if (objectNode?.type === 'call_expression') {
1019
+ const innerFunc = objectNode.childForFieldName('function');
1020
+ if (innerFunc?.type === 'import') {
1021
+ // 外层 .then(cb) 跳过——内层 import() 由递归子节点产出
1022
+ return;
1023
+ }
1024
+ }
1025
+ this._handleMemberCall(funcNode, node, callerCtx, out);
1026
+ return;
1027
+ }
1028
+ // optional_member_expression:obj?.method()(tree-sitter 对应节点类型)
1029
+ if (funcNode.type === 'optional_member_expression') {
1030
+ this._handleMemberCall(funcNode, node, callerCtx, out);
1031
+ return;
1032
+ }
1033
+ // 其他复杂形式(括号包裹的表达式等)→ 跳过
1034
+ }
1035
+ /**
1036
+ * 处理 member_expression / optional_member_expression 中的调用(严格与 PythonMapper L943-953 对齐):
1037
+ * - this.method() → member(无 qualifier)
1038
+ * - super.method() → super
1039
+ * - 首字母大写 qualifier(Class.method)→ member + qualifier
1040
+ * - 首字母小写 qualifier(mod.fn)→ cross-module + qualifier(关键:不是 member)
1041
+ */
1042
+ _handleMemberCall(memberNode, callNode, callerCtx, out) {
1043
+ const objectNode = memberNode.childForFieldName('object');
1044
+ const propertyNode = memberNode.childForFieldName('property');
1045
+ if (!propertyNode)
1046
+ return;
1047
+ const calleeName = propertyNode.text;
1048
+ const qualifier = objectNode?.text ?? '';
1049
+ // this.method() → member(无 qualifier,resolver 通过 callerContext 定位类)
1050
+ if (qualifier === 'this') {
1051
+ out.push(this._mkCallSite(calleeName, 'member', callNode, callerCtx));
1052
+ return;
1053
+ }
1054
+ // super.method() → super
1055
+ if (qualifier === 'super') {
1056
+ out.push(this._mkCallSite(calleeName, 'super', callNode, callerCtx));
1057
+ return;
1058
+ }
1059
+ // 首字母大写(Class.method)→ member + qualifier
1060
+ if (qualifier && /^[A-Z]/.test(qualifier)) {
1061
+ out.push(this._mkCallSite(calleeName, 'member', callNode, callerCtx, qualifier));
1062
+ return;
1063
+ }
1064
+ // 首字母小写(mod.fn)→ cross-module + qualifier(与 PythonMapper 对齐)
1065
+ if (qualifier) {
1066
+ out.push(this._mkCallSite(calleeName, 'cross-module', callNode, callerCtx, qualifier));
1067
+ return;
1068
+ }
1069
+ // 无 qualifier 兜底 → cross-module
1070
+ out.push(this._mkCallSite(calleeName, 'cross-module', callNode, callerCtx));
1071
+ }
1072
+ /**
1073
+ * 处理 new_expression 节点(T-009)。
1074
+ * - new Foo() → free,calleeName='Foo'(FR-1.3)
1075
+ * - new Function('code') → unresolved(W-2 修复,避免误判为本地构造)
1076
+ * - new Foo.Sub() → 委派 handleMemberCall
1077
+ * C-8 修复:不向 CallSite schema 添加 viaNew 元数据字段。
1078
+ */
1079
+ _handleNewExpression(node, callerCtx, out) {
1080
+ const constructorNode = node.childForFieldName('constructor');
1081
+ if (!constructorNode)
1082
+ return;
1083
+ // identifier 形式:new Foo()
1084
+ if (constructorNode.type === 'identifier') {
1085
+ const name = constructorNode.text;
1086
+ // W-2 修复:new Function('code') → unresolved(动态构造,避免误判为本地构造)
1087
+ if (name === 'Function') {
1088
+ out.push(this._mkCallSite('Function', 'unresolved', node, callerCtx));
1089
+ return;
1090
+ }
1091
+ // 普通构造:new Foo() → free,calleeName='Foo'
1092
+ out.push(this._mkCallSite(name, 'free', node, callerCtx));
1093
+ return;
1094
+ }
1095
+ // member_expression 形式:new Foo.Sub()(如 new express.Router())
1096
+ if (constructorNode.type === 'member_expression') {
1097
+ this._handleMemberCall(constructorNode, node, callerCtx, out);
1098
+ return;
1099
+ }
1100
+ }
1101
+ /**
1102
+ * 处理 decorator 节点(T-010)。
1103
+ * - 带参 decorator `@Foo()` → decorator kind
1104
+ * - bare decorator `@Foo`(无括号)→ 不产出(与 Python CL-04 对齐)
1105
+ *
1106
+ * W-3 修复:找到带参 decorator 的 call_expression 后产出 callSite,
1107
+ * 返回该 call_expression 节点作为跳过标记,walker 不再递归进入,
1108
+ * 避免 call_expression 子节点被 walker 再次产出 free/member callSite(双计数)。
1109
+ *
1110
+ * @returns 需要跳过的子树节点(call_expression),或 null(bare decorator 不产出)
1111
+ */
1112
+ _handleDecorator(node, callerCtx, out) {
1113
+ // 找 decorator 节点的 call_expression 子节点(带参 decorator 才有)
1114
+ const callExpr = findChild(node, 'call_expression');
1115
+ if (!callExpr) {
1116
+ // bare decorator(@Foo 无括号)→ 不产出,无需跳过子树
1117
+ return null;
1118
+ }
1119
+ // 从 call_expression 中取 callee 名称
1120
+ const funcNode = callExpr.childForFieldName('function');
1121
+ if (!funcNode)
1122
+ return callExpr;
1123
+ let calleeName;
1124
+ if (funcNode.type === 'identifier') {
1125
+ calleeName = funcNode.text;
1126
+ }
1127
+ else if (funcNode.type === 'member_expression') {
1128
+ const propNode = funcNode.childForFieldName('property');
1129
+ calleeName = propNode?.text ?? 'unknown';
1130
+ }
1131
+ else {
1132
+ calleeName = 'unknown';
1133
+ }
1134
+ out.push(this._mkCallSite(calleeName, 'decorator', callExpr, callerCtx));
1135
+ // 返回 callExpr,让 walker 跳过该子树,避免双计数(W-3 修复)
1136
+ return callExpr;
1137
+ }
1138
+ /**
1139
+ * 处理 tagged_template_expression 节点(T-010)。
1140
+ * - tag 为 identifier → free
1141
+ * - tag 为 member_expression → 委派 handleMemberCall
1142
+ */
1143
+ _handleTaggedTemplate(node, callerCtx, out) {
1144
+ const tagNode = node.childForFieldName('tag');
1145
+ if (!tagNode)
1146
+ return;
1147
+ if (tagNode.type === 'identifier') {
1148
+ out.push(this._mkCallSite(tagNode.text, 'free', node, callerCtx));
1149
+ return;
1150
+ }
1151
+ if (tagNode.type === 'member_expression') {
1152
+ this._handleMemberCall(tagNode, node, callerCtx, out);
1153
+ return;
1154
+ }
1155
+ }
1156
+ /**
1157
+ * 构造单个 CallSite 记录(6 字段,C-8 修复:不接受 dynamicReason / viaNew 参数)。
1158
+ * 字段:calleeName / calleeKind / line / column / callerContext / calleeQualifier
1159
+ */
1160
+ _mkCallSite(calleeName, calleeKind, callNode, callerContext, calleeQualifier) {
1161
+ const cs = {
1162
+ calleeName,
1163
+ calleeKind,
1164
+ line: callNode.startPosition.row + 1,
1165
+ };
1166
+ if (callNode.startPosition.column !== undefined) {
1167
+ cs.column = callNode.startPosition.column;
1168
+ }
1169
+ if (callerContext !== undefined)
1170
+ cs.callerContext = callerContext;
1171
+ if (calleeQualifier !== undefined)
1172
+ cs.calleeQualifier = calleeQualifier;
1173
+ return cs;
1174
+ }
705
1175
  }
706
1176
  //# sourceMappingURL=typescript-mapper.js.map