claude-flow-novice 2.15.10 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (652) hide show
  1. package/.claude/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
  2. package/.claude/commands/cfn-loop-cli.md +158 -464
  3. package/.claude/commands/cfn-loop-trigger.md +114 -0
  4. package/.claude/hooks/cfn-invoke-post-edit-ts.sh +100 -0
  5. package/.claude/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
  6. package/.claude/hooks/cfn-invoke-post-edit.sh +22 -0
  7. package/.claude/hooks/cfn-invoke-post-edit.sh.backup +87 -0
  8. package/.claude/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
  9. package/.claude/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
  10. package/.claude/hooks/cfn-invoke-pre-edit.sh +22 -0
  11. package/.claude/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
  12. package/.claude/skills/cfn-agent-spawning/SKILL.md +48 -1
  13. package/.claude/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
  14. package/.claude/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
  15. package/.claude/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
  16. package/.claude/skills/{cfn-redis-coordination/check-dependencies.sh → cfn-agent-spawning/check-dependencies.sh.backup} +3 -5
  17. package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
  18. package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
  19. package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
  20. package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
  21. package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
  22. package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
  23. package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
  24. package/.claude/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
  25. package/.claude/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
  26. package/.claude/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
  27. package/.claude/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
  28. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
  29. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
  30. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
  31. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
  32. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
  33. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
  34. package/.claude/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
  35. package/.claude/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
  36. package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
  37. package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
  38. package/.claude/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
  39. package/.claude/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
  40. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
  41. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
  42. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
  43. package/.claude/skills/cfn-loop-orchestration/SKILL.md +159 -48
  44. package/.claude/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
  45. package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
  46. package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
  47. package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
  48. package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
  49. package/.claude/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
  50. package/.claude/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
  51. package/.claude/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
  52. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
  53. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
  54. package/{claude-assets/skills/cfn-loop-orchestration → .claude/skills/cfn-loop-orchestration/archive/legacy-bash}/orchestrate-wrapper.sh +11 -1
  55. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
  56. package/.claude/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
  57. package/.claude/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
  58. package/.claude/skills/cfn-loop-orchestration/package-lock.json +3 -0
  59. package/.claude/skills/cfn-loop-orchestration/package.json +4 -0
  60. package/.claude/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
  61. package/.claude/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
  62. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
  63. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
  64. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
  65. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
  66. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
  67. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
  68. package/.claude/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
  69. package/.claude/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
  70. package/.claude/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
  71. package/.claude/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
  72. package/.claude/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
  73. package/.claude/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
  74. package/.claude/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
  75. package/.claude/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
  76. package/.claude/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
  77. package/.claude/skills/cfn-loop-orchestration/src/index.ts +2 -0
  78. package/.claude/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
  79. package/.claude/skills/cfn-loop-orchestration/src/types.ts +56 -0
  80. package/.claude/skills/cfn-loop-orchestration/test-cli.sh +92 -0
  81. package/.claude/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
  82. package/.claude/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
  83. package/.claude/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
  84. package/.claude/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
  85. package/.claude/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
  86. package/.claude/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
  87. package/.claude/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
  88. package/.claude/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
  89. package/.claude/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
  90. package/.claude/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
  91. package/.claude/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
  92. package/.claude/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
  93. package/.claude/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
  94. package/.claude/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
  95. package/.claude/skills/cfn-loop-validation/INDEX.md +531 -0
  96. package/.claude/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
  97. package/.claude/skills/cfn-loop-validation/SKILL.md +48 -1
  98. package/.claude/skills/cfn-loop-validation/SKILL.md.backup +353 -0
  99. package/.claude/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
  100. package/.claude/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
  101. package/.claude/skills/cfn-loop-validation/check-dependencies.sh +22 -0
  102. package/{claude-assets/skills/cfn-redis-coordination/check-dependencies.sh → .claude/skills/cfn-loop-validation/check-dependencies.sh.backup} +4 -5
  103. package/.claude/skills/cfn-loop-validation/detect-vapor.sh +59 -0
  104. package/.claude/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
  105. package/.claude/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
  106. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
  107. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
  108. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
  109. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
  110. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
  111. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
  112. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
  113. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
  114. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
  115. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
  116. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
  117. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
  118. package/.claude/skills/cfn-loop-validation/dist/types.d.ts +156 -0
  119. package/.claude/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
  120. package/.claude/skills/cfn-loop-validation/dist/types.js +66 -0
  121. package/.claude/skills/cfn-loop-validation/dist/types.js.map +1 -0
  122. package/.claude/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
  123. package/.claude/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
  124. package/.claude/skills/cfn-loop-validation/dist/validator.js +411 -0
  125. package/.claude/skills/cfn-loop-validation/dist/validator.js.map +1 -0
  126. package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
  127. package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
  128. package/.claude/skills/cfn-loop-validation/package.json +93 -0
  129. package/.claude/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
  130. package/.claude/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
  131. package/.claude/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
  132. package/.claude/skills/cfn-loop-validation/src/types.ts +215 -0
  133. package/.claude/skills/cfn-loop-validation/src/validator.ts +503 -0
  134. package/.claude/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
  135. package/.claude/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
  136. package/.claude/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
  137. package/.claude/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
  138. package/.claude/skills/cfn-loop-validation/validate-gate.sh +63 -0
  139. package/.claude/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
  140. package/.claude/skills/cfn-loop-validation/validate-iteration.sh +22 -0
  141. package/.claude/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
  142. package/.claude/skills/cfn-product-owner-decision/SKILL.md +479 -147
  143. package/.claude/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
  144. package/{claude-assets/skills/cfn-product-owner-decision → .claude/skills/cfn-product-owner-decision/archive/legacy-bash}/execute-decision.sh +24 -2
  145. package/.claude/skills/pre-edit-backup/SKILL.md +324 -0
  146. package/.claude/skills/pre-edit-backup/SKILL.md.backup +277 -0
  147. package/.claude/skills/pre-edit-backup/backup.sh +22 -0
  148. package/.claude/skills/pre-edit-backup/backup.sh.backup +107 -0
  149. package/claude-assets/agents/cfn-dev-team/CLAUDE.md +9 -81
  150. package/claude-assets/agents/cfn-dev-team/architecture/base-template-generator.md +4 -4
  151. package/claude-assets/agents/cfn-dev-team/architecture/planner.md +4 -4
  152. package/claude-assets/agents/cfn-dev-team/architecture/system-architect.md +5 -5
  153. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +1 -0
  154. package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +1 -0
  155. package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +1 -0
  156. package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +1 -0
  157. package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +14 -4
  158. package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +63 -70
  159. package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +50 -70
  160. package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +13 -4
  161. package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +27 -58
  162. package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +40 -58
  163. package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +18 -20
  164. package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +19 -28
  165. package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +15 -19
  166. package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +15 -10
  167. package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +15 -10
  168. package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +15 -25
  169. package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +17 -21
  170. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +17 -21
  171. package/claude-assets/agents/cfn-dev-team/product-owners/accessibility-advocate-persona.md +4 -4
  172. package/claude-assets/agents/cfn-dev-team/product-owners/cto-agent.md +4 -4
  173. package/claude-assets/agents/cfn-dev-team/product-owners/power-user-persona.md +4 -4
  174. package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +19 -27
  175. package/claude-assets/agents/cfn-dev-team/reviewers/code-reviewer.md +20 -51
  176. package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +22 -71
  177. package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +21 -64
  178. package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +22 -67
  179. package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +23 -67
  180. package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +14 -70
  181. package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +25 -73
  182. package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +26 -65
  183. package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +5 -5
  184. package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +27 -67
  185. package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +16 -73
  186. package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +27 -67
  187. package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +27 -60
  188. package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +15 -74
  189. package/claude-assets/agents/cfn-dev-team/testers/tester.md +14 -60
  190. package/claude-assets/agents/cfn-dev-team/testers/unit/tdd-london-unit-swarm.md +5 -5
  191. package/claude-assets/agents/cfn-dev-team/testers/validation/validation-production-validator.md +4 -4
  192. package/claude-assets/agents/cfn-dev-team/testing/test-validation-agent.md +4 -4
  193. package/claude-assets/agents/cfn-dev-team/utility/agent-builder.md +16 -16
  194. package/claude-assets/agents/cfn-dev-team/utility/analyst.md +16 -32
  195. package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +17 -17
  196. package/claude-assets/agents/cfn-dev-team/utility/context-curator.md +10 -5
  197. package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +12 -102
  198. package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +127 -814
  199. package/claude-assets/agents/cfn-dev-team/utility/researcher.md +16 -25
  200. package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +157 -667
  201. package/claude-assets/agents/custom/cfn-docker-expert.md +102 -0
  202. package/claude-assets/agents/custom/cfn-loops-cli-expert.md +129 -0
  203. package/claude-assets/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
  204. package/claude-assets/commands/cfn-loop-cli.md +158 -464
  205. package/claude-assets/commands/cfn-loop-trigger.md +114 -0
  206. package/claude-assets/hooks/SKILL.md +518 -0
  207. package/claude-assets/hooks/SKILL.md.backup +471 -0
  208. package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh +100 -0
  209. package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
  210. package/claude-assets/hooks/cfn-invoke-post-edit.sh +22 -0
  211. package/claude-assets/hooks/cfn-invoke-post-edit.sh.backup +87 -0
  212. package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
  213. package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
  214. package/claude-assets/hooks/cfn-invoke-pre-edit.sh +22 -0
  215. package/claude-assets/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
  216. package/claude-assets/skills/cfn-agent-selection-with-fallback/DELIVERABLES.md +409 -0
  217. package/claude-assets/skills/cfn-agent-selection-with-fallback/IMPLEMENTATION_SUMMARY.md +396 -0
  218. package/claude-assets/skills/cfn-agent-selection-with-fallback/INTEGRATION_GUIDE.md +308 -0
  219. package/claude-assets/skills/cfn-agent-selection-with-fallback/QUICK_REFERENCE.md +239 -0
  220. package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md +107 -1
  221. package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md.backup +302 -0
  222. package/claude-assets/skills/cfn-agent-selection-with-fallback/TYPESCRIPT_MIGRATION.md +295 -0
  223. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.cjs +297 -0
  224. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.js +297 -0
  225. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.cjs +96 -0
  226. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.js +96 -0
  227. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh +45 -0
  228. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh.backup +23 -0
  229. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh +22 -0
  230. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh.backup +173 -0
  231. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.test.ts +357 -0
  232. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.ts +350 -0
  233. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/cli.ts +74 -0
  234. package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh +22 -0
  235. package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh.backup +71 -0
  236. package/claude-assets/skills/cfn-agent-selection-with-fallback/tsconfig.json +18 -0
  237. package/claude-assets/skills/cfn-agent-spawning/SKILL.md +48 -1
  238. package/claude-assets/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
  239. package/claude-assets/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
  240. package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
  241. package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh.backup +30 -0
  242. package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
  243. package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
  244. package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
  245. package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
  246. package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
  247. package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
  248. package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
  249. package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
  250. package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
  251. package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
  252. package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
  253. package/claude-assets/skills/cfn-coordination/agent-completion.sh.backup +36 -0
  254. package/claude-assets/skills/cfn-coordination/coordination-signal.sh.backup +36 -0
  255. package/claude-assets/skills/cfn-coordination/coordination-wait.sh.backup +36 -0
  256. package/claude-assets/skills/cfn-dependency-ingestion/README.md +101 -0
  257. package/claude-assets/skills/cfn-dependency-ingestion/SKILL.md +369 -0
  258. package/claude-assets/skills/cfn-dependency-ingestion/build.sh +23 -0
  259. package/claude-assets/skills/cfn-dependency-ingestion/dist/ingest-dependencies.js +478 -0
  260. package/claude-assets/skills/cfn-dependency-ingestion/ingest-dependencies.sh +295 -0
  261. package/claude-assets/skills/cfn-dependency-ingestion/src/ingest-dependencies.ts +563 -0
  262. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
  263. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
  264. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
  265. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
  266. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
  267. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
  268. package/claude-assets/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
  269. package/claude-assets/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
  270. package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
  271. package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
  272. package/claude-assets/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
  273. package/claude-assets/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
  274. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
  275. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
  276. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
  277. package/claude-assets/skills/cfn-loop-orchestration/SKILL.md +159 -48
  278. package/claude-assets/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
  279. package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
  280. package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
  281. package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
  282. package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
  283. package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
  284. package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
  285. package/claude-assets/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
  286. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
  287. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
  288. package/{.claude/skills/cfn-loop-orchestration → claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash}/orchestrate-wrapper.sh +11 -1
  289. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
  290. package/claude-assets/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
  291. package/claude-assets/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
  292. package/claude-assets/skills/cfn-loop-orchestration/package-lock.json +3 -0
  293. package/claude-assets/skills/cfn-loop-orchestration/package.json +4 -0
  294. package/claude-assets/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
  295. package/claude-assets/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
  296. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
  297. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
  298. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
  299. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
  300. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
  301. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
  302. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
  303. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
  304. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
  305. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
  306. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
  307. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
  308. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
  309. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
  310. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
  311. package/claude-assets/skills/cfn-loop-orchestration/src/index.ts +2 -0
  312. package/claude-assets/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
  313. package/claude-assets/skills/cfn-loop-orchestration/src/types.ts +56 -0
  314. package/claude-assets/skills/cfn-loop-orchestration/test-cli.sh +92 -0
  315. package/claude-assets/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
  316. package/claude-assets/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
  317. package/claude-assets/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
  318. package/claude-assets/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
  319. package/claude-assets/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
  320. package/claude-assets/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
  321. package/claude-assets/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
  322. package/claude-assets/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
  323. package/claude-assets/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
  324. package/claude-assets/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
  325. package/claude-assets/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
  326. package/claude-assets/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
  327. package/claude-assets/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
  328. package/claude-assets/skills/cfn-loop-output-processing/.eslintrc.json +33 -0
  329. package/claude-assets/skills/cfn-loop-output-processing/DELIVERY_SUMMARY.txt +462 -0
  330. package/claude-assets/skills/cfn-loop-output-processing/DEPRECATION_NOTICE.md +183 -0
  331. package/claude-assets/skills/cfn-loop-output-processing/EXAMPLES.md +609 -0
  332. package/claude-assets/skills/cfn-loop-output-processing/IMPLEMENTATION_SUMMARY.md +418 -0
  333. package/claude-assets/skills/cfn-loop-output-processing/INDEX.md +531 -0
  334. package/claude-assets/skills/cfn-loop-output-processing/MIGRATION.md +362 -0
  335. package/claude-assets/skills/cfn-loop-output-processing/README.md +114 -0
  336. package/claude-assets/skills/cfn-loop-output-processing/SKILL.md +633 -0
  337. package/{.claude/skills/cfn-docker-redis-coordination → claude-assets/skills/cfn-loop-output-processing}/jest.config.js +7 -15
  338. package/claude-assets/skills/cfn-loop-output-processing/package.json +50 -0
  339. package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop2.ts +195 -0
  340. package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop3.ts +157 -0
  341. package/claude-assets/skills/cfn-loop-output-processing/src/output-processor.ts +632 -0
  342. package/claude-assets/skills/cfn-loop-output-processing/tests/output-processor.test.ts +617 -0
  343. package/claude-assets/skills/{cfn-docker-redis-coordination → cfn-loop-output-processing}/tsconfig.json +16 -7
  344. package/claude-assets/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
  345. package/claude-assets/skills/cfn-loop-validation/INDEX.md +531 -0
  346. package/claude-assets/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
  347. package/claude-assets/skills/cfn-loop-validation/SKILL.md +48 -1
  348. package/claude-assets/skills/cfn-loop-validation/SKILL.md.backup +353 -0
  349. package/claude-assets/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
  350. package/claude-assets/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
  351. package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh +22 -0
  352. package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh.backup +31 -0
  353. package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh +59 -0
  354. package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
  355. package/claude-assets/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
  356. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
  357. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
  358. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
  359. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
  360. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
  361. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
  362. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
  363. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
  364. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
  365. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
  366. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
  367. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
  368. package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts +156 -0
  369. package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
  370. package/claude-assets/skills/cfn-loop-validation/dist/types.js +66 -0
  371. package/claude-assets/skills/cfn-loop-validation/dist/types.js.map +1 -0
  372. package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
  373. package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
  374. package/claude-assets/skills/cfn-loop-validation/dist/validator.js +411 -0
  375. package/claude-assets/skills/cfn-loop-validation/dist/validator.js.map +1 -0
  376. package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
  377. package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
  378. package/claude-assets/skills/cfn-loop-validation/package.json +93 -0
  379. package/claude-assets/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
  380. package/claude-assets/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
  381. package/claude-assets/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
  382. package/claude-assets/skills/cfn-loop-validation/src/types.ts +215 -0
  383. package/claude-assets/skills/cfn-loop-validation/src/validator.ts +503 -0
  384. package/claude-assets/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
  385. package/claude-assets/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
  386. package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
  387. package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
  388. package/claude-assets/skills/cfn-loop-validation/validate-gate.sh +63 -0
  389. package/claude-assets/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
  390. package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh +22 -0
  391. package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
  392. package/claude-assets/skills/cfn-product-owner-decision/SKILL.md +479 -147
  393. package/claude-assets/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
  394. package/{.claude/skills/cfn-product-owner-decision → claude-assets/skills/cfn-product-owner-decision/archive/legacy-bash}/execute-decision.sh +24 -2
  395. package/claude-assets/skills/cfn-provider-routing/README.md +129 -0
  396. package/claude-assets/skills/cfn-provider-routing/SKILL.md +192 -0
  397. package/claude-assets/skills/cfn-provider-routing/resolve-provider-model.ts +223 -0
  398. package/claude-assets/skills/pre-edit-backup/SKILL.md +324 -0
  399. package/claude-assets/skills/pre-edit-backup/SKILL.md.backup +277 -0
  400. package/claude-assets/skills/pre-edit-backup/backup.sh +22 -0
  401. package/claude-assets/skills/pre-edit-backup/backup.sh.backup +107 -0
  402. package/dist/agents/agent-loader.js +146 -165
  403. package/dist/agents/agent-loader.js.map +1 -1
  404. package/dist/api/auth-endpoints.js +415 -0
  405. package/dist/api/auth-endpoints.js.map +1 -0
  406. package/dist/api/task-endpoints.js +562 -0
  407. package/dist/api/task-endpoints.js.map +1 -0
  408. package/dist/backend/server.js +418 -0
  409. package/dist/backend/server.js.map +1 -0
  410. package/dist/cfn-loop/product-owner/decision-parser.js +356 -0
  411. package/dist/cfn-loop/product-owner/decision-parser.js.map +1 -0
  412. package/dist/cfn-loop/product-owner/index.js +1 -0
  413. package/dist/cfn-loop/product-owner/index.js.map +1 -1
  414. package/dist/cli/agent-command.js +1 -1
  415. package/dist/cli/agent-command.js.map +1 -1
  416. package/dist/cli/agent-completion.js +273 -0
  417. package/dist/cli/agent-completion.js.map +1 -0
  418. package/dist/cli/agent-definition-parser.js +37 -4
  419. package/dist/cli/agent-definition-parser.js.map +1 -1
  420. package/dist/cli/agent-executor.js +32 -2
  421. package/dist/cli/agent-executor.js.map +1 -1
  422. package/dist/cli/agent-prompt-builder.js +83 -48
  423. package/dist/cli/agent-prompt-builder.js.map +1 -1
  424. package/dist/cli/agent-spawner.js +499 -0
  425. package/dist/cli/agent-spawner.js.map +1 -0
  426. package/dist/cli/anthropic-client.js +10 -3
  427. package/dist/cli/anthropic-client.js.map +1 -1
  428. package/dist/cli/config-manager.js.map +1 -1
  429. package/dist/cli/index.js +11 -0
  430. package/dist/cli/index.js.map +1 -1
  431. package/dist/cli/parse-decision-cli.js +268 -0
  432. package/dist/cli/parse-decision-cli.js.map +1 -0
  433. package/dist/cli/post-edit-hook.js +83 -0
  434. package/dist/cli/post-edit-hook.js.map +1 -0
  435. package/dist/cli/pre-edit-hook.js +77 -0
  436. package/dist/cli/pre-edit-hook.js.map +1 -0
  437. package/dist/cli/spawn-agent-cli.js +209 -0
  438. package/dist/cli/spawn-agent-cli.js.map +1 -0
  439. package/dist/coordination/coordination-wrapper.js +383 -0
  440. package/dist/coordination/coordination-wrapper.js.map +1 -0
  441. package/dist/coordination/store-success-criteria.js +68 -0
  442. package/dist/coordination/store-success-criteria.js.map +1 -0
  443. package/dist/coordination/store-task-context.js +65 -0
  444. package/dist/coordination/store-task-context.js.map +1 -0
  445. package/dist/hooks/backup-manager.js +273 -0
  446. package/dist/hooks/backup-manager.js.map +1 -0
  447. package/dist/hooks/post-edit-validator.js +388 -0
  448. package/dist/hooks/post-edit-validator.js.map +1 -0
  449. package/dist/integration/index.js +19 -0
  450. package/dist/integration/index.js.map +1 -0
  451. package/dist/integration/task-mode-adapter.js +297 -0
  452. package/dist/integration/task-mode-adapter.js.map +1 -0
  453. package/dist/integration/trigger-dev-client.js +253 -0
  454. package/dist/integration/trigger-dev-client.js.map +1 -0
  455. package/dist/integration/trigger-dev-webhooks.js +362 -0
  456. package/dist/integration/trigger-dev-webhooks.js.map +1 -0
  457. package/dist/lib/path-validator.js +14 -5
  458. package/dist/lib/path-validator.js.map +1 -1
  459. package/dist/lib/redis-queue-manager.js +5 -1
  460. package/dist/lib/redis-queue-manager.js.map +1 -1
  461. package/dist/middleware/authentication.js +317 -0
  462. package/dist/middleware/authentication.js.map +1 -0
  463. package/dist/services/authentication.js +669 -0
  464. package/dist/services/authentication.js.map +1 -0
  465. package/dist/services/session-management.js +436 -0
  466. package/dist/services/session-management.js.map +1 -0
  467. package/dist/services/skill-deployment.js +8 -6
  468. package/dist/services/skill-deployment.js.map +1 -1
  469. package/dist/services/user-service.js +710 -0
  470. package/dist/services/user-service.js.map +1 -0
  471. package/dist/types/trigger-dev-events.d.js +10 -0
  472. package/dist/types/trigger-dev-events.d.js.map +1 -0
  473. package/docs/README.md +240 -0
  474. package/package.json +13 -4
  475. package/scripts/compare-workflow-performance.sh +556 -0
  476. package/scripts/migrate-to-optimized-workflows.sh +438 -0
  477. package/scripts/organize-docs.sh +338 -0
  478. package/scripts/trigger-dev-setup.sh +267 -0
  479. package/.claude/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
  480. package/.claude/skills/cfn-docker-redis-coordination/README.md +0 -294
  481. package/.claude/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
  482. package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
  483. package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
  484. package/.claude/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
  485. package/.claude/skills/cfn-docker-redis-coordination/package.json +0 -40
  486. package/.claude/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
  487. package/.claude/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
  488. package/.claude/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
  489. package/.claude/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
  490. package/.claude/skills/cfn-docker-redis-coordination/tsconfig.json +0 -30
  491. package/.claude/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
  492. package/.claude/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
  493. package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
  494. package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
  495. package/.claude/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
  496. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
  497. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
  498. package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
  499. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
  500. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
  501. package/.claude/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
  502. package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
  503. package/.claude/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
  504. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
  505. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
  506. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
  507. package/.claude/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
  508. package/.claude/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
  509. package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
  510. package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
  511. package/.claude/skills/cfn-redis-coordination/config.json +0 -61
  512. package/.claude/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
  513. package/.claude/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
  514. package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
  515. package/.claude/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
  516. package/.claude/skills/cfn-redis-coordination/jest.config.js +0 -23
  517. package/.claude/skills/cfn-redis-coordination/package-lock.json +0 -5272
  518. package/.claude/skills/cfn-redis-coordination/package.json +0 -45
  519. package/.claude/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
  520. package/.claude/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
  521. package/.claude/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
  522. package/.claude/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
  523. package/.claude/skills/cfn-redis-coordination/src/index.ts +0 -82
  524. package/.claude/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
  525. package/.claude/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
  526. package/.claude/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
  527. package/.claude/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
  528. package/.claude/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
  529. package/.claude/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
  530. package/.claude/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
  531. package/.claude/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
  532. package/.claude/skills/cfn-redis-coordination/src/types.ts +0 -235
  533. package/.claude/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
  534. package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
  535. package/.claude/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
  536. package/.claude/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
  537. package/.claude/skills/cfn-redis-coordination/test-redis-check.js +0 -84
  538. package/.claude/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
  539. package/.claude/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
  540. package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
  541. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +0 -976
  542. package/claude-assets/agents/typescript-specialist.md +0 -280
  543. package/claude-assets/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
  544. package/claude-assets/skills/cfn-docker-redis-coordination/README.md +0 -294
  545. package/claude-assets/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
  546. package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
  547. package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
  548. package/claude-assets/skills/cfn-docker-redis-coordination/jest.config.js +0 -37
  549. package/claude-assets/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
  550. package/claude-assets/skills/cfn-docker-redis-coordination/package.json +0 -40
  551. package/claude-assets/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
  552. package/claude-assets/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
  553. package/claude-assets/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
  554. package/claude-assets/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
  555. package/claude-assets/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
  556. package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
  557. package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
  558. package/claude-assets/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
  559. package/claude-assets/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
  560. package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
  561. package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
  562. package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
  563. package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
  564. package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
  565. package/claude-assets/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
  566. package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
  567. package/claude-assets/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
  568. package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
  569. package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
  570. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
  571. package/claude-assets/skills/cfn-redis-cleanup/cleanup-redis.sh +0 -130
  572. package/claude-assets/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
  573. package/claude-assets/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
  574. package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
  575. package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
  576. package/claude-assets/skills/cfn-redis-coordination/config.json +0 -61
  577. package/claude-assets/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
  578. package/claude-assets/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
  579. package/claude-assets/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
  580. package/claude-assets/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
  581. package/claude-assets/skills/cfn-redis-coordination/jest.config.js +0 -23
  582. package/claude-assets/skills/cfn-redis-coordination/package-lock.json +0 -5272
  583. package/claude-assets/skills/cfn-redis-coordination/package.json +0 -45
  584. package/claude-assets/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
  585. package/claude-assets/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
  586. package/claude-assets/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
  587. package/claude-assets/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
  588. package/claude-assets/skills/cfn-redis-coordination/src/index.ts +0 -82
  589. package/claude-assets/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
  590. package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
  591. package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
  592. package/claude-assets/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
  593. package/claude-assets/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
  594. package/claude-assets/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
  595. package/claude-assets/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
  596. package/claude-assets/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
  597. package/claude-assets/skills/cfn-redis-coordination/src/types.ts +0 -235
  598. package/claude-assets/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
  599. package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
  600. package/claude-assets/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
  601. package/claude-assets/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
  602. package/claude-assets/skills/cfn-redis-coordination/test-redis-check.js +0 -84
  603. package/claude-assets/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
  604. package/claude-assets/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
  605. package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
  606. package/claude-assets/skills/cfn-redis-data-extraction/SKILL.md +0 -442
  607. package/claude-assets/skills/cfn-redis-data-extraction/extract.sh +0 -306
  608. package/dist/coordination/index.js +0 -25
  609. package/dist/coordination/index.js.map +0 -1
  610. package/docs/BUG_19_MEMORY_LEAK_TASK_MODE.md +0 -405
  611. package/docs/MEMORY_CLEANUP_GUIDE.md +0 -358
  612. package/docs/MEMORY_LEAK_FIX_SUMMARY.md +0 -322
  613. package/docs/REDIS_CLEANUP_EXECUTIVE_SUMMARY.md +0 -319
  614. package/docs/REDIS_CLEANUP_VERIFICATION_REPORT.md +0 -574
  615. /package/.claude/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
  616. /package/.claude/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
  617. /package/.claude/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
  618. /package/.claude/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
  619. /package/.claude/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
  620. /package/.claude/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
  621. /package/.claude/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
  622. /package/.claude/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
  623. /package/.claude/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
  624. /package/.claude/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
  625. /package/.claude/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
  626. /package/.claude/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
  627. /package/.claude/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
  628. /package/.claude/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
  629. /package/.claude/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
  630. /package/.claude/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
  631. /package/.claude/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
  632. /package/.claude/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
  633. /package/.claude/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
  634. /package/claude-assets/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
  635. /package/claude-assets/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
  636. /package/claude-assets/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
  637. /package/claude-assets/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
  638. /package/claude-assets/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
  639. /package/claude-assets/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
  640. /package/claude-assets/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
  641. /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
  642. /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
  643. /package/claude-assets/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
  644. /package/claude-assets/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
  645. /package/claude-assets/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
  646. /package/claude-assets/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
  647. /package/claude-assets/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
  648. /package/claude-assets/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
  649. /package/claude-assets/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
  650. /package/claude-assets/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
  651. /package/claude-assets/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
  652. /package/claude-assets/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
