moflo 4.8.48 → 4.8.50

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.
Files changed (66) hide show
  1. package/README.md +11 -0
  2. package/bin/gate.cjs +19 -4
  3. package/package.json +1 -2
  4. package/src/@claude-flow/cli/dist/src/init/executor.js +0 -4
  5. package/src/@claude-flow/cli/dist/src/version.js +1 -1
  6. package/src/@claude-flow/cli/package.json +106 -106
  7. package/.claude/agents/dual-mode/codex-coordinator.md +0 -224
  8. package/.claude/agents/dual-mode/codex-worker.md +0 -211
  9. package/.claude/agents/dual-mode/dual-orchestrator.md +0 -291
  10. package/.claude/agents/payments/agentic-payments.md +0 -126
  11. package/.claude/agents/sublinear/consensus-coordinator.md +0 -338
  12. package/.claude/agents/sublinear/matrix-optimizer.md +0 -185
  13. package/.claude/agents/sublinear/pagerank-analyzer.md +0 -299
  14. package/.claude/agents/sublinear/performance-optimizer.md +0 -368
  15. package/.claude/agents/sublinear/trading-predictor.md +0 -246
  16. package/.claude/agents/templates/automation-smart-agent.md +0 -205
  17. package/.claude/agents/templates/coordinator-swarm-init.md +0 -105
  18. package/.claude/agents/templates/github-pr-manager.md +0 -177
  19. package/.claude/agents/templates/implementer-sparc-coder.md +0 -259
  20. package/.claude/agents/templates/memory-coordinator.md +0 -187
  21. package/.claude/agents/templates/migration-plan.md +0 -746
  22. package/.claude/agents/templates/orchestrator-task.md +0 -139
  23. package/.claude/agents/templates/performance-analyzer.md +0 -199
  24. package/.claude/agents/templates/sparc-coordinator.md +0 -183
  25. package/.claude/commands/agents/README.md +0 -10
  26. package/.claude/commands/agents/agent-capabilities.md +0 -21
  27. package/.claude/commands/agents/agent-coordination.md +0 -28
  28. package/.claude/commands/agents/agent-spawning.md +0 -28
  29. package/.claude/commands/agents/agent-types.md +0 -26
  30. package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +0 -54
  31. package/.claude/commands/analysis/README.md +0 -9
  32. package/.claude/commands/analysis/bottleneck-detect.md +0 -162
  33. package/.claude/commands/analysis/performance-bottlenecks.md +0 -59
  34. package/.claude/commands/analysis/performance-report.md +0 -25
  35. package/.claude/commands/analysis/token-efficiency.md +0 -45
  36. package/.claude/commands/analysis/token-usage.md +0 -25
  37. package/.claude/commands/automation/README.md +0 -9
  38. package/.claude/commands/automation/auto-agent.md +0 -122
  39. package/.claude/commands/automation/self-healing.md +0 -106
  40. package/.claude/commands/automation/session-memory.md +0 -90
  41. package/.claude/commands/automation/smart-agents.md +0 -73
  42. package/.claude/commands/automation/smart-spawn.md +0 -25
  43. package/.claude/commands/automation/workflow-select.md +0 -25
  44. package/.claude/commands/monitoring/README.md +0 -9
  45. package/.claude/commands/monitoring/agent-metrics.md +0 -25
  46. package/.claude/commands/monitoring/agents.md +0 -44
  47. package/.claude/commands/monitoring/real-time-view.md +0 -25
  48. package/.claude/commands/monitoring/status.md +0 -46
  49. package/.claude/commands/monitoring/swarm-monitor.md +0 -25
  50. package/.claude/commands/optimization/README.md +0 -9
  51. package/.claude/commands/optimization/auto-topology.md +0 -62
  52. package/.claude/commands/optimization/cache-manage.md +0 -25
  53. package/.claude/commands/optimization/parallel-execute.md +0 -25
  54. package/.claude/commands/optimization/parallel-execution.md +0 -50
  55. package/.claude/commands/optimization/topology-optimize.md +0 -25
  56. package/.claude/scripts/build-embeddings.mjs +0 -549
  57. package/.claude/scripts/generate-code-map.mjs +0 -956
  58. package/.claude/scripts/hooks.mjs +0 -607
  59. package/.claude/scripts/index-all.mjs +0 -193
  60. package/.claude/scripts/index-guidance.mjs +0 -917
  61. package/.claude/scripts/index-tests.mjs +0 -729
  62. package/.claude/scripts/lib/moflo-resolve.mjs +0 -14
  63. package/.claude/scripts/lib/process-manager.mjs +0 -256
  64. package/.claude/scripts/lib/registry-cleanup.cjs +0 -41
  65. package/.claude/scripts/semantic-search.mjs +0 -473
  66. package/.claude/scripts/session-start-launcher.mjs +0 -272
