worktrust 0.11.8 → 0.11.9
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 +34 -0
- package/LICENSE +2 -0
- package/README.md +46 -24
- package/cli-menu-remote.mjs +128 -52
- package/cli-menu.mjs +149 -64
- package/engine-release.json +1 -1
- package/package-release.json +1 -1
- package/package.json +1 -1
- package/worktrust.mjs +43 -14
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,40 @@
|
|
|
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.9: a first menu, one row per item, and nothing you can do twice
|
|
6
|
+
|
|
7
|
+
**A short menu until this computer is connected.** `npx -y worktrust` on a computer that is not connected yet opens
|
|
8
|
+
Connect this computer, Preserve evidence, Help and Quit, and nothing that needs a connected computer. Connect is the
|
|
9
|
+
same sign-in as `worktrust connect`: it shows the plan, asks before it writes, and your browser signs in. The moment it
|
|
10
|
+
succeeds the full menu is there, without running anything again; if it stops, the short menu stays and says why in one
|
|
11
|
+
line. Preserve needs no account and is whole in both menus.
|
|
12
|
+
|
|
13
|
+
**An update that is not needed cannot be run again.** When this computer runs this version and npm has none newer, the
|
|
14
|
+
Update row is still drawn, dimmed, reading `up to date (0.11.9)`, and cannot be chosen: the arrows pass it and its digit
|
|
15
|
+
answers `Already up to date.` When npm could not be asked, the row says `newest not checked` and claims nothing.
|
|
16
|
+
`npx worktrust update` on a computer that is already on this version, with nothing waiting (every AI app's door
|
|
17
|
+
standing, nothing new to agree to), answers `Already up to date (0.11.9). Nothing changed.`; before, it took every door
|
|
18
|
+
out and put it back and said `7 added`. `update --force` sets everything up again all the same.
|
|
19
|
+
|
|
20
|
+
**One row per item.** Number, action, command and explanation stand on one line where the terminal is wide enough; on a
|
|
21
|
+
narrower one (80 columns) the chosen row's explanation has one fixed line under the list. No row moves when you move,
|
|
22
|
+
no sentence is cut, and every sentence was rewritten to 60 characters or fewer. Under 60 columns the command column goes.
|
|
23
|
+
|
|
24
|
+
**Remote Agent asks for the approval first.** Until this computer is approved, Approve this computer is first, and what
|
|
25
|
+
cannot work before it (Link a phone, Projects, Roots, Connections, Pause) is dimmed, marked `not yet`, and cannot be
|
|
26
|
+
chosen. Approved from inside the menu, the list opens at once with the cursor on Link a phone.
|
|
27
|
+
|
|
28
|
+
**A summary above the menu, Sharing, and the linked devices.** A connected computer's head says the account, this
|
|
29
|
+
computer and since when, Remote Agent with its connections, and what this computer shares; all from its own files, never
|
|
30
|
+
the key. Sharing › holds the switches that exist (`mcp off | on`, Remote Agent's pause) and says that the session hook has
|
|
31
|
+
none in the CLI. Remote Agent › Connections is a table (name, kind, since, last activity); Disconnect runs
|
|
32
|
+
`remote disconnect` with the confirmation you type, as before.
|
|
33
|
+
|
|
34
|
+
**Esc quits at the top**, like q, and goes back one level below it.
|
|
35
|
+
|
|
36
|
+
**`-y` where a first command is shown.** The README, the app and the site show `npx -y worktrust` and
|
|
37
|
+
`npx -y worktrust@latest …`, so npm's own `Ok to proceed?` is answered in advance.
|
|
38
|
+
|
|
5
39
|
## 0.11.8: the menu says more, stays in one place, and uses colour with meaning
|
|
6
40
|
|
|
7
41
|
**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.
|
package/README.md
CHANGED
|
@@ -21,12 +21,13 @@ 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
|
-
asks, and you approve the computer in your browser with your
|
|
29
|
-
|
|
27
|
+
In your own terminal this opens the menu. On a computer that is not connected yet it is a short one: Connect this
|
|
28
|
+
computer, Preserve evidence, Help. Connect shows the plan, asks, and you approve the computer in your browser with your
|
|
29
|
+
own account and second factor; the moment that succeeds, the full menu is there. The `-y` answers npm's own question in
|
|
30
|
+
advance: without it npm may ask `Ok to proceed?` before WorkTrust starts.
|
|
30
31
|
|
|
31
32
|
**With Python instead.** The Python package runs the same CLI and brings its own Node, so it needs no Node on the computer:
|
|
32
33
|
|
|
@@ -53,42 +54,63 @@ and show the ways forward, each with its exact command:
|
|
|
53
54
|
|
|
54
55
|
Without a terminal nothing is asked and nothing runs: the same text is printed and the command ends with a failure code.
|
|
55
56
|
|
|
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.
|
|
57
|
+
**Update.** `npx -y worktrust@latest update` brings this computer's hook and AI-app doors to the newest version. Your key and
|
|
58
|
+
pairing stay. On a computer that is already on that version, with nothing waiting, it says so and changes nothing;
|
|
59
|
+
`update --force` sets everything up again all the same.
|
|
58
60
|
|
|
59
61
|
**Stop.** `npx worktrust disconnect` takes WorkTrust out of every AI app here and removes the key. Then revoke the
|
|
60
62
|
computer in WorkTrust under Sources, Devices. More under [Undo](#undo).
|
|
61
63
|
|
|
62
64
|
## The menu
|
|
63
65
|
|
|
66
|
+
On a computer that is not connected yet:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
WorkTrust CLI 0.11.9
|
|
70
|
+
Not connected yet
|
|
71
|
+
|
|
72
|
+
> 1 Connect this computer npx worktrust connect
|
|
73
|
+
2 Preserve evidence › npx worktrust preserve …
|
|
74
|
+
3 Help · all commands npx worktrust help
|
|
75
|
+
4 Quit q
|
|
76
|
+
|
|
77
|
+
Asks before it writes; your browser signs in to WorkTrust.
|
|
78
|
+
|
|
79
|
+
↑/↓ move · Enter open · Esc quit · 1-9 jump
|
|
64
80
|
```
|
|
65
|
-
WorkTrust CLI 0.11.8
|
|
66
|
-
Connected as you@example.com · Remote Agent on
|
|
67
81
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
Once it is connected (80 columns; on a wide terminal each row's sentence stands on the row itself, as a fourth column):
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
WorkTrust CLI 0.11.9
|
|
86
|
+
Account you@example.com
|
|
87
|
+
This computer imac · connected since 2026-11-03
|
|
88
|
+
Remote Agent approved, 2 connections
|
|
89
|
+
Sharing session hook on · AI apps on (7) · Remote Agent approved
|
|
90
|
+
|
|
91
|
+
1 Update WorkTrust · up to date (0.11.9) npx worktrust update
|
|
92
|
+
> 2 Check this computer npx worktrust
|
|
72
93
|
3 Remote Agent › npx worktrust remote …
|
|
73
|
-
Opens the choices for steering this computer's agents from your phone. Nothing changes yet.
|
|
74
94
|
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
95
|
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.
|
|
96
|
+
6 Sharing › npx worktrust mcp …
|
|
80
97
|
7 Status npx worktrust status
|
|
81
|
-
Shows the key, the hook, the door and what this computer measured. It only reads.
|
|
82
98
|
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
99
|
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
100
|
Quit q
|
|
87
|
-
Leaves the menu. Nothing keeps running.
|
|
88
101
|
|
|
89
|
-
|
|
102
|
+
Shows what is coupled here and finishes what waits.
|
|
103
|
+
|
|
104
|
+
↑/↓ move · Enter open · Esc quit · 1-9 jump
|
|
90
105
|
```
|
|
91
106
|
|
|
107
|
+
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
|
|
108
|
+
when there is nothing to update, and most of Remote Agent until this computer is approved for it. The summary above the
|
|
109
|
+
menu comes from this computer's own files; it never shows the key. Sharing › says what this computer sends and holds the
|
|
110
|
+
switches that exist: `mcp off | on` and Remote Agent's pause. Remote Agent › Connections lists every linked phone and
|
|
111
|
+
browser, and disconnecting one runs `remote disconnect` with its typed confirmation. Esc quits at the top and goes back
|
|
112
|
+
one level below it.
|
|
113
|
+
|
|
92
114
|
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
115
|
there is no menu and nothing waits for a key.
|
|
94
116
|
|
|
@@ -98,7 +120,7 @@ there is no menu and nothing waits for a key.
|
|
|
98
120
|
|---|---|
|
|
99
121
|
| `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
122
|
| `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. |
|
|
123
|
+
| `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
124
|
| `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
125
|
| `npx worktrust disconnect` | Takes WorkTrust out of every AI app here. Asks first. |
|
|
104
126
|
| `npx worktrust status` | Shows what is connected here. It only reads. |
|
|
@@ -382,7 +404,7 @@ agent runs it makes no difference: `preserve` writes to your own user's places (
|
|
|
382
404
|
`~/AI-Evidence`), so every terminal and agent on this computer under your user reaches the same archive, and lines
|
|
383
405
|
from different versions sit side by side, each naming the version that measured it. Another user on the same computer
|
|
384
406
|
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
|
|
407
|
+
with `npx -y worktrust@latest update`, or (from 0.10.37, installed from npm) when you turn CLI active back on for that
|
|
386
408
|
computer in WorkTrust › Sources: it then updates itself, verified, the next time WorkTrust runs there (SECURITY.md,
|
|
387
409
|
"Updating itself when you turn it on"). The WorkTrust app says when a newer version is out.
|
|
388
410
|
|
package/cli-menu-remote.mjs
CHANGED
|
@@ -3,25 +3,31 @@
|
|
|
3
3
|
* preservation choices. Each item still runs one direct command (runShown), named in its muted line; this file only reads
|
|
4
4
|
* the remote settings to label the items and never writes one itself: a change goes through the command, so it goes
|
|
5
5
|
* through applySettingsChange (remote-settings.mjs) like a typed one. Folders are chosen without typing (folder-picker.mjs).
|
|
6
|
+
*
|
|
7
|
+
* 0.11.9 (owner, 2026-11-14): every sentence fits the one-row form (60 characters at most), and Remote Agent asks for the
|
|
8
|
+
* approval FIRST: what cannot work before it cannot be chosen (remoteItems).
|
|
6
9
|
*/
|
|
7
10
|
import { homedir } from "node:os";
|
|
8
11
|
import { join } from "node:path";
|
|
9
|
-
import { choose, runShown, typed } from "./cli-menu.mjs";
|
|
12
|
+
import { choose, remoteState, runShown, typed } from "./cli-menu.mjs";
|
|
10
13
|
import { makeProjectsFolder, pickFolder, pickerCommand, suggestedFolders } from "./folder-picker.mjs";
|
|
11
14
|
import { connections } from "./remote-connections.mjs";
|
|
12
15
|
import { loadIdentity, loadProjects, loadRoots, loadSettings } from "./remote-store.mjs";
|
|
13
16
|
import { allowedModes } from "./remote-settings.mjs";
|
|
14
17
|
|
|
15
|
-
const BACK = { label: "← Back", hint: "Esc",
|
|
18
|
+
const BACK = { label: "← Back", hint: "Esc", back: true }; // its name and its key say it: no sentence of its own (owner, 2026-11-14)
|
|
16
19
|
const tilde = (path) => (path.startsWith(homedir()) ? `~${path.slice(homedir().length)}` : path);
|
|
17
20
|
|
|
18
21
|
/** Loop one level: each pick runs, Back or Esc returns; a pick that returns false ends the menu (Ctrl+C after a command). */
|
|
19
|
-
async function level(term, header, title, build) {
|
|
22
|
+
async function level(term, header, title, build, io = null) {
|
|
20
23
|
for (;;) {
|
|
21
|
-
const picked = await choose(term, { header, title, items: build() });
|
|
24
|
+
const picked = await choose(term, { header, title: typeof title === "function" ? title() : title, items: build() });
|
|
22
25
|
if (picked === "quit") return false;
|
|
23
26
|
if (picked === "back" || picked.item.back) return true;
|
|
24
|
-
|
|
27
|
+
const result = picked.item.run ? await picked.item.run() : true;
|
|
28
|
+
await io?.state?.(); // the head above reads this computer again: what the command changed shows at once
|
|
29
|
+
if (result === false) return false;
|
|
30
|
+
if (result === "back") return true; // the step this level was for is done (0.11.9: approved): the level above draws again
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
|
|
@@ -38,8 +44,8 @@ async function addRoots(term, io, header) {
|
|
|
38
44
|
const offered = suggestedFolders().filter((f) => !have.has(f.path));
|
|
39
45
|
const items = [
|
|
40
46
|
...offered.map((f) => ({ label: tilde(f.path), note: { text: `${f.projects} project${f.projects === 1 ? "" : "s"} found`, tone: "dim" }, info: "Space ticks it; Enter adds the ticked folders as roots.", tick: true, path: f.path })),
|
|
41
|
-
{ label: "+ Make a new folder for my projects", make: true, hint: "npx worktrust remote roots add <folder> --git-init", info: "
|
|
42
|
-
{ label: "Choose another folder…", pick: true, hint: "npx worktrust remote roots add <folder>", info: "Opens the
|
|
47
|
+
{ label: "+ Make a new folder for my projects", make: true, hint: "npx worktrust remote roots add <folder> --git-init", info: "Makes a folder in your home folder and adds it as a root." },
|
|
48
|
+
{ label: "Choose another folder…", pick: true, hint: "npx worktrust remote roots add <folder>", info: "Opens the folder picker and adds the folder you choose." },
|
|
43
49
|
BACK,
|
|
44
50
|
];
|
|
45
51
|
const picked = await choose(term, { header, title: "Add folders where your projects live", items, multi: true });
|
|
@@ -58,16 +64,16 @@ async function addRoots(term, io, header) {
|
|
|
58
64
|
|
|
59
65
|
function rootsMenu(term, io, header) {
|
|
60
66
|
return level(term, header, "Roots for new projects", () => [
|
|
61
|
-
{ label: "+ Add folders", hint: "npx worktrust remote roots add <folder>", info: "
|
|
62
|
-
...loadRoots().map((r) => ({ label: `Remove ${tilde(r.path)}`, hint: `npx worktrust remote roots remove ${tilde(r.path)}`, info: "
|
|
67
|
+
{ label: "+ Add folders", hint: "npx worktrust remote roots add <folder>", info: "Choose folders whose projects a phone may open or add to.", run: () => addRoots(term, io, header) },
|
|
68
|
+
...loadRoots().map((r) => ({ label: `Remove ${tilde(r.path)}`, hint: `npx worktrust remote roots remove ${tilde(r.path)}`, info: "A phone can no longer use this folder. No file is touched.", run: () => runShown(term, io, ["remote", "roots", "remove", r.path]) })),
|
|
63
69
|
BACK,
|
|
64
70
|
]);
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
function projectsMenu(term, io, header) {
|
|
68
74
|
return level(term, header, "Projects a phone may steer an agent in", () => [
|
|
69
|
-
{ label: "+ Add a project folder…", hint: "npx worktrust remote projects add <folder>", info: "
|
|
70
|
-
...loadProjects().map((p) => ({ label: `Remove ${tilde(p.path)}`, hint: `npx worktrust remote projects remove ${tilde(p.path)}`, info: "
|
|
75
|
+
{ label: "+ Add a project folder…", hint: "npx worktrust remote projects add <folder>", info: "Pick a folder a phone may steer an agent in.", run: async () => { const path = await chooseFolder(term); term.enter(); return path ? runShown(term, io, ["remote", "projects", "add", path]) : true; } },
|
|
76
|
+
...loadProjects().map((p) => ({ label: `Remove ${tilde(p.path)}`, hint: `npx worktrust remote projects remove ${tilde(p.path)}`, info: "A phone can no longer start an agent here. No file changes.", run: () => runShown(term, io, ["remote", "projects", "remove", p.path]) })),
|
|
71
77
|
BACK,
|
|
72
78
|
]);
|
|
73
79
|
}
|
|
@@ -75,74 +81,144 @@ function projectsMenu(term, io, header) {
|
|
|
75
81
|
function modesMenu(term, io, header) {
|
|
76
82
|
return level(term, header, "Agent modes a phone may start here", () => {
|
|
77
83
|
const allowed = allowedModes(loadSettings());
|
|
78
|
-
const toggle = (mode, words) => ({ label: `${words}: ${allowed.includes(mode) ? "allowed" : "not allowed"}`, hint: `npx worktrust remote modes ${allowed.includes(mode) ? "deny" : "allow"} ${mode}`, info: allowed.includes(mode) ? `Stops a phone from starting
|
|
84
|
+
const toggle = (mode, words) => ({ label: `${words}: ${allowed.includes(mode) ? "allowed" : "not allowed"}`, hint: `npx worktrust remote modes ${allowed.includes(mode) ? "deny" : "allow"} ${mode}`, info: allowed.includes(mode) ? `Stops a phone from starting this mode${mode === "edit" ? "; auto goes too" : ""}.` : `Lets a phone start this mode${mode === "auto" ? "; that allows edit too" : ""}.`,
|
|
79
85
|
run: () => runShown(term, io, ["remote", "modes", allowed.includes(mode) ? "deny" : "allow", mode]) });
|
|
80
86
|
return [
|
|
81
|
-
{ label: "Manual
|
|
82
|
-
{ label: "Plan
|
|
87
|
+
{ label: "Manual: always allowed", info: "Always there: the agent asks before every change.", disabled: true },
|
|
88
|
+
{ label: "Plan: always allowed", info: "Always there: the agent reads and plans, changes nothing.", disabled: true },
|
|
83
89
|
toggle("edit", "Edit automatically"),
|
|
84
|
-
toggle("auto", "Auto
|
|
85
|
-
{ label: "Status", hint: "npx worktrust remote modes status", info: "Shows which modes a phone may start
|
|
90
|
+
toggle("auto", "Auto mode"),
|
|
91
|
+
{ label: "Status", hint: "npx worktrust remote modes status", info: "Shows which modes a phone may start. It only reads.", run: () => runShown(term, io, ["remote", "modes", "status"]) },
|
|
86
92
|
BACK,
|
|
87
93
|
];
|
|
88
94
|
});
|
|
89
95
|
}
|
|
90
96
|
|
|
97
|
+
/**
|
|
98
|
+
* THE LINKED DEVICES, AS A TABLE (0.11.9, owner 2026-11-14): one row per connection: name, kind, since, last activity. Enter
|
|
99
|
+
* opens that connection's acts. Disconnect runs the same `remote disconnect <fingerprint>` a person types, with its typed
|
|
100
|
+
* confirmation (remote-connections.mjs, a security decision of 2026-11-12): the menu confirms nothing itself and fills nothing in.
|
|
101
|
+
*/
|
|
102
|
+
const day = (ms) => (Number.isFinite(ms) ? new Date(ms).toISOString().slice(0, 10) : "not known");
|
|
91
103
|
function connectionsMenu(term, io, header) {
|
|
92
104
|
return level(term, header, "Connections to this computer", () => {
|
|
93
|
-
const list = connections();
|
|
105
|
+
const list = connections(), wide = Math.min(20, Math.max(4, ...list.map((c) => c.name.length))), last = term.size().columns >= 72; // a narrow terminal keeps name, kind and since
|
|
106
|
+
if (list.length === 0) return [
|
|
107
|
+
{ label: "No phone or browser is linked yet.", info: "Link one with the row below.", disabled: true, quiet: "Nothing to open here." },
|
|
108
|
+
{ label: "Link a phone (QR here)", hint: "npx worktrust remote pair", info: "Shows a QR that links a phone to this computer.", run: () => runShown(term, io, ["remote", "pair"]) },
|
|
109
|
+
BACK,
|
|
110
|
+
];
|
|
111
|
+
const acts = (c) => () => level(term, header, `${c.name} · ${c.kind} · ${c.fingerprint}`, () => [
|
|
112
|
+
...(c.state === "pending" ? [{ label: "Confirm it", hint: `npx worktrust remote phones confirm ${c.fingerprint}`, info: "Confirms this link. Check the fingerprint on the device.", run: async () => ((await runShown(term, io, ["remote", "phones", "confirm", c.fingerprint])) === false ? false : "back") }] : []),
|
|
113
|
+
{ label: "Disconnect", hint: `npx worktrust remote disconnect ${c.fingerprint}`, info: "Closes it. You type its name or code to confirm.", run: async () => ((await runShown(term, io, ["remote", "disconnect", c.fingerprint])) === false ? false : "back") },
|
|
114
|
+
BACK,
|
|
115
|
+
], io);
|
|
94
116
|
return [
|
|
95
|
-
{ label:
|
|
96
|
-
|
|
97
|
-
...list.map((c) => ({ label: `${c.name} · ${c.kind} · ${c.fingerprint}`, hint: `npx worktrust remote disconnect ${c.n}`, info: "Closes this connection; that device has to be linked again to come back. It asks twice.", run: () => runShown(term, io, ["remote", "disconnect", c.fingerprint]) })),
|
|
98
|
-
...(list.length > 0 ? [{ label: "Close all connections", hint: "npx worktrust remote disconnect --all", info: "Closes every connection to this computer. You type close all to confirm.", run: () => runShown(term, io, ["remote", "disconnect", "--all"]) }] : []),
|
|
117
|
+
...list.map((c) => ({ label: `${c.name.length > wide ? `${c.name.slice(0, wide - 1)}…` : c.name.padEnd(wide)} ${c.kind.padEnd(7)} since ${day(c.since)}${last ? ` last ${day(c.last_seen)}` : ""}${c.state === "pending" ? " pending" : ""}`, hint: `npx worktrust remote disconnect ${c.n}`, info: `Enter opens ${c.name} · ${c.fingerprint}.`, run: acts(c) })),
|
|
118
|
+
{ label: "Disconnect all…", hint: "npx worktrust remote disconnect --all", info: "Closes every connection. You type close all to confirm.", run: () => runShown(term, io, ["remote", "disconnect", "--all"]) },
|
|
99
119
|
BACK,
|
|
100
120
|
];
|
|
101
|
-
});
|
|
121
|
+
}, io);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* SHARING (0.11.9, owner 2026-11-14): what this computer sends, in words, and the switches that exist. Each switch runs the
|
|
126
|
+
* command a person types (`mcp off | on`, `remote pause | resume`); the session hook has no switch in the CLI (measuring is
|
|
127
|
+
* paused in WorkTrust under Sources, and `disconnect` takes it out), so its row says so and cannot be chosen. One app alone
|
|
128
|
+
* cannot be coupled or uncoupled by a command today, so there is no row per app. The state is read again at every draw.
|
|
129
|
+
*/
|
|
130
|
+
export function sharingItems(state, remote, act = {}) {
|
|
131
|
+
const doorOn = state.door === "on", live = ["approved", "paused"].includes(remote.word), paused = remote.word === "paused";
|
|
132
|
+
return [
|
|
133
|
+
{ label: `Session hook: ${state.hook === true ? "on" : state.hook === false ? "not installed" : "not known"}`, note: { text: "no switch here", tone: "dim" }, info: "Sends times, tokens, models and tools. Never content.", disabled: true, quiet: "Pause it under Sources." },
|
|
134
|
+
state.door === "on" || state.door === "off"
|
|
135
|
+
? { label: `WorkTrust in your AI apps: ${doorOn ? `on${Number.isInteger(state.apps) ? ` (${state.apps} app${state.apps === 1 ? "" : "s"})` : ""}` : "off"}`, hint: `npx worktrust mcp ${doorOn ? "off" : "on"}`, info: doorOn ? "On: your AI logs finished work. Enter takes the door out." : "Off: hours only. Enter puts the door back in your AI apps.", run: () => act.door?.(doorOn ? "off" : "on") }
|
|
136
|
+
: { label: "WorkTrust in your AI apps: not known", hint: "npx worktrust mcp status", info: "Its state could not be read. Enter shows it.", run: () => act.door?.("status") },
|
|
137
|
+
live
|
|
138
|
+
? { label: `Remote Agent: ${paused ? "paused" : "on"}`, hint: `npx worktrust remote ${paused ? "resume" : "pause"}`, info: paused ? "Paused: no phone steers agents here. Enter resumes." : "On: linked phones steer agents here. Enter pauses.", run: () => act.remote?.(paused ? "resume" : "pause") }
|
|
139
|
+
: { label: `Remote Agent: ${remote.word}`, hint: "npx worktrust remote …", info: "Lets your phone steer this computer's agents.", disabled: true, quiet: remote.word === "not known" ? "Its state could not be read." : "Set it up under Remote Agent." },
|
|
140
|
+
BACK,
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
export async function sharingMenu(term, io, header) {
|
|
144
|
+
for (;;) {
|
|
145
|
+
const state = await io.state();
|
|
146
|
+
const picked = await choose(term, { header, title: "Sharing", items: sharingItems(state, remoteState(), { door: (to) => runShown(term, io, ["mcp", to]), remote: (to) => runShown(term, io, ["remote", to]) }) });
|
|
147
|
+
if (picked === "quit") return false;
|
|
148
|
+
if (picked === "back" || picked.item.back) return true;
|
|
149
|
+
if ((await picked.item.run()) === false) return false;
|
|
150
|
+
}
|
|
102
151
|
}
|
|
103
152
|
|
|
104
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* WHETHER THIS COMPUTER IS APPROVED FOR REMOTE AGENT, in three states (0.11.9): true (its identity is here), false (none),
|
|
155
|
+
* null when the file could not be read (remote-store readJson refuses an unreadable or non-private one): not known is
|
|
156
|
+
* never "not approved".
|
|
157
|
+
*/
|
|
158
|
+
export function approval() { try { return Boolean(loadIdentity()); } catch { return null; } }
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Remote Agent's rows (owner, 2026-11-14: "first the approve, and once that succeeded you go on to the other steps"). Pure:
|
|
162
|
+
* `approved` is approval()'s answer, `act` what each row does. NOT APPROVED: the approval is first and chosen, and what
|
|
163
|
+
* cannot work before it cannot be chosen. By the code: `remote pair` and adding a project or a root refuse without this
|
|
164
|
+
* computer's remote keys (remote-cli.mjs needPaired, remote-settings.mjs applyRules), and no phone can be linked, so there
|
|
165
|
+
* is no connection to list and nothing to pause. Allowed modes is a local setting and Status only reads: both stay.
|
|
166
|
+
* APPROVED: Link a phone first, and approving again stays (new keys). NOT KNOWN: every row can be chosen and the title says so.
|
|
167
|
+
*/
|
|
168
|
+
export function remoteItems(approved, paused, act = {}) {
|
|
169
|
+
const wait = approved === false ? { disabled: true, quiet: "Approve this computer first.", note: { text: "not yet", tone: "dim" } } : {};
|
|
170
|
+
const approve = { label: approved ? "Approved ✓ · approve again ›" : "Approve this computer ›", hint: approved ? "npx worktrust remote app --repair" : "npx worktrust remote app | web", info: approved ? "Approve again: new keys, and linked phones link again." : "Needed once: your account allows steering this computer.", run: act.approve };
|
|
171
|
+
const link = { label: "Link a phone (QR here)", hint: "npx worktrust remote pair", info: "Shows a QR that links a phone to this computer.", run: act.link, ...wait };
|
|
172
|
+
return [
|
|
173
|
+
...(approved ? [link, approve] : [approve, link]),
|
|
174
|
+
{ label: "Projects ›", hint: "npx worktrust remote projects", info: "Folders a phone may steer an agent in.", run: act.projects, ...wait },
|
|
175
|
+
{ label: "Roots for new projects ›", hint: "npx worktrust remote roots", info: "Where a phone may open and create projects.", run: act.roots, ...wait },
|
|
176
|
+
{ label: "Allowed modes ›", hint: "npx worktrust remote modes", info: "Agent modes a phone may start. This computer is the limit.", run: act.modes },
|
|
177
|
+
{ label: "Connections ›", hint: "npx worktrust remote connections", info: "Phones and browsers linked here.", run: act.connections, ...wait },
|
|
178
|
+
{ label: paused ? "Resume" : "Pause", hint: `npx worktrust remote ${paused ? "resume" : "pause"}`, info: paused ? "Lets linked phones steer agents here again." : "Stops every phone until you resume. Links stay.", run: act.pause, ...wait },
|
|
179
|
+
{ label: "Status", hint: "npx worktrust remote status", info: "Shows if Remote Agent is on and what is linked. Only reads.", run: act.status },
|
|
180
|
+
BACK,
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** Remote Agent ›. The rows are read again after every command, so an approval made here opens the other steps at once. */
|
|
105
185
|
export function remoteMenu(term, io, header) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
186
|
+
const title = () => (approval() === null ? "Remote Agent · its state could not be read" : "Remote Agent");
|
|
187
|
+
return level(term, header, title, () => {
|
|
188
|
+
const approved = approval(), paused = (() => { try { return loadSettings().paused !== null; } catch { return false; } })();
|
|
189
|
+
// The two roads; one that leaves this computer approved returns to the list above, which now opens on Link a phone.
|
|
190
|
+
const road = (which) => async () => ((await runShown(term, io, ["remote", which, ...(approved ? ["--repair"] : [])])) === false ? false : approved === false && approval() === true ? "back" : true);
|
|
191
|
+
return remoteItems(approved, paused, {
|
|
192
|
+
approve: () => level(term, header, approved ? "Approve this computer again (new keys)" : "Approve this computer", () => [
|
|
193
|
+
{ label: "With the WorkTrust app", hint: `npx worktrust remote app${approved ? " --repair" : ""}`, info: "Shows a QR; scan it with the WorkTrust app and approve.", run: road("app") },
|
|
194
|
+
{ label: "In the browser", hint: `npx worktrust remote web${approved ? " --repair" : ""}`, info: "Opens WorkTrust in your browser, where you approve.", run: road("web") },
|
|
112
195
|
BACK,
|
|
113
|
-
])
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
{ label: "Allowed modes ›", hint: "npx worktrust remote modes", info: "Opens the agent modes a phone may start here: this computer is the ceiling.", run: () => modesMenu(term, io, header) },
|
|
121
|
-
{ label: "Connections ›", hint: "npx worktrust remote connections", info: "Opens the phones and browsers linked here, to confirm or close one.", run: () => connectionsMenu(term, io, header) },
|
|
122
|
-
{ label: paused ? "Resume" : "Pause", hint: `npx worktrust remote ${paused ? "resume" : "pause"}`, info: paused ? "Lets linked phones steer agents here again." : "Stops every phone from steering agents here until you resume; links and settings stay.", run: () => runShown(term, io, ["remote", paused ? "resume" : "pause"]) },
|
|
123
|
-
{ label: "Status", hint: "npx worktrust remote status", info: "Shows whether Remote Agent is on, its service and what is linked. It only reads.", run: () => runShown(term, io, ["remote", "status"]) },
|
|
124
|
-
BACK,
|
|
125
|
-
];
|
|
126
|
-
});
|
|
196
|
+
], io),
|
|
197
|
+
link: () => runShown(term, io, ["remote", "pair"]),
|
|
198
|
+
projects: () => projectsMenu(term, io, header), roots: () => rootsMenu(term, io, header), modes: () => modesMenu(term, io, header), connections: () => connectionsMenu(term, io, header),
|
|
199
|
+
pause: () => runShown(term, io, ["remote", paused ? "resume" : "pause"]),
|
|
200
|
+
status: () => runShown(term, io, ["remote", "status"]),
|
|
201
|
+
});
|
|
202
|
+
}, io);
|
|
127
203
|
}
|
|
128
204
|
|
|
129
205
|
export function historyMenu(term, io, header) {
|
|
130
206
|
return level(term, header, "Import earlier history", () => [
|
|
131
|
-
{ label: "
|
|
132
|
-
{ label: "
|
|
133
|
-
{ label: "
|
|
134
|
-
{ label: "
|
|
207
|
+
{ label: "Sessions on this computer", hint: "npx worktrust history", info: "Sessions your AI apps still hold. Shows a plan, asks first.", run: () => runShown(term, io, ["history"]) },
|
|
208
|
+
{ label: "Your local archive", hint: "npx worktrust history --from-archive", info: "Sessions your apps deleted, from your archive. Asks first.", run: () => runShown(term, io, ["history", "--from-archive"]) },
|
|
209
|
+
{ label: "A ChatGPT or Claude export…", hint: "npx worktrust history --export <path>", info: "Asks for its path. Reconstructed hours, never verified.", run: async () => { const path = await typed(term, "The export's path (the zip, its folder or conversations.json):", join(homedir(), "Downloads")); term.enter(); return path ? runShown(term, io, ["history", "--export", path]) : true; } },
|
|
210
|
+
{ label: "A copied session folder…", hint: "npx worktrust history --from-folder <dir>", info: "Your copy of a session folder. Reconstructed, not verified.", run: async () => { const path = await chooseFolder(term); term.enter(); return path ? runShown(term, io, ["history", "--from-folder", path]) : true; } },
|
|
135
211
|
BACK,
|
|
136
212
|
]);
|
|
137
213
|
}
|
|
138
214
|
|
|
139
215
|
export function preserveMenu(term, io, header) {
|
|
140
216
|
return level(term, header, "Preserve evidence", () => [
|
|
141
|
-
{ label: "How long each AI app keeps
|
|
142
|
-
{ label: "Keep them longer", hint: "npx worktrust preserve --apply", info: "
|
|
143
|
-
{ label: "Make a local archive", hint: "npx worktrust preserve --archive", info: "Writes a metadata-only
|
|
144
|
-
{ label: "Check the archive", hint: "npx worktrust preserve --verify", info: "Checks that record
|
|
145
|
-
{ label: "Count hours from the archive", hint: "npx worktrust preserve --summary", info: "Counts hours
|
|
217
|
+
{ label: "How long each AI app keeps sessions", hint: "npx worktrust preserve", info: "Shows how long each AI app keeps sessions. Changes nothing.", run: () => runShown(term, io, ["preserve"]) },
|
|
218
|
+
{ label: "Keep them longer", hint: "npx worktrust preserve --apply", info: "Keeps sessions longer. Asks per change, backs up first.", run: () => runShown(term, io, ["preserve", "--apply"]) },
|
|
219
|
+
{ label: "Make a local archive", hint: "npx worktrust preserve --archive", info: "Writes a metadata-only record to ~/AI-Evidence. Not sent.", run: () => runShown(term, io, ["preserve", "--archive"]) },
|
|
220
|
+
{ label: "Check the archive", hint: "npx worktrust preserve --verify", info: "Checks that record's hashes and signatures. It only reads.", run: () => runShown(term, io, ["preserve", "--verify"]) },
|
|
221
|
+
{ label: "Count hours from the archive", hint: "npx worktrust preserve --summary", info: "Counts hours and tokens from that record. It only reads.", run: () => runShown(term, io, ["preserve", "--summary"]) },
|
|
146
222
|
BACK,
|
|
147
223
|
]);
|
|
148
224
|
}
|
package/cli-menu.mjs
CHANGED
|
@@ -14,11 +14,21 @@
|
|
|
14
14
|
* sentence under it; the menu is redrawn IN PLACE (createTerminal) and never left in the scrollback; colours carry meaning
|
|
15
15
|
* and are off wherever cli-colour.mjs says so (NO_COLOR, --no-color, a pipe). A terminal without cursor addressing
|
|
16
16
|
* (TERM=dumb) gets no menu: the bare command runs as it always did.
|
|
17
|
+
*
|
|
18
|
+
* 0.11.9 (owner, 2026-11-14): a computer that is NOT connected gets a short menu (firstItems: Connect, Preserve, Help, Quit),
|
|
19
|
+
* and the full one the moment Connect succeeds, without running anything again (menuLoop reads the state after every command).
|
|
20
|
+
* And an Update with nothing to update is still drawn, dimmed and in words, and cannot be chosen (updateNote's `settled`).
|
|
21
|
+
* ONE ROW PER ITEM (owner, 2026-11-14: "the text under 1 is annoying"): number, action, command, explanation on one line
|
|
22
|
+
* where the terminal is wide enough, else the chosen row's explanation on one fixed line under the list (menuFrame). No row
|
|
23
|
+
* moves when the choice moves. A ROW THAT CANNOT BE CHOSEN is one mechanism for every menu: `disabled`, with `quiet`, the
|
|
24
|
+
* line its digit answers; the arrows pass it, it is dimmed, and its words say why (a note beside its name), never colour alone.
|
|
25
|
+
* Esc quits at the top like q and goes back one level below it. The head of a connected computer is a summary (headerLines):
|
|
26
|
+
* account, this computer, Remote Agent and its connections, and what this computer shares, from local files only.
|
|
17
27
|
*/
|
|
18
28
|
import { emitKeypressEvents } from "node:readline";
|
|
19
29
|
import { createInterface } from "node:readline/promises";
|
|
20
30
|
import { busyWith, clip, coloursFor, visibleLength } from "./cli-colour.mjs";
|
|
21
|
-
import { loadIdentity, loadSettings } from "./remote-store.mjs";
|
|
31
|
+
import { loadIdentity, loadPhones, loadSettings } from "./remote-store.mjs";
|
|
22
32
|
|
|
23
33
|
/** Whether bare `npx worktrust` opens the menu here. Pure: the caller passes what it knows. */
|
|
24
34
|
export function menuWanted({ args: given = [], env = {}, stdinTTY = false, stdoutTTY = false, agentShell = null } = {}) {
|
|
@@ -69,54 +79,71 @@ export function createTerminal(input = process.stdin, output = process.stdout) {
|
|
|
69
79
|
return { write, draw, erase, reset, size, enter, restore, key, anyKey };
|
|
70
80
|
}
|
|
71
81
|
|
|
82
|
+
const wrap = (text, width) => { const out = []; let line = ""; for (const word of text.split(" ")) { if (line && line.length + 1 + word.length > width) { out.push(line); line = word; } else line = line ? `${line} ${word}` : word; } return line ? [...out, line] : out; };
|
|
83
|
+
|
|
72
84
|
/**
|
|
73
|
-
* The lines of one list, as text. Pure: `view` is what choose holds, `columns` and `rows` the terminal's size.
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
85
|
+
* The lines of one list, as text. Pure: `view` is what choose holds, `columns` and `rows` the terminal's size. ONE ROW PER
|
|
86
|
+
* ITEM (0.11.9), and the rows never move when the choice moves:
|
|
87
|
+
* wide four columns on one line: number, action, command (dim), explanation (dim). Only when EVERY row's explanation
|
|
88
|
+
* fits whole (no sentence is ever cut), so the form does not depend on which row is chosen.
|
|
89
|
+
* narrower three columns, and the chosen row's explanation on fixed lines under the list, above the keys: as many lines as
|
|
90
|
+
* the longest explanation of this list needs at this width, always, so nothing jumps. 80 columns is this form.
|
|
91
|
+
* < 60 the command column goes too; and at any width a command that would not fit whole on its row is left out.
|
|
92
|
+
* The chosen item is marked by `>` and by its ground, never by colour alone. `asked` is the row whose digit was pressed
|
|
93
|
+
* though it cannot be chosen: its `quiet` line (and its explanation, where that is not on its row) is said under the list.
|
|
94
|
+
* A list taller than the terminal shows the items around the chosen one: a menu taller than the screen could not be redrawn in place.
|
|
78
95
|
*/
|
|
79
|
-
export function menuFrame({ header = [], title = null, items, at = 0, ticked = new Set(), multi = false, top = false, footer = null }, { rows = 24, columns = 100, p = paint } = {}) {
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const
|
|
96
|
+
export function menuFrame({ header = [], title = null, items, at = 0, ticked = new Set(), multi = false, top = false, footer = null, asked = null }, { rows = 24, columns = 100, p = paint } = {}) {
|
|
97
|
+
const width = columns - 1;
|
|
98
|
+
const heads = (lines) => [...lines, ...(title ? ["", ` ${p.bold(title)}`] : []), ""];
|
|
99
|
+
const keys = ` ${p.dim(footer ?? (multi ? "↑/↓ move · Space tick · Enter confirm · Esc back" : `↑/↓ move · Enter open · Esc ${top ? "quit" : "back"} · 1-9 jump`))}`;
|
|
83
100
|
const box = (item) => (multi && item.tick ? `[${ticked.has(item.label) ? "x" : " "}] ` : "");
|
|
84
|
-
const
|
|
85
|
-
// The commands stand in one column beside the names (a name longer than
|
|
86
|
-
const
|
|
101
|
+
const size = (item) => visibleLength(`${box(item)}${item.label}${item.note ? ` · ${item.note.text}` : ""}`);
|
|
102
|
+
// The commands stand in one column beside the names (a name longer than 64 pushes only its own command; a table row is a name).
|
|
103
|
+
const nameCol = Math.min(64, Math.max(0, ...items.map(size))), hintCol = Math.max(0, ...items.map((item) => (item.hint ?? "").length));
|
|
104
|
+
const upTo = (item) => 6 + Math.max(nameCol, size(item)) + 3; // where this row's command starts
|
|
105
|
+
const wide = columns >= 60 && items.every((item) => !item.info || upTo(item) + hintCol + 3 + item.info.length <= width);
|
|
87
106
|
const line = (item, i) => {
|
|
88
107
|
const label = ` ${i < 9 ? i + 1 : " "} ${box(item)}${item.label} `;
|
|
89
108
|
const note = item.note ? `· ${p[item.note.tone]?.(item.note.text) ?? item.note.text}` : "";
|
|
90
109
|
const name = i === at ? p.inverse(label) : item.disabled ? p.dim(label) : p.bold(label);
|
|
91
|
-
|
|
110
|
+
const gap = " ".repeat(Math.max(0, nameCol - size(item)) + (item.note ? 3 : 2)); // a name without a note ends in its own space
|
|
111
|
+
if (wide) return `${i === at ? ">" : " "} ${name}${note}${gap}${p.dim(item.info ? (item.hint ?? "").padEnd(hintCol) : item.hint ?? "")}${item.info ? ` ${p.dim(item.info)}` : ""}`;
|
|
112
|
+
return `${i === at ? ">" : " "} ${name}${note}${columns >= 60 && item.hint && upTo(item) + item.hint.length <= width ? `${gap}${p.dim(item.hint)}` : ""}`;
|
|
92
113
|
};
|
|
93
|
-
//
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
114
|
+
// Under the list: what the chosen row does or, after the digit of a row that cannot be chosen, why not.
|
|
115
|
+
const told = (item, refused) => [refused ? item.quiet : null, item.info].filter(Boolean).join(" ");
|
|
116
|
+
const need = Math.max(1, ...items.map((item) => wrap(told(item, item.disabled), width - 2).length));
|
|
117
|
+
const said = wrap(asked === null ? told(items[at], false) : told(items[asked], true), width - 2).map((part) => ` ${part}`);
|
|
118
|
+
const foot = wide ? ["", keys, ...(asked === null ? [] : [` ${p.dim(items[asked].quiet ?? items[asked].info ?? "")}`])] : ["", ...said, ...Array(Math.max(0, need - said.length)).fill(""), "", keys];
|
|
119
|
+
// A terminal too short for the list under the whole head keeps the head's first line only: the list matters more than the summary.
|
|
120
|
+
const all = items.map(line), fits = (lines) => all.length <= rows - 1 - lines.length - foot.length;
|
|
121
|
+
const head = fits(heads(header)) ? heads(header) : heads(header.slice(0, 1)), room = Math.max(3, rows - 1 - head.length - foot.length);
|
|
122
|
+
if (all.length <= room) return [...head, ...all, ...foot];
|
|
123
|
+
const span = Math.max(1, room - 2), from = Math.max(0, Math.min(at - Math.floor(span / 2), items.length - span));
|
|
124
|
+
return [...head, ` ${p.dim(from > 0 ? "↑ more" : "")}`, ...all.slice(from, from + span), ` ${p.dim(from + span < items.length ? "↓ more" : "")}`, ...foot];
|
|
102
125
|
}
|
|
103
126
|
|
|
104
127
|
/**
|
|
105
128
|
* One list: → { item } (Enter or a digit), "back" (Esc, ←), "quit" (q at the top, Ctrl+C). `items`: { label, hint?, info?,
|
|
106
|
-
* note?, disabled? }.
|
|
129
|
+
* note?, disabled?, quiet? }. A disabled item is never chosen: the arrows pass it, the list opens on the first item that can
|
|
130
|
+
* be, and its digit only says its `quiet` line. `multi`: Space ticks an item that has `tick: true`; the ticked items come back as `ticked`. `header`:
|
|
107
131
|
* the lines, or a function giving them, asked at every draw so a state a command just changed shows at once.
|
|
108
132
|
*/
|
|
109
133
|
export async function choose(term, { header = [], title, items, top = false, multi = false, footer = null }) {
|
|
110
134
|
let at = Math.max(0, items.findIndex((i) => !i.disabled));
|
|
111
135
|
const ticked = new Set(items.filter((i) => i.ticked).map((i) => i.label));
|
|
136
|
+
let asked = null; // the row whose digit was pressed though it cannot be chosen (0.11.9), said under the list until the next key
|
|
112
137
|
for (;;) {
|
|
113
|
-
term.draw(menuFrame({ header: typeof header === "function" ? header() : header, title, items, at, ticked, multi, top, footer }, term.size()));
|
|
138
|
+
term.draw(menuFrame({ header: typeof header === "function" ? header() : header, title, items, at, ticked, multi, top, footer, asked }, term.size()));
|
|
114
139
|
const k = await term.key();
|
|
115
140
|
if (k.name === "resize") { term.reset(); continue; }
|
|
141
|
+
asked = /^[1-9]$/.test(k.str ?? "") && items[Number(k.str) - 1]?.disabled ? Number(k.str) - 1 : null;
|
|
116
142
|
if (k.ctrl && k.name === "c") return "quit";
|
|
117
143
|
if (k.name === "up" || k.name === "k") { do at = (at - 1 + items.length) % items.length; while (items[at].disabled); continue; }
|
|
118
144
|
if (k.name === "down" || k.name === "j") { do at = (at + 1) % items.length; while (items[at].disabled); continue; }
|
|
119
|
-
if (k.name === "escape"
|
|
145
|
+
if (k.name === "escape") return top ? "quit" : "back"; // 0.11.9: Esc leaves the top like q (a lone Esc: readline tells it from an arrow's sequence)
|
|
146
|
+
if (k.name === "left") { if (!top) return "back"; continue; }
|
|
120
147
|
if (k.name === "q" && top) return "quit";
|
|
121
148
|
if (multi && k.name === "space" && items[at].tick) { ticked.has(items[at].label) ? ticked.delete(items[at].label) : ticked.add(items[at].label); continue; }
|
|
122
149
|
if (/^[1-9]$/.test(k.str ?? "") && items[Number(k.str) - 1] && !items[Number(k.str) - 1].disabled) { at = Number(k.str) - 1; if (!multi) return { item: items[at] }; continue; }
|
|
@@ -157,7 +184,7 @@ export async function runShown(term, io, args, label = null) {
|
|
|
157
184
|
}
|
|
158
185
|
|
|
159
186
|
/** What the Remote Agent item says where this Node has no WebSocket; Enter opens the ways forward (node-guide.mjs). */
|
|
160
|
-
export const REMOTE_NEEDS = "Needs Node 22.4 or later
|
|
187
|
+
export const REMOTE_NEEDS = "Needs Node 22.4 or later. Enter shows the ways to get it.";
|
|
161
188
|
|
|
162
189
|
const newer = (a, b) => { const x = String(a).split(".").map(Number), y = String(b).split(".").map(Number); for (let i = 0; i < 3; i += 1) if (x[i] !== y[i]) return x[i] > y[i]; return false; };
|
|
163
190
|
|
|
@@ -165,58 +192,125 @@ const newer = (a, b) => { const x = String(a).split(".").map(Number), y = String
|
|
|
165
192
|
* What the Update item says beside its name (owner, 2026-11-13), from the state read again after every command, so it is
|
|
166
193
|
* true the moment an update finishes: this computer's installed version behind this CLI's ("0.11.7 → 0.11.8 available"),
|
|
167
194
|
* a newer CLI published than the one running, or "up to date (0.11.8)". Null when this computer is not connected.
|
|
195
|
+
*
|
|
196
|
+
* THREE STATES, NEVER TWO (0.11.9, owner 2026-11-14: "now you can do the update twice"). Something to update; nothing to
|
|
197
|
+
* update and KNOWN so (`settled`: this computer runs this CLI's version and the registry answered that none is newer), which
|
|
198
|
+
* is the one state where the item cannot be chosen; and not known (the registry did not answer, or this computer's version
|
|
199
|
+
* is not this CLI's): that one says what it knows, claims no "up to date", and can still be chosen.
|
|
168
200
|
*/
|
|
169
201
|
export function updateNote(state) {
|
|
170
202
|
if (!state.connected) return null;
|
|
171
203
|
if (state.installed && newer(state.version, state.installed)) return { text: `${state.installed} → ${state.version} available`, tone: "yellow", behind: "computer" };
|
|
172
204
|
if (state.latest && newer(state.latest, state.version)) return { text: `${state.version} → ${state.latest} available`, tone: "yellow", behind: "cli" };
|
|
173
|
-
return { text:
|
|
205
|
+
if (!state.latestKnown) return { text: "newest not checked", tone: "dim", behind: null };
|
|
206
|
+
return { text: `up to date (${state.version})`, tone: state.installed === state.version ? "dim" : "green", behind: null, settled: state.installed === state.version };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Remote Agent here, in one word, with its confirmed connections; from this computer's own files. A file that cannot be read
|
|
211
|
+
* is "not known", never "not set up" (remote-store readJson refuses an unreadable or non-private one).
|
|
212
|
+
*/
|
|
213
|
+
export function remoteState() {
|
|
214
|
+
try { const s = loadSettings(), links = loadPhones().confirmed.length; return { links, word: !loadIdentity() ? "not set up" : !s.enabled ? "off" : s.paused ? "paused" : "approved" }; }
|
|
215
|
+
catch { return { links: null, word: "not known" }; }
|
|
174
216
|
}
|
|
175
217
|
|
|
176
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* The head. Not connected: the version and the one fact. Connected (0.11.9, owner 2026-11-14): a summary, label and value,
|
|
220
|
+
* of what this computer's own files say; never the key, never a secret; a date not recorded is a dash, a state that could
|
|
221
|
+
* not be read is "not known". `state`: version, latest, account, host, since, hook, door, apps (worktrust.mjs).
|
|
222
|
+
*/
|
|
177
223
|
export function headerLines(state) {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
224
|
+
const title = ` ${paint.bold(`WorkTrust CLI ${state.version}`)}${state.latest ? ` ${paint.yellow(`! ${state.latest} is out: quit, then npx -y worktrust@latest`)}` : ""}`;
|
|
225
|
+
if (!state.connected) return [title, " Not connected yet"];
|
|
226
|
+
const row = (label, value) => ` ${paint.dim(label.padEnd(14))} ${value}`, remote = remoteState(), host = String(state.host ?? "this computer");
|
|
227
|
+
const known = (value, yes, no) => (value === true ? yes : value === false ? no : "not known");
|
|
228
|
+
return [
|
|
229
|
+
title,
|
|
230
|
+
row("Account", state.account ?? "not recorded: run Check this computer"),
|
|
231
|
+
row("This computer", `${host.length > 28 ? `${host.slice(0, 27)}…` : host} · connected since ${/^\d{4}-\d{2}-\d{2}/.test(String(state.since ?? "")) ? String(state.since).slice(0, 10) : "-"}`),
|
|
232
|
+
row("Remote Agent", remote.links === null || ["not set up", "off"].includes(remote.word) ? remote.word : `${remote.word}, ${remote.links} connection${remote.links === 1 ? "" : "s"}`),
|
|
233
|
+
row("Sharing", `session hook ${known(state.hook, "on", "not installed")} · AI apps ${state.door === "off" ? "off" : state.door === "on" ? `on${Number.isInteger(state.apps) ? ` (${state.apps})` : ""}` : "not known"} · Remote Agent ${remote.word === "not set up" ? "off" : remote.word}`),
|
|
234
|
+
];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const HELP = (open) => ({ label: "Help · all commands", hint: "npx worktrust help", info: "Lists all commands. npx -y worktrust skips npm's question.", run: () => open(["help"]) });
|
|
238
|
+
const QUIT = { label: "Quit", hint: "q", info: "Leaves the menu. Nothing keeps running.", quit: true };
|
|
239
|
+
const PRESERVE = (sub, info) => ({ label: "Preserve evidence ›", hint: "npx worktrust preserve …", info, run: () => sub.preserve?.() });
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* THE FIRST MENU (0.11.9, owner 2026-11-14): what a computer that is not connected can do, and nothing that needs a
|
|
243
|
+
* connected one (no Update, Remote Agent, Import, AI apps switch, Status, Disconnect). Preserve needs no account, no key
|
|
244
|
+
* and no network at any of its levels (preserve.mjs; worktrust.mjs loads no key for it), so all of it stays.
|
|
245
|
+
*/
|
|
246
|
+
export function firstItems(open = () => true, sub = {}) {
|
|
185
247
|
return [
|
|
186
|
-
|
|
187
|
-
|
|
248
|
+
{ label: "Connect this computer", hint: "npx worktrust connect", info: "Asks before it writes; your browser signs in to WorkTrust.", run: () => open(["connect"]) },
|
|
249
|
+
PRESERVE(sub, "Keep your AI history here. No account; nothing is sent."),
|
|
250
|
+
HELP(open), QUIT,
|
|
188
251
|
];
|
|
189
252
|
}
|
|
190
253
|
|
|
254
|
+
/** Why the first menu still stands after Connect ran, in one line, by how the command ended (0 without a key: a No or a dry run). */
|
|
255
|
+
export function connectReason(code) {
|
|
256
|
+
if (code === 0) return "Connect stopped before the sign-in; nothing was written. 1 tries again.";
|
|
257
|
+
if (code === 130) return "Connect was cancelled; this computer is not connected. 1 tries again.";
|
|
258
|
+
return "Connect ended with the message above; not connected. 1 tries again.";
|
|
259
|
+
}
|
|
260
|
+
|
|
191
261
|
/**
|
|
192
262
|
* The top list (owner, 2026-11-13): Update first, then Check, then the rest as before. Pure but for the `run` closures.
|
|
193
263
|
* `open(args)` runs one direct command; `sub` holds the deeper levels.
|
|
194
264
|
*/
|
|
195
265
|
export function topItems(state, open = () => true, sub = {}) {
|
|
196
|
-
|
|
266
|
+
if (!state.connected) return firstItems(open, sub);
|
|
197
267
|
const note = updateNote(state);
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
: note.behind === "computer" ? `Brings this computer
|
|
201
|
-
:
|
|
268
|
+
const same = state.installed === state.version; // then `update` changes nothing and says so (worktrust.mjs update, 0.11.9)
|
|
269
|
+
const updateInfo = note.behind === "cli" ? "Newer CLI: quit, then npx -y worktrust@latest update."
|
|
270
|
+
: note.behind === "computer" ? `Brings this computer from ${state.installed} to ${state.version}. Your key stays.`
|
|
271
|
+
: note.settled ? "Nothing to update: this computer runs the latest version."
|
|
272
|
+
: same ? "Newest version not checked. Enter changes nothing here."
|
|
273
|
+
: "Sets up this computer's hook and AI-app doors again.";
|
|
202
274
|
return [
|
|
203
|
-
{ label: "Update WorkTrust", note, hint: "npx worktrust update", info: updateInfo, run: () => open(["update"]) },
|
|
204
|
-
{ label: "Check this computer", hint: "npx worktrust", info:
|
|
275
|
+
{ label: "Update WorkTrust", note, hint: "npx worktrust update", info: updateInfo, run: () => open(["update"]), ...(note.settled ? { disabled: true, quiet: "Already up to date." } : {}) },
|
|
276
|
+
{ label: "Check this computer", hint: "npx worktrust", info: "Shows what is coupled here and finishes what waits.", run: () => open([]) },
|
|
205
277
|
// Node before 22.4 has no WebSocket (0.11.8): the item stays, says why, and Enter opens the ways forward, not the levels.
|
|
206
278
|
state.remoteBlocked
|
|
207
279
|
? { label: "Remote Agent", note: { text: "needs Node 22.4+", tone: "yellow" }, hint: "npx worktrust remote …", info: REMOTE_NEEDS, run: () => open(["remote"]) }
|
|
208
|
-
: { label: "Remote Agent ›", hint: "npx worktrust remote …", info: "
|
|
209
|
-
{ label: "Import earlier history ›", hint: "npx worktrust history …", info: "
|
|
210
|
-
|
|
211
|
-
{ label:
|
|
212
|
-
{ label: "Status", hint: "npx worktrust status", info: "Shows the key, the hook
|
|
213
|
-
{ label: "Disconnect this computer", hint: "npx worktrust disconnect", info: "Takes WorkTrust out
|
|
214
|
-
|
|
215
|
-
{ label: "Quit", hint: "q", info: "Leaves the menu. Nothing keeps running.", quit: true },
|
|
280
|
+
: { label: "Remote Agent ›", hint: "npx worktrust remote …", info: "Steer this computer's agents from your phone.", run: () => sub.remote?.() },
|
|
281
|
+
{ label: "Import earlier history ›", hint: "npx worktrust history …", info: "Send earlier sessions as history. Each way asks first.", run: () => sub.history?.() },
|
|
282
|
+
PRESERVE(sub, "Keep your AI history on this computer. Nothing is sent."),
|
|
283
|
+
{ label: "Sharing ›", hint: "npx worktrust mcp …", info: "What this computer sends, and the switches for it.", run: () => sub.sharing?.() },
|
|
284
|
+
{ label: "Status", hint: "npx worktrust status", info: "Shows the key, the hook and the door. It only reads.", run: () => open(["status"]) },
|
|
285
|
+
{ label: "Disconnect this computer", hint: "npx worktrust disconnect", info: "Takes WorkTrust out and ends this computer's key. It asks.", run: () => open(["disconnect"]) },
|
|
286
|
+
HELP(open), QUIT,
|
|
216
287
|
];
|
|
217
288
|
}
|
|
218
289
|
|
|
219
|
-
/**
|
|
290
|
+
/**
|
|
291
|
+
* The menu's loop, apart from the process (0.11.9) so a test can drive it. The state is read again after every command: the
|
|
292
|
+
* version line and the Update item say the new state the moment an update ends, and the first menu becomes the full one the
|
|
293
|
+
* moment Connect leaves a key. When Connect ran and there is still no key, the first menu stays and its header says why.
|
|
294
|
+
*/
|
|
295
|
+
export async function menuLoop(term, io, levels) {
|
|
296
|
+
let last = null, state = null; // the command the top level ran last and how it ended; this computer's state as last read
|
|
297
|
+
const read = async () => (state = { ...(await busyWith("Reading this computer's state", () => io.state())), remoteBlocked: typeof globalThis.WebSocket !== "function" });
|
|
298
|
+
// A deeper level reads the state again after each of its commands (inner.state), so the head above it is true at once.
|
|
299
|
+
const inner = { runCli: (args) => io.runCli(args), state: read };
|
|
300
|
+
for (;;) {
|
|
301
|
+
await read();
|
|
302
|
+
const why = !state.connected && last?.args[0] === "connect" ? connectReason(last.code) : null;
|
|
303
|
+
const header = () => [...headerLines(state), ...(why ? [` ${paint.yellow(`! ${why}`)}`] : [])];
|
|
304
|
+
const open = (args) => { const ran = { args, code: 1 }; last = ran; return runShown(term, { runCli: async (given) => (ran.code = await io.runCli(given)) }, args); };
|
|
305
|
+
const items = topItems(state, open, Object.fromEntries(["remote", "history", "preserve", "sharing"].map((name) => [name, () => levels[`${name}Menu`](term, inner, header)])));
|
|
306
|
+
const picked = await choose(term, { header, items, top: true });
|
|
307
|
+
if (picked === "quit" || picked === "back" || picked.item.quit) break;
|
|
308
|
+
last = null;
|
|
309
|
+
if ((await picked.item.run()) === false) break;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** The top of the menu. `io`: { runCli(args) → Promise<code>, state() → { version, installed, latest, latestKnown, account, connected, door, host, since, hook, apps } }. */
|
|
220
314
|
// (remoteBlocked is added here: whether this Node lacks the WebSocket Remote Agent needs.)
|
|
221
315
|
export async function runMenu(io) {
|
|
222
316
|
paint = coloursFor(process.stdout);
|
|
@@ -227,16 +321,7 @@ export async function runMenu(io) {
|
|
|
227
321
|
process.on("SIGTERM", onSignal);
|
|
228
322
|
try {
|
|
229
323
|
term.enter();
|
|
230
|
-
|
|
231
|
-
for (;;) {
|
|
232
|
-
// Read again after every command: the version line and the Update item say the new state the moment an update ends.
|
|
233
|
-
const state = { ...(await busyWith("Reading this computer's state", () => io.state())), remoteBlocked: typeof globalThis.WebSocket !== "function" };
|
|
234
|
-
const header = () => headerLines(state);
|
|
235
|
-
const items = topItems(state, (args) => runShown(term, io, args), { remote: () => remoteMenu(term, io, header), history: () => historyMenu(term, io, header), preserve: () => preserveMenu(term, io, header) });
|
|
236
|
-
const picked = await choose(term, { header, items, top: true });
|
|
237
|
-
if (picked === "quit" || picked === "back" || picked.item.quit) break;
|
|
238
|
-
if ((await picked.item.run()) === false) break;
|
|
239
|
-
}
|
|
324
|
+
await menuLoop(term, io, await import("./cli-menu-remote.mjs"));
|
|
240
325
|
} finally {
|
|
241
326
|
process.off("SIGINT", onSignal);
|
|
242
327
|
process.off("SIGTERM", onSignal);
|
package/engine-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","cli-colour.mjs":"fa16b61ad179999c5c5365255182acf69bcba1eb5f5ce7b0e1e18c11f56130ae","cli-menu-remote.mjs":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","cli-colour.mjs":"fa16b61ad179999c5c5365255182acf69bcba1eb5f5ce7b0e1e18c11f56130ae","cli-menu-remote.mjs":"4f7284911d86e4463797e7dec976c4c10f46e6fdb3053c5ad211210e1efe25e5","cli-menu.mjs":"09eed126c220ffdfba8fedd7f2730ddcbc75471c31dcb5ce066c02592aa3b3b9","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"06b0ecbc222087160dc64c0b302391631e8e799038364c317c6cd28449c5044d","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","export-facts.mjs":"3bbb46c80e8678b5cea7e15dcbfc456a2b48595053241c2b3cea508092f9b917","folder-picker.mjs":"daeb379626d5716f91f588064c6b4083618279320c006c177960cc93f056d96a","git-commits.mjs":"af0ed45a2a42c8e17cabfb3649a2f524dbf80230f8a6ec1c6b775fed7d34dc9c","history-outbox.mjs":"85c70389effc5b4ec9d9b33af9192314e67f47af2752515b42a7959344ce2354","history-progress.mjs":"dcc25ee94b727f2605a763349a4d8764640335d6cf0043fb6108cebeed16dcb9","log-session.mjs":"167fe3718415fe690c9e4f7a3a993520e8c652edcf61184cc14cfec2db67d7bc","node-guide.mjs":"5bf52c5028b07a80ec4d41be365eb025dfce74328f41f928a26ce6737b1f9cc4","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":"cd111cae0f53a25a2d878a158479abfb1ace353361454843f91a16d241101d46","project-modes.mjs":"ada26e68297fbeb90e4e91d75a90fd2d7cc107b999a9702840675b5a7529463e","remote-adapter-claude-code.mjs":"6db24891f7b0c56c00b337e52f4d4aeb8c9a0413b3bf46d0fc8a45328ea71b3e","remote-adapter-codex.mjs":"d2fd6c61d9e3c4a45e9b10da1aa3c15d45c86629d6456e4a8d25ad95b13eb209","remote-adapter-opencode.mjs":"ddd7f3ec0b4ba92f4744453d60fda338b63550e3ec7b23fa3acc668df1d64eb7","remote-adapter-terminal.mjs":"9237d3747a25126fcdad42c0eab10e69393754388a6014b30fb0890b9c735888","remote-admin.mjs":"ac4d434c0a374159b27accac3fdd0324ff96ffe32227fba054cc62d00e58d35b","remote-agent-switch.mjs":"7ff5448f29f05a47d7298d730b21243a1bcf8a215b434a0c7fbf5f3cb0889041","remote-approval-bridge.mjs":"092f17b7969e4f35bea064315d04dcde1faa6a3fd3e737dcc05aece82c7a37c4","remote-approvals.mjs":"63847226e398f9eb5b8d3989ba2b2436fbedd898385eb5f2f63bbdf07fbe6852","remote-attachments.mjs":"2e9c1277329a45cf26c0c62abda632cf0ab9fad78d0504416ecee9805220e16c","remote-cdp.mjs":"70e333a1ebe845e872cc3a703a0a507391f8ce59640bdbd662bdad55eeff216b","remote-changes.mjs":"2141fece4961a5bc1bb1b046f78222812617457b1ba6452275eac6a897e62e19","remote-claude-events.mjs":"58822471203c6a1b66cf81c115c4d713657c3dea5c7b98df959f894ee5b2e704","remote-claude-progress.mjs":"2ca626d3dbc16d8d570abe1df6477b7e44ffb43c1d9145228ec5ea1928e415ca","remote-cli.mjs":"651a7f16e7475029985007ea97f4b838f8378ab620d3f3c2ab718da155fce94d","remote-coalesce.mjs":"cb0967d9cfe81e3892bcade8349d6814db98be8c2adbdb54df0b8d1b142f65d1","remote-codex-events.mjs":"58657d6070a50c837737cb85f5a1eaf9c2cbc4e1adfe3e970748ab3b2af94631","remote-connections.mjs":"e24ff04ed61647e164b6f055d4f691366f3204fe445140afc5f34abbed5d4080","remote-countdown.mjs":"85cf2d01fe5ca49895e08a3d5de346bb5e4a8dd31b9fda3fd9f9534d9e1e47cf","remote-daemon.mjs":"94d4896b0e1203f7a5bc7224a6221a36f4c20be89caee78b3ab37b9b6a2dac1d","remote-endorse.mjs":"89eda4883567176703e01e44d83e987271bc2a6134e108f517b3b213719a21f9","remote-inventory.mjs":"a8245604d41373819738eaf06ec1d2242cb5f7b2e60aa316f31d2f8742b8c70d","remote-journal.mjs":"907ebd48c53162b22dc743ef95b53c1a6be6886a7495605b5cfa820b8de9d330","remote-live-preview.mjs":"faa70f9260ac05037204c2a0c3facf4ffe42f68408948390b341b453a2932289","remote-opencode-events.mjs":"3108375501ead2c2c78bce1435cc2a9fe6d2af1d7ff1fb42e12ff3e0f5d9af9c","remote-opencode-session.mjs":"681b201d833a7d7d025122b3a79663bcdc0a989aefd39d8018a28113d8810caf","remote-pairing.mjs":"d8c2aba394fe73d850ea000c758e6b926c87b122eaf5c6aa92ec1183e90f90e1","remote-pipeline-config.mjs":"00cde6a61ce21144c51ac56fce42fee159aa9dba6586218a7ea790ce4a6bd40b","remote-pipeline-parsers.mjs":"43ca0d332d7bc883c4759a754a555815ae5dfe133446b91ba9f2e48a350fa20f","remote-pipeline.mjs":"b856ead989b29ddb618ef69bbacd104bae2b02c9d1c5214291d08ce469a8b24e","remote-policy.mjs":"16ea015ad5de3c357bce730ea8ea98571dc981d8591fb5156b1941b2c557a381","remote-preview.mjs":"fe504ad6f83dcb4a4ebdcc018686a9a5a900c47cdf8c45b75e7d02e2f3056155","remote-projects.mjs":"ec8c530ad3e880bca21a4d4078ecd68b6aaafcc442b50087127868d952034d5f","remote-protocol.mjs":"93f8c2031895d4e01006a1951d7c0e79ef71b86b2777eed5dfa966ab131e446d","remote-qr.mjs":"b80e2b4a5bc020cf6ed92e91d06b327cb5197de1c35b3445a0fc2c7a3bf1ab3f","remote-release-plans.mjs":"11884a62b7d6dcccb5e154a26603bdf650f7b40f946329fb174d8c13729bec74","remote-releases.mjs":"fb08b72593ea00013c8b679e0c0d7dee95b0fd7cc5fd31b80ac575d0e340927d","remote-run.mjs":"c180c401613e0c01dfc471bb6226ebb035a7299839f81c6e38ff714d75d68c3f","remote-screen-approvals.mjs":"c43ab286d36a38d17639d155782ffa017f1a9b6806a09b82ed0142a1290b6000","remote-screen-push.mjs":"4ee8bd48d24b2c87581e9f33d8354a86381f7febd82f89ed509a7a87c1442608","remote-screen-states.mjs":"7c3c86a584bebf52461f3cab39c05ea2a13910061704d48fc622956e842940f7","remote-service.mjs":"a3a5502e0f6f43b04e37ee778f43d88f4c219776439cfed0d8fa0b511e0c9637","remote-session-list.mjs":"494fdbe20f0542806ac6c42ad149c52e2d3ace23a3a7567f96dc7e80d092c727","remote-sessions.mjs":"1efb7869cef6090cbbeae15ff1e5ffe99dca3742f9c245686d6758bb705587d6","remote-settings.mjs":"ca16f39416a457bd5ceb1df847596e1b4bcd2894310eb6514664a619dee4981f","remote-steered.mjs":"d7afde92c62c87abbdb84b0cfea2eea4752e90a2e453e52a54812c4fe0395190","remote-steering.mjs":"7ba22e6110cea3ac75a4f084f8f92a5bd90c31a19d3ce58a88a0843bdadea834","remote-store.mjs":"7226d006d03788ea2a8de30226ab5f6bf45b1bcbb10ee7d4e28bf2c3cca5a2a7","remote-terminal-cli.mjs":"82a048b75e412d0b6db076afbb84cab7c754dec72b6c8b6af4d4906b38e988a7","remote-terminal-sessions.mjs":"6ab51824890a18768d23cedc499f3840b2b02a8ed651463c1fe2d74dd352a361","remote-transport.mjs":"68650fd77ea09b5762377f87cabdc1c73a34d77324aa5bf0cd9742094a50c32b","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","self-update.mjs":"378e3620d48c72cf0bf812be408883b995cdb2223de34a20f762dd73eeffb258","session-databases.mjs":"a16ffbc50ccc0e78f370ebe07f871d1a80f1977472e478e3599e7abfdc90c1b7","session-local-models.mjs":"bacd38ff8dd3056b552982ec52eb57c7b8ca86e1a46cd4cba30fc340e3e28fd4","setup-mcp.mjs":"b732e3dd9b3e522b7cc8acf167ce28ba8f1a8dee797ee15bd7c3b02919b13e6f","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"e9f20415c2b5d62a09f35a63075002ebd1da56edb32f242d52822d58ecbd8ac3","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"e2ac72ef0f14bb8b8f756f67c65b6adc88bc899e2794e8f0edcf305290ab7f33"},"format":"worktrust-package/1","kind":"engine","version":"0.11.9"},"signature":"vilYSSAd3p9Wk5pNj5taYk3DnUCz4-61GN1ZTCqMFxyo4dqt9vMVrIwcb7P5ksJZxu8ZP9WnP0lCwuA-ezOIDA"}
|
package/package-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"e8abb38c293b57b71d3a6163d6242d1f375e773372b91b6d8ce39c584c51262a","CHANGELOG.md":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"e8abb38c293b57b71d3a6163d6242d1f375e773372b91b6d8ce39c584c51262a","CHANGELOG.md":"3cae60d5eb0302bdcd0c737cc594677ddc8151359bfd3538d6707800225d35fd","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"8d0383d51db8bb0959eb3fa4eab482337c58492b254406c519e562911537d35f","README.md":"dd395252638bd253766b6b3bfe2362b687e86a17825982432245dcc776206a03","SECURITY.md":"6a798d875f48ae84c3a677397e5611e03b94215944952e0f61e13f6cfc949745","chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","cli-colour.mjs":"fa16b61ad179999c5c5365255182acf69bcba1eb5f5ce7b0e1e18c11f56130ae","cli-menu-remote.mjs":"4f7284911d86e4463797e7dec976c4c10f46e6fdb3053c5ad211210e1efe25e5","cli-menu.mjs":"09eed126c220ffdfba8fedd7f2730ddcbc75471c31dcb5ce066c02592aa3b3b9","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"06b0ecbc222087160dc64c0b302391631e8e799038364c317c6cd28449c5044d","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","engine-release.json":"8d97ea82525b5fcc6680fc8255caabc7ab68f4b04977b0e60e1326e09c6afed5","export-facts.mjs":"3bbb46c80e8678b5cea7e15dcbfc456a2b48595053241c2b3cea508092f9b917","folder-picker.mjs":"daeb379626d5716f91f588064c6b4083618279320c006c177960cc93f056d96a","git-commits.mjs":"af0ed45a2a42c8e17cabfb3649a2f524dbf80230f8a6ec1c6b775fed7d34dc9c","history-outbox.mjs":"85c70389effc5b4ec9d9b33af9192314e67f47af2752515b42a7959344ce2354","history-progress.mjs":"dcc25ee94b727f2605a763349a4d8764640335d6cf0043fb6108cebeed16dcb9","log-session.mjs":"167fe3718415fe690c9e4f7a3a993520e8c652edcf61184cc14cfec2db67d7bc","node-guide.mjs":"5bf52c5028b07a80ec4d41be365eb025dfce74328f41f928a26ce6737b1f9cc4","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","package.json":"0c8c690398d7bde34ddd45ae0f73bdf0546e8bc5f71cbf2de1f1db5d9092f5dc","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"cd111cae0f53a25a2d878a158479abfb1ace353361454843f91a16d241101d46","project-modes.mjs":"ada26e68297fbeb90e4e91d75a90fd2d7cc107b999a9702840675b5a7529463e","remote-adapter-claude-code.mjs":"6db24891f7b0c56c00b337e52f4d4aeb8c9a0413b3bf46d0fc8a45328ea71b3e","remote-adapter-codex.mjs":"d2fd6c61d9e3c4a45e9b10da1aa3c15d45c86629d6456e4a8d25ad95b13eb209","remote-adapter-opencode.mjs":"ddd7f3ec0b4ba92f4744453d60fda338b63550e3ec7b23fa3acc668df1d64eb7","remote-adapter-terminal.mjs":"9237d3747a25126fcdad42c0eab10e69393754388a6014b30fb0890b9c735888","remote-admin.mjs":"ac4d434c0a374159b27accac3fdd0324ff96ffe32227fba054cc62d00e58d35b","remote-agent-switch.mjs":"7ff5448f29f05a47d7298d730b21243a1bcf8a215b434a0c7fbf5f3cb0889041","remote-approval-bridge.mjs":"092f17b7969e4f35bea064315d04dcde1faa6a3fd3e737dcc05aece82c7a37c4","remote-approvals.mjs":"63847226e398f9eb5b8d3989ba2b2436fbedd898385eb5f2f63bbdf07fbe6852","remote-attachments.mjs":"2e9c1277329a45cf26c0c62abda632cf0ab9fad78d0504416ecee9805220e16c","remote-cdp.mjs":"70e333a1ebe845e872cc3a703a0a507391f8ce59640bdbd662bdad55eeff216b","remote-changes.mjs":"2141fece4961a5bc1bb1b046f78222812617457b1ba6452275eac6a897e62e19","remote-claude-events.mjs":"58822471203c6a1b66cf81c115c4d713657c3dea5c7b98df959f894ee5b2e704","remote-claude-progress.mjs":"2ca626d3dbc16d8d570abe1df6477b7e44ffb43c1d9145228ec5ea1928e415ca","remote-cli.mjs":"651a7f16e7475029985007ea97f4b838f8378ab620d3f3c2ab718da155fce94d","remote-coalesce.mjs":"cb0967d9cfe81e3892bcade8349d6814db98be8c2adbdb54df0b8d1b142f65d1","remote-codex-events.mjs":"58657d6070a50c837737cb85f5a1eaf9c2cbc4e1adfe3e970748ab3b2af94631","remote-connections.mjs":"e24ff04ed61647e164b6f055d4f691366f3204fe445140afc5f34abbed5d4080","remote-countdown.mjs":"85cf2d01fe5ca49895e08a3d5de346bb5e4a8dd31b9fda3fd9f9534d9e1e47cf","remote-daemon.mjs":"94d4896b0e1203f7a5bc7224a6221a36f4c20be89caee78b3ab37b9b6a2dac1d","remote-endorse.mjs":"89eda4883567176703e01e44d83e987271bc2a6134e108f517b3b213719a21f9","remote-inventory.mjs":"a8245604d41373819738eaf06ec1d2242cb5f7b2e60aa316f31d2f8742b8c70d","remote-journal.mjs":"907ebd48c53162b22dc743ef95b53c1a6be6886a7495605b5cfa820b8de9d330","remote-live-preview.mjs":"faa70f9260ac05037204c2a0c3facf4ffe42f68408948390b341b453a2932289","remote-opencode-events.mjs":"3108375501ead2c2c78bce1435cc2a9fe6d2af1d7ff1fb42e12ff3e0f5d9af9c","remote-opencode-session.mjs":"681b201d833a7d7d025122b3a79663bcdc0a989aefd39d8018a28113d8810caf","remote-pairing.mjs":"d8c2aba394fe73d850ea000c758e6b926c87b122eaf5c6aa92ec1183e90f90e1","remote-pipeline-config.mjs":"00cde6a61ce21144c51ac56fce42fee159aa9dba6586218a7ea790ce4a6bd40b","remote-pipeline-parsers.mjs":"43ca0d332d7bc883c4759a754a555815ae5dfe133446b91ba9f2e48a350fa20f","remote-pipeline.mjs":"b856ead989b29ddb618ef69bbacd104bae2b02c9d1c5214291d08ce469a8b24e","remote-policy.mjs":"16ea015ad5de3c357bce730ea8ea98571dc981d8591fb5156b1941b2c557a381","remote-preview.mjs":"fe504ad6f83dcb4a4ebdcc018686a9a5a900c47cdf8c45b75e7d02e2f3056155","remote-projects.mjs":"ec8c530ad3e880bca21a4d4078ecd68b6aaafcc442b50087127868d952034d5f","remote-protocol.mjs":"93f8c2031895d4e01006a1951d7c0e79ef71b86b2777eed5dfa966ab131e446d","remote-qr.mjs":"b80e2b4a5bc020cf6ed92e91d06b327cb5197de1c35b3445a0fc2c7a3bf1ab3f","remote-release-plans.mjs":"11884a62b7d6dcccb5e154a26603bdf650f7b40f946329fb174d8c13729bec74","remote-releases.mjs":"fb08b72593ea00013c8b679e0c0d7dee95b0fd7cc5fd31b80ac575d0e340927d","remote-run.mjs":"c180c401613e0c01dfc471bb6226ebb035a7299839f81c6e38ff714d75d68c3f","remote-screen-approvals.mjs":"c43ab286d36a38d17639d155782ffa017f1a9b6806a09b82ed0142a1290b6000","remote-screen-push.mjs":"4ee8bd48d24b2c87581e9f33d8354a86381f7febd82f89ed509a7a87c1442608","remote-screen-states.mjs":"7c3c86a584bebf52461f3cab39c05ea2a13910061704d48fc622956e842940f7","remote-service.mjs":"a3a5502e0f6f43b04e37ee778f43d88f4c219776439cfed0d8fa0b511e0c9637","remote-session-list.mjs":"494fdbe20f0542806ac6c42ad149c52e2d3ace23a3a7567f96dc7e80d092c727","remote-sessions.mjs":"1efb7869cef6090cbbeae15ff1e5ffe99dca3742f9c245686d6758bb705587d6","remote-settings.mjs":"ca16f39416a457bd5ceb1df847596e1b4bcd2894310eb6514664a619dee4981f","remote-steered.mjs":"d7afde92c62c87abbdb84b0cfea2eea4752e90a2e453e52a54812c4fe0395190","remote-steering.mjs":"7ba22e6110cea3ac75a4f084f8f92a5bd90c31a19d3ce58a88a0843bdadea834","remote-store.mjs":"7226d006d03788ea2a8de30226ab5f6bf45b1bcbb10ee7d4e28bf2c3cca5a2a7","remote-terminal-cli.mjs":"82a048b75e412d0b6db076afbb84cab7c754dec72b6c8b6af4d4906b38e988a7","remote-terminal-sessions.mjs":"6ab51824890a18768d23cedc499f3840b2b02a8ed651463c1fe2d74dd352a361","remote-transport.mjs":"68650fd77ea09b5762377f87cabdc1c73a34d77324aa5bf0cd9742094a50c32b","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","self-update.mjs":"378e3620d48c72cf0bf812be408883b995cdb2223de34a20f762dd73eeffb258","session-databases.mjs":"a16ffbc50ccc0e78f370ebe07f871d1a80f1977472e478e3599e7abfdc90c1b7","session-local-models.mjs":"bacd38ff8dd3056b552982ec52eb57c7b8ca86e1a46cd4cba30fc340e3e28fd4","setup-mcp.mjs":"b732e3dd9b3e522b7cc8acf167ce28ba8f1a8dee797ee15bd7c3b02919b13e6f","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"e9f20415c2b5d62a09f35a63075002ebd1da56edb32f242d52822d58ecbd8ac3","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"e2ac72ef0f14bb8b8f756f67c65b6adc88bc899e2794e8f0edcf305290ab7f33"},"format":"worktrust-package/1","kind":"npm","version":"0.11.9"},"signature":"9_ypkspVXoOYgaTLdv4CCVZ0IOr5m9RLTjtNVLFw_cl0VaVPbStkxGx9OuPFDcLX7kcP0jt2_EyE6GjaRiKdAw"}
|
package/package.json
CHANGED
package/worktrust.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* WorkTrust on a computer, in one command — like `gh auth login` (2026-10-03).
|
|
4
|
-
* npx worktrust in a person's own terminal (0.11.7; 0.11.8: Update first
|
|
4
|
+
* npx worktrust in a person's own terminal (0.11.7; 0.11.8: Update first; 0.11.9: not connected yet, a short
|
|
5
|
+
* menu: Connect, Preserve, Help): the menu (cli-menu.mjs), one item of which is
|
|
5
6
|
* what the bare command did until then; without a terminal, exactly that:
|
|
6
7
|
* show the plan, ask, approve this computer in the app, couple (0.10.7: a person's
|
|
7
8
|
* command always runs the newest version, whatever npx had cached);
|
|
@@ -11,7 +12,9 @@
|
|
|
11
12
|
* npx worktrust --device a computer without a browser (SSH): type a code on another device
|
|
12
13
|
* npx worktrust connect couple again, also on a computer already coupled
|
|
13
14
|
* npx worktrust update this computer onto the newest CLI, same key, no new pairing (0.10.30: what
|
|
14
|
-
* was agreed before is refreshed unasked; --rebuild agrees to the re-measure
|
|
15
|
+
* was agreed before is refreshed unasked; --rebuild agrees to the re-measure;
|
|
16
|
+
* 0.11.9: already on this version with nothing waiting, it says so and
|
|
17
|
+
* changes nothing; --force sets everything up again all the same)
|
|
15
18
|
* npx worktrust history send this computer's earlier sessions as history (asks first)
|
|
16
19
|
* npx worktrust history --rebuild the same as history (0.10.5: history always re-measures); WorkTrust replaces this computer's
|
|
17
20
|
* earlier lines day by day, never counting a day twice (shows the plan, asks first)
|
|
@@ -80,7 +83,7 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
|
|
|
80
83
|
const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
|
|
81
84
|
const has = (name) => args.includes(`--${name}`);
|
|
82
85
|
/** 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). */
|
|
83
|
-
const CLI_VERSION = "0.11.
|
|
86
|
+
const CLI_VERSION = "0.11.9";
|
|
84
87
|
/**
|
|
85
88
|
* 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
|
|
86
89
|
* to offer). Raised ONLY when what is measured changes: the timeline, the seconds, the tokens, the steering, the session
|
|
@@ -701,9 +704,18 @@ async function sessionEnd() {
|
|
|
701
704
|
async function update() {
|
|
702
705
|
const key = await freshKey();
|
|
703
706
|
if (!key) fail("this computer has no WorkTrust key file yet. Run npx worktrust connect.");
|
|
704
|
-
say();
|
|
705
|
-
|
|
706
|
-
|
|
707
|
+
const title = () => { say(); say(` WorkTrust · update ${hostname().replace(/\.local$/i, "")} to ${CLI_VERSION}`); say(); };
|
|
708
|
+
// ALREADY ON THIS VERSION (0.11.9, owner 2026-11-14: "when the latest version is already there it is useless to run the
|
|
709
|
+
// update again"): the second run took every door out and put it back, and said "7 added". Now it says so and changes
|
|
710
|
+
// nothing, but only when NOTHING waits: this version's stable copy, the door chosen, every AI app's door standing by the
|
|
711
|
+
// writer's own reading, nothing new to agree to, no Codex or Antigravity question open. `--force` is the repair road.
|
|
712
|
+
const same = !has("force") && !has("codex") && !has("antigravity") && stableVersion() === CLI_VERSION && existsSync(STABLE) && Boolean(doorState());
|
|
713
|
+
if (!same) title();
|
|
714
|
+
// The plan below asks the writer whether each door names THIS release's bridge, so the bridge's place must be the installed
|
|
715
|
+
// one first; the same release already in ~/.worktrust is only verified here, never written again.
|
|
716
|
+
// The old install is read BEFORE anything is prepared (check-core-logic history-rebuild: the rebuild offer compares it).
|
|
717
|
+
const previous = stableInstall();
|
|
718
|
+
if (same) await prepareBundledRuntime();
|
|
707
719
|
const paths = await scripts();
|
|
708
720
|
if (!doorState() && !has("dry-run")) saveDoorState({ mode: await chooseDoor(), asked: new Date().toISOString() }); // once, for a computer coupled before 0.10.37
|
|
709
721
|
const doorIsOff = doorOff();
|
|
@@ -711,10 +723,22 @@ async function update() {
|
|
|
711
723
|
// AGREED BEFORE, REFRESHED WITHOUT A QUESTION (0.10.30): an app or hook the person said yes to is brought onto this
|
|
712
724
|
// version's launcher; only what is NEW here is shown in full and asked about, and --yes leaves the new ones as they are.
|
|
713
725
|
const agreed = await consent();
|
|
714
|
-
say(" Every AI app found here gets the WorkTrust door, the local command that reads the key:");
|
|
715
726
|
const found = doorIsOff ? [] : planLines(plan.out, true).filter((line) => !line.includes("not on this machine"));
|
|
716
|
-
if (doorIsOff) say(` the door stays off here (hours only, ${DOOR_SWITCH})`);
|
|
717
727
|
const apps = [...new Set(found.map(labelOf).filter(Boolean))], fresh = apps.filter((app) => !agreed.has(`door:${app}`));
|
|
728
|
+
if (same) {
|
|
729
|
+
const standing = doorIsOff || planLines(plan.out).filter((line) => !line.includes("not on this machine")).every((line) => /^\s+✓ /.test(line));
|
|
730
|
+
const asked = (existsSync(join(homedir(), ".codex")) && !codexNotify().text) || (antigravityHere() && agyHooks() !== null && !agyHooks()?.worktrust);
|
|
731
|
+
if (plan.code === 0 && standing && fresh.length === 0 && agreed.has("session-hook") && !asked) {
|
|
732
|
+
say();
|
|
733
|
+
say(` Already up to date (${CLI_VERSION}). Nothing changed.`);
|
|
734
|
+
if (doorIsOff) say(` the door stays off here (hours only, ${DOOR_SWITCH})`); // a choice the update keeps is still said
|
|
735
|
+
say(" To set this computer up again all the same: npx worktrust update --force");
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
title();
|
|
739
|
+
}
|
|
740
|
+
say(" Every AI app found here gets the WorkTrust door, the local command that reads the key:");
|
|
741
|
+
if (doorIsOff) say(` the door stays off here (hours only, ${DOOR_SWITCH})`);
|
|
718
742
|
for (const app of apps) if (!fresh.includes(app)) say(` ✓ ${app}: refreshed (${agreed.said(`door:${app}`)})`);
|
|
719
743
|
for (const line of found) if (fresh.includes(labelOf(line))) say(`${line} · new`);
|
|
720
744
|
if (found.length === 0 && !doorIsOff) say(" (no AI app found here)");
|
|
@@ -730,7 +754,6 @@ async function update() {
|
|
|
730
754
|
else if (newOnes.length > 0) takeNew = await ask(`Couple the new ${newOnes.length === 1 ? "one" : "ones"} marked "new" (${newOnes.join(", ")})?`, false);
|
|
731
755
|
if (newOnes.length > 0 && !takeNew && !has("yes")) say(" The new ones stay as they are. npx worktrust update asks again.");
|
|
732
756
|
const skip = takeNew ? [] : fresh, hookOn = !hookFresh || takeNew;
|
|
733
|
-
const previous = stableInstall();
|
|
734
757
|
await prepareBundledRuntime();
|
|
735
758
|
ensureHome();
|
|
736
759
|
saveStableEntry();
|
|
@@ -1384,7 +1407,7 @@ async function status() {
|
|
|
1384
1407
|
if (measurePaused()) say(` Measuring: paused by you in Sources since ${String(measureState()?.since ?? "").slice(0, 10)}; nothing is measured or sent until you turn it on there`);
|
|
1385
1408
|
// THE LAST UPDATE ON TURN-ON (0.10.37): what happened, in words; the details are in ~/.worktrust/update.log, on this computer only.
|
|
1386
1409
|
{ const state = updateState(); if (state) { const code = (await selfUpdateModule()).updateResult(state);
|
|
1387
|
-
const words = { installed: `updated itself to ${state.version}`, current: `already on ${state.version} or newer`, python: "installed with Python: update it with the package manager you installed WorkTrust with", unsupported: "this installation cannot update itself: run npx worktrust@latest update", unverified: `${state.version} could not be verified, so nothing was installed`, failed: `the update to ${state.version} did not finish; the CLI stays as it was` };
|
|
1410
|
+
const words = { installed: `updated itself to ${state.version}`, current: `already on ${state.version} or newer`, python: "installed with Python: update it with the package manager you installed WorkTrust with", unsupported: "this installation cannot update itself: run npx -y worktrust@latest update", unverified: `${state.version} could not be verified, so nothing was installed`, failed: `the update to ${state.version} did not finish; the CLI stays as it was` };
|
|
1388
1411
|
say(` Update when turned on: ${words[code] ?? `to ${state.version}, under way`}${["unverified", "failed"].includes(code) ? " (~/.worktrust/update.log)" : ""}`); } }
|
|
1389
1412
|
// A TRANSCRIPT THE HOOK COULD NOT READ (0.10.32): the count of its last run that had any, never which file; WorkTrust has the count too.
|
|
1390
1413
|
{ let unread = null; try { unread = JSON.parse(readFileSync(join(HOME_DIR, "sessions.json"), "utf8")).__unreadable ?? null; } catch { /* no state yet */ }
|
|
@@ -1660,6 +1683,8 @@ function help() {
|
|
|
1660
1683
|
say(" --replace yes in advance to coupling a computer that is already coupled");
|
|
1661
1684
|
say(" worktrust update this computer onto the newest CLI: same key, no new pairing; what you agreed to before is");
|
|
1662
1685
|
say(" refreshed without a question, a new AI app or hook is asked about (--yes: skipped)");
|
|
1686
|
+
say(" already on this version with nothing waiting: says so and changes nothing");
|
|
1687
|
+
say(" --force set everything up again all the same (the repair road)");
|
|
1663
1688
|
say(" --rebuild yes in advance to the re-measure update offers after a new version (the plan is still shown)");
|
|
1664
1689
|
say(" --codex yes in advance to letting Codex wake the session hook (also for connect)");
|
|
1665
1690
|
say(" --antigravity yes in advance to letting Antigravity wake the session hook (also for connect)");
|
|
@@ -1761,17 +1786,21 @@ async function relayToNewest() {
|
|
|
1761
1786
|
if (command === "default" && BUNDLED && (await import("./cli-menu.mjs")).menuWanted({ args, env: process.env, stdinTTY: Boolean(process.stdin.isTTY), stdoutTTY: Boolean(process.stdout.isTTY), agentShell })) {
|
|
1762
1787
|
try { keyStore.load(); }
|
|
1763
1788
|
catch { fail("The local WorkTrust key file is unsafe or damaged, or the OS vault is locked or unavailable. Unlock your OS vault and retry. Do not delete the key file or reset the keychain."); }
|
|
1764
|
-
let latest;
|
|
1789
|
+
let latest, latestKnown = false; // 0.11.9: whether the registry answered at all (no answer is not "up to date")
|
|
1765
1790
|
const runCli = (cliArgs) => new Promise((resolve) => {
|
|
1766
1791
|
const child = spawn(moduleExecutable(HERE), [...moduleArgs(HERE, "worktrust.mjs", cliArgs)], { stdio: "inherit", env: { ...process.env, WORKTRUST_MENU: "off", WORKTRUST_RELAYED: "1", ...(has("no-color") || has("no-colour") ? { NO_COLOR: "1" } : {}) } });
|
|
1767
1792
|
child.on("error", () => resolve(1));
|
|
1768
|
-
child.on("exit", (code) => resolve(code ?? 1));
|
|
1793
|
+
child.on("exit", (code, signal) => resolve(code ?? (signal ? 130 : 1))); // stopped by Ctrl+C: 130, which the first menu reads as cancelled
|
|
1769
1794
|
});
|
|
1770
1795
|
const state = async () => {
|
|
1771
|
-
if (latest === undefined) { const v = await newestVersion(); latest = v && semverNewer(v, CLI_VERSION) ? v : null; }
|
|
1796
|
+
if (latest === undefined) { const v = await newestVersion(); latestKnown = v !== null; latest = v && semverNewer(v, CLI_VERSION) ? v : null; }
|
|
1772
1797
|
let key = null; try { key = keyStore.load(); } catch { key = null; }
|
|
1773
1798
|
// `installed` is read again at every ask (0.11.8): the menu's Update item says "up to date" the moment an update ends.
|
|
1774
|
-
|
|
1799
|
+
// THE SUMMARY'S FACTS (0.11.9): what this computer's own files say, never the key: its name, the day it was coupled, whether
|
|
1800
|
+
// the session hook stands in Claude Code's settings, and how many AI apps' doors the person agreed to (the consent record).
|
|
1801
|
+
let apps = null; try { apps = Object.keys(JSON.parse(readPrivateFile(CONSENT_FILE) ?? "null")?.entries ?? {}).filter((name) => name.startsWith("door:")).length; } catch { apps = null; }
|
|
1802
|
+
return { version: CLI_VERSION, installed: stableVersion(), latest, latestKnown, connected: Boolean(key), account: key?.account ?? null, door: doorOff() ? "off" : "on",
|
|
1803
|
+
host: hostname().replace(/\.local$/i, ""), since: key?.coupledAt ?? null, hook: sessionHookHere(), apps };
|
|
1775
1804
|
};
|
|
1776
1805
|
return (await import("./cli-menu.mjs")).runMenu({ runCli, state });
|
|
1777
1806
|
}
|