@@ -0,0 +1,499 @@
1
+ /**
2
+ * Agent Spawner Module
3
+ *
4
+ * High-level API for spawning agents with full type safety,
5
+ * environment variable handling, provider configuration parsing,
6
+ * and Redis coordination integration.
7
+ *
8
+ * Usage:
9
+ * const spawner = new AgentSpawner();
10
+ * const result = await spawner.spawnAgent({
11
+ * agentType: 'backend-developer',
12
+ * taskId: 'task-123',
13
+ * iteration: 1,
14
+ * mode: 'standard'
15
+ * });
16
+ */ import { existsSync, readFileSync } from 'fs';
17
+ import { resolve } from 'path';
18
+ import { spawn as childSpawn } from 'child_process';
19
+ import { v4 as uuidv4 } from 'uuid';
20
+ /**
21
+ * AgentSpawner class - Type-safe agent spawning with validation
22
+ */ export class AgentSpawner {
23
+ projectRoot;
24
+ agentProfilesDir;
25
+ agentConfigFile;
26
+ constructor(projectRoot){
27
+ this.projectRoot = projectRoot || process.cwd();
28
+ this.agentProfilesDir = resolve(this.projectRoot, '.claude/agents/cfn-dev-team');
29
+ this.agentConfigFile = resolve(this.projectRoot, '.claude/cfn-config/team-providers.json');
30
+ }
31
+ /**
32
+ * Spawn an agent with the given configuration
33
+ */ async spawnAgent(config) {
34
+ const timestamp = new Date().toISOString();
35
+ const agentId = this.generateAgentId(config.agentType);
36
+ try {
37
+ // Validate configuration
38
+ this.validateSpawnConfig(config);
39
+ // Check agent exists
40
+ const agentExists = await this.validateAgentExists(config.agentType);
41
+ if (!agentExists) {
42
+ return {
43
+ agentId,
44
+ pid: -1,
45
+ status: 'failed',
46
+ timestamp,
47
+ error: `Agent type not found: ${config.agentType}`
48
+ };
49
+ }
50
+ // Parse provider configuration if not explicitly provided
51
+ let provider = config.provider;
52
+ let model = config.model;
53
+ if (!provider || !model) {
54
+ const providerConfig = await this.parseAgentProvider(config.agentType);
55
+ provider = provider || providerConfig.provider;
56
+ model = model || providerConfig.model;
57
+ }
58
+ // Build environment variables
59
+ const env = this.buildEnvironment(config, agentId, provider, model);
60
+ // Spawn the process
61
+ const pid = await this.spawnProcess(config.agentType, env, config.background);
62
+ return {
63
+ agentId,
64
+ pid,
65
+ status: 'spawned',
66
+ timestamp,
67
+ metadata: {
68
+ agentType: config.agentType,
69
+ taskId: config.taskId,
70
+ iteration: config.iteration,
71
+ mode: config.mode,
72
+ provider,
73
+ model
74
+ }
75
+ };
76
+ } catch (error) {
77
+ return {
78
+ agentId,
79
+ pid: -1,
80
+ status: 'failed',
81
+ timestamp,
82
+ error: error instanceof Error ? error.message : String(error)
83
+ };
84
+ }
85
+ }
86
+ /**
87
+ * Spawn a worker with team configuration
88
+ */ async spawnWorker(config) {
89
+ const timestamp = new Date().toISOString();
90
+ const workerId = this.generateWorkerId(config.team);
91
+ try {
92
+ // Validate worker configuration
93
+ this.validateWorkerConfig(config);
94
+ // Load team provider configuration
95
+ const teamConfig = this.loadTeamConfig(config.team);
96
+ // Select model based on complexity
97
+ const model = this.selectModel(config.team, config.complexity);
98
+ // Get API key from environment
99
+ const apiKey = this.getApiKey(config.team, 'workers');
100
+ // Build environment for worker
101
+ const env = this.buildWorkerEnvironment(config, workerId, model, apiKey);
102
+ // Provider routing
103
+ this.routeWorkerProvider(config.providerMode, config.team, model, apiKey);
104
+ return {
105
+ agentId: workerId,
106
+ pid: 0,
107
+ status: 'spawned',
108
+ timestamp,
109
+ metadata: {
110
+ team: config.team,
111
+ complexity: config.complexity,
112
+ model,
113
+ provider: config.providerMode
114
+ }
115
+ };
116
+ } catch (error) {
117
+ return {
118
+ agentId: workerId,
119
+ pid: -1,
120
+ status: 'failed',
121
+ timestamp,
122
+ error: error instanceof Error ? error.message : String(error)
123
+ };
124
+ }
125
+ }
126
+ /**
127
+ * Validate that an agent type exists in the profiles directory
128
+ */ async validateAgentExists(agentType) {
129
+ // Normalize agent type (handle both underscore and hyphen variations)
130
+ const normalized = agentType.replace(/_/g, '-').toLowerCase();
131
+ // Check for agent profile in subdirectories
132
+ const possiblePaths = [
133
+ resolve(this.agentProfilesDir, `${normalized}.md`),
134
+ // Check in subdirectories
135
+ ...this.findAgentInSubdirs(normalized)
136
+ ];
137
+ return possiblePaths.some((path)=>existsSync(path));
138
+ }
139
+ /**
140
+ * Parse provider configuration from agent profile frontmatter
141
+ */ async parseAgentProvider(agentType) {
142
+ const agentPath = this.findAgentProfile(agentType);
143
+ if (!agentPath) {
144
+ return {
145
+ provider: 'zai',
146
+ model: 'glm-4.6'
147
+ };
148
+ }
149
+ try {
150
+ const content = readFileSync(agentPath, 'utf-8');
151
+ const providerMatch = content.match(/<!-- PROVIDER_PARAMETERS\s*([\s\S]*?)\s*-->/);
152
+ if (providerMatch) {
153
+ const params = providerMatch[1];
154
+ const providerMatch_ = params.match(/provider:\s*(\w+)/);
155
+ const modelMatch = params.match(/model:\s*([^\n]+)/);
156
+ return {
157
+ provider: providerMatch_?.[1] || 'zai',
158
+ model: modelMatch?.[1]?.trim() || 'glm-4.6'
159
+ };
160
+ }
161
+ } catch (error) {
162
+ // Silent fallback
163
+ }
164
+ return {
165
+ provider: 'zai',
166
+ model: 'glm-4.6'
167
+ };
168
+ }
169
+ /**
170
+ * Generate a unique agent ID
171
+ */ generateAgentId(agentType) {
172
+ const timestamp = Date.now();
173
+ const random = Math.random().toString(36).substring(2, 9);
174
+ return `agent-${agentType}-${timestamp}-${random}`;
175
+ }
176
+ /**
177
+ * Generate a unique worker ID
178
+ */ generateWorkerId(team) {
179
+ const uuid = uuidv4().substring(0, 8);
180
+ return `worker-${team}-${uuid}`;
181
+ }
182
+ /**
183
+ * Validate spawn configuration
184
+ */ validateSpawnConfig(config) {
185
+ const errors = [];
186
+ if (!config.agentType || typeof config.agentType !== 'string') {
187
+ errors.push('agentType must be a non-empty string');
188
+ }
189
+ if (!config.taskId || typeof config.taskId !== 'string') {
190
+ errors.push('taskId must be a non-empty string');
191
+ } else {
192
+ const taskIdValidation = this.validateTaskId(config.taskId);
193
+ if (!taskIdValidation.valid) {
194
+ errors.push(taskIdValidation.error || 'Invalid taskId format');
195
+ }
196
+ }
197
+ if (config.iteration === undefined || typeof config.iteration !== 'number') {
198
+ errors.push('iteration must be a number');
199
+ }
200
+ if (![
201
+ 'mvp',
202
+ 'standard',
203
+ 'enterprise'
204
+ ].includes(config.mode)) {
205
+ errors.push('mode must be mvp, standard, or enterprise');
206
+ }
207
+ if (errors.length > 0) {
208
+ throw new Error(`Configuration validation failed:\n${errors.join('\n')}`);
209
+ }
210
+ }
211
+ /**
212
+ * Validate worker configuration
213
+ */ validateWorkerConfig(config) {
214
+ const errors = [];
215
+ if (!config.team || typeof config.team !== 'string') {
216
+ errors.push('team must be a non-empty string');
217
+ }
218
+ if (![
219
+ 'simple',
220
+ 'complex'
221
+ ].includes(config.complexity)) {
222
+ errors.push('complexity must be simple or complex');
223
+ }
224
+ if (![
225
+ 'auto',
226
+ 'zai',
227
+ 'anthropic'
228
+ ].includes(config.providerMode)) {
229
+ errors.push('providerMode must be auto, zai, or anthropic');
230
+ }
231
+ if (errors.length > 0) {
232
+ throw new Error(`Worker configuration validation failed:\n${errors.join('\n')}`);
233
+ }
234
+ }
235
+ /**
236
+ * Validate task ID format (CVSS 8.9 - command injection prevention)
237
+ * Pattern: alphanumeric, underscore, hyphen, dot only, max 64 chars
238
+ */ validateTaskId(taskId) {
239
+ if (typeof taskId !== 'string' || taskId.length === 0) {
240
+ return {
241
+ valid: false,
242
+ error: 'Task ID must be a non-empty string'
243
+ };
244
+ }
245
+ const taskIdPattern = /^[a-zA-Z0-9_.-]{1,64}$/;
246
+ if (!taskIdPattern.test(taskId)) {
247
+ return {
248
+ valid: false,
249
+ error: 'Invalid task ID format - must contain only alphanumeric characters, dot, underscore, and hyphens (max 64 chars)'
250
+ };
251
+ }
252
+ return {
253
+ valid: true
254
+ };
255
+ }
256
+ /**
257
+ * Build environment variables for agent execution
258
+ */ buildEnvironment(config, agentId, provider, model) {
259
+ const env = {
260
+ ...process.env,
261
+ AGENT_ID: agentId,
262
+ AGENT_TYPE: config.agentType,
263
+ TASK_ID: config.taskId,
264
+ ITERATION: String(config.iteration),
265
+ MODE: config.mode,
266
+ PROVIDER: provider,
267
+ MODEL: model,
268
+ SPAWNED_AT: new Date().toISOString(),
269
+ PROJECT_ROOT: this.projectRoot
270
+ };
271
+ // Merge user-provided environment variables
272
+ if (config.env) {
273
+ Object.assign(env, config.env);
274
+ }
275
+ return env;
276
+ }
277
+ /**
278
+ * Build environment for worker process
279
+ */ buildWorkerEnvironment(config, workerId, model, apiKey) {
280
+ const env = {
281
+ ...process.env,
282
+ WORKER_ID: workerId,
283
+ TEAM: config.team,
284
+ COMPLEXITY: config.complexity,
285
+ MODEL: model,
286
+ API_KEY: apiKey,
287
+ PROJECT_ROOT: this.projectRoot
288
+ };
289
+ if (config.agentType) {
290
+ env.AGENT_TYPE = config.agentType;
291
+ }
292
+ if (config.taskContext) {
293
+ env.TASK_CONTEXT = config.taskContext;
294
+ }
295
+ return env;
296
+ }
297
+ /**
298
+ * Spawn the actual process
299
+ */ async spawnProcess(agentType, env, background = true) {
300
+ const args = [
301
+ 'src/cli/agent-executor.ts',
302
+ '--agent-type',
303
+ agentType
304
+ ];
305
+ const child = childSpawn('tsx', args, {
306
+ env,
307
+ stdio: background ? 'ignore' : 'inherit',
308
+ detached: background
309
+ });
310
+ const pid = child.pid || 0;
311
+ if (background) {
312
+ child.unref();
313
+ } else {
314
+ await new Promise((resolve, reject)=>{
315
+ child.on('exit', (code)=>{
316
+ if (code !== 0) {
317
+ reject(new Error(`Process exited with code ${code}`));
318
+ } else {
319
+ resolve(undefined);
320
+ }
321
+ });
322
+ });
323
+ }
324
+ return pid;
325
+ }
326
+ /**
327
+ * Find agent profile in directory structure
328
+ */ findAgentProfile(agentType) {
329
+ const normalized = agentType.replace(/_/g, '-').toLowerCase();
330
+ // Direct path
331
+ const directPath = resolve(this.agentProfilesDir, `${normalized}.md`);
332
+ if (existsSync(directPath)) {
333
+ return directPath;
334
+ }
335
+ // Search in subdirectories
336
+ const subdirs = [
337
+ 'developers',
338
+ 'testers',
339
+ 'reviewers',
340
+ 'architecture',
341
+ 'dev-ops',
342
+ 'product-owners',
343
+ 'coordinators',
344
+ 'analysts',
345
+ 'utility'
346
+ ];
347
+ for (const subdir of subdirs){
348
+ const path = resolve(this.agentProfilesDir, subdir, `${normalized}.md`);
349
+ if (existsSync(path)) {
350
+ return path;
351
+ }
352
+ // Check nested subdirectories
353
+ const nestedDirs = [
354
+ 'frontend',
355
+ 'backend',
356
+ 'database',
357
+ 'quality',
358
+ 'e2e',
359
+ 'unit',
360
+ 'validation',
361
+ 'data'
362
+ ];
363
+ for (const nested of nestedDirs){
364
+ const nestedPath = resolve(this.agentProfilesDir, subdir, nested, `${normalized}.md`);
365
+ if (existsSync(nestedPath)) {
366
+ return nestedPath;
367
+ }
368
+ }
369
+ }
370
+ return null;
371
+ }
372
+ /**
373
+ * Find agent in subdirectories
374
+ */ findAgentInSubdirs(normalized) {
375
+ const paths = [];
376
+ const subdirs = [
377
+ 'developers',
378
+ 'testers',
379
+ 'reviewers',
380
+ 'architecture',
381
+ 'dev-ops',
382
+ 'product-owners',
383
+ 'coordinators',
384
+ 'analysts',
385
+ 'utility'
386
+ ];
387
+ for (const subdir of subdirs){
388
+ const path = resolve(this.agentProfilesDir, subdir, `${normalized}.md`);
389
+ paths.push(path);
390
+ // Check nested directories
391
+ const nestedDirs = [
392
+ 'frontend',
393
+ 'backend',
394
+ 'database',
395
+ 'quality',
396
+ 'e2e',
397
+ 'unit',
398
+ 'validation',
399
+ 'data'
400
+ ];
401
+ for (const nested of nestedDirs){
402
+ paths.push(resolve(this.agentProfilesDir, subdir, nested, `${normalized}.md`));
403
+ }
404
+ }
405
+ return paths;
406
+ }
407
+ /**
408
+ * Load team configuration from config file
409
+ */ loadTeamConfig(team) {
410
+ if (!existsSync(this.agentConfigFile)) {
411
+ throw new Error(`Team configuration not found at ${this.agentConfigFile}`);
412
+ }
413
+ const content = readFileSync(this.agentConfigFile, 'utf-8');
414
+ const config = JSON.parse(content);
415
+ if (!config.teams || !config.teams[team]) {
416
+ throw new Error(`Invalid or missing provider configuration for team: ${team}`);
417
+ }
418
+ return config.teams[team];
419
+ }
420
+ /**
421
+ * Select model based on complexity
422
+ */ selectModel(team, complexity) {
423
+ const config = this.loadTeamConfig(team);
424
+ const workers = config.workers;
425
+ const models = workers?.models;
426
+ if (models && models[complexity]) {
427
+ return models[complexity];
428
+ }
429
+ // Fallback to default complexity
430
+ const defaultComplexity = 'simple';
431
+ if (models && models[defaultComplexity]) {
432
+ return models[defaultComplexity];
433
+ }
434
+ return 'gpt-4';
435
+ }
436
+ /**
437
+ * Get API key from environment
438
+ */ getApiKey(team, role) {
439
+ const config = this.loadTeamConfig(team);
440
+ const roleConfig = config[role];
441
+ if (!roleConfig) {
442
+ throw new Error(`No configuration found for team=${team}, role=${role}`);
443
+ }
444
+ const apiKeyEnvVar = roleConfig.apiKeyEnvVar;
445
+ if (!apiKeyEnvVar) {
446
+ throw new Error(`apiKeyEnvVar not configured for team=${team}, role=${role}`);
447
+ }
448
+ const apiKey = process.env[apiKeyEnvVar];
449
+ if (!apiKey) {
450
+ throw new Error(`API key not found in environment variable: ${apiKeyEnvVar}`);
451
+ }
452
+ return apiKey;
453
+ }
454
+ /**
455
+ * Route worker to appropriate provider
456
+ */ routeWorkerProvider(providerMode, team, model, apiKey) {
457
+ const config = this.loadTeamConfig(team);
458
+ const workers = config.workers;
459
+ const provider = workers?.provider;
460
+ const baseUrl = workers?.baseUrl;
461
+ switch(providerMode){
462
+ case 'auto':
463
+ this.routeAutoProvider(provider, baseUrl, model, apiKey);
464
+ break;
465
+ case 'zai':
466
+ process.env.ZAI_API_KEY = apiKey;
467
+ process.env.ZAI_BASE_URL = baseUrl;
468
+ process.env.ZAI_MODEL = model;
469
+ break;
470
+ case 'anthropic':
471
+ process.env.ANTHROPIC_API_KEY = apiKey;
472
+ process.env.ANTHROPIC_BASE_URL = baseUrl;
473
+ process.env.ANTHROPIC_MODEL = model;
474
+ break;
475
+ default:
476
+ throw new Error(`Invalid provider mode: ${providerMode}`);
477
+ }
478
+ }
479
+ /**
480
+ * Route to appropriate provider based on configuration
481
+ */ routeAutoProvider(provider, baseUrl, model, apiKey) {
482
+ switch(provider){
483
+ case 'zai':
484
+ process.env.ZAI_API_KEY = apiKey;
485
+ process.env.ZAI_BASE_URL = baseUrl;
486
+ process.env.ZAI_MODEL = model;
487
+ break;
488
+ case 'anthropic':
489
+ process.env.ANTHROPIC_API_KEY = apiKey;
490
+ process.env.ANTHROPIC_BASE_URL = baseUrl;
491
+ process.env.ANTHROPIC_MODEL = model;
492
+ break;
493
+ default:
494
+ throw new Error(`Unsupported provider: ${provider}`);
495
+ }
496
+ }
497
+ }
498
+
499
+ //# sourceMappingURL=agent-spawner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cli/agent-spawner.ts"],"sourcesContent":["/**\r\n * Agent Spawner Module\r\n *\r\n * High-level API for spawning agents with full type safety,\r\n * environment variable handling, provider configuration parsing,\r\n * and Redis coordination integration.\r\n *\r\n * Usage:\r\n * const spawner = new AgentSpawner();\r\n * const result = await spawner.spawnAgent({\r\n * agentType: 'backend-developer',\r\n * taskId: 'task-123',\r\n * iteration: 1,\r\n * mode: 'standard'\r\n * });\r\n */\r\n\r\nimport { existsSync, readFileSync } from 'fs';\r\nimport { resolve, join } from 'path';\r\nimport { execFileSync, spawn as childSpawn } from 'child_process';\r\nimport { v4 as uuidv4 } from 'uuid';\r\n\r\n/**\r\n * Configuration for spawning an agent\r\n */\r\ninterface SpawnAgentConfig {\r\n agentType: string;\r\n taskId: string;\r\n iteration: number;\r\n mode: 'mvp' | 'standard' | 'enterprise';\r\n provider?: string;\r\n model?: string;\r\n env?: Record<string, string>;\r\n background?: boolean;\r\n timeout?: number;\r\n}\r\n\r\n/**\r\n * Result of agent spawning operation\r\n */\r\ninterface SpawnResult {\r\n agentId: string;\r\n pid: number;\r\n status: 'spawned' | 'running' | 'failed';\r\n timestamp: string;\r\n error?: string;\r\n metadata?: Record<string, unknown>;\r\n}\r\n\r\n/**\r\n * Provider configuration parsed from agent profile\r\n */\r\ninterface ProviderConfig {\r\n provider: string;\r\n model: string;\r\n baseUrl?: string;\r\n}\r\n\r\n/**\r\n * Worker spawning configuration\r\n */\r\ninterface SpawnWorkerConfig {\r\n team: string;\r\n complexity: 'simple' | 'complex';\r\n providerMode: 'auto' | 'zai' | 'anthropic';\r\n agentType?: string;\r\n taskContext?: string;\r\n}\r\n\r\n/**\r\n * Validation result with optional error message\r\n */\r\ninterface ValidationResult {\r\n valid: boolean;\r\n error?: string;\r\n}\r\n\r\n/**\r\n * AgentSpawner class - Type-safe agent spawning with validation\r\n */\r\nexport class AgentSpawner {\r\n private projectRoot: string;\r\n private agentProfilesDir: string;\r\n private agentConfigFile: string;\r\n\r\n constructor(projectRoot?: string) {\r\n this.projectRoot = projectRoot || process.cwd();\r\n this.agentProfilesDir = resolve(this.projectRoot, '.claude/agents/cfn-dev-team');\r\n this.agentConfigFile = resolve(this.projectRoot, '.claude/cfn-config/team-providers.json');\r\n }\r\n\r\n /**\r\n * Spawn an agent with the given configuration\r\n */\r\n async spawnAgent(config: SpawnAgentConfig): Promise<SpawnResult> {\r\n const timestamp = new Date().toISOString();\r\n const agentId = this.generateAgentId(config.agentType);\r\n\r\n try {\r\n // Validate configuration\r\n this.validateSpawnConfig(config);\r\n\r\n // Check agent exists\r\n const agentExists = await this.validateAgentExists(config.agentType);\r\n if (!agentExists) {\r\n return {\r\n agentId,\r\n pid: -1,\r\n status: 'failed',\r\n timestamp,\r\n error: `Agent type not found: ${config.agentType}`\r\n };\r\n }\r\n\r\n // Parse provider configuration if not explicitly provided\r\n let provider = config.provider;\r\n let model = config.model;\r\n\r\n if (!provider || !model) {\r\n const providerConfig = await this.parseAgentProvider(config.agentType);\r\n provider = provider || providerConfig.provider;\r\n model = model || providerConfig.model;\r\n }\r\n\r\n // Build environment variables\r\n const env = this.buildEnvironment(config, agentId, provider, model);\r\n\r\n // Spawn the process\r\n const pid = await this.spawnProcess(config.agentType, env, config.background);\r\n\r\n return {\r\n agentId,\r\n pid,\r\n status: 'spawned',\r\n timestamp,\r\n metadata: {\r\n agentType: config.agentType,\r\n taskId: config.taskId,\r\n iteration: config.iteration,\r\n mode: config.mode,\r\n provider,\r\n model\r\n }\r\n };\r\n } catch (error) {\r\n return {\r\n agentId,\r\n pid: -1,\r\n status: 'failed',\r\n timestamp,\r\n error: error instanceof Error ? error.message : String(error)\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Spawn a worker with team configuration\r\n */\r\n async spawnWorker(config: SpawnWorkerConfig): Promise<SpawnResult> {\r\n const timestamp = new Date().toISOString();\r\n const workerId = this.generateWorkerId(config.team);\r\n\r\n try {\r\n // Validate worker configuration\r\n this.validateWorkerConfig(config);\r\n\r\n // Load team provider configuration\r\n const teamConfig = this.loadTeamConfig(config.team);\r\n\r\n // Select model based on complexity\r\n const model = this.selectModel(config.team, config.complexity);\r\n\r\n // Get API key from environment\r\n const apiKey = this.getApiKey(config.team, 'workers');\r\n\r\n // Build environment for worker\r\n const env = this.buildWorkerEnvironment(config, workerId, model, apiKey);\r\n\r\n // Provider routing\r\n this.routeWorkerProvider(config.providerMode, config.team, model, apiKey);\r\n\r\n return {\r\n agentId: workerId,\r\n pid: 0,\r\n status: 'spawned',\r\n timestamp,\r\n metadata: {\r\n team: config.team,\r\n complexity: config.complexity,\r\n model,\r\n provider: config.providerMode\r\n }\r\n };\r\n } catch (error) {\r\n return {\r\n agentId: workerId,\r\n pid: -1,\r\n status: 'failed',\r\n timestamp,\r\n error: error instanceof Error ? error.message : String(error)\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Validate that an agent type exists in the profiles directory\r\n */\r\n async validateAgentExists(agentType: string): Promise<boolean> {\r\n // Normalize agent type (handle both underscore and hyphen variations)\r\n const normalized = agentType.replace(/_/g, '-').toLowerCase();\r\n\r\n // Check for agent profile in subdirectories\r\n const possiblePaths = [\r\n resolve(this.agentProfilesDir, `${normalized}.md`),\r\n // Check in subdirectories\r\n ...this.findAgentInSubdirs(normalized)\r\n ];\r\n\r\n return possiblePaths.some(path => existsSync(path));\r\n }\r\n\r\n /**\r\n * Parse provider configuration from agent profile frontmatter\r\n */\r\n async parseAgentProvider(agentType: string): Promise<ProviderConfig> {\r\n const agentPath = this.findAgentProfile(agentType);\r\n\r\n if (!agentPath) {\r\n return {\r\n provider: 'zai',\r\n model: 'glm-4.6'\r\n };\r\n }\r\n\r\n try {\r\n const content = readFileSync(agentPath, 'utf-8');\r\n const providerMatch = content.match(/<!-- PROVIDER_PARAMETERS\\s*([\\s\\S]*?)\\s*-->/);\r\n\r\n if (providerMatch) {\r\n const params = providerMatch[1];\r\n const providerMatch_ = params.match(/provider:\\s*(\\w+)/);\r\n const modelMatch = params.match(/model:\\s*([^\\n]+)/);\r\n\r\n return {\r\n provider: providerMatch_?.[1] || 'zai',\r\n model: modelMatch?.[1]?.trim() || 'glm-4.6'\r\n };\r\n }\r\n } catch (error) {\r\n // Silent fallback\r\n }\r\n\r\n return {\r\n provider: 'zai',\r\n model: 'glm-4.6'\r\n };\r\n }\r\n\r\n /**\r\n * Generate a unique agent ID\r\n */\r\n private generateAgentId(agentType: string): string {\r\n const timestamp = Date.now();\r\n const random = Math.random().toString(36).substring(2, 9);\r\n return `agent-${agentType}-${timestamp}-${random}`;\r\n }\r\n\r\n /**\r\n * Generate a unique worker ID\r\n */\r\n private generateWorkerId(team: string): string {\r\n const uuid = uuidv4().substring(0, 8);\r\n return `worker-${team}-${uuid}`;\r\n }\r\n\r\n /**\r\n * Validate spawn configuration\r\n */\r\n private validateSpawnConfig(config: SpawnAgentConfig): void {\r\n const errors: string[] = [];\r\n\r\n if (!config.agentType || typeof config.agentType !== 'string') {\r\n errors.push('agentType must be a non-empty string');\r\n }\r\n\r\n if (!config.taskId || typeof config.taskId !== 'string') {\r\n errors.push('taskId must be a non-empty string');\r\n } else {\r\n const taskIdValidation = this.validateTaskId(config.taskId);\r\n if (!taskIdValidation.valid) {\r\n errors.push(taskIdValidation.error || 'Invalid taskId format');\r\n }\r\n }\r\n\r\n if (config.iteration === undefined || typeof config.iteration !== 'number') {\r\n errors.push('iteration must be a number');\r\n }\r\n\r\n if (!['mvp', 'standard', 'enterprise'].includes(config.mode)) {\r\n errors.push('mode must be mvp, standard, or enterprise');\r\n }\r\n\r\n if (errors.length > 0) {\r\n throw new Error(`Configuration validation failed:\\n${errors.join('\\n')}`);\r\n }\r\n }\r\n\r\n /**\r\n * Validate worker configuration\r\n */\r\n private validateWorkerConfig(config: SpawnWorkerConfig): void {\r\n const errors: string[] = [];\r\n\r\n if (!config.team || typeof config.team !== 'string') {\r\n errors.push('team must be a non-empty string');\r\n }\r\n\r\n if (!['simple', 'complex'].includes(config.complexity)) {\r\n errors.push('complexity must be simple or complex');\r\n }\r\n\r\n if (!['auto', 'zai', 'anthropic'].includes(config.providerMode)) {\r\n errors.push('providerMode must be auto, zai, or anthropic');\r\n }\r\n\r\n if (errors.length > 0) {\r\n throw new Error(`Worker configuration validation failed:\\n${errors.join('\\n')}`);\r\n }\r\n }\r\n\r\n /**\r\n * Validate task ID format (CVSS 8.9 - command injection prevention)\r\n * Pattern: alphanumeric, underscore, hyphen, dot only, max 64 chars\r\n */\r\n private validateTaskId(taskId: string): ValidationResult {\r\n if (typeof taskId !== 'string' || taskId.length === 0) {\r\n return { valid: false, error: 'Task ID must be a non-empty string' };\r\n }\r\n\r\n const taskIdPattern = /^[a-zA-Z0-9_.-]{1,64}$/;\r\n if (!taskIdPattern.test(taskId)) {\r\n return {\r\n valid: false,\r\n error: 'Invalid task ID format - must contain only alphanumeric characters, dot, underscore, and hyphens (max 64 chars)'\r\n };\r\n }\r\n\r\n return { valid: true };\r\n }\r\n\r\n /**\r\n * Build environment variables for agent execution\r\n */\r\n private buildEnvironment(\r\n config: SpawnAgentConfig,\r\n agentId: string,\r\n provider: string,\r\n model: string\r\n ): Record<string, string> {\r\n const env: Record<string, string> = {\r\n ...process.env as Record<string, string>,\r\n AGENT_ID: agentId,\r\n AGENT_TYPE: config.agentType,\r\n TASK_ID: config.taskId,\r\n ITERATION: String(config.iteration),\r\n MODE: config.mode,\r\n PROVIDER: provider,\r\n MODEL: model,\r\n SPAWNED_AT: new Date().toISOString(),\r\n PROJECT_ROOT: this.projectRoot\r\n };\r\n\r\n // Merge user-provided environment variables\r\n if (config.env) {\r\n Object.assign(env, config.env);\r\n }\r\n\r\n return env;\r\n }\r\n\r\n /**\r\n * Build environment for worker process\r\n */\r\n private buildWorkerEnvironment(\r\n config: SpawnWorkerConfig,\r\n workerId: string,\r\n model: string,\r\n apiKey: string\r\n ): Record<string, string> {\r\n const env: Record<string, string> = {\r\n ...process.env as Record<string, string>,\r\n WORKER_ID: workerId,\r\n TEAM: config.team,\r\n COMPLEXITY: config.complexity,\r\n MODEL: model,\r\n API_KEY: apiKey,\r\n PROJECT_ROOT: this.projectRoot\r\n };\r\n\r\n if (config.agentType) {\r\n env.AGENT_TYPE = config.agentType;\r\n }\r\n\r\n if (config.taskContext) {\r\n env.TASK_CONTEXT = config.taskContext;\r\n }\r\n\r\n return env;\r\n }\r\n\r\n /**\r\n * Spawn the actual process\r\n */\r\n private async spawnProcess(\r\n agentType: string,\r\n env: Record<string, string>,\r\n background: boolean = true\r\n ): Promise<number> {\r\n const args = [\r\n 'src/cli/agent-executor.ts',\r\n '--agent-type', agentType\r\n ];\r\n\r\n const child = childSpawn('tsx', args, {\r\n env,\r\n stdio: background ? 'ignore' : 'inherit',\r\n detached: background\r\n });\r\n\r\n const pid = child.pid || 0;\r\n\r\n if (background) {\r\n child.unref();\r\n } else {\r\n await new Promise((resolve, reject) => {\r\n child.on('exit', (code) => {\r\n if (code !== 0) {\r\n reject(new Error(`Process exited with code ${code}`));\r\n } else {\r\n resolve(undefined);\r\n }\r\n });\r\n });\r\n }\r\n\r\n return pid;\r\n }\r\n\r\n /**\r\n * Find agent profile in directory structure\r\n */\r\n private findAgentProfile(agentType: string): string | null {\r\n const normalized = agentType.replace(/_/g, '-').toLowerCase();\r\n\r\n // Direct path\r\n const directPath = resolve(this.agentProfilesDir, `${normalized}.md`);\r\n if (existsSync(directPath)) {\r\n return directPath;\r\n }\r\n\r\n // Search in subdirectories\r\n const subdirs = [\r\n 'developers', 'testers', 'reviewers', 'architecture',\r\n 'dev-ops', 'product-owners', 'coordinators', 'analysts', 'utility'\r\n ];\r\n\r\n for (const subdir of subdirs) {\r\n const path = resolve(this.agentProfilesDir, subdir, `${normalized}.md`);\r\n if (existsSync(path)) {\r\n return path;\r\n }\r\n\r\n // Check nested subdirectories\r\n const nestedDirs = ['frontend', 'backend', 'database', 'quality', 'e2e', 'unit', 'validation', 'data'];\r\n for (const nested of nestedDirs) {\r\n const nestedPath = resolve(this.agentProfilesDir, subdir, nested, `${normalized}.md`);\r\n if (existsSync(nestedPath)) {\r\n return nestedPath;\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Find agent in subdirectories\r\n */\r\n private findAgentInSubdirs(normalized: string): string[] {\r\n const paths: string[] = [];\r\n const subdirs = [\r\n 'developers', 'testers', 'reviewers', 'architecture',\r\n 'dev-ops', 'product-owners', 'coordinators', 'analysts', 'utility'\r\n ];\r\n\r\n for (const subdir of subdirs) {\r\n const path = resolve(this.agentProfilesDir, subdir, `${normalized}.md`);\r\n paths.push(path);\r\n\r\n // Check nested directories\r\n const nestedDirs = ['frontend', 'backend', 'database', 'quality', 'e2e', 'unit', 'validation', 'data'];\r\n for (const nested of nestedDirs) {\r\n paths.push(resolve(this.agentProfilesDir, subdir, nested, `${normalized}.md`));\r\n }\r\n }\r\n\r\n return paths;\r\n }\r\n\r\n /**\r\n * Load team configuration from config file\r\n */\r\n private loadTeamConfig(team: string): Record<string, unknown> {\r\n if (!existsSync(this.agentConfigFile)) {\r\n throw new Error(`Team configuration not found at ${this.agentConfigFile}`);\r\n }\r\n\r\n const content = readFileSync(this.agentConfigFile, 'utf-8');\r\n const config = JSON.parse(content);\r\n\r\n if (!config.teams || !config.teams[team]) {\r\n throw new Error(`Invalid or missing provider configuration for team: ${team}`);\r\n }\r\n\r\n return config.teams[team] as Record<string, unknown>;\r\n }\r\n\r\n /**\r\n * Select model based on complexity\r\n */\r\n private selectModel(team: string, complexity: 'simple' | 'complex'): string {\r\n const config = this.loadTeamConfig(team);\r\n const workers = config.workers as Record<string, unknown>;\r\n const models = workers?.models as Record<string, unknown>;\r\n\r\n if (models && models[complexity]) {\r\n return models[complexity] as string;\r\n }\r\n\r\n // Fallback to default complexity\r\n const defaultComplexity = 'simple';\r\n if (models && models[defaultComplexity]) {\r\n return models[defaultComplexity] as string;\r\n }\r\n\r\n return 'gpt-4';\r\n }\r\n\r\n /**\r\n * Get API key from environment\r\n */\r\n private getApiKey(team: string, role: 'coordinator' | 'workers'): string {\r\n const config = this.loadTeamConfig(team);\r\n const roleConfig = config[role] as Record<string, unknown>;\r\n\r\n if (!roleConfig) {\r\n throw new Error(`No configuration found for team=${team}, role=${role}`);\r\n }\r\n\r\n const apiKeyEnvVar = roleConfig.apiKeyEnvVar as string;\r\n\r\n if (!apiKeyEnvVar) {\r\n throw new Error(`apiKeyEnvVar not configured for team=${team}, role=${role}`);\r\n }\r\n\r\n const apiKey = process.env[apiKeyEnvVar];\r\n\r\n if (!apiKey) {\r\n throw new Error(`API key not found in environment variable: ${apiKeyEnvVar}`);\r\n }\r\n\r\n return apiKey;\r\n }\r\n\r\n /**\r\n * Route worker to appropriate provider\r\n */\r\n private routeWorkerProvider(\r\n providerMode: string,\r\n team: string,\r\n model: string,\r\n apiKey: string\r\n ): void {\r\n const config = this.loadTeamConfig(team);\r\n const workers = config.workers as Record<string, unknown>;\r\n const provider = workers?.provider as string;\r\n const baseUrl = workers?.baseUrl as string;\r\n\r\n switch (providerMode) {\r\n case 'auto':\r\n this.routeAutoProvider(provider, baseUrl, model, apiKey);\r\n break;\r\n case 'zai':\r\n process.env.ZAI_API_KEY = apiKey;\r\n process.env.ZAI_BASE_URL = baseUrl;\r\n process.env.ZAI_MODEL = model;\r\n break;\r\n case 'anthropic':\r\n process.env.ANTHROPIC_API_KEY = apiKey;\r\n process.env.ANTHROPIC_BASE_URL = baseUrl;\r\n process.env.ANTHROPIC_MODEL = model;\r\n break;\r\n default:\r\n throw new Error(`Invalid provider mode: ${providerMode}`);\r\n }\r\n }\r\n\r\n /**\r\n * Route to appropriate provider based on configuration\r\n */\r\n private routeAutoProvider(provider: string, baseUrl: string, model: string, apiKey: string): void {\r\n switch (provider) {\r\n case 'zai':\r\n process.env.ZAI_API_KEY = apiKey;\r\n process.env.ZAI_BASE_URL = baseUrl;\r\n process.env.ZAI_MODEL = model;\r\n break;\r\n case 'anthropic':\r\n process.env.ANTHROPIC_API_KEY = apiKey;\r\n process.env.ANTHROPIC_BASE_URL = baseUrl;\r\n process.env.ANTHROPIC_MODEL = model;\r\n break;\r\n default:\r\n throw new Error(`Unsupported provider: ${provider}`);\r\n }\r\n }\r\n}\r\n\r\nexport type { SpawnAgentConfig, SpawnResult, ProviderConfig, SpawnWorkerConfig };\r\n"],"names":["existsSync","readFileSync","resolve","spawn","childSpawn","v4","uuidv4","AgentSpawner","projectRoot","agentProfilesDir","agentConfigFile","process","cwd","spawnAgent","config","timestamp","Date","toISOString","agentId","generateAgentId","agentType","validateSpawnConfig","agentExists","validateAgentExists","pid","status","error","provider","model","providerConfig","parseAgentProvider","env","buildEnvironment","spawnProcess","background","metadata","taskId","iteration","mode","Error","message","String","spawnWorker","workerId","generateWorkerId","team","validateWorkerConfig","teamConfig","loadTeamConfig","selectModel","complexity","apiKey","getApiKey","buildWorkerEnvironment","routeWorkerProvider","providerMode","normalized","replace","toLowerCase","possiblePaths","findAgentInSubdirs","some","path","agentPath","findAgentProfile","content","providerMatch","match","params","providerMatch_","modelMatch","trim","now","random","Math","toString","substring","uuid","errors","push","taskIdValidation","validateTaskId","valid","undefined","includes","length","join","taskIdPattern","test","AGENT_ID","AGENT_TYPE","TASK_ID","ITERATION","MODE","PROVIDER","MODEL","SPAWNED_AT","PROJECT_ROOT","Object","assign","WORKER_ID","TEAM","COMPLEXITY","API_KEY","taskContext","TASK_CONTEXT","args","child","stdio","detached","unref","Promise","reject","on","code","directPath","subdirs","subdir","nestedDirs","nested","nestedPath","paths","JSON","parse","teams","workers","models","defaultComplexity","role","roleConfig","apiKeyEnvVar","baseUrl","routeAutoProvider","ZAI_API_KEY","ZAI_BASE_URL","ZAI_MODEL","ANTHROPIC_API_KEY","ANTHROPIC_BASE_URL","ANTHROPIC_MODEL"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,UAAU,EAAEC,YAAY,QAAQ,KAAK;AAC9C,SAASC,OAAO,QAAc,OAAO;AACrC,SAAuBC,SAASC,UAAU,QAAQ,gBAAgB;AAClE,SAASC,MAAMC,MAAM,QAAQ,OAAO;AAyDpC;;CAEC,GACD,OAAO,MAAMC;IACHC,YAAoB;IACpBC,iBAAyB;IACzBC,gBAAwB;IAEhC,YAAYF,WAAoB,CAAE;QAChC,IAAI,CAACA,WAAW,GAAGA,eAAeG,QAAQC,GAAG;QAC7C,IAAI,CAACH,gBAAgB,GAAGP,QAAQ,IAAI,CAACM,WAAW,EAAE;QAClD,IAAI,CAACE,eAAe,GAAGR,QAAQ,IAAI,CAACM,WAAW,EAAE;IACnD;IAEA;;GAEC,GACD,MAAMK,WAAWC,MAAwB,EAAwB;QAC/D,MAAMC,YAAY,IAAIC,OAAOC,WAAW;QACxC,MAAMC,UAAU,IAAI,CAACC,eAAe,CAACL,OAAOM,SAAS;QAErD,IAAI;YACF,yBAAyB;YACzB,IAAI,CAACC,mBAAmB,CAACP;YAEzB,qBAAqB;YACrB,MAAMQ,cAAc,MAAM,IAAI,CAACC,mBAAmB,CAACT,OAAOM,SAAS;YACnE,IAAI,CAACE,aAAa;gBAChB,OAAO;oBACL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xH,QAAQoB,GAAG,CAACwG,SAAS,GAAG3G;gBACxB;YACF,KAAK;gBACHjB,QAAQoB,GAAG,CAACyG,iBAAiB,GAAGrF;gBAChCxC,QAAQoB,GAAG,CAAC0G,kBAAkB,GAAGN;gBACjCxH,QAAQoB,GAAG,CAAC2G,eAAe,GAAG9G;gBAC9B;YACF;gBACE,MAAM,IAAIW,MAAM,CAAC,uBAAuB,EAAEgB,cAAc;QAC5D;IACF;IAEA;;GAEC,GACD,AAAQ6E,kBAAkBzG,QAAgB,EAAEwG,OAAe,EAAEvG,KAAa,EAAEuB,MAAc,EAAQ;QAChG,OAAQxB;YACN,KAAK;gBACHhB,QAAQoB,GAAG,CAACsG,WAAW,GAAGlF;gBAC1BxC,QAAQoB,GAAG,CAACuG,YAAY,GAAGH;gBAC3BxH,QAAQoB,GAAG,CAACwG,SAAS,GAAG3G;gBACxB;YACF,KAAK;gBACHjB,QAAQoB,GAAG,CAACyG,iBAAiB,GAAGrF;gBAChCxC,QAAQoB,GAAG,CAAC0G,kBAAkB,GAAGN;gBACjCxH,QAAQoB,GAAG,CAAC2G,eAAe,GAAG9G;gBAC9B;YACF;gBACE,MAAM,IAAIW,MAAM,CAAC,sBAAsB,EAAEZ,UAAU;QACvD;IACF;AACF"}
@@ -124,8 +124,8 @@ const execAsync = promisify(exec);
124
124
  let model = mapModelName(options.model, config.provider);