@@ -1,272 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Fast session-start launcher — single hook that replaces all SessionStart entries.
4
- *
5
- * Spawns background tasks via spawn(detached + unref) and exits immediately.
6
- *
7
- * Invoked by: node .claude/scripts/session-start-launcher.mjs
8
- */
9
-
10
- import { spawn } from 'child_process';
11
- import { existsSync, readFileSync, writeFileSync, copyFileSync, unlinkSync, readdirSync, mkdirSync } from 'fs';
12
- import { resolve, dirname } from 'path';
13
- import { fileURLToPath } from 'url';
14
-
15
- const __dirname = dirname(fileURLToPath(import.meta.url));
16
-
17
- // Detect project root by walking up from cwd to find package.json.
18
- // IMPORTANT: Do NOT use resolve(__dirname, '..') or '../..' — this script lives
19
- // in bin/ during development but gets synced to .claude/scripts/ in consumer
20
- // projects, so __dirname-relative paths break. findProjectRoot() works everywhere.
21
- function findProjectRoot() {
22
- let dir = process.cwd();
23
- const root = resolve(dir, '/');
24
- while (dir !== root) {
25
- if (existsSync(resolve(dir, 'package.json'))) return dir;
26
- dir = dirname(dir);
27
- }
28
- return process.cwd();
29
- }
30
-
31
- const projectRoot = findProjectRoot();
32
-
33
- // ── 1. Helper: fire-and-forget a background process ─────────────────────────
34
- function fireAndForget(cmd, args, label) {
35
- try {
36
- const proc = spawn(cmd, args, {
37
- cwd: projectRoot,
38
- stdio: 'ignore', // Don't hold stdio pipes open
39
- detached: true, // New process group
40
- shell: false,
41
- windowsHide: true // No console popup on Windows
42
- });
43
- proc.unref(); // Let this process exit without waiting
44
- } catch {
45
- // If spawn fails (e.g. node not found), don't block startup
46
- }
47
- }
48
-
49
- // ── 2. Reset workflow state for new session ──────────────────────────────────
50
- const stateDir = resolve(projectRoot, '.claude');
51
- const stateFile = resolve(stateDir, 'workflow-state.json');
52
- try {
53
- if (!existsSync(stateDir)) mkdirSync(stateDir, { recursive: true });
54
- writeFileSync(stateFile, JSON.stringify({
55
- tasksCreated: false,
56
- taskCount: 0,
57
- memorySearched: false,
58
- sessionStart: new Date().toISOString()
59
- }, null, 2));
60
- } catch {
61
- // Non-fatal - workflow gate will use defaults
62
- }
63
-
64
- // ── 3. Auto-sync scripts and helpers on version change ───────────────────────
65
- // Controlled by `auto_update.enabled` in moflo.yaml (default: true).
66
- // When moflo is upgraded (npm install), scripts and helpers may be stale.
67
- // Detect version change and sync from source before running hooks.
68
- let autoUpdateConfig = { enabled: true, scripts: true, helpers: true };
69
- try {
70
- const mofloYaml = resolve(projectRoot, 'moflo.yaml');
71
- if (existsSync(mofloYaml)) {
72
- const yamlContent = readFileSync(mofloYaml, 'utf-8');
73
- // Simple YAML parsing for auto_update block (avoids js-yaml dependency)
74
- const enabledMatch = yamlContent.match(/auto_update:\s*\n\s+enabled:\s*(true|false)/);
75
- const scriptsMatch = yamlContent.match(/auto_update:\s*\n(?:\s+\w+:.*\n)*?\s+scripts:\s*(true|false)/);
76
- const helpersMatch = yamlContent.match(/auto_update:\s*\n(?:\s+\w+:.*\n)*?\s+helpers:\s*(true|false)/);
77
- if (enabledMatch) autoUpdateConfig.enabled = enabledMatch[1] === 'true';
78
- if (scriptsMatch) autoUpdateConfig.scripts = scriptsMatch[1] === 'true';
79
- if (helpersMatch) autoUpdateConfig.helpers = helpersMatch[1] === 'true';
80
- }
81
- } catch { /* non-fatal — use defaults (all true) */ }
82
-
83
- try {
84
- const mofloPkgPath = resolve(projectRoot, 'node_modules/moflo/package.json');
85
- const versionStampPath = resolve(projectRoot, '.claude-flow', 'moflo-version');
86
- if (autoUpdateConfig.enabled && existsSync(mofloPkgPath)) {
87
- const installedVersion = JSON.parse(readFileSync(mofloPkgPath, 'utf-8')).version;
88
- let cachedVersion = '';
89
- try { cachedVersion = readFileSync(versionStampPath, 'utf-8').trim(); } catch {}
90
-
91
- if (installedVersion !== cachedVersion) {
92
- const binDir = resolve(projectRoot, 'node_modules/moflo/bin');
93
- const manifestPath = resolve(projectRoot, '.claude-flow', 'installed-files.json');
94
-
95
- // ── Manifest-based auto-update ──────────────────────────────────────
96
- //
97
- // IMPORTANT: Every file moflo installs into the destination project
98
- // MUST be recorded in `currentManifest` via syncFile() or a manual
99
- // push. On upgrade, files in the OLD manifest but NOT in the new one
100
- // are deleted — this is how we clean up files from prior versions
101
- // without accidentally deleting user-created or runtime files.
102
- //
103
- // When adding/removing files from the sync lists below:
104
- // 1. Use syncFile() for copied files (it records automatically)
105
- // 2. Push to currentManifest manually for generated files
106
- // 3. That's it — cleanup is automatic on the next upgrade
107
- // ────────────────────────────────────────────────────────────────────
108
-
109
- // Load the previous manifest so we can diff after syncing
110
- let previousManifest = [];
111
- try { previousManifest = JSON.parse(readFileSync(manifestPath, 'utf-8')); } catch { /* ok */ }
112
-
113
- // Track every file we install this round
114
- const currentManifest = [];
115
-
116
- /** Copy src → dest if src exists, record in manifest. */
117
- function syncFile(src, dest, manifestKey) {
118
- if (existsSync(src)) {
119
- try { copyFileSync(src, dest); currentManifest.push(manifestKey); } catch { /* non-fatal */ }
120
- }
121
- }
122
-
123
- // Version changed — sync scripts from bin/
124
- if (autoUpdateConfig.scripts) {
125
- const scriptsDir = resolve(projectRoot, '.claude/scripts');
126
- const scriptFiles = [
127
- 'hooks.mjs', 'session-start-launcher.mjs', 'index-guidance.mjs',
128
- 'build-embeddings.mjs', 'generate-code-map.mjs', 'semantic-search.mjs',
129
- 'index-tests.mjs', 'index-all.mjs',
130
- ];
131
- for (const file of scriptFiles) {
132
- syncFile(resolve(binDir, file), resolve(scriptsDir, file), `.claude/scripts/${file}`);
133
- }
134
-
135
- // Sync lib/ subdirectory (process-manager.mjs, registry-cleanup.cjs, etc.)
136
- // hooks.mjs imports ./lib/process-manager.mjs — without this, session-start
137
- // silently fails and the daemon, indexer, and pretrain never run.
138
- const libSrcDir = resolve(binDir, 'lib');
139
- const libDestDir = resolve(scriptsDir, 'lib');
140
- if (existsSync(libSrcDir)) {
141
- if (!existsSync(libDestDir)) mkdirSync(libDestDir, { recursive: true });
142
- for (const file of readdirSync(libSrcDir)) {
143
- syncFile(resolve(libSrcDir, file), resolve(libDestDir, file), `.claude/scripts/lib/${file}`);
144
- }
145
- }
146
- }
147
-
148
- // Sync helpers from bin/ and source .claude/helpers/
149
- if (autoUpdateConfig.helpers) {
150
- const helpersDir = resolve(projectRoot, '.claude/helpers');
151
- if (!existsSync(helpersDir)) mkdirSync(helpersDir, { recursive: true });
152
-
153
- // Gate and hook helpers — shipped as static files in bin/
154
- const binHelperFiles = [
155
- 'gate.cjs', 'gate-hook.mjs', 'prompt-hook.mjs', 'hook-handler.cjs',
156
- ];
157
- for (const file of binHelperFiles) {
158
- syncFile(resolve(binDir, file), resolve(helpersDir, file), `.claude/helpers/${file}`);
159
- }
160
-
161
- // Other helpers from .claude/helpers/ and CLI .claude/helpers/
162
- const helperSources = [
163
- resolve(projectRoot, 'node_modules/moflo/.claude/helpers'),
164
- resolve(projectRoot, 'node_modules/moflo/src/@claude-flow/cli/.claude/helpers'),
165
- ];
166
- const sourceHelperFiles = [
167
- 'auto-memory-hook.mjs', 'statusline.cjs', 'intelligence.cjs', 'pre-commit', 'post-commit',
168
- ];
169
- for (const file of sourceHelperFiles) {
170
- const dest = resolve(helpersDir, file);
171
- for (const srcDir of helperSources) {
172
- const src = resolve(srcDir, file);
173
- if (existsSync(src)) {
174
- try { copyFileSync(src, dest); currentManifest.push(`.claude/helpers/${file}`); } catch { /* non-fatal */ }
175
- break; // first source wins
176
- }
177
- }
178
- }
179
- }
180
-
181
- // Sync all shipped guidance files from node_modules/moflo/.claude/guidance/shipped/
182
- const guidanceDir = resolve(projectRoot, '.claude/guidance');
183
- const shippedDir = resolve(projectRoot, 'node_modules/moflo/.claude/guidance/shipped');
184
- if (existsSync(shippedDir)) {
185
- try {
186
- if (!existsSync(guidanceDir)) mkdirSync(guidanceDir, { recursive: true });
187
- const shippedFiles = readdirSync(shippedDir).filter(f => f.endsWith('.md'));
188
- for (const file of shippedFiles) {
189
- const src = resolve(shippedDir, file);
190
- const dest = resolve(guidanceDir, file);
191
- const header = `<!-- AUTO-GENERATED by moflo session-start. Do not edit — changes will be overwritten. -->\n<!-- Source: node_modules/moflo/.claude/guidance/shipped/${file} -->\n\n`;
192
- const content = readFileSync(src, 'utf-8');
193
- writeFileSync(dest, header + content);
194
- currentManifest.push(`.claude/guidance/${file}`);
195
- }
196
- } catch { /* non-fatal */ }
197
- }
198
-
199
- // ── Clean up files we installed previously but no longer ship ──
200
- // Only remove files that are in the OLD manifest but NOT in the new one.
201
- // This ensures we never delete user-created or runtime-generated files.
202
- if (previousManifest.length > 0) {
203
- const currentSet = new Set(currentManifest);
204
- for (const rel of previousManifest) {
205
- if (!currentSet.has(rel)) {
206
- const abs = resolve(projectRoot, rel);
207
- try { if (existsSync(abs)) unlinkSync(abs); } catch { /* non-fatal */ }
208
- }
209
- }
210
- }
211
-
212
- // Write updated manifest + version stamp
213
- try {
214
- const cfDir = resolve(projectRoot, '.claude-flow');
215
- if (!existsSync(cfDir)) mkdirSync(cfDir, { recursive: true });
216
- writeFileSync(manifestPath, JSON.stringify(currentManifest, null, 2));
217
- writeFileSync(versionStampPath, installedVersion);
218
- } catch {}
219
- }
220
- }
221
- } catch {
222
- // Non-fatal — scripts will still work, just may be stale
223
- }
224
-
225
- // ── 3b. Ensure shipped guidance files exist (even without version change) ──
226
- // Subagents need these files on disk for direct reads without memory search.
227
- try {
228
- const guidanceDir = resolve(projectRoot, '.claude/guidance');
229
- const shippedDir = resolve(projectRoot, 'node_modules/moflo/.claude/guidance/shipped');
230
- if (existsSync(shippedDir)) {
231
- const shippedFiles = readdirSync(shippedDir).filter(f => f.endsWith('.md'));
232
- for (const file of shippedFiles) {
233
- const dest = resolve(guidanceDir, file);
234
- if (!existsSync(dest)) {
235
- if (!existsSync(guidanceDir)) mkdirSync(guidanceDir, { recursive: true });
236
- const header = `<!-- AUTO-GENERATED by moflo session-start. Do not edit — changes will be overwritten. -->\n<!-- Source: node_modules/moflo/.claude/guidance/shipped/${file} -->\n\n`;
237
- const content = readFileSync(resolve(shippedDir, file), 'utf-8');
238
- writeFileSync(dest, header + content);
239
- }
240
- }
241
- }
242
- } catch { /* non-fatal */ }
243
-
244
- // ── 3c. Clean up double-prefixed guidance files from pre-4.8.45 upgrade ─────
245
- // Before 4.8.45, session-start dynamically prepended "moflo-" to shipped filenames.
246
- // When upgrading to 4.8.45+ (where files already have the prefix), the old in-memory
247
- // code runs once and produces "moflo-moflo-*" duplicates. Remove them here.
248
- try {
249
- const guidanceDir = resolve(projectRoot, '.claude/guidance');
250
- if (existsSync(guidanceDir)) {
251
- for (const file of readdirSync(guidanceDir)) {
252
- if ((file.startsWith('moflo-moflo-') || file === 'moflo-moflo.md' || file === 'moflo.md') && file.endsWith('.md')) {
253
- try { unlinkSync(resolve(guidanceDir, file)); } catch { /* non-fatal */ }
254
- }
255
- }
256
- }
257
- } catch { /* non-fatal */ }
258
-
259
- // ── 4. Spawn background tasks ───────────────────────────────────────────────
260
- const localCli = resolve(projectRoot, 'node_modules/moflo/src/@claude-flow/cli/bin/cli.js');
261
- const hasLocalCli = existsSync(localCli);
262
-
263
- // hooks.mjs session-start (daemon, indexer, pretrain, HNSW, neural patterns)
264
- const hooksScript = resolve(projectRoot, '.claude/scripts/hooks.mjs');
265
- if (existsSync(hooksScript)) {
266
- fireAndForget('node', [hooksScript, 'session-start'], 'hooks session-start');
267
- }
268
-
269
- // Patches are now baked into moflo@4.0.0 source — no runtime patching needed.
270
-
271
- // ── 5. Done — exit immediately ──────────────────────────────────────────────
272
- process.exit(0);