claude-flow-novice 2.15.3 → 2.15.5
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.
- package/.claude/cfn-extras/skills/advanced-features/cfn-agent-swap/recommend-swap.sh +59 -59
- package/.claude/cfn-extras/skills/analytics/cfn-improvement-recommender/recommend-improvements.sh +91 -91
- package/.claude/cfn-extras/skills/analytics/cfn-pattern-extraction/extract-patterns.sh +79 -79
- package/.claude/cfn-extras/skills/analytics/cfn-retrospective-report/generate-report.sh +100 -100
- package/.claude/cfn-extras/skills/analytics/cfn-telemetry/start-telemetry.sh +110 -110
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/add-bullet.sh +145 -145
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/log-merge.sh +67 -67
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/monitor-injection-performance.sh +137 -137
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/optimize-injection-pipeline.sh +168 -168
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/query-reflections.sh +35 -35
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/store-reflection.sh +45 -45
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/track-ab-test.sh +41 -41
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/update-reflection.sh +41 -41
- package/.claude/cfn-extras/skills/deprecated/cfn-cli-setup/validate-cli-environment.sh +191 -191
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/create-campaign.sh +231 -231
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/get-campaign-performance.sh +190 -190
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/pause-campaign.sh +142 -142
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/set-budget.sh +181 -181
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/update-bid-strategy.sh +133 -133
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/get-conversation-history.sh +121 -121
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/qualify-lead.sh +156 -156
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/schedule-demo.sh +181 -181
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/send-message.sh +137 -137
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/transfer-to-human.sh +179 -179
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/create-campaign.sh +183 -183
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/get-delivery-status.sh +139 -139
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/opt-out.sh +150 -150
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/schedule-campaign.sh +187 -187
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/send-sms.sh +181 -181
- package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/test-web-portal-skill.sh +50 -50
- package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/validate-deployment.sh +84 -84
- package/.claude/cfn-extras/skills/utility/cfn-environment-sanitization/sanitize-environment.sh +243 -243
- package/.claude/commands/cfn-loop-cli.md +29 -6
- package/.claude/commands/switch-api.md +31 -10
- package/.claude/hooks/cfn-lint-sql-injection.sh +61 -0
- package/.claude/hooks/cfn-post-edit-cfn-retrospective.sh +33 -2
- package/.claude/hooks/cfn-pre-edit-security-warning.sh +40 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +22 -24
- package/.claude/skills/cfn-docker-agent-spawning/SKILL.md +28 -4
- package/.claude/skills/cfn-docker-agent-spawning/spawn-agent.sh +3 -1
- package/.claude/skills/cfn-docker-loop-orchestration/orchestrate.sh +224 -20
- package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +550 -46
- package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +277 -0
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +238 -29
- package/.claude/skills/cfn-loop-orchestration/security_utils.sh +24 -0
- package/.claude/skills/cfn-loop-orchestration/test-iteration-context-injection.sh +366 -0
- package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +319 -0
- package/.claude/skills/cfn-redis-coordination/agent-log.sh +4 -0
- package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +124 -0
- package/.claude/skills/cfn-redis-coordination/agent-recovery.sh +2 -2
- package/.claude/skills/cfn-redis-coordination/collect-confidence-scores.sh +30 -0
- package/.claude/skills/cfn-redis-coordination/get-context.sh +33 -0
- package/.claude/skills/cfn-redis-coordination/get-success-criteria.sh +54 -0
- package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh +6 -2
- package/.claude/skills/cfn-redis-coordination/redis-cli-wrapper.sh +24 -3
- package/.claude/skills/cfn-redis-coordination/redis-functions.sh +34 -0
- package/.claude/skills/cfn-redis-coordination/report-completion.sh +24 -31
- package/.claude/skills/cfn-redis-coordination/store-context.sh +4 -0
- package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +85 -0
- package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +67 -0
- package/.claude/skills/cfn-sqlite-memory/ttl-cleanup.sh +17 -25
- package/.claude/skills/cfn-transparency-middleware/test-e2e.sh +15 -0
- package/.claude/skills/cfn-transparency-middleware/tests/input-validation.sh +15 -0
- package/README.md +116 -475
- package/claude-assets/agents/cfn-dev-team/README.md +103 -0
- package/claude-assets/agents/cfn-dev-team/architecture/goal-planner.md +1 -1
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +77 -15
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +355 -6
- package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +82 -1
- package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +82 -1
- package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +77 -15
- package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +99 -12
- package/claude-assets/agents/cfn-dev-team/dev-ops/github-commit-agent.md +1 -1
- package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +97 -0
- package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +20 -1
- package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +97 -0
- package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +110 -13
- package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +106 -15
- package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +115 -11
- package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +94 -7
- package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +87 -9
- package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +85 -7
- package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +160 -28
- package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +101 -19
- package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +108 -14
- package/claude-assets/agents/cfn-dev-team/reviewers/{reviewer.md → code-reviewer.md} +95 -8
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +107 -7
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +98 -7
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +95 -7
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +136 -9
- package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +108 -1
- package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +107 -13
- package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +737 -0
- package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +1 -1
- package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +828 -0
- package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +106 -7
- package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +77 -0
- package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +684 -0
- package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +110 -1
- package/claude-assets/agents/cfn-dev-team/testers/tester.md +94 -7
- package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +1 -3
- package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +87 -13
- package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +103 -7
- package/claude-assets/agents/cfn-dev-team/utility/researcher.md +1 -3
- package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +94 -7
- package/claude-assets/agents/docker-coordinators/cfn-docker-v3-coordinator.md +46 -0
- package/claude-assets/agents/project-only-agents/npm-package-specialist.md +1 -1
- package/claude-assets/cfn-extras/skills/advanced-features/cfn-agent-swap/recommend-swap.sh +59 -59
- package/claude-assets/cfn-extras/skills/analytics/cfn-improvement-recommender/recommend-improvements.sh +91 -91
- package/claude-assets/cfn-extras/skills/analytics/cfn-pattern-extraction/extract-patterns.sh +79 -79
- package/claude-assets/cfn-extras/skills/analytics/cfn-retrospective-report/generate-report.sh +100 -100
- package/claude-assets/cfn-extras/skills/analytics/cfn-telemetry/start-telemetry.sh +110 -110
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/add-bullet.sh +145 -145
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/log-merge.sh +67 -67
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/monitor-injection-performance.sh +137 -137
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/optimize-injection-pipeline.sh +168 -168
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/query-reflections.sh +35 -35
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/store-reflection.sh +45 -45
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/track-ab-test.sh +41 -41
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/update-reflection.sh +41 -41
- package/claude-assets/cfn-extras/skills/deprecated/cfn-cli-setup/validate-cli-environment.sh +191 -191
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/create-campaign.sh +231 -231
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/get-campaign-performance.sh +190 -190
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/pause-campaign.sh +142 -142
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/set-budget.sh +181 -181
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/update-bid-strategy.sh +133 -133
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/get-conversation-history.sh +121 -121
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/qualify-lead.sh +156 -156
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/schedule-demo.sh +181 -181
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/send-message.sh +137 -137
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/transfer-to-human.sh +179 -179
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/create-campaign.sh +183 -183
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/get-delivery-status.sh +139 -139
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/opt-out.sh +150 -150
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/schedule-campaign.sh +187 -187
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/send-sms.sh +181 -181
- package/claude-assets/cfn-extras/skills/ui-portal/cfn-web-portal/test-web-portal-skill.sh +50 -50
- package/claude-assets/cfn-extras/skills/ui-portal/cfn-web-portal/validate-deployment.sh +84 -84
- package/claude-assets/cfn-extras/skills/utility/cfn-environment-sanitization/sanitize-environment.sh +243 -243
- package/claude-assets/commands/cfn-loop-cli.md +29 -6
- package/claude-assets/commands/switch-api.md +31 -10
- package/claude-assets/hooks/cfn-lint-sql-injection.sh +61 -0
- package/claude-assets/hooks/cfn-post-edit-cfn-retrospective.sh +33 -2
- package/claude-assets/hooks/cfn-pre-edit-security-warning.sh +40 -0
- package/claude-assets/hooks/detect-hardcoded-credentials.sh +212 -0
- package/claude-assets/skills/SKILL_TEMPLATE.md +774 -0
- package/claude-assets/skills/agent-lifecycle/execute-lifecycle-hook.sh +84 -113
- package/claude-assets/skills/agent-lifecycle/simple-audit.sh +33 -6
- package/claude-assets/skills/agent-template-generator/SKILL.md +440 -0
- package/claude-assets/skills/agent-template-generator/generate-agent.sh +405 -0
- package/claude-assets/skills/agent-validation-linter/SKILL.md +589 -0
- package/claude-assets/skills/agent-validation-linter/lint-agents.sh +271 -0
- package/claude-assets/skills/bootstrap/bash-fundamentals.md +786 -0
- package/claude-assets/skills/bootstrap/database-connection.md +464 -0
- package/claude-assets/skills/bootstrap/error-handling.md +580 -0
- package/claude-assets/skills/bootstrap/file-operations.md +699 -0
- package/claude-assets/skills/bootstrap/skill-loader.md +616 -0
- package/claude-assets/skills/bootstrap/sqlite-params.sh +287 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +22 -24
- package/claude-assets/skills/cfn-automatic-memory-persistence/test-memory-persistence.sh +17 -16
- package/claude-assets/skills/cfn-deployment/SKILL.md +293 -0
- package/claude-assets/skills/cfn-deployment/execute.sh +21 -0
- package/claude-assets/skills/cfn-docker-agent-spawning/SKILL.md +28 -4
- package/claude-assets/skills/cfn-docker-agent-spawning/spawn-agent.sh +3 -1
- package/claude-assets/skills/cfn-docker-loop-orchestration/orchestrate.sh +224 -20
- package/claude-assets/skills/cfn-environment-sanitization/sanitize-environment.sh +38 -0
- package/claude-assets/skills/cfn-error-batching-strategy/lib/core-functions.sh +47 -47
- package/claude-assets/skills/cfn-file-operations/SKILL.md +290 -0
- package/claude-assets/skills/cfn-file-operations/execute.sh +129 -0
- package/claude-assets/skills/cfn-file-operations/lib/atomic-write.sh +294 -0
- package/claude-assets/skills/cfn-file-operations/lib/lock.sh +361 -0
- package/claude-assets/skills/cfn-file-operations/test.sh +369 -0
- package/claude-assets/skills/cfn-log-operations/SKILL.md +308 -0
- package/claude-assets/skills/cfn-log-operations/execute.sh +420 -0
- package/claude-assets/skills/cfn-log-operations/lib/rotate.sh +406 -0
- package/claude-assets/skills/cfn-log-operations/lib/search.sh +448 -0
- package/claude-assets/skills/cfn-log-operations/test.sh +394 -0
- package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +550 -46
- package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +277 -0
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +238 -29
- package/claude-assets/skills/cfn-loop-orchestration/security_utils.sh +24 -0
- package/claude-assets/skills/cfn-loop-orchestration/test-iteration-context-injection.sh +366 -0
- package/claude-assets/skills/cfn-parameterized-queries/SKILL.md +339 -0
- package/claude-assets/skills/cfn-playbook/query-playbook.sh +19 -15
- package/claude-assets/skills/cfn-playbook/update-playbook.sh +25 -14
- package/claude-assets/skills/cfn-process-instrumentation/instrument-process.sh +44 -0
- package/claude-assets/skills/cfn-promotion/SKILL.md +305 -0
- package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +319 -0
- package/claude-assets/skills/cfn-redis-coordination/agent-log.sh +4 -0
- package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +124 -0
- package/claude-assets/skills/cfn-redis-coordination/agent-recovery.sh +2 -2
- package/claude-assets/skills/cfn-redis-coordination/collect-confidence-scores.sh +30 -0
- package/claude-assets/skills/cfn-redis-coordination/get-context.sh +33 -0
- package/claude-assets/skills/cfn-redis-coordination/get-success-criteria.sh +54 -0
- package/claude-assets/skills/cfn-redis-coordination/invoke-waiting-mode.sh +6 -2
- package/claude-assets/skills/cfn-redis-coordination/redis-cli-wrapper.sh +24 -3
- package/claude-assets/skills/cfn-redis-coordination/redis-functions.sh +34 -0
- package/claude-assets/skills/cfn-redis-coordination/report-completion.sh +24 -31
- package/claude-assets/skills/cfn-redis-coordination/store-context.sh +4 -0
- package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +85 -0
- package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +67 -0
- package/claude-assets/skills/cfn-skill-loader/SKILL.md +466 -0
- package/claude-assets/skills/cfn-skill-loader/execute.sh +344 -0
- package/claude-assets/skills/cfn-sqlite-memory/ttl-cleanup.sh +17 -25
- package/claude-assets/skills/cfn-task-audit/get-audit-data.sh +42 -21
- package/claude-assets/skills/cfn-task-audit/store-task-audit.sh +17 -10
- package/claude-assets/skills/cfn-test-runner/detect-regressions.sh +17 -14
- package/claude-assets/skills/cfn-test-runner/detect-regressions.sh.backup-1763392821 +55 -0
- package/claude-assets/skills/cfn-test-runner/store-benchmarks.sh +17 -19
- package/claude-assets/skills/cfn-transparency-middleware/test-e2e.sh +15 -0
- package/claude-assets/skills/cfn-transparency-middleware/tests/input-validation.sh +15 -0
- package/claude-assets/skills/cfn-utilities/SKILL.md +237 -0
- package/claude-assets/skills/cfn-utilities/execute.sh +32 -0
- package/claude-assets/skills/cfn-utilities/lib/errors.sh +56 -0
- package/claude-assets/skills/cfn-utilities/lib/file-ops.sh +164 -0
- package/claude-assets/skills/cfn-utilities/lib/logging.sh +77 -0
- package/claude-assets/skills/cfn-utilities/lib/retry.sh +127 -0
- package/claude-assets/skills/cfn-utilities/test.sh +317 -0
- package/claude-assets/skills/integration/agent-handoff.sh +62 -64
- package/claude-assets/skills/json-validation/SKILL.md +431 -0
- package/claude-assets/skills/json-validation/test-validate-success-criteria.sh +421 -0
- package/claude-assets/skills/json-validation/validate-success-criteria.sh +197 -0
- package/claude-assets/skills/redis-coordination/validate-parameters.sh +34 -0
- package/claude-assets/skills/workflow-codification/DEPLOY_QUICK_REFERENCE.md +106 -0
- package/claude-assets/skills/workflow-codification/PROPAGATE_UPDATE_QUICK_REFERENCE.md +366 -0
- package/claude-assets/skills/workflow-codification/deploy-approved-skill.sh +481 -0
- package/claude-assets/skills/workflow-codification/deploy-approved-skill.sh.backup-1763392820 +512 -0
- package/claude-assets/skills/workflow-codification/lib/security-utils.sh +204 -0
- package/claude-assets/skills/workflow-codification/propagate-skill-update.sh +648 -0
- package/claude-assets/skills/workflow-codification/propagate-skill-update.sh.backup-1763392820 +664 -0
- package/claude-assets/skills/workflow-codification/test-integration.sh +15 -0
- package/claude-assets/skills/workflow-codification/test-metadata-update.sh +350 -0
- package/claude-assets/skills/workflow-codification/track-cost-savings.sh +55 -14
- package/claude-assets/skills/workflow-codification/track-cost-savings.sh.backup-1763392821 +445 -0
- package/claude-assets/skills/workflow-codification/track-edge-case.sh +27 -60
- package/claude-assets/skills/workflow-codification/workflow-codification.db +0 -0
- package/dist/ace/ace-curator.js +10 -2
- package/dist/ace/ace-curator.js.map +1 -1
- package/dist/ace/ace-generator.js +4 -0
- package/dist/ace/ace-generator.js.map +1 -1
- package/dist/ace/ace-reflector.js +1 -1
- package/dist/ace/ace-reflector.js.map +1 -1
- package/dist/ace/context-injection.js +24 -2
- package/dist/ace/context-injection.js.map +1 -1
- package/dist/agents/task-agent-integration.js +1 -1
- package/dist/agents/task-agent-integration.js.map +1 -1
- package/dist/api/health-endpoints.js +390 -0
- package/dist/api/health-endpoints.js.map +1 -0
- package/dist/cli/agent-executor.js +4 -1
- package/dist/cli/agent-executor.js.map +1 -1
- package/dist/cli/agent-prompt-builder.js +89 -1
- package/dist/cli/agent-prompt-builder.js.map +1 -1
- package/dist/cli/agent-spawn.js +130 -37
- package/dist/cli/agent-spawn.js.map +1 -1
- package/dist/cli/config-manager.js +109 -91
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/cli/conversation-fork-cleanup.js +201 -0
- package/dist/cli/conversation-fork-cleanup.js.map +1 -0
- package/dist/cli/conversation-fork.js +16 -3
- package/dist/cli/conversation-fork.js.map +1 -1
- package/dist/cli/skill-cache-validator.js +412 -0
- package/dist/cli/skill-cache-validator.js.map +1 -0
- package/dist/cli/skill-cli.js +991 -0
- package/dist/cli/skill-cli.js.map +1 -0
- package/dist/cli/skill-execution-logger.js +284 -0
- package/dist/cli/skill-execution-logger.js.map +1 -0
- package/dist/cli/skill-loader.js +457 -0
- package/dist/cli/skill-loader.js.map +1 -0
- package/dist/coordination/event-bus.js +2 -2
- package/dist/coordination/event-bus.js.map +1 -1
- package/dist/coordination/fleet-manager.js +1 -1
- package/dist/coordination/fleet-manager.js.map +1 -1
- package/dist/coordination/index.js +23 -9
- package/dist/coordination/index.js.map +1 -1
- package/dist/coordination/types/fleet-manager.types.js.map +1 -1
- package/dist/db/migration-manager.js +483 -0
- package/dist/db/migration-manager.js.map +1 -0
- package/dist/db/skills-query.js +535 -0
- package/dist/db/skills-query.js.map +1 -0
- package/dist/integration/DatabaseHandoff.js +1 -1
- package/dist/integration/DatabaseHandoff.js.map +1 -1
- package/dist/jobs/edge-case-analyzer.js +367 -0
- package/dist/jobs/edge-case-analyzer.js.map +1 -0
- package/dist/jobs/promotion-sla-enforcer.js +288 -0
- package/dist/jobs/promotion-sla-enforcer.js.map +1 -0
- package/dist/lib/agent-output-parser.js.map +1 -1
- package/dist/lib/agent-output-validator.js.map +1 -1
- package/dist/lib/agent-workspace.js +281 -0
- package/dist/lib/agent-workspace.js.map +1 -0
- package/dist/lib/atomic-file-writer.js +377 -0
- package/dist/lib/atomic-file-writer.js.map +1 -0
- package/dist/lib/backup-manager.js +779 -0
- package/dist/lib/backup-manager.js.map +1 -0
- package/dist/lib/checkpoint-manager.js +837 -0
- package/dist/lib/checkpoint-manager.js.map +1 -0
- package/dist/lib/circuit-breaker.js +340 -0
- package/dist/lib/circuit-breaker.js.map +1 -0
- package/dist/lib/completion-signal-handler.js +243 -0
- package/dist/lib/completion-signal-handler.js.map +1 -0
- package/dist/lib/config-manager.js +312 -0
- package/dist/lib/config-manager.js.map +1 -0
- package/dist/lib/config-migrator.js +386 -0
- package/dist/lib/config-migrator.js.map +1 -0
- package/dist/lib/config-validator.js.map +1 -1
- package/dist/lib/correlation-cache.js +311 -0
- package/dist/lib/correlation-cache.js.map +1 -0
- package/dist/lib/correlation.js +263 -0
- package/dist/lib/correlation.js.map +1 -0
- package/dist/lib/database-service/connection-pool-manager.js +520 -0
- package/dist/lib/database-service/connection-pool-manager.js.map +1 -0
- package/dist/lib/database-service/correlation.js +329 -0
- package/dist/lib/database-service/correlation.js.map +1 -0
- package/dist/lib/database-service/errors.js +120 -0
- package/dist/lib/database-service/errors.js.map +1 -0
- package/dist/lib/database-service/index.js +168 -0
- package/dist/lib/database-service/index.js.map +1 -0
- package/dist/lib/database-service/postgres-adapter.js +526 -0
- package/dist/lib/database-service/postgres-adapter.js.map +1 -0
- package/dist/lib/database-service/redis-adapter.js +360 -0
- package/dist/lib/database-service/redis-adapter.js.map +1 -0
- package/dist/lib/database-service/sqlite-adapter.js +544 -0
- package/dist/lib/database-service/sqlite-adapter.js.map +1 -0
- package/dist/lib/database-service/transaction-manager.js +773 -0
- package/dist/lib/database-service/transaction-manager.js.map +1 -0
- package/dist/lib/database-service/types.js +23 -0
- package/dist/lib/database-service/types.js.map +1 -0
- package/dist/lib/deadlock-resolver.js +292 -0
- package/dist/lib/deadlock-resolver.js.map +1 -0
- package/dist/lib/distributed-lock.js +451 -0
- package/dist/lib/distributed-lock.js.map +1 -0
- package/dist/lib/edge-case-deduplicator.js +227 -0
- package/dist/lib/edge-case-deduplicator.js.map +1 -0
- package/dist/lib/encryption-manager.js +322 -0
- package/dist/lib/encryption-manager.js.map +1 -0
- package/dist/lib/error-aggregator.js +234 -0
- package/dist/lib/error-aggregator.js.map +1 -0
- package/dist/lib/errors.js +287 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/file-lock-manager.js +578 -0
- package/dist/lib/file-lock-manager.js.map +1 -0
- package/dist/lib/file-operations.js +367 -0
- package/dist/lib/file-operations.js.map +1 -0
- package/dist/lib/idempotent-write.js +237 -0
- package/dist/lib/idempotent-write.js.map +1 -0
- package/dist/lib/integration-schema-validator.js +522 -0
- package/dist/lib/integration-schema-validator.js.map +1 -0
- package/dist/lib/lock-health-monitor.js +298 -0
- package/dist/lib/lock-health-monitor.js.map +1 -0
- package/dist/lib/log-shipper.js +422 -0
- package/dist/lib/log-shipper.js.map +1 -0
- package/dist/lib/logging.js +146 -0
- package/dist/lib/logging.js.map +1 -0
- package/dist/lib/message-deduplicator.js +439 -0
- package/dist/lib/message-deduplicator.js.map +1 -0
- package/dist/lib/multi-system-query.js +604 -0
- package/dist/lib/multi-system-query.js.map +1 -0
- package/dist/lib/orphan-detector.js +332 -0
- package/dist/lib/orphan-detector.js.map +1 -0
- package/dist/lib/password-generator.js +166 -0
- package/dist/lib/password-generator.js.map +1 -0
- package/dist/lib/path-validator.js +429 -0
- package/dist/lib/path-validator.js.map +1 -0
- package/dist/lib/query-translator.js +905 -0
- package/dist/lib/query-translator.js.map +1 -0
- package/dist/lib/queue-recovery.js +469 -0
- package/dist/lib/queue-recovery.js.map +1 -0
- package/dist/lib/redis-queue-manager.js +512 -0
- package/dist/lib/redis-queue-manager.js.map +1 -0
- package/dist/lib/reflection-archiver.js +272 -0
- package/dist/lib/reflection-archiver.js.map +1 -0
- package/dist/lib/retry-manager.js +453 -0
- package/dist/lib/retry-manager.js.map +1 -0
- package/dist/lib/retry.js +262 -0
- package/dist/lib/retry.js.map +1 -0
- package/dist/lib/schema-transform.js +695 -0
- package/dist/lib/schema-transform.js.map +1 -0
- package/dist/lib/schema-validator.js +491 -0
- package/dist/lib/schema-validator.js.map +1 -0
- package/dist/lib/skill-cache.js +297 -0
- package/dist/lib/skill-cache.js.map +1 -0
- package/dist/lib/skill-content-manager.js +337 -0
- package/dist/lib/skill-content-manager.js.map +1 -0
- package/dist/lib/skill-frontmatter-parser.js +237 -0
- package/dist/lib/skill-frontmatter-parser.js.map +1 -0
- package/dist/lib/skill-git-integration.js +275 -0
- package/dist/lib/skill-git-integration.js.map +1 -0
- package/dist/lib/skill-markdown-validator.js +396 -0
- package/dist/lib/skill-markdown-validator.js.map +1 -0
- package/dist/lib/skill-output-parser.js +312 -0
- package/dist/lib/skill-output-parser.js.map +1 -0
- package/dist/lib/unified-query-api.js +467 -0
- package/dist/lib/unified-query-api.js.map +1 -0
- package/dist/middleware/auth-middleware.js +350 -0
- package/dist/middleware/auth-middleware.js.map +1 -0
- package/dist/middleware/schema-validation.js +347 -0
- package/dist/middleware/schema-validation.js.map +1 -0
- package/dist/providers/anthropic-provider.js +1 -1
- package/dist/providers/anthropic-provider.js.map +1 -1
- package/dist/providers/provider-factory.js +2 -2
- package/dist/providers/provider-factory.js.map +1 -1
- package/dist/services/edge-case-analyzer.js +321 -0
- package/dist/services/edge-case-analyzer.js.map +1 -0
- package/dist/services/edge-case-deduplicator.js +266 -0
- package/dist/services/edge-case-deduplicator.js.map +1 -0
- package/dist/services/edge-case-detector.js +337 -0
- package/dist/services/edge-case-detector.js.map +1 -0
- package/dist/services/edge-case-tracker.js +547 -0
- package/dist/services/edge-case-tracker.js.map +1 -0
- package/dist/services/health-check-system.js +586 -0
- package/dist/services/health-check-system.js.map +1 -0
- package/dist/services/metrics-logger.js +412 -0
- package/dist/services/metrics-logger.js.map +1 -0
- package/dist/services/patch-generator.js +378 -0
- package/dist/services/patch-generator.js.map +1 -0
- package/dist/services/patch-validator.js +337 -0
- package/dist/services/patch-validator.js.map +1 -0
- package/dist/services/performance-monitor.js +811 -0
- package/dist/services/performance-monitor.js.map +1 -0
- package/dist/services/promotion-pipeline.js +918 -0
- package/dist/services/promotion-pipeline.js.map +1 -0
- package/dist/services/promotion-validator.js +394 -0
- package/dist/services/promotion-validator.js.map +1 -0
- package/dist/services/reflection-logger.js +388 -0
- package/dist/services/reflection-logger.js.map +1 -0
- package/dist/services/skill-deployment.js +472 -0
- package/dist/services/skill-deployment.js.map +1 -0
- package/dist/services/skill-loader.js +427 -0
- package/dist/services/skill-loader.js.map +1 -0
- package/dist/services/skill-promotion.js +372 -0
- package/dist/services/skill-promotion.js.map +1 -0
- package/dist/services/skill-validator.js +454 -0
- package/dist/services/skill-validator.js.map +1 -0
- package/dist/services/skill-versioning.js +244 -0
- package/dist/services/skill-versioning.js.map +1 -0
- package/dist/services/workspace-supervisor.js +597 -0
- package/dist/services/workspace-supervisor.js.map +1 -0
- package/dist/types/edge-case.js +45 -0
- package/dist/types/edge-case.js.map +1 -0
- package/docs/BUG_19_MEMORY_LEAK_TASK_MODE.md +405 -0
- package/docs/MEMORY_CLEANUP_GUIDE.md +358 -0
- package/docs/MEMORY_LEAK_FIX_SUMMARY.md +322 -0
- package/docs/REDIS_CLEANUP_EXECUTIVE_SUMMARY.md +319 -0
- package/docs/REDIS_CLEANUP_VERIFICATION_REPORT.md +574 -0
- package/package.json +35 -4
- package/readme/README.md +53 -5
- package/scripts/backup-cleanup.sh +627 -0
- package/scripts/cleanup-workspaces.sh +412 -0
- package/scripts/cleanup-yaml-configs.sh +141 -0
- package/scripts/deploy-approved-skills.sh +263 -0
- package/scripts/health-check.sh +447 -0
- package/scripts/log-aggregator.sh +554 -0
- package/scripts/log-monitor.sh +629 -0
- package/scripts/manage-agent-workspaces.sh +434 -0
- package/scripts/migrate-schema.sh +533 -0
- package/scripts/promote-staged-skills.sh +423 -0
- package/scripts/verify-no-secrets.sh +88 -35
- package/scripts/verify-redis-cleanup.sh +173 -0
- package/tests/README.md +84 -0
- package/tests/test-memory-leak-task-mode.sh +435 -0
- package/.claude/cfn-extras/agents/deprecated-coordinators/adaptive-coordinator.md.backup +0 -161
- package/.claude/cfn-extras/agents/deprecated-coordinators/blocking-coordinator-example.md.backup +0 -728
- package/.claude/cfn-extras/agents/deprecated-coordinators/mesh-coordinator.md.backup +0 -131
- package/.claude/skills/agent-lifecycle/SKILL.md +0 -60
- package/.claude/skills/agent-lifecycle/execute-lifecycle-hook.sh +0 -573
- package/.claude/skills/agent-lifecycle/simple-audit.sh +0 -31
- package/.claude/skills/cfn-agent-spawning/spawn-agent.sh.backup +0 -273
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.backup +0 -949
- package/README.md.backup_before_replace +0 -781
- package/claude-assets/cfn-extras/agents/deprecated-coordinators/adaptive-coordinator.md.backup +0 -161
- package/claude-assets/cfn-extras/agents/deprecated-coordinators/blocking-coordinator-example.md.backup +0 -728
- package/claude-assets/cfn-extras/agents/deprecated-coordinators/mesh-coordinator.md.backup +0 -131
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh.backup +0 -273
- 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,AAAKK,mCAAAA;;;;;;WAAAA;MAMX;AAED;;CAEC,GACD,OAAO,IAAA,AAAKC,qCAAAA;;;;;;WAAAA;MAMX;AAwCD;;CAEC,GACD,OAAO,MAAMC;IACHC,GAAsB;IACtBC,oBAA4B;IAEpC,YAAYC,MAA4B,CAAE;QACxC,IAAI,CAACF,EAAE,GAAG,IAAIT,SAASW,OAAOC,MAAM;QACpC,IAAI,CAACF,mBAAmB,GAAGC,OAAOD,mBAAmB,IAAI;QACzD,IAAI,CAACG,kBAAkB;IACzB;IAEA;;GAEC,GACD,AAAQA,qBAA2B;QACjC,IAAI,CAACJ,EAAE,CAACK,I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