125
125
  const maxTokens = options.maxTokens || 16000; // Sprint 6: 16K hard limit for GLM-4.6 (agents target 10K for buffer)
126
126
  const temperature = options.temperature ?? 1.0;
127
- // Disable streaming for Z.ai (compatibility issue)
128
- const enableStreaming = options.stream && config.provider !== 'zai';
127
+ // Streaming supported for both providers; retry without streaming if a provider rejects it
128
+ let enableStreaming = !!options.stream;
129
129
  console.log(`[anthropic-client] Provider: ${config.provider}`);
130
130
  console.log(`[anthropic-client] Model: ${model}`);
131
131
  console.log(`[anthropic-client] Max tokens: ${maxTokens}`);
@@ -168,7 +168,7 @@ const execAsync = promisify(exec);
168
168
  requestParams.tools = options.tools;
169
169
  }
170
170
  try {
171
- // Streaming response
171
+ // Streaming response (preferred)
172
172
  if (enableStreaming) {
173
173
  let fullContent = '';
174
174
  let inputTokens = 0;
@@ -220,6 +220,13 @@ const execAsync = promisify(exec);
220
220
  stopReason: response.stop_reason || 'end_turn'
221
221
  };
222
222
  } catch (error) {
223
+ // If streaming fails on Z.ai, retry once without streaming before falling back to model fallback logic
224
+ if (enableStreaming && config.provider === 'zai') {
225
+ console.warn('[anthropic-client] Streaming failed on z.ai, retrying without streaming:', error);
226
+ enableStreaming = false;
227
+ attempts--; // do not consume a model attempt
228
+ continue;
229
+ }
223
230
  lastError = error instanceof Error ? error : new Error(String(error));
224
231
  console.error(`[anthropic-client] Error with model ${currentModel}:`, lastError.message);
225
232
  // If this was the last attempt, throw the error