claude-flow-novice 2.15.11 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (636) hide show
  1. package/.claude/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
  2. package/.claude/commands/cfn-loop-cli.md +158 -464
  3. package/.claude/commands/cfn-loop-trigger.md +114 -0
  4. package/.claude/hooks/cfn-invoke-post-edit-ts.sh +100 -0
  5. package/.claude/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
  6. package/.claude/hooks/cfn-invoke-post-edit.sh +22 -0
  7. package/.claude/hooks/cfn-invoke-post-edit.sh.backup +87 -0
  8. package/.claude/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
  9. package/.claude/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
  10. package/.claude/hooks/cfn-invoke-pre-edit.sh +22 -0
  11. package/.claude/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
  12. package/.claude/skills/cfn-agent-spawning/SKILL.md +48 -1
  13. package/.claude/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
  14. package/.claude/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
  15. package/.claude/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
  16. package/.claude/skills/{cfn-redis-coordination/check-dependencies.sh → cfn-agent-spawning/check-dependencies.sh.backup} +3 -5
  17. package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
  18. package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
  19. package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
  20. package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
  21. package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
  22. package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
  23. package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
  24. package/.claude/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
  25. package/.claude/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
  26. package/.claude/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
  27. package/.claude/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
  28. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
  29. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
  30. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
  31. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
  32. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
  33. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
  34. package/.claude/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
  35. package/.claude/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
  36. package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
  37. package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
  38. package/.claude/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
  39. package/.claude/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
  40. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
  41. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
  42. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
  43. package/.claude/skills/cfn-loop-orchestration/SKILL.md +159 -48
  44. package/.claude/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
  45. package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
  46. package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
  47. package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
  48. package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
  49. package/.claude/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
  50. package/.claude/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
  51. package/.claude/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
  52. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
  53. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
  54. package/{claude-assets/skills/cfn-loop-orchestration → .claude/skills/cfn-loop-orchestration/archive/legacy-bash}/orchestrate-wrapper.sh +11 -1
  55. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
  56. package/.claude/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
  57. package/.claude/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
  58. package/.claude/skills/cfn-loop-orchestration/package-lock.json +3 -0
  59. package/.claude/skills/cfn-loop-orchestration/package.json +4 -0
  60. package/.claude/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
  61. package/.claude/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
  62. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
  63. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
  64. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
  65. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
  66. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
  67. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
  68. package/.claude/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
  69. package/.claude/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
  70. package/.claude/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
  71. package/.claude/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
  72. package/.claude/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
  73. package/.claude/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
  74. package/.claude/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
  75. package/.claude/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
  76. package/.claude/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
  77. package/.claude/skills/cfn-loop-orchestration/src/index.ts +2 -0
  78. package/.claude/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
  79. package/.claude/skills/cfn-loop-orchestration/src/types.ts +56 -0
  80. package/.claude/skills/cfn-loop-orchestration/test-cli.sh +92 -0
  81. package/.claude/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
  82. package/.claude/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
  83. package/.claude/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
  84. package/.claude/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
  85. package/.claude/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
  86. package/.claude/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
  87. package/.claude/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
  88. package/.claude/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
  89. package/.claude/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
  90. package/.claude/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
  91. package/.claude/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
  92. package/.claude/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
  93. package/.claude/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
  94. package/.claude/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
  95. package/.claude/skills/cfn-loop-validation/INDEX.md +531 -0
  96. package/.claude/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
  97. package/.claude/skills/cfn-loop-validation/SKILL.md +48 -1
  98. package/.claude/skills/cfn-loop-validation/SKILL.md.backup +353 -0
  99. package/.claude/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
  100. package/.claude/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
  101. package/.claude/skills/cfn-loop-validation/check-dependencies.sh +22 -0
  102. package/{claude-assets/skills/cfn-redis-coordination/check-dependencies.sh → .claude/skills/cfn-loop-validation/check-dependencies.sh.backup} +4 -5
  103. package/.claude/skills/cfn-loop-validation/detect-vapor.sh +59 -0
  104. package/.claude/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
  105. package/.claude/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
  106. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
  107. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
  108. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
  109. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
  110. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
  111. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
  112. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
  113. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
  114. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
  115. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
  116. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
  117. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
  118. package/.claude/skills/cfn-loop-validation/dist/types.d.ts +156 -0
  119. package/.claude/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
  120. package/.claude/skills/cfn-loop-validation/dist/types.js +66 -0
  121. package/.claude/skills/cfn-loop-validation/dist/types.js.map +1 -0
  122. package/.claude/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
  123. package/.claude/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
  124. package/.claude/skills/cfn-loop-validation/dist/validator.js +411 -0
  125. package/.claude/skills/cfn-loop-validation/dist/validator.js.map +1 -0
  126. package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
  127. package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
  128. package/.claude/skills/cfn-loop-validation/package.json +93 -0
  129. package/.claude/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
  130. package/.claude/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
  131. package/.claude/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
  132. package/.claude/skills/cfn-loop-validation/src/types.ts +215 -0
  133. package/.claude/skills/cfn-loop-validation/src/validator.ts +503 -0
  134. package/.claude/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
  135. package/.claude/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
  136. package/.claude/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
  137. package/.claude/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
  138. package/.claude/skills/cfn-loop-validation/validate-gate.sh +63 -0
  139. package/.claude/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
  140. package/.claude/skills/cfn-loop-validation/validate-iteration.sh +22 -0
  141. package/.claude/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
  142. package/.claude/skills/cfn-product-owner-decision/SKILL.md +479 -147
  143. package/.claude/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
  144. package/{claude-assets/skills/cfn-product-owner-decision → .claude/skills/cfn-product-owner-decision/archive/legacy-bash}/execute-decision.sh +24 -2
  145. package/.claude/skills/pre-edit-backup/SKILL.md +324 -0
  146. package/.claude/skills/pre-edit-backup/SKILL.md.backup +277 -0
  147. package/.claude/skills/pre-edit-backup/backup.sh +22 -0
  148. package/.claude/skills/pre-edit-backup/backup.sh.backup +107 -0
  149. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +1 -0
  150. package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +1 -0
  151. package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +1 -0
  152. package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +1 -0
  153. package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +10 -0
  154. package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +56 -33
  155. package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +46 -36
  156. package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +9 -0
  157. package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +17 -17
  158. package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +40 -58
  159. package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +18 -20
  160. package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +19 -28
  161. package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +15 -19
  162. package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +15 -10
  163. package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +15 -10
  164. package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +15 -25
  165. package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +17 -21
  166. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +17 -21
  167. package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +1 -5
  168. package/claude-assets/agents/cfn-dev-team/reviewers/code-reviewer.md +20 -51
  169. package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +22 -71
  170. package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +21 -64
  171. package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +22 -67
  172. package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +23 -67
  173. package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +7 -35
  174. package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +8 -37
  175. package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +16 -54
  176. package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +17 -55
  177. package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +9 -37
  178. package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +17 -55
  179. package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +17 -48
  180. package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +8 -37
  181. package/claude-assets/agents/cfn-dev-team/testers/tester.md +7 -27
  182. package/claude-assets/agents/cfn-dev-team/utility/analyst.md +12 -28
  183. package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +13 -13
  184. package/claude-assets/agents/cfn-dev-team/utility/context-curator.md +7 -2
  185. package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +5 -10
  186. package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +120 -714
  187. package/claude-assets/agents/cfn-dev-team/utility/researcher.md +12 -21
  188. package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +146 -572
  189. package/claude-assets/agents/custom/cfn-docker-expert.md +102 -0
  190. package/claude-assets/agents/custom/cfn-loops-cli-expert.md +129 -0
  191. package/claude-assets/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
  192. package/claude-assets/commands/cfn-loop-cli.md +158 -464
  193. package/claude-assets/commands/cfn-loop-trigger.md +114 -0
  194. package/claude-assets/hooks/SKILL.md +518 -0
  195. package/claude-assets/hooks/SKILL.md.backup +471 -0
  196. package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh +100 -0
  197. package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
  198. package/claude-assets/hooks/cfn-invoke-post-edit.sh +22 -0
  199. package/claude-assets/hooks/cfn-invoke-post-edit.sh.backup +87 -0
  200. package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
  201. package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
  202. package/claude-assets/hooks/cfn-invoke-pre-edit.sh +22 -0
  203. package/claude-assets/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
  204. package/claude-assets/skills/cfn-agent-selection-with-fallback/DELIVERABLES.md +409 -0
  205. package/claude-assets/skills/cfn-agent-selection-with-fallback/IMPLEMENTATION_SUMMARY.md +396 -0
  206. package/claude-assets/skills/cfn-agent-selection-with-fallback/INTEGRATION_GUIDE.md +308 -0
  207. package/claude-assets/skills/cfn-agent-selection-with-fallback/QUICK_REFERENCE.md +239 -0
  208. package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md +107 -1
  209. package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md.backup +302 -0
  210. package/claude-assets/skills/cfn-agent-selection-with-fallback/TYPESCRIPT_MIGRATION.md +295 -0
  211. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.cjs +297 -0
  212. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.js +297 -0
  213. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.cjs +96 -0
  214. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.js +96 -0
  215. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh +45 -0
  216. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh.backup +23 -0
  217. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh +22 -0
  218. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh.backup +173 -0
  219. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.test.ts +357 -0
  220. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.ts +350 -0
  221. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/cli.ts +74 -0
  222. package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh +22 -0
  223. package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh.backup +71 -0
  224. package/claude-assets/skills/cfn-agent-selection-with-fallback/tsconfig.json +18 -0
  225. package/claude-assets/skills/cfn-agent-spawning/SKILL.md +48 -1
  226. package/claude-assets/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
  227. package/claude-assets/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
  228. package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
  229. package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh.backup +30 -0
  230. package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
  231. package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
  232. package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
  233. package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
  234. package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
  235. package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
  236. package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
  237. package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
  238. package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
  239. package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
  240. package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
  241. package/claude-assets/skills/cfn-coordination/agent-completion.sh.backup +36 -0
  242. package/claude-assets/skills/cfn-coordination/coordination-signal.sh.backup +36 -0
  243. package/claude-assets/skills/cfn-coordination/coordination-wait.sh.backup +36 -0
  244. package/claude-assets/skills/cfn-dependency-ingestion/README.md +101 -0
  245. package/claude-assets/skills/cfn-dependency-ingestion/SKILL.md +369 -0
  246. package/claude-assets/skills/cfn-dependency-ingestion/build.sh +23 -0
  247. package/claude-assets/skills/cfn-dependency-ingestion/dist/ingest-dependencies.js +478 -0
  248. package/claude-assets/skills/cfn-dependency-ingestion/ingest-dependencies.sh +295 -0
  249. package/claude-assets/skills/cfn-dependency-ingestion/src/ingest-dependencies.ts +563 -0
  250. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
  251. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
  252. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
  253. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
  254. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
  255. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
  256. package/claude-assets/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
  257. package/claude-assets/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
  258. package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
  259. package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
  260. package/claude-assets/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
  261. package/claude-assets/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
  262. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
  263. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
  264. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
  265. package/claude-assets/skills/cfn-loop-orchestration/SKILL.md +159 -48
  266. package/claude-assets/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
  267. package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
  268. package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
  269. package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
  270. package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
  271. package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
  272. package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
  273. package/claude-assets/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
  274. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
  275. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
  276. package/{.claude/skills/cfn-loop-orchestration → claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash}/orchestrate-wrapper.sh +11 -1
  277. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
  278. package/claude-assets/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
  279. package/claude-assets/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
  280. package/claude-assets/skills/cfn-loop-orchestration/package-lock.json +3 -0
  281. package/claude-assets/skills/cfn-loop-orchestration/package.json +4 -0
  282. package/claude-assets/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
  283. package/claude-assets/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
  284. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
  285. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
  286. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
  287. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
  288. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
  289. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
  290. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
  291. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
  292. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
  293. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
  294. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
  295. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
  296. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
  297. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
  298. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
  299. package/claude-assets/skills/cfn-loop-orchestration/src/index.ts +2 -0
  300. package/claude-assets/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
  301. package/claude-assets/skills/cfn-loop-orchestration/src/types.ts +56 -0
  302. package/claude-assets/skills/cfn-loop-orchestration/test-cli.sh +92 -0
  303. package/claude-assets/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
  304. package/claude-assets/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
  305. package/claude-assets/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
  306. package/claude-assets/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
  307. package/claude-assets/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
  308. package/claude-assets/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
  309. package/claude-assets/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
  310. package/claude-assets/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
  311. package/claude-assets/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
  312. package/claude-assets/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
  313. package/claude-assets/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
  314. package/claude-assets/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
  315. package/claude-assets/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
  316. package/claude-assets/skills/cfn-loop-output-processing/.eslintrc.json +33 -0
  317. package/claude-assets/skills/cfn-loop-output-processing/DELIVERY_SUMMARY.txt +462 -0
  318. package/claude-assets/skills/cfn-loop-output-processing/DEPRECATION_NOTICE.md +183 -0
  319. package/claude-assets/skills/cfn-loop-output-processing/EXAMPLES.md +609 -0
  320. package/claude-assets/skills/cfn-loop-output-processing/IMPLEMENTATION_SUMMARY.md +418 -0
  321. package/claude-assets/skills/cfn-loop-output-processing/INDEX.md +531 -0
  322. package/claude-assets/skills/cfn-loop-output-processing/MIGRATION.md +362 -0
  323. package/claude-assets/skills/cfn-loop-output-processing/README.md +114 -0
  324. package/claude-assets/skills/cfn-loop-output-processing/SKILL.md +633 -0
  325. package/{.claude/skills/cfn-docker-redis-coordination → claude-assets/skills/cfn-loop-output-processing}/jest.config.js +7 -15
  326. package/claude-assets/skills/cfn-loop-output-processing/package.json +50 -0
  327. package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop2.ts +195 -0
  328. package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop3.ts +157 -0
  329. package/claude-assets/skills/cfn-loop-output-processing/src/output-processor.ts +632 -0
  330. package/claude-assets/skills/cfn-loop-output-processing/tests/output-processor.test.ts +617 -0
  331. package/claude-assets/skills/{cfn-docker-redis-coordination → cfn-loop-output-processing}/tsconfig.json +16 -7
  332. package/claude-assets/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
  333. package/claude-assets/skills/cfn-loop-validation/INDEX.md +531 -0
  334. package/claude-assets/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
  335. package/claude-assets/skills/cfn-loop-validation/SKILL.md +48 -1
  336. package/claude-assets/skills/cfn-loop-validation/SKILL.md.backup +353 -0
  337. package/claude-assets/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
  338. package/claude-assets/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
  339. package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh +22 -0
  340. package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh.backup +31 -0
  341. package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh +59 -0
  342. package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
  343. package/claude-assets/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
  344. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
  345. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
  346. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
  347. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
  348. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
  349. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
  350. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
  351. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
  352. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
  353. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
  354. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
  355. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
  356. package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts +156 -0
  357. package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
  358. package/claude-assets/skills/cfn-loop-validation/dist/types.js +66 -0
  359. package/claude-assets/skills/cfn-loop-validation/dist/types.js.map +1 -0
  360. package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
  361. package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
  362. package/claude-assets/skills/cfn-loop-validation/dist/validator.js +411 -0
  363. package/claude-assets/skills/cfn-loop-validation/dist/validator.js.map +1 -0
  364. package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
  365. package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
  366. package/claude-assets/skills/cfn-loop-validation/package.json +93 -0
  367. package/claude-assets/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
  368. package/claude-assets/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
  369. package/claude-assets/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
  370. package/claude-assets/skills/cfn-loop-validation/src/types.ts +215 -0
  371. package/claude-assets/skills/cfn-loop-validation/src/validator.ts +503 -0
  372. package/claude-assets/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
  373. package/claude-assets/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
  374. package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
  375. package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
  376. package/claude-assets/skills/cfn-loop-validation/validate-gate.sh +63 -0
  377. package/claude-assets/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
  378. package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh +22 -0
  379. package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
  380. package/claude-assets/skills/cfn-product-owner-decision/SKILL.md +479 -147
  381. package/claude-assets/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
  382. package/{.claude/skills/cfn-product-owner-decision → claude-assets/skills/cfn-product-owner-decision/archive/legacy-bash}/execute-decision.sh +24 -2
  383. package/claude-assets/skills/cfn-provider-routing/README.md +129 -0
  384. package/claude-assets/skills/cfn-provider-routing/SKILL.md +192 -0
  385. package/claude-assets/skills/cfn-provider-routing/resolve-provider-model.ts +223 -0
  386. package/claude-assets/skills/pre-edit-backup/SKILL.md +324 -0
  387. package/claude-assets/skills/pre-edit-backup/SKILL.md.backup +277 -0
  388. package/claude-assets/skills/pre-edit-backup/backup.sh +22 -0
  389. package/claude-assets/skills/pre-edit-backup/backup.sh.backup +107 -0
  390. package/dist/agents/agent-loader.js +146 -165
  391. package/dist/agents/agent-loader.js.map +1 -1
  392. package/dist/api/auth-endpoints.js +415 -0
  393. package/dist/api/auth-endpoints.js.map +1 -0
  394. package/dist/api/task-endpoints.js +562 -0
  395. package/dist/api/task-endpoints.js.map +1 -0
  396. package/dist/backend/server.js +418 -0
  397. package/dist/backend/server.js.map +1 -0
  398. package/dist/cfn-loop/product-owner/decision-parser.js +356 -0
  399. package/dist/cfn-loop/product-owner/decision-parser.js.map +1 -0
  400. package/dist/cfn-loop/product-owner/index.js +1 -0
  401. package/dist/cfn-loop/product-owner/index.js.map +1 -1
  402. package/dist/cli/agent-command.js +1 -1
  403. package/dist/cli/agent-command.js.map +1 -1
  404. package/dist/cli/agent-completion.js +273 -0
  405. package/dist/cli/agent-completion.js.map +1 -0
  406. package/dist/cli/agent-prompt-builder.js +83 -48
  407. package/dist/cli/agent-prompt-builder.js.map +1 -1
  408. package/dist/cli/agent-spawner.js +499 -0
  409. package/dist/cli/agent-spawner.js.map +1 -0
  410. package/dist/cli/anthropic-client.js +10 -3
  411. package/dist/cli/anthropic-client.js.map +1 -1
  412. package/dist/cli/config-manager.js +91 -109
  413. package/dist/cli/index.js +11 -0
  414. package/dist/cli/index.js.map +1 -1
  415. package/dist/cli/parse-decision-cli.js +268 -0
  416. package/dist/cli/parse-decision-cli.js.map +1 -0
  417. package/dist/cli/post-edit-hook.js +83 -0
  418. package/dist/cli/post-edit-hook.js.map +1 -0
  419. package/dist/cli/pre-edit-hook.js +77 -0
  420. package/dist/cli/pre-edit-hook.js.map +1 -0
  421. package/dist/cli/spawn-agent-cli.js +209 -0
  422. package/dist/cli/spawn-agent-cli.js.map +1 -0
  423. package/dist/coordination/coordination-wrapper.js +383 -0
  424. package/dist/coordination/coordination-wrapper.js.map +1 -0
  425. package/dist/coordination/store-success-criteria.js +68 -0
  426. package/dist/coordination/store-success-criteria.js.map +1 -0
  427. package/dist/coordination/store-task-context.js +65 -0
  428. package/dist/coordination/store-task-context.js.map +1 -0
  429. package/dist/hooks/backup-manager.js +273 -0
  430. package/dist/hooks/backup-manager.js.map +1 -0
  431. package/dist/hooks/post-edit-validator.js +388 -0
  432. package/dist/hooks/post-edit-validator.js.map +1 -0
  433. package/dist/integration/index.js +19 -0
  434. package/dist/integration/index.js.map +1 -0
  435. package/dist/integration/task-mode-adapter.js +297 -0
  436. package/dist/integration/task-mode-adapter.js.map +1 -0
  437. package/dist/integration/trigger-dev-client.js +253 -0
  438. package/dist/integration/trigger-dev-client.js.map +1 -0
  439. package/dist/integration/trigger-dev-webhooks.js +362 -0
  440. package/dist/integration/trigger-dev-webhooks.js.map +1 -0
  441. package/dist/lib/path-validator.js +14 -5
  442. package/dist/lib/path-validator.js.map +1 -1
  443. package/dist/lib/redis-queue-manager.js +5 -1
  444. package/dist/lib/redis-queue-manager.js.map +1 -1
  445. package/dist/middleware/authentication.js +317 -0
  446. package/dist/middleware/authentication.js.map +1 -0
  447. package/dist/services/authentication.js +669 -0
  448. package/dist/services/authentication.js.map +1 -0
  449. package/dist/services/session-management.js +436 -0
  450. package/dist/services/session-management.js.map +1 -0
  451. package/dist/services/skill-deployment.js +8 -6
  452. package/dist/services/skill-deployment.js.map +1 -1
  453. package/dist/services/user-service.js +710 -0
  454. package/dist/services/user-service.js.map +1 -0
  455. package/dist/types/trigger-dev-events.d.js +10 -0
  456. package/dist/types/trigger-dev-events.d.js.map +1 -0
  457. package/docs/README.md +240 -0
  458. package/package.json +13 -4
  459. package/scripts/compare-workflow-performance.sh +556 -0
  460. package/scripts/migrate-to-optimized-workflows.sh +438 -0
  461. package/scripts/organize-docs.sh +338 -0
  462. package/scripts/trigger-dev-setup.sh +267 -0
  463. package/.claude/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
  464. package/.claude/skills/cfn-docker-redis-coordination/README.md +0 -294
  465. package/.claude/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
  466. package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
  467. package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
  468. package/.claude/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
  469. package/.claude/skills/cfn-docker-redis-coordination/package.json +0 -40
  470. package/.claude/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
  471. package/.claude/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
  472. package/.claude/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
  473. package/.claude/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
  474. package/.claude/skills/cfn-docker-redis-coordination/tsconfig.json +0 -30
  475. package/.claude/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
  476. package/.claude/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
  477. package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
  478. package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
  479. package/.claude/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
  480. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
  481. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
  482. package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
  483. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
  484. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
  485. package/.claude/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
  486. package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
  487. package/.claude/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
  488. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
  489. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
  490. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
  491. package/.claude/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
  492. package/.claude/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
  493. package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
  494. package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
  495. package/.claude/skills/cfn-redis-coordination/config.json +0 -61
  496. package/.claude/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
  497. package/.claude/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
  498. package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
  499. package/.claude/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
  500. package/.claude/skills/cfn-redis-coordination/jest.config.js +0 -23
  501. package/.claude/skills/cfn-redis-coordination/package-lock.json +0 -5272
  502. package/.claude/skills/cfn-redis-coordination/package.json +0 -45
  503. package/.claude/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
  504. package/.claude/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
  505. package/.claude/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
  506. package/.claude/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
  507. package/.claude/skills/cfn-redis-coordination/src/index.ts +0 -82
  508. package/.claude/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
  509. package/.claude/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
  510. package/.claude/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
  511. package/.claude/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
  512. package/.claude/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
  513. package/.claude/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
  514. package/.claude/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
  515. package/.claude/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
  516. package/.claude/skills/cfn-redis-coordination/src/types.ts +0 -235
  517. package/.claude/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
  518. package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
  519. package/.claude/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
  520. package/.claude/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
  521. package/.claude/skills/cfn-redis-coordination/test-redis-check.js +0 -84
  522. package/.claude/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
  523. package/.claude/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
  524. package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
  525. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +0 -980
  526. package/claude-assets/agents/typescript-specialist.md +0 -280
  527. package/claude-assets/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
  528. package/claude-assets/skills/cfn-docker-redis-coordination/README.md +0 -294
  529. package/claude-assets/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
  530. package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
  531. package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
  532. package/claude-assets/skills/cfn-docker-redis-coordination/jest.config.js +0 -37
  533. package/claude-assets/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
  534. package/claude-assets/skills/cfn-docker-redis-coordination/package.json +0 -40
  535. package/claude-assets/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
  536. package/claude-assets/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
  537. package/claude-assets/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
  538. package/claude-assets/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
  539. package/claude-assets/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
  540. package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
  541. package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
  542. package/claude-assets/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
  543. package/claude-assets/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
  544. package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
  545. package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
  546. package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
  547. package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
  548. package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
  549. package/claude-assets/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
  550. package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
  551. package/claude-assets/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
  552. package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
  553. package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
  554. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
  555. package/claude-assets/skills/cfn-redis-cleanup/cleanup-redis.sh +0 -130
  556. package/claude-assets/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
  557. package/claude-assets/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
  558. package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
  559. package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
  560. package/claude-assets/skills/cfn-redis-coordination/config.json +0 -61
  561. package/claude-assets/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
  562. package/claude-assets/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
  563. package/claude-assets/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
  564. package/claude-assets/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
  565. package/claude-assets/skills/cfn-redis-coordination/jest.config.js +0 -23
  566. package/claude-assets/skills/cfn-redis-coordination/package-lock.json +0 -5272
  567. package/claude-assets/skills/cfn-redis-coordination/package.json +0 -45
  568. package/claude-assets/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
  569. package/claude-assets/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
  570. package/claude-assets/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
  571. package/claude-assets/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
  572. package/claude-assets/skills/cfn-redis-coordination/src/index.ts +0 -82
  573. package/claude-assets/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
  574. package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
  575. package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
  576. package/claude-assets/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
  577. package/claude-assets/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
  578. package/claude-assets/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
  579. package/claude-assets/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
  580. package/claude-assets/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
  581. package/claude-assets/skills/cfn-redis-coordination/src/types.ts +0 -235
  582. package/claude-assets/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
  583. package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
  584. package/claude-assets/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
  585. package/claude-assets/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
  586. package/claude-assets/skills/cfn-redis-coordination/test-redis-check.js +0 -84
  587. package/claude-assets/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
  588. package/claude-assets/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
  589. package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
  590. package/claude-assets/skills/cfn-redis-data-extraction/SKILL.md +0 -442
  591. package/claude-assets/skills/cfn-redis-data-extraction/extract.sh +0 -306
  592. package/dist/coordination/index.js +0 -25
  593. package/dist/coordination/index.js.map +0 -1
  594. package/docs/BUG_19_MEMORY_LEAK_TASK_MODE.md +0 -405
  595. package/docs/MEMORY_CLEANUP_GUIDE.md +0 -358
  596. package/docs/MEMORY_LEAK_FIX_SUMMARY.md +0 -322
  597. package/docs/REDIS_CLEANUP_EXECUTIVE_SUMMARY.md +0 -319
  598. package/docs/REDIS_CLEANUP_VERIFICATION_REPORT.md +0 -574
  599. /package/.claude/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
  600. /package/.claude/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
  601. /package/.claude/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
  602. /package/.claude/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
  603. /package/.claude/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
  604. /package/.claude/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
  605. /package/.claude/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
  606. /package/.claude/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
  607. /package/.claude/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
  608. /package/.claude/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
  609. /package/.claude/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
  610. /package/.claude/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
  611. /package/.claude/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
  612. /package/.claude/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
  613. /package/.claude/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
  614. /package/.claude/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
  615. /package/.claude/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
  616. /package/.claude/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
  617. /package/.claude/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
  618. /package/claude-assets/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
  619. /package/claude-assets/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
  620. /package/claude-assets/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
  621. /package/claude-assets/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
  622. /package/claude-assets/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
  623. /package/claude-assets/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
  624. /package/claude-assets/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
  625. /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
  626. /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
  627. /package/claude-assets/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
  628. /package/claude-assets/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
  629. /package/claude-assets/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
  630. /package/claude-assets/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
  631. /package/claude-assets/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
  632. /package/claude-assets/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
  633. /package/claude-assets/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
  634. /package/claude-assets/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
  635. /package/claude-assets/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
  636. /package/claude-assets/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
