spectra-cli 4.1.1 → 4.3.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 (682) hide show
  1. package/README.md +12 -5
  2. package/dist/.spectra-build-meta.json +9 -0
  3. package/dist/adapters/go-adapter.d.ts.map +1 -1
  4. package/dist/adapters/go-adapter.js +2 -0
  5. package/dist/adapters/go-adapter.js.map +1 -1
  6. package/dist/adapters/index.d.ts +1 -1
  7. package/dist/adapters/index.d.ts.map +1 -1
  8. package/dist/adapters/java-adapter.d.ts.map +1 -1
  9. package/dist/adapters/java-adapter.js +2 -0
  10. package/dist/adapters/java-adapter.js.map +1 -1
  11. package/dist/adapters/language-adapter.d.ts +42 -9
  12. package/dist/adapters/language-adapter.d.ts.map +1 -1
  13. package/dist/adapters/python-adapter.d.ts +34 -6
  14. package/dist/adapters/python-adapter.d.ts.map +1 -1
  15. package/dist/adapters/python-adapter.js +168 -61
  16. package/dist/adapters/python-adapter.js.map +1 -1
  17. package/dist/adapters/ts-js-adapter.d.ts +13 -5
  18. package/dist/adapters/ts-js-adapter.d.ts.map +1 -1
  19. package/dist/adapters/ts-js-adapter.js +55 -14
  20. package/dist/adapters/ts-js-adapter.js.map +1 -1
  21. package/dist/batch/batch-orchestrator.d.ts +74 -5
  22. package/dist/batch/batch-orchestrator.d.ts.map +1 -1
  23. package/dist/batch/batch-orchestrator.js +583 -70
  24. package/dist/batch/batch-orchestrator.js.map +1 -1
  25. package/dist/batch/delta-regenerator.d.ts +2 -2
  26. package/dist/batch/delta-regenerator.d.ts.map +1 -1
  27. package/dist/batch/delta-regenerator.js +21 -28
  28. package/dist/batch/delta-regenerator.js.map +1 -1
  29. package/dist/batch/module-grouper.d.ts +9 -2
  30. package/dist/batch/module-grouper.d.ts.map +1 -1
  31. package/dist/batch/module-grouper.js +3 -1
  32. package/dist/batch/module-grouper.js.map +1 -1
  33. package/dist/batch/regen-plan.d.ts +78 -0
  34. package/dist/batch/regen-plan.d.ts.map +1 -0
  35. package/dist/batch/regen-plan.js +93 -0
  36. package/dist/batch/regen-plan.js.map +1 -0
  37. package/dist/cli/commands/batch.d.ts.map +1 -1
  38. package/dist/cli/commands/batch.js +36 -8
  39. package/dist/cli/commands/batch.js.map +1 -1
  40. package/dist/cli/commands/graph.js +1 -1
  41. package/dist/cli/commands/graph.js.map +1 -1
  42. package/dist/cli/commands/index.d.ts +8 -0
  43. package/dist/cli/commands/index.d.ts.map +1 -0
  44. package/dist/cli/commands/index.js +274 -0
  45. package/dist/cli/commands/index.js.map +1 -0
  46. package/dist/cli/commands/query.d.ts.map +1 -1
  47. package/dist/cli/commands/query.js +3 -1
  48. package/dist/cli/commands/query.js.map +1 -1
  49. package/dist/cli/commands/scaffold-kb.d.ts +9 -0
  50. package/dist/cli/commands/scaffold-kb.d.ts.map +1 -0
  51. package/dist/cli/commands/scaffold-kb.js +179 -0
  52. package/dist/cli/commands/scaffold-kb.js.map +1 -0
  53. package/dist/cli/index.js +33 -14
  54. package/dist/cli/index.js.map +1 -1
  55. package/dist/cli/utils/error-handler.d.ts +0 -6
  56. package/dist/cli/utils/error-handler.d.ts.map +1 -1
  57. package/dist/cli/utils/error-handler.js +0 -13
  58. package/dist/cli/utils/error-handler.js.map +1 -1
  59. package/dist/cli/utils/parse-args.d.ts +55 -3
  60. package/dist/cli/utils/parse-args.d.ts.map +1 -1
  61. package/dist/cli/utils/parse-args.js +176 -13
  62. package/dist/cli/utils/parse-args.js.map +1 -1
  63. package/dist/cli/version-meta.d.ts +16 -0
  64. package/dist/cli/version-meta.d.ts.map +1 -0
  65. package/dist/cli/version-meta.js +28 -0
  66. package/dist/cli/version-meta.js.map +1 -0
  67. package/dist/core/ast-analyzer.d.ts.map +1 -1
  68. package/dist/core/ast-analyzer.js +75 -5
  69. package/dist/core/ast-analyzer.js.map +1 -1
  70. package/dist/core/import-resolver.d.ts +93 -0
  71. package/dist/core/import-resolver.d.ts.map +1 -0
  72. package/dist/core/import-resolver.js +414 -0
  73. package/dist/core/import-resolver.js.map +1 -0
  74. package/dist/core/query-mappers/base-mapper.d.ts +13 -0
  75. package/dist/core/query-mappers/base-mapper.d.ts.map +1 -1
  76. package/dist/core/query-mappers/go-mapper.d.ts +68 -0
  77. package/dist/core/query-mappers/go-mapper.d.ts.map +1 -1
  78. package/dist/core/query-mappers/go-mapper.js +421 -0
  79. package/dist/core/query-mappers/go-mapper.js.map +1 -1
  80. package/dist/core/query-mappers/java-mapper.d.ts +196 -0
  81. package/dist/core/query-mappers/java-mapper.d.ts.map +1 -1
  82. package/dist/core/query-mappers/java-mapper.js +600 -0
  83. package/dist/core/query-mappers/java-mapper.js.map +1 -1
  84. package/dist/core/query-mappers/python-mapper.d.ts +55 -0
  85. package/dist/core/query-mappers/python-mapper.d.ts.map +1 -1
  86. package/dist/core/query-mappers/python-mapper.js +273 -0
  87. package/dist/core/query-mappers/python-mapper.js.map +1 -1
  88. package/dist/core/query-mappers/typescript-mapper.d.ts +102 -0
  89. package/dist/core/query-mappers/typescript-mapper.d.ts.map +1 -1
  90. package/dist/core/query-mappers/typescript-mapper.js +470 -0
  91. package/dist/core/query-mappers/typescript-mapper.js.map +1 -1
  92. package/dist/core/single-spec-orchestrator.d.ts +21 -0
  93. package/dist/core/single-spec-orchestrator.d.ts.map +1 -1
  94. package/dist/core/single-spec-orchestrator.js +187 -23
  95. package/dist/core/single-spec-orchestrator.js.map +1 -1
  96. package/dist/core/skeleton-hash.d.ts +33 -0
  97. package/dist/core/skeleton-hash.d.ts.map +1 -0
  98. package/dist/core/skeleton-hash.js +76 -0
  99. package/dist/core/skeleton-hash.js.map +1 -0
  100. package/dist/core/tree-sitter-analyzer.d.ts +7 -0
  101. package/dist/core/tree-sitter-analyzer.d.ts.map +1 -1
  102. package/dist/core/tree-sitter-analyzer.js +32 -1
  103. package/dist/core/tree-sitter-analyzer.js.map +1 -1
  104. package/dist/core/tree-sitter-fallback.d.ts +12 -4
  105. package/dist/core/tree-sitter-fallback.d.ts.map +1 -1
  106. package/dist/core/tree-sitter-fallback.js +160 -12
  107. package/dist/core/tree-sitter-fallback.js.map +1 -1
  108. package/dist/extraction/extraction-types.d.ts +25 -25
  109. package/dist/extraction/image-extractor.d.ts.map +1 -1
  110. package/dist/extraction/image-extractor.js +3 -1
  111. package/dist/extraction/image-extractor.js.map +1 -1
  112. package/dist/extraction/markdown-extractor.d.ts.map +1 -1
  113. package/dist/extraction/markdown-extractor.js +3 -1
  114. package/dist/extraction/markdown-extractor.js.map +1 -1
  115. package/dist/generator/frontmatter.d.ts +5 -0
  116. package/dist/generator/frontmatter.d.ts.map +1 -1
  117. package/dist/generator/frontmatter.js +4 -0
  118. package/dist/generator/frontmatter.js.map +1 -1
  119. package/dist/generator/index-generator.d.ts +3 -3
  120. package/dist/generator/index-generator.d.ts.map +1 -1
  121. package/dist/generator/index-generator.js +1 -1
  122. package/dist/generator/index-generator.js.map +1 -1
  123. package/dist/graph/directory-graph.d.ts +14 -4
  124. package/dist/graph/directory-graph.d.ts.map +1 -1
  125. package/dist/graph/directory-graph.js +71 -128
  126. package/dist/graph/directory-graph.js.map +1 -1
  127. package/dist/graph/mermaid-renderer.d.ts +8 -5
  128. package/dist/graph/mermaid-renderer.d.ts.map +1 -1
  129. package/dist/graph/mermaid-renderer.js +3 -3
  130. package/dist/graph/mermaid-renderer.js.map +1 -1
  131. package/dist/graph/topological-sort.d.ts +13 -6
  132. package/dist/graph/topological-sort.d.ts.map +1 -1
  133. package/dist/graph/topological-sort.js +2 -2
  134. package/dist/graph/topological-sort.js.map +1 -1
  135. package/dist/kb-mcp/index.d.ts +14 -0
  136. package/dist/kb-mcp/index.d.ts.map +1 -0
  137. package/dist/kb-mcp/index.js +24 -0
  138. package/dist/kb-mcp/index.js.map +1 -0
  139. package/dist/kb-mcp/lib/kb-error.d.ts +21 -0
  140. package/dist/kb-mcp/lib/kb-error.d.ts.map +1 -0
  141. package/dist/kb-mcp/lib/kb-error.js +28 -0
  142. package/dist/kb-mcp/lib/kb-error.js.map +1 -0
  143. package/dist/kb-mcp/lib/kb-locator.d.ts +58 -0
  144. package/dist/kb-mcp/lib/kb-locator.d.ts.map +1 -0
  145. package/dist/kb-mcp/lib/kb-locator.js +85 -0
  146. package/dist/kb-mcp/lib/kb-locator.js.map +1 -0
  147. package/dist/kb-mcp/lib/result-merger.d.ts +35 -0
  148. package/dist/kb-mcp/lib/result-merger.d.ts.map +1 -0
  149. package/dist/kb-mcp/lib/result-merger.js +64 -0
  150. package/dist/kb-mcp/lib/result-merger.js.map +1 -0
  151. package/dist/kb-mcp/server.d.ts +12 -0
  152. package/dist/kb-mcp/server.d.ts.map +1 -0
  153. package/dist/kb-mcp/server.js +29 -0
  154. package/dist/kb-mcp/server.js.map +1 -0
  155. package/dist/kb-mcp/tools/kb-api-lookup.d.ts +28 -0
  156. package/dist/kb-mcp/tools/kb-api-lookup.d.ts.map +1 -0
  157. package/dist/kb-mcp/tools/kb-api-lookup.js +237 -0
  158. package/dist/kb-mcp/tools/kb-api-lookup.js.map +1 -0
  159. package/dist/kb-mcp/tools/kb-doc-lookup.d.ts +20 -0
  160. package/dist/kb-mcp/tools/kb-doc-lookup.d.ts.map +1 -0
  161. package/dist/kb-mcp/tools/kb-doc-lookup.js +92 -0
  162. package/dist/kb-mcp/tools/kb-doc-lookup.js.map +1 -0
  163. package/dist/kb-mcp/tools/kb-search.d.ts +23 -0
  164. package/dist/kb-mcp/tools/kb-search.d.ts.map +1 -0
  165. package/dist/kb-mcp/tools/kb-search.js +126 -0
  166. package/dist/kb-mcp/tools/kb-search.js.map +1 -0
  167. package/dist/knowledge-graph/call-resolver.d.ts +64 -0
  168. package/dist/knowledge-graph/call-resolver.d.ts.map +1 -0
  169. package/dist/knowledge-graph/call-resolver.js +323 -0
  170. package/dist/knowledge-graph/call-resolver.js.map +1 -0
  171. package/dist/knowledge-graph/import-resolver.d.ts +39 -0
  172. package/dist/knowledge-graph/import-resolver.d.ts.map +1 -0
  173. package/dist/knowledge-graph/import-resolver.js +214 -0
  174. package/dist/knowledge-graph/import-resolver.js.map +1 -0
  175. package/dist/knowledge-graph/incremental.d.ts +131 -0
  176. package/dist/knowledge-graph/incremental.d.ts.map +1 -0
  177. package/dist/knowledge-graph/incremental.js +432 -0
  178. package/dist/knowledge-graph/incremental.js.map +1 -0
  179. package/dist/knowledge-graph/index.d.ts +85 -0
  180. package/dist/knowledge-graph/index.d.ts.map +1 -0
  181. package/dist/knowledge-graph/index.js +198 -0
  182. package/dist/knowledge-graph/index.js.map +1 -0
  183. package/dist/knowledge-graph/module-derivation.d.ts +252 -0
  184. package/dist/knowledge-graph/module-derivation.d.ts.map +1 -0
  185. package/dist/knowledge-graph/module-derivation.js +418 -0
  186. package/dist/knowledge-graph/module-derivation.js.map +1 -0
  187. package/dist/knowledge-graph/persistence.d.ts +310 -0
  188. package/dist/knowledge-graph/persistence.d.ts.map +1 -0
  189. package/dist/knowledge-graph/persistence.js +280 -0
  190. package/dist/knowledge-graph/persistence.js.map +1 -0
  191. package/dist/knowledge-graph/query-helpers.d.ts +191 -0
  192. package/dist/knowledge-graph/query-helpers.d.ts.map +1 -0
  193. package/dist/knowledge-graph/query-helpers.js +559 -0
  194. package/dist/knowledge-graph/query-helpers.js.map +1 -0
  195. package/dist/knowledge-graph/relativize.d.ts +51 -0
  196. package/dist/knowledge-graph/relativize.d.ts.map +1 -0
  197. package/dist/knowledge-graph/relativize.js +104 -0
  198. package/dist/knowledge-graph/relativize.js.map +1 -0
  199. package/dist/knowledge-graph/unified-graph.d.ts +310 -0
  200. package/dist/knowledge-graph/unified-graph.d.ts.map +1 -0
  201. package/dist/knowledge-graph/unified-graph.js +182 -0
  202. package/dist/knowledge-graph/unified-graph.js.map +1 -0
  203. package/dist/mcp/agent-context-tools.d.ts +53 -0
  204. package/dist/mcp/agent-context-tools.d.ts.map +1 -0
  205. package/dist/mcp/agent-context-tools.js +806 -0
  206. package/dist/mcp/agent-context-tools.js.map +1 -0
  207. package/dist/mcp/file-nav-tools.d.ts +42 -0
  208. package/dist/mcp/file-nav-tools.d.ts.map +1 -0
  209. package/dist/mcp/file-nav-tools.js +318 -0
  210. package/dist/mcp/file-nav-tools.js.map +1 -0
  211. package/dist/mcp/graph-tools.d.ts +22 -0
  212. package/dist/mcp/graph-tools.d.ts.map +1 -1
  213. package/dist/mcp/graph-tools.js +204 -133
  214. package/dist/mcp/graph-tools.js.map +1 -1
  215. package/dist/mcp/lib/file-nav-helpers.d.ts +128 -0
  216. package/dist/mcp/lib/file-nav-helpers.d.ts.map +1 -0
  217. package/dist/mcp/lib/file-nav-helpers.js +305 -0
  218. package/dist/mcp/lib/file-nav-helpers.js.map +1 -0
  219. package/dist/mcp/lib/response-helpers.d.ts +67 -0
  220. package/dist/mcp/lib/response-helpers.d.ts.map +1 -0
  221. package/dist/mcp/lib/response-helpers.js +103 -0
  222. package/dist/mcp/lib/response-helpers.js.map +1 -0
  223. package/dist/mcp/lib/telemetry.d.ts +69 -0
  224. package/dist/mcp/lib/telemetry.d.ts.map +1 -0
  225. package/dist/mcp/lib/telemetry.js +113 -0
  226. package/dist/mcp/lib/telemetry.js.map +1 -0
  227. package/dist/mcp/lib/tool-response.d.ts +46 -0
  228. package/dist/mcp/lib/tool-response.d.ts.map +1 -0
  229. package/dist/mcp/lib/tool-response.js +83 -0
  230. package/dist/mcp/lib/tool-response.js.map +1 -0
  231. package/dist/mcp/server.d.ts +14 -1
  232. package/dist/mcp/server.d.ts.map +1 -1
  233. package/dist/mcp/server.js +216 -158
  234. package/dist/mcp/server.js.map +1 -1
  235. package/dist/models/call-site.d.ts +68 -0
  236. package/dist/models/call-site.d.ts.map +1 -0
  237. package/dist/models/call-site.js +60 -0
  238. package/dist/models/call-site.js.map +1 -0
  239. package/dist/models/code-skeleton.d.ts +80 -6
  240. package/dist/models/code-skeleton.d.ts.map +1 -1
  241. package/dist/models/code-skeleton.js +30 -0
  242. package/dist/models/code-skeleton.js.map +1 -1
  243. package/dist/models/drift-item.d.ts +4 -4
  244. package/dist/models/module-spec.d.ts +173 -94
  245. package/dist/models/module-spec.d.ts.map +1 -1
  246. package/dist/models/module-spec.js +6 -0
  247. package/dist/models/module-spec.js.map +1 -1
  248. package/dist/panoramic/adr-decision-pipeline.d.ts +53 -0
  249. package/dist/panoramic/adr-decision-pipeline.d.ts.map +1 -0
  250. package/dist/panoramic/adr-decision-pipeline.js +685 -0
  251. package/dist/panoramic/adr-decision-pipeline.js.map +1 -0
  252. package/dist/panoramic/api-surface-generator.d.ts +56 -0
  253. package/dist/panoramic/api-surface-generator.d.ts.map +1 -0
  254. package/dist/panoramic/api-surface-generator.js +1671 -0
  255. package/dist/panoramic/api-surface-generator.js.map +1 -0
  256. package/dist/panoramic/architecture-ir-builder.d.ts +19 -0
  257. package/dist/panoramic/architecture-ir-builder.d.ts.map +1 -0
  258. package/dist/panoramic/architecture-ir-builder.js +561 -0
  259. package/dist/panoramic/architecture-ir-builder.js.map +1 -0
  260. package/dist/panoramic/architecture-ir-exporters.d.ts +7 -0
  261. package/dist/panoramic/architecture-ir-exporters.d.ts.map +1 -0
  262. package/dist/panoramic/architecture-ir-exporters.js +183 -0
  263. package/dist/panoramic/architecture-ir-exporters.js.map +1 -0
  264. package/dist/panoramic/architecture-ir-generator.d.ts +36 -0
  265. package/dist/panoramic/architecture-ir-generator.d.ts.map +1 -0
  266. package/dist/panoramic/architecture-ir-generator.js +51 -0
  267. package/dist/panoramic/architecture-ir-generator.js.map +1 -0
  268. package/dist/panoramic/architecture-ir-mermaid-adapter.d.ts +6 -0
  269. package/dist/panoramic/architecture-ir-mermaid-adapter.d.ts.map +1 -0
  270. package/dist/panoramic/architecture-ir-mermaid-adapter.js +98 -0
  271. package/dist/panoramic/architecture-ir-mermaid-adapter.js.map +1 -0
  272. package/dist/panoramic/architecture-ir-model.d.ts +87 -0
  273. package/dist/panoramic/architecture-ir-model.d.ts.map +1 -0
  274. package/dist/panoramic/architecture-ir-model.js +20 -0
  275. package/dist/panoramic/architecture-ir-model.js.map +1 -0
  276. package/dist/panoramic/architecture-narrative.d.ts +68 -0
  277. package/dist/panoramic/architecture-narrative.d.ts.map +1 -0
  278. package/dist/panoramic/architecture-narrative.js +401 -0
  279. package/dist/panoramic/architecture-narrative.js.map +1 -0
  280. package/dist/panoramic/architecture-overview-generator.d.ts +31 -0
  281. package/dist/panoramic/architecture-overview-generator.d.ts.map +1 -0
  282. package/dist/panoramic/architecture-overview-generator.js +454 -0
  283. package/dist/panoramic/architecture-overview-generator.js.map +1 -0
  284. package/dist/panoramic/architecture-overview-model.d.ts +77 -0
  285. package/dist/panoramic/architecture-overview-model.d.ts.map +1 -0
  286. package/dist/panoramic/architecture-overview-model.js +31 -0
  287. package/dist/panoramic/architecture-overview-model.js.map +1 -0
  288. package/dist/panoramic/batch-project-docs.d.ts.map +1 -1
  289. package/dist/panoramic/batch-project-docs.js +4 -2
  290. package/dist/panoramic/batch-project-docs.js.map +1 -1
  291. package/dist/panoramic/builders/component-view-builder.d.ts +25 -1
  292. package/dist/panoramic/builders/component-view-builder.d.ts.map +1 -1
  293. package/dist/panoramic/builders/component-view-builder.js +83 -3
  294. package/dist/panoramic/builders/component-view-builder.js.map +1 -1
  295. package/dist/panoramic/builders/doc-graph-builder.d.ts +15 -2
  296. package/dist/panoramic/builders/doc-graph-builder.d.ts.map +1 -1
  297. package/dist/panoramic/builders/doc-graph-builder.js +20 -0
  298. package/dist/panoramic/builders/doc-graph-builder.js.map +1 -1
  299. package/dist/panoramic/component-view-builder.d.ts +17 -0
  300. package/dist/panoramic/component-view-builder.d.ts.map +1 -0
  301. package/dist/panoramic/component-view-builder.js +652 -0
  302. package/dist/panoramic/component-view-builder.js.map +1 -0
  303. package/dist/panoramic/component-view-model.d.ts +127 -0
  304. package/dist/panoramic/component-view-model.d.ts.map +1 -0
  305. package/dist/panoramic/component-view-model.js +65 -0
  306. package/dist/panoramic/component-view-model.js.map +1 -0
  307. package/dist/panoramic/config-reference-generator.d.ts +78 -0
  308. package/dist/panoramic/config-reference-generator.d.ts.map +1 -0
  309. package/dist/panoramic/config-reference-generator.js +199 -0
  310. package/dist/panoramic/config-reference-generator.js.map +1 -0
  311. package/dist/panoramic/coverage-auditor.d.ts +95 -0
  312. package/dist/panoramic/coverage-auditor.d.ts.map +1 -0
  313. package/dist/panoramic/coverage-auditor.js +290 -0
  314. package/dist/panoramic/coverage-auditor.js.map +1 -0
  315. package/dist/panoramic/cross-package-analyzer.d.ts +112 -0
  316. package/dist/panoramic/cross-package-analyzer.d.ts.map +1 -0
  317. package/dist/panoramic/cross-package-analyzer.js +258 -0
  318. package/dist/panoramic/cross-package-analyzer.js.map +1 -0
  319. package/dist/panoramic/data-model-generator.d.ts +528 -0
  320. package/dist/panoramic/data-model-generator.d.ts.map +1 -0
  321. package/dist/panoramic/data-model-generator.js +647 -0
  322. package/dist/panoramic/data-model-generator.js.map +1 -0
  323. package/dist/panoramic/doc-graph-builder.d.ts +80 -0
  324. package/dist/panoramic/doc-graph-builder.d.ts.map +1 -0
  325. package/dist/panoramic/doc-graph-builder.js +352 -0
  326. package/dist/panoramic/doc-graph-builder.js.map +1 -0
  327. package/dist/panoramic/docs-bundle-manifest-reader.d.ts +26 -0
  328. package/dist/panoramic/docs-bundle-manifest-reader.d.ts.map +1 -0
  329. package/dist/panoramic/docs-bundle-manifest-reader.js +106 -0
  330. package/dist/panoramic/docs-bundle-manifest-reader.js.map +1 -0
  331. package/dist/panoramic/docs-bundle-orchestrator.d.ts +14 -0
  332. package/dist/panoramic/docs-bundle-orchestrator.d.ts.map +1 -0
  333. package/dist/panoramic/docs-bundle-orchestrator.js +538 -0
  334. package/dist/panoramic/docs-bundle-orchestrator.js.map +1 -0
  335. package/dist/panoramic/docs-bundle-profiles.d.ts +4 -0
  336. package/dist/panoramic/docs-bundle-profiles.d.ts.map +1 -0
  337. package/dist/panoramic/docs-bundle-profiles.js +82 -0
  338. package/dist/panoramic/docs-bundle-profiles.js.map +1 -0
  339. package/dist/panoramic/docs-bundle-types.d.ts +94 -0
  340. package/dist/panoramic/docs-bundle-types.d.ts.map +1 -0
  341. package/dist/panoramic/docs-bundle-types.js +10 -0
  342. package/dist/panoramic/docs-bundle-types.js.map +1 -0
  343. package/dist/panoramic/docs-quality-evaluator.d.ts +31 -0
  344. package/dist/panoramic/docs-quality-evaluator.d.ts.map +1 -0
  345. package/dist/panoramic/docs-quality-evaluator.js +941 -0
  346. package/dist/panoramic/docs-quality-evaluator.js.map +1 -0
  347. package/dist/panoramic/docs-quality-model.d.ts +125 -0
  348. package/dist/panoramic/docs-quality-model.d.ts.map +1 -0
  349. package/dist/panoramic/docs-quality-model.js +166 -0
  350. package/dist/panoramic/docs-quality-model.js.map +1 -0
  351. package/dist/panoramic/dynamic-scenarios-builder.d.ts +18 -0
  352. package/dist/panoramic/dynamic-scenarios-builder.d.ts.map +1 -0
  353. package/dist/panoramic/dynamic-scenarios-builder.js +316 -0
  354. package/dist/panoramic/dynamic-scenarios-builder.js.map +1 -0
  355. package/dist/panoramic/event-surface-generator.d.ts +52 -0
  356. package/dist/panoramic/event-surface-generator.d.ts.map +1 -0
  357. package/dist/panoramic/event-surface-generator.js +507 -0
  358. package/dist/panoramic/event-surface-generator.js.map +1 -0
  359. package/dist/panoramic/generator-registry.d.ts +1 -1
  360. package/dist/panoramic/generator-registry.d.ts.map +1 -1
  361. package/dist/panoramic/generator-registry.js +5 -2
  362. package/dist/panoramic/generator-registry.js.map +1 -1
  363. package/dist/panoramic/generators/cross-package-analyzer.d.ts +5 -5
  364. package/dist/panoramic/generators/cross-package-analyzer.d.ts.map +1 -1
  365. package/dist/panoramic/generators/cross-package-analyzer.js +1 -1
  366. package/dist/panoramic/generators/cross-package-analyzer.js.map +1 -1
  367. package/dist/panoramic/generators/data-model-generator.d.ts +27 -27
  368. package/dist/panoramic/graph/confidence-mapper.d.ts +18 -0
  369. package/dist/panoramic/graph/confidence-mapper.d.ts.map +1 -1
  370. package/dist/panoramic/graph/confidence-mapper.js +26 -0
  371. package/dist/panoramic/graph/confidence-mapper.js.map +1 -1
  372. package/dist/panoramic/graph/graph-builder.d.ts +72 -2
  373. package/dist/panoramic/graph/graph-builder.d.ts.map +1 -1
  374. package/dist/panoramic/graph/graph-builder.js +330 -46
  375. package/dist/panoramic/graph/graph-builder.js.map +1 -1
  376. package/dist/panoramic/graph/graph-paths.d.ts +8 -0
  377. package/dist/panoramic/graph/graph-paths.d.ts.map +1 -1
  378. package/dist/panoramic/graph/graph-paths.js +10 -0
  379. package/dist/panoramic/graph/graph-paths.js.map +1 -1
  380. package/dist/panoramic/graph/graph-query.d.ts +49 -2
  381. package/dist/panoramic/graph/graph-query.d.ts.map +1 -1
  382. package/dist/panoramic/graph/graph-query.js +117 -19
  383. package/dist/panoramic/graph/graph-query.js.map +1 -1
  384. package/dist/panoramic/graph/graph-types.d.ts +32 -3
  385. package/dist/panoramic/graph/graph-types.d.ts.map +1 -1
  386. package/dist/panoramic/graph/index.d.ts +2 -1
  387. package/dist/panoramic/graph/index.d.ts.map +1 -1
  388. package/dist/panoramic/graph/index.js +1 -1
  389. package/dist/panoramic/graph/index.js.map +1 -1
  390. package/dist/panoramic/hyperedges/schema.d.ts +6 -6
  391. package/dist/panoramic/interface-surface-generator.d.ts +50 -0
  392. package/dist/panoramic/interface-surface-generator.d.ts.map +1 -0
  393. package/dist/panoramic/interface-surface-generator.js +388 -0
  394. package/dist/panoramic/interface-surface-generator.js.map +1 -0
  395. package/dist/panoramic/interfaces.d.ts +2 -2
  396. package/dist/panoramic/mock-readme-generator.d.ts +90 -0
  397. package/dist/panoramic/mock-readme-generator.d.ts.map +1 -0
  398. package/dist/panoramic/mock-readme-generator.js +111 -0
  399. package/dist/panoramic/mock-readme-generator.js.map +1 -0
  400. package/dist/panoramic/models/component-view-model.d.ts +1 -1
  401. package/dist/panoramic/models/component-view-model.d.ts.map +1 -1
  402. package/dist/panoramic/models/component-view-model.js.map +1 -1
  403. package/dist/panoramic/narrative-provenance-adapter.d.ts +8 -0
  404. package/dist/panoramic/narrative-provenance-adapter.d.ts.map +1 -0
  405. package/dist/panoramic/narrative-provenance-adapter.js +99 -0
  406. package/dist/panoramic/narrative-provenance-adapter.js.map +1 -0
  407. package/dist/panoramic/parser-registry.d.ts +1 -1
  408. package/dist/panoramic/parser-registry.js +1 -1
  409. package/dist/panoramic/parsers/types.d.ts +6 -6
  410. package/dist/panoramic/pattern-hints-generator.d.ts +28 -0
  411. package/dist/panoramic/pattern-hints-generator.d.ts.map +1 -0
  412. package/dist/panoramic/pattern-hints-generator.js +218 -0
  413. package/dist/panoramic/pattern-hints-generator.js.map +1 -0
  414. package/dist/panoramic/pattern-hints-model.d.ts +89 -0
  415. package/dist/panoramic/pattern-hints-model.d.ts.map +1 -0
  416. package/dist/panoramic/pattern-hints-model.js +61 -0
  417. package/dist/panoramic/pattern-hints-model.js.map +1 -0
  418. package/dist/panoramic/pattern-knowledge-base.d.ts +31 -0
  419. package/dist/panoramic/pattern-knowledge-base.d.ts.map +1 -0
  420. package/dist/panoramic/pattern-knowledge-base.js +407 -0
  421. package/dist/panoramic/pattern-knowledge-base.js.map +1 -0
  422. package/dist/panoramic/pipelines/adr-evidence-verifier.d.ts.map +1 -1
  423. package/dist/panoramic/pipelines/adr-evidence-verifier.js +1 -29
  424. package/dist/panoramic/pipelines/adr-evidence-verifier.js.map +1 -1
  425. package/dist/panoramic/pipelines/coverage-auditor.d.ts.map +1 -1
  426. package/dist/panoramic/pipelines/coverage-auditor.js +4 -2
  427. package/dist/panoramic/pipelines/coverage-auditor.js.map +1 -1
  428. package/dist/panoramic/pipelines/docs-bundle-orchestrator.js +13 -6
  429. package/dist/panoramic/pipelines/docs-bundle-orchestrator.js.map +1 -1
  430. package/dist/panoramic/pipelines/product-ux-docs.d.ts +5 -0
  431. package/dist/panoramic/pipelines/product-ux-docs.d.ts.map +1 -1
  432. package/dist/panoramic/pipelines/product-ux-docs.js +34 -6
  433. package/dist/panoramic/pipelines/product-ux-docs.js.map +1 -1
  434. package/dist/panoramic/product-ux-docs.d.ts +104 -0
  435. package/dist/panoramic/product-ux-docs.d.ts.map +1 -0
  436. package/dist/panoramic/product-ux-docs.js +817 -0
  437. package/dist/panoramic/product-ux-docs.js.map +1 -0
  438. package/dist/panoramic/qa/__tests__/citation.test.d.ts +2 -0
  439. package/dist/panoramic/qa/__tests__/citation.test.d.ts.map +1 -0
  440. package/dist/panoramic/qa/__tests__/citation.test.js +193 -0
  441. package/dist/panoramic/qa/__tests__/citation.test.js.map +1 -0
  442. package/dist/panoramic/qa/__tests__/debt-context.test.d.ts +2 -0
  443. package/dist/panoramic/qa/__tests__/debt-context.test.d.ts.map +1 -0
  444. package/dist/panoramic/qa/__tests__/debt-context.test.js +154 -0
  445. package/dist/panoramic/qa/__tests__/debt-context.test.js.map +1 -0
  446. package/dist/panoramic/qa/__tests__/graph-retriever.test.d.ts +2 -0
  447. package/dist/panoramic/qa/__tests__/graph-retriever.test.d.ts.map +1 -0
  448. package/dist/panoramic/qa/__tests__/graph-retriever.test.js +148 -0
  449. package/dist/panoramic/qa/__tests__/graph-retriever.test.js.map +1 -0
  450. package/dist/panoramic/qa/__tests__/index.test.d.ts +2 -0
  451. package/dist/panoramic/qa/__tests__/index.test.d.ts.map +1 -0
  452. package/dist/panoramic/qa/__tests__/index.test.js +246 -0
  453. package/dist/panoramic/qa/__tests__/index.test.js.map +1 -0
  454. package/dist/panoramic/qa/__tests__/llm-caller.test.d.ts +2 -0
  455. package/dist/panoramic/qa/__tests__/llm-caller.test.d.ts.map +1 -0
  456. package/dist/panoramic/qa/__tests__/llm-caller.test.js +168 -0
  457. package/dist/panoramic/qa/__tests__/llm-caller.test.js.map +1 -0
  458. package/dist/panoramic/qa/__tests__/prompt-builder.test.d.ts +2 -0
  459. package/dist/panoramic/qa/__tests__/prompt-builder.test.d.ts.map +1 -0
  460. package/dist/panoramic/qa/__tests__/prompt-builder.test.js +150 -0
  461. package/dist/panoramic/qa/__tests__/prompt-builder.test.js.map +1 -0
  462. package/dist/panoramic/qa/__tests__/qa-integration.test.d.ts +2 -0
  463. package/dist/panoramic/qa/__tests__/qa-integration.test.d.ts.map +1 -0
  464. package/dist/panoramic/qa/__tests__/qa-integration.test.js +296 -0
  465. package/dist/panoramic/qa/__tests__/qa-integration.test.js.map +1 -0
  466. package/dist/panoramic/qa/__tests__/rag-reranker.test.d.ts +2 -0
  467. package/dist/panoramic/qa/__tests__/rag-reranker.test.d.ts.map +1 -0
  468. package/dist/panoramic/qa/__tests__/rag-reranker.test.js +136 -0
  469. package/dist/panoramic/qa/__tests__/rag-reranker.test.js.map +1 -0
  470. package/dist/panoramic/qa/index.d.ts.map +1 -1
  471. package/dist/panoramic/qa/index.js +10 -3
  472. package/dist/panoramic/qa/index.js.map +1 -1
  473. package/dist/panoramic/query.d.ts +1 -0
  474. package/dist/panoramic/query.d.ts.map +1 -1
  475. package/dist/panoramic/query.js +5 -0
  476. package/dist/panoramic/query.js.map +1 -1
  477. package/dist/panoramic/runtime-topology-generator.d.ts +77 -0
  478. package/dist/panoramic/runtime-topology-generator.d.ts.map +1 -0
  479. package/dist/panoramic/runtime-topology-generator.js +676 -0
  480. package/dist/panoramic/runtime-topology-generator.js.map +1 -0
  481. package/dist/panoramic/runtime-topology-model.d.ts +145 -0
  482. package/dist/panoramic/runtime-topology-model.d.ts.map +1 -0
  483. package/dist/panoramic/runtime-topology-model.js +300 -0
  484. package/dist/panoramic/runtime-topology-model.js.map +1 -0
  485. package/dist/panoramic/troubleshooting-generator.d.ts +51 -0
  486. package/dist/panoramic/troubleshooting-generator.d.ts.map +1 -0
  487. package/dist/panoramic/troubleshooting-generator.js +451 -0
  488. package/dist/panoramic/troubleshooting-generator.js.map +1 -0
  489. package/dist/panoramic/utils/text-segmenter.d.ts +15 -0
  490. package/dist/panoramic/utils/text-segmenter.d.ts.map +1 -1
  491. package/dist/panoramic/utils/text-segmenter.js +38 -0
  492. package/dist/panoramic/utils/text-segmenter.js.map +1 -1
  493. package/dist/panoramic/workspace-index-generator.d.ts +148 -0
  494. package/dist/panoramic/workspace-index-generator.d.ts.map +1 -0
  495. package/dist/panoramic/workspace-index-generator.js +497 -0
  496. package/dist/panoramic/workspace-index-generator.js.map +1 -0
  497. package/dist/runtime-bootstrap.d.ts +9 -0
  498. package/dist/runtime-bootstrap.d.ts.map +1 -0
  499. package/dist/runtime-bootstrap.js +33 -0
  500. package/dist/runtime-bootstrap.js.map +1 -0
  501. package/dist/scaffold-kb/api-entities-serializer.d.ts +12 -0
  502. package/dist/scaffold-kb/api-entities-serializer.d.ts.map +1 -0
  503. package/dist/scaffold-kb/api-entities-serializer.js +144 -0
  504. package/dist/scaffold-kb/api-entities-serializer.js.map +1 -0
  505. package/dist/scaffold-kb/arbitration.d.ts +44 -0
  506. package/dist/scaffold-kb/arbitration.d.ts.map +1 -0
  507. package/dist/scaffold-kb/arbitration.js +144 -0
  508. package/dist/scaffold-kb/arbitration.js.map +1 -0
  509. package/dist/scaffold-kb/chunk-splitter.d.ts +20 -0
  510. package/dist/scaffold-kb/chunk-splitter.d.ts.map +1 -0
  511. package/dist/scaffold-kb/chunk-splitter.js +309 -0
  512. package/dist/scaffold-kb/chunk-splitter.js.map +1 -0
  513. package/dist/scaffold-kb/doc-graph-builder.d.ts +26 -0
  514. package/dist/scaffold-kb/doc-graph-builder.d.ts.map +1 -0
  515. package/dist/scaffold-kb/doc-graph-builder.js +72 -0
  516. package/dist/scaffold-kb/doc-graph-builder.js.map +1 -0
  517. package/dist/scaffold-kb/entity-extractor.d.ts +40 -0
  518. package/dist/scaffold-kb/entity-extractor.d.ts.map +1 -0
  519. package/dist/scaffold-kb/entity-extractor.js +0 -0
  520. package/dist/scaffold-kb/entity-extractor.js.map +1 -0
  521. package/dist/scaffold-kb/entity-heuristic.d.ts +14 -0
  522. package/dist/scaffold-kb/entity-heuristic.d.ts.map +1 -0
  523. package/dist/scaffold-kb/entity-heuristic.js +107 -0
  524. package/dist/scaffold-kb/entity-heuristic.js.map +1 -0
  525. package/dist/scaffold-kb/entity-matcher.d.ts +20 -0
  526. package/dist/scaffold-kb/entity-matcher.d.ts.map +1 -0
  527. package/dist/scaffold-kb/entity-matcher.js +53 -0
  528. package/dist/scaffold-kb/entity-matcher.js.map +1 -0
  529. package/dist/scaffold-kb/entity-util.d.ts +11 -0
  530. package/dist/scaffold-kb/entity-util.d.ts.map +1 -0
  531. package/dist/scaffold-kb/entity-util.js +23 -0
  532. package/dist/scaffold-kb/entity-util.js.map +1 -0
  533. package/dist/scaffold-kb/evidence-envelope.d.ts +17 -0
  534. package/dist/scaffold-kb/evidence-envelope.d.ts.map +1 -0
  535. package/dist/scaffold-kb/evidence-envelope.js +32 -0
  536. package/dist/scaffold-kb/evidence-envelope.js.map +1 -0
  537. package/dist/scaffold-kb/index.d.ts +20 -0
  538. package/dist/scaffold-kb/index.d.ts.map +1 -0
  539. package/dist/scaffold-kb/index.js +102 -0
  540. package/dist/scaffold-kb/index.js.map +1 -0
  541. package/dist/scaffold-kb/ingest/ingest-core.d.ts +47 -0
  542. package/dist/scaffold-kb/ingest/ingest-core.d.ts.map +1 -0
  543. package/dist/scaffold-kb/ingest/ingest-core.js +231 -0
  544. package/dist/scaffold-kb/ingest/ingest-core.js.map +1 -0
  545. package/dist/scaffold-kb/ingest/office-parser.d.ts +33 -0
  546. package/dist/scaffold-kb/ingest/office-parser.d.ts.map +1 -0
  547. package/dist/scaffold-kb/ingest/office-parser.js +187 -0
  548. package/dist/scaffold-kb/ingest/office-parser.js.map +1 -0
  549. package/dist/scaffold-kb/ingest/url-fetcher.d.ts +43 -0
  550. package/dist/scaffold-kb/ingest/url-fetcher.d.ts.map +1 -0
  551. package/dist/scaffold-kb/ingest/url-fetcher.js +245 -0
  552. package/dist/scaffold-kb/ingest/url-fetcher.js.map +1 -0
  553. package/dist/scaffold-kb/ingester.d.ts +38 -0
  554. package/dist/scaffold-kb/ingester.d.ts.map +1 -0
  555. package/dist/scaffold-kb/ingester.js +261 -0
  556. package/dist/scaffold-kb/ingester.js.map +1 -0
  557. package/dist/scaffold-kb/injection-format.d.ts +25 -0
  558. package/dist/scaffold-kb/injection-format.d.ts.map +1 -0
  559. package/dist/scaffold-kb/injection-format.js +55 -0
  560. package/dist/scaffold-kb/injection-format.js.map +1 -0
  561. package/dist/scaffold-kb/kb-writer.d.ts +13 -0
  562. package/dist/scaffold-kb/kb-writer.d.ts.map +1 -0
  563. package/dist/scaffold-kb/kb-writer.js +69 -0
  564. package/dist/scaffold-kb/kb-writer.js.map +1 -0
  565. package/dist/scaffold-kb/keyword-extract.d.ts +16 -0
  566. package/dist/scaffold-kb/keyword-extract.d.ts.map +1 -0
  567. package/dist/scaffold-kb/keyword-extract.js +49 -0
  568. package/dist/scaffold-kb/keyword-extract.js.map +1 -0
  569. package/dist/scaffold-kb/query-sanitizer.d.ts +28 -0
  570. package/dist/scaffold-kb/query-sanitizer.d.ts.map +1 -0
  571. package/dist/scaffold-kb/query-sanitizer.js +38 -0
  572. package/dist/scaffold-kb/query-sanitizer.js.map +1 -0
  573. package/dist/scaffold-kb/recall-eval.d.ts +48 -0
  574. package/dist/scaffold-kb/recall-eval.d.ts.map +1 -0
  575. package/dist/scaffold-kb/recall-eval.js +55 -0
  576. package/dist/scaffold-kb/recall-eval.js.map +1 -0
  577. package/dist/scaffold-kb/schema-compat.d.ts +22 -0
  578. package/dist/scaffold-kb/schema-compat.d.ts.map +1 -0
  579. package/dist/scaffold-kb/schema-compat.js +32 -0
  580. package/dist/scaffold-kb/schema-compat.js.map +1 -0
  581. package/dist/scaffold-kb/search-core.d.ts +42 -0
  582. package/dist/scaffold-kb/search-core.d.ts.map +1 -0
  583. package/dist/scaffold-kb/search-core.js +89 -0
  584. package/dist/scaffold-kb/search-core.js.map +1 -0
  585. package/dist/scaffold-kb/sqlite-engine.d.ts +58 -0
  586. package/dist/scaffold-kb/sqlite-engine.d.ts.map +1 -0
  587. package/dist/scaffold-kb/sqlite-engine.js +61 -0
  588. package/dist/scaffold-kb/sqlite-engine.js.map +1 -0
  589. package/dist/scaffold-kb/sqlite-writer.d.ts +18 -0
  590. package/dist/scaffold-kb/sqlite-writer.d.ts.map +1 -0
  591. package/dist/scaffold-kb/sqlite-writer.js +76 -0
  592. package/dist/scaffold-kb/sqlite-writer.js.map +1 -0
  593. package/dist/scaffold-kb/tokenizer.d.ts +26 -0
  594. package/dist/scaffold-kb/tokenizer.d.ts.map +1 -0
  595. package/dist/scaffold-kb/tokenizer.js +97 -0
  596. package/dist/scaffold-kb/tokenizer.js.map +1 -0
  597. package/dist/scaffold-kb/types.d.ts +157 -0
  598. package/dist/scaffold-kb/types.d.ts.map +1 -0
  599. package/dist/scaffold-kb/types.js +5 -0
  600. package/dist/scaffold-kb/types.js.map +1 -0
  601. package/dist/utils/file-scanner.d.ts +15 -0
  602. package/dist/utils/file-scanner.d.ts.map +1 -1
  603. package/dist/utils/file-scanner.js +18 -1
  604. package/dist/utils/file-scanner.js.map +1 -1
  605. package/dist/utils/string-distance.d.ts +20 -0
  606. package/dist/utils/string-distance.d.ts.map +1 -0
  607. package/dist/utils/string-distance.js +38 -0
  608. package/dist/utils/string-distance.js.map +1 -0
  609. package/package.json +22 -3
  610. package/plugins/demo-kb-en/.claude-plugin/plugin.json +11 -0
  611. package/plugins/demo-kb-en/.mcp.json +8 -0
  612. package/plugins/demo-kb-en/FIXTURE.json +23 -0
  613. package/plugins/demo-kb-en/FIXTURE.md +53 -0
  614. package/plugins/demo-kb-en/ingest-samples/meeting-notes.md +13 -0
  615. package/plugins/demo-kb-en/kb/api-entities.json +3445 -0
  616. package/plugins/demo-kb-en/kb/chunks.sqlite +0 -0
  617. package/plugins/demo-kb-en/kb/doc-graph.json +113 -0
  618. package/plugins/demo-kb-zh/.claude-plugin/plugin.json +11 -0
  619. package/plugins/demo-kb-zh/.mcp.json +8 -0
  620. package/plugins/demo-kb-zh/FIXTURE.json +23 -0
  621. package/plugins/demo-kb-zh/FIXTURE.md +63 -0
  622. package/plugins/demo-kb-zh/ingest-samples/meeting-notes.md +13 -0
  623. package/plugins/demo-kb-zh/kb/api-entities.json +990 -0
  624. package/plugins/demo-kb-zh/kb/chunks.sqlite +0 -0
  625. package/plugins/demo-kb-zh/kb/doc-graph.json +113 -0
  626. package/plugins/spec-driver/.claude-plugin/plugin.json +1 -1
  627. package/plugins/spec-driver/README.md +50 -1
  628. package/plugins/spec-driver/agents/implement.md +20 -1
  629. package/plugins/spec-driver/agents/plan.md +20 -1
  630. package/plugins/spec-driver/agents/quality-review.md +20 -1
  631. package/plugins/spec-driver/agents/spec-review.md +20 -1
  632. package/plugins/spec-driver/agents/verify.md +108 -1
  633. package/plugins/spec-driver/config/orchestration.yaml +39 -31
  634. package/plugins/spec-driver/contracts/orchestration-overrides-contract.yaml +27 -0
  635. package/plugins/spec-driver/contracts/orchestration-schema.mjs +272 -227
  636. package/plugins/spec-driver/contracts/wrapper-source-of-truth.yaml +3 -0
  637. package/plugins/spec-driver/docs/customization.md +134 -0
  638. package/plugins/spec-driver/docs/spectra-mcp-integration.md +165 -0
  639. package/plugins/spec-driver/hooks/hooks.json +9 -0
  640. package/plugins/spec-driver/hooks/stop-fix-compliance-check.sh +36 -0
  641. package/plugins/spec-driver/lib/delegation-contract.mjs +84 -0
  642. package/plugins/spec-driver/lib/orchestration-resolver.mjs +49 -0
  643. package/plugins/spec-driver/lib/orchestrator.mjs +29 -1
  644. package/plugins/spec-driver/lib/preference-rules.mjs +96 -0
  645. package/plugins/spec-driver/scripts/codex-skills.sh +28 -28
  646. package/plugins/spec-driver/scripts/dev/spike-fix-compliance-e2e.mjs +130 -0
  647. package/plugins/spec-driver/scripts/fix-compliance-judge.mjs +415 -0
  648. package/plugins/spec-driver/scripts/generate-adoption-insights.mjs +48 -1
  649. package/plugins/spec-driver/scripts/goal-loop-cli.mjs +307 -0
  650. package/plugins/spec-driver/scripts/init-project.sh +56 -0
  651. package/plugins/spec-driver/scripts/kb-prequery.mjs +125 -0
  652. package/plugins/spec-driver/scripts/lib/config-schema.mjs +200 -94
  653. package/plugins/spec-driver/scripts/lib/ensure-gitignore.sh +277 -0
  654. package/plugins/spec-driver/scripts/lib/extract-wrapper-body.mjs +136 -0
  655. package/plugins/spec-driver/scripts/lib/fix-compliance-core.mjs +434 -0
  656. package/plugins/spec-driver/scripts/lib/fix-compliance-io.mjs +335 -0
  657. package/plugins/spec-driver/scripts/lib/goal-loop-core.mjs +783 -0
  658. package/plugins/spec-driver/scripts/lib/init-project-output.sh +28 -0
  659. package/plugins/spec-driver/scripts/lib/load-zod.mjs +62 -0
  660. package/plugins/spec-driver/scripts/lib/project-profile-resolver.mjs +141 -49
  661. package/plugins/spec-driver/scripts/lib/project-profile-schema.mjs +88 -54
  662. package/plugins/spec-driver/scripts/postinstall.sh +13 -1
  663. package/plugins/spec-driver/scripts/record-workflow-run.mjs +75 -0
  664. package/plugins/spec-driver/scripts/sync-delegation-contract.mjs +187 -0
  665. package/plugins/spec-driver/scripts/sync-preference-rules.mjs +148 -0
  666. package/plugins/spec-driver/scripts/validate-orchestrator-models.mjs +156 -0
  667. package/plugins/spec-driver/scripts/validate-wrapper-sources.mjs +46 -1
  668. package/plugins/spec-driver/skills/spec-driver-feature/SKILL.md +302 -0
  669. package/plugins/spec-driver/skills/spec-driver-fix/SKILL.md +97 -8
  670. package/plugins/spec-driver/skills/spec-driver-implement/SKILL.md +18 -0
  671. package/plugins/spec-driver/skills/spec-driver-refactor/SKILL.md +10 -0
  672. package/plugins/spec-driver/skills/spec-driver-resume/SKILL.md +12 -1
  673. package/plugins/spec-driver/skills/spec-driver-story/SKILL.md +30 -0
  674. package/plugins/spec-driver/templates/delegation-contract.md +27 -0
  675. package/plugins/spec-driver/templates/goal-loop-override-template.yaml +284 -0
  676. package/plugins/spec-driver/templates/preference-rules.md +39 -0
  677. package/plugins/spec-driver/templates/specify-base/project-context-template.yaml +10 -0
  678. package/plugins/spectra/.claude-plugin/plugin.json +1 -1
  679. package/plugins/spectra/README.md +48 -1
  680. package/plugins/spectra/hooks/post-commit.sh +40 -0
  681. package/templates/module-spec.hbs +1 -0
  682. package/templates/product-overview.hbs +1 -1
