claude-flow-novice 2.15.3 → 2.15.4

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 (461) hide show
  1. package/.claude/cfn-extras/skills/advanced-features/cfn-agent-swap/recommend-swap.sh +59 -59
  2. package/.claude/cfn-extras/skills/analytics/cfn-improvement-recommender/recommend-improvements.sh +91 -91
  3. package/.claude/cfn-extras/skills/analytics/cfn-pattern-extraction/extract-patterns.sh +79 -79
  4. package/.claude/cfn-extras/skills/analytics/cfn-retrospective-report/generate-report.sh +100 -100
  5. package/.claude/cfn-extras/skills/analytics/cfn-telemetry/start-telemetry.sh +110 -110
  6. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/add-bullet.sh +145 -145
  7. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/log-merge.sh +67 -67
  8. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/monitor-injection-performance.sh +137 -137
  9. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/optimize-injection-pipeline.sh +168 -168
  10. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/query-reflections.sh +35 -35
  11. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/store-reflection.sh +45 -45
  12. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/track-ab-test.sh +41 -41
  13. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/update-reflection.sh +41 -41
  14. package/.claude/cfn-extras/skills/deprecated/cfn-cli-setup/validate-cli-environment.sh +191 -191
  15. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/create-campaign.sh +231 -231
  16. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/get-campaign-performance.sh +190 -190
  17. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/pause-campaign.sh +142 -142
  18. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/set-budget.sh +181 -181
  19. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/update-bid-strategy.sh +133 -133
  20. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/get-conversation-history.sh +121 -121
  21. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/qualify-lead.sh +156 -156
  22. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/schedule-demo.sh +181 -181
  23. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/send-message.sh +137 -137
  24. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/transfer-to-human.sh +179 -179
  25. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/create-campaign.sh +183 -183
  26. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/get-delivery-status.sh +139 -139
  27. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/opt-out.sh +150 -150
  28. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/schedule-campaign.sh +187 -187
  29. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/send-sms.sh +181 -181
  30. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/test-web-portal-skill.sh +50 -50
  31. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/validate-deployment.sh +84 -84
  32. package/.claude/cfn-extras/skills/utility/cfn-environment-sanitization/sanitize-environment.sh +243 -243
  33. package/.claude/commands/cfn-loop-cli.md +16 -2
  34. package/.claude/commands/switch-api.md +31 -10
  35. package/.claude/hooks/cfn-lint-sql-injection.sh +61 -0
  36. package/.claude/hooks/cfn-post-edit-cfn-retrospective.sh +33 -2
  37. package/.claude/hooks/cfn-pre-edit-security-warning.sh +40 -0
  38. package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +22 -24
  39. package/.claude/skills/cfn-docker-agent-spawning/SKILL.md +28 -4
  40. package/.claude/skills/cfn-docker-agent-spawning/spawn-agent.sh +3 -1
  41. package/.claude/skills/cfn-docker-loop-orchestration/orchestrate.sh +224 -20
  42. package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +550 -46
  43. package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +277 -0
  44. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +184 -23
  45. package/.claude/skills/cfn-loop-orchestration/security_utils.sh +24 -0
  46. package/.claude/skills/cfn-loop-orchestration/test-iteration-context-injection.sh +366 -0
  47. package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +319 -0
  48. package/.claude/skills/cfn-redis-coordination/agent-log.sh +4 -0
  49. package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +124 -0
  50. package/.claude/skills/cfn-redis-coordination/agent-recovery.sh +2 -2
  51. package/.claude/skills/cfn-redis-coordination/collect-confidence-scores.sh +30 -0
  52. package/.claude/skills/cfn-redis-coordination/get-context.sh +33 -0
  53. package/.claude/skills/cfn-redis-coordination/get-success-criteria.sh +54 -0
  54. package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh +3 -0
  55. package/.claude/skills/cfn-redis-coordination/redis-cli-wrapper.sh +24 -3
  56. package/.claude/skills/cfn-redis-coordination/redis-functions.sh +33 -0
  57. package/.claude/skills/cfn-redis-coordination/report-completion.sh +24 -31
  58. package/.claude/skills/cfn-redis-coordination/store-context.sh +4 -0
  59. package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +85 -0
  60. package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +67 -0
  61. package/.claude/skills/cfn-sqlite-memory/ttl-cleanup.sh +17 -25
  62. package/.claude/skills/cfn-transparency-middleware/test-e2e.sh +15 -0
  63. package/.claude/skills/cfn-transparency-middleware/tests/input-validation.sh +15 -0
  64. package/README.md +116 -475
  65. package/claude-assets/agents/cfn-dev-team/README.md +103 -0
  66. package/claude-assets/agents/cfn-dev-team/architecture/goal-planner.md +1 -1
  67. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +77 -15
  68. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +355 -6
  69. package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +82 -1
  70. package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +82 -1
  71. package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +77 -15
  72. package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +99 -12
  73. package/claude-assets/agents/cfn-dev-team/dev-ops/github-commit-agent.md +1 -1
  74. package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +97 -0
  75. package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +20 -1
  76. package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +97 -0
  77. package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +110 -13
  78. package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +106 -15
  79. package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +115 -11
  80. package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +94 -7
  81. package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +87 -9
  82. package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +85 -7
  83. package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +160 -28
  84. package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +101 -19
  85. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +108 -14
  86. package/claude-assets/agents/cfn-dev-team/reviewers/{reviewer.md → code-reviewer.md} +95 -8
  87. package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +107 -7
  88. package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +98 -7
  89. package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +95 -7
  90. package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +136 -9
  91. package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +108 -1
  92. package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +107 -13
  93. package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +737 -0
  94. package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +1 -1
  95. package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +828 -0
  96. package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +106 -7
  97. package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +77 -0
  98. package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +684 -0
  99. package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +110 -1
  100. package/claude-assets/agents/cfn-dev-team/testers/tester.md +94 -7
  101. package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +1 -3
  102. package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +87 -13
  103. package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +103 -7
  104. package/claude-assets/agents/cfn-dev-team/utility/researcher.md +1 -3
  105. package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +94 -7
  106. package/claude-assets/agents/docker-coordinators/cfn-docker-v3-coordinator.md +46 -0
  107. package/claude-assets/agents/project-only-agents/npm-package-specialist.md +1 -1
  108. package/claude-assets/cfn-extras/skills/advanced-features/cfn-agent-swap/recommend-swap.sh +59 -59
  109. package/claude-assets/cfn-extras/skills/analytics/cfn-improvement-recommender/recommend-improvements.sh +91 -91
  110. package/claude-assets/cfn-extras/skills/analytics/cfn-pattern-extraction/extract-patterns.sh +79 -79
  111. package/claude-assets/cfn-extras/skills/analytics/cfn-retrospective-report/generate-report.sh +100 -100
  112. package/claude-assets/cfn-extras/skills/analytics/cfn-telemetry/start-telemetry.sh +110 -110
  113. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/add-bullet.sh +145 -145
  114. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/log-merge.sh +67 -67
  115. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/monitor-injection-performance.sh +137 -137
  116. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/optimize-injection-pipeline.sh +168 -168
  117. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/query-reflections.sh +35 -35
  118. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/store-reflection.sh +45 -45
  119. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/track-ab-test.sh +41 -41
  120. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/update-reflection.sh +41 -41
  121. package/claude-assets/cfn-extras/skills/deprecated/cfn-cli-setup/validate-cli-environment.sh +191 -191
  122. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/create-campaign.sh +231 -231
  123. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/get-campaign-performance.sh +190 -190
  124. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/pause-campaign.sh +142 -142
  125. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/set-budget.sh +181 -181
  126. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/update-bid-strategy.sh +133 -133
  127. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/get-conversation-history.sh +121 -121
  128. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/qualify-lead.sh +156 -156
  129. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/schedule-demo.sh +181 -181
  130. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/send-message.sh +137 -137
  131. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/transfer-to-human.sh +179 -179
  132. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/create-campaign.sh +183 -183
  133. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/get-delivery-status.sh +139 -139
  134. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/opt-out.sh +150 -150
  135. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/schedule-campaign.sh +187 -187
  136. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/send-sms.sh +181 -181
  137. package/claude-assets/cfn-extras/skills/ui-portal/cfn-web-portal/test-web-portal-skill.sh +50 -50
  138. package/claude-assets/cfn-extras/skills/ui-portal/cfn-web-portal/validate-deployment.sh +84 -84
  139. package/claude-assets/cfn-extras/skills/utility/cfn-environment-sanitization/sanitize-environment.sh +243 -243
  140. package/claude-assets/commands/cfn-loop-cli.md +16 -2
  141. package/claude-assets/commands/switch-api.md +31 -10
  142. package/claude-assets/hooks/cfn-lint-sql-injection.sh +61 -0
  143. package/claude-assets/hooks/cfn-post-edit-cfn-retrospective.sh +33 -2
  144. package/claude-assets/hooks/cfn-pre-edit-security-warning.sh +40 -0
  145. package/claude-assets/hooks/detect-hardcoded-credentials.sh +212 -0
  146. package/claude-assets/skills/SKILL_TEMPLATE.md +774 -0
  147. package/claude-assets/skills/agent-lifecycle/execute-lifecycle-hook.sh +84 -113
  148. package/claude-assets/skills/agent-lifecycle/simple-audit.sh +33 -6
  149. package/claude-assets/skills/agent-template-generator/SKILL.md +440 -0
  150. package/claude-assets/skills/agent-template-generator/generate-agent.sh +405 -0
  151. package/claude-assets/skills/agent-validation-linter/SKILL.md +589 -0
  152. package/claude-assets/skills/agent-validation-linter/lint-agents.sh +271 -0
  153. package/claude-assets/skills/bootstrap/bash-fundamentals.md +786 -0
  154. package/claude-assets/skills/bootstrap/database-connection.md +464 -0
  155. package/claude-assets/skills/bootstrap/error-handling.md +580 -0
  156. package/claude-assets/skills/bootstrap/file-operations.md +699 -0
  157. package/claude-assets/skills/bootstrap/skill-loader.md +616 -0
  158. package/claude-assets/skills/bootstrap/sqlite-params.sh +287 -0
  159. package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +22 -24
  160. package/claude-assets/skills/cfn-automatic-memory-persistence/test-memory-persistence.sh +17 -16
  161. package/claude-assets/skills/cfn-deployment/SKILL.md +293 -0
  162. package/claude-assets/skills/cfn-deployment/execute.sh +21 -0
  163. package/claude-assets/skills/cfn-docker-agent-spawning/SKILL.md +28 -4
  164. package/claude-assets/skills/cfn-docker-agent-spawning/spawn-agent.sh +3 -1
  165. package/claude-assets/skills/cfn-docker-loop-orchestration/orchestrate.sh +224 -20
  166. package/claude-assets/skills/cfn-environment-sanitization/sanitize-environment.sh +38 -0
  167. package/claude-assets/skills/cfn-error-batching-strategy/lib/core-functions.sh +47 -47
  168. package/claude-assets/skills/cfn-file-operations/SKILL.md +290 -0
  169. package/claude-assets/skills/cfn-file-operations/execute.sh +129 -0
  170. package/claude-assets/skills/cfn-file-operations/lib/atomic-write.sh +294 -0
  171. package/claude-assets/skills/cfn-file-operations/lib/lock.sh +361 -0
  172. package/claude-assets/skills/cfn-file-operations/test.sh +369 -0
  173. package/claude-assets/skills/cfn-log-operations/SKILL.md +308 -0
  174. package/claude-assets/skills/cfn-log-operations/execute.sh +420 -0
  175. package/claude-assets/skills/cfn-log-operations/lib/rotate.sh +406 -0
  176. package/claude-assets/skills/cfn-log-operations/lib/search.sh +448 -0
  177. package/claude-assets/skills/cfn-log-operations/test.sh +394 -0
  178. package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +550 -46
  179. package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +277 -0
  180. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +184 -23
  181. package/claude-assets/skills/cfn-loop-orchestration/security_utils.sh +24 -0
  182. package/claude-assets/skills/cfn-loop-orchestration/test-iteration-context-injection.sh +366 -0
  183. package/claude-assets/skills/cfn-parameterized-queries/SKILL.md +339 -0
  184. package/claude-assets/skills/cfn-playbook/query-playbook.sh +19 -15
  185. package/claude-assets/skills/cfn-playbook/update-playbook.sh +25 -14
  186. package/claude-assets/skills/cfn-process-instrumentation/instrument-process.sh +44 -0
  187. package/claude-assets/skills/cfn-promotion/SKILL.md +305 -0
  188. package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +319 -0
  189. package/claude-assets/skills/cfn-redis-coordination/agent-log.sh +4 -0
  190. package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +124 -0
  191. package/claude-assets/skills/cfn-redis-coordination/agent-recovery.sh +2 -2
  192. package/claude-assets/skills/cfn-redis-coordination/collect-confidence-scores.sh +30 -0
  193. package/claude-assets/skills/cfn-redis-coordination/get-context.sh +33 -0
  194. package/claude-assets/skills/cfn-redis-coordination/get-success-criteria.sh +54 -0
  195. package/claude-assets/skills/cfn-redis-coordination/invoke-waiting-mode.sh +3 -0
  196. package/claude-assets/skills/cfn-redis-coordination/redis-cli-wrapper.sh +24 -3
  197. package/claude-assets/skills/cfn-redis-coordination/redis-functions.sh +33 -0
  198. package/claude-assets/skills/cfn-redis-coordination/report-completion.sh +24 -31
  199. package/claude-assets/skills/cfn-redis-coordination/store-context.sh +4 -0
  200. package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +85 -0
  201. package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +67 -0
  202. package/claude-assets/skills/cfn-skill-loader/SKILL.md +466 -0
  203. package/claude-assets/skills/cfn-skill-loader/execute.sh +344 -0
  204. package/claude-assets/skills/cfn-sqlite-memory/ttl-cleanup.sh +17 -25
  205. package/claude-assets/skills/cfn-task-audit/get-audit-data.sh +42 -21
  206. package/claude-assets/skills/cfn-task-audit/store-task-audit.sh +17 -10
  207. package/claude-assets/skills/cfn-test-runner/detect-regressions.sh +17 -14
  208. package/claude-assets/skills/cfn-test-runner/detect-regressions.sh.backup-1763392821 +55 -0
  209. package/claude-assets/skills/cfn-test-runner/store-benchmarks.sh +17 -19
  210. package/claude-assets/skills/cfn-transparency-middleware/test-e2e.sh +15 -0
  211. package/claude-assets/skills/cfn-transparency-middleware/tests/input-validation.sh +15 -0
  212. package/claude-assets/skills/cfn-utilities/SKILL.md +237 -0
  213. package/claude-assets/skills/cfn-utilities/execute.sh +32 -0
  214. package/claude-assets/skills/cfn-utilities/lib/errors.sh +56 -0
  215. package/claude-assets/skills/cfn-utilities/lib/file-ops.sh +164 -0
  216. package/claude-assets/skills/cfn-utilities/lib/logging.sh +77 -0
  217. package/claude-assets/skills/cfn-utilities/lib/retry.sh +127 -0
  218. package/claude-assets/skills/cfn-utilities/test.sh +317 -0
  219. package/claude-assets/skills/integration/agent-handoff.sh +62 -64
  220. package/claude-assets/skills/json-validation/SKILL.md +431 -0
  221. package/claude-assets/skills/json-validation/test-validate-success-criteria.sh +421 -0
  222. package/claude-assets/skills/json-validation/validate-success-criteria.sh +197 -0
  223. package/claude-assets/skills/redis-coordination/validate-parameters.sh +34 -0
  224. package/claude-assets/skills/workflow-codification/DEPLOY_QUICK_REFERENCE.md +106 -0
  225. package/claude-assets/skills/workflow-codification/PROPAGATE_UPDATE_QUICK_REFERENCE.md +366 -0
  226. package/claude-assets/skills/workflow-codification/deploy-approved-skill.sh +481 -0
  227. package/claude-assets/skills/workflow-codification/deploy-approved-skill.sh.backup-1763392820 +512 -0
  228. package/claude-assets/skills/workflow-codification/lib/security-utils.sh +204 -0
  229. package/claude-assets/skills/workflow-codification/propagate-skill-update.sh +648 -0
  230. package/claude-assets/skills/workflow-codification/propagate-skill-update.sh.backup-1763392820 +664 -0
  231. package/claude-assets/skills/workflow-codification/test-integration.sh +15 -0
  232. package/claude-assets/skills/workflow-codification/test-metadata-update.sh +350 -0
  233. package/claude-assets/skills/workflow-codification/track-cost-savings.sh +55 -14
  234. package/claude-assets/skills/workflow-codification/track-cost-savings.sh.backup-1763392821 +445 -0
  235. package/claude-assets/skills/workflow-codification/track-edge-case.sh +27 -60
  236. package/claude-assets/skills/workflow-codification/workflow-codification.db +0 -0
  237. package/dist/ace/ace-curator.js +10 -2
  238. package/dist/ace/ace-curator.js.map +1 -1
  239. package/dist/ace/ace-generator.js +4 -0
  240. package/dist/ace/ace-generator.js.map +1 -1
  241. package/dist/ace/ace-reflector.js +1 -1
  242. package/dist/ace/ace-reflector.js.map +1 -1
  243. package/dist/ace/context-injection.js +24 -2
  244. package/dist/ace/context-injection.js.map +1 -1
  245. package/dist/agents/agent-loader.js +146 -165
  246. package/dist/agents/agent-loader.js.map +1 -1
  247. package/dist/agents/task-agent-integration.js +1 -1
  248. package/dist/agents/task-agent-integration.js.map +1 -1
  249. package/dist/api/health-endpoints.js +390 -0
  250. package/dist/api/health-endpoints.js.map +1 -0
  251. package/dist/cli/agent-executor.js +4 -1
  252. package/dist/cli/agent-executor.js.map +1 -1
  253. package/dist/cli/agent-prompt-builder.js +89 -1
  254. package/dist/cli/agent-prompt-builder.js.map +1 -1
  255. package/dist/cli/agent-spawn.js +130 -37
  256. package/dist/cli/agent-spawn.js.map +1 -1
  257. package/dist/cli/skill-cache-validator.js +412 -0
  258. package/dist/cli/skill-cache-validator.js.map +1 -0
  259. package/dist/cli/skill-cli.js +991 -0
  260. package/dist/cli/skill-cli.js.map +1 -0
  261. package/dist/cli/skill-execution-logger.js +284 -0
  262. package/dist/cli/skill-execution-logger.js.map +1 -0
  263. package/dist/cli/skill-loader.js +457 -0
  264. package/dist/cli/skill-loader.js.map +1 -0
  265. package/dist/coordination/event-bus.js +2 -2
  266. package/dist/coordination/event-bus.js.map +1 -1
  267. package/dist/coordination/fleet-manager.js +1 -1
  268. package/dist/coordination/fleet-manager.js.map +1 -1
  269. package/dist/coordination/index.js +23 -9
  270. package/dist/coordination/index.js.map +1 -1
  271. package/dist/coordination/types/fleet-manager.types.js.map +1 -1
  272. package/dist/db/migration-manager.js +483 -0
  273. package/dist/db/migration-manager.js.map +1 -0
  274. package/dist/db/skills-query.js +535 -0
  275. package/dist/db/skills-query.js.map +1 -0
  276. package/dist/integration/DatabaseHandoff.js +1 -1
  277. package/dist/integration/DatabaseHandoff.js.map +1 -1
  278. package/dist/jobs/edge-case-analyzer.js +367 -0
  279. package/dist/jobs/edge-case-analyzer.js.map +1 -0
  280. package/dist/jobs/promotion-sla-enforcer.js +288 -0
  281. package/dist/jobs/promotion-sla-enforcer.js.map +1 -0
  282. package/dist/lib/agent-output-parser.js.map +1 -1
  283. package/dist/lib/agent-output-validator.js.map +1 -1
  284. package/dist/lib/agent-workspace.js +281 -0
  285. package/dist/lib/agent-workspace.js.map +1 -0
  286. package/dist/lib/atomic-file-writer.js +377 -0
  287. package/dist/lib/atomic-file-writer.js.map +1 -0
  288. package/dist/lib/backup-manager.js +779 -0
  289. package/dist/lib/backup-manager.js.map +1 -0
  290. package/dist/lib/checkpoint-manager.js +837 -0
  291. package/dist/lib/checkpoint-manager.js.map +1 -0
  292. package/dist/lib/circuit-breaker.js +340 -0
  293. package/dist/lib/circuit-breaker.js.map +1 -0
  294. package/dist/lib/completion-signal-handler.js +243 -0
  295. package/dist/lib/completion-signal-handler.js.map +1 -0
  296. package/dist/lib/config-manager.js +312 -0
  297. package/dist/lib/config-manager.js.map +1 -0
  298. package/dist/lib/config-migrator.js +386 -0
  299. package/dist/lib/config-migrator.js.map +1 -0
  300. package/dist/lib/config-validator.js.map +1 -1
  301. package/dist/lib/correlation-cache.js +311 -0
  302. package/dist/lib/correlation-cache.js.map +1 -0
  303. package/dist/lib/correlation.js +263 -0
  304. package/dist/lib/correlation.js.map +1 -0
  305. package/dist/lib/database-service/connection-pool-manager.js +520 -0
  306. package/dist/lib/database-service/connection-pool-manager.js.map +1 -0
  307. package/dist/lib/database-service/correlation.js +329 -0
  308. package/dist/lib/database-service/correlation.js.map +1 -0
  309. package/dist/lib/database-service/errors.js +120 -0
  310. package/dist/lib/database-service/errors.js.map +1 -0
  311. package/dist/lib/database-service/index.js +168 -0
  312. package/dist/lib/database-service/index.js.map +1 -0
  313. package/dist/lib/database-service/postgres-adapter.js +526 -0
  314. package/dist/lib/database-service/postgres-adapter.js.map +1 -0
  315. package/dist/lib/database-service/redis-adapter.js +360 -0
  316. package/dist/lib/database-service/redis-adapter.js.map +1 -0
  317. package/dist/lib/database-service/sqlite-adapter.js +544 -0
  318. package/dist/lib/database-service/sqlite-adapter.js.map +1 -0
  319. package/dist/lib/database-service/transaction-manager.js +773 -0
  320. package/dist/lib/database-service/transaction-manager.js.map +1 -0
  321. package/dist/lib/database-service/types.js +23 -0
  322. package/dist/lib/database-service/types.js.map +1 -0
  323. package/dist/lib/deadlock-resolver.js +292 -0
  324. package/dist/lib/deadlock-resolver.js.map +1 -0
  325. package/dist/lib/distributed-lock.js +451 -0
  326. package/dist/lib/distributed-lock.js.map +1 -0
  327. package/dist/lib/edge-case-deduplicator.js +227 -0
  328. package/dist/lib/edge-case-deduplicator.js.map +1 -0
  329. package/dist/lib/encryption-manager.js +322 -0
  330. package/dist/lib/encryption-manager.js.map +1 -0
  331. package/dist/lib/error-aggregator.js +234 -0
  332. package/dist/lib/error-aggregator.js.map +1 -0
  333. package/dist/lib/errors.js +287 -0
  334. package/dist/lib/errors.js.map +1 -0
  335. package/dist/lib/file-lock-manager.js +578 -0
  336. package/dist/lib/file-lock-manager.js.map +1 -0
  337. package/dist/lib/file-operations.js +367 -0
  338. package/dist/lib/file-operations.js.map +1 -0
  339. package/dist/lib/idempotent-write.js +237 -0
  340. package/dist/lib/idempotent-write.js.map +1 -0
  341. package/dist/lib/integration-schema-validator.js +522 -0
  342. package/dist/lib/integration-schema-validator.js.map +1 -0
  343. package/dist/lib/lock-health-monitor.js +298 -0
  344. package/dist/lib/lock-health-monitor.js.map +1 -0
  345. package/dist/lib/log-shipper.js +422 -0
  346. package/dist/lib/log-shipper.js.map +1 -0
  347. package/dist/lib/logging.js +146 -0
  348. package/dist/lib/logging.js.map +1 -0
  349. package/dist/lib/message-deduplicator.js +439 -0
  350. package/dist/lib/message-deduplicator.js.map +1 -0
  351. package/dist/lib/multi-system-query.js +604 -0
  352. package/dist/lib/multi-system-query.js.map +1 -0
  353. package/dist/lib/orphan-detector.js +332 -0
  354. package/dist/lib/orphan-detector.js.map +1 -0
  355. package/dist/lib/password-generator.js +166 -0
  356. package/dist/lib/password-generator.js.map +1 -0
  357. package/dist/lib/path-validator.js +429 -0
  358. package/dist/lib/path-validator.js.map +1 -0
  359. package/dist/lib/query-translator.js +905 -0
  360. package/dist/lib/query-translator.js.map +1 -0
  361. package/dist/lib/queue-recovery.js +469 -0
  362. package/dist/lib/queue-recovery.js.map +1 -0
  363. package/dist/lib/redis-queue-manager.js +512 -0
  364. package/dist/lib/redis-queue-manager.js.map +1 -0
  365. package/dist/lib/reflection-archiver.js +272 -0
  366. package/dist/lib/reflection-archiver.js.map +1 -0
  367. package/dist/lib/retry-manager.js +453 -0
  368. package/dist/lib/retry-manager.js.map +1 -0
  369. package/dist/lib/retry.js +262 -0
  370. package/dist/lib/retry.js.map +1 -0
  371. package/dist/lib/schema-transform.js +695 -0
  372. package/dist/lib/schema-transform.js.map +1 -0
  373. package/dist/lib/schema-validator.js +491 -0
  374. package/dist/lib/schema-validator.js.map +1 -0
  375. package/dist/lib/skill-cache.js +297 -0
  376. package/dist/lib/skill-cache.js.map +1 -0
  377. package/dist/lib/skill-content-manager.js +337 -0
  378. package/dist/lib/skill-content-manager.js.map +1 -0
  379. package/dist/lib/skill-frontmatter-parser.js +237 -0
  380. package/dist/lib/skill-frontmatter-parser.js.map +1 -0
  381. package/dist/lib/skill-git-integration.js +275 -0
  382. package/dist/lib/skill-git-integration.js.map +1 -0
  383. package/dist/lib/skill-markdown-validator.js +396 -0
  384. package/dist/lib/skill-markdown-validator.js.map +1 -0
  385. package/dist/lib/skill-output-parser.js +312 -0
  386. package/dist/lib/skill-output-parser.js.map +1 -0
  387. package/dist/lib/unified-query-api.js +467 -0
  388. package/dist/lib/unified-query-api.js.map +1 -0
  389. package/dist/middleware/auth-middleware.js +350 -0
  390. package/dist/middleware/auth-middleware.js.map +1 -0
  391. package/dist/middleware/schema-validation.js +347 -0
  392. package/dist/middleware/schema-validation.js.map +1 -0
  393. package/dist/providers/anthropic-provider.js +1 -1
  394. package/dist/providers/anthropic-provider.js.map +1 -1
  395. package/dist/providers/provider-factory.js +2 -2
  396. package/dist/providers/provider-factory.js.map +1 -1
  397. package/dist/services/edge-case-analyzer.js +321 -0
  398. package/dist/services/edge-case-analyzer.js.map +1 -0
  399. package/dist/services/edge-case-deduplicator.js +266 -0
  400. package/dist/services/edge-case-deduplicator.js.map +1 -0
  401. package/dist/services/edge-case-detector.js +337 -0
  402. package/dist/services/edge-case-detector.js.map +1 -0
  403. package/dist/services/edge-case-tracker.js +547 -0
  404. package/dist/services/edge-case-tracker.js.map +1 -0
  405. package/dist/services/health-check-system.js +586 -0
  406. package/dist/services/health-check-system.js.map +1 -0
  407. package/dist/services/metrics-logger.js +412 -0
  408. package/dist/services/metrics-logger.js.map +1 -0
  409. package/dist/services/patch-generator.js +378 -0
  410. package/dist/services/patch-generator.js.map +1 -0
  411. package/dist/services/patch-validator.js +337 -0
  412. package/dist/services/patch-validator.js.map +1 -0
  413. package/dist/services/performance-monitor.js +811 -0
  414. package/dist/services/performance-monitor.js.map +1 -0
  415. package/dist/services/promotion-pipeline.js +918 -0
  416. package/dist/services/promotion-pipeline.js.map +1 -0
  417. package/dist/services/promotion-validator.js +394 -0
  418. package/dist/services/promotion-validator.js.map +1 -0
  419. package/dist/services/reflection-logger.js +388 -0
  420. package/dist/services/reflection-logger.js.map +1 -0
  421. package/dist/services/skill-deployment.js +472 -0
  422. package/dist/services/skill-deployment.js.map +1 -0
  423. package/dist/services/skill-loader.js +427 -0
  424. package/dist/services/skill-loader.js.map +1 -0
  425. package/dist/services/skill-promotion.js +372 -0
  426. package/dist/services/skill-promotion.js.map +1 -0
  427. package/dist/services/skill-validator.js +454 -0
  428. package/dist/services/skill-validator.js.map +1 -0
  429. package/dist/services/skill-versioning.js +244 -0
  430. package/dist/services/skill-versioning.js.map +1 -0
  431. package/dist/services/workspace-supervisor.js +597 -0
  432. package/dist/services/workspace-supervisor.js.map +1 -0
  433. package/dist/types/edge-case.js +45 -0
  434. package/dist/types/edge-case.js.map +1 -0
  435. package/package.json +201 -177
  436. package/readme/README.md +19 -4
  437. package/scripts/backup-cleanup.sh +627 -0
  438. package/scripts/cleanup-workspaces.sh +412 -0
  439. package/scripts/cleanup-yaml-configs.sh +141 -0
  440. package/scripts/deploy-approved-skills.sh +263 -0
  441. package/scripts/health-check.sh +447 -0
  442. package/scripts/log-aggregator.sh +554 -0
  443. package/scripts/log-monitor.sh +629 -0
  444. package/scripts/manage-agent-workspaces.sh +434 -0
  445. package/scripts/migrate-schema.sh +533 -0
  446. package/scripts/promote-staged-skills.sh +423 -0
  447. package/scripts/verify-no-secrets.sh +88 -35
  448. package/.claude/cfn-extras/agents/deprecated-coordinators/adaptive-coordinator.md.backup +0 -161
  449. package/.claude/cfn-extras/agents/deprecated-coordinators/blocking-coordinator-example.md.backup +0 -728
  450. package/.claude/cfn-extras/agents/deprecated-coordinators/mesh-coordinator.md.backup +0 -131
  451. package/.claude/skills/agent-lifecycle/SKILL.md +0 -60
  452. package/.claude/skills/agent-lifecycle/execute-lifecycle-hook.sh +0 -573
  453. package/.claude/skills/agent-lifecycle/simple-audit.sh +0 -31
  454. package/.claude/skills/cfn-agent-spawning/spawn-agent.sh.backup +0 -273
  455. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.backup +0 -949
  456. package/README.md.backup_before_replace +0 -781
  457. package/claude-assets/cfn-extras/agents/deprecated-coordinators/adaptive-coordinator.md.backup +0 -161
  458. package/claude-assets/cfn-extras/agents/deprecated-coordinators/blocking-coordinator-example.md.backup +0 -728
  459. package/claude-assets/cfn-extras/agents/deprecated-coordinators/mesh-coordinator.md.backup +0 -131
  460. package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh.backup +0 -273
  461. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh.backup +0 -949
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env bash
2
+ # Retry logic with exponential backoff for CFN system
3
+
4
+ # Source logging if not already loaded
5
+ if ! declare -f log_info >/dev/null 2>&1; then
6
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
+ source "$SCRIPT_DIR/logging.sh"
8
+ fi
9
+
10
+ # Retry command with exponential backoff
11
+ # Usage: retry_with_backoff max_attempts base_delay_sec command [args...]
12
+ # Example: retry_with_backoff 3 2 curl -f https://api.example.com
13
+ retry_with_backoff() {
14
+ local max_attempts="${1:-3}"
15
+ local base_delay="${2:-2}"
16
+ shift 2
17
+ local command=("$@")
18
+
19
+ local attempt=1
20
+ local delay=$base_delay
21
+
22
+ while [ $attempt -le "$max_attempts" ]; do
23
+ log_debug "Attempt $attempt/$max_attempts: ${command[*]}" "{\"attempt\":$attempt,\"max\":$max_attempts}"
24
+
25
+ # Execute command and capture exit code immediately
26
+ "${command[@]}"
27
+ local exit_code=$?
28
+
29
+ # Check if command succeeded
30
+ if [ $exit_code -eq 0 ]; then
31
+ if [ $attempt -gt 1 ]; then
32
+ log_info "Command succeeded after retries" "{\"attempts\":$attempt,\"command\":\"${command[0]}\"}"
33
+ fi
34
+ return 0
35
+ fi
36
+
37
+ # Last attempt failed
38
+ if [ $attempt -eq "$max_attempts" ]; then
39
+ log_error "Command failed after $max_attempts attempts" "{\"command\":\"${command[0]}\",\"exit_code\":$exit_code}"
40
+ return $exit_code
41
+ fi
42
+
43
+ # Calculate next delay (exponential backoff: delay = base * 2^(attempt-1))
44
+ log_warn "Command failed, retrying in ${delay}s" "{\"attempt\":$attempt,\"delay\":$delay,\"exit_code\":$exit_code}"
45
+ sleep "$delay"
46
+
47
+ attempt=$((attempt + 1))
48
+ delay=$((delay * 2))
49
+ done
50
+
51
+ return 1
52
+ }
53
+
54
+ # Retry with fixed delay (no exponential backoff)
55
+ # Usage: retry_fixed max_attempts delay_sec command [args...]
56
+ retry_fixed() {
57
+ local max_attempts="${1:-3}"
58
+ local delay="${2:-2}"
59
+ shift 2
60
+ local command=("$@")
61
+
62
+ local attempt=1
63
+
64
+ while [ $attempt -le "$max_attempts" ]; do
65
+ log_debug "Attempt $attempt/$max_attempts: ${command[*]}" "{\"attempt\":$attempt}"
66
+
67
+ "${command[@]}"
68
+ local exit_code=$?
69
+
70
+ if [ $exit_code -eq 0 ]; then
71
+ return 0
72
+ fi
73
+
74
+ if [ $attempt -eq "$max_attempts" ]; then
75
+ log_error "Command failed after $max_attempts attempts" "{\"command\":\"${command[0]}\",\"exit_code\":$exit_code}"
76
+ return $exit_code
77
+ fi
78
+
79
+ log_warn "Command failed, retrying in ${delay}s" "{\"attempt\":$attempt,\"delay\":$delay}"
80
+ sleep "$delay"
81
+
82
+ attempt=$((attempt + 1))
83
+ done
84
+
85
+ return 1
86
+ }
87
+
88
+ # Retry until timeout (wall-clock timeout instead of attempt count)
89
+ # Usage: retry_until_timeout timeout_sec delay_sec command [args...]
90
+ retry_until_timeout() {
91
+ local timeout_sec="${1:-60}"
92
+ local delay="${2:-2}"
93
+ shift 2
94
+ local command=("$@")
95
+
96
+ local start_time
97
+ start_time=$(date +%s)
98
+ local end_time=$((start_time + timeout_sec))
99
+
100
+ local attempt=1
101
+
102
+ while [ "$(date +%s)" -lt "$end_time" ]; do
103
+ log_debug "Attempt $attempt (timeout in $((end_time - $(date +%s)))s): ${command[*]}" "{\"attempt\":$attempt}"
104
+
105
+ "${command[@]}"
106
+ local exit_code=$?
107
+
108
+ if [ $exit_code -eq 0 ]; then
109
+ return 0
110
+ fi
111
+
112
+ local current_time
113
+ current_time=$(date +%s)
114
+
115
+ if [ "$current_time" -ge "$end_time" ]; then
116
+ log_error "Command timed out after ${timeout_sec}s" "{\"command\":\"${command[0]}\",\"attempts\":$attempt,\"exit_code\":$exit_code}"
117
+ return 130 # Timeout exit code
118
+ fi
119
+
120
+ log_warn "Command failed, retrying in ${delay}s" "{\"attempt\":$attempt,\"remaining_time\":$((end_time - current_time))}"
121
+ sleep "$delay"
122
+
123
+ attempt=$((attempt + 1))
124
+ done
125
+
126
+ return 130
127
+ }
@@ -0,0 +1,317 @@
1
+ #!/usr/bin/env bash
2
+ # CFN Utilities Test Suite
3
+ # Tests all utility functions in lib/
4
+
5
+ set -euo pipefail
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ source "$SCRIPT_DIR/execute.sh"
9
+
10
+ # Test counters
11
+ TESTS_RUN=0
12
+ TESTS_PASSED=0
13
+ TESTS_FAILED=0
14
+
15
+ # Test result helpers
16
+ pass() {
17
+ echo "PASS: $1"
18
+ TESTS_PASSED=$((TESTS_PASSED + 1))
19
+ TESTS_RUN=$((TESTS_RUN + 1))
20
+ }
21
+
22
+ fail() {
23
+ echo "FAIL: $1"
24
+ TESTS_FAILED=$((TESTS_FAILED + 1))
25
+ TESTS_RUN=$((TESTS_RUN + 1))
26
+ }
27
+
28
+ assert_equals() {
29
+ local expected="$1"
30
+ local actual="$2"
31
+ local test_name="$3"
32
+
33
+ if [ "$expected" = "$actual" ]; then
34
+ pass "$test_name"
35
+ else
36
+ fail "$test_name (expected: '$expected', got: '$actual')"
37
+ fi
38
+ }
39
+
40
+ assert_contains() {
41
+ local haystack="$1"
42
+ local needle="$2"
43
+ local test_name="$3"
44
+
45
+ if [[ "$haystack" == *"$needle"* ]]; then
46
+ pass "$test_name"
47
+ else
48
+ fail "$test_name (string '$needle' not found in output)"
49
+ fi
50
+ }
51
+
52
+ assert_success() {
53
+ local test_name="$1"
54
+ pass "$test_name"
55
+ }
56
+
57
+ assert_failure() {
58
+ local test_name="$1"
59
+ fail "$test_name"
60
+ }
61
+
62
+ # Cleanup temporary test files
63
+ cleanup() {
64
+ rm -f /tmp/cfn-test-*
65
+ }
66
+ trap cleanup EXIT
67
+
68
+ echo "=== CFN Utilities Test Suite ==="
69
+ echo ""
70
+
71
+ # ===== LOGGING TESTS =====
72
+ echo "--- Testing Logging Functions ---"
73
+
74
+ # Test: log_json outputs valid JSON
75
+ output=$(log_json "info" "test message" '{"key":"value"}' 2>&1)
76
+ if echo "$output" | grep -q '"timestamp"' && echo "$output" | grep -q '"level":"info"' && echo "$output" | grep -q '"message":"test message"'; then
77
+ pass "log_json outputs valid JSON structure"
78
+ else
79
+ fail "log_json output invalid: $output"
80
+ fi
81
+
82
+ # Test: log_info outputs to stderr
83
+ output=$(log_info "info test" '{}' 2>&1 >/dev/null)
84
+ if echo "$output" | grep -q '"level":"info"'; then
85
+ pass "log_info outputs to stderr"
86
+ else
87
+ fail "log_info output incorrect"
88
+ fi
89
+
90
+ # Test: log_error includes error level
91
+ output=$(log_error "error test" '{"code":"E001"}' 2>&1)
92
+ if echo "$output" | grep -q '"level":"error"' && echo "$output" | grep -q 'E001'; then
93
+ pass "log_error includes error level and context"
94
+ else
95
+ fail "log_error output incorrect"
96
+ fi
97
+
98
+ # Test: log_debug respects LOG_LEVEL
99
+ LOG_LEVEL=info
100
+ output=$(log_debug "debug test" '{}' 2>&1)
101
+ if [ -z "$output" ]; then
102
+ pass "log_debug respects LOG_LEVEL=info (no output)"
103
+ else
104
+ fail "log_debug should not output when LOG_LEVEL=info"
105
+ fi
106
+
107
+ LOG_LEVEL=debug
108
+ output=$(log_debug "debug test" '{}' 2>&1)
109
+ if echo "$output" | grep -q '"level":"debug"'; then
110
+ pass "log_debug outputs when LOG_LEVEL=debug"
111
+ else
112
+ fail "log_debug should output when LOG_LEVEL=debug"
113
+ fi
114
+
115
+ # Test: generate_correlation_id produces output
116
+ corr_id=$(generate_correlation_id)
117
+ if [ -n "$corr_id" ]; then
118
+ pass "generate_correlation_id produces non-empty ID"
119
+ else
120
+ fail "generate_correlation_id produced empty ID"
121
+ fi
122
+
123
+ # ===== ERROR HANDLING TESTS =====
124
+ echo ""
125
+ echo "--- Testing Error Handling Functions ---"
126
+
127
+ # Test: error_handle returns error code
128
+ if error_handle "test error" '{}' 2>/dev/null; then
129
+ fail "error_handle should return non-zero exit code"
130
+ else
131
+ pass "error_handle returns non-zero exit code"
132
+ fi
133
+
134
+ # Test: is_error_code detects specific codes
135
+ EXITCODE=7
136
+ if is_error_code $EXITCODE 7; then
137
+ pass "is_error_code detects correct exit code"
138
+ else
139
+ fail "is_error_code should detect exit code 7"
140
+ fi
141
+
142
+ # Test: get_error_context returns JSON structure
143
+ test_exit_42() { return 42; }
144
+ test_exit_42 || true
145
+ context=$(get_error_context)
146
+ if echo "$context" | grep -q '"exit_code"' && echo "$context" | grep -q '"line"'; then
147
+ pass "get_error_context returns JSON structure"
148
+ else
149
+ fail "get_error_context output invalid: $context"
150
+ fi
151
+
152
+ # ===== RETRY TESTS =====
153
+ echo ""
154
+ echo "--- Testing Retry Functions ---"
155
+
156
+ # Test: retry_with_backoff succeeds on first try
157
+ counter=0
158
+ test_command() {
159
+ counter=$((counter + 1))
160
+ return 0
161
+ }
162
+ if retry_with_backoff 3 1 test_command 2>/dev/null; then
163
+ pass "retry_with_backoff succeeds immediately"
164
+ else
165
+ fail "retry_with_backoff should succeed"
166
+ fi
167
+
168
+ # Test: retry_with_backoff retries on failure
169
+ attempt_count=0
170
+ failing_command() {
171
+ attempt_count=$((attempt_count + 1))
172
+ [ $attempt_count -ge 3 ]
173
+ }
174
+ if retry_with_backoff 5 1 failing_command 2>/dev/null; then
175
+ assert_equals "3" "$attempt_count" "retry_with_backoff retries correct number of times"
176
+ else
177
+ fail "retry_with_backoff should eventually succeed"
178
+ fi
179
+
180
+ # Test: retry_with_backoff gives up after max attempts
181
+ always_fail() {
182
+ return 1
183
+ }
184
+ if retry_with_backoff 2 1 always_fail 2>/dev/null; then
185
+ fail "retry_with_backoff should fail after max attempts"
186
+ else
187
+ pass "retry_with_backoff gives up after max attempts"
188
+ fi
189
+
190
+ # Test: retry_fixed uses fixed delay
191
+ fixed_count=0
192
+ fixed_test() {
193
+ fixed_count=$((fixed_count + 1))
194
+ [ $fixed_count -ge 2 ]
195
+ }
196
+ if retry_fixed 3 1 fixed_test 2>/dev/null; then
197
+ pass "retry_fixed works with fixed delay"
198
+ else
199
+ fail "retry_fixed should succeed"
200
+ fi
201
+
202
+ # ===== FILE OPERATIONS TESTS =====
203
+ echo ""
204
+ echo "--- Testing File Operations ---"
205
+
206
+ # Test: atomic_write creates file
207
+ test_file="/tmp/cfn-test-atomic-$$"
208
+ if atomic_write "$test_file" "test content" 2>/dev/null; then
209
+ if [ -f "$test_file" ] && [ "$(cat "$test_file")" = "test content" ]; then
210
+ pass "atomic_write creates file with correct content"
211
+ else
212
+ fail "atomic_write file content incorrect"
213
+ fi
214
+ else
215
+ fail "atomic_write failed"
216
+ fi
217
+
218
+ # Test: atomic_write is actually atomic (no .tmp files left)
219
+ test_file2="/tmp/cfn-test-atomic2-$$"
220
+ atomic_write "$test_file2" "content" 2>/dev/null
221
+ if ! ls /tmp/cfn-test-atomic2-$$.tmp* 2>/dev/null; then
222
+ pass "atomic_write cleans up temporary files"
223
+ else
224
+ fail "atomic_write left temporary files"
225
+ fi
226
+
227
+ # Test: acquire_lock creates lock file
228
+ lock_file="/tmp/cfn-test-lock-$$"
229
+ if acquire_lock "$lock_file" 5 2>/dev/null; then
230
+ if [ -f "$lock_file" ] && [ "$(cat "$lock_file")" = "$$" ]; then
231
+ pass "acquire_lock creates lock file with PID"
232
+ release_lock "$lock_file" 2>/dev/null
233
+ else
234
+ fail "acquire_lock file content incorrect"
235
+ release_lock "$lock_file" 2>/dev/null
236
+ fi
237
+ else
238
+ fail "acquire_lock failed"
239
+ fi
240
+
241
+ # Test: acquire_lock blocks concurrent access
242
+ lock_file2="/tmp/cfn-test-lock2-$$"
243
+ acquire_lock "$lock_file2" 30 2>/dev/null
244
+ if acquire_lock "$lock_file2" 1 2>/dev/null; then
245
+ fail "acquire_lock should block when lock is held"
246
+ release_lock "$lock_file2" 2>/dev/null
247
+ else
248
+ pass "acquire_lock blocks concurrent access"
249
+ release_lock "$lock_file2" 2>/dev/null
250
+ fi
251
+
252
+ # Test: release_lock removes lock file
253
+ lock_file3="/tmp/cfn-test-lock3-$$"
254
+ acquire_lock "$lock_file3" 5 2>/dev/null
255
+ if release_lock "$lock_file3" 2>/dev/null; then
256
+ if [ ! -f "$lock_file3" ]; then
257
+ pass "release_lock removes lock file"
258
+ else
259
+ fail "release_lock did not remove lock file"
260
+ fi
261
+ else
262
+ fail "release_lock failed"
263
+ fi
264
+
265
+ # Test: with_lock executes command with lock
266
+ lock_file4="/tmp/cfn-test-lock4-$$"
267
+ output_file="/tmp/cfn-test-output-$$"
268
+ if with_lock "$lock_file4" 5 bash -c "echo 'locked' > $output_file" 2>/dev/null; then
269
+ if [ -f "$output_file" ] && [ "$(cat "$output_file")" = "locked" ]; then
270
+ pass "with_lock executes command successfully"
271
+ else
272
+ fail "with_lock command did not execute correctly"
273
+ fi
274
+ else
275
+ fail "with_lock failed"
276
+ fi
277
+
278
+ # Test: with_lock releases lock after execution
279
+ if [ -f "$lock_file4" ]; then
280
+ fail "with_lock did not release lock after execution"
281
+ else
282
+ pass "with_lock releases lock after execution"
283
+ fi
284
+
285
+ # Test: is_locked detects active locks
286
+ lock_file5="/tmp/cfn-test-lock5-$$"
287
+ acquire_lock "$lock_file5" 5 2>/dev/null
288
+ if is_locked "$lock_file5"; then
289
+ pass "is_locked detects active lock"
290
+ else
291
+ fail "is_locked should detect active lock"
292
+ fi
293
+ release_lock "$lock_file5" 2>/dev/null
294
+
295
+ # Test: is_locked returns false when no lock
296
+ lock_file6="/tmp/cfn-test-lock6-$$"
297
+ if is_locked "$lock_file6"; then
298
+ fail "is_locked should return false when no lock exists"
299
+ else
300
+ pass "is_locked returns false when no lock exists"
301
+ fi
302
+
303
+ # ===== SUMMARY =====
304
+ echo ""
305
+ echo "==================================="
306
+ echo "Tests run: $TESTS_RUN"
307
+ echo "Passed: $TESTS_PASSED"
308
+ echo "Failed: $TESTS_FAILED"
309
+ echo "==================================="
310
+
311
+ if [ $TESTS_FAILED -eq 0 ]; then
312
+ echo "All tests passed!"
313
+ exit 0
314
+ else
315
+ echo "Some tests failed!"
316
+ exit 1
317
+ fi
@@ -16,6 +16,11 @@
16
16
 
