claude-flow-novice 2.18.22 → 2.18.24
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/CLAUDE.md +17 -0
- package/.claude/cfn-scripts/check-memory.sh +150 -0
- package/.claude/cfn-scripts/run-with-memory-limit.sh +91 -0
- package/.claude/commands/cfn-loop/cfn-loop-cli.md +9 -0
- package/.claude/commands/cfn-loop-task.md +11 -0
- package/.claude/commands/cfn-ruvector/cfn-codebase-reindex.md +23 -4
- package/.claude/commands/cfn-ruvector/cfn-codebase-search.md +10 -2
- package/.claude/commands/cfn-ruvector/cfn-detect-stale-docs.md +22 -4
- package/.claude/hooks/README.md +148 -148
- package/.claude/hooks/cfn-bash-search-hook.sh +87 -0
- package/.claude/hooks/cfn-smart-search-hook.sh +127 -0
- package/.claude/hooks/deprecated/cfn-SessionStart-cfn-load-openai-key.sh +48 -0
- package/.claude/hooks/post-commit-codebase-index +79 -45
- package/.claude/settings.json +20 -11
- package/.claude/skills/CLAUDE.md +70 -0
- package/.claude/skills/cfn-edit-safety/lib/hooks/security-scanner.sh +1 -0
- package/.claude/skills/cfn-local-ruvector-accelerator/SKILL.md +37 -21
- package/.claude/skills/cfn-local-ruvector-accelerator/cfn-integration.sh +47 -6
- package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/index.rs +2 -1
- package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/init.rs +3 -3
- package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/query.rs +1 -1
- package/.claude/skills/cfn-local-ruvector-accelerator/src/lib.rs +1 -0
- package/.claude/skills/cfn-local-ruvector-accelerator/src/paths.rs +4 -2
- package/.claude/skills/cfn-local-ruvector-accelerator/src/search_engine.rs +11 -0
- package/.claude/skills/cfn-local-ruvector-accelerator/test_query_api.sh +102 -102
- package/CLAUDE.md +63 -373
- package/docs/CFN_LOOP_CLI_MODE.md +134 -0
- package/package.json +9 -5
- package/scripts/cfn-init.js +8 -2
- package/scripts/organize-root-files.sh +340 -340
- package/scripts/postinstall.js +120 -3
- package/test-epic-creator-security.sh +202 -202
- package/.claude/hooks/SessionStart:cfn-build-ruvector.sh +0 -28
- package/.claude/hooks/SessionStart:cfn-load-openai-key.sh +0 -35
- /package/.claude/hooks/{SessionStart-cfn-build-ruvector.sh → cfn-SessionStart-cfn-build-ruvector.sh} +0 -0
- /package/.claude/hooks/{cfn-load-cerebras-env.sh → deprecated/cfn-load-cerebras-env.sh} +0 -0
package/CLAUDE.md
CHANGED
|
@@ -1,395 +1,85 @@
|
|
|
1
|
-
#
|
|
2
|
-
---
|
|
1
|
+
# CFN Operating Guide
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Docs
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
| Topic | Path |
|
|
6
|
+
|-------|------|
|
|
7
|
+
| CLI Mode | `docs/CFN_LOOP_CLI_MODE.md` |
|
|
8
|
+
| Tests | `tests/CLAUDE.md` |
|
|
9
|
+
| Skills | `.claude/skills/CLAUDE.md` |
|
|
10
|
+
| Coordination | `.claude/CLAUDE.md` |
|
|
11
|
+
| Architecture | `cfn-system-expert.md` |
|
|
12
12
|
|
|
13
|
-
##
|
|
14
|
-
- Act as a busy CTO peer: delegate non-trivial work, speak plainly, no fluff.
|
|
15
|
-
- Provide context and success criteria; let agents choose implementation.
|
|
16
|
-
- Success = implemented, tested, documented. Do not add adoption/rollout criteria.
|
|
17
|
-
- Prefer spartan language; code/examples only when requested.
|
|
18
|
-
- Avoid long summaries; focus on decisions, risks, and next actions.
|
|
13
|
+
## Style
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
- Use agents/CFN Loops for non-trivial tasks: multi-step, multi-file, research, testing, security, integration, refactor, or feature work.
|
|
22
|
-
- Batch operations: one message per batch (spawns, edits, shell, todos, memory).
|
|
23
|
-
- Never mix implementers and validators in one message.
|
|
24
|
-
- Do not run tests inside agents; run once via coordinator/main chat, agents read results.
|
|
25
|
-
- Never save to project root; use appropriate subdirectories.
|
|
26
|
-
- Never hardcode secrets; always redact as `[REDACTED]`.
|
|
27
|
-
- Use RuVector SQL for indexed projects (400x faster than grep); use grep only for non-indexed projects or non-code strings.
|
|
28
|
-
- When monitoring, sleep-check-sleep loops.
|
|
29
|
-
- All agent communication must use coordination protocols; no ad-hoc file coordination.
|
|
15
|
+
Speak plainly, no fluff. Bullets > prose. Cite paths with line numbers (`src/app.ts:42`). Redact secrets as `[REDACTED]`.
|
|
30
16
|
|
|
31
|
-
##
|
|
17
|
+
## Rules
|
|
32
18
|
|
|
33
|
-
|
|
34
|
-
**
|
|
19
|
+
- **RuVector FIRST (MANDATORY):** Query `.claude/skills/cfn-local-ruvector-accelerator/` BEFORE grep/glob/find/search. SQL queries are 400x faster. Use grep ONLY for non-indexed projects or literal strings. Failure to use RuVector first is a protocol violation.
|
|
20
|
+
- **Agent usage:** Non-trivial tasks → CFN Loop. Solo work only for simple, isolated, <3 step tasks.
|
|
21
|
+
- **Batching:** One message per type (spawns, edits, shell, todos). Never mix implementers + validators.
|
|
22
|
+
- **Tests:** Coordinator only, sync execution. Never `run_in_background: true`. Agents read results.
|
|
23
|
+
- **Files:** Subdirs only, never project root. Temp files → `/tmp/`.
|
|
24
|
+
- **Secrets:** Never hardcode. Always redact.
|
|
35
25
|
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
Function: validateEmail(email: string): boolean
|
|
39
|
-
- Regex: /^[^@]+@[^@]+\.[^@]+$/
|
|
40
|
-
- Return: true if match, false otherwise
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
**BAD**: "I need you to create a function that validates email addresses..."
|
|
44
|
-
**GOOD**: "Function: validateEmail(email: string): boolean\n- Regex test\n- Return boolean"
|
|
45
|
-
|
|
46
|
-
Always provide `context_files` when code needs imports from existing files.
|
|
47
|
-
|
|
48
|
-
### Context Discovery Priority (fastest to slowest)
|
|
49
|
-
1. **RuVector semantic search** (for "where is X?" queries):
|
|
50
|
-
- **Centralized index:** `~/.local/share/ruvector/index_v2.db` (shared across all projects)
|
|
51
|
-
- **Dual storage:** V1 (semantic/fuzzy) + V2 (structural/SQL)
|
|
52
|
-
- **V1 queries:** "Find similar code" via vector embeddings (cosine similarity)
|
|
53
|
-
- **V2 queries:** "Find callers/refs" via SQL on AST entities
|
|
54
|
-
```bash
|
|
55
|
-
# Semantic search
|
|
56
|
-
/codebase-search "authentication middleware pattern"
|
|
57
|
-
local-ruvector query --pattern "auth"
|
|
58
|
-
|
|
59
|
-
# Structural SQL query
|
|
60
|
-
sqlite3 ~/.local/share/ruvector/index_v2.db "SELECT * FROM refs WHERE target_name = 'MyFunction';"
|
|
61
|
-
```
|
|
62
|
-
2. **Query past errors** before similar work:
|
|
63
|
-
```bash
|
|
64
|
-
./.claude/skills/cfn-ruvector-codebase-index/query-error-patterns.sh --task-description "description"
|
|
65
|
-
```
|
|
66
|
-
3. **Query learnings** for best practices:
|
|
67
|
-
```bash
|
|
68
|
-
./.claude/skills/cfn-ruvector-codebase-index/query-learnings.sh --task-description "description" --category PATTERN
|
|
69
|
-
```
|
|
70
|
-
4. **Grep** only for exact string/symbol matches
|
|
71
|
-
5. **Glob** only for known file patterns (`**/*.test.ts`)
|
|
72
|
-
|
|
73
|
-
### MDAP Execution Context (when `enableMDAP=true`)
|
|
74
|
-
Applies only in Trigger.dev MDAP mode:
|
|
75
|
-
- Single file only (path provided by decomposer)
|
|
76
|
-
- Target: <50 lines of code, atomic task
|
|
77
|
-
- No file discovery (context pre-injected)
|
|
78
|
-
- Return structured JSON: `{"success": true, "filePath": "...", "linesWritten": N, "confidence": 0.9}`
|
|
79
|
-
|
|
80
|
-
→ Full protocols: `.claude/agents/SHARED_PROTOCOL.md`
|
|
81
|
-
|
|
82
|
-
## 4) Mandatory Edit Workflow
|
|
83
|
-
- Pre-Edit Backup (required before any edit/write, including docs):
|
|
84
|
-
```bash
|
|
85
|
-
BACKUP_PATH=$(./.claude/hooks/cfn-invoke-pre-edit.sh "$FILE_TO_EDIT" --agent-id "$AGENT_ID")
|
|
86
|
-
```
|
|
87
|
-
- Post-Edit Validation (run after every edit):
|
|
88
|
-
```bash
|
|
89
|
-
./.claude/hooks/cfn-invoke-post-edit.sh "$EDITED_FILE" --agent-id "$AGENT_ID"
|
|
90
|
-
```
|
|
91
|
-
- Revert via backups only (never `git checkout --`):
|
|
92
|
-
```bash
|
|
93
|
-
./.claude/skills/pre-edit-backup/revert-file.sh "$FILE_PATH" --agent-id "$AGENT_ID"
|
|
94
|
-
```
|
|
95
|
-
- Hooks are non-blocking; fix issues surfaced by post-edit. Keep backup paths for reference.
|
|
96
|
-
|
|
97
|
-
## 5) When to Spawn Agents vs Work Solo
|
|
98
|
-
- Use a single agent (Task) only for simple, isolated work.
|
|
99
|
-
- Use coordinator/CFN Loop for: multi-agent needs, more than three steps, multi-file edits, design decisions, testing plus implementation, quality/security/performance/compliance, docs generation, system integration, or refactors.
|
|
100
|
-
- Triggers to avoid solo work: feature work, cross-cutting changes, research plus implementation, code review/quality gates, or anything requiring validation.
|
|
101
|
-
|
|
102
|
-
## 6) CFN Loop Modes (user chooses)
|
|
103
|
-
- Default Task Mode:
|
|
104
|
-
- Command: `/cfn-loop-task "Task description" --mode=standard`
|
|
105
|
-
- Spawns all agents directly; full visibility; higher cost.
|
|
106
|
-
- Best for debugging, learning, or short tasks (<5 minutes).
|
|
107
|
-
- CLI Mode (production default):
|
|
108
|
-
- Command: `/cfn-loop-cli "Task description" --mode=standard --provider kimi`
|
|
109
|
-
- Main chat spawns CLI agents directly; Redis BLPOP coordination; lower cost.
|
|
110
|
-
- Best for production, provider routing, and cost-sensitive work.
|
|
111
|
-
- Mode guidance: phrases like "execute cfn loop" use task mode; "production cli" uses CLI mode.
|
|
112
|
-
- Deprecated: manual Task() spawning for CLI workflows.
|
|
113
|
-
|
|
114
|
-
### Task Mode Execution Steps
|
|
115
|
-
1) Expand slash command; validate parameters.
|
|
116
|
-
2) Spawn required agents via Task() from main chat.
|
|
117
|
-
3) Provide context and success criteria; include lifecycle instructions if auditing.
|
|
118
|
-
4) Agents execute and return results; no Redis signaling.
|
|
119
|
-
5) Iterate or close based on validator/product owner feedback.
|
|
120
|
-
|
|
121
|
-
### Slash Command Execution Rules (CLI mode)
|
|
122
|
-
1) Expand slash command.
|
|
123
|
-
2) Immediately execute coordinator spawn via Bash tool using the exact command.
|
|
124
|
-
3) Do not merely show commands; run them.
|
|
125
|
-
4) Inform user after spawn with task ID.
|
|
126
|
-
Anti-patterns: pausing to ask what next, manual Task() for CLI workflows, skipping execution.
|
|
127
|
-
|
|
128
|
-
### CLI Mode Execution Steps
|
|
129
|
-
1) Expand slash command and validate required parameters (mode, optional provider).
|
|
130
|
-
2) Spawn coordinator via orchestration script; confirm task ID.
|
|
131
|
-
3) Loop 3 agents implement and run tests; orchestration monitors via Redis.
|
|
132
|
-
4) Gate check compares pass rate to mode threshold; if failing, iterate Loop 3.
|
|
133
|
-
5) If gate passes, Loop 2 validators review and score.
|
|
134
|
-
6) Product Owner agent decides PROCEED/ITERATE/ABORT; orchestrator enforces.
|
|
135
|
-
7) Report final status, code paths, test results; stop agents cleanly.
|
|
136
|
-
|
|
137
|
-
## 7) Provider Routing (optional)
|
|
138
|
-
- Enable custom routing: set `CFN_CUSTOM_ROUTING=true` in `.env`.
|
|
139
|
-
- Provider options: `zai` (default, cost), `kimi` (balanced), `openrouter` (broad access), `max` or `anthropic` (premium), `gemini`, `xai`.
|
|
140
|
-
- Agents without provider parameters default to Z.ai glm-4.6 when custom routing is on.
|
|
141
|
-
- Example flow: `/switch-api kimi` then `/cfn-loop-cli "Feature" --provider kimi`.
|
|
142
|
-
- Full guide: `docs/CUSTOM_PROVIDER_ROUTING.md`.
|
|
143
|
-
|
|
144
|
-
### Provider Selection Hints
|
|
145
|
-
- Cost sensitive: `zai` or low-tier `openrouter`.
|
|
146
|
-
- Balanced quality/cost: `kimi`.
|
|
147
|
-
- Highest quality/safety: `max` or `anthropic`.
|
|
148
|
-
- Google ecosystem: `gemini`.
|
|
149
|
-
- XAi/Grok style: `xai`.
|
|
150
|
-
- Mixed providers: set per-agent profile; otherwise inherit main chat provider.
|
|
151
|
-
|
|
152
|
-
## 8) Docker Build Requirements (WSL2)
|
|
153
|
-
- Always build from Linux-native storage; do not build from Windows mounts.
|
|
154
|
-
- Use scripts, not raw `docker build`:
|
|
155
|
-
- Preferred: `./.claude/skills/docker-build/build.sh --dockerfile docker/Dockerfile.agent --tag cfn-agent:latest`
|
|
156
|
-
- Manual: `DOCKERFILE="docker/Dockerfile.agent" IMAGE_NAME="cfn-agent" ./scripts/docker/build-from-linux.sh`
|
|
157
|
-
- Windows mount builds are ~755s vs <20s from Linux. All CFN images must use Linux builds.
|
|
158
|
-
- Dockerfiles should note the Linux build requirement; docker-specialist must comply.
|
|
26
|
+
## Edit Workflow
|
|
159
27
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
-
|
|
163
|
-
- [ ] Confirm Dockerfile path and tag arguments.
|
|
164
|
-
- [ ] Clean `/tmp/cfn-build` if space issues.
|
|
165
|
-
- [ ] Document build command and outputs when reporting failures.
|
|
166
|
-
- [ ] If builds are slow, verify you are not running from a Windows path.
|
|
28
|
+
```bash
|
|
29
|
+
# Before ANY edit:
|
|
30
|
+
./.claude/hooks/cfn-invoke-pre-edit.sh "$FILE" --agent-id "$ID"
|
|
167
31
|
|
|
168
|
-
|
|
169
|
-
-
|
|
170
|
-
- Port offsets auto-calculated with `run-in-worktree.sh` to avoid conflicts.
|
|
171
|
-
- Required environment variables when spawning agents:
|
|
172
|
-
```bash
|
|
173
|
-
export COMPOSE_PROJECT_NAME="cfn-${BRANCH}"
|
|
174
|
-
export CFN_REDIS_PORT="${CFN_REDIS_PORT}"
|
|
175
|
-
export CFN_POSTGRES_PORT="${CFN_POSTGRES_PORT}"
|
|
176
|
-
export WORKTREE_BRANCH="${BRANCH}"
|
|
177
|
-
```
|
|
178
|
-
- Use service names inside Docker networks: `redis`, `postgres`, `orchestrator` (not container names).
|
|
179
|
-
- Checklist: start stack with `./scripts/docker/run-in-worktree.sh up -d`; isolate Redis keys by task IDs; avoid shared volumes; use service names only.
|
|
180
|
-
- Port examples: main (6379/5432/3001); feature-auth (~6421/5474/3043); bugfix-validation (~6457/5510/3079).
|
|
32
|
+
# After edit:
|
|
33
|
+
./.claude/hooks/cfn-invoke-post-edit.sh "$FILE" --agent-id "$ID"
|
|
181
34
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
3) Export project/port env vars before spawning agents.
|
|
186
|
-
4) Connect using service names inside the network; from host, use offset ports.
|
|
187
|
-
5) Tear down with `./scripts/docker/run-in-worktree.sh down` and prune networks if needed.
|
|
188
|
-
|
|
189
|
-
## 10) Task Mode SQLite Lifecycle (audited tasks)
|
|
190
|
-
- Use when Task agents need an audit trail without Redis.
|
|
191
|
-
- Template:
|
|
192
|
-
```javascript
|
|
193
|
-
Task("docker-specialist", `
|
|
194
|
-
LIFECYCLE:
|
|
195
|
-
AGENT_ID="docker-$(date +%s)-$$"
|
|
196
|
-
sqlite3 "./claude-assets/skills/cfn-redis-coordination/data/cfn-loop.db" \
|
|
197
|
-
"CREATE TABLE IF NOT EXISTS agents (...);" && \
|
|
198
|
-
sqlite3 "$DB_PATH" "INSERT OR REPLACE INTO agents (...);"
|
|
199
|
-
# complete task
|
|
200
|
-
sqlite3 "$DB_PATH" "UPDATE agents SET status='completed', confidence=<0.85-0.95>, completed_at=datetime('now') WHERE id='$AGENT_ID';"
|
|
201
|
-
`)
|
|
202
|
-
```
|
|
203
|
-
- Database path: `./claude-assets/skills/cfn-redis-coordination/data/cfn-loop.db`.
|
|
204
|
-
- Table schema: `id, type, status, confidence, spawned_at, completed_at, metadata`.
|
|
205
|
-
- Do not include Redis/CLI commands in Task mode prompts; SQLite only.
|
|
206
|
-
|
|
207
|
-
### Lifecycle Notes
|
|
208
|
-
- Confidence values for auditing typically 0.85-0.95.
|
|
209
|
-
- Ensure `sqlite3` is installed; fail fast otherwise.
|
|
210
|
-
- Keep lifecycle instructions concise and ahead of the task request.
|
|
211
|
-
- Clean up stale audit rows if the table grows; retention per project policy.
|
|
212
|
-
|
|
213
|
-
## 11) Coordination Patterns and Namespace Isolation
|
|
214
|
-
- Coordination patterns: see `.claude/skills/cfn-coordination/SKILL.md` (chain, broadcast, mesh, consensus collection).
|
|
215
|
-
- Namespace structure: agents `.claude/agents/cfn-dev-team/`; skills `.claude/skills/cfn-*/`; hooks `.claude/hooks/cfn-*`; commands `.claude/commands/cfn/`.
|
|
216
|
-
- Enhanced orchestrator v3.0: `./.claude/skills/cfn-loop-orchestration/orchestrate.sh` (monitors agents, restarts stuck ones, enforces protocols).
|
|
217
|
-
- Orchestration flow: Loop 3 executes and tests -> gate check -> Loop 2 validators -> Product Owner decision (PROCEED/ITERATE/ABORT) -> iterate or finish.
|
|
218
|
-
- Agent protocol (CLI): completion signaling via Redis, context validation, metadata tracking, health monitoring.
|
|
219
|
-
- Task mode agents: return output directly; no Redis signaling.
|
|
220
|
-
|
|
221
|
-
### Coordination Anti-Patterns (avoid)
|
|
222
|
-
- Skipping gate check before spawning Loop 2.
|
|
223
|
-
- Validators reviewing without tests/logs.
|
|
224
|
-
- Product Owner decision without deliverable paths.
|
|
225
|
-
- Mixing service and container names inside Docker networks.
|
|
226
|
-
- Manual cleanup instead of orchestrator controls.
|
|
227
|
-
|
|
228
|
-
## 12) Agent Output Standards
|
|
229
|
-
- Bug docs: `docs/BUG_#_*.md` (investigation, fix, validation).
|
|
230
|
-
- Test scripts: `tests/test-*.sh` (checked in).
|
|
231
|
-
- Feature docs: `docs/FEATURE_NAME.md` (architecture/process).
|
|
232
|
-
- Temporary files: `/tmp/` only.
|
|
233
|
-
- Backlog items: `.claude/skills/cfn-backlog-management/add-backlog-item.sh` (item, reason, solution).
|
|
234
|
-
- Changelog: `.claude/skills/cfn-changelog-management/add-changelog-entry.sh` (10-100 characters, sparse impact).
|
|
235
|
-
- Full standards: `docs/AGENT_OUTPUT_STANDARDS.md`.
|
|
236
|
-
|
|
237
|
-
## 13) Test Execution Guidance
|
|
238
|
-
- Always run tests before committing: after features or bugfixes, agent behavior changes, CFN workflow changes.
|
|
239
|
-
- Suites and timing:
|
|
240
|
-
- `npm test` (1-5 minutes, dev feedback)
|
|
241
|
-
- `npm run test:unit` (~1 minute)
|
|
242
|
-
- `npm run test:integration` (~2 minutes)
|
|
243
|
-
- `npm run test:e2e` (~5 minutes)
|
|
244
|
-
- `./tests/cli-mode/run-all-tests.sh` (5-10 minutes; validates `/cfn-loop-cli`)
|
|
245
|
-
- `./tests/docker-mode/run-all-implementations.sh` (3-5 minutes; 45 integration tests)
|
|
246
|
-
- `./tests/cfn-v3/test-e2e-cfn-loop.sh` (5-15 minutes; coordinator/orchestration)
|
|
247
|
-
- Run CLI mode tests before commits touching agent spawning, coordination thresholds, or Redis patterns.
|
|
248
|
-
- Run Docker suite before Docker-related changes or releases.
|
|
249
|
-
- Test artifacts: `.artifacts/test-results/`, coverage `.artifacts/coverage/`, logs `.artifacts/logs/`, runtime `.artifacts/runtime/`.
|
|
250
|
-
|
|
251
|
-
### Test-Driven Gates (v3.0+)
|
|
252
|
-
- Loop 3 gate: pass rate must meet mode threshold before validators start.
|
|
253
|
-
- Loop 2 consensus thresholds by mode:
|
|
254
|
-
- MVP: gate >= 0.70, consensus >= 0.80
|
|
255
|
-
- Standard: gate >= 0.95, consensus >= 0.90
|
|
256
|
-
- Enterprise: gate >= 0.98, consensus >= 0.95
|
|
257
|
-
|
|
258
|
-
### Test Authoring Standards (tests/CLAUDE.md)
|
|
259
|
-
- Use `#!/bin/bash` and `set -euo pipefail`; source `tests/test-utils.sh` immediately.
|
|
260
|
-
- Structure with GIVEN/WHEN/THEN; use `log_step`, `log_info`, `annotate`, `assert_success`.
|
|
261
|
-
- Always add a cleanup trap (docker rm, worktree prune, rm -rf temp).
|
|
262
|
-
- Integration tests must use production code paths (spawn-agent.sh, production images, real CLI syntax, log checks).
|
|
263
|
-
- Infrastructure tests may mock networking or Redis; integration tests must not.
|
|
264
|
-
- Cite relevant bugs or references in test headers for traceability.
|
|
265
|
-
|
|
266
|
-
### Troubleshooting Quick Fixes
|
|
267
|
-
- Redis missing: `redis-server --daemonize yes` or docker `redis:7-alpine`.
|
|
268
|
-
- Docker not running: start daemon (`systemctl start docker` or Docker.app).
|
|
269
|
-
- Port conflicts: `docker stop $(docker ps -aq) && docker rm $(docker ps -aq) && docker network prune -f`.
|
|
270
|
-
- Permissions: `usermod -aG docker $USER` then `newgrp docker`.
|
|
271
|
-
- Verbose mode: `DEBUG=true ./tests/cli-mode/run-all-tests.sh`; inspect `.artifacts/logs/test-execution.log`.
|
|
272
|
-
|
|
273
|
-
## 14) Quality and Skill Development
|
|
274
|
-
- Skill guidelines: maximize modularity, explicit interfaces, minimal dependencies, thorough tests.
|
|
275
|
-
- STRAT-005: cover functional requirements and edge cases (timeouts, blocking). Example: `.claude/skills/cfn-coordination/test-orchestrator.sh`.
|
|
276
|
-
- Core skill references: `.claude/skills/cfn-coordination/SKILL.md`, `.claude/skills/cfn-agent-spawning/SKILL.md`, `.claude/skills/cfn-loop-validation/SKILL.md`.
|
|
277
|
-
|
|
278
|
-
## 15) General Programming Best Practices
|
|
279
|
-
- Regex validation: avoid self-matching patterns (`[[ $AGENTS =~ $AGENTS ]]`); use specific regexes.
|
|
280
|
-
- Comprehensive file validation: check type, permissions, size, and content integrity.
|
|
281
|
-
- Shell scripting: use strict mode `set -euo pipefail`; capture pipeline failures.
|
|
282
|
-
- Process management: use `trap` for signals, manage process groups to avoid zombies; clean up resources.
|
|
283
|
-
- Prefer explicit error handling and early exits to prevent cascading failures.
|
|
284
|
-
|
|
285
|
-
## 16) Quick Reference: Do / Do Not
|
|
286
|
-
- Do: delegate early, run backup hooks, keep responses concise, redact secrets, use service names, build Docker from Linux storage.
|
|
287
|
-
- Do: gate by tests, cite bugs or references in tests, run appropriate suite before commits.
|
|
288
|
-
- Do Not: skip pre-edit backup or post-edit hook; run tests inside agents; build Docker from Windows mounts; hardcode secrets; mix implementer and validator roles; save to project root.
|
|
289
|
-
|
|
290
|
-
## 17) Key Files and Paths
|
|
291
|
-
- Hooks: `./.claude/hooks/cfn-invoke-pre-edit.sh`, `./.claude/hooks/cfn-invoke-post-edit.sh`.
|
|
292
|
-
- Backup revert: `./.claude/skills/pre-edit-backup/revert-file.sh`.
|
|
293
|
-
- Orchestrator: `./.claude/skills/cfn-loop-orchestration/orchestrate.sh`.
|
|
294
|
-
- Provider routing guide: `docs/CUSTOM_PROVIDER_ROUTING.md`.
|
|
295
|
-
- Test guides: `tests/README.md`, `tests/CLAUDE.md`, `tests/cli-mode/README.md`, `tests/docker-mode/README.md`, `tests/TEST_COVERAGE_MATRIX.md`.
|
|
296
|
-
- CFN Loop architecture: `docs/CFN_LOOP_ARCHITECTURE.md`.
|
|
297
|
-
- CI/CD pipeline: `docker/CI_CD_TEST_INTEGRATION.md`.
|
|
298
|
-
- Analytics: `.artifacts/analytics/context-reduction-report.json`.
|
|
299
|
-
|
|
300
|
-
## 18) Execution Playbooks (quick recipes)
|
|
301
|
-
- Implement feature (CLI mode):
|
|
302
|
-
1) `/cfn-loop-cli "Implement <feature>" --mode=standard --provider kimi`
|
|
303
|
-
2) Provide acceptance criteria and target paths; cite relevant docs.
|
|
304
|
-
3) After completion, report code paths and tests run; suggest final validation.
|
|
305
|
-
- Debug bug (Task mode):
|
|
306
|
-
1) `/cfn-loop-task "Investigate bug <id>" --mode=standard`
|
|
307
|
-
2) Include repro steps and log paths; require root cause, fix, and tests.
|
|
308
|
-
3) Save output to `docs/BUG_<id>_*.md`.
|
|
309
|
-
- Add test coverage:
|
|
310
|
-
1) Spawn testing-focused agent; include target modules and desired coverage.
|
|
311
|
-
2) Require GIVEN/WHEN/THEN style, cleanup traps, production code paths.
|
|
312
|
-
3) Run the relevant suite once via coordinator; collect artifacts.
|
|
313
|
-
- Docker build verification:
|
|
314
|
-
1) Confirm Linux filesystem; use build script with tag.
|
|
315
|
-
2) Capture build command and timing; store logs if failing.
|
|
316
|
-
3) If failure, collect `/tmp/cfn-build` outputs and Docker logs.
|
|
317
|
-
|
|
318
|
-
## 19) Common Checks Before and After Work
|
|
319
|
-
- Before: confirm mode (task vs CLI), provider choice, environment variables, worktree isolation, and backup path.
|
|
320
|
-
- During: keep messages concise; avoid mixing roles; use service names; cite paths.
|
|
321
|
-
- After: run post-edit hook; run appropriate tests; link artifacts; note backlog items.
|
|
35
|
+
# Revert (not git checkout):
|
|
36
|
+
./.claude/skills/pre-edit-backup/revert-file.sh "$FILE" --agent-id "$ID"
|
|
37
|
+
```
|
|
322
38
|
|
|
323
|
-
##
|
|
324
|
-
- Redact credentials, tokens, and personal data (`[REDACTED]`).
|
|
325
|
-
- No secrets in code, docs, tests, or environment examples.
|
|
326
|
-
- Validate inputs (type, size, permissions) before processing.
|
|
327
|
-
- Prefer least-privilege operations; avoid destructive commands unless explicitly requested.
|
|
328
|
-
- Scrub task IDs or usernames in shared logs if sensitive.
|
|
39
|
+
## Task Mode
|
|
329
40
|
|
|
330
|
-
|
|
331
|
-
- For long-running tasks: execute action, `sleep <n>m`, recheck, repeat; avoid tight loops.
|
|
332
|
-
- Capture partial logs at each check; stop on errors.
|
|
333
|
-
- If stuck, restart via orchestrator rather than manual kills.
|
|
334
|
-
- Clean up child processes to avoid zombies and port leaks.
|
|
41
|
+
**Command:** `/cfn-loop-task "description" --mode=standard`
|
|
335
42
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
- Post-edit hook fails for missing tools (e.g., `jq`): install dependency or rerun after adding it.
|
|
341
|
-
- Tests flaking: rerun with `DEBUG=true`, inspect `.artifacts/logs/test-execution.log`.
|
|
342
|
-
- Orchestrator stuck: restart via orchestration script; check Redis coordination keys for stale locks.
|
|
43
|
+
1. Parse command, validate params
|
|
44
|
+
2. Spawn agents with context + success criteria
|
|
45
|
+
3. Agents execute, return results (no Redis)
|
|
46
|
+
4. Iterate on validator/PO feedback
|
|
343
47
|
|
|
344
|
-
|
|
345
|
-
- Place new scripts/tests in relevant subdirectories; never in project root.
|
|
346
|
-
- Name tests `test-*.sh`; feature docs `FEATURE_NAME.md`; bug docs `BUG_<id>_*.md`.
|
|
347
|
-
- Use workspace-relative paths when reporting results (for example `src/app.ts:42`).
|
|
348
|
-
- Do not use URI schemes like file:// or vscode:// in reports.
|
|
48
|
+
**CLI Mode:** See `docs/CFN_LOOP_CLI_MODE.md`
|
|
349
49
|
|
|
350
|
-
##
|
|
351
|
-
- Be concise and factual; bullets preferred.
|
|
352
|
-
- Include code paths inline with backticks; add line numbers when available.
|
|
353
|
-
- In reviews, list findings first (ordered by severity), then questions, then brief summary.
|
|
354
|
-
- Suggest next steps when natural; number options for quick replies.
|
|
355
|
-
- Avoid nested bullets and ANSI codes; keep headers short (1-3 words).
|
|
50
|
+
## Output Locations
|
|
356
51
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
52
|
+
| Type | Path |
|
|
53
|
+
|------|------|
|
|
54
|
+
| Bugs | `docs/BUG_#_*.md` |
|
|
55
|
+
| Tests | `tests/test-*.sh` |
|
|
56
|
+
| Features | `docs/FEATURE_*.md` |
|
|
57
|
+
| Temp | `/tmp/` only |
|
|
58
|
+
| Backlog | `.claude/skills/cfn-backlog-management/add-backlog-item.sh` |
|
|
59
|
+
| Changelog | `.claude/skills/cfn-changelog-management/add-changelog-entry.sh` |
|
|
363
60
|
|
|
364
|
-
##
|
|
365
|
-
- MVP: fast prototyping; gate >= 0.70, consensus >= 0.80; up to 5 iterations; 2 validators.
|
|
366
|
-
- Standard: production default; gate >= 0.95, consensus >= 0.90; up to 10 iterations; 3-5 validators.
|
|
367
|
-
- Enterprise: compliance focus; gate >= 0.98, consensus >= 0.95; up to 15 iterations; 5-7 validators.
|
|
368
|
-
- Pick higher modes for security/compliance-sensitive tasks; expect longer runtimes but higher assurance.
|
|
61
|
+
## Key Files
|
|
369
62
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
-
|
|
373
|
-
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
- Include artifact paths in reports; avoid attaching large logs inline.
|
|
377
|
-
- For coverage regressions, note impacted modules and thresholds breached.
|
|
63
|
+
| Purpose | Path |
|
|
64
|
+
|---------|------|
|
|
65
|
+
| Pre-edit hook | `.claude/hooks/cfn-invoke-pre-edit.sh` |
|
|
66
|
+
| Post-edit hook | `.claude/hooks/cfn-invoke-post-edit.sh` |
|
|
67
|
+
| Backup revert | `.claude/skills/pre-edit-backup/revert-file.sh` |
|
|
68
|
+
| RuVector skill | `.claude/skills/cfn-local-ruvector-accelerator/SKILL.md` |
|
|
378
69
|
|
|
379
|
-
##
|
|
380
|
-
- Local pre-commit recommendation: `npm test` then `./tests/cli-mode/run-all-tests.sh` then `./tests/docker-mode/run-all-implementations.sh`.
|
|
381
|
-
- Ensure Docker daemon is available before running Docker-mode suites.
|
|
382
|
-
- CI runs GitHub Actions for tests, coverage gates (>=80% lines/statements/functions), security scanning, and deployment.
|
|
383
|
-
- Before merging, confirm no flaky tests and no unvetted changes to orchestration or spawning scripts.
|
|
384
|
-
- Record any skipped tests with justification and follow-up owner.
|
|
70
|
+
## WSL Memory Monitor
|
|
385
71
|
|
|
386
|
-
|
|
387
|
-
-
|
|
388
|
-
-
|
|
389
|
-
-
|
|
390
|
-
-
|
|
391
|
-
-
|
|
72
|
+
Background process kills test runner memory leaks. Runs on session start.
|
|
73
|
+
- `>10%` memory (node test processes only) → killed
|
|
74
|
+
- Parent with test children totaling `>15%` combined → test children killed
|
|
75
|
+
- Targets: node processes running vitest, jest, mocha, ava, tap, playwright, cypress
|
|
76
|
+
- Never kills: bash, sh, zsh (even if running tests)
|
|
77
|
+
- Status: `~/.local/bin/wsl-memory-monitor.sh --status`
|
|
78
|
+
- Log: `/tmp/wsl-memory-monitor.log`
|
|
392
79
|
|
|
393
|
-
|
|
80
|
+
## Security
|
|
394
81
|
|
|
395
|
-
|
|
82
|
+
- Validate inputs: type, size, permissions
|
|
83
|
+
- Redact: credentials, tokens, PII → `[REDACTED]`
|
|
84
|
+
- Incidents: capture command, commit, env, logs
|
|
85
|
+
- Rollback: use backup scripts, not `git checkout`
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# CFN Loop CLI Mode Reference
|
|
2
|
+
|
|
3
|
+
**Purpose:** Detailed documentation for CLI mode execution of CFN Loops.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
CLI Mode is the production-default execution method for CFN Loops, optimized for cost and provider routing.
|
|
10
|
+
|
|
11
|
+
**Command:** `/cfn-loop-cli "Task description" --mode=standard --provider kimi`
|
|
12
|
+
|
|
13
|
+
**Best for:** Production workflows, provider routing, cost-sensitive work.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Execution Flow
|
|
18
|
+
|
|
19
|
+
### Slash Command Execution Rules
|
|
20
|
+
|
|
21
|
+
1. Expand slash command
|
|
22
|
+
2. Immediately execute coordinator spawn via Bash tool using the exact command
|
|
23
|
+
3. Do not merely show commands; run them
|
|
24
|
+
4. Inform user after spawn with task ID
|
|
25
|
+
|
|
26
|
+
**Anti-patterns:**
|
|
27
|
+
- Pausing to ask what next
|
|
28
|
+
- Manual Task() spawning for CLI workflows
|
|
29
|
+
- Skipping execution
|
|
30
|
+
|
|
31
|
+
### CLI Mode Execution Steps
|
|
32
|
+
|
|
33
|
+
1. **Expand & Validate:** Parse slash command, validate required parameters (mode, optional provider)
|
|
34
|
+
2. **Spawn Coordinator:** Execute orchestration script; confirm task ID
|
|
35
|
+
3. **Loop 3 Implementation:** Agents implement and run tests; orchestration monitors via Redis
|
|
36
|
+
4. **Gate Check:** Compare pass rate to mode threshold; if failing, iterate Loop 3
|
|
37
|
+
5. **Loop 2 Validation:** If gate passes, validators review and score
|
|
38
|
+
6. **Product Owner Decision:** PROCEED/ITERATE/ABORT; orchestrator enforces
|
|
39
|
+
7. **Report & Cleanup:** Final status, code paths, test results; stop agents cleanly
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Provider Routing
|
|
44
|
+
|
|
45
|
+
### Enable Custom Routing
|
|
46
|
+
|
|
47
|
+
Set `CFN_CUSTOM_ROUTING=true` in `.env`.
|
|
48
|
+
|
|
49
|
+
### Provider Options
|
|
50
|
+
|
|
51
|
+
| Provider | Use Case | Notes |
|
|
52
|
+
|----------|----------|-------|
|
|
53
|
+
| `zai` | Cost-sensitive | Default when custom routing enabled |
|
|
54
|
+
| `kimi` | Balanced quality/cost | Good general choice |
|
|
55
|
+
| `openrouter` | Broad access | Multiple models available |
|
|
56
|
+
| `max` / `anthropic` | Premium quality | Highest safety/quality |
|
|
57
|
+
| `gemini` | Google ecosystem | |
|
|
58
|
+
| `xai` | Grok-style responses | |
|
|
59
|
+
|
|
60
|
+
### Provider Selection
|
|
61
|
+
|
|
62
|
+
- **Cost sensitive:** `zai` or low-tier `openrouter`
|
|
63
|
+
- **Balanced:** `kimi`
|
|
64
|
+
- **Quality critical:** `max` or `anthropic`
|
|
65
|
+
- **Google tools:** `gemini`
|
|
66
|
+
- **Mixed providers:** Set per-agent profile; otherwise inherit main chat provider
|
|
67
|
+
|
|
68
|
+
### Example Flow
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
/switch-api kimi
|
|
72
|
+
/cfn-loop-cli "Implement feature" --provider kimi
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Full guide:** `docs/CUSTOM_PROVIDER_ROUTING.md`
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Mode Thresholds
|
|
80
|
+
|
|
81
|
+
### Test Gate Thresholds
|
|
82
|
+
|
|
83
|
+
| Mode | Gate Pass Rate | Consensus | Max Iterations | Validators |
|
|
84
|
+
|------|----------------|-----------|----------------|------------|
|
|
85
|
+
| MVP | >= 0.70 | >= 0.80 | 5 | 2 |
|
|
86
|
+
| Standard | >= 0.95 | >= 0.90 | 10 | 3-5 |
|
|
87
|
+
| Enterprise | >= 0.98 | >= 0.95 | 15 | 5-7 |
|
|
88
|
+
|
|
89
|
+
### Mode Selection
|
|
90
|
+
|
|
91
|
+
- **MVP:** Fast prototyping, demos, non-critical work
|
|
92
|
+
- **Standard:** Production default, most features
|
|
93
|
+
- **Enterprise:** Compliance-sensitive, security-critical work
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Redis Coordination
|
|
98
|
+
|
|
99
|
+
CLI mode uses Redis BLPOP for agent coordination:
|
|
100
|
+
|
|
101
|
+
- Agents signal completion via Redis
|
|
102
|
+
- Orchestrator monitors progress via polling
|
|
103
|
+
- Context validation and metadata tracking
|
|
104
|
+
- Health monitoring for stuck agents
|
|
105
|
+
|
|
106
|
+
**Key patterns:** `.claude/skills/cfn-coordination/SKILL.md`
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Deprecated Patterns
|
|
111
|
+
|
|
112
|
+
- Manual `Task()` spawning for CLI workflows
|
|
113
|
+
- Ad-hoc file coordination (use Redis protocols)
|
|
114
|
+
- Host-side iteration scripts (use self-contained coordinator)
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Quick Reference
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Standard CLI mode execution
|
|
122
|
+
/cfn-loop-cli "Implement feature X" --mode=standard
|
|
123
|
+
|
|
124
|
+
# With provider routing
|
|
125
|
+
/cfn-loop-cli "Fix bug Y" --mode=standard --provider kimi
|
|
126
|
+
|
|
127
|
+
# Enterprise mode for compliance
|
|
128
|
+
/cfn-loop-cli "Security audit" --mode=enterprise --provider anthropic
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**See also:**
|
|
132
|
+
- Root `CLAUDE.md` for Task Mode (debugging/learning)
|
|
133
|
+
- `docs/CFN_LOOP_ARCHITECTURE.md` for architecture details
|
|
134
|
+
- `.claude/agents/custom/cfn-loops-cli-expert.md` for CLI expert agent
|
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-flow-novice",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.24",
|
|
4
4
|
"description": "Claude Flow Novice - Advanced orchestration platform for multi-agent AI workflows with CFN Loop architecture\n\nIncludes Local RuVector Accelerator and all CFN skills for complete functionality.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"cfn-init": "./scripts/cfn-init.js"
|
|
8
|
+
"cfn-init": "./scripts/cfn-init.js",
|
|
9
|
+
"cfn-check-memory": "./.claude/cfn-scripts/check-memory.sh",
|
|
10
|
+
"cfn-run-limited": "./.claude/cfn-scripts/run-with-memory-limit.sh"
|
|
9
11
|
},
|
|
10
12
|
"scripts": {
|
|
11
13
|
"test": "npm run test:unit && npm run test:integration && npm run test:e2e",
|
|
12
|
-
"test:unit": "jest --testPathPattern=tests/unit --coverage --coverageDirectory=coverage/unit",
|
|
13
|
-
"test:integration": "jest --testPathPattern=tests/integration --coverage --coverageDirectory=coverage/integration",
|
|
14
|
-
"test:e2e": "jest --testPathPattern=tests/e2e --coverage --coverageDirectory=coverage/e2e",
|
|
14
|
+
"test:unit": "./.claude/cfn-scripts/run-with-memory-limit.sh 2G jest --testPathPattern=tests/unit --coverage --coverageDirectory=coverage/unit",
|
|
15
|
+
"test:integration": "./.claude/cfn-scripts/run-with-memory-limit.sh 4G jest --testPathPattern=tests/integration --coverage --coverageDirectory=coverage/integration",
|
|
16
|
+
"test:e2e": "./.claude/cfn-scripts/run-with-memory-limit.sh 6G jest --testPathPattern=tests/e2e --coverage --coverageDirectory=coverage/e2e",
|
|
15
17
|
"test:docker": "./tests/docker-mode/run-all-implementations.sh",
|
|
16
18
|
"test:cli": "./tests/cli-mode/run-all-tests.sh",
|
|
17
19
|
"test:cfn-v3": "./tests/cfn-v3/test-e2e-cfn-loop.sh",
|
|
@@ -61,6 +63,8 @@
|
|
|
61
63
|
"ruvector:local:query": "./.claude/skills/cfn-local-ruvector-accelerator/cfn-integration.sh query",
|
|
62
64
|
"ruvector:local:stats": "./.claude/skills/cfn-local-ruvector-accelerator/cfn-integration.sh stats",
|
|
63
65
|
"ruvector:local:build": "cd .claude/skills/cfn-local-ruvector-accelerator && cargo build --release",
|
|
66
|
+
"check:memory": "./.claude/cfn-scripts/check-memory.sh",
|
|
67
|
+
"check:memory:kill": "./.claude/cfn-scripts/check-memory.sh --kill",
|
|
64
68
|
"ci:pre-commit": "npm run lint && npm run test:unit && npm run security:audit",
|
|
65
69
|
"ci:full": "npm run test && npm run lint:fix && npm run security:audit && npm run performance:benchmark",
|
|
66
70
|
"dev:watch": "concurrently \"npm run build:watch\" \"nodemon dist/index.js\"",
|