claude-flow-novice 2.5.2 → 2.6.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.
Files changed (46) hide show
  1. package/.claude/agents/CLAUDE.md +740 -978
  2. package/.claude/agents/core-agents/cost-savings-cfn-loop-coordinator.md +47 -2
  3. package/.claude/agents/custom/agent-builder.md +637 -0
  4. package/.claude/api-configs/config-current-zai-config.env +62 -0
  5. package/.claude/api-configs/config-test-zai-config.env +62 -0
  6. package/.claude/api-configs/env-backups/before-anthropic-20251020-025404.env +62 -0
  7. package/.claude/api-configs/env-backups/before-restore-20251020-025431.env +62 -0
  8. package/.claude/artifacts/reflection-merge-logs/cli-agent-spawning-v2.5.2-merge-report.md +61 -0
  9. package/.claude/commands/cfn-loop-epic.md +41 -17
  10. package/.claude/commands/cfn-loop.md +43 -30
  11. package/.claude/commands/custom-routing-activate.md +37 -123
  12. package/.claude/commands/custom-routing-deactivate.md +27 -124
  13. package/.claude/commands/switch-api.md +41 -16
  14. package/.claude/skills/agent-execution/execute-agent.sh +126 -0
  15. package/.claude/skills/redis-coordination/AGENT_LOGGING.md +280 -0
  16. package/.claude/skills/redis-coordination/agent-log.sh +124 -0
  17. package/.claude/skills/redis-coordination/init-swarm.sh +6 -1
  18. package/.claude/skills/redis-coordination/invoke-waiting-mode.sh +62 -5
  19. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh +68 -8
  20. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup-1760949407 +933 -0
  21. package/.claude/skills/redis-coordination/store-epic-context.sh +123 -0
  22. package/.claude/skills/redis-coordination/test-iteration-feedback.sh +320 -0
  23. package/.claude/skills/skill-builder/SKILL.md +910 -0
  24. package/CLAUDE.md +76 -2
  25. package/dist/cli/agent-command.js +151 -0
  26. package/dist/cli/agent-command.js.map +1 -0
  27. package/dist/cli/agent-definition-parser.js +176 -0
  28. package/dist/cli/agent-definition-parser.js.map +1 -0
  29. package/dist/cli/agent-executor.js +176 -0
  30. package/dist/cli/agent-executor.js.map +1 -0
  31. package/dist/cli/agent-prompt-builder.js +188 -0
  32. package/dist/cli/agent-prompt-builder.js.map +1 -0
  33. package/dist/cli/agent-spawn.js +46 -1
  34. package/dist/cli/agent-spawn.js.map +1 -1
  35. package/dist/cli/anthropic-client.js +242 -0
  36. package/dist/cli/anthropic-client.js.map +1 -0
  37. package/dist/cli/cli-agent-context.js +353 -0
  38. package/dist/cli/cli-agent-context.js.map +1 -0
  39. package/dist/cli/cli-agent-context.test.js +451 -0
  40. package/dist/cli/cli-agent-context.test.js.map +1 -0
  41. package/dist/cli/index.js +115 -2
  42. package/dist/cli/index.js.map +1 -1
  43. package/dist/cli/iteration-history.js +188 -0
  44. package/dist/cli/iteration-history.js.map +1 -0
  45. package/package.json +3 -1
  46. package/scripts/switch-api.sh +233 -0
@@ -1,141 +1,55 @@
1
- # /custom-routing-activate - Enable Cost-Optimized Routing
1
+ ---
2
+ description: DEPRECATED - Use /switch-api zai instead
3
+ tags: [deprecated, routing]
4
+ ---
2
5
 
3
- Activate tiered provider routing to reduce LLM costs by routing most agents to Z.ai while keeping high-value agents on Anthropic.
6
+ # ⚠️ DEPRECATED Command
4
7
 
5
- ## Usage
8
+ **This command is deprecated and no longer needed.**
6
9
 