17
17
  set -euo pipefail
18
18
 
19
+ # Source parameterized query library for SQL injection prevention
20
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
22
+ source "$PROJECT_ROOT/.claude/skills/bootstrap/sqlite-params.sh"
23
+
19
24
  # Configuration
20
25
  AGENT_STATE_DB="${AGENT_STATE_DB:-./.claude/agents/state/agent-state.db}"
21
26
  HEARTBEAT_INTERVAL="${HEARTBEAT_INTERVAL:-30}"
@@ -132,23 +137,15 @@ agent_spawn() {
132
137
 
133
138
  log_info "Spawning agent" "{\"agent_id\":\"$agent_id\",\"agent_type\":\"$agent_type\",\"task_id\":\"$task_id\"}"
134
139
 
135
- # Register agent in database
136
- sqlite3 "$AGENT_STATE_DB" <<SQL
137
- INSERT INTO agents (
138
- agent_id, agent_type, task_id, status, spawned_at, timeout_seconds, metadata
139
- ) VALUES (
140
- '$agent_id',
141
- '$agent_type',
142
- '$task_id',
143
- 'spawned',
144
- '$(date -u +"%Y-%m-%dT%H:%M:%SZ")',
145
- $timeout_seconds,
146
- '$metadata'
147
- );
148
- SQL
140
+ # Register agent in database - using parameterized query
141
+ local spawned_timestamp
142
+ spawned_timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
143
+ sqlite_insert "$AGENT_STATE_DB" \
144
+ "INSERT INTO agents (agent_id, agent_type, task_id, status, spawned_at, timeout_seconds, metadata) VALUES (?1, ?2, ?3, 'spawned', ?4, ?5, ?6);" \
145
+ "$agent_id" "$agent_type" "$task_id" "$spawned_timestamp" "$timeout_seconds" "$metadata"
149
146
 
150
147
  # Standard agent spawn command (customizable via environment)
151
- local spawn_cmd="${AGENT_SPAWN_CMD:-npx claude-flow-novice agent-spawn}"
148
+ local spawn_cmd="${AGENT_SPAWN_CMD:-cfn-spawn agent}"
152
149
 
153
150
  # Spawn agent in background (example - replace with actual spawn mechanism)
154
151
  (
@@ -157,10 +154,10 @@ SQL
157
154
  export TASK_ID="$task_id"
158
155
  export AGENT_TYPE="$agent_type"
159
156
 
160
- # Update status to running
161
- sqlite3 "$AGENT_STATE_DB" <<SQL
162
- UPDATE agents SET status = 'running', pid = $$ WHERE agent_id = '$agent_id';
163
- SQL
157
+ # Update status to running - using parameterized query
158
+ sqlite_update "$AGENT_STATE_DB" \
159
+ "UPDATE agents SET status = 'running', pid = ?1 WHERE agent_id = ?2;" \
160
+ "$$" "$agent_id"
164
161
 
165
162
  # Start heartbeat in background
166
163
  agent_heartbeat_loop "$agent_id" "$task_id" &
@@ -186,10 +183,10 @@ SQL
186
183
 
187
184
  local agent_pid=$!
188
185
 
189
- # Update PID in database
190
- sqlite3 "$AGENT_STATE_DB" <<SQL
191
- UPDATE agents SET pid = $agent_pid WHERE agent_id = '$agent_id';
192
- SQL
186
+ # Update PID in database - using parameterized query
187
+ sqlite_update "$AGENT_STATE_DB" \
188
+ "UPDATE agents SET pid = ?1 WHERE agent_id = ?2;" \
189
+ "$agent_pid" "$agent_id"
193
190
 
194
191
  log_info "Agent spawned successfully" "{\"agent_id\":\"$agent_id\",\"pid\":$agent_pid}"
195
192
 
@@ -208,13 +205,13 @@ agent_heartbeat() {
208
205
  local timestamp
209
206
  timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
210
207
 
211
- # Update last heartbeat in agents table
212
- sqlite3 "$AGENT_STATE_DB" <<SQL
213
- UPDATE agents SET last_heartbeat = '$timestamp' WHERE agent_id = '$agent_id';
214
- INSERT INTO heartbeats (agent_id, task_id, timestamp, metadata) VALUES (
215
- '$agent_id', '$task_id', '$timestamp', '$metadata'
216
- );
217
- SQL
208
+ # Update last heartbeat in agents table - using parameterized queries
209
+ sqlite_update "$AGENT_STATE_DB" \
210
+ "UPDATE agents SET last_heartbeat = ?1 WHERE agent_id = ?2;" \
211
+ "$timestamp" "$agent_id"
212
+ sqlite_insert "$AGENT_STATE_DB" \
213
+ "INSERT INTO heartbeats (agent_id, task_id, timestamp, metadata) VALUES (?1, ?2, ?3, ?4);" \
214
+ "$agent_id" "$task_id" "$timestamp" "$metadata"
218
215
 
219
216
  log_debug "Heartbeat sent" "{\"agent_id\":\"$agent_id\",\"task_id\":\"$task_id\"}"
220
217
  }
@@ -229,9 +226,9 @@ agent_heartbeat_loop() {
229
226
  agent_heartbeat "$agent_id" "$task_id" || break
230
227
  sleep "$HEARTBEAT_INTERVAL"
231
228
 
232
- # Check if agent is still alive
229
+ # Check if agent is still alive - using parameterized query
233
230
  local status
234
- status=$(sqlite3 "$AGENT_STATE_DB" "SELECT status FROM agents WHERE agent_id = '$agent_id';" || echo "unknown")
231
+ status=$(sqlite_select "$AGENT_STATE_DB" "SELECT status FROM agents WHERE agent_id = ?1;" "$agent_id" || echo "unknown")
235
232
 
236
233
  if [[ "$status" == "completed" ]] || [[ "$status" == "failed" ]] || [[ "$status" == "timeout" ]]; then
237
234
  log_debug "Heartbeat loop stopping" "{\"agent_id\":\"$agent_id\",\"status\":\"$status\"}"
@@ -253,15 +250,10 @@ agent_complete() {
253
250
  local timestamp
254
251
  timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
255
252
 
256
- # Update agent status
257
- sqlite3 "$AGENT_STATE_DB" <<SQL
258
- UPDATE agents SET
259
- status = 'completed',
260
- completed_at = '$timestamp',
261
- confidence = $confidence,
262
- result = '$result'
263
- WHERE agent_id = '$agent_id';
264
- SQL
253
+ # Update agent status - using parameterized query
254
+ sqlite_update "$AGENT_STATE_DB" \
255
+ "UPDATE agents SET status = 'completed', completed_at = ?1, confidence = ?2, result = ?3 WHERE agent_id = ?4;" \
256
+ "$timestamp" "$confidence" "$result" "$agent_id"
265
257
 
266
258
  log_info "Agent completed" "{\"agent_id\":\"$agent_id\",\"task_id\":\"$task_id\",\"confidence\":$confidence}"
267
259
 
@@ -294,14 +286,10 @@ agent_fail() {
294
286
  EOF
295
287
  )
296
288
 
297
- sqlite3 "$AGENT_STATE_DB" <<SQL
298
- UPDATE agents SET
299
- status = 'failed',
300
- completed_at = '$timestamp',
301
- confidence = 0.0,
302
- result = '$error_result'
303
- WHERE agent_id = '$agent_id';
304
- SQL
289
+ # Update agent status for failure - using parameterized query
290
+ sqlite_update "$AGENT_STATE_DB" \
291
+ "UPDATE agents SET status = 'failed', completed_at = ?1, confidence = 0.0, result = ?2 WHERE agent_id = ?3;" \
292
+ "$timestamp" "$error_result" "$agent_id"
305
293
 
306
294
  log_error "Agent failed" "{\"agent_id\":\"$agent_id\",\"task_id\":\"$task_id\",\"error\":\"$error_message\"}"
307
295
  }
@@ -314,8 +302,9 @@ SQL
314
302
  agent_check_timeout() {
315
303
  local agent_id="$1"
316
304
 
305
+ # Get agent data - using parameterized query
317
306
  local agent_data
318
- agent_data=$(sqlite3 "$AGENT_STATE_DB" "SELECT spawned_at, timeout_seconds, status, pid FROM agents WHERE agent_id = '$agent_id';" | tr '|' ' ')
307
+ agent_data=$(sqlite_select "$AGENT_STATE_DB" "SELECT spawned_at, timeout_seconds, status, pid FROM agents WHERE agent_id = ?1;" "$agent_id" | tr '|' ' ')
319
308
 
320
309
  read -r spawned_at timeout_seconds status pid <<< "$agent_data"
321
310
 
@@ -349,14 +338,14 @@ agent_check_timeout() {
349
338
  fi
350
339
  fi
351
340
 
352
- # Mark as timeout
353
- sqlite3 "$AGENT_STATE_DB" <<SQL
354
- UPDATE agents SET
355
- status = 'timeout',
356
- completed_at = '$(date -u +"%Y-%m-%dT%H:%M:%SZ")',
357
- result = '{"error": "Agent exceeded timeout", "elapsed_seconds": $elapsed}'
358
- WHERE agent_id = '$agent_id';
359
- SQL
341
+ # Mark as timeout - using parameterized query
342
+ local timeout_timestamp
343
+ timeout_timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
344
+ local timeout_result
345
+ timeout_result="{\"error\": \"Agent exceeded timeout\", \"elapsed_seconds\": $elapsed}"
346
+ sqlite_update "$AGENT_STATE_DB" \
347
+ "UPDATE agents SET status = 'timeout', completed_at = ?1, result = ?2 WHERE agent_id = ?3;" \
348
+ "$timeout_timestamp" "$timeout_result" "$agent_id"
360
349
 
361
350
  return 1
362
351
  fi
@@ -380,9 +369,9 @@ agent_wait_for_completion() {
380
369
  start_time=$(date +%s)
381
370
 
382
371
  while true; do
383
- # Check status
372
+ # Check status - using parameterized query
384
373
  local status
385
- status=$(sqlite3 "$AGENT_STATE_DB" "SELECT status FROM agents WHERE agent_id = '$agent_id';" || echo "unknown")
374
+ status=$(sqlite_select "$AGENT_STATE_DB" "SELECT status FROM agents WHERE agent_id = ?1;" "$agent_id" || echo "unknown")
386
375
 
387
376
  if [[ "$status" == "completed" ]]; then
388
377
  log_info "Agent completed successfully" "{\"agent_id\":\"$agent_id\"}"
@@ -416,8 +405,11 @@ agent_wait_for_completion() {
416
405
  agent_get_status() {
417
406
  local agent_id="$1"
418
407
 
408
+ # Get status - using parameterized query (manual JSON mode as sqlite_select doesn't support -json flag)
419
409
  local status_json
420
- status_json=$(sqlite3 -json "$AGENT_STATE_DB" "SELECT * FROM agents WHERE agent_id = '$agent_id';" | jq '.[0]')
410
+ status_json=$(sqlite3 -json "$AGENT_STATE_DB" ".parameter init
411
+ .parameter set ?1 \"$agent_id\"
412
+ SELECT * FROM agents WHERE agent_id = ?1;" | jq '.[0]')
421
413
 
422
414
  echo "$status_json"
423
415
  }
@@ -428,8 +420,11 @@ agent_get_status() {
428
420
  agent_get_by_task() {
429
421
  local task_id="$1"
430
422
 
423
+ # Get agents by task - using parameterized query (manual JSON mode)
431
424
  local agents_json
432
- agents_json=$(sqlite3 -json "$AGENT_STATE_DB" "SELECT * FROM agents WHERE task_id = '$task_id' ORDER BY spawned_at DESC;")
425
+ agents_json=$(sqlite3 -json "$AGENT_STATE_DB" ".parameter init
426
+ .parameter set ?1 \"$task_id\"
427
+ SELECT * FROM agents WHERE task_id = ?1 ORDER BY spawned_at DESC;")
433
428
 
434
429
  echo "$agents_json"
435
430
  }
@@ -440,8 +435,11 @@ agent_get_by_task() {
440
435
  agent_get_heartbeats() {
441
436
  local agent_id="$1"
442
437
 
438
+ # Get heartbeats - using parameterized query (manual JSON mode)
443
439
  local heartbeats_json
444
- heartbeats_json=$(sqlite3 -json "$AGENT_STATE_DB" "SELECT * FROM heartbeats WHERE agent_id = '$agent_id' ORDER BY timestamp DESC LIMIT 100;")
440
+ heartbeats_json=$(sqlite3 -json "$AGENT_STATE_DB" ".parameter init
441
+ .parameter set ?1 \"$agent_id\"
442
+ SELECT * FROM heartbeats WHERE agent_id = ?1 ORDER BY timestamp DESC LIMIT 100;")
445
443
 
446
444
  echo "$heartbeats_json"
447
445
  }
@@ -477,7 +475,7 @@ CONFIGURATION:
477
475
  HEARTBEAT_INTERVAL - Heartbeat frequency in seconds (default: 30)
478
476
  COMPLETION_TIMEOUT - Default completion timeout (default: 300)
479
477
  LOG_FILE - Structured log file (default: /tmp/agent-handoff.log)
480
- AGENT_SPAWN_CMD - Agent spawn command (default: npx claude-flow-novice agent-spawn)
478
+ AGENT_SPAWN_CMD - Agent spawn command (default: cfn-spawn agent)
481
479
 
482
480
  BEFORE (Ad-hoc):
483
481
  # ❌ No correlation, no heartbeat, no timeout handling