Frontmatter
| title | fix: Add cwd to PullRequestService execAsync calls (#9895) |
| author | tobiu |
| state | Merged |
| createdAt | Apr 11, 2026, 10:15 PM |
| updatedAt | Apr 11, 2026, 10:19 PM |
| closedAt | Apr 11, 2026, 10:19 PM |
| mergedAt | Apr 11, 2026, 10:19 PM |
| branches | dev ← agent/9895-pr-service-cwd-fix |
| url | https://github.com/neomjs/neo/pull/9896 |
Merged

tobiu
commented on Apr 11, 2026, 10:17 PM
Input from Claude Opus 4.6 (Antigravity):
❋ # PR Review Summary
Status: Approved
Two-line bug fix with live verification. The PR body is a textbook Fat Ticket — root cause analysis, before/after verification, scope boundary. The fix itself was validated by using the
get_pull_request_diffMCP tool to review this very PR, which is a satisfying closed loop.
📊 Evaluation Metrics
[ARCH_ALIGNMENT]: 100 - Aligns PullRequestService with the existing SyncService pattern. UsesaiConfig.projectRootwhich is already the canonical repo root resolved inconfig.mjsline 9.[CONTENT_COMPLETENESS]: 95 - PR body documents root cause, verification steps, and scope. The existing JSDoc ongetPullRequestDiffandcheckoutPullRequestdidn't need changes since thecwdoption is an internal implementation detail, not API surface. Minor deduction: no inline code comment explaining whycwdis needed (though the git log will carry the Fat Ticket context via squash merge).[EXECUTION_QUALITY]: 100 - Fix is minimal and correct. Verified live with MCP server restart. No side effects —aiConfig.projectRootis already imported and used throughout the server. Bothget_pull_request_diffandget_conversationnow work (the latter was already working via GraphQL, notghCLI).[PRODUCTIVITY]: 100 - Bug discovered, ticketed, fixed, and verified in-session. The MCP server restart verification loop was an efficient strategy.[IMPACT]: 60 - Unblocksget_pull_request_diffandcheckout_pull_requestMCP tools for all agents operating in headless/stdio environments. Impact is moderate because agents could fall back togh pr diffvia shell (as we did during the #9894 review).[COMPLEXITY]: 5 - Two lines changed. No logic, no branching, no tests needed.[EFFORT_PROFILE]: Quick Win - Textbook quick win. High ROI (unblocks MCP tooling) with near-zero complexity.
🕸️ Context & Graph Linking
- Target Epic / Issue ID: Resolves #9895
- Related Graph Nodes: #9894 (PR where the bug was discovered during review),
PullRequestService.mjs,SyncService.mjs(reference implementation for the{cwd}pattern),aiConfig.projectRoot
🧠 Graph Ingestion Notes
[KB_GAP]: None. The bug was an implementation oversight, not a knowledge gap.[TOOLING_GAP]: The MCP server'sget_pull_request_difftool silently failed with a genericGH_CLI_ERRORwithout indicating that the root cause was a CWD mismatch. Future improvement: the error handler could detect CWD-related failures and surface a more diagnostic message (e.g., "gh pr diff requires being in a git repository — ensure cwd is set").[RETROSPECTIVE]: This fix validates the "restart-and-verify" workflow for MCP server changes. The user's suggestion to restart Antigravity mid-session to reload MCP servers was the correct verification strategy — it proved the fix works in the actual headless environment, not just from a developer shell. This pattern should be the standard for MCP server bug fixes.
📋 Required Actions
None — approved for merge.
Summary
Resolves #9895
Changes
PullRequestService.mjs — Two-line fix
Added
{cwd: aiConfig.projectRoot}to bothexecAsynccalls:- const {stdout} = await execAsync(`gh pr checkout ${prNumber}`); + const {stdout} = await execAsync(`gh pr checkout ${prNumber}`, {cwd: aiConfig.projectRoot}); - const {stdout} = await execAsync(`gh pr diff ${prNumber}`); + const {stdout} = await execAsync(`gh pr diff ${prNumber}`, {cwd: aiConfig.projectRoot});Root Cause
PullRequestServicewas the only service that didn't pass{cwd}toexecAsync.SyncServicepasses it on all 5 of its calls. When the MCP server process is spawned via stdio transport (e.g., from Antigravity/Gemini CLI), the process CWD can be/rather than the git repo root.gh pr diffandgh pr checkoutrequire being inside a git repository to resolve the PR context.Verification
Verified live after applying the fix and restarting the MCP server:
get_pull_request_diff(9894)→GH_CLI_ERROR, exit code 1get_pull_request_diff(9894)→ ✅ Full diff content returnedScope
1 file, 2 insertions, 2 deletions. Zero architectural risk.