carrick 0.3.150 → 0.3.152

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.
Files changed (84) hide show
  1. package/bin/carrick.mjs +1 -0
  2. package/dist/contract.d.ts +35 -0
  3. package/dist/contract.js.map +1 -1
  4. package/dist/global-install.d.ts +2 -2
  5. package/dist/global-install.js +1 -1
  6. package/dist/global-install.js.map +1 -1
  7. package/dist/hook/bash-targets.d.ts +29 -0
  8. package/dist/hook/bash-targets.js +377 -0
  9. package/dist/hook/bash-targets.js.map +1 -0
  10. package/dist/hook/edit-flow.d.ts +13 -0
  11. package/dist/hook/edit-flow.js +157 -0
  12. package/dist/hook/edit-flow.js.map +1 -0
  13. package/dist/hook/grep-missed.d.ts +19 -0
  14. package/dist/hook/grep-missed.js +129 -0
  15. package/dist/hook/grep-missed.js.map +1 -0
  16. package/dist/hook/late.js +6 -8
  17. package/dist/hook/late.js.map +1 -1
  18. package/dist/hook/post-bash.d.ts +2 -0
  19. package/dist/hook/post-bash.js +109 -0
  20. package/dist/hook/post-bash.js.map +1 -0
  21. package/dist/hook/post-edit.js +3 -136
  22. package/dist/hook/post-edit.js.map +1 -1
  23. package/dist/hook/post-read.js +3 -31
  24. package/dist/hook/post-read.js.map +1 -1
  25. package/dist/hook/read-answer.d.ts +6 -0
  26. package/dist/hook/read-answer.js +45 -0
  27. package/dist/hook/read-answer.js.map +1 -0
  28. package/dist/hook/reuse.d.ts +20 -0
  29. package/dist/hook/reuse.js +36 -1
  30. package/dist/hook/reuse.js.map +1 -1
  31. package/dist/hook/session-start.js +15 -13
  32. package/dist/hook/session-start.js.map +1 -1
  33. package/dist/hook/stop-wait.d.ts +2 -1
  34. package/dist/hook/stop-wait.js +81 -23
  35. package/dist/hook/stop-wait.js.map +1 -1
  36. package/dist/hook/stop.js +3 -5
  37. package/dist/hook/stop.js.map +1 -1
  38. package/dist/hook/upgrade.d.ts +11 -0
  39. package/dist/hook/upgrade.js +81 -0
  40. package/dist/hook/upgrade.js.map +1 -0
  41. package/dist/hook/worktree.d.ts +4 -0
  42. package/dist/hook/worktree.js +9 -0
  43. package/dist/hook/worktree.js.map +1 -1
  44. package/dist/init/agents-section.js +3 -2
  45. package/dist/init/agents-section.js.map +1 -1
  46. package/dist/init/outdated.d.ts +3 -2
  47. package/dist/init/outdated.js +9 -2
  48. package/dist/init/outdated.js.map +1 -1
  49. package/dist/init/repo-copies.d.ts +2 -0
  50. package/dist/init/repo-copies.js +1 -1
  51. package/dist/init/repo-copies.js.map +1 -1
  52. package/dist/init/self-update.d.ts +2 -2
  53. package/dist/init/self-update.js +56 -12
  54. package/dist/init/self-update.js.map +1 -1
  55. package/dist/init/settings.js +6 -0
  56. package/dist/init/settings.js.map +1 -1
  57. package/dist/render.d.ts +28 -10
  58. package/dist/render.js +76 -31
  59. package/dist/render.js.map +1 -1
  60. package/dist/self-upgrade.d.ts +1 -0
  61. package/dist/self-upgrade.js +10 -0
  62. package/dist/self-upgrade.js.map +1 -0
  63. package/dist/upgrade.d.ts +26 -0
  64. package/dist/upgrade.js +86 -0
  65. package/dist/upgrade.js.map +1 -0
  66. package/package.json +6 -6
  67. package/plugin/.claude-plugin/plugin.json +1 -1
  68. package/sidecar/dist/src/capture/anchors.d.ts +7 -0
  69. package/sidecar/dist/src/capture/anchors.js +13 -4
  70. package/sidecar/dist/src/capture/check-classify.js +4 -2
  71. package/sidecar/dist/src/capture/check.js +8 -4
  72. package/sidecar/dist/src/capture/deep-walk.d.ts +14 -8
  73. package/sidecar/dist/src/capture/deep-walk.js +26 -9
  74. package/sidecar/dist/src/capture/index.js +4 -2
  75. package/sidecar/dist/src/capture/self-check.d.ts +7 -0
  76. package/sidecar/dist/src/capture/self-check.js +19 -1
  77. package/sidecar/dist/src/capture/service-config.d.ts +5 -4
  78. package/sidecar/dist/src/capture/service-config.js +15 -12
  79. package/sidecar/dist/src/library-claims.js +157 -26
  80. package/sidecar/dist/src/position-rows.js +25 -3
  81. package/sidecar/dist/src/types.d.ts +32 -1
  82. package/sidecar/dist/src/validators.d.ts +104 -0
  83. package/sidecar/dist/src/validators.js +3 -1
  84. package/templates/skills/carrick-reuse.md +1 -1