@@ -0,0 +1,273 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Agent Completion CLI
4
+ *
5
+ * Signal agent completion with confidence score and test metrics
6
+ *
7
+ * Usage:
8
+ * agent-completion --task-id <id> --agent-id <id> --confidence <score> [options]
9
+ *
10
+ * Required Arguments:
11
+ * --task-id <id> Task identifier
12
+ * --agent-id <id> Agent identifier
13
+ * --confidence <score> Confidence score (0.0-1.0)
14
+ *
15
+ * Optional Arguments:
16
+ * --iteration <n> Iteration number (default: 1)
17
+ * --namespace <ns> Namespace: swarm | cfn_loop (default: swarm)
18
+ * --test-pass-rate <pct> Test pass rate (0.0-1.0)
19
+ * --tests-run <n> Total tests run
20
+ * --tests-passed <n> Tests passed
21
+ * --result <json> Result JSON (test pass rate preferred)
22
+ * --redis-host <h> Redis host (default: localhost)
23
+ * --redis-port <p> Redis port (default: 6379)
24
+ * --json Output result as JSON
25
+ * --help Show this help message
26
+ *
27
+ * Examples:
28
+ * # Simple completion with confidence
29
+ * agent-completion \
30
+ * --task-id task123 \
31
+ * --agent-id agent-loop3-1 \
32
+ * --confidence 0.92
33
+ *
34
+ * # Completion with test metrics (test-driven)
35
+ * agent-completion \
36
+ * --task-id task123 \
37
+ * --agent-id agent-loop3-1 \
38
+ * --confidence 0.95 \
39
+ * --test-pass-rate 0.98 \
40
+ * --tests-run 50 \
41
+ * --tests-passed 49
42
+ *
43
+ * # Validator consensus score
44
+ * agent-completion \
45
+ * --task-id task123 \
46
+ * --agent-id validator-1 \
47
+ * --confidence 0.88 \
48
+ * --iteration 1
49
+ */ import { CoordinationWrapper } from '../coordination/coordination-wrapper.js';
50
+ import * as process from 'process';
51
+ /**
52
+ * Parse command line arguments
53
+ */ function parseArgs() {
54
+ const args = process.argv.slice(2);
55
+ const options = {
56
+ namespace: 'swarm',
57
+ iteration: 1,
58
+ redisHost: process.env.CFN_REDIS_HOST || process.env.REDIS_HOST || 'localhost',
59
+ redisPort: parseInt(process.env.CFN_REDIS_PORT || process.env.REDIS_PORT || '6379'),
60
+ json: false
61
+ };
62
+ for(let i = 0; i < args.length; i++){
63
+ const arg = args[i];
64
+ switch(arg){
65
+ case '--task-id':
66
+ options.taskId = args[++i];
67
+ break;
68
+ case '--agent-id':
69
+ options.agentId = args[++i];
70
+ break;
71
+ case '--confidence':
72
+ options.confidence = parseFloat(args[++i]);
73
+ break;
74
+ case '--iteration':
75
+ options.iteration = parseInt(args[++i]);
76
+ break;
77
+ case '--namespace':
78
+ options.namespace = args[++i];
79
+ break;
80
+ case '--test-pass-rate':
81
+ options.testPassRate = parseFloat(args[++i]);
82
+ break;
83
+ case '--tests-run':
84
+ options.testsRun = parseInt(args[++i]);
85
+ break;
86
+ case '--tests-passed':
87
+ options.testsPassed = parseInt(args[++i]);
88
+ break;
89
+ case '--result':
90
+ options.result = args[++i];
91
+ break;
92
+ case '--redis-host':
93
+ options.redisHost = args[++i];
94
+ break;
95
+ case '--redis-port':
96
+ options.redisPort = parseInt(args[++i]);
97
+ break;
98
+ case '--json':
99
+ options.json = true;
100
+ break;
101
+ case '--help':
102
+ case '-h':
103
+ options.help = true;
104
+ break;
105
+ }
106
+ }
107
+ return options;
108
+ }
109
+ /**
110
+ * Show help message
111
+ */ function showHelp() {
112
+ console.log(`
113
+ Agent Completion CLI - Signal agent completion with test metrics
114
+
115
+ Usage:
116
+ agent-completion --task-id <id> --agent-id <id> --confidence <score> [options]
117
+
118
+ Required Arguments:
119
+ --task-id <id> Task identifier
120
+ --agent-id <id> Agent identifier
121
+ --confidence <score> Confidence score (0.0-1.0)
122
+
123
+ Optional Arguments:
124
+ --iteration <n> Iteration number (default: 1)
125
+ --namespace <ns> Namespace: swarm | cfn_loop (default: swarm)
126
+ --test-pass-rate <pct> Test pass rate (0.0-1.0, preferred over confidence)
127
+ --tests-run <n> Total tests run
128
+ --tests-passed <n> Tests passed
129
+ --result <json> Result JSON (for custom data)
130
+ --redis-host <h> Redis host (default: localhost or CFN_REDIS_HOST env)
131
+ --redis-port <p> Redis port (default: 6379 or CFN_REDIS_PORT env)
132
+ --json Output result as JSON
133
+ --help, -h Show this help message
134
+
135
+ Examples:
136
+ # Simple completion with confidence
137
+ agent-completion \\
138
+ --task-id task123 \\
139
+ --agent-id agent-loop3-1 \\
140
+ --confidence 0.92
141
+
142
+ # Test-driven completion with metrics
143
+ agent-completion \\
144
+ --task-id task123 \\
145
+ --agent-id agent-loop3-1 \\
146
+ --confidence 0.95 \\
147
+ --test-pass-rate 0.98 \\
148
+ --tests-run 50 \\
149
+ --tests-passed 49
150
+
151
+ # Validator consensus
152
+ agent-completion \\
153
+ --task-id task123 \\
154
+ --agent-id validator-1 \\
155
+ --confidence 0.88 \\
156
+ --iteration 1 \\
157
+ --json
158
+
159
+ Environment Variables:
160
+ CFN_REDIS_HOST Redis host
161
+ CFN_REDIS_PORT Redis port
162
+ REDIS_HOST Fallback Redis host
163
+ REDIS_PORT Fallback Redis port
164
+ `);
165
+ }
166
+ /**
167
+ * Validate confidence score
168
+ */ function validateConfidence(score) {
169
+ return typeof score === 'number' && score >= 0 && score <= 1;
170
+ }
171
+ /**
172
+ * Validate test pass rate
173
+ */ function validateTestPassRate(rate) {
174
+ return typeof rate === 'number' && rate >= 0 && rate <= 1;
175
+ }
176
+ /**
177
+ * Main function
178
+ */ async function main() {
179
+ const options = parseArgs();
180
+ if (options.help) {
181
+ showHelp();
182
+ process.exit(0);
183
+ }
184
+ // Validate required arguments
185
+ if (!options.taskId || !options.agentId || options.confidence === undefined) {
186
+ console.error('Error: Missing required arguments');
187
+ console.error('Use --help for usage information');
188
+ process.exit(1);
189
+ }
190
+ // Validate confidence score
191
+ if (!validateConfidence(options.confidence)) {
192
+ console.error('Error: Confidence score must be between 0.0 and 1.0');
193
+ process.exit(1);
194
+ }
195
+ // Validate test pass rate if provided
196
+ if (options.testPassRate !== undefined && !validateTestPassRate(options.testPassRate)) {
197
+ console.error('Error: Test pass rate must be between 0.0 and 1.0');
198
+ process.exit(1);
199
+ }
200
+ try {
201
+ // Create coordination wrapper
202
+ const coordinator = new CoordinationWrapper({
203
+ taskId: options.taskId,
204
+ namespace: options.namespace || 'swarm',
205
+ redisHost: options.redisHost || 'localhost',
206
+ redisPort: options.redisPort || 6379
207
+ });
208
+ // Connect to Redis
209
+ await coordinator.connect();
210
+ // Build result object
211
+ let resultObj;
212
+ if (options.result) {
213
+ try {
214
+ resultObj = JSON.parse(options.result);
215
+ } catch {
216
+ // If result is not valid JSON, store as string
217
+ resultObj = {
218
+ result: options.result
219
+ };
220
+ }
221
+ }
222
+ // Signal completion
223
+ await coordinator.signalCompletion(options.agentId, options.confidence, {
224
+ testPassRate: options.testPassRate,
225
+ testsRun: options.testsRun,
226
+ testsPassed: options.testsPassed,
227
+ result: resultObj,
228
+ iteration: options.iteration
229
+ });
230
+ // Output result
231
+ const output = {
232
+ taskId: options.taskId,
233
+ agentId: options.agentId,
234
+ confidence: options.confidence,
235
+ testPassRate: options.testPassRate,
236
+ testsRun: options.testsRun,
237
+ testsPassed: options.testsPassed,
238
+ iteration: options.iteration,
239
+ timestamp: new Date().toISOString(),
240
+ status: 'success'
241
+ };
242
+ if (options.json) {
243
+ console.log(JSON.stringify(output, null, 2));
244
+ } else {
245
+ console.log(`Agent ${options.agentId} completion reported`);
246
+ console.log(`Confidence: ${(options.confidence * 100).toFixed(1)}%`);
247
+ if (options.testPassRate !== undefined) {
248
+ console.log(`Test Pass Rate: ${(options.testPassRate * 100).toFixed(1)}%`);
249
+ }
250
+ if (options.testsRun !== undefined && options.testsPassed !== undefined) {
251
+ console.log(`Tests: ${options.testsPassed}/${options.testsRun}`);
252
+ }
253
+ }
254
+ // Disconnect
255
+ await coordinator.disconnect();
256
+ process.exit(0);
257
+ } catch (error) {
258
+ console.error('Error reporting agent completion:', error);
259
+ if (options.json) {
260
+ console.log(JSON.stringify({
261
+ taskId: options.taskId,
262
+ agentId: options.agentId,
263
+ status: 'error',
264
+ error: error instanceof Error ? error.message : 'Unknown error'
265
+ }, null, 2));
266
+ }
267
+ process.exit(1);
268
+ }
269
+ }
270
+ // Run main function
271
+ main();
272
+
273
+ //# sourceMappingURL=agent-completion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cli/agent-completion.ts"],"sourcesContent":["#!/usr/bin/env node\r\n\r\n/**\r\n * Agent Completion CLI\r\n *\r\n * Signal agent completion with confidence score and test metrics\r\n *\r\n * Usage:\r\n * agent-completion --task-id <id> --agent-id <id> --confidence <score> [options]\r\n *\r\n * Required Arguments:\r\n * --task-id <id> Task identifier\r\n * --agent-id <id> Agent identifier\r\n * --confidence <score> Confidence score (0.0-1.0)\r\n *\r\n * Optional Arguments:\r\n * --iteration <n> Iteration number (default: 1)\r\n * --namespace <ns> Namespace: swarm | cfn_loop (default: swarm)\r\n * --test-pass-rate <pct> Test pass rate (0.0-1.0)\r\n * --tests-run <n> Total tests run\r\n * --tests-passed <n> Tests passed\r\n * --result <json> Result JSON (test pass rate preferred)\r\n * --redis-host <h> Redis host (default: localhost)\r\n * --redis-port <p> Redis port (default: 6379)\r\n * --json Output result as JSON\r\n * --help Show this help message\r\n *\r\n * Examples:\r\n * # Simple completion with confidence\r\n * agent-completion \\\r\n * --task-id task123 \\\r\n * --agent-id agent-loop3-1 \\\r\n * --confidence 0.92\r\n *\r\n * # Completion with test metrics (test-driven)\r\n * agent-completion \\\r\n * --task-id task123 \\\r\n * --agent-id agent-loop3-1 \\\r\n * --confidence 0.95 \\\r\n * --test-pass-rate 0.98 \\\r\n * --tests-run 50 \\\r\n * --tests-passed 49\r\n *\r\n * # Validator consensus score\r\n * agent-completion \\\r\n * --task-id task123 \\\r\n * --agent-id validator-1 \\\r\n * --confidence 0.88 \\\r\n * --iteration 1\r\n */\r\n\r\nimport { CoordinationWrapper } from '../coordination/coordination-wrapper.js';\r\nimport * as process from 'process';\r\n\r\ninterface Options {\r\n taskId: string;\r\n agentId: string;\r\n confidence: number;\r\n iteration?: number;\r\n namespace?: 'swarm' | 'cfn_loop';\r\n testPassRate?: number;\r\n testsRun?: number;\r\n testsPassed?: number;\r\n result?: string;\r\n redisHost?: string;\r\n redisPort?: number;\r\n json?: boolean;\r\n help?: boolean;\r\n}\r\n\r\n/**\r\n * Parse command line arguments\r\n */\r\nfunction parseArgs(): Options {\r\n const args = process.argv.slice(2);\r\n const options: Partial<Options> = {\r\n namespace: 'swarm',\r\n iteration: 1,\r\n redisHost: process.env.CFN_REDIS_HOST || process.env.REDIS_HOST || 'localhost',\r\n redisPort: parseInt(process.env.CFN_REDIS_PORT || process.env.REDIS_PORT || '6379'),\r\n json: false\r\n };\r\n\r\n for (let i = 0; i < args.length; i++) {\r\n const arg = args[i];\r\n\r\n switch (arg) {\r\n case '--task-id':\r\n options.taskId = args[++i];\r\n break;\r\n case '--agent-id':\r\n options.agentId = args[++i];\r\n break;\r\n case '--confidence':\r\n options.confidence = parseFloat(args[++i]);\r\n break;\r\n case '--iteration':\r\n options.iteration = parseInt(args[++i]);\r\n break;\r\n case '--namespace':\r\n options.namespace = args[++i] as 'swarm' | 'cfn_loop';\r\n break;\r\n case '--test-pass-rate':\r\n options.testPassRate = parseFloat(args[++i]);\r\n break;\r\n case '--tests-run':\r\n options.testsRun = parseInt(args[++i]);\r\n break;\r\n case '--tests-passed':\r\n options.testsPassed = parseInt(args[++i]);\r\n break;\r\n case '--result':\r\n options.result = args[++i];\r\n break;\r\n case '--redis-host':\r\n options.redisHost = args[++i];\r\n break;\r\n case '--redis-port':\r\n options.redisPort = parseInt(args[++i]);\r\n break;\r\n case '--json':\r\n options.json = true;\r\n break;\r\n case '--help':\r\n case '-h':\r\n options.help = true;\r\n break;\r\n }\r\n }\r\n\r\n return options as Options;\r\n}\r\n\r\n/**\r\n * Show help message\r\n */\r\nfunction showHelp(): void {\r\n console.log(`\r\nAgent Completion CLI - Signal agent completion with test metrics\r\n\r\nUsage:\r\n agent-completion --task-id <id> --agent-id <id> --confidence <score> [options]\r\n\r\nRequired Arguments:\r\n --task-id <id> Task identifier\r\n --agent-id <id> Agent identifier\r\n --confidence <score> Confidence score (0.0-1.0)\r\n\r\nOptional Arguments:\r\n --iteration <n> Iteration number (default: 1)\r\n --namespace <ns> Namespace: swarm | cfn_loop (default: swarm)\r\n --test-pass-rate <pct> Test pass rate (0.0-1.0, preferred over confidence)\r\n --tests-run <n> Total tests run\r\n --tests-passed <n> Tests passed\r\n --result <json> Result JSON (for custom data)\r\n --redis-host <h> Redis host (default: localhost or CFN_REDIS_HOST env)\r\n --redis-port <p> Redis port (default: 6379 or CFN_REDIS_PORT env)\r\n --json Output result as JSON\r\n --help, -h Show this help message\r\n\r\nExamples:\r\n # Simple completion with confidence\r\n agent-completion \\\\\r\n --task-id task123 \\\\\r\n --agent-id agent-loop3-1 \\\\\r\n --confidence 0.92\r\n\r\n # Test-driven completion with metrics\r\n agent-completion \\\\\r\n --task-id task123 \\\\\r\n --agent-id agent-loop3-1 \\\\\r\n --confidence 0.95 \\\\\r\n --test-pass-rate 0.98 \\\\\r\n --tests-run 50 \\\\\r\n --tests-passed 49\r\n\r\n # Validator consensus\r\n agent-completion \\\\\r\n --task-id task123 \\\\\r\n --agent-id validator-1 \\\\\r\n --confidence 0.88 \\\\\r\n --iteration 1 \\\\\r\n --json\r\n\r\nEnvironment Variables:\r\n CFN_REDIS_HOST Redis host\r\n CFN_REDIS_PORT Redis port\r\n REDIS_HOST Fallback Redis host\r\n REDIS_PORT Fallback Redis port\r\n`);\r\n}\r\n\r\n/**\r\n * Validate confidence score\r\n */\r\nfunction validateConfidence(score: number): boolean {\r\n return typeof score === 'number' && score >= 0 && score <= 1;\r\n}\r\n\r\n/**\r\n * Validate test pass rate\r\n */\r\nfunction validateTestPassRate(rate: number): boolean {\r\n return typeof rate === 'number' && rate >= 0 && rate <= 1;\r\n}\r\n\r\n/**\r\n * Main function\r\n */\r\nasync function main(): Promise<void> {\r\n const options = parseArgs();\r\n\r\n if (options.help) {\r\n showHelp();\r\n process.exit(0);\r\n }\r\n\r\n // Validate required arguments\r\n if (!options.taskId || !options.agentId || options.confidence === undefined) {\r\n console.error('Error: Missing required arguments');\r\n console.error('Use --help for usage information');\r\n process.exit(1);\r\n }\r\n\r\n // Validate confidence score\r\n if (!validateConfidence(options.confidence)) {\r\n console.error('Error: Confidence score must be between 0.0 and 1.0');\r\n process.exit(1);\r\n }\r\n\r\n // Validate test pass rate if provided\r\n if (options.testPassRate !== undefined && !validateTestPassRate(options.testPassRate)) {\r\n console.error('Error: Test pass rate must be between 0.0 and 1.0');\r\n process.exit(1);\r\n }\r\n\r\n try {\r\n // Create coordination wrapper\r\n const coordinator = new CoordinationWrapper({\r\n taskId: options.taskId,\r\n namespace: options.namespace || 'swarm',\r\n redisHost: options.redisHost || 'localhost',\r\n redisPort: options.redisPort || 6379\r\n });\r\n\r\n // Connect to Redis\r\n await coordinator.connect();\r\n\r\n // Build result object\r\n let resultObj: Record<string, unknown> | undefined;\r\n if (options.result) {\r\n try {\r\n resultObj = JSON.parse(options.result);\r\n } catch {\r\n // If result is not valid JSON, store as string\r\n resultObj = { result: options.result };\r\n }\r\n }\r\n\r\n // Signal completion\r\n await coordinator.signalCompletion(options.agentId, options.confidence, {\r\n testPassRate: options.testPassRate,\r\n testsRun: options.testsRun,\r\n testsPassed: options.testsPassed,\r\n result: resultObj,\r\n iteration: options.iteration\r\n });\r\n\r\n // Output result\r\n const output = {\r\n taskId: options.taskId,\r\n agentId: options.agentId,\r\n confidence: options.confidence,\r\n testPassRate: options.testPassRate,\r\n testsRun: options.testsRun,\r\n testsPassed: options.testsPassed,\r\n iteration: options.iteration,\r\n timestamp: new Date().toISOString(),\r\n status: 'success'\r\n };\r\n\r\n if (options.json) {\r\n console.log(JSON.stringify(output, null, 2));\r\n } else {\r\n console.log(`Agent ${options.agentId} completion reported`);\r\n console.log(`Confidence: ${(options.confidence * 100).toFixed(1)}%`);\r\n if (options.testPassRate !== undefined) {\r\n console.log(`Test Pass Rate: ${(options.testPassRate * 100).toFixed(1)}%`);\r\n }\r\n if (options.testsRun !== undefined && options.testsPassed !== undefined) {\r\n console.log(`Tests: ${options.testsPassed}/${options.testsRun}`);\r\n }\r\n }\r\n\r\n // Disconnect\r\n await coordinator.disconnect();\r\n\r\n process.exit(0);\r\n } catch (error) {\r\n console.error('Error reporting agent completion:', error);\r\n if (options.json) {\r\n console.log(\r\n JSON.stringify({\r\n taskId: options.taskId,\r\n agentId: options.agentId,\r\n status: 'error',\r\n error: error instanceof Error ? error.message : 'Unknown error'\r\n }, null, 2)\r\n );\r\n }\r\n process.exit(1);\r\n }\r\n}\r\n\r\n// Run main function\r\nmain();\r\n"],"names":["CoordinationWrapper","process","parseArgs","args","argv","slice","options","namespace","iteration","redisHost","env","CFN_REDIS_HOST","REDIS_HOST","redisPort","parseInt","CFN_REDIS_PORT","REDIS_PORT","json","i","length","arg","taskId","agentId","confidence","parseFloat","testPassRate","testsRun","testsPassed","result","help","showHelp","console","log","validateConfidence","score","validateTestPassRate","rate","main","exit","undefined","error","coordinator","connect","resultObj","JSON","parse","signalCompletion","output","timestamp","Date","toISOString","status","stringify","toFixed","disconnect","Error","message"],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CC,GAED,SAASA,mBAAmB,QAAQ,0CAA0C;AAC9E,YAAYC,aAAa,UAAU;AAkBnC;;CAEC,GACD,SAASC;IACP,MAAMC,OAAOF,QAAQG,IAAI,CAACC,KAAK,CAAC;IAChC,MAAMC,UAA4B;QAChCC,WAAW;QACXC,WAAW;QACXC,WAAWR,QAAQS,GAAG,CAACC,cAAc,IAAIV,QAAQS,GAAG,CAACE,UAAU,IAAI;QACnEC,WAAWC,SAASb,QAAQS,GAAG,CAACK,cAAc,IAAId,QAAQS,GAAG,CAACM,UAAU,IAAI;QAC5EC,MAAM;IACR;IAEA,IAAK,IAAIC,IAAI,GAAGA,IAAIf,KAAKgB,MAAM,EAAED,IAAK;QACpC,MAAME,MAAMjB,IAAI,CAACe,EAAE;QAEnB,OAAQE;YACN,KAAK;gBACHd,QAAQe,MAAM,GAAGlB,IAAI,CAAC,EAAEe,EAAE;gBAC1B;YACF,KAAK;gBACHZ,QAAQgB,OAAO,GAAGnB,IAAI,CAAC,EAAEe,EAAE;gBAC3B;YACF,KAAK;gBACHZ,QAAQiB,UAAU,GAAGC,WAAWrB,IAAI,CAAC,EAAEe,EAAE;gBACzC;YACF,KAAK;gBACHZ,QAAQE,SAAS,GAAGM,SAASX,IAAI,CAAC,EAAEe,EAAE;gBACtC;YACF,KAAK;gBACHZ,QAAQC,SAAS,GAAGJ,IAAI,CAAC,EAAEe,EAAE;gBAC7B;YACF,KAAK;gBACHZ,QAAQmB,YAAY,GAAGD,WAAWrB,IAAI,CAAC,EAAEe,EAAE;gBAC3C;YACF,KAAK;gBACHZ,QAAQoB,QAAQ,GAAGZ,SAASX,IAAI,CAAC,EAAEe,EAAE;gBACrC;YACF,KAAK;gBACHZ,QAAQqB,WAAW,GAAGb,SAAS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MAAM,EAAE1B,QAAQgB,OAAO,CAAC,oBAAoB,CAAC;YAC1DS,QAAQC,GAAG,CAAC,CAAC,YAAY,EAAE,AAAC1B,CAAAA,QAAQiB,UAAU,GAAG,GAAE,EAAG8B,OAAO,CAAC,GAAG,CAAC,CAAC;YACnE,IAAI/C,QAAQmB,YAAY,KAAKc,WAAW;gBACtCR,QAAQC,GAAG,CAAC,CAAC,gBAAgB,EAAE,AAAC1B,CAAAA,QAAQmB,YAAY,GAAG,GAAE,EAAG4B,OAAO,CAAC,GAAG,CAAC,CAAC;YAC3E;YACA,IAAI/C,QAAQoB,QAAQ,KAAKa,aAAajC,QAAQqB,WAAW,KAAKY,WAAW;gBACvER,QAAQC,GAAG,CAAC,CAAC,OAAO,EAAE1B,QAAQqB,WAAW,CAAC,CAAC,EAAErB,QAAQoB,QAAQ,EAAE;YACjE;QACF;QAEA,aAAa;QACb,MAAMe,YAAYa,UAAU;QAE5BrD,QAAQqC,IAAI,CAAC;IACf,EAAE,OAAOE,OAAO;QACdT,QAAQS,KAAK,CAAC,qCAAqCA;QACnD,IAAIlC,QAAQW,IAAI,EAAE;YAChBc,QAAQC,GAAG,CACTY,KAAKQ,SAAS,CAAC;gBACb/B,QAAQf,QAAQe,MAAM;gBACtBC,SAAShB,QAAQgB,OAAO;gBACxB6B,QAAQ;gBACRX,OAAOA,iBAAiBe,QAAQf,MAAMgB,OAAO,GAAG;YAClD,GAAG,MAAM;QAEb;QACAvD,QAAQqC,IAAI,CAAC;IACf;AACF;AAEA,oBAAoB;AACpBD"}
@@ -11,69 +11,96 @@
11
11
  */ import { loadIterationHistory, formatIterationHistory } from './iteration-history.js';
