claude-flow 3.7.0-alpha.28 → 3.7.0-alpha.29

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.
@@ -26,18 +26,29 @@ const CONFIG = {
26
26
 
27
27
  const CWD = process.cwd();
28
28
 
29
- // Read package version once at startup
29
+ // Read package version once at startup. Probe the plugin's own install
30
+ // location first — `~/.claude/plugins/marketplaces/ruflo/package.json` — so
31
+ // users who installed via `/plugin install ruflo@ruflo` see the real version,
32
+ // not the hardcoded fallback (#1951).
30
33
  let pkgVersion = '3.5';
31
34
  try {
35
+ const os = require('os');
36
+ const home = os.homedir();
32
37
  const pkgPaths = [
38
+ path.join(home, '.claude', 'plugins', 'marketplaces', 'ruflo', 'package.json'),
33
39
  path.join(CWD, 'node_modules', '@claude-flow', 'cli', 'package.json'),
40
+ path.join(CWD, 'node_modules', 'ruflo', 'package.json'),
34
41
  path.join(CWD, 'v3', '@claude-flow', 'cli', 'package.json'),
35
42
  ];
36
43
  for (const p of pkgPaths) {
37
- if (fs.existsSync(p)) {
44
+ if (!fs.existsSync(p)) continue;
45
+ try {
38
46
  const pkg = JSON.parse(fs.readFileSync(p, 'utf-8'));
39
- if (pkg.version) { pkgVersion = pkg.version; break; }
40
- }
47
+ if (pkg && typeof pkg.version === 'string' && pkg.version.length > 0) {
48
+ pkgVersion = pkg.version;
49
+ break;
50
+ }
51
+ } catch { /* malformed package.json — try next */ }
41
52
  }
42
53
  } catch { /* use default */ }
43
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.7.0-alpha.28",
3
+ "version": "3.7.0-alpha.29",
4
4
  "description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -139,12 +139,23 @@ async function checkDaemonStatus() {
139
139
  }
140
140
  // Check memory database
