worktrust 0.11.5 → 0.11.7

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.
@@ -0,0 +1,191 @@
1
+ /**
2
+ * WHAT A PHONE MAY DO ON THIS COMPUTER, CHANGED IN ONE PLACE (CLI 0.11.7, owner 2026-11-12). Every change to the remote
3
+ * settings that widens or narrows a phone's reach (the ceiling of agent modes, the roots, the granted projects, the admin
4
+ * switch) goes through applySettingsChange(change, source). Today the only source is THIS KEYBOARD (`{ kind: "keyboard" }`,
5
+ * a `remote …` command or the menu, both refused in an AI agent's shell by worktrust.mjs). Part B adds a second source, a
6
+ * change the person approved in the WorkTrust app or on the web and the server signed (`{ kind: "admin", proof }`); it will
7
+ * be honoured only while `remote admin on` (the default) and only once its proof verifies here. Until part B ships, an
8
+ * admin change is refused: nothing but this keyboard changes these settings (docs/remote-agents/PROTOCOL.md "Agent modes").
9
+ *
10
+ * PART B (owner, 2026-11-12): the second source is here. A change from the app or the web arrives as `{ kind: "admin",
11
+ * proof, issuerKeys, claims, now }` (remote-daemon.mjs, from a sealed device.configure): remote-admin.mjs adminRefusal
12
+ * checks `remote admin on` and the issuer-signed proof (this computer, this account, this change, five minutes, one use),
13
+ * resolveAdminChange names its folder, root or connection from this computer's own lists by id, and the result goes
14
+ * through the same rules below as a typed command. The admin switch itself never changes from the app.
15
+ *
16
+ * THE CEILING OF AGENT MODES (protocol adapters.ts AGENT_MODES). Manual and plan are always allowed (today's behaviour);
17
+ * `allow edit` lets a phone start a session that edits files inside its projects without asking; `allow auto` lets it start
18
+ * the agent's own automatic mode, and, being above edit, allows edit too. `deny edit` takes both away again. The ceiling is
19
+ * read by the daemon on every start (checkAgentOptions), never taken from a phone.
20
+ */
21
+ import { readdirSync } from "node:fs";
22
+ import { adminRefusal, resolveAdminChange } from "./remote-admin.mjs";
23
+ import { removePhones } from "./remote-connections.mjs";
24
+ import { protectedFolder } from "./folder-picker.mjs";
25
+ import { canonicalProject } from "./remote-policy.mjs";
26
+ import { probeFolders } from "./remote-service.mjs";
27
+ import { checkRoot, MAX_ROOTS, rootIdOf } from "./remote-projects.mjs";
28
+ import { agentOptionsOf } from "./remote-inventory.mjs";
29
+ import * as P from "./remote-protocol.mjs";
30
+ import { ensureRemoteDir, loadKeys, loadProjects, loadRoots, loadSettings, projectIdOf, saveProjects, saveRoots, saveSettings, writeJson } from "./remote-store.mjs";
31
+
32
+ export const RAISABLE_MODES = Object.freeze(["edit", "auto"]);
33
+ const ORDER = ["manual", "edit", "plan", "auto"];
34
+
35
+ /** The modes this computer allows: manual and plan always, edit and auto when the person allowed them (auto brings edit). */
36
+ export function allowedModes(settings = loadSettings()) {
37
+ const set = new Set(["manual", "plan"]);
38
+ const asked = Array.isArray(settings.modes_allowed) ? settings.modes_allowed : [];
39
+ if (asked.includes("auto")) { set.add("auto"); set.add("edit"); }
40
+ if (asked.includes("edit")) set.add("edit");
41
+ return ORDER.filter((m) => set.has(m));
42
+ }
43
+
44
+ const refused = (reason) => ({ ok: false, reason });
45
+
46
+ /**
47
+ * A START'S 0.11.7 OPTIONS, decided here (remote-sessions.mjs calls it before anything is set up): the adapter's options as
48
+ * this computer reads them from its own agent, the ceiling from the settings file, and the extra projects from the
49
+ * computer's own list by id. → a reject reason, or { agentMode, effort, extraProjectIds, extras: [{ project_id, path }] }.
50
+ */
51
+ export function startChoice(payload, projectId, inventory, settings, known) {
52
+ const options = agentOptionsOf(inventory).find((o) => o.adapter === payload.adapter && o.mode === (payload.mode ?? "structured")) ?? null;
53
+ const choice = P.checkAgentOptions(payload, projectId, options, allowedModes(settings), new Set(known.map((p) => p.project_id)));
54
+ if (typeof choice === "string") return choice;
55
+ return { ...choice, extras: choice.extraProjectIds.map((id) => known.find((p) => p.project_id === id)) };
56
+ }
57
+
58
+ /**
59
+ * The one door for a settings change. `change`: { what: "modes", allow|deny: "edit"|"auto" } | { what: "roots", add: dir,
60
+ * git_init } | { what: "roots", remove: id|dir } | { what: "projects", add: dir } | { what: "projects", remove: id|dir } |
61
+ * { what: "admin", on: boolean } | { what: "connections", remove: fingerprint } (resolved from the app's change only).
62
+ * `source`: { kind: "keyboard" }, or { kind: "admin", proof, issuerKeys, claims, now, via } (part B; its change is
63
+ * crypto/admin.ts's ADMIN_CHANGE_SPEC, resolved by id before it reaches the rules below).
64
+ * → { ok: true, message, paths?, setting? } or { ok: false, reason, code? } (code: the protocol's reject reason).
65
+ */
66
+ export function applySettingsChange(change, source) {
67
+ if (source?.kind === "admin") {
68
+ // From the app or the web: `remote admin on`, then the issuer-signed proof, then this computer's own lists by id.
69
+ const gate = adminRefusal(change, source, loadSettings());
70
+ if (gate) return { ok: false, reason: gate.reason, code: gate.code };
71
+ const resolved = resolveAdminChange(change);
72
+ if (!resolved.ok) return { ok: false, reason: resolved.reason, code: resolved.code };
73
+ const done = applyRules(resolved.change, true);
74
+ return done.ok ? { ...done, setting: resolved.setting } : { ...done, code: done.code ?? "unsupported" };
75
+ }
76
+ if (source?.kind !== "keyboard") return refused("this computer's remote settings are changed at its keyboard");
77
+ return applyRules(change, false);
78
+ }
79
+
80
+ /** The rules every change meets, typed here or resolved from the app (`fromApp`): the same checks, the same files. */
81
+ function applyRules(change, fromApp) {
82
+ const settings = loadSettings();
83
+ if (change?.what === "modes") {
84
+ const mode = change.allow ?? change.deny;
85
+ if (!RAISABLE_MODES.includes(mode)) return refused("name edit or auto (manual and plan are always allowed)");
86
+ const now = new Set(allowedModes(settings));
87
+ if (change.allow) { now.add(mode); if (mode === "auto") now.add("edit"); }
88
+ else { now.delete(mode); if (mode === "edit") now.delete("auto"); }
89
+ saveSettings({ ...settings, modes_allowed: ORDER.filter((m) => now.has(m)) });
90
+ return { ok: true, message: `Allowed modes: ${allowedModes(loadSettings()).join(", ")}` };
91
+ }
92
+ if (change?.what === "connections" && fromApp) {
93
+ // From the app only (the keyboard's own `remote disconnect` asks twice and calls removePhones itself).
94
+ const n = removePhones([String(change.remove ?? "")]);
95
+ return n > 0 ? { ok: true, message: "Disconnected: it can no longer steer this computer." } : { ...refused("no phone or browser by that fingerprint"), code: "not_found" };
96
+ }
97
+ if (change?.what === "admin") {
98
+ if (fromApp) return refused("the admin switch changes at this keyboard only");
99
+ if (typeof change.on !== "boolean") return refused("on or off");
100
+ saveSettings({ ...settings, admin: change.on });
101
+ return { ok: true, message: change.on ? "Managing this computer from the app or the web: on. Each change there asks your authenticator, and this computer checks WorkTrust's signature on it." : "Managing this computer from the app or the web: off. Only this keyboard changes its remote settings." };
102
+ }
103
+ const keys = loadKeys();
104
+ if (change?.what === "roots") {
105
+ const list = loadRoots();
106
+ if (change.add !== undefined) {
107
+ if (!keys) return refused("this computer is not paired for remote yet: run `npx worktrust remote app`");
108
+ const root = checkRoot(change.add ?? "");
109
+ if (!root.ok) return refused(`not added: ${root.reason}`);
110
+ if (list.length >= MAX_ROOTS && !list.some((r) => r.path === root.path)) return refused(`at most ${MAX_ROOTS} roots`);
111
+ const root_id = rootIdOf(keys.projectSecret, root.path);
112
+ saveRoots([...list.filter((r) => r.root_id !== root_id), { root_id, path: root.path, git_init: change.git_init === true, added_at: Date.now() }]);
113
+ return { ok: true, paths: [root.path], message: `Root: ${root.path}. A phone may open the projects already in it and create one new, empty folder in it per request${change.git_init === true ? ", with git init" : ""}.` };
114
+ }
115
+ const key = String(change.remove ?? "");
116
+ const kept = list.filter((r) => r.root_id !== key && r.path !== key && r.path !== checkRoot(key).path);
117
+ if (kept.length === list.length) return refused("no root by that path or id");
118
+ saveRoots(kept);
119
+ return { ok: true, message: "Removed. Projects made in it stay granted: npx worktrust remote projects remove <folder>." };
120
+ }
121
+ if (change?.what === "projects") {
122
+ const list = loadProjects();
123
+ if (change.add !== undefined) {
124
+ if (!keys) return refused("this computer is not paired for remote yet: run `npx worktrust remote app`");
125
+ const canonical = canonicalProject(change.add ?? "");
126
+ if (!canonical.ok) return refused(`not granted: ${canonical.reason}`);
127
+ const project_id = projectIdOf(keys.projectSecret, canonical.path);
128
+ if (!list.some((p) => p.project_id === project_id)) saveProjects([...list, { project_id, path: canonical.path, added_at: Date.now() }]);
129
+ return { ok: true, paths: [canonical.path], message: `Granted: ${canonical.path}` };
130
+ }
131
+ const key = String(change.remove ?? "");
132
+ const canonical = canonicalProject(key);
133
+ const kept = list.filter((p) => p.project_id !== key && p.path !== key && !(canonical.ok && p.path === canonical.path));
134
+ if (kept.length === list.length) return refused("no granted folder by that path or id");
135
+ saveProjects(kept);
136
+ return { ok: true, message: "Removed." };
137
+ }
138
+ return refused("not a setting this computer knows");
139
+ }
140
+
141
+ /** `remote modes allow|deny edit|auto | status`. */
142
+ export function modesCommand(io, rest) {
143
+ if (rest[0] === "allow" || rest[0] === "deny") {
144
+ const done = applySettingsChange({ what: "modes", [rest[0]]: rest[1] }, { kind: "keyboard" });
145
+ if (!done.ok) io.fail(`npx worktrust remote modes allow|deny edit|auto: ${done.reason}`);
146
+ io.say(` ✓ ${done.message}`);
147
+ if (rest[0] === "allow") io.say(" A phone may now start sessions in it; the deny rules (no push, no install, no deploy, no secret) hold in every mode.");
148
+ return;
149
+ }
150
+ if (rest[0] !== undefined && rest[0] !== "status") io.fail("npx worktrust remote modes allow|deny edit|auto | status");
151
+ const allowed = allowedModes();
152
+ const WORDS = { manual: "Manual (asks for every change)", edit: "Edit automatically (edits inside the project without asking)", plan: "Plan (read-only)", auto: "Auto (the agent's own automatic mode)" };
153
+ io.say(" Agent modes a phone may start on this computer:");
154
+ for (const m of ORDER) io.say(` ${allowed.includes(m) ? "✓" : "·"} ${WORDS[m]}${allowed.includes(m) || m === "manual" || m === "plan" ? "" : ` allow: npx worktrust remote modes allow ${m}`}`);
155
+ }
156
+
157
+ /** `remote admin on|off | status`: whether a change approved in the app or on the web (with the authenticator) is honoured here. */
158
+ export function adminCommand(io, rest) {
159
+ if (rest[0] === "on" || rest[0] === "off") {
160
+ const done = applySettingsChange({ what: "admin", on: rest[0] === "on" }, { kind: "keyboard" });
161
+ io.say(` ✓ ${done.message}`);
162
+ return;
163
+ }
164
+ io.say(` Managing this computer from the app or the web: ${loadSettings().admin === false ? "off" : "on"} (npx worktrust remote admin on|off; each change there asks your authenticator)`);
165
+ }
166
+
167
+ /**
168
+ * `remote folder-check` (internal; run by probeFolders as the service's own program): can each root and project in a folder
169
+ * macOS guards be listed? Writes { at, folders: [{ path, folder, ok }] } to folder-check.json and nothing else.
170
+ */
171
+ export function folderCheck() {
172
+ const folders = [...loadRoots(), ...loadProjects()].map((x) => x.path).filter((path, i, all) => all.indexOf(path) === i && protectedFolder(path))
173
+ .map((path) => { try { readdirSync(path); return { path, folder: protectedFolder(path), ok: true }; } catch { return { path, folder: protectedFolder(path), ok: false }; } });
174
+ ensureRemoteDir();
175
+ writeJson("folder-check.json", { at: Date.now(), folders });
176
+ }
177
+
178
+ /** After a folder was added at the keyboard: when macOS guards it, ask at once, from the program that will run the agents. */
179
+ export async function askMacFolderAccess(io, paths) {
180
+ const guarded = [...new Set((paths ?? []).map((p) => protectedFolder(p)).filter(Boolean))];
181
+ if (guarded.length === 0) return null;
182
+ io.say(` macOS guards your ${guarded.join(" and ")} folder. It now asks once whether the program that runs your agents (shown as "node" or "python") may read it.`);
183
+ io.say(" Click OK (Allow). Without it, a session there stops at a prompt nobody sees, or fails with \"Operation not permitted\".");
184
+ const runtime = await io.prepare();
185
+ const result = await probeFolders({ program: [runtime.node, ...runtime.nodeArgs, runtime.entry, "remote", "folder-check"], path: loadSettings().agent_path ?? process.env.PATH ?? "" });
186
+ const refusedHere = (result?.folders ?? []).filter((f) => !f.ok);
187
+ if (result && refusedHere.length === 0) { io.say(" ✓ macOS lets the Remote Agent service read it."); return true; }
188
+ io.say(` ! ${result ? `macOS refused: ${refusedHere.map((f) => f.path).join(", ")}` : "No answer from macOS in time"}. To allow it later: System Settings › Privacy & Security › Files and Folders,`);
189
+ io.say(` then turn on ${guarded.join(" and ")} for "node" (or "python"); or add that program under Full Disk Access.`);
190
+ return false;
191
+ }
package/remote-store.mjs CHANGED
@@ -69,7 +69,10 @@ export const saveIdentity = (identity) => writeJson("identity.json", identity);
69
69
 
