claude-flow-novice 2.15.5 → 2.15.7

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 (540) hide show
  1. package/.claude/cfn-extras/.gs-api-quota.json +16 -0
  2. package/.claude/cfn-extras/.gs-progress-state.json +22 -0
  3. package/.claude/cfn-extras/GOOGLE_SHEETS_IMPLEMENTATION_SUMMARY.md +414 -0
  4. package/.claude/cfn-extras/agents/google-sheets/README.md +114 -0
  5. package/.claude/cfn-extras/agents/google-sheets/google-sheets-advanced-analytics-specialist.md +288 -0
  6. package/.claude/cfn-extras/agents/google-sheets/google-sheets-api-integrator.md +127 -0
  7. package/.claude/cfn-extras/agents/google-sheets/google-sheets-automation-scripting-specialist.md +195 -0
  8. package/.claude/cfn-extras/agents/google-sheets/google-sheets-business-validator.md +179 -0
  9. package/.claude/cfn-extras/agents/google-sheets/google-sheets-collaboration-security-specialist.md +240 -0
  10. package/.claude/cfn-extras/agents/google-sheets/google-sheets-coordinator.md +214 -0
  11. package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-transformer.md +127 -0
  12. package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-validation-quality-specialist.md +177 -0
  13. package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-validator.md +119 -0
  14. package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-visualization-specialist.md +135 -0
  15. package/.claude/cfn-extras/agents/google-sheets/google-sheets-design-layout-specialist.md +109 -0
  16. package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-engineer.md +127 -0
  17. package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-engineering-specialist.md +138 -0
  18. package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-validator.md +128 -0
  19. package/.claude/cfn-extras/agents/google-sheets/google-sheets-generalist.md +645 -0
  20. package/.claude/cfn-extras/agents/google-sheets/google-sheets-integration-api-specialist.md +258 -0
  21. package/.claude/cfn-extras/agents/google-sheets/google-sheets-performance-analyst.md +125 -0
  22. package/.claude/cfn-extras/agents/google-sheets/google-sheets-performance-optimization-specialist.md +211 -0
  23. package/.claude/cfn-extras/agents/google-sheets/google-sheets-schema-designer.md +130 -0
  24. package/.claude/cfn-extras/agents/google-sheets/google-sheets-template-architecture-specialist.md +259 -0
  25. package/.claude/cfn-extras/docs/GOOGLE_SHEETS_CFN_LOOP.md +617 -0
  26. package/.claude/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +453 -0
  27. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +272 -0
  28. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh +254 -0
  29. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/test.sh +174 -0
  30. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/validate.sh +98 -0
  31. package/.claude/cfn-extras/skills/google-sheets-decomposition/SKILL.md +269 -0
  32. package/.claude/cfn-extras/skills/google-sheets-decomposition/decompose.sh +313 -0
  33. package/.claude/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +237 -0
  34. package/.claude/cfn-extras/skills/google-sheets-formula-builder/build-formula.sh +220 -0
  35. package/.claude/cfn-extras/skills/google-sheets-formula-builder/test.sh +172 -0
  36. package/.claude/cfn-extras/skills/google-sheets-formula-builder/validate.sh +98 -0
  37. package/.claude/cfn-extras/skills/google-sheets-progress/SKILL.md +287 -0
  38. package/.claude/cfn-extras/skills/google-sheets-progress/test.sh +385 -0
  39. package/.claude/cfn-extras/skills/google-sheets-progress/track-progress.sh +516 -0
  40. package/.claude/cfn-extras/skills/google-sheets-progress/validate.sh +119 -0
  41. package/.claude/cfn-extras/skills/google-sheets-sprint-order/SKILL.md +277 -0
  42. package/.claude/cfn-extras/skills/google-sheets-sprint-order/order-sprints.sh +233 -0
  43. package/.claude/cfn-extras/skills/google-sheets-validation/SKILL.md +352 -0
  44. package/.claude/cfn-extras/skills/google-sheets-validation/test.sh +355 -0
  45. package/.claude/cfn-extras/skills/google-sheets-validation/validate-state.sh +374 -0
  46. package/.claude/cfn-extras/skills/google-sheets-validation/validate.sh +128 -0
  47. package/.claude/commands/cfn-context.md +10 -0
  48. package/.claude/commands/cfn-loop-cli.md +36 -15
  49. package/.claude/commands/google-sheets/google-sheets-loop.md +289 -0
  50. package/.claude/skills/cfn-agent-selector/SKILL.md +143 -0
  51. package/.claude/skills/cfn-agent-selector/select-agents.sh +94 -0
  52. package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -2
  53. package/.claude/skills/cfn-docker-agent-spawning/spawn-agent.sh +21 -2
  54. package/.claude/skills/cfn-docker-loop-orchestration/orchestrate.sh +11 -5
  55. package/.claude/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +348 -0
  56. package/.claude/skills/cfn-docker-redis-coordination/README.md +294 -0
  57. package/.claude/skills/cfn-docker-redis-coordination/jest.config.js +37 -0
  58. package/.claude/skills/cfn-docker-redis-coordination/package-lock.json +5259 -0
  59. package/.claude/skills/cfn-docker-redis-coordination/package.json +40 -0
  60. package/.claude/skills/cfn-docker-redis-coordination/src/coordinator.ts +801 -0
  61. package/.claude/skills/cfn-docker-redis-coordination/src/index.ts +42 -0
  62. package/.claude/skills/cfn-docker-redis-coordination/src/types.ts +351 -0
  63. package/.claude/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +1464 -0
  64. package/.claude/skills/cfn-docker-redis-coordination/tsconfig.json +30 -0
  65. package/.claude/skills/cfn-loop-orchestration/.eslintrc.js +56 -0
  66. package/.claude/skills/cfn-loop-orchestration/.prettierrc.json +18 -0
  67. package/.claude/skills/cfn-loop-orchestration/README.md +149 -41
  68. package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +39 -577
  69. package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +49 -270
  70. package/.claude/skills/cfn-loop-orchestration/jest.config.js +67 -0
  71. package/.claude/skills/cfn-loop-orchestration/orchestrate-wrapper.sh +268 -0
  72. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +91 -8
  73. package/.claude/skills/cfn-loop-orchestration/package-lock.json +5470 -0
  74. package/.claude/skills/cfn-loop-orchestration/package.json +49 -0
  75. package/.claude/skills/cfn-loop-orchestration/src/agent-spawner/agent-spawner.ts +34 -0
  76. package/.claude/skills/cfn-loop-orchestration/src/gate-checker/gate-checker.ts +36 -0
  77. package/.claude/skills/cfn-loop-orchestration/src/helpers/consensus.ts +87 -0
  78. package/.claude/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +115 -0
  79. package/.claude/skills/cfn-loop-orchestration/src/helpers/parse-test-results.ts +372 -0
  80. package/.claude/skills/cfn-loop-orchestration/src/index.ts +14 -0
  81. package/.claude/skills/cfn-loop-orchestration/src/orchestrator/orchestrator.ts +31 -0
  82. package/.claude/skills/cfn-loop-orchestration/src/redis/redis-coordinator.ts +72 -0
  83. package/.claude/skills/cfn-loop-orchestration/src/types.ts +188 -0
  84. package/.claude/skills/cfn-loop-orchestration/src/utils/logger.ts +32 -0
  85. package/.claude/skills/cfn-loop-orchestration/tests/consensus.test.ts +142 -0
  86. package/.claude/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +199 -0
  87. package/.claude/skills/cfn-loop-orchestration/tests/gate-check.test.ts +325 -0
  88. package/.claude/skills/cfn-loop-orchestration/tests/iteration-manager.test.ts +132 -0
  89. package/.claude/skills/cfn-loop-orchestration/tests/parse-test-results.test.ts +382 -0
  90. package/.claude/skills/cfn-loop-orchestration/tests/setup.ts +22 -0
  91. package/.claude/skills/cfn-loop-orchestration/tests/timeout-calculator.test.ts +118 -0
  92. package/.claude/skills/cfn-loop-orchestration/tests/types.test.ts +132 -0
  93. package/.claude/skills/cfn-loop-orchestration/tsconfig.json +54 -0
  94. package/.claude/skills/cfn-redis-coordination/bash-wrappers/store-context.sh +23 -0
  95. package/.claude/skills/cfn-redis-coordination/coverage/clover.xml +1447 -0
  96. package/.claude/skills/cfn-redis-coordination/coverage/coverage-final.json +13 -0
  97. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/agent-logger.ts.html +1423 -0
  98. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/agent-recovery.ts.html +1447 -0
  99. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/base.css +224 -0
  100. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/block-navigation.js +87 -0
  101. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/completion-reporter.ts.html +1273 -0
  102. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/context-manager.ts.html +1066 -0
  103. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/favicon.png +0 -0
  104. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/index.html +281 -0
  105. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/mode-detector.ts.html +550 -0
  106. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/prettify.css +1 -0
  107. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/prettify.js +2 -0
  108. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/redis-client.ts.html +2047 -0
  109. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/result-collector.ts.html +1396 -0
  110. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  111. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/sorter.js +210 -0
  112. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/swarm-manager.ts.html +1567 -0
  113. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/task-analyzer.ts.html +1297 -0
  114. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/task-executor.ts.html +1354 -0
  115. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/types.ts.html +790 -0
  116. package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/waiting-coordinator.ts.html +1846 -0
  117. package/.claude/skills/cfn-redis-coordination/coverage/lcov.info +2650 -0
  118. package/.claude/skills/cfn-redis-coordination/dist/agent-logger.d.ts +92 -0
  119. package/.claude/skills/cfn-redis-coordination/dist/agent-logger.d.ts.map +1 -0
  120. package/.claude/skills/cfn-redis-coordination/dist/agent-logger.js +329 -0
  121. package/.claude/skills/cfn-redis-coordination/dist/agent-logger.js.map +1 -0
  122. package/.claude/skills/cfn-redis-coordination/dist/agent-recovery.d.ts +75 -0
  123. package/.claude/skills/cfn-redis-coordination/dist/agent-recovery.d.ts.map +1 -0
  124. package/.claude/skills/cfn-redis-coordination/dist/agent-recovery.js +302 -0
  125. package/.claude/skills/cfn-redis-coordination/dist/agent-recovery.js.map +1 -0
  126. package/.claude/skills/cfn-redis-coordination/dist/completion-reporter.d.ts +58 -0
  127. package/.claude/skills/cfn-redis-coordination/dist/completion-reporter.d.ts.map +1 -0
  128. package/.claude/skills/cfn-redis-coordination/dist/completion-reporter.js +237 -0
  129. package/.claude/skills/cfn-redis-coordination/dist/completion-reporter.js.map +1 -0
  130. package/.claude/skills/cfn-redis-coordination/dist/context-manager.d.ts +63 -0
  131. package/.claude/skills/cfn-redis-coordination/dist/context-manager.d.ts.map +1 -0
  132. package/.claude/skills/cfn-redis-coordination/dist/context-manager.js +230 -0
  133. package/.claude/skills/cfn-redis-coordination/dist/context-manager.js.map +1 -0
  134. package/.claude/skills/cfn-redis-coordination/dist/index.d.ts +45 -0
  135. package/.claude/skills/cfn-redis-coordination/dist/index.d.ts.map +1 -0
  136. package/.claude/skills/cfn-redis-coordination/dist/index.js +114 -0
  137. package/.claude/skills/cfn-redis-coordination/dist/index.js.map +1 -0
  138. package/.claude/skills/cfn-redis-coordination/dist/mode-detector.d.ts +31 -0
  139. package/.claude/skills/cfn-redis-coordination/dist/mode-detector.d.ts.map +1 -0
  140. package/.claude/skills/cfn-redis-coordination/dist/mode-detector.js +185 -0
  141. package/.claude/skills/cfn-redis-coordination/dist/mode-detector.js.map +1 -0
  142. package/.claude/skills/cfn-redis-coordination/dist/redis-client.d.ts +191 -0
  143. package/.claude/skills/cfn-redis-coordination/dist/redis-client.d.ts.map +1 -0
  144. package/.claude/skills/cfn-redis-coordination/dist/redis-client.js +509 -0
  145. package/.claude/skills/cfn-redis-coordination/dist/redis-client.js.map +1 -0
  146. package/.claude/skills/cfn-redis-coordination/dist/result-collector.d.ts +75 -0
  147. package/.claude/skills/cfn-redis-coordination/dist/result-collector.d.ts.map +1 -0
  148. package/.claude/skills/cfn-redis-coordination/dist/result-collector.js +281 -0
  149. package/.claude/skills/cfn-redis-coordination/dist/result-collector.js.map +1 -0
  150. package/.claude/skills/cfn-redis-coordination/dist/swarm-manager.d.ts +75 -0
  151. package/.claude/skills/cfn-redis-coordination/dist/swarm-manager.d.ts.map +1 -0
  152. package/.claude/skills/cfn-redis-coordination/dist/swarm-manager.js +354 -0
  153. package/.claude/skills/cfn-redis-coordination/dist/swarm-manager.js.map +1 -0
  154. package/.claude/skills/cfn-redis-coordination/dist/task-analyzer.d.ts +62 -0
  155. package/.claude/skills/cfn-redis-coordination/dist/task-analyzer.d.ts.map +1 -0
  156. package/.claude/skills/cfn-redis-coordination/dist/task-analyzer.js +305 -0
  157. package/.claude/skills/cfn-redis-coordination/dist/task-analyzer.js.map +1 -0
  158. package/.claude/skills/cfn-redis-coordination/dist/task-executor.d.ts +97 -0
  159. package/.claude/skills/cfn-redis-coordination/dist/task-executor.d.ts.map +1 -0
  160. package/.claude/skills/cfn-redis-coordination/dist/task-executor.js +283 -0
  161. package/.claude/skills/cfn-redis-coordination/dist/task-executor.js.map +1 -0
  162. package/.claude/skills/cfn-redis-coordination/dist/types.d.ts +176 -0
  163. package/.claude/skills/cfn-redis-coordination/dist/types.d.ts.map +1 -0
  164. package/.claude/skills/cfn-redis-coordination/dist/types.js +81 -0
  165. package/.claude/skills/cfn-redis-coordination/dist/types.js.map +1 -0
  166. package/.claude/skills/cfn-redis-coordination/dist/waiting-coordinator.d.ts +86 -0
  167. package/.claude/skills/cfn-redis-coordination/dist/waiting-coordinator.d.ts.map +1 -0
  168. package/.claude/skills/cfn-redis-coordination/dist/waiting-coordinator.js +419 -0
  169. package/.claude/skills/cfn-redis-coordination/dist/waiting-coordinator.js.map +1 -0
  170. package/.claude/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +553 -0
  171. package/.claude/skills/cfn-redis-coordination/jest.config.js +23 -0
  172. package/.claude/skills/cfn-redis-coordination/package-lock.json +5272 -0
  173. package/.claude/skills/cfn-redis-coordination/package.json +45 -0
  174. package/.claude/skills/cfn-redis-coordination/redis-cli-wrapper.sh +21 -8
  175. package/.claude/skills/cfn-redis-coordination/src/agent-logger.ts +446 -0
  176. package/.claude/skills/cfn-redis-coordination/src/agent-recovery.ts +454 -0
  177. package/.claude/skills/cfn-redis-coordination/src/completion-reporter.ts +396 -0
  178. package/.claude/skills/cfn-redis-coordination/src/context-manager.ts +327 -0
  179. package/.claude/skills/cfn-redis-coordination/src/index.ts +82 -0
  180. package/.claude/skills/cfn-redis-coordination/src/mode-detector.ts +155 -0
  181. package/.claude/skills/cfn-redis-coordination/src/redis/redis-client.ts +305 -0
  182. package/.claude/skills/cfn-redis-coordination/src/redis/redis-functions.ts +283 -0
  183. package/.claude/skills/cfn-redis-coordination/src/redis-client.ts +654 -0
  184. package/.claude/skills/cfn-redis-coordination/src/result-collector.ts +437 -0
  185. package/.claude/skills/cfn-redis-coordination/src/swarm-manager.ts +494 -0
  186. package/.claude/skills/cfn-redis-coordination/src/task-analyzer.ts +404 -0
  187. package/.claude/skills/cfn-redis-coordination/src/task-executor.ts +423 -0
  188. package/.claude/skills/cfn-redis-coordination/src/types.ts +235 -0
  189. package/.claude/skills/cfn-redis-coordination/src/waiting-coordinator.ts +587 -0
  190. package/.claude/skills/cfn-redis-coordination/test-connection-attempts.js +70 -0
  191. package/.claude/skills/cfn-redis-coordination/test-mode-simple.js +121 -0
  192. package/.claude/skills/cfn-redis-coordination/test-redis-check.js +84 -0
  193. package/.claude/skills/cfn-redis-coordination/test-task-mode-redis.cjs +391 -0
  194. package/.claude/skills/cfn-redis-coordination/tests/coordination.test.ts +788 -0
  195. package/.claude/skills/cfn-redis-coordination/tsconfig.json +31 -0
  196. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +13 -72
  197. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +172 -62
  198. package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +465 -508
  199. package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +733 -743
  200. package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +13 -79
  201. package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +13 -18
  202. package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +13 -18
  203. package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +13 -18
  204. package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +15 -17
  205. package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +15 -17
  206. package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +15 -14
  207. package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +15 -17
  208. package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +15 -17
  209. package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +15 -17
  210. package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +23 -30
  211. package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +13 -18
  212. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +13 -18
  213. package/claude-assets/agents/cfn-dev-team/reviewers/code-reviewer.md +312 -317
  214. package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +23 -20
  215. package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +23 -20
  216. package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +23 -20
  217. package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +23 -20
  218. package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +16 -21
  219. package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +15 -20
  220. package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +718 -737
  221. package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +817 -828
  222. package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +15 -20
  223. package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +8 -9
  224. package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +668 -684
  225. package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +15 -20
  226. package/claude-assets/agents/cfn-dev-team/testers/tester.md +248 -253
  227. package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +13 -18
  228. package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +13 -18
  229. package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +13 -18
  230. package/claude-assets/agents/custom/cfn-redis-operations.md +530 -0
  231. package/claude-assets/agents/custom/cfn-system-expert.md +77 -0
  232. package/claude-assets/cfn-extras/.gs-api-quota.json +16 -0
  233. package/claude-assets/cfn-extras/.gs-progress-state.json +22 -0
  234. package/claude-assets/cfn-extras/GOOGLE_SHEETS_IMPLEMENTATION_SUMMARY.md +414 -0
  235. package/claude-assets/cfn-extras/agents/google-sheets/README.md +114 -0
  236. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-advanced-analytics-specialist.md +288 -0
  237. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-api-integrator.md +127 -0
  238. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-automation-scripting-specialist.md +195 -0
  239. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-business-validator.md +179 -0
  240. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-collaboration-security-specialist.md +240 -0
  241. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-coordinator.md +214 -0
  242. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-data-transformer.md +127 -0
  243. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-data-validation-quality-specialist.md +177 -0
  244. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-data-validator.md +119 -0
  245. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-data-visualization-specialist.md +135 -0
  246. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-design-layout-specialist.md +109 -0
  247. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-formula-engineer.md +127 -0
  248. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-formula-engineering-specialist.md +138 -0
  249. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-formula-validator.md +128 -0
  250. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-generalist.md +645 -0
  251. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-integration-api-specialist.md +258 -0
  252. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-performance-analyst.md +125 -0
  253. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-performance-optimization-specialist.md +211 -0
  254. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-schema-designer.md +130 -0
  255. package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-template-architecture-specialist.md +259 -0
  256. package/claude-assets/cfn-extras/docs/GOOGLE_SHEETS_CFN_LOOP.md +617 -0
  257. package/claude-assets/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +453 -0
  258. package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +272 -0
  259. package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh +254 -0
  260. package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/test.sh +174 -0
  261. package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/validate.sh +98 -0
  262. package/claude-assets/cfn-extras/skills/google-sheets-decomposition/SKILL.md +269 -0
  263. package/claude-assets/cfn-extras/skills/google-sheets-decomposition/decompose.sh +313 -0
  264. package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +237 -0
  265. package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/build-formula.sh +220 -0
  266. package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/test.sh +172 -0
  267. package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/validate.sh +98 -0
  268. package/claude-assets/cfn-extras/skills/google-sheets-progress/SKILL.md +287 -0
  269. package/claude-assets/cfn-extras/skills/google-sheets-progress/test.sh +385 -0
  270. package/claude-assets/cfn-extras/skills/google-sheets-progress/track-progress.sh +516 -0
  271. package/claude-assets/cfn-extras/skills/google-sheets-progress/validate.sh +119 -0
  272. package/claude-assets/cfn-extras/skills/google-sheets-sprint-order/SKILL.md +277 -0
  273. package/claude-assets/cfn-extras/skills/google-sheets-sprint-order/order-sprints.sh +233 -0
  274. package/claude-assets/cfn-extras/skills/google-sheets-validation/SKILL.md +352 -0
  275. package/claude-assets/cfn-extras/skills/google-sheets-validation/test.sh +355 -0
  276. package/claude-assets/cfn-extras/skills/google-sheets-validation/validate-state.sh +374 -0
  277. package/claude-assets/cfn-extras/skills/google-sheets-validation/validate.sh +128 -0
  278. package/claude-assets/commands/cfn-context.md +10 -0
  279. package/claude-assets/commands/cfn-loop-cli.md +36 -15
  280. package/claude-assets/commands/google-sheets/google-sheets-loop.md +289 -0
  281. package/claude-assets/hooks/cfn-pre-execution/SESSION_START_README.md +87 -0
  282. package/claude-assets/hooks/cfn-pre-execution/TEST_SESSION_START.md +128 -0
  283. package/claude-assets/hooks/cfn-pre-execution/session-start-context.sh +111 -0
  284. package/claude-assets/skills/cfn-agent-selection-with-fallback/INTEGRATION_EXAMPLE.md +209 -0
  285. package/claude-assets/skills/cfn-agent-selection-with-fallback/README.md +130 -0
  286. package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md +243 -0
  287. package/claude-assets/skills/cfn-agent-selection-with-fallback/agent-mappings.json +142 -0
  288. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh +173 -0
  289. package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh +71 -0
  290. package/claude-assets/skills/cfn-agent-selection-with-fallback/test-agent-selection.sh +282 -0
  291. package/claude-assets/skills/cfn-agent-selector/SKILL.md +143 -0
  292. package/claude-assets/skills/cfn-agent-selector/select-agents.sh +94 -0
  293. package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -2
  294. package/claude-assets/skills/cfn-docker-agent-spawning/spawn-agent.sh +21 -2
  295. package/claude-assets/skills/cfn-docker-coordination/.eslintrc.json +33 -0
  296. package/claude-assets/skills/cfn-docker-coordination/README.md +349 -0
  297. package/claude-assets/skills/cfn-docker-coordination/docker-helpers.sh +433 -0
  298. package/claude-assets/skills/cfn-docker-coordination/jest.config.js +25 -0
  299. package/claude-assets/skills/cfn-docker-coordination/package-lock.json +6827 -0
  300. package/claude-assets/skills/cfn-docker-coordination/package.json +38 -0
  301. package/claude-assets/skills/cfn-docker-coordination/src/agent-container.ts +471 -0
  302. package/claude-assets/skills/cfn-docker-coordination/src/docker-client.ts +483 -0
  303. package/claude-assets/skills/cfn-docker-coordination/src/health-checker.ts +418 -0
  304. package/claude-assets/skills/cfn-docker-coordination/src/index.ts +45 -0
  305. package/claude-assets/skills/cfn-docker-coordination/src/network-manager.ts +377 -0
  306. package/claude-assets/skills/cfn-docker-coordination/src/types.ts +412 -0
  307. package/claude-assets/skills/cfn-docker-coordination/src/volume-manager.ts +389 -0
  308. package/claude-assets/skills/cfn-docker-coordination/tests/agent-container.test.ts +379 -0
  309. package/claude-assets/skills/cfn-docker-coordination/tests/docker-client.test.ts +345 -0
  310. package/claude-assets/skills/cfn-docker-coordination/tests/health-checker.test.ts +535 -0
  311. package/claude-assets/skills/cfn-docker-coordination/tests/integration.test.ts +193 -0
  312. package/claude-assets/skills/cfn-docker-coordination/tests/network-manager.test.ts +352 -0
  313. package/claude-assets/skills/cfn-docker-coordination/tests/setup.ts +36 -0
  314. package/claude-assets/skills/cfn-docker-coordination/tsconfig.json +29 -0
  315. package/claude-assets/skills/cfn-docker-logging/INTEGRATION.md +268 -0
  316. package/claude-assets/skills/cfn-docker-logging/SAMPLE_OUTPUTS.md +237 -0
  317. package/claude-assets/skills/cfn-docker-logging/SKILL.md +442 -0
  318. package/claude-assets/skills/cfn-docker-logging/capture-container-logs.sh +120 -0
  319. package/claude-assets/skills/cfn-docker-logging/enable-logging.sh +430 -0
  320. package/claude-assets/skills/cfn-docker-logging/init-hybrid-logging.sh +210 -0
  321. package/claude-assets/skills/cfn-docker-logging/queries/analytics-summary.sh +87 -0
  322. package/claude-assets/skills/cfn-docker-logging/queries/query-agent-timeline.sh +51 -0
  323. package/claude-assets/skills/cfn-docker-logging/queries/query-consensus-history.sh +56 -0
  324. package/claude-assets/skills/cfn-docker-logging/queries/query-coordination-timeline.sh +39 -0
  325. package/claude-assets/skills/cfn-docker-logging/queries/query-failed-containers.sh +40 -0
  326. package/claude-assets/skills/cfn-docker-logging/queries/query-gate-checks.sh +39 -0
  327. package/claude-assets/skills/cfn-docker-logging/schema.sql +111 -0
  328. package/claude-assets/skills/cfn-docker-logging/sqlite-helpers.sh +240 -0
  329. package/claude-assets/skills/cfn-docker-logging/test-hybrid-logging.sh +331 -0
  330. package/claude-assets/skills/cfn-docker-loop-orchestration/orchestrate.sh +11 -5
  331. package/claude-assets/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +348 -0
  332. package/claude-assets/skills/cfn-docker-redis-coordination/README.md +294 -0
  333. package/claude-assets/skills/cfn-docker-redis-coordination/jest.config.js +37 -0
  334. package/claude-assets/skills/cfn-docker-redis-coordination/package-lock.json +5259 -0
  335. package/claude-assets/skills/cfn-docker-redis-coordination/package.json +40 -0
  336. package/claude-assets/skills/cfn-docker-redis-coordination/src/coordinator.ts +801 -0
  337. package/claude-assets/skills/cfn-docker-redis-coordination/src/index.ts +42 -0
  338. package/claude-assets/skills/cfn-docker-redis-coordination/src/types.ts +351 -0
  339. package/claude-assets/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +1464 -0
  340. package/claude-assets/skills/cfn-docker-redis-coordination/tsconfig.json +30 -0
  341. package/claude-assets/skills/cfn-error-logging/.eslintrc.json +57 -0
  342. package/claude-assets/skills/cfn-error-logging/.prettierrc.json +10 -0
  343. package/claude-assets/skills/cfn-error-logging/MIGRATION_SUMMARY.md +485 -0
  344. package/claude-assets/skills/cfn-error-logging/package.json +47 -0
  345. package/claude-assets/skills/cfn-error-logging/src/error-logger.ts +1042 -0
  346. package/claude-assets/skills/cfn-error-logging/src/index.ts +12 -0
  347. package/claude-assets/skills/cfn-error-logging/src/types.ts +456 -0
  348. package/claude-assets/skills/cfn-error-logging/tests/error-logger.test.ts +1302 -0
  349. package/claude-assets/skills/cfn-error-logging/tsconfig.json +38 -0
  350. package/claude-assets/skills/cfn-loop-orchestration/.eslintrc.js +56 -0
  351. package/claude-assets/skills/cfn-loop-orchestration/.prettierrc.json +18 -0
  352. package/claude-assets/skills/cfn-loop-orchestration/README.md +149 -41
  353. package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +39 -577
  354. package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +49 -270
  355. package/claude-assets/skills/cfn-loop-orchestration/jest.config.js +67 -0
  356. package/claude-assets/skills/cfn-loop-orchestration/orchestrate-wrapper.sh +268 -0
  357. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +91 -8
  358. package/claude-assets/skills/cfn-loop-orchestration/package-lock.json +5470 -0
  359. package/claude-assets/skills/cfn-loop-orchestration/package.json +49 -0
  360. package/claude-assets/skills/cfn-loop-orchestration/src/agent-spawner/agent-spawner.ts +34 -0
  361. package/claude-assets/skills/cfn-loop-orchestration/src/gate-checker/gate-checker.ts +36 -0
  362. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +115 -0
  363. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/parse-test-results.ts +372 -0
  364. package/claude-assets/skills/cfn-loop-orchestration/src/index.ts +14 -0
  365. package/claude-assets/skills/cfn-loop-orchestration/src/orchestrator/orchestrator.ts +31 -0
  366. package/claude-assets/skills/cfn-loop-orchestration/src/redis/redis-coordinator.ts +72 -0
  367. package/claude-assets/skills/cfn-loop-orchestration/src/types.ts +188 -0
  368. package/claude-assets/skills/cfn-loop-orchestration/src/utils/logger.ts +32 -0
  369. package/claude-assets/skills/cfn-loop-orchestration/tests/consensus.test.ts +142 -0
  370. package/claude-assets/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +199 -0
  371. package/claude-assets/skills/cfn-loop-orchestration/tests/gate-check.test.ts +325 -0
  372. package/claude-assets/skills/cfn-loop-orchestration/tests/iteration-manager.test.ts +132 -0
  373. package/claude-assets/skills/cfn-loop-orchestration/tests/parse-test-results.test.ts +382 -0
  374. package/claude-assets/skills/cfn-loop-orchestration/tests/setup.ts +22 -0
  375. package/claude-assets/skills/cfn-loop-orchestration/tests/timeout-calculator.test.ts +118 -0
  376. package/claude-assets/skills/cfn-loop-orchestration/tests/types.test.ts +132 -0
  377. package/claude-assets/skills/cfn-loop-orchestration/tsconfig.json +54 -0
  378. package/claude-assets/skills/cfn-redis-coordination/bash-wrappers/store-context.sh +23 -0
  379. package/claude-assets/skills/cfn-redis-coordination/coverage/clover.xml +1447 -0
  380. package/claude-assets/skills/cfn-redis-coordination/coverage/coverage-final.json +13 -0
  381. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/agent-logger.ts.html +1423 -0
  382. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/agent-recovery.ts.html +1447 -0
  383. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/base.css +224 -0
  384. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/block-navigation.js +87 -0
  385. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/completion-reporter.ts.html +1273 -0
  386. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/context-manager.ts.html +1066 -0
  387. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/favicon.png +0 -0
  388. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/index.html +281 -0
  389. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/mode-detector.ts.html +550 -0
  390. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/prettify.css +1 -0
  391. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/prettify.js +2 -0
  392. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/redis-client.ts.html +2047 -0
  393. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/result-collector.ts.html +1396 -0
  394. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  395. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/sorter.js +210 -0
  396. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/swarm-manager.ts.html +1567 -0
  397. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/task-analyzer.ts.html +1297 -0
  398. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/task-executor.ts.html +1354 -0
  399. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/types.ts.html +790 -0
  400. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/waiting-coordinator.ts.html +1846 -0
  401. package/claude-assets/skills/cfn-redis-coordination/coverage/lcov.info +2650 -0
  402. package/claude-assets/skills/cfn-redis-coordination/dist/agent-logger.d.ts +92 -0
  403. package/claude-assets/skills/cfn-redis-coordination/dist/agent-logger.d.ts.map +1 -0
  404. package/claude-assets/skills/cfn-redis-coordination/dist/agent-logger.js +329 -0
  405. package/claude-assets/skills/cfn-redis-coordination/dist/agent-logger.js.map +1 -0
  406. package/claude-assets/skills/cfn-redis-coordination/dist/agent-recovery.d.ts +75 -0
  407. package/claude-assets/skills/cfn-redis-coordination/dist/agent-recovery.d.ts.map +1 -0
  408. package/claude-assets/skills/cfn-redis-coordination/dist/agent-recovery.js +302 -0
  409. package/claude-assets/skills/cfn-redis-coordination/dist/agent-recovery.js.map +1 -0
  410. package/claude-assets/skills/cfn-redis-coordination/dist/completion-reporter.d.ts +58 -0
  411. package/claude-assets/skills/cfn-redis-coordination/dist/completion-reporter.d.ts.map +1 -0
  412. package/claude-assets/skills/cfn-redis-coordination/dist/completion-reporter.js +237 -0
  413. package/claude-assets/skills/cfn-redis-coordination/dist/completion-reporter.js.map +1 -0
  414. package/claude-assets/skills/cfn-redis-coordination/dist/context-manager.d.ts +63 -0
  415. package/claude-assets/skills/cfn-redis-coordination/dist/context-manager.d.ts.map +1 -0
  416. package/claude-assets/skills/cfn-redis-coordination/dist/context-manager.js +230 -0
  417. package/claude-assets/skills/cfn-redis-coordination/dist/context-manager.js.map +1 -0
  418. package/claude-assets/skills/cfn-redis-coordination/dist/index.d.ts +45 -0
  419. package/claude-assets/skills/cfn-redis-coordination/dist/index.d.ts.map +1 -0
  420. package/claude-assets/skills/cfn-redis-coordination/dist/index.js +114 -0
  421. package/claude-assets/skills/cfn-redis-coordination/dist/index.js.map +1 -0
  422. package/claude-assets/skills/cfn-redis-coordination/dist/mode-detector.d.ts +31 -0
  423. package/claude-assets/skills/cfn-redis-coordination/dist/mode-detector.d.ts.map +1 -0
  424. package/claude-assets/skills/cfn-redis-coordination/dist/mode-detector.js +185 -0
  425. package/claude-assets/skills/cfn-redis-coordination/dist/mode-detector.js.map +1 -0
  426. package/claude-assets/skills/cfn-redis-coordination/dist/redis-client.d.ts +191 -0
  427. package/claude-assets/skills/cfn-redis-coordination/dist/redis-client.d.ts.map +1 -0
  428. package/claude-assets/skills/cfn-redis-coordination/dist/redis-client.js +509 -0
  429. package/claude-assets/skills/cfn-redis-coordination/dist/redis-client.js.map +1 -0
  430. package/claude-assets/skills/cfn-redis-coordination/dist/result-collector.d.ts +75 -0
  431. package/claude-assets/skills/cfn-redis-coordination/dist/result-collector.d.ts.map +1 -0
  432. package/claude-assets/skills/cfn-redis-coordination/dist/result-collector.js +281 -0
  433. package/claude-assets/skills/cfn-redis-coordination/dist/result-collector.js.map +1 -0
  434. package/claude-assets/skills/cfn-redis-coordination/dist/swarm-manager.d.ts +75 -0
  435. package/claude-assets/skills/cfn-redis-coordination/dist/swarm-manager.d.ts.map +1 -0
  436. package/claude-assets/skills/cfn-redis-coordination/dist/swarm-manager.js +354 -0
  437. package/claude-assets/skills/cfn-redis-coordination/dist/swarm-manager.js.map +1 -0
  438. package/claude-assets/skills/cfn-redis-coordination/dist/task-analyzer.d.ts +62 -0
  439. package/claude-assets/skills/cfn-redis-coordination/dist/task-analyzer.d.ts.map +1 -0
  440. package/claude-assets/skills/cfn-redis-coordination/dist/task-analyzer.js +305 -0
  441. package/claude-assets/skills/cfn-redis-coordination/dist/task-analyzer.js.map +1 -0
  442. package/claude-assets/skills/cfn-redis-coordination/dist/task-executor.d.ts +97 -0
  443. package/claude-assets/skills/cfn-redis-coordination/dist/task-executor.d.ts.map +1 -0
  444. package/claude-assets/skills/cfn-redis-coordination/dist/task-executor.js +283 -0
  445. package/claude-assets/skills/cfn-redis-coordination/dist/task-executor.js.map +1 -0
  446. package/claude-assets/skills/cfn-redis-coordination/dist/types.d.ts +176 -0
  447. package/claude-assets/skills/cfn-redis-coordination/dist/types.d.ts.map +1 -0
  448. package/claude-assets/skills/cfn-redis-coordination/dist/types.js +81 -0
  449. package/claude-assets/skills/cfn-redis-coordination/dist/types.js.map +1 -0
  450. package/claude-assets/skills/cfn-redis-coordination/dist/waiting-coordinator.d.ts +86 -0
  451. package/claude-assets/skills/cfn-redis-coordination/dist/waiting-coordinator.d.ts.map +1 -0
  452. package/claude-assets/skills/cfn-redis-coordination/dist/waiting-coordinator.js +419 -0
  453. package/claude-assets/skills/cfn-redis-coordination/dist/waiting-coordinator.js.map +1 -0
  454. package/claude-assets/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +553 -0
  455. package/claude-assets/skills/cfn-redis-coordination/jest.config.js +23 -0
  456. package/claude-assets/skills/cfn-redis-coordination/package-lock.json +5272 -0
  457. package/claude-assets/skills/cfn-redis-coordination/package.json +45 -0
  458. package/claude-assets/skills/cfn-redis-coordination/redis-cli-wrapper.sh +21 -8
  459. package/claude-assets/skills/cfn-redis-coordination/src/agent-logger.ts +446 -0
  460. package/claude-assets/skills/cfn-redis-coordination/src/agent-recovery.ts +454 -0
  461. package/claude-assets/skills/cfn-redis-coordination/src/completion-reporter.ts +396 -0
  462. package/claude-assets/skills/cfn-redis-coordination/src/context-manager.ts +327 -0
  463. package/claude-assets/skills/cfn-redis-coordination/src/index.ts +82 -0
  464. package/claude-assets/skills/cfn-redis-coordination/src/mode-detector.ts +155 -0
  465. package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-client.ts +305 -0
  466. package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-functions.ts +283 -0
  467. package/claude-assets/skills/cfn-redis-coordination/src/redis-client.ts +654 -0
  468. package/claude-assets/skills/cfn-redis-coordination/src/result-collector.ts +437 -0
  469. package/claude-assets/skills/cfn-redis-coordination/src/swarm-manager.ts +494 -0
  470. package/claude-assets/skills/cfn-redis-coordination/src/task-analyzer.ts +404 -0
  471. package/claude-assets/skills/cfn-redis-coordination/src/task-executor.ts +423 -0
  472. package/claude-assets/skills/cfn-redis-coordination/src/types.ts +235 -0
  473. package/claude-assets/skills/cfn-redis-coordination/src/waiting-coordinator.ts +587 -0
  474. package/claude-assets/skills/cfn-redis-coordination/test-connection-attempts.js +70 -0
  475. package/claude-assets/skills/cfn-redis-coordination/test-mode-simple.js +121 -0
  476. package/claude-assets/skills/cfn-redis-coordination/test-redis-check.js +84 -0
  477. package/claude-assets/skills/cfn-redis-coordination/test-task-mode-redis.cjs +391 -0
  478. package/claude-assets/skills/cfn-redis-coordination/tests/coordination.test.ts +788 -0
  479. package/claude-assets/skills/cfn-redis-coordination/tsconfig.json +31 -0
  480. package/claude-assets/skills/cfn-skill-propagation/README.md +233 -0
  481. package/claude-assets/skills/cfn-skill-propagation/package-lock.json +5174 -0
  482. package/claude-assets/skills/cfn-skill-propagation/package.json +52 -0
  483. package/claude-assets/skills/cfn-skill-propagation/propagate-skill-update.sh +32 -0
  484. package/claude-assets/skills/cfn-skill-propagation/src/cli.ts +75 -0
  485. package/claude-assets/skills/cfn-skill-propagation/src/database-adapter.ts +239 -0
  486. package/claude-assets/skills/cfn-skill-propagation/src/file-system-adapter.ts +113 -0
  487. package/claude-assets/skills/cfn-skill-propagation/src/index.ts +72 -0
  488. package/claude-assets/skills/cfn-skill-propagation/src/logger.ts +43 -0
  489. package/claude-assets/skills/cfn-skill-propagation/src/metadata-parser.ts +154 -0
  490. package/claude-assets/skills/cfn-skill-propagation/src/skill-propagator.ts +274 -0
  491. package/claude-assets/skills/cfn-skill-propagation/src/skill-validator.ts +179 -0
  492. package/claude-assets/skills/cfn-skill-propagation/src/types.ts +143 -0
  493. package/claude-assets/skills/cfn-skill-propagation/src/version-manager.ts +118 -0
  494. package/claude-assets/skills/cfn-skill-propagation/tests/file-system-adapter.test.ts +91 -0
  495. package/claude-assets/skills/cfn-skill-propagation/tests/metadata-parser.test.ts +176 -0
  496. package/claude-assets/skills/cfn-skill-propagation/tests/skill-propagator.test.ts +209 -0
  497. package/claude-assets/skills/cfn-skill-propagation/tests/skill-validator.test.ts +203 -0
  498. package/claude-assets/skills/cfn-skill-propagation/tests/version-manager.test.ts +115 -0
  499. package/claude-assets/skills/cfn-skill-propagation/tsconfig.json +34 -0
  500. package/claude-assets/skills/task-classifier/SKILL.md +81 -0
  501. package/claude-assets/skills/task-classifier/classify-task.sh +62 -0
  502. package/claude-assets/skills/workflow-codification/package-lock.json +5170 -0
  503. package/claude-assets/skills/workflow-codification/package.json +30 -0
  504. package/claude-assets/skills/workflow-codification/src/index.ts +24 -0
  505. package/claude-assets/skills/workflow-codification/src/pattern-analyzer.ts +537 -0
  506. package/claude-assets/skills/workflow-codification/src/types.ts +180 -0
  507. package/claude-assets/skills/workflow-codification/tests/pattern-analyzer.test.ts +960 -0
  508. package/claude-assets/skills/workflow-codification/tsconfig.json +34 -0
  509. package/claude-assets/skills/workflow-codification/workflow-codification.db +0 -0
  510. package/dist/agent-spawner/agent-spawner.js +448 -0
  511. package/dist/agent-spawner/agent-spawner.js.map +1 -0
  512. package/dist/agent-spawner/index.js +10 -0
  513. package/dist/agent-spawner/index.js.map +1 -0
  514. package/dist/agent-spawner/types.js +14 -0
  515. package/dist/agent-spawner/types.js.map +1 -0
  516. package/dist/cli/agent-executor.js +47 -1
  517. package/dist/cli/agent-executor.js.map +1 -1
  518. package/dist/cli/agent-spawn.js +4 -1
  519. package/dist/cli/agent-spawn.js.map +1 -1
  520. package/dist/cli/config-manager.js +91 -109
  521. package/dist/cli/config-manager.js.map +1 -1
  522. package/dist/cli/tool-executor.js +3 -1
  523. package/dist/cli/tool-executor.js.map +1 -1
  524. package/dist/gate-checker/gate-checker.js +292 -0
  525. package/dist/gate-checker/gate-checker.js.map +1 -0
  526. package/dist/gate-checker/types.js +94 -0
  527. package/dist/gate-checker/types.js.map +1 -0
  528. package/dist/lib/database-service/connection-pool-manager.js +2 -1
  529. package/dist/lib/database-service/connection-pool-manager.js.map +1 -1
  530. package/dist/orchestrator/index.js +10 -0
  531. package/dist/orchestrator/index.js.map +1 -0
  532. package/dist/orchestrator/orchestrate.js +496 -0
  533. package/dist/orchestrator/orchestrate.js.map +1 -0
  534. package/dist/orchestrator/types.js +58 -0
  535. package/dist/orchestrator/types.js.map +1 -0
  536. package/package.json +1 -1
  537. package/scripts/clean-agent-profiles.sh +112 -0
  538. package/scripts/switch-api.sh +142 -4
  539. package/scripts/verify-no-secrets.sh +6 -13
  540. package/tests/README.md +175 -58
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/gate-checker/types.ts"],"sourcesContent":["/**\r\n * Gate Checker Type Definitions\r\n *\r\n * Core types and interfaces for the CFN Loop gate checking system including:\r\n * - Test result tracking\r\n * - Pass rate calculations\r\n * - Gate validation and thresholds\r\n * - Execution modes and strategies\r\n * - Error handling\r\n *\r\n * @module gate-checker/types\r\n */\r\n\r\n// ===== EXECUTION MODE TYPES =====\r\n\r\nexport type ExecutionMode = 'mvp' | 'standard' | 'enterprise';\r\n\r\nexport type GateCheckStrategy = 'test-driven' | 'confidence' | 'auto';\r\n\r\n// ===== TEST RESULT TYPES =====\r\n\r\n/**\r\n * Individual test result from a test suite execution\r\n */\r\nexport interface TestResult {\r\n pass_rate: number; // 0.0 to 1.0\r\n passed: number; // Number of passed tests\r\n failed: number; // Number of failed tests\r\n total: number; // Total number of tests\r\n status: 'success' | 'timeout' | 'parse_error' | 'failure' | 'parsed';\r\n}\r\n\r\n/**\r\n * Test suite definition from success criteria\r\n */\r\nexport interface TestSuite {\r\n name: string;\r\n command: string;\r\n timeout?: number; // Timeout in seconds\r\n framework?: string; // Test framework (jest, pytest, mocha, etc.)\r\n required?: boolean; // Whether this test suite is required for gate to pass\r\n}\r\n\r\n/**\r\n * Success criteria containing test suites and thresholds\r\n */\r\nexport interface SuccessCriteria {\r\n test_suites: TestSuite[];\r\n mode?: ExecutionMode;\r\n description?: string;\r\n}\r\n\r\n// ===== GATE RESULT TYPES =====\r\n\r\n/**\r\n * Result of gate check validation\r\n */\r\nexport interface GateResult {\r\n passed: boolean;\r\n pass_rate: number;\r\n threshold: number;\r\n mode: ExecutionMode;\r\n gap?: number; // threshold - pass_rate when gate fails\r\n test_results: TestResult[];\r\n failed_suites: string[]; // Names of failed test suites\r\n execution_time_ms: number;\r\n timestamp: number;\r\n}\r\n\r\n/**\r\n * Context for iteration when gate fails\r\n */\r\nexport interface IterationContext {\r\n gate_status: 'failed' | 'passed';\r\n pass_rate: number;\r\n threshold: number;\r\n gap?: number;\r\n failed_tests: TestResult[];\r\n recommendations: string[];\r\n}\r\n\r\n// ===== QUORUM & CONSENSUS TYPES =====\r\n\r\nexport type QuorumFormat = 'count' | 'percentage' | 'ratio';\r\n\r\n/**\r\n * Parsed quorum specification\r\n */\r\nexport interface QuorumSpec {\r\n format: QuorumFormat;\r\n value: number;\r\n}\r\n\r\n/**\r\n * Confidence-based gate result (legacy)\r\n */\r\nexport interface ConfidenceGateResult {\r\n consensus: number; // Consensus score 0.0 to 1.0\r\n threshold: number;\r\n passed: boolean;\r\n gap?: number;\r\n}\r\n\r\n// ===== VALIDATION ERROR TYPES =====\r\n\r\nexport class GateCheckError extends Error {\r\n constructor(\r\n message: string,\r\n public code: string,\r\n public metadata?: Record<string, unknown>\r\n ) {\r\n super(message);\r\n this.name = 'GateCheckError';\r\n }\r\n}\r\n\r\nexport class ValidationError extends GateCheckError {\r\n constructor(message: string, metadata?: Record<string, unknown>) {\r\n super(message, 'VALIDATION_ERROR', metadata);\r\n this.name = 'ValidationError';\r\n }\r\n}\r\n\r\nexport class SecurityError extends GateCheckError {\r\n constructor(message: string, metadata?: Record<string, unknown>) {\r\n super(message, 'SECURITY_ERROR', metadata);\r\n this.name = 'SecurityError';\r\n }\r\n}\r\n\r\nexport class TimeoutError extends GateCheckError {\r\n constructor(message: string, metadata?: Record<string, unknown>) {\r\n super(message, 'TIMEOUT_ERROR', metadata);\r\n this.name = 'TimeoutError';\r\n }\r\n}\r\n\r\n// ===== SECURITY CONSTRAINT TYPES =====\r\n\r\nexport interface SecurityConstraints {\r\n maxTestSuites: number; // Maximum number of test suites allowed\r\n maxFieldLength: number; // Maximum length for field names\r\n passThresholdMin: number; // Minimum value for pass threshold\r\n passThresholdMax: number; // Maximum value for pass threshold\r\n timeoutMin: number; // Minimum timeout in seconds\r\n timeoutMax: number; // Maximum timeout in seconds\r\n maxTotalTime: number; // Maximum total execution time in seconds\r\n}\r\n\r\n// ===== AGGREGATE RESULTS TYPES =====\r\n\r\n/**\r\n * Aggregated pass rate from multiple test results\r\n */\r\nexport interface AggregatePassRate {\r\n total_passed: number;\r\n total_tests: number;\r\n pass_rate: number;\r\n results: TestResult[];\r\n}\r\n\r\n// ===== TYPE GUARDS =====\r\n\r\n/**\r\n * Type guard to check if a value is a valid TestResult\r\n */\r\nexport function isValidTestResult(value: unknown): value is TestResult {\r\n if (typeof value !== 'object' || value === null) {\r\n return false;\r\n }\r\n\r\n const result = value as Record<string, unknown>;\r\n const validStatuses = ['success', 'timeout', 'parse_error', 'failure', 'parsed'];\r\n return (\r\n typeof result.pass_rate === 'number' &&\r\n typeof result.passed === 'number' &&\r\n typeof result.failed === 'number' &&\r\n typeof result.total === 'number' &&\r\n typeof result.status === 'string' &&\r\n result.pass_rate >= 0 &&\r\n result.pass_rate <= 1 &&\r\n result.passed >= 0 &&\r\n result.failed >= 0 &&\r\n result.total >= 0 &&\r\n validStatuses.indexOf(result.status as string) !== -1\r\n );\r\n}\r\n\r\n/**\r\n * Type guard to check if a value is a valid SuccessCriteria\r\n */\r\nexport function isValidSuccessCriteria(value: unknown): value is SuccessCriteria {\r\n if (typeof value !== 'object' || value === null) {\r\n return false;\r\n }\r\n\r\n const criteria = value as Record<string, unknown>;\r\n return (\r\n Array.isArray(criteria.test_suites) &&\r\n criteria.test_suites.length > 0 &&\r\n criteria.test_suites.every(suite => isValidTestSuite(suite))\r\n );\r\n}\r\n\r\n/**\r\n * Type guard to check if a value is a valid TestSuite\r\n */\r\nexport function isValidTestSuite(value: unknown): value is TestSuite {\r\n if (typeof value !== 'object' || value === null) {\r\n return false;\r\n }\r\n\r\n const suite = value as Record<string, unknown>;\r\n return (\r\n typeof suite.name === 'string' &&\r\n typeof suite.command === 'string' &&\r\n (suite.timeout === undefined || typeof suite.timeout === 'number') &&\r\n (suite.framework === undefined || typeof suite.framework === 'string') &&\r\n (suite.required === undefined || typeof suite.required === 'boolean')\r\n );\r\n}\r\n\r\n/**\r\n * Type guard to check if a value is a valid ExecutionMode\r\n */\r\nexport function isValidExecutionMode(value: unknown): value is ExecutionMode {\r\n return value === 'mvp' || value === 'standard' || value === 'enterprise';\r\n}\r\n\r\n/**\r\n * Type guard to check if a value is a valid GateCheckStrategy\r\n */\r\nexport function isValidGateCheckStrategy(value: unknown): value is GateCheckStrategy {\r\n return value === 'test-driven' || value === 'confidence' || value === 'auto';\r\n}\r\n\r\n// ===== EXPORTS =====\r\n\r\nexport default {\r\n isValidTestResult,\r\n isValidSuccessCriteria,\r\n isValidTestSuite,\r\n isValidExecutionMode,\r\n isValidGateCheckStrategy,\r\n};\r\n"],"names":["GateCheckError","Error","message","code","metadata","name","ValidationError","SecurityError","TimeoutError","isValidTestResult","value","result","validStatuses","pass_rate","passed","failed","total","status","indexOf","isValidSuccessCriteria","criteria","Array","isArray","test_suites","length","every","suite","isValidTestSuite","command","timeout","undefined","framework","required","isValidExecutionMode","isValidGateCheckStrategy"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,mCAAmC;AA0FnC,qCAAqC;AAErC,OAAO,MAAMA,uBAAuBC;;;IAClC,YACEC,OAAe,EACf,AAAOC,IAAY,EACnB,AAAOC,QAAkC,CACzC;QACA,KAAK,CAACF,eAHCC,OAAAA,WACAC,WAAAA;QAGP,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMC,wBAAwBN;IACnC,YAAYE,OAAe,EAAEE,QAAkC,CAAE;QAC/D,KAAK,CAACF,SAAS,oBAAoBE;QACnC,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAME,sBAAsBP;IACjC,YAAYE,OAAe,EAAEE,QAAkC,CAAE;QAC/D,KAAK,CAACF,SAAS,kBAAkBE;QACjC,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMG,qBAAqBR;IAChC,YAAYE,OAAe,EAAEE,QAAkC,CAAE;QAC/D,KAAK,CAACF,SAAS,iBAAiBE;QAChC,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AA0BA,0BAA0B;AAE1B;;CAEC,GACD,OAAO,SAASI,kBAAkBC,KAAc;IAC9C,IAAI,OAAOA,UAAU,YAAYA,UAAU,MAAM;QAC/C,OAAO;IACT;IAEA,MAAMC,SAASD;IACf,MAAME,gBAAgB;QAAC;QAAW;QAAW;QAAe;QAA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KAAc;IACrD,OAAOA,UAAU,iBAAiBA,UAAU,gBAAgBA,UAAU;AACxE;AAEA,sBAAsB;AAEtB,eAAe;IACbD;IACAU;IACAQ;IACAM;IACAC;AACF,EAAE"}
@@ -103,7 +103,7 @@ import { createDatabaseError } from './errors.js';
103
103
  const host = this.config.host || 'localhost';
