claude-flow-novice 2.18.5 → 2.18.6

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 (1023) hide show
  1. package/.claude/.cfn-initialized +1 -0
  2. package/.claude/FILE_MANIFEST.md +50 -0
  3. package/.claude/MANIFEST_INDEX.md +224 -0
  4. package/.claude/MANIFEST_README.md +308 -0
  5. package/.claude/TRIGGER_TASKS_MANIFEST.md +11 -0
  6. package/.claude/WORKING-SETUP.md +67 -0
  7. package/.claude/adaptive-context/cfn-v3-reflection.json +21 -0
  8. package/.claude/agent-principles/SPARSE_LANGUAGE_FINDINGS.md +991 -0
  9. package/.claude/agent-principles/agent-template.md +96 -0
  10. package/.claude/agent-principles/prompt-engineering.md +501 -0
  11. package/.claude/agents/AGENT_LIFECYCLE.md +532 -0
  12. package/.claude/agents/README-AGENT_LIFECYCLE.md +522 -0
  13. package/.claude/agents/README-VALIDATION.md +243 -0
  14. package/.claude/agents/SHARED_PROTOCOL.md +64 -0
  15. package/.claude/agents/cfn-dev-team/CLAUDE.md +1000 -0
  16. package/.claude/agents/cfn-dev-team/README.md +219 -0
  17. package/.claude/agents/cfn-dev-team/analysts/analyst.md +120 -0
  18. package/.claude/agents/cfn-dev-team/analysts/root-cause-analyst.md +264 -0
  19. package/.claude/agents/cfn-dev-team/architecture/api-designer-persona.md +152 -0
  20. package/.claude/agents/cfn-dev-team/architecture/base-template-generator.md +157 -0
  21. package/.claude/agents/cfn-dev-team/architecture/goal-planner.md +180 -0
  22. package/.claude/agents/cfn-dev-team/architecture/planner.md +139 -0
  23. package/.claude/agents/cfn-dev-team/architecture/system-architect.md +132 -0
  24. package/.claude/agents/cfn-dev-team/coordinators/README.md +42 -0
  25. package/.claude/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +893 -0
  26. package/.claude/agents/cfn-dev-team/coordinators/consensus-builder.md +480 -0
  27. package/.claude/agents/cfn-dev-team/coordinators/handoff-coordinator.md +747 -0
  28. package/.claude/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +510 -0
  29. package/.claude/agents/cfn-dev-team/dev-ops/devops-engineer.md +157 -0
  30. package/.claude/agents/cfn-dev-team/dev-ops/docker-specialist.md +671 -0
  31. package/.claude/agents/cfn-dev-team/dev-ops/github-commit-agent.md +123 -0
  32. package/.claude/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +624 -0
  33. package/.claude/agents/cfn-dev-team/developers/README.md +69 -0
  34. package/.claude/agents/cfn-dev-team/developers/api-gateway-specialist.md +977 -0
  35. package/.claude/agents/cfn-dev-team/developers/backend-developer-cerebras.md +210 -0
  36. package/.claude/agents/cfn-dev-team/developers/backend-developer.md +206 -0
  37. package/.claude/agents/cfn-dev-team/developers/data/data-engineer.md +672 -0
  38. package/.claude/agents/cfn-dev-team/developers/database/database-architect.md +376 -0
  39. package/.claude/agents/cfn-dev-team/developers/database/supabase-specialist.md +746 -0
  40. package/.claude/agents/cfn-dev-team/developers/frontend/mobile-dev.md +247 -0
  41. package/.claude/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +272 -0
  42. package/.claude/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +396 -0
  43. package/.claude/agents/cfn-dev-team/developers/frontend/ui-designer.md +221 -0
  44. package/.claude/agents/cfn-dev-team/developers/graphql-specialist.md +707 -0
  45. package/.claude/agents/cfn-dev-team/developers/rust-developer.md +228 -0
  46. package/.claude/agents/cfn-dev-team/documentation/README-VALIDATION.md +245 -0
  47. package/.claude/agents/cfn-dev-team/documentation/agent-type-guidelines.md +476 -0
  48. package/.claude/agents/cfn-dev-team/documentation/api-documentation.md +111 -0
  49. package/.claude/agents/cfn-dev-team/documentation/pseudocode.md +144 -0
  50. package/.claude/agents/cfn-dev-team/documentation/specification-agent.md +152 -0
  51. package/.claude/agents/cfn-dev-team/product-owners/accessibility-advocate-persona.md +119 -0
  52. package/.claude/agents/cfn-dev-team/product-owners/cto-agent.md +138 -0
  53. package/.claude/agents/cfn-dev-team/product-owners/power-user-persona.md +151 -0
  54. package/.claude/agents/cfn-dev-team/product-owners/product-owner.md +483 -0
  55. package/.claude/agents/cfn-dev-team/reviewers/README.md +58 -0
  56. package/.claude/agents/cfn-dev-team/reviewers/code-reviewer.md +303 -0
  57. package/.claude/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +220 -0
  58. package/.claude/agents/cfn-dev-team/reviewers/quality/cyclomatic-complexity-reducer.md +334 -0
  59. package/.claude/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +257 -0
  60. package/.claude/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +160 -0
  61. package/.claude/agents/cfn-dev-team/reviewers/quality/quality-metrics.md +386 -0
  62. package/.claude/agents/cfn-dev-team/testers/README.md +94 -0
  63. package/.claude/agents/cfn-dev-team/testers/api-testing-specialist.md +757 -0
  64. package/.claude/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +944 -0
  65. package/.claude/agents/cfn-dev-team/testers/contract-tester.md +687 -0
  66. package/.claude/agents/cfn-dev-team/testers/e2e/playwright-tester.md +124 -0
  67. package/.claude/agents/cfn-dev-team/testers/integration-tester.md +785 -0
  68. package/.claude/agents/cfn-dev-team/testers/interaction-tester.md +188 -0
  69. package/.claude/agents/cfn-dev-team/testers/load-testing-specialist.md +505 -0
  70. package/.claude/agents/cfn-dev-team/testers/mutation-testing-specialist.md +643 -0
  71. package/.claude/agents/cfn-dev-team/testers/playwright-tester.md +253 -0
  72. package/.claude/agents/cfn-dev-team/testers/tester.md +224 -0
  73. package/.claude/agents/cfn-dev-team/testers/unit/tdd-london-unit-swarm.md +37 -0
  74. package/.claude/agents/cfn-dev-team/testers/validation/validation-production-validator.md +27 -0
  75. package/.claude/agents/cfn-dev-team/testing/test-validation-agent.md +280 -0
  76. package/.claude/agents/cfn-dev-team/utility/agent-builder.md +487 -0
  77. package/.claude/agents/cfn-dev-team/utility/context-curator.md +69 -0
  78. package/.claude/agents/cfn-dev-team/utility/epic-creator-v2.md +2 -0
  79. package/.claude/agents/cfn-dev-team/utility/epic-creator.md +7 -0
  80. package/.claude/agents/cfn-dev-team/utility/memory-leak-specialist.md +177 -0
  81. package/.claude/agents/cfn-dev-team/utility/researcher.md +116 -0
  82. package/.claude/agents/cfn-dev-team/utility/z-ai-specialist.md +218 -0
  83. package/.claude/agents/csuite/cto-agent.md +371 -0
  84. package/.claude/agents/custom/cfn-docker-expert.md +132 -0
  85. package/.claude/agents/custom/cfn-loops-cli-expert.md +9 -0
  86. package/.claude/agents/custom/cfn-redis-operations.md +538 -0
  87. package/.claude/agents/custom/cfn-system-expert.md +489 -0
  88. package/.claude/agents/custom/claude-code-expert.md +298 -0
  89. package/.claude/agents/custom/mdap-trigger-specialist.md +82 -0
  90. package/.claude/agents/custom/trigger-dev-expert.md +386 -0
  91. package/.claude/agents/docker-coordinators/cfn-docker-v3-coordinator.md +1101 -0
  92. package/.claude/agents/docker-ts-fixer.md +65 -0
  93. package/.claude/agents/project-only-agents/npm-package-specialist.md +334 -0
  94. package/.claude/agents/validate-agent.js +841 -0
  95. package/.claude/cfn-config/team-providers.json +102 -0
  96. package/.claude/cfn-extras/.gs-api-quota.json +16 -0
  97. package/.claude/cfn-extras/.gs-progress-state.json +22 -0
  98. package/.claude/cfn-extras/agents/cfn-coordinator-enterprise.md +1303 -0
  99. package/.claude/cfn-extras/agents/cfn-coordinator-mvp.md +942 -0
  100. package/.claude/cfn-extras/agents/cfn-coordinator-standard.md +1062 -0
  101. package/.claude/cfn-extras/agents/cfn-loop-coordinator.md +157 -0
  102. package/.claude/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
  103. package/.claude/cfn-extras/agents/code-booster.md +67 -0
  104. package/.claude/cfn-extras/agents/coordinator.md +182 -0
  105. package/.claude/cfn-extras/agents/cost-savings-cfn-loop-coordinator.md +760 -0
  106. package/.claude/cfn-extras/agents/cost-savings-coordinator.md +173 -0
  107. package/.claude/cfn-extras/agents/deprecated-coordinators/adaptive-coordinator-enhanced.md +147 -0
  108. package/.claude/cfn-extras/agents/deprecated-coordinators/adaptive-coordinator.md +162 -0
  109. package/.claude/cfn-extras/agents/deprecated-coordinators/blocking-coordinator-example.md +729 -0
  110. package/.claude/cfn-extras/agents/deprecated-coordinators/byzantine-coordinator.md +100 -0
  111. package/.claude/cfn-extras/agents/deprecated-coordinators/cfn-coordinator-enterprise.md +323 -0
  112. package/.claude/cfn-extras/agents/deprecated-coordinators/cfn-coordinator-mvp.md +157 -0
  113. package/.claude/cfn-extras/agents/deprecated-coordinators/cfn-coordinator-standard.md +229 -0
  114. package/.claude/cfn-extras/agents/deprecated-coordinators/cfn-coordinator-unified.md +149 -0
  115. package/.claude/cfn-extras/agents/deprecated-coordinators/coordinator-hybrid.md +231 -0
  116. package/.claude/cfn-extras/agents/deprecated-coordinators/gossip-coordinator.md +165 -0
  117. package/.claude/cfn-extras/agents/deprecated-coordinators/hierarchical-coordinator.md +95 -0
  118. package/.claude/cfn-extras/agents/deprecated-coordinators/mesh-coordinator.md +132 -0
  119. package/.claude/cfn-extras/agents/deprecated-coordinators/task-coordinator.md +109 -0
  120. package/.claude/cfn-extras/agents/deprecated-coordinators/test-coordinator.md +142 -0
  121. package/.claude/cfn-extras/agents/docker-team/csuite/c-suite-template.md +529 -0
  122. package/.claude/cfn-extras/agents/docker-team/infrastructure/team-coordinator-template.md +467 -0
  123. package/.claude/cfn-extras/agents/docker-team/micro-sprint-planner.md +747 -0
  124. package/.claude/cfn-extras/agents/google-sheets/README.md +114 -0
  125. package/.claude/cfn-extras/agents/google-sheets/google-sheets-advanced-analytics-specialist.md +288 -0
  126. package/.claude/cfn-extras/agents/google-sheets/google-sheets-api-integrator.md +127 -0
  127. package/.claude/cfn-extras/agents/google-sheets/google-sheets-automation-scripting-specialist.md +195 -0
  128. package/.claude/cfn-extras/agents/google-sheets/google-sheets-business-validator.md +179 -0
  129. package/.claude/cfn-extras/agents/google-sheets/google-sheets-collaboration-security-specialist.md +240 -0
  130. package/.claude/cfn-extras/agents/google-sheets/google-sheets-coordinator.md +214 -0
  131. package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-transformer.md +127 -0
  132. package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-validation-quality-specialist.md +177 -0
  133. package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-validator.md +119 -0
  134. package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-visualization-specialist.md +135 -0
  135. package/.claude/cfn-extras/agents/google-sheets/google-sheets-design-layout-specialist.md +109 -0
  136. package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-engineer.md +127 -0
  137. package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-engineering-specialist.md +138 -0
  138. package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-validator.md +128 -0
  139. package/.claude/cfn-extras/agents/google-sheets/google-sheets-generalist.md +645 -0
  140. package/.claude/cfn-extras/agents/google-sheets/google-sheets-integration-api-specialist.md +258 -0
  141. package/.claude/cfn-extras/agents/google-sheets/google-sheets-performance-analyst.md +125 -0
  142. package/.claude/cfn-extras/agents/google-sheets/google-sheets-performance-optimization-specialist.md +211 -0
  143. package/.claude/cfn-extras/agents/google-sheets/google-sheets-schema-designer.md +130 -0
  144. package/.claude/cfn-extras/agents/google-sheets/google-sheets-template-architecture-specialist.md +259 -0
  145. package/.claude/cfn-extras/agents/google-sheets-specialist.md +614 -0
  146. package/.claude/cfn-extras/commands/cfn-docker/CFN_DOCKER_CLI.md +527 -0
  147. package/.claude/cfn-extras/commands/cfn-docker/CFN_DOCKER_LOOP.md +377 -0
  148. package/.claude/cfn-extras/commands/cfn-docker/CFN_DOCKER_NATIVE.md +295 -0
  149. package/.claude/cfn-extras/commands/cfn-docker/CFN_DOCKER_TASK.md +490 -0
  150. package/.claude/cfn-extras/commands/cfn-docker/cfn-docker-core-test-suite.md +326 -0
  151. package/.claude/cfn-extras/commands/deprecated/CFN_EXPERT_UPDATE.md +142 -0
  152. package/.claude/cfn-extras/commands/deprecated/README.md +55 -0
  153. package/.claude/cfn-extras/commands/deprecated/cfn-loop-epic.md +478 -0
  154. package/.claude/cfn-extras/commands/deprecated/cfn-loop-single.md +256 -0
  155. package/.claude/cfn-extras/commands/deprecated/cfn-loop-sprints.md +396 -0
  156. package/.claude/cfn-extras/commands/deprecated/context-curate.md +200 -0
  157. package/.claude/cfn-extras/commands/deprecated/context-inject.md +251 -0
  158. package/.claude/cfn-extras/commands/deprecated/context-query.md +210 -0
  159. package/.claude/cfn-extras/commands/deprecated/context-stats.md +269 -0
  160. package/.claude/cfn-extras/commands/deprecated/cost-savings-off.md +35 -0
  161. package/.claude/cfn-extras/commands/deprecated/cost-savings-on.md +35 -0
  162. package/.claude/cfn-extras/commands/deprecated/custom-routing-activate.md +55 -0
  163. package/.claude/cfn-extras/commands/deprecated/custom-routing-deactivate.md +46 -0
  164. package/.claude/cfn-extras/commands/deprecated/github-commit.md +289 -0
  165. package/.claude/cfn-extras/commands/deprecated/github.md +221 -0
  166. package/.claude/cfn-extras/commands/deprecated/hello-world-tests.md +381 -0
  167. package/.claude/cfn-extras/commands/deprecated/parse-epic.md +357 -0
  168. package/.claude/cfn-extras/commands/deprecated/run-tests.md +119 -0
  169. package/.claude/cfn-extras/commands/deprecated/suggest-improvements.md +95 -0
  170. package/.claude/cfn-extras/commands/google-sheets/google-sheets-loop.md +289 -0
  171. package/.claude/cfn-extras/docs/GOOGLE_SHEETS_CFN_LOOP.md +619 -0
  172. package/.claude/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +453 -0
  173. package/.claude/cfn-extras/skills/advanced-features/cfn-agent-swap/SKILL.md +36 -0
  174. package/.claude/cfn-extras/skills/advanced-features/cfn-agent-swap/recommend-swap.sh +60 -0
  175. package/.claude/cfn-extras/skills/advanced-features/cfn-api-validation/test-endpoints.sh +54 -0
  176. package/.claude/cfn-extras/skills/advanced-features/cfn-context-pruner/SKILL.md +75 -0
  177. package/.claude/cfn-extras/skills/advanced-features/cfn-context-pruner/prune-context.sh +73 -0
  178. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/README.md +299 -0
  179. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/SKILL.md +412 -0
  180. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/config.json +111 -0
  181. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/eventbus-wrapper.cjs +69 -0
  182. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/invoke-event-publish.sh +147 -0
  183. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/invoke-event-subscribe.sh +171 -0
  184. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/invoke-lifecycle-track.sh +201 -0
  185. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/test-event-bus.sh +280 -0
  186. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/README.md +74 -0
  187. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/SKILL.md +412 -0
  188. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/config.json +60 -0
  189. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/invoke-fleet-allocate.sh +182 -0
  190. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/invoke-fleet-balance.sh +239 -0
  191. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/invoke-fleet-metrics.sh +193 -0
  192. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/invoke-fleet-register.sh +124 -0
  193. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/test-fleet-manager.sh +345 -0
  194. package/.claude/cfn-extras/skills/advanced-features/cfn-task-mode-safety/cli-coordination.sh +519 -0
  195. package/.claude/cfn-extras/skills/advanced-features/cfn-task-mode-safety/mode-detection.sh +326 -0
  196. package/.claude/cfn-extras/skills/advanced-features/cfn-task-mode-sanitize/task-mode-env-sanitizer.sh +267 -0
  197. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/SKILL.md +40 -0
  198. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/agents-registry-clean.json +0 -0
  199. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/agents-registry-fixed.json +19 -0
  200. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/agents-registry.json +719 -0
  201. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/discover-agents.py +184 -0
  202. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/discover-agents.sh +87 -0
  203. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/invoke-registry.sh +11 -0
  204. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/temp_script.py +0 -0
  205. package/.claude/cfn-extras/skills/deprecated/cfn-agent-selector/SKILL.md +91 -0
  206. package/.claude/cfn-extras/skills/deprecated/cfn-agent-selector/select-agents.sh +112 -0
  207. package/.claude/cfn-extras/skills/deprecated/cfn-cli-setup/validate-cli-environment.sh +192 -0
  208. package/.claude/cfn-extras/skills/deprecated/cfn-simplified-agent-lifecycle/DESIGN.md +98 -0
  209. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +272 -0
  210. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh +254 -0
  211. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/test.sh +174 -0
  212. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/validate.sh +98 -0
  213. package/.claude/cfn-extras/skills/google-sheets-decomposition/SKILL.md +269 -0
  214. package/.claude/cfn-extras/skills/google-sheets-decomposition/decompose.sh +313 -0
  215. package/.claude/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +237 -0
  216. package/.claude/cfn-extras/skills/google-sheets-formula-builder/build-formula.sh +220 -0
  217. package/.claude/cfn-extras/skills/google-sheets-formula-builder/test.sh +172 -0
  218. package/.claude/cfn-extras/skills/google-sheets-formula-builder/validate.sh +98 -0
  219. package/.claude/cfn-extras/skills/google-sheets-progress/SKILL.md +287 -0
  220. package/.claude/cfn-extras/skills/google-sheets-progress/test.sh +385 -0
  221. package/.claude/cfn-extras/skills/google-sheets-progress/track-progress.sh +516 -0
  222. package/.claude/cfn-extras/skills/google-sheets-progress/validate.sh +119 -0
  223. package/.claude/cfn-extras/skills/google-sheets-sprint-order/SKILL.md +277 -0
  224. package/.claude/cfn-extras/skills/google-sheets-sprint-order/order-sprints.sh +233 -0
  225. package/.claude/cfn-extras/skills/google-sheets-validation/SKILL.md +352 -0
  226. package/.claude/cfn-extras/skills/google-sheets-validation/test.sh +355 -0
  227. package/.claude/cfn-extras/skills/google-sheets-validation/validate-state.sh +374 -0
  228. package/.claude/cfn-extras/skills/google-sheets-validation/validate.sh +128 -0
  229. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/SKILL.md +392 -0
  230. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/create-campaign.sh +231 -0
  231. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/get-campaign-performance.sh +190 -0
  232. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/pause-campaign.sh +142 -0
  233. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/set-budget.sh +181 -0
  234. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/update-bid-strategy.sh +133 -0
  235. package/.claude/cfn-extras/skills/marketing/cfn-marketing-analytics-data/SKILL.md +124 -0
  236. package/.claude/cfn-extras/skills/marketing/cfn-marketing-analytics-data/operations/get-ad-performance.sh +105 -0
  237. package/.claude/cfn-extras/skills/marketing/cfn-marketing-analytics-data/operations/get-conversion-funnel.sh +102 -0
  238. package/.claude/cfn-extras/skills/marketing/cfn-marketing-analytics-data/operations/get-email-performance.sh +105 -0
  239. package/.claude/cfn-extras/skills/marketing/cfn-marketing-analytics-data/operations/get-social-engagement.sh +105 -0
  240. package/.claude/cfn-extras/skills/marketing/cfn-marketing-analytics-data/operations/get-website-traffic.sh +107 -0
  241. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/SKILL.md +340 -0
  242. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/get-conversation-history.sh +121 -0
  243. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/qualify-lead.sh +156 -0
  244. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/schedule-demo.sh +181 -0
  245. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/send-message.sh +137 -0
  246. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/transfer-to-human.sh +179 -0
  247. package/.claude/cfn-extras/skills/marketing/cfn-marketing-competitive-intel/SKILL.md +350 -0
  248. package/.claude/cfn-extras/skills/marketing/cfn-marketing-competitive-intel/operations/get-backlink-profile.sh +154 -0
  249. package/.claude/cfn-extras/skills/marketing/cfn-marketing-competitive-intel/operations/get-keyword-rankings.sh +173 -0
  250. package/.claude/cfn-extras/skills/marketing/cfn-marketing-competitive-intel/operations/get-trending-topics.sh +147 -0
  251. package/.claude/cfn-extras/skills/marketing/cfn-marketing-competitive-intel/operations/monitor-competitor.sh +146 -0
  252. package/.claude/cfn-extras/skills/marketing/cfn-marketing-competitive-intel/operations/search-brand-mentions.sh +167 -0
  253. package/.claude/cfn-extras/skills/marketing/cfn-marketing-crm-contacts/SKILL.md +116 -0
  254. package/.claude/cfn-extras/skills/marketing/cfn-marketing-crm-contacts/operations/add-to-segment.sh +78 -0
  255. package/.claude/cfn-extras/skills/marketing/cfn-marketing-crm-contacts/operations/create-contact.sh +113 -0
  256. package/.claude/cfn-extras/skills/marketing/cfn-marketing-crm-contacts/operations/get-contact.sh +86 -0
  257. package/.claude/cfn-extras/skills/marketing/cfn-marketing-crm-contacts/operations/remove-from-segment.sh +78 -0
  258. package/.claude/cfn-extras/skills/marketing/cfn-marketing-crm-contacts/operations/update-contact.sh +120 -0
  259. package/.claude/cfn-extras/skills/marketing/cfn-marketing-email-campaigns/SKILL.md +106 -0
  260. package/.claude/cfn-extras/skills/marketing/cfn-marketing-email-campaigns/operations/create-campaign.sh +123 -0
  261. package/.claude/cfn-extras/skills/marketing/cfn-marketing-email-campaigns/operations/get-campaign-stats.sh +66 -0
  262. package/.claude/cfn-extras/skills/marketing/cfn-marketing-email-campaigns/operations/list-templates.sh +68 -0
  263. package/.claude/cfn-extras/skills/marketing/cfn-marketing-email-campaigns/operations/schedule-campaign.sh +85 -0
  264. package/.claude/cfn-extras/skills/marketing/cfn-marketing-email-campaigns/operations/send-test-email.sh +81 -0
  265. package/.claude/cfn-extras/skills/marketing/cfn-marketing-landing-pages/SKILL.md +366 -0
  266. package/.claude/cfn-extras/skills/marketing/cfn-marketing-landing-pages/operations/create-ab-test.sh +231 -0
  267. package/.claude/cfn-extras/skills/marketing/cfn-marketing-landing-pages/operations/create-landing-page.sh +190 -0
  268. package/.claude/cfn-extras/skills/marketing/cfn-marketing-landing-pages/operations/get-page-performance.sh +137 -0
  269. package/.claude/cfn-extras/skills/marketing/cfn-marketing-landing-pages/operations/publish-page.sh +120 -0
  270. package/.claude/cfn-extras/skills/marketing/cfn-marketing-landing-pages/operations/unpublish-page.sh +108 -0
  271. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-monitoring/SKILL.md +202 -0
  272. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-monitoring/operations/create-crisis-alert.sh +104 -0
  273. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-monitoring/operations/export-report.sh +92 -0
  274. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-monitoring/operations/get-sentiment-analysis.sh +85 -0
  275. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-monitoring/operations/search-mentions.sh +86 -0
  276. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-outreach/SKILL.md +168 -0
  277. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-outreach/operations/search-journalists.sh +74 -0
  278. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-outreach/operations/send-pitch.sh +80 -0
  279. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-outreach/operations/submit-haro-response.sh +88 -0
  280. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-outreach/operations/track-pitch-engagement.sh +66 -0
  281. package/.claude/cfn-extras/skills/marketing/cfn-marketing-press-distribution/SKILL.md +159 -0
  282. package/.claude/cfn-extras/skills/marketing/cfn-marketing-press-distribution/operations/distribute-press-release.sh +94 -0
  283. package/.claude/cfn-extras/skills/marketing/cfn-marketing-press-distribution/operations/get-distribution-status.sh +59 -0
  284. package/.claude/cfn-extras/skills/marketing/cfn-marketing-press-distribution/operations/get-pickup-metrics.sh +72 -0
  285. package/.claude/cfn-extras/skills/marketing/cfn-marketing-press-distribution/operations/list-templates.sh +53 -0
  286. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/SKILL.md +429 -0
  287. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/create-campaign.sh +183 -0
  288. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/get-delivery-status.sh +139 -0
  289. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/opt-out.sh +150 -0
  290. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/schedule-campaign.sh +187 -0
  291. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/send-sms.sh +181 -0
  292. package/.claude/cfn-extras/skills/marketing/cfn-marketing-social-publishing/SKILL.md +108 -0
  293. package/.claude/cfn-extras/skills/marketing/cfn-marketing-social-publishing/operations/create-post.sh +104 -0
  294. package/.claude/cfn-extras/skills/marketing/cfn-marketing-social-publishing/operations/delete-post.sh +76 -0
  295. package/.claude/cfn-extras/skills/marketing/cfn-marketing-social-publishing/operations/get-post-stats.sh +66 -0
  296. package/.claude/cfn-extras/skills/marketing/cfn-marketing-social-publishing/operations/schedule-post.sh +85 -0
  297. package/.claude/cfn-extras/skills/marketing/cfn-marketing-social-publishing/operations/upload-media.sh +88 -0
  298. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/DESIGN.md +117 -0
  299. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/SKILL.md +679 -0
  300. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/invoke-portal-agents.sh +129 -0
  301. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/invoke-portal-dashboard.sh +85 -0
  302. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/invoke-portal-events.sh +125 -0
  303. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/invoke-portal-metrics.sh +112 -0
  304. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/invoke-portal-start.sh +135 -0
  305. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/invoke-portal-stop.sh +121 -0
  306. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/test-web-portal-skill.sh +51 -0
  307. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/validate-deployment.sh +85 -0
  308. package/.claude/cfn-extras/skills/utility/cfn-environment-sanitization/SKILL.md +200 -0
  309. package/.claude/cfn-extras/skills/utility/cfn-environment-sanitization/sanitize-environment.sh +244 -0
  310. package/.claude/cfn-extras/skills/utility/cfn-process-instrumentation/SKILL.md +279 -0
  311. package/.claude/cfn-extras/skills/utility/cfn-process-instrumentation/instrument-process.sh +327 -0
  312. package/.claude/cfn-extras/workflows/marketing-ad-campaigns.json +125 -0
  313. package/.claude/cfn-extras/workflows/marketing-analytics-data.json +93 -0
  314. package/.claude/cfn-extras/workflows/marketing-chatbot-conversations.json +89 -0
  315. package/.claude/cfn-extras/workflows/marketing-competitive-intel.json +140 -0
  316. package/.claude/cfn-extras/workflows/marketing-crm-contacts.json +86 -0
  317. package/.claude/cfn-extras/workflows/marketing-email-campaigns.json +86 -0
  318. package/.claude/cfn-extras/workflows/marketing-landing-pages.json +137 -0
  319. package/.claude/cfn-extras/workflows/marketing-media-outreach.json +211 -0
  320. package/.claude/cfn-extras/workflows/marketing-press-distribution.json +224 -0
  321. package/.claude/cfn-extras/workflows/marketing-sms-campaigns.json +81 -0
  322. package/.claude/cfn-extras/workflows/marketing-social-publishing.json +86 -0
  323. package/.claude/commands/README.md +204 -0
  324. package/.claude/commands/cfn-loop/CFN_LOOP_FRONTEND.md +741 -0
  325. package/.claude/commands/cfn-loop/cfn-loop-cli.md +273 -0
  326. package/.claude/commands/cfn-loop/cfn-loop-document.md +499 -0
  327. package/.claude/commands/cfn-loop/cfn-loop-task.md +490 -0
  328. package/.claude/commands/cfn-loop/cfn-loop-trigger.md +56 -0
  329. package/.claude/commands/cfn-loop/cfn-mode.md +20 -0
  330. package/.claude/commands/cfn-loop/cfn-optimize-agents.md +103 -0
  331. package/.claude/commands/cfn-loop/list-agents-rebuild.md +205 -0
  332. package/.claude/commands/cfn-ruvector/codebase-reindex.md +37 -0
  333. package/.claude/commands/cfn-ruvector/codebase-search.md +38 -0
  334. package/.claude/commands/cfn-ruvector/detect-stale-docs.md +41 -0
  335. package/.claude/commands/cfn-test-framework +5 -0
  336. package/.claude/commands/check-errors.md +34 -0
  337. package/.claude/commands/cost-routing/switch-api.md +109 -0
  338. package/.claude/commands/detect-stale-docs.md +26 -0
  339. package/.claude/commands/epic-creator-v2.md +10 -0
  340. package/.claude/commands/ruvector-search.md +46 -0
  341. package/.claude/commands/sparc.md +46 -0
  342. package/.claude/commands/update-search-index.md +31 -0
  343. package/.claude/commands/workflow.md +295 -0
  344. package/.claude/commands/write-plan.md +275 -0
  345. package/.claude/coordinator-feedback-pattern.md +326 -0
  346. package/.claude/coordinator-patterns.md +126 -0
  347. package/.claude/core/agent-manager.js +80 -0
  348. package/.claude/core/agent-manager.js.map +1 -0
  349. package/.claude/core/config.js +1241 -0
  350. package/.claude/core/config.js.map +1 -0
  351. package/.claude/core/event-bus.js +136 -0
  352. package/.claude/core/event-bus.js.map +1 -0
  353. package/.claude/core/index.js +6 -0
  354. package/.claude/core/index.js.map +1 -0
  355. package/.claude/core/json-persistence.js +112 -0
  356. package/.claude/core/json-persistence.js.map +1 -0
  357. package/.claude/core/logger.js +245 -0
  358. package/.claude/core/logger.js.map +1 -0
  359. package/.claude/core/orchestrator-fixed.js +236 -0
  360. package/.claude/core/orchestrator-fixed.js.map +1 -0
  361. package/.claude/core/orchestrator.js +1136 -0
  362. package/.claude/core/orchestrator.js.map +1 -0
  363. package/.claude/core/persistence.js +185 -0
  364. package/.claude/core/persistence.js.map +1 -0
  365. package/.claude/core/project-manager.js +80 -0
  366. package/.claude/core/project-manager.js.map +1 -0
  367. package/.claude/core/slash-command.js +24 -0
  368. package/.claude/core/version.js +35 -0
  369. package/.claude/core/version.js.map +1 -0
  370. package/.claude/helpers/checkpoint-manager.sh +251 -0
  371. package/.claude/helpers/github-safe.js +106 -0
  372. package/.claude/helpers/github-setup.sh +28 -0
  373. package/.claude/helpers/quick-start.sh +19 -0
  374. package/.claude/helpers/setup-mcp.sh +18 -0
  375. package/.claude/helpers/standard-checkpoint-hooks.sh +179 -0
  376. package/.claude/hooks/GIT-HOOKS-USAGE-EXAMPLES.md +116 -0
  377. package/.claude/hooks/README-GIT-HOOKS.md +443 -0
  378. package/.claude/hooks/SKILL.md +518 -0
  379. package/.claude/hooks/SKILL.md.backup +471 -0
  380. package/.claude/hooks/cfn-BACKUP_USAGE.md +243 -0
  381. package/.claude/hooks/cfn-invoke-post-edit-ts.sh +100 -0
  382. package/.claude/hooks/cfn-invoke-post-edit.sh +135 -0
  383. package/.claude/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
  384. package/.claude/hooks/cfn-invoke-pre-edit.sh +110 -0
  385. package/.claude/hooks/cfn-invoke-security-validation.sh +70 -0
  386. package/.claude/hooks/cfn-lint-sql-injection.sh +61 -0
  387. package/.claude/hooks/cfn-post-edit-cfn-retrospective.sh +110 -0
  388. package/.claude/hooks/cfn-post-edit.config.json +51 -0
  389. package/.claude/hooks/cfn-post-edit.sh +21 -0
  390. package/.claude/hooks/cfn-post-execution/memory-cleanup.sh +20 -0
  391. package/.claude/hooks/cfn-pre-edit-backup.sh +71 -0
  392. package/.claude/hooks/cfn-pre-edit-security-warning.sh +40 -0
  393. package/.claude/hooks/cfn-pre-execution/SESSION_START_README.md +87 -0
  394. package/.claude/hooks/cfn-pre-execution/TEST_SESSION_START.md +128 -0
  395. package/.claude/hooks/cfn-pre-execution/memory-check.sh +20 -0
  396. package/.claude/hooks/cfn-pre-execution/session-start-context.sh +111 -0
  397. package/.claude/hooks/cfn-restore-from-backup.sh +37 -0
  398. package/.claude/hooks/detect-hardcoded-credentials.sh +212 -0
  399. package/.claude/hooks/install-git-hooks.sh +243 -0
  400. package/.claude/hooks/post-commit-codebase-index +75 -0
  401. package/.claude/hooks/subagent-start.sh +98 -0
  402. package/.claude/hooks/subagent-stop.sh +93 -0
  403. package/.claude/hooks/validators/credential-scanner.sh +172 -0
  404. package/.claude/hooks.json +33 -0
  405. package/.claude/logs/sprint1-hybrid-routing-v2-decision.json +18 -0
  406. package/.claude/prompts/cfn-loop-context.md +115 -0
  407. package/.claude/prompts/loop-specific/loop2.md +50 -0
  408. package/.claude/prompts/loop-specific/loop3.md +43 -0
  409. package/.claude/prompts/loop-specific/loop4.md +54 -0
  410. package/.claude/root-claude-distribute/CFN-CLAUDE.md +513 -0
  411. package/.claude/settings.json +172 -0
  412. package/.claude/settings.local.json +41 -0
  413. package/.claude/settings.playwright.json +198 -0
  414. package/.claude/skills/.cfn/task-configs/task-test-123.json +48 -0
  415. package/.claude/skills/SKILL_TEMPLATE.md +774 -0
  416. package/.claude/skills/bulk-add-ruvector-instructions.sh +89 -0
  417. package/.claude/skills/cfn-agent-lifecycle/SKILL.md +290 -0
  418. package/.claude/skills/cfn-agent-lifecycle/cli/lifecycle-hook.sh +5 -0
  419. package/.claude/skills/cfn-agent-lifecycle/cli/select-agents.sh +5 -0
  420. package/.claude/skills/cfn-agent-lifecycle/cli/spawn-agent.sh +5 -0
  421. package/.claude/skills/cfn-agent-lifecycle/execute.sh +355 -0
  422. package/.claude/skills/cfn-agent-lifecycle/lib/audit/execute-lifecycle-hook.sh +544 -0
  423. package/.claude/skills/cfn-agent-lifecycle/lib/audit/simple-audit.sh +58 -0
  424. package/.claude/skills/cfn-agent-lifecycle/lib/output/README.md +359 -0
  425. package/.claude/skills/cfn-agent-lifecycle/lib/selection/SKILL.md +29 -0
  426. package/.claude/skills/cfn-agent-lifecycle/lib/selection/agent-mappings.json +142 -0
  427. package/.claude/skills/cfn-agent-lifecycle/lib/selection/select-agents-with-fallback.sh +195 -0
  428. package/.claude/skills/cfn-agent-lifecycle/lib/selection/select-agents.sh +94 -0
  429. package/.claude/skills/cfn-agent-lifecycle/lib/selection/src/agent-selector.ts +350 -0
  430. package/.claude/skills/cfn-agent-lifecycle/lib/selection/src/cli.ts +74 -0
  431. package/.claude/skills/cfn-agent-lifecycle/lib/selection/task-classifier.sh +93 -0
  432. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/SKILL.md +38 -0
  433. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/check-dependencies.sh +52 -0
  434. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/execute-agent.sh +126 -0
  435. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/get-agent-provider-env.sh +149 -0
  436. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/parse-agent-provider.sh +81 -0
  437. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/spawn-agent-wrapper.sh +63 -0
  438. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/spawn-agent.sh +308 -0
  439. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/spawn-templates.sh +635 -0
  440. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/spawn-worker.sh +198 -0
  441. package/.claude/skills/cfn-agent-tooling/SKILL.md +52 -0
  442. package/.claude/skills/cfn-agent-tooling/lib/generator/SKILL.md +440 -0
  443. package/.claude/skills/cfn-agent-tooling/lib/generator/generate-agent.sh +405 -0
  444. package/.claude/skills/cfn-agent-tooling/lib/linter/SKILL.md +589 -0
  445. package/.claude/skills/cfn-agent-tooling/lib/linter/lint-agents.sh +271 -0
  446. package/.claude/skills/cfn-cerebras-code-generator/SKILL.md +53 -0
  447. package/.claude/skills/cfn-cerebras-code-generator/context-analyzer.sh +96 -0
  448. package/.claude/skills/cfn-cerebras-code-generator/generate-code.sh +205 -0
  449. package/.claude/skills/cfn-cerebras-coordinator/SKILL.md +103 -0
  450. package/.claude/skills/cfn-cerebras-coordinator/TEST_RESULTS.md +98 -0
  451. package/.claude/skills/cfn-cerebras-coordinator/coordinate-generation.sh +381 -0
  452. package/.claude/skills/cfn-cerebras-coordinator/example-fix-scenario.md +254 -0
  453. package/.claude/skills/cfn-cerebras-coordinator/example-workflow.md +142 -0
  454. package/.claude/skills/cfn-cerebras-coordinator/feedback-logger.sh +254 -0
  455. package/.claude/skills/cfn-cerebras-coordinator/fix-existing-code-v2.sh +443 -0
  456. package/.claude/skills/cfn-cerebras-coordinator/fix-existing-code.sh +519 -0
  457. package/.claude/skills/cfn-cerebras-coordinator/pattern-examples.md +317 -0
  458. package/.claude/skills/cfn-cerebras-coordinator/query-patterns.sh +182 -0
  459. package/.claude/skills/cfn-cerebras-coordinator/tdd-coordinator.sh +638 -0
  460. package/.claude/skills/cfn-cerebras-coordinator/test-runner.sh +335 -0
  461. package/.claude/skills/cfn-cerebras-mcp/SKILL.md +64 -0
  462. package/.claude/skills/cfn-compilation-error-fixer/HANDOFF.md +29 -0
  463. package/.claude/skills/cfn-compilation-error-fixer/README.md +202 -0
  464. package/.claude/skills/cfn-compilation-error-fixer/SKILL.md +426 -0
  465. package/.claude/skills/cfn-compilation-error-fixer/bin/fix-errors.sh +75 -0
  466. package/.claude/skills/cfn-compilation-error-fixer/index.js +81 -0
  467. package/.claude/skills/cfn-compilation-error-fixer/install.sh +60 -0
  468. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/README-TypeScript.md +164 -0
  469. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/cerebras-gated-fixer-v2.ts +1475 -0
  470. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/cerebras-gated-fixer-v2.ts.bak +1475 -0
  471. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/cerebras-sdk.d.ts +30 -0
  472. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/cerebras-wrapper.ts +93 -0
  473. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/package.json +30 -0
  474. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/package.json.bak +23 -0
  475. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/typescript-gated-fixer-v2.ts +977 -0
  476. package/.claude/skills/cfn-compilation-error-fixer/lib/gates/typescript-gates.ts +704 -0
  477. package/.claude/skills/cfn-compilation-error-fixer/package.json +47 -0
  478. package/.claude/skills/cfn-compilation-error-fixer/test-fixer-logic.sh +96 -0
  479. package/.claude/skills/cfn-compilation-error-fixer/test-installation.sh +97 -0
  480. package/.claude/skills/cfn-compilation-error-fixer/test-rust-fixer-validation.sh +54 -0
  481. package/.claude/skills/cfn-compilation-error-fixer/test-rust-fixer.sh +380 -0
  482. package/.claude/skills/cfn-compilation-error-fixer/test-typescript-fixer.sh +278 -0
  483. package/.claude/skills/cfn-compilation-error-fixer/validate-setup.md +70 -0
  484. package/.claude/skills/cfn-config/SKILL.md +52 -0
  485. package/.claude/skills/cfn-config/lib/management/README.md +42 -0
  486. package/.claude/skills/cfn-config/lib/management/SKILL.md +34 -0
  487. package/.claude/skills/cfn-config/lib/management/check-dependencies.sh +56 -0
  488. package/.claude/skills/cfn-config/lib/management/config.json +32 -0
  489. package/.claude/skills/cfn-config/lib/management/manage-config.sh +115 -0
  490. package/.claude/skills/cfn-config/lib/sanitization/sanitize-environment.sh +48 -0
  491. package/.claude/skills/cfn-conversation-sync/README.md +133 -0
  492. package/.claude/skills/cfn-conversation-sync/SKILL.md +82 -0
  493. package/.claude/skills/cfn-conversation-sync/sync-conversations.sh +229 -0
  494. package/.claude/skills/cfn-dependency-management/SKILL.md +118 -0
  495. package/.claude/skills/cfn-dependency-management/cfn-dependency-management.sh +18 -0
  496. package/.claude/skills/cfn-dependency-management/execute.sh +306 -0
  497. package/.claude/skills/cfn-dependency-management/lib/extractor/SKILL.md +35 -0
  498. package/.claude/skills/cfn-dependency-management/lib/extractor/extract-dependencies.sh +66 -0
  499. package/.claude/skills/cfn-dependency-management/lib/ingestion/README.md +101 -0
  500. package/.claude/skills/cfn-dependency-management/lib/ingestion/SKILL.md +397 -0
  501. package/.claude/skills/cfn-dependency-management/lib/ingestion/build.sh +23 -0
  502. package/.claude/skills/cfn-dependency-management/lib/ingestion/ingest-dependencies.sh +295 -0
  503. package/.claude/skills/cfn-dependency-management/lib/ingestion/ingest.sh +237 -0
  504. package/.claude/skills/cfn-dependency-management/lib/ingestion/manifests/cli-mode-dependencies.txt +219 -0
  505. package/.claude/skills/cfn-dependency-management/lib/ingestion/manifests/shared-dependencies.txt +57 -0
  506. package/.claude/skills/cfn-dependency-management/lib/ingestion/manifests/trigger-dev-dependencies.txt +82 -0
  507. package/.claude/skills/cfn-dependency-management/lib/ingestion/manifests/trigger-mode-dependencies.txt +80 -0
  508. package/.claude/skills/cfn-dependency-management/lib/ingestion/src/ingest-dependencies.ts +563 -0
  509. package/.claude/skills/cfn-deployment-lifecycle/SKILL.md +53 -0
  510. package/.claude/skills/cfn-deployment-lifecycle/lib/deployment/SKILL.md +293 -0
  511. package/.claude/skills/cfn-deployment-lifecycle/lib/deployment/execute.sh +21 -0
  512. package/.claude/skills/cfn-deployment-lifecycle/lib/promotion/SKILL.md +305 -0
  513. package/.claude/skills/cfn-docker-runtime/SKILL.md +84 -0
  514. package/.claude/skills/cfn-docker-runtime/execute.sh +386 -0
  515. package/.claude/skills/cfn-docker-runtime/lib/coordination/README.md +349 -0
  516. package/.claude/skills/cfn-docker-runtime/lib/coordination/docker-helpers.sh +433 -0
  517. package/.claude/skills/cfn-docker-runtime/lib/coordination/package.json +38 -0
  518. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/agent-container.ts +471 -0
  519. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/docker-client.ts +483 -0
  520. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/health-checker.ts +418 -0
  521. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/index.ts +45 -0
  522. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/network-manager.ts +377 -0
  523. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/types.ts +412 -0
  524. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/volume-manager.ts +389 -0
  525. package/.claude/skills/cfn-docker-runtime/lib/logging/INTEGRATION.md +268 -0
  526. package/.claude/skills/cfn-docker-runtime/lib/logging/SAMPLE_OUTPUTS.md +237 -0
  527. package/.claude/skills/cfn-docker-runtime/lib/logging/SKILL.md +442 -0
  528. package/.claude/skills/cfn-docker-runtime/lib/logging/capture-container-logs.sh +120 -0
  529. package/.claude/skills/cfn-docker-runtime/lib/logging/enable-logging.sh +430 -0
  530. package/.claude/skills/cfn-docker-runtime/lib/logging/init-hybrid-logging.sh +210 -0
  531. package/.claude/skills/cfn-docker-runtime/lib/logging/queries/analytics-summary.sh +87 -0
  532. package/.claude/skills/cfn-docker-runtime/lib/logging/queries/query-agent-timeline.sh +51 -0
  533. package/.claude/skills/cfn-docker-runtime/lib/logging/queries/query-consensus-history.sh +56 -0
  534. package/.claude/skills/cfn-docker-runtime/lib/logging/queries/query-coordination-timeline.sh +39 -0
  535. package/.claude/skills/cfn-docker-runtime/lib/logging/queries/query-failed-containers.sh +40 -0
  536. package/.claude/skills/cfn-docker-runtime/lib/logging/queries/query-gate-checks.sh +39 -0
  537. package/.claude/skills/cfn-docker-runtime/lib/logging/schema.sql +111 -0
  538. package/.claude/skills/cfn-docker-runtime/lib/logging/sqlite-helpers.sh +240 -0
  539. package/.claude/skills/cfn-docker-runtime/lib/logging/test-hybrid-logging.sh +331 -0
  540. package/.claude/skills/cfn-docker-runtime/lib/mcp/SKILL.md +555 -0
  541. package/.claude/skills/cfn-docker-runtime/lib/mcp/skill-mcp-selector.js +472 -0
  542. package/.claude/skills/cfn-docker-runtime/lib/orchestration/SKILL.md +449 -0
  543. package/.claude/skills/cfn-docker-runtime/lib/orchestration/orchestrate.sh +1722 -0
  544. package/.claude/skills/cfn-docker-runtime/lib/spawning/SKILL.md +418 -0
  545. package/.claude/skills/cfn-docker-runtime/lib/spawning/spawn-agent.sh +569 -0
  546. package/.claude/skills/cfn-docker-runtime/lib/waves/SKILL.md +944 -0
  547. package/.claude/skills/cfn-docker-runtime/lib/waves/cleanup-wave.sh +445 -0
  548. package/.claude/skills/cfn-docker-runtime/lib/waves/lib/docker-helpers.sh +804 -0
  549. package/.claude/skills/cfn-docker-runtime/lib/waves/monitor-wave.sh +485 -0
  550. package/.claude/skills/cfn-docker-runtime/lib/waves/spawn-wave.sh +547 -0
  551. package/.claude/skills/cfn-edit-safety/README.md +160 -0
  552. package/.claude/skills/cfn-edit-safety/SKILL.md +62 -0
  553. package/.claude/skills/cfn-edit-safety/cli/edit-safety-cli.sh +337 -0
  554. package/.claude/skills/cfn-edit-safety/edit-safety.sh +375 -0
  555. package/.claude/skills/cfn-edit-safety/lib/backup/SKILL.md +324 -0
  556. package/.claude/skills/cfn-edit-safety/lib/backup/SKILL.md.backup +277 -0
  557. package/.claude/skills/cfn-edit-safety/lib/backup/backup.sh +129 -0
  558. package/.claude/skills/cfn-edit-safety/lib/backup/backup.sh.backup +107 -0
  559. package/.claude/skills/cfn-edit-safety/lib/hooks/README.md +74 -0
  560. package/.claude/skills/cfn-edit-safety/lib/hooks/SKILL.md +148 -0
  561. package/.claude/skills/cfn-edit-safety/lib/hooks/auto-resolve.sh +66 -0
  562. package/.claude/skills/cfn-edit-safety/lib/hooks/check-dependencies.sh +40 -0
  563. package/.claude/skills/cfn-edit-safety/lib/hooks/feedback-resolver.sh +452 -0
  564. package/.claude/skills/cfn-edit-safety/lib/hooks/post-edit-handler.sh +155 -0
  565. package/.claude/skills/cfn-edit-safety/lib/hooks/security-scan.json +60 -0
  566. package/.claude/skills/cfn-edit-safety/lib/hooks/security-scanner.sh +121 -0
  567. package/.claude/skills/cfn-edit-safety/lib/hooks/test-root-warning-resolution.sh +148 -0
  568. package/.claude/skills/cfn-epic-parser/SKILL.md +220 -0
  569. package/.claude/skills/cfn-epic-parser/example-epic.md +49 -0
  570. package/.claude/skills/cfn-epic-parser/parse.sh +517 -0
  571. package/.claude/skills/cfn-epic-parser/test-parser.sh +299 -0
  572. package/.claude/skills/cfn-error-management/SKILL.md +176 -0
  573. package/.claude/skills/cfn-error-management/cli/batch-errors.sh +4 -0
  574. package/.claude/skills/cfn-error-management/cli/capture-error.sh +4 -0
  575. package/.claude/skills/cfn-error-management/cli/log-error.sh +4 -0
  576. package/.claude/skills/cfn-error-management/lib/batching/README.md +1016 -0
  577. package/.claude/skills/cfn-error-management/lib/batching/analyze-errors.sh +327 -0
  578. package/.claude/skills/cfn-error-management/lib/batching/calculate-waves.sh +256 -0
  579. package/.claude/skills/cfn-error-management/lib/batching/cli.sh +523 -0
  580. package/.claude/skills/cfn-error-management/lib/batching/cluster-files.sh +196 -0
  581. package/.claude/skills/cfn-error-management/lib/batching/create-batches.sh +261 -0
  582. package/.claude/skills/cfn-error-management/lib/capture/README.md +56 -0
  583. package/.claude/skills/cfn-error-management/lib/capture/capture-agent-error.sh +87 -0
  584. package/.claude/skills/cfn-error-management/lib/logging/README.md +339 -0
  585. package/.claude/skills/cfn-error-management/lib/logging/cleanup-error-logs.sh +334 -0
  586. package/.claude/skills/cfn-error-management/lib/logging/integrate-cli.sh +232 -0
  587. package/.claude/skills/cfn-error-management/lib/logging/integrate-docker.sh +294 -0
  588. package/.claude/skills/cfn-error-management/lib/logging/invoke-error-logging.sh +839 -0
  589. package/.claude/skills/cfn-error-management/lib/logging/src/error-logger.ts +1042 -0
  590. package/.claude/skills/cfn-error-management/lib/logging/src/index.ts +12 -0
  591. package/.claude/skills/cfn-error-management/lib/logging/src/types.ts +456 -0
  592. package/.claude/skills/cfn-error-management/lib/logging/test-error-logging.sh +475 -0
  593. package/.claude/skills/cfn-expert-update/SKILL.md +149 -0
  594. package/.claude/skills/cfn-expert-update/test-expert-update.sh +254 -0
  595. package/.claude/skills/cfn-expert-update/update-expert.sh +484 -0
  596. package/.claude/skills/cfn-intervention-system/SKILL.md +52 -0
  597. package/.claude/skills/cfn-intervention-system/lib/detector/SKILL.md +39 -0
  598. package/.claude/skills/cfn-intervention-system/lib/detector/detect-intervention.sh +106 -0
  599. package/.claude/skills/cfn-intervention-system/lib/orchestrator/SKILL.md +43 -0
  600. package/.claude/skills/cfn-intervention-system/lib/orchestrator/execute-intervention.sh +59 -0
  601. package/.claude/skills/cfn-knowledge-base/SKILL.md +109 -0
  602. package/.claude/skills/cfn-knowledge-base/cli/knowledge-base.sh +435 -0
  603. package/.claude/skills/cfn-knowledge-base/execute.sh +163 -0
  604. package/.claude/skills/cfn-knowledge-base/lib/playbook/SKILL.md +153 -0
  605. package/.claude/skills/cfn-knowledge-base/lib/playbook/init-playbook.sh +54 -0
  606. package/.claude/skills/cfn-knowledge-base/lib/playbook/lib/auto-update/auto-update-playbook.sh +86 -0
  607. package/.claude/skills/cfn-knowledge-base/lib/playbook/query-playbook.sh +89 -0
  608. package/.claude/skills/cfn-knowledge-base/lib/playbook/update-playbook.sh +67 -0
  609. package/.claude/skills/cfn-knowledge-base/lib/workflow/APPROVAL_WORKFLOW.md +806 -0
  610. package/.claude/skills/cfn-knowledge-base/lib/workflow/COST_TRACKING.md +637 -0
  611. package/.claude/skills/cfn-knowledge-base/lib/workflow/DEPLOY_QUICK_REFERENCE.md +106 -0
  612. package/.claude/skills/cfn-knowledge-base/lib/workflow/EDGE_CASE_TRACKING.md +404 -0
  613. package/.claude/skills/cfn-knowledge-base/lib/workflow/PROPAGATE_UPDATE_QUICK_REFERENCE.md +366 -0
  614. package/.claude/skills/cfn-knowledge-base/lib/workflow/README_PHASE4.md +457 -0
  615. package/.claude/skills/cfn-knowledge-base/lib/workflow/SKILL.md +110 -0
  616. package/.claude/skills/cfn-knowledge-base/lib/workflow/approval-workflow.sh +514 -0
  617. package/.claude/skills/cfn-knowledge-base/lib/workflow/deploy-approved-skill.sh +481 -0
  618. package/.claude/skills/cfn-knowledge-base/lib/workflow/deploy-approved-skill.sh.backup-1763392820 +512 -0
  619. package/.claude/skills/cfn-knowledge-base/lib/workflow/generate-skill-update.sh +525 -0
  620. package/.claude/skills/cfn-knowledge-base/lib/workflow/lib/security-utils.sh +204 -0
  621. package/.claude/skills/cfn-knowledge-base/lib/workflow/package.json +30 -0
  622. package/.claude/skills/cfn-knowledge-base/lib/workflow/propagate-skill-update.sh +654 -0
  623. package/.claude/skills/cfn-knowledge-base/lib/workflow/propagate-skill-update.sh.backup-1763392820 +664 -0
  624. package/.claude/skills/cfn-knowledge-base/lib/workflow/review-skill.sh +643 -0
  625. package/.claude/skills/cfn-knowledge-base/lib/workflow/src/index.ts +24 -0
  626. package/.claude/skills/cfn-knowledge-base/lib/workflow/src/pattern-analyzer.ts +537 -0
  627. package/.claude/skills/cfn-knowledge-base/lib/workflow/src/types.ts +180 -0
  628. package/.claude/skills/cfn-knowledge-base/lib/workflow/test-integration.sh +296 -0
  629. package/.claude/skills/cfn-knowledge-base/lib/workflow/test-metadata-update.sh +350 -0
  630. package/.claude/skills/cfn-knowledge-base/lib/workflow/track-cost-savings.sh +486 -0
  631. package/.claude/skills/cfn-knowledge-base/lib/workflow/track-cost-savings.sh.backup-1763392821 +445 -0
  632. package/.claude/skills/cfn-knowledge-base/lib/workflow/track-edge-case.sh +290 -0
  633. package/.claude/skills/cfn-local-ruvector-accelerator/Cargo.toml +40 -0
  634. package/.claude/skills/cfn-local-ruvector-accelerator/README.md +563 -0
  635. package/.claude/skills/cfn-local-ruvector-accelerator/SKILL.md +343 -0
  636. package/.claude/skills/cfn-local-ruvector-accelerator/cfn-integration.sh +179 -0
  637. package/.claude/skills/cfn-local-ruvector-accelerator/embeddings_manager.py +289 -0
  638. package/.claude/skills/cfn-local-ruvector-accelerator/index-code.sh +234 -0
  639. package/.claude/skills/cfn-local-ruvector-accelerator/init-local-ruvector.sh +112 -0
  640. package/.claude/skills/cfn-local-ruvector-accelerator/project-structure.md +53 -0
  641. package/.claude/skills/cfn-local-ruvector-accelerator/query-local.sh +169 -0
  642. package/.claude/skills/cfn-local-ruvector-accelerator/requirements.txt +2 -0
  643. package/.claude/skills/cfn-local-ruvector-accelerator/search_engine.py +200 -0
  644. package/.claude/skills/cfn-local-ruvector-accelerator/search_engine_v2.py +238 -0
  645. package/.claude/skills/cfn-local-ruvector-accelerator/sqlite_store.py +220 -0
  646. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/cleanup.rs +134 -0
  647. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/export.rs +40 -0
  648. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/index.rs +301 -0
  649. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/init.rs +127 -0
  650. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/migration.rs +74 -0
  651. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/mod.rs +18 -0
  652. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/query.rs +222 -0
  653. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/reset.rs +37 -0
  654. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/stats.rs +133 -0
  655. package/.claude/skills/cfn-local-ruvector-accelerator/src/embeddings.rs +121 -0
  656. package/.claude/skills/cfn-local-ruvector-accelerator/src/main.rs +359 -0
  657. package/.claude/skills/cfn-local-ruvector-accelerator/src/migration.rs +318 -0
  658. package/.claude/skills/cfn-local-ruvector-accelerator/src/search_engine.rs +281 -0
  659. package/.claude/skills/cfn-local-ruvector-accelerator/src/sqlite_store.rs +211 -0
  660. package/.claude/skills/cfn-local-ruvector-accelerator/test-local-ruvector.sh +250 -0
  661. package/.claude/skills/cfn-loop-orchestration-v2/SKILL.md +57 -0
  662. package/.claude/skills/cfn-loop-orchestration-v2/cli/cfn-orchestrator.cjs +49 -0
  663. package/.claude/skills/cfn-loop-orchestration-v2/cli/orchestrate.sh +21 -0
  664. package/.claude/skills/cfn-loop-orchestration-v2/cli/resolve-provider-model.cjs +69 -0
  665. package/.claude/skills/cfn-loop-orchestration-v2/lib/coordination/agent-completion.sh.backup +36 -0
  666. package/.claude/skills/cfn-loop-orchestration-v2/lib/coordination/coordination-patterns.ts +194 -0
  667. package/.claude/skills/cfn-loop-orchestration-v2/lib/coordination/coordination-signal.sh.backup +36 -0
  668. package/.claude/skills/cfn-loop-orchestration-v2/lib/coordination/coordination-wait.sh.backup +36 -0
  669. package/.claude/skills/cfn-loop-orchestration-v2/lib/coordination/index.ts +25 -0
  670. package/.claude/skills/cfn-loop-orchestration-v2/lib/decision/SKILL.md +664 -0
  671. package/.claude/skills/cfn-loop-orchestration-v2/lib/decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
  672. package/.claude/skills/cfn-loop-orchestration-v2/lib/decision/parse-decision.sh +66 -0
  673. package/.claude/skills/cfn-loop-orchestration-v2/lib/decision/test-backlog-integration.sh +148 -0
  674. package/.claude/skills/cfn-loop-orchestration-v2/lib/decision/validate-deliverables.sh +82 -0
  675. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/CONFIGURATION_IMPROVEMENTS.md +318 -0
  676. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/CONTEXT_LOOKUP_QUICK_START.md +378 -0
  677. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/NORTH_STAR_INDEX.md +323 -0
  678. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/ORCHESTRATOR_IMPLEMENTATION.md +493 -0
  679. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/ORCHESTRATOR_QUICK_START.md +499 -0
  680. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/README.md +149 -0
  681. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/SKILL.md +418 -0
  682. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
  683. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/VALIDATION_SUMMARY.txt +196 -0
  684. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/VALIDATOR_MODULE_GUIDE.md +526 -0
  685. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/e2e-validation-fixed.js +240 -0
  686. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/e2e-validation.js +213 -0
  687. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/package.json +53 -0
  688. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/run-north-star-e2e.ts +210 -0
  689. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/security_utils.sh +123 -0
  690. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/agent-spawner/agent-spawner.ts +34 -0
  691. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/cli/orchestrator-cli.ts +396 -0
  692. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/gate-checker/gate-checker.ts +36 -0
  693. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
  694. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
  695. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
  696. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
  697. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
  698. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/confidence-aggregator.ts +473 -0
  699. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/consensus.ts +87 -0
  700. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/context-injector.ts +349 -0
  701. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/context-lookup.ts +486 -0
  702. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/deliverable-verifier.ts +107 -0
  703. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/gate-check.ts +115 -0
  704. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/iteration-manager.ts +45 -0
  705. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/parse-test-results.ts +372 -0
  706. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/product-owner-decision.ts +316 -0
  707. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/spawn-agents.ts +357 -0
  708. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/timeout-calculator.ts +41 -0
  709. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/validator.ts +276 -0
  710. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/index.ts +16 -0
  711. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/orchestrate.ts +1389 -0
  712. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/orchestrator/orchestrator.ts +31 -0
  713. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/redis/redis-coordinator.ts +72 -0
  714. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/types.ts +244 -0
  715. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/utils/logger.ts +32 -0
  716. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/test-cfn-orchestration.sh +281 -0
  717. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/test-cli.sh +92 -0
  718. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/test-edge-cases.sh +188 -0
  719. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/test-iteration-context-injection.sh +366 -0
  720. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/test-typescript-integration.sh +442 -0
  721. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/DELIVERY_SUMMARY.txt +462 -0
  722. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/EXAMPLES.md +609 -0
  723. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/INDEX.md +531 -0
  724. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/README.md +114 -0
  725. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/SKILL.md +633 -0
  726. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/index.ts +6 -0
  727. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/output-processor.ts +183 -0
  728. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/package.json +50 -0
  729. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/src/cli/process-loop2.ts +195 -0
  730. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/src/cli/process-loop3.ts +157 -0
  731. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/src/output-processor.ts +632 -0
  732. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/INDEX.md +531 -0
  733. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/README.md +256 -0
  734. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/README_TYPESCRIPT.md +454 -0
  735. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/SKILL.md +400 -0
  736. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/SKILL.md.backup +353 -0
  737. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/SKILL_TYPESCRIPT.md +782 -0
  738. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
  739. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/check-dependencies.sh +53 -0
  740. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/check-dependencies.sh.backup +31 -0
  741. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/config.json +161 -0
  742. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/consensus-calculator.js +477 -0
  743. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/detect-vapor.sh +59 -0
  744. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/detect-vapor.sh.backup +37 -0
  745. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/evidence-chain.sql +163 -0
  746. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/index.ts +12 -0
  747. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/orchestrate-cfn-loop.sh +274 -0
  748. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/orchestrate-cfn-loop.sh.backup +252 -0
  749. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/package.json +93 -0
  750. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/src/cli/detect-vapor.ts +177 -0
  751. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/src/cli/validate-deliverables.ts +161 -0
  752. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/src/cli/validate-gate.ts +139 -0
  753. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/src/types.ts +215 -0
  754. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/src/validator.ts +503 -0
  755. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validate-deliverables.sh +59 -0
  756. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validate-deliverables.sh.backup +37 -0
  757. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validate-gate.sh +63 -0
  758. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validate-gate.sh.backup +41 -0
  759. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validate-iteration.sh +156 -0
  760. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validate-iteration.sh.backup +134 -0
  761. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validation-framework.ts +237 -0
  762. package/.claude/skills/cfn-mdap-context-injection/SKILL.md +21 -0
  763. package/.claude/skills/cfn-mdap-context-injection/inject.sh +348 -0
  764. package/.claude/skills/cfn-mdap-error-fixer/HANDOFF.md +383 -0
  765. package/.claude/skills/cfn-mdap-error-fixer/lib/fixer/cerebras-gated-fixer-v2.ts +1500 -0
  766. package/.claude/skills/cfn-mdap-error-fixer/lib/fixer/package.json +20 -0
  767. package/.claude/skills/cfn-mdap-error-fixer/skill.md +205 -0
  768. package/.claude/skills/cfn-memory-persistence/SKILL.md +59 -0
  769. package/.claude/skills/cfn-memory-persistence/lib/auto/SKILL.md +73 -0
  770. package/.claude/skills/cfn-memory-persistence/lib/auto/persist-agent-output.sh +49 -0
  771. package/.claude/skills/cfn-memory-persistence/lib/auto/query-agent-history.sh +35 -0
  772. package/.claude/skills/cfn-memory-persistence/lib/auto/test-memory-persistence.sh +230 -0
  773. package/.claude/skills/cfn-memory-persistence/lib/management/SKILL.md +271 -0
  774. package/.claude/skills/cfn-memory-persistence/lib/management/check-memory.sh +160 -0
  775. package/.claude/skills/cfn-memory-persistence/lib/management/cleanup-memory.sh +197 -0
  776. package/.claude/skills/cfn-memory-persistence/lib/redis/SKILL.md +42 -0
  777. package/.claude/skills/cfn-memory-persistence/lib/redis/agent-log.sh.backup +128 -0
  778. package/.claude/skills/cfn-memory-persistence/lib/redis/agent-recovery.sh.backup +75 -0
  779. package/.claude/skills/cfn-memory-persistence/lib/redis/analyze-task-complexity.sh.backup +277 -0
  780. package/.claude/skills/cfn-memory-persistence/lib/redis/bash-wrappers/store-context.sh.backup +23 -0
  781. package/.claude/skills/cfn-memory-persistence/lib/redis/cancel-swarm.sh.backup +221 -0
  782. package/.claude/skills/cfn-memory-persistence/lib/redis/cfn-loop-exec.sh.backup +468 -0
  783. package/.claude/skills/cfn-memory-persistence/lib/redis/cfn-loop-relaunch.sh.backup +29 -0
  784. package/.claude/skills/cfn-memory-persistence/lib/redis/collect-confidence-scores.sh.backup +209 -0
  785. package/.claude/skills/cfn-memory-persistence/lib/redis/collect-results.sh.backup +75 -0
  786. package/.claude/skills/cfn-memory-persistence/lib/redis/complete-swarm.sh.backup +75 -0
  787. package/.claude/skills/cfn-memory-persistence/lib/redis/get-context.sh.backup +146 -0
  788. package/.claude/skills/cfn-memory-persistence/lib/redis/get-success-criteria.sh.backup +54 -0
  789. package/.claude/skills/cfn-memory-persistence/lib/redis/invoke-waiting-mode.sh.backup +225 -0
  790. package/.claude/skills/cfn-memory-persistence/lib/redis/redis-cli-wrapper.sh.backup +43 -0
  791. package/.claude/skills/cfn-memory-persistence/lib/redis/redis-functions.sh.backup +34 -0
  792. package/.claude/skills/cfn-memory-persistence/lib/redis/report-completion.sh.backup +134 -0
  793. package/.claude/skills/cfn-memory-persistence/lib/redis/store-context.sh.backup +123 -0
  794. package/.claude/skills/cfn-memory-persistence/lib/sqlite/QUICK_REFERENCE.md +204 -0
  795. package/.claude/skills/cfn-memory-persistence/lib/sqlite/README.md +65 -0
  796. package/.claude/skills/cfn-memory-persistence/lib/sqlite/SKILL.md +415 -0
  797. package/.claude/skills/cfn-memory-persistence/lib/sqlite/acl-queries.sql +452 -0
  798. package/.claude/skills/cfn-memory-persistence/lib/sqlite/check-dependencies.sh +36 -0
  799. package/.claude/skills/cfn-memory-persistence/lib/sqlite/config.json +45 -0
  800. package/.claude/skills/cfn-memory-persistence/lib/sqlite/memory-cli.sh +74 -0
  801. package/.claude/skills/cfn-memory-persistence/lib/sqlite/test-state-persistence.js +187 -0
  802. package/.claude/skills/cfn-memory-persistence/lib/sqlite/ttl-cleanup.sh +266 -0
  803. package/.claude/skills/cfn-node-heap-sizer/SKILL.md +313 -0
  804. package/.claude/skills/cfn-node-heap-sizer/task-mode-heap-limiter.sh +326 -0
  805. package/.claude/skills/cfn-operations/SKILL.md +52 -0
  806. package/.claude/skills/cfn-operations/execute.sh +175 -0
  807. package/.claude/skills/cfn-operations/lib/file/SKILL.md +290 -0
  808. package/.claude/skills/cfn-operations/lib/file/execute.sh +129 -0
  809. package/.claude/skills/cfn-operations/lib/file/lib/atomic-write.sh +294 -0
  810. package/.claude/skills/cfn-operations/lib/file/lib/lock.sh +361 -0
  811. package/.claude/skills/cfn-operations/lib/file/test.sh +373 -0
  812. package/.claude/skills/cfn-operations/lib/log/SKILL.md +308 -0
  813. package/.claude/skills/cfn-operations/lib/log/execute.sh +420 -0
  814. package/.claude/skills/cfn-operations/lib/log/lib/rotate.sh +406 -0
  815. package/.claude/skills/cfn-operations/lib/log/lib/search.sh +448 -0
  816. package/.claude/skills/cfn-operations/lib/log/test.sh +400 -0
  817. package/.claude/skills/cfn-parameterized-queries/SKILL.md +368 -0
  818. package/.claude/skills/cfn-parameterized-queries/parameterized-queries.sh +249 -0
  819. package/.claude/skills/cfn-parameterized-queries/test-implementation.sh +237 -0
  820. package/.claude/skills/cfn-planning/SKILL.md +55 -0
  821. package/.claude/skills/cfn-planning/execute.sh +159 -0
  822. package/.claude/skills/cfn-planning/lib/coordinator/README.md +256 -0
  823. package/.claude/skills/cfn-planning/lib/coordinator/SKILL.md +62 -0
  824. package/.claude/skills/cfn-planning/lib/coordinator/map-dependencies-conflicts.sh +376 -0
  825. package/.claude/skills/cfn-planning/lib/coordinator/plan-coordinator-resources.sh +258 -0
  826. package/.claude/skills/cfn-planning/lib/coordinator/plan-multi-coordinator-work.sh +267 -0
  827. package/.claude/skills/cfn-planning/lib/coordinator/plan-risk-rollout.sh +350 -0
  828. package/.claude/skills/cfn-planning/lib/coordinator/test-multi-coordinator-planning.sh +338 -0
  829. package/.claude/skills/cfn-planning/lib/coordinator/validate-task-planning.sh +189 -0
  830. package/.claude/skills/cfn-planning/lib/epic/SKILL.md +44 -0
  831. package/.claude/skills/cfn-planning/lib/epic/decompose-epic.sh +104 -0
  832. package/.claude/skills/cfn-planning/lib/scope/SKILL.md +37 -0
  833. package/.claude/skills/cfn-planning/lib/scope/simplify-scope.sh +68 -0
  834. package/.claude/skills/cfn-process-management/SKILL.md +52 -0
  835. package/.claude/skills/cfn-process-management/cfn-process +16 -0
  836. package/.claude/skills/cfn-process-management/cli/process-manager +186 -0
  837. package/.claude/skills/cfn-process-management/lib/instrumentation/instrument-process.sh +44 -0
  838. package/.claude/skills/cfn-process-management/lib/lifecycle/README.md +43 -0
  839. package/.claude/skills/cfn-process-management/lib/lifecycle/SKILL.md +39 -0
  840. package/.claude/skills/cfn-process-management/lib/lifecycle/check-dependencies.sh +58 -0
  841. package/.claude/skills/cfn-process-management/lib/lifecycle/config.json +39 -0
  842. package/.claude/skills/cfn-process-management/lib/lifecycle/process-manager.sh +334 -0
  843. package/.claude/skills/cfn-project-management/SKILL.md +60 -0
  844. package/.claude/skills/cfn-project-management/lib/backlog/SKILL.md +199 -0
  845. package/.claude/skills/cfn-project-management/lib/backlog/add-backlog-item.sh +208 -0
  846. package/.claude/skills/cfn-project-management/lib/changelog/SKILL.md +349 -0
  847. package/.claude/skills/cfn-project-management/lib/changelog/add-changelog-entry.sh +202 -0
  848. package/.claude/skills/cfn-project-management/lib/changelog/bulk-import.sh +268 -0
  849. package/.claude/skills/cfn-project-management/lib/changelog/lib/README.md +212 -0
  850. package/.claude/skills/cfn-project-management/lib/changelog/lib/validation.sh +72 -0
  851. package/.claude/skills/cfn-routing-config/SKILL.md +52 -0
  852. package/.claude/skills/cfn-routing-config/lib/hybrid/README.md +50 -0
  853. package/.claude/skills/cfn-routing-config/lib/hybrid/SKILL.md +54 -0
  854. package/.claude/skills/cfn-routing-config/lib/hybrid/check-dependencies.sh +52 -0
  855. package/.claude/skills/cfn-routing-config/lib/hybrid/config.json +26 -0
  856. package/.claude/skills/cfn-routing-config/lib/hybrid/spawn-worker.sh +44 -0
  857. package/.claude/skills/cfn-routing-config/lib/provider/README.md +129 -0
  858. package/.claude/skills/cfn-routing-config/lib/provider/SKILL.md +215 -0
  859. package/.claude/skills/cfn-routing-config/lib/provider/resolve-provider-model.ts +252 -0
  860. package/.claude/skills/cfn-session-handoff/SKILL.md +53 -0
  861. package/.claude/skills/cfn-skill-management/FIXES_APPLIED.md +80 -0
  862. package/.claude/skills/cfn-skill-management/SKILL.md +55 -0
  863. package/.claude/skills/cfn-skill-management/lib/builder/SKILL.md +910 -0
  864. package/.claude/skills/cfn-skill-management/lib/loader/SKILL.md +466 -0
  865. package/.claude/skills/cfn-skill-management/lib/loader/execute.sh +344 -0
  866. package/.claude/skills/cfn-skill-management/lib/propagation/README.md +233 -0
  867. package/.claude/skills/cfn-skill-management/lib/propagation/package.json +56 -0
  868. package/.claude/skills/cfn-skill-management/lib/propagation/propagate-skill-update.sh +32 -0
  869. package/.claude/skills/cfn-skill-management/lib/propagation/src/cli.ts +75 -0
  870. package/.claude/skills/cfn-skill-management/lib/propagation/src/database-adapter.ts +239 -0
  871. package/.claude/skills/cfn-skill-management/lib/propagation/src/file-system-adapter.ts +113 -0
  872. package/.claude/skills/cfn-skill-management/lib/propagation/src/index.ts +72 -0
  873. package/.claude/skills/cfn-skill-management/lib/propagation/src/logger.ts +43 -0
  874. package/.claude/skills/cfn-skill-management/lib/propagation/src/metadata-parser.ts +154 -0
  875. package/.claude/skills/cfn-skill-management/lib/propagation/src/skill-propagator.ts +274 -0
  876. package/.claude/skills/cfn-skill-management/lib/propagation/src/skill-validator.ts +179 -0
  877. package/.claude/skills/cfn-skill-management/lib/propagation/src/types.ts +143 -0
  878. package/.claude/skills/cfn-skill-management/lib/propagation/src/version-manager.ts +118 -0
  879. package/.claude/skills/cfn-skill-management/src/cli/skill-loader.ts +364 -0
  880. package/.claude/skills/cfn-skill-management/src/lib/database-service.ts +313 -0
  881. package/.claude/skills/cfn-sprint-execution/SKILL.md +55 -0
  882. package/.claude/skills/cfn-sprint-execution/execute.sh +257 -0
  883. package/.claude/skills/cfn-sprint-execution/lib/checkpoint/SKILL.md +333 -0
  884. package/.claude/skills/cfn-sprint-execution/lib/checkpoint/cleanup-orphans.sh +374 -0
  885. package/.claude/skills/cfn-sprint-execution/lib/checkpoint/resume-wave.sh +325 -0
  886. package/.claude/skills/cfn-sprint-execution/lib/checkpoint/save-checkpoint.sh +284 -0
  887. package/.claude/skills/cfn-sprint-execution/lib/execution/SKILL.md +27 -0
  888. package/.claude/skills/cfn-sprint-execution/lib/execution/execute-sprint-task.sh +68 -0
  889. package/.claude/skills/cfn-sprint-execution/lib/execution/execute-sprint.sh +65 -0
  890. package/.claude/skills/cfn-task-decomposition/explore-123-subtasks.json +27 -0
  891. package/.claude/skills/cfn-task-decomposition/prompts/explore-123-analyze-prompt.md +36 -0
  892. package/.claude/skills/cfn-task-decomposition/prompts/explore-123-scan-prompt.md +36 -0
  893. package/.claude/skills/cfn-task-decomposition/prompts/test-final-fix-prompt.md +36 -0
  894. package/.claude/skills/cfn-task-decomposition/prompts/test-final-pattern-prompt.md +36 -0
  895. package/.claude/skills/cfn-task-decomposition/prompts/test-final-recon-prompt.md +36 -0
  896. package/.claude/skills/cfn-task-decomposition/prompts/test-final-validate-prompt.md +36 -0
  897. package/.claude/skills/cfn-task-decomposition/test-456-subtasks.json +60 -0
  898. package/.claude/skills/cfn-task-decomposition/test-789-subtasks.json +60 -0
  899. package/.claude/skills/cfn-task-decomposition/test-999-subtasks.json +27 -0
  900. package/.claude/skills/cfn-task-decomposition/test-debug-subtasks.json +60 -0
  901. package/.claude/skills/cfn-task-decomposition/test-debug2-subtasks.json +60 -0
  902. package/.claude/skills/cfn-task-decomposition/test-final-subtasks.json +60 -0
  903. package/.claude/skills/cfn-task-decomposition/test-simple-subtasks.json +60 -0
  904. package/.claude/skills/cfn-task-intelligence/SKILL.md +18 -0
  905. package/.claude/skills/cfn-task-intelligence/cfn-task-intelligence.sh +158 -0
  906. package/.claude/skills/cfn-task-intelligence/lib/classifier/SKILL.md +81 -0
  907. package/.claude/skills/cfn-task-intelligence/lib/classifier/classify-task.sh +297 -0
  908. package/.claude/skills/cfn-task-intelligence/lib/complexity/SKILL.md +96 -0
  909. package/.claude/skills/cfn-task-intelligence/lib/complexity/estimate-complexity.sh +144 -0
  910. package/.claude/skills/cfn-task-intelligence/lib/integration/SKILL.md +339 -0
  911. package/.claude/skills/cfn-task-intelligence/lib/integration/learning-loop.sh +127 -0
  912. package/.claude/skills/cfn-task-intelligence/lib/integration/post-feedback-hook.sh +124 -0
  913. package/.claude/skills/cfn-task-intelligence/lib/integration/pre-execution-hook.sh +59 -0
  914. package/.claude/skills/cfn-task-intelligence/lib/specialist/SKILL.md +41 -0
  915. package/.claude/skills/cfn-task-intelligence/lib/specialist/recommend-specialist.sh +57 -0
  916. package/.claude/skills/cfn-task-planning/SKILL.md +15 -0
  917. package/.claude/skills/cfn-task-planning/cli/classify-task.sh +4 -0
  918. package/.claude/skills/cfn-task-planning/cli/decompose-task.sh +4 -0
  919. package/.claude/skills/cfn-task-planning/cli/init-config.sh +4 -0
  920. package/.claude/skills/cfn-task-planning/lib/audit/get-audit-data.sh +397 -0
  921. package/.claude/skills/cfn-task-planning/lib/audit/store-task-audit.sh +191 -0
  922. package/.claude/skills/cfn-task-planning/lib/classifier/README.md +81 -0
  923. package/.claude/skills/cfn-task-planning/lib/classifier/classify-task.sh +297 -0
  924. package/.claude/skills/cfn-task-planning/lib/decomposition/task-decomposer.sh +415 -0
  925. package/.claude/skills/cfn-test-framework/CLI.md +191 -0
  926. package/.claude/skills/cfn-test-framework/SKILL.md +55 -0
  927. package/.claude/skills/cfn-test-framework/execute.sh +386 -0
  928. package/.claude/skills/cfn-test-framework/lib/execution/README.md +129 -0
  929. package/.claude/skills/cfn-test-framework/lib/execution/SKILL.md +128 -0
  930. package/.claude/skills/cfn-test-framework/lib/execution/check-dependencies.sh +36 -0
  931. package/.claude/skills/cfn-test-framework/lib/execution/test-cache-reader.sh +134 -0
  932. package/.claude/skills/cfn-test-framework/lib/execution/test-concurrent-conflicts.sh +115 -0
  933. package/.claude/skills/cfn-test-framework/lib/execution/test-coordinator-pattern.sh +109 -0
  934. package/.claude/skills/cfn-test-framework/lib/runner/SKILL.md +288 -0
  935. package/.claude/skills/cfn-test-framework/lib/runner/detect-regressions.sh +58 -0
  936. package/.claude/skills/cfn-test-framework/lib/runner/detect-regressions.sh.backup-1763392821 +55 -0
  937. package/.claude/skills/cfn-test-framework/lib/runner/init-benchmark-db.sh +48 -0
  938. package/.claude/skills/cfn-test-framework/lib/runner/run-all-tests.sh +222 -0
  939. package/.claude/skills/cfn-test-framework/lib/runner/store-benchmarks.sh +53 -0
  940. package/.claude/skills/cfn-test-framework/lib/runner/validate-redis-keys.sh +143 -0
  941. package/.claude/skills/cfn-test-framework/lib/webapp/README.md +142 -0
  942. package/.claude/skills/cfn-test-framework/lib/webapp/SCREENSHOT_NAMING_CONVENTION.md +547 -0
  943. package/.claude/skills/cfn-test-framework/lib/webapp/SKILL.md +877 -0
  944. package/.claude/skills/cfn-test-framework/lib/webapp/capture-screenshot.sh +238 -0
  945. package/.claude/skills/cfn-test-framework/lib/webapp/cfn-loop-integration.sh +265 -0
  946. package/.claude/skills/cfn-test-framework/lib/webapp/compare-screenshots.sh +199 -0
  947. package/.claude/skills/cfn-test-framework/lib/webapp/init-storage.sh +150 -0
  948. package/.claude/skills/cfn-test-framework/lib/webapp/set-baseline.sh +196 -0
  949. package/.claude/skills/cfn-test-framework/lib/webapp/test-webapp-testing.sh +233 -0
  950. package/.claude/skills/cfn-transparency-middleware/CACHE_MANAGER.md +98 -0
  951. package/.claude/skills/cfn-transparency-middleware/Cargo.lock +2358 -0
  952. package/.claude/skills/cfn-transparency-middleware/Cargo.toml +20 -0
  953. package/.claude/skills/cfn-transparency-middleware/README.md +327 -0
  954. package/.claude/skills/cfn-transparency-middleware/SECURITY.md +41 -0
  955. package/.claude/skills/cfn-transparency-middleware/SKILL.md +327 -0
  956. package/.claude/skills/cfn-transparency-middleware/TEST_RESULTS.md +174 -0
  957. package/.claude/skills/cfn-transparency-middleware/config.json +23 -0
  958. package/.claude/skills/cfn-transparency-middleware/fix_redact.sh +12 -0
  959. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-filter.sh +98 -0
  960. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-init.sh +224 -0
  961. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-level.sh +333 -0
  962. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-metrics.sh +345 -0
  963. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-observe.sh +140 -0
  964. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-stop.sh +235 -0
  965. package/.claude/skills/cfn-transparency-middleware/middleware-config.sh +29 -0
  966. package/.claude/skills/cfn-transparency-middleware/performance-benchmark.sh +79 -0
  967. package/.claude/skills/cfn-transparency-middleware/src/agent_metrics.rs +480 -0
  968. package/.claude/skills/cfn-transparency-middleware/src/api_handler.rs +318 -0
  969. package/.claude/skills/cfn-transparency-middleware/src/cache_manager.rs +219 -0
  970. package/.claude/skills/cfn-transparency-middleware/src/fix_regex.rs +9 -0
  971. package/.claude/skills/cfn-transparency-middleware/src/lib.rs +391 -0
  972. package/.claude/skills/cfn-transparency-middleware/src/lib.rs.backup +388 -0
  973. package/.claude/skills/cfn-transparency-middleware/src/main.rs +205 -0
  974. package/.claude/skills/cfn-transparency-middleware/src/memory_query.rs +93 -0
  975. package/.claude/skills/cfn-transparency-middleware/src/memory_repository.rs +169 -0
  976. package/.claude/skills/cfn-transparency-middleware/src/memory_schema.rs +154 -0
  977. package/.claude/skills/cfn-transparency-middleware/src/test_fix.txt +2 -0
  978. package/.claude/skills/cfn-transparency-middleware/test-e2e.sh +421 -0
  979. package/.claude/skills/cfn-transparency-middleware/test-integration.sh +162 -0
  980. package/.claude/skills/cfn-transparency-middleware/test-transparency-skill.sh +368 -0
  981. package/.claude/skills/cfn-transparency-middleware/test-transparency-skill.sh.unix +126 -0
  982. package/.claude/skills/cfn-transparency-middleware/wrap-agent.sh +132 -0
  983. package/.claude/skills/cfn-utilities/SKILL.md +239 -0
  984. package/.claude/skills/cfn-utilities/execute.sh +32 -0
  985. package/.claude/skills/cfn-utilities/lib/errors.sh +56 -0
  986. package/.claude/skills/cfn-utilities/lib/file-ops.sh +164 -0
  987. package/.claude/skills/cfn-utilities/lib/logging.sh +77 -0
  988. package/.claude/skills/cfn-utilities/lib/retry.sh +127 -0
  989. package/.claude/skills/cfn-utilities/test.sh +317 -0
  990. package/.claude/skills/cfn-validation-framework/SKILL.md +60 -0
  991. package/.claude/skills/cfn-validation-framework/execute.sh +223 -0
  992. package/.claude/skills/cfn-validation-framework/lib/deliverables/confidence-calculator.sh +262 -0
  993. package/.claude/skills/cfn-validation-framework/lib/instrumentation/wrapped-executor.sh +291 -0
  994. package/.claude/skills/cfn-validation-framework/lib/json/SKILL.md +431 -0
  995. package/.claude/skills/cfn-validation-framework/lib/json/test-validate-success-criteria.sh +421 -0
  996. package/.claude/skills/cfn-validation-framework/lib/json/validate-success-criteria.sh +197 -0
  997. package/.claude/skills/cfn-validation-framework/lib/layers/SKILL.md +133 -0
  998. package/.claude/skills/cfn-vision-analysis/SKILL.md +20 -0
  999. package/.claude/skills/deprecated/analyze-patterns.sh +899 -0
  1000. package/.claude/skills/equation-solver/README.md +327 -0
  1001. package/.claude/skills/equation-solver/SECURITY.md +306 -0
  1002. package/.claude/skills/equation-solver/SKILL.md +335 -0
  1003. package/.claude/skills/equation-solver/package.json +32 -0
  1004. package/.claude/skills/equation-solver/solve.sh +352 -0
  1005. package/.claude/skills/equation-solver/test-equation-solver-minimal.sh +103 -0
  1006. package/.claude/skills/equation-solver/test-equation-solver.sh +510 -0
  1007. package/.claude/skills/equation-solver/test.cjs +25 -0
  1008. package/.claude/skills/shared/bootstrap/sqlite-params.sh +156 -0
  1009. package/.claude/skills/shared/lib/path-utils.sh +139 -0
  1010. package/.claude/skills-database/APPROVAL_CRITERIA.md +925 -0
  1011. package/.claude/skills-database/APPROVAL_WORKFLOW.md +1482 -0
  1012. package/.claude/skills-database/ARCHITECTURE_DECISIONS.md +456 -0
  1013. package/.claude/skills-database/IMPLEMENTATION_GUIDE.md +763 -0
  1014. package/.claude/skills-database/README.md +564 -0
  1015. package/.claude/skills-database/TDD_SKILLS_DB_INTEGRATION.md +2286 -0
  1016. package/.claude/skills-database/schema-v2.sql +587 -0
  1017. package/.claude/slash-commands.json +92 -0
  1018. package/.claude/spawn-pattern-examples.md +500 -0
  1019. package/.claude/sprint-configs/cfn-naming-standardization.json +729 -0
  1020. package/.claude/state/cfn-expert-last-commit +2 -0
  1021. package/.claude/tooling/jq +0 -0
  1022. package/fix-node_modules.md +68 -0
  1023. package/package.json +2 -2
