Skip to content

feat: add /diff command and git diff statistics utility#3491

Merged
BZ-D merged 26 commits into
mainfrom
feat/git-diff-stats
May 10, 2026
Merged

feat: add /diff command and git diff statistics utility#3491
BZ-D merged 26 commits into
mainfrom
feat/git-diff-stats

Conversation

@BZ-D

@BZ-D BZ-D commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

TLDR

Implements the structured git-diff statistics feature requested in #2997 and exposes it through a new /diff slash command.

  • New core utility packages/core/src/utils/gitDiff.ts parses git diff --numstat, --shortstat, and unified git diff HEAD output into a structured result (files changed, lines added/removed, per-file summaries, hunks) with the caps called out in the issue: 50 files, 1 MB per file, 400 lines per file, plus a 500-file short-circuit via --shortstat.
  • New /diff built-in slash command renders the result as a single info message — header N files changed, +A / -R followed by per-file rows, with ? for untracked files and ~ for binary files.

Screenshots / Video Demo

Typical output inside a dirty working tree:

3 files changed, +42 / -7
  +10 -2  src/utils/gitDiff.ts
  + 5 -1  src/utils/gitUtils.ts
  ?       docs/new-note.md

On a clean tree or outside a git repo, /diff prints a single info line and exits without error.

Dive Deeper

Borrowed the parsing strategy from the reference implementation in claude-code-cli's utils/gitDiff.ts, then adapted to qwen-code conventions and fixed a handful of issues surfaced during adversarial review:

  • Linked worktrees / submodules. findGitRoot returns the directory that contains .git, but in a linked worktree .git is a file pointing at <main>/.git/worktrees/<name>/. A new resolveGitDir helper follows that indirection so MERGE_HEAD, CHERRY_PICK_HEAD, etc. are looked up in the right gitdir.
  • Rebase detection. REBASE_HEAD alone misses the common case. The transient-state check now looks at rebase-merge/ and rebase-apply/ directories too.
  • ---/+++/index as file content. The unified-diff parser previously skipped any line starting with those prefixes as file-header metadata, which corrupted hunks that removed or added source lines beginning with ---, +++, or index. Metadata is now only skipped before the first @@ hunk header.
  • Non-ASCII filenames. Every git invocation passes -c core.quotepath=false so Japanese / Chinese / other non-ASCII filenames stay as UTF-8 instead of being octal-escaped into keys like \346\227\245\346\234\254\350\252\236.txt.
  • Shortstat / numstat consistency. Both the fast (>500 files) and slow paths now add untracked file counts into stats.filesCount, so callers see a consistent surface.
  • MAX_LINES_PER_FILE truncation. Switched from continue to break so we stop scanning once the 400-line cap is reached rather than walking the remainder of a huge file looking for hunk headers.
  • /diff robustness. Wrapped in try/catch (FS permission errors surface as a friendly message rather than crashing the action), declared supportedModes: ['interactive', 'non_interactive', 'acp'] so the command works outside the Ink UI, and aligned ? / ~ marker rows with the +X -Y stat column so mixed output stays tabular.

Reviewer Test Plan

  1. Check out the branch and run the unit tests:
    npm --workspace @qwen-code/qwen-code-core run test -- src/utils/gitDiff.test.ts
    npm --workspace @qwen-code/qwen-code run test -- src/ui/commands/diffCommand.test.ts
    
    29 core tests + 12 CLI tests should pass.
  2. Start the CLI in a dirty working tree and run /diff. Expected: a header with files-changed / +added / -removed plus per-file rows.
  3. In the same CLI, try /diff in a clean tree, a fresh repo with no HEAD, and a non-git directory — each should print a single info message without throwing.
  4. (Optional) Reproduce a worktree scenario: git worktree add ../wt -b feature, drop a fake MERGE_HEAD inside <main>/.git/worktrees/wt/, and confirm /diff short-circuits with the "merge/rebase/cherry-pick/revert" message — this exercises the resolveGitDir fix.

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Validated on macOS via `npm run typecheck` (0 errors) and the project's vitest runner (1602 core tests pass, 271 CLI command tests pass).

Linked issues / bugs

Resolves #2997

BZ-D added 3 commits April 21, 2026 11:00
Port numstat + unified-diff parsing into `packages/core/src/utils/gitDiff.ts`
to surface structured working-tree change summaries (files changed, lines
added/removed, per-file hunks) against HEAD. Caps mirror issue #2997:
50 files, 1MB per file, 400 lines per file, with a 500-file short-circuit
via `git diff --shortstat` to avoid expensive work on massive diffs.

- `fetchGitDiff(cwd)` returns stats + per-file summaries (tracked + untracked).
- `fetchGitDiffHunks(cwd)` returns structured hunks on demand.
- `resolveGitDir(cwd)` follows `.git` file indirection so linked worktrees
  and submodules report the correct gitdir.
- Transient-state short-circuit covers merge, cherry-pick, revert, and both
  `rebase-merge` / `rebase-apply` layouts.
- `core.quotepath=false` is forced so non-ASCII filenames stay as UTF-8.

Refs #2997
Surface the `fetchGitDiff` utility through an interactive `/diff` command.
Prints a header (`N files changed, +A / -R`) followed by per-file rows with
padded add/remove counts. Untracked files are marked `?`, binary files are
marked `~`. When the change set exceeds the per-file cap, a trailing
`…and N more` note tells the user how many entries are hidden.

Returns a `MessageActionReturn` so it renders the same way in interactive
and non-interactive modes.
- Wrap `fetchGitDiff` in try/catch so permission errors on `.git` surface
  as a friendly error message instead of crashing the action.
- Declare `supportedModes: ['interactive', 'non_interactive', 'acp']` so
  the command is reachable outside the interactive Ink UI — the default
  for `commandType: 'local'` is interactive-only.
- Align `?` (untracked) and `~` (binary) markers with the `+X -Y` stat
  column via a padded prefix, so filenames line up regardless of row kind.
- Drop the "…and N more" hint when no rows are shown (shortstat fast-path
  with >500 files) — the count alone is sufficient and "showing first 0"
  is noise.
- Switch header to full-phrase i18n templates (separate singular/plural
  variants) instead of word-by-word `t()` calls that don't survive
  non-English locales.
- Extend tests to 12 scenarios: empty cwd, fetch rejection, singular
  "file" form, mixed untracked/binary/tracked alignment, 4-digit padding,
  shortstat fast-path, and supportedModes declaration. Mocks carry a
  `satisfies GitDiffResult` annotation so shape drift in core breaks the
  test at compile time.
@BZ-D BZ-D requested a review from wenshao April 21, 2026 06:26
Comment thread packages/core/src/utils/gitDiff.ts Fixed
@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Summary

