A side pane listing the files changed in the working tree, with colored git diff stats

A personal Claude Code plugin marketplace: terminal UI mods (a status band above the prompt and two side panes) and a plugin of skills shared across machines.
| Plugin | What it adds | Command |
|---|---|---|
prompt-status | A two-line band above the prompt: model and context window, current directory, git branch, context fill and rate-limit usage | — |
token-usage | A pane with context fill, session token totals, cost and rate limits | /token-usage |
git-changes | A pane listing the files changed in the working tree, with colored git diff stats | /changes |
my-skills | Personal skills shared across machines | /my-skills:<skill> |
/plugin marketplace add matr1xp/local-mods
/plugin install prompt-status@local-mods
/plugin install token-usage@local-mods
/plugin install git-changes@local-mods
/plugin install my-skills@local-mods
Renders above the prompt in every session:

model setting.*) refresh after each turn and once a minute. A detached HEAD shows its short commit hash.Opens a pane at session start. Run /token-usage to reopen it. The pane shows:

Running /clear resets the session totals.
Opens a pane in interactive sessions. Run /changes to reopen it and print a summary. The pane lists every file that differs from HEAD, whether staged, unstaged or untracked:

M, A, D, R, ??, …), +added / -deleted counts and a git --stat-style bar. Binary files show bin.● marker on files whose stats changed since the previous scan.HEAD in the pane, deleted and untracked files included. It reloads as the file changes. Press b or ← Back to return to the list.Edit, Write, NotebookEdit and Bash tool calls, and every 4 seconds while it is on screen. Press r to refresh by hand.GIT_OPTIONAL_LOCKS=0, so polling never holds index.lock while you run your own git commands.new.A home for personal skills, so they install on every machine like the other plugins. Each skill is a folder under my-skills/skills/ with a SKILL.md, and is invoked as /my-skills:<skill>. Claude also loads a skill on its own when a request matches its description.
To add a skill, copy my-skills/skills/example/ to my-skills/skills/<name>/, set name in the frontmatter to match the folder, and rewrite the description and body.
.claude-plugin/marketplace.json marketplace manifest listing the plugins
<plugin>/
.claude-plugin/plugin.json name, version, description
hooks/hooks.json points at the hooks module
hooks/register.tsx the mod: event hooks and UI rendering
types/index.d.ts shapes of the state each mod stores
tests/*.test.ts(x) tests using claude-code/testing
Run a plugin's tests, then validate the marketplace:
claude plugin test git-changes
claude plugin validate .
After changing a plugin, bump version in its .claude-plugin/plugin.json so other machines pick up the update with claude plugin update <plugin>@local-mods.
MIT. The software is provided as is, without warranty of any kind, and the author is not liable for any damage arising from its use.
hooks/register.tsx 541 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { ChangedFile, FileDiff, Snapshot } from '../types'
5
6const PANE = 'git-changes'
7const TITLE = 'Changes'
8const POLL_MS = 4000
9// Untracked files are counted one `git diff --no-index` each; past this many they show as "new".
10const MAX_UNTRACKED_COUNTED = 40
11const MAX_ROWS = 500
12// One drawing holds 100,000 characters of text in all; the diff leaves room for the
13// header around it and is cut at a line past this.
14const MAX_DIFF_CHARS = 90_000
15// A diff longer than this is not reloaded by a poll while its file's counts hold still.
16const LARGE_DIFF_CHARS = 20_000
17// git's well-known empty tree: the diff base before the first commit.
18const EMPTY_TREE = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'
19// Polling must never take index.lock out from under the person's own git commands.
20const GIT_ENV = { GIT_OPTIONAL_LOCKS: '0' }
21
22const STATUS_COLOR: Record<string, string> = {
23 M: 'warning',
24 A: 'success',
25 D: 'error',
26 R: 'suggestion',
27 C: 'suggestion',
28 T: 'warning',
29 U: 'error',
30 '?': 'subtle',
31}
32
33const snapshot = atom({ plugin: 'git-changes', key: 'snapshot' } as const, null)
34// The file whose diff the pane shows in place of the list; null shows the list.
35const diff = atom({ plugin: 'git-changes', key: 'diff' } as const, null)
36
37type Stat = { added: number | null; deleted: number | null; isBinary: boolean }
38
39const git = ($: EngineInterface, args: string[], cwd?: string) =>
40 $.process.run(['git', ...args], { cwd, env: GIT_ENV, timeoutMs: 10_000 })
41
42// `--numstat -z`: "added\tdeleted\tpath\0", or "added\tdeleted\t\0old\0new\0" for a
43// rename; a binary file counts "-".
44export function parseNumstat(out: string): Map<string, Stat> {
45 const tokens = out.split('\0')
46 const stats = new Map<string, Stat>()
47 for (let i = 0; i < tokens.length; i++) {
48 const head = tokens[i]
49 if (head === undefined || head === '') continue
50 const firstTab = head.indexOf('\t')
51 const secondTab = head.indexOf('\t', firstTab + 1)
52 const added = head.slice(0, firstTab)
53 const deleted = head.slice(firstTab + 1, secondTab)
54 let path = head.slice(secondTab + 1)
55 if (path === '') {
56 i += 2
57 path = tokens[i] ?? ''
58 }
59 const isBinary = added === '-'
60 stats.set(path, {
61 added: isBinary ? null : Number(added),
62 deleted: isBinary ? null : Number(deleted),
63 isBinary,
64 })
65 }
66 return stats
67}
68
69// `--name-status -z`: "M\0path\0", or "R100\0old\0new\0" for a rename or copy.
70export function parseNameStatus(out: string): Map<string, { status: string; from?: string }> {
71 const tokens = out.split('\0')
72 const statuses = new Map<string, { status: string; from?: string }>()
73 for (let i = 0; i < tokens.length; i++) {
74 const code = tokens[i]
75 if (code === undefined || code === '') continue
76 const letter = code.charAt(0)
77 if (letter === 'R' || letter === 'C') {
78 const from = tokens[i + 1] ?? ''
79 i += 2
80 statuses.set(tokens[i] ?? '', { status: letter, from })
81 } else {
82 i++
83 statuses.set(tokens[i] ?? '', { status: letter })
84 }
85 }
86 return statuses
87}
88
89async function countUntracked($: EngineInterface, root: string, path: string): Promise<Stat> {
90 // Exits 1 when the file differs from /dev/null, which it always does.
91 const { stdout } = await git($, ['diff', '--no-index', '--numstat', '-z', '--', '/dev/null', path], root)
92 const [stat] = parseNumstat(stdout).values()
93 return stat ?? { added: null, deleted: null, isBinary: false }
94}
95
96async function scan($: EngineInterface): Promise<Omit<Snapshot, 'fresh' | 'changedAt'>> {
97 const top = await git($, ['rev-parse', '--show-toplevel'])
98 if (top.exitCode !== 0) {
99 return { root: '', branch: '', files: [], error: 'Not a git repository' }
100 }
101 const root = top.stdout.trim()
102
103 const [symbolic, head] = await Promise.all([
104 git($, ['symbolic-ref', '--short', '-q', 'HEAD'], root),
105 git($, ['rev-parse', '--short', '-q', '--verify', 'HEAD'], root),
106 ])
107 const branch = symbolic.exitCode === 0 ? symbolic.stdout.trim() : `detached ${head.stdout.trim()}`
108 const base = head.exitCode === 0 ? 'HEAD' : EMPTY_TREE
109
110 const [numstat, nameStatus, others] = await Promise.all([
111 git($, ['diff', '-M', '--numstat', '-z', base], root),
112 git($, ['diff', '-M', '--name-status', '-z', base], root),
113 git($, ['ls-files', '--others', '--exclude-standard', '-z'], root),
114 ])
115 if (numstat.exitCode !== 0) {
116 return { root, branch, files: [], error: numstat.stderr.trim() || 'git diff failed' }
117 }
118
119 const stats = parseNumstat(numstat.stdout)
120 const statuses = parseNameStatus(nameStatus.stdout)
121 const files: ChangedFile[] = [...stats]
122 .map(([path, stat]) => ({ path, status: 'M', ...statuses.get(path), ...stat }))
123 .sort((a, b) => a.path.localeCompare(b.path))
124
125 const untracked = others.stdout.split('\0').filter(Boolean).sort()
126 const counted = await Promise.all(
127 untracked
128 .slice(0, MAX_UNTRACKED_COUNTED)
129 .map(path => countUntracked($, root, path).catch(() => null)),
130 )
131 untracked.forEach((path, i) => {
132 const stat = counted[i] ?? { added: null, deleted: null, isBinary: false }
133 files.push({ path, status: '?', ...stat })
134 })
135
136 return { root, branch, files, error: null }
137}
138
139// Drops git's file header (Code reads hunks alone) and cuts what is past MAX_DIFF_CHARS
140// at a line, renumbering a hunk cut short so it still parses.
141export function hunksOf(out: string): Pick<FileDiff, 'hunks' | 'isTruncated'> {
142 const first = out.startsWith('@@') ? 0 : out.indexOf('\n@@') + 1
143 if (first === 0 && !out.startsWith('@@')) return { hunks: '', isTruncated: false }
144 const hunks = out.slice(first).replace(/\n$/, '')
145 if (hunks.length <= MAX_DIFF_CHARS) return { hunks, isTruncated: false }
146
147 let lines = hunks.slice(0, hunks.lastIndexOf('\n', MAX_DIFF_CHARS)).split('\n')
148 let head = lines.findLastIndex(line => line.startsWith('@@'))
149 if (head === lines.length - 1) {
150 // The cut left the last hunk with a header and nothing under it.
151 if (head > 0) return { hunks: lines.slice(0, head).join('\n'), isTruncated: true }
152 // The only hunk starts with a line longer than a drawing (minified code): cut inside it.
153 lines = hunks.slice(0, MAX_DIFF_CHARS).split('\n')
154 head = 0
155 }
156 const body = lines.slice(head + 1)
157 const old = body.filter(line => line.startsWith(' ') || line.startsWith('-')).length
158 const now = body.filter(line => line.startsWith(' ') || line.startsWith('+')).length
159 lines[head] = (lines[head] ?? '').replace(
160 /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/,
161 (_, a: string, c: string) => `@@ -${a},${old} +${c},${now} @@`,
162 )
163 return { hunks: lines.join('\n'), isTruncated: true }
164}
165
166async function diffFile($: EngineInterface, root: string, file: ChangedFile): Promise<Omit<FileDiff, 'path'>> {
167 if (file.isBinary) return { hunks: '', isTruncated: false, error: null }
168 const flags = ['diff', '--no-color', '--no-ext-diff']
169 let ran
170 if (file.status === '?') {
171 ran = await git($, [...flags, '--no-index', '--', '/dev/null', file.path], root)
172 } else {
173 const head = await git($, ['rev-parse', '--short', '-q', '--verify', 'HEAD'], root)
174 const base = head.exitCode === 0 ? 'HEAD' : EMPTY_TREE
175 const paths = file.from === undefined ? [file.path] : [file.from, file.path]
176 ran = await git($, [...flags, '-M', base, '--', ...paths], root)
177 }
178 // `--no-index` exits 1 when the files differ, which they do.
179 if (ran.exitCode > 1) {
180 return { hunks: '', isTruncated: false, error: ran.stderr.trim() || 'git diff failed' }
181 }
182 return { ...hunksOf(ran.stdout), error: null }
183}
184
185// Bumped each time the person opens a diff or leaves it. A load that began under an older
186// generation is stale (Back, then the same file again) and must not write its result.
187let diffGeneration = 0
188// What the shown diff was last loaded from: a big diff is not re-run while this holds.
189let loadedFrom: { path: string; source: string } | undefined
190
191// What a file's diff is made from: its status, the commit it is diffed against, the rename
192// source and the file's content in the work tree, so an edit that keeps the counts shows.
193async function sourceOf($: EngineInterface, root: string, file: ChangedFile) {
194 const [head, blob] = await Promise.all([
195 git($, ['rev-parse', '-q', '--verify', 'HEAD'], root),
196 git($, ['hash-object', '--', file.path], root),
197 ])
198 // A deleted file has no content to hash.
199 const content = blob.exitCode === 0 ? blob.stdout.trim() : 'gone'
200 return [file.status, head.stdout.trim(), file.from ?? '', content].join('|')
201}
202
203// One diff load at a time, in the order asked: opening a file can land while a poll's load
204// is mid-way, and a later load reads later state, so it must also be the last to write.
205let loading: Promise<void> = Promise.resolve()
206
207function loadDiff($: EngineInterface): Promise<void> {
208 const load = loading.then(() => loadDiffNow($))
209 loading = load.catch(() => undefined)
210 return load
211}
212
213// Reloads the diff on show: back to the list when its file no longer differs.
214async function loadDiffNow($: EngineInterface) {
215 // Taken before any await, so a view opened or left meanwhile makes this load stale.
216 const generation = diffGeneration
217 const [snap, shown] = await Promise.all([read($, snapshot), read($, diff)])
218 if (snap === null || shown === null) return
219 const file = snap.files.find(candidate => candidate.path === shown.path)
220 if (file === undefined) {
221 await update($, diff, current => (current?.path === shown.path && generation === diffGeneration ? null : current))
222 return
223 }
224 // A poll skips re-running git on a large diff while what it is made from holds still.
225 let source: string
226 try {
227 source = await sourceOf($, snap.root, file)
228 } catch {
229 source = ''
230 }
231 if (
232 source !== '' &&
233 shown.hunks !== null &&
234 shown.hunks.length > LARGE_DIFF_CHARS &&
235 loadedFrom?.path === file.path &&
236 loadedFrom.source === source
237 ) {
238 return
239 }
240 let loaded: Omit<FileDiff, 'path'>
241 try {
242 loaded = await diffFile($, snap.root, file)
243 } catch (error) {
244 loaded = { hunks: '', isTruncated: false, error: error instanceof Error ? error.message : String(error) }
245 }
246 // Keep the same value when nothing moved, so a poll does not redraw; and drop a load
247 // the person has since left (Back, or another file, or the same file reopened).
248 await update($, diff, current => {
249 if (generation !== diffGeneration || current?.path !== file.path) return current
250 loadedFrom = { path: file.path, source }
251 return current.hunks === loaded.hunks && current.isTruncated === loaded.isTruncated && current.error === loaded.error
252 ? current
253 : { path: file.path, ...loaded }
254 })
255}
256
257async function showDiff($: EngineInterface, path: string) {
258 diffGeneration++
259 loadedFrom = undefined
260 await update($, diff, () => ({ path, hunks: null, isTruncated: false, error: null }))
261 await $.ui.scroll({ in: PANE, to: 'start' }).catch(() => undefined)
262 await loadDiff($)
263}
264
265async function showList($: EngineInterface, path: string) {
266 diffGeneration++
267 loadedFrom = undefined
268 await update($, diff, () => null)
269 await $.ui.scroll({ in: PANE, to: { key: `diff:${path}` } }).catch(() => undefined)
270}
271
272const signature = (file: ChangedFile) => `${file.status}|${file.added}|${file.deleted}`
273
274async function scanAndStore($: EngineInterface) {
275 let next: Omit<Snapshot, 'fresh' | 'changedAt'>
276 try {
277 next = await scan($)
278 } catch (error) {
279 next = { root: '', branch: '', files: [], error: error instanceof Error ? error.message : String(error) }
280 }
281 const prev = await read($, snapshot)
282 const prevByPath = new Map(prev?.files.map(file => [file.path, signature(file)]))
283 const isSame =
284 prev !== null &&
285 prev.root === next.root &&
286 prev.branch === next.branch &&
287 prev.error === next.error &&
288 prev.files.length === next.files.length &&
289 next.files.every(file => prevByPath.get(file.path) === signature(file))
290 if (isSame) return
291
292 // The first scan highlights nothing; later ones mark what moved since the last.
293 const fresh =
294 prev === null ? [] : next.files.filter(file => prevByPath.get(file.path) !== signature(file)).map(file => file.path)
295 const changedAt = await $.clock.now()
296 await update($, snapshot, () => ({ ...next, fresh, changedAt }))
297}
298
299// One scan at a time; a call that lands mid-scan queues one more pass after it.
300let running: Promise<void> | undefined
301let isQueued = false
302
303function refresh($: EngineInterface): Promise<void> {
304 if (running !== undefined) {
305 isQueued = true
306 return running
307 }
308 running = (async () => {
309 try {
310 do {
311 isQueued = false
312 await scanAndStore($)
313 await loadDiff($)
314 } while (isQueued)
315 } finally {
316 running = undefined
317 }
318 })()
319 return running
320}
321
322async function isPaneUp($: EngineInterface) {
323 const panes = await $.ui.panes()
324 return panes.some(pane => pane.id === PANE && pane.isPlaced)
325}
326
327const clock = (ms: number) => {
328 const at = new Date(ms)
329 return [at.getHours(), at.getMinutes(), at.getSeconds()].map(n => String(n).padStart(2, '0')).join(':')
330}
331
332const plural = (n: number, word: string) => `${n} ${word}${n === 1 ? '' : 's'}`
333
334export const register: Register = on => {
335 on('session.start', async ($, e, next) => {
336 await $.command.register({
337 name: 'changes',
338 description: 'Show changed files with git diff stats in a side pane',
339 })
340 if (e.isInteractive) {
341 await refresh($)
342 void $.ui.open({ id: PANE, title: TITLE })
343 $.clock.every(POLL_MS, () => {
344 void isPaneUp($)
345 .then(isUp => (isUp ? refresh($) : undefined))
346 .catch(() => undefined)
347 })
348 }
349
350 return next(e)
351 })
352
353 on('command.run', { command: 'changes' }, async ($, e) => {
354 diffGeneration++
355 loadedFrom = undefined
356 await update($, diff, () => null)
357 await refresh($)
358 await $.ui.open({ id: PANE, title: TITLE })
359 const snap = await read($, snapshot)
360 const tip = e.presentation.isFullscreen
361 ? ''
362 : ' It docks to the right in the fullscreen layout; on the main screen it sits above the prompt.'
363 if (snap === null || snap.error !== null) {
364 return { text: `Changes pane opened${snap?.error ? ` (${snap.error})` : ''}.${tip}` }
365 }
366 const added = snap.files.reduce((sum, file) => sum + (file.added ?? 0), 0)
367 const deleted = snap.files.reduce((sum, file) => sum + (file.deleted ?? 0), 0)
368
369 return {
370 text: `Changes pane opened: ${plural(snap.files.length, 'file')} changed, +${added} -${deleted}.${tip}`,
371 }
372 })
373
374 // Rescan right after a tool that may have touched files, so the pane keeps up with each edit.
375 on('tool.call', { tool: ['Edit', 'Write', 'NotebookEdit', 'Bash'] }, async ($, e, next) => {
376 const ran = await next(e)
377 if (await isPaneUp($)) await refresh($)
378
379 return ran
380 }).catch(($, e, next) => next(e))
381
382 on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
383 const { Box, Text, Button, Code } = $.ui.resolve(e)
384 const [snap, open] = await Promise.all([read($, snapshot), read($, diff)])
385 const width = e.props.bodyColumns
386
387 if (snap === null) {
388 return <Text dimColor>Scanning…</Text>
389 }
390 if (snap.error !== null) {
391 return (
392 <Box flexDirection="column">
393 <Text color="error">{snap.error}</Text>
394 <Button key="refresh" label="↻ Refresh" hotkey="r" onPress={() => refresh($)} />
395 </Box>
396 )
397 }
398
399 const statusText = (file: ChangedFile) => (file.status === '?' ? '??' : file.status).padEnd(2)
400
401 const viewed = open === null ? undefined : snap.files.find(file => file.path === open.path)
402 if (open !== null && viewed !== undefined) {
403 const body =
404 open.error !== null ? (
405 <Text color="error">{open.error}</Text>
406 ) : open.hunks === null ? (
407 <Text dimColor>Loading diff…</Text>
408 ) : open.hunks === '' ? (
409 <Text dimColor>{viewed.isBinary ? 'Binary file: no text diff' : 'No text changes to show'}</Text>
410 ) : (
411 <Code source={open.hunks} path={viewed.path} format="diff" />
412 )
413 return (
414 <Box flexDirection="column">
415 <Box flexDirection="row">
416 <Button key="back" label="← Back" hotkey="b" onPress={() => showList($, viewed.path)} />
417 <Text> </Text>
418 <Text color={STATUS_COLOR[viewed.status] ?? 'text'} bold>
419 {statusText(viewed)}{' '}
420 </Text>
421 <Text wrap="truncate-start">{viewed.path}</Text>
422 </Box>
423 {viewed.from !== undefined && <Text dimColor>from {viewed.from}</Text>}
424 <Text dimColor>{'─'.repeat(Math.max(1, width))}</Text>
425 {body}
426 {open.isTruncated && <Text dimColor>…cut here: the rest is too long to show</Text>}
427 </Box>
428 )
429 }
430
431 const fresh = new Set(snap.fresh)
432 const totalAdded = snap.files.reduce((sum, file) => sum + (file.added ?? 0), 0)
433 const totalDeleted = snap.files.reduce((sum, file) => sum + (file.deleted ?? 0), 0)
434
435 // Columns: marker, status, path, +added, -deleted, then a git --stat style bar.
436 const addedText = (file: ChangedFile) => (file.isBinary ? 'bin' : file.added === null ? 'new' : `+${file.added}`)
437 const deletedText = (file: ChangedFile) => (file.deleted === null ? '' : `-${file.deleted}`)
438 const addedWidth = Math.max(0, ...snap.files.map(file => addedText(file).length))
439 const deletedWidth = Math.max(0, ...snap.files.map(file => deletedText(file).length))
440 const barWidth = width >= 60 ? 12 : width >= 44 ? 6 : 0
441 const pathWidth = Math.max(8, width - 4 - (1 + addedWidth + 1 + deletedWidth) - (barWidth > 0 ? 1 + barWidth : 0))
442 const largest = Math.max(1, ...snap.files.map(file => (file.added ?? 0) + (file.deleted ?? 0)))
443 const scale = largest <= barWidth ? 1 : barWidth / largest
444
445 const bar = (file: ChangedFile) => {
446 const added = file.added ?? 0
447 const deleted = file.deleted ?? 0
448 let plus = added > 0 ? Math.max(1, Math.round(added * scale)) : 0
449 let minus = deleted > 0 ? Math.max(1, Math.round(deleted * scale)) : 0
450 while (plus + minus > barWidth) {
451 if (plus >= minus) plus--
452 else minus--
453 }
454 return (
455 <Text>
456 {' '}
457 <Text color="success">{'█'.repeat(plus)}</Text>
458 <Text color="error">{'█'.repeat(minus)}</Text>
459 {' '.repeat(barWidth - plus - minus)}
460 </Text>
461 )
462 }
463
464 const row = (file: ChangedFile) => {
465 const isFresh = fresh.has(file.path)
466 const slash = file.path.lastIndexOf('/')
467 const dir = file.path.slice(0, slash + 1)
468 const name = file.path.slice(slash + 1)
469 const label = (
470 <Text wrap="truncate-start" bold={isFresh}>
471 <Text dimColor>{dir}</Text>
472 {name}
473 </Text>
474 )
475 return (
476 <Box flexDirection="row">
477 <Text color="claude">{isFresh ? '●' : ' '}</Text>
478 <Text color={STATUS_COLOR[file.status] ?? 'text'} bold>
479 {statusText(file)}{' '}
480 </Text>
481 <Box width={pathWidth}>
482 <Button key={`diff:${file.path}`} plain onPress={() => showDiff($, file.path)}>
483 {label}
484 </Button>
485 </Box>
486 <Text> </Text>
487 <Text color={file.added === null ? 'subtle' : 'success'} bold={isFresh}>
488 {addedText(file).padStart(addedWidth)}
489 </Text>
490 <Text> </Text>
491 <Text color="error" bold={isFresh}>
492 {deletedText(file).padStart(deletedWidth)}
493 </Text>
494 {barWidth > 0 && bar(file)}
495 </Box>
496 )
497 }
498
499 const shown = snap.files.slice(0, MAX_ROWS)
500
501 return (
502 <Box flexDirection="column">
503 <Box flexDirection="row">
504 <Text dimColor>on </Text>
505 <Text color="suggestion" bold wrap="truncate-end">
506 {snap.branch}
507 </Text>
508 </Box>
509 {snap.files.length === 0 ? (
510 <Text color="success">Working tree clean</Text>
511 ) : (
512 <Text>
513 <Text bold>{plural(snap.files.length, 'file')} changed</Text>
514 {' '}
515 <Text color="success" bold>
516 +{totalAdded}
517 </Text>
518 {' '}
519 <Text color="error" bold>
520 -{totalDeleted}
521 </Text>
522 </Text>
523 )}
524 <Text dimColor>{'─'.repeat(Math.max(1, width))}</Text>
525 {shown.map(row)}
526 {snap.files.length > shown.length && (
527 <Text dimColor>…and {snap.files.length - shown.length} more</Text>
528 )}
529 <Text> </Text>
530 <Box flexDirection="row">
531 <Text dimColor>
532 {fresh.size > 0 && <Text color="claude">● </Text>}
533 {fresh.size > 0 ? 'just changed · ' : ''}updated {clock(snap.changedAt)}{' '}
534 </Text>
535 <Button key="refresh" label="↻ Refresh" hotkey="r" onPress={() => refresh($)} />
536 </Box>
537 </Box>
538 )
539 })
540}
541types/index.d.ts 46 lines1/**
2 * One changed file, as `git diff --numstat` / `--name-status` against HEAD
3 * report it (staged and unstaged together), or an untracked file.
4 */
5export type ChangedFile = {
6 /** Repo-relative path (the new path for a rename). */
7 path: string
8 /** The path it was renamed or copied from (R, C); absent otherwise. */
9 from?: string
10 /** git's status letter (M, A, D, R, C, T, U), or `?` for untracked. */
11 status: string
12 /** Lines added; null when binary or not counted. */
13 added: number | null
14 /** Lines deleted; null when binary or not counted. */
15 deleted: number | null
16 isBinary: boolean
17}
18
19export type Snapshot = {
20 /** The repository's top level, absolute; '' when the scan failed. */
21 root: string
22 branch: string
23 files: ChangedFile[]
24 /** Paths whose stats changed in the latest scan that found a difference. */
25 fresh: string[]
26 /** When the list last changed, ms since the epoch. */
27 changedAt: number
28 error: string | null
29}
30
31/** The file the pane shows the diff of in place of the list. */
32export type FileDiff = {
33 path: string
34 /** Unified-diff hunks from the first `@@`, '' when there are none; null while loading. */
35 hunks: string | null
36 /** True when the hunks were cut to what one drawing holds. */
37 isTruncated: boolean
38 error: string | null
39}
40
41declare module 'claude-code' {
42 interface PluginState {
43 'git-changes': { snapshot: Snapshot | null; diff: FileDiff | null }
44 }
45}
46