moflo 4.9.10 → 4.9.12

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 (37) hide show
  1. package/.claude/commands/simplify.md +78 -30
  2. package/.claude/guidance/shipped/moflo-cli-reference.md +201 -0
  3. package/.claude/guidance/shipped/moflo-core-guidance.md +30 -391
  4. package/.claude/guidance/shipped/moflo-cross-platform.md +20 -1
  5. package/.claude/guidance/shipped/moflo-guidance-rules.md +144 -0
  6. package/.claude/guidance/shipped/moflo-memory-strategy.md +1 -0
  7. package/.claude/guidance/shipped/moflo-memorydb-maintenance.md +33 -6
  8. package/.claude/guidance/shipped/moflo-session-start.md +154 -0
  9. package/.claude/guidance/shipped/moflo-settings-injection.md +124 -0
  10. package/.claude/guidance/shipped/moflo-source-hygiene.md +1 -1
  11. package/.claude/guidance/shipped/moflo-spell-custom-steps.md +126 -0
  12. package/.claude/guidance/shipped/moflo-spell-engine.md +4 -101
  13. package/.claude/guidance/shipped/moflo-subagents.md +10 -0
  14. package/.claude/guidance/shipped/moflo-task-icons.md +9 -0
  15. package/.claude/guidance/shipped/moflo-user-facing-language.md +8 -0
  16. package/.claude/guidance/shipped/moflo-yaml-reference.md +191 -0
  17. package/.claude/skills/connector-builder/SKILL.md +1 -1
  18. package/.claude/skills/guidance/SKILL.md +158 -0
  19. package/.claude/skills/publish/SKILL.md +16 -0
  20. package/.claude/skills/simplify/SKILL.md +90 -21
  21. package/.claude/skills/spell-builder/SKILL.md +2 -2
  22. package/.claude/skills/spell-builder/architecture.md +1 -1
  23. package/.claude/skills/spell-schedule/SKILL.md +167 -0
  24. package/bin/session-start-launcher.mjs +164 -11
  25. package/dist/src/cli/commands/doctor-checks-deep.js +62 -0
  26. package/dist/src/cli/commands/doctor.js +34 -1
  27. package/dist/src/cli/config/moflo-config.js +14 -3
  28. package/dist/src/cli/index.js +18 -0
  29. package/dist/src/cli/init/moflo-init.js +19 -4
  30. package/dist/src/cli/init/settings-generator.js +18 -3
  31. package/dist/src/cli/services/daemon-readiness.js +12 -0
  32. package/dist/src/cli/services/hook-block-hash.js +320 -0
  33. package/dist/src/cli/services/hook-wiring.js +54 -1
  34. package/dist/src/cli/services/index.js +2 -0
  35. package/dist/src/cli/services/process-registry.js +58 -0
  36. package/dist/src/cli/version.js +1 -1
  37. package/package.json +2 -2
@@ -1,55 +1,103 @@
1
1
  ---
2
- description: Review changed code for reuse, quality, and efficiency, then fix any issues found.
2
+ description: Review changed code for reuse, quality, and efficiency, then fix any issues found. Sizes review effort to the diff and routes the cheapest model that fits.
3
3
  ---
4
4
 
5
- # /simplify — Gate-Compliant Code Review
5
+ # /simplify — Adaptive Gate-Compliant Code Review
6
6
 
7
- Review all changed files for reuse opportunities, code quality, and efficiency improvements.
7
+ Review changed code for reuse, quality, and efficiency. **Effort scales with diff size; model is routed for cost.** A 5-line comment trim does not get 3 Opus agents.
8
8
 
9
- **This command overrides any built-in simplify skill.** Follow these steps exactly.
9
+ ## Phase 0: Gate prerequisites
10
10
 
11
- ## Prerequisites (MANDATORY do these FIRST)
11
+ These satisfy the memory-first and task-create-first gates. Always do them before any Agent spawn.
12
12
 
13
- 1. **Memory search**: Search for relevant patterns before reviewing
14
- ```
15
- mcp__moflo__memory_search — query: "code quality patterns", namespace: "patterns"
16
- ```
13
+ 1. **Memory search** `mcp__moflo__memory_search query: "code quality patterns", namespace: "patterns"`
14
+ 2. **Task create** — `TaskCreate — subject: "🔍 [Reviewer] Simplify changed code"`
17
15
 
