worktrust 0.10.33 → 0.10.35
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/README.md +30 -0
- package/commit-rules.mjs +447 -0
- package/engine-release.json +1 -1
- package/git-commits.mjs +346 -0
- package/history-outbox.mjs +5 -2
- package/log-session.mjs +5 -5
- package/package-release.json +1 -1
- package/package.json +3 -1
- package/session-databases.mjs +90 -1
- package/transcript-readers.mjs +14 -0
- package/worktrust.mjs +58 -8
package/worktrust.mjs
CHANGED
|
@@ -76,7 +76,7 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
|
|
|
76
76
|
const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
|
|
77
77
|
const has = (name) => args.includes(`--${name}`);
|
|
78
78
|
/** 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). */
|
|
79
|
-
const CLI_VERSION = "0.10.
|
|
79
|
+
const CLI_VERSION = "0.10.35";
|
|
80
80
|
/**
|
|
81
81
|
* 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
|
|
82
82
|
* to offer). Raised ONLY when what is measured changes: the timeline, the seconds, the tokens, the steering, the session
|
|
@@ -90,20 +90,27 @@ const CLI_VERSION = "0.10.33";
|
|
|
90
90
|
* existing data a re-measure would repack is 4 headless lines of one person on 2 days, none scheduled, none with a person's
|
|
91
91
|
* second and none under the 60 s floor, so a re-measure would move no figure the passport shows; raising would offer every
|
|
92
92
|
* person a re-measure for nothing. New runs arrive folded from 0.10.33 on.
|
|
93
|
+
* 0.10.35 RAISES IT TO 3 (owner, 2026-10-30): a new READER, Gemini CLI's own session files, so a computer with Gemini CLI has
|
|
94
|
+
* days no earlier rules measured; and every line now names its AI app at the door (source_app, 20261031100000), which lines
|
|
95
|
+
* measured before carry only when re-measured. Raising is what earlier readers would have done had the number existed (it
|
|
96
|
+
* came with 0.10.31): `update` offers the re-measure once, its day digests change with the rules, so the re-measure sends
|
|
97
|
+
* every day again; WorkTrust replaces only the lines of the two buckets (other apps, app not recorded) that name no app
|
|
98
|
+
* (20261031100200) and carries every other line as it is: no figure moves, the Other apps hours move to their app's row.
|
|
93
99
|
*/
|
|
94
|
-
const MEASURE_RULES =
|
|
100
|
+
const MEASURE_RULES = 3;
|
|
95
101
|
/** What each measure-rules version changed, in the words the re-measure offer says (one entry per raise, never rewritten). */
|
|
96
102
|
const MEASURE_CHANGES = {
|
|
97
103
|
1: ["each answer's tokens counted once", "nothing lost at midnight", "when each stretch began", "how you steered the agent", "what the seconds were", "more AI apps", "how each session was started"],
|
|
98
104
|
2: ["which subagents were active at once, and how their failed steps were recovered", "whether each agent call completed", "who wrote each turn of a run no person started"],
|
|
105
|
+
3: ["Gemini CLI's sessions", "which AI app each earlier line came from (Copilot in VS Code, Gemini CLI and the other apps get their own rows)"],
|
|
99
106
|
};
|
|
100
107
|
const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.worktrust.io").replace(/\/$/, "");
|
|
101
108
|
const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
|
|
102
109
|
const HOME_DIR = join(homedir(), ".worktrust");
|
|
103
110
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
104
|
-
const SCRIPTS = ["credential-store.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", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.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"];
|
|
111
|
+
const SCRIPTS = ["credential-store.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", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.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", "commit-rules.mjs", "git-commits.mjs"];
|
|
105
112
|
/** The modules the scripts import by name from beside them; a download keeps that name. */
|
|
106
|
-
const IMPORTED = new Set(["transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs"]);
|
|
113
|
+
const IMPORTED = new Set(["transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "commit-rules.mjs", "git-commits.mjs"]);
|
|
107
114
|
const downloaded = (name) => (IMPORTED.has(name) ? name : `${name}.download.mjs`);
|
|
108
115
|
const BUNDLED = SCRIPTS.every((name) => existsSync(join(HERE, name)));
|
|
109
116
|
const PLACEHOLDER = `wt_${"0".repeat(43)}`;
|
|
@@ -361,7 +368,7 @@ const previousNote = {
|
|
|
361
368
|
* file; a coupling to another account starts it empty. An unreadable file counts as no agreement at all.
|
|
362
369
|
*/
|
|
363
370
|
const CONSENT_FILE = join(HOME_DIR, "consent.json");
|
|
364
|
-
const CONSENT_NAME = /^(?:door:[^\n,]{1,80}|session-hook|codex-notify|antigravity-stop)$/;
|
|
371
|
+
const CONSENT_NAME = /^(?:door:[^\n,]{1,80}|session-hook|codex-notify|antigravity-stop|git-commits)$/;
|
|
365
372
|
const CONSENT_HOW = new Set(["typed", "flag", "found"]);
|
|
366
373
|
let consentLoaded = null;
|
|
367
374
|
async function consent() {
|
|
@@ -799,7 +806,7 @@ async function offerHistory(paths, token, devicePem, url = MCP, rebuild = false,
|
|
|
799
806
|
if (!has("history") && !agreedInAdvance && !(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; }
|
|
800
807
|
// 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.
|
|
801
808
|
historyDone(false);
|
|
802
|
-
const sent = await run(paths["log-session.mjs"], ["--history", ...(rebuild ? ["--rebuild"] : []), ...(has("retry-review") ? ["--retry-review"] : [])], token, true, env);
|
|
809
|
+
const sent = await run(paths["log-session.mjs"], ["--history", ...(rebuild ? ["--rebuild"] : []), ...(rebuild && has("force-days") ? ["--force-days"] : []), ...(has("retry-review") ? ["--retry-review"] : [])], token, true, env);
|
|
803
810
|
historyDone(sent.code === 0);
|
|
804
811
|
// WHAT ACTUALLY HAPPENED, FROM THE DOOR'S RECEIPTS (owner, 2026-10-10): a re-measure in which nothing changed must not say
|
|
805
812
|
// "replaced". The hook sums the receipts of every batch and prints one line; without it (an older hook) the sentence stays neutral.
|
|
@@ -823,7 +830,8 @@ async function offerHistory(paths, token, devicePem, url = MCP, rebuild = false,
|
|
|
823
830
|
if (Number(did?.delivery?.review) > 0) say(` ${did.delivery.review} lines are waiting for review. Earlier measurements remain unchanged. Reconnecting or repeating the import does not approve them.`);
|
|
824
831
|
// KEPT ON THE SERVER (0.10.27; owner, 2026-10-21): what did not arrive stays here and goes again by itself; nothing to resume by hand.
|
|
825
832
|
if (Number(did?.delivery?.waiting) > 0) say(" Some batches did not reach WorkTrust yet. They stay on this computer and are sent again by themselves the next time npx worktrust or your AI app's hook runs.");
|
|
826
|
-
|
|
833
|
+
// 0.10.35: a re-measure refused for older measure rules is told in WorkTrust's own words (the hook passes them on, cleaned).
|
|
834
|
+
if (Number(did?.delivery?.refused) > 0) say(typeof did.delivery.said === "string" ? ` ${did.delivery.said.replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").slice(0, 400)}` : ` WorkTrust closed an earlier run of ${did.delivery.refused} lines (it missed a batch for seven days): run npx worktrust@latest history again to send them as a new run.`);
|
|
827
835
|
// A STAGED RUN (0.10.27): WorkTrust holds every batch and rebuilds the days itself once the run is whole; the receipts say what it kept.
|
|
828
836
|
if (rebuild && n(did?.staged) > 0 && !Number(did?.delivery?.review) && !Number(did?.delivery?.waiting)) {
|
|
829
837
|
say(` ✓ Re-measured. WorkTrust holds all ${n(did.staged)} batches (${n(did.kept)} lines) and rebuilds these days itself, every AI app together, a day counted once. Sources › Logs shows it while it works.`);
|
|
@@ -1319,6 +1327,41 @@ async function preserve() {
|
|
|
1319
1327
|
process.exitCode = await new Promise((resolve) => child.on("exit", (code) => resolve(code ?? 1)));
|
|
1320
1328
|
}
|
|
1321
1329
|
|
|
1330
|
+
/**
|
|
1331
|
+
* YOUR OWN COMMITS, MEASURED HERE (`npx worktrust git`, 0.10.34; option C, owner 2026-10-29; docs/GITHUB.md). git-commits.mjs
|
|
1332
|
+
* reads them with git log and makes the GitHub walk's keys of them on this computer; this file lends it the key, the signed
|
|
1333
|
+
* send to the CLI's commits door, the question (Enter is No) and the consent file. Nothing is sent without a typed yes.
|
|
1334
|
+
*/
|
|
1335
|
+
function archiveSalt() {
|
|
1336
|
+
const file = join(HOME_DIR, "archive-salt");
|
|
1337
|
+
try { const kept = readPrivateFile(file)?.trim(); if (/^[0-9a-f]{64}$/.test(kept ?? "")) return kept; } catch { /* first run */ }
|
|
1338
|
+
try { ensureHome(); const made = randomBytes(32).toString("hex"); writePrivateFile(file, `${made}\n`); return made; } catch { return null; }
|
|
1339
|
+
}
|
|
1340
|
+
async function gitCommits() {
|
|
1341
|
+
if (!["git-commits.mjs", "commit-rules.mjs"].every((name) => existsSync(join(HERE, name)))) fail("worktrust git needs the complete WorkTrust npm/Python package. Nothing was read or sent.");
|
|
1342
|
+
const { gitMain } = await import("./git-commits.mjs");
|
|
1343
|
+
const sub = args.slice(args.indexOf("git") + 1).filter((arg) => !arg.startsWith("--"));
|
|
1344
|
+
const local = ["list", "emails", "remove"].includes(sub[0]) || has("dry-run");
|
|
1345
|
+
const key = local ? keyStore.load() : await freshKey();
|
|
1346
|
+
if (!key && !local) fail("this computer is not coupled. Run `npx worktrust` first.");
|
|
1347
|
+
const url = key ? `${new URL(key.url).origin}/api/cli/commits` : null;
|
|
1348
|
+
const send = async (body) => {
|
|
1349
|
+
if (!key || !url) return null;
|
|
1350
|
+
const text = JSON.stringify({ ...body, cli_version: CLI_VERSION });
|
|
1351
|
+
try {
|
|
1352
|
+
const response = await fetch(url, { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${key.token}`, "user-agent": `worktrust-cli/${CLI_VERSION}`, ...proof(key.device, url, text) }, body: text, redirect: "error", signal: AbortSignal.timeout(30_000) });
|
|
1353
|
+
if (response.status === 200) return await response.json();
|
|
1354
|
+
// A fair-use refusal (0.10.34, docs/FAIR-USE.md §2): its own sentence, said as it is; the commits stay for the next run.
|
|
1355
|
+
if (response.status === 429 || response.status === 503) {
|
|
1356
|
+
const refusal = await response.json().catch(() => null);
|
|
1357
|
+
if (typeof refusal?.message === "string") return { refused: { message: refusal.message.slice(0, 400), retryAfter: Number(response.headers.get("retry-after")) || null } };
|
|
1358
|
+
}
|
|
1359
|
+
return null;
|
|
1360
|
+
} catch { return null; }
|
|
1361
|
+
};
|
|
1362
|
+
process.exitCode = await gitMain(sub, { say, ask, send, consent: await consent(), salt: archiveSalt(), dryRun: has("dry-run") });
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1322
1365
|
function help() {
|
|
1323
1366
|
say("WorkTrust: couple this computer to your record. Metadata only.");
|
|
1324
1367
|
say();
|
|
@@ -1341,6 +1384,8 @@ function help() {
|
|
|
1341
1384
|
say(" --retry-review explicitly retry held batches after support resolves their review");
|
|
1342
1385
|
say(" --rebuild re-measure them with the current rules; WorkTrust replaces this computer's earlier lines,");
|
|
1343
1386
|
say(" day by day, never counting a day twice (shows the plan per AI app, asks first; --dry-run: the plan only)");
|
|
1387
|
+
say(" --force-days with --rebuild: send every day again, also the days WorkTrust holds unchanged, so lines");
|
|
1388
|
+
say(" measured before an app was named per line get their app (every AI app at once)");
|
|
1344
1389
|
say(" --from-archive [dir] send what your archive (preserve --archive) holds of sessions your AI apps already deleted,");
|
|
1345
1390
|
say(" marked as from your archive: a day this computer's key signed as measured, every other day");
|
|
1346
1391
|
say(" as reconstructed, never verified hours (shows the plan, asks first)");
|
|
@@ -1357,6 +1402,10 @@ function help() {
|
|
|
1357
1402
|
say(" worktrust mod the WorkTrust mod for Claude Code: what it counts, and whether it is on");
|
|
1358
1403
|
say(" install turn it on: counts permission answers, effort levels, context peaks and subagents (asks first)");
|
|
1359
1404
|
say(" remove turn it off and delete what it counted");
|
|
1405
|
+
say(" worktrust git send your own commits, measured on this computer: counts and kinds, never a file name,");
|
|
1406
|
+
say(" a message, code or the commit's id (asks once, with the list of repositories; Enter is No)");
|
|
1407
|
+
say(" add <folder> offer one more repository remove <folder> read nothing more from it");
|
|
1408
|
+
say(" list what is offered and agreed emails add <e-mail> another author e-mail of yours");
|
|
1360
1409
|
say(" worktrust preserve keep your AI history: the report, then the settings and a local archive, each on your yes");
|
|
1361
1410
|
say(" --apply keep them: asks per change, backs the file up first (--yes: no question)");
|
|
1362
1411
|
say(" --archive [dir] a local, metadata-only, hash-chained record of the measured days (~/AI-Evidence)");
|
|
@@ -1374,7 +1423,7 @@ async function main() {
|
|
|
1374
1423
|
if (!moduleArgs || !moduleExecutable || !createCredentialStore) fail("Use the complete WorkTrust package from npm/PyPI or the signed preservation kit; individual scripts cannot run.");
|
|
1375
1424
|
if (Number(process.versions.node.split(".")[0]) < 18) fail("needs Node 18 or later (fetch is built in from 18).");
|
|
1376
1425
|
const AGENT_ENV = ["CLAUDECODE", "CLAUDE_CODE_ENTRYPOINT", "CODEX_SANDBOX", "CODEX_CI", "GEMINI_CLI", "CURSOR_AGENT", "OPENCODE", "CLINE_ACTIVE", "AIDER_CHAT", "ANTIGRAVITY_AGENT", "WINDSURF_AGENT"];
|
|
1377
|
-
const PERSON_ONLY = new Set(["default", "connect", "update", "history", "disconnect", "preserve", "codex", "antigravity", "sources", "web", "import", "orchestration", "mod", "protect-key"]);
|
|
1426
|
+
const PERSON_ONLY = new Set(["default", "connect", "update", "history", "disconnect", "preserve", "codex", "antigravity", "sources", "web", "import", "orchestration", "mod", "protect-key", "git"]);
|
|
1378
1427
|
const agentShell = AGENT_ENV.find((name) => process.env[name] && process.env[name] !== "0");
|
|
1379
1428
|
if (agentShell && PERSON_ONLY.has(command)) {
|
|
1380
1429
|
say();
|
|
@@ -1431,6 +1480,7 @@ else if (command === "disconnect") await disconnect();
|
|
|
1431
1480
|
else if (command === "status") await status();
|
|
1432
1481
|
else if (command === "preserve") await preserve();
|
|
1433
1482
|
else if (command === "mod") await mod();
|
|
1483
|
+
else if (command === "git") await gitCommits();
|
|
1434
1484
|
else if (command === "orchestration") {
|
|
1435
1485
|
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.");
|
|
1436
1486
|
const { reportFile } = await import("./orchestration-report.mjs"); reportFile(args.slice(1));
|