moflo 4.9.11 → 4.9.13
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/commands/simplify.md +78 -30
- package/.claude/skills/eldar/SKILL.md +305 -0
- package/.claude/skills/simplify/SKILL.md +90 -21
- package/README.md +25 -0
- package/bin/hooks.mjs +2 -2
- package/bin/index-guidance.mjs +14 -24
- package/bin/index-patterns.mjs +13 -10
- package/bin/session-start-launcher.mjs +205 -11
- package/dist/src/cli/commands/doctor-checks-deep.js +76 -0
- package/dist/src/cli/commands/doctor.js +53 -1
- package/dist/src/cli/config/moflo-config.js +14 -3
- package/dist/src/cli/init/moflo-init.js +20 -266
- package/dist/src/cli/init/moflo-yaml-template.js +370 -0
- package/dist/src/cli/mcp-tools/hooks-tools.js +3 -1
- package/dist/src/cli/movector/model-router.js +66 -20
- package/dist/src/cli/services/hook-block-hash.js +341 -0
- package/dist/src/cli/services/index.js +2 -0
- package/dist/src/cli/version.js +1 -1
- package/package.json +2 -2
|
@@ -59,11 +59,11 @@ const DEFAULT_CONFIG = {
|
|
|
59
59
|
models: {
|
|
60
60
|
default: 'opus',
|
|
61
61
|
research: 'sonnet',
|
|
62
|
-
review: '
|
|
62
|
+
review: 'sonnet',
|
|
63
63
|
test: 'sonnet',
|
|
64
64
|
},
|
|
65
65
|
model_routing: {
|
|
66
|
-
enabled:
|
|
66
|
+
enabled: true,
|
|
67
67
|
confidence_threshold: 0.85,
|
|
68
68
|
cost_optimization: true,
|
|
69
69
|
circuit_breaker: true,
|
|
@@ -82,6 +82,7 @@ const DEFAULT_CONFIG = {
|
|
|
82
82
|
enabled: true,
|
|
83
83
|
scripts: true,
|
|
84
84
|
helpers: true,
|
|
85
|
+
hook_block_drift: 'warn',
|
|
85
86
|
},
|
|
86
87
|
sandbox: {
|
|
87
88
|
enabled: false,
|
|
@@ -205,6 +206,12 @@ function mergeConfig(raw, root) {
|
|
|
205
206
|
enabled: raw.auto_update?.enabled ?? raw.autoUpdate?.enabled ?? DEFAULT_CONFIG.auto_update.enabled,
|
|
206
207
|
scripts: raw.auto_update?.scripts ?? raw.autoUpdate?.scripts ?? DEFAULT_CONFIG.auto_update.scripts,
|
|
207
208
|
helpers: raw.auto_update?.helpers ?? raw.autoUpdate?.helpers ?? DEFAULT_CONFIG.auto_update.helpers,
|
|
209
|
+
hook_block_drift: (() => {
|
|
210
|
+
const v = raw.auto_update?.hook_block_drift ?? raw.autoUpdate?.hookBlockDrift;
|
|
211
|
+
return v === 'regenerate' || v === 'off' || v === 'warn'
|
|
212
|
+
? v
|
|
213
|
+
: DEFAULT_CONFIG.auto_update.hook_block_drift;
|
|
214
|
+
})(),
|
|
208
215
|
},
|
|
209
216
|
sandbox: {
|
|
210
217
|
enabled: raw.sandbox?.enabled ?? DEFAULT_CONFIG.sandbox.enabled,
|
|
@@ -385,7 +392,7 @@ models:
|
|
|
385
392
|
# When enabled, overrides the static model preferences above
|
|
386
393
|
# by analyzing task complexity and routing to the cheapest capable model.
|
|
387
394
|
model_routing:
|
|
388
|
-
enabled:
|
|
395
|
+
enabled: true # Set to false to pin to the static models above
|
|
389
396
|
confidence_threshold: 0.85 # Min confidence before escalating to a more capable model
|
|
390
397
|
cost_optimization: true # Prefer cheaper models when confidence is high
|
|
391
398
|
circuit_breaker: true # Penalize models that fail repeatedly
|
|
@@ -398,6 +405,10 @@ auto_update:
|
|
|
398
405
|
enabled: true # Master toggle for version-change auto-sync
|
|
399
406
|
scripts: true # Sync .claude/scripts/ from moflo bin/
|
|
400
407
|
helpers: true # Sync .claude/helpers/ from moflo source
|
|
408
|
+
hook_block_drift: warn # warn | regenerate | off
|
|
409
|
+
# warn = print drift summary on session start (default)
|
|
410
|
+
# regenerate = auto-add missing hooks (only when no customisations)
|
|
411
|
+
# off = skip detection entirely
|
|
401
412
|
|
|
402
413
|
# OS-level sandbox for spell bash steps
|
|
403
414
|
# Denylist always runs regardless of this setting
|
|
@@ -14,14 +14,8 @@ import * as path from 'path';
|
|
|
14
14
|
import { execSync } from 'child_process';
|
|
15
15
|
import { locateMofloRootPath } from '../services/moflo-require.js';
|
|
16
16
|
import { errorDetail } from '../shared/utils/error-detail.js';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// tooling trees would only produce noise. Hoisted from three identical inline
|
|
20
|
-
// copies in this file's discover* helpers.
|
|
21
|
-
const WALK_SKIP_DIRS = new Set([
|
|
22
|
-
'node_modules', '.git', 'dist', 'build', 'coverage', '.next', '.reports',
|
|
23
|
-
'.swarm', '.moflo', 'packages',
|
|
24
|
-
]);
|
|
17
|
+
import { discoverGuidanceDirs, discoverSrcDirs, discoverTestDirs, detectExtensions, renderMofloYaml, } from './moflo-yaml-template.js';
|
|
18
|
+
export { discoverTestDirs };
|
|
25
19
|
// ============================================================================
|
|
26
20
|
// Init
|
|
27
21
|
// ============================================================================
|
|
@@ -39,122 +33,6 @@ function mofloRootJoin(...segments) {
|
|
|
39
33
|
const hit = locateMofloRootPath(segments.join('/'));
|
|
40
34
|
return hit ? [hit] : [];
|
|
41
35
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Discover guidance directories by checking top-level candidates AND walking
|
|
44
|
-
* the project tree for subproject .claude/guidance dirs (monorepo support).
|
|
45
|
-
*/
|
|
46
|
-
function discoverGuidanceDirs(root) {
|
|
47
|
-
const TOP_LEVEL = ['.claude/guidance', 'docs/guides', 'docs', 'architecture', 'adr', '.cursor/rules'];
|
|
48
|
-
const found = TOP_LEVEL.filter(d => fs.existsSync(path.join(root, d)));
|
|
49
|
-
// Walk up to 3 levels deep looking for .claude/guidance in subprojects
|
|
50
|
-
function walk(dir, depth) {
|
|
51
|
-
if (depth > 3)
|
|
52
|
-
return;
|
|
53
|
-
try {
|
|
54
|
-
const entries = fs.readdirSync(path.join(root, dir), { withFileTypes: true });
|
|
55
|
-
for (const entry of entries) {
|
|
56
|
-
if (!entry.isDirectory() || WALK_SKIP_DIRS.has(entry.name))
|
|
57
|
-
continue;
|
|
58
|
-
const rel = dir ? `${dir}/${entry.name}` : entry.name;
|
|
59
|
-
const guidancePath = `${rel}/.claude/guidance`;
|
|
60
|
-
if (fs.existsSync(path.join(root, guidancePath))) {
|
|
61
|
-
// Verify it has .md files
|
|
62
|
-
try {
|
|
63
|
-
const files = fs.readdirSync(path.join(root, guidancePath));
|
|
64
|
-
if (files.some(f => f.endsWith('.md')))
|
|
65
|
-
found.push(guidancePath);
|
|
66
|
-
}
|
|
67
|
-
catch { /* skip unreadable */ }
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
walk(rel, depth + 1);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
catch { /* skip unreadable directories */ }
|
|
75
|
-
}
|
|
76
|
-
walk('', 0);
|
|
77
|
-
return found;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Discover test directories by checking common locations and walking for
|
|
81
|
-
* colocated __tests__ dirs. Returns relative paths.
|
|
82
|
-
*/
|
|
83
|
-
export function discoverTestDirs(root) {
|
|
84
|
-
const TOP_LEVEL = ['tests', 'test', '__tests__', 'spec', 'e2e'];
|
|
85
|
-
const found = TOP_LEVEL.filter(d => fs.existsSync(path.join(root, d)));
|
|
86
|
-
// Walk up to 3 levels deep looking for __tests__ dirs inside src
|
|
87
|
-
function walk(dir, depth) {
|
|
88
|
-
if (depth > 3)
|
|
89
|
-
return;
|
|
90
|
-
try {
|
|
91
|
-
const entries = fs.readdirSync(path.join(root, dir), { withFileTypes: true });
|
|
92
|
-
for (const entry of entries) {
|
|
93
|
-
if (!entry.isDirectory() || WALK_SKIP_DIRS.has(entry.name))
|
|
94
|
-
continue;
|
|
95
|
-
const rel = dir ? `${dir}/${entry.name}` : entry.name;
|
|
96
|
-
if (entry.name === '__tests__') {
|
|
97
|
-
found.push(rel);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
walk(rel, depth + 1);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
catch { /* skip unreadable directories */ }
|
|
105
|
-
}
|
|
106
|
-
walk('', 0);
|
|
107
|
-
return found;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Discover source directories by walking the project tree.
|
|
111
|
-
* Finds directories named 'src' (or top-level 'packages', 'lib', etc.)
|
|
112
|
-
* that contain .ts/.tsx/.js/.jsx files. Skips node_modules, dist, etc.
|
|
113
|
-
*/
|
|
114
|
-
function discoverSrcDirs(root) {
|
|
115
|
-
// Top-level candidates that are always source roots if they exist
|
|
116
|
-
const TOP_LEVEL = ['packages', 'lib', 'app', 'apps', 'services', 'server', 'client'];
|
|
117
|
-
const found = [];
|
|
118
|
-
// Add top-level candidates first
|
|
119
|
-
for (const d of TOP_LEVEL) {
|
|
120
|
-
if (fs.existsSync(path.join(root, d)))
|
|
121
|
-
found.push(d);
|
|
122
|
-
}
|
|
123
|
-
// Walk up to 3 levels deep looking for 'src' and 'migrations' directories
|
|
124
|
-
const SRC_NAMES = new Set(['src', 'migrations']);
|
|
125
|
-
function walk(dir, depth) {
|
|
126
|
-
if (depth > 3)
|
|
127
|
-
return;
|
|
128
|
-
try {
|
|
129
|
-
const entries = fs.readdirSync(path.join(root, dir), { withFileTypes: true });
|
|
130
|
-
for (const entry of entries) {
|
|
131
|
-
if (!entry.isDirectory() || WALK_SKIP_DIRS.has(entry.name))
|
|
132
|
-
continue;
|
|
133
|
-
const rel = dir ? `${dir}/${entry.name}` : entry.name;
|
|
134
|
-
if (SRC_NAMES.has(entry.name)) {
|
|
135
|
-
// Check it actually has source files
|
|
136
|
-
try {
|
|
137
|
-
const files = fs.readdirSync(path.join(root, rel));
|
|
138
|
-
const hasSource = files.some(f => /\.(ts|tsx|js|jsx)$/.test(f));
|
|
139
|
-
if (hasSource)
|
|
140
|
-
found.push(rel);
|
|
141
|
-
}
|
|
142
|
-
catch { /* skip unreadable */ }
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
walk(rel, depth + 1);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
catch { /* skip unreadable directories */ }
|
|
150
|
-
}
|
|
151
|
-
walk('', 0);
|
|
152
|
-
// Deduplicate: if 'packages' is found, don't also include 'packages/foo/src'
|
|
153
|
-
// since the code-map walker handles subdirs
|
|
154
|
-
return found.filter(d => {
|
|
155
|
-
return !found.some(other => other !== d && d.startsWith(other + '/'));
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
36
|
/**
|
|
159
37
|
* Run interactive wizard to collect user preferences.
|
|
160
38
|
*/
|
|
@@ -276,149 +154,25 @@ function generateConfig(root, force, answers) {
|
|
|
276
154
|
if (fs.existsSync(configPath) && !force) {
|
|
277
155
|
return { name: 'moflo.yaml', status: 'skipped', detail: 'Already exists (use --force to overwrite)' };
|
|
278
156
|
}
|
|
279
|
-
const projectName = path.basename(root);
|
|
280
|
-
const guidanceDirs = answers?.guidanceDirs ?? ['.claude/guidance'];
|
|
281
157
|
const srcDirs = answers?.srcDirs ?? ['src'];
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
# Docs: https://github.com/eric-cielo/moflo
|
|
301
|
-
|
|
302
|
-
project:
|
|
303
|
-
name: "${projectName}"
|
|
304
|
-
|
|
305
|
-
# Guidance/knowledge docs to index for semantic search
|
|
306
|
-
guidance:
|
|
307
|
-
directories:
|
|
308
|
-
${guidanceDirs.map(d => ` - ${d}`).join('\n')}
|
|
309
|
-
namespace: guidance
|
|
310
|
-
|
|
311
|
-
# Source directories for code navigation map
|
|
312
|
-
code_map:
|
|
313
|
-
directories:
|
|
314
|
-
${srcDirs.map(d => ` - ${d}`).join('\n')}
|
|
315
|
-
extensions: [${detectedExts.map(e => `"${e}"`).join(', ')}]
|
|
316
|
-
exclude: [node_modules, dist, .next, coverage, build, __pycache__, target, .git]
|
|
317
|
-
namespace: code-map
|
|
318
|
-
|
|
319
|
-
# Test file discovery and indexing
|
|
320
|
-
tests:
|
|
321
|
-
directories:
|
|
322
|
-
${testDirs.map(d => ` - ${d}`).join('\n')}
|
|
323
|
-
patterns: ["*.test.*", "*.spec.*", "*.test-*"]
|
|
324
|
-
extensions: [".ts", ".tsx", ".js", ".jsx"]
|
|
325
|
-
exclude: [node_modules, coverage, dist]
|
|
326
|
-
namespace: tests
|
|
327
|
-
|
|
328
|
-
# Spell gates (enforced via Claude Code hooks)
|
|
329
|
-
gates:
|
|
330
|
-
memory_first: ${gatesEnabled}
|
|
331
|
-
task_create_first: ${gatesEnabled}
|
|
332
|
-
context_tracking: ${gatesEnabled}
|
|
333
|
-
|
|
334
|
-
# Auto-index on session start
|
|
335
|
-
auto_index:
|
|
336
|
-
guidance: ${answers?.guidance ?? true}
|
|
337
|
-
code_map: ${answers?.codeMap ?? true}
|
|
338
|
-
tests: ${answers?.tests ?? true}
|
|
339
|
-
|
|
340
|
-
# Memory backend
|
|
341
|
-
memory:
|
|
342
|
-
backend: sql.js
|
|
343
|
-
embedding_model: Xenova/all-MiniLM-L6-v2
|
|
344
|
-
namespace: default
|
|
345
|
-
|
|
346
|
-
# Hook toggles (all on by default — disable to slim down)
|
|
347
|
-
hooks:
|
|
348
|
-
pre_edit: true # Track file edits for learning
|
|
349
|
-
post_edit: true # Record edit outcomes, train neural patterns
|
|
350
|
-
pre_task: true # Get agent routing before task spawn
|
|
351
|
-
post_task: true # Record task results for learning
|
|
352
|
-
gate: ${gatesEnabled} # Spell gate enforcement (memory-first, task-create-first)
|
|
353
|
-
route: true # Intelligent task routing on each prompt
|
|
354
|
-
stop_hook: ${answers?.stopHook ?? true} # Session-end persistence and metric export
|
|
355
|
-
session_restore: true # Restore session state on start
|
|
356
|
-
notification: true # Hook into Claude Code notifications
|
|
357
|
-
|
|
358
|
-
# MCP server options
|
|
359
|
-
mcp:
|
|
360
|
-
tool_defer: deferred # Defer 150+ tool schemas; loaded on demand via ToolSearch
|
|
361
|
-
auto_start: false # Auto-start MCP server on session begin
|
|
362
|
-
|
|
363
|
-
# Spell step sandboxing (OS-level process isolation for bash steps)
|
|
364
|
-
# Platform support: macOS (sandbox-exec), Linux/WSL (bwrap). Windows has no OS sandbox.
|
|
365
|
-
# Tiers:
|
|
366
|
-
# auto — Use best available sandbox for this platform (recommended when enabled)
|
|
367
|
-
# denylist-only — Layer 1 only: block catastrophic commands, no OS isolation
|
|
368
|
-
# full — Require full OS isolation; throws if the sandbox tool is unavailable
|
|
369
|
-
sandbox:
|
|
370
|
-
enabled: false # Set to true to wrap bash steps in an OS sandbox
|
|
371
|
-
tier: auto # auto | denylist-only | full
|
|
372
|
-
|
|
373
|
-
# Status line display (shown at bottom of Claude Code)
|
|
374
|
-
# mode: "compact" (default), "single-line", or "dashboard" (full multi-line)
|
|
375
|
-
status_line:
|
|
376
|
-
enabled: true
|
|
377
|
-
mode: compact
|
|
378
|
-
branding: "MoFlo V4"
|
|
379
|
-
show_git: true
|
|
380
|
-
show_session: true
|
|
381
|
-
show_swarm: true
|
|
382
|
-
show_mcp: true
|
|
383
|
-
|
|
384
|
-
# Model preferences (haiku, sonnet, opus)
|
|
385
|
-
models:
|
|
386
|
-
default: opus # Model for general tasks
|
|
387
|
-
research: sonnet # Model for research/exploration agents
|
|
388
|
-
review: opus # Model for code review agents
|
|
389
|
-
test: sonnet # Model for test-writing agents
|
|
390
|
-
|
|
391
|
-
# Intelligent model routing (auto-selects haiku/sonnet/opus per task)
|
|
392
|
-
# When enabled, overrides the static model preferences above
|
|
393
|
-
# by analyzing task complexity and routing to the cheapest capable model.
|
|
394
|
-
model_routing:
|
|
395
|
-
enabled: false # Set to true to enable dynamic routing
|
|
396
|
-
confidence_threshold: 0.85 # Min confidence before escalating to a more capable model
|
|
397
|
-
cost_optimization: true # Prefer cheaper models when confidence is high
|
|
398
|
-
circuit_breaker: true # Penalize models that fail repeatedly
|
|
399
|
-
# Per-agent overrides (set to "inherit" to use routing, or a specific model to pin)
|
|
400
|
-
# agent_overrides:
|
|
401
|
-
# security-architect: opus # Always use opus for security
|
|
402
|
-
# researcher: sonnet # Pin research to sonnet
|
|
403
|
-
`;
|
|
404
|
-
fs.writeFileSync(configPath, yaml, 'utf-8');
|
|
405
|
-
return { name: 'moflo.yaml', status: 'created', detail: `Detected: ${srcDirs.join(', ')} | ${detectedExts.join(', ')}` };
|
|
406
|
-
}
|
|
407
|
-
function scanExtensions(dir, extensions, depth, maxDepth) {
|
|
408
|
-
if (depth > maxDepth)
|
|
409
|
-
return;
|
|
410
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
411
|
-
for (const entry of entries.slice(0, 100)) {
|
|
412
|
-
if (entry.isDirectory() && !['node_modules', '.git', 'dist', 'build'].includes(entry.name)) {
|
|
413
|
-
scanExtensions(path.join(dir, entry.name), extensions, depth + 1, maxDepth);
|
|
414
|
-
}
|
|
415
|
-
else if (entry.isFile()) {
|
|
416
|
-
const ext = path.extname(entry.name);
|
|
417
|
-
if (['.ts', '.tsx', '.js', '.jsx', '.py', '.go', '.rs', '.java', '.kt', '.swift', '.rb', '.cs'].includes(ext)) {
|
|
418
|
-
extensions.add(ext);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
158
|
+
const config = {
|
|
159
|
+
projectName: path.basename(root),
|
|
160
|
+
guidanceDirs: answers?.guidanceDirs ?? ['.claude/guidance'],
|
|
161
|
+
srcDirs,
|
|
162
|
+
testDirs: answers?.testDirs ?? ['tests'],
|
|
163
|
+
detectedExts: detectExtensions(root, srcDirs),
|
|
164
|
+
guidance: answers?.guidance ?? true,
|
|
165
|
+
codeMap: answers?.codeMap ?? true,
|
|
166
|
+
tests: answers?.tests ?? true,
|
|
167
|
+
gates: answers?.gates ?? true,
|
|
168
|
+
stopHook: answers?.stopHook ?? true,
|
|
169
|
+
};
|
|
170
|
+
fs.writeFileSync(configPath, renderMofloYaml(config), 'utf-8');
|
|
171
|
+
return {
|
|
172
|
+
name: 'moflo.yaml',
|
|
173
|
+
status: 'created',
|
|
174
|
+
detail: `Detected: ${config.srcDirs.join(', ')} | ${config.detectedExts.join(', ')}`,
|
|
175
|
+
};
|
|
422
176
|
}
|
|
423
177
|
// ============================================================================
|
|
424
178
|
// Step 2: .claude/settings.json hooks
|