worktrust 0.10.8 → 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.
- package/package.json +1 -1
- package/worktrust.mjs +7 -3
package/package.json
CHANGED
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.
|
|
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
|
-
|
|
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(
|
|
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();
|