worktrust 0.10.7 → 0.10.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/worktrust.mjs +9 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worktrust",
3
- "version": "0.10.7",
3
+ "version": "0.10.9",
4
4
  "description": "Couple this computer to WorkTrust: approve a code in your browser, and every AI app here reports what you built. Metadata only, no dependencies.",
5
5
  "type": "module",
6
6
  "bin": {
package/worktrust.mjs CHANGED
@@ -74,7 +74,7 @@ const command = args.find((arg, at) => !arg.startsWith("--") && !(at > 0 && VALU
74
74
  const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
75
75
  const has = (name) => args.includes(`--${name}`);
76
76
  /** 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.7";
77
+ const CLI_VERSION = "0.10.9";
78
78
  const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.worktrust.io").replace(/\/$/, "");
79
79
  const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
80
80
  const HOME_DIR = join(homedir(), ".worktrust");
@@ -656,6 +656,8 @@ async function offerHistory(paths, token, devicePem, url = MCP, rebuild = false)
656
656
  }
657
657
  if (has("dry-run")) { say(" Dry run: nothing was sent."); return; }
658
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; }
659
+ // 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
+ historyDone(false);
659
661
  const sent = await run(paths["log-session.mjs"], ["--history", ...(rebuild ? ["--rebuild"] : [])], token, true, env);
660
662
  historyDone(sent.code === 0);
661
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.");
@@ -691,7 +693,9 @@ const HISTORY_STATE = join(HOME_DIR, "history.json");
691
693
  function historyDone(complete) {
692
694
  try { ensureHome(); writeFileSync(HISTORY_STATE, JSON.stringify({ version: CLI_VERSION, at: new Date().toISOString(), complete }), { mode: 0o600 }); } catch { /* the next run asks again */ }
693
695
  }
694
- const historyComplete = () => { try { return JSON.parse(readFileSync(HISTORY_STATE, "utf8")).complete === true; } catch { return false; } };
696
+ /** Complete AND measured by this very CLI (0.10.9): a run stopped after the update, before the history, leaves the history
697
+ * measured by an older version, and the next run must offer it again rather than read "complete" as done. */
698
+ const historyComplete = () => { try { const state = JSON.parse(readFileSync(HISTORY_STATE, "utf8")); return state.complete === true && state.version === CLI_VERSION; } catch { return false; } };
695
699
 
696
700
  /**
697
701
  * THE SAME COMMAND AGAIN DOES WHAT IS LEFT (0.10.5). On a computer already coupled, `npx worktrust@latest` brings it onto
@@ -704,7 +708,7 @@ async function again() {
704
708
  if (before && before !== CLI_VERSION) { await update(); return; }
705
709
  if (!historyComplete()) {
706
710
  const key = await freshKey();
707
- if (key) { say(); say(" Your earlier sessions have not all reached WorkTrust from this computer yet. This finishes them."); await offerHistory(await scripts(), key.token, key.device ?? null, key.url, true); }
711
+ 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); }
708
712
  }
709
713
  say();
710
714
  await status();
@@ -995,7 +999,8 @@ if (agentShell && PERSON_ONLY.has(command)) {
995
999
  * test), an AI agent's shell: this version runs as it is. The bridge and the hook, which run many times a day from the
996
1000
  * stable copy, never ask.
997
1001
  */
998
- const RELAY_COMMANDS = new Set(["default", "connect", "update", "history", "status", "disconnect", "preserve", "codex", "antigravity"]);
1002
+ // NOT `preserve` (0.10.8): it promises no network connection at all (the site and its kit say so), so it never asks npm.
1003
+ const RELAY_COMMANDS = new Set(["default", "connect", "update", "history", "status", "disconnect", "codex", "antigravity"]);
999
1004
  const semverNewer = (a, b) => { const x = a.split(".").map(Number), y = b.split(".").map(Number); for (let i = 0; i < 3; i += 1) if (x[i] !== y[i]) return x[i] > y[i]; return false; };
1000
1005
  async function newestVersion() {
1001
1006
  try {