Package Lines Statements Functions Branches
CLI 56.09% 56.09% 72.07% 79.31%
Core 76.74% 76.74% 79.33% 82.11%
CLI Package - Full Text Report
-------------------|---------|----------|---------|---------|-------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------|---------|----------|---------|---------|-------------------
All files          |   56.09 |    79.31 |   72.07 |   56.09 |                   
 src               |   67.99 |    62.34 |   74.19 |   67.99 |                   
  gemini.tsx       |   59.52 |    58.88 |   66.66 |   59.52 | ...62,770-773,781 
  ...ractiveCli.ts |   69.53 |    57.42 |   72.72 |   69.53 | ...21-768,776-783 
  ...liCommands.ts |   73.92 |     72.5 |     100 |   73.92 | ...40-264,289,389 
  ...ActiveAuth.ts |     100 |     87.5 |     100 |     100 | 66-80             
 ...cp-integration |    46.3 |    63.01 |   55.88 |    46.3 |                   
  acpAgent.ts      |   48.12 |    63.38 |   62.06 |   48.12 | ...91-793,807-815 
  authMethods.ts   |   12.19 |      100 |       0 |   12.19 | 11-31,34-38,41-50 
  errorCodes.ts    |       0 |        0 |       0 |       0 | 1-22              
  ...DirContext.ts |     100 |      100 |     100 |     100 |                   
 ...ration/service |   68.65 |    83.33 |   66.66 |   68.65 |                   
  filesystem.ts    |   68.65 |    83.33 |   66.66 |   68.65 | ...32,77-94,97-98 
 ...ration/session |   74.86 |    68.57 |    82.6 |   74.86 |                   
  ...ryReplayer.ts |   65.93 |    75.67 |   81.81 |   65.93 | ...40-255,268-269 
  Session.ts       |   73.52 |    66.12 |   82.92 |   73.52 | ...2322,2328-2331 
  ...entTracker.ts |   90.85 |    84.84 |      90 |   90.85 | ...35,199,251-260 
  index.ts         |       0 |        0 |       0 |       0 | 1-40              
  ...ssionUtils.ts |   84.21 |    77.77 |     100 |   84.21 | ...37-153,209-211 
  types.ts         |       0 |        0 |       0 |       0 | 1                 
 ...ssion/emitters |   96.01 |    90.75 |    92.3 |   96.01 |                   
  BaseEmitter.ts   |   76.92 |    66.66 |      80 |   76.92 | 23-24,39-40,55-56 
  ...ageEmitter.ts |     100 |    89.47 |     100 |     100 | 109,111           
  PlanEmitter.ts   |     100 |      100 |     100 |     100 |                   
  ...allEmitter.ts |   98.06 |     92.3 |     100 |   98.06 | 227-228,327,335   
  index.ts         |       0 |        0 |       0 |       0 | 1-10              
 ...ession/rewrite |   89.69 |    85.89 |   94.11 |   89.69 |                   
  LlmRewriter.ts   |   80.53 |    79.31 |     100 |   80.53 | ...17-119,170-174 
  ...Middleware.ts |   95.83 |    85.71 |     100 |   95.83 | 119,127-129       
  TurnBuffer.ts    |     100 |      100 |     100 |     100 |                   
  config.ts        |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  types.ts         |       0 |        0 |       0 |       0 | 1                 
 src/commands      |   62.18 |      100 |    9.52 |   62.18 |                   
  auth.ts          |   46.91 |      100 |       0 |   46.91 | ...,91-98,101-102 
  channel.ts       |   56.66 |      100 |       0 |   56.66 | 15-19,27-34       
  extensions.tsx   |   96.55 |      100 |      50 |   96.55 | 37                
  hooks.tsx        |   66.66 |      100 |       0 |   66.66 | 20-24             
  mcp.ts           |   94.73 |      100 |      50 |   94.73 | 28                
  review.ts        |   51.85 |      100 |       0 |   51.85 | 24-35,38          
 src/commands/auth |   66.16 |    79.82 |   78.94 |   66.16 |                   
  handler.ts       |   47.07 |    74.68 |   35.29 |   47.07 | ...-968,1058-1068 
  ...veSelector.ts |     100 |    96.66 |     100 |     100 | 58                
  ...outerOAuth.ts |   89.02 |    78.99 |   96.87 |   89.02 | ...18-622,716-718 
 ...mmands/channel |    39.2 |    79.45 |      50 |    39.2 |                   
  ...l-registry.ts |    8.57 |      100 |       0 |    8.57 | 6-21,24-42        
  config-utils.ts  |   91.89 |      100 |   66.66 |   91.89 | 20-25             
  configure.ts     |    14.7 |      100 |       0 |    14.7 | 18-21,23-84       
  pairing.ts       |   26.31 |      100 |       0 |   26.31 | ...30,40-50,52-65 
  pidfile.ts       |   96.34 |    86.95 |     100 |   96.34 | 49,59,91          
  start.ts         |   31.15 |       52 |   69.23 |   31.15 | ...73-476,485-487 
  status.ts        |   17.54 |      100 |       0 |   17.54 | 15-26,32-77       
  stop.ts          |      20 |      100 |       0 |      20 | 14-48             
 ...nds/extensions |   84.53 |    88.95 |   81.81 |   84.53 |                   
  consent.ts       |   71.65 |    89.28 |   42.85 |   71.65 | ...85-141,156-162 
  disable.ts       |     100 |      100 |     100 |     100 |                   
  enable.ts        |     100 |      100 |     100 |     100 |                   
  install.ts       |    75.6 |    66.66 |   66.66 |    75.6 | ...39-142,145-153 
  link.ts          |     100 |      100 |     100 |     100 |                   
  list.ts          |     100 |      100 |     100 |     100 |                   
  new.ts           |     100 |      100 |     100 |     100 |                   
  settings.ts      |   99.15 |      100 |   83.33 |   99.15 | 151               
  uninstall.ts     |    37.5 |      100 |   33.33 |    37.5 | 23-45,57-64,67-70 
  update.ts        |   96.32 |      100 |     100 |   96.32 | 101-105           
  utils.ts         |   60.24 |    28.57 |     100 |   60.24 | ...81,83-87,89-93 
 ...les/mcp-server |       0 |        0 |       0 |       0 |                   
  example.ts       |       0 |        0 |       0 |       0 | 1-60              
 src/commands/mcp  |   92.29 |    86.08 |   88.88 |   92.29 |                   
  add.ts           |     100 |    98.03 |     100 |     100 | 293               
  list.ts          |   91.22 |    80.76 |      80 |   91.22 | ...19-121,146-147 
  reconnect.ts     |   76.72 |    71.42 |   85.71 |   76.72 | 35-48,153-175     
  remove.ts        |     100 |       80 |     100 |     100 | 21-25             
 ...ommands/review |   11.57 |      100 |       0 |   11.57 |                   
  cleanup.ts       |   17.94 |      100 |       0 |   17.94 | ...01-106,108-109 
  deterministic.ts |   13.75 |      100 |       0 |   13.75 | ...22-738,740-741 
  fetch-pr.ts      |   11.36 |      100 |       0 |   11.36 | ...80-201,203-204 
  load-rules.ts    |   11.32 |      100 |       0 |   11.32 | ...41-153,155-156 
  pr-context.ts    |    6.22 |      100 |       0 |    6.22 | ...97-312,314-315 
  presubmit.ts     |    9.35 |      100 |       0 |    9.35 | ...62-287,289-290 
 ...nds/review/lib |      30 |      100 |       0 |      30 |                   
  gh.ts            |   22.58 |      100 |       0 |   22.58 | ...49,53-54,62-69 
  git.ts           |   22.72 |      100 |       0 |   22.72 | 15-18,29-39,43-44 
  paths.ts         |   52.94 |      100 |       0 |   52.94 | ...26,37-38,42-43 
 src/config        |   92.19 |    82.54 |   84.72 |   92.19 |                   
  auth.ts          |   87.87 |    81.35 |     100 |   87.87 | ...20-221,237-238 
  config.ts        |   86.36 |    82.53 |   72.72 |   86.36 | ...1339,1361-1362 
  keyBindings.ts   |   95.95 |       50 |     100 |   95.95 | 160-163           
  ...idersScope.ts |      92 |       90 |     100 |      92 | 11-12             
  sandboxConfig.ts |    58.9 |    61.53 |   66.66 |    58.9 | ...54-68,73,77-89 
  settings.ts      |   83.13 |    82.55 |   85.71 |   83.13 | ...35-936,941-944 
  ...ingsSchema.ts |     100 |      100 |     100 |     100 |                   
  ...tedFolders.ts |   96.29 |       94 |     100 |   96.29 | ...88-190,205-206 
 ...nfig/migration |   94.56 |    78.94 |   83.33 |   94.56 |                   
  index.ts         |   93.93 |    88.88 |     100 |   93.93 | 85-86             
  scheduler.ts     |   96.55 |    77.77 |     100 |   96.55 | 19-20             
  types.ts         |       0 |        0 |       0 |       0 | 1                 
 ...ation/versions |   93.63 |     94.5 |     100 |   93.63 |                   
  ...-v2-shared.ts |     100 |      100 |     100 |     100 |                   
  v1-to-v2.ts      |   81.75 |    90.19 |     100 |   81.75 | ...28-229,231-247 
  v2-to-v3.ts      |     100 |      100 |     100 |     100 |                   
 src/constants     |   11.97 |     87.5 |   16.66 |   11.97 |                   
  ...dardApiKey.ts |     100 |      100 |     100 |     100 |                   
  codingPlan.ts    |    8.75 |     87.5 |   16.66 |    8.75 | ...22-327,335-347 
 src/core          |     100 |      100 |     100 |     100 |                   
  auth.ts          |     100 |      100 |     100 |     100 |                   
  initializer.ts   |     100 |      100 |     100 |     100 |                   
  theme.ts         |     100 |      100 |     100 |     100 |                   
 src/dualOutput    |   63.09 |    64.51 |   55.55 |   63.09 |                   
  ...tputBridge.ts |   62.94 |    65.51 |   56.25 |   62.94 | ...22-323,331-334 
  ...utContext.tsx |     100 |      100 |     100 |     100 |                   
  index.ts         |       0 |        0 |       0 |       0 | 1-8               
 src/export        |       0 |        0 |       0 |       0 |                   
  index.ts         |       0 |        0 |       0 |       0 | 1-7               
 src/generated     |     100 |      100 |     100 |     100 |                   
  git-commit.ts    |     100 |      100 |     100 |     100 |                   
 src/i18n          |   48.26 |    76.19 |   38.88 |   48.26 |                   
  index.ts         |   26.92 |    76.92 |   26.66 |   26.92 | ...38-239,249-260 
  languages.ts     |    98.7 |       75 |     100 |    98.7 | 110               
 src/i18n/locales  |       0 |        0 |       0 |       0 |                   
  ca.js            |       0 |        0 |       0 |       0 | 1-2146            
  de.js            |       0 |        0 |       0 |       0 | 1-2069            
  en.js            |       0 |        0 |       0 |       0 | 1-2142            
  fr.js            |       0 |        0 |       0 |       0 | 1-2102            
  ja.js            |       0 |        0 |       0 |       0 | 1-1560            
  pt.js            |       0 |        0 |       0 |       0 | 1-2060            
  ru.js            |       0 |        0 |       0 |       0 | 1-2065            
  zh-TW.js         |       0 |        0 |       0 |       0 | 1-1703            
  zh.js            |       0 |        0 |       0 |       0 | 1-1942            
 ...nonInteractive |   72.67 |    72.14 |   74.07 |   72.67 |                   
  session.ts       |   76.86 |    70.45 |   85.71 |   76.86 | ...78-779,787-797 
  types.ts         |    42.5 |      100 |   33.33 |    42.5 | ...80-581,584-585 
 ...active/control |   77.55 |    88.23 |      80 |   77.55 |                   
  ...rolContext.ts |    7.69 |        0 |       0 |    7.69 | 47-79             
  ...Dispatcher.ts |   91.66 |    91.83 |   88.88 |   91.66 | ...54-372,388,391 
  ...rolService.ts |       8 |        0 |       0 |       8 | 46-179            
 ...ol/controllers |    7.04 |       80 |   13.33 |    7.04 |                   
  ...Controller.ts |   19.32 |      100 |      60 |   19.32 | 81-118,127-210    
  ...Controller.ts |       0 |        0 |       0 |       0 | 1-56              
  ...Controller.ts |    3.96 |      100 |   11.11 |    3.96 | ...61-379,389-494 
  ...Controller.ts |   14.06 |      100 |       0 |   14.06 | ...82-117,130-133 
  ...Controller.ts |    5.21 |      100 |       0 |    5.21 | ...21-433,442-471 
 .../control/types |       0 |        0 |       0 |       0 |                   
  serviceAPIs.ts   |       0 |        0 |       0 |       0 | 1                 
 ...Interactive/io |   97.59 |    93.06 |   95.18 |   97.59 |                   
  ...putAdapter.ts |   97.33 |    91.89 |   98.07 |   97.33 | ...1343,1368-1369 
  ...putAdapter.ts |      96 |    91.66 |   85.71 |      96 | 51-52             
  ...nputReader.ts |     100 |    94.73 |     100 |     100 | 67                
  ...putAdapter.ts |   98.28 |      100 |      90 |   98.28 | 81-82,122-123     
  index.ts         |     100 |      100 |     100 |     100 |                   
 src/patches       |       0 |        0 |       0 |       0 |                   
  is-in-ci.ts      |       0 |        0 |       0 |       0 | 1-17              
 src/remoteInput   |   86.98 |       75 |   85.71 |   86.98 |                   
  ...utContext.tsx |     100 |      100 |     100 |     100 |                   
  ...putWatcher.ts |   88.12 |    76.08 |   91.66 |   88.12 | ...21-222,233-236 
  index.ts         |       0 |        0 |       0 |       0 | 1-8               
 src/services      |   90.39 |    89.75 |   94.28 |   90.39 |                   
  ...mandLoader.ts |     100 |     92.3 |     100 |     100 | 90                
  ...killLoader.ts |     100 |    96.29 |     100 |     100 | 44                
  ...andService.ts |    93.5 |      100 |      80 |    93.5 | 107,150-153       
  ...mandLoader.ts |   86.83 |    83.87 |     100 |   86.83 | ...30-335,340-345 
  ...omptLoader.ts |   75.32 |    80.64 |   83.33 |   75.32 | ...05-206,272-273 
  ...mandLoader.ts |     100 |      100 |     100 |     100 |                   
  ...nd-factory.ts |      91 |     90.9 |     100 |      91 | 123,132-139       
  ...ation-tool.ts |     100 |    95.45 |     100 |     100 | 125               
  commandUtils.ts  |      96 |       90 |     100 |      96 | 48                
  ...and-parser.ts |   90.69 |    85.71 |     100 |   90.69 | 63-66             
  ...ionService.ts |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 ...ght/generators |   85.95 |    86.42 |   90.47 |   85.95 |                   
  DataProcessor.ts |   85.68 |    86.46 |   92.85 |   85.68 | ...1110,1114-1121 
  ...tGenerator.ts |   98.21 |    85.71 |     100 |   98.21 | 46                
  ...teRenderer.ts |   45.45 |      100 |       0 |   45.45 | 13-51             
 .../insight/types |       0 |       50 |      50 |       0 |                   
  ...sightTypes.ts |       0 |        0 |       0 |       0 |                   
  ...sightTypes.ts |       0 |        0 |       0 |       0 | 1                 
 ...mpt-processors |   97.27 |    94.04 |     100 |   97.27 |                   
  ...tProcessor.ts |     100 |      100 |     100 |     100 |                   
  ...eProcessor.ts |   94.52 |    84.21 |     100 |   94.52 | 46-47,93-94       
  ...tionParser.ts |     100 |      100 |     100 |     100 |                   
  ...lProcessor.ts |   97.41 |    95.65 |     100 |   97.41 | 95-98             
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/services/tips |   97.35 |    83.07 |     100 |   97.35 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  tipHistory.ts    |   92.45 |       70 |     100 |   92.45 | ...22,144,151,160 
  tipRegistry.ts   |     100 |    95.23 |     100 |     100 | 33                
  tipScheduler.ts  |     100 |    91.66 |     100 |     100 | 55                
 src/test-utils    |   93.75 |    83.33 |      80 |   93.75 |                   
  ...omMatchers.ts |   69.69 |       50 |      50 |   69.69 | 32-35,37-39,45-47 
  ...andContext.ts |     100 |      100 |     100 |     100 |                   
  render.tsx       |     100 |      100 |     100 |     100 |                   
 src/ui            |   63.23 |    68.42 |   51.28 |   63.23 |                   
  App.tsx          |     100 |      100 |     100 |     100 |                   
  AppContainer.tsx |   65.87 |    62.67 |   66.66 |   65.87 | ...2279,2283-2287 
  ...tionNudge.tsx |    9.58 |      100 |       0 |    9.58 | 24-94             
  ...ackDialog.tsx |   29.23 |      100 |       0 |   29.23 | 25-75             
  ...tionNudge.tsx |    7.69 |      100 |       0 |    7.69 | 25-103            
  colors.ts        |   52.72 |      100 |   23.52 |   52.72 | ...52,54-55,60-61 
  constants.ts     |     100 |      100 |     100 |     100 |                   
  keyMatchers.ts   |   91.83 |       90 |     100 |   91.83 | 25-26,54-55       
  ...tic-colors.ts |     100 |      100 |     100 |     100 |                   
  textConstants.ts |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/ui/auth       |   53.26 |    65.51 |      68 |   53.26 |                   
  AuthDialog.tsx   |   67.75 |    64.95 |    65.9 |   67.75 | ...1271,1273,1275 
  ...nProgress.tsx |       0 |        0 |       0 |       0 | 1-64              
  useAuth.ts       |    34.3 |    70.37 |     100 |    34.3 | ...14-920,922-937 
 src/ui/commands   |   61.22 |    78.74 |   62.61 |   61.22 |                   
  aboutCommand.ts  |     100 |    85.71 |     100 |     100 | 36                
  agentsCommand.ts |   72.97 |      100 |      20 |   72.97 | ...32,37-38,42-44 
  ...odeCommand.ts |     100 |      100 |     100 |     100 |                   
  arenaCommand.ts  |   33.13 |    67.64 |    37.5 |   33.13 | ...60-565,644-649 
  authCommand.ts   |     100 |      100 |     100 |     100 |                   
  btwCommand.ts    |   95.59 |    71.42 |     100 |   95.59 | 72,154-159        
  bugCommand.ts    |   77.35 |    66.66 |      50 |   77.35 | 21-22,60-69       
  clearCommand.ts  |   90.58 |    73.68 |      50 |   90.58 | ...46,74-75,93-94 
  ...essCommand.ts |   63.39 |       48 |      50 |   63.39 | ...48-149,163-166 
  ...extCommand.ts |    6.17 |      100 |      10 |    6.17 | ...21-522,527-528 
  copyCommand.ts   |     100 |      100 |     100 |     100 |                   
  deleteCommand.ts |     100 |      100 |     100 |     100 |                   
  diffCommand.ts   |   99.02 |    86.11 |     100 |   99.02 | 222,226           
  ...ryCommand.tsx |   66.11 |    76.74 |   55.55 |   66.11 | ...05-306,315-323 
  docsCommand.ts   |   96.07 |     87.5 |      50 |   96.07 | 20-21             
  doctorCommand.ts |     100 |    93.33 |     100 |     100 | 21                
  dreamCommand.ts  |      75 |    66.66 |   66.66 |      75 | 22-27,44-47       
  editorCommand.ts |     100 |      100 |     100 |     100 |                   
  exportCommand.ts |   56.93 |    91.66 |   33.33 |   56.93 | ...52-353,361-362 
  ...onsCommand.ts |   45.08 |    85.71 |   27.27 |   45.08 | ...37-238,247-248 
  forgetCommand.ts |   26.82 |      100 |      50 |   26.82 | 18-51             
  helpCommand.ts   |     100 |      100 |     100 |     100 |                   
  hooksCommand.ts  |   19.04 |       25 |      20 |   19.04 | ...86-187,204-205 
  ideCommand.ts    |   57.33 |    57.69 |   35.29 |   57.33 | ...05-306,310-324 
  initCommand.ts   |   84.33 |    72.72 |     100 |   84.33 | 68,82-87,89-94    
  ...ghtCommand.ts |    72.8 |    66.66 |   83.33 |    72.8 | ...31-245,250-273 
  ...ageCommand.ts |   89.39 |    82.35 |   76.92 |   89.39 | ...22-325,348-349 
  ...elsCommand.ts |     100 |      100 |     100 |     100 |                   
  mcpCommand.ts    |   86.66 |      100 |      50 |   86.66 | 14-15             
  memoryCommand.ts |   86.66 |      100 |      50 |   86.66 | 14-15             
  modelCommand.ts  |   42.19 |       65 |      50 |   42.19 | ...35-168,175-193 
  ...onsCommand.ts |     100 |      100 |     100 |     100 |                   
  planCommand.ts   |   78.82 |    76.92 |     100 |   78.82 | 30-35,51-56,68-73 
  quitCommand.ts   |   93.93 |      100 |      50 |   93.93 | 15-16             
  recapCommand.ts  |   21.81 |      100 |      50 |   21.81 | 24-73             
  ...berCommand.ts |   32.43 |      100 |      50 |   32.43 | 23-57             
  renameCommand.ts |   85.61 |    78.18 |     100 |   85.61 | ...15-322,329-334 
  ...oreCommand.ts |    92.3 |     87.5 |     100 |    92.3 | ...,83-88,129-130 
  resumeCommand.ts |     100 |      100 |     100 |     100 |                   
  rewindCommand.ts |      80 |      100 |      50 |      80 | 19-21             
  ...ngsCommand.ts |     100 |      100 |     100 |     100 |                   
  ...hubCommand.ts |   81.43 |    65.21 |      80 |   81.43 | ...70-173,176-179 
  skillsCommand.ts |   15.04 |      100 |      25 |   15.04 | ...90-106,109-136 
  statsCommand.ts  |   83.91 |    81.25 |      50 |   83.91 | ...31-132,142-145 
  ...ineCommand.ts |     100 |      100 |     100 |     100 |                   
  ...aryCommand.ts |    6.51 |      100 |      50 |    6.51 | 28-323            
  tasksCommand.ts  |   77.45 |    73.43 |     100 |   77.45 | ...55-159,181-186 
  ...tupCommand.ts |     100 |      100 |     100 |     100 |                   
  themeCommand.ts  |     100 |      100 |     100 |     100 |                   
  toolsCommand.ts  |   95.23 |      100 |      50 |   95.23 | 18-19             
  trustCommand.ts  |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
  vimCommand.ts    |   54.54 |      100 |      50 |   54.54 | 19-29             
 src/ui/components |   59.76 |    73.82 |   62.82 |   59.76 |                   
  AboutBox.tsx     |     100 |      100 |     100 |     100 |                   
  AnsiOutput.tsx   |   65.57 |      100 |      50 |   65.57 | 69-90             
  ApiKeyInput.tsx  |   18.91 |      100 |       0 |   18.91 | 30-95             
  AppHeader.tsx    |   88.88 |    81.81 |     100 |   88.88 | 34-40,42          
  ...odeDialog.tsx |     9.7 |      100 |       0 |     9.7 | 35-47,50-182      
  AsciiArt.ts      |     100 |      100 |     100 |     100 |                   
  ...Indicator.tsx |   14.63 |      100 |       0 |   14.63 | 18-56             
  ...TextInput.tsx |   67.83 |    72.09 |      50 |   67.83 | ...30-232,250,259 
  Composer.tsx     |   79.31 |    57.14 |     100 |   79.31 | ...-77,95,133,146 
  ...entPrompt.tsx |     100 |      100 |     100 |     100 |                   
  ...ryDisplay.tsx |   75.89 |    62.06 |     100 |   75.89 | ...,88,93-108,113 
  ...geDisplay.tsx |   68.42 |    57.14 |     100 |   68.42 | 16-17,31-32,42-50 
  ...ification.tsx |   28.57 |      100 |       0 |   28.57 | 16-36             
  ...gProfiler.tsx |       0 |        0 |       0 |       0 | 1-36              
  ...ogManager.tsx |    12.4 |      100 |       0 |    12.4 | 61-457            
  ...ngsDialog.tsx |    8.44 |      100 |       0 |    8.44 | 37-195            
  ExitWarning.tsx  |     100 |      100 |     100 |     100 |                   
  ...hProgress.tsx |    87.8 |    33.33 |     100 |    87.8 | 28-31,56          
  ...ustDialog.tsx |     100 |      100 |     100 |     100 |                   
  Footer.tsx       |   79.67 |    58.06 |     100 |   79.67 | ...98-102,104-108 
  ...ngSpinner.tsx |   54.28 |       50 |      50 |   54.28 | 31-48,61          
  Header.tsx       |   98.38 |    92.59 |     100 |   98.38 | 139,141           
  Help.tsx         |   98.74 |    68.75 |     100 |   98.74 | 74,129            
  ...emDisplay.tsx |   62.78 |    36.73 |     100 |   62.78 | ...22-331,334,337 
  ...ngeDialog.tsx |     100 |      100 |     100 |     100 |                   
  InputPrompt.tsx  |   81.63 |    76.68 |   83.33 |   81.63 | ...1339,1404,1454 
  ...Shortcuts.tsx |   20.87 |      100 |       0 |   20.87 | ...6,49-51,67-125 
  ...Indicator.tsx |     100 |    91.42 |     100 |     100 | 65,74             
  ...firmation.tsx |   91.42 |      100 |      50 |   91.42 | 26-31             
  MainContent.tsx  |   57.66 |    54.54 |     100 |   57.66 | ...89-200,209-223 
  ...elsDialog.tsx |   16.07 |    89.18 |      50 |   16.07 | ...58-159,162-648 
  MemoryDialog.tsx |   53.35 |    51.21 |   57.14 |   53.35 | ...55,367,380-382 
  ...geDisplay.tsx |       0 |        0 |       0 |       0 | 1-41              
  ModelDialog.tsx  |   76.59 |    54.54 |     100 |   76.59 | ...60-476,533-537 
  ...tsDisplay.tsx |     100 |    96.96 |     100 |     100 | 234               
  ...fications.tsx |   18.18 |      100 |       0 |   18.18 | 15-58             
  ...onsDialog.tsx |    2.13 |      100 |       0 |    2.13 | 62-133,148-1004   
  ...ryDisplay.tsx |     100 |      100 |     100 |     100 |                   
  ...icePrompt.tsx |   88.14 |    83.87 |     100 |   88.14 | ...01-105,133-138 
  PrepareLabel.tsx |   91.66 |    76.19 |     100 |   91.66 | 73-75,77-79,110   
  ...geDisplay.tsx |     100 |      100 |     100 |     100 |                   
  ...ngDisplay.tsx |   21.42 |      100 |       0 |   21.42 | 13-39             
  ...hProgress.tsx |   85.25 |    88.46 |     100 |   85.25 | 121-147           
  ...dSelector.tsx |    4.45 |      100 |       0 |    4.45 | 28-92,100-328     
  ...ionPicker.tsx |   94.76 |    87.17 |     100 |   94.76 | 99,132,253-261    
  ...onPreview.tsx |   91.73 |    78.26 |     100 |   91.73 | ...,70-71,126-128 
  ...ryDisplay.tsx |     100 |      100 |     100 |     100 |                   
  ...putPrompt.tsx |   72.56 |       80 |      40 |   72.56 | ...06-109,114-117 
  ...ngsDialog.tsx |   66.88 |    73.52 |     100 |   66.88 | ...11-819,825-826 
  ...ionDialog.tsx |    87.8 |      100 |   33.33 |    87.8 | 36-39,44-51       
  ...putPrompt.tsx |    15.9 |      100 |       0 |    15.9 | 20-63             
  ...Indicator.tsx |   57.14 |      100 |       0 |   57.14 | 12-15             
  ...MoreLines.tsx |      28 |      100 |       0 |      28 | 18-40             
  ...ionPicker.tsx |   17.59 |      100 |       0 |   17.59 | 55-172            
  StatsDisplay.tsx |     100 |      100 |     100 |     100 |                   
  ...yTodoList.tsx |   94.17 |       80 |     100 |   94.17 | 56-57,131-134     
  ...nsDisplay.tsx |   84.09 |    57.14 |     100 |   84.09 | ...16-118,125-127 
  ThemeDialog.tsx  |   89.95 |    46.15 |      75 |   89.95 | ...71-173,243-245 
  Tips.tsx         |   93.75 |       75 |     100 |   93.75 | 39-40             
  TodoDisplay.tsx  |     100 |      100 |     100 |     100 |                   
  ...tsDisplay.tsx |     100 |     87.5 |     100 |     100 | 31-32             
  TrustDialog.tsx  |     100 |    81.81 |     100 |     100 | 71-86             
  ...ification.tsx |   36.36 |      100 |       0 |   36.36 | 15-22             
  ...ackDialog.tsx |    7.84 |      100 |       0 |    7.84 | 24-134            
 ...nts/agent-view |    25.2 |       90 |      10 |    25.2 |                   
  ...atContent.tsx |    8.79 |      100 |       0 |    8.79 | 53-265,271-273    
  ...tChatView.tsx |   21.05 |      100 |       0 |   21.05 | 21-39             
  ...tComposer.tsx |    9.95 |      100 |       0 |    9.95 | 57-308            
  AgentFooter.tsx  |   17.07 |      100 |       0 |   17.07 | 28-66             
  AgentHeader.tsx  |   15.38 |      100 |       0 |   15.38 | 27-64             
  AgentTabBar.tsx  |    8.13 |      100 |       0 |    8.13 | 39-59,64-187      
  ...oryAdapter.ts |     100 |    91.83 |     100 |     100 | 103,109-110,138   
  index.ts         |       0 |        0 |       0 |       0 | 1-12              
 ...mponents/arena |   45.72 |    70.53 |   60.86 |   45.72 |                   
  ArenaCards.tsx   |   73.06 |    71.79 |   85.71 |   73.06 | ...83-185,321-326 
  ...ectDialog.tsx |   83.48 |    69.86 |   88.88 |   83.48 | ...88-392,409-410 
  ...artDialog.tsx |   10.15 |      100 |       0 |   10.15 | 27-161            
  ...tusDialog.tsx |    5.63 |      100 |       0 |    5.63 | 33-75,80-288      
  ...topDialog.tsx |    6.17 |      100 |       0 |    6.17 | 33-213            
 ...ackground-view |    71.2 |    79.71 |   78.94 |    71.2 |                   
  ...sksDialog.tsx |   71.23 |    78.83 |   73.33 |   71.23 | ...1063,1137-1139 
  ...TasksPill.tsx |   70.83 |    86.95 |     100 |   70.83 | 44,77-89,97-105   
 ...nts/extensions |   45.28 |    33.33 |      60 |   45.28 |                   
  ...gerDialog.tsx |   44.31 |    34.14 |      75 |   44.31 | ...71-480,483-488 
  index.ts         |       0 |        0 |       0 |       0 | 1-9               
  types.ts         |     100 |      100 |     100 |     100 |                   
 ...tensions/steps |   54.77 |    94.23 |   66.66 |   54.77 |                   
  ...ctionStep.tsx |   95.12 |    92.85 |   85.71 |   95.12 | 84-86,89          
  ...etailStep.tsx |    6.18 |      100 |       0 |    6.18 | 17-128            
  ...nListStep.tsx |   88.35 |    94.73 |      80 |   88.35 | 51-52,58-71,105   
  ...electStep.tsx |   13.46 |      100 |       0 |   13.46 | 20-70             
  ...nfirmStep.tsx |   19.56 |      100 |       0 |   19.56 | 23-65             
  index.ts         |     100 |      100 |     100 |     100 |                   
 ...mponents/hooks |   72.24 |    70.52 |      80 |   72.24 |                   
  ...etailStep.tsx |   96.52 |       75 |     100 |   96.52 | 33,37,50,59       
  ...etailStep.tsx |   93.27 |    73.68 |     100 |   93.27 | 41-42,99-104,110  
  ...abledStep.tsx |     100 |      100 |     100 |     100 |                   
  ...sListStep.tsx |     100 |      100 |     100 |     100 |                   
  ...entDialog.tsx |   36.09 |    47.05 |      50 |   36.09 | ...49,453-466,470 
  constants.ts     |     100 |      100 |     100 |     100 |                   
  index.ts         |       0 |        0 |       0 |       0 | 1-13              
  types.ts         |     100 |      100 |     100 |     100 |                   
 ...components/mcp |    20.2 |    84.61 |   81.81 |    20.2 |                   
  ...ealthPill.tsx |   68.42 |    85.71 |     100 |   68.42 | 40-46             
  ...entDialog.tsx |    3.64 |      100 |       0 |    3.64 | 41-717            
  constants.ts     |     100 |      100 |     100 |     100 |                   
  index.ts         |       0 |        0 |       0 |       0 | 1-30              
  types.ts         |     100 |      100 |     100 |     100 |                   
  utils.ts         |   96.42 |    87.09 |     100 |   96.42 | 21,96-97          
 ...ents/mcp/steps |    6.65 |      100 |       0 |    6.65 |                   
  ...icateStep.tsx |     5.1 |      100 |       0 |     5.1 | 34-95,98-334      
  ...electStep.tsx |   10.95 |      100 |       0 |   10.95 | 16-88             
  ...etailStep.tsx |    5.26 |      100 |       0 |    5.26 | 31-247            
  ...rListStep.tsx |    5.88 |      100 |       0 |    5.88 | 20-176            
  ...etailStep.tsx |   10.41 |      100 |       0 |   10.41 | ...1,67-79,82-139 
  ToolListStep.tsx |    7.14 |      100 |       0 |    7.14 | 16-146            
 ...nents/messages |   80.53 |    78.86 |   71.21 |   80.53 |                   
  ...ionDialog.tsx |   77.35 |    74.54 |    62.5 |   77.35 | ...90,508,526-528 
  BtwMessage.tsx   |     100 |      100 |     100 |     100 |                   
  ...upDisplay.tsx |   97.67 |    83.33 |     100 |   97.67 | 119,142,150       
  ...onMessage.tsx |   91.93 |    82.35 |     100 |   91.93 | 57-59,61,63       
  ...nMessages.tsx |   77.35 |      100 |      70 |   77.35 | ...31-244,248-260 
  DiffRenderer.tsx |   93.19 |    86.17 |     100 |   93.19 | ...09,237-238,304 
  ...tsDisplay.tsx |   97.82 |    77.27 |     100 |   97.82 | 87,89             
  ...ssMessage.tsx |    12.5 |      100 |       0 |    12.5 | 18-59             
  ...edMessage.tsx |   16.66 |      100 |       0 |   16.66 | 22-38             
  ...sMessages.tsx |   55.67 |       40 |   28.57 |   55.67 | ...20-125,133-145 
  ...ryMessage.tsx |   12.82 |      100 |       0 |   12.82 | 22-59             
  ...onMessage.tsx |   73.55 |    55.81 |   33.33 |   73.55 | ...41-443,450-452 
  ...upMessage.tsx |   76.95 |    82.08 |     100 |   76.95 | ...24-251,273-288 
  ToolMessage.tsx  |   90.68 |    81.35 |   91.66 |   90.68 | ...58-663,690-692 
 ...ponents/shared |    82.5 |    77.29 |   92.64 |    82.5 |                   
  ...ctionList.tsx |   99.03 |    95.65 |     100 |   99.03 | 85                
  ...tonSelect.tsx |     100 |      100 |     100 |     100 |                   
  EnumSelector.tsx |     100 |    96.42 |     100 |     100 | 58                
  MaxSizedBox.tsx  |   83.01 |    86.25 |   88.88 |   83.01 | ...12-513,618-619 
  MultiSelect.tsx  |    6.29 |      100 |       0 |    6.29 | 35-42,45-176      
  ...tonSelect.tsx |     100 |      100 |     100 |     100 |                   
  ...eSelector.tsx |     100 |       60 |     100 |     100 | 40-45             
  TextInput.tsx    |   74.84 |    57.14 |      75 |   74.84 | ...90-194,206-212 
  ...apsedTime.tsx |     100 |      100 |     100 |     100 |                   
  ...Indicator.tsx |     100 |      100 |     100 |     100 |                   
  text-buffer.ts   |   83.62 |    75.62 |   97.61 |   83.62 | ...2272,2300,2368 
  ...er-actions.ts |   86.71 |    67.79 |     100 |   86.71 | ...07-608,809-811 
 ...ents/subagents |   32.77 |    33.33 |    12.5 |   32.77 |                   
  constants.ts     |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  reducers.tsx     |    12.1 |      100 |       0 |    12.1 | 33-190            
  types.ts         |     100 |      100 |     100 |     100 |                   
  utils.ts         |   13.69 |    33.33 |   16.66 |   13.69 | ...1,56-57,60-102 
 ...bagents/create |    9.13 |      100 |       0 |    9.13 |                   
  ...ionWizard.tsx |    7.28 |      100 |       0 |    7.28 | 34-299            
  ...rSelector.tsx |   14.75 |      100 |       0 |   14.75 | 26-85             
  ...onSummary.tsx |    4.26 |      100 |       0 |    4.26 | 27-331            
  ...tionInput.tsx |    8.63 |      100 |       0 |    8.63 | 23-177            
  ...dSelector.tsx |   33.33 |      100 |       0 |   33.33 | 20-21,26-27,36-63 
  ...nSelector.tsx |    37.5 |      100 |       0 |    37.5 | 20-21,26-27,36-58 
  ...EntryStep.tsx |   12.76 |      100 |       0 |   12.76 | 34-78             
  ToolSelector.tsx |    4.16 |      100 |       0 |    4.16 | 31-253            
 ...bagents/manage |    8.39 |      100 |       0 |    8.39 |                   
  ...ctionStep.tsx |   10.25 |      100 |       0 |   10.25 | 21-103            
  ...eleteStep.tsx |   20.93 |      100 |       0 |   20.93 | 23-62             
  ...tEditStep.tsx |   25.53 |      100 |       0 |   25.53 | ...2,37-38,51-124 
  ...ctionStep.tsx |    2.29 |      100 |       0 |    2.29 | 28-449            
  ...iewerStep.tsx |   13.72 |      100 |       0 |   13.72 | 18-73             
  ...gerDialog.tsx |    6.74 |      100 |       0 |    6.74 | 35-341            
 ...agents/runtime |   81.76 |    58.24 |   92.85 |   81.76 |                   
  ...onDisplay.tsx |   81.76 |    58.24 |   92.85 |   81.76 | ...14-716,719-722 
 ...mponents/views |   42.16 |    69.23 |   21.42 |   42.16 |                   
  ContextUsage.tsx |     4.7 |      100 |       0 |     4.7 | ...52-167,170-456 
  DoctorReport.tsx |     9.8 |      100 |       0 |     9.8 | 25-54,57-131      
  ...sionsList.tsx |   87.69 |    73.68 |     100 |   87.69 | 65-72             
  McpStatus.tsx    |   89.53 |    60.52 |     100 |   89.53 | ...72,175-177,262 
  SkillsList.tsx   |   27.27 |      100 |       0 |   27.27 | 18-35             
  ToolsList.tsx    |     100 |      100 |     100 |     100 |                   
 src/ui/contexts   |   76.84 |    78.03 |   84.31 |   76.84 |                   
  ...ewContext.tsx |   65.77 |      100 |      75 |   65.77 | ...22-225,231-241 
  AppContext.tsx   |      80 |       50 |     100 |      80 | 19-20             
  ...ewContext.tsx |   93.37 |    68.57 |      50 |   93.37 | ...94-195,222-226 
  ...deContext.tsx |     100 |      100 |     100 |     100 |                   
  ...igContext.tsx |   81.81 |       50 |     100 |   81.81 | 15-16             
  ...ssContext.tsx |   81.88 |    82.26 |     100 |   81.88 | ...1153,1159-1161 
  ...owContext.tsx |   89.28 |       80 |   66.66 |   89.28 | 34,47-48,60-62    
  ...onContext.tsx |   43.28 |     62.5 |    62.5 |   43.28 | ...56-259,263-266 
  ...gsContext.tsx |   83.33 |       50 |     100 |   83.33 | 17-18             
  ...usContext.tsx |     100 |      100 |     100 |     100 |                   
  ...ngContext.tsx |   71.42 |       50 |     100 |   71.42 | 17-20             
  ...nsContext.tsx |   88.88 |       50 |     100 |   88.88 | 145-146           
  ...teContext.tsx |   85.71 |       50 |     100 |   85.71 | 175-176           
  ...deContext.tsx |   76.08 |    72.72 |     100 |   76.08 | 47-48,52-59,77-78 
 src/ui/editors    |   93.33 |    85.71 |   66.66 |   93.33 |                   
  ...ngsManager.ts |   93.33 |    85.71 |   66.66 |   93.33 | 49,63-64          
 src/ui/hooks      |    80.8 |    81.38 |   85.56 |    80.8 |                   
  ...dProcessor.ts |   83.12 |    82.56 |     100 |   83.12 | ...88-389,408-435 
  keyToAnsi.ts     |    3.92 |      100 |       0 |    3.92 | 19-77             
  ...dProcessor.ts |    94.8 |    70.58 |     100 |    94.8 | ...76-277,282-283 
  ...dProcessor.ts |   72.85 |    57.85 |   61.53 |   72.85 | ...84,808,827-831 
  ...amingState.ts |   12.22 |      100 |       0 |   12.22 | 54-158            
  ...agerDialog.ts |   88.23 |      100 |     100 |   88.23 | 20,24             
  ...ationFrame.ts |      32 |       60 |     100 |      32 | 42-44,51-90       
  ...odeCommand.ts |   58.82 |      100 |     100 |   58.82 | 28,33-48          
  ...enaCommand.ts |      85 |      100 |     100 |      85 | 23-24,29          
  ...aInProcess.ts |   19.81 |    66.66 |      25 |   19.81 | 57-175            
  ...Completion.ts |   92.77 |    89.09 |     100 |   92.77 | ...86-187,220-223 
  ...ifications.ts |   92.07 |    96.29 |     100 |   92.07 | 116-124           
  ...tIndicator.ts |     100 |    93.75 |     100 |     100 | 63                
  ...waySummary.ts |   96.22 |    69.69 |     100 |   96.22 | 125-127,169       
  ...ndTaskView.ts |   94.11 |    76.92 |     100 |   94.11 | 119-123,216,222   
  ...ketedPaste.ts |    23.8 |      100 |       0 |    23.8 | 19-37             
  ...lanUpdates.ts |     100 |       92 |     100 |     100 | 59,158            
  ...ompletion.tsx |   91.28 |    79.59 |     100 |   91.28 | ...20-221,259-269 
  ...dMigration.ts |   90.62 |       75 |     100 |   90.62 | 38-40             
  useCompletion.ts |    92.4 |     87.5 |     100 |    92.4 | 68-69,93-94,98-99 
  ...nitMessage.ts |     100 |      100 |     100 |     100 |                   
  ...extualTips.ts |   76.92 |       50 |     100 |   76.92 | 55,68,71-75,88-96 
  ...eteCommand.ts |   33.33 |       50 |     100 |   33.33 | 30,34,41-90       
  ...ialogClose.ts |   18.18 |      100 |     100 |   18.18 | 75-130            
  ...oublePress.ts |   53.12 |       75 |     100 |   53.12 | 33-35,41-54       
  ...orSettings.ts |     100 |      100 |     100 |     100 |                   
  ...Completion.ts |   99.12 |     97.7 |     100 |   99.12 | 182-183           
  ...ionUpdates.ts |   93.45 |     92.3 |     100 |   93.45 | ...83-287,300-306 
  ...agerDialog.ts |   88.88 |      100 |     100 |   88.88 | 21,25             
  ...backDialog.ts |   54.88 |       50 |   33.33 |   54.88 | ...71-173,195-196 
  useFocus.ts      |     100 |      100 |     100 |     100 |                   
  ...olderTrust.ts |     100 |      100 |     100 |     100 |                   
  ...ggestions.tsx |   67.46 |       90 |      50 |   67.46 | ...09-130,149-150 
  ...miniStream.ts |   75.84 |    72.89 |   91.66 |   75.84 | ...2293,2306-2314 
  ...BranchName.ts |    90.9 |     92.3 |     100 |    90.9 | 19-20,55-58       
  ...oryManager.ts |   93.15 |    93.75 |     100 |   93.15 | 44,107-110        
  ...ooksDialog.ts |    87.5 |      100 |     100 |    87.5 | 19,23             
  ...stListener.ts |     100 |      100 |     100 |     100 |                   
  ...nAuthError.ts |   76.19 |       50 |     100 |   76.19 | 39-40,43-45       
  ...putHistory.ts |   92.59 |    85.71 |     100 |   92.59 | 63-64,72,94-96    
  ...storyStore.ts |     100 |    94.11 |     100 |     100 | 69                
  useKeypress.ts   |     100 |      100 |     100 |     100 |                   
  ...rdProtocol.ts |   36.36 |      100 |       0 |   36.36 | 24-31             
  ...unchEditor.ts |    9.67 |      100 |       0 |    9.67 | 11-32,39-90       
  ...gIndicator.ts |     100 |      100 |     100 |     100 |                   
  useLogger.ts     |   21.05 |      100 |       0 |   21.05 | 15-37             
  useMCPHealth.ts  |   70.58 |       75 |      50 |   70.58 | 42-47,59-62       
  ...elsCommand.ts |     100 |      100 |     100 |     100 |                   
  useMcpDialog.ts  |    87.5 |      100 |     100 |    87.5 | 19,23             
  ...moryDialog.ts |    87.5 |      100 |     100 |    87.5 | 19,23             
  ...oryMonitor.ts |     100 |      100 |     100 |     100 |                   
  ...ssageQueue.ts |     100 |      100 |     100 |     100 |                   
  ...delCommand.ts |     100 |       75 |     100 |     100 | 22                
  ...raseCycler.ts |   84.74 |    76.47 |     100 |   84.74 | ...49,52-53,69-71 
  useQwenAuth.ts   |     100 |      100 |     100 |     100 |                   
  ...lScheduler.ts |   84.52 |    93.33 |     100 |   84.52 | ...27-232,328-338 
  ...oryCommand.ts |       0 |        0 |       0 |       0 | 1-7               
  ...umeCommand.ts |   97.24 |    76.92 |     100 |   97.24 | 104-105,145       
  ...ompletion.tsx |   90.59 |    83.33 |     100 |   90.59 | ...01,104,137-140 
  ...ectionList.ts |   96.96 |    95.69 |     100 |   96.96 | ...82-183,237-240 
  ...sionPicker.ts |   90.23 |    71.69 |     100 |   90.23 | ...78-279,283-284 
  ...ngsCommand.ts |   18.75 |      100 |       0 |   18.75 | 10-25             
  ...ellHistory.ts |   91.74 |    79.41 |     100 |   91.74 | ...74,122-123,133 
  ...oryCommand.ts |       0 |        0 |       0 |       0 | 1-73              
  ...Completion.ts |   78.99 |    81.48 |   94.11 |   78.99 | ...77-579,587-624 
  ...tateAndRef.ts |     100 |      100 |     100 |     100 |                   
  useStatusLine.ts |     100 |    98.79 |     100 |     100 | 257               
  ...eateDialog.ts |   88.23 |      100 |     100 |   88.23 | 14,18             
  ...tification.ts |     100 |    85.71 |     100 |     100 | 47                
  ...alProgress.ts |   53.06 |       50 |   66.66 |   53.06 | ...53,61-68,79-85 
  ...rminalSize.ts |   76.19 |      100 |      50 |   76.19 | 21-25             
  ...emeCommand.ts |   67.01 |    29.41 |     100 |   67.01 | ...10-111,115-116 
  useTimer.ts      |   88.09 |    85.71 |     100 |   88.09 | 44-45,51-53       
  ...lMigration.ts |       0 |        0 |       0 |       0 |                   
  ...rustModify.ts |     100 |      100 |     100 |     100 |                   
  ...elcomeBack.ts |   87.36 |     90.9 |     100 |   87.36 | ...,94-96,114-115 
  vim.ts           |   83.77 |    80.31 |     100 |   83.77 | ...55,759-767,776 
 src/ui/layouts    |   89.51 |    86.95 |     100 |   89.51 |                   
  ...AppLayout.tsx |   89.53 |    86.66 |     100 |   89.53 | 50-52,92-97       
  ...AppLayout.tsx |   89.47 |     87.5 |     100 |   89.47 | 58-63             
 ...i/manageModels |   93.61 |       48 |     100 |   93.61 |                   
  manageModels.ts  |   93.61 |       48 |     100 |   93.61 | ...63-166,179,209 
 src/ui/models     |   80.24 |    79.16 |   71.42 |   80.24 |                   
  ...ableModels.ts |   80.24 |    79.16 |   71.42 |   80.24 | ...,61-71,123-125 
 ...noninteractive |     100 |      100 |    7.14 |     100 |                   
  ...eractiveUi.ts |     100 |      100 |    7.14 |     100 |                   
 src/ui/state      |   94.91 |    81.81 |     100 |   94.91 |                   
  extensions.ts    |   94.91 |    81.81 |     100 |   94.91 | 68-69,88          
 src/ui/themes     |   98.53 |    70.31 |     100 |   98.53 |                   
  ansi-light.ts    |     100 |      100 |     100 |     100 |                   
  ansi.ts          |     100 |      100 |     100 |     100 |                   
  atom-one-dark.ts |     100 |      100 |     100 |     100 |                   
  ayu-light.ts     |     100 |      100 |     100 |     100 |                   
  ayu.ts           |     100 |      100 |     100 |     100 |                   
  color-utils.ts   |     100 |      100 |     100 |     100 |                   
  default-light.ts |     100 |      100 |     100 |     100 |                   
  default.ts       |     100 |      100 |     100 |     100 |                   
  ...inal-theme.ts |   88.59 |    85.45 |     100 |   88.59 | ...57-261,266-270 
  dracula.ts       |     100 |      100 |     100 |     100 |                   
  github-dark.ts   |     100 |      100 |     100 |     100 |                   
  github-light.ts  |     100 |      100 |     100 |     100 |                   
  googlecode.ts    |     100 |      100 |     100 |     100 |                   
  no-color.ts      |     100 |      100 |     100 |     100 |                   
  qwen-dark.ts     |     100 |      100 |     100 |     100 |                   
  qwen-light.ts    |     100 |      100 |     100 |     100 |                   
  ...tic-tokens.ts |     100 |      100 |     100 |     100 |                   
  ...-of-purple.ts |     100 |      100 |     100 |     100 |                   
  theme-manager.ts |   87.98 |    82.89 |     100 |   87.98 | ...48-357,362-363 
  theme.ts         |     100 |    38.02 |     100 |     100 | ...34-449,457-461 
  xcode.ts         |     100 |      100 |     100 |     100 |                   
 src/ui/utils      |   78.17 |    86.93 |   86.87 |   78.17 |                   
  ...Colorizer.tsx |   82.78 |    88.23 |     100 |   82.78 | ...10-111,197-223 
  ...nRenderer.tsx |   52.41 |    36.36 |      50 |   52.41 | ...49-151,171-180 
  ...wnDisplay.tsx |   86.79 |    88.88 |     100 |   86.79 | ...06-315,348-373 
  ...eRenderer.tsx |   94.45 |    81.25 |   94.11 |   94.45 | ...65,477,480-483 
  ...dWorkUtils.ts |     100 |      100 |     100 |     100 |                   
  ...boardUtils.ts |   59.61 |    58.82 |     100 |   59.61 | ...,86-88,107-149 
  commandUtils.ts  |    84.7 |    88.13 |      90 |    84.7 | ...63-164,260-279 
  computeStats.ts  |     100 |      100 |     100 |     100 |                   
  customBanner.ts  |   90.68 |    91.22 |     100 |   90.68 | ...13,324-327,334 
  displayUtils.ts  |   88.37 |    72.22 |     100 |   88.37 | 23,25,29,31,33    
  formatters.ts    |   95.23 |    98.27 |     100 |   95.23 | 117-120           
  gradientUtils.ts |     100 |      100 |     100 |     100 |                   
  highlight.ts     |   98.63 |       95 |     100 |   98.63 | 93                
  ...oryMapping.ts |     100 |    94.28 |     100 |     100 | 34,56             
  isNarrowWidth.ts |     100 |      100 |     100 |     100 |                   
  ...olDetector.ts |    8.23 |      100 |       0 |    8.23 | ...31-132,135-136 
  layoutUtils.ts   |     100 |      100 |     100 |     100 |                   
  ...nUtilities.ts |   69.84 |    85.71 |     100 |   69.84 | 75-91,100-101     
  ...ToolGroups.ts |    98.3 |    95.65 |     100 |    98.3 | 48-49             
  ...lsBySource.ts |     100 |    95.23 |     100 |     100 | 84                
  ...mConstants.ts |     100 |      100 |     100 |     100 |                   
  ...storyUtils.ts |   57.81 |    67.14 |      90 |   57.81 | ...64,412,417-439 
  ...ickerUtils.ts |     100 |      100 |     100 |     100 |                   
  ...izedOutput.ts |   94.94 |      100 |   88.88 |   94.94 | 112-117           
  ...wOptimizer.ts |     100 |    96.77 |     100 |     100 | 69                
  terminalSetup.ts |    4.37 |      100 |       0 |    4.37 | 44-393            
  textUtils.ts     |   97.35 |    94.44 |   91.66 |   97.35 | ...50-251,386-387 
  todoSnapshot.ts  |   89.11 |    93.18 |     100 |   89.11 | ...,66-78,180-181 
  updateCheck.ts   |     100 |    80.95 |     100 |     100 | 30-42             
 ...i/utils/export |   56.77 |     40.8 |   79.41 |   56.77 |                   
  collect.ts       |   55.92 |    50.58 |   86.36 |   55.92 | ...25-640,642-647 
  index.ts         |     100 |      100 |     100 |     100 |                   
  normalize.ts     |   57.47 |    20.51 |      80 |   57.47 | ...09-310,324-359 
  types.ts         |       0 |        0 |       0 |       0 | 1                 
  utils.ts         |      40 |      100 |       0 |      40 | 11-13             
 ...ort/formatters |    3.38 |      100 |       0 |    3.38 |                   
  html.ts          |    9.61 |      100 |       0 |    9.61 | ...28,34-76,82-84 
  json.ts          |      50 |      100 |       0 |      50 | 14-15             
  jsonl.ts         |     3.5 |      100 |       0 |     3.5 | 14-76             
  markdown.ts      |    0.94 |      100 |       0 |    0.94 | 13-295            
 src/utils         |   73.76 |    89.53 |   94.55 |   73.76 |                   
  acpModelUtils.ts |     100 |      100 |     100 |     100 |                   
  apiPreconnect.ts |   96.52 |    97.05 |     100 |   96.52 | 166-169           
  checks.ts        |   33.33 |      100 |       0 |   33.33 | 23-28             
  cleanup.ts       |   84.12 |    93.33 |      80 |   84.12 | 75,106-115        
  commands.ts      |     100 |      100 |     100 |     100 |                   
  commentJson.ts   |   85.29 |    89.47 |     100 |   85.29 | 48-57             
  ...Calculator.ts |     100 |      100 |     100 |     100 |                   
  deepMerge.ts     |     100 |       90 |     100 |     100 | 41-43,49          
  ...ScopeUtils.ts |   97.56 |    88.88 |     100 |   97.56 | 67                
  doctorChecks.ts  |   68.59 |    64.28 |     100 |   68.59 | ...63-269,293-309 
  ...putCapture.ts |   90.65 |    86.17 |     100 |   90.65 | ...72,370,372-373 
  ...arResolver.ts |   94.28 |    88.46 |     100 |   94.28 | 28-29,125-126     
  errors.ts        |   98.63 |    96.15 |     100 |   98.63 | 67-68             
  events.ts        |     100 |      100 |     100 |     100 |                   
  gitUtils.ts      |   91.91 |    84.61 |     100 |   91.91 | 78-81,124-127     
  ...AutoUpdate.ts |   90.76 |    93.33 |   88.88 |   90.76 | 103-114           
  ...lationInfo.ts |     100 |      100 |     100 |     100 |                   
  languageUtils.ts |   97.89 |    96.42 |     100 |   97.89 | 132-133           
  math.ts          |       0 |        0 |       0 |       0 | 1-15              
  ...onfigUtils.ts |     100 |      100 |     100 |     100 |                   
  ...iveHelpers.ts |   96.79 |    93.28 |     100 |   96.79 | ...76-477,575,588 
  osc.ts           |    97.5 |      100 |   88.88 |    97.5 | 195-196           
  package.ts       |   88.88 |       80 |     100 |   88.88 | 33-34             
  processUtils.ts  |     100 |      100 |     100 |     100 |                   
  readStdin.ts     |   79.62 |       90 |      80 |   79.62 | 33-40,52-54       
  relaunch.ts      |   98.07 |    76.92 |     100 |   98.07 | 70                
  resolvePath.ts   |   66.66 |       25 |     100 |   66.66 | 12-13,16,18-19    
  sandbox.ts       |       0 |        0 |       0 |       0 | 1-980             
  settingsUtils.ts |   86.32 |    90.59 |   94.44 |   86.32 | ...38,569,632-644 
  spawnWrapper.ts  |     100 |      100 |     100 |     100 |                   
  ...upProfiler.ts |     100 |    95.83 |     100 |     100 | 110               
  ...upWarnings.ts |     100 |      100 |     100 |     100 |                   
  stdioHelpers.ts  |     100 |       60 |     100 |     100 | 23,32             
  systemInfo.ts    |   92.52 |     90.9 |   83.33 |   92.52 | 63-69,184         
  ...InfoFields.ts |   86.91 |    65.78 |     100 |   86.91 | ...16-117,138-139 
  ...iffPreview.ts |   94.11 |    83.33 |     100 |   94.11 | 13                
  ...entEmitter.ts |     100 |      100 |     100 |     100 |                   
  ...upWarnings.ts |   91.17 |    82.35 |     100 |   91.17 | 67-68,73-74,77-78 
  version.ts       |     100 |       50 |     100 |     100 | 11                
  windowTitle.ts   |     100 |      100 |     100 |     100 |                   
  ...WithBackup.ts |    62.1 |    77.77 |     100 |    62.1 | 93,107,118-157    
