From 3b5a61fdc8298e033ea785388e4fd5fa842bf09c Mon Sep 17 00:00:00 2001 From: Jack Felke Date: Thu, 19 Mar 2026 20:14:44 -0700 Subject: [PATCH] fix(what-changed): use array args instead of shell syntax in run() calls run() uses execFileSync without a shell, so shell operators like 2>/dev/null and || were being passed as literal git arguments, causing silent failures. Replace with proper array args and existing git.ts helpers (getDiffFiles) with built-in fallback logic. --- src/tools/what-changed.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tools/what-changed.ts b/src/tools/what-changed.ts index 913dfa2..27eea20 100644 --- a/src/tools/what-changed.ts +++ b/src/tools/what-changed.ts @@ -1,6 +1,6 @@ import { z } from "zod"; import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { run, getBranch, getDiffStat } from "../lib/git.js"; +import { run, getBranch, getDiffFiles, getDiffStat } from "../lib/git.js"; export function registerWhatChanged(server: McpServer): void { server.tool( @@ -12,8 +12,9 @@ export function registerWhatChanged(server: McpServer): void { async ({ since }) => { const ref = since || "HEAD~5"; const diffStat = getDiffStat(ref); - const diffFiles = run(`git diff ${ref} --name-only 2>/dev/null || git diff HEAD~3 --name-only`); - const log = run(`git log ${ref}..HEAD --oneline 2>/dev/null || git log -5 --oneline`); + const diffFiles = getDiffFiles(ref); + const logResult = run(["log", `${ref}..HEAD`, "--oneline"]); + const log = logResult.startsWith("[") ? run(["log", "-5", "--oneline"]) : logResult; const branch = getBranch(); const fileList = diffFiles.split("\n").filter(Boolean);