worktrust 0.11.2 → 0.11.4
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 +31 -0
- package/count-behaviour.mjs +14 -8
- package/engine-release.json +1 -1
- package/git-commits.mjs +9 -6
- package/log-session.mjs +15 -15
- package/package-release.json +1 -1
- package/package.json +8 -2
- package/project-modes.mjs +184 -0
- package/remote-adapter-opencode.mjs +175 -0
- package/remote-agent-switch.mjs +33 -0
- package/remote-cli.mjs +12 -17
- package/remote-inventory.mjs +8 -4
- package/remote-opencode-events.mjs +90 -0
- package/remote-opencode-session.mjs +24 -0
- package/remote-sessions.mjs +13 -6
- package/remote-steered.mjs +7 -1
- package/remote-store.mjs +1 -1
- package/session-databases.mjs +6 -7
- package/session-local-models.mjs +165 -0
- package/worktrust.mjs +26 -7
package/README.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# worktrust
|
|
2
2
|
|
|
3
|
+
## 0.11.4: local models measured, confidential client work, OpenCode in MOCHI
|
|
4
|
+
|
|
5
|
+
**Local models, used directly.** The Ollama app's chats and Open WebUI's are now read like every other database client:
|
|
6
|
+
the model, the time of each turn and, for Open WebUI, the token counts it kept (the Ollama app keeps none, so none are
|
|
7
|
+
sent or estimated). Never a title, a message, a file or a prompt. A model used through OpenCode, Goose, Hermes or OpenClaw
|
|
8
|
+
was already measured with that client. Because these are days no earlier version measured, the measure rules become 4:
|
|
9
|
+
`npx worktrust update` on a computer measured by rules 3 offers the re-measure once and says why.
|
|
10
|
+
|
|
11
|
+
**Confidential client work.** `npx worktrust project confidential [folder]` marks a client's repository: its hours and
|
|
12
|
+
token counts still count, under one fixed marker, and no repository name, branch, remote, path, commit or app title
|
|
13
|
+
leaves the computer. Your passport names that share inside your verified hours as "Confidential client work".
|
|
14
|
+
`npx worktrust project exclude [folder]` leaves a folder out entirely, `project normal` undoes either, and `project list`
|
|
15
|
+
shows what you set. Only you change these at your keyboard; an agent's shell may only list them.
|
|
16
|
+
|
|
17
|
+
**OpenCode in MOCHI.** Your phone can steer OpenCode on this computer, and through it a local model such as Qwen on
|
|
18
|
+
Ollama. Like Codex it is off by default: `npx worktrust remote opencode on` says what OpenCode can do without asking and
|
|
19
|
+
asks for a typed yes; `off` switches it off again. Its runs ask your phone before every command, edit and fetch, and a
|
|
20
|
+
remote-steered session never counts as your hours.
|
|
21
|
+
|
|
22
|
+
**The import window.** An AI app on this computer is shown the `import_history` tool only in the hour after you copy the
|
|
23
|
+
import prompt in Sources on app.worktrust.io, so it no longer costs every session the tool's description.
|
|
24
|
+
`npx worktrust history` is unchanged.
|
|
25
|
+
|
|
26
|
+
## 0.11.3: every device off this computer at once
|
|
27
|
+
|
|
28
|
+
`npx worktrust remote phones remove --all` disconnects every phone and browser from this computer in one act, after one
|
|
29
|
+
confirmation at the keyboard. The computer refuses them from their next message. Sessions they started keep running here:
|
|
30
|
+
stop them with `npx worktrust remote disable`, or pause everything with `npx worktrust remote pause`. To end their keys for
|
|
31
|
+
your whole account too, use Settings › MOCHI on app.worktrust.io or MOCHI settings on your phone. What is measured for the
|
|
32
|
+
passport is unchanged: remote-steered sessions never count as your hours, and the measure rules stay 3.
|
|
33
|
+
|
|
3
34
|
## 0.11.2: your phone adds a browser
|
|
4
35
|
|
|
5
36
|
A browser where you use app.worktrust.io can steer this computer's agents without a walk to its keyboard: the browser
|
package/count-behaviour.mjs
CHANGED
|
@@ -36,6 +36,7 @@ import { execFileSync } from "node:child_process";
|
|
|
36
36
|
import { readFileSync, readdirSync, statSync, writeFileSync, mkdirSync, renameSync, openSync, closeSync, unlinkSync, readSync } from "node:fs";
|
|
37
37
|
import { join, dirname } from "node:path";
|
|
38
38
|
import { homedir } from "node:os";
|
|
39
|
+
import { readProjectModes, projectModeOf, strictestMode } from "./project-modes.mjs"; // 2026-11-09: exclude and confidential
|
|
39
40
|
|
|
40
41
|
/** DEVICE PROOF (2026-10-03): through `worktrust hook` a bound computer hands over WORKTRUST_DEVICE_KEY; every call is then signed. */
|
|
41
42
|
const proofFor = (url, body) => {
|
|
@@ -436,6 +437,9 @@ const DRY = !SEND && !STAGE;
|
|
|
436
437
|
|
|
437
438
|
const EXCLUDE = [];
|
|
438
439
|
const LEAVE_OUT = [];
|
|
440
|
+
// THE PROJECT MODES (project-modes.mjs): a confidential project is counted under the one context every confidential project
|
|
441
|
+
// shares, with no name digest beside it, and its commits are not read.
|
|
442
|
+
const PROJECT_MODES = { exclude: [], confidential: [] };
|
|
439
443
|
for (let i = 0; i < args.length; i += 1) if (args[i] === "--exclude" && args[i + 1]) EXCLUDE.push(args[i + 1].toLowerCase());
|
|
440
444
|
/**
|
|
441
445
|
* A claude.ai DATA EXPORT (Settings → Privacy → Export data) read beside the transcripts:
|
|
@@ -457,15 +461,15 @@ for (let i = 0; i < args.length; i += 1) if (args[i] === "--claude-export" && ar
|
|
|
457
461
|
const CHATGPT_EXPORTS = [];
|
|
458
462
|
for (let i = 0; i < args.length; i += 1) if (args[i] === "--chatgpt-export" && args[i + 1]) CHATGPT_EXPORTS.push(args[i + 1]);
|
|
459
463
|
try {
|
|
460
|
-
const config =
|
|
461
|
-
|
|
464
|
+
const config = readProjectModes();
|
|
465
|
+
PROJECT_MODES.exclude = config.exclude; PROJECT_MODES.confidential = config.confidential;
|
|
462
466
|
// GUARDRAILS (2026-09-27): `leaveOut` names WORDS a turn must not carry (a client, a project, a
|
|
463
467
|
// person, a subject); a turn carrying one is a filter miss, like the built-in categories below.
|
|
464
468
|
// The app writes this file from the person's own list; the words never leave this machine.
|
|
465
469
|
for (const entry of Array.isArray(config.leaveOut) ? config.leaveOut : []) { const word = String(entry).trim(); if (word) LEAVE_OUT.push(word); }
|
|
466
470
|
} catch { /* no config file is the common case */ }
|
|
467
471
|
const LEAVE_OUT_RE = LEAVE_OUT.length ? new RegExp(`(^|[^\\p{L}\\p{N}])(${LEAVE_OUT.map((word) => word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})(?![\\p{L}\\p{N}])`, "iu") : null;
|
|
468
|
-
const excluded = (dir) => EXCLUDE.some((needle) => dir.toLowerCase().includes(needle));
|
|
472
|
+
const excluded = (dir) => EXCLUDE.some((needle) => dir.toLowerCase().includes(needle)) || projectModeOf(dir, PROJECT_MODES) === "exclude";
|
|
469
473
|
/**
|
|
470
474
|
* v0.8 harness. `--classify` reads JSON lines `{"text": …, "second": …}` from stdin and prints the
|
|
471
475
|
* form, the act kind and the second-turn type per line — the test suite's door, and a way to see
|
|
@@ -796,6 +800,7 @@ const unitsByMonth = new Map(); // month → Map("unit|signal" → { unit, signa
|
|
|
796
800
|
*/
|
|
797
801
|
const contextOf = (projectDir) => createHash("sha256").update(`context:${projectDir}`).digest("hex").slice(0, 16);
|
|
798
802
|
let currentContext = null; // the project the next bump belongs to
|
|
803
|
+
const CONFIDENTIAL_CONTEXT = contextOf("worktrust-confidential"); let currentConfidential = false; // one context for every confidential project
|
|
799
804
|
const contextNames = new Map(); // digest → directory key, printed locally, NEVER sent
|
|
800
805
|
const contextBasenames = new Map(); // digest → the transcript's own cwd basename, the project's real name — local only
|
|
801
806
|
const byMonthContext = new Map(); // month → Map("signal|context" → count)
|
|
@@ -916,9 +921,10 @@ for await (const session of sessions()) {
|
|
|
916
921
|
const pendingTests = new Map(); // tool_use id → the run's unit, day and month
|
|
917
922
|
const testQueue = []; // runs without an id (a replayed store), matched to the next result in order
|
|
918
923
|
const projectDir = session.projectDir;
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
if (
|
|
924
|
+
currentConfidential = strictestMode([projectDir, session.basename, session.cwd], PROJECT_MODES) === "confidential";
|
|
925
|
+
currentContext = currentConfidential ? CONFIDENTIAL_CONTEXT : projectDir ? contextOf(projectDir) : null;
|
|
926
|
+
if (projectDir && !currentConfidential && !contextNames.has(currentContext)) contextNames.set(currentContext, projectDir);
|
|
927
|
+
if (session.basename && currentContext && !currentConfidential && !contextBasenames.has(currentContext)) contextBasenames.set(currentContext, session.basename);
|
|
922
928
|
const sessionUnit = unitOf(file);
|
|
923
929
|
let lineNo = 0;
|
|
924
930
|
// Streamed either way; a Codex rollout's stream is shaped into transcript lines as it passes.
|
|
@@ -939,8 +945,8 @@ for await (const session of sessions()) {
|
|
|
939
945
|
// The transcript names its own working directory; its last segment is the project's real
|
|
940
946
|
// name ("davosnl.com", "dlg-platform") — the directory key above encodes "/" and "." alike
|
|
941
947
|
// as "-", so it cannot say where a name starts. Kept locally, digested for the slug.
|
|
942
|
-
if (currentContext && line.cwd && !contextBasenames.has(currentContext)) { const base = String(line.cwd).split("/").filter(Boolean).at(-1); if (base) contextBasenames.set(currentContext, base); }
|
|
943
|
-
if (currentContext && line.cwd && !contextCwds.has(currentContext)) contextCwds.set(currentContext, String(line.cwd));
|
|
948
|
+
if (currentContext && !currentConfidential && line.cwd && !contextBasenames.has(currentContext)) { const base = String(line.cwd).split("/").filter(Boolean).at(-1); if (base) contextBasenames.set(currentContext, base); }
|
|
949
|
+
if (currentContext && !currentConfidential && line.cwd && !contextCwds.has(currentContext)) contextCwds.set(currentContext, String(line.cwd));
|
|
944
950
|
currentDay = line.timestamp ? String(line.timestamp).slice(0, 10) : null;
|
|
945
951
|
const month = line.timestamp ? String(line.timestamp).slice(0, 7) : null;
|
|
946
952
|
// ── structural half ──
|
package/engine-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"06b0ecbc222087160dc64c0b302391631e8e799038364c317c6cd28449c5044d","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","export-facts.mjs":"3bbb46c80e8678b5cea7e15dcbfc456a2b48595053241c2b3cea508092f9b917","git-commits.mjs":"af0ed45a2a42c8e17cabfb3649a2f524dbf80230f8a6ec1c6b775fed7d34dc9c","history-outbox.mjs":"85c70389effc5b4ec9d9b33af9192314e67f47af2752515b42a7959344ce2354","history-progress.mjs":"dcc25ee94b727f2605a763349a4d8764640335d6cf0043fb6108cebeed16dcb9","log-session.mjs":"167fe3718415fe690c9e4f7a3a993520e8c652edcf61184cc14cfec2db67d7bc","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"cd111cae0f53a25a2d878a158479abfb1ace353361454843f91a16d241101d46","project-modes.mjs":"ada26e68297fbeb90e4e91d75a90fd2d7cc107b999a9702840675b5a7529463e","remote-adapter-claude-code.mjs":"a5ef08186128d9fe4023944378bb0ff5682a8ae64ffdb07ef5e76cc51894d721","remote-adapter-codex.mjs":"d2fd6c61d9e3c4a45e9b10da1aa3c15d45c86629d6456e4a8d25ad95b13eb209","remote-adapter-opencode.mjs":"ab3ccc5e958ef17ceda595853e40a4521f5452f8d54e8fbf269299a397760a63","remote-adapter-terminal.mjs":"9237d3747a25126fcdad42c0eab10e69393754388a6014b30fb0890b9c735888","remote-agent-switch.mjs":"7ff5448f29f05a47d7298d730b21243a1bcf8a215b434a0c7fbf5f3cb0889041","remote-approval-bridge.mjs":"092f17b7969e4f35bea064315d04dcde1faa6a3fd3e737dcc05aece82c7a37c4","remote-approvals.mjs":"5a371e049ceb154100a3b0c1900d8a2c1fc193b01e8069f11ce1690bcf4df3e1","remote-attachments.mjs":"2e9c1277329a45cf26c0c62abda632cf0ab9fad78d0504416ecee9805220e16c","remote-cdp.mjs":"70e333a1ebe845e872cc3a703a0a507391f8ce59640bdbd662bdad55eeff216b","remote-changes.mjs":"2141fece4961a5bc1bb1b046f78222812617457b1ba6452275eac6a897e62e19","remote-claude-events.mjs":"58822471203c6a1b66cf81c115c4d713657c3dea5c7b98df959f894ee5b2e704","remote-claude-progress.mjs":"2ca626d3dbc16d8d570abe1df6477b7e44ffb43c1d9145228ec5ea1928e415ca","remote-cli.mjs":"bf2e1577b141e4dfe1fdb22d7a4fb6127dadc85c74796ce3b108455f75093b8b","remote-coalesce.mjs":"cb0967d9cfe81e3892bcade8349d6814db98be8c2adbdb54df0b8d1b142f65d1","remote-codex-events.mjs":"58657d6070a50c837737cb85f5a1eaf9c2cbc4e1adfe3e970748ab3b2af94631","remote-daemon.mjs":"5dadcced9bd2c69be8c48afbaabbf50bd16879612ada0553aa2284a873907492","remote-endorse.mjs":"89eda4883567176703e01e44d83e987271bc2a6134e108f517b3b213719a21f9","remote-inventory.mjs":"43954e427141b4303ca13d22068d50bfc81e544b085bce335b8e8d59dc520468","remote-journal.mjs":"907ebd48c53162b22dc743ef95b53c1a6be6886a7495605b5cfa820b8de9d330","remote-live-preview.mjs":"faa70f9260ac05037204c2a0c3facf4ffe42f68408948390b341b453a2932289","remote-opencode-events.mjs":"8ee6b070f4c4787e10305f105b925e6b5f95bff99c1e1f44577aeca0ef8c347e","remote-opencode-session.mjs":"681b201d833a7d7d025122b3a79663bcdc0a989aefd39d8018a28113d8810caf","remote-pairing.mjs":"ae03427b6510e52da08aaf9387d5e08516ee25380c7efa420432f4e1e936a7c5","remote-pipeline-config.mjs":"00cde6a61ce21144c51ac56fce42fee159aa9dba6586218a7ea790ce4a6bd40b","remote-pipeline-parsers.mjs":"43ca0d332d7bc883c4759a754a555815ae5dfe133446b91ba9f2e48a350fa20f","remote-pipeline.mjs":"b856ead989b29ddb618ef69bbacd104bae2b02c9d1c5214291d08ce469a8b24e","remote-policy.mjs":"aacf7578537021ab3849095bb1f58f0ed12c453c6ca2ab1352a1716fb13b0ca4","remote-preview.mjs":"fe504ad6f83dcb4a4ebdcc018686a9a5a900c47cdf8c45b75e7d02e2f3056155","remote-projects.mjs":"d07997167d1f51139ff010c8753639e48c5cd33688568459e184eabb12bfff84","remote-protocol.mjs":"7b2a78e585983be40e240b9ab0b2e31a69e586bd72292071886c60b217d97a60","remote-qr.mjs":"b80e2b4a5bc020cf6ed92e91d06b327cb5197de1c35b3445a0fc2c7a3bf1ab3f","remote-release-plans.mjs":"11884a62b7d6dcccb5e154a26603bdf650f7b40f946329fb174d8c13729bec74","remote-releases.mjs":"fb08b72593ea00013c8b679e0c0d7dee95b0fd7cc5fd31b80ac575d0e340927d","remote-run.mjs":"c72c77fdd14115e66f1f2be383ca4f1363a4cecc9dced9cc48cbb3e4bb44bc66","remote-screen-approvals.mjs":"c43ab286d36a38d17639d155782ffa017f1a9b6806a09b82ed0142a1290b6000","remote-screen-push.mjs":"4ee8bd48d24b2c87581e9f33d8354a86381f7febd82f89ed509a7a87c1442608","remote-screen-states.mjs":"7c3c86a584bebf52461f3cab39c05ea2a13910061704d48fc622956e842940f7","remote-service.mjs":"1b9d4ecf99b667f2ab7c78fe1dfd5cf507cbb36c5bcad15bfa2a88c313ae758e","remote-session-list.mjs":"494fdbe20f0542806ac6c42ad149c52e2d3ace23a3a7567f96dc7e80d092c727","remote-sessions.mjs":"64ae363f8b5f38c58c21afbeaa7951d9592c608c3c83cceb78b21700a64467e9","remote-steered.mjs":"d7afde92c62c87abbdb84b0cfea2eea4752e90a2e453e52a54812c4fe0395190","remote-steering.mjs":"7ba22e6110cea3ac75a4f084f8f92a5bd90c31a19d3ce58a88a0843bdadea834","remote-store.mjs":"51645f8355923fe51de00233477266a99e94d4ca1f98f797f96e4ebb15927e9a","remote-terminal-cli.mjs":"82a048b75e412d0b6db076afbb84cab7c754dec72b6c8b6af4d4906b38e988a7","remote-terminal-sessions.mjs":"6ab51824890a18768d23cedc499f3840b2b02a8ed651463c1fe2d74dd352a361","remote-transport.mjs":"68650fd77ea09b5762377f87cabdc1c73a34d77324aa5bf0cd9742094a50c32b","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","self-update.mjs":"378e3620d48c72cf0bf812be408883b995cdb2223de34a20f762dd73eeffb258","session-databases.mjs":"a16ffbc50ccc0e78f370ebe07f871d1a80f1977472e478e3599e7abfdc90c1b7","session-local-models.mjs":"bacd38ff8dd3056b552982ec52eb57c7b8ca86e1a46cd4cba30fc340e3e28fd4","setup-mcp.mjs":"b732e3dd9b3e522b7cc8acf167ce28ba8f1a8dee797ee15bd7c3b02919b13e6f","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"e9f20415c2b5d62a09f35a63075002ebd1da56edb32f242d52822d58ecbd8ac3","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"6c065d9bed11f3d0f2085c6214eac5e3296becdd3298bacd7af8db0939fa9b79"},"format":"worktrust-package/1","kind":"engine","version":"0.11.4"},"signature":"xt_RIIivuO-GekPF0Pcj2uuO3p5RN1-TKk2291FJIRIP1w2fQLqF7f24PQccKncu0f3eLUTO1SBTBksaV3LfCA"}
|
package/git-commits.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import { closeSync, existsSync, openSync, readFileSync, readSync, readdirSync, r
|
|
|
17
17
|
import { homedir } from "node:os";
|
|
18
18
|
import { join, resolve } from "node:path";
|
|
19
19
|
import * as rules from "./commit-rules.mjs";
|
|
20
|
+
import { readProjectModes, projectModeOf } from "./project-modes.mjs";
|
|
20
21
|
|
|
21
22
|
/** The walker's id primitive (apps/worktrust/app/src/lib/scoring/ids.ts), byte for byte. */
|
|
22
23
|
export function uuidFrom(...parts) {
|
|
@@ -204,10 +205,12 @@ export function transcriptCwds(home = homedir(), limit = LIMITS.transcripts) {
|
|
|
204
205
|
return [...cwds];
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
/**
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
/**
|
|
209
|
+
* The person's project modes (project-modes.mjs, `worktrust project`): an EXCLUDED folder is never read, and a CONFIDENTIAL one is
|
|
210
|
+
* not read here either (2026-11-09): a commit is not an hour, and its repository's label and references are what the mode keeps
|
|
211
|
+
* on this computer. Both apply to a folder the sessions named and to one the person added.
|
|
212
|
+
*/
|
|
213
|
+
const keptOut = (dir, home) => projectModeOf(dir, readProjectModes(home)) !== "normal";
|
|
211
214
|
|
|
212
215
|
// ── this computer's answers ──
|
|
213
216
|
export function stateFile(home = homedir()) { return join(home, ".worktrust", "git.json"); }
|
|
@@ -224,9 +227,9 @@ export function saveState(state, home = homedir()) {
|
|
|
224
227
|
/** The work trees to offer: the folders the sessions named, plus the ones the person added; none they removed. */
|
|
225
228
|
export function discoverRepos(state, home = homedir()) {
|
|
226
229
|
const roots = new Set();
|
|
227
|
-
for (const cwd of transcriptCwds(home)) { if (
|
|
230
|
+
for (const cwd of transcriptCwds(home)) { if (keptOut(cwd, home)) continue; const root = repoRootOf(cwd); if (root) roots.add(root); }
|
|
228
231
|
for (const [root, entry] of Object.entries(state.repos)) if (entry?.how === "typed" && existsSync(root)) roots.add(root);
|
|
229
|
-
return [...roots].sort();
|
|
232
|
+
return [...roots].filter((root) => !keptOut(root, home)).sort();
|
|
230
233
|
}
|
|
231
234
|
|
|
232
235
|
/** What each of the three ways in reads: the table the consent shows (and the Sources card, in the app's words). */
|
package/log-session.mjs
CHANGED
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
* (input plus cache creation, cache reads excluded), which the door calls `newInput`. The figures the terminal shows come
|
|
57
57
|
* from WorkTrust's receipts.
|
|
58
58
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
59
|
+
* EXCLUDED PROJECTS never open, CONFIDENTIAL ones send hours and tokens under one fixed marker, never a name, code, path or
|
|
60
|
+
* commit (`worktrust project exclude|confidential [folder]`, project-modes.mjs, docs/CONFIDENTIAL-WORK.md).
|
|
61
61
|
*/
|
|
62
62
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
63
63
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync, lstatSync, openSync, closeSync, fsyncSync, fstatSync, linkSync, unlinkSync, readSync, constants } from "node:fs";
|
|
@@ -66,7 +66,7 @@ import { dirname, join, resolve, sep } from "node:path";
|
|
|
66
66
|
import { fileURLToPath } from "node:url";
|
|
67
67
|
import { createHash, createHmac, createPrivateKey, createPublicKey, randomBytes, sign as cryptoSign } from "node:crypto";
|
|
68
68
|
|
|
69
|
-
import { moduleArgs, moduleExecutable, readPrivateFile, createPrivateFile } from "./package-integrity.mjs"; import { remoteSteeredOf } from "./remote-steered.mjs"; // 2026-11-07: a day steered from a phone is measured headless, steered_from "remote", never the person's hours (owner decision 1)
|
|
69
|
+
import { readProjectModes, projectModeOf, confidentialPayload, CONFIDENTIAL_REPO_CODE } from "./project-modes.mjs"; import { moduleArgs, moduleExecutable, readPrivateFile, createPrivateFile } from "./package-integrity.mjs"; import { remoteSteeredOf } from "./remote-steered.mjs"; // 2026-11-07: a day steered from a phone is measured headless, steered_from "remote", never the person's hours (owner decision 1)
|
|
70
70
|
|
|
71
71
|
async function main() {
|
|
72
72
|
const args = process.argv.slice(2), NODE_FLAGS = process.versions.node === "26.5.0" ? ["--no-concurrent-sparkplug"] : [];
|
|
@@ -221,10 +221,8 @@ function coupling() {
|
|
|
221
221
|
return codexCoupling();
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
})();
|
|
227
|
-
const excluded = (path) => excludes.some((text) => text && path.includes(text));
|
|
224
|
+
const PROJECT_MODES = readProjectModes();
|
|
225
|
+
const excluded = (path) => projectModeOf(path, PROJECT_MODES) === "exclude";
|
|
228
226
|
/**
|
|
229
227
|
* THE READERS live beside this file: Codex and Antigravity in transcript-readers.mjs (the counter imports it too, one
|
|
230
228
|
* reader), the database clients in session-databases.mjs. The install copies both into ~/.worktrust with this hook.
|
|
@@ -234,7 +232,7 @@ const { CODEX_ROLLOUT = /(?!)/, codexIdOf = (file) => String(file).split(/[\\/]/
|
|
|
234
232
|
// THE STRETCH'S DERIVED RECORD (0.7.4: split from this file): tool calls named by kind, verification, recovery, delegation,
|
|
235
233
|
// context and routing, for the local archive only. A copy without the module still measures and sends exactly as before.
|
|
236
234
|
const { callOf = (block) => ({ id: block.id, kinds: [], family: String(block.name), digest: "" }), deriveStretch = () => ({}), complexityOf = null, recoveryOf = null, resultOf = (block) => ({ id: block.tool_use_id, failed: block.is_error === true, refusal: null }) } = (await import("./stretch-evidence.mjs").catch(() => null)) ?? {};
|
|
237
|
-
const { DATABASE_SESSION = /(?!)/, databaseLines = () => null, databaseSessions = function* () {} } = (await import("./session-databases.mjs").catch(() => null)) ?? {};
|
|
235
|
+
const { DATABASE_SESSION = /(?!)/, databaseLines = () => null, databaseSessions = function* () {}, databaseStores = () => [] } = (await import("./session-databases.mjs").catch(() => null)) ?? {};
|
|
238
236
|
// A WEB CHAT'S DATA EXPORT AS HISTORY (0.10.10, owner 2026-10-10): chat-exports.mjs reads a ChatGPT or Claude export (the counter
|
|
239
237
|
// imports the same reader); `--history --export <path>` sends its conversations as RECONSTRUCTED days, never measured, never tokens.
|
|
240
238
|
const { EXPORT_CLIENTS = [], EXPORT_TITLES = {}, exportSessions = null, exportRef = null, exportRunRef = null, findExports = null } = (await import("./chat-exports.mjs").catch(() => null)) ?? {};
|
|
@@ -242,9 +240,9 @@ const { modCounts = () => null } = (await import("./claude-mod.mjs").catch(() =>
|
|
|
242
240
|
const liveOf = (file, day) => modCounts(String(file).split(/[\\/]/).pop().replace(/\.jsonl$/, ""), day) ?? codexLive(file, day); // 0.10.16: a Codex rollout's own
|
|
243
241
|
const { stackOfFiles = () => [], displayStackOfFiles = () => [] } = (await import("./stack-rules.mjs").catch(() => null)) ?? {}; // 0.10.11: core's stack rules and the display-only keys (tools_seen), generated (build-stack-rules --check); absent → nothing named, never a guess
|
|
244
242
|
const EXPORT_PATHS = []; for (let i = 0; i < args.length; i += 1) if (args[i] === "--export" && args[i + 1]) EXPORT_PATHS.push(args[i + 1]);
|
|
245
|
-
const DATABASE_CLIENTS = ["hermes", "goose", "opencode", "openclaw", "cursor", "copilot", "gemini-cli"]; // the registry's keys, the name each line carries (0.10.35: Gemini CLI)
|
|
243
|
+
const DATABASE_CLIENTS = ["hermes", "goose", "opencode", "openclaw", "cursor", "copilot", "gemini-cli", "ollama", "open-webui"]; // the registry's keys, the name each line carries (0.10.35: Gemini CLI; 2026-11-09: the Ollama app, Open WebUI)
|
|
246
244
|
const LIVE_SOURCE = new RegExp(`^(codex|antigravity|${DATABASE_CLIENTS.join("|")}):`); // a sweep entry's id → the client it names (every database client, 0.6.16)
|
|
247
|
-
const READER_FILES = ["history-outbox.mjs", "transcript-readers.mjs", "session-databases.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "claude-mod.mjs", "remote-steered.mjs"]; // 0.7.4: the derived record travels with the hook; 0.10.10: the export reader; 0.10.11: the stack rules; 0.10.15: the mod
|
|
245
|
+
const READER_FILES = ["project-modes.mjs", "history-outbox.mjs", "transcript-readers.mjs", "session-databases.mjs", "session-local-models.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "claude-mod.mjs", "remote-steered.mjs"]; // 0.7.4: the derived record travels with the hook; 0.10.10: the export reader; 0.10.11: the stack rules; 0.10.15: the mod
|
|
248
246
|
/** The roots this machine's transcripts live under; a test names its own. */
|
|
249
247
|
const claudeRoot = () => value("transcript-root") ?? join(homedir(), ".claude", "projects");
|
|
250
248
|
const codexRoot = () => { const given = value("codex-root"); if (given) return given.replace(/^~(?=\/|$)/, homedir()); return value("transcript-root") ? null : join(homedir(), ".codex", "sessions"); };
|
|
@@ -851,8 +849,9 @@ const STEERED_HERE = process.env.SSH_CONNECTION || process.env.SSH_CLIENT || pro
|
|
|
851
849
|
/** The one payload shape this script can build. Every key is a number, a date or an enum value. */
|
|
852
850
|
function payloadFor(stretch) {
|
|
853
851
|
const cwd = stretch.cwd && existsSync(stretch.cwd) ? stretch.cwd : null;
|
|
854
|
-
const
|
|
855
|
-
const
|
|
852
|
+
const confidential = projectModeOf(stretch.cwd, PROJECT_MODES) === "confidential"; // 2026-11-09: no name, no code, no commit; the marker below
|
|
853
|
+
const repo = cwd && !confidential ? repoOf(cwd) : null;
|
|
854
|
+
const repoCode = cwd && !repo && !confidential ? repoCodeOf(cwd) : null; // a code, never a name, for a repository it may not name
|
|
856
855
|
const touched = cwd ? pathsTouched(cwd, new Date(stretch.from).toISOString(), new Date(stretch.to).toISOString()) : { paths: [], committed: false, shas: [] };
|
|
857
856
|
const { layer, layers } = layersOf(touched.paths), stack = stackOfFiles(touched.paths), toolsSeen = displayStackOfFiles(touched.paths); // 0.10.11: the stack and the tools seen, from the same paths, keys only, two fields
|
|
858
857
|
// The seventh kind, used as it is defined: a stretch that changed no artefact is knowing
|
|
@@ -910,7 +909,8 @@ function payloadFor(stretch) {
|
|
|
910
909
|
// WHAT STAYS ON THIS COMPUTER (0.7.1): the stretch's derived record rides beside the payload for the local archive, never in it.
|
|
911
910
|
// The same record rides beside the payload for the local archive (preserve --archive).
|
|
912
911
|
if (evidence) DERIVED.set(payload, evidence);
|
|
913
|
-
|
|
912
|
+
const sealed = confidential ? confidentialPayload(payload) : payload; if (evidence) DERIVED.set(sealed, evidence);
|
|
913
|
+
return sealed;
|
|
914
914
|
}
|
|
915
915
|
|
|
916
916
|
/**
|
|
@@ -1659,7 +1659,7 @@ if (flag("evidence-summary")) {
|
|
|
1659
1659
|
process.stdout.write(`${JSON.stringify(summary)}\n`);
|
|
1660
1660
|
return await exitFlushed(0);
|
|
1661
1661
|
}
|
|
1662
|
-
if (flag("archive-lines")) { const lines = historyEntries(null, true).map((entry) => JSON.stringify({ ...entry, ...(DERIVED.get(entry) ?? {}), client: entrySource.get(entry) ?? "claude", started_at: new Date(entryFile.get(entry).from).toISOString(), folder: entryFile.get(entry).folder })); PROGRESS.sink?.end(); process.stdout.write(`${[...lines, JSON.stringify({ archive_end: lines.length })].join("\n")}\n`); return await exitFlushed(0); } // one write and a count, so the reader tells a whole answer from a cut one
|
|
1662
|
+
if (flag("archive-lines")) { const lines = historyEntries(null, true).map((entry) => JSON.stringify({ ...entry, ...(DERIVED.get(entry) ?? {}), client: entrySource.get(entry) ?? "claude", started_at: new Date(entryFile.get(entry).from).toISOString(), folder: entry.repo_code === CONFIDENTIAL_REPO_CODE ? null : entryFile.get(entry).folder })); PROGRESS.sink?.end(); process.stdout.write(`${[...lines, JSON.stringify({ archive_end: lines.length })].join("\n")}\n`); return await exitFlushed(0); } // one write and a count, so the reader tells a whole answer from a cut one
|
|
1663
1663
|
// THE EXPORTS IN A FOLDER (0.10.10, for the bare `npx worktrust`): which lie there, by vendor and digest, and which this computer
|
|
1664
1664
|
// already sent or was asked about; reads, prints one JSON line, sends nothing. `--export-offered <digest>` records a No.
|
|
1665
1665
|
if (flag("find-exports")) { const named = value("find-exports"), state = readExportsState(); const found = (findExports ? await findExports(named && !named.startsWith("--") ? named : undefined) : []).map((one) => ({ ...one, sent: state[one.digest]?.sent === true, offered: Boolean(state[one.digest]) })); process.stdout.write(`${JSON.stringify(found)}\n`); return await exitFlushed(0); }
|
|
@@ -1740,7 +1740,7 @@ if (flag("history")) {
|
|
|
1740
1740
|
const sizes = plan.map((item) => ({ lines: item.batch.length, bytes: Buffer.byteLength(item.body, "utf8"), timeline_bytes: item.batch.reduce((n, entry) => n + timelineOfEntry(entry), 0) }));
|
|
1741
1741
|
const kinds = { interactive: 0, headless: 0, scheduled: 0, unknown: 0 };
|
|
1742
1742
|
for (const entry of entries) kinds[entry.session_kind ?? "unknown"] += 1;
|
|
1743
|
-
console.log(JSON.stringify({ sessions: new Set(entries.map((entry) => entryFile.get(entry)?.file)).size, unreadable: READ_FAILURES.n, days: new Set(entries.map((entry) => entry.at.slice(0, 10))).size, first: months[0] ?? null, last: months.at(-1) ?? null, ...(fromExports ? { exports: fromExports.reports } : {}), ...(fromFolder ? { folder: fromFolder.report } : {}), clients,
|
|
1743
|
+
console.log(JSON.stringify({ sessions: new Set(entries.map((entry) => entryFile.get(entry)?.file)).size, unreadable: READ_FAILURES.n, stores: databaseStores(Object.fromEntries(DATABASE_CLIENTS.map((client) => [client, value(`${client}-root`)]).filter(([, root]) => root)), Boolean(value("transcript-root"))), days: new Set(entries.map((entry) => entry.at.slice(0, 10))).size, first: months[0] ?? null, last: months.at(-1) ?? null, ...(fromExports ? { exports: fromExports.reports } : {}), ...(fromFolder ? { folder: fromFolder.report } : {}), clients,
|
|
1744
1744
|
batches: { count: sizes.length, largest_bytes: Math.max(0, ...sizes.map((one) => one.bytes)), largest_timeline_bytes: Math.max(0, ...sizes.map((one) => one.timeline_bytes)), largest_lines: Math.max(0, ...sizes.map((one) => one.lines)), each: sizes }, session_kinds: kinds }));
|
|
1745
1745
|
return await exitFlushed(0);
|
|
1746
1746
|
}
|
package/package-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"e8abb38c293b57b71d3a6163d6242d1f375e773372b91b6d8ce39c584c51262a","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"b38ea343eb95892d4164274be4184d6e34eade9d4c454e1dcf8bc7735736425e","README.md":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"e8abb38c293b57b71d3a6163d6242d1f375e773372b91b6d8ce39c584c51262a","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"b38ea343eb95892d4164274be4184d6e34eade9d4c454e1dcf8bc7735736425e","README.md":"45d486ae56776dd516181f58e6624d3cefe54c6dc6f2b6b76e1ac2d4675e54ad","SECURITY.md":"69f654b8101ab49821b8eb54b631f0a028035149c727953dc7d609faa2a9b2e0","chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"06b0ecbc222087160dc64c0b302391631e8e799038364c317c6cd28449c5044d","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","engine-release.json":"27e7c13f7e656c7310affd242e0d3f732fd0f07656bc81b4fd5b32df7cdf720a","export-facts.mjs":"3bbb46c80e8678b5cea7e15dcbfc456a2b48595053241c2b3cea508092f9b917","git-commits.mjs":"af0ed45a2a42c8e17cabfb3649a2f524dbf80230f8a6ec1c6b775fed7d34dc9c","history-outbox.mjs":"85c70389effc5b4ec9d9b33af9192314e67f47af2752515b42a7959344ce2354","history-progress.mjs":"dcc25ee94b727f2605a763349a4d8764640335d6cf0043fb6108cebeed16dcb9","log-session.mjs":"167fe3718415fe690c9e4f7a3a993520e8c652edcf61184cc14cfec2db67d7bc","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","package.json":"2ffecd064224277315796697dfdb38db2816c1eedb0a299acd7eb8f2ede2620a","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"cd111cae0f53a25a2d878a158479abfb1ace353361454843f91a16d241101d46","project-modes.mjs":"ada26e68297fbeb90e4e91d75a90fd2d7cc107b999a9702840675b5a7529463e","remote-adapter-claude-code.mjs":"a5ef08186128d9fe4023944378bb0ff5682a8ae64ffdb07ef5e76cc51894d721","remote-adapter-codex.mjs":"d2fd6c61d9e3c4a45e9b10da1aa3c15d45c86629d6456e4a8d25ad95b13eb209","remote-adapter-opencode.mjs":"ab3ccc5e958ef17ceda595853e40a4521f5452f8d54e8fbf269299a397760a63","remote-adapter-terminal.mjs":"9237d3747a25126fcdad42c0eab10e69393754388a6014b30fb0890b9c735888","remote-agent-switch.mjs":"7ff5448f29f05a47d7298d730b21243a1bcf8a215b434a0c7fbf5f3cb0889041","remote-approval-bridge.mjs":"092f17b7969e4f35bea064315d04dcde1faa6a3fd3e737dcc05aece82c7a37c4","remote-approvals.mjs":"5a371e049ceb154100a3b0c1900d8a2c1fc193b01e8069f11ce1690bcf4df3e1","remote-attachments.mjs":"2e9c1277329a45cf26c0c62abda632cf0ab9fad78d0504416ecee9805220e16c","remote-cdp.mjs":"70e333a1ebe845e872cc3a703a0a507391f8ce59640bdbd662bdad55eeff216b","remote-changes.mjs":"2141fece4961a5bc1bb1b046f78222812617457b1ba6452275eac6a897e62e19","remote-claude-events.mjs":"58822471203c6a1b66cf81c115c4d713657c3dea5c7b98df959f894ee5b2e704","remote-claude-progress.mjs":"2ca626d3dbc16d8d570abe1df6477b7e44ffb43c1d9145228ec5ea1928e415ca","remote-cli.mjs":"bf2e1577b141e4dfe1fdb22d7a4fb6127dadc85c74796ce3b108455f75093b8b","remote-coalesce.mjs":"cb0967d9cfe81e3892bcade8349d6814db98be8c2adbdb54df0b8d1b142f65d1","remote-codex-events.mjs":"58657d6070a50c837737cb85f5a1eaf9c2cbc4e1adfe3e970748ab3b2af94631","remote-daemon.mjs":"5dadcced9bd2c69be8c48afbaabbf50bd16879612ada0553aa2284a873907492","remote-endorse.mjs":"89eda4883567176703e01e44d83e987271bc2a6134e108f517b3b213719a21f9","remote-inventory.mjs":"43954e427141b4303ca13d22068d50bfc81e544b085bce335b8e8d59dc520468","remote-journal.mjs":"907ebd48c53162b22dc743ef95b53c1a6be6886a7495605b5cfa820b8de9d330","remote-live-preview.mjs":"faa70f9260ac05037204c2a0c3facf4ffe42f68408948390b341b453a2932289","remote-opencode-events.mjs":"8ee6b070f4c4787e10305f105b925e6b5f95bff99c1e1f44577aeca0ef8c347e","remote-opencode-session.mjs":"681b201d833a7d7d025122b3a79663bcdc0a989aefd39d8018a28113d8810caf","remote-pairing.mjs":"ae03427b6510e52da08aaf9387d5e08516ee25380c7efa420432f4e1e936a7c5","remote-pipeline-config.mjs":"00cde6a61ce21144c51ac56fce42fee159aa9dba6586218a7ea790ce4a6bd40b","remote-pipeline-parsers.mjs":"43ca0d332d7bc883c4759a754a555815ae5dfe133446b91ba9f2e48a350fa20f","remote-pipeline.mjs":"b856ead989b29ddb618ef69bbacd104bae2b02c9d1c5214291d08ce469a8b24e","remote-policy.mjs":"aacf7578537021ab3849095bb1f58f0ed12c453c6ca2ab1352a1716fb13b0ca4","remote-preview.mjs":"fe504ad6f83dcb4a4ebdcc018686a9a5a900c47cdf8c45b75e7d02e2f3056155","remote-projects.mjs":"d07997167d1f51139ff010c8753639e48c5cd33688568459e184eabb12bfff84","remote-protocol.mjs":"7b2a78e585983be40e240b9ab0b2e31a69e586bd72292071886c60b217d97a60","remote-qr.mjs":"b80e2b4a5bc020cf6ed92e91d06b327cb5197de1c35b3445a0fc2c7a3bf1ab3f","remote-release-plans.mjs":"11884a62b7d6dcccb5e154a26603bdf650f7b40f946329fb174d8c13729bec74","remote-releases.mjs":"fb08b72593ea00013c8b679e0c0d7dee95b0fd7cc5fd31b80ac575d0e340927d","remote-run.mjs":"c72c77fdd14115e66f1f2be383ca4f1363a4cecc9dced9cc48cbb3e4bb44bc66","remote-screen-approvals.mjs":"c43ab286d36a38d17639d155782ffa017f1a9b6806a09b82ed0142a1290b6000","remote-screen-push.mjs":"4ee8bd48d24b2c87581e9f33d8354a86381f7febd82f89ed509a7a87c1442608","remote-screen-states.mjs":"7c3c86a584bebf52461f3cab39c05ea2a13910061704d48fc622956e842940f7","remote-service.mjs":"1b9d4ecf99b667f2ab7c78fe1dfd5cf507cbb36c5bcad15bfa2a88c313ae758e","remote-session-list.mjs":"494fdbe20f0542806ac6c42ad149c52e2d3ace23a3a7567f96dc7e80d092c727","remote-sessions.mjs":"64ae363f8b5f38c58c21afbeaa7951d9592c608c3c83cceb78b21700a64467e9","remote-steered.mjs":"d7afde92c62c87abbdb84b0cfea2eea4752e90a2e453e52a54812c4fe0395190","remote-steering.mjs":"7ba22e6110cea3ac75a4f084f8f92a5bd90c31a19d3ce58a88a0843bdadea834","remote-store.mjs":"51645f8355923fe51de00233477266a99e94d4ca1f98f797f96e4ebb15927e9a","remote-terminal-cli.mjs":"82a048b75e412d0b6db076afbb84cab7c754dec72b6c8b6af4d4906b38e988a7","remote-terminal-sessions.mjs":"6ab51824890a18768d23cedc499f3840b2b02a8ed651463c1fe2d74dd352a361","remote-transport.mjs":"68650fd77ea09b5762377f87cabdc1c73a34d77324aa5bf0cd9742094a50c32b","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","self-update.mjs":"378e3620d48c72cf0bf812be408883b995cdb2223de34a20f762dd73eeffb258","session-databases.mjs":"a16ffbc50ccc0e78f370ebe07f871d1a80f1977472e478e3599e7abfdc90c1b7","session-local-models.mjs":"bacd38ff8dd3056b552982ec52eb57c7b8ca86e1a46cd4cba30fc340e3e28fd4","setup-mcp.mjs":"b732e3dd9b3e522b7cc8acf167ce28ba8f1a8dee797ee15bd7c3b02919b13e6f","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"e9f20415c2b5d62a09f35a63075002ebd1da56edb32f242d52822d58ecbd8ac3","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"6c065d9bed11f3d0f2085c6214eac5e3296becdd3298bacd7af8db0939fa9b79"},"format":"worktrust-package/1","kind":"npm","version":"0.11.4"},"signature":"48Tc9BjElnZHbSUBfDOGdt4eAHM1fzCWKQl73BLpVioPBmVI2aDFRLUfxLGNKXkttAU0WiUvBG46HBFESFnOAw"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "worktrust",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
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": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"count-behaviour.mjs",
|
|
14
14
|
"transcript-readers.mjs",
|
|
15
15
|
"session-databases.mjs",
|
|
16
|
+
"session-local-models.mjs",
|
|
16
17
|
"config-edits.mjs",
|
|
17
18
|
"preserve.mjs",
|
|
18
19
|
"preserve-summary.mjs",
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"package-integrity.mjs",
|
|
35
36
|
"worktrust-launch.mjs",
|
|
36
37
|
"git-commits.mjs",
|
|
38
|
+
"project-modes.mjs",
|
|
37
39
|
"commit-rules.mjs",
|
|
38
40
|
"engine-release.json",
|
|
39
41
|
"package-release.json",
|
|
@@ -57,6 +59,9 @@
|
|
|
57
59
|
"remote-steering.mjs",
|
|
58
60
|
"remote-codex-events.mjs",
|
|
59
61
|
"remote-adapter-codex.mjs",
|
|
62
|
+
"remote-opencode-events.mjs",
|
|
63
|
+
"remote-adapter-opencode.mjs",
|
|
64
|
+
"remote-opencode-session.mjs",
|
|
60
65
|
"remote-adapter-terminal.mjs",
|
|
61
66
|
"remote-terminal-sessions.mjs",
|
|
62
67
|
"remote-terminal-cli.mjs",
|
|
@@ -84,7 +89,8 @@
|
|
|
84
89
|
"remote-service.mjs",
|
|
85
90
|
"remote-pairing.mjs",
|
|
86
91
|
"remote-qr.mjs",
|
|
87
|
-
"remote-cli.mjs"
|
|
92
|
+
"remote-cli.mjs",
|
|
93
|
+
"remote-agent-switch.mjs"
|
|
88
94
|
],
|
|
89
95
|
"engines": {
|
|
90
96
|
"node": ">=18"
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A PROJECT'S MODE ON THIS COMPUTER (owner, 2026-11-09; docs/CONFIDENTIAL-WORK.md). One file, ~/.worktrust-counter.json,
|
|
3
|
+
* holds two lists the person writes with `worktrust project exclude|confidential|normal [path]`:
|
|
4
|
+
*
|
|
5
|
+
* exclude the project is never read: no hours, no tokens, nothing (as since 2026-09-27)
|
|
6
|
+
* confidential hours and token counts still count, but nothing that names the client leaves this computer: no repository
|
|
7
|
+
* name, no HMAC code, no branch, no remote, no path, no commit; one fixed marker instead, the same for every
|
|
8
|
+
* confidential project, so their lines cannot be told apart
|
|
9
|
+
* normal neither (the default)
|
|
10
|
+
*
|
|
11
|
+
* EVERY READER ASKS HERE (scripts/check-project-modes.mjs refuses one that reads the file itself or sends work without asking):
|
|
12
|
+
* a reader that knew only `exclude` would send a confidential project's name, which is the one thing this mode exists to stop.
|
|
13
|
+
* Exclude wins over confidential; an entry is an absolute folder (what the command writes: the folder and everything under it)
|
|
14
|
+
* or a hand-written text (any folder whose name contains it, ignoring case, as the file always meant).
|
|
15
|
+
*
|
|
16
|
+
* AN OLDER READER FAILS CLOSED. A reader from before this mode knows only `exclude`, and it matched Claude Code's folders by a
|
|
17
|
+
* text inside their encoded name. So the command writes a folder into `exclude` twice (its path and its encoded name, which an
|
|
18
|
+
* older reader matches) and, for a confidential folder, into `confidential` as well: an older reader leaves the project out
|
|
19
|
+
* entirely, never names it; a reader that knows this file reads the pair as confidential.
|
|
20
|
+
*/
|
|
21
|
+
import { chmodSync, existsSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";
|
|
22
|
+
import { homedir } from "node:os";
|
|
23
|
+
import { basename, isAbsolute, join, resolve, sep } from "node:path";
|
|
24
|
+
|
|
25
|
+
export const COUNTER_CONFIG = ".worktrust-counter.json";
|
|
26
|
+
/** The one marker a confidential line carries in place of a repository (a repo_code's shape, never an HMAC of anything). */
|
|
27
|
+
export const CONFIDENTIAL_REPO_CODE = "0000000000000000";
|
|
28
|
+
/** What an AI app's free-text title becomes on a confidential line: the title is the person's words and may name the client. */
|
|
29
|
+
export const CONFIDENTIAL_TITLE = "Confidential client work";
|
|
30
|
+
export const MODES = ["exclude", "confidential", "normal"];
|
|
31
|
+
|
|
32
|
+
const configFile = (home) => join(home, COUNTER_CONFIG);
|
|
33
|
+
const strings = (list) => (Array.isArray(list) ? list.filter((entry) => typeof entry === "string" && entry.trim() !== "").map((entry) => entry.trim()) : []);
|
|
34
|
+
|
|
35
|
+
/** The whole file as it stands (other keys, such as leaveOut, kept), or an empty one. A damaged file reads as empty lists. */
|
|
36
|
+
function readConfig(home) {
|
|
37
|
+
try { const parsed = JSON.parse(readFileSync(configFile(home), "utf8")); return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {}; } catch { return {}; }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The two lists. A reader calls this once per run and hands the answer to projectModeOf. */
|
|
41
|
+
export function readProjectModes(home = homedir()) {
|
|
42
|
+
const config = readConfig(home);
|
|
43
|
+
const confidential = strings(config.confidential);
|
|
44
|
+
const shadows = new Set(confidential.flatMap(shadowsOf));
|
|
45
|
+
// leaveOut: the words a turn must not carry (count-behaviour), kept in the same file and read here with it.
|
|
46
|
+
return { exclude: strings(config.exclude).filter((entry) => !shadows.has(entry)), confidential, leaveOut: strings(config.leaveOut) };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Claude Code names a project's folder by its path with every character that is not a letter or digit as "-". */
|
|
50
|
+
const encoded = (path) => path.replace(/[^A-Za-z0-9]/g, "-");
|
|
51
|
+
/** The entries the command writes into `exclude` for one folder: its path and its encoded name (what an older reader matches). */
|
|
52
|
+
const shadowsOf = (folder) => (isAbsolute(folder) ? [folder, encoded(folder)] : [folder]);
|
|
53
|
+
const real = (path) => { try { return realpathSync(path); } catch { return path; } };
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Whether one entry covers a candidate. A candidate is what a reader holds: an absolute working directory, Claude Code's
|
|
57
|
+
* encoded project folder, or only a folder's name (Codex, Copilot). Wider rather than narrower: a confidential or excluded
|
|
58
|
+
* project that matches too much stays private; one that matches too little leaks.
|
|
59
|
+
*/
|
|
60
|
+
export function entryCovers(entry, candidate) {
|
|
61
|
+
if (!entry || !candidate) return false;
|
|
62
|
+
const text = String(candidate);
|
|
63
|
+
if (isAbsolute(entry)) {
|
|
64
|
+
const root = resolve(entry);
|
|
65
|
+
if (isAbsolute(text)) return [resolve(text), real(resolve(text))].some((path) => path === root || path.startsWith(root + sep));
|
|
66
|
+
const folder = encoded(root);
|
|
67
|
+
if (text === folder || text.startsWith(`${folder}-`)) return true;
|
|
68
|
+
return !/[\\/]/.test(text) && text.toLowerCase() === basename(root).toLowerCase();
|
|
69
|
+
}
|
|
70
|
+
return text.toLowerCase().includes(entry.toLowerCase());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** "exclude" | "confidential" | "normal" for a candidate; exclude wins. No candidate is normal (nothing to name). */
|
|
74
|
+
export function projectModeOf(candidate, modes = readProjectModes()) {
|
|
75
|
+
if (!candidate) return "normal";
|
|
76
|
+
if (modes.exclude.some((entry) => entryCovers(entry, candidate))) return "exclude";
|
|
77
|
+
if (modes.confidential.some((entry) => entryCovers(entry, candidate))) return "confidential";
|
|
78
|
+
return "normal";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The mode of the first candidate that has one, exclude before confidential (a reader may know a folder and a repo name). */
|
|
82
|
+
export function strictestMode(candidates, modes = readProjectModes()) {
|
|
83
|
+
const found = candidates.filter(Boolean).map((candidate) => projectModeOf(candidate, modes));
|
|
84
|
+
return found.includes("exclude") ? "exclude" : found.includes("confidential") ? "confidential" : "normal";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The keys that could name a client or a place: never on a confidential line, whatever sent them. */
|
|
88
|
+
const IDENTIFYING = ["repo", "repo_code", "repo_reported", "commits", "branch", "remote", "remote_url", "origin", "path", "paths", "files", "cwd", "project", "project_ref", "workspace", "folder", "schedule_ref"];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A line as it may leave this computer from a confidential project: the identifying keys out, the marker in. `title` is
|
|
92
|
+
* replaced only when the caller asks (an AI app's own title is free text; the hook's titles are fixed words).
|
|
93
|
+
*/
|
|
94
|
+
export function confidentialPayload(payload, { replaceTitle = false } = {}) {
|
|
95
|
+
const out = {};
|
|
96
|
+
for (const [key, value] of Object.entries(payload ?? {})) if (!IDENTIFYING.includes(key)) out[key] = value;
|
|
97
|
+
out.repo_code = CONFIDENTIAL_REPO_CODE;
|
|
98
|
+
if (replaceTitle) out.title = CONFIDENTIAL_TITLE;
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Writes one folder's mode: out of both lists, into the one named (normal: into neither). The file stays 0600, other keys kept. */
|
|
103
|
+
export function writeProjectMode(path, mode, home = homedir()) {
|
|
104
|
+
if (!MODES.includes(mode)) throw new Error(`mode: one of ${MODES.join(", ")}`);
|
|
105
|
+
const folder = real(resolve(path));
|
|
106
|
+
const config = readConfig(home);
|
|
107
|
+
const mine = new Set(shadowsOf(folder));
|
|
108
|
+
const exclude = strings(config.exclude).filter((entry) => !mine.has(entry));
|
|
109
|
+
const confidential = strings(config.confidential).filter((entry) => entry !== folder);
|
|
110
|
+
// Both modes go into `exclude` (an older reader leaves the folder out); confidential also into its own list.
|
|
111
|
+
if (mode !== "normal") exclude.push(...shadowsOf(folder));
|
|
112
|
+
if (mode === "confidential") confidential.push(folder);
|
|
113
|
+
const next = { ...config, exclude, confidential };
|
|
114
|
+
const file = configFile(home), temp = `${file}.${process.pid}.tmp`;
|
|
115
|
+
writeFileSync(temp, `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600 });
|
|
116
|
+
try { chmodSync(temp, 0o600); } catch { /* Windows */ }
|
|
117
|
+
renameSync(temp, file);
|
|
118
|
+
const modes = readProjectModes(home);
|
|
119
|
+
return { folder, mode, effective: projectModeOf(folder, modes), modes };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* `worktrust project exclude|confidential|normal [path]` and `worktrust project list`. The person's own file, written for
|
|
124
|
+
* them; nothing is sent. `io` carries say and fail; `home` and `cwd` are a test's.
|
|
125
|
+
*/
|
|
126
|
+
export function projectCommand(argv, io) {
|
|
127
|
+
const { say, fail, home = homedir(), cwd = process.cwd() } = io;
|
|
128
|
+
const [sub, given] = argv;
|
|
129
|
+
if (!sub || sub === "list") {
|
|
130
|
+
const modes = readProjectModes(home);
|
|
131
|
+
modes.exclude = modes.exclude.filter((entry) => !(/^-/.test(entry) && modes.exclude.some((other) => isAbsolute(other) && encoded(other) === entry)));
|
|
132
|
+
say();
|
|
133
|
+
if (!modes.exclude.length && !modes.confidential.length) { say(" Every project is normal on this computer."); say(" Change one with: worktrust project exclude|confidential|normal [folder]"); return 0; }
|
|
134
|
+
for (const entry of modes.confidential) say(` confidential ${entry}`);
|
|
135
|
+
for (const entry of modes.exclude) say(` excluded ${entry}`);
|
|
136
|
+
say();
|
|
137
|
+
say(" Confidential: hours and tokens count, nothing that names the client is sent. Excluded: nothing is read.");
|
|
138
|
+
return 0;
|
|
139
|
+
}
|
|
140
|
+
if (!MODES.includes(sub)) return fail("project: exclude, confidential, normal or list");
|
|
141
|
+
const folder = resolve(cwd, given ?? ".");
|
|
142
|
+
if (!existsSync(folder)) return fail(`project: ${folder} does not exist`);
|
|
143
|
+
const done = writeProjectMode(folder, sub, home);
|
|
144
|
+
say();
|
|
145
|
+
if (sub === "exclude") say(` Excluded: ${done.folder}. Nothing from it is read or sent.`);
|
|
146
|
+
else if (sub === "confidential") say(` Confidential: ${done.folder}. Hours and tokens count; no name, branch, path or commit is sent.`);
|
|
147
|
+
else say(` Normal: ${done.folder}.`);
|
|
148
|
+
if (done.effective !== sub) {
|
|
149
|
+
const word = done.effective === "exclude" ? "excluded" : done.effective;
|
|
150
|
+
say(` It stays ${word}: another entry covers it. See \`worktrust project list\`.`);
|
|
151
|
+
}
|
|
152
|
+
say(" Lines already on your record keep what they were sent with.");
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** A repository name's last segment ("acme/portal" → "portal"), what a folder entry can be matched by. */
|
|
157
|
+
const repoTail = (repo) => (typeof repo === "string" && repo.trim() ? repo.trim().replace(/\.git$/, "").split(/[\\/:]/).filter(Boolean).at(-1) ?? null : null);
|
|
158
|
+
const receipt = (id, note) => ({ jsonrpc: "2.0", id, result: { content: [{ type: "text", text: JSON.stringify({ receipt: "excluded", note }) }] } });
|
|
159
|
+
const EXCLUDED_NOTE = "This project is excluded on this computer (worktrust project list); nothing was sent.";
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* AN AI APP'S OWN CALL THROUGH THE BRIDGE (`worktrust mcp`). `log_work` and `import_history` are the AI app's words, so the
|
|
163
|
+
* mode is decided here, before anything leaves: by the folder the app started the bridge in and by the repository name the call
|
|
164
|
+
* carries. Excluded: answered here, nothing sent. Confidential: sealed (confidentialPayload, the title replaced). Any other
|
|
165
|
+
* message passes unchanged. Returns { forward } (the message to send) or { answer } (the reply to give, nothing sent).
|
|
166
|
+
*/
|
|
167
|
+
export function sealToolCall(message, cwd, modes = readProjectModes()) {
|
|
168
|
+
const name = message?.method === "tools/call" ? message.params?.name : null;
|
|
169
|
+
if (name !== "log_work" && name !== "import_history") return { forward: message };
|
|
170
|
+
const args = message.params?.arguments ?? {};
|
|
171
|
+
const here = projectModeOf(cwd, modes);
|
|
172
|
+
if (here === "exclude") return { answer: receipt(message.id, EXCLUDED_NOTE) };
|
|
173
|
+
const modeOf = (line) => strictestMode([cwd, repoTail(line?.repo)], modes); // the folder's mode, or stricter by the name
|
|
174
|
+
if (name === "log_work") {
|
|
175
|
+
const mode = modeOf(args);
|
|
176
|
+
if (mode === "exclude") return { answer: receipt(message.id, EXCLUDED_NOTE) };
|
|
177
|
+
if (mode === "normal") return { forward: message };
|
|
178
|
+
return { forward: { ...message, params: { ...message.params, arguments: confidentialPayload(args, { replaceTitle: true }) } } };
|
|
179
|
+
}
|
|
180
|
+
if (!Array.isArray(args.entries)) return { forward: message };
|
|
181
|
+
const entries = args.entries.flatMap((entry) => { const mode = modeOf(entry); return mode === "exclude" ? [] : mode === "confidential" ? [confidentialPayload(entry, { replaceTitle: true })] : [entry]; });
|
|
182
|
+
if (entries.length === 0 && args.entries.length > 0) return { answer: receipt(message.id, EXCLUDED_NOTE) };
|
|
183
|
+
return { forward: { ...message, params: { ...message.params, arguments: { ...args, entries } } } };
|
|
184
|
+
}
|