70
70
  // allow_endorse (2026-11-09): may a confirmed phone add a browser it scanned (remote-endorse.mjs)? Off until the person says so
71
71
  // here, at the keyboard (`worktrust remote phones allow-endorse on`).
72
- export const DEFAULT_SETTINGS = Object.freeze({ v: 1, enabled: false, paused: null, gateway: null, default_adapter: "claude-code", default_model: null, agent_path: null, codex: false, opencode: false, terminal: false, allow_endorse: false });
72
+ // modes_allowed (0.11.7, owner 2026-11-12): the CEILING of agent modes a phone may start, set here only (`worktrust remote
73
+ // modes allow|deny edit|auto`); manual and plan always. admin (0.11.7): RESERVED for managing this computer from the app or
74
+ // the web with a server-signed proof (part B); on by default, honoured by nothing yet (remote-settings.mjs).
75
+ export const DEFAULT_SETTINGS = Object.freeze({ v: 1, enabled: false, paused: null, gateway: null, default_adapter: "claude-code", default_model: null, agent_path: null, codex: false, opencode: false, terminal: false, allow_endorse: false, modes_allowed: Object.freeze(["manual", "plan"]), admin: true });
73
76
  export const loadSettings = () => ({ ...DEFAULT_SETTINGS, ...(readJson("settings.json") ?? {}) });