7
- ```bash
8
- /custom-routing-activate
9
- ```
10
-
11
- Simple! No arguments needed. Just run the command to enable cost optimization.
12
-
13
- ## What It Does
14
-
15
- Activates intelligent routing with three priority levels:
16
-
17
- ### Priority 1: Agent Profile Override
18
- Agents can specify their preferred provider in their profile:
19
- ```yaml
20
- provider: zai # Force Z.ai for this agent
21
- provider: anthropic # Force Anthropic for this agent
22
- ```
23
-
24
- ### Priority 2: Tier Configuration
25
- **ALL Task Tool agents route to Z.ai** for maximum cost savings:
26
- - `coder`, `tester`, `reviewer` → Z.ai
27
- - `architect`, `coordinator`, `system-architect` → Z.ai
28
- - `devops-engineer`, `security-specialist` → Z.ai
29
- - All 70+ agent types → Z.ai
30
-
31
- Only the main chat uses Anthropic Claude Max:
32
- - `main-chat` → Anthropic (your direct conversations)
33
-
34
- ## Cost Savings
35
-
36
- **Example calculation:**
37
- ```
38
- Without routing: 100 agent calls × $0.015 = $1.50
39
- With routing: 99 calls × $0.003 (Z.ai) + 1 call × $0.015 (main-chat) = $0.31
40
-
41
- 💰 Savings: 79% cost reduction (all agents on Z.ai)
42
- ```
43
-
44
- ## Output
45
-
46
- When you run `/custom-routing-activate`:
47
-
48
- ```
49
- ═══════════════════════════════════════════════════════
50
- Activating Tiered Provider Routing
51
- ═══════════════════════════════════════════════════════
52
-
53
- ✅ Tiered Provider Routing ACTIVATED
10
+ ## Use Instead
54
11
 
55
- 📊 Active Routing:
56
- ALL Task Tool agents (70+ types) → Z.ai
57
- • Main chat only → Anthropic Claude Max
58
- • Maximum cost optimization enabled
59
-
60
- 💰 Cost Optimization:
61
- • ~79% cost reduction on agent usage
62
- • All spawned agents use affordable Z.ai provider
63
- • Only main chat uses Anthropic Claude Max
64
-
65
- 🎯 Agent Profile Overrides:
66
- • Add provider: zai to agent profile → force Z.ai
67
- • Add provider: anthropic to agent profile → force Anthropic
68
-
69
- 💾 Configuration saved to:
70
- /path/to/project/.claude/settings.json
71
-
72
- 📖 To disable routing:
73
- /custom-routing-deactivate
74
- ═══════════════════════════════════════════════════════
75
- ```
76
-
77
- ## When to Use
78
-
79
- **Enable for:**
80
- - ✅ Production development (cost savings)
81
- - ✅ High-volume agent usage
82
- - ✅ Projects with budget constraints
83
- - ✅ Default recommendation for most projects
84
-
85
- **Disable for:**
86
- - Testing quality differences between providers
87
- - Debugging provider-specific issues
88
- - Ensuring consistent provider behavior
89
- - Short-term projects where consistency matters more than cost
90
-
91
- ## Configuration
92
-
93
- Settings are saved to `.claude/settings.json`:
94
-
95
- ```json
96
- {
97
- "tieredRouting": {
98
- "enabled": true
99
- }
100
- }
12
+ ```bash
13
+ /switch-api zai
101
14
  ```
102
15
 
103
- ## Related Commands
16
+ ## What Changed
104
17
 
105
- - `/custom-routing-deactivate` - Disable tiered routing
106
- - `/cfn-loop` - Self-correcting development loop (respects routing)
107
- - `/swarm` - Multi-agent coordination (respects routing)
18
+ **Old system (custom-routing):**
19
+ - Designed for per-agent profile routing
20
+ - Required `tieredRouting` flag in settings.json
21
+ - Never fully implemented
108
22
 
109
- ## Best Practices
23
+ **New system (switch-api):**
24
+ - ✅ Simple env var configuration
25
+ - ✅ Works with Main Chat + Task tool
26
+ - ✅ CLI agents use separate routing (.env)
27
+ - ✅ Fully operational
110
28
 
111
- 1. **Enable by default** - Activate routing for immediate cost savings
112
- 2. **Monitor quality** - Ensure Z.ai quality meets your standards
113
- 3. **Profile strategic agents** - Mark critical agents with `provider: anthropic`
114
- 4. **Test both modes** - Compare results with routing on and off
29
+ ## Migration
115
30
 
116
- ## Examples
117
-
118
- ### First-time activation
31
+ **If you were using `/custom-routing-activate`:**
119
32
  ```bash
