claude-flow-novice 2.14.9 → 2.14.11

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.
@@ -0,0 +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
279
+ main "$@"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow-novice",
3
- "version": "2.14.9",
3
+ "version": "2.14.11",
4
4
  "description": "AI agent orchestration framework with namespace-isolated skills, agents, and CFN Loop validation. Safe installation with ~0.01% collision risk.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",