moflo 4.9.10 → 4.9.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.
Files changed (31) hide show
  1. package/.claude/guidance/shipped/moflo-cli-reference.md +201 -0
  2. package/.claude/guidance/shipped/moflo-core-guidance.md +30 -391
  3. package/.claude/guidance/shipped/moflo-cross-platform.md +20 -1
  4. package/.claude/guidance/shipped/moflo-guidance-rules.md +144 -0
  5. package/.claude/guidance/shipped/moflo-memory-strategy.md +1 -0
  6. package/.claude/guidance/shipped/moflo-memorydb-maintenance.md +33 -6
  7. package/.claude/guidance/shipped/moflo-session-start.md +154 -0
  8. package/.claude/guidance/shipped/moflo-settings-injection.md +124 -0
  9. package/.claude/guidance/shipped/moflo-source-hygiene.md +1 -1
  10. package/.claude/guidance/shipped/moflo-spell-custom-steps.md +126 -0
  11. package/.claude/guidance/shipped/moflo-spell-engine.md +4 -101
  12. package/.claude/guidance/shipped/moflo-subagents.md +10 -0
  13. package/.claude/guidance/shipped/moflo-task-icons.md +9 -0
  14. package/.claude/guidance/shipped/moflo-user-facing-language.md +8 -0
  15. package/.claude/guidance/shipped/moflo-yaml-reference.md +191 -0
  16. package/.claude/skills/connector-builder/SKILL.md +1 -1
  17. package/.claude/skills/guidance/SKILL.md +158 -0
  18. package/.claude/skills/publish/SKILL.md +16 -0
  19. package/.claude/skills/spell-builder/SKILL.md +2 -2
  20. package/.claude/skills/spell-builder/architecture.md +1 -1
  21. package/.claude/skills/spell-schedule/SKILL.md +167 -0
  22. package/bin/session-start-launcher.mjs +20 -7
  23. package/dist/src/cli/commands/doctor.js +30 -0
  24. package/dist/src/cli/index.js +18 -0
  25. package/dist/src/cli/init/moflo-init.js +14 -1
  26. package/dist/src/cli/init/settings-generator.js +18 -3
  27. package/dist/src/cli/services/daemon-readiness.js +12 -0
  28. package/dist/src/cli/services/hook-wiring.js +54 -1
  29. package/dist/src/cli/services/process-registry.js +58 -0
  30. package/dist/src/cli/version.js +1 -1
  31. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  # Moflo CLI & MCP Reference
2
2
 
3
- **Purpose:** Complete CLI and MCP reference for moflo hooks, memory, agents, swarm, neural, and doctor commands. Read when using moflo features or debugging agent coordination.
3
+ **Purpose:** Hub for moflo's consumer-facing surfacegetting started, MCP setup, the comparison between Claude Code / MCP / CLI tools, the auto-learning protocol, and where to look for everything else. Read this first; deeper reference docs are linked from See Also.
4
4
 
5
5
  **MCP-First Policy:** Always prefer MCP tools (`mcp__moflo__*`) over CLI commands. Use `ToolSearch` to load them, then call directly. CLI is fallback only.
6
6
 
@@ -16,6 +16,7 @@ npx flo init # Interactive setup wizard
16
16
  ```
17
17
 
18
18
  `flo init` does the following:
19
+
19
20
  1. Creates `moflo.yaml` with detected project settings
20
21
  2. Sets up `.claude/settings.json` hooks (SessionStart, pre-edit, etc.)
21
22
  3. Configures `.mcp.json` for MCP tool access
@@ -29,6 +30,8 @@ npx flo-setup # Copy bootstrap guidance, inject CLAUDE.md section
29
30
  npx flo doctor --fix # Verify everything is working
30
31
  ```
31
32
 
33
+ For the full schema of `moflo.yaml` and the env-var overrides, see `moflo-yaml-reference.md`.
34
+
32
35
  ---
33
36
 
34
37
  ## Building from Source
