cocheck 0.4.0 → 0.4.1
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 +17 -3
- package/dist/agent-transcripts.js +15 -12
- package/dist/attribution/evidence.js +2 -1
- package/dist/attribution/reconstruct.js +19 -0
- package/dist/attribution/tag.js +3 -3
- package/dist/build-info.json +1 -1
- package/dist/cli.js +31 -11
- package/dist/connector/export-view.js +1 -1
- package/dist/coverage.js +5 -3
- package/dist/credit-guard.js +59 -54
- package/dist/harness-cmd/create.js +76 -0
- package/dist/harness-cmd/index.js +19 -0
- package/dist/harness-cmd/record.js +327 -0
- package/dist/harness-cmd/scrub.js +25 -0
- package/dist/harness-cmd/test.js +318 -0
- package/dist/harnesses/README.md +5 -0
- package/dist/harnesses/claude/cocheck-harness.json +344 -0
- package/dist/harnesses/codex/cocheck-harness.json +212 -0
- package/dist/harnesses/copilot/cocheck-harness.json +296 -0
- package/dist/{copilot-helpers.js → helper-linker.js} +43 -32
- package/dist/hook-adapter.js +287 -63
- package/dist/hook-cli.js +73 -36
- package/dist/hook-journal.js +40 -12
- package/dist/hosts/claude.js +23 -159
- package/dist/hosts/codex.js +41 -81
- package/dist/hosts/compile.js +275 -0
- package/dist/hosts/copilot.js +7 -162
- package/dist/hosts/extras.js +55 -0
- package/dist/hosts/harnesses.js +66 -0
- package/dist/hosts/index.js +176 -8
- package/dist/hosts/install-block.js +332 -0
- package/dist/hosts/manifest.js +372 -0
- package/dist/hosts/shared.js +21 -0
- package/dist/hosts/tool-classes.js +6 -0
- package/dist/hosts/types.js +1 -0
- package/dist/install.js +69 -22
- package/dist/ledger.js +11 -0
- package/dist/normalize.js +33 -9
- package/dist/open-pick.js +5 -3
- package/dist/patch-secrets.js +11 -11
- package/dist/review-server.js +2 -2
- package/dist/timeline/attribution.js +2 -2
- package/dist/timeline/describe.js +20 -17
- package/dist/timeline/load.js +2 -2
- package/dist/timeline/rail/assets/review.js +1 -1
- package/dist/timeline/rail/model.js +8 -8
- package/dist/timeline/read-signal.js +4 -4
- package/dist/timeline/render/view-v1.js +2 -13
- package/dist/timeline/runs.js +9 -9
- package/dist/timeline/timeline.js +8 -8
- package/dist/timeline/write-signal.js +4 -3
- package/package.json +2 -2
- package/public-kit/harness/GUIDE.md +81 -0
- package/public-kit/harness/README.md +10 -0
- package/public-kit/harness/cases/claude/shell-writes-file.json +120 -0
- package/public-kit/harness/cases/codex/apply-patch-writes-files.json +177 -0
- package/public-kit/harness/cases/codex/helper-writes-file.json +160 -0
- package/public-kit/harness/cases/codex/shell-writes-and-fails.json +110 -0
- package/public-kit/harness/cases/copilot/camel-case-patch-and-failure.json +126 -0
- package/public-kit/harness/cases/copilot/helper-writes-file.json +209 -0
- package/public-kit/harness/cases/copilot/vscode-helper-writes-file.json +236 -0
- package/public-kit/harness/examples/toyagent/cases/write-notes.json +142 -0
- package/public-kit/harness/examples/toyagent/cocheck-harness.json +47 -0
- package/public-kit/harness/examples/toyagent/recordings/payloads.jsonl +8 -0
- package/public-kit/harness/harnesses/antigravity/README.md +32 -0
- package/public-kit/harness/harnesses/antigravity/cases/failed-edit.json +99 -0
- package/public-kit/harness/harnesses/antigravity/cases/helper-writes-file.json +270 -0
- package/public-kit/harness/harnesses/antigravity/cases/shell-ok-fail-and-denied.json +211 -0
- package/public-kit/harness/harnesses/antigravity/cases/write-then-edit.json +191 -0
- package/public-kit/harness/harnesses/antigravity/cocheck-harness.json +62 -0
- package/public-kit/harness/harnesses/antigravity/recordings/payloads.jsonl +63 -0
- package/public-kit/harness/harnesses/cursor/README.md +40 -0
- package/public-kit/harness/harnesses/cursor/cases/editor-write-edit-shell-helper.json +359 -0
- package/public-kit/harness/harnesses/cursor/cases/read-then-write-one-call-id.json +159 -0
- package/public-kit/harness/harnesses/cursor/cocheck-harness.json +67 -0
- package/public-kit/harness/harnesses/cursor/recordings/payloads.jsonl +28 -0
- package/public-kit/harness/scaffold/README.md +42 -0
- package/public-kit/harness/scaffold/cocheck-harness.json +72 -0
- package/public-kit/harness/scaffold/recordings/.gitkeep +0 -0
- package/public-kit/harness/spec/v1.md +286 -0
- package/scripts/hook-launch.sh +1 -1
package/dist/install.js
CHANGED
|
@@ -14,7 +14,7 @@ import { KEYCHAIN_SERVICE } from "./seal.js";
|
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
import { resolveAdapterHome } from "./hook-adapter.js";
|
|
16
16
|
import { platform, platformFor } from "./platform/index.js";
|
|
17
|
-
import {
|
|
17
|
+
import { activeOutsiderFingerprints, allProfiles, findProfile, installableKeys, loadOutsiderHarnesses, MARKER, outsiderHarnessDir, profileWithExtra, skippedHarnesses } from "./hosts/index.js";
|
|
18
18
|
import { addToRegistry, readRegistry, resolveFolder } from "./registry.js";
|
|
19
19
|
import { heartbeatFilePath, isReviewProcessFor, lockFilePath, portFilePath, readPortFile } from "./review-server.js";
|
|
20
20
|
import { cliCommand } from "./session-context.js";
|
|
@@ -25,7 +25,10 @@ const MIN_NODE = [22, 18, 0];
|
|
|
25
25
|
/** Where the launcher looks for Node after PATH. Same list as scripts/hook-launch.sh: Homebrew's stable opt/node paths first, then the plain bin links. */
|
|
26
26
|
const DEFAULT_NODE_SEARCH = "/opt/homebrew/opt/node/bin/node /usr/local/opt/node/bin/node /opt/homebrew/bin/node /usr/local/bin/node";
|
|
27
27
|
/** The cost the hook adds to every tool call of the hosts installed (`hosts` is their display names). docs/install.md states the same figure. */
|
|
28
|
-
|
|
28
|
+
/** The two hosts a comma list example names: the first and last listed. */
|
|
29
|
+
const listExample = () => { const k = installableKeys(); return `${k[0]},${k[k.length - 1]}`; };
|
|
30
|
+
const defaultTimingLabel = () => { const p = profileWithExtra("install-default"); return p.install?.timingLabel ?? p.displayName; };
|
|
31
|
+
export const hookTimingNote = (hosts, windows = false) => `every ${hosts.length === 0 ? defaultTimingLabel() : hosts.join(" or ")} tool call runs CoCheck's hook twice, before and after it. ${windows ? "It adds a little time to each call; no timing has been measured on Windows yet." : "Together that is held under 1 second per call (median: 457 ms, measured on a Mac)."}`;
|
|
29
32
|
/** True when a file under the `src/` next to `dist/` is newer than the built hook. No `src/` (a packaged build) means not stale. */
|
|
30
33
|
export function builtHookIsStale(hookPath) {
|
|
31
34
|
const distDir = path.dirname(hookPath);
|
|
@@ -67,7 +70,7 @@ function parseArgs(args) {
|
|
|
67
70
|
else if (a === "--for") {
|
|
68
71
|
const v = args[++i];
|
|
69
72
|
if (v === undefined || v.startsWith("--"))
|
|
70
|
-
throw new Refusal(
|
|
73
|
+
throw new Refusal(`--for needs a host (${installableKeys().join(", ")}), a comma list such as ${listExample()}, both, all or none`);
|
|
71
74
|
out.for = v;
|
|
72
75
|
}
|
|
73
76
|
else if (a === "--home" || a === "--folder") {
|
|
@@ -94,12 +97,12 @@ function checkNode(version) {
|
|
|
94
97
|
* The folder that marks a host as present: the host's own config folder (~/.claude or $CLAUDE_CONFIG_DIR, ~/.codex or $CODEX_HOME,
|
|
95
98
|
* ~/.copilot or $COPILOT_HOME). A host whose config file CoCheck owns (Copilot's hooks/cocheck.json) is marked by the folder above `hooks`.
|
|
96
99
|
*/
|
|
97
|
-
export function hostDir(profile, env, userHome) {
|
|
98
|
-
const file = profile.install.configFile(env, userHome);
|
|
100
|
+
export function hostDir(profile, env, userHome, project) {
|
|
101
|
+
const file = profile.install.configFile(env, userHome, project);
|
|
99
102
|
return profile.install.ownsFile === true ? path.dirname(path.dirname(file)) : path.dirname(file);
|
|
100
103
|
}
|
|
101
104
|
/** A host is present when its config folder exists on disk. A host's binary on PATH does not count: an install never creates a host's folder. */
|
|
102
|
-
export const hostPresent = (profile, env, userHome) => profile.install !== undefined && existsSync(hostDir(profile, env, userHome));
|
|
105
|
+
export const hostPresent = (profile, env, userHome, project) => profile.install !== undefined && existsSync(hostDir(profile, env, userHome, project));
|
|
103
106
|
/** Per host, whether its hooks ran lately, read from the hook journal's event lines (the newest `at` of each host). */
|
|
104
107
|
export function lastHookRuns(home) {
|
|
105
108
|
return new Map([...lastHookRunsDetailed(home)].map(([host, r]) => [host, r.at]));
|
|
@@ -126,7 +129,7 @@ export function lastHookRunsDetailed(home) {
|
|
|
126
129
|
const r = JSON.parse(l);
|
|
127
130
|
const at = Date.parse(r.at ?? "");
|
|
128
131
|
if (r.host !== undefined && !Number.isNaN(at) && at > (out.get(r.host)?.at ?? 0))
|
|
129
|
-
out.set(r.host, typeof r.version === "string" && r.version !== "" ? {
|
|
132
|
+
out.set(r.host, { at, ...(typeof r.version === "string" && r.version !== "" ? { version: r.version } : {}), ...(typeof r.event === "string" && r.event !== "" ? { event: r.event } : {}) });
|
|
130
133
|
}
|
|
131
134
|
}
|
|
132
135
|
catch {
|
|
@@ -150,10 +153,11 @@ export function ageText(ms) {
|
|
|
150
153
|
* The hosts `--for` names: one key, a comma list (`claude,copilot`), `both` (an alias for `claude,codex`), `all` (every host with an installer)
|
|
151
154
|
* or `none` (no host: the data home and review page only). No flag installs every host that is present (see hostPresent). Order and repeats do not matter.
|
|
152
155
|
*/
|
|
153
|
-
function hostsFor(value, env, userHome) {
|
|
156
|
+
function hostsFor(value, env, userHome, project) {
|
|
154
157
|
const withInstaller = allProfiles().filter((p) => p.install !== undefined);
|
|
158
|
+
// An outsider harness is never picked by presence or by `all`: only by its own key, and then CoCheck prints its hook snippet instead of editing its config.
|
|
155
159
|
if (value === undefined)
|
|
156
|
-
return withInstaller.filter((p) => hostPresent(p, env, userHome));
|
|
160
|
+
return withInstaller.filter((p) => p.trust !== "outsider" && hostPresent(p, env, userHome, project));
|
|
157
161
|
if (value === "none")
|
|
158
162
|
return [];
|
|
159
163
|
const keys = new Set();
|
|
@@ -163,13 +167,15 @@ function hostsFor(value, env, userHome) {
|
|
|
163
167
|
if (p.install?.inBothAlias === true)
|
|
164
168
|
keys.add(p.key);
|
|
165
169
|
}
|
|
166
|
-
else if (part === "all")
|
|
170
|
+
else if (part === "all") {
|
|
167
171
|
for (const p of withInstaller)
|
|
168
|
-
|
|
172
|
+
if (p.trust !== "outsider")
|
|
173
|
+
keys.add(p.key);
|
|
174
|
+
}
|
|
169
175
|
else if (withInstaller.some((p) => p.key === part))
|
|
170
176
|
keys.add(part);
|
|
171
177
|
else
|
|
172
|
-
throw new Refusal(`--for must be ${withInstaller.map((p) => p.key).join(", ")}, a comma list of them, both, all or none, not ${JSON.stringify(value)}`);
|
|
178
|
+
throw new Refusal(`--for must be ${withInstaller.map((p) => p.key).join(", ")}, a comma list of them, both, all or none, not ${JSON.stringify(value)}${skippedHarnesses().length > 0 ? `. Harness manifests that did not load: ${skippedHarnesses().join("; ")}` : ""}`);
|
|
173
179
|
}
|
|
174
180
|
return withInstaller.filter((p) => keys.has(p.key));
|
|
175
181
|
}
|
|
@@ -190,7 +196,7 @@ function backupOnce(file, backup) {
|
|
|
190
196
|
* Fires the hook once through the same launcher the settings will call, against a scratch home and folder, and returns an error text, or
|
|
191
197
|
* undefined when it recorded the event. The person's own PATH is used, so a Node that only the installer could find fails here too.
|
|
192
198
|
*/
|
|
193
|
-
export function hookFires(launcher, hookPath, env = process.env, install =
|
|
199
|
+
export function hookFires(launcher, hookPath, env = process.env, install = profileWithExtra("install-default").install, plat = platform()) {
|
|
194
200
|
const scratch = mkdtempSync(path.join(tmpdir(), "cocheck-install-check-"));
|
|
195
201
|
try {
|
|
196
202
|
const home = path.join(scratch, "home");
|
|
@@ -198,7 +204,7 @@ export function hookFires(launcher, hookPath, env = process.env, install = defau
|
|
|
198
204
|
mkdirSync(folder);
|
|
199
205
|
addToRegistry(home, folder);
|
|
200
206
|
setTracking(home, install.hostFlag, "install-check", true, folder);
|
|
201
|
-
const check = install.checkPayload
|
|
207
|
+
const check = install.checkPayload(folder);
|
|
202
208
|
const payload = JSON.stringify(check.payload);
|
|
203
209
|
const hookArgs = ["--host", install.hostFlag, ...(check.event === undefined ? [] : ["--event", check.event]), ...(install.folderFromPayloadCwd === true ? [] : ["--folder", folder])];
|
|
204
210
|
// On Windows the host starts `node hook-launch.mjs ...` itself (no shell script), so the check does the same, with the data home as a launcher option.
|
|
@@ -256,6 +262,8 @@ function findNode(env, plat = platform()) {
|
|
|
256
262
|
/** What `cocheck status` prints and `cocheck open` prints first. Reads only; the reasons are the same ones the launcher writes and these checks add. */
|
|
257
263
|
export function installStatus(env, userHome, readHooksList, plat = platform()) {
|
|
258
264
|
const record = readInstallRecord(userHome);
|
|
265
|
+
if (record !== undefined)
|
|
266
|
+
loadOutsiderHarnesses(outsiderHarnessDir(env, record.home));
|
|
259
267
|
if (record === undefined) {
|
|
260
268
|
const reason = "CoCheck is not installed (no install record). Run: cocheck install --home <dir> --for <host>";
|
|
261
269
|
return { recording: false, reasons: [reason], text: `CoCheck: not recording. ${reason}\n` };
|
|
@@ -277,9 +285,18 @@ export function installStatus(env, userHome, readHooksList, plat = platform()) {
|
|
|
277
285
|
return "hooks have not fired yet";
|
|
278
286
|
return `hooks last fired ${ageText(Date.now() - last.at)} (${new Date(last.at).toISOString()})${last.version === undefined ? "" : `, by CoCheck ${last.version}`}`;
|
|
279
287
|
};
|
|
288
|
+
// The last event seen for a harness, from the same journal lines: its own line under the harness's state.
|
|
289
|
+
const lastEvent = (key) => {
|
|
290
|
+
const last = ran.get(key);
|
|
291
|
+
return last === undefined ? " no event seen yet\n" : ` last event: ${last.event ?? "(unnamed)"}, ${ageText(Date.now() - last.at)} (${new Date(last.at).toISOString()})\n`;
|
|
292
|
+
};
|
|
280
293
|
for (const profile of allProfiles()) {
|
|
281
294
|
const install = profile.install;
|
|
282
295
|
const entry = recorded.find((h) => h.host === profile.key);
|
|
296
|
+
if (profile.trust === "outsider") {
|
|
297
|
+
states.push(` ${profile.displayName} (your harness):\n${lastEvent(profile.key)}`);
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
283
300
|
if (install === undefined || entry === undefined) {
|
|
284
301
|
states.push(` ${profile.displayName}: not installed\n`);
|
|
285
302
|
continue;
|
|
@@ -300,7 +317,7 @@ export function installStatus(env, userHome, readHooksList, plat = platform()) {
|
|
|
300
317
|
states.push(` ${profile.displayName}: installed, hooks not trusted (${entry.configFile})\n`);
|
|
301
318
|
}
|
|
302
319
|
else
|
|
303
|
-
states.push(` ${profile.displayName}: installed (${entry.configFile}); ${fired(profile.key)}\n`);
|
|
320
|
+
states.push(` ${profile.displayName}: installed (${entry.configFile}); ${fired(profile.key)}\n${lastEvent(profile.key)}`);
|
|
304
321
|
}
|
|
305
322
|
const note = install.notes?.({ launcherDir: path.dirname(path.dirname(record.launcher)), home: record.home });
|
|
306
323
|
if (note !== undefined)
|
|
@@ -312,8 +329,22 @@ export function installStatus(env, userHome, readHooksList, plat = platform()) {
|
|
|
312
329
|
states.push(` ${profile.displayName}: config unreadable\n`);
|
|
313
330
|
}
|
|
314
331
|
}
|
|
332
|
+
// An outsider harness that also runs other hosts' hooks, with its own CoCheck hook installed: those hosts' hooks skip its payloads (see `runsOtherHostsHook`).
|
|
333
|
+
let watched = [];
|
|
334
|
+
try {
|
|
335
|
+
watched = readRegistry(record.home) ?? [];
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
// an unreadable registry: only the install's own folder is looked at
|
|
339
|
+
}
|
|
340
|
+
for (const a of activeOutsiderFingerprints(env, userHome, [...new Set([record.folder, ...watched])])) {
|
|
341
|
+
states.push(` ${a.skippedBy.join(" and ")} ${a.skippedBy.length === 1 ? "hook skips" : "hooks skip"} payloads from ${a.profile.displayName} (its CoCheck hook is in ${a.configFile})\n`);
|
|
342
|
+
}
|
|
343
|
+
// A harness manifest in the person's folder that did not load: named here, and it never stops another host.
|
|
344
|
+
for (const line of skippedHarnesses())
|
|
345
|
+
states.push(` Harness manifest skipped: ${line}\n`);
|
|
315
346
|
if (recorded.length === 0)
|
|
316
|
-
reasons.push(
|
|
347
|
+
reasons.push(`no host has CoCheck's hooks (it was installed with --for none), so nothing is recorded. Run the installer again with --for (${installableKeys().join(", ")}, both or all)`);
|
|
317
348
|
// What this OS cannot do, one plain line each. The per-call tag finds its call through the process tree and a POSIX shell comment, so it works on macOS only.
|
|
318
349
|
const absent = `${plat.office.liveExcel ? "" : " Live Excel: not available on this system; CoCheck reads saved files only, not a workbook that is open.\n"}${plat.shellDialect.kind === "posix" ? "" : " Per-call tag: not available on this system; writes are attributed by timing, not by which command made them.\n"}`;
|
|
319
350
|
const node = findNode(env, plat);
|
|
@@ -414,18 +445,25 @@ export async function runInstall(run) {
|
|
|
414
445
|
let stdout = "";
|
|
415
446
|
try {
|
|
416
447
|
const args = parseArgs(run.argv.slice(2));
|
|
448
|
+
loadOutsiderHarnesses(outsiderHarnessDir(run.env, args.home !== undefined && path.isAbsolute(args.home) ? path.resolve(args.home) : undefined));
|
|
417
449
|
const plat = platformFor(run.platform ?? process.platform);
|
|
418
450
|
const windows = plat.shellDialect.kind === "cmd";
|
|
419
451
|
const userHome = (windows ? run.env.USERPROFILE : undefined) || run.env.HOME || homedir();
|
|
420
452
|
// An uninstall with no --for reverses every host the install record lists (else the hosts present); an install detects the hosts present.
|
|
421
453
|
const recordedKeys = args.uninstall && args.for === undefined ? readInstallRecord(userHome) : undefined;
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
454
|
+
// The task folder, for a harness whose hook config sits in the project ({project} in its install path). An install replaces it with the
|
|
455
|
+
// resolved folder below, before any config is read or written; an uninstall reads the folder the install recorded.
|
|
456
|
+
let project = path.resolve(run.cwd, args.folder ?? (args.uninstall ? readInstallRecord(userHome)?.folder : undefined) ?? run.cwd);
|
|
457
|
+
const wanted = recordedKeys !== undefined ? allProfiles().filter((p) => p.install !== undefined && recordedKeys.hosts.some((h) => h.host === p.key)) : hostsFor(args.for, run.env, userHome, project);
|
|
458
|
+
// CoCheck edits only a built-in host's config. For an outsider harness it prints the entries to add (and, on uninstall, says there is nothing to remove).
|
|
459
|
+
const targets = wanted.filter((p) => p.trust !== "outsider");
|
|
460
|
+
const printed = wanted.filter((p) => p.trust === "outsider");
|
|
461
|
+
const defaultInstall = profileWithExtra("install-default").install;
|
|
462
|
+
const settingsFile = defaultInstall.configFile(run.env, userHome);
|
|
425
463
|
const backupFile = `${settingsFile}.cocheck-backup`;
|
|
426
464
|
const readText = (file) => (existsSync(file) ? readFileSync(file, "utf8") : "");
|
|
427
465
|
const placeOf = (profile) => {
|
|
428
|
-
const configFile = profile.install.configFile(run.env, userHome);
|
|
466
|
+
const configFile = profile.install.configFile(run.env, userHome, project);
|
|
429
467
|
return { profile, install: profile.install, configFile, backupFile: `${configFile}.cocheck-backup` };
|
|
430
468
|
};
|
|
431
469
|
if (args.uninstall) {
|
|
@@ -505,6 +543,8 @@ export async function runInstall(run) {
|
|
|
505
543
|
stdout += ` settings backup: ${existsSync(r.backupFile) ? `${r.backupFile}, a copy of your settings made by the first install` : "none was made"}.\n`;
|
|
506
544
|
if (removals.length === 0)
|
|
507
545
|
stdout += " settings backup: none was made.\n";
|
|
546
|
+
for (const p of printed)
|
|
547
|
+
stdout += ` ${p.displayName}: CoCheck never edited this harness's config; delete the CoCheck entries you added to ${p.install.configFile(run.env, userHome, project)}.\n`;
|
|
508
548
|
return { exitCode: 0, stdout, stderr: "" };
|
|
509
549
|
}
|
|
510
550
|
if (!["darwin", "win32"].includes(run.platform ?? process.platform))
|
|
@@ -532,6 +572,7 @@ export async function runInstall(run) {
|
|
|
532
572
|
if (!existsSync(folderArg) || !statSync(folderArg).isDirectory())
|
|
533
573
|
throw new Refusal(`${folderArg} is not a folder`);
|
|
534
574
|
const folder = resolveFolder(folderArg);
|
|
575
|
+
project = folder;
|
|
535
576
|
// CoCheck owns every file in its data folder (it sets their modes), so that folder must be one nothing of the person's lives in.
|
|
536
577
|
const homeOwners = [userHome, plat.paths.userHome()];
|
|
537
578
|
for (const owner of homeOwners) {
|
|
@@ -638,9 +679,9 @@ export async function runInstall(run) {
|
|
|
638
679
|
stdout += `CoCheck records the folder your agent is opened in. The install check ran in ${folder}\n`;
|
|
639
680
|
// What was written where, per host; a host that was not present is named so the person sees why nothing went there.
|
|
640
681
|
if (args.for === undefined) {
|
|
641
|
-
const absent = allProfiles().filter((p) => p.install !== undefined && !plans.some((x) => x.profile.key === p.key));
|
|
682
|
+
const absent = allProfiles().filter((p) => p.install !== undefined && p.trust !== "outsider" && !plans.some((x) => x.profile.key === p.key));
|
|
642
683
|
if (plans.length === 0)
|
|
643
|
-
stdout += `No host found: none of ${absent.map((p) => hostDir(p, run.env, userHome)).join(", ")} exists, so no hooks or skill were installed. Start the host once, or name it with --for.\n`;
|
|
684
|
+
stdout += `No host found: none of ${absent.map((p) => hostDir(p, run.env, userHome, folder)).join(", ")} exists, so no hooks or skill were installed. Start the host once, or name it with --for.\n`;
|
|
644
685
|
else if (absent.length > 0)
|
|
645
686
|
stdout += `Not installed (no config folder found): ${absent.map((p) => p.displayName).join(", ")}.\n`;
|
|
646
687
|
}
|
|
@@ -648,6 +689,12 @@ export async function runInstall(run) {
|
|
|
648
689
|
const skillFile = path.join(userHome, skillRootOf(p.profile.key), "cocheck", "SKILL.md");
|
|
649
690
|
stdout += `${p.profile.displayName}: hooks in ${p.configFile}; ${skillSkipped.includes(skillFile) ? `skill NOT written, ${skillFile} is not CoCheck's and stays` : `skill in ${skillFile}`}.\n`;
|
|
650
691
|
}
|
|
692
|
+
for (const p of printed) {
|
|
693
|
+
const install = p.install;
|
|
694
|
+
const configFile = install.configFile(run.env, userHome, folder);
|
|
695
|
+
const entries = install.addHooks("", configFile, { dataHome, launcher, hookPath, host: install.hostFlag, ...(pinned === undefined ? {} : { node: pinned }) }, plat);
|
|
696
|
+
stdout += `${p.displayName}: CoCheck does not edit the config of a harness it does not ship with. Add these hooks to ${configFile} (merge them into any hooks already there):\n${entries}`;
|
|
697
|
+
}
|
|
651
698
|
stdout += "Every session starts untracked. In a session, say \"start tracking\" (the cocheck skill runs `cocheck track start`) and \"stop tracking\" to switch it.\n";
|
|
652
699
|
// A source checkout is run as `node scripts/cocheck.ts`; a packaged install (no scripts/cocheck.ts) has `cocheck` on PATH.
|
|
653
700
|
const cli = cliCommand(root);
|
package/dist/ledger.js
CHANGED
|
@@ -1937,6 +1937,17 @@ export class Ledger {
|
|
|
1937
1937
|
}
|
|
1938
1938
|
return [...ids];
|
|
1939
1939
|
}
|
|
1940
|
+
/**
|
|
1941
|
+
* Whether the task's session ran `cocheck track stop` and has done nothing since: its newest op, leaving out ops written on its behalf
|
|
1942
|
+
* by other events (words found late, another session's call, a drop note), is the stop mark.
|
|
1943
|
+
*/
|
|
1944
|
+
trackingStoppedLast(taskId) {
|
|
1945
|
+
const r = this.#db
|
|
1946
|
+
.prepare(`SELECT json_extract(args_json, '$.hookEvent') AS e FROM ops WHERE task_id = ?
|
|
1947
|
+
AND COALESCE(json_extract(args_json, '$.hookEvent'), '') NOT IN ('LateNarration', 'OtherSessionCall', 'Dropped') ORDER BY id DESC LIMIT 1`)
|
|
1948
|
+
.get(taskId);
|
|
1949
|
+
return r?.e === "TrackingStopped";
|
|
1950
|
+
}
|
|
1940
1951
|
/** The first request the person typed in a task (a recorded UserPromptSubmit, a wake notification skipped), as typed; undefined when none is recorded. */
|
|
1941
1952
|
firstPromptForTask(taskId) {
|
|
1942
1953
|
const rows = this.#db.prepare("SELECT args_json FROM ops WHERE task_id = ? AND instr(args_json, 'UserPromptSubmit') > 0 ORDER BY id").all(taskId);
|
package/dist/normalize.js
CHANGED
|
@@ -9,7 +9,7 @@ import { SHARED_EVENT_KINDS } from "./hosts/types.js";
|
|
|
9
9
|
/** The version of the NormalizedEvent shape; a consumer refuses any other. */
|
|
10
10
|
const NORMALIZED_VERSION = 1;
|
|
11
11
|
/** Every host event name the adapter handles; the installer must register exactly these. */
|
|
12
|
-
export const HANDLED_EVENTS = Object.
|
|
12
|
+
export const HANDLED_EVENTS = Object.entries(SHARED_EVENT_KINDS).filter(([, kind]) => kind !== "other").map(([name]) => name);
|
|
13
13
|
/** Throws for a host that is not wired or a null payload. Never throws for a field of an odd type. */
|
|
14
14
|
export function normalize(host, raw, eventArg) {
|
|
15
15
|
if (!isHostKey(host))
|
|
@@ -19,7 +19,7 @@ export function normalize(host, raw, eventArg) {
|
|
|
19
19
|
// `null` threw (a TypeError, exit 1) before the normalizer existed; any other JSON value read as an event with no fields and was ignored (exit 0).
|
|
20
20
|
if (raw === null || raw === undefined)
|
|
21
21
|
throw new Error("hook payload is null");
|
|
22
|
-
const p = raw;
|
|
22
|
+
const p = profile.readPayload === undefined ? raw : profile.readPayload(raw, eventArg);
|
|
23
23
|
// A host whose payload names no event is told it by the hook command (`--event`).
|
|
24
24
|
const eventName = (profile.eventFromArg === true ? eventArg : p[f.eventName]);
|
|
25
25
|
const named = (typeof eventName === "string" && Object.hasOwn(profile.eventKinds, eventName) ? profile.eventKinds[eventName] : undefined) ?? "other";
|
|
@@ -29,7 +29,8 @@ export function normalize(host, raw, eventArg) {
|
|
|
29
29
|
const rawInput = profile.parseToolInput === undefined ? p[f.toolInput] : profile.parseToolInput(p[f.toolInput]);
|
|
30
30
|
// The tool's own name (a host that joins a namespace onto it has it taken off here, once); every consumer reads this form.
|
|
31
31
|
const reported = p[f.toolName];
|
|
32
|
-
const
|
|
32
|
+
const action = perActionCall(profile.perAction, kind, p);
|
|
33
|
+
const toolName = action !== undefined ? action.tool : typeof reported === "string" && profile.toolName !== undefined ? profile.toolName(reported, p) : reported;
|
|
33
34
|
return {
|
|
34
35
|
v: NORMALIZED_VERSION,
|
|
35
36
|
host,
|
|
@@ -39,13 +40,13 @@ export function normalize(host, raw, eventArg) {
|
|
|
39
40
|
cwd: p[f.cwd],
|
|
40
41
|
toolName,
|
|
41
42
|
// The raw input of a file-writing call (a patch is the new file contents) is scrubbed here, once; every consumer reads this form.
|
|
42
|
-
toolInput: scrubToolInput(toolName, rawInput),
|
|
43
|
-
toolResponse: f.toolResponse === undefined ? undefined : p[f.toolResponse],
|
|
43
|
+
toolInput: scrubToolInput(toolName, action !== undefined ? action.input : rawInput, host),
|
|
44
|
+
toolResponse: action?.response !== undefined ? action.response : f.toolResponse === undefined ? undefined : p[f.toolResponse],
|
|
44
45
|
toolUseId: p[f.toolUseId],
|
|
45
46
|
agentId: p[f.agentId],
|
|
46
47
|
agentType: p[f.agentType],
|
|
47
|
-
...(profile.capabilities.launchKey && typeof p.
|
|
48
|
-
failure: scrubbedFailure(profile.failureOf(kind, p), toolName, rawInput),
|
|
48
|
+
...(profile.capabilities.launchKey && f.launchKey !== undefined && typeof p[f.launchKey] === "string" && p[f.launchKey] !== "" ? { launchKey: p[f.launchKey] } : {}),
|
|
49
|
+
failure: scrubbedFailure(profile.failureOf(kind, p), toolName, action !== undefined ? action.input : rawInput, host),
|
|
49
50
|
transcriptPath: p[f.transcriptPath],
|
|
50
51
|
...helperTranscript(host, p),
|
|
51
52
|
lastAssistantMessage: p[f.lastAssistantMessage],
|
|
@@ -57,9 +58,32 @@ export function normalize(host, raw, eventArg) {
|
|
|
57
58
|
synthetic: false,
|
|
58
59
|
};
|
|
59
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* A per-action event (`file-edit`, `shell-pre`, `shell-post`) read as a call of the tool the profile declares for it: the tool's name, the input
|
|
63
|
+
* in the shape that tool class's rules read (`file_path` with `edits` or `content`; `command`), and for a shell Post its result. Values pass through unchecked.
|
|
64
|
+
* Undefined for any other kind, or a host that declares no per-action events.
|
|
65
|
+
*/
|
|
66
|
+
function perActionCall(pa, kind, p) {
|
|
67
|
+
if (pa === undefined)
|
|
68
|
+
return undefined;
|
|
69
|
+
const k = pa.fields;
|
|
70
|
+
if (kind === "file-edit") {
|
|
71
|
+
const list = k.editList === undefined ? undefined : p[k.editList];
|
|
72
|
+
const content = k.editContent === undefined ? undefined : p[k.editContent];
|
|
73
|
+
const edits = Array.isArray(list) ? list.map((e) => (typeof e === "object" && e !== null ? { old_string: e.old_string, new_string: e.new_string } : e)) : undefined;
|
|
74
|
+
return { tool: pa.fileEditTool, input: { file_path: p[k.editPath], ...(typeof content === "string" ? { content } : edits !== undefined ? { edits } : {}) } };
|
|
75
|
+
}
|
|
76
|
+
if (kind === "shell-pre" || kind === "shell-post") {
|
|
77
|
+
const exit = k.exitCode === undefined ? undefined : p[k.exitCode];
|
|
78
|
+
const out = k.output === undefined ? undefined : p[k.output];
|
|
79
|
+
const response = kind === "shell-post" && (exit !== undefined || out !== undefined) ? { ...(exit === undefined ? {} : { exit_code: exit }), ...(out === undefined ? {} : { output: out }) } : undefined;
|
|
80
|
+
return { tool: pa.shellTool, input: { command: p[k.command] }, ...(response === undefined ? {} : { response }) };
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
60
84
|
/** A host's error text with echoes of a withheld patch section removed (see patch-secrets.ts). */
|
|
61
|
-
function scrubbedFailure(failure, tool, input) {
|
|
62
|
-
return failure == null || typeof failure.raw !== "string" ? failure : { ...failure, raw: scrubFailureText(failure.raw, tool, input) };
|
|
85
|
+
function scrubbedFailure(failure, tool, input, host) {
|
|
86
|
+
return failure == null || typeof failure.raw !== "string" ? failure : { ...failure, raw: scrubFailureText(failure.raw, tool, input, host) };
|
|
63
87
|
}
|
|
64
88
|
/** Throws unless `ev` is a NormalizedEvent of the version this build reads. */
|
|
65
89
|
export function assertNormalized(ev) {
|
package/dist/open-pick.js
CHANGED
|
@@ -6,6 +6,7 @@ import { createHash } from "node:crypto";
|
|
|
6
6
|
import { mkdirSync, readFileSync, readdirSync, realpathSync, rmSync } from "node:fs";
|
|
7
7
|
import { writeFileAtomicSync } from "./home-perms.js";
|
|
8
8
|
import path from "node:path";
|
|
9
|
+
import { sessionOfEnv } from "./hosts/index.js";
|
|
9
10
|
import { HOOK_PREFIX, HOOK_SESSION_MARK, stripHookSession } from "./tasks.js";
|
|
10
11
|
const OPEN_DIR = "open-requests";
|
|
11
12
|
/** A record older than this no longer says which session asked. */
|
|
@@ -82,9 +83,10 @@ export function chooseOpenTask(tasks, cwd, env, records, now) {
|
|
|
82
83
|
if (sessions.size === 1)
|
|
83
84
|
return { task: newest(here1).id };
|
|
84
85
|
// Several sessions worked in this folder: only a session that asked decides.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
86
|
+
// A host that sets its session id in the shell of its session (`sessionEnv`) names the asking session itself.
|
|
87
|
+
for (const own of sessionOfEnv(env)) {
|
|
88
|
+
const id = sanitize(own.session);
|
|
89
|
+
const mine = here1.filter((t) => t.client.startsWith(`${own.host}-hook:`) && sessionOfClient(t.client) === id);
|
|
88
90
|
if (mine.length > 0)
|
|
89
91
|
return { task: newest(mine).id };
|
|
90
92
|
}
|
package/dist/patch-secrets.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// treatment a Write's content gets. A section whose file is a secret path (src/secret-files.ts) or whose lines hold a gitleaks-shaped value
|
|
3
3
|
// (src/secret-scan.ts) is withheld; the headers stay, so the timeline still names the files. Bound: the same detector as every other secret
|
|
4
4
|
// check (gitleaks default rules plus the secret-path list); a password in free prose with no vendor format is not detected.
|
|
5
|
-
import { allProfiles } from "./hosts/index.js";
|
|
5
|
+
import { allProfiles, toolEntryOf } from "./hosts/index.js";
|
|
6
6
|
import { isSecretPath } from "./secret-files.js";
|
|
7
7
|
import { firstSecretRule } from "./secret-scan.js";
|
|
8
8
|
const HEADER = /^\*\*\* (Add File|Update File|Delete File|Move to):[ \t]*(.+?)[ \t]*$/;
|
|
@@ -97,16 +97,16 @@ function leaves(v, out = [], depth = 0) {
|
|
|
97
97
|
leaves(x, out, depth + 1);
|
|
98
98
|
return out;
|
|
99
99
|
}
|
|
100
|
-
/** The tools that carry a patch (
|
|
101
|
-
export const isPatchTool = (tool) => typeof tool === "string" && /
|
|
100
|
+
/** The tools that carry a patch (class `patch` in the host's table), by name, in any namespaced form. With no host the built-in tables are read together. */
|
|
101
|
+
export const isPatchTool = (tool, host) => typeof tool === "string" && toolEntryOf(host, tool.slice(tool.search(/[^.:/]*$/)), true)?.class === "patch";
|
|
102
102
|
/** The input fields of a patch tool that hold the patch text. Anything else in an input (and every other tool's input) is left to the secret-content filter. */
|
|
103
103
|
const PATCH_FIELDS = ["input", "patch", "command", "diff"];
|
|
104
104
|
/**
|
|
105
105
|
* A patch tool's input with its patch text scrubbed (the input itself when it is the text, else the patch-carrying fields); the one form the
|
|
106
106
|
* adapter reads. Any other tool's input passes through untouched, so a Write whose content merely holds a patch block is not altered.
|
|
107
107
|
*/
|
|
108
|
-
export function scrubToolInput(tool, v) {
|
|
109
|
-
if (!isPatchTool(tool))
|
|
108
|
+
export function scrubToolInput(tool, v, host) {
|
|
109
|
+
if (!isPatchTool(tool, host))
|
|
110
110
|
return v;
|
|
111
111
|
if (typeof v === "string")
|
|
112
112
|
return scrubPatchText(v);
|
|
@@ -120,13 +120,13 @@ export function scrubToolInput(tool, v) {
|
|
|
120
120
|
* (Copilot: `{textResultForLlm, ...}`). Every string inside one is scrubbed, so a sibling text field is covered too.
|
|
121
121
|
*/
|
|
122
122
|
const RESPONSE_FIELDS = ["error", "tool_response", "toolResult"];
|
|
123
|
-
function scrubTextDeep(v, tool, input, depth = 0) {
|
|
123
|
+
function scrubTextDeep(v, tool, input, depth = 0, host) {
|
|
124
124
|
if (typeof v === "string")
|
|
125
|
-
return scrubFailureText(v, tool, input);
|
|
125
|
+
return scrubFailureText(v, tool, input, host);
|
|
126
126
|
if (Array.isArray(v) && depth < 6)
|
|
127
|
-
return v.map((x) => scrubTextDeep(x, tool, input, depth + 1));
|
|
127
|
+
return v.map((x) => scrubTextDeep(x, tool, input, depth + 1, host));
|
|
128
128
|
if (v !== null && typeof v === "object" && depth < 6)
|
|
129
|
-
return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, scrubTextDeep(x, tool, input, depth + 1)]));
|
|
129
|
+
return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, scrubTextDeep(x, tool, input, depth + 1, host)]));
|
|
130
130
|
return v;
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
@@ -185,8 +185,8 @@ export function scrubPayloadBytes(bytes) {
|
|
|
185
185
|
return changed ? Buffer.from(JSON.stringify(obj)) : bytes;
|
|
186
186
|
}
|
|
187
187
|
/** Error text with each line that echoes a withheld patch line replaced, and any patch text in it scrubbed. */
|
|
188
|
-
export function scrubFailureText(text, tool, input) {
|
|
189
|
-
if (!isPatchTool(tool))
|
|
188
|
+
export function scrubFailureText(text, tool, input, host) {
|
|
189
|
+
if (!isPatchTool(tool, host))
|
|
190
190
|
return text;
|
|
191
191
|
const secret = leaves(input).flatMap(withheldLinesOf);
|
|
192
192
|
const lines = scrubPatchText(text).split("\n");
|
package/dist/review-server.js
CHANGED
|
@@ -499,9 +499,9 @@ async function handleView(ledger, home, deps, res, taskId, rawKey, wholeAsked) {
|
|
|
499
499
|
const rows = change.format?.rows ?? [];
|
|
500
500
|
const changeSentence = rows.length === 0 ? undefined : `${rows.slice(0, 3).map((r) => (r.text.startsWith(r.location) ? r.text : `${r.location}: ${r.text.replace(/^[a-z ]+: /, "")}`)).join("; ")}${rows.length > 3 ? ` (and ${rows.length - 3} more)` : ""}.`;
|
|
501
501
|
const view = await renderer.view(before, after, { ...(whole === undefined ? {} : { whole }), ...(changeSentence === undefined ? {} : { changeSentence }), id: change.id, file: change.file, kind: change.kind, generic: change.generic, missing: [...missing, ...(change.generic.readerCaveats ?? [])], signal: goneSignal(res) });
|
|
502
|
-
// The words of each
|
|
502
|
+
// The words of each change come from the rail model's own row notes (the path that scrubs paths and secrets); a secret file's model change has none.
|
|
503
503
|
const railChange = buildRailModel(timeline, { connectorFor: connectorMatcherFor(home) }).stops.flatMap((st) => (st.change !== undefined && st.change.key === change.id ? [st.change] : []))[0];
|
|
504
|
-
const words = {
|
|
504
|
+
const words = { rowNotes: railChange?.rowNotes ?? [] };
|
|
505
505
|
return send(res, 200, JSON.stringify(viewToV1(view, words)), "application/json; charset=utf-8", { "cache-control": "private, no-store" });
|
|
506
506
|
}
|
|
507
507
|
/**
|
|
@@ -10,9 +10,9 @@ import { knownHostLabel } from "../hosts/index.js";
|
|
|
10
10
|
/**
|
|
11
11
|
* The rail's lane ids. A helper's lane is `agent:<n>`, numbered by the rail in the order helpers appear.
|
|
12
12
|
* MAIN_LANE is a stored key, not a host decision: existing ledgers and pages carry the main lane as "claude" whatever host ran, so the
|
|
13
|
-
* value stays and the lane's shown name comes from the task's host profile (`hostName`).
|
|
13
|
+
* value stays and the lane's shown name comes from the task's host profile (`hostName`). Legacy key kept on purpose: never rename it.
|
|
14
14
|
*/
|
|
15
|
-
export const MAIN_LANE = "claude";
|
|
15
|
+
export const MAIN_LANE = "claude"; // legacy key kept on purpose: stored in ledger rows and the rail
|
|
16
16
|
export const OUTSIDE_LANE = "other";
|
|
17
17
|
export const UNSURE_LANE = "unsure";
|
|
18
18
|
export const HELPER_LANE = "agent:";
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
// Lines from c, c2 and d are CoCheck's, and say so.
|
|
10
10
|
import { baseName as pathBaseName, words, WORDY } from "./runs.js";
|
|
11
11
|
import { isUriSubject } from "../connector/subject.js";
|
|
12
|
-
import {
|
|
12
|
+
import { isShellTool } from "../credit-guard.js";
|
|
13
|
+
import { toolEntryOf } from "../hosts/index.js";
|
|
13
14
|
import { isMcpTool } from "../tool-label.js";
|
|
14
15
|
/** A file name for a sentence; a connector's URI subject is its own name, never cut to its last segment. */
|
|
15
16
|
const baseName = (p) => (typeof p === "string" && isUriSubject(p) ? p : pathBaseName(p));
|
|
@@ -274,21 +275,28 @@ export function translateShell(cmd, named = [], failed = false, error = null) {
|
|
|
274
275
|
// ---- non-shell tools ----
|
|
275
276
|
/** A skill's name without its prefix: "anthropic-skills:pdf" is "pdf". The core names no product. */
|
|
276
277
|
const skillName = (raw) => raw.slice(raw.lastIndexOf(":") + 1).trim();
|
|
277
|
-
export function translateTool(tool, input, named = []) {
|
|
278
|
+
export function translateTool(tool, input, named = [], host) {
|
|
278
279
|
const i = (input && typeof input === "object" ? input : {});
|
|
279
280
|
const f = i.file_path ?? i.path ?? i.notebook_path ?? named[0] ?? null;
|
|
280
281
|
const file = f ? baseName(f) : null;
|
|
281
|
-
const t =
|
|
282
|
-
|
|
283
|
-
|
|
282
|
+
const t = String(tool ?? "");
|
|
283
|
+
// A sentence by the tool's class in its host's table; a file tool is described only when its input has the file-tool shape the sentence reads.
|
|
284
|
+
const entry = toolEntryOf(host, t);
|
|
285
|
+
switch (entry?.class === "launcher" || (entry?.fileInput === true && entry.class !== "read") || entry?.class === "read" ? entry.class : undefined) {
|
|
286
|
+
case "read":
|
|
284
287
|
return file ? `Read ${file}` : "Read a file";
|
|
285
|
-
case "
|
|
286
|
-
case "MultiEdit":
|
|
288
|
+
case "edit":
|
|
287
289
|
return file ? `Edited ${file}` : "Edited a file";
|
|
288
|
-
case "
|
|
290
|
+
case "write":
|
|
289
291
|
return file ? `Wrote ${file}` : "Wrote a file";
|
|
290
|
-
case "
|
|
292
|
+
case "notebook-edit":
|
|
291
293
|
return file ? `Edited the notebook ${file}` : "Edited a notebook";
|
|
294
|
+
case "launcher": {
|
|
295
|
+
const what = i.description ?? i.task_name;
|
|
296
|
+
return what ? `Started a helper agent: ${what}` : (i.subagent_type ?? i.agent_type) ? `Started a helper agent (${i.subagent_type ?? i.agent_type})` : "Started a helper agent";
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
switch (t) {
|
|
292
300
|
case "Glob":
|
|
293
301
|
return i.pattern ? `Looked for files matching ${q(i.pattern)}` : "Looked for files";
|
|
294
302
|
case "Grep":
|
|
@@ -303,11 +311,6 @@ export function translateTool(tool, input, named = []) {
|
|
|
303
311
|
}
|
|
304
312
|
case "WebSearch":
|
|
305
313
|
return i.query ? `Searched the web for ${q(i.query)}` : "Searched the web";
|
|
306
|
-
case "Task":
|
|
307
|
-
case "Agent": {
|
|
308
|
-
const what = i.description ?? i.task_name;
|
|
309
|
-
return what ? `Started a helper agent: ${what}` : (i.subagent_type ?? i.agent_type) ? `Started a helper agent (${i.subagent_type ?? i.agent_type})` : "Started a helper agent";
|
|
310
|
-
}
|
|
311
314
|
case "TodoWrite":
|
|
312
315
|
return "Updated its to-do list";
|
|
313
316
|
case "AskUserQuestion":
|
|
@@ -347,7 +350,7 @@ function labelInput(label) {
|
|
|
347
350
|
}
|
|
348
351
|
return Object.keys(out).length ? out : null;
|
|
349
352
|
}
|
|
350
|
-
export const isShell = (c) =>
|
|
353
|
+
export const isShell = (c) => isShellTool(String(c.tool ?? ""), c.host) || (!!c.command && c.command !== c.tool && !c.tool);
|
|
351
354
|
const REFUSED_LINE = "The host refused this call; nothing ran";
|
|
352
355
|
const NO_RESULT_SHELL = "Ran a command; no result recorded";
|
|
353
356
|
export function lineOf(c) {
|
|
@@ -372,8 +375,8 @@ export function lineOf(c) {
|
|
|
372
375
|
return { text: translateShell(c.command ?? "", named, c.closedBy === "failure", c.error ?? null), source: "shell", command: c.command || null };
|
|
373
376
|
const fromLabel = labelInput(c.toolLabel);
|
|
374
377
|
if (fromLabel)
|
|
375
|
-
return { text: translateTool(c.tool, fromLabel, named), source: "label", command: c.command && c.command !== c.tool ? c.command : null };
|
|
376
|
-
return { text: translateTool(c.tool, c.input, named), source: "tool", command: c.command && c.command !== c.tool ? c.command : null };
|
|
378
|
+
return { text: translateTool(c.tool, fromLabel, named, c.host), source: "label", command: c.command && c.command !== c.tool ? c.command : null };
|
|
379
|
+
return { text: translateTool(c.tool, c.input, named, c.host), source: "tool", command: c.command && c.command !== c.tool ? c.command : null };
|
|
377
380
|
}
|
|
378
381
|
// Consecutive calls with the same line become one: "Tried 3 times: ..." when any failed, else "... (3 times)".
|
|
379
382
|
export function groupLines(calls) {
|
package/dist/timeline/load.js
CHANGED
|
@@ -170,7 +170,7 @@ function toStoredDiff(a, id, before) {
|
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
172
|
* `transcripts` is where Claude Code keeps its project folders; with it, calls recorded before subagent lanes were stored get their subagent lanes back from the
|
|
173
|
-
* session's subagent transcripts (in memory only). Without it the ops are read as stored. `
|
|
173
|
+
* session's subagent transcripts (in memory only). Without it the ops are read as stored. `sessionsDir` points the host's session-file reads at a
|
|
174
174
|
* temp tree.
|
|
175
175
|
*/
|
|
176
176
|
export function loadRows(ledger, taskId, build, transcripts) {
|
|
@@ -178,7 +178,7 @@ export function loadRows(ledger, taskId, build, transcripts) {
|
|
|
178
178
|
const { fileStates } = rows;
|
|
179
179
|
const source = transcripts === undefined ? null : { root: transcripts.transcriptsRoot, folder: ledger.home === undefined ? null : taskFolderOf(ledger, ledger.home, taskId) };
|
|
180
180
|
// With the host's session files in reach, a call whose failure reached them after its Post is read as failed (in memory only).
|
|
181
|
-
const ops = source === null ? rows.ops : markFailedFromSessionFile(backfillAgentLanes(rows.ops, source), transcripts.
|
|
181
|
+
const ops = source === null ? rows.ops : markFailedFromSessionFile(backfillAgentLanes(rows.ops, source), transcripts.sessionsDir);
|
|
182
182
|
const evidence = source === null ? undefined : callEvidenceOf(ops, source);
|
|
183
183
|
const valuesExpiredAt = ledger.valuesExpiredAt(taskId) ?? null;
|
|
184
184
|
const removals = ledger.stateRemovalsForTask(taskId);
|
|
@@ -1846,7 +1846,7 @@
|
|
|
1846
1846
|
function paintBrief(b, reveal, stop) {
|
|
1847
1847
|
var lines = b.lines || [];
|
|
1848
1848
|
var card = el('div', { class: 'mcard' });
|
|
1849
|
-
var who = b.by || '
|
|
1849
|
+
var who = b.by || 'The agent';
|
|
1850
1850
|
if (b.encrypted) card.append(el('p', {}, who + ' keeps the brief it gives a helper encrypted, so CoCheck can\'t show it.'));
|
|
1851
1851
|
else if (!lines.length) card.append(el('p', {}, b.withheld ? 'The brief was withheld because it looked like it held a secret.' : 'No brief was recorded for this helper.'));
|
|
1852
1852
|
else {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { pathKit } from "../../paths.js";
|
|
2
|
-
import {
|
|
2
|
+
import { findProfile, resumesHelper } from "../../hosts/index.js";
|
|
3
3
|
import { isSecretPath, secretLine } from "../../secret-files.js";
|
|
4
4
|
import { HELPER_LANE, MAIN_LANE, OUTSIDE_LANE_ACTOR, UNSURE_LANE, UNSURE_LANE_ACTOR, byOf, hostName, laneKeyOf, laneOf, railActor, sideText, speakAs } from "../attribution.js";
|
|
5
5
|
import { SAME_CONTENT_AS, moreText } from "../notes.js";
|
|
6
6
|
import { NOTICE_LABEL } from "../timeline.js";
|
|
7
|
-
import { isLauncherTool, isReadOnlyMcpTool } from "../../credit-guard.js";
|
|
7
|
+
import { isLauncherTool, isReadOnlyMcpTool, isReadTool } from "../../credit-guard.js";
|
|
8
8
|
import { callFailed, callFailedAndUnopenable, callFailedShared, couldNotOpen } from "../broken.js";
|
|
9
9
|
import { attachFailureLines } from "./failure-line.js";
|
|
10
10
|
import { baseOf, dirName, isOutside, treeRows } from "./files-model.js";
|
|
@@ -13,7 +13,7 @@ const HELPER_COLORS = ["#e0a458", "#58b09c", "#d9777f", "#8aa6e0", "#b5c75b"];
|
|
|
13
13
|
/** The fixed lanes. The main lane's name and chip are the task's host; "Claude" here is only the default. */
|
|
14
14
|
export const ACTORS = [
|
|
15
15
|
{ id: "you", name: "You", chip: "Y", color: "#1c2740", fromStart: true },
|
|
16
|
-
{ id: MAIN_LANE, name:
|
|
16
|
+
{ id: MAIN_LANE, name: findProfile(MAIN_LANE)?.displayName ?? "Agent", chip: findProfile(MAIN_LANE)?.chip ?? "A", color: "#6fb0e3", main: true, fromStart: true },
|
|
17
17
|
{ ...OUTSIDE_LANE_ACTOR },
|
|
18
18
|
];
|
|
19
19
|
/** The one line for a tracking stop made by a command in the session. */
|
|
@@ -203,10 +203,10 @@ export function buildRailModel(timeline, opts = {}) {
|
|
|
203
203
|
// A launch is a point on the spawner's line (no stop of its own): a lane it starts leaves the line from there.
|
|
204
204
|
// Foreground launches count too, and a launch made by Claude (no agent on the call) names the request that owns it.
|
|
205
205
|
// So is a SendMessage, which starts the resumed line of the agent it wakes.
|
|
206
|
-
if (call.tool
|
|
206
|
+
if (resumesHelper(call.host, call.tool))
|
|
207
207
|
sendIds.add(sk(request.session, call.id));
|
|
208
|
-
if ((isLauncherTool(call.tool) || call.tool
|
|
209
|
-
entries.push({ at: call.start, launch: sk(request.session, call.id), req: call.agent ? null : request.id, bg: call.tool
|
|
208
|
+
if ((isLauncherTool(call.tool, call.host) || resumesHelper(call.host, call.tool)) && call.start != null)
|
|
209
|
+
entries.push({ at: call.start, launch: sk(request.session, call.id), req: call.agent ? null : request.id, bg: resumesHelper(call.host, call.tool) || call.background === true });
|
|
210
210
|
if (call.agent) {
|
|
211
211
|
const key = segKey(request.session, call.agent.id, call.resumedBy);
|
|
212
212
|
agentOfCall.set(sk(request.session, call.id), key);
|
|
@@ -236,7 +236,7 @@ export function buildRailModel(timeline, opts = {}) {
|
|
|
236
236
|
const lane = laneOfCall.get(call.id);
|
|
237
237
|
entries.push({ at: call.start ?? null, send: { call, session: request.session, key: lane.key, type: lane.type } });
|
|
238
238
|
}
|
|
239
|
-
else if (isLauncherTool(call.tool) && call.outcome !== "failed" && call.changes.length === 0 && call.start != null) {
|
|
239
|
+
else if (isLauncherTool(call.tool, call.host) && call.outcome !== "failed" && call.changes.length === 0 && call.start != null) {
|
|
240
240
|
// Starting a helper is a step on the spawner's lane, not a quiet call.
|
|
241
241
|
const lane = laneOfCall.get(call.id);
|
|
242
242
|
entries.push({ at: call.start, start: { call, session: request.session, key: lane.key, type: lane.type, launch: sk(request.session, call.id) } });
|
|
@@ -937,7 +937,7 @@ function attachInputs(files, placed, timeline) {
|
|
|
937
937
|
continue;
|
|
938
938
|
if (c.changes.length > 0)
|
|
939
939
|
break;
|
|
940
|
-
if (c.tool
|
|
940
|
+
if (isReadTool(c.tool, c.host))
|
|
941
941
|
take(c, looked);
|
|
942
942
|
}
|
|
943
943
|
return { own, looked };
|