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.
- package/.claude/helpers/auto-memory-hook.mjs +262 -81
- package/node_modules/@claude-flow/codex/README.md +38 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts.map +1 -1
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.js +4 -4
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.js.map +1 -1
- package/node_modules/@claude-flow/codex/dist/generators/dual-instructions.d.ts +20 -0
- package/node_modules/@claude-flow/codex/dist/generators/dual-instructions.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/dual-instructions.js +104 -0
- package/node_modules/@claude-flow/codex/dist/generators/dual-instructions.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.d.ts +2 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.d.ts.map +1 -1
- package/node_modules/@claude-flow/codex/dist/generators/index.js +2 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.js.map +1 -1
- package/node_modules/@claude-flow/codex/dist/generators/shared-instructions.d.ts +46 -0
- package/node_modules/@claude-flow/codex/dist/generators/shared-instructions.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/shared-instructions.js +162 -0
- package/node_modules/@claude-flow/codex/dist/generators/shared-instructions.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/index.d.ts +3 -3
- package/node_modules/@claude-flow/codex/dist/index.js +1 -1
- package/node_modules/@claude-flow/codex/dist/initializer.d.ts.map +1 -1
- package/node_modules/@claude-flow/codex/dist/initializer.js +16 -93
- package/node_modules/@claude-flow/codex/dist/initializer.js.map +1 -1
- package/node_modules/@claude-flow/codex/package.json +8 -6
- package/node_modules/@claude-flow/mcp/README.md +44 -0
- package/node_modules/@claude-flow/mcp/package.json +16 -4
- package/package.json +4 -4
- package/v3/@claude-flow/cli/catalog-manifest.json +3 -3
- package/v3/@claude-flow/cli/dist/src/autopilot-state.js +17 -8
- package/v3/@claude-flow/cli/dist/src/commands/agent.js +2 -1
- package/v3/@claude-flow/cli/dist/src/commands/init.js +28 -6
- package/v3/@claude-flow/cli/dist/src/commands/memory-backup.js +2 -1
- package/v3/@claude-flow/cli/dist/src/commands/memory-distill.js +2 -1
- package/v3/@claude-flow/cli/dist/src/commands/memory.js +47 -3
- package/v3/@claude-flow/cli/dist/src/commands/neural.js +6 -5
- package/v3/@claude-flow/cli/dist/src/commands/plugins-host.d.ts +13 -0
- package/v3/@claude-flow/cli/dist/src/commands/plugins-host.js +161 -0
- package/v3/@claude-flow/cli/dist/src/commands/plugins.js +3 -1
- package/v3/@claude-flow/cli/dist/src/commands/start-all.d.ts +28 -0
- package/v3/@claude-flow/cli/dist/src/commands/start-all.js +99 -0
- package/v3/@claude-flow/cli/dist/src/commands/start.d.ts +5 -1
- package/v3/@claude-flow/cli/dist/src/commands/start.js +17 -10
- package/v3/@claude-flow/cli/dist/src/commands/swarm.js +2 -1
- package/v3/@claude-flow/cli/dist/src/fs-secure.js +9 -2
- package/v3/@claude-flow/cli/dist/src/init/claudemd-generator.d.ts +15 -0
- package/v3/@claude-flow/cli/dist/src/init/claudemd-generator.js +64 -114
- package/v3/@claude-flow/cli/dist/src/init/dual-instructions.d.ts +29 -0
- package/v3/@claude-flow/cli/dist/src/init/dual-instructions.js +87 -0
- package/v3/@claude-flow/cli/dist/src/init/executor.js +96 -13
- package/v3/@claude-flow/cli/dist/src/init/index.d.ts +3 -1
- package/v3/@claude-flow/cli/dist/src/init/index.js +5 -1
- package/v3/@claude-flow/cli/dist/src/init/plugin-dedup.d.ts +61 -0
- package/v3/@claude-flow/cli/dist/src/init/plugin-dedup.js +130 -0
- package/v3/@claude-flow/cli/dist/src/init/shared-instructions.d.ts +46 -0
- package/v3/@claude-flow/cli/dist/src/init/shared-instructions.js +162 -0
- package/v3/@claude-flow/cli/dist/src/init/types.d.ts +33 -0
- package/v3/@claude-flow/cli/dist/src/init/types.js +3 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-tools.d.ts +14 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-tools.js +48 -5
- package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-hierarchical-inventory-tools.d.ts +15 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-hierarchical-inventory-tools.js +115 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-inventory-tools.d.ts +21 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-inventory-tools.js +152 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-tools.js +56 -7
- package/v3/@claude-flow/cli/dist/src/mcp-tools/aidefence-known-misses.d.ts +6 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/aidefence-known-misses.js +23 -5
- package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +21 -3
- package/v3/@claude-flow/cli/dist/src/mcp-tools/memory-tools.d.ts +29 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/memory-tools.js +239 -19
- package/v3/@claude-flow/cli/dist/src/mcp-tools/security-tools.js +53 -5
- package/v3/@claude-flow/cli/dist/src/memory/embedding-config.d.ts +79 -0
- package/v3/@claude-flow/cli/dist/src/memory/embedding-config.js +250 -0
- package/v3/@claude-flow/cli/dist/src/memory/ewc-consolidation.js +2 -1
- package/v3/@claude-flow/cli/dist/src/memory/intelligence.d.ts +28 -2
- package/v3/@claude-flow/cli/dist/src/memory/intelligence.js +37 -7
- package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.d.ts +42 -0
- package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.js +267 -28
- package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.d.ts +1 -1
- package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.js +47 -22
- package/v3/@claude-flow/cli/dist/src/ruvector/lora-adapter.js +3 -2
- package/v3/@claude-flow/cli/dist/src/ruvector/task-embedder.d.ts +2 -1
- package/v3/@claude-flow/cli/dist/src/ruvector/task-embedder.js +7 -3
- package/v3/@claude-flow/cli/dist/src/services/daemon-autostart.d.ts +4 -6
- package/v3/@claude-flow/cli/dist/src/services/daemon-autostart.js +6 -46
- package/v3/@claude-flow/cli/dist/src/services/host-executable.d.ts +68 -0
- package/v3/@claude-flow/cli/dist/src/services/host-executable.js +175 -0
- package/v3/@claude-flow/cli/dist/src/services/host-plugin-manager.d.ts +137 -0
- package/v3/@claude-flow/cli/dist/src/services/host-plugin-manager.js +374 -0
- package/v3/@claude-flow/cli/dist/src/services/project-root.d.ts +37 -0
- package/v3/@claude-flow/cli/dist/src/services/project-root.js +122 -0
- package/v3/@claude-flow/cli/package.json +7 -7
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dual-host marketplace plugin manager (#2854).
|
|
3
|
+
*
|
|
4
|
+
* Claude Code and Codex keep separate plugin registries. This service drives
|
|
5
|
+
* each host's own plugin CLI (never its caches) with a literal argv, so one
|
|
6
|
+
* `ruflo plugins host ...` call can apply the same state to both.
|
|
7
|
+
*
|
|
8
|
+
* Results are reported per host and per plugin. A failure on one host never
|
|
9
|
+
* hides the other's outcome, and `ok` is false if any requested host failed.
|
|
10
|
+
*
|
|
11
|
+
* `sync` policy (documented choice): the target enabled set is the UNION of
|
|
12
|
+
* the plugins enabled in either host. It is additive: a plugin missing from a
|
|
13
|
+
* host is installed there; nothing is ever removed; a plugin a host has
|
|
14
|
+
* installed but explicitly disabled is left disabled and reported.
|
|
15
|
+
*/
|
|
16
|
+
import { HOST_IDS, defaultHostSystemDeps, formatArgv, resolveHostExecutable, runHostArgv, } from './host-executable.js';
|
|
17
|
+
export * from './host-executable.js';
|
|
18
|
+
export const DEFAULT_MARKETPLACE_SOURCE = 'ruvnet/ruflo';
|
|
19
|
+
export const DEFAULT_MARKETPLACE_NAME = 'ruflo';
|
|
20
|
+
/** Lowercase kebab-case, as the Ruflo marketplace names its plugins. No leading `-`, no shell bytes. */
|
|
21
|
+
const PLUGIN_NAME_RE = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
22
|
+
const MARKETPLACE_NAME_RE = /^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$/;
|
|
23
|
+
const MARKETPLACE_SOURCE_RE = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,99}\/[A-Za-z0-9][A-Za-z0-9_.-]{0,99}$/;
|
|
24
|
+
export class HostPluginInputError extends Error {
|
|
25
|
+
}
|
|
26
|
+
/** Validate a plugin name (or `name@<marketplace>`) before it can reach an argv. */
|
|
27
|
+
export function validatePluginName(raw, marketplaceName = DEFAULT_MARKETPLACE_NAME) {
|
|
28
|
+
const at = raw.indexOf('@');
|
|
29
|
+
const name = at === -1 ? raw : raw.slice(0, at);
|
|
30
|
+
if (at !== -1 && raw.slice(at + 1) !== marketplaceName) {
|
|
31
|
+
throw new HostPluginInputError(`plugin "${raw}" is not from the ${marketplaceName} marketplace`);
|
|
32
|
+
}
|
|
33
|
+
if (!PLUGIN_NAME_RE.test(name) || name.includes('--')) {
|
|
34
|
+
throw new HostPluginInputError(`invalid plugin name ${JSON.stringify(raw)}: expected lowercase letters, digits and single hyphens`);
|
|
35
|
+
}
|
|
36
|
+
return name;
|
|
37
|
+
}
|
|
38
|
+
export function validateMarketplace(source, name) {
|
|
39
|
+
if (!MARKETPLACE_SOURCE_RE.test(source) || source.includes('..')) {
|
|
40
|
+
throw new HostPluginInputError(`invalid marketplace ${JSON.stringify(source)}: expected owner/repo`);
|
|
41
|
+
}
|
|
42
|
+
if (!MARKETPLACE_NAME_RE.test(name)) {
|
|
43
|
+
throw new HostPluginInputError(`invalid marketplace name ${JSON.stringify(name)}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Pure argv builder for a plugin action on one host. */
|
|
47
|
+
export function buildActionArgv(host, action, plugin, scope, mp) {
|
|
48
|
+
const id = `${plugin}@${mp.name}`;
|
|
49
|
+
if (host === 'claude') {
|
|
50
|
+
const steps = [];
|
|
51
|
+
if (action === 'update')
|
|
52
|
+
steps.push({ argv: ['plugin', 'marketplace', 'update', mp.name], purpose: 'refresh marketplace' });
|
|
53
|
+
steps.push({ argv: ['plugin', action, id, '--scope', scope], purpose: `${action} ${id}` });
|
|
54
|
+
return { supported: true, steps };
|
|
55
|
+
}
|
|
56
|
+
if (scope !== 'user') {
|
|
57
|
+
return {
|
|
58
|
+
supported: false,
|
|
59
|
+
reason: `Codex plugins are user-global; scope "${scope}" cannot be represented (refusing to widen it)`,
|
|
60
|
+
manual: `codex plugin add ${id} # only if you want it user-global`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
switch (action) {
|
|
64
|
+
case 'install':
|
|
65
|
+
return { supported: true, steps: [{ argv: ['plugin', 'add', id, '--json'], purpose: `install ${id}` }] };
|
|
66
|
+
case 'uninstall':
|
|
67
|
+
return { supported: true, steps: [{ argv: ['plugin', 'remove', id, '--json'], purpose: `uninstall ${id}` }] };
|
|
68
|
+
case 'update':
|
|
69
|
+
// Codex has no `plugin update`: refresh the marketplace snapshot, then re-add.
|
|
70
|
+
return {
|
|
71
|
+
supported: true,
|
|
72
|
+
steps: [
|
|
73
|
+
{ argv: ['plugin', 'marketplace', 'upgrade', mp.name], purpose: 'refresh marketplace' },
|
|
74
|
+
{ argv: ['plugin', 'add', id, '--json'], purpose: `reinstall ${id} from refreshed snapshot` },
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
default:
|
|
78
|
+
// Verified against codex-cli 0.165.0: `codex plugin` has only add|list|marketplace|remove.
|
|
79
|
+
return {
|
|
80
|
+
supported: false,
|
|
81
|
+
reason: `codex plugin has no ${action} command`,
|
|
82
|
+
manual: `set \`enabled = ${action === 'enable'}\` under [plugins."${id}"] in ~/.codex/config.toml`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export function buildMarketplaceArgv(host, op, mp) {
|
|
87
|
+
if (op === 'add')
|
|
88
|
+
return ['plugin', 'marketplace', 'add', mp.source];
|
|
89
|
+
return host === 'claude'
|
|
90
|
+
? ['plugin', 'marketplace', 'update', mp.name]
|
|
91
|
+
: ['plugin', 'marketplace', 'upgrade', mp.name];
|
|
92
|
+
}
|
|
93
|
+
export function buildListArgv(kind) {
|
|
94
|
+
return kind === 'plugins' ? ['plugin', 'list', '--json'] : ['plugin', 'marketplace', 'list', '--json'];
|
|
95
|
+
}
|
|
96
|
+
/** github repo / git URL / local path → comparable form (`owner/repo` or `dir:<path>`). */
|
|
97
|
+
export function normalizeMarketplaceSource(raw) {
|
|
98
|
+
const m = /^(?:https?:\/\/|git@)github\.com[/:]([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(raw.trim());
|
|
99
|
+
if (m)
|
|
100
|
+
return `${m[1]}/${m[2]}`.toLowerCase();
|
|
101
|
+
if (MARKETPLACE_SOURCE_RE.test(raw))
|
|
102
|
+
return raw.toLowerCase();
|
|
103
|
+
return `dir:${raw}`;
|
|
104
|
+
}
|
|
105
|
+
/** Parse `<host> plugin list --json` + `<host> plugin marketplace list --json`. */
|
|
106
|
+
export function parseHostState(host, pluginsJson, marketplacesJson, mp, scope, cwd) {
|
|
107
|
+
const plugins = new Map();
|
|
108
|
+
const suffix = `@${mp.name}`;
|
|
109
|
+
let marketplaceSource = null;
|
|
110
|
+
if (host === 'claude') {
|
|
111
|
+
const rows = JSON.parse(pluginsJson);
|
|
112
|
+
for (const r of Array.isArray(rows) ? rows : []) {
|
|
113
|
+
const id = String(r.id ?? '');
|
|
114
|
+
if (!id.endsWith(suffix) || r.scope !== scope)
|
|
115
|
+
continue;
|
|
116
|
+
if (scope !== 'user' && typeof r.projectPath === 'string' && r.projectPath !== cwd)
|
|
117
|
+
continue;
|
|
118
|
+
plugins.set(id.slice(0, -suffix.length), { version: String(r.version ?? 'unknown'), enabled: r.enabled !== false });
|
|
119
|
+
}
|
|
120
|
+
const mps = JSON.parse(marketplacesJson);
|
|
121
|
+
const own = (Array.isArray(mps) ? mps : []).find((m) => m.name === mp.name);
|
|
122
|
+
if (own)
|
|
123
|
+
marketplaceSource = normalizeMarketplaceSource(String(own.repo ?? own.url ?? own.path ?? ''));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
const doc = JSON.parse(pluginsJson);
|
|
127
|
+
for (const r of doc.installed ?? []) {
|
|
128
|
+
if (r.marketplaceName !== mp.name || r.installed === false)
|
|
129
|
+
continue;
|
|
130
|
+
plugins.set(String(r.name), { version: String(r.version ?? 'unknown'), enabled: r.enabled !== false });
|
|
131
|
+
}
|
|
132
|
+
const mdoc = JSON.parse(marketplacesJson);
|
|
133
|
+
const own = (mdoc.marketplaces ?? []).find((m) => m.name === mp.name);
|
|
134
|
+
if (own) {
|
|
135
|
+
const src = own.marketplaceSource;
|
|
136
|
+
marketplaceSource = normalizeMarketplaceSource(String(src?.source ?? own.root ?? ''));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return { plugins, marketplaceSource };
|
|
140
|
+
}
|
|
141
|
+
const FAILING = new Set(['failed', 'unsupported', 'refused']);
|
|
142
|
+
/** `not-detected` counts as a failure only when that host was explicitly requested. */
|
|
143
|
+
function summarize(action, dryRun, results, required) {
|
|
144
|
+
const ok = results.every((r) => !FAILING.has(r.outcome) && !(r.outcome === 'not-detected' && required.has(r.host)));
|
|
145
|
+
return { action, dryRun, ok, results };
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Pure sync planner. Marketplace first (add when absent, refresh when it is
|
|
149
|
+
* the canonical source, refuse a foreign source), then union-of-enabled installs.
|
|
150
|
+
*/
|
|
151
|
+
export function planSync(states, mp) {
|
|
152
|
+
const plan = [];
|
|
153
|
+
const canonical = normalizeMarketplaceSource(mp.source);
|
|
154
|
+
for (const host of HOST_IDS) {
|
|
155
|
+
const src = states[host].marketplaceSource;
|
|
156
|
+
if (src === null)
|
|
157
|
+
plan.push({ host, target: '(marketplace)', argv: buildMarketplaceArgv(host, 'add', mp), note: 'add marketplace' });
|
|
158
|
+
else if (src === canonical)
|
|
159
|
+
plan.push({ host, target: '(marketplace)', argv: buildMarketplaceArgv(host, 'update', mp), note: 'refresh marketplace' });
|
|
160
|
+
else
|
|
161
|
+
plan.push({ host, target: '(marketplace)', argv: null, note: `refused: "${mp.name}" is registered from ${src}, not ${canonical}` });
|
|
162
|
+
}
|
|
163
|
+
const union = new Set();
|
|
164
|
+
for (const host of HOST_IDS)
|
|
165
|
+
for (const [name, s] of states[host].plugins)
|
|
166
|
+
if (s.enabled)
|
|
167
|
+
union.add(name);
|
|
168
|
+
for (const name of [...union].sort()) {
|
|
169
|
+
for (const host of HOST_IDS) {
|
|
170
|
+
const have = states[host].plugins.get(name);
|
|
171
|
+
if (!have) {
|
|
172
|
+
const built = buildActionArgv(host, 'install', name, 'user', mp);
|
|
173
|
+
plan.push({ host, target: name, argv: built.supported ? built.steps[0].argv : null, note: 'install (enabled in the other host)' });
|
|
174
|
+
}
|
|
175
|
+
else if (!have.enabled) {
|
|
176
|
+
plan.push({ host, target: name, argv: null, note: 'kept disabled (explicitly disabled in this host)' });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return plan;
|
|
181
|
+
}
|
|
182
|
+
export function computeStatus(states) {
|
|
183
|
+
const names = new Set();
|
|
184
|
+
for (const s of Object.values(states))
|
|
185
|
+
for (const n of s.plugins.keys())
|
|
186
|
+
names.add(n);
|
|
187
|
+
return [...names].sort().map((plugin) => {
|
|
188
|
+
const c = states.claude?.plugins.get(plugin) ?? null;
|
|
189
|
+
const x = states.codex?.plugins.get(plugin) ?? null;
|
|
190
|
+
const drift = [];
|
|
191
|
+
if (states.claude && states.codex) {
|
|
192
|
+
if (!c)
|
|
193
|
+
drift.push('missing in claude');
|
|
194
|
+
if (!x)
|
|
195
|
+
drift.push('missing in codex');
|
|
196
|
+
if (c && x && c.version !== x.version)
|
|
197
|
+
drift.push(`version ${c.version} ≠ ${x.version}`);
|
|
198
|
+
if (c && x && c.enabled !== x.enabled)
|
|
199
|
+
drift.push('enabled state differs');
|
|
200
|
+
}
|
|
201
|
+
return { plugin, claude: c, codex: x, drift };
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
export class HostPluginManager {
|
|
205
|
+
deps;
|
|
206
|
+
constructor(deps = defaultHostSystemDeps()) {
|
|
207
|
+
this.deps = deps;
|
|
208
|
+
}
|
|
209
|
+
marketplace(opts) {
|
|
210
|
+
const mp = { source: opts.marketplace?.source ?? DEFAULT_MARKETPLACE_SOURCE, name: opts.marketplace?.name ?? DEFAULT_MARKETPLACE_NAME };
|
|
211
|
+
validateMarketplace(mp.source, mp.name);
|
|
212
|
+
return mp;
|
|
213
|
+
}
|
|
214
|
+
/** Resolve every requested host before anything mutates. */
|
|
215
|
+
async resolveHosts(selection = 'auto') {
|
|
216
|
+
const wanted = selection === 'both' || selection === 'auto' ? [...HOST_IDS] : [selection];
|
|
217
|
+
const required = new Set(selection === 'auto' ? [] : wanted);
|
|
218
|
+
const present = [];
|
|
219
|
+
const missing = [];
|
|
220
|
+
for (const host of wanted) {
|
|
221
|
+
const r = await resolveHostExecutable(host, this.deps);
|
|
222
|
+
if (r.ok)
|
|
223
|
+
present.push(r.invocation);
|
|
224
|
+
else
|
|
225
|
+
missing.push({ host, target: '*', outcome: 'not-detected', steps: [], message: r.reason });
|
|
226
|
+
}
|
|
227
|
+
if (selection === 'auto' && present.length === 0)
|
|
228
|
+
for (const m of missing)
|
|
229
|
+
required.add(m.host);
|
|
230
|
+
return { present, missing, required };
|
|
231
|
+
}
|
|
232
|
+
async readState(inv, mp, scope, cwd) {
|
|
233
|
+
const p = await runHostArgv(inv, buildListArgv('plugins'), this.deps);
|
|
234
|
+
const m = await runHostArgv(inv, buildListArgv('marketplaces'), this.deps);
|
|
235
|
+
if (!p.ok || !m.ok)
|
|
236
|
+
return `could not read ${inv.host} plugin state: ${(p.ok ? m : p).error ?? 'unknown error'}`;
|
|
237
|
+
try {
|
|
238
|
+
return parseHostState(inv.host, p.stdout, m.stdout, mp, scope, cwd);
|
|
239
|
+
}
|
|
240
|
+
catch (e) {
|
|
241
|
+
return `unparseable ${inv.host} plugin list output: ${e.message}`;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
async execSteps(inv, steps, dryRun) {
|
|
245
|
+
const results = [];
|
|
246
|
+
for (const step of steps) {
|
|
247
|
+
const r = { argv: step.argv, display: formatArgv(inv.host, step.argv), purpose: step.purpose };
|
|
248
|
+
results.push(r);
|
|
249
|
+
if (dryRun)
|
|
250
|
+
continue;
|
|
251
|
+
const run = await runHostArgv(inv, step.argv, this.deps);
|
|
252
|
+
r.ok = run.ok;
|
|
253
|
+
if (!run.ok) {
|
|
254
|
+
r.stderr = run.stderr.trim().slice(0, 2000);
|
|
255
|
+
r.error = run.error;
|
|
256
|
+
return { ok: false, results };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return { ok: true, results };
|
|
260
|
+
}
|
|
261
|
+
/** install | update | uninstall | enable | disable on every selected host. */
|
|
262
|
+
async apply(action, rawPlugins, opts = {}) {
|
|
263
|
+
const mp = this.marketplace(opts);
|
|
264
|
+
if (rawPlugins.length === 0)
|
|
265
|
+
throw new HostPluginInputError(`${action} needs at least one plugin name`);
|
|
266
|
+
const plugins = rawPlugins.map((p) => validatePluginName(p, mp.name));
|
|
267
|
+
const scope = opts.scope ?? 'user';
|
|
268
|
+
const dryRun = opts.dryRun === true;
|
|
269
|
+
const { present, missing, required } = await this.resolveHosts(opts.hosts);
|
|
270
|
+
const results = [...missing];
|
|
271
|
+
for (const inv of present) {
|
|
272
|
+
const state = await this.readState(inv, mp, scope, opts.cwd ?? process.cwd());
|
|
273
|
+
if (typeof state !== 'string' && state.marketplaceSource === null && action === 'install') {
|
|
274
|
+
const steps = [{ argv: buildMarketplaceArgv(inv.host, 'add', mp), purpose: 'add marketplace' }];
|
|
275
|
+
const run = await this.execSteps(inv, steps, dryRun);
|
|
276
|
+
results.push({ host: inv.host, target: '(marketplace)', outcome: dryRun ? 'planned' : run.ok ? 'ok' : 'failed', steps: run.results });
|
|
277
|
+
if (!run.ok) {
|
|
278
|
+
for (const p of plugins)
|
|
279
|
+
results.push({ host: inv.host, target: p, outcome: 'failed', steps: [], message: 'marketplace add failed' });
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
for (const plugin of plugins) {
|
|
284
|
+
const built = buildActionArgv(inv.host, action, plugin, scope, mp);
|
|
285
|
+
if (!built.supported) {
|
|
286
|
+
results.push({ host: inv.host, target: plugin, outcome: 'unsupported', steps: [], message: built.reason, manual: built.manual });
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
const have = typeof state === 'string' ? undefined : state.plugins.get(plugin);
|
|
290
|
+
const known = typeof state !== 'string';
|
|
291
|
+
const noop = known && ((action === 'install' && have !== undefined)
|
|
292
|
+
|| (action === 'uninstall' && have === undefined)
|
|
293
|
+
|| (action === 'enable' && have?.enabled === true)
|
|
294
|
+
|| (action === 'disable' && have?.enabled === false));
|
|
295
|
+
if (noop) {
|
|
296
|
+
results.push({ host: inv.host, target: plugin, outcome: 'unchanged', steps: [], message: 'already in the requested state' });
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
const run = await this.execSteps(inv, built.steps, dryRun);
|
|
300
|
+
results.push({
|
|
301
|
+
host: inv.host, target: plugin, steps: run.results,
|
|
302
|
+
outcome: dryRun ? 'planned' : run.ok ? 'ok' : 'failed',
|
|
303
|
+
message: typeof state === 'string' ? state : undefined,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return summarize(action, dryRun, results, required);
|
|
308
|
+
}
|
|
309
|
+
/** Make both hosts match: same marketplace, union of enabled plugins (additive). */
|
|
310
|
+
async sync(opts = {}) {
|
|
311
|
+
const mp = this.marketplace(opts);
|
|
312
|
+
const dryRun = opts.dryRun === true;
|
|
313
|
+
const scope = opts.scope ?? 'user';
|
|
314
|
+
if (scope !== 'user')
|
|
315
|
+
throw new HostPluginInputError('sync only supports --scope user: Codex plugins are user-global');
|
|
316
|
+
const { present, missing } = await this.resolveHosts('both');
|
|
317
|
+
const required = new Set(HOST_IDS);
|
|
318
|
+
if (missing.length > 0)
|
|
319
|
+
return { ...summarize('sync', dryRun, missing, required), plan: [] };
|
|
320
|
+
const states = {};
|
|
321
|
+
const results = [];
|
|
322
|
+
for (const inv of present) {
|
|
323
|
+
const s = await this.readState(inv, mp, scope, opts.cwd ?? process.cwd());
|
|
324
|
+
if (typeof s === 'string')
|
|
325
|
+
results.push({ host: inv.host, target: '*', outcome: 'failed', steps: [], message: s });
|
|
326
|
+
else
|
|
327
|
+
states[inv.host] = s;
|
|
328
|
+
}
|
|
329
|
+
if (results.length > 0)
|
|
330
|
+
return { ...summarize('sync', dryRun, results, required), plan: [] };
|
|
331
|
+
const plan = planSync(states, mp);
|
|
332
|
+
const byHost = new Map(present.map((inv) => [inv.host, inv]));
|
|
333
|
+
const marketFailed = new Set();
|
|
334
|
+
for (const entry of plan) {
|
|
335
|
+
const inv = byHost.get(entry.host);
|
|
336
|
+
if (entry.argv === null) {
|
|
337
|
+
const refused = entry.note.startsWith('refused');
|
|
338
|
+
if (refused)
|
|
339
|
+
marketFailed.add(entry.host);
|
|
340
|
+
results.push({ host: entry.host, target: entry.target, outcome: refused ? 'refused' : 'unchanged', steps: [], message: entry.note });
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
if (entry.target !== '(marketplace)' && marketFailed.has(entry.host) && states[entry.host].marketplaceSource === null) {
|
|
344
|
+
results.push({ host: entry.host, target: entry.target, outcome: 'failed', steps: [], message: 'skipped: marketplace unavailable' });
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
const run = await this.execSteps(inv, [{ argv: entry.argv, purpose: entry.note }], dryRun);
|
|
348
|
+
if (!run.ok && entry.target === '(marketplace)')
|
|
349
|
+
marketFailed.add(entry.host);
|
|
350
|
+
results.push({ host: entry.host, target: entry.target, steps: run.results, outcome: dryRun ? 'planned' : run.ok ? 'ok' : 'failed', message: entry.note });
|
|
351
|
+
}
|
|
352
|
+
return { ...summarize('sync', dryRun, results, required), plan };
|
|
353
|
+
}
|
|
354
|
+
/** Installed version per plugin per host, with drift flags. Read-only. */
|
|
355
|
+
async status(opts = {}) {
|
|
356
|
+
const mp = this.marketplace(opts);
|
|
357
|
+
const { present, missing, required } = await this.resolveHosts(opts.hosts);
|
|
358
|
+
const states = {};
|
|
359
|
+
const hosts = [...missing];
|
|
360
|
+
const marketplaces = {};
|
|
361
|
+
for (const inv of present) {
|
|
362
|
+
const s = await this.readState(inv, mp, opts.scope ?? 'user', opts.cwd ?? process.cwd());
|
|
363
|
+
if (typeof s === 'string')
|
|
364
|
+
hosts.push({ host: inv.host, target: '*', outcome: 'failed', steps: [], message: s });
|
|
365
|
+
else {
|
|
366
|
+
states[inv.host] = s;
|
|
367
|
+
marketplaces[inv.host] = s.marketplaceSource;
|
|
368
|
+
hosts.push({ host: inv.host, target: '*', outcome: 'ok', steps: [], message: inv.resolvedFrom });
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return { ok: summarize('install', false, hosts, required).ok, rows: computeStatus(states), hosts, marketplaces };
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=host-plugin-manager.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return true only when the directory contains a durable Ruflo project marker.
|
|
3
|
+
*
|
|
4
|
+
* A bare `.claude/` is owned by Claude Code, and a bare `.claude-flow/` is not
|
|
5
|
+
* sufficient either: startup-time policy/champion migration can create it
|
|
6
|
+
* before this function runs. Treating that mutation as authorization caused a
|
|
7
|
+
* read-only command in any Claude project to spawn a detached daemon (#2852).
|
|
8
|
+
*/
|
|
9
|
+
export declare function isRufloProject(projectRoot: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Walk up from `startDir` and return the NEAREST enclosing directory carrying
|
|
12
|
+
* a Ruflo marker. Nearest-wins keeps a monorepo's independently-initialized
|
|
13
|
+
* sub-project on its own state.
|
|
14
|
+
*
|
|
15
|
+
* A `.git` entry is a hard stop — the repository boundary. Without it the walk
|
|
16
|
+
* could escape into an unrelated ancestor (a Ruflo project living at `$HOME`,
|
|
17
|
+
* say) and hand every repo below it the same state.
|
|
18
|
+
*
|
|
19
|
+
* Returns the resolved `startDir` unchanged when no marker is found, which
|
|
20
|
+
* preserves the previous cwd-relative behaviour outside a Ruflo project.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveProjectRoot(startDir: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Anchor `dir` to its project root for durable state. Like resolveProjectRoot,
|
|
25
|
+
* but a walk that lands on home or a filesystem root is rejected and `dir` is
|
|
26
|
+
* returned instead — `~/.claude/settings.json` carrying a `claudeFlow` key
|
|
27
|
+
* must not turn $HOME into every non-git directory's project. Mirrors the
|
|
28
|
+
* guard cli-core's getProjectCwd() applies, so CLI commands and MCP tools
|
|
29
|
+
* agree on the root.
|
|
30
|
+
*/
|
|
31
|
+
export declare function anchorToProjectRoot(dir: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* The project root for the current process: anchorToProjectRoot(process.cwd()).
|
|
34
|
+
* Not cached — the walk is a handful of stat calls, and tests spy on cwd.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getProjectRoot(): string;
|
|
37
|
+
//# sourceMappingURL=project-root.d.ts.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project-root anchor for durable state (#2633, generalising #2877).
|
|
3
|
+
*
|
|
4
|
+
* Under an agent the Bash tool cwd is sticky, and MCP servers and hooks inherit
|
|
5
|
+
* it, so raw process.cwd() is often a subdirectory of the project. State keyed
|
|
6
|
+
* to it (`.claude-flow/`, `.swarm/`) was written there and never read again.
|
|
7
|
+
*
|
|
8
|
+
* This is a copy of `isRufloProject` / `resolveProjectRoot` in
|
|
9
|
+
* @claude-flow/cli-core (src/mcp-tools/types.ts). The CLI pins a published
|
|
10
|
+
* cli-core that predates those exports, so it cannot import them yet;
|
|
11
|
+
* __tests__/project-root-anchor-2633.test.ts pins the two copies together.
|
|
12
|
+
* Once the pin moves past the release that exports them, replace this file's
|
|
13
|
+
* bodies with a re-export.
|
|
14
|
+
*
|
|
15
|
+
* Every function here only reads the filesystem; none creates directories.
|
|
16
|
+
*/
|
|
17
|
+
import * as fs from 'fs';
|
|
18
|
+
import * as os from 'os';
|
|
19
|
+
import * as path from 'path';
|
|
20
|
+
/**
|
|
21
|
+
* Return true only when the directory contains a durable Ruflo project marker.
|
|
22
|
+
*
|
|
23
|
+
* A bare `.claude/` is owned by Claude Code, and a bare `.claude-flow/` is not
|
|
24
|
+
* sufficient either: startup-time policy/champion migration can create it
|
|
25
|
+
* before this function runs. Treating that mutation as authorization caused a
|
|
26
|
+
* read-only command in any Claude project to spawn a detached daemon (#2852).
|
|
27
|
+
*/
|
|
28
|
+
export function isRufloProject(projectRoot) {
|
|
29
|
+
const root = path.resolve(projectRoot);
|
|
30
|
+
const directMarkers = [
|
|
31
|
+
path.join(root, '.claude-flow', 'config.yaml'),
|
|
32
|
+
path.join(root, '.claude-flow', 'config.yml'),
|
|
33
|
+
path.join(root, '.claude-flow', 'config.json'),
|
|
34
|
+
path.join(root, 'claude-flow.config.json'),
|
|
35
|
+
path.join(root, '.swarm', 'memory.db'),
|
|
36
|
+
];
|
|
37
|
+
if (directMarkers.some((marker) => fs.existsSync(marker)))
|
|
38
|
+
return true;
|
|
39
|
+
try {
|
|
40
|
+
const settings = JSON.parse(fs.readFileSync(path.join(root, '.claude', 'settings.json'), 'utf-8'));
|
|
41
|
+
if (settings && typeof settings === 'object' && 'claudeFlow' in settings) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch { /* absent/malformed/non-Ruflo settings */ }
|
|
46
|
+
try {
|
|
47
|
+
const mcp = JSON.parse(fs.readFileSync(path.join(root, '.mcp.json'), 'utf-8'));
|
|
48
|
+
const servers = mcp?.mcpServers;
|
|
49
|
+
if (servers && typeof servers === 'object'
|
|
50
|
+
&& ('ruflo' in servers || 'claude-flow' in servers)) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch { /* absent/malformed/non-Ruflo MCP config */ }
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Walk up from `startDir` and return the NEAREST enclosing directory carrying
|
|
59
|
+
* a Ruflo marker. Nearest-wins keeps a monorepo's independently-initialized
|
|
60
|
+
* sub-project on its own state.
|
|
61
|
+
*
|
|
62
|
+
* A `.git` entry is a hard stop — the repository boundary. Without it the walk
|
|
63
|
+
* could escape into an unrelated ancestor (a Ruflo project living at `$HOME`,
|
|
64
|
+
* say) and hand every repo below it the same state.
|
|
65
|
+
*
|
|
66
|
+
* Returns the resolved `startDir` unchanged when no marker is found, which
|
|
67
|
+
* preserves the previous cwd-relative behaviour outside a Ruflo project.
|
|
68
|
+
*/
|
|
69
|
+
export function resolveProjectRoot(startDir) {
|
|
70
|
+
const start = path.resolve(startDir);
|
|
71
|
+
let dir = start;
|
|
72
|
+
for (;;) {
|
|
73
|
+
if (isRufloProject(dir))
|
|
74
|
+
return dir;
|
|
75
|
+
if (fs.existsSync(path.join(dir, '.git')))
|
|
76
|
+
return start;
|
|
77
|
+
const parent = path.dirname(dir);
|
|
78
|
+
if (parent === dir)
|
|
79
|
+
return start;
|
|
80
|
+
dir = parent;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function comparablePath(p) {
|
|
84
|
+
const r = path.resolve(p);
|
|
85
|
+
return process.platform === 'win32' ? r.toLowerCase() : r;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* True when `dir` is a filesystem root or the user's home directory. Same
|
|
89
|
+
* check as cli-core's isNonProjectDir; kept local so this module does not
|
|
90
|
+
* depend on the MCP types module (several suites mock it).
|
|
91
|
+
*/
|
|
92
|
+
function isHomeOrFsRoot(dir) {
|
|
93
|
+
const target = comparablePath(dir);
|
|
94
|
+
if (target === comparablePath(path.parse(target).root))
|
|
95
|
+
return true;
|
|
96
|
+
for (const home of [os.homedir(), process.env.HOME, process.env.USERPROFILE]) {
|
|
97
|
+
if (home && comparablePath(home) === target)
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Anchor `dir` to its project root for durable state. Like resolveProjectRoot,
|
|
104
|
+
* but a walk that lands on home or a filesystem root is rejected and `dir` is
|
|
105
|
+
* returned instead — `~/.claude/settings.json` carrying a `claudeFlow` key
|
|
106
|
+
* must not turn $HOME into every non-git directory's project. Mirrors the
|
|
107
|
+
* guard cli-core's getProjectCwd() applies, so CLI commands and MCP tools
|
|
108
|
+
* agree on the root.
|
|
109
|
+
*/
|
|
110
|
+
export function anchorToProjectRoot(dir) {
|
|
111
|
+
const start = path.resolve(dir);
|
|
112
|
+
const root = resolveProjectRoot(start);
|
|
113
|
+
return isHomeOrFsRoot(root) ? start : root;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The project root for the current process: anchorToProjectRoot(process.cwd()).
|
|
117
|
+
* Not cached — the walk is a handful of stat calls, and tests spy on cwd.
|
|
118
|
+
*/
|
|
119
|
+
export function getProjectRoot() {
|
|
120
|
+
return anchorToProjectRoot(process.cwd());
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=project-root.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-flow/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.75.0",
|
|
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",
|
|
@@ -101,9 +101,9 @@
|
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
103
|
"@electron/asar": "^4.3.1",
|
|
104
|
-
"@claude-flow/cli-core": "3.7.
|
|
105
|
-
"@claude-flow/codex": "3.0.
|
|
106
|
-
"@claude-flow/mcp": "3.1.
|
|
104
|
+
"@claude-flow/cli-core": "3.7.7",
|
|
105
|
+
"@claude-flow/codex": "3.0.8",
|
|
106
|
+
"@claude-flow/mcp": "3.1.7",
|
|
107
107
|
"@claude-flow/neural": "3.0.3",
|
|
108
108
|
"@claude-flow/plugin-agent-federation": "1.0.7",
|
|
109
109
|
"@claude-flow/security": "3.0.7",
|
|
@@ -130,12 +130,12 @@
|
|
|
130
130
|
"ws": "^8.21.0",
|
|
131
131
|
"yaml": "^2.8.0",
|
|
132
132
|
"zod": "^3.22.0",
|
|
133
|
-
"@claude-flow/memory": "3.
|
|
133
|
+
"@claude-flow/memory": "3.3.0"
|
|
134
134
|
},
|
|
135
135
|
"optionalDependencies": {
|
|
136
136
|
"@agntcy/slim-bindings": "2.1.1",
|
|
137
|
-
"@claude-flow/aidefence": "3.1.
|
|
138
|
-
"@claude-flow/memory": "3.
|
|
137
|
+
"@claude-flow/aidefence": "3.1.2",
|
|
138
|
+
"@claude-flow/memory": "3.3.0",
|
|
139
139
|
"@metaharness/flywheel": "~0.1.10",
|
|
140
140
|
"@metaharness/radio": "~0.1.0",
|
|
141
141
|
"@metaharness/turn-credit": "~0.1.0",
|