@@ -47,6 +50,7 @@ npm publish --otp=XXX # Requires 2FA OTP
47
50
  ```
48
51
 
49
52
  **Critical rules:**
53
+
50
54
  - npm only — no pnpm, yarn, or bun
51
55
  - Always build from root (`npm run build`) — never cd into subdirectories
52
56
  - Never publish without a successful build — `prepublishOnly` masks failures
@@ -80,6 +84,8 @@ On version change, `session-start-launcher.mjs` copies helper scripts from the i
80
84
 
81
85
  When adding a new helper script: generate it once, save it to `bin/`, and add it to the appropriate list in `session-start-launcher.mjs`.
82
86
 
87
+ **The full picture.** Helper sync is one of several things the launcher does on every session start. For the complete lifecycle (DB heal, embeddings migration, daemon recycling, settings.json self-heal, etc.) see `moflo-session-start.md`. For the contract on what moflo writes into `.claude/settings.json` and how surgical hook-wiring rewrites work, see `moflo-settings-injection.md`.
88
+
83
89
  ### Bundled Guidance
84
90
 
85
91
  Moflo ships its own guidance files (in `.claude/guidance/` within the package). When installed as a dependency, these are **automatically indexed** alongside the consumer project's guidance under the `guidance` namespace. This means agents in your project can search for moflo system docs (swarm patterns, memory commands, etc.) without any extra setup.
@@ -111,18 +117,7 @@ Moflo ships its own guidance files (in `.claude/guidance/` within the package).
111
117
 
112
118
  ## MCP Tools Setup
113
119
 
114
- MCP tools are the preferred way for Claude to interact with moflo. `flo init` creates a `.mcp.json` in the project root:
115
-
116
- ```json
117
- {
118
- "mcpServers": {
119
- "moflo": {
120
- "command": "node",
121
- "args": ["node_modules/moflo/bin/cli.js", "mcp", "start"]
122
- }
123
- }
124
- }
125
- ```
120
+ MCP tools are the preferred way for Claude to interact with moflo. `flo init` writes `.mcp.json` in the project root automatically (see `moflo-yaml-reference.md` for the file's content and the global-registration alternative).
126
121
 
127
122
  This gives Claude access to ~125 MCP tools (`mcp__moflo__memory_*`, `mcp__moflo__hooks_*`, `mcp__moflo__swarm_*`, `mcp__moflo__moflodb_*`, etc.) without any global installation.
128
123
 
@@ -148,190 +143,7 @@ The drift-guard test fails CI if a new tool is registered with no consumer and n
148
143
  - **HNSW**: Enabled
149
144
  - **Neural**: Enabled
150
145
 
151
- ---
152
-
153
- ## CLI Commands (26 Commands, 140+ Subcommands)
154
-
155
- ### Core Commands
156
-
157
- | Command | Subcommands | Description |
158
- |-------------|-------------|--------------------------------------------------------------------------|
159
- | `init` | 4 | Project initialization with wizard, presets, skills, hooks |
160
- | `agent` | 8 | Agent lifecycle (spawn, list, status, stop, metrics, pool, health, logs) |
161
- | `swarm` | 6 | Multi-agent swarm coordination and orchestration |
162
- | `memory` | 11 | sql.js + HNSW vector search, 150x-12,500x faster |
163
- | `mcp` | 9 | MCP server management and tool execution |
164
- | `task` | 6 | Task creation, assignment, and lifecycle |
165
- | `session` | 7 | Session state management and persistence |
166
- | `config` | 7 | Configuration management and provider setup |
167
- | `status` | 3 | System status monitoring with watch mode |
168
- | `workflow` | 6 | Workflow execution and template management |
169
- | `hooks` | 17 | Self-learning hooks + 12 background workers |
170
- | `hive-mind` | 6 | Queen-led Byzantine fault-tolerant consensus |
171
-
172
- ### Advanced Commands
173
-
174
- | Command | Subcommands | Description |
175
- |---------------|-------------|-------------------------------------------------------------------------------|
176
- | `daemon` | 5 | Background worker daemon (start, stop, status, trigger, enable) |
177
- | `neural` | 5 | Neural pattern training (train, status, patterns, predict, optimize) |
178
- | `security` | 6 | Security scanning (scan, audit, cve, threats, validate, report) |
179
- | `performance` | 5 | Performance profiling (benchmark, profile, metrics, optimize, report) |
180
- | `providers` | 5 | AI providers (list, add, remove, test, configure) |
181
- | `plugins` | 5 | Plugin management (list, install, uninstall, enable, disable) |
182
- | `deployment` | 5 | Deployment management (deploy, rollback, status, environments, release) |
183
- | `embeddings` | 4 | Vector embeddings (embed, batch, search, init) - 75x faster with agentic-flow |
184
- | `claims` | 4 | Claims-based authorization (check, grant, revoke, list) |
185
- | `migrate` | 5 | V2 to V3 migration with rollback support |
186
- | `epic` | 3 | Epic orchestrator — run/status/reset with single-branch or auto-merge strategy |
187
- | `doctor` | 1 | System diagnostics with health checks |
188
- | `completions` | 4 | Shell completions (bash, zsh, fish, powershell) |
189
-
190
- ### Quick Examples (MCP Preferred)
191
-
192
- | Task | MCP Tool | CLI Fallback |
193
- |------|----------|-------------|
194
- | Search memory | `mcp__moflo__memory_search` | `memory search --query "..."` |
195
- | Spawn agent | `mcp__moflo__agent_spawn` | `agent spawn -t coder --name my-coder` |
196
- | Init swarm | `mcp__moflo__swarm_init` | `swarm init --v3-mode` |
197
- | System health | `mcp__moflo__system_health` | `doctor --fix` |
198
- | Benchmark | `mcp__moflo__performance_benchmark` | `performance benchmark --suite all` |
199
-
200
- **CLI-only (no MCP equivalent — setup tasks):**
201
- ```bash
202
- npx flo init --wizard
203
- npx flo daemon start
204
- ```
205
-
206
- ---
207
-
208
- ## Available Agents (60+ Types)
209
-
210
- ### Core Development
211
- `coder`, `reviewer`, `tester`, `planner`, `researcher`
212
-
213
- ### Specialized Agents
214
- `security-architect`, `security-auditor`, `memory-specialist`, `performance-engineer`
215
-
216
- ### Swarm Coordination
217
- `hierarchical-coordinator`, `mesh-coordinator`, `adaptive-coordinator`, `collective-intelligence-coordinator`, `swarm-memory-manager`
218
-
219
- ### Consensus & Distributed
220
- `byzantine-coordinator`, `raft-manager`, `gossip-coordinator`, `consensus-builder`, `crdt-synchronizer`, `quorum-manager`, `security-manager`
221
-
222
- ### Performance & Optimization
223
- `perf-analyzer`, `performance-benchmarker`, `task-orchestrator`, `memory-coordinator`, `smart-agent`
224
-
225
- ### GitHub & Repository
226
- `github-modes`, `pr-manager`, `code-review-swarm`, `issue-tracker`, `release-manager`, `workflow-automation`, `project-board-sync`, `repo-architect`, `multi-repo-swarm`
227
-
228
- ### SPARC Methodology
229
- `sparc-coord`, `sparc-coder`, `specification`, `pseudocode`, `architecture`, `refinement`
230
-
231
- ### Specialized Development
232
- `backend-dev`, `mobile-dev`, `ml-developer`, `cicd-engineer`, `api-docs`, `system-architect`, `code-analyzer`, `base-template-generator`
233
-
234
- ### Testing & Validation
235
- `tdd-london-swarm`, `production-validator`
236
-
237
- ### Agent Routing (Anti-Drift)
238
-
239
- | Code | Task | Agents |
240
- |------|-------------|-------------------------------------------------|
241
- | 1 | Bug Fix | coordinator, researcher, coder, tester |
242
- | 3 | Feature | coordinator, architect, coder, tester, reviewer |
243
- | 5 | Refactor | coordinator, architect, coder, reviewer |
244
- | 7 | Performance | coordinator, perf-engineer, coder |
245
- | 9 | Security | coordinator, security-architect, auditor |
246
- | 11 | Docs | researcher, api-docs |
247
-
248
- **Codes 1-9: hierarchical/specialized (anti-drift). Code 11: mesh/balanced**
249
-
250
- ---
251
-
252
- ## Hooks System (27 Hooks + 12 Workers)
253
-
254
- ### All Available Hooks
255
-
256
- | Hook | Description | Key Options |
257
- |--------------------|------------------------------------------|---------------------------------------------|
258
- | `pre-edit` | Get context before editing files | `--file`, `--operation` |
259
- | `post-edit` | Record editing outcome for learning | `--file`, `--success`, `--train-neural` |
260
- | `pre-command` | Assess risk before commands | `--command`, `--validate-safety` |
261
- | `post-command` | Record command execution outcome | `--command`, `--track-metrics` |
262
- | `pre-task` | Record task start, get agent suggestions | `--description`, `--coordinate-swarm` |
263
- | `post-task` | Record task completion for learning | `--task-id`, `--success`, `--store-results` |
264
- | `session-start` | Start/restore session | `--session-id`, `--auto-configure` |
265
- | `session-end` | End session and persist state | `--generate-summary`, `--export-metrics` |
266
- | `session-restore` | Restore a previous session | `--session-id`, `--latest` |
267
- | `route` | Route task to optimal agent | `--task`, `--context`, `--top-k` |
268
- | `explain` | Explain routing decision | `--topic`, `--detailed` |
269
- | `pretrain` | Bootstrap intelligence from repo | `--model-type`, `--epochs` |
270
- | `build-agents` | Generate optimized agent configs | `--agent-types`, `--focus` |
271
- | `metrics` | View learning metrics dashboard | `--v3-dashboard`, `--format` |
272
- | `transfer` | Transfer patterns via IPFS registry | `store`, `from-project` |
273
- | `intelligence` | RuVector intelligence system | `trajectory-*`, `pattern-*`, `stats` |
274
- | `worker` | Background worker management | `list`, `dispatch`, `status`, `detect` |
275
- | `coverage-route` | Route based on test coverage gaps | `--task`, `--path` |
276
- | `coverage-suggest` | Suggest coverage improvements | `--path` |
277
- | `coverage-gaps` | List coverage gaps with priorities | `--format`, `--limit` |
278
-
279
- ### 12 Background Workers
280
-
281
- | Worker | Priority | Description |
282
- |---------------|----------|----------------------------|
283
- | `ultralearn` | normal | Deep knowledge acquisition |
284
- | `optimize` | high | Performance optimization |
285
- | `consolidate` | low | Memory consolidation |
286
- | `predict` | normal | Predictive preloading |
287
- | `audit` | critical | Security analysis |
288
- | `map` | normal | Codebase mapping |
289
- | `preload` | low | Resource preloading |
290
- | `deepdive` | normal | Deep code analysis |
291
- | `document` | normal | Auto-documentation |
292
- | `refactor` | normal | Refactoring suggestions |
293
- | `benchmark` | normal | Performance benchmarking |
294
- | `testgaps` | normal | Test coverage analysis |
295
-
296
- ### Essential Hook Commands (MCP Preferred)
297
-
298
- | Hook | MCP Tool | Key Params |
299
- |------|----------|------------|
300
- | Pre-task | `mcp__moflo__hooks_pre-task` | `description` |
301
- | Post-task | `mcp__moflo__hooks_post-task` | `taskId`, `success` |
302
- | Post-edit | `mcp__moflo__hooks_post-edit` | `file`, `trainNeural` |
303
- | Session-start | `mcp__moflo__hooks_session-start` | `sessionId` |
304
- | Session-end | `mcp__moflo__hooks_session-end` | `exportMetrics` |
305
- | Route | `mcp__moflo__hooks_route` | `task` |
306
- | Worker-dispatch | `mcp__moflo__hooks_worker-dispatch` | `trigger` |
307
-
308
- ---
309
-
310
- ## Hive-Mind Consensus
311
-
312
- ### Topologies
313
- - `hierarchical` - Queen controls workers directly
314
- - `mesh` - Fully connected peer network
315
- - `hierarchical-mesh` - Hybrid (recommended)
316
- - `adaptive` - Dynamic based on load
317
-
318
- ### Consensus Strategies
319
- - `byzantine` - BFT (tolerates f < n/3 faulty)
320
- - `raft` - Leader-based (tolerates f < n/2)
321
- - `gossip` - Epidemic for eventual consistency
322
- - `crdt` - Conflict-free replicated data types
323
- - `quorum` - Configurable quorum-based
324
-
325
- ---
326
-
327
- ## RuVector Integration (HNSW Vector Search)
328
-
329
- | Feature | Performance | Description |
330
- |---------|-------------|-------------|
331
- | **HNSW Index** | 150x-12,500x faster | Hierarchical Navigable Small World search |
332
- | **MicroLoRA** | <100us adaptation | Fast model adaptation (508k+ ops/sec) |
333
- | **FlashAttention** | 2.49x-7.47x speedup | Optimized attention computation |
334
- | **Int8 Quantization** | 3.92x memory reduction | Compressed weight storage |
146
+ For the full `moflo.yaml` schema, gate toggles, model routing, and sandbox config, see `moflo-yaml-reference.md`. For the catalog of commands, agents, hooks, and consensus topologies these defaults shape, see `moflo-cli-reference.md`.
335
147
 
336
148
  ---
337
149
 
@@ -342,6 +154,7 @@ npx flo daemon start
342
154
  **MCP (Preferred):** `mcp__moflo__memory_search` — `query: "[task keywords]", namespace: "patterns"`
343
155
 
344
156
  **CLI Fallback:**
157
+
345
158
  ```bash
