carrick 0.3.142 → 0.3.144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/carrick.mjs +7 -7
- package/dist/auth/read.d.ts +0 -10
- package/dist/auth/read.js +3 -11
- package/dist/auth/read.js.map +1 -1
- package/dist/cli.d.ts +23 -20
- package/dist/cli.js +17 -32
- package/dist/cli.js.map +1 -1
- package/dist/contract.d.ts +72 -0
- package/dist/contract.js +14 -0
- package/dist/contract.js.map +1 -1
- package/dist/hook/checked.d.ts +11 -0
- package/dist/hook/checked.js +44 -0
- package/dist/hook/checked.js.map +1 -0
- package/dist/hook/edited.d.ts +22 -0
- package/dist/hook/edited.js +84 -0
- package/dist/hook/edited.js.map +1 -0
- package/dist/hook/invoker.d.ts +7 -0
- package/dist/hook/invoker.js +18 -0
- package/dist/hook/invoker.js.map +1 -0
- package/dist/hook/late.d.ts +8 -0
- package/dist/hook/late.js +60 -0
- package/dist/hook/late.js.map +1 -0
- package/dist/hook/post-edit.d.ts +0 -22
- package/dist/hook/post-edit.js +78 -126
- package/dist/hook/post-edit.js.map +1 -1
- package/dist/hook/post-read.js +19 -9
- package/dist/hook/post-read.js.map +1 -1
- package/dist/hook/probe.d.ts +15 -0
- package/dist/hook/probe.js +41 -0
- package/dist/hook/probe.js.map +1 -0
- package/dist/hook/recheck-run.d.ts +2 -0
- package/dist/hook/recheck-run.js +28 -0
- package/dist/hook/recheck-run.js.map +1 -0
- package/dist/hook/rechecks.d.ts +108 -0
- package/dist/hook/rechecks.js +537 -0
- package/dist/hook/rechecks.js.map +1 -0
- package/dist/hook/refresh.d.ts +1 -0
- package/dist/hook/refresh.js +1 -1
- package/dist/hook/refresh.js.map +1 -1
- package/dist/hook/reuse.d.ts +15 -3
- package/dist/hook/reuse.js +31 -11
- package/dist/hook/reuse.js.map +1 -1
- package/dist/hook/session-start.js +14 -0
- package/dist/hook/session-start.js.map +1 -1
- package/dist/hook/stop-wait.d.ts +17 -0
- package/dist/hook/stop-wait.js +120 -0
- package/dist/hook/stop-wait.js.map +1 -0
- package/dist/hook/stop.js +12 -1
- package/dist/hook/stop.js.map +1 -1
- package/dist/hook/user-prompt.js +4 -1
- package/dist/hook/user-prompt.js.map +1 -1
- package/dist/init/agents-section.js +1 -3
- package/dist/init/agents-section.js.map +1 -1
- package/dist/init/connect.d.ts +6 -107
- package/dist/init/connect.js +7 -318
- package/dist/init/connect.js.map +1 -1
- package/dist/init/doctor.d.ts +8 -71
- package/dist/init/doctor.js +37 -223
- package/dist/init/doctor.js.map +1 -1
- package/dist/init/hosted.d.ts +7 -7
- package/dist/init/hosted.js +8 -10
- package/dist/init/hosted.js.map +1 -1
- package/dist/init/outdated.d.ts +11 -0
- package/dist/init/outdated.js +1 -1
- package/dist/init/outdated.js.map +1 -1
- package/dist/init/output.d.ts +0 -55
- package/dist/init/output.js +0 -142
- package/dist/init/output.js.map +1 -1
- package/dist/init/projects.d.ts +3 -200
- package/dist/init/projects.js +22 -352
- package/dist/init/projects.js.map +1 -1
- package/dist/init/remove.js +4 -5
- package/dist/init/remove.js.map +1 -1
- package/dist/init/repos.d.ts +25 -53
- package/dist/init/repos.js +28 -65
- package/dist/init/repos.js.map +1 -1
- package/dist/init/run.d.ts +52 -212
- package/dist/init/run.js +247 -987
- package/dist/init/run.js.map +1 -1
- package/dist/init/self-update.d.ts +18 -0
- package/dist/init/self-update.js +147 -0
- package/dist/init/self-update.js.map +1 -0
- package/dist/init/settings.d.ts +2 -0
- package/dist/init/settings.js +13 -2
- package/dist/init/settings.js.map +1 -1
- package/dist/render.d.ts +24 -6
- package/dist/render.js +135 -28
- package/dist/render.js.map +1 -1
- package/dist/templates.d.ts +1 -6
- package/dist/templates.js +4 -14
- package/dist/templates.js.map +1 -1
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/hooks/hooks.json +3 -2
- package/sidecar/dist/src/capture/api.d.ts +2 -2
- package/sidecar/dist/src/capture/deno-project.js +5 -1
- package/sidecar/dist/src/capture/index.d.ts +18 -0
- package/sidecar/dist/src/capture/index.js +73 -0
- package/sidecar/dist/src/index.js +1 -1
- package/sidecar/dist/src/library-claims.d.ts +4 -0
- package/sidecar/dist/src/library-claims.js +2 -2
- package/sidecar/dist/src/project-loader.js +9 -2
- package/sidecar/dist/src/type-inferrer.d.ts +17 -2
- package/sidecar/dist/src/type-inferrer.js +59 -16
- package/sidecar/dist/src/types.d.ts +26 -0
- package/sidecar/dist/src/validators.d.ts +6 -0
- package/sidecar/dist/src/validators.js +2 -0
- package/templates/carrick.json +0 -7
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ npm install -g carrick
|
|
|
17
17
|
carrick init
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
`carrick init` signs you in,
|
|
20
|
+
`carrick init` signs you in, connects your agent and downloads your index. The [quick start](https://docs.carrick.tools/quickstart) has the details (Node 24 or newer).
|
|
21
21
|
|
|
22
22
|
## One index, three surfaces
|
|
23
23
|
|
package/bin/carrick.mjs
CHANGED
|
@@ -38,6 +38,7 @@ if (nodeMajor() < NODE_FLOOR) {
|
|
|
38
38
|
const HOOKS = {
|
|
39
39
|
"post-edit": "../dist/hook/post-edit.js",
|
|
40
40
|
"post-read": "../dist/hook/post-read.js",
|
|
41
|
+
"recheck-run": "../dist/hook/recheck-run.js",
|
|
41
42
|
"session-start": "../dist/hook/session-start.js",
|
|
42
43
|
stop: "../dist/hook/stop.js",
|
|
43
44
|
"user-prompt": "../dist/hook/user-prompt.js",
|
|
@@ -296,8 +297,7 @@ function extraHelp() {
|
|
|
296
297
|
" task, silent when the task added no function)",
|
|
297
298
|
" hook user-prompt Codex UserPromptSubmit hook (the same nudge,",
|
|
298
299
|
" delivered on the next prompt)",
|
|
299
|
-
" templates
|
|
300
|
-
" carrick.json",
|
|
300
|
+
" templates workflow print the GitHub Actions workflow file",
|
|
301
301
|
" --version the version of this package",
|
|
302
302
|
"",
|
|
303
303
|
"ENVIRONMENT:",
|
|
@@ -306,7 +306,7 @@ function extraHelp() {
|
|
|
306
306
|
" one cached file and refreshes it in the",
|
|
307
307
|
" background; it never installs anything.",
|
|
308
308
|
"",
|
|
309
|
-
"`carrick init
|
|
309
|
+
"`carrick init` sets this folder up for your agent; `carrick init --help`",
|
|
310
310
|
"prints its own arguments.",
|
|
311
311
|
"",
|
|
312
312
|
].join("\n");
|
|
@@ -327,11 +327,11 @@ const SUBCOMMAND_HELP = {
|
|
|
327
327
|
"",
|
|
328
328
|
],
|
|
329
329
|
templates: [
|
|
330
|
-
"carrick templates
|
|
330
|
+
"carrick templates workflow [--variable value]...",
|
|
331
331
|
"",
|
|
332
|
-
"Print
|
|
333
|
-
"
|
|
334
|
-
"
|
|
332
|
+
"Print the GitHub Actions workflow file to stdout. Each --variable value pair",
|
|
333
|
+
"fills a placeholder of that name, for example `--default-branch trunk`. It",
|
|
334
|
+
"writes no file.",
|
|
335
335
|
"",
|
|
336
336
|
],
|
|
337
337
|
};
|
package/dist/auth/read.d.ts
CHANGED
|
@@ -5,20 +5,14 @@ declare const response: z.ZodObject<{
|
|
|
5
5
|
slug: z.ZodString;
|
|
6
6
|
billing_tier: z.ZodEnum<["free", "cross_repo", "paid"]>;
|
|
7
7
|
installed: z.ZodBoolean;
|
|
8
|
-
role: z.ZodCatch<z.ZodOptional<z.ZodEnum<["owner", "admin", "member"]>>>;
|
|
9
|
-
index_builder: z.ZodCatch<z.ZodOptional<z.ZodEnum<["cloud", "laptop"]>>>;
|
|
10
8
|
}, "strip", z.ZodTypeAny, {
|
|
11
9
|
installed: boolean;
|
|
12
10
|
slug: string;
|
|
13
11
|
billing_tier: "free" | "cross_repo" | "paid";
|
|
14
|
-
role?: "owner" | "admin" | "member" | undefined;
|
|
15
|
-
index_builder?: "cloud" | "laptop" | undefined;
|
|
16
12
|
}, {
|
|
17
13
|
installed: boolean;
|
|
18
14
|
slug: string;
|
|
19
15
|
billing_tier: "free" | "cross_repo" | "paid";
|
|
20
|
-
role?: unknown;
|
|
21
|
-
index_builder?: unknown;
|
|
22
16
|
}>;
|
|
23
17
|
allowance_sentence: z.ZodNullable<z.ZodString>;
|
|
24
18
|
repos: z.ZodArray<z.ZodDiscriminatedUnion<"connected", [z.ZodObject<{
|
|
@@ -90,8 +84,6 @@ declare const response: z.ZodObject<{
|
|
|
90
84
|
installed: boolean;
|
|
91
85
|
slug: string;
|
|
92
86
|
billing_tier: "free" | "cross_repo" | "paid";
|
|
93
|
-
role?: "owner" | "admin" | "member" | undefined;
|
|
94
|
-
index_builder?: "cloud" | "laptop" | undefined;
|
|
95
87
|
};
|
|
96
88
|
repos: ({
|
|
97
89
|
connected: false;
|
|
@@ -119,8 +111,6 @@ declare const response: z.ZodObject<{
|
|
|
119
111
|
installed: boolean;
|
|
120
112
|
slug: string;
|
|
121
113
|
billing_tier: "free" | "cross_repo" | "paid";
|
|
122
|
-
role?: unknown;
|
|
123
|
-
index_builder?: unknown;
|
|
124
114
|
};
|
|
125
115
|
repos: ({
|
|
126
116
|
connected: false;
|
package/dist/auth/read.js
CHANGED
|
@@ -11,17 +11,9 @@ const response = z.object({
|
|
|
11
11
|
slug: z.string().regex(/^[a-zA-Z0-9_-]+$/),
|
|
12
12
|
billing_tier: z.enum(["free", "cross_repo", "paid"]),
|
|
13
13
|
installed: z.boolean(),
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// outside the pinned three reads as unknown too, rather than failing the
|
|
18
|
-
// whole read.
|
|
19
|
-
role: z.enum(["owner", "admin", "member"]).optional().catch(undefined),
|
|
20
|
-
// Who builds this workspace's index (carrick-cloud#1969). Only "cloud"
|
|
21
|
-
// changes what `carrick init` does: absent, "laptop" and a value this
|
|
22
|
-
// build does not know all read as the laptop lane, never as a failed read
|
|
23
|
-
// (carrick#2219).
|
|
24
|
-
index_builder: z.enum(["cloud", "laptop"]).optional().catch(undefined),
|
|
14
|
+
// No `role` and no `index_builder`: `carrick init` has one run whatever
|
|
15
|
+
// the server says, waits on no browser step, and reads neither
|
|
16
|
+
// (carrick#3361).
|
|
25
17
|
}),
|
|
26
18
|
allowance_sentence: z.string().nullable(),
|
|
27
19
|
repos: z.array(repository),
|
package/dist/auth/read.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/auth/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC1J,MAAM,UAAU,GAAG,CAAC,CAAC,kBAAkB,CAAC,WAAW,EAAE;IACnD,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;IAChE,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;CAC9I,CAAC,CAAC;AACH,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IACxB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,yBA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,EAAE,UAAU,KAAK,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YACjF,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;SACzD,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QAAC,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;IAAC,CAAC;IAChH,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,6GAA6G,CAAC,CAAC;IAC1J,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;IAC5F,IAAI,OAAgB,CAAC;IACrB,IAAI,CAAC;QAAC,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IAAC,CAAC;IACtC,MAAM,CAAC;QAAC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAAC,CAAC;IAC7E,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,yHAAyH,CAAC,CAAC;IAChK,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -14,39 +14,42 @@ export type RunOptions = {
|
|
|
14
14
|
env?: NodeJS.ProcessEnv;
|
|
15
15
|
/** Injectable for tests; defaults to the real `carrick` binary. */
|
|
16
16
|
bin?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The limit for this call in ms, used when `CARRICK_TIMEOUT_MS` is not set
|
|
19
|
+
* (the environment's own value always wins). Absent: five seconds.
|
|
20
|
+
*/
|
|
21
|
+
limitMs?: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* What a `--recheck` call must state: its own limit. There is no default,
|
|
25
|
+
* because the right one depends on who is asking (a hook's probe, or the
|
|
26
|
+
* background runner), and a wrong one kills the call before it answers.
|
|
27
|
+
* `noRescan` is the probe: it answers at once, or says `recheck.deferred`.
|
|
28
|
+
*/
|
|
29
|
+
export type RecheckOptions = RunOptions & {
|
|
30
|
+
recheck: true;
|
|
31
|
+
limitMs: number;
|
|
32
|
+
noRescan?: boolean;
|
|
17
33
|
};
|
|
18
34
|
/**
|
|
19
35
|
* `carrick check <file> --json`, run from the workspace root.
|
|
20
36
|
*
|
|
21
37
|
* `recheck` asks the binary to re-extract the file and re-judge it against the
|
|
22
38
|
* index before answering, which costs a scan of that file's repo. It is passed
|
|
23
|
-
* by the post-edit hook and by nothing else: the
|
|
24
|
-
* every save, and a file being edited is always
|
|
25
|
-
* (carrick#1036).
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
export declare function check(file: string, options: RunOptions & {
|
|
30
|
-
recheck?: boolean;
|
|
31
|
-
}): Promise<RunOutcome<CheckResult>>;
|
|
32
|
-
/**
|
|
33
|
-
* The limit for a `--recheck` call: the caller's own if it set one, and
|
|
34
|
-
* otherwise long enough to outlast the binary's budget and still return inside
|
|
35
|
-
* the hook's fifteen seconds.
|
|
36
|
-
*
|
|
37
|
-
* A call about several files (`files` > 1, only ever a Codex patch) gets ten
|
|
38
|
-
* more seconds per further file, inside the 60 s Codex gives the hook. The
|
|
39
|
-
* binary stops re-checking a repo after its first miss, so a patch on a repo
|
|
40
|
-
* where the re-check does not fit waits out one budget, not one per file.
|
|
39
|
+
* by the post-edit hook, by the background runner and by nothing else: the
|
|
40
|
+
* language server runs this on every save, and a file being edited is always
|
|
41
|
+
* newer than the index (carrick#1036). A re-check states its own `limitMs`:
|
|
42
|
+
* one cut off by this timeout prints nothing at all, where one cut off by the
|
|
43
|
+
* binary's own budget still answers, so the caller sizes the limit above it.
|
|
41
44
|
*/
|
|
42
|
-
export declare function
|
|
45
|
+
export declare function check(file: string, options: RunOptions | RecheckOptions): Promise<RunOutcome<CheckResult>>;
|
|
43
46
|
/**
|
|
44
47
|
* `carrick check --each <files...> --json --recheck`: every file of one patch
|
|
45
48
|
* in one binary call (each answered as `check <file> --recheck` would), so a
|
|
46
49
|
* patch that touches six files starts one process rather than six. The
|
|
47
50
|
* answers come back in the order asked; `null` for a file the binary refused.
|
|
48
51
|
*/
|
|
49
|
-
export declare function checkEach(files: string[], options:
|
|
52
|
+
export declare function checkEach(files: string[], options: Omit<RecheckOptions, "recheck">): Promise<RunOutcome<Array<CheckResult | null>>>;
|
|
50
53
|
/**
|
|
51
54
|
* `carrick status --json`: the workspace, with no file in the question.
|
|
52
55
|
*
|
package/dist/cli.js
CHANGED
|
@@ -23,7 +23,7 @@ async function run(args, options, parse) {
|
|
|
23
23
|
execFile(bin, args, {
|
|
24
24
|
cwd: options.cwd,
|
|
25
25
|
env,
|
|
26
|
-
timeout: timeoutMs(env),
|
|
26
|
+
timeout: env["CARRICK_TIMEOUT_MS"] ? timeoutMs(env) : (options.limitMs ?? timeoutMs(env)),
|
|
27
27
|
maxBuffer: 32 * 1024 * 1024,
|
|
28
28
|
encoding: "utf8",
|
|
29
29
|
}, (error, stdout) => {
|
|
@@ -45,34 +45,20 @@ async function run(args, options, parse) {
|
|
|
45
45
|
*
|
|
46
46
|
* `recheck` asks the binary to re-extract the file and re-judge it against the
|
|
47
47
|
* index before answering, which costs a scan of that file's repo. It is passed
|
|
48
|
-
* by the post-edit hook and by nothing else: the
|
|
49
|
-
* every save, and a file being edited is always
|
|
50
|
-
* (carrick#1036).
|
|
51
|
-
*
|
|
52
|
-
*
|
|
48
|
+
* by the post-edit hook, by the background runner and by nothing else: the
|
|
49
|
+
* language server runs this on every save, and a file being edited is always
|
|
50
|
+
* newer than the index (carrick#1036). A re-check states its own `limitMs`:
|
|
51
|
+
* one cut off by this timeout prints nothing at all, where one cut off by the
|
|
52
|
+
* binary's own budget still answers, so the caller sizes the limit above it.
|
|
53
53
|
*/
|
|
54
54
|
export async function check(file, options) {
|
|
55
|
-
const args =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
* The limit for a `--recheck` call: the caller's own if it set one, and
|
|
63
|
-
* otherwise long enough to outlast the binary's budget and still return inside
|
|
64
|
-
* the hook's fifteen seconds.
|
|
65
|
-
*
|
|
66
|
-
* A call about several files (`files` > 1, only ever a Codex patch) gets ten
|
|
67
|
-
* more seconds per further file, inside the 60 s Codex gives the hook. The
|
|
68
|
-
* binary stops re-checking a repo after its first miss, so a patch on a repo
|
|
69
|
-
* where the re-check does not fit waits out one budget, not one per file.
|
|
70
|
-
*/
|
|
71
|
-
export function recheckTimeoutMs(env = process.env, files = 1) {
|
|
72
|
-
const own = env["CARRICK_TIMEOUT_MS"];
|
|
73
|
-
if (own)
|
|
74
|
-
return own;
|
|
75
|
-
return String(Math.min(12000 + 10000 * Math.max(files - 1, 0), 55000));
|
|
55
|
+
const args = ["check", file, "--json"];
|
|
56
|
+
if ("recheck" in options && options.recheck) {
|
|
57
|
+
args.push("--recheck");
|
|
58
|
+
if (options.noRescan)
|
|
59
|
+
args.push("--no-rescan");
|
|
60
|
+
}
|
|
61
|
+
return await run(args, options, parseCheckResult);
|
|
76
62
|
}
|
|
77
63
|
/**
|
|
78
64
|
* `carrick check --each <files...> --json --recheck`: every file of one patch
|
|
@@ -81,11 +67,10 @@ export function recheckTimeoutMs(env = process.env, files = 1) {
|
|
|
81
67
|
* answers come back in the order asked; `null` for a file the binary refused.
|
|
82
68
|
*/
|
|
83
69
|
export async function checkEach(files, options) {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return await run(["check", "--each", ...files, "--json", "--recheck"], { ...options, env }, parseCheckResults);
|
|
70
|
+
const args = ["check", "--each", ...files, "--json", "--recheck"];
|
|
71
|
+
if (options.noRescan)
|
|
72
|
+
args.push("--no-rescan");
|
|
73
|
+
return await run(args, options, parseCheckResults);
|
|
89
74
|
}
|
|
90
75
|
/**
|
|
91
76
|
* `carrick status --json`: the workspace, with no file in the question.
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,4EAA4E;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,GAGlB,MAAM,eAAe,CAAC;AAEvB,yEAAyE;AACzE,MAAM,UAAU,MAAM,CAAC,MAAyB,OAAO,CAAC,GAAG;IACzD,OAAO,GAAG,CAAC,aAAa,CAAC,IAAI,SAAS,CAAC;AACzC,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,SAAS,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC5D,MAAM,GAAG,GAAG,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IAC3D,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/D,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,4EAA4E;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,GAGlB,MAAM,eAAe,CAAC;AAEv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EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IAClE,IAAI,OAAO,CAAC,QAAQ;QAAE,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC/C,OAAO,MAAM,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAmD;IAEnD,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS;QAC5B,CAAC,CAAC,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC;QACxD,CAAC,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACzB,OAAO,MAAM,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACrD,CAAC"}
|
package/dist/contract.d.ts
CHANGED
|
@@ -132,6 +132,12 @@ export type CheckResult = {
|
|
|
132
132
|
* Absent only on a read that did not ask for a re-check.
|
|
133
133
|
*/
|
|
134
134
|
recheck?: Recheck;
|
|
135
|
+
/**
|
|
136
|
+
* Whether the type check ran, and why not (carrick#3204). A re-check that
|
|
137
|
+
* answered states its own run; every other answer states the index's.
|
|
138
|
+
* Absent from an older CLI.
|
|
139
|
+
*/
|
|
140
|
+
type_check?: TypeCheckState;
|
|
135
141
|
/**
|
|
136
142
|
* Who uses this file from elsewhere in its repo, already rendered by the CLI:
|
|
137
143
|
* one line per type an operation reads and per function with callers in
|
|
@@ -139,6 +145,15 @@ export type CheckResult = {
|
|
|
139
145
|
*/
|
|
140
146
|
uses_lines?: string[];
|
|
141
147
|
};
|
|
148
|
+
/** What the type check did: `type_check` on a check answer and on a status answer. */
|
|
149
|
+
export type TypeCheckState = {
|
|
150
|
+
/** False when the check did not run at all. */
|
|
151
|
+
ran: boolean;
|
|
152
|
+
/** Why it did not run. Absent when it ran. */
|
|
153
|
+
reason?: string;
|
|
154
|
+
pairs: number;
|
|
155
|
+
judged: number;
|
|
156
|
+
};
|
|
142
157
|
/** The `recheck` block of a `carrick.check/0` answer. */
|
|
143
158
|
export type Recheck = {
|
|
144
159
|
/**
|
|
@@ -172,6 +187,58 @@ export type Recheck = {
|
|
|
172
187
|
* are the indexed ones until the next `carrick refresh`. Absent otherwise.
|
|
173
188
|
*/
|
|
174
189
|
known_miss?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* True on a `none` from `check --recheck --no-rescan` for an edit that
|
|
192
|
+
* needs a re-scan: the call was asked not to start one, so the rows are the
|
|
193
|
+
* indexed ones. Absent otherwise.
|
|
194
|
+
*/
|
|
195
|
+
deferred?: boolean;
|
|
196
|
+
/** Which services this re-check read and which it judged at another version. */
|
|
197
|
+
scope?: RecheckScope;
|
|
198
|
+
/**
|
|
199
|
+
* Rows outside the edited file whose state this edit moved: a pair that
|
|
200
|
+
* agreed in the index and now mismatches, and a call the index matched that
|
|
201
|
+
* now reaches no route. Absent when the edit moved nothing.
|
|
202
|
+
*/
|
|
203
|
+
moved?: MovedRow[];
|
|
204
|
+
};
|
|
205
|
+
/** One row of `recheck.moved` (`docs/local-mode-output.md`, "`recheck.moved`"). */
|
|
206
|
+
export type MovedRow = {
|
|
207
|
+
/** Relative to the workspace root. */
|
|
208
|
+
file: string;
|
|
209
|
+
line?: number;
|
|
210
|
+
role: "route" | "call";
|
|
211
|
+
method: string;
|
|
212
|
+
path: string;
|
|
213
|
+
/** `compatible`, `matched` (a call that had a route) or `not_judged`. */
|
|
214
|
+
before: "compatible" | "matched" | "not_judged";
|
|
215
|
+
after: "type_mismatch" | "method_mismatch" | "no_route";
|
|
216
|
+
/** The other side, as `service file:line`. Empty on `no_route`. */
|
|
217
|
+
counterparts: string[];
|
|
218
|
+
reason: string;
|
|
219
|
+
/** The index held no resolved, compatible pair: never called a break. */
|
|
220
|
+
not_judged_before: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* The index was written by another carrick build: the verdict may have moved
|
|
223
|
+
* because the build changed, not because of the edit. Absent when false.
|
|
224
|
+
*/
|
|
225
|
+
other_build?: boolean;
|
|
226
|
+
};
|
|
227
|
+
/** The `scope` of a `recheck` block (`docs/local-mode-output.md`, "recheck"). */
|
|
228
|
+
export type RecheckScope = {
|
|
229
|
+
/** The edited file's service first, then every service reading a type it declares. */
|
|
230
|
+
reread: string[];
|
|
231
|
+
/** Every other service, with whose copy its verdicts used. */
|
|
232
|
+
not_reread: {
|
|
233
|
+
service: string;
|
|
234
|
+
operations: number;
|
|
235
|
+
reason: string;
|
|
236
|
+
}[];
|
|
237
|
+
/**
|
|
238
|
+
* The ones of `not_reread` judged at a version that predates the work: edited
|
|
239
|
+
* since the index with no re-check copy, or reading a path edited since it.
|
|
240
|
+
*/
|
|
241
|
+
stale: string[];
|
|
175
242
|
};
|
|
176
243
|
/** One function the working tree declares and the index does not. */
|
|
177
244
|
export type NewFunction = {
|
|
@@ -360,6 +427,11 @@ export type StatusResult = {
|
|
|
360
427
|
* the sentence rather than reconstructing one.
|
|
361
428
|
*/
|
|
362
429
|
analysing?: string[];
|
|
430
|
+
/**
|
|
431
|
+
* What the last build's type check did (carrick#3204). The CLI's status
|
|
432
|
+
* names it `skipped` when it did not run; it is mapped to this shape on read.
|
|
433
|
+
*/
|
|
434
|
+
type_check?: TypeCheckState;
|
|
363
435
|
services: StatusService[];
|
|
364
436
|
};
|
|
365
437
|
/**
|
package/dist/contract.js
CHANGED
|
@@ -97,6 +97,10 @@ function checkResultOf(parsed) {
|
|
|
97
97
|
if (isRecord(recheck) && typeof recheck["ran"] === "string") {
|
|
98
98
|
result.recheck = recheck;
|
|
99
99
|
}
|
|
100
|
+
const typeCheck = parsed["type_check"];
|
|
101
|
+
if (isRecord(typeCheck) && typeof typeCheck["ran"] === "boolean") {
|
|
102
|
+
result.type_check = typeCheck;
|
|
103
|
+
}
|
|
100
104
|
return result;
|
|
101
105
|
}
|
|
102
106
|
/**
|
|
@@ -160,6 +164,16 @@ export function parseStatusResult(stdout) {
|
|
|
160
164
|
if (isRecord(lastScan) && Array.isArray(lastScan["scans"])) {
|
|
161
165
|
result.last_scan = lastScan;
|
|
162
166
|
}
|
|
167
|
+
const statusCheck = parsed["type_check"];
|
|
168
|
+
if (isRecord(statusCheck) && typeof statusCheck["pairs"] === "number") {
|
|
169
|
+
const skipped = statusCheck["skipped"];
|
|
170
|
+
result.type_check = {
|
|
171
|
+
ran: typeof skipped !== "string",
|
|
172
|
+
...(typeof skipped === "string" ? { reason: skipped } : {}),
|
|
173
|
+
pairs: statusCheck["pairs"],
|
|
174
|
+
judged: typeof statusCheck["judged"] === "number" ? statusCheck["judged"] : 0,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
163
177
|
const repos = Array.isArray(parsed["repos"]) ? parsed["repos"] : [];
|
|
164
178
|
for (const entry of repos) {
|
|
165
179
|
if (!isRecord(entry))
|
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,yDAAyD;AACzD,+EAA+E;AAC/E,4DAA4D;AAC5D,6EAA6E;AAC7E,6EAA6E;AAC7E,+EAA+E;AAC/E,0CAA0C;
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,yDAAyD;AACzD,+EAA+E;AAC/E,4DAA4D;AAC5D,6EAA6E;AAC7E,6EAA6E;AAC7E,+EAA+E;AAC/E,0CAA0C;AAqQ1C,MAAM,CAAC,MAAM,MAAM,GAAG,iBAAiB,CAAC;AACxC,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAuMhD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAA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AAS;QAC/B,IAAI,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ;YAAE,SAAS;QACrF,IAAI,OAAO,KAAK,CAAC,uBAAuB,CAAC,KAAK,QAAQ;YAAE,SAAS;QACjE,CAAC,MAAM,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,KAA8B,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,WAAW,CAAC,IAAe;IACzC,OAAO,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC;AACrC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,MAAmB;IAC9C,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAC3B,OAAO,OAAO,CAAC,MAAM,IAAI,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,YAAY,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,cAAc,CAAC,MAAmB;IAChD,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The marker the binary writes, atomically, under `<root>/.carrick/`. */
|
|
2
|
+
export declare function checkMarkerPath(root: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* True when a `carrick check --changed` that exited 0 began after this
|
|
5
|
+
* session's newest edit in the workspace at `root`: it read the tree as it
|
|
6
|
+
* stands, so the clause would only send the agent to repeat it. Exit 1 (a
|
|
7
|
+
* problem to fix) and 2 (nothing checked) never count, and neither does a
|
|
8
|
+
* session with no recorded edit (nothing to compare). Started rather than
|
|
9
|
+
* finished: an edit made while the check ran may not have been read.
|
|
10
|
+
*/
|
|
11
|
+
export declare function checkedSinceLastEdit(session: string | undefined, root: string, home?: string): boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Whether `carrick check --changed` already ran since this session's last edit.
|
|
2
|
+
//
|
|
3
|
+
// The hooks' lines end "Run `carrick check --changed` before you finish."
|
|
4
|
+
// An agent that had just run it ran it again, 137 s and then 133 s
|
|
5
|
+
// (carrick#3357). The binary leaves a marker in the workspace when that
|
|
6
|
+
// command ends (`record_check_marker` in `src/local_mode/changed.rs`, same
|
|
7
|
+
// file name and fields); the hooks compare it with the newest edit the
|
|
8
|
+
// session record holds (`recordEdit` in `reuse.ts`).
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { readSession } from "./reuse.js";
|
|
12
|
+
/** The marker the binary writes, atomically, under `<root>/.carrick/`. */
|
|
13
|
+
export function checkMarkerPath(root) {
|
|
14
|
+
return path.join(root, ".carrick", "last-check-changed.json");
|
|
15
|
+
}
|
|
16
|
+
function readMarker(root) {
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(fs.readFileSync(checkMarkerPath(root), "utf8"));
|
|
19
|
+
if (typeof parsed.started_at_ms !== "number" || typeof parsed.exit !== "number")
|
|
20
|
+
return null;
|
|
21
|
+
return parsed;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* True when a `carrick check --changed` that exited 0 began after this
|
|
29
|
+
* session's newest edit in the workspace at `root`: it read the tree as it
|
|
30
|
+
* stands, so the clause would only send the agent to repeat it. Exit 1 (a
|
|
31
|
+
* problem to fix) and 2 (nothing checked) never count, and neither does a
|
|
32
|
+
* session with no recorded edit (nothing to compare). Started rather than
|
|
33
|
+
* finished: an edit made while the check ran may not have been read.
|
|
34
|
+
*/
|
|
35
|
+
export function checkedSinceLastEdit(session, root, home) {
|
|
36
|
+
if (!session)
|
|
37
|
+
return false;
|
|
38
|
+
const edited = readSession(session, home).edited[root];
|
|
39
|
+
if (edited === undefined)
|
|
40
|
+
return false;
|
|
41
|
+
const marker = readMarker(root);
|
|
42
|
+
return marker !== null && marker.exit === 0 && marker.started_at_ms > edited;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=checked.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checked.js","sourceRoot":"","sources":["../../src/hook/checked.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,0EAA0E;AAC1E,mEAAmE;AACnE,wEAAwE;AACxE,2EAA2E;AAC3E,uEAAuE;AACvE,qDAAqD;AAErD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,0EAA0E;AAC1E,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,yBAAyB,CAAC,CAAC;AAChE,CAAC;AAID,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAoB,CAAC;QAC7F,IAAI,OAAO,MAAM,CAAC,aAAa,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC7F,OAAO,MAAgB,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA2B,EAAE,IAAY,EAAE,IAAa;IAC3F,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACvC,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CheckResult } from "../contract.ts";
|
|
2
|
+
import type { NewFunction } from "./reuse.ts";
|
|
3
|
+
/** Whether `carrick check --changed` would judge this edited file: source, and not a test or story. */
|
|
4
|
+
export declare function isCheckedSource(file: string): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* What the re-check said this file declares and the index does not
|
|
7
|
+
* (carrick#1330).
|
|
8
|
+
*
|
|
9
|
+
* Nothing is printed about it here. This hook fires on every edit and most
|
|
10
|
+
* edits add no function; the one line about the ones that did belongs at the
|
|
11
|
+
* end of the task, where it costs one model turn instead of one per edit. All
|
|
12
|
+
* this does is put the names somewhere the Stop hook can find them.
|
|
13
|
+
*/
|
|
14
|
+
export declare function newFunctions(result: CheckResult, file: string): NewFunction[];
|
|
15
|
+
/**
|
|
16
|
+
* `file` relative to the nearest checkout top at or below `root`: the nearest
|
|
17
|
+
* directory holding `.git` (a folder, or the file a linked worktree has). An
|
|
18
|
+
* edit inside a nested worktree is then keyed as the index keys it, not with
|
|
19
|
+
* the worktree's own prefix (carrick#2936). With no nested checkout it is
|
|
20
|
+
* relative to `root`, as before.
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkoutRelative(root: string, file: string): string;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// What one edited file is, shared by the post-edit hook and the background
|
|
2
|
+
// re-check runner: whether the scan reads it, which checkout it sits in, and
|
|
3
|
+
// which functions a re-check says it newly declares.
|
|
4
|
+
//
|
|
5
|
+
// Split out of `post-edit.ts` because that file runs `main` on import, so
|
|
6
|
+
// nothing else could import from it.
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
/**
|
|
10
|
+
* The files `carrick check --changed` judges: the scanner's own source
|
|
11
|
+
* extensions (`SOURCE_EXTENSIONS` in `src/file_finder.rs`, carrick#904). An API
|
|
12
|
+
* spec file is not counted: the hook cannot tell a spec the scan reads from any
|
|
13
|
+
* other `.json` or `.yaml` without reading the repo, and a config file that
|
|
14
|
+
* moves no contract is what the line used to be wrong about.
|
|
15
|
+
*/
|
|
16
|
+
const CHECKED_EXTENSIONS = new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"]);
|
|
17
|
+
/** `TEST_FILE_INFIXES` in `src/file_finder.rs`: a test or story file name ends its stem in one. */
|
|
18
|
+
const TEST_FILE_INFIXES = [".test", ".spec", ".stories"];
|
|
19
|
+
/** `TEST_DIR_NAMES` in `src/file_finder.rs` (plus `.storybook`): trees the scan does not read. */
|
|
20
|
+
const TEST_DIR_NAMES = new Set([
|
|
21
|
+
"__tests__",
|
|
22
|
+
"__mocks__",
|
|
23
|
+
"__fixtures__",
|
|
24
|
+
"tests",
|
|
25
|
+
"test",
|
|
26
|
+
"fixtures",
|
|
27
|
+
"e2e",
|
|
28
|
+
".storybook",
|
|
29
|
+
]);
|
|
30
|
+
/** Whether `carrick check --changed` would judge this edited file: source, and not a test or story. */
|
|
31
|
+
export function isCheckedSource(file) {
|
|
32
|
+
const extension = path.extname(file).toLowerCase();
|
|
33
|
+
if (!CHECKED_EXTENSIONS.has(extension))
|
|
34
|
+
return false;
|
|
35
|
+
const stem = path.basename(file, extension).toLowerCase();
|
|
36
|
+
if (TEST_FILE_INFIXES.some((infix) => stem.endsWith(infix)))
|
|
37
|
+
return false;
|
|
38
|
+
// Directory names above the file. The scanner reads them relative to the
|
|
39
|
+
// scan root; the hook does not know it, so a checkout under a directory
|
|
40
|
+
// named `test` hides its source here: the line is then missing, not wrong.
|
|
41
|
+
const directories = path.dirname(file).split(/[\\/]/);
|
|
42
|
+
return !directories.some((name) => TEST_DIR_NAMES.has(name.toLowerCase()));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* What the re-check said this file declares and the index does not
|
|
46
|
+
* (carrick#1330).
|
|
47
|
+
*
|
|
48
|
+
* Nothing is printed about it here. This hook fires on every edit and most
|
|
49
|
+
* edits add no function; the one line about the ones that did belongs at the
|
|
50
|
+
* end of the task, where it costs one model turn instead of one per edit. All
|
|
51
|
+
* this does is put the names somewhere the Stop hook can find them.
|
|
52
|
+
*/
|
|
53
|
+
export function newFunctions(result, file) {
|
|
54
|
+
// Test, spec and story files never warrant a reuse check (carrick#2936).
|
|
55
|
+
if (!isCheckedSource(file))
|
|
56
|
+
return [];
|
|
57
|
+
return (result.recheck?.new_functions ?? []).map((entry) => ({
|
|
58
|
+
name: entry.name,
|
|
59
|
+
// The path this hook computed, not the one the binary echoes: it is the
|
|
60
|
+
// checkout-relative path the index holds, whatever root the edit ran from.
|
|
61
|
+
file,
|
|
62
|
+
indexCommit: result.index_commit ?? "",
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* `file` relative to the nearest checkout top at or below `root`: the nearest
|
|
67
|
+
* directory holding `.git` (a folder, or the file a linked worktree has). An
|
|
68
|
+
* edit inside a nested worktree is then keyed as the index keys it, not with
|
|
69
|
+
* the worktree's own prefix (carrick#2936). With no nested checkout it is
|
|
70
|
+
* relative to `root`, as before.
|
|
71
|
+
*/
|
|
72
|
+
export function checkoutRelative(root, file) {
|
|
73
|
+
let dir = path.dirname(file);
|
|
74
|
+
while (dir !== root && path.relative(root, dir) && !path.relative(root, dir).startsWith("..")) {
|
|
75
|
+
if (fs.existsSync(path.join(dir, ".git")))
|
|
76
|
+
return path.relative(dir, file);
|
|
77
|
+
const parent = path.dirname(dir);
|
|
78
|
+
if (parent === dir)
|
|
79
|
+
break;
|
|
80
|
+
dir = parent;
|
|
81
|
+
}
|
|
82
|
+
return path.relative(root, file);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=edited.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edited.js","sourceRoot":"","sources":["../../src/hook/edited.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,qDAAqD;AACrD,EAAE;AACF,0EAA0E;AAC1E,qCAAqC;AAErC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B;;;;;;GAMG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEnG,mGAAmG;AACnG,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AAEzD,kGAAkG;AAClG,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,WAAW;IACX,WAAW;IACX,cAAc;IACd,OAAO;IACP,MAAM;IACN,UAAU;IACV,KAAK;IACL,YAAY;CACb,CAAC,CAAC;AAEH,uGAAuG;AACvG,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IACnD,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC;QAAE,OAAO,KAAK,CA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GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9F,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC3E,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,GAAG;YAAE,MAAM;QAC1B,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The hooks that start the binary, and the value each sends. */
|
|
2
|
+
export type HookInvoker = "post-edit" | "stop" | "session-start" | "post-read";
|
|
3
|
+
export declare const INVOKER_ENV = "CARRICK_INVOKER";
|
|
4
|
+
/** The value the binary sends for a hook. */
|
|
5
|
+
export declare function invokerValue(hook: HookInvoker): string;
|
|
6
|
+
/** Mark this process, and every child it spawns, as started by `hook`. */
|
|
7
|
+
export declare function markInvoker(hook: HookInvoker, env?: NodeJS.ProcessEnv): void;
|