@claude-flow/cli 3.6.9 → 3.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,545 +1,363 @@
1
1
  /**
2
2
  * CLAUDE.md Generator
3
- * Generates enforceable, analyzer-optimized Claude Code configuration
4
- * with template variants for different usage patterns.
3
+ * Generates lean, enforceable Claude Code configuration optimized for token efficiency.
5
4
  *
6
5
  * Templates: minimal | standard | full | security | performance | solo
7
- * All templates use bullet-format rules with imperative keywords for enforceability.
6
+ * All templates use imperative rules and agent comms-first coordination.
8
7
  */
9
- // --- Section Generators (each returns enforceable markdown) ---
8
+ // --- Section Generators ---
10
9
  function behavioralRules() {
11
- return `## Behavioral Rules (Always Enforced)
10
+ return `## Rules
12
11
 
13
12
  - Do what has been asked; nothing more, nothing less
14
- - NEVER create files unless they're absolutely necessary for achieving your goal
15
- - ALWAYS prefer editing an existing file to creating a new one
16
- - NEVER proactively create documentation files (*.md) or README files unless explicitly requested
17
- - NEVER save working files, text/mds, or tests to the root folder
18
- - Never continuously check status after spawning a swarm — wait for results
13
+ - NEVER create files unless absolutely necessary prefer editing existing files
14
+ - NEVER create documentation files unless explicitly requested
15
+ - NEVER save working files or tests to root use \`/src\`, \`/tests\`, \`/docs\`, \`/config\`, \`/scripts\`
19
16
  - ALWAYS read a file before editing it
20
- - NEVER commit secrets, credentials, or .env files`;
21
- }
22
- function fileOrganization() {
23
- return `## File Organization
24
-
25
- - NEVER save to root folder — use the directories below
26
- - Use \`/src\` for source code files
27
- - Use \`/tests\` for test files
28
- - Use \`/docs\` for documentation and markdown files
29
- - Use \`/config\` for configuration files
30
- - Use \`/scripts\` for utility scripts
31
- - Use \`/examples\` for example code`;
17
+ - NEVER commit secrets, credentials, or .env files
18
+ - Keep files under 500 lines
19
+ - Validate input at system boundaries`;
32
20
  }
33
- function projectArchitecture(options) {
34
- return `## Project Architecture
21
+ function agentComms() {
22
+ return `## Agent Comms (SendMessage-First Coordination)
35
23
 
36
- - Follow Domain-Driven Design with bounded contexts
37
- - Keep files under 500 lines
38
- - Use typed interfaces for all public APIs
39
- - Prefer TDD London School (mock-first) for new code
40
- - Use event sourcing for state changes
41
- - Ensure input validation at system boundaries
24
+ Named agents coordinate via \`SendMessage\`, not polling or shared state.
42
25
 
43
- ### Project Config
26
+ \`\`\`
27
+ Lead (you) ←→ architect ←→ developer ←→ tester ←→ reviewer
28
+ (named agents message each other directly)
29
+ \`\`\`
44
30
 
45
- - **Topology**: ${options.runtime.topology}
46
- - **Max Agents**: ${options.runtime.maxAgents}
47
- - **Memory**: ${options.runtime.memoryBackend}
48
- - **HNSW**: ${options.runtime.enableHNSW ? 'Enabled' : 'Disabled'}
49
- - **Neural**: ${options.runtime.enableNeural ? 'Enabled' : 'Disabled'}`;
50
- }
51
- function concurrencyRules() {
52
- return `## Concurrency: 1 MESSAGE = ALL RELATED OPERATIONS
53
-
54
- - All operations MUST be concurrent/parallel in a single message
55
- - Use Claude Code's Agent tool for spawning agents, not just MCP
56
- - ALWAYS spawn ALL agents in ONE message with full instructions via Agent tool
57
- - ALWAYS batch ALL file reads/writes/edits in ONE message
58
- - ALWAYS batch ALL Bash commands in ONE message`;
59
- }
60
- function swarmOrchestration() {
61
- return `## Swarm Orchestration
31
+ ### Spawning a Coordinated Team
62
32
 
63
- - MUST initialize the swarm using CLI tools when starting complex tasks
64
- - MUST spawn concurrent agents using Claude Code's Agent tool
65
- - Never use CLI tools alone for execution — Agent tool agents do the actual work
66
- - MUST call CLI tools AND Agent tool in ONE message for complex work
33
+ \`\`\`javascript
34
+ // ALL agents in ONE message, each knows WHO to message next
35
+ Agent({ prompt: "Research the codebase. SendMessage findings to 'architect'.",
36
+ subagent_type: "researcher", name: "researcher", run_in_background: true })
37
+ Agent({ prompt: "Wait for 'researcher'. Design solution. SendMessage to 'coder'.",
38
+ subagent_type: "system-architect", name: "architect", run_in_background: true })
39
+ Agent({ prompt: "Wait for 'architect'. Implement it. SendMessage to 'tester'.",
40
+ subagent_type: "coder", name: "coder", run_in_background: true })
41
+ Agent({ prompt: "Wait for 'coder'. Write tests. SendMessage results to 'reviewer'.",
42
+ subagent_type: "tester", name: "tester", run_in_background: true })
43
+ Agent({ prompt: "Wait for 'tester'. Review code quality and security.",
44
+ subagent_type: "reviewer", name: "reviewer", run_in_background: true })
45
+
46
+ // Kick off the pipeline
47
+ SendMessage({ to: "researcher", summary: "Start", message: "[task context]" })
48
+ \`\`\`
49
+
50
+ ### Patterns
67
51
 
68
- ### 3-Tier Model Routing (ADR-026)
52
+ | Pattern | Flow | Use When |
53
+ |---------|------|----------|
54
+ | **Pipeline** | A → B → C → D | Sequential dependencies (feature dev) |
55
+ | **Fan-out** | Lead → A, B, C → Lead | Independent parallel work (research) |
56
+ | **Supervisor** | Lead ↔ workers | Ongoing coordination (complex refactor) |
69
57
 
70
- | Tier | Handler | Latency | Cost | Use Cases |
71
- |------|---------|---------|------|-----------|
72
- | **1** | Agent Booster (WASM) | <1ms | $0 | Simple transforms (var→const, add types) — Skip LLM |
73
- | **2** | Haiku | ~500ms | $0.0002 | Simple tasks, low complexity (<30%) |
74
- | **3** | Sonnet/Opus | 2-5s | $0.003-0.015 | Complex reasoning, architecture, security (>30%) |
58
+ ### Rules
75
59
 
76
- - For Tier 1 simple transforms, use Edit tool directly — no LLM agent needed`;
60
+ - ALWAYS name agents \`name: "role"\` makes them addressable
61
+ - ALWAYS include comms instructions in prompts — who to message, what to send
62
+ - Spawn ALL agents in ONE message with \`run_in_background: true\`
63
+ - After spawning: STOP, tell user what's running, wait for results
64
+ - NEVER poll status — agents message back or complete automatically`;
77
65
  }
78
- function antiDriftConfig() {
79
- return `## Swarm Configuration & Anti-Drift
66
+ function swarmConfig(options) {
67
+ return `## Swarm & Routing
80
68
 
81
- - ALWAYS use hierarchical topology for coding swarms
82
- - Keep maxAgents at 6-8 for tight coordination
83
- - Use specialized strategy for clear role boundaries
84
- - Use \`raft\` consensus for hive-mind (leader maintains authoritative state)
85
- - Run frequent checkpoints via \`post-task\` hooks
86
- - Keep shared memory namespace for all agents
69
+ ### Config
70
+ - **Topology**: ${options.runtime.topology} (anti-drift)
71
+ - **Max Agents**: ${options.runtime.maxAgents}
72
+ - **Memory**: ${options.runtime.memoryBackend}
73
+ - **HNSW**: ${options.runtime.enableHNSW ? 'Enabled' : 'Disabled'}
74
+ - **Neural**: ${options.runtime.enableNeural ? 'Enabled' : 'Disabled'}
87
75
 
88
76
  \`\`\`bash
89
77
  npx @claude-flow/cli@latest swarm init --topology hierarchical --max-agents 8 --strategy specialized
90
- \`\`\``;
91
- }
92
- function autoStartProtocol() {
93
- return `## Swarm Protocols & Routing
94
-
95
- ### Auto-Start Swarm Protocol
96
-
97
- When the user requests a complex task, spawn agents in background and WAIT:
98
-
99
- \`\`\`javascript
100
- // STEP 1: Initialize swarm coordination
101
- Bash("npx @claude-flow/cli@latest swarm init --topology hierarchical --max-agents 8 --strategy specialized")
102
-
103
- // STEP 2: Spawn ALL agents IN BACKGROUND in a SINGLE message
104
- Agent("Research requirements", "Analyze codebase patterns and store findings in memory", {subagent_type: "researcher", run_in_background: true})
105
- Agent("Design architecture", "Design architecture based on research", {subagent_type: "system-architect", run_in_background: true})
106
- Agent("Implement solution", "Implement the solution following the design", {subagent_type: "coder", run_in_background: true})
107
- Agent("Write tests", "Write comprehensive tests for the implementation", {subagent_type: "tester", run_in_background: true})
108
- Agent("Review code quality", "Review code quality, security, and best practices", {subagent_type: "reviewer", run_in_background: true})
109
78
  \`\`\`
110
79
 
111
80
  ### Agent Routing
112
81
 
113
- | Code | Task | Agents |
114
- |------|------|--------|
115
- | 1 | Bug Fix | coordinator, researcher, coder, tester |
116
- | 3 | Feature | coordinator, architect, coder, tester, reviewer |
117
- | 5 | Refactor | coordinator, architect, coder, reviewer |
118
- | 7 | Performance | coordinator, perf-engineer, coder |
119
- | 9 | Security | coordinator, security-architect, auditor |
120
-
121
- ### Task Complexity Detection
122
-
123
- - AUTO-INVOKE SWARM when task involves: 3+ files, new features, cross-module refactoring, API changes, security, or performance work
124
- - SKIP SWARM for: single file edits, simple bug fixes (1-2 lines), documentation updates, configuration changes`;
125
- }
126
- function executionRules() {
127
- return `## Swarm Execution Rules
128
-
129
- - ALWAYS use \`run_in_background: true\` for all Agent tool calls
130
- - ALWAYS put ALL Agent calls in ONE message for parallel execution
131
- - After spawning, STOP do NOT add more tool calls or check status
132
- - Never poll agent status repeatedly — trust agents to return
133
- - When agent results arrive, review ALL results before proceeding`;
82
+ | Task | Agents | Topology |
83
+ |------|--------|----------|
84
+ | Bug Fix | researcher, coder, tester | hierarchical |
85
+ | Feature | architect, coder, tester, reviewer | hierarchical |
86
+ | Refactor | architect, coder, reviewer | hierarchical |
87
+ | Performance | perf-engineer, coder | hierarchical |
88
+ | Security | security-architect, auditor | hierarchical |
89
+
90
+ ### When to Swarm
91
+ - **YES**: 3+ files, new features, cross-module refactoring, API changes, security, performance
92
+ - **NO**: single file edits, 1-2 line fixes, docs updates, config changes, questions
93
+
94
+ ### 3-Tier Model Routing
95
+
96
+ | Tier | Handler | Use Cases |
97
+ |------|---------|-----------|
98
+ | 1 | Agent Booster (WASM) | Simple transforms — skip LLM, use Edit directly |
99
+ | 2 | Haiku | Simple tasks, low complexity |
100
+ | 3 | Sonnet/Opus | Architecture, security, complex reasoning |`;
134
101
  }
135
- function cliCommandsTable() {
136
- return `## V3 CLI Commands
137
-
138
- ### Core Commands
139
-
140
- | Command | Subcommands | Description |
141
- |---------|-------------|-------------|
142
- | \`init\` | 4 | Project initialization |
143
- | \`agent\` | 8 | Agent lifecycle management |
144
- | \`swarm\` | 6 | Multi-agent swarm coordination |
145
- | \`memory\` | 11 | AgentDB memory with HNSW search |
146
- | \`task\` | 6 | Task creation and lifecycle |
147
- | \`session\` | 7 | Session state management |
148
- | \`hooks\` | 17 | Self-learning hooks + 12 workers |
149
- | \`hive-mind\` | 6 | Byzantine fault-tolerant consensus |
150
-
151
- ### Quick CLI Examples
102
+ function memoryAndLearning() {
103
+ return `## Memory & Learning
152
104
 
105
+ ### Before Any Task
153
106
  \`\`\`bash
154
- npx @claude-flow/cli@latest init --wizard
155
- npx @claude-flow/cli@latest agent spawn -t coder --name my-coder
156
- npx @claude-flow/cli@latest swarm init --v3-mode
157
- npx @claude-flow/cli@latest memory search --query "authentication patterns"
158
- npx @claude-flow/cli@latest doctor --fix
159
- \`\`\``;
160
- }
161
- function agentTypes() {
162
- return `## Available Agents (16 Roles + Custom)
107
+ npx @claude-flow/cli@latest memory search --query "[task keywords]" --namespace patterns
108
+ npx @claude-flow/cli@latest hooks route --task "[task description]"
109
+ \`\`\`
163
110
 
164
- ### Core Development
165
- \`coder\`, \`reviewer\`, \`tester\`, \`planner\`, \`researcher\`
111
+ ### After Success
112
+ \`\`\`bash
113
+ npx @claude-flow/cli@latest memory store --namespace patterns --key "[name]" --value "[what worked]"
114
+ npx @claude-flow/cli@latest hooks post-task --task-id "[id]" --success true --store-results true
115
+ \`\`\`
166
116
 
167
- ### Specialized
168
- \`security-architect\`, \`security-auditor\`, \`memory-specialist\`, \`performance-engineer\`
117
+ ### MCP Tools (use \`ToolSearch("keyword")\` to discover)
169
118
 
170
- ### Coordination
171
- \`hierarchical-coordinator\`, \`mesh-coordinator\`, \`adaptive-coordinator\`
119
+ | Category | Key Tools |
120
+ |----------|-----------|
121
+ | **Memory** | \`memory_store\`, \`memory_search\`, \`memory_search_unified\` |
122
+ | **Bridge** | \`memory_import_claude\`, \`memory_bridge_status\` |
123
+ | **Swarm** | \`swarm_init\`, \`swarm_status\`, \`swarm_health\` |
124
+ | **Agents** | \`agent_spawn\`, \`agent_list\`, \`agent_status\` |
125
+ | **Hooks** | \`hooks_route\`, \`hooks_post-task\`, \`hooks_worker-dispatch\` |
126
+ | **Security** | \`aidefence_scan\`, \`aidefence_is_safe\`, \`aidefence_has_pii\` |
127
+ | **Hive-Mind** | \`hive-mind_init\`, \`hive-mind_consensus\`, \`hive-mind_spawn\` |
172
128
 
173
- ### GitHub & Repository
174
- \`pr-manager\`, \`code-review-swarm\`, \`issue-tracker\`, \`release-manager\`
129
+ ### Background Workers
175
130
 
176
- Any string can be used as a custom agent type — these are the typed roles with specialized behavior.`;
177
- }
178
- function hooksSystem() {
179
- return `## Hooks System (27 Hooks + 12 Workers)
180
-
181
- ### Essential Hooks
182
-
183
- | Hook | Description |
184
- |------|-------------|
185
- | \`pre-task\` / \`post-task\` | Task lifecycle with learning |
186
- | \`pre-edit\` / \`post-edit\` | File editing with neural training |
187
- | \`session-start\` / \`session-end\` | Session state persistence |
188
- | \`route\` | Route task to optimal agent |
189
- | \`intelligence\` | RuVector intelligence system |
190
- | \`worker\` | Background worker management |
191
-
192
- ### 12 Background Workers
193
-
194
- | Worker | Priority | Description |
195
- |--------|----------|-------------|
196
- | \`optimize\` | high | Performance optimization |
197
- | \`audit\` | critical | Security analysis |
198
- | \`testgaps\` | normal | Test coverage analysis |
199
- | \`map\` | normal | Codebase mapping |
200
- | \`deepdive\` | normal | Deep code analysis |
201
- | \`document\` | normal | Auto-documentation |
131
+ | Worker | When |
132
+ |--------|------|
133
+ | \`audit\` | After security changes |
134
+ | \`optimize\` | After performance work |
135
+ | \`testgaps\` | After adding features |
136
+ | \`map\` | Every 5+ file changes |
137
+ | \`document\` | After API changes |
202
138
 
203
139
  \`\`\`bash
204
- npx @claude-flow/cli@latest hooks pre-task --description "[task]"
205
- npx @claude-flow/cli@latest hooks post-task --task-id "[id]" --success true
206
140
  npx @claude-flow/cli@latest hooks worker dispatch --trigger audit
207
141
  \`\`\``;
208
142
  }
209
- function learningProtocol() {
210
- return `## Auto-Learning Protocol
143
+ function agentTypes() {
144
+ return `## Agents
211
145
 
212
- ### Before Starting Any Task
213
- \`\`\`bash
214
- npx @claude-flow/cli@latest memory search --query "[task keywords]" --namespace patterns
215
- npx @claude-flow/cli@latest hooks route --task "[task description]"
216
- \`\`\`
146
+ **Core**: \`coder\`, \`reviewer\`, \`tester\`, \`planner\`, \`researcher\`
147
+ **Architecture**: \`system-architect\`, \`backend-dev\`, \`mobile-dev\`
148
+ **Security**: \`security-architect\`, \`security-auditor\`
149
+ **Performance**: \`performance-engineer\`, \`perf-analyzer\`
150
+ **Coordination**: \`hierarchical-coordinator\`, \`mesh-coordinator\`, \`adaptive-coordinator\`
151
+ **GitHub**: \`pr-manager\`, \`code-review-swarm\`, \`issue-tracker\`, \`release-manager\`
152
+
153
+ Any string works as a custom agent type.`;
154
+ }
155
+ function cliQuickRef() {
156
+ return `## CLI Quick Reference
217
157
 
218
- ### After Completing Any Task Successfully
219
158
  \`\`\`bash
220
- npx @claude-flow/cli@latest memory store --namespace patterns --key "[pattern-name]" --value "[what worked]"
221
- npx @claude-flow/cli@latest hooks post-task --task-id "[id]" --success true --store-results true
159
+ npx @claude-flow/cli@latest init --wizard # Setup
160
+ npx @claude-flow/cli@latest swarm init --v3-mode # Start swarm
161
+ npx @claude-flow/cli@latest memory search --query "" # Vector search
162
+ npx @claude-flow/cli@latest hooks route --task "" # Route to agent
163
+ npx @claude-flow/cli@latest doctor --fix # Diagnostics
164
+ npx @claude-flow/cli@latest security scan # Security scan
165
+ npx @claude-flow/cli@latest performance benchmark # Benchmarks
222
166
  \`\`\`
223
167
 
224
- - ALWAYS check memory before starting new features, debugging, or refactoring
225
- - ALWAYS store patterns in memory after solving bugs, completing features, or finding optimizations`;
168
+ 26 commands, 140+ subcommands. Use \`--help\` on any command for details.`;
226
169
  }
227
- function memoryCommands() {
228
- return `## Memory & Vector Search
229
-
230
- ### MCP Tools (use via ToolSearch to discover)
231
-
232
- | Tool | Description |
233
- |------|-------------|
234
- | \`memory_store\` | Store value with ONNX 384-dim vector embedding |
235
- | \`memory_search\` | Semantic vector search by query |
236
- | \`memory_retrieve\` | Get entry by key |
237
- | \`memory_list\` | List entries in namespace |
238
- | \`memory_delete\` | Delete entry |
239
- | \`memory_import_claude\` | Import Claude Code memories into AgentDB (allProjects=true for all) |
240
- | \`memory_search_unified\` | Search across ALL namespaces (Claude + AgentDB + patterns) |
241
- | \`memory_bridge_status\` | Show bridge health, vectors, SONA, intelligence |
242
-
243
- ### CLI Commands
170
+ function setupAndBoundary() {
171
+ return `## Setup
244
172
 
245
173
  \`\`\`bash
246
- # Store with vector embedding
247
- npx @claude-flow/cli@latest memory store --key "pattern-auth" --value "JWT with refresh" --namespace patterns
248
-
249
- # Semantic search
250
- npx @claude-flow/cli@latest memory search --query "authentication patterns"
251
-
252
- # Import all Claude Code memories into AgentDB
253
- node .claude/helpers/auto-memory-hook.mjs import-all
174
+ claude mcp add claude-flow -- npx -y @claude-flow/cli@latest
175
+ npx @claude-flow/cli@latest daemon start
176
+ npx @claude-flow/cli@latest doctor --fix
254
177
  \`\`\`
255
178
 
256
- ### Claude Code AgentDB Bridge
257
-
258
- Claude Code auto-memory files (\`~/.claude/projects/*/memory/*.md\`) are automatically imported into AgentDB with ONNX vector embeddings on session start. Use \`memory_search_unified\` to search across both stores.`;
259
- }
260
- function securityRulesLight() {
261
- return `## Security Rules
262
-
263
- - NEVER hardcode API keys, secrets, or credentials in source files
264
- - NEVER commit .env files or any file containing secrets
265
- - Always validate user input at system boundaries
266
- - Always sanitize file paths to prevent directory traversal
267
- - Run \`npx @claude-flow/cli@latest security scan\` after security-related changes`;
179
+ **Agent tool** handles execution (agents, files, code, git). **MCP tools** handle coordination (swarm, memory, hooks). **CLI** is the same via Bash.`;
268
180
  }
269
181
  function buildAndTest() {
270
182
  return `## Build & Test
271
183
 
272
- \`\`\`bash
273
- # Build
274
- npm run build
275
-
276
- # Test
277
- npm test
184
+ - ALWAYS run tests after code changes
185
+ - ALWAYS verify build succeeds before committing
278
186
 
279
- # Lint
280
- npm run lint
281
- \`\`\`
282
-
283
- - ALWAYS run tests after making code changes
284
- - ALWAYS verify build succeeds before committing`;
187
+ \`\`\`bash
188
+ npm run build && npm test
189
+ \`\`\``;
285
190
  }
286
191
  function securitySection() {
287
- return `## Security Protocol
192
+ return `## Security
288
193
 
289
- - NEVER hardcode API keys, secrets, or credentials in source files
290
- - NEVER commit .env files or any file containing secrets
291
- - Always validate all user input at system boundaries using Zod schemas
292
- - Always sanitize file paths to prevent directory traversal attacks
293
- - Always use parameterized queries — never concatenate SQL strings
294
- - Run security audit after any authentication or authorization changes
194
+ - NEVER hardcode secrets in source use environment variables
195
+ - Always validate input at boundaries (Zod schemas)
196
+ - Always sanitize file paths (prevent traversal)
197
+ - Always use parameterized queries (prevent injection)
295
198
 
296
- ### Security Scanning
297
199
  \`\`\`bash
298
200
  npx @claude-flow/cli@latest security scan --depth full
299
201
  npx @claude-flow/cli@latest security audit --report
300
- npx @claude-flow/cli@latest security cve --check
301
202
  \`\`\`
302
203
 
303
- ### Security Agents
304
- - \`security-architect\` — threat modeling, architecture review
305
- - \`security-auditor\` — code audit, vulnerability detection
306
- - Use agent routing code 9 (hierarchical/specialized) for security tasks`;
204
+ Agents: \`security-architect\` (threat modeling), \`security-auditor\` (vulnerability detection)`;
307
205
  }
308
206
  function performanceSection() {
309
- return `## Performance Optimization Protocol
207
+ return `## Performance
310
208
 
311
- - Always run benchmarks before and after performance changes
312
- - Always profile before optimizing — never guess at bottlenecks
313
- - Prefer algorithmic improvements over micro-optimizations
314
- - Use DiskANN or HNSW for vector search (auto-selected by dataset size)
315
- - Use Int8 quantization for ~4x memory reduction when needed
209
+ - Always benchmark before AND after optimization
210
+ - Always profile before optimizing — never guess bottlenecks
211
+ - Use HNSW/DiskANN for vector search, Int8 quantization for memory reduction
316
212
 
317
- ### Performance Tooling
318
213
  \`\`\`bash
319
214
  npx @claude-flow/cli@latest performance benchmark --suite all
320
215
  npx @claude-flow/cli@latest performance profile --target "[component]"
321
- npx @claude-flow/cli@latest performance metrics --format table
322
216
  \`\`\`
323
217
 
324
- ### Performance Agents
325
- - \`performance-engineer\` — profiling, benchmarking, optimization
326
- - \`perf-analyzer\` — bottleneck detection, analysis
327
- - Use agent routing code 7 (hierarchical/specialized) for performance tasks`;
218
+ Agents: \`performance-engineer\` (profiling), \`perf-analyzer\` (bottleneck detection)`;
328
219
  }
329
- function intelligenceSystem() {
330
- return `## Intelligence System
331
-
332
- - **SONA**: Self-Optimizing Pattern Learning (sub-millisecond pattern matching)
333
- - **HNSW/DiskANN**: HNSW-indexed vector search with DiskANN SSD-friendly fallback
334
- - **ONNX Embeddings**: all-MiniLM-L6-v2, 384 dimensions, real neural vectors
335
- - **ReasoningBank**: Pattern storage with file persistence
336
-
337
- The learning pipeline:
338
- 1. **RETRIEVE** Fetch relevant patterns via HNSW/DiskANN vector search
339
- 2. **JUDGE** Evaluate with verdicts (success/failure) from post-task hooks
340
- 3. **DISTILL** — Extract key learnings, store as patterns with embeddings
341
- 4. **CONSOLIDATE** — Persist patterns to disk across sessions`;
342
- }
343
- function envVars() {
344
- return `## Environment Variables
220
+ function hooksRef() {
221
+ return `## Hooks
222
+
223
+ | Hook | Purpose |
224
+ |------|---------|
225
+ | \`pre-task\` / \`post-task\` | Task lifecycle + learning |
226
+ | \`pre-edit\` / \`post-edit\` | File editing + neural training |
227
+ | \`session-start\` / \`session-end\` | Session persistence |
228
+ | \`route\` | Route to optimal agent |
229
+ | \`intelligence\` | Pattern learning (SONA) |
230
+ | \`worker\` | Background worker dispatch |
345
231
 
346
232
  \`\`\`bash
347
- CLAUDE_FLOW_CONFIG=./claude-flow.config.json
348
- CLAUDE_FLOW_LOG_LEVEL=info
349
- ANTHROPIC_API_KEY=sk-ant-...
350
- CLAUDE_FLOW_MEMORY_BACKEND=hybrid
351
- CLAUDE_FLOW_MEMORY_PATH=./data/memory
233
+ npx @claude-flow/cli@latest hooks pre-task --description "[task]"
234
+ npx @claude-flow/cli@latest hooks post-task --task-id "[id]" --success true
235
+ npx @claude-flow/cli@latest hooks session-start --session-id "[id]"
236
+ npx @claude-flow/cli@latest hooks route --task "[task]"
237
+ npx @claude-flow/cli@latest hooks worker dispatch --trigger audit
352
238
  \`\`\``;
353
239
  }
354
- function mcpToolDiscovery() {
355
- return `## Key MCP Tools (314 available — use ToolSearch to discover)
356
-
357
- ### Most Used Tools
358
-
359
- | Category | Tools | What They Do |
360
- |----------|-------|-------------|
361
- | **Memory** | \`memory_store\`, \`memory_search\`, \`memory_search_unified\` | Store/search with ONNX vector embeddings |
362
- | **Claude Bridge** | \`memory_import_claude\`, \`memory_bridge_status\` | Import Claude memories into AgentDB |
363
- | **Swarm** | \`swarm_init\`, \`swarm_status\`, \`swarm_health\` | Multi-agent coordination |
364
- | **Agents** | \`agent_spawn\`, \`agent_list\`, \`agent_status\` | Agent lifecycle |
365
- | **Hive-Mind** | \`hive-mind_init\`, \`hive-mind_spawn\`, \`hive-mind_consensus\` | Byzantine/Raft consensus |
366
- | **Hooks** | \`hooks_route\`, \`hooks_session-start\`, \`hooks_post-task\` | Task routing + learning |
367
- | **Workers** | \`hooks_worker-list\`, \`hooks_worker-dispatch\` | 12 background workers |
368
- | **Security** | \`aidefence_scan\`, \`aidefence_is_safe\` | Prompt injection detection |
369
- | **Intelligence** | \`hooks_intelligence\`, \`neural_status\` | Pattern learning + SONA |
370
-
371
- ### Swarm Capabilities
372
-
373
- - **Topologies**: hierarchical (anti-drift), mesh, ring, star, adaptive
374
- - **Consensus**: Raft (leader-based), Byzantine (PBFT), Gossip (eventual)
375
- - **Hive-Mind**: Queen-led coordination with spawn, broadcast, consensus voting, shared memory
376
- - **12 Background Workers**: audit, optimize, testgaps, map, deepdive, document, refactor, benchmark, ultralearn, consolidate, predict, preload
377
-
378
- ### Memory Capabilities
379
-
380
- - **ONNX Embeddings**: all-MiniLM-L6-v2, 384 dimensions — real neural vectors
381
- - **DiskANN**: SSD-friendly vector search (8,000x faster insert than HNSW, perfect recall at 1K)
382
- - **sql.js**: Cross-platform SQLite (WASM, no native compilation)
383
- - **Claude Code Bridge**: Auto-imports MEMORY.md files into AgentDB on session start
384
- - **Unified Search**: \`memory_search_unified\` searches Claude memories + AgentDB + patterns
385
- - **SONA Learning**: Trajectory recording → pattern extraction → file persistence
386
-
387
- ### How to Discover Tools
388
-
389
- Use ToolSearch to find specific tools:
390
- \`\`\`
391
- ToolSearch("memory search") → memory_store, memory_search, memory_search_unified
392
- ToolSearch("swarm") → swarm_init, swarm_status, swarm_health, swarm_shutdown
393
- ToolSearch("hive consensus") → hive-mind_consensus, hive-mind_status
394
- ToolSearch("+aidefence") → aidefence_scan, aidefence_is_safe, aidefence_has_pii
395
- \`\`\``;
240
+ function intelligenceSystem() {
241
+ return `## Intelligence (SONA + HNSW)
242
+
243
+ Pipeline: **RETRIEVE** (vector search) → **JUDGE** (success/failure) → **DISTILL** (extract patterns) → **CONSOLIDATE** (persist)
244
+
245
+ - **ONNX Embeddings**: all-MiniLM-L6-v2, 384-dim
246
+ - **HNSW/DiskANN**: 150x-12,500x faster search
247
+ - **SONA**: Sub-millisecond pattern adaptation
248
+ - **Claude Bridge**: Auto-imports \`~/.claude/projects/*/memory/*.md\` into AgentDB`;
396
249
  }
397
- function setupAndBoundary() {
398
- return `## Quick Setup
250
+ function federationRef() {
251
+ return `## Federation
252
+
253
+ Cross-installation agent collaboration with zero-trust security.
399
254
 
400
255
  \`\`\`bash
401
- claude mcp add claude-flow -- npx -y @claude-flow/cli@latest
402
- npx @claude-flow/cli@latest daemon start
403
- npx @claude-flow/cli@latest doctor --fix
256
+ npx @claude-flow/cli@latest federation init
257
+ npx @claude-flow/cli@latest federation join wss://peer:8443
258
+ npx @claude-flow/cli@latest federation send --to peer --type task-request --message "..."
259
+ npx @claude-flow/cli@latest federation status
404
260
  \`\`\`
405
261
 
406
- ## Claude Code vs MCP Tools
407
-
408
- - **Claude Code Agent tool** handles execution: agents, file ops, code generation, git
409
- - **MCP tools** (via ToolSearch) handle coordination: swarm, memory, hooks, routing, hive-mind
410
- - **CLI commands** (via Bash) are the same tools with terminal output
411
- - Use \`ToolSearch("keyword")\` to discover available MCP tools
412
-
413
- ## Support
262
+ - 5-tier trust: UNTRUSTED VERIFIED → ATTESTED → TRUSTED → PRIVILEGED
263
+ - PII pipeline: 14 types auto-stripped before data leaves your node
264
+ - mTLS + ed25519 handshake, HMAC-signed envelopes
265
+ - Compliance: HIPAA, SOC2, GDPR audit modes`;
266
+ }
267
+ function envVars() {
268
+ return `## Environment
414
269
 
415
- - Documentation: https://github.com/ruvnet/ruflo
416
- - Issues: https://github.com/ruvnet/ruflo/issues`;
270
+ \`\`\`bash
271
+ CLAUDE_FLOW_CONFIG=./claude-flow.config.json
272
+ CLAUDE_FLOW_LOG_LEVEL=info
273
+ CLAUDE_FLOW_MEMORY_BACKEND=hybrid
274
+ CLAUDE_FLOW_MEMORY_PATH=./data/memory
275
+ \`\`\``;
417
276
  }
418
277
  // --- Template Composers ---
419
- /**
420
- * Template section map — defines which sections are included per template.
421
- */
422
278
  const TEMPLATE_SECTIONS = {
423
279
  minimal: [
424
280
  behavioralRules,
425
- fileOrganization,
426
- projectArchitecture,
281
+ (_opts) => agentComms(),
282
+ swarmConfig,
427
283
  (_opts) => buildAndTest(),
428
- (_opts) => securityRulesLight(),
429
- concurrencyRules,
430
- (_opts) => antiDriftConfig(),
431
- executionRules,
432
- (_opts) => cliCommandsTable(),
284
+ (_opts) => cliQuickRef(),
433
285
  (_opts) => setupAndBoundary(),
434
286
  ],
435
287
  standard: [
436
288
  behavioralRules,
437
- fileOrganization,
438
- projectArchitecture,
439
- (_opts) => buildAndTest(),
440
- (_opts) => securityRulesLight(),
441
- concurrencyRules,
442
- (_opts) => swarmOrchestration(),
443
- (_opts) => antiDriftConfig(),
444
- executionRules,
445
- (_opts) => cliCommandsTable(),
289
+ (_opts) => agentComms(),
290
+ swarmConfig,
291
+ (_opts) => memoryAndLearning(),
446
292
  (_opts) => agentTypes(),
447
- (_opts) => memoryCommands(),
448
- (_opts) => mcpToolDiscovery(),
293
+ (_opts) => buildAndTest(),
294
+ (_opts) => cliQuickRef(),
449
295
  (_opts) => setupAndBoundary(),
450
296
  ],
451
297
  full: [
452
298
  behavioralRules,
453
- fileOrganization,
454
- projectArchitecture,
455
- (_opts) => buildAndTest(),
456
- (_opts) => securityRulesLight(),
457
- concurrencyRules,
458
- (_opts) => swarmOrchestration(),
459
- (_opts) => antiDriftConfig(),
460
- (_opts) => autoStartProtocol(),
461
- executionRules,
462
- (_opts) => cliCommandsTable(),
299
+ (_opts) => agentComms(),
300
+ swarmConfig,
301
+ (_opts) => memoryAndLearning(),
463
302
  (_opts) => agentTypes(),
464
- (_opts) => hooksSystem(),
465
- (_opts) => learningProtocol(),
466
- (_opts) => memoryCommands(),
467
- (_opts) => mcpToolDiscovery(),
303
+ (_opts) => hooksRef(),
468
304
  (_opts) => intelligenceSystem(),
305
+ (_opts) => federationRef(),
306
+ (_opts) => buildAndTest(),
469
307
  (_opts) => envVars(),
308
+ (_opts) => cliQuickRef(),
470
309
  (_opts) => setupAndBoundary(),
471
310
  ],
472
311
  security: [
473
312
  behavioralRules,
474
- fileOrganization,
475
- projectArchitecture,
476
- (_opts) => buildAndTest(),
477
- concurrencyRules,
478
- (_opts) => swarmOrchestration(),
479
- (_opts) => antiDriftConfig(),
480
- executionRules,
313
+ (_opts) => agentComms(),
314
+ swarmConfig,
481
315
  (_opts) => securitySection(),
482
- (_opts) => cliCommandsTable(),
316
+ (_opts) => memoryAndLearning(),
483
317
  (_opts) => agentTypes(),
484
- (_opts) => memoryCommands(),
318
+ (_opts) => buildAndTest(),
319
+ (_opts) => cliQuickRef(),
485
320
  (_opts) => setupAndBoundary(),
486
321
  ],
487
322
  performance: [
488
323
  behavioralRules,
489
- fileOrganization,
490
- projectArchitecture,
491
- (_opts) => buildAndTest(),
492
- (_opts) => securityRulesLight(),
493
- concurrencyRules,
494
- (_opts) => swarmOrchestration(),
495
- (_opts) => antiDriftConfig(),
496
- executionRules,
324
+ (_opts) => agentComms(),
325
+ swarmConfig,
497
326
  (_opts) => performanceSection(),
498
- (_opts) => cliCommandsTable(),
327
+ (_opts) => memoryAndLearning(),
499
328
  (_opts) => agentTypes(),
500
- (_opts) => memoryCommands(),
501
329
  (_opts) => intelligenceSystem(),
330
+ (_opts) => buildAndTest(),
331
+ (_opts) => cliQuickRef(),
502
332
  (_opts) => setupAndBoundary(),
503
333
  ],
504
334
  solo: [
505
335
  behavioralRules,
506
- fileOrganization,
507
- projectArchitecture,
336
+ (_opts) => agentComms(),
337
+ (_opts) => memoryAndLearning(),
508
338
  (_opts) => buildAndTest(),
509
- (_opts) => securityRulesLight(),
510
- concurrencyRules,
511
- executionRules,
512
- (_opts) => cliCommandsTable(),
513
- (_opts) => memoryCommands(),
339
+ (_opts) => cliQuickRef(),
514
340
  (_opts) => setupAndBoundary(),
515
341
  ],
516
342
  };
517
343
  // --- Public API ---
518
- /**
519
- * Generate CLAUDE.md content based on init options and template.
520
- * Template is determined by: options.runtime.claudeMdTemplate > explicit param > 'standard'
521
- */
522
344
  export function generateClaudeMd(options, template) {
523
345
  const tmpl = template ?? options.runtime.claudeMdTemplate ?? 'standard';
524
346
  const sections = TEMPLATE_SECTIONS[tmpl] ?? TEMPLATE_SECTIONS.standard;
525
- const header = `# Claude Code Configuration - RuFlo V3\n`;
347
+ const header = `# Ruflo — Claude Code Configuration\n`;
526
348
  const body = sections.map(fn => fn(options)).join('\n\n');
527
349
  return `${header}\n${body}\n`;
528
350
  }
529
- /**
530
- * Generate minimal CLAUDE.md content (backward-compatible alias).
531
- */
532
351
  export function generateMinimalClaudeMd(options) {
533
352
  return generateClaudeMd(options, 'minimal');
534
353
  }
535
- /** Available template names for CLI wizard */
536
354
  export const CLAUDE_MD_TEMPLATES = [
537
- { name: 'minimal', description: 'Quick start — behavioral rules, anti-drift config, CLI reference (~120 lines)' },
538
- { name: 'standard', description: 'Recommended — swarm orchestration, agents, memory commands (~250 lines)' },
539
- { name: 'full', description: 'Everything — hooks, learning protocol, intelligence system (~400 lines)' },
540
- { name: 'security', description: 'Security-focused — adds security scanning, audit protocols, CVE checks' },
541
- { name: 'performance', description: 'Performance-focused — adds benchmarking, profiling, optimization protocols' },
542
- { name: 'solo', description: 'Solo developer — no swarm, simple agent usage, memory commands (~150 lines)' },
355
+ { name: 'minimal', description: 'Lean start — rules, agent comms, swarm config, CLI ref (~80 lines)' },
356
+ { name: 'standard', description: 'Recommended — adds memory, learning, agent types (~140 lines)' },
357
+ { name: 'full', description: 'Everything — hooks, intelligence, federation (~220 lines)' },
358
+ { name: 'security', description: 'Security-focused — adds scanning, audit, threat agents' },
359
+ { name: 'performance', description: 'Performance-focused — adds benchmarking, profiling, SONA' },
360
+ { name: 'solo', description: 'Solo developer — comms, memory, no swarm (~90 lines)' },
543
361
  ];
544
362
  export default generateClaudeMd;
545
363
  //# sourceMappingURL=claudemd-generator.js.map