-------------------|---------|----------|---------|---------|-------------------
Core Package - Full Text Report
-------------------|---------|----------|---------|---------|-------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------|---------|----------|---------|---------|-------------------
All files          |   76.74 |    82.11 |   79.33 |   76.74 |                   
 src               |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
 src/__mocks__/fs  |       0 |        0 |       0 |       0 |                   
  promises.ts      |       0 |        0 |       0 |       0 | 1-48              
 src/agents        |   84.07 |    76.02 |   90.66 |   84.07 |                   
  ...transcript.ts |   88.76 |    75.43 |     100 |   88.76 | ...82,306-307,434 
  ...ent-resume.ts |   78.67 |    69.51 |   76.66 |   78.67 | ...88-992,995-997 
  ...ound-tasks.ts |   94.19 |    86.17 |     100 |   94.19 | ...15-616,633-634 
  index.ts         |     100 |      100 |     100 |     100 |                   
 src/agents/arena  |    76.9 |    66.66 |   78.94 |    76.9 |                   
  ...gentClient.ts |   79.47 |    88.88 |   81.81 |   79.47 | ...68-183,189-204 
  ArenaManager.ts  |   75.84 |     62.9 |   78.57 |   75.84 | ...1889,1895-1896 
  arena-events.ts  |   64.44 |      100 |      50 |   64.44 | ...71-175,178-183 
  diff-summary.ts  |    87.5 |    73.46 |     100 |    87.5 | ...32-133,137-138 
  index.ts         |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 ...gents/backends |    76.3 |    86.23 |   72.41 |    76.3 |                   
  ITermBackend.ts  |   97.97 |    93.93 |     100 |   97.97 | ...78-180,255,307 
  ...essBackend.ts |   91.06 |     90.9 |   82.35 |   91.06 | ...51-271,330,430 
  TmuxBackend.ts   |    90.7 |    76.55 |   97.36 |    90.7 | ...87,697,743-747 
  detect.ts        |   31.25 |      100 |       0 |   31.25 | 34-88             
  index.ts         |     100 |      100 |     100 |     100 |                   
  iterm-it2.ts     |     100 |     92.1 |     100 |     100 | 37-38,106         
  tmux-commands.ts |    6.64 |      100 |    3.03 |    6.64 | ...93-363,386-503 
  types.ts         |     100 |      100 |     100 |     100 |                   
 ...agents/runtime |   79.81 |    75.21 |      66 |   79.81 |                   
  agent-core.ts    |   73.97 |    69.03 |   48.48 |   73.97 | ...1299,1326-1372 
  agent-events.ts  |     100 |      100 |     100 |     100 |                   
  ...t-headless.ts |   79.09 |    69.76 |   52.38 |   79.09 | ...78-379,382-383 
  ...nteractive.ts |   79.71 |    79.62 |      75 |   79.71 | ...54,456,458,461 
  ...statistics.ts |   98.19 |    82.35 |     100 |   98.19 | 127,151,192,225   
  agent-types.ts   |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
 src/config        |    74.7 |    76.92 |    61.2 |    74.7 |                   
  config.ts        |   72.35 |     74.3 |   55.61 |   72.35 | ...2888,2892-2904 
  constants.ts     |     100 |      100 |     100 |     100 |                   
  models.ts        |     100 |      100 |     100 |     100 |                   
  storage.ts       |   95.72 |     93.1 |   91.66 |   95.72 | ...06-207,241-242 
 ...nfirmation-bus |   98.29 |    97.14 |     100 |   98.29 |                   
  message-bus.ts   |   98.14 |    97.05 |     100 |   98.14 | 42-43             
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/constants     |    4.95 |      100 |       0 |    4.95 |                   
  codingPlan.ts    |    4.95 |      100 |       0 |    4.95 | ...79-291,299-309 
 src/core          |   82.62 |    82.26 |   87.91 |   82.62 |                   
  baseLlmClient.ts |   96.77 |    96.42 |      80 |   96.77 | 123-126           
  client.ts        |   77.17 |    77.88 |    86.2 |   77.17 | ...1264,1268-1284 
  ...tGenerator.ts |    72.1 |    61.11 |     100 |    72.1 | ...63,365,372-375 
  ...lScheduler.ts |   77.12 |    81.01 |   92.68 |   77.12 | ...2200,2252-2256 
  geminiChat.ts    |   87.95 |     83.9 |   83.33 |   87.95 | ...1137,1204-1205 
  geminiRequest.ts |     100 |      100 |     100 |     100 |                   
  ...htProtocol.ts |    9.09 |      100 |       0 |    9.09 | 34-42,45-49,52-87 
  logger.ts        |   82.25 |    81.81 |     100 |   82.25 | ...57-361,407-421 
  ...tyDefaults.ts |     100 |      100 |     100 |     100 |                   
  ...olExecutor.ts |   92.59 |       75 |      50 |   92.59 | 41-42             
  ...on-helpers.ts |   85.71 |    70.58 |     100 |   85.71 | ...90-191,205-214 
  ...issionFlow.ts |   98.59 |    94.73 |     100 |   98.59 | 93                
  prompts.ts       |    88.8 |    88.05 |      75 |    88.8 | ...-898,1101-1102 
  tokenLimits.ts   |     100 |    89.47 |     100 |     100 | 51-52             
  ...okTriggers.ts |   99.31 |    91.02 |     100 |   99.31 | 124,135           
  turn.ts          |   96.42 |    88.88 |     100 |   96.42 | ...00,413-414,462 
 ...ntentGenerator |    94.6 |    79.35 |   92.68 |    94.6 |                   
  ...tGenerator.ts |   96.49 |    79.35 |      90 |   96.49 | ...24,481,637,693 
  converter.ts     |   94.38 |    79.78 |     100 |   94.38 | ...40-541,551,734 
  index.ts         |       0 |        0 |       0 |       0 | 1-21              
 ...ntentGenerator |   91.53 |    71.64 |   93.33 |   91.53 |                   
  ...tGenerator.ts |      90 |    70.96 |   92.85 |      90 | ...80-286,304-305 
  index.ts         |     100 |       80 |     100 |     100 | 50                
 ...ntentGenerator |   91.08 |    76.14 |   85.71 |   91.08 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...tGenerator.ts |   91.04 |    76.14 |   85.71 |   91.04 | ...23,533-534,562 
 ...ntentGenerator |   79.48 |    83.73 |   89.47 |   79.48 |                   
  constants.ts     |     100 |      100 |     100 |     100 |                   
  converter.ts     |   74.92 |    80.85 |   86.95 |   74.92 | ...1410,1431-1437 
  errorHandler.ts  |     100 |      100 |     100 |     100 |                   
  index.ts         |   43.85 |    14.28 |      50 |   43.85 | ...,87-91,102-103 
  ...tGenerator.ts |   48.78 |    91.66 |   77.77 |   48.78 | ...10-163,166-167 
  pipeline.ts      |   93.62 |    84.76 |     100 |   93.62 | ...78-479,487,547 
  ...ingOptions.ts |       0 |        0 |       0 |       0 | 1                 
  ...CallParser.ts |   90.66 |     88.4 |     100 |   90.66 | ...15-319,349-350 
  ...kingParser.ts |     100 |    96.87 |     100 |     100 | 42                
  types.ts         |       0 |        0 |       0 |       0 | 1                 
 ...rator/provider |   96.67 |    89.74 |   94.87 |   96.67 |                   
  dashscope.ts     |   97.22 |    87.69 |   93.33 |   97.22 | ...10-211,287-288 
  deepseek.ts      |   95.55 |    90.56 |     100 |   95.55 | ...31-132,145-146 
  default.ts       |   94.62 |    86.36 |   85.71 |   94.62 | 85-86,156-158     
  index.ts         |     100 |      100 |     100 |     100 |                   
  minimax.ts       |     100 |      100 |     100 |     100 |                   
  modelscope.ts    |     100 |      100 |     100 |     100 |                   
  openrouter.ts    |     100 |      100 |     100 |     100 |                   
  types.ts         |       0 |        0 |       0 |       0 |                   
 src/extension     |   60.62 |    79.43 |   79.03 |   60.62 |                   
  ...-converter.ts |   62.35 |    47.82 |      90 |   62.35 | ...90-791,800-832 
  ...ionManager.ts |   46.92 |    82.19 |   67.44 |   46.92 | ...1386,1396-1415 
  ...onSettings.ts |   93.46 |    93.05 |     100 |   93.46 | ...17-221,228-232 
  ...-converter.ts |   54.88 |    94.44 |      60 |   54.88 | ...35-146,158-192 
  github.ts        |   44.94 |    88.52 |      60 |   44.94 | ...53-359,398-451 
  index.ts         |     100 |      100 |     100 |     100 |                   
  marketplace.ts   |   97.29 |    93.75 |     100 |   97.29 | ...64,184-185,274 
  npm.ts           |   48.66 |    76.08 |      75 |   48.66 | ...18-420,427-431 
  override.ts      |   94.11 |    88.88 |     100 |   94.11 | 63-64,81-82       
  settings.ts      |   66.26 |      100 |      50 |   66.26 | 81-108,143-149    
  storage.ts       |   94.73 |       90 |     100 |   94.73 | 41-42             
  ...ableSchema.ts |     100 |      100 |     100 |     100 |                   
  variables.ts     |   88.75 |    83.33 |     100 |   88.75 | ...28-231,234-237 
 src/followup      |   46.35 |     92.3 |   71.87 |   46.35 |                   
  followupState.ts |      96 |    89.74 |     100 |      96 | 159-161,218-219   
  index.ts         |     100 |      100 |     100 |     100 |                   
  overlayFs.ts     |   95.06 |       84 |     100 |   95.06 | 78,108,122,133    
  speculation.ts   |   13.22 |      100 |   16.66 |   13.22 | 88-458,518-568    
  ...onToolGate.ts |     100 |    96.29 |     100 |     100 | 93                
  ...nGenerator.ts |   36.67 |    95.12 |   33.33 |   36.67 | ...24-326,361-391 
 src/generated     |       0 |        0 |       0 |       0 |                   
  git-commit.ts    |       0 |        0 |       0 |       0 | 1-10              
 src/hooks         |    80.6 |    84.37 |   84.16 |    80.6 |                   
  ...okRegistry.ts |   86.48 |    77.08 |     100 |   86.48 | ...41-344,362-369 
  ...bortSignal.ts |     100 |      100 |     100 |     100 |                   
  ...terpolator.ts |   96.66 |    93.33 |     100 |   96.66 | 66-67             
  ...HookRunner.ts |   96.68 |    87.23 |     100 |   96.68 | 110-112,231-233   
  ...Aggregator.ts |   96.37 |    90.54 |     100 |   96.37 | ...89,291-292,365 
  ...entHandler.ts |   95.58 |    84.37 |   92.59 |   95.58 | ...29,682-683,693 
  hookPlanner.ts   |   84.13 |    76.59 |      90 |   84.13 | ...38,144,162-173 
  hookRegistry.ts  |   88.83 |    86.36 |     100 |   88.83 | ...21,326,330,334 
  hookRunner.ts    |   53.63 |    72.22 |   61.11 |   53.63 | ...23-724,733-734 
  hookSystem.ts    |   75.47 |      100 |   56.41 |   75.47 | ...75-576,582-583 
  ...HookRunner.ts |   75.51 |     61.9 |      80 |   75.51 | ...05-406,424-425 
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...SkillHooks.ts |   78.75 |       75 |   66.66 |   78.75 | 62-66,137-152     
  ...oksManager.ts |    96.5 |     91.8 |     100 |    96.5 | ...90,209-210,223 
  ssrfGuard.ts     |   77.22 |    85.36 |     100 |   77.22 | ...57,261-267,273 
  trustedHooks.ts  |       0 |        0 |       0 |       0 | 1-124             
  types.ts         |   90.15 |    91.02 |   85.18 |   90.15 | ...91-392,452-456 
  urlValidator.ts  |     100 |      100 |     100 |     100 |                   
 src/ide           |   74.28 |    83.39 |   78.33 |   74.28 |                   
  constants.ts     |     100 |      100 |     100 |     100 |                   
  detect-ide.ts    |     100 |      100 |     100 |     100 |                   
  ide-client.ts    |    64.2 |    81.48 |   66.66 |    64.2 | ...9-970,999-1007 
  ide-installer.ts |   89.06 |    79.31 |     100 |   89.06 | ...36,143-147,160 
  ideContext.ts    |     100 |      100 |     100 |     100 |                   
  process-utils.ts |   84.84 |    71.79 |     100 |   84.84 | ...37,151,193-194 
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/lsp           |   33.92 |    45.16 |   45.76 |   33.92 |                   
  ...nfigLoader.ts |   70.27 |    35.89 |   94.73 |   70.27 | ...20-422,426-432 
  ...ionFactory.ts |    4.29 |      100 |       0 |    4.29 | ...20-371,377-394 
  ...Normalizer.ts |   23.09 |    13.72 |   30.43 |   23.09 | ...04-905,909-924 
  ...verManager.ts |   13.52 |    81.25 |   29.16 |   13.52 | ...75-694,700-730 
  ...eLspClient.ts |   17.89 |      100 |       0 |   17.89 | ...37-244,254-258 
  ...LspService.ts |   45.87 |    62.13 |   66.66 |   45.87 | ...1282,1299-1309 
  constants.ts     |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/mcp           |   78.69 |    75.34 |   75.92 |   78.69 |                   
  constants.ts     |     100 |      100 |     100 |     100 |                   
  ...h-provider.ts |   86.95 |      100 |   33.33 |   86.95 | ...,93,97,101-102 
  ...h-provider.ts |   73.82 |    53.92 |     100 |   73.82 | ...88-895,902-904 
  ...en-storage.ts |   98.62 |    97.72 |     100 |   98.62 | 87-88             
  oauth-utils.ts   |   70.58 |    85.29 |    90.9 |   70.58 | ...70-290,315-344 
  ...n-provider.ts |   89.83 |    95.83 |   45.45 |   89.83 | ...43,147,151-152 
 .../token-storage |   79.48 |    86.66 |   86.36 |   79.48 |                   
  ...en-storage.ts |     100 |      100 |     100 |     100 |                   
  ...en-storage.ts |   82.75 |    82.35 |   92.85 |   82.75 | ...62-172,180-181 
  ...en-storage.ts |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...en-storage.ts |   68.14 |    82.35 |   64.28 |   68.14 | ...81-295,298-314 
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/memory        |   61.59 |    74.87 |   66.44 |   61.59 |                   
  const.ts         |     100 |      100 |     100 |     100 |                   
  dream.ts         |   65.65 |    73.33 |      50 |   65.65 | 50,107-148        
  ...entPlanner.ts |   57.84 |    72.72 |   33.33 |   57.84 | ...35,140-147,152 
  entries.ts       |   59.84 |       70 |      50 |   59.84 | ...72-180,183-189 
  extract.ts       |    95.2 |    79.16 |     100 |    95.2 | 81-86,125         
  ...entPlanner.ts |   63.08 |    65.71 |   41.17 |   63.08 | ...17,222-223,332 
  ...ionPlanner.ts |       0 |        0 |       0 |       0 | 1                 
  forget.ts        |    8.04 |      100 |       0 |    8.04 | 67-342            
  governance.ts    |       0 |        0 |       0 |       0 | 1-352             
  indexer.ts       |   83.87 |    45.45 |     100 |   83.87 | ...50,56-57,69-70 
  manager.ts       |   73.32 |    78.94 |   74.35 |   73.32 | ...1163,1176-1178 
  memoryAge.ts     |   90.47 |    77.77 |     100 |   90.47 | 50-51             
  paths.ts         |   55.47 |    89.47 |   85.71 |   55.47 | ...,88-89,105-113 
  prompt.ts        |   93.36 |    71.42 |     100 |   93.36 | ...58,161,228-229 
  recall.ts        |   79.56 |    69.38 |   88.88 |   79.56 | ...40-245,269-280 
  ...ceSelector.ts |   91.86 |    77.27 |     100 |   91.86 | ...04,106-107,115 
  scan.ts          |   87.91 |    68.42 |     100 |   87.91 | ...47-48,58,82-87 
  status.ts        |   10.52 |      100 |       0 |   10.52 | 41-98             
  store.ts         |   94.44 |    83.33 |     100 |   94.44 | 56-57,92-93       
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/mocks         |       0 |        0 |       0 |       0 |                   
  msw.ts           |       0 |        0 |       0 |       0 | 1-9               
 src/models        |   89.49 |    85.58 |   87.14 |   89.49 |                   
  constants.ts     |     100 |      100 |     100 |     100 |                   
  ...tor-config.ts |   88.67 |     90.9 |     100 |   88.67 | 112,118,121-130   
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...nfigErrors.ts |   74.22 |       44 |   84.61 |   74.22 | ...,67-74,106-117 
  ...igResolver.ts |   98.63 |    92.53 |     100 |   98.63 | 161,323,329       
  modelRegistry.ts |     100 |    98.21 |     100 |     100 | 182               
  modelsConfig.ts  |   85.37 |    83.54 |   81.57 |   85.37 | ...1210,1239-1240 
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/output        |     100 |      100 |     100 |     100 |                   
  ...-formatter.ts |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/permissions   |   71.18 |    88.73 |   48.57 |   71.18 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...on-manager.ts |   81.42 |    86.66 |      80 |   81.42 | ...19-820,827-836 
  rule-parser.ts   |   95.99 |    93.18 |     100 |   95.99 | ...-864,1013-1015 
  ...-semantics.ts |   58.28 |    85.27 |    30.2 |   58.28 | ...1604-1614,1643 
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/prompts       |   83.63 |      100 |    87.5 |   83.63 |                   
  mcp-prompts.ts   |   18.18 |      100 |       0 |   18.18 | 11-19             
  ...t-registry.ts |     100 |      100 |     100 |     100 |                   
 src/qwen          |   86.03 |    79.48 |   97.18 |   86.03 |                   
  ...tGenerator.ts |   98.64 |    98.18 |     100 |   98.64 | 105-106           
  qwenOAuth2.ts    |   85.01 |    74.81 |   93.33 |   85.01 | ...,986-1002,1032 
  ...kenManager.ts |   83.79 |    76.22 |     100 |   83.79 | ...63-768,789-794 
 src/services      |   84.83 |    83.66 |   89.14 |   84.83 |                   
  ...llRegistry.ts |   97.82 |    94.73 |     100 |   97.82 | 172-173           
  ...ionService.ts |   95.42 |       94 |     100 |   95.42 | ...79,336,338-342 
  ...ingService.ts |   79.37 |     82.5 |   78.12 |   79.37 | ...1066,1083-1084 
  cronScheduler.ts |   97.56 |    92.98 |     100 |   97.56 | 62-63,77,155      
  ...eryService.ts |   80.43 |    95.45 |      75 |   80.43 | ...19-134,140-141 
  fileReadCache.ts |     100 |      100 |     100 |     100 |                   
  ...temService.ts |   89.76 |     85.1 |   88.88 |   89.76 | ...89,191,266-273 
  gitInit.ts       |     100 |      100 |     100 |     100 |                   
  gitService.ts    |   68.75 |     92.3 |   55.55 |   68.75 | ...12-122,125-129 
  ...reeService.ts |   71.83 |    68.47 |    91.3 |   71.83 | ...89-790,806,822 
  ...ionService.ts |   98.13 |     97.8 |   95.45 |   98.13 | ...32-333,380-381 
  ...orRegistry.ts |   96.76 |    92.15 |     100 |   96.76 | ...95-396,449-450 
  sessionRecap.ts  |   10.71 |      100 |       0 |   10.71 | 48-161            
  ...ionService.ts |   85.48 |    71.62 |      96 |   85.48 | ...73-983,987-988 
  sessionTitle.ts  |   93.95 |    70.37 |     100 |   93.95 | ...36-239,270-271 
  ...ionService.ts |   83.01 |    78.66 |   87.75 |   83.01 | ...1458,1464-1469 
  ...UseSummary.ts |    94.7 |    88.67 |     100 |    94.7 | ...69-171,221-222 
 ...icrocompaction |   98.62 |    86.44 |     100 |   98.62 |                   
  microcompact.ts  |   98.62 |    86.44 |     100 |   98.62 | 138,142           
 src/skills        |    86.7 |    83.88 |   93.61 |    86.7 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...activation.ts |     100 |     93.1 |     100 |     100 | 93,112            
  skill-load.ts    |   89.72 |    80.76 |     100 |   89.72 | ...28,248,260-262 
  skill-manager.ts |   82.68 |    79.32 |   90.32 |   82.68 | ...1135,1142-1146 
  symlinkScope.ts  |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/subagents     |   82.78 |    80.18 |   91.11 |   82.78 |                   
  ...tin-agents.ts |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...-selection.ts |     100 |      100 |     100 |     100 |                   
  ...nt-manager.ts |   76.75 |    72.09 |   87.09 |   76.75 | ...1176,1198-1199 
  types.ts         |     100 |      100 |     100 |     100 |                   
  validation.ts    |   92.46 |    95.18 |     100 |   92.46 | 51-56,69-74,78-83 
 src/telemetry     |   70.05 |       83 |   75.11 |   70.05 |                   
  config.ts        |     100 |      100 |     100 |     100 |                   
  constants.ts     |     100 |      100 |     100 |     100 |                   
  ...-exporters.ts |   46.37 |      100 |   44.44 |   46.37 | ...85,88-89,92-93 
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...t.circular.ts |       0 |        0 |       0 |       0 | 1-111             
  ...-processor.ts |   91.28 |    83.67 |   92.85 |   91.28 | ...66-171,186-187 
  ...t.circular.ts |       0 |        0 |       0 |       0 | 1-128             
  loggers.ts       |    51.9 |       64 |   57.77 |    51.9 | ...1214,1231-1251 
  metrics.ts       |    74.9 |    82.95 |   74.54 |    74.9 | ...58-978,981-992 
  sanitize.ts      |      80 |    83.33 |     100 |      80 | 35-36,41-42       
  sdk.ts           |   88.97 |    77.77 |     100 |   88.97 | ...80-281,300-304 
  ...etry-utils.ts |     100 |      100 |     100 |     100 |                   
  ...l-decision.ts |     100 |      100 |     100 |     100 |                   
  types.ts         |   79.09 |    85.59 |   83.33 |   79.09 | ...1134,1137-1166 
  uiTelemetry.ts   |   92.97 |    96.96 |   81.25 |   92.97 | ...93-194,200-207 
 ...ry/qwen-logger |   68.01 |    80.21 |   64.91 |   68.01 |                   
  event-types.ts   |       0 |        0 |       0 |       0 |                   
  qwen-logger.ts   |   68.01 |       80 |   64.28 |   68.01 | ...1042,1080-1081 
 src/test-utils    |   93.07 |    95.55 |   73.52 |   93.07 |                   
  config.ts        |     100 |      100 |     100 |     100 |                   
  ...st-helpers.ts |   94.11 |       90 |     100 |   94.11 | 69-70             
  index.ts         |     100 |      100 |     100 |     100 |                   
  mock-tool.ts     |   91.02 |    96.77 |   68.96 |   91.02 | ...32,196-197,210 
  ...aceContext.ts |     100 |      100 |     100 |     100 |                   
 src/tools         |   76.39 |    80.77 |   81.66 |   76.39 |                   
  ...erQuestion.ts |    88.8 |    76.74 |    90.9 |    88.8 | ...36-337,344-345 
  cron-create.ts   |   97.61 |    88.88 |   83.33 |   97.61 | 30-31             
  cron-delete.ts   |   96.55 |      100 |   83.33 |   96.55 | 26-27             
  cron-list.ts     |   96.36 |      100 |   83.33 |   96.36 | 25-26             
  diffOptions.ts   |     100 |      100 |     100 |     100 |                   
  edit.ts          |   77.69 |    84.46 |   73.33 |   77.69 | ...76-677,764-814 
  exitPlanMode.ts  |   84.61 |    85.71 |     100 |   84.61 | ...60-163,177-189 
  glob.ts          |   90.63 |    88.33 |   84.61 |   90.63 | ...28,171,302,305 
  grep.ts          |   79.19 |    85.71 |   78.94 |   79.19 | ...20,560,569-576 
  ls.ts            |   96.74 |    90.27 |     100 |   96.74 | 176-181,212,216   
  lsp.ts           |   72.69 |    60.09 |   90.32 |   72.69 | ...1208,1210-1211 
  ...nt-manager.ts |   52.09 |     65.9 |   47.36 |   52.09 | ...02-520,523-560 
  mcp-client.ts    |   29.65 |    71.05 |   46.87 |   29.65 | ...1434,1438-1441 
  mcp-tool.ts      |   90.92 |    88.88 |   96.42 |   90.92 | ...89-590,640-641 
  memory-config.ts |       0 |        0 |       0 |       0 | 1-48              
  ...iable-tool.ts |     100 |    84.61 |     100 |     100 | 102,109           
  monitor.ts       |   92.16 |    83.45 |      92 |   92.16 | ...15,544-547,560 
  ...nforcement.ts |   82.03 |    89.47 |     100 |   82.03 | 137-148,197-210   
  read-file.ts     |   95.09 |     88.6 |      90 |   95.09 | ...99,271-274,277 
  ripGrep.ts       |   94.59 |    85.71 |   93.33 |   94.59 | ...60,463,541-542 
  ...-transport.ts |    6.34 |        0 |       0 |    6.34 | 47-145            
  send-message.ts  |   88.77 |    91.66 |   83.33 |   88.77 | 44-45,68-76       
  shell.ts         |   81.42 |    80.74 |    90.9 |   81.42 | ...1243,1292-1298 
  skill-utils.ts   |     100 |      100 |     100 |     100 |                   
  skill.ts         |   88.11 |    91.17 |   84.61 |   88.11 | ...95,399,422-444 
  task-stop.ts     |   92.94 |    96.15 |   85.71 |   92.94 | 39-40,54-64       
  todoWrite.ts     |   85.42 |    84.09 |   84.61 |   85.42 | ...05-410,432-433 
  tool-error.ts    |     100 |      100 |     100 |     100 |                   
  tool-names.ts    |     100 |      100 |     100 |     100 |                   
  tool-registry.ts |   67.94 |    68.42 |   68.57 |   67.94 | ...59-660,668-669 
  tools.ts         |    87.6 |    89.79 |   88.23 |    87.6 | ...31-432,448-454 
  web-fetch.ts     |   88.44 |    76.92 |    92.3 |   88.44 | ...05-306,308-309 
  write-file.ts    |   78.82 |     78.2 |   83.33 |   78.82 | ...13-616,628-663 
 src/tools/agent   |   83.24 |    84.07 |   83.33 |   83.24 |                   
  agent-context.ts |     100 |      100 |     100 |     100 |                   
  agent.ts         |   83.37 |    84.21 |   82.92 |   83.37 | ...1536,1545-1549 
  fork-subagent.ts |   78.26 |    71.42 |      80 |   78.26 | 54-72,104-105     
 src/utils         |   87.77 |    86.73 |   92.41 |   87.77 |                   
  LruCache.ts      |       0 |        0 |       0 |       0 | 1-41              
  ...ssageQueue.ts |     100 |      100 |     100 |     100 |                   
  ...cFileWrite.ts |   76.08 |    44.44 |     100 |   76.08 | 61-70,72          
  bareMode.ts      |   27.27 |      100 |       0 |   27.27 | 9-15,18-19        
  browser.ts       |    7.69 |      100 |       0 |    7.69 | 17-56             
  ...igResolver.ts |     100 |      100 |     100 |     100 |                   
  cronDisplay.ts   |   42.85 |    23.07 |     100 |   42.85 | 26-31,33-45,47-54 
  cronParser.ts    |   89.74 |    85.71 |     100 |   89.74 | ...,63-64,183-186 
  debugLogger.ts   |   96.12 |    93.75 |   93.75 |   96.12 | 164-168           
  editHelper.ts    |   93.63 |     83.9 |     100 |   93.63 | ...28-429,463-464 
  editor.ts        |   97.61 |    95.71 |     100 |   97.61 | ...70-271,273-274 
  ...arResolver.ts |   94.28 |    88.88 |     100 |   94.28 | 28-29,125-126     
  ...entContext.ts |     100 |    95.45 |     100 |     100 | 83                
  errorParsing.ts  |    97.7 |    97.05 |     100 |    97.7 | 72-73             
  ...rReporting.ts |   88.46 |       90 |     100 |   88.46 | 69-74             
  errors.ts        |   70.92 |       80 |   53.33 |   70.92 | ...03-219,223-229 
  fetch.ts         |   70.18 |    71.42 |   71.42 |   70.18 | ...42,148,161,186 
  fileUtils.ts     |   89.18 |    85.13 |   94.73 |   89.18 | ...91-898,902-908 
  forkedAgent.ts   |   62.98 |    54.54 |      75 |   62.98 | ...23-432,434-447 
  formatters.ts    |   54.54 |       50 |     100 |   54.54 | 12-16             
  ...eUtilities.ts |   89.21 |    86.66 |     100 |   89.21 | 16-17,49-55,65-66 
  ...rStructure.ts |   94.36 |    94.28 |     100 |   94.36 | ...17-120,330-335 
  getPty.ts        |    12.5 |      100 |       0 |    12.5 | 21-34             
  gitDiff.ts       |   92.36 |    79.53 |     100 |   92.36 | ...55-856,928-929 
  ...noreParser.ts |    92.3 |    89.36 |     100 |    92.3 | ...15-116,186-187 
  gitUtils.ts      |   56.66 |    85.71 |      75 |   56.66 | ...2,72-73,97-148 
  iconvHelper.ts   |     100 |      100 |     100 |     100 |                   
  ...rePatterns.ts |     100 |      100 |     100 |     100 |                   
  ...ionManager.ts |     100 |     90.9 |     100 |     100 | 26                
  ...lPromptIds.ts |     100 |      100 |     100 |     100 |                   
  jsonl-utils.ts   |   59.57 |    89.74 |   45.45 |   59.57 | ...53-286,292-298 
  ...-detection.ts |     100 |      100 |     100 |     100 |                   
  ...yDiscovery.ts |   83.85 |    79.36 |     100 |   83.85 | ...15,318,410-413 
  ...tProcessor.ts |   93.63 |       90 |     100 |   93.63 | ...96-302,384-385 
  ...Inspectors.ts |   61.53 |      100 |      50 |   61.53 | 18-23             
  ...kerChecker.ts |   82.55 |    78.57 |     100 |   82.55 | 68-69,79-84,92-98 
  notebook.ts      |   94.35 |    84.78 |     100 |   94.35 | ...10,122,174-176 
  openaiLogger.ts  |   86.27 |    82.14 |     100 |   86.27 | ...05-107,130-135 
  partUtils.ts     |     100 |      100 |     100 |     100 |                   
  pathReader.ts    |     100 |      100 |     100 |     100 |                   
  paths.ts         |   92.82 |    91.02 |     100 |   92.82 | ...71-372,374-376 
  pdf.ts           |   93.68 |    87.05 |     100 |   93.68 | ...96-297,321-325 
  projectPath.ts   |     100 |      100 |     100 |     100 |                   
  ...ectSummary.ts |   89.39 |    72.41 |     100 |   89.39 | ...37-142,193-196 
  ...tIdContext.ts |     100 |      100 |     100 |     100 |                   
  proxyUtils.ts    |     100 |      100 |     100 |     100 |                   
  ...rDetection.ts |   58.57 |       76 |     100 |   58.57 | ...4,88-89,95-100 
  ...noreParser.ts |   85.45 |    85.18 |     100 |   85.45 | ...59,65-66,72-73 
  rateLimit.ts     |   92.55 |    85.92 |     100 |   92.55 | ...70-272,309-310 
  readManyFiles.ts |   87.96 |    86.95 |     100 |   87.96 | ...05-207,223-234 
  retry.ts         |   89.81 |    88.05 |     100 |   89.81 | ...29,350,357-358 
  ripgrepUtils.ts  |   46.53 |    84.37 |   66.66 |   46.53 | ...32-233,245-322 
  ...sDiscovery.ts |   97.42 |    92.85 |     100 |   97.42 | ...04,182-183,202 
  ...tchOptions.ts |   63.85 |    64.28 |   83.33 |   63.85 | ...29-130,187-188 
  safeJsonParse.ts |   74.07 |    83.33 |     100 |   74.07 | 40-46             
  ...nStringify.ts |     100 |      100 |     100 |     100 |                   
  ...aConverter.ts |   90.78 |    87.87 |     100 |   90.78 | ...41-42,93,95-96 
  ...aValidator.ts |   93.43 |    77.04 |     100 |   93.43 | ...46,155-158,212 
  ...r-launcher.ts |   76.92 |     91.3 |   66.66 |   76.92 | ...34,136,157-195 
  ...orageUtils.ts |   92.41 |    82.82 |     100 |   92.41 | ...39,423-430,441 
  shell-utils.ts   |   82.93 |     89.5 |     100 |   82.93 | ...1522,1529-1533 
  ...lAstParser.ts |   95.58 |    85.79 |     100 |   95.58 | ...1059-1061,1071 
  ...nlyChecker.ts |   95.75 |    92.47 |     100 |   95.75 | ...00-301,313-314 
  sideQuery.ts     |     100 |    92.85 |     100 |     100 | 43                
  ...tGenerator.ts |     100 |      100 |     100 |     100 |                   
  ...ameContext.ts |     100 |      100 |     100 |     100 |                   
  symlink.ts       |   77.77 |       50 |     100 |   77.77 | 44,54-59          
  ...emEncoding.ts |   96.36 |    91.17 |     100 |   96.36 | 59-60,124-125     
  terminalSafe.ts  |     100 |      100 |     100 |     100 |                   
  ...Serializer.ts |   98.72 |       90 |     100 |   98.72 | 42-43,134,201-203 
  testUtils.ts     |   53.33 |      100 |   33.33 |   53.33 | ...53,59-64,70-72 
  textUtils.ts     |      60 |      100 |   66.66 |      60 | 36-55             
  thoughtUtils.ts  |     100 |    92.85 |     100 |     100 | 71                
  ...-converter.ts |   94.59 |    85.71 |     100 |   94.59 | 35-36             
  tool-utils.ts    |    93.6 |     91.3 |     100 |    93.6 | ...58-159,162-163 
  truncation.ts    |     100 |       92 |     100 |     100 | 52,71             
  windowsPath.ts   |   89.47 |    79.31 |     100 |   89.47 | ...57-58,62,90-91 
  ...aceContext.ts |   93.71 |    88.88 |   93.33 |   93.71 | ...24-225,249-251 
  xml.ts           |     100 |      100 |     100 |     100 |                   
  yaml-parser.ts   |      92 |    84.31 |     100 |      92 | 49-53,65-69       
 ...ils/filesearch |   96.34 |    91.66 |     100 |   96.34 |                   
  crawlCache.ts    |     100 |      100 |     100 |     100 |                   
  crawler.ts       |   96.87 |    94.44 |     100 |   96.87 | 83-84             
  fileSearch.ts    |   93.29 |    86.76 |     100 |   93.29 | ...40-241,243-244 
  ignore.ts        |     100 |      100 |     100 |     100 |                   
  result-cache.ts  |     100 |     92.3 |     100 |     100 | 46                
 ...uest-tokenizer |   56.63 |    74.52 |   74.19 |   56.63 |                   
  ...eTokenizer.ts |   41.86 |    76.47 |   69.23 |   41.86 | ...70-443,453-507 
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...tTokenizer.ts |   68.39 |    69.49 |    90.9 |   68.39 | ...24-325,327-328 
  ...ageFormats.ts |      76 |      100 |   33.33 |      76 | 45-48,55-56       
  textTokenizer.ts |     100 |      100 |     100 |     100 |                   
  types.ts         |       0 |        0 |       0 |       0 | 1                 