346
159
  npx flo memory search --query '[task keywords]' --namespace patterns
347
160
  ```
@@ -368,12 +181,14 @@ npx flo memory search --query '[task keywords]' --namespace patterns
368
181
  ### Memory-Enhanced Development
369
182
 
370
183
  **ALWAYS check memory before:**
184
+
371
185
  - Starting a new feature (search for similar implementations)
372
186
  - Debugging an issue (search for past solutions)
373
187
  - Refactoring code (search for learned patterns)
374
188
  - Performance work (search for optimization strategies)
375
189
 
376
190
  **ALWAYS store in memory after:**
191
+
377
192
  - Solving a tricky bug (store the solution pattern)
378
193
  - Completing a feature (store the approach)
379
194
  - Finding a performance fix (store the optimization)
@@ -386,10 +201,12 @@ npx flo memory search --query '[task keywords]' --namespace patterns
386
201
  ### Store Data
387
202
 
388
203
  **MCP:** `mcp__moflo__memory_store`
204
+
389
205
  - Required: `key`, `value`
390
206
  - Optional: `namespace` (default: "default"), `ttl`, `tags`
391
207
 
392
208
  **CLI Fallback:**
209
+
393
210
  ```bash
394
211
  npx flo memory store --key "pattern-auth" --value "JWT with refresh tokens" --namespace patterns
