@llm-dev-ops/agentics-cli 1.4.58 → 1.4.68

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 (451) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/agents.d.ts.map +1 -1
  3. package/dist/commands/agents.js +227 -19
  4. package/dist/commands/agents.js.map +1 -1
  5. package/dist/pipeline/auto-chain.d.ts +1 -0
  6. package/dist/pipeline/auto-chain.d.ts.map +1 -1
  7. package/dist/pipeline/auto-chain.js +124 -37
  8. package/dist/pipeline/auto-chain.js.map +1 -1
  9. package/dist/pipeline/execution-context.d.ts.map +1 -1
  10. package/dist/pipeline/execution-context.js +12 -37
  11. package/dist/pipeline/execution-context.js.map +1 -1
  12. package/dist/pipeline/phase2/phases/adr-generator.d.ts.map +1 -1
  13. package/dist/pipeline/phase2/phases/adr-generator.js +160 -1
  14. package/dist/pipeline/phase2/phases/adr-generator.js.map +1 -1
  15. package/dist/pipeline/phase2/phases/ddd-generator.d.ts.map +1 -1
  16. package/dist/pipeline/phase2/phases/ddd-generator.js +400 -3
  17. package/dist/pipeline/phase2/phases/ddd-generator.js.map +1 -1
  18. package/dist/pipeline/phase2/phases/ddd-quality-gate.d.ts +43 -0
  19. package/dist/pipeline/phase2/phases/ddd-quality-gate.d.ts.map +1 -0
  20. package/dist/pipeline/phase2/phases/ddd-quality-gate.js +413 -0
  21. package/dist/pipeline/phase2/phases/ddd-quality-gate.js.map +1 -0
  22. package/dist/pipeline/phase2/phases/research-dossier.d.ts +0 -13
  23. package/dist/pipeline/phase2/phases/research-dossier.d.ts.map +1 -1
  24. package/dist/pipeline/phase2/phases/research-dossier.js +114 -1
  25. package/dist/pipeline/phase2/phases/research-dossier.js.map +1 -1
  26. package/dist/pipeline/phase2/phases/research-quality-gate.d.ts +48 -0
  27. package/dist/pipeline/phase2/phases/research-quality-gate.d.ts.map +1 -0
  28. package/dist/pipeline/phase2/phases/research-quality-gate.js +322 -0
  29. package/dist/pipeline/phase2/phases/research-quality-gate.js.map +1 -0
  30. package/dist/pipeline/phase2/phases/sparc-quality-gate.d.ts +41 -0
  31. package/dist/pipeline/phase2/phases/sparc-quality-gate.d.ts.map +1 -0
  32. package/dist/pipeline/phase2/phases/sparc-quality-gate.js +350 -0
  33. package/dist/pipeline/phase2/phases/sparc-quality-gate.js.map +1 -0
  34. package/dist/pipeline/phase2/phases/sparc-specification.d.ts +14 -0
  35. package/dist/pipeline/phase2/phases/sparc-specification.d.ts.map +1 -1
  36. package/dist/pipeline/phase2/phases/sparc-specification.js +500 -10
  37. package/dist/pipeline/phase2/phases/sparc-specification.js.map +1 -1
  38. package/dist/pipeline/phase2/phases/tdd-plan-generator.js +1 -1
  39. package/dist/pipeline/phase2/phases/tdd-plan-generator.js.map +1 -1
  40. package/dist/pipeline/phase2/phases/tech-stack-detector.d.ts +72 -0
  41. package/dist/pipeline/phase2/phases/tech-stack-detector.d.ts.map +1 -0
  42. package/dist/pipeline/phase2/phases/tech-stack-detector.js +332 -0
  43. package/dist/pipeline/phase2/phases/tech-stack-detector.js.map +1 -0
  44. package/dist/pipeline/phase2/types.d.ts +2 -0
  45. package/dist/pipeline/phase2/types.d.ts.map +1 -1
  46. package/dist/pipeline/phase3/phases/domain-codegen.d.ts.map +1 -1
  47. package/dist/pipeline/phase3/phases/domain-codegen.js +169 -4
  48. package/dist/pipeline/phase3/phases/domain-codegen.js.map +1 -1
  49. package/dist/pipeline/phase3/phases/test-generator.d.ts.map +1 -1
  50. package/dist/pipeline/phase3/phases/test-generator.js +12 -2
  51. package/dist/pipeline/phase3/phases/test-generator.js.map +1 -1
  52. package/dist/pipeline/phase3-sparc/phase3-sparc-coordinator.d.ts.map +1 -1
  53. package/dist/pipeline/phase3-sparc/phase3-sparc-coordinator.js +99 -1
  54. package/dist/pipeline/phase3-sparc/phase3-sparc-coordinator.js.map +1 -1
  55. package/dist/pipeline/phase4/phases/deployment-generator.d.ts +17 -4
  56. package/dist/pipeline/phase4/phases/deployment-generator.d.ts.map +1 -1
  57. package/dist/pipeline/phase4/phases/deployment-generator.js +364 -44
  58. package/dist/pipeline/phase4/phases/deployment-generator.js.map +1 -1
  59. package/dist/pipeline/phase4/phases/erp-client-generator.d.ts.map +1 -1
  60. package/dist/pipeline/phase4/phases/erp-client-generator.js +27 -15
  61. package/dist/pipeline/phase4/phases/erp-client-generator.js.map +1 -1
  62. package/dist/pipeline/phase4/phases/erp-target-resolver.d.ts.map +1 -1
  63. package/dist/pipeline/phase4/phases/erp-target-resolver.js +49 -2
  64. package/dist/pipeline/phase4/phases/erp-target-resolver.js.map +1 -1
  65. package/dist/pipeline/phase4/phases/http-server-generator.d.ts.map +1 -1
  66. package/dist/pipeline/phase4/phases/http-server-generator.js +263 -3
  67. package/dist/pipeline/phase4/phases/http-server-generator.js.map +1 -1
  68. package/dist/pipeline/phase4/phases/infra-adapter-generator.d.ts.map +1 -1
  69. package/dist/pipeline/phase4/phases/infra-adapter-generator.js +335 -37
  70. package/dist/pipeline/phase4/phases/infra-adapter-generator.js.map +1 -1
  71. package/dist/pipeline/phase4/types.d.ts +3 -1
  72. package/dist/pipeline/phase4/types.d.ts.map +1 -1
  73. package/dist/pipeline/phase4-adrs/phase4-adrs-coordinator.d.ts.map +1 -1
  74. package/dist/pipeline/phase4-adrs/phase4-adrs-coordinator.js +211 -2
  75. package/dist/pipeline/phase4-adrs/phase4-adrs-coordinator.js.map +1 -1
  76. package/dist/pipeline/phase5-build/phases/implementation-quality-gate.d.ts +54 -0
  77. package/dist/pipeline/phase5-build/phases/implementation-quality-gate.d.ts.map +1 -0
  78. package/dist/pipeline/phase5-build/phases/implementation-quality-gate.js +417 -0
  79. package/dist/pipeline/phase5-build/phases/implementation-quality-gate.js.map +1 -0
  80. package/dist/pipeline/phases/prompt-generator.js +1 -1
  81. package/dist/pipeline/phases/prompt-generator.js.map +1 -1
  82. package/dist/pipeline/ruflo-phase-executor.d.ts +116 -1
  83. package/dist/pipeline/ruflo-phase-executor.d.ts.map +1 -1
  84. package/dist/pipeline/ruflo-phase-executor.js +666 -159
  85. package/dist/pipeline/ruflo-phase-executor.js.map +1 -1
  86. package/dist/pipeline/swarm-orchestrator.d.ts.map +1 -1
  87. package/dist/pipeline/swarm-orchestrator.js +62 -6
  88. package/dist/pipeline/swarm-orchestrator.js.map +1 -1
  89. package/dist/routing/capability-classifier.d.ts +43 -0
  90. package/dist/routing/capability-classifier.d.ts.map +1 -0
  91. package/dist/routing/capability-classifier.js +157 -0
  92. package/dist/routing/capability-classifier.js.map +1 -0
  93. package/dist/routing/composition-engine.d.ts +77 -0
  94. package/dist/routing/composition-engine.d.ts.map +1 -0
  95. package/dist/routing/composition-engine.js +249 -0
  96. package/dist/routing/composition-engine.js.map +1 -0
  97. package/dist/routing/graph-federation.d.ts +71 -0
  98. package/dist/routing/graph-federation.d.ts.map +1 -0
  99. package/dist/routing/graph-federation.js +210 -0
  100. package/dist/routing/graph-federation.js.map +1 -0
  101. package/dist/routing/graph-loader.d.ts +74 -0
  102. package/dist/routing/graph-loader.d.ts.map +1 -0
  103. package/dist/routing/graph-loader.js +383 -0
  104. package/dist/routing/graph-loader.js.map +1 -0
  105. package/dist/routing/graph-router.d.ts +103 -0
  106. package/dist/routing/graph-router.d.ts.map +1 -0
  107. package/dist/routing/graph-router.js +415 -0
  108. package/dist/routing/graph-router.js.map +1 -0
  109. package/dist/routing/graph-validator.d.ts +44 -0
  110. package/dist/routing/graph-validator.d.ts.map +1 -0
  111. package/dist/routing/graph-validator.js +329 -0
  112. package/dist/routing/graph-validator.js.map +1 -0
  113. package/dist/routing/index.d.ts +52 -0
  114. package/dist/routing/index.d.ts.map +1 -0
  115. package/dist/routing/index.js +68 -0
  116. package/dist/routing/index.js.map +1 -0
  117. package/dist/routing/outcome-recorder.d.ts +71 -0
  118. package/dist/routing/outcome-recorder.d.ts.map +1 -0
  119. package/dist/routing/outcome-recorder.js +133 -0
  120. package/dist/routing/outcome-recorder.js.map +1 -0
  121. package/dist/routing/weight-adjuster.d.ts +59 -0
  122. package/dist/routing/weight-adjuster.d.ts.map +1 -0
  123. package/dist/routing/weight-adjuster.js +167 -0
  124. package/dist/routing/weight-adjuster.js.map +1 -0
  125. package/dist/routing/weighted-resolver.d.ts +55 -0
  126. package/dist/routing/weighted-resolver.d.ts.map +1 -0
  127. package/dist/routing/weighted-resolver.js +133 -0
  128. package/dist/routing/weighted-resolver.js.map +1 -0
  129. package/dist/synthesis/ask-artifact-writer.d.ts.map +1 -1
  130. package/dist/synthesis/ask-artifact-writer.js +8 -0
  131. package/dist/synthesis/ask-artifact-writer.js.map +1 -1
  132. package/dist/synthesis/simulation-artifact-generator.d.ts +14 -0
  133. package/dist/synthesis/simulation-artifact-generator.d.ts.map +1 -1
  134. package/dist/synthesis/simulation-artifact-generator.js +224 -1
  135. package/dist/synthesis/simulation-artifact-generator.js.map +1 -1
  136. package/dist/synthesis/simulation-renderers.d.ts.map +1 -1
  137. package/dist/synthesis/simulation-renderers.js +211 -40
  138. package/dist/synthesis/simulation-renderers.js.map +1 -1
  139. package/package.json +1 -1
  140. package/dist/bundled-agents/connector-hub-agents/package-lock.json +0 -11697
  141. package/dist/bundled-agents/connector-hub-agents/package.json +0 -75
  142. package/dist/bundled-agents/connector-hub-agents/tsconfig.build.json +0 -22
  143. package/dist/bundled-agents/connector-hub-agents/tsconfig.json +0 -57
  144. package/dist/bundled-agents/copilot-agents/functions/.gcloudignore +0 -17
  145. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/cors.d.ts +0 -14
  146. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/cors.js +0 -35
  147. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/cors.js.map +0 -1
  148. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/envelope.d.ts +0 -55
  149. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/envelope.js +0 -40
  150. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/envelope.js.map +0 -1
  151. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/health.d.ts +0 -22
  152. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/health.js +0 -38
  153. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/health.js.map +0 -1
  154. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/index.d.ts +0 -34
  155. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/index.js +0 -186
  156. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/index.js.map +0 -1
  157. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/router.d.ts +0 -36
  158. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/router.js +0 -121
  159. package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/router.js.map +0 -1
  160. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/config-validation/config-validation-agent.d.ts +0 -157
  161. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/config-validation/config-validation-agent.js +0 -948
  162. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/config-validation/config-validation-agent.js.map +0 -1
  163. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/config-validation/index.d.ts +0 -9
  164. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/config-validation/index.js +0 -27
  165. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/config-validation/index.js.map +0 -1
  166. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/agent-span-wrapper.d.ts +0 -23
  167. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/agent-span-wrapper.js +0 -50
  168. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/agent-span-wrapper.js.map +0 -1
  169. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/base-agent.d.ts +0 -214
  170. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/base-agent.js +0 -91
  171. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/base-agent.js.map +0 -1
  172. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/config-validation-schemas.d.ts +0 -1166
  173. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/config-validation-schemas.js +0 -308
  174. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/config-validation-schemas.js.map +0 -1
  175. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/decision-event.d.ts +0 -59
  176. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/decision-event.js +0 -62
  177. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/decision-event.js.map +0 -1
  178. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/decomposer-schemas.d.ts +0 -400
  179. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/decomposer-schemas.js +0 -113
  180. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/decomposer-schemas.js.map +0 -1
  181. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/execution-graph.d.ts +0 -250
  182. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/execution-graph.js +0 -169
  183. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/execution-graph.js.map +0 -1
  184. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/index.d.ts +0 -17
  185. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/index.js +0 -97
  186. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/index.js.map +0 -1
  187. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/intelligence-schemas.d.ts +0 -1674
  188. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/intelligence-schemas.js +0 -246
  189. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/intelligence-schemas.js.map +0 -1
  190. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/intent-classifier-schemas.d.ts +0 -1085
  191. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/intent-classifier-schemas.js +0 -218
  192. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/intent-classifier-schemas.js.map +0 -1
  193. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/meta-reasoner-schemas.d.ts +0 -949
  194. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/meta-reasoner-schemas.js +0 -253
  195. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/meta-reasoner-schemas.js.map +0 -1
  196. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/objective-clarifier-schemas.d.ts +0 -657
  197. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/objective-clarifier-schemas.js +0 -205
  198. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/objective-clarifier-schemas.js.map +0 -1
  199. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/pipeline-schemas.d.ts +0 -285
  200. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/pipeline-schemas.js +0 -106
  201. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/pipeline-schemas.js.map +0 -1
  202. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/planner-schemas.d.ts +0 -581
  203. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/planner-schemas.js +0 -136
  204. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/planner-schemas.js.map +0 -1
  205. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/reflection-schemas.d.ts +0 -791
  206. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/reflection-schemas.js +0 -225
  207. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/reflection-schemas.js.map +0 -1
  208. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/decomposer/decomposer-agent.d.ts +0 -120
  209. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/decomposer/decomposer-agent.js +0 -535
  210. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/decomposer/decomposer-agent.js.map +0 -1
  211. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/decomposer/index.d.ts +0 -9
  212. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/decomposer/index.js +0 -18
  213. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/decomposer/index.js.map +0 -1
  214. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/intent-classifier/index.d.ts +0 -4
  215. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/intent-classifier/index.js +0 -9
  216. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/intent-classifier/index.js.map +0 -1
  217. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/intent-classifier/intent-classifier-agent.d.ts +0 -123
  218. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/intent-classifier/intent-classifier-agent.js +0 -609
  219. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/intent-classifier/intent-classifier-agent.js.map +0 -1
  220. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/index.d.ts +0 -10
  221. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/index.js +0 -25
  222. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/index.js.map +0 -1
  223. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/meta-reasoner-agent.d.ts +0 -111
  224. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/meta-reasoner-agent.js +0 -686
  225. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/meta-reasoner-agent.js.map +0 -1
  226. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/telemetry.d.ts +0 -11
  227. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/telemetry.js +0 -25
  228. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/telemetry.js.map +0 -1
  229. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/index.d.ts +0 -6
  230. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/index.js +0 -15
  231. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/index.js.map +0 -1
  232. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/objective-clarifier-agent.d.ts +0 -126
  233. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/objective-clarifier-agent.js +0 -780
  234. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/objective-clarifier-agent.js.map +0 -1
  235. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/ruvector-persistence.d.ts +0 -49
  236. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/ruvector-persistence.js +0 -125
  237. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/ruvector-persistence.js.map +0 -1
  238. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/telemetry.d.ts +0 -73
  239. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/telemetry.js +0 -192
  240. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/telemetry.js.map +0 -1
  241. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/index.d.ts +0 -11
  242. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/index.js +0 -25
  243. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/index.js.map +0 -1
  244. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/planner-agent.d.ts +0 -127
  245. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/planner-agent.js +0 -483
  246. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/planner-agent.js.map +0 -1
  247. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/ruvector-persistence.d.ts +0 -49
  248. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/ruvector-persistence.js +0 -125
  249. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/ruvector-persistence.js.map +0 -1
  250. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/telemetry.d.ts +0 -73
  251. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/telemetry.js +0 -192
  252. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/telemetry.js.map +0 -1
  253. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/index.d.ts +0 -11
  254. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/index.js +0 -27
  255. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/index.js.map +0 -1
  256. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/reflection-agent.d.ts +0 -122
  257. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/reflection-agent.js +0 -645
  258. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/reflection-agent.js.map +0 -1
  259. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/ruvector-persistence.d.ts +0 -59
  260. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/ruvector-persistence.js +0 -156
  261. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/ruvector-persistence.js.map +0 -1
  262. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/telemetry.d.ts +0 -88
  263. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/telemetry.js +0 -246
  264. package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/telemetry.js.map +0 -1
  265. package/dist/bundled-agents/copilot-agents/functions/index.js +0 -4
  266. package/dist/bundled-agents/copilot-agents/functions/jest.config.js +0 -29
  267. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/cors.d.ts +0 -14
  268. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/cors.js +0 -35
  269. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/cors.js.map +0 -1
  270. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/envelope.d.ts +0 -27
  271. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/envelope.js +0 -21
  272. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/envelope.js.map +0 -1
  273. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/health.d.ts +0 -22
  274. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/health.js +0 -38
  275. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/health.js.map +0 -1
  276. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/index.d.ts +0 -34
  277. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/index.js +0 -174
  278. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/index.js.map +0 -1
  279. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/router.d.ts +0 -27
  280. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/router.js +0 -107
  281. package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/router.js.map +0 -1
  282. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/config-validation/config-validation-agent.d.ts +0 -157
  283. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/config-validation/config-validation-agent.js +0 -941
  284. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/config-validation/config-validation-agent.js.map +0 -1
  285. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/config-validation/index.d.ts +0 -9
  286. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/config-validation/index.js +0 -27
  287. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/config-validation/index.js.map +0 -1
  288. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/agent-span-wrapper.d.ts +0 -23
  289. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/agent-span-wrapper.js +0 -50
  290. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/agent-span-wrapper.js.map +0 -1
  291. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/base-agent.d.ts +0 -185
  292. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/base-agent.js +0 -86
  293. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/base-agent.js.map +0 -1
  294. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/config-validation-schemas.d.ts +0 -1081
  295. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/config-validation-schemas.js +0 -305
  296. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/config-validation-schemas.js.map +0 -1
  297. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/decision-event.d.ts +0 -59
  298. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/decision-event.js +0 -62
  299. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/decision-event.js.map +0 -1
  300. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/decomposer-schemas.d.ts +0 -315
  301. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/decomposer-schemas.js +0 -110
  302. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/decomposer-schemas.js.map +0 -1
  303. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/execution-graph.d.ts +0 -250
  304. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/execution-graph.js +0 -169
  305. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/execution-graph.js.map +0 -1
  306. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/index.d.ts +0 -16
  307. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/index.js +0 -88
  308. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/index.js.map +0 -1
  309. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/intelligence-schemas.d.ts +0 -1674
  310. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/intelligence-schemas.js +0 -246
  311. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/intelligence-schemas.js.map +0 -1
  312. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/intent-classifier-schemas.d.ts +0 -1000
  313. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/intent-classifier-schemas.js +0 -215
  314. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/intent-classifier-schemas.js.map +0 -1
  315. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/meta-reasoner-schemas.d.ts +0 -864
  316. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/meta-reasoner-schemas.js +0 -250
  317. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/meta-reasoner-schemas.js.map +0 -1
  318. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/objective-clarifier-schemas.d.ts +0 -572
  319. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/objective-clarifier-schemas.js +0 -202
  320. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/objective-clarifier-schemas.js.map +0 -1
  321. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/planner-schemas.d.ts +0 -496
  322. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/planner-schemas.js +0 -133
  323. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/planner-schemas.js.map +0 -1
  324. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/reflection-schemas.d.ts +0 -706
  325. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/reflection-schemas.js +0 -222
  326. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/reflection-schemas.js.map +0 -1
  327. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/decomposer/decomposer-agent.d.ts +0 -107
  328. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/decomposer/decomposer-agent.js +0 -360
  329. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/decomposer/decomposer-agent.js.map +0 -1
  330. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/decomposer/index.d.ts +0 -9
  331. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/decomposer/index.js +0 -18
  332. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/decomposer/index.js.map +0 -1
  333. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/intent-classifier/index.d.ts +0 -4
  334. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/intent-classifier/index.js +0 -9
  335. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/intent-classifier/index.js.map +0 -1
  336. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/intent-classifier/intent-classifier-agent.d.ts +0 -123
  337. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/intent-classifier/intent-classifier-agent.js +0 -609
  338. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/intent-classifier/intent-classifier-agent.js.map +0 -1
  339. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/index.d.ts +0 -10
  340. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/index.js +0 -25
  341. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/index.js.map +0 -1
  342. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/meta-reasoner-agent.d.ts +0 -111
  343. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/meta-reasoner-agent.js +0 -686
  344. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/meta-reasoner-agent.js.map +0 -1
  345. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/telemetry.d.ts +0 -11
  346. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/telemetry.js +0 -25
  347. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/telemetry.js.map +0 -1
  348. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/index.d.ts +0 -6
  349. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/index.js +0 -15
  350. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/index.js.map +0 -1
  351. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/objective-clarifier-agent.d.ts +0 -126
  352. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/objective-clarifier-agent.js +0 -780
  353. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/objective-clarifier-agent.js.map +0 -1
  354. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/ruvector-persistence.d.ts +0 -49
  355. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/ruvector-persistence.js +0 -125
  356. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/ruvector-persistence.js.map +0 -1
  357. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/telemetry.d.ts +0 -73
  358. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/telemetry.js +0 -192
  359. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/telemetry.js.map +0 -1
  360. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/index.d.ts +0 -11
  361. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/index.js +0 -25
  362. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/index.js.map +0 -1
  363. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/planner-agent.d.ts +0 -119
  364. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/planner-agent.js +0 -421
  365. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/planner-agent.js.map +0 -1
  366. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/ruvector-persistence.d.ts +0 -49
  367. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/ruvector-persistence.js +0 -125
  368. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/ruvector-persistence.js.map +0 -1
  369. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/telemetry.d.ts +0 -73
  370. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/telemetry.js +0 -192
  371. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/telemetry.js.map +0 -1
  372. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/index.d.ts +0 -11
  373. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/index.js +0 -27
  374. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/index.js.map +0 -1
  375. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/reflection-agent.d.ts +0 -122
  376. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/reflection-agent.js +0 -645
  377. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/reflection-agent.js.map +0 -1
  378. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/ruvector-persistence.d.ts +0 -59
  379. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/ruvector-persistence.js +0 -156
  380. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/ruvector-persistence.js.map +0 -1
  381. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/telemetry.d.ts +0 -88
  382. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/telemetry.js +0 -246
  383. package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/telemetry.js.map +0 -1
  384. package/dist/bundled-agents/copilot-agents/functions/package-lock.json +0 -5473
  385. package/dist/bundled-agents/copilot-agents/functions/package.json +0 -40
  386. package/dist/bundled-agents/copilot-agents/functions/src/claude.ts +0 -71
  387. package/dist/bundled-agents/copilot-agents/functions/src/cors.ts +0 -36
  388. package/dist/bundled-agents/copilot-agents/functions/src/envelope.ts +0 -77
  389. package/dist/bundled-agents/copilot-agents/functions/src/handler.test.ts +0 -340
  390. package/dist/bundled-agents/copilot-agents/functions/src/health.ts +0 -53
  391. package/dist/bundled-agents/copilot-agents/functions/src/index.ts +0 -201
  392. package/dist/bundled-agents/copilot-agents/functions/src/router.ts +0 -148
  393. package/dist/bundled-agents/copilot-agents/functions/tsconfig.json +0 -31
  394. package/dist/bundled-agents/copilot-agents/package-lock.json +0 -11825
  395. package/dist/bundled-agents/copilot-agents/package.json +0 -5
  396. package/dist/bundled-agents/governance-dashboard-agents/package-lock.json +0 -8282
  397. package/dist/bundled-agents/governance-dashboard-agents/package.json +0 -13
  398. package/dist/bundled-agents/orchestrator-agents/functions/contracts/index.js +0 -590
  399. package/dist/bundled-agents/orchestrator-agents/functions/index.js +0 -442
  400. package/dist/bundled-agents/orchestrator-agents/functions/test.js +0 -325
  401. package/dist/bundled-agents/orchestrator-agents/index.js +0 -6
  402. package/dist/bundled-agents/orchestrator-agents/package-lock.json +0 -13254
  403. package/dist/bundled-agents/orchestrator-agents/package.json +0 -20
  404. package/dist/bundled-agents/platform-agents/package-lock.json +0 -1723
  405. package/dist/bundled-agents/platform-agents/package.json +0 -22
  406. package/dist/bundled-agents/platform-agents/src/agents/decision-memo.ts +0 -463
  407. package/dist/bundled-agents/platform-agents/src/agents/decision.ts +0 -234
  408. package/dist/bundled-agents/platform-agents/src/agents/executive-summary.ts +0 -229
  409. package/dist/bundled-agents/platform-agents/src/agents/risk-score.ts +0 -327
  410. package/dist/bundled-agents/platform-agents/src/claude.ts +0 -71
  411. package/dist/bundled-agents/platform-agents/src/cors.ts +0 -24
  412. package/dist/bundled-agents/platform-agents/src/envelope.ts +0 -37
  413. package/dist/bundled-agents/platform-agents/src/health.ts +0 -20
  414. package/dist/bundled-agents/platform-agents/src/index.ts +0 -171
  415. package/dist/bundled-agents/platform-agents/src/router.ts +0 -38
  416. package/dist/bundled-agents/platform-agents/src/text-analysis.ts +0 -238
  417. package/dist/bundled-agents/platform-agents/tsconfig.json +0 -19
  418. package/dist/bundled-agents/sentinel-agents/lib/agents/alert.d.ts +0 -3
  419. package/dist/bundled-agents/sentinel-agents/lib/agents/alert.d.ts.map +0 -1
  420. package/dist/bundled-agents/sentinel-agents/lib/agents/alert.js +0 -43
  421. package/dist/bundled-agents/sentinel-agents/lib/agents/alert.js.map +0 -1
  422. package/dist/bundled-agents/sentinel-agents/lib/agents/anomaly.d.ts +0 -3
  423. package/dist/bundled-agents/sentinel-agents/lib/agents/anomaly.d.ts.map +0 -1
  424. package/dist/bundled-agents/sentinel-agents/lib/agents/anomaly.js +0 -30
  425. package/dist/bundled-agents/sentinel-agents/lib/agents/anomaly.js.map +0 -1
  426. package/dist/bundled-agents/sentinel-agents/lib/agents/correlation.d.ts +0 -3
  427. package/dist/bundled-agents/sentinel-agents/lib/agents/correlation.d.ts.map +0 -1
  428. package/dist/bundled-agents/sentinel-agents/lib/agents/correlation.js +0 -53
  429. package/dist/bundled-agents/sentinel-agents/lib/agents/correlation.js.map +0 -1
  430. package/dist/bundled-agents/sentinel-agents/lib/agents/drift.d.ts +0 -3
  431. package/dist/bundled-agents/sentinel-agents/lib/agents/drift.d.ts.map +0 -1
  432. package/dist/bundled-agents/sentinel-agents/lib/agents/drift.js +0 -51
  433. package/dist/bundled-agents/sentinel-agents/lib/agents/drift.js.map +0 -1
  434. package/dist/bundled-agents/sentinel-agents/lib/agents/rca.d.ts +0 -3
  435. package/dist/bundled-agents/sentinel-agents/lib/agents/rca.d.ts.map +0 -1
  436. package/dist/bundled-agents/sentinel-agents/lib/agents/rca.js +0 -36
  437. package/dist/bundled-agents/sentinel-agents/lib/agents/rca.js.map +0 -1
  438. package/dist/bundled-agents/sentinel-agents/lib/index.d.ts +0 -2
  439. package/dist/bundled-agents/sentinel-agents/lib/index.d.ts.map +0 -1
  440. package/dist/bundled-agents/sentinel-agents/lib/index.js +0 -70
  441. package/dist/bundled-agents/sentinel-agents/lib/index.js.map +0 -1
  442. package/dist/bundled-agents/sentinel-agents/package-lock.json +0 -12591
  443. package/dist/bundled-agents/sentinel-agents/package.json +0 -62
  444. package/dist/bundled-agents/sentinel-agents/src/agents/alert.ts +0 -46
  445. package/dist/bundled-agents/sentinel-agents/src/agents/anomaly.ts +0 -33
  446. package/dist/bundled-agents/sentinel-agents/src/agents/correlation.ts +0 -56
  447. package/dist/bundled-agents/sentinel-agents/src/agents/drift.ts +0 -54
  448. package/dist/bundled-agents/sentinel-agents/src/agents/rca.ts +0 -38
  449. package/dist/bundled-agents/sentinel-agents/src/claude.ts +0 -71
  450. package/dist/bundled-agents/sentinel-agents/src/index.ts +0 -77
  451. package/dist/bundled-agents/sentinel-agents/tsconfig.json +0 -20
