worktrust 0.11.8 → 0.11.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/LICENSE +5 -0
- package/README.md +54 -26
- package/cli-look.mjs +192 -0
- package/cli-menu-remote.mjs +153 -53
- package/cli-menu.mjs +168 -69
- package/engine-release.json +1 -1
- package/log-session.mjs +6 -169
- package/package-release.json +1 -1
- package/package.json +3 -1
- package/remote-adapter-claude-code.mjs +30 -4
- package/remote-adapter-terminal.mjs +4 -3
- package/remote-cli.mjs +22 -44
- package/remote-connections.mjs +55 -1
- package/remote-pairing.mjs +42 -4
- package/remote-qr.mjs +40 -15
- package/remote-run.mjs +7 -5
- package/remote-store.mjs +10 -0
- package/session-readers.mjs +202 -0
- package/worktrust.mjs +98 -31
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
The WorkTrust CLI, newest first. What the tool is and how to use it: [README.md](README.md).
|
|
4
4
|
|
|
5
|
+
## 0.11.10: one scan to connect, a look before you sign in, and no release from a phone
|
|
6
|
+
|
|
7
|
+
**One QR connects a computer.** `npx -y worktrust remote app` draws one code. Scanned in the WorkTrust app (Scan ›
|
|
8
|
+
Connect agent, or Add connection), it approves this computer with your authenticator code and links that phone in the
|
|
9
|
+
same pass. The button says so ("Approve and link this phone"), and a computer you link while another is already linked is
|
|
10
|
+
not chosen for you. A code opened with the phone's camera or in a browser only approves; the phone is linked by a second
|
|
11
|
+
code a moment later. The printed link no longer carries the pairing secret (`--show-link` prints it whole), and
|
|
12
|
+
`--no-pair` links nothing. Remote Agent uses WorkTrust's gateway by default, so `remote pair` and the service work on a
|
|
13
|
+
computer approved without `--gateway`, where they said "no gateway" before. Every QR is drawn more compactly: about a
|
|
14
|
+
sixth fewer lines for the pairing code.
|
|
15
|
+
|
|
16
|
+
**Look at this computer.** `npx worktrust look`, the first row before you sign in, counts what your AI apps recorded
|
|
17
|
+
here: sessions per app, the first and last day, or that a store could not be read. It sends nothing, writes nothing and
|
|
18
|
+
makes no network call. Then you connect and send them, or preserve them here.
|
|
19
|
+
|
|
20
|
+
**No release from a phone.** A session steered from your phone can no longer run a ship script, a deploy script, `psql`
|
|
21
|
+
or a release through `gh`, whatever your own desk settings allow; this computer's keyboard keeps every one of them.
|
|
22
|
+
|
|
23
|
+
**Clearer lines and a steady screen.** Check this computer says which files its test count reads (a file once per
|
|
24
|
+
stretch) and how many stretches are not classed. A window resized while the menu is open no longer clears a command's
|
|
25
|
+
output above it, such as a QR you still need. When Remote Agent is part of Premium for an account, the menu says so and
|
|
26
|
+
offers the upgrade page; the summary names the account type. The licence names whom to contact for any use it does not
|
|
27
|
+
allow. Nothing it measures changes: the measure rules stay 4.
|
|
28
|
+
|
|
29
|
+
## 0.11.9: a first menu, one row per item, and nothing you can do twice
|
|
30
|
+
|
|
31
|
+
**A short menu until this computer is connected.** `npx -y worktrust` on a computer that is not connected yet opens
|
|
32
|
+
Connect this computer, Preserve evidence, Help and Quit, and nothing that needs a connected computer. Connect is the
|
|
33
|
+
same sign-in as `worktrust connect`: it shows the plan, asks before it writes, and your browser signs in. The moment it
|
|
34
|
+
succeeds the full menu is there, without running anything again; if it stops, the short menu stays and says why in one
|
|
35
|
+
line. Preserve needs no account and is whole in both menus.
|
|
36
|
+
|
|
37
|
+
**An update that is not needed cannot be run again.** When this computer runs this version and npm has none newer, the
|
|
38
|
+
Update row is still drawn, dimmed, reading `up to date (0.11.9)`, and cannot be chosen: the arrows pass it and its digit
|
|
39
|
+
answers `Already up to date.` When npm could not be asked, the row says `newest not checked` and claims nothing.
|
|
40
|
+
`npx worktrust update` on a computer that is already on this version, with nothing waiting (every AI app's door
|
|
41
|
+
standing, nothing new to agree to), answers `Already up to date (0.11.9). Nothing changed.`; before, it took every door
|
|
42
|
+
out and put it back and said `7 added`. `update --force` sets everything up again all the same.
|
|
43
|
+
|
|
44
|
+
**One row per item.** Number, action, command and explanation stand on one line where the terminal is wide enough; on a
|
|
45
|
+
narrower one (80 columns) the chosen row's explanation has one fixed line under the list. No row moves when you move,
|
|
46
|
+
no sentence is cut, and every sentence was rewritten to 60 characters or fewer. Under 60 columns the command column goes.
|
|
47
|
+
|
|
48
|
+
**Remote Agent asks for the approval first.** Until this computer is approved, Approve this computer is first, and what
|
|
49
|
+
cannot work before it (Link a phone, Projects, Roots, Connections, Pause) is dimmed, marked `not yet`, and cannot be
|
|
50
|
+
chosen. Approved from inside the menu, the list opens at once with the cursor on Link a phone.
|
|
51
|
+
|
|
52
|
+
**A summary above the menu, Sharing, and the linked devices.** A connected computer's head says the account, this
|
|
53
|
+
computer and since when, Remote Agent with its connections, and what this computer shares; all from its own files, never
|
|
54
|
+
the key. Sharing › holds the switches that exist (`mcp off | on`, Remote Agent's pause) and says that the session hook has
|
|
55
|
+
none in the CLI. Remote Agent › Connections is a table (name, kind, since, last activity); Disconnect runs
|
|
56
|
+
`remote disconnect` with the confirmation you type, as before.
|
|
57
|
+
|
|
58
|
+
**Esc quits at the top**, like q, and goes back one level below it.
|
|
59
|
+
|
|
60
|
+
**`-y` where a first command is shown.** The README, the app and the site show `npx -y worktrust` and
|
|
61
|
+
`npx -y worktrust@latest …`, so npm's own `Ok to proceed?` is answered in advance.
|
|
62
|
+
|
|
5
63
|
## 0.11.8: the menu says more, stays in one place, and uses colour with meaning
|
|
6
64
|
|
|
7
65
|
**Update comes first, and says whether there is something to update.** The menu now opens on Update WorkTrust, then Check
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
WorkTrust CLI Licence
|
|
2
2
|
|
|
3
3
|
Version 1.1, in force from WorkTrust CLI version 0.10.39 (7 November 2026).
|
|
4
|
+
The WorkTrust CLI Licence has applied since WorkTrust CLI version 0.10.18
|
|
5
|
+
(17 October 2026); see section 5 for earlier versions.
|
|
4
6
|
|
|
5
7
|
Copyright (c) 2026 Oravita B.V. (WorkTrust), registered with the Dutch Chamber of
|
|
6
8
|
Commerce (KvK) under number 98076051. All rights reserved.
|
|
@@ -89,6 +91,9 @@ Nothing in this licence restricts what mandatory law allows a lawful user of a
|
|
|
89
91
|
computer program to do, including the acts permitted by Articles 5 and 6 of
|
|
90
92
|
Directive 2009/24/EC as implemented in the Dutch Copyright Act (Auteurswet).
|
|
91
93
|
|
|
94
|
+
For any use this licence does not allow, including commercial use of the code
|
|
95
|
+
itself, contact Oravita B.V. by email at hello@worktrust.io.
|
|
96
|
+
|
|
92
97
|
4. Ownership and all rights reserved
|
|
93
98
|
|
|
94
99
|
The Software is licensed, not sold. Oravita B.V. (WorkTrust) retains all right,
|
package/README.md
CHANGED
|
@@ -21,12 +21,14 @@ hiring instrument.
|
|
|
21
21
|
## Install and first run
|
|
22
22
|
|
|
23
23
|
```sh
|
|
24
|
-
npx worktrust
|
|
24
|
+
npx -y worktrust
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
In your own terminal this opens the menu. On a computer that is not connected yet
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
In your own terminal this opens the menu. On a computer that is not connected yet it is a short one: Look at this
|
|
28
|
+
computer, Connect this computer, Preserve evidence, Help. Look lists, per AI app, the sessions its own files hold here and
|
|
29
|
+
their first and last day; it reads only, and sends and keeps nothing. Connect shows the plan, asks, and you approve the computer in your browser with your
|
|
30
|
+
own account and second factor; the moment that succeeds, the full menu is there. The `-y` answers npm's own question in
|
|
31
|
+
advance: without it npm may ask `Ok to proceed?` before WorkTrust starts.
|
|
30
32
|
|
|
31
33
|
**With Python instead.** The Python package runs the same CLI and brings its own Node, so it needs no Node on the computer:
|
|
32
34
|
|
|
@@ -53,42 +55,64 @@ and show the ways forward, each with its exact command:
|
|
|
53
55
|
|
|
54
56
|
Without a terminal nothing is asked and nothing runs: the same text is printed and the command ends with a failure code.
|
|
55
57
|
|
|
56
|
-
**Update.** `npx worktrust@latest update` brings this computer's hook and AI-app doors to the newest version. Your key and
|
|
57
|
-
pairing stay.
|
|
58
|
+
**Update.** `npx -y worktrust@latest update` brings this computer's hook and AI-app doors to the newest version. Your key and
|
|
59
|
+
pairing stay. On a computer that is already on that version, with nothing waiting, it says so and changes nothing;
|
|
60
|
+
`update --force` sets everything up again all the same.
|
|
58
61
|
|
|
59
62
|
**Stop.** `npx worktrust disconnect` takes WorkTrust out of every AI app here and removes the key. Then revoke the
|
|
60
63
|
computer in WorkTrust under Sources, Devices. More under [Undo](#undo).
|
|
61
64
|
|
|
62
65
|
## The menu
|
|
63
66
|
|
|
67
|
+
On a computer that is not connected yet:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
WorkTrust CLI 0.11.10
|
|
71
|
+
Not connected yet
|
|
72
|
+
|
|
73
|
+
> 1 Look at this computer npx worktrust look
|
|
74
|
+
2 Connect this computer npx worktrust connect
|
|
75
|
+
3 Preserve evidence › npx worktrust preserve …
|
|
76
|
+
4 Help · all commands npx worktrust help
|
|
77
|
+
5 Quit q
|
|
78
|
+
|
|
79
|
+
Reads what your AI apps recorded here. Nothing is sent.
|
|
80
|
+
|
|
81
|
+
↑/↓ move · Enter open · Esc quit · 1-9 jump
|
|
64
82
|
```
|
|
65
|
-
WorkTrust CLI 0.11.8
|
|
66
|
-
Connected as you@example.com · Remote Agent on
|
|
67
83
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
Once it is connected (80 columns; on a wide terminal each row's sentence stands on the row itself, as a fourth column):
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
WorkTrust CLI 0.11.10
|
|
88
|
+
Account you@example.com
|
|
89
|
+
This computer imac · connected since 2026-11-03
|
|
90
|
+
Remote Agent approved, 2 connections
|
|
91
|
+
Sharing session hook on · AI apps on (7) · Remote Agent approved
|
|
92
|
+
|
|
93
|
+
1 Update WorkTrust · up to date (0.11.10) npx worktrust update
|
|
94
|
+
> 2 Check this computer npx worktrust
|
|
72
95
|
3 Remote Agent › npx worktrust remote …
|
|
73
|
-
Opens the choices for steering this computer's agents from your phone. Nothing changes yet.
|
|
74
96
|
4 Import earlier history › npx worktrust history …
|
|
75
|
-
Opens the ways to send earlier sessions as history. Each one shows its plan and asks first.
|
|
76
97
|
5 Preserve evidence › npx worktrust preserve …
|
|
77
|
-
|
|
78
|
-
6 WorkTrust in your AI apps: On npx worktrust mcp off
|
|
79
|
-
Takes the WorkTrust door out of every AI app here; the session hook keeps measuring your hours.
|
|
98
|
+
6 Sharing › npx worktrust mcp …
|
|
80
99
|
7 Status npx worktrust status
|
|
81
|
-
Shows the key, the hook, the door and what this computer measured. It only reads.
|
|
82
100
|
8 Disconnect this computer npx worktrust disconnect
|
|
83
|
-
Takes WorkTrust out of every AI app here and ends this computer's key. It asks first.
|
|
84
101
|
9 Help · all commands npx worktrust help
|
|
85
|
-
Lists every command and option. Tip: npx -y worktrust skips npm's own "Ok to proceed?" question.
|
|
86
102
|
Quit q
|
|
87
|
-
Leaves the menu. Nothing keeps running.
|
|
88
103
|
|
|
89
|
-
|
|
104
|
+
Shows what is coupled here and finishes what waits.
|
|
105
|
+
|
|
106
|
+
↑/↓ move · Enter open · Esc quit · 1-9 jump
|
|
90
107
|
```
|
|
91
108
|
|
|
109
|
+
One row per item, and no row moves when you move. A row that cannot be chosen is dimmed and says why in words: Update
|
|
110
|
+
when there is nothing to update, and most of Remote Agent until this computer is approved for it. The summary above the
|
|
111
|
+
menu comes from this computer's own files; it never shows the key. Sharing › says what this computer sends and holds the
|
|
112
|
+
switches that exist: `mcp off | on` and Remote Agent's pause. Remote Agent › Connections lists every linked phone and
|
|
113
|
+
browser, and disconnecting one runs `remote disconnect` with its typed confirmation. Esc quits at the top and goes back
|
|
114
|
+
one level below it.
|
|
115
|
+
|
|
92
116
|
Every item shows the command it runs, so you can type it next time. Without a terminal (a script, a hook, the MCP door)
|
|
93
117
|
there is no menu and nothing waits for a key.
|
|
94
118
|
|
|
@@ -98,10 +122,11 @@ there is no menu and nothing waits for a key.
|
|
|
98
122
|
|---|---|
|
|
99
123
|
| `npx worktrust` | In your terminal: the menu. Without a terminal, or with any option: connects this computer (shows the plan, asks, you approve in your browser), or shows what is connected. |
|
|
100
124
|
| `npx worktrust connect` | Connects this computer again, also when it is already connected. Asks first. |
|
|
101
|
-
| `npx worktrust update` | Brings this computer onto the newest CLI: same key, no new pairing. Something new is asked about. |
|
|
125
|
+
| `npx worktrust update` | Brings this computer onto the newest CLI: same key, no new pairing. Something new is asked about. Already there with nothing waiting: says so and changes nothing (`--force` sets it up again). |
|
|
102
126
|
| `npx worktrust history` | Sends this computer's earlier sessions as history. `--rebuild` measures them again, `--export <path>` reads a ChatGPT or Claude export, `--from-archive` and `--from-folder <dir>` read your own copies. Always shows the plan and asks. |
|
|
103
127
|
| `npx worktrust disconnect` | Takes WorkTrust out of every AI app here. Asks first. |
|
|
104
128
|
| `npx worktrust status` | Shows what is connected here. It only reads. |
|
|
129
|
+
| `npx worktrust look` | Shows what your AI apps recorded here: per app the sessions and their first and last day. Reads only; nothing is sent or kept, and no account is needed. |
|
|
105
130
|
| `npx worktrust project` | Sets a folder's mode: exclude (nothing read), confidential (hours and tokens count; no name, branch, path or commit is sent) or normal. `project list` shows them. |
|
|
106
131
|
| `npx worktrust remote` | Remote Agent: `app` or `web` approve this computer, `pair` links a phone, then `status`, `pause`, `resume`, `disable`, `connections`, `disconnect`, `projects`, `roots` and `modes`. |
|
|
107
132
|
| `npx worktrust mcp off` | Hours only: the WorkTrust door out of every AI app here. The session hook keeps measuring. |
|
|
@@ -382,7 +407,7 @@ agent runs it makes no difference: `preserve` writes to your own user's places (
|
|
|
382
407
|
`~/AI-Evidence`), so every terminal and agent on this computer under your user reaches the same archive, and lines
|
|
383
408
|
from different versions sit side by side, each naming the version that measured it. Another user on the same computer
|
|
384
409
|
gets an archive of their own. A coupled computer's session hook runs from its own copy in `~/.worktrust` and changes
|
|
385
|
-
with `npx worktrust@latest update`, or (from 0.10.37, installed from npm) when you turn CLI active back on for that
|
|
410
|
+
with `npx -y worktrust@latest update`, or (from 0.10.37, installed from npm) when you turn CLI active back on for that
|
|
386
411
|
computer in WorkTrust › Sources: it then updates itself, verified, the next time WorkTrust runs there (SECURITY.md,
|
|
387
412
|
"Updating itself when you turn it on"). The WorkTrust app says when a newer version is out.
|
|
388
413
|
|
|
@@ -708,7 +733,8 @@ Off until you run `npx worktrust remote app` (or `remote web`) at this keyboard;
|
|
|
708
733
|
that scanned it is confirmed; one that typed the code instead waits for `npx worktrust remote phones confirm`.
|
|
709
734
|
- Two roads to approve the computer's key: `npx worktrust remote app` shows the approval as a QR code here (no browser);
|
|
710
735
|
the WorkTrust app scans it and you approve with your authenticator code. `npx worktrust remote web` opens the approval
|
|
711
|
-
page in your browser. Both
|
|
736
|
+
page in your browser. Both use WorkTrust's gateway unless `--gateway` chooses another, and take `--device`; `remote
|
|
737
|
+
enable` (0.11.6 and before) is gone since 0.11.7.
|
|
712
738
|
- `projects add <folder>` grants a folder (its real path; never your home folder, the disk's root or a folder holding
|
|
713
739
|
keys, keychains, browser profiles or wallets). A phone starts agents only in granted folders, several at once (four by
|
|
714
740
|
default).
|
|
@@ -747,7 +773,7 @@ Off until you run `npx worktrust remote app` (or `remote web`) at this keyboard;
|
|
|
747
773
|
instead (off by default). A PIN reset in WorkTrust removes every browser link; phones keep theirs.
|
|
748
774
|
|
|
749
775
|
Remote needs Node 22.4 or later (the Python package bundles one). It connects to the WorkTrust gateway
|
|
750
|
-
(`wss://remote.worktrust.io`, live since 2026-11-09).
|
|
776
|
+
(`wss://remote.worktrust.io`, live since 2026-11-09), by default for everyone since 0.11.10.
|
|
751
777
|
|
|
752
778
|
## Requirements
|
|
753
779
|
|
|
@@ -769,6 +795,8 @@ with or without an account; every other feature is for WorkTrust account holders
|
|
|
769
795
|
only be installed and evaluated. The archives and files the CLI makes from your own data are yours.
|
|
770
796
|
Version 1.1 of the licence applies from 0.10.39; 0.10.18 to 0.10.38 were published under version 1.0; versions up to and
|
|
771
797
|
including 0.10.17 were published under the MIT licence and stay under it.
|
|
798
|
+
For any use the licence does not allow, including commercial use of the code itself, contact Oravita B.V. by email at
|
|
799
|
+
hello@worktrust.io.
|
|
772
800
|
|
|
773
801
|
## Release signatures and the limits of verification
|
|
774
802
|
|
package/cli-look.mjs
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LOOK AT THIS COMPUTER (`npx worktrust look`, CLI 0.11.10; owner, 2026-11-14): the first thing a person can do, before any
|
|
3
|
+
* account. Per AI app the readers know, how many SESSIONS its own files on this computer hold, and the first and the last
|
|
4
|
+
* day; a total line. COUNTS ONLY: sessions, apps, days. No hours, no level, no score, no tokens: hours are measured by
|
|
5
|
+
* WorkTrust from what the hook sends, and a figure counted here would differ from the verified one.
|
|
6
|
+
*
|
|
7
|
+
* It finds and reads sessions with the hook's own readers (session-readers.mjs, transcript-readers.mjs,
|
|
8
|
+
* session-databases.mjs), an excluded project skipped before a file is opened, exactly as the hook skips it. A session is a
|
|
9
|
+
* session file (or a database client's session) with at least one timestamped turn; a day is a UTC date, as the hook cuts
|
|
10
|
+
* days. Three states per app, never two: none found; found N (and how many could not be read); could not read. An app that
|
|
11
|
+
* is not on this computer is left out.
|
|
12
|
+
*
|
|
13
|
+
* IT WRITES NOTHING AND SENDS NOTHING: no key, no file, no cache, no consent record, no network call
|
|
14
|
+
* (scripts/test-cli-look.mjs runs it with every file write and every network function made to throw).
|
|
15
|
+
*
|
|
16
|
+
* measuredLines (0.11.10): the lines `Check this computer` prints from the hook's --evidence-summary, pure so a test reads
|
|
17
|
+
* them; what the two misleading lines count is now said in their words.
|
|
18
|
+
*/
|
|
19
|
+
import { readdirSync, statSync } from "node:fs";
|
|
20
|
+
import { createRequire } from "node:module";
|
|
21
|
+
import { homedir } from "node:os";
|
|
22
|
+
import { join } from "node:path";
|
|
23
|
+
import { projectModeOf, readProjectModes } from "./project-modes.mjs";
|
|
24
|
+
import { READ_FAILURES, sessionFinders, transcriptLines } from "./session-readers.mjs";
|
|
25
|
+
|
|
26
|
+
const readers = (await import("./transcript-readers.mjs").catch(() => null)) ?? {};
|
|
27
|
+
const databases = (await import("./session-databases.mjs").catch(() => null)) ?? {};
|
|
28
|
+
const localModels = (await import("./session-local-models.mjs").catch(() => null)) ?? {};
|
|
29
|
+
|
|
30
|
+
const isDir = (path) => { try { return statSync(path).isDirectory(); } catch { return false; } };
|
|
31
|
+
/** A folder that is there and cannot be listed: its app's sessions could not be read. */
|
|
32
|
+
const unlistable = (path) => { if (!isDir(path)) return false; try { readdirSync(path); return false; } catch { return true; } };
|
|
33
|
+
/** Whether this Node can open the database clients' stores (node:sqlite, Node 22.5+), asked without opening one. */
|
|
34
|
+
const sqliteHere = () => { const warn = process.emitWarning; try { process.emitWarning = () => {}; createRequire(import.meta.url)("node:sqlite"); return true; } catch { return false; } finally { process.emitWarning = warn; } };
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The apps the readers know, in the order the table shows them. `here`: whether the app is on this computer (its own folder);
|
|
38
|
+
* `roots`: the folders whose listing must work for its sessions to be read; `database`: read through node:sqlite.
|
|
39
|
+
*/
|
|
40
|
+
const homesOf = (fn) => (typeof fn === "function" ? fn() : []);
|
|
41
|
+
export const LOOK_APPS = [
|
|
42
|
+
{ key: "claude", name: "Claude Code", here: () => isDir(join(homedir(), ".claude")), roots: () => [join(homedir(), ".claude", "projects")] },
|
|
43
|
+
{ key: "codex", name: "Codex", here: () => isDir(join(homedir(), ".codex")), roots: () => [join(homedir(), ".codex", "sessions")] },
|
|
44
|
+
{ key: "antigravity", name: "Antigravity", here: () => Boolean(readers.antigravityHere?.()), roots: () => homesOf(readers.antigravityRoots).map((root) => join(root, "brain")) },
|
|
45
|
+
{ key: "cursor", name: "Cursor", database: true, here: () => homesOf(databases.cursorHomes).some(isDir) },
|
|
46
|
+
{ key: "copilot", name: "Copilot in VS Code", database: true, here: () => homesOf(databases.copilotHomes).some(isDir) },
|
|
47
|
+
{ key: "gemini-cli", name: "Gemini CLI", database: true, here: () => homesOf(databases.geminiHomes).some((home) => isDir(join(home, "tmp"))) },
|
|
48
|
+
{ key: "opencode", name: "OpenCode", database: true, here: () => homesOf(databases.opencodeHomes).some(isDir) },
|
|
49
|
+
{ key: "hermes", name: "Hermes Agent", database: true, here: () => Boolean(databases.hermesHere?.()) },
|
|
50
|
+
{ key: "goose", name: "Goose", database: true, here: () => homesOf(databases.gooseHomes).some(isDir) },
|
|
51
|
+
{ key: "openclaw", name: "OpenClaw", database: true, here: () => isDir(process.env.OPENCLAW_STATE_DIR || join(homedir(), ".openclaw")) },
|
|
52
|
+
{ key: "ollama", name: "Ollama", database: true, here: () => homesOf(localModels.ollamaHomes).some(isDir) },
|
|
53
|
+
{ key: "open-webui", name: "Open WebUI", database: true, here: () => homesOf(localModels.openWebuiHomes).some(isDir) },
|
|
54
|
+
];
|
|
55
|
+
/** A found session's app, by the id the finders give it: Claude Code's carry no prefix, every other client's names it. */
|
|
56
|
+
const appOf = (id) => /^([a-z][a-z-]*):/.exec(String(id))?.[1] ?? "claude";
|
|
57
|
+
const dayOf = (ms) => new Date(ms).toISOString().slice(0, 10);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* What the AI apps on this computer recorded: { apps: [{ key, name, state, sessions, unreadable, first, last, why }], total }.
|
|
61
|
+
* `state`: "none" | "found" | "unreadable". `progress(name)` is told each app as its sessions are read. Reads only.
|
|
62
|
+
*/
|
|
63
|
+
export function lookAt({ progress = null } = {}) {
|
|
64
|
+
const present = LOOK_APPS.filter((app) => { try { return app.here(); } catch { return false; } });
|
|
65
|
+
const rows = new Map(present.map((app) => [app.key, { key: app.key, name: app.name, state: "none", sessions: 0, unreadable: 0, first: null, last: null, why: null }]));
|
|
66
|
+
const modes = readProjectModes(), excluded = (path) => projectModeOf(path, modes) === "exclude";
|
|
67
|
+
const { CODEX_ROLLOUT = /(?!)/, codexIdOf = (file) => String(file).split(/[\\/]/).at(-1).replace(/\.jsonl$/, ""), antigravityIdOf = (file) => String(file).split(/[\\/]/).at(-4), codexLines, codexRolloutFiles = function* () {}, codexCwd = () => null, ANTIGRAVITY_TRANSCRIPT = /(?!)/, antigravityLines, antigravityRoots = () => [], antigravityTranscripts = function* () {}, antigravityContext = () => ({}) } = readers;
|
|
68
|
+
const { DATABASE_SESSION = /(?!)/, databaseLines = () => null, databaseSessions = function* () {}, databaseStores = () => [] } = databases;
|
|
69
|
+
const DATABASE_CLIENTS = LOOK_APPS.filter((app) => app.database).map((app) => app.key);
|
|
70
|
+
const finders = sessionFinders({ value: () => undefined, excluded, DATABASE_CLIENTS, codexRolloutFiles, codexCwd, codexIdOf, antigravityRoots, antigravityTranscripts, antigravityContext, databaseSessions });
|
|
71
|
+
const parsedLines = transcriptLines({ DATABASE_SESSION, databaseLines, CODEX_ROLLOUT, codexLines, ANTIGRAVITY_TRANSCRIPT, antigravityIdOf, antigravityLines, antigravityContext });
|
|
72
|
+
// A folder that is there and cannot be listed is an app that could not be read (the walks pass it over in silence).
|
|
73
|
+
for (const app of present) if ((app.roots?.() ?? []).some(unlistable)) rows.get(app.key).why = "folder";
|
|
74
|
+
// The database clients need node:sqlite; a store the local-model readers opened and could not read is said by them.
|
|
75
|
+
const sqlite = sqliteHere();
|
|
76
|
+
for (const app of present) if (app.database && !sqlite) rows.get(app.key).why = "node";
|
|
77
|
+
for (const store of (() => { try { return sqlite ? databaseStores() : []; } catch { return []; } })()) if (store?.state && store.state !== "read" && rows.has(store.client)) rows.get(store.client).why ??= "store";
|
|
78
|
+
const walk = rows.get("claude")?.why === "folder" ? finders.codexRollouts() : finders.allTranscripts();
|
|
79
|
+
let current = null;
|
|
80
|
+
for (const { id, file } of walk) {
|
|
81
|
+
const key = appOf(id), row = rows.get(key);
|
|
82
|
+
if (!row) continue; // an app the table does not show (none today): never counted under another's name
|
|
83
|
+
if (key !== current) { current = key; progress?.(row.name); }
|
|
84
|
+
const failedBefore = READ_FAILURES.n;
|
|
85
|
+
let first = Infinity, last = -Infinity, lines = null;
|
|
86
|
+
try { lines = parsedLines(file); } catch { lines = null; }
|
|
87
|
+
if (lines) { try { for (const line of lines) { if (!line?.timestamp || (line.type !== "user" && line.type !== "assistant")) continue; const at = Date.parse(line.timestamp); if (Number.isFinite(at)) { if (at < first) first = at; if (at > last) last = at; } } } catch { READ_FAILURES.n += 1; } }
|
|
88
|
+
if (READ_FAILURES.n > failedBefore || (!lines && DATABASE_SESSION.test(file))) { row.unreadable += 1; continue; }
|
|
89
|
+
if (!lines) continue; // a file gone between the walk and the read is no session
|
|
90
|
+
if (first === Infinity) continue; // no timestamped turn: nothing was recorded in it
|
|
91
|
+
row.sessions += 1;
|
|
92
|
+
if (!row.first || dayOf(first) < row.first) row.first = dayOf(first);
|
|
93
|
+
if (!row.last || dayOf(last) > row.last) row.last = dayOf(last);
|
|
94
|
+
}
|
|
95
|
+
const apps = [...rows.values()].map((row) => ({ ...row, state: row.sessions > 0 ? "found" : row.unreadable > 0 || row.why ? "unreadable" : "none" }));
|
|
96
|
+
const found = apps.filter((row) => row.sessions > 0);
|
|
97
|
+
const total = { sessions: found.reduce((n, row) => n + row.sessions, 0), apps: found.length, first: found.map((row) => row.first).sort()[0] ?? null, last: found.map((row) => row.last).sort().at(-1) ?? null };
|
|
98
|
+
return { apps, total };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const WHY = { node: "needs Node 22.5+", folder: "folder not readable", store: "database locked or unknown" };
|
|
102
|
+
const plural = (n, one, many) => `${n.toLocaleString("en-US")} ${n === 1 ? one : many}`;
|
|
103
|
+
|
|
104
|
+
/** The table, as lines. `columns`: the terminal's width; below 64 a row's days go to a line of their own. Pure. */
|
|
105
|
+
export function lookLines({ apps, total }, { columns = 80 } = {}) {
|
|
106
|
+
// A sentence wraps at the terminal's width, two spaces in, as the menu's fixed line does.
|
|
107
|
+
const said = (text) => text.split(" ").reduce((lines, word) => { const last = lines.at(-1); if (last && last.length + 1 + word.length <= columns - 3) lines[lines.length - 1] = `${last} ${word}`; else lines.push(word); return lines; }, []).map((line) => ` ${line}`);
|
|
108
|
+
const out = ["", ...said("What your AI apps recorded on this computer. Nothing was sent or kept."), ""];
|
|
109
|
+
if (apps.length === 0) return [...out, ...said("No AI app this CLI reads was found on this computer."), ""];
|
|
110
|
+
const nameCol = Math.max(...apps.map((row) => row.name.length), "Total".length);
|
|
111
|
+
const state = (row) => (row.state === "found" ? `${plural(row.sessions, "session", "sessions")}${row.unreadable ? ` · ${row.unreadable} could not be read` : ""}` : row.state === "none" ? "none found" : `could not read${row.why ? ` (${WHY[row.why]})` : ""}`);
|
|
112
|
+
const days = (row) => (row.first ? (row.first === row.last ? row.first : `${row.first} to ${row.last}`) : "");
|
|
113
|
+
const totalSaid = total.sessions ? `${plural(total.sessions, "session", "sessions")} in ${plural(total.apps, "app", "apps")}` : "no sessions found";
|
|
114
|
+
const stateCol = Math.max(totalSaid.length, ...apps.map((row) => state(row).length));
|
|
115
|
+
const narrow = 2 + nameCol + 3 + stateCol + 3 + "2026-01-01 to 2026-01-01".length > columns - 1;
|
|
116
|
+
const row = (name, said, span) => (narrow ? [` ${name.padEnd(nameCol)} ${said}`, ...(span ? [` ${"".padEnd(nameCol)} ${span}`] : [])] : [` ${name.padEnd(nameCol)} ${span ? said.padEnd(stateCol) : said}${span ? ` ${span}` : ""}`]);
|
|
117
|
+
for (const app of apps) out.push(...row(app.name, state(app), days(app)));
|
|
118
|
+
out.push("", ...row("Total", totalSaid, days(total)));
|
|
119
|
+
out.push("", ...said("Sessions and days only: WorkTrust measures the hours when you send them."));
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* THE MEASURED SUMMARY OF `Check this computer` (0.8.3; words corrected 0.11.10 from the owner's own output): one line per
|
|
125
|
+
* evidence group, from the hook's --evidence-summary JSON. Pure. Two lines said less than they count:
|
|
126
|
+
* · the changed files are, per stretch, every path of every commit in that repository during the stretch's window, any
|
|
127
|
+
* author, generated files and lockfiles included (or its uncommitted files when nothing was committed), a file counted
|
|
128
|
+
* once per stretch and again in the next: the line now says so;
|
|
129
|
+
* · the complexity classes come from the derived record, which not every stretch has: the stretches without one are said.
|
|
130
|
+
*/
|
|
131
|
+
export function measuredLines(m) {
|
|
132
|
+
if (!m || !m.stretches) return [" Measured here, last 30 days: no finished work stretch yet."];
|
|
133
|
+
const of = (part, whole, one, many) => `${part} of ${whole} ${whole === 1 ? one : many}`;
|
|
134
|
+
const out = ["", ` Measured here, last 30 days: ${m.stretches} work stretch${m.stretches === 1 ? "" : "es"} (the hours are WorkTrust's: see the app)`];
|
|
135
|
+
if (m.delivered) out.push(` verified before delivery ${of(m.verified_first, m.delivered, "stretch that delivered", "stretches that delivered")}`);
|
|
136
|
+
if (m.failures) out.push(` recovered failures ${of(m.recovered, m.failures, "failed tool call", "failed tool calls")} (${m.blind_retries} retried unchanged)`);
|
|
137
|
+
if (m.steers) out.push(` steering that worked ${of(m.effective_steers, m.steers, "time you stepped in", "times you stepped in")}`);
|
|
138
|
+
if (m.refused || m.guard_denied) out.push(` refused ${m.refused} by you · ${m.guard_denied} by a guard`);
|
|
139
|
+
if (m.planned) out.push(` planned ${m.planned} stretch${m.planned === 1 ? "" : "es"} with a to-do list`);
|
|
140
|
+
if (m.files) out.push(` tests among changed files ${of(m.test_files, m.files, "file", "files")}, a file once per stretch`, " (any author's commits in the stretch's window)");
|
|
141
|
+
const tiers = Object.entries(m.complexity ?? {}).sort(), classed = tiers.reduce((n, [, count]) => n + (Number(count) || 0), 0);
|
|
142
|
+
const classes = ` task complexity ${tiers.map(([tier, n]) => `${tier} ${n}`).join(" · ")}`, unclassed = m.stretches > classed ? `${m.stretches - classed} not classed` : null;
|
|
143
|
+
// The stretches without a class are said on the line, or under it where 80 columns would cut it.
|
|
144
|
+
if (tiers.length) out.push(...(!unclassed ? [classes] : classes.length + 3 + unclassed.length <= 79 ? [`${classes} · ${unclassed}`] : [classes, `${" ".repeat(31)}${unclassed}`]));
|
|
145
|
+
out.push(" Sent with each stretch as kinds and counts, never text. Keep your own copy: npx worktrust@latest preserve");
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* WHAT TO DO WITH IT (owner, 2026-11-14): a short list in the menu's own renderer under the table. Not connected: connect
|
|
151
|
+
* (the existing flow, which offers the past once after the sign-in); connected: send them as earlier history (it asks
|
|
152
|
+
* first). Preserve needs no account. Each names the command it runs, as every menu row does.
|
|
153
|
+
*/
|
|
154
|
+
export function lookItems(connected = false) {
|
|
155
|
+
return [
|
|
156
|
+
connected
|
|
157
|
+
? { label: "Send these to your WorkTrust account", hint: "npx worktrust history", info: "Sends them as earlier history. Shows a plan, asks first.", args: ["history"] }
|
|
158
|
+
: { label: "Connect and send these to your WorkTrust account", hint: "npx worktrust connect", info: "Asks before it writes; your browser signs in to WorkTrust.", args: ["connect"] },
|
|
159
|
+
{ label: "Preserve them here as evidence ›", hint: "npx worktrust preserve", info: "Keep your AI history here. No account; nothing is sent.", preserve: true },
|
|
160
|
+
{ label: "← Back", hint: "Esc", back: true },
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** The menu's Look row (cli-menu.mjs firstItems): the `look` command as a child, no key waited for, then the list. */
|
|
165
|
+
export async function lookMenu(term, io, levels) {
|
|
166
|
+
const menu = await import("./cli-menu.mjs");
|
|
167
|
+
const code = await menu.runShown(term, io, ["look"], null, { pause: false });
|
|
168
|
+
if (code !== 0) { term.write(`\n ! It ended with a message above. ${menu.muted("Press any key for the menu.")}\n`); const k = await term.anyKey(); return !(k.ctrl && k.name === "c"); }
|
|
169
|
+
const picked = await menu.choose(term, { title: "What next", items: lookItems(false) });
|
|
170
|
+
if (picked === "quit") return false;
|
|
171
|
+
if (picked === "back" || picked.item.back) return true;
|
|
172
|
+
return picked.item.preserve ? levels.preserveMenu(term, io, []) : menu.runShown(term, io, picked.item.args);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The same list after `npx worktrust look` in a person's own terminal (worktrust.mjs asks menuWanted first). Ctrl+C while a
|
|
177
|
+
* command it started runs is that command's; the list's own Ctrl+C and Esc leave. → the exit code of what it ran, else 0.
|
|
178
|
+
* `term` and `levels` are this process's terminal and the menu's deeper levels unless a test hands its own.
|
|
179
|
+
*/
|
|
180
|
+
export async function lookNext(io, { connected = false, term: given = null, levels: deeper = null } = {}) {
|
|
181
|
+
const menu = await import("./cli-menu.mjs"), levels = deeper ?? (await import("./cli-menu-remote.mjs"));
|
|
182
|
+
const term = given ?? menu.createTerminal(), hold = () => {};
|
|
183
|
+
process.on("SIGINT", hold);
|
|
184
|
+
try {
|
|
185
|
+
term.enter();
|
|
186
|
+
const picked = await menu.choose(term, { title: "What next", items: lookItems(connected) });
|
|
187
|
+
if (picked === "quit" || picked === "back" || picked.item.back) return 0;
|
|
188
|
+
if (picked.item.preserve) { await levels.preserveMenu(term, io, []); return 0; }
|
|
189
|
+
term.erase(); term.restore();
|
|
190
|
+
return await io.runCli(picked.item.args);
|
|
191
|
+
} finally { term.erase(); term.restore(); process.off("SIGINT", hold); }
|
|
192
|
+
}
|