claude-flow-novice 2.14.19 → 2.14.21
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/commands/CFN_LOOP_TASK_MODE.md +6 -6
- package/.claude/commands/cfn-loop-cli.md +71 -35
- package/.claude/root-claude-distribute/CFN-CLAUDE.md +115 -42
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +66 -11
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.backup +884 -0
- package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +326 -0
- package/claude-assets/agents/cfn-seo-team/technical-seo-specialist.md +9 -6
- package/claude-assets/commands/CFN_LOOP_TASK_MODE.md +6 -6
- package/claude-assets/commands/cfn-loop-cli.md +71 -35
- package/claude-assets/root-claude-distribute/CFN-CLAUDE.md +115 -42
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +66 -11
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh.backup +884 -0
- package/dist/agents/agent-loader.js +146 -165
- package/dist/agents/agent-loader.js.map +1 -1
- package/package.json +1 -1
- package/scripts/build-agent-image.sh +53 -0
- package/.claude/commands/CFN_LOOP_TASK_MODE copy.md +0 -495
- package/claude-assets/commands/CFN_LOOP_TASK_MODE copy.md +0 -495
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
## Overview
|
|
8
8
|
|
|
9
|
-
Task Mode: Main Chat
|
|
9
|
+
Task Mode: Main Chat coordinates directly and spawns agents via Task() tool with full context injection and visibility. NO coordinator agent is used.
|
|
10
10
|
|
|
11
11
|
| Aspect | Task Mode | CLI Mode |
|
|
12
12
|
|--------|-----------|----------|
|
|
13
|
-
| **Spawning** | Main Chat via Task() | Coordinator via npx CLI |
|
|
13
|
+
| **Spawning** | Main Chat directly via Task() | Coordinator via npx CLI |
|
|
14
14
|
| **Visibility** | Full transparency in Main Chat | Background, Redis logs |
|
|
15
15
|
| **Provider** | All Anthropic | CLI uses Z.ai routing |
|
|
16
16
|
| **Cost** | ~$0.150/iteration | ~$0.054/iteration (64% savings) |
|
|
@@ -88,15 +88,15 @@ return validators.slice(0, 6); // Max 6
|
|
|
88
88
|
## Sprint Completion Workflow
|
|
89
89
|
|
|
90
90
|
**Key Difference in Task Mode:**
|
|
91
|
-
- Product Owner spawned via `Task()` by
|
|
91
|
+
- Product Owner spawned via `Task()` by Main Chat directly (NOT via `execute-decision.sh`)
|
|
92
92
|
- Use helper scripts for parsing/validation: `parse-decision.sh`, `validate-deliverables.sh`
|
|
93
93
|
- CLI Mode uses `execute-decision.sh` which handles spawning + all logic
|
|
94
94
|
|
|
95
95
|
### 1. Consensus Validation
|
|
96
96
|
|
|
97
|
-
**Task Mode** -
|
|
97
|
+
**Task Mode** - Main Chat spawns Product Owner via Task():
|
|
98
98
|
```javascript
|
|
99
|
-
//
|
|
99
|
+
// Main Chat builds context and spawns PO
|
|
100
100
|
const poContext = `
|
|
101
101
|
CFN Loop iteration ${iteration} complete.
|
|
102
102
|
Loop 2 Consensus: ${consensus} (threshold: ${threshold})
|
|
@@ -164,7 +164,7 @@ EOF
|
|
|
164
164
|
### 5. Execute Product Owner Suggested Next Steps
|
|
165
165
|
|
|
166
166
|
**After PROCEED Decision:**
|
|
167
|
-
Product Owner may suggest follow-up tasks (documentation, testing, refactoring).
|
|
167
|
+
Product Owner may suggest follow-up tasks (documentation, testing, refactoring). Main Chat must proceed by spawning specialized agents to execute these tasks:
|
|
168
168
|
|
|
169
169
|
```javascript
|
|
170
170
|
// Parse PO feedback for suggested next steps
|
|
@@ -15,9 +15,9 @@ Execute CFN Loop using CLI spawning for maximum cost savings (95-98% vs Task too
|
|
|
15
15
|
## What is CLI Mode?
|
|
16
16
|
|
|
17
17
|
**CLI Mode Architecture v3.0 (Enhanced):**
|
|
18
|
-
- Main Chat
|
|
19
|
-
-
|
|
20
|
-
- CLI agents use **Z.ai custom routing** (when enabled)
|
|
18
|
+
- Main Chat processes **slash command** then spawns coordinator agent via CLI with background=true
|
|
19
|
+
- Coordinator spawns **all workers via CLI** with background=true for cost optimization
|
|
20
|
+
- All CLI agents use **Z.ai custom routing** (when enabled)
|
|
21
21
|
- **Real-time monitoring** with automatic recovery from stuck agents
|
|
22
22
|
- Background execution with **Redis monitoring** and progress visibility
|
|
23
23
|
- **Enhanced features**: Process health checking, context validation, broadcast protocol
|
|
@@ -38,7 +38,8 @@ Execute CFN Loop using CLI spawning for maximum cost savings (95-98% vs Task too
|
|
|
38
38
|
|
|
39
39
|
## Command Options
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
**Usage Examples:**
|
|
42
|
+
```
|
|
42
43
|
# Standard mode (recommended)
|
|
43
44
|
/cfn-loop-cli "Implement JWT authentication"
|
|
44
45
|
|
|
@@ -63,17 +64,27 @@ Execute CFN Loop using CLI spawning for maximum cost savings (95-98% vs Task too
|
|
|
63
64
|
|
|
64
65
|
## How CLI Mode Works
|
|
65
66
|
|
|
66
|
-
1. **Main Chat**
|
|
67
|
-
2. **
|
|
68
|
-
3. **
|
|
69
|
-
4. **
|
|
70
|
-
5. **
|
|
71
|
-
6. **
|
|
67
|
+
1. **Main Chat** invokes `/cfn-loop-cli` slash command
|
|
68
|
+
2. **SlashCommand tool** processes command and returns execution instructions to Main Chat
|
|
69
|
+
3. **Main Chat** spawns `cfn-v3-coordinator` agent via bash with background=true
|
|
70
|
+
4. **Coordinator** orchestrates the entire CFN Loop workflow in the background
|
|
71
|
+
5. **Coordinator** spawns **Loop 3 workers via CLI** with background=true
|
|
72
|
+
6. **Loop 3** agents implement the solution and validate against quality gates
|
|
73
|
+
7. **Coordinator** spawns **Loop 2 workers via CLI** for validation
|
|
74
|
+
8. **Product Owner** makes the final decision on deliverables
|
|
75
|
+
9. **Background execution** with Redis coordination for scalability
|
|
72
76
|
|
|
73
77
|
**CLI Architecture Pattern:**
|
|
74
|
-
- Main Chat →
|
|
75
|
-
|
|
76
|
-
-
|
|
78
|
+
- Main Chat → SlashCommand (processing) → Main Chat spawns coordinator via bash
|
|
79
|
+
```bash
|
|
80
|
+
npx claude-flow-novice agent cfn-v3-coordinator \
|
|
81
|
+
--task-id "cfn-cli-$(date +%s%N | tail -c 7)-${RANDOM}" \
|
|
82
|
+
--context "TASK_DESCRIPTION='Fix core infrastructure
|
|
83
|
+
dependencies' MODE='standard' MAX_ITERATIONS=10" \
|
|
84
|
+
--timeout 300 \
|
|
85
|
+
--background=true
|
|
86
|
+
```
|
|
87
|
+
- All agents spawned via CLI by coordinator with Z.ai routing and background execution
|
|
77
88
|
- Background execution enables monitoring and recovery capabilities
|
|
78
89
|
|
|
79
90
|
## Main Chat Monitoring Instructions
|
|
@@ -294,22 +305,22 @@ redis-cli DBSIZE
|
|
|
294
305
|
## Usage Examples
|
|
295
306
|
|
|
296
307
|
**Simple API Development:**
|
|
297
|
-
```
|
|
308
|
+
```
|
|
298
309
|
/cfn-loop-cli "Build REST API with user authentication"
|
|
299
310
|
```
|
|
300
311
|
|
|
301
312
|
**Complex Feature with High Quality Requirements:**
|
|
302
|
-
```
|
|
313
|
+
```
|
|
303
314
|
/cfn-loop-cli "Implement payment processing with PCI compliance" --mode=enterprise --max-iterations=15
|
|
304
315
|
```
|
|
305
316
|
|
|
306
317
|
**Quick Prototype:**
|
|
307
|
-
```
|
|
318
|
+
```
|
|
308
319
|
/cfn-loop-cli "Build MVP landing page" --mode=mvp
|
|
309
320
|
```
|
|
310
321
|
|
|
311
322
|
**Infrastructure Deployment:**
|
|
312
|
-
```
|
|
323
|
+
```
|
|
313
324
|
/cfn-loop-cli "Set up CI/CD pipeline for microservices"
|
|
314
325
|
```
|
|
315
326
|
|
|
@@ -330,7 +341,11 @@ redis-cli DBSIZE
|
|
|
330
341
|
|
|
331
342
|
## 🚨 EXECUTION INSTRUCTIONS (Internal Use)
|
|
332
343
|
|
|
333
|
-
**Main Chat:
|
|
344
|
+
**Main Chat: Slash command processing followed by CLI coordinator spawning:**
|
|
345
|
+
|
|
346
|
+
The SlashCommand tool processes the command and returns execution instructions. Main Chat then spawns the coordinator agent using CLI with background=true for monitoring capabilities.
|
|
347
|
+
|
|
348
|
+
**Coordinator Spawning Pattern:**
|
|
334
349
|
|
|
335
350
|
```bash
|
|
336
351
|
# Generate unique task ID
|
|
@@ -341,6 +356,36 @@ TASK_DESCRIPTION="$ARGUMENTS"
|
|
|
341
356
|
MODE="${mode:-standard}"
|
|
342
357
|
MAX_ITERATIONS="${maxIterations:-10}"
|
|
343
358
|
|
|
359
|
+
# Spawn coordinator via CLI (background execution)
|
|
360
|
+
npx claude-flow-novice agent cfn-v3-coordinator \
|
|
361
|
+
--task-id "$TASK_ID" \
|
|
362
|
+
--context "TASK_DESCRIPTION='$TASK_DESCRIPTION' MODE='$MODE' MAX_ITERATIONS=$MAX_ITERATIONS" \
|
|
363
|
+
--timeout 300 \
|
|
364
|
+
--background=true
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**Main Chat Execution Command:**
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
# Main Chat should execute this command after processing slash command
|
|
371
|
+
npx claude-flow-novice agent cfn-v3-coordinator \
|
|
372
|
+
--task-id "cfn-cli-$(date +%s%N | tail -c 7)-${RANDOM}" \
|
|
373
|
+
--context "TASK_DESCRIPTION='Fix core infrastructure dependencies - lucide-wrappers.tsx LucideIcon React 18 compatibility, resolve module export errors in types/, establish proper import path resolution' MODE='standard' MAX_ITERATIONS=10" \
|
|
374
|
+
--timeout 300 \
|
|
375
|
+
--background=true
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**Internal Coordinator Pattern (what the coordinator does):**
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
# Generate unique task ID
|
|
382
|
+
TASK_ID="cfn-cli-$(date +%s%N | tail -c 7)-${RANDOM}"
|
|
383
|
+
|
|
384
|
+
# Extract task description and mode from slash command arguments
|
|
385
|
+
TASK_DESCRIPTION="parsed from $ARGUMENTS"
|
|
386
|
+
MODE="${mode:-standard}"
|
|
387
|
+
MAX_ITERATIONS="${maxIterations:-10}"
|
|
388
|
+
|
|
344
389
|
# Determine appropriate agents based on task complexity
|
|
345
390
|
TASK_COMPLEXITY="standard" # auto-detect or pass from command
|
|
346
391
|
case "$TASK_COMPLEXITY" in
|
|
@@ -358,10 +403,11 @@ case "$TASK_COMPLEXITY" in
|
|
|
358
403
|
;;
|
|
359
404
|
esac
|
|
360
405
|
|
|
361
|
-
#
|
|
362
|
-
npx claude-flow-novice agent
|
|
406
|
+
# Coordinator spawns CLI workers (background execution)
|
|
407
|
+
npx claude-flow-novice agent "$LOOP3_AGENT" \
|
|
363
408
|
--task-id "$TASK_ID" \
|
|
364
|
-
--
|
|
409
|
+
--agent-id "$AGENT_ID" \
|
|
410
|
+
--context "Complete deliverables and acceptance criteria" \
|
|
365
411
|
--timeout 300 \
|
|
366
412
|
--background=true
|
|
367
413
|
|
|
@@ -369,17 +415,6 @@ npx claude-flow-novice agent cfn-v3-coordinator \
|
|
|
369
415
|
# redis-cli HGETALL "cfn_loop:task:$TASK_ID:context"
|
|
370
416
|
```
|
|
371
417
|
|
|
372
|
-
**CLI Coordinator Spawning Pattern:**
|
|
373
|
-
|
|
374
|
-
```bash
|
|
375
|
-
# Direct CLI coordinator spawning with background execution
|
|
376
|
-
npx claude-flow-novice agent cfn-v3-coordinator \
|
|
377
|
-
--task-id "unique-task-id" \
|
|
378
|
-
--context "task description; mode; max-iterations; agent-config" \
|
|
379
|
-
--timeout 300 \
|
|
380
|
-
--background=true
|
|
381
|
-
```
|
|
382
|
-
|
|
383
418
|
**Critical Background Execution Instructions:**
|
|
384
419
|
|
|
385
420
|
1. **Always use `--background=true`** for CLI mode to enable:
|
|
@@ -401,12 +436,13 @@ npx claude-flow-novice agent cfn-v3-coordinator \
|
|
|
401
436
|
- No recovery or persistence features
|
|
402
437
|
|
|
403
438
|
**Why This Pattern:**
|
|
404
|
-
- ✅
|
|
439
|
+
- ✅ Coordinator via CLI with background=true for monitoring capabilities
|
|
440
|
+
- ✅ All agents via CLI for maximum cost optimization (95-98% savings)
|
|
405
441
|
- ✅ Background execution with enhanced monitoring
|
|
406
|
-
- ✅ Z.ai routing automatically applied to all CLI agents
|
|
442
|
+
- ✅ Z.ai routing automatically applied to all CLI agents
|
|
407
443
|
- ✅ Redis coordination for agent communication
|
|
408
444
|
- ✅ Enhanced monitoring and recovery capabilities
|
|
409
|
-
- ✅ Clean separation: Main Chat →
|
|
445
|
+
- ✅ Clean separation: Main Chat → SlashCommand (processing) → Main Chat spawns CLI(coordinator) → CLI Workers
|
|
410
446
|
- ✅ Production-ready with real-time progress tracking
|
|
411
447
|
- ✅ No timeout limitations with `--background=true`
|
|
412
448
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
### Core Operational Rules
|
|
10
10
|
* **Use agents for all non-trivial work** (≥4 steps or any multi-file / research / testing / architecture / security / integration / refactor / feature)
|
|
11
|
+
* **🚨 FOR CFN LOOP CLI WORKFLOWS: Use CLI commands** - `/cfn-loop-cli "task"` (NEVER manual Task() spawning)
|
|
11
12
|
* **Initialize swarm before any multi-agent work**
|
|
12
13
|
* **Batch operations**: one message per related batch (spawn, file edits, bash, todos, memory ops)
|
|
13
14
|
* **Run post-edit hook after every file edit** inclusive of .md files and await the response
|
|
@@ -38,10 +39,12 @@
|
|
|
38
39
|
* Validators consensus: **≥0.90**
|
|
39
40
|
|
|
40
41
|
### CTO Delegation Persona
|
|
41
|
-
* **Act as a busy CTO** who delegates all non-trivial work to specialized agents or
|
|
42
|
+
* **Act as a busy CTO** who delegates all non-trivial work to specialized agents or CFN Loop CLI commands
|
|
43
|
+
* **For multi-agent workflows**: Use `/cfn-loop-cli "task description"` (automatically handles coordinator spawning)
|
|
44
|
+
* **For single agent tasks**: Use `Task("agent-type", "specific task")` directly
|
|
42
45
|
* **Define clear success criteria** for implementation (working code, passing tests, documented features)
|
|
43
46
|
* **Never define adoption criteria** (user engagement, rollout strategy, training plans)
|
|
44
|
-
* **Ruthlessly delegate** - if task requires >3 steps,
|
|
47
|
+
* **Ruthlessly delegate** - if task requires >3 steps, use CLI commands immediately
|
|
45
48
|
* **Provide context, not solutions** - agents figure out implementation details
|
|
46
49
|
* **Success = implementation complete** - not "users love it" or "team adopts it"
|
|
47
50
|
|
|
@@ -168,32 +171,42 @@ When spawned via CLI (`npx claude-flow-novice`), you automatically benefit from
|
|
|
168
171
|
/switch-api status
|
|
169
172
|
```
|
|
170
173
|
|
|
171
|
-
|
|
174
|
+
**🚨 CRITICAL: Main Chat MUST Use CLI Mode Commands**
|
|
172
175
|
|
|
173
|
-
|
|
176
|
+
**DO NOT spawn Task() agents directly for CFN Loop workflows.**
|
|
177
|
+
Instead, use the dedicated CLI mode slash commands that handle coordinator spawning automatically.
|
|
174
178
|
|
|
175
|
-
**❌ FORBIDDEN -
|
|
179
|
+
**❌ FORBIDDEN - Manual Task() Spawning:**
|
|
176
180
|
```javascript
|
|
177
|
-
// WRONG
|
|
178
|
-
Task("coordinator", "
|
|
179
|
-
Task("backend-
|
|
180
|
-
Task("tester", "Test feature...")
|
|
181
|
+
// WRONG - Don't spawn CFN Loop agents manually from Main Chat
|
|
182
|
+
Task("cfn-v3-coordinator", "Execute CFN Loop...") // ❌ NO
|
|
183
|
+
Task("backend-developer", "Implement feature...") // ❌ NO
|
|
184
|
+
Task("tester", "Test feature...") // ❌ NO
|
|
181
185
|
```
|
|
182
186
|
|
|
183
|
-
**✅ REQUIRED -
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
187
|
+
**✅ REQUIRED - Use CLI Mode Slash Commands:**
|
|
188
|
+
```bash
|
|
189
|
+
# PRODUCTION - Enhanced CLI mode v3.0 (default)
|
|
190
|
+
/cfn-loop-cli "Implement JWT authentication" --mode=standard
|
|
191
|
+
|
|
192
|
+
# DEBUGGING - Task mode (full visibility)
|
|
193
|
+
/cfn-loop-task "Fix security bug in auth module" --mode=standard
|
|
194
|
+
|
|
195
|
+
# QUICK TASKS - Single iteration
|
|
196
|
+
/cfn-loop-single "Update documentation"
|
|
197
|
+
|
|
198
|
+
# LARGE EPICS - Multi-phase
|
|
199
|
+
/cfn-loop-epic "Build complete authentication system"
|
|
195
200
|
```
|
|
196
201
|
|
|
202
|
+
**Why CLI Mode Commands?**
|
|
203
|
+
- ✅ Automatic coordinator spawning with enhanced monitoring v3.0
|
|
204
|
+
- ✅ Real-time agent progress tracking and automatic recovery
|
|
205
|
+
- ✅ Protocol compliance (prevents "consensus on vapor" anti-patterns)
|
|
206
|
+
- ✅ 95-98% cost savings with Z.ai routing
|
|
207
|
+
- ✅ Background execution with Redis persistence
|
|
208
|
+
- ✅ Built-in parameter validation and success criteria templates
|
|
209
|
+
|
|
197
210
|
**Why This Pattern:**
|
|
198
211
|
- Coordinator controls spawn timing via orchestrate.sh (no timeout issues)
|
|
199
212
|
- 95-98% cost savings vs Task() spawning
|
|
@@ -210,6 +223,7 @@ BACKUP_PATH=$(./.claude/hooks/cfn-invoke-pre-edit.sh "$FILE_TO_EDIT" --agent-id
|
|
|
210
223
|
**Why:** Enables safe file revert without git operations during parallel sessions.
|
|
211
224
|
**Location:** `.backups/[agent-id]/[timestamp]_[hash]/`
|
|
212
225
|
**Retention:** 24h TTL (configurable)
|
|
226
|
+
**Injection:** Automatically included in all agent prompts via `src/cli/agent-prompt-builder.ts`
|
|
213
227
|
|
|
214
228
|
**Revert Instead of Git:**
|
|
215
229
|
```bash
|
|
@@ -249,10 +263,21 @@ fi
|
|
|
249
263
|
|
|
250
264
|
## 2) When Agents Are Mandatory (Triggers)
|
|
251
265
|
|
|
252
|
-
If **any** apply,
|
|
266
|
+
If **any** apply, use CFN Loop CLI commands:
|
|
253
267
|
|
|
254
268
|
* > 3 distinct steps • multiple files • research+implement+test • design decisions • code review/quality • security/performance/compliance • system integration • docs generation • refactor/optimize • any feature work
|
|
255
269
|
|
|
270
|
+
**🚨 IMPORTANT: For complex multi-agent workflows, use CLI mode commands:**
|
|
271
|
+
```bash
|
|
272
|
+
# Production with enhanced monitoring v3.0
|
|
273
|
+
/cfn-loop-cli "Complex task description" --mode=standard
|
|
274
|
+
|
|
275
|
+
# Debugging with full visibility
|
|
276
|
+
/cfn-loop-task "Complex task description" --mode=standard
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Do NOT manually spawn Task() agents for CFN Loop workflows - the CLI commands handle coordination automatically.**
|
|
280
|
+
|
|
256
281
|
### Skill Selection Criteria
|
|
257
282
|
**Mandatory Skill Spawning Triggers:**
|
|
258
283
|
- Complex tasks (>3 steps)
|
|
@@ -273,16 +298,26 @@ npx claude-flow-novice swarm "Task Description" \
|
|
|
273
298
|
|
|
274
299
|
### Single Agent vs Coordinator
|
|
275
300
|
|
|
276
|
-
**Use Single Agent:**
|
|
301
|
+
**Use Single Agent (Task() directly):**
|
|
277
302
|
* 1 specialized task (coding, reviewing, testing)
|
|
278
303
|
* No dependencies on other agents
|
|
279
304
|
* Straightforward execution
|
|
305
|
+
* Simple, isolated work
|
|
280
306
|
|
|
281
|
-
**Use Coordinator:**
|
|
307
|
+
**Use Coordinator (CLI Commands):**
|
|
282
308
|
* Multiple agents needed (2+)
|
|
283
309
|
* Sequential dependencies (Loop 3 → Loop 2 → Product Owner)
|
|
284
310
|
* Iteration/consensus required
|
|
285
|
-
* CFN Loop workflows
|
|
311
|
+
* **ALL CFN Loop workflows**
|
|
312
|
+
|
|
313
|
+
**🚨 FOR CFN LOOP WORKFLOWS: Always use CLI commands - never manual Task() spawning**
|
|
314
|
+
```bash
|
|
315
|
+
# Multi-agent workflows (coordinator handles everything)
|
|
316
|
+
/cfn-loop-cli "Build authentication system" --mode=standard
|
|
317
|
+
|
|
318
|
+
# Single agent tasks (direct Task() is fine)
|
|
319
|
+
Task("reviewer", "Review this specific file")
|
|
320
|
+
```
|
|
286
321
|
|
|
287
322
|
## 3) Coordination Patterns
|
|
288
323
|
|
|
@@ -312,40 +347,48 @@ Refer to `.claude/skills/cfn-redis-coordination/SKILL.md` for:
|
|
|
312
347
|
|
|
313
348
|
### CFN Loop Orchestration Pattern
|
|
314
349
|
|
|
315
|
-
**CLI Mode (Production):**
|
|
316
|
-
Main Chat spawns cfn-v3-coordinator →
|
|
350
|
+
**CLI Mode (Production) - Enhanced v3.0:**
|
|
351
|
+
Main Chat spawns cfn-v3-coordinator → Enhanced orchestrator with monitoring → Workers via CLI with progress tracking → Automatic recovery from stuck agents
|
|
317
352
|
|
|
318
353
|
**Task Mode (Debugging):**
|
|
319
354
|
Main Chat spawns all agents directly via Task() → No coordinator → Full visibility
|
|
320
355
|
|
|
321
|
-
**Orchestrator:**
|
|
356
|
+
**Enhanced Orchestrator v3.0:**
|
|
322
357
|
```bash
|
|
323
358
|
./.claude/skills/cfn-loop-orchestration/orchestrate.sh
|
|
324
359
|
```
|
|
325
|
-
-
|
|
326
|
-
-
|
|
327
|
-
-
|
|
328
|
-
-
|
|
329
|
-
-
|
|
360
|
+
- ✅ **Enhanced Monitoring**: Real-time agent progress tracking with stuck detection
|
|
361
|
+
- ✅ **Automatic Recovery**: Dead process cleanup and agent restart capabilities
|
|
362
|
+
- ✅ **Protocol Compliance**: Prevents "consensus on vapor" anti-patterns
|
|
363
|
+
- ✅ **Enhanced Spawning**: Context validation and broadcast message injection
|
|
364
|
+
- ✅ **Progress Visibility**: Detailed progress reports with timestamps
|
|
365
|
+
- Spawns Loop 3 agents with protocol enforcement
|
|
366
|
+
- Enhanced waiting with progress tracking and recovery
|
|
367
|
+
- Collects confidence scores with metadata validation
|
|
368
|
+
- Gate check: spawn Loop 2 if ≥threshold (with health verification)
|
|
369
|
+
- Spawns Loop 2 agents (validators) with monitoring
|
|
370
|
+
- Collects consensus with stuck agent detection
|
|
330
371
|
- Spawns Product Owner for decision
|
|
331
|
-
- Manages iterations based on PROCEED/ITERATE/ABORT
|
|
372
|
+
- Manages iterations based on PROCEED/ITERATE/ABORT with timeout handling
|
|
332
373
|
|
|
333
374
|
**Agent Completion Protocol (Mode-Specific):**
|
|
334
375
|
|
|
335
|
-
**CLI Mode** (spawned via `npx claude-flow-novice agent-spawn`):
|
|
376
|
+
**CLI Mode v3.0** (spawned via `npx claude-flow-novice agent-spawn`):
|
|
336
377
|
```bash
|
|
337
|
-
# 1. Complete work
|
|
338
|
-
# 2.
|
|
378
|
+
# 1. Complete work with enhanced context
|
|
379
|
+
# 2. Automatic context validation (prevents "consensus on vapor")
|
|
380
|
+
# 3. Signal completion
|
|
339
381
|
redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete"
|
|
340
382
|
|
|
341
|
-
#
|
|
342
|
-
./.claude/skills/cfn-redis-coordination/
|
|
383
|
+
# 4. Report confidence with metadata
|
|
384
|
+
./.claude/skills/cfn-redis-coordination/report-completion.sh \
|
|
343
385
|
--task-id "$TASK_ID" \
|
|
344
386
|
--agent-id "$AGENT_ID" \
|
|
345
387
|
--confidence 0.85 \
|
|
346
|
-
--iteration 1
|
|
388
|
+
--iteration 1 \
|
|
389
|
+
--result '{"deliverables_created": ["file.ts"], "status": "complete"}'
|
|
347
390
|
|
|
348
|
-
# Agent exits cleanly (
|
|
391
|
+
# 5. Agent exits cleanly (orchestrator monitors via enhanced waiting)
|
|
349
392
|
```
|
|
350
393
|
|
|
351
394
|
**Task Mode** (spawned via Task() tool in Main Chat):
|
|
@@ -356,6 +399,12 @@ redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete"
|
|
|
356
399
|
# NO explicit completion protocol needed
|
|
357
400
|
```
|
|
358
401
|
|
|
402
|
+
**Enhanced Agent Protocol Requirements:**
|
|
403
|
+
- ✅ **Mandatory completion signaling**: `report-completion.sh` call required
|
|
404
|
+
- ✅ **Context awareness**: Broadcast messages automatically injected
|
|
405
|
+
- ✅ **Metadata tracking**: Agent status and process PID monitored
|
|
406
|
+
- ✅ **Health checking**: Process health validated during execution
|
|
407
|
+
|
|
359
408
|
**Orchestration Flow (CORRECTED - Self-Validation Pattern):**
|
|
360
409
|
1. Loop 3 agents complete work and report confidence
|
|
361
410
|
2. **Gate Check:** Loop 3 self-validation scores checked
|
|
@@ -686,4 +735,28 @@ Out of Scope:
|
|
|
686
735
|
- **Confidence:** 0.91
|
|
687
736
|
- **Priority:** 8
|
|
688
737
|
- **Insight**: Decompose complex systems into independent skills (20 skills in CFN v3: task-classifier, playbook, validation-templates, etc.). Enables reuse, testing isolation, and incremental enhancement.
|
|
689
|
-
- **Tags**: modularity, skills, architecture, reusability
|
|
738
|
+
- **Tags**: modularity, skills, architecture, reusability
|
|
739
|
+
## Sprint 10 Adaptive Context Lessons (Phase X - Defensive Programming)
|
|
740
|
+
|
|
741
|
+
### Defensive Programming Patterns
|
|
742
|
+
|
|
743
|
+
#### PATTERN-025: Comprehensive File Validation
|
|
744
|
+
- **Context**: Defensive File Handling
|
|
745
|
+
- **Insight**: Implement comprehensive file validation techniques that go beyond basic existence checks. Use multi-stage validation including file type, permissions, size constraints, and content integrity checks. Create a robust validation pipeline that prevents potential security vulnerabilities and unexpected system behavior.
|
|
746
|
+
- **Tags**: file-handling, defensive-programming, validation, security, system-integrity
|
|
747
|
+
- **Confidence**: 0.92
|
|
748
|
+
- **Priority**: 9/10
|
|
749
|
+
|
|
750
|
+
#### PATTERN-026: Shell Strict Mode
|
|
751
|
+
- **Context**: Bash Script Reliability
|
|
752
|
+
- **Insight**: Enable shell strict mode using `set -euo pipefail` to create more robust and predictable shell scripts. This approach forces immediate exit on errors, prevents unset variable usage, and ensures pipeline failures are properly captured. Dramatically improves script reliability and makes error conditions explicit.
|
|
753
|
+
- **Tags**: bash, shell-scripting, error-handling, defensive-programming, reliability
|
|
754
|
+
- **Confidence**: 0.90
|
|
755
|
+
- **Priority**: 9/10
|
|
756
|
+
|
|
757
|
+
#### PATTERN-028: Process Group Management
|
|
758
|
+
- **Context**: Background Process Handling
|
|
759
|
+
- **Insight**: Implement comprehensive process group management techniques to ensure clean termination and resource cleanup. Use techniques like `trap` for signal handling, process substitution, and explicit process group management to prevent zombie processes and resource leaks in complex multi-process environments.
|
|
760
|
+
- **Tags**: process-management, bash, background-processes, resource-cleanup, defensive-programming
|
|
761
|
+
- **Confidence**: 0.86
|
|
762
|
+
- **Priority**: 8/10
|
|
@@ -317,23 +317,78 @@ function store_context() {
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
build_agent_context() {
|
|
320
|
-
local
|
|
321
|
-
local
|
|
322
|
-
local
|
|
323
|
-
local
|
|
320
|
+
local task_id="$1"
|
|
321
|
+
local iteration="$2"
|
|
322
|
+
local agent_type="$3"
|
|
323
|
+
local feedback="$4"
|
|
324
|
+
local loop_type="${5:-}" # NEW: loop3, loop2, or loop4 (optional)
|
|
324
325
|
|
|
325
|
-
#
|
|
326
|
+
# Initialize context variables
|
|
326
327
|
local task_desc="CFN Loop implementation"
|
|
327
|
-
local deliverables
|
|
328
|
-
local acceptance
|
|
328
|
+
local deliverables=""
|
|
329
|
+
local acceptance=""
|
|
330
|
+
local epic_context=""
|
|
331
|
+
local phase_context=""
|
|
332
|
+
local target_files=""
|
|
333
|
+
|
|
334
|
+
# Try to retrieve complete context from Redis
|
|
335
|
+
if command -v "$REDIS_COORD_SKILL/get-context.sh" >/dev/null 2>&1; then
|
|
336
|
+
if redis_context=$("$REDIS_COORD_SKILL/get-context.sh" --task-id "$task_id" --namespace "swarm" 2>/dev/null); then
|
|
337
|
+
echo "📥 Retrieved Redis context for task: $task_id" >&2
|
|
338
|
+
|
|
339
|
+
# Extract fields from Redis context
|
|
340
|
+
task_desc=$(echo "$redis_context" | jq -r '.["epic-context"] // .epic_context // "CFN Loop implementation"' 2>/dev/null || echo "CFN Loop implementation")
|
|
341
|
+
deliverables=$(echo "$redis_context" | jq -r '.deliverables // [] | if type == "array" then join(", ") else . end' 2>/dev/null || echo "")
|
|
342
|
+
acceptance=$(echo "$redis_context" | jq -r '.acceptanceCriteria // .["acceptance-criteria"] // [] | if type == "array" then join(", ") else . end' 2>/dev/null || echo "")
|
|
343
|
+
epic_context=$(echo "$redis_context" | jq -r '.["epic-context"] // ""' 2>/dev/null || echo "")
|
|
344
|
+
phase_context=$(echo "$redis_context" | jq -r '.["phase-context"] // ""' 2>/dev/null || echo "")
|
|
345
|
+
target_files=$(echo "$redis_context" | jq -r '.["target-files"] // ""' 2>/dev/null || echo "")
|
|
346
|
+
|
|
347
|
+
echo "📋 Redis context extracted - Task: $task_desc" >&2
|
|
348
|
+
else
|
|
349
|
+
echo "⚠️ Failed to retrieve Redis context, using local SUCCESS_CRITERIA" >&2
|
|
350
|
+
fi
|
|
351
|
+
else
|
|
352
|
+
echo "⚠️ get-context.sh not found, using local SUCCESS_CRITERIA" >&2
|
|
353
|
+
fi
|
|
354
|
+
|
|
355
|
+
# Fallback to local SUCCESS_CRITERIA if Redis retrieval failed or incomplete
|
|
356
|
+
if [ -z "$deliverables" ] && [ -n "$SUCCESS_CRITERIA" ]; then
|
|
357
|
+
deliverables=$(echo "$SUCCESS_CRITERIA" | jq -r '.deliverables // [] | join(", ")' 2>/dev/null || echo "")
|
|
358
|
+
acceptance=$(echo "$SUCCESS_CRITERIA" | jq -r '.acceptanceCriteria // [] | join(", ")' 2>/dev/null || echo "")
|
|
359
|
+
echo "🔄 Using local SUCCESS_CRITERIA as fallback" >&2
|
|
360
|
+
fi
|
|
329
361
|
|
|
330
|
-
# Build
|
|
331
|
-
local context="Task: $task_desc
|
|
362
|
+
# Build comprehensive context string
|
|
363
|
+
local context="Task: $task_desc"
|
|
364
|
+
|
|
365
|
+
if [ -n "$deliverables" ]; then
|
|
366
|
+
context="$context | Deliverables: $deliverables"
|
|
367
|
+
fi
|
|
368
|
+
|
|
369
|
+
if [ -n "$acceptance" ]; then
|
|
370
|
+
context="$context | Acceptance Criteria: $acceptance"
|
|
371
|
+
fi
|
|
372
|
+
|
|
373
|
+
if [ -n "$target_files" ]; then
|
|
374
|
+
context="$context | Target Files: $target_files"
|
|
375
|
+
fi
|
|
376
|
+
|
|
377
|
+
context="$context | Iteration: $iteration"
|
|
332
378
|
|
|
333
379
|
if [[ -n "$feedback" ]]; then
|
|
334
380
|
context="$context | Feedback: $feedback"
|
|
335
381
|
fi
|
|
336
382
|
|
|
383
|
+
# Add epic/phase context if available
|
|
384
|
+
if [ -n "$epic_context" ]; then
|
|
385
|
+
context="$context | Epic: $epic_context"
|
|
386
|
+
fi
|
|
387
|
+
|
|
388
|
+
if [ -n "$phase_context" ]; then
|
|
389
|
+
context="$context | Phase: $phase_context"
|
|
390
|
+
fi
|
|
391
|
+
|
|
337
392
|
# Inject CFN Loop context if injection script exists and loop_type provided
|
|
338
393
|
if [[ -n "$loop_type" ]] && [[ -x "$SCRIPT_DIR/inject-loop-context.sh" ]]; then
|
|
339
394
|
context=$("$SCRIPT_DIR/inject-loop-context.sh" "$loop_type" "$context" 2>/dev/null || echo "$context")
|
|
@@ -375,7 +430,7 @@ function spawn_loop3_agents() {
|
|
|
375
430
|
--task-id "$safe_task_id" \
|
|
376
431
|
--agent-id "$safe_agent_id" \
|
|
377
432
|
--iteration "$iteration" \
|
|
378
|
-
--context "$(build_agent_context "$iteration" "$safe_agent_type" "" "loop3")" &
|
|
433
|
+
--context "$(build_agent_context "$safe_task_id" "$iteration" "$safe_agent_type" "" "loop3")" &
|
|
379
434
|
|
|
380
435
|
# Store PID for monitoring using unique agent ID
|
|
381
436
|
AGENT_PID=$!
|
|
@@ -608,7 +663,7 @@ function spawn_loop2_agents() {
|
|
|
608
663
|
--task-id "$task_id" \
|
|
609
664
|
--agent-id "$UNIQUE_VALIDATOR_ID" \
|
|
610
665
|
--iteration "$iteration" \
|
|
611
|
-
--context "$(build_agent_context "$iteration" "$agent_type" "" "loop2")" &
|
|
666
|
+
--context "$(build_agent_context "$task_id" "$iteration" "$agent_type" "" "loop2")" &
|
|
612
667
|
|
|
613
668
|
# Store PID for monitoring using unique agent ID
|
|
614
669
|
AGENT_PID=$!
|