@@ -0,0 +1,685 @@
1
+ /**
2
+ * ADR 决策流水线
3
+ *
4
+ * 基于项目级结构化输出、模块 spec、current-spec、增量 spec 与 git 提交历史,
5
+ * 生成候选 ADR 草稿与索引。该流水线优先使用确定性证据匹配,避免把 ADR 草稿
6
+ * 变成“看起来合理”的纯 LLM 幻觉文本。
7
+ */
8
+ import * as fs from 'node:fs';
9
+ import * as path from 'node:path';
10
+ import { spawnSync } from 'node:child_process';
11
+ import { loadTemplate } from './utils/template-loader.js';
12
+ export function generateBatchAdrDocs(options) {
13
+ const corpus = buildAdrCorpus(options);
14
+ const warnings = new Set();
15
+ const candidates = buildAdrCandidates(corpus);
16
+ if (candidates.length === 0) {
17
+ warnings.add('未识别到足够稳定的 ADR 候选信号,已仅生成空索引。');
18
+ }
19
+ const drafts = candidates
20
+ .sort((left, right) => right.score - left.score || left.title.localeCompare(right.title))
21
+ .slice(0, 4)
22
+ .map((candidate, index) => finalizeDraft(index + 1, candidate));
23
+ const adrDir = path.join(options.outputDir, 'docs', 'adr');
24
+ const writtenFiles = [];
25
+ for (const draft of drafts) {
26
+ const markdown = renderAdrDraft(draft);
27
+ const baseName = `${draft.decisionId.toLowerCase()}-${draft.slug}`;
28
+ const mdPath = path.join(adrDir, `${baseName}.md`);
29
+ const jsonPath = path.join(adrDir, `${baseName}.json`);
30
+ fs.mkdirSync(adrDir, { recursive: true });
31
+ fs.writeFileSync(mdPath, markdown, 'utf-8');
32
+ fs.writeFileSync(jsonPath, JSON.stringify(draft, null, 2), 'utf-8');
33
+ writtenFiles.push(mdPath, jsonPath);
34
+ }
35
+ const index = {
36
+ title: `ADR 决策索引: ${corpus.projectName}`,
37
+ generatedAt: new Date().toISOString(),
38
+ projectName: corpus.projectName,
39
+ summary: buildIndexSummary(corpus, drafts),
40
+ draftCount: drafts.length,
41
+ warnings: [...warnings],
42
+ drafts,
43
+ };
44
+ fs.mkdirSync(adrDir, { recursive: true });
45
+ const indexMarkdown = renderAdrIndex(index);
46
+ const indexMarkdownPath = path.join(adrDir, 'index.md');
47
+ const indexJsonPath = path.join(adrDir, 'index.json');
48
+ fs.writeFileSync(indexMarkdownPath, indexMarkdown, 'utf-8');
49
+ fs.writeFileSync(indexJsonPath, JSON.stringify(index, null, 2), 'utf-8');
50
+ writtenFiles.push(indexMarkdownPath, indexJsonPath);
51
+ return {
52
+ index,
53
+ drafts,
54
+ warnings: [...warnings],
55
+ writtenFiles,
56
+ };
57
+ }
58
+ function renderAdrDraft(draft) {
59
+ const template = loadTemplate('adr-draft.hbs', import.meta.url);
60
+ return template(draft);
61
+ }
62
+ function renderAdrIndex(output) {
63
+ const template = loadTemplate('adr-index.hbs', import.meta.url);
64
+ return template(output);
65
+ }
66
+ function buildAdrCorpus(options) {
67
+ const entries = [];
68
+ const projectName = options.architectureNarrative.projectName;
69
+ entries.push({
70
+ sourceType: 'architecture-narrative',
71
+ label: 'executive-summary',
72
+ path: path.join(options.outputDir, 'architecture-narrative.md'),
73
+ text: [
74
+ ...options.architectureNarrative.executiveSummary,
75
+ ...options.architectureNarrative.observations,
76
+ ].join('\n'),
77
+ });
78
+ for (const module of options.architectureNarrative.keyModules) {
79
+ entries.push({
80
+ sourceType: 'architecture-narrative',
81
+ label: `module:${module.sourceTarget}`,
82
+ path: path.join(options.outputDir, 'architecture-narrative.md'),
83
+ text: [
84
+ module.sourceTarget,
85
+ module.displayName,
86
+ module.intentSummary,
87
+ module.businessSummary,
88
+ module.dependencySummary,
89
+ ...module.keySymbols.map((symbol) => `${symbol.kind}:${symbol.name}:${symbol.note}`),
90
+ ...module.keyMethods.map((method) => `${method.kind}:${method.name}:${method.note}`),
91
+ ].join('\n'),
92
+ });
93
+ }
94
+ if (options.patternHints) {
95
+ entries.push({
96
+ sourceType: 'pattern-hints',
97
+ label: 'pattern-summary',
98
+ path: path.join(options.outputDir, 'pattern-hints.md'),
99
+ text: options.patternHints.model.matchedPatterns
100
+ .map((hint) => [
101
+ hint.patternName,
102
+ hint.summary,
103
+ hint.explanation,
104
+ ...hint.matchedSignals,
105
+ ].join('\n'))
106
+ .join('\n\n'),
107
+ });
108
+ }
109
+ if (options.architectureOverview) {
110
+ entries.push({
111
+ sourceType: 'architecture-overview',
112
+ label: 'overview-summary',
113
+ path: path.join(options.outputDir, 'architecture-overview.md'),
114
+ text: [
115
+ options.architectureOverview.title,
116
+ summarizeArchitectureSection(options.architectureOverview.systemContext),
117
+ summarizeArchitectureSection(options.architectureOverview.deploymentView),
118
+ summarizeArchitectureSection(options.architectureOverview.layeredView),
119
+ ].filter(Boolean).join('\n'),
120
+ });
121
+ }
122
+ for (const filePath of collectMarkdownEvidenceFiles(options.projectRoot)) {
123
+ const normalized = normalizeProjectPath(filePath, options.projectRoot);
124
+ const lower = normalized.toLowerCase();
125
+ let sourceType = 'spec';
126
+ if (lower.endsWith('/current-spec.md')) {
127
+ sourceType = 'current-spec';
128
+ }
129
+ else if (lower.endsWith('/blueprint.md')) {
130
+ sourceType = 'blueprint';
131
+ }
132
+ entries.push({
133
+ sourceType,
134
+ label: normalized,
135
+ path: normalized,
136
+ text: readTrimmed(filePath, 24_000),
137
+ });
138
+ }
139
+ for (const sourcePath of collectSourcePathSignals(options.projectRoot)) {
140
+ entries.push({
141
+ sourceType: 'source-path',
142
+ label: sourcePath,
143
+ path: sourcePath,
144
+ text: sourcePath,
145
+ });
146
+ }
147
+ const commits = loadRecentGitCommits(options.projectRoot);
148
+ for (const commit of commits) {
149
+ entries.push({
150
+ sourceType: 'commit',
151
+ label: commit.sha.slice(0, 7),
152
+ text: [commit.subject, commit.body].filter(Boolean).join('\n'),
153
+ });
154
+ }
155
+ return {
156
+ projectName,
157
+ projectRoot: options.projectRoot,
158
+ architectureNarrative: options.architectureNarrative,
159
+ architectureOverview: options.architectureOverview,
160
+ patternHints: options.patternHints,
161
+ commits,
162
+ entries,
163
+ };
164
+ }
165
+ function buildAdrCandidates(corpus) {
166
+ const candidates = [
167
+ buildCliHostedRuntimeCandidate(corpus),
168
+ buildStreamJsonProtocolCandidate(corpus),
169
+ buildRegistryExtensibilityCandidate(corpus),
170
+ buildDeterministicFactsCandidate(corpus),
171
+ buildCurrentSpecFactSourceCandidate(corpus),
172
+ buildAppendOnlySessionCandidate(corpus),
173
+ buildContainerizedRuntimeCandidate(corpus),
174
+ buildModularSeparationCandidate(corpus),
175
+ ].filter((candidate) => candidate !== null);
176
+ if (candidates.length >= 2) {
177
+ return candidates;
178
+ }
179
+ const fallback = buildGenericCoreSeparationCandidate(corpus);
180
+ return fallback ? [...candidates, fallback] : candidates;
181
+ }
182
+ function buildCliHostedRuntimeCandidate(corpus) {
183
+ const evidence = matchEvidence(corpus, [
184
+ 'claude code cli',
185
+ 'subprocess',
186
+ 'transport',
187
+ 'stdin/stdout',
188
+ 'cli 子进程',
189
+ 'subprocesscli',
190
+ 'subprocess_cli',
191
+ ], 4);
192
+ if (evidence.length < 2) {
193
+ return null;
194
+ }
195
+ return {
196
+ key: 'cli-hosted-runtime',
197
+ score: 98 + evidence.length,
198
+ title: '使用 CLI 作为宿主执行引擎',
199
+ category: 'runtime',
200
+ confidence: 'high',
201
+ inferred: false,
202
+ summary: '将宿主语言 SDK/工具层建立在现有 CLI runtime 之上,而不是重复实现 agent loop。',
203
+ decision: '以 CLI 子进程作为主执行引擎,宿主侧负责参数封装、回调桥接、消息解析与本地扩展接入。',
204
+ context: [
205
+ '代码和文档证据反复指向 CLI transport / subprocess transport,而不是直接 HTTP 模型客户端。',
206
+ '这种结构通常用于复用现有 agent loop、工具生态与权限/插件体系,减少宿主 SDK 自行实现运行时的成本。',
207
+ ],
208
+ consequences: [
209
+ '宿主层可以专注于类型系统、回调与本地扩展,而不必复制完整 runtime。',
210
+ '与 CLI 版本和协议的兼容性会成为关键约束,需要保持 transport 与消息解析层稳定。',
211
+ ],
212
+ alternatives: [
213
+ '直接构建独立的 HTTP / SDK runtime,完全绕过 CLI。',
214
+ '把 agent loop 内嵌在当前宿主进程中,不再依赖外部可执行程序。',
215
+ ],
216
+ evidence,
217
+ };
218
+ }
219
+ function buildStreamJsonProtocolCandidate(corpus) {
220
+ const evidence = matchEvidence(corpus, [
221
+ 'stream-json',
222
+ 'message parser',
223
+ 'control_request',
224
+ 'control response',
225
+ 'json',
226
+ 'stdin',
227
+ 'stdout',
228
+ 'message_parser',
229
+ '控制协议',
230
+ ], 4);
231
+ if (evidence.length < 2) {
232
+ return null;
233
+ }
234
+ return {
235
+ key: 'stream-json-protocol',
236
+ score: 94 + evidence.length,
237
+ title: '使用 JSON 流式控制协议连接宿主与运行时',
238
+ category: 'protocol',
239
+ confidence: 'high',
240
+ inferred: false,
241
+ summary: '在宿主层与运行时之间统一使用 JSON 消息流,维持双向控制和消息扩展能力。',
242
+ decision: '宿主与执行引擎之间通过 JSON over stdin/stdout 的流式协议交换初始化、控制请求、控制响应和消息事件。',
243
+ context: [
244
+ '项目中同时出现 message parser、streaming、stdin/stdout 与 control request/response 等证据,说明通信协议是架构核心而不是实现细节。',
245
+ '使用结构化协议有助于让 hook、工具权限、MCP 与 session 控制落到同一条消息总线上。',
246
+ ],
247
+ consequences: [
248
+ '消息类型、字段兼容性和缓冲容错会成为运行时稳定性的关键。',
249
+ '协议一旦扩展,宿主侧 parser 与 transport 需要同步演进。',
250
+ ],
251
+ alternatives: [
252
+ '使用一次性命令调用或纯文本 stdout 解析。',
253
+ '宿主与运行时只交换单向消息,不保留 control request/response 语义。',
254
+ ],
255
+ evidence,
256
+ };
257
+ }
258
+ function buildRegistryExtensibilityCandidate(corpus) {
259
+ const evidence = matchEvidence(corpus, [
260
+ 'generatorregistry',
261
+ 'parserregistry',
262
+ 'languageadapterregistry',
263
+ 'documentgenerator',
264
+ 'artifactparser',
265
+ '注册中心',
266
+ 'registry',
267
+ ], 5);
268
+ if (evidence.length < 2) {
269
+ return null;
270
+ }
271
+ return {
272
+ key: 'registry-extensibility',
273
+ score: 91 + evidence.length,
274
+ title: '使用 Registry 统一扩展生成器、解析器与语言适配器',
275
+ category: 'extensibility',
276
+ confidence: 'high',
277
+ inferred: false,
278
+ summary: '把生成器、解析器和适配器收敛到统一注册中心,避免能力扩展散落在分支逻辑里。',
279
+ decision: '通过 Registry 抽象统一管理 DocumentGenerator、ArtifactParser 与 LanguageAdapter 的发现、启停和按上下文过滤。',
280
+ context: [
281
+ '当前仓库的 panoramic 能力已经演化为多生成器、多解析器、多语言适配的组合系统。',
282
+ '如果没有统一注册/过滤机制,新增文档类型和解析链路会快速失控,并增加 batch 编排复杂度。',
283
+ ],
284
+ consequences: [
285
+ '扩展点更稳定,batch/CLI/MCP 可以共享同一套能力发现逻辑。',
286
+ 'Registry 自身会成为横切层,需要额外保证幂等初始化、冲突检测和可观察性。',
287
+ ],
288
+ alternatives: [
289
+ '在 CLI 或 batch 中硬编码每类生成器/解析器调用顺序。',
290
+ '按语言或文档类型拆散到多套互不共享的发现机制。',
291
+ ],
292
+ evidence,
293
+ };
294
+ }
295
+ function buildDeterministicFactsCandidate(corpus) {
296
+ const evidence = matchEvidence(corpus, [
297
+ 'ast-only',
298
+ 'fallback',
299
+ 'low confidence',
300
+ '静默降级',
301
+ 'graceful degradation',
302
+ 'confidence',
303
+ '结构化事实',
304
+ 'deterministic',
305
+ ], 4);
306
+ if (evidence.length < 2) {
307
+ return null;
308
+ }
309
+ return {
310
+ key: 'deterministic-facts',
311
+ score: 89 + evidence.length,
312
+ title: '优先保留确定性事实层并对 LLM 增强做诚实降级',
313
+ category: 'quality',
314
+ confidence: 'high',
315
+ inferred: false,
316
+ summary: '把结构化事实抽取与 narrative 增强分层,LLM 不可用时仍保留 AST/规则输出。',
317
+ decision: '将 API、配置、依赖图、模块签名等确定性事实保留在 parser/graph 层;LLM 仅用于 explanation、summary 与 narrative,失败时静默降级为 AST-only / low-confidence 输出。',
318
+ context: [
319
+ '当前产品明确区分结构化事实与 narrative 输出,并把低置信度和降级路径作为一等能力暴露。',
320
+ '这类工具链如果让 LLM 直接决定 canonical facts,会把文档体系变成不可验证的文本生成器。',
321
+ ],
322
+ consequences: [
323
+ '输出质量更可控,coverage audit 和 drift 检测仍能基于确定性事实运行。',
324
+ '当 LLM 不可用时,文档可读性会下降,但不会完全失去可用性。',
325
+ ],
326
+ alternatives: [
327
+ '让 LLM 直接生成或决定 API / 配置 / 依赖等结构事实。',
328
+ '在增强失败时终止整次文档生成,而不是保留保守输出。',
329
+ ],
330
+ evidence,
331
+ };
332
+ }
333
+ function buildCurrentSpecFactSourceCandidate(corpus) {
334
+ const evidence = matchEvidence(corpus, [
335
+ 'current-spec',
336
+ '产品规范活文档',
337
+ '事实源',
338
+ 'spec-driver-sync',
339
+ 'product facts',
340
+ ], 4).filter((entry) => entry.sourceType === 'current-spec' || entry.sourceType === 'spec' || entry.sourceType === 'commit');
341
+ if (evidence.length < 1) {
342
+ return null;
343
+ }
344
+ return {
345
+ key: 'current-spec-fact-source',
346
+ score: 86 + evidence.length,
347
+ title: '将 current-spec 作为产品文档的上游事实源',
348
+ category: 'product-facts',
349
+ confidence: 'high',
350
+ inferred: false,
351
+ summary: '先用 Spec Driver 聚合产品级事实,再派生 README、产品概览和对外文档,减少事实漂移。',
352
+ decision: '把 `current-spec.md` 作为产品/文档层的规范化事实源之一,优先消费聚合后的产品语义而不是重复从代码和增量 spec 中猜测产品定位。',
353
+ context: [
354
+ '当前仓库同时存在 reverse-spec 与 spec-driver,两者的职责边界之一就是“事实聚合”和“文档派生”分层。',
355
+ '没有产品级事实源时,对外文档会在 README、spec 和实现之间反复漂移。',
356
+ ],
357
+ consequences: [
358
+ 'README / product overview / feature brief 可以共享同一套产品事实摘要。',
359
+ '需要保证 sync 链路的及时性,否则 current-spec 会成为过时缓存。',
360
+ ],
361
+ alternatives: [
362
+ '每次生成对外文档都直接从增量 spec 与代码重新拼接产品语义。',
363
+ '完全依赖 README 或 issue 文本作为产品事实来源。',
364
+ ],
365
+ evidence,
366
+ };
367
+ }
368
+ function buildAppendOnlySessionCandidate(corpus) {
369
+ const evidence = matchEvidence(corpus, [
370
+ 'append-only',
371
+ 'session_mutations',
372
+ 'rename_session',
373
+ 'tag_session',
374
+ '追加式',
375
+ 'append only',
376
+ ], 4);
377
+ if (evidence.length < 2) {
378
+ return null;
379
+ }
380
+ return {
381
+ key: 'append-only-session-metadata',
382
+ score: 84 + evidence.length,
383
+ title: '对会话元数据采用 append-only 更新策略',
384
+ category: 'storage',
385
+ confidence: 'medium',
386
+ inferred: false,
387
+ summary: '通过追加元数据记录而非重写整份 transcript,降低并发写风险并保持读取兼容性。',
388
+ decision: '会话标题、标签等变更采用 append-only 元数据行追加,并在读取时应用最后一条记录生效的规则。',
389
+ context: [
390
+ '会话 transcript 往往体积较大,且运行时可能同时读取尾部或追加新消息。',
391
+ '全量重写 transcript 成本高,也更容易在并发场景下损坏或产生竞争。',
392
+ ],
393
+ consequences: [
394
+ '写路径更轻,兼容 tail-read/re-append 场景。',
395
+ '读取端需要承担“最后一条生效”的合并逻辑。',
396
+ ],
397
+ alternatives: [
398
+ '每次修改标题或标签都整文件重写 transcript。',
399
+ '把会话元数据迁到独立数据库或索引服务中维护。',
400
+ ],
401
+ evidence,
402
+ };
403
+ }
404
+ function buildContainerizedRuntimeCandidate(corpus) {
405
+ const deploymentAvailable = corpus.architectureOverview?.deploymentView?.available ?? false;
406
+ const evidence = deploymentAvailable
407
+ ? matchEvidence(corpus, ['docker', 'compose', 'deployment', 'runtime-topology', 'container'], 4)
408
+ : [];
409
+ if (!deploymentAvailable || evidence.length < 2) {
410
+ return null;
411
+ }
412
+ return {
413
+ key: 'containerized-runtime-boundary',
414
+ score: 82 + evidence.length,
415
+ title: '使用容器化部署边界表达运行时拓扑',
416
+ category: 'deployment',
417
+ confidence: 'medium',
418
+ inferred: false,
419
+ summary: '通过 Dockerfile / Compose 等制品显式建模服务、端口和依赖,而不是把运行时假设隐含在脚本里。',
420
+ decision: '将服务镜像、端口、环境变量和依赖关系显式维护为容器化运行时拓扑,并把部署视图作为架构文档的一等组成部分。',
421
+ context: [
422
+ '项目已经暴露出可解析的 Docker / Compose 运行时制品,说明部署边界是系统结构的一部分。',
423
+ '当部署事实没有结构化表达时,架构文档很难稳定覆盖服务关系与运维约束。',
424
+ ],
425
+ consequences: [
426
+ '运行时和部署约束更易被文档、审计和后续工具消费。',
427
+ '部署视图将依赖制品完整性;缺少 Docker/Compose 时需要降级说明。',
428
+ ],
429
+ alternatives: [
430
+ '仅在 README 或脚本里零散描述运行时与部署方式。',
431
+ '不把部署事实纳入架构文档主链路。',
432
+ ],
433
+ evidence,
434
+ };
435
+ }
436
+ function buildModularSeparationCandidate(corpus) {
437
+ const coreModules = corpus.architectureNarrative.keyModules.filter((module) => module.role === 'core');
438
+ if (coreModules.length < 2) {
439
+ return null;
440
+ }
441
+ const evidence = coreModules
442
+ .slice(0, 3)
443
+ .map((module) => evidenceFromModule(module))
444
+ .filter((entry) => entry !== null);
445
+ return {
446
+ key: 'modular-surface-separation',
447
+ score: 78 + evidence.length,
448
+ title: '按核心职责拆分模块边界,而不是把主流程堆叠在单一入口中',
449
+ category: 'modularity',
450
+ confidence: 'medium',
451
+ inferred: true,
452
+ summary: '把核心职责拆成多个聚焦模块,有助于让主流程、支撑能力和验证层分别演化。',
453
+ decision: `将核心能力优先拆分到 ${coreModules.slice(0, 3).map((module) => `\`${module.sourceTarget}\``).join('、')} 等职责明确的模块中,再由高层入口聚合。`,
454
+ context: [
455
+ '当前项目的关键模块已经呈现出相对清晰的职责分离,而不是所有能力都堆在同一目录或同一入口文件。',
456
+ '这类结构更有利于后续为不同文档视图、运行时路径或测试层提供稳定边界。',
457
+ ],
458
+ consequences: [
459
+ '模块级文档和组件级文档更容易建立阅读路径与责任边界。',
460
+ '如果聚合层过薄或缺少索引,阅读者仍可能感到跳转成本高,需要额外 narrative/overview 支撑。',
461
+ ],
462
+ alternatives: [
463
+ '把主流程、支撑能力和验证代码集中在单一模块或入口文件中。',
464
+ '依赖目录命名约定而不显式维护职责边界。',
465
+ ],
466
+ evidence,
467
+ };
468
+ }
469
+ function buildGenericCoreSeparationCandidate(corpus) {
470
+ const module = corpus.architectureNarrative.keyModules[0];
471
+ if (!module) {
472
+ return null;
473
+ }
474
+ const evidence = [evidenceFromModule(module)].filter((item) => item !== null);
475
+ return {
476
+ key: 'core-separation-fallback',
477
+ score: 60,
478
+ title: '围绕核心模块维持聚焦职责边界',
479
+ category: 'modularity',
480
+ confidence: 'medium',
481
+ inferred: true,
482
+ summary: '即便缺少更多产品/历史上下文,当前输出也显示系统围绕少数核心模块组织主流程。',
483
+ decision: `优先围绕 \`${module.sourceTarget}\` 一类核心模块组织主链路,并避免把支撑逻辑无边界地扩散到所有文件。`,
484
+ context: [
485
+ '当前可见证据有限,但架构叙事仍指向了若干核心模块与导出符号。',
486
+ ],
487
+ consequences: [
488
+ '可以为后续 component view / dynamic scenarios 留出更稳定的分析入口。',
489
+ ],
490
+ alternatives: [
491
+ '在证据不足的情况下完全放弃候选 ADR 输出。',
492
+ ],
493
+ evidence,
494
+ };
495
+ }
496
+ function finalizeDraft(index, candidate) {
497
+ const decisionId = `ADR-${String(index).padStart(4, '0')}`;
498
+ const slug = slugify(candidate.title);
499
+ const sourceTypes = uniqueSorted(candidate.evidence.map((item) => item.sourceType));
500
+ return {
501
+ decisionId,
502
+ slug,
503
+ title: candidate.title,
504
+ status: 'proposed',
505
+ category: candidate.category,
506
+ confidence: candidate.confidence,
507
+ inferred: candidate.inferred,
508
+ sourceTypes,
509
+ summary: candidate.summary,
510
+ decision: candidate.decision,
511
+ context: candidate.context,
512
+ consequences: candidate.consequences,
513
+ alternatives: candidate.alternatives,
514
+ evidence: candidate.evidence,
515
+ };
516
+ }
517
+ function buildIndexSummary(corpus, drafts) {
518
+ const lines = [
519
+ `本批次基于 ${drafts.length} 个候选 ADR 草稿组织决策索引,输入事实主要来自架构叙事、模式提示、现有 spec/current-spec 与近期提交历史。`,
520
+ ];
521
+ if (corpus.patternHints?.model.matchedPatterns.length) {
522
+ lines.push(`模式提示中识别到 ${corpus.patternHints.model.matchedPatterns.length} 条可用模式证据,可作为 ADR 背景的结构化补充。`);
523
+ }
524
+ if (corpus.commits.length > 0) {
525
+ lines.push(`已纳入最近 ${Math.min(corpus.commits.length, 20)} 条 git 提交标题作为演进证据。`);
526
+ }
527
+ else {
528
+ lines.push('未检测到可读取的 git 提交历史,部分 ADR 仅基于当前代码与文档结构推断。');
529
+ }
530
+ return lines;
531
+ }
532
+ function evidenceFromModule(module) {
533
+ const excerpt = [module.intentSummary, module.businessSummary, module.dependencySummary]
534
+ .filter(Boolean)
535
+ .join(' ')
536
+ .trim();
537
+ if (!excerpt) {
538
+ return null;
539
+ }
540
+ return {
541
+ sourceType: 'architecture-narrative',
542
+ label: module.sourceTarget,
543
+ path: 'architecture-narrative.md',
544
+ excerpt,
545
+ };
546
+ }
547
+ function summarizeArchitectureSection(section) {
548
+ if (!section) {
549
+ return '';
550
+ }
551
+ const parts = [
552
+ section.title,
553
+ section.description ?? '',
554
+ ...section.nodes.slice(0, 4).map((node) => `${node.kind}:${node.label}`),
555
+ ...section.edges.slice(0, 4).map((edge) => `${edge.from}->${edge.to}:${edge.relation}`),
556
+ section.missingReason ?? '',
557
+ ].filter(Boolean);
558
+ return parts.join(' | ');
559
+ }
560
+ function matchEvidence(corpus, keywords, limit) {
561
+ const loweredKeywords = keywords.map((item) => item.toLowerCase());
562
+ const matchedItems = corpus.entries
563
+ .map((entry) => {
564
+ const loweredText = entry.text.toLowerCase();
565
+ const score = loweredKeywords.reduce((sum, keyword) => (loweredText.includes(keyword) ? sum + 1 : sum), 0);
566
+ if (score === 0) {
567
+ return null;
568
+ }
569
+ return {
570
+ score,
571
+ evidence: {
572
+ sourceType: entry.sourceType,
573
+ label: entry.label,
574
+ path: entry.path,
575
+ excerpt: summarizeEvidenceText(entry.text, loweredKeywords),
576
+ },
577
+ };
578
+ })
579
+ .filter((item) => item !== null);
580
+ return matchedItems
581
+ .sort((left, right) => right.score - left.score || left.evidence.label.localeCompare(right.evidence.label))
582
+ .slice(0, limit)
583
+ .map((item) => item.evidence);
584
+ }
585
+ function summarizeEvidenceText(text, loweredKeywords) {
586
+ const normalized = text.replace(/\r/g, '');
587
+ const lines = normalized.split('\n').map((line) => line.trim()).filter(Boolean);
588
+ const matchedLine = lines.find((line) => {
589
+ const lowered = line.toLowerCase();
590
+ return loweredKeywords.some((keyword) => lowered.includes(keyword));
591
+ });
592
+ const source = matchedLine ?? lines[0] ?? normalized;
593
+ return source.length > 240 ? `${source.slice(0, 237)}...` : source;
594
+ }
595
+ function collectMarkdownEvidenceFiles(projectRoot) {
596
+ const specsDir = path.join(projectRoot, 'specs');
597
+ if (!fs.existsSync(specsDir)) {
598
+ return [];
599
+ }
600
+ const results = [];
601
+ walkDirectory(specsDir, (filePath) => {
602
+ const relative = normalizeProjectPath(filePath, projectRoot).toLowerCase();
603
+ if (relative.endsWith('/current-spec.md')
604
+ || relative.endsWith('/blueprint.md')
605
+ || relative.endsWith('/spec.md')) {
606
+ results.push(filePath);
607
+ }
608
+ });
609
+ return results.sort((left, right) => left.localeCompare(right));
610
+ }
611
+ function collectSourcePathSignals(projectRoot) {
612
+ const results = [];
613
+ walkDirectory(projectRoot, (filePath) => {
614
+ const relative = normalizeProjectPath(filePath, projectRoot);
615
+ const lower = relative.toLowerCase();
616
+ if (lower.startsWith('.git/')
617
+ || lower.startsWith('node_modules/')
618
+ || lower.startsWith('dist/')
619
+ || lower.startsWith('coverage/')
620
+ || lower.startsWith('specs/')
621
+ || lower.startsWith('.reverse-spec')) {
622
+ return;
623
+ }
624
+ results.push(relative);
625
+ });
626
+ return results.sort((left, right) => left.localeCompare(right));
627
+ }
628
+ function walkDirectory(dir, onFile) {
629
+ if (!fs.existsSync(dir)) {
630
+ return;
631
+ }
632
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
633
+ if (entry.isSymbolicLink()) {
634
+ continue;
635
+ }
636
+ const fullPath = path.join(dir, entry.name);
637
+ if (entry.isDirectory()) {
638
+ walkDirectory(fullPath, onFile);
639
+ continue;
640
+ }
641
+ if (entry.isFile()) {
642
+ onFile(fullPath);
643
+ }
644
+ }
645
+ }
646
+ function loadRecentGitCommits(projectRoot) {
647
+ const result = spawnSync('git', ['-C', projectRoot, 'log', '--no-color', '--pretty=format:%H%x1f%s%x1f%b%x1e', '-n', '20'], { encoding: 'utf-8' });
648
+ if (result.status !== 0 || !result.stdout) {
649
+ return [];
650
+ }
651
+ return result.stdout
652
+ .split('\x1e')
653
+ .map((chunk) => chunk.trim())
654
+ .filter(Boolean)
655
+ .map((chunk) => {
656
+ const [sha, subject, body] = chunk.split('\x1f');
657
+ return {
658
+ sha: sha ?? '',
659
+ subject: subject ?? '',
660
+ body: body ?? '',
661
+ };
662
+ })
663
+ .filter((entry) => entry.sha && entry.subject);
664
+ }
665
+ function normalizeProjectPath(filePath, projectRoot) {
666
+ const relative = path.relative(projectRoot, filePath);
667
+ return relative.split(path.sep).join('/');
668
+ }
669
+ function readTrimmed(filePath, maxLength) {
670
+ const content = fs.readFileSync(filePath, 'utf-8');
671
+ const normalized = content.replace(/\r/g, '');
672
+ return normalized.length > maxLength ? normalized.slice(0, maxLength) : normalized;
673
+ }
674
+ function slugify(value) {
675
+ return value
676
+ .toLowerCase()
677
+ .replace(/[^a-z0-9\u4e00-\u9fa5]+/g, '-')
678
+ .replace(/-+/g, '-')
679
+ .replace(/^-|-$/g, '')
680
+ .slice(0, 80);
681
+ }
682
+ function uniqueSorted(items) {
683
+ return [...new Set(items)].sort((left, right) => left.localeCompare(right));
684
+ }
685
+ //# sourceMappingURL=adr-decision-pipeline.js.map