claude-flow 3.37.0 → 3.38.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.
@@ -180,6 +180,21 @@
180
180
  "name": "ruflo-arena",
181
181
  "source": "./plugins/ruflo-arena",
182
182
  "description": "Competitive ruliology for ruflo swarms — arenas, tournaments, and adaptive co-evolution of program strategies (ADR-147/148); strategies-as-programs compete under payoff games"
183
+ },
184
+ {
185
+ "name": "ruflo-agntcy",
186
+ "source": "./plugins/ruflo-agntcy",
187
+ "description": "AGNTCY/Outshift Internet-of-Cognition runtime integration — SLIM secure transport, CASA intent-scoped tool authorization, and AGNTCY identity/observability spans (ADR-380); optional, removable augmentation per ADR-150"
188
+ },
189
+ {
190
+ "name": "ruflo-bbs-federation",
191
+ "source": "./plugins/ruflo-bbs-federation",
192
+ "description": "AgentBBS federated business-domain BBS room integration (ADR-164 Phase 1) — register/publish/watch/human-join MCP tools wrapping the agentbbs Rust workspace as a federation peer; degrades gracefully when agentbbs is absent"
193
+ },
194
+ {
195
+ "name": "ruflo-business-pods",
196
+ "source": "./plugins/ruflo-business-pods",
197
+ "description": "Business-domain pod templates for the federated business autopilot (ADR-164 Phase 2) — pod templates plus a dry-run-by-default single-tick runner that validates, reserves budget, and resolves agent roles before posting to the BBS room"
183
198
  }
184
199
  ]
185
200
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.37.0",
3
+ "version": "3.38.1",
4
4
  "workspaces": [
5
5
  "v3/@claude-flow/codex",
6
6
  "v3/@claude-flow/plugin-agent-federation",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "generation": 4,
4
- "generatedAt": "2026-08-11T17:05:49.193Z",
5
- "gitSha": "6ce18b5a",
4
+ "generatedAt": "2026-08-12T14:05:18.962Z",
5
+ "gitSha": "b8c37da8",
6
6
  "catalog": {
7
7
  "agents": 164,
8
8
  "tools": 397,
@@ -214,7 +214,15 @@ const storeCommand = {
214
214
  ]
215
215
  });
216
216
  output.writeln();
217
- output.printSuccess('Data stored successfully');
217
+ if (result.persistWarning) {
218
+ // #2968: the write ran, but the checkpoint signal indicates it may
219
+ // not have reached disk (sql.js fallback driver) — do not print an
220
+ // unconditional green success for a write that might vanish.
221
+ output.printWarning(`Data stored, but persistence is not guaranteed: ${result.persistWarning}`);
222
+ }
223
+ else {
224
+ output.printSuccess('Data stored successfully');
225
+ }
218
226
  return { success: true, data: { ...storeData, id: result.id, embedding: result.embedding, provenanceType: provenance || 'unknown' } };
219
227
  }
