🌊 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): count cancelled tasks in task_summary so the counts add up to total (#4489)
kevin99d5410b49c1
diff --git a/v3/@claude-flow/cli/__tests__/task-summary-cancelled.test.ts b/v3/@claude-flow/cli/__tests__/task-summary-cancelled.test.tsnew file mode 100644index 0000000000..e3cd835562--- /dev/null+++ b/v3/@claude-flow/cli/__tests__/task-summary-cancelled.test.ts@@ -0,0 +1,58 @@+/**+ * task_summary counted cancelled tasks in `total` but had no field for them,+ * so the per-status counts (and the `status` Tasks table) did not add up.+ */+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 { taskTools } from '../src/mcp-tools/task-tools.js';+import { systemTools } from '../src/mcp-tools/system-tools.js';++const tool = (name: string) => {+ const t = [...taskTools, ...systemTools].find(t => t.name === name);+ if (!t) throw new Error(`MCP tool not registered: ${name}`);+ return t;+};++type Summary = {+ total: number;+ pending: number;+ running: number;+ completed: number;+ failed: number;+ cancelled: number;+};++describe('task_summary', () => {+ let dir: string;+ let prevCwd: string | undefined;++ beforeEach(() => {+ dir = mkdtempSync(join(tmpdir(), 'ruflo-task-summary-'));+ prevCwd = process.env.CLAUDE_FLOW_CWD;+ process.env.CLAUDE_FLOW_CWD = dir;+ });++ afterEach(() => {+ if (prevCwd === undefined) delete process.env.CLAUDE_FLOW_CWD;+ else process.env.CLAUDE_FLOW_CWD = prevCwd;+ rmSync(dir, { recursive: true, force: true });+ });++ const create = async () =>+ (await tool('task_create').handler({ type: 'feature', description: 'work' }) as { taskId: string }).taskId;++ it('counts cancelled tasks so the per-status counts add up to total', async () => {+ await create();+ const cancelled = await create();+ const completed = await create();+ await tool('task_cancel').handler({ taskId: cancelled });+ await tool('task_complete').handler({ taskId: completed, result: {} });++ const summary = await tool('task_summary').handler({}) as Summary;+ expect(summary).toMatchObject({ total: 3, pending: 1, completed: 1, cancelled: 1 });+ const { total, ...byStatus } = summary;+ expect(Object.values(byStatus).reduce((a, b) => a + b, 0)).toBe(total);+ });+});diff --git a/v3/@claude-flow/cli/src/commands/status.ts b/v3/@claude-flow/cli/src/commands/status.tsindex 88cd71d623..187458623d 100644--- a/v3/@claude-flow/cli/src/commands/status.ts+++ b/v3/@claude-flow/cli/src/commands/status.ts@@ -121,6 +121,7 @@ async function getSystemStatus(): Promise<{running: number;completed: number;failed: number;+ cancelled: number;};performance: {cpuUsage: number;@@ -167,6 +168,7 @@ async function getSystemStatus(): Promise<{running: number;completed: number;failed: number;+ cancelled: number;}>('task_summary', {});return {@@ -220,7 +222,7 @@ async function getSystemStatus(): Promise<{backend: 'none',performance: { searchTime: 0, cacheHitRate: 0 }},- tasks: { total: 0, pending: 0, running: 0, completed: 0, failed: 0 },+ tasks: { total: 0, pending: 0, running: 0, completed: 0, failed: 0, cancelled: 0 },performance: {cpuUsage: 0,memoryUsage: 0,@@ -289,6 +291,7 @@ function displayStatus(status: Awaited<ReturnType<typeof getSystemStatus>>): voi{ status: 'Running', count: status.tasks.running },{ status: 'Completed', count: status.tasks.completed },{ status: 'Failed', count: status.tasks.failed },+ { status: 'Cancelled', count: status.tasks.cancelled },{ status: output.bold('Total'), count: status.tasks.total }]});diff --git a/v3/@claude-flow/cli/src/mcp-tools/system-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/system-tools.tsindex 8abadc8aad..ded640ec9c 100644--- a/v3/@claude-flow/cli/src/mcp-tools/system-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/system-tools.ts@@ -665,6 +665,7 @@ export const systemTools: MCPTool[] = [running: tasks.filter(t => t.status === 'in_progress').length,completed: tasks.filter(t => t.status === 'completed').length,failed: tasks.filter(t => t.status === 'failed').length,+ cancelled: tasks.filter(t => t.status === 'cancelled').length,};},},