← Back to Pull requests

fix(cli): read commit message diffs for quoted file names #16531

Open
unknown opened this pull request with 587 lines diff across 7 files
View on GitHub
unknown unknown commented on Nov 22, 2026 21:28 UTC
Author

Issue

Fixes #16529

Context

Commit message generation sent the model an empty diff for every changed file whose name contains a space (when nothing is staged) or a non-ASCII character such as café.ts (staged or not). The model saw only a Git-quoted file name, so it had to guess the message from the name. For a project with mostly non-Latin file names it received no diff content at all. selectedFiles from API callers also never matched these files.

Implementation

  • getGitContext read git diff --name-status --cached and git status --porcelain as newline-separated text. In that form Git C-quotes such names ("my file.ts", "caf\303\251.ts"), and the quoted string was passed on to git diff -- <path>, which matches nothing. Both commands now run with -z, as git-transfer.ts already does since #15045, so the real names come back.

  • parseNameStatus and parsePorcelain now read the NUL-separated format. For renames and copies, --name-status -z prints R100 old new as three fields and the new path is kept as before. --porcelain -z prints the new path in the record and the source path in a separate field after it, and that field is skipped. The existing parser unit tests were moved to the -z input format.

  • test/kilocode/commit-message-windows.test.ts mocks Bun.spawnSync by argv, so its key moves to the -z argv. It now also asserts that the file comes back with its diff, so the per-file spawn stays covered (from the review bot).

  • git() still calls trimEnd(). -z output always ends in a NUL, so a trailing space in a file name is kept.
  • Not changed here: the v2 port in packages/kilo-plugin/src/commit-message/git-context.ts has the same parsing and needs the same change on the v2 branch.

    Screenshots / Video

    N/A. No UI change.

    How to Test

    Manual/local verification

  • (agent) Ran the unmodified git-context.ts from main (1eb4d10) under Bun 1.4.4 against a repo with my file.ts and café.ts modified and nothing staged. Output: {"status":"modified","path":"\"caf\\303\\251.ts\"","diff":""} and {"status":"modified","path":"\"my file.ts\"","diff":""}. After staging café.ts, the --cached branch also gave diff: "". With this change both files come back under their real names with their diffs.

  • (agent) Added five integration tests in test/kilocode/commit-message/git-context.test.ts (spaces and non-ASCII unstaged, non-ASCII staged, untracked non-ASCII, staged rename to a non-ASCII name, selectedFiles with a non-ASCII name). All five fail on main and pass with the fix.

  • (agent) From packages/opencode/: bun test ./test/kilocode/commit-message/ ./test/kilocode/commit-message-windows.test.ts: 61 pass, 0 fail. Before the change, the same files had 53 passing tests and the 5 new ones failing. bun run typecheck passed.

  • (agent) From the repo root: bun run lint (oxlint): 0 errors. prettier --check on the changed files passed. bun run script/check-opencode-annotations.ts --worktree: nothing to check, because the files are under src/kilocode/. bun turbo typecheck --filter='!@kilocode/kilo-jetbrains': 30 of 30 tasks successful.
  • Reviewer test steps

    1. In a scratch Git folder: printf 'one\n' > 'my file.ts'; printf 'one\n' > café.ts; git add .; git commit -m init; printf 'two\n' > 'my file.ts'; printf 'two\n' > café.ts.
    2. Run bun -e 'import { getGitContext } from "<kilocode>/packages/opencode/src/kilocode/commit-message/git-context.ts"; console.log(JSON.stringify((await getGitContext(process.cwd())).files, null, 1))' from that folder.
    3. On main, both paths are quoted and diff is "". With this change, the paths are my file.ts and café.ts and each diff contains +two.

    Blocked checks and substitute verification

  • The full bun turbo test:ci --filter=@kilocode/cli suite was not run. The machine was heavily loaded, and under that load the git-backed tests in these files went past Bun's default 5 s timeout. Substitute: the commit-message test files above, run with --timeout 60000.

  • The JetBrains typecheck in the pre-push hook needs Java 21, which is not installed here. This change touches no Kotlin and no API used by the plugin. The non-JetBrains monorepo typecheck was run instead.

  • Ran on macOS with git 2.54. Windows and Linux were not run.
  • Checklist

  • Issue linked above, or exception explained

  • Tests/verification described

  • Screenshots/video included for visual changes, or marked N/A

  • Changeset considered for user-facing changes

  • I personally reviewed the diff and can explain the changes, including any AI-assisted work.
  • 🤖 Generated with Claude Code

    Diff: 587 lines (+440 / -147) across 7 files Reviewer: thejesh23 Review duration: 11613m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.50) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 587 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.382
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #16531"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.9% (MEDIUM) · Higher = larger blast radius
    49.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26.6% · Safe to merge
    26.6%