18
- 2. **Create task**: Track the simplification work
19
- ```
20
- TaskCreate — subject: "🔍 [Reviewer] Simplify changed code", description: "Review changed files for reuse, quality, and efficiency"
16
+ ## Phase 1: Identify the diff
17
+
18
+ ```bash
19
+ git diff HEAD # working tree
20
+ git diff main...HEAD # committed since branch base
21
21
  ```
22
22
 
23
- ## Execution
23
+ Treat the union as the diff. Note whether `/simplify` already ran on this branch in this session — if so, you are in a **validation pass** (Phase 4 below).
24
24
 
25
- After prerequisites are satisfied, get the list of changed files:
25
+ ## Phase 2: Classify the diff
26
26
 
27
- ```bash
28
- git diff --name-only HEAD~1
29
- ```
27
+ Pick the smallest tier the diff genuinely fits.
30
28
 
31
- Then launch 3 reviewer agents **in parallel** (single message, multiple Agent tool calls).
29
+ | Tier | Trigger | Action |
30
+ |------|---------|--------|
31
+ | **TRIVIAL** | ≤10 net LOC, single file, comments/formatting/local renames only | Self-review, zero agents |
32
+ | **SMALL** | ≤200 net LOC, ≤2 files, no API/dependency change | **One agent** (default for most diffs, including critical surface) |
33
+ | **NORMAL** | ≥3 files, OR >200 LOC, OR public API change, OR new/removed dependency, OR cross-cutting refactor | Three parallel agents |
32
34
 
33
- **CRITICAL**: Each agent prompt below includes a mandatory memory search step. This is required because subagents must satisfy the memory-first gate independently before using Glob, Grep, or Read tools. Do NOT remove the memory search from agent prompts.
35
+ Critical-surface files (launcher, hooks, MCP wiring) raise the *care* of the agent prompt sharper checklist, blast-radius framing they do **not** automatically escalate to NORMAL. Risk-weighted headcount-weighted.
36
+
37
+ ## Phase 3: Route the model (skip for TRIVIAL)
38
+
39
+ Before spawning any Agent, ask the moflo router which model to use:
34
40
 
35
- ### Agent 1: Reuse Reviewer
36
41
  ```
37
- Agentname: "reuse-reviewer", run_in_background: true, subagent_type: "reviewer", prompt: "FIRST ACTION: Run mcp__moflo__memory_search with query 'code reuse patterns' and namespace 'patterns'. You MUST do this before any Glob, Grep, or Read calls. THEN review these changed files for code reuse opportunities. Look for: duplicated logic that could use existing utilities, patterns already solved elsewhere in the codebase, opportunities to extract shared helpers. Files: $CHANGED_FILES"
42
+ mcp__moflo__hooks_model-route{
43
+ task: "Review N-line change in <files> for reuse, quality, efficiency",
44
+ preferCost: true
45
+ }
38
46
  ```
39
47
 
40
- ### Agent 2: Quality Reviewer
48
+ **Wording rules:** the router's complexity score is keyword-sensitive. Avoid `refactor`, `architect`, `audit`, `system`, `redesign`, `migrate` — those force opus even when scoring suggests sonnet. State LOC count, file count, and "review for reuse, quality, efficiency". Nothing more.
49
+
50
+ **Hard rule for `/simplify`: opus is never correct.** Code review never needs Opus reasoning, even on critical surface. If the router returns `opus`, downgrade to `sonnet`. On router failure, default to `sonnet`. Comment trims and pure formatting → `haiku`.
51
+
52
+ ## Phase 4: Validation pass (re-run after fixes from a prior simplify)
53
+
54
+ If `/simplify` already ran on this branch in this session AND the only edits since are fixes the prior pass surfaced, **default to TRIVIAL self-review** regardless of LOC count. The fan-out happened; the fix is small relative to the already-reviewed diff.
55
+
56
+ Escalate one tier (self-review → SMALL agent) only if the fix introduced a new file, a new exported symbol, a new dependency, or a control-flow change not covered by the original findings. Never escalate a validation pass to NORMAL.
57
+
58
+ ## Phase 5: Run the appropriate review
59
+
60
+ ### TRIVIAL / Validation
61
+ Run the three category checks (reuse / quality / efficiency) yourself in one pass against the diff. Most TRIVIAL diffs are clean — confirm and exit. Budget: ~30 seconds, no Agent.
62
+
63
+ ### SMALL — one agent
41
64
  ```
