worktrust 0.10.29 → 0.10.31
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 +46 -6
- package/SECURITY.md +17 -0
- package/engine-release.json +1 -1
- package/package-release.json +1 -1
- package/package.json +1 -1
- package/setup-mcp.mjs +3 -0
- package/worktrust.mjs +174 -50
package/README.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# worktrust
|
|
2
2
|
|
|
3
|
+
## 0.10.31: a re-measure is offered only when measuring changed
|
|
4
|
+
|
|
5
|
+
`update` offers to re-measure this computer's sessions only when the new version MEASURES differently from the one it
|
|
6
|
+
replaces: a different timeline, seconds, tokens, steering, session kinds or readers. A release that changes something
|
|
7
|
+
else (consent, coupling, words) offers nothing. The offer lists what changed, one line each. The CLI carries the
|
|
8
|
+
version of its measuring rules beside its own version and records it in `~/.worktrust/installed-release.json` and
|
|
9
|
+
`~/.worktrust/history.json`; an install from before 0.10.31, which did not record it, counts as measuring by 0.10.29's
|
|
10
|
+
rules, so 0.10.29 or 0.10.30 updated to 0.10.31 is offered nothing. A history sent completely by a version with the
|
|
11
|
+
same rules counts as done, so the bare `npx worktrust` does not offer it again either.
|
|
12
|
+
|
|
13
|
+
## 0.10.30: an update asks only what is new
|
|
14
|
+
|
|
15
|
+
`update` remembers what you said yes to. Each AI app's WorkTrust door, the session hook, Codex's `notify` line and
|
|
16
|
+
Antigravity's `Stop` hook that you agreed to are brought onto the new version without a question, each printed as
|
|
17
|
+
`✓ … refreshed (you agreed on <date>)`. Only the launcher's path changes; nothing else about what was agreed. A NEW AI
|
|
18
|
+
app, or a wake hook that is no longer there (you took it out), is shown in full and asked about; `--yes` leaves it as
|
|
19
|
+
it is and lists it as `skipped: new, run without --yes to decide`. A No drops the agreement, and `disconnect` deletes
|
|
20
|
+
the record. It is one small file, `~/.worktrust/consent.json` (see [SECURITY.md](SECURITY.md)). The first update that
|
|
21
|
+
keeps it counts the WorkTrust entries already on this computer as agreed, because only a yes ever wrote them.
|
|
22
|
+
|
|
23
|
+
The re-measure after a new version is one question, asked after its plan (the plan is counted on this computer and
|
|
24
|
+
sends nothing): `Send them (re-measured; …)? [y/N]`. Enter and `--yes` are No. `--rebuild` agrees in advance.
|
|
25
|
+
|
|
26
|
+
One line that updates a computer you coupled before, with no question at all:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
npx -y worktrust@latest update --yes --rebuild
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- `npx -y`: npm's own flag. It answers npm's `Ok to proceed?` before it downloads the package; WorkTrust never sees it.
|
|
33
|
+
- `worktrust@latest`: the newest published version, never a copy npm cached earlier.
|
|
34
|
+
- `update`: this computer onto that version, the same key, no new pairing.
|
|
35
|
+
- `--yes`: every question whose answer is Yes by default. Anything new stays as it is (skipped, and listed).
|
|
36
|
+
- `--rebuild`: yes in advance to re-measuring this computer's sessions with the new version's rules. WorkTrust
|
|
37
|
+
replaces this computer's earlier lines for those days, each withdrawn and kept, never deleted. Leave it out to
|
|
38
|
+
be asked.
|
|
39
|
+
- `--codex` and `--antigravity` say yes in advance to a NEW Codex or Antigravity wake hook as well.
|
|
40
|
+
|
|
3
41
|
## 0.10.29: history in calls WorkTrust takes; how each session was started
|
|
4
42
|
|
|
5
43
|
A history call carries at most 1.9 MB and 1.4 MB of timelines (WorkTrust takes 2 MB and 1.5 MB). A batch an earlier
|
|
@@ -335,10 +373,11 @@ sends them with one difference: WorkTrust **replaces** this computer's earlier l
|
|
|
335
373
|
token counts, model names, a layer keyword, counts; never text.
|
|
336
374
|
- **Only from this computer's own key.** A connector (an AI signed in on the web) cannot ask for a rebuild; WorkTrust
|
|
337
375
|
refuses it at the door.
|
|
338
|
-
- **Offered once by `update`.** When this computer's earlier lines were
|
|
339
|
-
`~/.worktrust` says which), `npx worktrust@latest update` says so in
|
|
340
|
-
|
|
341
|
-
|
|
376
|
+
- **Offered once by `update`.** When this computer's earlier lines were measured by other rules (the copy in
|
|
377
|
+
`~/.worktrust` says which; 0.10.31: the measuring rules, not the version), `npx worktrust@latest update` says so in
|
|
378
|
+
plain words, lists what changed, shows the plan and asks once (0.10.30); Enter and `--yes` are No, `--rebuild`
|
|
379
|
+
agrees in advance, and a version that measures as the one before offers nothing. The command cannot read your
|
|
380
|
+
record, so it is an offer, not a finding.
|
|
342
381
|
|
|
343
382
|
## A web chat's data export
|
|
344
383
|
|
|
@@ -461,7 +500,7 @@ retried safely. A row kept pending on WorkTrust remains excluded from counted ac
|
|
|
461
500
|
| | |
|
|
462
501
|
|---|---|
|
|
463
502
|
| **Reads** | Which AI apps are installed (the settings folders of Claude Code, Codex, Cursor, Gemini CLI, Antigravity, VS Code, Windsurf, Hermes Agent, Goose, OpenCode, OpenClaw), and the chats Cursor and Copilot keep (clocks, models and token counts only). Afterwards, the session hook reads Claude Code's, Codex's and Antigravity's session files, the session databases of Hermes, Goose, OpenCode and OpenClaw, and the chats Cursor and Copilot keep, on this computer to measure durations and token counts. |
|
|
464
|
-
| **Writes** | The key file (above). In each AI app's MCP settings (`~/.claude.json` through `claude mcp`, `~/.cursor/mcp.json`, `~/.codex/config.toml`, `~/.gemini/settings.json`, `~/.gemini/config/mcp_config.json` (Antigravity), VS Code's `mcp.json`, Windsurf's `mcp_config.json`, Hermes's and Goose's `config.yaml`, OpenCode's `opencode.json`, OpenClaw through `openclaw mcp set`) a WorkTrust entry that runs the local bridge, with no key in it; three hooks in `~/.claude/settings.json`; the bridge, the hook and the counter in `~/.worktrust
|
|
503
|
+
| **Writes** | The key file (above). In each AI app's MCP settings (`~/.claude.json` through `claude mcp`, `~/.cursor/mcp.json`, `~/.codex/config.toml`, `~/.gemini/settings.json`, `~/.gemini/config/mcp_config.json` (Antigravity), VS Code's `mcp.json`, Windsurf's `mcp_config.json`, Hermes's and Goose's `config.yaml`, OpenCode's `opencode.json`, OpenClaw through `openclaw mcp set`) a WorkTrust entry that runs the local bridge, with no key in it; three hooks in `~/.claude/settings.json`; the bridge, the hook and the counter in `~/.worktrust/`; and `~/.worktrust/consent.json`, what you agreed to (names and days only, 0.10.30). |
|
|
465
504
|
| **Sends, to pair** | This computer's system (macOS, Windows, Linux) and host name. WorkTrust also records the network address the request arrives from, as a security record kept 90 days and seen only by WorkTrust staff (to answer a theft or fraud report). |
|
|
466
505
|
| **Sends, afterwards** | Per measured stretch of work, and nothing else: its timeline and basis (`timeline`, `duration_basis`: since 0.10.20 the CLI sends no duration and no hours in layers of its own; WorkTrust computes them from the timeline), token counts (`tokens_in`, `tokens_out`, `tokens_cache_read`, `tokens_cache_write`, `token_basis`), the model's name (`model`), the kind of work and one layer keyword such as frontend or backend (`title`, `kind`, `layer`, `layers`), closed technology keys (`stack`) and separate display-only tool keys (`tools_seen`), how the turns are counted (`turn_basis`; the counts themselves WorkTrust reads from the timeline; the subagents' seconds wait for a timeline per run), when it began and ended and your computer's offset from UTC (`started_at`, `at`, `utc_offset`), what the CLI derived from the stretch as kinds and counts (`evidence`: checks run and failed, delivery steps and whether a check passed first, recoveries, delegation, context, routing, steering, refusals, planning, files and test files changed, the complexity class; with the WorkTrust mod on, its `live` counts from inside Claude Code: permission answers, effort levels, context and plan-limit peaks, subagents and setup; never a word, a command or a path; since 0.8.3, `live` since 0.10.15), a hash of the session and the day (`stretch_ref`), `steered_from` when it ran over SSH, the stretch's clock as step kinds and whole seconds so WorkTrust computes the figures itself (`timeline`, since 0.10.20: never a word, a tool name or a path), how the session was started as the AI app recorded it, beside the timeline (`session_kind`: interactive, headless or scheduled, since 0.10.29; left out when the app did not say), the CLI's version and a digest of its own files as signals (`cli_version`, `cli_digest`), and, so the work can be matched to GitHub, the repository as its remote's owner/name (`repo`, only for a repository on GitHub, GitLab or Bitbucket, the hosts WorkTrust can couple; never one on your own or a client's server), for any other git repository a code in its place (`repo_code`: 16 hex of an HMAC of its remote, or its root, keyed with this computer's own secret in `~/.worktrust/archive-salt`, which is never sent, so WorkTrust can group its lines but cannot tell which repository it is) and the hashes of the commits made in the stretch (`commits`, never their messages). |
|
|
467
506
|
| **Never sends** | Prompts, answers, code, file names or paths, commit messages, branch names, or the name of your local folder (a repository is named only as its remote's owner/name, above). The door has no field for them and refuses a submission that carries them. |
|
|
@@ -509,7 +548,8 @@ never as proof.
|
|
|
509
548
|
## Undo
|
|
510
549
|
|
|
511
550
|
`npx worktrust@latest disconnect` removes the WorkTrust entries (Hermes's hook with them), the hook (and Codex's `notify` line and
|
|
512
|
-
Antigravity's `worktrust` hook when WorkTrust set them), the credentials
|
|
551
|
+
Antigravity's `worktrust` hook when WorkTrust set them), the credentials, installed bridge scripts and the record of
|
|
552
|
+
what you agreed to (`~/.worktrust/consent.json`, 0.10.30).
|
|
513
553
|
Protected mode retains an encrypted empty slot and its OS wrapping key so reconnecting stays protected.
|
|
514
554
|
A small note of the previous account (masked) remains so that a later coupling by another account
|
|
515
555
|
does not offer its earlier work. Other retained files and your local evidence archive are not an
|
package/SECURITY.md
CHANGED
|
@@ -56,6 +56,23 @@ private transcripts or account data in a public issue.
|
|
|
56
56
|
- Local `disconnect` is distinct from server revocation and archive deletion. Revoke through
|
|
57
57
|
WorkTrust's device settings when the server credential must stop working.
|
|
58
58
|
|
|
59
|
+
## What you agreed to: `~/.worktrust/consent.json` (0.10.30)
|
|
60
|
+
|
|
61
|
+
- One private file (mode 0600, written through the same exclusive-temp, atomic-replace path as the credential file,
|
|
62
|
+
refused when it is a link or not owned by you). Per coupling you said yes to it holds a NAME only
|
|
63
|
+
(`door:<app>` such as `door:Cursor`, `session-hook`, `codex-notify`, `antigravity-stop`), the day, the CLI version
|
|
64
|
+
and how the yes was given (`typed`, `flag` for `--yes`, `--codex` or `--antigravity` said in advance, `found` for a
|
|
65
|
+
WorkTrust entry already on the computer when the file was first made). No key, no token, no path, no command and
|
|
66
|
+
nothing of any config file. It is never sent.
|
|
67
|
+
- What it changes: `update` refreshes an agreed entry without asking when only the launcher's path moves. It never
|
|
68
|
+
turns a new AI app or a wake hook that is no longer there into a yes: those are asked about, and `--yes` skips them.
|
|
69
|
+
It is never read as agreement to send anything: the re-measure of earlier history still needs a typed `y` or
|
|
70
|
+
`--rebuild`, every time a new version offers it.
|
|
71
|
+
- Who can change it: anyone who can write your home folder, which can already edit the AI apps' settings directly.
|
|
72
|
+
A forged entry can at most spare the question for a write WorkTrust would offer anyway (the door in an AI app found
|
|
73
|
+
here, a wake hook); it cannot widen what is written, sent or read. An unreadable or unsafe file counts as no agreement.
|
|
74
|
+
- A No drops the entry it answered; `disconnect` deletes the file; a coupling to another account starts it empty.
|
|
75
|
+
|
|
59
76
|
## What measurement signatures establish
|
|
60
77
|
|
|
61
78
|
The metadata journal introduced in the 0.10.21 candidate preserves observations, not their
|
package/engine-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"04eafe333940ec03d5058d8d51062124aa12ab882bf04db03bcda5613ec69298","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","config-edits.mjs":"0eba2f176ef6f7afba071d6e00de0ff19ba2b283180a801dfd957aa38c1edd94","count-behaviour.mjs":"1beaec2a4d0aead76d166f89cc52441a9cf48f2e69da9888ca2091dd3a10a37b","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","history-outbox.mjs":"b84e22542bb2d8195a469ee5f4116356ae9eac4a53ff2d40f0268b5b1de99dc5","log-session.mjs":"4da610744dfdd1aa939c231263fad9962288376bf8494ef3e0a08128e3d0cb17","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"3e369083ba43bcda2fa0622fd526aa64fcf8ad66e7b6e8f23821752c4d47ad27","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","session-databases.mjs":"543fd3b82d28d96d789be0a1dc9186c5fafa783e98b87e5b3b17b211542e2b4d","setup-mcp.mjs":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"04eafe333940ec03d5058d8d51062124aa12ab882bf04db03bcda5613ec69298","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","config-edits.mjs":"0eba2f176ef6f7afba071d6e00de0ff19ba2b283180a801dfd957aa38c1edd94","count-behaviour.mjs":"1beaec2a4d0aead76d166f89cc52441a9cf48f2e69da9888ca2091dd3a10a37b","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","history-outbox.mjs":"b84e22542bb2d8195a469ee5f4116356ae9eac4a53ff2d40f0268b5b1de99dc5","log-session.mjs":"4da610744dfdd1aa939c231263fad9962288376bf8494ef3e0a08128e3d0cb17","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"3e369083ba43bcda2fa0622fd526aa64fcf8ad66e7b6e8f23821752c4d47ad27","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","session-databases.mjs":"543fd3b82d28d96d789be0a1dc9186c5fafa783e98b87e5b3b17b211542e2b4d","setup-mcp.mjs":"0c29113179561af1c1e9ff8b7a786e7240edf48a2244993e12335e5ee362c812","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5b31a6f29b785d277e92257532f3c7cee366a79759decc7a75cfbaec2686ee13","transcript-readers.mjs":"2f17bb5f234ccd630d51cf3f35c396d1b43240b601330cc3abb193effb5bfc3c","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"7fdcd2996f0d401a7232467904d2900ee2cc084764ae25d4ffd5f9f4b57da1b3"},"format":"worktrust-package/1","kind":"engine","version":"0.10.31"},"signature":"BFiAtMFcbRPNlWst7-uNb2Flv378GZ195wtGF5nFxLkHaqNEhskqGe0KrzaDKM0T5AKCwf0VoAMOu9r4mf1TDw"}
|
package/package-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"c6f5280c5bf81a14db4bdc282218fb005706e92dd9a9170c0e727716ee91685a","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"3096ed1693974a90e1f4f59bf01c9559d94a7941d933e36fb81d3995a97f25c1","README.md":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"c6f5280c5bf81a14db4bdc282218fb005706e92dd9a9170c0e727716ee91685a","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"3096ed1693974a90e1f4f59bf01c9559d94a7941d933e36fb81d3995a97f25c1","README.md":"e0b621c26ba8bdfda128eb132d0c42db404bd2db285ad503d81a4bdcda2d1c9a","SECURITY.md":"a7f1187b4f384a71e1f69cb25327487597969c0b0422b377dd4c72086b1b9ad9","chat-exports.mjs":"04eafe333940ec03d5058d8d51062124aa12ab882bf04db03bcda5613ec69298","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","config-edits.mjs":"0eba2f176ef6f7afba071d6e00de0ff19ba2b283180a801dfd957aa38c1edd94","count-behaviour.mjs":"1beaec2a4d0aead76d166f89cc52441a9cf48f2e69da9888ca2091dd3a10a37b","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","engine-release.json":"02575409b07768da214adc4e11f14ce9118cda8dbf9163d6e330e472f9ee00a5","history-outbox.mjs":"b84e22542bb2d8195a469ee5f4116356ae9eac4a53ff2d40f0268b5b1de99dc5","log-session.mjs":"4da610744dfdd1aa939c231263fad9962288376bf8494ef3e0a08128e3d0cb17","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","package.json":"ba40fbf9fb3ae3ec7bad023c1c327660294db61fc479961bdd5ebdc70e92103e","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"3e369083ba43bcda2fa0622fd526aa64fcf8ad66e7b6e8f23821752c4d47ad27","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","session-databases.mjs":"543fd3b82d28d96d789be0a1dc9186c5fafa783e98b87e5b3b17b211542e2b4d","setup-mcp.mjs":"0c29113179561af1c1e9ff8b7a786e7240edf48a2244993e12335e5ee362c812","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5b31a6f29b785d277e92257532f3c7cee366a79759decc7a75cfbaec2686ee13","transcript-readers.mjs":"2f17bb5f234ccd630d51cf3f35c396d1b43240b601330cc3abb193effb5bfc3c","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"7fdcd2996f0d401a7232467904d2900ee2cc084764ae25d4ffd5f9f4b57da1b3"},"format":"worktrust-package/1","kind":"npm","version":"0.10.31"},"signature":"5zVtVZzppT1vbBpiUKj8OXIdN7C5HFGN3TXtBEY56jlctT7zYARKRAfRTbSDPnozaYiPeE5juo-5wseGwme4DA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "worktrust",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.31",
|
|
4
4
|
"description": "Couple this computer to WorkTrust: approve a code in your browser, and every AI app here reports what you built. Metadata only, no dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/setup-mcp.mjs
CHANGED
|
@@ -26,6 +26,8 @@ const value = (name) => { const i = args.indexOf(`--${name}`); return i >= 0 ? a
|
|
|
26
26
|
const WRITE = args.includes("--write");
|
|
27
27
|
const REMOVE = args.includes("--remove");
|
|
28
28
|
const NAME = value("name") ?? "worktrust";
|
|
29
|
+
/** `--skip "Cursor,Zed"` (0.10.30): apps the person has not agreed to yet are left exactly as they are, in and out. */
|
|
30
|
+
const SKIP = new Set((value("skip") ?? "").split(",").map((label) => label.trim()).filter(Boolean));
|
|
29
31
|
/**
|
|
30
32
|
* THE BRIDGE (2026-10-03). With `--bridge <path to worktrust.mjs>` no client is given a key: each
|
|
31
33
|
* gets a local command (`node worktrust.mjs mcp`) that reads the key from ~/.worktrust/key.json
|
|
@@ -217,6 +219,7 @@ let touched = 0;
|
|
|
217
219
|
let standing = 0;
|
|
218
220
|
for (const client of CLIENTS) {
|
|
219
221
|
if (!client.present()) { console.log(` – ${client.label}: not on this machine`); continue; }
|
|
222
|
+
if (SKIP.has(client.label)) { console.log(` · ${client.label}: left as it is (not agreed yet)`); continue; }
|
|
220
223
|
if (client.shape === "openclaw") {
|
|
221
224
|
const text = existsSync(client.file) ? readFileSync(client.file, "utf8") : "";
|
|
222
225
|
const named = new RegExp(`["']?${NAME}["']?\\s*:\\s*\\{`).test(text) && ours(text);
|
package/worktrust.mjs
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* npx worktrust --yes no question (for scripts); the computer is still approved in the app
|
|
9
9
|
* npx worktrust --device a computer without a browser (SSH): type a code on another device
|
|
10
10
|
* npx worktrust connect couple again, also on a computer already coupled
|
|
11
|
-
* npx worktrust update this computer onto the newest CLI, same key, no new pairing
|
|
11
|
+
* npx worktrust update this computer onto the newest CLI, same key, no new pairing (0.10.30: what
|
|
12
|
+
* was agreed before is refreshed unasked; --rebuild agrees to the re-measure)
|
|
12
13
|
* npx worktrust history send this computer's earlier sessions as history (asks first)
|
|
13
14
|
* npx worktrust history --rebuild the same as history (0.10.5: history always re-measures); WorkTrust replaces this computer's
|
|
14
15
|
* earlier lines day by day, never counting a day twice (shows the plan, asks first)
|
|
@@ -75,7 +76,19 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
|
|
|
75
76
|
const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
|
|
76
77
|
const has = (name) => args.includes(`--${name}`);
|
|
77
78
|
/** This CLI's version, said to the door so the app can tell which computer runs an old one (check-cli-package holds it equal to package.json). */
|
|
78
|
-
const CLI_VERSION = "0.10.
|
|
79
|
+
const CLI_VERSION = "0.10.31";
|
|
80
|
+
/**
|
|
81
|
+
* HOW THIS CLI MEASURES, AS A NUMBER OF ITS OWN (0.10.31; owner, 2026-10-28: 0.10.30 offered a re-measure it had no reason
|
|
82
|
+
* to offer). Raised ONLY when what is measured changes: the timeline, the seconds, the tokens, the steering, the session
|
|
83
|
+
* kinds, the readers. A release that changes consent, coupling or words keeps it. `update` offers the re-measure only when
|
|
84
|
+
* the earlier install measured by other rules, and names what changed from MEASURE_CHANGES; installed-release.json and
|
|
85
|
+
* history.json record it. 1 is the rules of 0.10.29, which 0.10.30 and 0.10.31 kept.
|
|
86
|
+
*/
|
|
87
|
+
const MEASURE_RULES = 1;
|
|
88
|
+
/** What each measure-rules version changed, in the words the re-measure offer says (one entry per raise, never rewritten). */
|
|
89
|
+
const MEASURE_CHANGES = {
|
|
90
|
+
1: ["each answer's tokens counted once", "nothing lost at midnight", "when each stretch began", "how you steered the agent", "what the seconds were", "more AI apps", "how each session was started"],
|
|
91
|
+
};
|
|
79
92
|
const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.worktrust.io").replace(/\/$/, "");
|
|
80
93
|
const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
|
|
81
94
|
const HOME_DIR = join(homedir(), ".worktrust");
|
|
@@ -296,7 +309,7 @@ async function prepareBundledRuntime() {
|
|
|
296
309
|
}
|
|
297
310
|
function saveStableEntry() {
|
|
298
311
|
const target = join(HOME_DIR, "installed-release.json"), temporary = `${target}.${randomBytes(8).toString("hex")}.tmp`;
|
|
299
|
-
try { writeFileSync(temporary, JSON.stringify({ version: CLI_VERSION }), { flag: "wx", mode: 0o600 }); renameSync(temporary, target); }
|
|
312
|
+
try { writeFileSync(temporary, JSON.stringify({ version: CLI_VERSION, measureRules: MEASURE_RULES }), { flag: "wx", mode: 0o600 }); renameSync(temporary, target); }
|
|
300
313
|
finally { try { rmSync(temporary); } catch { /* already renamed */ } }
|
|
301
314
|
}
|
|
302
315
|
|
|
@@ -330,6 +343,64 @@ const previousNote = {
|
|
|
330
343
|
erase() { try { rmSync(PREVIOUS_FILE); } catch { /* gone */ } },
|
|
331
344
|
};
|
|
332
345
|
|
|
346
|
+
/**
|
|
347
|
+
* WHAT THE PERSON ALREADY AGREED TO (0.10.30, owner 2026-10-28: "an update should need fewer y + Enter"). One small file,
|
|
348
|
+
* ~/.worktrust/consent.json (0600): per coupling the person said yes to, its name only (`door:<app>`, `session-hook`,
|
|
349
|
+
* `codex-notify`, `antigravity-stop`), the day, the CLI version and how (`typed`, `flag`: --yes / --codex / --antigravity
|
|
350
|
+
* said in advance, `found`: a WorkTrust entry already here when this file was first made, which only a yes ever wrote).
|
|
351
|
+
* Never a key, a path or a config's content. `update` refreshes an agreed entry whose only change is the launcher's path
|
|
352
|
+
* without asking; a NEW app or hook still asks, and under --yes is skipped. A No drops the entry; disconnect deletes the
|
|
353
|
+
* file; a coupling to another account starts it empty. An unreadable file counts as no agreement at all.
|
|
354
|
+
*/
|
|
355
|
+
const CONSENT_FILE = join(HOME_DIR, "consent.json");
|
|
356
|
+
const CONSENT_NAME = /^(?:door:[^\n,]{1,80}|session-hook|codex-notify|antigravity-stop)$/;
|
|
357
|
+
const CONSENT_HOW = new Set(["typed", "flag", "found"]);
|
|
358
|
+
let consentLoaded = null;
|
|
359
|
+
async function consent() {
|
|
360
|
+
if (consentLoaded) return consentLoaded;
|
|
361
|
+
let file = null;
|
|
362
|
+
try { const text = readPrivateFile(CONSENT_FILE); file = text === null ? null : JSON.parse(text); } catch { file = {}; }
|
|
363
|
+
const entries = {};
|
|
364
|
+
for (const [name, entry] of Object.entries(file?.entries ?? {})) if (CONSENT_NAME.test(name) && /^\d{4}-\d{2}-\d{2}$/.test(entry?.at ?? "") && CONSENT_HOW.has(entry?.how)) entries[name] = { at: entry.at, cli: String(entry.cli ?? "").slice(0, 16), how: entry.how };
|
|
365
|
+
let dirty = false;
|
|
366
|
+
const today = () => new Date().toISOString().slice(0, 10);
|
|
367
|
+
// THE FIRST RUN THAT KEEPS THIS FILE: what WorkTrust already wrote here on an earlier yes counts as that yes, once.
|
|
368
|
+
if (file === null) { for (const name of await consentFound()) entries[name] = { at: today(), cli: CLI_VERSION, how: "found" }; dirty = Object.keys(entries).length > 0; }
|
|
369
|
+
const save = () => { if (!dirty || has("dry-run")) return; try { ensureHome(); writePrivateFile(CONSENT_FILE, `${JSON.stringify({ version: 1, entries })}\n`); dirty = false; } catch { /* not kept: the next run asks again */ } };
|
|
370
|
+
consentLoaded = {
|
|
371
|
+
has: (name) => Boolean(entries[name]),
|
|
372
|
+
said: (name) => (entries[name]?.how === "found" ? "you agreed with an earlier version" : `you agreed on ${entries[name]?.at}`),
|
|
373
|
+
agree(name, how) { if (!entries[name]) { entries[name] = { at: today(), cli: CLI_VERSION, how }; dirty = true; } save(); },
|
|
374
|
+
drop(name) { if (entries[name]) { delete entries[name]; dirty = true; } save(); },
|
|
375
|
+
reset() { for (const name of Object.keys(entries)) delete entries[name]; dirty = true; save(); },
|
|
376
|
+
save,
|
|
377
|
+
};
|
|
378
|
+
return consentLoaded;
|
|
379
|
+
}
|
|
380
|
+
function eraseConsent() { try { rmSync(CONSENT_FILE); } catch { /* none */ } consentLoaded = null; }
|
|
381
|
+
/** The WorkTrust entries already standing here: each app's door (setup-mcp's own removal plan), the session hook, Codex's and Antigravity's wake hooks. */
|
|
382
|
+
async function consentFound() {
|
|
383
|
+
const found = [];
|
|
384
|
+
try {
|
|
385
|
+
const plan = await run((await scripts())["setup-mcp.mjs"], ["--remove"], PLACEHOLDER, true);
|
|
386
|
+
for (const line of plan.out.split("\n")) { const match = /^\s+− ([^:]+): would (?:remove from|run)/.exec(line); if (match && match[1] !== "Claude Code") found.push(`door:${match[1]}`); }
|
|
387
|
+
} catch { /* no plan: nothing found */ }
|
|
388
|
+
if (claudeDoorHere()) found.push("door:Claude Code");
|
|
389
|
+
if (sessionHookHere()) found.push("session-hook");
|
|
390
|
+
if (existsSync(join(homedir(), ".codex")) && isOurNotify(codexNotify().text ?? "")) found.push("codex-notify");
|
|
391
|
+
if (antigravityHere() && agyHooks()?.worktrust) found.push("antigravity-stop");
|
|
392
|
+
return found.filter((name) => CONSENT_NAME.test(name));
|
|
393
|
+
}
|
|
394
|
+
/** Claude Code's own entry for the door, as status reads it; the session hook in its settings. */
|
|
395
|
+
function claudeDoorHere() {
|
|
396
|
+
const servers = {};
|
|
397
|
+
try { const config = JSON.parse(readFileSync(join(homedir(), ".claude.json"), "utf8")); Object.assign(servers, config.mcpServers ?? {}); for (const project of Object.values(config.projects ?? {})) Object.assign(servers, project.mcpServers ?? {}); } catch { /* no Claude Code here */ }
|
|
398
|
+
return Object.entries(servers).find(([name, server]) => /worktrust/i.test(`${name} ${server?.url ?? ""} ${(server?.args ?? []).join(" ")}`)) ?? null;
|
|
399
|
+
}
|
|
400
|
+
function sessionHookHere() { try { return /log-session|worktrust(?:-launch)?\.(?:mjs|py)\\?" hook/.test(readFileSync(join(homedir(), ".claude", "settings.json"), "utf8")); } catch { return false; } }
|
|
401
|
+
/** The app a plan line names: " ✓ Cursor: …" → Cursor. */
|
|
402
|
+
const labelOf = (line) => /^\s*[↻+✓!−-] ([^:]+):/.exec(line)?.[1] ?? null;
|
|
403
|
+
|
|
333
404
|
/**
|
|
334
405
|
* THE OLD KEY ENDS WHEN THE COMPUTER IS COUPLED AGAIN (owner, 2026-10-04). Signed with the old key's own
|
|
335
406
|
* device key, which only this computer holds, and naming the new key by its prefix: WorkTrust ends the
|
|
@@ -565,31 +636,46 @@ async function update() {
|
|
|
565
636
|
say();
|
|
566
637
|
const paths = await scripts();
|
|
567
638
|
const plan = await run(paths["setup-mcp.mjs"], ["--bridge", STABLE], PLACEHOLDER, true);
|
|
639
|
+
// AGREED BEFORE, REFRESHED WITHOUT A QUESTION (0.10.30): an app or hook the person said yes to is brought onto this
|
|
640
|
+
// version's launcher; only what is NEW here is shown in full and asked about, and --yes leaves the new ones as they are.
|
|
641
|
+
const agreed = await consent();
|
|
568
642
|
say(" Every AI app found here gets the WorkTrust door, the local command that reads the key:");
|
|
569
643
|
const found = planLines(plan.out, true).filter((line) => !line.includes("not on this machine"));
|
|
570
|
-
|
|
644
|
+
const apps = [...new Set(found.map(labelOf).filter(Boolean))], fresh = apps.filter((app) => !agreed.has(`door:${app}`));
|
|
645
|
+
for (const app of apps) if (!fresh.includes(app)) say(` ✓ ${app}: refreshed (${agreed.said(`door:${app}`)})`);
|
|
646
|
+
for (const line of found) if (fresh.includes(labelOf(line))) say(`${line} · new`);
|
|
571
647
|
if (found.length === 0) say(" (no AI app found here)");
|
|
648
|
+
const hookFresh = !agreed.has("session-hook");
|
|
572
649
|
say(` The session hook and ${STABLE} are brought to ${CLI_VERSION}.`);
|
|
650
|
+
say(hookFresh ? ` + Session hook: ${join(homedir(), ".claude", "settings.json")} → SessionStart, SessionEnd and PreCompact run it · new` : ` ✓ Session hook: refreshed (${agreed.said("session-hook")})`);
|
|
573
651
|
say(" The key stays as it is: no new pairing, the same computer in WorkTrust.");
|
|
574
652
|
say();
|
|
575
653
|
if (has("dry-run")) { say(" Dry run: nothing was written and nothing was sent."); return; }
|
|
576
|
-
|
|
577
|
-
|
|
654
|
+
const newOnes = [...fresh, ...(hookFresh ? ["Session hook"] : [])];
|
|
655
|
+
let takeNew = false;
|
|
656
|
+
if (newOnes.length > 0 && has("yes")) say(` skipped: new, run without --yes to decide: ${newOnes.join(", ")}`);
|
|
657
|
+
else if (newOnes.length > 0) takeNew = await ask(`Couple the new ${newOnes.length === 1 ? "one" : "ones"} marked "new" (${newOnes.join(", ")})?`, false);
|
|
658
|
+
if (newOnes.length > 0 && !takeNew && !has("yes")) say(" The new ones stay as they are. npx worktrust update asks again.");
|
|
659
|
+
const skip = takeNew ? [] : fresh, hookOn = !hookFresh || takeNew;
|
|
660
|
+
const previous = stableInstall();
|
|
578
661
|
await prepareBundledRuntime();
|
|
579
662
|
ensureHome();
|
|
580
663
|
saveStableEntry();
|
|
581
664
|
say(` ✓ ${STABLE} is now ${CLI_VERSION}`);
|
|
582
|
-
// Out first, then in: an app that held a key of its own (a hand-made entry) moves onto the bridge.
|
|
583
|
-
|
|
584
|
-
|
|
665
|
+
// Out first, then in: an app that held a key of its own (a hand-made entry) moves onto the bridge. An app not agreed to is not touched.
|
|
666
|
+
const skipArgs = skip.length > 0 ? ["--skip", skip.join(",")] : [];
|
|
667
|
+
await run(paths["setup-mcp.mjs"], ["--remove", "--write", ...skipArgs], key.token, true);
|
|
668
|
+
if ((await run(paths["setup-mcp.mjs"], ["--write", "--bridge", STABLE, ...skipArgs], key.token)).code !== 0) fail("coupling the AI apps failed; the output above says where.");
|
|
585
669
|
const hookArgs = ["--install", "--via", STABLE];
|
|
586
|
-
if ((await run(paths["log-session.mjs"], hookArgs, key.token, false)).code !== 0) fail("installing the session hook failed; the output above says where.");
|
|
670
|
+
if (hookOn && (await run(paths["log-session.mjs"], hookArgs, key.token, false)).code !== 0) fail("installing the session hook failed; the output above says where.");
|
|
671
|
+
for (const name of [...apps.filter((app) => !skip.includes(app)).map((app) => `door:${app}`), ...(hookOn ? ["session-hook"] : [])]) agreed.agree(name, "typed");
|
|
672
|
+
agreed.save();
|
|
587
673
|
// Codex installed since, or a No said at connect: the one question, asked again (or "already set").
|
|
588
674
|
await offerCodex();
|
|
589
675
|
await offerAntigravity();
|
|
590
676
|
const reported = await accepted(key.url, key.token, key.device);
|
|
591
677
|
say(reported === true ? ` ✓ WorkTrust received CLI version ${CLI_VERSION}.` : " ! Installed locally. WorkTrust could not confirm the version yet; it will be reported on the next connection.");
|
|
592
|
-
await offerRebuild(
|
|
678
|
+
await offerRebuild(previous, paths, key);
|
|
593
679
|
say();
|
|
594
680
|
say(" Done. Quit your AI apps completely and open them again to use the updated CLI.");
|
|
595
681
|
}
|
|
@@ -632,6 +718,7 @@ async function connect() {
|
|
|
632
718
|
if (has("dry-run")) { say(" Dry run: nothing was written and nothing was sent."); return; }
|
|
633
719
|
if (!(await ask("Continue?"))) { say(" Stopped. Nothing was written and nothing was sent."); return; }
|
|
634
720
|
await prepareBundledRuntime();
|
|
721
|
+
const agreed = await consent(); // read before anything is written, so what this run writes is not taken for an earlier yes
|
|
635
722
|
|
|
636
723
|
// The device key: made here, its private half kept with the key, its public half bound at WorkTrust.
|
|
637
724
|
const device = direct ? null : generateKeyPairSync("ed25519");
|
|
@@ -662,6 +749,9 @@ async function connect() {
|
|
|
662
749
|
const floors = !previous || switched ? ["--from-now", ...(switched ? ["--history-floor", "now"] : [])] : [];
|
|
663
750
|
const hookArgs = ["--install", ...floors, "--via", STABLE, ...(direct ? ["--direct"] : [])];
|
|
664
751
|
if ((await run(paths["log-session.mjs"], hookArgs, token, false, { WORKTRUST_CODEX_OFFER: "1" })).code !== 0) fail("installing the session hook failed; the output above says where.");
|
|
752
|
+
// WHAT WAS AGREED HERE (0.10.30): the apps and the hook this "Continue?" covered; another account starts with none from before.
|
|
753
|
+
if (switched) agreed.reset();
|
|
754
|
+
for (const name of [...new Set(foundApps.map(labelOf).filter(Boolean))].map((app) => `door:${app}`).concat("session-hook")) agreed.agree(name, has("yes") ? "flag" : "typed");
|
|
665
755
|
await offerCodex();
|
|
666
756
|
await offerAntigravity();
|
|
667
757
|
if (switched) { say(); say(" Earlier work on this computer is not offered: it was coupled to another account before. Only work from now on goes to this account."); }
|
|
@@ -680,7 +770,7 @@ async function connect() {
|
|
|
680
770
|
* Enter, --yes and a closed terminal all mean No; `--history` says yes in advance. What goes is hours
|
|
681
771
|
* and tokens per day, filed as history (never verified hours, never text).
|
|
682
772
|
*/
|
|
683
|
-
async function offerHistory(paths, token, devicePem, url = MCP, rebuild = false) {
|
|
773
|
+
async function offerHistory(paths, token, devicePem, url = MCP, rebuild = false, agreedInAdvance = false) {
|
|
684
774
|
const env = { WORKTRUST_MCP_URL: url, ...(devicePem ? { WORKTRUST_DEVICE_KEY: devicePem } : {}) };
|
|
685
775
|
const counted = await run(paths["log-session.mjs"], ["--history", "--dry-run", "--summary"], token, true, env);
|
|
686
776
|
let found = null;
|
|
@@ -698,7 +788,7 @@ async function offerHistory(paths, token, devicePem, url = MCP, rebuild = false)
|
|
|
698
788
|
say(" never deleted, so a day is counted once. Other computers, web sources and days not listed are not touched.");
|
|
699
789
|
}
|
|
700
790
|
if (has("dry-run")) { say(" Dry run: nothing was sent."); return; }
|
|
701
|
-
if (!has("history") && !(rebuild ? await ask("Send them (re-measured; this computer's earlier lines for these days are replaced, a day is counted once)?", false) : await ask("Send these as history (hours and tokens per day; never text)?", false))) { historyDone(false); say(" Not sent. Send them later with: npx worktrust"); return; }
|
|
791
|
+
if (!has("history") && !agreedInAdvance && !(rebuild ? await ask("Send them (re-measured; this computer's earlier lines for these days are replaced, a day is counted once)?", false) : await ask("Send these as history (hours and tokens per day; never text)?", false))) { historyDone(false); say(" Not sent. Send them later with: npx worktrust"); return; }
|
|
702
792
|
// Marked unfinished before the first batch leaves (0.10.9): a send stopped halfway (Ctrl+C, a closed lid) is finished by the next run.
|
|
703
793
|
historyDone(false);
|
|
704
794
|
const sent = await run(paths["log-session.mjs"], ["--history", ...(rebuild ? ["--rebuild"] : []), ...(has("retry-review") ? ["--retry-review"] : [])], token, true, env);
|
|
@@ -731,21 +821,42 @@ async function offerHistory(paths, token, devicePem, url = MCP, rebuild = false)
|
|
|
731
821
|
const stableVersion = () => { try { const installed = JSON.parse(readFileSync(join(HOME_DIR, "installed-release.json"), "utf8")); if (/^\d+\.\d+\.\d+$/.test(installed.version)) return installed.version; } catch { /* older registration */ } try { return /const CLI_VERSION = "([^"]+)";/.exec(readFileSync(STABLE_FILE, "utf8"))?.[1] ?? null; } catch { return null; } };
|
|
732
822
|
|
|
733
823
|
/**
|
|
734
|
-
*
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
|
|
824
|
+
* THE RULES AN EARLIER CLI MEASURED BY (0.10.31). Recorded since 0.10.31 (installed-release.json, history.json, or the
|
|
825
|
+
* stable copy's own MEASURE_RULES); before that, read from its version: 0.10.29 and 0.10.30 measured by rules 1, anything
|
|
826
|
+
* older by earlier rules (0). Null when the version is unknown too.
|
|
827
|
+
*/
|
|
828
|
+
const rulesOf = (record) => (Number.isInteger(record?.measureRules) && record.measureRules >= 0 ? record.measureRules
|
|
829
|
+
: typeof record?.version === "string" && /^\d+\.\d+\.\d+$/.test(record.version) ? (record.version.split(".").map(Number).reduce((order, part, at) => order || Math.sign(part - [0, 10, 29][at]), 0) < 0 ? 0 : 1) : null);
|
|
830
|
+
/** The stable copy's version and measure rules, what this computer ran before an update; both null without one. */
|
|
831
|
+
function stableInstall() {
|
|
832
|
+
const version = stableVersion();
|
|
833
|
+
if (!version) return { version: null, rules: null };
|
|
834
|
+
try { const installed = JSON.parse(readFileSync(join(HOME_DIR, "installed-release.json"), "utf8")); if (installed.version === version && rulesOf(installed) !== null) return { version, rules: rulesOf(installed) }; } catch { /* older registration */ }
|
|
835
|
+
try { const own = /const MEASURE_RULES = (\d+);/.exec(readFileSync(STABLE_FILE, "utf8"))?.[1]; if (own) return { version, rules: Number(own) }; } catch { /* no stable copy */ }
|
|
836
|
+
return { version, rules: rulesOf({ version }) };
|
|
837
|
+
}
|
|
838
|
+
/** What changed between two measure-rules versions, in MEASURE_CHANGES' words, oldest first. */
|
|
839
|
+
const measureChanges = (from, to) => Object.keys(MEASURE_CHANGES).map(Number).filter((rules) => rules > Math.min(from, to) && rules <= Math.max(from, to)).sort((x, y) => x - y).flatMap((rules) => MEASURE_CHANGES[rules]);
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* OFFERED ONCE, BY `update`, IN PLAIN WORDS (owner, 2026-10-07): when the computer's earlier lines were measured by OTHER
|
|
843
|
+
* RULES than this CLI's (0.10.31: the measure-rules version, not the CLI version; 0.10.30 offered on every version and
|
|
844
|
+
* invited a re-send of history measured exactly as before). The CLI cannot read the record, so it is an offer, not a
|
|
845
|
+
* finding: the plan is shown and the question asked by the same path as `history --rebuild`; Enter is No. The offer
|
|
846
|
+
* names what changed. The same rules updated again offer nothing.
|
|
738
847
|
*/
|
|
739
|
-
async function offerRebuild(
|
|
740
|
-
if (!
|
|
848
|
+
async function offerRebuild(previous, paths, key) {
|
|
849
|
+
if (!previous?.version || previous.rules === null || previous.rules === MEASURE_RULES) return;
|
|
850
|
+
const changes = measureChanges(previous.rules, MEASURE_RULES);
|
|
741
851
|
say();
|
|
742
|
-
say(` This computer's earlier lines in WorkTrust were measured by worktrust ${
|
|
743
|
-
say(
|
|
744
|
-
|
|
745
|
-
say(" sessions still on this computer and have WorkTrust replace this computer's earlier lines,
|
|
746
|
-
say(" a day twice. Later: npx worktrust");
|
|
747
|
-
|
|
748
|
-
|
|
852
|
+
say(` This computer's earlier lines in WorkTrust were measured by worktrust ${previous.version}. Version ${CLI_VERSION} measures`);
|
|
853
|
+
say(changes.length > 0 ? " differently:" : " differently.");
|
|
854
|
+
for (const change of changes) say(` · ${change}`);
|
|
855
|
+
say(" You can re-measure the sessions still on this computer and have WorkTrust replace this computer's earlier lines,");
|
|
856
|
+
say(" day by day, never counting a day twice. Later: npx worktrust");
|
|
857
|
+
// ONE QUESTION, AFTER THE PLAN (0.10.30): counting the plan reads this computer only and sends nothing, so it is shown
|
|
858
|
+
// first and the send is asked once, Enter is No; `--rebuild` agrees in advance, --yes alone never does.
|
|
859
|
+
await offerHistory(paths, key.token, key.device ?? null, key.url, true, has("rebuild"));
|
|
749
860
|
}
|
|
750
861
|
|
|
751
862
|
/**
|
|
@@ -754,11 +865,12 @@ async function offerRebuild(previousVersion, paths, key) {
|
|
|
754
865
|
*/
|
|
755
866
|
const HISTORY_STATE = join(HOME_DIR, "history.json");
|
|
756
867
|
function historyDone(complete) {
|
|
757
|
-
try { ensureHome(); writeFileSync(HISTORY_STATE, JSON.stringify({ version: CLI_VERSION, at: new Date().toISOString(), complete }), { mode: 0o600 }); } catch { /* the next run asks again */ }
|
|
868
|
+
try { ensureHome(); writeFileSync(HISTORY_STATE, JSON.stringify({ version: CLI_VERSION, measureRules: MEASURE_RULES, at: new Date().toISOString(), complete }), { mode: 0o600 }); } catch { /* the next run asks again */ }
|
|
758
869
|
}
|
|
759
|
-
/** Complete AND measured by this
|
|
760
|
-
* measured by
|
|
761
|
-
|
|
870
|
+
/** Complete AND measured by this CLI's rules (0.10.9; the rules, not the version, since 0.10.31): a run stopped after the
|
|
871
|
+
* update, before the history, leaves the history measured by older rules, and the next run must offer it again rather
|
|
872
|
+
* than read "complete" as done. A version that measures as the one before finds its history done. */
|
|
873
|
+
const historyComplete = () => { try { const state = JSON.parse(readFileSync(HISTORY_STATE, "utf8")); return state.complete === true && rulesOf(state) === MEASURE_RULES; } catch { return false; } };
|
|
762
874
|
|
|
763
875
|
/**
|
|
764
876
|
* THE SAME COMMAND AGAIN DOES WHAT IS LEFT (0.10.5). On a computer already coupled, `npx worktrust@latest` brings it onto
|
|
@@ -971,17 +1083,24 @@ async function offerCodex() {
|
|
|
971
1083
|
say(" Codex takes one, so it stays as it is; Codex sessions are still sent whenever the Claude Code hook runs.");
|
|
972
1084
|
return;
|
|
973
1085
|
}
|
|
974
|
-
|
|
975
|
-
|
|
1086
|
+
// AGREED BEFORE (0.10.30): WorkTrust's own line, already said yes to, whose launcher path moved: refreshed without a question.
|
|
1087
|
+
const agreed = await consent(), known = Boolean(found.text) && agreed.has("codex-notify");
|
|
1088
|
+
if (known) say(` ✓ Codex wakes the session hook: refreshed (${agreed.said("codex-notify")}).`);
|
|
1089
|
+
else {
|
|
1090
|
+
say(" Codex can wake the session hook at the end of every turn, so Codex work arrives without Claude Code running:");
|
|
1091
|
+
say(` ${found.text ? "↻" : "+"} ${CODEX_CONFIG} → ${want}`);
|
|
1092
|
+
}
|
|
976
1093
|
if (has("dry-run")) { say(" Dry run: nothing was written."); return; }
|
|
977
|
-
if (!has("codex") &&
|
|
1094
|
+
if (!known && !has("codex") && has("yes")) { say(" Not set (skipped: new, run without --yes to decide)."); return; }
|
|
1095
|
+
if (!known && !has("codex") && !(await ask("Let Codex wake the session hook?", false))) { agreed.drop("codex-notify"); say(" Not set. npx worktrust update asks again."); return; }
|
|
978
1096
|
await prepareBundledRuntime(); want = desired();
|
|
979
1097
|
const rows = [...found.rows];
|
|
980
1098
|
if (found.text) rows.splice(found.at, found.end - found.at + 1, want);
|
|
981
1099
|
else rows.splice(found.insert, 0, ...(found.insert < rows.length && rows[found.insert] !== "" ? [want, ""] : [want]));
|
|
982
1100
|
if (rows.at(-1) !== "") rows.push("");
|
|
983
1101
|
writeCodex(rows);
|
|
984
|
-
|
|
1102
|
+
agreed.agree("codex-notify", has("codex") ? "flag" : "typed");
|
|
1103
|
+
say(known ? " Restart Codex to pick it up; the earlier file is kept as config.toml.worktrust-backup." : " ✓ Codex wakes the session hook. Restart Codex to pick it up; the earlier file is kept as config.toml.worktrust-backup.");
|
|
985
1104
|
}
|
|
986
1105
|
|
|
987
1106
|
/**
|
|
@@ -1014,13 +1133,20 @@ async function offerAntigravity() {
|
|
|
1014
1133
|
say();
|
|
1015
1134
|
if (hooks === null) { say(` ${AGY_HOOKS} is not readable JSON, so it is left as it is; Antigravity sessions are still sent whenever another hook runs.`); return; }
|
|
1016
1135
|
if (JSON.stringify(hooks.worktrust) === JSON.stringify(want)) { say(" ✓ Antigravity already wakes the session hook when its agent stops."); return; }
|
|
1017
|
-
|
|
1018
|
-
|
|
1136
|
+
// AGREED BEFORE (0.10.30): WorkTrust's own hook, already said yes to, whose launcher path moved: refreshed without a question.
|
|
1137
|
+
const agreed = await consent(), known = Boolean(hooks.worktrust) && agreed.has("antigravity-stop");
|
|
1138
|
+
if (known) say(` ✓ Antigravity wakes the session hook: refreshed (${agreed.said("antigravity-stop")}).`);
|
|
1139
|
+
else {
|
|
1140
|
+
say(" Antigravity can wake the session hook when its agent stops, so Antigravity work arrives without Claude Code running:");
|
|
1141
|
+
say(` ${hooks.worktrust ? "↻" : "+"} ${AGY_HOOKS} → worktrust: Stop runs ${want.Stop[0].command}`);
|
|
1142
|
+
}
|
|
1019
1143
|
if (has("dry-run")) { say(" Dry run: nothing was written."); return; }
|
|
1020
|
-
if (!has("antigravity") &&
|
|
1144
|
+
if (!known && !has("antigravity") && has("yes")) { say(" Not set (skipped: new, run without --yes to decide)."); return; }
|
|
1145
|
+
if (!known && !has("antigravity") && !(await ask("Let Antigravity wake the session hook?", false))) { agreed.drop("antigravity-stop"); say(" Not set. npx worktrust update asks again."); return; }
|
|
1021
1146
|
await prepareBundledRuntime(); want = desired();
|
|
1022
1147
|
writeAgyHooks({ ...hooks, worktrust: want });
|
|
1023
|
-
|
|
1148
|
+
agreed.agree("antigravity-stop", has("antigravity") ? "flag" : "typed");
|
|
1149
|
+
say(` ${known ? " Restart" : "✓ Antigravity wakes the session hook. Restart"} Antigravity to pick it up${existsSync(`${AGY_HOOKS}.worktrust-backup`) ? "; the earlier file is kept as hooks.json.worktrust-backup" : ""}.`);
|
|
1024
1150
|
}
|
|
1025
1151
|
/** Disconnect takes the hook named worktrust out of Antigravity's hooks, and nothing else. */
|
|
1026
1152
|
function removeAntigravityHook() {
|
|
@@ -1049,7 +1175,7 @@ async function disconnect() {
|
|
|
1049
1175
|
const plan = await run(paths["setup-mcp.mjs"], ["--remove"], PLACEHOLDER, true);
|
|
1050
1176
|
say(" 1. The WorkTrust door comes out of every AI app here:");
|
|
1051
1177
|
for (const line of planLines(plan.out)) say(line);
|
|
1052
|
-
say(" 2. The session hook comes out of ~/.claude/settings.json (and Codex's notify line and Antigravity's worktrust hook, when WorkTrust set them), credentials are removed (an encrypted empty slot keeps the OS-vault preference)");
|
|
1178
|
+
say(" 2. The session hook comes out of ~/.claude/settings.json (and Codex's notify line and Antigravity's worktrust hook, when WorkTrust set them), credentials are removed (an encrypted empty slot keeps the OS-vault preference), and so is the record of what you agreed to (consent.json)");
|
|
1053
1179
|
say(" but for one note of which account this computer fed (masked), so a later coupling by another account starts clean.");
|
|
1054
1180
|
say(" 3. The key itself stays valid until you revoke it: WorkTrust → Sources → Devices → this computer → Revoke.");
|
|
1055
1181
|
say();
|
|
@@ -1063,6 +1189,8 @@ async function disconnect() {
|
|
|
1063
1189
|
if (removeAntigravityHook()) say(" ✓ Antigravity no longer wakes the session hook.");
|
|
1064
1190
|
previousNote.save(keyStore.load());
|
|
1065
1191
|
keyStore.erase();
|
|
1192
|
+
eraseConsent(); // 0.10.30: what was agreed goes with the coupling; a later connect asks again
|
|
1193
|
+
|
|
1066
1194
|
// Everything of ours on this computer goes; the folder too, when nothing else is left in it.
|
|
1067
1195
|
for (const name of [STABLE_FILE, ...SCRIPTS.map((script) => join(HOME_DIR, downloaded(script))), join(HOME_DIR, "pinned")]) { try { rmSync(name); } catch { /* gone */ } }
|
|
1068
1196
|
try { rmSync(HOME_DIR, { recursive: false }); } catch { /* not empty, or gone */ }
|
|
@@ -1112,21 +1240,13 @@ async function mod() {
|
|
|
1112
1240
|
}
|
|
1113
1241
|
|
|
1114
1242
|
async function status() {
|
|
1115
|
-
const
|
|
1116
|
-
try {
|
|
1117
|
-
const config = JSON.parse(readFileSync(join(homedir(), ".claude.json"), "utf8"));
|
|
1118
|
-
Object.assign(servers, config.mcpServers ?? {});
|
|
1119
|
-
for (const project of Object.values(config.projects ?? {})) Object.assign(servers, project.mcpServers ?? {});
|
|
1120
|
-
} catch { /* no Claude Code here */ }
|
|
1121
|
-
const door = Object.entries(servers).find(([name, server]) => /worktrust/i.test(`${name} ${server?.url ?? ""} ${(server?.args ?? []).join(" ")}`));
|
|
1243
|
+
const door = claudeDoorHere();
|
|
1122
1244
|
say(door ? ` Claude Code: coupled (${door[1].url ?? "through the local bridge"})` : " Claude Code: not coupled. Run `npx worktrust connect`.");
|
|
1123
1245
|
const key = keyStore.load();
|
|
1124
1246
|
say(` Credential storage: ${keyStore.protected() ? "OS vault + encrypted local file" : "private local file; use worktrust protect-key after updating"}`);
|
|
1125
1247
|
say(key ? ` Key: in ${KEY_PLACE}, ${key.device ? "bound to this computer, " : ""}last renewed ${String(key.renewedAt ?? "").slice(0, 10) || "never"}` : " Key: not on this computer (or written into the apps' settings with --direct)");
|
|
1126
1248
|
if (key) say(key.account ? ` Account: ${key.account}${key.coupledAt ? `, coupled ${String(key.coupledAt).slice(0, 10)}` : ""}` : " Account: not recorded (coupled by an older version; `npx worktrust connect` records it)");
|
|
1127
|
-
|
|
1128
|
-
try { hook = /log-session|worktrust(?:-launch)?\.(?:mjs|py)\\?" hook/.test(readFileSync(join(homedir(), ".claude", "settings.json"), "utf8")); } catch { /* none */ }
|
|
1129
|
-
say(hook ? " Session hook: installed" : " Session hook: not installed");
|
|
1249
|
+
say(sessionHookHere() ? " Session hook: installed" : " Session hook: not installed");
|
|
1130
1250
|
if (existsSync(join(homedir(), ".codex"))) { const notify = codexNotify().text ?? ""; say(isOurNotify(notify) ? " Codex: wakes the session hook" : " Codex: does not wake the session hook (npx worktrust update asks)"); }
|
|
1131
1251
|
if (existsSync(join(homedir(), ".hermes"))) { let text = ""; try { text = readFileSync(join(homedir(), ".hermes", "config.yaml"), "utf8"); } catch { /* none */ } say(/worktrust(?:-launch)?\.(?:mjs|py)\\?" hook --hermes/.test(text) ? " Hermes Agent: wakes the session hook" : " Hermes Agent: does not wake the session hook (npx worktrust update writes it)"); }
|
|
1132
1252
|
if (antigravityHere()) say(agyHooks()?.worktrust ? " Antigravity: wakes the session hook" : " Antigravity: does not wake the session hook (npx worktrust update asks)");
|
|
@@ -1189,7 +1309,11 @@ function help() {
|
|
|
1189
1309
|
say(" --direct put the key in each app's settings instead of the key file");
|
|
1190
1310
|
say(" worktrust connect couple again, also when this computer is already coupled (asks first)");
|
|
1191
1311
|
say(" --replace yes in advance to coupling a computer that is already coupled");
|
|
1192
|
-
say(" worktrust update this computer onto the newest CLI: same key, no new pairing");
|
|
1312
|
+
say(" worktrust update this computer onto the newest CLI: same key, no new pairing; what you agreed to before is");
|
|
1313
|
+
say(" refreshed without a question, a new AI app or hook is asked about (--yes: skipped)");
|
|
1314
|
+
say(" --rebuild yes in advance to the re-measure update offers after a new version (the plan is still shown)");
|
|
1315
|
+
say(" --codex yes in advance to letting Codex wake the session hook (also for connect)");
|
|
1316
|
+
say(" --antigravity yes in advance to letting Antigravity wake the session hook (also for connect)");
|
|
1193
1317
|
say(" worktrust history send this computer's earlier sessions as history (asks first)");
|
|
1194
1318
|
say(" --resume retry saved metadata batches, even if source files are gone (asks first)");
|
|
1195
1319
|
say(" --retry-review explicitly retry held batches after support resolves their review");
|