claude-flow-novice 2.15.3 → 2.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (461) hide show
  1. package/.claude/cfn-extras/skills/advanced-features/cfn-agent-swap/recommend-swap.sh +59 -59
  2. package/.claude/cfn-extras/skills/analytics/cfn-improvement-recommender/recommend-improvements.sh +91 -91
  3. package/.claude/cfn-extras/skills/analytics/cfn-pattern-extraction/extract-patterns.sh +79 -79
  4. package/.claude/cfn-extras/skills/analytics/cfn-retrospective-report/generate-report.sh +100 -100
  5. package/.claude/cfn-extras/skills/analytics/cfn-telemetry/start-telemetry.sh +110 -110
  6. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/add-bullet.sh +145 -145
  7. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/log-merge.sh +67 -67
  8. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/monitor-injection-performance.sh +137 -137
  9. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/optimize-injection-pipeline.sh +168 -168
  10. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/query-reflections.sh +35 -35
  11. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/store-reflection.sh +45 -45
  12. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/track-ab-test.sh +41 -41
  13. package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/update-reflection.sh +41 -41
  14. package/.claude/cfn-extras/skills/deprecated/cfn-cli-setup/validate-cli-environment.sh +191 -191
  15. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/create-campaign.sh +231 -231
  16. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/get-campaign-performance.sh +190 -190
  17. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/pause-campaign.sh +142 -142
  18. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/set-budget.sh +181 -181
  19. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/update-bid-strategy.sh +133 -133
  20. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/get-conversation-history.sh +121 -121
  21. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/qualify-lead.sh +156 -156
  22. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/schedule-demo.sh +181 -181
  23. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/send-message.sh +137 -137
  24. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/transfer-to-human.sh +179 -179
  25. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/create-campaign.sh +183 -183
  26. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/get-delivery-status.sh +139 -139
  27. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/opt-out.sh +150 -150
  28. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/schedule-campaign.sh +187 -187
  29. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/send-sms.sh +181 -181
  30. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/test-web-portal-skill.sh +50 -50
  31. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/validate-deployment.sh +84 -84
  32. package/.claude/cfn-extras/skills/utility/cfn-environment-sanitization/sanitize-environment.sh +243 -243
  33. package/.claude/commands/cfn-loop-cli.md +16 -2
  34. package/.claude/commands/switch-api.md +31 -10
  35. package/.claude/hooks/cfn-lint-sql-injection.sh +61 -0
  36. package/.claude/hooks/cfn-post-edit-cfn-retrospective.sh +33 -2
  37. package/.claude/hooks/cfn-pre-edit-security-warning.sh +40 -0
  38. package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +22 -24
  39. package/.claude/skills/cfn-docker-agent-spawning/SKILL.md +28 -4
  40. package/.claude/skills/cfn-docker-agent-spawning/spawn-agent.sh +3 -1
  41. package/.claude/skills/cfn-docker-loop-orchestration/orchestrate.sh +224 -20
  42. package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +550 -46
  43. package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +277 -0
  44. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +184 -23
  45. package/.claude/skills/cfn-loop-orchestration/security_utils.sh +24 -0
  46. package/.claude/skills/cfn-loop-orchestration/test-iteration-context-injection.sh +366 -0
  47. package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +319 -0
  48. package/.claude/skills/cfn-redis-coordination/agent-log.sh +4 -0
  49. package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +124 -0
  50. package/.claude/skills/cfn-redis-coordination/agent-recovery.sh +2 -2
  51. package/.claude/skills/cfn-redis-coordination/collect-confidence-scores.sh +30 -0
  52. package/.claude/skills/cfn-redis-coordination/get-context.sh +33 -0
  53. package/.claude/skills/cfn-redis-coordination/get-success-criteria.sh +54 -0
  54. package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh +3 -0
  55. package/.claude/skills/cfn-redis-coordination/redis-cli-wrapper.sh +24 -3
  56. package/.claude/skills/cfn-redis-coordination/redis-functions.sh +33 -0
  57. package/.claude/skills/cfn-redis-coordination/report-completion.sh +24 -31
  58. package/.claude/skills/cfn-redis-coordination/store-context.sh +4 -0
  59. package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +85 -0
  60. package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +67 -0
  61. package/.claude/skills/cfn-sqlite-memory/ttl-cleanup.sh +17 -25
  62. package/.claude/skills/cfn-transparency-middleware/test-e2e.sh +15 -0
  63. package/.claude/skills/cfn-transparency-middleware/tests/input-validation.sh +15 -0
  64. package/README.md +116 -475
  65. package/claude-assets/agents/cfn-dev-team/README.md +103 -0
  66. package/claude-assets/agents/cfn-dev-team/architecture/goal-planner.md +1 -1
  67. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +77 -15
  68. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +355 -6
  69. package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +82 -1
  70. package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +82 -1
  71. package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +77 -15
  72. package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +99 -12
  73. package/claude-assets/agents/cfn-dev-team/dev-ops/github-commit-agent.md +1 -1
  74. package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +97 -0
  75. package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +20 -1
  76. package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +97 -0
  77. package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +110 -13
  78. package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +106 -15
  79. package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +115 -11
  80. package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +94 -7
  81. package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +87 -9
  82. package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +85 -7
  83. package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +160 -28
  84. package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +101 -19
  85. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +108 -14
  86. package/claude-assets/agents/cfn-dev-team/reviewers/{reviewer.md → code-reviewer.md} +95 -8
  87. package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +107 -7
  88. package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +98 -7
  89. package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +95 -7
  90. package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +136 -9
  91. package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +108 -1
  92. package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +107 -13
  93. package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +737 -0
  94. package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +1 -1
  95. package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +828 -0
  96. package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +106 -7
  97. package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +77 -0
  98. package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +684 -0
  99. package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +110 -1
  100. package/claude-assets/agents/cfn-dev-team/testers/tester.md +94 -7
  101. package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +1 -3
  102. package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +87 -13
  103. package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +103 -7
  104. package/claude-assets/agents/cfn-dev-team/utility/researcher.md +1 -3
  105. package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +94 -7
  106. package/claude-assets/agents/docker-coordinators/cfn-docker-v3-coordinator.md +46 -0
  107. package/claude-assets/agents/project-only-agents/npm-package-specialist.md +1 -1
  108. package/claude-assets/cfn-extras/skills/advanced-features/cfn-agent-swap/recommend-swap.sh +59 -59
  109. package/claude-assets/cfn-extras/skills/analytics/cfn-improvement-recommender/recommend-improvements.sh +91 -91
  110. package/claude-assets/cfn-extras/skills/analytics/cfn-pattern-extraction/extract-patterns.sh +79 -79
  111. package/claude-assets/cfn-extras/skills/analytics/cfn-retrospective-report/generate-report.sh +100 -100
  112. package/claude-assets/cfn-extras/skills/analytics/cfn-telemetry/start-telemetry.sh +110 -110
  113. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/add-bullet.sh +145 -145
  114. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/log-merge.sh +67 -67
  115. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/monitor-injection-performance.sh +137 -137
  116. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/optimize-injection-pipeline.sh +168 -168
  117. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/query-reflections.sh +35 -35
  118. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/store-reflection.sh +45 -45
  119. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/track-ab-test.sh +41 -41
  120. package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/update-reflection.sh +41 -41
  121. package/claude-assets/cfn-extras/skills/deprecated/cfn-cli-setup/validate-cli-environment.sh +191 -191
  122. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/create-campaign.sh +231 -231
  123. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/get-campaign-performance.sh +190 -190
  124. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/pause-campaign.sh +142 -142
  125. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/set-budget.sh +181 -181
  126. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/update-bid-strategy.sh +133 -133
  127. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/get-conversation-history.sh +121 -121
  128. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/qualify-lead.sh +156 -156
  129. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/schedule-demo.sh +181 -181
  130. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/send-message.sh +137 -137
  131. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/transfer-to-human.sh +179 -179
  132. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/create-campaign.sh +183 -183
  133. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/get-delivery-status.sh +139 -139
  134. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/opt-out.sh +150 -150
  135. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/schedule-campaign.sh +187 -187
  136. package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/send-sms.sh +181 -181
  137. package/claude-assets/cfn-extras/skills/ui-portal/cfn-web-portal/test-web-portal-skill.sh +50 -50
  138. package/claude-assets/cfn-extras/skills/ui-portal/cfn-web-portal/validate-deployment.sh +84 -84
  139. package/claude-assets/cfn-extras/skills/utility/cfn-environment-sanitization/sanitize-environment.sh +243 -243
  140. package/claude-assets/commands/cfn-loop-cli.md +16 -2
  141. package/claude-assets/commands/switch-api.md +31 -10
  142. package/claude-assets/hooks/cfn-lint-sql-injection.sh +61 -0
  143. package/claude-assets/hooks/cfn-post-edit-cfn-retrospective.sh +33 -2
  144. package/claude-assets/hooks/cfn-pre-edit-security-warning.sh +40 -0
  145. package/claude-assets/hooks/detect-hardcoded-credentials.sh +212 -0
  146. package/claude-assets/skills/SKILL_TEMPLATE.md +774 -0
  147. package/claude-assets/skills/agent-lifecycle/execute-lifecycle-hook.sh +84 -113
  148. package/claude-assets/skills/agent-lifecycle/simple-audit.sh +33 -6
  149. package/claude-assets/skills/agent-template-generator/SKILL.md +440 -0
  150. package/claude-assets/skills/agent-template-generator/generate-agent.sh +405 -0
  151. package/claude-assets/skills/agent-validation-linter/SKILL.md +589 -0
  152. package/claude-assets/skills/agent-validation-linter/lint-agents.sh +271 -0
  153. package/claude-assets/skills/bootstrap/bash-fundamentals.md +786 -0
  154. package/claude-assets/skills/bootstrap/database-connection.md +464 -0
  155. package/claude-assets/skills/bootstrap/error-handling.md +580 -0
  156. package/claude-assets/skills/bootstrap/file-operations.md +699 -0
  157. package/claude-assets/skills/bootstrap/skill-loader.md +616 -0
  158. package/claude-assets/skills/bootstrap/sqlite-params.sh +287 -0
  159. package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +22 -24
  160. package/claude-assets/skills/cfn-automatic-memory-persistence/test-memory-persistence.sh +17 -16
  161. package/claude-assets/skills/cfn-deployment/SKILL.md +293 -0
  162. package/claude-assets/skills/cfn-deployment/execute.sh +21 -0
  163. package/claude-assets/skills/cfn-docker-agent-spawning/SKILL.md +28 -4
  164. package/claude-assets/skills/cfn-docker-agent-spawning/spawn-agent.sh +3 -1
  165. package/claude-assets/skills/cfn-docker-loop-orchestration/orchestrate.sh +224 -20
  166. package/claude-assets/skills/cfn-environment-sanitization/sanitize-environment.sh +38 -0
  167. package/claude-assets/skills/cfn-error-batching-strategy/lib/core-functions.sh +47 -47
  168. package/claude-assets/skills/cfn-file-operations/SKILL.md +290 -0
  169. package/claude-assets/skills/cfn-file-operations/execute.sh +129 -0
  170. package/claude-assets/skills/cfn-file-operations/lib/atomic-write.sh +294 -0
  171. package/claude-assets/skills/cfn-file-operations/lib/lock.sh +361 -0
  172. package/claude-assets/skills/cfn-file-operations/test.sh +369 -0
  173. package/claude-assets/skills/cfn-log-operations/SKILL.md +308 -0
  174. package/claude-assets/skills/cfn-log-operations/execute.sh +420 -0
  175. package/claude-assets/skills/cfn-log-operations/lib/rotate.sh +406 -0
  176. package/claude-assets/skills/cfn-log-operations/lib/search.sh +448 -0
  177. package/claude-assets/skills/cfn-log-operations/test.sh +394 -0
  178. package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +550 -46
  179. package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +277 -0
  180. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +184 -23
  181. package/claude-assets/skills/cfn-loop-orchestration/security_utils.sh +24 -0
  182. package/claude-assets/skills/cfn-loop-orchestration/test-iteration-context-injection.sh +366 -0
  183. package/claude-assets/skills/cfn-parameterized-queries/SKILL.md +339 -0
  184. package/claude-assets/skills/cfn-playbook/query-playbook.sh +19 -15
  185. package/claude-assets/skills/cfn-playbook/update-playbook.sh +25 -14
  186. package/claude-assets/skills/cfn-process-instrumentation/instrument-process.sh +44 -0
  187. package/claude-assets/skills/cfn-promotion/SKILL.md +305 -0
  188. package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +319 -0
  189. package/claude-assets/skills/cfn-redis-coordination/agent-log.sh +4 -0
  190. package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +124 -0
  191. package/claude-assets/skills/cfn-redis-coordination/agent-recovery.sh +2 -2
  192. package/claude-assets/skills/cfn-redis-coordination/collect-confidence-scores.sh +30 -0
  193. package/claude-assets/skills/cfn-redis-coordination/get-context.sh +33 -0
  194. package/claude-assets/skills/cfn-redis-coordination/get-success-criteria.sh +54 -0
  195. package/claude-assets/skills/cfn-redis-coordination/invoke-waiting-mode.sh +3 -0
  196. package/claude-assets/skills/cfn-redis-coordination/redis-cli-wrapper.sh +24 -3
  197. package/claude-assets/skills/cfn-redis-coordination/redis-functions.sh +33 -0
  198. package/claude-assets/skills/cfn-redis-coordination/report-completion.sh +24 -31
  199. package/claude-assets/skills/cfn-redis-coordination/store-context.sh +4 -0
  200. package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +85 -0
  201. package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +67 -0
  202. package/claude-assets/skills/cfn-skill-loader/SKILL.md +466 -0
  203. package/claude-assets/skills/cfn-skill-loader/execute.sh +344 -0
  204. package/claude-assets/skills/cfn-sqlite-memory/ttl-cleanup.sh +17 -25
  205. package/claude-assets/skills/cfn-task-audit/get-audit-data.sh +42 -21
  206. package/claude-assets/skills/cfn-task-audit/store-task-audit.sh +17 -10
  207. package/claude-assets/skills/cfn-test-runner/detect-regressions.sh +17 -14
  208. package/claude-assets/skills/cfn-test-runner/detect-regressions.sh.backup-1763392821 +55 -0
  209. package/claude-assets/skills/cfn-test-runner/store-benchmarks.sh +17 -19
  210. package/claude-assets/skills/cfn-transparency-middleware/test-e2e.sh +15 -0
  211. package/claude-assets/skills/cfn-transparency-middleware/tests/input-validation.sh +15 -0
  212. package/claude-assets/skills/cfn-utilities/SKILL.md +237 -0
  213. package/claude-assets/skills/cfn-utilities/execute.sh +32 -0
  214. package/claude-assets/skills/cfn-utilities/lib/errors.sh +56 -0
  215. package/claude-assets/skills/cfn-utilities/lib/file-ops.sh +164 -0
  216. package/claude-assets/skills/cfn-utilities/lib/logging.sh +77 -0
  217. package/claude-assets/skills/cfn-utilities/lib/retry.sh +127 -0
  218. package/claude-assets/skills/cfn-utilities/test.sh +317 -0
  219. package/claude-assets/skills/integration/agent-handoff.sh +62 -64
  220. package/claude-assets/skills/json-validation/SKILL.md +431 -0
  221. package/claude-assets/skills/json-validation/test-validate-success-criteria.sh +421 -0
  222. package/claude-assets/skills/json-validation/validate-success-criteria.sh +197 -0
  223. package/claude-assets/skills/redis-coordination/validate-parameters.sh +34 -0
  224. package/claude-assets/skills/workflow-codification/DEPLOY_QUICK_REFERENCE.md +106 -0
  225. package/claude-assets/skills/workflow-codification/PROPAGATE_UPDATE_QUICK_REFERENCE.md +366 -0
  226. package/claude-assets/skills/workflow-codification/deploy-approved-skill.sh +481 -0
  227. package/claude-assets/skills/workflow-codification/deploy-approved-skill.sh.backup-1763392820 +512 -0
  228. package/claude-assets/skills/workflow-codification/lib/security-utils.sh +204 -0
  229. package/claude-assets/skills/workflow-codification/propagate-skill-update.sh +648 -0
  230. package/claude-assets/skills/workflow-codification/propagate-skill-update.sh.backup-1763392820 +664 -0
  231. package/claude-assets/skills/workflow-codification/test-integration.sh +15 -0
  232. package/claude-assets/skills/workflow-codification/test-metadata-update.sh +350 -0
  233. package/claude-assets/skills/workflow-codification/track-cost-savings.sh +55 -14
  234. package/claude-assets/skills/workflow-codification/track-cost-savings.sh.backup-1763392821 +445 -0
  235. package/claude-assets/skills/workflow-codification/track-edge-case.sh +27 -60
  236. package/claude-assets/skills/workflow-codification/workflow-codification.db +0 -0
  237. package/dist/ace/ace-curator.js +10 -2
  238. package/dist/ace/ace-curator.js.map +1 -1
  239. package/dist/ace/ace-generator.js +4 -0
  240. package/dist/ace/ace-generator.js.map +1 -1
  241. package/dist/ace/ace-reflector.js +1 -1
  242. package/dist/ace/ace-reflector.js.map +1 -1
  243. package/dist/ace/context-injection.js +24 -2
  244. package/dist/ace/context-injection.js.map +1 -1
  245. package/dist/agents/agent-loader.js +146 -165
  246. package/dist/agents/agent-loader.js.map +1 -1
  247. package/dist/agents/task-agent-integration.js +1 -1
  248. package/dist/agents/task-agent-integration.js.map +1 -1
  249. package/dist/api/health-endpoints.js +390 -0
  250. package/dist/api/health-endpoints.js.map +1 -0
  251. package/dist/cli/agent-executor.js +4 -1
  252. package/dist/cli/agent-executor.js.map +1 -1
  253. package/dist/cli/agent-prompt-builder.js +89 -1
  254. package/dist/cli/agent-prompt-builder.js.map +1 -1
  255. package/dist/cli/agent-spawn.js +130 -37
  256. package/dist/cli/agent-spawn.js.map +1 -1
  257. package/dist/cli/skill-cache-validator.js +412 -0
  258. package/dist/cli/skill-cache-validator.js.map +1 -0
  259. package/dist/cli/skill-cli.js +991 -0
  260. package/dist/cli/skill-cli.js.map +1 -0
  261. package/dist/cli/skill-execution-logger.js +284 -0
  262. package/dist/cli/skill-execution-logger.js.map +1 -0
  263. package/dist/cli/skill-loader.js +457 -0
  264. package/dist/cli/skill-loader.js.map +1 -0
  265. package/dist/coordination/event-bus.js +2 -2
  266. package/dist/coordination/event-bus.js.map +1 -1
  267. package/dist/coordination/fleet-manager.js +1 -1
  268. package/dist/coordination/fleet-manager.js.map +1 -1
  269. package/dist/coordination/index.js +23 -9
  270. package/dist/coordination/index.js.map +1 -1
  271. package/dist/coordination/types/fleet-manager.types.js.map +1 -1
  272. package/dist/db/migration-manager.js +483 -0
  273. package/dist/db/migration-manager.js.map +1 -0
  274. package/dist/db/skills-query.js +535 -0
  275. package/dist/db/skills-query.js.map +1 -0
  276. package/dist/integration/DatabaseHandoff.js +1 -1
  277. package/dist/integration/DatabaseHandoff.js.map +1 -1
  278. package/dist/jobs/edge-case-analyzer.js +367 -0
  279. package/dist/jobs/edge-case-analyzer.js.map +1 -0
  280. package/dist/jobs/promotion-sla-enforcer.js +288 -0
  281. package/dist/jobs/promotion-sla-enforcer.js.map +1 -0
  282. package/dist/lib/agent-output-parser.js.map +1 -1
  283. package/dist/lib/agent-output-validator.js.map +1 -1
  284. package/dist/lib/agent-workspace.js +281 -0
  285. package/dist/lib/agent-workspace.js.map +1 -0
  286. package/dist/lib/atomic-file-writer.js +377 -0
  287. package/dist/lib/atomic-file-writer.js.map +1 -0
  288. package/dist/lib/backup-manager.js +779 -0
  289. package/dist/lib/backup-manager.js.map +1 -0
  290. package/dist/lib/checkpoint-manager.js +837 -0
  291. package/dist/lib/checkpoint-manager.js.map +1 -0
  292. package/dist/lib/circuit-breaker.js +340 -0
  293. package/dist/lib/circuit-breaker.js.map +1 -0
  294. package/dist/lib/completion-signal-handler.js +243 -0
  295. package/dist/lib/completion-signal-handler.js.map +1 -0
  296. package/dist/lib/config-manager.js +312 -0
  297. package/dist/lib/config-manager.js.map +1 -0
  298. package/dist/lib/config-migrator.js +386 -0
  299. package/dist/lib/config-migrator.js.map +1 -0
  300. package/dist/lib/config-validator.js.map +1 -1
  301. package/dist/lib/correlation-cache.js +311 -0
  302. package/dist/lib/correlation-cache.js.map +1 -0
  303. package/dist/lib/correlation.js +263 -0
  304. package/dist/lib/correlation.js.map +1 -0
  305. package/dist/lib/database-service/connection-pool-manager.js +520 -0
  306. package/dist/lib/database-service/connection-pool-manager.js.map +1 -0
  307. package/dist/lib/database-service/correlation.js +329 -0
  308. package/dist/lib/database-service/correlation.js.map +1 -0
  309. package/dist/lib/database-service/errors.js +120 -0
  310. package/dist/lib/database-service/errors.js.map +1 -0
  311. package/dist/lib/database-service/index.js +168 -0
  312. package/dist/lib/database-service/index.js.map +1 -0
  313. package/dist/lib/database-service/postgres-adapter.js +526 -0
  314. package/dist/lib/database-service/postgres-adapter.js.map +1 -0
  315. package/dist/lib/database-service/redis-adapter.js +360 -0
  316. package/dist/lib/database-service/redis-adapter.js.map +1 -0
  317. package/dist/lib/database-service/sqlite-adapter.js +544 -0
  318. package/dist/lib/database-service/sqlite-adapter.js.map +1 -0
  319. package/dist/lib/database-service/transaction-manager.js +773 -0
  320. package/dist/lib/database-service/transaction-manager.js.map +1 -0
  321. package/dist/lib/database-service/types.js +23 -0
  322. package/dist/lib/database-service/types.js.map +1 -0
  323. package/dist/lib/deadlock-resolver.js +292 -0
  324. package/dist/lib/deadlock-resolver.js.map +1 -0
  325. package/dist/lib/distributed-lock.js +451 -0
  326. package/dist/lib/distributed-lock.js.map +1 -0
  327. package/dist/lib/edge-case-deduplicator.js +227 -0
  328. package/dist/lib/edge-case-deduplicator.js.map +1 -0
  329. package/dist/lib/encryption-manager.js +322 -0
  330. package/dist/lib/encryption-manager.js.map +1 -0
  331. package/dist/lib/error-aggregator.js +234 -0
  332. package/dist/lib/error-aggregator.js.map +1 -0
  333. package/dist/lib/errors.js +287 -0
  334. package/dist/lib/errors.js.map +1 -0
  335. package/dist/lib/file-lock-manager.js +578 -0
  336. package/dist/lib/file-lock-manager.js.map +1 -0
  337. package/dist/lib/file-operations.js +367 -0
  338. package/dist/lib/file-operations.js.map +1 -0
  339. package/dist/lib/idempotent-write.js +237 -0
  340. package/dist/lib/idempotent-write.js.map +1 -0
  341. package/dist/lib/integration-schema-validator.js +522 -0
  342. package/dist/lib/integration-schema-validator.js.map +1 -0
  343. package/dist/lib/lock-health-monitor.js +298 -0
  344. package/dist/lib/lock-health-monitor.js.map +1 -0
  345. package/dist/lib/log-shipper.js +422 -0
  346. package/dist/lib/log-shipper.js.map +1 -0
  347. package/dist/lib/logging.js +146 -0
  348. package/dist/lib/logging.js.map +1 -0
  349. package/dist/lib/message-deduplicator.js +439 -0
  350. package/dist/lib/message-deduplicator.js.map +1 -0
  351. package/dist/lib/multi-system-query.js +604 -0
  352. package/dist/lib/multi-system-query.js.map +1 -0
  353. package/dist/lib/orphan-detector.js +332 -0
  354. package/dist/lib/orphan-detector.js.map +1 -0
  355. package/dist/lib/password-generator.js +166 -0
  356. package/dist/lib/password-generator.js.map +1 -0
  357. package/dist/lib/path-validator.js +429 -0
  358. package/dist/lib/path-validator.js.map +1 -0
  359. package/dist/lib/query-translator.js +905 -0
  360. package/dist/lib/query-translator.js.map +1 -0
  361. package/dist/lib/queue-recovery.js +469 -0
  362. package/dist/lib/queue-recovery.js.map +1 -0
  363. package/dist/lib/redis-queue-manager.js +512 -0
  364. package/dist/lib/redis-queue-manager.js.map +1 -0
  365. package/dist/lib/reflection-archiver.js +272 -0
  366. package/dist/lib/reflection-archiver.js.map +1 -0
  367. package/dist/lib/retry-manager.js +453 -0
  368. package/dist/lib/retry-manager.js.map +1 -0
  369. package/dist/lib/retry.js +262 -0
  370. package/dist/lib/retry.js.map +1 -0
  371. package/dist/lib/schema-transform.js +695 -0
  372. package/dist/lib/schema-transform.js.map +1 -0
  373. package/dist/lib/schema-validator.js +491 -0
  374. package/dist/lib/schema-validator.js.map +1 -0
  375. package/dist/lib/skill-cache.js +297 -0
  376. package/dist/lib/skill-cache.js.map +1 -0
  377. package/dist/lib/skill-content-manager.js +337 -0
  378. package/dist/lib/skill-content-manager.js.map +1 -0
  379. package/dist/lib/skill-frontmatter-parser.js +237 -0
  380. package/dist/lib/skill-frontmatter-parser.js.map +1 -0
  381. package/dist/lib/skill-git-integration.js +275 -0
  382. package/dist/lib/skill-git-integration.js.map +1 -0
  383. package/dist/lib/skill-markdown-validator.js +396 -0
  384. package/dist/lib/skill-markdown-validator.js.map +1 -0
  385. package/dist/lib/skill-output-parser.js +312 -0
  386. package/dist/lib/skill-output-parser.js.map +1 -0
  387. package/dist/lib/unified-query-api.js +467 -0
  388. package/dist/lib/unified-query-api.js.map +1 -0
  389. package/dist/middleware/auth-middleware.js +350 -0
  390. package/dist/middleware/auth-middleware.js.map +1 -0
  391. package/dist/middleware/schema-validation.js +347 -0
  392. package/dist/middleware/schema-validation.js.map +1 -0
  393. package/dist/providers/anthropic-provider.js +1 -1
  394. package/dist/providers/anthropic-provider.js.map +1 -1
  395. package/dist/providers/provider-factory.js +2 -2
  396. package/dist/providers/provider-factory.js.map +1 -1
  397. package/dist/services/edge-case-analyzer.js +321 -0
  398. package/dist/services/edge-case-analyzer.js.map +1 -0
  399. package/dist/services/edge-case-deduplicator.js +266 -0
  400. package/dist/services/edge-case-deduplicator.js.map +1 -0
  401. package/dist/services/edge-case-detector.js +337 -0
  402. package/dist/services/edge-case-detector.js.map +1 -0
  403. package/dist/services/edge-case-tracker.js +547 -0
  404. package/dist/services/edge-case-tracker.js.map +1 -0
  405. package/dist/services/health-check-system.js +586 -0
  406. package/dist/services/health-check-system.js.map +1 -0
  407. package/dist/services/metrics-logger.js +412 -0
  408. package/dist/services/metrics-logger.js.map +1 -0
  409. package/dist/services/patch-generator.js +378 -0
  410. package/dist/services/patch-generator.js.map +1 -0
  411. package/dist/services/patch-validator.js +337 -0
  412. package/dist/services/patch-validator.js.map +1 -0
  413. package/dist/services/performance-monitor.js +811 -0
  414. package/dist/services/performance-monitor.js.map +1 -0
  415. package/dist/services/promotion-pipeline.js +918 -0
  416. package/dist/services/promotion-pipeline.js.map +1 -0
  417. package/dist/services/promotion-validator.js +394 -0
  418. package/dist/services/promotion-validator.js.map +1 -0
  419. package/dist/services/reflection-logger.js +388 -0
  420. package/dist/services/reflection-logger.js.map +1 -0
  421. package/dist/services/skill-deployment.js +472 -0
  422. package/dist/services/skill-deployment.js.map +1 -0
  423. package/dist/services/skill-loader.js +427 -0
  424. package/dist/services/skill-loader.js.map +1 -0
  425. package/dist/services/skill-promotion.js +372 -0
  426. package/dist/services/skill-promotion.js.map +1 -0
  427. package/dist/services/skill-validator.js +454 -0
  428. package/dist/services/skill-validator.js.map +1 -0
  429. package/dist/services/skill-versioning.js +244 -0
  430. package/dist/services/skill-versioning.js.map +1 -0
  431. package/dist/services/workspace-supervisor.js +597 -0
  432. package/dist/services/workspace-supervisor.js.map +1 -0
  433. package/dist/types/edge-case.js +45 -0
  434. package/dist/types/edge-case.js.map +1 -0
  435. package/package.json +201 -177
  436. package/readme/README.md +19 -4
  437. package/scripts/backup-cleanup.sh +627 -0
  438. package/scripts/cleanup-workspaces.sh +412 -0
  439. package/scripts/cleanup-yaml-configs.sh +141 -0
  440. package/scripts/deploy-approved-skills.sh +263 -0
  441. package/scripts/health-check.sh +447 -0
  442. package/scripts/log-aggregator.sh +554 -0
  443. package/scripts/log-monitor.sh +629 -0
  444. package/scripts/manage-agent-workspaces.sh +434 -0
  445. package/scripts/migrate-schema.sh +533 -0
  446. package/scripts/promote-staged-skills.sh +423 -0
  447. package/scripts/verify-no-secrets.sh +88 -35
  448. package/.claude/cfn-extras/agents/deprecated-coordinators/adaptive-coordinator.md.backup +0 -161
  449. package/.claude/cfn-extras/agents/deprecated-coordinators/blocking-coordinator-example.md.backup +0 -728
  450. package/.claude/cfn-extras/agents/deprecated-coordinators/mesh-coordinator.md.backup +0 -131
  451. package/.claude/skills/agent-lifecycle/SKILL.md +0 -60
  452. package/.claude/skills/agent-lifecycle/execute-lifecycle-hook.sh +0 -573
  453. package/.claude/skills/agent-lifecycle/simple-audit.sh +0 -31
  454. package/.claude/skills/cfn-agent-spawning/spawn-agent.sh.backup +0 -273
  455. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.backup +0 -949
  456. package/README.md.backup_before_replace +0 -781
  457. package/claude-assets/cfn-extras/agents/deprecated-coordinators/adaptive-coordinator.md.backup +0 -161
  458. package/claude-assets/cfn-extras/agents/deprecated-coordinators/blocking-coordinator-example.md.backup +0 -728
  459. package/claude-assets/cfn-extras/agents/deprecated-coordinators/mesh-coordinator.md.backup +0 -131
  460. package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh.backup +0 -273
  461. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh.backup +0 -949