@@ -0,0 +1,157 @@
1
+ // The post-edit hook's work once the edited files are known: ask the binary
2
+ // once, queue what needs a re-scan, print what the edit needs acted on.
3
+ //
4
+ // Shared by `hook post-edit` (a file edit, either host) and `hook post-bash`
5
+ // (a shell command that wrote a source file), so a write through the shell
6
+ // gets the same answer an Edit does: a finding, or nothing.
7
+ import path from "node:path";
8
+ import { createLogger } from "../log.js";
9
+ import { notRecheckedLine, pendingLine, renderPostToolUse } from "../render.js";
10
+ import { resolveRoot, rootNote } from "../root.js";
11
+ import { throttledVersionMismatch } from "../init/outdated.js";
12
+ import { currentVersion } from "../update.js";
13
+ import { markTold, recordEdit, toldKey, wasTold } from "./reuse.js";
14
+ import { deliverLate } from "./late.js";
15
+ import { needsBackground, probeEdits } from "./probe.js";
16
+ import { inOtherWorktree } from "./worktree.js";
17
+ import { answerInHand, enqueue, ensureRunner } from "./rechecks.js";
18
+ const log = createLogger("carrick-hook");
19
+ /** Print one `additionalContext` object, which the host attaches to the tool result. */
20
+ export function emit(context) {
21
+ process.stdout.write(JSON.stringify({
22
+ hookSpecificOutput: {
23
+ hookEventName: "PostToolUse",
24
+ additionalContext: context,
25
+ },
26
+ }));
27
+ }
28
+ /**
29
+ * Check `edited` (absolute paths, at least one) as the post-edit hook does and
30
+ * print the one object for them. `extra` lines (a read answer from the same
31
+ * command) are printed first, in the same object.
32
+ */
33
+ export async function editFlow(input, edited, extra = []) {
34
+ const { cwd, session } = input;
35
+ const channel = { channel: input.channel };
36
+ // One root for the call: every file in one patch is in the workspace the tool
37
+ // ran in, and resolving it per file would ask the same question repeatedly.
38
+ const choice = resolveRoot({
39
+ clientRoot: cwd,
40
+ projectDir: process.env["CLAUDE_PROJECT_DIR"] ?? null,
41
+ filePath: edited[0],
42
+ });
43
+ const note = rootNote(choice);
44
+ if (note)
45
+ log(note);
46
+ // Stamped before any line is built: a `carrick check --changed` that began
47
+ // earlier did not read this edit (`checked.ts`). The files themselves are
48
+ // recorded once the probe has answered (below).
49
+ const editedAt = Date.now();
50
+ if (session)
51
+ recordEdit(session, choice.root, editedAt);
52
+ const contexts = [];
53
+ // Files whose uses lines this message carries, remembered only once it is
54
+ // delivered: who uses a file is shown once per file per session (carrick#2067).
55
+ const told = [];
56
+ const relatives = edited.map((file) => path.relative(choice.root, file));
57
+ // The edit just landed, so the index describes the file as it was before
58
+ // it. The hook asks the binary once, with a probe that never starts a
59
+ // re-scan: an answer that needs none (the file reads the same, no service
60
+ // reads it, a known miss) comes back at once and prints below. Every other
61
+ // file is queued for the background runner (carrick#3198).
62
+ const answers = await probeEdits(relatives, choice.root);
63
+ const queueable = channel.channel === "hook" && Boolean(session);
64
+ const toQueue = [];
65
+ const rendered = new Map();
66
+ for (const [index, relative] of relatives.entries()) {
67
+ const result = answers.results[index] ?? null;
68
+ if (!result) {
69
+ // A probe with no answer queues every file; one unreadable file in a
70
+ // patch of four is no reason to say nothing about the other three.
71
+ log("no answer for", relative, answers.failure ?? "");
72
+ if (queueable)
73
+ toQueue.push(index);
74
+ continue;
75
+ }
76
+ if (queueable && needsBackground(result)) {
77
+ toQueue.push(index);
78
+ continue;
79
+ }
80
+ const key = toldKey(result, relative);
81
+ const show = !session || !wasTold(session, key);
82
+ if (show && result.uses_lines?.length)
83
+ told.push(key);
84
+ const context = renderPostToolUse(result, relative, { uses: show });
85
+ log(`check ${relative} -> ${context ? "context" : "nothing to say"} in ${answers.ms}ms`);
86
+ if (context)
87
+ rendered.set(index, context);
88
+ }
89
+ const queued = new Set();
90
+ if (toQueue.length > 0 && session) {
91
+ const entries = enqueue(choice.root, session, toQueue.map((index) => edited[index]), editedAt);
92
+ if (entries.length > 0)
93
+ ensureRunner(choice.root);
94
+ for (const entry of entries)
95
+ queued.add(entry.file);
96
+ for (const index of toQueue) {
97
+ const result = answers.results[index] ?? null;
98
+ if (queued.has(edited[index])) {
99
+ rendered.set(index, pendingLine(relatives[index], result?.service));
100
+ }
101
+ else {
102
+ // The queue refused it: say what is true rather than nothing.
103
+ rendered.set(index, notRecheckedLine(relatives[index], result?.recheck?.reason));
104
+ }
105
+ }
106
+ }
107
+ // What the Stop hook states the session's check from (carrick#3466): each
108
+ // file, at the time its entry or in-hand answer carries, and every answer
109
+ // this hook had in hand as the session's answer for that edit. Only on the
110
+ // hook channel, which is the one that queues and speaks at Stop. A file the
111
+ // binary refused (`error`: no index, an unreadable one) is not recorded:
112
+ // there is no check to state, and a fallback would fail the same way.
113
+ if (session && channel.channel === "hook") {
114
+ const recorded = [];
115
+ for (const [index, file] of edited.entries()) {
116
+ const result = answers.results[index] ?? null;
117
+ if (result?.error)
118
+ continue;
119
+ // A subagent's own worktree is not this session's change (carrick#3543).
120
+ if (inOtherWorktree(file, cwd ?? process.cwd()))
121
+ continue;
122
+ if (result !== null && !queued.has(file))
123
+ answerInHand(choice.root, session, file, result, editedAt);
124
+ if (result !== null || queued.has(file))
125
+ recorded.push(file);
126
+ }
127
+ if (recorded.length > 0)
128
+ recordEdit(session, choice.root, editedAt, undefined, recorded);
129
+ }
130
+ // Delivered after this edit is queued, so an older answer for a file this
131
+ // edit queues again is skipped (the newer entry carries it).
132
+ const late = channel.channel === "hook" ? deliverLate(session) : [];
133
+ contexts.push(...late);
134
+ for (const index of relatives.keys()) {
135
+ const context = rendered.get(index);
136
+ if (context)
137
+ contexts.push(context);
138
+ }
139
+ if (channel.channel !== "hook") {
140
+ log(`the ${channel.channel} channel owns delivery in this install; printing nothing`);
141
+ return;
142
+ }
143
+ // The `carrick` this hook is running is whatever PATH answered with, which
144
+ // an upgrade elsewhere can leave behind (carrick#1372). Claimed at the last
145
+ // possible moment, so the once-a-day stamp is spent only on a line that is
146
+ // actually delivered, and inside `additionalContext` rather than on a bare
147
+ // stdout line, which this host reads as a malformed hook response.
148
+ const mismatch = throttledVersionMismatch(choice.root, currentVersion());
149
+ if (mismatch)
150
+ contexts.push(mismatch);
151
+ if (told.length > 0 && session)
152
+ markTold(session, told);
153
+ contexts.unshift(...extra);
154
+ if (contexts.length > 0)
155
+ emit(contexts.join("\n\n"));
156
+ }
157
+ //# sourceMappingURL=edit-flow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit-flow.js","sourceRoot":"","sources":["../../src/hook/edit-flow.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,wEAAwE;AACxE,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,4DAA4D;AAE5D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEpE,MAAM,GAAG,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;AAEzC,wFAAwF;AACxF,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,CAAC,SAAS,CAAC;QACb,kBAAkB,EAAE;YAClB,aAAa,EAAE,aAAa;YAC5B,iBAAiB,EAAE,OAAO;SAC3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,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;QAC/B,GAAG,CAAC,OAAO,OAAO,CAAC,OAAO,0DAA0D,CAAC,CAAC;QACtF,OAAO;IACT,CAAC;IACD,2EAA2E;IAC3E,4EAA4E;IAC5E,2EAA2E;IAC3E,2EAA2E;IAC3E,mEAAmE;IACnE,MAAM,QAAQ,GAAG,wBAAwB,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;IACzE,IAAI,QAAQ;QAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO;QAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACxD,QAAQ,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IAC3B,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,19 @@
1
+ type Site = {
2
+ file: string;
3
+ line: number;
4
+ };
5
+ type Definition = {
6
+ file: string;
7
+ line: number;
8
+ callers: Site[];
9
+ total: number;
10
+ };
11
+ type NameMap = Record<string, Definition[]>;
12
+ /** The name map for the index under `root`, from the cache when the index has not changed. Null when there is no index. */
13
+ export declare function nameMap(root: string, home?: string): NameMap | null;
14
+ /**
15
+ * One line per searched name whose index sites the grep output lacks, or null.
16
+ * `output` is the command's stdout, `root` the workspace holding the index.
17
+ */
18
+ export declare function missedSites(names: string[], operands: string[], output: string, root: string, cwd: string, session: string | undefined, home?: string): string | null;
19
+ export {};
@@ -0,0 +1,129 @@
1
+ // The call sites a grep did not print, from the local index.
2
+ //
3
+ // A search for a function's name prints the files the search reached. The
4
+ // index already holds every caller of each function it knows (`uses` in
5
+ // `.carrick/index.json`), so a caller the output lacks is a site the agent
6
+ // has not seen. This says where they are, and nothing when the output already
7
+ // has them all: it never repeats what grep printed. It runs only after a
8
+ // grep or rg whose pattern names one identifier (`searchedNames`), asks no
9
+ // one, and costs $0.
10
+ //
11
+ // The index is read through a small name map cached beside the session
12
+ // records, keyed by the index file's mtime and size, so a grep after the first
13
+ // does not parse the whole index again.
14
+ import crypto from "node:crypto";
15
+ import fs from "node:fs";
16
+ import os from "node:os";
17
+ import path from "node:path";
18
+ import { sessionsDir, markTold, wasTold, writeAtomic } from "./reuse.js";
19
+ /** At most this many sites are named; the rest are counted. */
20
+ const MAX_SITES = 5;
21
+ /** At most this many names are answered for one command. */
22
+ const MAX_NAMES = 2;
23
+ /** The functions of at least five characters in the index, by name, with absolute paths. */
24
+ function buildMap(indexFile) {
25
+ const index = JSON.parse(fs.readFileSync(indexFile, "utf8"));
26
+ const map = {};
27
+ for (const repo of index.repos ?? []) {
28
+ if (typeof repo.path !== "string")
29
+ continue;
30
+ for (const [file, entry] of Object.entries(repo.uses ?? {})) {
31
+ for (const fn of entry.functions ?? []) {
32
+ if (typeof fn.name !== "string" || fn.name.length < 5 || typeof fn.line !== "number")
33
+ continue;
34
+ const callers = (fn.callers ?? [])
35
+ .filter((caller) => typeof caller.file === "string" && typeof caller.line === "number")
36
+ .map((caller) => ({ file: path.join(repo.path, caller.file), line: caller.line }));
37
+ (map[fn.name] ??= []).push({
38
+ file: path.join(repo.path, file),
39
+ line: fn.line,
40
+ callers,
41
+ total: typeof fn.callers_total === "number" ? fn.callers_total : callers.length,
42
+ });
43
+ }
44
+ }
45
+ }
46
+ return map;
47
+ }
48
+ /** The name map for the index under `root`, from the cache when the index has not changed. Null when there is no index. */
49
+ export function nameMap(root, home = os.homedir()) {
50
+ const indexFile = path.join(root, ".carrick", "index.json");
51
+ let stamp;
52
+ try {
53
+ const stat = fs.statSync(indexFile);
54
+ stamp = `${stat.mtimeMs}:${stat.size}`;
55
+ }
56
+ catch {
57
+ return null;
58
+ }
59
+ const key = crypto.createHash("sha1").update(root).digest("hex").slice(0, 12);
60
+ const cache = path.join(sessionsDir(home), `uses-${key}.map`);
61
+ try {
62
+ const cached = JSON.parse(fs.readFileSync(cache, "utf8"));
63
+ if (cached.stamp === stamp && cached.names)
64
+ return cached.names;
65
+ }
66
+ catch {
67
+ // No cache, or a half-written one: rebuild.
68
+ }
69
+ let names;
70
+ try {
71
+ names = buildMap(indexFile);
72
+ }
73
+ catch {
74
+ return null;
75
+ }
76
+ writeAtomic(cache, JSON.stringify({ stamp, names }));
77
+ return names;
78
+ }
79
+ /** Whether `output` printed the file at `abs`: by its path from the root, from the cwd, or in full. */
80
+ function printed(output, abs, root, cwd, operands) {
81
+ if (operands.has(abs))
82
+ return true;
83
+ const fromRoot = path.relative(root, abs);
84
+ const fromCwd = path.relative(cwd, abs);
85
+ return (output.includes(abs) ||
86
+ (!fromRoot.startsWith("..") && output.includes(fromRoot)) ||
87
+ (!fromCwd.startsWith("..") && output.includes(fromCwd)));
88
+ }
89
+ /**
90
+ * One line per searched name whose index sites the grep output lacks, or null.
91
+ * `output` is the command's stdout, `root` the workspace holding the index.
92
+ */
93
+ export function missedSites(names, operands, output, root, cwd, session, home) {
94
+ const map = nameMap(root, home);
95
+ if (map === null)
96
+ return null;
97
+ const files = new Set(operands);
98
+ const lines = [];
99
+ for (const name of names) {
100
+ if (lines.length >= MAX_NAMES)
101
+ break;
102
+ const definitions = map[name];
103
+ // A name defined in more than one place is a word, not a function.
104
+ if (!definitions || definitions.length !== 1)
105
+ continue;
106
+ const told = `grep:${name}`;
107
+ if (session && wasTold(session, told, home))
108
+ continue;
109
+ const definition = definitions[0];
110
+ const rel = (file) => path.relative(root, file);
111
+ const missed = definition.callers.filter((caller) => caller.file !== definition.file && !printed(output, caller.file, root, cwd, files));
112
+ const definitionMissed = !printed(output, definition.file, root, cwd, files);
113
+ if (missed.length === 0 && !definitionMissed)
114
+ continue;
115
+ const where = `${rel(definition.file)}:${definition.line}`;
116
+ if (missed.length === 0) {
117
+ lines.push(`Carrick: \`${name}\` is defined at ${where}, where this search did not reach.`);
118
+ }
119
+ else {
120
+ const shown = missed.slice(0, MAX_SITES).map((site) => `${rel(site.file)}:${site.line}`);
121
+ const more = missed.length - shown.length;
122
+ lines.push(`Carrick: \`${name}\` (${where}) is also called where this search did not reach: ${shown.join(", ")}${more > 0 ? ` (+${more} more)` : ""}.`);
123
+ }
124
+ if (session)
125
+ markTold(session, [told], home);
126
+ }
127
+ return lines.length > 0 ? lines.join("\n") : null;
128
+ }
129
+ //# sourceMappingURL=grep-missed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grep-missed.js","sourceRoot":"","sources":["../../src/hook/grep-missed.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,2EAA2E;AAC3E,qBAAqB;AACrB,EAAE;AACF,uEAAuE;AACvE,+EAA+E;AAC/E,wCAAwC;AAExC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzE,+DAA+D;AAC/D,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,4DAA4D;AAC5D,MAAM,SAAS,GAAG,CAAC,CAAC;AAMpB,4FAA4F;AAC5F,SAAS,QAAQ,CAAC,SAAiB;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAK1D,CAAC;IACF,MAAM,GAAG,GAAY,EAAE,CAAC;IACxB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;QACrC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AC,CAAC;YACzF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YAC1C,KAAK,CAAC,IAAI,CACR,cAAc,IAAI,OAAO,KAAK,qDAAqD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,CAC5I,CAAC;QACJ,CAAC;QACD,IAAI,OAAO;YAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACpD,CAAC"}
package/dist/hook/late.js CHANGED
@@ -7,20 +7,18 @@
7
7
  // any hook speaks. Each answer is claimed with `claimDelivery`, so parallel
