carrick 0.3.156 → 0.3.157
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/dist/facts/enabled.d.ts +6 -0
- package/dist/facts/enabled.js +8 -0
- package/dist/facts/enabled.js.map +1 -1
- package/dist/facts/fetch.js +2 -1
- package/dist/facts/fetch.js.map +1 -1
- package/dist/held/client.d.ts +34 -0
- package/dist/held/client.js +85 -0
- package/dist/held/client.js.map +1 -0
- package/dist/held/daemon.d.ts +106 -0
- package/dist/held/daemon.js +307 -0
- package/dist/held/daemon.js.map +1 -0
- package/dist/held/engine.d.ts +50 -0
- package/dist/held/engine.js +166 -0
- package/dist/held/engine.js.map +1 -0
- package/dist/held/paths.d.ts +9 -0
- package/dist/held/paths.js +27 -0
- package/dist/held/paths.js.map +1 -0
- package/dist/held/place.d.ts +84 -0
- package/dist/held/place.js +198 -0
- package/dist/held/place.js.map +1 -0
- package/dist/held/registry.d.ts +22 -0
- package/dist/held/registry.js +72 -0
- package/dist/held/registry.js.map +1 -0
- package/dist/held/run.d.ts +2 -0
- package/dist/held/run.js +60 -0
- package/dist/held/run.js.map +1 -0
- package/dist/hook/bash-targets.d.ts +7 -2
- package/dist/hook/bash-targets.js +82 -27
- package/dist/hook/bash-targets.js.map +1 -1
- package/dist/hook/lock.d.ts +26 -0
- package/dist/hook/lock.js +122 -0
- package/dist/hook/lock.js.map +1 -0
- package/dist/hook/post-bash.js +14 -5
- package/dist/hook/post-bash.js.map +1 -1
- package/dist/hook/rechecks.d.ts +1 -0
- package/dist/hook/rechecks.js +8 -121
- package/dist/hook/rechecks.js.map +1 -1
- package/dist/hook/timings.d.ts +2 -2
- package/dist/hook/timings.js +1 -1
- package/dist/hook/timings.js.map +1 -1
- package/dist/lsp-frame.d.ts +20 -0
- package/dist/lsp-frame.js +47 -0
- package/dist/lsp-frame.js.map +1 -0
- package/dist/server.js +4 -28
- package/dist/server.js.map +1 -1
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/capture/api.d.ts +31 -1
- package/sidecar/dist/src/capture/check-probe.d.ts +15 -9
- package/sidecar/dist/src/capture/check-probe.js +36 -11
- package/sidecar/dist/src/capture/index.d.ts +9 -3
- package/sidecar/dist/src/capture/index.js +9 -2
- package/sidecar/dist/src/capture/result-label.js +3 -1
- package/sidecar/dist/src/capture/type-reasons.json +78 -0
- package/sidecar/dist/src/definition-resolver.d.ts +4 -4
- package/sidecar/dist/src/definition-resolver.js +8 -9
- package/sidecar/dist/src/engine-stamp.json +1 -0
- package/sidecar/dist/src/held-shadow.d.ts +60 -0
- package/sidecar/dist/src/held-shadow.js +222 -0
- package/sidecar/dist/src/index.js +47 -1
- package/sidecar/dist/src/library-claims.d.ts +3 -1
- package/sidecar/dist/src/library-claims.js +79 -3
- package/sidecar/dist/src/type-home.d.ts +12 -0
- package/sidecar/dist/src/type-home.js +41 -1
- package/sidecar/dist/src/type-inferrer.d.ts +8 -3
- package/sidecar/dist/src/type-inferrer.js +36 -18
- package/sidecar/dist/src/type-structural-expander.d.ts +1 -11
- package/sidecar/dist/src/types.d.ts +43 -5
- package/sidecar/dist/src/validators.d.ts +293 -246
- package/sidecar/dist/src/validators.js +8 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type Diag = {
|
|
2
|
+
range: {
|
|
3
|
+
start: {
|
|
4
|
+
line: number;
|
|
5
|
+
character: number;
|
|
6
|
+
};
|
|
7
|
+
end: {
|
|
8
|
+
line: number;
|
|
9
|
+
character: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
severity?: number;
|
|
13
|
+
code?: number | string;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
export interface Engine {
|
|
17
|
+
/** The file's whole text, as it is now. The first call opens it, later ones replace it. */
|
|
18
|
+
set(file: string, text: string): void;
|
|
19
|
+
/** Diagnostics for each file, asked together. Rejects when the compiler cannot answer in full. */
|
|
20
|
+
pull(files: string[]): Promise<Map<string, Diag[]>>;
|
|
21
|
+
/** Resident memory of the compiler process in MB, or null when it is not running. */
|
|
22
|
+
rss(): number | null;
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare class Ts7Lsp implements Engine {
|
|
26
|
+
private readonly child;
|
|
27
|
+
private readonly framer;
|
|
28
|
+
private readonly pending;
|
|
29
|
+
private readonly versions;
|
|
30
|
+
private readonly cwd;
|
|
31
|
+
private nextId;
|
|
32
|
+
private exited;
|
|
33
|
+
/** Everything sent after `initialize` waits on this, so order is the call order. */
|
|
34
|
+
private readonly ready;
|
|
35
|
+
stderr: string;
|
|
36
|
+
/**
|
|
37
|
+
* @param command the native compiler executable (a `tsc` that speaks `--lsp`)
|
|
38
|
+
* @param cwd the shadow's `w` directory, where the generated tsconfig is
|
|
39
|
+
*/
|
|
40
|
+
constructor(command: string, cwd: string, args?: string[]);
|
|
41
|
+
private fail;
|
|
42
|
+
private consume;
|
|
43
|
+
private write;
|
|
44
|
+
private request;
|
|
45
|
+
private initialize;
|
|
46
|
+
set(file: string, text: string): void;
|
|
47
|
+
pull(files: string[]): Promise<Map<string, Diag[]>>;
|
|
48
|
+
rss(): number | null;
|
|
49
|
+
close(): Promise<void>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// The held compiler: one language server kept open over a shadow tree, so an
|
|
2
|
+
// edit is judged in hundreds of milliseconds instead of a cold compile.
|
|
3
|
+
//
|
|
4
|
+
// `Engine` is the seam: the daemon asks for diagnostics and never learns which
|
|
5
|
+
// compiler answers. `Ts7Lsp` is the TypeScript 7 implementation, spoken to over
|
|
6
|
+
// `tsc --lsp --stdio`. Another compiler swaps in behind the same interface.
|
|
7
|
+
import { execFileSync, spawn } from "node:child_process";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
10
|
+
import { Framer, frame } from "../lsp-frame.js";
|
|
11
|
+
export class Ts7Lsp {
|
|
12
|
+
child;
|
|
13
|
+
framer = new Framer();
|
|
14
|
+
pending = new Map();
|
|
15
|
+
versions = new Map();
|
|
16
|
+
cwd;
|
|
17
|
+
nextId = 1;
|
|
18
|
+
exited = false;
|
|
19
|
+
/** Everything sent after `initialize` waits on this, so order is the call order. */
|
|
20
|
+
ready;
|
|
21
|
+
stderr = "";
|
|
22
|
+
/**
|
|
23
|
+
* @param command the native compiler executable (a `tsc` that speaks `--lsp`)
|
|
24
|
+
* @param cwd the shadow's `w` directory, where the generated tsconfig is
|
|
25
|
+
*/
|
|
26
|
+
constructor(command, cwd, args = ["--lsp", "--stdio"]) {
|
|
27
|
+
this.cwd = cwd;
|
|
28
|
+
this.child = spawn(command, args, {
|
|
29
|
+
cwd,
|
|
30
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
31
|
+
env: { ...process.env, DO_NOT_TRACK: "1" },
|
|
32
|
+
});
|
|
33
|
+
this.child.stdout.on("data", (chunk) => this.consume(chunk));
|
|
34
|
+
this.child.stderr.on("data", (chunk) => {
|
|
35
|
+
this.stderr += chunk.toString("utf8");
|
|
36
|
+
});
|
|
37
|
+
this.child.on("error", (error) => this.fail(error));
|
|
38
|
+
this.child.on("exit", () => {
|
|
39
|
+
this.exited = true;
|
|
40
|
+
this.fail(new Error("compiler exited"));
|
|
41
|
+
});
|
|
42
|
+
this.ready = this.initialize();
|
|
43
|
+
// A start that fails is reported by the first `pull`; it must not also be
|
|
44
|
+
// an unhandled rejection here.
|
|
45
|
+
this.ready.catch(() => undefined);
|
|
46
|
+
}
|
|
47
|
+
fail(error) {
|
|
48
|
+
for (const pending of this.pending.values())
|
|
49
|
+
pending.reject(error);
|
|
50
|
+
this.pending.clear();
|
|
51
|
+
}
|
|
52
|
+
consume(chunk) {
|
|
53
|
+
for (const message of this.framer.push(chunk)) {
|
|
54
|
+
if (message.id !== undefined && message.method) {
|
|
55
|
+
// A request from the compiler: settings come back empty, anything else is accepted.
|
|
56
|
+
const items = message.params?.["items"] ?? [];
|
|
57
|
+
const result = message.method === "workspace/configuration" ? items.map(() => null) : null;
|
|
58
|
+
this.write({ id: message.id, result });
|
|
59
|
+
}
|
|
60
|
+
else if (typeof message.id === "number") {
|
|
61
|
+
const pending = this.pending.get(message.id);
|
|
62
|
+
this.pending.delete(message.id);
|
|
63
|
+
pending?.resolve(message);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
write(message) {
|
|
68
|
+
if (this.exited)
|
|
69
|
+
return;
|
|
70
|
+
this.child.stdin.write(frame(message));
|
|
71
|
+
}
|
|
72
|
+
request(method, params) {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
if (this.exited) {
|
|
75
|
+
reject(new Error("compiler exited"));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const id = this.nextId++;
|
|
79
|
+
this.pending.set(id, { resolve, reject });
|
|
80
|
+
this.write({ id, method, params });
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async initialize() {
|
|
84
|
+
const uri = pathToFileURL(this.cwd).toString();
|
|
85
|
+
const answer = await this.request("initialize", {
|
|
86
|
+
processId: process.pid,
|
|
87
|
+
rootUri: uri,
|
|
88
|
+
workspaceFolders: [{ uri, name: path.basename(path.dirname(this.cwd)) }],
|
|
89
|
+
capabilities: {
|
|
90
|
+
textDocument: {
|
|
91
|
+
diagnostic: { dynamicRegistration: false },
|
|
92
|
+
synchronization: { didSave: true },
|
|
93
|
+
},
|
|
94
|
+
workspace: { configuration: true, workspaceFolders: true },
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
if (answer.error)
|
|
98
|
+
throw new Error(`initialize failed: ${answer.error.message}`);
|
|
99
|
+
this.write({ method: "initialized", params: {} });
|
|
100
|
+
}
|
|
101
|
+
set(file, text) {
|
|
102
|
+
const uri = pathToFileURL(file).toString();
|
|
103
|
+
const version = (this.versions.get(file) ?? 0) + 1;
|
|
104
|
+
this.versions.set(file, version);
|
|
105
|
+
const message = version === 1
|
|
106
|
+
? {
|
|
107
|
+
method: "textDocument/didOpen",
|
|
108
|
+
params: { textDocument: { uri, languageId: "typescript", version, text } },
|
|
109
|
+
}
|
|
110
|
+
: {
|
|
111
|
+
method: "textDocument/didChange",
|
|
112
|
+
params: { textDocument: { uri, version }, contentChanges: [{ text }] },
|
|
113
|
+
};
|
|
114
|
+
void this.ready.then(() => this.write(message)).catch(() => undefined);
|
|
115
|
+
}
|
|
116
|
+
async pull(files) {
|
|
117
|
+
await this.ready;
|
|
118
|
+
const answers = await Promise.all(files.map((file) => this.request("textDocument/diagnostic", {
|
|
119
|
+
textDocument: { uri: pathToFileURL(file).toString() },
|
|
120
|
+
})));
|
|
121
|
+
const out = new Map();
|
|
122
|
+
files.forEach((file, i) => {
|
|
123
|
+
const answer = answers[i];
|
|
124
|
+
if (answer.error)
|
|
125
|
+
throw new Error(`diagnostic request failed: ${answer.error.message}`);
|
|
126
|
+
const result = answer.result;
|
|
127
|
+
// Anything but a full report is not "no diagnostics": it is no answer.
|
|
128
|
+
if (result?.kind !== "full") {
|
|
129
|
+
throw new Error(`diagnostic answer for ${file} is not a full report (${result?.kind ?? "null"})`);
|
|
130
|
+
}
|
|
131
|
+
out.set(file, result.items ?? []);
|
|
132
|
+
});
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
rss() {
|
|
136
|
+
const pid = this.child.pid;
|
|
137
|
+
if (this.exited || pid === undefined)
|
|
138
|
+
return null;
|
|
139
|
+
try {
|
|
140
|
+
const kb = Number.parseInt(execFileSync("ps", ["-o", "rss=", "-p", String(pid)]).toString().trim(), 10);
|
|
141
|
+
return Number.isFinite(kb) ? Math.round(kb / 1024) : null;
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async close() {
|
|
148
|
+
if (this.exited)
|
|
149
|
+
return;
|
|
150
|
+
const exit = new Promise((resolve) => this.child.once("exit", () => resolve()));
|
|
151
|
+
try {
|
|
152
|
+
await Promise.race([
|
|
153
|
+
this.ready.then(() => this.request("shutdown", null)),
|
|
154
|
+
new Promise((resolve) => setTimeout(resolve, 2000)),
|
|
155
|
+
]);
|
|
156
|
+
this.write({ method: "exit" });
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
// Killed below.
|
|
160
|
+
}
|
|
161
|
+
const timer = setTimeout(() => this.child.kill("SIGKILL"), 3000);
|
|
162
|
+
await exit;
|
|
163
|
+
clearTimeout(timer);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/held/engine.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,wEAAwE;AACxE,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,4EAA4E;AAE5E,OAAO,EAAE,YAAY,EAAE,KAAK,EAAuC,MAAM,oBAAoB,CAAC;AAC9F,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAmB,MAAM,iBAAiB,CAAC;AAwBjE,MAAM,OAAO,MAAM;IACA,KAAK,CAAiC;IACtC,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;IACtB,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IACrC,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IACrC,GAAG,CAAS;IACrB,MAAM,GAAG,CAAC,CAAC;IACX,MAAM,GAAG,KAAK,CAAC;IACvB,oFAAoF;IACnE,KAAK,CAAgB;IACtC,MAAM,GAAG,EAAE,CAAC;IAEZ;;;OAGG;IACH,YAAY,OAAe,EAAE,GAAW,EAAE,OAAiB,CAAC,OAAO,EAAE,SAAS,CAAC;QAC7E,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC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I,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,MAAM,IAAI,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACtF,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,IAAI,CAAC;gBACjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;gBACrD,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;aACpD,CAAC,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACP,gBAAgB;QAClB,CAAC;QACD,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;QACjE,MAAM,IAAI,CAAC;QACX,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The daemon touches its lock every tick; it is stale this long (plus the lock's slack) after. */
|
|
2
|
+
export declare const LOCK_CAP_MS = 30000;
|
|
3
|
+
export declare function heldDir(home?: string): string;
|
|
4
|
+
/** The first 12 hex characters of the sha-256 of the checkout's real path. */
|
|
5
|
+
export declare function rootKey(root: string): string;
|
|
6
|
+
export declare function socketPath(root: string, home?: string): string;
|
|
7
|
+
export declare function lockPath(root: string, home?: string): string;
|
|
8
|
+
/** One JSON line per request. */
|
|
9
|
+
export declare function logPath(root: string, home?: string): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Where the held-compiler daemon keeps its files. Everything is under
|
|
2
|
+
// `~/.carrick/held/`, outside every checkout, keyed by a hash of the checkout's
|
|
3
|
+
// real path (a socket path is capped near 104 bytes on macOS, so no names).
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { realPath } from "../fs-util.js";
|
|
8
|
+
/** The daemon touches its lock every tick; it is stale this long (plus the lock's slack) after. */
|
|
9
|
+
export const LOCK_CAP_MS = 30_000;
|
|
10
|
+
export function heldDir(home = os.homedir()) {
|
|
11
|
+
return path.join(home, ".carrick", "held");
|
|
12
|
+
}
|
|
13
|
+
/** The first 12 hex characters of the sha-256 of the checkout's real path. */
|
|
14
|
+
export function rootKey(root) {
|
|
15
|
+
return createHash("sha256").update(realPath(root)).digest("hex").slice(0, 12);
|
|
16
|
+
}
|
|
17
|
+
export function socketPath(root, home) {
|
|
18
|
+
return path.join(heldDir(home), `${rootKey(root)}.sock`);
|
|
19
|
+
}
|
|
20
|
+
export function lockPath(root, home) {
|
|
21
|
+
return path.join(heldDir(home), `${rootKey(root)}.lock`);
|
|
22
|
+
}
|
|
23
|
+
/** One JSON line per request. */
|
|
24
|
+
export function logPath(root, home) {
|
|
25
|
+
return path.join(heldDir(home), `${rootKey(root)}.log`);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/held/paths.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,gFAAgF;AAChF,4EAA4E;AAE5E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,mGAAmG;AACnG,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC;AAElC,MAAM,UAAU,OAAO,CAAC,OAAe,EAAE,CAAC,OAAO,EAAE;IACjD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,IAAa;IACpD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,IAAa;IAClD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED,iCAAiC;AACjC,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,IAAa;IACjD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import type { ContractGroup, ContractRow } from "../facts/store.ts";
|
|
3
|
+
/** What the placer reads of a contract row (a subset of the fact store's row). */
|
|
4
|
+
export type PlaceRow = Pick<ContractRow, "label" | "locator"> & {
|
|
5
|
+
id: number;
|
|
6
|
+
site: string | null;
|
|
7
|
+
line: number | null;
|
|
8
|
+
groups: Array<Pick<ContractGroup, "type">>;
|
|
9
|
+
};
|
|
10
|
+
/** A compiler diagnostic: its start offset in the checked text, its code, its message. */
|
|
11
|
+
export type Diag = {
|
|
12
|
+
start: number;
|
|
13
|
+
code: number;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
export type UnplacedReason = "not_registration" | "dispatch_case" | "javascript_file" | "no_site_found" | "site_not_unique";
|
|
17
|
+
export type UnarmedReason = "twin_passes" | "decl_error" | "no_hono" | `clean_check_fails:TS${number}`;
|
|
18
|
+
/** `no_hono` is a row's own reason too (the clean check names a non-route object). */
|
|
19
|
+
export type RowReason = UnplacedReason | UnarmedReason;
|
|
20
|
+
export type Check = {
|
|
21
|
+
id: number;
|
|
22
|
+
group: number;
|
|
23
|
+
/** `<id>_<group>`; the check's alias is `O<k>`. */
|
|
24
|
+
k: string;
|
|
25
|
+
/** The whole check expression: `__C.reg<k>(` through `, (o) => o)`. */
|
|
26
|
+
span: [number, number];
|
|
27
|
+
/** The check's two declaration lines in the appended namespace. */
|
|
28
|
+
declSpan: [number, number];
|
|
29
|
+
};
|
|
30
|
+
export type Overlay = {
|
|
31
|
+
text: string;
|
|
32
|
+
checks: Check[];
|
|
33
|
+
unplaced: Array<{
|
|
34
|
+
id: number;
|
|
35
|
+
reason: UnplacedReason;
|
|
36
|
+
}>;
|
|
37
|
+
/** Offset where the appended namespace starts. */
|
|
38
|
+
bodyEnd: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* D7. The call that starts on the row's line, whose callee is the label's
|
|
42
|
+
* method and whose first argument is the row's site literal. With none on that
|
|
43
|
+
* line, the unique such call in the file. Two or more is never a guess.
|
|
44
|
+
*/
|
|
45
|
+
export declare function findSite(sf: ts.SourceFile, row: Pick<PlaceRow, "label" | "site" | "line">): {
|
|
46
|
+
node: ts.CallExpression;
|
|
47
|
+
} | {
|
|
48
|
+
reason: UnplacedReason;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The file with every placeable row's registration wrapped. `clean` states the
|
|
52
|
+
* row's type; `twin` states it intersected with a property no reply has, so it
|
|
53
|
+
* must fail where the check can see the reply at all.
|
|
54
|
+
*/
|
|
55
|
+
export declare function overlay(file: string, text: string, rows: PlaceRow[], mode: "clean" | "twin"): Overlay;
|
|
56
|
+
/**
|
|
57
|
+
* R3. A diagnostic is a check's own line only when its start lies in the
|
|
58
|
+
* check's whole expression AND its message names the check's alias. Several
|
|
59
|
+
* checks can share an expression (two groups of one row, a chain): the
|
|
60
|
+
* narrowest that the message names wins. A diagnostic in a check's declaration
|
|
61
|
+
* lines is that check's `decl_error`. Everything else is `outside`, and never
|
|
62
|
+
* a line.
|
|
63
|
+
*/
|
|
64
|
+
export declare function attribute(ov: Overlay, diags: Diag[]): {
|
|
65
|
+
lines: Map<string, Diag[]>;
|
|
66
|
+
declErrors: Set<string>;
|
|
67
|
+
outside: Diag[];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* D6. On the current text, a check is armed only when its clean form is
|
|
71
|
+
* silent and its twin speaks. The gate reads the check's span, not the alias
|
|
72
|
+
* name: the twin's message may print the expanded intersection instead of
|
|
73
|
+
* `O<k>`, and the gate must not take that for silence. Only the gate is this
|
|
74
|
+
* broad; a line (see `attribute`) never is.
|
|
75
|
+
*/
|
|
76
|
+
export declare function arm(ov: Overlay, clean: Diag[], twin: Diag[]): {
|
|
77
|
+
armed: string[];
|
|
78
|
+
unarmed: Array<{
|
|
79
|
+
k: string;
|
|
80
|
+
id: number;
|
|
81
|
+
group: number;
|
|
82
|
+
reason: UnarmedReason;
|
|
83
|
+
}>;
|
|
84
|
+
};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// Part 3, T4: place, arm and attribute. Pure functions, no engine and no disk.
|
|
2
|
+
//
|
|
3
|
+
// A producer response row says "this route's 2xx reply has type T". To ask the
|
|
4
|
+
// compiler whether an edit breaks that, the registration call is wrapped in a
|
|
5
|
+
// check, `__C.reg<k>(<call>, (o) => o)`, where `o` is the route framework's own
|
|
6
|
+
// record of the handler's reply and the callback must return `O<k>`, the row's
|
|
7
|
+
// stated type. The check text is appended to the file's end (`declare
|
|
8
|
+
// namespace __C`), so no line moves.
|
|
9
|
+
//
|
|
10
|
+
// Three decisions live here:
|
|
11
|
+
// place (D7) which call is the row's site, on the CURRENT text
|
|
12
|
+
// arm (D6) which checks may speak: clean passes, its twin fails
|
|
13
|
+
// attribute (R3) which diagnostics are a check's own, and so may be a line
|
|
14
|
+
import ts from "typescript";
|
|
15
|
+
const POST = ", (o) => o)";
|
|
16
|
+
const OK = "200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226";
|
|
17
|
+
const PREAMBLE = [
|
|
18
|
+
` type Ok = ${OK};`,
|
|
19
|
+
" type Pick2xx<E> = E extends { status: infer St; output: infer O } ? ([Extract<St, Ok>] extends [never] ? never : O) : never;",
|
|
20
|
+
' type Out<R, P extends string, M extends string> = R extends import("hono").Hono<any, infer S extends import("hono").Schema, any>',
|
|
21
|
+
" ? (P extends keyof S ? (`$${M}` extends keyof S[P] ? Pick2xx<S[P][`$${M}`]> : { readonly __carrick_no_method_in_route_schema: M })",
|
|
22
|
+
" : { readonly __carrick_no_site_in_route_schema: P }) : { readonly __carrick_not_a_route_object: R };",
|
|
23
|
+
];
|
|
24
|
+
const methodOf = (label) => label.split(" ")[0].toLowerCase();
|
|
25
|
+
const scriptKind = (file) => (file.endsWith("x") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
|
|
26
|
+
function memberCalls(sf) {
|
|
27
|
+
const out = [];
|
|
28
|
+
const visit = (n) => {
|
|
29
|
+
if (ts.isCallExpression(n) && ts.isPropertyAccessExpression(n.expression)) {
|
|
30
|
+
const a0 = n.arguments[0];
|
|
31
|
+
const literal = a0 && (ts.isStringLiteral(a0) || ts.isNoSubstitutionTemplateLiteral(a0)) ? a0.text : undefined;
|
|
32
|
+
out.push({ node: n, name: n.expression.name.text, literal, line: sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1 });
|
|
33
|
+
}
|
|
34
|
+
ts.forEachChild(n, visit);
|
|
35
|
+
};
|
|
36
|
+
visit(sf);
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* D7. The call that starts on the row's line, whose callee is the label's
|
|
41
|
+
* method and whose first argument is the row's site literal. With none on that
|
|
42
|
+
* line, the unique such call in the file. Two or more is never a guess.
|
|
43
|
+
*/
|
|
44
|
+
export function findSite(sf, row) {
|
|
45
|
+
if (row.site === null)
|
|
46
|
+
return { reason: "no_site_found" };
|
|
47
|
+
const method = methodOf(row.label);
|
|
48
|
+
const same = memberCalls(sf).filter((c) => c.name === method && c.literal === row.site);
|
|
49
|
+
const onLine = same.filter((c) => c.line === row.line);
|
|
50
|
+
if (onLine.length === 1)
|
|
51
|
+
return { node: onLine[0].node };
|
|
52
|
+
if (onLine.length > 1)
|
|
53
|
+
return { reason: "site_not_unique" };
|
|
54
|
+
if (same.length === 1)
|
|
55
|
+
return { node: same[0].node };
|
|
56
|
+
return { reason: same.length === 0 ? "no_site_found" : "site_not_unique" };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The file with every placeable row's registration wrapped. `clean` states the
|
|
60
|
+
* row's type; `twin` states it intersected with a property no reply has, so it
|
|
61
|
+
* must fail where the check can see the reply at all.
|
|
62
|
+
*/
|
|
63
|
+
export function overlay(file, text, rows, mode) {
|
|
64
|
+
const unplaced = [];
|
|
65
|
+
const js = /\.(?:[mc]?js|jsx)$/.test(file);
|
|
66
|
+
const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, scriptKind(file));
|
|
67
|
+
const ops = [];
|
|
68
|
+
const checks = [];
|
|
69
|
+
const decls = [];
|
|
70
|
+
let seq = 0;
|
|
71
|
+
for (const row of rows) {
|
|
72
|
+
if (row.locator !== "registration") {
|
|
73
|
+
unplaced.push({ id: row.id, reason: "not_registration" });
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (row.label.includes("{")) {
|
|
77
|
+
unplaced.push({ id: row.id, reason: "dispatch_case" });
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (js) {
|
|
81
|
+
unplaced.push({ id: row.id, reason: "javascript_file" });
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const found = findSite(sf, row);
|
|
85
|
+
if (!("node" in found)) {
|
|
86
|
+
unplaced.push({ id: row.id, reason: found.reason });
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const start = found.node.getStart(sf);
|
|
90
|
+
const end = found.node.end;
|
|
91
|
+
const method = methodOf(row.label);
|
|
92
|
+
row.groups.forEach((g, group) => {
|
|
93
|
+
const k = `${row.id}_${group}`;
|
|
94
|
+
const stated = mode === "twin" ? `(${g.type}) & { readonly __carrick_never: true }` : `(${g.type})`;
|
|
95
|
+
decls.push(` type O${k} = ${stated};`);
|
|
96
|
+
decls.push(` function reg${k}<R>(r: R, c: (o: Out<R, ${JSON.stringify(row.site)}, ${JSON.stringify(method)}>) => O${k}): R;`);
|
|
97
|
+
ops.push({ at: start, s: `__C.reg${k}(`, side: "pre", seq, start, end });
|
|
98
|
+
ops.push({ at: end, s: POST, side: "post", seq, start, end });
|
|
99
|
+
seq += 1;
|
|
100
|
+
checks.push({ id: row.id, group, k, span: [0, 0], declSpan: [0, 0] });
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// Wraps at one offset must nest. Opening: the wider call first, later group outside.
|
|
104
|
+
// Closing: the mirror image. A close at an offset comes before an open there.
|
|
105
|
+
ops.sort((a, b) => {
|
|
106
|
+
if (a.at !== b.at)
|
|
107
|
+
return a.at - b.at;
|
|
108
|
+
if (a.side !== b.side)
|
|
109
|
+
return a.side === "post" ? -1 : 1;
|
|
110
|
+
if (a.side === "pre")
|
|
111
|
+
return b.end - a.end || b.seq - a.seq;
|
|
112
|
+
return b.start - a.start || a.seq - b.seq;
|
|
113
|
+
});
|
|
114
|
+
let out = "";
|
|
115
|
+
let last = 0;
|
|
116
|
+
const pos = new Map();
|
|
117
|
+
for (const o of ops) {
|
|
118
|
+
out += text.slice(last, o.at);
|
|
119
|
+
pos.set(`${o.seq}:${o.side}`, out.length);
|
|
120
|
+
out += o.s;
|
|
121
|
+
last = o.at;
|
|
122
|
+
}
|
|
123
|
+
out += text.slice(last);
|
|
124
|
+
const bodyEnd = out.length;
|
|
125
|
+
out += "\n" + ["declare namespace __C {", ...PREAMBLE, ...decls, "}"].join("\n") + "\n";
|
|
126
|
+
checks.forEach((c, i) => {
|
|
127
|
+
c.span = [pos.get(`${i}:pre`), pos.get(`${i}:post`) + POST.length];
|
|
128
|
+
const declAt = out.indexOf(` type O${c.k} = `, bodyEnd);
|
|
129
|
+
c.declSpan = [declAt, out.indexOf("\n", out.indexOf(`function reg${c.k}<`, declAt))];
|
|
130
|
+
});
|
|
131
|
+
return { text: out, checks, unplaced, bodyEnd };
|
|
132
|
+
}
|
|
133
|
+
const inside = (p, s) => p >= s[0] && p <= s[1];
|
|
134
|
+
const names = (message, k) => new RegExp(`\\bO${k}\\b`).test(message);
|
|
135
|
+
/**
|
|
136
|
+
* R3. A diagnostic is a check's own line only when its start lies in the
|
|
137
|
+
* check's whole expression AND its message names the check's alias. Several
|
|
138
|
+
* checks can share an expression (two groups of one row, a chain): the
|
|
139
|
+
* narrowest that the message names wins. A diagnostic in a check's declaration
|
|
140
|
+
* lines is that check's `decl_error`. Everything else is `outside`, and never
|
|
141
|
+
* a line.
|
|
142
|
+
*/
|
|
143
|
+
export function attribute(ov, diags) {
|
|
144
|
+
const lines = new Map();
|
|
145
|
+
const declErrors = new Set();
|
|
146
|
+
const outside = [];
|
|
147
|
+
for (const d of diags) {
|
|
148
|
+
const decl = ov.checks.find((c) => inside(d.start, c.declSpan));
|
|
149
|
+
if (decl) {
|
|
150
|
+
declErrors.add(decl.k);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
const own = ov.checks
|
|
154
|
+
.filter((c) => inside(d.start, c.span) && names(d.message, c.k))
|
|
155
|
+
.sort((a, b) => a.span[1] - a.span[0] - (b.span[1] - b.span[0]));
|
|
156
|
+
if (own.length === 0) {
|
|
157
|
+
outside.push(d);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const k = own[0].k;
|
|
161
|
+
lines.set(k, [...(lines.get(k) ?? []), d]);
|
|
162
|
+
}
|
|
163
|
+
return { lines, declErrors, outside };
|
|
164
|
+
}
|
|
165
|
+
/** A check "speaks" at the gate when anything but a syntax error (TS1xxx) starts in it. */
|
|
166
|
+
function speaks(c, diags) {
|
|
167
|
+
return diags.find((d) => d.code >= 2000 && inside(d.start, c.span));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* D6. On the current text, a check is armed only when its clean form is
|
|
171
|
+
* silent and its twin speaks. The gate reads the check's span, not the alias
|
|
172
|
+
* name: the twin's message may print the expanded intersection instead of
|
|
173
|
+
* `O<k>`, and the gate must not take that for silence. Only the gate is this
|
|
174
|
+
* broad; a line (see `attribute`) never is.
|
|
175
|
+
*/
|
|
176
|
+
export function arm(ov, clean, twin) {
|
|
177
|
+
const armed = [];
|
|
178
|
+
const unarmed = [];
|
|
179
|
+
for (const c of ov.checks) {
|
|
180
|
+
const no = (reason) => { unarmed.push({ k: c.k, id: c.id, group: c.group, reason }); };
|
|
181
|
+
if (clean.some((d) => inside(d.start, c.declSpan))) {
|
|
182
|
+
no("decl_error");
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const bad = speaks(c, clean);
|
|
186
|
+
if (bad) {
|
|
187
|
+
no(bad.message.includes("__carrick_not_a_route_object") ? "no_hono" : `clean_check_fails:TS${bad.code}`);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (!speaks(c, twin)) {
|
|
191
|
+
no("twin_passes");
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
armed.push(c.k);
|
|
195
|
+
}
|
|
196
|
+
return { armed, unarmed };
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=place.js.map
|
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C,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5G,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YAAC,EAAE,CAAC,YAAY,CAAC,CAAC;YAAC,SAAS;QAAC,CAAC;QACnF,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAC7B,IAAI,GAAG,EAAE,CAAC;YAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAuB,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YAAC,SAAS;QAAC,CAAC;QAChI,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;YAAC,EAAE,CAAC,aAAa,CAAC,CAAC;YAAC,SAAS;QAAC,CAAC;QACtD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** What a TypeScript 7 engine was measured to settle at, and so what a new one is counted as. */
|
|
2
|
+
export declare const ADMISSION_MB = 2048;
|
|
3
|
+
/** 1.5 x the plateau: an engine above this is restarted. */
|
|
4
|
+
export declare const RSS_CEILING_MB = 3072;
|
|
5
|
+
/** An engine idle this long may be closed to make room for another. */
|
|
6
|
+
export declare const EVICT_IDLE_MS: number;
|
|
7
|
+
export type EngineEntry = {
|
|
8
|
+
/** The daemon that owns the engine: the entry is live while this process is. */
|
|
9
|
+
pid: number;
|
|
10
|
+
root: string;
|
|
11
|
+
service: string;
|
|
12
|
+
rss_mb: number;
|
|
13
|
+
last_used: number;
|
|
14
|
+
};
|
|
15
|
+
export declare function memoryBudgetMb(env?: NodeJS.ProcessEnv): number;
|
|
16
|
+
export declare function registryDir(home?: string): string;
|
|
17
|
+
export declare function writeEntry(home: string | undefined, entry: EngineEntry): void;
|
|
18
|
+
export declare function removeEntry(home: string | undefined, pid: number, root: string, service: string): void;
|
|
19
|
+
/** Every entry whose owner is alive. An entry whose owner is gone is deleted here. */
|
|
20
|
+
export declare function liveEntries(home?: string): EngineEntry[];
|
|
21
|
+
/** Whether one more engine, counted at its plateau, keeps the live total within the budget. */
|
|
22
|
+
export declare function admits(entries: readonly EngineEntry[], budgetMb: number): boolean;
|