moflo 4.8.42 → 4.8.44

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,253 +1,253 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * MoFlo Project Setup
4
- *
5
- * Copies the agent-bootstrap guidance into the consuming project and
6
- * adds a CLAUDE.md section so subagents automatically follow the protocol.
7
- *
8
- * Usage:
9
- * npx flo-setup # First-time setup
10
- * npx flo-setup --update # Refresh bootstrap file after moflo upgrade
11
- * npx flo-setup --check # Check if setup is current
12
- *
13
- * What it does:
14
- * 1. Copies .claude/guidance/agent-bootstrap.md → project's .claude/guidance/moflo-bootstrap.md
15
- * 2. Appends a subagent protocol section to CLAUDE.md (idempotent, with markers)
16
- *
17
- * The project can layer its own .claude/guidance/agent-bootstrap.md on top for
18
- * project-specific rules (companyId, entity templates, etc.).
19
- */
20
-
21
- import { existsSync, readFileSync, writeFileSync, mkdirSync, copyFileSync } from 'node:fs';
22
- import { dirname, resolve, join } from 'node:path';
23
- import { fileURLToPath } from 'node:url';
24
-
25
- const __dirname = dirname(fileURLToPath(import.meta.url));
26
- const mofloRoot = resolve(__dirname, '..');
27
-
28
- const args = process.argv.slice(2);
29
- const updateOnly = args.includes('--update');
30
- const checkOnly = args.includes('--check');
31
-
32
- // Markers for idempotent CLAUDE.md updates — keep in sync with claudemd-generator.ts
33
- const MARKER_START = '<!-- MOFLO:INJECTED:START -->';
34
- const MARKER_END = '<!-- MOFLO:INJECTED:END -->';
35
- // Legacy markers to detect and replace
36
- const LEGACY_STARTS = ['<!-- MOFLO:SUBAGENT-PROTOCOL:START -->', '<!-- MOFLO:START -->'];
37
- const LEGACY_ENDS = ['<!-- MOFLO:SUBAGENT-PROTOCOL:END -->', '<!-- MOFLO:END -->'];
38
-
39
- // Minimal injection — just enough for Claude to work with moflo.
40
- // All detailed docs live in .claude/guidance/shipped/moflo.md.
41
- const CLAUDE_MD_SECTION = `${MARKER_START}
42
- ## MoFlo — AI Agent Orchestration
43
-
44
- This project uses [MoFlo](https://github.com/eric-cielo/moflo) for AI-assisted development workflows.
45
-
46
- ### FIRST ACTION ON EVERY PROMPT: Search Memory
47
-
48
- Your first tool call for every new user prompt MUST be a memory search. Do this BEFORE Glob, Grep, Read, or any file exploration.
49
-
50
- \`\`\`
51
- mcp__moflo__memory_search — query: "<task description>", namespace: "guidance" or "patterns" or "code-map"
52
- \`\`\`
53
-
54
- Search \`guidance\` and \`patterns\` namespaces on every prompt. Search \`code-map\` when navigating the codebase.
55
- When the user asks you to remember something: \`mcp__moflo__memory_store\` with namespace \`knowledge\`.
56
-
57
- ### Workflow Gates (enforced automatically)
58
-
59
- - **Memory-first**: Must search memory before Glob/Grep/Read
60
- - **TaskCreate-first**: Must call TaskCreate before spawning Agent tool
61
-
62
- - **Task Icons**: \`TaskCreate\` MUST use ICON+[Role] format — see \`.claude/guidance/task-icons.md\`
63
-
64
- ### MCP Tools (preferred over CLI)
65
-
66
- | Tool | Purpose |
67
- |------|---------|
68
- | \`mcp__moflo__memory_search\` | Semantic search across indexed knowledge |
69
- | \`mcp__moflo__memory_store\` | Store patterns and decisions |
70
- | \`mcp__moflo__hooks_route\` | Route task to optimal agent type |
71
- | \`mcp__moflo__hooks_pre-task\` | Record task start |
72
- | \`mcp__moflo__hooks_post-task\` | Record task completion for learning |
73
-
74
- ### CLI Fallback
75
-
76
- \`\`\`bash
77
- npx flo-search "[query]" --namespace guidance # Semantic search
78
- npx flo doctor --fix # Health check
79
- \`\`\`
80
-
81
- ### Full Reference
82
-
83
- For CLI commands, hooks, agents, swarm config, memory commands, and moflo.yaml options, see:
84
- \`.claude/guidance/shipped/moflo.md\`
85
- ${MARKER_END}`;
86
-
87
- function log(msg) {
88
- console.log(`[flo-setup] ${msg}`);
89
- }
90
-
91
- function findProjectRoot() {
92
- // Walk up from cwd looking for package.json that depends on moflo
93
- let dir = process.cwd();
94
- const root = resolve(dir, '/');
95
-
96
- while (dir !== root) {
97
- const pkgPath = join(dir, 'package.json');
98
- if (existsSync(pkgPath)) {
99
- try {
100
- const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
101
- const deps = { ...pkg.dependencies, ...pkg.devDependencies };
102
- if (deps && deps.moflo) {
103
- return dir;
104
- }
105
- } catch { /* ignore parse errors */ }
106
- }
107
- dir = dirname(dir);
108
- }
109
-
110
- // Fallback: use cwd if it has a package.json
111
- if (existsSync(join(process.cwd(), 'package.json'))) {
112
- return process.cwd();
113
- }
114
-
115
- return null;
116
- }
117
-
118
- function copyBootstrap(projectRoot) {
119
- const shippedSource = join(mofloRoot, '.claude', 'guidance', 'shipped', 'agent-bootstrap.md');
120
- const source = existsSync(shippedSource)
121
- ? shippedSource
122
- : join(mofloRoot, '.claude', 'guidance', 'agent-bootstrap.md');
123
- const targetDir = join(projectRoot, '.claude', 'guidance');
124
- const target = join(targetDir, 'moflo-bootstrap.md');
125
-
126
- if (!existsSync(source)) {
127
- log('❌ Source bootstrap not found in moflo package');
128
- return false;
129
- }
130
-
131
- // Read source content and prepend auto-generated notice
132
- const content = readFileSync(source, 'utf-8');
133
- const header = `<!-- AUTO-GENERATED by flo-setup. Do not edit — changes will be overwritten. -->
134
- <!-- Source: node_modules/moflo/.claude/guidance/agent-bootstrap.md -->
135
- <!-- To customize, create .claude/guidance/agent-bootstrap.md for project-specific rules. -->
136
-
137
- `;
138
-
139
- mkdirSync(targetDir, { recursive: true });
140
-
141
- // Check if file exists and is current
142
- if (existsSync(target)) {
143
- const existing = readFileSync(target, 'utf-8');
144
- const newContent = header + content;
145
- if (existing === newContent) {
146
- log('✅ moflo-bootstrap.md is current');
147
- return true;
148
- }
149
- log('📝 Updating moflo-bootstrap.md');
150
- } else {
151
- log('📝 Creating .claude/guidance/moflo-bootstrap.md');
152
- }
153
-
154
- if (!checkOnly) {
155
- writeFileSync(target, header + content, 'utf-8');
156
- }
157
- return true;
158
- }
159
-
160
- function updateClaudeMd(projectRoot) {
161
- const claudeMdPath = join(projectRoot, 'CLAUDE.md');
162
-
163
- if (!existsSync(claudeMdPath)) {
164
- if (checkOnly) {
165
- log('⚠️ No CLAUDE.md found');
166
- return false;
167
- }
168
- log('📝 Creating CLAUDE.md with subagent protocol section');
169
- writeFileSync(claudeMdPath, `# Project Configuration\n\n${CLAUDE_MD_SECTION}\n`, 'utf-8');
170
- return true;
171
- }
172
-
173
- const content = readFileSync(claudeMdPath, 'utf-8');
174
-
175
- // Check for current or legacy markers and replace
176
- const allStarts = [MARKER_START, ...LEGACY_STARTS];
177
- const allEnds = [MARKER_END, ...LEGACY_ENDS];
178
-
179
- for (let i = 0; i < allStarts.length; i++) {
180
- if (content.includes(allStarts[i])) {
181
- const startIdx = content.indexOf(allStarts[i]);
182
- const endIdx = content.indexOf(allEnds[i]);
183
-
184
- if (endIdx > startIdx) {
185
- // If current markers and content matches, we're up to date
186
- if (i === 0) {
187
- const existingSection = content.substring(startIdx, endIdx + allEnds[i].length);
188
- if (existingSection === CLAUDE_MD_SECTION) {
189
- log('✅ CLAUDE.md moflo section is current');
190
- return true;
191
- }
192
- }
193
-
194
- // Replace (current or legacy) with new section
195
- if (!checkOnly) {
196
- const updated = content.substring(0, startIdx) + CLAUDE_MD_SECTION + content.substring(endIdx + allEnds[i].length);
197
- writeFileSync(claudeMdPath, updated, 'utf-8');
198
- log(i === 0 ? '📝 Updated CLAUDE.md moflo section' : '📝 Replaced legacy CLAUDE.md section with minimal moflo injection');
199
- } else {
200
- log('⚠️ CLAUDE.md moflo section needs update');
201
- }
202
- return true;
203
- }
204
- }
205
- }
206
-
207
- if (updateOnly) {
208
- log('⚠️ CLAUDE.md has no moflo section (run without --update to add)');
209
- return false;
210
- }
211
-
212
- if (checkOnly) {
213
- log('⚠️ CLAUDE.md missing subagent protocol section');
214
- return false;
215
- }
216
-
217
- // Append section to end of CLAUDE.md
218
- const separator = content.endsWith('\n') ? '\n' : '\n\n';
219
- writeFileSync(claudeMdPath, content + separator + CLAUDE_MD_SECTION + '\n', 'utf-8');
220
- log('📝 Added subagent protocol section to CLAUDE.md');
221
- return true;
222
- }
223
-
224
- function main() {
225
- console.log('');
226
- console.log('MoFlo Project Setup');
227
- console.log('───────────────────');
228
-
229
- const projectRoot = findProjectRoot();
230
- if (!projectRoot) {
231
- log('❌ Could not find project root (no package.json with moflo dependency)');
232
- process.exit(1);
233
- }
234
-
235
- log(`Project: ${projectRoot}`);
236
- console.log('');
237
-
238
- // Step 1: Copy bootstrap file
239
- const bootstrapOk = copyBootstrap(projectRoot);
240
-
241
- // Step 2: Update CLAUDE.md (skip on --update, only refresh the file)
242
- const claudeOk = updateOnly ? true : updateClaudeMd(projectRoot);
243
-
244
- console.log('');
245
- if (checkOnly) {
246
- log(bootstrapOk && claudeOk ? '✅ Setup is current' : '⚠️ Setup needs attention');
247
- } else {
248
- log('✅ Done. Subagents will now follow the MoFlo bootstrap protocol.');
249
- }
250
- console.log('');
251
- }
252
-
253
- main();
2
+ /**
3
+ * MoFlo Project Setup
4
+ *
5
+ * Copies the subagents guidance into the consuming project and
6
+ * adds a CLAUDE.md section so subagents automatically follow the protocol.
7
+ *
8
+ * Usage:
9
+ * npx flo-setup # First-time setup
10
+ * npx flo-setup --update # Refresh bootstrap file after moflo upgrade
11
+ * npx flo-setup --check # Check if setup is current
12
+ *
13
+ * What it does:
14
+ * 1. Copies .claude/guidance/subagents.md → project's .claude/guidance/moflo-bootstrap.md
15
+ * 2. Appends a subagent protocol section to CLAUDE.md (idempotent, with markers)
16
+ *
17
+ * The project can layer its own .claude/guidance/subagents.md on top for
18
+ * project-specific rules (companyId, entity templates, etc.).
19
+ */
20
+
21
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, copyFileSync } from 'node:fs';
22
+ import { dirname, resolve, join } from 'node:path';
23
+ import { fileURLToPath } from 'node:url';
24
+
25
+ const __dirname = dirname(fileURLToPath(import.meta.url));
26
+ const mofloRoot = resolve(__dirname, '..');
27
+
28
+ const args = process.argv.slice(2);
29
+ const updateOnly = args.includes('--update');
30
+ const checkOnly = args.includes('--check');
31
+
32
+ // Markers for idempotent CLAUDE.md updates — keep in sync with claudemd-generator.ts
33
+ const MARKER_START = '<!-- MOFLO:INJECTED:START -->';
34
+ const MARKER_END = '<!-- MOFLO:INJECTED:END -->';
35
+ // Legacy markers to detect and replace
36
+ const LEGACY_STARTS = ['<!-- MOFLO:SUBAGENT-PROTOCOL:START -->', '<!-- MOFLO:START -->'];
37
+ const LEGACY_ENDS = ['<!-- MOFLO:SUBAGENT-PROTOCOL:END -->', '<!-- MOFLO:END -->'];
38
+
39
+ // Minimal injection — just enough for Claude to work with moflo.
40
+ // All detailed docs live in .claude/guidance/shipped/moflo.md.
41
+ const CLAUDE_MD_SECTION = `${MARKER_START}
42
+ ## MoFlo — AI Agent Orchestration
43
+
44
+ This project uses [MoFlo](https://github.com/eric-cielo/moflo) for AI-assisted development workflows.
45
+
46
+ ### FIRST ACTION ON EVERY PROMPT: Search Memory
47
+
48
+ Your first tool call for every new user prompt MUST be a memory search. Do this BEFORE Glob, Grep, Read, or any file exploration.
49
+
50
+ \`\`\`
51
+ mcp__moflo__memory_search — query: "<task description>", namespace: "guidance" or "patterns" or "code-map"
52
+ \`\`\`
53
+
54
+ Search \`guidance\` and \`patterns\` namespaces on every prompt. Search \`code-map\` when navigating the codebase.
55
+ When the user asks you to remember something: \`mcp__moflo__memory_store\` with namespace \`knowledge\`.
56
+
57
+ ### Workflow Gates (enforced automatically)
58
+
59
+ - **Memory-first**: Must search memory before Glob/Grep/Read
60
+ - **TaskCreate-first**: Must call TaskCreate before spawning Agent tool
61
+
62
+ - **Task Icons**: \`TaskCreate\` MUST use ICON+[Role] format — see \`.claude/guidance/task-icons.md\`
63
+
64
+ ### MCP Tools (preferred over CLI)
65
+
66
+ | Tool | Purpose |
67
+ |------|---------|
68
+ | \`mcp__moflo__memory_search\` | Semantic search across indexed knowledge |
69
+ | \`mcp__moflo__memory_store\` | Store patterns and decisions |
70
+ | \`mcp__moflo__hooks_route\` | Route task to optimal agent type |
71
+ | \`mcp__moflo__hooks_pre-task\` | Record task start |
72
+ | \`mcp__moflo__hooks_post-task\` | Record task completion for learning |
73
+
74
+ ### CLI Fallback
75
+
76
+ \`\`\`bash
77
+ npx flo-search "[query]" --namespace guidance # Semantic search
78
+ npx flo doctor --fix # Health check
79
+ \`\`\`
80
+
81
+ ### Full Reference
82
+
83
+ For CLI commands, hooks, agents, swarm config, memory commands, and moflo.yaml options, see:
84
+ \`.claude/guidance/shipped/moflo.md\`
85
+ ${MARKER_END}`;
86
+
87
+ function log(msg) {
88
+ console.log(`[flo-setup] ${msg}`);
89
+ }
90
+
91
+ function findProjectRoot() {
92
+ // Walk up from cwd looking for package.json that depends on moflo
93
+ let dir = process.cwd();
94
+ const root = resolve(dir, '/');
95
+
96
+ while (dir !== root) {
97
+ const pkgPath = join(dir, 'package.json');
98
+ if (existsSync(pkgPath)) {
99
+ try {
100
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
101
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
102
+ if (deps && deps.moflo) {
103
+ return dir;
104
+ }
105
+ } catch { /* ignore parse errors */ }
106
+ }
107
+ dir = dirname(dir);
108
+ }
109
+
110
+ // Fallback: use cwd if it has a package.json
111
+ if (existsSync(join(process.cwd(), 'package.json'))) {
112
+ return process.cwd();
113
+ }
114
+
115
+ return null;
116
+ }
117
+
118
+ function copyBootstrap(projectRoot) {
119
+ const shippedSource = join(mofloRoot, '.claude', 'guidance', 'shipped', 'subagents.md');
120
+ const source = existsSync(shippedSource)
121
+ ? shippedSource
122
+ : join(mofloRoot, '.claude', 'guidance', 'subagents.md');
123
+ const targetDir = join(projectRoot, '.claude', 'guidance');
124
+ const target = join(targetDir, 'moflo-bootstrap.md');
125
+
126
+ if (!existsSync(source)) {
127
+ log('❌ Source bootstrap not found in moflo package');
128
+ return false;
129
+ }
130
+
131
+ // Read source content and prepend auto-generated notice
132
+ const content = readFileSync(source, 'utf-8');
133
+ const header = `<!-- AUTO-GENERATED by flo-setup. Do not edit — changes will be overwritten. -->
134
+ <!-- Source: node_modules/moflo/.claude/guidance/subagents.md -->
135
+ <!-- To customize, create .claude/guidance/subagents.md for project-specific rules. -->
136
+
137
+ `;
138
+
139
+ mkdirSync(targetDir, { recursive: true });
140
+
141
+ // Check if file exists and is current
142
+ if (existsSync(target)) {
143
+ const existing = readFileSync(target, 'utf-8');
144
+ const newContent = header + content;
145
+ if (existing === newContent) {
146
+ log('✅ moflo-bootstrap.md is current');
147
+ return true;
148
+ }
149
+ log('📝 Updating moflo-bootstrap.md');
150
+ } else {
151
+ log('📝 Creating .claude/guidance/moflo-bootstrap.md');
152
+ }
153
+
154
+ if (!checkOnly) {
155
+ writeFileSync(target, header + content, 'utf-8');
156
+ }
157
+ return true;
158
+ }
159
+
160
+ function updateClaudeMd(projectRoot) {
161
+ const claudeMdPath = join(projectRoot, 'CLAUDE.md');
162
+
163
+ if (!existsSync(claudeMdPath)) {
164
+ if (checkOnly) {
165
+ log('⚠️ No CLAUDE.md found');
166
+ return false;
167
+ }
168
+ log('📝 Creating CLAUDE.md with subagent protocol section');
169
+ writeFileSync(claudeMdPath, `# Project Configuration\n\n${CLAUDE_MD_SECTION}\n`, 'utf-8');
170
+ return true;
171
+ }
172
+
173
+ const content = readFileSync(claudeMdPath, 'utf-8');
174
+
175
+ // Check for current or legacy markers and replace
176
+ const allStarts = [MARKER_START, ...LEGACY_STARTS];
177
+ const allEnds = [MARKER_END, ...LEGACY_ENDS];
178
+
179
+ for (let i = 0; i < allStarts.length; i++) {
180
+ if (content.includes(allStarts[i])) {
181
+ const startIdx = content.indexOf(allStarts[i]);
182
+ const endIdx = content.indexOf(allEnds[i]);
183
+
184
+ if (endIdx > startIdx) {
185
+ // If current markers and content matches, we're up to date
186
+ if (i === 0) {
187
+ const existingSection = content.substring(startIdx, endIdx + allEnds[i].length);
188
+ if (existingSection === CLAUDE_MD_SECTION) {
189
+ log('✅ CLAUDE.md moflo section is current');
190
+ return true;
191
+ }
192
+ }
193
+
194
+ // Replace (current or legacy) with new section
195
+ if (!checkOnly) {
196
+ const updated = content.substring(0, startIdx) + CLAUDE_MD_SECTION + content.substring(endIdx + allEnds[i].length);
197
+ writeFileSync(claudeMdPath, updated, 'utf-8');
198
+ log(i === 0 ? '📝 Updated CLAUDE.md moflo section' : '📝 Replaced legacy CLAUDE.md section with minimal moflo injection');
199
+ } else {
200
+ log('⚠️ CLAUDE.md moflo section needs update');
201
+ }
202
+ return true;
203
+ }
204
+ }
205
+ }
206
+
207
+ if (updateOnly) {
208
+ log('⚠️ CLAUDE.md has no moflo section (run without --update to add)');
209
+ return false;
210
+ }
211
+
212
+ if (checkOnly) {
213
+ log('⚠️ CLAUDE.md missing subagent protocol section');
214
+ return false;
215
+ }
216
+
217
+ // Append section to end of CLAUDE.md
218
+ const separator = content.endsWith('\n') ? '\n' : '\n\n';
219
+ writeFileSync(claudeMdPath, content + separator + CLAUDE_MD_SECTION + '\n', 'utf-8');
220
+ log('📝 Added subagent protocol section to CLAUDE.md');
221
+ return true;
222
+ }
223
+
224
+ function main() {
225
+ console.log('');
226
+ console.log('MoFlo Project Setup');
227
+ console.log('───────────────────');
228
+
229
+ const projectRoot = findProjectRoot();
230
+ if (!projectRoot) {
231
+ log('❌ Could not find project root (no package.json with moflo dependency)');
232
+ process.exit(1);
233
+ }
234
+
235
+ log(`Project: ${projectRoot}`);
236
+ console.log('');
237
+
238
+ // Step 1: Copy bootstrap file
239
+ const bootstrapOk = copyBootstrap(projectRoot);
240
+
241
+ // Step 2: Update CLAUDE.md (skip on --update, only refresh the file)
242
+ const claudeOk = updateOnly ? true : updateClaudeMd(projectRoot);
243
+
244
+ console.log('');
245
+ if (checkOnly) {
246
+ log(bootstrapOk && claudeOk ? '✅ Setup is current' : '⚠️ Setup needs attention');
247
+ } else {
248
+ log('✅ Done. Subagents will now follow the MoFlo bootstrap protocol.');
249
+ }
250
+ console.log('');
251
+ }
252
+
253
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moflo",
3
- "version": "4.8.42",
3
+ "version": "4.8.44",
4
4
  "description": "MoFlo — AI agent orchestration for Claude Code. Forked from ruflo/claude-flow with patches applied to source, plus feature-level orchestration.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -162,11 +162,11 @@ flo gate session-reset # Reset workflow state
162
162
  Sequence multiple GitHub issues through `/flo` workflows using a YAML definition:
163
163
 
164
164
  ```bash
165
- flo orc run feature.yaml # Execute a feature (stories in dependency order)
166
- flo orc run feature.yaml --dry-run # Show execution plan without running
167
- flo orc run feature.yaml --verbose # Execute with Claude output streaming
168
- flo orc status my-feature # Check progress of a feature
169
- flo orc reset my-feature # Reset feature state for re-run
165
+ flo epic run feature.yaml # Execute a feature (stories in dependency order)
166
+ flo epic run feature.yaml --dry-run # Show execution plan without running
167
+ flo epic run feature.yaml --verbose # Execute with Claude output streaming
168
+ flo epic status my-feature # Check progress of a feature
169
+ flo epic reset my-feature # Reset feature state for re-run
170
170
  ```
171
171
 
172
172
  Feature YAML example:
@@ -409,7 +409,7 @@ Here's how a typical task flows through both layers:
409
409
 
410
410
  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.
411
411
 
412
- 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`.
412
+ 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/moflo-claude-swarm-cohesion.md`.
413
413
 
414
414
  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.
415
415