8
8
  // hooks print it once.
9
9
  import { createLogger } from "../log.js";
10
- import { answersTheEdit, changedFailedLine, changedLines, notRecheckedLine, renderPostToolUse } from "../render.js";
10
+ import { answersTheEdit, changedLines, notRecheckedLine, renderPostToolUse } from "../render.js";
11
11
  import { claimDelivery, finishedFor, isChanged } from "./rechecks.js";
12
12
  import { checkedSinceLastEdit } from "./checked.js";
13
13
  import { markTold, toldKey, wasTold } from "./reuse.js";
14
14
  const log = createLogger("carrick-late");
15
15
  /** The words for one finished answer, or null when there is nothing to say. */
16
16
  export function lateContext(answer, uses, settled = false) {
17
- // The whole-change check a Stop queued (carrick#3466): its verdict, or that
18
- // it gave none. Never a clause: it is the check the clause asks for.
19
- if (isChanged(answer)) {
20
- if (answer.changed)
21
- return changedLines(answer.changed);
22
- return changedFailedLine(answer.state === "stopped" ? (answer.failure ?? "it stopped") : "the binary failed or printed no answer");
23
- }
17
+ // The whole-change check a Stop queued (carrick#3466) speaks only with a
18
+ // problem: a clean run, a run that could not check and a run that gave no
19
+ // answer print nothing (a failure is logged by `deliverLate`).
20
+ if (isChanged(answer))
21
+ return answer.changed ? changedLines(answer.changed) || null : null;
24
22
  if (!answer.result) {
25
23
  // An internal failure is logged, never shown: the reader needs the next step.
26
24
  const reason = answer.state === "stopped" ? (answer.failure ?? "the background re-check stopped") : "the background re-check gave no answer";
@@ -1 +1 @@
1
- {"version":3,"file":"late.js","sourceRoot":"","sources":["../../src/hook/late.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,6EAA6E;AAC7E,2EAA2E;AAC3E,4EAA4E;AAC5E,uBAAuB;AAEvB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACpH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,GAAG,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;AAEzC,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,IAAa,EAAE,OAAO,GAAG,KAAK;IACxE,4EAA4E;IAC5E,qEAAqE;IACrE,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,IAAI,MAAM,CAAC,OAAO;YAAE,OAAO,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACxD,OAAO,iBAAiB,CACtB,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,wCAAwC,CACzG,CAAC;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ACvB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM;gBAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,sBAAsB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env node
2
+ // PostToolUse hook for a shell command, on Claude Code.
3
+ //
4
+ // Most reads and writes of a source file in an agent session go through the
5
+ // shell, where the Read and Edit hooks cannot fire. This decides in one process
6
+ // what the command touched. A read of a TypeScript file gets the Read hook's
7
+ // answer (who depends on it). A write of one (a redirect, `tee`, `sed -i`, a
8
+ // script that rewrites it, an `apply_patch`) goes through the post-edit flow
9
+ // (`edit-flow.ts`): the same answer an Edit gives, a finding or nothing.
10
+ //
11
+ // A write is a path the command names in a write shape whose mtime moved since
12
+ // this session last saw it. A path with no record counts when it was modified
13
+ // in the last two minutes (a file the command created, or rewrote just now).
14
+ // Commands that move the tree in bulk (`git checkout`, `npm ci`) start nothing.
15
+ //
16
+ // It runs on every shell command, so the work before a target is found is a
17
+ // node start, a stdin read and one regex: nothing else is imported. A command
18
+ // that names no source file prints nothing and starts nothing. Whatever
19
+ // happens it exits 0 and prints at most the one JSON object.
20
+ import { readStdin } from "./stdin.js";
21
+ import path from "node:path";
22
+ import fs from "node:fs";
23
+ import { bashTargets, MENTIONS_SOURCE, movesTreeInBulk, searchedNames } from "./bash-targets.js";
24
+ /** At most this many files are asked about for one command. */
25
+ const MAX_FILES = 2;
26
+ /** At most this many written files go through the edit flow for one command. */
27
+ const MAX_WRITES = 5;
28
+ /** A written file with no record counts when modified this recently. */
29
+ const FRESH_MS = 120_000;
30
+ /** A command that may search the tree. */
31
+ const SEARCH_WORD = /\b(grep|rg|egrep|fgrep)\b/;
32
+ async function main() {
33
+ let payload;
34
+ try {
35
+ payload = JSON.parse((await readStdin()) || "{}");
36
+ }
37
+ catch {
38
+ return;
39
+ }
40
+ const command = payload.tool_input?.command;
41
+ if (!command || !(MENTIONS_SOURCE.test(command) || SEARCH_WORD.test(command)))
42
+ return;
43
+ const cwd = payload.cwd ?? process.cwd();
44
+ const { reads, writes } = bashTargets(command, path.resolve(cwd));
45
+ const candidates = writes.length > 0 && !movesTreeInBulk(command, path.resolve(cwd)) ? writes : [];
46
+ // A search for a function's name: the index sites its output did not print.
47
+ const searched = SEARCH_WORD.test(command) ? searchedNames(command, path.resolve(cwd)) : { names: [], operands: [] };
48
+ if (reads.length === 0 && candidates.length === 0 && searched.names.length === 0)
49
+ return;
50
+ const session = payload.session_id;
51
+ const { markInvoker } = await import("./invoker.js");
52
+ const { resolveChannel } = await import("../channel.js");
53
+ const channel = resolveChannel({ hooksInstalled: true });
54
+ const reuse = await import("./reuse.js");
55
+ // Written: the mtime moved since the session last saw the file.
56
+ const written = [];
57
+ if (candidates.length > 0 && channel.channel !== "off") {
58
+ const mtimes = {};
59
+ for (const file of candidates) {
60
+ let mtime;
61
+ try {
62
+ mtime = fs.statSync(file).mtimeMs;
63
+ }
64
+ catch {
65
+ continue;
66
+ }
67
+ mtimes[file] = mtime;
68
+ const seen = session ? reuse.writtenMtime(session, file) : undefined;
69
+ if (seen === undefined ? Date.now() - mtime < FRESH_MS : mtime !== seen)
70
+ written.push(file);
71
+ }
72
+ if (session && Object.keys(mtimes).length > 0)
73
+ reuse.markWritten(session, mtimes);
74
+ }
75
+ const toEdit = written.slice(0, MAX_WRITES);
76
+ // The answer is the Read hook's (or the edit hook's), so the cloud's log tells it the same way.
77
+ markInvoker(toEdit.length > 0 ? "post-edit" : "post-read");
78
+ if (toEdit.length === 0 && channel.channel !== "hook")
79
+ return;
80
+ const { wasRead } = reuse;
81
+ const fresh = channel.channel === "hook" ? reads.filter((file) => !(session && wasRead(session, file))).slice(0, MAX_FILES) : [];
82
+ const { answerRead } = await import("./read-answer.js");
83
+ const answers = (await Promise.all(fresh.map((file) => answerRead(file, payload.cwd, session)))).filter((line) => line !== null);
84
+ const response = payload.tool_response;
85
+ const output = typeof response === "string" ? response : response?.stdout;
86
+ if (channel.channel === "hook" && searched.names.length > 0 && typeof output === "string") {
87
+ const { resolveRoot } = await import("../root.js");
88
+ const root = resolveRoot({ clientRoot: payload.cwd ?? null, projectDir: process.env["CLAUDE_PROJECT_DIR"] ?? null }).root;
89
+ const { missedSites } = await import("./grep-missed.js");
90
+ const line = missedSites(searched.names, searched.operands, output, root, path.resolve(cwd), session);
91
+ if (line !== null)
92
+ answers.push(line);
93
+ }
94
+ if (toEdit.length > 0) {
95
+ const { editFlow } = await import("./edit-flow.js");
96
+ await editFlow({ cwd: payload.cwd ?? null, session, channel: channel.channel }, toEdit, answers);
97
+ return;
98
+ }
99
+ const { deliverLate } = await import("./late.js");
100
+ const contexts = [...deliverLate(session), ...answers];
101
+ if (contexts.length === 0)
102
+ return;
103
+ process.stdout.write(JSON.stringify({
104
+ hookSpecificOutput: { hookEventName: "PostToolUse", additionalContext: contexts.join("\n\n") },
105
+ }));
106
+ }
107
+ await main();
108
+ process.exit(0);
109
+ //# sourceMappingURL=post-bash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-bash.js","sourceRoot":"","sources":["../../src/hook/post-bash.ts"],"names":[],"mappings":";AACA,wDAAwD;AACxD,EAAE;AACF,4EAA4E;AAC5E,gFAAgF;AAChF,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,yEAAyE;AACzE,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,6EAA6E;AAC7E,gFAAgF;AAChF,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,wE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