@@ -0,0 +1,1722 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ # CFN Docker Loop Orchestration Implementation
5
+ # Usage: ./orchestrate.sh [OPERATION] [TASK_ID] [OPTIONS]
6
+
7
+ # Determine PROJECT_ROOT
8
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
10
+
11
+ # Detect worktree/branch for environment injection
12
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "main")
13
+ export WORKTREE_BRANCH="${CURRENT_BRANCH}"
14
+
15
+ # Default configuration
16
+ DEFAULT_MAX_ITERATIONS=10
17
+ DEFAULT_GATE_THRESHOLD=0.75
18
+ DEFAULT_CONSENSUS_THRESHOLD=0.90
19
+ DEFAULT_LOOP3_TIMEOUT=600
20
+ DEFAULT_LOOP2_TIMEOUT=300
21
+ DEFAULT_PO_TIMEOUT=180
22
+
23
+ # Colors for output
24
+ RED='\033[0;31m'
25
+ GREEN='\033[0;32m'
26
+ YELLOW='\033[1;33m'
27
+ BLUE='\033[0;34m'
28
+ PURPLE='\033[0;35m'
29
+ NC='\033[0m'
30
+
31
+ log() {
32
+ echo -e "${BLUE}[$(date '+%H:%M:%S')]${NC} $*" >&2
33
+ }
34
+
35
+ log_success() {
36
+ echo -e "${GREEN}[SUCCESS]${NC} $*" >&2
37
+ }
38
+
39
+ log_error() {
40
+ echo -e "${RED}[ERROR]${NC} $*" >&2
41
+ }
42
+
43
+ log_warning() {
44
+ echo -e "${YELLOW}[WARNING]${NC} $*" >&2
45
+ }
46
+
47
+ log_loop() {
48
+ echo -e "${PURPLE}[LOOP]${NC} $*" >&2
49
+ }
50
+
51
+ # Function to display usage
52
+ usage() {
53
+ cat << EOF
54
+ CFN Docker Loop Orchestration
55
+
56
+ Usage: $0 [OPERATION] [TASK_ID] [OPTIONS]
57
+
58
+ Operations:
59
+ execute Execute complete CFN Loop
60
+ init Initialize loop orchestration
61
+ spawn-loop3 Spawn Loop 3 implementer agents
62
+ monitor-loop3 Monitor Loop 3 completion
63
+ gate-check Check Loop 3 gate and decide next steps
64
+ spawn-loop2 Spawn Loop 2 validator agents
65
+ collect-consensus Collect Loop 2 consensus
66
+ trigger-po-decision Trigger Product Owner decision
67
+ analyze-task Analyze task and select agents
68
+ monitor-progress Monitor overall loop progress
69
+ validate-deliverables Validate required deliverables
70
+ handle-error Handle execution errors
71
+ execute-waves Execute complete wave-based execution (Mode A)
72
+ spawn-wave Spawn specific wave of containers
73
+ monitor-wave Monitor wave container completion
74
+ cleanup-wave Remove wave containers and artifacts
75
+ validate-errors Run error validation and count results
76
+
77
+ Options:
78
+ --task-description TEXT Task description
79
+ --mode MODE Execution mode (mvp|standard|enterprise)
80
+ --agents LIST Comma-separated agent types
81
+ --max-iterations NUM Maximum iterations (default: 10)
82
+ --gate-threshold NUM Gate threshold (default: 0.75)
83
+ --consensus-threshold NUM Consensus threshold (default: 0.90)
84
+ --context-file PATH Task context file
85
+ --success-criteria JSON Success criteria for test-driven validation
86
+ --timeout SECONDS Operation timeout
87
+ --memory-limit LIMIT Agent memory limit
88
+ --network NAME Docker network
89
+ --adaptive-selection Enable adaptive agent selection
90
+ --force-iteration NUM Force specific iteration
91
+ --dry-run Show configuration without execution
92
+ --verbose Enable verbose logging
93
+ --help Show this help message
94
+
95
+ Examples:
96
+ $0 execute --task-id task-auth --task-description "Implement user authentication" --mode standard
97
+ $0 spawn-loop3 --task-id task-auth --agents backend-developer,frontend-engineer,security-specialist
98
+ $0 monitor-loop3 --task-id task-auth --gate-threshold 0.80
99
+ $0 collect-consensus --task-id task-auth --required-consensus 0.90
100
+ $0 execute-waves --task-id task-fix --batching-plan /tmp/waves.json
101
+ $0 spawn-wave --task-id task-fix --wave-number 1 --batching-plan /tmp/waves.json
102
+ $0 monitor-wave --task-id task-fix --wave-number 1 --expected-count 28
103
+ $0 cleanup-wave --task-id task-fix --wave-number 1
104
+ $0 validate-errors --task-id task-fix --command "tsc --noEmit"
105
+
106
+ EOF
107
+ }
108
+
109
+ # JSON validation helper with security bounds checking
110
+ validate_json_context() {
111
+ local json_str="$1"
112
+
113
+ if [ -z "$json_str" ]; then
114
+ return 1
115
+ fi
116
+
117
+ # Security: Check size (max 10MB) BEFORE parsing
118
+ local size=$(echo -n "$json_str" | wc -c)
119
+ local MAX_JSON_SIZE=10485760 # 10MB limit
120
+
121
+ if [ "$size" -gt "$MAX_JSON_SIZE" ]; then
122
+ log_error "JSON exceeds maximum size (10MB): ${size} bytes"
123
+ log_error "Security Risk: DoS via excessive memory consumption"
124
+ return 1
125
+ fi
126
+
127
+ # Validate JSON structure
128
+ if ! echo "$json_str" | jq empty 2>/dev/null; then
129
+ log_error "Invalid JSON structure"
130
+ return 1
131
+ fi
132
+
133
+ # Security: Bounds check - validate array sizes if success criteria
134
+ if echo "$json_str" | jq -e '.test_suites' >/dev/null 2>&1; then
135
+ local TEST_SUITE_COUNT=$(echo "$json_str" | jq '.test_suites | length' 2>/dev/null || echo "0")
136
+ local MAX_TEST_SUITES=50
137
+
138
+ if [ "$TEST_SUITE_COUNT" -gt "$MAX_TEST_SUITES" ]; then
139
+ log_error "Test suites exceed maximum ($MAX_TEST_SUITES): $TEST_SUITE_COUNT"
140
+ log_error "Security Risk: DoS via resource exhaustion"
141
+ return 1
142
+ fi
143
+ fi
144
+
145
+ return 0
146
+ }
147
+
148
+ # Input sanitization helper
149
+ sanitize_input() {
150
+ local input="$1"
151
+ local max_length="${2:-256}"
152
+
153
+ # SECURITY FIX #2: Command injection prevention - strict alphanumeric whitelist
154
+ # Allows ONLY: letters, numbers, dash, underscore, space, comma, period, colon
155
+ local sanitized=$(echo "$input" | tr -cd '[:alnum:] _,.:-')
156
+
157
+ # Length bounds check
158
+ if [ ${#input} -gt "$max_length" ]; then
159
+ log_error "Input exceeds maximum length ($max_length): ${#input}"
160
+ return 1
161
+ fi
162
+
163
+ # Reject if input contains shell metacharacters: $, `, ;, |, &, >, <, (, ), {, }, [, ], \, ", ', =
164
+ if [[ "$input" =~ (\$|\`|;|\||&|>|<|\(|\)|\{|\}|\[|\]|\\|\"|\'|=) ]]; then
165
+ log_error "Input contains dangerous shell metacharacters"
166
+ log_error "Original: $input"
167
+ log_error "Security Risk: Command injection attack prevented"
168
+ return 1
169
+ fi
170
+
171
+ echo "$sanitized"
172
+ return 0
173
+ }
174
+
175
+ # Mode configuration
176
+ get_mode_config() {
177
+ local mode="$1"
178
+
179
+ case "$mode" in
180
+ "mvp")
181
+ echo '{"maxIterations":3,"gateThreshold":0.70,"consensusThreshold":0.80,"validators":2}'
182
+ ;;
183
+ "standard")
184
+ echo '{"maxIterations":10,"gateThreshold":0.75,"consensusThreshold":0.90,"validators":3}'
185
+ ;;
186
+ "enterprise")
187
+ echo '{"maxIterations":15,"gateThreshold":0.85,"consensusThreshold":0.95,"validators":5}'
188
+ ;;
189
+ *)
190
+ echo '{"maxIterations":10,"gateThreshold":0.75,"consensusThreshold":0.90,"validators":3}'
191
+ ;;
192
+ esac
193
+ }
194
+
195
+ # Path to skills
196
+ REDIS_COORDINATION_SKILL="$PROJECT_ROOT/.claude/skills/cfn-docker-redis-coordination/coordinate.sh"
197
+ AGENT_SPAWNING_SKILL="$PROJECT_ROOT/.claude/skills/cfn-docker-agent-spawning/spawn-agent.sh"
198
+ WAVE_EXECUTION_SKILL="$PROJECT_ROOT/.claude/skills/cfn-docker-wave-execution"
199
+ WAVE_SPAWN_SCRIPT="$WAVE_EXECUTION_SKILL/spawn-wave.sh"
200
+ WAVE_HELPERS="$WAVE_EXECUTION_SKILL/lib/docker-helpers.sh"
201
+ WAVE_CHECKPOINT_SKILL="$PROJECT_ROOT/.claude/skills/cfn-wave-checkpoint"
202
+ CHECKPOINT_SAVE_SCRIPT="$WAVE_CHECKPOINT_SKILL/save-checkpoint.sh"
203
+ CHECKPOINT_RESUME_SCRIPT="$WAVE_CHECKPOINT_SKILL/resume-wave.sh"
204
+ CHECKPOINT_CLEANUP_SCRIPT="$WAVE_CHECKPOINT_SKILL/cleanup-orphans.sh"
205
+
206
+ # Parse command line arguments
207
+ OPERATION=""
208
+ TASK_ID=""
209
+ TASK_DESCRIPTION=""
210
+ MODE="standard"
211
+ AGENTS=""
212
+ MAX_ITERATIONS="$DEFAULT_MAX_ITERATIONS"
213
+ GATE_THRESHOLD="$DEFAULT_GATE_THRESHOLD"
214
+ CONSENSUS_THRESHOLD="$DEFAULT_CONSENSUS_THRESHOLD"
215
+ CONTEXT_FILE=""
216
+ TIMEOUT=""
217
+ SUCCESS_CRITERIA=""
218
+ MEMORY_LIMIT=""
219
+ NETWORK=""
220
+ ADAPTIVE_SELECTION=false
221
+ FORCE_ITERATION=""
222
+ DRY_RUN=false
223
+ VERBOSE=false
224
+
225
+ # Mode A: Wave execution parameters
226
+ BATCHING_PLAN=""
227
+ WAVE_NUMBER=""
228
+ EXPECTED_COUNT=""
229
+ VALIDATION_COMMAND=""
230
+
231
+ while [[ $# -gt 0 ]]; do
232
+ case $1 in
233
+ --task-description)
234
+ TASK_DESCRIPTION="$2"
235
+ shift 2
236
+ ;;
237
+ --mode)
238
+ MODE="$2"
239
+ shift 2
240
+ ;;
241
+ --agents)
242
+ AGENTS="$2"
243
+ shift 2
244
+ ;;
245
+ --max-iterations)
246
+ MAX_ITERATIONS="$2"
247
+ shift 2
248
+ ;;
249
+ --gate-threshold)
250
+ GATE_THRESHOLD="$2"
251
+ shift 2
252
+ ;;
253
+ --consensus-threshold)
254
+ CONSENSUS_THRESHOLD="$2"
255
+ shift 2
256
+ ;;
257
+ --context-file)
258
+ CONTEXT_FILE="$2"
259
+ shift 2
260
+ ;;
261
+ --success-criteria)
262
+ SUCCESS_CRITERIA="$2"
263
+ shift 2
264
+ ;;
265
+ --timeout)
266
+ TIMEOUT="$2"
267
+ shift 2
268
+ ;;
269
+ --memory-limit)
270
+ MEMORY_LIMIT="$2"
271
+ shift 2
272
+ ;;
273
+ --network)
274
+ NETWORK="$2"
275
+ shift 2
276
+ ;;
277
+ --adaptive-selection)
278
+ ADAPTIVE_SELECTION=true
279
+ shift
280
+ ;;
281
+ --force-iteration)
282
+ FORCE_ITERATION="$2"
283
+ shift 2
284
+ ;;
285
+ --dry-run)
286
+ DRY_RUN=true
287
+ shift
288
+ ;;
289
+ --verbose)
290
+ VERBOSE=true
291
+ shift
292
+ ;;
293
+ --batching-plan)
294
+ BATCHING_PLAN="$2"
295
+ shift 2
296
+ ;;
297
+ --wave-number)
298
+ WAVE_NUMBER="$2"
299
+ shift 2
300
+ ;;
301
+ --expected-count)
302
+ EXPECTED_COUNT="$2"
303
+ shift 2
304
+ ;;
305
+ --command)
306
+ VALIDATION_COMMAND="$2"
307
+ shift 2
308
+ ;;
309
+ --help)
310
+ usage
311
+ exit 0
312
+ ;;
313
+ -*)
314
+ log_error "Unknown option: $1"
315
+ usage
316
+ exit 1
317
+ ;;
318
+ *)
319
+ if [[ -z "$OPERATION" ]]; then
320
+ OPERATION="$1"
321
+ elif [[ -z "$TASK_ID" ]]; then
322
+ TASK_ID="$1"
323
+ else
324
+ log_error "Too many arguments"
325
+ usage
326
+ exit 1
327
+ fi
328
+ shift
329
+ ;;
330
+ esac
331
+ done
332
+
333
+ # Apply mode configuration
334
+ MODE_CONFIG=$(get_mode_config "$MODE")
335
+ MAX_ITERATIONS=$(echo "$MODE_CONFIG" | jq -r '.maxIterations // 10')
336
+ GATE_THRESHOLD=$(echo "$MODE_CONFIG" | jq -r '.gateThreshold // 0.75')
337
+ CONSENSUS_THRESHOLD=$(echo "$MODE_CONFIG" | jq -r '.consensusThreshold // 0.90')
338
+
339
+ # Validate required arguments
340
+ if [[ -z "$OPERATION" ]]; then
341
+ log_error "Operation is required"
342
+ usage
343
+ exit 1
344
+ fi
345
+
346
+ if [[ -z "$TASK_ID" && "$OPERATION" != "analyze-task" ]]; then
347
+ log_error "Task ID is required"
348
+ usage
349
+ exit 1
350
+ fi
351
+
352
+ # Check dependencies
353
+ for dependency in "$REDIS_COORDINATION_SKILL" "$AGENT_SPAWNING_SKILL"; do
354
+ if [[ ! -f "$dependency" ]]; then
355
+ log_error "Required skill not found: $dependency"
356
+ exit 1
357
+ fi
358
+ done
359
+
360
+ # Validate Docker agent image exists
361
+ AGENT_IMAGE="${AGENT_IMAGE:-claude-flow-novice-agent:latest}"
362
+ if ! docker image inspect "$AGENT_IMAGE" &>/dev/null; then
363
+ log_error "Required Docker image not found: $AGENT_IMAGE"
364
+ log_error "Please build the image first or set AGENT_IMAGE environment variable"
365
+ exit 1
366
+ fi
367
+ log "Using agent image: $AGENT_IMAGE"
368
+
369
+ # Change to project root
370
+ cd "$PROJECT_ROOT"
371
+
372
+ # Operation implementations
373
+
374
+ # Planning phase: Decompose task into atomic units
375
+ plan_task() {
376
+ local task_description="$1"
377
+ local task_id="$2"
378
+
379
+ if [[ -z "$task_description" ]]; then
380
+ log_error "Task description is required for planning"
381
+ return 1
382
+ fi
383
+
384
+ log "Planning phase: Decomposing task into atomic units"
385
+ log "Task: $task_description"
386
+
387
+ # Create plan file
388
+ local plan_file="/tmp/cfn-docker-plan-${task_id}.json"
389
+
390
+ # Check if plan file already exists (from pre-planning)
391
+ if [[ -f "$plan_file" ]]; then
392
+ log "Using existing plan file: $plan_file"
393
+
394
+ # Validate plan structure
395
+ if ! jq -e '.atomic_tasks' "$plan_file" > /dev/null 2>&1; then
396
+ log_error "Invalid existing plan format: missing atomic_tasks"
397
+ return 1
398
+ fi
399
+
400
+ log_success "Task planning complete: $(jq -r '.atomic_tasks | length' "$plan_file") atomic tasks"
401
+
402
+ # Extract agent assignments from plan
403
+ local agents
404
+ agents=$(jq -r '.atomic_tasks[].agent_type' "$plan_file" | sort -u | tr '\n' ' ')
405
+ echo "$agents"
406
+ return 0
407
+ fi
408
+
409
+ # Generate plan via LLM API call (for Docker mode)
410
+ if [[ -n "${ANTHROPIC_API_KEY:-}" ]]; then
411
+ log "Generating plan via Anthropic API..."
412
+
413
+ # Create planning prompt
414
+ local planning_prompt="You are a task planning expert. Decompose this task into atomic units for parallel execution.
415
+
416
+ Task: ${task_description}
417
+
418
+ Requirements:
419
+ 1. Break task into 15-30 minute atomic units
420
+ 2. Each atomic task should have: description, estimated time, dependencies, agent type, deliverables
421
+ 3. Agent types available: backend-developer, react-frontend-engineer, security-specialist, tester, reviewer, devops-engineer
422
+ 4. Assign 1 atomic task per agent (2-3 max if shared context helps)
423
+ 5. Identify which tasks can run in parallel vs sequential
424
+ 6. Use simple dependency notation: [] for no dependencies, [\"task-1\"] for dependencies
425
+
426
+ Output ONLY valid JSON in this exact format:
427
+ {
428
+ \"atomic_tasks\": [
429
+ {
430
+ \"id\": \"task-1\",
431
+ \"description\": \"Implement JWT token generation middleware\",
432
+ \"estimated_time\": \"20 min\",
433
+ \"dependencies\": [],
434
+ \"agent_type\": \"backend-developer\",
435
+ \"deliverables\": [\"src/middleware/jwt.ts\", \"tests\"]
436
+ }
437
+ ],
438
+ \"execution_phases\": {
439
+ \"phase_1_parallel\": [\"task-1\", \"task-3\"],
440
+ \"phase_2_sequential\": [\"task-2\"]
441
+ }
442
+ }"
443
+
444
+ # Call Anthropic API
445
+ local api_response
446
+ api_response=$(curl -s -X POST https://api.anthropic.com/v1/messages \
447
+ -H "x-api-key: ${ANTHROPIC_API_KEY}" \
448
+ -H "anthropic-version: 2023-06-01" \
449
+ -H "content-type: application/json" \
450
+ -d "{
451
+ \"model\": \"claude-sonnet-4-20250514\",
452
+ \"max_tokens\": 2048,
453
+ \"messages\": [{
454
+ \"role\": \"user\",
455
+ \"content\": $(echo "$planning_prompt" | jq -Rs .)
456
+ }]
457
+ }")
458
+
459
+ # Extract plan from response
460
+ local plan_content
461
+ plan_content=$(echo "$api_response" | jq -r '.content[0].text' 2>/dev/null)
462
+
463
+ if [[ -z "$plan_content" || "$plan_content" == "null" ]]; then
464
+ log_error "Failed to get plan from API"
465
+ log_warning "API response: $(echo "$api_response" | head -100)"
466
+ return 1
467
+ fi
468
+
469
+ # Clean JSON (remove markdown code blocks if present)
470
+ plan_content=$(echo "$plan_content" | sed -n '/^{/,/^}/p')
471
+
472
+ # Save plan file
473
+ echo "$plan_content" > "$plan_file"
474
+
475
+ # Validate plan structure
476
+ if ! jq -e '.atomic_tasks' "$plan_file" > /dev/null 2>&1; then
477
+ log_error "Invalid plan format from API: missing atomic_tasks"
478
+ log_warning "Plan content: $(cat "$plan_file" | head -50)"
479
+ return 1
480
+ fi
481
+
482
+ log_success "Task planning complete via API: $(jq -r '.atomic_tasks | length' "$plan_file") atomic tasks"
483
+
484
+ # Extract agent assignments from plan
485
+ local agents
486
+ agents=$(jq -r '.atomic_tasks[].agent_type' "$plan_file" | sort -u | tr '\n' ' ')
487
+ echo "$agents"
488
+ return 0
489
+ fi
490
+
491
+ # No API key - wait for external plan file (Task mode)
492
+ log_warning "No ANTHROPIC_API_KEY found, waiting for external plan file..."
493
+ local wait_count=0
494
+ while [[ ! -f "$plan_file" && $wait_count -lt 30 ]]; do
495
+ sleep 1
496
+ ((wait_count++))
497
+ done
498
+
499
+ if [[ ! -f "$plan_file" ]]; then
500
+ log_warning "No plan file created, falling back to analyze_task"
501
+ return 1
502
+ fi
503
+
504
+ # Validate plan structure
505
+ if ! jq -e '.atomic_tasks' "$plan_file" > /dev/null 2>&1; then
506
+ log_error "Invalid plan format: missing atomic_tasks"
507
+ return 1
508
+ fi
509
+
510
+ log_success "Task planning complete: $(jq -r '.atomic_tasks | length' "$plan_file") atomic tasks"
511
+
512
+ # Extract agent assignments from plan
513
+ local agents
514
+ agents=$(jq -r '.atomic_tasks[].agent_type' "$plan_file" | sort -u | tr '\n' ' ')
515
+ echo "$agents"
516
+ }
517
+
518
+ analyze_task() {
519
+ local task_description="$1"
520
+ local task_id="${2:-}"
521
+
522
+ if [[ -z "$task_description" ]]; then
523
+ log_error "Task description is required for task analysis"
524
+ return 1
525
+ fi
526
+
527
+ log "Analyzing task: $task_description"
528
+
529
+ # Try planning first if task_id provided
530
+ if [[ -n "$task_id" ]]; then
531
+ local planned_agents
532
+ if planned_agents=$(plan_task "$task_description" "$task_id" 2>/dev/null); then
533
+ log "Using planned agent assignments: $planned_agents"
534
+ echo "$planned_agents"
535
+ return 0
536
+ fi
537
+ fi
538
+
539
+ # Fallback: Simple keyword-based agent selection
540
+ log_warning "Using fallback keyword-based agent selection"
541
+ local selected_agents=()
542
+
543
+ if [[ "$task_description" =~ (frontend|ui|user.interface|react|vue|angular) ]]; then
544
+ selected_agents+=("react-frontend-engineer")
545
+ fi
546
+
547
+ if [[ "$task_description" =~ (backend|api|server|database|authentication|security) ]]; then
548
+ selected_agents+=("backend-developer")
549
+ if [[ "$task_description" =~ (security|auth|encryption|password) ]]; then
550
+ selected_agents+=("security-specialist")
551
+ fi
552
+ fi
553
+
554
+ if [[ "$task_description" =~ (test|testing|quality|qa) ]]; then
555
+ selected_agents+=("tester")
556
+ fi
557
+
558
+ if [[ "$task_description" =~ (review|code.quality|refactor) ]]; then
559
+ selected_agents+=("reviewer")
560
+ fi
561
+
562
+ if [[ "$task_description" =~ (devops|deployment|docker|infrastructure) ]]; then
563
+ selected_agents+=("devops-engineer")
564
+ fi
565
+
566
+ # Default agents if none selected
567
+ if [[ ${#selected_agents[@]} -eq 0 ]]; then
568
+ selected_agents=("backend-developer" "react-frontend-engineer" "reviewer")
569
+ fi
570
+
571
+ # Limit to 3 agents for Loop 3
572
+ local loop3_agents=("${selected_agents[@]:0:3}")
573
+
574
+ log "Recommended Loop 3 agents: $(IFS=','; echo "${loop3_agents[*]}")"
575
+ log "Recommended Loop 2 agents: reviewer,tester"
576
+
577
+ echo "${loop3_agents[*]}"
578
+ }
579
+
580
+ init() {
581
+ local task_id="$1"
582
+ local context_file="$2"
583
+
584
+ log "Initializing loop orchestration for task: $task_id"
585
+
586
+ # Initialize Redis coordination
587
+ if [[ -n "$context_file" ]]; then
588
+ "$REDIS_COORDINATION_SKILL" init-task \
589
+ --task-id "$task_id" \
590
+ --context-file "$context_file"
591
+ else
592
+ "$REDIS_COORDINATION_SKILL" init-task \
593
+ --task-id "$task_id"
594
+ fi
595
+
596
+ # Store loop configuration
597
+ local config_file="/tmp/loop-config-${task_id}.json"
598
+ cat > "$config_file" << EOF
599
+ {
600
+ "taskId": "$task_id",
601
+ "mode": "$MODE",
602
+ "maxIterations": $MAX_ITERATIONS,
603
+ "gateThreshold": $GATE_THRESHOLD,
604
+ "consensusThreshold": $CONSENSUS_THRESHOLD,
605
+ "currentIteration": 1,
606
+ "currentLoop": 3,
607
+ "status": "initialized",
608
+ "createdAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
609
+ }
610
+ EOF
611
+
612
+ # Store success criteria if provided
613
+ if [[ -n "$SUCCESS_CRITERIA" ]]; then
614
+ if validate_json_context "$SUCCESS_CRITERIA"; then
615
+ # Store in Redis using coordination skill
616
+ if command -v redis-cli >/dev/null 2>&1; then
617
+ redis-cli HSET "task:${task_id}:context" "success-criteria" "$SUCCESS_CRITERIA" >/dev/null 2>&1 || {
618
+ log_warning "Failed to store success criteria in Redis, will pass via env vars"
619
+ }
620
+ log "Stored success criteria ($(echo "$SUCCESS_CRITERIA" | jq -r '.test_suites | length' 2>/dev/null || echo '0') test suites)"
621
+ else
622
+ log_warning "Redis not available, success criteria will be passed via environment variables"
623
+ fi
624
+ else
625
+ log_error "Invalid success criteria JSON, skipping storage"
626
+ fi
627
+ fi
628
+
629
+ log_success "Loop orchestration initialized: $task_id"
630
+ }
631
+
632
+ spawn_loop3() {
633
+ local task_id="$1"
634
+ local agents="$2"
635
+ local iteration="${3:-1}"
636
+
637
+ if [[ -z "$agents" ]]; then
638
+ log_error "Agent list is required for Loop 3 spawning"
639
+ return 1
640
+ fi
641
+
642
+ log_loop "Spawning Loop 3 implementers (iteration $iteration)"
643
+ log "Agents: $agents"
644
+
645
+ # Load success criteria from Redis (if available)
646
+ local AGENT_SUCCESS_CRITERIA=""
647
+ local AGENT_SUCCESS_CRITERIA_B64=""
648
+
649
+ if command -v redis-cli >/dev/null 2>&1; then
650
+ local LOADED_CRITERIA=$(redis-cli HGET "task:${task_id}:context" "success-criteria" 2>/dev/null || echo "")
651
+
652
+ if [[ -n "$LOADED_CRITERIA" && "$LOADED_CRITERIA" != "null" ]]; then
653
+ # Validate JSON
654
+ if echo "$LOADED_CRITERIA" | jq empty 2>/dev/null; then
655
+ AGENT_SUCCESS_CRITERIA="$LOADED_CRITERIA"
656
+
657
+ # Base64-encode for safe environment variable passing
658
+ AGENT_SUCCESS_CRITERIA_B64=$(echo -n "$AGENT_SUCCESS_CRITERIA" | base64 -w 0 2>/dev/null || echo -n "$AGENT_SUCCESS_CRITERIA" | base64)
659
+
660
+ local TEST_SUITE_COUNT=$(echo "$AGENT_SUCCESS_CRITERIA" | jq -r '.test_suites | length' 2>/dev/null || echo "0")
661
+ log "Success criteria loaded ($TEST_SUITE_COUNT test suites)"
662
+ else
663
+ log_warning "Invalid success criteria JSON in Redis, skipping"
664
+ fi
665
+ fi
666
+ fi
667
+
668
+ # Fallback to global SUCCESS_CRITERIA if not in Redis
669
+ if [[ -z "$AGENT_SUCCESS_CRITERIA" && -n "$SUCCESS_CRITERIA" ]]; then
670
+ AGENT_SUCCESS_CRITERIA="$SUCCESS_CRITERIA"
671
+ AGENT_SUCCESS_CRITERIA_B64=$(echo -n "$AGENT_SUCCESS_CRITERIA" | base64 -w 0 2>/dev/null || echo -n "$AGENT_SUCCESS_CRITERIA" | base64)
672
+ log "Using global success criteria (not in Redis)"
673
+ fi
674
+
675
+ # Check for execution plan
676
+ local plan_file="/tmp/cfn-docker-plan-${task_id}.json"
677
+ local has_plan=false
678
+ if [[ -f "$plan_file" ]] && jq -e '.atomic_tasks' "$plan_file" > /dev/null 2>&1; then
679
+ has_plan=true
680
+ log "Using execution plan with $(jq -r '.atomic_tasks | length' "$plan_file") atomic tasks"
681
+ fi
682
+
683
+ # Spawn agents
684
+ IFS=',' read -ra AGENT_ARRAY <<< "$agents"
685
+ local agent_ids=()
686
+ local task_index=0
687
+
688
+ for agent_type in "${AGENT_ARRAY[@]}"; do
689
+ agent_type=$(echo "$agent_type" | xargs) # trim whitespace
690
+
691
+ # Get atomic task assignment from plan (if available)
692
+ local atomic_task_desc="$TASK_DESCRIPTION"
693
+ local atomic_task_deliverables=""
694
+
695
+ if [[ "$has_plan" == true ]]; then
696
+ # Find atomic tasks assigned to this agent type
697
+ atomic_task_desc=$(jq -r ".atomic_tasks[] | select(.agent_type == \"$agent_type\") | .description" "$plan_file" 2>/dev/null | head -1 || echo "")
698
+ atomic_task_deliverables=$(jq -r ".atomic_tasks[] | select(.agent_type == \"$agent_type\") | .deliverables | join(\", \")" "$plan_file" 2>/dev/null | head -1 || echo "")
699
+
700
+ if [[ -n "$atomic_task_desc" && "$atomic_task_desc" != "null" ]]; then
701
+ log "Atomic task for $agent_type: $atomic_task_desc"
702
+ else
703
+ log_warning "No atomic task found in plan for $agent_type, using full task description"
704
+ atomic_task_desc="$TASK_DESCRIPTION"
705
+ fi
706
+ fi
707
+
708
+ # Store task context for this specific agent
709
+ local context_file="/tmp/task-context-${task_id}-loop3-${iteration}-${agent_type}.json"
710
+
711
+ # Create enhanced context with atomic task assignment
712
+ local context_json=$(cat << EOF
713
+ {
714
+ "task_id": "$task_id",
715
+ "loop_number": 3,
716
+ "iteration": $iteration,
717
+ "mode": "$MODE",
718
+ "role": "implementer",
719
+ "agent_type": "$agent_type",
720
+ "atomic_task": "$atomic_task_desc",
721
+ "expected_deliverables": "$atomic_task_deliverables",
722
+ "gate_threshold": $GATE_THRESHOLD,
723
+ "max_iterations": $MAX_ITERATIONS,
724
+ "instructions": "Complete your assigned atomic task (15-30 min scope). Focus on: $atomic_task_desc. Deliver working, tested code. Report confidence (0.0-1.0).",
725
+ "created_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
726
+ }
727
+ EOF
728
+ )
729
+
730
+ # Add success criteria if available (stored separately due to potential size)
731
+ if [[ -n "$AGENT_SUCCESS_CRITERIA_B64" ]]; then
732
+ context_json=$(echo "$context_json" | jq --arg criteria_b64 "$AGENT_SUCCESS_CRITERIA_B64" '. + {success_criteria_b64: $criteria_b64}')
733
+ fi
734
+
735
+ echo "$context_json" > "$context_file"
736
+
737
+ # Get task context from Redis if available
738
+ if [[ -n "$CONTEXT_FILE" ]]; then
739
+ # Merge with existing context
740
+ local merged_context=$(jq -s '.[0] * .[1]' "$CONTEXT_FILE" "$context_file")
741
+ echo "$merged_context" > "$context_file"
742
+ fi
743
+
744
+ if [[ "$DRY_RUN" == false ]]; then
745
+ # Docker container environment: Agent spawning skill will extract
746
+ # success_criteria_b64 from context file and pass to container via:
747
+ # docker run --env AGENT_SUCCESS_CRITERIA_B64=<base64-encoded-json>
748
+ # This enables secure test-driven validation in containerized agents
749
+
750
+ local agent_id
751
+ local spawn_output
752
+ spawn_output=$("$AGENT_SPAWNING_SKILL" \
753
+ "$agent_type" \
754
+ "$task_id" \
755
+ "" \
756
+ --context "$context_file" \
757
+ --memory-limit "${MEMORY_LIMIT:-1g}" \
758
+ --network "${NETWORK:-mcp-network}" 2>&1) || {
759
+ log_error "Spawning script failed for $agent_type"
760
+ log_error "Output: $spawn_output"
761
+ return 1
762
+ }
763
+ agent_id=$(echo "$spawn_output" | grep -o 'Agent ID: [^[:space:]]*' | head -1 | cut -d' ' -f3 || echo "")
764
+
765
+ if [[ -n "$agent_id" ]]; then
766
+ agent_ids+=("$agent_id")
767
+
768
+ # Register agent in Redis
769
+ "$REDIS_COORDINATION_SKILL" register-agent \
770
+ --agent-id "$agent_id" \
771
+ --agent-type "$agent_type" \
772
+ --task-id "$task_id"
773
+
774
+ log_success "Agent spawned: $agent_id ($agent_type)"
775
+ else
776
+ log_error "Failed to spawn agent: $agent_type"
777
+ return 1
778
+ fi
779
+ else
780
+ log "DRY RUN: Would spawn agent: $agent_type"
781
+ fi
782
+ done
783
+
784
+ # Validate agents were spawned successfully
785
+ if [[ "$DRY_RUN" == false && ${#agent_ids[@]} -eq 0 ]]; then
786
+ log_error "No agents were spawned successfully"
787
+ return 1
788
+ fi
789
+
790
+ if [[ "$DRY_RUN" == false && ${#agent_ids[@]} -gt 0 ]]; then
791
+ log_loop "Loop 3 agents spawned: ${#agent_ids[@]} agents"
792
+ # Store agent IDs for monitoring
793
+ printf '%s\n' "${agent_ids[@]}" > "/tmp/loop3-agents-${task_id}-${iteration}.txt"
794
+ fi
795
+
796
+ # Cleanup
797
+ rm -f "$context_file"
798
+ }
799
+
800
+ monitor_loop3() {
801
+ local task_id="$1"
802
+ local gate_threshold="${2:-$GATE_THRESHOLD}"
803
+ local iteration="${3:-1}"
804
+
805
+ log_loop "Monitoring Loop 3 completion (iteration $iteration)"
806
+
807
+ # Get spawned agents
808
+ local agents_file="/tmp/loop3-agents-${task_id}-${iteration}.txt"
809
+ if [[ ! -f "$agents_file" ]]; then
810
+ log_error "No Loop 3 agents found for task: $task_id"
811
+ return 1
812
+ fi
813
+
814
+ local agent_count=$(wc -l < "$agents_file")
815
+ log "Waiting for $agent_count agents to complete"
816
+
817
+ # Wait for agent completion
818
+ if "$REDIS_COORDINATION_SKILL" wait-loop \
819
+ --task-id "$task_id" \
820
+ --loop-number 3 \
821
+ --agent-count "$agent_count" \
822
+ --timeout "${TIMEOUT:-$DEFAULT_LOOP3_TIMEOUT}"; then
823
+
824
+ log_success "All Loop 3 agents completed"
825
+
826
+ # Collect confidence scores for gate check
827
+ local total_confidence=0
828
+ local completed_agents=0
829
+
830
+ while IFS= read -r agent_id; do
831
+ local confidence=$("$REDIS_COORDINATION_SKILL" get-context "$task_id" "$agent_id" 2>/dev/null | jq -r '.confidence // 0.0')
832
+ if [[ "$confidence" != "0.0" && "$confidence" != "null" ]]; then
833
+ total_confidence=$(echo "$total_confidence + $confidence" | bc -l)
834
+ ((completed_agents++))
835
+ if [[ "$VERBOSE" == true ]]; then
836
+ log "Agent $agent_id confidence: $confidence"
837
+ fi
838
+ fi
839
+ done < "$agents_file"
840
+
841
+ if [[ $completed_agents -gt 0 ]]; then
842
+ local average_confidence=$(echo "scale=3; $total_confidence / $completed_agents" | bc -l)
843
+ log "Gate result: $average_confidence >= $gate_threshold"
844
+
845
+ if (( $(echo "$average_confidence >= $gate_threshold" | bc -l) )); then
846
+ log_success "Loop 3 gate PASSED (confidence: $average_confidence)"
847
+ return 0
848
+ else
849
+ log_warning "Loop 3 gate FAILED (confidence: $average_confidence)"
850
+ return 1
851
+ fi
852
+ else
853
+ log_error "No confidence scores collected from agents"
854
+ return 1
855
+ fi
856
+ else
857
+ log_error "Loop 3 completion timeout or failure"
858
+ return 1
859
+ fi
860
+ }
861
+
862
+ gate_check() {
863
+ local task_id="$1"
864
+ local gate_threshold="${2:-$GATE_THRESHOLD}"
865
+ local iteration="${3:-1}"
866
+ local max_iterations="${4:-$MAX_ITERATIONS}"
867
+
868
+ log_loop "Performing gate check for iteration $iteration"
869
+
870
+ # First, ensure Loop 3 agents have completed
871
+ if ! monitor_loop3 "$task_id" "$gate_threshold" "$iteration"; then
872
+ log_error "Loop 3 monitoring failed"
873
+ return 1
874
+ fi
875
+
876
+ # Get Loop 3 agent IDs for gate check
877
+ local agents_file="/tmp/loop3-agents-${task_id}-${iteration}.txt"
878
+ local loop3_agent_ids=""
879
+
880
+ if [[ -f "$agents_file" ]]; then
881
+ loop3_agent_ids=$(cat "$agents_file" | tr '\n' ',' | sed 's/,$//')
882
+ else
883
+ log_error "No Loop 3 agent IDs found for gate check"
884
+ return 1
885
+ fi
886
+
887
+ # Load success criteria from Redis
888
+ local gate_success_criteria=""
889
+ if command -v redis-cli >/dev/null 2>&1; then
890
+ gate_success_criteria=$(redis-cli HGET "task:${task_id}:context" "success-criteria" 2>/dev/null || echo "")
891
+ fi
892
+
893
+ # Fallback to global SUCCESS_CRITERIA
894
+ if [[ -z "$gate_success_criteria" && -n "$SUCCESS_CRITERIA" ]]; then
895
+ gate_success_criteria="$SUCCESS_CRITERIA"
896
+ fi
897
+
898
+ # Use test-driven gate check helper if available
899
+ local GATE_CHECK_HELPER="$PROJECT_ROOT/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh"
900
+
901
+ if [[ -x "$GATE_CHECK_HELPER" ]]; then
902
+ log "Using test-driven gate check"
903
+
904
+ # Prepare arguments
905
+ local gate_args=(
906
+ --task-id "$task_id"
907
+ --agents "$loop3_agent_ids"
908
+ --threshold "$gate_threshold"
909
+ --min-quorum "0.66"
910
+ --mode "$MODE"
911
+ )
912
+
913
+ # Add success criteria if available
914
+ if [[ -n "$gate_success_criteria" ]]; then
915
+ gate_args+=(--success-criteria "$gate_success_criteria")
916
+ gate_args+=(--strategy "test-driven")
917
+ else
918
+ gate_args+=(--strategy "confidence")
919
+ log_warning "No success criteria available, using confidence-based gate check"
920
+ fi
921
+
922
+ if "$GATE_CHECK_HELPER" "${gate_args[@]}"; then
923
+ # Gate passed - proceed to Loop 2
924
+ log_success "Gate PASSED - proceeding to Loop 2 validation"
925
+
926
+ # Signal gate passed for Loop 2 agents
927
+ if command -v redis-cli >/dev/null 2>&1; then
928
+ redis-cli LPUSH "cfn_docker:task:$task_id:gate-passed" "proceed" > /dev/null 2>&1 || true
929
+ fi
930
+
931
+ return 0
932
+ else
933
+ # Gate failed - check if we can iterate
934
+ if [[ $iteration -lt $max_iterations ]]; then
935
+ log_warning "Gate FAILED - iterating Loop 3 ($iteration/$max_iterations)"
936
+
937
+ # Force next iteration
938
+ spawn_loop3 "$task_id" "$AGENTS" $((iteration + 1))
939
+ return 2 # Signal to iterate
940
+ else
941
+ log_error "Gate FAILED - max iterations reached ($max_iterations)"
942
+ return 1
943
+ fi
944
+ fi
945
+ else
946
+ # Fallback to legacy confidence-based gate check
947
+ log_warning "Gate check helper not found, using legacy confidence-based validation"
948
+
949
+ # The monitor_loop3 function already checked confidence
950
+ # If we got here, monitoring succeeded, so gate passes
951
+ log_success "Gate PASSED (legacy mode)"
952
+
953
+ # Signal gate passed
954
+ if command -v redis-cli >/dev/null 2>&1; then
955
+ redis-cli LPUSH "cfn_docker:task:$task_id:gate-passed" "proceed" > /dev/null 2>&1 || true
956
+ fi
957
+
958
+ return 0
959
+ fi
960
+ }
961
+
962
+ spawn_loop2() {
963
+ local task_id="$1"
964
+ local loop3_work="$2"
965
+
966
+ log_loop "Spawning Loop 2 validators"
967
+
968
+ # Standard Loop 2 agents
969
+ local validators="reviewer,tester"
970
+
971
+ # Add security specialist for sensitive tasks
972
+ if [[ "$TASK_DESCRIPTION" =~ (security|auth|password|encryption) ]]; then
973
+ validators="$validators,security-specialist"
974
+ fi
975
+
976
+ # Create Loop 2 context
977
+ local context_file="/tmp/task-context-${task_id}-loop2.json"
978
+ cat > "$context_file" << EOF
979
+ {
980
+ "task_id": "$task_id",
981
+ "loop_number": 2,
982
+ "iteration": 1,
983
+ "mode": "$MODE",
984
+ "role": "validator",
985
+ "task_description": "$TASK_DESCRIPTION",
986
+ "consensus_threshold": $CONSENSUS_THRESHOLD,
987
+ "loop3_work": "$loop3_work",
988
+ "instructions": "Review and validate the implementation from Loop 3. Check for quality, correctness, and adherence to requirements. Provide your confidence in the implementation (0.0-1.0) and specific feedback.",
989
+ "created_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
990
+ }
991
+ EOF
992
+
993
+ # Spawn validator agents
994
+ IFS=',' read -ra VALIDATOR_ARRAY <<< "$validators"
995
+ local validator_ids=()
996
+
997
+ for validator_type in "${VALIDATOR_ARRAY[@]}"; do
998
+ validator_type=$(echo "$validator_type" | xargs) # trim whitespace
999
+
1000
+ log "Spawning validator: $validator_type"
1001
+
1002
+ if [[ "$DRY_RUN" == false ]]; then
1003
+ local validator_id
1004
+ validator_id=$("$AGENT_SPAWNING_SKILL" \
1005
+ "$validator_type" \
1006
+ "$task_id" \
1007
+ "" \
1008
+ --context "$context_file" \
1009
+ --memory-limit "${MEMORY_LIMIT:-1g}" \
1010
+ --network "${NETWORK:-mcp-network}" 2>&1 | grep -o '^Agent ID: [^[:space]]*' | cut -d' ' -f3)
1011
+
1012
+ if [[ -n "$validator_id" ]]; then
1013
+ validator_ids+=("$validator_id")
1014
+
1015
+ # Register validator in Redis
1016
+ "$REDIS_COORDINATION_SKILL" register-agent \
1017
+ --agent-id "$validator_id" \
1018
+ --agent-type "$validator_type" \
1019
+ --task-id "$task_id"
1020
+
1021
+ log_success "Validator spawned: $validator_id ($validator_type)"
1022
+ else
1023
+ log_error "Failed to spawn validator: $validator_type"
1024
+ fi
1025
+ else
1026
+ log "DRY RUN: Would spawn validator: $validator_type"
1027
+ fi
1028
+ done
1029
+
1030
+ if [[ "$DRY_RUN" == false && ${#validator_ids[@]} -gt 0 ]]; then
1031
+ log_loop "Loop 2 validators spawned: ${#validator_ids[@]} validators"
1032
+ # Store validator IDs for monitoring
1033
+ printf '%s\n' "${validator_ids[@]}" > "/tmp/loop2-agents-${task_id}.txt"
1034
+ fi
1035
+
1036
+ # Cleanup
1037
+ rm -f "$context_file"
1038
+ }
1039
+
1040
+ collect_consensus() {
1041
+ local task_id="$1"
1042
+ local consensus_threshold="${2:-$CONSENSUS_THRESHOLD}"
1043
+
1044
+ log_loop "Collecting Loop 2 consensus (threshold: $consensus_threshold)"
1045
+
1046
+ # Get spawned validators
1047
+ local validators_file="/tmp/loop2-agents-${task_id}.txt"
1048
+ if [[ ! -f "$validators_file" ]]; then
1049
+ log_error "No Loop 2 validators found for task: $task_id"
1050
+ return 1
1051
+ fi
1052
+
1053
+ local validator_count=$(wc -l < "$validators_file")
1054
+ log "Waiting for $validator_count validators to complete"
1055
+
1056
+ # Wait for validator completion
1057
+ if "$REDIS_COORDINATION_SKILL" wait-loop \
1058
+ --task-id "$task_id" \
1059
+ --loop-number 2 \
1060
+ --agent-count "$validator_count" \
1061
+ --timeout "${TIMEOUT:-$DEFAULT_LOOP2_TIMEOUT}"; then
1062
+
1063
+ # Collect consensus
1064
+ if "$REDIS_COORDINATION_SKILL" collect-consensus \
1065
+ --task-id "$task_id" \
1066
+ --loop-number 2 \
1067
+ --required-consensus "$consensus_threshold"; then
1068
+
1069
+ log_success "Loop 2 consensus collected and PASSED"
1070
+ return 0
1071
+ else
1072
+ log_error "Loop 2 consensus collection FAILED or threshold not met"
1073
+ return 1
1074
+ fi
1075
+ else
1076
+ log_error "Loop 2 validator completion timeout"
1077
+ return 1
1078
+ fi
1079
+ }
1080
+
1081
+ trigger_po_decision() {
1082
+ local task_id="$1"
1083
+ local consensus_data="$2"
1084
+
1085
+ log_loop "Triggering Product Owner decision"
1086
+
1087
+ # Create PO context
1088
+ local context_file="/tmp/task-context-${task_id}-po.json"
1089
+ cat > "$context_file" << EOF
1090
+ {
1091
+ "task_id": "$task_id",
1092
+ "loop_number": 4,
1093
+ "role": "product-owner",
1094
+ "mode": "$MODE",
1095
+ "task_description": "$TASK_DESCRIPTION",
1096
+ "consensus_data": "$consensus_data",
1097
+ "instructions": "Review the consensus data and make a strategic decision: PROCEED (implementation complete), ITERATE (needs more work), or ABORT (task not feasible). Use GOAP methodology for decision analysis.",
1098
+ "created_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
1099
+ }
1100
+ EOF
1101
+
1102
+ # Spawn Product Owner
1103
+ log "Spawning Product Owner for decision"
1104
+
1105
+ if [[ "$DRY_RUN" == false ]]; then
1106
+ local po_id
1107
+ po_id=$("$AGENT_SPAWNING_SKILL" \
1108
+ "product-owner" \
1109
+ "$task_id" \
1110
+ "" \
1111
+ --context "$context_file" \
1112
+ --memory-limit "${MEMORY_LIMIT:-1g}" \
1113
+ --network "${NETWORK:-mcp-network}" 2>&1 | grep -o '^Agent ID: [^[:space:]]*' | cut -d' ' -f3)
1114
+
1115
+ if [[ -n "$po_id" ]]; then
1116
+ log_success "Product Owner spawned: $po_id"
1117
+
1118
+ # Wait for PO decision (with timeout)
1119
+ if "$REDIS_COORDINATION_SKILL" wait-loop \
1120
+ --task-id "$task_id" \
1121
+ --loop-number 4 \
1122
+ --agent-count 1 \
1123
+ --timeout "${TIMEOUT:-$DEFAULT_PO_TIMEOUT}"; then
1124
+
1125
+ log_success "Product Owner decision completed"
1126
+ return 0
1127
+ else
1128
+ log_error "Product Owner decision timeout"
1129
+ return 1
1130
+ fi
1131
+ else
1132
+ log_error "Failed to spawn Product Owner"
1133
+ return 1
1134
+ fi
1135
+ else
1136
+ log "DRY RUN: Would spawn Product Owner"
1137
+ fi
1138
+
1139
+ # Cleanup
1140
+ rm -f "$context_file"
1141
+ }
1142
+
1143
+ ################################################################################
1144
+ # MEMORY BUDGET VALIDATION
1145
+ ################################################################################
1146
+
1147
+ validate_memory_budget() {
1148
+ local batching_plan="$1"
1149
+
1150
+ if [[ ! -f "$batching_plan" ]]; then
1151
+ log_error "Batching plan not found: $batching_plan"
1152
+ return 1
1153
+ fi
1154
+
1155
+ # Parse available Docker memory
1156
+ local available_memory
1157
+ available_memory=$(docker info --format '{{.MemTotal}}' 2>/dev/null || echo "0")
1158
+
1159
+ if [[ "$available_memory" -eq 0 ]]; then
1160
+ log_warning "Cannot determine Docker memory - skipping memory validation"
1161
+ return 0
1162
+ fi
1163
+
1164
+ # Calculate required memory from plan
1165
+ local total_memory=0
1166
+ local wave_count
1167
+ wave_count=$(jq '.waves | length' "$batching_plan" 2>/dev/null || echo "0")
1168
+
1169
+ for wave_idx in $(seq 0 $((wave_count - 1))); do
1170
+ local containers_in_wave
1171
+ containers_in_wave=$(jq ".waves[$wave_idx].batch_count // 0" "$batching_plan" 2>/dev/null || echo "0")
1172
+
1173
+ # Default memory per container (512MB)
1174
+ local memory_per_container=$((512 * 1024 * 1024))
1175
+
1176
+ # Check for tier-specific memory
1177
+ local tier
1178
+ tier=$(jq ".waves[$wave_idx].tier // 1" "$batching_plan" 2>/dev/null || echo "1")
1179
+
1180
+ case "$tier" in
1181
+ 1) memory_per_container=$((512 * 1024 * 1024)) ;;
1182
+ 2) memory_per_container=$((600 * 1024 * 1024)) ;;
1183
+ 3) memory_per_container=$((800 * 1024 * 1024)) ;;
1184
+ 4) memory_per_container=$((1024 * 1024 * 1024)) ;;
1185
+ esac
1186
+
1187
+ local wave_memory=$((containers_in_wave * memory_per_container))
1188
+ total_memory=$((total_memory + wave_memory))
1189
+
1190
+ log "Wave $((wave_idx + 1)): $containers_in_wave containers × $((memory_per_container / 1024 / 1024))MB = $((wave_memory / 1024 / 1024))MB"
1191
+ done
1192
+
1193
+ # Compare with available memory
1194
+ local total_memory_gb=$((total_memory / 1024 / 1024 / 1024))
1195
+ local available_memory_gb=$((available_memory / 1024 / 1024 / 1024))
1196
+
1197
+ log "Memory validation: Required $total_memory_gb GB / Available $available_memory_gb GB"
1198
+
1199
+ if [[ $total_memory -gt $available_memory ]]; then
1200
+ log_error "Insufficient memory: Required $total_memory_gb GB exceeds available $available_memory_gb GB"
1201
+ return 1
1202
+ fi
1203
+
1204
+ log_success "Memory validation passed"
1205
+ return 0
1206
+ }
1207
+
1208
+ ################################################################################
1209
+ # CHECKPOINT MANAGEMENT
1210
+ ################################################################################
1211
+
1212
+ check_checkpoint_recovery() {
1213
+ local task_id="$1"
1214
+
1215
+ if [[ -z "$task_id" ]]; then
1216
+ log_error "check_checkpoint_recovery requires: task_id"
1217
+ return 1
1218
+ fi
1219
+
1220
+ if [[ ! -x "$CHECKPOINT_RESUME_SCRIPT" ]]; then
1221
+ log_warning "Checkpoint recovery script not found: $CHECKPOINT_RESUME_SCRIPT"
1222
+ return 1
1223
+ fi
1224
+
1225
+ log "Checking for existing checkpoints for task: $task_id"
1226
+
1227
+ # Source the resume script functions
1228
+ source "$CHECKPOINT_RESUME_SCRIPT" 2>/dev/null || {
1229
+ log_warning "Failed to source checkpoint resume script"
1230
+ return 1
1231
+ }
1232
+
1233
+ # Check if resumable waves exist
1234
+ if get_resumable_waves "$task_id" > /tmp/resumable_waves.txt 2>/dev/null; then
1235
+ local wave_count
1236
+ wave_count=$(wc -l < /tmp/resumable_waves.txt)
1237
+
1238
+ if [[ $wave_count -gt 0 ]]; then
1239
+ log_success "Found $wave_count checkpoint(s) for recovery"
1240
+ return 0
1241
+ fi
1242
+ fi
1243
+
1244
+ return 1
1245
+ }
1246
+
1247
+ resume_from_checkpoint() {
1248
+ local task_id="$1"
1249
+
1250
+ if [[ -z "$task_id" ]]; then
1251
+ log_error "resume_from_checkpoint requires: task_id"
1252
+ return 1
1253
+ fi
1254
+
1255
+ if [[ ! -x "$CHECKPOINT_RESUME_SCRIPT" ]]; then
1256
+ log_error "Checkpoint recovery script not found: $CHECKPOINT_RESUME_SCRIPT"
1257
+ return 1
1258
+ fi
1259
+
1260
+ log "Attempting to resume from checkpoint for task: $task_id"
1261
+
1262
+ # Call resume script
1263
+ if "$CHECKPOINT_RESUME_SCRIPT" resume "$task_id"; then
1264
+ log_success "Successfully resumed from checkpoint"
1265
+ return 0
1266
+ else
1267
+ log_error "Failed to resume from checkpoint"
1268
+ return 1
1269
+ fi
1270
+ }
1271
+
1272
+ save_wave_checkpoint() {
1273
+ local task_id="$1"
1274
+ local wave_number="$2"
1275
+ local container_ids="$3"
1276
+ local batch_count="$4"
1277
+
1278
+ if [[ -z "$task_id" ]] || [[ -z "$wave_number" ]] || [[ -z "$container_ids" ]]; then
1279
+ log_warning "Invalid checkpoint parameters, skipping checkpoint save"
1280
+ return 0 # Non-fatal
1281
+ fi
1282
+
1283
+ if [[ ! -x "$CHECKPOINT_SAVE_SCRIPT" ]]; then
1284
+ log_warning "Checkpoint save script not found, skipping checkpoint"
1285
+ return 0 # Non-fatal
1286
+ fi
1287
+
1288
+ log "Saving checkpoint for wave $wave_number"
1289
+
1290
+ # Call save script
1291
+ if "$CHECKPOINT_SAVE_SCRIPT" \
1292
+ save "$task_id" "$wave_number" "$container_ids" "$(date +%s)" "$batch_count" >/dev/null 2>&1; then
1293
+ log_success "Checkpoint saved for wave $wave_number"
1294
+ return 0
1295
+ else
1296
+ log_warning "Failed to save checkpoint (execution will continue)"
1297
+ return 0 # Non-fatal
1298
+ fi
1299
+ }
1300
+
1301
+ cleanup_orphaned_containers() {
1302
+ local task_id="$1"
1303
+ local wave_number="${2:-}"
1304
+
1305
+ if [[ -z "$task_id" ]]; then
1306
+ log_error "cleanup_orphaned_containers requires: task_id"
1307
+ return 1
1308
+ fi
1309
+
1310
+ if [[ ! -x "$CHECKPOINT_CLEANUP_SCRIPT" ]]; then
1311
+ log_warning "Checkpoint cleanup script not found, skipping orphan cleanup"
1312
+ return 0
1313
+ fi
1314
+
1315
+ log "Cleaning up orphaned containers for task: $task_id"
1316
+
1317
+ if [[ -z "$wave_number" ]]; then
1318
+ # Cleanup all waves
1319
+ if "$CHECKPOINT_CLEANUP_SCRIPT" cleanup "$task_id" >/dev/null 2>&1; then
1320
+ log_success "Orphan cleanup completed"
1321
+ return 0
1322
+ fi
1323
+ else
1324
+ # Cleanup specific wave
1325
+ if "$CHECKPOINT_CLEANUP_SCRIPT" cleanup "$task_id" "$wave_number" >/dev/null 2>&1; then
1326
+ log_success "Orphan cleanup completed for wave $wave_number"
1327
+ return 0
1328
+ fi
1329
+ fi
1330
+
1331
+ log_warning "Orphan cleanup encountered errors (non-fatal)"
1332
+ return 0
1333
+ }
1334
+
1335
+ # Mode A: Wave Execution Operations
1336
+
1337
+ spawn_wave() {
1338
+ local task_id="$1"
1339
+ local wave_number="$2"
1340
+ local plan_file="$3"
1341
+
1342
+ if [[ -z "$task_id" ]] || [[ -z "$wave_number" ]] || [[ -z "$plan_file" ]]; then
1343
+ log_error "spawn_wave requires: task_id, wave_number, plan_file"
1344
+ return 1
1345
+ fi
1346
+
1347
+ if [[ ! -f "$plan_file" ]]; then
1348
+ log_error "Batching plan not found: $plan_file"
1349
+ return 1
1350
+ fi
1351
+
1352
+ log "Spawning wave $wave_number for task: $task_id"
1353
+
1354
+ # Validate plan has expected wave
1355
+ if ! jq -e ".waves[$((wave_number - 1))]" "$plan_file" > /dev/null 2>&1; then
1356
+ log_error "Wave $wave_number not found in plan"
1357
+ return 1
1358
+ fi
1359
+
1360
+ # Call wave-execution skill
1361
+ if [[ ! -x "$WAVE_SPAWN_SCRIPT" ]]; then
1362
+ log_error "Wave spawn script not found or not executable: $WAVE_SPAWN_SCRIPT"
1363
+ return 1
1364
+ fi
1365
+
1366
+ # Spawn containers for this wave
1367
+ local output_file="/tmp/cfn-wave-${task_id}-${wave_number}-spawned.json"
1368
+ if "$WAVE_SPAWN_SCRIPT" \
1369
+ --wave-plan "$plan_file" \
1370
+ --wave-number "$wave_number" \
1371
+ --base-image "claude-flow-novice:latest" \
1372
+ --workspace "$PROJECT_ROOT" \
1373
+ --network "${NETWORK:-mcp-network}" \
1374
+ --output "$output_file"; then
1375
+
1376
+ log_success "Wave $wave_number spawned successfully"
1377
+
1378
+ # Output spawned container IDs for tracking
1379
+ if [[ -f "$output_file" ]]; then
1380
+ cat "$output_file"
1381
+ fi
1382
+ return 0
1383
+ else
1384
+ log_error "Failed to spawn wave $wave_number"
1385
+ return 1
1386
+ fi
1387
+ }
1388
+
1389
+ monitor_wave() {
1390
+ local task_id="$1"
1391
+ local wave_number="$2"
1392
+ local expected_count="$3"
1393
+
1394
+ if [[ -z "$task_id" ]] || [[ -z "$wave_number" ]]; then
1395
+ log_error "monitor_wave requires: task_id, wave_number"
1396
+ return 1
1397
+ fi
1398
+
1399
+ log "Monitoring wave $wave_number for task: $task_id"
1400
+ log "Expected container count: ${expected_count:-N/A}"
1401
+
1402
+ # Use wave execution skill monitoring
1403
+ local timeout="${TIMEOUT:-600}"
1404
+ local monitor_script="$WAVE_EXECUTION_SKILL/monitor-wave.sh"
1405
+
1406
+ if [[ ! -x "$monitor_script" ]]; then
1407
+ log_error "Wave monitor script not found: $monitor_script"
1408
+ return 1
1409
+ fi
1410
+
1411
+ # Monitor containers until completion or timeout
1412
+ if "$monitor_script" \
1413
+ --task-id "$task_id" \
1414
+ --wave-number "$wave_number" \
1415
+ --expected-count "${expected_count:-0}" \
1416
+ --timeout "$timeout"; then
1417
+
1418
+ log_success "Wave $wave_number completed successfully"
1419
+ return 0
1420
+ else
1421
+ local exit_code=$?
1422
+ if [[ $exit_code -eq 2 ]]; then
1423
+ log_error "Wave $wave_number monitoring timeout"
1424
+ else
1425
+ log_error "Wave $wave_number failed"
1426
+ fi
1427
+ return $exit_code
1428
+ fi
1429
+ }
1430
+
1431
+ cleanup_wave() {
1432
+ local task_id="$1"
1433
+ local wave_number="$2"
1434
+
1435
+ if [[ -z "$task_id" ]] || [[ -z "$wave_number" ]]; then
1436
+ log_error "cleanup_wave requires: task_id, wave_number"
1437
+ return 1
1438
+ fi
1439
+
1440
+ log "Cleaning up wave $wave_number for task: $task_id"
1441
+
1442
+ # Use wave execution skill cleanup
1443
+ local cleanup_script="$WAVE_EXECUTION_SKILL/cleanup-wave.sh"
1444
+
1445
+ if [[ ! -x "$cleanup_script" ]]; then
1446
+ log_error "Wave cleanup script not found: $cleanup_script"
1447
+ return 1
1448
+ fi
1449
+
1450
+ # Remove containers and artifacts
1451
+ if "$cleanup_script" \
1452
+ --task-id "$task_id" \
1453
+ --wave-number "$wave_number"; then
1454
+
1455
+ log_success "Wave $wave_number cleaned up successfully"
1456
+ return 0
1457
+ else
1458
+ log_warning "Wave $wave_number cleanup had errors (partial cleanup)"
1459
+ return 1
1460
+ fi
1461
+ }
1462
+
1463
+ validate_errors() {
1464
+ local task_id="$1"
1465
+ local command="$2"
1466
+
1467
+ if [[ -z "$task_id" ]] || [[ -z "$command" ]]; then
1468
+ log_error "validate_errors requires: task_id, command"
1469
+ return 1
1470
+ fi
1471
+
1472
+ log "Running error validation for task: $task_id"
1473
+ log "Command: $command"
1474
+
1475
+ # Create temporary output file for results
1476
+ local output_file="/tmp/cfn-validate-errors-${task_id}.log"
1477
+
1478
+ # Execute validation command and capture output
1479
+ if eval "$command" > "$output_file" 2>&1; then
1480
+ local error_count=0
1481
+ else
1482
+ # Command failed, count errors from output
1483
+ local error_count=$(grep -i "error" "$output_file" 2>/dev/null | wc -l)
1484
+ fi
1485
+
1486
+ log_success "Error validation complete"
1487
+ log "Error count: $error_count"
1488
+
1489
+ # Return JSON results
1490
+ cat << EOF
1491
+ {
1492
+ "task_id": "$task_id",
1493
+ "command": "$command",
1494
+ "error_count": $error_count,
1495
+ "output_file": "$output_file",
1496
+ "timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
1497
+ }
1498
+ EOF
1499
+
1500
+ return 0
1501
+ }
1502
+
1503
+ execute_waves() {
1504
+ local task_id="$1"
1505
+ local plan_file="$2"
1506
+
1507
+ if [[ -z "$task_id" ]] || [[ -z "$plan_file" ]]; then
1508
+ log_error "execute_waves requires: task_id, plan_file"
1509
+ return 1
1510
+ fi
1511
+
1512
+ if [[ ! -f "$plan_file" ]]; then
1513
+ log_error "Batching plan not found: $plan_file"
1514
+ return 1
1515
+ fi
1516
+
1517
+ log "Starting complete wave-based execution for task: $task_id"
1518
+ log "Plan file: $plan_file"
1519
+
1520
+ # Parse wave count from plan
1521
+ local wave_count
1522
+ wave_count=$(jq '.waves | length' "$plan_file" 2>/dev/null)
1523
+
1524
+ if [[ -z "$wave_count" ]] || [[ "$wave_count" -lt 1 ]]; then
1525
+ log_error "Invalid plan: no waves found"
1526
+ return 1
1527
+ fi
1528
+
1529
+ log "Total waves to execute: $wave_count"
1530
+
1531
+ # Validate memory budget before starting
1532
+ if ! validate_memory_budget "$plan_file"; then
1533
+ log_error "Memory budget validation failed - aborting execution"
1534
+ return 1
1535
+ fi
1536
+
1537
+ # Check for checkpoint recovery
1538
+ if check_checkpoint_recovery "$task_id"; then
1539
+ log_warning "Found existing checkpoint for task: $task_id"
1540
+ if resume_from_checkpoint "$task_id"; then
1541
+ log_success "Resumed execution from checkpoint"
1542
+ # Continue monitoring remaining waves
1543
+ else
1544
+ log_warning "Checkpoint resume failed, starting fresh execution"
1545
+ fi
1546
+ fi
1547
+
1548
+ # Track results
1549
+ local results_file="/tmp/cfn-wave-results-${task_id}.json"
1550
+ echo '{"waves": [], "summary": {"total": 0, "succeeded": 0, "failed": 0}}' > "$results_file"
1551
+
1552
+ # Execute each wave sequentially
1553
+ for wave_num in $(seq 1 "$wave_count"); do
1554
+ log_loop "=== Wave $wave_num/$wave_count ==="
1555
+
1556
+ # Get batch count for this wave
1557
+ local batch_count
1558
+ batch_count=$(jq ".waves[$((wave_num - 1))].batch_count // 0" "$plan_file" 2>/dev/null)
1559
+
1560
+ # Spawn wave
1561
+ if ! spawn_wave "$task_id" "$wave_num" "$plan_file"; then
1562
+ log_error "Failed to spawn wave $wave_num"
1563
+ # Attempt orphan cleanup before exiting
1564
+ cleanup_orphaned_containers "$task_id" "$wave_num"
1565
+ return 1
1566
+ fi
1567
+
1568
+ # Get container IDs from spawn output for checkpoint
1569
+ local container_ids
1570
+ container_ids=$(docker ps -a --filter "label=cfn.task=$task_id" --filter "label=cfn.wave=$wave_num" --format "{{.ID}}" 2>/dev/null | tr '\n' ',' | sed 's/,$//')
1571
+
1572
+ # Validate container IDs before saving checkpoint
1573
+ if [[ -z "$container_ids" ]]; then
1574
+ log_error "No containers found for wave $wave_num - checkpoint not saved"
1575
+ cleanup_orphaned_containers "$task_id" "$wave_num"
1576
+ return 1
1577
+ fi
1578
+
1579
+ # Save checkpoint after successful spawn
1580
+ save_wave_checkpoint "$task_id" "$wave_num" "$container_ids" "$batch_count"
1581
+
1582
+ # Monitor wave completion
1583
+ if ! monitor_wave "$task_id" "$wave_num" "$batch_count"; then
1584
+ log_error "Wave $wave_num failed or timed out"
1585
+ # Attempt orphan cleanup before exiting
1586
+ cleanup_orphaned_containers "$task_id" "$wave_num"
1587
+ return 1
1588
+ fi
1589
+
1590
+ # Update results
1591
+ jq --arg wn "$wave_num" --arg status "completed" '.waves += [{wave_number: ($wn | tonumber), status: $status}]' "$results_file" > "${results_file}.tmp" && \
1592
+ mv "${results_file}.tmp" "$results_file"
1593
+
1594
+ log_success "Wave $wave_num completed"
1595
+ done
1596
+
1597
+ # Final cleanup and validation
1598
+ log "Finalizing wave execution..."
1599
+
1600
+ for wave_num in $(seq 1 "$wave_count"); do
1601
+ # Don't cleanup yet - logs may be needed
1602
+ log "Preparing to cleanup wave $wave_num (logs preserved)"
1603
+ done
1604
+
1605
+ # Output final results
1606
+ log_success "Wave execution completed for task: $task_id"
1607
+ cat "$results_file"
1608
+
1609
+ return 0
1610
+ }
1611
+
1612
+ execute() {
1613
+ local task_id="$1"
1614
+ local task_description="$2"
1615
+
1616
+ log "Starting complete CFN Loop execution for task: $task_id"
1617
+ log "Description: $task_description"
1618
+ log "Mode: $MODE"
1619
+
1620
+ # Analyze task and select agents if not specified (includes planning phase)
1621
+ if [[ -z "$AGENTS" ]]; then
1622
+ AGENTS=$(analyze_task "$task_description" "$task_id")
1623
+ fi
1624
+
1625
+ # Initialize orchestration
1626
+ init "$task_id" "$CONTEXT_FILE"
1627
+
1628
+ # Main loop execution
1629
+ local iteration=1
1630
+ while [[ $iteration -le $MAX_ITERATIONS ]]; do
1631
+ log_loop "=== Iteration $iteration/$MAX_ITERATIONS ==="
1632
+
1633
+ # Spawn Loop 3 implementers
1634
+ spawn_loop3 "$task_id" "$AGENTS" "$iteration"
1635
+
1636
+ # Gate check
1637
+ gate_check "$task_id" "$GATE_THRESHOLD" "$iteration" "$MAX_ITERATIONS"
1638
+ gate_result=$?
1639
+ case $gate_result in
1640
+ 0) # Gate passed
1641
+ log_loop "Gate PASSED - proceeding to Loop 2"
1642
+ break
1643
+ ;;
1644
+ 1) # Gate failed, max iterations reached
1645
+ log_error "Gate FAILED - max iterations reached"
1646
+ return 1
1647
+ ;;
1648
+ 2) # Gate failed, iterate
1649
+ ((iteration++))
1650
+ continue
1651
+ ;;
1652
+ *)
1653
+ log_error "Invalid gate result: $gate_result"
1654
+ return 1
1655
+ ;;
1656
+ esac
1657
+ done
1658
+
1659
+ # Spawn Loop 2 validators
1660
+ spawn_loop2 "$task_id" "Loop 3 implementation completed"
1661
+
1662
+ # Collect consensus
1663
+ if collect_consensus "$task_id" "$CONSENSUS_THRESHOLD"; then
1664
+ # Trigger Product Owner decision
1665
+ trigger_po_decision "$task_id" "Consensus achieved"
1666
+ log_success "CFN Loop execution completed successfully"
1667
+ else
1668
+ log_error "CFN Loop execution failed at consensus stage"
1669
+ return 1
1670
+ fi
1671
+ }
1672
+
1673
+ # Main operation dispatcher
1674
+ case "$OPERATION" in
1675
+ execute)
1676
+ execute "$TASK_ID" "$TASK_DESCRIPTION"
1677
+ ;;
1678
+ init)
1679
+ init "$TASK_ID" "$CONTEXT_FILE"
1680
+ ;;
1681
+ analyze-task)
1682
+ analyze_task "$TASK_DESCRIPTION"
1683
+ ;;
1684
+ spawn-loop3)
1685
+ spawn_loop3 "$TASK_ID" "$AGENTS" "${FORCE_ITERATION:-1}"
1686
+ ;;
1687
+ monitor-loop3)
1688
+ monitor_loop3 "$TASK_ID" "$GATE_THRESHOLD" "${FORCE_ITERATION:-1}"
1689
+ ;;
1690
+ gate-check)
1691
+ gate_check "$TASK_ID" "$GATE_THRESHOLD" "${FORCE_ITERATION:-1}" "$MAX_ITERATIONS"
1692
+ ;;
1693
+ spawn-loop2)
1694
+ spawn_loop2 "$TASK_ID" ""
1695
+ ;;
1696
+ collect-consensus)
1697
+ collect_consensus "$TASK_ID" "$CONSENSUS_THRESHOLD"
1698
+ ;;
1699
+ trigger-po-decision)
1700
+ trigger_po_decision "$TASK_ID" ""
1701
+ ;;
1702
+ execute-waves)
1703
+ execute_waves "$TASK_ID" "$BATCHING_PLAN"
1704
+ ;;
1705
+ spawn-wave)
1706
+ spawn_wave "$TASK_ID" "$WAVE_NUMBER" "$BATCHING_PLAN"
1707
+ ;;
1708
+ monitor-wave)
1709
+ monitor_wave "$TASK_ID" "$WAVE_NUMBER" "$EXPECTED_COUNT"
1710
+ ;;
1711
+ cleanup-wave)
1712
+ cleanup_wave "$TASK_ID" "$WAVE_NUMBER"
1713
+ ;;
1714
+ validate-errors)
1715
+ validate_errors "$TASK_ID" "$VALIDATION_COMMAND"
1716
+ ;;
1717
+ *)
1718
+ log_error "Unknown operation: $OPERATION"
1719
+ usage
1720
+ exit 1
1721
+ ;;
1722
+ esac