@intellectual-frontiers/repoctl 0.0.0-stage → 0.1.0
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/LICENSE +75 -0
- package/README.md +19 -2
- package/dist/governance/checks.d.ts +23 -0
- package/dist/governance/config.d.ts +233 -0
- package/dist/governance/generators.d.ts +54 -0
- package/dist/governance/identity.d.ts +23 -0
- package/dist/governance/ids.d.ts +46 -0
- package/dist/governance/mod.d.ts +25 -0
- package/dist/governance/mod.js +1063 -0
- package/dist/governance/problems.d.ts +28 -0
- package/dist/governance/proof.d.ts +108 -0
- package/dist/governance/tiers.d.ts +25 -0
- package/dist/governance/verbs.d.ts +43 -0
- package/dist/governance/version.d.ts +14 -0
- package/dist/logical/check.d.ts +33 -0
- package/dist/logical/commit.d.ts +64 -0
- package/dist/logical/constants.d.ts +27 -0
- package/dist/logical/declared.d.ts +32 -0
- package/dist/logical/docs.d.ts +31 -0
- package/dist/logical/doctor.d.ts +42 -0
- package/dist/logical/findings.d.ts +26 -0
- package/dist/logical/glob.d.ts +17 -0
- package/dist/logical/hygiene-facts.d.ts +33 -0
- package/dist/logical/hygiene.d.ts +68 -0
- package/dist/logical/merge.d.ts +46 -0
- package/dist/logical/mod.d.ts +36 -0
- package/dist/logical/mod.js +2553 -0
- package/dist/logical/order.d.ts +24 -0
- package/dist/logical/pool.d.ts +14 -0
- package/dist/logical/ports.d.ts +96 -0
- package/dist/logical/prove.d.ts +118 -0
- package/dist/logical/publish.d.ts +70 -0
- package/dist/logical/scaffold.d.ts +52 -0
- package/dist/logical/select.d.ts +83 -0
- package/dist/logical/semver.d.ts +16 -0
- package/dist/logical/status.d.ts +71 -0
- package/dist/logical/step.d.ts +18 -0
- package/dist/logical/surface.d.ts +73 -0
- package/dist/logical/sync.d.ts +34 -0
- package/dist/mod.d.ts +20 -0
- package/dist/mod.js +12992 -0
- package/dist/physical/adapters.d.ts +25 -0
- package/dist/physical/config-load.d.ts +30 -0
- package/dist/physical/define.d.ts +73 -0
- package/dist/physical/mod.d.ts +26 -0
- package/dist/physical/mod.js +12660 -0
- package/dist/physical/program.d.ts +14 -0
- package/dist/physical/prove-run.d.ts +50 -0
- package/dist/physical/prove.d.ts +76 -0
- package/dist/physical/tests.d.ts +54 -0
- package/dist/physical/verbs/check.d.ts +26 -0
- package/dist/physical/verbs/docs.d.ts +6 -0
- package/dist/physical/verbs/library.d.ts +4 -0
- package/dist/physical/verbs/prove.d.ts +5 -0
- package/dist/physical/verbs/releasing.d.ts +27 -0
- package/dist/physical/verbs/sync.d.ts +12 -0
- package/dist/repoctl.d.ts +16 -0
- package/package.json +70 -4
- package/repoctl.mjs +12693 -0
|
@@ -0,0 +1,2553 @@
|
|
|
1
|
+
// ../core/src/absurd.ts
|
|
2
|
+
function absurd(value) {
|
|
3
|
+
throw new Error(`an alternative was not handled: ${JSON.stringify(value)}`);
|
|
4
|
+
}
|
|
5
|
+
// ../core/src/result.ts
|
|
6
|
+
function ok(value) {
|
|
7
|
+
return { kind: "ok", value };
|
|
8
|
+
}
|
|
9
|
+
function err(error) {
|
|
10
|
+
return { kind: "err", error };
|
|
11
|
+
}
|
|
12
|
+
var done = ok(undefined);
|
|
13
|
+
|
|
14
|
+
// ../core/src/decode.ts
|
|
15
|
+
function describe(input) {
|
|
16
|
+
if (input === null)
|
|
17
|
+
return "null";
|
|
18
|
+
if (input === undefined)
|
|
19
|
+
return "nothing";
|
|
20
|
+
if (Array.isArray(input))
|
|
21
|
+
return "an array";
|
|
22
|
+
const t = typeof input;
|
|
23
|
+
if (t === "string")
|
|
24
|
+
return `the string ${JSON.stringify(input).slice(0, 60)}`;
|
|
25
|
+
if (t === "object")
|
|
26
|
+
return "an object";
|
|
27
|
+
if (t === "function")
|
|
28
|
+
return "a function";
|
|
29
|
+
if (typeof input === "symbol")
|
|
30
|
+
return "a symbol";
|
|
31
|
+
if (typeof input === "number" || typeof input === "bigint" || typeof input === "boolean")
|
|
32
|
+
return `${t} ${String(input)}`;
|
|
33
|
+
return t;
|
|
34
|
+
}
|
|
35
|
+
function fail(path, expected, input) {
|
|
36
|
+
return err({ kind: "decode", path, expected, found: describe(input) });
|
|
37
|
+
}
|
|
38
|
+
var string = (input, path = "$") => typeof input === "string" ? ok(input) : fail(path, "a string", input);
|
|
39
|
+
var integer = (input, path = "$") => typeof input === "number" && Number.isInteger(input) ? ok(input) : fail(path, "an integer", input);
|
|
40
|
+
var unknownValue = (input) => ok(input);
|
|
41
|
+
function literal(...values) {
|
|
42
|
+
return (input, path = "$") => typeof input === "string" && values.includes(input) ? ok(input) : fail(path, `one of ${values.join(", ")}`, input);
|
|
43
|
+
}
|
|
44
|
+
function array(element) {
|
|
45
|
+
return (input, path = "$") => {
|
|
46
|
+
if (!Array.isArray(input))
|
|
47
|
+
return fail(path, "an array", input);
|
|
48
|
+
const out = [];
|
|
49
|
+
for (const [i, value] of input.entries()) {
|
|
50
|
+
const r = element(value, `${path}[${i}]`);
|
|
51
|
+
if (r.kind === "err")
|
|
52
|
+
return r;
|
|
53
|
+
out.push(r.value);
|
|
54
|
+
}
|
|
55
|
+
return ok(out);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
var isPlainObject = (input) => typeof input === "object" && input !== null && !Array.isArray(input);
|
|
59
|
+
function object(required, optional) {
|
|
60
|
+
return (input, path = "$") => {
|
|
61
|
+
if (!isPlainObject(input))
|
|
62
|
+
return fail(path, "an object", input);
|
|
63
|
+
const out = {};
|
|
64
|
+
for (const [key, decoder] of Object.entries(required)) {
|
|
65
|
+
const r = decoder(Reflect.get(input, key), `${path}.${key}`);
|
|
66
|
+
if (r.kind === "err")
|
|
67
|
+
return r;
|
|
68
|
+
out[key] = r.value;
|
|
69
|
+
}
|
|
70
|
+
for (const [key, decoder] of Object.entries(optional ?? {})) {
|
|
71
|
+
const value = Reflect.get(input, key);
|
|
72
|
+
if (value === undefined)
|
|
73
|
+
continue;
|
|
74
|
+
const r = decoder(value, `${path}.${key}`);
|
|
75
|
+
if (r.kind === "err")
|
|
76
|
+
return r;
|
|
77
|
+
out[key] = r.value;
|
|
78
|
+
}
|
|
79
|
+
return ok(out);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function refine(base, name, valid) {
|
|
83
|
+
return (input, path = "$") => {
|
|
84
|
+
const r = base(input, path);
|
|
85
|
+
if (r.kind === "err")
|
|
86
|
+
return r;
|
|
87
|
+
return valid(r.value) ? ok(r.value) : fail(path, `a ${name}`, input);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// ../core/src/text.ts
|
|
91
|
+
var ANSI = new RegExp(`${String.fromCharCode(27)}\\[[0-9;?]*[A-Za-z]`, "g");
|
|
92
|
+
// src/governance/ids.ts
|
|
93
|
+
var LIBRARY = refine(string, "library name", (t) => /^[a-z][a-z0-9-]*$/.test(t) && t.length <= 60);
|
|
94
|
+
var SEMVER = refine(string, "semver", (t) => /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(t));
|
|
95
|
+
var ISSUE = refine(string, "issue number", (t) => /^[1-9]\d{0,8}$/.test(t));
|
|
96
|
+
var SESSION = refine(string, "session url", (t) => /^https:\/\/[A-Za-z0-9.-]+(?:\/[A-Za-z0-9._~%/-]*)?$/.test(t));
|
|
97
|
+
var SUBJECT = refine(string, "commit subject", (t) => t.trim() === t && t !== "" && !t.includes(`
|
|
98
|
+
`) && t.length <= 100 && !t.endsWith("."));
|
|
99
|
+
var STEP = refine(string, "step id", (t) => /^[a-z][a-z0-9:-]*$/.test(t) && t.length <= 60);
|
|
100
|
+
var VARIABLE = refine(string, "variable name", (t) => /^[A-Z][A-Z0-9_]*$/.test(t) && t.length <= 80);
|
|
101
|
+
var REF = refine(string, "git ref", (t) => t !== "" && !t.startsWith("-") && !/[\s~^:?*[\\]|\.\.|@\{|\/\/|\.lock$|\/$/.test(t));
|
|
102
|
+
function parseLibraryName(text) {
|
|
103
|
+
const r = LIBRARY(text, "name");
|
|
104
|
+
return r.kind === "ok" ? ok(r.value) : err(`${JSON.stringify(text)} is not a library name: lower-case letters, digits and hyphens, starting with a letter, at most 60 characters`);
|
|
105
|
+
}
|
|
106
|
+
function parseSemver(text) {
|
|
107
|
+
const r = SEMVER(text, "version");
|
|
108
|
+
return r.kind === "ok" ? ok(r.value) : err(`${JSON.stringify(text)} is not a version of the form 1.2.3, with an optional -pre-release`);
|
|
109
|
+
}
|
|
110
|
+
// src/governance/generators.ts
|
|
111
|
+
function stepText(step) {
|
|
112
|
+
return step.kind === "program" ? step.argv.join(" ") : step.label;
|
|
113
|
+
}
|
|
114
|
+
// src/governance/identity.ts
|
|
115
|
+
function identityArgs(identity) {
|
|
116
|
+
return ["-c", `user.name=${identity.name}`, "-c", `user.email=${identity.email}`];
|
|
117
|
+
}
|
|
118
|
+
// src/governance/proof.ts
|
|
119
|
+
var PROOF_TIER_IDS = ["T0", "T1", "T2", "T3", "T4", "T5", "T6"];
|
|
120
|
+
var PROOF_TIERS = {
|
|
121
|
+
T0: { id: "T0", name: "static", proves: "types, format, specification and trace checks, on the affected files alone", budgetSeconds: 10, runsOn: ["edit", "push", "main", "nightly", "release"] },
|
|
122
|
+
T1: { id: "T1", name: "library", proves: "the suite of one library, property tests included", budgetSeconds: 30, runsOn: ["edit", "push", "main", "nightly", "release"] },
|
|
123
|
+
T2: { id: "T2", name: "seam", proves: "provider conformance and consumer seam tests where a provider's surface changed", budgetSeconds: 120, runsOn: ["push", "main", "nightly", "release"] },
|
|
124
|
+
T3: { id: "T3", name: "packaging", proves: "a tarball packed, installed, imported and type-checked", budgetSeconds: 120, runsOn: ["push", "main", "nightly", "release"] },
|
|
125
|
+
T4: { id: "T4", name: "end to end", proves: "the hermetic flows of a product", budgetSeconds: 600, runsOn: ["main", "nightly", "release"] },
|
|
126
|
+
T5: { id: "T5", name: "platform", proves: "Windows, macOS and Node against Bun, for libraries with code of their own for a system", budgetSeconds: 600, runsOn: ["main", "nightly", "release"] },
|
|
127
|
+
T6: { id: "T6", name: "release", proves: "everything, once per release", budgetSeconds: 1800, runsOn: ["release"] }
|
|
128
|
+
};
|
|
129
|
+
var CHANGE_CLASSES = ["prose", "spec", "spec-requirements", "generated", "version", "test", "source", "packaging", "planner", "outside"];
|
|
130
|
+
var CLASS_RULES = {
|
|
131
|
+
prose: { class: "prose", means: "a comment, TSDoc or text with no code change", proofs: "the documentation check", tiers: ["T0"] },
|
|
132
|
+
spec: { class: "spec", means: "a specification whose requirement identifiers are unchanged", proofs: "the specification and trace checks", tiers: ["T0"] },
|
|
133
|
+
"spec-requirements": { class: "spec-requirements", means: "a specification whose requirement identifiers changed", proofs: "the specification and trace checks, and the suite of the library", tiers: ["T0", "T1"] },
|
|
134
|
+
generated: { class: "generated", means: "a file a generator makes", proofs: "sync --check: the bytes equal the generators'", tiers: ["T0"] },
|
|
135
|
+
version: { class: "version", means: "a version or a release record only", proofs: "the versions check", tiers: ["T0"] },
|
|
136
|
+
test: { class: "test", means: "a test file of a library", proofs: "types, trace and the suite of that library", tiers: ["T0", "T1"] },
|
|
137
|
+
source: {
|
|
138
|
+
class: "source",
|
|
139
|
+
means: "code inside a library",
|
|
140
|
+
proofs: "types, trace and the suite of the library; its importers only where the public surface changed, and only the importers of the changed symbols; a foundation library also its smoke gate",
|
|
141
|
+
tiers: ["T0", "T1", "T2"]
|
|
142
|
+
},
|
|
143
|
+
packaging: { class: "packaging", means: "exports, package.json beyond its version, the packer", proofs: "pack, install, import and type-check the tarball", tiers: ["T0", "T3"] },
|
|
144
|
+
planner: { class: "planner", means: "the planner, the generators, the workflows or the tier rules", proofs: "every proof of every tier", tiers: ["T0", "T1", "T2", "T3", "T4", "T5", "T6"] },
|
|
145
|
+
outside: { class: "outside", means: "a file in no library that is none of the above", proofs: "the checks of the repository and the libraries that read the file", tiers: ["T0", "T1", "T4"] }
|
|
146
|
+
};
|
|
147
|
+
function tierOfProof(p) {
|
|
148
|
+
switch (p.kind) {
|
|
149
|
+
case "docs-check":
|
|
150
|
+
case "spec-check":
|
|
151
|
+
case "trace-check":
|
|
152
|
+
case "types":
|
|
153
|
+
case "sync-check":
|
|
154
|
+
case "versions-check":
|
|
155
|
+
return "T0";
|
|
156
|
+
case "suite":
|
|
157
|
+
case "smoke":
|
|
158
|
+
return "T1";
|
|
159
|
+
case "seam":
|
|
160
|
+
return "T2";
|
|
161
|
+
case "pack":
|
|
162
|
+
return "T3";
|
|
163
|
+
case "end-to-end":
|
|
164
|
+
return "T4";
|
|
165
|
+
case "platform":
|
|
166
|
+
return "T5";
|
|
167
|
+
case "release-gate":
|
|
168
|
+
return "T6";
|
|
169
|
+
default:
|
|
170
|
+
return absurd(p);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function proofKey(p) {
|
|
174
|
+
switch (p.kind) {
|
|
175
|
+
case "docs-check":
|
|
176
|
+
case "sync-check":
|
|
177
|
+
case "versions-check":
|
|
178
|
+
case "end-to-end":
|
|
179
|
+
case "release-gate":
|
|
180
|
+
return p.kind;
|
|
181
|
+
case "spec-check":
|
|
182
|
+
return `${p.kind}:${p.scope}`;
|
|
183
|
+
case "trace-check":
|
|
184
|
+
case "types":
|
|
185
|
+
case "suite":
|
|
186
|
+
case "smoke":
|
|
187
|
+
case "pack":
|
|
188
|
+
return `${p.kind}:${p.library}`;
|
|
189
|
+
case "seam":
|
|
190
|
+
return `${p.kind}:${p.provider}>${p.consumer}`;
|
|
191
|
+
case "platform":
|
|
192
|
+
return `${p.kind}:${p.library}:${p.system}`;
|
|
193
|
+
default:
|
|
194
|
+
return absurd(p);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
var PLANNER_GLOBS = [
|
|
198
|
+
"commons/repoctl/src/governance/proof.ts",
|
|
199
|
+
"commons/repoctl/src/governance/generators.ts",
|
|
200
|
+
"commons/repoctl/src/logical/prove*.ts",
|
|
201
|
+
"commons/repoctl/src/logical/surface.ts",
|
|
202
|
+
"commons/repoctl/src/logical/select.ts",
|
|
203
|
+
"commons/repoctl/src/physical/tests.ts",
|
|
204
|
+
"commons/repoctl/src/physical/prove*.ts",
|
|
205
|
+
"commons/repoctl/src/physical/verbs/prove.ts",
|
|
206
|
+
"commons/libraries/src/affected.ts",
|
|
207
|
+
"commons/libraries/src/plan.ts",
|
|
208
|
+
"commons/libraries/src/dev.ts",
|
|
209
|
+
"commons/libraries/src/generate-*.ts",
|
|
210
|
+
"commons/libraries/src/libraries.ts",
|
|
211
|
+
"commons/libraries/src/readme.ts",
|
|
212
|
+
"commons/libraries/src/license.ts",
|
|
213
|
+
"commons/libraries/src/workflows/**",
|
|
214
|
+
"commons/tools/generate-*.ts"
|
|
215
|
+
];
|
|
216
|
+
// ../headless/src/governance/tier.ts
|
|
217
|
+
var tierDecoder = refine(string, "tier name", (t) => /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(t));
|
|
218
|
+
function parseTierName(text) {
|
|
219
|
+
const r = tierDecoder(text, "tier");
|
|
220
|
+
return r.kind === "ok" ? ok(r.value) : err(`${JSON.stringify(text)} is not a tier name: lower-case words joined by hyphens`);
|
|
221
|
+
}
|
|
222
|
+
function literalTier(text) {
|
|
223
|
+
const r = parseTierName(text);
|
|
224
|
+
if (r.kind === "err")
|
|
225
|
+
throw new Error(r.error);
|
|
226
|
+
return r.value;
|
|
227
|
+
}
|
|
228
|
+
var PUBLIC = literalTier("public");
|
|
229
|
+
var OPERATOR = literalTier("operator");
|
|
230
|
+
var ADMINISTRATOR = literalTier("administrator");
|
|
231
|
+
// ../headless/src/governance/reach.ts
|
|
232
|
+
function defineReach(d) {
|
|
233
|
+
return {
|
|
234
|
+
channels: d.channels,
|
|
235
|
+
readOnly: d.readOnly ?? false,
|
|
236
|
+
idempotent: d.idempotent ?? false,
|
|
237
|
+
needsTty: d.needsTty ?? false,
|
|
238
|
+
runsAs: d.runsAs ?? "caller",
|
|
239
|
+
confirmation: d.confirmation ?? "none"
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
// ../headless/src/governance/redact.ts
|
|
243
|
+
var MASK = "***";
|
|
244
|
+
var MIN_SECRET = 4;
|
|
245
|
+
var SHAPES = [
|
|
246
|
+
/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,
|
|
247
|
+
/\bgh[pousr]_[A-Za-z0-9]{20,}\b/g,
|
|
248
|
+
/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,
|
|
249
|
+
/\bglpat-[A-Za-z0-9_-]{16,}/g,
|
|
250
|
+
/\bxox[abprs]-[A-Za-z0-9-]{10,}/g,
|
|
251
|
+
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
252
|
+
/\bnpm_[A-Za-z0-9]{30,}\b/g,
|
|
253
|
+
/\bsk-[A-Za-z0-9_-]{20,}/g,
|
|
254
|
+
/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
|
|
255
|
+
];
|
|
256
|
+
var escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
257
|
+
var VALUE = String.raw`('[^']*'|"[^"]*"|[^\s,;&'"]+)`;
|
|
258
|
+
function redact(text, secrets = [], options = {}) {
|
|
259
|
+
let out = text.replace(/([a-z][a-z0-9+.-]*:\/\/[^\s:/@]*):([^\s@/]+)@/gi, `$1:${MASK}@`).replace(new RegExp(String.raw`(\b(?:password|passwd|pwd)\s*=\s*)${VALUE}`, "gi"), `$1${MASK}`);
|
|
260
|
+
if (options.shapes !== false) {
|
|
261
|
+
for (const shape of SHAPES)
|
|
262
|
+
out = out.replace(shape, MASK);
|
|
263
|
+
out = out.replace(/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{16,}/g, `$1${MASK}`);
|
|
264
|
+
}
|
|
265
|
+
const keys = (options.keys ?? []).filter((k) => k !== "");
|
|
266
|
+
if (keys.length > 0) {
|
|
267
|
+
const alt = keys.map(escape).join("|");
|
|
268
|
+
out = out.replace(new RegExp(String.raw`(\b(?:${alt})\s*=\s*)${VALUE}`, "g"), `$1${MASK}`).replace(new RegExp(String.raw`("(?:${alt})"\s*:\s*)("[^"]*")`, "g"), `$1"${MASK}"`);
|
|
269
|
+
}
|
|
270
|
+
const longestFirst = [...secrets].filter((s) => s.length >= MIN_SECRET).sort((a, b) => b.length - a.length);
|
|
271
|
+
for (const s of longestFirst)
|
|
272
|
+
out = out.split(s).join(MASK);
|
|
273
|
+
return out;
|
|
274
|
+
}
|
|
275
|
+
// src/governance/tiers.ts
|
|
276
|
+
function named(id, standIn) {
|
|
277
|
+
const r = parseTierName(id);
|
|
278
|
+
return r.kind === "ok" ? r.value : standIn;
|
|
279
|
+
}
|
|
280
|
+
var TIERS = {
|
|
281
|
+
public: PUBLIC,
|
|
282
|
+
contributor: named("contributor", OPERATOR),
|
|
283
|
+
releaser: named("releaser", ADMINISTRATOR)
|
|
284
|
+
};
|
|
285
|
+
var LADDER = { ladder: [TIERS.public, TIERS.contributor, TIERS.releaser], default: TIERS.contributor };
|
|
286
|
+
// src/logical/findings.ts
|
|
287
|
+
function finding(level, code, message, fix) {
|
|
288
|
+
return { level, code, message, fix };
|
|
289
|
+
}
|
|
290
|
+
function tailLines(text, n) {
|
|
291
|
+
return text.split(`
|
|
292
|
+
`).map((l) => l.trim()).filter((l) => l !== "").slice(-n);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// src/logical/constants.ts
|
|
296
|
+
var DECLARATION = /\b([A-Z][A-Z0-9_]*_VERSION)\b[^=\n]*=\s*"([^"\n]*)"/g;
|
|
297
|
+
function constantsIn(source) {
|
|
298
|
+
const out = [];
|
|
299
|
+
for (const m of source.text.matchAll(DECLARATION)) {
|
|
300
|
+
const name = m[1];
|
|
301
|
+
const value = m[2];
|
|
302
|
+
if (name === undefined || value === undefined)
|
|
303
|
+
continue;
|
|
304
|
+
out.push({ path: source.path, name, value, line: source.text.slice(0, m.index).split(`
|
|
305
|
+
`).length });
|
|
306
|
+
}
|
|
307
|
+
return out;
|
|
308
|
+
}
|
|
309
|
+
function conventionName(library) {
|
|
310
|
+
return `${library.toUpperCase().replace(/-/g, "_")}_VERSION`;
|
|
311
|
+
}
|
|
312
|
+
function isRead(library, path) {
|
|
313
|
+
const own = `${library.folder}/`;
|
|
314
|
+
if (!path.startsWith(own))
|
|
315
|
+
return false;
|
|
316
|
+
const inside = path.slice(own.length);
|
|
317
|
+
return inside.startsWith("src/") && inside.endsWith(".ts") || library.versionConstants.some((c) => c.file === inside);
|
|
318
|
+
}
|
|
319
|
+
function constantFindings(libraries, sources) {
|
|
320
|
+
const out = [];
|
|
321
|
+
for (const lib of libraries) {
|
|
322
|
+
const here = sources.filter((s) => isRead(lib, s.path));
|
|
323
|
+
const found = here.flatMap(constantsIn);
|
|
324
|
+
const declared = new Set(lib.versionConstants.map((c) => `${lib.folder}/${c.file}\x00${c.name}`));
|
|
325
|
+
for (const c of lib.versionConstants) {
|
|
326
|
+
if (!found.some((f) => f.path === `${lib.folder}/${c.file}` && f.name === c.name))
|
|
327
|
+
out.push(finding("fail", "E-VERSION-CONSTANT", `${lib.folder}/${c.file}: the manifest names ${c.name} as holding the version of ${lib.name}, and the file does not say ${c.name} = "<version>"`, `fix the manifest's versionConstants of ${lib.name}`));
|
|
328
|
+
}
|
|
329
|
+
for (const f of found) {
|
|
330
|
+
const named = declared.has(`${f.path}\x00${f.name}`);
|
|
331
|
+
if (!named && f.name !== conventionName(lib.name))
|
|
332
|
+
continue;
|
|
333
|
+
if (parseSemver(f.value).kind === "err") {
|
|
334
|
+
out.push(finding("fail", "E-VERSION-CONSTANT", `${f.path}:${f.line}: ${f.name} is "${f.value}", which is not a version`, "repoctl sync"));
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (f.value !== lib.version)
|
|
338
|
+
out.push(finding("fail", "E-VERSION-CONSTANT", `${f.path}:${f.line}: ${f.name} is "${f.value}" and the version of ${lib.name} is "${lib.version}"`, `set ${f.name} to "${lib.version}" in ${f.path}`));
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return out;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// src/logical/declared.ts
|
|
345
|
+
var FROM = /^[ \t]*(?:(?:import|export)\b[^"'`\n]*?|\}[ \t]*)\bfrom[ \t]+"([^"\n]+)"|^[ \t]*import[ \t]+"([^"\n]+)"/gm;
|
|
346
|
+
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
347
|
+
function importedPackageOf(specifier) {
|
|
348
|
+
if (specifier.startsWith("node:"))
|
|
349
|
+
return "@types/node";
|
|
350
|
+
if (specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("$") || specifier.startsWith("bun:") || specifier === "bun")
|
|
351
|
+
return;
|
|
352
|
+
const parts = specifier.split("/");
|
|
353
|
+
const head = parts[0];
|
|
354
|
+
if (head === undefined)
|
|
355
|
+
return;
|
|
356
|
+
return head.startsWith("@") ? `${head}/${parts[1] ?? ""}` : head;
|
|
357
|
+
}
|
|
358
|
+
function withoutBlockComments(text) {
|
|
359
|
+
return text.replace(/\/\*[\s\S]*?\*\//g, (c) => c.replace(/[^\n]/g, " "));
|
|
360
|
+
}
|
|
361
|
+
function importedPackages(source) {
|
|
362
|
+
const text = withoutBlockComments(source.text);
|
|
363
|
+
const out = new Map;
|
|
364
|
+
for (const m of text.matchAll(FROM)) {
|
|
365
|
+
const pkg = importedPackageOf(m[1] ?? m[2] ?? "");
|
|
366
|
+
if (pkg !== undefined && !out.has(pkg))
|
|
367
|
+
out.set(pkg, text.slice(0, m.index).split(`
|
|
368
|
+
`).length);
|
|
369
|
+
}
|
|
370
|
+
return out;
|
|
371
|
+
}
|
|
372
|
+
function declaredNames(manifest) {
|
|
373
|
+
let json;
|
|
374
|
+
try {
|
|
375
|
+
json = JSON.parse(manifest);
|
|
376
|
+
} catch {
|
|
377
|
+
return new Set;
|
|
378
|
+
}
|
|
379
|
+
if (!isRecord(json))
|
|
380
|
+
return new Set;
|
|
381
|
+
const names = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"].flatMap((k) => {
|
|
382
|
+
const section = json[k];
|
|
383
|
+
return isRecord(section) ? Object.keys(section) : [];
|
|
384
|
+
});
|
|
385
|
+
return new Set(names);
|
|
386
|
+
}
|
|
387
|
+
function undeclaredFindings(libraries) {
|
|
388
|
+
const out = [];
|
|
389
|
+
for (const lib of libraries) {
|
|
390
|
+
const declared = declaredNames(lib.manifest);
|
|
391
|
+
const own = `@intellectual-frontiers/${lib.name}`;
|
|
392
|
+
const first = new Map;
|
|
393
|
+
for (const source of lib.sources) {
|
|
394
|
+
for (const [pkg, line] of importedPackages(source))
|
|
395
|
+
if (pkg !== own && !declared.has(pkg) && !first.has(pkg))
|
|
396
|
+
first.set(pkg, `${source.path}:${line}`);
|
|
397
|
+
}
|
|
398
|
+
for (const [pkg, where] of [...first].sort(([a], [b]) => a.localeCompare(b))) {
|
|
399
|
+
const add = pkg.startsWith("@intellectual-frontiers/") ? `"${pkg}": "link:../${pkg.slice("@intellectual-frontiers/".length)}"` : `${pkg} (exact version)`;
|
|
400
|
+
out.push(finding("fail", "E-UNDECLARED-DEPENDENCY", `${lib.folder}: ${where} imports ${pkg}, which ${lib.folder}/package.json does not declare`, `add ${add} to the devDependencies of ${lib.folder}/package.json`));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return out;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// src/logical/glob.ts
|
|
407
|
+
var segments = (glob) => glob.split("/").filter((s) => s !== "");
|
|
408
|
+
var regexOf = (segment) => new RegExp(`^${segment.split("*").map((p) => p.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join("[^/]*")}$`);
|
|
409
|
+
var segmentMatches = (pattern, name) => regexOf(pattern).test(name);
|
|
410
|
+
function matchFrom(pattern, path) {
|
|
411
|
+
const [head, ...rest] = pattern;
|
|
412
|
+
if (head === undefined)
|
|
413
|
+
return path.length === 0;
|
|
414
|
+
if (head === "**")
|
|
415
|
+
return matchFrom(rest, path) || path.length > 0 && matchFrom(pattern, path.slice(1));
|
|
416
|
+
const [first, ...others] = path;
|
|
417
|
+
return first !== undefined && segmentMatches(head, first) && matchFrom(rest, others);
|
|
418
|
+
}
|
|
419
|
+
function matches(glob, path) {
|
|
420
|
+
return matchFrom(segments(glob), segments(path));
|
|
421
|
+
}
|
|
422
|
+
function segmentOverlap(a, b) {
|
|
423
|
+
if (a === b)
|
|
424
|
+
return true;
|
|
425
|
+
if (!a.includes("*"))
|
|
426
|
+
return segmentMatches(b, a);
|
|
427
|
+
if (!b.includes("*"))
|
|
428
|
+
return segmentMatches(a, b);
|
|
429
|
+
const head = (s) => s.slice(0, s.indexOf("*"));
|
|
430
|
+
const tail = (s) => s.slice(s.lastIndexOf("*") + 1);
|
|
431
|
+
const compatible = (x, y, from) => from === "start" ? x.startsWith(y) || y.startsWith(x) : x.endsWith(y) || y.endsWith(x);
|
|
432
|
+
return compatible(head(a), head(b), "start") && compatible(tail(a), tail(b), "end");
|
|
433
|
+
}
|
|
434
|
+
function overlapFrom(a, b) {
|
|
435
|
+
const [x, ...xs] = a;
|
|
436
|
+
const [y, ...ys] = b;
|
|
437
|
+
if (x === undefined && y === undefined)
|
|
438
|
+
return true;
|
|
439
|
+
if (x === "**")
|
|
440
|
+
return overlapFrom(xs, b) || y !== undefined && overlapFrom(a, ys);
|
|
441
|
+
if (y === "**")
|
|
442
|
+
return overlapFrom(a, ys) || x !== undefined && overlapFrom(xs, b);
|
|
443
|
+
if (x === undefined || y === undefined)
|
|
444
|
+
return false;
|
|
445
|
+
return segmentOverlap(x, y) && overlapFrom(xs, ys);
|
|
446
|
+
}
|
|
447
|
+
function overlap(a, b) {
|
|
448
|
+
return overlapFrom(segments(a), segments(b));
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// src/logical/order.ts
|
|
452
|
+
function reads(later, earlier) {
|
|
453
|
+
return later.id !== earlier.id && (later.after.includes(earlier.id) || earlier.outputs.some((o) => later.inputs.some((i) => overlap(o, i))));
|
|
454
|
+
}
|
|
455
|
+
function orderGenerators(table) {
|
|
456
|
+
const left = [...table];
|
|
457
|
+
const done = [];
|
|
458
|
+
while (left.length > 0) {
|
|
459
|
+
const next = left.find((g) => !left.some((other) => reads(g, other)));
|
|
460
|
+
if (next === undefined)
|
|
461
|
+
return err(left.map((g) => g.id));
|
|
462
|
+
done.push(next);
|
|
463
|
+
left.splice(left.indexOf(next), 1);
|
|
464
|
+
}
|
|
465
|
+
return ok(done);
|
|
466
|
+
}
|
|
467
|
+
function generatorOf(table, path) {
|
|
468
|
+
return table.find((g) => g.outputs.some((o) => matches(o, path)));
|
|
469
|
+
}
|
|
470
|
+
function fixOf(g) {
|
|
471
|
+
return stepText(g.run);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// src/logical/pool.ts
|
|
475
|
+
async function pool(items, width, job) {
|
|
476
|
+
const results = [];
|
|
477
|
+
const order = items.map((item, index) => ({ item, index }));
|
|
478
|
+
const slots = [];
|
|
479
|
+
let next = 0;
|
|
480
|
+
const worker = async () => {
|
|
481
|
+
for (;; ) {
|
|
482
|
+
const mine = order[next++];
|
|
483
|
+
if (mine === undefined)
|
|
484
|
+
return;
|
|
485
|
+
results[mine.index] = await job(mine.item);
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
for (let i = 0;i < Math.max(1, Math.min(width, items.length)); i++)
|
|
489
|
+
slots.push(worker());
|
|
490
|
+
await Promise.all(slots);
|
|
491
|
+
return results;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// src/logical/step.ts
|
|
495
|
+
async function runStep(w, step) {
|
|
496
|
+
if (step.kind === "program")
|
|
497
|
+
return await w.process.run(step.argv, { cwd: w.repo });
|
|
498
|
+
try {
|
|
499
|
+
return await step.call({ repo: w.repo });
|
|
500
|
+
} catch (e) {
|
|
501
|
+
return { code: 2, stdout: "", stderr: `${step.label} threw: ${e instanceof Error ? e.message : String(e)}` };
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// src/logical/sync.ts
|
|
506
|
+
function classify(run) {
|
|
507
|
+
return run.code === 0 ? "fresh" : run.code === 1 ? "stale" : "failed";
|
|
508
|
+
}
|
|
509
|
+
var linesOf = (run) => tailLines(`${run.stdout}
|
|
510
|
+
${run.stderr}`, 8);
|
|
511
|
+
async function runSync(w, mode, order, only = []) {
|
|
512
|
+
const outcomes = [];
|
|
513
|
+
for (const g of order) {
|
|
514
|
+
if (only.length > 0 && !only.includes(g.id))
|
|
515
|
+
continue;
|
|
516
|
+
const checked = await runStep(w, g.check);
|
|
517
|
+
const state = classify(checked);
|
|
518
|
+
const fix = fixOf(g);
|
|
519
|
+
if (state === "fresh")
|
|
520
|
+
outcomes.push({ kind: "fresh", id: g.id });
|
|
521
|
+
else if (state === "failed")
|
|
522
|
+
outcomes.push({ kind: "failed", id: g.id, fix, detail: linesOf(checked) });
|
|
523
|
+
else if (mode === "check")
|
|
524
|
+
outcomes.push({ kind: "stale", id: g.id, fix, detail: linesOf(checked) });
|
|
525
|
+
else {
|
|
526
|
+
const wrote = await runStep(w, g.run);
|
|
527
|
+
const again = wrote.code === 0 ? await runStep(w, g.check) : wrote;
|
|
528
|
+
outcomes.push(again.code === 0 ? { kind: "regenerated", id: g.id } : { kind: "failed", id: g.id, fix, detail: linesOf(again) });
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return { mode, outcomes };
|
|
532
|
+
}
|
|
533
|
+
function findingsOfSync(report) {
|
|
534
|
+
return report.outcomes.flatMap((o) => {
|
|
535
|
+
switch (o.kind) {
|
|
536
|
+
case "fresh":
|
|
537
|
+
case "regenerated":
|
|
538
|
+
return [];
|
|
539
|
+
case "stale":
|
|
540
|
+
return [finding("fail", "E-STALE-GENERATED", `${o.id}: its files are not what its sources make${o.detail.length > 0 ? ` (${o.detail.join("; ")})` : ""}`, o.fix)];
|
|
541
|
+
case "failed":
|
|
542
|
+
return [finding("fail", "E-GENERATOR-FAILED", `${o.id}: it could not be made${o.detail.length > 0 ? ` (${o.detail.join("; ")})` : ""}`, o.fix)];
|
|
543
|
+
default:
|
|
544
|
+
return absurd(o);
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// src/logical/check.ts
|
|
550
|
+
function sectionOk(s) {
|
|
551
|
+
return s.findings.every((f) => f.level !== "fail");
|
|
552
|
+
}
|
|
553
|
+
function reportOk(r) {
|
|
554
|
+
return r.sections.every(sectionOk);
|
|
555
|
+
}
|
|
556
|
+
var MOST = 12;
|
|
557
|
+
function findingsOfProgram(run, code, fix) {
|
|
558
|
+
if (run.code === 0)
|
|
559
|
+
return [];
|
|
560
|
+
const said = tailLines(`${run.stderr}
|
|
561
|
+
${run.stdout}`, 200);
|
|
562
|
+
if (run.code === 1) {
|
|
563
|
+
const shown = said.slice(0, MOST).map((l) => finding("fail", code, l, fix));
|
|
564
|
+
return said.length > MOST ? [...shown, finding("fail", code, `and ${said.length - MOST} more lines; run ${fix} to read them`, fix)] : shown;
|
|
565
|
+
}
|
|
566
|
+
return [finding("warn", "E-ENVIRONMENT", `the check could not run (status ${run.code}): ${said.slice(-2).join("; ")}`, fix)];
|
|
567
|
+
}
|
|
568
|
+
var fill = (argv, values) => argv.map((w) => w.replace(/\{(kit|level)\}/g, (_m, k) => values[k] ?? ""));
|
|
569
|
+
async function specKitSection(w, specKit, lib) {
|
|
570
|
+
const kit = `${lib.folder}/${lib.specKit ?? "spec-kit"}`;
|
|
571
|
+
const values = { kit, level: lib.level };
|
|
572
|
+
const here = { cwd: w.repo };
|
|
573
|
+
const format = fill(specKit.format, values);
|
|
574
|
+
const rules = fill(specKit.rules, values);
|
|
575
|
+
const [f, r] = [await w.process.run(format, here), await w.process.run(rules, here)];
|
|
576
|
+
return {
|
|
577
|
+
id: `spec-kit:${lib.name}`,
|
|
578
|
+
title: `The specification kit of ${lib.name}`,
|
|
579
|
+
findings: [...findingsOfProgram(f, "E-SPEC-KIT", format.join(" ")), ...findingsOfProgram(r, "E-MIZAN-RULE", rules.join(" "))]
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
async function sourcesOf(w, libs) {
|
|
583
|
+
const out = [];
|
|
584
|
+
for (const lib of libs) {
|
|
585
|
+
const base = `${w.repo}/${lib.folder}`;
|
|
586
|
+
const paths = new Set([...(await w.files.walk(`${base}/src`)).filter((p) => p.endsWith(".ts")).map((p) => `src/${p}`), ...lib.versionConstants.map((c) => c.file)]);
|
|
587
|
+
for (const inside of [...paths].sort()) {
|
|
588
|
+
const text = await w.files.read(`${base}/${inside}`);
|
|
589
|
+
if (text !== undefined)
|
|
590
|
+
out.push({ path: `${lib.folder}/${inside}`, text });
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
return out;
|
|
594
|
+
}
|
|
595
|
+
async function declaredInputs(w, libs) {
|
|
596
|
+
const out = [];
|
|
597
|
+
for (const lib of libs) {
|
|
598
|
+
const base = `${w.repo}/${lib.folder}`;
|
|
599
|
+
const walked = await Promise.all(["src", "suite", "tools"].map(async (d) => (await w.files.walk(`${base}/${d}`)).filter((p) => p.endsWith(".ts")).map((p) => `${d}/${p}`)));
|
|
600
|
+
const sources = [];
|
|
601
|
+
for (const path of [...walked.flat(), "about.ts"].sort()) {
|
|
602
|
+
const text = await w.files.read(`${base}/${path}`);
|
|
603
|
+
if (text !== undefined)
|
|
604
|
+
sources.push({ path: `${lib.folder}/${path}`, text });
|
|
605
|
+
}
|
|
606
|
+
out.push({ name: lib.name, folder: lib.folder, manifest: await w.files.read(`${base}/package.json`) ?? "", sources });
|
|
607
|
+
}
|
|
608
|
+
return out;
|
|
609
|
+
}
|
|
610
|
+
async function runCheck(w, config) {
|
|
611
|
+
const sections = [];
|
|
612
|
+
const synced = await runSync(w, "check", config.generators);
|
|
613
|
+
for (const o of synced.outcomes) {
|
|
614
|
+
const g = config.generators.find((x) => x.id === o.id);
|
|
615
|
+
sections.push({ id: `generator:${o.id}`, title: `The files of the generator ${o.id}`, findings: findingsOfSync({ mode: "check", outcomes: [o] }).map((f) => g === undefined ? f : { ...f, fix: fixOf(g) }) });
|
|
616
|
+
}
|
|
617
|
+
for (const c of config.checks)
|
|
618
|
+
sections.push({ id: c.id, title: c.summary, findings: findingsOfProgram(await runStep(w, c.run), c.code, stepText(c.run)) });
|
|
619
|
+
if (config.libraries === undefined)
|
|
620
|
+
return { sections };
|
|
621
|
+
const libs = await w.libraries.list();
|
|
622
|
+
if (libs.kind === "err") {
|
|
623
|
+
sections.push({ id: "libraries", title: "The manifests of the libraries", findings: [finding("fail", "E-LIBRARY-CHECK", libs.error, "repoctl doctor")] });
|
|
624
|
+
return { sections };
|
|
625
|
+
}
|
|
626
|
+
const specKit = config.libraries.specKit;
|
|
627
|
+
if (specKit !== undefined)
|
|
628
|
+
for (const s of await pool(libs.value.filter((l) => l.specKit !== undefined), 6, (l) => specKitSection(w, specKit, l)))
|
|
629
|
+
sections.push(s);
|
|
630
|
+
if (config.libraries.versionConstants)
|
|
631
|
+
sections.push({ id: "version-constants", title: "The constants of the sources that say a version", findings: constantFindings(libs.value, await sourcesOf(w, libs.value)) });
|
|
632
|
+
if (config.libraries.declaredDependencies)
|
|
633
|
+
sections.push({ id: "declared-dependencies", title: "The packages each library imports and declares", findings: undeclaredFindings(await declaredInputs(w, libs.value)) });
|
|
634
|
+
return { sections };
|
|
635
|
+
}
|
|
636
|
+
// src/logical/commit.ts
|
|
637
|
+
function messageOf(policy, input) {
|
|
638
|
+
const lines = policy.trailers.flatMap((t) => {
|
|
639
|
+
switch (t) {
|
|
640
|
+
case "issue":
|
|
641
|
+
return input.refs === undefined ? [] : [`${policy.issue.prefix}${input.refs}`];
|
|
642
|
+
case "co-author":
|
|
643
|
+
return input.coAuthor === undefined ? [] : [input.coAuthor];
|
|
644
|
+
case "session":
|
|
645
|
+
return input.session === undefined ? [] : [`Claude-Session: ${input.session}`];
|
|
646
|
+
default:
|
|
647
|
+
return absurd(t);
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
return { subject: input.subject, trailers: lines };
|
|
651
|
+
}
|
|
652
|
+
function messageText(m) {
|
|
653
|
+
return m.trailers.length === 0 ? `${m.subject}
|
|
654
|
+
` : `${m.subject}
|
|
655
|
+
|
|
656
|
+
${m.trailers.join(`
|
|
657
|
+
`)}
|
|
658
|
+
`;
|
|
659
|
+
}
|
|
660
|
+
function forbidden(policy, path) {
|
|
661
|
+
if (policy.allow.some((g) => matches(g, path)))
|
|
662
|
+
return;
|
|
663
|
+
return policy.paths.find((p) => matches(p.glob, path))?.why;
|
|
664
|
+
}
|
|
665
|
+
function secretLike(policy, text) {
|
|
666
|
+
return policy.secrets.find((s) => new RegExp(s.pattern).test(text))?.label;
|
|
667
|
+
}
|
|
668
|
+
var lines = (text) => text.split(`
|
|
669
|
+
`).map((l) => l.trim()).filter((l) => l !== "");
|
|
670
|
+
async function runCommit(w, input, order, policy) {
|
|
671
|
+
const here = { cwd: w.repo };
|
|
672
|
+
const git = (...args) => w.process.run(["git", "-c", "core.quotepath=false", ...args], here);
|
|
673
|
+
const refuse = (found) => ({ kind: "refused", findings: found });
|
|
674
|
+
const named = input.paths.flatMap((p) => {
|
|
675
|
+
const why = forbidden(policy.forbidden, p);
|
|
676
|
+
return why === undefined ? [] : [finding("fail", "E-COMMIT-FORBIDDEN", `${p} is ${why}`, `do not add ${p}`)];
|
|
677
|
+
});
|
|
678
|
+
if (named.length > 0)
|
|
679
|
+
return refuse(named);
|
|
680
|
+
const synced = findingsOfSync(await runSync(w, "check", order));
|
|
681
|
+
if (synced.length > 0)
|
|
682
|
+
return refuse(synced);
|
|
683
|
+
if (!input.dryRun && input.paths.length > 0) {
|
|
684
|
+
const added = await git("add", "--", ...input.paths);
|
|
685
|
+
if (added.code !== 0)
|
|
686
|
+
return refuse([finding("fail", "E-COMMIT-FAILED", `git could not add the paths: ${lines(added.stderr).slice(-1)[0] ?? "no message"}`, "git status")]);
|
|
687
|
+
}
|
|
688
|
+
const staged = lines((await git("diff", "--cached", "--name-only")).stdout);
|
|
689
|
+
const files = input.dryRun ? [...new Set([...staged, ...input.paths])] : staged;
|
|
690
|
+
if (files.length === 0)
|
|
691
|
+
return refuse([finding("fail", "E-COMMIT-NOTHING", "nothing is staged and no path was given", "git status")]);
|
|
692
|
+
const found = [];
|
|
693
|
+
for (const path of files) {
|
|
694
|
+
const why = forbidden(policy.forbidden, path);
|
|
695
|
+
if (why !== undefined) {
|
|
696
|
+
found.push(finding("fail", "E-COMMIT-FORBIDDEN", `${path} is ${why}`, `git restore --staged ${path}`));
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
const text = await w.files.read(`${w.repo}/${path}`);
|
|
700
|
+
const looks = text === undefined ? undefined : secretLike(policy.forbidden, text);
|
|
701
|
+
if (looks !== undefined)
|
|
702
|
+
found.push(finding("fail", "E-COMMIT-FORBIDDEN", `${path} holds what looks like ${looks}`, `git restore --staged ${path}`));
|
|
703
|
+
}
|
|
704
|
+
if (found.length > 0)
|
|
705
|
+
return refuse(found);
|
|
706
|
+
const message = messageOf(policy, { subject: input.subject, refs: input.refs, coAuthor: input.coAuthor, session: input.session });
|
|
707
|
+
const text = messageText(message);
|
|
708
|
+
if (input.dryRun)
|
|
709
|
+
return { kind: "preview", message: text, files };
|
|
710
|
+
const made = await w.process.run(["git", ...identityArgs(policy.identity), "commit", "-m", message.subject, ...message.trailers.length === 0 ? [] : ["-m", message.trailers.join(`
|
|
711
|
+
`)]], here);
|
|
712
|
+
if (made.code !== 0)
|
|
713
|
+
return refuse([finding("fail", "E-COMMIT-FAILED", `git did not make the commit: ${lines(`${made.stdout}
|
|
714
|
+
${made.stderr}`).slice(-2).join("; ")}`, "git status")]);
|
|
715
|
+
const sha = lines((await git("rev-parse", "--short", "HEAD")).stdout)[0] ?? "";
|
|
716
|
+
return { kind: "committed", message: text, files, sha };
|
|
717
|
+
}
|
|
718
|
+
// src/logical/doctor.ts
|
|
719
|
+
function majorOf(version) {
|
|
720
|
+
const m = /^v?(\d+)\./.exec(version ?? "");
|
|
721
|
+
return m?.[1] === undefined ? undefined : Number(m[1]);
|
|
722
|
+
}
|
|
723
|
+
function diagnose(f, policy) {
|
|
724
|
+
const out = [];
|
|
725
|
+
if (!f.git.works)
|
|
726
|
+
out.push(finding("fail", "E-DOCTOR-GIT", "git does not run here", "install Git and run repoctl doctor again"));
|
|
727
|
+
else if (!f.git.inside)
|
|
728
|
+
out.push(finding("fail", "E-DOCTOR-GIT", "this folder is not inside a Git working tree", "run repoctl from a clone of the repository"));
|
|
729
|
+
else if (!f.git.origin)
|
|
730
|
+
out.push(finding("warn", "E-DOCTOR-GIT", "this checkout has no remote named origin, so the tags and the base of the checks are not known", "git remote add origin <address of the repository>"));
|
|
731
|
+
if (!f.installed)
|
|
732
|
+
out.push(finding("fail", "E-DOCTOR-INSTALL", "the root has no node_modules", policy.install));
|
|
733
|
+
if (f.unlinked.length > 0 && policy.links !== undefined)
|
|
734
|
+
out.push(finding("fail", "E-DOCTOR-LINKS", `the libraries are not linked: ${f.unlinked.join(", ")}`, policy.links.fix.join(" ")));
|
|
735
|
+
const major = majorOf(f.node);
|
|
736
|
+
if (policy.minNode !== undefined && (major === undefined || major < policy.minNode))
|
|
737
|
+
out.push(finding("fail", "E-DOCTOR-NODE", `Node is ${f.node ?? "not available"} and this repository needs Node ${policy.minNode}`, `install Node ${policy.minNode} and put it first on the PATH`));
|
|
738
|
+
if (f.bun !== undefined && f.pinnedBun !== undefined && f.bun !== f.pinnedBun)
|
|
739
|
+
out.push(finding("warn", "E-DOCTOR-BUN", `Bun is ${f.bun} and the repository pins ${f.pinnedBun}`, `bun upgrade --version ${f.pinnedBun}`));
|
|
740
|
+
return [...out, ...f.stale];
|
|
741
|
+
}
|
|
742
|
+
var firstLine = (text) => text.split(`
|
|
743
|
+
`).map((l) => l.trim()).find((l) => l !== "");
|
|
744
|
+
async function gatherFacts(w, order, policy) {
|
|
745
|
+
const here = { cwd: w.repo };
|
|
746
|
+
const git = await w.process.run(["git", "--version"], here).catch(() => ({ code: 127, stdout: "", stderr: "" }));
|
|
747
|
+
const inside = git.code === 0 && (await w.process.run(["git", "rev-parse", "--is-inside-work-tree"], here)).stdout.trim() === "true";
|
|
748
|
+
const origin = inside && (await w.process.run(["git", "remote", "get-url", "origin"], here)).code === 0;
|
|
749
|
+
const node = await w.process.run(["node", "--version"], here).catch(() => ({ code: 127, stdout: "", stderr: "" }));
|
|
750
|
+
const bun = await w.process.run(["bun", "--version"], here).catch(() => ({ code: 127, stdout: "", stderr: "" }));
|
|
751
|
+
const pins = policy.bunPin === undefined ? undefined : await w.files.read(`${w.repo}/${policy.bunPin.file}`);
|
|
752
|
+
const pinnedBun = pins === undefined || policy.bunPin === undefined ? undefined : new RegExp(`^${policy.bunPin.variable}=(.+)$`, "m").exec(pins)?.[1]?.trim();
|
|
753
|
+
const installed = await w.files.exists(`${w.repo}/node_modules`);
|
|
754
|
+
const libs = await w.libraries.list();
|
|
755
|
+
const linked = policy.links === undefined ? [] : await w.files.list(`${w.repo}/${policy.links.folder}`);
|
|
756
|
+
const unlinked = policy.links !== undefined && libs.kind === "ok" ? libs.value.map((l) => l.name).filter((n) => !linked.includes(n)) : [];
|
|
757
|
+
const stale = installed ? findingsOfSync(await runSync(w, "check", order)) : [];
|
|
758
|
+
return {
|
|
759
|
+
git: { works: git.code === 0, inside, origin },
|
|
760
|
+
installed,
|
|
761
|
+
unlinked,
|
|
762
|
+
node: node.code === 0 ? firstLine(node.stdout) : undefined,
|
|
763
|
+
bun: bun.code === 0 ? firstLine(bun.stdout) : undefined,
|
|
764
|
+
pinnedBun,
|
|
765
|
+
stale
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
// src/logical/merge.ts
|
|
769
|
+
function partitionConflicts(table, paths) {
|
|
770
|
+
return {
|
|
771
|
+
generated: paths.filter((p) => generatorOf(table, p) !== undefined),
|
|
772
|
+
written: paths.filter((p) => generatorOf(table, p) === undefined)
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
function isMixed(table, path) {
|
|
776
|
+
return (generatorOf(table, path)?.mixed ?? []).some((glob) => matches(glob, path));
|
|
777
|
+
}
|
|
778
|
+
var lines2 = (text) => text.split(`
|
|
779
|
+
`).map((l) => l.trim()).filter((l) => l !== "");
|
|
780
|
+
async function union(w, path) {
|
|
781
|
+
const here = { cwd: w.repo };
|
|
782
|
+
const dir = await w.files.makeTemp("repoctl-merge-");
|
|
783
|
+
try {
|
|
784
|
+
const names = ["base", "ours", "theirs"];
|
|
785
|
+
for (const [i, name] of names.entries()) {
|
|
786
|
+
const shown = await w.process.run(["git", "show", `:${i + 1}:${path}`], here);
|
|
787
|
+
await w.files.write(`${dir}/${name}`, shown.code === 0 ? shown.stdout : "");
|
|
788
|
+
}
|
|
789
|
+
const merged = await w.process.run(["git", "merge-file", "-p", "--union", `${dir}/theirs`, `${dir}/base`, `${dir}/ours`], here);
|
|
790
|
+
if (merged.code !== 0)
|
|
791
|
+
return false;
|
|
792
|
+
await w.files.write(`${w.repo}/${path}`, merged.stdout);
|
|
793
|
+
return true;
|
|
794
|
+
} finally {
|
|
795
|
+
await w.files.removeTree(dir);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
async function runMerge(w, ref, order, identity) {
|
|
799
|
+
const here = { cwd: w.repo };
|
|
800
|
+
const git = (...args) => w.process.run(["git", ...identityArgs(identity), ...args], here);
|
|
801
|
+
const merged = await git("merge", "--no-edit", ref);
|
|
802
|
+
if (merged.code === 0)
|
|
803
|
+
return { kind: "merged", sync: await runSync(w, "check", order) };
|
|
804
|
+
const unmerged = lines2((await git("diff", "--name-only", "--diff-filter=U")).stdout);
|
|
805
|
+
if (unmerged.length === 0)
|
|
806
|
+
return { kind: "refused", why: tailLines(`${merged.stdout}
|
|
807
|
+
${merged.stderr}`, 6) };
|
|
808
|
+
const { generated, written } = partitionConflicts(order, unmerged);
|
|
809
|
+
const cleared = [];
|
|
810
|
+
const stuck = [];
|
|
811
|
+
const unioned = [];
|
|
812
|
+
for (const path of generated) {
|
|
813
|
+
const mixed = isMixed(order, path);
|
|
814
|
+
const taken = mixed ? await union(w, path) : (await git("checkout", "--ours", "--", path)).code === 0;
|
|
815
|
+
if (taken && mixed)
|
|
816
|
+
unioned.push(path);
|
|
817
|
+
(taken ? cleared : stuck).push(path);
|
|
818
|
+
}
|
|
819
|
+
const sync = await runSync(w, "write", order);
|
|
820
|
+
const fresh = new Set(sync.outcomes.filter((o) => o.kind === "fresh" || o.kind === "regenerated").map((o) => o.id));
|
|
821
|
+
const regenerated = [];
|
|
822
|
+
const unresolved = [...stuck];
|
|
823
|
+
for (const path of cleared) {
|
|
824
|
+
const g = generatorOf(order, path);
|
|
825
|
+
if (g !== undefined && fresh.has(g.id)) {
|
|
826
|
+
const added = await git("add", "--", path);
|
|
827
|
+
(added.code === 0 ? regenerated : unresolved).push(path);
|
|
828
|
+
} else
|
|
829
|
+
unresolved.push(path);
|
|
830
|
+
}
|
|
831
|
+
const changed = [...lines2((await git("diff", "--name-only")).stdout), ...lines2((await git("ls-files", "--others", "--exclude-standard")).stdout)];
|
|
832
|
+
for (const path of changed)
|
|
833
|
+
if (!written.includes(path) && !unresolved.includes(path) && generatorOf(order, path) !== undefined)
|
|
834
|
+
await git("add", "--", path);
|
|
835
|
+
const committed = written.length === 0 && unresolved.length === 0 ? (await git("commit", "--no-edit")).code === 0 : false;
|
|
836
|
+
return { kind: "conflicts", regenerated, unioned: unioned.filter((p) => regenerated.includes(p)), unresolved, written, committed, sync };
|
|
837
|
+
}
|
|
838
|
+
// src/logical/surface.ts
|
|
839
|
+
var WORD = /[A-Za-z_$][\w$]*/y;
|
|
840
|
+
var BLOCK = /^(?:export\s+)?(?:declare\s+)?(?:default\s+)?(?:abstract\s+)?(?:interface|class|namespace|module|enum|const\s+enum|global)\b/;
|
|
841
|
+
var STARTERS = new Set(["export", "declare", "import", "type", "interface", "const", "function", "class", "namespace", "enum", "let", "var", "abstract", "module", "global"]);
|
|
842
|
+
function skipString(text, i) {
|
|
843
|
+
const q = text[i] ?? "";
|
|
844
|
+
let j = i + 1;
|
|
845
|
+
while (j < text.length) {
|
|
846
|
+
const c = text[j] ?? "";
|
|
847
|
+
if (c === "\\")
|
|
848
|
+
j += 2;
|
|
849
|
+
else if (c === q)
|
|
850
|
+
return j + 1;
|
|
851
|
+
else if (q === "`" && c === "$" && text[j + 1] === "{")
|
|
852
|
+
j = skipBraces(text, j + 1);
|
|
853
|
+
else
|
|
854
|
+
j++;
|
|
855
|
+
}
|
|
856
|
+
return text.length;
|
|
857
|
+
}
|
|
858
|
+
function skipBraces(text, i) {
|
|
859
|
+
let depth = 0;
|
|
860
|
+
let j = i;
|
|
861
|
+
while (j < text.length) {
|
|
862
|
+
const c = text[j] ?? "";
|
|
863
|
+
if (c === "'" || c === '"' || c === "`")
|
|
864
|
+
j = skipString(text, j);
|
|
865
|
+
else {
|
|
866
|
+
if (c === "{")
|
|
867
|
+
depth++;
|
|
868
|
+
if (c === "}") {
|
|
869
|
+
depth--;
|
|
870
|
+
if (depth === 0)
|
|
871
|
+
return j + 1;
|
|
872
|
+
}
|
|
873
|
+
j++;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
return text.length;
|
|
877
|
+
}
|
|
878
|
+
function stripComments(text) {
|
|
879
|
+
let out = "";
|
|
880
|
+
let i = 0;
|
|
881
|
+
let prev = "";
|
|
882
|
+
while (i < text.length) {
|
|
883
|
+
const c = text[i] ?? "";
|
|
884
|
+
const next = text[i + 1] ?? "";
|
|
885
|
+
if (c === "/" && next === "/") {
|
|
886
|
+
while (i < text.length && text[i] !== `
|
|
887
|
+
`)
|
|
888
|
+
i++;
|
|
889
|
+
} else if (c === "/" && next === "*") {
|
|
890
|
+
const end = text.indexOf("*/", i + 2);
|
|
891
|
+
i = end < 0 ? text.length : end + 2;
|
|
892
|
+
out += " ";
|
|
893
|
+
} else if (c === "'" || c === '"' || c === "`") {
|
|
894
|
+
const j = skipString(text, i);
|
|
895
|
+
out += text.slice(i, j);
|
|
896
|
+
i = j;
|
|
897
|
+
prev = c;
|
|
898
|
+
} else if (c === "/" && (prev === "" || "(,=:[!&|?{};".includes(prev) || /(?:^|[^\w$])(?:return|typeof|case|in|of|void)$/.test(out.trimEnd()))) {
|
|
899
|
+
let j = i + 1;
|
|
900
|
+
let inClass = false;
|
|
901
|
+
while (j < text.length && text[j] !== `
|
|
902
|
+
`) {
|
|
903
|
+
const d = text[j] ?? "";
|
|
904
|
+
if (d === "\\")
|
|
905
|
+
j++;
|
|
906
|
+
else if (d === "[")
|
|
907
|
+
inClass = true;
|
|
908
|
+
else if (d === "]")
|
|
909
|
+
inClass = false;
|
|
910
|
+
else if (d === "/" && !inClass)
|
|
911
|
+
break;
|
|
912
|
+
j++;
|
|
913
|
+
}
|
|
914
|
+
out += text.slice(i, j + 1);
|
|
915
|
+
i = j + 1;
|
|
916
|
+
prev = "/";
|
|
917
|
+
} else {
|
|
918
|
+
out += c;
|
|
919
|
+
if (c.trim() !== "")
|
|
920
|
+
prev = c;
|
|
921
|
+
i++;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
return out;
|
|
925
|
+
}
|
|
926
|
+
function codeOf(text) {
|
|
927
|
+
return stripComments(text).replace(/\s+/g, " ").trim();
|
|
928
|
+
}
|
|
929
|
+
function statementsOf(text) {
|
|
930
|
+
const out = [];
|
|
931
|
+
let start = 0;
|
|
932
|
+
let depth = 0;
|
|
933
|
+
let i = 0;
|
|
934
|
+
const push = (end) => {
|
|
935
|
+
const s = text.slice(start, end).trim();
|
|
936
|
+
if (s !== "")
|
|
937
|
+
out.push(s);
|
|
938
|
+
start = end;
|
|
939
|
+
};
|
|
940
|
+
while (i < text.length) {
|
|
941
|
+
const c = text[i] ?? "";
|
|
942
|
+
if (c === "'" || c === '"' || c === "`") {
|
|
943
|
+
i = skipString(text, i);
|
|
944
|
+
} else if (c === "/" && text[i + 1] === "/") {
|
|
945
|
+
while (i < text.length && text[i] !== `
|
|
946
|
+
`)
|
|
947
|
+
i++;
|
|
948
|
+
} else if (c === "/" && text[i + 1] === "*") {
|
|
949
|
+
const end = text.indexOf("*/", i + 2);
|
|
950
|
+
i = end < 0 ? text.length : end + 2;
|
|
951
|
+
} else if ("{([".includes(c)) {
|
|
952
|
+
depth++;
|
|
953
|
+
i++;
|
|
954
|
+
} else if (")}]".includes(c)) {
|
|
955
|
+
depth--;
|
|
956
|
+
i++;
|
|
957
|
+
if (depth === 0 && c === "}" && BLOCK.test(text.slice(start, i).trimStart())) {
|
|
958
|
+
WORD.lastIndex = text.length - text.slice(i).trimStart().length;
|
|
959
|
+
const upcoming = WORD.exec(text)?.[0];
|
|
960
|
+
const rest = text.slice(i).trimStart();
|
|
961
|
+
if (rest === "" || rest.startsWith(";") || upcoming !== undefined && STARTERS.has(upcoming)) {
|
|
962
|
+
if (rest.startsWith(";"))
|
|
963
|
+
i = text.length - rest.length + 1;
|
|
964
|
+
push(i);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
} else if (c === ";" && depth === 0) {
|
|
968
|
+
i++;
|
|
969
|
+
push(i);
|
|
970
|
+
} else
|
|
971
|
+
i++;
|
|
972
|
+
}
|
|
973
|
+
push(text.length);
|
|
974
|
+
return out;
|
|
975
|
+
}
|
|
976
|
+
var DECLARED = /^export\s+(?:declare\s+)?(?:default\s+)?(?:abstract\s+)?(?:async\s+)?(?:function\*?|class|interface|type|const|let|var|enum|namespace|module)\s+([A-Za-z_$][\w$]*)/;
|
|
977
|
+
function exportedNames(statement) {
|
|
978
|
+
const s = statement.trimStart();
|
|
979
|
+
if (!s.startsWith("export"))
|
|
980
|
+
return [];
|
|
981
|
+
const declared = DECLARED.exec(s);
|
|
982
|
+
if (declared?.[1] !== undefined)
|
|
983
|
+
return [declared[1]];
|
|
984
|
+
if (/^export\s+default\b/.test(s))
|
|
985
|
+
return ["default"];
|
|
986
|
+
const star = /^export\s+\*\s+(?:as\s+([A-Za-z_$][\w$]*)\s+)?from\b/.exec(s);
|
|
987
|
+
if (star !== null)
|
|
988
|
+
return [star[1] ?? "*"];
|
|
989
|
+
const list = /^export\s+(?:type\s+)?\{([^}]*)\}/.exec(s);
|
|
990
|
+
if (list?.[1] !== undefined)
|
|
991
|
+
return list[1].split(",").map((item) => item.trim().replace(/^type\s+/, "")).filter((item) => item !== "").map((item) => item.split(/\s+as\s+/).pop() ?? item);
|
|
992
|
+
return [];
|
|
993
|
+
}
|
|
994
|
+
function declarationsOf(file, text) {
|
|
995
|
+
const statements = statementsOf(text).map((s) => s.replace(/\s+/g, " "));
|
|
996
|
+
const local = statements.filter((s) => exportedNames(s).length === 0 && s !== "export {};").join(`
|
|
997
|
+
`);
|
|
998
|
+
return statements.flatMap((s) => exportedNames(s).map((name) => ({ file, name, text: `${s}
|
|
999
|
+
${local}` })));
|
|
1000
|
+
}
|
|
1001
|
+
function fingerprintOf(declarations, hash) {
|
|
1002
|
+
const byName = new Map;
|
|
1003
|
+
for (const d of declarations)
|
|
1004
|
+
byName.set(d.name, [...byName.get(d.name) ?? [], hash(d.text)]);
|
|
1005
|
+
return new Map([...byName].sort(([a], [b]) => a < b ? -1 : 1).map(([name, hashes]) => [name, [...hashes].sort().join(",")]));
|
|
1006
|
+
}
|
|
1007
|
+
function surfaceDelta(base, now) {
|
|
1008
|
+
const changed = [...new Set([...base.keys(), ...now.keys()])].filter((n) => base.get(n) !== now.get(n)).sort();
|
|
1009
|
+
return changed.length === 0 ? { kind: "same" } : { kind: "changed", symbols: changed };
|
|
1010
|
+
}
|
|
1011
|
+
function mentionsOf(declarations) {
|
|
1012
|
+
const byName = new Map;
|
|
1013
|
+
for (const d of declarations) {
|
|
1014
|
+
const set = byName.get(d.name) ?? new Set;
|
|
1015
|
+
for (const w of d.text.match(/[A-Za-z_$][\w$]*/g) ?? [])
|
|
1016
|
+
set.add(w);
|
|
1017
|
+
byName.set(d.name, set);
|
|
1018
|
+
}
|
|
1019
|
+
return [...byName].sort(([a], [b]) => a < b ? -1 : 1).map(([name, set]) => ({ name, mentions: [...set].sort() }));
|
|
1020
|
+
}
|
|
1021
|
+
var IMPORT_FROM = /\b(?:import|export)\s+(?:type\s+)?([^'";]*?)\s*from\s*["']([^"']+)["']/g;
|
|
1022
|
+
var SIDE_EFFECT = /\bimport\s*["']([^"']+)["']/g;
|
|
1023
|
+
var DYNAMIC = /\bimport\(\s*["']([^"']+)["']\s*\)/g;
|
|
1024
|
+
function packageOf(specifier) {
|
|
1025
|
+
if (specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("node:"))
|
|
1026
|
+
return;
|
|
1027
|
+
const parts = specifier.split("/");
|
|
1028
|
+
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
1029
|
+
}
|
|
1030
|
+
function usagesOf(text) {
|
|
1031
|
+
const code = stripComments(text);
|
|
1032
|
+
const found = new Map;
|
|
1033
|
+
const entry = (specifier) => {
|
|
1034
|
+
const pkg = packageOf(specifier);
|
|
1035
|
+
if (pkg === undefined)
|
|
1036
|
+
return;
|
|
1037
|
+
const e = found.get(pkg) ?? { all: false, names: new Set };
|
|
1038
|
+
found.set(pkg, e);
|
|
1039
|
+
return e;
|
|
1040
|
+
};
|
|
1041
|
+
for (const m of code.matchAll(IMPORT_FROM)) {
|
|
1042
|
+
const e = m[2] === undefined ? undefined : entry(m[2]);
|
|
1043
|
+
if (e === undefined)
|
|
1044
|
+
continue;
|
|
1045
|
+
const clause = m[1] ?? "";
|
|
1046
|
+
if (clause.includes("*"))
|
|
1047
|
+
e.all = true;
|
|
1048
|
+
const braces = /\{([^}]*)\}/.exec(clause);
|
|
1049
|
+
const outside = clause.replace(/\{[^}]*\}/, "").replace(/^type\s+/, "").replace(/,/g, " ").trim();
|
|
1050
|
+
if (outside !== "" && !outside.includes("*"))
|
|
1051
|
+
e.names.add("default");
|
|
1052
|
+
for (const item of (braces?.[1] ?? "").split(",")) {
|
|
1053
|
+
const original = item.trim().replace(/^type\s+/, "").split(/\s+as\s+/)[0]?.trim() ?? "";
|
|
1054
|
+
if (original !== "")
|
|
1055
|
+
e.names.add(original);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
for (const m of code.matchAll(SIDE_EFFECT)) {
|
|
1059
|
+
const e = m[1] === undefined ? undefined : entry(m[1]);
|
|
1060
|
+
if (e !== undefined)
|
|
1061
|
+
e.all = true;
|
|
1062
|
+
}
|
|
1063
|
+
for (const m of code.matchAll(DYNAMIC)) {
|
|
1064
|
+
const e = m[1] === undefined ? undefined : entry(m[1]);
|
|
1065
|
+
if (e !== undefined)
|
|
1066
|
+
e.all = true;
|
|
1067
|
+
}
|
|
1068
|
+
return new Map([...found].map(([pkg, e]) => [pkg, { all: e.all, names: [...e.names].sort() }]));
|
|
1069
|
+
}
|
|
1070
|
+
function importsOf(text, pkg) {
|
|
1071
|
+
return usagesOf(text).get(pkg) ?? { all: false, names: [] };
|
|
1072
|
+
}
|
|
1073
|
+
function joinUsage(a, b) {
|
|
1074
|
+
return { all: a.all || b.all, names: [...new Set([...a.names, ...b.names])].sort() };
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
// src/logical/prove.ts
|
|
1078
|
+
var LIBRARY_FILE = /^commons\/([a-z][a-z0-9-]*)\//;
|
|
1079
|
+
var CODE = /\.(?:ts|mts|mjs|js)$/;
|
|
1080
|
+
var specLines = (text) => text.split(`
|
|
1081
|
+
`).filter((l) => /\bSpec:\s/.test(l)).join(`
|
|
1082
|
+
`);
|
|
1083
|
+
var requirementIds = (text) => [...new Set(text.match(/\*\*FR-\d+\*\*/g) ?? [])].sort().join(",");
|
|
1084
|
+
function jsonWithout(text, key) {
|
|
1085
|
+
if (text === undefined)
|
|
1086
|
+
return;
|
|
1087
|
+
try {
|
|
1088
|
+
const x = JSON.parse(text);
|
|
1089
|
+
if (typeof x !== "object" || x === null || Array.isArray(x))
|
|
1090
|
+
return text;
|
|
1091
|
+
return JSON.stringify(Object.fromEntries(Object.entries(x).filter(([k]) => k !== key)));
|
|
1092
|
+
} catch {
|
|
1093
|
+
return text;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
var withoutVersion = (text) => text?.replace(/\bversion\s*[:=]\s*["'][^"']*["']/g, "version").replace(/\b[A-Z_]*VERSION\s*=\s*["'][^"']*["']/g, "VERSION");
|
|
1097
|
+
function classifyFile(change, libraryOf) {
|
|
1098
|
+
const { path, before, after } = change;
|
|
1099
|
+
const library = libraryOf(path);
|
|
1100
|
+
const is = (cls) => ({ path, class: cls, library });
|
|
1101
|
+
const base = path.split("/").pop() ?? path;
|
|
1102
|
+
if (PLANNER_GLOBS.some((g) => matches(g, path)))
|
|
1103
|
+
return is("planner");
|
|
1104
|
+
if (path.endsWith("pack-library.ts"))
|
|
1105
|
+
return is("packaging");
|
|
1106
|
+
if (path === "commons/generated/release.auto.json")
|
|
1107
|
+
return is("version");
|
|
1108
|
+
if (path.startsWith("commons/generated/") || /\.auto\.[a-z]+$/.test(base) || base === "LICENSE" || base === "THIRD_PARTY_NOTICES.md" || /^\.github\/workflows\/.*\.auto\.yml$/.test(path))
|
|
1109
|
+
return is("generated");
|
|
1110
|
+
if (base === "package.json") {
|
|
1111
|
+
if (before === undefined || after === undefined)
|
|
1112
|
+
return is("packaging");
|
|
1113
|
+
return jsonWithout(before, "version") === jsonWithout(after, "version") ? is("version") : is("packaging");
|
|
1114
|
+
}
|
|
1115
|
+
if (base === "library.ts" || base === "release.ts") {
|
|
1116
|
+
if (before === undefined || after === undefined)
|
|
1117
|
+
return is("packaging");
|
|
1118
|
+
return withoutVersion(before) === withoutVersion(after) ? is("version") : is("packaging");
|
|
1119
|
+
}
|
|
1120
|
+
if (path.includes("/spec-kit/") || path.startsWith("spec-kit/")) {
|
|
1121
|
+
if (path.endsWith("spec.md"))
|
|
1122
|
+
return requirementIds(before ?? "") === requirementIds(after ?? "") ? is("spec") : is("spec-requirements");
|
|
1123
|
+
return is("spec");
|
|
1124
|
+
}
|
|
1125
|
+
if (/\.(?:md|html|txt)$/.test(base))
|
|
1126
|
+
return is("prose");
|
|
1127
|
+
if (CODE.test(base)) {
|
|
1128
|
+
if (before !== undefined && after !== undefined && codeOf(before) === codeOf(after))
|
|
1129
|
+
return specLines(before) === specLines(after) ? is("prose") : is("spec");
|
|
1130
|
+
if (library === undefined)
|
|
1131
|
+
return is("outside");
|
|
1132
|
+
return base.endsWith(".test.ts") || path.includes("/suite/") ? is("test") : is("source");
|
|
1133
|
+
}
|
|
1134
|
+
return library === undefined ? is("outside") : is("source");
|
|
1135
|
+
}
|
|
1136
|
+
function classesOf(files) {
|
|
1137
|
+
return CHANGE_CLASSES.filter((c) => files.some((f) => f.class === c));
|
|
1138
|
+
}
|
|
1139
|
+
function libraryOfPath(libraries) {
|
|
1140
|
+
return (path) => {
|
|
1141
|
+
const m = LIBRARY_FILE.exec(path);
|
|
1142
|
+
return m === null ? undefined : libraries.find((l) => l.folder === `commons/${m[1] ?? ""}`)?.name;
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
var planned = (proof, why) => ({ proof, tier: tierOfProof(proof), why });
|
|
1146
|
+
function everything(libraries, why) {
|
|
1147
|
+
const proofs = [{ kind: "docs-check" }, { kind: "spec-check", scope: "repository" }, { kind: "sync-check" }, { kind: "versions-check" }, { kind: "end-to-end" }, { kind: "release-gate" }];
|
|
1148
|
+
for (const l of libraries) {
|
|
1149
|
+
proofs.push({ kind: "types", library: l.name }, { kind: "trace-check", library: l.name }, { kind: "suite", library: l.name }, { kind: "pack", library: l.name });
|
|
1150
|
+
if (l.foundation)
|
|
1151
|
+
proofs.push({ kind: "smoke", library: l.name });
|
|
1152
|
+
for (const system of l.systems)
|
|
1153
|
+
proofs.push({ kind: "platform", library: l.name, system });
|
|
1154
|
+
for (const u of l.uses)
|
|
1155
|
+
proofs.push({ kind: "seam", provider: u.provider, consumer: l.name });
|
|
1156
|
+
}
|
|
1157
|
+
return proofs.map((p) => planned(p, why));
|
|
1158
|
+
}
|
|
1159
|
+
var listOf = (xs, n = 6) => xs.length <= n ? xs.join(", ") : `${xs.slice(0, n).join(", ")} and ${xs.length - n} more`;
|
|
1160
|
+
function whySentence(w) {
|
|
1161
|
+
switch (w.kind) {
|
|
1162
|
+
case "class":
|
|
1163
|
+
return `${w.files} ${w.files === 1 ? "file is" : "files are"} ${w.class}: ${CLASS_RULES[w.class].means}`;
|
|
1164
|
+
case "surface":
|
|
1165
|
+
return `the public surface of ${w.provider} changed in ${listOf(w.symbols)}, which this library imports`;
|
|
1166
|
+
case "surface-unknown":
|
|
1167
|
+
return `the public surface of ${w.provider} cannot be compared (${w.why}), so every importer is reached`;
|
|
1168
|
+
case "foundation":
|
|
1169
|
+
return `${w.library} is a foundation library: the smoke gate of the foundation (the suites of core, formats, crypto, system, terminal, kanon and libraries) runs before anything wider`;
|
|
1170
|
+
case "everything":
|
|
1171
|
+
return w.because;
|
|
1172
|
+
default:
|
|
1173
|
+
return absurd(w);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
function skipSentence(s) {
|
|
1177
|
+
return `${s.subject}: ${s.because}`;
|
|
1178
|
+
}
|
|
1179
|
+
function proofLabel(p) {
|
|
1180
|
+
switch (p.kind) {
|
|
1181
|
+
case "docs-check":
|
|
1182
|
+
return "documentation check";
|
|
1183
|
+
case "spec-check":
|
|
1184
|
+
return `specification check (${p.scope})`;
|
|
1185
|
+
case "trace-check":
|
|
1186
|
+
return `trace check of ${p.library}`;
|
|
1187
|
+
case "types":
|
|
1188
|
+
return `types of ${p.library}`;
|
|
1189
|
+
case "sync-check":
|
|
1190
|
+
return "sync --check";
|
|
1191
|
+
case "versions-check":
|
|
1192
|
+
return "versions check";
|
|
1193
|
+
case "suite":
|
|
1194
|
+
return `suite of ${p.library}`;
|
|
1195
|
+
case "smoke":
|
|
1196
|
+
return `smoke gate of ${p.library}`;
|
|
1197
|
+
case "seam":
|
|
1198
|
+
return `seam ${p.provider} to ${p.consumer}`;
|
|
1199
|
+
case "pack":
|
|
1200
|
+
return `tarball of ${p.library}`;
|
|
1201
|
+
case "end-to-end":
|
|
1202
|
+
return "end-to-end flows";
|
|
1203
|
+
case "platform":
|
|
1204
|
+
return `${p.library} on ${p.system}`;
|
|
1205
|
+
case "release-gate":
|
|
1206
|
+
return "release gate";
|
|
1207
|
+
default:
|
|
1208
|
+
return absurd(p);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
function planProof(input) {
|
|
1212
|
+
const libs = new Map(input.libraries.map((l) => [l.name, l]));
|
|
1213
|
+
const total = input.libraries.length;
|
|
1214
|
+
const files = input.changed.map((c) => classifyFile(c, libraryOfPath(input.libraries)));
|
|
1215
|
+
const classes = classesOf(files);
|
|
1216
|
+
const finish = (proofs, skipped) => {
|
|
1217
|
+
const byKey = new Map;
|
|
1218
|
+
for (const p of proofs)
|
|
1219
|
+
if (!byKey.has(proofKey(p.proof)))
|
|
1220
|
+
byKey.set(proofKey(p.proof), p);
|
|
1221
|
+
const ordered = [...byKey.values()].sort((a, b) => PROOF_TIER_IDS.indexOf(a.tier) - PROOF_TIER_IDS.indexOf(b.tier) || (proofKey(a.proof) < proofKey(b.proof) ? -1 : 1));
|
|
1222
|
+
const proven = [...new Set(ordered.flatMap((p) => ("library" in p.proof) ? [p.proof.library] : ("consumer" in p.proof) ? [p.proof.consumer] : []))].sort();
|
|
1223
|
+
const tierSkips = PROOF_TIER_IDS.filter((t) => !ordered.some((p) => p.tier === t)).map((t) => t === "T4" || t === "T5" || t === "T6" ? { tier: t, subject: PROOF_TIERS[t].name, reason: "tier-scheduled", because: `it runs on ${PROOF_TIERS[t].runsOn.filter((o) => o !== "edit" && o !== "push").join(", ")}, and this change reaches none of what it proves` } : { tier: t, subject: PROOF_TIERS[t].name, reason: "class-needs-none", because: `no class of this change needs it (${classes.map((c) => c).join(", ") || "no change"})` });
|
|
1224
|
+
const plan = { base: input.base, files, classes, proofs: ordered, skipped: [...skipped, ...tierSkips], libraries: { total, proven } };
|
|
1225
|
+
return { kind: "plan", plan };
|
|
1226
|
+
};
|
|
1227
|
+
if (input.all)
|
|
1228
|
+
return finish(everything(input.libraries, { kind: "everything", because: "--all plans every proof of every tier" }), []);
|
|
1229
|
+
if (!input.gitKnown)
|
|
1230
|
+
return finish(everything(input.libraries, { kind: "everything", because: "Git cannot say what changed, so nothing can be shown safe to skip" }), []);
|
|
1231
|
+
const planner = files.find((f) => f.class === "planner");
|
|
1232
|
+
if (planner !== undefined)
|
|
1233
|
+
return finish(everything(input.libraries, { kind: "everything", because: `${planner.path} is the planner, a generator or a tier rule: nothing it decides can be shown safe to skip` }), []);
|
|
1234
|
+
const proofs = [];
|
|
1235
|
+
const skipped = [];
|
|
1236
|
+
const add = (proof, why) => {
|
|
1237
|
+
proofs.push(planned(proof, why));
|
|
1238
|
+
};
|
|
1239
|
+
const sourceLibs = new Set;
|
|
1240
|
+
for (const f of files) {
|
|
1241
|
+
const why = { kind: "class", class: f.class, files: files.filter((x) => x.class === f.class).length };
|
|
1242
|
+
const lib = f.library;
|
|
1243
|
+
switch (f.class) {
|
|
1244
|
+
case "prose":
|
|
1245
|
+
add({ kind: "docs-check" }, why);
|
|
1246
|
+
break;
|
|
1247
|
+
case "spec":
|
|
1248
|
+
add({ kind: "spec-check", scope: lib ?? "repository" }, why);
|
|
1249
|
+
if (lib !== undefined)
|
|
1250
|
+
add({ kind: "trace-check", library: lib }, why);
|
|
1251
|
+
break;
|
|
1252
|
+
case "spec-requirements":
|
|
1253
|
+
add({ kind: "spec-check", scope: lib ?? "repository" }, why);
|
|
1254
|
+
if (lib !== undefined)
|
|
1255
|
+
add({ kind: "trace-check", library: lib }, why);
|
|
1256
|
+
if (lib !== undefined)
|
|
1257
|
+
add({ kind: "suite", library: lib }, why);
|
|
1258
|
+
break;
|
|
1259
|
+
case "generated":
|
|
1260
|
+
add({ kind: "sync-check" }, why);
|
|
1261
|
+
break;
|
|
1262
|
+
case "version":
|
|
1263
|
+
add({ kind: "versions-check" }, why);
|
|
1264
|
+
break;
|
|
1265
|
+
case "test":
|
|
1266
|
+
if (lib !== undefined) {
|
|
1267
|
+
add({ kind: "types", library: lib }, why);
|
|
1268
|
+
add({ kind: "trace-check", library: lib }, why);
|
|
1269
|
+
add({ kind: "suite", library: lib }, why);
|
|
1270
|
+
}
|
|
1271
|
+
break;
|
|
1272
|
+
case "source":
|
|
1273
|
+
if (lib !== undefined) {
|
|
1274
|
+
sourceLibs.add(lib);
|
|
1275
|
+
add({ kind: "types", library: lib }, why);
|
|
1276
|
+
add({ kind: "trace-check", library: lib }, why);
|
|
1277
|
+
add({ kind: "suite", library: lib }, why);
|
|
1278
|
+
}
|
|
1279
|
+
break;
|
|
1280
|
+
case "packaging":
|
|
1281
|
+
for (const l of lib === undefined ? input.libraries : input.libraries.filter((x) => x.name === lib))
|
|
1282
|
+
add({ kind: "pack", library: l.name }, why);
|
|
1283
|
+
break;
|
|
1284
|
+
case "planner":
|
|
1285
|
+
break;
|
|
1286
|
+
case "outside":
|
|
1287
|
+
add({ kind: "spec-check", scope: "repository" }, why);
|
|
1288
|
+
add({ kind: "end-to-end" }, why);
|
|
1289
|
+
for (const l of input.outsideReaders) {
|
|
1290
|
+
add({ kind: "types", library: l }, why);
|
|
1291
|
+
add({ kind: "suite", library: l }, why);
|
|
1292
|
+
}
|
|
1293
|
+
break;
|
|
1294
|
+
default:
|
|
1295
|
+
return absurd(f.class);
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
const need = [];
|
|
1299
|
+
const reached = new Map;
|
|
1300
|
+
const unseen = new Map;
|
|
1301
|
+
const leave = (provider, reason, changed, importer) => {
|
|
1302
|
+
const key = `${provider}:${reason}`;
|
|
1303
|
+
const group = unseen.get(key) ?? { provider, reason, changed, importers: [] };
|
|
1304
|
+
if (!group.importers.includes(importer))
|
|
1305
|
+
group.importers.push(importer);
|
|
1306
|
+
unseen.set(key, group);
|
|
1307
|
+
};
|
|
1308
|
+
const visit = (provider, changed, via) => {
|
|
1309
|
+
const importers = input.libraries.filter((l) => l.uses.some((u) => u.provider === provider));
|
|
1310
|
+
for (const x of importers) {
|
|
1311
|
+
const usage = x.uses.find((u) => u.provider === provider)?.usage;
|
|
1312
|
+
if (usage === undefined)
|
|
1313
|
+
continue;
|
|
1314
|
+
if (changed !== "all" && changed.size === 0) {
|
|
1315
|
+
leave(provider, "surface-unchanged", [], x.name);
|
|
1316
|
+
continue;
|
|
1317
|
+
}
|
|
1318
|
+
const hit = changed === "all" || usage.all || usage.names.some((n) => changed.has(n));
|
|
1319
|
+
if (!hit) {
|
|
1320
|
+
leave(provider, "symbols-unused", [...changed].sort(), x.name);
|
|
1321
|
+
continue;
|
|
1322
|
+
}
|
|
1323
|
+
const key = `${provider}>${x.name}`;
|
|
1324
|
+
if (reached.has(key))
|
|
1325
|
+
continue;
|
|
1326
|
+
reached.set(key, { changed, via });
|
|
1327
|
+
add({ kind: "types", library: x.name }, via);
|
|
1328
|
+
add({ kind: "seam", provider, consumer: x.name }, via);
|
|
1329
|
+
const surface = input.surfaces.get(x.name);
|
|
1330
|
+
if (surface === undefined) {
|
|
1331
|
+
if (!need.includes(x.name))
|
|
1332
|
+
need.push(x.name);
|
|
1333
|
+
continue;
|
|
1334
|
+
}
|
|
1335
|
+
const onward = changed === "all" ? "all" : new Set(surface.mentions.filter((m) => m.mentions.some((n) => changed.has(n))).map((m) => m.name));
|
|
1336
|
+
if (onward === "all" || onward.size > 0)
|
|
1337
|
+
visit(x.name, onward, { kind: "surface", provider: x.name, symbols: onward === "all" ? [] : [...onward].sort() });
|
|
1338
|
+
}
|
|
1339
|
+
};
|
|
1340
|
+
for (const name of [...sourceLibs].sort()) {
|
|
1341
|
+
const surface = input.surfaces.get(name);
|
|
1342
|
+
if (surface === undefined) {
|
|
1343
|
+
need.push(name);
|
|
1344
|
+
continue;
|
|
1345
|
+
}
|
|
1346
|
+
const node = libs.get(name);
|
|
1347
|
+
if (node?.foundation === true)
|
|
1348
|
+
for (const f of input.libraries.filter((l) => l.foundation))
|
|
1349
|
+
add({ kind: "smoke", library: f.name }, { kind: "foundation", library: name });
|
|
1350
|
+
const d = surface.delta;
|
|
1351
|
+
switch (d.kind) {
|
|
1352
|
+
case "same":
|
|
1353
|
+
visit(name, new Set, { kind: "surface", provider: name, symbols: [] });
|
|
1354
|
+
break;
|
|
1355
|
+
case "changed":
|
|
1356
|
+
visit(name, new Set(d.symbols), { kind: "surface", provider: name, symbols: d.symbols });
|
|
1357
|
+
break;
|
|
1358
|
+
case "unknown":
|
|
1359
|
+
visit(name, "all", { kind: "surface-unknown", provider: name, why: d.why });
|
|
1360
|
+
break;
|
|
1361
|
+
default:
|
|
1362
|
+
return absurd(d);
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
if (need.length > 0)
|
|
1366
|
+
return { kind: "needs", libraries: [...new Set(need)].sort() };
|
|
1367
|
+
for (const g of [...unseen.values()].sort((a, b) => a.provider + a.reason < b.provider + b.reason ? -1 : 1)) {
|
|
1368
|
+
const stillReached = (name) => reached.has(`${g.provider}>${name}`);
|
|
1369
|
+
const importers = g.importers.filter((n) => !stillReached(n)).sort();
|
|
1370
|
+
if (importers.length === 0)
|
|
1371
|
+
continue;
|
|
1372
|
+
const subject = `seam ${g.provider} to ${listOf(importers, 4)}`;
|
|
1373
|
+
skipped.push(g.reason === "surface-unchanged" ? { tier: "T2", subject, reason: g.reason, because: `the public surface of ${g.provider} is the same as at ${input.base}, so its ${importers.length} importers cannot see the change` } : { tier: "T2", subject, reason: g.reason, because: `${importers.length === 1 ? "it imports" : `these ${importers.length} importers import`} other symbols of ${g.provider} than ${listOf(g.changed, 4)}` });
|
|
1374
|
+
}
|
|
1375
|
+
for (const name of sourceLibs) {
|
|
1376
|
+
const node = libs.get(name);
|
|
1377
|
+
for (const system of node?.systems ?? [])
|
|
1378
|
+
skipped.push({ tier: "T5", subject: `${name} on ${system}`, reason: "tier-scheduled", because: "platform proofs run on main and nightly" });
|
|
1379
|
+
}
|
|
1380
|
+
return finish(proofs, skipped);
|
|
1381
|
+
}
|
|
1382
|
+
// ../headless/src/logical/outcome.ts
|
|
1383
|
+
function outcomeOf(data, fields = {}) {
|
|
1384
|
+
return {
|
|
1385
|
+
data,
|
|
1386
|
+
text: fields.text,
|
|
1387
|
+
problems: fields.problems ?? [],
|
|
1388
|
+
outcomes: fields.outcomes ?? [],
|
|
1389
|
+
hints: fields.hints ?? [],
|
|
1390
|
+
next: fields.next ?? [],
|
|
1391
|
+
findings: fields.findings ?? [],
|
|
1392
|
+
title: fields.title,
|
|
1393
|
+
cancelled: fields.cancelled ?? false,
|
|
1394
|
+
exit: fields.exit
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
var NOTHING = outcomeOf(null);
|
|
1398
|
+
|
|
1399
|
+
// ../headless/src/logical/nested.ts
|
|
1400
|
+
var problemDecoder = object({ level: literal("fail", "warn", "pending", "action"), message: string }, { phase: string, fix: string, code: string, raw: string, logLine: integer });
|
|
1401
|
+
var summaryDecoder = object({
|
|
1402
|
+
fails: integer,
|
|
1403
|
+
warns: integer,
|
|
1404
|
+
pending: integer,
|
|
1405
|
+
actions: integer,
|
|
1406
|
+
problems: array(problemDecoder),
|
|
1407
|
+
outcomes: array(string)
|
|
1408
|
+
});
|
|
1409
|
+
|
|
1410
|
+
// ../headless/src/logical/compose.ts
|
|
1411
|
+
var WORD2 = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
1412
|
+
var idDecoder = refine(string, "plugin id", (t) => WORD2.test(t));
|
|
1413
|
+
// ../headless/src/logical/credentials.ts
|
|
1414
|
+
var idDecoder2 = refine(string, "credential id", (t) => t.length > 0 && t.length <= 200 && !/[\u0000-\u001f\u007f]/.test(t));
|
|
1415
|
+
// ../headless/src/logical/envelope.ts
|
|
1416
|
+
var ENVELOPE_SCHEMA = "headless.envelope/1";
|
|
1417
|
+
// ../headless/src/logical/machine.ts
|
|
1418
|
+
var REACH = defineReach({ channels: ["local", "ssh", "mcp", "rest"], readOnly: true, idempotent: true });
|
|
1419
|
+
// ../headless/src/logical/sha256.ts
|
|
1420
|
+
var K = [
|
|
1421
|
+
1116352408,
|
|
1422
|
+
1899447441,
|
|
1423
|
+
3049323471,
|
|
1424
|
+
3921009573,
|
|
1425
|
+
961987163,
|
|
1426
|
+
1508970993,
|
|
1427
|
+
2453635748,
|
|
1428
|
+
2870763221,
|
|
1429
|
+
3624381080,
|
|
1430
|
+
310598401,
|
|
1431
|
+
607225278,
|
|
1432
|
+
1426881987,
|
|
1433
|
+
1925078388,
|
|
1434
|
+
2162078206,
|
|
1435
|
+
2614888103,
|
|
1436
|
+
3248222580,
|
|
1437
|
+
3835390401,
|
|
1438
|
+
4022224774,
|
|
1439
|
+
264347078,
|
|
1440
|
+
604807628,
|
|
1441
|
+
770255983,
|
|
1442
|
+
1249150122,
|
|
1443
|
+
1555081692,
|
|
1444
|
+
1996064986,
|
|
1445
|
+
2554220882,
|
|
1446
|
+
2821834349,
|
|
1447
|
+
2952996808,
|
|
1448
|
+
3210313671,
|
|
1449
|
+
3336571891,
|
|
1450
|
+
3584528711,
|
|
1451
|
+
113926993,
|
|
1452
|
+
338241895,
|
|
1453
|
+
666307205,
|
|
1454
|
+
773529912,
|
|
1455
|
+
1294757372,
|
|
1456
|
+
1396182291,
|
|
1457
|
+
1695183700,
|
|
1458
|
+
1986661051,
|
|
1459
|
+
2177026350,
|
|
1460
|
+
2456956037,
|
|
1461
|
+
2730485921,
|
|
1462
|
+
2820302411,
|
|
1463
|
+
3259730800,
|
|
1464
|
+
3345764771,
|
|
1465
|
+
3516065817,
|
|
1466
|
+
3600352804,
|
|
1467
|
+
4094571909,
|
|
1468
|
+
275423344,
|
|
1469
|
+
430227734,
|
|
1470
|
+
506948616,
|
|
1471
|
+
659060556,
|
|
1472
|
+
883997877,
|
|
1473
|
+
958139571,
|
|
1474
|
+
1322822218,
|
|
1475
|
+
1537002063,
|
|
1476
|
+
1747873779,
|
|
1477
|
+
1955562222,
|
|
1478
|
+
2024104815,
|
|
1479
|
+
2227730452,
|
|
1480
|
+
2361852424,
|
|
1481
|
+
2428436474,
|
|
1482
|
+
2756734187,
|
|
1483
|
+
3204031479,
|
|
1484
|
+
3329325298
|
|
1485
|
+
];
|
|
1486
|
+
var rotr = (x, n) => x >>> n | x << 32 - n;
|
|
1487
|
+
function padded(bytes) {
|
|
1488
|
+
const total = Math.ceil((bytes.length + 9) / 64) * 64;
|
|
1489
|
+
const out = new Uint8Array(total);
|
|
1490
|
+
out.set(bytes);
|
|
1491
|
+
out[bytes.length] = 128;
|
|
1492
|
+
const view = new DataView(out.buffer);
|
|
1493
|
+
view.setUint32(total - 8, Math.floor(bytes.length * 8 / 4294967296));
|
|
1494
|
+
view.setUint32(total - 4, bytes.length * 8 >>> 0);
|
|
1495
|
+
return out;
|
|
1496
|
+
}
|
|
1497
|
+
function sha256(bytes) {
|
|
1498
|
+
const h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225];
|
|
1499
|
+
const message = padded(bytes);
|
|
1500
|
+
const view = new DataView(message.buffer);
|
|
1501
|
+
const w = new Array(64).fill(0);
|
|
1502
|
+
for (let block = 0;block < message.length; block += 64) {
|
|
1503
|
+
for (let i = 0;i < 16; i += 1)
|
|
1504
|
+
w[i] = view.getUint32(block + i * 4);
|
|
1505
|
+
for (let i = 16;i < 64; i += 1) {
|
|
1506
|
+
const a = w[i - 15] ?? 0;
|
|
1507
|
+
const b = w[i - 2] ?? 0;
|
|
1508
|
+
const s0 = rotr(a, 7) ^ rotr(a, 18) ^ a >>> 3;
|
|
1509
|
+
const s1 = rotr(b, 17) ^ rotr(b, 19) ^ b >>> 10;
|
|
1510
|
+
w[i] = (w[i - 16] ?? 0) + s0 + (w[i - 7] ?? 0) + s1 >>> 0;
|
|
1511
|
+
}
|
|
1512
|
+
let [a, b, c, d, e, f, g, hh] = h;
|
|
1513
|
+
for (let i = 0;i < 64; i += 1) {
|
|
1514
|
+
const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
1515
|
+
const ch = e & f ^ ~e & g;
|
|
1516
|
+
const t1 = hh + s1 + ch + (K[i] ?? 0) + (w[i] ?? 0) >>> 0;
|
|
1517
|
+
const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
1518
|
+
const maj = a & b ^ a & c ^ b & c;
|
|
1519
|
+
const t2 = s0 + maj >>> 0;
|
|
1520
|
+
hh = g;
|
|
1521
|
+
g = f;
|
|
1522
|
+
f = e;
|
|
1523
|
+
e = d + t1 >>> 0;
|
|
1524
|
+
d = c;
|
|
1525
|
+
c = b;
|
|
1526
|
+
b = a;
|
|
1527
|
+
a = t1 + t2 >>> 0;
|
|
1528
|
+
}
|
|
1529
|
+
const next = [a, b, c, d, e, f, g, hh];
|
|
1530
|
+
for (let i = 0;i < 8; i += 1)
|
|
1531
|
+
h[i] = (h[i] ?? 0) + (next[i] ?? 0) >>> 0;
|
|
1532
|
+
}
|
|
1533
|
+
const out = new Uint8Array(32);
|
|
1534
|
+
const o = new DataView(out.buffer);
|
|
1535
|
+
for (let i = 0;i < 8; i += 1)
|
|
1536
|
+
o.setUint32(i * 4, h[i] ?? 0);
|
|
1537
|
+
return out;
|
|
1538
|
+
}
|
|
1539
|
+
function sha256Hex(text) {
|
|
1540
|
+
return [...sha256(new TextEncoder().encode(text))].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
// ../headless/src/logical/plan.ts
|
|
1544
|
+
var stepDecoder = refine(string, "step id", (t) => /^[a-z0-9][a-z0-9._:-]{0,99}$/.test(t));
|
|
1545
|
+
var hashDecoder = refine(string, "plan hash", (t) => /^sha256:[0-9a-f]{64}$/.test(t));
|
|
1546
|
+
// ../headless/src/logical/remote.ts
|
|
1547
|
+
var ENVELOPE = object({
|
|
1548
|
+
schema: literal(ENVELOPE_SCHEMA),
|
|
1549
|
+
exit: object({ code: integer, name: string }),
|
|
1550
|
+
problems: array(problemDecoder),
|
|
1551
|
+
outcomes: array(string),
|
|
1552
|
+
hints: array(object({ id: string, message: string }, { command: string })),
|
|
1553
|
+
next: array(string),
|
|
1554
|
+
data: unknownValue
|
|
1555
|
+
});
|
|
1556
|
+
// src/logical/publish.ts
|
|
1557
|
+
function tarballPath(repo, e) {
|
|
1558
|
+
return `${repo}/${e.folder}/dist/${e.package.replace(/^@/, "").replace("/", "-")}-${e.version}.tgz`;
|
|
1559
|
+
}
|
|
1560
|
+
function confirmationPhrase(entries) {
|
|
1561
|
+
const sent = entries.filter((e) => e.publish).map((e) => `${e.slug}@${e.version}`);
|
|
1562
|
+
return `publish ${sent.length} ${sha256Hex(sent.join(`
|
|
1563
|
+
`)).slice(0, 8)}`;
|
|
1564
|
+
}
|
|
1565
|
+
async function planPublish(w, entries, tagged) {
|
|
1566
|
+
const todo = entries.filter((e) => e.publish && !tagged.has(e.tag));
|
|
1567
|
+
const items = [];
|
|
1568
|
+
for (const entry of todo) {
|
|
1569
|
+
const seen = await w.registry.view(entry.package);
|
|
1570
|
+
if (seen.kind === "err") {
|
|
1571
|
+
items.push({ kind: "unknown", entry, why: seen.error });
|
|
1572
|
+
continue;
|
|
1573
|
+
}
|
|
1574
|
+
if (seen.value !== "absent" && seen.value.versions.includes(entry.version)) {
|
|
1575
|
+
items.push({ kind: "present", entry });
|
|
1576
|
+
continue;
|
|
1577
|
+
}
|
|
1578
|
+
const tarball = tarballPath(w.repo, entry);
|
|
1579
|
+
items.push(await w.files.exists(tarball) ? { kind: "ready", entry, tarball } : { kind: "no-tarball", entry, tarball });
|
|
1580
|
+
}
|
|
1581
|
+
return { items, phrase: confirmationPhrase(todo) };
|
|
1582
|
+
}
|
|
1583
|
+
function gate(input) {
|
|
1584
|
+
const out = [];
|
|
1585
|
+
if (input.token === undefined)
|
|
1586
|
+
out.push(finding("fail", "E-NO-TOKEN", "INFRO_NPMJS_TOKEN is not set, so nothing can be sent to npm by hand", "repoctl doctor"));
|
|
1587
|
+
if (input.typed !== input.phrase)
|
|
1588
|
+
out.push(finding("fail", "E-PUBLISH-REFUSED", `the confirmation is not the one the preview printed (${input.phrase})`, `repoctl release publish --yes --confirm "${input.phrase}"`));
|
|
1589
|
+
return out;
|
|
1590
|
+
}
|
|
1591
|
+
function npmrcText(token) {
|
|
1592
|
+
return `//registry.npmjs.org/:_authToken=${token.reveal()}
|
|
1593
|
+
`;
|
|
1594
|
+
}
|
|
1595
|
+
async function runPublish(w, plan, token) {
|
|
1596
|
+
const out = [];
|
|
1597
|
+
const scrub = (text) => redact(text, [token.reveal()]);
|
|
1598
|
+
const dir = await w.files.makeTemp("repoctl-npm-");
|
|
1599
|
+
try {
|
|
1600
|
+
const rc = `${dir}/npmrc`;
|
|
1601
|
+
await w.files.write(rc, npmrcText(token), 384);
|
|
1602
|
+
for (const item of plan.items) {
|
|
1603
|
+
switch (item.kind) {
|
|
1604
|
+
case "present":
|
|
1605
|
+
out.push({ kind: "present", entry: item.entry });
|
|
1606
|
+
break;
|
|
1607
|
+
case "unknown":
|
|
1608
|
+
out.push({ kind: "not-run", entry: item.entry, why: scrub(`npm could not be asked about it (${item.why})`) });
|
|
1609
|
+
break;
|
|
1610
|
+
case "no-tarball":
|
|
1611
|
+
out.push({ kind: "not-run", entry: item.entry, why: `its tarball ${item.tarball} is not there` });
|
|
1612
|
+
break;
|
|
1613
|
+
case "ready": {
|
|
1614
|
+
const ran = await w.process.run(["npm", "publish", item.tarball, "--access", "public", "--userconfig", rc], { cwd: w.repo });
|
|
1615
|
+
out.push(ran.code === 0 ? { kind: "published", entry: item.entry } : { kind: "failed", entry: item.entry, detail: tailLines(scrub(`${ran.stderr}
|
|
1616
|
+
${ran.stdout}`), 6) });
|
|
1617
|
+
break;
|
|
1618
|
+
}
|
|
1619
|
+
default:
|
|
1620
|
+
return out;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
} finally {
|
|
1624
|
+
await w.files.removeTree(dir);
|
|
1625
|
+
}
|
|
1626
|
+
return out;
|
|
1627
|
+
}
|
|
1628
|
+
function findingsOfPublish(done) {
|
|
1629
|
+
return done.flatMap((p) => {
|
|
1630
|
+
switch (p.kind) {
|
|
1631
|
+
case "published":
|
|
1632
|
+
case "present":
|
|
1633
|
+
return [];
|
|
1634
|
+
case "failed":
|
|
1635
|
+
return [finding("fail", "E-PUBLISH-FAILED", `${p.entry.slug} ${p.entry.version}: npm did not take it (${p.detail.join("; ")})`, "repoctl status")];
|
|
1636
|
+
case "not-run":
|
|
1637
|
+
return [finding("fail", p.why.includes("tarball") ? "E-NO-TARBALL" : "E-NPM-UNREACHABLE", `${p.entry.slug} ${p.entry.version}: ${p.why}`, p.why.includes("tarball") ? "repoctl release apply" : "repoctl status")];
|
|
1638
|
+
default:
|
|
1639
|
+
return [];
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
var STAGED_NOTE = "npm stages a version published by hand for about an hour: `repoctl status` lists it once npm shows it, and the release workflow makes the tags";
|
|
1644
|
+
// src/logical/docs.ts
|
|
1645
|
+
function docsArguments(ask, settings, repo, out) {
|
|
1646
|
+
const config = `${repo}/${settings.config}`;
|
|
1647
|
+
return ask === "build" ? ["build", "--out", out ?? `${repo}/${settings.out}`, "--config", config] : ["check", "--config", config];
|
|
1648
|
+
}
|
|
1649
|
+
function missingGenerator(why) {
|
|
1650
|
+
return finding("fail", "E-DOCS-GENERATOR-MISSING", `the documentation generator is not installed: ${why}`, "bun add --dev @intellectual-frontiers/docs");
|
|
1651
|
+
}
|
|
1652
|
+
function failedGenerator(ask, status) {
|
|
1653
|
+
return finding("fail", "E-DOCS-FAILED", `the documentation generator ended with ${status} while it ${ask === "check" ? "checked" : "built"} the site`, "repoctl docs check");
|
|
1654
|
+
}
|
|
1655
|
+
// src/logical/scaffold.ts
|
|
1656
|
+
var ROLES = ["foundation", "pattern", "program", "standard"];
|
|
1657
|
+
function acceptName(text, held, existing, folder) {
|
|
1658
|
+
const name = parseLibraryName(text);
|
|
1659
|
+
if (name.kind === "err")
|
|
1660
|
+
return err({ code: "E-LIBRARY-NAME", message: name.error });
|
|
1661
|
+
const taken = held.find((h) => h.match.kind === "exact" ? h.match.name === name.value : name.value.startsWith(h.match.prefix));
|
|
1662
|
+
if (taken !== undefined)
|
|
1663
|
+
return err({ code: "E-LIBRARY-RESERVED", message: `${name.value} is held for the family of the library ${taken.host}` });
|
|
1664
|
+
if (existing.includes(name.value))
|
|
1665
|
+
return err({ code: "E-LIBRARY-EXISTS", message: `${folder}/${name.value} exists` });
|
|
1666
|
+
return ok(name.value);
|
|
1667
|
+
}
|
|
1668
|
+
function titleOf(name) {
|
|
1669
|
+
return name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
1670
|
+
}
|
|
1671
|
+
var q = (s) => JSON.stringify(s);
|
|
1672
|
+
var imp = (what, from) => `import ${what} from ${JSON.stringify(from)};`;
|
|
1673
|
+
function filesOf(l) {
|
|
1674
|
+
const n = l.name;
|
|
1675
|
+
const t = titleOf(n);
|
|
1676
|
+
const spec = `0001-${n}-layers`;
|
|
1677
|
+
const root = `${l.folder}/${n}`;
|
|
1678
|
+
const file = (path, text) => ({ path: `${root}/${path}`, text });
|
|
1679
|
+
const pkg = `@intellectual-frontiers/${n}`;
|
|
1680
|
+
return [
|
|
1681
|
+
file("library.ts", `// Spec: ${spec} FR-001
|
|
1682
|
+
/**
|
|
1683
|
+
* The manifest of ${t}, a library of commons (commons 0027-commons-libraries FR-012): data a program reads and never runs. Its \`kanon\` field is the table of its layers (commons 0033-kanon FR-010), which the shared checker
|
|
1684
|
+
* of \`@intellectual-frontiers/kanon\` holds in \`verify\`.
|
|
1685
|
+
*
|
|
1686
|
+
* @module
|
|
1687
|
+
*/
|
|
1688
|
+
export const library = {
|
|
1689
|
+
name: ${q(n)},
|
|
1690
|
+
level: "L1",
|
|
1691
|
+
specKit: "spec-kit",
|
|
1692
|
+
verify: "bun run verify",
|
|
1693
|
+
version: "0.1.0",
|
|
1694
|
+
distribution: ["github"],
|
|
1695
|
+
exports: [".", "./governance", "./logical", "./physical"],
|
|
1696
|
+
summary: ${q(l.summary)},
|
|
1697
|
+
kanon: {
|
|
1698
|
+
package: ${q(pkg)},
|
|
1699
|
+
units: [
|
|
1700
|
+
{ folder: "src/governance/", layer: "governance", packages: [{ name: "@intellectual-frontiers/core", subpaths: [] }] },
|
|
1701
|
+
{ folder: "src/logical/", layer: "logical", packages: [{ name: "@intellectual-frontiers/core", subpaths: [] }] },
|
|
1702
|
+
{ folder: "src/physical/", layer: "physical", mayImport: ["src/governance/", "src/logical/"], packages: [{ name: "@intellectual-frontiers/core", subpaths: [] }, { name: "@intellectual-frontiers/system", subpaths: "any" }] },
|
|
1703
|
+
{ folder: "src/", own: true },
|
|
1704
|
+
{ folder: "suite/", own: true },
|
|
1705
|
+
{ folder: "tools/", own: true },
|
|
1706
|
+
{ folder: "./", own: true },
|
|
1707
|
+
],
|
|
1708
|
+
},
|
|
1709
|
+
};
|
|
1710
|
+
`),
|
|
1711
|
+
file("package.json", `${JSON.stringify({
|
|
1712
|
+
name: pkg,
|
|
1713
|
+
private: true,
|
|
1714
|
+
version: "0.1.0",
|
|
1715
|
+
description: l.summary,
|
|
1716
|
+
type: "module",
|
|
1717
|
+
engines: { node: ">=26" },
|
|
1718
|
+
exports: { ".": "./src/mod.ts", "./governance": "./src/governance/mod.ts", "./logical": "./src/logical/mod.ts", "./physical": "./src/physical/mod.ts" },
|
|
1719
|
+
scripts: {
|
|
1720
|
+
check: "tsc -p tsconfig.json",
|
|
1721
|
+
test: "bun test suite/",
|
|
1722
|
+
"test:node": 'node --test "suite/**/*.test.ts"',
|
|
1723
|
+
verify: "tsc -p tsconfig.json && bun ../tools/mizan-check.ts --root spec-kit && bun ../libraries/src/check.ts --root spec-kit --level L1 && bun ../kanon/src/check.ts && bun tools/check.ts && bun test suite/"
|
|
1724
|
+
},
|
|
1725
|
+
devDependencies: {
|
|
1726
|
+
"@intellectual-frontiers/core": "link:../core",
|
|
1727
|
+
"@intellectual-frontiers/kanon": "link:../kanon",
|
|
1728
|
+
"@intellectual-frontiers/libraries": "link:../libraries",
|
|
1729
|
+
"@intellectual-frontiers/mizan": "link:../mizan",
|
|
1730
|
+
"@intellectual-frontiers/system": "link:../system",
|
|
1731
|
+
"@intellectual-frontiers/test": "link:../test",
|
|
1732
|
+
"@types/node": "26.6.6",
|
|
1733
|
+
"fast-check": "4.10.2",
|
|
1734
|
+
typescript: "7.0.2"
|
|
1735
|
+
}
|
|
1736
|
+
}, null, 2)}
|
|
1737
|
+
`),
|
|
1738
|
+
file("release.ts", `/**
|
|
1739
|
+
* The release record of this work (commons 0026-works-versioning): data, read and never run. \`versions bump\` writes it; never edit it by hand.
|
|
1740
|
+
*
|
|
1741
|
+
* @module
|
|
1742
|
+
*/
|
|
1743
|
+
export const release = {
|
|
1744
|
+
slug: ${q(n)},
|
|
1745
|
+
kind: "Software",
|
|
1746
|
+
title: ${q(`${t}: a library of Intellectual Frontiers Commons`)},
|
|
1747
|
+
authors: [
|
|
1748
|
+
{
|
|
1749
|
+
name: "Intellectual Frontiers",
|
|
1750
|
+
},
|
|
1751
|
+
],
|
|
1752
|
+
version: "0.1.0",
|
|
1753
|
+
repository: "https://github.com/intellectual-frontiers/.github",
|
|
1754
|
+
};
|
|
1755
|
+
`),
|
|
1756
|
+
file("tsconfig.json", `{
|
|
1757
|
+
"extends": "../tsconfig.base.json",
|
|
1758
|
+
"compilerOptions": {
|
|
1759
|
+
"lib": ["es2024", "dom", "dom.iterable"],
|
|
1760
|
+
"skipLibCheck": true
|
|
1761
|
+
},
|
|
1762
|
+
"include": ["about.ts", "src/**/*.ts", "suite/**/*.ts", "tools/**/*.ts"]
|
|
1763
|
+
}
|
|
1764
|
+
`),
|
|
1765
|
+
file("about.ts", `// Spec: ${spec} FR-001
|
|
1766
|
+
/**
|
|
1767
|
+
* The typed facts of ${t}, an independent library of commons (commons 0027-commons-libraries). Its specification is in its own spec kit (\`spec-kit/\`), numbered from 0001; this repository knows it as one requirement of
|
|
1768
|
+
* 0027-commons-libraries, proved by \`bun run verify\` in this folder.
|
|
1769
|
+
*
|
|
1770
|
+
* @module
|
|
1771
|
+
*/
|
|
1772
|
+
${imp("type { About }", "@intellectual-frontiers/core/about")}
|
|
1773
|
+
|
|
1774
|
+
/** ${t}. */
|
|
1775
|
+
export const about: About = {
|
|
1776
|
+
title: ${q(t)},
|
|
1777
|
+
summary: ${q(l.summary)},
|
|
1778
|
+
folders: [
|
|
1779
|
+
{ path: "spec-kit/", what: "The library's own specifications, numbered from 0001.", mayImport: ["nothing: Markdown and TSV"] },
|
|
1780
|
+
{ path: "src/governance/", what: "Layer 1: what the library is, as data and types.", mayImport: ["core, by package name"] },
|
|
1781
|
+
{ path: "src/logical/", what: "Layer 2: the model the library reasons with.", mayImport: ["governance, by package name", "core, by package name"] },
|
|
1782
|
+
{ path: "src/physical/", what: "Layer 3: what reads files, runs programs and reaches the network.", mayImport: ["governance and logical, by package name", "core and the system, by package name"] },
|
|
1783
|
+
{ path: "suite/", what: "The tests: every requirement.", mayImport: ["src/", "the test module of commons' runtime, by package name"] },
|
|
1784
|
+
{ path: "tools/", what: "The trace check \`bun run verify\` runs.", mayImport: ["the kernel, the runtime and the packer of commons, by package name"] },
|
|
1785
|
+
],
|
|
1786
|
+
};
|
|
1787
|
+
`),
|
|
1788
|
+
file("src/mod.ts", `// Spec: ${spec} FR-001
|
|
1789
|
+
/**
|
|
1790
|
+
* ${t}: its three layers as namespaces.
|
|
1791
|
+
*
|
|
1792
|
+
* @module
|
|
1793
|
+
*/
|
|
1794
|
+
export * as governance from "./governance/mod.ts";
|
|
1795
|
+
export * as logical from "./logical/mod.ts";
|
|
1796
|
+
export * as physical from "./physical/mod.ts";
|
|
1797
|
+
`),
|
|
1798
|
+
file("src/governance/mod.ts", `// Spec: ${spec} FR-001
|
|
1799
|
+
/**
|
|
1800
|
+
* The Governance layer of ${t}: what it is, as data and types.
|
|
1801
|
+
*
|
|
1802
|
+
* @module
|
|
1803
|
+
*/
|
|
1804
|
+
export {};
|
|
1805
|
+
`),
|
|
1806
|
+
file("src/logical/mod.ts", `// Spec: ${spec} FR-001
|
|
1807
|
+
/**
|
|
1808
|
+
* The Logical layer of ${t}: the model it reasons with.
|
|
1809
|
+
*
|
|
1810
|
+
* @module
|
|
1811
|
+
*/
|
|
1812
|
+
export {};
|
|
1813
|
+
`),
|
|
1814
|
+
file("src/physical/mod.ts", `// Spec: ${spec} FR-001
|
|
1815
|
+
/**
|
|
1816
|
+
* The Physical layer of ${t}: what reads files, runs programs and reaches the network.
|
|
1817
|
+
*
|
|
1818
|
+
* @module
|
|
1819
|
+
*/
|
|
1820
|
+
export {};
|
|
1821
|
+
`),
|
|
1822
|
+
file("spec-kit/registry.tsv", `number slug state
|
|
1823
|
+
0001 ${n}-layers in force
|
|
1824
|
+
`),
|
|
1825
|
+
file("spec-kit/mizan.baseline.txt", ""),
|
|
1826
|
+
file("spec-kit/enforcement.tsv", `# What enforces each requirement in this library's specs (0024-spec-format FR-011 - FR-014).
|
|
1827
|
+
# mechanism: check | gate | review | none. by: "<repo>: <command>" for check and gate, the defining requirement for review, "-" for none.
|
|
1828
|
+
requirement mechanism by note
|
|
1829
|
+
${spec} FR-001 check .github: cd commons/${n} && bun run verify suite/layers.test.ts: every file of the real tree is in a unit and no import is outside its row
|
|
1830
|
+
${spec} FR-002 check .github: cd commons/${n} && bun run verify suite/layers.test.ts: verify runs every check of the library
|
|
1831
|
+
`),
|
|
1832
|
+
file(`spec-kit/specs/${spec}/spec.md`, `# Feature Specification: ${t} layers
|
|
1833
|
+
|
|
1834
|
+
**Spec ID:** ${spec}
|
|
1835
|
+
**Status:** Active
|
|
1836
|
+
**Owner:** if
|
|
1837
|
+
**Domain:** commons
|
|
1838
|
+
|
|
1839
|
+
**Input:** ${l.summary} It is built to Kanon (commons 0033-kanon): Governance says what it is, Logical is the model it reasons with, and Physical is what touches the world.
|
|
1840
|
+
|
|
1841
|
+
## Requirements
|
|
1842
|
+
|
|
1843
|
+
- **FR-001**: The library MUST be Kanon: its manifest \`library.ts\` MUST declare the table of its units in the field \`kanon\`, with the units \`src/governance/\`, \`src/logical/\` and \`src/physical/\`, and the shared checker of \`@intellectual-frontiers/kanon\` MUST find no import that the table does not allow.
|
|
1844
|
+
- **FR-002**: \`bun run verify\` in the folder of the library MUST run the TypeScript 7 compiler, the checks of the specification kit, the check of the level L1, the layers check of Kanon, the trace check and the tests, and MUST fail on any finding that is not held by a baseline that only shrinks.
|
|
1845
|
+
|
|
1846
|
+
## Acceptance scenarios
|
|
1847
|
+
|
|
1848
|
+
1. **Given** the real tree of the library, **When** the layers check runs, **Then** every file is in a unit and no import is outside its row, per FR-001.
|
|
1849
|
+
2. **Given** the package of the library, **When** its \`verify\` script is read, **Then** it runs every check, per FR-002.
|
|
1850
|
+
|
|
1851
|
+
## Out of scope
|
|
1852
|
+
|
|
1853
|
+
- Everything the library will do: its next specifications.
|
|
1854
|
+
|
|
1855
|
+
## Edge cases
|
|
1856
|
+
|
|
1857
|
+
- A file in no unit of the table: it is a finding of the layers check, per FR-001.
|
|
1858
|
+
- A \`verify\` that leaves out a check: it is a finding of the test, per FR-002.
|
|
1859
|
+
|
|
1860
|
+
## Assumptions
|
|
1861
|
+
|
|
1862
|
+
- The shared checker of Kanon and the manifest check of the libraries are on the branch that holds this library.
|
|
1863
|
+
|
|
1864
|
+
## Open questions
|
|
1865
|
+
|
|
1866
|
+
- None.
|
|
1867
|
+
|
|
1868
|
+
## Key entities
|
|
1869
|
+
|
|
1870
|
+
- **${t}** - the library.
|
|
1871
|
+
|
|
1872
|
+
## Success criteria
|
|
1873
|
+
|
|
1874
|
+
- **SC-001**: The layers check of Kanon finds nothing in the real tree.
|
|
1875
|
+
|
|
1876
|
+
## Review & acceptance checklist
|
|
1877
|
+
|
|
1878
|
+
- [x] Every requirement is testable (MUST / MUST NOT), not aspirational
|
|
1879
|
+
- [x] No company fact is asserted here
|
|
1880
|
+
- [x] Every open item is marked, not silently decided
|
|
1881
|
+
`),
|
|
1882
|
+
file("suite/layers.test.ts", `/**
|
|
1883
|
+
* Tests of the layers of ${t} over the shared checker of Kanon (commons ${n} ${spec} FR-001, FR-002): the table in the manifest holds every file of the real tree with no finding, and \`verify\` runs every check.
|
|
1884
|
+
*
|
|
1885
|
+
* @module
|
|
1886
|
+
*/
|
|
1887
|
+
${imp("{ assert, assertEquals, proves }", "@intellectual-frontiers/test")}
|
|
1888
|
+
${imp("{ decodeTable }", "@intellectual-frontiers/kanon")}
|
|
1889
|
+
${imp("{ findings as hostFindings, readTable }", "@intellectual-frontiers/kanon/host")}
|
|
1890
|
+
${imp("{ fs, path }", "@intellectual-frontiers/system")}
|
|
1891
|
+
${imp("{ library }", "../library.ts")}
|
|
1892
|
+
|
|
1893
|
+
const ROOT = path.resolve(path.dirname(path.fromFileUrl(import.meta.url)), "..");
|
|
1894
|
+
|
|
1895
|
+
proves(["${spec} FR-001"], "the shared checker finds nothing in the real tree", () => {
|
|
1896
|
+
assertEquals(readTable(ROOT).kind, "ok");
|
|
1897
|
+
assertEquals(decodeTable(library.kanon).kind, "ok");
|
|
1898
|
+
const found = hostFindings(ROOT);
|
|
1899
|
+
assert(found.kind === "ok", "the real tree is read");
|
|
1900
|
+
assertEquals(found.value.map((f) => \`\${f.rule} \${f.file}\`), []);
|
|
1901
|
+
});
|
|
1902
|
+
|
|
1903
|
+
proves(["${spec} FR-002"], "verify runs every check of the library", async () => {
|
|
1904
|
+
const pkg = JSON.parse(await fs.readTextFile(path.join(ROOT, "package.json"))) as { scripts: Record<string, string> };
|
|
1905
|
+
const verify = pkg.scripts["verify"] ?? "";
|
|
1906
|
+
for (const step of ["tsc -p tsconfig.json", "mizan-check.ts --root spec-kit", "check.ts --root spec-kit --level L1", "bun ../kanon/src/check.ts", "bun tools/check.ts", "bun test suite/"]) {
|
|
1907
|
+
assert(verify.includes(step), \`verify runs \${step}\`);
|
|
1908
|
+
}
|
|
1909
|
+
});
|
|
1910
|
+
`),
|
|
1911
|
+
file("tools/check.ts", CHECK_TOOL(n, t, spec)),
|
|
1912
|
+
file("trace.baseline.txt", "")
|
|
1913
|
+
];
|
|
1914
|
+
}
|
|
1915
|
+
function CHECK_TOOL(n, t, spec) {
|
|
1916
|
+
return `// Spec: ${spec} FR-002
|
|
1917
|
+
/**
|
|
1918
|
+
* The check \`bun run verify\` runs on the library (commons ${n} ${spec} FR-002): the trace of its sources and tests to its own specifications (commons 0015-trace), the findings held against \`trace.baseline.txt\`, which only
|
|
1919
|
+
* shrinks. It prints the lines of the judgement and exits with 0, or with 1 where a finding is new or a line of the baseline is stale.
|
|
1920
|
+
*
|
|
1921
|
+
* \`\`\`sh
|
|
1922
|
+
* bun tools/check.ts check
|
|
1923
|
+
* bun tools/check.ts --write-baseline hold what is found now (the first time only)
|
|
1924
|
+
* \`\`\`
|
|
1925
|
+
*
|
|
1926
|
+
* @module
|
|
1927
|
+
*/
|
|
1928
|
+
${imp("* as kernel", "@intellectual-frontiers/mizan/trace")}
|
|
1929
|
+
${imp("{ fs, path }", "@intellectual-frontiers/system")}
|
|
1930
|
+
${imp("* as runtime", "@intellectual-frontiers/mizan/host/trace")}
|
|
1931
|
+
|
|
1932
|
+
const ROOT = path.resolve(path.dirname(path.fromFileUrl(import.meta.url)), "..");
|
|
1933
|
+
const BASELINE = "trace.baseline.txt";
|
|
1934
|
+
const COMMENTS = [
|
|
1935
|
+
"# The findings of the trace check of ${t} (tools/check.ts) that existed when each was first held.",
|
|
1936
|
+
"# A new finding fails the check, and so does a line below that no longer occurs: when you fix one, delete its line.",
|
|
1937
|
+
"# Never add a line to make a check pass.",
|
|
1938
|
+
] as const;
|
|
1939
|
+
|
|
1940
|
+
/** Every finding of the library at \`root\`: the trace of its sources and tests to its specifications. */
|
|
1941
|
+
export async function findings(root: string): Promise<readonly kernel.Keyed[]> {
|
|
1942
|
+
const sources = await runtime.readSources(root, ["about.ts", "src", "tools"]);
|
|
1943
|
+
const tests = await runtime.readSources(root, ["suite"]);
|
|
1944
|
+
const specs = await runtime.readSpecs(root, "spec-kit/specs");
|
|
1945
|
+
return kernel.traceFindings({ specs, sources, tests, ontology: [], specsFolder: "spec-kit/specs" });
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
/** The command line: the exit status, and what to print. */
|
|
1949
|
+
export async function main(argv: readonly string[]): Promise<{ readonly code: 0 | 1; readonly lines: readonly string[] }> {
|
|
1950
|
+
const found = await findings(ROOT);
|
|
1951
|
+
if (argv.includes("--write-baseline")) {
|
|
1952
|
+
await fs.writeTextFile(path.join(ROOT, BASELINE), kernel.formatBaseline(found, COMMENTS));
|
|
1953
|
+
return { code: 0, lines: [\`${n}-check: wrote \${BASELINE} (\${found.length} findings held)\`] };
|
|
1954
|
+
}
|
|
1955
|
+
const text = await fs.readTextFile(path.join(ROOT, BASELINE)).catch(() => "");
|
|
1956
|
+
const judged = kernel.judge(found, kernel.parseBaseline(text));
|
|
1957
|
+
return { code: kernel.passes(judged) ? 0 : 1, lines: kernel.report(judged, "${n}-check", BASELINE) };
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
if (import.meta.main) {
|
|
1961
|
+
const r = await main(process.argv.slice(2));
|
|
1962
|
+
for (const line of r.lines) console.log(line);
|
|
1963
|
+
process.exit(r.code);
|
|
1964
|
+
}
|
|
1965
|
+
`;
|
|
1966
|
+
}
|
|
1967
|
+
function withRole(source, name, role) {
|
|
1968
|
+
const start = source.indexOf("export const ROLE_OF");
|
|
1969
|
+
if (start < 0)
|
|
1970
|
+
return err("readme.ts has no ROLE_OF");
|
|
1971
|
+
const end = source.indexOf(`
|
|
1972
|
+
]);`, start);
|
|
1973
|
+
if (end < 0)
|
|
1974
|
+
return err("the ROLE_OF of readme.ts does not end where it is read");
|
|
1975
|
+
const body = source.slice(start, end);
|
|
1976
|
+
const entry = ` [${q(name)}, ${q(role)}],`;
|
|
1977
|
+
if (body.includes(`[${q(name)},`))
|
|
1978
|
+
return ok(source);
|
|
1979
|
+
const lastOfRole = body.lastIndexOf(`, ${q(role)}],`);
|
|
1980
|
+
if (lastOfRole < 0)
|
|
1981
|
+
return ok(`${source.slice(0, end)}
|
|
1982
|
+
${entry}${source.slice(end)}`);
|
|
1983
|
+
const at = start + body.indexOf(`
|
|
1984
|
+
`, lastOfRole);
|
|
1985
|
+
return ok(`${source.slice(0, at)}
|
|
1986
|
+
${entry}${source.slice(at)}`);
|
|
1987
|
+
}
|
|
1988
|
+
// src/logical/select.ts
|
|
1989
|
+
function specIdsOf(text) {
|
|
1990
|
+
const ids = new Set;
|
|
1991
|
+
for (const m of text.matchAll(/\bSpec:\s*([^\n]*)/g)) {
|
|
1992
|
+
const spec = /(\d{4}-[a-z0-9-]+)\s+(FR-\d+(?:\s*,\s*FR-\d+)*)/.exec(m[1] ?? "");
|
|
1993
|
+
if (spec?.[1] === undefined || spec[2] === undefined)
|
|
1994
|
+
continue;
|
|
1995
|
+
for (const fr of spec[2].split(","))
|
|
1996
|
+
ids.add(`${spec[1]} ${fr.trim()}`);
|
|
1997
|
+
}
|
|
1998
|
+
return [...ids].sort();
|
|
1999
|
+
}
|
|
2000
|
+
function provesOf(text) {
|
|
2001
|
+
const ids = new Set;
|
|
2002
|
+
for (const call of text.matchAll(/\bproves\(\s*\[([^\]]*)\]/g))
|
|
2003
|
+
for (const id of (call[1] ?? "").matchAll(/["'`]([^"'`]+)["'`]/g))
|
|
2004
|
+
if (id[1] !== undefined)
|
|
2005
|
+
ids.add(id[1]);
|
|
2006
|
+
return [...ids].sort();
|
|
2007
|
+
}
|
|
2008
|
+
function specOfPath(path) {
|
|
2009
|
+
return /\/specs\/(\d{4}-[a-z0-9-]+)\//.exec(path)?.[1];
|
|
2010
|
+
}
|
|
2011
|
+
var ENVIRONMENT = /\bCHECKOUT\b|import\.meta\.(?:url|dirname|dir)\b|\bprocess\.cwd\(|\bfromFileUrl\(/;
|
|
2012
|
+
function readsTheTree(text) {
|
|
2013
|
+
return ENVIRONMENT.test(text);
|
|
2014
|
+
}
|
|
2015
|
+
var reaches = (depends, path) => depends.some((d) => d.endsWith("/") ? path.startsWith(d) : d === path);
|
|
2016
|
+
function selectTests(tests, changed, everything) {
|
|
2017
|
+
const ids = new Set(changed.flatMap((c) => [...specIdsOf(c.text), ...specOfPath(c.path) === undefined ? [] : [`${specOfPath(c.path)} `]]));
|
|
2018
|
+
const run = [];
|
|
2019
|
+
const left = [];
|
|
2020
|
+
for (const test of tests) {
|
|
2021
|
+
const by = everything ? "everything" : changed.some((c) => reaches(test.depends, c.path) || c.path === test.path) ? "import" : test.proves.some((p) => ids.has(p) || [...ids].some((i) => i.endsWith(" ") && p.startsWith(i))) ? "trace" : test.environmental && changed.length > 0 ? "environmental" : undefined;
|
|
2022
|
+
if (by === undefined)
|
|
2023
|
+
left.push(test);
|
|
2024
|
+
else
|
|
2025
|
+
run.push({ test, by });
|
|
2026
|
+
}
|
|
2027
|
+
return { run, left };
|
|
2028
|
+
}
|
|
2029
|
+
function selectSeam(tests, provider, delta) {
|
|
2030
|
+
const run = [];
|
|
2031
|
+
const left = [];
|
|
2032
|
+
for (const test of tests) {
|
|
2033
|
+
const usage = test.uses.find((u) => u.provider === provider)?.usage;
|
|
2034
|
+
const hit = usage !== undefined && (delta.kind === "unknown" || usage.all || delta.kind === "changed" && usage.names.some((n) => delta.symbols.includes(n)));
|
|
2035
|
+
if (hit)
|
|
2036
|
+
run.push({ test, by: "symbol" });
|
|
2037
|
+
else
|
|
2038
|
+
left.push(test);
|
|
2039
|
+
}
|
|
2040
|
+
return { run, left };
|
|
2041
|
+
}
|
|
2042
|
+
function applyQuarantine(selected, entries, today) {
|
|
2043
|
+
const live = entries.filter((e) => e.expires >= today);
|
|
2044
|
+
const run = [];
|
|
2045
|
+
const held = [];
|
|
2046
|
+
for (const item of selected) {
|
|
2047
|
+
const entry = live.find((e) => e.test === item.test.path);
|
|
2048
|
+
if (entry === undefined)
|
|
2049
|
+
run.push(item);
|
|
2050
|
+
else
|
|
2051
|
+
held.push({ item, entry });
|
|
2052
|
+
}
|
|
2053
|
+
return { run, held, expired: entries.filter((e) => e.expires < today) };
|
|
2054
|
+
}
|
|
2055
|
+
function seedsOf(output) {
|
|
2056
|
+
const out = new Set;
|
|
2057
|
+
for (const m of output.matchAll(/\bseed:\s*(-?\d+)/g))
|
|
2058
|
+
out.add(`seed ${m[1] ?? ""}`);
|
|
2059
|
+
for (const m of output.matchAll(/Counterexample:\s*([^\n]+)/g))
|
|
2060
|
+
out.add(`counterexample ${m[1] ?? ""}`);
|
|
2061
|
+
return [...out];
|
|
2062
|
+
}
|
|
2063
|
+
function cacheKeyOf(parts) {
|
|
2064
|
+
return JSON.stringify([parts.runtime, parts.library, parts.test, ...[...parts.hashes].sort(([a], [b]) => a < b ? -1 : 1)]);
|
|
2065
|
+
}
|
|
2066
|
+
// src/logical/semver.ts
|
|
2067
|
+
var PARTS = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+.*)?$/;
|
|
2068
|
+
function partsOf(text) {
|
|
2069
|
+
const m = PARTS.exec(text);
|
|
2070
|
+
if (m === null)
|
|
2071
|
+
return;
|
|
2072
|
+
return { numbers: [Number(m[1]), Number(m[2]), Number(m[3])], pre: m[4] };
|
|
2073
|
+
}
|
|
2074
|
+
function compareSemver(a, b) {
|
|
2075
|
+
const x = partsOf(a);
|
|
2076
|
+
const y = partsOf(b);
|
|
2077
|
+
if (x === undefined || y === undefined)
|
|
2078
|
+
return x === undefined && y === undefined ? 0 : x === undefined ? -1 : 1;
|
|
2079
|
+
for (let i = 0;i < 3; i++) {
|
|
2080
|
+
const d = (x.numbers[i] ?? 0) - (y.numbers[i] ?? 0);
|
|
2081
|
+
if (d !== 0)
|
|
2082
|
+
return d < 0 ? -1 : 1;
|
|
2083
|
+
}
|
|
2084
|
+
if (x.pre === y.pre)
|
|
2085
|
+
return 0;
|
|
2086
|
+
if (x.pre === undefined)
|
|
2087
|
+
return 1;
|
|
2088
|
+
if (y.pre === undefined)
|
|
2089
|
+
return -1;
|
|
2090
|
+
return x.pre < y.pre ? -1 : 1;
|
|
2091
|
+
}
|
|
2092
|
+
function greatest(versions) {
|
|
2093
|
+
return versions.reduce((best, v) => best === undefined || compareSemver(v, best) > 0 ? v : best, undefined);
|
|
2094
|
+
}
|
|
2095
|
+
// src/logical/status.ts
|
|
2096
|
+
var TAG = /^(.+)-v(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
|
|
2097
|
+
function tagsOf(text) {
|
|
2098
|
+
const out = new Map;
|
|
2099
|
+
for (const raw of text.split(`
|
|
2100
|
+
`)) {
|
|
2101
|
+
const line = raw.trim();
|
|
2102
|
+
if (line === "")
|
|
2103
|
+
continue;
|
|
2104
|
+
const ref = line.includes("\t") ? line.split("\t")[1] ?? "" : line;
|
|
2105
|
+
const name = ref.replace(/^refs\/tags\//, "").replace(/\^\{\}$/, "");
|
|
2106
|
+
const m = TAG.exec(name);
|
|
2107
|
+
if (m?.[1] === undefined || m[2] === undefined)
|
|
2108
|
+
continue;
|
|
2109
|
+
const have = out.get(m[1]) ?? [];
|
|
2110
|
+
if (!have.includes(m[2]))
|
|
2111
|
+
have.push(m[2]);
|
|
2112
|
+
out.set(m[1], have);
|
|
2113
|
+
}
|
|
2114
|
+
return out;
|
|
2115
|
+
}
|
|
2116
|
+
function stateOf(lib, npm, tag) {
|
|
2117
|
+
if (lib.held !== undefined)
|
|
2118
|
+
return "held";
|
|
2119
|
+
if (npm.kind === "skipped" || npm.kind === "unreachable" || tag.kind === "unreachable")
|
|
2120
|
+
return "unknown";
|
|
2121
|
+
if (lib.npm && (npm.kind === "absent" || npm.kind === "found" && !npm.hasRepoVersion))
|
|
2122
|
+
return "unpublished";
|
|
2123
|
+
if (tag.kind === "none" || !tag.hasRepoVersion)
|
|
2124
|
+
return "untagged";
|
|
2125
|
+
return "released";
|
|
2126
|
+
}
|
|
2127
|
+
var npmCell = (lib, got) => {
|
|
2128
|
+
if (got.kind === "err")
|
|
2129
|
+
return { kind: "unreachable", why: got.error };
|
|
2130
|
+
if (got.value === "absent")
|
|
2131
|
+
return { kind: "absent" };
|
|
2132
|
+
return { kind: "found", latest: got.value.latest, hasRepoVersion: got.value.versions.includes(lib.version) };
|
|
2133
|
+
};
|
|
2134
|
+
async function runStatus(w, options) {
|
|
2135
|
+
const libs = await w.libraries.list();
|
|
2136
|
+
if (libs.kind === "err")
|
|
2137
|
+
return err(libs.error);
|
|
2138
|
+
const here = { cwd: w.repo };
|
|
2139
|
+
const source = options.offline ? "local" : "remote";
|
|
2140
|
+
const listed = await w.process.run(options.offline ? ["git", "tag", "--list"] : ["git", "ls-remote", "--tags", "origin"], here);
|
|
2141
|
+
const tags = listed.code === 0 ? tagsOf(listed.stdout) : undefined;
|
|
2142
|
+
const why = `git could not list the tags (${listed.stderr.trim().split(`
|
|
2143
|
+
`).slice(-1)[0] ?? "no message"})`;
|
|
2144
|
+
const rows = await pool([...libs.value].sort((a, b) => a.name < b.name ? -1 : 1), 8, async (lib) => {
|
|
2145
|
+
const npm = lib.held !== undefined || !lib.npm ? { kind: "not-published" } : options.offline ? { kind: "skipped" } : npmCell(lib, await w.registry.view(lib.package));
|
|
2146
|
+
const versions = lib.held !== undefined ? [] : tags?.get(lib.name) ?? [];
|
|
2147
|
+
const latest = greatest(versions);
|
|
2148
|
+
const tag = tags === undefined ? { kind: "unreachable", why } : latest === undefined ? { kind: "none", source } : { kind: "found", latest, hasRepoVersion: versions.includes(lib.version), source };
|
|
2149
|
+
return { library: lib.name, repo: lib.version, npm, tag, state: stateOf(lib, npm, tag) };
|
|
2150
|
+
});
|
|
2151
|
+
return ok({ offline: options.offline, rows });
|
|
2152
|
+
}
|
|
2153
|
+
function findingsOfStatus(r) {
|
|
2154
|
+
const out = [];
|
|
2155
|
+
for (const row of r.rows) {
|
|
2156
|
+
if (row.npm.kind === "unreachable")
|
|
2157
|
+
out.push(finding("warn", "E-NPM-UNREACHABLE", `${row.library}: npm could not be asked (${row.npm.why})`, "repoctl status --offline"));
|
|
2158
|
+
}
|
|
2159
|
+
const tagFailure = r.rows.find((row) => row.tag.kind === "unreachable");
|
|
2160
|
+
if (tagFailure?.tag.kind === "unreachable")
|
|
2161
|
+
out.push(finding("warn", "E-ENVIRONMENT", tagFailure.tag.why, "repoctl doctor"));
|
|
2162
|
+
return out;
|
|
2163
|
+
}
|
|
2164
|
+
var npmText = (c) => {
|
|
2165
|
+
switch (c.kind) {
|
|
2166
|
+
case "skipped":
|
|
2167
|
+
return "-";
|
|
2168
|
+
case "not-published":
|
|
2169
|
+
return "not on npm";
|
|
2170
|
+
case "absent":
|
|
2171
|
+
return "none";
|
|
2172
|
+
case "unreachable":
|
|
2173
|
+
return "unreachable";
|
|
2174
|
+
case "found":
|
|
2175
|
+
return `${c.latest ?? "?"}${c.hasRepoVersion ? "" : " (this version not listed)"}`;
|
|
2176
|
+
default:
|
|
2177
|
+
return "?";
|
|
2178
|
+
}
|
|
2179
|
+
};
|
|
2180
|
+
var tagText = (c) => {
|
|
2181
|
+
switch (c.kind) {
|
|
2182
|
+
case "unreachable":
|
|
2183
|
+
return "unreachable";
|
|
2184
|
+
case "none":
|
|
2185
|
+
return "none";
|
|
2186
|
+
case "found":
|
|
2187
|
+
return `${c.latest}${c.hasRepoVersion ? "" : " (this version not tagged)"}`;
|
|
2188
|
+
default:
|
|
2189
|
+
return "?";
|
|
2190
|
+
}
|
|
2191
|
+
};
|
|
2192
|
+
function tableOf(r) {
|
|
2193
|
+
const head = ["library", "repo", "npm", "tag", "state"];
|
|
2194
|
+
const body = r.rows.map((row) => [row.library, row.repo, npmText(row.npm), tagText(row.tag), row.state]);
|
|
2195
|
+
const width = head.map((h, i) => Math.max(h.length, ...body.map((b) => (b[i] ?? "").length)));
|
|
2196
|
+
const line = (cells) => cells.map((c, i) => c.padEnd(width[i] ?? 0)).join(" ").trimEnd();
|
|
2197
|
+
return [line(head), ...body.map(line)].join(`
|
|
2198
|
+
`);
|
|
2199
|
+
}
|
|
2200
|
+
// src/logical/hygiene.ts
|
|
2201
|
+
var EXACT = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
2202
|
+
function isExactVersion(spec) {
|
|
2203
|
+
return EXACT.test(spec);
|
|
2204
|
+
}
|
|
2205
|
+
function isGitOfFamily(policy, spec) {
|
|
2206
|
+
const lower = spec.toLowerCase();
|
|
2207
|
+
return policy.gitSources.some((g) => lower.includes(g));
|
|
2208
|
+
}
|
|
2209
|
+
function pathOf(spec) {
|
|
2210
|
+
const m = /^(?:file|link):(.*)$/.exec(spec);
|
|
2211
|
+
return m?.[1];
|
|
2212
|
+
}
|
|
2213
|
+
function segments2(path) {
|
|
2214
|
+
return path.split(/[\\/]/).filter((s) => s !== "" && s !== "." && s !== "..");
|
|
2215
|
+
}
|
|
2216
|
+
function intoFamily(policy, path) {
|
|
2217
|
+
if (policy.pathSegment === "")
|
|
2218
|
+
return false;
|
|
2219
|
+
const s = segments2(path);
|
|
2220
|
+
const at = s.indexOf(policy.pathSegment);
|
|
2221
|
+
return at >= 0 && at < s.length - 1 && !policy.allow.paths.some((g) => matches(g, path.replace(/\\/g, "/")));
|
|
2222
|
+
}
|
|
2223
|
+
var dirOf = (file) => file.slice(0, Math.max(0, file.lastIndexOf("/")));
|
|
2224
|
+
function isOwn(p, workspaces) {
|
|
2225
|
+
if (p.path === "package.json")
|
|
2226
|
+
return true;
|
|
2227
|
+
const dir = dirOf(p.path);
|
|
2228
|
+
return workspaces.some((w) => matches(w.replace(/^\.\//, "").replace(/\/$/, ""), dir));
|
|
2229
|
+
}
|
|
2230
|
+
var ORDER = ["E-HYGIENE-GIT", "E-HYGIENE-PATH", "E-HYGIENE-IMPORT", "E-HYGIENE-VENDORED", "E-HYGIENE-DUPLICATE", "E-HYGIENE-RANGE", "E-ENVIRONMENT"];
|
|
2231
|
+
function hygiene(facts, policy) {
|
|
2232
|
+
const out = [];
|
|
2233
|
+
const own = facts.repository === "source";
|
|
2234
|
+
const SCOPE = policy.scope;
|
|
2235
|
+
for (const p of facts.packages) {
|
|
2236
|
+
for (const d of p.dependencies) {
|
|
2237
|
+
if (isGitOfFamily(policy, d.spec))
|
|
2238
|
+
out.push({ level: "fail", code: "E-HYGIENE-GIT", path: p.path, message: `${p.path}: ${d.name} is a Git dependency on the family's own repository (${d.spec}): install a published package instead`, fix: `bun add ${SCOPE}<package>@<version> --exact` });
|
|
2239
|
+
const target = pathOf(d.spec);
|
|
2240
|
+
if (!own && target !== undefined && intoFamily(policy, target))
|
|
2241
|
+
out.push({ level: "fail", code: "E-HYGIENE-PATH", path: p.path, message: `${p.path}: ${d.name} is a ${d.spec.slice(0, d.spec.indexOf(":"))}: dependency into a checkout of the family (${target}): install a published package instead`, fix: `bun add ${SCOPE}<package>@<version> --exact` });
|
|
2242
|
+
if (d.name.startsWith(SCOPE) && target === undefined && !isGitOfFamily(policy, d.spec) && !d.spec.startsWith("workspace:") && !isExactVersion(d.spec))
|
|
2243
|
+
out.push({ level: "warn", code: "E-HYGIENE-RANGE", path: p.path, message: `${p.path}: ${d.name} is "${d.spec}", which is not an exact version`, fix: `bun add ${d.name}@<version> --exact` });
|
|
2244
|
+
}
|
|
2245
|
+
if (!own && p.name !== undefined && p.name.startsWith(SCOPE) && !policy.allow.packages.includes(p.name) && !isOwn(p, facts.workspaces))
|
|
2246
|
+
out.push({ level: "fail", code: "E-HYGIENE-VENDORED", path: p.path, message: `${p.path}: a folder of this repository carries the package ${p.name}, which is a copy of a package of the family: remove it and install the published package`, fix: `bun add ${p.name}@<version> --exact` });
|
|
2247
|
+
}
|
|
2248
|
+
if (!own) {
|
|
2249
|
+
for (const i of facts.imports)
|
|
2250
|
+
if (i.specifier.startsWith(".") && intoFamily(policy, i.specifier))
|
|
2251
|
+
out.push({ level: "fail", code: "E-HYGIENE-IMPORT", path: i.file, message: `${i.file}: imports ${i.specifier}, which reaches into a copy of the family: import the package by its name`, fix: "import from @intellectual-frontiers/<library>" });
|
|
2252
|
+
}
|
|
2253
|
+
const copies = new Map;
|
|
2254
|
+
const add = (pkg, c) => void copies.set(pkg, [...copies.get(pkg) ?? [], c]);
|
|
2255
|
+
for (const l of facts.locks)
|
|
2256
|
+
if (l.kind === "read")
|
|
2257
|
+
for (const [pkg, cs] of l.copies)
|
|
2258
|
+
for (const c of cs)
|
|
2259
|
+
add(pkg, c);
|
|
2260
|
+
for (const [pkg, cs] of facts.installed)
|
|
2261
|
+
for (const c of cs)
|
|
2262
|
+
add(pkg, c);
|
|
2263
|
+
for (const [pkg, cs] of [...copies].sort(([a], [b]) => a < b ? -1 : 1)) {
|
|
2264
|
+
const versions = [...new Set(cs.map((c) => c.version))].sort();
|
|
2265
|
+
if (versions.length < 2)
|
|
2266
|
+
continue;
|
|
2267
|
+
const where = versions.map((v) => `${v} (${cs.find((c) => c.version === v)?.where ?? "?"})`).join(", ");
|
|
2268
|
+
out.push({ level: "fail", code: "E-HYGIENE-DUPLICATE", path: cs[0]?.where ?? pkg, message: `${pkg} is installed ${versions.length} times, at ${where}: make the tree hold one copy`, fix: `add "overrides": { "${pkg}": "${versions[versions.length - 1] ?? ""}" } to package.json and install again` });
|
|
2269
|
+
}
|
|
2270
|
+
for (const l of facts.locks)
|
|
2271
|
+
if (l.kind === "unreadable")
|
|
2272
|
+
out.push({ level: "fail", code: "E-ENVIRONMENT", path: l.file, message: `${l.file} could not be read (${l.why}), so the installed copies are not known`, fix: "bun install" });
|
|
2273
|
+
if (facts.locks.length === 0 && facts.packages.length > 0)
|
|
2274
|
+
out.push({ level: "warn", code: "E-ENVIRONMENT", path: "package.json", message: "there is no bun.lock or package-lock.json: the installed copies are read from node_modules alone", fix: "bun install" });
|
|
2275
|
+
return out.sort((a, b) => ORDER.indexOf(a.code) - ORDER.indexOf(b.code) || (a.path < b.path ? -1 : a.path > b.path ? 1 : 0) || (a.message < b.message ? -1 : 1));
|
|
2276
|
+
}
|
|
2277
|
+
function hygieneFails(findings) {
|
|
2278
|
+
return findings.some((f) => {
|
|
2279
|
+
switch (f.level) {
|
|
2280
|
+
case "fail":
|
|
2281
|
+
return true;
|
|
2282
|
+
case "warn":
|
|
2283
|
+
return false;
|
|
2284
|
+
default:
|
|
2285
|
+
return absurd(f.level);
|
|
2286
|
+
}
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
function countsOf2(findings) {
|
|
2290
|
+
return { failures: findings.filter((f) => f.level === "fail").length, warnings: findings.filter((f) => f.level === "warn").length };
|
|
2291
|
+
}
|
|
2292
|
+
// src/logical/hygiene-facts.ts
|
|
2293
|
+
function stripJsonc(text) {
|
|
2294
|
+
let out = "";
|
|
2295
|
+
for (let i = 0;i < text.length; i++) {
|
|
2296
|
+
const c = text.charAt(i);
|
|
2297
|
+
const next = text.charAt(i + 1);
|
|
2298
|
+
if (c === '"') {
|
|
2299
|
+
let j = i + 1;
|
|
2300
|
+
while (j < text.length && text.charAt(j) !== '"')
|
|
2301
|
+
j += text.charAt(j) === "\\" ? 2 : 1;
|
|
2302
|
+
out += text.slice(i, j + 1);
|
|
2303
|
+
i = j;
|
|
2304
|
+
} else if (c === "/" && next === "/") {
|
|
2305
|
+
while (i < text.length && text.charAt(i) !== `
|
|
2306
|
+
`)
|
|
2307
|
+
i++;
|
|
2308
|
+
out += `
|
|
2309
|
+
`;
|
|
2310
|
+
} else if (c === "/" && next === "*") {
|
|
2311
|
+
const end = text.indexOf("*/", i + 2);
|
|
2312
|
+
i = end < 0 ? text.length : end + 1;
|
|
2313
|
+
} else
|
|
2314
|
+
out += c;
|
|
2315
|
+
}
|
|
2316
|
+
return out.replace(/,(\s*[}\]])/g, "$1");
|
|
2317
|
+
}
|
|
2318
|
+
var record2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? Object.fromEntries(Object.entries(v)) : {};
|
|
2319
|
+
var text = (v) => typeof v === "string" ? v : undefined;
|
|
2320
|
+
var add = (into, name, c) => void into.set(name, [...into.get(name) ?? [], c]);
|
|
2321
|
+
function parseBunLock(source, file, scope) {
|
|
2322
|
+
let json;
|
|
2323
|
+
try {
|
|
2324
|
+
json = JSON.parse(stripJsonc(source));
|
|
2325
|
+
} catch (e) {
|
|
2326
|
+
return { kind: "unreadable", file, why: e instanceof Error ? e.message : String(e) };
|
|
2327
|
+
}
|
|
2328
|
+
const packages = record2(record2(json)["packages"]);
|
|
2329
|
+
const copies = new Map;
|
|
2330
|
+
for (const [key, value] of Object.entries(packages)) {
|
|
2331
|
+
const head = Array.isArray(value) ? text(value[0]) : undefined;
|
|
2332
|
+
const at = head === undefined ? -1 : head.lastIndexOf("@");
|
|
2333
|
+
if (head === undefined || at <= 0)
|
|
2334
|
+
continue;
|
|
2335
|
+
const name = head.slice(0, at);
|
|
2336
|
+
const version = head.slice(at + 1);
|
|
2337
|
+
if (name.startsWith(scope) && /^\d/.test(version))
|
|
2338
|
+
add(copies, name, { version, where: `${file}: ${key}` });
|
|
2339
|
+
}
|
|
2340
|
+
return { kind: "read", file, copies };
|
|
2341
|
+
}
|
|
2342
|
+
function parseNpmLock(source, file, scope) {
|
|
2343
|
+
let json;
|
|
2344
|
+
try {
|
|
2345
|
+
json = JSON.parse(source);
|
|
2346
|
+
} catch (e) {
|
|
2347
|
+
return { kind: "unreadable", file, why: e instanceof Error ? e.message : String(e) };
|
|
2348
|
+
}
|
|
2349
|
+
const packages = record2(record2(json)["packages"]);
|
|
2350
|
+
const copies = new Map;
|
|
2351
|
+
for (const [key, value] of Object.entries(packages)) {
|
|
2352
|
+
const at = key.lastIndexOf("node_modules/");
|
|
2353
|
+
if (at < 0)
|
|
2354
|
+
continue;
|
|
2355
|
+
const name = key.slice(at + "node_modules/".length);
|
|
2356
|
+
const version = text(record2(value)["version"]);
|
|
2357
|
+
if (name.startsWith(scope) && version !== undefined)
|
|
2358
|
+
add(copies, name, { version, where: `${file}: ${key}` });
|
|
2359
|
+
}
|
|
2360
|
+
return { kind: "read", file, copies };
|
|
2361
|
+
}
|
|
2362
|
+
var SECTIONS = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
|
|
2363
|
+
function parsePackage(source, path) {
|
|
2364
|
+
let json;
|
|
2365
|
+
try {
|
|
2366
|
+
json = JSON.parse(source);
|
|
2367
|
+
} catch (e) {
|
|
2368
|
+
return err(`${path} is not JSON (${e instanceof Error ? e.message : String(e)})`);
|
|
2369
|
+
}
|
|
2370
|
+
const o = record2(json);
|
|
2371
|
+
const dependencies = [];
|
|
2372
|
+
for (const section of SECTIONS)
|
|
2373
|
+
for (const [name, spec] of Object.entries(record2(o[section])))
|
|
2374
|
+
if (typeof spec === "string")
|
|
2375
|
+
dependencies.push({ name, spec });
|
|
2376
|
+
const ws = o["workspaces"];
|
|
2377
|
+
const nested = record2(ws)["packages"];
|
|
2378
|
+
const globs = Array.isArray(ws) ? ws : Array.isArray(nested) ? nested : [];
|
|
2379
|
+
return ok({ facts: { path, name: text(o["name"]), dependencies }, workspaces: globs.flatMap((g) => typeof g === "string" ? [g] : []) });
|
|
2380
|
+
}
|
|
2381
|
+
function relativeImports(source) {
|
|
2382
|
+
return [...source.matchAll(/(?:\bfrom\s+|\bimport\s+|\bimport\(\s*|\brequire\(\s*)["'](\.[^"']*)["']/g)].map((m) => m[1] ?? "").filter((s) => s !== "");
|
|
2383
|
+
}
|
|
2384
|
+
var SOURCE = /\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs)$/;
|
|
2385
|
+
async function installedUnder(files, root, nm, into, depth, scope) {
|
|
2386
|
+
if (depth > 4)
|
|
2387
|
+
return;
|
|
2388
|
+
for (const entry of await files.list(`${root}/${nm}`)) {
|
|
2389
|
+
if (entry === ".bun") {
|
|
2390
|
+
for (const store of await files.list(`${root}/${nm}/.bun`))
|
|
2391
|
+
await installedUnder(files, root, `${nm}/.bun/${store}/node_modules`, into, depth + 1, scope);
|
|
2392
|
+
continue;
|
|
2393
|
+
}
|
|
2394
|
+
if (entry.startsWith("."))
|
|
2395
|
+
continue;
|
|
2396
|
+
const names = entry.startsWith("@") ? (await files.list(`${root}/${nm}/${entry}`)).map((n) => `${entry}/${n}`) : [entry];
|
|
2397
|
+
for (const name of names) {
|
|
2398
|
+
const dir = `${nm}/${name}`;
|
|
2399
|
+
const manifest = await files.read(`${root}/${dir}/package.json`);
|
|
2400
|
+
if (manifest !== undefined && name.startsWith(scope)) {
|
|
2401
|
+
const r = parsePackage(manifest, `${dir}/package.json`);
|
|
2402
|
+
const version = (() => {
|
|
2403
|
+
try {
|
|
2404
|
+
return text(record2(JSON.parse(manifest))["version"]);
|
|
2405
|
+
} catch {
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2408
|
+
})();
|
|
2409
|
+
if (r.kind === "ok" && version !== undefined)
|
|
2410
|
+
add(into, name, { version, where: dir });
|
|
2411
|
+
}
|
|
2412
|
+
await installedUnder(files, root, `${dir}/node_modules`, into, depth + 1, scope);
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
async function gatherHygieneFacts(w, policy) {
|
|
2417
|
+
const all = (await w.files.walk(w.repo)).filter((p) => !p.startsWith(".git/"));
|
|
2418
|
+
const packages = [];
|
|
2419
|
+
let workspaces = [];
|
|
2420
|
+
const imports = [];
|
|
2421
|
+
for (const p of all) {
|
|
2422
|
+
if (p === "package.json" || p.endsWith("/package.json")) {
|
|
2423
|
+
const read = await w.files.read(`${w.repo}/${p}`);
|
|
2424
|
+
if (read === undefined)
|
|
2425
|
+
continue;
|
|
2426
|
+
const parsed = parsePackage(read, p);
|
|
2427
|
+
if (parsed.kind === "err")
|
|
2428
|
+
continue;
|
|
2429
|
+
packages.push(parsed.value.facts);
|
|
2430
|
+
if (p === "package.json")
|
|
2431
|
+
workspaces = parsed.value.workspaces;
|
|
2432
|
+
} else if (SOURCE.test(p)) {
|
|
2433
|
+
const read = await w.files.read(`${w.repo}/${p}`);
|
|
2434
|
+
if (read !== undefined)
|
|
2435
|
+
for (const specifier of relativeImports(read))
|
|
2436
|
+
imports.push({ file: p, specifier });
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
const locks = [];
|
|
2440
|
+
for (const [file, parse] of [["bun.lock", parseBunLock], ["package-lock.json", parseNpmLock]]) {
|
|
2441
|
+
const read = await w.files.read(`${w.repo}/${file}`);
|
|
2442
|
+
if (read !== undefined)
|
|
2443
|
+
locks.push(parse(read, file, policy.scope));
|
|
2444
|
+
}
|
|
2445
|
+
const installed = new Map;
|
|
2446
|
+
await installedUnder(w.files, w.repo, "node_modules", installed, 0, policy.scope);
|
|
2447
|
+
const repository = policy.sourceMarker !== "" && await w.files.exists(`${w.repo}/${policy.sourceMarker}`) ? "source" : "consumer";
|
|
2448
|
+
return { repository, packages, locks, installed, imports, workspaces };
|
|
2449
|
+
}
|
|
2450
|
+
export {
|
|
2451
|
+
ROLES,
|
|
2452
|
+
STAGED_NOTE,
|
|
2453
|
+
acceptName,
|
|
2454
|
+
applyQuarantine,
|
|
2455
|
+
cacheKeyOf,
|
|
2456
|
+
classesOf,
|
|
2457
|
+
classify,
|
|
2458
|
+
classifyFile,
|
|
2459
|
+
codeOf,
|
|
2460
|
+
compareSemver,
|
|
2461
|
+
confirmationPhrase,
|
|
2462
|
+
constantFindings,
|
|
2463
|
+
constantsIn,
|
|
2464
|
+
conventionName,
|
|
2465
|
+
countsOf2 as countsOf,
|
|
2466
|
+
declarationsOf,
|
|
2467
|
+
declaredNames,
|
|
2468
|
+
diagnose,
|
|
2469
|
+
docsArguments,
|
|
2470
|
+
everything,
|
|
2471
|
+
exportedNames,
|
|
2472
|
+
failedGenerator,
|
|
2473
|
+
filesOf,
|
|
2474
|
+
finding,
|
|
2475
|
+
findingsOfProgram,
|
|
2476
|
+
findingsOfPublish,
|
|
2477
|
+
findingsOfStatus,
|
|
2478
|
+
findingsOfSync,
|
|
2479
|
+
fingerprintOf,
|
|
2480
|
+
fixOf,
|
|
2481
|
+
forbidden,
|
|
2482
|
+
gate,
|
|
2483
|
+
gatherFacts,
|
|
2484
|
+
gatherHygieneFacts,
|
|
2485
|
+
generatorOf,
|
|
2486
|
+
greatest,
|
|
2487
|
+
hygiene,
|
|
2488
|
+
hygieneFails,
|
|
2489
|
+
importedPackageOf,
|
|
2490
|
+
importedPackages,
|
|
2491
|
+
importsOf,
|
|
2492
|
+
intoFamily,
|
|
2493
|
+
isExactVersion,
|
|
2494
|
+
isGitOfFamily,
|
|
2495
|
+
isMixed,
|
|
2496
|
+
isRead,
|
|
2497
|
+
joinUsage,
|
|
2498
|
+
libraryOfPath,
|
|
2499
|
+
majorOf,
|
|
2500
|
+
matches,
|
|
2501
|
+
mentionsOf,
|
|
2502
|
+
messageOf,
|
|
2503
|
+
messageText,
|
|
2504
|
+
missingGenerator,
|
|
2505
|
+
npmrcText,
|
|
2506
|
+
orderGenerators,
|
|
2507
|
+
overlap,
|
|
2508
|
+
packageOf,
|
|
2509
|
+
parseBunLock,
|
|
2510
|
+
parseNpmLock,
|
|
2511
|
+
parsePackage,
|
|
2512
|
+
partitionConflicts,
|
|
2513
|
+
pathOf,
|
|
2514
|
+
planProof,
|
|
2515
|
+
planPublish,
|
|
2516
|
+
pool,
|
|
2517
|
+
proofLabel,
|
|
2518
|
+
provesOf,
|
|
2519
|
+
reads,
|
|
2520
|
+
readsTheTree,
|
|
2521
|
+
relativeImports,
|
|
2522
|
+
reportOk,
|
|
2523
|
+
runCheck,
|
|
2524
|
+
runCommit,
|
|
2525
|
+
runMerge,
|
|
2526
|
+
runPublish,
|
|
2527
|
+
runStatus,
|
|
2528
|
+
runStep,
|
|
2529
|
+
runSync,
|
|
2530
|
+
secretLike,
|
|
2531
|
+
sectionOk,
|
|
2532
|
+
seedsOf,
|
|
2533
|
+
selectSeam,
|
|
2534
|
+
selectTests,
|
|
2535
|
+
skipSentence,
|
|
2536
|
+
specIdsOf,
|
|
2537
|
+
specOfPath,
|
|
2538
|
+
stateOf,
|
|
2539
|
+
statementsOf,
|
|
2540
|
+
stripComments,
|
|
2541
|
+
stripJsonc,
|
|
2542
|
+
surfaceDelta,
|
|
2543
|
+
tableOf,
|
|
2544
|
+
tagsOf,
|
|
2545
|
+
tailLines,
|
|
2546
|
+
tarballPath,
|
|
2547
|
+
titleOf,
|
|
2548
|
+
undeclaredFindings,
|
|
2549
|
+
usagesOf,
|
|
2550
|
+
whySentence,
|
|
2551
|
+
withRole,
|
|
2552
|
+
withoutBlockComments
|
|
2553
|
+
};
|