@vibe-commit/capture 0.6.1 → 0.7.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 +80 -5
- package/dist/agent_hooks.d.ts +8 -0
- package/dist/agent_hooks.js +31 -1
- package/dist/agent_hooks.js.map +1 -1
- package/dist/agents/claude_code.d.ts +34 -0
- package/dist/agents/claude_code.js +141 -8
- package/dist/agents/claude_code.js.map +1 -1
- package/dist/agents/codex_cli.d.ts +13 -0
- package/dist/agents/codex_cli.js +241 -2
- package/dist/agents/codex_cli.js.map +1 -1
- package/dist/agents/cursor.d.ts +34 -0
- package/dist/agents/cursor.js +115 -1
- package/dist/agents/cursor.js.map +1 -1
- package/dist/agents/session_listing.d.ts +29 -0
- package/dist/agents/session_listing.js +49 -0
- package/dist/agents/session_listing.js.map +1 -0
- package/dist/agents/types.d.ts +118 -8
- package/dist/agents/types.js +17 -3
- package/dist/agents/types.js.map +1 -1
- package/dist/commands/approval_pending.d.ts +9 -0
- package/dist/commands/approval_pending.js +23 -0
- package/dist/commands/approval_pending.js.map +1 -0
- package/dist/commands/auth.js +31 -11
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/backfill.d.ts +160 -0
- package/dist/commands/backfill.js +748 -0
- package/dist/commands/backfill.js.map +1 -0
- package/dist/commands/browser_credential.d.ts +2 -0
- package/dist/commands/browser_credential.js +31 -14
- package/dist/commands/browser_credential.js.map +1 -1
- package/dist/commands/connect.d.ts +137 -0
- package/dist/commands/connect.js +203 -109
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/connect_picker.d.ts +27 -0
- package/dist/commands/connect_picker.js +415 -0
- package/dist/commands/connect_picker.js.map +1 -0
- package/dist/commands/context.d.ts +16 -0
- package/dist/commands/context.js +27 -0
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/credential_problem.d.ts +15 -4
- package/dist/commands/credential_problem.js +29 -22
- package/dist/commands/credential_problem.js.map +1 -1
- package/dist/commands/device_credential.d.ts +2 -0
- package/dist/commands/device_credential.js +16 -14
- package/dist/commands/device_credential.js.map +1 -1
- package/dist/commands/finalize.d.ts +95 -0
- package/dist/commands/finalize.js +249 -74
- package/dist/commands/finalize.js.map +1 -1
- package/dist/commands/finish_mint.d.ts +2 -6
- package/dist/commands/finish_mint.js +10 -2
- package/dist/commands/finish_mint.js.map +1 -1
- package/dist/commands/report.js +38 -30
- package/dist/commands/report.js.map +1 -1
- package/dist/commands/scan.d.ts +162 -0
- package/dist/commands/scan.js +507 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/status.js +119 -22
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/status_hooks.d.ts +14 -0
- package/dist/commands/status_hooks.js +81 -0
- package/dist/commands/status_hooks.js.map +1 -0
- package/dist/commands/status_machine.d.ts +18 -0
- package/dist/commands/status_machine.js +149 -0
- package/dist/commands/status_machine.js.map +1 -0
- package/dist/commands/why.js +44 -31
- package/dist/commands/why.js.map +1 -1
- package/dist/consent.d.ts +111 -0
- package/dist/consent.js +203 -1
- package/dist/consent.js.map +1 -1
- package/dist/copy/error_codes.d.ts +222 -0
- package/dist/copy/error_codes.js +105 -0
- package/dist/copy/error_codes.js.map +1 -0
- package/dist/copy/index.d.ts +2 -2
- package/dist/copy/index.js +2 -2
- package/dist/copy/index.js.map +1 -1
- package/dist/copy/strings.d.ts +497 -29
- package/dist/copy/strings.js +601 -35
- package/dist/copy/strings.js.map +1 -1
- package/dist/copy/time.d.ts +11 -0
- package/dist/copy/time.js +18 -0
- package/dist/copy/time.js.map +1 -1
- package/dist/credential.d.ts +5 -1
- package/dist/credential.js +2 -2
- package/dist/credential.js.map +1 -1
- package/dist/git.d.ts +43 -0
- package/dist/git.js +95 -0
- package/dist/git.js.map +1 -1
- package/dist/hooks/entry.d.ts +18 -1
- package/dist/hooks/entry.js +110 -13
- package/dist/hooks/entry.js.map +1 -1
- package/dist/hooks/post_commit.js +3 -3
- package/dist/hooks/post_commit.js.map +1 -1
- package/dist/hooks/post_rewrite.js +6 -4
- package/dist/hooks/post_rewrite.js.map +1 -1
- package/dist/hooks/session_start.d.ts +93 -0
- package/dist/hooks/session_start.js +199 -0
- package/dist/hooks/session_start.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +56 -8
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +57 -0
- package/dist/install.js +54 -20
- package/dist/install.js.map +1 -1
- package/dist/json.d.ts +32 -9
- package/dist/json.js +35 -8
- package/dist/json.js.map +1 -1
- package/dist/machine_state.d.ts +52 -0
- package/dist/machine_state.js +63 -0
- package/dist/machine_state.js.map +1 -0
- package/dist/oauth/session.d.ts +1 -0
- package/dist/org_pending.d.ts +52 -0
- package/dist/org_pending.js +109 -0
- package/dist/org_pending.js.map +1 -0
- package/dist/paths.d.ts +50 -0
- package/dist/paths.js +64 -0
- package/dist/paths.js.map +1 -1
- package/dist/picker.d.ts +180 -0
- package/dist/picker.js +477 -0
- package/dist/picker.js.map +1 -0
- package/dist/picker_checklist.d.ts +125 -0
- package/dist/picker_checklist.js +375 -0
- package/dist/picker_checklist.js.map +1 -0
- package/dist/policy.d.ts +54 -0
- package/dist/policy.js +47 -0
- package/dist/policy.js.map +1 -1
- package/dist/post.d.ts +50 -16
- package/dist/post.js +220 -16
- package/dist/post.js.map +1 -1
- package/dist/state.d.ts +6 -0
- package/dist/state.js +38 -1
- package/dist/state.js.map +1 -1
- package/dist/system_message.d.ts +8 -1
- package/dist/system_message.js +19 -1
- package/dist/system_message.js.map +1 -1
- package/dist/term.d.ts +28 -2
- package/dist/term.js +23 -2
- package/dist/term.js.map +1 -1
- package/dist/verb_help.d.ts +13 -0
- package/dist/verb_help.js +40 -0
- package/dist/verb_help.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -9
package/README.md
CHANGED
|
@@ -25,9 +25,11 @@ the approved direction points at `Vibe-Commit/claude-plugin`, which vendors the
|
|
|
25
25
|
|
|
26
26
|
| Command | What it does |
|
|
27
27
|
|---|---|
|
|
28
|
-
| `vibecommit connect` |
|
|
29
|
-
| `vibecommit auth` | Replace this machine's credential: sign in through the browser, or `--paste` one you made in Settings. Run it again whenever `status` or a hook says the credential is no longer accepted.
|
|
30
|
-
| `vibecommit
|
|
28
|
+
| `vibecommit connect` | Choose the repositories to capture, from any folder, and connect them: whole owners, including repos you clone later, or single repos. It shows what is uploaded and asks before it signs in, adds commit hooks to each clone, and offers to upload sessions still on this machine. A repo with no remote keeps the one-repo flow. `--typed` uses the typed prompt instead of the arrow-key list. On a machine with no credential it signs you in through the browser first. |
|
|
29
|
+
| `vibecommit auth` | Replace this machine's credential: sign in through the browser, or `--paste` one you made in Settings. Run it again whenever `status` or a hook says the credential is no longer accepted. On a terminal it then goes on to `connect`: inside a git repo, or outside one on a machine that captures nothing yet; with `--stdin` or no terminal it only saves the credential. |
|
|
30
|
+
| `vibecommit scan [--json]` | List the repositories you have used a coding agent in on this machine, from the agents' folder names and Codex's thread index. It opens no session file, uploads nothing and changes no setting. Exit `4` when none is found; `--json` prints one document, including what it could not list and why. |
|
|
31
|
+
| `vibecommit backfill` | Upload the earlier coding-agent sessions still on this machine, for the repositories you chose. It lists them first and asks (default no); a Claude Code session is sent only after reading one value from its transcript, the folder it started in, to check it belongs to that repository. Sessions arrive without commit links. Not offered: Cursor sessions (Cursor does not record that folder), sessions over 50 MiB, and sessions in a clone with no reflog. It asks again about each repository as it goes, so `vibecommit off` stops the rest of that repository. **Exit codes:** `0` done, declined at the question, or interrupted with Ctrl+C (sessions held for an organization's approval are done too), `1` stopped with the resume fix (the server asked to wait, could not be reached, or refused this machine's credential) or could not run, `2` no terminal, or an argument was given, `3` not connected, `4` nothing to upload. **Resuming:** a stopped or interrupted run loses nothing already sent; run it again and it offers only the sessions not yet uploaded. |
|
|
32
|
+
| `vibecommit status` | Show whether capture is on for this repo, or for this machine from outside a repo, and when it last succeeded. Inside a repo it also says why it is on (`basis`). |
|
|
31
33
|
| `vibecommit off` | Stop capturing for this repo. |
|
|
32
34
|
| `vibecommit why <file>:<line>` | Show the conversation turns recorded against the commit that last changed this line. |
|
|
33
35
|
| `vibecommit report --since <when>` | Summarise capture coverage over a time window. |
|
|
@@ -68,7 +70,10 @@ vibecommit finalize --session <session_id> # or --latest when only one sessio
|
|
|
68
70
|
Exit `0` — the server confirmed the last turn is recorded. Exit `5` — the data was delivered
|
|
69
71
|
but the server did not confirm it (a server older than this command): treat as **not** closed.
|
|
70
72
|
Exit `2` — nothing was sent (bad arguments, an unknown or still-running session, or several
|
|
71
|
-
recent sessions for `--latest`). Exit `3` — this repo is not connected
|
|
73
|
+
recent sessions for `--latest`). Exit `3` — this repo is not connected, this machine has no credential, or its
|
|
74
|
+
credential can't be used (it is not an ingest credential, its file is readable by other accounts, or it can't be read).
|
|
75
|
+
Exit `1` — it was not confirmed closed for any other reason: the folder is not a git repository, the transcript cannot
|
|
76
|
+
be found or read, the credential is no longer accepted, or the delivery failed. It is safe to run twice.
|
|
72
77
|
Resuming the session afterwards opens a new turn; nothing already recorded is changed.
|
|
73
78
|
|
|
74
79
|
`finalize` refuses a session whose transcript changed in the last few seconds. `--force` skips that check,
|
|
@@ -163,7 +168,7 @@ ask `connect`'s consent question; outside a repository, with `--stdin`, or with
|
|
|
163
168
|
credential, exactly as before, and a refused replacement (`declined`) still exits 1 without connecting. The chained
|
|
164
169
|
`connect` never opens a second sign-in. `vibecommit connect` in a repository where Claude Code has not run yet now
|
|
165
170
|
installs the git and agent hooks and exits 0 (it used to exit 1 and install neither); its "no Claude Code session"
|
|
166
|
-
warning is on stdout, and a `vibecommit` command on PATH that is not this one still exits 1. An
|
|
171
|
+
warning is on stdout, and a `vibecommit` command on PATH that is not this one still exits 1. An organization that
|
|
167
172
|
has not approved capture yet now gets its hooks installed too: the "capture is armed" screen was previously
|
|
168
173
|
printed without them. The ending reports hook setup first, then prints "Connected." and, when the server's reply
|
|
169
174
|
names the recorded session, a link to that session's page (`/app/conversations/<id>`), falling back to the
|
|
@@ -174,6 +179,76 @@ server's reply; the hooks never read a successful response body.
|
|
|
174
179
|
error's body at 64 KiB even when the server does not declare its length; it used to buffer the whole body before
|
|
175
180
|
checking. The hooks still never read a successful response body.
|
|
176
181
|
|
|
182
|
+
0.7.0 lets you connect from any folder, adds `scan` and `backfill`, puts a stable code on every error, and changes
|
|
183
|
+
the contracts below. The hooks still never read a successful response body.
|
|
184
|
+
|
|
185
|
+
*Connecting.* `vibecommit connect` no longer needs a git work tree. It lists the repositories you have used a coding
|
|
186
|
+
agent in (Claude Code, Codex CLI and Cursor) from the agents' folder names and Codex's thread index, without opening
|
|
187
|
+
a session file, and you choose whole owners, including repositories you clone later, or single repositories. The
|
|
188
|
+
disclosure's heading now says "coding-agent transcripts"; its paragraphs are unchanged. Your choices are saved in
|
|
189
|
+
`~/.vibecommit/grants.json`; consent given per clone by 0.6.x keeps working beside it, and a `grants.json` that cannot
|
|
190
|
+
be read stops capture for every repository with a remote until it is fixed. A 0.7.0 command that rewrites it keeps any
|
|
191
|
+
fields it doesn't recognize, so a newer client's state survives it. After "Capture is on", `connect` offers to
|
|
192
|
+
upload the earlier sessions still on this machine, a separate question that defaults to no. Inside a repository it
|
|
193
|
+
shows the same list with that repository ticked, and a repository with no remote keeps the 0.6.0 flow. A repository
|
|
194
|
+
with a remote and no Claude Code session yet ends on "Capture is on" and the dashboard, not 0.6.0's "no Claude Code
|
|
195
|
+
session" warning; the hooks are still installed and the exit is still 0. With no terminal, `connect` refuses with exit
|
|
196
|
+
`2` and the code `CONSENT_NEEDS_TTY`; the disclosure still prints first. A terminal `vibecommit auth` now continues
|
|
197
|
+
into this flow, inside a git repository or outside one on a machine that captures nothing yet, so it may also offer to
|
|
198
|
+
upload earlier sessions (default no); with `--stdin` or no terminal it still only saves the credential. That replaces
|
|
199
|
+
the "outside a repository" clause of the 0.6.0 paragraph above; its `--stdin` and no-terminal clauses, and "The
|
|
200
|
+
chained `connect` never opens a second sign-in", still hold.
|
|
201
|
+
|
|
202
|
+
*New verbs and changed ones.* `vibecommit scan [--json]` lists repositories and exits `4` when it finds none.
|
|
203
|
+
`vibecommit backfill` uploads earlier sessions for the repositories you chose, after two yeses and without commit
|
|
204
|
+
links; its exit codes are in the table above. `vibecommit status` now answers from any folder; `status --json` gains
|
|
205
|
+
`scope` and `basis` on a repository's document (`basis` is `owner`, `repo` or `per_clone`, or `null` when it is off),
|
|
206
|
+
a machine document with its own keys, and `org_pending`: `{at_ms}` or `null` inside a repository, and the list of
|
|
207
|
+
waiting repositories at machine level. `status` names a repository whose organization has not approved capture yet,
|
|
208
|
+
from inside it or from any folder. `vibecommit off` turns the repository off by its name, for every clone of it on
|
|
209
|
+
this machine.
|
|
210
|
+
|
|
211
|
+
*Delivery.* A 413 no longer writes off the span. A span goes in deltas of at most 8 MiB cut on a record boundary, a
|
|
212
|
+
413 halves the delta and retries, and only a single record that alone exceeds a limit (8 MiB raw, or 960 KiB
|
|
213
|
+
compressed) is skipped and counted; `status` reports it as "skipped … will not be sent later". A hook sends further
|
|
214
|
+
deltas only while its existing budget lasts and leaves the rest for its next event or `vibecommit finalize`. The test
|
|
215
|
+
capture in `connect` sends at most one hook budget and its first upload times out after about 3 seconds (it was 5).
|
|
216
|
+
|
|
217
|
+
*Hooks.* Claude Code, Codex and Cursor now register a `SessionStart` hook. In a clone you have granted, it installs the
|
|
218
|
+
commit hooks once, by plain writes only (if either slot holds someone else's hook it writes nothing, and `status`
|
|
219
|
+
says so), says so in one short notice, and uploads nothing, opens no transcript and makes no request. Notices show only
|
|
220
|
+
in the agents' terminal interfaces, so `status` is the record in `claude -p` and `codex exec`; Cursor's `sessionStart`
|
|
221
|
+
has no way to show one, and that hook is registered from reading Cursor's code, not from watching it run. Codex asks you to trust new hooks the next time it starts — until you do, it will not run them. The new `SessionStart` entry arrives untrusted, so
|
|
222
|
+
existing Codex users see one review after upgrading and running `connect`, and again whenever the path of the
|
|
223
|
+
`vibecommit` binary changes (an nvm switch, a plugin update). The Claude Code plugin installs no git hooks, including
|
|
224
|
+
from `SessionStart`.
|
|
225
|
+
|
|
226
|
+
*Errors.* Every error block now carries a stable code on its own muted line before the fix, with a link:
|
|
227
|
+
`NOT_A_REPO · vibecommit.ai/docs/errors#not-a-repo`. There are 61 codes (`test/error-codes.golden.txt`); a code names
|
|
228
|
+
a condition and carries no exit code. `UNKNOWN_COMMAND` replaces the help dump for an unknown verb: it prints a block
|
|
229
|
+
that points to `vibecommit --help`, and the exit is still `2`. `CONSENT_NEEDS_TTY` is now on its own code line, not in
|
|
230
|
+
parentheses in the sentence. A `--json` failure of `status`, `why` or `report`, and an unexpected error under `scan --json`, is now one document
|
|
231
|
+
on stdout and nothing on stderr, where 0.6.x left stdout empty: `{ schema, verb, outcome: "error", error: { code, what, why, fix } }`.
|
|
232
|
+
`fix` is `null` only when the block has no fix label at all; a label with nothing to type is `{ "label": …,
|
|
233
|
+
"commands": [] }`. Every fix command, in the text and in `--json`, follows the install channel: a machine that has only
|
|
234
|
+
the Claude Code plugin is told `node <path> …`, not a `vibecommit` it does not have. `vibecommit <verb> --help` now
|
|
235
|
+
prints usage, options and exit codes for `connect`, `auth`, `scan`, `status`, `why`, `report`, `finalize` and
|
|
236
|
+
`backfill`. `finalize` outside a git repository still exits `1`, and the README now says so. When `finalize` finds no
|
|
237
|
+
credential it says "This machine isn't connected." (`NO_CREDENTIAL`); a credential that is present but unusable gets
|
|
238
|
+
the same precise block `status` and `connect` print, and both exit `3`. A credential the server rejects still
|
|
239
|
+
reaches the send and exits `1`. `auth` with an empty or wrong-kind credential now puts the settings link first and the
|
|
240
|
+
commands last. Commands written inside a sentence, such as "run `vibecommit connect` to add them", follow the install
|
|
241
|
+
channel too. `CLIENT_TOO_OLD` (the server sent an answer this version is too old to show) now tells an npm install to
|
|
242
|
+
"Update VibeCommit to pick up the current client, then run this again:" with `npm install -g @vibe-commit/capture@latest`;
|
|
243
|
+
the plugin's reinstall line is unchanged. When the folder that holds the credential file, `~/.vibecommit`, is open to
|
|
244
|
+
other accounts, `CREDENTIAL_FILE_INSECURE` names the folder and gives `chmod 700 ~/.vibecommit`, not the file's
|
|
245
|
+
`chmod 600`. The package's `homepage` is `https://www.vibecommit.ai/install`, its `bugs` link is the plugin's
|
|
246
|
+
issues page, and `repository` is dropped, because this repository is private.
|
|
247
|
+
|
|
248
|
+
*A 0.6.x defect fixed.* For a repository whose path held an `_`, a space or another character outside letters and
|
|
249
|
+
digits, `connect`'s test capture looked in a Claude Code folder that does not exist and skipped the upload; it now
|
|
250
|
+
spells the folder name as Claude Code does.
|
|
251
|
+
|
|
177
252
|
## Status
|
|
178
253
|
|
|
179
254
|
**Implemented**, not a scaffold. All six commands above have real bodies — OAuth sign-in
|
package/dist/agent_hooks.d.ts
CHANGED
|
@@ -146,6 +146,14 @@ export declare function mergeHookDocument(raw: string | null, shape: HookDocShap
|
|
|
146
146
|
* and costs at most a duplicate. `writeAgentHooks` passes `existsSync`.
|
|
147
147
|
*/
|
|
148
148
|
binaryExists?: (path: string) => boolean): MergeOutcome;
|
|
149
|
+
/**
|
|
150
|
+
* Is one of OUR entries registered for this event in `raw`? Read-only, for `status` (0.7.0): a 0.6.x machine has
|
|
151
|
+
* `Stop`, `PreCompact` and `SessionEnd` but no `SessionStart`, and `npm i -g` alone never adds one.
|
|
152
|
+
*
|
|
153
|
+
* Unparseable, absent or the wrong shape all answer false — "not registered" is the honest reading of a file
|
|
154
|
+
* this client cannot use, and `connect` is the verb that explains a refusal.
|
|
155
|
+
*/
|
|
156
|
+
export declare function hasRegistration(raw: string | null, shape: HookDocShape, registration: HookRegistration, binaryExists?: (path: string) => boolean): boolean;
|
|
149
157
|
export type AgentHookInstall = {
|
|
150
158
|
readonly kind: "installed";
|
|
151
159
|
readonly path: string;
|
package/dist/agent_hooks.js
CHANGED
|
@@ -268,6 +268,28 @@ function isOurs(entry, shape, registration, binaryExists) {
|
|
|
268
268
|
typeof inner.command === "string" &&
|
|
269
269
|
commandIsOurs(inner.command, registration.command, binaryExists));
|
|
270
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Is one of OUR entries registered for this event in `raw`? Read-only, for `status` (0.7.0): a 0.6.x machine has
|
|
273
|
+
* `Stop`, `PreCompact` and `SessionEnd` but no `SessionStart`, and `npm i -g` alone never adds one.
|
|
274
|
+
*
|
|
275
|
+
* Unparseable, absent or the wrong shape all answer false — "not registered" is the honest reading of a file
|
|
276
|
+
* this client cannot use, and `connect` is the verb that explains a refusal.
|
|
277
|
+
*/
|
|
278
|
+
export function hasRegistration(raw, shape, registration, binaryExists = existsSync) {
|
|
279
|
+
if (raw === null)
|
|
280
|
+
return false;
|
|
281
|
+
let doc;
|
|
282
|
+
try {
|
|
283
|
+
doc = JSON.parse(raw);
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
if (!isRecord(doc) || !isRecord(doc.hooks))
|
|
289
|
+
return false;
|
|
290
|
+
const entries = doc.hooks[registration.event];
|
|
291
|
+
return Array.isArray(entries) && entries.some((e) => isOurs(e, shape, registration, binaryExists));
|
|
292
|
+
}
|
|
271
293
|
/**
|
|
272
294
|
* ⛔ **THE WHOLE STRING, NEVER A SUBSTRING — the trap `TODOS[138]` names.**
|
|
273
295
|
*
|
|
@@ -368,6 +390,15 @@ export function writeAgentHooks(path, shape, registrations) {
|
|
|
368
390
|
const merged = mergeHookDocument(raw, shape, registrations, existsSync);
|
|
369
391
|
if (merged.kind === "refused")
|
|
370
392
|
return { kind: "refused", path, why: merged.why };
|
|
393
|
+
const events = registrations.map((registration) => registration.event);
|
|
394
|
+
// ⛔ **A BYTE-IDENTICAL RESULT IS NOT WRITTEN AT ALL** (0.7.0, VQ ruling). Codex hashes each hook's normalized
|
|
395
|
+
// config (event, matcher, command, timeout) and runs a user-level hook only while a persisted hash matches, so
|
|
396
|
+
// the entry this client writes is something the user has to APPROVE. A re-`connect` with the same binary path
|
|
397
|
+
// rebuilds the same entry; rewriting the file anyway churns its mtime for nothing and invites every tool that
|
|
398
|
+
// watches it to react. A MOVED binary path still lands here as different text and is refreshed, because a stale
|
|
399
|
+
// path is worse than a fresh review — the hook would point at a binary that is gone.
|
|
400
|
+
if (raw !== null && merged.text === raw)
|
|
401
|
+
return { kind: "already", path, events };
|
|
371
402
|
const temp = join(dirname(path), `.${AGENT_HOOK_MARKER.replace(/\W+/g, "-")}.tmp`);
|
|
372
403
|
try {
|
|
373
404
|
mkdirSync(dirname(path), { recursive: true });
|
|
@@ -379,7 +410,6 @@ export function writeAgentHooks(path, shape, registrations) {
|
|
|
379
410
|
catch (error) {
|
|
380
411
|
return { kind: "failed", path, why: error instanceof Error ? error.message : "write failed" };
|
|
381
412
|
}
|
|
382
|
-
const events = registrations.map((registration) => registration.event);
|
|
383
413
|
// "already" is not "nothing happened" — the command was still refreshed. It is
|
|
384
414
|
// the answer to *did this connect ADD anything*, which is what a user reads.
|
|
385
415
|
return merged.added.length === 0
|
package/dist/agent_hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent_hooks.js","sourceRoot":"","sources":["../src/agent_hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC9G,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIpD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,4BAA4B,CAAC;AAE9D,oFAAoF;AACpF,MAAM,UAAU,GAAG,aAAa,CAAC;AAKjC,+DAA+D;AAC/D,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WAAW,CAAC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C;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;IAChG,CAAC;IAED,+EAA+E;IAC/E,6EAA6E;IAC7E,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;QAC9B,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE;QACnC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -8,4 +8,38 @@
|
|
|
8
8
|
* confinement call, which now runs against the registry's union.
|
|
9
9
|
*/
|
|
10
10
|
import type { TranscriptDialect } from "./types.js";
|
|
11
|
+
/**
|
|
12
|
+
* The longest folder name Claude Code writes verbatim.
|
|
13
|
+
*
|
|
14
|
+
* ⛔ **MEASURED (Open Question 3, VS, 2026-10-24).** An encoded path that would
|
|
15
|
+
* pass 200 characters is cut to 200, then `-`, then 6 hash characters (a
|
|
16
|
+
* measured name was 207 long, `…-x911fg`). The hash is not invertible from here,
|
|
17
|
+
* so such a folder cannot be matched to a path — and so a name LONGER than this
|
|
18
|
+
* is always a hashed one, since a verbatim name never exceeds it.
|
|
19
|
+
*/
|
|
20
|
+
export declare const CLAUDE_NAME_LIMIT = 200;
|
|
21
|
+
/**
|
|
22
|
+
* The folder name Claude Code gives a project path — Open Question 3.
|
|
23
|
+
*
|
|
24
|
+
* ⛔ **EVERY UTF-16 CODE UNIT OUTSIDE `[A-Za-z0-9]` BECOMES ONE `-`.** Measured by
|
|
25
|
+
* running throwaway sessions in folders named with `. _`, a space, `@ + ~ ( ) ' =
|
|
26
|
+
* , # % &`, `é` and an emoji: all of them, and the emoji TWICE, because the
|
|
27
|
+
* regular expression below runs over code units (no `u` flag) and an emoji is
|
|
28
|
+
* two. Runs do NOT collapse (`501/-Users` gave `501--Users`), a literal `-` stays
|
|
29
|
+
* itself, case is kept, and a leading `/` gives a leading `-`.
|
|
30
|
+
*
|
|
31
|
+
* ⚠ **This replaces `/[/.]/g`, which was the rule the first version of
|
|
32
|
+
* `locateCurrentTranscript` derived from 17 folders none of which held anything
|
|
33
|
+
* else.** For a repo whose path held an `_` or a space, `connect`'s test capture
|
|
34
|
+
* looked in a folder that does not exist and skipped the beat (a 0.6.x defect;
|
|
35
|
+
* `test/scan-encodings.test.ts` carries its regression cell).
|
|
36
|
+
*
|
|
37
|
+
* ⚠ **It returns the FULL encoding even past the limit**, and the callers decide
|
|
38
|
+
* what that means: `locateCurrentTranscript` cannot find a hashed folder, and the
|
|
39
|
+
* scan's walk compares PREFIXES of a name that is itself at most the limit, so a
|
|
40
|
+
* longer prefix simply never matches. One function, no second spelling of the rule.
|
|
41
|
+
*/
|
|
42
|
+
export declare function encodeProjectPath(path: string): string;
|
|
43
|
+
/** Is this folder name one Claude Code cut and hashed? See `CLAUDE_NAME_LIMIT`. */
|
|
44
|
+
export declare function isHashedProjectName(name: string): boolean;
|
|
11
45
|
export declare const CLAUDE_CODE: TranscriptDialect;
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* `commands/connect.ts`'s own `findCurrentTranscript` verbatim except for the
|
|
8
8
|
* confinement call, which now runs against the registry's union.
|
|
9
9
|
*/
|
|
10
|
-
import { readdirSync, statSync } from "node:fs";
|
|
10
|
+
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
11
11
|
import { basename, join } from "node:path";
|
|
12
|
-
import { claudeSettingsPath, isInside, isTranscriptFile, transcriptRoot } from "../paths.js";
|
|
12
|
+
import { claudeConfigPath, claudeSettingsPath, isInside, isTranscriptFile, transcriptRoot, } from "../paths.js";
|
|
13
|
+
import { readEntries, sessionFile, subdirectories } from "./session_listing.js";
|
|
13
14
|
/**
|
|
14
15
|
* The client-side backstop, per event.
|
|
15
16
|
*
|
|
@@ -38,16 +39,66 @@ const CLAUDE_CLIENT_BUDGET_MS = 5_000;
|
|
|
38
39
|
const CLAUDE_REGISTERED_STOP_MS = 8_000;
|
|
39
40
|
const CLAUDE_REGISTERED_PRECOMPACT_MS = 8_000;
|
|
40
41
|
const CLAUDE_REGISTERED_SESSION_END_MS = 10_000;
|
|
42
|
+
/**
|
|
43
|
+
* `SessionStart` reuses `Stop`'s two clocks and has no fast path of its own.
|
|
44
|
+
*
|
|
45
|
+
* ⛔ **A logged shortcut** — gstack-shortcut(dec-e650afbf), eng review D7 · B,
|
|
46
|
+
* Alexander's choice over a 1.5 s cap. The ceiling: a hung `SessionStart` can
|
|
47
|
+
* hold a session's start up by as long as the REGISTERED timeout (8 s here).
|
|
48
|
+
* Upgrade when a measurement or a user report shows session-start delay, or
|
|
49
|
+
* before slice 2's grants fetch is built into this handler.
|
|
50
|
+
*/
|
|
51
|
+
const CLAUDE_REGISTERED_SESSION_START_MS = CLAUDE_REGISTERED_STOP_MS; // gstack-shortcut(dec-e650afbf)
|
|
52
|
+
/**
|
|
53
|
+
* The longest folder name Claude Code writes verbatim.
|
|
54
|
+
*
|
|
55
|
+
* ⛔ **MEASURED (Open Question 3, VS, 2026-10-24).** An encoded path that would
|
|
56
|
+
* pass 200 characters is cut to 200, then `-`, then 6 hash characters (a
|
|
57
|
+
* measured name was 207 long, `…-x911fg`). The hash is not invertible from here,
|
|
58
|
+
* so such a folder cannot be matched to a path — and so a name LONGER than this
|
|
59
|
+
* is always a hashed one, since a verbatim name never exceeds it.
|
|
60
|
+
*/
|
|
61
|
+
export const CLAUDE_NAME_LIMIT = 200;
|
|
62
|
+
/**
|
|
63
|
+
* The folder name Claude Code gives a project path — Open Question 3.
|
|
64
|
+
*
|
|
65
|
+
* ⛔ **EVERY UTF-16 CODE UNIT OUTSIDE `[A-Za-z0-9]` BECOMES ONE `-`.** Measured by
|
|
66
|
+
* running throwaway sessions in folders named with `. _`, a space, `@ + ~ ( ) ' =
|
|
67
|
+
* , # % &`, `é` and an emoji: all of them, and the emoji TWICE, because the
|
|
68
|
+
* regular expression below runs over code units (no `u` flag) and an emoji is
|
|
69
|
+
* two. Runs do NOT collapse (`501/-Users` gave `501--Users`), a literal `-` stays
|
|
70
|
+
* itself, case is kept, and a leading `/` gives a leading `-`.
|
|
71
|
+
*
|
|
72
|
+
* ⚠ **This replaces `/[/.]/g`, which was the rule the first version of
|
|
73
|
+
* `locateCurrentTranscript` derived from 17 folders none of which held anything
|
|
74
|
+
* else.** For a repo whose path held an `_` or a space, `connect`'s test capture
|
|
75
|
+
* looked in a folder that does not exist and skipped the beat (a 0.6.x defect;
|
|
76
|
+
* `test/scan-encodings.test.ts` carries its regression cell).
|
|
77
|
+
*
|
|
78
|
+
* ⚠ **It returns the FULL encoding even past the limit**, and the callers decide
|
|
79
|
+
* what that means: `locateCurrentTranscript` cannot find a hashed folder, and the
|
|
80
|
+
* scan's walk compares PREFIXES of a name that is itself at most the limit, so a
|
|
81
|
+
* longer prefix simply never matches. One function, no second spelling of the rule.
|
|
82
|
+
*/
|
|
83
|
+
export function encodeProjectPath(path) {
|
|
84
|
+
return path.replace(/[^A-Za-z0-9]/g, "-");
|
|
85
|
+
}
|
|
86
|
+
/** Is this folder name one Claude Code cut and hashed? See `CLAUDE_NAME_LIMIT`. */
|
|
87
|
+
export function isHashedProjectName(name) {
|
|
88
|
+
return name.length > CLAUDE_NAME_LIMIT;
|
|
89
|
+
}
|
|
41
90
|
/**
|
|
42
91
|
* The transcript for the session running right now.
|
|
43
92
|
*
|
|
44
93
|
* A hook is HANDED `transcript_path` on stdin. `connect` is typed by a human and
|
|
45
94
|
* gets nothing, so it has to find one: Claude Code stores transcripts at
|
|
46
95
|
* `<transcriptRoot>/<encoded-project-path>/<session-id>.jsonl`, where the
|
|
47
|
-
* encoding
|
|
48
|
-
* directory on this machine against the `cwd` its transcripts
|
|
49
|
-
* matched exactly, and both misses were sessions whose `cwd`
|
|
50
|
-
* not a different encoding.
|
|
96
|
+
* encoding is `encodeProjectPath` above. The first version of that was derived
|
|
97
|
+
* by comparing every directory on this machine against the `cwd` its transcripts
|
|
98
|
+
* record — 15 of 17 matched exactly, and both misses were sessions whose `cwd`
|
|
99
|
+
* MOVED mid-session, not a different encoding. ⚠ Seventeen folders cannot
|
|
100
|
+
* contain a character none of them had: see `encodeProjectPath` for what that
|
|
101
|
+
* assumption cost.
|
|
51
102
|
*
|
|
52
103
|
* Which is also why this looks up the directory for THIS project rather than
|
|
53
104
|
* taking the newest transcript anywhere: a session that started in another
|
|
@@ -70,7 +121,13 @@ const CLAUDE_REGISTERED_SESSION_END_MS = 10_000;
|
|
|
70
121
|
*/
|
|
71
122
|
function locateCurrentTranscript(home, env, projectKey) {
|
|
72
123
|
const root = transcriptRoot(home, env);
|
|
73
|
-
const
|
|
124
|
+
const name = encodeProjectPath(projectKey);
|
|
125
|
+
// A hashed folder name cannot be derived from the path, so there is nothing to
|
|
126
|
+
// look in. `connect` then skips the test-capture beat, as it does for an agent
|
|
127
|
+
// with no locator, rather than guessing a sibling.
|
|
128
|
+
if (isHashedProjectName(name))
|
|
129
|
+
return null;
|
|
130
|
+
const dir = join(root, name);
|
|
74
131
|
let entries;
|
|
75
132
|
try {
|
|
76
133
|
entries = readdirSync(dir);
|
|
@@ -129,6 +186,70 @@ function claudeSessionIdFromEnv(env) {
|
|
|
129
186
|
const value = raw.trim();
|
|
130
187
|
return value === "" ? null : value;
|
|
131
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* The folders Claude Code has recorded running in: the KEYS of `~/.claude.json`'s
|
|
191
|
+
* `projects` map, and nothing else.
|
|
192
|
+
*
|
|
193
|
+
* ⛔ **Keys only.** The file also holds account and onboarding state, none of
|
|
194
|
+
* which this client has any use for. Nothing but the key strings leaves this
|
|
195
|
+
* function, and a failure of any kind is an empty list: the signal then simply
|
|
196
|
+
* does not fire, which skips less. ⚠ **No error is ever surfaced or logged** — Node
|
|
197
|
+
* 22's `JSON.parse` message quotes the text it failed on, and this file is not
|
|
198
|
+
* one whose text belongs on a screen.
|
|
199
|
+
*/
|
|
200
|
+
function recordedProjectPaths(home, env) {
|
|
201
|
+
try {
|
|
202
|
+
const parsed = JSON.parse(readFileSync(claudeConfigPath(home, env), "utf8"));
|
|
203
|
+
const projects = typeof parsed === "object" && parsed !== null
|
|
204
|
+
? parsed.projects
|
|
205
|
+
: undefined;
|
|
206
|
+
return typeof projects === "object" && projects !== null ? Object.keys(projects) : [];
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Claude Code's sessions, by folder — `D11 · A`, `scan`.
|
|
214
|
+
*
|
|
215
|
+
* `<root>/<encoded path>/<session-id>.jsonl`. Only the files DIRECTLY in a
|
|
216
|
+
* project folder are sessions: `<session-id>/subagents/…` holds delegated work
|
|
217
|
+
* that belongs to a parent session (`CR-124`), and counting it would turn one
|
|
218
|
+
* session into several. A legacy `agent-*.jsonl` sidechain at this level is
|
|
219
|
+
* excluded for the same reason.
|
|
220
|
+
*
|
|
221
|
+
* ⛔ **Names and times only.** The folder name is returned still ENCODED; whether
|
|
222
|
+
* it resolves to a path is the scan engine's walk, against the filesystem, never
|
|
223
|
+
* against a transcript's own `cwd` record (D60 §D6).
|
|
224
|
+
*/
|
|
225
|
+
function claudeSessionSource(home, env) {
|
|
226
|
+
const root = transcriptRoot(home, env);
|
|
227
|
+
const folders = [];
|
|
228
|
+
try {
|
|
229
|
+
for (const folder of subdirectories(root)) {
|
|
230
|
+
const sessions = [];
|
|
231
|
+
for (const entry of readEntries(folder.path) ?? []) {
|
|
232
|
+
if (!entry.name.endsWith(".jsonl") || entry.name.startsWith("agent-"))
|
|
233
|
+
continue;
|
|
234
|
+
const session = sessionFile(join(folder.path, entry.name));
|
|
235
|
+
if (session !== null)
|
|
236
|
+
sessions.push(session);
|
|
237
|
+
}
|
|
238
|
+
if (sessions.length > 0)
|
|
239
|
+
folders.push({ name: folder.name, sessions });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
return { kind: "unreadable", reason: "unreadable" };
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
kind: "folders",
|
|
247
|
+
folders,
|
|
248
|
+
encode: encodeProjectPath,
|
|
249
|
+
isHashed: isHashedProjectName,
|
|
250
|
+
recorded: recordedProjectPaths(home, env),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
132
253
|
export const CLAUDE_CODE = {
|
|
133
254
|
id: "claude-code",
|
|
134
255
|
transport: "ndjson",
|
|
@@ -143,7 +264,12 @@ export const CLAUDE_CODE = {
|
|
|
143
264
|
// agent the client was built for. Declared explicitly rather than defaulted so
|
|
144
265
|
// that a dialect added later must ANSWER the question; a default would let a
|
|
145
266
|
// camelCase agent inherit Claude's spellings and match nothing (`CR-195`).
|
|
146
|
-
eventNames: {
|
|
267
|
+
eventNames: {
|
|
268
|
+
Stop: "Stop",
|
|
269
|
+
PreCompact: "PreCompact",
|
|
270
|
+
SessionEnd: "SessionEnd",
|
|
271
|
+
SessionStart: "SessionStart",
|
|
272
|
+
},
|
|
147
273
|
// ⛔ `~/.claude/settings.json`, honouring `CLAUDE_CONFIG_DIR`. ⚠ This is the
|
|
148
274
|
// file the PLUGIN path does not need — the plugin ships its own `hooks.json`
|
|
149
275
|
// — and the npm path had no writer at all, which is the defect `/install`
|
|
@@ -162,12 +288,19 @@ export const CLAUDE_CODE = {
|
|
|
162
288
|
registeredTimeoutMs: CLAUDE_REGISTERED_SESSION_END_MS,
|
|
163
289
|
clientBudgetMs: CLAUDE_CLIENT_BUDGET_MS,
|
|
164
290
|
},
|
|
291
|
+
// MEASURED (Open Question 1, 2.1.309): fires before the first prompt in `-p`
|
|
292
|
+
// and the TUI, and accepts `systemMessage`. gstack-shortcut(dec-e650afbf).
|
|
293
|
+
SessionStart: {
|
|
294
|
+
registeredTimeoutMs: CLAUDE_REGISTERED_SESSION_START_MS,
|
|
295
|
+
clientBudgetMs: CLAUDE_CLIENT_BUDGET_MS,
|
|
296
|
+
},
|
|
165
297
|
},
|
|
166
298
|
// `<session>/subagents/agent-*.jsonl`, globbed — the paths are never handed
|
|
167
299
|
// over. `CR-124`, D76.
|
|
168
300
|
delegatedTranscripts: "discover",
|
|
169
301
|
redaction: "claude-code",
|
|
170
302
|
sessionIdFromEnv: claudeSessionIdFromEnv,
|
|
303
|
+
sessionSource: claudeSessionSource,
|
|
171
304
|
locateCurrentTranscript,
|
|
172
305
|
};
|
|
173
306
|
//# sourceMappingURL=claude_code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude_code.js","sourceRoot":"","sources":["../../src/agents/claude_code.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"claude_code.js","sourceRoot":"","sources":["../../src/agents/claude_code.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,QAAQ,EACR,gBAAgB,EAChB,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAShF;;;;;;;;;GASG;AACH,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAEtC;;;;;;;;;;;;;GAaG;AACH,MAAM,yBAAyB,GAAG,KAAK,CAAC;AACxC,MAAM,+BAA+B,GAAG,KAAK,CAAC;AAC9C,MAAM,gCAAgC,GAAG,MAAM,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,kCAAkC,GAAG,yBAAyB,CAAC,CA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AoB,EAAE,UAAU;IAChC,SAAS,EAAE,aAAa;IACxB,gBAAgB,EAAE,sBAAsB;IACxC,aAAa,EAAE,mBAAmB;IAClC,uBAAuB;CACxB,CAAC"}
|
|
@@ -12,4 +12,17 @@
|
|
|
12
12
|
* reader can check them against the product rather than against this file.
|
|
13
13
|
*/
|
|
14
14
|
import type { TranscriptDialect } from "./types.js";
|
|
15
|
+
/**
|
|
16
|
+
* ⛔ **THE FOUR COLUMNS, AND NO OTHER — `D11 · A`, Alexander's approved read.**
|
|
17
|
+
*
|
|
18
|
+
* The thread index also holds `first_user_message`, `title`, `preview` and more,
|
|
19
|
+
* which are CONTENT. Selecting one would turn a metadata read into a transcript
|
|
20
|
+
* read, so the statement names exactly these four and `test/scan-codex-index.test.ts`
|
|
21
|
+
* asserts the SQL carries nothing else. ⚠ **`archived` is not here either, on
|
|
22
|
+
* purpose** (VQ, 2026-10-24): an archived thread's `rollout_path` is decided by
|
|
23
|
+
* the admission below, and a fifth column would change the approved read surface.
|
|
24
|
+
*/
|
|
25
|
+
export declare const CODEX_INDEX_COLUMNS: readonly ["cwd", "git_origin_url", "rollout_path", "created_at"];
|
|
26
|
+
/** The one statement the adapter runs against a thread row. */
|
|
27
|
+
export declare const CODEX_INDEX_SQL: string;
|
|
15
28
|
export declare const CODEX_CLI: TranscriptDialect;
|