220
228
  catch (error) {
@@ -0,0 +1,27 @@
1
+ export interface RemovedAgentMapping {
2
+ /** Basename as it shipped in the init template, e.g. "coder.md". */
3
+ basename: string;
4
+ /** Marketplace plugin id (name in .claude-plugin/marketplace.json) that now owns it. */
5
+ plugin: string;
6
+ }
7
+ export interface RemovedAgentGap {
8
+ agent: string;
9
+ plugin: string;
10
+ installCommand: string;
11
+ }
12
+ export interface DetectRemovedAgentGapsOptions {
13
+ /**
14
+ * Override for the Claude Code plugin-registry home directory. Defaults to
15
+ * os.homedir(). Tests inject an isolated temp dir so results don't depend
16
+ * on whatever is actually installed on the machine running the suite.
17
+ */
18
+ homeDir?: string;
19
+ }
20
+ /**
21
+ * Returns one gap row per removed agent that is both missing from the
22
+ * project's .claude/agents/ tree and not covered by an installed owning
23
+ * plugin. Pure filesystem checks, no CLI version comparison (ADR-382 Part B
24
+ * scope note: a filesystem check is sufficient and accurate here).
25
+ */
26
+ export declare function detectRemovedAgentGaps(cwd: string, removedAgents: RemovedAgentMapping[], options?: DetectRemovedAgentGapsOptions): RemovedAgentGap[];
27
+ //# sourceMappingURL=migrate-agent-detection.d.ts.map
@@ -0,0 +1,113 @@
1
+ /**
2
+ * ADR-382 Part B — the `ruflo migrate` mitigation ADR-128 promised and never
3
+ * shipped: detect the 9 forked agents ADR-128 Phase 2 deleted from the init
4
+ * template (each plugin is now canonical) and, when a project is missing one
5
+ * AND the owning plugin isn't installed, surface an install suggestion.
6
+ * See v3/docs/adr/ADR-382-init-scaffold-content-drift-remediation.md and
7
+ * https://github.com/ruvnet/ruflo/issues/2971.
8
+ *
9
+ * Kept in a sibling module (not migrate.ts) because migrate.ts is already
10
+ * near/over the 500-line budget — see CLAUDE.md file-size rule.
11
+ */
12
+ import * as fs from 'fs';
13
+ import * as path from 'path';
14
+ import * as os from 'os';
15
+ /**
16
+ * Claude Code records every plugin install (marketplace-scoped, "user" or
17
+ * "project") in a single global file — ~/.claude/plugins/installed_plugins.json,
18
+ * keyed "<plugin>@<marketplace>". This is the only real on-disk signal for
19
+ * "is the owning plugin installed"; there is no per-project marker and no
20
+ * ruflo-side tracking for marketplace plugins (ruflo's own PluginManager
21
+ * manifest at .claude-flow/plugins/installed.json tracks a different,
22
+ * npm-package-based plugin system).
23
+ */
24
+ function readInstalledPluginsRegistry(homeDir) {
25
+ const registryPath = path.join(homeDir, '.claude', 'plugins', 'installed_plugins.json');
26
+ try {
27
+ if (!fs.existsSync(registryPath))
28
+ return {};
29
+ const raw = fs.readFileSync(registryPath, 'utf-8');
30
+ const parsed = JSON.parse(raw);
31
+ if (parsed && typeof parsed === 'object' && parsed.plugins && typeof parsed.plugins === 'object') {
32
+ return parsed.plugins;
33
+ }
34
+ return {};
35
+ }
36
+ catch {
37
+ return {};
38
+ }
39
+ }
40
+ function isPluginInstalled(pluginName, cwd, registry) {
41
+ const resolvedCwd = path.resolve(cwd);
42
+ const prefix = `${pluginName}@`;
43
+ for (const [key, entries] of Object.entries(registry)) {
44
+ if (!key.startsWith(prefix))
45
+ continue;
46
+ if (!Array.isArray(entries))
47
+ continue;
48
+ for (const entry of entries) {
49
+ if (entry?.scope === 'project') {
50
+ if (entry.projectPath && path.resolve(entry.projectPath) === resolvedCwd)
51
+ return true;
52
+ }
53
+ else {
54
+ // "user" scope (or unspecified) applies to every project.
55
+ return true;
56
+ }
57
+ }
58
+ }
59
+ return false;
60
+ }
61
+ function agentFileExists(cwd, basename) {
62
+ const agentsDir = path.join(cwd, '.claude', 'agents');
63
+ return findBasename(agentsDir, basename, 0);
64
+ }
65
+ // .claude/agents/ is a shallow tree (category/[subcategory]/name.md); a small
66
+ // depth guard is enough to avoid pathological recursion without needing a
67
+ // real glob dependency for a two-or-three-level lookup.
68
+ const MAX_AGENT_DIR_DEPTH = 6;
69
+ function findBasename(dir, basename, depth) {
70
+ if (depth > MAX_AGENT_DIR_DEPTH)
71
+ return false;
72
+ let entries;
73
+ try {
74
+ entries = fs.readdirSync(dir, { withFileTypes: true });
75
+ }
76
+ catch {
77
+ return false;
78
+ }
79
+ for (const entry of entries) {
80
+ if (entry.isDirectory()) {
81
+ if (findBasename(path.join(dir, entry.name), basename, depth + 1))
82
+ return true;
83
+ }
84
+ else if (entry.isFile() && entry.name === basename) {
85
+ return true;
86
+ }
87
+ }
88
+ return false;
89
+ }
90
+ /**
91
+ * Returns one gap row per removed agent that is both missing from the
92
+ * project's .claude/agents/ tree and not covered by an installed owning
93
+ * plugin. Pure filesystem checks, no CLI version comparison (ADR-382 Part B
94
+ * scope note: a filesystem check is sufficient and accurate here).
95
+ */
96
+ export function detectRemovedAgentGaps(cwd, removedAgents, options = {}) {
97
+ const homeDir = options.homeDir ?? os.homedir();
98
+ const registry = readInstalledPluginsRegistry(homeDir);
99
+ const gaps = [];
100
+ for (const { basename, plugin } of removedAgents) {
101
+ if (agentFileExists(cwd, basename))
102
+ continue;
103
+ if (isPluginInstalled(plugin, cwd, registry))
104
+ continue;
105
+ gaps.push({
106
+ agent: basename,
107
+ plugin,
108
+ installCommand: `ruflo plugins install ${plugin}`,
109
+ });
110
+ }
111
+ return gaps;
112
+ }
113
+ //# sourceMappingURL=migrate-agent-detection.js.map
@@ -5,6 +5,7 @@
5
5
  import { output } from '../output.js';
6
6
  import * as fs from 'fs';
7
7
  import * as path from 'path';
8
+ import { detectRemovedAgentGaps } from './migrate-agent-detection.js';
8
9
  // Migration targets
9
10
  const MIGRATION_TARGETS = [
10
11
  { value: 'config', label: 'Configuration', hint: 'Migrate configuration files' },
@@ -15,6 +16,21 @@ const MIGRATION_TARGETS = [
15
16
  { value: 'embeddings', label: 'Embeddings', hint: 'Migrate to ONNX with hyperbolic support' },
16
17
  { value: 'all', label: 'All', hint: 'Full migration' }
17
18
  ];
19
+ // ADR-128 Phase 2 deleted these 9 forked agents from the init template,
20
+ // making each plugin canonical — but ADR-128's own Consequences section
21
+ // promised "`ruflo migrate` should detect removed agents and print install
22
+ // suggestions," which never shipped until ADR-382 Part B (issue #2971).
23
+ const REMOVED_AGENTS = [
24
+ { basename: 'coder.md', plugin: 'ruflo-core' },
25
+ { basename: 'researcher.md', plugin: 'ruflo-core' },
26
+ { basename: 'reviewer.md', plugin: 'ruflo-core' },
27
+ { basename: 'tester.md', plugin: 'ruflo-testgen' },
28
+ { basename: 'memory-specialist.md', plugin: 'ruflo-rag-memory' },
29
+ { basename: 'security-auditor.md', plugin: 'ruflo-security-audit' },
30
+ { basename: 'sparc-orchestrator.md', plugin: 'ruflo-sparc' },
31
+ { basename: 'goal-planner.md', plugin: 'ruflo-goals' },
32
+ { basename: 'adr-architect.md', plugin: 'ruflo-adr' },
33
+ ];
18
34
  // Status command
19
35
  const statusCommand = {
20
36
  name: 'status',
@@ -101,10 +117,13 @@ const statusCommand = {
101
117
  if (migrationState) {
102
118
  components.push({ component: 'Migration State', status: migrationState, migrationNeeded: 'no' });
103
119
  }
120
+ // ADR-382 Part B: agents ADR-128 removed from the init template that are
121
+ // both missing from this project and not covered by an installed plugin.
122
+ const removedAgentGaps = detectRemovedAgentGaps(cwd, REMOVED_AGENTS);
104
123
  // Display results
105
124
  if (ctx.flags.format === 'json') {
106
- output.printJson({ components, migrationState });
107
- return { success: true, data: { components, migrationState } };
125
+ output.printJson({ components, migrationState, removedAgentGaps });
126
+ return { success: true, data: { components, migrationState, removedAgentGaps } };
108
127
  }
109
128
  output.writeln();
110
129
  output.writeln(output.bold('Migration Status'));
@@ -130,7 +149,26 @@ const statusCommand = {
130
149
  else {
131
150
  output.printSuccess('No migration needed.');
132
151
  }
133
- return { success: true, data: { components, needsMigration } };
152
+ if (removedAgentGaps.length > 0) {
153
+ output.writeln();
154
+ output.writeln(output.bold('Removed Agents (ADR-128)'));
155
+ output.printTable({
156
+ columns: [
157
+ { key: 'agent', header: 'Agent', width: 24 },
158
+ { key: 'plugin', header: 'Owning Plugin', width: 20 },
159
+ { key: 'installCommand', header: 'Install', width: 34 }
160
+ ],
161
+ data: removedAgentGaps.map(g => ({
162
+ agent: output.warning(g.agent),
163
+ plugin: g.plugin,
164
+ installCommand: output.dim(g.installCommand)
165
+ })),
166
+ border: false
167
+ });
168
+ output.writeln();
169
+ output.printInfo(`${removedAgentGaps.length} agent(s) removed by ADR-128 are missing from .claude/agents/ and not covered by an installed plugin.`);
170
+ }
171
+ return { success: true, data: { components, needsMigration, removedAgentGaps } };
134
172
  }
135
173
  };
136
174
  // Run migration
@@ -67,6 +67,13 @@ export declare function bridgeStoreEntry(options: {
67
67
  cached?: boolean;
68
68
  attested?: boolean;
69
69
  error?: string;
70
+ /** #2968: set when the post-write checkpoint failed in a way that
71
+ * indicates this connection may not durably persist writes at all
72
+ * (the sql.js fallback driver, engaged when better-sqlite3's native
73
+ * binding is missing). The write above still ran and `success` is
74
+ * still true — this is advisory, not a failure — but callers should
75
+ * surface it instead of only printing an unconditional success message. */
76
+ persistWarning?: string;
70
77
  } | null>;
71
78
  /**
72
79
  * Search entries via AgentDB v3.
@@ -897,12 +897,27 @@ export async function bridgeStoreEntry(options) {
897
897
  // `sqlite3` vector count) then see a stale/empty main DB file and report
898
898
  // "0 vectors" / empty search. A PASSIVE checkpoint flushes committed pages
899
899
  // into the main file without blocking writers. Best-effort, never fatal.
900
+ let persistWarning;
900
901
  try {
901
902
  if (typeof ctx.db.pragma === 'function') {
902
903
  ctx.db.pragma('wal_checkpoint(PASSIVE)');
903
904
  }
904
905
  }
905
- catch { /* non-WAL, busy, or unsupported — non-fatal */ }
906
+ catch (checkpointErr) {
907
+ // #2968: on the sql.js fallback driver (engaged when better-sqlite3's
908
+ // native binding never got built — e.g. a skipped optionalDependency
909
+ // postinstall), this PRAGMA isn't implemented and throws "Invalid
910
+ // PRAGMA command". sql.js has no WAL journal to checkpoint at all, so
911
+ // this specific failure is the strongest signal available here that
912
+ // the insert above may exist only in this process's in-memory image
913
+ // and never reach disk — not the ordinary "non-WAL, busy, or
914
+ // unsupported" case the old blanket catch assumed. Surface it rather
915
+ // than swallow it silently; other pragma failures stay non-fatal.
916
+ const msg = checkpointErr instanceof Error ? checkpointErr.message : String(checkpointErr);
917
+ if (/Invalid PRAGMA/i.test(msg)) {
918
+ persistWarning = `sql.js fallback driver in use — this write may not be durably persisted to disk (${msg}). Install better-sqlite3's native binding to restore durable writes (see issue #2968: npm rebuild better-sqlite3, or reinstall with install scripts enabled).`;
919
+ }
920
+ }
906
921
  // Phase 2: Write-through to TieredCache
907
922
  const safeNs = String(namespace).replace(/:/g, '_');
908
923
  const safeKey = String(key).replace(/:/g, '_');
@@ -918,6 +933,7 @@ export async function bridgeStoreEntry(options) {
918
933
  guarded: true,
919
934
  cached: true,
920
935
  attested: true,
936
+ ...(persistWarning ? { persistWarning } : {}),
921
937
  };
922
938
  }
923
939
  catch (err) {
@@ -995,10 +1011,17 @@ export async function bridgeSearchEntries(options) {
995
1011
  const whereExtra = filters.length > 0 ? `AND ${filters.join(' AND ')}` : '';
996
1012
  let rows;
997
1013
  try {
1014
+ // #2982/#2976: this pre-rank SELECT truncates the corpus to 1000 rows
1015
+ // before BM25/embedding scoring runs. Without ORDER BY, SQLite returns
1016
+ // rows in arbitrary storage order (effectively oldest-inserted-first at
1017
+ // scale), so on any corpus over 1000 entries the newest — and often
1018
+ // most relevant — rows never reach scoring at all. bridgeListEntries()
1019
+ // already orders by updated_at DESC for the same reason; mirror it here.
998
1020
  const stmt = ctx.db.prepare(`
999
1021
  SELECT id, key, namespace, content, embedding, provenance_type
1000
1022
  FROM memory_entries
1001
1023
  WHERE ${ACTIVE_MEMORY_ROW_SQL} ${whereExtra}
1024
+ ORDER BY updated_at DESC
1002
1025
  LIMIT 1000
1003
1026
  `);
1004
1027
  rows = filterParams.length > 0 ? stmt.all(...filterParams) : stmt.all();
@@ -1506,10 +1529,14 @@ export async function bridgeSearchHNSW(queryEmbedding, options, dbPath) {
1506
1529
  : '';
1507
1530
  let rows;
1508
1531
  try {
1532
+ // #2982/#2976: same unordered pre-rank truncation as bridgeSearchEntries
1533
+ // above — without ORDER BY, a corpus over 10000 rows silently drops
1534
+ // its newest entries before cosine scoring ever runs.
1509
1535
  const stmt = ctx.db.prepare(`
1510
1536
  SELECT id, key, namespace, content, embedding
1511
1537
  FROM memory_entries
1512
1538
  WHERE status = 'active' AND embedding IS NOT NULL ${nsFilter}
1539
+ ORDER BY updated_at DESC
1513
1540
  LIMIT 10000
1514
1541
  `);
1515
1542
  rows = nsFilter
@@ -448,6 +448,9 @@ export declare function storeEntry(options: {
448
448
  model: string;
449
449
  };
450
450
  error?: string;
451
+ /** #2968: set when the bridge's checkpoint failed in a way indicating
452
+ * this write may not be durably persisted (sql.js fallback driver). */
453
+ persistWarning?: string;
451
454
  }>;
452
455
  /**
453
456
  * Search entries using sql.js with vector similarity
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.37.0",
3
+ "version": "3.38.1",
4
4
  "type": "module",
5
5
  "description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",