worktrust 0.8.8 → 0.9.0
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 +2 -0
- package/package.json +1 -1
- package/preserve-lines.mjs +16 -2
- package/stretch-evidence.mjs +67 -6
- package/worktrust.mjs +1 -1
package/README.md
CHANGED
|
@@ -173,6 +173,8 @@ nothing it does not:
|
|
|
173
173
|
| `unconfirmed` | checks the stretch ran whose outcome no reader could see (Codex's code mode prints no exit code; a background terminal), per kind: counted, never as a pass (0.8.5) |
|
|
174
174
|
| `autonomy`, `authorship` | the permission mode the AI app ran in, on one scale (ask, edits, plan, auto, full), how often it changed and the turns in plan mode; of the stretch's commits, how many name an AI as co-author (the trailer is read here, its names never leave) (0.8.7) |
|
|
175
175
|
| `framing`, `quality`, `risk`, `tool_mix`, `reads`, `context_files` | how the work was framed (your turns before the agent's first action, a plan first or not), checked (a check passing after the last change, the failures before a check passed, the change looked at before delivery; security scans count as checks), risked (destructive commands proposed, refused, run), which kinds of tools were used, files read again unchanged, and which of the AI app's own context files (instructions, skills, agents, commands, settings, MCP) the commits changed; kinds and counts only (0.8.8) |
|
|
176
|
+
| `quality.change_blocks`, `checked_blocks`, `rework_cycles`, `stage` | how many change blocks (edits with no check between them) a check followed, how often a failed check was followed by another change before it ran again (rework), and the furthest step the stretch reached here: attempted, verified, committed, pushed, pr, deployed; counts and one word only (0.8.9) |
|
|
177
|
+
| `timing` | how fast the stretch moved: seconds from your first turn to the first action and from the first change to the first check, the actions and seconds from a failure to the change that answered it, the calls from a failed check to it passing, and the calls back to work after a compaction; medians from the order and the clocks, never what was said (0.9.0) |
|
|
176
178
|
| `collector_version` | the CLI version that measured it |
|
|
177
179
|
| `seq`, `prev`, `hash` | the line's place, the hash of the line before it, and its own hash |
|
|
178
180
|
|
package/package.json
CHANGED
package/preserve-lines.mjs
CHANGED
|
@@ -105,7 +105,17 @@ export function archiveLine(entry, behaviour = null, { ids = {}, collector, salt
|
|
|
105
105
|
// PRACTICE (0.8.8): framing, verification quality, risk, tool mix, re-reads, context files; whole counts and flags only.
|
|
106
106
|
const bool = (value) => value === true || value === false;
|
|
107
107
|
if (entry.framing && whole(entry.framing.turns_before_action) && bool(entry.framing.planned_first)) line.framing = { turns_before_action: entry.framing.turns_before_action, planned_first: entry.framing.planned_first };
|
|
108
|
-
if (entry.quality && whole(entry.quality.fix_cycles_max) && (bool(entry.quality.checked_after_change) || entry.quality.checked_after_change === null) && (bool(entry.quality.inspected_first) || entry.quality.inspected_first === null))
|
|
108
|
+
if (entry.quality && whole(entry.quality.fix_cycles_max) && (bool(entry.quality.checked_after_change) || entry.quality.checked_after_change === null) && (bool(entry.quality.inspected_first) || entry.quality.inspected_first === null)) {
|
|
109
|
+
line.quality = { checked_after_change: entry.quality.checked_after_change, fix_cycles_max: entry.quality.fix_cycles_max, inspected_first: entry.quality.inspected_first };
|
|
110
|
+
// 0.8.9: change blocks, how many a check followed, rework cycles.
|
|
111
|
+
if (whole(entry.quality.change_blocks) && whole(entry.quality.checked_blocks) && whole(entry.quality.rework_cycles) && entry.quality.checked_blocks <= entry.quality.change_blocks) Object.assign(line.quality, { change_blocks: entry.quality.change_blocks, checked_blocks: entry.quality.checked_blocks, rework_cycles: entry.quality.rework_cycles });
|
|
112
|
+
}
|
|
113
|
+
if (STAGES.includes(entry.stage)) line.stage = entry.stage;
|
|
114
|
+
// 0.9.0: how fast the stretch moved; whole seconds and counts, each key optional.
|
|
115
|
+
if (entry.timing && typeof entry.timing === "object") {
|
|
116
|
+
const timing = Object.fromEntries(TIMING_KEYS.filter((key) => whole(entry.timing[key])).map((key) => [key, entry.timing[key]]));
|
|
117
|
+
if (Object.keys(timing).length > 0) line.timing = timing;
|
|
118
|
+
}
|
|
109
119
|
const risk = pick(entry.risk, ["proposed", "refused", "run"]);
|
|
110
120
|
if (risk && risk.proposed > 0 && risk.refused + risk.run <= risk.proposed) line.risk = risk;
|
|
111
121
|
const keyed = (record, keys) => { const kept = Object.entries(record && typeof record === "object" ? record : {}).filter(([key, n]) => keys.includes(key) && whole(n) && n > 0).sort(); return kept.length ? Object.fromEntries(kept) : null; };
|
|
@@ -162,7 +172,11 @@ export function archiveEntries(dir, ownKey) {
|
|
|
162
172
|
* a line of their own that names the stretch it adds to (`supplements`) and carries only what no earlier line of that
|
|
163
173
|
* stretch carries, in the same chain, under the same day's root. Null when there is nothing new.
|
|
164
174
|
*/
|
|
165
|
-
|
|
175
|
+
/** The furthest step a stretch reached on the computer (0.8.9). */
|
|
176
|
+
const STAGES = ["attempted", "verified", "committed", "pushed", "pr", "deployed"];
|
|
177
|
+
/** How fast a stretch moved (0.9.0). */
|
|
178
|
+
const TIMING_KEYS = ["first_action_s", "first_check_s", "detect_actions", "detect_s", "recovery_calls", "resume_actions"];
|
|
179
|
+
export const DERIVED_KEYS = ["signals", "analyzer_version", "verification", "unconfirmed", "delivery", "recovery", "delegation", "context", "routing", "steering", "tools", "complexity", "oversight", "planning", "changes", "autonomy", "authorship", "framing", "quality", "risk", "tool_mix", "reads", "context_files", "stage", "timing", "interrupts", "steers", "utc_offset"];
|
|
166
180
|
export function supplementFor(line, earlier) {
|
|
167
181
|
const missing = DERIVED_KEYS.filter((key) => line[key] !== undefined && !earlier.some((old) => old[key] !== undefined));
|
|
168
182
|
if (missing.length === 0) return null;
|
package/stretch-evidence.mjs
CHANGED
|
@@ -268,6 +268,10 @@ function autonomyOf(messages) {
|
|
|
268
268
|
* (plan mode, a plan approved, a to-do list) came before it.
|
|
269
269
|
* quality: whether a check passed AFTER the stretch's last change; the most failures one check family took before it
|
|
270
270
|
* passed; whether the change was looked at (git diff, show, status) before the first delivery step.
|
|
271
|
+
* 0.8.9: change BLOCKS (edits with no check between them) and how many a check followed before the next one;
|
|
272
|
+
* REWORK cycles (a check failed, then a change before that check ran again: change, fail, change).
|
|
273
|
+
* stage: the furthest step the stretch reached on this computer: attempted (it changed something), verified (a check
|
|
274
|
+
* passed), committed, pushed, pr, deployed (0.8.9). Merged and confirmed are the server's, from GitHub.
|
|
271
275
|
* risk: destructive commands proposed, refused (by the person or a guard) and run.
|
|
272
276
|
* tool_mix: calls per kind of tool (search, read, edit, shell, agent, web, data, mcp, plan).
|
|
273
277
|
* reads: files read again unchanged (the same read twice), the cost of context that did not hold.
|
|
@@ -282,6 +286,8 @@ function practiceOf(messages, { isHumanTurn }) {
|
|
|
282
286
|
let turns = 0, acted = false, planned = false, turnsBefore = 0, plannedFirst = false;
|
|
283
287
|
let lastChange = -1, passedAfter = false, delivered = false, inspectedFirst = false;
|
|
284
288
|
const failuresBefore = new Map(); let cyclesMax = 0;
|
|
289
|
+
let blocks = 0, checkedBlocks = 0, inBlock = false, rework = 0, passedAny = false;
|
|
290
|
+
const pendingFail = new Set(), reached = new Set();
|
|
285
291
|
const risk = { proposed: 0, refused: 0, run: 0 }, mix = {}, reads = new Map();
|
|
286
292
|
let index = 0;
|
|
287
293
|
for (const message of messages) {
|
|
@@ -294,15 +300,21 @@ function practiceOf(messages, { isHumanTurn }) {
|
|
|
294
300
|
mix[toolKind(tool)] = (mix[toolKind(tool)] ?? 0) + 1;
|
|
295
301
|
if (PLAN_TOOLS.has(tool) && tool !== "AskUserQuestion") planned = true;
|
|
296
302
|
if (!acted && ACTION_TOOLS.has(tool)) { acted = true; turnsBefore = turns; plannedFirst = planned; }
|
|
297
|
-
if (EDIT_TOOLS.has(tool)) {
|
|
303
|
+
if (EDIT_TOOLS.has(tool)) {
|
|
304
|
+
lastChange = index; passedAfter = false;
|
|
305
|
+
if (!inBlock) { blocks += 1; inBlock = true; }
|
|
306
|
+
rework += pendingFail.size; pendingFail.clear();
|
|
307
|
+
}
|
|
298
308
|
if (tool === "Read") reads.set(call.digest, (reads.get(call.digest) ?? 0) + 1);
|
|
299
309
|
const checks = call.kinds.filter((kind) => CHECK_KINDS.includes(kind));
|
|
310
|
+
if (checks.length > 0 && inBlock) { checkedBlocks += 1; inBlock = false; }
|
|
300
311
|
for (const kind of checks) {
|
|
301
|
-
if (result?.failed === true) failuresBefore.set(kind, (failuresBefore.get(kind) ?? 0) + 1);
|
|
312
|
+
if (result?.failed === true) { failuresBefore.set(kind, (failuresBefore.get(kind) ?? 0) + 1); pendingFail.add(kind); }
|
|
313
|
+
if (result?.failed === false) { passedAny = true; pendingFail.delete(kind); }
|
|
302
314
|
if (result?.failed === false) { cyclesMax = Math.max(cyclesMax, failuresBefore.get(kind) ?? 0); failuresBefore.set(kind, 0); if (index > lastChange) passedAfter = true; }
|
|
303
315
|
}
|
|
304
316
|
if (call.kinds.includes("inspect") && !delivered) inspectedFirst = true;
|
|
305
|
-
if (call.kinds.some((kind) => DELIVERY_KINDS.includes(kind)) && result?.failed === false) delivered = true;
|
|
317
|
+
if (call.kinds.some((kind) => DELIVERY_KINDS.includes(kind)) && result?.failed === false) { delivered = true; for (const kind of call.kinds) if (DELIVERY_KINDS.includes(kind)) reached.add(kind); }
|
|
306
318
|
if (call.kinds.includes("destructive")) {
|
|
307
319
|
risk.proposed += 1;
|
|
308
320
|
if (result?.refusal) risk.refused += 1; else if (result?.failed === false) risk.run += 1;
|
|
@@ -311,18 +323,67 @@ function practiceOf(messages, { isHumanTurn }) {
|
|
|
311
323
|
}
|
|
312
324
|
if (index === 0) return null;
|
|
313
325
|
const repeated = [...reads.values()].reduce((sum, n) => sum + Math.max(0, n - 1), 0);
|
|
326
|
+
const stage = ["deploy", "pr", "push", "commit"].find((kind) => reached.has(kind)) ?? (lastChange > 0 ? (passedAny ? "verified" : "attempted") : null);
|
|
314
327
|
return {
|
|
315
328
|
framing: { turns_before_action: acted ? turnsBefore : turns, planned_first: acted ? plannedFirst : planned },
|
|
316
|
-
quality: { checked_after_change: lastChange > 0 ? passedAfter : null, fix_cycles_max: cyclesMax, inspected_first: delivered ? inspectedFirst : null },
|
|
329
|
+
quality: { checked_after_change: lastChange > 0 ? passedAfter : null, fix_cycles_max: cyclesMax, inspected_first: delivered ? inspectedFirst : null, change_blocks: blocks, checked_blocks: checkedBlocks, rework_cycles: rework },
|
|
330
|
+
...(stage ? { stage: { deploy: "deployed", pr: "pr", push: "pushed", commit: "committed" }[stage] ?? stage } : {}),
|
|
317
331
|
...(risk.proposed > 0 ? { risk } : {}),
|
|
318
332
|
tool_mix: mix,
|
|
319
333
|
reads: { repeated },
|
|
320
334
|
};
|
|
321
335
|
}
|
|
322
336
|
|
|
337
|
+
/**
|
|
338
|
+
* HOW FAST A STRETCH MOVED (0.9.0): seconds from the person's first turn to the agent's first action (an edit, a write or
|
|
339
|
+
* a shell command) and from the first change to the first check; per failure, the actions and seconds until the next
|
|
340
|
+
* change that answered it (detection), and the calls from a failed check to that check passing (recovery depth); after
|
|
341
|
+
* a resume, a clear or a compaction, the calls until the next change or check (back to work). Medians, from the order
|
|
342
|
+
* and the clocks alone; nothing of what was said or run.
|
|
343
|
+
*/
|
|
344
|
+
const median = (values) => { if (values.length === 0) return null; const sorted = [...values].sort((a, b) => a - b); const middle = Math.floor(sorted.length / 2); return Math.round(sorted.length % 2 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2); };
|
|
345
|
+
function timingOf(messages, { isHumanTurn, textOf }) {
|
|
346
|
+
let firstTurn = null, firstAction = null, firstChange = null, firstCheck = null, index = 0, resumedAt = null;
|
|
347
|
+
const kindsById = new Map(), open = [], openChecks = new Map(), detect = [], detectSeconds = [], depth = [], resume = [];
|
|
348
|
+
for (const message of messages) {
|
|
349
|
+
if (message.bridge || !Number.isFinite(message.at)) continue;
|
|
350
|
+
const text = message.type === "user" ? textOf(message.content) : "";
|
|
351
|
+
if (message.compacted || ["compact", "clear", "resume"].includes(COMMAND.exec(text)?.[1] ?? "")) resumedAt = index;
|
|
352
|
+
if (message.type === "user" && !message.meta && message.kind !== "tool_result" && isHumanTurn(message.content) && firstTurn === null) firstTurn = message.at;
|
|
353
|
+
for (const result of message.results ?? []) {
|
|
354
|
+
const kinds = kindsById.get(result.id) ?? [];
|
|
355
|
+
if (result.failed !== true) {
|
|
356
|
+
for (const kind of kinds.filter((item) => CHECK_KINDS.includes(item) && result.failed === false)) { const at = openChecks.get(kind); if (at !== undefined) { depth.push(index - at); openChecks.delete(kind); } }
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
open.push({ index, at: message.at });
|
|
360
|
+
for (const kind of kinds.filter((item) => CHECK_KINDS.includes(item))) if (!openChecks.has(kind)) openChecks.set(kind, index);
|
|
361
|
+
}
|
|
362
|
+
for (const call of message.calls ?? []) {
|
|
363
|
+
index += 1;
|
|
364
|
+
kindsById.set(call.id, call.kinds);
|
|
365
|
+
const tool = call.family.split("|")[0];
|
|
366
|
+
if (firstAction === null && ACTION_TOOLS.has(tool)) firstAction = message.at;
|
|
367
|
+
if (EDIT_TOOLS.has(tool)) {
|
|
368
|
+
if (firstChange === null) firstChange = message.at;
|
|
369
|
+
for (const failure of open.splice(0)) { detect.push(index - failure.index); detectSeconds.push(Math.max(0, (message.at - failure.at) / 1000)); }
|
|
370
|
+
}
|
|
371
|
+
if (firstChange !== null && firstCheck === null && call.kinds.some((kind) => CHECK_KINDS.includes(kind))) firstCheck = message.at;
|
|
372
|
+
if (resumedAt !== null && (EDIT_TOOLS.has(tool) || call.kinds.some((kind) => CHECK_KINDS.includes(kind)))) { resume.push(index - resumedAt); resumedAt = null; }
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
const out = {
|
|
376
|
+
first_action_s: firstTurn !== null && firstAction !== null && firstAction >= firstTurn ? Math.round((firstAction - firstTurn) / 1000) : null,
|
|
377
|
+
first_check_s: firstChange !== null && firstCheck !== null ? Math.round((firstCheck - firstChange) / 1000) : null,
|
|
378
|
+
detect_actions: median(detect), detect_s: median(detectSeconds), recovery_calls: median(depth), resume_actions: median(resume),
|
|
379
|
+
};
|
|
380
|
+
const kept = Object.fromEntries(Object.entries(out).filter(([, value]) => value !== null));
|
|
381
|
+
return Object.keys(kept).length > 0 ? kept : null;
|
|
382
|
+
}
|
|
383
|
+
|
|
323
384
|
/** The stretch's whole derived record; `helpers` are the hook's own readers of a human turn, so both read it the same way. */
|
|
324
385
|
export function deriveStretch(messages, helpers) {
|
|
325
386
|
const context = contextOf(messages, helpers), routing = routingOf(messages), steering = steeringOf(messages, helpers);
|
|
326
|
-
const tools = toolsOf(messages), oversight = oversightOf(messages), planning = planningOf(messages), autonomy = autonomyOf(messages), practice = practiceOf(messages, helpers);
|
|
327
|
-
return { ...(practice ?? {}), ...(oversight ? { oversight } : {}), ...(planning ? { planning } : {}), ...(autonomy ? { autonomy } : {}), ...verificationOf(messages, helpers), ...(context ? { context } : {}), ...(routing ? { routing } : {}), ...(steering ? { steering } : {}), ...(tools ? { tools } : {}) };
|
|
387
|
+
const timing = timingOf(messages, helpers), tools = toolsOf(messages), oversight = oversightOf(messages), planning = planningOf(messages), autonomy = autonomyOf(messages), practice = practiceOf(messages, helpers);
|
|
388
|
+
return { ...(practice ?? {}), ...(oversight ? { oversight } : {}), ...(planning ? { planning } : {}), ...(autonomy ? { autonomy } : {}), ...verificationOf(messages, helpers), ...(context ? { context } : {}), ...(routing ? { routing } : {}), ...(steering ? { steering } : {}), ...(tools ? { tools } : {}), ...(timing ? { timing } : {}) };
|
|
328
389
|
}
|
package/worktrust.mjs
CHANGED
|
@@ -73,7 +73,7 @@ const command = args.find((arg, at) => !arg.startsWith("--") && !(at > 0 && VALU
|
|
|
73
73
|
const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
|
|
74
74
|
const has = (name) => args.includes(`--${name}`);
|
|
75
75
|
/** 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). */
|
|
76
|
-
const CLI_VERSION = "0.
|
|
76
|
+
const CLI_VERSION = "0.9.0";
|
|
77
77
|
const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.worktrust.io").replace(/\/$/, "");
|
|
78
78
|
const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
|
|
79
79
|
const HOME_DIR = join(homedir(), ".worktrust");
|