Skip to content
Source
Sign inSign up
pingdotgg/t3code

Introduce pluggable VCS driver foundation #2435

Mergedjuliusmarmingemerged 46 commits intomain fromrefs/pull/2435/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

this is a core rearchitecture we can add JJ, GitLab, BitBucket on top of later

Summary

  • Added a new vcs contract layer and typed VCS errors to replace Git-specific plumbing with provider-neutral abstractions.
  • Implemented the new GitVcsDriver and VcsProcess services, then rewired server code that previously depended on GitCore.
  • Migrated checkpointing, workspace, orchestration, and server integration paths to use the new VCS services.
  • Removed the old GitCore implementation and its tests in favor of the new driver-backed execution path.
  • Added version-control phase plans to document the follow-on provider abstraction work.

Testing

  • Not run (changes were not validated in this turn).
  • Expected validation: bun fmt
  • Expected validation: bun lint
  • Expected validation: bun typecheck

Note

High Risk Large refactor of core Git/VCS and source-control orchestration paths (status/PR/worktrees/checkpointing) to new VcsProcess/driver registries, which can break repo detection, caching, and PR workflows if behavior differs. Touches subprocess execution and typed error plumbing, increasing regression risk across many integration tests.

Overview Introduces a new VCS foundation: VcsProcess (Effect-native subprocess execution with bounded output/timeouts and typed errors) plus VcsDriverRegistry that detects/caches repositories and routes to GitVcsDriver.

Refactors server workflows to use these abstractions: checkpointing now executes Git commands via the registry and returns VcsError types; orchestration/integration harness wiring swaps GitCore/GitStatusBroadcaster for VcsDriverRegistry/VcsStatusBroadcaster and adds GitWorkflowService routing.

Reworks GitManager to depend on GitVcsDriver for local operations and SourceControlProviderRegistry for change-request operations (provider-neutral terminology, updated status/PR field names like refName/hasPrimaryRemote), with updated tests and a new provider-fallback test. Adds Phase 1/2 version-control plan docs under .plans/.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 9e3db6e3f891700b7088a823c3368405c03618df. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Introduce pluggable VCS driver foundation replacing Git-specific services with provider-neutral abstractions

  • Adds a VcsDriver interface and GitVcsDriver implementation behind a VcsDriverRegistry that resolves drivers by kind, with detection caching (2s TTL) and project-config discovery via .t3code/vcs.json
  • Introduces VcsProcess as a standardized subprocess abstraction for all VCS command execution, replacing direct GitCore usage throughout checkpointing, workspace indexing, and orchestration
  • Renames all WebSocket RPC methods from git.* to vcs.* (e.g. vcsListRefs, vcsSwitchRef, vcsCreateRef) and replaces subscribeGitStatus with subscribeVcsStatus; field names change from branch/hasOriginRemote/isDefaultBranch to refName/hasPrimaryRemote/isDefaultRef throughout
  • Adds a SourceControlProviderRegistry with a GitHubSourceControlProvider adapter and a SourceControlDiscovery service that probes locally available VCS tools and providers (GitHub, GitLab, Azure DevOps, Bitbucket); a new /settings/source-control settings panel surfaces discovery results
  • Introduces GitWorkflowService as a facade over GitVcsDriver + GitManager that returns empty non-repo results when no repository is detected, replacing direct GitCore/GitStatusBroadcaster dependencies in orchestration
  • Risk: all WebSocket RPC method names, subscription names, and status payload field names are breaking changes for any client not updated in this PR
