Fix MCP file discovery errors (#9)

* fix tool errors

*QA
This commit is contained in:
Shawn Morreau
2025-12-17 11:29:27 -05:00
committed by GitHub
parent a88b3d18ce
commit 6716183068
7 changed files with 6909 additions and 7559 deletions
+19 -5
View File
@@ -1,6 +1,7 @@
import { execSync } from "node:child_process";
import { existsSync, rmSync } from "node:fs";
import type { Context } from "../main.ts";
import { checkoutPrBranch } from "../mcp/checkout.ts";
import { log } from "./cli.ts";
import { $ } from "./shell.ts";
@@ -72,11 +73,11 @@ export function setupGitConfig(): void {
/**
* Setup git authentication for the repository.
* PR checkout is handled dynamically by the checkout_pr MCP tool.
* For PR events, uses the shared checkoutPrBranch helper (also used by checkout_pr MCP tool).
*
* FORK PR ARCHITECTURE (handled by checkout_pr tool):
* FORK PR ARCHITECTURE:
* - origin: always points to BASE REPO (where PR targets)
* - checkout_pr sets per-branch pushRemote config for fork PRs
* - checkoutPrBranch sets per-branch pushRemote config for fork PRs
* - diff operations use: git diff origin/<base>..HEAD
*/
export async function setupGit(ctx: Context): Promise<void> {
@@ -95,8 +96,21 @@ export async function setupGit(ctx: Context): Promise<void> {
log.debug("no existing authentication headers to remove");
}
// authenticate origin - needed for all fetch operations including PR fetches
// non-PR events: set up origin with token, stay on default branch
if (ctx.payload.event.is_pr !== true || !ctx.payload.event.issue_number) {
const originUrl = `https://x-access-token:${ctx.githubInstallationToken}@github.com/${ctx.owner}/${ctx.name}.git`;
$("git", ["remote", "set-url", "origin", originUrl], { cwd: repoDir });
log.info("✓ Updated origin URL with authentication token");
return;
}
// PR event: checkout PR branch using shared helper
const prNumber = ctx.payload.event.issue_number;
// ensure origin is configured with auth token before checkout
const originUrl = `https://x-access-token:${ctx.githubInstallationToken}@github.com/${ctx.owner}/${ctx.name}.git`;
$("git", ["remote", "set-url", "origin", originUrl], { cwd: repoDir });
log.info("✓ updated origin URL with authentication token");
// use shared checkout helper (handles fork remotes, push config, etc.)
await checkoutPrBranch(ctx, prNumber);
}