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,161 @@
|
|
|
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 { output } from '../output.js';
|
|
7
|
+
import { HostPluginInputError, HostPluginManager, } from '../services/host-plugin-manager.js';
|
|
8
|
+
const HOST_VALUES = ['claude', 'codex', 'both'];
|
|
9
|
+
const SCOPE_VALUES = ['user', 'project', 'local'];
|
|
10
|
+
const commonOptions = [
|
|
11
|
+
{ name: 'host', type: 'string', description: 'claude | codex | both (default: every host that is installed)' },
|
|
12
|
+
{ name: 'marketplace', type: 'string', description: 'Marketplace source as owner/repo', default: 'ruvnet/ruflo' },
|
|
13
|
+
{ name: 'marketplace-name', type: 'string', description: 'Marketplace name the source registers as', default: 'ruflo' },
|
|
14
|
+
{ name: 'scope', type: 'string', description: 'Claude scope: user | project | local (Codex supports user only)', default: 'user' },
|
|
15
|
+
{ name: 'dry-run', type: 'boolean', description: 'Print the exact argv that would run, change nothing' },
|
|
16
|
+
{ name: 'json', type: 'boolean', description: 'Print the structured per-host report as JSON' },
|
|
17
|
+
];
|
|
18
|
+
/** Exposed for tests: lets them inject a manager wired to fake host CLIs. */
|
|
19
|
+
export const hostCommandRuntime = { createManager: () => new HostPluginManager() };
|
|
20
|
+
function flag(ctx, kebab) {
|
|
21
|
+
const camel = kebab.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
22
|
+
return ctx.flags[kebab] ?? ctx.flags[camel];
|
|
23
|
+
}
|
|
24
|
+
function readOptions(ctx) {
|
|
25
|
+
const host = flag(ctx, 'host');
|
|
26
|
+
if (host !== undefined && !HOST_VALUES.includes(host)) {
|
|
27
|
+
throw new HostPluginInputError(`--host must be one of ${HOST_VALUES.join(', ')}`);
|
|
28
|
+
}
|
|
29
|
+
const scope = (flag(ctx, 'scope') ?? 'user');
|
|
30
|
+
if (!SCOPE_VALUES.includes(scope))
|
|
31
|
+
throw new HostPluginInputError(`--scope must be one of ${SCOPE_VALUES.join(', ')}`);
|
|
32
|
+
return {
|
|
33
|
+
hosts: host ?? 'auto',
|
|
34
|
+
scope,
|
|
35
|
+
dryRun: flag(ctx, 'dry-run') === true,
|
|
36
|
+
cwd: ctx.cwd,
|
|
37
|
+
marketplace: {
|
|
38
|
+
source: flag(ctx, 'marketplace') ?? undefined,
|
|
39
|
+
name: flag(ctx, 'marketplace-name') ?? undefined,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function renderResult(r) {
|
|
44
|
+
const tag = r.outcome === 'ok' || r.outcome === 'unchanged' ? output.success(r.outcome)
|
|
45
|
+
: r.outcome === 'planned' ? output.highlight(r.outcome) : output.error(r.outcome);
|
|
46
|
+
output.writeln(` [${r.host}] ${r.target}: ${tag}${r.message ? ` — ${r.message}` : ''}`);
|
|
47
|
+
for (const s of r.steps) {
|
|
48
|
+
output.writeln(` $ ${s.display}${s.ok === false ? output.error(' (failed)') : ''}`);
|
|
49
|
+
if (s.stderr)
|
|
50
|
+
output.writeln(output.dim(` ${s.stderr.split('\n').slice(0, 3).join(' | ')}`));
|
|
51
|
+
}
|
|
52
|
+
if (r.manual)
|
|
53
|
+
output.writeln(output.dim(` manual: ${r.manual}`));
|
|
54
|
+
}
|
|
55
|
+
function finish(ctx, report) {
|
|
56
|
+
if (flag(ctx, 'json') === true) {
|
|
57
|
+
output.writeln(JSON.stringify(report, null, 2));
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
output.writeln(output.bold(`plugins host ${report.action}${report.dryRun ? ' (dry run — nothing executed)' : ''}`));
|
|
61
|
+
for (const r of report.results)
|
|
62
|
+
renderResult(r);
|
|
63
|
+
output.writeln(report.ok ? output.success('all requested hosts succeeded') : output.error('one or more hosts failed — see above'));
|
|
64
|
+
}
|
|
65
|
+
return { success: report.ok, exitCode: report.ok ? 0 : 1, data: report };
|
|
66
|
+
}
|
|
67
|
+
function fail(ctx, err) {
|
|
68
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
69
|
+
if (flag(ctx, 'json') === true)
|
|
70
|
+
output.writeln(JSON.stringify({ ok: false, error: message }));
|
|
71
|
+
else
|
|
72
|
+
output.printError(message);
|
|
73
|
+
return { success: false, exitCode: 1, message };
|
|
74
|
+
}
|
|
75
|
+
function actionCommand(action, description) {
|
|
76
|
+
return {
|
|
77
|
+
name: action,
|
|
78
|
+
description,
|
|
79
|
+
options: commonOptions,
|
|
80
|
+
action: async (ctx) => {
|
|
81
|
+
try {
|
|
82
|
+
const report = await hostCommandRuntime.createManager().apply(action, ctx.args, readOptions(ctx));
|
|
83
|
+
return finish(ctx, report);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
return fail(ctx, err);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const syncCommand = {
|
|
92
|
+
name: 'sync',
|
|
93
|
+
description: 'Make Claude Code and Codex match: same marketplace, union of enabled plugins (additive, never removes)',
|
|
94
|
+
options: commonOptions,
|
|
95
|
+
action: async (ctx) => {
|
|
96
|
+
try {
|
|
97
|
+
const report = await hostCommandRuntime.createManager().sync(readOptions(ctx));
|
|
98
|
+
return finish(ctx, report);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
return fail(ctx, err);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
const statusCommand = {
|
|
106
|
+
name: 'status',
|
|
107
|
+
description: 'Show each host\'s installed version per Ruflo plugin and flag drift',
|
|
108
|
+
options: commonOptions,
|
|
109
|
+
action: async (ctx) => {
|
|
110
|
+
try {
|
|
111
|
+
const status = await hostCommandRuntime.createManager().status(readOptions(ctx));
|
|
112
|
+
if (flag(ctx, 'json') === true) {
|
|
113
|
+
output.writeln(JSON.stringify(status, null, 2));
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
for (const h of status.hosts)
|
|
117
|
+
renderResult(h);
|
|
118
|
+
for (const [host, src] of Object.entries(status.marketplaces)) {
|
|
119
|
+
output.writeln(` [${host}] marketplace: ${src ?? output.warning('not registered')}`);
|
|
120
|
+
}
|
|
121
|
+
const fmt = (s) => (s ? `${s.version}${s.enabled ? '' : ' (disabled)'}` : '-');
|
|
122
|
+
output.printTable({
|
|
123
|
+
columns: [
|
|
124
|
+
{ key: 'plugin', header: 'Plugin', width: 28 },
|
|
125
|
+
{ key: 'claude', header: 'Claude', width: 18 },
|
|
126
|
+
{ key: 'codex', header: 'Codex', width: 18 },
|
|
127
|
+
{ key: 'drift', header: 'Drift', width: 36 },
|
|
128
|
+
],
|
|
129
|
+
data: status.rows.map((r) => ({ plugin: r.plugin, claude: fmt(r.claude), codex: fmt(r.codex), drift: r.drift.join('; ') || 'in sync' })),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return { success: status.ok, exitCode: status.ok ? 0 : 1, data: status };
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
return fail(ctx, err);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
export const hostCommand = {
|
|
140
|
+
name: 'host',
|
|
141
|
+
description: 'Install/update/remove Ruflo marketplace plugins in Claude Code and Codex together',
|
|
142
|
+
subcommands: [
|
|
143
|
+
actionCommand('install', 'Install plugin(s) in every selected host'),
|
|
144
|
+
actionCommand('update', 'Refresh the marketplace and update plugin(s) in every selected host'),
|
|
145
|
+
actionCommand('uninstall', 'Uninstall plugin(s) from every selected host'),
|
|
146
|
+
actionCommand('enable', 'Enable plugin(s) in every selected host'),
|
|
147
|
+
actionCommand('disable', 'Disable plugin(s) in every selected host'),
|
|
148
|
+
syncCommand,
|
|
149
|
+
statusCommand,
|
|
150
|
+
],
|
|
151
|
+
examples: [
|
|
152
|
+
{ command: 'ruflo plugins host install ruflo-swarm', description: 'Install in Claude Code and Codex' },
|
|
153
|
+
{ command: 'ruflo plugins host sync --dry-run', description: 'Show what sync would run' },
|
|
154
|
+
{ command: 'ruflo plugins host status', description: 'Per-host versions and drift' },
|
|
155
|
+
],
|
|
156
|
+
action: async () => {
|
|
157
|
+
output.writeln('Usage: ruflo plugins host <install|update|uninstall|enable|disable|sync|status> [plugin...] [--host claude|codex|both] [--dry-run]');
|
|
158
|
+
return { success: true };
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
//# sourceMappingURL=plugins-host.js.map
|
|
@@ -13,6 +13,7 @@ import { getBulkRatings } from '../services/registry-api.js';
|
|
|
13
13
|
import { scanLocalPluginBeforeInstall, verifyCommand } from './plugins-verify.js';
|
|
14
14
|
import { acceptRiskFrom } from '../plugins/marketplace-trust/scan.js';
|
|
15
15
|
import { pathsCommand } from './plugins-paths.js';
|
|
16
|
+
import { hostCommand } from './plugins-host.js';
|
|
16
17
|
// List subcommand - Now uses IPFS-based registry
|
|
17
18
|
const listCommand = {
|
|
18
19
|
name: 'list',
|
|
@@ -906,7 +907,7 @@ const rateCommand = {
|
|
|
906
907
|
export const pluginsCommand = {
|
|
907
908
|
name: 'plugins',
|
|
908
909
|
description: 'Plugin management with IPFS-based decentralized registry',
|
|
909
|
-
subcommands: [listCommand, searchCommand, installCommand, uninstallCommand, upgradeCommand, toggleCommand, infoCommand, createCommand, rateCommand, verifyCommand, pathsCommand],
|
|
910
|
+
subcommands: [listCommand, searchCommand, installCommand, uninstallCommand, upgradeCommand, toggleCommand, infoCommand, createCommand, rateCommand, verifyCommand, pathsCommand, hostCommand],
|
|
910
911
|
examples: [
|
|
911
912
|
{ command: 'claude-flow plugins list', description: 'List plugins from IPFS registry' },
|
|
912
913
|
{ command: 'claude-flow plugins search -q neural', description: 'Search for plugins' },
|
|
@@ -929,6 +930,7 @@ export const pluginsCommand = {
|
|
|
929
930
|
`${output.highlight('info')} - Show detailed plugin information`,
|
|
930
931
|
`${output.highlight('verify')} - Check ruflo marketplace plugins against their release signatures`,
|
|
931
932
|
`${output.highlight('paths')} - Local folders of ruflo plugins (claude -p --plugin-dir, Agent SDK)`,
|
|
933
|
+
`${output.highlight('host')} - Install/sync ruflo marketplace plugins in Claude Code and Codex together`,
|
|
932
934
|
`${output.highlight('create')} - Scaffold a new plugin project`,
|
|
933
935
|
]);
|
|
934
936
|
output.writeln();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ruflo start all` (#1177): bring up everything in one command.
|
|
3
|
+
*
|
|
4
|
+
* 0. project init — only when the project was never initialized (same path as `start quick`)
|
|
5
|
+
* 1. memory init — only when the memory database is missing (never overwrites)
|
|
6
|
+
* 2. daemon start — only when no daemon is running
|
|
7
|
+
* 3. start — the main `start` action
|
|
8
|
+
*
|
|
9
|
+
* Every step is injectable through `deps` so tests can mock each one.
|
|
10
|
+
*/
|
|
11
|
+
import type { CommandContext, CommandResult } from '../types.js';
|
|
12
|
+
/** Steps `start all` runs, injectable so tests can replace each one. */
|
|
13
|
+
export interface StartAllDeps {
|
|
14
|
+
isProjectInitialized: (cwd: string) => boolean | Promise<boolean>;
|
|
15
|
+
initProject: (ctx: CommandContext) => Promise<CommandResult | void>;
|
|
16
|
+
isMemoryInitialized: () => Promise<boolean>;
|
|
17
|
+
initMemory: () => Promise<{
|
|
18
|
+
success: boolean;
|
|
19
|
+
error?: string;
|
|
20
|
+
}>;
|
|
21
|
+
isDaemonRunning: (cwd: string) => boolean | Promise<boolean>;
|
|
22
|
+
startDaemon: (ctx: CommandContext) => Promise<CommandResult | void>;
|
|
23
|
+
start: (ctx: CommandContext) => Promise<CommandResult>;
|
|
24
|
+
}
|
|
25
|
+
export declare const defaultStartAllDeps: StartAllDeps;
|
|
26
|
+
/** Runs the steps in order; stops at the first failure with a non-zero result naming it. */
|
|
27
|
+
export declare function runStartAll(ctx: CommandContext, deps?: StartAllDeps): Promise<CommandResult>;
|
|
28
|
+
//# sourceMappingURL=start-all.d.ts.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ruflo start all` (#1177): bring up everything in one command.
|
|
3
|
+
*
|
|
4
|
+
* 0. project init — only when the project was never initialized (same path as `start quick`)
|
|
5
|
+
* 1. memory init — only when the memory database is missing (never overwrites)
|
|
6
|
+
* 2. daemon start — only when no daemon is running
|
|
7
|
+
* 3. start — the main `start` action
|
|
8
|
+
*
|
|
9
|
+
* Every step is injectable through `deps` so tests can mock each one.
|
|
10
|
+
*/
|
|
11
|
+
import { output } from '../output.js';
|
|
12
|
+
// Real steps, loaded lazily: plain `start` must not pull in sql.js or the daemon
|
|
13
|
+
// module, and start.ts imports this file (a static import back would be a cycle).
|
|
14
|
+
export const defaultStartAllDeps = {
|
|
15
|
+
isProjectInitialized: async (cwd) => (await import('./start.js')).isInitialized(cwd),
|
|
16
|
+
initProject: async (ctx) => (await import('./start.js')).runMinimalProjectInit(ctx),
|
|
17
|
+
isMemoryInitialized: async () => {
|
|
18
|
+
const { checkMemoryInitialization } = await import('../memory/memory-initializer.js');
|
|
19
|
+
return (await checkMemoryInitialization()).initialized;
|
|
20
|
+
},
|
|
21
|
+
initMemory: async () => {
|
|
22
|
+
const { initializeMemoryDatabase } = await import('../memory/memory-initializer.js');
|
|
23
|
+
// force: false — never overwrite an existing database.
|
|
24
|
+
return initializeMemoryDatabase({ force: false });
|
|
25
|
+
},
|
|
26
|
+
isDaemonRunning: async (cwd) => {
|
|
27
|
+
const { isDaemonAlive, resolveDaemonProjectRoot } = await import('../services/daemon-autostart.js');
|
|
28
|
+
return isDaemonAlive(resolveDaemonProjectRoot(cwd));
|
|
29
|
+
},
|
|
30
|
+
startDaemon: async (ctx) => {
|
|
31
|
+
const { daemonCommand } = await import('./daemon.js');
|
|
32
|
+
const daemonStart = daemonCommand.subcommands?.find((c) => c.name === 'start');
|
|
33
|
+
if (!daemonStart?.action)
|
|
34
|
+
throw new Error('daemon start command not found');
|
|
35
|
+
// Only `quiet` is forwarded: start's own flags (port, topology, daemon) mean something else to `daemon start`.
|
|
36
|
+
const flags = { _: [] };
|
|
37
|
+
if (ctx.flags.quiet !== undefined)
|
|
38
|
+
flags.quiet = ctx.flags.quiet;
|
|
39
|
+
return daemonStart.action({ ...ctx, args: [], flags });
|
|
40
|
+
},
|
|
41
|
+
start: async (ctx) => (await import('./start.js')).startAction(ctx),
|
|
42
|
+
};
|
|
43
|
+
function fail(step, error) {
|
|
44
|
+
const detail = error instanceof Error ? error.message : String(error ?? 'unknown error');
|
|
45
|
+
output.printError(`start all: ${step} failed: ${detail}`);
|
|
46
|
+
return { success: false, exitCode: 1, data: { failedStep: step, error: detail } };
|
|
47
|
+
}
|
|
48
|
+
/** Runs the steps in order; stops at the first failure with a non-zero result naming it. */
|
|
49
|
+
export async function runStartAll(ctx, deps = defaultStartAllDeps) {
|
|
50
|
+
try {
|
|
51
|
+
if (await deps.isProjectInitialized(ctx.cwd)) {
|
|
52
|
+
output.printInfo('Project already initialized, skipping init');
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
output.printInfo('Project not initialized, running init first...');
|
|
56
|
+
const init = await deps.initProject(ctx);
|
|
57
|
+
if (init && !init.success)
|
|
58
|
+
return fail('project init', 'init returned failure');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return fail('project init', error);
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
if (await deps.isMemoryInitialized()) {
|
|
66
|
+
output.printInfo('Memory already initialized, skipping');
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const init = await deps.initMemory();
|
|
70
|
+
if (!init.success)
|
|
71
|
+
return fail('memory init', init.error);
|
|
72
|
+
output.printSuccess('Memory initialized');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return fail('memory init', error);
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
if (await deps.isDaemonRunning(ctx.cwd)) {
|
|
80
|
+
output.printInfo('Daemon already running, skipping');
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const daemon = await deps.startDaemon(ctx);
|
|
84
|
+
if (daemon && !daemon.success)
|
|
85
|
+
return fail('daemon start', 'daemon start returned failure');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return fail('daemon start', error);
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const result = await deps.start(ctx);
|
|
93
|
+
return result.success ? result : fail('start', 'start returned failure');
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
return fail('start', error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=start-all.js.map
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
* V3 CLI Start Command
|
|
3
3
|
* System startup for Claude Flow orchestration
|
|
4
4
|
*/
|
|
5
|
-
import type { Command } from '../types.js';
|
|
5
|
+
import type { Command, CommandContext, CommandResult } from '../types.js';
|
|
6
|
+
export declare function isInitialized(cwd: string): boolean;
|
|
7
|
+
export declare const startAction: (ctx: CommandContext) => Promise<CommandResult>;
|
|
8
|
+
/** Project init shared by `start quick` and `start all`: `init --minimal`. Callers check isInitialized() first. */
|
|
9
|
+
export declare function runMinimalProjectInit(ctx: CommandContext): Promise<CommandResult | void>;
|
|
6
10
|
export declare const startCommand: Command;
|
|
7
11
|
export default startCommand;
|
|
8
12
|
//# sourceMappingURL=start.d.ts.map
|
|
@@ -7,12 +7,13 @@ import { confirm } from '../prompt.js';
|
|
|
7
7
|
import { callMCPTool, MCPClientError } from '../mcp-client.js';
|
|
8
8
|
import * as fs from 'fs';
|
|
9
9
|
import * as path from 'path';
|
|
10
|
+
import { runStartAll } from './start-all.js';
|
|
10
11
|
// Default configuration
|
|
11
12
|
const DEFAULT_PORT = 3000;
|
|
12
13
|
const DEFAULT_TOPOLOGY = 'hierarchical-mesh';
|
|
13
14
|
const DEFAULT_MAX_AGENTS = 15;
|
|
14
15
|
// Check if project is initialized
|
|
15
|
-
function isInitialized(cwd) {
|
|
16
|
+
export function isInitialized(cwd) {
|
|
16
17
|
const configPath = path.join(cwd, '.claude-flow', 'config.yaml');
|
|
17
18
|
return fs.existsSync(configPath);
|
|
18
19
|
}
|
|
@@ -81,7 +82,7 @@ function loadConfig(cwd) {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
// Main start action
|
|
84
|
-
const startAction = async (ctx) => {
|
|
85
|
+
export const startAction = async (ctx) => {
|
|
85
86
|
const daemon = ctx.flags.daemon;
|
|
86
87
|
const port = ctx.flags.port || DEFAULT_PORT;
|
|
87
88
|
const topology = ctx.flags.topology || DEFAULT_TOPOLOGY;
|
|
@@ -343,6 +344,11 @@ const restartCommand = {
|
|
|
343
344
|
};
|
|
344
345
|
}
|
|
345
346
|
};
|
|
347
|
+
/** Project init shared by `start quick` and `start all`: `init --minimal`. Callers check isInitialized() first. */
|
|
348
|
+
export async function runMinimalProjectInit(ctx) {
|
|
349
|
+
const { initCommand } = await import('./init.js');
|
|
350
|
+
return initCommand.action({ ...ctx, flags: { ...ctx.flags, minimal: true } });
|
|
351
|
+
}
|
|
346
352
|
// Quick start subcommand
|
|
347
353
|
const quickCommand = {
|
|
348
354
|
name: 'quick',
|
|
@@ -353,13 +359,7 @@ const quickCommand = {
|
|
|
353
359
|
if (!isInitialized(ctx.cwd)) {
|
|
354
360
|
output.printInfo('Project not initialized, running init first...');
|
|
355
361
|
output.writeln();
|
|
356
|
-
|
|
357
|
-
const { initCommand } = await import('./init.js');
|
|
358
|
-
const initCtx = {
|
|
359
|
-
...ctx,
|
|
360
|
-
flags: { ...ctx.flags, minimal: true }
|
|
361
|
-
};
|
|
362
|
-
await initCommand.action(initCtx);
|
|
362
|
+
await runMinimalProjectInit(ctx);
|
|
363
363
|
output.writeln();
|
|
364
364
|
}
|
|
365
365
|
// Start with defaults
|
|
@@ -369,11 +369,17 @@ const quickCommand = {
|
|
|
369
369
|
});
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
|
+
// Start-all subcommand (#1177); steps live in start-all.ts
|
|
373
|
+
const allCommand = {
|
|
374
|
+
name: 'all',
|
|
375
|
+
description: 'Init the project and memory if needed, start the daemon if not running, then start the system',
|
|
376
|
+
action: (ctx) => runStartAll(ctx),
|
|
377
|
+
};
|
|
372
378
|
// Main start command
|
|
373
379
|
export const startCommand = {
|
|
374
380
|
name: 'start',
|
|
375
381
|
description: 'Start the RuFlo orchestration system',
|
|
376
|
-
subcommands: [stopCommand, restartCommand, quickCommand],
|
|
382
|
+
subcommands: [stopCommand, restartCommand, quickCommand, allCommand],
|
|
377
383
|
options: [
|
|
378
384
|
{
|
|
379
385
|
name: 'daemon',
|
|
@@ -410,6 +416,7 @@ export const startCommand = {
|
|
|
410
416
|
{ command: 'claude-flow start --topology mesh', description: 'Start with mesh topology' },
|
|
411
417
|
{ command: 'claude-flow start --skip-mcp', description: 'Start without MCP server' },
|
|
412
418
|
{ command: 'claude-flow start quick', description: 'Quick start with defaults' },
|
|
419
|
+
{ command: 'claude-flow start all', description: 'Init project/memory if needed, start the daemon, then start' },
|
|
413
420
|
{ command: 'claude-flow start stop', description: 'Stop the running system' }
|
|
414
421
|
],
|
|
415
422
|
action: startAction
|
|
@@ -8,6 +8,7 @@ import { callMCPTool, MCPClientError } from '../mcp-client.js';
|
|
|
8
8
|
import { swarmJoinCommand } from './agntcy/swarm-join.js';
|
|
9
9
|
import * as fs from 'fs';
|
|
10
10
|
import * as path from 'path';
|
|
11
|
+
import { getProjectRoot } from '../services/project-root.js';
|
|
11
12
|
import { noteFirstAgentRun } from '../funnel/activation.js';
|
|
12
13
|
// Read the CLI-side swarm state file (`.swarm/state.json`), written by
|
|
13
14
|
// `swarm init` and rewritten by `swarm start` / `swarm stop`.
|
|
@@ -128,7 +129,7 @@ function getSwarmStatus(swarmId) {
|
|
|
128
129
|
// instead of reporting Total 0 while `agent list` shows N agents.
|
|
129
130
|
if (totalAgents === 0) {
|
|
130
131
|
try {
|
|
131
|
-
const activityPath = path.join(
|
|
132
|
+
const activityPath = path.join(getProjectRoot(), '.claude-flow', 'metrics', 'swarm-activity.json');
|
|
132
133
|
if (fs.existsSync(activityPath)) {
|
|
133
134
|
const activity = JSON.parse(fs.readFileSync(activityPath, 'utf-8'));
|
|
134
135
|
const count = Math.max(0, Number((activity?.swarm?.agent_count)) || 0);
|
|
@@ -42,8 +42,15 @@ export function writeFileAtomic(path, data, opts = {}) {
|
|
|
42
42
|
let fd;
|
|
43
43
|
try {
|
|
44
44
|
fd = openSync(tmp, 'wx', mode);
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
// writeSync may write fewer bytes than asked (#4888). Loop until every byte
|
|
46
|
+
// is on the temp file, or rename() would publish a truncated image.
|
|
47
|
+
let written = 0;
|
|
48
|
+
while (written < data.length) {
|
|
49
|
+
const n = writeSync(fd, data, written, data.length - written, written);
|
|
50
|
+
if (n <= 0)
|
|
51
|
+
throw new Error(`writeFileAtomic: write made no progress at byte ${written} of ${data.length}`);
|
|
52
|
+
written += n;
|
|
53
|
+
}
|
|
47
54
|
fsyncSync(fd); // durability: force bytes to disk BEFORE the rename
|
|
48
55
|
closeSync(fd);
|
|
49
56
|
fd = undefined;
|
|
@@ -8,6 +8,21 @@
|
|
|
8
8
|
import type { InitOptions, ClaudeMdTemplate } from './types.js';
|
|
9
9
|
export declare function generateClaudeMd(options: InitOptions, template?: ClaudeMdTemplate): string;
|
|
10
10
|
export declare function generateMinimalClaudeMd(options: InitOptions): string;
|
|
11
|
+
/**
|
|
12
|
+
* The shared sections, with the CLI invoked as `cli`. With the default (this
|
|
13
|
+
* file's form) they are what a CLAUDE.md importing AGENTS.md must not repeat;
|
|
14
|
+
* with `AGENTS_MD_CLI` they are exactly what the codex generator writes into
|
|
15
|
+
* AGENTS.md.
|
|
16
|
+
*/
|
|
17
|
+
export declare function sharedSectionsForImport(cli?: string): string[];
|
|
18
|
+
/** How the codex generator writes the CLI invocation into AGENTS.md. */
|
|
19
|
+
export declare const AGENTS_MD_CLI = "npx @claude-flow/cli";
|
|
20
|
+
/**
|
|
21
|
+
* #2638 dual mode: CLAUDE.md imports AGENTS.md (which carries the shared
|
|
22
|
+
* sections) and keeps only what is Claude-specific, plus any template extras
|
|
23
|
+
* the shared set does not cover. Nothing here repeats a shared section.
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateDualClaudeMd(options: InitOptions, template?: ClaudeMdTemplate): string;
|
|
11
26
|
export declare const CLAUDE_MD_TEMPLATES: Array<{
|
|
12
27
|
name: ClaudeMdTemplate;
|
|
13
28
|
description: string;
|