@@ -19,6 +19,7 @@ import * as fs from 'node:fs';
19
19
  import * as path from 'node:path';
20
20
  import { createSpan, endSpan, emitSpan } from '../telemetry.js';
21
21
  import { normalizeContextName } from './ddd-generator.js';
22
+ import { createClaudeCodeRunner } from '../../../runtime/claude-code-runner.js';
22
23
  // ============================================================================
23
24
  // Constants
24
25
  // ============================================================================
@@ -26,11 +27,322 @@ const DIR_MODE = 0o700;
26
27
  const FILE_MODE = 0o600;
27
28
  const SPARC_SUBDIR = 'sparc';
28
29
  // ============================================================================
30
+ // Intelligence / ML Detection
31
+ // ============================================================================
32
+ /**
33
+ * Detect whether the user's query requires intelligence/ML/analytics contexts.
34
+ * Returns keywords found and suggested intelligence context names.
35
+ */
36
+ export function detectIntelligenceRequirements(query) {
37
+ const lowerQuery = query.toLowerCase();
38
+ const keywords = [];
39
+ const patterns = [
40
+ [/\b(?:ai|artificial[\s-]?intelligence|machine[\s-]?learning|ml)\b/i, 'AI/ML'],
41
+ [/\b(?:predict|prediction|predictive)\b/i, 'prediction'],
42
+ [/\b(?:anomal|outlier|deviation[\s-]?detect)\b/i, 'anomaly-detection'],
43
+ [/\b(?:pattern[\s-]?recogni|pattern[\s-]?detect|pattern[\s-]?analys)\b/i, 'pattern-recognition'],
44
+ [/\b(?:forecast|forecasting|time[\s-]?series)\b/i, 'forecasting'],
45
+ [/\b(?:classif|categoriz|cluster)\b/i, 'classification'],
46
+ [/\b(?:neural[\s-]?net|deep[\s-]?learn|transformer|llm|nlp)\b/i, 'deep-learning'],
47
+ [/\b(?:recommend|suggestion[\s-]?engine|collaborative[\s-]?filter)\b/i, 'recommendation'],
48
+ [/\b(?:sentiment[\s-]?analy|text[\s-]?mining|natural[\s-]?language)\b/i, 'nlp'],
49
+ [/\b(?:computer[\s-]?vision|image[\s-]?recogni|object[\s-]?detect)\b/i, 'vision'],
50
+ [/\b(?:drift|model[\s-]?degradat|concept[\s-]?drift)\b/i, 'drift-detection'],
51
+ [/\b(?:feature[\s-]?engineer|feature[\s-]?extract|feature[\s-]?store)\b/i, 'feature-engineering'],
52
+ [/\b(?:train|training[\s-]?data|training[\s-]?pipeline|model[\s-]?train)\b/i, 'model-training'],
53
+ [/\b(?:data[\s-]?pipeline|etl|data[\s-]?ingest|data[\s-]?lake)\b/i, 'data-pipeline'],
54
+ [/\b(?:analytics|analytic|statistical[\s-]?analys|data[\s-]?analys)\b/i, 'analytics'],
55
+ [/\b(?:historical[\s-]?data|historical[\s-]?pattern|trend[\s-]?analys)\b/i, 'historical-analysis'],
56
+ ];
57
+ for (const [pat, keyword] of patterns) {
58
+ if (pat.test(lowerQuery))
59
+ keywords.push(keyword);
60
+ }
61
+ if (keywords.length === 0)
62
+ return { hasIntelligence: false, keywords: [], suggestedContexts: [] };
63
+ // Build suggested contexts based on detected keywords
64
+ const suggestedContexts = [];
65
+ if (keywords.some(k => ['anomaly-detection', 'drift-detection', 'pattern-recognition'].includes(k))) {
66
+ suggestedContexts.push({
67
+ name: 'anomaly-detection-engine',
68
+ type: 'anomaly-detection',
69
+ commands: ['DetectAnomalies', 'TrainDetectionModel', 'UpdateBaseline', 'GetAnomalyReport', 'ConfigureThresholds'],
70
+ description: 'Anomaly detection and pattern recognition engine using statistical and ML models',
71
+ });
72
+ }
73
+ if (keywords.some(k => ['prediction', 'forecasting', 'time-series'].includes(k))) {
74
+ suggestedContexts.push({
75
+ name: 'forecasting-engine',
76
+ type: 'forecasting',
77
+ commands: ['RunForecast', 'TrainForecastModel', 'EvaluateModelAccuracy', 'GetForecastResults', 'UpdateHistoricalData'],
78
+ description: 'Time-series forecasting and predictive analytics engine',
79
+ });
80
+ }
81
+ if (keywords.some(k => ['AI/ML', 'deep-learning', 'classification', 'model-training'].includes(k))) {
82
+ suggestedContexts.push({
83
+ name: 'ml-inference-engine',
84
+ type: 'ml-inference',
85
+ commands: ['RunInference', 'TrainModel', 'DeployModel', 'EvaluateModel', 'GetModelMetrics', 'RetireModel'],
86
+ description: 'Machine learning model lifecycle management and inference engine',
87
+ });
88
+ }
89
+ if (keywords.some(k => ['analytics', 'historical-analysis'].includes(k))) {
90
+ suggestedContexts.push({
91
+ name: 'analytics-engine',
92
+ type: 'analytics',
93
+ commands: ['RunAnalysis', 'GenerateReport', 'ComputeMetrics', 'QueryHistoricalData', 'BuildDashboard'],
94
+ description: 'Analytics and business intelligence engine for historical data analysis',
95
+ });
96
+ }
97
+ if (keywords.some(k => ['data-pipeline', 'feature-engineering'].includes(k))) {
98
+ suggestedContexts.push({
99
+ name: 'data-pipeline',
100
+ type: 'data-pipeline',
101
+ commands: ['IngestData', 'TransformData', 'ExtractFeatures', 'ValidateData', 'SchedulePipeline'],
102
+ description: 'Data ingestion, transformation, and feature engineering pipeline',
103
+ });
104
+ }
105
+ if (keywords.some(k => ['recommendation', 'nlp', 'vision'].includes(k))) {
106
+ suggestedContexts.push({
107
+ name: 'ml-inference-engine',
108
+ type: 'ml-inference',
109
+ commands: ['RunInference', 'TrainModel', 'DeployModel', 'EvaluateModel', 'GetModelMetrics', 'RetireModel'],
110
+ description: 'Machine learning model lifecycle management and inference engine',
111
+ });
112
+ }
113
+ // If we detected intelligence keywords but no specific context matched, add a generic one
114
+ if (suggestedContexts.length === 0) {
115
+ suggestedContexts.push({
116
+ name: 'intelligence-engine',
117
+ type: 'analytics',
118
+ commands: ['AnalyzeData', 'DetectPatterns', 'GenerateInsights', 'RunModel', 'GetResults'],
119
+ description: 'Intelligence and analytics engine for data-driven insights',
120
+ });
121
+ }
122
+ // Deduplicate by name
123
+ const seen = new Set();
124
+ const deduped = suggestedContexts.filter(c => {
125
+ if (seen.has(c.name))
126
+ return false;
127
+ seen.add(c.name);
128
+ return true;
129
+ });
130
+ return { hasIntelligence: true, keywords, suggestedContexts: deduped };
131
+ }
132
+ // ============================================================================
29
133
  // Helpers