395
212
  ```
@@ -397,10 +214,12 @@ npx flo memory store --key "pattern-auth" --value "JWT with refresh tokens" --na
397
214
  ### Search Data (semantic vector search)
398
215
 
399
216
  **MCP:** `mcp__moflo__memory_search`
217
+
400
218
  - Required: `query`
401
219
  - Optional: `namespace`, `limit`, `threshold`
402
220
 
403
221
  **CLI Fallback:**
222
+
404
223
  ```bash
405
224
  npx flo memory search --query "authentication patterns" --namespace patterns --limit 5
406
225
  ```
@@ -408,11 +227,13 @@ npx flo memory search --query "authentication patterns" --namespace patterns --l
408
227
  ### List Entries
409
228
 
410
229
  **MCP:** `mcp__moflo__memory_list`
230
+
411
231
  - Optional: `namespace`, `limit`
412
232
 
413
233
  ### Retrieve Specific Entry
414
234
 
415
235
  **MCP:** `mcp__moflo__memory_retrieve`
236
+
416
237
  - Required: `key`
417
238
  - Optional: `namespace` (default: "default")
418
239
 
@@ -421,6 +242,7 @@ npx flo memory search --query "authentication patterns" --namespace patterns --l
421
242
  ## Claude Code vs MCP vs CLI Tools
422
243
 
423
244
  ### Claude Code Handles ALL EXECUTION:
245
+
424
246
  - **Task tool**: Spawn and run agents concurrently
425
247
  - File operations (Read, Write, Edit, Glob, Grep)
426
248
  - Code generation and programming
@@ -440,6 +262,7 @@ npx flo memory search --query "authentication patterns" --namespace patterns --l
440
262
  ### CLI Commands (Fallback Only):
441
263
 
442
264
  Only use CLI via Bash when MCP tools are unavailable:
265
+
443
266
  ```bash
