@xbghc/warden 0.1.0 → 0.3.0
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/README.md +75 -15
- package/dist/cli.js +713 -133
- package/dist/web/assets/index-CUBjyx71.js +192 -0
- package/dist/web/assets/index-D8iWq0bG.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-BWrmu1DB.css +0 -1
- package/dist/web/assets/index-CZQadJRz.js +0 -192
package/README.md
CHANGED
|
@@ -5,12 +5,15 @@ with line comments you can copy back to the agent as a prompt.
|
|
|
5
5
|
|
|
6
6
|
- Runs as a single local process per repository (`127.0.0.1` only, no auth, no database).
|
|
7
7
|
- Diff sources: working tree, staged, working tree vs HEAD, any commit, any two refs, and git worktrees.
|
|
8
|
+
- Side-by-side **Unstaged** and **Staged** file lists, so staging a hunk in your editor is what marks it reviewed.
|
|
8
9
|
- GitHub-style unified / side-by-side diff with syntax highlighting, collapsed file tree, lazy per-file loading, context expansion, virtual scrolling.
|
|
9
10
|
- Line comments (single line or a dragged range), Markdown, edit / delete.
|
|
10
11
|
- One click copies all comments as an agent-readable prompt to the clipboard.
|
|
11
|
-
- Review state (viewed files, comments, local issues, preferences) persists outside the repo and survives restarts.
|
|
12
|
-
- Comments
|
|
12
|
+
- Review state (viewed files, comments, local issues, todos, preferences) persists outside the repo and survives restarts.
|
|
13
|
+
- Comments follow the code: they move with a hunk that gets staged, re-attach after the agent edits the file, and are cleaned up once the change is committed.
|
|
14
|
+
- Auto-refresh — warden watches the repository and reloads itself when you edit, stage, commit or switch branches.
|
|
13
15
|
- Local issues (title, Markdown body, open/closed) that link comments.
|
|
16
|
+
- Branch-scoped todos, exportable as a numbered checklist.
|
|
14
17
|
- Commit history browser.
|
|
15
18
|
- Click a line number to jump to that line in a running nvim instance (WSL2 friendly).
|
|
16
19
|
- Read-only with respect to git: only whitelisted read sub-commands are ever executed.
|
|
@@ -50,12 +53,18 @@ Several instances on the same repository can run at the same time.
|
|
|
50
53
|
Refs accept anything git can resolve (`main`, `v1.2`, `HEAD~3`, a sha). `@` is `HEAD`.
|
|
51
54
|
Worktrees are discovered with `git worktree list` and share the review state of the main repository.
|
|
52
55
|
|
|
56
|
+
`working`, `staged` and `all` are the three **local views** of one worktree. While any of them is
|
|
57
|
+
selected the sidebar shows two blocks — Unstaged (`working`) and Staged (`staged`) — instead of a
|
|
58
|
+
single tree, and clicking a file switches to the view it belongs to. A file that is only partly
|
|
59
|
+
staged appears in both. Switching between the three keeps your comments, the draft you are typing
|
|
60
|
+
and the current selection; only the diff is reloaded. Commit and range targets keep the single tree.
|
|
61
|
+
|
|
53
62
|
## Keyboard
|
|
54
63
|
|
|
55
64
|
| Key | Action |
|
|
56
65
|
|---|---|
|
|
57
66
|
| `r` | Refresh the current target (file list + open diff, then re-anchor comments) |
|
|
58
|
-
| `j` / `k` | Next / previous file |
|
|
67
|
+
| `j` / `k` | Next / previous file, walking Unstaged then Staged and switching view at the boundary |
|
|
59
68
|
| `n` / `p` | Next / previous hunk |
|
|
60
69
|
| `Ctrl+Enter` | Save the comment being edited |
|
|
61
70
|
| `Esc` | Cancel editing / close a panel / cancel re-attach mode |
|
|
@@ -98,12 +107,54 @@ Issues can be copied in the same format (with the issue title, status and body o
|
|
|
98
107
|
|
|
99
108
|
Every comment stores a hash of its hunk, of each covered line and of three context lines above and
|
|
100
109
|
below. On refresh the comment is re-attached in this order: same hunk still present → same relative
|
|
101
|
-
position; otherwise search the file for the same line sequence (context lines disambiguate duplicates)
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
position; otherwise search the file for the same line sequence (context lines disambiguate duplicates).
|
|
111
|
+
|
|
112
|
+
The three local views of a worktree share one pool of comments, and re-anchoring searches all of
|
|
113
|
+
them — the comment's current view first, then `working`, `staged`, `all`. So:
|
|
114
|
+
|
|
115
|
+
- Comment on an unstaged hunk, then `git add` it → the comment turns up in the Staged view,
|
|
116
|
+
unchanged. The card shows which view it moved to; clicking it jumps there.
|
|
117
|
+
- The agent edits the commented line → nothing matches, and the comment becomes *orphaned*: listed
|
|
118
|
+
at the top of the rail with its original snippet, ready to be deleted or re-attached to a new selection.
|
|
119
|
+
- `git commit` → re-anchoring notices HEAD moved. Comments that no longer have a home anywhere are
|
|
120
|
+
**deleted** (and unlinked from any issue), because the code they were about is now history.
|
|
121
|
+
Anything still visible in Unstaged or Staged survives, including as a context line.
|
|
122
|
+
|
|
123
|
+
Comment markers in the diff belong to one view; the rail's *全部* tab lists the whole pool and
|
|
124
|
+
*此文件* lists every comment on the open file regardless of which view it currently sits in.
|
|
125
|
+
|
|
126
|
+
"Viewed" is per view, so a half-staged file can be marked read on one side and not the other. It is
|
|
127
|
+
bound to a hash of the file's diff; when the diff changes the flag is dropped and the file is marked
|
|
128
|
+
*已变化*.
|
|
129
|
+
|
|
130
|
+
## Auto-refresh
|
|
131
|
+
|
|
132
|
+
warden polls the worktree every 1.5 s while the page is open (`git status --porcelain`, HEAD, the
|
|
133
|
+
branch name, plus mtime and size of the paths status reports — enough to notice a second edit to an
|
|
134
|
+
already-modified file) and pushes a change event over `GET /api/events` (SSE). The page then re-runs
|
|
135
|
+
the normal refresh: re-anchor, reload both file lists, reload the open diff. Your draft comment,
|
|
136
|
+
selection, current view and current file are left alone, and the diff is scrolled back to where you
|
|
137
|
+
were reading. Turn it off with the *自动* toggle next to the refresh button; `r` still
|
|
138
|
+
refreshes by hand.
|
|
139
|
+
|
|
140
|
+
## Todos
|
|
141
|
+
|
|
142
|
+
Notes attached to a branch rather than to a line of code, for the things you notice while reviewing
|
|
143
|
+
that do not belong in a comment. They are not deleted when you commit. The Todos drawer filters by
|
|
144
|
+
status, defaults to the current branch and can show all branches; *复制 Todo* copies the open ones
|
|
145
|
+
(optionally including the done ones, marked ` (done)`) as:
|
|
146
|
+
|
|
147
|
+
```markdown
|
|
148
|
+
# TODO
|
|
149
|
+
Branch: feature/x
|
|
150
|
+
Repo: /home/user/project
|
|
151
|
+
Count: 2
|
|
104
152
|
|
|
105
|
-
|
|
106
|
-
|
|
153
|
+
## 1. 补充 OrderList 的空状态
|
|
154
|
+
描述正文(Markdown)…
|
|
155
|
+
|
|
156
|
+
## 2. useOrder 的依赖数组缺少 id
|
|
157
|
+
```
|
|
107
158
|
|
|
108
159
|
## nvim integration
|
|
109
160
|
|
|
@@ -128,6 +179,12 @@ jump to the nearest new-side line; for commit targets the working-tree file is o
|
|
|
128
179
|
`schemaVersion`, written atomically (temp file + rename) under a small lock file so multiple instances
|
|
129
180
|
can share it. Delete the directory to reset.
|
|
130
181
|
|
|
182
|
+
`targets` is keyed by target key, plus one *comment scope* per worktree — `local`, or
|
|
183
|
+
`worktree:<path>:local` — holding the comments the three local views share and the HEAD sha the last
|
|
184
|
+
re-anchor saw. `viewed` stays on the individual view keys. Issues and todos are top level. State
|
|
185
|
+
written by an older version is migrated on load: comments filed under `working` / `staged` / `all`
|
|
186
|
+
move into the matching scope the first time the file is read.
|
|
187
|
+
|
|
131
188
|
## WSL2 notes
|
|
132
189
|
|
|
133
190
|
- Access the UI from the Windows browser at the printed `http://127.0.0.1:<port>/` URL; WSL2 forwards
|
|
@@ -150,7 +207,7 @@ repository. Requests that would need anything else get HTTP 400.
|
|
|
150
207
|
```sh
|
|
151
208
|
pnpm install
|
|
152
209
|
pnpm dev # API server on :4100 (tsx watch) + Vite dev server on :5173 with /api proxied
|
|
153
|
-
pnpm test # vitest: diff parser, anchoring,
|
|
210
|
+
pnpm test # vitest: diff parser, anchoring, comment scopes, watcher, todos, export, state, HTTP API
|
|
154
211
|
pnpm typecheck
|
|
155
212
|
pnpm build # dist/web (Vite) + dist/cli.js (tsup, zero runtime dependencies)
|
|
156
213
|
node dist/cli.js path/to/repo
|
|
@@ -160,8 +217,8 @@ Layout:
|
|
|
160
217
|
|
|
161
218
|
```
|
|
162
219
|
bin/cli.ts argument parsing, start server, open browser
|
|
163
|
-
packages/shared types + target key helpers (bundled into both sides)
|
|
164
|
-
packages/server Hono API, git wrapper, diff parser, targets, anchoring, state, export, nvim
|
|
220
|
+
packages/shared types + target key / comment scope helpers (bundled into both sides)
|
|
221
|
+
packages/server Hono API, git wrapper, diff parser, targets, anchoring, watcher, state, export, nvim
|
|
165
222
|
packages/web React + Vite UI (shiki highlighting, @tanstack/react-virtual, react-markdown)
|
|
166
223
|
test/ API integration tests on a generated git repository
|
|
167
224
|
```
|
|
@@ -169,10 +226,13 @@ test/ API integration tests on a generated git repository
|
|
|
169
226
|
Only `dist/`, `README.md`, `LICENSE` and `package.json` are published.
|
|
170
227
|
|
|
171
228
|
Releasing: bump `version` in `package.json`, commit, then push a matching tag —
|
|
172
|
-
`git tag v0.
|
|
173
|
-
runs build + tests through `prepublishOnly`, and publishes
|
|
174
|
-
|
|
175
|
-
`
|
|
229
|
+
`git tag v0.2.0 && git push origin v0.2.0`. The `Publish to npm` workflow checks the tag against the
|
|
230
|
+
version, runs build + tests through `prepublishOnly`, and publishes over OIDC trusted publishing — no
|
|
231
|
+
`NPM_TOKEN` secret to store or rotate. It relies on a trusted publisher configured on the package's
|
|
232
|
+
npmjs.com settings page (user `xbghc`, repo `warden`, workflow `publish.yml`), and passes
|
|
233
|
+
`--provenance` explicitly, because npm's automatic attestation does not fire through `pnpm publish`
|
|
234
|
+
(0.2.0 shipped without one). CI runs typecheck, tests, build and a `publish --dry-run` on every push
|
|
235
|
+
to `main` and every pull request.
|
|
176
236
|
|
|
177
237
|
## License
|
|
178
238
|
|