Four IEnvironmentCheck implementations in src/ClaudeDo.Installer/Checks/: - ClaudeCliCheck (Error) — resolves ctx.ClaudeBin via ExecutableResolver, runs --version; failure message lists searched PATH entries + fallback dirs, flags shim resolution (.cmd/.ps1) in Detail. - ClaudeVersionCheck (Error) — tolerant version parsing (ignores surrounding text), numeric System.Version comparison against a named floor constant (2.1.220, see docs/explore-notes/installer-preflight.md §3). Unparseable or missing CLI -> Unknown, never Failed. - ClaudeAuthCheck (Error) — `claude auth status --json`, never sends a prompt. - PermissionModeAutoCheck (Warning) — per the note's §2 conclusion, real auto-mode eligibility (org/model/plan) has no cheap static signal, so this only confirms `claude --help` still lists "auto" as a --permission-mode choice. Kept as its own check rather than folded into ClaudeVersionCheck, since the note explicitly separates "flag recognized" from "mode eligible" and only the former is checkable at all. All four share a new ClaudeCliLookup that resolves the CLI and runs --version exactly once per install run (memoized, semaphore-guarded), so none of the three version-dependent checks repeats that call. Foundation prerequisites this task depends on (docs/explore-notes/ installer-preflight.md, ExecutableResolver, the IEnvironmentCheck/CheckResult/ EnvironmentCheckService abstraction, ProcessCommand, IProcessRunner) existed only on an unmerged sibling branch, not on main. Rather than merging that whole unreviewed branch, the specific prerequisite files were copied in as-is (git history shows their origin). GitCheck/GitIdentityCheck/PortCheck/ WriteAccessCheck from that branch were intentionally NOT brought in — out of scope for this task. Deviations/decisions worth flagging: - Added ExecutableResolver.FallbackDirectories() (public) so ClaudeCliCheck can name the checked fallback locations in its failure message; the prior branch kept that list private. - Paths.cs now qualifies System.Environment explicitly. Adding the ClaudeDo.Data.Environment namespace makes bare `Environment.X` inside any ClaudeDo.Data.* namespace resolve to the sibling namespace instead of System.Environment (C# prefers nested/enclosing namespace members over usings) — this broke the build until qualified. Not done (explicitly out of scope): no DI wiring into the wizard UI, no XAML — matches how the prerequisite Git/Port/WriteAccess checks were also left unwired.
55 lines
2.0 KiB
C#
55 lines
2.0 KiB
C#
using ClaudeDo.Installer.Core;
|
|
|
|
namespace ClaudeDo.Installer.Checks;
|
|
|
|
/// <summary>Gates the CLI flags ClaudeArgsBuilder relies on — blocking.</summary>
|
|
public sealed class ClaudeVersionCheck : IEnvironmentCheck
|
|
{
|
|
public const string CheckId = "claude-version";
|
|
|
|
/// <summary>
|
|
/// Newest version confirmed to work end-to-end with every flag ClaudeDo uses (--permission-mode
|
|
/// auto, --effort, --agents, --json-schema, --append-system-prompt, --output-format stream-json
|
|
/// --verbose, --resume, mcp add --transport http --scope user). A verified floor, not a proven
|
|
/// theoretical minimum — see docs/explore-notes/installer-preflight.md §3.
|
|
/// </summary>
|
|
public static readonly Version MinimumVersion = new(2, 1, 220);
|
|
|
|
private readonly ClaudeCliLookup _lookup;
|
|
|
|
public ClaudeVersionCheck(ClaudeCliLookup lookup)
|
|
{
|
|
_lookup = lookup;
|
|
}
|
|
|
|
public string Id => CheckId;
|
|
public CheckSeverity Severity => CheckSeverity.Error;
|
|
|
|
public async Task<CheckResult> RunAsync(InstallContext ctx, CancellationToken ct)
|
|
{
|
|
var lookup = await _lookup.ResolveAsync(ctx, ct);
|
|
|
|
if (lookup.Resolved is null)
|
|
{
|
|
return CheckResult.Unknown(Id, Severity, "checks.claudeVersion.title",
|
|
"The claude CLI was not found — version could not be checked.");
|
|
}
|
|
|
|
if (lookup.ExitCode != 0 || lookup.ParsedVersion is null)
|
|
{
|
|
return CheckResult.Unknown(Id, Severity, "checks.claudeVersion.title",
|
|
$"Could not parse a version from '{lookup.Output.Trim()}'.");
|
|
}
|
|
|
|
if (lookup.ParsedVersion < MinimumVersion)
|
|
{
|
|
return CheckResult.Fail(Id, Severity, "checks.claudeVersion.title",
|
|
$"claude {lookup.ParsedVersion} is older than the required {MinimumVersion}.",
|
|
"checks.claudeVersion.hint");
|
|
}
|
|
|
|
return CheckResult.Ok(Id, Severity, "checks.claudeVersion.title",
|
|
$"claude {lookup.ParsedVersion} meets the minimum ({MinimumVersion}).");
|
|
}
|
|
}
|