claude-flow 3.74.1 → 3.75.0

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 (91) hide show
  1. package/.claude/helpers/auto-memory-hook.mjs +262 -81
  2. package/node_modules/@claude-flow/codex/README.md +38 -0
  3. package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts +1 -0
  4. package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts.map +1 -1
  5. package/node_modules/@claude-flow/codex/dist/generators/agents-md.js +4 -4
  6. package/node_modules/@claude-flow/codex/dist/generators/agents-md.js.map +1 -1
  7. package/node_modules/@claude-flow/codex/dist/generators/dual-instructions.d.ts +20 -0
  8. package/node_modules/@claude-flow/codex/dist/generators/dual-instructions.d.ts.map +1 -0
  9. package/node_modules/@claude-flow/codex/dist/generators/dual-instructions.js +104 -0
  10. package/node_modules/@claude-flow/codex/dist/generators/dual-instructions.js.map +1 -0
  11. package/node_modules/@claude-flow/codex/dist/generators/index.d.ts +2 -0
  12. package/node_modules/@claude-flow/codex/dist/generators/index.d.ts.map +1 -1
  13. package/node_modules/@claude-flow/codex/dist/generators/index.js +2 -0
  14. package/node_modules/@claude-flow/codex/dist/generators/index.js.map +1 -1
  15. package/node_modules/@claude-flow/codex/dist/generators/shared-instructions.d.ts +46 -0
  16. package/node_modules/@claude-flow/codex/dist/generators/shared-instructions.d.ts.map +1 -0
  17. package/node_modules/@claude-flow/codex/dist/generators/shared-instructions.js +162 -0
  18. package/node_modules/@claude-flow/codex/dist/generators/shared-instructions.js.map +1 -0
  19. package/node_modules/@claude-flow/codex/dist/index.d.ts +3 -3
  20. package/node_modules/@claude-flow/codex/dist/index.js +1 -1
  21. package/node_modules/@claude-flow/codex/dist/initializer.d.ts.map +1 -1
  22. package/node_modules/@claude-flow/codex/dist/initializer.js +16 -93
  23. package/node_modules/@claude-flow/codex/dist/initializer.js.map +1 -1
  24. package/node_modules/@claude-flow/codex/package.json +8 -6
  25. package/node_modules/@claude-flow/mcp/README.md +44 -0
  26. package/node_modules/@claude-flow/mcp/package.json +16 -4
  27. package/package.json +4 -4
  28. package/v3/@claude-flow/cli/catalog-manifest.json +3 -3
  29. package/v3/@claude-flow/cli/dist/src/autopilot-state.js +17 -8
  30. package/v3/@claude-flow/cli/dist/src/commands/agent.js +2 -1
  31. package/v3/@claude-flow/cli/dist/src/commands/init.js +28 -6
  32. package/v3/@claude-flow/cli/dist/src/commands/memory-backup.js +2 -1
  33. package/v3/@claude-flow/cli/dist/src/commands/memory-distill.js +2 -1
  34. package/v3/@claude-flow/cli/dist/src/commands/memory.js +47 -3
  35. package/v3/@claude-flow/cli/dist/src/commands/neural.js +6 -5
  36. package/v3/@claude-flow/cli/dist/src/commands/plugins-host.d.ts +13 -0
  37. package/v3/@claude-flow/cli/dist/src/commands/plugins-host.js +161 -0
  38. package/v3/@claude-flow/cli/dist/src/commands/plugins.js +3 -1
  39. package/v3/@claude-flow/cli/dist/src/commands/start-all.d.ts +28 -0
  40. package/v3/@claude-flow/cli/dist/src/commands/start-all.js +99 -0
  41. package/v3/@claude-flow/cli/dist/src/commands/start.d.ts +5 -1
  42. package/v3/@claude-flow/cli/dist/src/commands/start.js +17 -10
  43. package/v3/@claude-flow/cli/dist/src/commands/swarm.js +2 -1
  44. package/v3/@claude-flow/cli/dist/src/fs-secure.js +9 -2
  45. package/v3/@claude-flow/cli/dist/src/init/claudemd-generator.d.ts +15 -0
  46. package/v3/@claude-flow/cli/dist/src/init/claudemd-generator.js +64 -114
  47. package/v3/@claude-flow/cli/dist/src/init/dual-instructions.d.ts +29 -0
  48. package/v3/@claude-flow/cli/dist/src/init/dual-instructions.js +87 -0
  49. package/v3/@claude-flow/cli/dist/src/init/executor.js +96 -13
  50. package/v3/@claude-flow/cli/dist/src/init/index.d.ts +3 -1
  51. package/v3/@claude-flow/cli/dist/src/init/index.js +5 -1
  52. package/v3/@claude-flow/cli/dist/src/init/plugin-dedup.d.ts +61 -0
  53. package/v3/@claude-flow/cli/dist/src/init/plugin-dedup.js +130 -0
  54. package/v3/@claude-flow/cli/dist/src/init/shared-instructions.d.ts +46 -0
  55. package/v3/@claude-flow/cli/dist/src/init/shared-instructions.js +162 -0
  56. package/v3/@claude-flow/cli/dist/src/init/types.d.ts +33 -0
  57. package/v3/@claude-flow/cli/dist/src/init/types.js +3 -0
  58. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-tools.d.ts +14 -0
  59. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-tools.js +48 -5
  60. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-hierarchical-inventory-tools.d.ts +15 -0
  61. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-hierarchical-inventory-tools.js +115 -0
  62. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-inventory-tools.d.ts +21 -0
  63. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-inventory-tools.js +152 -0
  64. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-tools.js +56 -7
  65. package/v3/@claude-flow/cli/dist/src/mcp-tools/aidefence-known-misses.d.ts +6 -0
  66. package/v3/@claude-flow/cli/dist/src/mcp-tools/aidefence-known-misses.js +23 -5
  67. package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +21 -3
  68. package/v3/@claude-flow/cli/dist/src/mcp-tools/memory-tools.d.ts +29 -0
  69. package/v3/@claude-flow/cli/dist/src/mcp-tools/memory-tools.js +239 -19
  70. package/v3/@claude-flow/cli/dist/src/mcp-tools/security-tools.js +53 -5
  71. package/v3/@claude-flow/cli/dist/src/memory/embedding-config.d.ts +79 -0
  72. package/v3/@claude-flow/cli/dist/src/memory/embedding-config.js +250 -0
  73. package/v3/@claude-flow/cli/dist/src/memory/ewc-consolidation.js +2 -1
  74. package/v3/@claude-flow/cli/dist/src/memory/intelligence.d.ts +28 -2
  75. package/v3/@claude-flow/cli/dist/src/memory/intelligence.js +37 -7
  76. package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.d.ts +42 -0
  77. package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.js +267 -28
  78. package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.d.ts +1 -1
  79. package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.js +47 -22
  80. package/v3/@claude-flow/cli/dist/src/ruvector/lora-adapter.js +3 -2
  81. package/v3/@claude-flow/cli/dist/src/ruvector/task-embedder.d.ts +2 -1
  82. package/v3/@claude-flow/cli/dist/src/ruvector/task-embedder.js +7 -3
  83. package/v3/@claude-flow/cli/dist/src/services/daemon-autostart.d.ts +4 -6
  84. package/v3/@claude-flow/cli/dist/src/services/daemon-autostart.js +6 -46
  85. package/v3/@claude-flow/cli/dist/src/services/host-executable.d.ts +68 -0
  86. package/v3/@claude-flow/cli/dist/src/services/host-executable.js +175 -0
  87. package/v3/@claude-flow/cli/dist/src/services/host-plugin-manager.d.ts +137 -0
  88. package/v3/@claude-flow/cli/dist/src/services/host-plugin-manager.js +374 -0
  89. package/v3/@claude-flow/cli/dist/src/services/project-root.d.ts +37 -0
  90. package/v3/@claude-flow/cli/dist/src/services/project-root.js +122 -0
  91. package/v3/@claude-flow/cli/package.json +7 -7
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/codex",
3
- "version": "3.0.6",
3
+ "version": "3.0.8",
4
4
  "description": "Codex CLI integration for Ruflo (claude-flow) - OpenAI Codex platform adapter",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -63,14 +63,16 @@
