worktrust 0.10.9 → 0.10.11

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,153 @@
1
+ // GENERATED by scripts/build-stack-rules.mjs from packages/core/src/scoring/stack.ts and packages/core/src/stack-display.ts (the sources of truth). Do not edit:
2
+ // `node scripts/build-stack-rules.mjs` rewrites it and `--check` refuses a copy that drifted from core, in either direction.
3
+ /**
4
+ * WHICH TECHNOLOGY A STRETCH TOUCHED, read off file PATHS and sent as keys from core's closed list (owner, 2026-10-10:
5
+ * recognition stays FILES ONLY: a file names it, never a dependency list, never code content). The hook reads the same
6
+ * paths it already reads for the layers; the paths never travel, only the keys.
7
+ */
8
+ export const TECHNOLOGIES = [
9
+ "typescript", "javascript", "python", "go", "rust", "java", "kotlin", "swift", "csharp", "ruby", "php", "cpp", "sql", "shell",
10
+ "react", "nextjs", "vue", "svelte", "angular", "reactNative", "expo", "tailwind", "nodejs", "django", "fastapi", "rails", "dotnet", "spring", "flutter",
11
+ "postgres", "supabase", "prisma", "graphql", "docker", "kubernetes", "terraform", "githubActions", "vercel", "aws", "gcp", "azure",
12
+
13
+
14
+
15
+ "redis", "sqlite", "vitest", "jest", "playwright", "storybook", "cloudflare", "deno", "bun", "drizzle", "vite", "webpack", "electron", "firebase", "sentry", "mcp", "claude",
16
+
17
+
18
+
19
+
20
+
21
+ "retrieval", "pgvector", "pinecone", "weaviate", "qdrant", "chroma", "langchain", "llamaindex",
22
+ ];
23
+ const BY_EXTENSION = [
24
+ [/\.(ts|mts|cts)$/i, ["typescript"]],
25
+ [/\.tsx$/i, ["typescript", "react"]],
26
+ [/\.jsx$/i, ["javascript", "react"]],
27
+ [/\.(js|mjs|cjs)$/i, ["javascript"]],
28
+ [/\.py$/i, ["python"]],
29
+ [/\.go$/i, ["go"]],
30
+ [/\.rs$/i, ["rust"]],
31
+ [/\.java$/i, ["java"]],
32
+ [/\.kt$/i, ["kotlin"]],
33
+ [/\.swift$/i, ["swift"]],
34
+ [/\.cs$/i, ["csharp"]],
35
+ [/\.rb$/i, ["ruby"]],
36
+ [/\.php$/i, ["php"]],
37
+ [/\.(c|cc|cpp|h|hpp)$/i, ["cpp"]],
38
+ [/\.sql$/i, ["sql"]],
39
+ [/\.(sqlite|sqlite3)$/i, ["sqlite"]],
40
+ [/\.(sh|bash|zsh)$/i, ["shell"]],
41
+ [/\.vue$/i, ["vue"]],
42
+ [/\.svelte$/i, ["svelte"]],
43
+ [/\.dart$/i, ["flutter"]],
44
+ [/\.prisma$/i, ["prisma"]],
45
+ [/\.(graphql|gql)$/i, ["graphql"]],
46
+ [/\.tf$/i, ["terraform"]],
47
+ ];
48
+ const BY_NAME = [
49
+ [/(^|\/)next\.config\.(js|mjs|ts)$/i, ["nextjs"]],
50
+ [/(^|\/)tailwind\.config\.(js|mjs|ts)$|(^|\/)postcss\.config\./i, ["tailwind"]],
51
+ [/(^|\/)package(-lock)?\.json$|(^|\/)pnpm-lock\.yaml$|(^|\/)yarn\.lock$/i, ["nodejs"]],
52
+ [/(^|\/)app\.json$|(^|\/)eas\.json$/i, ["expo", "reactNative"]],
53
+ [/(^|\/)angular\.json$/i, ["angular"]],
54
+ [/(^|\/)manage\.py$|(^|\/)settings\.py$/i, ["django"]],
55
+ [/(^|\/)(requirements\.txt|pyproject\.toml|Pipfile)$/i, ["python"]],
56
+ [/(^|\/)Gemfile(\.lock)?$|(^|\/)config\/routes\.rb$/i, ["rails"]],
57
+ [/\.csproj$|(^|\/)Program\.cs$/i, ["dotnet"]],
58
+ [/(^|\/)pom\.xml$|(^|\/)build\.gradle(\.kts)?$/i, ["spring"]],
59
+ [/(^|\/)pubspec\.yaml$/i, ["flutter"]],
60
+ [/(^|\/)supabase\//i, ["supabase", "postgres"]],
61
+ [/(^|\/)(Dockerfile|docker-compose[^/]*\.ya?ml)$/i, ["docker"]],
62
+ [/(^|\/)(k8s|kubernetes|helm)\//i, ["kubernetes"]],
63
+ [/(^|\/)\.github\/workflows\//i, ["githubActions"]],
64
+ [/(^|\/)vercel\.json$/i, ["vercel"]],
65
+ [/(^|\/)(cloudformation|cdk)\/|(^|\/)serverless\.ya?ml$/i, ["aws"]],
66
+ [/(^|\/)app\.yaml$|(^|\/)cloudbuild\.ya?ml$/i, ["gcp"]],
67
+ [/(^|\/)azure-pipelines\.ya?ml$|(^|\/)host\.json$/i, ["azure"]],
68
+ [/(^|\/)redis\.conf$|(^|\/)redis\//i, ["redis"]],
69
+ [/(^|\/)vitest\.(config|workspace)\.[cm]?[jt]s$/i, ["vitest"]],
70
+ [/(^|\/)jest\.config\.[cm]?[jt]s$|(^|\/)jest\.setup\.[cm]?[jt]s$/i, ["jest"]],
71
+ [/(^|\/)playwright\.config\.[cm]?[jt]s$/i, ["playwright"]],
72
+ [/(^|\/)\.storybook\/|\.stories\.[jt]sx?$/i, ["storybook"]],
73
+ [/(^|\/)wrangler\.(toml|jsonc?)$/i, ["cloudflare"]],
74
+ [/(^|\/)deno\.(jsonc?|lock)$/i, ["deno"]],
75
+ [/(^|\/)bun\.lockb?$|(^|\/)bunfig\.toml$/i, ["bun"]],
76
+ [/(^|\/)drizzle\.config\.[cm]?[jt]s$|(^|\/)drizzle\//i, ["drizzle"]],
77
+ [/(^|\/)vite\.config\.[cm]?[jt]s$/i, ["vite"]],
78
+ [/(^|\/)webpack\.config\.[cm]?[jt]s$/i, ["webpack"]],
79
+ [/(^|\/)electron-builder\.(ya?ml|json)$|(^|\/)electron\.vite\.config\.[cm]?[jt]s$/i, ["electron"]],
80
+ [/(^|\/)firebase\.json$|(^|\/)\.firebaserc$/i, ["firebase"]],
81
+ [/(^|\/)sentry\.[a-z]+\.config\.[cm]?[jt]s$/i, ["sentry"]],
82
+ [/(^|\/)\.mcp\.json$|(^|\/)mcp\.json$/i, ["mcp"]],
83
+ [/(^|\/)\.claude\/|(^|\/)CLAUDE\.md$/i, ["claude"]],
84
+ [/(^|\/)(rag|retrieval|embeddings?|vector[-_]?stores?)(\/|\.)/i, ["retrieval"]],
85
+ [/(^|\/)pgvector(\/|\.)|(^|\/)migrations?\/[^/]*(vector|embedding)[^/]*\.sql$/i, ["pgvector", "retrieval"]],
86
+ [/(^|\/)pinecone[^/]*(\/|\.)/i, ["pinecone", "retrieval"]],
87
+ [/(^|\/)weaviate[^/]*(\/|\.)/i, ["weaviate", "retrieval"]],
88
+ [/(^|\/)qdrant[^/]*(\/|\.)/i, ["qdrant", "retrieval"]],
89
+ [/(^|\/)chroma(\/|\.sqlite3$)/i, ["chroma", "retrieval"]],
90
+ [/(^|\/)langchain[^/]*(\/|\.)|(^|\/)langgraph\.json$/i, ["langchain"]],
91
+ [/(^|\/)llama[-_]?index[^/]*(\/|\.)/i, ["llamaindex", "retrieval"]],
92
+ ];
93
+ /** One path → its technologies, sorted; the manifest rules first, then the extension rules, as core reads it. */
94
+ export function stackOfFile(path) {
95
+ const found = new Set();
96
+ for (const [pattern, keys] of BY_NAME) if (pattern.test(path)) for (const key of keys) found.add(key);
97
+ for (const [pattern, keys] of BY_EXTENSION) if (pattern.test(path)) for (const key of keys) found.add(key);
98
+ return [...found].sort();
99
+ }
100
+ /** Many paths → the union, sorted; keys only. */
101
+ export function stackOfFiles(paths) {
102
+ const found = new Set();
103
+ for (const path of paths) for (const key of stackOfFile(path)) found.add(key);
104
+ return [...found].sort();
105
+ }
106
+ /**
107
+ * TOOLS SEEN IN THE FILES (owner, 2026-10-10): the display-only keys beside the frozen engine list, the same rule (a file
108
+ * names it), sent apart as `tools_seen` so no scoring reader of `stack` ever sees them.
109
+ */
110
+ export const DISPLAY_TECHNOLOGIES = [
111
+ "npm",
112
+ "cli",
113
+ "pytorch",
114
+ "huggingface",
115
+ "onnx",
116
+ "tensorflow",
117
+ "jupyter",
118
+ "gguf",
119
+ "ollama",
120
+ "mlflow",
121
+ "wandb",
122
+ "dvc",
123
+ ];
124
+ const DISPLAY_BY_NAME = [
125
+ [/(^|\/)\.npm(ignore|rc)$/i, ["npm"]],
126
+ [/(^|\/)bin\/[^/]+$/i, ["cli"]],
127
+ [/(^|\/)tokenizer(_config)?\.json$/i, ["huggingface"]],
128
+ [/(^|\/)saved_model\.pb$/i, ["tensorflow"]],
129
+ [/(^|\/)Modelfile$/, ["ollama"]],
130
+ [/(^|\/)mlruns\//i, ["mlflow"]],
131
+ [/(^|\/)wandb\//i, ["wandb"]],
132
+ [/(^|\/)dvc\.yaml$/i, ["dvc"]],
133
+ ];
134
+ const DISPLAY_BY_EXTENSION = [
135
+ [/\.(pt|pth|ckpt)$/i, ["pytorch"]],
136
+ [/\.safetensors$/i, ["huggingface"]],
137
+ [/\.onnx$/i, ["onnx"]],
138
+ [/\.(tflite|h5|keras)$/i, ["tensorflow"]],
139
+ [/\.ipynb$/i, ["jupyter"]],
140
+ [/\.gguf$/i, ["gguf"]],
141
+ [/\.dvc$/i, ["dvc"]],
142
+ ];
143
+ export function displayStackOfFile(path) {
144
+ const found = new Set();
145
+ for (const [pattern, keys] of DISPLAY_BY_NAME) if (pattern.test(path)) for (const key of keys) found.add(key);
146
+ for (const [pattern, keys] of DISPLAY_BY_EXTENSION) if (pattern.test(path)) for (const key of keys) found.add(key);
147
+ return [...found].sort();
148
+ }
149
+ export function displayStackOfFiles(paths) {
150
+ const found = new Set();
151
+ for (const path of paths) for (const key of displayStackOfFile(path)) found.add(key);
152
+ return [...found].sort();
153
+ }
package/worktrust.mjs CHANGED
@@ -8,15 +8,24 @@
8
8
  * npx worktrust --dry-run show the plan only; nothing is written, nothing is sent
9
9
  * npx worktrust --yes no question (for scripts); the computer is still approved in the app
10
10
  * npx worktrust --device a computer without a browser (SSH): type a code on another device
11
- * npx worktrust@latest connect couple again, also on a computer already coupled
12
- * npx worktrust@latest update this computer onto the newest CLI, same key, no new pairing
13
- * npx worktrust@latest history send this computer's earlier sessions as history (asks first)
14
- * npx worktrust@latest history --rebuild the same as history (0.10.5: history always re-measures); WorkTrust replaces this computer's
11
+ * npx worktrust connect couple again, also on a computer already coupled
12
+ * npx worktrust update this computer onto the newest CLI, same key, no new pairing
13
+ * npx worktrust history send this computer's earlier sessions as history (asks first)
14
+ * npx worktrust history --rebuild the same as history (0.10.5: history always re-measures); WorkTrust replaces this computer's
15
15
  * earlier lines day by day, never counting a day twice (shows the plan, asks first)
16
- * npx worktrust@latest history --from-archive [dir] send what your local archive holds of sessions your AI apps have
17
- * already deleted, marked as from your archive (shows the plan, asks first)
18
- * npx worktrust@latest disconnect show what comes out, ask, take it out again
19
- * npx worktrust@latest status what is coupled here
16
+ * npx worktrust history --from-archive [dir] send what your local archive holds of sessions your AI apps have
17
+ * already deleted, marked as from your archive (shows the plan, asks first):
18
+ * a day this computer's device key signed as measured, every other day
19
+ * (unsigned, the local archive key's, another computer's) as reconstructed
20
+ * npx worktrust history --from-folder <dir> your own copy of an AI app's session folder (a backed-up ~/.claude/projects,
21
+ * ~/.codex/sessions): the days this computer's own sessions lack, reconstructed,
22
+ * never verified hours (shows the plan, asks first; 0.10.10)
23
+ * npx worktrust history --export <path> a ChatGPT or Claude data export (the zip, its folder or conversations.json)
24
+ * as history: hours RECONSTRUCTED from its clocks, shown with their origin,
25
+ * never verified hours (shows the plan, asks first; 0.10.10). The bare
26
+ * command on a coupled computer offers an export lying in ~/Downloads once.
27
+ * npx worktrust disconnect show what comes out, ask, take it out again
28
+ * npx worktrust status what is coupled here
20
29
  * npx worktrust@latest preserve how long each AI app here keeps its sessions (--apply keeps them,
21
30
  * --archive [dir] a local metadata-only record, --verify [dir] checks it,
22
31
  * --summary [dir] counts hours, tokens and parallel sessions from it);
@@ -69,19 +78,19 @@ import { createInterface as lines } from "node:readline";
69
78
  import { fileURLToPath } from "node:url";
70
79
 
71
80
  const args = process.argv.slice(2);
72
- const VALUED = ["--name", "--origin", "--url"];
81
+ const VALUED = ["--name", "--origin", "--url", "--export", "--from-folder"];
73
82
  const command = args.find((arg, at) => !arg.startsWith("--") && !(at > 0 && VALUED.includes(args[at - 1]))) ?? (args.includes("--help") ? "help" : "default");
74
83
  const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
75
84
  const has = (name) => args.includes(`--${name}`);
76
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). */
77
- const CLI_VERSION = "0.10.9";
86
+ const CLI_VERSION = "0.10.11";
78
87
  const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.worktrust.io").replace(/\/$/, "");
79
88
  const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
80
89
  const HOME_DIR = join(homedir(), ".worktrust");
81
90
  const HERE = dirname(fileURLToPath(import.meta.url));
82
- const SCRIPTS = ["setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs"];
91
+ const SCRIPTS = ["setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs"];
83
92
  /** The modules the scripts import by name from beside them; a download keeps that name. */
84
- const IMPORTED = new Set(["transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs"]);
93
+ const IMPORTED = new Set(["transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs"]);
85
94
  const downloaded = (name) => (IMPORTED.has(name) ? name : `${name}.download.mjs`);
86
95
  const BUNDLED = SCRIPTS.every((name) => existsSync(join(HERE, name)));
87
96
  const PLACEHOLDER = `wt_${"0".repeat(43)}`;
@@ -219,7 +228,7 @@ async function pairByBrowser(host, extra) {
219
228
  const exchange = await post("/api/cli/token", { device_code: secret, code, code_verifier: verifier }).catch(() => null);
220
229
  if (!exchange || exchange.status !== 200 || !exchange.json.token) fail(`the approval could not be exchanged (${exchange?.json?.error ?? "no answer"}). Run \`worktrust connect\` again.`);
221
230
  say(` ✓ Approved as "${exchange.json.label}"${exchange.json.account ? ` for the WorkTrust account ${exchange.json.account}` : ""}`);
222
- if (exchange.json.account) say(" Not your account? Run `npx worktrust@latest disconnect` now and revoke it in WorkTrust.");
231
+ if (exchange.json.account) say(" Not your account? Run `npx worktrust disconnect` now and revoke it in WorkTrust.");
223
232
  if (extraBound && exchange.json.bound === false) say(" ! WorkTrust did not bind the key to this computer; it works like a key made by hand.");
224
233
  return paired(exchange.json);
225
234
  }
@@ -248,7 +257,7 @@ async function pairByCode(host, extra) {
248
257
  if (!answer) continue;
249
258
  if (answer.status === 200 && answer.json.token) {
250
259
  say(` ✓ Approved as "${answer.json.label}"${answer.json.account ? ` for the WorkTrust account ${answer.json.account}` : ""}`);
251
- if (answer.json.account) say(" Not your account? Run `npx worktrust@latest disconnect` now and revoke it in WorkTrust.");
260
+ if (answer.json.account) say(" Not your account? Run `npx worktrust disconnect` now and revoke it in WorkTrust.");
252
261
  return paired(answer.json);
253
262
  }
254
263
  if (answer.json.error === "slow_down") wait += 2000;
@@ -375,7 +384,7 @@ async function copiedHere(key) {
375
384
  const url = `${new URL(key.url).origin}/api/cli/moved`, body = JSON.stringify(computerIds());
376
385
  await fetch(url, { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${key.token}`, ...proof(key.device, url, body) }, body });
377
386
  } catch { /* offline: it is told next time */ }
378
- process.stderr.write("WorkTrust: this key was made on another computer (copied from a backup?). Nothing is sent from here; run `npx worktrust@latest connect` on this computer.\n");
387
+ process.stderr.write("WorkTrust: this key was made on another computer (copied from a backup?). Nothing is sent from here; run `npx worktrust connect` on this computer.\n");
379
388
  return true;
380
389
  }
381
390
 
@@ -442,7 +451,7 @@ async function bridge() {
442
451
  let message;
443
452
  try { message = JSON.parse(line); } catch { continue; }
444
453
  if (message.method === "initialize" && message.params?.clientInfo?.name) agent = `${message.params.clientInfo.name}/${message.params.clientInfo.version ?? "0"} (worktrust-bridge) worktrust-cli/${CLI_VERSION}`;
445
- if (!key) { if (message.id !== undefined) answer(message.id, "WorkTrust is not connected on this computer: run `npx worktrust@latest connect`."); continue; }
454
+ if (!key) { if (message.id !== undefined) answer(message.id, "WorkTrust is not connected on this computer: run `npx worktrust connect`."); continue; }
446
455
  try {
447
456
  const response = await fetch(key.url, { method: "POST", headers: { "content-type": "application/json", accept: "application/json, text/event-stream", authorization: `Bearer ${key.token}`, "user-agent": agent, ...(session ? { "mcp-session-id": session } : {}), ...proof(key.device, key.url, line) }, body: line });
448
457
  session = response.headers.get("mcp-session-id") ?? session;
@@ -455,7 +464,7 @@ async function bridge() {
455
464
  const again = await fetch(key.url, { method: "POST", headers: { "content-type": "application/json", accept: "application/json, text/event-stream", authorization: `Bearer ${key.token}`, "user-agent": agent, ...(session ? { "mcp-session-id": session } : {}), ...proof(key.device, key.url, line) }, body: line });
456
465
  if (again.status !== 401) { const text = await again.text(); const parts = (again.headers.get("content-type") ?? "").includes("event-stream") ? text.split("\n").filter((part) => part.startsWith("data:")).map((part) => part.slice(5).trim()) : [text.trim()]; for (const part of parts.filter(Boolean)) process.stdout.write(`${part}\n`); continue; }
457
466
  }
458
- answer(message.id, "WorkTrust did not accept this computer's key: run `npx worktrust@latest connect` again.");
467
+ answer(message.id, "WorkTrust did not accept this computer's key: run `npx worktrust connect` again.");
459
468
  continue;
460
469
  }
461
470
  const text = await response.text();
@@ -521,7 +530,7 @@ async function sessionEnd() {
521
530
  */
522
531
  async function update() {
523
532
  const key = await freshKey();
524
- if (!key) fail("this computer has no WorkTrust key file yet. Run npx worktrust@latest connect.");
533
+ if (!key) fail("this computer has no WorkTrust key file yet. Run npx worktrust connect.");
525
534
  say();
526
535
  say(` WorkTrust · update ${hostname().replace(/\.local$/i, "")} to ${CLI_VERSION}`);
527
536
  say();
@@ -655,13 +664,13 @@ async function offerHistory(paths, token, devicePem, url = MCP, rebuild = false)
655
664
  say(" never deleted, so a day is counted once. Other computers, web sources and days not listed are not touched.");
656
665
  }
657
666
  if (has("dry-run")) { say(" Dry run: nothing was sent."); return; }
658
- if (!has("history") && !(rebuild ? await ask("Send them (re-measured; this computer's earlier lines for these days are replaced, a day is counted once)?", false) : await ask("Send these as history (hours and tokens per day; never text)?", false))) { historyDone(false); say(" Not sent. Send them later with: npx worktrust@latest"); return; }
667
+ if (!has("history") && !(rebuild ? await ask("Send them (re-measured; this computer's earlier lines for these days are replaced, a day is counted once)?", false) : await ask("Send these as history (hours and tokens per day; never text)?", false))) { historyDone(false); say(" Not sent. Send them later with: npx worktrust"); return; }
659
668
  // Marked unfinished before the first batch leaves (0.10.9): a send stopped halfway (Ctrl+C, a closed lid) is finished by the next run.
660
669
  historyDone(false);
661
670
  const sent = await run(paths["log-session.mjs"], ["--history", ...(rebuild ? ["--rebuild"] : [])], token, true, env);
662
671
  historyDone(sent.code === 0);
663
- if (rebuild) say(sent.code === 0 ? " ✓ Rebuilt. This computer's earlier lines for those days were replaced; the record shows each replacement." : " Not all of it arrived. Run npx worktrust@latest again: it finishes what did not arrive, a day already rebuilt is counted once.");
664
- else say(sent.code === 0 ? " ✓ Sent as history. Measured sessions count toward your verified hours; a day WorkTrust already holds is kept once." : " Not all of it arrived. Run npx worktrust@latest history again: a line already received is kept once.");
672
+ if (rebuild) say(sent.code === 0 ? " ✓ Rebuilt. This computer's earlier lines for those days were replaced; the record shows each replacement." : " Not all of it arrived. Run npx worktrust again: it finishes what did not arrive, a day already rebuilt is counted once.");
673
+ else say(sent.code === 0 ? " ✓ Sent as history. Measured sessions count toward your verified hours; a day WorkTrust already holds is kept once." : " Not all of it arrived. Run npx worktrust history again: a line already received is kept once.");
665
674
  }
666
675
 
667
676
  /** The version stamped in the stable copy in ~/.worktrust, the CLI this computer ran before an update; null without one. */
@@ -680,7 +689,7 @@ async function offerRebuild(previousVersion, paths, key) {
680
689
  say(" differently (each answer's tokens counted once, nothing lost at midnight, when each stretch began, how you steered");
681
690
  say(" the agent, what the seconds were, more AI apps). You can re-measure the");
682
691
  say(" sessions still on this computer and have WorkTrust replace this computer's earlier lines, day by day, never counting");
683
- say(" a day twice. Later: npx worktrust@latest");
692
+ say(" a day twice. Later: npx worktrust");
684
693
  if (!(await ask("Show the plan and rebuild now?", false))) { say(" Not now."); return; }
685
694
  await offerHistory(paths, key.token, key.device ?? null, key.url, true);
686
695
  }
@@ -710,16 +719,20 @@ async function again() {
710
719
  const key = await freshKey();
711
720
  if (key) { say(); say(` Your earlier sessions are not yet measured by worktrust ${CLI_VERSION} in WorkTrust, or did not all arrive. This finishes them.`); await offerHistory(await scripts(), key.token, key.device ?? null, key.url, true); }
712
721
  }
722
+ // A WEB CHAT'S EXPORT LYING IN DOWNLOADS (0.10.10): offered once, Enter is No.
723
+ { const key = await freshKey(); if (key) await offerDownloads(await scripts(), key); }
713
724
  say();
714
725
  await status();
715
726
  say();
716
- say(" This computer is coupled. `npx worktrust@latest connect` couples it again; `npx worktrust@latest disconnect` takes it out.");
727
+ say(" This computer is coupled. `npx worktrust connect` couples it again; `npx worktrust disconnect` takes it out.");
717
728
  }
718
729
 
719
730
  async function history() {
720
731
  const key = await freshKey();
721
732
  if (!key) fail("this computer is not coupled through the key file. Run npx worktrust first.");
722
733
  if (has("from-archive")) return offerArchive(await scripts(), key);
734
+ if (has("export")) { if (!flag("export") || flag("export").startsWith("--")) fail("--export needs the export's path: the zip, its folder, or conversations.json"); await offerExport(await scripts(), key, flag("export")); return; }
735
+ if (has("from-folder")) { if (!flag("from-folder") || flag("from-folder").startsWith("--")) fail("--from-folder needs the copied folder's path"); await offerFolder(await scripts(), key, flag("from-folder")); return; }
723
736
  // ONE PATH (0.10.5): sending is re-measuring. On a computer WorkTrust has never heard from nothing is replaced, so it is a
724
737
  // plain send; after a failure, a merge or an older CLI, the same command replaces day by day. `--rebuild` still reads.
725
738
  await offerHistory(await scripts(), key.token, key.device ?? null, key.url, true);
@@ -742,6 +755,94 @@ async function offerArchive(paths, key) {
742
755
  say(sent.code === 0 ? " ✓ Sent as history from your archive. It shows in WorkTrust as earlier work, marked as such, never as verified hours." : ` Not sent: ${sent.out.trim().split("\n").pop()}`);
743
756
  }
744
757
 
758
+ /**
759
+ * A WEB CHAT'S DATA EXPORT AS HISTORY (0.10.10, owner 2026-10-10). ChatGPT's and Claude's exports (the zip, its folder, or
760
+ * conversations.json) go through the history door as RECONSTRUCTED hours: shown with their origin, never verified
761
+ * hours, because the file can be edited before it is read and no device key witnessed it. Nothing of a conversation
762
+ * leaves: not its title, not a message; the hook reads the clocks, the person's own turns and the model's name. The
763
+ * plan first (the product, conversations, days, hours, first and last month), then one question; Enter is No;
764
+ * `--dry-run` stops before it; `--history` says yes in advance. Answers whether the export arrived whole.
765
+ */
766
+ const EXPORT_PRODUCT = { chatgpt: "ChatGPT", "claude-web": "Claude on the web" };
767
+ async function offerExport(paths, key, path) {
768
+ const env = { WORKTRUST_MCP_URL: key.url, ...(key.device ? { WORKTRUST_DEVICE_KEY: key.device } : {}) };
769
+ const counted = await run(paths["log-session.mjs"], ["--history", "--export", path, "--dry-run", "--summary"], key.token, true, env);
770
+ let found = null;
771
+ try { found = JSON.parse(counted.out.trim().split("\n").pop()); } catch { /* no line: the export could not be read */ }
772
+ const report = found?.exports?.[0];
773
+ say();
774
+ if (counted.code !== 0 || !report) { say(` ${counted.out.trim().split("\n").filter(Boolean).pop() ?? "export: it could not be read"}. Nothing was sent.`); return false; }
775
+ const product = EXPORT_PRODUCT[report.vendor] ?? report.vendor;
776
+ if (!report.days) { say(` ${product} export · ${report.conversations} conversations, none with a clock to place: nothing to send.`); return true; }
777
+ say(` ${product} export · ${report.conversations} conversations · ${report.days} days · ${report.hours} reconstructed hours · ${String(report.first).slice(0, 7)} … ${String(report.last).slice(0, 7)}`);
778
+ say(" Hours reconstructed from the export's own clocks: shown with their origin, never verified hours. Never a title or a message.");
779
+ if (has("dry-run")) { say(" Dry run: nothing was sent."); return false; }
780
+ if (!has("history") && !(await ask("Send it as history (reconstructed hours per day; never text)?", false))) { say(` Not sent. Send it later with: npx worktrust history --export ${path}`); return false; }
781
+ const sent = await run(paths["log-session.mjs"], ["--history", "--export", path], key.token, true, env);
782
+ say(sent.code === 0 ? ` ✓ Sent as history. It shows in WorkTrust as ${product}, reconstructed, never as verified hours; a line already received is kept once.` : ` Not all of it arrived. Run npx worktrust history --export ${path} again: a line already received is kept once.`);
783
+ if (sent.code !== 0) return false;
784
+ // THE EXPORT REPLACES (owner, 2026-10-10): the door withdrew the product's earlier connector lines on the export's days by itself and
785
+ // says so; the lines an AI app reported under no product on those days may describe the same conversations, and go only on a yes.
786
+ const counts = lastCounts(sent.out);
787
+ if (counts.superseded > 0) say(` ${counts.superseded} earlier line${counts.superseded === 1 ? "" : "s"} of ${product} on those days, brought in by a connector, ${counts.superseded === 1 ? "is" : "are"} withdrawn and kept (each with a correction row): the export's lines count, a day counts once.`);
788
+ if (counts.unknownOnDays > 0) {
789
+ const n = counts.unknownOnDays;
790
+ say(` ${n} earlier line${n === 1 ? "" : "s"} an AI app reported for these days, under no product, may describe the same conversations.`);
791
+ if (has("withdraw-unknown") || (await ask(`Also withdraw ${n} earlier line${n === 1 ? "" : "s"} an AI app reported for these days?`, false))) {
792
+ const again = await run(paths["log-session.mjs"], ["--history", "--export", path, "--withdraw-unknown"], key.token, true, env);
793
+ const done = lastCounts(again.out);
794
+ say(again.code === 0 ? ` ✓ Withdrawn and kept: ${done.unknownWithdrawn} earlier line${done.unknownWithdrawn === 1 ? "" : "s"}, each with a correction row; never deleted.` : ` Not withdrawn: ${again.out.trim().split("\n").pop()}`);
795
+ } else say(` Kept. Later: npx worktrust history --export ${path} --withdraw-unknown`);
796
+ }
797
+ return true;
798
+ }
799
+ /** The hook's last line of counts after an export send (superseded, unknownOnDays, unknownWithdrawn); zeros when there is none. */
800
+ function lastCounts(out) {
801
+ try { const line = out.trim().split("\n").filter((text) => text.startsWith("{")).pop(); const json = JSON.parse(line ?? "{}"); return { superseded: Number(json.superseded) || 0, unknownOnDays: Number(json.unknownOnDays) || 0, unknownWithdrawn: Number(json.unknownWithdrawn) || 0 }; } catch { return { superseded: 0, unknownOnDays: 0, unknownWithdrawn: 0 }; }
802
+ }
803
+
804
+ /**
805
+ * THE EXPORT LYING IN DOWNLOADS (0.10.10): on a coupled computer the bare command looks in ~/Downloads, its top level
806
+ * only, for a ChatGPT or Claude export it has neither sent nor asked about, and offers each once by the same path as
807
+ * `history --export`; a No is remembered by the file's digest (never a conversation), and the command to send it later is
808
+ * said. A dry run remembers nothing.
809
+ */
810
+ async function offerDownloads(paths, key) {
811
+ const found = await run(paths["log-session.mjs"], ["--find-exports"], "", true, { WORKTRUST_MCP_URL: "" });
812
+ let exports = [];
813
+ try { exports = JSON.parse(found.out.trim().split("\n").pop()); } catch { return; }
814
+ for (const one of Array.isArray(exports) ? exports : []) {
815
+ if (one.sent || one.offered) continue;
816
+ say();
817
+ say(` A ${EXPORT_PRODUCT[one.vendor] ?? one.vendor} export lies in your Downloads folder: ${one.path}`);
818
+ const sent = await offerExport(paths, key, one.path);
819
+ if (!sent && !has("dry-run")) await run(paths["log-session.mjs"], ["--export-offered", one.digest], "", true, { WORKTRUST_MCP_URL: "" });
820
+ }
821
+ }
822
+
823
+ /**
824
+ * A COPIED SESSION FOLDER AS HISTORY (owner, 2026-10-10, one rule): a person's own backup of ~/.claude/projects, ~/.codex/sessions
825
+ * or an Antigravity brain folder, read by the hook with the same readers and clock as the live folders (never those), its days
826
+ * RECONSTRUCTED and titled as from a copied folder; a stretch the live folders already hold is skipped (they win). The plan
827
+ * first, then one question; Enter is No; `--dry-run` stops before it; `--history` says yes in advance.
828
+ */
829
+ async function offerFolder(paths, key, dir) {
830
+ const env = { WORKTRUST_MCP_URL: key.url, ...(key.device ? { WORKTRUST_DEVICE_KEY: key.device } : {}) };
831
+ const counted = await run(paths["log-session.mjs"], ["--history", "--from-folder", dir, "--dry-run", "--summary"], key.token, true, env);
832
+ let found = null;
833
+ try { found = JSON.parse(counted.out.trim().split("\n").pop()); } catch { /* no line: the folder could not be read */ }
834
+ const report = found?.folder;
835
+ say();
836
+ if (counted.code !== 0 || !report) { say(` ${counted.out.trim().split("\n").filter(Boolean).pop() ?? "folder: it could not be read"}. Nothing was sent.`); return; }
837
+ say(` Copied session folder · ${report.stretches} stretch${report.stretches === 1 ? "" : "es"} (${report.skipped} already among this computer's own sessions, skipped) · ${report.days} day${report.days === 1 ? "" : "s"} · ${report.hours} reconstructed hours${report.first ? ` · ${report.first} … ${report.last}` : ""}`);
838
+ if (!report.days) { say(" Nothing to send: every day of the copy is already among this computer's own sessions."); return; }
839
+ say(" Hours reconstructed from the copy's own clocks: shown with their origin, never verified hours. Never text.");
840
+ if (has("dry-run")) { say(" Dry run: nothing was sent."); return; }
841
+ if (!has("history") && !(await ask("Send it as history (reconstructed hours per day; never text)?", false))) { say(` Not sent. Send it later with: npx worktrust history --from-folder ${dir}`); return; }
842
+ const sent = await run(paths["log-session.mjs"], ["--history", "--from-folder", dir], key.token, true, env);
843
+ say(sent.code === 0 ? " ✓ Sent as history. It shows in WorkTrust as reconstructed, from a copied session folder, never as verified hours; a line already received is kept once." : ` Not all of it arrived. Run npx worktrust history --from-folder ${dir} again: a line already received is kept once.`);
844
+ }
845
+
745
846
  /**
746
847
  * CODEX WAKES THE HOOK ON A YES (owner, 2026-10-04). Codex has no hook settings: it runs ONE `notify`
747
848
  * program at the end of every turn, named on a top-level line of ~/.codex/config.toml. Without it
@@ -791,7 +892,7 @@ async function offerCodex() {
791
892
  say(" Codex can wake the session hook at the end of every turn, so Codex work arrives without Claude Code running:");
792
893
  say(` ${found.text ? "↻" : "+"} ${CODEX_CONFIG} → ${want}`);
793
894
  if (has("dry-run")) { say(" Dry run: nothing was written."); return; }
794
- if (!has("codex") && !(await ask("Let Codex wake the session hook?", false))) { say(" Not set. npx worktrust@latest update asks again."); return; }
895
+ if (!has("codex") && !(await ask("Let Codex wake the session hook?", false))) { say(" Not set. npx worktrust update asks again."); return; }
795
896
  const rows = [...found.rows];
796
897
  if (found.text) rows.splice(found.at, found.end - found.at + 1, want);
797
898
  else rows.splice(found.insert, 0, ...(found.insert < rows.length && rows[found.insert] !== "" ? [want, ""] : [want]));
@@ -832,7 +933,7 @@ async function offerAntigravity() {
832
933
  say(" Antigravity can wake the session hook when its agent stops, so Antigravity work arrives without Claude Code running:");
833
934
  say(` ${hooks.worktrust ? "↻" : "+"} ${AGY_HOOKS} → worktrust: Stop runs ${want.Stop[0].command}`);
834
935
  if (has("dry-run")) { say(" Dry run: nothing was written."); return; }
835
- if (!has("antigravity") && !(await ask("Let Antigravity wake the session hook?", false))) { say(" Not set. npx worktrust@latest update asks again."); return; }
936
+ if (!has("antigravity") && !(await ask("Let Antigravity wake the session hook?", false))) { say(" Not set. npx worktrust update asks again."); return; }
836
937
  writeAgyHooks({ ...hooks, worktrust: want });
837
938
  say(` ✓ Antigravity wakes the session hook. Restart Antigravity to pick it up${existsSync(`${AGY_HOOKS}.worktrust-backup`) ? "; the earlier file is kept as hooks.json.worktrust-backup" : ""}.`);
838
939
  }
@@ -890,16 +991,16 @@ async function status() {
890
991
  for (const project of Object.values(config.projects ?? {})) Object.assign(servers, project.mcpServers ?? {});
891
992
  } catch { /* no Claude Code here */ }
892
993
  const door = Object.entries(servers).find(([name, server]) => /worktrust/i.test(`${name} ${server?.url ?? ""} ${(server?.args ?? []).join(" ")}`));
893
- say(door ? ` Claude Code: coupled (${door[1].url ?? "through the local bridge"})` : " Claude Code: not coupled. Run `npx worktrust@latest connect`.");
994
+ say(door ? ` Claude Code: coupled (${door[1].url ?? "through the local bridge"})` : " Claude Code: not coupled. Run `npx worktrust connect`.");
894
995
  const key = keyStore.load();
895
996
  say(key ? ` Key: in ${KEY_PLACE}, ${key.device ? "bound to this computer, " : ""}last renewed ${String(key.renewedAt ?? "").slice(0, 10) || "never"}` : " Key: not on this computer (or written into the apps' settings with --direct)");
896
- if (key) say(key.account ? ` Account: ${key.account}${key.coupledAt ? `, coupled ${String(key.coupledAt).slice(0, 10)}` : ""}` : " Account: not recorded (coupled by an older version; `npx worktrust@latest connect` records it)");
997
+ if (key) say(key.account ? ` Account: ${key.account}${key.coupledAt ? `, coupled ${String(key.coupledAt).slice(0, 10)}` : ""}` : " Account: not recorded (coupled by an older version; `npx worktrust connect` records it)");
897
998
  let hook = false;
898
999
  try { hook = /log-session|worktrust\.mjs\\?" hook/.test(readFileSync(join(homedir(), ".claude", "settings.json"), "utf8")); } catch { /* none */ }
899
1000
  say(hook ? " Session hook: installed" : " Session hook: not installed");
900
- if (existsSync(join(homedir(), ".codex"))) { const notify = codexNotify().text ?? ""; say(isOurNotify(notify) ? " Codex: wakes the session hook" : " Codex: does not wake the session hook (npx worktrust@latest update asks)"); }
901
- if (existsSync(join(homedir(), ".hermes"))) { let text = ""; try { text = readFileSync(join(homedir(), ".hermes", "config.yaml"), "utf8"); } catch { /* none */ } say(/worktrust\.mjs\\?" hook --hermes/.test(text) ? " Hermes Agent: wakes the session hook" : " Hermes Agent: does not wake the session hook (npx worktrust@latest update writes it)"); }
902
- if (antigravityHere()) say(agyHooks()?.worktrust ? " Antigravity: wakes the session hook" : " Antigravity: does not wake the session hook (npx worktrust@latest update asks)");
1001
+ if (existsSync(join(homedir(), ".codex"))) { const notify = codexNotify().text ?? ""; say(isOurNotify(notify) ? " Codex: wakes the session hook" : " Codex: does not wake the session hook (npx worktrust update asks)"); }
1002
+ if (existsSync(join(homedir(), ".hermes"))) { let text = ""; try { text = readFileSync(join(homedir(), ".hermes", "config.yaml"), "utf8"); } catch { /* none */ } say(/worktrust\.mjs\\?" hook --hermes/.test(text) ? " Hermes Agent: wakes the session hook" : " Hermes Agent: does not wake the session hook (npx worktrust update writes it)"); }
1003
+ if (antigravityHere()) say(agyHooks()?.worktrust ? " Antigravity: wakes the session hook" : " Antigravity: does not wake the session hook (npx worktrust update asks)");
903
1004
  say(existsSync(join(HOME_DIR, "pinned")) ? " Counter: from the package, pinned" : existsSync(join(HOME_DIR, "count-behaviour.mjs")) ? " Counter: follows the site" : " Counter: not installed");
904
1005
  await measuredHere();
905
1006
  }
@@ -916,15 +1017,15 @@ async function measuredHere() {
916
1017
  let m = null;
917
1018
  try { m = JSON.parse(read.out.trim().split("\n").filter((text) => text.startsWith("{")).pop()); } catch { return; }
918
1019
  if (!m || !m.stretches) { say(" Measured here, last 30 days: no finished work stretch yet."); return; }
919
- const of = (part, whole, unit) => `${part} of ${whole} ${unit}`;
1020
+ const of = (part, whole, one, many) => `${part} of ${whole} ${whole === 1 ? one : many}`;
920
1021
  say();
921
- say(` Measured here, last 30 days: ${m.stretches} work stretches · ${m.hours} h`);
922
- if (m.delivered) say(` verified before delivery ${of(m.verified_first, m.delivered, "stretches that delivered")}`);
923
- if (m.failures) say(` recovered failures ${of(m.recovered, m.failures, "failed tool calls")} (${m.blind_retries} retried unchanged)`);
924
- if (m.steers) say(` steering that worked ${of(m.effective_steers, m.steers, "times you stepped in")}`);
1022
+ say(` Measured here, last 30 days: ${m.stretches} work stretch${m.stretches === 1 ? "" : "es"} · ${m.hours >= 1 ? `${m.hours} h` : "under 1 h"}`);
1023
+ if (m.delivered) say(` verified before delivery ${of(m.verified_first, m.delivered, "stretch that delivered", "stretches that delivered")}`);
1024
+ if (m.failures) say(` recovered failures ${of(m.recovered, m.failures, "failed tool call", "failed tool calls")} (${m.blind_retries} retried unchanged)`);
1025
+ if (m.steers) say(` steering that worked ${of(m.effective_steers, m.steers, "time you stepped in", "times you stepped in")}`);
925
1026
  if (m.refused || m.guard_denied) say(` refused ${m.refused} by you · ${m.guard_denied} by a guard`);
926
- if (m.planned) say(` planned ${m.planned} stretches with a to-do list`);
927
- if (m.files) say(` tests among changed files ${of(m.test_files, m.files, "files")}`);
1027
+ if (m.planned) say(` planned ${m.planned} stretch${m.planned === 1 ? "" : "es"} with a to-do list`);
1028
+ if (m.files) say(` tests among changed files ${of(m.test_files, m.files, "file", "files")}`);
928
1029
  const tiers = Object.entries(m.complexity ?? {}).sort();
929
1030
  if (tiers.length) say(` task complexity ${tiers.map(([tier, n]) => `${tier} ${n}`).join(" · ")}`);
930
1031
  say(" Sent with each stretch as kinds and counts, never text. Keep your own copy: npx worktrust@latest preserve");
@@ -964,7 +1065,14 @@ function help() {
964
1065
  say(" --rebuild re-measure them with the current rules; WorkTrust replaces this computer's earlier lines,");
965
1066
  say(" day by day, never counting a day twice (shows the plan per AI app, asks first; --dry-run: the plan only)");
966
1067
  say(" --from-archive [dir] send what your archive (preserve --archive) holds of sessions your AI apps already deleted,");
967
- say(" only days this computer signed, marked as from your archive (shows the plan, asks first)");
1068
+ say(" marked as from your archive: a day this computer's key signed as measured, every other day");
1069
+ say(" as reconstructed, never verified hours (shows the plan, asks first)");
1070
+ say(" --export <path> a ChatGPT or Claude data export (the zip, its folder or conversations.json) as history:");
1071
+ say(" hours reconstructed from its clocks, shown with their origin, never verified hours (asks first);");
1072
+ say(" on its days the export replaces the product's earlier connector lines (withdrawn, kept)");
1073
+ say(" --withdraw-unknown with --export: yes in advance to withdrawing the earlier lines an AI app reported for those days");
1074
+ say(" --from-folder <dir> your own copy of an AI app's session folder (a backed-up ~/.claude/projects, ~/.codex/sessions):");
1075
+ say(" days this computer's own sessions lack, reconstructed, never verified hours (asks first)");
968
1076
  say(" worktrust disconnect take WorkTrust out of every AI app here (asks first)");
969
1077
  say(" worktrust status what is coupled here");
970
1078
  say(" worktrust preserve keep your AI history: the report, then the settings and a local archive, each on your yes");