moflo 4.8.9 → 4.8.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.
- package/.claude/agents/core/coder.md +265 -265
- package/.claude/agents/core/planner.md +167 -167
- package/.claude/agents/core/researcher.md +189 -189
- package/.claude/agents/core/reviewer.md +325 -325
- package/.claude/agents/core/tester.md +318 -318
- package/.claude/agents/dual-mode/codex-coordinator.md +224 -224
- package/.claude/agents/dual-mode/codex-worker.md +211 -211
- package/.claude/agents/dual-mode/dual-orchestrator.md +291 -291
- package/.claude/agents/github/code-review-swarm.md +537 -537
- package/.claude/agents/github/github-modes.md +172 -172
- package/.claude/agents/github/issue-tracker.md +318 -318
- package/.claude/agents/github/multi-repo-swarm.md +552 -552
- package/.claude/agents/github/pr-manager.md +190 -190
- package/.claude/agents/github/project-board-sync.md +508 -508
- package/.claude/agents/github/release-manager.md +366 -366
- package/.claude/agents/github/release-swarm.md +582 -582
- package/.claude/agents/github/repo-architect.md +397 -397
- package/.claude/agents/github/swarm-issue.md +572 -572
- package/.claude/agents/github/swarm-pr.md +427 -427
- package/.claude/agents/github/sync-coordinator.md +451 -451
- package/.claude/agents/github/workflow-automation.md +634 -634
- package/.claude/agents/goal/code-goal-planner.md +445 -445
- package/.claude/agents/hive-mind/collective-intelligence-coordinator.md +129 -129
- package/.claude/agents/hive-mind/queen-coordinator.md +202 -202
- package/.claude/agents/hive-mind/scout-explorer.md +241 -241
- package/.claude/agents/hive-mind/swarm-memory-manager.md +192 -192
- package/.claude/agents/hive-mind/worker-specialist.md +216 -216
- package/.claude/agents/neural/safla-neural.md +73 -73
- package/.claude/agents/reasoning/goal-planner.md +72 -72
- package/.claude/agents/swarm/adaptive-coordinator.md +395 -395
- package/.claude/agents/swarm/hierarchical-coordinator.md +326 -326
- package/.claude/agents/swarm/mesh-coordinator.md +391 -391
- package/.claude/agents/templates/migration-plan.md +745 -745
- package/.claude/commands/agents/agent-spawning.md +28 -28
- package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +53 -53
- package/.claude/commands/analysis/bottleneck-detect.md +162 -162
- package/.claude/commands/analysis/performance-bottlenecks.md +58 -58
- package/.claude/commands/analysis/token-efficiency.md +44 -44
- package/.claude/commands/automation/auto-agent.md +122 -122
- package/.claude/commands/automation/self-healing.md +105 -105
- package/.claude/commands/automation/session-memory.md +89 -89
- package/.claude/commands/automation/smart-agents.md +72 -72
- package/.claude/commands/coordination/init.md +44 -44
- package/.claude/commands/coordination/orchestrate.md +43 -43
- package/.claude/commands/coordination/spawn.md +45 -45
- package/.claude/commands/coordination/swarm-init.md +85 -85
- package/.claude/commands/github/github-modes.md +146 -146
- package/.claude/commands/github/github-swarm.md +121 -121
- package/.claude/commands/github/issue-tracker.md +291 -291
- package/.claude/commands/github/pr-manager.md +169 -169
- package/.claude/commands/github/release-manager.md +337 -337
- package/.claude/commands/github/repo-architect.md +366 -366
- package/.claude/commands/github/sync-coordinator.md +300 -300
- package/.claude/commands/memory/neural.md +47 -47
- package/.claude/commands/monitoring/agents.md +44 -44
- package/.claude/commands/monitoring/status.md +46 -46
- package/.claude/commands/optimization/auto-topology.md +61 -61
- package/.claude/commands/optimization/parallel-execution.md +49 -49
- package/.claude/commands/sparc/analyzer.md +51 -51
- package/.claude/commands/sparc/architect.md +53 -53
- package/.claude/commands/sparc/ask.md +97 -97
- package/.claude/commands/sparc/batch-executor.md +54 -54
- package/.claude/commands/sparc/code.md +89 -89
- package/.claude/commands/sparc/coder.md +54 -54
- package/.claude/commands/sparc/debug.md +83 -83
- package/.claude/commands/sparc/debugger.md +54 -54
- package/.claude/commands/sparc/designer.md +53 -53
- package/.claude/commands/sparc/devops.md +109 -109
- package/.claude/commands/sparc/docs-writer.md +80 -80
- package/.claude/commands/sparc/documenter.md +54 -54
- package/.claude/commands/sparc/innovator.md +54 -54
- package/.claude/commands/sparc/integration.md +83 -83
- package/.claude/commands/sparc/mcp.md +117 -117
- package/.claude/commands/sparc/memory-manager.md +54 -54
- package/.claude/commands/sparc/optimizer.md +54 -54
- package/.claude/commands/sparc/orchestrator.md +131 -131
- package/.claude/commands/sparc/post-deployment-monitoring-mode.md +83 -83
- package/.claude/commands/sparc/refinement-optimization-mode.md +83 -83
- package/.claude/commands/sparc/researcher.md +54 -54
- package/.claude/commands/sparc/reviewer.md +54 -54
- package/.claude/commands/sparc/security-review.md +80 -80
- package/.claude/commands/sparc/sparc-modes.md +174 -174
- package/.claude/commands/sparc/sparc.md +111 -111
- package/.claude/commands/sparc/spec-pseudocode.md +80 -80
- package/.claude/commands/sparc/supabase-admin.md +348 -348
- package/.claude/commands/sparc/swarm-coordinator.md +54 -54
- package/.claude/commands/sparc/tdd.md +54 -54
- package/.claude/commands/sparc/tester.md +54 -54
- package/.claude/commands/sparc/tutorial.md +79 -79
- package/.claude/commands/sparc/workflow-manager.md +54 -54
- package/.claude/commands/sparc.md +166 -166
- package/.claude/commands/swarm/analysis.md +95 -95
- package/.claude/commands/swarm/development.md +96 -96
- package/.claude/commands/swarm/examples.md +168 -168
- package/.claude/commands/swarm/maintenance.md +102 -102
- package/.claude/commands/swarm/optimization.md +117 -117
- package/.claude/commands/swarm/research.md +136 -136
- package/.claude/commands/swarm/testing.md +131 -131
- package/.claude/commands/training/neural-patterns.md +73 -73
- package/.claude/commands/training/specialization.md +62 -62
- package/.claude/commands/workflows/development.md +77 -77
- package/.claude/commands/workflows/research.md +62 -62
- package/.claude/guidance/{agent-bootstrap.md → shipped/agent-bootstrap.md} +126 -126
- package/.claude/guidance/{guidance-memory-strategy.md → shipped/guidance-memory-strategy.md} +262 -262
- package/.claude/guidance/{memory-strategy.md → shipped/memory-strategy.md} +204 -204
- package/.claude/guidance/{moflo.md → shipped/moflo.md} +45 -31
- package/.claude/guidance/{task-swarm-integration.md → shipped/task-swarm-integration.md} +441 -348
- package/.claude/helpers/gate.cjs +236 -236
- package/.claude/helpers/hook-handler.cjs +42 -46
- package/.claude/settings.json +2 -2
- package/.claude/settings.local.json +3 -3
- package/.claude/skills/fl/SKILL.md +29 -23
- package/.claude/skills/flo/SKILL.md +29 -23
- package/.claude/skills/github-code-review/SKILL.md +4 -4
- package/.claude/skills/github-multi-repo/SKILL.md +8 -8
- package/.claude/skills/github-project-management/SKILL.md +6 -6
- package/.claude/skills/github-release-management/SKILL.md +12 -12
- package/.claude/skills/github-workflow-automation/SKILL.md +6 -6
- package/.claude/skills/hooks-automation/SKILL.md +1201 -1201
- package/.claude/skills/performance-analysis/SKILL.md +563 -563
- package/.claude/skills/sparc-methodology/SKILL.md +64 -64
- package/.claude/skills/swarm-advanced/SKILL.md +77 -77
- package/.claude-plugin/README.md +3 -3
- package/.claude-plugin/docs/PLUGIN_SUMMARY.md +3 -3
- package/.claude-plugin/docs/QUICKSTART.md +4 -4
- package/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +3 -3
- package/.claude-plugin/scripts/install.sh +9 -9
- package/.claude-plugin/scripts/verify.sh +7 -7
- package/README.md +311 -116
- package/bin/gate-hook.mjs +50 -0
- package/bin/gate.cjs +138 -0
- package/bin/hook-handler.cjs +83 -0
- package/bin/hooks.mjs +72 -12
- package/bin/index-guidance.mjs +28 -34
- package/bin/index-tests.mjs +710 -0
- package/bin/lib/process-manager.mjs +243 -0
- package/bin/lib/registry-cleanup.cjs +41 -0
- package/bin/prompt-hook.mjs +72 -0
- package/bin/semantic-search.mjs +473 -441
- package/bin/session-start-launcher.mjs +81 -31
- package/bin/setup-project.mjs +13 -10
- package/package.json +4 -2
- package/src/@claude-flow/cli/README.md +1 -1
- package/src/@claude-flow/cli/bin/cli.js +175 -175
- package/src/@claude-flow/cli/dist/src/commands/doctor.js +1091 -736
- package/src/@claude-flow/cli/dist/src/commands/github.d.ts +12 -0
- package/src/@claude-flow/cli/dist/src/commands/github.js +505 -0
- package/src/@claude-flow/cli/dist/src/commands/hive-mind.js +90 -90
- package/src/@claude-flow/cli/dist/src/commands/index.d.ts +1 -0
- package/src/@claude-flow/cli/dist/src/commands/index.js +7 -0
- package/src/@claude-flow/cli/dist/src/config-adapter.js +1 -1
- package/src/@claude-flow/cli/dist/src/init/claudemd-generator.js +1 -1
- package/src/@claude-flow/cli/dist/src/init/executor.js +109 -5
- package/src/@claude-flow/cli/dist/src/init/helpers-generator.d.ts +14 -0
- package/src/@claude-flow/cli/dist/src/init/helpers-generator.js +156 -24
- package/src/@claude-flow/cli/dist/src/init/mcp-generator.js +20 -20
- package/src/@claude-flow/cli/dist/src/init/moflo-init.d.ts +7 -0
- package/src/@claude-flow/cli/dist/src/init/moflo-init.js +72 -10
- package/src/@claude-flow/cli/dist/src/init/settings-generator.js +23 -14
- package/src/@claude-flow/cli/dist/src/mcp-server.js +3 -3
- package/src/@claude-flow/cli/dist/src/plugins/manager.js +9 -8
- package/src/@claude-flow/cli/dist/src/services/worker-daemon.d.ts +1 -0
- package/src/@claude-flow/cli/dist/src/services/worker-daemon.js +3 -1
- package/src/@claude-flow/cli/dist/src/services/workflow-gate.js +10 -10
- package/src/@claude-flow/cli/package.json +1 -1
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"node": ">=20.0.0"
|
|
50
50
|
},
|
|
51
51
|
"mcpServers": {
|
|
52
|
-
"
|
|
52
|
+
"moflo": {
|
|
53
53
|
"command": "npx",
|
|
54
|
-
"args": ["
|
|
55
|
-
"description": "Core
|
|
54
|
+
"args": ["moflo", "mcp", "start"],
|
|
55
|
+
"description": "Core MoFlo MCP server for swarm coordination, agent management, and task orchestration (40+ tools)",
|
|
56
56
|
"optional": false
|
|
57
57
|
},
|
|
58
58
|
"ruv-swarm": {
|
|
@@ -135,15 +135,15 @@ if [ "$INSTALL_TYPE" = "1" ] || [ "$INSTALL_TYPE" = "4" ]; then
|
|
|
135
135
|
cat > "$SETTINGS_FILE" << 'SETTINGS_EOF'
|
|
136
136
|
{
|
|
137
137
|
"mcpServers": {
|
|
138
|
-
"
|
|
138
|
+
"moflo": {
|
|
139
139
|
"command": "npx",
|
|
140
|
-
"args": ["
|
|
141
|
-
"description": "Core
|
|
140
|
+
"args": ["moflo", "mcp", "start"],
|
|
141
|
+
"description": "Core MoFlo MCP server with 40+ orchestration tools"
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
SETTINGS_EOF
|
|
146
|
-
success "Created settings.json with
|
|
146
|
+
success "Created settings.json with MoFlo MCP server"
|
|
147
147
|
else
|
|
148
148
|
info "Settings file exists. Please manually add MCP servers:"
|
|
149
149
|
echo ""
|
|
@@ -152,9 +152,9 @@ Add to ~/.claude/settings.json:
|
|
|
152
152
|
|
|
153
153
|
{
|
|
154
154
|
"mcpServers": {
|
|
155
|
-
"
|
|
155
|
+
"moflo": {
|
|
156
156
|
"command": "npx",
|
|
157
|
-
"args": ["
|
|
157
|
+
"args": ["moflo", "mcp", "start"]
|
|
158
158
|
},
|
|
159
159
|
"ruv-swarm": {
|
|
160
160
|
"command": "npx",
|
|
@@ -175,9 +175,9 @@ MCP_INSTRUCTIONS
|
|
|
175
175
|
INSTALL_MCP=${INSTALL_MCP:-y}
|
|
176
176
|
|
|
177
177
|
if [ "$INSTALL_MCP" = "y" ]; then
|
|
178
|
-
info "Installing
|
|
179
|
-
npx
|
|
180
|
-
success "
|
|
178
|
+
info "Installing moflo MCP server..."
|
|
179
|
+
npx moflo --version 2>/dev/null || npm install -g moflo
|
|
180
|
+
success "MoFlo MCP server installed"
|
|
181
181
|
|
|
182
182
|
read -p "Install optional ruv-swarm MCP? (y/n) [n]: " INSTALL_RUV
|
|
183
183
|
if [ "$INSTALL_RUV" = "y" ]; then
|
|
@@ -56,10 +56,10 @@ info "Checking Claude Code settings..."
|
|
|
56
56
|
if [ -f "$HOME/.claude/settings.json" ]; then
|
|
57
57
|
success "Settings file exists"
|
|
58
58
|
|
|
59
|
-
if grep -q "claude-flow" "$HOME/.claude/settings.json"; then
|
|
60
|
-
success "
|
|
59
|
+
if grep -q '"moflo"' "$HOME/.claude/settings.json" || grep -q '"claude-flow"' "$HOME/.claude/settings.json"; then
|
|
60
|
+
success "MoFlo MCP server configured"
|
|
61
61
|
else
|
|
62
|
-
warning "
|
|
62
|
+
warning "MoFlo MCP server not configured"
|
|
63
63
|
((WARNINGS++))
|
|
64
64
|
fi
|
|
65
65
|
else
|
|
@@ -69,11 +69,11 @@ fi
|
|
|
69
69
|
|
|
70
70
|
# Check MCP packages
|
|
71
71
|
info "Checking MCP packages..."
|
|
72
|
-
if npx
|
|
73
|
-
VERSION=$(npx
|
|
74
|
-
success "
|
|
72
|
+
if npx moflo --version &> /dev/null; then
|
|
73
|
+
VERSION=$(npx moflo --version 2>/dev/null || echo "unknown")
|
|
74
|
+
success "moflo MCP: $VERSION"
|
|
75
75
|
else
|
|
76
|
-
warning "
|
|
76
|
+
warning "moflo MCP not installed"
|
|
77
77
|
((WARNINGS++))
|
|
78
78
|
fi
|
|
79
79
|
|
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
**An opinionated fork of [Ruflo/Claude Flow](https://github.com/ruvnet/ruflo), optimized for local development.**
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## TL;DR
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
MoFlo makes your AI coding assistant remember what it learns, check what it knows before exploring files, and get smarter over time — all automatically. Install it, run `flo init`, restart your AI client, and everything just works: your docs and code are indexed on session start so the AI can search them instantly, workflow gates prevent the AI from wasting tokens on blind exploration, task outcomes feed back into routing so it picks the right agent type next time, and context depletion warnings tell you when to start a fresh session. No configuration, no API keys, no cloud services — it all runs locally on your machine.
|
|
12
12
|
|
|
13
13
|
## Opinionated Defaults
|
|
14
14
|
|
|
@@ -56,12 +56,13 @@ npm install --save-dev moflo
|
|
|
56
56
|
npx flo init
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
`flo init` automatically scans your project to find where your guidance and
|
|
59
|
+
`flo init` automatically scans your project to find where your guidance, code, and tests live, then writes the results into `moflo.yaml`. It looks for:
|
|
60
60
|
|
|
61
61
|
| What | Directories it checks | Default if none found |
|
|
62
62
|
|------|----------------------|----------------------|
|
|
63
63
|
| **Guidance** | `.claude/guidance`, `docs/guides`, `docs`, `architecture`, `adr`, `.cursor/rules` | `.claude/guidance` |
|
|
64
64
|
| **Source code** | `src`, `packages`, `lib`, `app`, `apps`, `services`, `server`, `client` | `src` |
|
|
65
|
+
| **Tests** | `tests`, `test`, `__tests__`, `spec`, `e2e`, plus `__tests__` dirs inside `src/` | `tests` |
|
|
65
66
|
| **Languages** | Scans detected source dirs for file extensions | `.ts`, `.tsx`, `.js`, `.jsx` |
|
|
66
67
|
|
|
67
68
|
It also generates:
|
|
@@ -76,6 +77,20 @@ It also generates:
|
|
|
76
77
|
|
|
77
78
|
In interactive mode (`flo init` without `--yes`), it shows what it found and lets you confirm or adjust before writing.
|
|
78
79
|
|
|
80
|
+
#### Migrating from Claude Flow / Ruflo
|
|
81
|
+
|
|
82
|
+
If `flo init` detects an existing `.claude/settings.json` or `.claude-flow/` directory (from a prior Claude Flow or Ruflo installation), it treats the project as already initialized and runs in **update mode** — merging MoFlo's hooks and configuration into your existing setup without overwriting your data. Specifically:
|
|
83
|
+
|
|
84
|
+
- **Hooks** — If your `.claude/settings.json` already has MoFlo-style gate hooks (`flo gate`), the hooks step is skipped. Otherwise, MoFlo's hooks are written into the file (existing non-MoFlo hooks are not removed).
|
|
85
|
+
- **MCP servers** — MoFlo registers itself as the `moflo` server in `.mcp.json`. If you had `claude-flow` or `ruflo` MCP servers configured previously, those entries remain untouched — you can remove them manually once you've verified MoFlo is working. The `flo doctor` command checks for the `moflo` server specifically.
|
|
86
|
+
- **Config files** — `moflo.yaml`, `CLAUDE.md`, and `.claude/skills/flo/` follow the same skip-if-exists logic. Use `--force` to regenerate them.
|
|
87
|
+
|
|
88
|
+
To force a clean re-initialization over an existing setup:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npx flo init --force
|
|
92
|
+
```
|
|
93
|
+
|
|
79
94
|
### 2. Review your guidance and code settings
|
|
80
95
|
|
|
81
96
|
Open `moflo.yaml` to see what init detected. The two key sections:
|
|
@@ -100,7 +115,20 @@ code_map:
|
|
|
100
115
|
exclude: [node_modules, dist, .next, coverage]
|
|
101
116
|
```
|
|
102
117
|
|
|
103
|
-
|
|
118
|
+
**Tests** — test files to index for "what tests cover X?" reverse mapping:
|
|
119
|
+
|
|
120
|
+
```yaml
|
|
121
|
+
tests:
|
|
122
|
+
directories:
|
|
123
|
+
- tests # your test files
|
|
124
|
+
- __tests__ # jest-style test dirs
|
|
125
|
+
patterns: ["*.test.*", "*.spec.*", "*.test-*"]
|
|
126
|
+
extensions: [".ts", ".tsx", ".js", ".jsx"]
|
|
127
|
+
exclude: [node_modules, coverage, dist]
|
|
128
|
+
namespace: tests
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
MoFlo chunks your guidance files into semantic embeddings, indexes your code structure, and maps test files back to their source targets — so Claude searches your knowledge base before touching any files. Adjust these directories to match your project:
|
|
104
132
|
|
|
105
133
|
```yaml
|
|
106
134
|
# Monorepo with shared docs
|
|
@@ -128,6 +156,83 @@ Both indexes run automatically at session start after this, so you only need to
|
|
|
128
156
|
npx flo memory refresh # Reindex all content, rebuild embeddings, cleanup, vacuum
|
|
129
157
|
```
|
|
130
158
|
|
|
159
|
+
## Auto-Indexing
|
|
160
|
+
|
|
161
|
+
MoFlo automatically indexes three types of content on every session start, so your AI assistant always has up-to-date knowledge without manual intervention.
|
|
162
|
+
|
|
163
|
+
### What gets indexed
|
|
164
|
+
|
|
165
|
+
| Index | Content | What it produces | Namespace |
|
|
166
|
+
|-------|---------|------------------|-----------|
|
|
167
|
+
| **Guidance** | Markdown files in your guidance directories (`.claude/guidance/`, `docs/`, etc.) | Chunked text with 384-dim semantic embeddings — enables natural-language search across your project documentation | `guidance` |
|
|
168
|
+
| **Code map** | Source files in your code directories (`src/`, `packages/`, etc.) | Structural index of exports, classes, functions, and types — enables "where does X live?" navigation without Glob/Grep | `code-map` |
|
|
169
|
+
| **Tests** | Test files matching configured patterns (`*.test.*`, `*.spec.*`) | Reverse mapping from test files to their source targets — enables "what tests cover X?" lookups | `tests` |
|
|
170
|
+
|
|
171
|
+
### How it works
|
|
172
|
+
|
|
173
|
+
1. **Session start hook** — When your AI client starts a new session, MoFlo's `SessionStart` hook launches three indexers in parallel as background processes.
|
|
174
|
+
2. **Incremental** — Each indexer tracks file modification times. Only files that changed since the last index run are re-processed. The first run takes longer; subsequent runs typically finish in under a second.
|
|
175
|
+
3. **Embedding generation** — Guidance chunks are embedded using MiniLM-L6-v2 (384 dimensions, WASM). These vectors are stored in the SQLite memory database and used for semantic search.
|
|
176
|
+
4. **No blocking** — The indexers run in the background and don't block your session from starting. You can begin working immediately.
|
|
177
|
+
|
|
178
|
+
### Configuration
|
|
179
|
+
|
|
180
|
+
Each indexer can be toggled independently in `moflo.yaml`:
|
|
181
|
+
|
|
182
|
+
```yaml
|
|
183
|
+
auto_index:
|
|
184
|
+
guidance: true # Index docs on session start
|
|
185
|
+
code_map: true # Index code structure on session start
|
|
186
|
+
tests: true # Index test files on session start
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Set any to `false` to disable that indexer. The underlying data remains in memory — you just stop refreshing it automatically. You can still run indexers manually:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
npx flo memory index-guidance # Manual guidance reindex
|
|
193
|
+
npx flo memory code-map # Manual code map reindex
|
|
194
|
+
npx flo memory refresh # Reindex everything + rebuild embeddings + vacuum
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Why this matters
|
|
198
|
+
|
|
199
|
+
Without auto-indexing, your AI assistant starts every session with a blank slate — it doesn't know what documentation exists, where code lives, or what tests cover which files. It resorts to Glob/Grep exploration, which burns tokens and context window on rediscovery.
|
|
200
|
+
|
|
201
|
+
With auto-indexing, the AI can search semantically ("how does auth work?") and get relevant documentation chunks ranked by similarity, or ask "where is the user model defined?" and get a direct answer from the code map — all without touching the filesystem.
|
|
202
|
+
|
|
203
|
+
## The Gate System
|
|
204
|
+
|
|
205
|
+
MoFlo installs Claude Code hooks that run on every tool call. Together, these gates create a **feedback loop** that prevents Claude from wasting tokens on blind exploration and ensures it builds on prior knowledge.
|
|
206
|
+
|
|
207
|
+
### Gates explained
|
|
208
|
+
|
|
209
|
+
| Gate | What it enforces | When it triggers | Why it matters |
|
|
210
|
+
|------|-----------------|------------------|----------------|
|
|
211
|
+
| **Memory-first** | Claude must search the memory database before using Glob, Grep, or Read on guidance files | Before every Glob/Grep call, and before Read calls targeting `.claude/guidance/` | Prevents the AI from re-exploring files it (or a previous session) already indexed. Forces it to check what it knows first, saving tokens and context window. |
|
|
212
|
+
| **TaskCreate-first** | Claude must call TaskCreate before spawning sub-agents via the Task tool | Before every Task (agent spawn) call | Ensures every piece of delegated work is tracked. Prevents runaway agent proliferation where Claude spawns agents without a clear plan. |
|
|
213
|
+
| **Context tracking** | Tracks conversation length and warns about context depletion | On every user prompt (UserPromptSubmit hook) | As conversations grow, AI quality degrades. MoFlo tracks interaction count and assigns a bracket (FRESH → MODERATE → DEPLETED → CRITICAL), advising Claude to checkpoint progress or start a fresh session before quality drops. |
|
|
214
|
+
| **Routing** | Analyzes each prompt and recommends the optimal agent type and model tier | On every user prompt (UserPromptSubmit hook) | Saves cost by suggesting haiku for simple tasks, sonnet for moderate ones, opus for complex reasoning — without you having to think about model selection. |
|
|
215
|
+
|
|
216
|
+
### Smart classification
|
|
217
|
+
|
|
218
|
+
The memory-first gate doesn't blindly block every request. It classifies each prompt:
|
|
219
|
+
|
|
220
|
+
- **Simple directives** (e.g., "commit", "yes", "continue", "looks good") — skip the gate entirely, no memory search required
|
|
221
|
+
- **Task-oriented prompts** (e.g., "fix the auth bug", "add pagination to the API") — gate enforced, must search memory first
|
|
222
|
+
|
|
223
|
+
### Disabling gates
|
|
224
|
+
|
|
225
|
+
All gates are configurable in `moflo.yaml`:
|
|
226
|
+
|
|
227
|
+
```yaml
|
|
228
|
+
gates:
|
|
229
|
+
memory_first: true # Set to false to disable memory-first enforcement
|
|
230
|
+
task_create_first: true # Set to false to disable TaskCreate enforcement
|
|
231
|
+
context_tracking: true # Set to false to disable context bracket warnings
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
You can also disable individual hooks in `.claude/settings.json` by removing the corresponding hook entries.
|
|
235
|
+
|
|
131
236
|
## The `/flo` Skill
|
|
132
237
|
|
|
133
238
|
Inside your AI client, the `/flo` (or `/fl`) slash command drives GitHub issue workflows:
|
|
@@ -245,11 +350,77 @@ flo gate session-reset # Reset workflow state
|
|
|
245
350
|
|
|
246
351
|
```bash
|
|
247
352
|
flo doctor # Quick health check (environment, deps, config)
|
|
353
|
+
flo doctor --fix # Auto-fix issues (memory DB, daemon, config, MCP, zombies)
|
|
248
354
|
flo diagnose # Full integration test (memory, swarm, hive, hooks, neural)
|
|
249
355
|
flo diagnose --suite memory # Run only memory tests
|
|
250
356
|
flo diagnose --json # JSON output for CI/automation
|
|
251
357
|
```
|
|
252
358
|
|
|
359
|
+
#### `flo doctor` — Health Check
|
|
360
|
+
|
|
361
|
+
`flo doctor` runs 16 parallel health checks against your environment and reports pass/warn/fail for each:
|
|
362
|
+
|
|
363
|
+
| Check | What it verifies |
|
|
364
|
+
|-------|-----------------|
|
|
365
|
+
| **Version Freshness** | Whether your installed MoFlo version matches the latest on npm (detects stale npx cache) |
|
|
366
|
+
| **Node.js Version** | Node.js >= 20 installed |
|
|
367
|
+
| **npm Version** | npm >= 9 installed |
|
|
368
|
+
| **Claude Code CLI** | `claude` command available |
|
|
369
|
+
| **Git** | Git installed and project is a git repository |
|
|
370
|
+
| **Config File** | Valid `moflo.yaml` or `.claude-flow/config.yaml` exists |
|
|
371
|
+
| **Daemon Status** | Background daemon running (checks PID, cleans stale locks) |
|
|
372
|
+
| **Memory Database** | SQLite memory DB exists and is accessible |
|
|
373
|
+
| **Embeddings** | Vectors indexed in memory DB, HNSW index present |
|
|
374
|
+
| **Test Directories** | Test dirs from `moflo.yaml` exist on disk, reports auto-index status |
|
|
375
|
+
| **MCP Servers** | `moflo` MCP server configured in `.mcp.json` |
|
|
376
|
+
| **Disk Space** | Sufficient free disk space (warns at 80%, fails at 90%) |
|
|
377
|
+
| **TypeScript** | TypeScript compiler available |
|
|
378
|
+
| **agentic-flow** | Optional agentic-flow package installed (for enhanced embeddings/routing) |
|
|
379
|
+
| **Zombie Processes** | No orphaned MoFlo node processes running |
|
|
380
|
+
|
|
381
|
+
**Auto-fix mode** (`flo doctor --fix`) attempts to repair each failing check automatically:
|
|
382
|
+
|
|
383
|
+
| Issue | What `--fix` does |
|
|
384
|
+
|-------|------------------|
|
|
385
|
+
| Missing memory database | Creates `.swarm/` directory and initializes the SQLite DB |
|
|
386
|
+
| Embeddings not initialized | Initializes memory DB and runs `embeddings init` |
|
|
387
|
+
| Missing config file | Runs `config init` to generate defaults |
|
|
388
|
+
| Stale daemon lock | Removes stale `.claude-flow/daemon.lock` and restarts daemon |
|
|
389
|
+
| MCP server not configured | Runs `claude mcp add moflo` to register the server |
|
|
390
|
+
| Claude Code CLI missing | Installs `@anthropic-ai/claude-code` globally |
|
|
391
|
+
| Zombie processes | Kills orphaned MoFlo processes (tracked + OS-level scan) |
|
|
392
|
+
|
|
393
|
+
After auto-fixing, doctor re-runs all checks and shows the updated results. Issues that can't be fixed automatically are listed with manual fix commands.
|
|
394
|
+
|
|
395
|
+
Additional flags:
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
flo doctor --install # Auto-install missing Claude Code CLI
|
|
399
|
+
flo doctor --kill-zombies # Find and kill orphaned MoFlo processes
|
|
400
|
+
flo doctor -c memory # Check only a specific component
|
|
401
|
+
flo doctor -c embeddings # Check only embeddings health
|
|
402
|
+
flo doctor --verbose # Verbose output
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
#### `flo diagnose` — Integration Tests
|
|
406
|
+
|
|
407
|
+
While `doctor` checks your environment, `diagnose` exercises every subsystem end-to-end: memory CRUD, embedding generation, semantic search, swarm lifecycle, hive-mind consensus, task management, hooks, config, neural patterns, and init idempotency. All test data is cleaned up after each test — nothing is left behind.
|
|
408
|
+
|
|
409
|
+
### GitHub Repository Setup
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
flo github setup # One-shot: generate CI + apply repo settings + branch protection
|
|
413
|
+
flo github setup --dry-run # Preview everything without making changes
|
|
414
|
+
flo github ci # Generate .github/workflows/ci.yml from project config
|
|
415
|
+
flo github ci --dry-run # Print workflow to stdout
|
|
416
|
+
flo github settings # Apply repo settings + branch protection via gh CLI
|
|
417
|
+
flo github settings --dry-run # Preview settings changes
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
`flo github ci` auto-detects your package manager (npm/pnpm/yarn/bun), TypeScript, and test directories from `moflo.yaml` and `package.json`, then generates a CI workflow with install, build, lint, type-check, and test steps.
|
|
421
|
+
|
|
422
|
+
`flo github settings` applies recommended defaults via `gh` CLI: delete-branch-on-merge, squash merge with PR title/body, auto-merge, linear history, and configurable branch protection (required reviews, dismiss stale reviews, block force pushes). Requires `gh auth login`.
|
|
423
|
+
|
|
253
424
|
### System
|
|
254
425
|
|
|
255
426
|
```bash
|
|
@@ -257,6 +428,134 @@ flo init # Initialize project (one-time setup)
|
|
|
257
428
|
flo --version # Show version
|
|
258
429
|
```
|
|
259
430
|
|
|
431
|
+
## What Ships Out of the Box
|
|
432
|
+
|
|
433
|
+
`flo init` wires up the following systems automatically. Here's what each one does, why it matters, and whether it's enabled by default.
|
|
434
|
+
|
|
435
|
+
### Hooks (enabled OOTB)
|
|
436
|
+
|
|
437
|
+
Hooks are shell commands that Claude Code runs automatically at specific points in its workflow. MoFlo installs 14 hooks across 7 lifecycle events. You don't invoke these — they fire automatically.
|
|
438
|
+
|
|
439
|
+
| Hook Event | What fires | What it does | Enabled OOTB |
|
|
440
|
+
|------------|-----------|-------------|:---:|
|
|
441
|
+
| **PreToolUse: Write/Edit** | `flo hooks pre-edit` | Records which file is about to be edited, captures before-state for learning | Yes |
|
|
442
|
+
| **PreToolUse: Glob/Grep** | `flo gate check-before-scan` | Memory-first gate — blocks file exploration until memory is searched | Yes |
|
|
443
|
+
| **PreToolUse: Read** | `flo gate check-before-read` | Blocks reading guidance files directly until memory is searched | Yes |
|
|
444
|
+
| **PreToolUse: Task** | `flo gate check-before-agent` + `flo hooks pre-task` | TaskCreate gate + routing recommendation before agent spawn | Yes |
|
|
445
|
+
| **PreToolUse: Bash** | `flo gate check-dangerous-command` | Safety check on shell commands | Yes |
|
|
446
|
+
| **PostToolUse: Write/Edit** | `flo hooks post-edit` | Records edit outcome, optionally trains neural patterns | Yes |
|
|
447
|
+
| **PostToolUse: Task** | `flo hooks post-task` | Records task completion, feeds outcome into routing learner | Yes |
|
|
448
|
+
| **PostToolUse: TaskCreate** | `flo gate record-task-created` | Records that a task was registered (clears TaskCreate gate) | Yes |
|
|
449
|
+
| **PostToolUse: Bash** | `flo gate check-bash-memory` | Detects memory search commands in Bash (clears memory gate) | Yes |
|
|
450
|
+
| **PostToolUse: memory_search** | `flo gate record-memory-searched` | Records that memory was searched (clears memory-first gate) | Yes |
|
|
451
|
+
| **UserPromptSubmit** | `flo gate prompt-reminder` + `flo hooks route` | Resets per-prompt gate state, tracks context bracket, routes task to agent | Yes |
|
|
452
|
+
| **SessionStart** | `session-start-launcher.mjs` | Launches auto-indexers (guidance, code map, tests), restores session state | Yes |
|
|
453
|
+
| **Stop** | `flo hooks session-end` | Persists session metrics, exports learning data | Yes |
|
|
454
|
+
| **PreCompact** | `flo gate compact-guidance` | Injects guidance summary before context compaction | Yes |
|
|
455
|
+
| **Notification** | `flo hooks notification` | Routes Claude Code notifications through MoFlo | Yes |
|
|
456
|
+
|
|
457
|
+
### Systems (enabled OOTB)
|
|
458
|
+
|
|
459
|
+
These are the backend systems that hooks and commands interact with.
|
|
460
|
+
|
|
461
|
+
| System | What It Does | Why It Matters | Enabled OOTB |
|
|
462
|
+
|--------|-------------|----------------|:---:|
|
|
463
|
+
| **Semantic Memory** | SQLite database (sql.js/WASM) storing knowledge entries with 384-dim vector embeddings | Your AI assistant accumulates project knowledge across sessions instead of starting from scratch each time | Yes |
|
|
464
|
+
| **HNSW Vector Search** | Hierarchical Navigable Small World index for fast nearest-neighbor search | Searches across thousands of stored entries return in milliseconds instead of scanning linearly | Yes |
|
|
465
|
+
| **Guidance Indexing** | Chunks markdown docs into overlapping segments, embeds each with MiniLM-L6-v2 | Your project documentation becomes searchable by meaning ("how does auth work?") not just keywords | Yes |
|
|
466
|
+
| **Code Map** | Parses source files for exports, classes, functions, types | The AI can answer "where is X defined?" from the index instead of running Glob/Grep | Yes |
|
|
467
|
+
| **Test Indexing** | Maps test files to their source targets based on naming patterns | The AI can answer "what tests cover X?" and identify untested code | Yes |
|
|
468
|
+
| **Workflow Gates** | Hook-based enforcement of memory-first and task-registration patterns | Prevents the AI from wasting tokens on blind exploration and untracked agent spawns | Yes |
|
|
469
|
+
| **Context Tracking** | Interaction counter with bracket classification (FRESH/MODERATE/DEPLETED/CRITICAL) | Warns before context quality degrades, suggests when to checkpoint or start fresh | Yes |
|
|
470
|
+
| **Semantic Routing** | Matches task descriptions to agent types using vector similarity against 12 built-in patterns | Routes work to the right specialist (security-architect, tester, coder, etc.) automatically | Yes |
|
|
471
|
+
| **Learned Routing** | Records task outcomes (agent type + success/failure) and feeds them back into routing | Routing gets smarter over time — successful patterns are weighted higher in future recommendations | Yes |
|
|
472
|
+
| **SONA Learning** | Self-Optimizing Neural Architecture that learns from task trajectories | Adapts routing weights based on actual outcomes, not just keyword matching | Yes |
|
|
473
|
+
| **MicroLoRA Adaptation** | Rank-2 LoRA weight updates from successful patterns (~1µs per adapt) | Fine-grained model adaptation without full retraining | Yes |
|
|
474
|
+
| **EWC++ Consolidation** | Elastic Weight Consolidation that prevents catastrophic forgetting | New learning doesn't overwrite patterns from earlier sessions | Yes |
|
|
475
|
+
| **Session Persistence** | Stop hook exports session metrics; SessionStart hook restores prior state | Patterns learned on Monday are available on Friday | Yes |
|
|
476
|
+
| **Status Line** | Live dashboard showing git branch, session state, memory stats, MCP status | At-a-glance visibility into what MoFlo is doing | Yes |
|
|
477
|
+
| **MCP Tool Server** | 150+ MCP tools for memory, hooks, coordination, etc. (schemas deferred by default) | Enables AI clients to interact with MoFlo programmatically | Yes (deferred) |
|
|
478
|
+
|
|
479
|
+
### Systems (available but off by default)
|
|
480
|
+
|
|
481
|
+
| System | What It Does | How to Enable |
|
|
482
|
+
|--------|-------------|---------------|
|
|
483
|
+
| **Model Routing** | Auto-selects haiku/sonnet/opus per task based on complexity analysis | `model_routing.enabled: true` in `moflo.yaml` |
|
|
484
|
+
| **MCP Auto-Start** | Starts MCP server automatically on session begin | `mcp.auto_start: true` in `moflo.yaml` |
|
|
485
|
+
| **Tool Schema Eager Loading** | Loads all 150+ MCP tool schemas at startup (instead of on-demand) | `mcp.tool_defer: false` in `moflo.yaml` |
|
|
486
|
+
|
|
487
|
+
## The Two-Layer Task System
|
|
488
|
+
|
|
489
|
+
MoFlo doesn't replace your AI client's task system — it wraps it. Your client (Claude Code, Cursor, or any MCP-capable tool) handles spawning agents and running code. MoFlo adds a coordination layer on top that handles memory, routing, and learning.
|
|
490
|
+
|
|
491
|
+
```
|
|
492
|
+
┌──────────────────────────────────────────────────┐
|
|
493
|
+
│ YOUR AI CLIENT (Execution Layer) │
|
|
494
|
+
│ Spawns agents, runs code, streams output │
|
|
495
|
+
│ TaskCreate → Agent → TaskUpdate → results │
|
|
496
|
+
├──────────────────────────────────────────────────┤
|
|
497
|
+
│ MOFLO (Knowledge Layer) │
|
|
498
|
+
│ Routes tasks, gates agent spawns, stores │
|
|
499
|
+
│ patterns, learns from outcomes │
|
|
500
|
+
└──────────────────────────────────────────────────┘
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
Here's how a typical task flows through both layers:
|
|
504
|
+
|
|
505
|
+
1. **MoFlo routes** — Before work starts, MoFlo analyzes the prompt and recommends an agent type and model tier via hook or MCP tool.
|
|
506
|
+
2. **MoFlo gates** — Before an agent can spawn, MoFlo verifies that memory was searched and a task was registered. This prevents blind exploration.
|
|
507
|
+
3. **Your client executes** — The actual agent runs through your client's native task system. MoFlo doesn't manage the agent — your client handles execution, output, and completion.
|
|
508
|
+
4. **MoFlo learns** — After the agent finishes, MoFlo records what worked (or didn't) in its memory database. Successful patterns feed into future routing.
|
|
509
|
+
|
|
510
|
+
The key insight: **your client handles execution, MoFlo handles knowledge.** Your client is good at spawning agents and running code. MoFlo is good at remembering what happened, routing to the right agent, and ensuring prior knowledge is checked before exploring from scratch.
|
|
511
|
+
|
|
512
|
+
For complex work, MoFlo structures tasks into waves — a research wave discovers context, then an implementation wave acts on it — with dependencies tracked through both the client's task system and MoFlo's coordination layer. The full integration pattern is documented in `.claude/guidance/task-swarm-integration.md`.
|
|
513
|
+
|
|
514
|
+
The `/flo` skill ties both systems together for GitHub issues — driving a full workflow (research → enhance → implement → test → simplify → PR) with your client's agents for execution and MoFlo's memory for continuity.
|
|
515
|
+
|
|
516
|
+
### Intelligent Agent Routing
|
|
517
|
+
|
|
518
|
+
MoFlo ships with 12 built-in task patterns that map common work to the right agent type:
|
|
519
|
+
|
|
520
|
+
| Pattern | Keywords | Primary Agent |
|
|
521
|
+
|---------|----------|---------------|
|
|
522
|
+
| security-task | auth, password, encryption, CVE | security-architect |
|
|
523
|
+
| testing-task | test, spec, coverage, e2e | tester |
|
|
524
|
+
| database-task | schema, migration, SQL, ORM | architect |
|
|
525
|
+
| feature-task | implement, add, create, build | architect → coder |
|
|
526
|
+
| bugfix-task | bug, fix, error, crash, debug | coder |
|
|
527
|
+
| api-task | endpoint, REST, route, handler | architect → coder |
|
|
528
|
+
| ... | | *(12 patterns total)* |
|
|
529
|
+
|
|
530
|
+
When you route a task (`flo hooks route --task "..."` or via MCP), MoFlo runs semantic similarity against these patterns using HNSW vector search and returns a ranked recommendation with confidence scores.
|
|
531
|
+
|
|
532
|
+
**The routing gets smarter over time.** Every time a task completes successfully, MoFlo's post-task hook records the outcome — the full task description, which agent handled it, and whether it succeeded. These learned patterns are combined with the built-in seeds on every future route call. Because learned patterns contain rich task descriptions (not just short keywords), they discriminate better as they accumulate.
|
|
533
|
+
|
|
534
|
+
Routing outcomes are stored in `.claude-flow/routing-outcomes.json` and persist across sessions. You can inspect them with `flo hooks patterns` or transfer them between projects with `flo hooks transfer`.
|
|
535
|
+
|
|
536
|
+
### Memory & Knowledge Storage
|
|
537
|
+
|
|
538
|
+
MoFlo uses a SQLite database (via sql.js/WASM — no native deps) to store three types of knowledge:
|
|
539
|
+
|
|
540
|
+
| Namespace | What's Stored | How It Gets There |
|
|
541
|
+
|-----------|---------------|-------------------|
|
|
542
|
+
| `guidance` | Chunked project docs (`.claude/guidance/`, `docs/`) with 384-dim embeddings | `flo-index` on session start |
|
|
543
|
+
| `code-map` | Structural index of source files (exports, classes, functions) | `flo-codemap` on session start |
|
|
544
|
+
| `patterns` | Learned patterns from successful task outcomes | Post-task hooks after agent work |
|
|
545
|
+
|
|
546
|
+
**Semantic search** uses cosine similarity on neural embeddings (MiniLM-L6-v2, 384 dimensions). When Claude searches memory, it gets the most relevant chunks ranked by semantic similarity — not keyword matching.
|
|
547
|
+
|
|
548
|
+
**Session start indexing** — Three background processes run on every session start: the guidance indexer, the code map generator, and the learning service. All three are incremental (unchanged files are skipped) and run in parallel so they don't block the session.
|
|
549
|
+
|
|
550
|
+
**Cross-session persistence** — Everything stored in the database survives across sessions. Patterns learned on Monday are available on Friday. The stop hook exports session metrics, and the session-restore hook loads prior state.
|
|
551
|
+
|
|
552
|
+
### For Claude
|
|
553
|
+
|
|
554
|
+
When `flo init` runs, it appends a workflow section to your CLAUDE.md that teaches Claude:
|
|
555
|
+
- Always search memory before Glob/Grep/Read (enforced by gates)
|
|
556
|
+
- Use `mcp__moflo__memory_search` for knowledge retrieval
|
|
557
|
+
- Use `/flo <issue>` (or `/fl`) for issue execution
|
|
558
|
+
- Store learnings after task completion
|
|
260
559
|
|
|
261
560
|
## Full Configuration Reference
|
|
262
561
|
|
|
@@ -276,6 +575,13 @@ code_map:
|
|
|
276
575
|
exclude: [node_modules, dist]
|
|
277
576
|
namespace: code-map
|
|
278
577
|
|
|
578
|
+
tests:
|
|
579
|
+
directories: [tests, __tests__]
|
|
580
|
+
patterns: ["*.test.*", "*.spec.*", "*.test-*"]
|
|
581
|
+
extensions: [".ts", ".tsx", ".js", ".jsx"]
|
|
582
|
+
exclude: [node_modules, coverage, dist]
|
|
583
|
+
namespace: tests
|
|
584
|
+
|
|
279
585
|
gates:
|
|
280
586
|
memory_first: true # Must search memory before file exploration
|
|
281
587
|
task_create_first: true # Must TaskCreate before Agent tool
|
|
@@ -284,6 +590,7 @@ gates:
|
|
|
284
590
|
auto_index:
|
|
285
591
|
guidance: true # Auto-index docs on session start
|
|
286
592
|
code_map: true # Auto-index code on session start
|
|
593
|
+
tests: true # Auto-index test files on session start
|
|
287
594
|
|
|
288
595
|
mcp:
|
|
289
596
|
tool_defer: true # Defer 150+ tool schemas; loaded on demand via ToolSearch
|
|
@@ -353,118 +660,6 @@ model_routing:
|
|
|
353
660
|
researcher: sonnet # Pin research to sonnet
|
|
354
661
|
```
|
|
355
662
|
|
|
356
|
-
## How It Works
|
|
357
|
-
|
|
358
|
-
MoFlo sits between Claude Code and your project. It uses Claude Code's native hook system to enforce good habits, store knowledge, and learn from outcomes — so Claude gets better at working in your codebase over time.
|
|
359
|
-
|
|
360
|
-
### The Gate System
|
|
361
|
-
|
|
362
|
-
MoFlo installs Claude Code hooks that run on every tool call. Together, these gates create a **feedback loop** that prevents Claude from wasting tokens on blind exploration and ensures it builds on prior knowledge.
|
|
363
|
-
|
|
364
|
-
**Memory-first gate** — Before Claude can use Glob, Grep, or Read on guidance files, it must first search the memory database. This forces Claude to check what it already knows (or what was learned in prior sessions) before re-exploring from scratch. The gate automatically classifies each prompt — simple directives like "commit" or "yes" skip the gate, while task-oriented prompts like "fix the auth bug" enforce it.
|
|
365
|
-
|
|
366
|
-
**Task-create gate** — Before Claude can spawn sub-agents via the Task tool, it must call TaskCreate first. This ensures every agent spawn is tracked, preventing runaway agent proliferation and making it possible to review what work was delegated.
|
|
367
|
-
|
|
368
|
-
**Context tracking** — Each interaction increments a counter. As the conversation grows, MoFlo warns Claude about context depletion (FRESH → MODERATE → DEPLETED → CRITICAL) and advises it to checkpoint progress, compact, or start a fresh session before quality degrades.
|
|
369
|
-
|
|
370
|
-
**Routing** — On each prompt, MoFlo's route hook analyzes the task and recommends the optimal agent type and model tier (haiku for simple tasks, sonnet for moderate, opus for complex). This saves cost without sacrificing quality.
|
|
371
|
-
|
|
372
|
-
All gates are configurable via `moflo.yaml` — you can disable any individual hook if it doesn't suit your workflow.
|
|
373
|
-
|
|
374
|
-
### Intelligent Agent Routing
|
|
375
|
-
|
|
376
|
-
MoFlo ships with 12 built-in task patterns that map common work to the right agent type:
|
|
377
|
-
|
|
378
|
-
| Pattern | Keywords | Primary Agent |
|
|
379
|
-
|---------|----------|---------------|
|
|
380
|
-
| security-task | auth, password, encryption, CVE | security-architect |
|
|
381
|
-
| testing-task | test, spec, coverage, e2e | tester |
|
|
382
|
-
| database-task | schema, migration, SQL, ORM | architect |
|
|
383
|
-
| feature-task | implement, add, create, build | architect → coder |
|
|
384
|
-
| bugfix-task | bug, fix, error, crash, debug | coder |
|
|
385
|
-
| api-task | endpoint, REST, route, handler | architect → coder |
|
|
386
|
-
| ... | | *(12 patterns total)* |
|
|
387
|
-
|
|
388
|
-
When you route a task (`flo hooks route --task "..."` or via MCP), MoFlo runs semantic similarity against these patterns using HNSW vector search and returns a ranked recommendation with confidence scores.
|
|
389
|
-
|
|
390
|
-
**The routing gets smarter over time.** Every time a task completes successfully, MoFlo's post-task hook records the outcome — the full task description, which agent handled it, and whether it succeeded. These learned patterns are combined with the built-in seeds on every future route call. Because learned patterns contain rich task descriptions (not just short keywords), they discriminate better as they accumulate.
|
|
391
|
-
|
|
392
|
-
Routing outcomes are stored in `.claude-flow/routing-outcomes.json` and persist across sessions. You can inspect them with `flo hooks patterns` or transfer them between projects with `flo hooks transfer`.
|
|
393
|
-
|
|
394
|
-
### What Ships Out of the Box
|
|
395
|
-
|
|
396
|
-
`flo init` wires up the following systems automatically — no configuration needed:
|
|
397
|
-
|
|
398
|
-
| System | What It Does | Technology |
|
|
399
|
-
|--------|-------------|------------|
|
|
400
|
-
| **Semantic Memory** | Store and search knowledge with 384-dim embeddings | sql.js (WASM SQLite) + Transformers.js (MiniLM-L6-v2) |
|
|
401
|
-
| **HNSW Vector Search** | Fast nearest-neighbor search across all stored knowledge | `@ruvector/core` VectorDb |
|
|
402
|
-
| **Semantic Routing** | Match tasks to agent types using vector similarity | `@ruvector/router` SemanticRouter |
|
|
403
|
-
| **SONA Learning** | Learn from task trajectories — what agent handled what, and whether it succeeded | `@ruvector/sona` SonaEngine (Rust/NAPI) |
|
|
404
|
-
| **MicroLoRA Adaptation** | Rank-2 LoRA weight updates from successful patterns (~1µs per adapt) | `@ruvector/learning-wasm` |
|
|
405
|
-
| **EWC++ Consolidation** | Prevent catastrophic forgetting — new learning doesn't overwrite old patterns | Built into hooks-tools |
|
|
406
|
-
| **Workflow Gates** | Memory-first and task-registration enforcement via Claude Code hooks | `.claude/settings.json` hooks |
|
|
407
|
-
| **Context Tracking** | Monitor context window depletion (FRESH → CRITICAL) | Session interaction counter |
|
|
408
|
-
| **Guidance Indexing** | Chunk and embed your project docs on session start | `flo-index` bin script |
|
|
409
|
-
| **Code Map** | Index source file structure (types, exports, functions) on session start | `flo-codemap` bin script |
|
|
410
|
-
| **Learned Routing** | Task outcomes feed back into routing — gets smarter over time | `routing-outcomes.json` persistence |
|
|
411
|
-
| **Status Line** | Live dashboard showing git, swarm, memory, and MCP status | `statusline.cjs` hook |
|
|
412
|
-
|
|
413
|
-
All of these run locally with zero external dependencies. The SONA, MicroLoRA, and HNSW components are WASM/NAPI binaries that ship with the npm package — no compilation, no GPU, no API keys.
|
|
414
|
-
|
|
415
|
-
### The Two-Layer Task System
|
|
416
|
-
|
|
417
|
-
MoFlo doesn't replace your AI client's task system — it wraps it. Your client (Claude Code, Cursor, or any MCP-capable tool) handles spawning agents and running code. MoFlo adds a coordination layer on top that handles memory, routing, and learning.
|
|
418
|
-
|
|
419
|
-
```
|
|
420
|
-
┌──────────────────────────────────────────────────┐
|
|
421
|
-
│ YOUR AI CLIENT (Execution Layer) │
|
|
422
|
-
│ Spawns agents, runs code, streams output │
|
|
423
|
-
│ TaskCreate → Agent → TaskUpdate → results │
|
|
424
|
-
├──────────────────────────────────────────────────┤
|
|
425
|
-
│ MOFLO (Knowledge Layer) │
|
|
426
|
-
│ Routes tasks, gates agent spawns, stores │
|
|
427
|
-
│ patterns, learns from outcomes │
|
|
428
|
-
└──────────────────────────────────────────────────┘
|
|
429
|
-
```
|
|
430
|
-
|
|
431
|
-
Here's how a typical task flows through both layers:
|
|
432
|
-
|
|
433
|
-
1. **MoFlo routes** — Before work starts, MoFlo analyzes the prompt and recommends an agent type and model tier via hook or MCP tool.
|
|
434
|
-
2. **MoFlo gates** — Before an agent can spawn, MoFlo verifies that memory was searched and a task was registered. This prevents blind exploration.
|
|
435
|
-
3. **Your client executes** — The actual agent runs through your client's native task system. MoFlo doesn't manage the agent — your client handles execution, output, and completion.
|
|
436
|
-
4. **MoFlo learns** — After the agent finishes, MoFlo records what worked (or didn't) in its memory database. Successful patterns feed into future routing.
|
|
437
|
-
|
|
438
|
-
The key insight: **your client handles execution, MoFlo handles knowledge.** Your client is good at spawning agents and running code. MoFlo is good at remembering what happened, routing to the right agent, and ensuring prior knowledge is checked before exploring from scratch.
|
|
439
|
-
|
|
440
|
-
For complex work, MoFlo structures tasks into waves — a research wave discovers context, then an implementation wave acts on it — with dependencies tracked through both the client's task system and MoFlo's coordination layer. The full integration pattern is documented in `.claude/guidance/task-swarm-integration.md`.
|
|
441
|
-
|
|
442
|
-
The `/flo` skill ties both systems together for GitHub issues — driving a full workflow (research → enhance → implement → test → simplify → PR) with your client's agents for execution and MoFlo's memory for continuity.
|
|
443
|
-
|
|
444
|
-
### Memory & Knowledge Storage
|
|
445
|
-
|
|
446
|
-
MoFlo uses a SQLite database (via sql.js/WASM — no native deps) to store three types of knowledge:
|
|
447
|
-
|
|
448
|
-
| Namespace | What's Stored | How It Gets There |
|
|
449
|
-
|-----------|---------------|-------------------|
|
|
450
|
-
| `guidance` | Chunked project docs (`.claude/guidance/`, `docs/`) with 384-dim embeddings | `flo-index` on session start |
|
|
451
|
-
| `code-map` | Structural index of source files (exports, classes, functions) | `flo-codemap` on session start |
|
|
452
|
-
| `patterns` | Learned patterns from successful task outcomes | Post-task hooks after agent work |
|
|
453
|
-
|
|
454
|
-
**Semantic search** uses cosine similarity on neural embeddings (MiniLM-L6-v2, 384 dimensions). When Claude searches memory, it gets the most relevant chunks ranked by semantic similarity — not keyword matching.
|
|
455
|
-
|
|
456
|
-
**Session start indexing** — Three background processes run on every session start: the guidance indexer, the code map generator, and the learning service. All three are incremental (unchanged files are skipped) and run in parallel so they don't block the session.
|
|
457
|
-
|
|
458
|
-
**Cross-session persistence** — Everything stored in the database survives across sessions. Patterns learned on Monday are available on Friday. The stop hook exports session metrics, and the session-restore hook loads prior state.
|
|
459
|
-
|
|
460
|
-
### For Claude
|
|
461
|
-
|
|
462
|
-
When `flo init` runs, it appends a workflow section to your CLAUDE.md that teaches Claude:
|
|
463
|
-
- Always search memory before Glob/Grep/Read (enforced by gates)
|
|
464
|
-
- Use `mcp__claude-flow__memory_search` for knowledge retrieval
|
|
465
|
-
- Use `/flo <issue>` (or `/fl`) for issue execution
|
|
466
|
-
- Store learnings after task completion
|
|
467
|
-
|
|
468
663
|
## Architecture
|
|
469
664
|
|
|
470
665
|
- **7 standalone bin scripts** shipped with npm: `flo-search`, `flo-embeddings`, `flo-index`, `flo-codemap`, `flo-learn`, `flo-setup`, plus the main `flo` CLI
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
|
|
5
|
+
var command = process.argv[2];
|
|
6
|
+
if (!command) process.exit(0);
|
|
7
|
+
|
|
8
|
+
// Read stdin JSON from Claude Code
|
|
9
|
+
var stdinData = '';
|
|
10
|
+
try {
|
|
11
|
+
stdinData = await new Promise(function(res) {
|
|
12
|
+
var data = '';
|
|
13
|
+
var timeout = setTimeout(function() { res(data); }, 500);
|
|
14
|
+
process.stdin.setEncoding('utf-8');
|
|
15
|
+
process.stdin.on('data', function(chunk) { data += chunk; });
|
|
16
|
+
process.stdin.on('end', function() { clearTimeout(timeout); res(data); });
|
|
17
|
+
process.stdin.on('error', function() { clearTimeout(timeout); res(''); });
|
|
18
|
+
if (process.stdin.isTTY) { clearTimeout(timeout); res(''); }
|
|
19
|
+
});
|
|
20
|
+
} catch (e) { /* no stdin */ }
|
|
21
|
+
|
|
22
|
+
var hookContext = {};
|
|
23
|
+
try { if (stdinData.trim()) hookContext = JSON.parse(stdinData); } catch (e) {}
|
|
24
|
+
|
|
25
|
+
// Pass tool info as env vars for gate.cjs
|
|
26
|
+
var env = Object.assign({}, process.env);
|
|
27
|
+
if (hookContext.tool_name) env.TOOL_NAME = hookContext.tool_name;
|
|
28
|
+
if (hookContext.tool_input && typeof hookContext.tool_input === 'object') {
|
|
29
|
+
Object.keys(hookContext.tool_input).forEach(function(key) {
|
|
30
|
+
if (typeof hookContext.tool_input[key] === 'string') {
|
|
31
|
+
env['TOOL_INPUT_' + key] = hookContext.tool_input[key];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Run gate.cjs with the enriched environment
|
|
37
|
+
var projectDir = (env.CLAUDE_PROJECT_DIR || process.cwd()).replace(/^\/([a-z])\//i, '$1:/');
|
|
38
|
+
var gateScript = resolve(projectDir, '.claude/helpers/gate.cjs');
|
|
39
|
+
try {
|
|
40
|
+
var output = execSync('node "' + gateScript + '" ' + command, {
|
|
41
|
+
env: env, encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe']
|
|
42
|
+
});
|
|
43
|
+
if (output.trim()) process.stdout.write(output);
|
|
44
|
+
process.exit(0);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
// gate.cjs exit(2) = block, exit(1) = also block attempt — translate both to exit(2)
|
|
47
|
+
if (err.stderr) process.stderr.write(err.stderr);
|
|
48
|
+
if (err.stdout) process.stderr.write(err.stdout);
|
|
49
|
+
process.exit(err.status === 2 || err.status === 1 ? 2 : 0);
|
|
50
|
+
}
|