63
63
  "prepublishOnly": "npm run build"
64
64
  },
65
65
  "keywords": [
66
+ "ruflo",
67
+ "claude-flow",
66
68
  "codex",
67
69
  "openai",
68
- "claude-flow",
69
- "coflow",
70
+ "codex-cli",
70
71
  "agents",
71
72
  "skills",
72
73
  "AGENTS.md",
73
- "agentic-ai"
74
+ "agentic-ai",
75
+ "mcp"
74
76
  ],
75
77
  "author": "rUv",
76
78
  "license": "MIT",
@@ -79,7 +81,7 @@
79
81
  "url": "git+https://github.com/ruvnet/ruflo.git",
80
82
  "directory": "v3/@claude-flow/codex"
81
83
  },
82
- "homepage": "https://github.com/ruvnet/ruflo#readme",
84
+ "homepage": "https://ruv.io",
83
85
  "bugs": {
84
86
  "url": "https://github.com/ruvnet/ruflo/issues"
85
87
  },
@@ -105,7 +107,7 @@
105
107
  "fs-extra": "^11.2.0",
106
108
  "chalk": "^5.3.0",
107
109
  "inquirer": "^9.2.0",
108
- "yaml": "^2.4.0",
110
+ "yaml": "^2.8.3",
109
111
  "@iarna/toml": "^2.2.5",
110
112
  "@claude-flow/security": "^3.0.0"
111
113
  },
@@ -1,5 +1,43 @@
1
1
  # @claude-flow/mcp