444
267
  npx flo <command> [options]
445
268
  ```
@@ -456,202 +279,13 @@ Checks: Node version (20+), Git, config validity, daemon status, memory database
456
279
 
457
280
  ---
458
281
 
459
- ## Environment Variables
460
-
461
- ```bash
462
- # Configuration
463
- CLAUDE_FLOW_CONFIG=./claude-flow.config.json
464
- CLAUDE_FLOW_LOG_LEVEL=info
465
-
466
- # MCP Server
467
- CLAUDE_FLOW_MCP_PORT=3000
468
- CLAUDE_FLOW_MCP_HOST=localhost
469
- CLAUDE_FLOW_MCP_TRANSPORT=stdio
470
-
471
- # Memory
472
- CLAUDE_FLOW_MEMORY_BACKEND=hybrid
473
- CLAUDE_FLOW_MEMORY_PATH=./data/memory
474
- ```
475
-
476
- ---
477
-
478
- ## Quick Setup
479
-
480
- ### Project-Level MCP (Recommended)
481
-
482
- Configure `.mcp.json` in the project root:
483
-
484
- ```json
485
- {
486
- "mcpServers": {
487
- "moflo": {
488
- "command": "node",
489
- "args": ["node_modules/moflo/bin/cli.js", "mcp", "start"]
490
- }
491
- }
492
- }
493
- ```
494
-
495
- ### Alternative: Global MCP Registration
496
-
497
- ```bash
498
- claude mcp add moflo -- npx moflo@alpha
499
- npx flo daemon start
500
- npx flo doctor --fix
501
- ```
502
-
503
- ---
504
-
505
- ## Project Configuration (moflo.yaml)
506
-
507
- Moflo reads `moflo.yaml` (or `moflo.config.json`) from the project root. All fields have sensible defaults — the file is optional.
508
-
509
- ### Full Reference
510
-
511
- ```yaml
512
- project:
513
- name: "my-project" # Project name (default: directory name)
514
-
515
- # Guidance/knowledge docs to index for semantic search
516
- guidance:
517
- directories: # Directories to scan for .md files
518
- - .claude/guidance # Default
519
- - docs/guides # Default
520
- namespace: guidance # Memory namespace for indexed docs
521
-
522
- # Source directories for code navigation map
523
- code_map:
524
- directories: # Directories to scan for source files
525
- - src # Default
526
- - packages
527
- - lib
528
- - app
529
- extensions: [".ts", ".tsx", ".js", ".jsx", ".py", ".go", ".rs", ".java"]
530
- exclude: [node_modules, dist, .next, coverage, build, __pycache__, target, .git]
531
- namespace: code-map
532
-
533
- # Workflow gates (enforced via Claude Code hooks)
534
- # Memory-first is enforced at the scan/read layer (Glob, Grep, Read gates).
535
- # Agent spawning is never blocked — SubagentStart hook injects guidance directive.
536
- gates:
537
- memory_first: true # Block Glob/Grep/Read until memory is searched
538
- task_create_first: true # Advisory reminder before Agent tool (not blocking)
539
- context_tracking: true # Track context bracket (FRESH/MODERATE/DEPLETED/CRITICAL)
540
-
541
- # Auto-index on session start
542
- auto_index:
543
- guidance: true # Run flo-index (guidance RAG indexer)
544
- code_map: true # Run flo-codemap (structural code index)
545
-
546
- # Memory backend
547
- memory:
548
- backend: sql.js # sql.js (WASM) | json
549
- embedding_model: Xenova/all-MiniLM-L6-v2 # 384-dim neural embeddings
550
- namespace: default # Default namespace for memory operations
551
-
552
- # Hook toggles (all on by default — disable to slim down)
553
- hooks:
554
- pre_edit: true # Track file edits for learning
555
- post_edit: true # Record edit outcomes, train neural patterns
556
- pre_task: true # Get agent routing before task spawn
557
- post_task: true # Record task results for learning
558
- gate: true # Workflow gate enforcement (memory-first at scan/read layer)
559
- route: true # Intelligent task routing on each prompt
560
- stop_hook: true # Session-end persistence and metric export
561
- session_restore: true # Restore session state on start
562
- notification: true # Hook into Claude Code notifications
563
-
564
- # Model preferences (haiku, sonnet, opus)
565
- models:
566
- default: opus # General tasks
567
- research: sonnet # Research/exploration agents
568
- review: opus # Code review agents
569
- test: sonnet # Test-writing agents
570
-
571
- # Intelligent model routing (auto-selects haiku/sonnet/opus per task)
572
- model_routing:
573
- enabled: false # Set true to enable dynamic routing
574
- confidence_threshold: 0.85 # Min confidence before escalating
575
- cost_optimization: true # Prefer cheaper models when confident
576
- circuit_breaker: true # Penalize models that fail repeatedly
577
- # agent_overrides:
578
- # security-architect: opus
579
- # researcher: sonnet
580
-
581
- # Status line display
582
- status_line:
583
- enabled: true # Show status line at all
584
- branding: "Moflo V4" # Text in status bar
585
- mode: single-line # single-line (default) or dashboard (multi-line)
586
- show_git: true # Git branch, changes, ahead/behind
587
- show_model: true # Current model name
588
- show_session: true # Session duration
589
- show_intelligence: true # Intelligence % indicator
590
- show_swarm: true # Active swarm agents count
591
- show_hooks: true # Enabled hooks count
592
- show_mcp: true # MCP server count
593
- show_security: true # CVE/security status (dashboard only)
594
- show_adrs: true # ADR compliance (dashboard only)
595
- show_agentdb: true # MofloDb vectors/size (dashboard only)
596
- show_tests: true # Test file count (dashboard only)
597
-
598
- # Spell step sandboxing (OS-level process isolation for bash steps)
599
- # Platform support: macOS (sandbox-exec), Linux/WSL (bwrap). Windows has no OS sandbox.
600
- sandbox:
601
- enabled: false # Set to true to wrap bash steps in an OS sandbox
602
- tier: auto # auto | denylist-only | full
603
- ```
604
-
605
- If your `moflo.yaml` predates the `sandbox:` block, it is auto-appended on the next session start — you never need to re-run `moflo init` after a version bump.
606
-
607
- ### Key Behaviors
608
-
609
- | Config | Effect |
610
- |--------|--------|
611
- | `auto_index.guidance: false` | Skip guidance indexing on session start |
612
- | `auto_index.code_map: false` | Skip code map generation on session start |
613
- | `gates.memory_first: true` | Block Glob/Grep/Read until memory is searched first |
614
- | `gates.task_create_first: true` | Advisory reminder before Agent tool (not blocking) |
615
- | `gates.context_tracking: true` | Show FRESH/MODERATE/DEPLETED/CRITICAL context bracket |
616
- | `hooks.pre_edit: false` | Disable file-edit tracking (skips pre-edit hook) |
617
- | `hooks.post_edit: false` | Disable edit outcome recording and neural training |
618
- | `hooks.pre_task: false` | Disable agent routing recommendations before spawn |
619
- | `hooks.post_task: false` | Disable task result recording for learning |
620
- | `hooks.gate: false` | Disable all workflow gates (memory-first, task-create-first) |
621
- | `hooks.route: false` | Disable intelligent task routing on each prompt |
622
- | `hooks.stop_hook: false` | Disable session-end persistence and metric export |
623
- | `hooks.notification: false` | Disable notification hook |
624
- | `model_routing.enabled: true` | Auto-select haiku/sonnet/opus based on task complexity |
625
- | `status_line.mode: dashboard` | Switch to multi-line status display |
626
- | `status_line.show_swarm: false` | Hide swarm agent count from status bar |
627
- | `sandbox.enabled: true` | Wrap bash steps in an OS sandbox (macOS/Linux/WSL) — absolute disable when `false`, regardless of tier |
628
- | `sandbox.tier: full` | Require OS sandbox; throw at runtime if the platform tool is unavailable |
629
- | `sandbox.tier: denylist-only` | Keep Layer 1 denylist only; skip OS isolation even when enabled |
630
-
631
- ---
632
-
633
- ## Cross-Platform Compatibility
634
-
635
- All code changes MUST work on Windows, macOS, and Linux. Follow these rules:
636
-
637
- - **Paths**: Use `path.join()` / `path.resolve()`, never hardcoded `/` or `\\` separators
638
- - **Process spawning**: Use `detached: !isWin` for background processes; on Windows use `shell: true, windowsHide: true` instead
639
- - **Process killing**: Use `taskkill /F /PID` on Windows, `process.kill(pid, signal)` on POSIX
640
- - **Process inspection**: Use PowerShell `Get-CimInstance` on Windows, `/proc/<pid>/cmdline` on Linux, `ps -p <pid>` on macOS
641
- - **Shell commands**: Never assume bash — use `child_process.spawn` with explicit args instead of shell string interpolation
642
- - **File locking**: Use `fs.writeFileSync(path, data, { flag: 'wx' })` for atomic locks (works cross-platform)
643
- - **Signals**: SIGHUP/SIGTERM are POSIX-only; on Windows use `taskkill` or process exit events
644
- - **Line endings**: Use `\n` in code; let git handle CRLF conversion
645
- - **Temp dirs**: Use `os.tmpdir()`, not `/tmp`
646
- - **PID recycling**: Windows recycles PIDs aggressively — always verify process command line, not just PID liveness
647
-
648
282
  ## Troubleshooting Common Issues
649
283
 
650
284
  | Symptom | Cause | Fix |
651
285
  |---------|-------|-----|
652
286
  | No MCP tools available | `.mcp.json` missing or moflo not installed | Run `npx flo init` or manually create `.mcp.json` |
653
287
  | Memory search returns nothing | Indexer hasn't run yet | Run `npx flo-index --force` to index guidance |
654
- | Low search quality | Guidance docs missing `**Purpose:**` lines or generic headings | Follow guidance optimization rules in `guidance-memory-strategy.md` |
288
+ | Low search quality | Guidance docs missing `**Purpose:**` lines or generic headings | Follow guidance optimization rules in `moflo-memory-strategy.md` |
655
289
  | Session start slow | All three indexers running | Set `auto_index.code_map: false` in `moflo.yaml` if code map not needed |
656
290
  | Status line not showing | `statusline.cjs` error or `status_line.enabled: false` | Run `node .claude/helpers/statusline.cjs` to test, check `moflo.yaml` |
657
291
  | Embeddings fail on first run (offline / air-gapped) | `fastembed` model cache missing | Pre-populate `~/.cache/fastembed` or set `FASTEMBED_CACHE` to a pre-baked cache dir — see `docs/modules/embeddings.md` "Sandbox & air-gapped first-run" |
@@ -664,7 +298,12 @@ See `moflo-memory-strategy.md` for memory-specific troubleshooting.
664
298
 
665
299
  ## See Also
666
300
 
667
- - `.claude/guidance/moflo-subagents.md` - Subagents memory-first protocol and store patterns
668
- - `.claude/guidance/moflo-claude-swarm-cohesion.md` - Task & swarm coordination with TaskCreate/TaskUpdate
669
- - `.claude/guidance/moflo-memory-strategy.md` - Database schema, namespaces, search commands, RAG linking
670
- - `.claude/guidance/guidance-memory-strategy.md` - How to write guidance docs that index well for RAG
301
+ - `.claude/guidance/shipped/moflo-cli-reference.md` CLI commands, agents, hooks, hive-mind, RuVector
302
+ - `.claude/guidance/shipped/moflo-yaml-reference.md` `moflo.yaml` schema, environment variables, `.mcp.json` setup
303
+ - `.claude/guidance/shipped/moflo-subagents.md` Subagents memory-first protocol and store patterns
304
+ - `.claude/guidance/shipped/moflo-claude-swarm-cohesion.md` Task & swarm coordination with TaskCreate/TaskUpdate
305
+ - `.claude/guidance/shipped/moflo-memory-strategy.md` — Database schema, namespaces, search commands, RAG linking
306
+ - `.claude/guidance/shipped/moflo-memorydb-maintenance.md` — Reindexing, namespace purging, recovery
307
+ - `.claude/guidance/shipped/moflo-session-start.md` — Complete session-start lifecycle (DB heal, sync, migrations, daemon)
308
+ - `.claude/guidance/shipped/moflo-settings-injection.md` — What moflo writes into `.claude/` and how surgical self-heal works
309
+ - `.claude/guidance/shipped/moflo-cross-platform.md` — Windows/macOS/Linux portability rules for any code change
@@ -72,11 +72,30 @@ const mod = await import(`file://${absolutePath}`);
72
72
  | Find executable | `which` | `where` |
