@llm-dev-ops/agentics-cli 1.4.59 → 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 +167 -0
  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
@@ -16,6 +16,7 @@
16
16
  import { execSync, spawnSync } from 'node:child_process';
17
17
  import * as fs from 'node:fs';
18
18
  import * as path from 'node:path';
19
+ import { loadTechStack, formatTechStackForPrompt } from './phase2/phases/tech-stack-detector.js';
19
20
  // ============================================================================
20
21
  // Constants
21
22
  // ============================================================================
@@ -23,6 +24,50 @@ const CHECK_TIMEOUT = 30_000;
23
24
  const DEFAULT_SWARM_TIMEOUT = 600_000;
24
25
  const DEFAULT_MAX_AGENTS = 8;
25
26
  const MAX_ARTIFACT_CONTENT_BYTES = 32_000;
27
+ /**
28
+ * Naming convention rules embedded in implementation prompts to prevent
29
+ * double-prefix bugs like "IIbudgetManagementPort".
30
+ */
31
+ const NAMING_CONVENTION_RULES = [
32
+ 'Port interfaces: {ContextName}Port (e.g., BudgetManagementPort) — NO "I" prefix',
33
+ 'Adapters: {Implementation}{ContextName}Adapter (e.g., PostgresBudgetManagementAdapter)',
34
+ 'Never use double-prefix like "II*" or "IInterface*"',
35
+ 'Domain types: PascalCase with no prefix (e.g., BudgetOrder, not IBudgetOrder)',
36
+ ].join('\n');
37
+ // ============================================================================
38
+ // Interface Naming Sanitization (ADR-029 Fix 5)
39
+ // ============================================================================
40
+ /**
41
+ * Sanitize generated interface names to prevent double-prefix bugs.
42
+ *
43
+ * Convention:
44
+ * Port interfaces: {ContextName}Port (no "I" prefix)
45
+ * Adapters: {Implementation}{ContextName}Adapter
46
+ * Never double-prefix (II*, IInterface*)
47
+ */
48
+ export function sanitizeInterfaceName(name, kind) {
49
+ // Strip any leading "I" prefix(es) — handles II, III, IInterface, etc.
50
+ let stripped = name;
51
+ while (/^I[A-Z]/.test(stripped)) {
52
+ stripped = stripped.slice(1);
53
+ }
54
+ // Apply convention based on kind
55
+ switch (kind) {
56
+ case 'port':
57
+ // Ensure it ends with "Port" and has no "I" prefix
58
+ if (!stripped.endsWith('Port'))
59
+ stripped = `${stripped}Port`;
60
+ return stripped;
61
+ case 'adapter':
62
+ // Ensure it ends with "Adapter" and has no "I" prefix
63
+ if (!stripped.endsWith('Adapter'))
64
+ stripped = `${stripped}Adapter`;
65
+ return stripped;
66
+ case 'interface':
67
+ // Just strip double-prefixes, no convention enforcement
68
+ return stripped;
69
+ }
70
+ }
26
71
  // ============================================================================
27
72
  // Binary Resolution (shared — no duplication)
28
73
  // ============================================================================