2
2
 
3
+ <!-- adr-356:quickstart:start -->
4
+ ![Animated diagram: an MCP client request travels through a transport and the MCPServer to the ToolRegistry and the tool handler](https://raw.githubusercontent.com/ruvnet/ruflo/main/v3/@claude-flow/mcp/assets/mcp-flow.svg)
5
+
6
+ **@claude-flow/mcp** — A standalone Model Context Protocol server: stdio, HTTP and WebSocket transports, a schema-checked tool registry, resources, prompts and tasks.
7
+
8
+ **Supported environments:** Node.js 20+ · ESM · Linux, macOS, Windows (pure JavaScript)
9
+
10
+ ## Quickstart
11
+
12
+ ```bash
13
+ npm install @claude-flow/mcp
14
+ ```
15
+
16
+ ```js
17
+ import { createToolRegistry, defineTool } from '@claude-flow/mcp';
18
+
19
+ const logger = { debug() {}, info() {}, warn: console.warn, error: console.error };
20
+ const registry = createToolRegistry(logger);
21
+ registry.register(defineTool('echo', 'Echo the input text', {
22
+ type: 'object', properties: { text: { type: 'string' } }, required: ['text'],
23
+ }, async ({ text }) => ({ echoed: text })));
24
+ console.log(registry.getToolNames());
25
+ const result = await registry.execute('echo', { text: 'hi' });
26
+ console.log(result.isError ?? false, result.content[0].text);
27
+ ```
28
+
29
+ Expected output:
30
+
31
+ ```text
32
+ [ 'echo' ]
33
+ false {
34
+ "echoed": "hi"
35
+ }
36
+ ```
37
+
38
+ Used by [`@claude-flow/cli`](https://www.npmjs.com/package/@claude-flow/cli), which serves the Ruflo tools over this server.
39
+ <!-- adr-356:quickstart:end -->
40
+
3
41
  [![npm version](https://img.shields.io/npm/v/@claude-flow/mcp.svg)](https://www.npmjs.com/package/@claude-flow/mcp)
4
42
  [![npm downloads](https://img.shields.io/npm/dm/@claude-flow/mcp.svg)](https://www.npmjs.com/package/@claude-flow/mcp)
5
43
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -427,3 +465,9 @@ const ErrorCodes = {
427
465
  ## License
428
466
 
429
467
  MIT
468
+
469
+ <!-- adr-356:footer:start -->
470
+ ---
471
+
472
+ Built by [rUv](https://ruv.io) · [ruv.io](https://ruv.io) · [Source](https://github.com/ruvnet/ruflo/tree/main/v3/@claude-flow/mcp)
473
+ <!-- adr-356:footer:end -->
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/mcp",
3
- "version": "3.1.6",
3
+ "version": "3.1.7",
4
4
  "type": "module",
5
5
  "description": "Standalone MCP (Model Context Protocol) server - stdio/http/websocket transports, connection pooling, tool registry",
6
6
  "main": "dist/index.js",
@@ -25,8 +25,11 @@
25
25
  "vitest": "^4.1.0"
26
26
  },
27
27
  "keywords": [
28
+ "ruflo",
29
+ "claude-flow",
28
30
  "mcp",
29
31
  "model-context-protocol",
32
+ "mcp-server",
30
33
  "claude",
31
34
  "ai-agents",
32
35
  "json-rpc",
@@ -37,16 +40,25 @@
37
40
  "publishConfig": {
38
41
  "access": "public"
39
42
  },
43
+ "homepage": "https://ruv.io",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/ruvnet/ruflo.git",
47
+ "directory": "v3/@claude-flow/mcp"
48
+ },
49
+ "bugs": {
50
+ "url": "https://github.com/ruvnet/ruflo/issues"
51
+ },
40
52
  "rufloBundledRuntime": {
41
53
  "format": 1,
42
54
  "sourceDependencies": {
43
55
  "dependencies": {
44
- "ajv": "^8.12.0",
56
+ "ajv": "^8.20.0",
45
57
  "cors": "^2.8.5",
46
- "express": "^4.18.2",
58
+ "express": "^4.22.3",
47
59
  "express-rate-limit": "^8.4.1",
48
60
  "helmet": "^7.1.0",
49
- "ws": "^8.14.2"
61
+ "ws": "^8.21.0"
50
62
  }
51
63
  }
52
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.74.1",
3
+ "version": "3.75.0",
4
4
  "workspaces": [
5
5
  "v3/@claude-flow/codex",
6
6
  "v3/@claude-flow/mcp",
@@ -69,9 +69,9 @@
69
69
  "v3:security": "npm run security:audit && npm run security:test"
70
70
  },
71
71
  "dependencies": {
72
- "@claude-flow/cli-core": "3.7.6",
73
- "@claude-flow/codex": "3.0.6",
74
- "@claude-flow/mcp": "3.1.6",
72
+ "@claude-flow/cli-core": "3.7.7",
73
+ "@claude-flow/codex": "3.0.8",
74
+ "@claude-flow/mcp": "3.1.7",
75
75
  "@claude-flow/neural": "3.0.3",
76
76
  "@claude-flow/plugin-agent-federation": "1.0.7",
77
77
  "@claude-flow/security": "3.0.7",
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "generation": 7,
4
- "generatedAt": "2026-11-09T06:36:19.466Z",
5
- "gitSha": "2d590fc0",
4
+ "generatedAt": "2026-11-10T01:36:54.714Z",
5
+ "gitSha": "745737aa",
6
6
  "catalog": {
7
7
  "agents": 177,
8
- "tools": 451,
8
+ "tools": 458,
9
9
  "skills": 40
10
10
  },
11
11
  "benchmark": null
@@ -14,10 +14,19 @@ import { createRequire } from 'node:module';
14
14
  import { pathToFileURL } from 'node:url';
15
15
  import { homedir } from 'node:os';
16
16
  import { writeFileAtomic } from './fs-secure.js';
17
+ import { getProjectRoot } from './services/project-root.js';
17
18
  // ── Constants ─────────────────────────────────────────────────
18
19
  export const STATE_DIR = '.claude-flow/data';
19
20
  export const STATE_FILE = `${STATE_DIR}/autopilot-state.json`;
20
21
  export const LOG_FILE = `${STATE_DIR}/autopilot-log.json`;
22
+ /**
23
+ * #2633: resolve a state path against the Ruflo project root, not raw
24
+ * process.cwd(). The constants above stay relative; resolution happens per
25
+ * call so a drifted agent shell still finds the project's state.
26
+ */
27
+ function statePath(rel) {
28
+ return resolve(getProjectRoot(), rel);
29
+ }
21
30
  /** Maximum entries kept in state.history (prevents unbounded growth) */
22
31
  const MAX_HISTORY_ENTRIES = 50;
23
32
  /** Maximum entries kept in the event log */
@@ -107,7 +116,7 @@ export function getDefaultState() {
107
116
  };
108
117
  }
109
118
  export function loadState() {
110
- const filePath = resolve(STATE_FILE);
119
+ const filePath = statePath(STATE_FILE);
111
120
  const defaults = getDefaultState();
112
121
  try {
113
122
  if (existsSync(filePath)) {
@@ -131,7 +140,7 @@ export function loadState() {
131
140
  return defaults;
132
141
  }
133
142
  export function saveState(state) {
134
- const dir = resolve(STATE_DIR);
143
+ const dir = statePath(STATE_DIR);
135
144
  if (!existsSync(dir))
136
145
  mkdirSync(dir, { recursive: true });
137
146
  // Cap history before saving
@@ -143,7 +152,7 @@ export function saveState(state) {
143
152
  // calls can no longer collide on a shared `.tmp` basename and race one
144
153
  // another's renameSync into ENOENT. Related to but distinct from #1637.
145
154
  try {
146
- writeFileAtomic(resolve(STATE_FILE), Buffer.from(JSON.stringify(state, null, 2)));
155
+ writeFileAtomic(statePath(STATE_FILE), Buffer.from(JSON.stringify(state, null, 2)));
147
156
  }
148
157
  catch {
149
158
  // A losing concurrent writer may briefly see ENOENT/EEXIST — the winning
@@ -152,8 +161,8 @@ export function saveState(state) {
152
161
  }
153
162
  }
154
163
  export function appendLog(entry) {
155
- const filePath = resolve(LOG_FILE);
156
- const dir = resolve(STATE_DIR);
164
+ const filePath = statePath(LOG_FILE);
165
+ const dir = statePath(STATE_DIR);
157
166
  if (!existsSync(dir))
158
167
  mkdirSync(dir, { recursive: true });
159
168
  let log = [];
@@ -182,7 +191,7 @@ export function appendLog(entry) {
182
191
  }
183
192
  }
184
193
  export function loadLog() {
185
- const filePath = resolve(LOG_FILE);
194
+ const filePath = statePath(LOG_FILE);
186
195
  try {
187
196
  if (existsSync(filePath)) {
188
197
  const result = safeJsonParse(readFileSync(filePath, 'utf-8'));
@@ -228,7 +237,7 @@ export function discoverTasks(sources) {
228
237
  catch { /* skip source */ }
229
238
  }
230
239
  if (source === 'swarm-tasks') {
231
- const swarmFile = resolve('.claude-flow/swarm-tasks.json');
240
+ const swarmFile = statePath('.claude-flow/swarm-tasks.json');
232
241
  try {
233
242
  if (existsSync(swarmFile)) {
234
243
  const data = safeJsonParse(readFileSync(swarmFile, 'utf-8'));
@@ -249,7 +258,7 @@ export function discoverTasks(sources) {
249
258
  catch { /* skip source */ }
250
259
  }
251
260
  if (source === 'file-checklist') {
252
- const checklistFile = resolve('.claude-flow/data/checklist.json');
261
+ const checklistFile = statePath('.claude-flow/data/checklist.json');
253
262
  try {
254
263
  if (existsSync(checklistFile)) {
255
264
  const data = safeJsonParse(readFileSync(checklistFile, 'utf-8'));
@@ -9,6 +9,7 @@ import { wasmSubcommands } from './agent-wasm.js';
9
9
  import { agentPublishCommand } from './agntcy/publish.js';
10
10
  import * as fs from 'fs';
11
11
  import * as path from 'path';
12
+ import { getProjectRoot } from '../services/project-root.js';
12
13
  import { noteFirstAgentRun } from '../funnel/activation.js';
13
14
  /**
14
15
  * Update swarm-activity.json metrics after agent count changes.
@@ -16,7 +17,7 @@ import { noteFirstAgentRun } from '../funnel/activation.js';
16
17
  */
17
18
  function updateSwarmActivityMetrics(agentCountDelta) {
18
19
  try {
19
- const metricsDir = path.join(process.cwd(), '.claude-flow', 'metrics');
20
+ const metricsDir = path.join(getProjectRoot(), '.claude-flow', 'metrics');
20
21
  const activityPath = path.join(metricsDir, 'swarm-activity.json');
21
22
  let data = {
22
23
  timestamp: new Date().toISOString(),
@@ -7,7 +7,7 @@ import { confirm, select, multiSelect, input } from '../prompt.js';
7
7
  import * as fs from 'fs';
8
8
  import * as path from 'path';
9
9
  import { spawnSync } from 'node:child_process';
10
- import { executeInit, executeUpgrade, executeUpgradeWithMissing, DEFAULT_INIT_OPTIONS, MINIMAL_INIT_OPTIONS, FULL_INIT_OPTIONS, } from '../init/index.js';
10
+ import { executeInit, executeUpgrade, executeUpgradeWithMissing, DEFAULT_INIT_OPTIONS, MINIMAL_INIT_OPTIONS, FULL_INIT_OPTIONS, finalizeDualInstructions, formatPluginDedupSummary, } from '../init/index.js';
11
11
  import { executeGrokInit } from '../init/grok-generator.js';
12
12
  import { ENROLLMENT_SCREEN, recordEnrollmentOutcome, shouldOfferEnrollment, } from '../funnel/enrollment.js';
13
13
  import { commandExists } from '../services/harness-hosts.js';
@@ -539,7 +539,10 @@ async function initCodexAction(ctx, options) {
539
539
  if (!CodexInitializer) {
540
540
  spinner.stop();
541
541
  output.printInfo('Fetching the stable Codex adapter for this initialization...');
542
- const success = runCodexInitializerCli(ctx.cwd, { template, force, dual: dualMode, codexTrust });
542
+ // #2638: never pass --dual to a fetched adapter of unknown version — an
543
+ // older one rewrites CLAUDE.md with its own stub under --force. Without
544
+ // it, finalizeDualInstructions keeps the full CLAUDE.md.
545
+ const success = runCodexInitializerCli(ctx.cwd, { template, force, dual: false, codexTrust });
543
546
  if (!success) {
544
547
  output.printError('Codex initialization failed while running @claude-flow/codex@latest.');
545
548
  return { success: false, exitCode: 1 };
@@ -766,6 +769,10 @@ const initClaudeAction = async (ctx) => {
766
769
  if (noGlobal) {
767
770
  options.skipGlobalClaudeMd = true;
768
771
  }
772
+ // #2638 — set by the --dual route below: CLAUDE.md imports AGENTS.md.
773
+ if (ctx.flags.instructionsSource === 'agents-md') {
774
+ options.instructionsSource = 'agents-md';
775
+ }
769
776
  const riskyMode = riskyModeFromFlags(ctx.flags);
770
777
  if (typeof riskyMode === 'object') {
771
778
  output.printError(riskyMode.error);
@@ -805,6 +812,12 @@ const initClaudeAction = async (ctx) => {
805
812
  }
806
813
  output.printBox(summary.join('\n'), 'Summary');
807
814
  output.writeln();
815
+ // #2640: say what was left to the installed ruflo plugins, and why.
816
+ const pluginLines = result.pluginDedup ? formatPluginDedupSummary(result.pluginDedup) : [];
817
+ if (pluginLines.length > 0) {
818
+ output.printBox(pluginLines.join('\n'), 'Provided by installed plugins');
819
+ output.writeln();
820
+ }
808
821
  // Security: surface anything settings-risk-scanner.ts flagged in a
809
822
  // pre-existing settings.json this init carried forward unexamined.
810
823
  if (result.warnings && result.warnings.length > 0) {
@@ -1013,8 +1026,9 @@ const initClaudeAction = async (ctx) => {
1013
1026
  };
1014
1027
  /**
1015
1028
  * Route platform initialization. Dual mode deliberately runs both native
1016
- * initializers: Claude Code first, then Codex without its compatibility
1017
- * CLAUDE.md stub so the full native Claude scaffold remains authoritative.
1029
+ * initializers: Claude Code first, then Codex. #2638: AGENTS.md carries the
1030
+ * shared instruction sections once and CLAUDE.md imports it (`@AGENTS.md`)
1031
+ * with only the Claude-specific sections; the .claude/ scaffold is unchanged.
1018
1032
  */
1019
1033
  const initAction = async (ctx) => {
1020
1034
  const force = ctx.flags.force;
@@ -1045,6 +1059,8 @@ const initAction = async (ctx) => {
1045
1059
  dual: false,
1046
1060
  // The explicit Codex pass below owns Codex setup.
1047
1061
  'no-codex-detect': true,
1062
+ // #2638 — AGENTS.md owns the shared sections; CLAUDE.md imports it.
1063
+ instructionsSource: 'agents-md',
1048
1064
  },
1049
1065
  };
1050
1066
  const claudeResult = await initClaudeAction(claudeContext);
@@ -1052,12 +1068,18 @@ const initAction = async (ctx) => {
1052
1068
  return claudeResult;
1053
1069
  const codexResult = await initCodexAction(ctx, {
1054
1070
  codexMode: true,
1055
- // Preserve the full CLAUDE.md and .claude/ scaffold just generated.
1056
- dualMode: false,
1071
+ // #2638 — dual AGENTS.md (shared + Codex-only sections). Codex leaves a
1072
+ // CLAUDE.md that already imports AGENTS.md alone.
1073
+ dualMode: true,
1057
1074
  force,
1058
1075
  minimal,
1059
1076
  full,
1060
1077
  });
1078
+ // Keep the @AGENTS.md import only if AGENTS.md really carries the shared
1079
+ // sections; otherwise the full CLAUDE.md is written back.
1080
+ const instructions = finalizeDualInstructions(ctx.cwd, claudeResult.data);
1081
+ if (instructions.action === 'restored' && instructions.message)
1082
+ output.printWarning(instructions.message);
1061
1083
  if (!codexResult.success) {
1062
1084
  return {
1063
1085
  ...codexResult,
@@ -1,4 +1,5 @@
1
1
  import { output } from '../output.js';
2
+ import { anchorToProjectRoot } from '../services/project-root.js';
2
3
  import { backupMemoryDb, backupProjectMemoryDbs } from '../services/memory-backup.js';
3
4
  export const backupCommand = {
4
5
  name: 'backup',
@@ -30,7 +31,7 @@ export const backupCommand = {
30
31
  receipts = [r];
31
32
  }
32
33
  else {
33
- const project = await backupProjectMemoryDbs(ctx.cwd, options);
34
+ const project = await backupProjectMemoryDbs(anchorToProjectRoot(ctx.cwd || process.cwd()), options);
34
35
  r = project;
35
36
  receipts = project.backups;
36
37
  }
@@ -27,6 +27,7 @@
27
27
  import * as fs from 'fs';
28
28
  import * as path from 'path';
29
29
  import { output } from '../output.js';
30
+ import { anchorToProjectRoot } from '../services/project-root.js';
30
31
  import { runDistillationForStores, projectMemoryDbPaths, defaultMemoryDbPath, } from '../services/memory-distillation.js';
31
32
  const DEFAULT_CONFIG = {
32
33
  dryRun: false,
@@ -146,7 +147,7 @@ const runCommand = {
146
147
  const explicitDb = typeof ctx.flags.db === 'string' && ctx.flags.db.trim()
147
148
  ? path.resolve(ctx.flags.db)
148
149
  : undefined;
149
- const dbPaths = explicitDb ? [explicitDb] : projectMemoryDbPaths(ctx.cwd || process.cwd());
150
+ const dbPaths = explicitDb ? [explicitDb] : projectMemoryDbPaths(anchorToProjectRoot(ctx.cwd || process.cwd()));
150
151
  const dbPath = explicitDb ?? dbPaths[0];
151
152
  output.writeln();
152
153
  output.writeln(output.bold('Memory Distillation (ADR-174)'));
@@ -16,7 +16,7 @@ import { MAX_LIST_EMBEDDINGS } from '../memory/embedding-q8.js';
16
16
  import { existsSync } from 'node:fs';
17
17
  import { siblingAgentDbPath } from '../memory/memory-bridge.js';
18
18
  import { validateIdentifier } from '../mcp-tools/validate-input.js';
19
- import { memoryKeyError } from '../mcp-tools/memory-tools.js';
19
+ import { memoryKeyError, MEMORY_SCOPES, resolveScopedNamespace } from '../mcp-tools/memory-tools.js';
20
20
  import { memoryPeek } from '../memory/memory-peek.js';
21
21
  /**
22
22
  * #3228: a miss in one store is not a miss in the memory.
@@ -73,6 +73,31 @@ const DB_PATH_OPTION = {
73
73
  'Precedence: --path > CLAUDE_FLOW_DB_PATH > CLAUDE_FLOW_MEMORY_PATH/memory.db > cwd/.swarm/memory.db',
74
74
  type: 'string',
75
75
  };
76
+ // #1227: AgentMemoryScope flags, shared by store / retrieve / search. Same
77
+ // resolution as the MCP tools: --scope + --agent prefix the namespace as
78
+ // agent-memory:<scope>:<agent>:<namespace>; neither flag → unchanged.
79
+ const SCOPE_OPTIONS = [
80
+ {
81
+ name: 'scope',
82
+ description: 'AgentMemoryScope: project | local | user (requires --agent; #1227)',
83
+ type: 'string',
84
+ choices: [...MEMORY_SCOPES],
85
+ },
86
+ {
87
+ name: 'agent',
88
+ description: 'Agent id whose scoped memory to use (letters, digits, _ and -; requires --scope)',
89
+ type: 'string',
90
+ },
91
+ ];
92
+ /** Resolve --scope/--agent onto a namespace, printing the error on failure. */
93
+ function scopedNamespaceFromFlags(ctx, namespace) {
94
+ const scoped = resolveScopedNamespace({ scope: ctx.flags.scope, agentId: ctx.flags.agent, namespace });
95
+ if (!scoped.ok) {
96
+ output.printError(scoped.error);
97
+ return null;
98
+ }
99
+ return scoped.namespace;
100
+ }
76
101
  // Store command
77
102
  const storeCommand = {
78
103
  name: 'store',
@@ -151,10 +176,12 @@ const storeCommand = {
151
176
  type: 'string',
152
177
  choices: ['user_claim', 'agent_output', 'system_observation', 'tool_result', 'unknown'],
153
178
  },
179
+ ...SCOPE_OPTIONS,
154
180
  DB_PATH_OPTION
155
181
  ],
156
182
  examples: [
157
183
  { command: 'claude-flow memory store -k "api/auth" -v "JWT implementation"', description: 'Store text' },
184
+ { command: 'claude-flow memory store -k "style" -v "tabs" --scope local --agent coder', description: 'Store in the local scope of agent "coder" (#1227)' },
158
185
  { command: 'claude-flow memory store -k "pattern/singleton" --vector', description: 'Store vector' },
159
186
  { command: 'claude-flow memory store -k "pattern" -v "new" --no-upsert', description: 'Strict insert (fail if key exists)' },
160
187
  { command: 'claude-flow memory store -k "user/goal" -v "ship by Friday" --provenance user_claim', description: 'Store with typed provenance (ADR-323)' }
@@ -164,7 +191,10 @@ const storeCommand = {
164
191
  let value = ctx.flags.value || ctx.args[0];
165
192
  // #2461: without `|| 'default'`, omitting -n stores under the literal
166
193
  // string namespace "undefined" — silent data loss for first-time users.
167
- const namespace = ctx.flags.namespace || 'default';
194
+ // #1227: --scope/--agent move the write into that scope's partition.
195
+ const namespace = scopedNamespaceFromFlags(ctx, ctx.flags.namespace || 'default');
196
+ if (namespace === null)
197
+ return { success: false, exitCode: 1 };
168
198
  const ttl = ctx.flags.ttl;
169
199
  const tags = ctx.flags.tags ? ctx.flags.tags.split(',') : [];
170
200
  const asVector = ctx.flags.vector;
@@ -333,13 +363,17 @@ const retrieveCommand = {
333
363
  type: 'boolean',
334
364
  default: false
335
365
  },
366
+ ...SCOPE_OPTIONS,
336
367
  DB_PATH_OPTION
337
368
  ],
338
369
  action: async (ctx) => {
339
370
  const key = ctx.flags.key || ctx.args[0];
340
371
  // #2461: mirror the store-side default so `memory retrieve -k k` (no -n)
341
372
  // looks under "default" rather than the literal namespace "undefined".
342
- const namespace = ctx.flags.namespace || 'default';
373
+ // #1227: --scope/--agent read only that scope's partition.
374
+ const namespace = scopedNamespaceFromFlags(ctx, ctx.flags.namespace || 'default');
375
+ if (namespace === null)
376
+ return { success: false, exitCode: 1 };
343
377
  if (!key) {
344
378
  output.printError('Key is required');
345
379
  return { success: false, exitCode: 1 };
@@ -476,6 +510,7 @@ const searchCommand = {
476
510
  description: 'Comma-separated provenance types to restrict results to: user_claim,agent_output,system_observation,tool_result,unknown — ADR-323',
477
511
  type: 'string',
478
512
  },
513
+ ...SCOPE_OPTIONS,
479
514
  DB_PATH_OPTION
480
515
  ],
481
516
  examples: [
@@ -512,6 +547,15 @@ const searchCommand = {
512
547
  output.printError('Query is required. Use --query or -q');
513
548
  return { success: false, exitCode: 1 };
514
549
  }
550
+ // #1227: with --scope/--agent the search stays inside that scope; an
551
+ // omitted --namespace there means the scope's "default", matching store
552
+ // and retrieve. Without them nothing changes (omitted → every namespace).
553
+ if (ctx.flags.scope !== undefined || ctx.flags.agent !== undefined) {
554
+ const scopedNs = scopedNamespaceFromFlags(ctx, ctx.flags.namespace || 'default');
555
+ if (scopedNs === null)
556
+ return { success: false, exitCode: 1 };
557
+ namespace = scopedNs;
558
+ }
515
559
  // #2760 SCM routed memory (v1 MVP) — classify query intent and
516
560
  // print a routing hint. Only fires when --intent is NOT the default
517
561
  // "mixed" AND --namespace was NOT explicitly passed. Intentionally
@@ -5,6 +5,7 @@
5
5
  * Created with ❤️ by ruv.io
6
6
  */
7
7
  import { output } from '../output.js';
8
+ import { getProjectRoot } from '../services/project-root.js';
8
9
  // Train subcommand - REAL WASM training with RuVector
9
10
  const trainCommand = {
10
11
  name: 'train',
@@ -227,7 +228,7 @@ const trainCommand = {
227
228
  dim,
228
229
  validationSplit: valSplit,
229
230
  resumeFrom: resumePath,
230
- checkpointPath: path.join(process.cwd(), '.claude-flow', 'neural', `lora-checkpoint-${Date.now()}.json`),
231
+ checkpointPath: path.join(getProjectRoot(), '.claude-flow', 'neural', `lora-checkpoint-${Date.now()}.json`),
231
232
  });
232
233
  }
233
234
  catch (err) {
@@ -331,7 +332,7 @@ const trainCommand = {
331
332
  try {
332
333
  const { LoRAAdapter } = await import('../ruvector/lora-adapter.js');
333
334
  const path = await import('path');
334
- const cpDir = path.join(process.cwd(), '.claude-flow', 'neural');
335
+ const cpDir = path.join(getProjectRoot(), '.claude-flow', 'neural');
335
336
  const cpPath = path.join(cpDir, `lora-checkpoint-${Date.now()}.json`);
336
337
  const adapter = new LoRAAdapter({ inputDim: dim, outputDim: dim, rank: 4 });
337
338
  await adapter.initBackend();
@@ -862,7 +863,7 @@ const optimizeCommand = {
862
863
  }
863
864
  catch { /* background learning is best-effort */ }
864
865
  // Get actual pattern storage size
865
- const patternDir = path.join(process.cwd(), '.claude-flow', 'neural');
866
+ const patternDir = path.join(getProjectRoot(), '.claude-flow', 'neural');
866
867
  let beforeSize = 0;
867
868
  try {
868
869
  const patternFile = path.join(patternDir, 'patterns.json');
@@ -1060,7 +1061,7 @@ const exportCommand = {
1060
1061
  },
1061
1062
  };
1062
1063
  // Load patterns from local storage
1063
- const memoryDir = path.join(process.cwd(), '.claude-flow', 'memory');
1064
+ const memoryDir = path.join(getProjectRoot(), '.claude-flow', 'memory');
1064
1065
  const patternsFile = path.join(memoryDir, 'patterns.json');
1065
1066
  if (fs.existsSync(patternsFile)) {
1066
1067
  const patterns = JSON.parse(fs.readFileSync(patternsFile, 'utf8'));
@@ -1453,7 +1454,7 @@ const importCommand = {
1453
1454
  output.writeln(output.warning(`Filtered ${patterns.length - validPatterns.length} suspicious patterns`));
1454
1455
  }
1455
1456
  // Save to local memory
1456
- const memoryDir = path.join(process.cwd(), '.claude-flow', 'memory');
1457
+ const memoryDir = path.join(getProjectRoot(), '.claude-flow', 'memory');
1457
1458
  if (!fs.existsSync(memoryDir)) {
1458
1459
  fs.mkdirSync(memoryDir, { recursive: true });
1459
1460
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `ruflo plugins host <action>` — dual-host (Claude Code + Codex) installer for
3
+ * Ruflo marketplace plugins (#2854). Every host mutation goes through that
4
+ * host's own plugin CLI via HostPluginManager (literal argv, no shell).
5
+ */
6
+ import type { Command } from '../types.js';
7
+ import { HostPluginManager } from '../services/host-plugin-manager.js';
8
+ /** Exposed for tests: lets them inject a manager wired to fake host CLIs. */
9
+ export declare const hostCommandRuntime: {
10
+ createManager: () => HostPluginManager;
11
+ };
12
+ export declare const hostCommand: Command;
13
+ //# sourceMappingURL=plugins-host.d.ts.map