claude-flow-novice 2.15.11 → 2.16.1

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 (741) hide show
  1. package/.claude/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
  2. package/.claude/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +1 -1
  3. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +1 -1
  4. package/.claude/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +1 -1
  5. package/.claude/cfn-extras/skills/google-sheets-progress/SKILL.md +1 -1
  6. package/.claude/commands/CFN_LOOP_FRONTEND.md +1 -1
  7. package/.claude/commands/cfn-loop-cli.md +214 -442
  8. package/.claude/commands/cfn-loop-frontend.md +1 -1
  9. package/.claude/commands/cfn-loop-task.md +2 -2
  10. package/.claude/commands/cfn-loop-trigger.md +114 -0
  11. package/.claude/commands/deprecated/cfn-loop.md +2 -2
  12. package/.claude/hooks/cfn-invoke-post-edit-ts.sh +100 -0
  13. package/.claude/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
  14. package/.claude/hooks/cfn-invoke-post-edit.sh +53 -5
  15. package/.claude/hooks/cfn-invoke-post-edit.sh.backup +87 -0
  16. package/.claude/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
  17. package/.claude/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
  18. package/.claude/hooks/cfn-invoke-pre-edit.sh +22 -0
  19. package/.claude/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
  20. package/.claude/hooks/cfn-post-edit.config.json +9 -2
  21. package/.claude/root-claude-distribute/CFN-CLAUDE.md +1 -1
  22. package/.claude/skills/cfn-agent-spawning/SKILL.md +48 -1
  23. package/.claude/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
  24. package/.claude/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
  25. package/.claude/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
  26. package/.claude/skills/{cfn-redis-coordination/check-dependencies.sh → cfn-agent-spawning/check-dependencies.sh.backup} +3 -5
  27. package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
  28. package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
  29. package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
  30. package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
  31. package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
  32. package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
  33. package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
  34. package/.claude/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
  35. package/.claude/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
  36. package/.claude/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
  37. package/.claude/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
  38. package/.claude/skills/cfn-backlog-management/SKILL.md +1 -1
  39. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
  40. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
  41. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
  42. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
  43. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
  44. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
  45. package/.claude/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
  46. package/.claude/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
  47. package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
  48. package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
  49. package/.claude/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
  50. package/.claude/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
  51. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
  52. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
  53. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
  54. package/.claude/skills/cfn-loop-orchestration/SKILL.md +159 -48
  55. package/.claude/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
  56. package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
  57. package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
  58. package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
  59. package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
  60. package/.claude/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
  61. package/.claude/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
  62. package/.claude/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
  63. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
  64. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
  65. package/.claude/skills/cfn-loop-orchestration/{orchestrate-wrapper.sh → archive/legacy-bash/orchestrate-wrapper.sh} +11 -1
  66. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
  67. package/.claude/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
  68. package/.claude/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
  69. package/.claude/skills/cfn-loop-orchestration/package-lock.json +3 -0
  70. package/.claude/skills/cfn-loop-orchestration/package.json +4 -0
  71. package/.claude/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
  72. package/.claude/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
  73. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
  74. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
  75. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
  76. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
  77. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
  78. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
  79. package/.claude/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
  80. package/.claude/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
  81. package/.claude/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
  82. package/.claude/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
  83. package/.claude/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
  84. package/.claude/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
  85. package/.claude/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
  86. package/.claude/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
  87. package/.claude/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
  88. package/.claude/skills/cfn-loop-orchestration/src/index.ts +2 -0
  89. package/.claude/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
  90. package/.claude/skills/cfn-loop-orchestration/src/types.ts +56 -0
  91. package/.claude/skills/cfn-loop-orchestration/test-cli.sh +92 -0
  92. package/.claude/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
  93. package/.claude/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
  94. package/.claude/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
  95. package/.claude/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
  96. package/.claude/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
  97. package/.claude/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
  98. package/.claude/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
  99. package/.claude/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
  100. package/.claude/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
  101. package/.claude/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
  102. package/.claude/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
  103. package/.claude/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
  104. package/.claude/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
  105. package/.claude/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
  106. package/.claude/skills/cfn-loop-validation/INDEX.md +531 -0
  107. package/.claude/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
  108. package/.claude/skills/cfn-loop-validation/SKILL.md +48 -1
  109. package/.claude/skills/cfn-loop-validation/SKILL.md.backup +353 -0
  110. package/.claude/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
  111. package/.claude/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
  112. package/.claude/skills/cfn-loop-validation/check-dependencies.sh +22 -0
  113. package/{claude-assets/skills/cfn-redis-coordination/check-dependencies.sh → .claude/skills/cfn-loop-validation/check-dependencies.sh.backup} +4 -5
  114. package/.claude/skills/cfn-loop-validation/detect-vapor.sh +59 -0
  115. package/.claude/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
  116. package/.claude/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
  117. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
  118. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
  119. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
  120. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
  121. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
  122. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
  123. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
  124. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
  125. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
  126. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
  127. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
  128. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
  129. package/.claude/skills/cfn-loop-validation/dist/types.d.ts +156 -0
  130. package/.claude/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
  131. package/.claude/skills/cfn-loop-validation/dist/types.js +66 -0
  132. package/.claude/skills/cfn-loop-validation/dist/types.js.map +1 -0
  133. package/.claude/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
  134. package/.claude/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
  135. package/.claude/skills/cfn-loop-validation/dist/validator.js +411 -0
  136. package/.claude/skills/cfn-loop-validation/dist/validator.js.map +1 -0
  137. package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
  138. package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
  139. package/.claude/skills/cfn-loop-validation/package.json +93 -0
  140. package/.claude/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
  141. package/.claude/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
  142. package/.claude/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
  143. package/.claude/skills/cfn-loop-validation/src/types.ts +215 -0
  144. package/.claude/skills/cfn-loop-validation/src/validator.ts +503 -0
  145. package/.claude/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
  146. package/.claude/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
  147. package/.claude/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
  148. package/.claude/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
  149. package/.claude/skills/cfn-loop-validation/validate-gate.sh +63 -0
  150. package/.claude/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
  151. package/.claude/skills/cfn-loop-validation/validate-iteration.sh +22 -0
  152. package/.claude/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
  153. package/.claude/skills/cfn-product-owner-decision/SKILL.md +479 -147
  154. package/.claude/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
  155. package/.claude/skills/cfn-product-owner-decision/{execute-decision.sh → archive/legacy-bash/execute-decision.sh} +24 -2
  156. package/.claude/skills/pre-edit-backup/SKILL.md +324 -0
  157. package/.claude/skills/pre-edit-backup/SKILL.md.backup +277 -0
  158. package/.claude/skills/pre-edit-backup/backup.sh +22 -0
  159. package/.claude/skills/pre-edit-backup/backup.sh.backup +107 -0
  160. package/claude-assets/agents/cfn-dev-team/analysts/root-cause-analyst.md +2 -2
  161. package/claude-assets/agents/cfn-dev-team/architecture/base-template-generator.md +1 -1
  162. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +3 -2
  163. package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +1 -0
  164. package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +2 -1
  165. package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +1 -0
  166. package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +11 -1
  167. package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +58 -35
  168. package/claude-assets/agents/cfn-dev-team/dev-ops/github-commit-agent.md +2 -2
  169. package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +47 -37
  170. package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +18 -18
  171. package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +40 -58
  172. package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +19 -21
  173. package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +20 -29
  174. package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +15 -19
  175. package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +15 -10
  176. package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +16 -11
  177. package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +16 -26
  178. package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +18 -22
  179. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +17 -21
  180. package/claude-assets/agents/cfn-dev-team/documentation/pseudocode.md +1 -1
  181. package/claude-assets/agents/cfn-dev-team/product-owners/accessibility-advocate-persona.md +1 -1
  182. package/claude-assets/agents/cfn-dev-team/product-owners/cto-agent.md +1 -1
  183. package/claude-assets/agents/cfn-dev-team/product-owners/power-user-persona.md +1 -1
  184. package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +1 -5
  185. package/claude-assets/agents/cfn-dev-team/reviewers/code-reviewer.md +20 -51
  186. package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +22 -71
  187. package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +21 -64
  188. package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +22 -67
  189. package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +24 -68
  190. package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +8 -36
  191. package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +9 -38
  192. package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +17 -55
  193. package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +1 -1
  194. package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +18 -56
  195. package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +9 -37
  196. package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +18 -56
  197. package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +18 -49
  198. package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +8 -37
  199. package/claude-assets/agents/cfn-dev-team/testers/tester.md +7 -27
  200. package/claude-assets/agents/cfn-dev-team/testers/unit/tdd-london-unit-swarm.md +1 -1
  201. package/claude-assets/agents/cfn-dev-team/utility/agent-builder.md +11 -0
  202. package/claude-assets/agents/cfn-dev-team/utility/analyst.md +13 -29
  203. package/claude-assets/agents/cfn-dev-team/utility/claude-code-expert.md +1 -1
  204. package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +13 -13
  205. package/claude-assets/agents/cfn-dev-team/utility/context-curator.md +7 -2
  206. package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +6 -11
  207. package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +121 -715
  208. package/claude-assets/agents/cfn-dev-team/utility/researcher.md +13 -22
  209. package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +147 -573
  210. package/claude-assets/agents/custom/cfn-docker-expert.md +103 -0
  211. package/claude-assets/agents/custom/cfn-loops-cli-expert.md +438 -0
  212. package/claude-assets/agents/custom/cfn-redis-operations.md +529 -529
  213. package/claude-assets/agents/custom/cfn-system-expert.md +1 -1
  214. package/claude-assets/agents/custom/trigger-dev-expert.md +369 -0
  215. package/claude-assets/agents/docker-team/micro-sprint-planner.md +747 -747
  216. package/claude-assets/agents/project-only-agents/npm-package-specialist.md +1 -1
  217. package/claude-assets/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
  218. package/claude-assets/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +1 -1
  219. package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +1 -1
  220. package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +1 -1
  221. package/claude-assets/cfn-extras/skills/google-sheets-progress/SKILL.md +1 -1
  222. package/claude-assets/commands/CFN_LOOP_FRONTEND.md +1 -1
  223. package/claude-assets/commands/cfn-loop-cli.md +214 -442
  224. package/claude-assets/commands/cfn-loop-frontend.md +1 -1
  225. package/claude-assets/commands/cfn-loop-task.md +2 -2
  226. package/claude-assets/commands/cfn-loop-trigger.md +114 -0
  227. package/claude-assets/commands/deprecated/cfn-loop.md +2 -2
  228. package/claude-assets/hooks/GIT-HOOKS-USAGE-EXAMPLES.md +116 -0
  229. package/claude-assets/hooks/README-GIT-HOOKS.md +443 -0
  230. package/claude-assets/hooks/SKILL.md +518 -0
  231. package/claude-assets/hooks/SKILL.md.backup +471 -0
  232. package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh +100 -0
  233. package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
  234. package/claude-assets/hooks/cfn-invoke-post-edit.sh +53 -5
  235. package/claude-assets/hooks/cfn-invoke-post-edit.sh.backup +87 -0
  236. package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
  237. package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
  238. package/claude-assets/hooks/cfn-invoke-pre-edit.sh +22 -0
  239. package/claude-assets/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
  240. package/claude-assets/hooks/cfn-post-edit.config.json +9 -2
  241. package/claude-assets/hooks/install-git-hooks.sh +243 -0
  242. package/claude-assets/hooks/subagent-start.sh +98 -0
  243. package/claude-assets/hooks/subagent-stop.sh +93 -0
  244. package/claude-assets/hooks/validators/credential-scanner.sh +172 -0
  245. package/claude-assets/root-claude-distribute/CFN-CLAUDE.md +1 -1
  246. package/claude-assets/skills/cfn-agent-selection-with-fallback/DELIVERABLES.md +409 -0
  247. package/claude-assets/skills/cfn-agent-selection-with-fallback/IMPLEMENTATION_SUMMARY.md +396 -0
  248. package/claude-assets/skills/cfn-agent-selection-with-fallback/INTEGRATION_GUIDE.md +308 -0
  249. package/claude-assets/skills/cfn-agent-selection-with-fallback/QUICK_REFERENCE.md +239 -0
  250. package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md +107 -1
  251. package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md.backup +302 -0
  252. package/claude-assets/skills/cfn-agent-selection-with-fallback/TYPESCRIPT_MIGRATION.md +295 -0
  253. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.cjs +297 -0
  254. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.js +297 -0
  255. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.cjs +96 -0
  256. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.js +96 -0
  257. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh +45 -0
  258. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh.backup +23 -0
  259. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh +22 -0
  260. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh.backup +173 -0
  261. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.test.ts +357 -0
  262. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.ts +350 -0
  263. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/cli.ts +74 -0
  264. package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh +22 -0
  265. package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh.backup +71 -0
  266. package/claude-assets/skills/cfn-agent-selection-with-fallback/tsconfig.json +18 -0
  267. package/claude-assets/skills/cfn-agent-spawning/SKILL.md +48 -1
  268. package/claude-assets/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
  269. package/claude-assets/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
  270. package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
  271. package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh.backup +30 -0
  272. package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
  273. package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
  274. package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
  275. package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
  276. package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
  277. package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
  278. package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
  279. package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
  280. package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
  281. package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
  282. package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
  283. package/claude-assets/skills/cfn-backlog-management/SKILL.md +1 -1
  284. package/claude-assets/skills/cfn-coordination/agent-completion.sh.backup +36 -0
  285. package/claude-assets/skills/cfn-coordination/coordination-signal.sh.backup +36 -0
  286. package/claude-assets/skills/cfn-coordination/coordination-wait.sh.backup +36 -0
  287. package/claude-assets/skills/cfn-dependency-ingestion/README.md +101 -0
  288. package/claude-assets/skills/cfn-dependency-ingestion/SKILL.md +397 -0
  289. package/claude-assets/skills/cfn-dependency-ingestion/build.sh +23 -0
  290. package/claude-assets/skills/cfn-dependency-ingestion/dist/ingest-dependencies.js +478 -0
  291. package/claude-assets/skills/cfn-dependency-ingestion/ingest-dependencies.sh +295 -0
  292. package/claude-assets/skills/cfn-dependency-ingestion/ingest.sh +237 -0
  293. package/claude-assets/skills/cfn-dependency-ingestion/manifests/cli-mode-dependencies.txt +73 -0
  294. package/claude-assets/skills/cfn-dependency-ingestion/manifests/shared-dependencies.txt +57 -0
  295. package/claude-assets/skills/cfn-dependency-ingestion/manifests/trigger-dev-dependencies.txt +82 -0
  296. package/claude-assets/skills/cfn-dependency-ingestion/manifests/trigger-mode-dependencies.txt +80 -0
  297. package/claude-assets/skills/cfn-dependency-ingestion/src/ingest-dependencies.ts +563 -0
  298. package/claude-assets/skills/cfn-environment-sanitization/sanitize-environment.sh +14 -4
  299. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
  300. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
  301. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
  302. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
  303. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
  304. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
  305. package/claude-assets/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
  306. package/claude-assets/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
  307. package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
  308. package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
  309. package/claude-assets/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
  310. package/claude-assets/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
  311. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
  312. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
  313. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
  314. package/claude-assets/skills/cfn-loop-orchestration/SKILL.md +159 -48
  315. package/claude-assets/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
  316. package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
  317. package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
  318. package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
  319. package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
  320. package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
  321. package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
  322. package/claude-assets/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
  323. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
  324. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
  325. package/claude-assets/skills/cfn-loop-orchestration/{orchestrate-wrapper.sh → archive/legacy-bash/orchestrate-wrapper.sh} +11 -1
  326. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
  327. package/claude-assets/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
  328. package/claude-assets/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
  329. package/claude-assets/skills/cfn-loop-orchestration/package-lock.json +3 -0
  330. package/claude-assets/skills/cfn-loop-orchestration/package.json +4 -0
  331. package/claude-assets/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
  332. package/claude-assets/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
  333. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
  334. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
  335. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
  336. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
  337. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
  338. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
  339. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
  340. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
  341. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
  342. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
  343. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
  344. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
  345. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
  346. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
  347. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
  348. package/claude-assets/skills/cfn-loop-orchestration/src/index.ts +2 -0
  349. package/claude-assets/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
  350. package/claude-assets/skills/cfn-loop-orchestration/src/types.ts +56 -0
  351. package/claude-assets/skills/cfn-loop-orchestration/test-cli.sh +92 -0
  352. package/claude-assets/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
  353. package/claude-assets/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
  354. package/claude-assets/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
  355. package/claude-assets/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
  356. package/claude-assets/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
  357. package/claude-assets/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
  358. package/claude-assets/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
  359. package/claude-assets/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
  360. package/claude-assets/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
  361. package/claude-assets/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
  362. package/claude-assets/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
  363. package/claude-assets/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
  364. package/claude-assets/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
  365. package/claude-assets/skills/cfn-loop-output-processing/.eslintrc.json +33 -0
  366. package/claude-assets/skills/cfn-loop-output-processing/DELIVERY_SUMMARY.txt +462 -0
  367. package/claude-assets/skills/cfn-loop-output-processing/DEPRECATION_NOTICE.md +183 -0
  368. package/claude-assets/skills/cfn-loop-output-processing/EXAMPLES.md +609 -0
  369. package/claude-assets/skills/cfn-loop-output-processing/IMPLEMENTATION_SUMMARY.md +418 -0
  370. package/claude-assets/skills/cfn-loop-output-processing/INDEX.md +531 -0
  371. package/claude-assets/skills/cfn-loop-output-processing/MIGRATION.md +362 -0
  372. package/claude-assets/skills/cfn-loop-output-processing/README.md +114 -0
  373. package/claude-assets/skills/cfn-loop-output-processing/SKILL.md +633 -0
  374. package/{.claude/skills/cfn-docker-redis-coordination → claude-assets/skills/cfn-loop-output-processing}/jest.config.js +7 -15
  375. package/claude-assets/skills/cfn-loop-output-processing/package.json +50 -0
  376. package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop2.ts +195 -0
  377. package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop3.ts +157 -0
  378. package/claude-assets/skills/cfn-loop-output-processing/src/output-processor.ts +632 -0
  379. package/claude-assets/skills/cfn-loop-output-processing/tests/output-processor.test.ts +617 -0
  380. package/claude-assets/skills/{cfn-docker-redis-coordination → cfn-loop-output-processing}/tsconfig.json +16 -7
  381. package/claude-assets/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
  382. package/claude-assets/skills/cfn-loop-validation/INDEX.md +531 -0
  383. package/claude-assets/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
  384. package/claude-assets/skills/cfn-loop-validation/SKILL.md +48 -1
  385. package/claude-assets/skills/cfn-loop-validation/SKILL.md.backup +353 -0
  386. package/claude-assets/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
  387. package/claude-assets/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
  388. package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh +22 -0
  389. package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh.backup +31 -0
  390. package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh +59 -0
  391. package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
  392. package/claude-assets/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
  393. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
  394. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
  395. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
  396. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
  397. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
  398. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
  399. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
  400. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
  401. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
  402. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
  403. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
  404. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
  405. package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts +156 -0
  406. package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
  407. package/claude-assets/skills/cfn-loop-validation/dist/types.js +66 -0
  408. package/claude-assets/skills/cfn-loop-validation/dist/types.js.map +1 -0
  409. package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
  410. package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
  411. package/claude-assets/skills/cfn-loop-validation/dist/validator.js +411 -0
  412. package/claude-assets/skills/cfn-loop-validation/dist/validator.js.map +1 -0
  413. package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
  414. package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
  415. package/claude-assets/skills/cfn-loop-validation/package.json +93 -0
  416. package/claude-assets/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
  417. package/claude-assets/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
  418. package/claude-assets/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
  419. package/claude-assets/skills/cfn-loop-validation/src/types.ts +215 -0
  420. package/claude-assets/skills/cfn-loop-validation/src/validator.ts +503 -0
  421. package/claude-assets/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
  422. package/claude-assets/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
  423. package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
  424. package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
  425. package/claude-assets/skills/cfn-loop-validation/validate-gate.sh +63 -0
  426. package/claude-assets/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
  427. package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh +22 -0
  428. package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
  429. package/claude-assets/skills/cfn-product-owner-decision/SKILL.md +479 -147
  430. package/claude-assets/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
  431. package/claude-assets/skills/cfn-product-owner-decision/{execute-decision.sh → archive/legacy-bash/execute-decision.sh} +24 -2
  432. package/claude-assets/skills/cfn-provider-routing/README.md +129 -0
  433. package/claude-assets/skills/cfn-provider-routing/SKILL.md +215 -0
  434. package/claude-assets/skills/cfn-provider-routing/resolve-provider-model.ts +223 -0
  435. package/claude-assets/skills/docker-build/build.sh +1 -1
  436. package/claude-assets/skills/pre-edit-backup/SKILL.md +324 -0
  437. package/claude-assets/skills/pre-edit-backup/SKILL.md.backup +277 -0
  438. package/claude-assets/skills/pre-edit-backup/backup.sh +22 -0
  439. package/claude-assets/skills/pre-edit-backup/backup.sh.backup +107 -0
  440. package/dist/agent/skill-mcp-selector.js +2 -1
  441. package/dist/agent/skill-mcp-selector.js.map +1 -1
  442. package/dist/api/auth-endpoints.js +415 -0
  443. package/dist/api/auth-endpoints.js.map +1 -0
  444. package/dist/api/task-endpoints.js +562 -0
  445. package/dist/api/task-endpoints.js.map +1 -0
  446. package/dist/backend/server.js +418 -0
  447. package/dist/backend/server.js.map +1 -0
  448. package/dist/cfn-loop/product-owner/decision-parser.js +356 -0
  449. package/dist/cfn-loop/product-owner/decision-parser.js.map +1 -0
  450. package/dist/cfn-loop/product-owner/index.js +1 -0
  451. package/dist/cfn-loop/product-owner/index.js.map +1 -1
  452. package/dist/cli/agent-command.js +1 -1
  453. package/dist/cli/agent-command.js.map +1 -1
  454. package/dist/cli/agent-completion.js +273 -0
  455. package/dist/cli/agent-completion.js.map +1 -0
  456. package/dist/cli/agent-executor.js +470 -26
  457. package/dist/cli/agent-executor.js.map +1 -1
  458. package/dist/cli/agent-prompt-builder.js +83 -48
  459. package/dist/cli/agent-prompt-builder.js.map +1 -1
  460. package/dist/cli/agent-spawn.js +7 -4
  461. package/dist/cli/agent-spawn.js.map +1 -1
  462. package/dist/cli/agent-spawner.js +546 -0
  463. package/dist/cli/agent-spawner.js.map +1 -0
  464. package/dist/cli/agent-token-manager.js +2 -1
  465. package/dist/cli/agent-token-manager.js.map +1 -1
  466. package/dist/cli/anthropic-client.js +127 -14
  467. package/dist/cli/anthropic-client.js.map +1 -1
  468. package/dist/cli/cfn-context.js +2 -1
  469. package/dist/cli/cfn-context.js.map +1 -1
  470. package/dist/cli/cfn-metrics.js +2 -1
  471. package/dist/cli/cfn-metrics.js.map +1 -1
  472. package/dist/cli/cfn-redis.js +2 -1
  473. package/dist/cli/cfn-redis.js.map +1 -1
  474. package/dist/cli/cli-agent-context.js +2 -0
  475. package/dist/cli/cli-agent-context.js.map +1 -1
  476. package/dist/cli/config-manager.js +90 -356
  477. package/dist/cli/config-manager.js.map +1 -1
  478. package/dist/cli/conversation-fork-cleanup.js +2 -1
  479. package/dist/cli/conversation-fork-cleanup.js.map +1 -1
  480. package/dist/cli/conversation-fork.js +2 -1
  481. package/dist/cli/conversation-fork.js.map +1 -1
  482. package/dist/cli/coordination/agent-messaging.js +415 -0
  483. package/dist/cli/coordination/agent-messaging.js.map +1 -0
  484. package/dist/cli/coordination/wait-for-threshold.js +232 -0
  485. package/dist/cli/coordination/wait-for-threshold.js.map +1 -0
  486. package/dist/cli/index.js +11 -0
  487. package/dist/cli/index.js.map +1 -1
  488. package/dist/cli/iteration-history.js +2 -1
  489. package/dist/cli/iteration-history.js.map +1 -1
  490. package/dist/cli/parse-decision-cli.js +268 -0
  491. package/dist/cli/parse-decision-cli.js.map +1 -0
  492. package/dist/cli/post-edit-hook.js +83 -0
  493. package/dist/cli/post-edit-hook.js.map +1 -0
  494. package/dist/cli/pre-edit-hook.js +77 -0
  495. package/dist/cli/pre-edit-hook.js.map +1 -0
  496. package/dist/cli/process-lifecycle.js +5 -1
  497. package/dist/cli/process-lifecycle.js.map +1 -1
  498. package/dist/cli/spawn-agent-cli.js +244 -0
  499. package/dist/cli/spawn-agent-cli.js.map +1 -0
  500. package/dist/coordination/coordination-wrapper.js +383 -0
  501. package/dist/coordination/coordination-wrapper.js.map +1 -0
  502. package/dist/coordination/redis-waiting-mode.js +4 -0
  503. package/dist/coordination/redis-waiting-mode.js.map +1 -1
  504. package/dist/coordination/store-success-criteria.js +68 -0
  505. package/dist/coordination/store-success-criteria.js.map +1 -0
  506. package/dist/coordination/store-task-context.js +65 -0
  507. package/dist/coordination/store-task-context.js.map +1 -0
  508. package/dist/hooks/backup-manager.js +273 -0
  509. package/dist/hooks/backup-manager.js.map +1 -0
  510. package/dist/hooks/post-edit-validator.js +388 -0
  511. package/dist/hooks/post-edit-validator.js.map +1 -0
  512. package/dist/integration/index.js +19 -0
  513. package/dist/integration/index.js.map +1 -0
  514. package/dist/integration/task-mode-adapter.js +297 -0
  515. package/dist/integration/task-mode-adapter.js.map +1 -0
  516. package/dist/integration/trigger-dev-client.js +253 -0
  517. package/dist/integration/trigger-dev-client.js.map +1 -0
  518. package/dist/integration/trigger-dev-webhooks.js +362 -0
  519. package/dist/integration/trigger-dev-webhooks.js.map +1 -0
  520. package/dist/lib/artifact-registry.js +4 -0
  521. package/dist/lib/artifact-registry.js.map +1 -1
  522. package/dist/lib/connection-pool.js +390 -0
  523. package/dist/lib/connection-pool.js.map +1 -0
  524. package/dist/lib/environment-contract.js +258 -0
  525. package/dist/lib/environment-contract.js.map +1 -0
  526. package/dist/lib/path-validator.js +14 -5
  527. package/dist/lib/path-validator.js.map +1 -1
  528. package/dist/lib/query-optimizer.js +388 -0
  529. package/dist/lib/query-optimizer.js.map +1 -0
  530. package/dist/lib/redis-queue-manager.js +5 -1
  531. package/dist/lib/redis-queue-manager.js.map +1 -1
  532. package/dist/lib/result-cache.js +285 -0
  533. package/dist/lib/result-cache.js.map +1 -0
  534. package/dist/mcp/auth-middleware.js +2 -1
  535. package/dist/mcp/auth-middleware.js.map +1 -1
  536. package/dist/mcp/playwright-mcp-server-auth.js +2 -1
  537. package/dist/mcp/playwright-mcp-server-auth.js.map +1 -1
  538. package/dist/middleware/authentication.js +317 -0
  539. package/dist/middleware/authentication.js.map +1 -0
  540. package/dist/services/authentication.js +669 -0
  541. package/dist/services/authentication.js.map +1 -0
  542. package/dist/services/session-management.js +436 -0
  543. package/dist/services/session-management.js.map +1 -0
  544. package/dist/services/skill-deployment.js +8 -6
  545. package/dist/services/skill-deployment.js.map +1 -1
  546. package/dist/services/user-service.js +710 -0
  547. package/dist/services/user-service.js.map +1 -0
  548. package/dist/types/trigger-dev-events.d.js +10 -0
  549. package/dist/types/trigger-dev-events.d.js.map +1 -0
  550. package/docs/README.md +240 -0
  551. package/package.json +15 -4
  552. package/scripts/build-agent-image.sh +1 -1
  553. package/scripts/compare-workflow-performance.sh +556 -0
  554. package/scripts/cost-allocation-tracker.sh +632 -0
  555. package/scripts/docker-rebuild-all-agents.sh +2 -2
  556. package/scripts/migrate-to-optimized-workflows.sh +438 -0
  557. package/scripts/organize-docs.sh +338 -0
  558. package/scripts/reorganize-tests.sh +280 -0
  559. package/scripts/trigger-dev-setup.sh +279 -0
  560. package/tests/README.md +45 -0
  561. package/.claude/commands/cost-savings-status.md +0 -34
  562. package/.claude/commands/metrics-summary.md +0 -58
  563. package/.claude/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
  564. package/.claude/skills/cfn-docker-redis-coordination/README.md +0 -294
  565. package/.claude/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
  566. package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
  567. package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
  568. package/.claude/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
  569. package/.claude/skills/cfn-docker-redis-coordination/package.json +0 -40
  570. package/.claude/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
  571. package/.claude/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
  572. package/.claude/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
  573. package/.claude/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
  574. package/.claude/skills/cfn-docker-redis-coordination/tsconfig.json +0 -30
  575. package/.claude/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
  576. package/.claude/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
  577. package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
  578. package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
  579. package/.claude/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
  580. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
  581. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
  582. package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
  583. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
  584. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
  585. package/.claude/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
  586. package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
  587. package/.claude/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
  588. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
  589. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
  590. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
  591. package/.claude/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
  592. package/.claude/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
  593. package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
  594. package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
  595. package/.claude/skills/cfn-redis-coordination/config.json +0 -61
  596. package/.claude/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
  597. package/.claude/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
  598. package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
  599. package/.claude/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
  600. package/.claude/skills/cfn-redis-coordination/jest.config.js +0 -23
  601. package/.claude/skills/cfn-redis-coordination/package-lock.json +0 -5272
  602. package/.claude/skills/cfn-redis-coordination/package.json +0 -45
  603. package/.claude/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
  604. package/.claude/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
  605. package/.claude/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
  606. package/.claude/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
  607. package/.claude/skills/cfn-redis-coordination/src/index.ts +0 -82
  608. package/.claude/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
  609. package/.claude/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
  610. package/.claude/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
  611. package/.claude/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
  612. package/.claude/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
  613. package/.claude/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
  614. package/.claude/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
  615. package/.claude/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
  616. package/.claude/skills/cfn-redis-coordination/src/types.ts +0 -235
  617. package/.claude/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
  618. package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
  619. package/.claude/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
  620. package/.claude/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
  621. package/.claude/skills/cfn-redis-coordination/test-redis-check.js +0 -84
  622. package/.claude/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
  623. package/.claude/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
  624. package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
  625. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +0 -980
  626. package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +0 -759
  627. package/claude-assets/agents/custom/test-mcp-access.md +0 -24
  628. package/claude-assets/agents/typescript-specialist.md +0 -280
  629. package/claude-assets/commands/cost-savings-status.md +0 -34
  630. package/claude-assets/commands/metrics-summary.md +0 -58
  631. package/claude-assets/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
  632. package/claude-assets/skills/cfn-docker-redis-coordination/README.md +0 -294
  633. package/claude-assets/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
  634. package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
  635. package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
  636. package/claude-assets/skills/cfn-docker-redis-coordination/jest.config.js +0 -37
  637. package/claude-assets/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
  638. package/claude-assets/skills/cfn-docker-redis-coordination/package.json +0 -40
  639. package/claude-assets/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
  640. package/claude-assets/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
  641. package/claude-assets/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
  642. package/claude-assets/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
  643. package/claude-assets/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
  644. package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
  645. package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
  646. package/claude-assets/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
  647. package/claude-assets/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
  648. package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
  649. package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
  650. package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
  651. package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
  652. package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
  653. package/claude-assets/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
  654. package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
  655. package/claude-assets/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
  656. package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
  657. package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
  658. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
  659. package/claude-assets/skills/cfn-redis-cleanup/cleanup-redis.sh +0 -130
  660. package/claude-assets/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
  661. package/claude-assets/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
  662. package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
  663. package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
  664. package/claude-assets/skills/cfn-redis-coordination/config.json +0 -61
  665. package/claude-assets/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
  666. package/claude-assets/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
  667. package/claude-assets/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
  668. package/claude-assets/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
  669. package/claude-assets/skills/cfn-redis-coordination/jest.config.js +0 -23
  670. package/claude-assets/skills/cfn-redis-coordination/package-lock.json +0 -5272
  671. package/claude-assets/skills/cfn-redis-coordination/package.json +0 -45
  672. package/claude-assets/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
  673. package/claude-assets/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
  674. package/claude-assets/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
  675. package/claude-assets/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
  676. package/claude-assets/skills/cfn-redis-coordination/src/index.ts +0 -82
  677. package/claude-assets/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
  678. package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
  679. package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
  680. package/claude-assets/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
  681. package/claude-assets/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
  682. package/claude-assets/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
  683. package/claude-assets/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
  684. package/claude-assets/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
  685. package/claude-assets/skills/cfn-redis-coordination/src/types.ts +0 -235
  686. package/claude-assets/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
  687. package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
  688. package/claude-assets/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
  689. package/claude-assets/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
  690. package/claude-assets/skills/cfn-redis-coordination/test-redis-check.js +0 -84
  691. package/claude-assets/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
  692. package/claude-assets/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
  693. package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
  694. package/claude-assets/skills/cfn-redis-data-extraction/SKILL.md +0 -442
  695. package/claude-assets/skills/cfn-redis-data-extraction/extract.sh +0 -306
  696. package/dist/coordination/index.js +0 -25
  697. package/dist/coordination/index.js.map +0 -1
  698. package/docs/BUG_19_MEMORY_LEAK_TASK_MODE.md +0 -405
  699. package/docs/MEMORY_CLEANUP_GUIDE.md +0 -358
  700. package/docs/MEMORY_LEAK_FIX_SUMMARY.md +0 -322
  701. package/docs/REDIS_CLEANUP_EXECUTIVE_SUMMARY.md +0 -319
  702. package/docs/REDIS_CLEANUP_VERIFICATION_REPORT.md +0 -574
  703. package/tests/test-memory-leak-task-mode.sh +0 -435
  704. /package/.claude/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
  705. /package/.claude/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
  706. /package/.claude/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
  707. /package/.claude/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
  708. /package/.claude/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
  709. /package/.claude/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
  710. /package/.claude/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
  711. /package/.claude/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
  712. /package/.claude/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
  713. /package/.claude/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
  714. /package/.claude/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
  715. /package/.claude/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
  716. /package/.claude/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
  717. /package/.claude/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
  718. /package/.claude/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
  719. /package/.claude/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
  720. /package/.claude/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
  721. /package/.claude/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
  722. /package/.claude/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
  723. /package/claude-assets/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
  724. /package/claude-assets/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
  725. /package/claude-assets/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
  726. /package/claude-assets/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
  727. /package/claude-assets/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
  728. /package/claude-assets/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
  729. /package/claude-assets/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
  730. /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
  731. /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
  732. /package/claude-assets/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
  733. /package/claude-assets/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
  734. /package/claude-assets/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
  735. /package/claude-assets/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
  736. /package/claude-assets/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
  737. /package/claude-assets/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
  738. /package/claude-assets/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
  739. /package/claude-assets/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
  740. /package/claude-assets/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
  741. /package/claude-assets/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/coordination/coordination-wrapper.ts"],"sourcesContent":["/**\r\n * Unified TypeScript Coordination Wrapper\r\n *\r\n * Provides a type-safe interface for all Redis-based coordination operations\r\n * in the CFN Loop critical path. Wraps the existing redis-coordinator with\r\n * semantic coordination methods for:\r\n * - Agent lifecycle management\r\n * - Signal/wait primitives\r\n * - Consensus collection\r\n * - Task state management\r\n *\r\n * Key patterns:\r\n * - swarm:* namespace for unified coordination\r\n * - Backward compatible with cfn_loop:task:* legacy namespace\r\n * - Type-safe agent state tracking\r\n * - Automatic timeout handling\r\n */\r\n\r\nimport Redis from 'ioredis';\nimport type { Redis as RedisClient } from 'ioredis';\nimport { EventEmitter } from 'events';\r\n\r\n/**\r\n * Configuration for coordination wrapper\r\n */\r\nexport interface CoordinationConfig {\r\n redisHost: string;\r\n redisPort: number;\r\n redisDb?: number;\r\n taskId: string;\r\n namespace?: 'swarm' | 'cfn_loop';\r\n defaultTimeout?: number;\r\n}\r\n\r\n/**\r\n * Agent state as tracked in Redis\r\n */\r\nexport interface AgentState {\r\n agentId: string;\r\n type: string;\r\n status: 'spawned' | 'running' | 'waiting' | 'completed' | 'failed';\r\n confidence?: number;\r\n testPassRate?: number;\r\n testsRun?: number;\r\n testsPassed?: number;\r\n result?: Record<string, unknown>;\r\n timestamp: string;\r\n iteration?: number;\r\n}\r\n\r\n/**\r\n * Consensus score from validator\r\n */\r\nexport interface ConsensusScore {\r\n agentId: string;\r\n score: number;\r\n feedback?: string;\r\n timestamp: string;\r\n}\r\n\r\n/**\r\n * Task state snapshot\r\n */\r\nexport interface TaskState {\r\n taskId: string;\r\n status: 'pending' | 'in_progress' | 'completed' | 'failed';\r\n context: Record<string, unknown>;\r\n agents: AgentState[];\r\n consensus?: number;\r\n iteration: number;\r\n updatedAt: string;\r\n}\r\n\r\n/**\r\n * Coordination signal/wait result\r\n */\r\nexport interface SignalResult {\r\n received: boolean;\r\n message?: string;\r\n timestamp?: string;\r\n timeout: boolean;\r\n}\r\n\r\n/**\r\n * Unified Coordination Wrapper\r\n *\r\n * Provides semantic coordination methods that abstract away Redis key patterns\r\n * and protocol details while maintaining type safety.\r\n */\r\nexport class CoordinationWrapper extends EventEmitter {\r\n private redis: RedisClient;\r\n private taskId: string;\r\n private namespace: 'swarm' | 'cfn_loop';\r\n private defaultTimeout: number;\r\n private isConnected: boolean = false;\r\n\r\n constructor(config: CoordinationConfig) {\r\n super();\r\n this.taskId = config.taskId;\r\n this.namespace = config.namespace || 'swarm';\r\n this.defaultTimeout = config.defaultTimeout || 120000; // 120 seconds\r\n\r\n // Create Redis client with provided configuration\r\n this.redis = new (Redis as any)({\r\n host: config.redisHost,\r\n port: config.redisPort,\r\n db: config.redisDb || 0,\r\n lazyConnect: true,\r\n maxRetriesPerRequest: null, // Needed for blocking operations\r\n enableReadyCheck: false\r\n });\r\n\r\n // Set up error handling\r\n this.redis.on('error', (error) => {\r\n this.emit('redis-error', error);\r\n });\r\n\r\n this.redis.on('connect', () => {\r\n this.isConnected = true;\r\n this.emit('connected');\r\n });\r\n\r\n this.redis.on('disconnect', () => {\r\n this.isConnected = false;\r\n this.emit('disconnected');\r\n });\r\n }\r\n\r\n /**\r\n * Connect to Redis\r\n */\r\n async connect(): Promise<void> {\r\n if (!this.isConnected) {\r\n await this.redis.connect();\r\n }\r\n }\r\n\r\n /**\r\n * Disconnect from Redis\r\n */\r\n async disconnect(): Promise<void> {\r\n if (this.isConnected) {\r\n await this.redis.disconnect();\r\n }\r\n }\r\n\r\n /**\r\n * Check if connected to Redis\r\n */\r\n isReady(): boolean {\r\n return this.isConnected;\r\n }\r\n\r\n /**\r\n * AGENT LIFECYCLE MANAGEMENT\r\n */\r\n\r\n /**\r\n * Register a spawned agent in the coordination system\r\n */\r\n async registerAgent(agentId: string, agentType: string): Promise<void> {\r\n const state: AgentState = {\r\n agentId,\r\n type: agentType,\r\n status: 'spawned',\r\n timestamp: new Date().toISOString()\r\n };\r\n\r\n const key = this.getAgentStateKey(agentId);\r\n await this.redis.set(key, JSON.stringify(state), 'EX', 86400); // 24h expiry\r\n }\r\n\r\n /**\r\n * Update agent status\r\n */\r\n async updateAgentStatus(\r\n agentId: string,\r\n status: AgentState['status']\r\n ): Promise<void> {\r\n const key = this.getAgentStateKey(agentId);\r\n const state = await this.getAgentState(agentId);\r\n\r\n if (!state) {\r\n throw new Error(`Agent ${agentId} not registered`);\r\n }\r\n\r\n state.status = status;\r\n state.timestamp = new Date().toISOString();\r\n\r\n await this.redis.set(key, JSON.stringify(state), 'EX', 86400);\r\n }\r\n\r\n /**\r\n * Signal agent completion with confidence score\r\n */\r\n async signalCompletion(\r\n agentId: string,\r\n confidence: number,\r\n options?: {\r\n testPassRate?: number;\r\n testsRun?: number;\r\n testsPassed?: number;\r\n result?: Record<string, unknown>;\r\n iteration?: number;\r\n }\r\n ): Promise<void> {\r\n const key = this.getAgentStateKey(agentId);\r\n const state = await this.getAgentState(agentId);\r\n\r\n if (!state) {\r\n throw new Error(`Agent ${agentId} not registered`);\r\n }\r\n\r\n state.status = 'completed';\r\n state.confidence = confidence;\r\n state.testPassRate = options?.testPassRate;\r\n state.testsRun = options?.testsRun;\r\n state.testsPassed = options?.testsPassed;\r\n state.result = options?.result;\r\n state.iteration = options?.iteration;\r\n state.timestamp = new Date().toISOString();\r\n\r\n // Store in agent state with 24h expiry\r\n await this.redis.set(key, JSON.stringify(state), 'EX', 86400);\r\n\r\n // Also publish completion signal to waiting agents\r\n const channel = this.getCompletionChannel(agentId);\r\n await this.redis.publish(channel, JSON.stringify(state));\r\n\r\n // Add to completion leaderboard for consensus collection\r\n const leaderboardKey = this.getCompletionLeaderboardKey();\r\n await this.redis.zadd(\r\n leaderboardKey,\r\n confidence * 100, // Score for sorting\r\n JSON.stringify({\r\n agentId,\r\n confidence,\r\n timestamp: state.timestamp\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Get agent state\r\n */\r\n async getAgentState(agentId: string): Promise<AgentState | null> {\r\n const key = this.getAgentStateKey(agentId);\r\n const data = await this.redis.get(key);\r\n\r\n if (!data) {\r\n return null;\r\n }\r\n\r\n return JSON.parse(data) as AgentState;\r\n }\r\n\r\n /**\r\n * Get all agents in current task\r\n */\r\n async getAllAgents(): Promise<AgentState[]> {\r\n const pattern = this.getAgentStateKeyPattern();\r\n const keys = await this.redis.keys(pattern);\r\n\r\n const agents: AgentState[] = [];\r\n for (const key of keys) {\r\n const data = await this.redis.get(key);\r\n if (data) {\r\n agents.push(JSON.parse(data) as AgentState);\r\n }\r\n }\r\n\r\n return agents;\r\n }\r\n\r\n /**\r\n * COORDINATION PRIMITIVES\r\n */\r\n\r\n /**\r\n * Wait for a coordination signal with timeout\r\n */\r\n async waitForSignal(\r\n channel: string,\r\n timeoutMs?: number\r\n ): Promise<SignalResult> {\r\n const timeout = timeoutMs || this.defaultTimeout;\r\n const timeoutSeconds = Math.ceil(timeout / 1000);\r\n\r\n try {\r\n // Use BLPOP to block-wait on a list\r\n const listKey = this.getSignalKey(channel);\r\n const result = await this.redis.blpop(listKey, timeoutSeconds);\r\n\r\n if (result === null) {\r\n return {\r\n received: false,\r\n timeout: true\r\n };\r\n }\r\n\r\n return {\r\n received: true,\r\n message: result[1],\r\n timestamp: new Date().toISOString(),\r\n timeout: false\r\n };\r\n } catch (error) {\r\n return {\r\n received: false,\r\n timeout: false\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Broadcast a signal to all waiting agents\r\n */\r\n async broadcastSignal(channel: string, message: string): Promise<void> {\r\n // Use pub/sub for broadcast (fire-and-forget to subscribers)\r\n await this.redis.publish(channel, message);\r\n\r\n // Also store in a list for new subscribers (via BLPOP pattern)\r\n const listKey = this.getSignalKey(channel);\r\n await this.redis.lpush(listKey, message);\r\n\r\n // Keep only recent signals (last 100)\r\n await this.redis.ltrim(listKey, 0, 99);\r\n\r\n // Expire the list after 1 hour\r\n await this.redis.expire(listKey, 3600);\r\n }\r\n\r\n /**\r\n * Subscribe to signal channel (pub/sub pattern)\r\n */\r\n subscribeToSignal(\r\n channel: string,\r\n callback: (message: string) => void\r\n ): () => void {\r\n // Create a separate subscriber for pub/sub\r\n const subscriber = this.redis.duplicate();\r\n\r\n subscriber.on('message', (chan, message) => {\r\n if (chan === channel) {\r\n callback(message);\r\n }\r\n });\r\n\r\n subscriber.subscribe(channel);\r\n\r\n // Return unsubscribe function\r\n return () => {\r\n subscriber.unsubscribe(channel);\r\n subscriber.disconnect();\r\n };\r\n }\r\n\r\n /**\r\n * CONSENSUS & VALIDATION\r\n */\r\n\r\n /**\r\n * Collect consensus scores from multiple validators\r\n */\r\n async collectConsensus(\r\n agentIds: string[],\r\n timeoutMs?: number\r\n ): Promise<ConsensusScore[]> {\r\n const timeout = timeoutMs || this.defaultTimeout;\r\n const startTime = Date.now();\r\n const scores: ConsensusScore[] = [];\r\n\r\n for (const agentId of agentIds) {\r\n const elapsed = Date.now() - startTime;\r\n const remaining = Math.max(1, timeout - elapsed);\r\n const remainingSeconds = Math.ceil(remaining / 1000);\r\n\r\n // Wait for each validator to report consensus\r\n const scoreKey = this.getConsensusKey(agentId);\r\n const data = await this.redis.blpop(scoreKey, remainingSeconds);\r\n\r\n if (data) {\r\n const score = JSON.parse(data[1]) as ConsensusScore;\r\n scores.push(score);\r\n }\r\n }\r\n\r\n return scores;\r\n }\r\n\r\n /**\r\n * Report a consensus score\r\n */\r\n async reportConsensusScore(\r\n agentId: string,\r\n score: number,\r\n feedback?: string\r\n ): Promise<void> {\r\n const consensusScore: ConsensusScore = {\r\n agentId,\r\n score,\r\n feedback,\r\n timestamp: new Date().toISOString()\r\n };\r\n\r\n const key = this.getConsensusKey(agentId);\r\n await this.redis.lpush(key, JSON.stringify(consensusScore));\r\n await this.redis.expire(key, 86400); // 24h expiry\r\n }\r\n\r\n /**\r\n * Calculate average consensus from scores\r\n */\r\n calculateAverageConsensus(scores: ConsensusScore[]): number {\r\n if (scores.length === 0) {\r\n return 0;\r\n }\r\n\r\n const sum = scores.reduce((acc, score) => acc + score.score, 0);\r\n return sum / scores.length;\r\n }\r\n\r\n /**\r\n * TASK STATE MANAGEMENT\r\n */\r\n\r\n /**\r\n * Store task context (usually CFN Loop parameters)\r\n */\r\n async storeTaskContext(context: Record<string, unknown>): Promise<void> {\r\n const key = this.getTaskContextKey();\r\n await this.redis.set(key, JSON.stringify(context), 'EX', 86400);\r\n }\r\n\r\n /**\r\n * Load task context\r\n */\r\n async loadTaskContext(): Promise<Record<string, unknown> | null> {\r\n const key = this.getTaskContextKey();\r\n const data = await this.redis.get(key);\r\n\r\n if (!data) {\r\n return null;\r\n }\r\n\r\n return JSON.parse(data) as Record<string, unknown>;\r\n }\r\n\r\n /**\r\n * Update task status\r\n */\r\n async updateTaskStatus(\r\n status: TaskState['status'],\r\n iteration?: number\r\n ): Promise<void> {\r\n const key = this.getTaskStatusKey();\r\n\r\n const state: Partial<TaskState> = {\r\n taskId: this.taskId,\r\n status,\r\n updatedAt: new Date().toISOString()\r\n };\r\n\r\n if (iteration !== undefined) {\r\n state.iteration = iteration;\r\n }\r\n\r\n // Get existing context if available\r\n const contextData = await this.loadTaskContext();\r\n if (contextData) {\r\n state.context = contextData;\r\n }\r\n\r\n // Get all agents\r\n state.agents = await this.getAllAgents();\r\n\r\n await this.redis.set(key, JSON.stringify(state), 'EX', 86400);\r\n }\r\n\r\n /**\r\n * Get full task state snapshot\r\n */\r\n async getTaskState(): Promise<TaskState | null> {\r\n const key = this.getTaskStatusKey();\r\n const data = await this.redis.get(key);\r\n\r\n if (!data) {\r\n return null;\r\n }\r\n\r\n return JSON.parse(data) as TaskState;\r\n }\r\n\r\n /**\r\n * HELPER METHODS FOR KEY GENERATION\r\n */\r\n\r\n private getAgentStateKey(agentId: string): string {\r\n if (this.namespace === 'cfn_loop') {\r\n return `cfn_loop:task:${this.taskId}:agent:${agentId}`;\r\n }\r\n return `${this.namespace}:${this.taskId}:agent:${agentId}`;\r\n }\r\n\r\n private getAgentStateKeyPattern(): string {\r\n if (this.namespace === 'cfn_loop') {\r\n return `cfn_loop:task:${this.taskId}:agent:*`;\r\n }\r\n return `${this.namespace}:${this.taskId}:agent:*`;\r\n }\r\n\r\n private getCompletionChannel(agentId: string): string {\r\n if (this.namespace === 'cfn_loop') {\r\n return `cfn_loop:task:${this.taskId}:completion:${agentId}`;\r\n }\r\n return `${this.namespace}:${this.taskId}:completion`;\r\n }\r\n\r\n private getCompletionLeaderboardKey(): string {\r\n if (this.namespace === 'cfn_loop') {\r\n return `cfn_loop:task:${this.taskId}:completions`;\r\n }\r\n return `${this.namespace}:${this.taskId}:completions`;\r\n }\r\n\r\n private getSignalKey(channel: string): string {\r\n if (this.namespace === 'cfn_loop') {\r\n return `cfn_loop:task:${this.taskId}:signal:${channel}`;\r\n }\r\n return `${this.namespace}:${this.taskId}:signal:${channel}`;\r\n }\r\n\r\n private getConsensusKey(agentId: string): string {\r\n if (this.namespace === 'cfn_loop') {\r\n return `cfn_loop:task:${this.taskId}:consensus:${agentId}`;\r\n }\r\n return `${this.namespace}:${this.taskId}:consensus:${agentId}`;\r\n }\r\n\r\n private getTaskContextKey(): string {\r\n if (this.namespace === 'cfn_loop') {\r\n return `cfn_loop:task:${this.taskId}:context`;\r\n }\r\n return `${this.namespace}:${this.taskId}:context`;\r\n }\r\n\r\n private getTaskStatusKey(): string {\r\n if (this.namespace === 'cfn_loop') {\r\n return `cfn_loop:task:${this.taskId}:status`;\r\n }\r\n return `${this.namespace}:${this.taskId}:status`;\r\n }\r\n\r\n /**\r\n * CLEANUP & UTILITIES\r\n */\r\n\r\n /**\r\n * Clear all coordination state for this task\r\n */\r\n async clearTaskState(): Promise<void> {\r\n const pattern = this.getTaskKeysPattern();\r\n const keys = await this.redis.keys(pattern);\r\n\r\n if (keys.length > 0) {\r\n await this.redis.del(...keys);\r\n }\r\n }\r\n\r\n private getTaskKeysPattern(): string {\r\n if (this.namespace === 'cfn_loop') {\r\n return `cfn_loop:task:${this.taskId}:*`;\r\n }\r\n return `${this.namespace}:${this.taskId}:*`;\r\n }\r\n\r\n /**\r\n * Get Redis client for advanced operations\r\n */\r\n getRedisClient(): RedisClient {\r\n return this.redis;\r\n }\r\n}\r\n\r\nexport default CoordinationWrapper;\r\n"],"names":["Redis","EventEmitter","CoordinationWrapper","redis","taskId","namespace","defaultTimeout","isConnected","config","host","redisHost","port","redisPort","db","redisDb","lazyConnect","maxRetriesPerRequest","enableReadyCheck","on","error","emit","connect","disconnect","isReady","registerAgent","agentId","agentType","state","type","status","timestamp","Date","toISOString","key","getAgentStateKey","set","JSON","stringify","updateAgentStatus","getAgentState","Error","signalCompletion","confidence","options","testPassRate","testsRun","testsPassed","result","iteration","channel","getCompletionChannel","publish","leaderboardKey","getCompletionLeaderboardKey","zadd","data","get","parse","getAllAgents","pattern","getAgentStateKeyPattern","keys","agents","push","waitForSignal","timeoutMs","timeout","timeoutSeconds","Math","ceil","listKey","getSignalKey","blpop","received","message","broadcastSignal","lpush","ltrim","expire","subscribeToSignal","callback","subscriber","duplicate","chan","subscribe","unsubscribe","collectConsensus","agentIds","startTime","now","scores","elapsed","remaining","max","remainingSeconds","scoreKey","getConsensusKey","score","reportConsensusScore","feedback","consensusScore","calculateAverageConsensus","length","sum","reduce","acc","storeTaskContext","context","getTaskContextKey","loadTaskContext","updateTaskStatus","getTaskStatusKey","updatedAt","undefined","contextData","getTaskState","clearTaskState","getTaskKeysPattern","del","getRedisClient"],"mappings":"AAAA;;;;;;;;;;;;;;;;CAgBC,GAED,OAAOA,WAAW,UAAU;AAE5B,SAASC,YAAY,QAAQ,SAAS;AA+DtC;;;;;CAKC,GACD,OAAO,MAAMC,4BAA4BD;IAC/BE,MAAmB;IACnBC,OAAe;IACfC,UAAgC;IAChCC,eAAuB;IACvBC,cAAuB,MAAM;IAErC,YAAYC,MAA0B,CAAE;QACtC,KAAK;QACL,IAAI,CAACJ,MAAM,GAAGI,OAAOJ,MAAM;QAC3B,IAAI,CAACC,SAAS,GAAGG,OAAOH,SAAS,IAAI;QACrC,IAAI,CAACC,cAAc,GAAGE,OAAOF,cAAc,IAAI,QAAQ,cAAc;QAErE,kDAAkD;QAClD,IAAI,CAACH,KAAK,GAAG,IAAKH,MAAc;YAC9BS,MAAMD,OAAOE,SAAS;YACtBC,MAAMH,OAAOI,SAAS;YACtBC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CAAC;IACnD;IAEQ2G,mBAA2B;QACjC,IAAI,IAAI,CAAC1G,SAAS,KAAK,YAAY;YACjC,OAAO,CAAC,cAAc,EAAE,IAAI,CAACD,MAAM,CAAC,OAAO,CAAC;QAC9C;QACA,OAAO,GAAG,IAAI,CAACC,SAAS,CAAC,CAAC,EAAE,IAAI,CAACD,MAAM,CAAC,OAAO,CAAC;IAClD;IAEA;;GAEC,GAED;;GAEC,GACD,MAAMgH,iBAAgC;QACpC,MAAMzD,UAAU,IAAI,CAAC0D,kBAAkB;QACvC,MAAMxD,OAAO,MAAM,IAAI,CAAC1D,KAAK,CAAC0D,IAAI,CAACF;QAEnC,IAAIE,KAAKyC,MAAM,GAAG,GAAG;YACnB,MAAM,IAAI,CAACnG,KAAK,CAACmH,GAAG,IAAIzD;QAC1B;IACF;IAEQwD,qBAA6B;QACnC,IAAI,IAAI,CAAChH,SAAS,KAAK,YAAY;YACjC,OAAO,CAAC,cAAc,EAAE,IAAI,CAACD,MAAM,CAAC,EAAE,CAAC;QACzC;QACA,OAAO,GAAG,IAAI,CAACC,SAAS,CAAC,CAAC,EAAE,IAAI,CAACD,MAAM,CAAC,EAAE,CAAC;IAC7C;IAEA;;GAEC,GACDmH,iBAA8B;QAC5B,OAAO,IAAI,CAACpH,KAAK;IACnB;AACF;AAEA,eAAeD,oBAAoB"}
@@ -1,6 +1,10 @@
1
1
  import Redis from 'ioredis';
2
2
  import { readFileSync } from 'fs';
3
3
  import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ // ESM-compatible __dirname
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
4
8
  export class RedisWaitingMode {
5
9
  redis;
6
10
  config;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/coordination/redis-waiting-mode.ts"],"sourcesContent":["import Redis from 'ioredis';\nimport { readFileSync } from 'fs';\nimport path from 'path';\n\ninterface RedisConfig {\n host: string;\n port: number;\n db: number;\n}\n\ninterface WaitingModeConfig {\n defaultTimeout: number;\n wakeChannelPattern: string;\n resultKeyPattern: string;\n consensusThreshold: number;\n}\n\nexport class RedisWaitingMode {\n private redis: Redis;\n private config: RedisConfig & { waitingMode: WaitingModeConfig };\n\n constructor() {\n const configPath = path.resolve(__dirname, '../../.claude/skills/redis-coordination/config.json');\n const configFile = readFileSync(configPath, 'utf-8');\n this.config = JSON.parse(configFile);\n\n this.redis = new Redis({\n host: this.config.host,\n port: this.config.port,\n db: this.config.db\n });\n }\n\n async enterWaitingMode(taskId: string, agentId: string, context: string): Promise<any> {\n try {\n const wakeChannel = this.config.waitingMode.wakeChannelPattern\n .replace('{taskId}', taskId)\n .replace('{agentId}', agentId);\n\n const result = await this.redis.blpop(\n wakeChannel,\n this.config.waitingMode.defaultTimeout / 1000\n );\n\n return {\n status: result ? 'woken' : 'timeout',\n payload: result ? JSON.parse(result[1]) : null,\n context\n };\n } catch (error) {\n return {\n status: 'error',\n message: error instanceof Error ? error.message : 'Unknown error',\n context\n };\n }\n }\n\n async wakeAgent(taskId: string, agentId: string, payload: any): Promise<any> {\n try {\n const wakeChannel = this.config.waitingMode.wakeChannelPattern\n .replace('{taskId}', taskId)\n .replace('{agentId}', agentId);\n\n await this.redis.lpush(wakeChannel, JSON.stringify(payload));\n\n return {\n status: 'success',\n taskId,\n agentId,\n payload\n };\n } catch (error) {\n return {\n status: 'error',\n message: error instanceof Error ? error.message : 'Unknown error',\n taskId,\n agentId\n };\n }\n }\n\n async reportResult(taskId: string, agentId: string, result: any, confidence: number): Promise<any> {\n try {\n const resultKey = this.config.waitingMode.resultKeyPattern\n .replace('{taskId}', taskId)\n .replace('{agentId}', agentId);\n\n await this.redis.set(resultKey, JSON.stringify({\n result,\n confidence,\n timestamp: Date.now()\n }));\n\n return {\n status: 'success',\n taskId,\n agentId,\n confidence\n };\n } catch (error) {\n return {\n status: 'error',\n message: error instanceof Error ? error.message : 'Unknown error',\n taskId,\n agentId\n };\n }\n }\n\n async collectConsensus(taskId: string, agentIds: string[]): Promise<any> {\n try {\n const results = await Promise.all(\n agentIds.map(async (agentId) => {\n const resultKey = this.config.waitingMode.resultKeyPattern\n .replace('{taskId}', taskId)\n .replace('{agentId}', agentId);\n\n const resultStr = await this.redis.get(resultKey);\n return resultStr ? JSON.parse(resultStr) : null;\n })\n );\n\n const validResults = results.filter(r => r && r.confidence);\n const avgConfidence = validResults.length\n ? validResults.reduce((sum, r) => sum + r.confidence, 0) / validResults.length\n : 0;\n\n const consensusReached = avgConfidence >= this.config.waitingMode.consensusThreshold;\n\n return {\n status: consensusReached ? 'consensus' : 'insufficient_consensus',\n taskId,\n results: validResults,\n avgConfidence,\n consensusThreshold: this.config.waitingMode.consensusThreshold\n };\n } catch (error) {\n return {\n status: 'error',\n message: error instanceof Error ? error.message : 'Unknown error',\n taskId\n };\n }\n }\n}\n\n// Export a singleton instance for easier use\nexport const redisWaitingMode = new RedisWaitingMode();\n"],"names":["Redis","readFileSync","path","RedisWaitingMode","redis","config","configPath","resolve","__dirname","configFile","JSON","parse","host","port","db","enterWaitingMode","taskId","agentId","context","wakeChannel","waitingMode","wakeChannelPattern","replace","result","blpop","defaultTimeout","status","payload","error","message","Error","wakeAgent","lpush","stringify","reportResult","confidence","resultKey","resultKeyPattern","set","timestamp","Date","now","collectConsensus","agentIds","results","Promise","all","map","resultStr","get","validResults","filter","r","avgConfidence","length","reduce","sum","consensusReached","consensusThreshold","redisWaitingMode"],"mappings":"AAAA,OAAOA,WAAW,UAAU;AAC5B,SAASC,YAAY,QAAQ,KAAK;AAClC,OAAOC,UAAU,OAAO;AAexB,OAAO,MAAMC;IACHC,MAAa;IACbC,OAAyD;IAEjE,aAAc;QACZ,MAAMC,aAAaJ,KAAKK,OAAO,CAACC,WAAW;QAC3C,MAAMC,aAAaR,aAAaK,YAAY;QAC5C,IAAI,CAACD,MAAM,GAAGK,KAAKC,KAAK,CAACF;QAEzB,IAAI,CAACL,KAAK,GAAG,IAAIJ,MAAM;YACrBY,MAAM,IAAI,CAACP,MAAM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;QACF,EAAE,OAAO9B,OAAO;YACd,OAAO;gBACLF,QAAQ;gBACRG,SAASD,iBAAiBE,QAAQF,MAAMC,OAAO,GAAG;gBAClDb;YACF;QACF;IACF;AACF;AAEA,6CAA6C;AAC7C,OAAO,MAAM2C,mBAAmB,IAAIxD,mBAAmB"}
1
+ {"version":3,"sources":["../../src/coordination/redis-waiting-mode.ts"],"sourcesContent":["import Redis from 'ioredis';\nimport { readFileSync } from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\n// ESM-compatible __dirname\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\ninterface RedisConfig {\n host: string;\n port: number;\n db: number;\n}\n\ninterface WaitingModeConfig {\n defaultTimeout: number;\n wakeChannelPattern: string;\n resultKeyPattern: string;\n consensusThreshold: number;\n}\n\nexport class RedisWaitingMode {\n private redis: Redis;\n private config: RedisConfig & { waitingMode: WaitingModeConfig };\n\n constructor() {\n const configPath = path.resolve(__dirname, '../../.claude/skills/redis-coordination/config.json');\n const configFile = readFileSync(configPath, 'utf-8');\n this.config = JSON.parse(configFile);\n\n this.redis = new Redis({\n host: this.config.host,\n port: this.config.port,\n db: this.config.db\n });\n }\n\n async enterWaitingMode(taskId: string, agentId: string, context: string): Promise<any> {\n try {\n const wakeChannel = this.config.waitingMode.wakeChannelPattern\n .replace('{taskId}', taskId)\n .replace('{agentId}', agentId);\n\n const result = await this.redis.blpop(\n wakeChannel,\n this.config.waitingMode.defaultTimeout / 1000\n );\n\n return {\n status: result ? 'woken' : 'timeout',\n payload: result ? JSON.parse(result[1]) : null,\n context\n };\n } catch (error) {\n return {\n status: 'error',\n message: error instanceof Error ? error.message : 'Unknown error',\n context\n };\n }\n }\n\n async wakeAgent(taskId: string, agentId: string, payload: any): Promise<any> {\n try {\n const wakeChannel = this.config.waitingMode.wakeChannelPattern\n .replace('{taskId}', taskId)\n .replace('{agentId}', agentId);\n\n await this.redis.lpush(wakeChannel, JSON.stringify(payload));\n\n return {\n status: 'success',\n taskId,\n agentId,\n payload\n };\n } catch (error) {\n return {\n status: 'error',\n message: error instanceof Error ? error.message : 'Unknown error',\n taskId,\n agentId\n };\n }\n }\n\n async reportResult(taskId: string, agentId: string, result: any, confidence: number): Promise<any> {\n try {\n const resultKey = this.config.waitingMode.resultKeyPattern\n .replace('{taskId}', taskId)\n .replace('{agentId}', agentId);\n\n await this.redis.set(resultKey, JSON.stringify({\n result,\n confidence,\n timestamp: Date.now()\n }));\n\n return {\n status: 'success',\n taskId,\n agentId,\n confidence\n };\n } catch (error) {\n return {\n status: 'error',\n message: error instanceof Error ? error.message : 'Unknown error',\n taskId,\n agentId\n };\n }\n }\n\n async collectConsensus(taskId: string, agentIds: string[]): Promise<any> {\n try {\n const results = await Promise.all(\n agentIds.map(async (agentId) => {\n const resultKey = this.config.waitingMode.resultKeyPattern\n .replace('{taskId}', taskId)\n .replace('{agentId}', agentId);\n\n const resultStr = await this.redis.get(resultKey);\n return resultStr ? JSON.parse(resultStr) : null;\n })\n );\n\n const validResults = results.filter(r => r && r.confidence);\n const avgConfidence = validResults.length\n ? validResults.reduce((sum, r) => sum + r.confidence, 0) / validResults.length\n : 0;\n\n const consensusReached = avgConfidence >= this.config.waitingMode.consensusThreshold;\n\n return {\n status: consensusReached ? 'consensus' : 'insufficient_consensus',\n taskId,\n results: validResults,\n avgConfidence,\n consensusThreshold: this.config.waitingMode.consensusThreshold\n };\n } catch (error) {\n return {\n status: 'error',\n message: error instanceof Error ? error.message : 'Unknown error',\n taskId\n };\n }\n }\n}\n\n// Export a singleton instance for easier use\nexport const redisWaitingMode = new RedisWaitingMode();\n"],"names":["Redis","readFileSync","path","fileURLToPath","__filename","url","__dirname","dirname","RedisWaitingMode","redis","config","configPath","resolve","configFile","JSON","parse","host","port","db","enterWaitingMode","taskId","agentId","context","wakeChannel","waitingMode","wakeChannelPattern","replace","result","blpop","defaultTimeout","status","payload","error","message","Error","wakeAgent","lpush","stringify","reportResult","confidence","resultKey","resultKeyPattern","set","timestamp","Date","now","collectConsensus","agentIds","results","Promise","all","map","resultStr","get","validResults","filter","r","avgConfidence","length","reduce","sum","consensusReached","consensusThreshold","redisWaitingMode"],"mappings":"AAAA,OAAOA,WAAW,UAAU;AAC5B,SAASC,YAAY,QAAQ,KAAK;AAClC,OAAOC,UAAU,OAAO;AACxB,SAASC,aAAa,QAAQ,MAAM;AAEpC,2BAA2B;AAC3B,MAAMC,aAAaD,cAAc,YAAYE,GAAG;AAChD,MAAMC,YAAYJ,KAAKK,OAAO,CAACH;AAe/B,OAAO,MAAMI;IACHC,MAAa;IACbC,OAAyD;IAEjE,aAAc;QACZ,MAAMC,aAAaT,KAAKU,OAAO,CAACN,WAAW;QAC3C,MAAMO,aAAaZ,aAAaU,YAAY;QAC5C,IAAI,CAACD,MAAM,GAAGI,KAAKC,KAAK,CAACF;QAEzB,IAAI,CAACJ,KAAK,GAAG,IAAIT,MAAM;YACrBgB,MAAM,IAAI,CAACN,MAAM,CAACM,IAAI;YACtBC,MAAM,IAAI,CAACP,MAAM,CAACO,IAAI;YACtBC,IAAI,IAAI,CAACR,MAAM,CAACQ,EAAE;QACpB;IACF;IAEA,MAAMC,iBAAiBC,MAAc,EAAEC,OAAe,EAAEC,OAAe,EAAgB;QACrF,IAAI;YACF,MAAMC,cAAc,IAAI,CAACb,MAAM,CAACc,WAAW,CAACC,kBAAkB,CAC3DC,OAAO,CAAC,YAAYN,QACpBM,OAAO,CAAC,aAAaL;YAExB,MAAMM,SAAS,MAAM,IAAI,CAAClB,KAAK,CAACmB,KAAK,CACnCL,aACA,IAAI,CAACb,MAAM,CAACc,WAAW,CAACK,cAAc,GAAG;YAG3C,OAAO;gBACLC,QAAQH,SAAS,UAAU;gBAC3BI,SAASJ,SAASb,KAAKC,KAAK,CAACY,MAAM,CAAC,EAAE,IAAI;gBAC1CL;YACF;QACF,EAAE,OAAOU,OAAO;YACd,OAAO;gBACLF,QAAQ;gBACRG,SAASD,iBAAiBE,QAAQF,MAAMC,OA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,YAAYN,QACpBM,OAAO,CAAC,aAAaL;gBAExB,MAAM+B,YAAY,MAAM,IAAI,CAAC3C,KAAK,CAAC4C,GAAG,CAACb;gBACvC,OAAOY,YAAYtC,KAAKC,KAAK,CAACqC,aAAa;YAC7C;YAGF,MAAME,eAAeN,QAAQO,MAAM,CAACC,CAAAA,IAAKA,KAAKA,EAAEjB,UAAU;YAC1D,MAAMkB,gBAAgBH,aAAaI,MAAM,GACrCJ,aAAaK,MAAM,CAAC,CAACC,KAAKJ,IAAMI,MAAMJ,EAAEjB,UAAU,EAAE,KAAKe,aAAaI,MAAM,GAC5E;YAEJ,MAAMG,mBAAmBJ,iBAAiB,IAAI,CAAC/C,MAAM,CAACc,WAAW,CAACsC,kBAAkB;YAEpF,OAAO;gBACLhC,QAAQ+B,mBAAmB,cAAc;gBACzCzC;gBACA4B,SAASM;gBACTG;gBACAK,oBAAoB,IAAI,CAACpD,MAAM,CAACc,WAAW,CAACsC,kBAAkB;YAChE;QACF,EAAE,OAAO9B,OAAO;YACd,OAAO;gBACLF,QAAQ;gBACRG,SAASD,iBAAiBE,QAAQF,MAAMC,OAAO,GAAG;gBAClDb;YACF;QACF;IACF;AACF;AAEA,6CAA6C;AAC7C,OAAO,MAAM2C,mBAAmB,IAAIvD,mBAAmB"}
@@ -0,0 +1,68 @@
1
+ import Redis from 'ioredis';
2
+ const argValue = (flag)=>{
3
+ const index = process.argv.indexOf(flag);
4
+ if (index === -1 || index + 1 >= process.argv.length) {
5
+ return undefined;
6
+ }
7
+ return process.argv[index + 1];
8
+ };
9
+ const parseArgs = ()=>{
10
+ const taskId = argValue('--task-id');
11
+ const criteriaRaw = argValue('--criteria');
12
+ if (!taskId) throw new Error('--task-id is required');
13
+ if (!/^[A-Za-z0-9_-]+$/.test(taskId)) {
14
+ throw new Error('Invalid task id format; use alphanumeric, dash, underscore only');
15
+ }
16
+ if (!criteriaRaw) throw new Error('--criteria is required');
17
+ return {
18
+ taskId,
19
+ criteriaRaw,
20
+ redisHost: process.env.REDIS_HOST || 'localhost',
21
+ redisPort: Number(process.env.REDIS_PORT || 6379),
22
+ ttlSeconds: 86400
23
+ };
24
+ };
25
+ const validateCriteria = (criteria)=>{
26
+ if (!Array.isArray(criteria.test_suites)) {
27
+ throw new Error('success criteria must include test_suites array');
28
+ }
29
+ if (criteria.test_suites.length === 0) {
30
+ throw new Error('test_suites cannot be empty');
31
+ }
32
+ };
33
+ const storeCriteria = async (args)=>{
34
+ let parsed;
35
+ try {
36
+ parsed = JSON.parse(args.criteriaRaw);
37
+ } catch {
38
+ throw new Error('criteria is not valid JSON');
39
+ }
40
+ validateCriteria(parsed);
41
+ const redis = new Redis({
42
+ host: args.redisHost,
43
+ port: args.redisPort,
44
+ lazyConnect: true
45
+ });
46
+ try {
47
+ await redis.connect();
48
+ const key = `swarm:${args.taskId}:context`;
49
+ const serialized = JSON.stringify(parsed);
50
+ await redis.hset(key, 'success-criteria', serialized);
51
+ await redis.expire(key, args.ttlSeconds);
52
+ console.log(`✅ Success criteria stored in Redis: ${key}`);
53
+ console.log(` Test suites: ${parsed.test_suites.length}`);
54
+ console.log(` TTL: ${args.ttlSeconds} seconds`);
55
+ } finally{
56
+ redis.disconnect();
57
+ }
58
+ };
59
+ const main = async ()=>{
60
+ const args = parseArgs();
61
+ await storeCriteria(args);
62
+ };
63
+ main().catch((error)=>{
64
+ console.error(`❌ Failed to store success criteria: ${error.message}`);
65
+ process.exitCode = 1;
66
+ });
67
+
68
+ //# sourceMappingURL=store-success-criteria.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/coordination/store-success-criteria.ts"],"sourcesContent":["import Redis from 'ioredis';\n\ninterface SuccessCriteriaArgs {\n taskId: string;\n criteriaRaw: string;\n redisHost: string;\n redisPort: number;\n ttlSeconds: number;\n}\n\ntype TestSuite = {\n name: string;\n command: string;\n required?: boolean;\n pass_threshold?: number;\n};\n\ninterface SuccessCriteria {\n test_suites: TestSuite[];\n gate_mode?: string;\n metadata?: Record<string, unknown>;\n}\n\nconst argValue = (flag: string): string | undefined => {\n const index = process.argv.indexOf(flag);\n if (index === -1 || index + 1 >= process.argv.length) {\n return undefined;\n }\n return process.argv[index + 1];\n};\n\nconst parseArgs = (): SuccessCriteriaArgs => {\n const taskId = argValue('--task-id');\n const criteriaRaw = argValue('--criteria');\n\n if (!taskId) throw new Error('--task-id is required');\n if (!/^[A-Za-z0-9_-]+$/.test(taskId)) {\n throw new Error('Invalid task id format; use alphanumeric, dash, underscore only');\n }\n\n if (!criteriaRaw) throw new Error('--criteria is required');\n\n return {\n taskId,\n criteriaRaw,\n redisHost: process.env.REDIS_HOST || 'localhost',\n redisPort: Number(process.env.REDIS_PORT || 6379),\n ttlSeconds: 86400,\n };\n};\n\nconst validateCriteria = (criteria: SuccessCriteria) => {\n if (!Array.isArray(criteria.test_suites)) {\n throw new Error('success criteria must include test_suites array');\n }\n if (criteria.test_suites.length === 0) {\n throw new Error('test_suites cannot be empty');\n }\n};\n\nconst storeCriteria = async (args: SuccessCriteriaArgs) => {\n let parsed: SuccessCriteria;\n try {\n parsed = JSON.parse(args.criteriaRaw) as SuccessCriteria;\n } catch {\n throw new Error('criteria is not valid JSON');\n }\n\n validateCriteria(parsed);\n\n const redis = new Redis({\n host: args.redisHost,\n port: args.redisPort,\n lazyConnect: true,\n });\n\n try {\n await redis.connect();\n const key = `swarm:${args.taskId}:context`;\n const serialized = JSON.stringify(parsed);\n\n await redis.hset(key, 'success-criteria', serialized);\n await redis.expire(key, args.ttlSeconds);\n\n console.log(`✅ Success criteria stored in Redis: ${key}`);\n console.log(` Test suites: ${parsed.test_suites.length}`);\n console.log(` TTL: ${args.ttlSeconds} seconds`);\n } finally {\n redis.disconnect();\n }\n};\n\nconst main = async () => {\n const args = parseArgs();\n await storeCriteria(args);\n};\n\nmain().catch((error) => {\n console.error(`❌ Failed to store success criteria: ${error.message}`);\n process.exitCode = 1;\n});\n"],"names":["Redis","argValue","flag","index","process","argv","indexOf","length","undefined","parseArgs","taskId","criteriaRaw","Error","test","redisHost","env","REDIS_HOST","redisPort","Number","REDIS_PORT","ttlSeconds","validateCriteria","criteria","Array","isArray","test_suites","storeCriteria","args","parsed","JSON","parse","redis","host","port","lazyConnect","connect","key","serialized","stringify","hset","expire","console","log","disconnect","main","catch","error","message","exitCode"],"mappings":"AAAA,OAAOA,WAAW,UAAU;AAuB5B,MAAMC,WAAW,CAACC;IAChB,MAAMC,QAAQC,QAAQC,IAAI,CAACC,OAAO,CAACJ;IACnC,IAAIC,UAAU,CAAC,KAAKA,QAAQ,KAAKC,QAAQC,IAAI,CAACE,MAAM,EAAE;QACpD,OAAOC;IACT;IACA,OAAOJ,QAAQC,IAAI,CAACF,QAAQ,EAAE;AAChC;AAEA,MAAMM,YAAY;IAChB,MAAMC,SAAST,SAAS;IACxB,MAAMU,cAAcV,SAAS;IAE7B,IAAI,CAACS,QAAQ,MAAM,IAAIE,MAAM;IAC7B,IAAI,CAAC,mBAAmBC,IAAI,CAACH,SAAS;QACpC,MAAM,IAAIE,MAAM;IAClB;IAEA,IAAI,CAACD,aAAa,MAAM,IAAIC,MAAM;IAElC,OAAO;QACLF;QACAC;QACAG,WAAWV,QAAQW,GAAG,CAACC,UAAU,IAAI;QACrCC,WAAWC,OAAOd,QAAQW,GAAG,CAACI,UAAU,IAAI;QAC5CC,YAAY;IACd;AACF;AAEA,MAAMC,mBAAmB,CAACC;IACxB,IAAI,CAACC,MAAMC,OAAO,CAACF,SAASG,WAAW,GAAG;QACxC,MAAM,IAAIb,MAAM;IAClB;IACA,IAAIU,SAASG,WAAW,CAAClB,MAAM,KAAK,GAAG;QACrC,MAAM,IAAIK,MAAM;IAClB;AACF;AAEA,MAAMc,gBAAgB,OAAOC;IAC3B,IAAIC;IACJ,IAAI;QACFA,SAASC,KAAKC,KAAK,CAACH,KAAKhB,WAAW;IACtC,EAAE,OAAM;QACN,MAAM,IAAIC,MAAM;IAClB;IAEAS,iBAAiBO;IAEjB,MAAMG,QAAQ,IAAI/B,MAAM;QACtBgC,MAAML,KAAKb,SAAS;QACpBmB,MAAMN,KAAKV,SAAS;QACpBiB,aAAa;IACf;IAEA,IAAI;QACF,MAAMH,MAAMI,OAAO;QACnB,MAAMC,MAAM,CAAC,MAAM,EAAET,KAAKjB,MAAM,CAAC,QAAQ,CAAC;QAC1C,MAAM2B,aAAaR,KAAKS,SAAS,CAACV;QAElC,MAAMG,MAAMQ,IAAI,CAACH,KAAK,oBAAoBC;QAC1C,MAAMN,MAAMS,MAAM,CAACJ,KAAKT,KAAKP,UAAU;QAEvCqB,QAAQC,GAAG,CAAC,CAAC,oCAAoC,EAAEN,KAAK;QACxDK,QAAQC,GAAG,CAAC,CAAC,gBAAgB,EAAEd,OAAOH,WAAW,CAAClB,MAAM,EAAE;QAC1DkC,QAAQC,GAAG,CAAC,CAAC,QAAQ,EAAEf,KAAKP,UAAU,CAAC,QAAQ,CAAC;IAClD,SAAU;QACRW,MAAMY,UAAU;IAClB;AACF;AAEA,MAAMC,OAAO;IACX,MAAMjB,OAAOlB;IACb,MAAMiB,cAAcC;AACtB;AAEAiB,OAAOC,KAAK,CAAC,CAACC;IACZL,QAAQK,KAAK,CAAC,CAAC,oCAAoC,EAAEA,MAAMC,OAAO,EAAE;IACpE3C,QAAQ4C,QAAQ,GAAG;AACrB"}
@@ -0,0 +1,65 @@
1
+ import Redis from 'ioredis';
2
+ const argValue = (flag)=>{
3
+ const index = process.argv.indexOf(flag);
4
+ if (index === -1 || index + 1 >= process.argv.length) {
5
+ return undefined;
6
+ }
7
+ return process.argv[index + 1];
8
+ };
9
+ const parseArgs = ()=>{
10
+ const taskId = argValue('--task-id');
11
+ const description = argValue('--description');
12
+ const mode = argValue('--mode');
13
+ const maxIterationsRaw = argValue('--max-iterations');
14
+ if (!taskId) throw new Error('--task-id is required');
15
+ if (!/^[A-Za-z0-9_-]+$/.test(taskId)) {
16
+ throw new Error('Invalid task id format; use alphanumeric, dash, underscore only');
17
+ }
18
+ if (!description) throw new Error('--description is required');
19
+ if (!mode) throw new Error('--mode is required');
20
+ if (!maxIterationsRaw) throw new Error('--max-iterations is required');
21
+ const maxIterations = Number(maxIterationsRaw);
22
+ if (!Number.isFinite(maxIterations) || maxIterations <= 0) {
23
+ throw new Error('--max-iterations must be a positive number');
24
+ }
25
+ return {
26
+ taskId,
27
+ description,
28
+ mode,
29
+ maxIterations,
30
+ redisHost: process.env.REDIS_HOST || 'localhost',
31
+ redisPort: Number(process.env.REDIS_PORT || 6379),
32
+ ttlSeconds: 86400
33
+ };
34
+ };
35
+ const storeContext = async (args)=>{
36
+ const redis = new Redis({
37
+ host: args.redisHost,
38
+ port: args.redisPort,
39
+ lazyConnect: true
40
+ });
41
+ try {
42
+ await redis.connect();
43
+ const key = `swarm:${args.taskId}:context`;
44
+ await redis.hset(key, {
45
+ 'task_description': args.description,
46
+ 'mode': args.mode,
47
+ 'max_iterations': String(args.maxIterations)
48
+ });
49
+ await redis.expire(key, args.ttlSeconds);
50
+ console.log(`✅ Task context stored in Redis: ${key}`);
51
+ console.log(` TTL: ${args.ttlSeconds} seconds`);
52
+ } finally{
53
+ redis.disconnect();
54
+ }
55
+ };
56
+ const main = async ()=>{
57
+ const args = parseArgs();
58
+ await storeContext(args);
59
+ };
60
+ main().catch((error)=>{
61
+ console.error(`❌ Failed to store task context: ${error.message}`);
62
+ process.exitCode = 1;
63
+ });
64
+
65
+ //# sourceMappingURL=store-task-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/coordination/store-task-context.ts"],"sourcesContent":["import Redis from 'ioredis';\n\ninterface TaskContextArgs {\n taskId: string;\n description: string;\n mode: string;\n maxIterations: number;\n redisHost: string;\n redisPort: number;\n ttlSeconds: number;\n}\n\nconst argValue = (flag: string): string | undefined => {\n const index = process.argv.indexOf(flag);\n if (index === -1 || index + 1 >= process.argv.length) {\n return undefined;\n }\n return process.argv[index + 1];\n};\n\nconst parseArgs = (): TaskContextArgs => {\n const taskId = argValue('--task-id');\n const description = argValue('--description');\n const mode = argValue('--mode');\n const maxIterationsRaw = argValue('--max-iterations');\n\n if (!taskId) throw new Error('--task-id is required');\n if (!/^[A-Za-z0-9_-]+$/.test(taskId)) {\n throw new Error('Invalid task id format; use alphanumeric, dash, underscore only');\n }\n\n if (!description) throw new Error('--description is required');\n if (!mode) throw new Error('--mode is required');\n if (!maxIterationsRaw) throw new Error('--max-iterations is required');\n\n const maxIterations = Number(maxIterationsRaw);\n if (!Number.isFinite(maxIterations) || maxIterations <= 0) {\n throw new Error('--max-iterations must be a positive number');\n }\n\n return {\n taskId,\n description,\n mode,\n maxIterations,\n redisHost: process.env.REDIS_HOST || 'localhost',\n redisPort: Number(process.env.REDIS_PORT || 6379),\n ttlSeconds: 86400,\n };\n};\n\nconst storeContext = async (args: TaskContextArgs) => {\n const redis = new Redis({\n host: args.redisHost,\n port: args.redisPort,\n lazyConnect: true,\n });\n\n try {\n await redis.connect();\n const key = `swarm:${args.taskId}:context`;\n\n await redis.hset(key, {\n 'task_description': args.description,\n 'mode': args.mode,\n 'max_iterations': String(args.maxIterations),\n });\n\n await redis.expire(key, args.ttlSeconds);\n\n console.log(`✅ Task context stored in Redis: ${key}`);\n console.log(` TTL: ${args.ttlSeconds} seconds`);\n } finally {\n redis.disconnect();\n }\n};\n\nconst main = async () => {\n const args = parseArgs();\n await storeContext(args);\n};\n\nmain().catch((error) => {\n console.error(`❌ Failed to store task context: ${error.message}`);\n process.exitCode = 1;\n});\n"],"names":["Redis","argValue","flag","index","process","argv","indexOf","length","undefined","parseArgs","taskId","description","mode","maxIterationsRaw","Error","test","maxIterations","Number","isFinite","redisHost","env","REDIS_HOST","redisPort","REDIS_PORT","ttlSeconds","storeContext","args","redis","host","port","lazyConnect","connect","key","hset","String","expire","console","log","disconnect","main","catch","error","message","exitCode"],"mappings":"AAAA,OAAOA,WAAW,UAAU;AAY5B,MAAMC,WAAW,CAACC;IAChB,MAAMC,QAAQC,QAAQC,IAAI,CAACC,OAAO,CAACJ;IACnC,IAAIC,UAAU,CAAC,K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AU;QAEvCY,QAAQC,GAAG,CAAC,CAAC,gCAAgC,EAAEL,KAAK;QACpDI,QAAQC,GAAG,CAAC,CAAC,QAAQ,EAAEX,KAAKF,UAAU,CAAC,QAAQ,CAAC;IAClD,SAAU;QACRG,MAAMW,UAAU;IAClB;AACF;AAEA,MAAMC,OAAO;IACX,MAAMb,OAAOjB;IACb,MAAMgB,aAAaC;AACrB;AAEAa,OAAOC,KAAK,CAAC,CAACC;IACZL,QAAQK,KAAK,CAAC,CAAC,gCAAgC,EAAEA,MAAMC,OAAO,EAAE;IAChEtC,QAAQuC,QAAQ,GAAG;AACrB"}
@@ -0,0 +1,273 @@
1
+ /**
2
+ * Backup Manager - File lifecycle backup creation and restoration
3
+ * Manages pre-edit backups with metadata, hash generation, and cleanup
4
+ */ import * as fs from 'fs/promises';
5
+ import * as path from 'path';
6
+ import * as crypto from 'crypto';
7
+ export class BackupManager {
8
+ config;
9
+ projectRoot;
10
+ constructor(projectRoot = process.cwd(), config){
11
+ this.projectRoot = projectRoot;
12
+ this.config = {
13
+ retentionHours: config?.retentionHours ?? 24,
14
+ maxBackups: config?.maxBackups ?? 10,
15
+ backupDir: config?.backupDir ?? '.backups'
16
+ };
17
+ }
18
+ /**
19
+ * Generate SHA256 hash of file content (8 char truncated)
20
+ */ async generateFileHash(filePath) {
21
+ try {
22
+ const content = await fs.readFile(filePath);
23
+ const hash = crypto.createHash('sha256').update(content).digest('hex');
24
+ return hash.substring(0, 8);
25
+ } catch (error) {
26
+ throw new Error(`Failed to generate hash for ${filePath}: ${error}`);
27
+ }
28
+ }
29
+ /**
30
+ * Count lines in a file
31
+ */ async countLines(filePath) {
32
+ try {
33
+ const content = await fs.readFile(filePath, 'utf-8');
34
+ return content.split('\n').length - 1; // Subtract 1 for trailing newline
35
+ } catch {
36
+ return 0;
37
+ }
38
+ }
39
+ /**
40
+ * Get file size in bytes
41
+ */ async getFileSize(filePath) {
42
+ try {
43
+ const stat = await fs.stat(filePath);
44
+ return stat.size;
45
+ } catch {
46
+ return 0;
47
+ }
48
+ }
49
+ /**
50
+ * Create a backup of a file before editing
51
+ */ async createBackup(filePath, agentId) {
52
+ // Validate inputs
53
+ if (!filePath) {
54
+ throw new Error('File path is required');
55
+ }
56
+ if (!agentId) {
57
+ throw new Error('Agent ID is required');
58
+ }
59
+ // Check if file exists
60
+ try {
61
+ await fs.stat(filePath);
62
+ } catch {
63
+ throw new Error(`File does not exist: ${filePath}`);
64
+ }
65
+ try {
66
+ // Generate timestamp and hash
67
+ const timestamp = new Date().toISOString();
68
+ const fileHash = await this.generateFileHash(filePath);
69
+ const unixTimestamp = Date.now();
70
+ // Create backup directory structure: .backups/agent-id/timestamp_hash/
71
+ const backupBaseDir = path.join(this.projectRoot, this.config.backupDir, agentId);
72
+ const backupName = `${unixTimestamp}_${fileHash}`;
73
+ const fullBackupPath = path.join(backupBaseDir, backupName);
74
+ // Create backup directory
75
+ await fs.mkdir(fullBackupPath, {
76
+ recursive: true
77
+ });
78
+ // Copy original file to backup location
79
+ const originalFileName = path.basename(filePath);
80
+ const backupFilePath = path.join(fullBackupPath, originalFileName);
81
+ await fs.copyFile(filePath, backupFilePath);
82
+ // Gather metadata
83
+ const fileSize = await this.getFileSize(filePath);
84
+ const lineCount = await this.countLines(filePath);
85
+ // Create metadata file
86
+ const metadata = {
87
+ timestamp,
88
+ agentId,
89
+ originalFile: filePath,
90
+ fileHash,
91
+ backupPath: fullBackupPath,
92
+ createdAt: new Date().toISOString(),
93
+ fileSize,
94
+ lineCount
95
+ };
96
+ const metadataPath = path.join(fullBackupPath, 'metadata.json');
97
+ await fs.writeFile(metadataPath, JSON.stringify(metadata, null, 2));
98
+ // Create revert script
99
+ const revertScriptPath = path.join(fullBackupPath, 'revert.sh');
100
+ const revertScript = `#!/bin/bash
101
+ # Auto-generated revert script for ${filePath}
102
+ set -euo pipefail
103
+
104
+ echo "Reverting: ${filePath}"
105
+ cp "${backupFilePath}" "${filePath}"
106
+ echo "✅ File reverted successfully"
107
+ `;
108
+ await fs.writeFile(revertScriptPath, revertScript, {
109
+ mode: 0o755
110
+ });
111
+ // Clean up old backups
112
+ await this.cleanOldBackups(agentId);
113
+ return {
114
+ backupPath: fullBackupPath,
115
+ timestamp: new Date().toISOString(),
116
+ fileHash,
117
+ originalPath: filePath,
118
+ metadata
119
+ };
120
+ } catch (error) {
121
+ throw new Error(`Backup creation failed for ${filePath}: ${error}`);
122
+ }
123
+ }
124
+ /**
125
+ * Revert a file from its backup
126
+ */ async revertFile(filePath, agentId) {
127
+ try {
128
+ // Find the most recent backup for this file
129
+ const backups = await this.listBackups(filePath);
130
+ if (backups.length === 0) {
131
+ throw new Error(`No backups found for ${filePath}`);
132
+ }
133
+ // Get the most recent backup
134
+ const mostRecentBackup = backups[0];
135
+ const backupedFile = path.join(mostRecentBackup.metadata.backupPath, path.basename(filePath));
136
+ // Verify backup file exists
137
+ await fs.stat(backupedFile);
138
+ // Restore file
139
+ await fs.copyFile(backupedFile, filePath);
140
+ } catch (error) {
141
+ throw new Error(`Failed to revert ${filePath}: ${error}`);
142
+ }
143
+ }
144
+ /**
145
+ * List all backups for a given file
146
+ */ async listBackups(filePath) {
147
+ try {
148
+ const backupBaseDir = path.join(this.projectRoot, this.config.backupDir);
149
+ const fileName = path.basename(filePath);
150
+ // Recursively search for backups
151
+ const backups = [];
152
+ const searchDir = async (dir)=>{
153
+ try {
154
+ const entries = await fs.readdir(dir, {
155
+ withFileTypes: true
156
+ });
157
+ for (const entry of entries){
158
+ const fullPath = path.join(dir, entry.name);
159
+ if (entry.isDirectory()) {
160
+ // Try to read metadata.json
161
+ const metadataPath = path.join(fullPath, 'metadata.json');
162
+ try {
163
+ const metadataContent = await fs.readFile(metadataPath, 'utf-8');
164
+ const metadata = JSON.parse(metadataContent);
165
+ // Check if this backup is for our file
166
+ if (metadata.originalFile === filePath) {
167
+ backups.push({
168
+ backupPath: fullPath,
169
+ timestamp: metadata.timestamp,
170
+ fileHash: metadata.fileHash,
171
+ originalPath: metadata.originalFile,
172
+ metadata
173
+ });
174
+ }
175
+ } catch {
176
+ // Not a backup directory, recurse
177
+ await searchDir(fullPath);
178
+ }
179
+ }
180
+ }
181
+ } catch (error) {
182
+ // Directory doesn't exist or other read error
183
+ return;
184
+ }
185
+ };
186
+ await searchDir(backupBaseDir);
187
+ // Sort by timestamp descending (most recent first)
188
+ return backups.sort((a, b)=>new Date(b.metadata.createdAt).getTime() - new Date(a.metadata.createdAt).getTime());
189
+ } catch {
190
+ return [];
191
+ }
192
+ }
193
+ /**
194
+ * Clean up old backups for an agent
195
+ */ async cleanOldBackups(agentId) {
196
+ try {
197
+ const backupDir = path.join(this.projectRoot, this.config.backupDir, agentId);
198
+ const retentionMs = this.config.retentionHours * 60 * 60 * 1000;
199
+ const cutoffTime = Date.now() - retentionMs;
200
+ let deletedCount = 0;
201
+ // Read agent backup directory
202
+ let entries = [];
203
+ try {
204
+ entries = await fs.readdir(backupDir);
205
+ } catch {
206
+ // Directory doesn't exist
207
+ return 0;
208
+ }
209
+ // Get backup metadata and timestamps
210
+ const backupTimestamps = [];
211
+ for (const entry of entries){
212
+ const fullPath = path.join(backupDir, entry);
213
+ const metadataPath = path.join(fullPath, 'metadata.json');
214
+ try {
215
+ const metadataContent = await fs.readFile(metadataPath, 'utf-8');
216
+ const metadata = JSON.parse(metadataContent);
217
+ const timestamp = new Date(metadata.createdAt).getTime();
218
+ backupTimestamps.push({
219
+ name: entry,
220
+ timestamp
221
+ });
222
+ } catch {
223
+ // Skip invalid backup directories
224
+ }
225
+ }
226
+ // Sort by timestamp descending
227
+ backupTimestamps.sort((a, b)=>b.timestamp - a.timestamp);
228
+ // Remove old backups (either too old or exceed max count)
229
+ for(let i = 0; i < backupTimestamps.length; i++){
230
+ const { name, timestamp } = backupTimestamps[i];
231
+ // Remove if older than retention or if exceeds max count
232
+ if (timestamp < cutoffTime || i >= this.config.maxBackups) {
233
+ const fullPath = path.join(backupDir, name);
234
+ try {
235
+ await fs.rm(fullPath, {
236
+ recursive: true,
237
+ force: true
238
+ });
239
+ deletedCount++;
240
+ } catch {
241
+ // Continue with next backup
242
+ }
243
+ }
244
+ }
245
+ return deletedCount;
246
+ } catch {
247
+ return 0;
248
+ }
249
+ }
250
+ /**
251
+ * Verify backup integrity
252
+ */ async verifyBackup(backupPath) {
253
+ try {
254
+ const metadataPath = path.join(backupPath, 'metadata.json');
255
+ const metadata = JSON.parse(await fs.readFile(metadataPath, 'utf-8'));
256
+ // Check backup file exists
257
+ const fileName = path.basename(metadata.originalFile);
258
+ const backupFilePath = path.join(backupPath, fileName);
259
+ const stat = await fs.stat(backupFilePath);
260
+ // Verify size matches metadata
261
+ if (stat.size !== metadata.fileSize) {
262
+ return false;
263
+ }
264
+ // Verify hash matches
265
+ const actualHash = await this.generateFileHash(backupFilePath);
266
+ return actualHash === metadata.fileHash;
267
+ } catch {
268
+ return false;
269
+ }
270
+ }
271
+ }
272
+
273
+ //# sourceMappingURL=backup-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/backup-manager.ts"],"sourcesContent":["/**\r\n * Backup Manager - File lifecycle backup creation and restoration\r\n * Manages pre-edit backups with metadata, hash generation, and cleanup\r\n */\r\n\r\nimport * as fs from 'fs/promises';\r\nimport * as path from 'path';\r\nimport * as crypto from 'crypto';\r\nimport { fileURLToPath } from 'url';\r\n\r\ninterface BackupConfig {\r\n retentionHours: number;\r\n maxBackups: number;\r\n backupDir: string;\r\n}\r\n\r\ninterface BackupMetadata {\r\n timestamp: string;\r\n agentId: string;\r\n originalFile: string;\r\n fileHash: string;\r\n backupPath: string;\r\n createdAt: string;\r\n fileSize: number;\r\n lineCount: number;\r\n}\r\n\r\ninterface BackupResult {\r\n backupPath: string;\r\n timestamp: string;\r\n fileHash: string;\r\n originalPath: string;\r\n metadata: BackupMetadata;\r\n}\r\n\r\nexport class BackupManager {\r\n private config: BackupConfig;\r\n private projectRoot: string;\r\n\r\n constructor(projectRoot: string = process.cwd(), config?: Partial<BackupConfig>) {\r\n this.projectRoot = projectRoot;\r\n this.config = {\r\n retentionHours: config?.retentionHours ?? 24,\r\n maxBackups: config?.maxBackups ?? 10,\r\n backupDir: config?.backupDir ?? '.backups',\r\n };\r\n }\r\n\r\n /**\r\n * Generate SHA256 hash of file content (8 char truncated)\r\n */\r\n private async generateFileHash(filePath: string): Promise<string> {\r\n try {\r\n const content = await fs.readFile(filePath);\r\n const hash = crypto.createHash('sha256').update(content).digest('hex');\r\n return hash.substring(0, 8);\r\n } catch (error) {\r\n throw new Error(`Failed to generate hash for ${filePath}: ${error}`);\r\n }\r\n }\r\n\r\n /**\r\n * Count lines in a file\r\n */\r\n private async countLines(filePath: string): Promise<number> {\r\n try {\r\n const content = await fs.readFile(filePath, 'utf-8');\r\n return content.split('\\n').length - 1; // Subtract 1 for trailing newline\r\n } catch {\r\n return 0;\r\n }\r\n }\r\n\r\n /**\r\n * Get file size in bytes\r\n */\r\n private async getFileSize(filePath: string): Promise<number> {\r\n try {\r\n const stat = await fs.stat(filePath);\r\n return stat.size;\r\n } catch {\r\n return 0;\r\n }\r\n }\r\n\r\n /**\r\n * Create a backup of a file before editing\r\n */\r\n async createBackup(filePath: string, agentId: string): Promise<BackupResult> {\r\n // Validate inputs\r\n if (!filePath) {\r\n throw new Error('File path is required');\r\n }\r\n\r\n if (!agentId) {\r\n throw new Error('Agent ID is required');\r\n }\r\n\r\n // Check if file exists\r\n try {\r\n await fs.stat(filePath);\r\n } catch {\r\n throw new Error(`File does not exist: ${filePath}`);\r\n }\r\n\r\n try {\r\n // Generate timestamp and hash\r\n const timestamp = new Date().toISOString();\r\n const fileHash = await this.generateFileHash(filePath);\r\n const unixTimestamp = Date.now();\r\n\r\n // Create backup directory structure: .backups/agent-id/timestamp_hash/\r\n const backupBaseDir = path.join(this.projectRoot, this.config.backupDir, agentId);\r\n const backupName = `${unixTimestamp}_${fileHash}`;\r\n const fullBackupPath = path.join(backupBaseDir, backupName);\r\n\r\n // Create backup directory\r\n await fs.mkdir(fullBackupPath, { recursive: true });\r\n\r\n // Copy original file to backup location\r\n const originalFileName = path.basename(filePath);\r\n const backupFilePath = path.join(fullBackupPath, originalFileName);\r\n await fs.copyFile(filePath, backupFilePath);\r\n\r\n // Gather metadata\r\n const fileSize = await this.getFileSize(filePath);\r\n const lineCount = await this.countLines(filePath);\r\n\r\n // Create metadata file\r\n const metadata: BackupMetadata = {\r\n timestamp,\r\n agentId,\r\n originalFile: filePath,\r\n fileHash,\r\n backupPath: fullBackupPath,\r\n createdAt: new Date().toISOString(),\r\n fileSize,\r\n lineCount,\r\n };\r\n\r\n const metadataPath = path.join(fullBackupPath, 'metadata.json');\r\n await fs.writeFile(metadataPath, JSON.stringify(metadata, null, 2));\r\n\r\n // Create revert script\r\n const revertScriptPath = path.join(fullBackupPath, 'revert.sh');\r\n const revertScript = `#!/bin/bash\r\n# Auto-generated revert script for ${filePath}\r\nset -euo pipefail\r\n\r\necho \"Reverting: ${filePath}\"\r\ncp \"${backupFilePath}\" \"${filePath}\"\r\necho \"✅ File reverted successfully\"\r\n`;\r\n await fs.writeFile(revertScriptPath, revertScript, { mode: 0o755 });\r\n\r\n // Clean up old backups\r\n await this.cleanOldBackups(agentId);\r\n\r\n return {\r\n backupPath: fullBackupPath,\r\n timestamp: new Date().toISOString(),\r\n fileHash,\r\n originalPath: filePath,\r\n metadata,\r\n };\r\n } catch (error) {\r\n throw new Error(`Backup creation failed for ${filePath}: ${error}`);\r\n }\r\n }\r\n\r\n /**\r\n * Revert a file from its backup\r\n */\r\n async revertFile(filePath: string, agentId: string): Promise<void> {\r\n try {\r\n // Find the most recent backup for this file\r\n const backups = await this.listBackups(filePath);\r\n if (backups.length === 0) {\r\n throw new Error(`No backups found for ${filePath}`);\r\n }\r\n\r\n // Get the most recent backup\r\n const mostRecentBackup = backups[0];\r\n const backupedFile = path.join(\r\n mostRecentBackup.metadata.backupPath,\r\n path.basename(filePath)\r\n );\r\n\r\n // Verify backup file exists\r\n await fs.stat(backupedFile);\r\n\r\n // Restore file\r\n await fs.copyFile(backupedFile, filePath);\r\n } catch (error) {\r\n throw new Error(`Failed to revert ${filePath}: ${error}`);\r\n }\r\n }\r\n\r\n /**\r\n * List all backups for a given file\r\n */\r\n async listBackups(filePath: string): Promise<BackupResult[]> {\r\n try {\r\n const backupBaseDir = path.join(this.projectRoot, this.config.backupDir);\r\n const fileName = path.basename(filePath);\r\n\r\n // Recursively search for backups\r\n const backups: BackupResult[] = [];\r\n const searchDir = async (dir: string) => {\r\n try {\r\n const entries = await fs.readdir(dir, { withFileTypes: true });\r\n\r\n for (const entry of entries) {\r\n const fullPath = path.join(dir, entry.name);\r\n\r\n if (entry.isDirectory()) {\r\n // Try to read metadata.json\r\n const metadataPath = path.join(fullPath, 'metadata.json');\r\n try {\r\n const metadataContent = await fs.readFile(metadataPath, 'utf-8');\r\n const metadata: BackupMetadata = JSON.parse(metadataContent);\r\n\r\n // Check if this backup is for our file\r\n if (metadata.originalFile === filePath) {\r\n backups.push({\r\n backupPath: fullPath,\r\n timestamp: metadata.timestamp,\r\n fileHash: metadata.fileHash,\r\n originalPath: metadata.originalFile,\r\n metadata,\r\n });\r\n }\r\n } catch {\r\n // Not a backup directory, recurse\r\n await searchDir(fullPath);\r\n }\r\n }\r\n }\r\n } catch (error) {\r\n // Directory doesn't exist or other read error\r\n return;\r\n }\r\n };\r\n\r\n await searchDir(backupBaseDir);\r\n\r\n // Sort by timestamp descending (most recent first)\r\n return backups.sort(\r\n (a, b) =>\r\n new Date(b.metadata.createdAt).getTime() -\r\n new Date(a.metadata.createdAt).getTime()\r\n );\r\n } catch {\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * Clean up old backups for an agent\r\n */\r\n async cleanOldBackups(agentId: string): Promise<number> {\r\n try {\r\n const backupDir = path.join(this.projectRoot, this.config.backupDir, agentId);\r\n const retentionMs = this.config.retentionHours * 60 * 60 * 1000;\r\n const cutoffTime = Date.now() - retentionMs;\r\n let deletedCount = 0;\r\n\r\n // Read agent backup directory\r\n let entries: string[] = [];\r\n try {\r\n entries = await fs.readdir(backupDir);\r\n } catch {\r\n // Directory doesn't exist\r\n return 0;\r\n }\r\n\r\n // Get backup metadata and timestamps\r\n const backupTimestamps: Array<{ name: string; timestamp: number }> = [];\r\n\r\n for (const entry of entries) {\r\n const fullPath = path.join(backupDir, entry);\r\n const metadataPath = path.join(fullPath, 'metadata.json');\r\n\r\n try {\r\n const metadataContent = await fs.readFile(metadataPath, 'utf-8');\r\n const metadata: BackupMetadata = JSON.parse(metadataContent);\r\n const timestamp = new Date(metadata.createdAt).getTime();\r\n\r\n backupTimestamps.push({ name: entry, timestamp });\r\n } catch {\r\n // Skip invalid backup directories\r\n }\r\n }\r\n\r\n // Sort by timestamp descending\r\n backupTimestamps.sort((a, b) => b.timestamp - a.timestamp);\r\n\r\n // Remove old backups (either too old or exceed max count)\r\n for (let i = 0; i < backupTimestamps.length; i++) {\r\n const { name, timestamp } = backupTimestamps[i];\r\n\r\n // Remove if older than retention or if exceeds max count\r\n if (timestamp < cutoffTime || i >= this.config.maxBackups) {\r\n const fullPath = path.join(backupDir, name);\r\n try {\r\n await fs.rm(fullPath, { recursive: true, force: true });\r\n deletedCount++;\r\n } catch {\r\n // Continue with next backup\r\n }\r\n }\r\n }\r\n\r\n return deletedCount;\r\n } catch {\r\n return 0;\r\n }\r\n }\r\n\r\n /**\r\n * Verify backup integrity\r\n */\r\n async verifyBackup(backupPath: string): Promise<boolean> {\r\n try {\r\n const metadataPath = path.join(backupPath, 'metadata.json');\r\n const metadata: BackupMetadata = JSON.parse(\r\n await fs.readFile(metadataPath, 'utf-8')\r\n );\r\n\r\n // Check backup file exists\r\n const fileName = path.basename(metadata.originalFile);\r\n const backupFilePath = path.join(backupPath, fileName);\r\n const stat = await fs.stat(backupFilePath);\r\n\r\n // Verify size matches metadata\r\n if (stat.size !== metadata.fileSize) {\r\n return false;\r\n }\r\n\r\n // Verify hash matches\r\n const actualHash = await this.generateFileHash(backupFilePath);\r\n return actualHash === metadata.fileHash;\r\n } catch {\r\n return false;\r\n }\r\n }\r\n}\r\n"],"names":["fs","path","crypto","BackupManager","config","projectRoot","process","cwd","retentionHours","maxBackups","backupDir","generateFileHash","filePath","content","readFile","hash","createHash","update","digest","substring","error","Error","countLines","split","length","getFileSize","stat","size","createBackup","agentId","timestamp","Date","toISOString","fileHash","unixTimestamp","now","backupBaseDir","join","backupName","fullBackupPath","mkdir","recursive","originalFileName","basename","backupFilePath","copyFile","fileSize","lineCount","metadata","originalFile","backupPath","createdAt","metadataPath","writeFile","JSON","stringify","revertScriptPath","revertScript","mode","cleanOldBackups","originalPath","revertFile","backups","listBackups","mostRecentBackup","backupedFile","fileName","searchDir","dir","entries","readdir","withFileTypes","entry","fullPath","name","isDirectory","metadataContent","parse","push","sort","a","b","getTime","retentionMs","cutoffTime","deletedCount","backupTimestamps","i","rm","force","verifyBackup","actualHash"],"mappings":"AAAA;;;CAGC,GAED,YAAYA,QAAQ,cAAc;AAClC,YAAYC,UAAU,OAAO;AAC7B,YAAYC,YAAY,SAAS;AA4BjC,OAAO,MAAMC;IACHC,OAAqB;IACrBC,YAAoB;IAE5B,YAAYA,cAAsBC,QAAQC,GAAG,EAAE,EAAEH,MAA8B,CAAE;QAC/E,IAAI,CAACC,WAAW,GAAGA;QACnB,IAAI,CAACD,MAAM,GAAG;YACZI,gBAAgBJ,QAAQI,kBAAkB;YAC1CC,YAAYL,QAAQK,cAAc;YAClCC,WAAWN,QAAQM,aAAa;QAClC;IACF;IAEA;;GAEC,GACD,MAAcC,iBAAiBC,QAAgB,EAAmB;QAChE,IAAI;YACF,MAAMC,UAAU,MAAMb,GAAGc,QAAQ,CAACF;YAClC,MAAMG,OAAOb,OAAOc,UAAU,CAAC,UAAUC,MAAM,CAACJ,SAASK,MAAM,CAAC;YAChE,OAAOH,KAAKI,SAAS,CAAC,GAAG;QAC3B,EAAE,OAAOC,OAAO;YACd,MAAM,IAAIC,MAAM,CAAC,4BAA4B,EAAET,SAAS,EAAE,EAAEQ,OAAO;QACr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