30
134
  // ============================================================================
135
+ /**
136
+ * Load agentics fleet report from phase2Dir and format for LLM context.
137
+ * Returns a string summary of agent findings, or empty string if unavailable.
138
+ */
139
+ function loadAgenticsFleetContext(phase2Dir) {
140
+ try {
141
+ const reportPath = path.join(phase2Dir, 'agentics-agents-report.json');
142
+ if (!fs.existsSync(reportPath))
143
+ return '';
144
+ const report = JSON.parse(fs.readFileSync(reportPath, 'utf-8'));
145
+ if (!report.results || report.results.length === 0)
146
+ return '';
147
+ const successResults = report.results.filter(r => r.status === 200);
148
+ if (successResults.length === 0)
149
+ return '';
150
+ const agentSummaries = successResults.slice(0, 15).map(r => {
151
+ const resp = r.response;
152
+ const data = resp?.['data'];
153
+ // Extract meaningful content from agent response
154
+ let finding = '';
155
+ if (data) {
156
+ // Common agent response shapes
157
+ const plan = data['plan'];
158
+ const analysis = data['analysis'];
159
+ const hypothesis = data['hypothesis'];
160
+ const metrics = data['metrics'];
161
+ const recommendations = data['recommendations'];
162
+ if (plan?.['steps']) {
163
+ const steps = plan['steps'].slice(0, 3);
164
+ finding = steps.map(s => s['title'] || s['description'] || '').join('; ');
165
+ }
166
+ else if (analysis?.['summary'] || analysis?.['findings']) {
167
+ finding = String(analysis['summary'] || analysis['findings'] || '').slice(0, 200);
168
+ }
169
+ else if (hypothesis?.['statement']) {
170
+ finding = `Hypothesis: ${hypothesis['statement']}`;
171
+ }
172
+ else if (metrics?.['kpis']) {
173
+ const kpis = metrics['kpis'].slice(0, 3);
174
+ finding = kpis.map(k => `${k['name']}: ${k['value']} ${k['unit'] || ''}`).join('; ');
175
+ }
176
+ else if (recommendations) {
177
+ finding = recommendations.slice(0, 3)
178
+ .map(r2 => String(r2['recommendation'] || r2['title'] || r2)).join('; ');
179
+ }
180
+ else {
181
+ // Generic extraction: take first few string values
182
+ const vals = Object.values(data).filter(v => typeof v === 'string').slice(0, 2);
183
+ finding = vals.map(v => String(v).slice(0, 100)).join('; ');
184
+ }
185
+ }
186
+ return `- [${r.domain}/${r.agent}] ${r.role}: ${finding || 'analysis completed'}`;
187
+ }).join('\n');
188
+ return `\nAGENTICS FLEET ANALYSIS (${successResults.length} agents from 27 domains):\n${agentSummaries}\n`;
189
+ }
190
+ catch {
191
+ return '';
192
+ }
193
+ }
31
194
  function pad3(n) {
32
195
  return String(n).padStart(3, '0');
33
196
  }