42
- Agent — name: "quality-reviewer", run_in_background: true, subagent_type: "reviewer", prompt: "FIRST ACTION: Run mcp__moflo__memory_search with query 'code quality patterns' and namespace 'patterns'. You MUST do this before any Glob, Grep, or Read calls. THEN review these changed files for code quality issues. Look for: unclear naming, overly complex logic, missing error handling at system boundaries, potential bugs, consistency with existing patterns. Files: $CHANGED_FILES"
65
+ Agent — {
66
+ subagent_type: "reviewer",
67
+ model: "<sonnet (or haiku for trivial-formatting tier from router)>",
68
+ prompt: "FIRST ACTION: Run mcp__moflo__memory_search with query 'code review patterns' and namespace 'patterns' to satisfy the memory-first gate. THEN review this diff for reuse, quality, and efficiency. <diff inline>. Flag specific issues as file:line + 1-line description. Max 5 file reads. Under 200 words. Skip cosmetic style. Don't suggest cross-cutting refactors of code outside this diff."
69
+ }
43
70
  ```
44
71
 
45
- ### Agent 3: Efficiency Reviewer
72
+ For critical-surface files, prepend a 1-line risk note (e.g., "This is `bin/session-start-launcher.mjs` — runs in every consumer's session-start hot path; cross-platform + blast-radius matter."). One careful agent, not three.
73
+
74
+ ### NORMAL — three parallel agents
75
+ Launch three agents in a single message, each at the routed model (typically sonnet). Each agent gets the SMALL-tier tool-budget cap.
76
+
77
+ - **Agent 1 (Reuse):** existing helpers/utilities that should be used; duplicated patterns; functions re-implementing something already in the codebase.
78
+ - **Agent 2 (Quality):** redundant state, parameter sprawl, copy-paste with variation, leaky abstractions, stringly-typed code, nested conditionals 3+ levels, unnecessary comments.
79
+ - **Agent 3 (Efficiency):** unnecessary work, missed concurrency, hot-path bloat, recurring no-op updates, TOCTOU existence checks, unbounded structures, over-broad reads.
80
+
81
+ Each agent prompt must start with `FIRST ACTION: mcp__moflo__memory_search ... namespace: "patterns"` — subagents must satisfy the memory-first gate independently before Glob/Grep/Read.
82
+
83
+ ## Phase 6: Fix or skip
84
+
85
+ Aggregate findings. Fix each issue directly that's worth fixing. False positives or out-of-scope: note and skip without arguing.
86
+
87
+ If fixes were made, re-run tests to confirm nothing broke. If tests fail after a fix, revert it.
88
+
89
+ After fixes: the next `/simplify` invocation is a **validation pass** (Phase 4). Bundle related fixes into one batch so a single validation pass covers them — don't re-fan-out for cosmetic micro-corrections.
90
+
91
+ ## Phase 7: Optional — record routing outcome
92
+
93
+ If you spawned an agent, feed back the outcome so the router learns:
94
+
46
95
  ```
