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,14 +0,0 @@
1
- /**
2
- * Shared dependency resolver for moflo bin scripts.
3
- * Resolves packages from moflo's own node_modules (not the consuming project's).
4
- * On Windows, converts native paths to file:// URLs required by ESM import().
5
- */
6
-
7
- import { createRequire } from 'module';
8
- import { fileURLToPath, pathToFileURL } from 'url';
9
-
10
- const __require = createRequire(fileURLToPath(import.meta.url));
11
-
12
- export function mofloResolveURL(specifier) {
13
- return pathToFileURL(__require.resolve(specifier)).href;
14
- }
@@ -1,256 +0,0 @@
1
- /**
2
- * Shared background process manager for moflo.
3
- *
4
- * All background spawn paths (hooks.mjs, hook-handler.cjs, session-start-launcher.mjs)
5
- * delegate here so that PID tracking, dedup, and cleanup happen in one place.
6
- *
7
- * API:
8
- * spawn(cmd, args, label) — spawn with label-based dedup + PID tracking
9
- * killAll() — SIGTERM every tracked process, prune registry
10
- * getActive() — list currently alive tracked processes
11
- * prune() — remove dead entries from registry
12
- *
13
- * Registry: .claude-flow/background-pids.json
14
- * Lock: .claude-flow/spawn.lock (30 s TTL — prevents thundering-herd)
15
- */
16
-
17
- import { spawn } from 'child_process';
18
- import { existsSync, readFileSync, writeFileSync, renameSync, mkdirSync, unlinkSync, statSync, openSync, closeSync } from 'fs';
19
- import { resolve, dirname } from 'path';
20
- import { fileURLToPath } from 'url';
21
-
22
- const __filename = fileURLToPath(import.meta.url);
23
- const __dirname = dirname(__filename);
24
-
25
- const LOCK_TTL_MS = 30_000;
26
-
27
- /** Resolve the project root (two levels up from bin/lib/). */
28
- function defaultRoot() {
29
- return resolve(__dirname, '../..');
30
- }
31
-
32
- /** Ensure .claude-flow/ directory exists. */
33
- function ensureDir(dir) {
34
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
35
- }
36
-
37
- /** Check if a PID is alive (cross-platform). */
38
- function isAlive(pid) {
39
- try {
40
- process.kill(pid, 0);
41
- return true;
42
- } catch {
43
- return false;
44
- }
45
- }
46
-
47
- // ── Registry I/O ────────────────────────────────────────────────────────────
48
-
49
- function registryPath(root) {
50
- return resolve(root, '.claude-flow', 'background-pids.json');
51
- }
52
-
53
- function lockPath(root) {
54
- return resolve(root, '.claude-flow', 'spawn.lock');
55
- }
56
-
57
- function readRegistry(root) {
58
- const p = registryPath(root);
59
- if (!existsSync(p)) return [];
60
- try {
61
- const parsed = JSON.parse(readFileSync(p, 'utf-8'));
62
- return Array.isArray(parsed) ? parsed : [];
63
- } catch {
64
- return [];
65
- }
66
- }
67
-
68
- /** Atomic write: write to tmp file then rename to avoid torn reads. */
69
- function writeRegistry(root, entries) {
70
- const p = registryPath(root);
71
- const tmp = p + '.tmp.' + process.pid;
72
- ensureDir(dirname(p));
73
- writeFileSync(tmp, JSON.stringify(entries, null, 2));
74
- renameSync(tmp, p);
75
- }
76
-
77
- // ── Lock (30 s TTL) ────────────────────────────────────────────────────────
78
-
79
- function checkLock(root) {
80
- const lp = lockPath(root);
81
- if (!existsSync(lp)) return false;
82
- try {
83
- const age = Date.now() - statSync(lp).mtimeMs;
84
- return age < LOCK_TTL_MS;
85
- } catch {
86
- return false;
87
- }
88
- }
89
-
90
- /** Atomic lock acquisition using exclusive-create flag. */
91
- function writeLock(root) {
92
- const lp = lockPath(root);
93
- ensureDir(dirname(lp));
94
- try {
95
- writeFileSync(lp, String(Date.now()), { flag: 'wx' });
96
- } catch {
97
- // File already exists — overwrite if stale, otherwise skip
98
- try {
99
- const age = Date.now() - statSync(lp).mtimeMs;
100
- if (age >= LOCK_TTL_MS) {
101
- unlinkSync(lp);
102
- writeFileSync(lp, String(Date.now()), { flag: 'wx' });
103
- }
104
- } catch { /* lost race on stale cleanup — non-fatal */ }
105
- }
106
- }
107
-
108
- function clearLock(root) {
109
- const lp = lockPath(root);
110
- try {
111
- if (existsSync(lp)) unlinkSync(lp);
112
- } catch { /* non-fatal */ }
113
- }
114
-
115
- // ── Public API ──────────────────────────────────────────────────────────────
116
-
117
- /**
118
- * Create a ProcessManager bound to a project root.
119
- * @param {string} [root] — project root (defaults to two levels above bin/lib/)
120
- */
121
- export function createProcessManager(root) {
122
- const projectRoot = root || defaultRoot();
123
-
124
- return {
125
- /**
126
- * Spawn a background process with label-based dedup and PID tracking.
127
- *
128
- * If a process with the same `label` is already alive, the spawn is skipped.
129
- *
130
- * @param {string} cmd — executable (e.g. 'node')
131
- * @param {string[]} args — arguments
132
- * @param {string} label — unique label for dedup (e.g. 'index-guidance')
133
- * @returns {{ pid: number|null, skipped: boolean }}
134
- */
135
- spawn(cmd, args, label) {
136
- // Dedup: skip if same label is already alive
137
- const entries = readRegistry(projectRoot);
138
- const existing = entries.find(e => e.label === label);
139
- if (existing && isAlive(existing.pid)) {
140
- return { pid: existing.pid, skipped: true };
141
- }
142
-
143
- try {
144
- // Redirect background process output to log file instead of /dev/null
145
- // This ensures errors from background indexers/pretrain are captured
146
- let stdio = 'ignore';
147
- try {
148
- const swarmDir = resolve(projectRoot, '.swarm');
149
- ensureDir(swarmDir);
150
- const logPath = resolve(swarmDir, 'background.log');
151
- const fd = openSync(logPath, 'a');
152
- stdio = ['ignore', fd, fd];
153
- } catch {
154
- // Fall back to ignore if log file can't be opened
155
- }
156
-
157
- const proc = spawn(cmd, args, {
158
- cwd: projectRoot,
159
- stdio,
160
- detached: true,
161
- shell: false,
162
- windowsHide: true,
163
- });
164
-
165
- // Swallow async spawn errors (e.g. ENOENT for bad command)
166
- proc.on('error', () => {});
167
- proc.unref();
168
-
169
- if (proc.pid) {
170
- // Remove any stale entry with the same label, then append new
171
- const fresh = entries.filter(e => e.label !== label);
172
- fresh.push({
173
- pid: proc.pid,
174
- label,
175
- cmd: `${cmd} ${args.join(' ')}`.substring(0, 200),
176
- startedAt: new Date().toISOString(),
177
- });
178
- writeRegistry(projectRoot, fresh);
179
- }
180
-
181
- return { pid: proc.pid || null, skipped: false };
182
- } catch {
183
- return { pid: null, skipped: false };
184
- }
185
- },
186
-
187
- /**
188
- * Kill all tracked background processes.
189
- * @returns {{ killed: number, total: number }}
190
- */
191
- killAll() {
192
- const entries = readRegistry(projectRoot);
193
- let killed = 0;
194
-
195
- for (const entry of entries) {
196
- if (!isAlive(entry.pid)) continue;
197
- try {
198
- process.kill(entry.pid, 'SIGTERM');
199
- killed++;
200
- } catch { /* already gone */ }
201
- }
202
-
203
- // Clear registry and lock
204
- writeRegistry(projectRoot, []);
205
- clearLock(projectRoot);
206
-
207
- return { killed, total: entries.length };
208
- },
209
-
210
- /**
211
- * Return list of currently alive tracked processes.
212
- * @returns {Array<{ pid: number, label: string, cmd: string, startedAt: string }>}
213
- */
214
- getActive() {
215
- const entries = readRegistry(projectRoot);
216
- return entries.filter(e => isAlive(e.pid));
217
- },
218
-
219
- /**
220
- * Remove dead entries from the registry.
221
- * @returns {{ pruned: number, remaining: number }}
222
- */
223
- prune() {
224
- const entries = readRegistry(projectRoot);
225
- const alive = entries.filter(e => isAlive(e.pid));
226
- writeRegistry(projectRoot, alive);
227
- return { pruned: entries.length - alive.length, remaining: alive.length };
228
- },
229
-
230
- /**
231
- * Check if the spawn lock is held (another session-restore spawned recently).
232
- */
233
- isLocked() {
234
- return checkLock(projectRoot);
235
- },
236
-
237
- /**
238
- * Acquire the spawn lock (30 s TTL).
239
- */
240
- acquireLock() {
241
- writeLock(projectRoot);
242
- },
243
-
244
- /**
245
- * Release the spawn lock.
246
- */
247
- releaseLock() {
248
- clearLock(projectRoot);
249
- },
250
-
251
- /** Expose the project root for callers that need it. */
252
- get root() {
253
- return projectRoot;
254
- },
255
- };
256
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * Synchronous cleanup of the ProcessManager background-pids registry.
3
- *
4
- * Safe to call from CJS hooks that run under process.exit() — no async,
5
- * no ESM imports, pure fs + process.kill.
6
- *
7
- * Used by: .claude/helpers/hook-handler.cjs, bin/hook-handler.cjs (session-end)
8
- */
9
- 'use strict';
10
-
11
- var fs = require('fs');
12
- var path = require('path');
13
-
14
- /**
15
- * Kill all tracked background processes and clear the registry.
16
- * @param {string} projectDir - absolute path to the project root
17
- * @returns {number} count of processes killed
18
- */
19
- function killTrackedSync(projectDir) {
20
- var pidFile = path.join(projectDir, '.claude-flow', 'background-pids.json');
21
- var lockFile = path.join(projectDir, '.claude-flow', 'spawn.lock');
22
- var killed = 0;
23
-
24
- try {
25
- if (fs.existsSync(pidFile)) {
26
- var entries = JSON.parse(fs.readFileSync(pidFile, 'utf-8'));
27
- if (!Array.isArray(entries)) entries = [];
28
- for (var i = 0; i < entries.length; i++) {
29
- try { process.kill(entries[i].pid, 0); } catch (e) { continue; }
30
- try { process.kill(entries[i].pid, 'SIGTERM'); killed++; } catch (e) { /* ok */ }
31
- }
32
- fs.writeFileSync(pidFile, '[]');
33
- }
34
- } catch (e) { /* non-fatal */ }
35
-
36
- try { if (fs.existsSync(lockFile)) fs.unlinkSync(lockFile); } catch (e) { /* ok */ }
37
-
38
- return killed;
39
- }
40
-
41
- module.exports = { killTrackedSync };