diff --git a/v3/@claude-flow/cli/__tests__/windows-devnull-redirects-4770.test.ts b/v3/@claude-flow/cli/__tests__/windows-devnull-redirects-4770.test.ts index 28eb414cf8..3805345ce6 100644 --- a/v3/@claude-flow/cli/__tests__/windows-devnull-redirects-4770.test.ts +++ b/v3/@claude-flow/cli/__tests__/windows-devnull-redirects-4770.test.ts @@ -5,10 +5,12 @@ import { join } from 'node:path'; import { getGitUncommittedCount } from '../src/funnel/local-signals.js'; describe('#4770 no /dev/null redirects', () => { - it('init does not redirect stderr to /dev/null', () => { - const src = readFileSync(join(__dirname, '../src/commands/init.ts'), 'utf-8'); - expect(src).not.toMatch(/2>\s*\/dev\/null/); - }); + for (const file of ['commands/init.ts', 'commands/analyze.ts', 'commands/security.ts', 'appliance/rvfa-builder.ts']) { + it(`${file} does not redirect stderr to /dev/null`, () => { + const src = readFileSync(join(__dirname, '../src', file), 'utf-8'); + expect(src).not.toMatch(/2>\s*\/dev\/null/); + }); + } it('getGitUncommittedCount returns a number in a git checkout', () => { // Was always undefined on Windows. diff --git a/v3/@claude-flow/cli/src/appliance/rvfa-builder.ts b/v3/@claude-flow/cli/src/appliance/rvfa-builder.ts index 0b3db06ea2..514e12ee1e 100644 --- a/v3/@claude-flow/cli/src/appliance/rvfa-builder.ts +++ b/v3/@claude-flow/cli/src/appliance/rvfa-builder.ts @@ -198,7 +198,11 @@ export class RvfaBuilder { private buildRufloSection(): Buffer { let packageMeta: Record | null = null; try { - const raw = execSync('npm pack ruflo@latest --dry-run --json 2>/dev/null', { encoding: 'utf-8', timeout: 15_000 }); + const raw = execSync('npm pack ruflo@latest --dry-run --json', { + encoding: 'utf-8', + timeout: 15_000, + stdio: ['ignore', 'pipe', 'pipe'], + }); const parsed = JSON.parse(raw); if (Array.isArray(parsed) && parsed.length > 0) packageMeta = parsed[0]; } catch { /* manifest-only fallback */ } diff --git a/v3/@claude-flow/cli/src/commands/analyze.ts b/v3/@claude-flow/cli/src/commands/analyze.ts index faaec1edc3..b0f04b61c5 100644 --- a/v3/@claude-flow/cli/src/commands/analyze.ts +++ b/v3/@claude-flow/cli/src/commands/analyze.ts @@ -1495,7 +1495,19 @@ const depsCommand: Command = { output.writeln(output.dim('-'.repeat(60))); try { - const auditRaw = execSync('npm audit --json 2>/dev/null', { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 }); + let auditRaw: string; + try { + auditRaw = execSync('npm audit --json', { + encoding: 'utf-8', + maxBuffer: 10 * 1024 * 1024, + stdio: ['pipe', 'pipe', 'pipe'], + }); + } catch (auditErr: unknown) { + // npm audit exits non-zero when vulnerabilities found — stdout still has JSON + const stdout = auditErr instanceof Error && 'stdout' in auditErr ? (auditErr as { stdout: string }).stdout : ''; + if (!stdout) throw auditErr; + auditRaw = stdout; + } const audit = JSON.parse(auditRaw); const vulns = audit.metadata?.vulnerabilities || audit.vulnerabilities || {}; const info = vulns.info || 0; diff --git a/v3/@claude-flow/cli/src/commands/security.ts b/v3/@claude-flow/cli/src/commands/security.ts index 751e8c94db..133feecf34 100644 --- a/v3/@claude-flow/cli/src/commands/security.ts +++ b/v3/@claude-flow/cli/src/commands/security.ts @@ -505,7 +505,7 @@ const cveCommand: Command = { // If --check CVE-XXXX is given, filter to that specific CVE ID. let auditJson: string; try { - auditJson = execSync('npm audit --json 2>/dev/null', { + auditJson = execSync('npm audit --json', { encoding: 'utf-8', timeout: 30000, stdio: ['pipe', 'pipe', 'pipe'],