104
104
  const port = this.config.port || 6379;
105
105
  if (this.config.password) {
106
- // Include password in connection string: redis://:password@host:port
106
+ // Include password in connection string (credentials from environment)
107
107
  url = `redis://:${encodeURIComponent(this.config.password)}@${host}:${port}`;
108
108
  } else {
109
109
  url = `redis://${host}:${port}`;
@@ -136,6 +136,7 @@ import { createDatabaseError } from './errors.js';
136
136
  * Initialize PostgreSQL connection pool
137
137
  */ async initializePostgresPool() {
138
138
  const connectionString = this.config.connectionString || `postgresql://${this.config.username}:${this.config.password}@${this.config.host}:${this.config.port}/${this.config.database}`;
139
+ // Note: credentials come from config object (typically loaded from environment variables)
139
140
  this.pool = new Pool({
140
141
  connectionString,
141
142
  min: this.options.minConnections,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/database-service/connection-pool-manager.ts"],"sourcesContent":["/**\r\n * Connection Pool Manager\r\n *\r\n * Manages connection pools for database adapters with:\r\n * - Automatic initialization on service startup\r\n * - Connection health checks (ping every 30s)\r\n * - Automatic reconnection with exponential backoff\r\n * - Connection metrics (active, idle, pending)\r\n * - Graceful degradation on connection failures\r\n *\r\n * Part of Bug Fix: Connection Pool Initialization\r\n */\r\n\r\nimport sqlite3 from 'sqlite3';\r\nimport { open, Database } from 'sqlite';\r\nimport { createClient, RedisClientType } from 'redis';\r\nimport { Pool, PoolClient } from 'pg';\r\nimport {\r\n DatabaseConfig,\r\n DatabaseErrorCode,\r\n} from './types.js';\r\nimport { createDatabaseError } from './errors.js';\r\n\r\nexport interface ConnectionPoolStats {\r\n type: 'redis' | 'sqlite' | 'postgres';\r\n total: number;\r\n active: number;\r\n idle: number;\r\n pending: number;\r\n maxConnections: number;\r\n available: number;\r\n healthy: boolean;\r\n lastHealthCheck?: Date;\r\n healthCheckActive: boolean;\r\n reconnectAttempts: number;\r\n failedAttempts: number;\r\n uptime: number;\r\n}\r\n\r\nexport interface PoolOptions {\r\n minConnections?: number;\r\n maxConnections?: number;\r\n acquireTimeout?: number;\r\n idleTimeout?: number;\r\n healthCheckInterval?: number;\r\n maxReconnectAttempts?: number;\r\n reconnectBaseDelay?: number;\r\n}\r\n\r\n/**\r\n * Connection Pool Manager\r\n *\r\n * Manages connection lifecycle, health checks, and automatic recovery\r\n */\r\nexport class ConnectionPoolManager {\r\n private config: DatabaseConfig;\r\n private options: Required<PoolOptions>;\r\n private pool: any = null;\r\n private connections: Set<any> = new Set();\r\n private activeConnections: Set<any> = new Set();\r\n private pendingRequests: Array<{\r\n resolve: (connection: any) => void;\r\n reject: (error: Error) => void;\r\n timestamp: number;\r\n }> = [];\r\n private healthCheckInterval?: NodeJS.Timeout;\r\n private lastHealthCheck?: Date;\r\n private healthCheckActive: boolean = false;\r\n private reconnectAttempts: number = 0;\r\n private maxReconnectAttempts: number = 10;\r\n private failedAttempts: number = 0;\r\n private startTime: Date;\r\n private isShuttingDown: boolean = false;\r\n private cacheFallbackEnabled: boolean = false;\r\n private cache: Map<string, any> = new Map();\r\n\r\n constructor(config: DatabaseConfig, options: PoolOptions = {}) {\r\n this.config = config;\r\n this.options = {\r\n minConnections: options.minConnections ?? 2,\r\n maxConnections: options.maxConnections ?? config.poolSize ?? 10,\r\n acquireTimeout: options.acquireTimeout ?? config.timeout ?? 5000,\r\n idleTimeout: options.idleTimeout ?? 30000,\r\n healthCheckInterval: options.healthCheckInterval ?? 30000,\r\n maxReconnectAttempts: options.maxReconnectAttempts ?? 10,\r\n reconnectBaseDelay: options.reconnectBaseDelay ?? 1000,\r\n };\r\n this.maxReconnectAttempts = this.options.maxReconnectAttempts;\r\n this.startTime = new Date();\r\n }\r\n\r\n /**\r\n * Initialize connection pool\r\n */\r\n async initialize(): Promise<void> {\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n await this.initializeSQLitePool();\r\n break;\r\n case 'redis':\r\n await this.initializeRedisPool();\r\n break;\r\n case 'postgres':\r\n await this.initializePostgresPool();\r\n break;\r\n default:\r\n throw new Error(`Unsupported database type: ${this.config.type}`);\r\n }\r\n\r\n // Initialize minimum connections\r\n await this.warmUpPool();\r\n } catch (err) {\r\n this.failedAttempts++;\r\n throw createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n `Failed to initialize ${this.config.type} connection pool`,\r\n err instanceof Error ? err : new Error(String(err)),\r\n { config: this.config }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Initialize SQLite connection pool\r\n */\r\n private async initializeSQLitePool(): Promise<void> {\r\n const dbPath = this.config.database || this.config.connectionString || ':memory:';\r\n\r\n if (!dbPath || dbPath === '') {\r\n throw new Error('SQLite database path is required');\r\n }\r\n\r\n // Create connection pool for SQLite\r\n for (let i = 0; i < this.options.minConnections; i++) {\r\n const db = await open({\r\n filename: dbPath,\r\n driver: sqlite3.Database,\r\n });\r\n\r\n await db.run('PRAGMA foreign_keys = ON');\r\n await db.run(`PRAGMA busy_timeout = ${this.config.timeout || 5000}`);\r\n\r\n this.connections.add(db);\r\n }\r\n }\r\n\r\n /**\r\n * Initialize Redis connection pool\r\n */\r\n private async initializeRedisPool(): Promise<void> {\r\n let url = this.config.connectionString;\r\n\r\n if (!url) {\r\n // Build connection string with optional authentication\r\n const host = this.config.host || 'localhost';\r\n const port = this.config.port || 6379;\r\n\r\n if (this.config.password) {\r\n // Include password in connection string: redis://:password@host:port\r\n url = `redis://:${encodeURIComponent(this.config.password)}@${host}:${port}`;\r\n } else {\r\n url = `redis://${host}:${port}`;\r\n }\r\n }\r\n\r\n this.pool = createClient({\r\n url,\r\n socket: {\r\n connectTimeout: this.config.timeout || 5000,\r\n reconnectStrategy: (retries) => {\r\n if (retries > this.maxReconnectAttempts) {\r\n return false;\r\n }\r\n // Exponential backoff\r\n return Math.min(this.options.reconnectBaseDelay * Math.pow(2, retries), 30000);\r\n },\r\n },\r\n });\r\n\r\n // Set up event handlers\r\n this.pool.on('error', (err: Error) => {\r\n console.error('Redis connection error:', err);\r\n this.failedAttempts++;\r\n });\r\n\r\n this.pool.on('reconnecting', () => {\r\n this.reconnectAttempts++;\r\n });\r\n\r\n await this.pool.connect();\r\n }\r\n\r\n /**\r\n * Initialize PostgreSQL connection pool\r\n */\r\n private async initializePostgresPool(): Promise<void> {\r\n const connectionString = this.config.connectionString ||\r\n `postgresql://${this.config.username}:${this.config.password}@${this.config.host}:${this.config.port}/${this.config.database}`;\r\n\r\n this.pool = new Pool({\r\n connectionString,\r\n min: this.options.minConnections,\r\n max: this.options.maxConnections,\r\n idleTimeoutMillis: this.options.idleTimeout,\r\n connectionTimeoutMillis: this.options.acquireTimeout,\r\n });\r\n\r\n // Test connection\r\n const client = await this.pool.connect();\r\n await client.query('SELECT 1');\r\n client.release();\r\n }\r\n\r\n /**\r\n * Warm up pool by creating minimum connections\r\n */\r\n private async warmUpPool(): Promise<void> {\r\n if (this.config.type === 'sqlite') {\r\n // SQLite connections already created in initializeSQLitePool\r\n return;\r\n }\r\n\r\n // For Redis and Postgres, connections are managed by their libraries\r\n // We just need to verify connectivity\r\n if (this.config.type === 'redis') {\r\n await this.pool.ping();\r\n } else if (this.config.type === 'postgres') {\r\n const client = await this.pool.connect();\r\n await client.query('SELECT 1');\r\n client.release();\r\n }\r\n }\r\n\r\n /**\r\n * Acquire connection from pool\r\n */\r\n async acquire(): Promise<any> {\r\n if (this.isShuttingDown) {\r\n throw createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n 'Connection pool is shutting down',\r\n undefined,\r\n { type: this.config.type }\r\n );\r\n }\r\n\r\n const startTime = Date.now();\r\n\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n return await this.acquireSQLiteConnection(startTime);\r\n case 'redis':\r\n return this.pool;\r\n case 'postgres':\r\n return await this.pool.connect();\r\n default:\r\n throw new Error(`Unsupported database type: ${this.config.type}`);\r\n }\r\n } catch (err) {\r\n throw createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n 'Failed to acquire connection',\r\n err instanceof Error ? err : new Error(String(err)),\r\n { type: this.config.type }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Acquire SQLite connection from pool\r\n */\r\n private async acquireSQLiteConnection(startTime: number): Promise<Database> {\r\n // Check for available connection\r\n const availableConnection = Array.from(this.connections).find(\r\n conn => !this.activeConnections.has(conn)\r\n );\r\n\r\n if (availableConnection) {\r\n this.activeConnections.add(availableConnection);\r\n return availableConnection as Database;\r\n }\r\n\r\n // Check if we can create more connections\r\n if (this.connections.size < this.options.maxConnections) {\r\n const newConnection = await this.createSQLiteConnection();\r\n this.connections.add(newConnection);\r\n this.activeConnections.add(newConnection);\r\n return newConnection;\r\n }\r\n\r\n // Queue request\r\n return new Promise((resolve, reject) => {\r\n const timeoutId = setTimeout(() => {\r\n const index = this.pendingRequests.findIndex(req => req.resolve === resolve);\r\n if (index !== -1) {\r\n this.pendingRequests.splice(index, 1);\r\n }\r\n reject(createDatabaseError(\r\n DatabaseErrorCode.TIMEOUT,\r\n 'Connection acquisition timeout',\r\n undefined,\r\n { timeout: this.options.acquireTimeout }\r\n ));\r\n }, this.options.acquireTimeout);\r\n\r\n this.pendingRequests.push({\r\n resolve: (conn) => {\r\n clearTimeout(timeoutId);\r\n resolve(conn);\r\n },\r\n reject: (err) => {\r\n clearTimeout(timeoutId);\r\n reject(err);\r\n },\r\n timestamp: startTime,\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Create new SQLite connection\r\n */\r\n private async createSQLiteConnection(): Promise<Database> {\r\n const dbPath = this.config.database || this.config.connectionString || ':memory:';\r\n\r\n const db = await open({\r\n filename: dbPath,\r\n driver: sqlite3.Database,\r\n });\r\n\r\n await db.run('PRAGMA foreign_keys = ON');\r\n await db.run(`PRAGMA busy_timeout = ${this.config.timeout || 5000}`);\r\n\r\n return db;\r\n }\r\n\r\n /**\r\n * Release connection back to pool\r\n */\r\n async release(connection: any): Promise<void> {\r\n if (!connection) {\r\n return;\r\n }\r\n\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n this.releaseSQLiteConnection(connection);\r\n break;\r\n case 'redis':\r\n // Redis client is shared, no release needed\r\n break;\r\n case 'postgres':\r\n if (connection && typeof connection.release === 'function') {\r\n connection.release();\r\n }\r\n break;\r\n }\r\n } catch (err) {\r\n console.error('Failed to release connection:', err);\r\n }\r\n }\r\n\r\n /**\r\n * Release SQLite connection\r\n */\r\n private releaseSQLiteConnection(connection: Database): void {\r\n this.activeConnections.delete(connection);\r\n\r\n // Process pending requests\r\n if (this.pendingRequests.length > 0) {\r\n const pending = this.pendingRequests.shift();\r\n if (pending) {\r\n this.activeConnections.add(connection);\r\n pending.resolve(connection);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Start periodic health checks\r\n */\r\n startHealthChecks(): void {\r\n if (this.healthCheckActive) {\r\n return;\r\n }\r\n\r\n this.healthCheckActive = true;\r\n this.healthCheckInterval = setInterval(async () => {\r\n try {\r\n const healthy = await this.performHealthCheck();\r\n this.lastHealthCheck = new Date();\r\n\r\n if (!healthy) {\r\n console.warn(`Health check failed for ${this.config.type} pool`);\r\n await this.attemptReconnection();\r\n }\r\n } catch (err) {\r\n console.error('Health check error:', err);\r\n }\r\n }, this.options.healthCheckInterval);\r\n }\r\n\r\n /**\r\n * Stop health checks\r\n */\r\n stopHealthChecks(): void {\r\n if (this.healthCheckInterval) {\r\n clearInterval(this.healthCheckInterval);\r\n this.healthCheckInterval = undefined;\r\n }\r\n this.healthCheckActive = false;\r\n }\r\n\r\n /**\r\n * Perform health check\r\n */\r\n private async performHealthCheck(): Promise<boolean> {\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite': {\r\n const connection = Array.from(this.connections)[0];\r\n if (connection) {\r\n await (connection as Database).get('SELECT 1');\r\n return true;\r\n }\r\n return false;\r\n }\r\n case 'redis':\r\n if (this.pool) {\r\n await this.pool.ping();\r\n return true;\r\n }\r\n return false;\r\n case 'postgres':\r\n if (this.pool) {\r\n const client = await this.pool.connect();\r\n await client.query('SELECT 1');\r\n client.release();\r\n return true;\r\n }\r\n return false;\r\n default:\r\n return false;\r\n }\r\n } catch (err) {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Check if pool is healthy (exposed for testing)\r\n */\r\n private async isHealthy(): Promise<boolean> {\r\n return this.performHealthCheck();\r\n }\r\n\r\n /**\r\n * Attempt reconnection with exponential backoff\r\n */\r\n private async attemptReconnection(): Promise<void> {\r\n if (this.reconnectAttempts >= this.maxReconnectAttempts) {\r\n console.error(`Max reconnection attempts (${this.maxReconnectAttempts}) reached for ${this.config.type}`);\r\n return;\r\n }\r\n\r\n const delay = Math.min(\r\n this.options.reconnectBaseDelay * Math.pow(2, this.reconnectAttempts),\r\n 30000\r\n );\r\n\r\n this.reconnectAttempts++;\r\n\r\n await new Promise(resolve => setTimeout(resolve, delay));\r\n\r\n try {\r\n await this.initialize();\r\n console.log(`Reconnection successful for ${this.config.type}`);\r\n this.reconnectAttempts = 0;\r\n } catch (err) {\r\n console.error(`Reconnection failed for ${this.config.type}:`, err);\r\n }\r\n }\r\n\r\n /**\r\n * Get reconnection delays for testing\r\n */\r\n private getReconnectDelays(): number[] {\r\n const delays: number[] = [];\r\n for (let i = 0; i < 5; i++) {\r\n delays.push(\r\n Math.min(this.options.reconnectBaseDelay * Math.pow(2, i), 30000)\r\n );\r\n }\r\n return delays;\r\n }\r\n\r\n /**\r\n * Simulate disconnection (for testing)\r\n */\r\n private simulateDisconnection(): void {\r\n if (this.config.type === 'redis' && this.pool) {\r\n this.pool.disconnect();\r\n } else if (this.config.type === 'postgres' && this.pool) {\r\n this.pool.end();\r\n }\r\n }\r\n\r\n /**\r\n * Remove unhealthy connections (for testing)\r\n */\r\n private removeUnhealthyConnections(count: number): void {\r\n if (this.config.type === 'sqlite') {\r\n const connectionsToRemove = Array.from(this.connections).slice(0, count);\r\n connectionsToRemove.forEach(conn => {\r\n this.connections.delete(conn);\r\n this.activeConnections.delete(conn);\r\n (conn as Database).close();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Enable cache fallback for graceful degradation\r\n */\r\n enableCacheFallback(enabled: boolean): void {\r\n this.cacheFallbackEnabled = enabled;\r\n }\r\n\r\n /**\r\n * Get data with cache fallback\r\n */\r\n async getWithFallback(key: string): Promise<any> {\r\n try {\r\n const connection = await this.acquire();\r\n // Actual data retrieval would happen here\r\n await this.release(connection);\r\n return null;\r\n } catch (err) {\r\n if (this.cacheFallbackEnabled && this.cache.has(key)) {\r\n console.warn(`Using cached data for key: ${key}`);\r\n return this.cache.get(key);\r\n }\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Get connection pool statistics\r\n */\r\n getStats(): ConnectionPoolStats {\r\n const now = Date.now();\r\n const uptime = now - this.startTime.getTime();\r\n\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n return {\r\n type: 'sqlite',\r\n total: this.connections.size,\r\n active: this.activeConnections.size,\r\n idle: this.connections.size - this.activeConnections.size,\r\n pending: this.pendingRequests.length,\r\n maxConnections: this.options.maxConnections,\r\n available: this.connections.size - this.activeConnections.size,\r\n healthy: this.connections.size > 0,\r\n lastHealthCheck: this.lastHealthCheck,\r\n healthCheckActive: this.healthCheckActive,\r\n reconnectAttempts: this.reconnectAttempts,\r\n failedAttempts: this.failedAttempts,\r\n uptime,\r\n };\r\n\r\n case 'redis':\r\n return {\r\n type: 'redis',\r\n total: this.pool ? 1 : 0,\r\n active: this.pool?.isOpen ? 1 : 0,\r\n idle: 0,\r\n pending: 0,\r\n maxConnections: 1,\r\n available: this.pool?.isOpen ? 1 : 0,\r\n healthy: this.pool?.isOpen ?? false,\r\n lastHealthCheck: this.lastHealthCheck,\r\n healthCheckActive: this.healthCheckActive,\r\n reconnectAttempts: this.reconnectAttempts,\r\n failedAttempts: this.failedAttempts,\r\n uptime,\r\n };\r\n\r\n case 'postgres':\r\n return {\r\n type: 'postgres',\r\n total: this.pool?.totalCount ?? 0,\r\n active: (this.pool?.totalCount ?? 0) - (this.pool?.idleCount ?? 0),\r\n idle: this.pool?.idleCount ?? 0,\r\n pending: this.pool?.waitingCount ?? 0,\r\n maxConnections: this.options.maxConnections,\r\n available: this.pool?.idleCount ?? 0,\r\n healthy: this.pool !== null,\r\n lastHealthCheck: this.lastHealthCheck,\r\n healthCheckActive: this.healthCheckActive,\r\n reconnectAttempts: this.reconnectAttempts,\r\n failedAttempts: this.failedAttempts,\r\n uptime,\r\n };\r\n\r\n default:\r\n throw new Error(`Unsupported database type: ${this.config.type}`);\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown connection pool\r\n */\r\n async shutdown(): Promise<void> {\r\n if (this.isShuttingDown) {\r\n return;\r\n }\r\n\r\n this.isShuttingDown = true;\r\n this.stopHealthChecks();\r\n\r\n // Reject all pending requests\r\n this.pendingRequests.forEach(req => {\r\n req.reject(createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n 'Connection pool is shutting down',\r\n undefined,\r\n { type: this.config.type }\r\n ));\r\n });\r\n this.pendingRequests = [];\r\n\r\n // Close all connections\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n await Promise.all(\r\n Array.from(this.connections).map(conn => (conn as Database).close())\r\n );\r\n this.connections.clear();\r\n this.activeConnections.clear();\r\n break;\r\n\r\n case 'redis':\r\n if (this.pool) {\r\n await this.pool.quit();\r\n this.pool = null;\r\n }\r\n break;\r\n\r\n case 'postgres':\r\n if (this.pool) {\r\n await this.pool.end();\r\n this.pool = null;\r\n }\r\n break;\r\n }\r\n } catch (err) {\r\n console.error('Error during shutdown:', err);\r\n }\r\n }\r\n}\r\n"],"names":["sqlite3","open","createClient","Pool","DatabaseErrorCode","createDatabaseError","ConnectionPoolManager","config","options","pool","connections","Set","activeConnections","pendingRequests","healthCheckInterval","lastHealthCheck","healthCheckActive","reconnectAttempts","maxReconnectAttempts","failedAttempts","startTime","isShuttingDown","cacheFallbackEnabled","cache","Map","minConnections","maxConnections","poolSize","acquireTimeout","timeout","idleTimeout","reconnectBaseDelay","Date","initialize","type","initializeSQLitePool","initializeRedisPool","initializePostgresPool","Error","warmUpPool","err","CONNECTION_FAILED","String","dbPath","database","connectionString","i","db","filename","driver","Database","run","add","url","host","port","password","encodeURIComponent","socket","connectTimeout","reconnectStrategy","retries","Math","min","pow","on","console","error","connect","username","max","idleTimeoutMillis","connectionTimeoutMillis","client","query","release","ping","acquire","undefined","now","acquireSQLiteConnection","availableConnection","Array","from","find","conn","has","size","newConnection","createSQLiteConnection","Promise","resolve","reject","timeoutId","setTimeout","index","findIndex","req","splice","TIMEOUT","push","clearTimeout","timestamp","connection","releaseSQLiteConnection","delete","length","pending","shift","startHealthChecks","setInterval","healthy","performHealthCheck","warn","attemptReconnection","stopHealthChecks","clearInterval","get","isHealthy","delay","log","getReconnectDelays","delays","simulateDisconnection","disconnect","end","removeUnhealthyConnections","count","connectionsToRemove","slice","forEach","close","enableCacheFallback","enabled","getWithFallback","key","getStats","uptime","getTime","total","active","idle","available","isOpen","totalCount","idleCount","waitingCount","shutdown","all","map","clear","quit"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,OAAOA,aAAa,UAAU;AAC9B,SAASC,IAAI,QAAkB,SAAS;AACxC,SAASC,YAAY,QAAyB,QAAQ;AACtD,SAASC,IAAI,QAAoB,KAAK;AACtC,SAEEC,iBAAiB,QACZ,aAAa;AACpB,SAASC,mBAAmB,QAAQ,cAAc;AA4BlD;;;;CAIC,GACD,OAAO,MAAMC;IACHC,OAAuB;IACvBC,QAA+B;IAC/BC,OAAY,KAAK;IACjBC,cAAwB,IAAIC,MAAM;IAClCC,oBAA8B,IAAID,MAAM;IACxCE,kBAIH,EAAE,CAAC;IACAC,oBAAqC;IACrCC,gBAAuB;IACvBC,oBAA6B,MAAM;IACnCC,oBAA4B,EAAE;IAC9BC,uBAA+B,GAAG;IAClCC,iBAA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,CAAC,IAAI,CAACzE,WAAW,EAAE2I,GAAG,CAAChE,CAAAA,OAAQ,AAACA,KAAkB8C,KAAK;oBAEnE,IAAI,CAACzH,WAAW,CAAC4I,KAAK;oBACtB,IAAI,CAAC1I,iBAAiB,CAAC0I,KAAK;oBAC5B;gBAEF,KAAK;oBACH,IAAI,IAAI,CAAC7I,IAAI,EAAE;wBACb,MAAM,IAAI,CAACA,IAAI,CAAC8I,IAAI;wBACpB,IAAI,CAAC9I,IAAI,GAAG;oBACd;oBACA;gBAEF,KAAK;oBACH,IAAI,IAAI,CAACA,IAAI,EAAE;wBACb,MAAM,IAAI,CAACA,IAAI,CAACoH,GAAG;wBACnB,IAAI,CAACpH,IAAI,GAAG;oBACd;oBACA;YACJ;QACF,EAAE,OAAO+B,KAAK;YACZ0B,QAAQC,KAAK,CAAC,0BAA0B3B;QAC1C;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/lib/database-service/connection-pool-manager.ts"],"sourcesContent":["/**\r\n * Connection Pool Manager\r\n *\r\n * Manages connection pools for database adapters with:\r\n * - Automatic initialization on service startup\r\n * - Connection health checks (ping every 30s)\r\n * - Automatic reconnection with exponential backoff\r\n * - Connection metrics (active, idle, pending)\r\n * - Graceful degradation on connection failures\r\n *\r\n * Part of Bug Fix: Connection Pool Initialization\r\n */\r\n\r\nimport sqlite3 from 'sqlite3';\r\nimport { open, Database } from 'sqlite';\r\nimport { createClient, RedisClientType } from 'redis';\r\nimport { Pool, PoolClient } from 'pg';\r\nimport {\r\n DatabaseConfig,\r\n DatabaseErrorCode,\r\n} from './types.js';\r\nimport { createDatabaseError } from './errors.js';\r\n\r\nexport interface ConnectionPoolStats {\r\n type: 'redis' | 'sqlite' | 'postgres';\r\n total: number;\r\n active: number;\r\n idle: number;\r\n pending: number;\r\n maxConnections: number;\r\n available: number;\r\n healthy: boolean;\r\n lastHealthCheck?: Date;\r\n healthCheckActive: boolean;\r\n reconnectAttempts: number;\r\n failedAttempts: number;\r\n uptime: number;\r\n}\r\n\r\nexport interface PoolOptions {\r\n minConnections?: number;\r\n maxConnections?: number;\r\n acquireTimeout?: number;\r\n idleTimeout?: number;\r\n healthCheckInterval?: number;\r\n maxReconnectAttempts?: number;\r\n reconnectBaseDelay?: number;\r\n}\r\n\r\n/**\r\n * Connection Pool Manager\r\n *\r\n * Manages connection lifecycle, health checks, and automatic recovery\r\n */\r\nexport class ConnectionPoolManager {\r\n private config: DatabaseConfig;\r\n private options: Required<PoolOptions>;\r\n private pool: any = null;\r\n private connections: Set<any> = new Set();\r\n private activeConnections: Set<any> = new Set();\r\n private pendingRequests: Array<{\r\n resolve: (connection: any) => void;\r\n reject: (error: Error) => void;\r\n timestamp: number;\r\n }> = [];\r\n private healthCheckInterval?: NodeJS.Timeout;\r\n private lastHealthCheck?: Date;\r\n private healthCheckActive: boolean = false;\r\n private reconnectAttempts: number = 0;\r\n private maxReconnectAttempts: number = 10;\r\n private failedAttempts: number = 0;\r\n private startTime: Date;\r\n private isShuttingDown: boolean = false;\r\n private cacheFallbackEnabled: boolean = false;\r\n private cache: Map<string, any> = new Map();\r\n\r\n constructor(config: DatabaseConfig, options: PoolOptions = {}) {\r\n this.config = config;\r\n this.options = {\r\n minConnections: options.minConnections ?? 2,\r\n maxConnections: options.maxConnections ?? config.poolSize ?? 10,\r\n acquireTimeout: options.acquireTimeout ?? config.timeout ?? 5000,\r\n idleTimeout: options.idleTimeout ?? 30000,\r\n healthCheckInterval: options.healthCheckInterval ?? 30000,\r\n maxReconnectAttempts: options.maxReconnectAttempts ?? 10,\r\n reconnectBaseDelay: options.reconnectBaseDelay ?? 1000,\r\n };\r\n this.maxReconnectAttempts = this.options.maxReconnectAttempts;\r\n this.startTime = new Date();\r\n }\r\n\r\n /**\r\n * Initialize connection pool\r\n */\r\n async initialize(): Promise<void> {\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n await this.initializeSQLitePool();\r\n break;\r\n case 'redis':\r\n await this.initializeRedisPool();\r\n break;\r\n case 'postgres':\r\n await this.initializePostgresPool();\r\n break;\r\n default:\r\n throw new Error(`Unsupported database type: ${this.config.type}`);\r\n }\r\n\r\n // Initialize minimum connections\r\n await this.warmUpPool();\r\n } catch (err) {\r\n this.failedAttempts++;\r\n throw createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n `Failed to initialize ${this.config.type} connection pool`,\r\n err instanceof Error ? err : new Error(String(err)),\r\n { config: this.config }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Initialize SQLite connection pool\r\n */\r\n private async initializeSQLitePool(): Promise<void> {\r\n const dbPath = this.config.database || this.config.connectionString || ':memory:';\r\n\r\n if (!dbPath || dbPath === '') {\r\n throw new Error('SQLite database path is required');\r\n }\r\n\r\n // Create connection pool for SQLite\r\n for (let i = 0; i < this.options.minConnections; i++) {\r\n const db = await open({\r\n filename: dbPath,\r\n driver: sqlite3.Database,\r\n });\r\n\r\n await db.run('PRAGMA foreign_keys = ON');\r\n await db.run(`PRAGMA busy_timeout = ${this.config.timeout || 5000}`);\r\n\r\n this.connections.add(db);\r\n }\r\n }\r\n\r\n /**\r\n * Initialize Redis connection pool\r\n */\r\n private async initializeRedisPool(): Promise<void> {\r\n let url = this.config.connectionString;\r\n\r\n if (!url) {\r\n // Build connection string with optional authentication\r\n const host = this.config.host || 'localhost';\r\n const port = this.config.port || 6379;\r\n\r\n if (this.config.password) {\r\n // Include password in connection string (credentials from environment)\r\n url = `redis://:${encodeURIComponent(this.config.password)}@${host}:${port}`;\r\n } else {\r\n url = `redis://${host}:${port}`;\r\n }\r\n }\r\n\r\n this.pool = createClient({\r\n url,\r\n socket: {\r\n connectTimeout: this.config.timeout || 5000,\r\n reconnectStrategy: (retries) => {\r\n if (retries > this.maxReconnectAttempts) {\r\n return false;\r\n }\r\n // Exponential backoff\r\n return Math.min(this.options.reconnectBaseDelay * Math.pow(2, retries), 30000);\r\n },\r\n },\r\n });\r\n\r\n // Set up event handlers\r\n this.pool.on('error', (err: Error) => {\r\n console.error('Redis connection error:', err);\r\n this.failedAttempts++;\r\n });\r\n\r\n this.pool.on('reconnecting', () => {\r\n this.reconnectAttempts++;\r\n });\r\n\r\n await this.pool.connect();\r\n }\r\n\r\n /**\r\n * Initialize PostgreSQL connection pool\r\n */\r\n private async initializePostgresPool(): Promise<void> {\r\n const connectionString = this.config.connectionString ||\r\n `postgresql://${this.config.username}:${this.config.password}@${this.config.host}:${this.config.port}/${this.config.database}`;\r\n // Note: credentials come from config object (typically loaded from environment variables)\r\n\r\n this.pool = new Pool({\r\n connectionString,\r\n min: this.options.minConnections,\r\n max: this.options.maxConnections,\r\n idleTimeoutMillis: this.options.idleTimeout,\r\n connectionTimeoutMillis: this.options.acquireTimeout,\r\n });\r\n\r\n // Test connection\r\n const client = await this.pool.connect();\r\n await client.query('SELECT 1');\r\n client.release();\r\n }\r\n\r\n /**\r\n * Warm up pool by creating minimum connections\r\n */\r\n private async warmUpPool(): Promise<void> {\r\n if (this.config.type === 'sqlite') {\r\n // SQLite connections already created in initializeSQLitePool\r\n return;\r\n }\r\n\r\n // For Redis and Postgres, connections are managed by their libraries\r\n // We just need to verify connectivity\r\n if (this.config.type === 'redis') {\r\n await this.pool.ping();\r\n } else if (this.config.type === 'postgres') {\r\n const client = await this.pool.connect();\r\n await client.query('SELECT 1');\r\n client.release();\r\n }\r\n }\r\n\r\n /**\r\n * Acquire connection from pool\r\n */\r\n async acquire(): Promise<any> {\r\n if (this.isShuttingDown) {\r\n throw createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n 'Connection pool is shutting down',\r\n undefined,\r\n { type: this.config.type }\r\n );\r\n }\r\n\r\n const startTime = Date.now();\r\n\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n return await this.acquireSQLiteConnection(startTime);\r\n case 'redis':\r\n return this.pool;\r\n case 'postgres':\r\n return await this.pool.connect();\r\n default:\r\n throw new Error(`Unsupported database type: ${this.config.type}`);\r\n }\r\n } catch (err) {\r\n throw createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n 'Failed to acquire connection',\r\n err instanceof Error ? err : new Error(String(err)),\r\n { type: this.config.type }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Acquire SQLite connection from pool\r\n */\r\n private async acquireSQLiteConnection(startTime: number): Promise<Database> {\r\n // Check for available connection\r\n const availableConnection = Array.from(this.connections).find(\r\n conn => !this.activeConnections.has(conn)\r\n );\r\n\r\n if (availableConnection) {\r\n this.activeConnections.add(availableConnection);\r\n return availableConnection as Database;\r\n }\r\n\r\n // Check if we can create more connections\r\n if (this.connections.size < this.options.maxConnections) {\r\n const newConnection = await this.createSQLiteConnection();\r\n this.connections.add(newConnection);\r\n this.activeConnections.add(newConnection);\r\n return newConnection;\r\n }\r\n\r\n // Queue request\r\n return new Promise((resolve, reject) => {\r\n const timeoutId = setTimeout(() => {\r\n const index = this.pendingRequests.findIndex(req => req.resolve === resolve);\r\n if (index !== -1) {\r\n this.pendingRequests.splice(index, 1);\r\n }\r\n reject(createDatabaseError(\r\n DatabaseErrorCode.TIMEOUT,\r\n 'Connection acquisition timeout',\r\n undefined,\r\n { timeout: this.options.acquireTimeout }\r\n ));\r\n }, this.options.acquireTimeout);\r\n\r\n this.pendingRequests.push({\r\n resolve: (conn) => {\r\n clearTimeout(timeoutId);\r\n resolve(conn);\r\n },\r\n reject: (err) => {\r\n clearTimeout(timeoutId);\r\n reject(err);\r\n },\r\n timestamp: startTime,\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Create new SQLite connection\r\n */\r\n private async createSQLiteConnection(): Promise<Database> {\r\n const dbPath = this.config.database || this.config.connectionString || ':memory:';\r\n\r\n const db = await open({\r\n filename: dbPath,\r\n driver: sqlite3.Database,\r\n });\r\n\r\n await db.run('PRAGMA foreign_keys = ON');\r\n await db.run(`PRAGMA busy_timeout = ${this.config.timeout || 5000}`);\r\n\r\n return db;\r\n }\r\n\r\n /**\r\n * Release connection back to pool\r\n */\r\n async release(connection: any): Promise<void> {\r\n if (!connection) {\r\n return;\r\n }\r\n\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n this.releaseSQLiteConnection(connection);\r\n break;\r\n case 'redis':\r\n // Redis client is shared, no release needed\r\n break;\r\n case 'postgres':\r\n if (connection && typeof connection.release === 'function') {\r\n connection.release();\r\n }\r\n break;\r\n }\r\n } catch (err) {\r\n console.error('Failed to release connection:', err);\r\n }\r\n }\r\n\r\n /**\r\n * Release SQLite connection\r\n */\r\n private releaseSQLiteConnection(connection: Database): void {\r\n this.activeConnections.delete(connection);\r\n\r\n // Process pending requests\r\n if (this.pendingRequests.length > 0) {\r\n const pending = this.pendingRequests.shift();\r\n if (pending) {\r\n this.activeConnections.add(connection);\r\n pending.resolve(connection);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Start periodic health checks\r\n */\r\n startHealthChecks(): void {\r\n if (this.healthCheckActive) {\r\n return;\r\n }\r\n\r\n this.healthCheckActive = true;\r\n this.healthCheckInterval = setInterval(async () => {\r\n try {\r\n const healthy = await this.performHealthCheck();\r\n this.lastHealthCheck = new Date();\r\n\r\n if (!healthy) {\r\n console.warn(`Health check failed for ${this.config.type} pool`);\r\n await this.attemptReconnection();\r\n }\r\n } catch (err) {\r\n console.error('Health check error:', err);\r\n }\r\n }, this.options.healthCheckInterval);\r\n }\r\n\r\n /**\r\n * Stop health checks\r\n */\r\n stopHealthChecks(): void {\r\n if (this.healthCheckInterval) {\r\n clearInterval(this.healthCheckInterval);\r\n this.healthCheckInterval = undefined;\r\n }\r\n this.healthCheckActive = false;\r\n }\r\n\r\n /**\r\n * Perform health check\r\n */\r\n private async performHealthCheck(): Promise<boolean> {\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite': {\r\n const connection = Array.from(this.connections)[0];\r\n if (connection) {\r\n await (connection as Database).get('SELECT 1');\r\n return true;\r\n }\r\n return false;\r\n }\r\n case 'redis':\r\n if (this.pool) {\r\n await this.pool.ping();\r\n return true;\r\n }\r\n return false;\r\n case 'postgres':\r\n if (this.pool) {\r\n const client = await this.pool.connect();\r\n await client.query('SELECT 1');\r\n client.release();\r\n return true;\r\n }\r\n return false;\r\n default:\r\n return false;\r\n }\r\n } catch (err) {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Check if pool is healthy (exposed for testing)\r\n */\r\n private async isHealthy(): Promise<boolean> {\r\n return this.performHealthCheck();\r\n }\r\n\r\n /**\r\n * Attempt reconnection with exponential backoff\r\n */\r\n private async attemptReconnection(): Promise<void> {\r\n if (this.reconnectAttempts >= this.maxReconnectAttempts) {\r\n console.error(`Max reconnection attempts (${this.maxReconnectAttempts}) reached for ${this.config.type}`);\r\n return;\r\n }\r\n\r\n const delay = Math.min(\r\n this.options.reconnectBaseDelay * Math.pow(2, this.reconnectAttempts),\r\n 30000\r\n );\r\n\r\n this.reconnectAttempts++;\r\n\r\n await new Promise(resolve => setTimeout(resolve, delay));\r\n\r\n try {\r\n await this.initialize();\r\n console.log(`Reconnection successful for ${this.config.type}`);\r\n this.reconnectAttempts = 0;\r\n } catch (err) {\r\n console.error(`Reconnection failed for ${this.config.type}:`, err);\r\n }\r\n }\r\n\r\n /**\r\n * Get reconnection delays for testing\r\n */\r\n private getReconnectDelays(): number[] {\r\n const delays: number[] = [];\r\n for (let i = 0; i < 5; i++) {\r\n delays.push(\r\n Math.min(this.options.reconnectBaseDelay * Math.pow(2, i), 30000)\r\n );\r\n }\r\n return delays;\r\n }\r\n\r\n /**\r\n * Simulate disconnection (for testing)\r\n */\r\n private simulateDisconnection(): void {\r\n if (this.config.type === 'redis' && this.pool) {\r\n this.pool.disconnect();\r\n } else if (this.config.type === 'postgres' && this.pool) {\r\n this.pool.end();\r\n }\r\n }\r\n\r\n /**\r\n * Remove unhealthy connections (for testing)\r\n */\r\n private removeUnhealthyConnections(count: number): void {\r\n if (this.config.type === 'sqlite') {\r\n const connectionsToRemove = Array.from(this.connections).slice(0, count);\r\n connectionsToRemove.forEach(conn => {\r\n this.connections.delete(conn);\r\n this.activeConnections.delete(conn);\r\n (conn as Database).close();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Enable cache fallback for graceful degradation\r\n */\r\n enableCacheFallback(enabled: boolean): void {\r\n this.cacheFallbackEnabled = enabled;\r\n }\r\n\r\n /**\r\n * Get data with cache fallback\r\n */\r\n async getWithFallback(key: string): Promise<any> {\r\n try {\r\n const connection = await this.acquire();\r\n // Actual data retrieval would happen here\r\n await this.release(connection);\r\n return null;\r\n } catch (err) {\r\n if (this.cacheFallbackEnabled && this.cache.has(key)) {\r\n console.warn(`Using cached data for key: ${key}`);\r\n return this.cache.get(key);\r\n }\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Get connection pool statistics\r\n */\r\n getStats(): ConnectionPoolStats {\r\n const now = Date.now();\r\n const uptime = now - this.startTime.getTime();\r\n\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n return {\r\n type: 'sqlite',\r\n total: this.connections.size,\r\n active: this.activeConnections.size,\r\n idle: this.connections.size - this.activeConnections.size,\r\n pending: this.pendingRequests.length,\r\n maxConnections: this.options.maxConnections,\r\n available: this.connections.size - this.activeConnections.size,\r\n healthy: this.connections.size > 0,\r\n lastHealthCheck: this.lastHealthCheck,\r\n healthCheckActive: this.healthCheckActive,\r\n reconnectAttempts: this.reconnectAttempts,\r\n failedAttempts: this.failedAttempts,\r\n uptime,\r\n };\r\n\r\n case 'redis':\r\n return {\r\n type: 'redis',\r\n total: this.pool ? 1 : 0,\r\n active: this.pool?.isOpen ? 1 : 0,\r\n idle: 0,\r\n pending: 0,\r\n maxConnections: 1,\r\n available: this.pool?.isOpen ? 1 : 0,\r\n healthy: this.pool?.isOpen ?? false,\r\n lastHealthCheck: this.lastHealthCheck,\r\n healthCheckActive: this.healthCheckActive,\r\n reconnectAttempts: this.reconnectAttempts,\r\n failedAttempts: this.failedAttempts,\r\n uptime,\r\n };\r\n\r\n case 'postgres':\r\n return {\r\n type: 'postgres',\r\n total: this.pool?.totalCount ?? 0,\r\n active: (this.pool?.totalCount ?? 0) - (this.pool?.idleCount ?? 0),\r\n idle: this.pool?.idleCount ?? 0,\r\n pending: this.pool?.waitingCount ?? 0,\r\n maxConnections: this.options.maxConnections,\r\n available: this.pool?.idleCount ?? 0,\r\n healthy: this.pool !== null,\r\n lastHealthCheck: this.lastHealthCheck,\r\n healthCheckActive: this.healthCheckActive,\r\n reconnectAttempts: this.reconnectAttempts,\r\n failedAttempts: this.failedAttempts,\r\n uptime,\r\n };\r\n\r\n default:\r\n throw new Error(`Unsupported database type: ${this.config.type}`);\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown connection pool\r\n */\r\n async shutdown(): Promise<void> {\r\n if (this.isShuttingDown) {\r\n return;\r\n }\r\n\r\n this.isShuttingDown = true;\r\n this.stopHealthChecks();\r\n\r\n // Reject all pending requests\r\n this.pendingRequests.forEach(req => {\r\n req.reject(createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n 'Connection pool is shutting down',\r\n undefined,\r\n { type: this.config.type }\r\n ));\r\n });\r\n this.pendingRequests = [];\r\n\r\n // Close all connections\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n await Promise.all(\r\n Array.from(this.connections).map(conn => (conn as Database).close())\r\n );\r\n this.connections.clear();\r\n this.activeConnections.clear();\r\n break;\r\n\r\n case 'redis':\r\n if (this.pool) {\r\n await this.pool.quit();\r\n this.pool = null;\r\n }\r\n break;\r\n\r\n case 'postgres':\r\n if (this.pool) {\r\n await this.pool.end();\r\n this.pool = null;\r\n }\r\n break;\r\n }\r\n } catch (err) {\r\n console.error('Error during shutdown:', err);\r\n }\r\n }\r\n}\r\n"],"names":["sqlite3","open","createClient","Pool","DatabaseErrorCode","createDatabaseError","ConnectionPoolManager","config","options","pool","connections","Set","activeConnections","pendingRequests","healthCheckInterval","lastHealthCheck","healthCheckActive","reconnectAttempts","maxReconnectAttempts","failedAttempts","startTime","isShuttingDown","cacheFallbackEnabled","cache","Map","minConnections","maxConnections","poolSize","acquireTimeout","timeout","idleTimeout","reconnectBaseDelay","Date","initialize","type","initializeSQLitePool","initializeRedisPool","initializePostgresPool","Error","warmUpPool","err","CONNECTION_FAILED","String","dbPath","database","connectionString","i","db","filename","driver","Database","run","add","url","host","port","password","encodeURIComponent","socket","connectTimeout","reconnectStrategy","retries","Math","min","pow","on","console","error","connect","username","max","idleTimeoutMillis","connectionTimeoutMillis","client","query","release","ping","acquire","undefined","now","acquireSQLiteConnection","availableConnection","Array","from","find","conn","has","size","newConnection","createSQLiteConnection","Promise","resolve","reject","timeoutId","setTimeout","index","findIndex","req","splice","TIMEOUT","push","clearTimeout","timestamp","connection","releaseSQLiteConnection","delete","length","pending","shift","startHealthChecks","setInterval","healthy","performHealthCheck","warn","attemptReconnection","stopHealthChecks","clearInterval","get","isHealthy","delay","log","getReconnectDelays","delays","simulateDisconnection","disconnect","end","removeUnhealthyConnections","count","connectionsToRemove","slice","forEach","close","enableCacheFallback","enabled","getWithFallback","key","getStats","uptime","getTime","total","active","idle","available","isOpen","totalCount","idleCount","waitingCount","shutdown","all","map","clear","quit"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,OAAOA,aAAa,UAAU;AAC9B,SAASC,IAAI,QAAkB,SAAS;AACxC,SAASC,YAAY,QAAyB,QAAQ;AACtD,SAASC,IAAI,QAAoB,KAAK;AACtC,SAEEC,iBAAiB,QACZ,aAAa;AACpB,SAASC,mBAAmB,QAAQ,cAAc;AA4BlD;;;;CAIC,GACD,OAAO,MAAMC;IACHC,OAAuB;IACvBC,QAA+B;IAC/BC,OAAY,KAAK;IACjBC,cAAwB,IAAIC,MAAM;IAClCC,oBAA8B,IAAID,MAAM;IACxCE,kBAIH,EAAE,CAAC;IACAC,oBAAqC;IACrCC,gBAAuB;IACvBC,oBAA6B,MAAM;IACnCC,oBAA4B,EAAE;IAC9BC,uBAA+B,GAAG;IAClCC,iBAAyB,EAAE;IAC3BC,UAAgB;IAChBC,iBAA0B,MAAM;IAChCC,uBAAgC,MAAM;IACt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AQ,AAACA,KAAkB8C,KAAK;oBAEnE,IAAI,CAACzH,WAAW,CAAC4I,KAAK;oBACtB,IAAI,CAAC1I,iBAAiB,CAAC0I,KAAK;oBAC5B;gBAEF,KAAK;oBACH,IAAI,IAAI,CAAC7I,IAAI,EAAE;wBACb,MAAM,IAAI,CAACA,IAAI,CAAC8I,IAAI;wBACpB,IAAI,CAAC9I,IAAI,GAAG;oBACd;oBACA;gBAEF,KAAK;oBACH,IAAI,IAAI,CAACA,IAAI,EAAE;wBACb,MAAM,IAAI,CAACA,IAAI,CAACoH,GAAG;wBACnB,IAAI,CAACpH,IAAI,GAAG;oBACd;oBACA;YACJ;QACF,EAAE,OAAO+B,KAAK;YACZ0B,QAAQC,KAAK,CAAC,0BAA0B3B;QAC1C;IACF;AACF"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * CFN Loop Orchestrator Module Exports
3
+ *
4
+ * Main exports for orchestration functionality.
5
+ *
6
+ * @module orchestrator
7
+ */ export { CFNOrchestrator, default } from './orchestrate';
8
+ export * from './types';
9
+
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/orchestrator/index.ts"],"sourcesContent":["/**\r\n * CFN Loop Orchestrator Module Exports\r\n *\r\n * Main exports for orchestration functionality.\r\n *\r\n * @module orchestrator\r\n */\r\n\r\nexport { CFNOrchestrator, default } from './orchestrate';\r\nexport * from './types';\r\n"],"names":["CFNOrchestrator","default"],"mappings":"AAAA;;;;;;CAMC,GAED,SAASA,eAAe,EAAEC,OAAO,QAAQ,gBAAgB;AACzD,cAAc,UAAU"}