Macroscope summarized 9e3db6e.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 9b72afe9-19aa-41ae-a95e-de88371d3c73

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `t3code/pluggable-git-integration`

      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Cursor Bugbot has reviewed your changes and found 1 potential issue.

      Autofix Details

      Bugbot Autofix prepared a fix for the issue found in the latest run.

      • ✅ Fixed: Execute method silently drops env field breaking checkpoints
        • Added env to gitCommand's options type and forwarded input.env from the execute method to gitCommand, so CheckpointStore's GIT_INDEX_FILE and author/committer overrides are now properly passed through to the spawned git process.

      Create PR

      Or push these changes by commenting:

      @cursor push 6506f41f19
      Preview (pingdotgg/t3code@6506f41f19)
      diff --git a/apps/server/src/vcs/Layers/GitVcsDriver.ts b/apps/server/src/vcs/Layers/GitVcsDriver.ts
      --- a/apps/server/src/vcs/Layers/GitVcsDriver.ts
      +++ b/apps/server/src/vcs/Layers/GitVcsDriver.ts
      @@ -69,6 +69,7 @@
         args: ReadonlyArray<string>,
         options?: {
           readonly stdin?: string;
      +    readonly env?: NodeJS.ProcessEnv;
           readonly allowNonZeroExit?: boolean;
           readonly timeoutMs?: number;
           readonly maxOutputBytes?: number;
      @@ -81,6 +82,7 @@
           args,
           cwd,
           ...(options?.stdin !== undefined ? { stdin: options.stdin } : {}),
      +    ...(options?.env !== undefined ? { env: options.env } : {}),
           ...(options?.allowNonZeroExit !== undefined
             ? { allowNonZeroExit: options.allowNonZeroExit }
             : {}),
      @@ -118,6 +120,7 @@
         const execute: VcsDriverShape["execute"] = (input) =>
           gitCommand(process, input.operation, input.cwd, input.args, {
             ...(input.stdin !== undefined ? { stdin: input.stdin } : {}),
      +      ...(input.env !== undefined ? { env: input.env } : {}),
             ...(input.allowNonZeroExit !== undefined ? { allowNonZeroExit: input.allowNonZeroExit } : {}),
             ...(input.timeoutMs !== undefined ? { timeoutMs: input.timeoutMs } : {}),
             ...(input.maxOutputBytes !== undefined ? { maxOutputBytes: input.maxOutputBytes } : {}),
      You can send follow-ups to the cloud agent here.
    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      1 blocking correctness issue found. Diff is too large for automated approval analysis. A human reviewer should evaluate this PR.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Cursor Bugbot has reviewed your changes and found 1 potential issue.

      There are 2 total unresolved issues (including 1 from previous review).

      Autofix Details

      Bugbot Autofix prepared a fix for the issue found in the latest run.

      • ✅ Fixed: VcsProcessExitError misused for non-exit validation failures
        • Replaced all three misuses of VcsProcessExitError (with fabricated exitCode values) with CheckpointInvariantError, which correctly represents application-level invariant violations rather than process exit failures.

      Create PR

      Or push these changes by commenting:

      @cursor push 9cbdcf4648
      Preview (pingdotgg/t3code@9cbdcf4648)
      diff --git a/apps/server/src/checkpointing/Layers/CheckpointStore.ts b/apps/server/src/checkpointing/Layers/CheckpointStore.ts
      --- a/apps/server/src/checkpointing/Layers/CheckpointStore.ts
      +++ b/apps/server/src/checkpointing/Layers/CheckpointStore.ts
      @@ -14,7 +14,6 @@
       import { Effect, Layer, FileSystem, Path } from "effect";
       
       import { CheckpointInvariantError } from "../Errors.ts";
      -import { VcsProcessExitError } from "@t3tools/contracts";
       import { VcsDriver } from "../../vcs/VcsDriver.ts";
       import { CheckpointStore, type CheckpointStoreShape } from "../Services/CheckpointStore.ts";
       import { CheckpointRef } from "@t3tools/contracts";
      @@ -128,11 +127,8 @@
               });
               const treeOid = writeTreeResult.stdout.trim();
               if (treeOid.length === 0) {
      -          return yield* new VcsProcessExitError({
      +          return yield* new CheckpointInvariantError({
                   operation,
      -            command: "git write-tree",
      -            cwd: input.cwd,
      -            exitCode: 0,
                   detail: "git write-tree returned an empty tree oid.",
                 });
               }
      @@ -146,11 +142,8 @@
               });
               const commitOid = commitTreeResult.stdout.trim();
               if (commitOid.length === 0) {
      -          return yield* new VcsProcessExitError({
      +          return yield* new CheckpointInvariantError({
                   operation,
      -            command: "git commit-tree",
      -            cwd: input.cwd,
      -            exitCode: 0,
                   detail: "git commit-tree returned an empty commit oid.",
                 });
               }
      @@ -234,11 +227,8 @@
             }
       
             if (!fromCommitOid || !toCommitOid) {
      -        return yield* new VcsProcessExitError({
      +        return yield* new CheckpointInvariantError({
                 operation,
      -          command: "git diff",
      -          cwd: input.cwd,
      -          exitCode: 1,
                 detail: "Checkpoint ref is unavailable for diff operation.",
               });
             }
      You can send follow-ups to the cloud agent here.
    6. Cursor Bugbot has reviewed your changes and found 1 potential issue.

      Autofix Details

      Bugbot Autofix prepared a fix for the issue found in the latest run.

      • ✅ Fixed: Uncached repository detection on every checkpoint git command
        • Added an in-memory Map cache in VcsDriverRegistry.resolve() keyed on cwd+requestedKind so that detectRepository() (which spawns 3 git processes) is only called once per unique path, eliminating ~18 unnecessary process spawns per checkpoint capture.

      Create PR

      Or push these changes by commenting:

      @cursor push 0f019fda3d
      Preview (pingdotgg/t3code@0f019fda3d)
      diff --git a/apps/server/src/vcs/VcsDriverRegistry.ts b/apps/server/src/vcs/VcsDriverRegistry.ts
      --- a/apps/server/src/vcs/VcsDriverRegistry.ts
      +++ b/apps/server/src/vcs/VcsDriverRegistry.ts
      @@ -40,6 +40,8 @@
           git,
         };
       
      +  const resolveCache = new Map<string, VcsDriverHandle>();
      +
         const detectWithDriver = Effect.fn("VcsDriverRegistry.detectWithDriver")(function* (
           kind: VcsDriverKind,
           driver: VcsDriverShape,
      @@ -78,12 +80,19 @@
       
         const resolve: VcsDriverRegistryShape["resolve"] = Effect.fn("VcsDriverRegistry.resolve")(
           function* (input) {
      +      const requestedKind = input.requestedKind ?? "auto";
      +      const cacheKey = `${input.cwd}\0${requestedKind}`;
      +      const cached = resolveCache.get(cacheKey);
      +      if (cached) {
      +        return cached;
      +      }
      +
             const detected = yield* detect(input);
             if (detected) {
      +        resolveCache.set(cacheKey, detected);
               return detected;
             }
       
      -      const requestedKind = input.requestedKind ?? "auto";
             return yield* unsupported(
               "VcsDriverRegistry.resolve",
               requestedKind === "auto" ? "unknown" : requestedKind,
      You can send follow-ups to the cloud agent here.
    7. Cursor Bugbot has reviewed your changes and found 1 potential issue.

      Autofix Details

      Bugbot Autofix prepared a fix for the issue found in the latest run.

      • ✅ Fixed: VcsStatusBroadcaster drops CWD symlink normalization from old code
        • Restored the normalizeCwd helper (using realpathSync.native) and added calls in getStatus, refreshLocalStatus, refreshStatus, and streamStatus to resolve symlinks before cache lookups and PubSub filtering, matching the old GitStatusBroadcasterLive behavior.

      Create PR

      Or push these changes by commenting:

      @cursor push 1c1db2f34e
      Preview (pingdotgg/t3code@1c1db2f34e)
      diff --git a/apps/server/src/vcs/VcsStatusBroadcaster.ts b/apps/server/src/vcs/VcsStatusBroadcaster.ts
      --- a/apps/server/src/vcs/VcsStatusBroadcaster.ts
      +++ b/apps/server/src/vcs/VcsStatusBroadcaster.ts
      @@ -1,3 +1,5 @@
      +import { realpathSync } from "node:fs";
      +
       import {
         Duration,
         Effect,
      @@ -63,6 +65,14 @@
         VcsStatusBroadcasterShape
       >()("t3/vcs/VcsStatusBroadcaster") {}
       
      +function normalizeCwd(cwd: string): string {
      +  try {
      +    return realpathSync.native(cwd);
      +  } catch {
      +    return cwd;
      +  }
      +}
      +
       function fingerprintStatusPart(status: unknown): string {
         return JSON.stringify(status);
       }
      @@ -188,16 +198,18 @@
           const getStatus: VcsStatusBroadcasterShape["getStatus"] = Effect.fn(
             "VcsStatusBroadcaster.getStatus",
           )(function* (input) {
      +      const cwd = normalizeCwd(input.cwd);
             const [local, remote] = yield* Effect.all([
      -        getOrLoadLocalStatus(input.cwd),
      -        getOrLoadRemoteStatus(input.cwd),
      +        getOrLoadLocalStatus(cwd),
      +        getOrLoadRemoteStatus(cwd),
             ]);
             return mergeGitStatusParts(local, remote);
           });
       
           const refreshLocalStatus: VcsStatusBroadcasterShape["refreshLocalStatus"] = Effect.fn(
             "VcsStatusBroadcaster.refreshLocalStatus",
      -    )(function* (cwd) {
      +    )(function* (rawCwd) {
      +      const cwd = normalizeCwd(rawCwd);
             yield* workflow.invalidateLocalStatus(cwd);
             const local = yield* workflow.localStatus({ cwd });
             return yield* updateCachedLocalStatus(cwd, local, { publish: true });
      @@ -213,7 +225,8 @@
       
           const refreshStatus: VcsStatusBroadcasterShape["refreshStatus"] = Effect.fn(
             "VcsStatusBroadcaster.refreshStatus",
      -    )(function* (cwd) {
      +    )(function* (rawCwd) {
      +      const cwd = normalizeCwd(rawCwd);
             const [local, remote] = yield* Effect.all([
               refreshLocalStatus(cwd),
               refreshRemoteStatus(cwd),
      @@ -299,12 +312,13 @@
           const streamStatus: VcsStatusBroadcasterShape["streamStatus"] = (input) =>
             Stream.unwrap(
               Effect.gen(function* () {
      +          const cwd = normalizeCwd(input.cwd);
                 const subscription = yield* PubSub.subscribe(changesPubSub);
      -          const initialLocal = yield* getOrLoadLocalStatus(input.cwd);
      -          const initialRemote = (yield* getCachedStatus(input.cwd))?.remote?.value ?? null;
      -          yield* retainRemotePoller(input.cwd);
      +          const initialLocal = yield* getOrLoadLocalStatus(cwd);
      +          const initialRemote = (yield* getCachedStatus(cwd))?.remote?.value ?? null;
      +          yield* retainRemotePoller(cwd);
       
      -          const release = releaseRemotePoller(input.cwd).pipe(Effect.ignore, Effect.asVoid);
      +          const release = releaseRemotePoller(cwd).pipe(Effect.ignore, Effect.asVoid);
       
                 return Stream.concat(
                   Stream.make({
      @@ -313,7 +327,7 @@
                     remote: initialRemote,
                   }),
                   Stream.fromSubscription(subscription).pipe(
      -              Stream.filter((event) => event.cwd === input.cwd),
      +              Stream.filter((event) => event.cwd === cwd),
                     Stream.map((event) => event.event),
                   ),
                 ).pipe(Stream.ensuring(release));
      You can send follow-ups to the cloud agent here.
    8. Cursor Bugbot has reviewed your changes and found 1 potential issue.

      Autofix Details

      Bugbot Autofix prepared a fix for the issue found in the latest run.

      • ✅ Fixed: Custom env silently dropped in VCS driver execute
        • Added env to the gitCommand options signature and forwarded input.env from the execute method through gitCommand to process.run, so GIT_INDEX_FILE and other environment variables are now properly passed to the spawned git processes.

      Create PR

      Or push these changes by commenting:

      @cursor push e4920a3ee7
      Preview (pingdotgg/t3code@e4920a3ee7)
      diff --git a/apps/server/src/vcs/GitVcsDriver.ts b/apps/server/src/vcs/GitVcsDriver.ts
      --- a/apps/server/src/vcs/GitVcsDriver.ts
      +++ b/apps/server/src/vcs/GitVcsDriver.ts
      @@ -257,6 +257,7 @@
         args: ReadonlyArray<string>,
         options?: {
           readonly stdin?: string;
      +    readonly env?: NodeJS.ProcessEnv;
           readonly allowNonZeroExit?: boolean;
           readonly timeoutMs?: number;
           readonly maxOutputBytes?: number;
      @@ -269,6 +270,7 @@
           args,
           cwd,
           ...(options?.stdin !== undefined ? { stdin: options.stdin } : {}),
      +    ...(options?.env !== undefined ? { env: options.env } : {}),
           ...(options?.allowNonZeroExit !== undefined
             ? { allowNonZeroExit: options.allowNonZeroExit }
             : {}),
      @@ -305,6 +307,7 @@
         const execute: VcsDriverShape["execute"] = (input) =>
           gitCommand(process, input.operation, input.cwd, input.args, {
             ...(input.stdin !== undefined ? { stdin: input.stdin } : {}),
      +      ...(input.env !== undefined ? { env: input.env } : {}),
             ...(input.allowNonZeroExit !== undefined ? { allowNonZeroExit: input.allowNonZeroExit } : {}),
             ...(input.timeoutMs !== undefined ? { timeoutMs: input.timeoutMs } : {}),
             ...(input.maxOutputBytes !== undefined ? { maxOutputBytes: input.maxOutputBytes } : {}),
      You can send follow-ups to the cloud agent here.
    9. Cursor Bugbot has reviewed your changes and found 1 potential issue.

      Autofix Details

      Bugbot Autofix prepared a fix for the issue found in the latest run.

      • ✅ Fixed: Dual exit code field names create fragile inconsistency
        • Renamed ExecuteGitResult.code to ExecuteGitResult.exitCode to match VcsProcessOutput.exitCode, unifying the exit code field name across both execute signatures and updating all 30+ references in GitVcsDriverCore.ts, SourceControlProviderRegistry.ts, and test files.

      Create PR

      Or push these changes by commenting:

      @cursor push 5f17833408
      Preview (pingdotgg/t3code@5f17833408)
      diff --git a/apps/server/src/git/GitManager.test.ts b/apps/server/src/git/GitManager.test.ts
      --- a/apps/server/src/git/GitManager.test.ts
      +++ b/apps/server/src/git/GitManager.test.ts
      @@ -224,7 +224,7 @@
             allowNonZeroExit,
           });
           return {
      -      code: result.code,
      +      code: result.exitCode,
             stdout: result.stdout,
             stderr: result.stderr,
           };
      
      diff --git a/apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts b/apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts
      --- a/apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts
      +++ b/apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts
      @@ -8,7 +8,7 @@
       const processResult = (stdout: string) => ({
         stdout,
         stderr: "",
      -  code: 0,
      +  exitCode: 0,
         signal: null,
         timedOut: false,
         stdoutTruncated: false,
      
      diff --git a/apps/server/src/sourceControl/SourceControlProviderRegistry.ts b/apps/server/src/sourceControl/SourceControlProviderRegistry.ts
      --- a/apps/server/src/sourceControl/SourceControlProviderRegistry.ts
      +++ b/apps/server/src/sourceControl/SourceControlProviderRegistry.ts
      @@ -89,7 +89,7 @@
                 })
                 .pipe(
                   Effect.map((result) =>
      -              result.code === 0 ? firstRemoteUrlFromVerboseOutput(result.stdout) : null,
      +              result.exitCode === 0 ? firstRemoteUrlFromVerboseOutput(result.stdout) : null,
                   ),
                   Effect.mapError((error) => providerDetectionError("detectProvider", cwd, error)),
                 ));
      
      diff --git a/apps/server/src/vcs/GitVcsDriver.ts b/apps/server/src/vcs/GitVcsDriver.ts
      --- a/apps/server/src/vcs/GitVcsDriver.ts
      +++ b/apps/server/src/vcs/GitVcsDriver.ts
      @@ -35,7 +35,7 @@
       }
       
       export interface ExecuteGitResult {
      -  readonly code: number;
      +  readonly exitCode: number;
         readonly stdout: string;
         readonly stderr: string;
         readonly stdoutTruncated: boolean;
      
      diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.ts
      --- a/apps/server/src/vcs/GitVcsDriverCore.ts
      +++ b/apps/server/src/vcs/GitVcsDriverCore.ts
      @@ -693,7 +693,7 @@
               }
       
               return {
      -          code: exitCode,
      +          exitCode,
                 stdout: stdout.text,
                 stderr: stderr.text,
                 stdoutTruncated: stdout.truncated,
      @@ -761,7 +761,7 @@
             ...(options.progress ? { progress: options.progress } : {}),
           }).pipe(
             Effect.flatMap((result) => {
      -        if (options.allowNonZeroExit || result.code === 0) {
      +        if (options.allowNonZeroExit || result.exitCode === 0) {
                 return Effect.succeed(result);
               }
               const stderr = result.stderr.trim();
      @@ -778,7 +778,7 @@
                   operation,
                   cwd,
                   args,
      -            `${commandLabel(args)} failed: code=${result.code ?? "null"}`,
      +            `${commandLabel(args)} failed: code=${result.exitCode ?? "null"}`,
                 ),
               );
             }),
      @@ -823,7 +823,7 @@
               allowNonZeroExit: true,
               timeoutMs: 5_000,
             },
      -    ).pipe(Effect.map((result) => result.code === 0));
      +    ).pipe(Effect.map((result) => result.exitCode === 0));
       
         const resolveAvailableBranchName = Effect.fn("resolveAvailableBranchName")(function* (
           cwd: string,
      @@ -939,7 +939,7 @@
             { allowNonZeroExit: true },
           ).pipe(
             Effect.map((result) => {
      -        if (result.code !== 0) {
      +        if (result.exitCode !== 0) {
                 return null;
               }
               return parseDefaultBranchFromRemoteHeadRef(result.stdout, remoteName);
      @@ -958,12 +958,12 @@
             {
               allowNonZeroExit: true,
             },
      -    ).pipe(Effect.map((result) => result.code === 0));
      +    ).pipe(Effect.map((result) => result.exitCode === 0));
       
         const originRemoteExists = (cwd: string): Effect.Effect<boolean, GitCommandError> =>
           executeGit("GitVcsDriver.originRemoteExists", cwd, ["remote", "get-url", "origin"], {
             allowNonZeroExit: true,
      -    }).pipe(Effect.map((result) => result.code === 0));
      +    }).pipe(Effect.map((result) => result.exitCode === 0));
       
         const listRemoteNames = (cwd: string): Effect.Effect<ReadonlyArray<string>, GitCommandError> =>
           runGitStdout("GitVcsDriver.listRemoteNames", cwd, ["remote"]).pipe(
      @@ -1115,7 +1115,7 @@
             ["rev-list", "--count", `${baseRef}..HEAD`],
             { allowNonZeroExit: true },
           );
      -    if (result.code !== 0) {
      +    if (result.exitCode !== 0) {
             return 0;
           }
       
      @@ -1140,7 +1140,7 @@
           );
       
           const branchLastCommit = new Map<string, number>();
      -    if (branchRecency.code !== 0) {
      +    if (branchRecency.exitCode !== 0) {
             return branchLastCommit;
           }
       
      @@ -1173,7 +1173,7 @@
             return NON_REPOSITORY_STATUS_DETAILS;
           }
       
      -    if (statusResult.code !== 0) {
      +    if (statusResult.exitCode !== 0) {
             const stderr = statusResult.stderr.trim();
             return yield* createGitCommandError(
               "GitVcsDriver.statusDetails.status",
      @@ -1206,7 +1206,7 @@
             );
           const statusStdout = statusResult.stdout;
           const defaultBranch =
      -      defaultRefResult.code === 0
      +      defaultRefResult.exitCode === 0
               ? defaultRefResult.stdout.trim().replace(/^refs\/remotes\/origin\//, "")
               : null;
       
      @@ -1614,7 +1614,7 @@
           ).pipe(
             Effect.catchIf(isMissingGitCwdError, () =>
               Effect.succeed({
      -          code: 128,
      +          exitCode: 128,
                 stdout: "",
                 stderr: "fatal: not a git repository",
                 stdoutTruncated: false,
      @@ -1623,7 +1623,7 @@
             ),
           );
       
      -    if (localBranchResult.code !== 0) {
      +    if (localBranchResult.exitCode !== 0) {
             const stderr = localBranchResult.stderr.trim();
             if (stderr.toLowerCase().includes("not a git repository")) {
               return {
      @@ -1654,7 +1654,7 @@
             Effect.catch((error) =>
               Effect.logWarning(
                 `GitVcsDriver.listRefs: remote refName lookup failed for ${input.cwd}: ${error.message}. Falling back to an empty remote refName list.`,
      -        ).pipe(Effect.as({ code: 1, stdout: "", stderr: "" })),
      +        ).pipe(Effect.as({ exitCode: 1, stdout: "", stderr: "" })),
             ),
           );
       
      @@ -1670,7 +1670,7 @@
             Effect.catch((error) =>
               Effect.logWarning(
                 `GitVcsDriver.listRefs: remote name lookup failed for ${input.cwd}: ${error.message}. Falling back to an empty remote name list.`,
      -        ).pipe(Effect.as({ code: 1, stdout: "", stderr: "" })),
      +        ).pipe(Effect.as({ exitCode: 1, stdout: "", stderr: "" })),
             ),
           );
       
      @@ -1703,25 +1703,25 @@
             );
       
           const remoteNames =
      -      remoteNamesResult.code === 0 ? parseRemoteNames(remoteNamesResult.stdout) : [];
      -    if (remoteBranchResult.code !== 0 && remoteBranchResult.stderr.trim().length > 0) {
      +      remoteNamesResult.exitCode === 0 ? parseRemoteNames(remoteNamesResult.stdout) : [];
      +    if (remoteBranchResult.exitCode !== 0 && remoteBranchResult.stderr.trim().length > 0) {
             yield* Effect.logWarning(
      -        `GitVcsDriver.listRefs: remote refName lookup returned code ${remoteBranchResult.code} for ${input.cwd}: ${remoteBranchResult.stderr.trim()}. Falling back to an empty remote refName list.`,
      +        `GitVcsDriver.listRefs: remote refName lookup returned code ${remoteBranchResult.exitCode} for ${input.cwd}: ${remoteBranchResult.stderr.trim()}. Falling back to an empty remote refName list.`,
             );
           }
      -    if (remoteNamesResult.code !== 0 && remoteNamesResult.stderr.trim().length > 0) {
      +    if (remoteNamesResult.exitCode !== 0 && remoteNamesResult.stderr.trim().length > 0) {
             yield* Effect.logWarning(
      -        `GitVcsDriver.listRefs: remote name lookup returned code ${remoteNamesResult.code} for ${input.cwd}: ${remoteNamesResult.stderr.trim()}. Falling back to an empty remote name list.`,
      +        `GitVcsDriver.listRefs: remote name lookup returned code ${remoteNamesResult.exitCode} for ${input.cwd}: ${remoteNamesResult.stderr.trim()}. Falling back to an empty remote name list.`,
             );
           }
       
           const defaultBranch =
      -      defaultRef.code === 0
      +      defaultRef.exitCode === 0
               ? defaultRef.stdout.trim().replace(/^refs\/remotes\/origin\//, "")
               : null;
       
           const worktreeMap = new Map<string, string>();
      -    if (worktreeList.code === 0) {
      +    if (worktreeList.exitCode === 0) {
             let currentPath: string | null = null;
             for (const line of worktreeList.stdout.split("\n")) {
               if (line.startsWith("worktree ")) {
      @@ -1762,7 +1762,7 @@
             });
       
           const remoteBranches =
      -      remoteBranchResult.code === 0
      +      remoteBranchResult.exitCode === 0
               ? remoteBranchResult.stdout
                   .split("\n")
                   .map(parseBranchLine)
      @@ -1943,7 +1943,7 @@
                   timeoutMs: 5_000,
                   allowNonZeroExit: true,
                 },
      -        ).pipe(Effect.map((result) => result.code === 0)),
      +        ).pipe(Effect.map((result) => result.exitCode === 0)),
               executeGit(
                 "GitVcsDriver.switchRef.remoteExists",
                 input.cwd,
      @@ -1952,7 +1952,7 @@
                   timeoutMs: 5_000,
                   allowNonZeroExit: true,
                 },
      -        ).pipe(Effect.map((result) => result.code === 0)),
      +        ).pipe(Effect.map((result) => result.exitCode === 0)),
             ],
             { concurrency: "unbounded" },
           );
      @@ -1968,7 +1968,7 @@
                 },
               ).pipe(
                 Effect.map((result) =>
      -            result.code === 0
      +            result.exitCode === 0
                     ? parseTrackingBranchByUpstreamRef(result.stdout, input.refName)
                     : null,
                 ),
      @@ -1986,7 +1986,7 @@
                     timeoutMs: 5_000,
                     allowNonZeroExit: true,
                   },
      -          ).pipe(Effect.map((result) => result.code === 0))
      +          ).pipe(Effect.map((result) => result.exitCode === 0))
               : false;
       
           const checkoutArgs = localInputExists
      You can send follow-ups to the cloud agent here.
    10. Cursor Bugbot has reviewed your changes and found 1 potential issue.

      There are 2 total unresolved issues (including 1 from previous review).

      Autofix Details

      Bugbot Autofix prepared a fix for the issue found in the latest run.

      • ✅ Fixed: Missing empty-stdout guard breaks PR lookup loop
        • Added an empty-string guard before JSON decoding in the non-open state branch of listChangeRequests, returning an empty array when stdout is empty so the findLatestPr loop can continue trying remaining head selectors.

      Create PR

      Or push these changes by commenting:

      @cursor push d5fa9c0593
      Preview (pingdotgg/t3code@d5fa9c0593)
      diff --git a/apps/server/src/sourceControl/GitHubSourceControlProvider.ts b/apps/server/src/sourceControl/GitHubSourceControlProvider.ts
      --- a/apps/server/src/sourceControl/GitHubSourceControlProvider.ts
      +++ b/apps/server/src/sourceControl/GitHubSourceControlProvider.ts
      @@ -76,8 +76,12 @@
               ],
             })
             .pipe(
      -        Effect.flatMap((result) =>
      -          Effect.sync(() => decodeGitHubPullRequestListJson(result.stdout.trim())).pipe(
      +        Effect.flatMap((result) => {
      +          const raw = result.stdout.trim();
      +          if (raw.length === 0) {
      +            return Effect.succeed([]);
      +          }
      +          return Effect.sync(() => decodeGitHubPullRequestListJson(raw)).pipe(
                   Effect.flatMap((decoded) =>
                     Result.isSuccess(decoded)
                       ? Effect.succeed(
      @@ -95,8 +99,8 @@
                           }),
                         ),
                   ),
      -          ),
      -        ),
      +          );
      +        }),
               Effect.mapError((error) =>
                 Schema.is(SourceControlProviderError)(error)
                   ? error
      You can send follow-ups to the cloud agent here.
    11. Cursor Bugbot has reviewed your changes and found 1 potential issue.

      There are 2 total unresolved issues (including 1 from previous review).

      Autofix Details

      Bugbot Autofix prepared a fix for the issue found in the latest run.

      • ✅ Fixed: Provider resolution failure bypasses default branch fallback
        • Wrapped both sourceControlProvider(cwd) resolution and .getDefaultBranch() in a single Effect pipeline using Effect.flatMap, so Effect.catch now handles failures from either step and the "main" fallback is always reachable.

      Create PR

      Or push these changes by commenting:

      @cursor push b73e16cbcc
      Preview (pingdotgg/t3code@b73e16cbcc)
      diff --git a/apps/server/src/git/GitManager.ts b/apps/server/src/git/GitManager.ts
      --- a/apps/server/src/git/GitManager.ts
      +++ b/apps/server/src/git/GitManager.ts
      @@ -1045,9 +1045,10 @@
             }
           }
       
      -    const defaultFromProvider = yield* (yield* sourceControlProvider(cwd))
      -      .getDefaultBranch({ cwd })
      -      .pipe(Effect.catch(() => Effect.succeed(null)));
      +    const defaultFromProvider = yield* sourceControlProvider(cwd).pipe(
      +      Effect.flatMap((provider) => provider.getDefaultBranch({ cwd })),
      +      Effect.catch(() => Effect.succeed(null)),
      +    );
           if (defaultFromProvider) {
             return defaultFromProvider;
           }
      You can send follow-ups to the cloud agent here.
    12. Cursor Bugbot has reviewed your changes and found 1 potential issue.

      There are 3 total unresolved issues (including 2 from previous reviews).

      Autofix Details

      Bugbot Autofix prepared a fix for the issue found in the latest run.

      • ✅ Fixed: Local variable shadows outer sourceControlProvider function
        • Renamed the local variable from sourceControlProvider to hostingProvider inside readLocalStatus to eliminate the shadowing of the outer sourceControlProvider function, while preserving the sourceControlProvider key in the returned object.

      Create PR

      Or push these changes by commenting:

      @cursor push fde1ecb449
      Preview (pingdotgg/t3code@fde1ecb449)
      diff --git a/apps/server/src/git/GitManager.ts b/apps/server/src/git/GitManager.ts
      --- a/apps/server/src/git/GitManager.ts
      +++ b/apps/server/src/git/GitManager.ts
      @@ -699,13 +699,13 @@
             .pipe(
               Effect.catchIf(isNotGitRepositoryError, () => Effect.succeed(nonRepositoryStatusDetails)),
             );
      -    const sourceControlProvider = details.isRepo
      +    const hostingProvider = details.isRepo
             ? yield* resolveHostingProvider(cwd, details.branch)
             : null;
       
           return {
             isRepo: details.isRepo,
      -      ...(sourceControlProvider ? { sourceControlProvider } : {}),
      +      ...(hostingProvider ? { sourceControlProvider: hostingProvider } : {}),
             hasPrimaryRemote: details.hasOriginRemote,
             isDefaultRef: details.isDefaultBranch,
             refName: details.branch,
      You can send follow-ups to the cloud agent here.
    13. @cursor push fde1ecb449

    14. apps/server/src/git/GitManager.ts line 125Resolvedby juliusmarminge
    15. @@ -496,2 +448,2 @@
      496448
      497449 if (event === "child_exit") {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium vcs/GitVcsDriverCore.ts:449

      Line 451 references traceRecord.success.exitCode, but git trace2 child_exit events use the field name code, not exitCode. Since exitCode does not exist on the trace record, code is always undefined, so the typeof code === "number" check on line 452 always fails and exitCode is always null for hook finished events. The diff shows this was incorrectly changed from .code to .exitCode.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file apps/server/src/vcs/GitVcsDriverCore.ts around line 449:
      
      Line 451 references `traceRecord.success.exitCode`, but git trace2 `child_exit` events use the field name `code`, not `exitCode`. Since `exitCode` does not exist on the trace record, `code` is always `undefined`, so the `typeof code === "number"` check on line 452 always fails and `exitCode` is always `null` for hook finished events. The diff shows this was incorrectly changed from `.code` to `.exitCode`.
      
      Evidence trail:
      1. apps/server/src/vcs/GitVcsDriverCore.ts line 451: `const code = traceRecord.success.exitCode;` (at REVIEWED_COMMIT)
      2. apps/server/src/vcs/GitVcsDriverCore.ts line 452: `const exitCode = typeof code === "number" && Number.isInteger(code) ? code : null;`
      3. Trace2Record schema at line 387: `const Trace2Record = Schema.Record(Schema.String, Schema.Unknown);` — produces Record<string, unknown>
      4. Git trace2 documentation: https://git-scm.com/docs/api-trace2 — child_exit event format shows field name is `code`, not `exitCode`:
         [code fence]json
         {"event":"child_exit", "child_id":2, "pid":14708, "code":0, "t_rel":0.110605}
         [code fence]
      5. PR diff shows file is entirely new (`--- /dev/null`, `new file mode 100644`) — sub-claim about 'diff showing change from .code to .exitCode' is incorrect but ancillary
    16. Cursor Bugbot has reviewed your changes and found 1 potential issue.

      Fix All in Cursor

      Bugbot Autofix prepared a fix for the issue found in the latest run.

      • ✅ Fixed: Unhandled provider error aborts action before commit/push
        • Wrapped the sourceControlProvider() call in runStackedAction with Effect.catch fallback to getChangeRequestTerminologyForKind("unknown"), matching the existing pattern in buildCompletionToast.

      Create PR

      Or push these changes by commenting:

      @cursor push 6dd13497dc
      Preview (pingdotgg/t3code@6dd13497dc)
      diff --git a/apps/server/src/git/GitManager.ts b/apps/server/src/git/GitManager.ts
      --- a/apps/server/src/git/GitManager.ts
      +++ b/apps/server/src/git/GitManager.ts
      @@ -1663,7 +1663,10 @@
               const currentBranch = branchStep.name ?? initialStatus.branch;
               const commitAction = isCommitAction(input.action) ? input.action : null;
               const changeRequestTerms = wantsPr
      -          ? getChangeRequestTerminologyForKind((yield* sourceControlProvider(input.cwd)).kind)
      +          ? yield* sourceControlProvider(input.cwd).pipe(
      +              Effect.map((provider) => getChangeRequestTerminologyForKind(provider.kind)),
      +              Effect.catch(() => Effect.succeed(getChangeRequestTerminologyForKind("unknown"))),
      +            )
                 : null;
       
               const commit = commitAction
      You can send follow-ups to the cloud agent here. Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 76dc275c515442450b433b0d7c0971c216107dfc. Configure [here](https://www.cursor.com/dashboard/bugbot).
    17. @cursor push 6dd13497dc

    18. juliusmarminge merged this6d7fe2e

    19. juliusmarminge closed this

Sign in to join this conversation.