claude-flow 3.5.78 → 3.5.79

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.5.78",
3
+ "version": "3.5.79",
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",
@@ -231,8 +231,12 @@ const initAction = async (ctx) => {
231
231
  }
232
232
  output.printBox(summary.join('\n'), 'Summary');
233
233
  output.writeln();
234
- // Show what was created
235
- if (options.components.claudeMd || options.components.settings || options.components.skills || options.components.commands || options.components.agents) {
234
+ // Show what was created (honest about skip-claude — #1597)
235
+ if (skipClaude) {
236
+ output.printBox('Skipped (--skip-claude): no files written under .claude/ or ~/.claude/', 'Claude Code Integration');
237
+ output.writeln();
238
+ }
239
+ else if (options.components.claudeMd || options.components.settings || options.components.skills || options.components.commands || options.components.agents) {
236
240
  output.printBox([
237
241
  options.components.claudeMd ? `CLAUDE.md: Swarm guidance & configuration` : '',
238
242
  options.components.settings ? `Settings: .claude/settings.json` : '',
@@ -909,7 +913,7 @@ export const initCommand = {
909
913
  },
910
914
  {
911
915
  name: 'skip-claude',
912
- description: 'Skip .claude/ directory creation (runtime only)',
916
+ description: 'Skip all .claude/ writes including global ~/.claude/CLAUDE.md (runtime only)',
913
917
  type: 'boolean',
914
918
  default: false,
915
919
  },
@@ -1663,6 +1663,11 @@ async function writeClaudeMd(targetDir, options, result) {
1663
1663
  result.created.files.push('CLAUDE.md');
1664
1664
  }
1665
1665
  // Also write/append global ~/.claude/CLAUDE.md so ruflo tools are used automatically (#1497)
1666
+ // Guarded to never overwrite user content and to respect opt-out env var (#1597).
1667
+ // Opt out entirely with CLAUDE_FLOW_SKIP_GLOBAL_CLAUDE_MD=1.
1668
+ if (process.env.CLAUDE_FLOW_SKIP_GLOBAL_CLAUDE_MD === '1') {
1669
+ return;
1670
+ }
1666
1671
  const homeDir = process.env.HOME || process.env.USERPROFILE || '';
1667
1672
  if (homeDir) {
1668
1673
  const globalClaudeDir = path.join(homeDir, '.claude');
@@ -1682,8 +1687,13 @@ async function writeClaudeMd(targetDir, options, result) {
1682
1687
  if (fs.existsSync(globalClaudeMd)) {
1683
1688
  const existing = fs.readFileSync(globalClaudeMd, 'utf-8');
1684
1689
  if (!existing.includes('Ruflo Integration')) {
1690
+ // Always back up existing user content before any modification (#1597).
1691
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
1692
+ const backupPath = `${globalClaudeMd}.backup-${timestamp}`;
1693
+ fs.copyFileSync(globalClaudeMd, backupPath);
1685
1694
  fs.appendFileSync(globalClaudeMd, rufloBlock);
1686
1695
  result.created.files.push('~/.claude/CLAUDE.md (appended ruflo block)');
1696
+ result.created.files.push(`~/.claude/CLAUDE.md.backup-${timestamp} (backup of pre-existing content)`);
1687
1697
  }
1688
1698
  }
1689
1699
  else {
@@ -18,11 +18,28 @@ export interface MCPToolResult {
18
18
  isError?: boolean;
19
19
  }
20
20
  /**
21
- * Returns the effective project working directory.
22
- * Prefers CLAUDE_FLOW_CWD (set by the install script for global/MCP installs
23
- * where process.cwd() may resolve to '/') over the real process.cwd().
21
+ * Returns the effective project working directory for storage path resolution.
22
+ *
23
+ * Resolution order (#1577):
24
+ * 1. CLAUDE_FLOW_PROJECT_DIR — explicit ruflo project override
25
+ * 2. CLAUDE_FLOW_CWD — legacy ruflo override set by install script
26
+ * 3. CLAUDE_PROJECT_DIR — Claude Code's native project dir env var
27
+ * 4. INIT_CWD — npm's original invocation dir
28
+ * 5. process.cwd() — if it is not a system directory
29
+ * 6. os.homedir() — safe fallback
30
+ *
31
+ * System directories (e.g. C:\Windows\System32 on Windows, where MCP servers
32
+ * spawned by AI agents commonly inherit cwd) are rejected at every step.
33
+ *
34
+ * Only use this for storage path resolution. When the actual runtime working
35
+ * directory matters (e.g. child process cwd, user-facing status), call
36
+ * process.cwd() directly.
24
37
  */
25
38
  export declare function getProjectCwd(): string;
39
+ /**
40
+ * Reset cached value. Intended for tests only.
41
+ */
42
+ export declare function __resetProjectCwdCache(): void;
26
43
  export interface MCPTool {
27
44
  name: string;
28
45
  description: string;
@@ -3,12 +3,73 @@
3
3
  *
4
4
  * Local type definitions to avoid external imports outside package boundary.
5
5
  */
6
+ import { homedir } from 'node:os';
7
+ // System directories that must not be used for project storage (#1577).
8
+ // On Windows, MCP servers spawned by AI agents often inherit System32 as cwd
9
+ // — writing there fails with EPERM.
10
+ const SYSTEM_DIR_PREFIXES = [
11
+ 'c:\\windows',
12
+ 'c:/windows',
13
+ '/windows/system32',
14
+ ];
15
+ function isSystemDir(dir) {
16
+ if (!dir)
17
+ return true;
18
+ const lower = dir.toLowerCase().replace(/\\/g, '/');
19
+ return SYSTEM_DIR_PREFIXES.some((p) => lower.startsWith(p.replace(/\\/g, '/')));
20
+ }
21
+ let _cachedProjectCwd;
6
22
  /**
7
- * Returns the effective project working directory.
8
- * Prefers CLAUDE_FLOW_CWD (set by the install script for global/MCP installs
9
- * where process.cwd() may resolve to '/') over the real process.cwd().
23
+ * Returns the effective project working directory for storage path resolution.
24
+ *
25
+ * Resolution order (#1577):
26
+ * 1. CLAUDE_FLOW_PROJECT_DIR — explicit ruflo project override
27
+ * 2. CLAUDE_FLOW_CWD — legacy ruflo override set by install script
28
+ * 3. CLAUDE_PROJECT_DIR — Claude Code's native project dir env var
29
+ * 4. INIT_CWD — npm's original invocation dir
30
+ * 5. process.cwd() — if it is not a system directory
31
+ * 6. os.homedir() — safe fallback
32
+ *
33
+ * System directories (e.g. C:\Windows\System32 on Windows, where MCP servers
34
+ * spawned by AI agents commonly inherit cwd) are rejected at every step.
35
+ *
36
+ * Only use this for storage path resolution. When the actual runtime working
37
+ * directory matters (e.g. child process cwd, user-facing status), call
38
+ * process.cwd() directly.
10
39
  */
11
40
  export function getProjectCwd() {
12
- return process.env.CLAUDE_FLOW_CWD || process.cwd();
41
+ if (_cachedProjectCwd !== undefined)
42
+ return _cachedProjectCwd;
43
+ const envKeys = [
44
+ 'CLAUDE_FLOW_PROJECT_DIR',
45
+ 'CLAUDE_FLOW_CWD',
46
+ 'CLAUDE_PROJECT_DIR',
47
+ 'INIT_CWD',
48
+ ];
49
+ for (const key of envKeys) {
50
+ const val = process.env[key];
51
+ if (val && !isSystemDir(val)) {
52
+ _cachedProjectCwd = val;
53
+ return _cachedProjectCwd;
54
+ }
55
+ }
56
+ try {
57
+ const cwd = process.cwd();
58
+ if (!isSystemDir(cwd)) {
59
+ _cachedProjectCwd = cwd;
60
+ return _cachedProjectCwd;
61
+ }
62
+ }
63
+ catch {
64
+ // process.cwd() can throw ENOENT if the cwd was deleted — fall through.
65
+ }
66
+ _cachedProjectCwd = homedir();
67
+ return _cachedProjectCwd;
68
+ }
69
+ /**
70
+ * Reset cached value. Intended for tests only.
71
+ */
72
+ export function __resetProjectCwdCache() {
73
+ _cachedProjectCwd = undefined;
13
74
  }
14
75
  //# sourceMappingURL=types.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.5.78",
3
+ "version": "3.5.79",
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",
@@ -115,8 +115,7 @@
115
115
  "@ruvector/rvagent-wasm": "^0.1.0",
116
116
  "@ruvector/diskann": "^0.1.0",
117
117
  "@ruvector/sona": "^0.1.5",
118
- "agentdb": "^3.0.0-alpha.11",
119
- "agentic-flow": "^3.0.0-alpha.1"
118
+ "agentdb": "^3.0.0-alpha.11"
120
119
  },
121
120
  "publishConfig": {
122
121
  "access": "public",