worktrust 0.9.1 → 0.9.2
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 +1 -0
- package/log-session.mjs +27 -1
- package/package.json +1 -1
- package/preserve-lines.mjs +8 -1
- package/stretch-evidence.mjs +18 -2
- package/worktrust.mjs +1 -1
package/README.md
CHANGED
|
@@ -176,6 +176,7 @@ nothing it does not:
|
|
|
176
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
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) |
|
|
178
178
|
| `hygiene` | risk and hygiene: rollbacks, privileged commands (sudo, a forced push), hooks skipped (--no-verify), secrets touched (a .env printed, a private key read), destructive commands and how many a look or a check came before, the answer to a guard (retried, changed, stopped), and whether a check followed delivery; counts only, never the command or the path (0.9.1) |
|
|
179
|
+
| `route` | the route the work took: branches made, pushes straight to the default branch, and of the stretch's own commits those over twenty files, a fix that followed another, those naming an issue, and the changed CI, script and docs files; counts only, never a subject, a branch name or a path (0.9.2) |
|
|
179
180
|
| `collector_version` | the CLI version that measured it |
|
|
180
181
|
| `seq`, `prev`, `hash` | the line's place, the hash of the line before it, and its own hash |
|
|
181
182
|
|
package/log-session.mjs
CHANGED
|
@@ -153,6 +153,31 @@ const contextFilesOf = (paths) => { const out = {}; for (const path of paths) fo
|
|
|
153
153
|
const AI_COAUTHOR = /\b(claude|anthropic|codex|openai|chatgpt|copilot|cursor|devin|gemini|jules|aider|windsurf|cline)\b/i;
|
|
154
154
|
/** A path that holds tests, by the conventions of the common test runners (read here; the path never leaves). */
|
|
155
155
|
const TEST_PATH = /(^|[\\/])(__tests__|tests?|spec|e2e)[\\/]|\.(test|spec)\.[cm]?[jt]sx?$|_test\.(go|py|rb)$|(^|[\\/])test_[^\\/]+\.py$|Tests?\.(java|kt|cs|swift)$/;
|
|
156
|
+
/**
|
|
157
|
+
* THE ROUTE FROM GIT (0.9.2), of the stretch's own commits, read here and never kept: commits over twenty files, a fix
|
|
158
|
+
* that followed another commit of the stretch, a commit naming an issue (#12, ABC-123); and of the changed files, how
|
|
159
|
+
* many are CI, scripts or docs (what lets another person run it again). Subjects and paths never leave.
|
|
160
|
+
*/
|
|
161
|
+
const CI_PATH = /(^|[\\/])\.github[\\/]workflows[\\/]|(^|[\\/])\.gitlab-ci\.ya?ml$|(^|[\\/])Jenkinsfile$|(^|[\\/])\.circleci[\\/]|(^|[\\/])azure-pipelines\.ya?ml$/;
|
|
162
|
+
const SCRIPT_PATH = /(^|[\\/])scripts?[\\/]|(^|[\\/])Makefile$|(^|[\\/])justfile$|\.(sh|ps1)$/;
|
|
163
|
+
const DOC_PATH = /(^|[\\/])docs?[\\/]|(^|[\\/])README(\.[a-z]+)?$|(^|[\\/])CHANGELOG\.md$/i;
|
|
164
|
+
const FIX_SUBJECT = /^(fix|hotfix|revert)\b/i, ISSUE_REF = /#\d+\b|\b[A-Z][A-Z0-9]+-\d+\b/;
|
|
165
|
+
const gitRouteOf = (cwd, shas, paths) => {
|
|
166
|
+
const out = {};
|
|
167
|
+
if (cwd && shas.length > 0) {
|
|
168
|
+
const commits = git(cwd, "log", "--no-walk", "--date-order", "--reverse", "--format=%x1e%s", "--shortstat", ...shas.slice(0, 50)).split("\x1e").map((block) => block.trim()).filter(Boolean)
|
|
169
|
+
.map((block) => ({ subject: block.split("\n")[0], files: Number(/(\d+) files? changed/.exec(block)?.[1] ?? 0) }));
|
|
170
|
+
const large = commits.filter((commit) => commit.files > 20).length, fixes = commits.slice(1).filter((commit) => FIX_SUBJECT.test(commit.subject)).length, issues = commits.filter((commit) => ISSUE_REF.test(commit.subject)).length;
|
|
171
|
+
if (large) out.commits_large = large;
|
|
172
|
+
if (fixes) out.fix_followups = fixes;
|
|
173
|
+
if (issues) out.issue_refs = issues;
|
|
174
|
+
}
|
|
175
|
+
const ci = paths.filter((path) => CI_PATH.test(path)).length, scripts = paths.filter((path) => SCRIPT_PATH.test(path)).length, docs = paths.filter((path) => DOC_PATH.test(path)).length;
|
|
176
|
+
if (ci) out.ci_files = ci;
|
|
177
|
+
if (scripts) out.script_files = scripts;
|
|
178
|
+
if (docs) out.doc_files = docs;
|
|
179
|
+
return out;
|
|
180
|
+
};
|
|
156
181
|
/** The derived record of a stretch, kept for the local archive only (see payloadFor). */
|
|
157
182
|
const DERIVED = new WeakMap();
|
|
158
183
|
const AGENT_RUNS_MAX = 10000, AGENT_SECONDS_MAX = 2592000;
|
|
@@ -622,7 +647,8 @@ function payloadFor(stretch) {
|
|
|
622
647
|
const changed = [...new Set(touched.paths)], tests = changed.filter((path) => TEST_PATH.test(path)).length;
|
|
623
648
|
// 0.8.7: of the stretch's commits, how many name an AI as co-author (the Co-authored-by trailer, read here, never kept).
|
|
624
649
|
const coauthored = cwd && touched.shas.length > 0 ? git(cwd, "log", "--no-walk", "--format=%(trailers:key=Co-authored-by,valueonly,separator=%x01)%x00", ...touched.shas.slice(0, 50)).split("\0").filter((entry, index) => index < Math.min(50, touched.shas.length) && AI_COAUTHOR.test(entry)).length : 0;
|
|
625
|
-
const
|
|
650
|
+
const route = { ...(stretch.derived?.route ?? {}), ...(touched.committed ? gitRouteOf(cwd, touched.shas, changed) : {}) };
|
|
651
|
+
const derived = stretch.derived ? { ...stretch.derived, ...(Object.keys(route).length > 0 ? { route } : {}), ...(changed.length > 0 ? { changes: { files: changed.length, test_files: tests } } : {}), ...(touched.shas.length > 0 ? { authorship: { commits: Math.min(50, touched.shas.length), ai_coauthored: coauthored } } : {}), ...(contextFilesOf(changed) ? { context_files: contextFilesOf(changed) } : {}), ...(complexityOf ? { complexity: complexityOf(stretch.derived, { layers: Math.max(layers.length, layer ? 1 : 0), agentRuns: stretch.agents?.runs ?? 0, agentPeak: stretch.agents?.peak ?? 0, seconds: stretch.seconds }) } : {}) } : null;
|
|
626
652
|
const payload = {
|
|
627
653
|
title: layer ? `AI-assisted work · ${layer}` : "AI-assisted work",
|
|
628
654
|
kind,
|
package/package.json
CHANGED
package/preserve-lines.mjs
CHANGED
|
@@ -122,6 +122,11 @@ export function archiveLine(entry, behaviour = null, { ids = {}, collector, salt
|
|
|
122
122
|
if (typeof entry.hygiene.checked_after_delivery === "boolean") hygiene.checked_after_delivery = entry.hygiene.checked_after_delivery;
|
|
123
123
|
if (Object.keys(hygiene).length > 0) line.hygiene = hygiene;
|
|
124
124
|
}
|
|
125
|
+
// 0.9.2: the route the work took; whole counts only.
|
|
126
|
+
if (entry.route && typeof entry.route === "object") {
|
|
127
|
+
const route = Object.fromEntries(ROUTE_KEYS.filter((key) => whole(entry.route[key])).map((key) => [key, entry.route[key]]));
|
|
128
|
+
if (Object.keys(route).length > 0) line.route = route;
|
|
129
|
+
}
|
|
125
130
|
const risk = pick(entry.risk, ["proposed", "refused", "run"]);
|
|
126
131
|
if (risk && risk.proposed > 0 && risk.refused + risk.run <= risk.proposed) line.risk = risk;
|
|
127
132
|
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; };
|
|
@@ -181,10 +186,12 @@ export function archiveEntries(dir, ownKey) {
|
|
|
181
186
|
/** The furthest step a stretch reached on the computer (0.8.9). */
|
|
182
187
|
const STAGES = ["attempted", "verified", "committed", "pushed", "pr", "deployed"];
|
|
183
188
|
/** How fast a stretch moved (0.9.0). */
|
|
189
|
+
/** The route the work took (0.9.2). */
|
|
190
|
+
const ROUTE_KEYS = ["branches", "pushes_to_main", "commits_large", "fix_followups", "issue_refs", "ci_files", "script_files", "doc_files"];
|
|
184
191
|
/** Risk and hygiene (0.9.1). */
|
|
185
192
|
const HYGIENE_KEYS = ["rollbacks", "privileged", "bypasses", "secrets", "destructive", "destructive_checked", "guard_retried", "guard_changed", "guard_stopped"];
|
|
186
193
|
const TIMING_KEYS = ["first_action_s", "first_check_s", "detect_actions", "detect_s", "recovery_calls", "resume_actions"];
|
|
187
|
-
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", "hygiene", "interrupts", "steers", "utc_offset"];
|
|
194
|
+
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", "hygiene", "route", "interrupts", "steers", "utc_offset"];
|
|
188
195
|
export function supplementFor(line, earlier) {
|
|
189
196
|
const missing = DERIVED_KEYS.filter((key) => line[key] !== undefined && !earlier.some((old) => old[key] !== undefined));
|
|
190
197
|
if (missing.length === 0) return null;
|
package/stretch-evidence.mjs
CHANGED
|
@@ -46,6 +46,9 @@ const MARKS = [
|
|
|
46
46
|
["rollback", /\bgit\s+(revert|restore)\b|\bgit\s+reset\s+--hard\b|\b(vercel|fly|netlify)\s+rollback\b|\bkubectl\s+rollout\s+undo\b/],
|
|
47
47
|
["privilege", /(^|[\s;&|])sudo\s|\bgit\s+push\b[^\n]*\s(-f|--force(-with-lease)?)\b|\bchmod\s+(-R\s+)?777\b/],
|
|
48
48
|
["bypass", /\s--no-verify\b/],
|
|
49
|
+
// 0.9.2: the route the work took: a branch of its own, or a push straight to the default branch.
|
|
50
|
+
["branch", /\bgit\s+(checkout\s+-b|switch\s+-c)\s|\bgit\s+branch\s+(?!-)[\w./-]+/],
|
|
51
|
+
["push_main", /\bgit\s+push\b[^\n;&|]*\s(main|master)\b/],
|
|
49
52
|
];
|
|
50
53
|
const SECRET_FILE = /(^|[\/\s'"])(\.env(\.[\w-]+)?|id_(rsa|ed25519|ecdsa)|[\w.-]+\.(pem|p12|pfx|key)|credentials(\.json)?|\.npmrc|\.netrc|\.pgpass)(['"\s]|$)/;
|
|
51
54
|
const PRINTS = /\b(cat|less|more|head|tail|bat|type|Get-Content|grep|sed|awk|cp|scp|base64)\b/;
|
|
@@ -437,9 +440,22 @@ function hygieneOf(messages) {
|
|
|
437
440
|
return Object.keys(kept).length > 0 ? kept : null;
|
|
438
441
|
}
|
|
439
442
|
|
|
443
|
+
/** THE ROUTE (0.9.2), from the commands: branches made, pushes straight to the default branch that went through. */
|
|
444
|
+
function routeOf(messages) {
|
|
445
|
+
const results = new Map();
|
|
446
|
+
for (const message of messages) for (const result of message.results ?? []) results.set(result.id, result);
|
|
447
|
+
let branches = 0, pushesToMain = 0;
|
|
448
|
+
for (const message of messages) for (const call of message.calls ?? []) {
|
|
449
|
+
const marks = call.marks ?? [];
|
|
450
|
+
if (marks.includes("branch")) branches += 1;
|
|
451
|
+
if (marks.includes("push_main") && results.get(call.id)?.failed === false) pushesToMain += 1;
|
|
452
|
+
}
|
|
453
|
+
return branches + pushesToMain > 0 ? { ...(branches ? { branches } : {}), ...(pushesToMain ? { pushes_to_main: pushesToMain } : {}) } : null;
|
|
454
|
+
}
|
|
455
|
+
|
|
440
456
|
/** The stretch's whole derived record; `helpers` are the hook's own readers of a human turn, so both read it the same way. */
|
|
441
457
|
export function deriveStretch(messages, helpers) {
|
|
442
458
|
const context = contextOf(messages, helpers), routing = routingOf(messages), steering = steeringOf(messages, helpers);
|
|
443
|
-
const timing = timingOf(messages, helpers), hygiene = hygieneOf(messages), tools = toolsOf(messages), oversight = oversightOf(messages), planning = planningOf(messages), autonomy = autonomyOf(messages), practice = practiceOf(messages, helpers);
|
|
444
|
-
return { ...(practice ?? {}), ...(oversight ? { oversight } : {}), ...(planning ? { planning } : {}), ...(autonomy ? { autonomy } : {}), ...verificationOf(messages, helpers), ...(context ? { context } : {}), ...(routing ? { routing } : {}), ...(steering ? { steering } : {}), ...(tools ? { tools } : {}), ...(timing ? { timing } : {}), ...(hygiene ? { hygiene } : {}) };
|
|
459
|
+
const timing = timingOf(messages, helpers), hygiene = hygieneOf(messages), route = routeOf(messages), tools = toolsOf(messages), oversight = oversightOf(messages), planning = planningOf(messages), autonomy = autonomyOf(messages), practice = practiceOf(messages, helpers);
|
|
460
|
+
return { ...(practice ?? {}), ...(oversight ? { oversight } : {}), ...(planning ? { planning } : {}), ...(autonomy ? { autonomy } : {}), ...verificationOf(messages, helpers), ...(context ? { context } : {}), ...(routing ? { routing } : {}), ...(steering ? { steering } : {}), ...(tools ? { tools } : {}), ...(timing ? { timing } : {}), ...(hygiene ? { hygiene } : {}), ...(route ? { route } : {}) };
|
|
445
461
|
}
|
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.9.
|
|
76
|
+
const CLI_VERSION = "0.9.2";
|
|
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");
|