@xbghc/warden 0.1.0 → 0.2.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 +73 -15
- package/dist/cli.js +640 -123
- package/dist/web/assets/{index-BWrmu1DB.css → index-DKfCCm8U.css} +1 -1
- package/dist/web/assets/index-stdccAW_.js +192 -0
- package/dist/web/index.html +2 -2
- package/package.json +3 -3
- 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,53 @@ 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 *自动刷新* checkbox; `r` still refreshes by hand.
|
|
138
|
+
|
|
139
|
+
## Todos
|
|
104
140
|
|
|
105
|
-
|
|
106
|
-
|
|
141
|
+
Notes attached to a branch rather than to a line of code, for the things you notice while reviewing
|
|
142
|
+
that do not belong in a comment. They are not deleted when you commit. The Todos drawer filters by
|
|
143
|
+
status, defaults to the current branch and can show all branches; *复制 Todo* copies the open ones
|
|
144
|
+
(optionally including the done ones, marked ` (done)`) as:
|
|
145
|
+
|
|
146
|
+
```markdown
|
|
147
|
+
# TODO
|
|
148
|
+
Branch: feature/x
|
|
149
|
+
Repo: /home/user/project
|
|
150
|
+
Count: 2
|
|
151
|
+
|
|
152
|
+
## 1. 补充 OrderList 的空状态
|
|
153
|
+
描述正文(Markdown)…
|
|
154
|
+
|
|
155
|
+
## 2. useOrder 的依赖数组缺少 id
|
|
156
|
+
```
|
|
107
157
|
|
|
108
158
|
## nvim integration
|
|
109
159
|
|
|
@@ -128,6 +178,12 @@ jump to the nearest new-side line; for commit targets the working-tree file is o
|
|
|
128
178
|
`schemaVersion`, written atomically (temp file + rename) under a small lock file so multiple instances
|
|
129
179
|
can share it. Delete the directory to reset.
|
|
130
180
|
|
|
181
|
+
`targets` is keyed by target key, plus one *comment scope* per worktree — `local`, or
|
|
182
|
+
`worktree:<path>:local` — holding the comments the three local views share and the HEAD sha the last
|
|
183
|
+
re-anchor saw. `viewed` stays on the individual view keys. Issues and todos are top level. State
|
|
184
|
+
written by an older version is migrated on load: comments filed under `working` / `staged` / `all`
|
|
185
|
+
move into the matching scope the first time the file is read.
|
|
186
|
+
|
|
131
187
|
## WSL2 notes
|
|
132
188
|
|
|
133
189
|
- Access the UI from the Windows browser at the printed `http://127.0.0.1:<port>/` URL; WSL2 forwards
|
|
@@ -150,7 +206,7 @@ repository. Requests that would need anything else get HTTP 400.
|
|
|
150
206
|
```sh
|
|
151
207
|
pnpm install
|
|
152
208
|
pnpm dev # API server on :4100 (tsx watch) + Vite dev server on :5173 with /api proxied
|
|
153
|
-
pnpm test # vitest: diff parser, anchoring,
|
|
209
|
+
pnpm test # vitest: diff parser, anchoring, comment scopes, watcher, todos, export, state, HTTP API
|
|
154
210
|
pnpm typecheck
|
|
155
211
|
pnpm build # dist/web (Vite) + dist/cli.js (tsup, zero runtime dependencies)
|
|
156
212
|
node dist/cli.js path/to/repo
|
|
@@ -160,8 +216,8 @@ Layout:
|
|
|
160
216
|
|
|
161
217
|
```
|
|
162
218
|
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
|
|
219
|
+
packages/shared types + target key / comment scope helpers (bundled into both sides)
|
|
220
|
+
packages/server Hono API, git wrapper, diff parser, targets, anchoring, watcher, state, export, nvim
|
|
165
221
|
packages/web React + Vite UI (shiki highlighting, @tanstack/react-virtual, react-markdown)
|
|
166
222
|
test/ API integration tests on a generated git repository
|
|
167
223
|
```
|
|
@@ -169,10 +225,12 @@ test/ API integration tests on a generated git repository
|
|
|
169
225
|
Only `dist/`, `README.md`, `LICENSE` and `package.json` are published.
|
|
170
226
|
|
|
171
227
|
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
|
-
|
|
228
|
+
`git tag v0.2.0 && git push origin v0.2.0`. The `Publish to npm` workflow checks the tag against the
|
|
229
|
+
version, runs build + tests through `prepublishOnly`, and publishes over OIDC trusted publishing —
|
|
230
|
+
no `NPM_TOKEN` secret, and provenance is attested automatically. It relies on a trusted publisher
|
|
231
|
+
configured on the package's npmjs.com settings page (user `xbghc`, repo `warden`, workflow
|
|
232
|
+
`publish.yml`). CI runs typecheck, tests, build and a `publish --dry-run` on every push to `main` and
|
|
233
|
+
every pull request.
|
|
176
234
|
|
|
177
235
|
## License
|
|
178
236
|
|