claude-flow-novice 2.14.18 → 2.14.20
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_EXPERT_UPDATE.md +142 -0
- package/.claude/commands/CFN_LOOP_TASK_MODE.md +6 -6
- package/.claude/commands/cfn-docker/CFN_DOCKER_CLI.md +527 -0
- package/.claude/commands/cfn-docker/CFN_DOCKER_LOOP.md +377 -0
- package/.claude/commands/cfn-docker/CFN_DOCKER_TASK.md +490 -0
- package/.claude/commands/cfn-loop-cli.md +279 -69
- package/.claude/commands/deprecated/README.md +55 -0
- 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/agents/docker-coordinators/cfn-docker-v3-coordinator.md +199 -0
- package/claude-assets/commands/CFN_EXPERT_UPDATE.md +142 -0
- package/claude-assets/commands/CFN_LOOP_TASK_MODE.md +6 -6
- package/claude-assets/commands/cfn-docker/CFN_DOCKER_CLI.md +527 -0
- package/claude-assets/commands/cfn-docker/CFN_DOCKER_LOOP.md +377 -0
- package/claude-assets/commands/cfn-docker/CFN_DOCKER_TASK.md +490 -0
- package/claude-assets/commands/cfn-loop-cli.md +279 -69
- package/claude-assets/commands/deprecated/README.md +55 -0
- package/claude-assets/root-claude-distribute/CFN-CLAUDE.md +115 -42
- package/claude-assets/skills/cfn-docker-agent-spawning/SKILL.md +394 -0
- package/claude-assets/skills/cfn-docker-agent-spawning/spawn-agent.sh +461 -0
- package/claude-assets/skills/cfn-docker-loop-orchestration/SKILL.md +449 -0
- package/claude-assets/skills/cfn-docker-loop-orchestration/orchestrate.sh +787 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/SKILL.md +435 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh +635 -0
- package/claude-assets/skills/cfn-docker-skill-mcp-selection/SKILL.md +289 -0
- package/claude-assets/skills/cfn-docker-skill-mcp-selection/skill-mcp-selector.js +472 -0
- package/claude-assets/skills/cfn-expert-update/update-expert.sh +346 -0
- 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/cli/config-manager.js +91 -109
- package/dist/cli/config-manager.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
- /package/.claude/commands/{cfn-loop-epic.md → deprecated/cfn-loop-epic.md} +0 -0
- /package/.claude/commands/{cfn-loop-single.md → deprecated/cfn-loop-single.md} +0 -0
- /package/.claude/commands/{cfn-loop-sprints.md → deprecated/cfn-loop-sprints.md} +0 -0
- /package/.claude/commands/{cfn-loop.md → deprecated/cfn-loop.md} +0 -0
- /package/.claude/commands/{cfn/run-tests.md → run-tests.md} +0 -0
- /package/claude-assets/commands/{cfn-loop-epic.md → deprecated/cfn-loop-epic.md} +0 -0
- /package/claude-assets/commands/{cfn-loop-single.md → deprecated/cfn-loop-single.md} +0 -0
- /package/claude-assets/commands/{cfn-loop-sprints.md → deprecated/cfn-loop-sprints.md} +0 -0
- /package/claude-assets/commands/{cfn-loop.md → deprecated/cfn-loop.md} +0 -0
- /package/claude-assets/commands/{cfn/run-tests.md → run-tests.md} +0 -0
|
@@ -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
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
# CFN Docker Agent Spawning Skill
|
|
2
|
+
|
|
3
|
+
**Purpose:** Spawn agents in isolated Docker containers with skill-based MCP selection, resource management, and authentication.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This skill manages the lifecycle of container-based agents, providing isolated execution environments with controlled resource usage, secure MCP access, and comprehensive monitoring capabilities.
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
Agent Spawning Request
|
|
13
|
+
↓
|
|
14
|
+
Container Configuration (memory, CPU, volumes)
|
|
15
|
+
↓
|
|
16
|
+
Docker Container Creation
|
|
17
|
+
↓
|
|
18
|
+
MCP Token Generation & Injection
|
|
19
|
+
↓
|
|
20
|
+
Agent Initialization (claude-flow-novice agent-spawn)
|
|
21
|
+
↓
|
|
22
|
+
Resource Monitoring & Management
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Core Functions
|
|
26
|
+
|
|
27
|
+
### 1. Container Configuration
|
|
28
|
+
Generate Docker container specifications based on agent type and requirements:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Configure container for frontend engineer
|
|
32
|
+
cfn-docker-agent-spawn configure \
|
|
33
|
+
--agent-type react-frontend-engineer \
|
|
34
|
+
--memory-limit 1g \
|
|
35
|
+
--cpu-limit 1.0 \
|
|
36
|
+
--network mcp-network
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2. Container Creation
|
|
40
|
+
Create and start Docker containers with proper isolation:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Spawn agent container
|
|
44
|
+
cfn-docker-agent-spawn create \
|
|
45
|
+
--agent-id agent-frontend-001 \
|
|
46
|
+
--agent-type react-frontend-engineer \
|
|
47
|
+
--task-id task-authentication \
|
|
48
|
+
--context "${TASK_CONTEXT}"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 3. MCP Integration
|
|
52
|
+
Configure secure MCP server access with authentication tokens:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Setup MCP access for container
|
|
56
|
+
cfn-docker-agent-spawn setup-mcp \
|
|
57
|
+
--container-id agent-frontend-001 \
|
|
58
|
+
--mcp-servers playwright \
|
|
59
|
+
--token-file /tmp/mcp-tokens.json
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 4. Resource Management
|
|
63
|
+
Monitor and manage container resources:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Monitor container resources
|
|
67
|
+
cfn-docker-agent-spawn monitor \
|
|
68
|
+
--container-id agent-frontend-001 \
|
|
69
|
+
--alert-threshold 90%
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Container Specification
|
|
73
|
+
|
|
74
|
+
### Standard Configuration
|
|
75
|
+
```yaml
|
|
76
|
+
# Docker container specification
|
|
77
|
+
agent-container:
|
|
78
|
+
image: claude-flow-novice:agent
|
|
79
|
+
hostname: agent-{{AGENT_ID}}
|
|
80
|
+
networks:
|
|
81
|
+
- mcp-network
|
|
82
|
+
volumes:
|
|
83
|
+
- ./.claude:/app/.claude:ro
|
|
84
|
+
- ./src:/app/src:ro
|
|
85
|
+
- agent-workspace-{{AGENT_ID}}:/app/workspace
|
|
86
|
+
environment:
|
|
87
|
+
- AGENT_ID={{AGENT_ID}}
|
|
88
|
+
- AGENT_TYPE={{AGENT_TYPE}}
|
|
89
|
+
- TASK_ID={{TASK_ID}}
|
|
90
|
+
- REDIS_URL=redis://redis:6379
|
|
91
|
+
- MCP_TOKENS_FILE=/tmp/mcp-tokens.json
|
|
92
|
+
resources:
|
|
93
|
+
memory: {{MEMORY_LIMIT}}
|
|
94
|
+
cpu: {{CPU_LIMIT}}
|
|
95
|
+
restart_policy: unless-stopped
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Volume Mounts
|
|
99
|
+
- **Codebase**: Read-only mount for source code and skills
|
|
100
|
+
- **Agent Configuration**: Read-only mount for .claude directory
|
|
101
|
+
- **Workspace**: Writable mount for agent work output
|
|
102
|
+
- **Token Store**: Temporary file for MCP authentication tokens
|
|
103
|
+
|
|
104
|
+
### Environment Variables
|
|
105
|
+
- `AGENT_ID`: Unique container identifier
|
|
106
|
+
- `AGENT_TYPE`: Agent type for skill-based selection
|
|
107
|
+
- `TASK_ID`: CFN Loop task identifier
|
|
108
|
+
- `REDIS_URL`: Redis connection string
|
|
109
|
+
- `MCP_TOKENS_FILE`: Path to MCP authentication tokens
|
|
110
|
+
|
|
111
|
+
## Usage Patterns
|
|
112
|
+
|
|
113
|
+
### Basic Agent Spawning
|
|
114
|
+
```bash
|
|
115
|
+
# Spawn single agent
|
|
116
|
+
cfn-docker-agent-spawn \
|
|
117
|
+
--agent-type react-frontend-engineer \
|
|
118
|
+
--task-id "implement-ui" \
|
|
119
|
+
--memory-limit 1g
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Batch Agent Spawning
|
|
123
|
+
```bash
|
|
124
|
+
# Spawn team of agents
|
|
125
|
+
cfn-docker-agent-spawn batch \
|
|
126
|
+
--team frontend \
|
|
127
|
+
--agents 3 \
|
|
128
|
+
--task-id "ui-development" \
|
|
129
|
+
--memory-limit 1g \
|
|
130
|
+
--network mcp-network
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Custom Configuration
|
|
134
|
+
```bash
|
|
135
|
+
# Spawn with custom configuration
|
|
136
|
+
cfn-docker-agent-spawn \
|
|
137
|
+
--agent-type security-specialist \
|
|
138
|
+
--custom-config config/security-agent.json \
|
|
139
|
+
--environment "DEBUG=true,LOG_LEVEL=verbose" \
|
|
140
|
+
--volume /data/secrets:/app/secrets:ro
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Resource Management
|
|
144
|
+
|
|
145
|
+
### Memory Limits
|
|
146
|
+
| Agent Type | Default Limit | Maximum Recommended |
|
|
147
|
+
|------------|---------------|---------------------|
|
|
148
|
+
| **Frontend Engineer** | 1GB | 2GB |
|
|
149
|
+
| **Backend Developer** | 768MB | 1.5GB |
|
|
150
|
+
| **Security Specialist** | 1.5GB | 3GB |
|
|
151
|
+
| **DevOps Engineer** | 1GB | 2GB |
|
|
152
|
+
|
|
153
|
+
### CPU Limits
|
|
154
|
+
- **Standard Agents**: 0.5-1.0 CPU units
|
|
155
|
+
- **Resource-Intensive Agents**: 1.0-2.0 CPU units
|
|
156
|
+
- **Batch Operations**: 0.3-0.5 CPU units per agent
|
|
157
|
+
|
|
158
|
+
### Network Configuration
|
|
159
|
+
```bash
|
|
160
|
+
# Create isolated network for MCP communication
|
|
161
|
+
docker network create mcp-network --driver bridge
|
|
162
|
+
|
|
163
|
+
# Connect containers to MCP network
|
|
164
|
+
docker network connect mcp-network agent-frontend-001
|
|
165
|
+
docker network connect mcp-network playwright-mcp
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Integration with CFN Docker Skills
|
|
169
|
+
|
|
170
|
+
### Skill-Based MCP Selection
|
|
171
|
+
```bash
|
|
172
|
+
# Get MCP configuration for agent
|
|
173
|
+
MCP_CONFIG=$(cfn-docker-skill-mcp-selector select --agent-type ${AGENT_TYPE})
|
|
174
|
+
|
|
175
|
+
# Spawn with MCP configuration
|
|
176
|
+
cfn-docker-agent-spawn \
|
|
177
|
+
--agent-type ${AGENT_TYPE} \
|
|
178
|
+
--mcp-config "${MCP_CONFIG}" \
|
|
179
|
+
--auto-tokens
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Redis Coordination
|
|
183
|
+
```bash
|
|
184
|
+
# Register agent in Redis
|
|
185
|
+
cfn-docker-redis-coordination register \
|
|
186
|
+
--agent-id ${AGENT_ID} \
|
|
187
|
+
--container-id ${CONTAINER_ID} \
|
|
188
|
+
--status "spawning"
|
|
189
|
+
|
|
190
|
+
# Update agent status
|
|
191
|
+
cfn-docker-redis-coordination update-status \
|
|
192
|
+
--agent-id ${AGENT_ID} \
|
|
193
|
+
--status "running"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Loop Orchestration
|
|
197
|
+
```bash
|
|
198
|
+
# Spawn agents for Loop 3 implementation
|
|
199
|
+
cfn-docker-loop-orchestration spawn-loop3 \
|
|
200
|
+
--task-context "${TASK_CONTEXT}" \
|
|
201
|
+
--agent-count 3 \
|
|
202
|
+
--parallel
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Monitoring and Observability
|
|
206
|
+
|
|
207
|
+
### Resource Monitoring
|
|
208
|
+
```bash
|
|
209
|
+
# Real-time resource usage
|
|
210
|
+
cfn-docker-agent-spawn stats \
|
|
211
|
+
--agent-id agent-frontend-001 \
|
|
212
|
+
--format json
|
|
213
|
+
|
|
214
|
+
# Historical resource data
|
|
215
|
+
cfn-docker-agent-spawn history \
|
|
216
|
+
--agent-id agent-frontend-001 \
|
|
217
|
+
--duration 1h
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Health Checks
|
|
221
|
+
```bash
|
|
222
|
+
# Container health status
|
|
223
|
+
cfn-docker-agent-spawn health \
|
|
224
|
+
--agent-id agent-frontend-001
|
|
225
|
+
|
|
226
|
+
# MCP server connectivity
|
|
227
|
+
cfn-docker-agent-spawn check-mcp \
|
|
228
|
+
--agent-id agent-frontend-001 \
|
|
229
|
+
--servers playwright,redis
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Logging
|
|
233
|
+
```bash
|
|
234
|
+
# Container logs
|
|
235
|
+
cfn-docker-agent-spawn logs \
|
|
236
|
+
--agent-id agent-frontend-001 \
|
|
237
|
+
--tail 100
|
|
238
|
+
|
|
239
|
+
# Structured logs for monitoring
|
|
240
|
+
cfn-docker-agent-spawn logs \
|
|
241
|
+
--agent-id agent-frontend-001 \
|
|
242
|
+
--format json \
|
|
243
|
+
--output /var/log/agents/${AGENT_ID}.log
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Error Handling
|
|
247
|
+
|
|
248
|
+
### Container Failure Recovery
|
|
249
|
+
```bash
|
|
250
|
+
# Automatic restart on failure
|
|
251
|
+
cfn-docker-agent-spawn \
|
|
252
|
+
--agent-type ${AGENT_TYPE} \
|
|
253
|
+
--restart-policy on-failure \
|
|
254
|
+
--restart-count 3
|
|
255
|
+
|
|
256
|
+
# Manual recovery
|
|
257
|
+
cfn-docker-agent-spawn recover \
|
|
258
|
+
--agent-id agent-frontend-001 \
|
|
259
|
+
--backup-state
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Resource Exhaustion Handling
|
|
263
|
+
```bash
|
|
264
|
+
# Memory pressure handling
|
|
265
|
+
cfn-docker-agent-spawn \
|
|
266
|
+
--memory-limit 1g \
|
|
267
|
+
--memory-swap 1.5g \
|
|
268
|
+
--oom-kill-disable
|
|
269
|
+
|
|
270
|
+
# CPU throttling
|
|
271
|
+
cfn-docker-agent-spawn \
|
|
272
|
+
--cpu-limit 1.0 \
|
|
273
|
+
--cpu-shares 1024
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Network Isolation Issues
|
|
277
|
+
```bash
|
|
278
|
+
# Network connectivity validation
|
|
279
|
+
cfn-docker-agent-spawn validate-network \
|
|
280
|
+
--agent-id agent-frontend-001 \
|
|
281
|
+
--targets redis:6379,playwright-mcp:3000
|
|
282
|
+
|
|
283
|
+
# Network repair
|
|
284
|
+
cfn-docker-agent-spawn repair-network \
|
|
285
|
+
--agent-id agent-frontend-001 \
|
|
286
|
+
--recreate-network
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Performance Optimization
|
|
290
|
+
|
|
291
|
+
### Startup Optimization
|
|
292
|
+
- **Pre-warmed Images**: Use Docker image layer caching
|
|
293
|
+
- **Parallel Startup**: Spawn multiple containers concurrently
|
|
294
|
+
- **Lazy Loading**: Load MCP servers on-demand
|
|
295
|
+
- **Resource Pre-allocation**: Reserve resources in advance
|
|
296
|
+
|
|
297
|
+
### Memory Optimization
|
|
298
|
+
- **Selective MCP Loading**: Only load required MCP servers
|
|
299
|
+
- **Workspace Cleanup**: Clean temporary files automatically
|
|
300
|
+
- **Garbage Collection**: Optimize Node.js memory management
|
|
301
|
+
- **Shared Libraries**: Use shared mounts for common dependencies
|
|
302
|
+
|
|
303
|
+
### Network Optimization
|
|
304
|
+
- **Local Network**: Use Docker bridge networks for MCP communication
|
|
305
|
+
- **Connection Pooling**: Reuse MCP server connections
|
|
306
|
+
- **DNS Caching**: Cache MCP server DNS resolution
|
|
307
|
+
- **Compression**: Compress large data transfers
|
|
308
|
+
|
|
309
|
+
## Security Considerations
|
|
310
|
+
|
|
311
|
+
### Container Isolation
|
|
312
|
+
- **Read-only Codebase**: Prevent code modification
|
|
313
|
+
- **Limited Privileges**: Run as non-root user
|
|
314
|
+
- **Resource Limits**: Prevent DoS attacks
|
|
315
|
+
- **Network Segmentation**: Isolate agent networks
|
|
316
|
+
|
|
317
|
+
### Token Security
|
|
318
|
+
- **Secure Token Storage**: Use tmpfs for token files
|
|
319
|
+
- **Token Expiration**: Automatic token rotation
|
|
320
|
+
- **Access Logging**: Log all token usage
|
|
321
|
+
- **Revocation**: Immediate token invalidation
|
|
322
|
+
|
|
323
|
+
### File System Security
|
|
324
|
+
- **Restricted Access**: Limit file system access
|
|
325
|
+
- **Workspace Isolation**: Isolate agent workspaces
|
|
326
|
+
- **Temporary Files**: Secure cleanup of temporary files
|
|
327
|
+
- **Audit Logging**: Log all file system operations
|
|
328
|
+
|
|
329
|
+
## Testing and Validation
|
|
330
|
+
|
|
331
|
+
### Unit Tests
|
|
332
|
+
- Container creation and configuration
|
|
333
|
+
- Resource limit enforcement
|
|
334
|
+
- Network connectivity validation
|
|
335
|
+
- Token injection and validation
|
|
336
|
+
|
|
337
|
+
### Integration Tests
|
|
338
|
+
- End-to-end agent spawning workflow
|
|
339
|
+
- MCP server connectivity and authentication
|
|
340
|
+
- Resource monitoring and alerting
|
|
341
|
+
- Error handling and recovery
|
|
342
|
+
|
|
343
|
+
### Performance Tests
|
|
344
|
+
- Container startup time measurement
|
|
345
|
+
- Resource usage benchmarking
|
|
346
|
+
- Concurrent spawning scalability
|
|
347
|
+
- Network performance validation
|
|
348
|
+
|
|
349
|
+
## Troubleshooting
|
|
350
|
+
|
|
351
|
+
### Common Issues
|
|
352
|
+
1. **Container Won't Start**: Check image availability and resource limits
|
|
353
|
+
2. **MCP Connection Failed**: Verify network configuration and token validity
|
|
354
|
+
3. **Memory Issues**: Monitor usage and adjust limits
|
|
355
|
+
4. **Permission Errors**: Check volume mounts and user permissions
|
|
356
|
+
|
|
357
|
+
### Debug Commands
|
|
358
|
+
```bash
|
|
359
|
+
# Debug container creation
|
|
360
|
+
cfn-docker-agent-spawn debug \
|
|
361
|
+
--agent-type ${AGENT_TYPE} \
|
|
362
|
+
--verbose \
|
|
363
|
+
--dry-run
|
|
364
|
+
|
|
365
|
+
# Inspect container configuration
|
|
366
|
+
cfn-docker-agent-spawn inspect \
|
|
367
|
+
--container-id ${CONTAINER_ID} \
|
|
368
|
+
--format json
|
|
369
|
+
|
|
370
|
+
# Validate MCP connectivity
|
|
371
|
+
cfn-docker-agent-spawn test-mcp \
|
|
372
|
+
--container-id ${CONTAINER_ID} \
|
|
373
|
+
--all-servers
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Best Practices
|
|
377
|
+
|
|
378
|
+
### Resource Planning
|
|
379
|
+
- **Conservative Limits**: Start with lower memory limits and increase as needed
|
|
380
|
+
- **Monitoring**: Implement comprehensive resource monitoring
|
|
381
|
+
- **Capacity Planning**: Plan for peak usage scenarios
|
|
382
|
+
- **Resource Cleanup**: Clean up unused containers and volumes
|
|
383
|
+
|
|
384
|
+
### Security Hardening
|
|
385
|
+
- **Minimal Images**: Use minimal Docker images
|
|
386
|
+
- **Regular Updates**: Keep base images updated
|
|
387
|
+
- **Scanning**: Regularly scan images for vulnerabilities
|
|
388
|
+
- **Access Control**: Implement proper access controls
|
|
389
|
+
|
|
390
|
+
### Operational Excellence
|
|
391
|
+
- **Automation**: Automate container lifecycle management
|
|
392
|
+
- **Observability**: Implement comprehensive monitoring
|
|
393
|
+
- **Documentation**: Maintain detailed configuration documentation
|
|
394
|
+
- **Backup**: Backup critical container configurations
|