197
+ // ============================================================================
198
+ // Complete SPARC Generation (single LLM call)
199
+ //
200
+ // SPARC is a high-level architecture document with 5 sections:
201
+ // Specification, Pseudocode, Architecture, Refinement, Completion
202
+ // Each section should be deep, domain-specific, and cohesive — not
203
+ // disconnected template fragments. See docs/SPARC-reference.md for examples.
204
+ // ============================================================================
205
+ /**
206
+ * Generate the ENTIRE SPARC document in one LLM call.
207
+ * This produces a cohesive architecture document like the PowerInfer example
208
+ * in docs/SPARC-reference.md — deep domain-specific content, not templates.
209
+ */
210
+ function tryGenerateCompleteSPARC(query, projectContext, dossier, artifacts, phase2Dir) {
211
+ try {
212
+ const runner = createClaudeCodeRunner();
213
+ // Build rich context from dossier + agents
214
+ const dossierItems = dossier.items.slice(0, 40)
215
+ .map(i => `- [${i.category}] ${i.title}: ${i.content.slice(0, 200)}`)
216
+ .join('\n');
217
+ const agentContext = loadAgenticsFleetContext(phase2Dir);
218
+ // Extract domain services for the prompt
219
+ const domainServices = extractDomainServices(query, artifacts, dossier);
220
+ const servicesList = domainServices.map(svc => `- ${svc.name}: ${svc.responsibility} (capabilities: ${svc.capabilities.join(', ')}; systems: ${svc.relatedSystems.join(', ') || 'none'})`).join('\n');
221
+ // Detect tech stack
222
+ const allText = (query + ' ' + projectContext).toLowerCase();
223
+ const techStack = [];
224
+ const techPatterns = [
225
+ [/\bsap\b/i, 'SAP'], [/\bsnowflake\b/i, 'Snowflake'], [/\bsalesforce\b/i, 'Salesforce'],
226
+ [/\baws\b/i, 'AWS'], [/\bazure\b/i, 'Azure'], [/\bgcp\b|google cloud/i, 'GCP'],
227
+ [/\bkafka\b/i, 'Kafka'], [/\bpostgres/i, 'PostgreSQL'], [/\bmongodb\b/i, 'MongoDB'],
228
+ [/\bredis\b/i, 'Redis'], [/\bkubernetes\b|\bk8s\b/i, 'Kubernetes'],
229
+ [/\boracle\b/i, 'Oracle'], [/\bnetsuite\b/i, 'NetSuite'], [/\bworkday\b/i, 'Workday'],
230
+ ];
231
+ for (const [pat, name] of techPatterns) {
232
+ if (pat.test(allText))
233
+ techStack.push(name);
234
+ }
235
+ // Detect intelligence/ML requirements
236
+ const intelligenceReqs = detectIntelligenceRequirements(query);
237
+ let intelligenceGuidance = '';
238
+ if (intelligenceReqs.hasIntelligence) {
239
+ intelligenceGuidance = '\n=== INTELLIGENCE/ML REQUIREMENTS ===\n' +
240
+ `Detected keywords: ${intelligenceReqs.keywords.join(', ')}\n` +
241
+ 'The following intelligence contexts MUST be included in the architecture:\n' +
242
+ intelligenceReqs.suggestedContexts.map(c => `- ${c.name} (${c.type}): ${c.description}\n Commands: ${c.commands.join(', ')}\n NOTE: This is NOT a CRUD context. It must contain ML/analytics logic, not Create/Update/Delete operations.`).join('\n') +
243
+ '\n\nCRITICAL: Intelligence contexts must have commands like TrainModel, RunInference, DetectAnomalies — NOT generic Create*, Update*, Delete*.\n';
244
+ }
245
+ const prompt = `You are a senior enterprise architect creating a complete SPARC architecture document.\n` +
246
+ `\nSPARC is a high-level architecture methodology with 5 sections: Specification, Pseudocode, Architecture, Refinement, Completion.\n` +
247
+ `Each section must be DEEPLY domain-specific — not generic templates.\n` +
248
+ `\n=== PROJECT ===\n${query}\n` +
249
+ `\n=== TECHNOLOGY STACK ===\n${techStack.join(', ') || 'To be determined based on domain requirements'}\n` +
250
+ `\n=== PROJECT CONTEXT ===\n${projectContext.slice(0, 3000)}\n` +
251
+ `\n=== RESEARCH FINDINGS (${dossier.items.length} items from 110 agents) ===\n${dossierItems}\n` +
252
+ (agentContext ? `\n${agentContext}` : '') +
253
+ (intelligenceGuidance ? `\n${intelligenceGuidance}` : '') +
254
+ `\n=== DOMAIN SERVICES ===\n${servicesList}\n` +
255
+ `\nWrite the COMPLETE SPARC document with these 5 sections. Use the section headers EXACTLY as shown:\n` +
256
+ `\n# Specification\n` +
257
+ `Deep domain analysis: goals and motivation, supported features/model classes, specific performance/latency/memory targets with numbers, ` +
258
+ `compatibility and integration requirements with actual system APIs (e.g. real SAP API names, real Snowflake SQL interfaces). ` +
259
+ `Include functional requirements with acceptance criteria, non-functional requirements with specific numbers, ` +
260
+ `stakeholder roles specific to this domain (not generic "Employees"), and system integration details.\n` +
261
+ `\n# Pseudocode\n` +
262
+ `High-level pseudocode showing the ACTUAL algorithms, data structures, and control flow. ` +
263
+ `Include typed struct/class definitions with real field names and types. ` +
264
+ `Show function signatures with typed parameters. Show the REAL business logic — calculations, validations, decision trees, state machines. ` +
265
+ `NOT generic "validate_input → process → persist" templates. ` +
266
+ `Use \`\`\`pseudocode blocks for code.\n` +
267
+ `\n# Architecture\n` +
268
+ `System architecture: component design, data flow diagrams, module interactions, technology stack decisions with rationale. ` +
269
+ `Include crate/package organization, backend implementations, data models and schemas, ` +
270
+ `key architectural patterns (why microservices vs monolith, why event sourcing vs CRUD, etc.), ` +
271
+ `scalability strategy, security architecture, and integration architecture with actual external system APIs.\n` +
272
+ `\n# Refinement\n` +
273
+ `Optimization and hardening: quantization/performance support, format compatibility details, ` +
274
+ `fallback strategies, SIMD/parallel optimizations, memory layout, cache locality, ` +
275
+ `quality vs performance trade-offs with specific tuning parameters, security hardening, ` +
276
+ `edge case handling specific to this domain.\n` +
277
+ `\n# Completion\n` +
278
+ `Integration plan: how components connect end-to-end, testing plan (unit/integration/e2e with domain-specific test cases), ` +
279
+ `benchmark targets with specific numbers, deployment strategy, monitoring and observability, ` +
280
+ `model/system-specific adjustments, post-deployment validation.\n` +
281
+ `\nCRITICAL RULES:\n` +
282
+ `1. Every section must be DEEPLY domain-specific to "${query.slice(0, 100)}"\n` +
283
+ `2. Include REAL API names, REAL data structures, REAL algorithms — not placeholders\n` +
284
+ `3. Pseudocode must have typed structs and real function logic, not "validate→execute→persist"\n` +
285
+ `4. Architecture must describe actual component interactions, not "User → API → DB"\n` +
286
+ `5. Use the research findings and agent analysis above as your primary source of domain knowledge\n` +
287
+ `6. Each section should be 500-2000 words of substantive content\n` +
288
+ `7. This is a HIGH-LEVEL ARCHITECTURE document — not a process description`;
289
+ const result = runner.invoke(prompt, {
290
+ runId: `sparc-complete-${Date.now()}`,
291
+ timeoutMs: 300_000, // 5 minutes for comprehensive document
292
+ });
293
+ const data = result.data;
294
+ const content = typeof data.content === 'string' ? data.content : '';
295
+ // Validate: must have all 5 sections and substantial content
296
+ if (content.length < 3000) {
297
+ process.stderr.write(`[sparc] Complete SPARC too short (${content.length} chars), falling back\n`);
298
+ return null;
299
+ }
300
+ const hasSections = ['# Specification', '# Pseudocode', '# Architecture', '# Refinement', '# Completion']
301
+ .every(h => content.includes(h));
302
+ if (!hasSections) {
303
+ process.stderr.write('[sparc] Complete SPARC missing sections, falling back\n');
304
+ return null;
305
+ }
306
+ process.stderr.write(`[sparc] LLM-generated complete SPARC: ${content.length} chars in ${result.durationMs}ms\n`);
307
+ return content;
308
+ }
309
+ catch (err) {
310
+ process.stderr.write(`[sparc] Complete SPARC generation failed: ${err instanceof Error ? err.message : String(err)}\n`);
311
+ return null;
312
+ }
313
+ }
314
+ /**
315
+ * Split a complete SPARC document into its 5 sections.
316
+ * Looks for "# Specification", "# Pseudocode", "# Architecture", "# Refinement", "# Completion"
317
+ * as top-level headers.
318
+ */
319
+ function splitSPARCSections(fullDoc) {
320
+ const sectionPattern = /^# (Specification|Pseudocode|Architecture|Refinement|Completion)\b/gm;
321
+ const positions = [];
322
+ let match;
323
+ while ((match = sectionPattern.exec(fullDoc)) !== null) {
324
+ const sectionName = match[1];
325
+ if (sectionName) {
326
+ positions.push({ name: sectionName.toLowerCase(), start: match.index });
327
+ }
328
+ }
329
+ const extract = (name) => {
330
+ const idx = positions.findIndex(p => p.name === name);
331
+ if (idx === -1)
332
+ return `# ${name.charAt(0).toUpperCase() + name.slice(1)}\n\n(Section not generated)`;
333
+ const pos = positions[idx];
334
+ const nextPos = idx + 1 < positions.length ? positions[idx + 1] : undefined;
335
+ const end = nextPos ? nextPos.start : fullDoc.length;
336
+ return fullDoc.slice(pos.start, end).trim();
337
+ };
338
+ return {
339
+ specification: extract('specification'),
340
+ pseudocode: extract('pseudocode'),
341
+ architecture: extract('architecture'),
342
+ refinement: extract('refinement'),
343
+ completion: extract('completion'),
344
+ };
345
+ }
34
346
  /** Gather all textual content from Phase 1 artifacts into a single context blob. */
