🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(migrate): honor --dry-run in migrate run and migrate fix (#4568)
nk-batman21e4e5487efcd1
diff --git a/v3/@claude-flow/cli/__tests__/migrate-dry-run.test.ts b/v3/@claude-flow/cli/__tests__/migrate-dry-run.test.tsnew file mode 100644index 0000000000..1e05f33df1--- /dev/null+++ b/v3/@claude-flow/cli/__tests__/migrate-dry-run.test.ts@@ -0,0 +1,64 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';++const mocks = vi.hoisted(() => ({+ restoreRemovedAgents: vi.fn(async (..._args: unknown[]) => []),+}));++vi.mock('../src/output.js', () => ({ output: new Proxy({}, {+ get: (_target, name) => name === 'writeln' ? () => {} : (value: unknown) => value,+}) }));+vi.mock('../src/commands/migrate-agent-detection.js', () => ({+ detectRemovedAgentGaps: () => [{ agent: 'coder.md', plugin: 'ruflo-core', installCommand: '/plugin install ruflo-core@ruflo' }],+}));+vi.mock('../src/commands/migrate-agent-restore.js', () => ({+ restoreRemovedAgents: mocks.restoreRemovedAgents,+}));+import { migrateCommand } from '../src/commands/migrate.js';+import { CommandParser } from '../src/parser.js';++let root: string;+beforeEach(() => {+ root = mkdtempSync(join(tmpdir(), 'migrate-dry-run-'));+ writeFileSync(join(root, 'claude-flow.config.json'), '{"version":"2","swarm":{"mode":"mesh"}}\n');+ mkdirSync(join(root, 'data', 'sessions'), { recursive: true });+ writeFileSync(join(root, 'data', 'sessions', 'session-1.json'), '{}\n');+});+afterEach(() => {+ rmSync(root, { recursive: true, force: true });+ vi.clearAllMocks();+});++async function migrate(argv: string[]): Promise<void> {+ const parser = new CommandParser();+ parser.registerCommand(migrateCommand);+ const { flags } = parser.parse(['migrate', ...argv]);+ const subcommand = migrateCommand.subcommands!.find((command) => command.name === argv[0])!;+ const result = await subcommand.action!({ args: [], flags, cwd: root, interactive: false });+ expect(result?.success).toBe(true);+}++describe('migrate --dry-run through the real command parser', () => {+ it('migrate run --dry-run writes nothing', async () => {+ await migrate(['run', '--dry-run']);+ expect(existsSync(join(root, '.claude-flow'))).toBe(false);+ });++ it('migrate run still migrates without the flag', async () => {+ await migrate(['run']);+ expect(existsSync(join(root, '.claude-flow', 'config.json'))).toBe(true);+ expect(existsSync(join(root, '.claude-flow', 'sessions', 'session-1.json'))).toBe(true);+ });++ it.each(['--dry-run', '-d'])('migrate fix --agents %s restores as a dry run', async (flag) => {+ await migrate(['fix', '--agents', flag]);+ expect(mocks.restoreRemovedAgents).toHaveBeenCalledWith(root, expect.any(Array), { dryRun: true });+ });++ it('migrate fix --agents still restores without the flag', async () => {+ await migrate(['fix', '--agents']);+ expect(mocks.restoreRemovedAgents).toHaveBeenCalledWith(root, expect.any(Array), { dryRun: false });+ });+});diff --git a/v3/@claude-flow/cli/src/commands/migrate.ts b/v3/@claude-flow/cli/src/commands/migrate.tsindex e16d1bea6b..4b00c81716 100644--- a/v3/@claude-flow/cli/src/commands/migrate.ts+++ b/v3/@claude-flow/cli/src/commands/migrate.ts@@ -232,7 +232,7 @@ const runCommand: Command = {],action: async (ctx: CommandContext): Promise<CommandResult> => {const cwd = ctx.cwd || process.cwd();- const dryRun = ctx.flags['dry-run'] === true;+ const dryRun = ctx.flags.dryRun === true || ctx.flags['dry-run'] === true;const skipBackup = ctx.flags.backup === false;const timestamp = new Date().toISOString().replace(/[:.]/g, '-');const v3Dir = path.join(cwd, '.claude-flow');@@ -794,7 +794,7 @@ const fixCommand: Command = {return { success: true, data: { results: [] } };}- const dryRun = Boolean(ctx.flags['dry-run']);+ const dryRun = ctx.flags.dryRun === true || ctx.flags['dry-run'] === true;const results = await restoreRemovedAgents(cwd, gaps, { dryRun });if (ctx.flags.format === 'json') {