12
12
  import { SkillLoader } from './skill-loader.js';
13
13
  /**
14
- * Build CFN Loop protocol instructions
15
- */ function buildCFNLoopProtocol(taskId, agentId) {
14
+ * Build CLI Mode Redis Completion Protocol for CLI Mode
15
+ */ function buildCLIModeProtocol(taskId, agentId) {
16
16
  return `
17
- ## CFN Loop Redis Completion Protocol
17
+ ## CLI Mode Redis Completion Protocol
18
18
 
19
- You are participating in a CFN Loop workflow. Follow this protocol EXACTLY:
19
+ You are running in CLI Mode with Main Chat coordination. Follow this protocol EXACTLY:
20
20
 
21
21
  ### Step 1: Complete Your Work
22
22
  Execute your assigned task (implementation, review, testing, etc.)
23
23
 
24
- ### Step 2: Calculate Confidence Score
25
- Assess your work quality and assign a confidence score (0.0-1.0):
26
- - 0.90-1.0: Excellent, production-ready
27
- - 0.75-0.89: Good, minor issues possible
28
- - 0.50-0.74: Acceptable, needs review
29
- - 0.0-0.49: Poor, significant issues
24
+ ### Step 2: Signal Completion to Main Chat
25
+ Send a Redis signal to notify Main Chat that you're finished:
30
26
 
31
- ### Step 3: Report Completion to Redis
32
27
  \`\`\`bash
33
- ./.claude/skills/cfn-redis-coordination/report-completion.sh \\
34
- --task-id "${taskId}" \\
35
- --agent-id "${agentId}" \\
36
- --confidence [YOUR_CONFIDENCE_SCORE] \\
37
- --iteration \${ITERATION:-1}
38
- \`\`\`
28
+ # Use Node.js for Redis communication
29
+ node -e "
30
+ const { createClient } = require('redis');
31
+ const signal = {
32
+ agentId: '${agentId}',
33
+ taskId: '${taskId}',
34
+ status: 'completed',
35
+ timestamp: new Date().toISOString(),
36
+ provider: process.env.PROVIDER || 'unknown',
37
+ model: process.env.MODEL || 'unknown',
38
+ confidence: 0.90, // Replace with your actual confidence
39
+ metadata: {
40
+ iteration: process.env.ITERATION || 1,
41
+ mode: process.env.MODE || 'standard'
42
+ }
43
+ };
44
+
45
+ (async () => {
46
+ const client = createClient({ url: 'redis://localhost:6379' });
47
+ await client.connect();
39
48
 
40
- This script automatically:
41
- - Signals completion via \`swarm:${taskId}:${agentId}:done\`
42
- - Stores confidence in \`swarm:${taskId}:${agentId}:confidence\`
43
- - Creates result hash in \`swarm:${taskId}:${agentId}:result\`
44
- - Updates SQLite persistence layer
49
+ const signalKey = \`cfn:mainchat:signal:\${process.env.TASK_ID}\`;
50
+ await client.lPush(signalKey, JSON.stringify(signal));
51
+
52
+ console.log(\`✅ Completion signal sent to Main Chat via Redis\`);
53
+ await client.disconnect();
54
+ })();
55
+ "
56
+ \`\`\`
45
57
 
46
- ### Step 4: Exit Cleanly
47
- After reporting, exit immediately. DO NOT enter waiting mode.
58
+ ### Step 3: Exit Cleanly
59
+ After sending the signal, exit immediately. Main Chat is waiting for your Redis signal.
48
60
 
49
- The orchestrator will:
50
- - Collect confidence scores from all agents
51
- - Run gate check (≥0.75 threshold)
52
- - Spawn validators if gate passes
53
- - Spawn fresh agents for iteration N+1 if needed
61
+ **Why This Protocol:**
62
+ - Main Chat uses Redis BLPOP to wait for your completion signal
63
+ - Enables simple 2-layer coordination (Main Chat → CLI agents)
64
+ - No complex orchestrator needed for CLI mode
65
+ - Supports different AI providers via environment variables
54
66
 
55
67
  **Environment Variables Available:**
56
68
  - TASK_ID: ${taskId}
57
69
  - AGENT_ID: ${agentId}
58
- - ITERATION: Current iteration number (default: 1)
59
- - CONFIDENCE_SCORE: Your final confidence assessment
70
+ - PROVIDER: AI provider (zai, kimi, anthropic, etc.)
71
+ - MODEL: Specific model being used
72
+ - ITERATION: Current iteration number
73
+ - MODE: Execution mode (mvp, standard, enterprise)
60
74
 
61
- **Why This Matters:**
62
- - Enables zero-token coordination (orchestrator uses Redis BLPOP)
63
- - Supports adaptive agent specialization (spawn different specialist for iteration N+1)
64
- - Prevents memory leaks (agents exit after reporting)
65
- - Confidence scores drive gate checks and consensus validation
75
+ **Main Chat Workflow:**
76
+ 1. Spawns you via CLI with specific provider/model
77
+ 2. Waits via \`redis-cli BLPOP cfn:mainchat:signal:${taskId}\`
78
+ 3. Processes your completion signal when received
79
+ 4. Continues with next task or spawns additional agents
66
80
 
67
- **CRITICAL:** Report completion before exiting. Orchestrator is waiting for your signal.
81
+ **CRITICAL:** Send Redis signal before exiting. Main Chat cannot proceed without your completion signal.
68
82
  `;
69
83
  }
84
+ /**
85
+ * Parse shell variable format into JSON object
86
+ * Example: "WORKSPACE='/tmp/test' MODE='standard'" -> {WORKSPACE: '/tmp/test', MODE: 'standard'}
87
+ */ function parseShellVariables(shellContext) {
88
+ const jsonObj = {};
89
+ const regex = /([A-Z_]+)='([^']*)'/g;
90
+ let match;
91
+ while((match = regex.exec(shellContext)) !== null){
92
+ jsonObj[match[1]] = match[2];
93
+ }
94
+ return jsonObj;
95
+ }
70
96
  /**
71
97
  * Parse and enrich JSON context into natural language instructions
72
98
  */ function enrichJSONContext(jsonObj) {
73
99
  const sections = [];
74
- // Extract task description
75
- if (jsonObj.task) {
76
- sections.push(`**Task:** ${jsonObj.task}`);
100
+ // Extract task description (support both 'task' and 'taskDescription' keys)
101
+ const taskText = jsonObj.task || jsonObj.taskDescription;
102
+ if (taskText) {
103
+ sections.push(`**Task:** ${taskText}`);
77
104
  }
78
105
  // Parse files - convert comma-separated string to bullet list
79
106
  if (jsonObj.files) {
@@ -102,9 +129,10 @@ The orchestrator will:
102
129
  if (jsonObj.batch) {
103
130
  sections.push(`\n**Batch:** ${jsonObj.batch}`);
104
131
  }
105
- // Add directory context
106
- if (jsonObj.directory) {
107
- sections.push(`\n**Working Directory:** ${jsonObj.directory}`);
132
+ // Add directory context - support 'directory', 'WORKSPACE', and 'workspace' keys
133
+ const workspacePath = jsonObj.directory || jsonObj.WORKSPACE || jsonObj.workspace;
134
+ if (workspacePath) {
135
+ sections.push(`\n**Working Directory:** ${workspacePath}`);
108
136
  }
109
137
  // Add acceptance criteria
110
138
  if (jsonObj.acceptanceCriteria) {
@@ -129,10 +157,17 @@ The orchestrator will:
129
157
  */ function buildTaskDescription(agentType, context) {
130
158
  let desc = '';
131
159
  if (context.context) {
132
- // Try to parse as JSON first
160
+ // Try to parse context in multiple formats
133
161
  let contextStr = context.context.trim();
134
- // Check if context looks like JSON
135
- if (contextStr.startsWith('{') && contextStr.endsWith('}') || contextStr.startsWith('[') && contextStr.endsWith(']')) {
162
+ // Parse shell variables BEFORE attempting JSON parse
163
+ if (contextStr.includes('=') && !contextStr.startsWith('{')) {
164
+ const jsonObj = parseShellVariables(contextStr);
165
+ desc = enrichJSONContext(jsonObj);
166
+ // Add instruction footer for structured tasks
167
+ if (jsonObj.files || jsonObj.deliverables) {
168
+ desc += '\n\n**Process each item systematically and report confidence when complete.**';
169
+ }
170
+ } else if (contextStr.startsWith('{') && contextStr.endsWith('}') || contextStr.startsWith('[') && contextStr.endsWith(']')) {
136
171
  try {
137
172
  const jsonObj = JSON.parse(contextStr);
138
173
  desc = enrichJSONContext(jsonObj);
@@ -333,9 +368,9 @@ ${env.join('\n')}
333
368
  console.warn(`[agent-prompt-builder] Skill loading failed: ${skillError}`);
334
369
  // Continue without skills
335
370
  }
336
- // 5. CFN Loop protocol (ALWAYS inject when taskId present - enables Redis coordination)
371
+ // 5. CLI Mode protocol (ALWAYS inject when taskId present - enables Redis coordination)
337
372
  if (context.taskId && agentId) {
338
- sections.push(buildCFNLoopProtocol(context.taskId, agentId));
373
+ sections.push(buildCLIModeProtocol(context.taskId, agentId));
339
374
  sections.push('');
340
375
  }
341
376
  // 6. Environment context
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/agent-prompt-builder.ts"],"sourcesContent":["/**\r\n * Agent Prompt Builder\r\n *\r\n * Builds comprehensive prompts for CLI-spawned agents by combining:\r\n * - Agent definition (YAML + markdown)\r\n * - Task context (taskId, iteration, mode)\r\n * - CFN Loop protocol (if applicable)\r\n * - Iteration history (Sprint 3 - Phase 2)\r\n * - Environment variables\r\n * - Skills (Phase 5 - Skills Database integration)\r\n */\r\n\r\nimport { AgentDefinition, hasCFNLoopProtocol } from './agent-definition-parser.js';\r\nimport { loadIterationHistory, formatIterationHistory } from './iteration-history.js';\r\nimport { SkillLoader, Skill } from './skill-loader.js';\r\n\r\nexport interface TaskContext {\r\n taskId?: string;\r\n iteration?: number;\r\n context?: string;\r\n mode?: string;\r\n priority?: number;\r\n parentTaskId?: string;\r\n agentId?: string;\r\n keywords?: string; // Phase 5: For skill filtering\r\n phase?: string; // Phase 5: CFN Loop phase (loop1, loop2, loop3)\r\n}\r\n\r\n/**\r\n * Build CFN Loop protocol instructions\r\n */\r\nfunction buildCFNLoopProtocol(taskId: string, agentId: string): string {\r\n return `\r\n## CFN Loop Redis Completion Protocol\r\n\r\nYou are participating in a CFN Loop workflow. Follow this protocol EXACTLY:\r\n\r\n### Step 1: Complete Your Work\r\nExecute your assigned task (implementation, review, testing, etc.)\r\n\r\n### Step 2: Calculate Confidence Score\r\nAssess your work quality and assign a confidence score (0.0-1.0):\r\n- 0.90-1.0: Excellent, production-ready\r\n- 0.75-0.89: Good, minor issues possible\r\n- 0.50-0.74: Acceptable, needs review\r\n- 0.0-0.49: Poor, significant issues\r\n\r\n### Step 3: Report Completion to Redis\r\n\\`\\`\\`bash\r\n./.claude/skills/cfn-redis-coordination/report-completion.sh \\\\\r\n --task-id \"${taskId}\" \\\\\r\n --agent-id \"${agentId}\" \\\\\r\n --confidence [YOUR_CONFIDENCE_SCORE] \\\\\r\n --iteration \\${ITERATION:-1}\r\n\\`\\`\\`\r\n\r\nThis script automatically:\r\n- Signals completion via \\`swarm:${taskId}:${agentId}:done\\`\r\n- Stores confidence in \\`swarm:${taskId}:${agentId}:confidence\\`\r\n- Creates result hash in \\`swarm:${taskId}:${agentId}:result\\`\r\n- Updates SQLite persistence layer\r\n\r\n### Step 4: Exit Cleanly\r\nAfter reporting, exit immediately. DO NOT enter waiting mode.\r\n\r\nThe orchestrator will:\r\n- Collect confidence scores from all agents\r\n- Run gate check (≥0.75 threshold)\r\n- Spawn validators if gate passes\r\n- Spawn fresh agents for iteration N+1 if needed\r\n\r\n**Environment Variables Available:**\r\n- TASK_ID: ${taskId}\r\n- AGENT_ID: ${agentId}\r\n- ITERATION: Current iteration number (default: 1)\r\n- CONFIDENCE_SCORE: Your final confidence assessment\r\n\r\n**Why This Matters:**\r\n- Enables zero-token coordination (orchestrator uses Redis BLPOP)\r\n- Supports adaptive agent specialization (spawn different specialist for iteration N+1)\r\n- Prevents memory leaks (agents exit after reporting)\r\n- Confidence scores drive gate checks and consensus validation\r\n\r\n**CRITICAL:** Report completion before exiting. Orchestrator is waiting for your signal.\r\n`;\r\n}\r\n\r\n/**\r\n * Parse and enrich JSON context into natural language instructions\r\n */\r\nfunction enrichJSONContext(jsonObj: any): string {\r\n const sections: string[] = [];\r\n\r\n // Extract task description\r\n if (jsonObj.task) {\r\n sections.push(`**Task:** ${jsonObj.task}`);\r\n }\r\n\r\n // Parse files - convert comma-separated string to bullet list\r\n if (jsonObj.files) {\r\n const fileList = typeof jsonObj.files === 'string'\r\n ? jsonObj.files.split(',').map(f => f.trim()).filter(f => f)\r\n : Array.isArray(jsonObj.files) ? jsonObj.files : [];\r\n\r\n if (fileList.length > 0) {\r\n sections.push('\\n**Files to process:**');\r\n fileList.forEach(file => sections.push(`- ${file}`));\r\n }\r\n }\r\n\r\n // Add requirements/deliverables\r\n if (jsonObj.requirements) {\r\n const reqs = Array.isArray(jsonObj.requirements) ? jsonObj.requirements : [jsonObj.requirements];\r\n sections.push('\\n**Requirements:**');\r\n reqs.forEach((req, i) => sections.push(`${i + 1}. ${req}`));\r\n }\r\n\r\n if (jsonObj.deliverables) {\r\n const delivs = Array.isArray(jsonObj.deliverables) ? jsonObj.deliverables : [jsonObj.deliverables];\r\n sections.push('\\n**Deliverables:**');\r\n delivs.forEach(deliv => sections.push(`- ${deliv}`));\r\n }\r\n\r\n // Add batch information\r\n if (jsonObj.batch) {\r\n sections.push(`\\n**Batch:** ${jsonObj.batch}`);\r\n }\r\n\r\n // Add directory context\r\n if (jsonObj.directory) {\r\n sections.push(`\\n**Working Directory:** ${jsonObj.directory}`);\r\n }\r\n\r\n // Add acceptance criteria\r\n if (jsonObj.acceptanceCriteria) {\r\n const criteria = Array.isArray(jsonObj.acceptanceCriteria)\r\n ? jsonObj.acceptanceCriteria\r\n : [jsonObj.acceptanceCriteria];\r\n sections.push('\\n**Acceptance Criteria:**');\r\n criteria.forEach(criterion => sections.push(`- ${criterion}`));\r\n }\r\n\r\n // Add explicit instructions if present\r\n if (jsonObj.instructions) {\r\n sections.push('\\n**Instructions:**');\r\n const instrs = Array.isArray(jsonObj.instructions) ? jsonObj.instructions : [jsonObj.instructions];\r\n instrs.forEach((instr, i) => sections.push(`${i + 1}. ${instr}`));\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Build task description from context\r\n */\r\nfunction buildTaskDescription(agentType: string, context: TaskContext): string {\r\n let desc = '';\r\n\r\n if (context.context) {\r\n // Try to parse as JSON first\r\n let contextStr = context.context.trim();\r\n\r\n // Check if context looks like JSON\r\n if ((contextStr.startsWith('{') && contextStr.endsWith('}')) ||\r\n (contextStr.startsWith('[') && contextStr.endsWith(']'))) {\r\n try {\r\n const jsonObj = JSON.parse(contextStr);\r\n desc = enrichJSONContext(jsonObj);\r\n\r\n // Add instruction footer for structured tasks\r\n if (jsonObj.files || jsonObj.deliverables) {\r\n desc += '\\n\\n**Process each item systematically and report confidence when complete.**';\r\n }\r\n } catch (e) {\r\n // Not valid JSON, treat as plain text\r\n desc = context.context;\r\n }\r\n } else {\r\n // Plain text context\r\n desc = context.context;\r\n }\r\n } else {\r\n desc = `Execute task as ${agentType} agent`;\r\n }\r\n\r\n // Add metadata fields\r\n if (context.taskId) {\r\n desc += `\\n\\n**Task ID:** ${context.taskId}`;\r\n }\r\n\r\n if (context.iteration) {\r\n desc += `\\n**Iteration:** ${context.iteration}`;\r\n }\r\n\r\n if (context.mode) {\r\n desc += `\\n**Mode:** ${context.mode}`;\r\n }\r\n\r\n if (context.priority) {\r\n desc += `\\n**Priority:** ${context.priority}`;\r\n }\r\n\r\n if (context.parentTaskId) {\r\n desc += `\\n**Parent Task:** ${context.parentTaskId}`;\r\n }\r\n\r\n return desc;\r\n}\r\n\r\n/**\r\n * Build environment context section\r\n */\r\nfunction buildEnvironmentContext(context: TaskContext): string {\r\n const env: string[] = [];\r\n\r\n if (context.taskId) env.push(`TASK_ID=${context.taskId}`);\r\n if (context.iteration) env.push(`ITERATION=${context.iteration}`);\r\n if (context.mode) env.push(`MODE=${context.mode}`);\r\n if (context.priority) env.push(`PRIORITY=${context.priority}`);\r\n if (context.parentTaskId) env.push(`PARENT_TASK_ID=${context.parentTaskId}`);\r\n\r\n // Docker workspace detection\r\n const isDockerEnv = process.env.DOCKER_AGENT === 'true' || process.env.WORKSPACE_ROOT;\r\n const workspaceRoot = process.env.WORKSPACE_ROOT || '/workspace';\r\n\r\n if (isDockerEnv) {\r\n env.push(`WORKSPACE_ROOT=${workspaceRoot}`);\r\n }\r\n\r\n // Always include Docker context if detected, even if env array is empty\r\n if (isDockerEnv && env.length === 0) {\r\n env.push(`WORKSPACE_ROOT=${workspaceRoot}`);\r\n }\r\n\r\n if (env.length === 0 && !isDockerEnv) return '';\r\n\r\n let contextText = `\r\n## Environment Variables\r\n\r\n\\`\\`\\`bash\r\n${env.join('\\n')}\r\n\\`\\`\\`\r\n`;\r\n\r\n // Add Docker workspace notice if detected\r\n if (isDockerEnv) {\r\n contextText += `\r\n\r\n## Docker Container Environment\r\n\r\n**CRITICAL:** You are running inside a Docker container.\r\n\r\n- **Working Directory:** \\`${workspaceRoot}\\`\r\n- **File Paths:** All file operations use \\`${workspaceRoot}/\\` prefix\r\n- **Example:** To read \\`src/file.ts\\`, use \\`${workspaceRoot}/src/file.ts\\`\r\n\r\n**DO NOT** use paths from your training data or Main Chat context. Use \\`${workspaceRoot}/\\` for all file operations.\r\n`;\r\n }\r\n\r\n return contextText;\r\n}\r\n\r\n/**\r\n * Load skills for agent (Phase 5: Skills Database Integration)\r\n */\r\nasync function loadSkillsForAgent(\r\n agentType: string,\r\n context: TaskContext\r\n): Promise<Skill[]> {\r\n // Feature flag check\r\n if (process.env.CFN_SKILLS_DATABASE !== 'true') {\r\n return [];\r\n }\r\n\r\n try {\r\n const dbPath = process.env.CFN_SKILLS_DB_PATH || './.claude/skills-database/skills.db';\r\n const skillLoader = new SkillLoader(dbPath, {\r\n enableCache: true,\r\n cacheMaxSize: 100,\r\n cacheTTL: 60000 // 1 minute\r\n });\r\n\r\n // Extract keywords from context for filtering\r\n const keywords = context.keywords || context.context?.toLowerCase() || '';\r\n\r\n const skills = await skillLoader.loadSkillsForAgent(agentType, {\r\n taskId: context.taskId,\r\n keywords,\r\n phase: context.phase,\r\n mode: context.mode,\r\n iteration: context.iteration\r\n });\r\n\r\n skillLoader.close();\r\n return skills;\r\n } catch (error) {\r\n console.warn(`[agent-prompt-builder] Failed to load skills: ${error}`);\r\n return [];\r\n }\r\n}\r\n\r\n/**\r\n * Format skills for prompt injection\r\n */\r\nfunction formatSkillsForPrompt(skills: Skill[]): string {\r\n if (skills.length === 0) {\r\n return '';\r\n }\r\n\r\n const sections: string[] = [];\r\n\r\n sections.push('## Applicable Skills');\r\n sections.push('');\r\n sections.push('The following skills have been loaded based on your agent type and task context:');\r\n sections.push('');\r\n\r\n for (const skill of skills) {\r\n const approvalBadge = skill.approvalLevel === 'auto' ? '✓' :\r\n skill.approvalLevel === 'escalate' ? '⚠' : '✋';\r\n sections.push(`### ${skill.name} (v${skill.version}) [${approvalBadge} ${skill.approvalLevel}]`);\r\n sections.push('');\r\n if (skill.content) {\r\n sections.push(skill.content);\r\n } else {\r\n sections.push(`*Skill content not available*`);\r\n }\r\n sections.push('');\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Build complete prompt for agent execution (async for iteration history + skills)\r\n */\r\nexport async function buildAgentPrompt(\r\n definition: AgentDefinition,\r\n context: TaskContext\r\n): Promise<string> {\r\n // Use explicit agent ID if provided, otherwise generate from name + iteration\r\n const agentId = context.agentId || `${definition.name}-${context.iteration || 1}`;\r\n const startTime = Date.now();\r\n\r\n const sections: string[] = [];\r\n\r\n // 1. Agent definition header\r\n sections.push(`# Agent: ${definition.name}`);\r\n sections.push('');\r\n sections.push(definition.description);\r\n sections.push('');\r\n\r\n // 2. Task description\r\n sections.push('## Task');\r\n sections.push('');\r\n sections.push(buildTaskDescription(definition.name, context));\r\n sections.push('');\r\n\r\n // 3. Iteration history (Sprint 3 - Phase 2)\r\n // Load and format previous iterations if iteration > 1\r\n if (context.taskId && context.iteration && context.iteration > 1) {\r\n try {\r\n const history = await loadIterationHistory(context.taskId, agentId, context.iteration);\r\n const historyText = formatIterationHistory(history, context.iteration);\r\n sections.push(historyText);\r\n sections.push('');\r\n } catch (err) {\r\n console.warn(`[agent-prompt-builder] Failed to load iteration history:`, err);\r\n // Continue without history\r\n }\r\n }\r\n\r\n // 4. Agent definition content (from markdown file)\r\n sections.push('## Agent Definition');\r\n sections.push('');\r\n sections.push(definition.content);\r\n sections.push('');\r\n\r\n // 4a. Load and inject skills (Phase 5: Skills Database Integration)\r\n try {\r\n const skills = await loadSkillsForAgent(definition.type || definition.name, context);\r\n\r\n if (skills.length > 0) {\r\n const skillsText = formatSkillsForPrompt(skills);\r\n sections.push(skillsText);\r\n sections.push('');\r\n\r\n // Log skill usage for analytics (Phase 5)\r\n if (process.env.CFN_SKILLS_DATABASE === 'true' && context.taskId) {\r\n try {\r\n const dbPath = process.env.CFN_SKILLS_DB_PATH || './.claude/skills-database/skills.db';\r\n const skillLoader = new SkillLoader(dbPath);\r\n\r\n await skillLoader.logSkillUsage({\r\n agentId: agentId,\r\n agentType: definition.type || definition.name,\r\n skillIds: skills.map(s => s.id).filter(id => id > 0), // Exclude bootstrap skills (negative IDs)\r\n taskId: context.taskId,\r\n phase: context.phase,\r\n loadedAt: new Date(),\r\n executionTimeMs: Date.now() - startTime\r\n });\r\n\r\n skillLoader.close();\r\n } catch (logError) {\r\n console.warn(`[agent-prompt-builder] Failed to log skill usage: ${logError}`);\r\n }\r\n }\r\n }\r\n } catch (skillError) {\r\n console.warn(`[agent-prompt-builder] Skill loading failed: ${skillError}`);\r\n // Continue without skills\r\n }\r\n\r\n // 5. CFN Loop protocol (ALWAYS inject when taskId present - enables Redis coordination)\r\n if (context.taskId && agentId) {\r\n sections.push(buildCFNLoopProtocol(context.taskId, agentId));\r\n sections.push('');\r\n }\r\n\r\n // 6. Environment context\r\n const envContext = buildEnvironmentContext(context);\r\n if (envContext) {\r\n sections.push(envContext);\r\n sections.push('');\r\n }\r\n\r\n // 7. Execution instructions\r\n sections.push('## Execution Instructions');\r\n sections.push('');\r\n sections.push('1. Read and understand the task requirements');\r\n if (context.iteration && context.iteration > 1) {\r\n sections.push('2. Review iteration history and feedback from validators');\r\n sections.push('3. Address specific feedback points from previous iteration');\r\n sections.push('4. Execute your core responsibilities as defined above');\r\n } else {\r\n sections.push('2. Execute your core responsibilities as defined above');\r\n sections.push('3. Follow any protocol steps (CFN Loop, validation hooks, etc.)');\r\n }\r\n sections.push('4. Provide clear, concise output');\r\n sections.push('5. Report confidence score if applicable');\r\n sections.push('');\r\n\r\n // 7a. Pre-edit backup requirement (MANDATORY)\r\n sections.push('## Pre-Edit Backup Protocol (MANDATORY)');\r\n sections.push('');\r\n sections.push('**BEFORE ANY Edit/Write/MultiEdit operation, you MUST create a backup:**');\r\n sections.push('');\r\n sections.push('```bash');\r\n sections.push(`BACKUP_PATH=$(./.claude/hooks/cfn-invoke-pre-edit.sh \"$FILE_TO_EDIT\" --agent-id \"${agentId}\")`);\r\n sections.push('```');\r\n sections.push('');\r\n sections.push('**Why:** Enables safe file revert without git operations during parallel sessions.');\r\n sections.push('**Location:** `.backups/[agent-id]/[timestamp]_[hash]/`');\r\n sections.push('**Retention:** 24h TTL (configurable)');\r\n sections.push('');\r\n sections.push('**Complete Edit Workflow:**');\r\n sections.push('```bash');\r\n sections.push('# 1. Pre-Edit: Create backup');\r\n sections.push(`BACKUP_PATH=$(./.claude/hooks/cfn-invoke-pre-edit.sh \"src/file.ts\" --agent-id \"${agentId}\")`);\r\n sections.push('');\r\n sections.push('# 2. Edit: Perform file modification');\r\n sections.push('Edit: file_path=\"src/file.ts\" old_string=\"...\" new_string=\"...\"');\r\n sections.push('');\r\n sections.push('# 3. Post-Edit: Validate changes');\r\n sections.push(`./.claude/hooks/cfn-invoke-post-edit.sh \"src/file.ts\" --agent-id \"${agentId}\"`);\r\n sections.push('```');\r\n sections.push('');\r\n\r\n // 8. Tool reminder\r\n if (definition.tools && definition.tools.length > 0) {\r\n sections.push('## Available Tools');\r\n sections.push('');\r\n sections.push(`You have access to: ${definition.tools.join(', ')}`);\r\n sections.push('');\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Extract agent ID from context\r\n * If agentId is explicitly provided in context, use it; otherwise generate from name + iteration\r\n */\r\nexport function getAgentId(definition: AgentDefinition, context: TaskContext): string {\r\n if (context.agentId) {\r\n return context.agentId;\r\n }\r\n return `${definition.name}-${context.iteration || 1}`;\r\n}\r\n\r\n/**\r\n * Build system prompt for agent (optional, for structured agent behavior)\r\n */\r\nexport function buildSystemPrompt(definition: AgentDefinition): string {\r\n return `You are ${definition.name}, a specialized AI agent.\r\n\r\nType: ${definition.type || 'specialist'}\r\nModel: ${definition.model}\r\nTools: ${definition.tools.join(', ')}\r\n\r\nFollow your agent definition exactly and complete assigned tasks with high quality.`;\r\n}\r\n"],"names":["loadIterationHistory","formatIterationHistory","SkillLoader","buildCFNLoopProtocol","taskId","agentId","enrichJSONContext","jsonObj","sections","task","push","files","fileList","split","map","f","trim","filter","Array","isArray","length","forEach","file","requirements","reqs","req","i","deliverables","delivs","deliv","batch","directory","acceptanceCriteria","criteria","criterion","instructions","instrs","instr","join","buildTaskDescription","agentType","context","desc","contextStr","startsWith","endsWith","JSON","parse","e","iteration","mode","priority","parentTaskId","buildEnvironmentContext","env","isDockerEnv","process","DOCKER_AGENT","WORKSPACE_ROOT","workspaceRoot","contextText","loadSkillsForAgent","CFN_SKILLS_DATABASE","dbPath","CFN_SKILLS_DB_PATH","skillLoader","enableCache","cacheMaxSize","cacheTTL","keywords","toLowerCase","skills","phase","close","error","console","warn","formatSkillsForPrompt","skill","approvalBadge","approvalLevel","name","version","content","buildAgentPrompt","definition","startTime","Date","now","description","history","historyText","err","type","skillsText","logSkillUsage","skillIds","s","id","loadedAt","executionTimeMs","logError","skillError","envContext","tools","getAgent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IACdF,SAASE,IAAI,CAAC,CAAC,kEAAkE,EAAEL,QAAQ,CAAC,CAAC;IAC7FG,SAASE,IAAI,CAAC;IACdF,SAASE,IAAI,CAAC;IAEd,mBAAmB;IACnB,IAAI2E,WAAWmB,KAAK,IAAInB,WAAWmB,KAAK,CAACpF,MAAM,GAAG,GAAG;QACnDZ,SAASE,IAAI,CAAC;QACdF,SAASE,IAAI,CAAC;QACdF,SAASE,IAAI,CAAC,CAAC,oBAAoB,EAAE2E,WAAWmB,KAAK,CAAClE,IAAI,CAAC,OAAO;QAClE9B,SAASE,IAAI,CAAC;IAChB;IAEA,OAAOF,SAAS8B,IAAI,CAAC;AACvB;AAEA;;;CAGC,GACD,OAAO,SAASmE,WAAWpB,UAA2B,EAAE5C,OAAoB;IAC1E,IAAIA,QAAQpC,OAAO,EAAE;QACnB,OAAOoC,QAAQpC,OAAO;IACxB;IACA,OAAO,GAAGgF,WAAWJ,IAAI,CAAC,CAAC,EAAExC,QAAQQ,SAAS,IAAI,GAAG;AACvD;AAEA;;CAEC,GACD,OAAO,SAASyD,kBAAkBrB,UAA2B;IAC3D,OAAO,CAAC,QAAQ,EAAEA,WAAWJ,IAAI,CAAC;;MAE9B,EAAEI,WAAWQ,IAAI,IAAI,aAAa;OACjC,EAAER,WAAWsB,KAAK,CAAC;OACnB,EAAEtB,WAAWmB,KAAK,CAAClE,IAAI,CAAC,MAAM;;mFAE8C,CAAC;AACpF"}
1
+ {"version":3,"sources":["../../src/cli/agent-prompt-builder.ts"],"sourcesContent":["/**\r\n * Agent Prompt Builder\r\n *\r\n * Builds comprehensive prompts for CLI-spawned agents by combining:\r\n * - Agent definition (YAML + markdown)\r\n * - Task context (taskId, iteration, mode)\r\n * - CFN Loop protocol (if applicable)\r\n * - Iteration history (Sprint 3 - Phase 2)\r\n * - Environment variables\r\n * - Skills (Phase 5 - Skills Database integration)\r\n */\r\n\r\nimport { AgentDefinition, hasCFNLoopProtocol } from './agent-definition-parser.js';\r\nimport { loadIterationHistory, formatIterationHistory } from './iteration-history.js';\r\nimport { SkillLoader, Skill } from './skill-loader.js';\r\n\r\nexport interface TaskContext {\r\n taskId?: string;\r\n iteration?: number;\r\n context?: string;\r\n mode?: string;\r\n priority?: number;\r\n parentTaskId?: string;\r\n agentId?: string;\r\n keywords?: string; // Phase 5: For skill filtering\r\n phase?: string; // Phase 5: CFN Loop phase (loop1, loop2, loop3)\r\n}\r\n\r\n/**\r\n * Build CLI Mode Redis Completion Protocol for CLI Mode\r\n */\r\nfunction buildCLIModeProtocol(taskId: string, agentId: string): string {\r\n return `\r\n## CLI Mode Redis Completion Protocol\r\n\r\nYou are running in CLI Mode with Main Chat coordination. Follow this protocol EXACTLY:\r\n\r\n### Step 1: Complete Your Work\r\nExecute your assigned task (implementation, review, testing, etc.)\r\n\r\n### Step 2: Signal Completion to Main Chat\r\nSend a Redis signal to notify Main Chat that you're finished:\r\n\r\n\\`\\`\\`bash\r\n# Use Node.js for Redis communication\r\nnode -e \"\r\nconst { createClient } = require('redis');\r\nconst signal = {\r\n agentId: '${agentId}',\r\n taskId: '${taskId}',\r\n status: 'completed',\r\n timestamp: new Date().toISOString(),\r\n provider: process.env.PROVIDER || 'unknown',\r\n model: process.env.MODEL || 'unknown',\r\n confidence: 0.90, // Replace with your actual confidence\r\n metadata: {\r\n iteration: process.env.ITERATION || 1,\r\n mode: process.env.MODE || 'standard'\r\n }\r\n};\r\n\r\n(async () => {\r\n const client = createClient({ url: 'redis://localhost:6379' });\r\n await client.connect();\r\n\r\n const signalKey = \\`cfn:mainchat:signal:\\${process.env.TASK_ID}\\`;\r\n await client.lPush(signalKey, JSON.stringify(signal));\r\n\r\n console.log(\\`✅ Completion signal sent to Main Chat via Redis\\`);\r\n await client.disconnect();\r\n})();\r\n\"\r\n\\`\\`\\`\r\n\r\n### Step 3: Exit Cleanly\r\nAfter sending the signal, exit immediately. Main Chat is waiting for your Redis signal.\r\n\r\n**Why This Protocol:**\r\n- Main Chat uses Redis BLPOP to wait for your completion signal\r\n- Enables simple 2-layer coordination (Main Chat → CLI agents)\r\n- No complex orchestrator needed for CLI mode\r\n- Supports different AI providers via environment variables\r\n\r\n**Environment Variables Available:**\r\n- TASK_ID: ${taskId}\r\n- AGENT_ID: ${agentId}\r\n- PROVIDER: AI provider (zai, kimi, anthropic, etc.)\r\n- MODEL: Specific model being used\r\n- ITERATION: Current iteration number\r\n- MODE: Execution mode (mvp, standard, enterprise)\r\n\r\n**Main Chat Workflow:**\r\n1. Spawns you via CLI with specific provider/model\r\n2. Waits via \\`redis-cli BLPOP cfn:mainchat:signal:${taskId}\\`\r\n3. Processes your completion signal when received\r\n4. Continues with next task or spawns additional agents\r\n\r\n**CRITICAL:** Send Redis signal before exiting. Main Chat cannot proceed without your completion signal.\r\n`;\r\n}\r\n\r\n/**\r\n * Parse shell variable format into JSON object\r\n * Example: \"WORKSPACE='/tmp/test' MODE='standard'\" -> {WORKSPACE: '/tmp/test', MODE: 'standard'}\r\n */\r\nfunction parseShellVariables(shellContext: string): any {\r\n const jsonObj: any = {};\r\n const regex = /([A-Z_]+)='([^']*)'/g;\r\n let match;\r\n while ((match = regex.exec(shellContext)) !== null) {\r\n jsonObj[match[1]] = match[2];\r\n }\r\n return jsonObj;\r\n}\r\n\r\n/**\r\n * Parse and enrich JSON context into natural language instructions\r\n */\r\nfunction enrichJSONContext(jsonObj: any): string {\r\n const sections: string[] = [];\r\n\r\n // Extract task description (support both 'task' and 'taskDescription' keys)\r\n const taskText = jsonObj.task || jsonObj.taskDescription;\r\n if (taskText) {\r\n sections.push(`**Task:** ${taskText}`);\r\n }\r\n\r\n // Parse files - convert comma-separated string to bullet list\r\n if (jsonObj.files) {\r\n const fileList = typeof jsonObj.files === 'string'\r\n ? jsonObj.files.split(',').map(f => f.trim()).filter(f => f)\r\n : Array.isArray(jsonObj.files) ? jsonObj.files : [];\r\n\r\n if (fileList.length > 0) {\r\n sections.push('\\n**Files to process:**');\r\n fileList.forEach(file => sections.push(`- ${file}`));\r\n }\r\n }\r\n\r\n // Add requirements/deliverables\r\n if (jsonObj.requirements) {\r\n const reqs = Array.isArray(jsonObj.requirements) ? jsonObj.requirements : [jsonObj.requirements];\r\n sections.push('\\n**Requirements:**');\r\n reqs.forEach((req, i) => sections.push(`${i + 1}. ${req}`));\r\n }\r\n\r\n if (jsonObj.deliverables) {\r\n const delivs = Array.isArray(jsonObj.deliverables) ? jsonObj.deliverables : [jsonObj.deliverables];\r\n sections.push('\\n**Deliverables:**');\r\n delivs.forEach(deliv => sections.push(`- ${deliv}`));\r\n }\r\n\r\n // Add batch information\r\n if (jsonObj.batch) {\r\n sections.push(`\\n**Batch:** ${jsonObj.batch}`);\r\n }\r\n\r\n // Add directory context - support 'directory', 'WORKSPACE', and 'workspace' keys\r\n const workspacePath = jsonObj.directory || jsonObj.WORKSPACE || jsonObj.workspace;\r\n if (workspacePath) {\r\n sections.push(`\\n**Working Directory:** ${workspacePath}`);\r\n }\r\n\r\n // Add acceptance criteria\r\n if (jsonObj.acceptanceCriteria) {\r\n const criteria = Array.isArray(jsonObj.acceptanceCriteria)\r\n ? jsonObj.acceptanceCriteria\r\n : [jsonObj.acceptanceCriteria];\r\n sections.push('\\n**Acceptance Criteria:**');\r\n criteria.forEach(criterion => sections.push(`- ${criterion}`));\r\n }\r\n\r\n // Add explicit instructions if present\r\n if (jsonObj.instructions) {\r\n sections.push('\\n**Instructions:**');\r\n const instrs = Array.isArray(jsonObj.instructions) ? jsonObj.instructions : [jsonObj.instructions];\r\n instrs.forEach((instr, i) => sections.push(`${i + 1}. ${instr}`));\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Build task description from context\r\n */\r\nfunction buildTaskDescription(agentType: string, context: TaskContext): string {\r\n let desc = '';\r\n\r\n if (context.context) {\r\n // Try to parse context in multiple formats\r\n let contextStr = context.context.trim();\r\n\r\n // Parse shell variables BEFORE attempting JSON parse\r\n if (contextStr.includes('=') && !contextStr.startsWith('{')) {\r\n const jsonObj = parseShellVariables(contextStr);\r\n desc = enrichJSONContext(jsonObj);\r\n\r\n // Add instruction footer for structured tasks\r\n if (jsonObj.files || jsonObj.deliverables) {\r\n desc += '\\n\\n**Process each item systematically and report confidence when complete.**';\r\n }\r\n }\r\n // Check if context looks like JSON\r\n else if ((contextStr.startsWith('{') && contextStr.endsWith('}')) ||\r\n (contextStr.startsWith('[') && contextStr.endsWith(']'))) {\r\n try {\r\n const jsonObj = JSON.parse(contextStr);\r\n desc = enrichJSONContext(jsonObj);\r\n\r\n // Add instruction footer for structured tasks\r\n if (jsonObj.files || jsonObj.deliverables) {\r\n desc += '\\n\\n**Process each item systematically and report confidence when complete.**';\r\n }\r\n } catch (e) {\r\n // Not valid JSON, treat as plain text\r\n desc = context.context;\r\n }\r\n } else {\r\n // Plain text context\r\n desc = context.context;\r\n }\r\n } else {\r\n desc = `Execute task as ${agentType} agent`;\r\n }\r\n\r\n // Add metadata fields\r\n if (context.taskId) {\r\n desc += `\\n\\n**Task ID:** ${context.taskId}`;\r\n }\r\n\r\n if (context.iteration) {\r\n desc += `\\n**Iteration:** ${context.iteration}`;\r\n }\r\n\r\n if (context.mode) {\r\n desc += `\\n**Mode:** ${context.mode}`;\r\n }\r\n\r\n if (context.priority) {\r\n desc += `\\n**Priority:** ${context.priority}`;\r\n }\r\n\r\n if (context.parentTaskId) {\r\n desc += `\\n**Parent Task:** ${context.parentTaskId}`;\r\n }\r\n\r\n return desc;\r\n}\r\n\r\n/**\r\n * Build environment context section\r\n */\r\nfunction buildEnvironmentContext(context: TaskContext): string {\r\n const env: string[] = [];\r\n\r\n if (context.taskId) env.push(`TASK_ID=${context.taskId}`);\r\n if (context.iteration) env.push(`ITERATION=${context.iteration}`);\r\n if (context.mode) env.push(`MODE=${context.mode}`);\r\n if (context.priority) env.push(`PRIORITY=${context.priority}`);\r\n if (context.parentTaskId) env.push(`PARENT_TASK_ID=${context.parentTaskId}`);\r\n\r\n // Docker workspace detection\r\n const isDockerEnv = process.env.DOCKER_AGENT === 'true' || process.env.WORKSPACE_ROOT;\r\n const workspaceRoot = process.env.WORKSPACE_ROOT || '/workspace';\r\n\r\n if (isDockerEnv) {\r\n env.push(`WORKSPACE_ROOT=${workspaceRoot}`);\r\n }\r\n\r\n // Always include Docker context if detected, even if env array is empty\r\n if (isDockerEnv && env.length === 0) {\r\n env.push(`WORKSPACE_ROOT=${workspaceRoot}`);\r\n }\r\n\r\n if (env.length === 0 && !isDockerEnv) return '';\r\n\r\n let contextText = `\r\n## Environment Variables\r\n\r\n\\`\\`\\`bash\r\n${env.join('\\n')}\r\n\\`\\`\\`\r\n`;\r\n\r\n // Add Docker workspace notice if detected\r\n if (isDockerEnv) {\r\n contextText += `\r\n\r\n## Docker Container Environment\r\n\r\n**CRITICAL:** You are running inside a Docker container.\r\n\r\n- **Working Directory:** \\`${workspaceRoot}\\`\r\n- **File Paths:** All file operations use \\`${workspaceRoot}/\\` prefix\r\n- **Example:** To read \\`src/file.ts\\`, use \\`${workspaceRoot}/src/file.ts\\`\r\n\r\n**DO NOT** use paths from your training data or Main Chat context. Use \\`${workspaceRoot}/\\` for all file operations.\r\n`;\r\n }\r\n\r\n return contextText;\r\n}\r\n\r\n/**\r\n * Load skills for agent (Phase 5: Skills Database Integration)\r\n */\r\nasync function loadSkillsForAgent(\r\n agentType: string,\r\n context: TaskContext\r\n): Promise<Skill[]> {\r\n // Feature flag check\r\n if (process.env.CFN_SKILLS_DATABASE !== 'true') {\r\n return [];\r\n }\r\n\r\n try {\r\n const dbPath = process.env.CFN_SKILLS_DB_PATH || './.claude/skills-database/skills.db';\r\n const skillLoader = new SkillLoader(dbPath, {\r\n enableCache: true,\r\n cacheMaxSize: 100,\r\n cacheTTL: 60000 // 1 minute\r\n });\r\n\r\n // Extract keywords from context for filtering\r\n const keywords = context.keywords || context.context?.toLowerCase() || '';\r\n\r\n const skills = await skillLoader.loadSkillsForAgent(agentType, {\r\n taskId: context.taskId,\r\n keywords,\r\n phase: context.phase,\r\n mode: context.mode,\r\n iteration: context.iteration\r\n });\r\n\r\n skillLoader.close();\r\n return skills;\r\n } catch (error) {\r\n console.warn(`[agent-prompt-builder] Failed to load skills: ${error}`);\r\n return [];\r\n }\r\n}\r\n\r\n/**\r\n * Format skills for prompt injection\r\n */\r\nfunction formatSkillsForPrompt(skills: Skill[]): string {\r\n if (skills.length === 0) {\r\n return '';\r\n }\r\n\r\n const sections: string[] = [];\r\n\r\n sections.push('## Applicable Skills');\r\n sections.push('');\r\n sections.push('The following skills have been loaded based on your agent type and task context:');\r\n sections.push('');\r\n\r\n for (const skill of skills) {\r\n const approvalBadge = skill.approvalLevel === 'auto' ? '✓' :\r\n skill.approvalLevel === 'escalate' ? '⚠' : '✋';\r\n sections.push(`### ${skill.name} (v${skill.version}) [${approvalBadge} ${skill.approvalLevel}]`);\r\n sections.push('');\r\n if (skill.content) {\r\n sections.push(skill.content);\r\n } else {\r\n sections.push(`*Skill content not available*`);\r\n }\r\n sections.push('');\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Build complete prompt for agent execution (async for iteration history + skills)\r\n */\r\nexport async function buildAgentPrompt(\r\n definition: AgentDefinition,\r\n context: TaskContext\r\n): Promise<string> {\r\n // Use explicit agent ID if provided, otherwise generate from name + iteration\r\n const agentId = context.agentId || `${definition.name}-${context.iteration || 1}`;\r\n const startTime = Date.now();\r\n\r\n const sections: string[] = [];\r\n\r\n // 1. Agent definition header\r\n sections.push(`# Agent: ${definition.name}`);\r\n sections.push('');\r\n sections.push(definition.description);\r\n sections.push('');\r\n\r\n // 2. Task description\r\n sections.push('## Task');\r\n sections.push('');\r\n sections.push(buildTaskDescription(definition.name, context));\r\n sections.push('');\r\n\r\n // 3. Iteration history (Sprint 3 - Phase 2)\r\n // Load and format previous iterations if iteration > 1\r\n if (context.taskId && context.iteration && context.iteration > 1) {\r\n try {\r\n const history = await loadIterationHistory(context.taskId, agentId, context.iteration);\r\n const historyText = formatIterationHistory(history, context.iteration);\r\n sections.push(historyText);\r\n sections.push('');\r\n } catch (err) {\r\n console.warn(`[agent-prompt-builder] Failed to load iteration history:`, err);\r\n // Continue without history\r\n }\r\n }\r\n\r\n // 4. Agent definition content (from markdown file)\r\n sections.push('## Agent Definition');\r\n sections.push('');\r\n sections.push(definition.content);\r\n sections.push('');\r\n\r\n // 4a. Load and inject skills (Phase 5: Skills Database Integration)\r\n try {\r\n const skills = await loadSkillsForAgent(definition.type || definition.name, context);\r\n\r\n if (skills.length > 0) {\r\n const skillsText = formatSkillsForPrompt(skills);\r\n sections.push(skillsText);\r\n sections.push('');\r\n\r\n // Log skill usage for analytics (Phase 5)\r\n if (process.env.CFN_SKILLS_DATABASE === 'true' && context.taskId) {\r\n try {\r\n const dbPath = process.env.CFN_SKILLS_DB_PATH || './.claude/skills-database/skills.db';\r\n const skillLoader = new SkillLoader(dbPath);\r\n\r\n await skillLoader.logSkillUsage({\r\n agentId: agentId,\r\n agentType: definition.type || definition.name,\r\n skillIds: skills.map(s => s.id).filter(id => id > 0), // Exclude bootstrap skills (negative IDs)\r\n taskId: context.taskId,\r\n phase: context.phase,\r\n loadedAt: new Date(),\r\n executionTimeMs: Date.now() - startTime\r\n });\r\n\r\n skillLoader.close();\r\n } catch (logError) {\r\n console.warn(`[agent-prompt-builder] Failed to log skill usage: ${logError}`);\r\n }\r\n }\r\n }\r\n } catch (skillError) {\r\n console.warn(`[agent-prompt-builder] Skill loading failed: ${skillError}`);\r\n // Continue without skills\r\n }\r\n\r\n // 5. CLI Mode protocol (ALWAYS inject when taskId present - enables Redis coordination)\r\n if (context.taskId && agentId) {\r\n sections.push(buildCLIModeProtocol(context.taskId, agentId));\r\n sections.push('');\r\n }\r\n\r\n // 6. Environment context\r\n const envContext = buildEnvironmentContext(context);\r\n if (envContext) {\r\n sections.push(envContext);\r\n sections.push('');\r\n }\r\n\r\n // 7. Execution instructions\r\n sections.push('## Execution Instructions');\r\n sections.push('');\r\n sections.push('1. Read and understand the task requirements');\r\n if (context.iteration && context.iteration > 1) {\r\n sections.push('2. Review iteration history and feedback from validators');\r\n sections.push('3. Address specific feedback points from previous iteration');\r\n sections.push('4. Execute your core responsibilities as defined above');\r\n } else {\r\n sections.push('2. Execute your core responsibilities as defined above');\r\n sections.push('3. Follow any protocol steps (CFN Loop, validation hooks, etc.)');\r\n }\r\n sections.push('4. Provide clear, concise output');\r\n sections.push('5. Report confidence score if applicable');\r\n sections.push('');\r\n\r\n // 7a. Pre-edit backup requirement (MANDATORY)\r\n sections.push('## Pre-Edit Backup Protocol (MANDATORY)');\r\n sections.push('');\r\n sections.push('**BEFORE ANY Edit/Write/MultiEdit operation, you MUST create a backup:**');\r\n sections.push('');\r\n sections.push('```bash');\r\n sections.push(`BACKUP_PATH=$(./.claude/hooks/cfn-invoke-pre-edit.sh \"$FILE_TO_EDIT\" --agent-id \"${agentId}\")`);\r\n sections.push('```');\r\n sections.push('');\r\n sections.push('**Why:** Enables safe file revert without git operations during parallel sessions.');\r\n sections.push('**Location:** `.backups/[agent-id]/[timestamp]_[hash]/`');\r\n sections.push('**Retention:** 24h TTL (configurable)');\r\n sections.push('');\r\n sections.push('**Complete Edit Workflow:**');\r\n sections.push('```bash');\r\n sections.push('# 1. Pre-Edit: Create backup');\r\n sections.push(`BACKUP_PATH=$(./.claude/hooks/cfn-invoke-pre-edit.sh \"src/file.ts\" --agent-id \"${agentId}\")`);\r\n sections.push('');\r\n sections.push('# 2. Edit: Perform file modification');\r\n sections.push('Edit: file_path=\"src/file.ts\" old_string=\"...\" new_string=\"...\"');\r\n sections.push('');\r\n sections.push('# 3. Post-Edit: Validate changes');\r\n sections.push(`./.claude/hooks/cfn-invoke-post-edit.sh \"src/file.ts\" --agent-id \"${agentId}\"`);\r\n sections.push('```');\r\n sections.push('');\r\n\r\n // 8. Tool reminder\r\n if (definition.tools && definition.tools.length > 0) {\r\n sections.push('## Available Tools');\r\n sections.push('');\r\n sections.push(`You have access to: ${definition.tools.join(', ')}`);\r\n sections.push('');\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Extract agent ID from context\r\n * If agentId is explicitly provided in context, use it; otherwise generate from name + iteration\r\n */\r\nexport function getAgentId(definition: AgentDefinition, context: TaskContext): string {\r\n if (context.agentId) {\r\n return context.agentId;\r\n }\r\n return `${definition.name}-${context.iteration || 1}`;\r\n}\r\n\r\n/**\r\n * Build system prompt for agent (optional, for structured agent behavior)\r\n */\r\nexport function buildSystemPrompt(definition: AgentDefinition): string {\r\n return `You are ${definition.name}, a specialized AI agent.\r\n\r\nType: ${definition.type || 'specialist'}\r\nModel: ${definition.model}\r\nTools: ${definition.tools.join(', ')}\r\n\r\nFollow your agent definition exactly and complete assigned tasks with high quality.`;\r\n}\r\n"],"names":["loadIterationHistory","formatIterationHistory","SkillLoader","buildCLIModeProtocol","taskId","agentId","parseShellVariables","shellContext","jsonObj","regex","match","exec","enrichJSONContext","sections","taskText","task","taskDescription","push","files","fileList","split","map","f","trim","filter","Array","isArray","length","forEach","file","requirements","reqs","req","i","deliverables","delivs","deliv","batch","workspacePath","directory","WORKSPACE","workspace","acceptanceCriteria","criteria","criterion","instructions","instrs","instr","join","buildTaskDescription","agentType","context","desc","contextStr","includes","startsWith","endsWith","JSON","parse","e","iteration","mode","priority","parentTaskId","buildEnvironmentContext","env","isDockerEnv","process","DOCKER_AGENT","WORKSPACE_ROOT","workspaceRoot","contextText","loadSkillsForAgent","CFN_SKILLS_DATABASE","dbPath","CFN_SKILLS_DB_PATH","skillLoader","enableCache","cacheMaxSize","cacheTTL","keywords","toLowerCase","skills","phase","close","error","console","warn","formatSkillsForPrompt","skill","approvalBadge","approvalLevel","name","version","content","buildAgentPrompt","definition","startTime","Date","now","description","history","historyText","err","type","skillsText","logSkillUsage","skillIds","s","id","loadedAt","executionTimeMs","logError","skillError","envContext","tools","getAgentId","buildSystemPrompt","model"],"mappings":"AAAA;;;;;;;;;;CAUC,GAGD,SAASA,oBAAoB,EAAEC,sBAAsB,QAAQ,yBAAyB;AACtF,SAASC,WAAW,QAAe,oBA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