-------------------|---------|----------|---------|---------|-------------------

For detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run.

@tanzhenxin tanzhenxin added the type/feature-request New feature or enhancement request label Apr 21, 2026
// Fetch untracked filenames up front so both the shortstat fast path and
// the numstat slow path report the same `filesCount` surface.
const untrackedPaths = (await fetchUntrackedPaths(cwd)) ?? [];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] fetchGitDiff() loads all untracked paths before deciding whether the --shortstat fast path should skip per-file details. In repos with many untracked files, /diff still pays for a full git ls-files --others --exclude-standard scan and allocates the whole path list even when it ends up returning summary-only output. Consider delaying untracked-path collection until after the fast-path decision, or counting untracked files without materializing every path first.

— gpt-5.4 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 005f88e. fetchGitDiff no longer materializes the untracked-path list before the fast-path decision — it holds only the raw ls-files -z stdout and counts NUL bytes to get the file count, then defers split('\0') until the slow path is actually taken. The per-file array is only allocated when we're going to use it.

Comment thread packages/core/src/utils/gitDiff.ts Outdated
return {
stats: {
...quickStats,
filesCount: quickStats.filesCount + untrackedPaths.length,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] The MAX_FILES_FOR_DETAILS short-circuit only uses the tracked-file count from git diff --shortstat, so a tree with relatively few tracked edits but hundreds of untracked files still falls through to the slow path. That defeats the new 500-file guardrail for one of the most common large-workspace cases this command is meant to protect against. Consider basing the threshold on tracked + untracked counts before deciding to run --numstat.

— gpt-5.4 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 005f88e. The short-circuit now compares quickStats.filesCount + untrackedCount against MAX_FILES_FOR_DETAILS, so a tree with few tracked edits but hundreds of untracked files still takes the summary-only path instead of falling through to --numstat.

BZ-D added 3 commits April 24, 2026 10:02
- Remove invalid `commandType` field from diffCommand (SlashCommand has
  no such property; caused a TS build failure).
- Drop duplicate `NumstatResult` interface in gitDiff.ts — it is
  structurally identical to `GitDiffResult`.
- Register the 9 missing `/diff` i18n strings in en.js / zh.js so the
  command is translatable (previously only `Configuration not available.`
  had entries).
- fetchUntrackedPaths now uses `ls-files -z` so filenames containing
  newlines, tabs, or non-ASCII bytes round-trip cleanly instead of
  being C-style quoted and split into phantom entries.
- fetchGitDiff runs the `--shortstat` probe and the untracked-paths
  lookup in parallel, since both are needed regardless of which path
  the function takes.
- parseGitDiff measures per-file diff size via Buffer.byteLength so
  MAX_DIFF_SIZE_BYTES matches its documented meaning on non-ASCII diffs.
- Adds a regression test for an untracked file whose name contains a
  literal newline.
@BZ-D

BZ-D commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator Author
  • P2 packages/core/src/utils/gitDiff.ts:91
    When the workspace only has new untracked files, fetchGitDiff() reports filesCount > 0 but leaves linesAdded at 0 because this block only increments filesCount. That makes /diff print headers like 1 file changed, +0 / -0 for a brand-new file, which is misleading for the common “create a new file before git add” workflow. The totals need to account for untracked file contents as additions, not just add placeholder per-file rows.

  • P3 packages/core/src/utils/gitDiff.ts:134
    parseGitNumstat() assumes git diff --numstat emits one raw path per newline-delimited record, but Git C-quotes unusual tracked paths even with core.quotepath=false (for example a tracked file named line1\nline2.txt comes back as "line1\nline2.txt"). In that case this parser stores the quoted escape sequence as the map key instead of the real filename, so /diff and any caller of fetchGitDiff() show the wrong path for tracked special filenames. Using --numstat -z here, like ls-files, would avoid that mismatch.

Comment thread packages/core/src/utils/gitDiff.ts Fixed
Addresses the five open review threads on #3491:

- parseShortstat: anchored and bounded the regex (`^...$` with `\d{1,10}`)
  so adversarial inputs can no longer drive polynomial backtracking. Closes
  CodeQL alert #137.
- fetchGitDiff: only parse the untracked-path list when we actually need
  it; the fast path now counts NUL bytes in the raw `ls-files -z` stdout
  (wenshao P1).
- fetchGitDiff: base the `MAX_FILES_FOR_DETAILS` short-circuit on
  `tracked + untracked`, so repos with few edits but many untracked files
  still take the summary-only path (wenshao P2).
- fetchGitDiff: count newlines in each untracked text file (binary sniff +
  1 MB read cap) and fold that into both the header `+N` and the per-file
  row, so a brand-new file no longer renders as `+0 / -0` (BZ-D P2).
- parseGitNumstat: switch to `git diff --numstat -z`. The parser now uses
  index-based slicing and a rename-pair state machine, so tracked
  filenames containing tabs/newlines/non-ASCII keep their real bytes
  (BZ-D P3). Renames collapse into a single `old => new` entry.

UI: untracked rows render as `+N filename (new)` (or
`~ filename (binary, new)`) instead of the placeholder `?` marker;
`/diff` now shows real additions for fresh files.
@BZ-D

BZ-D commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed both items in 005f88e.

P2 — untracked totals underreporting +N

fetchGitDiff now reads each untracked file (up to MAX_DIFF_SIZE_BYTES, with a NUL-byte binary sniff on the first 8 KB) and folds its line count into both the header +N and the per-file row. A brand-new text file renders as +N filename (new) instead of +0 / -0, while suspected binaries render as ~ filename (binary, new) so large blobs or log files can't stall the command. Two new tests cover the text and binary branches.

P3 — C-quoted tracked filenames via --numstat

Switched to git diff --numstat -z. The parser now walks NUL-delimited tokens and uses index-based slicing (indexOf('\t') twice) so literal tabs/newlines/non-ASCII bytes round-trip without any C-style quoting. Renames collapse into a single old => new per-file entry via a small rename-pair state machine (since -z splits those across three tokens). Integration tests create a tracked file named tab\there.txt and a git mv rename to verify the real filename is preserved end-to-end.

…m display

Two issues surfaced during a directionless multi-round audit of the /diff
feature:

1. `countUntrackedLines` reads at most `UNTRACKED_READ_CAP_BYTES` (1 MB)
   per file, so a 10 MB new log was silently reported as `+~20k` when the
   real count is ~10×. The helper now `fstat`s the file and returns a
   `truncated: true` flag when size exceeds the read window; `/diff`
   surfaces it as `(new, partial)` so the `+N` isn't read as exact.

2. Line-count aggregation was coupled to the per-file display cap: when
   tracked changes filled the `MAX_FILES` slot, untracked line counts
   beyond the remaining slots were dropped from `stats.linesAdded`
   entirely (header under-reported additions). Decoupled: we now read up
   to `MAX_FILES` untracked files for their line counts regardless of
   display slots, and only restrict the visible rows to `remainingSlots`.

Added regression tests for both: a 1.5 MB new file asserts `truncated:
true` and a lower-bound line count, and a `MAX_FILES`-saturated tracked
set + 5 untracked files asserts that untracked additions still appear in
the header totals even though none of them get displayed.
Comment thread packages/core/src/utils/gitDiff.ts Outdated
stats.filesCount += untrackedCount;
const untrackedPaths = splitNulDelimited(untrackedOut);
const remainingSlots = Math.max(0, MAX_FILES - perFileStats.size);
const visiblePaths = untrackedPaths.slice(0, remainingSlots);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] fetchGitDiff() adds every untracked file to stats.filesCount, but only adds line counts for the subset of untracked files that fit into the 50-entry perFileStats display cap (visiblePaths). If tracked files already fill the cap, or there are more untracked files than remaining slots, /diff can report many changed files while omitting most untracked additions from the header total. Count untracked line stats for all untracked paths when computing header totals, while only inserting the first remainingSlots into perFileStats; or explicitly mark totals as capped if full counting is intentional.

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already addressed in 5075ad5, landed before this review ran against 005f88e. fetchGitDiff now reads up to MAX_FILES untracked files for their line counts regardless of display slots and folds all of them into stats.linesAdded; only the visible rows are restricted to remainingSlots. Regression test aggregates untracked line counts into linesAdded even when the per-file map is full of tracked entries covers the case where tracked files saturate the map.

