Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 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

fix(session): include persisted stores by default in MCP snapshots

Rudy Celekli5e79d15cd210
diff --git a/v3/@claude-flow/cli/__tests__/session-save-defaults-r50.test.ts b/v3/@claude-flow/cli/__tests__/session-save-defaults-r50.test.ts
new file mode 100644
index 0000000000..7c1480a759
--- /dev/null
+++ b/v3/@claude-flow/cli/__tests__/session-save-defaults-r50.test.ts
@@ -0,0 +1,31 @@
+import { beforeEach, afterEach, expect, it, vi } from 'vitest';
+import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+const state = vi.hoisted(() => ({ cwd: '' }));
+vi.mock('../src/mcp-tools/types.js', () => ({ getProjectCwd: () => state.cwd }));
+import { sessionTools } from '../src/mcp-tools/session-tools.js';
+const save = (input: object) => sessionTools.find(t => t.name === 'session_save')!.handler({ name: 'snapshot', ...input }) as Promise<any>;
+beforeEach(() => {
+ state.cwd = mkdtempSync(join(tmpdir(), 'ruflo-save-defaults-'));
+ for (const [kind, data] of Object.entries({ tasks: { tasks: { task1: { taskId: 'task1' } } }, agents: { agents: { agent1: { agentId: 'agent1' } } }, memory: { entries: { key1: { key: 'key1', value: 'value' } } } })) {
+ const dir = join(state.cwd, '.claude-flow', kind); mkdirSync(dir, { recursive: true }); writeFileSync(join(dir, 'store.json'), JSON.stringify(data));
+ }
+});
+afterEach(() => rmSync(state.cwd, { recursive: true, force: true }));
+it('saves existing stores when MCP callers omit include flags', async () => {
+ const result = await save({});
+ expect(result.stats).toMatchObject({ tasks: 1, agents: 1, memoryEntries: 1 });
+ expect(Object.keys(JSON.parse(readFileSync(result.path, 'utf8')).data).sort()).toEqual(['agents', 'memory', 'tasks']);
+});
+it.each(['includeTasks', 'includeAgents', 'includeMemory'])('honors explicit false for %s while keeping other stores', async flag => {
+ const result = await save({ [flag]: false });
+ const statsKey = { includeTasks: 'tasks', includeAgents: 'agents', includeMemory: 'memoryEntries' }[flag]!;
+ expect(result.stats[statsKey]).toBe(0);
+ expect(['tasks','agents','memoryEntries'].filter(k => k !== statsKey).map(k => result.stats[k])).toEqual([1,1]);
+});
+it('supports intentionally empty metadata-only sessions', async () => {
+ const result = await save({ includeTasks: false, includeAgents: false, includeMemory: false });
+ expect(result.stats).toMatchObject({ tasks: 0, agents: 0, memoryEntries: 0 });
+ expect(JSON.parse(readFileSync(result.path, 'utf8')).data).toBeUndefined();
+});
diff --git a/v3/@claude-flow/cli/src/mcp-tools/session-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/session-tools.ts
index 3da5bda412..1a2d985422 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/session-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/session-tools.ts
@@ -148,9 +148,9 @@ export const sessionTools: MCPTool[] = [
properties: {
name: { type: 'string', description: 'Session name' },
description: { type: 'string', description: 'Session description' },
- includeMemory: { type: 'boolean', description: 'Include memory in session' },
- includeTasks: { type: 'boolean', description: 'Include tasks in session' },
- includeAgents: { type: 'boolean', description: 'Include agents in session' },
+ includeMemory: { type: 'boolean', default: true, description: 'Include memory in session' },
+ includeTasks: { type: 'boolean', default: true, description: 'Include tasks in session' },
+ includeAgents: { type: 'boolean', default: true, description: 'Include agents in session' },
},
required: ['name'],
},
@@ -167,9 +167,9 @@ export const sessionTools: MCPTool[] = [
// Load related data based on options
const data = loadRelatedStores({
- includeMemory: input.includeMemory as boolean,
- includeTasks: input.includeTasks as boolean,
- includeAgents: input.includeAgents as boolean,
+ includeMemory: input.includeMemory !== false,
+ includeTasks: input.includeTasks !== false,
+ includeAgents: input.includeAgents !== false,
});
// Calculate stats