73
73
  | Null device | `/dev/null` | `NUL` |
74
74
  | Shell | `/bin/sh` | `cmd.exe` |
75
- | Kill process | `kill <pid>` | `taskkill /PID <pid>` |
75
+ | Kill process | `kill <pid>` | `taskkill /F /PID <pid>` |
76
76
  | List processes | `ps -eo pid,command` | `tasklist` |
77
+ | Inspect a PID's command line | `/proc/<pid>/cmdline` (Linux) or `ps -p <pid>` (macOS) | PowerShell `Get-CimInstance Win32_Process -Filter "ProcessId=<pid>"` |
78
+
79
+ **Background process spawning differs by platform.** Use `detached: !isWin` for backgrounded children on POSIX; on Windows use `{ shell: true, windowsHide: true }` instead — `detached` does not behave the same way and the `windowsHide` flag prevents flashing console windows.
77
80
 
78
81
  **Shell escape functions MUST match the target shell.** POSIX single-quote escaping (`'arg'`) does not work in `cmd.exe`. If you select `cmd.exe` as the shell on Windows, escape with `"` or `^`.
79
82
 
83
+ **Never assume `bash` is on PATH.** Use `child_process.spawn` with explicit args instead of building a shell string the user's shell will re-parse. On Windows, even with `shell: true`, the default is `cmd.exe` — POSIX-isms in the command string will fail.
84
+
85
+ ---
86
+
87
+ ## Signals and Process Lifecycle
88
+
89
+ **SIGHUP and SIGTERM are POSIX-only.** On Windows, `process.kill(pid, 'SIGHUP')` is a best-effort emulation that often just terminates the process. To stop a process portably, prefer `taskkill /F /PID <pid>` on Windows and `process.kill(pid, 'SIGTERM')` on POSIX, with explicit branching.
90
+
91
+ **Windows recycles PIDs aggressively.** A PID that was alive a few minutes ago may now belong to an unrelated process. Anywhere we do "is this PID still mine?" the check MUST verify the process command line (or another stable marker), not just PID liveness — otherwise we'll send signals to whoever inherited the PID.
92
+
93
+ ---
94
+
95
+ ## Cross-Platform File Locking
96
+
97
+ **Use `fs.writeFileSync(path, data, { flag: 'wx' })` for atomic locks.** The `wx` flag fails if the file already exists, giving an atomic create-or-fail primitive that works the same on Windows, macOS, and Linux. Don't reach for `flock`, `fcntl`, or shelling out to `lockfile` — those are POSIX-only or platform-fragile.
98
+
80
99
  ---
81
100
 
82
101
  ## Shebang Files (bin/ Directory)