47
- Agentname: "efficiency-reviewer", run_in_background: true, subagent_type: "reviewer", prompt: "FIRST ACTION: Run mcp__moflo__memory_search with query 'performance optimization patterns' and namespace 'patterns'. You MUST do this before any Glob, Grep, or Read calls. THEN review these changed files for efficiency improvements. Look for: unnecessary allocations, O(n^2) where O(n) is possible, redundant operations, opportunities to batch or cache. Files: $CHANGED_FILES"
96
+ mcp__moflo__hooks_model-outcome{ task: "...", model: "<chosen>", outcome: "success" | "failure" | "escalated" }
48
97
  ```
49
98
 
50
- ## Post-Review
99
+ `escalated` only when a real miss happened that a higher tier would have caught — never used to retroactively justify opus.
100
+
101
+ ## Briefly summarize
51
102
 
52
- 1. Collect findings from all 3 reviewers
53
- 2. Apply fixes that preserve ALL existing functionality — no behavior changes
54
- 3. If fixes were made, re-run tests to confirm nothing broke
55
- 4. If tests fail after fixes, revert the simplification changes
103
+ End with one or two sentences: which tier ran, which model, what was fixed (or "clean — no changes"). No headers, no bullets.
@@ -0,0 +1,201 @@
1
+ # Moflo CLI Surface — Commands, Agents, Hooks
2
+
3
+ **Purpose:** Reference for moflo's CLI command surface, available agents, hooks, and consensus topologies. Use this when picking a command/agent/hook by name; for higher-level workflow guidance see `moflo-core-guidance.md`, and for `moflo.yaml` knobs that gate this surface see `moflo-yaml-reference.md`.
4
+
5
+ ---
6
+
7
+ ## CLI Commands (26 Commands, 140+ Subcommands)
8
+
9
+ ### Core Commands
10
+
11
+ | Command | Subcommands | Description |
12
+ |-------------|-------------|--------------------------------------------------------------------------|
13
+ | `init` | 4 | Project initialization with wizard, presets, skills, hooks |
14
+ | `agent` | 8 | Agent lifecycle (spawn, list, status, stop, metrics, pool, health, logs) |
15
+ | `swarm` | 6 | Multi-agent swarm coordination and orchestration |
16
+ | `memory` | 11 | sql.js + HNSW vector search, 150x-12,500x faster |
17
+ | `mcp` | 9 | MCP server management and tool execution |
18
+ | `task` | 6 | Task creation, assignment, and lifecycle |
19
+ | `session` | 7 | Session state management and persistence |
20
+ | `config` | 7 | Configuration management and provider setup |
21
+ | `status` | 3 | System status monitoring with watch mode |
22
+ | `workflow` | 6 | Workflow execution and template management |
23
+ | `hooks` | 17 | Self-learning hooks + 12 background workers |
24
+ | `hive-mind` | 6 | Queen-led Byzantine fault-tolerant consensus |
25
+
26
+ ### Advanced Commands
27
+
28
+ | Command | Subcommands | Description |
29
+ |---------------|-------------|-------------------------------------------------------------------------------|
30
+ | `daemon` | 5 | Background worker daemon (start, stop, status, trigger, enable) |
31
+ | `neural` | 5 | Neural pattern training (train, status, patterns, predict, optimize) |
32
+ | `security` | 6 | Security scanning (scan, audit, cve, threats, validate, report) |
33
+ | `performance` | 5 | Performance profiling (benchmark, profile, metrics, optimize, report) |
34
+ | `providers` | 5 | AI providers (list, add, remove, test, configure) |
35
+ | `plugins` | 5 | Plugin management (list, install, uninstall, enable, disable) |
36
+ | `deployment` | 5 | Deployment management (deploy, rollback, status, environments, release) |
37
+ | `embeddings` | 4 | Vector embeddings (embed, batch, search, init) — fastembed runtime |
38
+ | `claims` | 4 | Claims-based authorization (check, grant, revoke, list) |
39
+ | `migrate` | 5 | V2 to V3 migration with rollback support |
40
+ | `epic` | 3 | Epic orchestrator — run/status/reset with single-branch or auto-merge strategy |
41
+ | `doctor` | 1 | System diagnostics with health checks |
42
+ | `completions` | 4 | Shell completions (bash, zsh, fish, powershell) |
43
+
44
+ ### Quick Examples (MCP Preferred)
45
+
46
+ | Task | MCP Tool | CLI Fallback |
47
+ |------|----------|-------------|
48
+ | Search memory | `mcp__moflo__memory_search` | `memory search --query "..."` |
49
+ | Spawn agent | `mcp__moflo__agent_spawn` | `agent spawn -t coder --name my-coder` |
50
+ | Init swarm | `mcp__moflo__swarm_init` | `swarm init --v3-mode` |
51
+ | System health | `mcp__moflo__system_health` | `doctor --fix` |
52
+ | Benchmark | `mcp__moflo__performance_benchmark` | `performance benchmark --suite all` |
53
+
54
+ **CLI-only (no MCP equivalent — setup tasks):**
55
+ ```bash
56
+ npx flo init --wizard
57
+ npx flo daemon start
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Available Agents (60+ Types)
63
+
64
+ ### Core Development
65
+ `coder`, `reviewer`, `tester`, `planner`, `researcher`
66
+
67
+ ### Specialized Agents
68
+ `security-architect`, `security-auditor`, `memory-specialist`, `performance-engineer`
69
+
70
+ ### Swarm Coordination
71
+ `hierarchical-coordinator`, `mesh-coordinator`, `adaptive-coordinator`, `collective-intelligence-coordinator`, `swarm-memory-manager`
72
+
73
+ ### Consensus & Distributed
74
+ `byzantine-coordinator`, `raft-manager`, `gossip-coordinator`, `consensus-builder`, `crdt-synchronizer`, `quorum-manager`, `security-manager`
75
+
76
+ ### Performance & Optimization
77
+ `perf-analyzer`, `performance-benchmarker`, `task-orchestrator`, `memory-coordinator`, `smart-agent`
78
+
79
+ ### GitHub & Repository
80
+ `github-modes`, `pr-manager`, `code-review-swarm`, `issue-tracker`, `release-manager`, `workflow-automation`, `project-board-sync`, `repo-architect`, `multi-repo-swarm`
81
+
82
+ ### SPARC Methodology
83
+ `sparc-coord`, `sparc-coder`, `specification`, `pseudocode`, `architecture`, `refinement`
84
+
85
+ ### Specialized Development
86
+ `backend-dev`, `mobile-dev`, `ml-developer`, `cicd-engineer`, `api-docs`, `system-architect`, `code-analyzer`, `base-template-generator`
87
+
88
+ ### Testing & Validation
89
+ `tdd-london-swarm`, `production-validator`
90
+
91
+ ### Agent Routing (Anti-Drift)
92
+
93
+ | Code | Task | Agents |
94
+ |------|-------------|-------------------------------------------------|
95
+ | 1 | Bug Fix | coordinator, researcher, coder, tester |
96
+ | 3 | Feature | coordinator, architect, coder, tester, reviewer |
97
+ | 5 | Refactor | coordinator, architect, coder, reviewer |
98
+ | 7 | Performance | coordinator, perf-engineer, coder |
99
+ | 9 | Security | coordinator, security-architect, auditor |
100
+ | 11 | Docs | researcher, api-docs |
101
+
102
+ **Codes 1-9: hierarchical/specialized (anti-drift). Code 11: mesh/balanced.**
103
+
104
+ ---
105
+
106
+ ## Hooks System (27 Hooks + 12 Workers)
107
+
108
+ ### All Available Hooks
109
+
110
+ | Hook | Description | Key Options |
111
+ |--------------------|------------------------------------------|---------------------------------------------|
112
+ | `pre-edit` | Get context before editing files | `--file`, `--operation` |
113
+ | `post-edit` | Record editing outcome for learning | `--file`, `--success`, `--train-neural` |
114
+ | `pre-command` | Assess risk before commands | `--command`, `--validate-safety` |
115
+ | `post-command` | Record command execution outcome | `--command`, `--track-metrics` |
116
+ | `pre-task` | Record task start, get agent suggestions | `--description`, `--coordinate-swarm` |
117
+ | `post-task` | Record task completion for learning | `--task-id`, `--success`, `--store-results` |
118
+ | `session-start` | Start/restore session | `--session-id`, `--auto-configure` |
119
+ | `session-end` | End session and persist state | `--generate-summary`, `--export-metrics` |
120
+ | `session-restore` | Restore a previous session | `--session-id`, `--latest` |
121
+ | `route` | Route task to optimal agent | `--task`, `--context`, `--top-k` |
122
+ | `explain` | Explain routing decision | `--topic`, `--detailed` |
123
+ | `pretrain` | Bootstrap intelligence from repo | `--model-type`, `--epochs` |
124
+ | `build-agents` | Generate optimized agent configs | `--agent-types`, `--focus` |
125
+ | `metrics` | View learning metrics dashboard | `--v3-dashboard`, `--format` |
126
+ | `transfer` | Transfer patterns via IPFS registry | `store`, `from-project` |
127
+ | `intelligence` | RuVector intelligence system | `trajectory-*`, `pattern-*`, `stats` |
128
+ | `worker` | Background worker management | `list`, `dispatch`, `status`, `detect` |
129
+ | `coverage-route` | Route based on test coverage gaps | `--task`, `--path` |
130
+ | `coverage-suggest` | Suggest coverage improvements | `--path` |
131
+ | `coverage-gaps` | List coverage gaps with priorities | `--format`, `--limit` |
132
+
133
+ ### 12 Background Workers
134
+
135
+ | Worker | Priority | Description |
136
+ |---------------|----------|----------------------------|
137
+ | `ultralearn` | normal | Deep knowledge acquisition |
138
+ | `optimize` | high | Performance optimization |
139
+ | `consolidate` | low | Memory consolidation |
140
+ | `predict` | normal | Predictive preloading |
141
+ | `audit` | critical | Security analysis |
142
+ | `map` | normal | Codebase mapping |
143
+ | `preload` | low | Resource preloading |
144
+ | `deepdive` | normal | Deep code analysis |
145
+ | `document` | normal | Auto-documentation |
146
+ | `refactor` | normal | Refactoring suggestions |
147
+ | `benchmark` | normal | Performance benchmarking |
148
+ | `testgaps` | normal | Test coverage analysis |
149
+
150
+ ### Essential Hook Commands (MCP Preferred)
151
+
152
+ | Hook | MCP Tool | Key Params |
153
+ |------|----------|------------|
154
+ | Pre-task | `mcp__moflo__hooks_pre-task` | `description` |
155
+ | Post-task | `mcp__moflo__hooks_post-task` | `taskId`, `success` |
156
+ | Post-edit | `mcp__moflo__hooks_post-edit` | `file`, `trainNeural` |
157
+ | Session-start | `mcp__moflo__hooks_session-start` | `sessionId` |
158
+ | Session-end | `mcp__moflo__hooks_session-end` | `exportMetrics` |
159
+ | Route | `mcp__moflo__hooks_route` | `task` |
160
+ | Worker-dispatch | `mcp__moflo__hooks_worker-dispatch` | `trigger` |
161
+
162
+ ---
163
+
164
+ ## Hive-Mind Consensus
165
+
166
+ ### Topologies
167
+
168
+ - `hierarchical` — Queen controls workers directly
169
+ - `mesh` — Fully connected peer network
170
+ - `hierarchical-mesh` — Hybrid (recommended)
171
+ - `adaptive` — Dynamic based on load
172
+
173
+ ### Consensus Strategies
174
+
175
+ - `byzantine` — BFT (tolerates f < n/3 faulty)
176
+ - `raft` — Leader-based (tolerates f < n/2)
177
+ - `gossip` — Epidemic for eventual consistency
178
+ - `crdt` — Conflict-free replicated data types
179
+ - `quorum` — Configurable quorum-based
180
+
181
+ ---
182
+
183
+ ## RuVector Integration (HNSW Vector Search)
184
+
185
+ | Feature | Performance | Description |
186
+ |---------|-------------|-------------|
187
+ | **HNSW Index** | 150x–12,500x faster | Hierarchical Navigable Small World search |
188
+ | **MicroLoRA** | <100µs adaptation | Fast model adaptation (508k+ ops/sec) |
189
+ | **FlashAttention** | 2.49x–7.47x speedup | Optimized attention computation |
190
+ | **Int8 Quantization** | 3.92x memory reduction | Compressed weight storage |
191
+
192
+ ---
193
+
194
+ ## See Also
195
+
196
+ - `.claude/guidance/shipped/moflo-core-guidance.md` — Hub: getting started, MCP setup, troubleshooting, comparison table
197
+ - `.claude/guidance/shipped/moflo-yaml-reference.md` — `moflo.yaml` schema and runtime env-var overrides for the surfaces listed here
198
+ - `.claude/guidance/shipped/moflo-claude-swarm-cohesion.md` — How TaskCreate + swarm coordinators cooperate (uses the agent codes above)
199
+ - `.claude/guidance/shipped/moflo-subagents.md` — Subagent memory-first protocol and store-back rules
200
+ - `.claude/guidance/shipped/moflo-memory-strategy.md` — Memory namespaces, RAG linking, and search query patterns
201
+ - `.claude/guidance/shipped/moflo-memorydb-maintenance.md` — How the namespaces above are populated and refreshed