35
347
  function gatherProjectContext(artifacts) {
36
348
  const parts = [];
@@ -106,7 +418,64 @@ function summarizeDossier(dossier) {
106
418
  // Each function writes a SPARC phase document driven entirely by the user's
107
419
  // query and collected artifacts. No hardcoded patterns.
108
420
  // ============================================================================
109
- function writeSpecificationMarkdown(query, projectContext, _dossierSummary, dossier) {
421
+ function writeSpecificationMarkdown(query, projectContext, _dossierSummary, dossier, phase2Dir = '') {
422
+ // ADR-027: Try LLM-generated specification first
423
+ const llmSpec = tryGenerateLLMSpecification(query, projectContext, dossier, phase2Dir);
424
+ if (llmSpec)
425
+ return llmSpec;
426
+ // Fallback: deterministic bullet-point format
427
+ return writeTemplateSpecification(query, projectContext, dossier);
428
+ }
429
+ /**
430
+ * ADR-027: Generate a real specification using Claude.
431
+ * Derives functional requirements, acceptance criteria, stakeholder analysis,
432
+ * and non-functional requirements from the domain — not just bullet-pointing the dossier.
433
+ */
434
+ function tryGenerateLLMSpecification(query, projectContext, dossier, phase2Dir = '') {
435
+ try {
436
+ const runner = createClaudeCodeRunner();
437
+ const dossierItems = dossier.items.slice(0, 30)
438
+ .map(i => `- [${i.category}] ${i.title}: ${i.content.slice(0, 150)}`)
439
+ .join('\n');
440
+ // ADR-027: Include agentics fleet analysis from 110 agents
441
+ const agentContext = phase2Dir ? loadAgenticsFleetContext(phase2Dir) : '';
442
+ const prompt = `You are a senior business analyst writing a functional specification.\n` +
443
+ `\nPROJECT: ${query}\n` +
444
+ `\nPROJECT CONTEXT:\n${projectContext.slice(0, 2000)}\n` +
445
+ `\nRESEARCH FINDINGS:\n${dossierItems}\n` +
446
+ (agentContext ? agentContext + '\n' : '') +
447
+ `\nWrite a complete "Specification" markdown document with these sections:\n` +
448
+ `\n# Specification\n` +
449
+ `## Objective - What this system does and why\n` +
450
+ `## Stakeholders & Actors - Real roles (e.g., Trader, Risk Manager, Compliance Officer, IT Admin) with their needs — NOT generic "Employees"\n` +
451
+ `## Functional Requirements - Numbered, testable requirements with acceptance criteria. Each requirement must be specific enough to write a test for.\n` +
452
+ `## Non-Functional Requirements - Performance targets (specific numbers), security requirements, compliance requirements, scalability targets\n` +
453
+ `## System Integrations - Specific systems to integrate with, actual API surfaces, data flows, authentication methods\n` +
454
+ `## Domain Model Overview - Key entities with their attributes and relationships (typed fields, not generic)\n` +
455
+ `## Risk Factors - Domain-specific risks with severity and mitigation strategies\n` +
456
+ `## Success Criteria - Measurable outcomes that determine project success\n` +
457
+ `## Assumptions & Constraints\n` +
458
+ `## Reflection - Summary of specification coverage\n` +
459
+ `\nCRITICAL: Derive REAL requirements from the domain. Do NOT just reformat the research findings as bullet points. Each requirement must be specific, testable, and include acceptance criteria.`;
460
+ const result = runner.invoke(prompt, {
461
+ runId: `sparc-spec-${Date.now()}`,
462
+ timeoutMs: 180_000,
463
+ });
464
+ const data = result.data;
465
+ const content = typeof data.content === 'string' ? data.content : '';
466
+ if (content.length > 500) {
467
+ process.stderr.write(`[sparc-specification] LLM-generated specification: ${content.length} chars in ${result.durationMs}ms\n`);
468
+ return content;
469
+ }
470
+ return null;
471
+ }
472
+ catch (err) {
473
+ process.stderr.write(`[sparc-specification] LLM spec failed: ${err instanceof Error ? err.message : String(err)}\n`);
474
+ return null;
475
+ }
476
+ }
477
+ /** Fallback: deterministic specification from dossier items. */
478
+ function writeTemplateSpecification(query, projectContext, dossier) {
110
479
  const requirements = dossier.items.filter(i => i.category === 'requirement' || i.category === 'recommendation');
111
480
  const constraints = dossier.items.filter(i => i.category === 'constraint');
112
481
  const risks = dossier.items.filter(i => i.category === 'risk');
@@ -176,15 +545,99 @@ function writeSpecificationMarkdown(query, projectContext, _dossierSummary, doss
176
545
  lines.push('');
177
546
  return lines.join('\n');
178
547
  }
179
- function writePseudocodeMarkdown(query, _context, dossier, artifacts) {
548
+ function writePseudocodeMarkdown(query, _context, dossier, artifacts, phase2Dir = '') {
549
+ // Derive modules from DOMAIN services (not roadmap phases)
550
+ const domainServices = extractDomainServices(query, artifacts, dossier);
551
+ // ADR-027 Change 1: Try LLM-generated domain-specific pseudocode first
552
+ const llmResult = tryGenerateLLMPseudocode(query, domainServices, dossier, phase2Dir);
553
+ if (llmResult)
554
+ return llmResult;
555
+ // Fallback: deterministic template (original behavior pre-ADR-027)
556
+ return writeTemplatePseudocode(query, domainServices);
557
+ }
558
+ /**
559
+ * ADR-027 Change 1: Generate domain-specific pseudocode using Claude Code LLM.
560
+ *
561
+ * Instead of the generic validate→execute→persist template, Claude generates
562
+ * pseudocode with domain-specific typed data structures, real algorithms,
563
+ * business rules, and integration points.
564
+ *
565
+ * @returns Pseudocode markdown string, or null if LLM is unavailable/fails.
566
+ */
567
+ function tryGenerateLLMPseudocode(query, services, dossier, phase2Dir = '') {
568
+ try {
569
+ const runner = createClaudeCodeRunner();
570
+ // Build dossier context (limit to avoid prompt overflow)
571
+ const relevantItems = dossier.items
572
+ .filter(i => ['requirement', 'recommendation', 'decision-rationale', 'constraint'].includes(i.category))
573
+ .slice(0, 25);
574
+ const dossierContext = relevantItems
575
+ .map(i => `- [${i.category}] ${i.title}: ${i.content.slice(0, 200)}`)
576
+ .join('\n');
577
+ // ADR-027: Include agentics fleet analysis from 110 agents
578
+ const agentContext = phase2Dir ? loadAgenticsFleetContext(phase2Dir) : '';
579
+ const servicesList = services.map(svc => `### ${svc.name}\n- Responsibility: ${svc.responsibility}\n- Capabilities: ${svc.capabilities.join(', ')}\n- Related systems: ${svc.relatedSystems.join(', ') || 'none'}`).join('\n\n');
580
+ const prompt = `You are a senior domain engineer writing detailed pseudocode for an enterprise system.\n` +
581
+ `\nDOMAIN: ${query}\n` +
582
+ `\nRESEARCH FINDINGS:\n${dossierContext}\n` +
583
+ (agentContext ? agentContext + '\n' : '') +
584
+ `\nSERVICES TO IMPLEMENT:\n${servicesList}\n` +
585
+ `\nWrite a complete pseudocode document in markdown. For EACH service above, write:\n` +
586
+ `1. Domain-specific data structures with typed fields (string, number, boolean, Date, enums)\n` +
587
+ `2. Functions with typed parameters implementing REAL domain algorithms\n` +
588
+ `3. Domain-specific error handling and validation\n` +
589
+ `4. Business rules, calculations, and decision logic specific to this domain\n` +
590
+ `\nCRITICAL: Do NOT write generic templates like "validate_preconditions(input) -> aggregate.execute(input) -> persist(aggregate)". Every function must contain domain-specific logic with real typed parameters.\n` +
591
+ `\nFormat: Start with "# Pseudocode" then "## Objective" describing the domain, then a "## [Service Name] Service" section per service with \`\`\`pseudocode blocks containing typed structs and functions. End with "## Reflection" summarizing coverage.\n` +
592
+ `\nExample of GOOD pseudocode for a maintenance domain (write for YOUR domain, not this):\n` +
593
+ `\`\`\`pseudocode\n` +
594
+ `struct MaintenanceOrder:\n` +
595
+ ` order_id: string\n` +
596
+ ` aircraft_registration: string\n` +
597
+ ` task_type: enum(scheduled|unscheduled|deferred)\n` +
598
+ ` priority: enum(AOG|urgent|routine)\n` +
599
+ ` estimated_labor_hours: number\n` +
600
+ ` parts_required: PartRequirement[]\n` +
601
+ `\n` +
602
+ `function create_maintenance_order(reg: string, task: TaskType, findings: InspectionFinding[]):\n` +
603
+ ` aircraft = lookup_aircraft(reg)\n` +
604
+ ` if aircraft.status == "retired": return AircraftRetiredError(reg)\n` +
605
+ ` priority = assess_priority(findings, aircraft.next_flight_time)\n` +
606
+ ` parts = calculate_required_parts(findings, aircraft.type_certificate)\n` +
607
+ ` labor = estimate_labor_hours(findings, aircraft.maintenance_history)\n` +
608
+ ` order = MaintenanceOrder(generate_id(), reg, task, priority, labor, parts)\n` +
609
+ ` if priority == AOG: notify_ops_control(aircraft, order)\n` +
610
+ ` persist(order)\n` +
611
+ ` emit_event("maintenance.order.created", order)\n` +
612
+ ` return order\n` +
613
+ `\`\`\``;
614
+ const result = runner.invoke(prompt, {
615
+ runId: `sparc-pseudo-${Date.now()}`,
616
+ timeoutMs: 180_000, // 3 minutes for comprehensive pseudocode
617
+ });
618
+ // Extract content from unwrapped Claude Code envelope
619
+ const data = result.data;
620
+ const content = typeof data.content === 'string' ? data.content : '';
621
+ if (content.length > 300) {
622
+ process.stderr.write(`[sparc-specification] LLM-generated pseudocode: ${content.length} chars in ${result.durationMs}ms\n`);
623
+ return content;
624
+ }
625
+ process.stderr.write('[sparc-specification] LLM returned insufficient pseudocode, using template fallback\n');
626
+ return null;
627
+ }
628
+ catch (err) {
629
+ process.stderr.write(`[sparc-specification] LLM pseudocode generation failed, using template fallback: ${err instanceof Error ? err.message : String(err)}\n`);
630
+ return null;
631
+ }
632
+ }
633
+ /** Fallback: deterministic pseudocode template (pre-ADR-027 behavior). */
634
+ function writeTemplatePseudocode(query, domainServices) {
180
635
  const lines = [];
181
636
  lines.push('# Pseudocode');
182
637
  lines.push('');
183
638
  lines.push('## Objective');
184
639
  lines.push(`Create a pseudocode outline for each domain service: **${query}**`);
185
640
  lines.push('');
186
- // Derive modules from DOMAIN services (not roadmap phases)
187
- const domainServices = extractDomainServices(query, artifacts, dossier);
188
641
  for (const svc of domainServices) {
189
642
  const title = svc.name.replace(/-/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
190
643
  lines.push(`## ${title} Service`);
@@ -637,6 +1090,24 @@ function extractDomainServices(query, artifacts, dossier) {
637
1090
  }
638
1091
  }
639
1092
  }
1093
+ // 9. ADR-029 Fix 4: Add intelligence/ML services when query requires them
1094
+ const intelligenceReqs = detectIntelligenceRequirements(query);
1095
+ if (intelligenceReqs.hasIntelligence) {
1096
+ for (const ctx of intelligenceReqs.suggestedContexts) {
1097
+ // Only add if not already covered by an existing service
1098
+ const alreadyExists = Array.from(services.values()).some(s => s.name.toLowerCase().includes(ctx.name.split('-')[0]) ||
1099
+ ctx.name.includes(s.name.toLowerCase()));
1100
+ if (!alreadyExists) {
1101
+ services.set(ctx.name, {
1102
+ name: ctx.name,
1103
+ responsibility: ctx.description,
1104
+ capabilities: ctx.commands,
1105
+ relatedSystems: [],
1106
+ dossierItemRefs: [],
1107
+ });
1108
+ }
1109
+ }
1110
+ }
640
1111
  return Array.from(services.values()).slice(0, 12);
641
1112
  }
642
1113
  // ============================================================================
@@ -832,12 +1303,31 @@ export async function generateSPARCSpecification(context) {
832
1303
  // Gather project context from all artifacts
833
1304
  const projectContext = gatherProjectContext(context.phase1Artifacts);
834
1305
  const dossierSummary = summarizeDossier(dossier);
835
- // Build 5 SPARC markdown documents
836
- const specMd = writeSpecificationMarkdown(query, projectContext, dossierSummary, dossier);
837
- const pseudoMd = writePseudocodeMarkdown(query, projectContext, dossier, context.phase1Artifacts);
838
- const archMd = writeArchitectureMarkdown(query, projectContext, dossier, context.phase1Artifacts);
839
- const refineMd = writeRefinementMarkdown(query, projectContext, dossier);
840
- const completionMd = writeCompletionMarkdown(query, projectContext, dossier, context.phase1Artifacts);
1306
+ // ADR-027: Try single comprehensive LLM SPARC generation first
1307
+ // SPARC is ONE cohesive architecture document, not 5 disconnected fragments
1308
+ const llmSparc = tryGenerateCompleteSPARC(query, projectContext, dossier, context.phase1Artifacts, context.phase2Dir);
1309
+ let specMd;
1310
+ let pseudoMd;
1311
+ let archMd;
1312
+ let refineMd;
1313
+ let completionMd;
1314
+ if (llmSparc) {
1315
+ // LLM generated the full SPARC — split into sections
1316
+ const sections = splitSPARCSections(llmSparc);
1317
+ specMd = sections.specification;
1318
+ pseudoMd = sections.pseudocode;
1319
+ archMd = sections.architecture;
1320
+ refineMd = sections.refinement;
1321
+ completionMd = sections.completion;
1322
+ }
1323
+ else {
1324
+ // Fallback: individual LLM calls per section, then template fallback
1325
+ specMd = writeSpecificationMarkdown(query, projectContext, dossierSummary, dossier, context.phase2Dir);
1326
+ pseudoMd = writePseudocodeMarkdown(query, projectContext, dossier, context.phase1Artifacts, context.phase2Dir);
1327
+ archMd = writeArchitectureMarkdown(query, projectContext, dossier, context.phase1Artifacts);
1328
+ refineMd = writeRefinementMarkdown(query, projectContext, dossier);
1329
+ completionMd = writeCompletionMarkdown(query, projectContext, dossier, context.phase1Artifacts);
1330
+ }
841
1331
  // Build JSON compat shim
842
1332
  const sparc = buildCompatJSON(dossier, context.phase1Artifacts);
843
1333
  // Write files