@@ -91,6 +136,13 @@ export function checkRufloAvailable() {
91
136
  function rufloExec(binary, args, cwd, timeout = CHECK_TIMEOUT) {
92
137
  const result = spawnSync(binary, args, {
93
138
  cwd, timeout, encoding: 'utf-8', stdio: 'pipe',
139
+ env: {
140
+ ...process.env,
141
+ // Tell ruflo to use Claude Code's logged-in session for LLM work
142
+ // instead of requiring a separate ANTHROPIC_API_KEY
143
+ CLAUDECODE: '1',
144
+ CLAUDE_FLOW_PROVIDER: 'claude-code',
145
+ },
94
146
  });
95
147
  if (result.status !== 0) {
96
148
  const stderr = (result.stderr ?? '').trim();
@@ -238,113 +290,499 @@ function extractSPARCSummary(sparcPath) {
238
290
  return { services: [], integrations: [], pseudocodeModules: [] };
239
291
  }
240
292
  }
293
+ // ============================================================================
294
+ // Dependency Graph & Wave Ordering (ADR-028 Changes 2 & 4)
295
+ // ============================================================================
241
296
  /**
242
- * Build a structured implementation prompt from pipeline artifacts.
297
+ * Analyze the DDD context map to determine bounded context dependencies.
298
+ * Returns a map of context name -> list of context names it depends on.
243
299
  *
244
- * This prompt is fed to Ruflo swarms AND the 110 agentics.dev agent fleet.
245
- * It directs them to implement the ADRs + DDDs with high-level SPARC guidance
246
- * using London School TDD (outside-in, mock collaborators at seam boundaries).
300
+ * Dependency direction: if A is upstream of B (A -> B), then B depends on A.
301
+ * Relationships like "customer-supplier", "conformist", and "anticorruption-layer"
302
+ * mean the downstream context depends on the upstream context.
303
+ * "shared-kernel" means mutual dependency — both go in the same wave.
304
+ */
305
+ export function buildContextDependencyGraph(contextMap, contextNames) {
306
+ const deps = new Map();
307
+ // Initialize all contexts with empty dependency lists
308
+ for (const name of contextNames) {
309
+ deps.set(name, []);
310
+ }
311
+ for (const rel of contextMap) {
312
+ const relType = rel.relationship.toLowerCase();
313
+ if (relType.includes('shared-kernel') || relType.includes('shared kernel')) {
314
+ // Shared kernel: mutual dependency — neither depends on the other
315
+ // They will naturally land in the same wave since neither blocks the other
316
+ continue;
317
+ }
318
+ // For all directional relationships, the downstream (to) depends on upstream (from)
319
+ const downstream = rel.to;
320
+ const upstream = rel.from;
321
+ if (deps.has(downstream) && contextNames.includes(upstream)) {
322
+ const existing = deps.get(downstream);
323
+ if (!existing.includes(upstream)) {
324
+ existing.push(upstream);
325
+ }
326
+ }
327
+ }
328
+ return deps;
329
+ }
330
+ /**
331
+ * Topologically sort bounded contexts by dependency order.
332
+ * Contexts with no dependencies come first (foundations), then contexts
333
+ * that depend only on already-sorted contexts, and so on.
247
334
  *
248
- * The prompt is written to disk as `implementation-prompt.md` and used as the
249
- * swarm objective across all phases.
335
+ * Returns contexts grouped by depth level (0 = no deps, 1 = depends on level 0, etc.).
336
+ * Handles cycles by placing cyclic contexts at the deepest level encountered.
250
337
  */
251
- export function buildImplementationPrompt(artifacts, scenarioQuery, language) {
252
- // Resolve artifact paths
338
+ export function topologicalSort(deps) {
339
+ const levels = [];
340
+ const assigned = new Set();
341
+ const contextNames = Array.from(deps.keys());
342
+ // Iteratively find contexts whose dependencies are all assigned
343
+ let maxIterations = contextNames.length + 1;
344
+ while (assigned.size < contextNames.length && maxIterations > 0) {
345
+ maxIterations--;
346
+ const currentLevel = [];
347
+ for (const name of contextNames) {
348
+ if (assigned.has(name))
349
+ continue;
350
+ const contextDeps = deps.get(name) ?? [];
351
+ const allDepsAssigned = contextDeps.every(d => assigned.has(d));
352
+ if (allDepsAssigned) {
353
+ currentLevel.push(name);
354
+ }
355
+ }
356
+ if (currentLevel.length === 0) {
357
+ // Remaining contexts have circular dependencies — assign them all now
358
+ const remaining = contextNames.filter(n => !assigned.has(n));
359
+ if (remaining.length > 0) {
360
+ levels.push(remaining);
361
+ for (const name of remaining)
362
+ assigned.add(name);
363
+ }
364
+ break;
365
+ }
366
+ levels.push(currentLevel);
367
+ for (const name of currentLevel)
368
+ assigned.add(name);
369
+ }
370
+ return levels;
371
+ }
372
+ /**
373
+ * Group topologically sorted contexts into implementation waves.
374
+ *
375
+ * - Wave 1 (Foundation): Database schemas, shared infrastructure, contexts with zero dependencies
376
+ * - Wave 2 (Core): Contexts that depend only on Wave 1 contexts
377
+ * - Wave 3 (Dependent): Contexts that depend on Wave 2 contexts
378
+ * - Wave 4 (Cross-cutting): Frontend, tests, deployment — built AFTER domain code exists
379
+ *
380
+ * If there are more than 3 dependency levels, intermediate levels are merged
381
+ * into Waves 2 and 3 proportionally.
382
+ */
383
+ export function groupIntoWaves(sortedLevels, _language, scenarioQuery, artifacts) {
384
+ const artifactCtx = buildArtifactContext(artifacts);
385
+ // Map dependency levels to waves 1-3
386
+ const domainWaves = [];
387
+ if (sortedLevels.length === 0) {
388
+ // No DDD contexts — single foundation wave
389
+ domainWaves.push({
390
+ wave: 1,
391
+ label: 'Foundation',
392
+ contexts: [],
393
+ prompt: '',
394
+ tasks: [],
395
+ dependsOn: [],
396
+ });
397
+ }
398
+ else if (sortedLevels.length === 1) {
399
+ // All contexts are independent — put them all in Wave 2 (core)
400
+ domainWaves.push({
401
+ wave: 1,
402
+ label: 'Foundation',
403
+ contexts: [],
404
+ prompt: '',
405
+ tasks: [{
406
+ label: 'Database & Shared Infrastructure',
407
+ description: `Generate database schemas, shared types, and infrastructure adapters for: ${scenarioQuery.slice(0, 200)}. ` +
408
+ `Include: CREATE TABLE per aggregate root, connection management, shared value objects, ` +
409
+ `base repository interfaces, and ERP client stubs. Source: ${artifactCtx}`,
410
+ targetDir: 'src/shared',
411
+ wave: 1,
412
+ }],
413
+ dependsOn: [],
414
+ });
415
+ domainWaves.push({
416
+ wave: 2,
417
+ label: 'Core Bounded Contexts',
418
+ contexts: sortedLevels[0] ?? [],
419
+ prompt: '',
420
+ tasks: [],
421
+ dependsOn: [1],
422
+ });
423
+ }
424
+ else {
425
+ // Multiple dependency levels
426
+ // Level 0 -> Wave 1 (Foundation)
427
+ domainWaves.push({
428
+ wave: 1,
429
+ label: 'Foundation',
430
+ contexts: sortedLevels[0] ?? [],
431
+ prompt: '',
432
+ tasks: [{
433
+ label: 'Database & Shared Infrastructure',
434
+ description: `Generate database schemas, shared types, and infrastructure adapters for: ${scenarioQuery.slice(0, 200)}. ` +
435
+ `Include: CREATE TABLE per aggregate root, connection management, shared value objects, ` +
436
+ `base repository interfaces, and ERP client stubs. Source: ${artifactCtx}`,
437
+ targetDir: 'src/shared',
438
+ wave: 1,
439
+ }],
440
+ dependsOn: [],
441
+ });
442
+ // Level 1 -> Wave 2 (Core)
443
+ domainWaves.push({
444
+ wave: 2,
445
+ label: 'Core Bounded Contexts',
446
+ contexts: sortedLevels[1] ?? [],
447
+ prompt: '',
448
+ tasks: [],
449
+ dependsOn: [1],
450
+ });
451
+ // Levels 2+ -> Wave 3 (Dependent)
452
+ const dependentContexts = sortedLevels.slice(2).flat();
453
+ if (dependentContexts.length > 0) {
454
+ domainWaves.push({
455
+ wave: 3,
456
+ label: 'Dependent Bounded Contexts',
457
+ contexts: dependentContexts,
458
+ prompt: '',
459
+ tasks: [],
460
+ dependsOn: [1, 2],
461
+ });
462
+ }
463
+ }
464
+ // Collect all domain context task labels for cross-cutting dependency tracking
465
+ const allDomainContextNames = sortedLevels.flat();
466
+ const domainTaskLabels = allDomainContextNames.map(name => `Context: ${name}`);
467
+ const testDependsOn = ['Database & Shared Infrastructure', ...domainTaskLabels];
468
+ // Wave 4: Cross-cutting (always last)
469
+ domainWaves.push({
470
+ wave: 4,
471
+ label: 'Cross-Cutting Concerns',
472
+ contexts: [],
473
+ prompt: '',
474
+ tasks: [
475
+ {
476
+ label: 'Frontend Application',
477
+ description: `Build a production-ready frontend application for: ${scenarioQuery.slice(0, 300)}. ` +
478
+ `Build a complete dashboard with per-bounded-context pages, data tables for queries, ` +
479
+ `command forms, typed API client, authentication flow, error boundaries, loading states, ` +
480
+ `and responsive layout. Source: ${artifactCtx}`,
481
+ targetDir: 'ui',
482
+ wave: 4,
483
+ dependsOn: ['Database & Shared Infrastructure'],
484
+ },
485
+ {
486
+ label: 'Infrastructure & Integration',
487
+ description: `Build production infrastructure and integration layer for: ${scenarioQuery.slice(0, 300)}. ` +
488
+ `Include: HTTP middleware (auth, CORS, logging, rate limiting, error handling), ` +
489
+ `ERP client adapters with real API endpoints (not stubs), database connection management, ` +
490
+ `integration modules for detected external systems, health checks, and metrics endpoints. ` +
491
+ `Source: ${artifactCtx}`,
492
+ targetDir: 'src/infra',
493
+ wave: 4,
494
+ dependsOn: ['Database & Shared Infrastructure'],
495
+ },
496
+ {
497
+ label: 'Test Suite',
498
+ description: `Build a comprehensive test suite for: ${scenarioQuery.slice(0, 300)}. ` +
499
+ `IMPORTANT: This task runs AFTER domain code is generated. ` +
500
+ `Import modules from the ACTUAL generated domain code — do NOT guess import paths. ` +
501
+ `Read the generated source files in src/ to discover what modules, classes, and functions exist, ` +
502
+ `then write tests that import and test those REAL exports. ` +
503
+ `Write London School TDD tests: mock collaborator interfaces at aggregate boundaries, ` +
504
+ `test command handlers in isolation, test query handlers with in-memory adapters. ` +
505
+ `Every test must compile and import modules that actually exist. ` +
506
+ `NAMING CONVENTION: Port interfaces are named {ContextName}Port (no "I" prefix). ` +
507
+ `Adapters are {Implementation}{ContextName}Adapter. Never use "II*" double-prefix. ` +
508
+ `Source: ${artifactCtx}`,
509
+ targetDir: 'tests',
510
+ wave: 4,
511
+ dependsOn: testDependsOn,
512
+ },
513
+ {
514
+ label: 'Deployment Configuration',
515
+ description: `Generate production deployment configuration for: ${scenarioQuery.slice(0, 300)}. ` +
516
+ `Include: Dockerfile (multi-stage, optimized), Docker Compose for local dev, ` +
517
+ `cloud deployment configs (Cloud Run / ECS / K8s manifests), CI/CD pipeline, ` +
518
+ `environment variable templates, and IaC (Terraform/YAML) for detected cloud provider. ` +
519
+ `Source: ${artifactCtx}`,
520
+ targetDir: 'deploy',
521
+ wave: 4,
522
+ dependsOn: ['Database & Shared Infrastructure'],
523
+ },
524
+ ],
525
+ dependsOn: [1, 2, 3],
526
+ });
527
+ return domainWaves;
528
+ }
529
+ /**
530
+ * Build a focused, 20-40 line implementation prompt for a single wave.
531
+ * Each prompt tells the LLM exactly:
532
+ * - What to implement (specific contexts, specific ADRs)
533
+ * - Why this order (dependency rationale)
534
+ * - What's already built (prior wave output)
535
+ * - Concrete fields and types (from DDD aggregates)
536
+ */
537
+ export function buildWavePrompt(wave, ddd, adrs, tdd, language, priorWaveLabels) {
538
+ const lines = [];
539
+ lines.push(`# Wave ${wave.wave}: ${wave.label}`);
540
+ lines.push('');
541
+ // Why this order
542
+ if (wave.dependsOn.length > 0) {
543
+ lines.push(`## Prerequisites`);
544
+ lines.push(`This wave depends on: ${priorWaveLabels.join(', ')}. Those modules are already built and available for import.`);
545
+ lines.push('');
546
+ }
547
+ else {
548
+ lines.push(`## Foundation Wave`);
549
+ lines.push(`This wave has no dependencies. Build foundational types, schemas, and shared infrastructure first.`);
550
+ lines.push('');
551
+ }
552
+ // What to implement — only the contexts in THIS wave
553
+ if (wave.contexts.length > 0) {
554
+ lines.push(`## Bounded Contexts to Implement`);
555
+ lines.push('');
556
+ for (const ctxName of wave.contexts) {
557
+ const ctxData = ddd.contexts.find(c => c.name === ctxName);
558
+ if (ctxData) {
559
+ lines.push(`### ${ctxData.name}`);
560
+ if (ctxData.aggregates.length > 0)
561
+ lines.push(`- Aggregates: ${ctxData.aggregates.join(', ')}`);
562
+ if (ctxData.commands.length > 0)
563
+ lines.push(`- Commands: ${ctxData.commands.join(', ')}`);
564
+ if (ctxData.queries.length > 0)
565
+ lines.push(`- Queries: ${ctxData.queries.join(', ')}`);
566
+ if (ctxData.events.length > 0)
567
+ lines.push(`- Domain Events: ${ctxData.events.join(', ')}`);
568
+ lines.push('');
569
+ }
570
+ }
571
+ }
572
+ // Relevant ADRs only — filter to ones mentioning this wave's contexts
573
+ const relevantAdrs = wave.contexts.length > 0
574
+ ? adrs.filter(a => {
575
+ const text = `${a.title} ${a.decision}`.toLowerCase();
576
+ return wave.contexts.some(c => text.includes(c.toLowerCase())) || text.includes('all') || text.includes('general');
577
+ })
578
+ : adrs;
579
+ if (relevantAdrs.length > 0) {
580
+ lines.push(`## Applicable ADRs`);
581
+ for (const adr of relevantAdrs.slice(0, 8)) {
582
+ lines.push(`- **${adr.id}**: ${adr.title}${adr.decision ? ' -- ' + adr.decision.slice(0, 120) : ''}`);
583
+ }
584
+ lines.push('');
585
+ }
586
+ // Relevant test suites only
587
+ const relevantSuites = wave.contexts.length > 0
588
+ ? tdd.suites.filter(s => {
589
+ const suiteName = s.name.toLowerCase();
590
+ return wave.contexts.some(c => suiteName.includes(c.toLowerCase()));
591
+ })
592
+ : tdd.suites;
593
+ if (relevantSuites.length > 0) {
594
+ lines.push(`## Test Suites for This Wave`);
595
+ for (const suite of relevantSuites) {
596
+ lines.push(`- ${suite.name}: ${suite.testCount} tests (${suite.strategy})`);
597
+ }
598
+ lines.push('');
599
+ }
600
+ // Implementation mandate
601
+ lines.push(`## Rules`);
602
+ lines.push(`- Language: ${language}`);
603
+ lines.push(`- Write REAL business logic with concrete types -- no Record<string, unknown>, no TODO stubs`);
604
+ lines.push(`- London School TDD: test first, mock collaborators at seam boundaries`);
605
+ lines.push(`- Ports/adapters: domain logic has ZERO infrastructure imports`);
606
+ lines.push('');
607
+ lines.push(`## Naming Convention`);
608
+ lines.push(NAMING_CONVENTION_RULES);
609
+ lines.push('');
610
+ return lines.join('\n');
611
+ }
612
+ /**
613
+ * ADR-029: Try to load tech-stack.json from a run directory inferred from
614
+ * artifact paths, and return formatted prompt context if found.
615
+ */
616
+ function loadTechStackContext(artifacts) {
617
+ // Infer run directory from any artifact path (go up from phase2/adrs/)
618
+ const anyPath = Object.values(artifacts).find(p => p && fs.existsSync(p));
619
+ if (!anyPath)
620
+ return '';
621
+ // Try several candidate directories
622
+ const candidates = [
623
+ path.resolve(path.dirname(anyPath), '..'), // parent of artifact
624
+ path.resolve(path.dirname(anyPath), '..', '..'), // grandparent
625
+ path.resolve(path.dirname(anyPath)), // same dir
626
+ ];
627
+ for (const dir of candidates) {
628
+ const ts = loadTechStack(dir);
629
+ if (ts) {
630
+ return '\n' + formatTechStackForPrompt(ts) + '\n';
631
+ }
632
+ }
633
+ return '';
634
+ }
635
+ /**
636
+ * Build iterative, dependency-ordered implementation prompts.
637
+ *
638
+ * Instead of one monolithic prompt dumping ALL contexts, ADRs, and TDD suites,
639
+ * this function produces a sequence of focused wave prompts. Each wave prompt
640
+ * references only the contexts, ADRs, and tests relevant to that wave, and
641
+ * explicitly states what prior waves have already built.
642
+ *
643
+ * Exported for direct use by Phase 5 wave-ordered execution.
644
+ */
645
+ export function buildIterativeImplementationPrompts(artifacts, scenarioQuery, language) {
253
646
  const dddPath = artifacts['DDD'] ?? artifacts['ddd'] ?? '';
254
647
  const adrPath = artifacts['ADRs'] ?? artifacts['adrs'] ?? artifacts['adr-index'] ?? '';
255
648
  const tddPath = artifacts['TDD'] ?? artifacts['tdd'] ?? '';
256
- const sparcPath = artifacts['SPARC'] ?? artifacts['sparc'] ?? artifacts['sparc-combined'] ?? '';
257
- // Extract structured data from artifacts
258
649
  const ddd = extractDDDSummary(dddPath);
259
650
  const adrs = extractADRSummary(adrPath);
260
651
  const tdd = extractTDDSummary(tddPath);
652
+ // If no DDD model, return a single wave with the full prompt (backward compat)
653
+ if (ddd.contexts.length === 0) {
654
+ const fallbackPrompt = buildLegacyImplementationPrompt(artifacts, scenarioQuery, language);
655
+ return [{
656
+ wave: 1,
657
+ label: 'Full Implementation (no DDD model)',
658
+ contexts: [],
659
+ prompt: fallbackPrompt,
660
+ tasks: [],
661
+ dependsOn: [],
662
+ }];
663
+ }
664
+ // Build dependency graph from context map
665
+ const contextNames = ddd.contexts.map(c => c.name);
666
+ const depGraph = buildContextDependencyGraph(ddd.contextMap, contextNames);
667
+ // Topological sort
668
+ const sortedLevels = topologicalSort(depGraph);
669
+ // Group into waves
670
+ const waves = groupIntoWaves(sortedLevels, language, scenarioQuery, artifacts);
671
+ // Generate focused prompts per wave
672
+ const priorLabels = [];
673
+ const promptedWaves = [];
674
+ for (const wave of waves) {
675
+ const prompt = buildWavePrompt(wave, ddd, adrs, tdd, language, [...priorLabels]);
676
+ // Build per-context tasks for this wave's bounded contexts
677
+ const dddPath2 = artifacts['DDD'] ?? artifacts['ddd'] ?? '';
678
+ const contexts = readBoundedContextNames(dddPath2);
679
+ const artifactCtx = buildArtifactContext(artifacts);
680
+ const inferredRunDir = dddPath2 ? path.resolve(path.dirname(dddPath2), '..', '..') : '';
681
+ const contextTasks = [];
682
+ for (const ctxName of wave.contexts) {
683
+ const ctx = contexts.find(c => c.name === ctxName);
684
+ if (!ctx)
685
+ continue;
686
+ const ctxSlug = ctx.name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
687
+ const promptFileName = `${ctxSlug}-implementation.md`;
688
+ // Try to read per-context prompt file
689
+ let promptContent = '';
690
+ const promptPaths = [
691
+ inferredRunDir ? path.join(inferredRunDir, 'prompts', promptFileName) : '',
692
+ inferredRunDir ? path.join(inferredRunDir, 'phase3', 'project', 'prompts', promptFileName) : '',
693
+ ].filter(Boolean);
694
+ for (const pp of promptPaths) {
695
+ try {
696
+ if (fs.existsSync(pp)) {
697
+ promptContent = fs.readFileSync(pp, 'utf-8');
698
+ break;
699
+ }
700
+ }
701
+ catch { /* continue */ }
702
+ }
703
+ const promptSection = promptContent
704
+ ? `\n\n--- IMPLEMENTATION PROMPT ---\n${promptContent.slice(0, 4000)}\n--- END PROMPT ---\n`
705
+ : `Aggregates: ${ctx.aggregates.join(', ')}. Commands: ${ctx.commands.join(', ')}. Queries: ${ctx.queries.join(', ')}. `;
706
+ // Determine which prior context labels this task depends on
707
+ const depGraph2 = buildContextDependencyGraph(extractDDDSummary(dddPath2).contextMap, contexts.map(c => c.name));
708
+ const ctxDeps = depGraph2.get(ctx.name) ?? [];
709
+ const taskDependsOn = ctxDeps.map(d => `Context: ${d}`);
710
+ if (wave.wave > 1) {
711
+ taskDependsOn.push('Database & Shared Infrastructure');
712
+ }
713
+ contextTasks.push({
714
+ label: `Context: ${ctx.name}`,
715
+ description: `Implement bounded context "${ctx.name}" in ${language} for: ${scenarioQuery.slice(0, 200)}. ` +
716
+ `Write REAL business logic -- not stubs. ` +
717
+ `${promptSection}` +
718
+ `Source: ${artifactCtx}`,
719
+ targetDir: `src/${ctxSlug}`,
720
+ wave: wave.wave,
721
+ dependsOn: taskDependsOn.length > 0 ? taskDependsOn : undefined,
722
+ });
723
+ }
724
+ // Merge context tasks with any pre-existing wave tasks (e.g., infrastructure, cross-cutting)
725
+ const allTasks = [...wave.tasks, ...contextTasks];
726
+ promptedWaves.push({
727
+ ...wave,
728
+ prompt,
729
+ tasks: allTasks,
730
+ });
731
+ priorLabels.push(`Wave ${wave.wave} (${wave.label})`);
732
+ }
733
+ return promptedWaves;
734
+ }
735
+ /**
736
+ * Legacy implementation prompt builder — used as fallback when no DDD model exists.
737
+ * This preserves the original monolithic prompt for backward compatibility.
738
+ */
739
+ function buildLegacyImplementationPrompt(artifacts, scenarioQuery, language) {
740
+ const adrPath = artifacts['ADRs'] ?? artifacts['adrs'] ?? artifacts['adr-index'] ?? '';
741
+ const tddPath = artifacts['TDD'] ?? artifacts['tdd'] ?? '';
742
+ const sparcPath = artifacts['SPARC'] ?? artifacts['sparc'] ?? artifacts['sparc-combined'] ?? '';
743
+ // DDD summary intentionally omitted in legacy fallback (no DDD model available)
744
+ const adrs = extractADRSummary(adrPath);
745
+ const tdd = extractTDDSummary(tddPath);
261
746
  const sparc = extractSPARCSummary(sparcPath);
262
747
  const lines = [];
263
- // Header
264
748
  lines.push(`# Implementation Directive`);
265
749
  lines.push('');
266
750
  lines.push(`Implement the following system in ${language} using London School TDD (outside-in, mock collaborators at seam boundaries).`);
267
- lines.push(`Ruflo swarm agents and the 110 agentics.dev agent fleet work TOGETHER: agents provide deep analysis (security, quality, governance, ERP integration), Ruflo agents write production code.`);
268
751
  lines.push('');
269
- // Scenario
270
752
  lines.push(`## Scenario`);
271
753
  lines.push(scenarioQuery.slice(0, 600));
272
754
  lines.push('');
273
- // DDD Bounded Contexts
274
- if (ddd.contexts.length > 0) {
275
- lines.push(`## Bounded Contexts (${ddd.contexts.length} from DDD Model)`);
276
- lines.push('');
277
- for (const ctx of ddd.contexts) {
278
- lines.push(`### ${ctx.name}`);
279
- if (ctx.aggregates.length > 0)
280
- lines.push(`- Aggregates: ${ctx.aggregates.join(', ')}`);
281
- if (ctx.commands.length > 0)
282
- lines.push(`- Commands: ${ctx.commands.join(', ')}`);
283
- if (ctx.queries.length > 0)
284
- lines.push(`- Queries: ${ctx.queries.join(', ')}`);
285
- if (ctx.events.length > 0)
286
- lines.push(`- Domain Events: ${ctx.events.join(', ')}`);
287
- lines.push('');
288
- }
289
- if (ddd.contextMap.length > 0) {
290
- lines.push(`### Context Map`);
291
- for (const rel of ddd.contextMap) {
292
- lines.push(`- ${rel.from} -> ${rel.to} (${rel.relationship})`);
293
- }
294
- lines.push('');
295
- }
296
- }
297
- // ADR Decisions
298
755
  if (adrs.length > 0) {
299
756
  lines.push(`## Architectural Decisions (${adrs.length} ADRs)`);
300
757
  lines.push('');
301
758
  for (const adr of adrs) {
302
- lines.push(`- **${adr.id}**: ${adr.title}${adr.decision ? ' ' + adr.decision : ''}`);
759
+ lines.push(`- **${adr.id}**: ${adr.title}${adr.decision ? ' -- ' + adr.decision : ''}`);
303
760
  }
304
761
  lines.push('');
305
762
  }
306
- // TDD Strategy
307
- lines.push(`## Test Strategy: London School TDD`);
308
- lines.push('');
309
- lines.push('1. Write the test FIRST — define the expected behavior');
310
- lines.push('2. Mock all collaborator interfaces at aggregate/seam boundaries');
311
- lines.push('3. Test command handlers in isolation with stubbed repositories and event publishers');
312
- lines.push('4. Test query handlers with in-memory adapters');
313
- lines.push('5. Integration tests at seam boundaries verify adapter contracts');
314
- lines.push('6. Red-green-refactor: minimal code to pass, then clean up');
315
- lines.push('');
316
763
  if (tdd.suites.length > 0) {
317
- lines.push(`### Test Suites (${tdd.suites.length} from TDD Plan)`);
764
+ lines.push(`## Test Suites (${tdd.suites.length})`);
318
765
  for (const suite of tdd.suites) {
319
766
  lines.push(`- ${suite.name}: ${suite.testCount} tests (${suite.strategy})`);
320
767
  }
321
768
  lines.push('');
322
769
  }
323
- // SPARC Architecture Guidance
324
770
  if (sparc.services.length > 0 || sparc.integrations.length > 0) {
325
- lines.push(`## Architecture Guidance (from SPARC Specification)`);
326
- lines.push('');
771
+ lines.push(`## Architecture Guidance`);
327
772
  if (sparc.services.length > 0)
328
773
  lines.push(`- Services: ${sparc.services.join(', ')}`);
329
774
  if (sparc.integrations.length > 0)
330
- lines.push(`- External Integrations: ${sparc.integrations.join(', ')}`);
331
- if (sparc.pseudocodeModules.length > 0)
332
- lines.push(`- Pseudocode Modules: ${sparc.pseudocodeModules.join(', ')}`);
775
+ lines.push(`- Integrations: ${sparc.integrations.join(', ')}`);
333
776
  lines.push('');
334
777
  }
335
- // Implementation Rules
336
- lines.push(`## Implementation Rules`);
778
+ lines.push(`## Rules`);
779
+ lines.push(`- Write REAL business logic -- no stubs, no TODOs`);
780
+ lines.push(`- Ports/adapters: domain has ZERO infrastructure imports`);
781
+ lines.push(`- London School TDD: test first, mock at seams`);
337
782
  lines.push('');
338
- lines.push('1. Every command handler gets a unit test FIRST (London School: mock deps, verify interactions)');
339
- lines.push('2. Aggregates enforce invariants — throw on violation, never allow invalid state');
340
- lines.push('3. Domain events emitted on every state change — events are the source of truth');
341
- lines.push('4. Ports/adapters pattern: domain logic has ZERO infrastructure imports');
342
- lines.push('5. All ERP calls go through adapter interfaces — never call ERP directly from domain');
343
- lines.push('6. Use the agentics agent fleet analysis for: security constraints (shield), quality baselines (test-bench), ERP surface mapping (connector-hub), governance requirements (governance-dashboard)');
344
- lines.push('7. Write REAL business logic — not stubs, not TODOs, not placeholder comments');
345
- lines.push('8. Each bounded context is a separate module with its own aggregate, commands, queries, events, and ports');
783
+ lines.push(`## Naming Convention`);
784
+ lines.push(NAMING_CONVENTION_RULES);
346
785
  lines.push('');
347
- // Artifact file paths for reference
348
786
  const pathLines = [];
349
787
  for (const [label, filePath] of Object.entries(artifacts)) {
350
788
  if (fs.existsSync(filePath))
@@ -358,6 +796,67 @@ export function buildImplementationPrompt(artifacts, scenarioQuery, language) {
358
796
  }
359
797
  return lines.join('\n');
360
798
  }
799
+ /**
800
+ * Build a structured implementation prompt from pipeline artifacts.
801
+ *
802
+ * This prompt is fed to Ruflo swarms AND the 110 agentics.dev agent fleet.
803
+ * It directs them to implement the ADRs + DDDs with high-level SPARC guidance
804
+ * using London School TDD (outside-in, mock collaborators at seam boundaries).
805
+ *
806
+ * The prompt is written to disk as `implementation-prompt.md` and used as the
807
+ * swarm objective across all phases.
808
+ *
809
+ * ADR-028: Now internally uses iterative wave-ordered prompts. The output is
810
+ * a single string with clear wave boundaries for backward compatibility.
811
+ */
812
+ export function buildImplementationPrompt(artifacts, scenarioQuery, language) {
813
+ // ADR-028: Use iterative wave-ordered prompts instead of monolithic dump
814
+ const waves = buildIterativeImplementationPrompts(artifacts, scenarioQuery, language);
815
+ // Join wave prompts into a single document with clear wave boundaries
816
+ const sections = [];
817
+ sections.push(`# Implementation Directive`);
818
+ sections.push('');
819
+ sections.push(`Implement the following system in ${language} using London School TDD (outside-in, mock collaborators at seam boundaries).`);
820
+ sections.push(`Implementation is organized into ${waves.length} sequential waves based on dependency order.`);
821
+ sections.push('');
822
+ sections.push(`## Scenario`);
823
+ sections.push(scenarioQuery.slice(0, 600));
824
+ sections.push('');
825
+ // ADR-029: Embed detected tech stack so all waves use the correct ERP API
826
+ const techCtx = loadTechStackContext(artifacts);
827
+ if (techCtx) {
828
+ sections.push(techCtx);
829
+ sections.push('');
830
+ }
831
+ // Emit each wave as a clearly delimited section
832
+ for (const wave of waves) {
833
+ sections.push(`${'='.repeat(72)}`);
834
+ sections.push(wave.prompt);
835
+ if (wave.tasks.length > 0) {
836
+ sections.push(`### Tasks in this wave`);
837
+ for (const task of wave.tasks) {
838
+ const deps = task.dependsOn && task.dependsOn.length > 0
839
+ ? ` (depends on: ${task.dependsOn.join(', ')})`
840
+ : '';
841
+ sections.push(`- ${task.label} -> ${task.targetDir}${deps}`);
842
+ }
843
+ sections.push('');
844
+ }
845
+ }
846
+ // Artifact file paths for reference
847
+ const pathLines = [];
848
+ for (const [label, filePath] of Object.entries(artifacts)) {
849
+ if (fs.existsSync(filePath))
850
+ pathLines.push(`- ${label}: ${filePath}`);
851
+ }
852
+ if (pathLines.length > 0) {
853
+ sections.push(`## Artifact Paths`);
854
+ sections.push('');
855
+ sections.push(...pathLines);
856
+ sections.push('');
857
+ }
858
+ return sections.join('\n');
859
+ }
361
860
  /**
362
861
  * Build and persist the implementation prompt to disk.
363
862
  * Returns the prompt text and the file path where it was written.
@@ -695,110 +1194,112 @@ export function buildPhase4Tasks(scenarioQuery, artifacts) {
695
1194
  }
696
1195
  /**
697
1196
  * Build Ruflo tasks for Phase 5: Production Build.
698
- * Ruflo writes the complete production-ready application.
1197
+ *
1198
+ * ADR-028 Change 4: Instead of creating all tasks in a flat list dispatched
1199
+ * simultaneously, tasks are now organized into dependency-ordered waves.
1200
+ * Each task carries a `wave` property and `dependsOn` references so the
1201
+ * executor can run them sequentially (wave 1 first, then 2, etc.).
1202
+ *
1203
+ * Wave structure:
1204
+ * Wave 1 (Foundation): Database schemas, shared infra, contexts with no deps
1205
+ * Wave 2 (Core): Independent bounded contexts
1206
+ * Wave 3 (Dependent): Contexts that reference Wave 2 contexts
1207
+ * Wave 4 (Cross-cutting): Frontend, tests, deployment -- AFTER domain code
699
1208
  */
700
1209
  export function buildPhase5Tasks(scenarioQuery, language, artifacts) {
701
- const artifactCtx = buildArtifactContext(artifacts);
702
- const tasks = [];
703
- // --- Per-context tasks (ADR-004) ---
704
- // Read bounded contexts from the DDD domain model and generate one Ruflo
705
- // task per context. Each task references its implementation prompt file
706
- // so the swarm receives focused instructions with invariants, commands,
707
- // queries, events, ports, ADR constraints, and TDD test cases.
708
1210
  const dddPath = artifacts['DDD'] ?? artifacts['ddd'] ?? '';
709
1211
  const contexts = readBoundedContextNames(dddPath);
710
- if (contexts.length > 0) {
711
- // Derive runDir from DDD artifact path (ADR-015)
712
- const dddDir = dddPath ? path.dirname(dddPath) : '';
713
- // runDir is typically the grandparent of the DDD file (runDir/phase2/ddd/domain-model.json)
714
- const inferredRunDir = dddDir ? path.resolve(dddDir, '..', '..') : '';
715
- for (const ctx of contexts) {
716
- const ctxSlug = ctx.name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
717
- const promptFileName = `${ctxSlug}-implementation.md`;
718
- // ADR-015: Try to read prompt content and embed it in the task description
719
- let promptContent = '';
720
- const promptPaths = [
721
- inferredRunDir ? path.join(inferredRunDir, 'prompts', promptFileName) : '',
722
- inferredRunDir ? path.join(inferredRunDir, 'phase3', 'project', 'prompts', promptFileName) : '',
723
- ].filter(Boolean);
724
- for (const pp of promptPaths) {
725
- try {
726
- if (fs.existsSync(pp)) {
727
- promptContent = fs.readFileSync(pp, 'utf-8');
728
- break;
729
- }
730
- }
731
- catch { /* continue to next path */ }
732
- }
733
- // Build task description: embed prompt content if available, otherwise fall back to summary
734
- const promptSection = promptContent
735
- ? `\n\n--- IMPLEMENTATION PROMPT ---\n${promptContent.slice(0, 4000)}\n--- END PROMPT ---\n`
736
- : `Aggregates: ${ctx.aggregates.join(', ')}. ` +
737
- `Commands: ${ctx.commands.join(', ')}. ` +
738
- `Queries: ${ctx.queries.join(', ')}. `;
739
- tasks.push({
740
- label: `Context: ${ctx.name}`,
741
- description: `Implement bounded context "${ctx.name}" in ${language} for: ${scenarioQuery.slice(0, 200)}. ` +
742
- `Write REAL business logic — not stubs. ` +
743
- `${promptSection}` +
744
- `Source: ${artifactCtx}`,
745
- targetDir: `src/${ctxSlug}`,
746
- });
1212
+ // If no DDD model, fall back to the legacy flat list (single wave)
1213
+ if (contexts.length === 0) {
1214
+ return buildPhase5TasksLegacy(scenarioQuery, language, artifacts);
1215
+ }
1216
+ // ADR-028: Use iterative wave-ordered prompts for task generation
1217
+ const waves = buildIterativeImplementationPrompts(artifacts, scenarioQuery, language);
1218
+ // Flatten waves into a single task list, preserving wave and dependency metadata
1219
+ const tasks = [];
1220
+ for (const wave of waves) {
1221
+ for (const task of wave.tasks) {
1222
+ tasks.push(task);
747
1223
  }
748
1224
  }
749
- // --- Cross-cutting tasks (kept as supplementary) ---
750
- tasks.push({
751
- label: 'Frontend Application',
752
- description: `Build a production-ready frontend application for: ${scenarioQuery.slice(0, 300)}. ` +
753
- `Build a complete dashboard with per-bounded-context pages, data tables for queries, ` +
754
- `command forms, typed API client, authentication flow, error boundaries, loading states, ` +
755
- `and responsive layout. Source: ${artifactCtx}`,
756
- targetDir: 'ui',
757
- }, {
758
- label: 'Infrastructure & Integration',
759
- description: `Build production infrastructure and integration layer for: ${scenarioQuery.slice(0, 300)}. ` +
760
- `Include: HTTP middleware (auth, CORS, logging, rate limiting, error handling), ` +
761
- `ERP client adapters with real API endpoints (not stubs), database connection management, ` +
762
- `integration modules for detected external systems, health checks, and metrics endpoints. ` +
763
- `Source: ${artifactCtx}`,
764
- targetDir: 'src/infra',
765
- }, {
766
- label: 'Database & SQL',
767
- description: `Generate production SQL schemas for: ${scenarioQuery.slice(0, 300)}. ` +
768
- `Include: CREATE TABLE per DDD aggregate root, indexes for query patterns, foreign keys, ` +
769
- `constraint checks, migration scripts (up/down), seed data for development, and ` +
770
- `database-specific optimizations for the detected engine. Source: ${artifactCtx}`,
771
- targetDir: 'sql',
772
- }, {
773
- label: 'Test Suite',
774
- description: `Build a comprehensive test suite for: ${scenarioQuery.slice(0, 300)}. ` +
775
- `Implement ALL tests from the TDD plan: unit tests per aggregate, integration tests per seam, ` +
776
- `acceptance tests per bounded context, and e2e tests for critical user flows. ` +
777
- `Include mock contracts, test fixtures, and golden datasets. Tests must PASS. ` +
778
- `Source: ${artifactCtx}`,
779
- targetDir: 'tests',
780
- }, {
781
- label: 'Deployment Configuration',
782
- description: `Generate production deployment configuration for: ${scenarioQuery.slice(0, 300)}. ` +
783
- `Include: Dockerfile (multi-stage, optimized), Docker Compose for local dev, ` +
784
- `cloud deployment configs (Cloud Run / ECS / K8s manifests), CI/CD pipeline, ` +
785
- `environment variable templates, and IaC (Terraform/YAML) for detected cloud provider. ` +
786
- `Source: ${artifactCtx}`,
787
- targetDir: 'deploy',
788
- });
789
- // If no per-context tasks were created (no DDD model), add the generic backend task as fallback
790
- if (contexts.length === 0) {
791
- tasks.unshift({
1225
+ return tasks;
1226
+ }
1227
+ /**
1228
+ * Legacy Phase 5 task builder -- used when no DDD domain model exists.
1229
+ * Produces the original flat task list for backward compatibility.
1230
+ */
1231
+ function buildPhase5TasksLegacy(scenarioQuery, language, artifacts) {
1232
+ const artifactCtx = buildArtifactContext(artifacts);
1233
+ return [
1234
+ {
792
1235
  label: 'Backend Implementation',
793
1236
  description: `Build a complete, production-ready ${language} backend service for: ${scenarioQuery.slice(0, 300)}. ` +
794
1237
  `Implement ALL command handlers, query handlers, domain logic, aggregate roots, and domain events ` +
795
- `from the DDD model. Include real business logic not stubs. Wire all integration points with ` +
1238
+ `from the DDD model. Include real business logic -- not stubs. Wire all integration points with ` +
796
1239
  `actual API calls (not mock clients). Include connection pooling, retry logic, circuit breakers, ` +
797
1240
  `and comprehensive error handling. Source: ${artifactCtx}`,
798
1241
  targetDir: 'src',
799
- });
800
- }
801
- return tasks;
1242
+ wave: 1,
1243
+ },
1244
+ {
1245
+ label: 'Frontend Application',
1246
+ description: `Build a production-ready frontend application for: ${scenarioQuery.slice(0, 300)}. ` +
1247
+ `Build a complete dashboard with data tables for queries, ` +
1248
+ `command forms, typed API client, authentication flow, error boundaries, loading states, ` +
1249
+ `and responsive layout. Source: ${artifactCtx}`,
1250
+ targetDir: 'ui',
1251
+ wave: 2,
1252
+ dependsOn: ['Backend Implementation'],
1253
+ },
1254
+ {
1255
+ label: 'Infrastructure & Integration',
1256
+ description: `Build production infrastructure and integration layer for: ${scenarioQuery.slice(0, 300)}. ` +
1257
+ `Include: HTTP middleware (auth, CORS, logging, rate limiting, error handling), ` +
1258
+ `ERP client adapters with real API endpoints (not stubs), database connection management, ` +
1259
+ `integration modules for detected external systems, health checks, and metrics endpoints. ` +
1260
+ `Source: ${artifactCtx}`,
1261
+ targetDir: 'src/infra',
1262
+ wave: 2,
1263
+ dependsOn: ['Backend Implementation'],
1264
+ },
1265
+ {
1266
+ label: 'Database & SQL',
1267
+ description: `Generate production SQL schemas for: ${scenarioQuery.slice(0, 300)}. ` +
1268
+ `Include: CREATE TABLE per DDD aggregate root, indexes for query patterns, foreign keys, ` +
1269
+ `constraint checks, migration scripts (up/down), seed data for development, and ` +
1270
+ `database-specific optimizations for the detected engine. Source: ${artifactCtx}`,
1271
+ targetDir: 'sql',
1272
+ wave: 1,
1273
+ },
1274
+ {
1275
+ label: 'Test Suite',
1276
+ description: `Build a comprehensive test suite for: ${scenarioQuery.slice(0, 300)}. ` +
1277
+ `IMPORTANT: This task runs AFTER domain code is generated. ` +
1278
+ `Import modules from the ACTUAL generated domain code — do NOT guess import paths. ` +
1279
+ `Read the generated source files in src/ to discover what modules, classes, and functions exist, ` +
1280
+ `then write tests that import and test those REAL exports. ` +
1281
+ `Write London School TDD tests: mock collaborator interfaces at aggregate boundaries, ` +
1282
+ `test command handlers in isolation, test query handlers with in-memory adapters. ` +
1283
+ `Every test must compile and import modules that actually exist. ` +
1284
+ `NAMING CONVENTION: Port interfaces are named {ContextName}Port (no "I" prefix). ` +
1285
+ `Adapters are {Implementation}{ContextName}Adapter. Never use "II*" double-prefix. ` +
1286
+ `Source: ${artifactCtx}`,
1287
+ targetDir: 'tests',
1288
+ wave: 4,
1289
+ dependsOn: ['Backend Implementation', 'Database & SQL'],
1290
+ },
1291
+ {
1292
+ label: 'Deployment Configuration',
1293
+ description: `Generate production deployment configuration for: ${scenarioQuery.slice(0, 300)}. ` +
1294
+ `Include: Dockerfile (multi-stage, optimized), Docker Compose for local dev, ` +
1295
+ `cloud deployment configs (Cloud Run / ECS / K8s manifests), CI/CD pipeline, ` +
1296
+ `environment variable templates, and IaC (Terraform/YAML) for detected cloud provider. ` +
1297
+ `Source: ${artifactCtx}`,
1298
+ targetDir: 'deploy',
1299
+ wave: 2,
1300
+ dependsOn: ['Backend Implementation'],
1301
+ },
1302
+ ];
802
1303
  }
803
1304
  /**
804
1305
  * Read bounded context names from the DDD domain-model.json.
@@ -1026,7 +1527,13 @@ export function collectPhase4Artifacts(runDir) {
1026
1527
  'TDD': 'phase3/tdd/tdd-plan.json',
1027
1528
  'phase3-agents': 'phase3/agentics-agents-report.json',
1028
1529
  'sparc-specification': 'engineering/sparc-specification.md',
1530
+ 'sparc-specification-md': 'phase3/sparc/specification.md',
1531
+ 'sparc-architecture-md': 'phase3/sparc/architecture.md',
1532
+ 'sparc-pseudocode-md': 'phase3/sparc/pseudocode.md',
1533
+ 'sparc-refinement-md': 'phase3/sparc/refinement.md',
1534
+ 'sparc-completion-md': 'phase3/sparc/completion.md',
1029
1535
  'tdd-test-plan': 'engineering/tdd-test-plan.md',
1536
+ 'tdd-plan-md': 'phase3/tdd/tdd-plan.md',
1030
1537
  };
1031
1538
  for (const [label, file] of Object.entries(phase3Candidates)) {
1032
1539
  const p = path.join(runDir, file);