claude-flow-novice 2.15.11 → 2.16.0
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/agents/cfn-v3-coordinator.md +517 -0
- package/.claude/commands/cfn-loop-cli.md +158 -464
- package/.claude/commands/cfn-loop-trigger.md +114 -0
- package/.claude/hooks/cfn-invoke-post-edit-ts.sh +100 -0
- package/.claude/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
- package/.claude/hooks/cfn-invoke-post-edit.sh +22 -0
- package/.claude/hooks/cfn-invoke-post-edit.sh.backup +87 -0
- package/.claude/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
- package/.claude/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
- package/.claude/hooks/cfn-invoke-pre-edit.sh +22 -0
- package/.claude/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
- package/.claude/skills/cfn-agent-spawning/SKILL.md +48 -1
- package/.claude/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
- package/.claude/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
- package/.claude/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
- package/.claude/skills/{cfn-redis-coordination/check-dependencies.sh → cfn-agent-spawning/check-dependencies.sh.backup} +3 -5
- package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
- package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
- package/.claude/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
- package/.claude/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
- package/.claude/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
- package/.claude/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
- package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
- package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
- package/.claude/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
- package/.claude/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
- package/.claude/skills/cfn-loop-orchestration/SKILL.md +159 -48
- package/.claude/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
- package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
- package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
- package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
- package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
- package/.claude/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
- package/.claude/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
- package/.claude/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
- package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
- package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
- package/{claude-assets/skills/cfn-loop-orchestration → .claude/skills/cfn-loop-orchestration/archive/legacy-bash}/orchestrate-wrapper.sh +11 -1
- package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
- package/.claude/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
- package/.claude/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
- package/.claude/skills/cfn-loop-orchestration/package-lock.json +3 -0
- package/.claude/skills/cfn-loop-orchestration/package.json +4 -0
- package/.claude/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
- package/.claude/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
- package/.claude/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
- package/.claude/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
- package/.claude/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
- package/.claude/skills/cfn-loop-orchestration/src/index.ts +2 -0
- package/.claude/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
- package/.claude/skills/cfn-loop-orchestration/src/types.ts +56 -0
- package/.claude/skills/cfn-loop-orchestration/test-cli.sh +92 -0
- package/.claude/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
- package/.claude/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
- package/.claude/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
- package/.claude/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
- package/.claude/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
- package/.claude/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
- package/.claude/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
- package/.claude/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
- package/.claude/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
- package/.claude/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
- package/.claude/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
- package/.claude/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
- package/.claude/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
- package/.claude/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
- package/.claude/skills/cfn-loop-validation/INDEX.md +531 -0
- package/.claude/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
- package/.claude/skills/cfn-loop-validation/SKILL.md +48 -1
- package/.claude/skills/cfn-loop-validation/SKILL.md.backup +353 -0
- package/.claude/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
- package/.claude/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
- package/.claude/skills/cfn-loop-validation/check-dependencies.sh +22 -0
- package/{claude-assets/skills/cfn-redis-coordination/check-dependencies.sh → .claude/skills/cfn-loop-validation/check-dependencies.sh.backup} +4 -5
- package/.claude/skills/cfn-loop-validation/detect-vapor.sh +59 -0
- package/.claude/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
- package/.claude/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/types.d.ts +156 -0
- package/.claude/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/types.js +66 -0
- package/.claude/skills/cfn-loop-validation/dist/types.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.js +411 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
- package/.claude/skills/cfn-loop-validation/package.json +93 -0
- package/.claude/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
- package/.claude/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
- package/.claude/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
- package/.claude/skills/cfn-loop-validation/src/types.ts +215 -0
- package/.claude/skills/cfn-loop-validation/src/validator.ts +503 -0
- package/.claude/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
- package/.claude/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
- package/.claude/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
- package/.claude/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
- package/.claude/skills/cfn-loop-validation/validate-gate.sh +63 -0
- package/.claude/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
- package/.claude/skills/cfn-loop-validation/validate-iteration.sh +22 -0
- package/.claude/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
- package/.claude/skills/cfn-product-owner-decision/SKILL.md +479 -147
- package/.claude/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
- package/{claude-assets/skills/cfn-product-owner-decision → .claude/skills/cfn-product-owner-decision/archive/legacy-bash}/execute-decision.sh +24 -2
- package/.claude/skills/pre-edit-backup/SKILL.md +324 -0
- package/.claude/skills/pre-edit-backup/SKILL.md.backup +277 -0
- package/.claude/skills/pre-edit-backup/backup.sh +22 -0
- package/.claude/skills/pre-edit-backup/backup.sh.backup +107 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +1 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +1 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +1 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +1 -0
- package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +10 -0
- package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +56 -33
- package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +46 -36
- package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +9 -0
- package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +17 -17
- package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +40 -58
- package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +18 -20
- package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +19 -28
- package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +15 -19
- package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +15 -10
- package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +15 -10
- package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +15 -25
- package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +17 -21
- package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +17 -21
- package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +1 -5
- package/claude-assets/agents/cfn-dev-team/reviewers/code-reviewer.md +20 -51
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +22 -71
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +21 -64
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +22 -67
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +23 -67
- package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +7 -35
- package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +8 -37
- package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +16 -54
- package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +17 -55
- package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +9 -37
- package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +17 -55
- package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +17 -48
- package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +8 -37
- package/claude-assets/agents/cfn-dev-team/testers/tester.md +7 -27
- package/claude-assets/agents/cfn-dev-team/utility/analyst.md +12 -28
- package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +13 -13
- package/claude-assets/agents/cfn-dev-team/utility/context-curator.md +7 -2
- package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +5 -10
- package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +120 -714
- package/claude-assets/agents/cfn-dev-team/utility/researcher.md +12 -21
- package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +146 -572
- package/claude-assets/agents/custom/cfn-docker-expert.md +102 -0
- package/claude-assets/agents/custom/cfn-loops-cli-expert.md +129 -0
- package/claude-assets/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
- package/claude-assets/commands/cfn-loop-cli.md +158 -464
- package/claude-assets/commands/cfn-loop-trigger.md +114 -0
- package/claude-assets/hooks/SKILL.md +518 -0
- package/claude-assets/hooks/SKILL.md.backup +471 -0
- package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh +100 -0
- package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
- package/claude-assets/hooks/cfn-invoke-post-edit.sh +22 -0
- package/claude-assets/hooks/cfn-invoke-post-edit.sh.backup +87 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit.sh +22 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/DELIVERABLES.md +409 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/IMPLEMENTATION_SUMMARY.md +396 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/INTEGRATION_GUIDE.md +308 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/QUICK_REFERENCE.md +239 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md +107 -1
- package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md.backup +302 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/TYPESCRIPT_MIGRATION.md +295 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.cjs +297 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.js +297 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.cjs +96 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.js +96 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh +45 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh.backup +23 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh +22 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh.backup +173 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.test.ts +357 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.ts +350 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/src/cli.ts +74 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh +22 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh.backup +71 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/tsconfig.json +18 -0
- package/claude-assets/skills/cfn-agent-spawning/SKILL.md +48 -1
- package/claude-assets/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
- package/claude-assets/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
- package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh.backup +30 -0
- package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
- package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
- package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
- package/claude-assets/skills/cfn-coordination/agent-completion.sh.backup +36 -0
- package/claude-assets/skills/cfn-coordination/coordination-signal.sh.backup +36 -0
- package/claude-assets/skills/cfn-coordination/coordination-wait.sh.backup +36 -0
- package/claude-assets/skills/cfn-dependency-ingestion/README.md +101 -0
- package/claude-assets/skills/cfn-dependency-ingestion/SKILL.md +369 -0
- package/claude-assets/skills/cfn-dependency-ingestion/build.sh +23 -0
- package/claude-assets/skills/cfn-dependency-ingestion/dist/ingest-dependencies.js +478 -0
- package/claude-assets/skills/cfn-dependency-ingestion/ingest-dependencies.sh +295 -0
- package/claude-assets/skills/cfn-dependency-ingestion/src/ingest-dependencies.ts +563 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
- package/claude-assets/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
- package/claude-assets/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
- package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
- package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
- package/claude-assets/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
- package/claude-assets/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
- package/claude-assets/skills/cfn-loop-orchestration/SKILL.md +159 -48
- package/claude-assets/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
- package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
- package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
- package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
- package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
- package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
- package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
- package/claude-assets/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
- package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
- package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
- package/{.claude/skills/cfn-loop-orchestration → claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash}/orchestrate-wrapper.sh +11 -1
- package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
- package/claude-assets/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
- package/claude-assets/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
- package/claude-assets/skills/cfn-loop-orchestration/package-lock.json +3 -0
- package/claude-assets/skills/cfn-loop-orchestration/package.json +4 -0
- package/claude-assets/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/index.ts +2 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
- package/claude-assets/skills/cfn-loop-orchestration/src/types.ts +56 -0
- package/claude-assets/skills/cfn-loop-orchestration/test-cli.sh +92 -0
- package/claude-assets/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
- package/claude-assets/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
- package/claude-assets/skills/cfn-loop-output-processing/.eslintrc.json +33 -0
- package/claude-assets/skills/cfn-loop-output-processing/DELIVERY_SUMMARY.txt +462 -0
- package/claude-assets/skills/cfn-loop-output-processing/DEPRECATION_NOTICE.md +183 -0
- package/claude-assets/skills/cfn-loop-output-processing/EXAMPLES.md +609 -0
- package/claude-assets/skills/cfn-loop-output-processing/IMPLEMENTATION_SUMMARY.md +418 -0
- package/claude-assets/skills/cfn-loop-output-processing/INDEX.md +531 -0
- package/claude-assets/skills/cfn-loop-output-processing/MIGRATION.md +362 -0
- package/claude-assets/skills/cfn-loop-output-processing/README.md +114 -0
- package/claude-assets/skills/cfn-loop-output-processing/SKILL.md +633 -0
- package/{.claude/skills/cfn-docker-redis-coordination → claude-assets/skills/cfn-loop-output-processing}/jest.config.js +7 -15
- package/claude-assets/skills/cfn-loop-output-processing/package.json +50 -0
- package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop2.ts +195 -0
- package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop3.ts +157 -0
- package/claude-assets/skills/cfn-loop-output-processing/src/output-processor.ts +632 -0
- package/claude-assets/skills/cfn-loop-output-processing/tests/output-processor.test.ts +617 -0
- package/claude-assets/skills/{cfn-docker-redis-coordination → cfn-loop-output-processing}/tsconfig.json +16 -7
- package/claude-assets/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
- package/claude-assets/skills/cfn-loop-validation/INDEX.md +531 -0
- package/claude-assets/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
- package/claude-assets/skills/cfn-loop-validation/SKILL.md +48 -1
- package/claude-assets/skills/cfn-loop-validation/SKILL.md.backup +353 -0
- package/claude-assets/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
- package/claude-assets/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
- package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh +22 -0
- package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh.backup +31 -0
- package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh +59 -0
- package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
- package/claude-assets/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts +156 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.js +66 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.js +411 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
- package/claude-assets/skills/cfn-loop-validation/package.json +93 -0
- package/claude-assets/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
- package/claude-assets/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
- package/claude-assets/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
- package/claude-assets/skills/cfn-loop-validation/src/types.ts +215 -0
- package/claude-assets/skills/cfn-loop-validation/src/validator.ts +503 -0
- package/claude-assets/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
- package/claude-assets/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
- package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
- package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
- package/claude-assets/skills/cfn-loop-validation/validate-gate.sh +63 -0
- package/claude-assets/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
- package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh +22 -0
- package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
- package/claude-assets/skills/cfn-product-owner-decision/SKILL.md +479 -147
- package/claude-assets/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
- package/{.claude/skills/cfn-product-owner-decision → claude-assets/skills/cfn-product-owner-decision/archive/legacy-bash}/execute-decision.sh +24 -2
- package/claude-assets/skills/cfn-provider-routing/README.md +129 -0
- package/claude-assets/skills/cfn-provider-routing/SKILL.md +192 -0
- package/claude-assets/skills/cfn-provider-routing/resolve-provider-model.ts +223 -0
- package/claude-assets/skills/pre-edit-backup/SKILL.md +324 -0
- package/claude-assets/skills/pre-edit-backup/SKILL.md.backup +277 -0
- package/claude-assets/skills/pre-edit-backup/backup.sh +22 -0
- package/claude-assets/skills/pre-edit-backup/backup.sh.backup +107 -0
- package/dist/agents/agent-loader.js +146 -165
- package/dist/agents/agent-loader.js.map +1 -1
- package/dist/api/auth-endpoints.js +415 -0
- package/dist/api/auth-endpoints.js.map +1 -0
- package/dist/api/task-endpoints.js +562 -0
- package/dist/api/task-endpoints.js.map +1 -0
- package/dist/backend/server.js +418 -0
- package/dist/backend/server.js.map +1 -0
- package/dist/cfn-loop/product-owner/decision-parser.js +356 -0
- package/dist/cfn-loop/product-owner/decision-parser.js.map +1 -0
- package/dist/cfn-loop/product-owner/index.js +1 -0
- package/dist/cfn-loop/product-owner/index.js.map +1 -1
- package/dist/cli/agent-command.js +1 -1
- package/dist/cli/agent-command.js.map +1 -1
- package/dist/cli/agent-completion.js +273 -0
- package/dist/cli/agent-completion.js.map +1 -0
- package/dist/cli/agent-prompt-builder.js +83 -48
- package/dist/cli/agent-prompt-builder.js.map +1 -1
- package/dist/cli/agent-spawner.js +499 -0
- package/dist/cli/agent-spawner.js.map +1 -0
- package/dist/cli/anthropic-client.js +10 -3
- package/dist/cli/anthropic-client.js.map +1 -1
- package/dist/cli/config-manager.js +91 -109
- package/dist/cli/index.js +11 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/parse-decision-cli.js +268 -0
- package/dist/cli/parse-decision-cli.js.map +1 -0
- package/dist/cli/post-edit-hook.js +83 -0
- package/dist/cli/post-edit-hook.js.map +1 -0
- package/dist/cli/pre-edit-hook.js +77 -0
- package/dist/cli/pre-edit-hook.js.map +1 -0
- package/dist/cli/spawn-agent-cli.js +209 -0
- package/dist/cli/spawn-agent-cli.js.map +1 -0
- package/dist/coordination/coordination-wrapper.js +383 -0
- package/dist/coordination/coordination-wrapper.js.map +1 -0
- package/dist/coordination/store-success-criteria.js +68 -0
- package/dist/coordination/store-success-criteria.js.map +1 -0
- package/dist/coordination/store-task-context.js +65 -0
- package/dist/coordination/store-task-context.js.map +1 -0
- package/dist/hooks/backup-manager.js +273 -0
- package/dist/hooks/backup-manager.js.map +1 -0
- package/dist/hooks/post-edit-validator.js +388 -0
- package/dist/hooks/post-edit-validator.js.map +1 -0
- package/dist/integration/index.js +19 -0
- package/dist/integration/index.js.map +1 -0
- package/dist/integration/task-mode-adapter.js +297 -0
- package/dist/integration/task-mode-adapter.js.map +1 -0
- package/dist/integration/trigger-dev-client.js +253 -0
- package/dist/integration/trigger-dev-client.js.map +1 -0
- package/dist/integration/trigger-dev-webhooks.js +362 -0
- package/dist/integration/trigger-dev-webhooks.js.map +1 -0
- package/dist/lib/path-validator.js +14 -5
- package/dist/lib/path-validator.js.map +1 -1
- package/dist/lib/redis-queue-manager.js +5 -1
- package/dist/lib/redis-queue-manager.js.map +1 -1
- package/dist/middleware/authentication.js +317 -0
- package/dist/middleware/authentication.js.map +1 -0
- package/dist/services/authentication.js +669 -0
- package/dist/services/authentication.js.map +1 -0
- package/dist/services/session-management.js +436 -0
- package/dist/services/session-management.js.map +1 -0
- package/dist/services/skill-deployment.js +8 -6
- package/dist/services/skill-deployment.js.map +1 -1
- package/dist/services/user-service.js +710 -0
- package/dist/services/user-service.js.map +1 -0
- package/dist/types/trigger-dev-events.d.js +10 -0
- package/dist/types/trigger-dev-events.d.js.map +1 -0
- package/docs/README.md +240 -0
- package/package.json +13 -4
- package/scripts/compare-workflow-performance.sh +556 -0
- package/scripts/migrate-to-optimized-workflows.sh +438 -0
- package/scripts/organize-docs.sh +338 -0
- package/scripts/trigger-dev-setup.sh +267 -0
- package/.claude/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
- package/.claude/skills/cfn-docker-redis-coordination/README.md +0 -294
- package/.claude/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
- package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
- package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
- package/.claude/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
- package/.claude/skills/cfn-docker-redis-coordination/package.json +0 -40
- package/.claude/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
- package/.claude/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
- package/.claude/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
- package/.claude/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
- package/.claude/skills/cfn-docker-redis-coordination/tsconfig.json +0 -30
- package/.claude/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
- package/.claude/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
- package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
- package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
- package/.claude/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
- package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
- package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
- package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
- package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
- package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
- package/.claude/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
- package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
- package/.claude/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
- package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
- package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
- package/.claude/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
- package/.claude/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
- package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
- package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
- package/.claude/skills/cfn-redis-coordination/config.json +0 -61
- package/.claude/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
- package/.claude/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
- package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
- package/.claude/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
- package/.claude/skills/cfn-redis-coordination/jest.config.js +0 -23
- package/.claude/skills/cfn-redis-coordination/package-lock.json +0 -5272
- package/.claude/skills/cfn-redis-coordination/package.json +0 -45
- package/.claude/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
- package/.claude/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
- package/.claude/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
- package/.claude/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
- package/.claude/skills/cfn-redis-coordination/src/index.ts +0 -82
- package/.claude/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
- package/.claude/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
- package/.claude/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
- package/.claude/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
- package/.claude/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
- package/.claude/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
- package/.claude/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
- package/.claude/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
- package/.claude/skills/cfn-redis-coordination/src/types.ts +0 -235
- package/.claude/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
- package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
- package/.claude/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
- package/.claude/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
- package/.claude/skills/cfn-redis-coordination/test-redis-check.js +0 -84
- package/.claude/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
- package/.claude/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
- package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +0 -980
- package/claude-assets/agents/typescript-specialist.md +0 -280
- package/claude-assets/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
- package/claude-assets/skills/cfn-docker-redis-coordination/README.md +0 -294
- package/claude-assets/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
- package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
- package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
- package/claude-assets/skills/cfn-docker-redis-coordination/jest.config.js +0 -37
- package/claude-assets/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
- package/claude-assets/skills/cfn-docker-redis-coordination/package.json +0 -40
- package/claude-assets/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
- package/claude-assets/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
- package/claude-assets/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
- package/claude-assets/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
- package/claude-assets/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
- package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
- package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
- package/claude-assets/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
- package/claude-assets/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
- package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
- package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
- package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
- package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
- package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
- package/claude-assets/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
- package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
- package/claude-assets/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
- package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
- package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
- package/claude-assets/skills/cfn-redis-cleanup/cleanup-redis.sh +0 -130
- package/claude-assets/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
- package/claude-assets/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
- package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
- package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
- package/claude-assets/skills/cfn-redis-coordination/config.json +0 -61
- package/claude-assets/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
- package/claude-assets/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
- package/claude-assets/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
- package/claude-assets/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
- package/claude-assets/skills/cfn-redis-coordination/jest.config.js +0 -23
- package/claude-assets/skills/cfn-redis-coordination/package-lock.json +0 -5272
- package/claude-assets/skills/cfn-redis-coordination/package.json +0 -45
- package/claude-assets/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
- package/claude-assets/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
- package/claude-assets/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
- package/claude-assets/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
- package/claude-assets/skills/cfn-redis-coordination/src/index.ts +0 -82
- package/claude-assets/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
- package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
- package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
- package/claude-assets/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
- package/claude-assets/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
- package/claude-assets/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
- package/claude-assets/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
- package/claude-assets/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
- package/claude-assets/skills/cfn-redis-coordination/src/types.ts +0 -235
- package/claude-assets/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
- package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
- package/claude-assets/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
- package/claude-assets/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
- package/claude-assets/skills/cfn-redis-coordination/test-redis-check.js +0 -84
- package/claude-assets/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
- package/claude-assets/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
- package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
- package/claude-assets/skills/cfn-redis-data-extraction/SKILL.md +0 -442
- package/claude-assets/skills/cfn-redis-data-extraction/extract.sh +0 -306
- package/dist/coordination/index.js +0 -25
- package/dist/coordination/index.js.map +0 -1
- package/docs/BUG_19_MEMORY_LEAK_TASK_MODE.md +0 -405
- package/docs/MEMORY_CLEANUP_GUIDE.md +0 -358
- package/docs/MEMORY_LEAK_FIX_SUMMARY.md +0 -322
- package/docs/REDIS_CLEANUP_EXECUTIVE_SUMMARY.md +0 -319
- package/docs/REDIS_CLEANUP_VERIFICATION_REPORT.md +0 -574
- /package/.claude/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
- /package/.claude/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
- /package/claude-assets/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Agent Completion CLI
|
|
4
|
+
*
|
|
5
|
+
* Signal agent completion with confidence score and test metrics
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* agent-completion --task-id <id> --agent-id <id> --confidence <score> [options]
|
|
9
|
+
*
|
|
10
|
+
* Required Arguments:
|
|
11
|
+
* --task-id <id> Task identifier
|
|
12
|
+
* --agent-id <id> Agent identifier
|
|
13
|
+
* --confidence <score> Confidence score (0.0-1.0)
|
|
14
|
+
*
|
|
15
|
+
* Optional Arguments:
|
|
16
|
+
* --iteration <n> Iteration number (default: 1)
|
|
17
|
+
* --namespace <ns> Namespace: swarm | cfn_loop (default: swarm)
|
|
18
|
+
* --test-pass-rate <pct> Test pass rate (0.0-1.0)
|
|
19
|
+
* --tests-run <n> Total tests run
|
|
20
|
+
* --tests-passed <n> Tests passed
|
|
21
|
+
* --result <json> Result JSON (test pass rate preferred)
|
|
22
|
+
* --redis-host <h> Redis host (default: localhost)
|
|
23
|
+
* --redis-port <p> Redis port (default: 6379)
|
|
24
|
+
* --json Output result as JSON
|
|
25
|
+
* --help Show this help message
|
|
26
|
+
*
|
|
27
|
+
* Examples:
|
|
28
|
+
* # Simple completion with confidence
|
|
29
|
+
* agent-completion \
|
|
30
|
+
* --task-id task123 \
|
|
31
|
+
* --agent-id agent-loop3-1 \
|
|
32
|
+
* --confidence 0.92
|
|
33
|
+
*
|
|
34
|
+
* # Completion with test metrics (test-driven)
|
|
35
|
+
* agent-completion \
|
|
36
|
+
* --task-id task123 \
|
|
37
|
+
* --agent-id agent-loop3-1 \
|
|
38
|
+
* --confidence 0.95 \
|
|
39
|
+
* --test-pass-rate 0.98 \
|
|
40
|
+
* --tests-run 50 \
|
|
41
|
+
* --tests-passed 49
|
|
42
|
+
*
|
|
43
|
+
* # Validator consensus score
|
|
44
|
+
* agent-completion \
|
|
45
|
+
* --task-id task123 \
|
|
46
|
+
* --agent-id validator-1 \
|
|
47
|
+
* --confidence 0.88 \
|
|
48
|
+
* --iteration 1
|
|
49
|
+
*/ import { CoordinationWrapper } from '../coordination/coordination-wrapper.js';
|
|
50
|
+
import * as process from 'process';
|
|
51
|
+
/**
|
|
52
|
+
* Parse command line arguments
|
|
53
|
+
*/ function parseArgs() {
|
|
54
|
+
const args = process.argv.slice(2);
|
|
55
|
+
const options = {
|
|
56
|
+
namespace: 'swarm',
|
|
57
|
+
iteration: 1,
|
|
58
|
+
redisHost: process.env.CFN_REDIS_HOST || process.env.REDIS_HOST || 'localhost',
|
|
59
|
+
redisPort: parseInt(process.env.CFN_REDIS_PORT || process.env.REDIS_PORT || '6379'),
|
|
60
|
+
json: false
|
|
61
|
+
};
|
|
62
|
+
for(let i = 0; i < args.length; i++){
|
|
63
|
+
const arg = args[i];
|
|
64
|
+
switch(arg){
|
|
65
|
+
case '--task-id':
|
|
66
|
+
options.taskId = args[++i];
|
|
67
|
+
break;
|
|
68
|
+
case '--agent-id':
|
|
69
|
+
options.agentId = args[++i];
|
|
70
|
+
break;
|
|
71
|
+
case '--confidence':
|
|
72
|
+
options.confidence = parseFloat(args[++i]);
|
|
73
|
+
break;
|
|
74
|
+
case '--iteration':
|
|
75
|
+
options.iteration = parseInt(args[++i]);
|
|
76
|
+
break;
|
|
77
|
+
case '--namespace':
|
|
78
|
+
options.namespace = args[++i];
|
|
79
|
+
break;
|
|
80
|
+
case '--test-pass-rate':
|
|
81
|
+
options.testPassRate = parseFloat(args[++i]);
|
|
82
|
+
break;
|
|
83
|
+
case '--tests-run':
|
|
84
|
+
options.testsRun = parseInt(args[++i]);
|
|
85
|
+
break;
|
|
86
|
+
case '--tests-passed':
|
|
87
|
+
options.testsPassed = parseInt(args[++i]);
|
|
88
|
+
break;
|
|
89
|
+
case '--result':
|
|
90
|
+
options.result = args[++i];
|
|
91
|
+
break;
|
|
92
|
+
case '--redis-host':
|
|
93
|
+
options.redisHost = args[++i];
|
|
94
|
+
break;
|
|
95
|
+
case '--redis-port':
|
|
96
|
+
options.redisPort = parseInt(args[++i]);
|
|
97
|
+
break;
|
|
98
|
+
case '--json':
|
|
99
|
+
options.json = true;
|
|
100
|
+
break;
|
|
101
|
+
case '--help':
|
|
102
|
+
case '-h':
|
|
103
|
+
options.help = true;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return options;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Show help message
|
|
111
|
+
*/ function showHelp() {
|
|
112
|
+
console.log(`
|
|
113
|
+
Agent Completion CLI - Signal agent completion with test metrics
|
|
114
|
+
|
|
115
|
+
Usage:
|
|
116
|
+
agent-completion --task-id <id> --agent-id <id> --confidence <score> [options]
|
|
117
|
+
|
|
118
|
+
Required Arguments:
|
|
119
|
+
--task-id <id> Task identifier
|
|
120
|
+
--agent-id <id> Agent identifier
|
|
121
|
+
--confidence <score> Confidence score (0.0-1.0)
|
|
122
|
+
|
|
123
|
+
Optional Arguments:
|
|
124
|
+
--iteration <n> Iteration number (default: 1)
|
|
125
|
+
--namespace <ns> Namespace: swarm | cfn_loop (default: swarm)
|
|
126
|
+
--test-pass-rate <pct> Test pass rate (0.0-1.0, preferred over confidence)
|
|
127
|
+
--tests-run <n> Total tests run
|
|
128
|
+
--tests-passed <n> Tests passed
|
|
129
|
+
--result <json> Result JSON (for custom data)
|
|
130
|
+
--redis-host <h> Redis host (default: localhost or CFN_REDIS_HOST env)
|
|
131
|
+
--redis-port <p> Redis port (default: 6379 or CFN_REDIS_PORT env)
|
|
132
|
+
--json Output result as JSON
|
|
133
|
+
--help, -h Show this help message
|
|
134
|
+
|
|
135
|
+
Examples:
|
|
136
|
+
# Simple completion with confidence
|
|
137
|
+
agent-completion \\
|
|
138
|
+
--task-id task123 \\
|
|
139
|
+
--agent-id agent-loop3-1 \\
|
|
140
|
+
--confidence 0.92
|
|
141
|
+
|
|
142
|
+
# Test-driven completion with metrics
|
|
143
|
+
agent-completion \\
|
|
144
|
+
--task-id task123 \\
|
|
145
|
+
--agent-id agent-loop3-1 \\
|
|
146
|
+
--confidence 0.95 \\
|
|
147
|
+
--test-pass-rate 0.98 \\
|
|
148
|
+
--tests-run 50 \\
|
|
149
|
+
--tests-passed 49
|
|
150
|
+
|
|
151
|
+
# Validator consensus
|
|
152
|
+
agent-completion \\
|
|
153
|
+
--task-id task123 \\
|
|
154
|
+
--agent-id validator-1 \\
|
|
155
|
+
--confidence 0.88 \\
|
|
156
|
+
--iteration 1 \\
|
|
157
|
+
--json
|
|
158
|
+
|
|
159
|
+
Environment Variables:
|
|
160
|
+
CFN_REDIS_HOST Redis host
|
|
161
|
+
CFN_REDIS_PORT Redis port
|
|
162
|
+
REDIS_HOST Fallback Redis host
|
|
163
|
+
REDIS_PORT Fallback Redis port
|
|
164
|
+
`);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Validate confidence score
|
|
168
|
+
*/ function validateConfidence(score) {
|
|
169
|
+
return typeof score === 'number' && score >= 0 && score <= 1;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Validate test pass rate
|
|
173
|
+
*/ function validateTestPassRate(rate) {
|
|
174
|
+
return typeof rate === 'number' && rate >= 0 && rate <= 1;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Main function
|
|
178
|
+
*/ async function main() {
|
|
179
|
+
const options = parseArgs();
|
|
180
|
+
if (options.help) {
|
|
181
|
+
showHelp();
|
|
182
|
+
process.exit(0);
|
|
183
|
+
}
|
|
184
|
+
// Validate required arguments
|
|
185
|
+
if (!options.taskId || !options.agentId || options.confidence === undefined) {
|
|
186
|
+
console.error('Error: Missing required arguments');
|
|
187
|
+
console.error('Use --help for usage information');
|
|
188
|
+
process.exit(1);
|
|
189
|
+
}
|
|
190
|
+
// Validate confidence score
|
|
191
|
+
if (!validateConfidence(options.confidence)) {
|
|
192
|
+
console.error('Error: Confidence score must be between 0.0 and 1.0');
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
// Validate test pass rate if provided
|
|
196
|
+
if (options.testPassRate !== undefined && !validateTestPassRate(options.testPassRate)) {
|
|
197
|
+
console.error('Error: Test pass rate must be between 0.0 and 1.0');
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
try {
|
|
201
|
+
// Create coordination wrapper
|
|
202
|
+
const coordinator = new CoordinationWrapper({
|
|
203
|
+
taskId: options.taskId,
|
|
204
|
+
namespace: options.namespace || 'swarm',
|
|
205
|
+
redisHost: options.redisHost || 'localhost',
|
|
206
|
+
redisPort: options.redisPort || 6379
|
|
207
|
+
});
|
|
208
|
+
// Connect to Redis
|
|
209
|
+
await coordinator.connect();
|
|
210
|
+
// Build result object
|
|
211
|
+
let resultObj;
|
|
212
|
+
if (options.result) {
|
|
213
|
+
try {
|
|
214
|
+
resultObj = JSON.parse(options.result);
|
|
215
|
+
} catch {
|
|
216
|
+
// If result is not valid JSON, store as string
|
|
217
|
+
resultObj = {
|
|
218
|
+
result: options.result
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// Signal completion
|
|
223
|
+
await coordinator.signalCompletion(options.agentId, options.confidence, {
|
|
224
|
+
testPassRate: options.testPassRate,
|
|
225
|
+
testsRun: options.testsRun,
|
|
226
|
+
testsPassed: options.testsPassed,
|
|
227
|
+
result: resultObj,
|
|
228
|
+
iteration: options.iteration
|
|
229
|
+
});
|
|
230
|
+
// Output result
|
|
231
|
+
const output = {
|
|
232
|
+
taskId: options.taskId,
|
|
233
|
+
agentId: options.agentId,
|
|
234
|
+
confidence: options.confidence,
|
|
235
|
+
testPassRate: options.testPassRate,
|
|
236
|
+
testsRun: options.testsRun,
|
|
237
|
+
testsPassed: options.testsPassed,
|
|
238
|
+
iteration: options.iteration,
|
|
239
|
+
timestamp: new Date().toISOString(),
|
|
240
|
+
status: 'success'
|
|
241
|
+
};
|
|
242
|
+
if (options.json) {
|
|
243
|
+
console.log(JSON.stringify(output, null, 2));
|
|
244
|
+
} else {
|
|
245
|
+
console.log(`Agent ${options.agentId} completion reported`);
|
|
246
|
+
console.log(`Confidence: ${(options.confidence * 100).toFixed(1)}%`);
|
|
247
|
+
if (options.testPassRate !== undefined) {
|
|
248
|
+
console.log(`Test Pass Rate: ${(options.testPassRate * 100).toFixed(1)}%`);
|
|
249
|
+
}
|
|
250
|
+
if (options.testsRun !== undefined && options.testsPassed !== undefined) {
|
|
251
|
+
console.log(`Tests: ${options.testsPassed}/${options.testsRun}`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
// Disconnect
|
|
255
|
+
await coordinator.disconnect();
|
|
256
|
+
process.exit(0);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
console.error('Error reporting agent completion:', error);
|
|
259
|
+
if (options.json) {
|
|
260
|
+
console.log(JSON.stringify({
|
|
261
|
+
taskId: options.taskId,
|
|
262
|
+
agentId: options.agentId,
|
|
263
|
+
status: 'error',
|
|
264
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
265
|
+
}, null, 2));
|
|
266
|
+
}
|
|
267
|
+
process.exit(1);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// Run main function
|
|
271
|
+
main();
|
|
272
|
+
|
|
273
|
+
//# sourceMappingURL=agent-completion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli/agent-completion.ts"],"sourcesContent":["#!/usr/bin/env node\r\n\r\n/**\r\n * Agent Completion CLI\r\n *\r\n * Signal agent completion with confidence score and test metrics\r\n *\r\n * Usage:\r\n * agent-completion --task-id <id> --agent-id <id> --confidence <score> [options]\r\n *\r\n * Required Arguments:\r\n * --task-id <id> Task identifier\r\n * --agent-id <id> Agent identifier\r\n * --confidence <score> Confidence score (0.0-1.0)\r\n *\r\n * Optional Arguments:\r\n * --iteration <n> Iteration number (default: 1)\r\n * --namespace <ns> Namespace: swarm | cfn_loop (default: swarm)\r\n * --test-pass-rate <pct> Test pass rate (0.0-1.0)\r\n * --tests-run <n> Total tests run\r\n * --tests-passed <n> Tests passed\r\n * --result <json> Result JSON (test pass rate preferred)\r\n * --redis-host <h> Redis host (default: localhost)\r\n * --redis-port <p> Redis port (default: 6379)\r\n * --json Output result as JSON\r\n * --help Show this help message\r\n *\r\n * Examples:\r\n * # Simple completion with confidence\r\n * agent-completion \\\r\n * --task-id task123 \\\r\n * --agent-id agent-loop3-1 \\\r\n * --confidence 0.92\r\n *\r\n * # Completion with test metrics (test-driven)\r\n * agent-completion \\\r\n * --task-id task123 \\\r\n * --agent-id agent-loop3-1 \\\r\n * --confidence 0.95 \\\r\n * --test-pass-rate 0.98 \\\r\n * --tests-run 50 \\\r\n * --tests-passed 49\r\n *\r\n * # Validator consensus score\r\n * agent-completion \\\r\n * --task-id task123 \\\r\n * --agent-id validator-1 \\\r\n * --confidence 0.88 \\\r\n * --iteration 1\r\n */\r\n\r\nimport { CoordinationWrapper } from '../coordination/coordination-wrapper.js';\r\nimport * as process from 'process';\r\n\r\ninterface Options {\r\n taskId: string;\r\n agentId: string;\r\n confidence: number;\r\n iteration?: number;\r\n namespace?: 'swarm' | 'cfn_loop';\r\n testPassRate?: number;\r\n testsRun?: number;\r\n testsPassed?: number;\r\n result?: string;\r\n redisHost?: string;\r\n redisPort?: number;\r\n json?: boolean;\r\n help?: boolean;\r\n}\r\n\r\n/**\r\n * Parse command line arguments\r\n */\r\nfunction parseArgs(): Options {\r\n const args = process.argv.slice(2);\r\n const options: Partial<Options> = {\r\n namespace: 'swarm',\r\n iteration: 1,\r\n redisHost: process.env.CFN_REDIS_HOST || process.env.REDIS_HOST || 'localhost',\r\n redisPort: parseInt(process.env.CFN_REDIS_PORT || process.env.REDIS_PORT || '6379'),\r\n json: false\r\n };\r\n\r\n for (let i = 0; i < args.length; i++) {\r\n const arg = args[i];\r\n\r\n switch (arg) {\r\n case '--task-id':\r\n options.taskId = args[++i];\r\n break;\r\n case '--agent-id':\r\n options.agentId = args[++i];\r\n break;\r\n case '--confidence':\r\n options.confidence = parseFloat(args[++i]);\r\n break;\r\n case '--iteration':\r\n options.iteration = parseInt(args[++i]);\r\n break;\r\n case '--namespace':\r\n options.namespace = args[++i] as 'swarm' | 'cfn_loop';\r\n break;\r\n case '--test-pass-rate':\r\n options.testPassRate = parseFloat(args[++i]);\r\n break;\r\n case '--tests-run':\r\n options.testsRun = parseInt(args[++i]);\r\n break;\r\n case '--tests-passed':\r\n options.testsPassed = parseInt(args[++i]);\r\n break;\r\n case '--result':\r\n options.result = args[++i];\r\n break;\r\n case '--redis-host':\r\n options.redisHost = args[++i];\r\n break;\r\n case '--redis-port':\r\n options.redisPort = parseInt(args[++i]);\r\n break;\r\n case '--json':\r\n options.json = true;\r\n break;\r\n case '--help':\r\n case '-h':\r\n options.help = true;\r\n break;\r\n }\r\n }\r\n\r\n return options as Options;\r\n}\r\n\r\n/**\r\n * Show help message\r\n */\r\nfunction showHelp(): void {\r\n console.log(`\r\nAgent Completion CLI - Signal agent completion with test metrics\r\n\r\nUsage:\r\n agent-completion --task-id <id> --agent-id <id> --confidence <score> [options]\r\n\r\nRequired Arguments:\r\n --task-id <id> Task identifier\r\n --agent-id <id> Agent identifier\r\n --confidence <score> Confidence score (0.0-1.0)\r\n\r\nOptional Arguments:\r\n --iteration <n> Iteration number (default: 1)\r\n --namespace <ns> Namespace: swarm | cfn_loop (default: swarm)\r\n --test-pass-rate <pct> Test pass rate (0.0-1.0, preferred over confidence)\r\n --tests-run <n> Total tests run\r\n --tests-passed <n> Tests passed\r\n --result <json> Result JSON (for custom data)\r\n --redis-host <h> Redis host (default: localhost or CFN_REDIS_HOST env)\r\n --redis-port <p> Redis port (default: 6379 or CFN_REDIS_PORT env)\r\n --json Output result as JSON\r\n --help, -h Show this help message\r\n\r\nExamples:\r\n # Simple completion with confidence\r\n agent-completion \\\\\r\n --task-id task123 \\\\\r\n --agent-id agent-loop3-1 \\\\\r\n --confidence 0.92\r\n\r\n # Test-driven completion with metrics\r\n agent-completion \\\\\r\n --task-id task123 \\\\\r\n --agent-id agent-loop3-1 \\\\\r\n --confidence 0.95 \\\\\r\n --test-pass-rate 0.98 \\\\\r\n --tests-run 50 \\\\\r\n --tests-passed 49\r\n\r\n # Validator consensus\r\n agent-completion \\\\\r\n --task-id task123 \\\\\r\n --agent-id validator-1 \\\\\r\n --confidence 0.88 \\\\\r\n --iteration 1 \\\\\r\n --json\r\n\r\nEnvironment Variables:\r\n CFN_REDIS_HOST Redis host\r\n CFN_REDIS_PORT Redis port\r\n REDIS_HOST Fallback Redis host\r\n REDIS_PORT Fallback Redis port\r\n`);\r\n}\r\n\r\n/**\r\n * Validate confidence score\r\n */\r\nfunction validateConfidence(score: number): boolean {\r\n return typeof score === 'number' && score >= 0 && score <= 1;\r\n}\r\n\r\n/**\r\n * Validate test pass rate\r\n */\r\nfunction validateTestPassRate(rate: number): boolean {\r\n return typeof rate === 'number' && rate >= 0 && rate <= 1;\r\n}\r\n\r\n/**\r\n * Main function\r\n */\r\nasync function main(): Promise<void> {\r\n const options = parseArgs();\r\n\r\n if (options.help) {\r\n showHelp();\r\n process.exit(0);\r\n }\r\n\r\n // Validate required arguments\r\n if (!options.taskId || !options.agentId || options.confidence === undefined) {\r\n console.error('Error: Missing required arguments');\r\n console.error('Use --help for usage information');\r\n process.exit(1);\r\n }\r\n\r\n // Validate confidence score\r\n if (!validateConfidence(options.confidence)) {\r\n console.error('Error: Confidence score must be between 0.0 and 1.0');\r\n process.exit(1);\r\n }\r\n\r\n // Validate test pass rate if provided\r\n if (options.testPassRate !== undefined && !validateTestPassRate(options.testPassRate)) {\r\n console.error('Error: Test pass rate must be between 0.0 and 1.0');\r\n process.exit(1);\r\n }\r\n\r\n try {\r\n // Create coordination wrapper\r\n const coordinator = new CoordinationWrapper({\r\n taskId: options.taskId,\r\n namespace: options.namespace || 'swarm',\r\n redisHost: options.redisHost || 'localhost',\r\n redisPort: options.redisPort || 6379\r\n });\r\n\r\n // Connect to Redis\r\n await coordinator.connect();\r\n\r\n // Build result object\r\n let resultObj: Record<string, unknown> | undefined;\r\n if (options.result) {\r\n try {\r\n resultObj = JSON.parse(options.result);\r\n } catch {\r\n // If result is not valid JSON, store as string\r\n resultObj = { result: options.result };\r\n }\r\n }\r\n\r\n // Signal completion\r\n await coordinator.signalCompletion(options.agentId, options.confidence, {\r\n testPassRate: options.testPassRate,\r\n testsRun: options.testsRun,\r\n testsPassed: options.testsPassed,\r\n result: resultObj,\r\n iteration: options.iteration\r\n });\r\n\r\n // Output result\r\n const output = {\r\n taskId: options.taskId,\r\n agentId: options.agentId,\r\n confidence: options.confidence,\r\n testPassRate: options.testPassRate,\r\n testsRun: options.testsRun,\r\n testsPassed: options.testsPassed,\r\n iteration: options.iteration,\r\n timestamp: new Date().toISOString(),\r\n status: 'success'\r\n };\r\n\r\n if (options.json) {\r\n console.log(JSON.stringify(output, null, 2));\r\n } else {\r\n console.log(`Agent ${options.agentId} completion reported`);\r\n console.log(`Confidence: ${(options.confidence * 100).toFixed(1)}%`);\r\n if (options.testPassRate !== undefined) {\r\n console.log(`Test Pass Rate: ${(options.testPassRate * 100).toFixed(1)}%`);\r\n }\r\n if (options.testsRun !== undefined && options.testsPassed !== undefined) {\r\n console.log(`Tests: ${options.testsPassed}/${options.testsRun}`);\r\n }\r\n }\r\n\r\n // Disconnect\r\n await coordinator.disconnect();\r\n\r\n process.exit(0);\r\n } catch (error) {\r\n console.error('Error reporting agent completion:', error);\r\n if (options.json) {\r\n console.log(\r\n JSON.stringify({\r\n taskId: options.taskId,\r\n agentId: options.agentId,\r\n status: 'error',\r\n error: error instanceof Error ? error.message : 'Unknown error'\r\n }, null, 2)\r\n );\r\n }\r\n process.exit(1);\r\n }\r\n}\r\n\r\n// Run main function\r\nmain();\r\n"],"names":["CoordinationWrapper","process","parseArgs","args","argv","slice","options","namespace","iteration","redisHost","env","CFN_REDIS_HOST","REDIS_HOST","redisPort","parseInt","CFN_REDIS_PORT","REDIS_PORT","json","i","length","arg","taskId","agentId","confidence","parseFloat","testPassRate","testsRun","testsPassed","result","help","showHelp","console","log","validateConfidence","score","validateTestPassRate","rate","main","exit","undefined","error","coordinator","connect","resultObj","JSON","parse","signalCompletion","output","timestamp","Date","toISOString","status","stringify","toFixed","disconnect","Error","message"],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CC,GAED,SAASA,mBAAmB,QAAQ,0CAA0C;AAC9E,YAAYC,aAAa,UAAU;AAkBnC;;CAEC,GACD,SAASC;IACP,MAAMC,OAAOF,QAAQG,IAAI,CAACC,KAAK,CAAC;IAChC,MAAMC,UAA4B;QAChCC,WAAW;QACXC,WAAW;QACXC,WAAWR,QAAQS,GAAG,CAACC,cAAc,IAAIV,QAAQS,GAAG,CAACE,UAAU,IAAI;QACnEC,WAAWC,SAASb,QAAQS,GAAG,CAACK,cAAc,IAAId,QAAQS,GAAG,CAACM,UAAU,IAAI;QAC5EC,MAAM;IACR;IAEA,IAAK,IAAIC,IAAI,GAAGA,IAAIf,KAAKgB,MAAM,EAAED,IAAK;QACpC,MAAME,MAAMjB,IAAI,CAACe,EAAE;QAEnB,OAAQE;YACN,KAAK;gBACHd,QAAQe,MAAM,GAAGlB,IAAI,CAAC,EAAEe,EAAE;gBAC1B;YACF,KAAK;gBACHZ,QAAQgB,OAAO,GAAGnB,IAAI,CAAC,EAAEe,EAAE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BC,SAAShB,QAAQgB,OAAO;gBACxB6B,QAAQ;gBACRX,OAAOA,iBAAiBe,QAAQf,MAAMgB,OAAO,GAAG;YAClD,GAAG,MAAM;QAEb;QACAvD,QAAQqC,IAAI,CAAC;IACf;AACF;AAEA,oBAAoB;AACpBD"}
|
|
@@ -11,69 +11,96 @@
|
|
|
11
11
|
*/ import { loadIterationHistory, formatIterationHistory } from './iteration-history.js';
|
|
12
12
|
import { SkillLoader } from './skill-loader.js';
|
|
13
13
|
/**
|
|
14
|
-
* Build
|
|
15
|
-
*/ function
|
|
14
|
+
* Build CLI Mode Redis Completion Protocol for CLI Mode
|
|
15
|
+
*/ function buildCLIModeProtocol(taskId, agentId) {
|
|
16
16
|
return `
|
|
17
|
-
##
|
|
17
|
+
## CLI Mode Redis Completion Protocol
|
|
18
18
|
|
|
19
|
-
You are
|
|
19
|
+
You are running in CLI Mode with Main Chat coordination. Follow this protocol EXACTLY:
|
|
20
20
|
|
|
21
21
|
### Step 1: Complete Your Work
|
|
22
22
|
Execute your assigned task (implementation, review, testing, etc.)
|
|
23
23
|
|
|
24
|
-
### Step 2:
|
|
25
|
-
|
|
26
|
-
- 0.90-1.0: Excellent, production-ready
|
|
27
|
-
- 0.75-0.89: Good, minor issues possible
|
|
28
|
-
- 0.50-0.74: Acceptable, needs review
|
|
29
|
-
- 0.0-0.49: Poor, significant issues
|
|
24
|
+
### Step 2: Signal Completion to Main Chat
|
|
25
|
+
Send a Redis signal to notify Main Chat that you're finished:
|
|
30
26
|
|
|
31
|
-
### Step 3: Report Completion to Redis
|
|
32
27
|
\`\`\`bash
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
# Use Node.js for Redis communication
|
|
29
|
+
node -e "
|
|
30
|
+
const { createClient } = require('redis');
|
|
31
|
+
const signal = {
|
|
32
|
+
agentId: '${agentId}',
|
|
33
|
+
taskId: '${taskId}',
|
|
34
|
+
status: 'completed',
|
|
35
|
+
timestamp: new Date().toISOString(),
|
|
36
|
+
provider: process.env.PROVIDER || 'unknown',
|
|
37
|
+
model: process.env.MODEL || 'unknown',
|
|
38
|
+
confidence: 0.90, // Replace with your actual confidence
|
|
39
|
+
metadata: {
|
|
40
|
+
iteration: process.env.ITERATION || 1,
|
|
41
|
+
mode: process.env.MODE || 'standard'
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
(async () => {
|
|
46
|
+
const client = createClient({ url: 'redis://localhost:6379' });
|
|
47
|
+
await client.connect();
|
|
39
48
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
const signalKey = \`cfn:mainchat:signal:\${process.env.TASK_ID}\`;
|
|
50
|
+
await client.lPush(signalKey, JSON.stringify(signal));
|
|
51
|
+
|
|
52
|
+
console.log(\`✅ Completion signal sent to Main Chat via Redis\`);
|
|
53
|
+
await client.disconnect();
|
|
54
|
+
})();
|
|
55
|
+
"
|
|
56
|
+
\`\`\`
|
|
45
57
|
|
|
46
|
-
### Step
|
|
47
|
-
After
|
|
58
|
+
### Step 3: Exit Cleanly
|
|
59
|
+
After sending the signal, exit immediately. Main Chat is waiting for your Redis signal.
|
|
48
60
|
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
61
|
+
**Why This Protocol:**
|
|
62
|
+
- Main Chat uses Redis BLPOP to wait for your completion signal
|
|
63
|
+
- Enables simple 2-layer coordination (Main Chat → CLI agents)
|
|
64
|
+
- No complex orchestrator needed for CLI mode
|
|
65
|
+
- Supports different AI providers via environment variables
|
|
54
66
|
|
|
55
67
|
**Environment Variables Available:**
|
|
56
68
|
- TASK_ID: ${taskId}
|
|
57
69
|
- AGENT_ID: ${agentId}
|
|
58
|
-
-
|
|
59
|
-
-
|
|
70
|
+
- PROVIDER: AI provider (zai, kimi, anthropic, etc.)
|
|
71
|
+
- MODEL: Specific model being used
|
|
72
|
+
- ITERATION: Current iteration number
|
|
73
|
+
- MODE: Execution mode (mvp, standard, enterprise)
|
|
60
74
|
|
|
61
|
-
**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
**Main Chat Workflow:**
|
|
76
|
+
1. Spawns you via CLI with specific provider/model
|
|
77
|
+
2. Waits via \`redis-cli BLPOP cfn:mainchat:signal:${taskId}\`
|
|
78
|
+
3. Processes your completion signal when received
|
|
79
|
+
4. Continues with next task or spawns additional agents
|
|
66
80
|
|
|
67
|
-
**CRITICAL:**
|
|
81
|
+
**CRITICAL:** Send Redis signal before exiting. Main Chat cannot proceed without your completion signal.
|
|
68
82
|
`;
|
|
69
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Parse shell variable format into JSON object
|
|
86
|
+
* Example: "WORKSPACE='/tmp/test' MODE='standard'" -> {WORKSPACE: '/tmp/test', MODE: 'standard'}
|
|
87
|
+
*/ function parseShellVariables(shellContext) {
|
|
88
|
+
const jsonObj = {};
|
|
89
|
+
const regex = /([A-Z_]+)='([^']*)'/g;
|
|
90
|
+
let match;
|
|
91
|
+
while((match = regex.exec(shellContext)) !== null){
|
|
92
|
+
jsonObj[match[1]] = match[2];
|
|
93
|
+
}
|
|
94
|
+
return jsonObj;
|
|
95
|
+
}
|
|
70
96
|
/**
|
|
71
97
|
* Parse and enrich JSON context into natural language instructions
|
|
72
98
|
*/ function enrichJSONContext(jsonObj) {
|
|
73
99
|
const sections = [];
|
|
74
|
-
// Extract task description
|
|
75
|
-
|
|
76
|
-
|
|
100
|
+
// Extract task description (support both 'task' and 'taskDescription' keys)
|
|
101
|
+
const taskText = jsonObj.task || jsonObj.taskDescription;
|
|
102
|
+
if (taskText) {
|
|
103
|
+
sections.push(`**Task:** ${taskText}`);
|
|
77
104
|
}
|
|
78
105
|
// Parse files - convert comma-separated string to bullet list
|
|
79
106
|
if (jsonObj.files) {
|
|
@@ -102,9 +129,10 @@ The orchestrator will:
|
|
|
102
129
|
if (jsonObj.batch) {
|
|
103
130
|
sections.push(`\n**Batch:** ${jsonObj.batch}`);
|
|
104
131
|
}
|
|
105
|
-
// Add directory context
|
|
106
|
-
|
|
107
|
-
|
|
132
|
+
// Add directory context - support 'directory', 'WORKSPACE', and 'workspace' keys
|
|
133
|
+
const workspacePath = jsonObj.directory || jsonObj.WORKSPACE || jsonObj.workspace;
|
|
134
|
+
if (workspacePath) {
|
|
135
|
+
sections.push(`\n**Working Directory:** ${workspacePath}`);
|
|
108
136
|
}
|
|
109
137
|
// Add acceptance criteria
|
|
110
138
|
if (jsonObj.acceptanceCriteria) {
|
|
@@ -129,10 +157,17 @@ The orchestrator will:
|
|
|
129
157
|
*/ function buildTaskDescription(agentType, context) {
|
|
130
158
|
let desc = '';
|
|
131
159
|
if (context.context) {
|
|
132
|
-
// Try to parse
|
|
160
|
+
// Try to parse context in multiple formats
|
|
133
161
|
let contextStr = context.context.trim();
|
|
134
|
-
//
|
|
135
|
-
if (contextStr.
|
|
162
|
+
// Parse shell variables BEFORE attempting JSON parse
|
|
163
|
+
if (contextStr.includes('=') && !contextStr.startsWith('{')) {
|
|
164
|
+
const jsonObj = parseShellVariables(contextStr);
|
|
165
|
+
desc = enrichJSONContext(jsonObj);
|
|
166
|
+
// Add instruction footer for structured tasks
|
|
167
|
+
if (jsonObj.files || jsonObj.deliverables) {
|
|
168
|
+
desc += '\n\n**Process each item systematically and report confidence when complete.**';
|
|
169
|
+
}
|
|
170
|
+
} else if (contextStr.startsWith('{') && contextStr.endsWith('}') || contextStr.startsWith('[') && contextStr.endsWith(']')) {
|
|
136
171
|
try {
|
|
137
172
|
const jsonObj = JSON.parse(contextStr);
|
|
138
173
|
desc = enrichJSONContext(jsonObj);
|
|
@@ -333,9 +368,9 @@ ${env.join('\n')}
|
|
|
333
368
|
console.warn(`[agent-prompt-builder] Skill loading failed: ${skillError}`);
|
|
334
369
|
// Continue without skills
|
|
335
370
|
}
|
|
336
|
-
// 5.
|
|
371
|
+
// 5. CLI Mode protocol (ALWAYS inject when taskId present - enables Redis coordination)
|
|
337
372
|
if (context.taskId && agentId) {
|
|
338
|
-
sections.push(
|
|
373
|
+
sections.push(buildCLIModeProtocol(context.taskId, agentId));
|
|
339
374
|
sections.push('');
|
|
340
375
|
}
|
|
341
376
|
// 6. Environment context
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/agent-prompt-builder.ts"],"sourcesContent":["/**\r\n * Agent Prompt Builder\r\n *\r\n * Builds comprehensive prompts for CLI-spawned agents by combining:\r\n * - Agent definition (YAML + markdown)\r\n * - Task context (taskId, iteration, mode)\r\n * - CFN Loop protocol (if applicable)\r\n * - Iteration history (Sprint 3 - Phase 2)\r\n * - Environment variables\r\n * - Skills (Phase 5 - Skills Database integration)\r\n */\r\n\r\nimport { AgentDefinition, hasCFNLoopProtocol } from './agent-definition-parser.js';\r\nimport { loadIterationHistory, formatIterationHistory } from './iteration-history.js';\r\nimport { SkillLoader, Skill } from './skill-loader.js';\r\n\r\nexport interface TaskContext {\r\n taskId?: string;\r\n iteration?: number;\r\n context?: string;\r\n mode?: string;\r\n priority?: number;\r\n parentTaskId?: string;\r\n agentId?: string;\r\n keywords?: string; // Phase 5: For skill filtering\r\n phase?: string; // Phase 5: CFN Loop phase (loop1, loop2, loop3)\r\n}\r\n\r\n/**\r\n * Build CFN Loop protocol instructions\r\n */\r\nfunction buildCFNLoopProtocol(taskId: string, agentId: string): string {\r\n return `\r\n## CFN Loop Redis Completion Protocol\r\n\r\nYou are participating in a CFN Loop workflow. Follow this protocol EXACTLY:\r\n\r\n### Step 1: Complete Your Work\r\nExecute your assigned task (implementation, review, testing, etc.)\r\n\r\n### Step 2: Calculate Confidence Score\r\nAssess your work quality and assign a confidence score (0.0-1.0):\r\n- 0.90-1.0: Excellent, production-ready\r\n- 0.75-0.89: Good, minor issues possible\r\n- 0.50-0.74: Acceptable, needs review\r\n- 0.0-0.49: Poor, significant issues\r\n\r\n### Step 3: Report Completion to Redis\r\n\\`\\`\\`bash\r\n./.claude/skills/cfn-redis-coordination/report-completion.sh \\\\\r\n --task-id \"${taskId}\" \\\\\r\n --agent-id \"${agentId}\" \\\\\r\n --confidence [YOUR_CONFIDENCE_SCORE] \\\\\r\n --iteration \\${ITERATION:-1}\r\n\\`\\`\\`\r\n\r\nThis script automatically:\r\n- Signals completion via \\`swarm:${taskId}:${agentId}:done\\`\r\n- Stores confidence in \\`swarm:${taskId}:${agentId}:confidence\\`\r\n- Creates result hash in \\`swarm:${taskId}:${agentId}:result\\`\r\n- Updates SQLite persistence layer\r\n\r\n### Step 4: Exit Cleanly\r\nAfter reporting, exit immediately. DO NOT enter waiting mode.\r\n\r\nThe orchestrator will:\r\n- Collect confidence scores from all agents\r\n- Run gate check (≥0.75 threshold)\r\n- Spawn validators if gate passes\r\n- Spawn fresh agents for iteration N+1 if needed\r\n\r\n**Environment Variables Available:**\r\n- TASK_ID: ${taskId}\r\n- AGENT_ID: ${agentId}\r\n- ITERATION: Current iteration number (default: 1)\r\n- CONFIDENCE_SCORE: Your final confidence assessment\r\n\r\n**Why This Matters:**\r\n- Enables zero-token coordination (orchestrator uses Redis BLPOP)\r\n- Supports adaptive agent specialization (spawn different specialist for iteration N+1)\r\n- Prevents memory leaks (agents exit after reporting)\r\n- Confidence scores drive gate checks and consensus validation\r\n\r\n**CRITICAL:** Report completion before exiting. Orchestrator is waiting for your signal.\r\n`;\r\n}\r\n\r\n/**\r\n * Parse and enrich JSON context into natural language instructions\r\n */\r\nfunction enrichJSONContext(jsonObj: any): string {\r\n const sections: string[] = [];\r\n\r\n // Extract task description\r\n if (jsonObj.task) {\r\n sections.push(`**Task:** ${jsonObj.task}`);\r\n }\r\n\r\n // Parse files - convert comma-separated string to bullet list\r\n if (jsonObj.files) {\r\n const fileList = typeof jsonObj.files === 'string'\r\n ? jsonObj.files.split(',').map(f => f.trim()).filter(f => f)\r\n : Array.isArray(jsonObj.files) ? jsonObj.files : [];\r\n\r\n if (fileList.length > 0) {\r\n sections.push('\\n**Files to process:**');\r\n fileList.forEach(file => sections.push(`- ${file}`));\r\n }\r\n }\r\n\r\n // Add requirements/deliverables\r\n if (jsonObj.requirements) {\r\n const reqs = Array.isArray(jsonObj.requirements) ? jsonObj.requirements : [jsonObj.requirements];\r\n sections.push('\\n**Requirements:**');\r\n reqs.forEach((req, i) => sections.push(`${i + 1}. ${req}`));\r\n }\r\n\r\n if (jsonObj.deliverables) {\r\n const delivs = Array.isArray(jsonObj.deliverables) ? jsonObj.deliverables : [jsonObj.deliverables];\r\n sections.push('\\n**Deliverables:**');\r\n delivs.forEach(deliv => sections.push(`- ${deliv}`));\r\n }\r\n\r\n // Add batch information\r\n if (jsonObj.batch) {\r\n sections.push(`\\n**Batch:** ${jsonObj.batch}`);\r\n }\r\n\r\n // Add directory context\r\n if (jsonObj.directory) {\r\n sections.push(`\\n**Working Directory:** ${jsonObj.directory}`);\r\n }\r\n\r\n // Add acceptance criteria\r\n if (jsonObj.acceptanceCriteria) {\r\n const criteria = Array.isArray(jsonObj.acceptanceCriteria)\r\n ? jsonObj.acceptanceCriteria\r\n : [jsonObj.acceptanceCriteria];\r\n sections.push('\\n**Acceptance Criteria:**');\r\n criteria.forEach(criterion => sections.push(`- ${criterion}`));\r\n }\r\n\r\n // Add explicit instructions if present\r\n if (jsonObj.instructions) {\r\n sections.push('\\n**Instructions:**');\r\n const instrs = Array.isArray(jsonObj.instructions) ? jsonObj.instructions : [jsonObj.instructions];\r\n instrs.forEach((instr, i) => sections.push(`${i + 1}. ${instr}`));\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Build task description from context\r\n */\r\nfunction buildTaskDescription(agentType: string, context: TaskContext): string {\r\n let desc = '';\r\n\r\n if (context.context) {\r\n // Try to parse as JSON first\r\n let contextStr = context.context.trim();\r\n\r\n // Check if context looks like JSON\r\n if ((contextStr.startsWith('{') && contextStr.endsWith('}')) ||\r\n (contextStr.startsWith('[') && contextStr.endsWith(']'))) {\r\n try {\r\n const jsonObj = JSON.parse(contextStr);\r\n desc = enrichJSONContext(jsonObj);\r\n\r\n // Add instruction footer for structured tasks\r\n if (jsonObj.files || jsonObj.deliverables) {\r\n desc += '\\n\\n**Process each item systematically and report confidence when complete.**';\r\n }\r\n } catch (e) {\r\n // Not valid JSON, treat as plain text\r\n desc = context.context;\r\n }\r\n } else {\r\n // Plain text context\r\n desc = context.context;\r\n }\r\n } else {\r\n desc = `Execute task as ${agentType} agent`;\r\n }\r\n\r\n // Add metadata fields\r\n if (context.taskId) {\r\n desc += `\\n\\n**Task ID:** ${context.taskId}`;\r\n }\r\n\r\n if (context.iteration) {\r\n desc += `\\n**Iteration:** ${context.iteration}`;\r\n }\r\n\r\n if (context.mode) {\r\n desc += `\\n**Mode:** ${context.mode}`;\r\n }\r\n\r\n if (context.priority) {\r\n desc += `\\n**Priority:** ${context.priority}`;\r\n }\r\n\r\n if (context.parentTaskId) {\r\n desc += `\\n**Parent Task:** ${context.parentTaskId}`;\r\n }\r\n\r\n return desc;\r\n}\r\n\r\n/**\r\n * Build environment context section\r\n */\r\nfunction buildEnvironmentContext(context: TaskContext): string {\r\n const env: string[] = [];\r\n\r\n if (context.taskId) env.push(`TASK_ID=${context.taskId}`);\r\n if (context.iteration) env.push(`ITERATION=${context.iteration}`);\r\n if (context.mode) env.push(`MODE=${context.mode}`);\r\n if (context.priority) env.push(`PRIORITY=${context.priority}`);\r\n if (context.parentTaskId) env.push(`PARENT_TASK_ID=${context.parentTaskId}`);\r\n\r\n // Docker workspace detection\r\n const isDockerEnv = process.env.DOCKER_AGENT === 'true' || process.env.WORKSPACE_ROOT;\r\n const workspaceRoot = process.env.WORKSPACE_ROOT || '/workspace';\r\n\r\n if (isDockerEnv) {\r\n env.push(`WORKSPACE_ROOT=${workspaceRoot}`);\r\n }\r\n\r\n // Always include Docker context if detected, even if env array is empty\r\n if (isDockerEnv && env.length === 0) {\r\n env.push(`WORKSPACE_ROOT=${workspaceRoot}`);\r\n }\r\n\r\n if (env.length === 0 && !isDockerEnv) return '';\r\n\r\n let contextText = `\r\n## Environment Variables\r\n\r\n\\`\\`\\`bash\r\n${env.join('\\n')}\r\n\\`\\`\\`\r\n`;\r\n\r\n // Add Docker workspace notice if detected\r\n if (isDockerEnv) {\r\n contextText += `\r\n\r\n## Docker Container Environment\r\n\r\n**CRITICAL:** You are running inside a Docker container.\r\n\r\n- **Working Directory:** \\`${workspaceRoot}\\`\r\n- **File Paths:** All file operations use \\`${workspaceRoot}/\\` prefix\r\n- **Example:** To read \\`src/file.ts\\`, use \\`${workspaceRoot}/src/file.ts\\`\r\n\r\n**DO NOT** use paths from your training data or Main Chat context. Use \\`${workspaceRoot}/\\` for all file operations.\r\n`;\r\n }\r\n\r\n return contextText;\r\n}\r\n\r\n/**\r\n * Load skills for agent (Phase 5: Skills Database Integration)\r\n */\r\nasync function loadSkillsForAgent(\r\n agentType: string,\r\n context: TaskContext\r\n): Promise<Skill[]> {\r\n // Feature flag check\r\n if (process.env.CFN_SKILLS_DATABASE !== 'true') {\r\n return [];\r\n }\r\n\r\n try {\r\n const dbPath = process.env.CFN_SKILLS_DB_PATH || './.claude/skills-database/skills.db';\r\n const skillLoader = new SkillLoader(dbPath, {\r\n enableCache: true,\r\n cacheMaxSize: 100,\r\n cacheTTL: 60000 // 1 minute\r\n });\r\n\r\n // Extract keywords from context for filtering\r\n const keywords = context.keywords || context.context?.toLowerCase() || '';\r\n\r\n const skills = await skillLoader.loadSkillsForAgent(agentType, {\r\n taskId: context.taskId,\r\n keywords,\r\n phase: context.phase,\r\n mode: context.mode,\r\n iteration: context.iteration\r\n });\r\n\r\n skillLoader.close();\r\n return skills;\r\n } catch (error) {\r\n console.warn(`[agent-prompt-builder] Failed to load skills: ${error}`);\r\n return [];\r\n }\r\n}\r\n\r\n/**\r\n * Format skills for prompt injection\r\n */\r\nfunction formatSkillsForPrompt(skills: Skill[]): string {\r\n if (skills.length === 0) {\r\n return '';\r\n }\r\n\r\n const sections: string[] = [];\r\n\r\n sections.push('## Applicable Skills');\r\n sections.push('');\r\n sections.push('The following skills have been loaded based on your agent type and task context:');\r\n sections.push('');\r\n\r\n for (const skill of skills) {\r\n const approvalBadge = skill.approvalLevel === 'auto' ? '✓' :\r\n skill.approvalLevel === 'escalate' ? '⚠' : '✋';\r\n sections.push(`### ${skill.name} (v${skill.version}) [${approvalBadge} ${skill.approvalLevel}]`);\r\n sections.push('');\r\n if (skill.content) {\r\n sections.push(skill.content);\r\n } else {\r\n sections.push(`*Skill content not available*`);\r\n }\r\n sections.push('');\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Build complete prompt for agent execution (async for iteration history + skills)\r\n */\r\nexport async function buildAgentPrompt(\r\n definition: AgentDefinition,\r\n context: TaskContext\r\n): Promise<string> {\r\n // Use explicit agent ID if provided, otherwise generate from name + iteration\r\n const agentId = context.agentId || `${definition.name}-${context.iteration || 1}`;\r\n const startTime = Date.now();\r\n\r\n const sections: string[] = [];\r\n\r\n // 1. Agent definition header\r\n sections.push(`# Agent: ${definition.name}`);\r\n sections.push('');\r\n sections.push(definition.description);\r\n sections.push('');\r\n\r\n // 2. Task description\r\n sections.push('## Task');\r\n sections.push('');\r\n sections.push(buildTaskDescription(definition.name, context));\r\n sections.push('');\r\n\r\n // 3. Iteration history (Sprint 3 - Phase 2)\r\n // Load and format previous iterations if iteration > 1\r\n if (context.taskId && context.iteration && context.iteration > 1) {\r\n try {\r\n const history = await loadIterationHistory(context.taskId, agentId, context.iteration);\r\n const historyText = formatIterationHistory(history, context.iteration);\r\n sections.push(historyText);\r\n sections.push('');\r\n } catch (err) {\r\n console.warn(`[agent-prompt-builder] Failed to load iteration history:`, err);\r\n // Continue without history\r\n }\r\n }\r\n\r\n // 4. Agent definition content (from markdown file)\r\n sections.push('## Agent Definition');\r\n sections.push('');\r\n sections.push(definition.content);\r\n sections.push('');\r\n\r\n // 4a. Load and inject skills (Phase 5: Skills Database Integration)\r\n try {\r\n const skills = await loadSkillsForAgent(definition.type || definition.name, context);\r\n\r\n if (skills.length > 0) {\r\n const skillsText = formatSkillsForPrompt(skills);\r\n sections.push(skillsText);\r\n sections.push('');\r\n\r\n // Log skill usage for analytics (Phase 5)\r\n if (process.env.CFN_SKILLS_DATABASE === 'true' && context.taskId) {\r\n try {\r\n const dbPath = process.env.CFN_SKILLS_DB_PATH || './.claude/skills-database/skills.db';\r\n const skillLoader = new SkillLoader(dbPath);\r\n\r\n await skillLoader.logSkillUsage({\r\n agentId: agentId,\r\n agentType: definition.type || definition.name,\r\n skillIds: skills.map(s => s.id).filter(id => id > 0), // Exclude bootstrap skills (negative IDs)\r\n taskId: context.taskId,\r\n phase: context.phase,\r\n loadedAt: new Date(),\r\n executionTimeMs: Date.now() - startTime\r\n });\r\n\r\n skillLoader.close();\r\n } catch (logError) {\r\n console.warn(`[agent-prompt-builder] Failed to log skill usage: ${logError}`);\r\n }\r\n }\r\n }\r\n } catch (skillError) {\r\n console.warn(`[agent-prompt-builder] Skill loading failed: ${skillError}`);\r\n // Continue without skills\r\n }\r\n\r\n // 5. CFN Loop protocol (ALWAYS inject when taskId present - enables Redis coordination)\r\n if (context.taskId && agentId) {\r\n sections.push(buildCFNLoopProtocol(context.taskId, agentId));\r\n sections.push('');\r\n }\r\n\r\n // 6. Environment context\r\n const envContext = buildEnvironmentContext(context);\r\n if (envContext) {\r\n sections.push(envContext);\r\n sections.push('');\r\n }\r\n\r\n // 7. Execution instructions\r\n sections.push('## Execution Instructions');\r\n sections.push('');\r\n sections.push('1. Read and understand the task requirements');\r\n if (context.iteration && context.iteration > 1) {\r\n sections.push('2. Review iteration history and feedback from validators');\r\n sections.push('3. Address specific feedback points from previous iteration');\r\n sections.push('4. Execute your core responsibilities as defined above');\r\n } else {\r\n sections.push('2. Execute your core responsibilities as defined above');\r\n sections.push('3. Follow any protocol steps (CFN Loop, validation hooks, etc.)');\r\n }\r\n sections.push('4. Provide clear, concise output');\r\n sections.push('5. Report confidence score if applicable');\r\n sections.push('');\r\n\r\n // 7a. Pre-edit backup requirement (MANDATORY)\r\n sections.push('## Pre-Edit Backup Protocol (MANDATORY)');\r\n sections.push('');\r\n sections.push('**BEFORE ANY Edit/Write/MultiEdit operation, you MUST create a backup:**');\r\n sections.push('');\r\n sections.push('```bash');\r\n sections.push(`BACKUP_PATH=$(./.claude/hooks/cfn-invoke-pre-edit.sh \"$FILE_TO_EDIT\" --agent-id \"${agentId}\")`);\r\n sections.push('```');\r\n sections.push('');\r\n sections.push('**Why:** Enables safe file revert without git operations during parallel sessions.');\r\n sections.push('**Location:** `.backups/[agent-id]/[timestamp]_[hash]/`');\r\n sections.push('**Retention:** 24h TTL (configurable)');\r\n sections.push('');\r\n sections.push('**Complete Edit Workflow:**');\r\n sections.push('```bash');\r\n sections.push('# 1. Pre-Edit: Create backup');\r\n sections.push(`BACKUP_PATH=$(./.claude/hooks/cfn-invoke-pre-edit.sh \"src/file.ts\" --agent-id \"${agentId}\")`);\r\n sections.push('');\r\n sections.push('# 2. Edit: Perform file modification');\r\n sections.push('Edit: file_path=\"src/file.ts\" old_string=\"...\" new_string=\"...\"');\r\n sections.push('');\r\n sections.push('# 3. Post-Edit: Validate changes');\r\n sections.push(`./.claude/hooks/cfn-invoke-post-edit.sh \"src/file.ts\" --agent-id \"${agentId}\"`);\r\n sections.push('```');\r\n sections.push('');\r\n\r\n // 8. Tool reminder\r\n if (definition.tools && definition.tools.length > 0) {\r\n sections.push('## Available Tools');\r\n sections.push('');\r\n sections.push(`You have access to: ${definition.tools.join(', ')}`);\r\n sections.push('');\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Extract agent ID from context\r\n * If agentId is explicitly provided in context, use it; otherwise generate from name + iteration\r\n */\r\nexport function getAgentId(definition: AgentDefinition, context: TaskContext): string {\r\n if (context.agentId) {\r\n return context.agentId;\r\n }\r\n return `${definition.name}-${context.iteration || 1}`;\r\n}\r\n\r\n/**\r\n * Build system prompt for agent (optional, for structured agent behavior)\r\n */\r\nexport function buildSystemPrompt(definition: AgentDefinition): string {\r\n return `You are ${definition.name}, a specialized AI agent.\r\n\r\nType: ${definition.type || 'specialist'}\r\nModel: ${definition.model}\r\nTools: ${definition.tools.join(', ')}\r\n\r\nFollow your agent definition exactly and complete assigned tasks with high quality.`;\r\n}\r\n"],"names":["loadIterationHistory","formatIterationHistory","SkillLoader","buildCFNLoopProtocol","taskId","agentId","enrichJSONContext","jsonObj","sections","task","push","files","fileList","split","map","f","trim","filter","Array","isArray","length","forEach","file","requirements","reqs","req","i","deliverables","delivs","deliv","batch","directory","acceptanceCriteria","criteria","criterion","instructions","instrs","instr","join","buildTaskDescription","agentType","context","desc","contextStr","startsWith","endsWith","JSON","parse","e","iteration","mode","priority","parentTaskId","buildEnvironmentContext","env","isDockerEnv","process","DOCKER_AGENT","WORKSPACE_ROOT","workspaceRoot","contextText","loadSkillsForAgent","CFN_SKILLS_DATABASE","dbPath","CFN_SKILLS_DB_PATH","skillLoader","enableCache","cacheMaxSize","cacheTTL","keywords","toLowerCase","skills","phase","close","error","console","warn","formatSkillsForPrompt","skill","approvalBadge","approvalLevel","name","version","content","buildAgentPrompt","definition","startTime","Date","now","description","history","historyText","err","type","skillsText","logSkillUsage","skillIds","s","id","loadedAt","executionTimeMs","logError","skillError","envContext","tools","getAgentId","buildSystemPrompt","model"],"mappings":"AAAA;;;;;;;;;;CAUC,GAGD,SAASA,oBAAoB,EAAEC,sBAAsB,QAAQ,yBAAyB;AACtF,SAASC,WAAW,QAAe,oBAAoB;AAcvD;;CAEC,GACD,SAASC,qBAAqBC,MAAc,EAAEC,OAAe;IAC3D,OAAO,CAAC;;;;;;;;;;;;;;;;;;aAkBG,EAAED,OAAO;cACR,EAAEC,QAAQ;;;;;;iCAMS,EAAED,OAAO,CAAC,EAAEC,QAAQ;+BACtB,EAAED,OAAO,CAAC,EAAEC,QAAQ;iCAClB,EAAED,OAAO,CAAC,EAAEC,QAAQ;;;;;;;;;;;;;WAa1C,EAAED,OAAO;YAC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GC,GACD,OAAO,SAASmE,WAAWpB,UAA2B,EAAE5C,OAAoB;IAC1E,IAAIA,QAAQpC,OAAO,EAAE;QACnB,OAAOoC,QAAQpC,OAAO;IACxB;IACA,OAAO,GAAGgF,WAAWJ,IAAI,CAAC,CAAC,EAAExC,QAAQQ,SAAS,IAAI,GAAG;AACvD;AAEA;;CAEC,GACD,OAAO,SAASyD,kBAAkBrB,UAA2B;IAC3D,OAAO,CAAC,QAAQ,EAAEA,WAAWJ,IAAI,CAAC;;MAE9B,EAAEI,WAAWQ,IAAI,IAAI,aAAa;OACjC,EAAER,WAAWsB,KAAK,CAAC;OACnB,EAAEtB,WAAWmB,KAAK,CAAClE,IAAI,CAAC,MAAM;;mFAE8C,CAAC;AACpF"}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/agent-prompt-builder.ts"],"sourcesContent":["/**\r\n * Agent Prompt Builder\r\n *\r\n * Builds comprehensive prompts for CLI-spawned agents by combining:\r\n * - Agent definition (YAML + markdown)\r\n * - Task context (taskId, iteration, mode)\r\n * - CFN Loop protocol (if applicable)\r\n * - Iteration history (Sprint 3 - Phase 2)\r\n * - Environment variables\r\n * - Skills (Phase 5 - Skills Database integration)\r\n */\r\n\r\nimport { AgentDefinition, hasCFNLoopProtocol } from './agent-definition-parser.js';\r\nimport { loadIterationHistory, formatIterationHistory } from './iteration-history.js';\r\nimport { SkillLoader, Skill } from './skill-loader.js';\r\n\r\nexport interface TaskContext {\r\n taskId?: string;\r\n iteration?: number;\r\n context?: string;\r\n mode?: string;\r\n priority?: number;\r\n parentTaskId?: string;\r\n agentId?: string;\r\n keywords?: string; // Phase 5: For skill filtering\r\n phase?: string; // Phase 5: CFN Loop phase (loop1, loop2, loop3)\r\n}\r\n\r\n/**\r\n * Build CLI Mode Redis Completion Protocol for CLI Mode\r\n */\r\nfunction buildCLIModeProtocol(taskId: string, agentId: string): string {\r\n return `\r\n## CLI Mode Redis Completion Protocol\r\n\r\nYou are running in CLI Mode with Main Chat coordination. Follow this protocol EXACTLY:\r\n\r\n### Step 1: Complete Your Work\r\nExecute your assigned task (implementation, review, testing, etc.)\r\n\r\n### Step 2: Signal Completion to Main Chat\r\nSend a Redis signal to notify Main Chat that you're finished:\r\n\r\n\\`\\`\\`bash\r\n# Use Node.js for Redis communication\r\nnode -e \"\r\nconst { createClient } = require('redis');\r\nconst signal = {\r\n agentId: '${agentId}',\r\n taskId: '${taskId}',\r\n status: 'completed',\r\n timestamp: new Date().toISOString(),\r\n provider: process.env.PROVIDER || 'unknown',\r\n model: process.env.MODEL || 'unknown',\r\n confidence: 0.90, // Replace with your actual confidence\r\n metadata: {\r\n iteration: process.env.ITERATION || 1,\r\n mode: process.env.MODE || 'standard'\r\n }\r\n};\r\n\r\n(async () => {\r\n const client = createClient({ url: 'redis://localhost:6379' });\r\n await client.connect();\r\n\r\n const signalKey = \\`cfn:mainchat:signal:\\${process.env.TASK_ID}\\`;\r\n await client.lPush(signalKey, JSON.stringify(signal));\r\n\r\n console.log(\\`✅ Completion signal sent to Main Chat via Redis\\`);\r\n await client.disconnect();\r\n})();\r\n\"\r\n\\`\\`\\`\r\n\r\n### Step 3: Exit Cleanly\r\nAfter sending the signal, exit immediately. Main Chat is waiting for your Redis signal.\r\n\r\n**Why This Protocol:**\r\n- Main Chat uses Redis BLPOP to wait for your completion signal\r\n- Enables simple 2-layer coordination (Main Chat → CLI agents)\r\n- No complex orchestrator needed for CLI mode\r\n- Supports different AI providers via environment variables\r\n\r\n**Environment Variables Available:**\r\n- TASK_ID: ${taskId}\r\n- AGENT_ID: ${agentId}\r\n- PROVIDER: AI provider (zai, kimi, anthropic, etc.)\r\n- MODEL: Specific model being used\r\n- ITERATION: Current iteration number\r\n- MODE: Execution mode (mvp, standard, enterprise)\r\n\r\n**Main Chat Workflow:**\r\n1. Spawns you via CLI with specific provider/model\r\n2. Waits via \\`redis-cli BLPOP cfn:mainchat:signal:${taskId}\\`\r\n3. Processes your completion signal when received\r\n4. Continues with next task or spawns additional agents\r\n\r\n**CRITICAL:** Send Redis signal before exiting. Main Chat cannot proceed without your completion signal.\r\n`;\r\n}\r\n\r\n/**\r\n * Parse shell variable format into JSON object\r\n * Example: \"WORKSPACE='/tmp/test' MODE='standard'\" -> {WORKSPACE: '/tmp/test', MODE: 'standard'}\r\n */\r\nfunction parseShellVariables(shellContext: string): any {\r\n const jsonObj: any = {};\r\n const regex = /([A-Z_]+)='([^']*)'/g;\r\n let match;\r\n while ((match = regex.exec(shellContext)) !== null) {\r\n jsonObj[match[1]] = match[2];\r\n }\r\n return jsonObj;\r\n}\r\n\r\n/**\r\n * Parse and enrich JSON context into natural language instructions\r\n */\r\nfunction enrichJSONContext(jsonObj: any): string {\r\n const sections: string[] = [];\r\n\r\n // Extract task description (support both 'task' and 'taskDescription' keys)\r\n const taskText = jsonObj.task || jsonObj.taskDescription;\r\n if (taskText) {\r\n sections.push(`**Task:** ${taskText}`);\r\n }\r\n\r\n // Parse files - convert comma-separated string to bullet list\r\n if (jsonObj.files) {\r\n const fileList = typeof jsonObj.files === 'string'\r\n ? jsonObj.files.split(',').map(f => f.trim()).filter(f => f)\r\n : Array.isArray(jsonObj.files) ? jsonObj.files : [];\r\n\r\n if (fileList.length > 0) {\r\n sections.push('\\n**Files to process:**');\r\n fileList.forEach(file => sections.push(`- ${file}`));\r\n }\r\n }\r\n\r\n // Add requirements/deliverables\r\n if (jsonObj.requirements) {\r\n const reqs = Array.isArray(jsonObj.requirements) ? jsonObj.requirements : [jsonObj.requirements];\r\n sections.push('\\n**Requirements:**');\r\n reqs.forEach((req, i) => sections.push(`${i + 1}. ${req}`));\r\n }\r\n\r\n if (jsonObj.deliverables) {\r\n const delivs = Array.isArray(jsonObj.deliverables) ? jsonObj.deliverables : [jsonObj.deliverables];\r\n sections.push('\\n**Deliverables:**');\r\n delivs.forEach(deliv => sections.push(`- ${deliv}`));\r\n }\r\n\r\n // Add batch information\r\n if (jsonObj.batch) {\r\n sections.push(`\\n**Batch:** ${jsonObj.batch}`);\r\n }\r\n\r\n // Add directory context - support 'directory', 'WORKSPACE', and 'workspace' keys\r\n const workspacePath = jsonObj.directory || jsonObj.WORKSPACE || jsonObj.workspace;\r\n if (workspacePath) {\r\n sections.push(`\\n**Working Directory:** ${workspacePath}`);\r\n }\r\n\r\n // Add acceptance criteria\r\n if (jsonObj.acceptanceCriteria) {\r\n const criteria = Array.isArray(jsonObj.acceptanceCriteria)\r\n ? jsonObj.acceptanceCriteria\r\n : [jsonObj.acceptanceCriteria];\r\n sections.push('\\n**Acceptance Criteria:**');\r\n criteria.forEach(criterion => sections.push(`- ${criterion}`));\r\n }\r\n\r\n // Add explicit instructions if present\r\n if (jsonObj.instructions) {\r\n sections.push('\\n**Instructions:**');\r\n const instrs = Array.isArray(jsonObj.instructions) ? jsonObj.instructions : [jsonObj.instructions];\r\n instrs.forEach((instr, i) => sections.push(`${i + 1}. ${instr}`));\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Build task description from context\r\n */\r\nfunction buildTaskDescription(agentType: string, context: TaskContext): string {\r\n let desc = '';\r\n\r\n if (context.context) {\r\n // Try to parse context in multiple formats\r\n let contextStr = context.context.trim();\r\n\r\n // Parse shell variables BEFORE attempting JSON parse\r\n if (contextStr.includes('=') && !contextStr.startsWith('{')) {\r\n const jsonObj = parseShellVariables(contextStr);\r\n desc = enrichJSONContext(jsonObj);\r\n\r\n // Add instruction footer for structured tasks\r\n if (jsonObj.files || jsonObj.deliverables) {\r\n desc += '\\n\\n**Process each item systematically and report confidence when complete.**';\r\n }\r\n }\r\n // Check if context looks like JSON\r\n else if ((contextStr.startsWith('{') && contextStr.endsWith('}')) ||\r\n (contextStr.startsWith('[') && contextStr.endsWith(']'))) {\r\n try {\r\n const jsonObj = JSON.parse(contextStr);\r\n desc = enrichJSONContext(jsonObj);\r\n\r\n // Add instruction footer for structured tasks\r\n if (jsonObj.files || jsonObj.deliverables) {\r\n desc += '\\n\\n**Process each item systematically and report confidence when complete.**';\r\n }\r\n } catch (e) {\r\n // Not valid JSON, treat as plain text\r\n desc = context.context;\r\n }\r\n } else {\r\n // Plain text context\r\n desc = context.context;\r\n }\r\n } else {\r\n desc = `Execute task as ${agentType} agent`;\r\n }\r\n\r\n // Add metadata fields\r\n if (context.taskId) {\r\n desc += `\\n\\n**Task ID:** ${context.taskId}`;\r\n }\r\n\r\n if (context.iteration) {\r\n desc += `\\n**Iteration:** ${context.iteration}`;\r\n }\r\n\r\n if (context.mode) {\r\n desc += `\\n**Mode:** ${context.mode}`;\r\n }\r\n\r\n if (context.priority) {\r\n desc += `\\n**Priority:** ${context.priority}`;\r\n }\r\n\r\n if (context.parentTaskId) {\r\n desc += `\\n**Parent Task:** ${context.parentTaskId}`;\r\n }\r\n\r\n return desc;\r\n}\r\n\r\n/**\r\n * Build environment context section\r\n */\r\nfunction buildEnvironmentContext(context: TaskContext): string {\r\n const env: string[] = [];\r\n\r\n if (context.taskId) env.push(`TASK_ID=${context.taskId}`);\r\n if (context.iteration) env.push(`ITERATION=${context.iteration}`);\r\n if (context.mode) env.push(`MODE=${context.mode}`);\r\n if (context.priority) env.push(`PRIORITY=${context.priority}`);\r\n if (context.parentTaskId) env.push(`PARENT_TASK_ID=${context.parentTaskId}`);\r\n\r\n // Docker workspace detection\r\n const isDockerEnv = process.env.DOCKER_AGENT === 'true' || process.env.WORKSPACE_ROOT;\r\n const workspaceRoot = process.env.WORKSPACE_ROOT || '/workspace';\r\n\r\n if (isDockerEnv) {\r\n env.push(`WORKSPACE_ROOT=${workspaceRoot}`);\r\n }\r\n\r\n // Always include Docker context if detected, even if env array is empty\r\n if (isDockerEnv && env.length === 0) {\r\n env.push(`WORKSPACE_ROOT=${workspaceRoot}`);\r\n }\r\n\r\n if (env.length === 0 && !isDockerEnv) return '';\r\n\r\n let contextText = `\r\n## Environment Variables\r\n\r\n\\`\\`\\`bash\r\n${env.join('\\n')}\r\n\\`\\`\\`\r\n`;\r\n\r\n // Add Docker workspace notice if detected\r\n if (isDockerEnv) {\r\n contextText += `\r\n\r\n## Docker Container Environment\r\n\r\n**CRITICAL:** You are running inside a Docker container.\r\n\r\n- **Working Directory:** \\`${workspaceRoot}\\`\r\n- **File Paths:** All file operations use \\`${workspaceRoot}/\\` prefix\r\n- **Example:** To read \\`src/file.ts\\`, use \\`${workspaceRoot}/src/file.ts\\`\r\n\r\n**DO NOT** use paths from your training data or Main Chat context. Use \\`${workspaceRoot}/\\` for all file operations.\r\n`;\r\n }\r\n\r\n return contextText;\r\n}\r\n\r\n/**\r\n * Load skills for agent (Phase 5: Skills Database Integration)\r\n */\r\nasync function loadSkillsForAgent(\r\n agentType: string,\r\n context: TaskContext\r\n): Promise<Skill[]> {\r\n // Feature flag check\r\n if (process.env.CFN_SKILLS_DATABASE !== 'true') {\r\n return [];\r\n }\r\n\r\n try {\r\n const dbPath = process.env.CFN_SKILLS_DB_PATH || './.claude/skills-database/skills.db';\r\n const skillLoader = new SkillLoader(dbPath, {\r\n enableCache: true,\r\n cacheMaxSize: 100,\r\n cacheTTL: 60000 // 1 minute\r\n });\r\n\r\n // Extract keywords from context for filtering\r\n const keywords = context.keywords || context.context?.toLowerCase() || '';\r\n\r\n const skills = await skillLoader.loadSkillsForAgent(agentType, {\r\n taskId: context.taskId,\r\n keywords,\r\n phase: context.phase,\r\n mode: context.mode,\r\n iteration: context.iteration\r\n });\r\n\r\n skillLoader.close();\r\n return skills;\r\n } catch (error) {\r\n console.warn(`[agent-prompt-builder] Failed to load skills: ${error}`);\r\n return [];\r\n }\r\n}\r\n\r\n/**\r\n * Format skills for prompt injection\r\n */\r\nfunction formatSkillsForPrompt(skills: Skill[]): string {\r\n if (skills.length === 0) {\r\n return '';\r\n }\r\n\r\n const sections: string[] = [];\r\n\r\n sections.push('## Applicable Skills');\r\n sections.push('');\r\n sections.push('The following skills have been loaded based on your agent type and task context:');\r\n sections.push('');\r\n\r\n for (const skill of skills) {\r\n const approvalBadge = skill.approvalLevel === 'auto' ? '✓' :\r\n skill.approvalLevel === 'escalate' ? '⚠' : '✋';\r\n sections.push(`### ${skill.name} (v${skill.version}) [${approvalBadge} ${skill.approvalLevel}]`);\r\n sections.push('');\r\n if (skill.content) {\r\n sections.push(skill.content);\r\n } else {\r\n sections.push(`*Skill content not available*`);\r\n }\r\n sections.push('');\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Build complete prompt for agent execution (async for iteration history + skills)\r\n */\r\nexport async function buildAgentPrompt(\r\n definition: AgentDefinition,\r\n context: TaskContext\r\n): Promise<string> {\r\n // Use explicit agent ID if provided, otherwise generate from name + iteration\r\n const agentId = context.agentId || `${definition.name}-${context.iteration || 1}`;\r\n const startTime = Date.now();\r\n\r\n const sections: string[] = [];\r\n\r\n // 1. Agent definition header\r\n sections.push(`# Agent: ${definition.name}`);\r\n sections.push('');\r\n sections.push(definition.description);\r\n sections.push('');\r\n\r\n // 2. Task description\r\n sections.push('## Task');\r\n sections.push('');\r\n sections.push(buildTaskDescription(definition.name, context));\r\n sections.push('');\r\n\r\n // 3. Iteration history (Sprint 3 - Phase 2)\r\n // Load and format previous iterations if iteration > 1\r\n if (context.taskId && context.iteration && context.iteration > 1) {\r\n try {\r\n const history = await loadIterationHistory(context.taskId, agentId, context.iteration);\r\n const historyText = formatIterationHistory(history, context.iteration);\r\n sections.push(historyText);\r\n sections.push('');\r\n } catch (err) {\r\n console.warn(`[agent-prompt-builder] Failed to load iteration history:`, err);\r\n // Continue without history\r\n }\r\n }\r\n\r\n // 4. Agent definition content (from markdown file)\r\n sections.push('## Agent Definition');\r\n sections.push('');\r\n sections.push(definition.content);\r\n sections.push('');\r\n\r\n // 4a. Load and inject skills (Phase 5: Skills Database Integration)\r\n try {\r\n const skills = await loadSkillsForAgent(definition.type || definition.name, context);\r\n\r\n if (skills.length > 0) {\r\n const skillsText = formatSkillsForPrompt(skills);\r\n sections.push(skillsText);\r\n sections.push('');\r\n\r\n // Log skill usage for analytics (Phase 5)\r\n if (process.env.CFN_SKILLS_DATABASE === 'true' && context.taskId) {\r\n try {\r\n const dbPath = process.env.CFN_SKILLS_DB_PATH || './.claude/skills-database/skills.db';\r\n const skillLoader = new SkillLoader(dbPath);\r\n\r\n await skillLoader.logSkillUsage({\r\n agentId: agentId,\r\n agentType: definition.type || definition.name,\r\n skillIds: skills.map(s => s.id).filter(id => id > 0), // Exclude bootstrap skills (negative IDs)\r\n taskId: context.taskId,\r\n phase: context.phase,\r\n loadedAt: new Date(),\r\n executionTimeMs: Date.now() - startTime\r\n });\r\n\r\n skillLoader.close();\r\n } catch (logError) {\r\n console.warn(`[agent-prompt-builder] Failed to log skill usage: ${logError}`);\r\n }\r\n }\r\n }\r\n } catch (skillError) {\r\n console.warn(`[agent-prompt-builder] Skill loading failed: ${skillError}`);\r\n // Continue without skills\r\n }\r\n\r\n // 5. CLI Mode protocol (ALWAYS inject when taskId present - enables Redis coordination)\r\n if (context.taskId && agentId) {\r\n sections.push(buildCLIModeProtocol(context.taskId, agentId));\r\n sections.push('');\r\n }\r\n\r\n // 6. Environment context\r\n const envContext = buildEnvironmentContext(context);\r\n if (envContext) {\r\n sections.push(envContext);\r\n sections.push('');\r\n }\r\n\r\n // 7. Execution instructions\r\n sections.push('## Execution Instructions');\r\n sections.push('');\r\n sections.push('1. Read and understand the task requirements');\r\n if (context.iteration && context.iteration > 1) {\r\n sections.push('2. Review iteration history and feedback from validators');\r\n sections.push('3. Address specific feedback points from previous iteration');\r\n sections.push('4. Execute your core responsibilities as defined above');\r\n } else {\r\n sections.push('2. Execute your core responsibilities as defined above');\r\n sections.push('3. Follow any protocol steps (CFN Loop, validation hooks, etc.)');\r\n }\r\n sections.push('4. Provide clear, concise output');\r\n sections.push('5. Report confidence score if applicable');\r\n sections.push('');\r\n\r\n // 7a. Pre-edit backup requirement (MANDATORY)\r\n sections.push('## Pre-Edit Backup Protocol (MANDATORY)');\r\n sections.push('');\r\n sections.push('**BEFORE ANY Edit/Write/MultiEdit operation, you MUST create a backup:**');\r\n sections.push('');\r\n sections.push('```bash');\r\n sections.push(`BACKUP_PATH=$(./.claude/hooks/cfn-invoke-pre-edit.sh \"$FILE_TO_EDIT\" --agent-id \"${agentId}\")`);\r\n sections.push('```');\r\n sections.push('');\r\n sections.push('**Why:** Enables safe file revert without git operations during parallel sessions.');\r\n sections.push('**Location:** `.backups/[agent-id]/[timestamp]_[hash]/`');\r\n sections.push('**Retention:** 24h TTL (configurable)');\r\n sections.push('');\r\n sections.push('**Complete Edit Workflow:**');\r\n sections.push('```bash');\r\n sections.push('# 1. Pre-Edit: Create backup');\r\n sections.push(`BACKUP_PATH=$(./.claude/hooks/cfn-invoke-pre-edit.sh \"src/file.ts\" --agent-id \"${agentId}\")`);\r\n sections.push('');\r\n sections.push('# 2. Edit: Perform file modification');\r\n sections.push('Edit: file_path=\"src/file.ts\" old_string=\"...\" new_string=\"...\"');\r\n sections.push('');\r\n sections.push('# 3. Post-Edit: Validate changes');\r\n sections.push(`./.claude/hooks/cfn-invoke-post-edit.sh \"src/file.ts\" --agent-id \"${agentId}\"`);\r\n sections.push('```');\r\n sections.push('');\r\n\r\n // 8. Tool reminder\r\n if (definition.tools && definition.tools.length > 0) {\r\n sections.push('## Available Tools');\r\n sections.push('');\r\n sections.push(`You have access to: ${definition.tools.join(', ')}`);\r\n sections.push('');\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Extract agent ID from context\r\n * If agentId is explicitly provided in context, use it; otherwise generate from name + iteration\r\n */\r\nexport function getAgentId(definition: AgentDefinition, context: TaskContext): string {\r\n if (context.agentId) {\r\n return context.agentId;\r\n }\r\n return `${definition.name}-${context.iteration || 1}`;\r\n}\r\n\r\n/**\r\n * Build system prompt for agent (optional, for structured agent behavior)\r\n */\r\nexport function buildSystemPrompt(definition: AgentDefinition): string {\r\n return `You are ${definition.name}, a specialized AI agent.\r\n\r\nType: ${definition.type || 'specialist'}\r\nModel: ${definition.model}\r\nTools: ${definition.tools.join(', ')}\r\n\r\nFollow your agent definition exactly and complete assigned tasks with high quality.`;\r\n}\r\n"],"names":["loadIterationHistory","formatIterationHistory","SkillLoader","buildCLIModeProtocol","taskId","agentId","parseShellVariables","shellContext","jsonObj","regex","match","exec","enrichJSONContext","sections","taskText","task","taskDescription","push","files","fileList","split","map","f","trim","filter","Array","isArray","length","forEach","file","requirements","reqs","req","i","deliverables","delivs","deliv","batch","workspacePath","directory","WORKSPACE","workspace","acceptanceCriteria","criteria","criterion","instructions","instrs","instr","join","buildTaskDescription","agentType","context","desc","contextStr","includes","startsWith","endsWith","JSON","parse","e","iteration","mode","priority","parentTaskId","buildEnvironmentContext","env","isDockerEnv","process","DOCKER_AGENT","WORKSPACE_ROOT","workspaceRoot","contextText","loadSkillsForAgent","CFN_SKILLS_DATABASE","dbPath","CFN_SKILLS_DB_PATH","skillLoader","enableCache","cacheMaxSize","cacheTTL","keywords","toLowerCase","skills","phase","close","error","console","warn","formatSkillsForPrompt","skill","approvalBadge","approvalLevel","name","version","content","buildAgentPrompt","definition","startTime","Date","now","description","history","historyText","err","type","skillsText","logSkillUsage","skillIds","s","id","loadedAt","executionTimeMs","logError","skillError","envContext","tools","getAgentId","buildSystemPrompt","model"],"mappings":"AAAA;;;;;;;;;;CAUC,GAGD,SAASA,oBAAoB,EAAEC,sBAAsB,QAAQ,yBAAyB;AACtF,SAASC,WAAW,QAAe,oBAAoB;AAcvD;;CAEC,GACD,SAASC,qBAAqBC,MAAc,EAAEC,OAAe;IAC3D,OAAO,CAAC;;;;;;;;;;;;;;;;YAgBE,EAAEA,QAAQ;WACX,EAAED,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAmCT,EAAEA,OAAO;YACR,EAAEC,QAAQ;;;;;;;;mDAQ6B,EAAED,OAAO;;;;;AAK5D,CAAC;AACD;AAEA;;;CAGC,GACD,SAASE,oBAAoBC,YAAoB;IAC/C,MAAMC,UAAe,CAAC;IACtB,MAAMC,QAAQ;IACd,IAAIC;IACJ,MAAO,AAACA,CAAAA,QAAQD,MAAME,IAAI,CAACJ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