🌊 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(cli): report every stored workflow in workflow_list total, not just the limited page (#4372)
kevin0c1a09f3ee8c
diff --git a/v3/@claude-flow/cli/__tests__/workflow-list-total.test.ts b/v3/@claude-flow/cli/__tests__/workflow-list-total.test.tsnew file mode 100644index 0000000000..2bd06cbfac--- /dev/null+++ b/v3/@claude-flow/cli/__tests__/workflow-list-total.test.ts@@ -0,0 +1,56 @@+/**+ * workflow_list computed `total` after applying `limit`, so `workflow list`+ * printed "Total: 20 workflows" even when more workflows were stored.+ */+import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { mkdtempSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { workflowTools } from '../src/mcp-tools/workflow-tools.js';++const tool = (name: string) => {+ const t = workflowTools.find(t => t.name === name);+ if (!t) throw new Error(`MCP tool not registered: ${name}`);+ return t;+};++type ListResult = { workflows: Array<{ workflowId: string }>; total: number };++describe('workflow_list total', () => {+ let dir: string;+ let prevCwd: string | undefined;++ beforeEach(async () => {+ dir = mkdtempSync(join(tmpdir(), 'ruflo-workflow-list-total-'));+ prevCwd = process.env.CLAUDE_FLOW_CWD;+ process.env.CLAUDE_FLOW_CWD = dir;+ const create = tool('workflow_create').handler;+ for (let i = 0; i < 3; i++) {+ await create({ name: `workflow ${i}` });+ }+ });++ afterEach(() => {+ if (prevCwd === undefined) delete process.env.CLAUDE_FLOW_CWD;+ else process.env.CLAUDE_FLOW_CWD = prevCwd;+ rmSync(dir, { recursive: true, force: true });+ });++ it('reports every stored workflow in total, not just the returned page', async () => {+ const result = await tool('workflow_list').handler({ limit: 2 }) as ListResult;+ expect(result.workflows).toHaveLength(2);+ expect(result.total).toBe(3);+ });++ it('counts the matches for the CLI default status filter', async () => {+ const result = await tool('workflow_list').handler({ status: 'all', limit: 1 }) as ListResult;+ expect(result.workflows).toHaveLength(1);+ expect(result.total).toBe(3);+ });++ it('total equals the number of workflows when under the limit', async () => {+ const result = await tool('workflow_list').handler({}) as ListResult;+ expect(result.workflows).toHaveLength(3);+ expect(result.total).toBe(3);+ });+});diff --git a/v3/@claude-flow/cli/src/mcp-tools/workflow-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/workflow-tools.tsindex 6a425d0982..8afccd7a07 100644--- a/v3/@claude-flow/cli/src/mcp-tools/workflow-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/workflow-tools.ts@@ -643,7 +643,8 @@ export const workflowTools: MCPTool[] = [// Sort by creation date (newest first)workflows.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());- // Apply limit+ // Count the matches before the limit cuts the page down+ const total = workflows.length;const limit = (input.limit as number) || 20;workflows = workflows.slice(0, limit);@@ -656,7 +657,7 @@ export const workflowTools: MCPTool[] = [createdAt: w.createdAt,completedAt: w.completedAt,})),- total: workflows.length,+ total,filters: { status: input.status },};},