claude-flow-novice 2.5.2 → 2.8.1
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/adaptive-context/cfn-v3-reflection.json +21 -0
- package/.claude/agents/AGENT_LIFECYCLE.md +495 -0
- package/.claude/agents/CLAUDE.md +1002 -1233
- package/.claude/agents/accessibility-advocate.md +457 -0
- package/.claude/agents/agent-principles/README.md +226 -226
- package/.claude/agents/agent-principles/agent-type-guidelines.md +10 -0
- package/.claude/agents/agent-principles/format-selection.md +10 -0
- package/.claude/agents/agent-principles/phase4-template-optimization.md +502 -494
- package/.claude/agents/agent-principles/prompt-engineering.md +8 -0
- package/.claude/agents/agent-principles/quality-metrics.md +8 -0
- package/.claude/agents/analysis/code-analyzer.md +7 -17
- package/.claude/agents/analysis/code-review/analyze-code-quality.md +2 -104
- package/.claude/agents/analysis/perf-analyzer.md +2 -196
- package/.claude/agents/context/context-curator.md +78 -84
- package/.claude/agents/context/context-reflector.md +27 -81
- package/.claude/agents/coordinators/README.md +42 -0
- package/.claude/agents/coordinators/cfn-v3-coordinator.md +440 -0
- package/.claude/agents/{product-owner-team → coordinators}/cto-agent.md +154 -187
- package/.claude/agents/coordinators/multi-sprint-coordinator.md +50 -0
- package/.claude/agents/{product-owner-team → coordinators}/product-owner-agent.md +6 -39
- package/.claude/agents/{cfn-loop → coordinators}/product-owner.md +72 -17
- package/.claude/agents/core-agents/reviewer.md +114 -135
- package/.claude/agents/custom/agent-builder.md +637 -0
- package/.claude/agents/developers/README.md +69 -0
- package/.claude/agents/developers/backend-dev.md +77 -0
- package/.claude/agents/{core-agents → developers}/coder.md +131 -26
- package/.claude/agents/developers/react-frontend-engineer.md +121 -0
- package/.claude/agents/{frontend → developers}/state-architect.md +1 -0
- package/.claude/agents/{frontend → developers}/ui-designer.md +1 -0
- package/.claude/agents/development/backend/dev-backend-api.md +0 -29
- package/.claude/agents/development/npm-package-specialist.md +355 -347
- package/.claude/agents/documentation/api-docs/docs-api-openapi.md +8 -0
- package/.claude/agents/documentation/api-docs.md +8 -0
- package/.claude/agents/github/github-commit-agent.md +125 -117
- package/.claude/agents/goal/goal-planner.md +8 -0
- package/.claude/agents/infrastructure/README.md +100 -0
- package/.claude/agents/{specialized → infrastructure}/devops-engineer.md +131 -150
- package/.claude/agents/planners/README.md +94 -0
- package/.claude/agents/{core-agents → planners}/analyst.md +1 -22
- package/.claude/agents/{planning-team → planners}/api-designer-persona.md +8 -0
- package/.claude/agents/{core-agents → planners}/architect.md +7 -20
- package/.claude/agents/{core-agents → planners}/planner.md +0 -21
- package/.claude/agents/{planning-team → planners}/security-architect-persona.md +8 -28
- package/.claude/agents/{planning-team → planners}/system-architect-persona.md +6 -38
- package/.claude/agents/{architecture → planners}/system-architect.md +12 -17
- package/.claude/agents/product-owner-team/accessibility-advocate-persona.md +132 -161
- package/.claude/agents/product-owner-team/power-user-persona.md +149 -182
- package/.claude/agents/retrospective-analyst.md +84 -0
- package/.claude/agents/reviewers/README.md +58 -0
- package/.claude/agents/{analysis → reviewers}/code-quality-validator.md +8 -17
- package/.claude/agents/reviewers/reviewer.md +181 -0
- package/.claude/agents/sparc/architecture.md +6 -25
- package/.claude/agents/sparc/pseudocode.md +6 -0
- package/.claude/agents/sparc/refinement.md +6 -0
- package/.claude/agents/sparc/specification.md +1 -0
- package/.claude/agents/specialists/README.md +60 -0
- package/.claude/agents/{core-agents → specialists}/base-template-generator.md +8 -21
- package/.claude/agents/{specialized → specialists}/cli-agent-optimizer.md +1 -1
- package/.claude/agents/{specialized → specialists}/code-booster.md +1 -0
- package/.claude/agents/{consensus → specialists}/consensus-builder.md +1 -17
- package/.claude/agents/{specialized/mobile → specialists}/mobile-dev.md +0 -20
- package/.claude/agents/{core-agents → specialists}/performance-benchmarker.md +134 -148
- package/.claude/agents/{specialized → specialists}/rust-developer.md +1 -20
- package/.claude/agents/{specialized → specialists}/rust-enterprise-developer.md +1 -20
- package/.claude/agents/{specialized → specialists}/rust-mvp-developer.md +1 -20
- package/.claude/agents/{core-agents → specialists}/security-manager.md +68 -88
- package/.claude/agents/{security → specialists}/security-specialist-existing.md +6 -57
- package/.claude/agents/{security → specialists}/security-specialist.md +6 -30
- package/.claude/agents/{specialized/mobile → specialists}/spec-mobile-react-native.md +2 -21
- package/.claude/agents/testers/README.md +94 -0
- package/.claude/agents/{testing → testers}/e2e/playwright-agent.md +1 -20
- package/.claude/agents/{testing → testers}/interaction-tester.md +1 -20
- package/.claude/agents/{testing → testers}/playwright-tester.md +1 -1
- package/.claude/agents/testers/tester.md +139 -0
- package/.claude/agents/testers/unit/tdd-london-swarm.md +49 -0
- package/.claude/agents/testers/validation/production-validator.md +33 -0
- package/.claude/agents-ignore/cfn-loop-coordinator.md +157 -0
- package/.claude/agents-ignore/cfn-loop-coordinator.md.backup +156 -0
- package/.claude/agents-ignore/coordinator.md.backup +182 -0
- package/.claude/agents-ignore/cost-savings-cfn-loop-coordinator.md +760 -0
- package/.claude/agents-ignore/cost-savings-coordinator.md +173 -0
- package/.claude/artifacts/ace-reflections/REFLECT-001-summary.json +39 -0
- package/.claude/artifacts/ace-reflections/sprint-7_$(date -u +/"%Y%m%d_%H%M%S/").json" +47 -0
- package/.claude/artifacts/reflection-merge-logs/cli-agent-spawning-v2.5.2-merge-report.md +61 -0
- package/.claude/commands/CFN_COORDINATOR_PARAMETERS.md +10 -10
- package/.claude/commands/cfn-loop-epic.md +43 -19
- package/.claude/commands/cfn-loop-single.md +3 -3
- package/.claude/commands/cfn-loop-sprints.md +1 -1
- package/.claude/commands/cfn-loop.md +45 -32
- package/.claude/commands/cfn-mode.md +20 -0
- package/.claude/commands/custom-routing-activate.md +37 -123
- package/.claude/commands/custom-routing-deactivate.md +27 -124
- package/.claude/commands/switch-api.md +41 -16
- package/.claude/commands/write-plan.md +104 -0
- package/.claude/data/cfn-loop.db +0 -0
- package/.claude/data/cfn_loop_logs.db +0 -0
- package/.claude/hooks/BACKUP_USAGE.md +243 -0
- package/.claude/hooks/post-edit-cfn-retrospective.sh +79 -0
- package/.claude/hooks/post-edit.sh +21 -0
- package/.claude/hooks/pre-edit-backup.sh +71 -0
- package/.claude/hooks/restore-from-backup.sh +37 -0
- package/.claude/prompts/cfn-loop-context.md +115 -0
- package/.claude/prompts/loop-specific/loop2.md +50 -0
- package/.claude/prompts/loop-specific/loop3.md +43 -0
- package/.claude/prompts/loop-specific/loop4.md +54 -0
- package/.claude/root-claude-distribute/CLAUDE.md +76 -2
- package/.claude/skills/ace-system/sprint-7-lessons.json +46 -0
- package/.claude/skills/ace-system/store-reflection.sh +33 -136
- package/.claude/skills/agent-discovery/SKILL.md +40 -0
- package/.claude/skills/agent-discovery/agents-registry-clean.json +0 -0
- package/.claude/skills/agent-discovery/agents-registry-fixed.json +19 -0
- package/.claude/skills/agent-discovery/agents-registry.json +718 -0
- package/.claude/skills/agent-discovery/discover-agents.py +175 -0
- package/.claude/skills/agent-discovery/discover-agents.sh +87 -0
- package/.claude/skills/agent-discovery/invoke-registry.sh +11 -0
- package/.claude/skills/agent-discovery/temp_script.py +0 -0
- package/.claude/skills/agent-execution/execute-agent.sh +126 -0
- package/.claude/skills/agent-output-processing/SKILL.md +359 -0
- package/.claude/skills/agent-selector/SKILL.md +90 -0
- package/.claude/skills/agent-selector/select-agents.sh +96 -0
- package/.claude/skills/agent-spawning/agent-selection-guide.md +1 -1
- package/.claude/skills/agent-swap/SKILL.md +36 -0
- package/.claude/skills/agent-swap/recommend-swap.sh +60 -0
- package/.claude/skills/api-validation/test-endpoints.sh +54 -0
- package/.claude/skills/automatic-memory-persistence/SKILL.md +73 -0
- package/.claude/skills/automatic-memory-persistence/persist-agent-output.sh +49 -0
- package/.claude/skills/automatic-memory-persistence/query-agent-history.sh +35 -0
- package/.claude/skills/automatic-memory-persistence/test-memory-persistence.sh +235 -0
- package/.claude/skills/cfn-loop-orchestration/README.md +41 -0
- package/.claude/skills/cfn-loop-orchestration/SKILL.md +299 -0
- package/.claude/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +228 -0
- package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +84 -0
- package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +71 -0
- package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +90 -0
- package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +87 -0
- package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +51 -0
- package/.claude/skills/cfn-loop-orchestration/inject-loop-context.sh +41 -0
- package/.claude/skills/cfn-loop-orchestration/monitor-execution.sh +156 -0
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +840 -0
- package/.claude/skills/cfn-loop-orchestration/security_utils.sh +99 -0
- package/.claude/skills/cfn-loop-orchestration/test-cfn-orchestration.sh +281 -0
- package/.claude/skills/cfn-loop-orchestration/test-edge-cases.sh +188 -0
- package/.claude/skills/cfn-loop-validation/SKILL.md +307 -217
- package/.claude/skills/complexity-estimator/SKILL.md +96 -0
- package/.claude/skills/complexity-estimator/estimate-complexity.sh +144 -0
- package/.claude/skills/context-pruner/SKILL.md +75 -0
- package/.claude/skills/context-pruner/prune-context.sh +73 -0
- package/.claude/skills/defense-in-depth/SKILL.md +133 -0
- package/.claude/skills/dependency-extractor/SKILL.md +35 -0
- package/.claude/skills/dependency-extractor/extract-dependencies.sh +66 -0
- package/.claude/skills/epic-decomposer/SKILL.md +44 -0
- package/.claude/skills/epic-decomposer/decompose-epic.sh +104 -0
- package/.claude/skills/improvement-recommender/SKILL.md +33 -0
- package/.claude/skills/improvement-recommender/recommend-improvements.sh +92 -0
- package/.claude/skills/intervention-detector/SKILL.md +39 -0
- package/.claude/skills/intervention-detector/detect-intervention.sh +111 -0
- package/.claude/skills/intervention-orchestrator/SKILL.md +43 -0
- package/.claude/skills/intervention-orchestrator/execute-intervention.sh +59 -0
- package/.claude/skills/loop2-output-processing/SKILL.md +163 -0
- package/.claude/skills/loop2-output-processing/execute-and-extract.sh +77 -0
- package/.claude/skills/loop2-output-processing/execute-and-extract.sh.backup +36 -0
- package/.claude/skills/loop2-output-processing/parse-feedback.sh +147 -0
- package/.claude/skills/loop2-output-processing/process-validator-output.sh +275 -0
- package/.claude/skills/loop2-output-processing/test-bug27-fix.sh +200 -0
- package/.claude/skills/loop2-output-processing/test-loop2-processing.sh +113 -0
- package/.claude/skills/loop3-output-processing/AGENT_COMPLETION_PROTOCOL.md +206 -0
- package/.claude/skills/loop3-output-processing/SKILL.md +421 -0
- package/.claude/skills/loop3-output-processing/calculate-confidence.sh +28 -0
- package/.claude/skills/loop3-output-processing/execute-and-extract.sh +85 -0
- package/.claude/skills/loop3-output-processing/parse-confidence.sh +31 -0
- package/.claude/skills/loop3-output-processing/test-agent-timeout.sh +327 -0
- package/.claude/skills/loop3-output-processing/test-loop3-processing.sh +155 -0
- package/.claude/skills/loop3-output-processing/verify-deliverables.sh +42 -0
- package/.claude/skills/pattern-extraction/SKILL.md +30 -0
- package/.claude/skills/pattern-extraction/extract-patterns.sh +80 -0
- package/.claude/skills/playbook/SKILL.md +113 -0
- package/.claude/skills/playbook/init-playbook.sh +54 -0
- package/.claude/skills/playbook/playbook.db +0 -0
- package/.claude/skills/playbook/query-playbook.sh +79 -0
- package/.claude/skills/playbook/update-playbook.sh +69 -0
- package/.claude/skills/playbook-auto-update/SKILL.md +29 -0
- package/.claude/skills/playbook-auto-update/auto-update-playbook.sh +86 -0
- package/.claude/skills/product-owner-decision/SKILL.md +332 -0
- package/.claude/skills/product-owner-decision/execute-decision.sh +176 -0
- package/.claude/skills/product-owner-decision/parse-decision.sh +66 -0
- package/.claude/skills/product-owner-decision/validate-deliverables.sh +82 -0
- package/.claude/skills/redis-coordination/AGENT_LOGGING.md +280 -0
- package/.claude/skills/redis-coordination/LOGGING.md +260 -0
- package/.claude/skills/redis-coordination/README.md +30 -29
- package/.claude/skills/redis-coordination/SKILL.md +685 -83
- package/.claude/skills/redis-coordination/agent-log.sh +124 -0
- package/.claude/skills/redis-coordination/analyze-task-complexity.sh +277 -0
- package/.claude/skills/redis-coordination/cfn-loop-exec.sh +468 -0
- package/.claude/skills/redis-coordination/collect-confidence-scores.sh +179 -0
- package/.claude/skills/redis-coordination/collect-results.sh +75 -0
- package/.claude/skills/redis-coordination/data/cfn-loop.db +0 -0
- package/.claude/skills/redis-coordination/demos/test-iteration-feedback.sh +320 -0
- package/.claude/skills/redis-coordination/{test-orchestrator.sh → demos/test-orchestrator.sh} +25 -0
- package/.claude/skills/redis-coordination/execute-product-owner-decision.sh +258 -0
- package/.claude/skills/redis-coordination/get-agent-timeout.sh +176 -176
- package/.claude/skills/redis-coordination/init-swarm.sh +6 -1
- package/.claude/skills/redis-coordination/invoke-waiting-mode.sh +106 -183
- package/.claude/skills/redis-coordination/invoke-waiting-mode.sh.backup-p7 +423 -0
- package/.claude/skills/redis-coordination/log-event.sh +109 -0
- package/.claude/skills/redis-coordination/monitor-cfn-violations.sh +391 -0
- package/.claude/skills/redis-coordination/orchestrate-cfn-loop-v3.sh +141 -0
- package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh +31 -933
- package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup +38 -0
- package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup-1761167675 +1672 -0
- package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup-p5 +1604 -0
- package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup-phase1 +1550 -0
- package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup-phase2 +1621 -0
- package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup-phase3 +1621 -0
- package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.bak +0 -0
- package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.broken +1627 -0
- package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.corrupted +80 -0
- package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.deprecated +1864 -0
- package/.claude/skills/redis-coordination/query-logs.sh +103 -0
- package/.claude/skills/redis-coordination/retrieve-context.sh +58 -0
- package/.claude/skills/redis-coordination/select-specialist-agent.sh +371 -0
- package/.claude/skills/redis-coordination/semantic-match-tfidf.py +252 -0
- package/.claude/skills/redis-coordination/send-heartbeat.sh +164 -72
- package/.claude/skills/redis-coordination/signal.sh +38 -0
- package/.claude/skills/redis-coordination/store-context.sh +86 -0
- package/.claude/skills/redis-coordination/store-epic-context.sh +123 -0
- package/.claude/skills/redis-coordination/test-context-injection.sh +354 -0
- package/.claude/skills/redis-coordination/test-timeout-enforcement.sh +513 -0
- package/.claude/skills/redis-coordination/tests/convert-line-endings.sh +15 -0
- package/.claude/skills/redis-coordination/tests/dlq-functionality-test.sh +101 -101
- package/.claude/skills/redis-coordination/tests/edge-cases-test.sh +98 -98
- package/.claude/skills/redis-coordination/tests/integration-test.sh +169 -169
- package/.claude/skills/redis-coordination/tests/retry-mechanism-test.sh +81 -81
- package/.claude/skills/redis-coordination/tests/run-test-suite.sh +91 -91
- package/.claude/skills/redis-coordination/tests/run-tests.sh +4 -0
- package/.claude/skills/redis-coordination/tests/test-primitives.sh +166 -0
- package/.claude/skills/redis-coordination/tests/test-utils.sh +53 -121
- package/.claude/skills/redis-coordination/tests/test_coordination_primitives.sh.deprecated +20 -0
- package/.claude/skills/redis-coordination/tests/test_utils.sh +49 -0
- package/.claude/skills/redis-coordination/v2_modularization/core_orchestration.sh +76 -0
- package/.claude/skills/redis-coordination/validate-parameters.sh +492 -0
- package/.claude/skills/retrospective-report/SKILL.md +31 -0
- package/.claude/skills/retrospective-report/generate-report.sh +101 -0
- package/.claude/skills/run-all-skill-tests.sh +124 -0
- package/.claude/skills/scope-simplifier/SKILL.md +37 -0
- package/.claude/skills/scope-simplifier/simplify-scope.sh +68 -0
- package/.claude/skills/simplified-agent-lifecycle/COST_ANALYSIS.md +49 -0
- package/.claude/skills/simplified-agent-lifecycle/DESIGN.md +98 -0
- package/.claude/skills/simplified-agent-lifecycle/MIGRATION_PLAN.md +74 -0
- package/.claude/skills/skill-builder/SKILL.md +910 -0
- package/.claude/skills/specialist-injection/SKILL.md +41 -0
- package/.claude/skills/specialist-injection/recommend-specialist.sh +57 -0
- package/.claude/skills/sprint-execution/SKILL.md +27 -0
- package/.claude/skills/sprint-execution/execute-sprint-task.sh +59 -0
- package/.claude/skills/sprint-execution/execute-sprint.sh +65 -0
- package/.claude/skills/sprint-planner/SKILL.md +37 -0
- package/.claude/skills/sprint-planner/plan-sprint.sh +85 -0
- package/.claude/skills/standardized-error-handling/SKILL.md +56 -0
- package/.claude/skills/standardized-error-handling/capture-agent-error.sh +87 -0
- package/.claude/skills/standardized-error-handling/test-error-handling.sh +166 -0
- package/.claude/skills/task-classifier/SKILL.md +94 -0
- package/.claude/skills/task-classifier/classify-task.sh +115 -0
- package/.claude/skills/validation-templates/SKILL.md +47 -0
- package/.claude/skills/validation-templates/content.json +38 -0
- package/.claude/skills/validation-templates/data.json +38 -0
- package/.claude/skills/validation-templates/design.json +38 -0
- package/.claude/skills/validation-templates/infrastructure.json +38 -0
- package/.claude/skills/validation-templates/research.json +38 -0
- package/.claude/skills/validation-templates/software.json +38 -0
- package/.claude/skills/webapp-testing/README.md +142 -0
- package/.claude/skills/webapp-testing/SCREENSHOT_NAMING_CONVENTION.md +547 -0
- package/.claude/skills/webapp-testing/SKILL.md +877 -0
- package/.claude/skills/webapp-testing/capture-screenshot.sh +238 -0
- package/.claude/skills/webapp-testing/cfn-loop-integration.sh +265 -0
- package/.claude/skills/webapp-testing/compare-screenshots.sh +199 -0
- package/.claude/skills/webapp-testing/init-storage.sh +150 -0
- package/.claude/skills/webapp-testing/set-baseline.sh +196 -0
- package/.claude/skills/webapp-testing/test-webapp-testing.sh +233 -0
- package/.claude/spawn-pattern-examples.md +3 -3
- package/CLAUDE.md +364 -16
- package/README.md +598 -251
- package/dist/agents/agent-loader.js +146 -165
- package/dist/agents/agent-loader.js.map +1 -1
- package/dist/cli/agent-command.js +153 -0
- package/dist/cli/agent-command.js.map +1 -0
- package/dist/cli/agent-definition-parser.js +183 -0
- package/dist/cli/agent-definition-parser.js.map +1 -0
- package/dist/cli/agent-executor.js +310 -0
- package/dist/cli/agent-executor.js.map +1 -0
- package/dist/cli/agent-prompt-builder.js +268 -0
- package/dist/cli/agent-prompt-builder.js.map +1 -0
- package/dist/cli/agent-spawn.js +56 -2
- package/dist/cli/agent-spawn.js.map +1 -1
- package/dist/cli/anthropic-client.js +421 -0
- package/dist/cli/anthropic-client.js.map +1 -0
- package/dist/cli/cfn-context.js +150 -0
- package/dist/cli/cfn-context.js.map +1 -1
- package/dist/cli/cfn-fork.js +159 -0
- package/dist/cli/cfn-fork.js.map +1 -0
- package/dist/cli/cli-agent-context.js +358 -0
- package/dist/cli/cli-agent-context.js.map +1 -0
- package/dist/cli/config-manager.js +109 -91
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/cli/conversation-fork.js +201 -0
- package/dist/cli/conversation-fork.js.map +1 -0
- package/dist/cli/index.js +119 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/iteration-history.js +188 -0
- package/dist/cli/iteration-history.js.map +1 -0
- package/dist/cli/tool-definitions.js +263 -0
- package/dist/cli/tool-definitions.js.map +1 -0
- package/dist/cli/tool-executor.js +247 -0
- package/dist/cli/tool-executor.js.map +1 -0
- package/dist/hello.js +8 -0
- package/dist/hello.js.map +1 -0
- package/package.json +16 -6
- package/scripts/README.md +68 -0
- package/scripts/cfn-intervention-example.sh +21 -0
- package/scripts/migrate-test-infrastructure.sh +40 -0
- package/scripts/switch-api.sh +233 -0
- package/scripts/validate-test-migration.sh +49 -0
- package/scripts/verify-no-secrets.sh +55 -0
- package/.claude/agents/architecture/system-architect.md.backup +0 -603
- package/.claude/agents/code-booster.md +0 -131
- package/.claude/agents/consensus/performance-benchmarker.md +0 -101
- package/.claude/agents/consensus/security-manager.md +0 -107
- package/.claude/agents/context-curator.md +0 -167
- package/.claude/agents/context-reflector.md +0 -65
- package/.claude/agents/core-agents/cfn-loop-coordinator.md +0 -134
- package/.claude/agents/core-agents/code-quality-validator.md +0 -149
- package/.claude/agents/core-agents/context-curator.md +0 -452
- package/.claude/agents/core-agents/context-reflector.md +0 -273
- package/.claude/agents/core-agents/cost-savings-cfn-loop-coordinator.md +0 -190
- package/.claude/agents/core-agents/tester.md +0 -170
- package/.claude/agents/development/backend-dev.md +0 -165
- package/.claude/agents/devops/devops-engineer.md +0 -148
- package/.claude/agents/frontend/interaction-tester.md +0 -139
- package/.claude/agents/frontend/react-frontend-engineer.md +0 -9
- package/.claude/agents/personas/accessibility-advocate-persona.md +0 -107
- package/.claude/agents/testing/production-validator.md +0 -179
- package/.claude/agents/testing/tdd-london-swarm.md +0 -209
- package/.claude/agents/testing/unit/tdd-london-swarm.md +0 -43
- package/.claude/agents/testing/validation/production-validator.md +0 -43
- package/dist/coordination/fleet-manager.test.js +0 -141
- package/dist/coordination/fleet-manager.test.js.map +0 -1
- package/dist/middleware/transparency-middleware.test.js +0 -184
- package/dist/middleware/transparency-middleware.test.js.map +0 -1
- /package/.claude/agents/{core-agents → developers}/researcher.md +0 -0
- /package/.claude/agents/{consensus → specialists}/crdt-synchronizer.md +0 -0
- /package/.claude/agents/{consensus → specialists}/quorum-manager.md +0 -0
- /package/.claude/agents/{consensus → specialists}/raft-manager.md +0 -0
- /package/.claude/{agents/core-agents → agents-ignore}/coordinator.md +0 -0
- /package/.claude/{agents/core-agents/cost-savings-coordinator.md → agents-ignore/cost-savings-coordinator.md.backup} +0 -0
- /package/.claude/skills/redis-coordination/{phase4-wake-queue-test-report.md → demos/phase4-wake-queue-test-report.md} +0 -0
- /package/.claude/skills/redis-coordination/{test-bzpopmin-fix.sh → demos/test-bzpopmin-fix.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-cancel-swarm.sh → demos/test-cancel-swarm.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-dlq.sh → demos/test-dlq.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-priority-wake-phase4-unix.sh → demos/test-priority-wake-phase4-unix.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-priority-wake-phase4.sh → demos/test-priority-wake-phase4.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-priority-wake.sh → demos/test-priority-wake.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-quick-fix.sh → demos/test-quick-fix.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-quorum-absolute.sh → demos/test-quorum-absolute.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-quorum-fallback.sh → demos/test-quorum-fallback.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-quorum-percentage.sh → demos/test-quorum-percentage.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-quorum-with-retry.sh → demos/test-quorum-with-retry.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-quorum.sh → demos/test-quorum.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-shutdown-handling.sh → demos/test-shutdown-handling.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-shutdown.sh → demos/test-shutdown.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-utils-unix.sh → demos/test-utils-unix.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-utils.sh → demos/test-utils.sh} +0 -0
- /package/.claude/skills/redis-coordination/{test-waiting-mode.sh → demos/test-waiting-mode.sh} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli/agent-prompt-builder.ts"],"sourcesContent":["/**\r\n * Agent Prompt Builder\r\n *\r\n * Builds comprehensive prompts for CLI-spawned agents by combining:\r\n * - Agent definition (YAML + markdown)\r\n * - Task context (taskId, iteration, mode)\r\n * - CFN Loop protocol (if applicable)\r\n * - Iteration history (Sprint 3 - Phase 2)\r\n * - Environment variables\r\n */\r\n\r\nimport { AgentDefinition, hasCFNLoopProtocol } from './agent-definition-parser.js';\r\nimport { loadIterationHistory, formatIterationHistory } from './iteration-history.js';\r\n\r\nexport interface TaskContext {\r\n taskId?: string;\r\n iteration?: number;\r\n context?: string;\r\n mode?: string;\r\n priority?: number;\r\n parentTaskId?: string;\r\n agentId?: string;\r\n}\r\n\r\n/**\r\n * Build CFN Loop protocol instructions\r\n */\r\nfunction buildCFNLoopProtocol(taskId: string, agentId: string): string {\r\n return `\r\n## CFN Loop Redis Completion Protocol\r\n\r\nYou are participating in a CFN Loop workflow. Follow this protocol EXACTLY:\r\n\r\n### Step 1: Complete Work\r\nExecute your assigned task (implementation, review, testing, etc.)\r\n\r\n### Step 2: Signal Completion\r\n\\`\\`\\`bash\r\nredis-cli lpush \"swarm:${taskId}:\\${AGENT_ID}:done\" \"complete\"\r\n\\`\\`\\`\r\n\r\n### Step 3: Report Confidence Score\r\n\\`\\`\\`bash\r\n./.claude/skills/redis-coordination/invoke-waiting-mode.sh report \\\\\r\n --task-id \"${taskId}\" \\\\\r\n --agent-id \"\\${AGENT_ID}\" \\\\\r\n --confidence [0.0-1.0] \\\\\r\n --iteration ${taskId.includes('iteration') ? 'CURRENT_ITERATION' : '1'}\r\n\\`\\`\\`\r\n\r\n### Step 4: Enter Waiting Mode (for potential iteration)\r\n\\`\\`\\`bash\r\n./.claude/skills/redis-coordination/invoke-waiting-mode.sh enter \\\\\r\n --task-id \"${taskId}\" \\\\\r\n --agent-id \"\\${AGENT_ID}\" \\\\\r\n --context \"iteration-complete\"\r\n\\`\\`\\`\r\n\r\n**Critical Context Variables:**\r\n- TASK_ID: ${taskId}\r\n- AGENT_ID: ${agentId} (your unique identifier)\r\n- Confidence: Your self-assessment score (0.0-1.0)\r\n\r\n**Why This Matters:**\r\n- Zero-token blocking coordination (BLPOP waits without API calls)\r\n- Orchestrator collects confidence/consensus scores automatically\r\n- Supports autonomous iteration based on quality gates\r\n- Agent woken instantly (<100ms) if iteration needed\r\n\r\n**IMPORTANT:** You MUST complete all 4 steps in order. The orchestrator is waiting for your completion signal.\r\n`;\r\n}\r\n\r\n/**\r\n * Parse and enrich JSON context into natural language instructions\r\n */\r\nfunction enrichJSONContext(jsonObj: any): string {\r\n const sections: string[] = [];\r\n\r\n // Extract task description\r\n if (jsonObj.task) {\r\n sections.push(`**Task:** ${jsonObj.task}`);\r\n }\r\n\r\n // Parse files - convert comma-separated string to bullet list\r\n if (jsonObj.files) {\r\n const fileList = typeof jsonObj.files === 'string'\r\n ? jsonObj.files.split(',').map(f => f.trim()).filter(f => f)\r\n : Array.isArray(jsonObj.files) ? jsonObj.files : [];\r\n\r\n if (fileList.length > 0) {\r\n sections.push('\\n**Files to process:**');\r\n fileList.forEach(file => sections.push(`- ${file}`));\r\n }\r\n }\r\n\r\n // Add requirements/deliverables\r\n if (jsonObj.requirements) {\r\n const reqs = Array.isArray(jsonObj.requirements) ? jsonObj.requirements : [jsonObj.requirements];\r\n sections.push('\\n**Requirements:**');\r\n reqs.forEach((req, i) => sections.push(`${i + 1}. ${req}`));\r\n }\r\n\r\n if (jsonObj.deliverables) {\r\n const delivs = Array.isArray(jsonObj.deliverables) ? jsonObj.deliverables : [jsonObj.deliverables];\r\n sections.push('\\n**Deliverables:**');\r\n delivs.forEach(deliv => sections.push(`- ${deliv}`));\r\n }\r\n\r\n // Add batch information\r\n if (jsonObj.batch) {\r\n sections.push(`\\n**Batch:** ${jsonObj.batch}`);\r\n }\r\n\r\n // Add directory context\r\n if (jsonObj.directory) {\r\n sections.push(`\\n**Working Directory:** ${jsonObj.directory}`);\r\n }\r\n\r\n // Add acceptance criteria\r\n if (jsonObj.acceptanceCriteria) {\r\n const criteria = Array.isArray(jsonObj.acceptanceCriteria)\r\n ? jsonObj.acceptanceCriteria\r\n : [jsonObj.acceptanceCriteria];\r\n sections.push('\\n**Acceptance Criteria:**');\r\n criteria.forEach(criterion => sections.push(`- ${criterion}`));\r\n }\r\n\r\n // Add explicit instructions if present\r\n if (jsonObj.instructions) {\r\n sections.push('\\n**Instructions:**');\r\n const instrs = Array.isArray(jsonObj.instructions) ? jsonObj.instructions : [jsonObj.instructions];\r\n instrs.forEach((instr, i) => sections.push(`${i + 1}. ${instr}`));\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Build task description from context\r\n */\r\nfunction buildTaskDescription(agentType: string, context: TaskContext): string {\r\n let desc = '';\r\n\r\n if (context.context) {\r\n // Try to parse as JSON first\r\n let contextStr = context.context.trim();\r\n\r\n // Check if context looks like JSON\r\n if ((contextStr.startsWith('{') && contextStr.endsWith('}')) ||\r\n (contextStr.startsWith('[') && contextStr.endsWith(']'))) {\r\n try {\r\n const jsonObj = JSON.parse(contextStr);\r\n desc = enrichJSONContext(jsonObj);\r\n\r\n // Add instruction footer for structured tasks\r\n if (jsonObj.files || jsonObj.deliverables) {\r\n desc += '\\n\\n**Process each item systematically and report confidence when complete.**';\r\n }\r\n } catch (e) {\r\n // Not valid JSON, treat as plain text\r\n desc = context.context;\r\n }\r\n } else {\r\n // Plain text context\r\n desc = context.context;\r\n }\r\n } else {\r\n desc = `Execute task as ${agentType} agent`;\r\n }\r\n\r\n // Add metadata fields\r\n if (context.taskId) {\r\n desc += `\\n\\n**Task ID:** ${context.taskId}`;\r\n }\r\n\r\n if (context.iteration) {\r\n desc += `\\n**Iteration:** ${context.iteration}`;\r\n }\r\n\r\n if (context.mode) {\r\n desc += `\\n**Mode:** ${context.mode}`;\r\n }\r\n\r\n if (context.priority) {\r\n desc += `\\n**Priority:** ${context.priority}`;\r\n }\r\n\r\n if (context.parentTaskId) {\r\n desc += `\\n**Parent Task:** ${context.parentTaskId}`;\r\n }\r\n\r\n return desc;\r\n}\r\n\r\n/**\r\n * Build environment context section\r\n */\r\nfunction buildEnvironmentContext(context: TaskContext): string {\r\n const env: string[] = [];\r\n\r\n if (context.taskId) env.push(`TASK_ID=${context.taskId}`);\r\n if (context.iteration) env.push(`ITERATION=${context.iteration}`);\r\n if (context.mode) env.push(`MODE=${context.mode}`);\r\n if (context.priority) env.push(`PRIORITY=${context.priority}`);\r\n if (context.parentTaskId) env.push(`PARENT_TASK_ID=${context.parentTaskId}`);\r\n\r\n if (env.length === 0) return '';\r\n\r\n return `\r\n## Environment Variables\r\n\r\n\\`\\`\\`bash\r\n${env.join('\\n')}\r\n\\`\\`\\`\r\n`;\r\n}\r\n\r\n/**\r\n * Build complete prompt for agent execution (async for iteration history)\r\n */\r\nexport async function buildAgentPrompt(\r\n definition: AgentDefinition,\r\n context: TaskContext\r\n): Promise<string> {\r\n const agentId = `${definition.name}-${context.iteration || 1}`;\r\n\r\n const sections: string[] = [];\r\n\r\n // 1. Agent definition header\r\n sections.push(`# Agent: ${definition.name}`);\r\n sections.push('');\r\n sections.push(definition.description);\r\n sections.push('');\r\n\r\n // 2. Task description\r\n sections.push('## Task');\r\n sections.push('');\r\n sections.push(buildTaskDescription(definition.name, context));\r\n sections.push('');\r\n\r\n // 3. Iteration history (Sprint 3 - Phase 2)\r\n // Load and format previous iterations if iteration > 1\r\n if (context.taskId && context.iteration && context.iteration > 1) {\r\n try {\r\n const history = await loadIterationHistory(context.taskId, agentId, context.iteration);\r\n const historyText = formatIterationHistory(history, context.iteration);\r\n sections.push(historyText);\r\n sections.push('');\r\n } catch (err) {\r\n console.warn(`[agent-prompt-builder] Failed to load iteration history:`, err);\r\n // Continue without history\r\n }\r\n }\r\n\r\n // 4. Agent definition content (from markdown file)\r\n sections.push('## Agent Definition');\r\n sections.push('');\r\n sections.push(definition.content);\r\n sections.push('');\r\n\r\n // 5. CFN Loop protocol (if agent supports it AND task context includes taskId)\r\n if (context.taskId && hasCFNLoopProtocol(definition)) {\r\n sections.push(buildCFNLoopProtocol(context.taskId, agentId));\r\n sections.push('');\r\n }\r\n\r\n // 6. Environment context\r\n const envContext = buildEnvironmentContext(context);\r\n if (envContext) {\r\n sections.push(envContext);\r\n sections.push('');\r\n }\r\n\r\n // 7. Execution instructions\r\n sections.push('## Execution Instructions');\r\n sections.push('');\r\n sections.push('1. Read and understand the task requirements');\r\n if (context.iteration && context.iteration > 1) {\r\n sections.push('2. Review iteration history and feedback from validators');\r\n sections.push('3. Address specific feedback points from previous iteration');\r\n sections.push('4. Execute your core responsibilities as defined above');\r\n } else {\r\n sections.push('2. Execute your core responsibilities as defined above');\r\n sections.push('3. Follow any protocol steps (CFN Loop, validation hooks, etc.)');\r\n }\r\n sections.push('4. Provide clear, concise output');\r\n sections.push('5. Report confidence score if applicable');\r\n sections.push('');\r\n\r\n // 8. Tool reminder\r\n if (definition.tools && definition.tools.length > 0) {\r\n sections.push('## Available Tools');\r\n sections.push('');\r\n sections.push(`You have access to: ${definition.tools.join(', ')}`);\r\n sections.push('');\r\n }\r\n\r\n return sections.join('\\n');\r\n}\r\n\r\n/**\r\n * Extract agent ID from context\r\n * If agentId is explicitly provided in context, use it; otherwise generate from name + iteration\r\n */\r\nexport function getAgentId(definition: AgentDefinition, context: TaskContext): string {\r\n if (context.agentId) {\r\n return context.agentId;\r\n }\r\n return `${definition.name}-${context.iteration || 1}`;\r\n}\r\n\r\n/**\r\n * Build system prompt for agent (optional, for structured agent behavior)\r\n */\r\nexport function buildSystemPrompt(definition: AgentDefinition): string {\r\n return `You are ${definition.name}, a specialized AI agent.\r\n\r\nType: ${definition.type || 'specialist'}\r\nModel: ${definition.model}\r\nTools: ${definition.tools.join(', ')}\r\n\r\nFollow your agent definition exactly and complete assigned tasks with high quality.`;\r\n}\r\n"],"names":["hasCFNLoopProtocol","loadIterationHistory","formatIterationHistory","buildCFNLoopProtocol","taskId","agentId","includes","enrichJSONContext","jsonObj","sections","task","push","files","fileList","split","map","f","trim","filter","Array","isArray","length","forEach","file","requirements","reqs","req","i","deliverables","delivs","deliv","batch","directory","acceptanceCriteria","criteria","criterion","instructions","instrs","instr","join","buildTaskDescription","agentType","context","desc","contextStr","startsWith","endsWith","JSON","parse","e","iteration","mode","priority","parentTaskId","buildEnvironmentContext","env","buildAgentPrompt","definition","name","description","history","historyText","err","console","warn","content","envContext","tools","getAgentId","buildSystemPrompt","type","model"],"mappings":"AAAA;;;;;;;;;CASC,GAED,SAA0BA,kBAAkB,QAAQ,+BAA+B;AACnF,S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,CAAC,oBAAoB,EAAE8C,WAAWU,KAAK,CAAC5B,IAAI,CAAC,OAAO;QAClE9B,SAASE,IAAI,CAAC;IAChB;IAEA,OAAOF,SAAS8B,IAAI,CAAC;AACvB;AAEA;;;CAGC,GACD,OAAO,SAAS6B,WAAWX,UAA2B,EAAEf,OAAoB;IAC1E,IAAIA,QAAQrC,OAAO,EAAE;QACnB,OAAOqC,QAAQrC,OAAO;IACxB;IACA,OAAO,GAAGoD,WAAWC,IAAI,CAAC,CAAC,EAAEhB,QAAQQ,SAAS,IAAI,GAAG;AACvD;AAEA;;CAEC,GACD,OAAO,SAASmB,kBAAkBZ,UAA2B;IAC3D,OAAO,CAAC,QAAQ,EAAEA,WAAWC,IAAI,CAAC;;MAE9B,EAAED,WAAWa,IAAI,IAAI,aAAa;OACjC,EAAEb,WAAWc,KAAK,CAAC;OACnB,EAAEd,WAAWU,KAAK,CAAC5B,IAAI,CAAC,MAAM;;mFAE8C,CAAC;AACpF"}
|
package/dist/cli/agent-spawn.js
CHANGED
|
@@ -36,6 +36,9 @@
|
|
|
36
36
|
const key = optionArgs[i];
|
|
37
37
|
const value = optionArgs[i + 1];
|
|
38
38
|
switch(key){
|
|
39
|
+
case '--agent-id':
|
|
40
|
+
options.agentId = value;
|
|
41
|
+
break;
|
|
39
42
|
case '--task-id':
|
|
40
43
|
options.taskId = value;
|
|
41
44
|
break;
|
|
@@ -67,8 +70,9 @@
|
|
|
67
70
|
* This is a wrapper/alias for the existing claude-flow-novice agent spawning mechanism
|
|
68
71
|
* Provides the cfn-spawn naming pattern while delegating to the working implementation
|
|
69
72
|
*/ async function spawnAgent(options) {
|
|
70
|
-
const { agentType, taskId, iteration, context, mode, priority, parentTaskId } = options;
|
|
73
|
+
const { agentType, agentId, taskId, iteration, context, mode, priority, parentTaskId } = options;
|
|
71
74
|
console.log(`[cfn-spawn] Spawning agent: ${agentType}`);
|
|
75
|
+
if (agentId) console.log(`[cfn-spawn] Agent ID: ${agentId}`);
|
|
72
76
|
if (taskId) console.log(`[cfn-spawn] Task ID: ${taskId}`);
|
|
73
77
|
if (iteration) console.log(`[cfn-spawn] Iteration: ${iteration}`);
|
|
74
78
|
if (context) console.log(`[cfn-spawn] Context: ${context}`);
|
|
@@ -80,6 +84,9 @@
|
|
|
80
84
|
agentType
|
|
81
85
|
];
|
|
82
86
|
// Add optional parameters
|
|
87
|
+
if (agentId) {
|
|
88
|
+
claudeArgs.push('--agent-id', agentId);
|
|
89
|
+
}
|
|
83
90
|
if (taskId) {
|
|
84
91
|
claudeArgs.push('--task-id', taskId);
|
|
85
92
|
}
|
|
@@ -98,6 +105,47 @@
|
|
|
98
105
|
if (parentTaskId) {
|
|
99
106
|
claudeArgs.push('--parent-task-id', parentTaskId);
|
|
100
107
|
}
|
|
108
|
+
// Fetch epic context from Redis if available
|
|
109
|
+
let epicContext = '';
|
|
110
|
+
let phaseContext = '';
|
|
111
|
+
let successCriteria = '';
|
|
112
|
+
if (taskId) {
|
|
113
|
+
try {
|
|
114
|
+
const { execSync } = await import('child_process');
|
|
115
|
+
// Try to read epic-level context from Redis
|
|
116
|
+
try {
|
|
117
|
+
epicContext = execSync(`redis-cli get "swarm:${taskId}:epic-context"`, {
|
|
118
|
+
encoding: 'utf8'
|
|
119
|
+
}).trim();
|
|
120
|
+
if (epicContext === '(nil)') epicContext = '';
|
|
121
|
+
} catch (e) {
|
|
122
|
+
// Redis not available or key doesn't exist
|
|
123
|
+
}
|
|
124
|
+
// Try to read phase-specific context
|
|
125
|
+
try {
|
|
126
|
+
phaseContext = execSync(`redis-cli get "swarm:${taskId}:phase-context"`, {
|
|
127
|
+
encoding: 'utf8'
|
|
128
|
+
}).trim();
|
|
129
|
+
if (phaseContext === '(nil)') phaseContext = '';
|
|
130
|
+
} catch (e) {
|
|
131
|
+
// Redis not available or key doesn't exist
|
|
132
|
+
}
|
|
133
|
+
// Try to read success criteria
|
|
134
|
+
try {
|
|
135
|
+
successCriteria = execSync(`redis-cli get "swarm:${taskId}:success-criteria"`, {
|
|
136
|
+
encoding: 'utf8'
|
|
137
|
+
}).trim();
|
|
138
|
+
if (successCriteria === '(nil)') successCriteria = '';
|
|
139
|
+
} catch (e) {
|
|
140
|
+
// Redis not available or key doesn't exist
|
|
141
|
+
}
|
|
142
|
+
if (epicContext) {
|
|
143
|
+
console.log(`[cfn-spawn] Epic context loaded from Redis`);
|
|
144
|
+
}
|
|
145
|
+
} catch (err) {
|
|
146
|
+
console.warn(`[cfn-spawn] Could not load epic context from Redis:`, err);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
101
149
|
// Add environment variables for agent context
|
|
102
150
|
const env = {
|
|
103
151
|
...process.env,
|
|
@@ -107,7 +155,11 @@
|
|
|
107
155
|
CONTEXT: context || '',
|
|
108
156
|
MODE: mode || 'cli',
|
|
109
157
|
PRIORITY: priority?.toString() || '5',
|
|
110
|
-
PARENT_TASK_ID: parentTaskId || ''
|
|
158
|
+
PARENT_TASK_ID: parentTaskId || '',
|
|
159
|
+
// Epic-level context from Redis
|
|
160
|
+
EPIC_CONTEXT: epicContext,
|
|
161
|
+
PHASE_CONTEXT: phaseContext,
|
|
162
|
+
SUCCESS_CRITERIA: successCriteria
|
|
111
163
|
};
|
|
112
164
|
console.log(`[cfn-spawn] Executing: npx ${claudeArgs.join(' ')}`);
|
|
113
165
|
// Spawn the claude-flow-novice agent process
|
|
@@ -162,6 +214,7 @@ Usage:
|
|
|
162
214
|
cfn-spawn <type> [options] (agent is implied)
|
|
163
215
|
|
|
164
216
|
Options:
|
|
217
|
+
--agent-id <id> Explicit agent identifier (overrides auto-generation)
|
|
165
218
|
--task-id <id> Task identifier
|
|
166
219
|
--iteration <n> Iteration number
|
|
167
220
|
--context <text> Context description
|
|
@@ -173,6 +226,7 @@ Examples:
|
|
|
173
226
|
cfn-spawn agent researcher --task-id task-123 --iteration 1
|
|
174
227
|
cfn-spawn coder --task-id auth-impl --context "Implement JWT auth"
|
|
175
228
|
cfn-spawn reviewer --task-id auth-impl --iteration 2 --mode cli
|
|
229
|
+
cfn-spawn tester --agent-id tester-1-1 --task-id test-phase --iteration 1
|
|
176
230
|
`);
|
|
177
231
|
return;
|
|
178
232
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/agent-spawn.ts"],"sourcesContent":["#!/usr/bin/env node\r\n/**\r\n * Agent Spawning CLI - Direct agent process spawning\r\n *\r\n * Usage:\r\n * npx cfn-spawn agent <type> [options]\r\n * npx cfn-spawn <type> [options] (agent is implied)\r\n *\r\n * Examples:\r\n * npx cfn-spawn agent researcher --task-id task-123 --iteration 1\r\n * npx cfn-spawn researcher --task-id task-123 --iteration 1\r\n */\r\n\r\nimport { spawn } from 'child_process';\r\nimport { resolve } from 'path';\r\n\r\ninterface AgentSpawnOptions {\r\n agentType: string;\r\n taskId?: string;\r\n iteration?: number;\r\n context?: string;\r\n mode?: string;\r\n priority?: number;\r\n parentTaskId?: string;\r\n}\r\n\r\n/**\r\n * Parse command line arguments for agent spawning\r\n */\r\nfunction parseAgentArgs(args: string[]): AgentSpawnOptions | null {\r\n // Handle both \"agent <type>\" and \"<type>\" patterns\r\n let agentType: string;\r\n let optionArgs: string[];\r\n\r\n if (args[0] === 'agent') {\r\n agentType = args[1];\r\n optionArgs = args.slice(2);\r\n } else {\r\n agentType = args[0];\r\n optionArgs = args.slice(1);\r\n }\r\n\r\n if (!agentType) {\r\n console.error('Error: Agent type is required');\r\n console.error('Usage: cfn-spawn agent <type> [options]');\r\n return null;\r\n }\r\n\r\n const options: AgentSpawnOptions = { agentType };\r\n\r\n // Parse optional parameters\r\n for (let i = 0; i < optionArgs.length; i += 2) {\r\n const key = optionArgs[i];\r\n const value = optionArgs[i + 1];\r\n\r\n switch (key) {\r\n case '--task-id':\r\n options.taskId = value;\r\n break;\r\n case '--iteration':\r\n options.iteration = parseInt(value, 10);\r\n break;\r\n case '--context':\r\n options.context = value;\r\n break;\r\n case '--mode':\r\n options.mode = value;\r\n break;\r\n case '--priority':\r\n options.priority = parseInt(value, 10);\r\n break;\r\n case '--parent-task':\r\n case '--parent-task-id':\r\n options.parentTaskId = value;\r\n break;\r\n default:\r\n console.warn(`Unknown option: ${key}`);\r\n }\r\n }\r\n\r\n return options;\r\n}\r\n\r\n/**\r\n * Spawn an agent process using npx claude-flow-novice agent\r\n *\r\n * This is a wrapper/alias for the existing claude-flow-novice agent spawning mechanism\r\n * Provides the cfn-spawn naming pattern while delegating to the working implementation\r\n */\r\nasync function spawnAgent(options: AgentSpawnOptions): Promise<void> {\r\n const { agentType, taskId, iteration, context, mode, priority, parentTaskId } = options;\r\n\r\n console.log(`[cfn-spawn] Spawning agent: ${agentType}`);\r\n if (taskId) console.log(`[cfn-spawn] Task ID: ${taskId}`);\r\n if (iteration) console.log(`[cfn-spawn] Iteration: ${iteration}`);\r\n if (context) console.log(`[cfn-spawn] Context: ${context}`);\r\n if (mode) console.log(`[cfn-spawn] Mode: ${mode}`);\r\n\r\n // Build command arguments for npx claude-flow-novice agent\r\n const claudeArgs = ['claude-flow-novice', 'agent', agentType];\r\n\r\n // Add optional parameters\r\n if (taskId) {\r\n claudeArgs.push('--task-id', taskId);\r\n }\r\n if (iteration) {\r\n claudeArgs.push('--iteration', iteration.toString());\r\n }\r\n if (context) {\r\n claudeArgs.push('--context', context);\r\n }\r\n if (mode) {\r\n claudeArgs.push('--mode', mode);\r\n }\r\n if (priority) {\r\n claudeArgs.push('--priority', priority.toString());\r\n }\r\n if (parentTaskId) {\r\n claudeArgs.push('--parent-task-id', parentTaskId);\r\n }\r\n\r\n // Add environment variables for agent context\r\n const env = {\r\n ...process.env,\r\n AGENT_TYPE: agentType,\r\n TASK_ID: taskId || '',\r\n ITERATION: iteration?.toString() || '1',\r\n CONTEXT: context || '',\r\n MODE: mode || 'cli',\r\n PRIORITY: priority?.toString() || '5',\r\n PARENT_TASK_ID: parentTaskId || ''\r\n };\r\n\r\n console.log(`[cfn-spawn] Executing: npx ${claudeArgs.join(' ')}`);\r\n\r\n // Spawn the claude-flow-novice agent process\r\n const agentProcess = spawn('npx', claudeArgs, {\r\n stdio: 'inherit',\r\n env,\r\n cwd: process.cwd()\r\n });\r\n\r\n // Handle process exit\r\n agentProcess.on('exit', (code, signal) => {\r\n if (code === 0) {\r\n console.log(`[cfn-spawn] Agent ${agentType} completed successfully`);\r\n } else {\r\n console.error(`[cfn-spawn] Agent ${agentType} exited with code ${code}, signal ${signal}`);\r\n }\r\n process.exit(code || 0);\r\n });\r\n\r\n // Handle process errors\r\n agentProcess.on('error', (err) => {\r\n console.error(`[cfn-spawn] Failed to spawn agent ${agentType}:`, err.message);\r\n process.exit(1);\r\n });\r\n\r\n // Cleanup on parent exit\r\n process.on('SIGINT', () => {\r\n console.log('\\n[cfn-spawn] Received SIGINT, terminating agent...');\r\n agentProcess.kill('SIGINT');\r\n });\r\n\r\n process.on('SIGTERM', () => {\r\n console.log('\\n[cfn-spawn] Received SIGTERM, terminating agent...');\r\n agentProcess.kill('SIGTERM');\r\n });\r\n}\r\n\r\n/**\r\n * Build task description for the agent\r\n */\r\nfunction buildTaskDescription(\r\n agentType: string,\r\n taskId?: string,\r\n iteration?: number,\r\n context?: string\r\n): string {\r\n let desc = `Execute task as ${agentType} agent`;\r\n\r\n if (taskId) desc += ` for task ${taskId}`;\r\n if (iteration) desc += ` (iteration ${iteration})`;\r\n if (context) desc += `: ${context}`;\r\n\r\n return desc;\r\n}\r\n\r\n/**\r\n * Main CLI entry point\r\n */\r\nexport async function main(args: string[] = process.argv.slice(2)): Promise<void> {\r\n // Show help if requested\r\n if (args.includes('--help') || args.includes('-h')) {\r\n console.log(`\r\ncfn-spawn - Claude Flow Novice Agent Spawner\r\n\r\nUsage:\r\n cfn-spawn agent <type> [options]\r\n cfn-spawn <type> [options] (agent is implied)\r\n\r\nOptions:\r\n --task-id <id> Task identifier\r\n --iteration <n> Iteration number\r\n --context <text> Context description\r\n --mode <mode> Execution mode (cli, api, hybrid)\r\n --priority <1-10> Task priority\r\n --parent-task-id <id> Parent task identifier\r\n\r\nExamples:\r\n cfn-spawn agent researcher --task-id task-123 --iteration 1\r\n cfn-spawn coder --task-id auth-impl --context \"Implement JWT auth\"\r\n cfn-spawn reviewer --task-id auth-impl --iteration 2 --mode cli\r\n `);\r\n return;\r\n }\r\n\r\n // Parse arguments\r\n const options = parseAgentArgs(args);\r\n if (!options) {\r\n process.exit(1);\r\n }\r\n\r\n // Spawn the agent\r\n await spawnAgent(options);\r\n}\r\n\r\n// Run if called directly\r\n// ES module check - compare import.meta.url with the executed file\r\nconst isMainModule = import.meta.url.endsWith(process.argv[1]?.replace(/\\\\/g, '/') || '');\r\nif (isMainModule) {\r\n main().catch((err) => {\r\n console.error('[cfn-spawn] Fatal error:', err);\r\n process.exit(1);\r\n });\r\n}\r\n"],"names":["spawn","parseAgentArgs","args","agentType","optionArgs","slice","console","error","options","i","length","key","value","taskId","iteration","parseInt","context","mode","priority","parentTaskId","warn","spawnAgent","log","claudeArgs","push","toString","env","process","AGENT_TYPE","TASK_ID","ITERATION","CONTEXT","MODE","PRIORITY","PARENT_TASK_ID","join","agentProcess","stdio","cwd","on","code","signal","exit","err","message","kill","buildTaskDescription","desc","main","argv","includes","isMainModule","url","endsWith","replace","catch"],"mappings":";AACA;;;;;;;;;;CAUC,GAED,SAASA,KAAK,QAAQ,gBAAgB;AAatC;;CAEC,GACD,SAASC,eAAeC,IAAc;IACpC,mDAAmD;IACnD,IAAIC;IACJ,IAAIC;IAEJ,IAAIF,IAAI,CAAC,EAAE,KAAK,SAAS;QACvBC,YAAYD,IAAI,CAAC,EAAE;QACnBE,aAAaF,KAAKG,KAAK,CAAC;IAC1B,OAAO;QACLF,YAAYD,IAAI,CAAC,EAAE;QACnBE,aAAaF,KAAKG,KAAK,CAAC;IAC1B;IAEA,IAAI,CAACF,WAAW;QACdG,QAAQC,KAAK,CAAC;QACdD,QAAQC,KAAK,CAAC;QACd,OAAO;IACT;IAEA,MAAMC,UAA6B;QAAEL;IAAU;IAE/C,4BAA4B;IAC5B,IAAK,I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node\r\n/**\r\n * Agent Spawning CLI - Direct agent process spawning\r\n *\r\n * Usage:\r\n * npx cfn-spawn agent <type> [options]\r\n * npx cfn-spawn <type> [options] (agent is implied)\r\n *\r\n * Examples:\r\n * npx cfn-spawn agent researcher --task-id task-123 --iteration 1\r\n * npx cfn-spawn researcher --task-id task-123 --iteration 1\r\n */\r\n\r\nimport { spawn } from 'child_process';\r\nimport { resolve } from 'path';\r\n\r\ninterface AgentSpawnOptions {\r\n agentType: string;\r\n agentId?: string;\r\n taskId?: string;\r\n iteration?: number;\r\n context?: string;\r\n mode?: string;\r\n priority?: number;\r\n parentTaskId?: string;\r\n}\r\n\r\n/**\r\n * Parse command line arguments for agent spawning\r\n */\r\nfunction parseAgentArgs(args: string[]): AgentSpawnOptions | null {\r\n // Handle both \"agent <type>\" and \"<type>\" patterns\r\n let agentType: string;\r\n let optionArgs: string[];\r\n\r\n if (args[0] === 'agent') {\r\n agentType = args[1];\r\n optionArgs = args.slice(2);\r\n } else {\r\n agentType = args[0];\r\n optionArgs = args.slice(1);\r\n }\r\n\r\n if (!agentType) {\r\n console.error('Error: Agent type is required');\r\n console.error('Usage: cfn-spawn agent <type> [options]');\r\n return null;\r\n }\r\n\r\n const options: AgentSpawnOptions = { agentType };\r\n\r\n // Parse optional parameters\r\n for (let i = 0; i < optionArgs.length; i += 2) {\r\n const key = optionArgs[i];\r\n const value = optionArgs[i + 1];\r\n\r\n switch (key) {\r\n case '--agent-id':\r\n options.agentId = value;\r\n break;\r\n case '--task-id':\r\n options.taskId = value;\r\n break;\r\n case '--iteration':\r\n options.iteration = parseInt(value, 10);\r\n break;\r\n case '--context':\r\n options.context = value;\r\n break;\r\n case '--mode':\r\n options.mode = value;\r\n break;\r\n case '--priority':\r\n options.priority = parseInt(value, 10);\r\n break;\r\n case '--parent-task':\r\n case '--parent-task-id':\r\n options.parentTaskId = value;\r\n break;\r\n default:\r\n console.warn(`Unknown option: ${key}`);\r\n }\r\n }\r\n\r\n return options;\r\n}\r\n\r\n/**\r\n * Spawn an agent process using npx claude-flow-novice agent\r\n *\r\n * This is a wrapper/alias for the existing claude-flow-novice agent spawning mechanism\r\n * Provides the cfn-spawn naming pattern while delegating to the working implementation\r\n */\r\nasync function spawnAgent(options: AgentSpawnOptions): Promise<void> {\r\n const { agentType, agentId, taskId, iteration, context, mode, priority, parentTaskId } = options;\r\n\r\n console.log(`[cfn-spawn] Spawning agent: ${agentType}`);\r\n if (agentId) console.log(`[cfn-spawn] Agent ID: ${agentId}`);\r\n if (taskId) console.log(`[cfn-spawn] Task ID: ${taskId}`);\r\n if (iteration) console.log(`[cfn-spawn] Iteration: ${iteration}`);\r\n if (context) console.log(`[cfn-spawn] Context: ${context}`);\r\n if (mode) console.log(`[cfn-spawn] Mode: ${mode}`);\r\n\r\n // Build command arguments for npx claude-flow-novice agent\r\n const claudeArgs = ['claude-flow-novice', 'agent', agentType];\r\n\r\n // Add optional parameters\r\n if (agentId) {\r\n claudeArgs.push('--agent-id', agentId);\r\n }\r\n if (taskId) {\r\n claudeArgs.push('--task-id', taskId);\r\n }\r\n if (iteration) {\r\n claudeArgs.push('--iteration', iteration.toString());\r\n }\r\n if (context) {\r\n claudeArgs.push('--context', context);\r\n }\r\n if (mode) {\r\n claudeArgs.push('--mode', mode);\r\n }\r\n if (priority) {\r\n claudeArgs.push('--priority', priority.toString());\r\n }\r\n if (parentTaskId) {\r\n claudeArgs.push('--parent-task-id', parentTaskId);\r\n }\r\n\r\n // Fetch epic context from Redis if available\r\n let epicContext = '';\r\n let phaseContext = '';\r\n let successCriteria = '';\r\n\r\n if (taskId) {\r\n try {\r\n const { execSync } = await import('child_process');\r\n\r\n // Try to read epic-level context from Redis\r\n try {\r\n epicContext = execSync(`redis-cli get \"swarm:${taskId}:epic-context\"`, { encoding: 'utf8' }).trim();\r\n if (epicContext === '(nil)') epicContext = '';\r\n } catch (e) {\r\n // Redis not available or key doesn't exist\r\n }\r\n\r\n // Try to read phase-specific context\r\n try {\r\n phaseContext = execSync(`redis-cli get \"swarm:${taskId}:phase-context\"`, { encoding: 'utf8' }).trim();\r\n if (phaseContext === '(nil)') phaseContext = '';\r\n } catch (e) {\r\n // Redis not available or key doesn't exist\r\n }\r\n\r\n // Try to read success criteria\r\n try {\r\n successCriteria = execSync(`redis-cli get \"swarm:${taskId}:success-criteria\"`, { encoding: 'utf8' }).trim();\r\n if (successCriteria === '(nil)') successCriteria = '';\r\n } catch (e) {\r\n // Redis not available or key doesn't exist\r\n }\r\n\r\n if (epicContext) {\r\n console.log(`[cfn-spawn] Epic context loaded from Redis`);\r\n }\r\n } catch (err) {\r\n console.warn(`[cfn-spawn] Could not load epic context from Redis:`, err);\r\n }\r\n }\r\n\r\n // Add environment variables for agent context\r\n const env = {\r\n ...process.env,\r\n AGENT_TYPE: agentType,\r\n TASK_ID: taskId || '',\r\n ITERATION: iteration?.toString() || '1',\r\n CONTEXT: context || '',\r\n MODE: mode || 'cli',\r\n PRIORITY: priority?.toString() || '5',\r\n PARENT_TASK_ID: parentTaskId || '',\r\n // Epic-level context from Redis\r\n EPIC_CONTEXT: epicContext,\r\n PHASE_CONTEXT: phaseContext,\r\n SUCCESS_CRITERIA: successCriteria\r\n };\r\n\r\n console.log(`[cfn-spawn] Executing: npx ${claudeArgs.join(' ')}`);\r\n\r\n // Spawn the claude-flow-novice agent process\r\n const agentProcess = spawn('npx', claudeArgs, {\r\n stdio: 'inherit',\r\n env,\r\n cwd: process.cwd()\r\n });\r\n\r\n // Handle process exit\r\n agentProcess.on('exit', (code, signal) => {\r\n if (code === 0) {\r\n console.log(`[cfn-spawn] Agent ${agentType} completed successfully`);\r\n } else {\r\n console.error(`[cfn-spawn] Agent ${agentType} exited with code ${code}, signal ${signal}`);\r\n }\r\n process.exit(code || 0);\r\n });\r\n\r\n // Handle process errors\r\n agentProcess.on('error', (err) => {\r\n console.error(`[cfn-spawn] Failed to spawn agent ${agentType}:`, err.message);\r\n process.exit(1);\r\n });\r\n\r\n // Cleanup on parent exit\r\n process.on('SIGINT', () => {\r\n console.log('\\n[cfn-spawn] Received SIGINT, terminating agent...');\r\n agentProcess.kill('SIGINT');\r\n });\r\n\r\n process.on('SIGTERM', () => {\r\n console.log('\\n[cfn-spawn] Received SIGTERM, terminating agent...');\r\n agentProcess.kill('SIGTERM');\r\n });\r\n}\r\n\r\n/**\r\n * Build task description for the agent\r\n */\r\nfunction buildTaskDescription(\r\n agentType: string,\r\n taskId?: string,\r\n iteration?: number,\r\n context?: string\r\n): string {\r\n let desc = `Execute task as ${agentType} agent`;\r\n\r\n if (taskId) desc += ` for task ${taskId}`;\r\n if (iteration) desc += ` (iteration ${iteration})`;\r\n if (context) desc += `: ${context}`;\r\n\r\n return desc;\r\n}\r\n\r\n/**\r\n * Main CLI entry point\r\n */\r\nexport async function main(args: string[] = process.argv.slice(2)): Promise<void> {\r\n // Show help if requested\r\n if (args.includes('--help') || args.includes('-h')) {\r\n console.log(`\r\ncfn-spawn - Claude Flow Novice Agent Spawner\r\n\r\nUsage:\r\n cfn-spawn agent <type> [options]\r\n cfn-spawn <type> [options] (agent is implied)\r\n\r\nOptions:\r\n --agent-id <id> Explicit agent identifier (overrides auto-generation)\r\n --task-id <id> Task identifier\r\n --iteration <n> Iteration number\r\n --context <text> Context description\r\n --mode <mode> Execution mode (cli, api, hybrid)\r\n --priority <1-10> Task priority\r\n --parent-task-id <id> Parent task identifier\r\n\r\nExamples:\r\n cfn-spawn agent researcher --task-id task-123 --iteration 1\r\n cfn-spawn coder --task-id auth-impl --context \"Implement JWT auth\"\r\n cfn-spawn reviewer --task-id auth-impl --iteration 2 --mode cli\r\n cfn-spawn tester --agent-id tester-1-1 --task-id test-phase --iteration 1\r\n `);\r\n return;\r\n }\r\n\r\n // Parse arguments\r\n const options = parseAgentArgs(args);\r\n if (!options) {\r\n process.exit(1);\r\n }\r\n\r\n // Spawn the agent\r\n await spawnAgent(options);\r\n}\r\n\r\n// Run if called directly\r\n// ES module check - compare import.meta.url with the executed file\r\nconst isMainModule = import.meta.url.endsWith(process.argv[1]?.replace(/\\\\/g, '/') || '');\r\nif (isMainModule) {\r\n main().catch((err) => {\r\n console.error('[cfn-spawn] Fatal error:', err);\r\n process.exit(1);\r\n });\r\n}\r\n"],"names":["spawn","parseAgentArgs","args","agentType","optionArgs","slice","console","error","options","i","length","key","value","agentId","taskId","iteration","parseInt","context","mode","priority","parentTaskId","warn","spawnAgent","log","claudeArgs","push","toString","epicContext","phaseContext","successCriteria","execSync","encoding","trim","e","err","env","process","AGENT_TYPE","TASK_ID","ITERATION","CONTEXT","MODE","PRIORITY","PARENT_TASK_ID","EPIC_CONTEXT","PHASE_CONTEXT","SUCCESS_CRITERIA","join","agentProcess","stdio","cwd","on","code","signal","exit","message","kill","buildTaskDescription","desc","main","argv","includes","isMainModule","url","endsWith","replace","catch"],"mappings":";AACA;;;;;;;;;;CAUC,GAED,SAASA,KAAK,QAAQ,gBAAgB;AActC;;CAEC,GACD,SAASC,eAAeC,IAAc;IACpC,mDAAmD;IACnD,IAAIC;IACJ,IAAIC;IAEJ,IAAIF,IAAI,CAAC,EAAE,KAAK,SAAS;QACvBC,YAAYD,IAAI,CAAC,EAAE;QACnBE,aAAaF,KAAKG,KAAK,CAAC;IAC1B,OAAO;QACLF,YAAYD,IAAI,CAAC,EAAE;QACnBE,aAAaF,KAAKG,KAAK,CAAC;IAC1B;IAEA,IAAI,CAACF,WAAW;QACdG,QAAQC,KAAK,CAAC;QACdD,QAAQC,KAAK,CAAC;QACd,OAAO;IACT;IAEA,MAAMC,UAA6B;QAAEL;IAAU;IAE/C,4BAA4B;IAC5B,IAAK,IAAIM,IAAI,GAAGA,IAAIL,WAAWM,MAAM,EAAED,KAAK,EAAG;QAC7C,MAAME,MAAMP,UAAU,CAACK,EAAE;QACzB,MAAMG,QAAQR,UAAU,CAACK,IAAI,EAAE;QAE/B,OAAQE;YACN,KAAK;gBACHH,QAAQK,OAAO,GAAGD;gBAClB;YACF,KAAK;gBACHJ,QAAQM,MAAM,GAAGF;gBACjB;YACF,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AEhB,IAAIyC,OAAO,CAAC,gBAAgB,EAAEvD,UAAU,MAAM,CAAC;IAE/C,IAAIW,QAAQ4C,QAAQ,CAAC,UAAU,EAAE5C,QAAQ;IACzC,IAAIC,WAAW2C,QAAQ,CAAC,YAAY,EAAE3C,UAAU,CAAC,CAAC;IAClD,IAAIE,SAASyC,QAAQ,CAAC,EAAE,EAAEzC,SAAS;IAEnC,OAAOyC;AACT;AAEA;;CAEC,GACD,OAAO,eAAeC,KAAKzD,OAAiBkC,QAAQwB,IAAI,CAACvD,KAAK,CAAC,EAAE;IAC/D,yBAAyB;IACzB,IAAIH,KAAK2D,QAAQ,CAAC,aAAa3D,KAAK2D,QAAQ,CAAC,OAAO;QAClDvD,QAAQiB,GAAG,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;IAqBb,CAAC;QACD;IACF;IAEA,kBAAkB;IAClB,MAAMf,UAAUP,eAAeC;IAC/B,IAAI,CAACM,SAAS;QACZ4B,QAAQkB,IAAI,CAAC;IACf;IAEA,kBAAkB;IAClB,MAAMhC,WAAWd;AACnB;AAEA,yBAAyB;AACzB,mEAAmE;AACnE,MAAMsD,eAAe,YAAYC,GAAG,CAACC,QAAQ,CAAC5B,QAAQwB,IAAI,CAAC,EAAE,EAAEK,QAAQ,OAAO,QAAQ;AACtF,IAAIH,cAAc;IAChBH,OAAOO,KAAK,CAAC,CAAChC;QACZ5B,QAAQC,KAAK,CAAC,4BAA4B2B;QAC1CE,QAAQkB,IAAI,CAAC;IACf;AACF"}
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic API Client
|
|
3
|
+
*
|
|
4
|
+
* Handles communication with Claude API (Anthropic or z.ai provider).
|
|
5
|
+
* Supports streaming responses and tool execution.
|
|
6
|
+
*/ import Anthropic from '@anthropic-ai/sdk';
|
|
7
|
+
import fs from 'fs/promises';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { exec } from 'child_process';
|
|
10
|
+
import { promisify } from 'util';
|
|
11
|
+
import { executeTool } from './tool-executor.js';
|
|
12
|
+
const execAsync = promisify(exec);
|
|
13
|
+
/**
|
|
14
|
+
* Get API configuration from environment and config files
|
|
15
|
+
*/ export async function getAPIConfig() {
|
|
16
|
+
// Check environment variable
|
|
17
|
+
const envProvider = process.env.CLAUDE_API_PROVIDER;
|
|
18
|
+
if (envProvider === 'zai') {
|
|
19
|
+
return {
|
|
20
|
+
provider: 'zai',
|
|
21
|
+
apiKey: process.env.ZAI_API_KEY || process.env.ANTHROPIC_API_KEY,
|
|
22
|
+
baseURL: process.env.ZAI_BASE_URL || 'https://api.z.ai/api/anthropic'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Check config file
|
|
26
|
+
try {
|
|
27
|
+
const configPath = path.join('.claude', 'config', 'api-provider.json');
|
|
28
|
+
const config = JSON.parse(await fs.readFile(configPath, 'utf-8'));
|
|
29
|
+
if (config.provider === 'zai' || config.provider === 'z.ai') {
|
|
30
|
+
return {
|
|
31
|
+
provider: 'zai',
|
|
32
|
+
apiKey: config.apiKey || process.env.ZAI_API_KEY || process.env.ANTHROPIC_API_KEY,
|
|
33
|
+
baseURL: config.baseURL || process.env.ZAI_BASE_URL || 'https://api.z.ai/api/anthropic'
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
} catch {
|
|
37
|
+
// Config file doesn't exist, use defaults
|
|
38
|
+
}
|
|
39
|
+
// Default to Anthropic
|
|
40
|
+
return {
|
|
41
|
+
provider: 'anthropic',
|
|
42
|
+
apiKey: process.env.ANTHROPIC_API_KEY
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create Anthropic client with appropriate configuration
|
|
47
|
+
*/ export async function createClient() {
|
|
48
|
+
const config = await getAPIConfig();
|
|
49
|
+
if (!config.apiKey) {
|
|
50
|
+
throw new Error(`API key not found. Set ${config.provider === 'zai' ? 'ZAI_API_KEY' : 'ANTHROPIC_API_KEY'} environment variable.`);
|
|
51
|
+
}
|
|
52
|
+
const clientOptions = {
|
|
53
|
+
apiKey: config.apiKey,
|
|
54
|
+
timeout: 120000,
|
|
55
|
+
maxRetries: 2
|
|
56
|
+
};
|
|
57
|
+
if (config.provider === 'zai' && config.baseURL) {
|
|
58
|
+
clientOptions.baseURL = config.baseURL;
|
|
59
|
+
}
|
|
60
|
+
return new Anthropic(clientOptions);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Map agent model name to API model ID (provider-specific)
|
|
64
|
+
*/ export function mapModelName(agentModel, provider = 'anthropic') {
|
|
65
|
+
// Z.ai uses GLM models - try glm-4.6 first for all models
|
|
66
|
+
if (provider === 'zai') {
|
|
67
|
+
const zaiModelMap = {
|
|
68
|
+
haiku: 'glm-4.6',
|
|
69
|
+
sonnet: 'glm-4.6',
|
|
70
|
+
opus: 'glm-4.6'
|
|
71
|
+
};
|
|
72
|
+
return zaiModelMap[agentModel] || 'glm-4.6';
|
|
73
|
+
}
|
|
74
|
+
// Anthropic uses Claude models
|
|
75
|
+
const modelMap = {
|
|
76
|
+
haiku: 'claude-3-5-haiku-20241022',
|
|
77
|
+
sonnet: 'claude-3-5-sonnet-20241022',
|
|
78
|
+
opus: 'claude-3-opus-20240229'
|
|
79
|
+
};
|
|
80
|
+
return modelMap[agentModel] || modelMap.haiku;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get fallback model for Z.ai (glm-4.6 -> glm-4.5-air)
|
|
84
|
+
*/ function getFallbackModel(model) {
|
|
85
|
+
if (model === 'glm-4.6') {
|
|
86
|
+
return 'glm-4.5-air';
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Send message to Claude API with streaming support and automatic fallback
|
|
92
|
+
*/ export async function sendMessage(options, onChunk) {
|
|
93
|
+
const client = await createClient();
|
|
94
|
+
const config = await getAPIConfig();
|
|
95
|
+
// Primary model (glm-4.6 for Z.ai, Claude for Anthropic)
|
|
96
|
+
let model = mapModelName(options.model, config.provider);
|
|
97
|
+
const maxTokens = options.maxTokens || 16000; // Sprint 6: 16K hard limit for GLM-4.6 (agents target 10K for buffer)
|
|
98
|
+
const temperature = options.temperature ?? 1.0;
|
|
99
|
+
// Disable streaming for Z.ai (compatibility issue)
|
|
100
|
+
const enableStreaming = options.stream && config.provider !== 'zai';
|
|
101
|
+
console.log(`[anthropic-client] Provider: ${config.provider}`);
|
|
102
|
+
console.log(`[anthropic-client] Model: ${model}`);
|
|
103
|
+
console.log(`[anthropic-client] Max tokens: ${maxTokens}`);
|
|
104
|
+
console.log(`[anthropic-client] Stream: ${enableStreaming ? 'enabled' : 'disabled'}`);
|
|
105
|
+
console.log('');
|
|
106
|
+
// Sprint 4: Use messages array if provided (conversation forking)
|
|
107
|
+
const messages = options.messages ? options.messages.map((m)=>({
|
|
108
|
+
role: m.role,
|
|
109
|
+
content: m.content
|
|
110
|
+
})) : [
|
|
111
|
+
{
|
|
112
|
+
role: 'user',
|
|
113
|
+
content: options.prompt
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
// Retry logic: Try primary model (glm-4.6), fall back to glm-4.5 on error
|
|
117
|
+
let lastError = null;
|
|
118
|
+
let attempts = 0;
|
|
119
|
+
const maxAttempts = 2; // Primary + fallback
|
|
120
|
+
while(attempts < maxAttempts){
|
|
121
|
+
const currentModel = attempts === 0 ? model : getFallbackModel(model);
|
|
122
|
+
if (!currentModel) {
|
|
123
|
+
// No fallback available, throw last error
|
|
124
|
+
throw lastError || new Error('No model available');
|
|
125
|
+
}
|
|
126
|
+
attempts++;
|
|
127
|
+
if (attempts > 1) {
|
|
128
|
+
console.log(`[anthropic-client] Retrying with fallback model: ${currentModel}`);
|
|
129
|
+
}
|
|
130
|
+
const requestParams = {
|
|
131
|
+
model: currentModel,
|
|
132
|
+
max_tokens: maxTokens,
|
|
133
|
+
temperature,
|
|
134
|
+
messages
|
|
135
|
+
};
|
|
136
|
+
if (options.systemPrompt) {
|
|
137
|
+
requestParams.system = options.systemPrompt;
|
|
138
|
+
}
|
|
139
|
+
if (options.tools && options.tools.length > 0) {
|
|
140
|
+
requestParams.tools = options.tools;
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
// Streaming response
|
|
144
|
+
if (enableStreaming) {
|
|
145
|
+
let fullContent = '';
|
|
146
|
+
let inputTokens = 0;
|
|
147
|
+
let outputTokens = 0;
|
|
148
|
+
let stopReason = 'end_turn';
|
|
149
|
+
console.log('[anthropic-client] Creating streaming request...');
|
|
150
|
+
const stream = await client.messages.create({
|
|
151
|
+
...requestParams,
|
|
152
|
+
stream: true
|
|
153
|
+
});
|
|
154
|
+
console.log('[anthropic-client] Stream created, processing events...');
|
|
155
|
+
for await (const event of stream){
|
|
156
|
+
console.log('[anthropic-client] Event type:', event.type);
|
|
157
|
+
if (event.type === 'message_start') {
|
|
158
|
+
// @ts-ignore - usage exists on message_start
|
|
159
|
+
inputTokens = event.message.usage?.input_tokens || 0;
|
|
160
|
+
} else if (event.type === 'content_block_delta') {
|
|
161
|
+
// @ts-ignore - text exists on delta
|
|
162
|
+
const text = event.delta?.text || '';
|
|
163
|
+
fullContent += text;
|
|
164
|
+
if (onChunk) {
|
|
165
|
+
onChunk(text);
|
|
166
|
+
}
|
|
167
|
+
} else if (event.type === 'message_delta') {
|
|
168
|
+
// @ts-ignore - usage exists on message_delta
|
|
169
|
+
outputTokens = event.usage?.output_tokens || 0;
|
|
170
|
+
// @ts-ignore - stop_reason exists on delta
|
|
171
|
+
stopReason = event.delta?.stop_reason || 'end_turn';
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
content: fullContent,
|
|
176
|
+
usage: {
|
|
177
|
+
inputTokens,
|
|
178
|
+
outputTokens
|
|
179
|
+
},
|
|
180
|
+
stopReason
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
// Non-streaming response
|
|
184
|
+
const response = await client.messages.create(requestParams);
|
|
185
|
+
const content = response.content.filter((block)=>block.type === 'text').map((block)=>block.text).join('\n') || '';
|
|
186
|
+
return {
|
|
187
|
+
content,
|
|
188
|
+
usage: {
|
|
189
|
+
inputTokens: response.usage.input_tokens,
|
|
190
|
+
outputTokens: response.usage.output_tokens
|
|
191
|
+
},
|
|
192
|
+
stopReason: response.stop_reason || 'end_turn'
|
|
193
|
+
};
|
|
194
|
+
} catch (error) {
|
|
195
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
196
|
+
console.error(`[anthropic-client] Error with model ${currentModel}:`, lastError.message);
|
|
197
|
+
// If this was the last attempt, throw the error
|
|
198
|
+
if (attempts >= maxAttempts) {
|
|
199
|
+
throw lastError;
|
|
200
|
+
}
|
|
201
|
+
// Continue to next attempt with fallback model
|
|
202
|
+
console.log('[anthropic-client] Will retry with fallback model...');
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// Should never reach here
|
|
206
|
+
throw lastError || new Error('All retry attempts failed');
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Execute agent with tool support (agentic loop)
|
|
210
|
+
*
|
|
211
|
+
* Handles:
|
|
212
|
+
* 1. Send message with tools
|
|
213
|
+
* 2. Get response
|
|
214
|
+
* 3. If tool_use blocks, execute tools and send results back
|
|
215
|
+
* 4. Repeat until final text response
|
|
216
|
+
*/ async function executeWithTools(options, onChunk) {
|
|
217
|
+
const client = await createClient();
|
|
218
|
+
const config = await getAPIConfig();
|
|
219
|
+
const model = mapModelName(options.model, config.provider);
|
|
220
|
+
const maxTokens = options.maxTokens || 16000;
|
|
221
|
+
const temperature = options.temperature ?? 1.0;
|
|
222
|
+
// Build initial messages array
|
|
223
|
+
const messages = options.messages ? options.messages.map((m)=>({
|
|
224
|
+
role: m.role,
|
|
225
|
+
content: m.content
|
|
226
|
+
})) : [
|
|
227
|
+
{
|
|
228
|
+
role: 'user',
|
|
229
|
+
content: options.prompt
|
|
230
|
+
}
|
|
231
|
+
];
|
|
232
|
+
let totalInputTokens = 0;
|
|
233
|
+
let totalOutputTokens = 0;
|
|
234
|
+
let fullTextContent = '';
|
|
235
|
+
const MAX_ITERATIONS = 10; // Prevent infinite loops
|
|
236
|
+
let iteration = 0;
|
|
237
|
+
while(iteration < MAX_ITERATIONS){
|
|
238
|
+
iteration++;
|
|
239
|
+
console.log(`[executeWithTools] Iteration ${iteration}`);
|
|
240
|
+
const requestParams = {
|
|
241
|
+
model,
|
|
242
|
+
max_tokens: maxTokens,
|
|
243
|
+
temperature,
|
|
244
|
+
messages
|
|
245
|
+
};
|
|
246
|
+
if (options.systemPrompt) {
|
|
247
|
+
requestParams.system = options.systemPrompt;
|
|
248
|
+
}
|
|
249
|
+
if (options.tools && options.tools.length > 0) {
|
|
250
|
+
requestParams.tools = options.tools;
|
|
251
|
+
}
|
|
252
|
+
// Make API request (non-streaming for now to handle tool_use)
|
|
253
|
+
const response = await client.messages.create(requestParams);
|
|
254
|
+
totalInputTokens += response.usage.input_tokens;
|
|
255
|
+
totalOutputTokens += response.usage.output_tokens;
|
|
256
|
+
// Extract content blocks
|
|
257
|
+
const textBlocks = response.content.filter((block)=>block.type === 'text');
|
|
258
|
+
const toolUseBlocks = response.content.filter((block)=>block.type === 'tool_use');
|
|
259
|
+
// Stream text output
|
|
260
|
+
for (const block of textBlocks){
|
|
261
|
+
if (block.type === 'text') {
|
|
262
|
+
const text = block.text;
|
|
263
|
+
fullTextContent += text;
|
|
264
|
+
if (onChunk) {
|
|
265
|
+
onChunk(text);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// If no tool uses, we're done
|
|
270
|
+
if (toolUseBlocks.length === 0) {
|
|
271
|
+
console.log(`[executeWithTools] No tool uses, completing`);
|
|
272
|
+
return {
|
|
273
|
+
content: fullTextContent,
|
|
274
|
+
usage: {
|
|
275
|
+
inputTokens: totalInputTokens,
|
|
276
|
+
outputTokens: totalOutputTokens
|
|
277
|
+
},
|
|
278
|
+
stopReason: response.stop_reason || 'end_turn'
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
// Execute tools
|
|
282
|
+
console.log(`[executeWithTools] Executing ${toolUseBlocks.length} tool(s)`);
|
|
283
|
+
const toolResults = [];
|
|
284
|
+
for (const toolUseBlock of toolUseBlocks){
|
|
285
|
+
if (toolUseBlock.type !== 'tool_use') continue;
|
|
286
|
+
const toolUse = {
|
|
287
|
+
type: 'tool_use',
|
|
288
|
+
id: toolUseBlock.id,
|
|
289
|
+
name: toolUseBlock.name,
|
|
290
|
+
input: toolUseBlock.input
|
|
291
|
+
};
|
|
292
|
+
console.log(`[executeWithTools] Tool: ${toolUse.name}`);
|
|
293
|
+
const result = await executeTool(toolUse);
|
|
294
|
+
toolResults.push(result);
|
|
295
|
+
// Stream tool result
|
|
296
|
+
if (onChunk) {
|
|
297
|
+
onChunk(`\n[Tool: ${toolUse.name}] ${result.content.substring(0, 100)}${result.content.length > 100 ? '...' : ''}\n`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Add assistant message with tool_use
|
|
301
|
+
messages.push({
|
|
302
|
+
role: 'assistant',
|
|
303
|
+
content: response.content
|
|
304
|
+
});
|
|
305
|
+
// Add tool results as user message
|
|
306
|
+
messages.push({
|
|
307
|
+
role: 'user',
|
|
308
|
+
content: toolResults
|
|
309
|
+
});
|
|
310
|
+
// Continue to next iteration
|
|
311
|
+
}
|
|
312
|
+
// Reached max iterations
|
|
313
|
+
console.warn(`[executeWithTools] Reached max iterations (${MAX_ITERATIONS})`);
|
|
314
|
+
return {
|
|
315
|
+
content: fullTextContent,
|
|
316
|
+
usage: {
|
|
317
|
+
inputTokens: totalInputTokens,
|
|
318
|
+
outputTokens: totalOutputTokens
|
|
319
|
+
},
|
|
320
|
+
stopReason: 'max_tokens'
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Execute agent via API with full lifecycle
|
|
325
|
+
*/ export async function executeAgentAPI(agentType, agentId, model, prompt, systemPrompt, messages, maxTokens, tools// Tool definitions for agent capabilities
|
|
326
|
+
) {
|
|
327
|
+
// Start heartbeat monitoring (declare at function scope for error handling)
|
|
328
|
+
let heartbeatInterval = null;
|
|
329
|
+
const taskId = process.env.TASK_ID;
|
|
330
|
+
try {
|
|
331
|
+
console.log(`[anthropic-client] Executing agent: ${agentType}`);
|
|
332
|
+
console.log(`[anthropic-client] Agent ID: ${agentId}`);
|
|
333
|
+
if (messages && messages.length > 1) {
|
|
334
|
+
console.log(`[anthropic-client] Continuing conversation (${messages.length} messages)`);
|
|
335
|
+
}
|
|
336
|
+
console.log('');
|
|
337
|
+
if (taskId) {
|
|
338
|
+
heartbeatInterval = setInterval(async ()=>{
|
|
339
|
+
try {
|
|
340
|
+
await execAsync(`redis-cli hset "swarm:${taskId}:agent:${agentId}" heartbeat "${Date.now()}" status "working"`);
|
|
341
|
+
} catch (err) {
|
|
342
|
+
console.error('[heartbeat] Error sending heartbeat:', err);
|
|
343
|
+
}
|
|
344
|
+
}, 30000); // Every 30 seconds
|
|
345
|
+
console.log(`[heartbeat] Monitoring started for agent ${agentId} (30s interval)`);
|
|
346
|
+
}
|
|
347
|
+
let fullOutput = '';
|
|
348
|
+
// If tools provided, use agentic loop with tool execution
|
|
349
|
+
// Otherwise use simple streaming
|
|
350
|
+
let response;
|
|
351
|
+
if (tools && tools.length > 0) {
|
|
352
|
+
console.log(`[anthropic-client] Tools enabled: ${tools.map((t)=>t.name).join(', ')}`);
|
|
353
|
+
response = await executeWithTools({
|
|
354
|
+
model,
|
|
355
|
+
prompt,
|
|
356
|
+
systemPrompt,
|
|
357
|
+
messages,
|
|
358
|
+
maxTokens,
|
|
359
|
+
tools
|
|
360
|
+
}, (chunk)=>{
|
|
361
|
+
process.stdout.write(chunk);
|
|
362
|
+
fullOutput += chunk;
|
|
363
|
+
});
|
|
364
|
+
} else {
|
|
365
|
+
response = await sendMessage({
|
|
366
|
+
model,
|
|
367
|
+
prompt,
|
|
368
|
+
systemPrompt,
|
|
369
|
+
stream: true,
|
|
370
|
+
messages,
|
|
371
|
+
maxTokens
|
|
372
|
+
}, (chunk)=>{
|
|
373
|
+
process.stdout.write(chunk);
|
|
374
|
+
fullOutput += chunk;
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
console.log('\n');
|
|
378
|
+
console.log('=== Agent Execution Complete ===');
|
|
379
|
+
console.log(`Input tokens: ${response.usage.inputTokens}`);
|
|
380
|
+
console.log(`Output tokens: ${response.usage.outputTokens}`);
|
|
381
|
+
console.log(`Stop reason: ${response.stopReason}`);
|
|
382
|
+
// Stop heartbeat and send final status
|
|
383
|
+
if (heartbeatInterval) {
|
|
384
|
+
clearInterval(heartbeatInterval);
|
|
385
|
+
if (taskId) {
|
|
386
|
+
await execAsync(`redis-cli hset "swarm:${taskId}:agent:${agentId}" heartbeat "${Date.now()}" status "complete"`);
|
|
387
|
+
console.log(`[heartbeat] Monitoring stopped - agent ${agentId} complete`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
success: true,
|
|
392
|
+
output: response.content,
|
|
393
|
+
usage: response.usage
|
|
394
|
+
};
|
|
395
|
+
} catch (error) {
|
|
396
|
+
console.error('[anthropic-client] Error:', error);
|
|
397
|
+
// Stop heartbeat and send error status
|
|
398
|
+
if (heartbeatInterval) {
|
|
399
|
+
clearInterval(heartbeatInterval);
|
|
400
|
+
if (taskId) {
|
|
401
|
+
try {
|
|
402
|
+
await execAsync(`redis-cli hset "swarm:${taskId}:agent:${agentId}" heartbeat "${Date.now()}" status "error"`);
|
|
403
|
+
console.log(`[heartbeat] Monitoring stopped - agent ${agentId} error`);
|
|
404
|
+
} catch (err) {
|
|
405
|
+
// Ignore heartbeat errors during error handling
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return {
|
|
410
|
+
success: false,
|
|
411
|
+
output: '',
|
|
412
|
+
usage: {
|
|
413
|
+
inputTokens: 0,
|
|
414
|
+
outputTokens: 0
|
|
415
|
+
},
|
|
416
|
+
error: error instanceof Error ? error.message : String(error)
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
//# sourceMappingURL=anthropic-client.js.map
|