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(hooks): honor --no-color in hooks statusline (#4387)

nk-batman219f35d160e672
diff --git a/v3/@claude-flow/cli/__tests__/hooks-statusline-no-color.test.ts b/v3/@claude-flow/cli/__tests__/hooks-statusline-no-color.test.ts
new file mode 100644
index 0000000000..792aab35e4
--- /dev/null
+++ b/v3/@claude-flow/cli/__tests__/hooks-statusline-no-color.test.ts
@@ -0,0 +1,57 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { mkdtempSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+
+const lines = vi.hoisted(() => [] as string[]);
+vi.mock('../src/output.js', () => ({ output: new Proxy({}, {
+ get: (_target, name) => name === 'writeln'
+ ? (text = '') => { lines.push(String(text)); }
+ : (value: unknown) => value,
+}) }));
+vi.mock('../src/mcp-client.js', () => ({ callMCPTool: vi.fn(), MCPClientError: class extends Error {} }));
+vi.mock('../src/funnel/index.js', () => ({ getFunnelPromo: () => null }));
+vi.mock('../src/funnel/local-signals.js', () => ({
+ getSecurityStatus: () => ({ status: 'CLEAN', findings: 0, cvesFixed: 0, totalCves: 0 }),
+ getSwarmStatus: () => ({ activeAgents: 0, maxAgents: 15, coordinationActive: false }),
+ getGitUncommittedCount: () => 0,
+}));
+import { hooksCommand } from '../src/commands/hooks.js';
+import { CommandParser } from '../src/parser.js';
+
+const cwd = process.cwd();
+let root: string;
+beforeEach(() => {
+ lines.length = 0;
+ root = mkdtempSync(join(tmpdir(), 'hooks-statusline-no-color-'));
+ process.chdir(root);
+ // A terminal run: no Claude Code JSON waiting on stdin.
+ Object.defineProperty(process.stdin, 'isTTY', { value: true, configurable: true });
+});
+afterEach(() => {
+ delete (process.stdin as { isTTY?: boolean }).isTTY;
+ process.chdir(cwd);
+ rmSync(root, { recursive: true, force: true });
+});
+
+async function statusline(argv: string[]): Promise<string> {
+ const parser = new CommandParser();
+ parser.registerCommand(hooksCommand);
+ const { flags } = parser.parse(['hooks', 'statusline', '--full', ...argv]);
+ const command = hooksCommand.subcommands!.find(c => c.name === 'statusline')!;
+ const result = await command.action!({ args: [], flags, cwd: root, interactive: false });
+ expect(result?.success).toBe(true);
+ return lines.join('\n');
+}
+
+describe('hooks statusline --no-color', () => {
+ it('prints no ANSI escape codes', async () => {
+ const text = await statusline(['--no-color']);
+ expect(text).toContain('RuFlo V3');
+ expect(text).not.toContain('\x1b[');
+ });
+
+ it('keeps colors without the flag', async () => {
+ expect(await statusline([])).toContain('\x1b[');
+ });
+});
diff --git a/v3/@claude-flow/cli/src/commands/hooks.ts b/v3/@claude-flow/cli/src/commands/hooks.ts
index b09f4c6fd5..f429cb7d66 100644
--- a/v3/@claude-flow/cli/src/commands/hooks.ts
+++ b/v3/@claude-flow/cli/src/commands/hooks.ts
@@ -4451,7 +4451,8 @@ const statuslineCommand: Command = {
}
// Full colored output
- const noColor = ctx.flags['no-color'] || ctx.flags.noColor;
+ // The parser stores `--no-color` as `color: false`.
+ const noColor = ctx.flags['no-color'] || ctx.flags.noColor || ctx.flags.color === false;
const c = noColor ? {
reset: '', bold: '', dim: '', red: '', green: '', yellow: '', blue: '',
purple: '', cyan: '', brightRed: '', brightGreen: '', brightYellow: '',