74
77
  export const saveSettings = (settings) => writeJson("settings.json", { ...DEFAULT_SETTINGS, ...settings });
75
78
 
package/worktrust.mjs CHANGED
@@ -1,7 +1,9 @@
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 show the plan, ask, approve this computer in the app, couple (0.10.7: a person's
4
+ * npx worktrust in a person's own terminal (0.11.7): the menu (cli-menu.mjs), whose first item is
5
+ * what the bare command did until then; without a terminal, exactly that:
6
+ * show the plan, ask, approve this computer in the app, couple (0.10.7: a person's
5
7
  * command always runs the newest version, whatever npx had cached);
6
8
  * on a computer already coupled: what is coupled here
7
9
  * npx worktrust --dry-run show the plan only; nothing is written, nothing is sent
@@ -26,7 +28,7 @@
26
28
  * command on a coupled computer offers an export lying in ~/Downloads once.
27
29
  * npx worktrust disconnect show what comes out, ask, take it out again
28
30
  * npx worktrust status what is coupled here
29
- * npx worktrust remote enable|pair|status|pause|resume|disable|phones|projects|run steer this computer's agents
31
+ * npx worktrust remote app|web|pair|status|pause|resume|disable|phones|projects|roots|modes|run steer this computer's agents
30
32
  * from your phone (remote-cli.mjs; opt-in, its own key, never the measurement key)
31
33
  * npx worktrust@latest preserve how long each AI app here keeps its sessions (--apply keeps them,
32
34
  * --archive [dir] a local metadata-only record, --verify [dir] checks it,
@@ -78,7 +80,7 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
78
80
  const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
79
81
  const has = (name) => args.includes(`--${name}`);
80
82
  /** 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). */
81
- const CLI_VERSION = "0.11.5";
83
+ const CLI_VERSION = "0.11.7";
82
84
  /**
83
85
  * 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
84
86
  * to offer). Raised ONLY when what is measured changes: the timeline, the seconds, the tokens, the steering, the session
@@ -114,7 +116,7 @@ const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.w
114
116
  const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
115
117
  const HOME_DIR = join(homedir(), ".worktrust");
116
118
  const HERE = dirname(fileURLToPath(import.meta.url));
117
- const SCRIPTS = ["credential-store.mjs", "remote-protocol.mjs", "remote-store.mjs", "remote-policy.mjs", "remote-journal.mjs", "remote-steered.mjs", "remote-inventory.mjs", "remote-claude-events.mjs", "remote-claude-progress.mjs", "remote-attachments.mjs", "remote-preview.mjs", "remote-coalesce.mjs", "remote-steering.mjs", "remote-codex-events.mjs", "remote-adapter-codex.mjs", "remote-opencode-events.mjs", "remote-adapter-opencode.mjs", "remote-opencode-session.mjs", "remote-adapter-terminal.mjs", "remote-terminal-sessions.mjs", "remote-terminal-cli.mjs", "remote-screen-states.mjs", "remote-screen-approvals.mjs", "remote-screen-push.mjs", "remote-cdp.mjs", "remote-live-preview.mjs", "remote-projects.mjs", "remote-pipeline-config.mjs", "remote-pipeline-parsers.mjs", "remote-pipeline.mjs", "remote-releases.mjs", "remote-release-plans.mjs", "remote-adapter-claude-code.mjs", "remote-approval-bridge.mjs", "remote-approvals.mjs", "remote-sessions.mjs", "remote-session-list.mjs", "remote-changes.mjs", "remote-endorse.mjs", "remote-daemon.mjs", "remote-transport.mjs", "remote-run.mjs", "remote-service.mjs", "remote-pairing.mjs", "remote-qr.mjs", "remote-cli.mjs", "remote-agent-switch.mjs", "credential-vault.mjs", "credential-vault-scripts.mjs", "history-outbox.mjs", "setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "session-local-models.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "export-facts.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "claude-mod.mjs", "package-integrity.mjs", "worktrust-launch.mjs", "project-modes.mjs", "commit-rules.mjs", "git-commits.mjs", "self-update.mjs", "history-progress.mjs"];
119
+ const SCRIPTS = ["credential-store.mjs", "remote-protocol.mjs", "remote-store.mjs", "remote-policy.mjs", "remote-journal.mjs", "remote-steered.mjs", "remote-inventory.mjs", "remote-claude-events.mjs", "remote-claude-progress.mjs", "remote-attachments.mjs", "remote-preview.mjs", "remote-coalesce.mjs", "remote-steering.mjs", "remote-codex-events.mjs", "remote-adapter-codex.mjs", "remote-opencode-events.mjs", "remote-adapter-opencode.mjs", "remote-opencode-session.mjs", "remote-adapter-terminal.mjs", "remote-terminal-sessions.mjs", "remote-terminal-cli.mjs", "remote-screen-states.mjs", "remote-screen-approvals.mjs", "remote-screen-push.mjs", "remote-cdp.mjs", "remote-live-preview.mjs", "remote-projects.mjs", "remote-pipeline-config.mjs", "remote-pipeline-parsers.mjs", "remote-pipeline.mjs", "remote-releases.mjs", "remote-release-plans.mjs", "remote-adapter-claude-code.mjs", "remote-approval-bridge.mjs", "remote-approvals.mjs", "remote-sessions.mjs", "remote-session-list.mjs", "remote-changes.mjs", "remote-endorse.mjs", "remote-daemon.mjs", "remote-transport.mjs", "remote-run.mjs", "remote-service.mjs", "remote-pairing.mjs", "remote-qr.mjs", "remote-cli.mjs", "remote-agent-switch.mjs", "remote-settings.mjs", "folder-picker.mjs", "cli-menu.mjs", "cli-menu-remote.mjs", "remote-countdown.mjs", "remote-connections.mjs", "remote-admin.mjs", "credential-vault.mjs", "credential-vault-scripts.mjs", "history-outbox.mjs", "setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "session-local-models.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "export-facts.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "claude-mod.mjs", "package-integrity.mjs", "worktrust-launch.mjs", "project-modes.mjs", "commit-rules.mjs", "git-commits.mjs", "self-update.mjs", "history-progress.mjs"];
118
120
  /** The modules the scripts import by name from beside them; a download keeps that name. */
119
121
  const IMPORTED = new Set(["project-modes.mjs", "transcript-readers.mjs", "session-databases.mjs", "session-local-models.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "export-facts.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "commit-rules.mjs", "git-commits.mjs"]);
120
122
  const downloaded = (name) => (IMPORTED.has(name) ? name : `${name}.download.mjs`);
@@ -1638,8 +1640,9 @@ async function doorCommand(sub) {
1638
1640
  function help() {
1639
1641
  say("WorkTrust: couple this computer to your record. Metadata only.");
1640
1642
  say();
1641
- say(" worktrust couple this computer: show the plan, ask, approve in your browser");
1642
- say(" (already coupled: shows what is coupled here)");
1643
+ say(" worktrust in your terminal: the menu (every command below, with the short form it runs)");
1644
+ say(" without a terminal, or with any option: couple this computer: show the plan, ask,");
1645
+ say(" approve in your browser (already coupled: shows what is coupled here)");
1643
1646
  say(" --dry-run the plan only: nothing is written, nothing is sent");
1644
1647
  say(" --yes no question (the computer is still approved in the browser)");
1645
1648
  say(" --device no browser here (SSH): type a code on another device");
@@ -1672,8 +1675,12 @@ function help() {
1672
1675
  say(" worktrust status what is coupled here");
1673
1676
  say(" worktrust project a folder's mode: exclude (nothing read), confidential (hours and tokens count, no name,");
1674
1677
  say(" branch, path or commit sent) or normal; `project list` shows them (default folder: here)");
1675
- say(" worktrust remote steer this computer's agents from your phone: enable, pair (a QR), status, pause, resume,");
1676
- say(" disable, phones, projects, run. Opt-in, its own key, never counted as your AI Hours");
1678
+ say(" worktrust remote steer this computer's agents from your phone (opt-in, its own key, never your AI Hours):");
1679
+ say(" app | web approve this computer: with the WorkTrust app (a QR here) | in the browser");
1680
+ say(" pair link a phone (a QR) status · pause · resume · disable · phones");
1681
+ say(" connections every phone and browser linked here; disconnect <n|name|fingerprint> | --all closes them");
1682
+ say(" projects · roots the folders a phone may steer an agent in; roots open the git projects inside them");
1683
+ say(" modes allow|deny edit|auto the agent modes a phone may start (default: manual and plan)");
1677
1684
  say(" worktrust mcp off hours only: the WorkTrust door out of every AI app here, nothing of it in your sessions;");
1678
1685
  say(" the session hook keeps measuring your hours, and update leaves the door out");
1679
1686
  say(" worktrust mcp on the door back in, so your AI can log finished work (about 40 tokens per session)");
@@ -1740,6 +1747,25 @@ async function relayToNewest() {
1740
1747
  say(` WorkTrust ${latest} is available. Automatic execution is paused until signed release verification is configured.`);
1741
1748
  say(" Update explicitly using the package manager you installed with. This invocation keeps its current version.");
1742
1749
  }
1750
+ // THE MENU (0.11.7, owner 2026-11-12): bare `npx worktrust` in a person's own terminal, nowhere else (cli-menu.mjs menuWanted:
1751
+ // both ends a terminal, no argument, not relayed, not a hook or the MCP door, not an agent's shell, WORKTRUST_MENU not off).
1752
+ // Each item runs one direct command as a child of this CLI, the terminal handed over and the menu kept out of it.
1753
+ 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 })) {
1754
+ try { keyStore.load(); }
1755
+ 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."); }
1756
+ let latest;
1757
+ const runCli = (cliArgs) => new Promise((resolve) => {
1758
+ const child = spawn(moduleExecutable(HERE), [...moduleArgs(HERE, "worktrust.mjs", cliArgs)], { stdio: "inherit", env: { ...process.env, WORKTRUST_MENU: "off", WORKTRUST_RELAYED: "1" } });
1759
+ child.on("error", () => resolve(1));
1760
+ child.on("exit", (code) => resolve(code ?? 1));
1761
+ });
1762
+ const state = async () => {
1763
+ if (latest === undefined) { const v = await newestVersion(); latest = v && semverNewer(v, CLI_VERSION) ? v : null; }
1764
+ let key = null; try { key = keyStore.load(); } catch { key = null; }
1765
+ return { version: CLI_VERSION, latest, connected: Boolean(key), account: key?.account ?? null, door: doorOff() ? "off" : "on" };
1766
+ };
1767
+ return (await import("./cli-menu.mjs")).runMenu({ runCli, state });
1768
+ }
1743
1769
  if (await relayToNewest()) return;
1744
1770
 
1745
1771
  if (!["version", "help", "preserve", "project"].includes(command)) {
@@ -1776,7 +1802,9 @@ else if (command === "orchestration") {
1776
1802
  if (!["orchestration-report.mjs", "orchestration-evidence.mjs", "orchestration-contract.mjs"].every((name) => existsSync(join(HERE, name)))) fail("Local agent reports need the complete WorkTrust npm/Python package or preservation kit. No file was read or sent.");
1777
1803
  const { reportFile } = await import("./orchestration-report.mjs"); reportFile(args.slice(1));
1778
1804
  }
1779
- else help();
1805
+ // A word the CLI does not know (the owner typed `update,` on 2026-11-11 and got the help with no reason): say so, then the
1806
+ // help, and end with a failure code so a script notices.
1807
+ else { if (command !== "help") { say(` Unknown command: ${command}. The commands are below.`); process.exitCode = 1; } help(); }
1780
1808
 
1781
1809
  }
1782
1810
  try { await main(); } catch (error) { if (!(error instanceof CliFailure)) throw error; process.exitCode = 1; }