141
141
  async function checkMemoryDatabase() {
142
- const dbPaths = [
143
- '.claude-flow/memory.db',
144
- '.swarm/memory.db',
145
- 'data/memory.db'
146
- ];
147
- for (const dbPath of dbPaths) {
142
+ // Authoritative path comes from `getMemoryRoot()` (honors
143
+ // `CLAUDE_FLOW_MEMORY_PATH`, claude-flow.config.json's `memory.persistPath`,
144
+ // then defaults to `.swarm/`). #1946: the previous hard-coded list missed
145
+ // `data/memory/memory.db` (a common config) and ignored the env var
146
+ // entirely, so doctor reported "Not initialized" on perfectly-init'd DBs.
147
+ // Try the configured path first, then fall back to the historic candidates.
148
+ const candidates = [];
149
+ try {
150
+ const { getMemoryRoot } = await import('../memory/memory-initializer.js');
151
+ candidates.push(join(getMemoryRoot(), 'memory.db'));
152
+ }
153
+ catch {
154
+ /* memory-initializer not available — fall through to legacy candidates */
155
+ }
156
+ candidates.push('.swarm/memory.db', '.claude-flow/memory.db', 'data/memory/memory.db', // matches `CLAUDE_FLOW_MEMORY_PATH=data/memory`
157
+ 'data/memory.db');
158
+ for (const dbPath of candidates) {
148
159
  if (existsSync(dbPath)) {
149
160
  try {
150
161
  const stats = statSync(dbPath);
@@ -637,23 +637,34 @@ function generateStatusline() {
637
637
  const integration = getIntegrationStatus();
638
638
  const lines = [];
639
639
 
640
- // Header
641
- // Read version from package.json
640
+ // Header — read version from the FIRST package.json we find, preferring
641
+ // the plugin install at ~/.claude/plugins/marketplaces/ruflo/package.json.
642
+ // The previous list only checked project-local node_modules, so plugin
643
+ // users saw the hard-coded fallback (V3.5) even on newer alphas (#1951).
642
644
  let pkgVersion = '3.6';
643
645
  try {
644
- const pkgPath = path.join(CWD, 'node_modules', '@claude-flow', 'cli', 'package.json');
645
- if (fs.existsSync(pkgPath)) {
646
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
647
- if (pkg.version) pkgVersion = pkg.version;
648
- } else {
649
- // Try npx-installed location
650
- const npxPkg = path.join(CWD, 'v3', '@claude-flow', 'cli', 'package.json');
651
- if (fs.existsSync(npxPkg)) {
652
- const pkg = JSON.parse(fs.readFileSync(npxPkg, 'utf-8'));
653
- if (pkg.version) pkgVersion = pkg.version;
654
- }
646
+ const home = require('os').homedir();
647
+ const pkgPaths = [
648
+ // 1. The plugin's own root (installed via /plugin install).
649
+ path.join(home, '.claude', 'plugins', 'marketplaces', 'ruflo', 'package.json'),
650
+ // 2. Project-local @claude-flow/cli — npm-style install.
651
+ path.join(CWD, 'node_modules', '@claude-flow', 'cli', 'package.json'),
652
+ // 3. Project-local ruflo umbrella.
653
+ path.join(CWD, 'node_modules', 'ruflo', 'package.json'),
654
+ // 4. Source-checkout location (when developing in this repo).
655
+ path.join(CWD, 'v3', '@claude-flow', 'cli', 'package.json'),
656
+ ];
657
+ for (const p of pkgPaths) {
658
+ if (!fs.existsSync(p)) continue;
659
+ try {
660
+ const pkg = JSON.parse(fs.readFileSync(p, 'utf-8'));
661
+ if (pkg && typeof pkg.version === 'string' && pkg.version.length > 0) {
662
+ pkgVersion = pkg.version;
663
+ break;
664
+ }
665
+ } catch { /* malformed package.json — try next */ }
655
666
  }
656
- } catch { /* use default */ }
667
+ } catch { /* fall through to the hardcoded default */ }
657
668
  let header = c.bold + c.brightPurple + '\\u258A RuFlo V' + pkgVersion + ' ' + c.reset;
658
669
  header += (swarm.coordinationActive ? c.brightCyan : c.dim) + '\\u25CF ' + c.brightCyan + git.name + c.reset;
659
670
  if (git.gitBranch) {
@@ -18,26 +18,50 @@
18
18
  */
19
19
  import * as path from 'path';
20
20
  import * as crypto from 'crypto';
21
+ import { createRequire } from 'node:module';
21
22
  // ===== Lazy singleton =====
22
23
  let registryPromise = null;
23
24
  let registryInstance = null;
24
25
  let bridgeAvailable = null;
25
26
  /**
26
27
  * Resolve database path with path traversal protection.
27
- * Only allows paths within or below the project's .swarm directory,
28
+ * Only allows paths within or below the project's working directory,
28
29
  * or the special ':memory:' path.
30
+ *
31
+ * #1945: the previous hard-coded `<cwd>/.swarm/memory.db` default ignored
32
+ * `CLAUDE_FLOW_MEMORY_PATH` / `claude-flow.config.json#memory.persistPath`
33
+ * — so users with non-default memory paths had `memory init` write to e.g.
34
+ * `data/memory/memory.db` while `bridgeStoreEntry()` wrote to
35
+ * `.swarm/memory.db`. CLI store reported success against the wrong file and
36
+ * a fresh process reading the configured path saw nothing.
37
+ *
38
+ * Use `getMemoryRoot()` (from memory-initializer) so the bridge and the
39
+ * initializer agree on the same file. Imported via require() to avoid a
40
+ * circular ESM dep between memory-initializer.ts and memory-bridge.ts.
29
41
  */
30
42
  function getDbPath(customPath) {
31
- const swarmDir = path.resolve(process.cwd(), '.swarm');
43
+ let defaultDir = path.resolve(process.cwd(), '.swarm');
44
+ try {
45
+ // `getMemoryRoot()` honors $CLAUDE_FLOW_MEMORY_PATH, then the
46
+ // claude-flow.config.json `memory.persistPath`, then defaults to `.swarm`.
47
+ const cjsRequire = createRequire(import.meta.url);
48
+ const mod = cjsRequire('./memory-initializer.js');
49
+ if (typeof mod.getMemoryRoot === 'function') {
50
+ defaultDir = mod.getMemoryRoot();
51
+ }
52
+ }
53
+ catch {
54
+ /* memory-initializer not resolvable in this build — keep `.swarm/` default */
55
+ }
32
56
  if (!customPath)
33
- return path.join(swarmDir, 'memory.db');
57
+ return path.join(defaultDir, 'memory.db');
34
58
  if (customPath === ':memory:')
35
59
  return ':memory:';
36
60
  const resolved = path.resolve(customPath);
37
- // Ensure the path doesn't escape the working directory
61
+ // Ensure the path doesn't escape the working directory.
38
62
  const cwd = process.cwd();
39
63
  if (!resolved.startsWith(cwd)) {
40
- return path.join(swarmDir, 'memory.db'); // fallback to safe default
64
+ return path.join(defaultDir, 'memory.db'); // fallback to safe default
41
65
  }
42
66
  return resolved;
43
67
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.7.0-alpha.28",
3
+ "version": "3.7.0-alpha.29",
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",