fix(cli): read commit message diffs for quoted file names #16531
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
thejesh23
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.selectedFilesfrom API callers also never matched these files.Implementation
getGitContextreadgit diff --name-status --cachedandgit status --porcelainas 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 togit diff -- <path>, which matches nothing. Both commands now run with-z, asgit-transfer.tsalready does since #15045, so the real names come back.parseNameStatusandparsePorcelainnow read the NUL-separated format. For renames and copies,--name-status -zprintsR100 old newas three fields and the new path is kept as before.--porcelain -zprints 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-zinput format.test/kilocode/commit-message-windows.test.tsmocksBun.spawnSyncby argv, so its key moves to the-zargv. 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 callstrimEnd().-zoutput 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.tshas the same parsing and needs the same change on thev2branch.Screenshots / Video
N/A. No UI change.
How to Test
Manual/local verification
git-context.tsfrommain(1eb4d10) under Bun 1.4.4 against a repo withmy file.tsandcafé.tsmodified and nothing staged. Output:{"status":"modified","path":"\"caf\\303\\251.ts\"","diff":""}and{"status":"modified","path":"\"my file.ts\"","diff":""}. After stagingcafé.ts, the--cachedbranch also gavediff: "". With this change both files come back under their real names with their diffs.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,selectedFileswith a non-ASCII name). All five fail onmainand pass with the fix.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 typecheckpassed.bun run lint(oxlint): 0 errors.prettier --checkon the changed files passed.bun run script/check-opencode-annotations.ts --worktree: nothing to check, because the files are undersrc/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 anddiffis"". With this change, the paths aremy file.tsandcafé.tsand each diff contains+two.Blocked checks and substitute verification
bun turbo test:ci --filter=@kilocode/clisuite 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.Checklist
🤖 Generated with Claude Code