🌊 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(cleanup): honor --keep-config (#4435)
nk-batman211d6930e58342
diff --git a/v3/@claude-flow/cli/__tests__/cleanup-keep-config.test.ts b/v3/@claude-flow/cli/__tests__/cleanup-keep-config.test.tsnew file mode 100644index 0000000000..65953c7825--- /dev/null+++ b/v3/@claude-flow/cli/__tests__/cleanup-keep-config.test.ts@@ -0,0 +1,47 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';++vi.mock('../src/output.js', () => ({ output: new Proxy({}, {+ get: (_target, name) => name === 'writeln' ? () => {} : (value: unknown) => value,+}) }));+import { cleanupCommand } from '../src/commands/cleanup.js';+import { CommandParser } from '../src/parser.js';++let root: string;+beforeEach(() => {+ root = mkdtempSync(join(tmpdir(), 'cleanup-keep-config-'));+ mkdirSync(join(root, '.claude-flow'));+ mkdirSync(join(root, '.claude'));+ writeFileSync(join(root, 'claude-flow.config.json'), '{"memory":{"persistPath":".swarm"}}\n');+ writeFileSync(join(root, '.claude', 'settings.json'), '{"hooks":{"Stop":[]},"claudeFlow":{"enabled":true}}\n');+});+afterEach(() => {+ rmSync(root, { recursive: true, force: true });+});++async function cleanup(argv: string[]): Promise<void> {+ const parser = new CommandParser();+ parser.registerCommand(cleanupCommand);+ const { flags } = parser.parse(['cleanup', '--force', ...argv]);+ const result = await cleanupCommand.action!({ args: [], flags, cwd: root, interactive: false });+ expect(result?.success).toBe(true);+ expect(existsSync(join(root, '.claude-flow'))).toBe(false);+}++const settings = () => JSON.parse(readFileSync(join(root, '.claude', 'settings.json'), 'utf-8'));++describe('cleanup --force --keep-config through the real command parser', () => {+ it.each(['--keep-config', '-k'])('keeps the config files with %s', async (flag) => {+ await cleanup([flag]);+ expect(existsSync(join(root, 'claude-flow.config.json'))).toBe(true);+ expect(settings()).toEqual({ hooks: { Stop: [] }, claudeFlow: { enabled: true } });+ });++ it('still removes them without the flag', async () => {+ await cleanup([]);+ expect(existsSync(join(root, 'claude-flow.config.json'))).toBe(false);+ expect(settings()).toEqual({});+ });+});diff --git a/v3/@claude-flow/cli/src/commands/cleanup.ts b/v3/@claude-flow/cli/src/commands/cleanup.tsindex e21a6df80b..89db7af6e9 100644--- a/v3/@claude-flow/cli/src/commands/cleanup.ts+++ b/v3/@claude-flow/cli/src/commands/cleanup.ts@@ -124,7 +124,7 @@ export const cleanupCommand: Command = {],action: async (ctx: CommandContext): Promise<CommandResult> => {const force = ctx.flags.force === true;- const keepConfig = ctx.flags['keep-config'] === true;+ const keepConfig = ctx.flags.keepConfig === true || ctx.flags['keep-config'] === true;const cwd = ctx.cwd;const dryRun = !force;