Comment thread packages/core/src/utils/gitDiff.ts Outdated
if (Buffer.byteLength(fileDiff, 'utf8') > MAX_DIFF_SIZE_BYTES) continue;

const lines = fileDiff.split('\n');
const headerMatch = lines[0]?.match(/^a\/(.+?) b\/(.+)$/);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] parseGitDiff() parses diff --git a/... b/... with ^a\/(.+?) b\/(.+)$. Valid paths can contain b/, for example a b/c.txt, which causes the parser to key hunks under the wrong filename. Since fetchGitDiffHunks() is exported from core, consumers can receive hunks keyed by invalid paths and fail to correlate hunk data with stats, editor paths, or filesystem paths. Avoid deriving the path from the ambiguous diff --git header; parse the subsequent +++ b/<path> line, or use custom --src-prefix / --dst-prefix values. Add a regression test for a file named like a b/c.txt.

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — confirmed locally that a real a b/c.txt produces diff --git a/a b/c.txt b/a b/c.txt with no escaping, so the previous regex keyed hunks under a wrong path.

Fixed in 54a0b2d. Replaced the ambiguous diff --git header parse with an extractFilePath helper that walks the block for unambiguous markers (rename to / copy to / +++ b/<path> with /dev/null fallback to --- a/<path>) and strips the TAB git appends on paths containing whitespace. Added 4 unit tests (space-in-path, rename, delete, new-file) plus an end-to-end test that creates a real a b/c.txt and verifies fetchGitDiffHunks keys the hunks under a b/c.txt.