120
- $ /custom-routing-activate
121
-
122
- ✅ Tiered Provider Routing ACTIVATED
123
-
124
- 💰 Cost Optimization:
125
- • ~64% cost reduction on agent usage
33
+ # Just run this instead:
34
+ /switch-api zai
126
35
  ```
127
36
 
128
- ### Already activated
129
- ```bash
130
- $ /custom-routing-activate
37
+ **Effect:**
38
+ - Main Chat + Task() agents use Z.ai ($0.50/1M)
39
+ - CLI agents use Z.ai (from .env)
40
+ - Combined 97% cost savings
131
41
 
132
- Tiered routing is already ENABLED
42
+ ## Why Deprecated
133
43
 
134
- 💡 To disable, run: /custom-routing-deactivate
135
- ```
44
+ The custom-routing system was designed but never fully implemented. The new switch-api provides:
45
+
46
+ 1. **Simpler configuration** - Just env vars
47
+ 2. **Actually works** - Complete implementation
48
+ 3. **Clear separation** - Main Chat vs CLI routing
49
+ 4. **Better documentation** - See `/switch-api` help
136
50
 
137
51
  ## See Also
138
52
 
139
- - **Deactivation**: `/custom-routing-deactivate`
140
- - **Status Check**: `/activate-custom-routing` (shows current status)
141
- - **Agent Profiles**: `.claude/agents/*.md` (add `provider` field)
53
+ - `/switch-api` - Current routing system
54
+ - `/switch-api zai` - Enable Z.ai for Main Chat
55
+ - `/switch-api max` - Use Anthropic for Main Chat
@@ -1,143 +1,46 @@
1
- # /custom-routing-deactivate - Disable Tiered Routing
1
+ ---
2
+ description: DEPRECATED - Use /switch-api max instead
3
+ tags: [deprecated, routing]
4
+ ---
2
5
 
3
- Deactivate tiered provider routing so all agents use the default provider configuration (sonnet model).
6
+ # ⚠️ DEPRECATED Command
4
7
 
5
- ## Usage
8
+ **This command is deprecated and no longer needed.**
6
9
 
7
- ```bash
8
- /custom-routing-deactivate
9
- ```
10
-
11
- Simple! No arguments needed. Just run the command to disable tiered routing.
12
-
13
- ## What It Does
14
-
15
- Disables profile-based provider routing. After deactivation:
16
-
17
- - ✅ All agents use **sonnet model** (from agent profiles)
18
- - ✅ Single provider for all agents
19
- - ✅ No provider-based routing
20
- - ✅ Consistent behavior across all agents
21
-
22
- ## Use Cases
23
-
24
- **Disable for:**
25
- - Testing quality differences between providers
26
- - Debugging provider-specific issues
27
- - Ensuring consistent provider behavior
28
- - A/B testing routing vs non-routing
29
- - Projects where consistency matters more than cost
30
-
31
- **Enable for:**
32
- - Production development (cost savings)
33
- - High-volume agent usage
34
- - Projects with budget constraints
35
-
36
- ## Output
37
-
38
- When you run `/custom-routing-deactivate`:
39
-
40
- ```
41
- ═══════════════════════════════════════════════════════
42
- Deactivating Tiered Provider Routing
43
- ═══════════════════════════════════════════════════════
44
-
45
- ✅ Tiered Provider Routing DEACTIVATED
46
-
47
- 📊 Current Routing:
48
- • All agents use sonnet model (from agent profiles)
49
- • Single provider for all agents
50
- • No provider-based routing
51
-
52
- ⚠️ Cost Impact:
53
- • All agents use default provider (typically Anthropic)
54
- • No cost optimization active
55
- • Useful for testing or consistency requirements
56
-
57
- 💾 Configuration saved to:
58
- /path/to/project/.claude/settings.json
59
-
60
- 📖 To enable routing:
61
- /custom-routing-activate
62
- ═══════════════════════════════════════════════════════
63
- ```
10
+ ## Use Instead
64
11
 
65
- ## Configuration
66
-
67
- Settings are saved to `.claude/settings.json`:
68
-
69
- ```json
70
- {
71
- "tieredRouting": {
72
- "enabled": false
73
- }
74
- }
75
- ```
76
-
77
- ## Cost Impact
78
-
79
- **Without routing (after deactivation):**
80
- ```
81
- 100 agent calls × $0.015 (Anthropic) = $1.50
82
- ```
83
-
84
- **With routing (before deactivation):**
85
- ```
86
- 80 calls × $0.003 (Z.ai) + 20 calls × $0.015 (Anthropic) = $0.54
12
+ ```bash
13
+ /switch-api max
87
14
  ```
88
15
 
89
- **Impact of deactivation:** +$0.96 per 100 agent calls (178% increase)
90
-
91
- ## Related Commands
92
-
93
- - `/custom-routing-activate` - Enable tiered routing
94
- - `/activate-custom-routing` - Show routing status
95
- - `/cfn-loop` - Self-correcting development loop
16
+ ## What This Does
96
17
 
97
- ## When to Deactivate
18
+ Switches Main Chat + Task tool back to Anthropic (default provider).
98
19
 
99
- ### Good Reasons:
100
- ✅ Testing quality differences
101
- ✅ Debugging provider issues
102
- ✅ Short-term consistency needs
103
- ✅ Comparing routing vs non-routing
20
+ **Note:** Requires running `claude login` after switching.
104
21
 
105
- ### Bad Reasons:
106
- ❌ "I don't understand routing" - Learn it first, saves money
107
- ❌ "Too complicated" - It's automatic once enabled
108
- ❌ "Not sure if it works" - Test it with small tasks first
22
+ ## Migration
109
23
 
110
- ## Examples
111
-
112
- ### Deactivate routing
24
+ **If you were using `/custom-routing-deactivate`:**
113
25
  ```bash
114
- $ /custom-routing-deactivate
115
-
116
- ✅ Tiered Provider Routing DEACTIVATED
26
+ # Just run this instead:
27
+ /switch-api max
117
28
 
118
- 📊 Current Routing:
119
- All agents use sonnet model (from agent profiles)
120
- • Single provider for all agents
29
+ # Then re-authenticate:
30
+ claude login
121
31
  ```
122
32
 
123
- ### Already deactivated
124
- ```bash
125
- $ /custom-routing-deactivate
126
-
127
- ✅ Tiered routing is already DISABLED
128
-
129
- 💡 To enable cost optimization, run: /custom-routing-activate
130
- ```
33
+ ## Why Deprecated
131
34
 
132
- ## Best Practices
35
+ The custom-routing system was designed but never fully implemented. The new switch-api provides the same functionality with:
133
36
 
134
- 1. **Deactivate temporarily** - Only disable for testing, then re-enable
135
- 2. **Document why** - Note the reason for deactivation in project docs
136
- 3. **Set reminder** - Remember to re-enable after testing
137
- 4. **Compare results** - Use deactivation to validate routing quality
37
+ 1. **Simpler commands** - `/switch-api zai` or `/switch-api max`
38
+ 2. **Actually works** - Complete implementation
39
+ 3. **Clear behavior** - Explicit env var management
40
+ 4. **Better docs** - See `/switch-api` help
138
41
 
139
42
  ## See Also
140
43
 
141
- - **Activation**: `/custom-routing-activate`
142
- - **Status Check**: `/activate-custom-routing`
143
- - **Cost Analysis**: Check `.claude/settings.json` for current state
44
+ - `/switch-api` - Current routing system
45
+ - `/switch-api max` - Use Anthropic for Main Chat
46
+ - `/switch-api zai` - Use Z.ai for cost savings
@@ -1,28 +1,53 @@
1
1
  ---
2
- description: Switch between z.ai and Anthropic Claude Max API providers
3
- tags: [config, api, utility]
2
+ description: Switch Main Chat and Task tool between Z.ai and Anthropic providers
3
+ tags: [config, api, cost-optimization]
4
4
  ---
5
5
 
6
- Switch Claude API provider between z.ai (GLM models) and official Anthropic Claude Max.
6
+ Switch Main Chat and Task() tool API provider between Z.ai (cost-optimized) and Anthropic (high-quality).
7
+
8
+ **Important:** CLI agents always use Z.ai (from `.env`). This command only affects Main Chat and Task() spawned agents.
7
9
 
8
10
  **Usage:**
9
- - `/switch-api` - Show current API
10
- - `/switch-api zai` - Switch to z.ai (GLM-4.6)
11
- - `/switch-api max` - Switch to Claude Max
12
- - `/switch-api list` - List saved configurations
13
- - `/switch-api save <name>` - Save current config
14
- - `/switch-api restore <name>` - Restore saved config
11
+ - `/switch-api` - Show current status
12
+ - `/switch-api zai` - Main Chat/Task tool use Z.ai ($0.50/1M tokens)
13
+ - `/switch-api max` - Main Chat/Task tool use Anthropic ($15/1M tokens, requires re-login)
15
14
 
16
15
  **Arguments:**
17
- - `zai` - Use z.ai API with GLM models
18
- - `max` or `claude` - Use official Anthropic API
19
- - `status` - Show current API configuration
20
- - `list` - List all saved configurations
21
- - `save <name>` - Save current settings
22
- - `restore <name>` - Restore previously saved settings
16
+ - `status` - Show current routing configuration (default)
17
+ - `zai` - Route Main Chat + Task tool to Z.ai for cost savings
18
+ - `max` or `claude` - Route Main Chat + Task tool to Anthropic for quality
19
+
20
+ **What This Does:**
21
+
22
+ `/switch-api zai`:
23
+ - Adds env vars to `.claude/settings.json`
24
+ - Main Chat + Task() agents use Z.ai
25
+ - Cost: $0.50/1M tokens (97% savings)
26
+ - No login required
23
27
 
24
- Execute API switch using bash script:
28
+ `/switch-api max`:
29
+ - Removes env vars from `.claude/settings.json`
30
+ - Main Chat + Task() agents use Anthropic
31
+ - Cost: $15/1M tokens (or $0 with unlimited plan)
32
+ - **Requires** running `claude login`
25
33
 
34
+ **Combined Architecture:**
35
+ ```
36
+ Main Chat (Anthropic or Z.ai - your choice)
37
+
38
+ Task() → Coordinator (uses Main Chat provider)
39
+
40
+ CLI spawn → Workers (always Z.ai from .env)
41
+ ```
42
+
43
+ **Execute:**
26
44
  ```bash
27
45
  bash scripts/switch-api.sh {{args}}
28
46
  ```
47
+
48
+ **Examples:**
49
+ ```bash
50
+ /switch-api # Show current routing
51
+ /switch-api zai # Cost-optimize Main Chat
52
+ /switch-api max # Quality-optimize Main Chat (requires re-login)
53
+ ```
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env bash
2
+ ##############################################################################
3
+ # Agent Execution Script
4
+ #
5
+ # Executes CLI-spawned agents by invoking Claude API with agent prompt.
6
+ # Supports both Anthropic and z.ai provider routing.
7
+ #
8
+ # Environment Variables:
9
+ # AGENT_TYPE - Agent type/name (e.g., "rust-enterprise-developer")
10
+ # AGENT_ID - Unique agent identifier (e.g., "rust-enterprise-1")
11
+ # AGENT_MODEL - Model to use (haiku, sonnet, opus)
12
+ # AGENT_TOOLS - Comma-separated list of tools
13
+ # TASK_ID - Task identifier for CFN Loop coordination
14
+ # ITERATION - Current iteration number
15
+ # MODE - Execution mode (cli, api, hybrid)
16
+ # PROMPT_FILE - Path to file containing agent prompt
17
+ #
18
+ # Usage:
19
+ # ./execute-agent.sh
20
+ ##############################################################################
21
+
22
+ set -euo pipefail
23
+
24
+ # Validate required environment variables
25
+ if [ -z "${AGENT_TYPE:-}" ]; then
26
+ echo "Error: AGENT_TYPE environment variable required" >&2
27
+ exit 1
28
+ fi
29
+
30
+ if [ -z "${PROMPT_FILE:-}" ] || [ ! -f "${PROMPT_FILE:-}" ]; then
31
+ echo "Error: PROMPT_FILE must be set and file must exist" >&2
32
+ exit 1
33
+ fi
34
+
35
+ # Default values
36
+ AGENT_ID="${AGENT_ID:-${AGENT_TYPE}-1}"
37
+ AGENT_MODEL="${AGENT_MODEL:-haiku}"
38
+ TASK_ID="${TASK_ID:-}"
39
+ ITERATION="${ITERATION:-1}"
40
+ MODE="${MODE:-cli}"
41
+
42
+ echo "=== Agent Execution ==="
43
+ echo "Agent Type: $AGENT_TYPE"
44
+ echo "Agent ID: $AGENT_ID"
45
+ echo "Model: $AGENT_MODEL"
46
+ echo "Task ID: ${TASK_ID:-N/A}"
47
+ echo "Iteration: $ITERATION"
48
+ echo "Mode: $MODE"
49
+ echo ""
50
+
51
+ # Read prompt from file
52
+ PROMPT=$(cat "$PROMPT_FILE")
53
+
54
+ # Determine API provider
55
+ API_PROVIDER="anthropic"
56
+ if [ -f ".claude/config/api-provider.json" ]; then
57
+ PROVIDER_CONFIG=$(cat .claude/config/api-provider.json)
58
+ if echo "$PROVIDER_CONFIG" | grep -q '"provider".*"zai"'; then
59
+ API_PROVIDER="zai"
60
+ fi
61
+ fi
62
+
63
+ if [ "${CLAUDE_API_PROVIDER:-}" = "zai" ]; then
64
+ API_PROVIDER="zai"
65
+ fi
66
+
67
+ echo "API Provider: $API_PROVIDER"
68
+ echo ""
69
+
70
+ # Map agent model to API model name
71
+ case "$AGENT_MODEL" in
72
+ haiku)
73
+ API_MODEL="claude-3-5-haiku-20241022"
74
+ ;;
75
+ sonnet)
76
+ API_MODEL="claude-3-5-sonnet-20241022"
77
+ ;;
78
+ opus)
79
+ API_MODEL="claude-3-opus-20240229"
80
+ ;;
81
+ *)
82
+ echo "Warning: Unknown model '$AGENT_MODEL', defaulting to haiku" >&2
83
+ API_MODEL="claude-3-5-haiku-20241022"
84
+ ;;
85
+ esac
86
+
87
+ # For now, we'll simulate agent execution by echoing the prompt
88
+ # TODO: Implement actual API calls when API client is ready
89
+ echo "=== Agent Prompt (First 500 chars) ==="
90
+ echo "$PROMPT" | head -c 500
91
+ echo "..."
92
+ echo ""
93
+ echo "=== Agent Execution Status ==="
94
+ echo "✅ Agent prompt prepared successfully"
95
+ echo "⚠️ Note: Direct API execution not yet implemented"
96
+ echo ""
97
+ echo "Next Steps:"
98
+ echo "1. Integrate with Claude API SDK"
99
+ echo "2. Implement streaming response handling"
100
+ echo "3. Add tool execution support"
101
+ echo ""
102
+
103
+ # For CFN Loop agents, simulate completion protocol
104
+ if [ -n "$TASK_ID" ]; then
105
+ echo "=== CFN Loop Simulation ==="
106
+ echo "This agent would execute the following protocol:"
107
+ echo ""
108
+ echo "1. Execute task work"
109
+ echo "2. redis-cli lpush \"swarm:${TASK_ID}:${AGENT_ID}:done\" \"complete\""
110
+ echo "3. ./.claude/skills/redis-coordination/invoke-waiting-mode.sh report \\"
111
+ echo " --task-id \"$TASK_ID\" \\"
112
+ echo " --agent-id \"$AGENT_ID\" \\"
113
+ echo " --confidence 0.85 \\"
114
+ echo " --iteration $ITERATION"
115
+ echo "4. ./.claude/skills/redis-coordination/invoke-waiting-mode.sh enter \\"
116
+ echo " --task-id \"$TASK_ID\" \\"
117
+ echo " --agent-id \"$AGENT_ID\" \\"
118
+ echo " --context \"iteration-complete\""
119
+ echo ""
120
+ fi
121
+
122
+ # Clean up prompt file
123
+ rm -f "$PROMPT_FILE"
124
+
125
+ # Exit with success (temporary until real execution implemented)
126
+ exit 0