moflo 4.6.11 → 4.7.1
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/helpers/hook-handler.cjs +35 -6
- package/.claude/settings.json +4 -4
- package/.claude/workflow-state.json +5 -0
- package/README.md +11 -1
- package/bin/hooks.mjs +519 -0
- package/bin/session-start-launcher.mjs +63 -0
- package/bin/setup-project.mjs +1 -1
- package/package.json +3 -2
- package/src/@claude-flow/cli/README.md +452 -7536
- package/src/@claude-flow/cli/dist/src/commands/doctor.js +1 -1
- package/src/@claude-flow/cli/dist/src/commands/embeddings.js +4 -4
- package/src/@claude-flow/cli/dist/src/commands/init.js +35 -8
- package/src/@claude-flow/cli/dist/src/commands/swarm.js +2 -2
- package/src/@claude-flow/cli/dist/src/init/claudemd-generator.js +316 -294
- package/src/@claude-flow/cli/dist/src/init/executor.js +461 -465
- package/src/@claude-flow/cli/dist/src/init/helpers-generator.d.ts +0 -36
- package/src/@claude-flow/cli/dist/src/init/helpers-generator.js +146 -1124
- package/src/@claude-flow/cli/dist/src/init/index.d.ts +1 -1
- package/src/@claude-flow/cli/dist/src/init/index.js +1 -1
- package/src/@claude-flow/cli/dist/src/init/mcp-generator.js +6 -3
- package/src/@claude-flow/cli/dist/src/init/moflo-init.js +108 -424
- package/src/@claude-flow/cli/dist/src/init/settings-generator.js +50 -120
- package/src/@claude-flow/cli/dist/src/init/types.d.ts +2 -0
- package/src/@claude-flow/cli/dist/src/init/types.js +2 -0
- package/src/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +275 -32
- package/src/@claude-flow/cli/dist/src/plugins/store/discovery.js +4 -204
- package/src/@claude-flow/cli/dist/src/plugins/tests/standalone-test.js +4 -4
- package/src/@claude-flow/cli/dist/src/runtime/headless.d.ts +3 -3
- package/src/@claude-flow/cli/dist/src/runtime/headless.js +31 -31
- package/src/@claude-flow/cli/dist/src/services/agentic-flow-bridge.d.ts +3 -3
- package/src/@claude-flow/cli/dist/src/services/agentic-flow-bridge.js +3 -1
- package/src/@claude-flow/cli/dist/src/services/headless-worker-executor.js +14 -0
- package/src/@claude-flow/cli/dist/src/services/workflow-gate.js +21 -1
- package/src/@claude-flow/cli/dist/src/transfer/store/tests/standalone-test.js +4 -4
- package/src/@claude-flow/cli/package.json +1 -1
|
@@ -6,7 +6,7 @@ export { type InitOptions, type InitComponents, type InitResult, type HooksConfi
|
|
|
6
6
|
export { generateSettings, generateSettingsJson, } from './settings-generator.js';
|
|
7
7
|
export { generateMCPConfig, generateMCPJson, generateMCPCommands, } from './mcp-generator.js';
|
|
8
8
|
export { generateStatuslineScript, generateStatuslineHook, } from './statusline-generator.js';
|
|
9
|
-
export { generatePreCommitHook, generatePostCommitHook,
|
|
9
|
+
export { generatePreCommitHook, generatePostCommitHook, generateAutoMemoryHook, generateHelpers, } from './helpers-generator.js';
|
|
10
10
|
export { generateClaudeMd, generateMinimalClaudeMd, CLAUDE_MD_TEMPLATES, } from './claudemd-generator.js';
|
|
11
11
|
export { executeInit, executeUpgrade, executeUpgradeWithMissing, default } from './executor.js';
|
|
12
12
|
export type { UpgradeResult } from './executor.js';
|
|
@@ -8,7 +8,7 @@ export { DEFAULT_INIT_OPTIONS, MINIMAL_INIT_OPTIONS, FULL_INIT_OPTIONS, detectPl
|
|
|
8
8
|
export { generateSettings, generateSettingsJson, } from './settings-generator.js';
|
|
9
9
|
export { generateMCPConfig, generateMCPJson, generateMCPCommands, } from './mcp-generator.js';
|
|
10
10
|
export { generateStatuslineScript, generateStatuslineHook, } from './statusline-generator.js';
|
|
11
|
-
export { generatePreCommitHook, generatePostCommitHook,
|
|
11
|
+
export { generatePreCommitHook, generatePostCommitHook, generateAutoMemoryHook, generateHelpers, } from './helpers-generator.js';
|
|
12
12
|
export { generateClaudeMd, generateMinimalClaudeMd, CLAUDE_MD_TEMPLATES, } from './claudemd-generator.js';
|
|
13
13
|
// Main executor
|
|
14
14
|
export { executeInit, executeUpgrade, executeUpgradeWithMissing, default } from './executor.js';
|
|
@@ -29,6 +29,9 @@ export function generateMCPConfig(options) {
|
|
|
29
29
|
const npmEnv = {
|
|
30
30
|
npm_config_update_notifier: 'false',
|
|
31
31
|
};
|
|
32
|
+
// When toolDefer is true, emit "deferred" so Claude Code loads schemas on
|
|
33
|
+
// demand via ToolSearch instead of putting 150+ schemas into context at startup.
|
|
34
|
+
const deferProps = config.toolDefer ? { toolDefer: 'deferred' } : {};
|
|
32
35
|
// Claude Flow MCP server (core)
|
|
33
36
|
if (config.claudeFlow) {
|
|
34
37
|
mcpServers['claude-flow'] = createMCPServerEntry(['@claude-flow/cli@latest', 'mcp', 'start'], {
|
|
@@ -38,15 +41,15 @@ export function generateMCPConfig(options) {
|
|
|
38
41
|
CLAUDE_FLOW_TOPOLOGY: options.runtime.topology,
|
|
39
42
|
CLAUDE_FLOW_MAX_AGENTS: String(options.runtime.maxAgents),
|
|
40
43
|
CLAUDE_FLOW_MEMORY_BACKEND: options.runtime.memoryBackend,
|
|
41
|
-
}, { autoStart: config.autoStart });
|
|
44
|
+
}, { autoStart: config.autoStart, ...deferProps });
|
|
42
45
|
}
|
|
43
46
|
// Ruv-Swarm MCP server (enhanced coordination)
|
|
44
47
|
if (config.ruvSwarm) {
|
|
45
|
-
mcpServers['ruv-swarm'] = createMCPServerEntry(['ruv-swarm', 'mcp', 'start'], { ...npmEnv }, { optional: true });
|
|
48
|
+
mcpServers['ruv-swarm'] = createMCPServerEntry(['ruv-swarm', 'mcp', 'start'], { ...npmEnv }, { optional: true, ...deferProps });
|
|
46
49
|
}
|
|
47
50
|
// Flow Nexus MCP server (cloud features)
|
|
48
51
|
if (config.flowNexus) {
|
|
49
|
-
mcpServers['flow-nexus'] = createMCPServerEntry(['flow-nexus@latest', 'mcp', 'start'], { ...npmEnv }, { optional: true, requiresAuth: true });
|
|
52
|
+
mcpServers['flow-nexus'] = createMCPServerEntry(['flow-nexus@latest', 'mcp', 'start'], { ...npmEnv }, { optional: true, requiresAuth: true, ...deferProps });
|
|
50
53
|
}
|
|
51
54
|
return { mcpServers };
|
|
52
55
|
}
|
|
@@ -20,9 +20,9 @@ import * as path from 'path';
|
|
|
20
20
|
async function runWizard(root) {
|
|
21
21
|
const { confirm, input } = await import('../prompt.js');
|
|
22
22
|
// Detect project structure
|
|
23
|
-
const guidanceCandidates = ['.claude/guidance', 'docs/guides', 'docs'];
|
|
23
|
+
const guidanceCandidates = ['.claude/guidance', 'docs/guides', 'docs', 'architecture', 'adr', '.cursor/rules'];
|
|
24
24
|
const detectedGuidance = guidanceCandidates.filter(d => fs.existsSync(path.join(root, d)));
|
|
25
|
-
const srcCandidates = ['src', 'packages', 'lib', 'app', 'apps', 'services'];
|
|
25
|
+
const srcCandidates = ['src', 'packages', 'lib', 'app', 'apps', 'services', 'server', 'client'];
|
|
26
26
|
const detectedSrc = srcCandidates.filter(d => fs.existsSync(path.join(root, d)));
|
|
27
27
|
// Ask questions
|
|
28
28
|
const guidance = await confirm({
|
|
@@ -67,11 +67,11 @@ async function runWizard(root) {
|
|
|
67
67
|
* Get default answers (--yes mode).
|
|
68
68
|
*/
|
|
69
69
|
function defaultAnswers(root) {
|
|
70
|
-
const guidanceCandidates = ['.claude/guidance', 'docs/guides', 'docs'];
|
|
70
|
+
const guidanceCandidates = ['.claude/guidance', 'docs/guides', 'docs', 'architecture', 'adr', '.cursor/rules'];
|
|
71
71
|
const guidanceDirs = guidanceCandidates.filter(d => fs.existsSync(path.join(root, d)));
|
|
72
72
|
if (guidanceDirs.length === 0)
|
|
73
73
|
guidanceDirs.push('.claude/guidance');
|
|
74
|
-
const srcCandidates = ['src', 'packages', 'lib', 'app', 'apps', 'services'];
|
|
74
|
+
const srcCandidates = ['src', 'packages', 'lib', 'app', 'apps', 'services', 'server', 'client'];
|
|
75
75
|
const srcDirs = srcCandidates.filter(d => fs.existsSync(path.join(root, d)));
|
|
76
76
|
if (srcDirs.length === 0)
|
|
77
77
|
srcDirs.push('src');
|
|
@@ -100,7 +100,9 @@ export async function initMoflo(options) {
|
|
|
100
100
|
steps.push(generateSkill(projectRoot, force));
|
|
101
101
|
// Step 4: CLAUDE.md MoFlo section
|
|
102
102
|
steps.push(generateClaudeMd(projectRoot, force));
|
|
103
|
-
// Step 5: .
|
|
103
|
+
// Step 5: .claude/scripts/ from moflo bin/
|
|
104
|
+
steps.push(syncScripts(projectRoot, force));
|
|
105
|
+
// Step 6: .gitignore entries
|
|
104
106
|
steps.push(updateGitignore(projectRoot));
|
|
105
107
|
return { steps };
|
|
106
108
|
}
|
|
@@ -180,15 +182,22 @@ hooks:
|
|
|
180
182
|
session_restore: true # Restore session state on start
|
|
181
183
|
notification: true # Hook into Claude Code notifications
|
|
182
184
|
|
|
185
|
+
# MCP server options
|
|
186
|
+
mcp:
|
|
187
|
+
tool_defer: deferred # Defer 150+ tool schemas; loaded on demand via ToolSearch
|
|
188
|
+
auto_start: false # Auto-start MCP server on session begin
|
|
189
|
+
|
|
183
190
|
# Status line display (shown at bottom of Claude Code)
|
|
184
|
-
# mode: "single-line"
|
|
191
|
+
# mode: "compact" (default), "single-line", or "dashboard" (full multi-line)
|
|
185
192
|
status_line:
|
|
186
193
|
enabled: true
|
|
187
|
-
mode:
|
|
194
|
+
mode: compact
|
|
188
195
|
branding: "MoFlo V4"
|
|
189
196
|
show_git: true
|
|
190
|
-
show_model: true
|
|
191
197
|
show_session: true
|
|
198
|
+
show_swarm: true
|
|
199
|
+
show_agentdb: true
|
|
200
|
+
show_mcp: true
|
|
192
201
|
|
|
193
202
|
# Model preferences (haiku, sonnet, opus)
|
|
194
203
|
models:
|
|
@@ -292,6 +301,14 @@ function generateHooks(root, force, answers) {
|
|
|
292
301
|
"timeout": 5000
|
|
293
302
|
}
|
|
294
303
|
]
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"matcher": "^Bash$",
|
|
307
|
+
"hooks": [{
|
|
308
|
+
"type": "command",
|
|
309
|
+
"command": "npx flo gate check-dangerous-command",
|
|
310
|
+
"timeout": 2000
|
|
311
|
+
}]
|
|
295
312
|
}
|
|
296
313
|
],
|
|
297
314
|
"PostToolUse": [
|
|
@@ -372,6 +389,15 @@ function generateHooks(root, force, answers) {
|
|
|
372
389
|
}]
|
|
373
390
|
}
|
|
374
391
|
],
|
|
392
|
+
"PreCompact": [
|
|
393
|
+
{
|
|
394
|
+
"hooks": [{
|
|
395
|
+
"type": "command",
|
|
396
|
+
"command": "npx flo gate compact-guidance",
|
|
397
|
+
"timeout": 3000
|
|
398
|
+
}]
|
|
399
|
+
}
|
|
400
|
+
],
|
|
375
401
|
"Notification": [
|
|
376
402
|
{
|
|
377
403
|
"hooks": [{
|
|
@@ -401,419 +427,23 @@ function generateSkill(root, force) {
|
|
|
401
427
|
if (!fs.existsSync(skillDir)) {
|
|
402
428
|
fs.mkdirSync(skillDir, { recursive: true });
|
|
403
429
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
/flo
|
|
420
|
-
|
|
421
|
-
/flo --enhance <issue-number> # Same as -e
|
|
422
|
-
/flo -r <issue-number> # Research only: analyze issue, output findings
|
|
423
|
-
/flo --research <issue-number> # Same as -r
|
|
424
|
-
\`\`\`
|
|
425
|
-
|
|
426
|
-
Also available as \`/fl\` (shorthand alias).
|
|
427
|
-
|
|
428
|
-
### Execution Mode (how work is done)
|
|
429
|
-
|
|
430
|
-
\`\`\`
|
|
431
|
-
/flo 123 # SWARM mode (default) - multi-agent coordination
|
|
432
|
-
/flo -sw 123 # SWARM mode (explicit)
|
|
433
|
-
/flo --swarm 123 # Same as -sw
|
|
434
|
-
/flo -hv 123 # HIVE-MIND mode - consensus-based coordination
|
|
435
|
-
/flo --hive 123 # Same as -hv
|
|
436
|
-
/flo -n 123 # NAKED mode - single Claude, no agents
|
|
437
|
-
/flo --naked 123 # Same as -n
|
|
438
|
-
\`\`\`
|
|
439
|
-
|
|
440
|
-
### Epic Handling
|
|
441
|
-
|
|
442
|
-
\`\`\`
|
|
443
|
-
/flo 42 # If #42 is an epic, processes all stories sequentially
|
|
444
|
-
\`\`\`
|
|
445
|
-
|
|
446
|
-
**Epic Detection:** Issues with \`epic\` label or containing \`## Stories\` / \`## Tasks\` sections are automatically detected as epics.
|
|
447
|
-
|
|
448
|
-
**Sequential Processing:** When an epic is selected:
|
|
449
|
-
1. List all child stories/tasks (from checklist or linked issues)
|
|
450
|
-
2. Process each story **one at a time** in order
|
|
451
|
-
3. Each story goes through the full workflow (research -> enhance -> implement -> test -> PR)
|
|
452
|
-
4. After each story's PR is created, move to the next story
|
|
453
|
-
5. Continue until all stories are complete
|
|
454
|
-
|
|
455
|
-
### Combined Examples
|
|
456
|
-
|
|
457
|
-
\`\`\`
|
|
458
|
-
/flo 123 # Swarm + full workflow (default) - includes ALL tests
|
|
459
|
-
/flo 42 # If #42 is epic, processes stories sequentially
|
|
460
|
-
/flo -e 123 # Swarm + enhance only (no implementation)
|
|
461
|
-
/flo -hv -e 123 # Hive-mind + enhance only
|
|
462
|
-
/flo -n -r 123 # Naked + research only
|
|
463
|
-
/flo --swarm --enhance 123 # Explicit swarm + enhance only
|
|
464
|
-
/flo -n 123 # Naked + full workflow (still runs all tests)
|
|
465
|
-
\`\`\`
|
|
466
|
-
|
|
467
|
-
## SWARM IS MANDATORY BY DEFAULT
|
|
468
|
-
|
|
469
|
-
Even if a task "looks simple", you MUST use swarm coordination unless
|
|
470
|
-
the user explicitly passes -n/--naked. "Simple" is a trap. Tasks have
|
|
471
|
-
hidden complexity. Swarm catches it.
|
|
472
|
-
|
|
473
|
-
THE ONLY WAY TO SKIP SWARM: User passes -n or --naked explicitly.
|
|
474
|
-
|
|
475
|
-
## COMPREHENSIVE TESTING REQUIREMENT
|
|
476
|
-
|
|
477
|
-
ALL tests MUST pass BEFORE PR creation - NO EXCEPTIONS.
|
|
478
|
-
- Unit Tests: MANDATORY for all new/modified code
|
|
479
|
-
- Integration Tests: MANDATORY for API endpoints and services
|
|
480
|
-
- E2E Tests: MANDATORY for user-facing features
|
|
481
|
-
PR CANNOT BE CREATED until all relevant tests pass.
|
|
482
|
-
|
|
483
|
-
## Workflow Overview
|
|
484
|
-
|
|
485
|
-
\`\`\`
|
|
486
|
-
Research -> Enhance -> Execute -> Testing -> Simplify -> PR+Done
|
|
487
|
-
|
|
488
|
-
Research: Fetch issue, search memory, read guidance, find files
|
|
489
|
-
Enhance: Update GitHub issue with tech analysis, affected files, impl plan
|
|
490
|
-
Execute: Assign self, create branch, implement changes
|
|
491
|
-
Testing: Unit + Integration + E2E tests (ALL MUST PASS - gate)
|
|
492
|
-
Simplify: Run /simplify on changed code (gate - must run before PR)
|
|
493
|
-
PR+Done: Create PR, update issue status, store learnings
|
|
494
|
-
\`\`\`
|
|
495
|
-
|
|
496
|
-
### Workflow Gates
|
|
497
|
-
|
|
498
|
-
| Gate | Requirement | Blocked Action |
|
|
499
|
-
|------|-------------|----------------|
|
|
500
|
-
| **Testing Gate** | Unit + Integration + E2E must pass | PR creation |
|
|
501
|
-
| **Simplification Gate** | /simplify must run on changed files | PR creation |
|
|
502
|
-
|
|
503
|
-
### Execution Mode (applies to all phases)
|
|
504
|
-
|
|
505
|
-
| Mode | Description |
|
|
506
|
-
|------|-------------|
|
|
507
|
-
| **SWARM** (default) | Multi-agent via Task tool: researcher, coder, tester, reviewer |
|
|
508
|
-
| **HIVE-MIND** (-hv) | Consensus-based coordination for architecture decisions |
|
|
509
|
-
| **NAKED** (-n) | Single Claude, no agent spawning. Only when user explicitly requests. |
|
|
510
|
-
|
|
511
|
-
## Phase 1: Research (-r or default first step)
|
|
512
|
-
|
|
513
|
-
### 1.1 Fetch Issue Details
|
|
514
|
-
\`\`\`bash
|
|
515
|
-
gh issue view <issue-number> --json number,title,body,labels,state,assignees,comments,milestone
|
|
516
|
-
\`\`\`
|
|
517
|
-
|
|
518
|
-
### 1.2 Check Enhancement Status
|
|
519
|
-
Look for \`## Implementation Plan\` marker in issue body.
|
|
520
|
-
- **If present**: Issue already enhanced, skip to execute or confirm
|
|
521
|
-
- **If absent**: Proceed with research and enhancement
|
|
522
|
-
|
|
523
|
-
### 1.3 Search Memory FIRST
|
|
524
|
-
ALWAYS search memory BEFORE reading guidance or docs files.
|
|
525
|
-
Memory has file paths, context, and patterns - often all you need.
|
|
526
|
-
Only read guidance files if memory search returns zero relevant results.
|
|
527
|
-
|
|
528
|
-
\`\`\`bash
|
|
529
|
-
npx flo memory search --query "<issue title keywords>" --namespace patterns
|
|
530
|
-
npx flo memory search --query "<domain keywords>" --namespace guidance
|
|
531
|
-
\`\`\`
|
|
532
|
-
|
|
533
|
-
Or via MCP: \`mcp__claude-flow__memory_search\`
|
|
534
|
-
|
|
535
|
-
### 1.4 Read Guidance Docs (ONLY if memory insufficient)
|
|
536
|
-
**Only if memory search returned < 3 relevant results**, read guidance files:
|
|
537
|
-
- Bug -> testing patterns, error handling
|
|
538
|
-
- Feature -> domain model, architecture
|
|
539
|
-
- UI -> frontend patterns, components
|
|
540
|
-
|
|
541
|
-
### 1.5 Research Codebase
|
|
542
|
-
Use Task tool with Explore agent to find:
|
|
543
|
-
- Affected files and their current state
|
|
544
|
-
- Related code and dependencies
|
|
545
|
-
- Existing patterns to follow
|
|
546
|
-
- Test coverage gaps
|
|
547
|
-
|
|
548
|
-
## Phase 2: Enhance (-e includes research + enhancement)
|
|
549
|
-
|
|
550
|
-
### 2.1 Build Enhancement
|
|
551
|
-
Compile research into structured enhancement:
|
|
552
|
-
|
|
553
|
-
**Technical Analysis** - Root cause (bugs) or approach (features), impact, risk factors
|
|
554
|
-
|
|
555
|
-
**Affected Files** - Files to modify (with line numbers), new files, deletions
|
|
556
|
-
|
|
557
|
-
**Implementation Plan** - Numbered steps with clear actions, dependencies, decision points
|
|
558
|
-
|
|
559
|
-
**Test Plan** - Unit tests to add/update, integration tests needed, manual testing checklist
|
|
560
|
-
|
|
561
|
-
**Estimates** - Complexity (Low/Medium/High), scope (# files, # new tests)
|
|
562
|
-
|
|
563
|
-
### 2.2 Update GitHub Issue
|
|
564
|
-
\`\`\`bash
|
|
565
|
-
gh issue edit <issue-number> --body "<original body + Technical Analysis + Affected Files + Implementation Plan + Test Plan + Estimates>"
|
|
566
|
-
\`\`\`
|
|
567
|
-
|
|
568
|
-
### 2.3 Add Enhancement Comment
|
|
569
|
-
\`\`\`bash
|
|
570
|
-
gh issue comment <issue-number> --body "Issue enhanced with implementation plan. Ready for execution."
|
|
571
|
-
\`\`\`
|
|
572
|
-
|
|
573
|
-
## Phase 3: Execute (default, runs automatically after enhance)
|
|
574
|
-
|
|
575
|
-
### 3.1 Assign Issue and Update Status
|
|
576
|
-
\`\`\`bash
|
|
577
|
-
gh issue edit <issue-number> --add-assignee @me
|
|
578
|
-
gh issue edit <issue-number> --add-label "in-progress"
|
|
579
|
-
\`\`\`
|
|
580
|
-
|
|
581
|
-
### 3.2 Create Branch
|
|
582
|
-
\`\`\`bash
|
|
583
|
-
git checkout main && git pull origin main
|
|
584
|
-
git checkout -b <type>/<issue-number>-<short-desc>
|
|
585
|
-
\`\`\`
|
|
586
|
-
Types: \`feature/\`, \`fix/\`, \`refactor/\`, \`docs/\`
|
|
587
|
-
|
|
588
|
-
### 3.3 Implement
|
|
589
|
-
Follow the implementation plan from the enhanced issue. No prompts - execute all steps.
|
|
590
|
-
|
|
591
|
-
## Phase 4: Testing (MANDATORY GATE)
|
|
592
|
-
|
|
593
|
-
This is NOT optional. ALL applicable test types must pass for the change type.
|
|
594
|
-
WORKFLOW STOPS HERE until tests pass. No shortcuts. No exceptions.
|
|
595
|
-
|
|
596
|
-
### 4.1 Write and Run Tests
|
|
597
|
-
Write unit, integration, and E2E tests as appropriate for the change type.
|
|
598
|
-
Use the project's existing test runner and patterns.
|
|
599
|
-
|
|
600
|
-
### 4.2 Test Auto-Fix Loop
|
|
601
|
-
If any tests fail, enter the auto-fix loop (max 3 retries OR 10 minutes):
|
|
602
|
-
1. Run all tests
|
|
603
|
-
2. If ALL pass -> proceed to simplification
|
|
604
|
-
3. If ANY fail: analyze failure, fix test or implementation code, retry
|
|
605
|
-
4. If retries exhausted -> STOP and report to user
|
|
606
|
-
|
|
607
|
-
## Phase 4.5: Code Simplification (MANDATORY)
|
|
608
|
-
|
|
609
|
-
The built-in /simplify command reviews ALL changed code for:
|
|
610
|
-
- Reuse opportunities and code quality
|
|
611
|
-
- Efficiency improvements
|
|
612
|
-
- Consistency with existing codebase patterns
|
|
613
|
-
- Preserves ALL functionality - no behavior changes
|
|
614
|
-
|
|
615
|
-
If /simplify makes changes -> re-run tests to confirm nothing broke.
|
|
616
|
-
If re-tests fail -> revert changes, proceed with original code.
|
|
617
|
-
|
|
618
|
-
## Phase 5: Commit and PR (only after tests pass)
|
|
619
|
-
|
|
620
|
-
### 5.1 Commit
|
|
621
|
-
\`\`\`bash
|
|
622
|
-
git add <specific files>
|
|
623
|
-
git commit -m "type(scope): description
|
|
624
|
-
|
|
625
|
-
Closes #<issue-number>
|
|
626
|
-
|
|
627
|
-
Co-Authored-By: Claude <noreply@anthropic.com>"
|
|
628
|
-
\`\`\`
|
|
629
|
-
|
|
630
|
-
### 5.2 Create PR
|
|
631
|
-
\`\`\`bash
|
|
632
|
-
git push -u origin <branch-name>
|
|
633
|
-
gh pr create --title "type(scope): description" --body "## Summary
|
|
634
|
-
<brief description>
|
|
635
|
-
|
|
636
|
-
## Changes
|
|
637
|
-
<bullet list>
|
|
638
|
-
|
|
639
|
-
## Testing
|
|
640
|
-
- [x] Unit tests pass
|
|
641
|
-
- [x] Integration tests pass
|
|
642
|
-
- [x] E2E tests pass
|
|
643
|
-
- [ ] Manual testing done
|
|
644
|
-
|
|
645
|
-
Closes #<issue-number>"
|
|
646
|
-
\`\`\`
|
|
647
|
-
|
|
648
|
-
### 5.3 Update Issue Status
|
|
649
|
-
\`\`\`bash
|
|
650
|
-
gh issue edit <issue-number> --remove-label "in-progress" --add-label "ready-for-review"
|
|
651
|
-
gh issue comment <issue-number> --body "PR created: <pr-url>"
|
|
652
|
-
\`\`\`
|
|
653
|
-
|
|
654
|
-
## Epic Handling
|
|
655
|
-
|
|
656
|
-
### Detecting Epics
|
|
657
|
-
|
|
658
|
-
An issue is an **epic** if:
|
|
659
|
-
1. It has the \`epic\` label, OR
|
|
660
|
-
2. Its body contains \`## Stories\` or \`## Tasks\` sections, OR
|
|
661
|
-
3. It has linked child issues (via \`- [ ] #123\` checklist format)
|
|
662
|
-
|
|
663
|
-
### Epic Processing Flow
|
|
664
|
-
|
|
665
|
-
1. DETECT EPIC - Check labels, parse body for ## Stories / ## Tasks, extract issue references
|
|
666
|
-
2. LIST ALL STORIES - Extract from checklist, order top-to-bottom as listed
|
|
667
|
-
3. SEQUENTIAL PROCESSING - For each story: run full /flo workflow, wait for PR, update checklist
|
|
668
|
-
4. COMPLETION - All stories have PRs, epic marked as ready-for-review
|
|
669
|
-
|
|
670
|
-
ONE STORY AT A TIME - NO PARALLEL STORY EXECUTION.
|
|
671
|
-
Each story must complete (PR created) before starting next.
|
|
672
|
-
|
|
673
|
-
### Epic Detection Code
|
|
674
|
-
|
|
675
|
-
\`\`\`javascript
|
|
676
|
-
function isEpic(issue) {
|
|
677
|
-
if (issue.labels?.some(l => l.name === 'epic')) return true;
|
|
678
|
-
if (issue.body?.includes('## Stories') || issue.body?.includes('## Tasks')) return true;
|
|
679
|
-
const linkedIssuePattern = /- \\[[ x]\\] #\\d+/;
|
|
680
|
-
if (linkedIssuePattern.test(issue.body)) return true;
|
|
681
|
-
return false;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
function extractStories(epicBody) {
|
|
685
|
-
const stories = [];
|
|
686
|
-
const pattern = /- \\[[ ]\\] #(\\d+)/g;
|
|
687
|
-
let match;
|
|
688
|
-
while ((match = pattern.exec(epicBody)) !== null) {
|
|
689
|
-
stories.push(parseInt(match[1]));
|
|
690
|
-
}
|
|
691
|
-
return stories;
|
|
692
|
-
}
|
|
693
|
-
\`\`\`
|
|
694
|
-
|
|
695
|
-
## Parse Arguments
|
|
696
|
-
|
|
697
|
-
\`\`\`javascript
|
|
698
|
-
const args = "$ARGUMENTS".trim().split(/\\s+/);
|
|
699
|
-
let workflowMode = "full"; // full, enhance, research
|
|
700
|
-
let execMode = "swarm"; // swarm (default), hive, naked
|
|
701
|
-
let issueNumber = null;
|
|
702
|
-
|
|
703
|
-
for (let i = 0; i < args.length; i++) {
|
|
704
|
-
const arg = args[i];
|
|
705
|
-
|
|
706
|
-
// Workflow mode (what to do)
|
|
707
|
-
if (arg === "-e" || arg === "--enhance") {
|
|
708
|
-
workflowMode = "enhance";
|
|
709
|
-
} else if (arg === "-r" || arg === "--research") {
|
|
710
|
-
workflowMode = "research";
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// Execution mode (how to do it)
|
|
714
|
-
else if (arg === "-sw" || arg === "--swarm") {
|
|
715
|
-
execMode = "swarm";
|
|
716
|
-
} else if (arg === "-hv" || arg === "--hive") {
|
|
717
|
-
execMode = "hive";
|
|
718
|
-
} else if (arg === "-n" || arg === "--naked") {
|
|
719
|
-
execMode = "naked";
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
// Issue number
|
|
723
|
-
else if (/^\\d+$/.test(arg)) {
|
|
724
|
-
issueNumber = arg;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
if (!issueNumber) {
|
|
729
|
-
throw new Error("Issue number required. Usage: /flo <issue-number>");
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
// Log execution mode to prevent silent skipping
|
|
733
|
-
console.log("Execution mode: " + execMode.toUpperCase());
|
|
734
|
-
if (execMode === "swarm") {
|
|
735
|
-
console.log("SWARM MODE: Will spawn agents via Task tool. Do NOT skip this.");
|
|
736
|
-
}
|
|
737
|
-
console.log("TESTING: Unit + Integration + E2E tests REQUIRED before PR.");
|
|
738
|
-
console.log("SIMPLIFY: /simplify command runs on changed code before PR.");
|
|
739
|
-
\`\`\`
|
|
740
|
-
|
|
741
|
-
## Execution Flow
|
|
742
|
-
|
|
743
|
-
### Workflow Modes (what to do)
|
|
744
|
-
|
|
745
|
-
| Mode | Command | Steps | Stops After |
|
|
746
|
-
|------|---------|-------|-------------|
|
|
747
|
-
| **Full** (default) | \`/flo 123\` | Research -> Enhance -> Implement -> Test -> Simplify -> PR | PR created |
|
|
748
|
-
| **Epic** | \`/flo 42\` (epic) | For each story: Full workflow sequentially | All story PRs created |
|
|
749
|
-
| **Enhance** | \`/flo -e 123\` | Research -> Enhance | Issue updated |
|
|
750
|
-
| **Research** | \`/flo -r 123\` | Research | Findings output |
|
|
751
|
-
|
|
752
|
-
### Execution Modes (how to do it)
|
|
753
|
-
|
|
754
|
-
| Mode | Flag | Description | When to Use |
|
|
755
|
-
|------|------|-------------|-------------|
|
|
756
|
-
| **Swarm** (DEFAULT) | \`-sw\`, \`--swarm\` | Multi-agent via Task tool | Always, unless explicitly overridden |
|
|
757
|
-
| **Hive-Mind** | \`-hv\`, \`--hive\` | Consensus-based coordination | Architecture decisions, tradeoffs |
|
|
758
|
-
| **Naked** | \`-n\`, \`--naked\` | Single Claude, no agents | User explicitly wants simple mode |
|
|
759
|
-
|
|
760
|
-
## Execution Mode Details
|
|
761
|
-
|
|
762
|
-
### SWARM Mode (Default) - ALWAYS USE UNLESS TOLD OTHERWISE
|
|
763
|
-
|
|
764
|
-
You MUST use the Task tool to spawn agents. No exceptions.
|
|
765
|
-
|
|
766
|
-
**Swarm spawns these agents via Task tool:**
|
|
767
|
-
- \`researcher\` - Analyzes issue, searches memory, finds patterns
|
|
768
|
-
- \`coder\` - Implements changes following plan
|
|
769
|
-
- \`tester\` - Writes and runs tests
|
|
770
|
-
- \`/simplify\` - Built-in command that reviews changed code before PR
|
|
771
|
-
- \`reviewer\` - Reviews code before PR
|
|
772
|
-
|
|
773
|
-
**Swarm execution pattern:**
|
|
774
|
-
\`\`\`javascript
|
|
775
|
-
// 1. Create task list FIRST
|
|
776
|
-
TaskCreate({ subject: "Research issue #123", ... })
|
|
777
|
-
TaskCreate({ subject: "Implement changes", ... })
|
|
778
|
-
TaskCreate({ subject: "Test implementation", ... })
|
|
779
|
-
TaskCreate({ subject: "Run /simplify on changed files", ... })
|
|
780
|
-
TaskCreate({ subject: "Review and PR", ... })
|
|
781
|
-
|
|
782
|
-
// 2. Init swarm
|
|
783
|
-
Bash("npx flo swarm init --topology hierarchical --max-agents 8 --strategy specialized")
|
|
784
|
-
|
|
785
|
-
// 3. Spawn agents with Task tool (run_in_background: true)
|
|
786
|
-
Task({ prompt: "...", subagent_type: "researcher", run_in_background: true })
|
|
787
|
-
Task({ prompt: "...", subagent_type: "coder", run_in_background: true })
|
|
788
|
-
|
|
789
|
-
// 4. Wait for results, synthesize, continue
|
|
790
|
-
\`\`\`
|
|
791
|
-
|
|
792
|
-
### HIVE-MIND Mode (-hv, --hive)
|
|
793
|
-
|
|
794
|
-
Use for consensus-based decisions:
|
|
795
|
-
- Architecture choices
|
|
796
|
-
- Approach tradeoffs
|
|
797
|
-
- Design decisions with multiple valid options
|
|
798
|
-
|
|
799
|
-
### NAKED Mode (-n, --naked)
|
|
800
|
-
|
|
801
|
-
**Only when user explicitly requests.** Single Claude execution without agents.
|
|
802
|
-
- Still uses Task tool for tracking
|
|
803
|
-
- Still creates tasks for visibility
|
|
804
|
-
- Just doesn't spawn multiple agents
|
|
805
|
-
|
|
806
|
-
---
|
|
807
|
-
|
|
808
|
-
**Full mode executes without prompts.** It will:
|
|
809
|
-
1. Research the issue and codebase
|
|
810
|
-
2. Enhance the GitHub issue with implementation plan
|
|
811
|
-
3. Assign issue to self, add "in-progress" label
|
|
812
|
-
4. Create branch, implement, test
|
|
813
|
-
5. Run /simplify on changed code, re-test if changes made
|
|
814
|
-
6. Commit, create PR, update issue status
|
|
815
|
-
7. Store learnings
|
|
816
|
-
`;
|
|
430
|
+
// Copy static SKILL.md from moflo package instead of generating it
|
|
431
|
+
let skillContent = '';
|
|
432
|
+
const staticSkillCandidates = [
|
|
433
|
+
// Installed via npm
|
|
434
|
+
path.join(root, 'node_modules', 'moflo', '.claude', 'skills', 'flo', 'SKILL.md'),
|
|
435
|
+
// Running from moflo repo itself
|
|
436
|
+
path.join(path.dirname(path.dirname(path.dirname(path.dirname(path.dirname(__dirname))))), '.claude', 'skills', 'flo', 'SKILL.md'),
|
|
437
|
+
];
|
|
438
|
+
for (const candidate of staticSkillCandidates) {
|
|
439
|
+
if (fs.existsSync(candidate)) {
|
|
440
|
+
skillContent = fs.readFileSync(candidate, 'utf-8');
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (!skillContent) {
|
|
445
|
+
return { name: '.claude/skills/flo/', status: 'error', detail: 'Could not find SKILL.md in moflo package' };
|
|
446
|
+
}
|
|
817
447
|
fs.writeFileSync(skillFile, skillContent, 'utf-8');
|
|
818
448
|
// Create /fl alias (same content)
|
|
819
449
|
if (!fs.existsSync(aliasDir)) {
|
|
@@ -861,10 +491,11 @@ This project uses [MoFlo](https://github.com/eric-cielo/moflo) for AI-assisted d
|
|
|
861
491
|
Your first tool call for every new user prompt MUST be a memory search. Do this BEFORE Glob, Grep, Read, or any file exploration.
|
|
862
492
|
|
|
863
493
|
\`\`\`
|
|
864
|
-
mcp__claude-flow__memory_search — query: "<task description>", namespace: "guidance" or "patterns" or "code-map"
|
|
494
|
+
mcp__claude-flow__memory_search — query: "<task description>", namespace: "guidance" or "patterns" or "knowledge" or "code-map"
|
|
865
495
|
\`\`\`
|
|
866
496
|
|
|
867
|
-
For codebase navigation, search the \`code-map\` namespace first. For patterns and domain knowledge, search \`patterns\` and \`guidance\`.
|
|
497
|
+
For codebase navigation, search the \`code-map\` namespace first. For patterns and domain knowledge, search \`patterns\`, \`knowledge\`, and \`guidance\`.
|
|
498
|
+
When the user asks you to remember something, store it: \`memory store --namespace knowledge --key "[topic]" --value "[what to remember]"\`
|
|
868
499
|
|
|
869
500
|
### Workflow Gates (enforced automatically)
|
|
870
501
|
|
|
@@ -918,7 +549,60 @@ ${MOFLO_MARKER_END}
|
|
|
918
549
|
};
|
|
919
550
|
}
|
|
920
551
|
// ============================================================================
|
|
921
|
-
// Step 5: .
|
|
552
|
+
// Step 5: .claude/scripts/ — sync from moflo bin/
|
|
553
|
+
// These scripts are used by session-start hooks for indexing, code map, etc.
|
|
554
|
+
// Always overwrite to keep them in sync with the installed moflo version.
|
|
555
|
+
// ============================================================================
|
|
556
|
+
const SCRIPT_MAP = {
|
|
557
|
+
'hooks.mjs': 'hooks.mjs',
|
|
558
|
+
'session-start-launcher.mjs': 'session-start-launcher.mjs',
|
|
559
|
+
'index-guidance.mjs': 'index-guidance.mjs',
|
|
560
|
+
'build-embeddings.mjs': 'build-embeddings.mjs',
|
|
561
|
+
'generate-code-map.mjs': 'generate-code-map.mjs',
|
|
562
|
+
'semantic-search.mjs': 'semantic-search.mjs',
|
|
563
|
+
};
|
|
564
|
+
function syncScripts(root, force) {
|
|
565
|
+
const scriptsDir = path.join(root, '.claude', 'scripts');
|
|
566
|
+
if (!fs.existsSync(scriptsDir)) {
|
|
567
|
+
fs.mkdirSync(scriptsDir, { recursive: true });
|
|
568
|
+
}
|
|
569
|
+
// Find moflo bin/ directory
|
|
570
|
+
const candidates = [
|
|
571
|
+
path.join(root, 'node_modules', 'moflo', 'bin'),
|
|
572
|
+
// When running from moflo repo itself
|
|
573
|
+
path.join(path.dirname(path.dirname(path.dirname(path.dirname(path.dirname(__dirname))))), 'bin'),
|
|
574
|
+
];
|
|
575
|
+
const binDir = candidates.find(d => fs.existsSync(d));
|
|
576
|
+
if (!binDir) {
|
|
577
|
+
return { name: '.claude/scripts/', status: 'skipped', detail: 'moflo bin/ not found' };
|
|
578
|
+
}
|
|
579
|
+
let copied = 0;
|
|
580
|
+
for (const [dest, src] of Object.entries(SCRIPT_MAP)) {
|
|
581
|
+
const srcPath = path.join(binDir, src);
|
|
582
|
+
const destPath = path.join(scriptsDir, dest);
|
|
583
|
+
if (!fs.existsSync(srcPath))
|
|
584
|
+
continue;
|
|
585
|
+
// Always overwrite scripts to keep in sync (they're derived, not user-edited)
|
|
586
|
+
if (!fs.existsSync(destPath) || force || isStale(srcPath, destPath)) {
|
|
587
|
+
fs.copyFileSync(srcPath, destPath);
|
|
588
|
+
copied++;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
if (copied === 0) {
|
|
592
|
+
return { name: '.claude/scripts/', status: 'skipped', detail: 'Scripts already up to date' };
|
|
593
|
+
}
|
|
594
|
+
return { name: '.claude/scripts/', status: 'updated', detail: `${copied} scripts synced from moflo` };
|
|
595
|
+
}
|
|
596
|
+
function isStale(srcPath, destPath) {
|
|
597
|
+
try {
|
|
598
|
+
return fs.statSync(srcPath).mtimeMs > fs.statSync(destPath).mtimeMs;
|
|
599
|
+
}
|
|
600
|
+
catch {
|
|
601
|
+
return true;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
// ============================================================================
|
|
605
|
+
// Step 6: .gitignore
|
|
922
606
|
// ============================================================================
|
|
923
607
|
function updateGitignore(root) {
|
|
924
608
|
const gitignorePath = path.join(root, '.gitignore');
|