fix(worktree): resolve Git executable outside PATH#1776
Conversation
Resolve Git through the platform layer so Windows worktree setup still works when AO is launched with a degraded PATH.
Test Coverage Report
Uncovered lines
|
Greptile SummaryThis PR fixes worktree operations failing with a raw
Confidence Score: 5/5Safe to merge — the change is additive, well-tested across all platform branches, and correctly follows the established caching and cross-platform patterns already in platform.ts. All changed code paths are covered by explicit tests (PATH hit, Windows/macOS/Linux fallback candidates, bare-git fallback). The findOnPath generalisation preserves existing Windows shell-resolution behaviour because pathDelimiterForCurrentPlatform() still returns ';' on Windows. Caching mirrors the getShell() pattern exactly, and the ENOENT enrichment in git() is a strict improvement with no regression risk. No files require special attention.
|
| Filename | Overview |
|---|---|
| packages/core/src/platform.ts | Adds cross-platform getGitExecutable() with PATH-walk, platform-specific fallback candidates, and caching; findOnPath is properly generalised from Windows-only to cross-platform using platform-aware delimiters and separators. |
| packages/core/src/index.ts | Exports getGitExecutable from the core package; _resetGitExecutableCache is correctly kept internal (not re-exported). |
| packages/plugins/workspace-worktree/src/index.ts | Replaces bare "git" with getGitExecutable() in both git() and exists(); git() now wraps ENOENT with a user-readable message. exists() still silently returns false on all errors, which is the correct semantic for an existence check. |
| packages/core/src/tests/platform.test.ts | Adds synchronous PATH-walk test and three async branch tests (Windows fallback, macOS Homebrew, Linux bare-git) using vi.doMock + vi.resetModules() + dynamic import() for per-test existsSync isolation; cache reset is properly handled via _resetGitExecutableCache() in beforeEach/afterEach. |
| packages/plugins/workspace-worktree/src/tests/index.test.ts | Adds getGitExecutable to the @aoagents/ao-core mock so existing worktree tests continue to compile and pass after the new import. |
Reviews (3): Last reviewed commit: "fix(worktree): satisfy platform test lin..." | Re-trigger Greptile
Cache Git executable resolution and cover fallback branches so worktree setup avoids repeated filesystem probes while preserving cross-platform behavior.
Avoid import() type annotations in mocked platform tests while keeping fallback branch coverage intact.
Summary
closes #1777
Test plan
pnpm --filter @aoagents/ao-core test -- src/__tests__/platform.test.tspnpm --filter @aoagents/ao-core typecheck && pnpm --filter @aoagents/ao-core build && pnpm --filter @aoagents/ao-plugin-workspace-worktree typecheck && pnpm --filter @aoagents/ao-plugin-workspace-worktree buildgetGitExecutable()resolvesC:\Program Files\Git\cmd\git.exeandworkspaceExists=true