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(cli): make `status tasks` list tasks instead of always printing "No tasks" (#4321)

kevin0b936e78a87d
diff --git a/v3/@claude-flow/cli/__tests__/status-tasks-all.test.ts b/v3/@claude-flow/cli/__tests__/status-tasks-all.test.ts
new file mode 100644
index 0000000000..3ffac0e00e
--- /dev/null
+++ b/v3/@claude-flow/cli/__tests__/status-tasks-all.test.ts
@@ -0,0 +1,77 @@
+/**
+ * `status tasks` sends `status: 'all'` to task_list, which treated it as a
+ * literal status, filtered every task out and printed "No tasks". It also
+ * read `id` / `agent`, while task_list returns `taskId` / `assignedTo`.
+ */
+import { describe, it, expect, beforeEach, afterEach, vi } 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 { statusCommand } from '../src/commands/status.js';
+import { output } from '../src/output.js';
+import type { CommandContext } from '../src/types.js';
+
+const tool = (name: string) => {
+ const t = taskTools.find(t => t.name === name);
+ if (!t) throw new Error(`MCP tool not registered: ${name}`);
+ return t;
+};
+
+const tasksCommand = statusCommand.subcommands!.find(c => c.name === 'tasks')!;
+
+describe('status tasks', () => {
+ let dir: string;
+ let prevCwd: string | undefined;
+ let pending: string;
+ let done: string;
+
+ beforeEach(async () => {
+ dir = mkdtempSync(join(tmpdir(), 'ruflo-status-tasks-'));
+ prevCwd = process.env.CLAUDE_FLOW_CWD;
+ process.env.CLAUDE_FLOW_CWD = dir;
+
+ const create = tool('task_create').handler;
+ pending = (await create({ type: 'feature', description: 'still open' }) as { taskId: string }).taskId;
+ done = (await create({ type: 'bugfix', description: 'finished' }) as { taskId: string }).taskId;
+ await tool('task_complete').handler({ taskId: done });
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ if (prevCwd === undefined) delete process.env.CLAUDE_FLOW_CWD;
+ else process.env.CLAUDE_FLOW_CWD = prevCwd;
+ rmSync(dir, { recursive: true, force: true });
+ });
+
+ it("task_list treats status 'all' as no status filter", async () => {
+ const result = await tool('task_list').handler({ status: 'all' }) as { tasks: Array<{ taskId: string }> };
+ expect(result.tasks.map(t => t.taskId).sort()).toEqual([pending, done].sort());
+ });
+
+ it('task_list still filters by a real status', async () => {
+ const result = await tool('task_list').handler({ status: 'completed' }) as { tasks: Array<{ taskId: string }> };
+ expect(result.tasks.map(t => t.taskId)).toEqual([done]);
+ });
+
+ it('status tasks lists every task', async () => {
+ const ctx = { args: [], flags: { format: 'json' }, cwd: dir, interactive: false } as unknown as CommandContext;
+ const result = await tasksCommand.action!(ctx);
+ expect(result?.success).toBe(true);
+ const tasks = (result!.data as { tasks: Array<{ taskId: string }> }).tasks;
+ expect(tasks.map(t => t.taskId).sort()).toEqual([pending, done].sort());
+ });
+
+ it('status tasks shows the task id and assigned agents in the table', async () => {
+ await tool('task_assign').handler({ taskId: pending, agentIds: ['agent-a', 'agent-b'] });
+ const printTable = vi.spyOn(output, 'printTable').mockImplementation(() => {});
+ vi.spyOn(output, 'writeln').mockImplementation(() => {});
+ const ctx = { args: [], flags: {}, cwd: dir, interactive: false } as unknown as CommandContext;
+ const result = await tasksCommand.action!(ctx);
+ expect(result?.success).toBe(true);
+ const rows = printTable.mock.calls[0][0].data as Array<{ id: string; agent: string }>;
+ const row = rows.find(r => r.id === pending);
+ expect(row?.agent).toBe('agent-a, agent-b');
+ expect(rows.map(r => r.id).sort()).toEqual([pending, done].sort());
+ });
+});
diff --git a/v3/@claude-flow/cli/src/commands/status.ts b/v3/@claude-flow/cli/src/commands/status.ts
index 6918d989a7..88cd71d623 100644
--- a/v3/@claude-flow/cli/src/commands/status.ts
+++ b/v3/@claude-flow/cli/src/commands/status.ts
@@ -580,11 +580,11 @@ const tasksCommand: Command = {
try {
const result = await callMCPTool<{
tasks: Array<{
- id: string;
+ taskId: string;
type: string;
status: string;
priority: string;
- agent?: string;
+ assignedTo?: string[];
progress: number;
createdAt: string;
}>;
@@ -614,11 +614,11 @@ const tasksCommand: Command = {
{ key: 'progress', header: 'Progress', width: 10 }
],
data: result.tasks.map(t => ({
- id: t.id,
+ id: t.taskId,
type: t.type,
status: formatHealth(t.status),
priority: t.priority,
- agent: t.agent || '-',
+ agent: t.assignedTo?.length ? t.assignedTo.join(', ') : '-',
progress: `${t.progress}%`
}))
});
diff --git a/v3/@claude-flow/cli/src/mcp-tools/task-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/task-tools.ts
index cac19fe731..85646bcce2 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/task-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/task-tools.ts
@@ -241,9 +241,11 @@ export const taskTools: MCPTool[] = [
// Apply filters
if (input.status) {
- // Support comma-separated status values
+ // Support comma-separated status values. 'all' (sent by `status tasks`) means no status filter.
const statuses = (input.status as string).split(',').map(s => s.trim());
- tasks = tasks.filter(t => statuses.includes(t.status));
+ if (!statuses.includes('all')) {
+ tasks = tasks.filter(t => statuses.includes(t.status));
+ }
}
if (input.type) {
tasks = tasks.filter(t => t.type === input.type);