BZ-D added 2 commits April 24, 2026 17:21
`diff --git a/X b/Y` is ambiguous when X contains ` b/` — a file literally
named `a b/c.txt` produces `diff --git a/a b/c.txt b/a b/c.txt` with no
escape or quoting, and the previous regex `^a\/(.+?) b\/(.+)$` keyed the
hunks under the wrong path. Consumers of the exported `fetchGitDiffHunks`
API would then fail to correlate hunks with stats or editor paths.

Introduces `extractFilePath(lines)` which walks the block for the
unambiguous markers (`rename to` / `copy to` / `+++ b/<path>` with a
`/dev/null` fallback to `--- a/<path>`) and strips the trailing TAB git
appends to paths containing whitespace. Adds unit tests for the
`a b/c.txt`, rename, delete, and new-file cases plus an end-to-end test
that creates a real `a b/c.txt` file and asserts `fetchGitDiffHunks`
keys the hunks correctly.

Addresses wenshao review comment #3136657141 on #3491.
The /diff stats used to come back as a plain-text MessageActionReturn.
Pipes and ACP still get that, but in interactive terminals we now dispatch
a structured history item so the numbers can carry theme colors.

- packages/cli/src/ui/types.ts — new DiffRenderRow / DiffRenderModel /
  HistoryItemDiffStats, MessageType.DIFF_STATS.
- packages/cli/src/ui/components/messages/DiffStatsDisplay.tsx — renders
  +N in theme.status.success (green), -M in theme.status.error (red), and
  the (new) / (binary) / (new, partial) markers in theme.text.secondary
  (dim). Column alignment matches the plain-text fallback.
- packages/cli/src/ui/components/HistoryItemDisplay.tsx — routes the new
  item type.
- packages/cli/src/ui/commands/diffCommand.ts — builds a DiffRenderModel
  once and fans out: interactive calls context.ui.addItem; other modes
  fall through to renderDiffModelText() for the plain-text path. Error
  and "clean tree" branches keep the existing info/error
  MessageActionReturn in every mode.
- Tests: existing diffCommand suite moved to an explicit non_interactive
  context (it was asserting text content); new interactive suite covers
  addItem dispatch and model shape; DiffStatsDisplay component tests
  cover the four row variants and the "…and N more" note.
* the working tree is in a transient state (merge, rebase, cherry-pick,
* revert) — those states carry incoming changes that weren't intentionally
* made by the user.
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] fetchGitDiff(cwd) runs tracked diff commands and untracked discovery from cwd, then resolves untracked paths with path.join(cwd, relPath). When Qwen Code is launched from a subdirectory, tracked git diff paths are repo-root-relative, but git ls-files --others is scoped/relative to that subdirectory. That can make /diff include repo-wide tracked changes while omitting untracked files outside the current subdirectory, and it can emit inconsistent path keys for untracked rows.

Resolve the repository root once and use it consistently for all Git operations and line counting; keep emitted paths repo-root-relative.

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed locally — running git diff --numstat -z from <repo>/sub emits sub/tracked.txt (repo-root-relative) while git ls-files --others -z emits untracked.txt (cwd-relative) and skips files in sibling directories entirely.

Fixed in bb0164d. fetchGitDiff and fetchGitDiffHunks now resolve the worktree root with findGitRoot(cwd) once and run every git invocation (and the path.join(...) for countUntrackedLines) from that root. All perFileStats keys are repo-root-relative and the listing is repo-wide, so /diff produces identical output regardless of which subdirectory the user is in. Regression test in fetchGitDiff invocation from a subdirectory creates a tracked subdir change plus an untracked file at the repo root and asserts both come back keyed correctly when invoked from the subdir.

Comment thread packages/core/src/utils/gitDiff.ts Outdated
): Promise<UntrackedLineStats> {
let fh;
try {
fh = await open(absPath, 'r');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] countUntrackedLines opens every untracked path with open(absPath, 'r') without first verifying that the path is a regular file. Git can list untracked FIFOs and symlinks; opening a FIFO for reading can block indefinitely waiting for a writer, and opening a symlink follows its target outside the worktree.

Use lstat before opening untracked paths and only count regular files. Treat symlinks and special files as non-countable/binary rows, or handle symlinks explicitly without following them.

Suggested change
fh = await open(absPath, 'r');
let st;
try {
st = await lstat(absPath);
} catch {
return { added: 0, isBinary: false, truncated: false };
}
if (!st.isFile()) {
return { added: 0, isBinary: true, truncated: false };
}

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in bb0164dcountUntrackedLines now lstats the path before open and bails out on anything that isn't a regular file: symlinks and FIFOs render as binary ~ rows, so the open never blocks on a FIFO and never dereferences a symlink target outside the worktree. Regression test creates an untracked symlink pointing at content under a separate tmpdir (outside the worktree) and asserts the entry lands as isBinary: true with linesAdded unchanged — the target's lines never leak into the totals.

BZ-D added 2 commits April 27, 2026 11:30
# Conflicts:
#	scripts/unused-keys-only-in-locales.json
Audit of the colorize commit found one real DRY hazard: DiffStatsDisplay
and renderDiffModelText each independently re-derived addWidth /
remWidth / statColumnWidth from the same row list. If anyone later
changed one formula, the interactive Ink output and the non-interactive
plain text would silently fall out of column alignment.

Extract the computation into computeDiffColumnWidths() exported from
diffCommand.ts; both renderers now call it. Adds a focused unit test of
the contract (empty rows, widest non-binary row wins, binary rows are
ignored, untracked text rows count). Drop a redundant
`Omit<HistoryItemDiffStats, 'id'>` annotation since the type already has
no id field.
@BZ-D

BZ-D commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator Author

E2E Test Cases:

Normal

image

Modified files clickable

image

Add, remove and modify

image

BZ-D added 2 commits April 27, 2026 14:57
Two Critical findings on PR #3491:

1. (line 63) When /diff is invoked from a subdirectory of the worktree,
   `git diff` emits repo-root-relative paths but `git ls-files --others`
   is scoped to cwd and emits cwd-relative paths. Result: mixed path
   bases in `perFileStats` and silent omission of untracked files in
   sibling directories. Resolve `findGitRoot(cwd)` once and run every
   git invocation (and `path.join(...)` for line counting) from there,
   so all keys are repo-root-relative and the listing is repo-wide.

2. (line 455) `countUntrackedLines` opened every untracked path with
   `open(absPath, 'r')`. Git's `ls-files --others` can list FIFOs
   (whose `open()` blocks indefinitely waiting on a writer) and
   symlinks (which `open()` dereferences, potentially reading outside
   the worktree). Add an `lstat` gate: only regular files are counted;
   symlinks and other special files render as binary `~` rows.

Two new integration tests cover both regressions: one creates a
sibling untracked file at the repo root and invokes fetchGitDiff from
a subdir asserting all three changes (root + sub) come back keyed by
repo-root-relative paths; the other creates a symlink pointing at
content outside the worktree and asserts it lands as a binary row
with no contribution to linesAdded.
The previous fix(core) commit accidentally bundled two unrelated
working-tree edits (a test comment in .npmrc and a TODO in README.md)
that I had used while sanity-testing /diff. They have nothing to do
with the fix; restore them to their pre-bb0164d99 state.
@BZ-D

BZ-D commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator Author

E2E verification of untracked-file behavior

Set up a fixture that exercises every branch of countUntrackedLines and the wenshao subdir-path fix, then invoked fetchGitDiff directly (the same code path /diff runs through):

Fixture (under /tmp/diff-untracked-demo, freshly initialized git repo with one tracked seed.txt already committed, then):

  • seed.txt — appended one line (tracked modification)
  • new-text.txtone\ntwo\nthree\n (3-line untracked text)
  • new-binary.bin\x89PNG\x00\xff\x10 (NUL byte at offset 4)
  • new-empty.txt — empty file
  • new-huge.log — 1.5 MB of 'a' * 100 + '\n' (exceeds 1 MB read cap)
  • new-symlink — symlink to /tmp/diff-outside/target.txt (2 lines outside the worktree)
  • new-fifo — FIFO created with mkfifo
  • sub/sub-untracked.txt — empty file in a subdirectory

Result invoking fetchGitDiff('/tmp/diff-untracked-demo'):

stats: { filesCount: 8, linesAdded: 9915, linesRemoved: 0 }
  seed.txt                →  {"added":1,"removed":0,"isBinary":false}
  new-binary.bin          →  {"added":0,"isBinary":true, "isUntracked":true,"truncated":false}
  new-empty.txt           →  {"added":0,"isBinary":false,"isUntracked":true,"truncated":false}
  new-huge.log            →  {"added":9900,"isBinary":false,"isUntracked":true,"truncated":true}
  new-symlink             →  {"added":0,"isBinary":true, "isUntracked":true,"truncated":false}
  new-text.txt            →  {"added":3,"isBinary":false,"isUntracked":true,"truncated":false}
  sub/sub-untracked.txt   →  {"added":0,"isBinary":false,"isUntracked":true,"truncated":false}
branch check
tracked numstat seed.txt +1 -0, no isUntracked
untracked text line counting new-text.txt +3
NUL-byte binary sniff (first 8 KB) new-binary.bin isBinary:true, added:0
empty-file early return new-empty.txt +0, truncated:false
> 1 MB read cap → truncated new-huge.log +9900, truncated:true
lstat gate, symlink not followed new-symlink isBinary:true; target's 2 secret lines did NOT contaminate linesAdded (would have been 9917 if followed)
FIFO filtered upstream by git new-fifo not present in output
repo-root-relative keys for nested paths sub/sub-untracked.txt keyed correctly

Subdirectory invocation (wenshao Critical line 63 fix) — invoking from <repo>/sub instead of root:

stats: { filesCount: 8, linesAdded: 9915, linesRemoved: 0 }
  seed.txt
  new-binary.bin
  new-empty.txt
  new-huge.log
  new-symlink
  new-text.txt
  sub/sub-untracked.txt

Identical totals and identical repo-root-relative keys as the root invocation — the entire repo is reported, not just files under sub/.

Non-git directory (graceful degradation):

fetchGitDiff('/Users/.../code/github-qwen-code')  // no .git in any ancestor
→ null

The CLI surfaces this as ● No diff available. Either this is not a git repository, HEAD is missing, or a merge/rebase/cherry-pick/revert is in progress.

All branches behave as designed.

Comment thread packages/core/src/utils/gitDiff.ts Outdated
// header silently under-reporting additions when tracked changes have
// already filled the per-file map.
const countable = untrackedPaths.slice(0, MAX_FILES);
const countableStats = await Promise.all(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] fetchGitDiff() counts up to 50 untracked files with one Promise.all, and each countUntrackedLines() call allocates a 1 MB buffer. In a workspace with many large untracked files, a single /diff invocation can therefore allocate roughly 50 MB of buffers at once, plus the matching file descriptors and I/O pressure. Because /diff runs on the interactive path, this can cause avoidable memory spikes or latency in constrained environments.

Consider bounding this work with a small concurrency limit, or reading files with a reusable/chunked buffer, so totals stay accurate without making the worst-case allocation fully concurrent.

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 002d17c.

countUntrackedLines now reads in fixed 64 KB chunks instead of allocating one full UNTRACKED_READ_CAP_BYTES (1 MB) buffer per file. With the existing MAX_FILES = 50 concurrency, peak heap footprint of a single /diff invocation drops from ~50 MB to ~3.2 MB.

Implementation notes:

  • Loop reads min(64 KB, capRemaining) per iteration via fh.read(buf, 0, toRead, totalRead), breaking on bytesRead === 0 (EOF) or when totalRead hits UNTRACKED_READ_CAP_BYTES.
  • Binary sniff (BINARY_SNIFF_BYTES = 8 KB) tracks sniffedBytes across iterations so it works even if a read returns a short chunk; in practice it always completes inside the first chunk because chunk size > sniff window.
  • lastByte is tracked across reads for the trailing-partial-line rule.
  • truncated is decided once at the end via fh.stat() — only when we hit the cap with more bytes still on disk, identical semantics to the single-shot path.
  • Buffer.allocUnsafe for the chunk buffer (we only iterate within bytesRead, so uninit bytes are never observed).

All 44 gitDiff tests pass unchanged, including the 1.5 MB truncation test (marks oversized untracked text files as truncated) which now exercises the chunk-boundary code path. Re-ran the e2e fixture from the verification report — new-huge.log still reports +9900, truncated:true byte-for-byte.

I considered also adding a concurrency limit on top, but with chunked reads the per-file buffer is already small enough that the marginal benefit (3.2 MB → 512 KB at concurrency=8) didn't justify the extra worker-pool plumbing. Happy to revisit if you'd prefer that ceiling enforced explicitly.

`countUntrackedLines` allocated a fresh `UNTRACKED_READ_CAP_BYTES`
(1 MB) buffer per file. With up to MAX_FILES (=50) line-counts
running concurrently via `Promise.all`, the worst-case heap
footprint of a single `/diff` invocation was ~50 MB of transient
buffers — avoidable spike on small containers / low-memory hosts
flagged by wenshao on PR #3491.

Switch to a fixed 64 KB chunk buffer and read in a loop, accumulating
line counts and tracking the last byte across iterations. Peak
footprint is now ~3.2 MB (50 × 64 KB). Behavior is identical: same
binary sniff over the first 8 KB, same truncation flag when the read
hits the cap with bytes still on disk, same trailing-partial-line
rule. All 44 gitDiff tests pass unchanged, including the 1.5 MB
truncation test which now crosses chunk boundaries.
Two non-blocking suggestions from qqqys's CR on PR #3491:

- `buildDiffRenderModel`: expand the JSDoc to call out the implicit
  row-ordering contract that both renderers depend on (tracked entries
  first in numstat order, then untracked appended in ls-files order).
  Future replacements of the underlying Map need to preserve this
  sequence.

- `DiffStatsDisplay`: drop the `${i}-${filename}` React key in favor of
  bare `filename`. Filenames are unique within a single
  `DiffRenderModel` (perFileStats is a Map keyed by filename), so the
  index prefix added no information.
@BZ-D

BZ-D commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator Author

@qqqys 多谢细致的 CR,逐条回复:

1. 两次 findGitRoot 调用 — 已采纳,早于这条 review 几小时落在 6b3ea41fetchGitDifffetchGitDiffHunks 都改成单次 findGitRoot(cwd),把 gitRoot 串到 isInTransientGitState 和所有 runGit 调用,删除了 isGitRepository 这个死引用。三次祖先遍历缩到一次。

2. isInTransientGitState 缓存 — 评估后没采纳。普通 repo 走的是单次 stat('.git') 系统调用(.git 是目录就直接返回,不进 readFile)。Linked worktree 才会多一次 readFile 解析 gitdir:。整体开销远小于后面要起的 git 子进程。缓存层会引入失效问题(worktree 切换、.git 改动)反而复杂化。

3. countNulDelimited 用 split 更快 — 没采纳,反过来:split('\0') 会把整段 stdout 切成 N 个 substring 数组,对 100k untracked 文件的大 stdout 来说就是 100k 次字符串分配(且 fast-path 我们只要 count,不要 paths)。charCodeAt 一遍 O(n) 不分配,正是为了避免这个。注释里也写明了 "fast path only has to count NUL bytes instead of allocating a full path array"。

4. supportedModes as const — 当前 tsc --noEmit 干净。SlashCommand.supportedModes?: ExecutionMode[] 接受 readonly tuple 字面量赋值(TS 在 readonly→mutable 上对 array 字面量做了协变松弛)。如果 strict mode 之后收紧,这边会作为 lint 报告暴露。

5. 行序约定加注释 — 已采纳,24dfb8726。buildDiffRenderModel 的 JSDoc 现在写明 "tracked numstat entries first (alphabetical), then untracked appended in ls-files order. Renderers depend on this — if perFileStats ever switches to a different container, the row sequence must continue to be stable across runs."

6. DiffRow key 简化 — 已采纳,24dfb8726。改为 key={row.filename}perFileStats 本身就以 filename 为 key 去重,index 前缀冗余。

7/8. rewindCommand / shellExecutionService / terminalSerializer.test.ts 的格式化改动 — 这些不是本 PR 的提交,是 8b277f66c Merge remote-tracking branch 'origin/main' 把上游已合并的 #3441(rewind feature)和 #3591(TUI flicker fix)拉了进来。通过 git log main..HEAD -- <这些文件> 可以看到它们都是上游 commit(c406c735054465b0c0),不在我自己的提交里。本 PR 真正的变更面是 git diff main...HEAD -- 'packages/core/src/utils/gitDiff*' 'packages/cli/src/ui/commands/diffCommand*' 'packages/cli/src/ui/components/messages/DiffStatsDisplay*' 'packages/cli/src/ui/types.ts' 'packages/cli/src/ui/components/HistoryItemDisplay.tsx' 'packages/cli/src/services/BuiltinCommandLoader.ts' 'packages/core/src/index.ts' 'packages/cli/src/i18n/locales/*.js' 这一组。

9. truncated 只对 untracked 有意义 — 已经在 JSDoc 写了限定 ("Only meaningful for untracked files: true when the file exceeded the line-counting read cap")。tracked 文件走 --numstat,git 直接给出权威的 added/removed 行数(不存在"读到一半"的概念);MAX_LINES_PER_FILE 只截断 hunk 渲染(在 parseGitDiff 里),那是 hunks API 的事,不影响 stats。所以 tracked + truncated 在当前 schema 下没有对应语义。

— 总结:1/5/6 已落地(早于这条 review),2/3/4 解释保留现状,7/8 是上游 merge 噪声不在本 PR 真正改动里,9 是 schema 里已限定的范围。

Symmetrical to the (new) marker for untracked files: tracked files that
were removed from the worktree relative to HEAD now render with a
(deleted) suffix (or (binary, deleted) for binary deletes), so users
can tell a delete apart from a heavy edit.

Implementation:
- core: `fetchGitDiff` now runs `git diff HEAD --name-status -z` in
  parallel with the existing numstat call. `parseDeletedFromNameStatus`
  extracts the set of D-status paths (skipping R/C rename and copy
  pairs, both halves of which still exist on disk under one name or
  the other). Each `perFileStats` entry whose key is in that set gets
  `isDeleted: true`. Numstat alone could not distinguish a delete
  (`0\t10\tpath`) from a heavy edit; the name-status pass disambiguates.
- cli: `DiffRenderRow` carries `isDeleted: boolean`; both the plain-text
  renderer and the Ink component append the new suffix in
  `theme.text.secondary` (dim).
- i18n: new `(deleted)` and `(binary, deleted)` keys in en/zh/zh-TW.

Tests:
- Unit: `parseDeletedFromNameStatus` covers D-only extraction, R/C pair
  skipping, NUL-safe paths (tabs / non-ASCII), and empty input.
- Integration: real repo deletes a tracked text + a tracked binary plus
  edits another file; asserts the deleted entries get `isDeleted: true`
  but the heavy edit does not. Second test verifies neither half of a
  `git mv` rename gets flagged as deleted.
- CLI / component: `(deleted)` and `(binary, deleted)` rendering
  variants with column alignment intact.
@BZ-D

BZ-D commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator Author

E2E verification of the (deleted) marker

Built a fixture exercising every branch of the new deletion-detection path side-by-side, then invoked fetchGitDiff directly:

Setup (initial commit contains 5 tracked files; then in the worktree):

  • kept.txt — appended one line (normal tracked modification)
  • heavy-edit.txt — emptied via : > heavy-edit.txt (drops 5 lines, file still exists — the critical disambiguation case that numstat alone can't tell apart from a delete)
  • gone.txtrm'd (text delete)
  • gone.binrm'd (binary delete, content had a NUL byte)
  • old-name.txtnew-name.txt via git mv (rename, neither half should be flagged as deleted)
  • untracked.txt — created fresh (new untracked, should still show (new))

Result invoking fetchGitDiff('/tmp/diff-deleted-demo'):

stats: { filesCount: 6, linesAdded: 2, linesRemoved: 7 }
  gone.bin                       →  {"added":0,"removed":0,"isBinary":true,"isDeleted":true}
  gone.txt                       →  {"added":0,"removed":2,"isBinary":false,"isDeleted":true}
  heavy-edit.txt                 →  {"added":0,"removed":5,"isBinary":false}
  kept.txt                       →  {"added":1,"removed":0,"isBinary":false}
  old-name.txt => new-name.txt   →  {"added":0,"removed":0,"isBinary":false}
  untracked.txt                  →  {"added":1,"removed":0,"isBinary":false,"isUntracked":true,"truncated":false}
branch check
binary delete gone.binisBinary:true, isDeleted:true → renders ~ gone.bin (binary, deleted)
text delete gone.txtremoved:2, isDeleted:true → renders +0 -2 gone.txt (deleted)
heavy edit ≠ delete heavy-edit.txtremoved:5 but no isDeleted → renders +0 -5 heavy-edit.txt (no marker). This is the case numstat alone reports as 0\t5\theavy-edit.txt — same wire shape as a delete; only the parallel --name-status call lets us tell them apart.
normal modify kept.txtadded:1 plain row
rename — neither side flagged old-name.txt => new-name.txt is the collapsed rename row from parseGitNumstat's rename state machine; parseDeletedFromNameStatus skips both halves of the R<score> pair, so neither old-name.txt nor new-name.txt ends up in the deleted set, and the composite key never matches either. isDeleted stays unset.
untracked still works untracked.txtisUntracked:true, isDeleted: undefined → still renders +1 -0 untracked.txt (new)

Header totals: linesAdded = 2 = 1 (kept) + 1 (untracked); linesRemoved = 7 = 5 (heavy-edit) + 2 (gone) — binary deletes don't contribute to line totals (they have added: 0, removed: 0), consistent with how git's numstat reports binary files. ✓

TUI rendering (after rebuild, with QWEN_WORKING_DIR=/tmp/diff-deleted-demo npm start then /diff):

6 files changed, +2 / -7
  ~      gone.bin (binary, deleted)
  +0 -2  gone.txt (deleted)
  +0 -5  heavy-edit.txt
  +1 -0  kept.txt
  +0 -0  old-name.txt => new-name.txt
  +1 -0  untracked.txt (new)

Plus (deleted) / (binary, deleted) / (new) rendered in theme.text.secondary (dim), +N in theme.status.success (green), -M in theme.status.error (red).

All branches behave as designed; the disambiguation between "delete" and "heavy edit that drops N lines" works correctly via the parallel git diff HEAD --name-status -z call.

);
if (diffOut == null) return new Map();
return parseGitDiff(diffOut);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] fetchGitDiffHunks() invokes plain git diff HEAD without --no-ext-diff. Unlike the stats paths, plain git diff can honor GIT_EXTERNAL_DIFF and configured external diff drivers, so this exported read-only utility can unexpectedly execute repository/user-configured commands when a caller only wants to inspect hunks.

