carrick 0.3.145 → 0.3.147
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/bin/carrick.mjs +4 -4
- package/dist/cli.d.ts +8 -1
- package/dist/cli.js +14 -2
- package/dist/cli.js.map +1 -1
- package/dist/contract.d.ts +31 -0
- package/dist/contract.js +29 -3
- package/dist/contract.js.map +1 -1
- package/dist/diagnostics.js +1 -9
- package/dist/diagnostics.js.map +1 -1
- package/dist/fs-util.d.ts +6 -0
- package/dist/fs-util.js +29 -0
- package/dist/fs-util.js.map +1 -0
- package/dist/global-install.js +1 -8
- package/dist/global-install.js.map +1 -1
- package/dist/hook/apply-patch.js +3 -4
- package/dist/hook/apply-patch.js.map +1 -1
- package/dist/hook/checked.d.ts +3 -1
- package/dist/hook/checked.js +9 -2
- package/dist/hook/checked.js.map +1 -1
- package/dist/hook/late.js +9 -2
- package/dist/hook/late.js.map +1 -1
- package/dist/hook/post-edit.js +33 -24
- package/dist/hook/post-edit.js.map +1 -1
- package/dist/hook/post-read.js +1 -6
- package/dist/hook/post-read.js.map +1 -1
- package/dist/hook/rechecks.d.ts +45 -1
- package/dist/hook/rechecks.js +116 -10
- package/dist/hook/rechecks.js.map +1 -1
- package/dist/hook/reuse.d.ts +31 -58
- package/dist/hook/reuse.js +48 -112
- package/dist/hook/reuse.js.map +1 -1
- package/dist/hook/session-start.d.ts +9 -0
- package/dist/hook/session-start.js +43 -16
- package/dist/hook/session-start.js.map +1 -1
- package/dist/hook/stdin.d.ts +2 -0
- package/dist/hook/stdin.js +8 -0
- package/dist/hook/stdin.js.map +1 -0
- package/dist/hook/stop-wait.d.ts +24 -1
- package/dist/hook/stop-wait.js +163 -28
- package/dist/hook/stop-wait.js.map +1 -1
- package/dist/hook/stop.js +17 -36
- package/dist/hook/stop.js.map +1 -1
- package/dist/hook/user-prompt.js +13 -30
- package/dist/hook/user-prompt.js.map +1 -1
- package/dist/hosted-snapshot.d.ts +37 -0
- package/dist/hosted-snapshot.js +49 -0
- package/dist/hosted-snapshot.js.map +1 -0
- package/dist/init/agents-section.d.ts +16 -2
- package/dist/init/agents-section.js +43 -7
- package/dist/init/agents-section.js.map +1 -1
- package/dist/init/codex.js +8 -7
- package/dist/init/codex.js.map +1 -1
- package/dist/init/mcp.js +1 -3
- package/dist/init/mcp.js.map +1 -1
- package/dist/init/remove.d.ts +2 -0
- package/dist/init/remove.js +18 -4
- package/dist/init/remove.js.map +1 -1
- package/dist/init/repo-copies.js +2 -10
- package/dist/init/repo-copies.js.map +1 -1
- package/dist/init/repos.d.ts +0 -2
- package/dist/init/repos.js +1 -9
- package/dist/init/repos.js.map +1 -1
- package/dist/init/run.js +14 -4
- package/dist/init/run.js.map +1 -1
- package/dist/init/self-update.d.ts +2 -2
- package/dist/init/self-update.js +89 -3
- package/dist/init/self-update.js.map +1 -1
- package/dist/init/settings.js +5 -7
- package/dist/init/settings.js.map +1 -1
- package/dist/native.js +1 -9
- package/dist/native.js.map +1 -1
- package/dist/render.d.ts +54 -11
- package/dist/render.js +188 -34
- package/dist/render.js.map +1 -1
- package/dist/root.d.ts +1 -2
- package/dist/root.js +1 -9
- package/dist/root.js.map +1 -1
- package/dist/surfaces.js +1 -3
- package/dist/surfaces.js.map +1 -1
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/bundler.js +30 -28
- package/sidecar/dist/src/capture/service-config.d.ts +6 -0
- package/sidecar/dist/src/capture/service-config.js +11 -1
- package/sidecar/dist/src/library-claims.js +14 -0
- package/sidecar/dist/src/platform-body-read.d.ts +46 -0
- package/sidecar/dist/src/platform-body-read.js +82 -0
- package/sidecar/dist/src/response-modes.d.ts +5 -4
- package/sidecar/dist/src/response-modes.js +21 -25
- package/sidecar/dist/src/retype.js +11 -16
- package/sidecar/dist/src/stated-params.d.ts +6 -0
- package/sidecar/dist/src/stated-params.js +13 -0
- package/sidecar/dist/src/type-inferrer.d.ts +47 -14
- package/sidecar/dist/src/type-inferrer.js +119 -62
- package/sidecar/dist/src/types.d.ts +20 -3
- package/templates/skills/carrick-census.md +24 -3
- package/templates/skills/carrick-drift.md +11 -3
- package/templates/skills/carrick-impact.md +8 -3
- package/dist/hook/edited.d.ts +0 -22
- package/dist/hook/edited.js +0 -84
- package/dist/hook/edited.js.map +0 -1
package/dist/hook/reuse.d.ts
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import type { CheckResult } from "../contract.ts";
|
|
2
|
-
/** One function the working tree declares and the index does not. */
|
|
3
|
-
export type NewFunction = {
|
|
4
|
-
/** As the source spells it. */
|
|
5
|
-
name: string;
|
|
6
|
-
/** Repo-relative path of the file that declares it. */
|
|
7
|
-
file: string;
|
|
8
|
-
/** The commit the index this was compared against was taken at. */
|
|
9
|
-
indexCommit: string;
|
|
10
|
-
};
|
|
11
2
|
/** A session's accumulated record. */
|
|
12
3
|
export type SessionRecord = {
|
|
13
|
-
/** Every new function this session has seen, in the order it saw them. */
|
|
14
|
-
found: NewFunction[];
|
|
15
|
-
/** `file::name` for the ones a nudge has already listed. */
|
|
16
|
-
nudged: string[];
|
|
17
4
|
/**
|
|
18
5
|
* `repo::file` for every file whose uses lines this session has been shown
|
|
19
6
|
* (carrick#2067), so the post-edit hook prints them once per file.
|
|
@@ -29,6 +16,26 @@ export type SessionRecord = {
|
|
|
29
16
|
* `checked.ts` compares it with the last `carrick check --changed`.
|
|
30
17
|
*/
|
|
31
18
|
edited: Record<string, number>;
|
|
19
|
+
/**
|
|
20
|
+
* Absolute path -> the workspace root it was edited in and epoch ms of its
|
|
21
|
+
* newest edit: the files the Stop hook states the session's check for
|
|
22
|
+
* (`sessionCoverage` in `stop-wait.ts`, carrick#3466).
|
|
23
|
+
*/
|
|
24
|
+
files: Record<string, {
|
|
25
|
+
root: string;
|
|
26
|
+
at: number;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Workspace root -> the newest edit there the Stop hook has already spoken
|
|
30
|
+
* about (checked, or queued `check --changed` for): it speaks once per change.
|
|
31
|
+
*/
|
|
32
|
+
stated: Record<string, number>;
|
|
33
|
+
/**
|
|
34
|
+
* Workspace root -> the newest edit there whose every file the per-file
|
|
35
|
+
* re-checks answered, as Stop stated it. `checked.ts` reads it like a clean
|
|
36
|
+
* `check --changed` marker.
|
|
37
|
+
*/
|
|
38
|
+
covered: Record<string, number>;
|
|
32
39
|
/** RFC 3339, when this file was last written. Drives the prune below. */
|
|
33
40
|
updated: string;
|
|
34
41
|
};
|
|
@@ -66,17 +73,6 @@ export declare function sessionRecords(home?: string): number;
|
|
|
66
73
|
* rule every other half of `carrick uninstall` follows (carrick#1034).
|
|
67
74
|
*/
|
|
68
75
|
export declare function removeSessions(home?: string): number;
|
|
69
|
-
/**
|
|
70
|
-
* Add what one edit found, keeping the first sighting of each function.
|
|
71
|
-
*
|
|
72
|
-
* Deduplicated on file and name: an agent edits one file several times in a
|
|
73
|
-
* task, and every one of those edits re-reports the same new function.
|
|
74
|
-
*/
|
|
75
|
-
export declare function record(sessionId: string, found: NewFunction[], home?: string): SessionRecord;
|
|
76
|
-
/** What a nudge has not yet named, oldest first. */
|
|
77
|
-
export declare function pending(record: SessionRecord): NewFunction[];
|
|
78
|
-
/** Mark entries as named, so the next stop of the same task says nothing. */
|
|
79
|
-
export declare function markNudged(sessionId: string, entries: NewFunction[], home?: string): void;
|
|
80
76
|
/**
|
|
81
77
|
* The key a file's uses lines are remembered under: its repo and its
|
|
82
78
|
* repo-relative path, so one path in two repos is two files.
|
|
@@ -86,46 +82,23 @@ export declare function toldKey(result: CheckResult, fallbackFile: string): stri
|
|
|
86
82
|
export declare function wasTold(sessionId: string, key: string, home?: string): boolean;
|
|
87
83
|
/** Remember that this session has been shown the uses lines under `keys`. */
|
|
88
84
|
export declare function markTold(sessionId: string, keys: string[], home?: string): void;
|
|
89
|
-
/** Remember that this session edited a file in the workspace at `root` at `at` (epoch ms). */
|
|
90
|
-
export declare function recordEdit(sessionId: string, root: string, at: number, home?: string): void;
|
|
91
|
-
/** Whether the Read hook has already asked about this absolute path. */
|
|
92
|
-
export declare function wasRead(sessionId: string, file: string, home?: string): boolean;
|
|
93
|
-
/** Remember that the Read hook has asked about this absolute path. */
|
|
94
|
-
export declare function markRead(sessionId: string, file: string, home?: string): void;
|
|
95
|
-
/** What one delivery of the nudge said, for the hook that delivered it. */
|
|
96
|
-
export type Drained = {
|
|
97
|
-
/** The line to hand the model. */
|
|
98
|
-
line: string;
|
|
99
|
-
/** How many functions it names. */
|
|
100
|
-
named: number;
|
|
101
|
-
/** How many the session has recorded in all, named or not. */
|
|
102
|
-
found: number;
|
|
103
|
-
};
|
|
104
85
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* The one place the sequence lives, because two hooks deliver it: Claude Code's
|
|
108
|
-
* `Stop`, and Codex's `UserPromptSubmit`, which is the only non-blocking
|
|
109
|
-
* model-visible event Codex gives us. Both read the same store, speak the same
|
|
110
|
-
* line and mark the same set; only the event name on the wire differs.
|
|
111
|
-
*
|
|
112
|
-
* The marking happens here, before the caller writes anything, and that order
|
|
113
|
-
* is the point: a nudge that is written and not recorded fires again on the
|
|
114
|
-
* next stop, and a task is several stops.
|
|
86
|
+
* Remember that this session edited `files` (absolute paths) in the workspace
|
|
87
|
+
* at `root` at `at` (epoch ms).
|
|
115
88
|
*/
|
|
116
|
-
export declare function
|
|
89
|
+
export declare function recordEdit(sessionId: string, root: string, at: number, home?: string, files?: string[]): void;
|
|
117
90
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* functions are new, so the index has no name to find). Short on purpose, and it starts with "Carrick:" so the
|
|
121
|
-
* user can tell where it came from. The two limits on the answer (what the
|
|
122
|
-
* index was taken at, and that the match is on what a function is described as
|
|
123
|
-
* doing) live in the `carrick-reuse` skill, where the answer is read.
|
|
91
|
+
* Remember that Stop spoke about the change in `root` up to the edit at
|
|
92
|
+
* `upTo`, and whether every file of it was answered (`covered`).
|
|
124
93
|
*/
|
|
125
|
-
export declare function
|
|
94
|
+
export declare function markStated(sessionId: string, root: string, upTo: number, covered: boolean, home?: string): void;
|
|
95
|
+
/** Whether the Read hook has already asked about this absolute path. */
|
|
96
|
+
export declare function wasRead(sessionId: string, file: string, home?: string): boolean;
|
|
97
|
+
/** Remember that the Read hook has asked about this absolute path. */
|
|
98
|
+
export declare function markRead(sessionId: string, file: string, home?: string): void;
|
|
126
99
|
/**
|
|
127
100
|
* The one project slug the workspace's cached hosted snapshot names, or ""
|
|
128
|
-
* when there is none or more than one (
|
|
101
|
+
* when there is none or more than one (a tool call needs one project).
|
|
129
102
|
* `snapshot.json` is written by the hosted refresh: `resolution.repos[]`
|
|
130
103
|
* carries each connected repo's `project_slug`.
|
|
131
104
|
*/
|
package/dist/hook/reuse.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
// What one session
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// The measured problem: a reuse check that waits to be remembered does not
|
|
5
|
-
// run. Prose alone reached the index in none of five runs; a hook reached it
|
|
6
|
-
// in all five. So the check has to be delivered, not documented — but delivery
|
|
7
|
-
// costs a model turn, and most edits add no function, so it cannot ride the
|
|
8
|
-
// edit. The split is: the post-edit hook RECORDS silently (it already re-checks
|
|
9
|
-
// the edited file, and the list of new functions comes back in that answer),
|
|
10
|
-
// and the Stop hook SPEAKS once, with everything the task accumulated.
|
|
1
|
+
// What one session's hooks remember between calls: which files' uses lines it
|
|
2
|
+
// has been shown, which files the Read hook has asked about, and when it last
|
|
3
|
+
// edited each workspace.
|
|
11
4
|
//
|
|
12
5
|
// The store is a file per session under `~/.carrick/sessions`, outside every
|
|
13
6
|
// repository: a scratch file about one conversation is not a thing to put in a
|
|
@@ -15,7 +8,10 @@
|
|
|
15
8
|
// Nothing here ever throws at its caller — an edit and a stop must not fail
|
|
16
9
|
// because a state file could not be written.
|
|
17
10
|
//
|
|
18
|
-
//
|
|
11
|
+
// It no longer lists the functions a session added: the end-of-task reuse
|
|
12
|
+
// nudge that read that list is gone (carrick#3436). A file an older install
|
|
13
|
+
// wrote still loads; `readSession` keeps only the fields below.
|
|
14
|
+
import { snapshotRepos } from "../hosted-snapshot.js";
|
|
19
15
|
import fs from "node:fs";
|
|
20
16
|
import os from "node:os";
|
|
21
17
|
import path from "node:path";
|
|
@@ -34,18 +30,21 @@ export function sessionFile(sessionId, home = os.homedir()) {
|
|
|
34
30
|
export function sessionsDir(home = os.homedir()) {
|
|
35
31
|
return path.join(home, ".carrick", "sessions");
|
|
36
32
|
}
|
|
37
|
-
/** The
|
|
38
|
-
function
|
|
39
|
-
|
|
33
|
+
/** The `root -> epoch ms` entries of a record field that are numbers. */
|
|
34
|
+
function stamps(raw) {
|
|
35
|
+
if (typeof raw !== "object" || raw === null)
|
|
36
|
+
return {};
|
|
37
|
+
return Object.fromEntries(Object.entries(raw).filter((entry) => typeof entry[1] === "number" && Number.isFinite(entry[1])));
|
|
40
38
|
}
|
|
41
39
|
/** A session's record, or an empty one. Never throws. */
|
|
42
40
|
export function readSession(sessionId, home) {
|
|
43
41
|
const empty = {
|
|
44
|
-
found: [],
|
|
45
|
-
nudged: [],
|
|
46
42
|
told: [],
|
|
47
43
|
read: [],
|
|
48
44
|
edited: {},
|
|
45
|
+
files: {},
|
|
46
|
+
stated: {},
|
|
47
|
+
covered: {},
|
|
49
48
|
updated: "",
|
|
50
49
|
};
|
|
51
50
|
const file = sessionFile(sessionId, home);
|
|
@@ -64,19 +63,20 @@ export function readSession(sessionId, home) {
|
|
|
64
63
|
return empty;
|
|
65
64
|
const record = parsed;
|
|
66
65
|
return {
|
|
67
|
-
found: Array.isArray(record.found)
|
|
68
|
-
? record.found.filter((entry) => typeof entry?.name === "string" && typeof entry?.file === "string")
|
|
69
|
-
: [],
|
|
70
|
-
nudged: Array.isArray(record.nudged)
|
|
71
|
-
? record.nudged.filter((entry) => typeof entry === "string")
|
|
72
|
-
: [],
|
|
73
66
|
told: Array.isArray(record.told)
|
|
74
67
|
? record.told.filter((entry) => typeof entry === "string")
|
|
75
68
|
: [],
|
|
76
69
|
read: Array.isArray(record.read)
|
|
77
70
|
? record.read.filter((entry) => typeof entry === "string")
|
|
78
71
|
: [],
|
|
79
|
-
edited:
|
|
72
|
+
edited: stamps(record.edited),
|
|
73
|
+
files: Object.fromEntries(Object.entries(record.files ?? {}).filter((entry) => typeof entry[1] === "object" &&
|
|
74
|
+
entry[1] !== null &&
|
|
75
|
+
typeof entry[1].root === "string" &&
|
|
76
|
+
typeof entry[1].at === "number" &&
|
|
77
|
+
Number.isFinite(entry[1].at))),
|
|
78
|
+
stated: stamps(record.stated),
|
|
79
|
+
covered: stamps(record.covered),
|
|
80
80
|
updated: typeof record.updated === "string" ? record.updated : "",
|
|
81
81
|
};
|
|
82
82
|
}
|
|
@@ -105,8 +105,8 @@ export function writeAtomic(file, body) {
|
|
|
105
105
|
return true;
|
|
106
106
|
}
|
|
107
107
|
catch {
|
|
108
|
-
// Nothing to do and nothing to say:
|
|
109
|
-
// rides behind is not.
|
|
108
|
+
// Nothing to do and nothing to say: this record is a nicety and the edit
|
|
109
|
+
// it rides behind is not.
|
|
110
110
|
try {
|
|
111
111
|
fs.unlinkSync(temp);
|
|
112
112
|
}
|
|
@@ -201,40 +201,6 @@ export function removeSessions(home) {
|
|
|
201
201
|
}
|
|
202
202
|
return removed;
|
|
203
203
|
}
|
|
204
|
-
/**
|
|
205
|
-
* Add what one edit found, keeping the first sighting of each function.
|
|
206
|
-
*
|
|
207
|
-
* Deduplicated on file and name: an agent edits one file several times in a
|
|
208
|
-
* task, and every one of those edits re-reports the same new function.
|
|
209
|
-
*/
|
|
210
|
-
export function record(sessionId, found, home) {
|
|
211
|
-
const current = readSession(sessionId, home);
|
|
212
|
-
const seen = new Set(current.found.map(key));
|
|
213
|
-
for (const entry of found) {
|
|
214
|
-
if (seen.has(key(entry)))
|
|
215
|
-
continue;
|
|
216
|
-
seen.add(key(entry));
|
|
217
|
-
current.found.push(entry);
|
|
218
|
-
}
|
|
219
|
-
current.updated = new Date().toISOString();
|
|
220
|
-
write(sessionId, current, home);
|
|
221
|
-
return current;
|
|
222
|
-
}
|
|
223
|
-
/** What a nudge has not yet named, oldest first. */
|
|
224
|
-
export function pending(record) {
|
|
225
|
-
const nudged = new Set(record.nudged);
|
|
226
|
-
return record.found.filter((entry) => !nudged.has(key(entry)));
|
|
227
|
-
}
|
|
228
|
-
/** Mark entries as named, so the next stop of the same task says nothing. */
|
|
229
|
-
export function markNudged(sessionId, entries, home) {
|
|
230
|
-
const current = readSession(sessionId, home);
|
|
231
|
-
const nudged = new Set(current.nudged);
|
|
232
|
-
for (const entry of entries)
|
|
233
|
-
nudged.add(key(entry));
|
|
234
|
-
current.nudged = [...nudged];
|
|
235
|
-
current.updated = new Date().toISOString();
|
|
236
|
-
write(sessionId, current, home);
|
|
237
|
-
}
|
|
238
204
|
/**
|
|
239
205
|
* The key a file's uses lines are remembered under: its repo and its
|
|
240
206
|
* repo-relative path, so one path in two repos is two files.
|
|
@@ -258,10 +224,28 @@ export function markTold(sessionId, keys, home) {
|
|
|
258
224
|
current.updated = new Date().toISOString();
|
|
259
225
|
write(sessionId, current, home);
|
|
260
226
|
}
|
|
261
|
-
/**
|
|
262
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Remember that this session edited `files` (absolute paths) in the workspace
|
|
229
|
+
* at `root` at `at` (epoch ms).
|
|
230
|
+
*/
|
|
231
|
+
export function recordEdit(sessionId, root, at, home, files = []) {
|
|
263
232
|
const current = readSession(sessionId, home);
|
|
264
233
|
current.edited[root] = Math.max(at, current.edited[root] ?? 0);
|
|
234
|
+
for (const file of files) {
|
|
235
|
+
current.files[file] = { root, at: Math.max(at, current.files[file]?.at ?? 0) };
|
|
236
|
+
}
|
|
237
|
+
current.updated = new Date().toISOString();
|
|
238
|
+
write(sessionId, current, home);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Remember that Stop spoke about the change in `root` up to the edit at
|
|
242
|
+
* `upTo`, and whether every file of it was answered (`covered`).
|
|
243
|
+
*/
|
|
244
|
+
export function markStated(sessionId, root, upTo, covered, home) {
|
|
245
|
+
const current = readSession(sessionId, home);
|
|
246
|
+
current.stated[root] = Math.max(upTo, current.stated[root] ?? 0);
|
|
247
|
+
if (covered)
|
|
248
|
+
current.covered[root] = Math.max(upTo, current.covered[root] ?? 0);
|
|
265
249
|
current.updated = new Date().toISOString();
|
|
266
250
|
write(sessionId, current, home);
|
|
267
251
|
}
|
|
@@ -278,63 +262,15 @@ export function markRead(sessionId, file, home) {
|
|
|
278
262
|
current.updated = new Date().toISOString();
|
|
279
263
|
write(sessionId, current, home);
|
|
280
264
|
}
|
|
281
|
-
/**
|
|
282
|
-
* The nudge for one session, marked as spoken, or nothing to say (carrick#1335).
|
|
283
|
-
*
|
|
284
|
-
* The one place the sequence lives, because two hooks deliver it: Claude Code's
|
|
285
|
-
* `Stop`, and Codex's `UserPromptSubmit`, which is the only non-blocking
|
|
286
|
-
* model-visible event Codex gives us. Both read the same store, speak the same
|
|
287
|
-
* line and mark the same set; only the event name on the wire differs.
|
|
288
|
-
*
|
|
289
|
-
* The marking happens here, before the caller writes anything, and that order
|
|
290
|
-
* is the point: a nudge that is written and not recorded fires again on the
|
|
291
|
-
* next stop, and a task is several stops.
|
|
292
|
-
*/
|
|
293
|
-
export function drain(sessionId, root, home) {
|
|
294
|
-
const current = readSession(sessionId, home);
|
|
295
|
-
const waiting = pending(current);
|
|
296
|
-
if (waiting.length === 0)
|
|
297
|
-
return null;
|
|
298
|
-
const line = nudge(waiting, root === null ? "" : snapshotProjectSlug(root));
|
|
299
|
-
markNudged(sessionId, waiting, home);
|
|
300
|
-
return { line, named: waiting.length, found: current.found.length };
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* The one line the Stop hook hands the model: how many functions, at most two
|
|
304
|
-
* names, and the ask with the exact call (`functions`, one `{ description }` each: the
|
|
305
|
-
* functions are new, so the index has no name to find). Short on purpose, and it starts with "Carrick:" so the
|
|
306
|
-
* user can tell where it came from. The two limits on the answer (what the
|
|
307
|
-
* index was taken at, and that the match is on what a function is described as
|
|
308
|
-
* doing) live in the `carrick-reuse` skill, where the answer is read.
|
|
309
|
-
*/
|
|
310
|
-
export function nudge(entries, slug = "") {
|
|
311
|
-
const total = entries.length;
|
|
312
|
-
const shown = entries.slice(0, 2).map((entry) => entry.name);
|
|
313
|
-
const rest = total - shown.length;
|
|
314
|
-
const list = rest > 0
|
|
315
|
-
? `${shown.join(", ")} and ${rest} more`
|
|
316
|
-
: shown.length === 2
|
|
317
|
-
? `${shown[0]} and ${shown[1]}`
|
|
318
|
-
: shown[0];
|
|
319
|
-
const projectArg = slug === "" ? "" : `\`project: "${slug}"\` and `;
|
|
320
|
-
return `Carrick: this task added ${total} new function${total === 1 ? "" : "s"} (${list}). Check them for existing copies with one find_similar call, passing ${projectArg}\`functions\`, one \`{ description }\` per new function: one plain sentence saying what it does (new functions are not in the index yet, so a name is not found). Where it names an existing function that does the same job, or most of it, call that function instead: delete your copy, or, when the task asked for your function by name, keep the function but make its body call the existing one and add only what it lacks. Then tell the user in one line what Carrick found and what you changed.`;
|
|
321
|
-
}
|
|
322
265
|
/**
|
|
323
266
|
* The one project slug the workspace's cached hosted snapshot names, or ""
|
|
324
|
-
* when there is none or more than one (
|
|
267
|
+
* when there is none or more than one (a tool call needs one project).
|
|
325
268
|
* `snapshot.json` is written by the hosted refresh: `resolution.repos[]`
|
|
326
269
|
* carries each connected repo's `project_slug`.
|
|
327
270
|
*/
|
|
328
271
|
export function snapshotProjectSlug(root) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
parsed = JSON.parse(fs.readFileSync(path.join(root, ".carrick", "hosted", "snapshot.json"), "utf8"));
|
|
332
|
-
}
|
|
333
|
-
catch {
|
|
334
|
-
return "";
|
|
335
|
-
}
|
|
336
|
-
const repos = parsed?.resolution?.repos;
|
|
337
|
-
if (!Array.isArray(repos))
|
|
272
|
+
const repos = snapshotRepos(root);
|
|
273
|
+
if (repos === null)
|
|
338
274
|
return "";
|
|
339
275
|
const slugs = new Set();
|
|
340
276
|
for (const repo of repos) {
|
package/dist/hook/reuse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reuse.js","sourceRoot":"","sources":["../../src/hook/reuse.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,oEAAoE;AACpE,EAAE;AACF,2EAA2E;AAC3E,6EAA6E;AAC7E,+EAA+E;AAC/E,4EAA4E;AAC5E,gFAAgF;AAChF,6EAA6E;AAC7E,uEAAuE;AACvE,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,4EAA4E;AAC5E,6CAA6C;AAC7C,EAAE;AACF,iEAAiE;AAEjE,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAsC7B,mEAAmE;AACnE,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,sDAAsD;AACtD,MAAM,UAAU,MAAM,CAAC,SAAiB;IACtC,OAAO,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,OAAe,EAAE,CAAC,OAAO,EAAE;IACxE,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7B,OAAO,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACpF,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,CAAC,OAAO,EAAE;IACrD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,E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AAC,CAAC;IAC/D,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -9,3 +9,12 @@
|
|
|
9
9
|
export declare function runByCodex(env: NodeJS.ProcessEnv, stdin: string): boolean;
|
|
10
10
|
/** The shape Codex's `parse_session_start` takes the model context from. */
|
|
11
11
|
export declare function codexEmission(context: string): string;
|
|
12
|
+
/** Default gap between two statements that HEAD keeps the copy back. */
|
|
13
|
+
export declare const HELD_NOTICE_COOLDOWN_MS: number;
|
|
14
|
+
/**
|
|
15
|
+
* The hosted line, and, at most once per cooldown, the line saying HEAD keeps
|
|
16
|
+
* this machine's copy back (carrick#3433). Null where no record exists yet,
|
|
17
|
+
* which keeps the session start as it was. The claim is taken only when there
|
|
18
|
+
* is a held line to print, so a day of current copies does not use it up.
|
|
19
|
+
*/
|
|
20
|
+
export declare function hostedSync(root: string, now: number, env?: NodeJS.ProcessEnv): string[] | null;
|
|
@@ -16,13 +16,15 @@
|
|
|
16
16
|
// SessionStart hook's context from `hookSpecificOutput.additionalContext`
|
|
17
17
|
// (`codex-rs/hooks/src/engine/output_parser.rs`, `parse_session_start`), so
|
|
18
18
|
// there the lines go out as that JSON. Claude Code keeps the plain print.
|
|
19
|
+
import { readStdin } from "./stdin.js";
|
|
19
20
|
import { status } from "../cli.js";
|
|
20
21
|
import { resolveChannel } from "../channel.js";
|
|
21
22
|
import { createLogger } from "../log.js";
|
|
22
|
-
import { CHECK_BEFORE_DONE, renderSessionStart } from "../render.js";
|
|
23
|
+
import { CHECK_BEFORE_DONE, heldLine, hostedLine, renderSessionStart } from "../render.js";
|
|
24
|
+
import { lastSync } from "../hosted-snapshot.js";
|
|
23
25
|
import { resolveRoot, rootNote } from "../root.js";
|
|
24
26
|
import { currentVersion, readUpdateState, suppressed, updateNotice } from "../update.js";
|
|
25
|
-
import { forwardInBackground, refreshInBackground } from "./refresh.js";
|
|
27
|
+
import { claimRefresh, cooldownMs, forwardInBackground, markerPath, refreshInBackground, } from "./refresh.js";
|
|
26
28
|
import { versionMismatch } from "../init/outdated.js";
|
|
27
29
|
import { bringUpToDate } from "../init/self-update.js";
|
|
28
30
|
import { markInvoker } from "./invoker.js";
|
|
@@ -44,13 +46,8 @@ function versionLine() {
|
|
|
44
46
|
const state = readUpdateState(process.env);
|
|
45
47
|
return updateNotice(currentVersion(), state?.latest ?? null, { env: process.env });
|
|
46
48
|
}
|
|
47
|
-
async function
|
|
48
|
-
|
|
49
|
-
return "";
|
|
50
|
-
const chunks = [];
|
|
51
|
-
for await (const chunk of process.stdin)
|
|
52
|
-
chunks.push(Buffer.from(chunk));
|
|
53
|
-
return Buffer.concat(chunks).toString("utf8");
|
|
49
|
+
async function readStdinUnlessTty() {
|
|
50
|
+
return process.stdin.isTTY ? "" : readStdin();
|
|
54
51
|
}
|
|
55
52
|
/**
|
|
56
53
|
* Whether Codex, not Claude Code, is running this hook.
|
|
@@ -83,7 +80,7 @@ async function main() {
|
|
|
83
80
|
return;
|
|
84
81
|
}
|
|
85
82
|
const lines = [];
|
|
86
|
-
const codex = runByCodex(process.env, await
|
|
83
|
+
const codex = runByCodex(process.env, await readStdinUnlessTty());
|
|
87
84
|
const choice = resolveRoot({
|
|
88
85
|
clientRoot: process.cwd(),
|
|
89
86
|
projectDir: process.env["CLAUDE_PROJECT_DIR"] ?? null,
|
|
@@ -103,12 +100,15 @@ async function main() {
|
|
|
103
100
|
// because this runs once per session and the agent about to work here is the
|
|
104
101
|
// reader who can act on it (carrick#1372).
|
|
105
102
|
if (choice.markerFound) {
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
103
|
+
// Both harnesses: Codex gets the AGENTS.md section and the skills, which it
|
|
104
|
+
// reads with no trust gate (carrick#3435). It has no `CLAUDE_PROJECT_DIR`, so
|
|
105
|
+
// the Claude Code settings files are left to a Claude Code session, and
|
|
106
|
+
// `.codex/hooks.json` is never written (`init/self-update.ts`).
|
|
107
|
+
// A by-hand run (neither harness) writes nothing.
|
|
108
|
+
const projectDir = codex ? null : process.env["CLAUDE_PROJECT_DIR"] || null;
|
|
109
|
+
if (codex || projectDir) {
|
|
110
110
|
try {
|
|
111
|
-
lines.push(...bringUpToDate(choice.root, projectDir, currentVersion()));
|
|
111
|
+
lines.push(...bringUpToDate(choice.root, projectDir, currentVersion(), (message) => log(message)));
|
|
112
112
|
}
|
|
113
113
|
catch (error) {
|
|
114
114
|
log("self-update failed", String(error));
|
|
@@ -124,9 +124,16 @@ async function main() {
|
|
|
124
124
|
flush(lines, codex);
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
|
+
// What the MCP answers from, and the copy the hooks compare against, ahead
|
|
128
|
+
// of this machine's own scan: that scan's date alone was read as the age of
|
|
129
|
+
// every answer (carrick#3432). From the last background move's record; the
|
|
130
|
+
// move itself runs after this read, so the line is at most one run behind.
|
|
131
|
+
const hosted = outcome.result.error ? null : hostedSync(choice.root, Date.now());
|
|
132
|
+
if (hosted)
|
|
133
|
+
lines.push(...hosted);
|
|
127
134
|
// Ends with a newline: this is a line a developer also runs by hand and
|
|
128
135
|
// compares against `carrick status`, and that one ends its output properly.
|
|
129
|
-
lines.push(renderSessionStart(outcome.result));
|
|
136
|
+
lines.push(renderSessionStart(outcome.result, { afterHostedLine: hosted !== null }));
|
|
130
137
|
if (!outcome.result.error)
|
|
131
138
|
lines.push(CHECK_BEFORE_DONE);
|
|
132
139
|
// The hosted index the first CI scan writes is picked up here rather than by
|
|
@@ -154,6 +161,26 @@ async function main() {
|
|
|
154
161
|
}
|
|
155
162
|
flush(lines, codex);
|
|
156
163
|
}
|
|
164
|
+
/** Default gap between two statements that HEAD keeps the copy back. */
|
|
165
|
+
export const HELD_NOTICE_COOLDOWN_MS = 24 * 60 * 60_000;
|
|
166
|
+
/**
|
|
167
|
+
* The hosted line, and, at most once per cooldown, the line saying HEAD keeps
|
|
168
|
+
* this machine's copy back (carrick#3433). Null where no record exists yet,
|
|
169
|
+
* which keeps the session start as it was. The claim is taken only when there
|
|
170
|
+
* is a held line to print, so a day of current copies does not use it up.
|
|
171
|
+
*/
|
|
172
|
+
export function hostedSync(root, now, env = process.env) {
|
|
173
|
+
const sync = lastSync(root);
|
|
174
|
+
const hosted = sync ? hostedLine(sync, now) : null;
|
|
175
|
+
if (!sync || !hosted)
|
|
176
|
+
return null;
|
|
177
|
+
const lines = [hosted];
|
|
178
|
+
const held = heldLine(sync);
|
|
179
|
+
const cooldown = cooldownMs(env, "CARRICK_HELD_NOTICE_COOLDOWN_MS", HELD_NOTICE_COOLDOWN_MS);
|
|
180
|
+
if (held && claimRefresh(markerPath(root, "last-held-notice"), now, cooldown))
|
|
181
|
+
lines.push(held);
|
|
182
|
+
return lines;
|
|
183
|
+
}
|
|
157
184
|
/** One write at the end, so the Codex form is a single JSON document. */
|
|
158
185
|
function flush(lines, codex) {
|
|
159
186
|
if (lines.length === 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-start.js","sourceRoot":"","sources":["../../src/hook/session-start.ts"],"names":[],"mappings":";AACA,8EAA8E;AAC9E,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,gFAAgF;AAChF,4EAA4E;AAC5E,mDAAmD;AACnD,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,0EAA0E;AAC1E,gEAAgE;AAChE,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,4EAA4E;AAC5E,0EAA0E;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"session-start.js","sour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;IAChG,OAAO,KAAK,CAAC;AACf,CAAC;AAED,yEAAyE;AACzE,SAAS,KAAK,CAAC,KAAe,EAAE,KAAc;IAC5C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC/B,IAAI,KAAK;QAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;QAC5D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,IAAI,EAAE,CAAC;AACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** All of stdin as text. Shared by the hook entry points; Node built-ins only. */
|
|
2
|
+
export async function readStdin() {
|
|
3
|
+
const chunks = [];
|
|
4
|
+
for await (const chunk of process.stdin)
|
|
5
|
+
chunks.push(Buffer.from(chunk));
|
|
6
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=stdin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdin.js","sourceRoot":"","sources":["../../src/hook/stdin.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK;QAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACzE,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC"}
|
package/dist/hook/stop-wait.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Answer } from "./rechecks.ts";
|
|
1
2
|
/** How long Stop waits when its entry carries no `--wait-s` (an older install). */
|
|
2
3
|
export declare const DEFAULT_WAIT_S = 3;
|
|
3
4
|
/** The `--wait-s <n>` (or `--wait-s=<n>`) in an argument list, else the default. */
|
|
@@ -11,7 +12,29 @@ export type StopOptions = {
|
|
|
11
12
|
ensure?: (root: string) => boolean;
|
|
12
13
|
};
|
|
13
14
|
export type StopResult = {
|
|
14
|
-
/** Lines to print
|
|
15
|
+
/** Lines to print; empty when there is nothing to say. */
|
|
15
16
|
lines: string[];
|
|
16
17
|
};
|
|
18
|
+
export type Coverage = {
|
|
19
|
+
/** How many files this session recorded an edit of in the workspace. */
|
|
20
|
+
files: number;
|
|
21
|
+
/** The newest of those edits: what a statement about the change covers. */
|
|
22
|
+
upTo: number;
|
|
23
|
+
/** The answers that cover their file, one per covered file. */
|
|
24
|
+
covered: Answer[];
|
|
25
|
+
/** Each file not covered, workspace-relative, and why. */
|
|
26
|
+
gaps: Array<{
|
|
27
|
+
file: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Whether the per-file re-checks answered every file this session edited in
|
|
33
|
+
* the workspace at `root` (carrick#3466). A file is covered when its newest
|
|
34
|
+
* entry was queued (or answered in hand) at or after its last edit, is
|
|
35
|
+
* answered with no error, answers the edit as it stands on disk, and judged
|
|
36
|
+
* no service that reads it at its indexed version. Everything else is a gap,
|
|
37
|
+
* with the reason a reader can act on.
|
|
38
|
+
*/
|
|
39
|
+
export declare function sessionCoverage(session: string, root: string, home?: string, now?: number): Coverage;
|
|
17
40
|
export declare function stopAnswers(session: string, options: StopOptions): Promise<StopResult>;
|