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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/anthropic-client.ts"],"sourcesContent":["/**\r\n * Anthropic API Client\r\n *\r\n * Handles communication with Claude API (Anthropic or z.ai provider).\r\n * Supports streaming responses and tool execution.\r\n */\r\n\r\nimport Anthropic from '@anthropic-ai/sdk';\r\nimport fs from 'fs/promises';\r\nimport path from 'path';\r\nimport { exec } from 'child_process';\r\nimport { promisify } from 'util';\r\nimport { executeTool, type ToolUse, type ToolResult } from './tool-executor.js';\r\n\r\nconst execAsync = promisify(exec);\r\n\r\nexport interface APIConfig {\r\n provider: 'anthropic' | 'zai' | 'kimi' | 'openrouter';\r\n apiKey?: string;\r\n baseURL?: string;\r\n}\r\n\r\nexport interface MessageOptions {\r\n model: string;\r\n prompt: string;\r\n systemPrompt?: string;\r\n maxTokens?: number;\r\n temperature?: number;\r\n stream?: boolean;\r\n tools?: any[];\r\n messages?: Array<{ role: string; content: string }>; // Sprint 4: Conversation forking\r\n}\r\n\r\nexport interface MessageResponse {\r\n content: string;\r\n usage: {\r\n inputTokens: number;\r\n outputTokens: number;\r\n };\r\n stopReason: string;\r\n}\r\n\r\n/**\r\n * Get API configuration from environment and config files\r\n */\r\nexport async function getAPIConfig(): Promise<APIConfig> {\r\n // Check environment variable\r\n const envProvider = process.env.CLAUDE_API_PROVIDER;\r\n\r\n if (envProvider === 'zai') {\r\n return {\r\n provider: 'zai',\r\n apiKey: process.env.ZAI_API_KEY || process.env.ANTHROPIC_API_KEY,\r\n baseURL: process.env.ZAI_BASE_URL || 'https://api.z.ai/api/anthropic',\r\n };\r\n }\r\n\r\n if (envProvider === 'kimi') {\r\n return {\r\n provider: 'kimi',\r\n apiKey: process.env.KIMI_API_KEY,\r\n baseURL: process.env.KIMI_BASE_URL || 'https://api.moonshot.cn/v1',\r\n };\r\n }\r\n\r\n if (envProvider === 'openrouter') {\r\n return {\r\n provider: 'openrouter',\r\n apiKey: process.env.OPENROUTER_API_KEY,\r\n baseURL: process.env.OPENROUTER_BASE_URL || 'https://openrouter.ai/api/v1',\r\n };\r\n }\r\n\r\n // Check config file\r\n try {\r\n const configPath = path.join('.claude', 'config', 'api-provider.json');\r\n const config = JSON.parse(await fs.readFile(configPath, 'utf-8'));\r\n\r\n if (config.provider === 'zai' || config.provider === 'z.ai') {\r\n return {\r\n provider: 'zai',\r\n apiKey: config.apiKey || process.env.ZAI_API_KEY || process.env.ANTHROPIC_API_KEY,\r\n baseURL: config.baseURL || process.env.ZAI_BASE_URL || 'https://api.z.ai/api/anthropic',\r\n };\r\n }\r\n\r\n if (config.provider === 'kimi') {\r\n return {\r\n provider: 'kimi',\r\n apiKey: config.apiKey || process.env.KIMI_API_KEY,\r\n baseURL: config.baseURL || process.env.KIMI_BASE_URL || 'https://api.moonshot.cn/v1',\r\n };\r\n }\r\n\r\n if (config.provider === 'openrouter') {\r\n return {\r\n provider: 'openrouter',\r\n apiKey: config.apiKey || process.env.OPENROUTER_API_KEY,\r\n baseURL: config.baseURL || process.env.OPENROUTER_BASE_URL || 'https://openrouter.ai/api/v1',\r\n };\r\n }\r\n } catch {\r\n // Config file doesn't exist, use defaults\r\n }\r\n\r\n // Default to Anthropic\r\n return {\r\n provider: 'anthropic',\r\n apiKey: process.env.ANTHROPIC_API_KEY,\r\n };\r\n}\r\n\r\n/**\r\n * Create Anthropic client with appropriate configuration\r\n */\r\nexport async function createClient(): Promise<Anthropic> {\r\n const config = await getAPIConfig();\r\n\r\n if (!config.apiKey) {\r\n throw new Error(\r\n `API key not found. Set ${config.provider === 'zai' ? 'ZAI_API_KEY' : 'ANTHROPIC_API_KEY'} environment variable.`\r\n );\r\n }\r\n\r\n const clientOptions: any = {\r\n apiKey: config.apiKey,\r\n timeout: 120000, // 2 minutes (120 seconds)\r\n maxRetries: 2,\r\n };\r\n\r\n if (config.provider === 'zai' && config.baseURL) {\r\n clientOptions.baseURL = config.baseURL;\r\n }\r\n\r\n return new Anthropic(clientOptions);\r\n}\r\n\r\n/**\r\n * Map agent model name to API model ID (provider-specific)\r\n */\r\nexport function mapModelName(agentModel: string, provider: 'anthropic' | 'zai' = 'anthropic'): string {\r\n // Z.ai uses GLM models - try glm-4.6 first for all models\r\n if (provider === 'zai') {\r\n const zaiModelMap: Record<string, string> = {\r\n haiku: 'glm-4.6',\r\n sonnet: 'glm-4.6',\r\n opus: 'glm-4.6',\r\n };\r\n return zaiModelMap[agentModel] || 'glm-4.6';\r\n }\r\n\r\n // Anthropic uses Claude models\r\n const modelMap: Record<string, string> = {\r\n haiku: 'claude-3-5-haiku-20241022',\r\n sonnet: 'claude-3-5-sonnet-20241022',\r\n opus: 'claude-3-opus-20240229',\r\n };\r\n\r\n return modelMap[agentModel] || modelMap.haiku;\r\n}\r\n\r\n/**\r\n * Get fallback model for Z.ai (glm-4.6 -> glm-4.5-air)\r\n */\r\nfunction getFallbackModel(model: string): string | null {\r\n if (model === 'glm-4.6') {\r\n return 'glm-4.5-air';\r\n }\r\n return null;\r\n}\r\n\r\n/**\r\n * Send message to Claude API with streaming support and automatic fallback\r\n */\r\nexport async function sendMessage(\r\n options: MessageOptions,\r\n onChunk?: (text: string) => void\r\n): Promise<MessageResponse> {\r\n const client = await createClient();\r\n const config = await getAPIConfig();\r\n\r\n // Primary model (glm-4.6 for Z.ai, Claude for Anthropic)\r\n let model = mapModelName(options.model, config.provider);\r\n const maxTokens = options.maxTokens || 16000; // Sprint 6: 16K hard limit for GLM-4.6 (agents target 10K for buffer)\r\n const temperature = options.temperature ?? 1.0;\r\n\r\n // Disable streaming for Z.ai (compatibility issue)\r\n const enableStreaming = options.stream && config.provider !== 'zai';\r\n\r\n console.log(`[anthropic-client] Provider: ${config.provider}`);\r\n console.log(`[anthropic-client] Model: ${model}`);\r\n console.log(`[anthropic-client] Max tokens: ${maxTokens}`);\r\n console.log(`[anthropic-client] Stream: ${enableStreaming ? 'enabled' : 'disabled'}`);\r\n console.log('');\r\n\r\n // Sprint 4: Use messages array if provided (conversation forking)\r\n const messages: Anthropic.MessageParam[] = options.messages\r\n ? options.messages.map(m => ({\r\n role: m.role as 'user' | 'assistant',\r\n content: m.content,\r\n }))\r\n : [\r\n {\r\n role: 'user',\r\n content: options.prompt,\r\n },\r\n ];\r\n\r\n // Retry logic: Try primary model (glm-4.6), fall back to glm-4.5 on error\r\n let lastError: Error | null = null;\r\n let attempts = 0;\r\n const maxAttempts = 2; // Primary + fallback\r\n\r\n while (attempts < maxAttempts) {\r\n const currentModel = attempts === 0 ? model : getFallbackModel(model);\r\n\r\n if (!currentModel) {\r\n // No fallback available, throw last error\r\n throw lastError || new Error('No model available');\r\n }\r\n\r\n attempts++;\r\n\r\n if (attempts > 1) {\r\n console.log(`[anthropic-client] Retrying with fallback model: ${currentModel}`);\r\n }\r\n\r\n const requestParams: Anthropic.MessageCreateParams = {\r\n model: currentModel,\r\n max_tokens: maxTokens,\r\n temperature,\r\n messages,\r\n };\r\n\r\n if (options.systemPrompt) {\r\n requestParams.system = options.systemPrompt;\r\n }\r\n\r\n if (options.tools && options.tools.length > 0) {\r\n requestParams.tools = options.tools;\r\n }\r\n\r\n try {\r\n // Streaming response\r\n if (enableStreaming) {\r\n let fullContent = '';\r\n let inputTokens = 0;\r\n let outputTokens = 0;\r\n let stopReason = 'end_turn';\r\n\r\n console.log('[anthropic-client] Creating streaming request...');\r\n const stream = await client.messages.create({\r\n ...requestParams,\r\n stream: true,\r\n });\r\n\r\n console.log('[anthropic-client] Stream created, processing events...');\r\n for await (const event of stream) {\r\n console.log('[anthropic-client] Event type:', event.type);\r\n if (event.type === 'message_start') {\r\n // @ts-ignore - usage exists on message_start\r\n inputTokens = event.message.usage?.input_tokens || 0;\r\n } else if (event.type === 'content_block_delta') {\r\n // @ts-ignore - text exists on delta\r\n const text = event.delta?.text || '';\r\n fullContent += text;\r\n if (onChunk) {\r\n onChunk(text);\r\n }\r\n } else if (event.type === 'message_delta') {\r\n // @ts-ignore - usage exists on message_delta\r\n outputTokens = event.usage?.output_tokens || 0;\r\n // @ts-ignore - stop_reason exists on delta\r\n stopReason = event.delta?.stop_reason || 'end_turn';\r\n }\r\n }\r\n\r\n return {\r\n content: fullContent,\r\n usage: {\r\n inputTokens,\r\n outputTokens,\r\n },\r\n stopReason,\r\n };\r\n }\r\n\r\n // Non-streaming response\r\n const response = await client.messages.create(requestParams);\r\n\r\n const content =\r\n response.content\r\n .filter((block) => block.type === 'text')\r\n .map((block) => (block as any).text)\r\n .join('\\n') || '';\r\n\r\n return {\r\n content,\r\n usage: {\r\n inputTokens: response.usage.input_tokens,\r\n outputTokens: response.usage.output_tokens,\r\n },\r\n stopReason: response.stop_reason || 'end_turn',\r\n };\r\n } catch (error) {\r\n lastError = error instanceof Error ? error : new Error(String(error));\r\n console.error(`[anthropic-client] Error with model ${currentModel}:`, lastError.message);\r\n\r\n // If this was the last attempt, throw the error\r\n if (attempts >= maxAttempts) {\r\n throw lastError;\r\n }\r\n\r\n // Continue to next attempt with fallback model\r\n console.log('[anthropic-client] Will retry with fallback model...');\r\n }\r\n }\r\n\r\n // Should never reach here\r\n throw lastError || new Error('All retry attempts failed');\r\n}\r\n\r\n/**\r\n * Execute agent with tool support (agentic loop)\r\n *\r\n * Handles:\r\n * 1. Send message with tools\r\n * 2. Get response\r\n * 3. If tool_use blocks, execute tools and send results back\r\n * 4. Repeat until final text response\r\n */\r\nasync function executeWithTools(\r\n options: MessageOptions,\r\n onChunk?: (text: string) => void\r\n): Promise<MessageResponse> {\r\n const client = await createClient();\r\n const config = await getAPIConfig();\r\n\r\n const model = mapModelName(options.model, config.provider);\r\n const maxTokens = options.maxTokens || 16000;\r\n const temperature = options.temperature ?? 1.0;\r\n\r\n // Build initial messages array\r\n const messages: Anthropic.MessageParam[] = options.messages\r\n ? options.messages.map(m => ({\r\n role: m.role as 'user' | 'assistant',\r\n content: m.content,\r\n }))\r\n : [\r\n {\r\n role: 'user',\r\n content: options.prompt,\r\n },\r\n ];\r\n\r\n let totalInputTokens = 0;\r\n let totalOutputTokens = 0;\r\n let fullTextContent = '';\r\n const MAX_ITERATIONS = 20; // Prevent infinite loops (increased for exploration phase)\r\n let iteration = 0;\r\n\r\n while (iteration < MAX_ITERATIONS) {\r\n iteration++;\r\n console.log(`[executeWithTools] Iteration ${iteration}`);\r\n\r\n const requestParams: Anthropic.MessageCreateParams = {\r\n model,\r\n max_tokens: maxTokens,\r\n temperature,\r\n messages,\r\n };\r\n\r\n if (options.systemPrompt) {\r\n requestParams.system = options.systemPrompt;\r\n }\r\n\r\n if (options.tools && options.tools.length > 0) {\r\n requestParams.tools = options.tools;\r\n }\r\n\r\n // Make API request (non-streaming for now to handle tool_use)\r\n const response = await client.messages.create(requestParams);\r\n\r\n totalInputTokens += response.usage.input_tokens;\r\n totalOutputTokens += response.usage.output_tokens;\r\n\r\n // Extract content blocks\r\n const textBlocks = response.content.filter(block => block.type === 'text');\r\n const toolUseBlocks = response.content.filter(block => block.type === 'tool_use');\r\n\r\n // Stream text output\r\n for (const block of textBlocks) {\r\n if (block.type === 'text') {\r\n const text = (block as any).text;\r\n fullTextContent += text;\r\n if (onChunk) {\r\n onChunk(text);\r\n }\r\n }\r\n }\r\n\r\n // If no tool uses, we're done\r\n if (toolUseBlocks.length === 0) {\r\n console.log(`[executeWithTools] No tool uses, completing`);\r\n return {\r\n content: fullTextContent,\r\n usage: {\r\n inputTokens: totalInputTokens,\r\n outputTokens: totalOutputTokens,\r\n },\r\n stopReason: response.stop_reason || 'end_turn',\r\n };\r\n }\r\n\r\n // Execute tools\r\n console.log(`[executeWithTools] Executing ${toolUseBlocks.length} tool(s)`);\r\n const toolResults: ToolResult[] = [];\r\n\r\n for (const toolUseBlock of toolUseBlocks) {\r\n if (toolUseBlock.type !== 'tool_use') continue;\r\n\r\n const toolUse: ToolUse = {\r\n type: 'tool_use',\r\n id: (toolUseBlock as any).id,\r\n name: (toolUseBlock as any).name,\r\n input: (toolUseBlock as any).input,\r\n };\r\n\r\n console.log(`[executeWithTools] Tool: ${toolUse.name}`);\r\n const result = await executeTool(toolUse);\r\n toolResults.push(result);\r\n\r\n // Stream tool result\r\n if (onChunk) {\r\n onChunk(`\\n[Tool: ${toolUse.name}] ${result.content.substring(0, 100)}${result.content.length > 100 ? '...' : ''}\\n`);\r\n }\r\n }\r\n\r\n // Add assistant message with tool_use\r\n messages.push({\r\n role: 'assistant',\r\n content: response.content as any,\r\n });\r\n\r\n // Add tool results as user message\r\n messages.push({\r\n role: 'user',\r\n content: toolResults as any,\r\n });\r\n\r\n // Continue to next iteration\r\n }\r\n\r\n // Reached max iterations\r\n console.warn(`[executeWithTools] Reached max iterations (${MAX_ITERATIONS})`);\r\n return {\r\n content: fullTextContent,\r\n usage: {\r\n inputTokens: totalInputTokens,\r\n outputTokens: totalOutputTokens,\r\n },\r\n stopReason: 'max_tokens',\r\n };\r\n}\r\n\r\n/**\r\n * Execute agent via API with full lifecycle\r\n */\r\nexport async function executeAgentAPI(\r\n agentType: string,\r\n agentId: string,\r\n model: string,\r\n prompt: string,\r\n systemPrompt?: string,\r\n messages?: Array<{ role: string; content: string }>, // Sprint 4: Conversation forking\r\n maxTokens?: number, // Sprint 6: Configurable token limit\r\n tools?: any[] // Tool definitions for agent capabilities\r\n): Promise<{ success: boolean; output: string; usage: any; error?: string }> {\r\n // Start heartbeat monitoring (declare at function scope for error handling)\r\n let heartbeatInterval: NodeJS.Timeout | null = null;\r\n const taskId = process.env.TASK_ID;\r\n\r\n // Bug #6 Fix: Read Redis connection parameters from process.env and interpolate in TypeScript\r\n const redisHost = process.env.CFN_REDIS_HOST || 'cfn-redis';\r\n const redisPort = process.env.CFN_REDIS_PORT || '6379';\r\n\r\n try {\r\n console.log(`[anthropic-client] Executing agent: ${agentType}`);\r\n console.log(`[anthropic-client] Agent ID: ${agentId}`);\r\n if (messages && messages.length > 1) {\r\n console.log(`[anthropic-client] Continuing conversation (${messages.length} messages)`);\r\n }\r\n console.log('');\r\n\r\n if (taskId) {\r\n heartbeatInterval = setInterval(async () => {\r\n try {\r\n await execAsync(`redis-cli -h ${redisHost} -p ${redisPort} hset \"swarm:${taskId}:agent:${agentId}\" heartbeat \"${Date.now()}\" status \"working\"`);\r\n } catch (err) {\r\n console.error('[heartbeat] Error sending heartbeat:', err);\r\n }\r\n }, 30000); // Every 30 seconds\r\n\r\n console.log(`[heartbeat] Monitoring started for agent ${agentId} (30s interval)`);\r\n }\r\n\r\n let fullOutput = '';\r\n\r\n // If tools provided, use agentic loop with tool execution\r\n // Otherwise use simple streaming\r\n let response: MessageResponse;\r\n\r\n if (tools && tools.length > 0) {\r\n console.log(`[anthropic-client] Tools enabled: ${tools.map(t => t.name).join(', ')}`);\r\n response = await executeWithTools(\r\n {\r\n model,\r\n prompt,\r\n systemPrompt,\r\n messages,\r\n maxTokens,\r\n tools\r\n },\r\n (chunk) => {\r\n process.stdout.write(chunk);\r\n fullOutput += chunk;\r\n }\r\n );\r\n } else {\r\n response = await sendMessage(\r\n {\r\n model,\r\n prompt,\r\n systemPrompt,\r\n stream: true,\r\n messages,\r\n maxTokens,\r\n },\r\n (chunk) => {\r\n process.stdout.write(chunk);\r\n fullOutput += chunk;\r\n }\r\n );\r\n }\r\n\r\n console.log('\\n');\r\n console.log('=== Agent Execution Complete ===');\r\n console.log(`Input tokens: ${response.usage.inputTokens}`);\r\n console.log(`Output tokens: ${response.usage.outputTokens}`);\r\n console.log(`Stop reason: ${response.stopReason}`);\r\n\r\n // Stop heartbeat and send final status\r\n if (heartbeatInterval) {\r\n clearInterval(heartbeatInterval);\r\n\r\n if (taskId) {\r\n await execAsync(`redis-cli -h ${redisHost} -p ${redisPort} hset \"swarm:${taskId}:agent:${agentId}\" heartbeat \"${Date.now()}\" status \"complete\"`);\r\n console.log(`[heartbeat] Monitoring stopped - agent ${agentId} complete`);\r\n }\r\n }\r\n\r\n return {\r\n success: true,\r\n output: response.content,\r\n usage: response.usage,\r\n };\r\n } catch (error) {\r\n console.error('[anthropic-client] Error:', error);\r\n\r\n // Stop heartbeat and send error status\r\n if (heartbeatInterval) {\r\n clearInterval(heartbeatInterval);\r\n\r\n if (taskId) {\r\n try {\r\n await execAsync(`redis-cli -h ${redisHost} -p ${redisPort} hset \"swarm:${taskId}:agent:${agentId}\" heartbeat \"${Date.now()}\" status \"error\"`);\r\n console.log(`[heartbeat] Monitoring stopped - agent ${agentId} error`);\r\n } catch (err) {\r\n // Ignore heartbeat errors during error handling\r\n }\r\n }\r\n }\r\n\r\n return {\r\n success: false,\r\n output: '',\r\n usage: { inputTokens: 0, outputTokens: 0 },\r\n error: error instanceof Error ? error.message : String(error),\r\n };\r\n }\r\n}\r\n"],"names":["Anthropic","fs","path","exec","promisify","executeTool","execAsync","getAPIConfig","envProvider","process","env","CLAUDE_API_PROVIDER","provider","apiKey","ZAI_API_KEY","ANTHROPIC_API_KEY","baseURL","ZAI_BASE_URL","KIMI_API_KEY","KIMI_BASE_URL","OPENROUTER_API_KEY","OPENROUTER_BASE_URL","configPath","join","config","JSON","parse","readFile","createClient","Error","clientOptions","timeout","maxRetries","mapModelName","agentModel","zaiModelMap","haiku","sonnet","opus","modelMap","getFallbackModel","model","sendMessage","options","onChunk","client","maxTokens","temperature","enableStreaming","stream","console","log","messages","map","m","role","content","prompt","lastError","attempts","maxAttempts","currentModel","requestParams","max_tokens","systemPrompt","system","tools","length","fullContent","inputTokens","outputTokens","stopReason","create","event","type","message","usage","input_tokens","text","delta","output_tokens","stop_reason","response","filter","block","error","String","executeWithTools","totalInputTokens","totalOutputTokens","fullTextContent","MAX_ITERATIONS","iteration","textBlocks","toolUseBlocks","toolResults","toolUseBlock","toolUse","id","name","input","result","push","substring","warn","executeAgentAPI","agentType","agentId","heartbeatInterval","taskId","TASK_ID","redisHost","CFN_REDIS_HOST","redisPort","CFN_REDIS_PORT","setInterval","Date","now","err","fullOutput","t","chunk","stdout","write","clearInterval","success","output"],"mappings":"AAAA;;;;;CAKC,GAED,OAAOA,eAAe,oBAAoB;AAC1C,OAAOC,QAAQ,cAAc;AAC7B,OAAOC,UAAU,OAAO;AACxB,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,WAAW,QAAuC,qBAAqB;AAEhF,MAAMC,YAAYF,UAAUD;AA4B5B;;CAEC,GACD,OAAO,eAAeI;IACpB,6BAA6B;IAC7B,MAAMC,cAAcC,QAAQC,GAAG,CAACC,mBAAmB;IAEnD,IAAIH,gBAAgB,OAAO;QACzB,OAAO;YACLI,UAAU;YACVC,QAAQJ,QAAQC,GAAG,CAACI,WAAW,IAAIL,QAAQC,GAAG,CAACK,iBAAiB;YAChEC,SAASP,QAAQC,GAAG,CAACO,YAAY,IAAI;QACvC;IACF;IAEA,IAAIT,gBAAgB,QAAQ;QAC1B,OAAO;YACLI,UAAU;YACVC,QAAQJ,QAAQC,GAAG,CAACQ,YAAY;YAChCF,SAASP,QAAQC,GAAG,CAACS,aAAa,IAAI;QACxC;IACF;IAEA,IAAIX,gBAAgB,cAAc;QAChC,OAAO;YACLI,UAAU;YACVC,QAAQJ,QAAQC,GAAG,CAACU,kBAAkB;YACtCJ,SAASP,QAAQC,GAAG,CAACW,mBAAmB,IAAI;QAC9C;IACF;IAEA,oBAAoB;IACpB,IAAI;QACF,MAAMC,aAAapB,KAAKqB,IAAI,CAAC,WAAW,UAAU;QAClD,MAAMC,SAASC,KAAKC,KAAK,CAAC,MAAMzB,GAAG0B,QAAQ,CAACL,YAAY;QAExD,IAAIE,OAAOZ,QAAQ,KAAK,SA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C/InE,QAAQC,GAAG,CAAC,CAAC,uCAAuC,EAAEwD,QAAQ,SAAS,CAAC;YAC1E;QACF;QAEA,OAAO;YACLkB,SAAS;YACTC,QAAQ5C,SAAS1B,OAAO;YACxBoB,OAAOM,SAASN,KAAK;QACvB;IACF,EAAE,OAAOS,OAAO;QACdnC,QAAQmC,KAAK,CAAC,6BAA6BA;QAE3C,uCAAuC;QACvC,IAAIuB,mBAAmB;YACrBgB,cAAchB;YAEd,IAAIC,QAAQ;gBACV,IAAI;oBACF,MAAMvG,UAAU,CAAC,aAAa,EAAEyG,UAAU,IAAI,EAAEE,UAAU,aAAa,EAAEJ,OAAO,OAAO,EAAEF,QAAQ,aAAa,EAAES,KAAKC,GAAG,GAAG,gBAAgB,CAAC;oBAC5InE,QAAQC,GAAG,CAAC,CAAC,uCAAuC,EAAEwD,QAAQ,MAAM,CAAC;gBACvE,EAAE,OAAOW,KAAK;gBACZ,gDAAgD;gBAClD;YACF;QACF;QAEA,OAAO;YACLO,SAAS;YACTC,QAAQ;YACRlD,OAAO;gBAAEP,aAAa;gBAAGC,cAAc;YAAE;YACzCe,OAAOA,iBAAiBxD,QAAQwD,MAAMV,OAAO,GAAGW,OAAOD;QACzD;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/anthropic-client.ts"],"sourcesContent":["/**\r\n * Anthropic API Client\r\n *\r\n * Handles communication with Claude API (Anthropic or z.ai provider).\r\n * Supports streaming responses and tool execution.\r\n */\r\n\r\nimport Anthropic from '@anthropic-ai/sdk';\r\nimport fs from 'fs/promises';\r\nimport path from 'path';\r\nimport { exec } from 'child_process';\r\nimport { promisify } from 'util';\r\nimport { executeTool, type ToolUse, type ToolResult } from './tool-executor.js';\r\n\r\nconst execAsync = promisify(exec);\r\n\r\nexport interface APIConfig {\r\n provider: 'anthropic' | 'zai' | 'kimi' | 'openrouter';\r\n apiKey?: string;\r\n baseURL?: string;\r\n}\r\n\r\nexport interface MessageOptions {\r\n model: string;\r\n prompt: string;\r\n systemPrompt?: string;\r\n maxTokens?: number;\r\n temperature?: number;\r\n stream?: boolean;\r\n tools?: any[];\r\n messages?: Array<{ role: string; content: string }>; // Sprint 4: Conversation forking\r\n}\r\n\r\nexport interface MessageResponse {\r\n content: string;\r\n usage: {\r\n inputTokens: number;\r\n outputTokens: number;\r\n };\r\n stopReason: string;\r\n}\r\n\r\n/**\r\n * Get API configuration from environment and config files\r\n */\r\nexport async function getAPIConfig(): Promise<APIConfig> {\r\n // Check environment variable\r\n const envProvider = process.env.CLAUDE_API_PROVIDER;\r\n\r\n if (envProvider === 'zai') {\r\n return {\r\n provider: 'zai',\r\n apiKey: process.env.ZAI_API_KEY || process.env.ANTHROPIC_API_KEY,\r\n baseURL: process.env.ZAI_BASE_URL || 'https://api.z.ai/api/anthropic',\r\n };\r\n }\r\n\r\n if (envProvider === 'kimi') {\r\n return {\r\n provider: 'kimi',\r\n apiKey: process.env.KIMI_API_KEY,\r\n baseURL: process.env.KIMI_BASE_URL || 'https://api.moonshot.cn/v1',\r\n };\r\n }\r\n\r\n if (envProvider === 'openrouter') {\r\n return {\r\n provider: 'openrouter',\r\n apiKey: process.env.OPENROUTER_API_KEY,\r\n baseURL: process.env.OPENROUTER_BASE_URL || 'https://openrouter.ai/api/v1',\r\n };\r\n }\r\n\r\n // Check config file\r\n try {\r\n const configPath = path.join('.claude', 'config', 'api-provider.json');\r\n const config = JSON.parse(await fs.readFile(configPath, 'utf-8'));\r\n\r\n if (config.provider === 'zai' || config.provider === 'z.ai') {\r\n return {\r\n provider: 'zai',\r\n apiKey: config.apiKey || process.env.ZAI_API_KEY || process.env.ANTHROPIC_API_KEY,\r\n baseURL: config.baseURL || process.env.ZAI_BASE_URL || 'https://api.z.ai/api/anthropic',\r\n };\r\n }\r\n\r\n if (config.provider === 'kimi') {\r\n return {\r\n provider: 'kimi',\r\n apiKey: config.apiKey || process.env.KIMI_API_KEY,\r\n baseURL: config.baseURL || process.env.KIMI_BASE_URL || 'https://api.moonshot.cn/v1',\r\n };\r\n }\r\n\r\n if (config.provider === 'openrouter') {\r\n return {\r\n provider: 'openrouter',\r\n apiKey: config.apiKey || process.env.OPENROUTER_API_KEY,\r\n baseURL: config.baseURL || process.env.OPENROUTER_BASE_URL || 'https://openrouter.ai/api/v1',\r\n };\r\n }\r\n } catch {\r\n // Config file doesn't exist, use defaults\r\n }\r\n\r\n // Default to Anthropic\r\n return {\r\n provider: 'anthropic',\r\n apiKey: process.env.ANTHROPIC_API_KEY,\r\n };\r\n}\r\n\r\n/**\r\n * Create Anthropic client with appropriate configuration\r\n */\r\nexport async function createClient(): Promise<Anthropic> {\r\n const config = await getAPIConfig();\r\n\r\n if (!config.apiKey) {\r\n throw new Error(\r\n `API key not found. Set ${config.provider === 'zai' ? 'ZAI_API_KEY' : 'ANTHROPIC_API_KEY'} environment variable.`\r\n );\r\n }\r\n\r\n const clientOptions: any = {\r\n apiKey: config.apiKey,\r\n timeout: 120000, // 2 minutes (120 seconds)\r\n maxRetries: 2,\r\n };\r\n\r\n if (config.provider === 'zai' && config.baseURL) {\r\n clientOptions.baseURL = config.baseURL;\r\n }\r\n\r\n return new Anthropic(clientOptions);\r\n}\r\n\r\n/**\r\n * Map agent model name to API model ID (provider-specific)\r\n */\r\nexport function mapModelName(agentModel: string, provider: 'anthropic' | 'zai' = 'anthropic'): string {\r\n // Z.ai uses GLM models - try glm-4.6 first for all models\r\n if (provider === 'zai') {\r\n const zaiModelMap: Record<string, string> = {\r\n haiku: 'glm-4.6',\r\n sonnet: 'glm-4.6',\r\n opus: 'glm-4.6',\r\n };\r\n return zaiModelMap[agentModel] || 'glm-4.6';\r\n }\r\n\r\n // Anthropic uses Claude models\r\n const modelMap: Record<string, string> = {\r\n haiku: 'claude-3-5-haiku-20241022',\r\n sonnet: 'claude-3-5-sonnet-20241022',\r\n opus: 'claude-3-opus-20240229',\r\n };\r\n\r\n return modelMap[agentModel] || modelMap.haiku;\r\n}\r\n\r\n/**\r\n * Get fallback model for Z.ai (glm-4.6 -> glm-4.5-air)\r\n */\r\nfunction getFallbackModel(model: string): string | null {\r\n if (model === 'glm-4.6') {\r\n return 'glm-4.5-air';\r\n }\r\n return null;\r\n}\r\n\r\n/**\r\n * Send message to Claude API with streaming support and automatic fallback\r\n */\r\nexport async function sendMessage(\r\n options: MessageOptions,\r\n onChunk?: (text: string) => void\r\n): Promise<MessageResponse> {\r\n const client = await createClient();\r\n const config = await getAPIConfig();\r\n\r\n // Primary model (glm-4.6 for Z.ai, Claude for Anthropic)\r\n let model = mapModelName(options.model, config.provider);\r\n const maxTokens = options.maxTokens || 16000; // Sprint 6: 16K hard limit for GLM-4.6 (agents target 10K for buffer)\r\n const temperature = options.temperature ?? 1.0;\r\n\r\n // Streaming supported for both providers; retry without streaming if a provider rejects it\n let enableStreaming = !!options.stream;\n\r\n console.log(`[anthropic-client] Provider: ${config.provider}`);\r\n console.log(`[anthropic-client] Model: ${model}`);\r\n console.log(`[anthropic-client] Max tokens: ${maxTokens}`);\r\n console.log(`[anthropic-client] Stream: ${enableStreaming ? 'enabled' : 'disabled'}`);\r\n console.log('');\r\n\r\n // Sprint 4: Use messages array if provided (conversation forking)\r\n const messages: Anthropic.MessageParam[] = options.messages\r\n ? options.messages.map(m => ({\r\n role: m.role as 'user' | 'assistant',\r\n content: m.content,\r\n }))\r\n : [\r\n {\r\n role: 'user',\r\n content: options.prompt,\r\n },\r\n ];\r\n\r\n // Retry logic: Try primary model (glm-4.6), fall back to glm-4.5 on error\r\n let lastError: Error | null = null;\r\n let attempts = 0;\r\n const maxAttempts = 2; // Primary + fallback\r\n\r\n while (attempts < maxAttempts) {\r\n const currentModel = attempts === 0 ? model : getFallbackModel(model);\r\n\r\n if (!currentModel) {\r\n // No fallback available, throw last error\r\n throw lastError || new Error('No model available');\r\n }\r\n\r\n attempts++;\r\n\r\n if (attempts > 1) {\r\n console.log(`[anthropic-client] Retrying with fallback model: ${currentModel}`);\r\n }\r\n\r\n const requestParams: Anthropic.MessageCreateParams = {\r\n model: currentModel,\r\n max_tokens: maxTokens,\r\n temperature,\r\n messages,\r\n };\r\n\r\n if (options.systemPrompt) {\r\n requestParams.system = options.systemPrompt;\r\n }\r\n\r\n if (options.tools && options.tools.length > 0) {\r\n requestParams.tools = options.tools;\r\n }\r\n\r\n try {\n // Streaming response (preferred)\n if (enableStreaming) {\n let fullContent = '';\n let inputTokens = 0;\n let outputTokens = 0;\n let stopReason = 'end_turn';\n\n console.log('[anthropic-client] Creating streaming request...');\n const stream = await client.messages.create({\n ...requestParams,\n stream: true,\n });\n\n console.log('[anthropic-client] Stream created, processing events...');\n for await (const event of stream) {\n console.log('[anthropic-client] Event type:', event.type);\n if (event.type === 'message_start') {\n // @ts-ignore - usage exists on message_start\n inputTokens = event.message.usage?.input_tokens || 0;\n } else if (event.type === 'content_block_delta') {\n // @ts-ignore - text exists on delta\n const text = event.delta?.text || '';\n fullContent += text;\n if (onChunk) {\n onChunk(text);\n }\n } else if (event.type === 'message_delta') {\n // @ts-ignore - usage exists on message_delta\n outputTokens = event.usage?.output_tokens || 0;\n // @ts-ignore - stop_reason exists on delta\n stopReason = event.delta?.stop_reason || 'end_turn';\n }\n }\n\n return {\n content: fullContent,\n usage: {\n inputTokens,\n outputTokens,\n },\n stopReason,\n };\n }\n\n // Non-streaming response\n const response = await client.messages.create(requestParams);\n\n const content =\n response.content\n .filter((block) => block.type === 'text')\n .map((block) => (block as any).text)\n .join('\\n') || '';\n\n return {\n content,\n usage: {\n inputTokens: response.usage.input_tokens,\n outputTokens: response.usage.output_tokens,\n },\n stopReason: response.stop_reason || 'end_turn',\n };\n } catch (error) {\n // If streaming fails on Z.ai, retry once without streaming before falling back to model fallback logic\n if (enableStreaming && config.provider === 'zai') {\n console.warn('[anthropic-client] Streaming failed on z.ai, retrying without streaming:', error);\n enableStreaming = false;\n attempts--; // do not consume a model attempt\n continue;\n }\n\n lastError = error instanceof Error ? error : new Error(String(error));\n console.error(`[anthropic-client] Error with model ${currentModel}:`, lastError.message);\n\n // If this was the last attempt, throw the error\n if (attempts >= maxAttempts) {\n throw lastError;\n }\n\n // Continue to next attempt with fallback model\n console.log('[anthropic-client] Will retry with fallback model...');\n }\n }\n\r\n // Should never reach here\r\n throw lastError || new Error('All retry attempts failed');\r\n}\r\n\r\n/**\r\n * Execute agent with tool support (agentic loop)\r\n *\r\n * Handles:\r\n * 1. Send message with tools\r\n * 2. Get response\r\n * 3. If tool_use blocks, execute tools and send results back\r\n * 4. Repeat until final text response\r\n */\r\nasync function executeWithTools(\r\n options: MessageOptions,\r\n onChunk?: (text: string) => void\r\n): Promise<MessageResponse> {\r\n const client = await createClient();\r\n const config = await getAPIConfig();\r\n\r\n const model = mapModelName(options.model, config.provider);\r\n const maxTokens = options.maxTokens || 16000;\r\n const temperature = options.temperature ?? 1.0;\r\n\r\n // Build initial messages array\r\n const messages: Anthropic.MessageParam[] = options.messages\r\n ? options.messages.map(m => ({\r\n role: m.role as 'user' | 'assistant',\r\n content: m.content,\r\n }))\r\n : [\r\n {\r\n role: 'user',\r\n content: options.prompt,\r\n },\r\n ];\r\n\r\n let totalInputTokens = 0;\r\n let totalOutputTokens = 0;\r\n let fullTextContent = '';\r\n const MAX_ITERATIONS = 20; // Prevent infinite loops (increased for exploration phase)\r\n let iteration = 0;\r\n\r\n while (iteration < MAX_ITERATIONS) {\r\n iteration++;\r\n console.log(`[executeWithTools] Iteration ${iteration}`);\r\n\r\n const requestParams: Anthropic.MessageCreateParams = {\r\n model,\r\n max_tokens: maxTokens,\r\n temperature,\r\n messages,\r\n };\r\n\r\n if (options.systemPrompt) {\r\n requestParams.system = options.systemPrompt;\r\n }\r\n\r\n if (options.tools && options.tools.length > 0) {\r\n requestParams.tools = options.tools;\r\n }\r\n\r\n // Make API request (non-streaming for now to handle tool_use)\r\n const response = await client.messages.create(requestParams);\r\n\r\n totalInputTokens += response.usage.input_tokens;\r\n totalOutputTokens += response.usage.output_tokens;\r\n\r\n // Extract content blocks\r\n const textBlocks = response.content.filter(block => block.type === 'text');\r\n const toolUseBlocks = response.content.filter(block => block.type === 'tool_use');\r\n\r\n // Stream text output\r\n for (const block of textBlocks) {\r\n if (block.type === 'text') {\r\n const text = (block as any).text;\r\n fullTextContent += text;\r\n if (onChunk) {\r\n onChunk(text);\r\n }\r\n }\r\n }\r\n\r\n // If no tool uses, we're done\r\n if (toolUseBlocks.length === 0) {\r\n console.log(`[executeWithTools] No tool uses, completing`);\r\n return {\r\n content: fullTextContent,\r\n usage: {\r\n inputTokens: totalInputTokens,\r\n outputTokens: totalOutputTokens,\r\n },\r\n stopReason: response.stop_reason || 'end_turn',\r\n };\r\n }\r\n\r\n // Execute tools\r\n console.log(`[executeWithTools] Executing ${toolUseBlocks.length} tool(s)`);\r\n const toolResults: ToolResult[] = [];\r\n\r\n for (const toolUseBlock of toolUseBlocks) {\r\n if (toolUseBlock.type !== 'tool_use') continue;\r\n\r\n const toolUse: ToolUse = {\r\n type: 'tool_use',\r\n id: (toolUseBlock as any).id,\r\n name: (toolUseBlock as any).name,\r\n input: (toolUseBlock as any).input,\r\n };\r\n\r\n console.log(`[executeWithTools] Tool: ${toolUse.name}`);\r\n const result = await executeTool(toolUse);\r\n toolResults.push(result);\r\n\r\n // Stream tool result\r\n if (onChunk) {\r\n onChunk(`\\n[Tool: ${toolUse.name}] ${result.content.substring(0, 100)}${result.content.length > 100 ? '...' : ''}\\n`);\r\n }\r\n }\r\n\r\n // Add assistant message with tool_use\r\n messages.push({\r\n role: 'assistant',\r\n content: response.content as any,\r\n });\r\n\r\n // Add tool results as user message\r\n messages.push({\r\n role: 'user',\r\n content: toolResults as any,\r\n });\r\n\r\n // Continue to next iteration\r\n }\r\n\r\n // Reached max iterations\r\n console.warn(`[executeWithTools] Reached max iterations (${MAX_ITERATIONS})`);\r\n return {\r\n content: fullTextContent,\r\n usage: {\r\n inputTokens: totalInputTokens,\r\n outputTokens: totalOutputTokens,\r\n },\r\n stopReason: 'max_tokens',\r\n };\r\n}\r\n\r\n/**\r\n * Execute agent via API with full lifecycle\r\n */\r\nexport async function executeAgentAPI(\r\n agentType: string,\r\n agentId: string,\r\n model: string,\r\n prompt: string,\r\n systemPrompt?: string,\r\n messages?: Array<{ role: string; content: string }>, // Sprint 4: Conversation forking\r\n maxTokens?: number, // Sprint 6: Configurable token limit\r\n tools?: any[] // Tool definitions for agent capabilities\r\n): Promise<{ success: boolean; output: string; usage: any; error?: string }> {\r\n // Start heartbeat monitoring (declare at function scope for error handling)\r\n let heartbeatInterval: NodeJS.Timeout | null = null;\r\n const taskId = process.env.TASK_ID;\r\n\r\n // Bug #6 Fix: Read Redis connection parameters from process.env and interpolate in TypeScript\r\n const redisHost = process.env.CFN_REDIS_HOST || 'cfn-redis';\r\n const redisPort = process.env.CFN_REDIS_PORT || '6379';\r\n\r\n try {\r\n console.log(`[anthropic-client] Executing agent: ${agentType}`);\r\n console.log(`[anthropic-client] Agent ID: ${agentId}`);\r\n if (messages && messages.length > 1) {\r\n console.log(`[anthropic-client] Continuing conversation (${messages.length} messages)`);\r\n }\r\n console.log('');\r\n\r\n if (taskId) {\r\n heartbeatInterval = setInterval(async () => {\r\n try {\r\n await execAsync(`redis-cli -h ${redisHost} -p ${redisPort} hset \"swarm:${taskId}:agent:${agentId}\" heartbeat \"${Date.now()}\" status \"working\"`);\r\n } catch (err) {\r\n console.error('[heartbeat] Error sending heartbeat:', err);\r\n }\r\n }, 30000); // Every 30 seconds\r\n\r\n console.log(`[heartbeat] Monitoring started for agent ${agentId} (30s interval)`);\r\n }\r\n\r\n let fullOutput = '';\r\n\r\n // If tools provided, use agentic loop with tool execution\r\n // Otherwise use simple streaming\r\n let response: MessageResponse;\r\n\r\n if (tools && tools.length > 0) {\r\n console.log(`[anthropic-client] Tools enabled: ${tools.map(t => t.name).join(', ')}`);\r\n response = await executeWithTools(\r\n {\r\n model,\r\n prompt,\r\n systemPrompt,\r\n messages,\r\n maxTokens,\r\n tools\r\n },\r\n (chunk) => {\r\n process.stdout.write(chunk);\r\n fullOutput += chunk;\r\n }\r\n );\r\n } else {\r\n response = await sendMessage(\r\n {\r\n model,\r\n prompt,\r\n systemPrompt,\r\n stream: true,\r\n messages,\r\n maxTokens,\r\n },\r\n (chunk) => {\r\n process.stdout.write(chunk);\r\n fullOutput += chunk;\r\n }\r\n );\r\n }\r\n\r\n console.log('\\n');\r\n console.log('=== Agent Execution Complete ===');\r\n console.log(`Input tokens: ${response.usage.inputTokens}`);\r\n console.log(`Output tokens: ${response.usage.outputTokens}`);\r\n console.log(`Stop reason: ${response.stopReason}`);\r\n\r\n // Stop heartbeat and send final status\r\n if (heartbeatInterval) {\r\n clearInterval(heartbeatInterval);\r\n\r\n if (taskId) {\r\n await execAsync(`redis-cli -h ${redisHost} -p ${redisPort} hset \"swarm:${taskId}:agent:${agentId}\" heartbeat \"${Date.now()}\" status \"complete\"`);\r\n console.log(`[heartbeat] Monitoring stopped - agent ${agentId} complete`);\r\n }\r\n }\r\n\r\n return {\r\n success: true,\r\n output: response.content,\r\n usage: response.usage,\r\n };\r\n } catch (error) {\r\n console.error('[anthropic-client] Error:', error);\r\n\r\n // Stop heartbeat and send error status\r\n if (heartbeatInterval) {\r\n clearInterval(heartbeatInterval);\r\n\r\n if (taskId) {\r\n try {\r\n await execAsync(`redis-cli -h ${redisHost} -p ${redisPort} hset \"swarm:${taskId}:agent:${agentId}\" heartbeat \"${Date.now()}\" status \"error\"`);\r\n console.log(`[heartbeat] Monitoring stopped - agent ${agentId} error`);\r\n } catch (err) {\r\n // Ignore heartbeat errors during error handling\r\n }\r\n }\r\n }\r\n\r\n return {\r\n success: false,\r\n output: '',\r\n usage: { inputTokens: 0, outputTokens: 0 },\r\n error: error instanceof Error ? error.message : String(error),\r\n };\r\n }\r\n}\r\n"],"names":["Anthropic","fs","path","exec","promisify","executeTool","execAsync","getAPIConfig","envProvider","process","env","CLAUDE_API_PROVIDER","provider","apiKey","ZAI_API_KEY","ANTHROPIC_API_KEY","baseURL","ZAI_BASE_URL","KIMI_API_KEY","KIMI_BASE_URL","OPENROUTER_API_KEY","OPENROUTER_BASE_URL","configPath","join","config","JSON","parse","readFile","createClient","Error","clientOptions","timeout","maxRetries","mapModelName","agentModel","zaiModelMap","haiku","sonnet","opus","modelMap","getFallbackModel","model","sendMessage","options","onChunk","client","maxTokens","temperature","enableStreaming","stream","console","log","messages","map","m","role","content","prompt","lastError","attempts","maxAttempts","currentModel","requestParams","max_tokens","systemPrompt","system","tools","length","fullContent","inputTokens","outputTokens","stopReason","create","event","type","message","usage","input_tokens","text","delta","output_tokens","stop_reason","response","filter","block","error","warn","String","executeWithTools","totalInputTokens","totalOutputTokens","fullTextContent","MAX_ITERATIONS","iteration","textBlocks","toolUseBlocks","toolResults","toolUseBlock","toolUse","id","name","input","result","push","substring","executeAgentAPI","agentType","agentId","heartbeatInterval","taskId","TASK_ID","redisHost","CFN_REDIS_HOST","redisPort","CFN_REDIS_PORT","setInterval","Date","now","err","fullOutput","t","chunk","stdout","write","clearInterval","success","output"],"mappings":"AAAA;;;;;CAKC,GAED,OAAOA,eAAe,oBAAoB;AAC1C,OAAOC,QAAQ,cAAc;AAC7B,OAAOC,UAAU,OAAO;AACxB,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,WAAW,QAAuC,qBAAqB;AAEhF,MAAMC,YAAYF,UAAUD;AA4B5B;;CAEC,GACD,OAAO,eAAeI;IACpB,6BAA6B;IAC7B,MAAMC,cAAcC,QAAQC,GAAG,CAACC,mBAAmB;IAEnD,IAAIH,gBAAgB,OAAO;QACzB,OAAO;YACLI,UAAU;YACVC,QAAQJ,QAAQC,GAAG,CAACI,WAAW,IAAIL,QAAQC,GAAG,CAACK,iBAAiB;YAChEC,SAASP,QAAQC,GAAG,CAACO,YAAY,IAAI;QACvC;IACF;IAEA,IAAIT,gBAAgB,QAAQ;QAC1B,OAAO;YACLI,UAAU;YACVC,QAAQJ,QAAQC,GAAG,CAACQ,YAAY;YAChCF,SAASP,QAAQC,GAAG,CAACS,aAAa,IAA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GAAGY,OAAOF;QACzD;IACF;AACF"}
|
|
@@ -1,118 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import * as fs from "fs/promises";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import Ajv from "ajv";
|
|
4
|
+
import * as lodash from "lodash";
|
|
5
|
+
let ConfigManager = class ConfigManager {
|
|
6
|
+
static _instance = null;
|
|
7
|
+
configPath;
|
|
8
|
+
schemaPath;
|
|
9
|
+
ajv;
|
|
10
|
+
constructor(){
|
|
11
|
+
this.configPath = path.join(process.env.HOME || "", ".claude-flow-config.json");
|
|
12
|
+
this.schemaPath = path.join(__dirname, "../../.claude/skills/config-management/config.json");
|
|
13
|
+
this.ajv = new Ajv();
|
|
7
14
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
+
static getInstance() {
|
|
16
|
+
if (!ConfigManager._instance) {
|
|
17
|
+
ConfigManager._instance = new ConfigManager();
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
return ConfigManager._instance;
|
|
20
|
+
}
|
|
21
|
+
async readConfig() {
|
|
22
|
+
try {
|
|
23
|
+
const configContent = await fs.readFile(this.configPath, "utf-8");
|
|
24
|
+
return JSON.parse(configContent);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
// If config doesn't exist, create from schema
|
|
27
|
+
return this.resetToDefaults();
|
|
22
28
|
}
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
}
|
|
30
|
+
async writeConfig(config) {
|
|
31
|
+
const schemaContent = await fs.readFile(this.schemaPath, "utf-8");
|
|
32
|
+
const schema = JSON.parse(schemaContent);
|
|
33
|
+
const validate = this.ajv.compile(schema);
|
|
34
|
+
if (!validate(config)) {
|
|
35
|
+
throw new Error("Invalid configuration: " + this.ajv.errorsText(validate.errors));
|
|
25
36
|
}
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
var __generator = this && this.__generator || function(thisArg, body) {
|
|
30
|
-
var _ = {
|
|
31
|
-
label: 0,
|
|
32
|
-
sent: function() {
|
|
33
|
-
if (t[0] & 1) throw t[1];
|
|
34
|
-
return t[1];
|
|
35
|
-
},
|
|
36
|
-
trys: [],
|
|
37
|
-
ops: []
|
|
38
|
-
}, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
39
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
40
|
-
return this;
|
|
41
|
-
}), g;
|
|
42
|
-
function verb(n) {
|
|
43
|
-
return function(v) {
|
|
44
|
-
return step([
|
|
45
|
-
n,
|
|
46
|
-
v
|
|
47
|
-
]);
|
|
48
|
-
};
|
|
37
|
+
await fs.writeFile(this.configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
49
38
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
];
|
|
58
|
-
switch(op[0]){
|
|
59
|
-
case 0:
|
|
60
|
-
case 1:
|
|
61
|
-
t = op;
|
|
62
|
-
break;
|
|
63
|
-
case 4:
|
|
64
|
-
_.label++;
|
|
65
|
-
return {
|
|
66
|
-
value: op[1],
|
|
67
|
-
done: false
|
|
68
|
-
};
|
|
69
|
-
case 5:
|
|
70
|
-
_.label++;
|
|
71
|
-
y = op[1];
|
|
72
|
-
op = [
|
|
73
|
-
0
|
|
74
|
-
];
|
|
75
|
-
continue;
|
|
76
|
-
case 7:
|
|
77
|
-
op = _.ops.pop();
|
|
78
|
-
_.trys.pop();
|
|
79
|
-
continue;
|
|
80
|
-
default:
|
|
81
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
82
|
-
_ = 0;
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
86
|
-
_.label = op[1];
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
90
|
-
_.label = t[1];
|
|
91
|
-
t = op;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
if (t && _.label < t[2]) {
|
|
95
|
-
_.label = t[2];
|
|
96
|
-
_.ops.push(op);
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
if (t[2]) _.ops.pop();
|
|
100
|
-
_.trys.pop();
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
op = body.call(thisArg, _);
|
|
104
|
-
} catch (e) {
|
|
105
|
-
op = [
|
|
106
|
-
6,
|
|
107
|
-
e
|
|
108
|
-
];
|
|
109
|
-
y = 0;
|
|
110
|
-
} finally{
|
|
111
|
-
f = t = 0;
|
|
39
|
+
async getValue(keyPath) {
|
|
40
|
+
const config = await this.readConfig();
|
|
41
|
+
const value = lodash.get(config, keyPath);
|
|
42
|
+
if (value === undefined) {
|
|
43
|
+
// Check if it's a custom key path not in the schema
|
|
44
|
+
const customConfig = await this.readCustomConfig();
|
|
45
|
+
return lodash.get(customConfig, keyPath);
|
|
112
46
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
async readCustomConfig() {
|
|
50
|
+
try {
|
|
51
|
+
const customConfigPath = path.join(process.env.HOME || "", ".claude-flow-custom-config.json");
|
|
52
|
+
const customConfigContent = await fs.readFile(customConfigPath, "utf-8");
|
|
53
|
+
return JSON.parse(customConfigContent);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
// If custom config doesn't exist or can't be read, return empty object
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async set(key, value) {
|
|
60
|
+
const config = await this.readConfig();
|
|
61
|
+
// Type assertion to handle full object
|
|
62
|
+
if (typeof value === "object" && value !== null) {
|
|
63
|
+
config[key] = value;
|
|
64
|
+
} else {
|
|
65
|
+
throw new Error("Invalid configuration value");
|
|
66
|
+
}
|
|
67
|
+
await this.writeConfig(config);
|
|
68
|
+
}
|
|
69
|
+
async getAll() {
|
|
70
|
+
return this.readConfig();
|
|
71
|
+
}
|
|
72
|
+
async resetToDefaults() {
|
|
73
|
+
const schemaContent = await fs.readFile(this.schemaPath, "utf-8");
|
|
74
|
+
const schema = JSON.parse(schemaContent);
|
|
75
|
+
// Extract default values from the schema
|
|
76
|
+
const defaultConfig = {
|
|
77
|
+
redis: {
|
|
78
|
+
host: schema.properties.redis.properties.host.default,
|
|
79
|
+
port: schema.properties.redis.properties.port.default
|
|
80
|
+
},
|
|
81
|
+
agent: {
|
|
82
|
+
default_strategy: schema.properties.agent.properties.default_strategy.default,
|
|
83
|
+
max_concurrent_agents: schema.properties.agent.properties.max_concurrent_agents.default,
|
|
84
|
+
log_level: schema.properties.agent.properties.log_level.default
|
|
85
|
+
},
|
|
86
|
+
security: {
|
|
87
|
+
enabled: schema.properties.security.properties.enabled.default,
|
|
88
|
+
max_retry_attempts: schema.properties.security.properties.max_retry_attempts.default
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
await this.writeConfig(defaultConfig);
|
|
92
|
+
return defaultConfig;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
export default ConfigManager;
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=config-manager.js.mapop[1] : void 0,
|
|
116
98
|
done: true
|
|
117
99
|
};
|
|
118
100
|
}
|
package/dist/cli/index.js
CHANGED
|
@@ -86,6 +86,10 @@ import { agentCommand } from './agent-command.js';
|
|
|
86
86
|
case '--debug':
|
|
87
87
|
options.debug = true;
|
|
88
88
|
break;
|
|
89
|
+
case '--provider':
|
|
90
|
+
options.provider = value;
|
|
91
|
+
i++;
|
|
92
|
+
break;
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
return {
|
|
@@ -112,6 +116,9 @@ Examples:
|
|
|
112
116
|
# Spawn an agent
|
|
113
117
|
npx claude-flow-novice agent coder --context "Implement feature"
|
|
114
118
|
|
|
119
|
+
# Spawn an agent with ZAI provider
|
|
120
|
+
npx claude-flow-novice agent coder --provider zai --context "Implement feature"
|
|
121
|
+
|
|
115
122
|
# List available agents
|
|
116
123
|
npx claude-flow-novice agent --list
|
|
117
124
|
|
|
@@ -139,6 +146,10 @@ For more information:
|
|
|
139
146
|
const { command, agentType, options } = parseArgs(args);
|
|
140
147
|
switch(command){
|
|
141
148
|
case 'agent':
|
|
149
|
+
// Set provider environment variable if specified
|
|
150
|
+
if (options.provider) {
|
|
151
|
+
process.env.CLAUDE_API_PROVIDER = options.provider;
|
|
152
|
+
}
|
|
142
153
|
await agentCommand(agentType, options);
|
|
143
154
|
break;
|
|
144
155
|
default:
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\r\n/**\r\n * CLI Entry Point - v2.1\r\n *\r\n * Handles agent spawning commands with memory management:\r\n * npx claude-flow-novice agent <type> [options]\r\n */\r\n\r\n// Load environment variables from .env file\r\nimport 'dotenv/config';\r\n\r\n// Apply safe memory defaults if not configured\r\nif (!process.env.NODE_OPTIONS) {\r\n // Set conservative 8GB limit (reduced from default 16GB)\r\n process.env.NODE_OPTIONS = '--max-old-space-size=8192';\r\n} else if (!process.env.NODE_OPTIONS.includes('max-old-space-size')) {\r\n // Append memory limit to existing NODE_OPTIONS\r\n process.env.NODE_OPTIONS += ' --max-old-space-size=8192';\r\n}\r\n\r\n// Enable memory profiling in development/debug mode\r\nif (process.env.NODE_ENV === 'development' || process.env.CLAUDE_DEBUG) {\r\n if (!process.env.NODE_OPTIONS.includes('inspect')) {\r\n process.env.NODE_OPTIONS += ' --inspect=0.0.0.0:9229';\r\n }\r\n if (!process.env.NODE_OPTIONS.includes('heap-prof')) {\r\n process.env.NODE_OPTIONS += ' --heap-prof';\r\n }\r\n}\r\n\r\nimport { VERSION } from '../core/index.js';\r\nimport { agentCommand, AgentCommandOptions } from './agent-command.js';\r\n\r\n/**\r\n * Parse command line arguments\r\n */\r\nfunction parseArgs(args: string[]): { command: string; agentType?: string; options: AgentCommandOptions } {\r\n const command = args[0] || 'help';\r\n const agentType = args[1] && !args[1].startsWith('--') ? args[1] : undefined;\r\n const options: AgentCommandOptions = {};\r\n\r\n // Parse options and capture positional context argument\r\n for (let i = agentType ? 2 : 1; i < args.length; i++) {\r\n const arg = args[i];\r\n const value = args[i + 1];\r\n\r\n // Capture non-flag positional arguments as context (before any flags)\r\n if (!arg.startsWith('--') && !options.context) {\r\n options.context = arg;\r\n continue;\r\n }\r\n\r\n switch (arg) {\r\n case '--task-id':\r\n options.taskId = value;\r\n i++;\r\n break;\r\n case '--iteration':\r\n options.iteration = parseInt(value, 10);\r\n i++;\r\n break;\r\n case '--agent-id':\r\n options.agentId = value;\r\n i++;\r\n break;\r\n case '--context':\r\n options.context = value;\r\n i++;\r\n break;\r\n case '--mode':\r\n options.mode = value;\r\n i++;\r\n break;\r\n case '--priority':\r\n options.priority = parseInt(value, 10);\r\n i++;\r\n break;\r\n case '--parent-task-id':\r\n options.parentTaskId = value;\r\n i++;\r\n break;\r\n case '--list':\r\n options.list = true;\r\n break;\r\n case '--help':\r\n case '-h':\r\n options.help = true;\r\n break;\r\n case '--memory-limit':\r\n options.memoryLimit = parseInt(value, 10);\r\n i++;\r\n break;\r\n case '--enable-profiling':\r\n options.enableProfiling = true;\r\n break;\r\n case '--debug':\r\n options.debug = true;\r\n break;\r\n }\r\n }\r\n\r\n return { command, agentType, options };\r\n}\r\n\r\n/**\r\n * Display main CLI help\r\n */\r\nfunction displayHelp(): void {\r\n console.log(`\r\nClaude Flow Novice CLI v${VERSION}\r\n\r\nUsage:\r\n npx claude-flow-novice <command> [options]\r\n\r\nCommands:\r\n agent <type> [options] Spawn an agent for task execution\r\n --version Show version number\r\n --help Show this help message\r\n\r\nExamples:\r\n # Spawn an agent\r\n npx claude-flow-novice agent coder --context \"Implement feature\"\r\n\r\n # List available agents\r\n npx claude-flow-novice agent --list\r\n\r\n # Show version\r\n npx claude-flow-novice --version\r\n\r\nFor more information:\r\n https://github.com/yourusername/claude-flow-novice\r\n`);\r\n}\r\n\r\n/**\r\n * Main CLI entry point\r\n */\r\nasync function main() {\r\n const args = process.argv.slice(2);\r\n\r\n // Handle version flag\r\n if (args.includes('--version') || args.includes('-v')) {\r\n console.log(`Claude Flow Novice v${VERSION}`);\r\n return;\r\n }\r\n\r\n // Handle help flag\r\n if (args.length === 0 || args.includes('--help') || args.includes('-h')) {\r\n displayHelp();\r\n return;\r\n }\r\n\r\n const { command, agentType, options } = parseArgs(args);\r\n\r\n switch (command) {\r\n case 'agent':\r\n await agentCommand(agentType, options);\r\n break;\r\n\r\n default:\r\n console.error(`Unknown command: ${command}`);\r\n console.log('Run with --help for usage information');\r\n process.exit(1);\r\n }\r\n}\r\n\r\n// Run CLI\r\nmain().catch((error) => {\r\n console.error('[claude-flow-novice] Fatal error:', error);\r\n process.exit(1);\r\n});\r\n"],"names":["process","env","NODE_OPTIONS","includes","NODE_ENV","CLAUDE_DEBUG","VERSION","agentCommand","parseArgs","args","command","agentType","startsWith","undefined","options","i","length","arg","value","context","taskId","iteration","parseInt","agentId","mode","priority","parentTaskId","list","help","memoryLimit","enableProfiling","debug","displayHelp","console","log","main","argv","slice","error","exit","catch"],"mappings":";AACA;;;;;CAKC,GAED,4CAA4C;AAC5C,OAAO,gBAAgB;AAEvB,+CAA+C;AAC/C,IAAI,CAACA,QAAQC,GAAG,CAACC,YAAY,EAAE;IAC7B,yDAAyD;IACzDF,QAAQC,GAAG,CAACC,YAAY,GAAG;AAC7B,O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GL;gBAClBH;gBACA;YACF,KAAK;gBACHD,QAAQK,OAAO,GAAGD;gBAClBH;gBACA;YACF,KAAK;gBACHD,QAAQU,IAAI,GAAGN;gBACfH;gBACA;YACF,KAAK;gBACHD,QAAQW,QAAQ,GAAGH,SAASJ,OAAO;gBACnCH;gBACA;YACF,KAAK;gBACHD,QAAQY,YAAY,GAAGR;gBACvBH;gBACA;YACF,KAAK;gBACHD,QAAQa,IAAI,GAAG;gBACf;YACF,KAAK;YACL,KAAK;gBACHb,QAAQc,IAAI,GAAG;gBACf;YACF,KAAK;gBACHd,QAAQe,WAAW,GAAGP,SAASJ,OAAO;gBACtCH;gBACA;YACF,KAAK;gBACHD,QAAQgB,eAAe,GAAG;gBAC1B;YACF,KAAK;gBACHhB,QAAQiB,KAAK,GAAG;gBAChB;QACJ;IACF;IAEA,OAAO;
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\r\n/**\r\n * CLI Entry Point - v2.1\r\n *\r\n * Handles agent spawning commands with memory management:\r\n * npx claude-flow-novice agent <type> [options]\r\n */\r\n\r\n// Load environment variables from .env file\r\nimport 'dotenv/config';\r\n\r\n// Apply safe memory defaults if not configured\r\nif (!process.env.NODE_OPTIONS) {\r\n // Set conservative 8GB limit (reduced from default 16GB)\r\n process.env.NODE_OPTIONS = '--max-old-space-size=8192';\r\n} else if (!process.env.NODE_OPTIONS.includes('max-old-space-size')) {\r\n // Append memory limit to existing NODE_OPTIONS\r\n process.env.NODE_OPTIONS += ' --max-old-space-size=8192';\r\n}\r\n\r\n// Enable memory profiling in development/debug mode\r\nif (process.env.NODE_ENV === 'development' || process.env.CLAUDE_DEBUG) {\r\n if (!process.env.NODE_OPTIONS.includes('inspect')) {\r\n process.env.NODE_OPTIONS += ' --inspect=0.0.0.0:9229';\r\n }\r\n if (!process.env.NODE_OPTIONS.includes('heap-prof')) {\r\n process.env.NODE_OPTIONS += ' --heap-prof';\r\n }\r\n}\r\n\r\nimport { VERSION } from '../core/index.js';\r\nimport { agentCommand, AgentCommandOptions } from './agent-command.js';\r\n\r\n/**\r\n * Parse command line arguments\r\n */\r\nfunction parseArgs(args: string[]): { command: string; agentType?: string; options: AgentCommandOptions } {\r\n const command = args[0] || 'help';\r\n const agentType = args[1] && !args[1].startsWith('--') ? args[1] : undefined;\r\n const options: AgentCommandOptions = {};\r\n\r\n // Parse options and capture positional context argument\r\n for (let i = agentType ? 2 : 1; i < args.length; i++) {\r\n const arg = args[i];\r\n const value = args[i + 1];\r\n\r\n // Capture non-flag positional arguments as context (before any flags)\r\n if (!arg.startsWith('--') && !options.context) {\r\n options.context = arg;\r\n continue;\r\n }\r\n\r\n switch (arg) {\r\n case '--task-id':\r\n options.taskId = value;\r\n i++;\r\n break;\r\n case '--iteration':\r\n options.iteration = parseInt(value, 10);\r\n i++;\r\n break;\r\n case '--agent-id':\r\n options.agentId = value;\r\n i++;\r\n break;\r\n case '--context':\r\n options.context = value;\r\n i++;\r\n break;\r\n case '--mode':\r\n options.mode = value;\r\n i++;\r\n break;\r\n case '--priority':\r\n options.priority = parseInt(value, 10);\r\n i++;\r\n break;\r\n case '--parent-task-id':\r\n options.parentTaskId = value;\r\n i++;\r\n break;\r\n case '--list':\r\n options.list = true;\r\n break;\r\n case '--help':\r\n case '-h':\r\n options.help = true;\r\n break;\r\n case '--memory-limit':\r\n options.memoryLimit = parseInt(value, 10);\r\n i++;\r\n break;\r\n case '--enable-profiling':\r\n options.enableProfiling = true;\r\n break;\r\n case '--debug':\r\n options.debug = true;\r\n break;\r\n case '--provider':\r\n options.provider = value;\r\n i++;\r\n break;\r\n }\r\n }\r\n\r\n return { command, agentType, options };\r\n}\r\n\r\n/**\r\n * Display main CLI help\r\n */\r\nfunction displayHelp(): void {\r\n console.log(`\r\nClaude Flow Novice CLI v${VERSION}\r\n\r\nUsage:\r\n npx claude-flow-novice <command> [options]\r\n\r\nCommands:\r\n agent <type> [options] Spawn an agent for task execution\r\n --version Show version number\r\n --help Show this help message\r\n\r\nExamples:\r\n # Spawn an agent\r\n npx claude-flow-novice agent coder --context \"Implement feature\"\r\n\r\n # Spawn an agent with ZAI provider\r\n npx claude-flow-novice agent coder --provider zai --context \"Implement feature\"\r\n\r\n # List available agents\r\n npx claude-flow-novice agent --list\r\n\r\n # Show version\r\n npx claude-flow-novice --version\r\n\r\nFor more information:\r\n https://github.com/yourusername/claude-flow-novice\r\n`);\r\n}\r\n\r\n/**\r\n * Main CLI entry point\r\n */\r\nasync function main() {\r\n const args = process.argv.slice(2);\r\n\r\n // Handle version flag\r\n if (args.includes('--version') || args.includes('-v')) {\r\n console.log(`Claude Flow Novice v${VERSION}`);\r\n return;\r\n }\r\n\r\n // Handle help flag\r\n if (args.length === 0 || args.includes('--help') || args.includes('-h')) {\r\n displayHelp();\r\n return;\r\n }\r\n\r\n const { command, agentType, options } = parseArgs(args);\r\n\r\n switch (command) {\r\n case 'agent':\r\n // Set provider environment variable if specified\r\n if (options.provider) {\r\n process.env.CLAUDE_API_PROVIDER = options.provider;\r\n }\r\n await agentCommand(agentType, options);\r\n break;\r\n\r\n default:\r\n console.error(`Unknown command: ${command}`);\r\n console.log('Run with --help for usage information');\r\n process.exit(1);\r\n }\r\n}\r\n\r\n// Run CLI\r\nmain().catch((error) => {\r\n console.error('[claude-flow-novice] Fatal error:', error);\r\n process.exit(1);\r\n});\r\n"],"names":["process","env","NODE_OPTIONS","includes","NODE_ENV","CLAUDE_DEBUG","VERSION","agentCommand","parseArgs","args","command","agentType","startsWith","undefined","options","i","length","arg","value","context","taskId","iteration","parseInt","agentId","mode","priority","parentTaskId","list","help","memoryLimit","enableProfiling","debug","provider","displayHelp","console","log","main","argv","slice","CLAUDE_API_PROVIDER","error","exit","catch"],"mappings":";AACA;;;;;CAKC,GAED,4CAA4C;AAC5C,OAAO,gBAAgB;AAEvB,+CAA+C;AAC/C,IAAI,CAACA,QAAQC,GAAG,CAACC,YAAY,EAAE;IAC7B,yDAAyD;IACzDF,QAAQC,GAAG,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