claude-flow-novice 2.15.1 → 2.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/cfn-extras/agents/google-sheets-specialist.md +614 -0
- package/.claude/commands/cfn/create-handoff.md +224 -0
- package/.claude/hooks/cfn-BACKUP_USAGE.md +243 -243
- package/.claude/hooks/cfn-invoke-security-validation.sh +69 -69
- package/.claude/hooks/cfn-post-edit-cfn-retrospective.sh +78 -78
- package/.claude/hooks/cfn-post-edit.config.json +44 -44
- package/.claude/skills/agent-lifecycle/SKILL.md +60 -0
- package/.claude/skills/agent-lifecycle/execute-lifecycle-hook.sh +573 -0
- package/.claude/skills/agent-lifecycle/simple-audit.sh +31 -0
- package/.claude/skills/cfn-hybrid-routing/check-dependencies.sh +51 -51
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -252
- package/.claude/skills/cfn-redis-coordination/agent-recovery.sh +74 -74
- package/.claude/skills/cfn-redis-coordination/get-context.sh +112 -112
- package/.claude/skills/cfn-transparency-middleware/middleware-config.sh +28 -28
- package/.claude/skills/cfn-transparency-middleware/performance-benchmark.sh +78 -78
- package/.claude/skills/cfn-transparency-middleware/test-integration.sh +161 -161
- package/.claude/skills/cfn-transparency-middleware/test-transparency-skill.sh +367 -367
- package/.claude/skills/cfn-transparency-middleware/tests/input-validation.sh +92 -92
- package/.claude/skills/cfn-transparency-middleware/wrap-agent.sh +131 -131
- package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +662 -0
- package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +29 -0
- package/claude-assets/cfn-extras/agents/google-sheets-specialist.md +614 -0
- package/claude-assets/commands/cfn/create-handoff.md +224 -0
- package/claude-assets/hooks/cfn-BACKUP_USAGE.md +243 -243
- package/claude-assets/hooks/cfn-invoke-security-validation.sh +69 -69
- package/claude-assets/hooks/cfn-post-edit-cfn-retrospective.sh +78 -78
- package/claude-assets/hooks/cfn-post-edit.config.json +44 -44
- package/claude-assets/hooks/cfn-post-execution/memory-cleanup.sh +19 -19
- package/claude-assets/hooks/cfn-pre-execution/memory-check.sh +19 -19
- package/claude-assets/skills/agent-lifecycle/execute-lifecycle-hook.sh +572 -572
- package/claude-assets/skills/agent-lifecycle/simple-audit.sh +30 -30
- package/claude-assets/skills/cfn-automatic-memory-persistence/persist-agent-output.sh +48 -48
- package/claude-assets/skills/cfn-automatic-memory-persistence/query-agent-history.sh +34 -34
- package/claude-assets/skills/cfn-deliverable-validation/confidence-calculator.sh +261 -261
- package/claude-assets/skills/cfn-expert-update/update-expert.sh +345 -345
- package/claude-assets/skills/cfn-hybrid-routing/check-dependencies.sh +51 -51
- package/claude-assets/skills/cfn-intervention-detector/detect-intervention.sh +110 -110
- package/claude-assets/skills/cfn-intervention-orchestrator/execute-intervention.sh +58 -58
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -252
- package/claude-assets/skills/cfn-loop2-output-processing/process-validator-output.sh +275 -275
- package/claude-assets/skills/cfn-memory-management/check-memory.sh +159 -159
- package/claude-assets/skills/cfn-memory-management/cleanup-memory.sh +196 -196
- package/claude-assets/skills/cfn-node-heap-sizer/task-mode-heap-limiter.sh +325 -325
- package/claude-assets/skills/cfn-playbook-auto-update/auto-update-playbook.sh +85 -85
- package/claude-assets/skills/cfn-redis-coordination/agent-recovery.sh +74 -74
- package/claude-assets/skills/cfn-redis-coordination/get-context.sh +112 -112
- package/claude-assets/skills/cfn-scope-simplifier/simplify-scope.sh +67 -67
- package/claude-assets/skills/cfn-specialist-injection/recommend-specialist.sh +56 -56
- package/claude-assets/skills/cfn-standardized-error-handling/capture-agent-error.sh +86 -86
- package/claude-assets/skills/cfn-standardized-error-handling/test-error-handling.sh +165 -165
- package/claude-assets/skills/cfn-task-config-init/initialize-config.sh +264 -264
- package/claude-assets/skills/cfn-task-decomposition/task-decomposer.sh +278 -278
- package/claude-assets/skills/cfn-transparency-middleware/middleware-config.sh +28 -28
- package/claude-assets/skills/cfn-transparency-middleware/performance-benchmark.sh +78 -78
- package/claude-assets/skills/cfn-transparency-middleware/test-integration.sh +161 -161
- package/claude-assets/skills/cfn-transparency-middleware/test-transparency-skill.sh +367 -367
- package/claude-assets/skills/cfn-transparency-middleware/tests/input-validation.sh +92 -92
- package/claude-assets/skills/cfn-transparency-middleware/wrap-agent.sh +131 -131
- package/claude-assets/skills/docker-build/SKILL.md +96 -203
- package/claude-assets/skills/docker-build/build.sh +73 -73
- package/claude-assets/skills/integration/agent-handoff.sh +494 -0
- package/claude-assets/skills/integration/file-operations.sh +414 -0
- package/claude-assets/skills/workflow-codification/APPROVAL_WORKFLOW.md +806 -0
- package/claude-assets/skills/workflow-codification/COST_TRACKING.md +637 -0
- package/claude-assets/skills/workflow-codification/EDGE_CASE_TRACKING.md +404 -0
- package/claude-assets/skills/workflow-codification/README_PHASE4.md +457 -0
- package/claude-assets/skills/workflow-codification/SKILL.md +110 -0
- package/claude-assets/skills/workflow-codification/analyze-patterns.sh +899 -0
- package/claude-assets/skills/workflow-codification/approval-workflow.sh +514 -0
- package/claude-assets/skills/workflow-codification/generate-skill-update.sh +525 -0
- package/claude-assets/skills/workflow-codification/review-skill.sh +643 -0
- package/claude-assets/skills/workflow-codification/templates/email-notification.txt +114 -0
- package/claude-assets/skills/workflow-codification/templates/slack-notification.md +85 -0
- package/claude-assets/skills/workflow-codification/test-integration.sh +281 -0
- package/claude-assets/skills/workflow-codification/track-cost-savings.sh +445 -0
- package/claude-assets/skills/workflow-codification/track-edge-case.sh +323 -0
- package/dist/agents/agent-loader.js +165 -146
- package/dist/agents/agent-loader.js.map +1 -1
- package/dist/cli/config-manager.js +91 -109
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/integration/DatabaseHandoff.js +507 -0
- package/dist/integration/DatabaseHandoff.js.map +1 -0
- package/dist/integration/StandardAdapter.js +291 -0
- package/dist/integration/StandardAdapter.js.map +1 -0
- package/dist/lib/agent-output-parser.js +518 -0
- package/dist/lib/agent-output-parser.js.map +1 -0
- package/dist/lib/agent-output-validator.js +950 -0
- package/dist/lib/agent-output-validator.js.map +1 -0
- package/dist/lib/artifact-registry.js +443 -0
- package/dist/lib/artifact-registry.js.map +1 -0
- package/dist/lib/config-validator.js +687 -0
- package/dist/lib/config-validator.js.map +1 -0
- package/dist/types/agent-output.js +44 -0
- package/dist/types/agent-output.js.map +1 -0
- package/dist/types/config.js +28 -0
- package/dist/types/config.js.map +1 -0
- package/package.json +2 -1
- package/scripts/artifact-cleanup.sh +392 -0
- package/scripts/build-linux.sh +78 -0
- package/scripts/deploy-production.sh +355 -355
- package/scripts/docker-playwright-fix.sh +311 -311
- package/scripts/docker-rebuild-all-agents.sh +127 -127
- package/scripts/memory-leak-prevention.sh +305 -305
- package/scripts/migrate-artifacts.sh +563 -0
- package/scripts/migrate-yaml-to-json.sh +465 -0
- package/scripts/run-marketing-tests.sh +42 -42
- package/scripts/update_paths.sh +46 -46
|
@@ -1,279 +1,279 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Task Decomposition for Complex Operations
|
|
3
|
-
# Breaks down complex tasks into smaller, tool-budget-efficient subtasks
|
|
4
|
-
|
|
5
|
-
set -euo pipefail
|
|
6
|
-
|
|
7
|
-
# Configuration
|
|
8
|
-
TASK_ID="${1}"
|
|
9
|
-
TASK_DESCRIPTION="${2}"
|
|
10
|
-
TOOL_BUDGET="${3:-10}" # Default 10 tool budget per agent
|
|
11
|
-
COMPLEXITY_THRESHOLD="${4:-medium}" # low, medium, high
|
|
12
|
-
|
|
13
|
-
# Colors for output
|
|
14
|
-
RED='\033[0;31m'
|
|
15
|
-
GREEN='\033[0;32m'
|
|
16
|
-
YELLOW='\033[1;33m'
|
|
17
|
-
BLUE='\033[0;34m'
|
|
18
|
-
NC='\033[0m' # No Color
|
|
19
|
-
|
|
20
|
-
echo -e "${BLUE}🔧 CFN Loop Task Decomposition${NC}"
|
|
21
|
-
echo "Task ID: $TASK_ID"
|
|
22
|
-
echo "Tool Budget: $TOOL_BUDGET per agent"
|
|
23
|
-
echo "Complexity: $COMPLEXITY_THRESHOLD"
|
|
24
|
-
echo ""
|
|
25
|
-
|
|
26
|
-
# Function to analyze task complexity
|
|
27
|
-
analyze_task_complexity() {
|
|
28
|
-
local description="$1"
|
|
29
|
-
local complexity_score=0
|
|
30
|
-
|
|
31
|
-
# File operation indicators
|
|
32
|
-
if echo "$description" | grep -qiE "(fix|create|modify|update|delete|write).*file"; then
|
|
33
|
-
((complexity_score += 3))
|
|
34
|
-
fi
|
|
35
|
-
|
|
36
|
-
# Directory exploration indicators
|
|
37
|
-
if echo "$description" | grep -qiE "(explore|find|search|scan|directory|folder)"; then
|
|
38
|
-
((complexity_score += 2))
|
|
39
|
-
fi
|
|
40
|
-
|
|
41
|
-
# Multiple component indicators
|
|
42
|
-
if echo "$description" | grep -qiE "(multiple|batch|all|every|comprehensive)"; then
|
|
43
|
-
((complexity_score += 4))
|
|
44
|
-
fi
|
|
45
|
-
|
|
46
|
-
# TypeScript/Complex file indicators
|
|
47
|
-
if echo "$description" | grep -qiE "(typescript|tsx|interface|type|complex)"; then
|
|
48
|
-
((complexity_score += 2))
|
|
49
|
-
fi
|
|
50
|
-
|
|
51
|
-
# Dependency analysis indicators
|
|
52
|
-
if echo "$description" | grep -qiE "(dependency|import|require|module)"; then
|
|
53
|
-
((complexity_score += 2))
|
|
54
|
-
fi
|
|
55
|
-
|
|
56
|
-
echo "$complexity_score"
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
# Function to decompose TypeScript error fixing tasks
|
|
60
|
-
decompose_typescript_task() {
|
|
61
|
-
local task_id="$1"
|
|
62
|
-
local description="$2"
|
|
63
|
-
local output_file=".claude/skills/cfn-task-decomposition/${task_id}-subtasks.json"
|
|
64
|
-
|
|
65
|
-
echo -e "${YELLOW}Decomposing TypeScript task...${NC}"
|
|
66
|
-
|
|
67
|
-
# Create subtasks
|
|
68
|
-
cat > "$output_file" << EOF
|
|
69
|
-
{
|
|
70
|
-
"task_id": "$task_id",
|
|
71
|
-
"original_task": "$description",
|
|
72
|
-
"decomposition_strategy": "typescript-error-fixing",
|
|
73
|
-
"subtasks": [
|
|
74
|
-
{
|
|
75
|
-
"subtask_id": "${task_id}-recon",
|
|
76
|
-
"title": "Directory Reconnaissance",
|
|
77
|
-
"description": "Explore project structure and identify TypeScript files needing fixes",
|
|
78
|
-
"agent_type": "researcher",
|
|
79
|
-
"tool_budget": 5,
|
|
80
|
-
"expected_tools": ["find", "grep", "Read", "Glob"],
|
|
81
|
-
"deliverables": ["file-list.txt", "error-classification.json"],
|
|
82
|
-
"estimated_duration": "5-10 minutes"
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
"subtask_id": "${task_id}-pattern",
|
|
86
|
-
"title": "Error Pattern Analysis",
|
|
87
|
-
"description": "Analyze TypeScript errors and identify common patterns",
|
|
88
|
-
"agent_type": "analyst",
|
|
89
|
-
"tool_budget": 8,
|
|
90
|
-
"expected_tools": ["Read", "Grep", "Bash"],
|
|
91
|
-
"deliverables": ["error-patterns.json", "fix-strategy.md"],
|
|
92
|
-
"estimated_duration": "10-15 minutes"
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"subtask_id": "${task_id}-fix",
|
|
96
|
-
"title": "File-by-File Fixes",
|
|
97
|
-
"description": "Fix TypeScript errors in identified files using patterns",
|
|
98
|
-
"agent_type": "backend-developer",
|
|
99
|
-
"tool_budget": 15,
|
|
100
|
-
"expected_tools": ["Read", "Edit", "Write", "Bash"],
|
|
101
|
-
"deliverables": ["fixed-files/", "fix-summary.json"],
|
|
102
|
-
"estimated_duration": "20-30 minutes",
|
|
103
|
-
"batch_processing": {
|
|
104
|
-
"max_files_per_batch": 3,
|
|
105
|
-
"batches_total": 5
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
"subtask_id": "${task_id}-validate",
|
|
110
|
-
"title": "Validation and Testing",
|
|
111
|
-
"description": "Validate fixes and run TypeScript compilation",
|
|
112
|
-
"agent_type": "tester",
|
|
113
|
-
"tool_budget": 10,
|
|
114
|
-
"expected_tools": ["Bash", "Read", "Write"],
|
|
115
|
-
"deliverables": ["validation-report.json", "compilation-results.txt"],
|
|
116
|
-
"estimated_duration": "10-15 minutes"
|
|
117
|
-
}
|
|
118
|
-
],
|
|
119
|
-
"coordination": {
|
|
120
|
-
"dependency_order": ["recon", "pattern", "fix", "validate"],
|
|
121
|
-
"redis_context_keys": {
|
|
122
|
-
"recon": "${task_id}:recon:results",
|
|
123
|
-
"pattern": "${task_id}:pattern:results",
|
|
124
|
-
"fix": "${task_id}:fix:results",
|
|
125
|
-
"validate": "${task_id}:validate:results"
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
EOF
|
|
130
|
-
|
|
131
|
-
echo -e "${GREEN}✓ Task decomposition created: $output_file${NC}"
|
|
132
|
-
echo "$output_file"
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
# Function to decompose file exploration tasks
|
|
136
|
-
decompose_exploration_task() {
|
|
137
|
-
local task_id="$1"
|
|
138
|
-
local description="$2"
|
|
139
|
-
local output_file=".claude/skills/cfn-task-decomposition/${task_id}-subtasks.json"
|
|
140
|
-
|
|
141
|
-
echo -e "${YELLOW}Decomposing exploration task...${NC}"
|
|
142
|
-
|
|
143
|
-
cat > "$output_file" << EOF
|
|
144
|
-
{
|
|
145
|
-
"task_id": "$task_id",
|
|
146
|
-
"original_task": "$description",
|
|
147
|
-
"decomposition_strategy": "directory-exploration",
|
|
148
|
-
"subtasks": [
|
|
149
|
-
{
|
|
150
|
-
"subtask_id": "${task_id}-scan",
|
|
151
|
-
"title": "Targeted Directory Scan",
|
|
152
|
-
"description": "Scan specific directories for target files using ripgrep",
|
|
153
|
-
"agent_type": "researcher",
|
|
154
|
-
"tool_budget": 6,
|
|
155
|
-
"expected_tools": ["Bash", "rg", "Glob", "Read"],
|
|
156
|
-
"deliverables": ["target-files.txt", "directory-map.json"],
|
|
157
|
-
"estimated_duration": "5-8 minutes"
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
"subtask_id": "${task_id}-analyze",
|
|
161
|
-
"title": "File Content Analysis",
|
|
162
|
-
"description": "Analyze found files to understand structure and patterns",
|
|
163
|
-
"agent_type": "analyst",
|
|
164
|
-
"tool_budget": 8,
|
|
165
|
-
"expected_tools": ["Read", "Grep", "Write"],
|
|
166
|
-
"deliverables": ["file-analysis.json", "content-summary.md"],
|
|
167
|
-
"estimated_duration": "8-12 minutes"
|
|
168
|
-
}
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
EOF
|
|
172
|
-
|
|
173
|
-
echo -e "${GREEN}✓ Task decomposition created: $output_file${NC}"
|
|
174
|
-
echo "$output_file"
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
# Function to create task-specific agent prompts
|
|
178
|
-
create_agent_prompts() {
|
|
179
|
-
local subtasks_file="$1"
|
|
180
|
-
local prompts_dir=".claude/skills/cfn-task-decomposition/prompts"
|
|
181
|
-
|
|
182
|
-
mkdir -p "$prompts_dir"
|
|
183
|
-
|
|
184
|
-
# Extract subtask information
|
|
185
|
-
local task_id=$(jq -r '.task_id' "$subtasks_file")
|
|
186
|
-
local strategy=$(jq -r '.decomposition_strategy' "$subtasks_file")
|
|
187
|
-
|
|
188
|
-
# Generate prompts for each subtask
|
|
189
|
-
jq -r '.subtasks[] | @base64' "$subtasks_file" | while read -r subtask_b64; do
|
|
190
|
-
local subtask=$(echo "$subtask_b64" | base64 -d)
|
|
191
|
-
local subtask_id=$(echo "$subtask" | jq -r '.subtask_id')
|
|
192
|
-
local title=$(echo "$subtask" | jq -r '.title')
|
|
193
|
-
local description=$(echo "$subtask" | jq -r '.description')
|
|
194
|
-
local tool_budget=$(echo "$subtask" | jq -r '.tool_budget')
|
|
195
|
-
local deliverables=$(echo "$subtask" | jq -r '.deliverables[]')
|
|
196
|
-
|
|
197
|
-
cat > "$prompts_dir/${subtask_id}-prompt.md" << EOF
|
|
198
|
-
# Task: $title
|
|
199
|
-
|
|
200
|
-
## Context
|
|
201
|
-
You are working on subtask "${subtask_id}" of the larger task "${task_id}".
|
|
202
|
-
|
|
203
|
-
## Your Mission
|
|
204
|
-
$description
|
|
205
|
-
|
|
206
|
-
## Tool Budget Optimization
|
|
207
|
-
You have **$tool_budget tool uses** available. Use them efficiently:
|
|
208
|
-
|
|
209
|
-
### Recommended Tool Sequence:
|
|
210
|
-
1. **Exploration tools** (Read, Glob, Bash) - 2-3 uses
|
|
211
|
-
2. **Analysis tools** (Grep, Read) - 2-3 uses
|
|
212
|
-
3. **Implementation tools** (Edit, Write) - 3-5 uses
|
|
213
|
-
4. **Validation tools** (Bash, Read) - 1-2 uses
|
|
214
|
-
|
|
215
|
-
### Efficiency Tips:
|
|
216
|
-
- **Batch operations**: Read multiple files in one tool use when possible
|
|
217
|
-
- **Targeted searches**: Use specific patterns instead of broad scans
|
|
218
|
-
- **Early validation**: Check results after each major step
|
|
219
|
-
- **Combine tool uses**: Use compound commands to reduce tool count
|
|
220
|
-
|
|
221
|
-
## Expected Deliverables
|
|
222
|
-
$deliverables
|
|
223
|
-
|
|
224
|
-
## Success Criteria
|
|
225
|
-
- All deliverables created with high quality
|
|
226
|
-
- Tool budget not exceeded
|
|
227
|
-
- Results passed to next subtask via Redis
|
|
228
|
-
|
|
229
|
-
## Redis Context
|
|
230
|
-
- Store results in: \`${task_id}:${subtask_id}:results\`
|
|
231
|
-
- Use confidence scoring based on deliverable completion
|
|
232
|
-
- Signal completion via Redis LPUSH to \`${task_id}:${subtask_id}:done\`
|
|
233
|
-
EOF
|
|
234
|
-
|
|
235
|
-
echo -e "${GREEN}✓ Created prompt for $subtask_id${NC}"
|
|
236
|
-
done
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
# Main execution
|
|
240
|
-
main() {
|
|
241
|
-
local complexity_score=$(analyze_task_complexity "$TASK_DESCRIPTION")
|
|
242
|
-
echo -e "${YELLOW}Task Complexity Score: $complexity_score${NC}"
|
|
243
|
-
|
|
244
|
-
local decomposition_file=""
|
|
245
|
-
|
|
246
|
-
# Determine decomposition strategy based on task type
|
|
247
|
-
if echo "$TASK_DESCRIPTION" | grep -qiE "(typescript|tsx|ts27|ts23|error|fix)"; then
|
|
248
|
-
decomposition_file=$(decompose_typescript_task "$TASK_ID" "$TASK_DESCRIPTION")
|
|
249
|
-
elif echo "$TASK_DESCRIPTION" | grep -qiE "(explore|find|search|scan)"; then
|
|
250
|
-
decomposition_file=$(decompose_exploration_task "$TASK_ID" "$TASK_DESCRIPTION")
|
|
251
|
-
else
|
|
252
|
-
echo -e "${YELLOW}Using general task decomposition...${NC}"
|
|
253
|
-
decomposition_file=$(decompose_typescript_task "$TASK_ID" "$TASK_DESCRIPTION")
|
|
254
|
-
fi
|
|
255
|
-
|
|
256
|
-
# Create agent prompts
|
|
257
|
-
if [ -n "$decomposition_file" ] && [ -f "$decomposition_file" ]; then
|
|
258
|
-
create_agent_prompts "$decomposition_file"
|
|
259
|
-
|
|
260
|
-
echo -e "\n${GREEN}=== Task Decomposition Complete ===${NC}"
|
|
261
|
-
echo -e "📄 ${BLUE}Decomposition file:${NC} $decomposition_file"
|
|
262
|
-
echo -e "🤖 ${BLUE}Agent prompts:${NC} .claude/skills/cfn-task-decomposition/prompts/"
|
|
263
|
-
echo -e "💡 ${BLUE}Strategy:${NC} Break complex task into tool-budget-efficient subtasks"
|
|
264
|
-
|
|
265
|
-
# Store decomposition info in Redis for coordinator
|
|
266
|
-
if command -v redis-cli >/dev/null 2>&1; then
|
|
267
|
-
redis-cli set "${TASK_ID}:decomposition" "$(cat "$decomposition_file")" >/dev/null
|
|
268
|
-
echo -e "📦 ${BLUE}Redis context stored:${NC} ${TASK_ID}:decomposition"
|
|
269
|
-
fi
|
|
270
|
-
|
|
271
|
-
return 0
|
|
272
|
-
else
|
|
273
|
-
echo -e "${RED}❌ Task decomposition failed${NC}"
|
|
274
|
-
return 1
|
|
275
|
-
fi
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
# Execute main function
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Task Decomposition for Complex Operations
|
|
3
|
+
# Breaks down complex tasks into smaller, tool-budget-efficient subtasks
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
# Configuration
|
|
8
|
+
TASK_ID="${1}"
|
|
9
|
+
TASK_DESCRIPTION="${2}"
|
|
10
|
+
TOOL_BUDGET="${3:-10}" # Default 10 tool budget per agent
|
|
11
|
+
COMPLEXITY_THRESHOLD="${4:-medium}" # low, medium, high
|
|
12
|
+
|
|
13
|
+
# Colors for output
|
|
14
|
+
RED='\033[0;31m'
|
|
15
|
+
GREEN='\033[0;32m'
|
|
16
|
+
YELLOW='\033[1;33m'
|
|
17
|
+
BLUE='\033[0;34m'
|
|
18
|
+
NC='\033[0m' # No Color
|
|
19
|
+
|
|
20
|
+
echo -e "${BLUE}🔧 CFN Loop Task Decomposition${NC}"
|
|
21
|
+
echo "Task ID: $TASK_ID"
|
|
22
|
+
echo "Tool Budget: $TOOL_BUDGET per agent"
|
|
23
|
+
echo "Complexity: $COMPLEXITY_THRESHOLD"
|
|
24
|
+
echo ""
|
|
25
|
+
|
|
26
|
+
# Function to analyze task complexity
|
|
27
|
+
analyze_task_complexity() {
|
|
28
|
+
local description="$1"
|
|
29
|
+
local complexity_score=0
|
|
30
|
+
|
|
31
|
+
# File operation indicators
|
|
32
|
+
if echo "$description" | grep -qiE "(fix|create|modify|update|delete|write).*file"; then
|
|
33
|
+
((complexity_score += 3))
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# Directory exploration indicators
|
|
37
|
+
if echo "$description" | grep -qiE "(explore|find|search|scan|directory|folder)"; then
|
|
38
|
+
((complexity_score += 2))
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Multiple component indicators
|
|
42
|
+
if echo "$description" | grep -qiE "(multiple|batch|all|every|comprehensive)"; then
|
|
43
|
+
((complexity_score += 4))
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
# TypeScript/Complex file indicators
|
|
47
|
+
if echo "$description" | grep -qiE "(typescript|tsx|interface|type|complex)"; then
|
|
48
|
+
((complexity_score += 2))
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
# Dependency analysis indicators
|
|
52
|
+
if echo "$description" | grep -qiE "(dependency|import|require|module)"; then
|
|
53
|
+
((complexity_score += 2))
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
echo "$complexity_score"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Function to decompose TypeScript error fixing tasks
|
|
60
|
+
decompose_typescript_task() {
|
|
61
|
+
local task_id="$1"
|
|
62
|
+
local description="$2"
|
|
63
|
+
local output_file=".claude/skills/cfn-task-decomposition/${task_id}-subtasks.json"
|
|
64
|
+
|
|
65
|
+
echo -e "${YELLOW}Decomposing TypeScript task...${NC}"
|
|
66
|
+
|
|
67
|
+
# Create subtasks
|
|
68
|
+
cat > "$output_file" << EOF
|
|
69
|
+
{
|
|
70
|
+
"task_id": "$task_id",
|
|
71
|
+
"original_task": "$description",
|
|
72
|
+
"decomposition_strategy": "typescript-error-fixing",
|
|
73
|
+
"subtasks": [
|
|
74
|
+
{
|
|
75
|
+
"subtask_id": "${task_id}-recon",
|
|
76
|
+
"title": "Directory Reconnaissance",
|
|
77
|
+
"description": "Explore project structure and identify TypeScript files needing fixes",
|
|
78
|
+
"agent_type": "researcher",
|
|
79
|
+
"tool_budget": 5,
|
|
80
|
+
"expected_tools": ["find", "grep", "Read", "Glob"],
|
|
81
|
+
"deliverables": ["file-list.txt", "error-classification.json"],
|
|
82
|
+
"estimated_duration": "5-10 minutes"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"subtask_id": "${task_id}-pattern",
|
|
86
|
+
"title": "Error Pattern Analysis",
|
|
87
|
+
"description": "Analyze TypeScript errors and identify common patterns",
|
|
88
|
+
"agent_type": "analyst",
|
|
89
|
+
"tool_budget": 8,
|
|
90
|
+
"expected_tools": ["Read", "Grep", "Bash"],
|
|
91
|
+
"deliverables": ["error-patterns.json", "fix-strategy.md"],
|
|
92
|
+
"estimated_duration": "10-15 minutes"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"subtask_id": "${task_id}-fix",
|
|
96
|
+
"title": "File-by-File Fixes",
|
|
97
|
+
"description": "Fix TypeScript errors in identified files using patterns",
|
|
98
|
+
"agent_type": "backend-developer",
|
|
99
|
+
"tool_budget": 15,
|
|
100
|
+
"expected_tools": ["Read", "Edit", "Write", "Bash"],
|
|
101
|
+
"deliverables": ["fixed-files/", "fix-summary.json"],
|
|
102
|
+
"estimated_duration": "20-30 minutes",
|
|
103
|
+
"batch_processing": {
|
|
104
|
+
"max_files_per_batch": 3,
|
|
105
|
+
"batches_total": 5
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"subtask_id": "${task_id}-validate",
|
|
110
|
+
"title": "Validation and Testing",
|
|
111
|
+
"description": "Validate fixes and run TypeScript compilation",
|
|
112
|
+
"agent_type": "tester",
|
|
113
|
+
"tool_budget": 10,
|
|
114
|
+
"expected_tools": ["Bash", "Read", "Write"],
|
|
115
|
+
"deliverables": ["validation-report.json", "compilation-results.txt"],
|
|
116
|
+
"estimated_duration": "10-15 minutes"
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"coordination": {
|
|
120
|
+
"dependency_order": ["recon", "pattern", "fix", "validate"],
|
|
121
|
+
"redis_context_keys": {
|
|
122
|
+
"recon": "${task_id}:recon:results",
|
|
123
|
+
"pattern": "${task_id}:pattern:results",
|
|
124
|
+
"fix": "${task_id}:fix:results",
|
|
125
|
+
"validate": "${task_id}:validate:results"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
EOF
|
|
130
|
+
|
|
131
|
+
echo -e "${GREEN}✓ Task decomposition created: $output_file${NC}"
|
|
132
|
+
echo "$output_file"
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
# Function to decompose file exploration tasks
|
|
136
|
+
decompose_exploration_task() {
|
|
137
|
+
local task_id="$1"
|
|
138
|
+
local description="$2"
|
|
139
|
+
local output_file=".claude/skills/cfn-task-decomposition/${task_id}-subtasks.json"
|
|
140
|
+
|
|
141
|
+
echo -e "${YELLOW}Decomposing exploration task...${NC}"
|
|
142
|
+
|
|
143
|
+
cat > "$output_file" << EOF
|
|
144
|
+
{
|
|
145
|
+
"task_id": "$task_id",
|
|
146
|
+
"original_task": "$description",
|
|
147
|
+
"decomposition_strategy": "directory-exploration",
|
|
148
|
+
"subtasks": [
|
|
149
|
+
{
|
|
150
|
+
"subtask_id": "${task_id}-scan",
|
|
151
|
+
"title": "Targeted Directory Scan",
|
|
152
|
+
"description": "Scan specific directories for target files using ripgrep",
|
|
153
|
+
"agent_type": "researcher",
|
|
154
|
+
"tool_budget": 6,
|
|
155
|
+
"expected_tools": ["Bash", "rg", "Glob", "Read"],
|
|
156
|
+
"deliverables": ["target-files.txt", "directory-map.json"],
|
|
157
|
+
"estimated_duration": "5-8 minutes"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"subtask_id": "${task_id}-analyze",
|
|
161
|
+
"title": "File Content Analysis",
|
|
162
|
+
"description": "Analyze found files to understand structure and patterns",
|
|
163
|
+
"agent_type": "analyst",
|
|
164
|
+
"tool_budget": 8,
|
|
165
|
+
"expected_tools": ["Read", "Grep", "Write"],
|
|
166
|
+
"deliverables": ["file-analysis.json", "content-summary.md"],
|
|
167
|
+
"estimated_duration": "8-12 minutes"
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
EOF
|
|
172
|
+
|
|
173
|
+
echo -e "${GREEN}✓ Task decomposition created: $output_file${NC}"
|
|
174
|
+
echo "$output_file"
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
# Function to create task-specific agent prompts
|
|
178
|
+
create_agent_prompts() {
|
|
179
|
+
local subtasks_file="$1"
|
|
180
|
+
local prompts_dir=".claude/skills/cfn-task-decomposition/prompts"
|
|
181
|
+
|
|
182
|
+
mkdir -p "$prompts_dir"
|
|
183
|
+
|
|
184
|
+
# Extract subtask information
|
|
185
|
+
local task_id=$(jq -r '.task_id' "$subtasks_file")
|
|
186
|
+
local strategy=$(jq -r '.decomposition_strategy' "$subtasks_file")
|
|
187
|
+
|
|
188
|
+
# Generate prompts for each subtask
|
|
189
|
+
jq -r '.subtasks[] | @base64' "$subtasks_file" | while read -r subtask_b64; do
|
|
190
|
+
local subtask=$(echo "$subtask_b64" | base64 -d)
|
|
191
|
+
local subtask_id=$(echo "$subtask" | jq -r '.subtask_id')
|
|
192
|
+
local title=$(echo "$subtask" | jq -r '.title')
|
|
193
|
+
local description=$(echo "$subtask" | jq -r '.description')
|
|
194
|
+
local tool_budget=$(echo "$subtask" | jq -r '.tool_budget')
|
|
195
|
+
local deliverables=$(echo "$subtask" | jq -r '.deliverables[]')
|
|
196
|
+
|
|
197
|
+
cat > "$prompts_dir/${subtask_id}-prompt.md" << EOF
|
|
198
|
+
# Task: $title
|
|
199
|
+
|
|
200
|
+
## Context
|
|
201
|
+
You are working on subtask "${subtask_id}" of the larger task "${task_id}".
|
|
202
|
+
|
|
203
|
+
## Your Mission
|
|
204
|
+
$description
|
|
205
|
+
|
|
206
|
+
## Tool Budget Optimization
|
|
207
|
+
You have **$tool_budget tool uses** available. Use them efficiently:
|
|
208
|
+
|
|
209
|
+
### Recommended Tool Sequence:
|
|
210
|
+
1. **Exploration tools** (Read, Glob, Bash) - 2-3 uses
|
|
211
|
+
2. **Analysis tools** (Grep, Read) - 2-3 uses
|
|
212
|
+
3. **Implementation tools** (Edit, Write) - 3-5 uses
|
|
213
|
+
4. **Validation tools** (Bash, Read) - 1-2 uses
|
|
214
|
+
|
|
215
|
+
### Efficiency Tips:
|
|
216
|
+
- **Batch operations**: Read multiple files in one tool use when possible
|
|
217
|
+
- **Targeted searches**: Use specific patterns instead of broad scans
|
|
218
|
+
- **Early validation**: Check results after each major step
|
|
219
|
+
- **Combine tool uses**: Use compound commands to reduce tool count
|
|
220
|
+
|
|
221
|
+
## Expected Deliverables
|
|
222
|
+
$deliverables
|
|
223
|
+
|
|
224
|
+
## Success Criteria
|
|
225
|
+
- All deliverables created with high quality
|
|
226
|
+
- Tool budget not exceeded
|
|
227
|
+
- Results passed to next subtask via Redis
|
|
228
|
+
|
|
229
|
+
## Redis Context
|
|
230
|
+
- Store results in: \`${task_id}:${subtask_id}:results\`
|
|
231
|
+
- Use confidence scoring based on deliverable completion
|
|
232
|
+
- Signal completion via Redis LPUSH to \`${task_id}:${subtask_id}:done\`
|
|
233
|
+
EOF
|
|
234
|
+
|
|
235
|
+
echo -e "${GREEN}✓ Created prompt for $subtask_id${NC}"
|
|
236
|
+
done
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
# Main execution
|
|
240
|
+
main() {
|
|
241
|
+
local complexity_score=$(analyze_task_complexity "$TASK_DESCRIPTION")
|
|
242
|
+
echo -e "${YELLOW}Task Complexity Score: $complexity_score${NC}"
|
|
243
|
+
|
|
244
|
+
local decomposition_file=""
|
|
245
|
+
|
|
246
|
+
# Determine decomposition strategy based on task type
|
|
247
|
+
if echo "$TASK_DESCRIPTION" | grep -qiE "(typescript|tsx|ts27|ts23|error|fix)"; then
|
|
248
|
+
decomposition_file=$(decompose_typescript_task "$TASK_ID" "$TASK_DESCRIPTION")
|
|
249
|
+
elif echo "$TASK_DESCRIPTION" | grep -qiE "(explore|find|search|scan)"; then
|
|
250
|
+
decomposition_file=$(decompose_exploration_task "$TASK_ID" "$TASK_DESCRIPTION")
|
|
251
|
+
else
|
|
252
|
+
echo -e "${YELLOW}Using general task decomposition...${NC}"
|
|
253
|
+
decomposition_file=$(decompose_typescript_task "$TASK_ID" "$TASK_DESCRIPTION")
|
|
254
|
+
fi
|
|
255
|
+
|
|
256
|
+
# Create agent prompts
|
|
257
|
+
if [ -n "$decomposition_file" ] && [ -f "$decomposition_file" ]; then
|
|
258
|
+
create_agent_prompts "$decomposition_file"
|
|
259
|
+
|
|
260
|
+
echo -e "\n${GREEN}=== Task Decomposition Complete ===${NC}"
|
|
261
|
+
echo -e "📄 ${BLUE}Decomposition file:${NC} $decomposition_file"
|
|
262
|
+
echo -e "🤖 ${BLUE}Agent prompts:${NC} .claude/skills/cfn-task-decomposition/prompts/"
|
|
263
|
+
echo -e "💡 ${BLUE}Strategy:${NC} Break complex task into tool-budget-efficient subtasks"
|
|
264
|
+
|
|
265
|
+
# Store decomposition info in Redis for coordinator
|
|
266
|
+
if command -v redis-cli >/dev/null 2>&1; then
|
|
267
|
+
redis-cli set "${TASK_ID}:decomposition" "$(cat "$decomposition_file")" >/dev/null
|
|
268
|
+
echo -e "📦 ${BLUE}Redis context stored:${NC} ${TASK_ID}:decomposition"
|
|
269
|
+
fi
|
|
270
|
+
|
|
271
|
+
return 0
|
|
272
|
+
else
|
|
273
|
+
echo -e "${RED}❌ Task decomposition failed${NC}"
|
|
274
|
+
return 1
|
|
275
|
+
fi
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
# Execute main function
|
|
279
279
|
main "$@"
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Transparency Middleware Configuration
|
|
4
|
-
# Version: 1.0.0
|
|
5
|
-
|
|
6
|
-
# Redis Configuration
|
|
7
|
-
export REDIS_HOST="${REDIS_HOST:-localhost}"
|
|
8
|
-
export REDIS_PORT="${REDIS_PORT:-6379}"
|
|
9
|
-
|
|
10
|
-
# Transparency Levels
|
|
11
|
-
TRANSPARENCY_LEVELS=(
|
|
12
|
-
"minimal" # Minimal logging, low overhead
|
|
13
|
-
"detailed" # Standard operational insights
|
|
14
|
-
"verbose" # Comprehensive logging
|
|
15
|
-
"debug" # Maximum verbosity and tracing
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
# Performance Thresholds
|
|
19
|
-
export MAX_OVERHEAD_PERCENTAGE=5
|
|
20
|
-
export MAX_MESSAGE_LATENCY_MS=50
|
|
21
|
-
export MAX_MEMORY_USAGE_MB=10
|
|
22
|
-
|
|
23
|
-
# Logging Configuration
|
|
24
|
-
export LOG_RETENTION_DAYS=7
|
|
25
|
-
export LOG_MAX_SIZE_MB=100
|
|
26
|
-
|
|
27
|
-
# Test-specific Configuration
|
|
28
|
-
export TEST_TIMEOUT_SECONDS=30
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Transparency Middleware Configuration
|
|
4
|
+
# Version: 1.0.0
|
|
5
|
+
|
|
6
|
+
# Redis Configuration
|
|
7
|
+
export REDIS_HOST="${REDIS_HOST:-localhost}"
|
|
8
|
+
export REDIS_PORT="${REDIS_PORT:-6379}"
|
|
9
|
+
|
|
10
|
+
# Transparency Levels
|
|
11
|
+
TRANSPARENCY_LEVELS=(
|
|
12
|
+
"minimal" # Minimal logging, low overhead
|
|
13
|
+
"detailed" # Standard operational insights
|
|
14
|
+
"verbose" # Comprehensive logging
|
|
15
|
+
"debug" # Maximum verbosity and tracing
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
# Performance Thresholds
|
|
19
|
+
export MAX_OVERHEAD_PERCENTAGE=5
|
|
20
|
+
export MAX_MESSAGE_LATENCY_MS=50
|
|
21
|
+
export MAX_MEMORY_USAGE_MB=10
|
|
22
|
+
|
|
23
|
+
# Logging Configuration
|
|
24
|
+
export LOG_RETENTION_DAYS=7
|
|
25
|
+
export LOG_MAX_SIZE_MB=100
|
|
26
|
+
|
|
27
|
+
# Test-specific Configuration
|
|
28
|
+
export TEST_TIMEOUT_SECONDS=30
|
|
29
29
|
export TEST_MESSAGE_COUNT=1000
|