Suggested change
}
['--no-optional-locks', 'diff', 'HEAD', '--no-ext-diff'],

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 667f01a, with two extensions to your suggestion:

  1. All four git diff calls now pin --no-ext-diff, not just the plain fetchGitDiffHunks one. I empirically verified that the stats variants (--shortstat / --numstat / --name-status) don't currently invoke external diff drivers — running each with GIT_EXTERNAL_DIFF=evil.sh in a sandbox confirmed only plain git diff fires the driver. But pinning the flag uniformly is a zero-cost hardening, and git's behavior around external drivers has shifted between versions, so I'd rather not rely on the implicit assumption.

  2. Regression test plants the actual attack vector: GIT_EXTERNAL_DIFF=evil.sh (a script whose only side effect is writing a sentinel file) is set in process.env, then fetchGitDiffHunks runs against a real worktree with a modification. The test asserts the sentinel never appears on disk — proving --no-ext-diff reaches the spawned git and actually blocks the driver. Without the flag this test would pre-commit fail with a sentinel write.

Manual verification trace (sandbox):

=== plain `git diff HEAD` with GIT_EXTERNAL_DIFF set ===
EVIL EXTERNAL DIFF EXECUTED with args: file.txt /var/.../git-blob-... ...

=== `git diff HEAD --no-ext-diff` ===
diff --git a/file.txt b/file.txt
...

=== `git diff HEAD --numstat` (no flag) ===
1\t0\tfile.txt          ← driver did NOT fire
=== `git diff HEAD --shortstat` (no flag) ===
 1 file changed, 1 insertion(+)   ← driver did NOT fire
=== `git diff HEAD --name-status` (no flag) ===
M\tfile.txt             ← driver did NOT fire

So plain diff is the only currently-exploitable call site, but the fix lands on every diff invocation.

BZ-D added 3 commits April 28, 2026 16:15
Plain `git diff HEAD` honors `GIT_EXTERNAL_DIFF` and configured
`diff.<name>.command` drivers, so the exported `fetchGitDiffHunks`
utility could execute arbitrary commands when invoked inside a
worktree whose user-global or repo-local config registers an
external driver.

Add `--no-ext-diff` to every `git diff` call:
- `fetchGitDiffHunks`'s plain `git diff HEAD` — the actual
  vulnerability surface.
- `fetchGitDiff`'s `--shortstat`, `--numstat`, `--name-status`
  variants — defense-in-depth. Empirically these stats modes
  already bypass external drivers in current git, but git's
  behavior here has shifted between versions before, and
  pinning the flag everywhere is a zero-cost hardening that
  keeps the policy uniform across every `git diff` we run.

Regression test plants `GIT_EXTERNAL_DIFF=evil.sh` (a driver that
writes a sentinel file as its side effect) before calling
`fetchGitDiffHunks`, then asserts the sentinel never appears —
confirming `--no-ext-diff` actually stops git from spawning the
driver.

Closes wenshao critical comment on PR #3491.
PR #3491 CI was failing across all 9 platform/Node combos with:

    Error: [vitest] No "constants" export is defined on the "node:fs" mock.
        at gitDiff.ts:70 const UNTRACKED_OPEN_FLAGS =
                                fsConstants.O_RDONLY | (fsConstants.O_NOFOLLOW ?? 0)
        at index.ts:279  export * from './utils/gitDiff.js'

Six unrelated test files (`client.test.ts`, `geminiChat.test.ts`,
`marketplace.test.ts`, `npm.test.ts`, `mcp-client.test.ts`,
`nextSpeakerChecker.test.ts`) `vi.mock('node:fs', ...)` without
returning `constants`, and their transitive import of
`@qwen-code/qwen-code-core` pulls in `gitDiff.ts`, whose
module-load-time `import { constants as fsConstants }` plus the
top-level `UNTRACKED_OPEN_FLAGS` constant tripped vitest's strict
mock proxy.

Two changes:

1. Switch `import { constants }` to `import * as nodeFs from 'node:fs'`.
   Strict-mock no longer rejects the import statement itself.
2. Move the flag computation out of a module-load constant into a
   memoized `getUntrackedOpenFlags()` called from inside
   `countUntrackedLines`. Tests that don't actually invoke
   `fetchGitDiff` / `fetchGitDiffHunks` (i.e. all six broken ones)
   never reach the property access, so vitest's proxy never trips.
   `?? 0` fallback on each constant lookup is preserved so Windows
   (no `O_NOFOLLOW`) and the genuine "constants is undefined" mock
   path both degrade to plain `O_RDONLY` without throwing.

Locally re-ran all six previously-failing files (199 tests) — all
green. Existing 51 gitDiff tests unchanged.
Windows CI was failing only on:

    resolveGitDir > follows the gitdir pointer for linked worktrees
    AssertionError: expected 'C:/Users/runneradmin/.../main/.git/worktrees/wt'
        to contain '.git\worktrees'

Git writes the linked-worktree pointer in the `.git` *file* using
forward slashes — `gitdir: C:/Users/.../main/.git/worktrees/wt` —
even on Windows. `resolveGitDir` surfaces that string verbatim
(intentional, since fs APIs on Windows accept both separators). But
the assertion used `path.join('.git', 'worktrees')`, which is
`'.git\\worktrees'` on Windows, so the substring-contains check
failed despite the value being correct.

Switch to a regex that matches either separator: `/[/\\]\.git[/\\]worktrees[/\\]/`.
Now the assertion holds on POSIX (where path.join uses `/` anyway)
and Windows (where git's value uses `/` but the host uses `\`).

6285/6289 Windows tests already passed before this; only this one
assertion was platform-dependent.
return { added: 0, isBinary: true, truncated: false };
}
try {
// Stream the file in fixed-size chunks instead of allocating one full

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] extractFilePath() only accepts unquoted +++ b/<path> / --- a/<path> metadata. Git still C-quotes paths containing characters such as literal tabs, producing headers like +++ "b/tab\tname.txt", so the parser fails p.startsWith('b/') and drops the file’s hunks entirely. fetchGitDiffHunks() can therefore silently miss valid modified tracked files, while stats parsing handles these paths via --numstat -z.

Suggested fix: decode Git C-style quoted metadata paths before checking a/ / b/ prefixes, and add a regression test with a tracked filename containing a literal tab.

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 632b259.

Confirmed locally: with core.quotepath=false set, a tracked file named tab\there.txt still shows up as +++ "b/tab\there.txt" in plain git diff output — the C-quoting (for tabs/newlines/quotes) is independent of core.quotepath (which only suppresses the octal form for non-ASCII bytes). My old extractFilePath failed p.startsWith('b/') and dropped the file's hunks entirely.

Added unquoteCStylePath() that:

  • Detects the surrounding "..." wrapper.
  • Decodes \t, \n, \r, \", \\ plus octal \NNN escapes to raw bytes, so multi-byte UTF-8 sequences like \346\226\207 (= ) reassemble correctly even though we never set quotepath=true ourselves (covers callers feeding us output produced by some other diff command).
  • Returns the UTF-8-decoded string.

extractFilePath now pipes every candidate through stripTab → unquoteCStylePath before checking the a/ / b/ prefix.

Tests: 2 new unit tests (tab-escape, octal-escape), 1 new integration test that creates a real tab\there.txt tracked file and asserts fetchGitDiffHunks keys hunks under the real name (no-ops on filesystems that reject tab-in-name).

Comment thread packages/core/src/utils/gitDiff.ts Outdated
const untrackedCount = countNulDelimited(untrackedOut);

if (shortstatOut != null) {
const quickStats = parseShortstat(shortstatOut);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] The >500-file fast path only runs when git diff --shortstat parses to a truthy value. With no tracked changes and more than 500 untracked files, shortstat is empty, so the slow path runs and only counts lines for untrackedPaths.slice(0, MAX_FILES). For 501 one-line untracked files this reports filesCount: 501 but linesAdded: 50, materially under-reporting totals and bypassing the intended guardrail.

Suggested fix: treat missing shortstat as zero tracked stats when applying the tracked-plus-untracked fast path, or count all untracked files intended for header totals before returning detailed stats.

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 632b259.

You're right — if (quickStats && ...) short-circuited when shortstat was empty (no tracked changes). 0 tracked + 501 untracked therefore slipped past the guardrail and hit the slow path, which only line-counted the first MAX_FILES untracked entries — header would say +50 / -0 for what was actually 501 newly-added files.

Fix: treat empty/null/unparseable shortstat as EMPTY_STATS = { filesCount: 0, linesAdded: 0, linesRemoved: 0 } and apply the threshold on tracked + untracked uniformly:

const quickStats =
  (shortstatOut != null && parseShortstat(shortstatOut)) || EMPTY_STATS;
if (quickStats.filesCount + untrackedCount > MAX_FILES_FOR_DETAILS) {
  return { stats: { ...quickStats, filesCount: ... }, perFileStats: new Map() };
}

Regression test plants 501 untracked files + 0 tracked changes and asserts the result has filesCount: 501 with an empty perFileStats Map (i.e. the summary-only fast path actually fired).

Comment thread packages/core/src/utils/gitDiff.ts Outdated
// global config that sets `GIT_EXTERNAL_DIFF` or `diff.<name>.command`
// would let `git diff` execute arbitrary commands when this read-only
// utility is invoked. The stats variants in `fetchGitDiff` already
// bypass external drivers, but plain `git diff` honors them.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] fetchGitDiffHunks() reads the full git diff HEAD output into memory via execFile before parser-level caps (MAX_FILES, per-file size, per-file lines) apply. Large diffs can still allocate up to the command buffer as a string before most content is discarded, causing avoidable latency and memory spikes.

Suggested fix: stream git diff output and stop once caps are reached, or document the API as a full-diff reader if streaming is intentionally out of scope.

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged — documented the limitation in the JSDoc rather than implementing streaming in this PR (632b259):

NOTE on memory: this reads the full git diff HEAD stdout via execFile before applying parser caps (MAX_FILES, MAX_DIFF_SIZE_BYTES, MAX_LINES_PER_FILE). For very large diffs we can buffer up to the runGit maxBuffer (64 MB) before dropping content. Streaming the parser would let us terminate git early at MAX_FILES; that's a reasonable follow-up but out of scope for this utility's first cut.

Streaming is a non-trivial refactor here — child_process.spawn with a Node ReadableStream, incremental file-block detection (the ^diff --git boundary), UTF-8 boundary handling on Buffer chunks, and a graceful child.kill() once MAX_FILES is reached. I'd rather land that as a separate PR than bundle it with this one. Tracking the 64 MB maxBuffer cap as the failsafe in the meantime — pathological diffs error out cleanly via runGit's catch-and-return-null path.

Happy to file a follow-up issue if you want to track this explicitly.

Two Critical findings + one suggestion from wenshao on PR #3491:

1. (line 615) `extractFilePath` only accepted unquoted `+++ b/...` /
   `--- a/...` headers. Git wraps a path in `"..."` and applies
   C-style escaping (`\t`, `\n`, `\r`, `\"`, `\\`, plus octal `\NNN`
   for non-ASCII bytes) whenever the raw path contains a character
   that breaks space-delimited parsing. `core.quotepath=false` only
   disables the octal form for non-ASCII bytes — control chars and
   quotes are still escaped — so `fetchGitDiffHunks` silently dropped
   hunks for any tracked file whose name contained a tab, newline,
   or quote.

   Add `unquoteCStylePath()`: detects the surrounding quotes, decodes
   `\t`/`\n`/`\r`/`\"`/`\\` plus octal `\NNN` to raw bytes, then
   UTF-8-decodes the byte sequence so multi-byte octal sequences like
   `\346\226\207` (= `文`) round-trip correctly. `extractFilePath`
   pipes every candidate through `stripTab` -> `unquoteCStylePath`
   before checking the `a/` / `b/` prefix.

   Two unit tests cover the tab and octal cases; one integration test
   creates a real `tab\there.txt` tracked file, modifies it, and asserts
   `fetchGitDiffHunks` keys hunks under the real name. The integration
   test no-ops on filesystems that reject tab-in-name (NTFS).

2. (line 146) The >MAX_FILES_FOR_DETAILS fast path was guarded by
   `quickStats &&`, which short-circuited to false when shortstat
   returned an empty string. A workspace with 0 tracked changes plus
   501 untracked files therefore slipped past the guardrail and ran
   the slow path, line-counting only the first MAX_FILES untracked
   files — header reported `filesCount: 501` but `linesAdded` missed
   the other 451.

   Treat empty/null/unparseable shortstat as `EMPTY_STATS` and apply
   the threshold on `tracked + untracked` uniformly. Integration test
   plants 501 untracked files + 0 tracked and asserts the result has
   `filesCount: 501` with an empty perFileStats Map (summary-only).

3. (line 263) `fetchGitDiffHunks` reads the full `git diff HEAD`
   stdout before parser caps apply. Documented in the JSDoc as a
   known limitation: streaming the parser to terminate git early at
   MAX_FILES is a reasonable follow-up but a non-trivial refactor
   (spawn + incremental parse + UTF-8 boundary handling) and out of
   scope for this PR. The existing `runGit` 64 MB maxBuffer keeps
   pathological cases from runaway-allocating.

55 gitDiff tests pass (51 + 4 new).
Comment thread packages/core/src/utils/gitDiff.ts Outdated
// utility is invoked. The stats variants in `fetchGitDiff` already
// bypass external drivers, but plain `git diff` honors them.
const diffOut = await runGit(
['--no-optional-locks', 'diff', '--no-ext-diff', 'HEAD'],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] The git diff calls disable external diff drivers with --no-ext-diff, but they still allow Git textconv filters. Textconv is configured separately through .gitattributes / diff.<driver>.textconv, and git diff --no-ext-diff can still execute those commands while /diff is only trying to inspect local changes. Add --no-textconv to each git diff invocation that already passes --no-ext-diff, and add a regression test with a textconv driver that writes a sentinel file and must not fire.

Suggested change
['--no-optional-locks', 'diff', '--no-ext-diff', 'HEAD'],
['--no-optional-locks', 'diff', '--no-ext-diff', '--no-textconv', 'HEAD'],

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 4b371a4.

Verified locally that textconv is a separate code path from the external diff drivers — --no-ext-diff alone is insufficient:

