diffstalkerd 0.7.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,442 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.8.1] - 2026-07-28
11
+
12
+ ### Added
13
+
14
+ - **Web UI: recent repos group by project.** The header's "Recent" list now
15
+ collapses a repo's worktrees into one row (like the "Open on daemon" list
16
+ already did), instead of one row per worktree; picking a multi-worktree
17
+ project opens its most recently edited worktree. Both lists label a
18
+ project with the same "N worktrees" count — all of its worktrees, not
19
+ just the open ones — so one project reads identically in either. A recent
20
+ entry that no longer resolves to any worktree (a removed worktree
21
+ directory still in local prefs) is dropped instead of showing as its own
22
+ stray row.
23
+ - **Web UI: the worktree switcher is a two-line dropdown, split into
24
+ Recent and Stale.** Replaces the native `<select>` (whose closed state
25
+ leaked the active worktree's last-edited time into the trigger) with a
26
+ custom panel: each row notes commits ahead of its base branch and a
27
+ relative "edited N ago" time. A long-lived project accumulates worktrees
28
+ without bound, so anything touched in the last week is Recent and always
29
+ shown, while the rest collapses to three rows behind an "N more" reveal.
30
+ The active worktree stays visible even when it falls outside that
31
+ preview.
32
+ - **Web UI: the Changes tab shows its changed-file count** — `Changes (4)`,
33
+ or `Changes (0)` on a clean tree — so the tab says whether there is
34
+ anything to look at without having to open it first.
35
+ - **Web UI: wrap long lines.** A small, deliberately low-key "Wrap" toggle in
36
+ the corner of every diff pane (Changes, Compare, History) and the Explorer
37
+ file viewer — off by default, persisted, closer to a Notepad/Word "Word
38
+ Wrap" checkbox than the header's headline display toggles. Unified diffs
39
+ and the file viewer wrap; split diffs always stay on their normal
40
+ horizontal-scroll layout (a wrapped del/add pair can wrap to a different
41
+ line count per side, which would desync the two columns).
42
+
43
+ ## [0.8.0] - 2026-07-26
44
+
45
+ A security-hardening and web-UI-polish release. The daemon is now
46
+ loopback-only with an origin guard and a least-privilege API surface, the
47
+ repo gained public-project governance, and the web UI got a round of polish.
48
+
49
+ ### Security
50
+
51
+ - **The daemon binds loopback only.** Removed the `--host` flag — there is no
52
+ option to bind a routable interface (it has no authentication). Reach it from
53
+ another machine over an SSH tunnel (`ssh -L 7337:localhost:7337 …`).
54
+ - **Origin guard on a bound `--port`.** A `Host` allow-list blocks DNS-rebinding
55
+ (421) and cross-site requests are rejected (CSRF, 403); non-browser clients
56
+ (the CLI, `curl`) pass untouched. Every response also carries hardening headers
57
+ (`X-Content-Type-Options`, `X-Frame-Options: DENY`, `Referrer-Policy`) and a
58
+ strict `Content-Security-Policy` for the served SPA.
59
+ - **Least-privilege REST surface on a port.** A `--port` (web) daemon routes only
60
+ what the web UI uses — reads, repo open/release, and file-level stage/unstage.
61
+ Every CLI-only mutation (commit, discard, hunk staging, remote/branch
62
+ operations, persisted compare base) returns `404`; the full API stays on the
63
+ CLI's unix socket.
64
+ - Hardened the untracked-file diff (realpath containment against symlink escapes
65
+ + a read cap) and bounded the history `count` parameter.
66
+
67
+ ### Added
68
+
69
+ - Public-project governance: `SECURITY.md`, `CONTRIBUTING.md`, `CODEOWNERS`,
70
+ Dependabot, CodeQL, and continuous CI (build + lint + full test suite on every
71
+ push and pull request).
72
+ - A workspace-wide circular-dependency check that catches cross-package cycles
73
+ the per-package checks miss.
74
+
75
+ ### Changed
76
+
77
+ - **Web UI polish.** Per-view toolbars now get their own row instead of crowding
78
+ the global toggles; Compare shows the `branch → base` direction and reload
79
+ feedback; stacked diffs pin the hunk header below the file header; the Journal
80
+ entry header was redesigned to match the rest of the site — a `--surface`
81
+ strip with a kind-coloured left rail, the kind shown as colour-coded text
82
+ (the site's status idiom) and a bold filename — dropping the bordered kind
83
+ pill and the line range that just duplicated the diff's own @@ header.
84
+ - Journal: a commit (or any boundary that retired changes) can now be folded
85
+ to collapse the entries it committed into its one line, click to re-expand.
86
+ And "created" now reads as "new file" only for a genuinely new file — a new
87
+ change region in an existing file reads as "edited" (coloured modified),
88
+ which is what it actually is.
89
+ - Journal, restraint pass: pared back to a calm second-screen viewer of your
90
+ uncommitted work. Dropped the outdated-stub resurrection, the "seeded" tag,
91
+ the kind-help hover glossary, per-entry copy-path, and the fold-chain
92
+ drill-in (the ×N is now a static churn marker); `expanded`/`shrunk` fold into
93
+ `edited` and `renamed` renders neutral, so the kind vocabulary is just
94
+ new-file / edited / reverted; relative times freeze to a wall-clock HH:MM
95
+ past an hour so the column stops perpetually re-ticking. Fixed selection-vs-hover across every list (a selected row was
96
+ indistinguishable from a hovered one), added focus-visible rings, and gave the
97
+ stage/unstage buttons semantic hover colors.
98
+ - README leads with the web UI, with light and dark screenshots.
99
+
100
+ ### Internal
101
+
102
+ - Dependency refresh: eslint 10, TypeScript 6.0, chokidar 5, and the GitHub
103
+ Actions majors. `engines.node` raised to `>=20.19.0` (chokidar 5's floor).
104
+
105
+ ## [0.7.1] - 2026-07-23
106
+
107
+ ### Changed
108
+
109
+ - **Compare view — the active-file indicator follows your scroll.** As you scroll
110
+ the stacked diffs, the file list highlights whichever file you are on (and
111
+ nearest-edge-scrolls to keep that row in view), through the SAME mechanism a
112
+ click uses. That focus indicator is now prominent — a selection-tinted row,
113
+ clearly distinct from the hover state — in both the Compare and Changes views,
114
+ and the first file is selected on load so the indicator is present from the
115
+ start.
116
+
117
+ ## [0.7.0] - 2026-07-23
118
+
119
+ ### Added
120
+
121
+ - **Journal view (web UI).** A new second view — a chronological, downward-only
122
+ log of every change as it happens, tracked **per hunk** rather than per file:
123
+ two edits to two different files land as two entries at the bottom even if
124
+ those files also changed higher up. Each entry has a timestamp, path, kind
125
+ (created / edited / expanded / shrunk / reverted / renamed), line span, +/−
126
+ stats, and its own diff. When a hunk is edited/expanded/shrunk/reverted the
127
+ older entry higher up is marked outdated and collapses while the fresh one
128
+ appears at the bottom (lineage via a `supersedes` chain); rapid edits to one
129
+ hunk fold into a single entry. The log is daemon-owned (HEAD-axis observation,
130
+ in-memory, bounded/pruned), streamed over SSE with an epoch + `since`
131
+ reconnect protocol so a client never sees a torn or interleaved log. Huge and
132
+ binary files show a collapsed placeholder. Observation is guarded against
133
+ torn reads during external `git checkout`/rebase so those never storm the log.
134
+ - **Diff viewing modes (web UI).** Two global, persisted header toggles applied
135
+ to every diff surface (Changes, Journal, History, Compare) through the one
136
+ shared diff renderer: **syntax highlighting** (highlight.js-tokenized content
137
+ vs. plain text — language detected per file, theme-colored so it stays readable
138
+ over the add/del row tints, composing with the existing word-level
139
+ highlighting) and a **split / side-by-side view** (old on the left, new on the
140
+ right; deletions paired with additions row-for-row, long lines scrolling
141
+ horizontally).
142
+ - **File staging in the web UI.** The Changes view gains a per-row stage (+) /
143
+ unstage (−) button — the web UI's first working-tree mutation. No commit,
144
+ discard, or hunk-staging; those stay in the terminal UI.
145
+ - **Stacked diff surface (web UI).** Changes and Compare render every file's diff
146
+ in one continuous scroll with sticky per-file headers and per-file collapse;
147
+ the file list becomes a jump navigator into the stack.
148
+ - **Broader syntax-highlighting coverage.** The Explorer file viewer and the diff
149
+ syntax mode now cover many more file types — Vue SFCs, Jenkinsfiles (Groovy),
150
+ Dockerfiles, PowerShell, HCL/Terraform, F#, Elixir, Clojure, and others —
151
+ instead of falling back to plain text.
152
+
153
+ ### Changed
154
+
155
+ - **Responsive web layout.** The header reflows on narrow / portrait screens —
156
+ the repo identity and the find-file + theme controls stay put while the mode
157
+ toggles drop to their own full-width row — and at 1080px wide or less the
158
+ activity rail becomes a top tab band and every side-by-side view (list | diff)
159
+ stacks top-over-bottom, so nothing overflows on a vertical monitor. The app no
160
+ longer stretches past the viewport on a wide diff line.
161
+ - **Journal polish.** Entries live-tick their relative time from the moment they
162
+ arrive, keep the file name visible on long paths (the directory ellipses, full
163
+ path on hover), and gain a copy-full-path button; the kind badge and the
164
+ "changed before the Journal started" (seeded) note explain themselves on hover.
165
+ - The draggable divider between the two panes in every split view is now a
166
+ visible bar with a grab handle, so the file list and the diff / content read as
167
+ clearly separate. Ellipsized paths and labels throughout the UI gained hover
168
+ titles so the full text is always reachable.
169
+
170
+ ## [0.6.0] - 2026-07-21
171
+
172
+ ### Added
173
+
174
+ - **Web UI (read-only viewer).** `diffstalkerd` now serves a Vue 3 browser client
175
+ at `GET /` (run it with `--port N`, open `http://localhost:N`). It is a viewer,
176
+ not a manager — it reads git state and never mutates it. Four views mirroring the
177
+ terminal UI: Changes (file list + working-tree diffs, per-hunk view), History
178
+ (commit list + diff), a GitHub-PR-style Compare view against a base branch, and
179
+ an Explorer with syntax highlighting. Plus a fuzzy file finder, the six themes,
180
+ and live updates over SSE. The web build ships inside the `diffstalkerd` tarball
181
+ — it is not a separately published package. No authentication; the daemon binds
182
+ `127.0.0.1` — keep it on localhost.
183
+ - **Follow + auto mode in the web UI.** A follow toggle switches the viewed repo
184
+ when an external tool appends to the follow hook file. Auto mode additionally
185
+ selects the freshest-changed file (and flashes it) and switches views as the
186
+ changed-file set grows or empties — driven by a new per-file mtime signal the
187
+ daemon now includes in shared state (browsers can't `fs.stat`, and it also
188
+ defeats SSE payload dedup so in-place edits still fire an update).
189
+ - **Portrait / vertical-monitor layout.** On portrait or square viewports the
190
+ view rail rotates into a full-width top tab band and each view stacks its list
191
+ above a full-width diff, with drag-resizable rows. Landscape is byte-for-byte
192
+ unchanged.
193
+ - **Collapsible folders** in the web Compare and Explorer file trees, with
194
+ single-child directory chains folded onto one row for compactness.
195
+ - A favicon (the diff-gutter add/remove mark) for the web UI.
196
+
197
+ ### Internal
198
+
199
+ - **Single-source versioning.** The root `package.json` is now the one source of
200
+ version truth. `scripts/release.sh` reads and bumps it, and derives the two
201
+ published manifests (`diffstalker`, `diffstalkerd`) from it in lockstep. The
202
+ private, bundled packages (`@diffstalker/core`, `@diffstalker/client`,
203
+ `@diffstalker/web`) are pinned to a static `0.0.0` and never versioned — they
204
+ ship inside the published bundles, never on their own. The release's bun.lock
205
+ patch is now equality-scoped to the outgoing version and asserts the published
206
+ entries landed on the new one, so it can't silently ship a stale pin.
207
+ - A shared `@diffstalker/core/view/*` presentation-logic layer (diff/word/tree/
208
+ format helpers) extracted from the CLI and reused by the web client.
209
+
210
+ ## [0.5.1] - 2026-07-20
211
+
212
+ ### Fixed
213
+
214
+ - The published `diffstalker` now pins the exact matching `diffstalkerd`
215
+ version. `release.sh` refreshes `bun.lock`'s workspace versions on bump
216
+ (`bun pm pack` derives the cli's `diffstalkerd` pin from the lockfile, not
217
+ the manifest), and CI now fails the release if any published package's
218
+ workspace-sibling pin is not the exact release version. 0.5.0 shipped
219
+ pinning `diffstalkerd@0.4.0` — functional (same daemon build) but wrong.
220
+
221
+ ## [0.5.0] - 2026-07-20
222
+
223
+ ### Changed
224
+
225
+ - **Daemon architecture.** The single npm package was split into a bun
226
+ monorepo of four packages: `@diffstalker/core` (headless git state),
227
+ `@diffstalker/daemon` (`diffstalkerd`: a Node http REST + SSE server over
228
+ core), `@diffstalker/client` (a typed REST + SSE client), and `diffstalker`
229
+ (the terminal UI). Same features, new plumbing.
230
+ - **The CLI is now a daemon-backed client.** It holds no in-process git: on
231
+ launch it attaches to a running `diffstalkerd` or spawns one on a unix
232
+ socket, opens repos over REST, and follows live state over SSE. A new
233
+ `RepoSession` is the client-side store (shared state over SSE + mutation
234
+ envelopes; selection/history/compare pulled on demand).
235
+ - **The daemon owns git state and follow mode.** It watches the follow hook
236
+ file and broadcasts `follow-change` so any client can switch focus; the CLI
237
+ reacts to it as policy. The in-process command server and follow-file
238
+ watcher were removed from the CLI.
239
+ - Opening or following a bare-repo container no longer forces a worktree
240
+ choice through the picker; the most recently active worktree (by git
241
+ index/HEAD activity) is opened automatically. Shift+W still switches
242
+ worktrees explicitly.
243
+ - **A leaner `diffstalker`.** The published UI no longer depends on a git
244
+ library: the pure diff/patch parsers it needs (hunk extraction, status
245
+ maps) were split into dependency-free core modules, so `simple-git` is now
246
+ a `diffstalkerd`-only dependency. The two published packages are the lean
247
+ `diffstalker` (which pulls in `diffstalkerd`) and `diffstalkerd` itself.
248
+
249
+ ### Added
250
+
251
+ - **`diffstalkerd` binary** (`@diffstalker/daemon`): REST + SSE over
252
+ `@diffstalker/core`, unix-socket by default (`0600` under
253
+ `$XDG_RUNTIME_DIR`), with follow mode and systemd socket activation. See
254
+ `packages/daemon/README.md`.
255
+ - **Graceful daemon reconnect.** When the SSE stream drops, the CLI shows one
256
+ calm "daemon connection lost — reconnecting…" line and recovers in the
257
+ background — re-spawning the daemon if needed and re-opening repos by their
258
+ stable path-hashed id (no ENOENT screen spam).
259
+ - `scripts/rmrf.sh` helper for safe recursive deletes.
260
+
261
+ ### Removed
262
+
263
+ - The `--once` flag (show status once and exit). The UI is always a live,
264
+ daemon-backed view now.
265
+ - The in-process command server and follow-file watcher, which moved into
266
+ `diffstalkerd`.
267
+
268
+ ## [0.4.0] - 2026-07-07
269
+
270
+ ### Fixed
271
+
272
+ - **npm package was uninstallable**: the postinstall hook pointed at a script
273
+ excluded from the published tarball, so every `npm install diffstalker`
274
+ failed. The neo-blessed 24-bit RGB patch is now applied at runtime, with no
275
+ postinstall step.
276
+ - Commit submission: pressing Enter in the commit input never actually
277
+ submitted (it appended an invisible newline); the commit is now submitted
278
+ with Ctrl+S.
279
+ - Transient git failures (e.g. index.lock contention) no longer wipe the file
280
+ list by masquerading as "not a git repository".
281
+ - Watcher and IPC socket errors no longer crash the app; errors surface in
282
+ the header instead of disappearing.
283
+ - Crash diagnostics are printed to the normal screen buffer instead of being
284
+ discarded with the alternate one.
285
+ - Untracked file names containing shell metacharacters no longer break the
286
+ diff preview.
287
+
288
+ ### Added
289
+
290
+ - Per-hunk edit times in the diff viewer ("just now", "5 minutes ago",
291
+ "2 days ago"), observed live while diffstalker runs, with file mtime as
292
+ the fallback for pre-session changes. Freshly-changed hunks flash yellow,
293
+ and in auto mode the diff pane scrolls to keep the newest change on
294
+ screen. Sub-minute times update every second.
295
+ - Multi-line commit messages: the commit input is now 4 rows; Enter inserts
296
+ a newline, Ctrl+S commits.
297
+ - Page scrolling (PageUp/PageDown, Ctrl+U/Ctrl+D) and jump to top/bottom
298
+ (g/G) in lists and diff panes.
299
+ - `d` on an untracked file now offers to delete it (git clean) with
300
+ confirmation.
301
+ - Tests for the hunk staging pipeline and WorkingTreeManager.
302
+
303
+ ### Changed
304
+
305
+ - Published package ships via a files allowlist; requires node >= 20.
306
+ - Releases publish to npm before pushing the metrics commit, and refuse to
307
+ run without a changelog entry.
308
+
309
+ ## [0.3.0] - 2026-07-06
310
+
311
+ ### Added
312
+
313
+ - Git worktree and bare-repo layout support, with a worktree switcher
314
+ - Mouse support in the repo picker
315
+ - "Include uncommitted" checkbox rendered in the Compare view
316
+ - Auto-scroll to the latest changed file in auto mode
317
+
318
+ ### Fixed
319
+
320
+ - Follow mode not switching into a nested repository
321
+
322
+ ## [0.2.6] - 2026-03-08
323
+
324
+ ### Fixed
325
+
326
+ - Error spam when opening a non-git directory
327
+
328
+ ## [0.2.5] - 2026-03-06
329
+
330
+ ### Added
331
+
332
+ - Show application version in hotkeys modal footer
333
+
334
+ ## [0.2.4] - 2026-03-08
335
+
336
+ ### Added
337
+
338
+ - Repo picker modal (`r`) for switching between recent repositories
339
+ - Focus zone system for Tab/Shift-Tab navigation
340
+
341
+ ### Changed
342
+
343
+ - Commit tab stripped to the essentials: message input, amend, submit
344
+ - Modal state centralized in ModalController
345
+
346
+ ### Fixed
347
+
348
+ - `q` closing the app while a modal was open
349
+ - Hotkeys modal `?` toggle race condition
350
+ - History selection not updating after refresh
351
+
352
+ ## [0.2.3] - 2026-02-06
353
+
354
+ ### Added
355
+
356
+ - Repository control center on the commit tab
357
+ - Release script and documented release workflow
358
+
359
+ ### Changed
360
+
361
+ - File finder rebuilt on `git ls-files` with fzf matching
362
+
363
+ ## [0.2.2] - 2026-02-01
364
+
365
+ ### Added
366
+
367
+ - Hunk-level staging with toggle key, click selection, and per-file indicators
368
+ - Flat file view with combined interleaved diff
369
+ - fzf-powered file finder (Ctrl+P)
370
+ - Unit and integration tests for git and utility modules
371
+ - dependency-cruiser architecture layering rules
372
+ - Pre-push hook running tests before tag pushes
373
+
374
+ ### Fixed
375
+
376
+ - Phantom context line on the last hunk of a diff
377
+ - Selection desync on full-hunk staging
378
+ - Explorer mouse and keyboard bugs
379
+
380
+ ## [0.2.1] - 2026-01-30
381
+
382
+ ### Added
383
+
384
+ - Explorer tree view with git status, file finder, and selection anchor
385
+ - Code quality metrics tooling
386
+
387
+ ### Changed
388
+
389
+ - App.ts decomposed into KeyBindings, MouseHandlers, PaneRenderers, and FollowMode modules
390
+
391
+ ### Fixed
392
+
393
+ - Watcher cleanup and state refresh when switching repositories
394
+
395
+ ## [0.2.0] - 2026-01-27
396
+
397
+ ### Changed
398
+
399
+ - **Major rewrite**: Migrated from Ink (React for CLIs) to neo-blessed for native terminal rendering
400
+ - Significantly improved scroll performance - no more lag on large diffs
401
+ - More responsive UI with direct terminal control
402
+ - Reduced memory footprint
403
+ - Gitignore-aware file watching - no longer watches inside node_modules, dist, etc.
404
+
405
+ ### Added
406
+
407
+ - Base branch picker modal (`b` in Compare view) for selecting PR comparison base
408
+ - Discard confirmation dialog (`d` on unstaged files) with y/n prompt
409
+ - Toggle uncommitted changes in Compare view (`u`)
410
+ - External git operation detection - UI updates when staging/committing outside the app
411
+ - Explorer view (tab 5) for browsing repository files with syntax highlighting
412
+ - tmux-test.sh script for headless UI testing
413
+
414
+ ### Fixed
415
+
416
+ - Window resize now properly updates all UI elements
417
+ - Diff content no longer contains control characters
418
+ - Improved diff line alignment and file separation
419
+ - Modal key isolation - navigation keys no longer affect background list when modal is open
420
+ - Auto-scroll keeps selection visible when navigating in all list views
421
+ - Commit textarea focus no longer crashes the app
422
+ - Terminal cleanup on startup clears leftover mouse mode from previous crashes
423
+
424
+ ### Technical
425
+
426
+ - Replaced React hooks with event-driven state management
427
+ - Single source of truth pattern for scroll calculations
428
+ - Operation queue for serialized git operations
429
+ - Polling-based git watcher for reliable atomic write detection
430
+
431
+ ## [0.1.0] - 2026-01-21
432
+
433
+ ### Added
434
+
435
+ - Initial release
436
+ - Four views: Diff, Commit, History, and PR comparison
437
+ - Two-pane layout with resizable split
438
+ - Mouse support: click to select, stage/unstage, scroll, switch tabs
439
+ - Word-level diff highlighting
440
+ - 6 color themes including colorblind-friendly and ANSI-only variants
441
+ - Follow mode for shell integration
442
+ - Keyboard navigation with vim-style bindings
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 diffstalker contributors
3
+ Copyright (c) 2026 yogh-io
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -31,8 +31,7 @@ Options:
31
31
  ```
32
32
  --socket PATH Bind a unix socket at PATH
33
33
  (default: $XDG_RUNTIME_DIR/diffstalker/diffstalkerd.sock)
34
- --port N Bind TCP port N instead of a unix socket
35
- --host H Host to bind with --port (default: 127.0.0.1)
34
+ --port N Bind TCP port N (loopback only) instead of a unix socket
36
35
  --follow-file PATH Hook file to follow (created when missing)
37
36
  (default: ~/.cache/diffstalker/target)
38
37
  --no-follow Disable follow mode (no hook-file watcher)
@@ -60,8 +59,26 @@ deliberately no `/tmp` fallback. Pass `--socket PATH` explicitly instead.
60
59
  If a live daemon already answers on the socket path, startup fails; a stale
61
60
  socket file (nothing listening) is removed and reused.
62
61
 
63
- There is no authentication yet. Keep the daemon on a unix socket or
64
- localhost; a bearer-token check is planned before it may bind further.
62
+ The daemon has no authentication, so it binds **loopback only** — a unix
63
+ socket, or `--port` on `127.0.0.1`. There is no option to bind a routable
64
+ interface (bearer-token auth would be a prerequisite for that, and is not
65
+ implemented). On a port an
66
+ origin guard runs: a `Host` allow-list rejects rebound hostnames
67
+ (DNS-rebinding defense, 421), and state-changing requests with a cross-site
68
+ `Sec-Fetch-Site` or a non-loopback `Origin` are rejected (CSRF defense,
69
+ 403). Non-browser clients (the CLI, `curl`) send neither header and a
70
+ loopback `Host`, so they pass. Every response also carries hardening
71
+ headers (`X-Content-Type-Options`, `X-Frame-Options: DENY`,
72
+ `Referrer-Policy`, and a strict `Content-Security-Policy` for the served
73
+ SPA). To reach the daemon from another machine, forward the port over SSH
74
+ (`ssh -L`). See `SECURITY.md` at the repo root.
75
+
76
+ A `--port` daemon also exposes a **reduced API** (least privilege): only the
77
+ endpoints the web UI uses — reads, `POST`/`DELETE /repos`, and
78
+ `POST /repos/:id/stage`/`unstage`. The CLI-only mutations (commit, discard,
79
+ hunk staging, `PUT /compare/base`, and every remote/branch operation) are
80
+ not routed on a port; they exist only over the unix socket. Requesting one
81
+ on a port returns `404 Unknown route`.
65
82
 
66
83
  ## Environment
67
84
 
@@ -102,7 +119,8 @@ values are rejected with a 400 so they can never be parsed as git flags.
102
119
  | GET | `/repos` | List open repos (`id`, `path`, `branch`) |
103
120
  | POST | `/repos` | Open a repo: `{"path": "/abs/path"}` → `{id, path}` (201 created, 200 already open) |
104
121
  | DELETE | `/repos/:id` | Close a repo (refcounted per open) |
105
- | GET | `/repos/:id/worktrees` | Registered worktrees (`path`, `branch`, `head`, `isBare`): main worktree, linked worktrees, and the bare entry in a bare-worktree layout |
122
+ | GET | `/repos/:id/worktrees` | Registered worktrees (`path`, `branch`, `head`, `isBare`, `lastActivity`, `aheadOfBase`): main worktree, linked worktrees, and the bare entry in a bare-worktree layout |
123
+ | GET | `/worktrees?path=` | Same as above, but for a raw filesystem path instead of an already-opened repo id (e.g. a recently-visited repo a client hasn't opened on this daemon) |
106
124
  | GET | `/repos/:id/status` | Shared state: status, hunk counts, stash list, in-progress operation, error, working-file mtimes (path → mtimeMs; what browser clients build mtime-based auto mode on) |
107
125
  | GET | `/repos/:id/diff?path=&staged=` | Diff; whole tree without `path`, staged side with `staged=true` |
108
126
  | GET | `/repos/:id/history?count=` | Commit history (`CommitInfo[]`, default 100, ISO dates) |