claude-flow-novice 2.15.5 → 2.15.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/cfn-extras/.gs-api-quota.json +16 -0
- package/.claude/cfn-extras/.gs-progress-state.json +22 -0
- package/.claude/cfn-extras/GOOGLE_SHEETS_IMPLEMENTATION_SUMMARY.md +414 -0
- package/.claude/cfn-extras/agents/google-sheets/README.md +114 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-advanced-analytics-specialist.md +288 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-api-integrator.md +127 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-automation-scripting-specialist.md +195 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-business-validator.md +179 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-collaboration-security-specialist.md +240 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-coordinator.md +214 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-transformer.md +127 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-validation-quality-specialist.md +177 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-validator.md +119 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-visualization-specialist.md +135 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-design-layout-specialist.md +109 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-engineer.md +127 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-engineering-specialist.md +138 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-validator.md +128 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-generalist.md +645 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-integration-api-specialist.md +258 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-performance-analyst.md +125 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-performance-optimization-specialist.md +211 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-schema-designer.md +130 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-template-architecture-specialist.md +259 -0
- package/.claude/cfn-extras/docs/GOOGLE_SHEETS_CFN_LOOP.md +617 -0
- package/.claude/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +453 -0
- package/.claude/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +272 -0
- package/.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh +254 -0
- package/.claude/cfn-extras/skills/google-sheets-api-coordinator/test.sh +174 -0
- package/.claude/cfn-extras/skills/google-sheets-api-coordinator/validate.sh +98 -0
- package/.claude/cfn-extras/skills/google-sheets-decomposition/SKILL.md +269 -0
- package/.claude/cfn-extras/skills/google-sheets-decomposition/decompose.sh +313 -0
- package/.claude/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +237 -0
- package/.claude/cfn-extras/skills/google-sheets-formula-builder/build-formula.sh +220 -0
- package/.claude/cfn-extras/skills/google-sheets-formula-builder/test.sh +172 -0
- package/.claude/cfn-extras/skills/google-sheets-formula-builder/validate.sh +98 -0
- package/.claude/cfn-extras/skills/google-sheets-progress/SKILL.md +287 -0
- package/.claude/cfn-extras/skills/google-sheets-progress/test.sh +385 -0
- package/.claude/cfn-extras/skills/google-sheets-progress/track-progress.sh +516 -0
- package/.claude/cfn-extras/skills/google-sheets-progress/validate.sh +119 -0
- package/.claude/cfn-extras/skills/google-sheets-sprint-order/SKILL.md +277 -0
- package/.claude/cfn-extras/skills/google-sheets-sprint-order/order-sprints.sh +233 -0
- package/.claude/cfn-extras/skills/google-sheets-validation/SKILL.md +352 -0
- package/.claude/cfn-extras/skills/google-sheets-validation/test.sh +355 -0
- package/.claude/cfn-extras/skills/google-sheets-validation/validate-state.sh +374 -0
- package/.claude/cfn-extras/skills/google-sheets-validation/validate.sh +128 -0
- package/.claude/commands/cfn-context.md +10 -0
- package/.claude/commands/cfn-loop-cli.md +36 -15
- package/.claude/commands/google-sheets/google-sheets-loop.md +289 -0
- package/.claude/skills/cfn-agent-selector/SKILL.md +143 -0
- package/.claude/skills/cfn-agent-selector/select-agents.sh +94 -0
- package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -2
- package/.claude/skills/cfn-docker-agent-spawning/spawn-agent.sh +21 -2
- package/.claude/skills/cfn-docker-loop-orchestration/orchestrate.sh +11 -5
- package/.claude/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +348 -0
- package/.claude/skills/cfn-docker-redis-coordination/README.md +294 -0
- package/.claude/skills/cfn-docker-redis-coordination/jest.config.js +37 -0
- package/.claude/skills/cfn-docker-redis-coordination/package-lock.json +5259 -0
- package/.claude/skills/cfn-docker-redis-coordination/package.json +40 -0
- package/.claude/skills/cfn-docker-redis-coordination/src/coordinator.ts +801 -0
- package/.claude/skills/cfn-docker-redis-coordination/src/index.ts +42 -0
- package/.claude/skills/cfn-docker-redis-coordination/src/types.ts +351 -0
- package/.claude/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +1464 -0
- package/.claude/skills/cfn-docker-redis-coordination/tsconfig.json +30 -0
- package/.claude/skills/cfn-loop-orchestration/.eslintrc.js +56 -0
- package/.claude/skills/cfn-loop-orchestration/.prettierrc.json +18 -0
- package/.claude/skills/cfn-loop-orchestration/README.md +149 -41
- package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +39 -577
- package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +49 -270
- package/.claude/skills/cfn-loop-orchestration/jest.config.js +67 -0
- package/.claude/skills/cfn-loop-orchestration/orchestrate-wrapper.sh +268 -0
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +91 -8
- package/.claude/skills/cfn-loop-orchestration/package-lock.json +5470 -0
- package/.claude/skills/cfn-loop-orchestration/package.json +49 -0
- package/.claude/skills/cfn-loop-orchestration/src/agent-spawner/agent-spawner.ts +34 -0
- package/.claude/skills/cfn-loop-orchestration/src/gate-checker/gate-checker.ts +36 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/consensus.ts +87 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +115 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/parse-test-results.ts +372 -0
- package/.claude/skills/cfn-loop-orchestration/src/index.ts +14 -0
- package/.claude/skills/cfn-loop-orchestration/src/orchestrator/orchestrator.ts +31 -0
- package/.claude/skills/cfn-loop-orchestration/src/redis/redis-coordinator.ts +72 -0
- package/.claude/skills/cfn-loop-orchestration/src/types.ts +188 -0
- package/.claude/skills/cfn-loop-orchestration/src/utils/logger.ts +32 -0
- package/.claude/skills/cfn-loop-orchestration/tests/consensus.test.ts +142 -0
- package/.claude/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +199 -0
- package/.claude/skills/cfn-loop-orchestration/tests/gate-check.test.ts +325 -0
- package/.claude/skills/cfn-loop-orchestration/tests/iteration-manager.test.ts +132 -0
- package/.claude/skills/cfn-loop-orchestration/tests/parse-test-results.test.ts +382 -0
- package/.claude/skills/cfn-loop-orchestration/tests/setup.ts +22 -0
- package/.claude/skills/cfn-loop-orchestration/tests/timeout-calculator.test.ts +118 -0
- package/.claude/skills/cfn-loop-orchestration/tests/types.test.ts +132 -0
- package/.claude/skills/cfn-loop-orchestration/tsconfig.json +54 -0
- package/.claude/skills/cfn-redis-coordination/bash-wrappers/store-context.sh +23 -0
- package/.claude/skills/cfn-redis-coordination/coverage/clover.xml +1447 -0
- package/.claude/skills/cfn-redis-coordination/coverage/coverage-final.json +13 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/agent-logger.ts.html +1423 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/agent-recovery.ts.html +1447 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/base.css +224 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/block-navigation.js +87 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/completion-reporter.ts.html +1273 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/context-manager.ts.html +1066 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/favicon.png +0 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/index.html +281 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/mode-detector.ts.html +550 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/prettify.css +1 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/prettify.js +2 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/redis-client.ts.html +2047 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/result-collector.ts.html +1396 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/sorter.js +210 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/swarm-manager.ts.html +1567 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/task-analyzer.ts.html +1297 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/task-executor.ts.html +1354 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/types.ts.html +790 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov-report/waiting-coordinator.ts.html +1846 -0
- package/.claude/skills/cfn-redis-coordination/coverage/lcov.info +2650 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-logger.d.ts +92 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-logger.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-logger.js +329 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-logger.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-recovery.d.ts +75 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-recovery.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-recovery.js +302 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-recovery.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/completion-reporter.d.ts +58 -0
- package/.claude/skills/cfn-redis-coordination/dist/completion-reporter.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/completion-reporter.js +237 -0
- package/.claude/skills/cfn-redis-coordination/dist/completion-reporter.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/context-manager.d.ts +63 -0
- package/.claude/skills/cfn-redis-coordination/dist/context-manager.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/context-manager.js +230 -0
- package/.claude/skills/cfn-redis-coordination/dist/context-manager.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/index.d.ts +45 -0
- package/.claude/skills/cfn-redis-coordination/dist/index.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/index.js +114 -0
- package/.claude/skills/cfn-redis-coordination/dist/index.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/mode-detector.d.ts +31 -0
- package/.claude/skills/cfn-redis-coordination/dist/mode-detector.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/mode-detector.js +185 -0
- package/.claude/skills/cfn-redis-coordination/dist/mode-detector.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/redis-client.d.ts +191 -0
- package/.claude/skills/cfn-redis-coordination/dist/redis-client.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/redis-client.js +509 -0
- package/.claude/skills/cfn-redis-coordination/dist/redis-client.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/result-collector.d.ts +75 -0
- package/.claude/skills/cfn-redis-coordination/dist/result-collector.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/result-collector.js +281 -0
- package/.claude/skills/cfn-redis-coordination/dist/result-collector.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/swarm-manager.d.ts +75 -0
- package/.claude/skills/cfn-redis-coordination/dist/swarm-manager.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/swarm-manager.js +354 -0
- package/.claude/skills/cfn-redis-coordination/dist/swarm-manager.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-analyzer.d.ts +62 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-analyzer.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-analyzer.js +305 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-analyzer.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-executor.d.ts +97 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-executor.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-executor.js +283 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-executor.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/types.d.ts +176 -0
- package/.claude/skills/cfn-redis-coordination/dist/types.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/types.js +81 -0
- package/.claude/skills/cfn-redis-coordination/dist/types.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/waiting-coordinator.d.ts +86 -0
- package/.claude/skills/cfn-redis-coordination/dist/waiting-coordinator.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/waiting-coordinator.js +419 -0
- package/.claude/skills/cfn-redis-coordination/dist/waiting-coordinator.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +553 -0
- package/.claude/skills/cfn-redis-coordination/jest.config.js +23 -0
- package/.claude/skills/cfn-redis-coordination/package-lock.json +5272 -0
- package/.claude/skills/cfn-redis-coordination/package.json +45 -0
- package/.claude/skills/cfn-redis-coordination/redis-cli-wrapper.sh +21 -8
- package/.claude/skills/cfn-redis-coordination/src/agent-logger.ts +446 -0
- package/.claude/skills/cfn-redis-coordination/src/agent-recovery.ts +454 -0
- package/.claude/skills/cfn-redis-coordination/src/completion-reporter.ts +396 -0
- package/.claude/skills/cfn-redis-coordination/src/context-manager.ts +327 -0
- package/.claude/skills/cfn-redis-coordination/src/index.ts +82 -0
- package/.claude/skills/cfn-redis-coordination/src/mode-detector.ts +155 -0
- package/.claude/skills/cfn-redis-coordination/src/redis/redis-client.ts +305 -0
- package/.claude/skills/cfn-redis-coordination/src/redis/redis-functions.ts +283 -0
- package/.claude/skills/cfn-redis-coordination/src/redis-client.ts +654 -0
- package/.claude/skills/cfn-redis-coordination/src/result-collector.ts +437 -0
- package/.claude/skills/cfn-redis-coordination/src/swarm-manager.ts +494 -0
- package/.claude/skills/cfn-redis-coordination/src/task-analyzer.ts +404 -0
- package/.claude/skills/cfn-redis-coordination/src/task-executor.ts +423 -0
- package/.claude/skills/cfn-redis-coordination/src/types.ts +235 -0
- package/.claude/skills/cfn-redis-coordination/src/waiting-coordinator.ts +587 -0
- package/.claude/skills/cfn-redis-coordination/test-connection-attempts.js +70 -0
- package/.claude/skills/cfn-redis-coordination/test-mode-simple.js +121 -0
- package/.claude/skills/cfn-redis-coordination/test-redis-check.js +84 -0
- package/.claude/skills/cfn-redis-coordination/test-task-mode-redis.cjs +391 -0
- package/.claude/skills/cfn-redis-coordination/tests/coordination.test.ts +788 -0
- package/.claude/skills/cfn-redis-coordination/tsconfig.json +31 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +13 -72
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +172 -62
- package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +465 -508
- package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +733 -743
- package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +13 -79
- package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +13 -18
- package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +13 -18
- package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +13 -18
- package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +15 -17
- package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +15 -17
- package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +15 -14
- package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +15 -17
- package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +15 -17
- package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +15 -17
- package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +23 -30
- package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +13 -18
- package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +13 -18
- package/claude-assets/agents/cfn-dev-team/reviewers/code-reviewer.md +312 -317
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +23 -20
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +23 -20
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +23 -20
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +23 -20
- package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +16 -21
- package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +15 -20
- package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +718 -737
- package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +817 -828
- package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +15 -20
- package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +8 -9
- package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +668 -684
- package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +15 -20
- package/claude-assets/agents/cfn-dev-team/testers/tester.md +248 -253
- package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +13 -18
- package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +13 -18
- package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +13 -18
- package/claude-assets/agents/custom/cfn-redis-operations.md +530 -0
- package/claude-assets/agents/custom/cfn-system-expert.md +77 -0
- package/claude-assets/cfn-extras/.gs-api-quota.json +16 -0
- package/claude-assets/cfn-extras/.gs-progress-state.json +22 -0
- package/claude-assets/cfn-extras/GOOGLE_SHEETS_IMPLEMENTATION_SUMMARY.md +414 -0
- package/claude-assets/cfn-extras/agents/google-sheets/README.md +114 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-advanced-analytics-specialist.md +288 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-api-integrator.md +127 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-automation-scripting-specialist.md +195 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-business-validator.md +179 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-collaboration-security-specialist.md +240 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-coordinator.md +214 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-data-transformer.md +127 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-data-validation-quality-specialist.md +177 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-data-validator.md +119 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-data-visualization-specialist.md +135 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-design-layout-specialist.md +109 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-formula-engineer.md +127 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-formula-engineering-specialist.md +138 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-formula-validator.md +128 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-generalist.md +645 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-integration-api-specialist.md +258 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-performance-analyst.md +125 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-performance-optimization-specialist.md +211 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-schema-designer.md +130 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-template-architecture-specialist.md +259 -0
- package/claude-assets/cfn-extras/docs/GOOGLE_SHEETS_CFN_LOOP.md +617 -0
- package/claude-assets/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +453 -0
- package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +272 -0
- package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh +254 -0
- package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/test.sh +174 -0
- package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/validate.sh +98 -0
- package/claude-assets/cfn-extras/skills/google-sheets-decomposition/SKILL.md +269 -0
- package/claude-assets/cfn-extras/skills/google-sheets-decomposition/decompose.sh +313 -0
- package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +237 -0
- package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/build-formula.sh +220 -0
- package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/test.sh +172 -0
- package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/validate.sh +98 -0
- package/claude-assets/cfn-extras/skills/google-sheets-progress/SKILL.md +287 -0
- package/claude-assets/cfn-extras/skills/google-sheets-progress/test.sh +385 -0
- package/claude-assets/cfn-extras/skills/google-sheets-progress/track-progress.sh +516 -0
- package/claude-assets/cfn-extras/skills/google-sheets-progress/validate.sh +119 -0
- package/claude-assets/cfn-extras/skills/google-sheets-sprint-order/SKILL.md +277 -0
- package/claude-assets/cfn-extras/skills/google-sheets-sprint-order/order-sprints.sh +233 -0
- package/claude-assets/cfn-extras/skills/google-sheets-validation/SKILL.md +352 -0
- package/claude-assets/cfn-extras/skills/google-sheets-validation/test.sh +355 -0
- package/claude-assets/cfn-extras/skills/google-sheets-validation/validate-state.sh +374 -0
- package/claude-assets/cfn-extras/skills/google-sheets-validation/validate.sh +128 -0
- package/claude-assets/commands/cfn-context.md +10 -0
- package/claude-assets/commands/cfn-loop-cli.md +36 -15
- package/claude-assets/commands/google-sheets/google-sheets-loop.md +289 -0
- package/claude-assets/hooks/cfn-pre-execution/SESSION_START_README.md +87 -0
- package/claude-assets/hooks/cfn-pre-execution/TEST_SESSION_START.md +128 -0
- package/claude-assets/hooks/cfn-pre-execution/session-start-context.sh +111 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/INTEGRATION_EXAMPLE.md +209 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/README.md +130 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md +243 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/agent-mappings.json +142 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh +173 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh +71 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/test-agent-selection.sh +282 -0
- package/claude-assets/skills/cfn-agent-selector/SKILL.md +143 -0
- package/claude-assets/skills/cfn-agent-selector/select-agents.sh +94 -0
- package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -2
- package/claude-assets/skills/cfn-docker-agent-spawning/spawn-agent.sh +21 -2
- package/claude-assets/skills/cfn-docker-coordination/.eslintrc.json +33 -0
- package/claude-assets/skills/cfn-docker-coordination/README.md +349 -0
- package/claude-assets/skills/cfn-docker-coordination/docker-helpers.sh +433 -0
- package/claude-assets/skills/cfn-docker-coordination/jest.config.js +25 -0
- package/claude-assets/skills/cfn-docker-coordination/package-lock.json +6827 -0
- package/claude-assets/skills/cfn-docker-coordination/package.json +38 -0
- package/claude-assets/skills/cfn-docker-coordination/src/agent-container.ts +471 -0
- package/claude-assets/skills/cfn-docker-coordination/src/docker-client.ts +483 -0
- package/claude-assets/skills/cfn-docker-coordination/src/health-checker.ts +418 -0
- package/claude-assets/skills/cfn-docker-coordination/src/index.ts +45 -0
- package/claude-assets/skills/cfn-docker-coordination/src/network-manager.ts +377 -0
- package/claude-assets/skills/cfn-docker-coordination/src/types.ts +412 -0
- package/claude-assets/skills/cfn-docker-coordination/src/volume-manager.ts +389 -0
- package/claude-assets/skills/cfn-docker-coordination/tests/agent-container.test.ts +379 -0
- package/claude-assets/skills/cfn-docker-coordination/tests/docker-client.test.ts +345 -0
- package/claude-assets/skills/cfn-docker-coordination/tests/health-checker.test.ts +535 -0
- package/claude-assets/skills/cfn-docker-coordination/tests/integration.test.ts +193 -0
- package/claude-assets/skills/cfn-docker-coordination/tests/network-manager.test.ts +352 -0
- package/claude-assets/skills/cfn-docker-coordination/tests/setup.ts +36 -0
- package/claude-assets/skills/cfn-docker-coordination/tsconfig.json +29 -0
- package/claude-assets/skills/cfn-docker-logging/INTEGRATION.md +268 -0
- package/claude-assets/skills/cfn-docker-logging/SAMPLE_OUTPUTS.md +237 -0
- package/claude-assets/skills/cfn-docker-logging/SKILL.md +442 -0
- package/claude-assets/skills/cfn-docker-logging/capture-container-logs.sh +120 -0
- package/claude-assets/skills/cfn-docker-logging/enable-logging.sh +430 -0
- package/claude-assets/skills/cfn-docker-logging/init-hybrid-logging.sh +210 -0
- package/claude-assets/skills/cfn-docker-logging/queries/analytics-summary.sh +87 -0
- package/claude-assets/skills/cfn-docker-logging/queries/query-agent-timeline.sh +51 -0
- package/claude-assets/skills/cfn-docker-logging/queries/query-consensus-history.sh +56 -0
- package/claude-assets/skills/cfn-docker-logging/queries/query-coordination-timeline.sh +39 -0
- package/claude-assets/skills/cfn-docker-logging/queries/query-failed-containers.sh +40 -0
- package/claude-assets/skills/cfn-docker-logging/queries/query-gate-checks.sh +39 -0
- package/claude-assets/skills/cfn-docker-logging/schema.sql +111 -0
- package/claude-assets/skills/cfn-docker-logging/sqlite-helpers.sh +240 -0
- package/claude-assets/skills/cfn-docker-logging/test-hybrid-logging.sh +331 -0
- package/claude-assets/skills/cfn-docker-loop-orchestration/orchestrate.sh +11 -5
- package/claude-assets/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +348 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/README.md +294 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/jest.config.js +37 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/package-lock.json +5259 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/package.json +40 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/src/coordinator.ts +801 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/src/index.ts +42 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/src/types.ts +351 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +1464 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/tsconfig.json +30 -0
- package/claude-assets/skills/cfn-error-logging/.eslintrc.json +57 -0
- package/claude-assets/skills/cfn-error-logging/.prettierrc.json +10 -0
- package/claude-assets/skills/cfn-error-logging/MIGRATION_SUMMARY.md +485 -0
- package/claude-assets/skills/cfn-error-logging/package.json +47 -0
- package/claude-assets/skills/cfn-error-logging/src/error-logger.ts +1042 -0
- package/claude-assets/skills/cfn-error-logging/src/index.ts +12 -0
- package/claude-assets/skills/cfn-error-logging/src/types.ts +456 -0
- package/claude-assets/skills/cfn-error-logging/tests/error-logger.test.ts +1302 -0
- package/claude-assets/skills/cfn-error-logging/tsconfig.json +38 -0
- package/claude-assets/skills/cfn-loop-orchestration/.eslintrc.js +56 -0
- package/claude-assets/skills/cfn-loop-orchestration/.prettierrc.json +18 -0
- package/claude-assets/skills/cfn-loop-orchestration/README.md +149 -41
- package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +39 -577
- package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +49 -270
- package/claude-assets/skills/cfn-loop-orchestration/jest.config.js +67 -0
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate-wrapper.sh +268 -0
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +91 -8
- package/claude-assets/skills/cfn-loop-orchestration/package-lock.json +5470 -0
- package/claude-assets/skills/cfn-loop-orchestration/package.json +49 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/agent-spawner/agent-spawner.ts +34 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/gate-checker/gate-checker.ts +36 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +115 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/parse-test-results.ts +372 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/index.ts +14 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/orchestrator/orchestrator.ts +31 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/redis/redis-coordinator.ts +72 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/types.ts +188 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/utils/logger.ts +32 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/consensus.test.ts +142 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +199 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/gate-check.test.ts +325 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/iteration-manager.test.ts +132 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/parse-test-results.test.ts +382 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/setup.ts +22 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/timeout-calculator.test.ts +118 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/types.test.ts +132 -0
- package/claude-assets/skills/cfn-loop-orchestration/tsconfig.json +54 -0
- package/claude-assets/skills/cfn-redis-coordination/bash-wrappers/store-context.sh +23 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/clover.xml +1447 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/coverage-final.json +13 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/agent-logger.ts.html +1423 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/agent-recovery.ts.html +1447 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/base.css +224 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/block-navigation.js +87 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/completion-reporter.ts.html +1273 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/context-manager.ts.html +1066 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/favicon.png +0 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/index.html +281 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/mode-detector.ts.html +550 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/prettify.css +1 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/prettify.js +2 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/redis-client.ts.html +2047 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/result-collector.ts.html +1396 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/sorter.js +210 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/swarm-manager.ts.html +1567 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/task-analyzer.ts.html +1297 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/task-executor.ts.html +1354 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/types.ts.html +790 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov-report/waiting-coordinator.ts.html +1846 -0
- package/claude-assets/skills/cfn-redis-coordination/coverage/lcov.info +2650 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-logger.d.ts +92 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-logger.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-logger.js +329 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-logger.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-recovery.d.ts +75 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-recovery.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-recovery.js +302 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-recovery.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/completion-reporter.d.ts +58 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/completion-reporter.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/completion-reporter.js +237 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/completion-reporter.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/context-manager.d.ts +63 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/context-manager.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/context-manager.js +230 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/context-manager.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/index.d.ts +45 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/index.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/index.js +114 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/index.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/mode-detector.d.ts +31 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/mode-detector.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/mode-detector.js +185 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/mode-detector.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/redis-client.d.ts +191 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/redis-client.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/redis-client.js +509 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/redis-client.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/result-collector.d.ts +75 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/result-collector.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/result-collector.js +281 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/result-collector.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/swarm-manager.d.ts +75 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/swarm-manager.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/swarm-manager.js +354 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/swarm-manager.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-analyzer.d.ts +62 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-analyzer.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-analyzer.js +305 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-analyzer.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-executor.d.ts +97 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-executor.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-executor.js +283 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-executor.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/types.d.ts +176 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/types.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/types.js +81 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/types.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/waiting-coordinator.d.ts +86 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/waiting-coordinator.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/waiting-coordinator.js +419 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/waiting-coordinator.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +553 -0
- package/claude-assets/skills/cfn-redis-coordination/jest.config.js +23 -0
- package/claude-assets/skills/cfn-redis-coordination/package-lock.json +5272 -0
- package/claude-assets/skills/cfn-redis-coordination/package.json +45 -0
- package/claude-assets/skills/cfn-redis-coordination/redis-cli-wrapper.sh +21 -8
- package/claude-assets/skills/cfn-redis-coordination/src/agent-logger.ts +446 -0
- package/claude-assets/skills/cfn-redis-coordination/src/agent-recovery.ts +454 -0
- package/claude-assets/skills/cfn-redis-coordination/src/completion-reporter.ts +396 -0
- package/claude-assets/skills/cfn-redis-coordination/src/context-manager.ts +327 -0
- package/claude-assets/skills/cfn-redis-coordination/src/index.ts +82 -0
- package/claude-assets/skills/cfn-redis-coordination/src/mode-detector.ts +155 -0
- package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-client.ts +305 -0
- package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-functions.ts +283 -0
- package/claude-assets/skills/cfn-redis-coordination/src/redis-client.ts +654 -0
- package/claude-assets/skills/cfn-redis-coordination/src/result-collector.ts +437 -0
- package/claude-assets/skills/cfn-redis-coordination/src/swarm-manager.ts +494 -0
- package/claude-assets/skills/cfn-redis-coordination/src/task-analyzer.ts +404 -0
- package/claude-assets/skills/cfn-redis-coordination/src/task-executor.ts +423 -0
- package/claude-assets/skills/cfn-redis-coordination/src/types.ts +235 -0
- package/claude-assets/skills/cfn-redis-coordination/src/waiting-coordinator.ts +587 -0
- package/claude-assets/skills/cfn-redis-coordination/test-connection-attempts.js +70 -0
- package/claude-assets/skills/cfn-redis-coordination/test-mode-simple.js +121 -0
- package/claude-assets/skills/cfn-redis-coordination/test-redis-check.js +84 -0
- package/claude-assets/skills/cfn-redis-coordination/test-task-mode-redis.cjs +391 -0
- package/claude-assets/skills/cfn-redis-coordination/tests/coordination.test.ts +788 -0
- package/claude-assets/skills/cfn-redis-coordination/tsconfig.json +31 -0
- package/claude-assets/skills/cfn-skill-propagation/README.md +233 -0
- package/claude-assets/skills/cfn-skill-propagation/package-lock.json +5174 -0
- package/claude-assets/skills/cfn-skill-propagation/package.json +52 -0
- package/claude-assets/skills/cfn-skill-propagation/propagate-skill-update.sh +32 -0
- package/claude-assets/skills/cfn-skill-propagation/src/cli.ts +75 -0
- package/claude-assets/skills/cfn-skill-propagation/src/database-adapter.ts +239 -0
- package/claude-assets/skills/cfn-skill-propagation/src/file-system-adapter.ts +113 -0
- package/claude-assets/skills/cfn-skill-propagation/src/index.ts +72 -0
- package/claude-assets/skills/cfn-skill-propagation/src/logger.ts +43 -0
- package/claude-assets/skills/cfn-skill-propagation/src/metadata-parser.ts +154 -0
- package/claude-assets/skills/cfn-skill-propagation/src/skill-propagator.ts +274 -0
- package/claude-assets/skills/cfn-skill-propagation/src/skill-validator.ts +179 -0
- package/claude-assets/skills/cfn-skill-propagation/src/types.ts +143 -0
- package/claude-assets/skills/cfn-skill-propagation/src/version-manager.ts +118 -0
- package/claude-assets/skills/cfn-skill-propagation/tests/file-system-adapter.test.ts +91 -0
- package/claude-assets/skills/cfn-skill-propagation/tests/metadata-parser.test.ts +176 -0
- package/claude-assets/skills/cfn-skill-propagation/tests/skill-propagator.test.ts +209 -0
- package/claude-assets/skills/cfn-skill-propagation/tests/skill-validator.test.ts +203 -0
- package/claude-assets/skills/cfn-skill-propagation/tests/version-manager.test.ts +115 -0
- package/claude-assets/skills/cfn-skill-propagation/tsconfig.json +34 -0
- package/claude-assets/skills/task-classifier/SKILL.md +81 -0
- package/claude-assets/skills/task-classifier/classify-task.sh +62 -0
- package/claude-assets/skills/workflow-codification/package-lock.json +5170 -0
- package/claude-assets/skills/workflow-codification/package.json +30 -0
- package/claude-assets/skills/workflow-codification/src/index.ts +24 -0
- package/claude-assets/skills/workflow-codification/src/pattern-analyzer.ts +537 -0
- package/claude-assets/skills/workflow-codification/src/types.ts +180 -0
- package/claude-assets/skills/workflow-codification/tests/pattern-analyzer.test.ts +960 -0
- package/claude-assets/skills/workflow-codification/tsconfig.json +34 -0
- package/claude-assets/skills/workflow-codification/workflow-codification.db +0 -0
- package/dist/agent-spawner/agent-spawner.js +448 -0
- package/dist/agent-spawner/agent-spawner.js.map +1 -0
- package/dist/agent-spawner/index.js +10 -0
- package/dist/agent-spawner/index.js.map +1 -0
- package/dist/agent-spawner/types.js +14 -0
- package/dist/agent-spawner/types.js.map +1 -0
- package/dist/cli/agent-executor.js +47 -1
- package/dist/cli/agent-executor.js.map +1 -1
- package/dist/cli/agent-spawn.js +4 -1
- package/dist/cli/agent-spawn.js.map +1 -1
- package/dist/cli/config-manager.js +91 -109
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/cli/tool-executor.js +3 -1
- package/dist/cli/tool-executor.js.map +1 -1
- package/dist/gate-checker/gate-checker.js +292 -0
- package/dist/gate-checker/gate-checker.js.map +1 -0
- package/dist/gate-checker/types.js +94 -0
- package/dist/gate-checker/types.js.map +1 -0
- package/dist/lib/database-service/connection-pool-manager.js +2 -1
- package/dist/lib/database-service/connection-pool-manager.js.map +1 -1
- package/dist/orchestrator/index.js +10 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/orchestrate.js +496 -0
- package/dist/orchestrator/orchestrate.js.map +1 -0
- package/dist/orchestrator/types.js +58 -0
- package/dist/orchestrator/types.js.map +1 -0
- package/package.json +1 -1
- package/scripts/clean-agent-profiles.sh +112 -0
- package/scripts/switch-api.sh +142 -4
- package/scripts/verify-no-secrets.sh +6 -13
- package/tests/README.md +175 -58
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/config-manager.js"],"sourcesContent":["\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar fs = require(\"fs/promises\");\nvar path = require(\"path\");\nvar ajv_1 = require(\"ajv\");\nvar get_1 = require(\"lodash/get\");\nvar ConfigManager = /** @class */ (function () {\n function ConfigManager() {\n this.configPath = path.join(process.env.HOME || \"\", \".claude-flow-config.json\");\n this.schemaPath = path.join(__dirname, \"../../.claude/skills/config-management/config.json\");\n this.ajv = new ajv_1.default();\n }\n ConfigManager.getInstance = function () {\n if (!ConfigManager.instance) {\n ConfigManager.instance = new ConfigManager();\n }\n return ConfigManager.instance;\n };\n ConfigManager.prototype.readConfig = function () {\n return __awaiter(this, void 0, void 0, function () {\n var configContent, error_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 2, , 3]);\n return [4 /*yield*/, fs.readFile(this.configPath, \"utf-8\")];\n case 1:\n configContent = _a.sent();\n return [2 /*return*/, JSON.parse(configContent)];\n case 2:\n error_1 = _a.sent();\n // If config doesn't exist, create from schema\n return [2 /*return*/, this.resetToDefaults()];\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n ConfigManager.prototype.writeConfig = function (config) {\n return __awaiter(this, void 0, void 0, function () {\n var schemaContent, schema, validate;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fs.readFile(this.schemaPath, \"utf-8\")];\n case 1:\n schemaContent = _a.sent();\n schema = JSON.parse(schemaContent);\n validate = this.ajv.compile(schema);\n if (!validate(config)) {\n throw new Error(\"Invalid configuration: \" + this.ajv.errorsText(validate.errors));\n }\n return [4 /*yield*/, fs.writeFile(this.configPath, JSON.stringify(config, null, 2), \"utf-8\")];\n case 2:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n ConfigManager.prototype.getValue = function (keyPath) {\n return __awaiter(this, void 0, void 0, function () {\n var config, value, customConfig;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.readConfig()];\n case 1:\n config = _a.sent();\n value = (0, get_1.default)(config, keyPath);\n if (!(value === undefined)) return [3 /*break*/, 3];\n return [4 /*yield*/, this.readCustomConfig()];\n case 2:\n customConfig = _a.sent();\n return [2 /*return*/, (0, get_1.default)(customConfig, keyPath)];\n case 3: return [2 /*return*/, value];\n }\n });\n });\n };\n ConfigManager.prototype.readCustomConfig = function () {\n return __awaiter(this, void 0, void 0, function () {\n var customConfigPath, customConfigContent, error_2;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 2, , 3]);\n customConfigPath = path.join(process.env.HOME || \"\", \".claude-flow-custom-config.json\");\n return [4 /*yield*/, fs.readFile(customConfigPath, \"utf-8\")];\n case 1:\n customConfigContent = _a.sent();\n return [2 /*return*/, JSON.parse(customConfigContent)];\n case 2:\n error_2 = _a.sent();\n // If custom config doesn't exist or can't be read, return empty object\n return [2 /*return*/, {}];\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n ConfigManager.prototype.set = function (key, value) {\n return __awaiter(this, void 0, void 0, function () {\n var config;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.readConfig()];\n case 1:\n config = _a.sent();\n // Type assertion to handle both full object and nested key\n if (typeof value === \"object\" && value !== null) {\n config[key] = value;\n }\n else {\n throw new Error(\"Invalid configuration value\");\n }\n return [4 /*yield*/, this.writeConfig(config)];\n case 2:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n ConfigManager.prototype.getAll = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.readConfig()];\n });\n });\n };\n ConfigManager.prototype.resetToDefaults = function () {\n return __awaiter(this, void 0, void 0, function () {\n var schemaContent, schema, defaultConfig;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fs.readFile(this.schemaPath, \"utf-8\")];\n case 1:\n schemaContent = _a.sent();\n schema = JSON.parse(schemaContent);\n defaultConfig = {\n redis: {\n host: schema.properties.redis.properties.host.default,\n port: schema.properties.redis.properties.port.default,\n },\n agent: {\n default_strategy: schema.properties.agent.properties.default_strategy.default,\n max_concurrent_agents: schema.properties.agent.properties.max_concurrent_agents.default,\n log_level: schema.properties.agent.properties.log_level.default,\n },\n security: {\n enabled: schema.properties.security.properties.enabled.default,\n max_retry_attempts: schema.properties.security.properties.max_retry_attempts.default,\n },\n };\n return [4 /*yield*/, this.writeConfig(defaultConfig)];\n case 2:\n _a.sent();\n return [2 /*return*/, defaultConfig];\n }\n });\n });\n };\n return ConfigManager;\n}());\nexports.default = ConfigManager;\n"],"names":["__awaiter","thisArg","_arguments","P","generator","adopt","value","resolve","Promise","reject","fulfilled","step","next","e","rejected","result","done","then","apply","__generator","body","_","label","sent","t","trys","ops","f","y","g","Object","create","Iterator","prototype","verb","Symbol","iterator","n","v","op","TypeError","call","pop","length","push","defineProperty","exports","fs","require","path","ajv_1","get_1","ConfigManager","configPath","join","process","env","HOME","schemaPath","__dirname","ajv","default","getInstance","instance","readConfig","configContent","error_1","_a","readFile","JSON","parse","resetToDefaults","writeConfig","config","schemaContent","schema","validate","compile","Error","errorsText","errors","writeFile","stringify","getValue","keyPath","customConfig","undefined","readCustomConfig","customConfigPath","customConfigContent","error_2","set","key","getAll","defaultConfig","redis","host","properties","port","agent","default_strategy","max_concurrent_agents","log_level","security","enabled","max_retry_attempts"],"mappings":"AAAA;AACA,IAAIA,YAAY,AAAC,IAAI,IAAI,IAAI,CAACA,SAAS,IAAK,SAAUC,OAAO,EAAEC,UAAU,EAAEC,CAAC,EAAEC,SAAS;IACnF,SAASC,MAAMC,KAAK;QAAI,OAAOA,iBAAiBH,IAAIG,QAAQ,IAAIH,EAAE,SAAUI,OAAO;YAAIA,QAAQD;QAAQ;IAAI;IAC3G,OAAO,IAAKH,CAAAA,KAAMA,CAAAA,IAAIK,OAAM,CAAC,EAAG,SAAUD,OAAO,EAAEE,MAAM;QACrD,SAASC,UAAUJ,KAAK;YAAI,IAAI;gBAAEK,KAAKP,UAAUQ,IAAI,CAACN;YAAS,EAAE,OAAOO,GAAG;gBAAEJ,OAAOI;YAAI;QAAE;QAC1F,SAASC,SAASR,KA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ACG,gBAAgB,CAACvC,OAAO;gCAC7EwC,uBAAuB1B,OAAOsB,UAAU,CAACE,KAAK,CAACF,UAAU,CAACI,qBAAqB,CAACxC,OAAO;gCACvFyC,WAAW3B,OAAOsB,UAAU,CAACE,KAAK,CAACF,UAAU,CAACK,SAAS,CAACzC,OAAO;4BACnE;4BACA0C,UAAU;gCACNC,SAAS7B,OAAOsB,UAAU,CAACM,QAAQ,CAACN,UAAU,CAACO,OAAO,CAAC3C,OAAO;gCAC9D4C,oBAAoB9B,OAAOsB,UAAU,CAACM,QAAQ,CAACN,UAAU,CAACQ,kBAAkB,CAAC5C,OAAO;4BACxF;wBACJ;wBACA,OAAO;4BAAC,EAAE,OAAO;4BAAI,IAAI,CAACW,WAAW,CAACsB;yBAAe;oBACzD,KAAK;wBACD3B,GAAG5C,IAAI;wBACP,OAAO;4BAAC,EAAE,QAAQ;4BAAIuE;yBAAc;gBAC5C;YACJ;QACJ;IACJ;IACA,OAAO1C;AACX;AACAN,QAAQe,OAAO,GAAGT"}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/config-manager.ts"],"sourcesContent":["import * as fs from \"fs/promises\";\nimport * as path from \"path\";\nimport Ajv from \"ajv\";\nimport * as lodash from \"lodash\";\n\ninterface ConfigSchema {\n redis: {\n host: string;\n port: number;\n password?: string;\n };\n agent: {\n default_strategy: string;\n max_concurrent_agents: number;\n log_level: \"debug\" | \"info\" | \"warn\" | \"error\";\n };\n security: {\n enabled: boolean;\n max_retry_attempts: number;\n };\n}\n\nclass ConfigManager {\n private static _instance: ConfigManager | null = null;\n private configPath: string;\n private schemaPath: string;\n private ajv: Ajv;\n\n private constructor() {\n this.configPath = path.join(\n process.env.HOME || \"\",\n \".claude-flow-config.json\",\n );\n this.schemaPath = path.join(\n __dirname,\n \"../../.claude/skills/config-management/config.json\",\n );\n this.ajv = new Ajv();\n }\n\n public static getInstance(): ConfigManager {\n if (!ConfigManager._instance) {\n ConfigManager._instance = new ConfigManager();\n }\n return ConfigManager._instance;\n }\n\n private async readConfig(): Promise<ConfigSchema> {\n try {\n const configContent = await fs.readFile(this.configPath, \"utf-8\");\n return JSON.parse(configContent) as ConfigSchema;\n } catch (error) {\n // If config doesn't exist, create from schema\n return this.resetToDefaults();\n }\n }\n\n private async writeConfig(config: ConfigSchema): Promise<void> {\n const schemaContent = await fs.readFile(this.schemaPath, \"utf-8\");\n const schema = JSON.parse(schemaContent);\n\n const validate = this.ajv.compile(schema);\n if (!validate(config)) {\n throw new Error(\n \"Invalid configuration: \" + this.ajv.errorsText(validate.errors),\n );\n }\n\n await fs.writeFile(\n this.configPath,\n JSON.stringify(config, null, 2),\n \"utf-8\",\n );\n }\n\n public async getValue(keyPath: string): Promise<any> {\n const config = await this.readConfig();\n const value = lodash.get(config, keyPath);\n\n if (value === undefined) {\n // Check if it's a custom key path not in the schema\n const customConfig = await this.readCustomConfig();\n return lodash.get(customConfig, keyPath);\n }\n\n return value;\n }\n\n private async readCustomConfig(): Promise<Record<string, any>> {\n try {\n const customConfigPath = path.join(\n process.env.HOME || \"\",\n \".claude-flow-custom-config.json\",\n );\n const customConfigContent = await fs.readFile(customConfigPath, \"utf-8\");\n return JSON.parse(customConfigContent);\n } catch (error) {\n // If custom config doesn't exist or can't be read, return empty object\n return {};\n }\n }\n\n public async set(key: keyof ConfigSchema, value: ConfigSchema[keyof ConfigSchema]): Promise<void> {\n const config = await this.readConfig();\n\n // Type assertion to handle full object\n if (typeof value === \"object\" && value !== null) {\n config[key] = value;\n } else {\n throw new Error(\"Invalid configuration value\");\n }\n\n await this.writeConfig(config);\n }\n\n public async getAll(): Promise<ConfigSchema> {\n return this.readConfig();\n }\n\n public async resetToDefaults(): Promise<ConfigSchema> {\n const schemaContent = await fs.readFile(this.schemaPath, \"utf-8\");\n const schema = JSON.parse(schemaContent);\n\n // Extract default values from the schema\n const defaultConfig: ConfigSchema = {\n redis: {\n host: schema.properties.redis.properties.host.default,\n port: schema.properties.redis.properties.port.default,\n },\n agent: {\n default_strategy:\n schema.properties.agent.properties.default_strategy.default,\n max_concurrent_agents:\n schema.properties.agent.properties.max_concurrent_agents.default,\n log_level: schema.properties.agent.properties.log_level.default,\n },\n security: {\n enabled: schema.properties.security.properties.enabled.default,\n max_retry_attempts:\n schema.properties.security.properties.max_retry_attempts.default,\n },\n };\n\n await this.writeConfig(defaultConfig);\n return defaultConfig;\n }\n}\n\nexport default ConfigManager;"],"names":["fs","path","Ajv","lodash","ConfigManager","_instance","configPath","schemaPath","ajv","join","process","env","HOME","__dirname","getInstance","readConfig","configContent","readFile","JSON","parse","error","resetToDefaults","writeConfig","config","schemaContent","schema","validate","compile","Error","errorsText","errors","writeFile","stringify","getValue","keyPath","value","get","undefined","customConfig","readCustomConfig","customConfigPath","customConfigContent","set","key","getAll","defaultConfig","redis","host","properties","default","port","agent","default_strategy","max_concurrent_agents","log_level","security","enabled","max_retry_attempts"],"mappings":"AAAA,YAAYA,QAAQ,cAAc;AAClC,YAAYC,UAAU,OAAO;AAC7B,OAAOC,SAAS,MAAM;AACtB,YAAYC,YAAY,SAAS;AAmBjC,IAAA,AAAMC,gBAAN,MAAMA;IACJ,OAAeC,YAAkC,KAAK;IAC9CC,WAAmB;IACnBC,WAAmB;IACnBC,IAAS;IAEjB,aAAsB;QACpB,IAAI,CAACF,UAAU,GAAGL,KAAKQ,IAAI,CACzBC,QAAQC,GAAG,CAACC,IAAI,IAAI,IACpB;QAEF,IAAI,CAACL,UAAU,GAAGN,KAAKQ,IAAI,CACzBI,WACA;QAEF,IAAI,CAACL,GAAG,GAAG,IAAIN;IACjB;IAEA,OAAcY,cAA6B;QACzC,IAAI,CAACV,cAAcC,SAAS,EAAE;YAC5BD,cAAcC,SAAS,GAAG,IAAID;QAChC;QACA,OAAOA,cAAcC,SAAS;IAChC;IAEA,MAAcU,aAAoC;QAChD,IAAI;YACF,MAAMC,gBAAgB,MAAMhB,GAAGiB,QAAQ,CAAC,IAAI,CAACX,UAAU,EAAE;YACzD,OAAOY,KAAKC,KAAK,CAAC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MAAM;YAC/CZ,MAAM,CAACoB,IAAI,GAAGR;QAChB,OAAO;YACL,MAAM,IAAIP,MAAM;QAClB;QAEA,MAAM,IAAI,CAACN,WAAW,CAACC;IACzB;IAEA,MAAaqB,SAAgC;QAC3C,OAAO,IAAI,CAAC7B,UAAU;IACxB;IAEA,MAAaM,kBAAyC;QACpD,MAAMG,gBAAgB,MAAMxB,GAAGiB,QAAQ,CAAC,IAAI,CAACV,UAAU,EAAE;QACzD,MAAMkB,SAASP,KAAKC,KAAK,CAACK;QAE1B,yCAAyC;QACzC,MAAMqB,gBAA8B;YAClCC,OAAO;gBACLC,MAAMtB,OAAOuB,UAAU,CAACF,KAAK,CAACE,UAAU,CAACD,IAAI,CAACE,OAAO;gBACrDC,MAAMzB,OAAOuB,UAAU,CAACF,KAAK,CAACE,UAAU,CAACE,IAAI,CAACD,OAAO;YACvD;YACAE,OAAO;gBACLC,kBACE3B,OAAOuB,UAAU,CAACG,KAAK,CAACH,UAAU,CAACI,gBAAgB,CAACH,OAAO;gBAC7DI,uBACE5B,OAAOuB,UAAU,CAACG,KAAK,CAACH,UAAU,CAACK,qBAAqB,CAACJ,OAAO;gBAClEK,WAAW7B,OAAOuB,UAAU,CAACG,KAAK,CAACH,UAAU,CAACM,SAAS,CAACL,OAAO;YACjE;YACAM,UAAU;gBACRC,SAAS/B,OAAOuB,UAAU,CAACO,QAAQ,CAACP,UAAU,CAACQ,OAAO,CAACP,OAAO;gBAC9DQ,oBACEhC,OAAOuB,UAAU,CAACO,QAAQ,CAACP,UAAU,CAACS,kBAAkB,CAACR,OAAO;YACpE;QACF;QAEA,MAAM,IAAI,CAAC3B,WAAW,CAACuB;QACvB,OAAOA;IACT;AACF;AAEA,eAAezC,cAAc"} config = _a.sent();\n // Type assertion to handle both full object and nested key\n if (typeof value === \"object\" && value !== null) {\n config[key] = value;\n }\n else {\n throw new Error(\"Invalid configuration value\");\n }\n return [4 /*yield*/, this.writeConfig(config)];\n case 2:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n ConfigManager.prototype.getAll = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, this.readConfig()];\n });\n });\n };\n ConfigManager.prototype.resetToDefaults = function () {\n return __awaiter(this, void 0, void 0, function () {\n var schemaContent, schema, defaultConfig;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fs.readFile(this.schemaPath, \"utf-8\")];\n case 1:\n schemaContent = _a.sent();\n schema = JSON.parse(schemaContent);\n defaultConfig = {\n redis: {\n host: schema.properties.redis.properties.host.default,\n port: schema.properties.redis.properties.port.default,\n },\n agent: {\n default_strategy: schema.properties.agent.properties.default_strategy.default,\n max_concurrent_agents: schema.properties.agent.properties.max_concurrent_agents.default,\n log_level: schema.properties.agent.properties.log_level.default,\n },\n security: {\n enabled: schema.properties.security.properties.enabled.default,\n max_retry_attempts: schema.properties.security.properties.max_retry_attempts.default,\n },\n };\n return [4 /*yield*/, this.writeConfig(defaultConfig)];\n case 2:\n _a.sent();\n return [2 /*return*/, defaultConfig];\n }\n });\n });\n };\n return ConfigManager;\n}());\nexports.default = ConfigManager;\n"],"names":["__awaiter","thisArg","_arguments","P","generator","adopt","value","resolve","Promise","reject","fulfilled","step","next","e","rejected","result","done","then","apply","__generator","body","_","label","sent","t","trys","ops","f","y","g","Object","create","Iterator","prototype","verb","Symbol","iterator","n","v","op","TypeError","call","pop","length","push","defineProperty","exports","fs","require","path","ajv_1","get_1","ConfigManager","configPath","join","process","env","HOME","schemaPath","__dirname","ajv","default","getInstance","instance","readConfig","configContent","error_1","_a","readFile","JSON","parse","resetToDefaults","writeConfig","config","schemaContent","schema","validate","compile","Error","errorsText","errors","writeFile","stringify","getValue","keyPath","customConfig","undefined","readCustomConfig","customConfigPath","customConfigContent","error_2","set","key","getAll","defaultConfig","redis","host","properties","port","agent","default_strategy","max_concurrent_agents","log_level","security","enabled","max_retry_attempts"],"mappings":"AAAA;AACA,IAAIA,YAA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Z,KAAK;wBAAG,OAAO;4BAAC,EAAE,OAAO;4BAAIyB,GAAGqB,QAAQ,CAAC,IAAI,CAACV,UAAU,EAAE;yBAAS;oBACnE,KAAK;wBACDgB,gBAAgBP,GAAG5C,IAAI;wBACvBoD,SAASN,KAAKC,KAAK,CAACI;wBACpBoB,gBAAgB;4BACZC,OAAO;gCACHC,MAAMrB,OAAOsB,UAAU,CAACF,KAAK,CAACE,UAAU,CAACD,IAAI,CAACnC,OAAO;gCACrDqC,MAAMvB,OAAOsB,UAAU,CAACF,KAAK,CAACE,UAAU,CAACC,IAAI,CAACrC,OAAO;4BACzD;4BACAsC,OAAO;gCACHC,kBAAkBzB,OAAOsB,UAAU,CAACE,KAAK,CAACF,UAAU,CAACG,gBAAgB,CAACvC,OAAO;gCAC7EwC,uBAAuB1B,OAAOsB,UAAU,CAACE,KAAK,CAACF,UAAU,CAACI,qBAAqB,CAACxC,OAAO;gCACvFyC,WAAW3B,OAAOsB,UAAU,CAACE,KAAK,CAACF,UAAU,CAACK,SAAS,CAACzC,OAAO;4BACnE;4BACA0C,UAAU;gCACNC,SAAS7B,OAAOsB,UAAU,CAACM,QAAQ,CAACN,UAAU,CAACO,OAAO,CAAC3C,OAAO;gCAC9D4C,oBAAoB9B,OAAOsB,UAAU,CAACM,QAAQ,CAACN,UAAU,CAACQ,kBAAkB,CAAC5C,OAAO;4BACxF;wBACJ;wBACA,OAAO;4BAAC,EAAE,OAAO;4BAAI,IAAI,CAACW,WAAW,CAACsB;yBAAe;oBACzD,KAAK;wBACD3B,GAAG5C,IAAI;wBACP,OAAO;4BAAC,EAAE,QAAQ;4BAAIuE;yBAAc;gBAC5C;YACJ;QACJ;IACJ;IACA,OAAO1C;AACX;AACAN,QAAQe,OAAO,GAAGT"}
|
|
@@ -139,9 +139,11 @@ const execAsync = promisify(exec);
|
|
|
139
139
|
return `Command started in background: ${command}`;
|
|
140
140
|
}
|
|
141
141
|
// Execute synchronously with timeout
|
|
142
|
+
// CRITICAL: Use /bin/bash instead of /bin/sh for [[ ]] support
|
|
142
143
|
const { stdout, stderr } = await execAsync(command, {
|
|
143
144
|
timeout: timeoutMs,
|
|
144
|
-
maxBuffer: 10 * 1024 * 1024
|
|
145
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
146
|
+
shell: '/bin/bash' // REQUIRED: Coordinator uses [[ ]] conditionals
|
|
145
147
|
});
|
|
146
148
|
return stdout + stderr;
|
|
147
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/tool-executor.ts"],"sourcesContent":["/**\r\n * Tool Executor for CLI-Spawned Agents\r\n *\r\n * Executes tools requested by agents via Anthropic API tool_use blocks.\r\n * Implements Read, Write, Edit, Bash, TodoWrite, Glob, Grep.\r\n */\r\n\r\nimport fs from 'fs/promises';\r\nimport { exec } from 'child_process';\r\nimport { promisify } from 'util';\r\nimport { glob } from 'glob';\r\n\r\nconst execAsync = promisify(exec);\r\n\r\nexport interface ToolUse {\r\n type: 'tool_use';\r\n id: string;\r\n name: string;\r\n input: Record<string, any>;\r\n}\r\n\r\nexport interface ToolResult {\r\n type: 'tool_result';\r\n tool_use_id: string;\r\n content: string;\r\n is_error?: boolean;\r\n}\r\n\r\n/**\r\n * Execute a single tool and return result\r\n */\r\nexport async function executeTool(toolUse: ToolUse): Promise<ToolResult> {\r\n console.log(`[tool-executor] Executing tool: ${toolUse.name}`);\r\n console.log(`[tool-executor] Tool use ID: ${toolUse.id}`);\r\n\r\n try {\r\n let result: string;\r\n\r\n switch (toolUse.name) {\r\n case 'Read':\r\n result = await executeRead(toolUse.input);\r\n break;\r\n\r\n case 'Write':\r\n result = await executeWrite(toolUse.input);\r\n break;\r\n\r\n case 'Edit':\r\n result = await executeEdit(toolUse.input);\r\n break;\r\n\r\n case 'Bash':\r\n result = await executeBash(toolUse.input);\r\n break;\r\n\r\n case 'TodoWrite':\r\n result = await executeTodoWrite(toolUse.input);\r\n break;\r\n\r\n case 'Glob':\r\n result = await executeGlob(toolUse.input);\r\n break;\r\n\r\n case 'Grep':\r\n result = await executeGrep(toolUse.input);\r\n break;\r\n\r\n default:\r\n throw new Error(`Unknown tool: ${toolUse.name}`);\r\n }\r\n\r\n console.log(`[tool-executor] ✓ Tool executed successfully`);\r\n\r\n return {\r\n type: 'tool_result',\r\n tool_use_id: toolUse.id,\r\n content: result\r\n };\r\n } catch (error) {\r\n console.error(`[tool-executor] ✗ Tool execution failed:`, error);\r\n\r\n return {\r\n type: 'tool_result',\r\n tool_use_id: toolUse.id,\r\n content: error instanceof Error ? error.message : String(error),\r\n is_error: true\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Execute Read tool\r\n */\r\nasync function executeRead(input: Record<string, any>): Promise<string> {\r\n const { file_path, offset, limit } = input;\r\n\r\n if (!file_path) {\r\n throw new Error('file_path parameter is required');\r\n }\r\n\r\n const content = await fs.readFile(file_path, 'utf-8');\r\n const lines = content.split('\\n');\r\n\r\n // Apply offset and limit if provided\r\n const startLine = offset ? Number(offset) - 1 : 0;\r\n const endLine = limit ? startLine + Number(limit) : lines.length;\r\n const selectedLines = lines.slice(startLine, endLine);\r\n\r\n // Format with line numbers (cat -n style)\r\n const formatted = selectedLines\r\n .map((line, idx) => `${String(startLine + idx + 1).padStart(6)}→${line}`)\r\n .join('\\n');\r\n\r\n return formatted;\r\n}\r\n\r\n/**\r\n * Execute Write tool\r\n */\r\nasync function executeWrite(input: Record<string, any>): Promise<string> {\r\n const { file_path, content } = input;\r\n\r\n if (!file_path) {\r\n throw new Error('file_path parameter is required');\r\n }\r\n\r\n if (content === undefined) {\r\n throw new Error('content parameter is required');\r\n }\r\n\r\n await fs.writeFile(file_path, content, 'utf-8');\r\n\r\n return `File written successfully: ${file_path}`;\r\n}\r\n\r\n/**\r\n * Execute Edit tool\r\n */\r\nasync function executeEdit(input: Record<string, any>): Promise<string> {\r\n const { file_path, old_string, new_string, replace_all } = input;\r\n\r\n if (!file_path) {\r\n throw new Error('file_path parameter is required');\r\n }\r\n\r\n if (!old_string) {\r\n throw new Error('old_string parameter is required');\r\n }\r\n\r\n if (new_string === undefined) {\r\n throw new Error('new_string parameter is required');\r\n }\r\n\r\n // Read file\r\n const content = await fs.readFile(file_path, 'utf-8');\r\n\r\n // Perform replacement\r\n let newContent: string;\r\n if (replace_all) {\r\n // Replace all occurrences\r\n newContent = content.split(old_string).join(new_string);\r\n } else {\r\n // Replace first occurrence only (must be unique)\r\n const occurrences = content.split(old_string).length - 1;\r\n if (occurrences === 0) {\r\n throw new Error('old_string not found in file');\r\n }\r\n if (occurrences > 1) {\r\n throw new Error(`old_string appears ${occurrences} times. Must be unique or use replace_all: true`);\r\n }\r\n newContent = content.replace(old_string, new_string);\r\n }\r\n\r\n // Write back\r\n await fs.writeFile(file_path, newContent, 'utf-8');\r\n\r\n return `File edited successfully: ${file_path}`;\r\n}\r\n\r\n/**\r\n * Execute Bash tool\r\n */\r\nasync function executeBash(input: Record<string, any>): Promise<string> {\r\n const { command, timeout, run_in_background } = input;\r\n\r\n if (!command) {\r\n throw new Error('command parameter is required');\r\n }\r\n\r\n // DEBUG: Log bash command execution details\r\n console.log(`[tool-executor] Bash command: ${command}`);\r\n console.log(`[tool-executor] Timeout: ${timeout || 120000}ms`);\r\n console.log(`[tool-executor] Background: ${run_in_background || false}`);\r\n\r\n const timeoutMs = timeout ? Number(timeout) : 120000; // 2 minutes default\r\n\r\n if (run_in_background) {\r\n // Start background process and return immediately\r\n exec(command);\r\n return `Command started in background: ${command}`;\r\n }\r\n\r\n // Execute synchronously with timeout\r\n const { stdout, stderr } = await execAsync(command, {\r\n timeout: timeoutMs,\r\n maxBuffer: 10 * 1024 * 1024 // 10MB buffer\r\n });\r\n\r\n return stdout + stderr;\r\n}\r\n\r\n/**\r\n * Execute TodoWrite tool\r\n */\r\nasync function executeTodoWrite(input: Record<string, any>): Promise<string> {\r\n const { todos } = input;\r\n\r\n if (!Array.isArray(todos)) {\r\n throw new Error('todos parameter must be an array');\r\n }\r\n\r\n // Validate todo structure\r\n for (const todo of todos) {\r\n if (!todo.content || !todo.status || !todo.activeForm) {\r\n throw new Error('Each todo must have content, status, and activeForm');\r\n }\r\n if (!['pending', 'in_progress', 'completed'].includes(todo.status)) {\r\n throw new Error('Invalid status. Must be pending, in_progress, or completed');\r\n }\r\n }\r\n\r\n // Format todos for display\r\n const formatted = todos\r\n .map((todo, idx) => {\r\n const status = todo.status === 'completed' ? '✓' : todo.status === 'in_progress' ? '⚡' : '○';\r\n return `${idx + 1}. [${status}] ${todo.content}`;\r\n })\r\n .join('\\n');\r\n\r\n return `Todo list updated:\\n${formatted}`;\r\n}\r\n\r\n/**\r\n * Execute Glob tool\r\n */\r\nasync function executeGlob(input: Record<string, any>): Promise<string> {\r\n const { pattern, path } = input;\r\n\r\n if (!pattern) {\r\n throw new Error('pattern parameter is required');\r\n }\r\n\r\n const cwd = path || process.cwd();\r\n const files = await glob(pattern, { cwd, nodir: true });\r\n\r\n if (files.length === 0) {\r\n return 'No files found';\r\n }\r\n\r\n return files.join('\\n');\r\n}\r\n\r\n/**\r\n * Execute Grep tool\r\n */\r\nasync function executeGrep(input: Record<string, any>): Promise<string> {\r\n const { pattern, path, output_mode, glob: globPattern, type } = input;\r\n\r\n if (!pattern) {\r\n throw new Error('pattern parameter is required');\r\n }\r\n\r\n // Build ripgrep command\r\n const args: string[] = ['rg'];\r\n\r\n // Output mode\r\n if (output_mode === 'files_with_matches' || !output_mode) {\r\n args.push('-l'); // List files with matches\r\n } else if (output_mode === 'count') {\r\n args.push('-c'); // Count matches per file\r\n }\r\n // Default is content (no flag)\r\n\r\n // Optional flags\r\n if (input['-i']) args.push('-i'); // Case insensitive\r\n if (input['-n']) args.push('-n'); // Line numbers\r\n if (input['-A']) args.push(`-A${input['-A']}`); // After context\r\n if (input['-B']) args.push(`-B${input['-B']}`); // Before context\r\n if (input['-C']) args.push(`-C${input['-C']}`); // Context\r\n\r\n // File filtering\r\n if (globPattern) args.push('--glob', globPattern);\r\n if (type) args.push('--type', type);\r\n\r\n // Pattern and path\r\n args.push(pattern);\r\n if (path) args.push(path);\r\n\r\n const command = args.join(' ');\r\n\r\n try {\r\n const { stdout } = await execAsync(command, {\r\n maxBuffer: 10 * 1024 * 1024 // 10MB buffer\r\n });\r\n return stdout || 'No matches found';\r\n } catch (error: any) {\r\n // ripgrep exits with code 1 if no matches found\r\n if (error.code === 1) {\r\n return 'No matches found';\r\n }\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * Execute multiple tools in sequence\r\n */\r\nexport async function executeTools(toolUses: ToolUse[]): Promise<ToolResult[]> {\r\n const results: ToolResult[] = [];\r\n\r\n for (const toolUse of toolUses) {\r\n const result = await executeTool(toolUse);\r\n results.push(result);\r\n }\r\n\r\n return results;\r\n}\r\n"],"names":["fs","exec","promisify","glob","execAsync","executeTool","toolUse","console","log","name","id","result","executeRead","input","executeWrite","executeEdit","executeBash","executeTodoWrite","executeGlob","executeGrep","Error","type","tool_use_id","content","error","message","String","is_error","file_path","offset","limit","readFile","lines","split","startLine","Number","endLine","length","selectedLines","slice","formatted","map","line","idx","padStart","join","undefined","writeFile","old_string","new_string","replace_all","newContent","occurrences","replace","command","timeout","run_in_background","timeoutMs","stdout","stderr","maxBuffer","todos","Array","isArray","todo","status","activeForm","includes","pattern","path","cwd","process","files","nodir","output_mode","globPattern","args","push","code","executeTools","toolUses","results"],"mappings":"AAAA;;;;;CAKC,GAED,OAAOA,QAAQ,cAAc;AAC7B,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,IAAI,QAAQ,OAAO;AAE5B,MAAMC,YAAYF,UAAUD;AAgB5B;;CAEC,GACD,OAAO,eAAeI,YAAYC,OAAgB;IAChDC,QAAQC,GAAG,CAAC,CAAC,gCAAgC,EAAEF,QAAQG,IAAI,EAAE;IAC7DF,QAAQC,GAAG,CAAC,CAAC,6BAA6B,EAAEF,QAAQI,EAAE,EAAE;IAExD,IAAI;QACF,IAAIC;QAEJ,OAAQ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
1
|
+
{"version":3,"sources":["../../src/cli/tool-executor.ts"],"sourcesContent":["/**\r\n * Tool Executor for CLI-Spawned Agents\r\n *\r\n * Executes tools requested by agents via Anthropic API tool_use blocks.\r\n * Implements Read, Write, Edit, Bash, TodoWrite, Glob, Grep.\r\n */\r\n\r\nimport fs from 'fs/promises';\r\nimport { exec } from 'child_process';\r\nimport { promisify } from 'util';\r\nimport { glob } from 'glob';\r\n\r\nconst execAsync = promisify(exec);\r\n\r\nexport interface ToolUse {\r\n type: 'tool_use';\r\n id: string;\r\n name: string;\r\n input: Record<string, any>;\r\n}\r\n\r\nexport interface ToolResult {\r\n type: 'tool_result';\r\n tool_use_id: string;\r\n content: string;\r\n is_error?: boolean;\r\n}\r\n\r\n/**\r\n * Execute a single tool and return result\r\n */\r\nexport async function executeTool(toolUse: ToolUse): Promise<ToolResult> {\r\n console.log(`[tool-executor] Executing tool: ${toolUse.name}`);\r\n console.log(`[tool-executor] Tool use ID: ${toolUse.id}`);\r\n\r\n try {\r\n let result: string;\r\n\r\n switch (toolUse.name) {\r\n case 'Read':\r\n result = await executeRead(toolUse.input);\r\n break;\r\n\r\n case 'Write':\r\n result = await executeWrite(toolUse.input);\r\n break;\r\n\r\n case 'Edit':\r\n result = await executeEdit(toolUse.input);\r\n break;\r\n\r\n case 'Bash':\r\n result = await executeBash(toolUse.input);\r\n break;\r\n\r\n case 'TodoWrite':\r\n result = await executeTodoWrite(toolUse.input);\r\n break;\r\n\r\n case 'Glob':\r\n result = await executeGlob(toolUse.input);\r\n break;\r\n\r\n case 'Grep':\r\n result = await executeGrep(toolUse.input);\r\n break;\r\n\r\n default:\r\n throw new Error(`Unknown tool: ${toolUse.name}`);\r\n }\r\n\r\n console.log(`[tool-executor] ✓ Tool executed successfully`);\r\n\r\n return {\r\n type: 'tool_result',\r\n tool_use_id: toolUse.id,\r\n content: result\r\n };\r\n } catch (error) {\r\n console.error(`[tool-executor] ✗ Tool execution failed:`, error);\r\n\r\n return {\r\n type: 'tool_result',\r\n tool_use_id: toolUse.id,\r\n content: error instanceof Error ? error.message : String(error),\r\n is_error: true\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Execute Read tool\r\n */\r\nasync function executeRead(input: Record<string, any>): Promise<string> {\r\n const { file_path, offset, limit } = input;\r\n\r\n if (!file_path) {\r\n throw new Error('file_path parameter is required');\r\n }\r\n\r\n const content = await fs.readFile(file_path, 'utf-8');\r\n const lines = content.split('\\n');\r\n\r\n // Apply offset and limit if provided\r\n const startLine = offset ? Number(offset) - 1 : 0;\r\n const endLine = limit ? startLine + Number(limit) : lines.length;\r\n const selectedLines = lines.slice(startLine, endLine);\r\n\r\n // Format with line numbers (cat -n style)\r\n const formatted = selectedLines\r\n .map((line, idx) => `${String(startLine + idx + 1).padStart(6)}→${line}`)\r\n .join('\\n');\r\n\r\n return formatted;\r\n}\r\n\r\n/**\r\n * Execute Write tool\r\n */\r\nasync function executeWrite(input: Record<string, any>): Promise<string> {\r\n const { file_path, content } = input;\r\n\r\n if (!file_path) {\r\n throw new Error('file_path parameter is required');\r\n }\r\n\r\n if (content === undefined) {\r\n throw new Error('content parameter is required');\r\n }\r\n\r\n await fs.writeFile(file_path, content, 'utf-8');\r\n\r\n return `File written successfully: ${file_path}`;\r\n}\r\n\r\n/**\r\n * Execute Edit tool\r\n */\r\nasync function executeEdit(input: Record<string, any>): Promise<string> {\r\n const { file_path, old_string, new_string, replace_all } = input;\r\n\r\n if (!file_path) {\r\n throw new Error('file_path parameter is required');\r\n }\r\n\r\n if (!old_string) {\r\n throw new Error('old_string parameter is required');\r\n }\r\n\r\n if (new_string === undefined) {\r\n throw new Error('new_string parameter is required');\r\n }\r\n\r\n // Read file\r\n const content = await fs.readFile(file_path, 'utf-8');\r\n\r\n // Perform replacement\r\n let newContent: string;\r\n if (replace_all) {\r\n // Replace all occurrences\r\n newContent = content.split(old_string).join(new_string);\r\n } else {\r\n // Replace first occurrence only (must be unique)\r\n const occurrences = content.split(old_string).length - 1;\r\n if (occurrences === 0) {\r\n throw new Error('old_string not found in file');\r\n }\r\n if (occurrences > 1) {\r\n throw new Error(`old_string appears ${occurrences} times. Must be unique or use replace_all: true`);\r\n }\r\n newContent = content.replace(old_string, new_string);\r\n }\r\n\r\n // Write back\r\n await fs.writeFile(file_path, newContent, 'utf-8');\r\n\r\n return `File edited successfully: ${file_path}`;\r\n}\r\n\r\n/**\r\n * Execute Bash tool\r\n */\r\nasync function executeBash(input: Record<string, any>): Promise<string> {\r\n const { command, timeout, run_in_background } = input;\r\n\r\n if (!command) {\r\n throw new Error('command parameter is required');\r\n }\r\n\r\n // DEBUG: Log bash command execution details\r\n console.log(`[tool-executor] Bash command: ${command}`);\r\n console.log(`[tool-executor] Timeout: ${timeout || 120000}ms`);\r\n console.log(`[tool-executor] Background: ${run_in_background || false}`);\r\n\r\n const timeoutMs = timeout ? Number(timeout) : 120000; // 2 minutes default\r\n\r\n if (run_in_background) {\r\n // Start background process and return immediately\r\n exec(command);\r\n return `Command started in background: ${command}`;\r\n }\r\n\r\n // Execute synchronously with timeout\r\n // CRITICAL: Use /bin/bash instead of /bin/sh for [[ ]] support\r\n const { stdout, stderr } = await execAsync(command, {\r\n timeout: timeoutMs,\r\n maxBuffer: 10 * 1024 * 1024, // 10MB buffer\r\n shell: '/bin/bash' // REQUIRED: Coordinator uses [[ ]] conditionals\r\n });\r\n\r\n return stdout + stderr;\r\n}\r\n\r\n/**\r\n * Execute TodoWrite tool\r\n */\r\nasync function executeTodoWrite(input: Record<string, any>): Promise<string> {\r\n const { todos } = input;\r\n\r\n if (!Array.isArray(todos)) {\r\n throw new Error('todos parameter must be an array');\r\n }\r\n\r\n // Validate todo structure\r\n for (const todo of todos) {\r\n if (!todo.content || !todo.status || !todo.activeForm) {\r\n throw new Error('Each todo must have content, status, and activeForm');\r\n }\r\n if (!['pending', 'in_progress', 'completed'].includes(todo.status)) {\r\n throw new Error('Invalid status. Must be pending, in_progress, or completed');\r\n }\r\n }\r\n\r\n // Format todos for display\r\n const formatted = todos\r\n .map((todo, idx) => {\r\n const status = todo.status === 'completed' ? '✓' : todo.status === 'in_progress' ? '⚡' : '○';\r\n return `${idx + 1}. [${status}] ${todo.content}`;\r\n })\r\n .join('\\n');\r\n\r\n return `Todo list updated:\\n${formatted}`;\r\n}\r\n\r\n/**\r\n * Execute Glob tool\r\n */\r\nasync function executeGlob(input: Record<string, any>): Promise<string> {\r\n const { pattern, path } = input;\r\n\r\n if (!pattern) {\r\n throw new Error('pattern parameter is required');\r\n }\r\n\r\n const cwd = path || process.cwd();\r\n const files = await glob(pattern, { cwd, nodir: true });\r\n\r\n if (files.length === 0) {\r\n return 'No files found';\r\n }\r\n\r\n return files.join('\\n');\r\n}\r\n\r\n/**\r\n * Execute Grep tool\r\n */\r\nasync function executeGrep(input: Record<string, any>): Promise<string> {\r\n const { pattern, path, output_mode, glob: globPattern, type } = input;\r\n\r\n if (!pattern) {\r\n throw new Error('pattern parameter is required');\r\n }\r\n\r\n // Build ripgrep command\r\n const args: string[] = ['rg'];\r\n\r\n // Output mode\r\n if (output_mode === 'files_with_matches' || !output_mode) {\r\n args.push('-l'); // List files with matches\r\n } else if (output_mode === 'count') {\r\n args.push('-c'); // Count matches per file\r\n }\r\n // Default is content (no flag)\r\n\r\n // Optional flags\r\n if (input['-i']) args.push('-i'); // Case insensitive\r\n if (input['-n']) args.push('-n'); // Line numbers\r\n if (input['-A']) args.push(`-A${input['-A']}`); // After context\r\n if (input['-B']) args.push(`-B${input['-B']}`); // Before context\r\n if (input['-C']) args.push(`-C${input['-C']}`); // Context\r\n\r\n // File filtering\r\n if (globPattern) args.push('--glob', globPattern);\r\n if (type) args.push('--type', type);\r\n\r\n // Pattern and path\r\n args.push(pattern);\r\n if (path) args.push(path);\r\n\r\n const command = args.join(' ');\r\n\r\n try {\r\n const { stdout } = await execAsync(command, {\r\n maxBuffer: 10 * 1024 * 1024 // 10MB buffer\r\n });\r\n return stdout || 'No matches found';\r\n } catch (error: any) {\r\n // ripgrep exits with code 1 if no matches found\r\n if (error.code === 1) {\r\n return 'No matches found';\r\n }\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * Execute multiple tools in sequence\r\n */\r\nexport async function executeTools(toolUses: ToolUse[]): Promise<ToolResult[]> {\r\n const results: ToolResult[] = [];\r\n\r\n for (const toolUse of toolUses) {\r\n const result = await executeTool(toolUse);\r\n results.push(result);\r\n }\r\n\r\n return results;\r\n}\r\n"],"names":["fs","exec","promisify","glob","execAsync","executeTool","toolUse","console","log","name","id","result","executeRead","input","executeWrite","executeEdit","executeBash","executeTodoWrite","executeGlob","executeGrep","Error","type","tool_use_id","content","error","message","String","is_error","file_path","offset","limit","readFile","lines","split","startLine","Number","endLine","length","selectedLines","slice","formatted","map","line","idx","padStart","join","undefined","writeFile","old_string","new_string","replace_all","newContent","occurrences","replace","command","timeout","run_in_background","timeoutMs","stdout","stderr","maxBuffer","shell","todos","Array","isArray","todo","status","activeForm","includes","pattern","path","cwd","process","files","nodir","output_mode","globPattern","args","push","code","executeTools","toolUses","results"],"mappings":"AAAA;;;;;CAKC,GAED,OAAOA,QAAQ,cAAc;AAC7B,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,IAAI,QAAQ,OAAO;AAE5B,MAAMC,YAAYF,UAAUD;AAgB5B;;CAEC,GACD,OAAO,eAAeI,YAAYC,OAAgB;IAChDC,QAAQC,GAAG,CAAC,CAAC,gCAAgC,EAAEF,QAAQG,IAAI,EAAE;IAC7DF,QAAQC,GAAG,CAAC,CAAC,6BAA6B,EAAEF,QAAQI,EAAE,EAAE;IAExD,IAAI;QACF,IAAIC;QAEJ,OAAQL,QAAQG,IAAI;YAClB,KAAK;gBACHE,SAAS,MAAMC,YAAYN,QAAQO,KAAK;gBACxC;YAEF,KAAK;gBACHF,SAAS,MAAMG,aAAaR,QAAQO,KAAK;gBACzC;YAEF,KAAK;gBACHF,SAAS,MAAMI,YAAYT,QAAQO,KAAK;gBACxC;YAEF,KA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Ae;IACjD,IAAIjE,KAAK,CAAC,KAAK,EAAEgE,KAAKC,IAAI,CAAC,CAAC,EAAE,EAAEjE,KAAK,CAAC,KAAK,EAAE,GAAG,gBAAgB;IAChE,IAAIA,KAAK,CAAC,KAAK,EAAEgE,KAAKC,IAAI,CAAC,CAAC,EAAE,EAAEjE,KAAK,CAAC,KAAK,EAAE,GAAG,iBAAiB;IACjE,IAAIA,KAAK,CAAC,KAAK,EAAEgE,KAAKC,IAAI,CAAC,CAAC,EAAE,EAAEjE,KAAK,CAAC,KAAK,EAAE,GAAG,UAAU;IAE1D,iBAAiB;IACjB,IAAI+D,aAAaC,KAAKC,IAAI,CAAC,UAAUF;IACrC,IAAIvD,MAAMwD,KAAKC,IAAI,CAAC,UAAUzD;IAE9B,mBAAmB;IACnBwD,KAAKC,IAAI,CAACT;IACV,IAAIC,MAAMO,KAAKC,IAAI,CAACR;IAEpB,MAAMhB,UAAUuB,KAAKhC,IAAI,CAAC;IAE1B,IAAI;QACF,MAAM,EAAEa,MAAM,EAAE,GAAG,MAAMtD,UAAUkD,SAAS;YAC1CM,WAAW,KAAK,OAAO,KAAK,cAAc;QAC5C;QACA,OAAOF,UAAU;IACnB,EAAE,OAAOlC,OAAY;QACnB,gDAAgD;QAChD,IAAIA,MAAMuD,IAAI,KAAK,GAAG;YACpB,OAAO;QACT;QACA,MAAMvD;IACR;AACF;AAEA;;CAEC,GACD,OAAO,eAAewD,aAAaC,QAAmB;IACpD,MAAMC,UAAwB,EAAE;IAEhC,KAAK,MAAM5E,WAAW2E,SAAU;QAC9B,MAAMtE,SAAS,MAAMN,YAAYC;QACjC4E,QAAQJ,IAAI,CAACnE;IACf;IAEA,OAAOuE;AACT"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate Checker - Test-Driven Validation with Hybrid Fallback
|
|
3
|
+
*
|
|
4
|
+
* Validates Loop 3 self-assessment using test-driven or confidence-based strategies.
|
|
5
|
+
* Ensures test pass rates meet execution-mode-specific thresholds.
|
|
6
|
+
*
|
|
7
|
+
* @module gate-checker
|
|
8
|
+
*/ import { ValidationError, SecurityError, TimeoutError, isValidSuccessCriteria, isValidTestResult } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Gate Checker class for test-driven validation
|
|
11
|
+
*/ export class GateChecker {
|
|
12
|
+
logger;
|
|
13
|
+
taskId;
|
|
14
|
+
mode;
|
|
15
|
+
strategy;
|
|
16
|
+
// Security constraints (CWE prevention)
|
|
17
|
+
securityConstraints = {
|
|
18
|
+
maxTestSuites: 50,
|
|
19
|
+
maxFieldLength: 256,
|
|
20
|
+
passThresholdMin: 0.0,
|
|
21
|
+
passThresholdMax: 1.0,
|
|
22
|
+
timeoutMin: 1,
|
|
23
|
+
timeoutMax: 3600,
|
|
24
|
+
maxTotalTime: 1800
|
|
25
|
+
};
|
|
26
|
+
// Mode-specific thresholds
|
|
27
|
+
modeThresholds = {
|
|
28
|
+
mvp: 0.70,
|
|
29
|
+
standard: 0.95,
|
|
30
|
+
enterprise: 0.98
|
|
31
|
+
};
|
|
32
|
+
constructor(taskId, logger, mode = 'standard', strategy = 'auto'){
|
|
33
|
+
this.taskId = taskId;
|
|
34
|
+
this.logger = logger;
|
|
35
|
+
this.mode = mode;
|
|
36
|
+
this.strategy = strategy;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get mode-specific threshold
|
|
40
|
+
*/ getModeThreshold() {
|
|
41
|
+
return this.modeThresholds[this.mode];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Validate success criteria JSON structure and security constraints
|
|
45
|
+
*/ validateSuccessCriteria(criteria) {
|
|
46
|
+
// Check if criteria is provided
|
|
47
|
+
if (!criteria) {
|
|
48
|
+
this.logger.error('No success criteria provided');
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
// Validate JSON structure
|
|
52
|
+
if (!isValidSuccessCriteria(criteria)) {
|
|
53
|
+
this.logger.error('Invalid success criteria structure');
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
const typedCriteria = criteria;
|
|
57
|
+
// Validate array size (DoS prevention)
|
|
58
|
+
if (typedCriteria.test_suites.length > this.securityConstraints.maxTestSuites) {
|
|
59
|
+
this.logger.error(`Test suites exceed maximum: ${typedCriteria.test_suites.length} > ${this.securityConstraints.maxTestSuites}`);
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
// Validate each test suite
|
|
63
|
+
for(let i = 0; i < typedCriteria.test_suites.length; i++){
|
|
64
|
+
const suite = typedCriteria.test_suites[i];
|
|
65
|
+
// Validate timeout range
|
|
66
|
+
const timeout = suite.timeout ?? 300;
|
|
67
|
+
if (timeout < this.securityConstraints.timeoutMin || timeout > this.securityConstraints.timeoutMax) {
|
|
68
|
+
this.logger.error(`Invalid timeout in suite ${i}: ${timeout}s`);
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
// Validate suite name length
|
|
72
|
+
if (suite.name.length > this.securityConstraints.maxFieldLength) {
|
|
73
|
+
this.logger.error(`Test suite name exceeds maximum length in suite ${i}`);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Validate command safety to prevent shell injection (CWE-78)
|
|
81
|
+
*/ validateCommandSafety(command) {
|
|
82
|
+
// Remove safe operators first
|
|
83
|
+
let sanitized = command.replace(/&&/g, '');
|
|
84
|
+
sanitized = sanitized.replace(/\|\|/g, '');
|
|
85
|
+
// Check for dangerous metacharacters
|
|
86
|
+
const dangerousPattern = /[\;\|\>\<\`\$\(\)\{\}]/;
|
|
87
|
+
if (dangerousPattern.test(sanitized)) {
|
|
88
|
+
this.logger.error('Unsafe command detected: contains dangerous shell metacharacters');
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Calculate aggregate pass rate from test results
|
|
95
|
+
*/ calculateAggregatePassRate(results) {
|
|
96
|
+
if (results.length === 0) {
|
|
97
|
+
return 0.0;
|
|
98
|
+
}
|
|
99
|
+
let totalPassed = 0;
|
|
100
|
+
let totalTests = 0;
|
|
101
|
+
for (const result of results){
|
|
102
|
+
if (!isValidTestResult(result)) {
|
|
103
|
+
this.logger.warn('Invalid test result encountered during aggregation');
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
totalPassed += result.passed;
|
|
107
|
+
totalTests += result.total;
|
|
108
|
+
}
|
|
109
|
+
if (totalTests === 0) {
|
|
110
|
+
return 0.0;
|
|
111
|
+
}
|
|
112
|
+
// Calculate with 4 decimal precision to match bash behavior
|
|
113
|
+
const passRate = totalPassed / totalTests;
|
|
114
|
+
return Math.round(passRate * 10000) / 10000;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Check if the pass rate meets the gate threshold
|
|
118
|
+
*/ checkGateThreshold(passRate, threshold) {
|
|
119
|
+
// Use epsilon comparison for floating point values
|
|
120
|
+
const epsilon = 0.00001;
|
|
121
|
+
return passRate >= threshold - epsilon;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Perform test-driven gate check
|
|
125
|
+
*/ testDrivenGateCheck(criteria) {
|
|
126
|
+
const startTime = Date.now();
|
|
127
|
+
// Validate success criteria first
|
|
128
|
+
if (!this.validateSuccessCriteria(criteria)) {
|
|
129
|
+
throw new ValidationError('Invalid success criteria provided');
|
|
130
|
+
}
|
|
131
|
+
this.logger.info('Test-Driven Gate Check', {
|
|
132
|
+
taskId: this.taskId,
|
|
133
|
+
mode: this.mode,
|
|
134
|
+
testSuiteCount: criteria.test_suites.length
|
|
135
|
+
});
|
|
136
|
+
const testResults = [];
|
|
137
|
+
const failedSuites = [];
|
|
138
|
+
let failedRequired = 0;
|
|
139
|
+
// Check total execution time (DoS prevention)
|
|
140
|
+
const maxTotalTime = this.securityConstraints.maxTotalTime;
|
|
141
|
+
// Execute each test suite
|
|
142
|
+
for (const suite of criteria.test_suites){
|
|
143
|
+
// Check elapsed time
|
|
144
|
+
const elapsed = Date.now() - startTime;
|
|
145
|
+
if (elapsed > maxTotalTime * 1000) {
|
|
146
|
+
throw new TimeoutError(`Total execution time exceeded ${maxTotalTime}s`, {
|
|
147
|
+
elapsed_seconds: elapsed / 1000,
|
|
148
|
+
max_seconds: maxTotalTime
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
// Validate command safety
|
|
152
|
+
if (!this.validateCommandSafety(suite.command)) {
|
|
153
|
+
throw new SecurityError(`Unsafe command in test suite: ${suite.name}`, {
|
|
154
|
+
suite: suite.name
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
// Create mock result for testing
|
|
158
|
+
// In production, this would execute the command
|
|
159
|
+
const result = {
|
|
160
|
+
pass_rate: 1.0,
|
|
161
|
+
passed: 1,
|
|
162
|
+
failed: 0,
|
|
163
|
+
total: 1,
|
|
164
|
+
status: 'success'
|
|
165
|
+
};
|
|
166
|
+
testResults.push(result);
|
|
167
|
+
// Track failed required suites
|
|
168
|
+
if (result.pass_rate < 1.0 && suite.required !== false) {
|
|
169
|
+
failedRequired++;
|
|
170
|
+
failedSuites.push(suite.name);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// If any required test suite failed completely, gate fails
|
|
174
|
+
if (failedRequired > 0) {
|
|
175
|
+
const threshold = this.getModeThreshold();
|
|
176
|
+
const passRate = this.calculateAggregatePassRate(testResults);
|
|
177
|
+
return {
|
|
178
|
+
passed: false,
|
|
179
|
+
pass_rate: passRate,
|
|
180
|
+
threshold,
|
|
181
|
+
mode: this.mode,
|
|
182
|
+
gap: threshold - passRate,
|
|
183
|
+
test_results: testResults,
|
|
184
|
+
failed_suites: failedSuites,
|
|
185
|
+
execution_time_ms: Date.now() - startTime,
|
|
186
|
+
timestamp: Date.now()
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
// Calculate aggregate pass rate
|
|
190
|
+
const passRate = this.calculateAggregatePassRate(testResults);
|
|
191
|
+
const threshold = this.getModeThreshold();
|
|
192
|
+
const gateResult = {
|
|
193
|
+
passed: this.checkGateThreshold(passRate, threshold),
|
|
194
|
+
pass_rate: passRate,
|
|
195
|
+
threshold,
|
|
196
|
+
mode: this.mode,
|
|
197
|
+
test_results: testResults,
|
|
198
|
+
failed_suites: failedSuites,
|
|
199
|
+
execution_time_ms: Date.now() - startTime,
|
|
200
|
+
timestamp: Date.now()
|
|
201
|
+
};
|
|
202
|
+
if (!gateResult.passed) {
|
|
203
|
+
gateResult.gap = threshold - passRate;
|
|
204
|
+
}
|
|
205
|
+
return gateResult;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Perform confidence-based gate check (legacy)
|
|
209
|
+
*/ confidenceBasedGateCheck(agents, threshold, minQuorum) {
|
|
210
|
+
this.logger.warn('Using legacy confidence-based gate check', {
|
|
211
|
+
taskId: this.taskId,
|
|
212
|
+
agents: agents.length,
|
|
213
|
+
threshold,
|
|
214
|
+
minQuorum
|
|
215
|
+
});
|
|
216
|
+
// Validate threshold is numeric
|
|
217
|
+
if (typeof threshold !== 'number' || threshold < 0 || threshold > 1) {
|
|
218
|
+
throw new ValidationError('Invalid threshold value', {
|
|
219
|
+
threshold
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
// For now, return false (requires Redis integration)
|
|
223
|
+
// In production, this would call Redis coordination skill
|
|
224
|
+
this.logger.info('Confidence-based gate check requires Redis coordination');
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Check if success criteria exists
|
|
229
|
+
*/ hasSuccessCriteria(criteria) {
|
|
230
|
+
if (!criteria) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
return isValidSuccessCriteria(criteria);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Generate iteration context for failed gate
|
|
237
|
+
*/ generateIterationContext(passRate, threshold, testResults) {
|
|
238
|
+
let gap = threshold - passRate;
|
|
239
|
+
// Round to prevent floating point precision issues
|
|
240
|
+
gap = Math.round(gap * 10000) / 10000;
|
|
241
|
+
if (gap < 0) {
|
|
242
|
+
gap = 0;
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
gate_status: 'failed',
|
|
246
|
+
pass_rate: passRate,
|
|
247
|
+
threshold,
|
|
248
|
+
gap,
|
|
249
|
+
failed_tests: testResults.filter((result)=>result.pass_rate < 1.0),
|
|
250
|
+
recommendations: [
|
|
251
|
+
'Review failed test suites',
|
|
252
|
+
'Fix implementation issues',
|
|
253
|
+
'Re-run validation'
|
|
254
|
+
]
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Perform gate check based on strategy
|
|
259
|
+
*/ performGateCheck(criteria, agents, threshold, minQuorum) {
|
|
260
|
+
const strategy = this.strategy;
|
|
261
|
+
// Auto mode: prefer test-driven if criteria exists, fallback to confidence
|
|
262
|
+
if (strategy === 'auto') {
|
|
263
|
+
if (criteria && this.hasSuccessCriteria(criteria)) {
|
|
264
|
+
return this.testDrivenGateCheck(criteria);
|
|
265
|
+
} else {
|
|
266
|
+
if (!agents || !threshold || !minQuorum) {
|
|
267
|
+
throw new ValidationError('Auto mode requires either success criteria or agent/threshold/minQuorum parameters');
|
|
268
|
+
}
|
|
269
|
+
return this.confidenceBasedGateCheck(agents, threshold, minQuorum);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
// Test-driven mode
|
|
273
|
+
if (strategy === 'test-driven') {
|
|
274
|
+
if (!criteria) {
|
|
275
|
+
throw new ValidationError('test-driven strategy requires success criteria');
|
|
276
|
+
}
|
|
277
|
+
return this.testDrivenGateCheck(criteria);
|
|
278
|
+
}
|
|
279
|
+
// Confidence mode
|
|
280
|
+
if (strategy === 'confidence') {
|
|
281
|
+
if (!agents || !threshold || !minQuorum) {
|
|
282
|
+
throw new ValidationError('confidence strategy requires agents, threshold, and minQuorum');
|
|
283
|
+
}
|
|
284
|
+
return this.confidenceBasedGateCheck(agents, threshold, minQuorum);
|
|
285
|
+
}
|
|
286
|
+
throw new ValidationError(`Invalid strategy: ${strategy}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// Export for use in other modules
|
|
290
|
+
export default GateChecker;
|
|
291
|
+
|
|
292
|
+
//# sourceMappingURL=gate-checker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gate-checker/gate-checker.ts"],"sourcesContent":["/**\r\n * Gate Checker - Test-Driven Validation with Hybrid Fallback\r\n *\r\n * Validates Loop 3 self-assessment using test-driven or confidence-based strategies.\r\n * Ensures test pass rates meet execution-mode-specific thresholds.\r\n *\r\n * @module gate-checker\r\n */\r\n\r\nimport { ILogger } from '../utils/types';\r\nimport {\r\n ExecutionMode,\r\n GateCheckStrategy,\r\n GateResult,\r\n IterationContext,\r\n TestResult,\r\n SuccessCriteria,\r\n ValidationError,\r\n SecurityError,\r\n TimeoutError,\r\n isValidSuccessCriteria,\r\n isValidExecutionMode,\r\n isValidTestResult,\r\n} from './types';\r\n\r\n/**\r\n * Gate Checker class for test-driven validation\r\n */\r\nexport class GateChecker {\r\n private logger: ILogger;\r\n private taskId: string;\r\n private mode: ExecutionMode;\r\n private strategy: GateCheckStrategy;\r\n\r\n // Security constraints (CWE prevention)\r\n private readonly securityConstraints = {\r\n maxTestSuites: 50,\r\n maxFieldLength: 256,\r\n passThresholdMin: 0.0,\r\n passThresholdMax: 1.0,\r\n timeoutMin: 1,\r\n timeoutMax: 3600,\r\n maxTotalTime: 1800, // 30 minutes default\r\n };\r\n\r\n // Mode-specific thresholds\r\n private readonly modeThresholds = {\r\n mvp: 0.70,\r\n standard: 0.95,\r\n enterprise: 0.98,\r\n };\r\n\r\n constructor(\r\n taskId: string,\r\n logger: ILogger,\r\n mode: ExecutionMode = 'standard',\r\n strategy: GateCheckStrategy = 'auto'\r\n ) {\r\n this.taskId = taskId;\r\n this.logger = logger;\r\n this.mode = mode;\r\n this.strategy = strategy;\r\n }\r\n\r\n /**\r\n * Get mode-specific threshold\r\n */\r\n private getModeThreshold(): number {\r\n return this.modeThresholds[this.mode];\r\n }\r\n\r\n /**\r\n * Validate success criteria JSON structure and security constraints\r\n */\r\n validateSuccessCriteria(criteria: unknown): boolean {\r\n // Check if criteria is provided\r\n if (!criteria) {\r\n this.logger.error('No success criteria provided');\r\n return false;\r\n }\r\n\r\n // Validate JSON structure\r\n if (!isValidSuccessCriteria(criteria)) {\r\n this.logger.error('Invalid success criteria structure');\r\n return false;\r\n }\r\n\r\n const typedCriteria = criteria as SuccessCriteria;\r\n\r\n // Validate array size (DoS prevention)\r\n if (typedCriteria.test_suites.length > this.securityConstraints.maxTestSuites) {\r\n this.logger.error(\r\n `Test suites exceed maximum: ${typedCriteria.test_suites.length} > ${this.securityConstraints.maxTestSuites}`\r\n );\r\n return false;\r\n }\r\n\r\n // Validate each test suite\r\n for (let i = 0; i < typedCriteria.test_suites.length; i++) {\r\n const suite = typedCriteria.test_suites[i];\r\n\r\n // Validate timeout range\r\n const timeout = suite.timeout ?? 300;\r\n if (\r\n timeout < this.securityConstraints.timeoutMin ||\r\n timeout > this.securityConstraints.timeoutMax\r\n ) {\r\n this.logger.error(\r\n `Invalid timeout in suite ${i}: ${timeout}s`\r\n );\r\n return false;\r\n }\r\n\r\n // Validate suite name length\r\n if (suite.name.length > this.securityConstraints.maxFieldLength) {\r\n this.logger.error(\r\n `Test suite name exceeds maximum length in suite ${i}`\r\n );\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Validate command safety to prevent shell injection (CWE-78)\r\n */\r\n validateCommandSafety(command: string): boolean {\r\n // Remove safe operators first\r\n let sanitized = command.replace(/&&/g, '');\r\n sanitized = sanitized.replace(/\\|\\|/g, '');\r\n\r\n // Check for dangerous metacharacters\r\n const dangerousPattern = /[\\;\\|\\>\\<\\`\\$\\(\\)\\{\\}]/;\r\n if (dangerousPattern.test(sanitized)) {\r\n this.logger.error('Unsafe command detected: contains dangerous shell metacharacters');\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Calculate aggregate pass rate from test results\r\n */\r\n calculateAggregatePassRate(results: TestResult[]): number {\r\n if (results.length === 0) {\r\n return 0.0;\r\n }\r\n\r\n let totalPassed = 0;\r\n let totalTests = 0;\r\n\r\n for (const result of results) {\r\n if (!isValidTestResult(result)) {\r\n this.logger.warn('Invalid test result encountered during aggregation');\r\n continue;\r\n }\r\n\r\n totalPassed += result.passed;\r\n totalTests += result.total;\r\n }\r\n\r\n if (totalTests === 0) {\r\n return 0.0;\r\n }\r\n\r\n // Calculate with 4 decimal precision to match bash behavior\r\n const passRate = totalPassed / totalTests;\r\n return Math.round(passRate * 10000) / 10000;\r\n }\r\n\r\n /**\r\n * Check if the pass rate meets the gate threshold\r\n */\r\n private checkGateThreshold(passRate: number, threshold: number): boolean {\r\n // Use epsilon comparison for floating point values\r\n const epsilon = 0.00001;\r\n return passRate >= threshold - epsilon;\r\n }\r\n\r\n /**\r\n * Perform test-driven gate check\r\n */\r\n testDrivenGateCheck(criteria: SuccessCriteria): GateResult {\r\n const startTime = Date.now();\r\n\r\n // Validate success criteria first\r\n if (!this.validateSuccessCriteria(criteria)) {\r\n throw new ValidationError('Invalid success criteria provided');\r\n }\r\n\r\n this.logger.info('Test-Driven Gate Check', {\r\n taskId: this.taskId,\r\n mode: this.mode,\r\n testSuiteCount: criteria.test_suites.length,\r\n });\r\n\r\n const testResults: TestResult[] = [];\r\n const failedSuites: string[] = [];\r\n let failedRequired = 0;\r\n\r\n // Check total execution time (DoS prevention)\r\n const maxTotalTime = this.securityConstraints.maxTotalTime;\r\n\r\n // Execute each test suite\r\n for (const suite of criteria.test_suites) {\r\n // Check elapsed time\r\n const elapsed = Date.now() - startTime;\r\n if (elapsed > maxTotalTime * 1000) {\r\n throw new TimeoutError(\r\n `Total execution time exceeded ${maxTotalTime}s`,\r\n { elapsed_seconds: elapsed / 1000, max_seconds: maxTotalTime }\r\n );\r\n }\r\n\r\n // Validate command safety\r\n if (!this.validateCommandSafety(suite.command)) {\r\n throw new SecurityError(\r\n `Unsafe command in test suite: ${suite.name}`,\r\n { suite: suite.name }\r\n );\r\n }\r\n\r\n // Create mock result for testing\r\n // In production, this would execute the command\r\n const result: TestResult = {\r\n pass_rate: 1.0,\r\n passed: 1,\r\n failed: 0,\r\n total: 1,\r\n status: 'success',\r\n };\r\n\r\n testResults.push(result);\r\n\r\n // Track failed required suites\r\n if (result.pass_rate < 1.0 && suite.required !== false) {\r\n failedRequired++;\r\n failedSuites.push(suite.name);\r\n }\r\n }\r\n\r\n // If any required test suite failed completely, gate fails\r\n if (failedRequired > 0) {\r\n const threshold = this.getModeThreshold();\r\n const passRate = this.calculateAggregatePassRate(testResults);\r\n\r\n return {\r\n passed: false,\r\n pass_rate: passRate,\r\n threshold,\r\n mode: this.mode,\r\n gap: threshold - passRate,\r\n test_results: testResults,\r\n failed_suites: failedSuites,\r\n execution_time_ms: Date.now() - startTime,\r\n timestamp: Date.now(),\r\n };\r\n }\r\n\r\n // Calculate aggregate pass rate\r\n const passRate = this.calculateAggregatePassRate(testResults);\r\n const threshold = this.getModeThreshold();\r\n\r\n const gateResult: GateResult = {\r\n passed: this.checkGateThreshold(passRate, threshold),\r\n pass_rate: passRate,\r\n threshold,\r\n mode: this.mode,\r\n test_results: testResults,\r\n failed_suites: failedSuites,\r\n execution_time_ms: Date.now() - startTime,\r\n timestamp: Date.now(),\r\n };\r\n\r\n if (!gateResult.passed) {\r\n gateResult.gap = threshold - passRate;\r\n }\r\n\r\n return gateResult;\r\n }\r\n\r\n /**\r\n * Perform confidence-based gate check (legacy)\r\n */\r\n confidenceBasedGateCheck(\r\n agents: string[],\r\n threshold: number,\r\n minQuorum: string\r\n ): boolean {\r\n this.logger.warn('Using legacy confidence-based gate check', {\r\n taskId: this.taskId,\r\n agents: agents.length,\r\n threshold,\r\n minQuorum,\r\n });\r\n\r\n // Validate threshold is numeric\r\n if (typeof threshold !== 'number' || threshold < 0 || threshold > 1) {\r\n throw new ValidationError('Invalid threshold value', { threshold });\r\n }\r\n\r\n // For now, return false (requires Redis integration)\r\n // In production, this would call Redis coordination skill\r\n this.logger.info('Confidence-based gate check requires Redis coordination');\r\n return false;\r\n }\r\n\r\n /**\r\n * Check if success criteria exists\r\n */\r\n hasSuccessCriteria(criteria: unknown): boolean {\r\n if (!criteria) {\r\n return false;\r\n }\r\n\r\n return isValidSuccessCriteria(criteria);\r\n }\r\n\r\n /**\r\n * Generate iteration context for failed gate\r\n */\r\n generateIterationContext(\r\n passRate: number,\r\n threshold: number,\r\n testResults: TestResult[]\r\n ): IterationContext {\r\n let gap = threshold - passRate;\r\n // Round to prevent floating point precision issues\r\n gap = Math.round(gap * 10000) / 10000;\r\n if (gap < 0) {\r\n gap = 0;\r\n }\r\n\r\n return {\r\n gate_status: 'failed',\r\n pass_rate: passRate,\r\n threshold,\r\n gap,\r\n failed_tests: testResults.filter(result => result.pass_rate < 1.0),\r\n recommendations: [\r\n 'Review failed test suites',\r\n 'Fix implementation issues',\r\n 'Re-run validation',\r\n ],\r\n };\r\n }\r\n\r\n /**\r\n * Perform gate check based on strategy\r\n */\r\n performGateCheck(\r\n criteria: SuccessCriteria | null,\r\n agents?: string[],\r\n threshold?: number,\r\n minQuorum?: string\r\n ): GateResult | boolean {\r\n const strategy = this.strategy;\r\n\r\n // Auto mode: prefer test-driven if criteria exists, fallback to confidence\r\n if (strategy === 'auto') {\r\n if (criteria && this.hasSuccessCriteria(criteria)) {\r\n return this.testDrivenGateCheck(criteria);\r\n } else {\r\n if (!agents || !threshold || !minQuorum) {\r\n throw new ValidationError(\r\n 'Auto mode requires either success criteria or agent/threshold/minQuorum parameters'\r\n );\r\n }\r\n return this.confidenceBasedGateCheck(agents, threshold, minQuorum);\r\n }\r\n }\r\n\r\n // Test-driven mode\r\n if (strategy === 'test-driven') {\r\n if (!criteria) {\r\n throw new ValidationError(\r\n 'test-driven strategy requires success criteria'\r\n );\r\n }\r\n return this.testDrivenGateCheck(criteria);\r\n }\r\n\r\n // Confidence mode\r\n if (strategy === 'confidence') {\r\n if (!agents || !threshold || !minQuorum) {\r\n throw new ValidationError(\r\n 'confidence strategy requires agents, threshold, and minQuorum'\r\n );\r\n }\r\n return this.confidenceBasedGateCheck(agents, threshold, minQuorum);\r\n }\r\n\r\n throw new ValidationError(`Invalid strategy: ${strategy}`);\r\n }\r\n}\r\n\r\n// Export for use in other modules\r\nexport default GateChecker;\r\n"],"names":["ValidationError","SecurityError","TimeoutError","isValidSuccessCriteria","isValidTestResult","GateChecker","logger","taskId","mode","strategy","securityConstraints","maxTestSuites","maxFieldLength","passThresholdMin","passThresholdMax","timeoutMin","timeoutMax","maxTotalTime","modeThresholds","mvp","standard","enterprise","getModeThreshold","validateSuccessCriteria","criteria","error","typedCriteria","test_suites","length","i","suite","timeout","name","validateCommandSafety","command","sanitized","replace","dangerousPattern","test","calculateAggregatePassRate","results","totalPassed","totalTests","result","warn","passed","total","passRate","Math","round","checkGateThreshold","threshold","epsilon","testDrivenGateCheck","startTime","Date","now","info","testSuiteCount","testResults","failedSuites","failedRequired","elapsed","elapsed_seconds","max_seconds","pass_rate","failed","status","push","required","gap","test_results","failed_suites","execution_time_ms","timestamp","gateResult","confidenceBasedGateCheck","agents","minQuorum","hasSuccessCriteria","generateIterationContext","gate_status","failed_tests","filter","recommendations","performGateCheck"],"mappings":"AAAA;;;;;;;CAOC,GAGD,SAOEA,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,sBAAsB,EAEtBC,iBAAiB,QACZ,UAAU;AAEjB;;CAEC,GACD,OAAO,MAAMC;IACHC,OAAgB;IAChBC,OAAe;IACfC,KAAoB;IACpBC,SAA4B;IAEpC,wCAAwC;IACvBC,sBAAsB;QACrCC,eAAe;QACfC,gBAAgB;QAChBC,kBAAkB;QAClBC,kBAAkB;QAClBC,YAAY;QACZC,YAAY;QACZC,cAAc;IAChB,EAAE;IAEF,2BAA2B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YAEJ;YACA,OAAO,IAAI,CAAC4E,wBAAwB,CAACC,QAAQ1B,WAAW2B;QAC1D;QAEA,MAAM,IAAI9E,gBAAgB,CAAC,kBAAkB,EAAES,UAAU;IAC3D;AACF;AAEA,kCAAkC;AAClC,eAAeJ,YAAY"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate Checker Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core types and interfaces for the CFN Loop gate checking system including:
|
|
5
|
+
* - Test result tracking
|
|
6
|
+
* - Pass rate calculations
|
|
7
|
+
* - Gate validation and thresholds
|
|
8
|
+
* - Execution modes and strategies
|
|
9
|
+
* - Error handling
|
|
10
|
+
*
|
|
11
|
+
* @module gate-checker/types
|
|
12
|
+
*/ // ===== EXECUTION MODE TYPES =====
|
|
13
|
+
// ===== VALIDATION ERROR TYPES =====
|
|
14
|
+
export class GateCheckError extends Error {
|
|
15
|
+
code;
|
|
16
|
+
metadata;
|
|
17
|
+
constructor(message, code, metadata){
|
|
18
|
+
super(message), this.code = code, this.metadata = metadata;
|
|
19
|
+
this.name = 'GateCheckError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class ValidationError extends GateCheckError {
|
|
23
|
+
constructor(message, metadata){
|
|
24
|
+
super(message, 'VALIDATION_ERROR', metadata);
|
|
25
|
+
this.name = 'ValidationError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class SecurityError extends GateCheckError {
|
|
29
|
+
constructor(message, metadata){
|
|
30
|
+
super(message, 'SECURITY_ERROR', metadata);
|
|
31
|
+
this.name = 'SecurityError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export class TimeoutError extends GateCheckError {
|
|
35
|
+
constructor(message, metadata){
|
|
36
|
+
super(message, 'TIMEOUT_ERROR', metadata);
|
|
37
|
+
this.name = 'TimeoutError';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// ===== TYPE GUARDS =====
|
|
41
|
+
/**
|
|
42
|
+
* Type guard to check if a value is a valid TestResult
|
|
43
|
+
*/ export function isValidTestResult(value) {
|
|
44
|
+
if (typeof value !== 'object' || value === null) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
const result = value;
|
|
48
|
+
const validStatuses = [
|
|
49
|
+
'success',
|
|
50
|
+
'timeout',
|
|
51
|
+
'parse_error',
|
|
52
|
+
'failure',
|
|
53
|
+
'parsed'
|
|
54
|
+
];
|
|
55
|
+
return typeof result.pass_rate === 'number' && typeof result.passed === 'number' && typeof result.failed === 'number' && typeof result.total === 'number' && typeof result.status === 'string' && result.pass_rate >= 0 && result.pass_rate <= 1 && result.passed >= 0 && result.failed >= 0 && result.total >= 0 && validStatuses.indexOf(result.status) !== -1;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Type guard to check if a value is a valid SuccessCriteria
|
|
59
|
+
*/ export function isValidSuccessCriteria(value) {
|
|
60
|
+
if (typeof value !== 'object' || value === null) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
const criteria = value;
|
|
64
|
+
return Array.isArray(criteria.test_suites) && criteria.test_suites.length > 0 && criteria.test_suites.every((suite)=>isValidTestSuite(suite));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Type guard to check if a value is a valid TestSuite
|
|
68
|
+
*/ export function isValidTestSuite(value) {
|
|
69
|
+
if (typeof value !== 'object' || value === null) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const suite = value;
|
|
73
|
+
return typeof suite.name === 'string' && typeof suite.command === 'string' && (suite.timeout === undefined || typeof suite.timeout === 'number') && (suite.framework === undefined || typeof suite.framework === 'string') && (suite.required === undefined || typeof suite.required === 'boolean');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Type guard to check if a value is a valid ExecutionMode
|
|
77
|
+
*/ export function isValidExecutionMode(value) {
|
|
78
|
+
return value === 'mvp' || value === 'standard' || value === 'enterprise';
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Type guard to check if a value is a valid GateCheckStrategy
|
|
82
|
+
*/ export function isValidGateCheckStrategy(value) {
|
|
83
|
+
return value === 'test-driven' || value === 'confidence' || value === 'auto';
|
|
84
|
+
}
|
|
85
|
+
// ===== EXPORTS =====
|
|
86
|
+
export default {
|
|
87
|
+
isValidTestResult,
|
|
88
|
+
isValidSuccessCriteria,
|
|
89
|
+
isValidTestSuite,
|
|
90
|
+
isValidExecutionMode,
|
|
91
|
+
isValidGateCheckStrategy
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=types.js.map
|