git config diff.evil.textconv /tmp/evil.sh
echo '*.pdf diff=evil' > .gitattributes
# ... commit + modify doc.pdf ...

git diff HEAD --no-ext-diff               -> /tmp/evil.sh DOES fire (writes sentinel)
git diff HEAD --no-ext-diff --no-textconv -> driver does NOT fire

Pinned --no-textconv on all four git diff invocations alongside --no-ext-diff. Empirically only the plain-diff call (fetchGitDiffHunks) currently fires textconv (the stats variants don't), but pinning both flags uniformly is defense-in-depth and keeps the policy declarative.

Regression test plants the actual attack vector — registers diff.evil.textconv = /path/to/evil.sh in the worktree's .git/config, sets *.pdf diff=evil in .gitattributes, commits + modifies a .pdf file, and asserts the driver's sentinel file is NOT written when fetchGitDiffHunks runs. Without the new flag this test would fail with the sentinel present.

…rivers

Builds on the earlier `--no-ext-diff` hardening. wenshao pointed out
that `--no-ext-diff` covers `GIT_EXTERNAL_DIFF` and
`diff.<name>.command`, but it does NOT block textconv filters
registered via `.gitattributes` + `diff.<name>.textconv` — those run
on a separate code path inside `git diff`.

Verified locally:

    git config diff.evil.textconv /tmp/evil.sh
    echo '*.pdf diff=evil' > .gitattributes
    # ... commit + modify doc.pdf ...

    git diff HEAD --no-ext-diff               -> /tmp/evil.sh fires
    git diff HEAD --no-ext-diff --no-textconv -> driver does NOT fire

Add `--no-textconv` to all four `git diff` invocations
(shortstat / numstat / name-status / plain hunks). As with
`--no-ext-diff`, only the plain-diff call (`fetchGitDiffHunks`) is
known to invoke textconv in current git, but pinning both flags
uniformly is defense-in-depth and keeps the policy declarative.

Regression test plants a real textconv driver in a worktree's
`.git/config` + `.gitattributes` and asserts the driver's sentinel
file is NOT written when `fetchGitDiffHunks` runs. Without the new
flag the test fails with the sentinel present.
@BZ-D

BZ-D commented Apr 29, 2026

Copy link
Copy Markdown
Collaborator Author

多轮无方向评审报告(设计方案 + 实现代码)

针对当前分支 feat/git-diff-stats 做了三轮无方向审计,所有结论附在下面。

Round 1 — 代码层逐函数审查

packages/core/src/utils/gitDiff.ts(872 行)

函数 检查点 结论
parseGitNumstat rename 三 token 状态机(pending → oldPath → newPath)、-z 中保留路径里的 \t ✅ 索引切分而非 split('\t'),rename 折叠为 old => new
parseGitDiff ^diff --git 多行锚定 split、content 行(前缀 +/-/ /\\)误命中风险 ✅ content 行有前缀,不会在行首匹配 delimiter
parseDeletedFromNameStatus R<score> / C<score> 跳过 2 个 path token,仅捕获 D ✅ rename 两端都不会被误标为 deleted
parseShortstat ReDoS 表面(CodeQL #137 ✅ 已锚定 ^...$/m + \d{1,10} 闭合
extractFilePath diff --git a/X b/YX b/ 时的歧义;/dev/null;C-quoted;octal UTF-8 rename to / copy to / +++ b/ / --- a/ 优先级 + unquoteCStylePath
countUntrackedLines TOCTOU、FIFO/symlink、超大文件、空文件、无尾换行 lstat + O_NOFOLLOW + 64 KB 分块(堆峰值 ~3.2 MB)
runGit 命令注入面 execFile 非 shell;--no-ext-diff + --no-textconv 封死 4 处 git diff 的命令执行面

Round 2 — 数据流与边界

  • findGitRoot 同步祖先扫描,每次调用至多 1 次,resolveGitDirFromRoot 复用结果
  • 快速路径在 shortstat 输出为空时回退 EMPTY_STATS,使 `0 tracked + 501 untracked` 也能命中 >MAX_FILES_FOR_DETAILS 护栏(避免 linesAdded 漏算 451 个文件)
  • 子目录调用:所有 git 命令都锚定在 gitRoot,untracked 路径用 path.join(gitRoot, relPath) 还原绝对路径,per-file key 与 numstat 输出保持一致
  • 暂存状态:MERGE_HEAD / CHERRY_PICK_HEAD / REVERT_HEAD / rebase-merge / rebase-apply 五种全部覆盖(rebase 走目录 probe,不只是 ref 文件)
  • numstat 和 name-status 来自两次独立 execFile,期间状态变化最差只会漏标 isDeleted,不会错标
  • 渲染:buildDiffRenderModelcomputeDiffColumnWidths 是文本路径与 Ink 路径列对齐的唯一真源,二者不会漂移

Round 3 — 测试 + 工具链

检查 结果
vitest run gitDiff.test.ts diffCommand.test.ts DiffStatsDisplay.test.tsx ✅ 86 / 86(gitDiff 56 + diffCommand 24 + DiffStatsDisplay 6)
tsc -p packages/core --noEmit ✅ 干净
tsc -p packages/cli --noEmit ✅ 干净
eslint 三个改动文件 ✅ 干净
i18n key(en / zh / zh-TW)齐备性 ✅ 16 个 key 全部命中三个 locale
MessageType.DIFF_STATS 路由 HistoryItemDisplay.tsx:178 正确分发到 <DiffStatsDisplay>
14 个 export 的外部引用 ✅ 无死代码

仅有的次要观察(非缺陷)

  1. Ink 渲染头部的 , 是硬编码 ASCII:彩色路径把 `{count} files changed` / `+N` / `-M` 拆成多个 <Text> 才能分别上色,中间的 `, ` 没法走 t();文本路径走整段 t('{{count}} files changed, +{{added}} / -{{removed}}'),zh 翻译为全角 。属于「分段染色」与「整段翻译」的取舍,影响仅限交互模式下中文用户看到的是半角逗号。
  2. 快速路径未计入 untracked 行数:当 tracked + untracked > 500 时直接返回 shortstat 的统计 + untracked 文件数,不读取 untracked 文件内容(否则就违背了 fast-path 的目的)。linesAdded 在该路径下是下界,且无 UI 标记。属于已知的有意取舍。

结论

方案与实现没有发现需要改动的问题,可以维持现状。

Comment thread packages/core/src/utils/gitDiff.ts Outdated
countUntrackedLines(path.join(gitRoot, relPath)),
),
);
for (const s of countableStats) stats.linesAdded += s.added;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] fetchGitDiff() adds every untracked file to stats.filesCount, but only line-counts untrackedPaths.slice(0, MAX_FILES). For 51–500 untracked files with no tracked changes, /diff reports all changed files while linesAdded includes only the first 50 files, so the header can substantially under-report additions.

Consider counting all untracked paths in the slow path, or explicitly marking the totals as capped/partial instead of presenting them as complete.

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in ecb7743.

Confirmed locally: with 0 tracked changes and 60 untracked one-line files in a clean repo, the pre-fix /diff reported 60 files changed, +50 linesuntrackedPaths.slice(0, MAX_FILES) clipped lines 51-60 out of stats.linesAdded while keeping them in filesCount.

Fix. fetchGitDiff now reads line counts for every untracked path that survives the >MAX_FILES_FOR_DETAILS fast-path filter (so up to ~500 files at the outer cap, not just MAX_FILES). The extension is bounded by a new mapWithConcurrency helper that runs at most MAX_FILES (50) countUntrackedLines calls concurrently, so peak heap stays around MAX_FILES * UNTRACKED_READ_CHUNK_BYTES (~3.2 MB) regardless of how many files survive into the slow path. Per-file rendering still caps at MAX_FILES — the rest are folded into linesAdded and surface as hiddenCount on the renderer side.

Why bound concurrency rather than just Promise.all over all of them. A workspace with 500 untracked files would otherwise open 500 file handles + 500 × 64 KB chunk buffers in flight; the explicit cap keeps /diff predictable on constrained hosts (containers, CI runners) without changing behavior on the common case (≤50 untracked).

Test. line-counts every untracked file in the slow path, not just the first MAX_FILES in gitDiff.test.ts creates MAX_FILES + 10 = 60 untracked one-line files in a clean repo and asserts:

  • stats.filesCount === 60
  • stats.linesAdded === 60 (would be 50 pre-fix)
  • perFileStats.size === MAX_FILES — visible-row cap unchanged

Filenames are zero-padded so ls-files --others returns them in stable order, otherwise the pre-fix bug would randomly cover the first 50 files instead of cleanly missing 10.

: r.isDeleted
? ` ${t('(binary, deleted)')}`
: ` ${t('(binary)')}`;
out.push(` ${padMarker('~', statColumnWidth)} ${r.filename}${suffix}`);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] renderDiffModelText() interpolates raw r.filename values into non-interactive output. Git permits filenames containing ANSI/control bytes; the interactive history path is sanitized via escapeAnsiCtrlCodes(item), but non-interactive/ACP output bypasses that protection.

This can let a malicious repository filename inject terminal control sequences into logs, CI output, or non-interactive terminal displays. Sanitize filenames at the plain-text rendering boundary, for example by applying the existing escapeAnsiCtrlCodes helper to r.filename before interpolation.

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in ecb7743.

Confirmed the gap locally:

  • Interactive: HistoryItemDisplay.tsx:88 runs the entire item through escapeAnsiCtrlCodes(item), which recursively walks model.rows[i].filename and JSON-escapes any byte matching ansiRegex(). Safe.
  • Non-interactive / ACP: renderDiffModelText was building strings with template-literal concatenation and the result went straight into MessageActionReturn.content → stdout / logs / transports, no sanitizer.

A repo containing a tracked file named e.g. evil\x1b[31mEVIL\x1b[0m.txt could therefore inject SGR codes into CI logs, terminal scrollback, even pagers. Worse vectors include \x1b[2J (clear screen), \x1b[H (cursor home), and DECSC / DECRC pairs that hide later output.

Fix. Pipe r.filename through escapeAnsiCtrlCodes inside formatRowsText on every row variant — modified, binary, untracked, deleted. The same helper used by the interactive path, applied once per filename at the rendering boundary so the suffix markers ((binary), (new), (deleted), (new, partial), (binary, new), (binary, deleted)) and the i18n header strings are preserved unchanged.

Tests (diffCommand.test.ts, new renderDiffModelText filename sanitization describe block):

  1. escapes raw ANSI escape sequences embedded in tracked filenames — feeds safe\x1b[31mEVIL\x1b[0m.txt into a modified-row mock, asserts \x1b[ never appears in the output and the literal �[31m form does.
  2. escapes ANSI sequences in untracked / binary / deleted suffix rows — covers all three suffix branches with \x1b[2J, \x1b[H, \x1b[0K filenames; asserts no raw ESC byte survives, while (binary) / (new) / (deleted) still render.

The interactive path is unchanged (already covered by escapeAnsiCtrlCodes(item) at the HistoryItem boundary), so this fix is purely additive on the text-output side.

…f output

Two Critical issues from PR #3491 review:

1. fetchGitDiff slow path only line-counted the first MAX_FILES (50)
   untracked paths via `untrackedPaths.slice(0, MAX_FILES)`. With 51-500
   untracked files in a clean tree the header reported the full file count
   but only ~50 files' worth of additions, materially under-reporting the
   total. Now read every untracked path that survived the
   >MAX_FILES_FOR_DETAILS fast-path filter, with concurrency bounded to
   MAX_FILES so peak heap stays around MAX_FILES *
   UNTRACKED_READ_CHUNK_BYTES (~3.2 MB) regardless of input size.

2. renderDiffModelText interpolated raw filenames into the non-interactive
   / ACP text path. The interactive history is sanitized via
   escapeAnsiCtrlCodes(item) inside HistoryItemDisplay, but the text path
   streams to stdout / logs / transports with no equivalent hop, so a
   tracked or untracked filename containing \x1b[2J etc. could inject
   color resets, cursor moves, or full screen clears into CI logs and
   downstream terminals. Pipe r.filename through escapeAnsiCtrlCodes at
   the rendering boundary on every row variant (binary, untracked,
   deleted, modified).

Tests:
- gitDiff.test.ts: regression that asserts every one of MAX_FILES + 10
  untracked one-line files contributes to stats.linesAdded (would be 50
  pre-fix vs 60 actual).
- diffCommand.test.ts: two new specs covering ANSI escapes in
  modified-file rows and in binary / untracked / deleted suffix rows.
  Verifies raw \x1b never reaches stdout while suffix markers ((binary),
  (new), (deleted)) still render.
@BZ-D BZ-D requested a review from wenshao April 29, 2026 08:50
Comment thread packages/core/src/utils/gitDiff.ts Outdated
if (!s.startsWith('"') || !s.endsWith('"') || s.length < 2) return s;
const inner = s.slice(1, -1);
// Build raw bytes first so octal `\NNN` sequences (each one byte of a
// potentially multi-byte UTF-8 character) reassemble correctly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] This branch encodes inner[i], which is only one UTF-16 code unit. If Git emits a quoted path that also contains raw non-BMP Unicode under core.quotepath=false (for example an emoji plus a tab or quote that forces C-style quoting), the surrogate pair is split and decoded as replacement characters, so the hunk map is keyed by a corrupted filename.

A safer fix is to encode one Unicode code point at a time and advance by the produced string length, while still keeping octal escapes as raw bytes.

Suggested change
// potentially multi-byte UTF-8 character) reassemble correctly.
const cp = inner.codePointAt(i);
if (cp === undefined) {
i++;
continue;
}
const ch = String.fromCodePoint(cp);
bytes.push(...Buffer.from(ch, 'utf8'));
i += ch.length;

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 4f7e8dd.

Confirmed locally: a tracked file named \t🚀.txt produces +++ "b/\t🚀.txt" in plain git diff output. Under the previous walker, the rocket emoji (U+1F680, two UTF-16 code units \uD83D\uDE80) was iterated one code unit at a time, and Buffer.from('\uD83D', 'utf8') emits the 3-byte replacement sequence EF BF BD for a lone surrogate — so the filename round-tripped as two U+FFFD characters and the hunk key never matched the on-disk path.

Fix: the non-backslash branch now reads via inner.codePointAt(i), builds String.fromCodePoint(cp), and advances by ch.length. Non-BMP code points are encoded as their full 4-byte UTF-8 sequence, octal \NNN escapes still pass through the byte-stream branch unchanged, and the bytes array is still UTF-8-decoded en masse so multi-byte octal sequences continue to reassemble correctly.

Regression test (preserves non-BMP code points in quoted paths instead of splitting surrogates in gitDiff.test.ts) feeds a quoted path with \t🚀.txt (forced-quoting via the literal tab plus a non-BMP code point in the same path) through parseGitDiff and asserts the hunk key is \t🚀.txt. Without the fix this would key under \t\uFFFD\uFFFD.txt.

(inner[i + 1 + octal.length] ?? '') >= '0' &&
(inner[i + 1 + octal.length] ?? '') <= '7'
) {
octal += inner[i + 1 + octal.length];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] Git's C-style quoting can emit \a, \b, \f, and \v for control characters in paths, but this decoder falls through to the default branch and drops the backslash, turning those filenames into ordinary a/b/f/v characters. That means fetchGitDiffHunks can return hunks under a path that does not match the real tracked filename.

Please add explicit mappings for the remaining C escapes and cover at least one of them with a regression test.

Suggested change
octal += inner[i + 1 + octal.length];
case 'a':
bytes.push(0x07);
i += 2;
break;
case 'b':
bytes.push(0x08);
i += 2;
break;
case 'f':
bytes.push(0x0c);
i += 2;
break;
case 'v':
bytes.push(0x0b);
i += 2;
break;
default:

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 4f7e8dd.

You're right — \a, \b, \f, \v were falling into the default branch, which bytes.push(...Buffer.from(next, 'utf8'))-ed only the trailing letter and silently dropped the leading backslash. So a tracked path like bell\afile.txt (BEL embedded) was decoding to bellafile.txt, and fetchGitDiffHunks keyed hunks under a name that didn't exist on disk.

Fix: explicit case arms for 'a' → 0x07, 'b' → 0x08, 'f' → 0x0c, 'v' → 0x0b next to the existing t / n / r / " / \\ arms. The octal-escape branch is unchanged.

Regression test (decodes the remaining C-style escapes (\a, \b, \f, \v) in gitDiff.test.ts) constructs a multi-file diff covering all four escapes (bell\afile.txt, back\bspace.txt, form\ffeed.txt, vert\vtab.txt) and asserts the hunk keys decode to the literal control-byte forms bell\x07file.txt, back\x08space.txt, form\x0cfeed.txt, vert\x0btab.txt. Without the fix the keys collapse to bellafile.txt / backbspace.txt / formffeed.txt / vertvtab.txt.

// `escapeAnsiCtrlCodes(item)` sanitizer in `HistoryItemDisplay`. Without
// this hop, a hostile filename could inject color resets, cursor moves,
// or full screen clears into CI logs and any consumer's terminal.
const safeName = escapeAnsiCtrlCodes(r.filename);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] escapeAnsiCtrlCodes only escapes ANSI escape sequences matched by ansi-regex; it does not escape other terminal-control bytes that Git filenames can contain, such as newline, carriage return, backspace, or BEL. As a result, a filename like bad\nINJECTED.txt or bad\roverwrite.txt can still alter non-interactive/ACP output layout or terminal behavior.

Please sanitize all non-printable control characters at this text boundary, not just ANSI sequences, and add regression coverage for newline/carriage-return/control-byte filenames.

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 4f7e8dd.

Confirmed the gap: escapeAnsiCtrlCodes runs the input through ansi-regex, which only matches the multi-byte CSI / OSC / DEC families. Standalone control bytes that aren't part of a recognized escape sequence — \n (LF), \r (CR), \x08 (BS), \x07 (BEL), \x09 (TAB), \x7f (DEL), and the C1 range \x80-\x9f — went through unchanged. A filename like bad\nINJECTED.txt would still tear our two-column diff layout apart in CI logs, bad\roverwrite.txt would still let the next row stomp on the previous one, and BEL would still beep terminals on every render.

Fix: introduced sanitizeFilenameForDisplay in diffCommand.ts that pipes the filename through escapeAnsiCtrlCodes first (preserves the existing CSI-injection coverage) and then replaces every byte in [\x00-\x1f\x7f-\x9f] via escapeControlChar. The escaper emits the familiar \\b / \\t / \\n / \\f / \\r short forms and falls back to \\u00XX for everything else (DEL and the C1 range — JSON.stringify would leave those two ranges as raw bytes, which is exactly what we're trying to keep out of the rendered output, hence the hand-rolled escape rather than reusing JSON.stringify(ch).slice(1,-1)). All four call sites — modified, untracked, binary, deleted — now go through this sanitizer.

Regression test (escapes standalone control bytes that ansi-regex does not match in diffCommand.test.ts) renders a five-row diff with filenames containing raw \n, \r, BS, BEL, and DEL respectively, then asserts none of those bytes survive into the output and that the JSON-style escaped forms (bad\nINJECTED.txt, bad\roverwrite.txt) appear instead. The existing escapes ANSI sequences in untracked / binary / deleted suffix rows test still passes against the new sanitizer, so the previous CSI coverage is intact.

BZ-D added 2 commits May 7, 2026 14:31
- unquoteCStylePath now walks Unicode code points so non-BMP characters
  (e.g. emoji) inside a forced-quoted path no longer get split into lone
  surrogates and decoded as replacement characters.
- Add explicit C-escape mappings for \a, \b, \f, \v so paths using those
  control bytes decode to BEL/BS/FF/VT instead of dropping the backslash.
- Replace escapeAnsiCtrlCodes(filename) at the /diff text-rendering
  boundary with a sanitizer that also escapes standalone C0/C1 control
  bytes plus DEL, closing newline / CR / BS / BEL injection vectors that
  ansi-regex does not match.

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No review issues found — the diff is clean, tests are thorough, and security mitigations are in place. LGTM! ✅

⚠️ Downgraded from Approve to Comment: CI has 1 failing check — Test (windows-latest, 24.x). All other platforms (macOS 20/22/24, Ubuntu 20/22/24, Windows 20/22) and lint/CodeQL checks pass. The single Windows 24.x failure is likely pre-existing / flaky, not caused by this PR.

— deepseek-v4-pro via Qwen Code /review

@BZ-D

BZ-D commented May 9, 2026

Copy link
Copy Markdown
Collaborator Author

@wenshao 你之前那条 review 已经 LGTM,只是因为 Test (windows-latest, 24.x) 这一项 CI 没过被 downgrade 到了 Comment。我刚才把那个失败的 case 重新跑了一遍,已经通过了——现在所有平台(macOS 20/22/24、Ubuntu 20/22/24、Windows 20/22/24)以及 Lint、CodeQL 全绿。麻烦再 review 并 approve 一下,谢谢!

@BZ-D BZ-D requested a review from wenshao May 9, 2026 06:24

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found. LGTM! ✅ — DeepSeek/deepseek-v4-pro via Qwen Code /review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/feature-request New feature or enhancement request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P2] Git Diff Statistics / Git Diff 统计

5 participants