singularity-forge/src/claude-cli-check.ts
Mikael Hugo b24f426f2b batch: snapshot of in-flight v2 work
This commit captures uncommitted modifications that accumulated in the
working tree across multiple in-progress workstreams. It is a snapshot
to clear the deck before sf v3 work begins; individual workstreams
should land separately on top of this.

Notable additions:
- trace-collector.ts, traces.ts, src/tests/trace-export.test.ts —
  trace export plumbing
- biome.json — Biome linter configuration
- .gitignore — exclude native/npm/**/*.node compiled binaries

The bulk of the diff is across src/resources/extensions/sf/ (301 files)
and src/resources/extensions/sf/tests/ (277 files), reflecting the
ongoing sf extension work. Specific feature commits should follow this
snapshot rather than being archaeology'd out of it.

The 76MB native/npm/linux-x64-gnu/forge_engine.node compiled binary
was left out of the commit — it's now gitignored and built locally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-29 12:42:31 +02:00

42 lines
1 KiB
TypeScript

// sf — Claude CLI binary detection for onboarding
// Lightweight check used at onboarding time (before extensions load).
// The full readiness check with caching lives in the claude-code-cli extension.
import { execFileSync } from "node:child_process";
/**
* Check if the `claude` binary is installed (regardless of auth state).
*/
export function isClaudeBinaryInstalled(): boolean {
try {
execFileSync("claude", ["--version"], { timeout: 5_000, stdio: "pipe" });
return true;
} catch {
return false;
}
}
/**
* Check if the `claude` CLI is installed AND authenticated.
*/
export function isClaudeCliReady(): boolean {
try {
execFileSync("claude", ["--version"], { timeout: 5_000, stdio: "pipe" });
} catch {
return false;
}
try {
const output = execFileSync("claude", ["auth", "status"], {
timeout: 5_000,
stdio: "pipe",
})
.toString()
.toLowerCase();
return !/not logged in|no credentials|unauthenticated|not authenticated/i.test(
output,
);
} catch {
return false;
}
}