@@ -0,0 +1,378 @@
1
+ /**
2
+ * Patch Generator
3
+ * Part of Task 5.1: Edge Case Analyzer & Skill Patcher
4
+ *
5
+ * Generates simple patch templates for common failure patterns.
6
+ * Phase 1 supports basic patches: error handling, null checks, type validation, timeouts, file checks.
7
+ *
8
+ * Features:
9
+ * - Simple patch template generation
10
+ * - Confidence calculation (≥0.85 threshold)
11
+ * - Patch preview generation
12
+ * - Integration with DatabaseService
13
+ * - PENDING_UPDATE status for manual approval
14
+ * - Performance optimized (<1s for patch generation)
15
+ *
16
+ * Usage:
17
+ * const generator = new PatchGenerator({ dbPath: './patches.db' });
18
+ * const patch = generator.generatePatch(failure, category);
19
+ * if (patch.confidence >= 0.85) {
20
+ * const proposal = await generator.createPatchProposal(patch);
21
+ * }
22
+ */ import * as crypto from 'crypto';
23
+ import Database from 'better-sqlite3';
24
+ import { createLogger } from '../lib/logging.js';
25
+ import { ErrorCode, createError } from '../lib/errors.js';
26
+ import { FailureCategory } from './edge-case-analyzer.js';
27
+ const logger = createLogger('patch-generator');
28
+ /**
29
+ * Patch type classification
30
+ */ export var PatchType = /*#__PURE__*/ function(PatchType) {
31
+ PatchType["ADD_ERROR_HANDLING"] = "ADD_ERROR_HANDLING";
32
+ PatchType["ADD_NULL_CHECK"] = "ADD_NULL_CHECK";
33
+ PatchType["ADD_TYPE_VALIDATION"] = "ADD_TYPE_VALIDATION";
34
+ PatchType["ADD_TIMEOUT"] = "ADD_TIMEOUT";
35
+ PatchType["ADD_FILE_CHECK"] = "ADD_FILE_CHECK";
36
+ return PatchType;
37
+ }({});
38
+ /**
39
+ * Patch status
40
+ */ export var PatchStatus = /*#__PURE__*/ function(PatchStatus) {
41
+ PatchStatus["PENDING_UPDATE"] = "PENDING_UPDATE";
42
+ PatchStatus["APPROVED"] = "APPROVED";
43
+ PatchStatus["DEPLOYED"] = "DEPLOYED";
44
+ PatchStatus["REJECTED"] = "REJECTED";
45
+ PatchStatus["ROLLED_BACK"] = "ROLLED_BACK";
46
+ return PatchStatus;
47
+ }({});
48
+ /**
49
+ * Patch Generator Service
50
+ */ export class PatchGenerator {
51
+ db;
52
+ confidenceThreshold;
53
+ constructor(config){
54
+ this.db = new Database(config.dbPath);
55
+ this.confidenceThreshold = config.confidenceThreshold || 0.85;
56
+ this.initializeDatabase();
57
+ }
58
+ /**
59
+ * Initialize database schema
60
+ */ initializeDatabase() {
61
+ this.db.exec(`
62
+ CREATE TABLE IF NOT EXISTS skill_patches (
63
+ id TEXT PRIMARY KEY,
64
+ skill_id TEXT NOT NULL,
65
+ failure_id TEXT NOT NULL,
66
+ category TEXT NOT NULL,
67
+ patch_content TEXT NOT NULL,
68
+ confidence REAL NOT NULL,
69
+ status TEXT DEFAULT 'PENDING_UPDATE',
70
+ created_at TEXT DEFAULT CURRENT_TIMESTAMP,
71
+ approved_by TEXT,
72
+ deployed_at TEXT,
73
+ success INTEGER,
74
+ rollback_reason TEXT
75
+ );
76
+
77
+ CREATE INDEX IF NOT EXISTS idx_skill_patches_skill ON skill_patches(skill_id);
78
+ CREATE INDEX IF NOT EXISTS idx_skill_patches_status ON skill_patches(status);
79
+ CREATE INDEX IF NOT EXISTS idx_skill_patches_confidence ON skill_patches(confidence);
80
+ `);
81
+ }
82
+ /**
83
+ * Parse target file and line from stack trace
84
+ */ parseStackTrace(stackTrace) {
85
+ // Try to extract file and line from stack trace
86
+ // Formats:
87
+ // - at functionName (file.ts:42:10)
88
+ // - at /absolute/path/file.ts:42:10
89
+ // - at functionName (/absolute/path/file.ts:42:10)
90
+ const patterns = [
91
+ /at\s+.*?\(([^:]+):(\d+):\d+\)/,
92
+ /at\s+([^:]+):(\d+):\d+/,
93
+ /\(([^:]+):(\d+):\d+\)/
94
+ ];
95
+ for (const pattern of patterns){
96
+ const match = stackTrace.match(pattern);
97
+ if (match) {
98
+ const file = match[1].trim();
99
+ const line = parseInt(match[2], 10);
100
+ return {
101
+ file,
102
+ line
103
+ };
104
+ }
105
+ }
106
+ return {
107
+ file: 'unknown',
108
+ line: 0
109
+ };
110
+ }
111
+ /**
112
+ * Generate patch for failure
113
+ *
114
+ * Performance target: <1s
115
+ */ generatePatch(failure, category) {
116
+ const startTime = Date.now();
117
+ const { file, line } = this.parseStackTrace(failure.stackTrace);
118
+ let patchType;
119
+ let content;
120
+ // Determine patch type and generate content based on failure category
121
+ if (category === FailureCategory.TIMEOUT) {
122
+ patchType = "ADD_TIMEOUT";
123
+ const timeout = failure.context.timeout || 5000;
124
+ content = `const result = await withTimeout(operation(), ${timeout});`;
125
+ } else if (category === FailureCategory.VALIDATION_ERROR && (failure.errorMessage.includes('null') || failure.errorMessage.includes('undefined'))) {
126
+ patchType = "ADD_NULL_CHECK";
127
+ const variableName = this.extractVariableName(failure.errorMessage);
128
+ content = `if (${variableName} === null || ${variableName} === undefined) {
129
+ throw new StandardError('NULL_VALUE', '${variableName} cannot be null or undefined');
130
+ }`;
131
+ } else if (category === FailureCategory.VALIDATION_ERROR && (failure.errorMessage.includes('Expected') || failure.errorMessage.includes('type'))) {
132
+ patchType = "ADD_TYPE_VALIDATION";
133
+ const expectedType = failure.context.expectedType || 'string';
134
+ const variableName = this.extractVariableName(failure.errorMessage);
135
+ content = `if (typeof ${variableName} !== '${expectedType}') {
136
+ throw new StandardError('INVALID_TYPE', 'Expected ${expectedType} but got ' + typeof ${variableName});
137
+ }`;
138
+ } else if (category === FailureCategory.LOGIC_ERROR && failure.errorMessage.includes('File not found')) {
139
+ patchType = "ADD_FILE_CHECK";
140
+ const filePath = failure.context.filePath || 'filePath';
141
+ content = `if (!fs.existsSync(${filePath})) {
142
+ throw new StandardError('FILE_NOT_FOUND', \`File not found: \${${filePath}}\`);
143
+ }`;
144
+ } else {
145
+ // Default to error handling
146
+ patchType = "ADD_ERROR_HANDLING";
147
+ const operation = failure.context.operation || 'operation';
148
+ content = `try {
149
+ // existing code for ${operation}
150
+ } catch (error) {
151
+ logger.error('${operation} failed', error);
152
+ throw new StandardError('OPERATION_FAILED', '${operation} failed', {}, error);
153
+ }`;
154
+ }
155
+ const patch = {
156
+ id: crypto.randomUUID(),
157
+ failureId: failure.id,
158
+ skillId: failure.skillId,
159
+ type: patchType,
160
+ category,
161
+ content,
162
+ targetFile: file,
163
+ targetLine: line,
164
+ confidence: 0,
165
+ similarFailureCount: 0
166
+ };
167
+ logger.debug('Patch generated', {
168
+ patchType,
169
+ targetFile: file,
170
+ targetLine: line,
171
+ durationMs: Date.now() - startTime
172
+ });
173
+ return patch;
174
+ }
175
+ /**
176
+ * Extract variable name from error message
177
+ */ extractVariableName(errorMessage) {
178
+ // Try to extract variable name from error messages like:
179
+ // - "Cannot read property 'x' of null"
180
+ // - "userData is null"
181
+ // - "Expected string but got number for field"
182
+ const patterns = [
183
+ /Cannot read property.*?of (\w+)/,
184
+ /(\w+) is (null|undefined)/,
185
+ /for (\w+)/,
186
+ /(\w+) cannot be/
187
+ ];
188
+ for (const pattern of patterns){
189
+ const match = errorMessage.match(pattern);
190
+ if (match && match[1] !== 'null' && match[1] !== 'undefined') {
191
+ return match[1];
192
+ }
193
+ }
194
+ return 'value';
195
+ }
196
+ /**
197
+ * Calculate patch confidence
198
+ *
199
+ * Factors:
200
+ * - Number of similar failures (higher = more confident)
201
+ * - Patch type (some types are more reliable)
202
+ * - Category (some categories are easier to fix)
203
+ *
204
+ * Threshold: ≥0.85 for auto-approval consideration
205
+ */ calculatePatchConfidence(patch) {
206
+ let confidence = 0.5; // Base confidence
207
+ // Similar failure count boost (up to +0.4)
208
+ const failureBoost = Math.min(0.4, patch.similarFailureCount * 0.04);
209
+ confidence += failureBoost;
210
+ // Patch type boost
211
+ if (patch.type === "ADD_ERROR_HANDLING" || patch.type === "ADD_NULL_CHECK") {
212
+ confidence += 0.1; // These are generally safe
213
+ }
214
+ if (patch.type === "ADD_FILE_CHECK" || patch.type === "ADD_TIMEOUT") {
215
+ confidence += 0.05; // Moderately safe
216
+ }
217
+ // Category boost
218
+ if (patch.category === FailureCategory.VALIDATION_ERROR) {
219
+ confidence += 0.05; // Validation fixes are usually straightforward
220
+ }
221
+ return Math.min(0.98, confidence);
222
+ }
223
+ /**
224
+ * Create patch proposal (requires confidence ≥ threshold)
225
+ */ async createPatchProposal(patch) {
226
+ const startTime = Date.now();
227
+ // Calculate confidence if not set
228
+ if (patch.confidence === 0) {
229
+ patch.confidence = this.calculatePatchConfidence(patch);
230
+ }
231
+ // Enforce confidence threshold
232
+ if (patch.confidence < this.confidenceThreshold) {
233
+ throw createError(ErrorCode.VALIDATION_FAILED, `Patch confidence ${patch.confidence.toFixed(2)} below threshold ${this.confidenceThreshold}`, {
234
+ patchId: patch.id,
235
+ confidence: patch.confidence
236
+ });
237
+ }
238
+ // Generate preview
239
+ const preview = this.generatePatchPreview(patch);
240
+ // Store in database
241
+ this.db.prepare(`
242
+ INSERT INTO skill_patches (id, skill_id, failure_id, category, patch_content, confidence, status)
243
+ VALUES (?, ?, ?, ?, ?, ?, ?)
244
+ `).run(patch.id, patch.skillId, patch.failureId, patch.category, patch.content, patch.confidence, "PENDING_UPDATE");
245
+ const proposal = {
246
+ patch,
247
+ status: "PENDING_UPDATE",
248
+ createdAt: new Date(),
249
+ preview
250
+ };
251
+ logger.info('Patch proposal created', {
252
+ patchId: patch.id,
253
+ confidence: patch.confidence,
254
+ status: "PENDING_UPDATE",
255
+ durationMs: Date.now() - startTime
256
+ });
257
+ return proposal;
258
+ }
259
+ /**
260
+ * Generate human-readable patch preview
261
+ */ generatePatchPreview(patch) {
262
+ return `
263
+ Patch Preview
264
+ =============
265
+ ID: ${patch.id}
266
+ Type: ${patch.type}
267
+ Category: ${patch.category}
268
+ Skill: ${patch.skillId}
269
+ Confidence: ${patch.confidence.toFixed(2)}
270
+
271
+ Target:
272
+ File: ${patch.targetFile}
273
+ Line: ${patch.targetLine}
274
+
275
+ Patch Content:
276
+ ${patch.content.split('\n').map((line)=>' ' + line).join('\n')}
277
+
278
+ Similar Failures: ${patch.similarFailureCount}
279
+ Status: Pending Manual Approval
280
+ `.trim();
281
+ }
282
+ /**
283
+ * Get patch proposal by ID
284
+ */ getPatchProposal(patchId) {
285
+ const stmt = this.db.prepare('SELECT * FROM skill_patches WHERE id = ?');
286
+ const row = stmt.get(patchId);
287
+ if (!row) {
288
+ return undefined;
289
+ }
290
+ const patch = {
291
+ id: row.id,
292
+ failureId: row.failure_id,
293
+ skillId: row.skill_id,
294
+ type: row.category,
295
+ category: row.category,
296
+ content: row.patch_content,
297
+ targetFile: '',
298
+ targetLine: 0,
299
+ confidence: row.confidence,
300
+ similarFailureCount: 0
301
+ };
302
+ const proposal = {
303
+ patch,
304
+ status: row.status,
305
+ createdAt: new Date(row.created_at),
306
+ preview: this.generatePatchPreview(patch),
307
+ approvedBy: row.approved_by,
308
+ deployedAt: row.deployed_at ? new Date(row.deployed_at) : undefined,
309
+ success: row.success !== null ? Boolean(row.success) : undefined,
310
+ rollbackReason: row.rollback_reason
311
+ };
312
+ return proposal;
313
+ }
314
+ /**
315
+ * Get pending patches (optionally filtered by skill)
316
+ */ getPendingPatches(skillId) {
317
+ let query = `
318
+ SELECT * FROM skill_patches
319
+ WHERE status = 'PENDING_UPDATE'
320
+ `;
321
+ const params = [];
322
+ if (skillId) {
323
+ query += ' AND skill_id = ?';
324
+ params.push(skillId);
325
+ }
326
+ query += ' ORDER BY confidence DESC';
327
+ const stmt = this.db.prepare(query);
328
+ const rows = stmt.all(...params);
329
+ return rows.map((row)=>{
330
+ const patch = {
331
+ id: row.id,
332
+ failureId: row.failure_id,
333
+ skillId: row.skill_id,
334
+ type: this.inferPatchType(row.patch_content),
335
+ category: row.category,
336
+ content: row.patch_content,
337
+ targetFile: '',
338
+ targetLine: 0,
339
+ confidence: row.confidence,
340
+ similarFailureCount: 0
341
+ };
342
+ return {
343
+ patch,
344
+ status: row.status,
345
+ createdAt: new Date(row.created_at),
346
+ preview: this.generatePatchPreview(patch),
347
+ approvedBy: row.approved_by,
348
+ deployedAt: row.deployed_at ? new Date(row.deployed_at) : undefined,
349
+ success: row.success !== null ? Boolean(row.success) : undefined,
350
+ rollbackReason: row.rollback_reason
351
+ };
352
+ });
353
+ }
354
+ /**
355
+ * Infer patch type from content
356
+ */ inferPatchType(content) {
357
+ if (content.includes('withTimeout')) {
358
+ return "ADD_TIMEOUT";
359
+ }
360
+ if (content.includes('null') || content.includes('undefined')) {
361
+ return "ADD_NULL_CHECK";
362
+ }
363
+ if (content.includes('typeof')) {
364
+ return "ADD_TYPE_VALIDATION";
365
+ }
366
+ if (content.includes('fs.existsSync')) {
367
+ return "ADD_FILE_CHECK";
368
+ }
369
+ return "ADD_ERROR_HANDLING";
370
+ }
371
+ /**
372
+ * Close database connection
373
+ */ close() {
374
+ this.db.close();
375
+ }
376
+ }
377
+
378
+ //# sourceMappingURL=patch-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/services/patch-generator.ts"],"sourcesContent":["/**\r\n * Patch Generator\r\n * Part of Task 5.1: Edge Case Analyzer & Skill Patcher\r\n *\r\n * Generates simple patch templates for common failure patterns.\r\n * Phase 1 supports basic patches: error handling, null checks, type validation, timeouts, file checks.\r\n *\r\n * Features:\r\n * - Simple patch template generation\r\n * - Confidence calculation (≥0.85 threshold)\r\n * - Patch preview generation\r\n * - Integration with DatabaseService\r\n * - PENDING_UPDATE status for manual approval\r\n * - Performance optimized (<1s for patch generation)\r\n *\r\n * Usage:\r\n * const generator = new PatchGenerator({ dbPath: './patches.db' });\r\n * const patch = generator.generatePatch(failure, category);\r\n * if (patch.confidence >= 0.85) {\r\n * const proposal = await generator.createPatchProposal(patch);\r\n * }\r\n */\r\n\r\nimport * as crypto from 'crypto';\r\nimport Database from 'better-sqlite3';\r\nimport { createLogger } from '../lib/logging.js';\r\nimport { StandardError, ErrorCode, createError } from '../lib/errors.js';\r\nimport { FailureCategory, Failure } from './edge-case-analyzer.js';\r\n\r\nconst logger = createLogger('patch-generator');\r\n\r\n/**\r\n * Patch type classification\r\n */\r\nexport enum PatchType {\r\n ADD_ERROR_HANDLING = 'ADD_ERROR_HANDLING',\r\n ADD_NULL_CHECK = 'ADD_NULL_CHECK',\r\n ADD_TYPE_VALIDATION = 'ADD_TYPE_VALIDATION',\r\n ADD_TIMEOUT = 'ADD_TIMEOUT',\r\n ADD_FILE_CHECK = 'ADD_FILE_CHECK',\r\n}\r\n\r\n/**\r\n * Patch status\r\n */\r\nexport enum PatchStatus {\r\n PENDING_UPDATE = 'PENDING_UPDATE',\r\n APPROVED = 'APPROVED',\r\n DEPLOYED = 'DEPLOYED',\r\n REJECTED = 'REJECTED',\r\n ROLLED_BACK = 'ROLLED_BACK',\r\n}\r\n\r\n/**\r\n * Patch definition\r\n */\r\nexport interface Patch {\r\n id: string;\r\n failureId: string;\r\n skillId: string;\r\n type: PatchType;\r\n category: FailureCategory;\r\n content: string;\r\n targetFile: string;\r\n targetLine: number;\r\n confidence: number;\r\n similarFailureCount: number;\r\n}\r\n\r\n/**\r\n * Patch proposal with metadata\r\n */\r\nexport interface PatchProposal {\r\n patch: Patch;\r\n status: PatchStatus;\r\n createdAt: Date;\r\n preview: string;\r\n approvedBy?: string;\r\n deployedAt?: Date;\r\n success?: boolean;\r\n rollbackReason?: string;\r\n}\r\n\r\n/**\r\n * Generator configuration\r\n */\r\nexport interface PatchGeneratorConfig {\r\n dbPath: string;\r\n confidenceThreshold?: number;\r\n}\r\n\r\n/**\r\n * Patch Generator Service\r\n */\r\nexport class PatchGenerator {\r\n private db: Database.Database;\r\n private confidenceThreshold: number;\r\n\r\n constructor(config: PatchGeneratorConfig) {\r\n this.db = new Database(config.dbPath);\r\n this.confidenceThreshold = config.confidenceThreshold || 0.85;\r\n this.initializeDatabase();\r\n }\r\n\r\n /**\r\n * Initialize database schema\r\n */\r\n private initializeDatabase(): void {\r\n this.db.exec(`\r\n CREATE TABLE IF NOT EXISTS skill_patches (\r\n id TEXT PRIMARY KEY,\r\n skill_id TEXT NOT NULL,\r\n failure_id TEXT NOT NULL,\r\n category TEXT NOT NULL,\r\n patch_content TEXT NOT NULL,\r\n confidence REAL NOT NULL,\r\n status TEXT DEFAULT 'PENDING_UPDATE',\r\n created_at TEXT DEFAULT CURRENT_TIMESTAMP,\r\n approved_by TEXT,\r\n deployed_at TEXT,\r\n success INTEGER,\r\n rollback_reason TEXT\r\n );\r\n\r\n CREATE INDEX IF NOT EXISTS idx_skill_patches_skill ON skill_patches(skill_id);\r\n CREATE INDEX IF NOT EXISTS idx_skill_patches_status ON skill_patches(status);\r\n CREATE INDEX IF NOT EXISTS idx_skill_patches_confidence ON skill_patches(confidence);\r\n `);\r\n }\r\n\r\n /**\r\n * Parse target file and line from stack trace\r\n */\r\n private parseStackTrace(stackTrace: string): { file: string; line: number } {\r\n // Try to extract file and line from stack trace\r\n // Formats:\r\n // - at functionName (file.ts:42:10)\r\n // - at /absolute/path/file.ts:42:10\r\n // - at functionName (/absolute/path/file.ts:42:10)\r\n\r\n const patterns = [\r\n /at\\s+.*?\\(([^:]+):(\\d+):\\d+\\)/, // at func (file:line:col)\r\n /at\\s+([^:]+):(\\d+):\\d+/, // at file:line:col\r\n /\\(([^:]+):(\\d+):\\d+\\)/, // (file:line:col)\r\n ];\r\n\r\n for (const pattern of patterns) {\r\n const match = stackTrace.match(pattern);\r\n if (match) {\r\n const file = match[1].trim();\r\n const line = parseInt(match[2], 10);\r\n return { file, line };\r\n }\r\n }\r\n\r\n return { file: 'unknown', line: 0 };\r\n }\r\n\r\n /**\r\n * Generate patch for failure\r\n *\r\n * Performance target: <1s\r\n */\r\n generatePatch(failure: Failure, category: FailureCategory): Patch {\r\n const startTime = Date.now();\r\n\r\n const { file, line } = this.parseStackTrace(failure.stackTrace);\r\n\r\n let patchType: PatchType;\r\n let content: string;\r\n\r\n // Determine patch type and generate content based on failure category\r\n if (category === FailureCategory.TIMEOUT) {\r\n patchType = PatchType.ADD_TIMEOUT;\r\n const timeout = failure.context.timeout || 5000;\r\n content = `const result = await withTimeout(operation(), ${timeout});`;\r\n } else if (\r\n category === FailureCategory.VALIDATION_ERROR &&\r\n (failure.errorMessage.includes('null') || failure.errorMessage.includes('undefined'))\r\n ) {\r\n patchType = PatchType.ADD_NULL_CHECK;\r\n const variableName = this.extractVariableName(failure.errorMessage);\r\n content = `if (${variableName} === null || ${variableName} === undefined) {\r\n throw new StandardError('NULL_VALUE', '${variableName} cannot be null or undefined');\r\n}`;\r\n } else if (\r\n category === FailureCategory.VALIDATION_ERROR &&\r\n (failure.errorMessage.includes('Expected') || failure.errorMessage.includes('type'))\r\n ) {\r\n patchType = PatchType.ADD_TYPE_VALIDATION;\r\n const expectedType = failure.context.expectedType || 'string';\r\n const variableName = this.extractVariableName(failure.errorMessage);\r\n content = `if (typeof ${variableName} !== '${expectedType}') {\r\n throw new StandardError('INVALID_TYPE', 'Expected ${expectedType} but got ' + typeof ${variableName});\r\n}`;\r\n } else if (\r\n category === FailureCategory.LOGIC_ERROR &&\r\n failure.errorMessage.includes('File not found')\r\n ) {\r\n patchType = PatchType.ADD_FILE_CHECK;\r\n const filePath = failure.context.filePath || 'filePath';\r\n content = `if (!fs.existsSync(${filePath})) {\r\n throw new StandardError('FILE_NOT_FOUND', \\`File not found: \\${${filePath}}\\`);\r\n}`;\r\n } else {\r\n // Default to error handling\r\n patchType = PatchType.ADD_ERROR_HANDLING;\r\n const operation = failure.context.operation || 'operation';\r\n content = `try {\r\n // existing code for ${operation}\r\n} catch (error) {\r\n logger.error('${operation} failed', error);\r\n throw new StandardError('OPERATION_FAILED', '${operation} failed', {}, error);\r\n}`;\r\n }\r\n\r\n const patch: Patch = {\r\n id: crypto.randomUUID(),\r\n failureId: failure.id,\r\n skillId: failure.skillId,\r\n type: patchType,\r\n category,\r\n content,\r\n targetFile: file,\r\n targetLine: line,\r\n confidence: 0, // Will be calculated separately\r\n similarFailureCount: 0, // Will be set by caller\r\n };\r\n\r\n logger.debug('Patch generated', {\r\n patchType,\r\n targetFile: file,\r\n targetLine: line,\r\n durationMs: Date.now() - startTime,\r\n });\r\n\r\n return patch;\r\n }\r\n\r\n /**\r\n * Extract variable name from error message\r\n */\r\n private extractVariableName(errorMessage: string): string {\r\n // Try to extract variable name from error messages like:\r\n // - \"Cannot read property 'x' of null\"\r\n // - \"userData is null\"\r\n // - \"Expected string but got number for field\"\r\n\r\n const patterns = [\r\n /Cannot read property.*?of (\\w+)/,\r\n /(\\w+) is (null|undefined)/,\r\n /for (\\w+)/,\r\n /(\\w+) cannot be/,\r\n ];\r\n\r\n for (const pattern of patterns) {\r\n const match = errorMessage.match(pattern);\r\n if (match && match[1] !== 'null' && match[1] !== 'undefined') {\r\n return match[1];\r\n }\r\n }\r\n\r\n return 'value';\r\n }\r\n\r\n /**\r\n * Calculate patch confidence\r\n *\r\n * Factors:\r\n * - Number of similar failures (higher = more confident)\r\n * - Patch type (some types are more reliable)\r\n * - Category (some categories are easier to fix)\r\n *\r\n * Threshold: ≥0.85 for auto-approval consideration\r\n */\r\n calculatePatchConfidence(patch: Patch): number {\r\n let confidence = 0.5; // Base confidence\r\n\r\n // Similar failure count boost (up to +0.4)\r\n const failureBoost = Math.min(0.4, patch.similarFailureCount * 0.04);\r\n confidence += failureBoost;\r\n\r\n // Patch type boost\r\n if (\r\n patch.type === PatchType.ADD_ERROR_HANDLING ||\r\n patch.type === PatchType.ADD_NULL_CHECK\r\n ) {\r\n confidence += 0.1; // These are generally safe\r\n }\r\n\r\n if (patch.type === PatchType.ADD_FILE_CHECK || patch.type === PatchType.ADD_TIMEOUT) {\r\n confidence += 0.05; // Moderately safe\r\n }\r\n\r\n // Category boost\r\n if (patch.category === FailureCategory.VALIDATION_ERROR) {\r\n confidence += 0.05; // Validation fixes are usually straightforward\r\n }\r\n\r\n return Math.min(0.98, confidence);\r\n }\r\n\r\n /**\r\n * Create patch proposal (requires confidence ≥ threshold)\r\n */\r\n async createPatchProposal(patch: Patch): Promise<PatchProposal> {\r\n const startTime = Date.now();\r\n\r\n // Calculate confidence if not set\r\n if (patch.confidence === 0) {\r\n patch.confidence = this.calculatePatchConfidence(patch);\r\n }\r\n\r\n // Enforce confidence threshold\r\n if (patch.confidence < this.confidenceThreshold) {\r\n throw createError(\r\n ErrorCode.VALIDATION_FAILED,\r\n `Patch confidence ${patch.confidence.toFixed(2)} below threshold ${this.confidenceThreshold}`,\r\n { patchId: patch.id, confidence: patch.confidence }\r\n );\r\n }\r\n\r\n // Generate preview\r\n const preview = this.generatePatchPreview(patch);\r\n\r\n // Store in database\r\n this.db\r\n .prepare(\r\n `\r\n INSERT INTO skill_patches (id, skill_id, failure_id, category, patch_content, confidence, status)\r\n VALUES (?, ?, ?, ?, ?, ?, ?)\r\n `\r\n )\r\n .run(\r\n patch.id,\r\n patch.skillId,\r\n patch.failureId,\r\n patch.category,\r\n patch.content,\r\n patch.confidence,\r\n PatchStatus.PENDING_UPDATE\r\n );\r\n\r\n const proposal: PatchProposal = {\r\n patch,\r\n status: PatchStatus.PENDING_UPDATE,\r\n createdAt: new Date(),\r\n preview,\r\n };\r\n\r\n logger.info('Patch proposal created', {\r\n patchId: patch.id,\r\n confidence: patch.confidence,\r\n status: PatchStatus.PENDING_UPDATE,\r\n durationMs: Date.now() - startTime,\r\n });\r\n\r\n return proposal;\r\n }\r\n\r\n /**\r\n * Generate human-readable patch preview\r\n */\r\n private generatePatchPreview(patch: Patch): string {\r\n return `\r\nPatch Preview\r\n=============\r\nID: ${patch.id}\r\nType: ${patch.type}\r\nCategory: ${patch.category}\r\nSkill: ${patch.skillId}\r\nConfidence: ${patch.confidence.toFixed(2)}\r\n\r\nTarget:\r\n File: ${patch.targetFile}\r\n Line: ${patch.targetLine}\r\n\r\nPatch Content:\r\n${patch.content.split('\\n').map(line => ' ' + line).join('\\n')}\r\n\r\nSimilar Failures: ${patch.similarFailureCount}\r\nStatus: Pending Manual Approval\r\n `.trim();\r\n }\r\n\r\n /**\r\n * Get patch proposal by ID\r\n */\r\n getPatchProposal(patchId: string): PatchProposal | undefined {\r\n const stmt = this.db.prepare('SELECT * FROM skill_patches WHERE id = ?');\r\n const row = stmt.get(patchId) as any;\r\n\r\n if (!row) {\r\n return undefined;\r\n }\r\n\r\n const patch: Patch = {\r\n id: row.id,\r\n failureId: row.failure_id,\r\n skillId: row.skill_id,\r\n type: row.category as PatchType, // Note: Using category for type mapping\r\n category: row.category as FailureCategory,\r\n content: row.patch_content,\r\n targetFile: '', // Not stored in DB for simplicity\r\n targetLine: 0,\r\n confidence: row.confidence,\r\n similarFailureCount: 0, // Not stored in DB\r\n };\r\n\r\n const proposal: PatchProposal = {\r\n patch,\r\n status: row.status as PatchStatus,\r\n createdAt: new Date(row.created_at),\r\n preview: this.generatePatchPreview(patch),\r\n approvedBy: row.approved_by,\r\n deployedAt: row.deployed_at ? new Date(row.deployed_at) : undefined,\r\n success: row.success !== null ? Boolean(row.success) : undefined,\r\n rollbackReason: row.rollback_reason,\r\n };\r\n\r\n return proposal;\r\n }\r\n\r\n /**\r\n * Get pending patches (optionally filtered by skill)\r\n */\r\n getPendingPatches(skillId?: string): PatchProposal[] {\r\n let query = `\r\n SELECT * FROM skill_patches\r\n WHERE status = 'PENDING_UPDATE'\r\n `;\r\n const params: any[] = [];\r\n\r\n if (skillId) {\r\n query += ' AND skill_id = ?';\r\n params.push(skillId);\r\n }\r\n\r\n query += ' ORDER BY confidence DESC';\r\n\r\n const stmt = this.db.prepare(query);\r\n const rows = stmt.all(...params) as any[];\r\n\r\n return rows.map(row => {\r\n const patch: Patch = {\r\n id: row.id,\r\n failureId: row.failure_id,\r\n skillId: row.skill_id,\r\n type: this.inferPatchType(row.patch_content),\r\n category: row.category as FailureCategory,\r\n content: row.patch_content,\r\n targetFile: '',\r\n targetLine: 0,\r\n confidence: row.confidence,\r\n similarFailureCount: 0,\r\n };\r\n\r\n return {\r\n patch,\r\n status: row.status as PatchStatus,\r\n createdAt: new Date(row.created_at),\r\n preview: this.generatePatchPreview(patch),\r\n approvedBy: row.approved_by,\r\n deployedAt: row.deployed_at ? new Date(row.deployed_at) : undefined,\r\n success: row.success !== null ? Boolean(row.success) : undefined,\r\n rollbackReason: row.rollback_reason,\r\n };\r\n });\r\n }\r\n\r\n /**\r\n * Infer patch type from content\r\n */\r\n private inferPatchType(content: string): PatchType {\r\n if (content.includes('withTimeout')) {\r\n return PatchType.ADD_TIMEOUT;\r\n }\r\n if (content.includes('null') || content.includes('undefined')) {\r\n return PatchType.ADD_NULL_CHECK;\r\n }\r\n if (content.includes('typeof')) {\r\n return PatchType.ADD_TYPE_VALIDATION;\r\n }\r\n if (content.includes('fs.existsSync')) {\r\n return PatchType.ADD_FILE_CHECK;\r\n }\r\n return PatchType.ADD_ERROR_HANDLING;\r\n }\r\n\r\n /**\r\n * Close database connection\r\n */\r\n close(): void {\r\n this.db.close();\r\n }\r\n}\r\n"],"names":["crypto","Database","createLogger","ErrorCode","createError","FailureCategory","logger","PatchType","PatchStatus","PatchGenerator","db","confidenceThreshold","config","dbPath","initializeDatabase","exec","parseStackTrace","stackTrace","patterns","pattern","match","file","trim","line","parseInt","generatePatch","failure","category","startTime","Date","now","patchType","content","TIMEOUT","timeout","context","VALIDATION_ERROR","errorMessage","includes","variableName","extractVariableName","expectedType","LOGIC_ERROR","filePath","operation","patch","id","randomUUID","failureId","skillId","type","targetFile","targetLine","confidence","similarFailureCount","debug","durationMs","calculatePatchConfidence","failureBoost","Math","min","createPatchProposal","VALIDATION_FAILED","toFixed","patchId","preview","generatePatchPreview","prepare","run","proposal","status","createdAt","info","split","map","join","getPatchProposal","stmt","row","get","undefined","failure_id","skill_id","patch_content","created_at","approvedBy","approved_by","deployedAt","deployed_at","success","Boolean","rollbackReason","rollback_reason","getPendingPatches","query","params","push","rows","all","inferPatchType","close"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;CAqBC,GAED,YAAYA,YAAY,SAAS;AACjC,OAAOC,cAAc,iBAAiB;AACtC,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAAwBC,SAAS,EAAEC,WAAW,QAAQ,mBAAmB;AACzE,SAASC,eAAe,QAAiB,0BAA0B;AAEnE,MAAMC,SAASJ,aAAa;AAE5B;;CAEC,GACD,OAAO,IAAA,AA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