moflo 4.8.43 → 4.8.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- # Task & Swarm Integration Pattern
1
+ # MoFlo–Claude Swarm Cohesion
2
2
 
3
- **Purpose:** Integrate native Claude Code tasks with moflo swarm coordination for visible progress tracking and structured agent orchestration.
3
+ **Purpose:** Integrate native Claude Code tasks with MoFlo swarm coordination for visible progress tracking and structured agent orchestration.
4
4
 
5
5
  ---
6
6
 
@@ -144,7 +144,7 @@ TaskCreate was already called in Step 1 — tasks are visible before agents spaw
144
144
  ```javascript
145
145
  // TaskCreate already done in Step 1 above
146
146
  Task({
147
- prompt: `FIRST: Search memory, then read .claude/guidance/agent-bootstrap.md
147
+ prompt: `FIRST: Search memory, then read .claude/guidance/moflo-subagents.md
148
148
 
149
149
  YOUR TASK (ID: 1): Research requirements and codebase patterns
150
150
  - Analyze feature requirements
@@ -436,6 +436,6 @@ npx flo swarm init --topology hierarchical-mesh --max-agents 15 --strategy speci
436
436
 
437
437
  ## See Also
438
438
 
439
- - `.claude/guidance/agent-bootstrap.md` - Subagent bootstrap guide
440
- - `.claude/guidance/memory-strategy.md` - Memory architecture and search
439
+ - `.claude/guidance/moflo-subagents.md` - Subagents guide
440
+ - `.claude/guidance/moflo-memory-strategy.md` - Memory architecture and search
441
441
  - `.claude/guidance/moflo.md` - Full CLI/MCP reference
@@ -1,276 +1,277 @@
1
- # Memory & Semantic Search Strategy
2
-
3
- **Purpose:** How memory, embeddings, and semantic search work in moflo. Reference when writing guidance documents, debugging search quality, configuring memory for a consumer project, or extending the system.
4
-
5
- ---
6
-
7
- ## Problem Statement
8
-
9
- Claude Code agents need project-specific knowledge — coding rules, architecture patterns, entity templates, testing conventions — delivered at the right moment. Without a retrieval system, agents either miss critical rules or require massive CLAUDE.md files that waste context window tokens.
10
-
11
- **Goals:**
12
- - Agents find relevant guidance automatically via semantic search
13
- - Subagents spawned by the coordinator inherit memory access
14
- - Search quality is high enough that agents don't need to read whole files
15
- - The system survives `npm install` (indexing runs on session start)
16
-
17
- ---
18
-
19
- ## Architecture Overview
20
-
21
- ```
22
- Source Files (.claude/guidance/*.md, docs/*.md)
23
- |
24
- v
25
- index-guidance.mjs --- Chunk on ## headers, build RAG links
26
- | (prev/next, siblings, parent/child, context overlap)
27
- v
28
- .swarm/memory.db ----- SQLite (entries + metadata + embedding vectors)
29
- |
30
- v
31
- build-embeddings.mjs - Generate 384-dim vectors per entry
32
- | (Xenova/all-MiniLM-L6-v2 neural, or domain-aware hash fallback)
33
- v
34
- HNSW index ----------- Approximate nearest-neighbor search
35
- v
36
- Search layer ---------- Three access paths:
37
- 1. MCP tools (mcp__moflo__memory_search) -- preferred
38
- 2. CLI (npx flo memory search) -- fallback
39
- 3. Script (semantic-search.mjs) -- detailed output
40
- ```
41
-
42
- **Key files:**
43
-
44
- | File | Purpose |
45
- |------|---------|
46
- | `.swarm/memory.db` | SQLite database with all entries, embeddings, metadata |
47
- | `.swarm/code-map-hash.txt` | SHA-256 hash for incremental code map skip |
48
- | `.claude-flow/neural/patterns.json` | ReasoningBank learned patterns |
49
- | `bin/build-embeddings.mjs` | Generates 384-dim embeddings |
50
- | `bin/index-guidance.mjs` | Indexes guidance files with RAG linking |
51
- | `bin/generate-code-map.mjs` | Generates structural code map (projects, dirs, types, interfaces) |
52
- | `bin/index-patterns.mjs` | Extracts per-file code patterns |
53
- | `bin/index-tests.mjs` | Indexes test structure and patterns |
54
- | `bin/index-all.mjs` | Runs the full indexing chain sequentially |
55
-
56
- ---
57
-
58
- ## Namespaces
59
-
60
- | Namespace | Content | Indexed By |
61
- |-----------|---------|------------|
62
- | `guidance` | Indexed guidance and docs | `index-guidance.mjs` |
63
- | `code-map` | Structural codebase index (projects, directories, types, interfaces) | `generate-code-map.mjs` |
64
- | `patterns` | Per-file code patterns (services, routes, error handling, exports) | `index-patterns.mjs` |
65
- | `tests` | Test structure and patterns | `index-tests.mjs` |
66
-
67
- ---
68
-
69
- ## Guidance Document Optimization Rules
70
-
71
- These rules determine how well your guidance documents retrieve via semantic search:
72
-
73
- ### 1. Every file needs a Purpose line
74
-
75
- Add `**Purpose:**` as the first meaningful line after the title. Claude checks this first for relevance scoring. Without it, the chunk has no summary signal.
76
-
77
- ### 2. H2 headings are the primary retrieval signal
78
-
79
- The indexer splits on `##`. Each heading becomes the chunk title, prepended to searchable content. Domain-specific keywords in headings dramatically improve recall.
80
-
81
- **Bad:** `## Overview`, `## Rules`, `## Pattern`
82
- **Good:** `## Soft Delete Rules`, `## JWT Authentication Pattern`, `## Database Entity Migration`
83
-
84
- ### 3. Ideal chunk size: 1000-4000 characters
85
-
86
- Below 50 chars the chunk is dropped. Above 6000 the indexer force-splits on paragraphs, which breaks mid-thought. The sweet spot produces focused embeddings.
87
-
88
- ### 4. Self-contained chunks
89
-
90
- Each H2 section must answer a question without needing the rest of the document. Include: the rule, a code example, and a cross-reference.
91
-
92
- ### 5. Tables over prose
93
-
94
- Claude parses structured data more accurately than paragraphs. DO/DON'T tables, field reference tables, and command tables all retrieve better.
95
-
96
- ### 6. Cross-references create a navigation graph
97
-
98
- The RAG indexer stores `prevChunk`/`nextChunk`/`siblings` metadata. Cross-references between documents let Claude follow chains: `core.md -> coding-rules.md -> database.md`.
99
-
100
- ### 7. No decorative formatting
101
-
102
- ASCII boxes, excessive emoji, rhetorical questions, and motivational text all waste tokens without improving retrieval or comprehension.
103
-
104
- ---
105
-
106
- ## Embedding Strategy
107
-
108
- ### Embedding Models
109
-
110
- | Model | Quality | Speed | When Used |
111
- |-------|---------|-------|-----------|
112
- | `Xenova/all-MiniLM-L6-v2` | High (true semantic) | ~3s for 1000 entries | Primary — `build-embeddings.mjs` uses this |
113
- | `domain-aware-hash-v1` | Good (domain clustering) | <1s for 1000 entries | Fallback when Transformers.js unavailable |
114
-
115
- **Neural embeddings (Xenova/all-MiniLM-L6-v2):**
116
- - Uses `@xenova/transformers` with ONNX WASM runtime
117
- - 384-dimensional vectors, L2-normalized
118
- - True semantic understanding — "soft delete" matches "mark as deleted" without keyword overlap
119
- - Loaded lazily on first use, cached for subsequent queries
120
-
121
- **Domain-aware hash embeddings (fallback):**
122
- - Custom SimHash-style algorithm with 12 domain clusters
123
- - Multi-position hashing with bigram/trigram features
124
- - Good at keyword-level matching but misses semantic paraphrases
125
- - No external dependencies — always available
126
-
127
- ### The Embedding Alignment Problem
128
-
129
- **Critical rule:** Query embeddings MUST match stored embeddings. Computing cosine similarity between vectors from different models produces meaningless scores.
130
-
131
- Both the search scripts and the MCP memory tools auto-detect the stored embedding model and generate matching query vectors. Search also filters out entries with mismatched `embedding_model`.
132
-
133
- ### Domain Cluster Tuning
134
-
135
- The hash fallback's domain clusters can be extended with project-specific terms:
136
-
137
- | Cluster | Example Terms |
138
- |---------|--------------|
139
- | `database` | your ORM, database engine, schema terms |
140
- | `frontend` | UI framework, component library terms |
141
- | `backend` | DI container, API framework terms |
142
- | `testing` | test framework, assertion library terms |
143
- | `security` | auth system, permission model terms |
144
-
145
- ---
146
-
147
- ## RAG Indexing Pipeline
148
-
149
- ### How `index-guidance.mjs` Works
150
-
151
- 1. **Scan** configured directories for `.md` files
152
- 2. **Hash check** — Skip files whose content hash hasn't changed (unless `--force`)
153
- 3. **Store full document** as `doc-{prefix}-{name}` (for complete retrieval)
154
- 4. **Chunk on `##` headers** — Each H2 section becomes a separate entry
155
- 5. **H3 subsections** become child chunks with parent H2 as context prefix
156
- 6. **Force-split** sections over 4000 chars on paragraph boundaries
157
- 7. **Build RAG metadata** for every chunk:
158
-
159
- | Metadata Field | Purpose |
160
- |---------------|---------|
161
- | `parentDoc` | Link back to full document |
162
- | `prevChunk` / `nextChunk` | Sequential navigation |
163
- | `siblings` | All chunk keys from same document |
164
- | `hierarchicalParent` / `hierarchicalChildren` | H2->H3 relationships |
165
- | `contextBefore` / `contextAfter` | 20% overlapping text from adjacent chunks |
166
-
167
- 8. **Prepend context** — Each chunk's searchable content includes overlap from neighbors
168
- 9. **Stale cleanup** — After indexing, remove entries for files that no longer exist on disk
169
- 10. **Background embedding** — Spawn `build-embeddings.mjs` to generate vectors
170
-
171
- ### Configuring Indexed Directories
172
-
173
- In `moflo.yaml`:
174
-
175
- ```yaml
176
- guidance:
177
- directories:
178
- - .claude/guidance
179
- - docs/guides
180
- ```
181
-
182
- Default directories (when no config): `.claude/guidance`, `docs/guides`
183
-
184
- Moflo also automatically indexes its own bundled guidance from `node_modules/moflo/.claude/guidance/` when installed as a dependency.
185
-
186
- ---
187
-
188
- ## Search Commands
189
-
190
- All methods auto-detect the stored embedding model and generate matching query vectors:
191
-
192
- **MCP (Preferred):** `mcp__moflo__memory_search` — `query: "your query", namespace: "guidance"`
193
-
194
- **CLI (Fallback):**
195
- ```bash
196
- npx flo memory search --query "your query" --namespace guidance
197
- ```
198
-
199
- **Search options:**
200
-
201
- | Flag | Default | Purpose |
202
- |------|---------|---------|
203
- | `--namespace` | all | Filter to specific namespace |
204
- | `--limit` | 5 | Number of results |
205
- | `--threshold` | 0.3 | Minimum similarity score |
206
- | `--json` | false | Output as JSON |
207
-
208
- ### Code Map Search (for codebase navigation)
209
-
210
- When you need to find where a type, service, entity, or component lives — search `code-map` BEFORE using Glob/Grep:
211
-
212
- **MCP:** `mcp__moflo__memory_search` — `query: "payment service", namespace: "code-map"`
213
-
214
- **What code-map contains:**
215
-
216
- | Chunk prefix | What it answers |
217
- |--------------|-----------------|
218
- | `project:` | "What's in the api project?" |
219
- | `dir:` | "What types are in the entities directory?" |
220
- | `iface-map:` | "What implements IPaymentService?" |
221
- | `type-index:` | "Where is Service defined?" |
222
-
223
- ---
224
-
225
- ## Session Start Indexing
226
-
227
- On every session start, `hooks.mjs` spawns `index-all.mjs` which runs the full chain:
228
-
229
- | Indexer | Namespace | What it does |
230
- |---------|-----------|--------------|
231
- | `index-guidance.mjs` | `guidance` | Chunks markdown, builds RAG links |
232
- | `generate-code-map.mjs` | `code-map` | Scans source for types, interfaces, directories |
233
- | `index-tests.mjs` | `tests` | Indexes test structure |
234
- | `index-patterns.mjs` | `patterns` | Extracts per-file code patterns |
235
- | `build-embeddings.mjs` | all | Generates vectors for any unembedded entries |
236
-
237
- Indexing is incremental by default — files whose content hash hasn't changed are skipped. Use `--force` to reindex everything.
238
-
239
- ---
240
-
241
- ## Replication Guide
242
-
243
- To set up this system in a new project:
244
-
245
- ```bash
246
- npm install moflo
247
- npx flo init
248
- ```
249
-
250
- Create `.claude/guidance/` with markdown files following the optimization rules above, then:
251
-
252
- ```bash
253
- npx flo-index --force # Index documents
254
- npx flo memory search --query "your domain query" --namespace guidance # Verify
255
- ```
256
-
257
- ---
258
-
259
- ## Troubleshooting
260
-
261
- | Symptom | Cause | Fix |
262
- |---------|-------|-----|
263
- | Search returns irrelevant results | Query/stored embedding model mismatch | Auto-detected now; verify with `--verbose` flag |
264
- | Low similarity scores | Query doesn't match domain terms | Include domain keywords in query |
265
- | "Vector: No" in list | Entry lacks embedding | Run `node bin/build-embeddings.mjs` |
266
- | Entries not found after adding file | Indexer hasn't run yet | Run `node bin/index-all.mjs` or restart session |
267
- | Bundled moflo guidance not indexed | Not installed as dependency | Only indexes when `node_modules/moflo/.claude/guidance/` exists |
268
- | Empty namespace | Indexer never ran or DB was purged | See `memorydb-maintenance.md` for reindex/purge procedures |
269
-
270
- ---
271
-
272
- ## See Also
273
-
274
- - `memorydb-maintenance.md` — Database location, schema, purge/reindex procedures
275
- - `agent-bootstrap.md` — Subagent bootstrap guide
276
- - `moflo.md` — Full CLI/MCP reference
1
+ # Memory & Semantic Search Strategy
2
+
3
+ **Purpose:** How memory, embeddings, and semantic search work in moflo. Reference when writing guidance documents, debugging search quality, configuring memory for a consumer project, or extending the system.
4
+
5
+ ---
6
+
7
+ ## Problem Statement
8
+
9
+ Claude Code agents need project-specific knowledge — coding rules, architecture patterns, entity templates, testing conventions — delivered at the right moment. Without a retrieval system, agents either miss critical rules or require massive CLAUDE.md files that waste context window tokens.
10
+
11
+ **Goals:**
12
+ - Agents find relevant guidance automatically via semantic search
13
+ - Subagents spawned by the coordinator inherit memory access
14
+ - Search quality is high enough that agents don't need to read whole files
15
+ - The system survives `npm install` (indexing runs on session start)
16
+
17
+ ---
18
+
19
+ ## Architecture Overview
20
+
21
+ ```
22
+ Source Files (.claude/guidance/*.md, docs/*.md)
23
+ |
24
+ v
25
+ index-guidance.mjs --- Chunk on ## headers, build RAG links
26
+ | (prev/next, siblings, parent/child, context overlap)
27
+ v
28
+ .swarm/memory.db ----- SQLite (entries + metadata + embedding vectors)
29
+ |
30
+ v
31
+ build-embeddings.mjs - Generate 384-dim vectors per entry
32
+ | (Xenova/all-MiniLM-L6-v2 neural, or domain-aware hash fallback)
33
+ v
34
+ HNSW index ----------- Approximate nearest-neighbor search
35
+ v
36
+ Search layer ---------- Three access paths:
37
+ 1. MCP tools (mcp__moflo__memory_search) -- preferred
38
+ 2. CLI (npx flo memory search) -- fallback
39
+ 3. Script (semantic-search.mjs) -- detailed output
40
+ ```
41
+
42
+ **Key files:**
43
+
44
+ | File | Purpose |
45
+ |------|---------|
46
+ | `.swarm/memory.db` | SQLite database with all entries, embeddings, metadata |
47
+ | `.swarm/code-map-hash.txt` | SHA-256 hash for incremental code map skip |
48
+ | `.claude-flow/neural/patterns.json` | ReasoningBank learned patterns |
49
+ | `bin/build-embeddings.mjs` | Generates 384-dim embeddings |
50
+ | `bin/index-guidance.mjs` | Indexes guidance files with RAG linking |
51
+ | `bin/generate-code-map.mjs` | Generates structural code map (projects, dirs, types, interfaces) |
52
+ | `bin/index-patterns.mjs` | Extracts per-file code patterns |
53
+ | `bin/index-tests.mjs` | Indexes test structure and patterns |
54
+ | `bin/index-all.mjs` | Runs the full indexing chain sequentially |
55
+
56
+ ---
57
+
58
+ ## Namespaces
59
+
60
+ | Namespace | Content | Indexed By |
61
+ |-----------|---------|------------|
62
+ | `guidance` | Indexed guidance and docs | `index-guidance.mjs` |
63
+ | `code-map` | Structural codebase index (projects, directories, types, interfaces) | `generate-code-map.mjs` |
64
+ | `patterns` | Per-file code patterns (services, routes, error handling, exports) | `index-patterns.mjs` |
65
+ | `tests` | Test structure and patterns | `index-tests.mjs` |
66
+
67
+ ---
68
+
69
+ ## Guidance Document Optimization Rules
70
+
71
+ These rules determine how well your guidance documents retrieve via semantic search:
72
+
73
+ ### 1. Every file needs a Purpose line
74
+
75
+ Add `**Purpose:**` as the first meaningful line after the title. Claude checks this first for relevance scoring. Without it, the chunk has no summary signal.
76
+
77
+ ### 2. H2 headings are the primary retrieval signal
78
+
79
+ The indexer splits on `##`. Each heading becomes the chunk title, prepended to searchable content. Domain-specific keywords in headings dramatically improve recall.
80
+
81
+ **Bad:** `## Overview`, `## Rules`, `## Pattern`
82
+ **Good:** `## Soft Delete Rules`, `## JWT Authentication Pattern`, `## Database Entity Migration`
83
+
84
+ ### 3. Ideal chunk size: 1000-4000 characters
85
+
86
+ Below 50 chars the chunk is dropped. Above 6000 the indexer force-splits on paragraphs, which breaks mid-thought. The sweet spot produces focused embeddings.
87
+
88
+ ### 4. Self-contained chunks
89
+
90
+ Each H2 section must answer a question without needing the rest of the document. Include: the rule, a code example, and a cross-reference.
91
+
92
+ ### 5. Tables over prose
93
+
94
+ Claude parses structured data more accurately than paragraphs. DO/DON'T tables, field reference tables, and command tables all retrieve better.
95
+
96
+ ### 6. Cross-references create a navigation graph
97
+
98
+ The RAG indexer stores `prevChunk`/`nextChunk`/`siblings` metadata. Cross-references between documents let Claude follow chains: `core.md -> coding-rules.md -> database.md`.
99
+
100
+ ### 7. No decorative formatting
101
+
102
+ ASCII boxes, excessive emoji, rhetorical questions, and motivational text all waste tokens without improving retrieval or comprehension.
103
+
104
+ ---
105
+
106
+ ## Embedding Strategy
107
+
108
+ ### Embedding Models
109
+
110
+ | Model | Quality | Speed | When Used |
111
+ |-------|---------|-------|-----------|
112
+ | `Xenova/all-MiniLM-L6-v2` | High (true semantic) | ~3s for 1000 entries | Primary — `build-embeddings.mjs` uses this |
113
+ | `domain-aware-hash-v1` | Good (domain clustering) | <1s for 1000 entries | Fallback when Transformers.js unavailable |
114
+
115
+ **Neural embeddings (Xenova/all-MiniLM-L6-v2):**
116
+ - Uses `@xenova/transformers` with ONNX WASM runtime
117
+ - 384-dimensional vectors, L2-normalized
118
+ - True semantic understanding — "soft delete" matches "mark as deleted" without keyword overlap
119
+ - Loaded lazily on first use, cached for subsequent queries
120
+
121
+ **Domain-aware hash embeddings (fallback):**
122
+ - Custom SimHash-style algorithm with 12 domain clusters
123
+ - Multi-position hashing with bigram/trigram features
124
+ - Good at keyword-level matching but misses semantic paraphrases
125
+ - No external dependencies — always available
126
+
127
+ ### The Embedding Alignment Problem
128
+
129
+ **Critical rule:** Query embeddings MUST match stored embeddings. Computing cosine similarity between vectors from different models produces meaningless scores.
130
+
131
+ Both the search scripts and the MCP memory tools auto-detect the stored embedding model and generate matching query vectors. Search also filters out entries with mismatched `embedding_model`.
132
+
133
+ ### Domain Cluster Tuning
134
+
135
+ The hash fallback's domain clusters can be extended with project-specific terms:
136
+
137
+ | Cluster | Example Terms |
138
+ |---------|--------------|
139
+ | `database` | your ORM, database engine, schema terms |
140
+ | `frontend` | UI framework, component library terms |
141
+ | `backend` | DI container, API framework terms |
142
+ | `testing` | test framework, assertion library terms |
143
+ | `security` | auth system, permission model terms |
144
+
145
+ ---
146
+
147
+ ## RAG Indexing Pipeline
148
+
149
+ ### How `index-guidance.mjs` Works
150
+
151
+ 1. **Scan** configured directories for `.md` files
152
+ 2. **Hash check** — Skip files whose content hash hasn't changed (unless `--force`)
153
+ 3. **Store full document** as `doc-{prefix}-{name}` (for complete retrieval)
154
+ 4. **Chunk on `##` headers** — Each H2 section becomes a separate entry
155
+ 5. **H3 subsections** become child chunks with parent H2 as context prefix
156
+ 6. **Force-split** sections over 4000 chars on paragraph boundaries
157
+ 7. **Build RAG metadata** for every chunk:
158
+
159
+ | Metadata Field | Purpose |
160
+ |---------------|---------|
161
+ | `parentDoc` | Link back to full document |
162
+ | `prevChunk` / `nextChunk` | Sequential navigation |
163
+ | `siblings` | All chunk keys from same document |
164
+ | `hierarchicalParent` / `hierarchicalChildren` | H2->H3 relationships |
165
+ | `contextBefore` / `contextAfter` | 20% overlapping text from adjacent chunks |
166
+
167
+ 8. **Prepend context** — Each chunk's searchable content includes overlap from neighbors
168
+ 9. **Stale cleanup** — After indexing, remove entries for files that no longer exist on disk
169
+ 10. **Background embedding** — Spawn `build-embeddings.mjs` to generate vectors
170
+
171
+ ### Configuring Indexed Directories
172
+
173
+ In `moflo.yaml`:
174
+
175
+ ```yaml
176
+ guidance:
177
+ directories:
178
+ - .claude/guidance
179
+ - docs/guides
180
+ ```
181
+
182
+ Default directories (when no config): `.claude/guidance`, `docs/guides`
183
+
184
+ Moflo also automatically indexes its own bundled guidance from `node_modules/moflo/.claude/guidance/` when installed as a dependency.
185
+
186
+ ---
187
+
188
+ ## Search Commands
189
+
190
+ All methods auto-detect the stored embedding model and generate matching query vectors:
191
+
192
+ **MCP (Preferred):** `mcp__moflo__memory_search` — `query: "your query", namespace: "guidance"`
193
+
194
+ **CLI (Fallback):**
195
+ ```bash
196
+ npx flo memory search --query "your query" --namespace guidance
197
+ ```
198
+
199
+ **Search options:**
200
+
201
+ | Flag | Default | Purpose |
202
+ |------|---------|---------|
203
+ | `--namespace` | all | Filter to specific namespace |
204
+ | `--limit` | 5 | Number of results |
205
+ | `--threshold` | 0.3 | Minimum similarity score |
206
+ | `--json` | false | Output as JSON |
207
+
208
+ ### Code Map Search (for codebase navigation)
209
+
210
+ When you need to find where a type, service, entity, or component lives — search `code-map` BEFORE using Glob/Grep:
211
+
212
+ **MCP:** `mcp__moflo__memory_search` — `query: "payment service", namespace: "code-map"`
213
+
214
+ **What code-map contains:**
215
+
216
+ | Chunk prefix | What it answers |
217
+ |--------------|-----------------|
218
+ | `project:` | "What's in the api project?" |
219
+ | `dir:` | "What types are in the entities directory?" |
220
+ | `iface-map:` | "What implements IPaymentService?" |
221
+ | `type-index:` | "Where is Service defined?" |
222
+
223
+ ---
224
+
225
+ ## Session Start Indexing
226
+
227
+ On every session start, `hooks.mjs` spawns `index-all.mjs` which runs the full chain:
228
+
229
+ | Indexer | Namespace | What it does |
230
+ |---------|-----------|--------------|
231
+ | `index-guidance.mjs` | `guidance` | Chunks markdown, builds RAG links |
232
+ | `generate-code-map.mjs` | `code-map` | Scans source for types, interfaces, directories |
233
+ | `index-tests.mjs` | `tests` | Indexes test structure |
234
+ | `index-patterns.mjs` | `patterns` | Extracts per-file code patterns |
235
+ | `build-embeddings.mjs` | all | Generates vectors for any unembedded entries |
236
+
237
+ Indexing is incremental by default — files whose content hash hasn't changed are skipped. Use `--force` to reindex everything.
238
+
239
+ ---
240
+
241
+ ## Replication Guide
242
+
243
+ To set up this system in a new project:
244
+
245
+ ```bash
246
+ npm install moflo
247
+ npx flo init
248
+ ```
249
+
250
+ Create `.claude/guidance/` with markdown files following the optimization rules above, then:
251
+
252
+ ```bash
253
+ npx flo-index --force # Index documents
254
+ npx flo memory search --query "your domain query" --namespace guidance # Verify
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Troubleshooting
260
+
261
+ | Symptom | Cause | Fix |
262
+ |---------|-------|-----|
263
+ | Search returns irrelevant results | Query/stored embedding model mismatch | Auto-detected now; verify with `--verbose` flag |
264
+ | Low similarity scores | Query doesn't match domain terms | Include domain keywords in query |
265
+ | "Vector: No" in list | Entry lacks embedding | Run `node bin/build-embeddings.mjs` |
266
+ | Entries not found after adding file | Indexer hasn't run yet | Run `node bin/index-all.mjs` or restart session |
267
+ | Bundled moflo guidance not indexed | Not installed as dependency | Only indexes when `node_modules/moflo/.claude/guidance/` exists |
268
+ | Empty namespace | Indexer never ran or DB was purged | See `moflo-memorydb-maintenance.md` for reindex/purge procedures |
269
+
270
+ ---
271
+
272
+ ## See Also
273
+
274
+ - `moflo-memorydb-maintenance.md` — Database location, schema, purge/reindex procedures
275
+ - `moflo-subagents.md` — Subagents guide
276
+ - `moflo-claude-swarm-cohesion.md` — Task & swarm coordination
277
+ - `moflo.md` — Full CLI/MCP reference
@@ -1,6 +1,6 @@
1
- # MoFlo Agent Bootstrap Guide
1
+ # MoFlo Subagents Guide
2
2
 
3
- **Purpose:** Quick-start reference for subagents spawned by coordinators. Every subagent should follow this protocol before doing any work.
3
+ **Purpose:** Protocol for subagents spawned by coordinators. Follow these steps before doing any work.
4
4
 
5
5
  ---
6
6
 
@@ -51,25 +51,11 @@ Use results with score > 0.3. If no good results, fall back to reading project g
51
51
 
52
52
  ---
53
53
 
54
- ## 2. Check Project-Specific Bootstrap
54
+ ## 2. Check for Project-Specific Overrides
55
55
 
56
- **After reading this file, check for a project-specific bootstrap:**
56
+ Claude Code automatically loads all `.claude/guidance/*.md` files into your context. If the consuming project has its own guidance files (e.g., domain rules, entity patterns, tech stack conventions), they are already available to you — no need to read them manually.
57
57
 
58
- ```bash
59
- # Project-specific bootstrap (has domain rules, patterns, templates)
60
- cat .claude/guidance/agent-bootstrap.md 2>/dev/null | head -10
61
- ```
62
-
63
- If `.claude/guidance/agent-bootstrap.md` exists, **read it next**. It contains project-specific rules (entity patterns, multi-tenancy, tech stack conventions) that override generic guidance.
64
-
65
- If no project bootstrap exists, look for general project guidance:
66
-
67
- ```bash
68
- ls .claude/guidance/ 2>/dev/null
69
- cat .claude/guidance/core.md 2>/dev/null | head -50
70
- ```
71
-
72
- Project guidance always takes precedence over generic patterns.
58
+ Project-specific guidance always takes precedence over generic MoFlo guidance.
73
59
 
74
60
  ---
75
61
 
@@ -114,7 +100,7 @@ This applies to ALL `gh` commands that target a repo: `pr create`, `pr merge`, `
114
100
 
115
101
  ### Task Icons (MANDATORY)
116
102
  - `TaskCreate` MUST use **ICON + [Role]** in `subject` and `activeForm`
117
- - Full icon map: `.claude/guidance/shipped/task-icons.md`
103
+ - Full icon map: `.claude/guidance/shipped/moflo-task-icons.md`
118
104
  - Example: `🧪 [Tester] Run unit tests` / activeForm: `🧪 Running unit tests`
119
105
 
120
106
  ---
@@ -634,13 +634,13 @@ All code changes MUST work on Windows, macOS, and Linux. Follow these rules:
634
634
  | `flo` command not found | Not in PATH | Use `npx flo` or `node node_modules/moflo/bin/index-guidance.mjs` |
635
635
  | Bundled guidance not indexed | Running inside moflo repo (same dir) | Bundled guidance only indexes when installed as a dependency in a different project |
636
636
 
637
- See `memory-strategy.md` for memory-specific troubleshooting.
637
+ See `moflo-memory-strategy.md` for memory-specific troubleshooting.
638
638
 
639
639
  ---
640
640
 
641
641
  ## See Also
642
642
 
643
- - `.claude/guidance/agent-bootstrap.md` - Subagent memory-first protocol and store patterns
644
- - `.claude/guidance/task-swarm-integration.md` - Task & swarm coordination with TaskCreate/TaskUpdate
645
- - `.claude/guidance/memory-strategy.md` - Database schema, namespaces, search commands, RAG linking
643
+ - `.claude/guidance/moflo-subagents.md` - Subagents memory-first protocol and store patterns
644
+ - `.claude/guidance/moflo-claude-swarm-cohesion.md` - Task & swarm coordination with TaskCreate/TaskUpdate
645
+ - `.claude/guidance/moflo-memory-strategy.md` - Database schema, namespaces, search commands, RAG linking
646
646
  - `.claude/guidance/guidance-memory-strategy.md` - How to write guidance docs that index well for RAG