@skillstech/thunderlang 1.8.0 → 2.0.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/CHANGELOG.md +78 -1
- package/README.md +5 -0
- package/dist/core.cjs +73 -25
- package/dist/index.cjs +1230 -519
- package/dist/learn.cjs +89 -32
- package/package.json +17 -15
- package/src/cli-main.mjs +186 -151
- package/src/core/ThunderRuntime.cs +22 -1
- package/src/core/check.mjs +8 -0
- package/src/core/engine-core.mjs +7 -0
- package/src/core/engine-values.mjs +2 -0
- package/src/core/from-python.mjs +1 -1
- package/src/core/go-run.mjs +3 -1
- package/src/core/index.mjs +7 -2
- package/src/core/java/thunder/ThunderRuntime.java +1 -0
- package/src/core/kind.mjs +3 -0
- package/src/core/parser.mjs +22 -21
- package/src/core/project.mjs +21 -0
- package/src/core/runtime-go/thunder_runtime.go +41 -1
- package/src/core/rust/thunder_runtime.rs +1 -0
- package/src/core/target-csharp.mjs +14 -0
- package/src/core/target-go.mjs +14 -0
- package/src/core/target-java.mjs +14 -0
- package/src/core/target-python.mjs +8 -0
- package/src/core/target-rust.mjs +14 -0
- package/src/core/target-typescript.mjs +14 -0
- package/src/core-changes-fs.mjs +1 -1
- package/src/emit.mjs +3 -3
- package/src/evidence-words.d.mts +6 -0
- package/src/evidence-words.mjs +47 -0
- package/src/evidence.mjs +8 -1
- package/src/index.d.ts +15 -0
- package/src/index.mjs +4 -1
- package/src/learn-lessons.mjs +1 -1
- package/src/lsp.mjs +110 -0
- package/src/mcp.mjs +5 -9
- package/src/obligations.d.mts +5 -0
- package/src/obligations.mjs +30 -2
- package/src/program.d.mts +3 -0
- package/src/program.mjs +3 -0
- package/src/review.mjs +6 -3
- package/src/same.mjs +16 -6
- package/src/scan-queries.mjs +2 -1
- package/src/symbols.d.mts +23 -0
- package/src/symbols.mjs +351 -0
- package/src/template.d.mts +31 -0
- package/src/template.mjs +189 -0
package/dist/index.cjs
CHANGED
|
@@ -9,9 +9,9 @@ var __export = (target, all) => {
|
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let
|
|
13
|
-
if (!__hasOwnProp.call(to,
|
|
14
|
-
__defProp(to,
|
|
12
|
+
for (let key2 of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
14
|
+
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
@@ -30,6 +30,7 @@ __export(index_exports, {
|
|
|
30
30
|
BLOCKABLE_PHASES: () => BLOCKABLE_PHASES,
|
|
31
31
|
BRAND_PATHS: () => BRAND_PATHS,
|
|
32
32
|
CHANGES_SCHEMA: () => CHANGES_SCHEMA,
|
|
33
|
+
CLAIM_STATUS: () => CLAIM_STATUS,
|
|
33
34
|
CLAIM_STATUSES: () => CLAIM_STATUSES,
|
|
34
35
|
CLASSIFICATIONS: () => CLASSIFICATIONS,
|
|
35
36
|
CODEGEN_SCHEMA: () => CODEGEN_SCHEMA,
|
|
@@ -49,6 +50,8 @@ __export(index_exports, {
|
|
|
49
50
|
ENTRY_TYPES: () => ENTRY_TYPES,
|
|
50
51
|
ERROR_KINDS: () => ERROR_KINDS,
|
|
51
52
|
EVENT_LOG_SCHEMA: () => EVENT_LOG_SCHEMA,
|
|
53
|
+
EVIDENCE_LEVELS: () => EVIDENCE_LEVELS,
|
|
54
|
+
EVIDENCE_WORDS: () => EVIDENCE_WORDS,
|
|
52
55
|
EXAMPLES_SCHEMA: () => EXAMPLES_SCHEMA,
|
|
53
56
|
EXPORT_FORMATS: () => EXPORT_FORMATS,
|
|
54
57
|
EXPR_SCHEMA: () => EXPR_SCHEMA,
|
|
@@ -130,6 +133,7 @@ __export(index_exports, {
|
|
|
130
133
|
STYLE_SCHEMA: () => STYLE_SCHEMA,
|
|
131
134
|
SUPPORTED_LANGUAGES: () => SUPPORTED_LANGUAGES,
|
|
132
135
|
SYNC_SCHEMA: () => SYNC_SCHEMA,
|
|
136
|
+
TEMPLATE_SCHEMA: () => TEMPLATE_SCHEMA,
|
|
133
137
|
TEST_SCHEMA: () => TEST_SCHEMA,
|
|
134
138
|
THUNDER_TEXT_EXT: () => THUNDER_TEXT_EXT,
|
|
135
139
|
THUNDER_VISUAL: () => THUNDER_VISUAL,
|
|
@@ -154,6 +158,7 @@ __export(index_exports, {
|
|
|
154
158
|
analyzePrivacy: () => analyzePrivacy,
|
|
155
159
|
analyzeStyle: () => analyzeStyle,
|
|
156
160
|
applyEdits: () => applyEdits,
|
|
161
|
+
applyRename: () => applyRename,
|
|
157
162
|
applyWaivers: () => applyWaivers,
|
|
158
163
|
approvalFor: () => approvalFor,
|
|
159
164
|
approvalsFor: () => approvalsFor,
|
|
@@ -185,8 +190,10 @@ __export(index_exports, {
|
|
|
185
190
|
checkDrift: () => checkDrift,
|
|
186
191
|
checkPassport: () => checkPassport,
|
|
187
192
|
checkPassportOnDisk: () => checkPassportOnDisk,
|
|
193
|
+
claimStatus: () => claimStatus,
|
|
188
194
|
classify: () => classify,
|
|
189
195
|
collectReadableFiles: () => collectReadableFiles,
|
|
196
|
+
combineEvidence: () => combineEvidence,
|
|
190
197
|
compileExpr: () => compileExpr,
|
|
191
198
|
compileGuard: () => compileGuard,
|
|
192
199
|
compileSource: () => compileSource,
|
|
@@ -201,6 +208,7 @@ __export(index_exports, {
|
|
|
201
208
|
coreServiceFacts: () => coreServiceFacts,
|
|
202
209
|
correctionsFor: () => correctionsFor,
|
|
203
210
|
coverageView: () => coverageView,
|
|
211
|
+
definitionsAt: () => definitionsAt,
|
|
204
212
|
describeEdit: () => describeEdit,
|
|
205
213
|
detailOf: () => detailOf,
|
|
206
214
|
detectConflicts: () => detectConflicts,
|
|
@@ -219,6 +227,8 @@ __export(index_exports, {
|
|
|
219
227
|
evaluateOutcomes: () => evaluateOutcomes,
|
|
220
228
|
eventsFor: () => eventsFor,
|
|
221
229
|
eventsOfType: () => eventsOfType,
|
|
230
|
+
evidenceMeaning: () => evidenceMeaning,
|
|
231
|
+
evidenceWord: () => evidenceWord,
|
|
222
232
|
examplesOf: () => examplesOf,
|
|
223
233
|
expandNode: () => expandNode,
|
|
224
234
|
explain: () => explain,
|
|
@@ -307,7 +317,9 @@ __export(index_exports, {
|
|
|
307
317
|
recordRejection: () => recordRejection,
|
|
308
318
|
recordRiskAcceptance: () => recordRiskAcceptance,
|
|
309
319
|
recordVerification: () => recordVerification,
|
|
320
|
+
referencesAt: () => referencesAt,
|
|
310
321
|
regionMetrics: () => regionMetrics,
|
|
322
|
+
renameAt: () => renameAt,
|
|
311
323
|
renameNodeType: () => renameNodeType,
|
|
312
324
|
renameRelationshipType: () => renameRelationshipType,
|
|
313
325
|
renderLensDoc: () => renderLensDoc,
|
|
@@ -358,6 +370,8 @@ __export(index_exports, {
|
|
|
358
370
|
stepRoundTrip: () => stepRoundTrip,
|
|
359
371
|
styleDiagnostics: () => styleDiagnostics,
|
|
360
372
|
subjectName: () => subjectName,
|
|
373
|
+
symbolAt: () => symbolAt,
|
|
374
|
+
templateOf: () => templateOf,
|
|
361
375
|
thunderReview: () => thunderReview,
|
|
362
376
|
thunderText: () => thunderText,
|
|
363
377
|
thunderWrite: () => thunderWrite,
|
|
@@ -1170,8 +1184,8 @@ function parseIntent(source) {
|
|
|
1170
1184
|
if (k === "given") {
|
|
1171
1185
|
for (const pair2 of a.split(",")) {
|
|
1172
1186
|
const bits = pair2.trim().split(/\s+/);
|
|
1173
|
-
const
|
|
1174
|
-
if (
|
|
1187
|
+
const key2 = bits.shift();
|
|
1188
|
+
if (key2) cs.given[key2] = bits.join(" ");
|
|
1175
1189
|
}
|
|
1176
1190
|
} else if (k === "expect") cs.expect = a;
|
|
1177
1191
|
else if (k === "events") cs.events = a.split(",").map((s) => s.trim()).filter(Boolean);
|
|
@@ -1455,7 +1469,34 @@ function sha256hex(input) {
|
|
|
1455
1469
|
}
|
|
1456
1470
|
var sha256 = (s) => `sha256:${sha256hex(String(s))}`;
|
|
1457
1471
|
|
|
1472
|
+
// src/evidence-words.mjs
|
|
1473
|
+
var EVIDENCE_LEVELS = ["proven", "tested", "partial", "unverified", "violated"];
|
|
1474
|
+
var EVIDENCE_WORDS = {
|
|
1475
|
+
proven: { word: "Proven", means: "holds for every possible input: checked exhaustively, or proved by a solver" },
|
|
1476
|
+
tested: { word: "Tested", means: "passed on the cases that ran, and only on those" },
|
|
1477
|
+
partial: { word: "Partially checked", means: "some parts are checked and passed; others are not checked yet" },
|
|
1478
|
+
unverified: { word: "Unverified", means: "nothing checks it yet" },
|
|
1479
|
+
violated: { word: "Violated", means: "a check failed: there is a case where it does not hold" }
|
|
1480
|
+
};
|
|
1481
|
+
function evidenceWord(level) {
|
|
1482
|
+
return EVIDENCE_WORDS[level]?.word ?? null;
|
|
1483
|
+
}
|
|
1484
|
+
function evidenceMeaning(level) {
|
|
1485
|
+
const w = EVIDENCE_WORDS[level];
|
|
1486
|
+
return w ? `${w.word}: ${w.means}` : null;
|
|
1487
|
+
}
|
|
1488
|
+
function combineEvidence(levels) {
|
|
1489
|
+
const ls = [...levels].filter((l) => EVIDENCE_LEVELS.includes(l));
|
|
1490
|
+
if (!ls.length) return "unverified";
|
|
1491
|
+
if (ls.includes("violated")) return "violated";
|
|
1492
|
+
if (ls.every((l) => l === "proven")) return "proven";
|
|
1493
|
+
if (ls.every((l) => l === "proven" || l === "tested")) return "tested";
|
|
1494
|
+
if (ls.every((l) => l === "unverified")) return "unverified";
|
|
1495
|
+
return "partial";
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1458
1498
|
// src/evidence.mjs
|
|
1499
|
+
var CLAIM_EVIDENCE = { verified: "tested", failed: "violated", planned: "unverified", needs_verification: "unverified" };
|
|
1459
1500
|
var COUNTED_STATUSES = ["verified", "failed", "planned", "needs_verification"];
|
|
1460
1501
|
var stripHash = (h) => String(h || "").replace(/^sha256:/, "");
|
|
1461
1502
|
var short = (h, n = 16) => stripHash(h).slice(0, n);
|
|
@@ -1473,7 +1514,7 @@ function envelope(eventType, evidenceId, ctx = {}, payload = {}) {
|
|
|
1473
1514
|
payload
|
|
1474
1515
|
};
|
|
1475
1516
|
}
|
|
1476
|
-
var safeClaim = (kind, c) => ({ id: c.id, kind, status: c.status, provenBy: c.provenBy || null });
|
|
1517
|
+
var safeClaim = (kind, c) => ({ id: c.id, kind, status: c.status, evidence: c.evidenceLevel || CLAIM_EVIDENCE[c.status] || "unverified", provenBy: c.provenBy || null });
|
|
1477
1518
|
function countByStatus(claims) {
|
|
1478
1519
|
const counts = Object.fromEntries(COUNTED_STATUSES.map((s) => [s, 0]));
|
|
1479
1520
|
for (const c of claims) if (c && Object.prototype.hasOwnProperty.call(counts, c.status)) counts[c.status]++;
|
|
@@ -1499,6 +1540,7 @@ function toEvidenceEvents(proof) {
|
|
|
1499
1540
|
proofStatus: proof.proofStatus || null,
|
|
1500
1541
|
total: claims.length,
|
|
1501
1542
|
counts: countByStatus(claims),
|
|
1543
|
+
evidence: combineEvidence(claims.map((c) => c.evidence)),
|
|
1502
1544
|
freshness: { implementation: fr.implementation || null, dependencies: fr.dependencies ? fr.dependencies.hash || null : null, environment: fr.environment || null },
|
|
1503
1545
|
claims
|
|
1504
1546
|
})];
|
|
@@ -2461,8 +2503,8 @@ function isRecognizedType(type) {
|
|
|
2461
2503
|
if (!t) return true;
|
|
2462
2504
|
const listMatch = t.match(/^(?:List|Array)<(.+)>$/i);
|
|
2463
2505
|
if (listMatch) return isRecognizedType(listMatch[1]);
|
|
2464
|
-
const
|
|
2465
|
-
if (SEMANTIC[
|
|
2506
|
+
const key2 = t.toLowerCase();
|
|
2507
|
+
if (SEMANTIC[key2] || PRIMITIVE[key2]) return true;
|
|
2466
2508
|
if (/id$/i.test(t)) return true;
|
|
2467
2509
|
if (/^[A-Z]/.test(t)) return true;
|
|
2468
2510
|
return false;
|
|
@@ -2471,13 +2513,13 @@ function typeToJsonSchema(type) {
|
|
|
2471
2513
|
const t = String(type || "").trim();
|
|
2472
2514
|
const listMatch = t.match(/^List<(.+)>$/i) || t.match(/^Array<(.+)>$/i);
|
|
2473
2515
|
if (listMatch) return { type: "array", items: typeToJsonSchema(listMatch[1]) };
|
|
2474
|
-
const
|
|
2516
|
+
const key2 = t.toLowerCase();
|
|
2475
2517
|
const units = moneyTypeMinorUnits(t);
|
|
2476
|
-
if (units != null &&
|
|
2518
|
+
if (units != null && key2 !== "money") {
|
|
2477
2519
|
return { type: "string", pattern: units ? `^-?[0-9]+(\\.[0-9]{1,${units}})?$` : "^-?[0-9]+$", description: `Thunder Money: an exact decimal amount with up to ${units} minor units, as a string.` };
|
|
2478
2520
|
}
|
|
2479
|
-
if (SEMANTIC[
|
|
2480
|
-
if (PRIMITIVE[
|
|
2521
|
+
if (SEMANTIC[key2]) return { ...SEMANTIC[key2] };
|
|
2522
|
+
if (PRIMITIVE[key2]) return { ...PRIMITIVE[key2] };
|
|
2481
2523
|
if (/id$/i.test(t)) return { type: "string", title: t };
|
|
2482
2524
|
return { type: "object", title: t };
|
|
2483
2525
|
}
|
|
@@ -2596,7 +2638,7 @@ function notesSummary(ast) {
|
|
|
2596
2638
|
byLens
|
|
2597
2639
|
};
|
|
2598
2640
|
}
|
|
2599
|
-
var COMPILER_VERSION = "
|
|
2641
|
+
var COMPILER_VERSION = "2.0.0";
|
|
2600
2642
|
var PROOF_SCHEMA_VERSION = "0.1.0";
|
|
2601
2643
|
var SOURCE_PRODUCT = "skillstech-compiler";
|
|
2602
2644
|
function buildContractGraph(ast, generatedAt) {
|
|
@@ -3070,7 +3112,6 @@ function semanticDiagnostics(ast) {
|
|
|
3070
3112
|
}
|
|
3071
3113
|
function buildProof(ast, { sourceFile, sourceHash, targetsRequested, targetsGenerated, diagnostics, generatedAt, origin = "authored" }) {
|
|
3072
3114
|
const passedSemantic = !diagnostics.some((x) => x.level === "error");
|
|
3073
|
-
const verifiedText = ast.verify.join(" ").toLowerCase();
|
|
3074
3115
|
return {
|
|
3075
3116
|
schemaVersion: PROOF_SCHEMA_VERSION,
|
|
3076
3117
|
sourceProduct: SOURCE_PRODUCT,
|
|
@@ -3088,7 +3129,8 @@ function buildProof(ast, { sourceFile, sourceHash, targetsRequested, targetsGene
|
|
|
3088
3129
|
guarantees: ast.guarantees.map((g) => ({
|
|
3089
3130
|
id: g.id,
|
|
3090
3131
|
text: g.statement,
|
|
3091
|
-
|
|
3132
|
+
// planned only when this guarantee names its own check; a verify block elsewhere in the mission doesn't count.
|
|
3133
|
+
status: g.verify.length > 0 ? "planned" : "needs_verification",
|
|
3092
3134
|
evidence: g.verify,
|
|
3093
3135
|
verifications: g.verifications || []
|
|
3094
3136
|
})),
|
|
@@ -3202,20 +3244,20 @@ function validateProof(proof) {
|
|
|
3202
3244
|
if (isStr(proof.sourceHash) && !/^sha256:[0-9a-f]{64}$/.test(proof.sourceHash)) {
|
|
3203
3245
|
err("sourceHash", 'sourceHash must be "sha256:<64 hex chars>"');
|
|
3204
3246
|
}
|
|
3205
|
-
for (const
|
|
3206
|
-
const list3 = proof[
|
|
3247
|
+
for (const key2 of ["guarantees", "neverRules"]) {
|
|
3248
|
+
const list3 = proof[key2];
|
|
3207
3249
|
if (!Array.isArray(list3)) {
|
|
3208
|
-
err(
|
|
3250
|
+
err(key2, `${key2} must be an array`);
|
|
3209
3251
|
continue;
|
|
3210
3252
|
}
|
|
3211
3253
|
list3.forEach((c, i) => {
|
|
3212
3254
|
if (c === null || typeof c !== "object") {
|
|
3213
|
-
err(`${
|
|
3255
|
+
err(`${key2}[${i}]`, "claim must be an object");
|
|
3214
3256
|
return;
|
|
3215
3257
|
}
|
|
3216
|
-
if (!isStr(c.text)) err(`${
|
|
3217
|
-
if (!CLAIM_STATUSES.includes(c.status)) err(`${
|
|
3218
|
-
if (c.evidence !== void 0 && !Array.isArray(c.evidence)) err(`${
|
|
3258
|
+
if (!isStr(c.text)) err(`${key2}[${i}].text`, "claim text must be a string");
|
|
3259
|
+
if (!CLAIM_STATUSES.includes(c.status)) err(`${key2}[${i}].status`, `status must be one of ${CLAIM_STATUSES.join(", ")}`);
|
|
3260
|
+
if (c.evidence !== void 0 && !Array.isArray(c.evidence)) err(`${key2}[${i}].evidence`, "evidence must be an array");
|
|
3219
3261
|
});
|
|
3220
3262
|
}
|
|
3221
3263
|
const v = proof.verification;
|
|
@@ -3815,9 +3857,9 @@ function extractFactsPerl(source, file = "input.pl") {
|
|
|
3815
3857
|
const dieRe = /\b(?:die|croak|confess)\s+["']([^"']+)["']/g;
|
|
3816
3858
|
while (m = dieRe.exec(source)) {
|
|
3817
3859
|
const s = m[1].replace(/\\n$/, "").trim().slice(0, 60);
|
|
3818
|
-
const
|
|
3819
|
-
if (s && !seenErr.has(
|
|
3820
|
-
seenErr.add(
|
|
3860
|
+
const key2 = s.toLowerCase();
|
|
3861
|
+
if (s && !seenErr.has(key2)) {
|
|
3862
|
+
seenErr.add(key2);
|
|
3821
3863
|
errors.push({ name: s, file, line: lineOf(source, m.index) });
|
|
3822
3864
|
}
|
|
3823
3865
|
}
|
|
@@ -4251,9 +4293,9 @@ var ADAPTERS = {
|
|
|
4251
4293
|
exs: extractFactsElixir
|
|
4252
4294
|
};
|
|
4253
4295
|
function extractFacts(source, language, file) {
|
|
4254
|
-
const
|
|
4255
|
-
const adapter = ADAPTERS[
|
|
4256
|
-
return adapter ? adapter(String(source), file || `input.${LANG_EXT[
|
|
4296
|
+
const key2 = String(language).toLowerCase();
|
|
4297
|
+
const adapter = ADAPTERS[key2];
|
|
4298
|
+
return adapter ? adapter(String(source), file || `input.${LANG_EXT[key2] || "txt"}`) : null;
|
|
4257
4299
|
}
|
|
4258
4300
|
var SUPPORTED_LANGUAGES = ["typescript", "javascript", "python", "java", "csharp", "go", "rust", "c", "cpp", "swift", "php", "ruby", "perl", "kotlin", "scala", "elixir"];
|
|
4259
4301
|
var DYNAMIC_LANGUAGES = /* @__PURE__ */ new Set(["perl", "javascript", "python", "ruby", "php", "elixir"]);
|
|
@@ -4348,7 +4390,7 @@ function renderLiftedIntent(lift) {
|
|
|
4348
4390
|
const t = s.nodeType ? ` ${s.nodeType}` : "";
|
|
4349
4391
|
const c = s.confidence ? ` confidence:${s.confidence}` : "";
|
|
4350
4392
|
L.push(`# ${s.nodeId}${t}${c}${s.title ? ` , ${s.title}` : ""}`);
|
|
4351
|
-
for (const
|
|
4393
|
+
for (const loc2 of s.evidenceRef.sourceLocations) L.push(`# at ${loc2.file}${loc2.line ? `:${loc2.line}` : ""}`);
|
|
4352
4394
|
for (const sig of s.evidenceRef.signals.slice(0, 5)) L.push(`# signal: ${sig}`);
|
|
4353
4395
|
if (s.evidenceRef.ledgerRef) L.push(`# ledger: seq ${s.evidenceRef.ledgerRef.seq} ${s.evidenceRef.ledgerRef.hash}`);
|
|
4354
4396
|
}
|
|
@@ -4417,14 +4459,14 @@ function isPublicFn(fn, language) {
|
|
|
4417
4459
|
return !name.startsWith("_") && name !== "init" && name !== "constructor";
|
|
4418
4460
|
}
|
|
4419
4461
|
function liftAll(source, { language = "typescript", file = "", publicOnly = true } = {}) {
|
|
4420
|
-
const
|
|
4421
|
-
const adapter = ADAPTERS[
|
|
4462
|
+
const key2 = String(language).toLowerCase();
|
|
4463
|
+
const adapter = ADAPTERS[key2];
|
|
4422
4464
|
if (!adapter) return { ok: false, error: `Unsupported language "${language}". Supported: ${SUPPORTED_LANGUAGES.join(", ")}.` };
|
|
4423
|
-
const resolvedFile = file || `input.${LANG_EXT[
|
|
4465
|
+
const resolvedFile = file || `input.${LANG_EXT[key2] || "txt"}`;
|
|
4424
4466
|
const codeFacts = adapter(source, resolvedFile);
|
|
4425
4467
|
let fns = codeFacts.functions;
|
|
4426
4468
|
if (publicOnly) {
|
|
4427
|
-
const pub = fns.filter((f) => isPublicFn(f,
|
|
4469
|
+
const pub = fns.filter((f) => isPublicFn(f, key2));
|
|
4428
4470
|
if (pub.length) fns = pub;
|
|
4429
4471
|
}
|
|
4430
4472
|
if (!fns.length) return { ok: false, error: "No functions found to infer intent from.", codeFacts };
|
|
@@ -4496,12 +4538,12 @@ var LANG_EXT = {
|
|
|
4496
4538
|
elixir: "ex"
|
|
4497
4539
|
};
|
|
4498
4540
|
function liftSource(source, { language = "typescript", file = "", seeds = void 0 } = {}) {
|
|
4499
|
-
const
|
|
4500
|
-
const adapter = ADAPTERS[
|
|
4541
|
+
const key2 = String(language).toLowerCase();
|
|
4542
|
+
const adapter = ADAPTERS[key2];
|
|
4501
4543
|
if (!adapter) {
|
|
4502
4544
|
return { ok: false, error: `Unsupported language "${language}". Supported: ${SUPPORTED_LANGUAGES.join(", ")}.` };
|
|
4503
4545
|
}
|
|
4504
|
-
const resolvedFile = file || `input.${LANG_EXT[
|
|
4546
|
+
const resolvedFile = file || `input.${LANG_EXT[key2] || "txt"}`;
|
|
4505
4547
|
const codeFacts = adapter(source, resolvedFile);
|
|
4506
4548
|
const lifted = inferIntent(codeFacts);
|
|
4507
4549
|
if (!lifted) {
|
|
@@ -5747,6 +5789,21 @@ function runTests(ast) {
|
|
|
5747
5789
|
}
|
|
5748
5790
|
|
|
5749
5791
|
// src/obligations.mjs
|
|
5792
|
+
var CLAIM_STATUS = { verified: "verified", failed: "failed", declared: "planned", unverified: "needs_verification" };
|
|
5793
|
+
var claimStatus = (status) => CLAIM_STATUS[status] ?? "needs_verification";
|
|
5794
|
+
function foldObligations(proof, resolved) {
|
|
5795
|
+
const byId = new Map(resolved.obligations.filter((o) => o.id).map((o) => [o.id, o]));
|
|
5796
|
+
const fold = (claims, kind) => {
|
|
5797
|
+
const ofKind = resolved.obligations.filter((o) => o.kind === kind);
|
|
5798
|
+
return claims.map((claim, i) => {
|
|
5799
|
+
const o = claim.id && byId.get(claim.id) || ofKind[i];
|
|
5800
|
+
return o ? { ...claim, status: claimStatus(o.status), provenBy: o.provenBy || null, evidenceLevel: o.evidenceLevel, evidenceWord: o.evidenceWord } : claim;
|
|
5801
|
+
});
|
|
5802
|
+
};
|
|
5803
|
+
proof.guarantees = fold(proof.guarantees, "guarantee");
|
|
5804
|
+
proof.neverRules = fold(proof.neverRules, "prohibition");
|
|
5805
|
+
return proof;
|
|
5806
|
+
}
|
|
5750
5807
|
function resolveObligations(ast) {
|
|
5751
5808
|
const tests = runTests(ast);
|
|
5752
5809
|
const byTarget = /* @__PURE__ */ new Map();
|
|
@@ -5755,17 +5812,20 @@ function resolveObligations(ast) {
|
|
|
5755
5812
|
const previous = byTarget.get(name);
|
|
5756
5813
|
byTarget.set(name, { name, pass: (previous?.pass ?? true) && result.pass, cases: (previous?.cases ?? 0) + 1 });
|
|
5757
5814
|
}
|
|
5758
|
-
const
|
|
5815
|
+
const build2 = (kind, claim) => {
|
|
5759
5816
|
const verify = claim.verify || [];
|
|
5760
5817
|
const names = [...new Set(verify.map((v) => String(v).trim()))];
|
|
5761
5818
|
const evidence2 = names.map((name) => byTarget.get(name) || (name.startsWith("test ") ? byTarget.get(name.slice(5).trim()) : null) || { name, pass: null, cases: 0 });
|
|
5762
5819
|
const unresolved = evidence2.filter((e) => e.pass === null).map((e) => e.name);
|
|
5763
5820
|
const status = !names.length ? "unverified" : evidence2.some((e) => e.pass === false) ? "failed" : unresolved.length ? "declared" : "verified";
|
|
5821
|
+
const evidenceLevel = combineEvidence(evidence2.map((e) => e.pass === true ? "tested" : e.pass === false ? "violated" : "unverified"));
|
|
5764
5822
|
return {
|
|
5765
5823
|
kind,
|
|
5766
5824
|
id: claim.id,
|
|
5767
5825
|
text: claim.statement,
|
|
5768
5826
|
status,
|
|
5827
|
+
evidenceLevel,
|
|
5828
|
+
evidenceWord: evidenceWord(evidenceLevel),
|
|
5769
5829
|
verify,
|
|
5770
5830
|
kinds: [...new Set((claim.verifications || []).map((v) => v.kind).filter((k) => k && k !== "unclassified"))],
|
|
5771
5831
|
provenBy: status === "verified" || status === "failed" ? evidence2.filter((e) => e.pass !== null).map((e) => e.name).join(", ") : null,
|
|
@@ -5774,11 +5834,20 @@ function resolveObligations(ast) {
|
|
|
5774
5834
|
};
|
|
5775
5835
|
};
|
|
5776
5836
|
const obligations = [
|
|
5777
|
-
...(ast.guarantees || []).map((g) =>
|
|
5778
|
-
...(ast.neverRules || []).map((n) =>
|
|
5837
|
+
...(ast.guarantees || []).map((g) => build2("guarantee", g)),
|
|
5838
|
+
...(ast.neverRules || []).map((n) => build2("prohibition", n))
|
|
5779
5839
|
];
|
|
5780
5840
|
const count2 = (s) => obligations.filter((o) => o.status === s).length;
|
|
5781
|
-
|
|
5841
|
+
const byLevel = (l) => obligations.filter((o) => o.evidenceLevel === l).length;
|
|
5842
|
+
return {
|
|
5843
|
+
obligations,
|
|
5844
|
+
tests,
|
|
5845
|
+
verified: count2("verified"),
|
|
5846
|
+
declared: count2("declared"),
|
|
5847
|
+
unverified: count2("unverified"),
|
|
5848
|
+
failed: count2("failed"),
|
|
5849
|
+
evidence: { tested: byLevel("tested"), partial: byLevel("partial"), unverified: byLevel("unverified"), violated: byLevel("violated") }
|
|
5850
|
+
};
|
|
5782
5851
|
}
|
|
5783
5852
|
|
|
5784
5853
|
// src/review-atlas.mjs
|
|
@@ -5991,7 +6060,7 @@ function diffGraphs(before, after) {
|
|
|
5991
6060
|
};
|
|
5992
6061
|
}
|
|
5993
6062
|
function mergeGraphs(base2, ours, theirs) {
|
|
5994
|
-
const
|
|
6063
|
+
const key2 = (n) => n ? contentKey(n) : "MISSING";
|
|
5995
6064
|
const bN = new Map((base2?.nodes || []).map((n) => [n.id, n]));
|
|
5996
6065
|
const oN = new Map((ours?.nodes || []).map((n) => [n.id, n]));
|
|
5997
6066
|
const tN = new Map((theirs?.nodes || []).map((n) => [n.id, n]));
|
|
@@ -6002,8 +6071,8 @@ function mergeGraphs(base2, ours, theirs) {
|
|
|
6002
6071
|
const b = bN.get(id2) || null;
|
|
6003
6072
|
const o = oN.get(id2) || null;
|
|
6004
6073
|
const t = tN.get(id2) || null;
|
|
6005
|
-
const oChanged =
|
|
6006
|
-
const tChanged =
|
|
6074
|
+
const oChanged = key2(o) !== key2(b);
|
|
6075
|
+
const tChanged = key2(t) !== key2(b);
|
|
6007
6076
|
if (!oChanged && !tChanged) {
|
|
6008
6077
|
if (b) merged.set(id2, b);
|
|
6009
6078
|
continue;
|
|
@@ -6016,7 +6085,7 @@ function mergeGraphs(base2, ours, theirs) {
|
|
|
6016
6085
|
if (t) merged.set(id2, t);
|
|
6017
6086
|
continue;
|
|
6018
6087
|
}
|
|
6019
|
-
if (
|
|
6088
|
+
if (key2(o) === key2(t)) {
|
|
6020
6089
|
if (o) merged.set(id2, o);
|
|
6021
6090
|
continue;
|
|
6022
6091
|
}
|
|
@@ -7443,18 +7512,18 @@ function fieldRange(lines, block, name) {
|
|
|
7443
7512
|
function removeField(lines, section, name) {
|
|
7444
7513
|
const block = blocks(lines).find((b) => b.keyword === section);
|
|
7445
7514
|
if (!block) return { ok: false, reason: `no ${section} block` };
|
|
7446
|
-
const
|
|
7447
|
-
if (!
|
|
7448
|
-
return { ok: true, lines: [...lines.slice(0,
|
|
7515
|
+
const range2 = fieldRange(lines, block, name);
|
|
7516
|
+
if (!range2) return { ok: false, reason: `field "${name}" not found in ${section}` };
|
|
7517
|
+
return { ok: true, lines: [...lines.slice(0, range2.start), ...lines.slice(range2.end + 1)] };
|
|
7449
7518
|
}
|
|
7450
7519
|
function setFieldType(lines, section, name, type) {
|
|
7451
7520
|
const block = blocks(lines).find((b) => b.keyword === section);
|
|
7452
7521
|
if (!block) return { ok: false, reason: `no ${section} block` };
|
|
7453
|
-
const
|
|
7454
|
-
if (!
|
|
7455
|
-
const ind = lines[
|
|
7522
|
+
const range2 = fieldRange(lines, block, name);
|
|
7523
|
+
if (!range2) return { ok: false, reason: `field "${name}" not found in ${section}` };
|
|
7524
|
+
const ind = lines[range2.start].slice(0, indentOf(lines[range2.start]));
|
|
7456
7525
|
const rebuilt = `${ind}${name}: ${type}`;
|
|
7457
|
-
return { ok: true, lines: [...lines.slice(0,
|
|
7526
|
+
return { ok: true, lines: [...lines.slice(0, range2.start), rebuilt, ...lines.slice(range2.start + 1)] };
|
|
7458
7527
|
}
|
|
7459
7528
|
var findNamedBlock = (lines, keyword, name) => blocks(lines).find((b) => b.keyword === keyword && restOf(b.header) === name) || null;
|
|
7460
7529
|
function removeNamedBlock(lines, keyword, name) {
|
|
@@ -8088,9 +8157,9 @@ function scanProject(files) {
|
|
|
8088
8157
|
perFile.push(r.summary);
|
|
8089
8158
|
allFindings.push(...r.findings);
|
|
8090
8159
|
for (const n of r.ir.nodes) {
|
|
8091
|
-
const
|
|
8092
|
-
if (!seenNodeIds.has(
|
|
8093
|
-
seenNodeIds.add(
|
|
8160
|
+
const key2 = `${file}:${n.id}`;
|
|
8161
|
+
if (!seenNodeIds.has(key2)) {
|
|
8162
|
+
seenNodeIds.add(key2);
|
|
8094
8163
|
irNodes.push({ ...n, id: `${file ? `${file}#` : ""}${n.id}` });
|
|
8095
8164
|
}
|
|
8096
8165
|
}
|
|
@@ -8905,9 +8974,9 @@ var BUILDERS = {
|
|
|
8905
8974
|
py: buildPython
|
|
8906
8975
|
};
|
|
8907
8976
|
function generateWithDiagnostics(ast, target) {
|
|
8908
|
-
const
|
|
8909
|
-
if (!
|
|
8910
|
-
return
|
|
8977
|
+
const build2 = BUILDERS[String(target).toLowerCase()];
|
|
8978
|
+
if (!build2) throw new Error(`Unknown generation target "${target}". Use one of: ${Object.keys(BUILDERS).join(", ")}.`);
|
|
8979
|
+
return build2(ast);
|
|
8911
8980
|
}
|
|
8912
8981
|
var GENERATORS = {
|
|
8913
8982
|
typescript: toTypeScript,
|
|
@@ -9609,10 +9678,10 @@ function typedInputs(params, values, kinds, { odd = true } = {}) {
|
|
|
9609
9678
|
return values;
|
|
9610
9679
|
};
|
|
9611
9680
|
const pools = params.map((p) => pool(kinds[p.name]));
|
|
9612
|
-
const
|
|
9681
|
+
const key2 = (a) => JSON.stringify(a);
|
|
9613
9682
|
const seen = /* @__PURE__ */ new Set(), out = [];
|
|
9614
9683
|
const push = (a) => {
|
|
9615
|
-
const k =
|
|
9684
|
+
const k = key2(a);
|
|
9616
9685
|
if (!seen.has(k)) {
|
|
9617
9686
|
seen.add(k);
|
|
9618
9687
|
out.push(a);
|
|
@@ -9639,7 +9708,7 @@ function typedInputs(params, values, kinds, { odd = true } = {}) {
|
|
|
9639
9708
|
while (out.length < MAX_INPUTS) push(pools.map((p) => p[Math.floor(rand() * p.length)]));
|
|
9640
9709
|
}
|
|
9641
9710
|
if (odd) {
|
|
9642
|
-
for (let j = 0; j < params.length; j++) for (const v of values) if (!pools[j].some((x) =>
|
|
9711
|
+
for (let j = 0; j < params.length; j++) for (const v of values) if (!pools[j].some((x) => key2(x) === key2(v))) push(pools.map((p, i) => i === j ? v : p[0]));
|
|
9643
9712
|
}
|
|
9644
9713
|
return out;
|
|
9645
9714
|
}
|
|
@@ -11307,9 +11376,9 @@ var Parser = class {
|
|
|
11307
11376
|
hashPairsInline() {
|
|
11308
11377
|
const entries = [];
|
|
11309
11378
|
while (!this.isOp(")") && this.peek().t !== "eof") {
|
|
11310
|
-
const
|
|
11379
|
+
const key2 = this.expr(0.6);
|
|
11311
11380
|
this.eat("=>");
|
|
11312
|
-
entries.push({ key, value: this.expr(0.6) });
|
|
11381
|
+
entries.push({ key: key2, value: this.expr(0.6) });
|
|
11313
11382
|
if (this.isOp(",")) this.next();
|
|
11314
11383
|
else break;
|
|
11315
11384
|
}
|
|
@@ -11533,15 +11602,15 @@ var Parser = class {
|
|
|
11533
11602
|
entries.push({ kind: "spread", value: this.expr(0.6), form: "..." });
|
|
11534
11603
|
} else if (t.t === "op" && t.v === "[") {
|
|
11535
11604
|
this.next();
|
|
11536
|
-
const
|
|
11605
|
+
const key2 = this.expr(0);
|
|
11537
11606
|
this.eat("]");
|
|
11538
11607
|
this.eat(":");
|
|
11539
|
-
entries.push({ key, value: this.expr(0.6), computed: true });
|
|
11608
|
+
entries.push({ key: key2, value: this.expr(0.6), computed: true });
|
|
11540
11609
|
} else if ((t.t === "id" || t.t === "str" || t.t === "num") && this.isOp(":", 1)) {
|
|
11541
11610
|
this.next();
|
|
11542
11611
|
this.next();
|
|
11543
|
-
const
|
|
11544
|
-
entries.push({ key, value: this.expr(0.6) });
|
|
11612
|
+
const key2 = t.t === "id" ? { kind: "literal", type: "text", value: t.v, raw: t.v } : t.t === "num" ? numberValue(t.v) : stringValue(t);
|
|
11613
|
+
entries.push({ key: key2, value: this.expr(0.6) });
|
|
11545
11614
|
} else if (t.t === "id" && (this.isOp(",", 1) || this.isOp("}", 1)) && isJs(this.lang)) {
|
|
11546
11615
|
this.next();
|
|
11547
11616
|
entries.push({ key: { kind: "literal", type: "text", value: t.v, raw: t.v }, value: { kind: "name", name: t.v }, shorthand: true });
|
|
@@ -11636,9 +11705,9 @@ var Parser = class {
|
|
|
11636
11705
|
this.next();
|
|
11637
11706
|
entries.push({ kind: "spread", value: this.expr(14), form: "**" });
|
|
11638
11707
|
} else {
|
|
11639
|
-
const
|
|
11708
|
+
const key2 = this.expr(0.6);
|
|
11640
11709
|
this.eat("=>");
|
|
11641
|
-
entries.push({ key, value: this.expr(0.6) });
|
|
11710
|
+
entries.push({ key: key2, value: this.expr(0.6) });
|
|
11642
11711
|
}
|
|
11643
11712
|
if (this.isOp(",")) {
|
|
11644
11713
|
this.next();
|
|
@@ -12128,12 +12197,12 @@ function splitParams(text2) {
|
|
|
12128
12197
|
var flatName = (n) => n.kind === "name" ? n.name : n.kind === "member" ? flatName(n.object) == null ? null : `${flatName(n.object)}${n.static ? "::" : "."}${n.property}` : n.kind === "index" ? flatName(n.object) == null ? null : `${flatName(n.object)}[${n.index.kind === "name" ? n.index.name : "\u2026"}]` : null;
|
|
12129
12198
|
var GROUPED = /* @__PURE__ */ new WeakSet();
|
|
12130
12199
|
var CACHE = /* @__PURE__ */ new Map();
|
|
12131
|
-
var cached = (
|
|
12132
|
-
const hit = CACHE.get(
|
|
12200
|
+
var cached = (key2, fn) => {
|
|
12201
|
+
const hit = CACHE.get(key2);
|
|
12133
12202
|
if (hit !== void 0) return hit;
|
|
12134
12203
|
const v = fn();
|
|
12135
12204
|
if (CACHE.size > 4e3) CACHE.clear();
|
|
12136
|
-
CACHE.set(
|
|
12205
|
+
CACHE.set(key2, v);
|
|
12137
12206
|
return v;
|
|
12138
12207
|
};
|
|
12139
12208
|
function parseExpr(text2, language = "") {
|
|
@@ -12490,9 +12559,9 @@ function rubyArgList(p) {
|
|
|
12490
12559
|
p.next();
|
|
12491
12560
|
out.push({ kind: "named", name: t.v, value: p.expr(0.6) });
|
|
12492
12561
|
} else if (t.t === "str" && p.isOp("=>", 1)) {
|
|
12493
|
-
const
|
|
12562
|
+
const key2 = p.expr(0.6);
|
|
12494
12563
|
p.eat("=>");
|
|
12495
|
-
out.push({ kind: "object", entries: [{ key, value: p.expr(0.6) }], form: "hash", bare: true });
|
|
12564
|
+
out.push({ kind: "object", entries: [{ key: key2, value: p.expr(0.6) }], form: "hash", bare: true });
|
|
12496
12565
|
} else out.push(p.expr(0.6));
|
|
12497
12566
|
if (p.isOp(",")) {
|
|
12498
12567
|
p.next();
|
|
@@ -17139,11 +17208,11 @@ function parseTemplate(html, fileSrc = null, offset = 0) {
|
|
|
17139
17208
|
return { type: "block", kind: m[1], head: (m[2] ?? "").trim(), kids: body2, line };
|
|
17140
17209
|
};
|
|
17141
17210
|
const nodes2 = parseNodes(null, false);
|
|
17142
|
-
const
|
|
17211
|
+
const join9 = (list3) => {
|
|
17143
17212
|
const out = [];
|
|
17144
17213
|
for (const n of list3) {
|
|
17145
17214
|
if (n.type === "el") {
|
|
17146
|
-
n.kids =
|
|
17215
|
+
n.kids = join9(n.kids);
|
|
17147
17216
|
out.push(n);
|
|
17148
17217
|
continue;
|
|
17149
17218
|
}
|
|
@@ -17151,7 +17220,7 @@ function parseTemplate(html, fileSrc = null, offset = 0) {
|
|
|
17151
17220
|
out.push(n);
|
|
17152
17221
|
continue;
|
|
17153
17222
|
}
|
|
17154
|
-
n.kids =
|
|
17223
|
+
n.kids = join9(n.kids);
|
|
17155
17224
|
const prev = out[out.length - 1];
|
|
17156
17225
|
if (n.kind === "else" && prev?.type === "cond") {
|
|
17157
17226
|
let tail = prev;
|
|
@@ -17177,7 +17246,7 @@ function parseTemplate(html, fileSrc = null, offset = 0) {
|
|
|
17177
17246
|
}
|
|
17178
17247
|
return out;
|
|
17179
17248
|
};
|
|
17180
|
-
return
|
|
17249
|
+
return join9(nodes2);
|
|
17181
17250
|
}
|
|
17182
17251
|
var CONTAINERS = /* @__PURE__ */ new Set(["div", "span", "section", "main", "article", "aside", "Fragment", "React.Fragment", "ng-container", "ng-template", "template", "body", "html"]);
|
|
17183
17252
|
var INLINE = /* @__PURE__ */ new Set(["strong", "em", "b", "i", "small", "code", "mark", "u", "sup", "sub", "abbr", "time"]);
|
|
@@ -18282,12 +18351,12 @@ function exactIn(inner, code3, open) {
|
|
|
18282
18351
|
}
|
|
18283
18352
|
const cut = /…$/.test(inner);
|
|
18284
18353
|
const w = textSkeleton(inner.replace(/…$/, ""), true);
|
|
18285
|
-
const
|
|
18286
|
-
let c = SKELETON_CACHE.get(
|
|
18354
|
+
const key2 = `${open ? 1 : 0}${code3}`;
|
|
18355
|
+
let c = SKELETON_CACHE.get(key2);
|
|
18287
18356
|
if (c === void 0) {
|
|
18288
18357
|
if (SKELETON_CACHE.size > 5e3) SKELETON_CACHE.clear();
|
|
18289
18358
|
c = `${textSkeleton(code3, false, open)}`;
|
|
18290
|
-
SKELETON_CACHE.set(
|
|
18359
|
+
SKELETON_CACHE.set(key2, c);
|
|
18291
18360
|
}
|
|
18292
18361
|
const parts = w.split("");
|
|
18293
18362
|
const B = "[\"'`\\s=(,;:\\[|]", E = "[\"'`\\s),;:\\]|]";
|
|
@@ -18627,8 +18696,8 @@ ${full}`)) return WHY.form;
|
|
|
18627
18696
|
const sw = m[1];
|
|
18628
18697
|
if (/^(?:Force|ErrorAction|WarningAction|InformationAction|Verbose|Debug|Confirm|WhatIf|NoNewline|ForegroundColor|BackgroundColor|OutVariable|ErrorVariable|Scope|Global|Script|Not|Contains|NotContains|Match|NotMatch|Like|NotLike|And|Or|Eq|Ne|Gt|Lt|Ge|Le|Is|IsNot|In|NotIn|Replace|Split|Join|F|As|Band|Bor|PassThru|Mandatory|Online|NoElement|NoTypeInformation)$/i.test(sw)) continue;
|
|
18629
18698
|
const map = { recurse: / everything | all | recursive| and every /, raw: / whole | as one | raw /, unique: / unique | once | duplicate /, file: / files? /, directory: / folders? /, leaf: / last part | leaf /, parent: / parent | folder /, descending: / descending | highest | largest | last /, first: / first /, last: / last /, sum: / total | sum /, count: / how many | count /, resolve: / full /, literalpath: / path /, encoding: / encoding /, append: / adds? | append /, nonewline: / /, quiet: / quiet /, simplematch: / plain text | as text /, casesensitive: / case /, asplaintext: / plain /, aspath: / path /, include: / including /, exclude: / except | excluding | without /, skip: / skip /, wait: / wait /, nowait: / without waiting /, nologo: / /, noprofile: / without the profile /, hidden: / hidden /, wrap: / wrap /, autosize: / size /, expandproperty: / /, property: / /, typename: / type /, list: / list /, all: / all /, tail: / last /, totalcount: / first /, delimiter: / separated /, header: / header /, noclobber: / not overwrite | replace nothing /, depth: / deep | depth /, compress: / compact | compress /, asjob: / background /, isvalid: / valid /, pathtype: / folder | file /, erroraction: / / };
|
|
18630
|
-
const
|
|
18631
|
-
if (said2.includes(` ${splitWords(sw).join(" ")} `) || map[
|
|
18699
|
+
const key2 = sw.toLowerCase();
|
|
18700
|
+
if (said2.includes(` ${splitWords(sw).join(" ")} `) || map[key2] && map[key2].test(said2)) continue;
|
|
18632
18701
|
return WHY.meaning;
|
|
18633
18702
|
}
|
|
18634
18703
|
}
|
|
@@ -21104,8 +21173,8 @@ function readSchema(src) {
|
|
|
21104
21173
|
const def = rest2.match(/\bDEFAULT\s+('(?:[^']|'')*'|\([^)]*\)|[\w.:]+(?:\(\))?)/i);
|
|
21105
21174
|
const column = { name: unquote(col[1]), type: col[2], line, primary: /\bPRIMARY\s+KEY\b/i.test(rest2), notNull: /\bNOT\s+NULL\b/i.test(rest2), ...def ? { default: def[1] } : {}, ...ref2 ? { ref: bare(ref2[1]) } : {} };
|
|
21106
21175
|
table.columns.push(column);
|
|
21107
|
-
const
|
|
21108
|
-
if (
|
|
21176
|
+
const check2 = rest2.match(/\bCHECK\s*\((.*)\)/i);
|
|
21177
|
+
if (check2) table.checks.push({ cond: check2[1], line });
|
|
21109
21178
|
if (/\bUNIQUE\b/i.test(rest2)) table.uniques.push({ cols: [column.name], line });
|
|
21110
21179
|
}
|
|
21111
21180
|
tables.push(table);
|
|
@@ -23003,17 +23072,17 @@ ${L[pos].trim()}`;
|
|
|
23003
23072
|
throw new YamlError(`Expected "key: value", found "${t.slice(0, 40)}"`, lineNo(pos));
|
|
23004
23073
|
}
|
|
23005
23074
|
const rawKey = t.slice(0, c).trim();
|
|
23006
|
-
const
|
|
23075
|
+
const key2 = rawKey[0] === '"' || rawKey[0] === "'" ? unquote2(rawKey) : rawKey;
|
|
23007
23076
|
const at2 = pos++;
|
|
23008
23077
|
const rest2 = t.slice(c + 1).trim();
|
|
23009
23078
|
const value = rest2 ? inlineValue(rest2, at2, ind) : block(ind, at2);
|
|
23010
|
-
if (
|
|
23079
|
+
if (key2 === "<<") {
|
|
23011
23080
|
for (const src of value.t === "seq" ? value.items : [value]) if (src.t === "map") {
|
|
23012
23081
|
for (const e of src.entries) if (!out.entries.some((x) => x.key === e.key)) out.entries.push(e);
|
|
23013
23082
|
}
|
|
23014
23083
|
continue;
|
|
23015
23084
|
}
|
|
23016
|
-
out.entries.push({ key, line: lineNo(at2), value });
|
|
23085
|
+
out.entries.push({ key: key2, line: lineNo(at2), value });
|
|
23017
23086
|
}
|
|
23018
23087
|
return out;
|
|
23019
23088
|
}
|
|
@@ -23213,8 +23282,8 @@ function scalar(n) {
|
|
|
23213
23282
|
if (/^[-+]?(\d+\.\d*|\.\d+|\d+(\.\d*)?[eE][-+]?\d+)$/.test(v)) return Number(v);
|
|
23214
23283
|
return v;
|
|
23215
23284
|
}
|
|
23216
|
-
var get = (n,
|
|
23217
|
-
var entry = (n,
|
|
23285
|
+
var get = (n, key2) => n?.t === "map" ? n.entries.findLast((e) => e.key === key2)?.value : void 0;
|
|
23286
|
+
var entry = (n, key2) => n?.t === "map" ? n.entries.findLast((e) => e.key === key2) : void 0;
|
|
23218
23287
|
var text = (n) => n?.t === "str" && n.v != null ? String(n.v) : void 0;
|
|
23219
23288
|
var list = (n) => n?.t === "seq" ? n.items : n?.t === "str" && n.v != null ? [n] : [];
|
|
23220
23289
|
|
|
@@ -23376,16 +23445,16 @@ function actionWords(uses, w) {
|
|
|
23376
23445
|
const repo = u.split("@")[0];
|
|
23377
23446
|
const [owner, name = "", ...sub2] = repo.split("/");
|
|
23378
23447
|
const path = sub2.join("/");
|
|
23379
|
-
const
|
|
23448
|
+
const key2 = `${owner}/${name}`.toLowerCase();
|
|
23380
23449
|
const W = (k) => w[k] != null ? sayExpressions(String(w[k])) : null;
|
|
23381
|
-
if (
|
|
23450
|
+
if (key2 === "actions/checkout") {
|
|
23382
23451
|
const bits = [];
|
|
23383
23452
|
if (w.repository) bits.push(`of ${W("repository")}`);
|
|
23384
23453
|
if (w.ref) bits.push(`at ${W("ref")}`);
|
|
23385
23454
|
if (String(w["fetch-depth"]) === "0") bits.push("with its whole history");
|
|
23386
23455
|
return `Gets the code${bits.length ? ` ${bits.join(" ")}` : ""}`;
|
|
23387
23456
|
}
|
|
23388
|
-
const setupName = /^actions\/(setup-\w+)$/.exec(
|
|
23457
|
+
const setupName = /^actions\/(setup-\w+)$/.exec(key2)?.[1] ?? (key2 === "ruby/setup-ruby" ? "setup-ruby" : null);
|
|
23389
23458
|
if (setupName && SETUP[setupName]) {
|
|
23390
23459
|
const lang = SETUP[setupName];
|
|
23391
23460
|
const vkey = Object.keys(w).find((k) => /-version$/.test(k) && k !== "check-latest");
|
|
@@ -23432,7 +23501,7 @@ function actionWords(uses, w) {
|
|
|
23432
23501
|
"peaceiris/actions-gh-pages": () => "Publishes the site to GitHub Pages",
|
|
23433
23502
|
"codecov/codecov-action": () => "Sends test coverage to Codecov",
|
|
23434
23503
|
"actions/dependency-review-action": () => "Checks new dependencies for known problems"
|
|
23435
|
-
}[
|
|
23504
|
+
}[key2];
|
|
23436
23505
|
if (known3) return known3();
|
|
23437
23506
|
return `Uses ${repo}`;
|
|
23438
23507
|
}
|
|
@@ -24085,7 +24154,7 @@ var Parser2 = class _Parser {
|
|
|
24085
24154
|
if (this.isId("for") && this.hcl) {
|
|
24086
24155
|
const r = this.withNl(true, () => {
|
|
24087
24156
|
const head = this.forHead();
|
|
24088
|
-
const
|
|
24157
|
+
const key2 = this.expr();
|
|
24089
24158
|
this.expect("=>");
|
|
24090
24159
|
const value = this.expr();
|
|
24091
24160
|
if (this.is("...")) this.next();
|
|
@@ -24095,7 +24164,7 @@ var Parser2 = class _Parser {
|
|
|
24095
24164
|
when = this.expr();
|
|
24096
24165
|
}
|
|
24097
24166
|
const close2 = this.expect("}");
|
|
24098
|
-
return { head, key, value, when, close: close2 };
|
|
24167
|
+
return { head, key: key2, value, when, close: close2 };
|
|
24099
24168
|
});
|
|
24100
24169
|
return this.node("for", open.s, r.close.e, { kind: "obj", vars: r.head.vars, coll: r.head.coll, key: r.key, value: r.value, ...r.when ? { when: r.when } : {} });
|
|
24101
24170
|
}
|
|
@@ -24114,21 +24183,21 @@ var Parser2 = class _Parser {
|
|
|
24114
24183
|
entries.push(hooked);
|
|
24115
24184
|
continue;
|
|
24116
24185
|
}
|
|
24117
|
-
let
|
|
24186
|
+
let key2, keyNode = null;
|
|
24118
24187
|
if (kt.k === "id" && (this.is("=", 1) || this.is(":", 1))) {
|
|
24119
24188
|
this.next();
|
|
24120
|
-
|
|
24189
|
+
key2 = kt.v;
|
|
24121
24190
|
} else if (kt.k === "str" && (this.is("=", 1) || this.is(":", 1))) {
|
|
24122
24191
|
keyNode = this.string(this.next());
|
|
24123
|
-
|
|
24192
|
+
key2 = keyNode.template ? this.src.slice(kt.s, kt.e) : keyNode.v;
|
|
24124
24193
|
} else {
|
|
24125
24194
|
keyNode = this.withNl(true, () => this.binary(0));
|
|
24126
|
-
|
|
24195
|
+
key2 = this.src.slice(keyNode.s, keyNode.e);
|
|
24127
24196
|
}
|
|
24128
|
-
const
|
|
24129
|
-
if (
|
|
24197
|
+
const sep3 = this.next();
|
|
24198
|
+
if (sep3.k !== "p" || sep3.v !== "=" && sep3.v !== ":") throw new ParseError(`Expected "=" or ":" after ${key2}`, this.lineOf(sep3));
|
|
24130
24199
|
const value = this.expr();
|
|
24131
|
-
entries.push({ key, ...keyNode && keyNode.t !== "str" ? { keyNode } : {}, value, line: this.lineOf(kt) });
|
|
24200
|
+
entries.push({ key: key2, ...keyNode && keyNode.t !== "str" ? { keyNode } : {}, value, line: this.lineOf(kt) });
|
|
24132
24201
|
}
|
|
24133
24202
|
if (this.is(",")) this.next();
|
|
24134
24203
|
else if (!this.is("}") && this.toks[this.i]?.k !== "nl") throw new ParseError('Expected a new line, "," or "}" in an object', this.lineOf(this.peek()));
|
|
@@ -24307,8 +24376,8 @@ function toValue(n, src) {
|
|
|
24307
24376
|
}
|
|
24308
24377
|
return { ref: src.slice(n.s, n.e), node: n };
|
|
24309
24378
|
}
|
|
24310
|
-
function entryOf(obj,
|
|
24311
|
-
return obj?.t === "obj" ? obj.entries.find((e) => e.key ===
|
|
24379
|
+
function entryOf(obj, key2) {
|
|
24380
|
+
return obj?.t === "obj" ? obj.entries.find((e) => e.key === key2) : void 0;
|
|
24312
24381
|
}
|
|
24313
24382
|
|
|
24314
24383
|
// src/hcl.mjs
|
|
@@ -24581,8 +24650,8 @@ var normKey = (k) => String(k ?? "").toLowerCase().replace(/[_\-.]/g, "");
|
|
|
24581
24650
|
var RUNS_IN = /* @__PURE__ */ new Set(["resourcegroupname", "resourcegroup", "resourcegroupid", "serviceplanid", "appserviceplanid", "serverfarmid", "serverid", "clusterid", "vpcid", "subnetid", "subnetids", "subnets", "virtualnetworkname", "virtualnetworkid", "parent", "parentid", "managedenvironmentid", "environmentid", "containerappenvironmentid", "namespacename", "namespaceid", "hostingplanid", "clustername", "instanceid", "dbsubnetgroupname", "subnet"]);
|
|
24582
24651
|
var SENDS_TO = /* @__PURE__ */ new Set(["loganalyticsworkspaceid", "workspaceid", "workspaceresourceid", "applicationinsightsid", "appinsightsid", "topicarn", "snstopicarn", "queueurl", "queuearn", "destinationarn", "eventhubname", "eventhubauthorizationruleid", "targetarn", "deadlettertargetarn"]);
|
|
24583
24652
|
var CHILD_STORAGE = /(container|share|queue|table|blob|file_system|filesystem)/i;
|
|
24584
|
-
function linkKind(
|
|
24585
|
-
const k = normKey(
|
|
24653
|
+
function linkKind(key2, { toLookup = false, fromType = "", secretValue = false } = {}) {
|
|
24654
|
+
const k = normKey(key2);
|
|
24586
24655
|
if (toLookup || secretValue) return "reads-from";
|
|
24587
24656
|
if (RUNS_IN.has(k)) return "runs-in";
|
|
24588
24657
|
if ((k === "storageaccountname" || k === "storageaccountid" || k === "keyvaultid" || k === "servername") && /(container|share|queue|table|blob|secret|key|certificate|database|filesystem|file_system)/i.test(fromType) && CHILD_STORAGE.test(fromType + (k === "keyvaultid" ? "container" : ""))) return "runs-in";
|
|
@@ -24656,35 +24725,35 @@ function portsOpen(from, to, protocol) {
|
|
|
24656
24725
|
const t = to == null ? String(from ?? "").includes("-") ? Number(String(from).split("-")[1]) : f : Number(to);
|
|
24657
24726
|
if (f == null || Number.isNaN(f)) return { says: "every port", beyondWeb: true };
|
|
24658
24727
|
if (f === 0 && (t === 0 || t === 65535) || f === 1 && t === 65535) return { says: "every port", beyondWeb: true };
|
|
24659
|
-
const
|
|
24660
|
-
return { says:
|
|
24728
|
+
const range2 = f === t ? `port ${f}` : `ports ${f} to ${t}`;
|
|
24729
|
+
return { says: range2, beyondWeb: !(f === t && (f === 80 || f === 443)) };
|
|
24661
24730
|
}
|
|
24662
24731
|
var PUBLIC_TRUE = /* @__PURE__ */ new Set(["allowblobpublicaccess", "allownesteditemstobepublic"]);
|
|
24663
24732
|
var PUBLIC_FALSE = /* @__PURE__ */ new Set(["blockpublicacls", "blockpublicpolicy", "ignorepublicacls", "restrictpublicbuckets"]);
|
|
24664
24733
|
var ENCRYPT_FALSE = /* @__PURE__ */ new Set(["encrypted", "storageencrypted", "encryptionenabled", "enableencryption", "httpsonly", "enablehttpstrafficonly", "httpstrafficonlyenabled", "supportshttpstrafficonly", "sslenforcementenabled", "enforcessl", "requiressl", "encryptionatrest", "kmsencrypted", "atrestencryptionenabled", "transitencryptionenabled"]);
|
|
24665
24734
|
var ENCRYPT_TRUE = /* @__PURE__ */ new Set(["enablenonsslport", "nonsslportenabled", "allowhttp"]);
|
|
24666
24735
|
var PUBLIC_ACL = /* @__PURE__ */ new Set(["public-read", "public-read-write", "authenticated-read", "website"]);
|
|
24667
|
-
function keyFacts(
|
|
24668
|
-
const k = normKey(
|
|
24736
|
+
function keyFacts(key2, value, say, where) {
|
|
24737
|
+
const k = normKey(key2);
|
|
24669
24738
|
const v = value?.t === "bool" ? value.v : value?.t === "str" && !value.template ? value.v : void 0;
|
|
24670
24739
|
if (v === void 0) return false;
|
|
24671
|
-
if (PUBLIC_TRUE.has(k) && v === true) say("storage-public", `${where} allows public, anonymous access to its files (${
|
|
24672
|
-
else if (PUBLIC_FALSE.has(k) && v === false) say("storage-public", `${where} does not block public access (${
|
|
24673
|
-
else if ((k === "containeraccesstype" || k === "publicaccess") && typeof v === "string" && /^(blob|container)$/i.test(v)) say("storage-public", `${where} lets anyone read its ${/^container$/i.test(v) ? "files and list them" : "files"} without signing in (${
|
|
24740
|
+
if (PUBLIC_TRUE.has(k) && v === true) say("storage-public", `${where} allows public, anonymous access to its files (${key2} = true).`);
|
|
24741
|
+
else if (PUBLIC_FALSE.has(k) && v === false) say("storage-public", `${where} does not block public access (${key2} = false).`);
|
|
24742
|
+
else if ((k === "containeraccesstype" || k === "publicaccess") && typeof v === "string" && /^(blob|container)$/i.test(v)) say("storage-public", `${where} lets anyone read its ${/^container$/i.test(v) ? "files and list them" : "files"} without signing in (${key2} = ${v}).`);
|
|
24674
24743
|
else if (k === "acl" && typeof v === "string" && PUBLIC_ACL.has(v.toLowerCase())) say("storage-public", `${where} is readable by ${v.toLowerCase() === "authenticated-read" ? "any AWS account" : "anyone"} (acl = ${v}).`);
|
|
24675
|
-
else if (ENCRYPT_FALSE.has(k) && v === false) say("encryption-off", `${where} turns off ${/https|ssl/.test(k) ? "encrypted connections (HTTPS)" : "encryption"} (${
|
|
24676
|
-
else if (ENCRYPT_TRUE.has(k) && v === true) say("encryption-off", `${where} allows connections that are not encrypted (${
|
|
24677
|
-
else if ((k === "mintlsversion" || k === "minimumtlsversion") && typeof v === "string" && /1[._]?[01]$/.test(v)) say("encryption-off", `${where} accepts old, weak encryption (${
|
|
24678
|
-
else if (isSecretKey(
|
|
24679
|
-
say("secret-in-plain-config", `${where} has ${
|
|
24744
|
+
else if (ENCRYPT_FALSE.has(k) && v === false) say("encryption-off", `${where} turns off ${/https|ssl/.test(k) ? "encrypted connections (HTTPS)" : "encryption"} (${key2} = false).`);
|
|
24745
|
+
else if (ENCRYPT_TRUE.has(k) && v === true) say("encryption-off", `${where} allows connections that are not encrypted (${key2} = true).`);
|
|
24746
|
+
else if ((k === "mintlsversion" || k === "minimumtlsversion") && typeof v === "string" && /1[._]?[01]$/.test(v)) say("encryption-off", `${where} accepts old, weak encryption (${key2} = ${v}).`);
|
|
24747
|
+
else if (isSecretKey(key2) && typeof v === "string" && v.length > 0 && !/^(true|false|\d+|enabled|disabled|none|null)$/i.test(v)) {
|
|
24748
|
+
say("secret-in-plain-config", `${where} has ${key2} written in the file, where anyone who can read it sees the value.`);
|
|
24680
24749
|
return true;
|
|
24681
24750
|
}
|
|
24682
24751
|
return false;
|
|
24683
24752
|
}
|
|
24684
24753
|
var SECRET_LAST = /* @__PURE__ */ new Set(["password", "passwd", "pwd", "secret", "token", "credential", "credentials", "passphrase", "sas"]);
|
|
24685
24754
|
var KEY_KINDS = /* @__PURE__ */ new Set(["api", "access", "private", "secret", "account", "shared", "primary", "secondary", "master", "admin", "signing", "subscription", "storage", "client", "auth", "instrumentation"]);
|
|
24686
|
-
function isSecretKey(
|
|
24687
|
-
const w = String(
|
|
24755
|
+
function isSecretKey(key2) {
|
|
24756
|
+
const w = String(key2 ?? "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
24688
24757
|
const last = w.at(-1), prev = w.at(-2);
|
|
24689
24758
|
if (!last) return false;
|
|
24690
24759
|
if (SECRET_LAST.has(last)) return true;
|
|
@@ -24755,12 +24824,12 @@ function question(c) {
|
|
|
24755
24824
|
if (i > 0 && !/ (and|or) /.test(s.slice(0, i))) return `Is ${s.slice(0, i)} ${s.slice(i + 4)}?`;
|
|
24756
24825
|
return `Only when ${s}?`;
|
|
24757
24826
|
}
|
|
24758
|
-
function leaves(n,
|
|
24827
|
+
function leaves(n, key2, line, out = []) {
|
|
24759
24828
|
if (!n) return out;
|
|
24760
24829
|
if (n.t === "obj") {
|
|
24761
|
-
for (const e of n.entries) if (!e.nested) leaves(e.value, e.spread ?
|
|
24762
|
-
} else if (n.t === "list") for (const x of n.items) leaves(x,
|
|
24763
|
-
else out.push({ key, value: n, line: n.t === "str" || n.t === "ref" ? line : line });
|
|
24830
|
+
for (const e of n.entries) if (!e.nested) leaves(e.value, e.spread ? key2 : e.key, e.line, out);
|
|
24831
|
+
} else if (n.t === "list") for (const x of n.items) leaves(x, key2, x.line ?? line, out);
|
|
24832
|
+
else out.push({ key: key2, value: n, line: n.t === "str" || n.t === "ref" ? line : line });
|
|
24764
24833
|
return out;
|
|
24765
24834
|
}
|
|
24766
24835
|
|
|
@@ -25923,7 +25992,7 @@ function secretLiteral(name, value) {
|
|
|
25923
25992
|
return !/^(true|false|yes|no|on|off|\d+|enabled|disabled|none|null|changeme|<.*>)$/i.test(v);
|
|
25924
25993
|
}
|
|
25925
25994
|
var HOST_KEY = /(host|hostname|addr|address|url|uri|server|servers|endpoint|dsn|broker|brokers|connection|conn)$/i;
|
|
25926
|
-
function servicesNamed(
|
|
25995
|
+
function servicesNamed(key2, value, known3) {
|
|
25927
25996
|
const out = [];
|
|
25928
25997
|
const v = String(value ?? "").trim();
|
|
25929
25998
|
const add2 = (h) => {
|
|
@@ -25942,7 +26011,7 @@ function servicesNamed(key, value, known3) {
|
|
|
25942
26011
|
add2(hp[1]);
|
|
25943
26012
|
continue;
|
|
25944
26013
|
}
|
|
25945
|
-
if (HOST_KEY.test(String(
|
|
26014
|
+
if (HOST_KEY.test(String(key2 ?? "").replace(/[_-]/g, "")) && /^[A-Za-z0-9][\w.-]*$/.test(part)) add2(part);
|
|
25946
26015
|
}
|
|
25947
26016
|
return out;
|
|
25948
26017
|
}
|
|
@@ -26008,7 +26077,7 @@ var at = (n, ...keys) => {
|
|
|
26008
26077
|
for (const k of keys) cur = get(cur, k);
|
|
26009
26078
|
return cur;
|
|
26010
26079
|
};
|
|
26011
|
-
var lineOf3 = (n,
|
|
26080
|
+
var lineOf3 = (n, key2, fallback) => entry(n, key2)?.line ?? fallback;
|
|
26012
26081
|
var labelsOf = (n) => n?.t === "map" ? Object.fromEntries(n.entries.map((e) => [e.key, str(e.value) ?? ""])) : {};
|
|
26013
26082
|
var selectorWords = (labels) => listWords3(Object.entries(labels).map(([k, v]) => `${k}=${v}`));
|
|
26014
26083
|
function selectorOf(n) {
|
|
@@ -26103,7 +26172,7 @@ function readKubernetes(src, file = "k8s.yaml") {
|
|
|
26103
26172
|
const addr = (k, nm) => k8sAddress(k, nm, CLUSTER_SCOPED.has(k) ? void 0 : ns);
|
|
26104
26173
|
declared.push({ address, kind, name, line: r.line, n: r.n });
|
|
26105
26174
|
const knows = [];
|
|
26106
|
-
const know = (label,
|
|
26175
|
+
const know = (label, kindText2, line, extra = {}) => knows.push({ name: extra.name ?? label, label, kind: kindText2, start: null, line: line ?? r.line, ...extra });
|
|
26107
26176
|
const where = `The ${kindWords(kind)} ${name}`;
|
|
26108
26177
|
const thing = { kind: "resource", name: address, label: `${cap2(kindWords(kind))} ${name}`, resourceType: kind, address, file, lines: [r.line, r.endLine], knows, choices: [] };
|
|
26109
26178
|
const doc = commentAbove(srcLines, r.line);
|
|
@@ -26145,20 +26214,20 @@ function readKubernetes(src, file = "k8s.yaml") {
|
|
|
26145
26214
|
} else if (kind === "Ingress") {
|
|
26146
26215
|
readIngress({ spec, meta, where, know, fact, link, address, addr, line: r.line });
|
|
26147
26216
|
} else if (kind === "ConfigMap") {
|
|
26148
|
-
for (const
|
|
26217
|
+
for (const key2 of ["data", "binaryData"]) for (const e of get(r.n, key2)?.entries ?? []) {
|
|
26149
26218
|
const v = str(e.value) ?? "";
|
|
26150
26219
|
const secret = isSecretName(e.key);
|
|
26151
26220
|
const multi = v.includes("\n");
|
|
26152
26221
|
if (secretLiteral(e.key, v)) fact("secret-in-plain-config", `The ConfigMap ${name} has ${e.key} written in the file, and ConfigMaps are not kept secret.`, e.line);
|
|
26153
|
-
const shown =
|
|
26222
|
+
const shown = key2 === "binaryData" ? "binary data" : secret ? "a secret-looking value (not shown)" : multi ? `a file (${v.replace(/\n$/, "").split("\n").length} lines)` : v === "" ? "(empty)" : short4(v);
|
|
26154
26223
|
know(e.key, shown, e.line, { setting: true, ...secret ? { secret: true } : {} });
|
|
26155
|
-
setting({ name: e.key, source: "literal", secret, line: e.line, ...!secret && !multi &&
|
|
26224
|
+
setting({ name: e.key, source: "literal", secret, line: e.line, ...!secret && !multi && key2 === "data" ? { default: short4(v) } : {} });
|
|
26156
26225
|
}
|
|
26157
26226
|
} else if (kind === "Secret") {
|
|
26158
26227
|
const type = str(get(r.n, "type")) ?? "Opaque";
|
|
26159
26228
|
know("Holds", { "kubernetes.io/tls": "a TLS certificate and its key", "kubernetes.io/dockerconfigjson": "a sign-in for a container registry", "kubernetes.io/dockercfg": "a sign-in for a container registry", "kubernetes.io/service-account-token": "a service account token", "kubernetes.io/basic-auth": "a user name and password", "kubernetes.io/ssh-auth": "an SSH key" }[type] ?? `secret values (${type})`, lineOf3(r.n, "type"));
|
|
26160
26229
|
let written = null;
|
|
26161
|
-
for (const
|
|
26230
|
+
for (const key2 of ["data", "stringData"]) for (const e of get(r.n, key2)?.entries ?? []) {
|
|
26162
26231
|
know(e.key, "a secret value (only its name is shown)", e.line, { setting: true, secret: true });
|
|
26163
26232
|
setting({ name: e.key, source: "secret", secret: true, line: e.line });
|
|
26164
26233
|
if (!written && (str(e.value) ?? "") !== "" && !hasVar2(str(e.value))) written = e.line;
|
|
@@ -26450,13 +26519,13 @@ function readWorkload(c) {
|
|
|
26450
26519
|
if (vf) {
|
|
26451
26520
|
const sk = get(vf, "secretKeyRef"), ck = get(vf, "configMapKeyRef"), fr = get(vf, "fieldRef"), rr = get(vf, "resourceFieldRef");
|
|
26452
26521
|
if (sk) {
|
|
26453
|
-
const sn = str(get(sk, "name")),
|
|
26454
|
-
know(`${pre}${en}`, `the secret value ${
|
|
26522
|
+
const sn = str(get(sk, "name")), key2 = str(get(sk, "key"));
|
|
26523
|
+
know(`${pre}${en}`, `the secret value ${key2} in the Secret ${sn} (only its name is shown)`, line, { name: en, setting: true, secret: true });
|
|
26455
26524
|
setting({ name: en, source: "secret", secret: true, line });
|
|
26456
26525
|
link(address, addr("Secret", sn), "reads-from", line);
|
|
26457
26526
|
} else if (ck) {
|
|
26458
|
-
const cmn = str(get(ck, "name")),
|
|
26459
|
-
know(`${pre}${en}`, `the value ${
|
|
26527
|
+
const cmn = str(get(ck, "name")), key2 = str(get(ck, "key"));
|
|
26528
|
+
know(`${pre}${en}`, `the value ${key2} in the ConfigMap ${cmn}`, line, { name: en, setting: true });
|
|
26460
26529
|
setting({ name: en, source: "variable", secret: false, line });
|
|
26461
26530
|
link(address, addr("ConfigMap", cmn), "reads-from", line);
|
|
26462
26531
|
} else if (fr || rr) {
|
|
@@ -26493,9 +26562,9 @@ function readWorkload(c) {
|
|
|
26493
26562
|
if (req && amount(req)) know(`${pre}Asks for`, amount(req), lineOf3(res, "requests"));
|
|
26494
26563
|
if (lim && amount(lim)) know(`${pre}Can use at most`, amount(lim), lineOf3(res, "limits"));
|
|
26495
26564
|
if (!init && (!lim || !lim.entries?.length)) fact("no-resource-limits", `${cwhere} has no resource limits, so it can use as much CPU and memory as the node has.`, lineOf3(ct, "resources", lineOf3(ct, "name", ct.line)));
|
|
26496
|
-
for (const [
|
|
26497
|
-
const p = get(ct,
|
|
26498
|
-
if (p) know(`${pre}${label}`, probeWords(p,
|
|
26565
|
+
for (const [key2, label] of [["startupProbe", "Has started when"], ["readinessProbe", "Ready for traffic when"], ["livenessProbe", "Restarted when"]]) {
|
|
26566
|
+
const p = get(ct, key2);
|
|
26567
|
+
if (p) know(`${pre}${label}`, probeWords(p, key2 === "livenessProbe" ? "fails" : "succeeds"), lineOf3(ct, key2));
|
|
26499
26568
|
}
|
|
26500
26569
|
const sc = get(ct, "securityContext");
|
|
26501
26570
|
const pick2 = (k) => {
|
|
@@ -26655,11 +26724,11 @@ function readNetworkPolicy({ spec, know }) {
|
|
|
26655
26724
|
know("Applies to", `${selectorOf(get(spec, "podSelector")).says} in its namespace`, lineOf3(spec, "podSelector"));
|
|
26656
26725
|
const types = list(get(spec, "policyTypes")).map(str);
|
|
26657
26726
|
const has2 = (k) => types.includes(k) || !types.length && (k === "Ingress" || get(spec, "egress"));
|
|
26658
|
-
for (const [
|
|
26727
|
+
for (const [key2, type, label, dir] of [["ingress", "Ingress", "Lets in", "from"], ["egress", "Egress", "Lets out", "to"]]) {
|
|
26659
26728
|
if (!has2(type)) continue;
|
|
26660
|
-
const rules = list(get(spec,
|
|
26729
|
+
const rules = list(get(spec, key2));
|
|
26661
26730
|
if (!rules.length) {
|
|
26662
|
-
know(label, `nothing: every ${
|
|
26731
|
+
know(label, `nothing: every ${key2 === "ingress" ? "incoming" : "outgoing"} connection is blocked`, lineOf3(spec, key2, lineOf3(spec, "policyTypes")));
|
|
26663
26732
|
continue;
|
|
26664
26733
|
}
|
|
26665
26734
|
for (const r of rules) {
|
|
@@ -26676,7 +26745,7 @@ var str2 = (n) => {
|
|
|
26676
26745
|
const v = scalar(n);
|
|
26677
26746
|
return v == null ? void 0 : String(v);
|
|
26678
26747
|
};
|
|
26679
|
-
var lineOf4 = (n,
|
|
26748
|
+
var lineOf4 = (n, key2, fallback) => entry(n, key2)?.line ?? fallback;
|
|
26680
26749
|
var short5 = (s, n = 80) => s.length > n ? `${s.slice(0, n - 1)}\u2026` : s;
|
|
26681
26750
|
var varsIn = (s) => {
|
|
26682
26751
|
const out = [];
|
|
@@ -26776,14 +26845,14 @@ function readCompose(src, file = "compose.yaml") {
|
|
|
26776
26845
|
};
|
|
26777
26846
|
const services = get(root, "services");
|
|
26778
26847
|
const serviceNames = new Set((services?.entries ?? []).map((e) => e.key));
|
|
26779
|
-
const top = (
|
|
26848
|
+
const top = (key2) => new Map((get(root, key2)?.entries ?? []).map((e) => [e.key, e]));
|
|
26780
26849
|
const volumes = top("volumes"), networks = top("networks"), secrets = top("secrets"), configs = top("configs");
|
|
26781
26850
|
const declared = [];
|
|
26782
|
-
for (const [
|
|
26783
|
-
for (const [name, e] of top(
|
|
26851
|
+
for (const [key2, type, word] of [["networks", "compose-network", "network"], ["volumes", "compose-volume", "volume"], ["secrets", "compose-secret", "secret"], ["configs", "compose-config", "config"]]) {
|
|
26852
|
+
for (const [name, e] of top(key2)) {
|
|
26784
26853
|
const v = e.value;
|
|
26785
26854
|
const knows = [];
|
|
26786
|
-
const know = (label,
|
|
26855
|
+
const know = (label, kindText2, line, extra = {}) => knows.push({ name: label, label, kind: kindText2, start: null, line: line ?? e.line, ...extra });
|
|
26787
26856
|
const ext = get(v, "external");
|
|
26788
26857
|
const external = str2(ext) === "true" || ext?.t === "map";
|
|
26789
26858
|
const realName = str2(get(v, "name")) ?? str2(get(ext, "name"));
|
|
@@ -26791,20 +26860,20 @@ function readCompose(src, file = "compose.yaml") {
|
|
|
26791
26860
|
else if (realName) know("Named", realName, lineOf4(v, "name"));
|
|
26792
26861
|
const driver = str2(get(v, "driver"));
|
|
26793
26862
|
if (driver) know("Driver", driver, lineOf4(v, "driver"));
|
|
26794
|
-
if (
|
|
26795
|
-
if (
|
|
26863
|
+
if (key2 === "networks" && str2(get(v, "internal")) === "true") know("Reaches", "only the services on it (no way out to the internet)", lineOf4(v, "internal"));
|
|
26864
|
+
if (key2 === "secrets" || key2 === "configs") {
|
|
26796
26865
|
const f = str2(get(v, "file")), env = str2(get(v, "environment")), content = get(v, "content");
|
|
26797
26866
|
if (f) know("Read from", `the file ${f} on the computer it starts on`, lineOf4(v, "file"));
|
|
26798
26867
|
if (env) know("Taken from", `the variable ${env} on the computer it starts on`, lineOf4(v, "environment"));
|
|
26799
|
-
if (content) know("Written here",
|
|
26800
|
-
if (
|
|
26868
|
+
if (content) know("Written here", key2 === "secrets" ? "yes (not shown)" : short5(str2(content) ?? ""), lineOf4(v, "content"));
|
|
26869
|
+
if (key2 === "secrets") {
|
|
26801
26870
|
setting({ name, source: "secret", secret: true, line: e.line });
|
|
26802
26871
|
if (content && !hasVar2(str2(content))) fact("secret-in-plain-config", `The secret ${name} has its value written in the Compose file.`, lineOf4(v, "content"));
|
|
26803
26872
|
}
|
|
26804
26873
|
}
|
|
26805
|
-
const address = `${
|
|
26874
|
+
const address = `${key2}.${name}`;
|
|
26806
26875
|
things.push({ kind: "resource", name: address, label: `${cap2(word)} ${name}`, resourceType: type, address, file, lines: [e.line, Math.max(e.line, lastLine3(v))], knows, choices: [], ...external ? { existing: true } : {} });
|
|
26807
|
-
declared.push({ address, kind:
|
|
26876
|
+
declared.push({ address, kind: key2, name, line: e.line, external });
|
|
26808
26877
|
}
|
|
26809
26878
|
}
|
|
26810
26879
|
const starts = /* @__PURE__ */ new Map();
|
|
@@ -26813,22 +26882,22 @@ function readCompose(src, file = "compose.yaml") {
|
|
|
26813
26882
|
const address = `services.${name}`;
|
|
26814
26883
|
const where = `The service ${name}`;
|
|
26815
26884
|
const knows = [];
|
|
26816
|
-
const know = (label,
|
|
26885
|
+
const know = (label, kindText2, line, extra = {}) => knows.push({ name: extra.name ?? label, label, kind: kindText2, start: null, line: line ?? e.line, ...extra });
|
|
26817
26886
|
const image = str2(get(s, "image"));
|
|
26818
|
-
const
|
|
26887
|
+
const build2 = get(s, "build");
|
|
26819
26888
|
const info = { image, build: null, after: [], profiles: list(get(s, "profiles")).map(str2) };
|
|
26820
|
-
if (
|
|
26821
|
-
const ctx =
|
|
26822
|
-
const df =
|
|
26823
|
-
const target =
|
|
26889
|
+
if (build2) {
|
|
26890
|
+
const ctx = build2.t === "map" ? str2(get(build2, "context")) ?? "." : str2(build2) ?? ".";
|
|
26891
|
+
const df = build2.t === "map" ? str2(get(build2, "dockerfile")) : void 0;
|
|
26892
|
+
const target = build2.t === "map" ? str2(get(build2, "target")) : void 0;
|
|
26824
26893
|
const remote = /^(https?|git|ssh):\/\/|^git@|\.git(#|$)/.test(ctx);
|
|
26825
26894
|
info.build = ctx;
|
|
26826
|
-
know("Built from", `${remote ? `the repository ${ctx}` : ctx === "." ? "this folder" : `the folder ${ctx}`}${df ? `, with ${df}` : ""}${target ? `, the ${target} stage` : ""}`,
|
|
26895
|
+
know("Built from", `${remote ? `the repository ${ctx}` : ctx === "." ? "this folder" : `the folder ${ctx}`}${df ? `, with ${df}` : ""}${target ? `, the ${target} stage` : ""}`, build2.t === "map" ? lineOf4(build2, "context", lineOf4(s, "build")) : lineOf4(s, "build"), { name: "build" });
|
|
26827
26896
|
if (!remote && !hasVar2(ctx) && !(df && (hasVar2(df) || df.startsWith("/")))) {
|
|
26828
26897
|
const path = normPath(`${dir ? `${dir}/` : ""}${ctx}/${df ?? "Dockerfile"}`);
|
|
26829
26898
|
if (path) link(address, `image:${path}`, "uses", lineOf4(s, "build"));
|
|
26830
26899
|
}
|
|
26831
|
-
for (const a of envEntries(
|
|
26900
|
+
for (const a of envEntries(build2.t === "map" ? get(build2, "args") : null)) {
|
|
26832
26901
|
const secret = isSecretName(a.key);
|
|
26833
26902
|
if (secretLiteral(a.key, a.value)) fact("secret-in-plain-env", `${where} passes ${a.key} to its build with the value written in the file.`, a.line);
|
|
26834
26903
|
setting({ name: a.key, source: a.value == null || hasVar2(a.value) ? "computed" : "parameter", secret, line: a.line, ...a.value == null || hasVar2(a.value) ? { computed: true } : {}, ...!secret && a.value != null && !hasVar2(a.value) ? { default: a.value } : {} });
|
|
@@ -29240,12 +29309,12 @@ function makeStepper(src) {
|
|
|
29240
29309
|
const kids2 = lastSteps(chain[chain.length - 1], lastOp);
|
|
29241
29310
|
return [{ kind: "branch", says: `If ${cond}`, ...base2(n), ...kids2.length ? { children: kids2 } : {} }];
|
|
29242
29311
|
}
|
|
29243
|
-
const
|
|
29312
|
+
const build2 = (i) => {
|
|
29244
29313
|
if (i === chain.length - 1) return lastSteps(chain[i], ops[i - 1]);
|
|
29245
29314
|
const op = ops[i];
|
|
29246
29315
|
const head = chain[i];
|
|
29247
29316
|
const cond = nodeCond(head, op === "||");
|
|
29248
|
-
const kids2 =
|
|
29317
|
+
const kids2 = build2(i + 1);
|
|
29249
29318
|
const b = { kind: "branch", says: `If ${cond}`, ...base2(n, i === 0 ? codeOf2(n) : codeOf2(head)), ...kids2.length ? { children: kids2 } : {} };
|
|
29250
29319
|
if (isTest(head) || head.type === "pipeline" && head.negate) return [b];
|
|
29251
29320
|
const own = steps([head]);
|
|
@@ -29254,7 +29323,7 @@ function makeStepper(src) {
|
|
|
29254
29323
|
if (head.type === "simple" && (head.words[0] === "command" && head.words[1] === "-v" || /^(which|type|hash)$/.test(head.words[0]) || /^e?grep$/.test(head.words[0]) && head.words.some((w) => /^-[a-zA-Z]*q/.test(w)))) return [b];
|
|
29255
29324
|
return [...own, { ...b, says: `If that ${op === "&&" ? "worked" : "failed"}` }];
|
|
29256
29325
|
};
|
|
29257
|
-
return
|
|
29326
|
+
return build2(0);
|
|
29258
29327
|
}
|
|
29259
29328
|
return { steps, lineAt: lineAt5, codeOf: codeOf2, headOf: headOf2 };
|
|
29260
29329
|
}
|
|
@@ -29788,8 +29857,8 @@ function sayValue2(toks, plain = false) {
|
|
|
29788
29857
|
while (k < g.length) {
|
|
29789
29858
|
if (g[k][0].text === "[" && g[k].length > 2) {
|
|
29790
29859
|
if (index != null) return null;
|
|
29791
|
-
const
|
|
29792
|
-
index =
|
|
29860
|
+
const key2 = at0(g[k].slice(1, -1));
|
|
29861
|
+
index = key2.length === 1 && key2[0].t === "str" ? { key: key2[0].body } : key2.length === 1 && key2[0].t === "num" && /^\d+$/.test(key2[0].text) ? { n: Number(key2[0].text) } : key2.length === 2 && key2[0].text === "-" && key2[1].text === "1" ? { last: true } : key2.length === 1 && key2[0].t === "var" ? { by: varWords2(key2[0].name) } : null;
|
|
29793
29862
|
if (!index) return null;
|
|
29794
29863
|
k++;
|
|
29795
29864
|
continue;
|
|
@@ -29920,11 +29989,11 @@ function condWords3(toks, neg2) {
|
|
|
29920
29989
|
}
|
|
29921
29990
|
return parts;
|
|
29922
29991
|
};
|
|
29923
|
-
for (const [names,
|
|
29992
|
+
for (const [names, join9, flip] of [[["or", "xor"], " or ", " and "], [["and"], " and ", " or "]]) {
|
|
29924
29993
|
const parts = split(names);
|
|
29925
29994
|
if (parts.length > 1) {
|
|
29926
29995
|
const said = parts.map((p) => condWords3(p.flat(), neg2));
|
|
29927
|
-
return said.some((x) => !x) ? null : said.join(neg2 ? flip :
|
|
29996
|
+
return said.some((x) => !x) ? null : said.join(neg2 ? flip : join9);
|
|
29928
29997
|
}
|
|
29929
29998
|
}
|
|
29930
29999
|
if (g[0].length === 1 && (g[0][0].t === "op" && opName(g[0][0]) === "not" || g[0][0].text === "!")) return condWords3(g.slice(1).flat(), !neg2);
|
|
@@ -30074,7 +30143,7 @@ var ALIASES = { ls: "Get-ChildItem", dir: "Get-ChildItem", gci: "Get-ChildItem",
|
|
|
30074
30143
|
var STOP_ON_ERROR = false;
|
|
30075
30144
|
var KNOWN_FNS2 = /* @__PURE__ */ new Set();
|
|
30076
30145
|
var argWords = (x) => sayValue2(x) ?? asCodeWords(toksCode(x), 60);
|
|
30077
|
-
var msgArg = (a,
|
|
30146
|
+
var msgArg = (a, key2) => a.named[key2] ? argWords(a.named[key2]) : a.pos[0] ? argWords(a.pos[0]) : "(empty)";
|
|
30078
30147
|
function withArgs(a) {
|
|
30079
30148
|
const parts = [...a.pos.map(argWords), ...Object.entries(a.named).map(([k, v]) => `${words9(a.spelled[k] ?? k)} set to ${argWords(v)}`), ...[...a.switches].map((k) => `the ${words9(a.spelled[k] ?? k)} switch`)];
|
|
30080
30149
|
return parts.length ? ` with ${list2(parts)}` : "";
|
|
@@ -31358,11 +31427,11 @@ function glueText(s) {
|
|
|
31358
31427
|
}
|
|
31359
31428
|
return out;
|
|
31360
31429
|
}
|
|
31361
|
-
function textOf3(args,
|
|
31430
|
+
function textOf3(args, sep3 = "", glue = false) {
|
|
31362
31431
|
return args.filter((a) => !a.name).map((a) => {
|
|
31363
31432
|
const v = at02(a.toks);
|
|
31364
31433
|
return v.length === 1 && v[0].t === "str" ? glue ? glueText(rawText(v[0])) : rawText(v[0]) : placeholder(a.toks);
|
|
31365
|
-
}).join(
|
|
31434
|
+
}).join(sep3);
|
|
31366
31435
|
}
|
|
31367
31436
|
var oneValue = (args) => {
|
|
31368
31437
|
const p = args.filter((a) => !a.name);
|
|
@@ -31391,8 +31460,8 @@ function sprintfText(args) {
|
|
|
31391
31460
|
});
|
|
31392
31461
|
return bad || k !== plain.length ? null : out;
|
|
31393
31462
|
}
|
|
31394
|
-
function pasteText(args,
|
|
31395
|
-
const s = namedText(args, "sep",
|
|
31463
|
+
function pasteText(args, sep3) {
|
|
31464
|
+
const s = namedText(args, "sep", sep3), collapse = namedText(args, "collapse", void 0);
|
|
31396
31465
|
if (s == null || collapse === null) return null;
|
|
31397
31466
|
const t = quote(textOf3(args, s));
|
|
31398
31467
|
return collapse === void 0 ? t : `${t} (each, joined with "${collapse}")`;
|
|
@@ -31664,9 +31733,9 @@ function callVerb({ bare: bare2, name, args }) {
|
|
|
31664
31733
|
case "print":
|
|
31665
31734
|
return `Shows ${a0 ?? "it"}`;
|
|
31666
31735
|
case "cat": {
|
|
31667
|
-
const
|
|
31736
|
+
const sep3 = namedText(args, "sep", " ");
|
|
31668
31737
|
const to = args.find((a) => a.name === "file");
|
|
31669
|
-
return
|
|
31738
|
+
return sep3 == null ? null : `Shows ${oneValue(args) ? sayValue3(args.find((a) => !a.name).toks) ?? "a value" : quote(textOf3(args, sep3))}${to ? ` (to ${sayValue3(to.toks) ?? "a connection"})` : ""}`;
|
|
31670
31739
|
}
|
|
31671
31740
|
case "message":
|
|
31672
31741
|
case "inform":
|
|
@@ -31767,7 +31836,7 @@ function condWords4(list3, neg2, preCall = null) {
|
|
|
31767
31836
|
const v = at02(list3);
|
|
31768
31837
|
if (!v.length && !preCall) return null;
|
|
31769
31838
|
const g = groups2(v);
|
|
31770
|
-
for (const [ops,
|
|
31839
|
+
for (const [ops, join9, flip] of [[["||", "|"], " or ", " and "], [["&&", "&"], " and ", " or "]]) {
|
|
31771
31840
|
const parts = [[]];
|
|
31772
31841
|
for (const x of g) {
|
|
31773
31842
|
if (x.length === 1 && x[0].t === "op" && ops.includes(x[0].text)) parts.push([]);
|
|
@@ -31776,7 +31845,7 @@ function condWords4(list3, neg2, preCall = null) {
|
|
|
31776
31845
|
if (parts.length > 1) {
|
|
31777
31846
|
if (neg2) return null;
|
|
31778
31847
|
const said = parts.map((p) => condWords4(p, neg2));
|
|
31779
|
-
return said.some((s) => !s || /^not: /.test(s)) ? null : said.join(
|
|
31848
|
+
return said.some((s) => !s || /^not: /.test(s)) ? null : said.join(join9);
|
|
31780
31849
|
}
|
|
31781
31850
|
}
|
|
31782
31851
|
if (!preCall && isOp(g[0]?.[0], "!")) return condWords4(v.slice(1), !neg2);
|
|
@@ -32050,7 +32119,7 @@ function makeReader2(src) {
|
|
|
32050
32119
|
while (i < to && (toks[i].t === "nl" || toks[i].t === "comment")) i++;
|
|
32051
32120
|
return i;
|
|
32052
32121
|
};
|
|
32053
|
-
const
|
|
32122
|
+
const range2 = (list3) => [list3[0].i, list3[list3.length - 1].i + 1];
|
|
32054
32123
|
const bodyRange2 = (i, to) => {
|
|
32055
32124
|
const k = next(i, to);
|
|
32056
32125
|
return isOp(toks[k], "{") && toks[k].match != null && toks[k].match < to ? [k + 1, toks[k].match, true] : [k, to, false];
|
|
@@ -32352,13 +32421,13 @@ function makeReader2(src) {
|
|
|
32352
32421
|
const step = { kind: "try", says: `Tries these steps and handles any error${target ? ` (the answer becomes ${target})` : ""}`, ...base2(s, e, head(s, e)) };
|
|
32353
32422
|
const expr = call2.args.find((a) => !a.name || a.name === "expr");
|
|
32354
32423
|
if (expr && at02(expr.toks).length) {
|
|
32355
|
-
const r =
|
|
32424
|
+
const r = range2(at02(expr.toks));
|
|
32356
32425
|
const kids2 = stepsOfBody(r[0], r[1], { ...ctx, last: !!target || ctx.last });
|
|
32357
32426
|
if (kids2.length) step.children = kids2;
|
|
32358
32427
|
}
|
|
32359
32428
|
for (const a of call2.args.filter((x) => x.name && x.name !== "expr")) {
|
|
32360
32429
|
const fv = fnValue(a.toks);
|
|
32361
|
-
const r = at02(a.toks).length ?
|
|
32430
|
+
const r = at02(a.toks).length ? range2(at02(a.toks)) : null;
|
|
32362
32431
|
if (a.name === "finally") {
|
|
32363
32432
|
step.always = { line: lineAt5(at02(a.toks)[0]?.at ?? toks[s].at), steps: r ? stepsOfBody(r[0], r[1], { ...ctx, last: false }) : [] };
|
|
32364
32433
|
continue;
|
|
@@ -32383,7 +32452,7 @@ function makeReader2(src) {
|
|
|
32383
32452
|
}
|
|
32384
32453
|
const names = a.name ? [...pending, a.name] : null;
|
|
32385
32454
|
pending = [];
|
|
32386
|
-
const r = vtoks.length ?
|
|
32455
|
+
const r = vtoks.length ? range2(vtoks) : null;
|
|
32387
32456
|
const kids2 = r ? stepsOfBody(r[0], r[1], ctx) : [];
|
|
32388
32457
|
arms.push({ kind: "check", says: names ? `When it is ${list2(names.map((n) => `"${n}"`)).replace(/,? and ([^,]*)$/, " or $1")}` : "Otherwise", caseLabel: true, code: names ? `${names.join(", ")} =` : "(default)", line: lineAt5(vtoks[0]?.at ?? toks[s].at), span: r ? spanOf2(r[0], r[1]) : spanOf2(s, e), ...kids2.length ? { children: kids2 } : {} });
|
|
32389
32458
|
}
|
|
@@ -32437,12 +32506,12 @@ function makeReader2(src) {
|
|
|
32437
32506
|
if (bare2 === "source") return [{ kind: "call", says: `Runs the R file ${a0 ?? "?"}`, ...base2(s, e) }];
|
|
32438
32507
|
if (bare2 === "tryCatch" || bare2 === "withCallingHandlers") return [tryStep(call2, s, e, ctx)];
|
|
32439
32508
|
if (bare2 === "try") {
|
|
32440
|
-
const r = args[0] && at02(args[0].toks).length ?
|
|
32509
|
+
const r = args[0] && at02(args[0].toks).length ? range2(at02(args[0].toks)) : null;
|
|
32441
32510
|
const kids2 = r ? stepsOfBody(r[0], r[1], { ...ctx, last: false }) : [];
|
|
32442
32511
|
return [{ kind: "try", says: "Tries these steps, and carries on if they fail", ...base2(s, e, head(s, e)), ...kids2.length ? { children: kids2 } : {}, handlers: [{ says: "If anything goes wrong", line: lineAt5(toks[s].at), steps: [] }] }];
|
|
32443
32512
|
}
|
|
32444
32513
|
if (bare2 === "on.exit") {
|
|
32445
|
-
const r = args[0] && at02(args[0].toks).length ?
|
|
32514
|
+
const r = args[0] && at02(args[0].toks).length ? range2(at02(args[0].toks)) : null;
|
|
32446
32515
|
const kids2 = r ? stepsOfBody(r[0], r[1], { ...ctx, last: false }) : [];
|
|
32447
32516
|
return [{ kind: "call", says: "At the end, even if something fails, it runs these steps", ...base2(s, e, head(s, e)), ...kids2.length ? { children: kids2, nested: true } : {} }];
|
|
32448
32517
|
}
|
|
@@ -33090,7 +33159,7 @@ function findFunctions(src, language) {
|
|
|
33090
33159
|
fns.push({ key: `${name}@${m.index}`, name, line: fnLine2, params: parseParams2(src.slice(open + 1, close), language), returns: (head[1] || "").trim() || null, bodyStart: markerAt2 + 1 + lead, body: `return ${rest2.slice(lead, end2).trim()}`, exprBody: rest2.slice(lead, end2).trim().length });
|
|
33091
33160
|
continue;
|
|
33092
33161
|
}
|
|
33093
|
-
const
|
|
33162
|
+
const key2 = `${name}@${m.index}`;
|
|
33094
33163
|
const fnLine = lineAt2(src, m.index + m[0].lastIndexOf(name));
|
|
33095
33164
|
if (seen.has(name + ":" + fnLine)) continue;
|
|
33096
33165
|
seen.add(name + ":" + fnLine);
|
|
@@ -33102,17 +33171,17 @@ function findFunctions(src, language) {
|
|
|
33102
33171
|
const lead = rest2.match(/^\s*/)[0].length;
|
|
33103
33172
|
if (rest2[lead] === "{") {
|
|
33104
33173
|
const bo = markerAt + 2 + lead, bc = matchClose(src, bo);
|
|
33105
|
-
if (bc > 0) fns.push({ key, name, line: fnLine, params, returns, bodyStart: bo + 1, body: src.slice(bo + 1, bc) });
|
|
33174
|
+
if (bc > 0) fns.push({ key: key2, name, line: fnLine, params, returns, bodyStart: bo + 1, body: src.slice(bo + 1, bc) });
|
|
33106
33175
|
} else {
|
|
33107
33176
|
const semi = topLevelIndex(rest2, ";");
|
|
33108
33177
|
const blank = rest2.search(/\n\s*\n/);
|
|
33109
33178
|
const end2 = semi < 0 ? blank : blank < 0 ? semi : Math.min(semi, blank);
|
|
33110
33179
|
const expr = (end2 < 0 ? rest2 : rest2.slice(0, end2)).trim();
|
|
33111
|
-
fns.push({ key, name, line: fnLine, params, returns, bodyStart: markerAt + 2 + lead, body: `return ${expr};`, exprBody: expr.length });
|
|
33180
|
+
fns.push({ key: key2, name, line: fnLine, params, returns, bodyStart: markerAt + 2 + lead, body: `return ${expr};`, exprBody: expr.length });
|
|
33112
33181
|
}
|
|
33113
33182
|
} else {
|
|
33114
33183
|
const bc = matchClose(src, markerAt);
|
|
33115
|
-
if (bc > 0) fns.push({ key, name, line: fnLine, params, returns, bodyStart: markerAt + 1, body: src.slice(markerAt + 1, bc) });
|
|
33184
|
+
if (bc > 0) fns.push({ key: key2, name, line: fnLine, params, returns, bodyStart: markerAt + 1, body: src.slice(markerAt + 1, bc) });
|
|
33116
33185
|
}
|
|
33117
33186
|
}
|
|
33118
33187
|
}
|
|
@@ -35433,14 +35502,14 @@ function anchorSpan(span, fn, lang) {
|
|
|
35433
35502
|
}
|
|
35434
35503
|
}
|
|
35435
35504
|
function markBuildOnlySteps(steps, fn, lang, code3, srcLines) {
|
|
35436
|
-
const
|
|
35437
|
-
if (!
|
|
35505
|
+
const range2 = srcLines.length ? bodyRange(fn, lang, code3) : null;
|
|
35506
|
+
if (!range2) return;
|
|
35438
35507
|
const only = /* @__PURE__ */ new Map();
|
|
35439
35508
|
const stack = [];
|
|
35440
35509
|
const clean = (t) => t.replace(/\s*\/[/*].*$/, "").replace(/\s+/g, " ").trim();
|
|
35441
|
-
for (let l =
|
|
35510
|
+
for (let l = range2[0]; l <= range2[1]; l++) {
|
|
35442
35511
|
let t = (srcLines[l - 1] ?? "").trim();
|
|
35443
|
-
while (/^#/.test(t) && /\\$/.test(t) && l <
|
|
35512
|
+
while (/^#/.test(t) && /\\$/.test(t) && l < range2[1]) t = `${t.slice(0, -1).trim()} ${(srcLines[l++] ?? "").trim()}`;
|
|
35444
35513
|
let m;
|
|
35445
35514
|
if (m = t.match(/^#\s*(if|ifdef|ifndef)\b(.*)$/)) stack.push({ first: clean(`#${m[1]}${m[2]}`), label: clean(`#${m[1]}${m[2]}`) });
|
|
35446
35515
|
else if ((m = t.match(/^#\s*(elif|elifdef|elifndef)\b(.*)$/)) && stack.length) stack[stack.length - 1].label = clean(`#${m[1]}${m[2]}`);
|
|
@@ -35593,20 +35662,20 @@ function functionSteps(fn, lang, code3, names, srcLines = []) {
|
|
|
35593
35662
|
};
|
|
35594
35663
|
withExpr(r.steps);
|
|
35595
35664
|
for (const sk of r.skipped) anchorSpan(sk, fn, lang);
|
|
35596
|
-
const
|
|
35597
|
-
if (
|
|
35665
|
+
const range2 = bodyRange(fn, lang, code3);
|
|
35666
|
+
if (range2) {
|
|
35598
35667
|
const covered = /* @__PURE__ */ new Set();
|
|
35599
35668
|
for (const sp of [...r.steps.map((x) => x.span), ...r.skipped]) if (sp) for (let l = sp.startLine; l <= sp.endLine; l++) covered.add(l);
|
|
35600
35669
|
let real = 0, hit = 0;
|
|
35601
35670
|
const missing = [];
|
|
35602
|
-
for (let l =
|
|
35671
|
+
for (let l = range2[0]; l <= range2[1]; l++) {
|
|
35603
35672
|
const t = srcLines[l - 1] ?? "";
|
|
35604
35673
|
if (TRIVIA_LINE.test(t)) continue;
|
|
35605
35674
|
real++;
|
|
35606
35675
|
if (covered.has(l)) hit++;
|
|
35607
35676
|
else if (missing.length < 5) missing.push(l);
|
|
35608
35677
|
}
|
|
35609
|
-
r.anchor = { schema: "thunder-anchor-v1", bodyLines:
|
|
35678
|
+
r.anchor = { schema: "thunder-anchor-v1", bodyLines: range2, codeLines: real, coveredLines: hit, coverage: real ? Math.round(hit / real * 1e3) / 1e3 : 1, missing };
|
|
35610
35679
|
}
|
|
35611
35680
|
for (const st of r.steps) {
|
|
35612
35681
|
if (st.kind !== "branch" || !st.cond) continue;
|
|
@@ -36251,10 +36320,10 @@ function plainFromReading(item4) {
|
|
|
36251
36320
|
};
|
|
36252
36321
|
for (const r of item4.rules) {
|
|
36253
36322
|
const when = r.when.trim();
|
|
36254
|
-
const
|
|
36323
|
+
const join9 = / or /.test(when) ? "any" : "all";
|
|
36255
36324
|
if (/ or /.test(when) && / and /.test(when)) return null;
|
|
36256
36325
|
const conditions = [];
|
|
36257
|
-
for (const part of when.split(
|
|
36326
|
+
for (const part of when.split(join9 === "all" ? " and " : " or ")) {
|
|
36258
36327
|
const t = part.trim();
|
|
36259
36328
|
let m;
|
|
36260
36329
|
const input2 = (id2) => inputs2.find((i) => i.id === id2);
|
|
@@ -36278,7 +36347,7 @@ function plainFromReading(item4) {
|
|
|
36278
36347
|
} else return null;
|
|
36279
36348
|
}
|
|
36280
36349
|
if (!outcome3(r.result)) return null;
|
|
36281
|
-
model.rules.push({ outcome: r.result, join:
|
|
36350
|
+
model.rules.push({ outcome: r.result, join: join9, conditions });
|
|
36282
36351
|
}
|
|
36283
36352
|
if (!outcome3(item4.otherwise.result)) return null;
|
|
36284
36353
|
model.otherwise = item4.otherwise.result;
|
|
@@ -36426,8 +36495,8 @@ function visualFor(item4) {
|
|
|
36426
36495
|
return { element: item4.route ? "action" : "function", shape: "steps-card", line: "solid", title: item4.title ?? (item4.route ? `When someone calls ${badge.text}` : `What ${words10(item4.name)} does`), ...badge ? { badge } : {}, ...base2 };
|
|
36427
36496
|
}
|
|
36428
36497
|
function visualForStep(step) {
|
|
36429
|
-
const
|
|
36430
|
-
const m = STEP_MARKS[
|
|
36498
|
+
const key2 = step?.restates ? "restates" : STEP_MARKS[step?.kind] ? step.kind : "other";
|
|
36499
|
+
const m = STEP_MARKS[key2];
|
|
36431
36500
|
return { mark: m.mark, label: m.label, color: m.color, show: m.show, line: m.line || "solid", text: m.show === "code" ? step.code ?? step.says : step.says };
|
|
36432
36501
|
}
|
|
36433
36502
|
function safePlain(item4) {
|
|
@@ -37269,9 +37338,9 @@ function callsIn(expr, out = []) {
|
|
|
37269
37338
|
var bind = (files, symbol = null, extra = {}) => ({ files, symbol, ...extra });
|
|
37270
37339
|
function jsImports(src, file, ctx, out) {
|
|
37271
37340
|
const clean = stripComments2(src);
|
|
37272
|
-
const
|
|
37341
|
+
const resolve7 = (spec) => ctx.jsFile(file, spec);
|
|
37273
37342
|
const add2 = (local, spec, symbol, line) => {
|
|
37274
|
-
const r =
|
|
37343
|
+
const r = resolve7(spec);
|
|
37275
37344
|
if (r.file) out.bindings.set(local, bind([r.file], symbol, { line, spec }));
|
|
37276
37345
|
else out.unresolved.push({ file, line, import: spec, why: r.why });
|
|
37277
37346
|
};
|
|
@@ -37831,10 +37900,10 @@ function linkSystem(model, files) {
|
|
|
37831
37900
|
if (once.has(k)) continue;
|
|
37832
37901
|
once.add(k);
|
|
37833
37902
|
if (/^(external|standard library)/.test(u.why)) {
|
|
37834
|
-
const
|
|
37835
|
-
const e = external.get(
|
|
37903
|
+
const key2 = u.why;
|
|
37904
|
+
const e = external.get(key2);
|
|
37836
37905
|
if (e) e.files++;
|
|
37837
|
-
else external.set(
|
|
37906
|
+
else external.set(key2, { file, line: u.line, import: u.import, why: u.why, files: 1 });
|
|
37838
37907
|
} else notLinked.push(u);
|
|
37839
37908
|
}
|
|
37840
37909
|
}
|
|
@@ -37997,7 +38066,7 @@ function linkSystem(model, files) {
|
|
|
37997
38066
|
}
|
|
37998
38067
|
return typesFor2(file).get(name);
|
|
37999
38068
|
};
|
|
38000
|
-
const
|
|
38069
|
+
const resolve7 = (file, path, isNew, member) => {
|
|
38001
38070
|
const lang = langOf.get(file);
|
|
38002
38071
|
const mod = modules.get(file);
|
|
38003
38072
|
if (!mod) return { why: null };
|
|
@@ -38137,7 +38206,7 @@ function linkSystem(model, files) {
|
|
|
38137
38206
|
task = /^(delay|apply_async|perform_async|perform_later)$/.test(last);
|
|
38138
38207
|
}
|
|
38139
38208
|
argc = (call2.args || []).length;
|
|
38140
|
-
const r =
|
|
38209
|
+
const r = resolve7(m.file, p, isNew, m);
|
|
38141
38210
|
if (r.member && r.member.id !== m.id) {
|
|
38142
38211
|
const cross = r.member.file !== m.file;
|
|
38143
38212
|
link({ from: m.id, to: r.member.id, kind: task ? "sends-to" : "uses", node: nd.id, file: r.member.file, line: nd.line ?? null, ...cross ? { crossFile: true } : {}, ...task ? { task: r.member.name } : {} });
|
|
@@ -38873,17 +38942,17 @@ function parse3(src) {
|
|
|
38873
38942
|
opt2(",");
|
|
38874
38943
|
continue;
|
|
38875
38944
|
}
|
|
38876
|
-
let
|
|
38945
|
+
let key2;
|
|
38877
38946
|
if (at2("[")) {
|
|
38878
38947
|
next();
|
|
38879
|
-
|
|
38948
|
+
key2 = { computed: expression() };
|
|
38880
38949
|
eat("]");
|
|
38881
|
-
} else
|
|
38950
|
+
} else key2 = next().v;
|
|
38882
38951
|
let value;
|
|
38883
38952
|
if (opt2(":")) value = pattern2();
|
|
38884
|
-
else value = { type: "Id", name: typeof
|
|
38953
|
+
else value = { type: "Id", name: typeof key2 === "string" ? key2 : "?", line };
|
|
38885
38954
|
if (opt2("=")) value = { type: "Default", target: value, value: assign(), line };
|
|
38886
|
-
props.push({ key, value });
|
|
38955
|
+
props.push({ key: key2, value });
|
|
38887
38956
|
if (!opt2(",")) break;
|
|
38888
38957
|
}
|
|
38889
38958
|
eat("}");
|
|
@@ -38998,16 +39067,16 @@ function parse3(src) {
|
|
|
38998
39067
|
if ((at2("get") || at2("set")) && !at2("(", 1) && !at2("=", 1) && !at2(":", 1)) {
|
|
38999
39068
|
kind = next().v;
|
|
39000
39069
|
}
|
|
39001
|
-
let
|
|
39070
|
+
let key2;
|
|
39002
39071
|
if (at2("[")) {
|
|
39003
39072
|
next();
|
|
39004
39073
|
expression();
|
|
39005
39074
|
eat("]");
|
|
39006
|
-
|
|
39075
|
+
key2 = "[computed]";
|
|
39007
39076
|
} else if (at2("#")) {
|
|
39008
39077
|
next();
|
|
39009
|
-
|
|
39010
|
-
} else
|
|
39078
|
+
key2 = "#" + next().v;
|
|
39079
|
+
} else key2 = next().v;
|
|
39011
39080
|
opt2("?");
|
|
39012
39081
|
opt2("!");
|
|
39013
39082
|
if (at2("(") || at2("<")) {
|
|
@@ -39019,12 +39088,12 @@ function parse3(src) {
|
|
|
39019
39088
|
opt2(";");
|
|
39020
39089
|
continue;
|
|
39021
39090
|
}
|
|
39022
|
-
members.push({ kind, key, isStatic, fn: { type: "Arrow", params: ps, body: body2, isAsync, line: mline, isMethod: true, name:
|
|
39091
|
+
members.push({ kind, key: key2, isStatic, fn: { type: "Arrow", params: ps, body: body2, isAsync, line: mline, isMethod: true, name: key2 }, line: mline });
|
|
39023
39092
|
} else {
|
|
39024
39093
|
if (opt2(":")) skipType(["=", ";", "}"]);
|
|
39025
39094
|
const value = opt2("=") ? assign() : null;
|
|
39026
39095
|
semi();
|
|
39027
|
-
members.push({ kind: "field", key, isStatic, value, line: mline });
|
|
39096
|
+
members.push({ kind: "field", key: key2, isStatic, value, line: mline });
|
|
39028
39097
|
}
|
|
39029
39098
|
}
|
|
39030
39099
|
eat("}");
|
|
@@ -39315,27 +39384,27 @@ function parse3(src) {
|
|
|
39315
39384
|
}
|
|
39316
39385
|
opt2("*");
|
|
39317
39386
|
if ((at2("get") || at2("set")) && !at2(",", 1) && !at2(":", 1) && !at2("(", 1) && !at2("}", 1)) kind = next().v;
|
|
39318
|
-
let
|
|
39387
|
+
let key2, computed = null;
|
|
39319
39388
|
if (at2("[")) {
|
|
39320
39389
|
next();
|
|
39321
39390
|
computed = assign();
|
|
39322
39391
|
eat("]");
|
|
39323
|
-
|
|
39392
|
+
key2 = computed.type === "Lit" ? String(computed.value) : null;
|
|
39324
39393
|
} else {
|
|
39325
39394
|
const kt = next();
|
|
39326
|
-
|
|
39395
|
+
key2 = kt.t === "num" ? kt.v : kt.v;
|
|
39327
39396
|
}
|
|
39328
39397
|
if (at2("(") || at2("<")) {
|
|
39329
39398
|
if (at2("<")) skipBalanced2();
|
|
39330
39399
|
const ps = params();
|
|
39331
39400
|
if (opt2(":")) skipType(["{"]);
|
|
39332
39401
|
const body2 = block();
|
|
39333
|
-
props.push({ key, value: { type: "Arrow", params: ps, body: body2, isAsync, line: pline, isMethod: true, name:
|
|
39334
|
-
} else if (opt2(":")) props.push({ key, computed, value: assign(), line: pline });
|
|
39402
|
+
props.push({ key: key2, value: { type: "Arrow", params: ps, body: body2, isAsync, line: pline, isMethod: true, name: key2 }, method: true, kind, line: pline });
|
|
39403
|
+
} else if (opt2(":")) props.push({ key: key2, computed, value: assign(), line: pline });
|
|
39335
39404
|
else if (at2("=")) {
|
|
39336
39405
|
next();
|
|
39337
|
-
props.push({ key, value: { type: "Id", name:
|
|
39338
|
-
} else props.push({ key, value: { type: "Id", name:
|
|
39406
|
+
props.push({ key: key2, value: { type: "Id", name: key2, line: pline }, shorthand: true, line: pline, dflt: assign() });
|
|
39407
|
+
} else props.push({ key: key2, value: { type: "Id", name: key2, line: pline }, shorthand: true, line: pline });
|
|
39339
39408
|
if (!opt2(",")) break;
|
|
39340
39409
|
}
|
|
39341
39410
|
eat("}");
|
|
@@ -39731,10 +39800,10 @@ var Analyzer = class {
|
|
|
39731
39800
|
}
|
|
39732
39801
|
// A module-level name, resolved through imports. Returns a value.
|
|
39733
39802
|
moduleValue(file, name, line, seen = /* @__PURE__ */ new Set()) {
|
|
39734
|
-
const
|
|
39735
|
-
if (this.moduleCache.has(
|
|
39736
|
-
if (seen.has(
|
|
39737
|
-
seen.add(
|
|
39803
|
+
const key2 = `${file}::${name}`;
|
|
39804
|
+
if (this.moduleCache.has(key2)) return this.moduleCache.get(key2);
|
|
39805
|
+
if (seen.has(key2)) return {};
|
|
39806
|
+
seen.add(key2);
|
|
39738
39807
|
const m = this.p.files.get(file);
|
|
39739
39808
|
let v;
|
|
39740
39809
|
const b = m.bindings.get(name);
|
|
@@ -39750,7 +39819,7 @@ var Analyzer = class {
|
|
|
39750
39819
|
if (/^@prisma\/client$|^drizzle-orm|^knex$|^pg$|^postgres$|^mysql2?|^@neondatabase|^kysely$/.test(imp.from) && DB_NAMES.test(name)) v.isDb = { label: name };
|
|
39751
39820
|
}
|
|
39752
39821
|
}
|
|
39753
|
-
this.moduleCache.set(
|
|
39822
|
+
this.moduleCache.set(key2, v);
|
|
39754
39823
|
return v;
|
|
39755
39824
|
}
|
|
39756
39825
|
exportValue(file, name, seen = /* @__PURE__ */ new Set()) {
|
|
@@ -40022,8 +40091,8 @@ var Analyzer = class {
|
|
|
40022
40091
|
this.bindPattern(prop.rest, v, scope, st, ctx, declare);
|
|
40023
40092
|
continue;
|
|
40024
40093
|
}
|
|
40025
|
-
const
|
|
40026
|
-
const mv =
|
|
40094
|
+
const key2 = typeof prop.key === "string" ? prop.key : null;
|
|
40095
|
+
const mv = key2 ? this.member(v, key2, st, ctx, p.line) : dataOf(v);
|
|
40027
40096
|
this.bindPattern(prop.value, mv, scope, st, ctx, declare);
|
|
40028
40097
|
}
|
|
40029
40098
|
return;
|
|
@@ -41092,17 +41161,17 @@ function accessFlow(files, { maxRoutes = 2e3 } = {}) {
|
|
|
41092
41161
|
for (const sink of res.route.sinks) {
|
|
41093
41162
|
for (const rec2 of sink.val.recs ?? []) {
|
|
41094
41163
|
if (rec2.kind === "create") continue;
|
|
41095
|
-
const
|
|
41096
|
-
if (seen.has(
|
|
41097
|
-
seen.add(
|
|
41164
|
+
const key2 = `${rec2.id}@${sink.line}`;
|
|
41165
|
+
if (seen.has(key2)) continue;
|
|
41166
|
+
seen.add(key2);
|
|
41098
41167
|
const p = judgePath(sink, rec2);
|
|
41099
41168
|
if (p) paths.push(p);
|
|
41100
41169
|
}
|
|
41101
41170
|
if (!(sink.val.recs ?? []).some((rc) => rc.keyed || rc.unknownWhere)) {
|
|
41102
41171
|
for (const u of sink.val.unknown ?? []) {
|
|
41103
|
-
const
|
|
41104
|
-
if (seen.has(
|
|
41105
|
-
seen.add(
|
|
41172
|
+
const key2 = `${u.file}:${u.line}@${sink.line}`;
|
|
41173
|
+
if (seen.has(key2)) continue;
|
|
41174
|
+
seen.add(key2);
|
|
41106
41175
|
paths.push(judgeUnknown(sink, u));
|
|
41107
41176
|
}
|
|
41108
41177
|
}
|
|
@@ -41705,9 +41774,9 @@ function youGiveOf(item4) {
|
|
|
41705
41774
|
var dirOf3 = (p) => String(p).includes("/") ? String(p).slice(0, String(p).lastIndexOf("/")) : "";
|
|
41706
41775
|
function resolveAcrossFiles(pending, things, links, linkKeys) {
|
|
41707
41776
|
const add2 = (p, to) => {
|
|
41708
|
-
const
|
|
41709
|
-
if (to && to !== p.from && !linkKeys.has(
|
|
41710
|
-
linkKeys.add(
|
|
41777
|
+
const key2 = `${p.from}>${to}>${p.l.kind}>${p.l.line}`;
|
|
41778
|
+
if (to && to !== p.from && !linkKeys.has(key2)) {
|
|
41779
|
+
linkKeys.add(key2);
|
|
41711
41780
|
links.push({ from: p.from, to, kind: p.l.kind, file: p.l.file, line: p.l.line });
|
|
41712
41781
|
}
|
|
41713
41782
|
};
|
|
@@ -41789,8 +41858,8 @@ function thunderModel(files, { name = "app" } = {}) {
|
|
|
41789
41858
|
const declaredThing = (item4) => fileThings.some((t) => !t.assigned && t.name === item4.name && t.lines[0] === item4.line);
|
|
41790
41859
|
const fileMembers = fns.filter((item4) => !declaredThing(item4)).map((item4) => {
|
|
41791
41860
|
const inside2 = infra ? void 0 : fileThings.filter((t) => !t.assigned && (item4.line > t.lines[0] && item4.line <= t.lines[1] || (t.memberRanges || []).some(([a, b]) => item4.line >= a && item4.line <= b))).sort((a, b) => b.lines[0] - a.lines[0])[0] ?? (item4.qualifier ? fileThings.find((t) => !t.assigned && t.name === item4.qualifier && t.kind !== "choices") : void 0) ?? (language === "c" ? fileThings.find((t) => !t.assigned && t.kind !== "choices" && cOwns(t, item4)) : void 0);
|
|
41792
|
-
const
|
|
41793
|
-
const owner = infra ? void 0 : inside2 ?? fileThings.find((t) => t.assigned && (t.assigned.includes(
|
|
41861
|
+
const key2 = `${item4.name}:${item4.line}`;
|
|
41862
|
+
const owner = infra ? void 0 : inside2 ?? fileThings.find((t) => t.assigned && (t.assigned.includes(key2) || t.ctor === key2 || !item4.assignedTo && t.spans.some(([a, b]) => item4.line > a && item4.line <= b)));
|
|
41794
41863
|
const own = language === "c" && owner ? cShortName(owner, item4.name) : item4.name;
|
|
41795
41864
|
if (language === "c" && owner && owner.kind === "record") owner.kind = "thing";
|
|
41796
41865
|
const v = visualFor(item4);
|
|
@@ -41862,9 +41931,9 @@ function thunderModel(files, { name = "app" } = {}) {
|
|
|
41862
41931
|
const byThing = new Map(fileThings.map((t) => [t.name, t.id]));
|
|
41863
41932
|
for (const l of infra.links) {
|
|
41864
41933
|
const from = byItem.get(l.from) ?? byThing.get(l.from), to = byItem.get(l.to) ?? byThing.get(l.to);
|
|
41865
|
-
const
|
|
41866
|
-
if (from && to && !linkKeys.has(
|
|
41867
|
-
linkKeys.add(
|
|
41934
|
+
const key2 = `${from}>${to}>${l.kind}>${l.line}`;
|
|
41935
|
+
if (from && to && !linkKeys.has(key2)) {
|
|
41936
|
+
linkKeys.add(key2);
|
|
41868
41937
|
links.push({ from, to, kind: l.kind, file: l.file, line: l.line });
|
|
41869
41938
|
} else if (from && !to && (language === "terraform" || language === "kubernetes" || language === "docker-compose")) pending.push({ dir: dirOf3(f.path), from, l, language });
|
|
41870
41939
|
}
|
|
@@ -41874,9 +41943,9 @@ function thunderModel(files, { name = "app" } = {}) {
|
|
|
41874
41943
|
const dockerImages = things.filter((t) => t.resourceType === "docker-image");
|
|
41875
41944
|
for (const t of things) for (const im of t.images ?? []) {
|
|
41876
41945
|
const hits = dockerImages.filter((d) => dirOf3(d.address.slice("image:".length)).split("/").pop() === im.name);
|
|
41877
|
-
const
|
|
41878
|
-
if (
|
|
41879
|
-
linkKeys.add(
|
|
41946
|
+
const key2 = hits.length === 1 && `${t.id}>${hits[0].id}>uses>${im.line}`;
|
|
41947
|
+
if (key2 && !linkKeys.has(key2)) {
|
|
41948
|
+
linkKeys.add(key2);
|
|
41880
41949
|
links.push({ from: t.id, to: hits[0].id, kind: "uses", file: t.file, line: im.line });
|
|
41881
41950
|
}
|
|
41882
41951
|
}
|
|
@@ -42224,10 +42293,10 @@ function readLevel(model, level, focus, { full = false } = {}) {
|
|
|
42224
42293
|
const base2 = { level: lv.id, name: lv.name, question: lv.question };
|
|
42225
42294
|
const about = member ? { scope: "member", id: member.id, title: member.label + (member.yesNo ? "?" : ""), symbol: SYMBOL_OF[member.kind], file: member.file, lines: member.lines } : thing ? { scope: "thing", id: thing.id, title: thing.label, symbol: SYMBOL_OF[thing.kind], file: thing.file, lines: thing.lines } : { scope: "app", id: null, title: model.name, symbol: "app", file: model.files[0]?.path ?? null, lines: null };
|
|
42226
42295
|
const memberById = (id2) => model.members.find((m) => m.id === id2);
|
|
42227
|
-
const once = (ls,
|
|
42296
|
+
const once = (ls, key2) => {
|
|
42228
42297
|
const seen = /* @__PURE__ */ new Set();
|
|
42229
42298
|
return ls.filter((l) => {
|
|
42230
|
-
const k = `${l[
|
|
42299
|
+
const k = `${l[key2]}|${l.kind}`;
|
|
42231
42300
|
if (seen.has(k)) return false;
|
|
42232
42301
|
seen.add(k);
|
|
42233
42302
|
return true;
|
|
@@ -42405,7 +42474,7 @@ var SETTING_READS = [
|
|
|
42405
42474
|
new RegExp(`\\bgetenv\\(\\s*${Q}${KEY}${Q}`, "g"),
|
|
42406
42475
|
new RegExp(`\\$_ENV\\[\\s*${Q}${KEY}${Q}`, "g")
|
|
42407
42476
|
];
|
|
42408
|
-
var isGenericSetting = (
|
|
42477
|
+
var isGenericSetting = (key2) => GENERIC_SETTINGS.has(key2) || /^(VERCEL_|EAS_BUILD|GITHUB_|RUNNER_|npm_|NETLIFY|RENDER_|RAILWAY_|FLY_|HEROKU_|AWS_LAMBDA_|K_SERVICE|KUBERNETES_)/.test(key2);
|
|
42409
42478
|
var GENERIC_SETTINGS = /* @__PURE__ */ new Set(["NODE_ENV", "PORT", "HOST", "HOSTNAME", "HOME", "PATH", "PWD", "USER", "SHELL", "TMPDIR", "TEMP", "TMP", "TZ", "LANG", "CI", "DEBUG", "ENV", "ENVIRONMENT", "APP_ENV", "LOG_LEVEL", "LOGLEVEL", "VERBOSE", "GITHUB_ACTIONS", "npm_package_version", "ASPNETCORE_ENVIRONMENT", "DOTNET_ENVIRONMENT", "PYTHONPATH", "GOPATH", "JAVA_HOME", "NODE_OPTIONS", "CI_COMMIT_SHA"]);
|
|
42410
42479
|
function settingsIn(files) {
|
|
42411
42480
|
const out = [];
|
|
@@ -42658,7 +42727,7 @@ function sharedFacts(read) {
|
|
|
42658
42727
|
};
|
|
42659
42728
|
const manyRepos = (xs) => new Set(xs.map((y) => y.repo.name)).size > 1;
|
|
42660
42729
|
const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
42661
|
-
const settings = [...group(read.flatMap((r) => (r.settings ?? []).filter((x) => !isGenericSetting(x.key)).map((x) => [x.key, r, x]))).entries()].filter(([, xs]) => manyRepos(xs)).sort(byKey).map(([
|
|
42730
|
+
const settings = [...group(read.flatMap((r) => (r.settings ?? []).filter((x) => !isGenericSetting(x.key)).map((x) => [x.key, r, x]))).entries()].filter(([, xs]) => manyRepos(xs)).sort(byKey).map(([key2, xs]) => ({ key: key2, readers: xs.map(({ repo, x }) => end(repo, x)) }));
|
|
42662
42731
|
const tables = [...group(read.flatMap((r) => (r.tables ?? []).map((x) => [x.table, r, x]))).entries()].filter(([, xs]) => manyRepos(xs)).sort(byKey).map(([table, xs]) => ({ table, users: xs.map(({ repo, x }) => ({ ...end(repo, x), access: x.access })) }));
|
|
42663
42732
|
const drift = [];
|
|
42664
42733
|
for (const [name, xs] of [...group(read.flatMap((r) => (r.packages?.depends ?? []).filter((d) => d.version && !d.peer && !LOCAL_VERSION.test(d.version)).map((d) => [d.package, r, d]))).entries()].sort(byKey)) {
|
|
@@ -42726,11 +42795,11 @@ function traceImpact(trace, changes) {
|
|
|
42726
42795
|
if (!isTestFile(c.file)) {
|
|
42727
42796
|
for (const p of repo.packages?.publishes ?? []) {
|
|
42728
42797
|
if (p.root && c.file !== p.root && !c.file.startsWith(`${p.root}/`)) continue;
|
|
42729
|
-
const
|
|
42730
|
-
if (packagesDone.has(
|
|
42798
|
+
const key2 = `${repo.name}|${p.package}`;
|
|
42799
|
+
if (packagesDone.has(key2)) continue;
|
|
42731
42800
|
const deps = trace.links.filter((l) => l.kind === "package" && l.to.repo === repo.name && l.package === p.package);
|
|
42732
42801
|
if (!deps.length) continue;
|
|
42733
|
-
packagesDone.add(
|
|
42802
|
+
packagesDone.add(key2);
|
|
42734
42803
|
findings2.push({ risk: "medium", kind: "package-changed", says: `${p.package} is published from here, and ${count(new Set(deps.map((d) => d.from.repo)).size, "other repository")} ${new Set(deps.map((d) => d.from.repo)).size === 1 ? "depends" : "depend"} on it; the change reaches them when they take the new version`, at: end(repo, p), dependents: deps.map((l) => ({ ...l.from, how: `depends on ${p.package}${l.version ? ` ${l.version}` : ""}` })) });
|
|
42735
42804
|
}
|
|
42736
42805
|
}
|
|
@@ -43559,10 +43628,10 @@ var ExprParser = class {
|
|
|
43559
43628
|
if (this.names.alts?.size && s.peek()?.t === "word") {
|
|
43560
43629
|
const run = [];
|
|
43561
43630
|
for (let j = s.i; s.ts[j]?.t === "word" && !RESERVED2.has(s.ts[j].lower); j++) run.push(s.ts[j]);
|
|
43562
|
-
const ak = this.longest(run, (
|
|
43563
|
-
if (ak && !this.longest(run, (
|
|
43631
|
+
const ak = this.longest(run, (key2) => this.names.alts.has(key2));
|
|
43632
|
+
if (ak && !this.longest(run, (key2) => this.names.known.has(key2))) {
|
|
43564
43633
|
s.i += ak;
|
|
43565
|
-
return wrap2({ k: "isAlt", e: l, alt: keyOf(run.slice(0, ak)), text: run.slice(0, ak).map((x) => x.text).join(" "), line });
|
|
43634
|
+
return wrap2({ k: "isAlt", e: l, alt: keyOf(run.slice(0, ak)), text: run.slice(0, ak).map((x) => x.text).join(" "), col: run[0].col, line });
|
|
43566
43635
|
}
|
|
43567
43636
|
}
|
|
43568
43637
|
return { k: "cmp", op: neg2 ? "!=" : "==", l, r: this.add(s, o), line };
|
|
@@ -43613,15 +43682,15 @@ var ExprParser = class {
|
|
|
43613
43682
|
s.next();
|
|
43614
43683
|
const run = this.wordRun(s);
|
|
43615
43684
|
if (!run.length) s.fail(`I expected a field name after "'s".`, null, "TC108");
|
|
43616
|
-
const k = this.longest(run, (
|
|
43685
|
+
const k = this.longest(run, (key2) => this.names.fields.has(key2)) || run.length;
|
|
43617
43686
|
s.i -= run.length - k;
|
|
43618
|
-
e = { k: "field", obj: e, name: keyOf(run.slice(0, k)), text: run.slice(0, k).map((w) => w.text).join(" "), line: s.line };
|
|
43687
|
+
e = { k: "field", obj: e, name: keyOf(run.slice(0, k)), text: run.slice(0, k).map((w) => w.text).join(" "), col: run[0].col, line: s.line };
|
|
43619
43688
|
} else if (isWord(t, "at") && !isWord(s.peek(1), "least") && !isWord(s.peek(1), "most")) {
|
|
43620
43689
|
s.next();
|
|
43621
|
-
const
|
|
43690
|
+
const key2 = this.unary(s, { ...o, noAnd: true });
|
|
43622
43691
|
let dflt = null;
|
|
43623
43692
|
if (s.word("otherwise")) dflt = this.unary(s, { ...o, noAnd: true });
|
|
43624
|
-
e = { k: "at", obj: e, key, dflt, line: s.line };
|
|
43693
|
+
e = { k: "at", obj: e, key: key2, dflt, line: s.line };
|
|
43625
43694
|
} else if (isWord(t, "as")) {
|
|
43626
43695
|
s.next();
|
|
43627
43696
|
e = { k: "conv", e, type: this.typeRef(s), line: s.line };
|
|
@@ -43668,7 +43737,7 @@ var ExprParser = class {
|
|
|
43668
43737
|
fieldAhead(s, k) {
|
|
43669
43738
|
const run = [];
|
|
43670
43739
|
for (let j = s.i + k; s.ts[j]?.t === "word" && !RESERVED2.has(s.ts[j].lower); j++) run.push(s.ts[j]);
|
|
43671
|
-
return this.longest(run, (
|
|
43740
|
+
return this.longest(run, (key2) => this.names.fields.has(key2)) > 0;
|
|
43672
43741
|
}
|
|
43673
43742
|
longest(run, ok) {
|
|
43674
43743
|
for (let k = run.length; k > 0; k--) if (ok(keyOf(run.slice(0, k)))) return k;
|
|
@@ -43704,20 +43773,20 @@ var ExprParser = class {
|
|
|
43704
43773
|
}
|
|
43705
43774
|
if (w === "map") {
|
|
43706
43775
|
if (s.word("of")) {
|
|
43707
|
-
const
|
|
43776
|
+
const key3 = this.typeRef(s);
|
|
43708
43777
|
if (!s.word("to")) s.fail('"map of" needs "to": map of text to number.', null, "TC306");
|
|
43709
|
-
return { k: "map", key:
|
|
43778
|
+
return { k: "map", key: key3, of: this.typeRef(s) };
|
|
43710
43779
|
}
|
|
43711
43780
|
return { k: "map", key: { k: "unknown" }, of: { k: "unknown" } };
|
|
43712
43781
|
}
|
|
43713
43782
|
const simple = { number: "number", numbers: "number", text: "text", texts: "text", "yes/no": "bool", money: "money", date: "date", integer: "whole" }[w];
|
|
43714
43783
|
if (simple) return { k: simple };
|
|
43715
43784
|
const run = [t, ...this.wordRun(s)];
|
|
43716
|
-
const k = this.longest(run, (
|
|
43785
|
+
const k = this.longest(run, (key3) => this.names.records.has(key3)) || this.longest(run, (key3) => this.names.records.has(key3.replace(/s$/, "")));
|
|
43717
43786
|
if (!k) s.fail(`I don't know the kind of value "${run.map((x) => x.text).join(" ")}".`, 'Kinds: number, whole number, text, yes/no, money, date, list of \u2026, map of \u2026 to \u2026, optional \u2026, or a record you defined with "A \u2026 has:".', "TC306");
|
|
43718
43787
|
s.i -= run.length - k;
|
|
43719
|
-
const
|
|
43720
|
-
return { k: "record", name: this.names.records.has(
|
|
43788
|
+
const key2 = keyOf(run.slice(0, k));
|
|
43789
|
+
return { k: "record", name: this.names.records.has(key2) ? key2 : key2.replace(/s$/, ""), col: run[0].col, line: s.line };
|
|
43721
43790
|
}
|
|
43722
43791
|
/** The fields a record is built with: with name "Ann" and balance $10 (none without "with"). */
|
|
43723
43792
|
recordFields(s, line) {
|
|
@@ -43726,7 +43795,7 @@ var ExprParser = class {
|
|
|
43726
43795
|
do {
|
|
43727
43796
|
const fr = this.wordRun(s);
|
|
43728
43797
|
if (!fr.length) s.fail(`I expected a field name after "with" (for example: with name "Ann").`, null, "TC108");
|
|
43729
|
-
const fk = this.longest(fr, (
|
|
43798
|
+
const fk = this.longest(fr, (key2) => this.names.fields.has(key2)) || fr.length;
|
|
43730
43799
|
s.i -= fr.length - fk;
|
|
43731
43800
|
fields.push({ name: keyOf(fr.slice(0, fk)), text: fr.slice(0, fk).map((x) => x.text).join(" "), e: this.expr(s, { noAnd: true }), line });
|
|
43732
43801
|
} while ((isSym(s.peek(), ",") || isWord(s.peek(), "and")) && this.fieldAhead(s, 1) && s.next());
|
|
@@ -43879,27 +43948,27 @@ var ExprParser = class {
|
|
|
43879
43948
|
const alt = keyOf(run.slice(0, i));
|
|
43880
43949
|
const recs = this.names.alts.get(alt);
|
|
43881
43950
|
if (!recs) continue;
|
|
43882
|
-
const rk = this.longest(run.slice(i), (
|
|
43951
|
+
const rk = this.longest(run.slice(i), (key2) => recs.includes(key2));
|
|
43883
43952
|
if (!rk || i + rk !== run.length) continue;
|
|
43884
43953
|
s.i -= run.length - i - rk;
|
|
43885
|
-
const node2 = { k: "new", record: keyOf(run.slice(i, i + rk)), alt, altText: run.slice(0, i).map((x) => x.text).join(" "), fields: this.recordFields(s, line), line };
|
|
43954
|
+
const node2 = { k: "new", record: keyOf(run.slice(i, i + rk)), alt, altText: run.slice(0, i).map((x) => x.text).join(" "), altCol: run[0].col, recordCol: run[i].col, fields: this.recordFields(s, line), line };
|
|
43886
43955
|
return node2;
|
|
43887
43956
|
}
|
|
43888
43957
|
for (let i = 1; i < run.length; i++) {
|
|
43889
|
-
const rk = this.longest(run.slice(i), (
|
|
43958
|
+
const rk = this.longest(run.slice(i), (key2) => this.names.altsOf.has(key2));
|
|
43890
43959
|
if (!rk || i + rk !== run.length) continue;
|
|
43891
43960
|
s.i -= run.length - i - rk;
|
|
43892
|
-
return { k: "new", record: keyOf(run.slice(i, i + rk)), alt: keyOf(run.slice(0, i)), altText: run.slice(0, i).map((x) => x.text).join(" "), fields: this.recordFields(s, line), line };
|
|
43961
|
+
return { k: "new", record: keyOf(run.slice(i, i + rk)), alt: keyOf(run.slice(0, i)), altText: run.slice(0, i).map((x) => x.text).join(" "), altCol: run[0].col, recordCol: run[i].col, fields: this.recordFields(s, line), line };
|
|
43893
43962
|
}
|
|
43894
43963
|
}
|
|
43895
43964
|
let off = run[0]?.lower === "new" && run.length > 1 ? 1 : 0;
|
|
43896
|
-
const recK = this.longest(run.slice(off), (
|
|
43897
|
-
const wantsRecord = o.article || off || isWord(s.peek(), "with") || !this.longest(run, (
|
|
43965
|
+
const recK = this.longest(run.slice(off), (key2) => this.names.records.has(key2));
|
|
43966
|
+
const wantsRecord = o.article || off || isWord(s.peek(), "with") || !this.longest(run, (key2) => this.names.known.has(key2));
|
|
43898
43967
|
if (recK && wantsRecord && recK + off === run.length) {
|
|
43899
43968
|
s.i -= run.length - off - recK;
|
|
43900
43969
|
const name = keyOf(run.slice(off, off + recK));
|
|
43901
43970
|
const fields = this.recordFields(s, line);
|
|
43902
|
-
const node2 = { k: "new", record: name, fields, line };
|
|
43971
|
+
const node2 = { k: "new", record: name, recordCol: run[off].col, fields, line };
|
|
43903
43972
|
if (!fields.length && this.open) this.open.push(node2);
|
|
43904
43973
|
return node2;
|
|
43905
43974
|
}
|
|
@@ -43908,26 +43977,27 @@ var ExprParser = class {
|
|
|
43908
43977
|
s.next();
|
|
43909
43978
|
return { k: "from", name: keyOf(run), text: run.map((x) => x.text).join(" "), list: this.unary(s, o), line };
|
|
43910
43979
|
}
|
|
43911
|
-
const k = this.longest(run, (
|
|
43980
|
+
const k = this.longest(run, (key2) => this.names.known.has(key2));
|
|
43912
43981
|
if (k) {
|
|
43913
43982
|
s.i -= run.length - k;
|
|
43914
|
-
const
|
|
43983
|
+
const key2 = keyOf(run.slice(0, k));
|
|
43915
43984
|
const text2 = run.slice(0, k).map((x) => x.text).join(" ");
|
|
43916
|
-
if (this.names.known.get(
|
|
43917
|
-
|
|
43918
|
-
if (s.
|
|
43919
|
-
|
|
43985
|
+
if (this.names.known.get(key2) === "func") {
|
|
43986
|
+
const col = run[0].col;
|
|
43987
|
+
if (isSym(s.peek(), "(")) return { k: "call", name: key2, text: text2, col, args: this.parenArgs(s), line };
|
|
43988
|
+
if (s.word("with")) return { k: "call", name: key2, text: text2, col, args: this.withArgs(s), line };
|
|
43989
|
+
const node2 = { k: "call", name: key2, text: text2, col, args: [], line, bare: true };
|
|
43920
43990
|
if (this.open) this.open.push(node2);
|
|
43921
43991
|
return node2;
|
|
43922
43992
|
}
|
|
43923
|
-
return { k: "name", name:
|
|
43993
|
+
return { k: "name", name: key2, text: text2, col: run[0].col, line };
|
|
43924
43994
|
}
|
|
43925
|
-
const fk = this.longest(run, (
|
|
43995
|
+
const fk = this.longest(run, (key2) => this.names.fields.has(key2));
|
|
43926
43996
|
if (fk) {
|
|
43927
43997
|
s.i -= run.length - fk;
|
|
43928
|
-
return { k: "name", name: keyOf(run.slice(0, fk)), text: run.slice(0, fk).map((x) => x.text).join(" "), line, unknown: true };
|
|
43998
|
+
return { k: "name", name: keyOf(run.slice(0, fk)), text: run.slice(0, fk).map((x) => x.text).join(" "), col: run[0].col, line, unknown: true };
|
|
43929
43999
|
}
|
|
43930
|
-
return { k: "name", name: keyOf(run), text: run.map((x) => x.text).join(" "), line, unknown: true };
|
|
44000
|
+
return { k: "name", name: keyOf(run), text: run.map((x) => x.text).join(" "), col: run[0]?.col, line, unknown: true };
|
|
43931
44001
|
}
|
|
43932
44002
|
};
|
|
43933
44003
|
function parseCore(source, { seed = null } = {}) {
|
|
@@ -44048,7 +44118,7 @@ function nameWords2(ts, line, what) {
|
|
|
44048
44118
|
if (t.t !== "word") throw new CoreError(diag("TC105", line, `A name can only use words, but "${show2(t)}" is not a word.`));
|
|
44049
44119
|
if (RESERVED2.has(t.lower)) throw new CoreError(diag("TC202", line, `A name can't contain the word "${t.text}", because it belongs to Thunder.`, `Try a name without "${t.text}".`));
|
|
44050
44120
|
}
|
|
44051
|
-
return { name: keyOf(words14), text: words14.map((x) => x.text).join(" ") };
|
|
44121
|
+
return { name: keyOf(words14), text: words14.map((x) => x.text).join(" "), col: words14[0].col };
|
|
44052
44122
|
}
|
|
44053
44123
|
function parseStatement2(n, ep, names, diagnostics, ctx, siblings) {
|
|
44054
44124
|
const ts = n.tokens;
|
|
@@ -44146,8 +44216,8 @@ function parseStatement2(n, ep, names, diagnostics, ctx, siblings) {
|
|
|
44146
44216
|
otherwise = sub2;
|
|
44147
44217
|
continue;
|
|
44148
44218
|
}
|
|
44149
|
-
const { name, text: text2 } = nameWords2(ct.slice(0, -1), c.line, "A case");
|
|
44150
|
-
cases.push({ alt: name, text: text2, body: sub2, line: c.line });
|
|
44219
|
+
const { name, text: text2, col } = nameWords2(ct.slice(0, -1), c.line, "A case");
|
|
44220
|
+
cases.push({ alt: name, text: text2, col, body: sub2, line: c.line });
|
|
44151
44221
|
} catch (e2) {
|
|
44152
44222
|
if (e2 instanceof CoreError) diagnostics.push(e2.diagnostic);
|
|
44153
44223
|
else throw e2;
|
|
@@ -44197,7 +44267,7 @@ function parseStatement2(n, ep, names, diagnostics, ctx, siblings) {
|
|
|
44197
44267
|
}
|
|
44198
44268
|
if (w0 === "to" && isSym(ts[ts.length - 1], ":")) {
|
|
44199
44269
|
if (!ctx.top) fail3("TC402", 'A "To" block (a function) must be written at the left edge, not inside another block.');
|
|
44200
|
-
const { name, text: text2 } = nameWords2(header().slice(1), line, '"To"');
|
|
44270
|
+
const { name, text: text2, col } = nameWords2(header().slice(1), line, '"To"');
|
|
44201
44271
|
const kids2 = n.children;
|
|
44202
44272
|
let params = [];
|
|
44203
44273
|
let bodyNodes = kids2;
|
|
@@ -44208,7 +44278,7 @@ function parseStatement2(n, ep, names, diagnostics, ctx, siblings) {
|
|
|
44208
44278
|
r++;
|
|
44209
44279
|
}
|
|
44210
44280
|
bodyNodes = kids2.slice(r);
|
|
44211
|
-
return { k: "func", name, text: text2, params, body: parseBlock(bodyNodes, ep, names, diagnostics, { inFunc: true }), line };
|
|
44281
|
+
return { k: "func", name, text: text2, col, params, body: parseBlock(bodyNodes, ep, names, diagnostics, { inFunc: true }), line };
|
|
44212
44282
|
}
|
|
44213
44283
|
if (w0 === "receive") fail3("TC111", '"Receive" must be the first line inside a "To" block or a "Screen".');
|
|
44214
44284
|
if (w0 === "screen" && isSym(ts[ts.length - 1], ":")) {
|
|
@@ -44223,7 +44293,7 @@ function parseStatement2(n, ep, names, diagnostics, ctx, siblings) {
|
|
|
44223
44293
|
if (w0 === "show") fail3("TC118", '"Show" is used inside a "Screen" (a screen shows things). In a program, write: Say \u2026');
|
|
44224
44294
|
if ((w0 === "a" || w0 === "an") && isOneOf(ts)) {
|
|
44225
44295
|
if (!ctx.top) fail3("TC402", 'A data type ("A \u2026 is one of:") must be written at the left edge, not inside another block.');
|
|
44226
|
-
const { name, text: text2 } = nameWords2(ts.slice(1, -4), line, "A data type");
|
|
44296
|
+
const { name, text: text2, col } = nameWords2(ts.slice(1, -4), line, "A data type");
|
|
44227
44297
|
const alts = [];
|
|
44228
44298
|
for (const c of n.children) {
|
|
44229
44299
|
try {
|
|
@@ -44246,11 +44316,11 @@ function parseStatement2(n, ep, names, diagnostics, ctx, siblings) {
|
|
|
44246
44316
|
const opt2 = (t) => t.k === "optional" ? t : { k: "optional", of: t };
|
|
44247
44317
|
const fields = [{ name: "which", text: "which", type: { k: "text" }, line, hidden: true }];
|
|
44248
44318
|
for (const a of alts) for (const f of a.fields) if (!fields.some((x) => x.name === f.name)) fields.push({ ...f, type: opt2(f.type) });
|
|
44249
|
-
return { k: "record", name, text: text2, fields, rules: [], alts, line };
|
|
44319
|
+
return { k: "record", name, text: text2, col, fields, rules: [], alts, line };
|
|
44250
44320
|
}
|
|
44251
44321
|
if ((w0 === "a" || w0 === "an") && isWord(ts[ts.length - 2], "has") && isSym(ts[ts.length - 1], ":")) {
|
|
44252
44322
|
if (!ctx.top) fail3("TC402", 'A record ("A \u2026 has:") must be written at the left edge, not inside another block.');
|
|
44253
|
-
const { name, text: text2 } = nameWords2(ts.slice(1, -2), line, "A record");
|
|
44323
|
+
const { name, text: text2, col } = nameWords2(ts.slice(1, -2), line, "A record");
|
|
44254
44324
|
const fields = [], rules = [];
|
|
44255
44325
|
for (const c of n.children) {
|
|
44256
44326
|
try {
|
|
@@ -44266,7 +44336,7 @@ function parseStatement2(n, ep, names, diagnostics, ctx, siblings) {
|
|
|
44266
44336
|
else throw e2;
|
|
44267
44337
|
}
|
|
44268
44338
|
}
|
|
44269
|
-
return { k: "record", name, text: text2, fields, rules, line };
|
|
44339
|
+
return { k: "record", name, text: text2, col, fields, rules, line };
|
|
44270
44340
|
}
|
|
44271
44341
|
if (w0 === "expect") return { ...parseExpect(rest2, line, ep), raw: n.raw };
|
|
44272
44342
|
if (w0 === "never") return parseNever(ts, line, ep);
|
|
@@ -44356,7 +44426,7 @@ function parseStatement2(n, ep, names, diagnostics, ctx, siblings) {
|
|
|
44356
44426
|
if (t.t === "word" && !RESERVED2.has(t.lower)) run.push(t);
|
|
44357
44427
|
else break;
|
|
44358
44428
|
}
|
|
44359
|
-
const known3 = ep.longest(run, (
|
|
44429
|
+
const known3 = ep.longest(run, (key2) => names.known.has(key2));
|
|
44360
44430
|
if (!known3) {
|
|
44361
44431
|
const restTs = ts.slice(1);
|
|
44362
44432
|
return { k: "unknownVerb", verb: ts[0].text, object: restTs.length ? safeParse(ep, restTs, line) : null, line, raw: n.raw };
|
|
@@ -44511,19 +44581,19 @@ function parseElement(c, ep, names, diagnostics, screen, siblings) {
|
|
|
44511
44581
|
);
|
|
44512
44582
|
}
|
|
44513
44583
|
const r = opens ? ts.slice(1, -1) : ts.slice(1);
|
|
44514
|
-
const
|
|
44584
|
+
const key2 = (i, j) => keyOf(r.slice(i, j));
|
|
44515
44585
|
const label = (at2, what) => {
|
|
44516
44586
|
if (r[at2]?.t !== "str") fail3("TC108", `${what} needs its words in quotes, like: Show ${what.toLowerCase()} "Save".`);
|
|
44517
44587
|
return ep.parse([r[at2]], line);
|
|
44518
44588
|
};
|
|
44519
|
-
if (
|
|
44589
|
+
if (key2(0, 2) === "a heading") {
|
|
44520
44590
|
noBlock("A heading");
|
|
44521
44591
|
let v = r.slice(2);
|
|
44522
44592
|
if (isSym(v[0], ":")) v = v.slice(1);
|
|
44523
44593
|
if (!v.length) fail3("TC108", 'A heading needs its words: Show a heading "Welcome", or Show a heading: title.');
|
|
44524
44594
|
return { k: "heading", e: ep.parse(v, line), line };
|
|
44525
44595
|
}
|
|
44526
|
-
if (
|
|
44596
|
+
if (key2(0, 4) === "a list with each") {
|
|
44527
44597
|
const inAt = splitTop4(r, (t) => isWord(t, "in"));
|
|
44528
44598
|
if (inAt < 0) fail3("TC108", 'Write "Show a list with each item in items:".');
|
|
44529
44599
|
if (!opens || !c.children.length) fail3("TC103", `"${c.raw.trim()}" needs the lines to show for each item, indented under it.`, `For example:
|
|
@@ -44531,13 +44601,13 @@ function parseElement(c, ep, names, diagnostics, screen, siblings) {
|
|
|
44531
44601
|
const v = nameWords2(r.slice(4, inAt), line, "The list");
|
|
44532
44602
|
return { k: "list", v, iter: ep.parse(r.slice(inAt + 1), line), body: parseElements(c.children, ep, names, diagnostics, screen), line };
|
|
44533
44603
|
}
|
|
44534
|
-
if (
|
|
44535
|
-
if (
|
|
44604
|
+
if (key2(0, 2) === "a list") fail3("TC108", "A list names each item: Show a list with each item in items:", "Then indent what to show for each item under it.");
|
|
44605
|
+
if (key2(0, 2) === "a row") {
|
|
44536
44606
|
if (r.length > 2) fail3("TC112", 'Write "Show a row:" and put what it holds on the lines under it.');
|
|
44537
44607
|
if (!opens || !c.children.length) fail3("TC103", '"Show a row:" needs the things to put side by side, indented under it.');
|
|
44538
44608
|
return { k: "row", body: parseElements(c.children, ep, names, diagnostics, screen), line };
|
|
44539
44609
|
}
|
|
44540
|
-
if (
|
|
44610
|
+
if (key2(0, 3) === "a text box" || key2(0, 3) === "a number box") {
|
|
44541
44611
|
noBlock("A box");
|
|
44542
44612
|
const kind = r[1].lower === "text" ? "textbox" : "numberbox";
|
|
44543
44613
|
const what = kind === "textbox" ? "A text box" : "A number box";
|
|
@@ -44546,7 +44616,7 @@ function parseElement(c, ep, names, diagnostics, screen, siblings) {
|
|
|
44546
44616
|
const target = nameWords2(r.slice(5), line, what);
|
|
44547
44617
|
return { k: kind, label: lab, target: { k: "name", ...target, line }, line };
|
|
44548
44618
|
}
|
|
44549
|
-
if (
|
|
44619
|
+
if (key2(0, 2) === "a button") {
|
|
44550
44620
|
const lab = label(2, "A button");
|
|
44551
44621
|
let i = 3, off = null, opensScreen = null;
|
|
44552
44622
|
if (isSym(r[i], "(")) {
|
|
@@ -44647,8 +44717,8 @@ var PY_TAKEN = new Set(`False None True and as assert async await break class co
|
|
|
44647
44717
|
print len sorted range list dict str int float bool object super isinstance getattr setattr type id input open sum min max any all map filter iter next round abs format repr hash vars dir set tuple
|
|
44648
44718
|
Decimal date dataclass field main THUNDER_SOURCE THUNDER_TESTS failure
|
|
44649
44719
|
Money Stop RuleBroken ExpectationFailed ThunderError show divide modulo to_number to_whole to_money to_text to_yes_no to_date total_of average_of smallest_of largest_of first_of last_of item_at set_item entry get_field set_field add_to remove_from round_to read_file never expect_value expect_true expect_failure explain run run_tests pairs_of`.split(/\s+/));
|
|
44650
|
-
function pyName(
|
|
44651
|
-
const words14 =
|
|
44720
|
+
function pyName(key2, style = "snake") {
|
|
44721
|
+
const words14 = key2.split(" ").map((w) => w.replace(/[^\p{L}\p{N}_]/gu, "_"));
|
|
44652
44722
|
let n = style === "upper" ? words14.join("_").toUpperCase() : style === "pascal" ? words14.map((w) => w[0].toUpperCase() + w.slice(1)).join("") : words14.join("_").toLowerCase();
|
|
44653
44723
|
if (/^[0-9]/.test(n)) n = `_${n}`;
|
|
44654
44724
|
while (PY_TAKEN.has(n)) n += "_";
|
|
@@ -44664,8 +44734,8 @@ var Scope2 = class {
|
|
|
44664
44734
|
this.kind = kind;
|
|
44665
44735
|
this.vars = /* @__PURE__ */ new Map();
|
|
44666
44736
|
}
|
|
44667
|
-
get(
|
|
44668
|
-
return this.vars.get(
|
|
44737
|
+
get(key2) {
|
|
44738
|
+
return this.vars.get(key2) ?? this.parent?.get(key2);
|
|
44669
44739
|
}
|
|
44670
44740
|
};
|
|
44671
44741
|
function checkCore(program, { imported = [] } = {}) {
|
|
@@ -44952,23 +45022,23 @@ var Checker = class {
|
|
|
44952
45022
|
this.rules.push(entry3);
|
|
44953
45023
|
for (const r of fieldOf) (r.rulesToCheck ??= []).push(entry3);
|
|
44954
45024
|
}
|
|
44955
|
-
anyParamOrLocal(
|
|
45025
|
+
anyParamOrLocal(key2) {
|
|
44956
45026
|
let hit = false;
|
|
44957
45027
|
const visit = (body2) => {
|
|
44958
45028
|
for (const s of body2) {
|
|
44959
|
-
if (s.k === "set" && s.target.k === "name" && s.target.name ===
|
|
45029
|
+
if (s.k === "set" && s.target.k === "name" && s.target.name === key2) hit = true;
|
|
44960
45030
|
for (const b of childBlocks(s)) visit(b);
|
|
44961
45031
|
}
|
|
44962
45032
|
};
|
|
44963
45033
|
for (const f of this.funcs.values()) {
|
|
44964
|
-
if (f.params.some((p) => p.name ===
|
|
45034
|
+
if (f.params.some((p) => p.name === key2)) hit = true;
|
|
44965
45035
|
visit(f.body);
|
|
44966
45036
|
}
|
|
44967
45037
|
for (const s of this.p.body) if (s.k === "test") visit(s.body);
|
|
44968
45038
|
return hit;
|
|
44969
45039
|
}
|
|
44970
|
-
rulesFor(
|
|
44971
|
-
return this.rules.filter((r) => r.watchesVar && r.subject ===
|
|
45040
|
+
rulesFor(key2) {
|
|
45041
|
+
return this.rules.filter((r) => r.watchesVar && r.subject === key2);
|
|
44972
45042
|
}
|
|
44973
45043
|
/**
|
|
44974
45044
|
* An endpoint (When someone calls GET /habits/{name}:): a known method, one per method and path, every {part} of
|
|
@@ -44979,9 +45049,9 @@ var Checker = class {
|
|
|
44979
45049
|
const line = ep.line;
|
|
44980
45050
|
if (!["GET", "POST", "PUT", "PATCH", "DELETE"].includes(ep.method)) this.err("TC108", line, `"${ep.method}" isn't an HTTP method Thunder answers.`, "Use GET, POST, PUT, PATCH, or DELETE.");
|
|
44981
45051
|
this.routes ??= /* @__PURE__ */ new Map();
|
|
44982
|
-
const
|
|
44983
|
-
if (this.routes.has(
|
|
44984
|
-
else if (!this.routes.has(
|
|
45052
|
+
const key2 = `${ep.method} /${ep.segments.map((g) => g.param ? "{}" : g.lit).join("/")}`;
|
|
45053
|
+
if (this.routes.has(key2) && this.routes.get(key2).path !== ep.path) this.err("TC203", line, `${ep.method} ${ep.path} is answered already, by ${ep.method} ${this.routes.get(key2).path} (line ${this.routes.get(key2).line}).`, "Each method and path is answered by one endpoint.");
|
|
45054
|
+
else if (!this.routes.has(key2)) this.routes.set(key2, ep);
|
|
44985
45055
|
const plain = (t) => t && (["whole", "number", "money", "text", "bool", "date"].includes(t.k) || t.k === "optional" && plain(t.of));
|
|
44986
45056
|
for (const p of f.params) {
|
|
44987
45057
|
if (!p.type) p.type = { k: "text" };
|
|
@@ -45206,6 +45276,10 @@ var Checker = class {
|
|
|
45206
45276
|
if (s.targetKind === "list" && known(tt.of) && known(te) && !compatible(tt.of, te)) this.err("TC303", line, `This list holds ${typeWords4(tt.of)}, so ${typeWords4(te)} can't be added to it.`);
|
|
45207
45277
|
if (s.k === "add" && s.targetKind === "list" && !known(tt.of) && known(te) && s.target.k === "name" && s.target.ref?.type?.k === "list") s.target.ref.type = T("list", { of: te });
|
|
45208
45278
|
this.afterAssign(s, s.target, sc);
|
|
45279
|
+
if (s.targetKind === "list" || s.targetKind === "map" && s.k === "remove") {
|
|
45280
|
+
const watched = s.target.k === "name" ? s.rules?.length > 0 : s.target.k === "field" && (this.records.get(s.target.record)?.rulesToCheck ?? []).some((r) => r.subject === s.target.name);
|
|
45281
|
+
if (watched && s.targetKind === "list") s.guard = true;
|
|
45282
|
+
}
|
|
45209
45283
|
return;
|
|
45210
45284
|
}
|
|
45211
45285
|
case "increase":
|
|
@@ -45392,8 +45466,8 @@ var Checker = class {
|
|
|
45392
45466
|
}
|
|
45393
45467
|
}
|
|
45394
45468
|
}
|
|
45395
|
-
localPy(
|
|
45396
|
-
return pyName(
|
|
45469
|
+
localPy(key2, sc) {
|
|
45470
|
+
return pyName(key2);
|
|
45397
45471
|
}
|
|
45398
45472
|
checkSet(s, sc, ctx) {
|
|
45399
45473
|
const line = s.line;
|
|
@@ -45601,6 +45675,7 @@ var Checker = class {
|
|
|
45601
45675
|
case "field": {
|
|
45602
45676
|
const ot = this.ex(e.obj, sc, o);
|
|
45603
45677
|
const r = ot.k === "record" ? this.records.get(ot.name) : null;
|
|
45678
|
+
if (r) e.record = r.name;
|
|
45604
45679
|
if (r?.altMap && e.name !== "which" && r.fieldMap.has(e.name)) {
|
|
45605
45680
|
const alt = this.narrowed(e.obj);
|
|
45606
45681
|
const a = alt ? r.altMap.get(alt) : null;
|
|
@@ -45871,11 +45946,11 @@ var Checker = class {
|
|
|
45871
45946
|
const ts = e.args.map((a) => this.ex(a, sc, o));
|
|
45872
45947
|
const required = f.params.filter((p) => !p.dflt).length;
|
|
45873
45948
|
if (ts.length < required || ts.length > f.params.length) {
|
|
45874
|
-
const
|
|
45949
|
+
const range2 = required === f.params.length ? `${f.params.length} value${f.params.length === 1 ? "" : "s"}` : `${required} to ${f.params.length} values`;
|
|
45875
45950
|
this.err(
|
|
45876
45951
|
"TC207",
|
|
45877
45952
|
e.line,
|
|
45878
|
-
`"${f.text}" receives ${
|
|
45953
|
+
`"${f.text}" receives ${range2} (${f.params.map((p) => p.dflt ? `${p.text}, if given` : p.text).join(", ") || "none"}), but ${ts.length} ${ts.length === 1 ? "was" : "were"} given.`,
|
|
45879
45954
|
f.params.length > 1 && ts.length === 1 ? `Separate the values with commas or "and": ${f.text} with ${f.params.map((p) => p.text).join(" and ")}. To give a yes/no made with "and", put it in parentheses.` : null
|
|
45880
45955
|
);
|
|
45881
45956
|
} else f.params.slice(0, ts.length).forEach((p, k) => {
|
|
@@ -46045,15 +46120,15 @@ var Checker = class {
|
|
|
46045
46120
|
}
|
|
46046
46121
|
// A field of each item of a list (for "from", "sorted by", "Sort … by"). Plural words name a field only when
|
|
46047
46122
|
// removing a final "s" or "es" gives exactly a field's name (prices -> price); otherwise the words are used as is.
|
|
46048
|
-
fieldOfElem(et,
|
|
46123
|
+
fieldOfElem(et, key2, text2, line, plural6 = false) {
|
|
46049
46124
|
const r = et.k === "record" ? this.records.get(et.name) : null;
|
|
46050
46125
|
if (!r) return { dynamic: true, key: text2, type: UNKNOWN };
|
|
46051
|
-
const options = [
|
|
46126
|
+
const options = [key2, ...plural6 ? [key2.replace(/es$/, ""), key2.replace(/s$/, "")] : []];
|
|
46052
46127
|
for (const k of options) if (r.fieldMap.has(k)) {
|
|
46053
46128
|
const f = r.fieldMap.get(k);
|
|
46054
46129
|
return { py: f.py, type: f.type };
|
|
46055
46130
|
}
|
|
46056
|
-
const g = closest(
|
|
46131
|
+
const g = closest(key2, [...r.fieldMap.keys()]);
|
|
46057
46132
|
this.err("TC206", line, `A ${r.text} has no field "${text2}".`, g ? `Did you mean "${g}"?` : `Fields: ${[...r.fieldMap.keys()].join(", ")}.`);
|
|
46058
46133
|
return { dynamic: true, key: text2, type: UNKNOWN };
|
|
46059
46134
|
}
|
|
@@ -46493,6 +46568,14 @@ ${body2.join("\n").replace(/\n{4,}/g, "\n\n\n")}
|
|
|
46493
46568
|
case "remove": {
|
|
46494
46569
|
const v = this.x(s.e).c;
|
|
46495
46570
|
const target = this.lv(s.target);
|
|
46571
|
+
if (s.guard) {
|
|
46572
|
+
const copy = `_copy_${s.line}_`;
|
|
46573
|
+
this.emit(`${copy} = list(${target})`, L);
|
|
46574
|
+
this.emit(s.k === "add" ? `${copy}.append(${v})` : `${this.R("remove_from")}(${copy}, ${v})`, L);
|
|
46575
|
+
if (s.target.k === "name") this.assign(s, target, copy);
|
|
46576
|
+
else this.store(s.target, copy, L);
|
|
46577
|
+
return;
|
|
46578
|
+
}
|
|
46496
46579
|
if (s.targetKind === "list") this.emit(s.k === "add" ? `${target}.append(${v})` : `${this.R("remove_from")}(${target}, ${v})`, L);
|
|
46497
46580
|
else if (s.targetKind === "map") this.emit(`${this.R("remove_from")}(${target}, ${v})`, L);
|
|
46498
46581
|
else if (s.targetKind === "number") {
|
|
@@ -46524,8 +46607,8 @@ ${body2.join("\n").replace(/\n{4,}/g, "\n\n\n")}
|
|
|
46524
46607
|
}
|
|
46525
46608
|
case "sort": {
|
|
46526
46609
|
const target = this.x(s.target);
|
|
46527
|
-
const
|
|
46528
|
-
const args = [
|
|
46610
|
+
const key2 = s.field ? this.keyLambda(s.field) : null;
|
|
46611
|
+
const args = [key2 ? `key=${key2}` : null, s.desc ? "reverse=True" : null].filter(Boolean).join(", ");
|
|
46529
46612
|
this.emit(`${wrap(target, P.atom)}.sort(${args})`, L);
|
|
46530
46613
|
return;
|
|
46531
46614
|
}
|
|
@@ -48039,8 +48122,8 @@ def run_tests(modules):
|
|
|
48039
48122
|
`;
|
|
48040
48123
|
|
|
48041
48124
|
// src/core/index.mjs
|
|
48042
|
-
function
|
|
48043
|
-
|
|
48125
|
+
function seedFrom(imported = []) {
|
|
48126
|
+
return imported.length ? {
|
|
48044
48127
|
known: imported.flatMap((r) => [...r.program.names.known].filter(([, kind]) => kind !== "var")),
|
|
48045
48128
|
fields: imported.flatMap((r) => [...r.program.names.fields]),
|
|
48046
48129
|
records: imported.flatMap((r) => [...r.program.names.records]),
|
|
@@ -48049,6 +48132,9 @@ function compileCore(source, { file = "main.thunder", imported = [], srcModules
|
|
|
48049
48132
|
alts: imported.flatMap((r) => [...r.program.names.alts ?? []]),
|
|
48050
48133
|
altsOf: imported.flatMap((r) => [...r.program.names.altsOf ?? []])
|
|
48051
48134
|
} : null;
|
|
48135
|
+
}
|
|
48136
|
+
function compileCore(source, { file = "main.thunder", imported = [], srcModules = [] } = {}) {
|
|
48137
|
+
const seed = seedFrom(imported);
|
|
48052
48138
|
const program = parseCore(source, { seed });
|
|
48053
48139
|
const { diagnostics, info } = checkCore(program, { imported: imported.map((r) => r.info) });
|
|
48054
48140
|
const ok = diagnostics.length === 0;
|
|
@@ -48840,8 +48926,8 @@ function contains(container, item4) {
|
|
|
48840
48926
|
if (container instanceof Tuple) return container.items.some((x) => eq2(x, item4));
|
|
48841
48927
|
throw TypeErr(`argument of type '${typeName(container)}' is not iterable`);
|
|
48842
48928
|
}
|
|
48843
|
-
function pySort(items,
|
|
48844
|
-
const keyed = items.map((v, i) => ({ v, k:
|
|
48929
|
+
function pySort(items, key2, reverse) {
|
|
48930
|
+
const keyed = items.map((v, i) => ({ v, k: key2 ? key2(v) : v, i }));
|
|
48845
48931
|
keyed.sort((x, y) => {
|
|
48846
48932
|
if (compare2("<", reverse ? y.k : x.k, reverse ? x.k : y.k)) return -1;
|
|
48847
48933
|
if (compare2("<", reverse ? x.k : y.k, reverse ? y.k : x.k)) return 1;
|
|
@@ -49131,31 +49217,31 @@ function setAttrWith(checkRules, obj, name, value) {
|
|
|
49131
49217
|
if (obj instanceof Money) throw new PyErr("AttributeError", "Money cannot be changed; make new money instead.");
|
|
49132
49218
|
throw attrErr(obj, name);
|
|
49133
49219
|
}
|
|
49134
|
-
function getField(obj,
|
|
49135
|
-
if (obj === null) throw MissingValue(`This value is nothing, so it has no ${
|
|
49136
|
-
const names = [
|
|
49220
|
+
function getField(obj, key2) {
|
|
49221
|
+
if (obj === null) throw MissingValue(`This value is nothing, so it has no ${key2}.`);
|
|
49222
|
+
const names = [key2, key2.replace(/ /g, "_"), key2.toLowerCase(), key2.toLowerCase().replace(/ /g, "_")];
|
|
49137
49223
|
if (obj instanceof PyDict) {
|
|
49138
49224
|
for (const k of names) if (obj.has(k)) return obj.get(k);
|
|
49139
|
-
for (const [k, v] of obj.m.values()) if (pyStrip(pyStr(k)).toLowerCase() ===
|
|
49140
|
-
throw MissingValue(`There is no field "${
|
|
49225
|
+
for (const [k, v] of obj.m.values()) if (pyStrip(pyStr(k)).toLowerCase() === key2.toLowerCase()) return v;
|
|
49226
|
+
throw MissingValue(`There is no field "${key2}". Fields here: ${obj.keys().map(pyStr).join(", ")}.`);
|
|
49141
49227
|
}
|
|
49142
49228
|
for (const k of names) {
|
|
49143
49229
|
if (obj instanceof RecordVal && obj.f.has(k)) return obj.f.get(k);
|
|
49144
49230
|
if (obj instanceof Money && k === "amount") return obj.amount;
|
|
49145
49231
|
}
|
|
49146
|
-
throw MissingValue(`${describe2(obj)} has no field "${
|
|
49232
|
+
throw MissingValue(`${describe2(obj)} has no field "${key2}".`);
|
|
49147
49233
|
}
|
|
49148
|
-
function setFieldWith(setAttr, obj,
|
|
49234
|
+
function setFieldWith(setAttr, obj, key2, value) {
|
|
49149
49235
|
if (obj instanceof PyDict) {
|
|
49150
|
-
obj.set(
|
|
49236
|
+
obj.set(key2, value);
|
|
49151
49237
|
return;
|
|
49152
49238
|
}
|
|
49153
|
-
const names = [
|
|
49239
|
+
const names = [key2, key2.replace(/ /g, "_"), key2.toLowerCase(), key2.toLowerCase().replace(/ /g, "_")];
|
|
49154
49240
|
for (const k of names) if (obj instanceof RecordVal && obj.f.has(k)) {
|
|
49155
49241
|
setAttr(obj, k, value);
|
|
49156
49242
|
return;
|
|
49157
49243
|
}
|
|
49158
|
-
throw MissingValue(`${describe2(obj)} has no field "${
|
|
49244
|
+
throw MissingValue(`${describe2(obj)} has no field "${key2}".`);
|
|
49159
49245
|
}
|
|
49160
49246
|
function addTo(target, value) {
|
|
49161
49247
|
if (Array.isArray(target)) {
|
|
@@ -49164,6 +49250,14 @@ function addTo(target, value) {
|
|
|
49164
49250
|
}
|
|
49165
49251
|
return add(target, value);
|
|
49166
49252
|
}
|
|
49253
|
+
function copyList(target) {
|
|
49254
|
+
if (!Array.isArray(target)) throw attrErr(target, "append");
|
|
49255
|
+
return [...target];
|
|
49256
|
+
}
|
|
49257
|
+
function appendTo(target, value) {
|
|
49258
|
+
if (!Array.isArray(target)) throw attrErr(target, "append");
|
|
49259
|
+
target.push(value);
|
|
49260
|
+
}
|
|
49167
49261
|
function removeFrom(target, value) {
|
|
49168
49262
|
if (target instanceof PyDict) {
|
|
49169
49263
|
if (!target.has(value)) throw MissingValue(`There is no entry for ${show3(value)} to remove.`);
|
|
@@ -49367,19 +49461,19 @@ function textOf4(v, what) {
|
|
|
49367
49461
|
if (typeof v !== "string") throw KindMismatch(`${what} needs text, but it is ${describe2(v)}.`);
|
|
49368
49462
|
return v;
|
|
49369
49463
|
}
|
|
49370
|
-
function joined(items,
|
|
49371
|
-
|
|
49464
|
+
function joined(items, sep3) {
|
|
49465
|
+
sep3 = textOf4(sep3, '"joined with"');
|
|
49372
49466
|
const out = [];
|
|
49373
49467
|
pyIter(items).forEach((x, i) => {
|
|
49374
49468
|
if (typeof x !== "string") throw KindMismatch(`"joined with" joins text, but item ${i + 1} is ${describe2(x)}. Turn it into text first.`);
|
|
49375
49469
|
out.push(x);
|
|
49376
49470
|
});
|
|
49377
|
-
return out.join(
|
|
49471
|
+
return out.join(sep3);
|
|
49378
49472
|
}
|
|
49379
|
-
function splitAt(text2,
|
|
49380
|
-
|
|
49381
|
-
if (
|
|
49382
|
-
return textOf4(text2, '"split at"').split(
|
|
49473
|
+
function splitAt(text2, sep3) {
|
|
49474
|
+
sep3 = textOf4(sep3, '"split at"');
|
|
49475
|
+
if (sep3 === "") throw KindMismatch('"split at" needs something to split at, not empty text.');
|
|
49476
|
+
return textOf4(text2, '"split at"').split(sep3);
|
|
49383
49477
|
}
|
|
49384
49478
|
function replacing(text2, old, nw) {
|
|
49385
49479
|
old = textOf4(old, '"replacing"');
|
|
@@ -49738,10 +49832,10 @@ var Engine = class {
|
|
|
49738
49832
|
return;
|
|
49739
49833
|
}
|
|
49740
49834
|
if (t.k === "at") {
|
|
49741
|
-
const obj = this.x(t.obj, env),
|
|
49742
|
-
if (t.objKind === "list") this.setItem(obj,
|
|
49743
|
-
else if (t.objKind === "map") this.mapSet(obj,
|
|
49744
|
-
else this.setEntry(obj,
|
|
49835
|
+
const obj = this.x(t.obj, env), key2 = this.x(t.key, env);
|
|
49836
|
+
if (t.objKind === "list") this.setItem(obj, key2, v);
|
|
49837
|
+
else if (t.objKind === "map") this.mapSet(obj, key2, v);
|
|
49838
|
+
else this.setEntry(obj, key2, v);
|
|
49745
49839
|
}
|
|
49746
49840
|
}
|
|
49747
49841
|
stmt(s, env) {
|
|
@@ -49925,8 +50019,8 @@ var Engine = class {
|
|
|
49925
50019
|
case "sort": {
|
|
49926
50020
|
const target = this.x(s.target, env);
|
|
49927
50021
|
if (!Array.isArray(target)) throw attrErr(target, "sort");
|
|
49928
|
-
const
|
|
49929
|
-
const sorted = pySort(target,
|
|
50022
|
+
const key2 = s.field ? this.keyFn(s.field, env) : null;
|
|
50023
|
+
const sorted = pySort(target, key2, !!s.desc);
|
|
49930
50024
|
target.splice(0, target.length, ...sorted);
|
|
49931
50025
|
return;
|
|
49932
50026
|
}
|
|
@@ -49966,6 +50060,14 @@ var Engine = class {
|
|
|
49966
50060
|
const isName = s.target.k === "name";
|
|
49967
50061
|
const target = this.x(s.target, env);
|
|
49968
50062
|
const py2 = isName ? s.target.ref?.py ?? "unknown" : null;
|
|
50063
|
+
if (s.guard) {
|
|
50064
|
+
const copy = copyList(target);
|
|
50065
|
+
if (s.k === "add") appendTo(copy, v);
|
|
50066
|
+
else this.removeFrom(copy, v);
|
|
50067
|
+
if (isName) this.assign(s, py2, copy, env);
|
|
50068
|
+
else this.store(s.target, copy, env);
|
|
50069
|
+
return;
|
|
50070
|
+
}
|
|
49969
50071
|
if (s.targetKind === "list") {
|
|
49970
50072
|
if (s.k === "add") {
|
|
49971
50073
|
if (!Array.isArray(target)) throw attrErr(target, "append");
|
|
@@ -50076,11 +50178,11 @@ var Engine = class {
|
|
|
50076
50178
|
mapGet(m, k, dflt) {
|
|
50077
50179
|
return mapGet(m, k, dflt);
|
|
50078
50180
|
}
|
|
50079
|
-
getField(obj,
|
|
50080
|
-
return getField(obj,
|
|
50181
|
+
getField(obj, key2) {
|
|
50182
|
+
return getField(obj, key2);
|
|
50081
50183
|
}
|
|
50082
|
-
setField(obj,
|
|
50083
|
-
setFieldWith((o, k, v) => this.setAttr(o, k, v), obj,
|
|
50184
|
+
setField(obj, key2, value) {
|
|
50185
|
+
setFieldWith((o, k, v) => this.setAttr(o, k, v), obj, key2, value);
|
|
50084
50186
|
}
|
|
50085
50187
|
addTo(target, value) {
|
|
50086
50188
|
return addTo(target, value);
|
|
@@ -50559,24 +50661,24 @@ var stopShape = (m) => m.replace(/\$?-?\d[\d,]*(\.\d+)?/g, "\u2026");
|
|
|
50559
50661
|
function outcome2(fn) {
|
|
50560
50662
|
try {
|
|
50561
50663
|
const v = fn();
|
|
50562
|
-
let
|
|
50664
|
+
let key2;
|
|
50563
50665
|
try {
|
|
50564
|
-
|
|
50666
|
+
key2 = dataJson(v);
|
|
50565
50667
|
} catch {
|
|
50566
|
-
|
|
50668
|
+
key2 = show3(v);
|
|
50567
50669
|
}
|
|
50568
50670
|
if (v instanceof RecordVal) {
|
|
50569
50671
|
const which = v.cls.alts ? v.f.get("which") : null;
|
|
50570
50672
|
const label2 = which ? `${article2(which)} ${which} ${v.cls.py}` : `${article2(v.cls.py)} ${v.cls.py}`;
|
|
50571
50673
|
let fields = null;
|
|
50572
50674
|
try {
|
|
50573
|
-
fields = JSON.parse(
|
|
50675
|
+
fields = JSON.parse(key2);
|
|
50574
50676
|
} catch {
|
|
50575
50677
|
}
|
|
50576
|
-
return { key, label: label2, group: label2, fields };
|
|
50678
|
+
return { key: key2, label: label2, group: label2, fields };
|
|
50577
50679
|
}
|
|
50578
50680
|
const label = Array.isArray(v) ? `a list of ${v.length}` : typeof v === "string" ? JSON.stringify(v) : show3(v);
|
|
50579
|
-
return { key, label, group: label };
|
|
50681
|
+
return { key: key2, label, group: label };
|
|
50580
50682
|
} catch (e) {
|
|
50581
50683
|
if (e instanceof OutOfSteps || e instanceof RangeError) return { unknown: true };
|
|
50582
50684
|
const err = asPyErr(e);
|
|
@@ -50696,10 +50798,10 @@ function compareRuns(A, B, a, b, lit5, until = Infinity) {
|
|
|
50696
50798
|
done.push([idx, d.key]);
|
|
50697
50799
|
}
|
|
50698
50800
|
const read = readSlots(b, slots);
|
|
50699
|
-
const list3 = [...groups3.entries()].sort((x, y) => y[1].otherKind - x[1].otherKind || y[1].inputs.length - x[1].inputs.length).map(([
|
|
50801
|
+
const list3 = [...groups3.entries()].sort((x, y) => y[1].otherKind - x[1].otherKind || y[1].inputs.length - x[1].inputs.length).map(([key2, g]) => ({ says: g.says, ...describeGroup(key2, g, slots, done, read) }));
|
|
50700
50802
|
return { tried: done.length, unknown, stopped, changed: list3.reduce((n, g) => n + g.count, 0), groups: list3 };
|
|
50701
50803
|
}
|
|
50702
|
-
function describeGroup(
|
|
50804
|
+
function describeGroup(key2, g, slots, done, read) {
|
|
50703
50805
|
let best = null;
|
|
50704
50806
|
slots.forEach((s, si) => {
|
|
50705
50807
|
if (!["money", "whole", "number"].includes(s.kind)) return;
|
|
@@ -50707,7 +50809,7 @@ function describeGroup(key, g, slots, done, read) {
|
|
|
50707
50809
|
for (const [idx, k] of done) {
|
|
50708
50810
|
const lineKey = idx.filter((_, i) => i !== si).join(",");
|
|
50709
50811
|
if (!lines.has(lineKey)) lines.set(lineKey, []);
|
|
50710
|
-
lines.get(lineKey).push([idx[si], k ===
|
|
50812
|
+
lines.get(lineKey).push([idx[si], k === key2]);
|
|
50711
50813
|
}
|
|
50712
50814
|
const runs = /* @__PURE__ */ new Map();
|
|
50713
50815
|
for (const pts of lines.values()) {
|
|
@@ -50766,8 +50868,8 @@ function coreChanges(oldFiles, newFiles) {
|
|
|
50766
50868
|
const lit5 = literals([A, B]);
|
|
50767
50869
|
const changes = [];
|
|
50768
50870
|
const srcBroken = B.results.some((r) => r.kind === "src" && !r.ok);
|
|
50769
|
-
const
|
|
50770
|
-
for (const p of
|
|
50871
|
+
const problems2 = B.results.filter((r) => !r.ok && !(srcBroken && r.kind === "test")).map((r) => ({ file: r.path, diagnostics: (r.diagnostics ?? []).filter((d) => d.severity !== "warning").map((d) => ({ line: d.line, code: d.code, message: d.message })) }));
|
|
50872
|
+
for (const p of problems2) {
|
|
50771
50873
|
const d = p.diagnostics[0];
|
|
50772
50874
|
changes.push({
|
|
50773
50875
|
id: `file:${p.file}`,
|
|
@@ -50877,7 +50979,7 @@ function coreChanges(oldFiles, newFiles) {
|
|
|
50877
50979
|
}
|
|
50878
50980
|
const order2 = { risk: 0, meaning: 1 };
|
|
50879
50981
|
changes.sort((x, y) => order2[x.severity] - order2[y.severity] || byText(String(x.file), String(y.file)) || x.line - y.line);
|
|
50880
|
-
return { schema: CORE_CHANGES_SCHEMA, files: [...new Set([...A.files, ...B.files].map((f) => f.path))], changes, unchanged, problems };
|
|
50982
|
+
return { schema: CORE_CHANGES_SCHEMA, files: [...new Set([...A.files, ...B.files].map((f) => f.path))], changes, unchanged, problems: problems2 };
|
|
50881
50983
|
}
|
|
50882
50984
|
function recordWords(a, b) {
|
|
50883
50985
|
const fa = new Map(a.node.fields.map((f) => [f.name, f])), fb = new Map(b.node.fields.map((f) => [f.name, f]));
|
|
@@ -51206,8 +51308,8 @@ var MAX_CASES = 4096;
|
|
|
51206
51308
|
var nameKey = (name) => String(name).replace(/[_\s-]/g, "").toLowerCase();
|
|
51207
51309
|
var norm4 = (s) => String(s).toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
51208
51310
|
var stemKey = (path) => nameKey(String(path).replace(/\.[^./]+$/, "").replace(/\\/g, "/"));
|
|
51209
|
-
function compact(it,
|
|
51210
|
-
const base2 = { key, file, language, name: it.name, kind: it.kind, line: it.line, route: it.route, element: visualFor(it).element };
|
|
51311
|
+
function compact(it, key2, file, language) {
|
|
51312
|
+
const base2 = { key: key2, file, language, name: it.name, kind: it.kind, line: it.line, route: it.route, element: visualFor(it).element };
|
|
51211
51313
|
return it.kind === "decision" ? { ...it, ...base2 } : { ...base2, flat: flatSteps(it.steps) };
|
|
51212
51314
|
}
|
|
51213
51315
|
function readAll(files) {
|
|
@@ -51228,9 +51330,9 @@ function readAll(files) {
|
|
|
51228
51330
|
const n = nameKey(it.name);
|
|
51229
51331
|
const nth = (seen.get(n) || 0) + 1;
|
|
51230
51332
|
seen.set(n, nth);
|
|
51231
|
-
const
|
|
51232
|
-
items.set(
|
|
51233
|
-
byName.set(n, byName.has(n) ? null :
|
|
51333
|
+
const key2 = `${stemKey(f.path)}#${n}${nth > 1 ? `#${nth}` : ""}`;
|
|
51334
|
+
items.set(key2, compact(it, key2, f.path, language));
|
|
51335
|
+
byName.set(n, byName.has(n) ? null : key2);
|
|
51234
51336
|
}
|
|
51235
51337
|
}
|
|
51236
51338
|
return { items, byName, unreadable };
|
|
@@ -51276,14 +51378,16 @@ function compareRules(oldItem, newItem) {
|
|
|
51276
51378
|
return comparePlainRules(a, b);
|
|
51277
51379
|
}
|
|
51278
51380
|
function comparePlainRules(a, b) {
|
|
51279
|
-
const
|
|
51280
|
-
const toA = new Map(a.inputs.map((i) => [
|
|
51281
|
-
if (a.inputs.length !== b.inputs.length || !b.inputs.every((i) => toA.has(
|
|
51381
|
+
const key2 = (i) => `${nameKey(i.label)}:${i.kind}`;
|
|
51382
|
+
const toA = new Map(a.inputs.map((i) => [key2(i), i.id]));
|
|
51383
|
+
if (a.inputs.length !== b.inputs.length || !b.inputs.every((i) => toA.has(key2(i)))) {
|
|
51282
51384
|
return { same: false, tried: 0, reason: `They need different facts: ${a.inputs.map((i) => i.label).join(", ")} versus ${b.inputs.map((i) => i.label).join(", ")}.` };
|
|
51283
51385
|
}
|
|
51284
|
-
const bAsA = { ...b, inputs: b.inputs.map((i) => ({ ...i, id: toA.get(
|
|
51386
|
+
const bAsA = { ...b, inputs: b.inputs.map((i) => ({ ...i, id: toA.get(key2(i)) })), rules: b.rules.map((r) => ({ ...r, conditions: r.conditions.map((c) => ({ ...c, input: toA.get(key2(b.inputs.find((i) => i.id === c.input))) })) })) };
|
|
51285
51387
|
let tried = 0;
|
|
51286
|
-
|
|
51388
|
+
const axes = caseValues([a, bAsA]);
|
|
51389
|
+
const total = axes.reduce((n, [, vs]) => n * Math.max(1, vs.length), 1);
|
|
51390
|
+
for (const values of product(axes)) {
|
|
51287
51391
|
if (++tried > MAX_CASES) {
|
|
51288
51392
|
tried--;
|
|
51289
51393
|
break;
|
|
@@ -51291,7 +51395,7 @@ function comparePlainRules(a, b) {
|
|
|
51291
51395
|
const x = explainPlain(a, values).outcome, y = explainPlain(bAsA, values).outcome;
|
|
51292
51396
|
if (x !== y) return { same: false, tried, counterexample: { values: { ...values }, facts: a.inputs.map((i) => `${i.label} ${i.kind === "yesno" ? values[i.id] ? i.yes ?? "yes" : i.no ?? "no" : values[i.id]}`).join(", "), old: x, new: y } };
|
|
51293
51397
|
}
|
|
51294
|
-
return { same: true, tried };
|
|
51398
|
+
return { same: true, tried, total, ...total > tried ? { capped: true } : {} };
|
|
51295
51399
|
}
|
|
51296
51400
|
var SYNTAX = new Set("const let var val final auto def fn func function return await async new public private protected static self this my local export mut ref out in of for foreach if elif elsif while do then end each as range".split(" "));
|
|
51297
51401
|
var OPS5 = { "&&": "and", "||": "or", "!": "not", "===": "==", "!==": "!=", "<>": "!=", "**": "^", and: "and", or: "or", not: "not", is: "==", None: "null", nil: "null", undefined: "null", NULL: "null", nullptr: "null", True: "true", False: "false" };
|
|
@@ -51314,7 +51418,7 @@ function compareItems(o, n) {
|
|
|
51314
51418
|
if (o.kind === "decision") {
|
|
51315
51419
|
const r = compareRules(o, n);
|
|
51316
51420
|
if (!r) return { status: "cannot-check", reason: "One rule could not be drawn as a card, so its answers could not be compared.", ...where };
|
|
51317
|
-
if (r.same) return { status: "same", reason: `Same answer on all ${r.tried} edge cases.`, ...where };
|
|
51421
|
+
if (r.same) return { status: "same", reason: r.capped ? `Same answer on the first ${r.tried} of ${r.total} edge cases (the rest were not tried).` : `Same answer on all ${r.tried} edge cases.`, ...where };
|
|
51318
51422
|
if (r.counterexample) {
|
|
51319
51423
|
const facts = r.counterexample.facts;
|
|
51320
51424
|
return { status: "different", reason: `Different answer for ${facts}: ${r.counterexample.old} before, ${r.counterexample.new} after.`, counterexample: r.counterexample, ...where };
|
|
@@ -51334,31 +51438,36 @@ function compareItems(o, n) {
|
|
|
51334
51438
|
function sameMeaning(oldFiles, newFiles) {
|
|
51335
51439
|
const A = readAll(oldFiles), B = readAll(newFiles);
|
|
51336
51440
|
const items = [], used = /* @__PURE__ */ new Set();
|
|
51337
|
-
const partner = (
|
|
51338
|
-
if (B.items.has(
|
|
51441
|
+
const partner = (key2, o) => {
|
|
51442
|
+
if (B.items.has(key2) && !used.has(key2)) return key2;
|
|
51339
51443
|
const n = nameKey(o.name), a = A.byName.get(n), b = B.byName.get(n);
|
|
51340
51444
|
return a && b && !used.has(b) ? b : null;
|
|
51341
51445
|
};
|
|
51342
|
-
for (const [
|
|
51343
|
-
const k = partner(
|
|
51446
|
+
for (const [key2, o] of A.items) {
|
|
51447
|
+
const k = partner(key2, o);
|
|
51344
51448
|
if (k) used.add(k);
|
|
51345
51449
|
const n = k && B.items.get(k);
|
|
51346
51450
|
items.push({ name: o.name, ...n ? compareItems(o, n) : { status: "only-old", reason: "Not found in the new code.", old: { file: o.file, line: o.line, language: o.language } } });
|
|
51347
51451
|
}
|
|
51348
|
-
for (const [
|
|
51452
|
+
for (const [key2, n] of B.items) if (!used.has(key2)) items.push({ name: n.name, status: "only-new", reason: "New: not in the old code.", new: { file: n.file, line: n.line, language: n.language } });
|
|
51349
51453
|
const counts = { same: 0, different: 0, "only-old": 0, "only-new": 0, "cannot-check": 0 };
|
|
51350
|
-
for (const it of items)
|
|
51454
|
+
for (const it of items) {
|
|
51455
|
+
counts[it.status]++;
|
|
51456
|
+
it.evidence = it.status === "same" ? /edge cases/.test(it.reason) ? "tested" : "partial" : it.status === "cannot-check" ? "unverified" : "violated";
|
|
51457
|
+
}
|
|
51351
51458
|
const verdict2 = counts.different || counts["only-old"] || counts["only-new"] ? "different" : counts["cannot-check"] ? "partly-checked" : "same";
|
|
51352
|
-
|
|
51459
|
+
const evidence2 = combineEvidence(items.map((it) => it.evidence));
|
|
51460
|
+
return { schema: SAME_SCHEMA, verdict: verdict2, evidence: evidence2, counts, items, unreadable: [...A.unreadable, ...B.unreadable] };
|
|
51353
51461
|
}
|
|
51354
51462
|
function renderSame(r) {
|
|
51355
51463
|
const head = r.verdict === "same" ? "Same meaning." : r.verdict === "partly-checked" ? "No differences found, but some parts could not be checked." : "Different meaning.";
|
|
51356
|
-
const
|
|
51464
|
+
const how = r.evidence ? ` ${evidenceWord(r.evidence)}${r.evidence === "tested" ? " (answers compared on edge cases, not every input)" : r.evidence === "partial" ? " (some parts compared by running, others only by reading)" : ""}.` : "";
|
|
51465
|
+
const lines = [`${head}${how} ${r.counts.same} same, ${r.counts.different} different, ${r.counts["only-old"]} only in the old code, ${r.counts["only-new"]} only in the new code, ${r.counts["cannot-check"]} not checked.`];
|
|
51357
51466
|
const order2 = ["different", "only-old", "only-new", "cannot-check", "same"];
|
|
51358
51467
|
const label = { different: "different", "only-old": "only old", "only-new": "only new", "cannot-check": "not checked", same: "same" };
|
|
51359
51468
|
for (const st of order2) for (const it of r.items.filter((x) => x.status === st)) {
|
|
51360
|
-
const
|
|
51361
|
-
lines.push(` ${label[st].padEnd(11)} ${it.name} (${
|
|
51469
|
+
const loc2 = [it.old && `${it.old.file}:${it.old.line}`, it.new && `${it.new.file}:${it.new.line}`].filter(Boolean).join(" \u2192 ");
|
|
51470
|
+
lines.push(` ${label[st].padEnd(11)} ${it.name} (${loc2}) ${it.reason}`);
|
|
51362
51471
|
}
|
|
51363
51472
|
return `${lines.join("\n")}
|
|
51364
51473
|
`;
|
|
@@ -51561,7 +51670,7 @@ function findMember(state, ref2) {
|
|
|
51561
51670
|
if (r.file && path !== r.file && !path.endsWith(`/${r.file}`)) continue;
|
|
51562
51671
|
const rd = state.read(path);
|
|
51563
51672
|
if (!rd) continue;
|
|
51564
|
-
for (const { key, item: item4 } of memberKeys(rd.reading)) if (item4.name === r.name) candidates3.push({ path, key, item: item4, language: rd.language, reading: rd.reading, source: f });
|
|
51673
|
+
for (const { key: key2, item: item4 } of memberKeys(rd.reading)) if (item4.name === r.name) candidates3.push({ path, key: key2, item: item4, language: rd.language, reading: rd.reading, source: f });
|
|
51565
51674
|
}
|
|
51566
51675
|
if (!candidates3.length && r.name) {
|
|
51567
51676
|
const bare2 = String(r.name).replace(/\s+/g, "");
|
|
@@ -51569,7 +51678,7 @@ function findMember(state, ref2) {
|
|
|
51569
51678
|
if (r.file && path !== r.file && !path.endsWith(`/${r.file}`)) continue;
|
|
51570
51679
|
const rd = state.read(path);
|
|
51571
51680
|
if (!rd) continue;
|
|
51572
|
-
for (const { key, item: item4 } of memberKeys(rd.reading)) if (String(item4.name).replace(/\s+/g, "") === bare2) candidates3.push({ path, key, item: item4, language: rd.language, reading: rd.reading, source: f });
|
|
51681
|
+
for (const { key: key2, item: item4 } of memberKeys(rd.reading)) if (String(item4.name).replace(/\s+/g, "") === bare2) candidates3.push({ path, key: key2, item: item4, language: rd.language, reading: rd.reading, source: f });
|
|
51573
51682
|
}
|
|
51574
51683
|
}
|
|
51575
51684
|
if (!candidates3.length) refuse(`No function named ${r.name}${r.file ? ` in ${r.file}` : ""} was found.`);
|
|
@@ -51669,9 +51778,9 @@ var isNode = (v) => v && typeof v === "object" && !Array.isArray(v) && typeof v.
|
|
|
51669
51778
|
function diffTrees(o, n, sp, language) {
|
|
51670
51779
|
if (sameExpr(o, n)) return [];
|
|
51671
51780
|
const whole = () => {
|
|
51672
|
-
const
|
|
51673
|
-
if (!
|
|
51674
|
-
return [{ range, text: renderPart(n, o, sp, language), node: n, old: o }];
|
|
51781
|
+
const range2 = sp.rangeOf(o);
|
|
51782
|
+
if (!range2) return null;
|
|
51783
|
+
return [{ range: range2, text: renderPart(n, o, sp, language), node: n, old: o }];
|
|
51675
51784
|
};
|
|
51676
51785
|
if (o.kind !== n.kind) return whole();
|
|
51677
51786
|
const keys = /* @__PURE__ */ new Set([...Object.keys(o), ...Object.keys(n)]);
|
|
@@ -51727,7 +51836,7 @@ function rewriteCode(code3, oldTree, newTree, language) {
|
|
|
51727
51836
|
if (sp && sameExpr(sp.tree, oldTree)) {
|
|
51728
51837
|
const reps = diffTrees(sp.tree, newTree, sp, language);
|
|
51729
51838
|
if (reps) {
|
|
51730
|
-
const
|
|
51839
|
+
const build2 = (paren) => {
|
|
51731
51840
|
let text2 = sp.source;
|
|
51732
51841
|
const edits = reps.map((r) => {
|
|
51733
51842
|
if (r.op) {
|
|
@@ -51743,7 +51852,7 @@ function rewriteCode(code3, oldTree, newTree, language) {
|
|
|
51743
51852
|
for (const e of edits) text2 = text2.slice(0, e.range[0]) + e.text + text2.slice(e.range[1]);
|
|
51744
51853
|
return text2;
|
|
51745
51854
|
};
|
|
51746
|
-
attempts.push(
|
|
51855
|
+
attempts.push(build2(false), build2(true));
|
|
51747
51856
|
}
|
|
51748
51857
|
}
|
|
51749
51858
|
try {
|
|
@@ -52269,11 +52378,11 @@ function opSetCondition(ctx, edit) {
|
|
|
52269
52378
|
did.push("turned the question around");
|
|
52270
52379
|
}
|
|
52271
52380
|
if (edit.addClause != null) {
|
|
52272
|
-
const
|
|
52273
|
-
if (
|
|
52381
|
+
const join9 = edit.addClause.join || "and";
|
|
52382
|
+
if (join9 !== "and" && join9 !== "or") refuse('A new part joins with "and" or "or".');
|
|
52274
52383
|
const part = exprFrom(edit.addClause.when, ctx.language, "condition");
|
|
52275
|
-
test = test.kind === "logic" && test.op ===
|
|
52276
|
-
did.push(`added "${
|
|
52384
|
+
test = test.kind === "logic" && test.op === join9 ? { ...test, operands: [...test.operands, part] } : { kind: "logic", op: join9, operands: [test, part] };
|
|
52385
|
+
did.push(`added "${join9} ${sayFull(part)}"`);
|
|
52277
52386
|
}
|
|
52278
52387
|
if (edit.removeClause != null) {
|
|
52279
52388
|
if (test.kind !== "logic") refuse("This question has one part; remove the question instead (removeStep).");
|
|
@@ -52345,25 +52454,25 @@ function placeFor(ctx, edit) {
|
|
|
52345
52454
|
if (!pos) refuse('Say where the new step goes: before, after, or into ({ step, side: "yes" | "no", at: "start" | "end" }).');
|
|
52346
52455
|
if (pos === "into") {
|
|
52347
52456
|
const into = typeof edit.into === "object" && !Array.isArray(edit.into) ? edit.into : { step: edit.into };
|
|
52348
|
-
const
|
|
52349
|
-
const p =
|
|
52457
|
+
const loc3 = ctx.at(into.step);
|
|
52458
|
+
const p = loc3.step;
|
|
52350
52459
|
const side2 = into.side || "yes";
|
|
52351
52460
|
if (!SIDES[side2]) refuse('A side is "yes" or "no".');
|
|
52352
52461
|
const kids2 = side2 === "yes" ? p.children || [] : p.otherwise;
|
|
52353
52462
|
if (!(p.expr?.kind === "if" || p.expr?.kind === "loop" || side2 === "yes" && p.children)) refuse(`The step at line ${p.line} is not a question or a repeat, so it has no side to add to.`);
|
|
52354
|
-
if (side2 === "no" && !kids2) return { pos, newElse: true, loc:
|
|
52463
|
+
if (side2 === "no" && !kids2) return { pos, newElse: true, loc: loc3 };
|
|
52355
52464
|
if (!kids2?.length) needsAi(`The ${side2} side of ${q(sayStep(p))} is empty in the code; the writer adds next to an existing step.`);
|
|
52356
52465
|
const atEnd = into.at !== "start";
|
|
52357
52466
|
const anchor = atEnd ? kids2[kids2.length - 1] : kids2[0];
|
|
52358
52467
|
const [a2, b2] = stepLines(anchor);
|
|
52359
|
-
return { pos, line: atEnd ? b2 + 1 : a2, indent: indentOf3(linesOf(ctx.source)[a2 - 1]), shapePath: [...
|
|
52468
|
+
return { pos, line: atEnd ? b2 + 1 : a2, indent: indentOf3(linesOf(ctx.source)[a2 - 1]), shapePath: [...loc3.path, ...side2 === "no" ? ["else"] : [], atEnd ? kids2.length : 0], loc: loc3 };
|
|
52360
52469
|
}
|
|
52361
|
-
const
|
|
52362
|
-
const [a, b] = stepLines(
|
|
52363
|
-
if (!ownsLines(ctx.source,
|
|
52364
|
-
const path = [...
|
|
52470
|
+
const loc2 = ctx.at(edit[pos]);
|
|
52471
|
+
const [a, b] = stepLines(loc2.step);
|
|
52472
|
+
if (!ownsLines(ctx.source, loc2.step)) needsAi(`The step at line ${loc2.step.line} shares its lines with other code, so the writer cannot place a step ${pos} it.`);
|
|
52473
|
+
const path = [...loc2.path];
|
|
52365
52474
|
if (pos === "after") path[path.length - 1] += 1;
|
|
52366
|
-
return { pos, line: pos === "after" ? b + 1 : withDecorators(ctx.source, a), indent: indentOf3(linesOf(ctx.source)[a - 1]), shapePath: path, loc };
|
|
52475
|
+
return { pos, line: pos === "after" ? b + 1 : withDecorators(ctx.source, a), indent: indentOf3(linesOf(ctx.source)[a - 1]), shapePath: path, loc: loc2 };
|
|
52367
52476
|
}
|
|
52368
52477
|
function insertShape(shape, path, nodes2) {
|
|
52369
52478
|
const list3 = path.length === 1 ? shape : (() => {
|
|
@@ -52402,15 +52511,15 @@ function docstringBefore(L, a) {
|
|
|
52402
52511
|
}
|
|
52403
52512
|
return false;
|
|
52404
52513
|
}
|
|
52405
|
-
function removeAt(ctx,
|
|
52406
|
-
const [a0, b] = stepLines(
|
|
52514
|
+
function removeAt(ctx, loc2, { replaceWithPass = true } = {}) {
|
|
52515
|
+
const [a0, b] = stepLines(loc2.step);
|
|
52407
52516
|
const a = withDecorators(ctx.source, a0);
|
|
52408
|
-
if (!ownsLines(ctx.source,
|
|
52517
|
+
if (!ownsLines(ctx.source, loc2.step)) needsAi(`The step at line ${loc2.step.line} shares its lines with other code, so the writer cannot remove it alone.`);
|
|
52409
52518
|
const L = linesOf(ctx.source);
|
|
52410
|
-
const siblings =
|
|
52411
|
-
if (ctx.language === "python" && siblings.length === 1 && replaceWithPass && (
|
|
52519
|
+
const siblings = loc2.list.filter((s) => s.expr?.kind !== "pass");
|
|
52520
|
+
if (ctx.language === "python" && siblings.length === 1 && replaceWithPass && (loc2.parent || !docstringBefore(L, a))) ctx.lines(a, b - a + 1, [`${indentOf3(L[a - 1])}pass`]);
|
|
52412
52521
|
else ctx.lines(a, b - a + 1, []);
|
|
52413
|
-
listAt(ctx.shape,
|
|
52522
|
+
listAt(ctx.shape, loc2.path).splice(loc2.path[loc2.path.length - 1], 1);
|
|
52414
52523
|
}
|
|
52415
52524
|
function opAddStep(ctx, edit) {
|
|
52416
52525
|
if (edit.step == null && edit.steps == null) refuse('Say the new step with "step" (code, { if, then }, or { stop }).');
|
|
@@ -52419,18 +52528,18 @@ function opAddStep(ctx, edit) {
|
|
|
52419
52528
|
return `Added ${nodes2.map((n) => q(sayFull(n.e))).join(", ")}`;
|
|
52420
52529
|
}
|
|
52421
52530
|
function opRemoveStep(ctx, edit) {
|
|
52422
|
-
const
|
|
52423
|
-
removeAt(ctx,
|
|
52424
|
-
return `Removed ${q(sayStep(
|
|
52531
|
+
const loc2 = ctx.at(edit.step);
|
|
52532
|
+
removeAt(ctx, loc2);
|
|
52533
|
+
return `Removed ${q(sayStep(loc2.step))}${loc2.step.children?.length ? ` and the ${loc2.step.children.length} step${loc2.step.children.length === 1 ? "" : "s"} inside it` : ""}`;
|
|
52425
52534
|
}
|
|
52426
52535
|
function opMoveStep(ctx, edit) {
|
|
52427
|
-
const
|
|
52536
|
+
const loc2 = ctx.at(edit.step);
|
|
52428
52537
|
const pos = edit.before != null ? "before" : edit.after != null ? "after" : refuse("Say where it moves: before or after another step.");
|
|
52429
52538
|
const dest = ctx.at(edit[pos]);
|
|
52430
|
-
if (dest.step ===
|
|
52431
|
-
if (dest.path.join(".").startsWith(`${
|
|
52432
|
-
if (!ownsLines(ctx.source,
|
|
52433
|
-
const [a0, b] = stepLines(
|
|
52539
|
+
if (dest.step === loc2.step) refuse("A step cannot move next to itself.");
|
|
52540
|
+
if (dest.path.join(".").startsWith(`${loc2.path.join(".")}.`)) refuse("A step cannot move inside itself.");
|
|
52541
|
+
if (!ownsLines(ctx.source, loc2.step) || !ownsLines(ctx.source, dest.step)) needsAi("One of the steps shares its lines with other code, so the writer cannot move it alone.");
|
|
52542
|
+
const [a0, b] = stepLines(loc2.step);
|
|
52434
52543
|
const a = withDecorators(ctx.source, a0);
|
|
52435
52544
|
const [da0, db] = stepLines(dest.step);
|
|
52436
52545
|
const da = withDecorators(ctx.source, da0);
|
|
@@ -52440,7 +52549,7 @@ function opMoveStep(ctx, edit) {
|
|
|
52440
52549
|
const re = moved.map((l) => l.startsWith(fromIndent) ? toIndent + l.slice(fromIndent.length) : l);
|
|
52441
52550
|
const at2 = pos === "before" ? da : db + 1;
|
|
52442
52551
|
if (at2 >= a && at2 <= b + 1) refuse("The step is already there.");
|
|
52443
|
-
const node2 = listAt(ctx.shape,
|
|
52552
|
+
const node2 = listAt(ctx.shape, loc2.path)[loc2.path[loc2.path.length - 1]];
|
|
52444
52553
|
if (at2 > b) {
|
|
52445
52554
|
ctx.lines(at2, 0, re);
|
|
52446
52555
|
ctx.lines(a, b - a + 1, []);
|
|
@@ -52449,15 +52558,15 @@ function opMoveStep(ctx, edit) {
|
|
|
52449
52558
|
ctx.lines(at2, 0, re);
|
|
52450
52559
|
}
|
|
52451
52560
|
const destKey = dest.path.join(".");
|
|
52452
|
-
listAt(ctx.shape,
|
|
52561
|
+
listAt(ctx.shape, loc2.path).splice(loc2.path[loc2.path.length - 1], 1);
|
|
52453
52562
|
const destPath = [...dest.path];
|
|
52454
|
-
const lp =
|
|
52563
|
+
const lp = loc2.path;
|
|
52455
52564
|
if (lp.length <= destPath.length && lp.slice(0, -1).join(".") === destPath.slice(0, lp.length - 1).join(".") && lp[lp.length - 1] < destPath[lp.length - 1]) destPath[lp.length - 1] -= 1;
|
|
52456
52565
|
void destKey;
|
|
52457
52566
|
if (pos === "after") destPath[destPath.length - 1] += 1;
|
|
52458
|
-
if (ctx.language === "python" &&
|
|
52567
|
+
if (ctx.language === "python" && loc2.list.length === 1 && loc2.parent) needsAi("Moving the only step out of a Python block would leave it empty.");
|
|
52459
52568
|
insertShape(ctx.shape, destPath, [node2]);
|
|
52460
|
-
return `Moved ${q(sayStep(
|
|
52569
|
+
return `Moved ${q(sayStep(loc2.step))} ${pos} ${q(sayStep(dest.step))}`;
|
|
52461
52570
|
}
|
|
52462
52571
|
function opAddStop(ctx, edit) {
|
|
52463
52572
|
const stop = { e: stopTree(ctx, edit.error, edit.message), c: [] };
|
|
@@ -52467,28 +52576,28 @@ function opAddStop(ctx, edit) {
|
|
|
52467
52576
|
return `Added a Stop: if ${sayFull(test)}, stop with ${q(edit.message)}`;
|
|
52468
52577
|
}
|
|
52469
52578
|
if (edit.step == null) refuse(`Say where the Stop goes: a new question ("when" and before/after), or a question's side ("step" and "side").`);
|
|
52470
|
-
const
|
|
52471
|
-
if (
|
|
52579
|
+
const loc2 = ctx.at(edit.step);
|
|
52580
|
+
if (loc2.step.expr?.kind !== "if") refuse(`The step at line ${loc2.step.line} is not a question, so it has no side to stop on.`);
|
|
52472
52581
|
const side2 = edit.side || "yes";
|
|
52473
|
-
const kids2 = side2 === "yes" ?
|
|
52582
|
+
const kids2 = side2 === "yes" ? loc2.step.children : loc2.step.otherwise;
|
|
52474
52583
|
const last = kids2?.[kids2.length - 1];
|
|
52475
|
-
if (last && /^(return|throw)$/.test(last.expr?.kind ?? "")) refuse(`The ${side2} side of ${q(sayStep(
|
|
52476
|
-
if (side2 === "no" &&
|
|
52584
|
+
if (last && /^(return|throw)$/.test(last.expr?.kind ?? "")) refuse(`The ${side2} side of ${q(sayStep(loc2.step))} already ends (${q(sayStep(last))}); a Stop after it would never be reached.`);
|
|
52585
|
+
if (side2 === "no" && loc2.step.otherwise?.length && loc2.step.otherwise.length === 1 && loc2.step.otherwise[0].expr?.kind === "if" && !ctx.source.split("\n")[loc2.step.otherwise[0].line - 1].includes("{")) needsAi("The no side is an else-if chain; the writer does not add to it.");
|
|
52477
52586
|
insertSteps(ctx, { into: { step: edit.step, side: side2, at: "end" } }, [stop]);
|
|
52478
|
-
return `Added a Stop on the ${side2} side of ${q(sayStep(
|
|
52587
|
+
return `Added a Stop on the ${side2} side of ${q(sayStep(loc2.step))}: ${q(edit.message)}`;
|
|
52479
52588
|
}
|
|
52480
52589
|
function opRemoveStop(ctx, edit) {
|
|
52481
|
-
const
|
|
52482
|
-
const isStop =
|
|
52483
|
-
if (!isStop) refuse(`The step at line ${
|
|
52484
|
-
const parent =
|
|
52485
|
-
if (parent && parent.expr?.kind === "if" && parent.children?.length === 1 && parent.children[0] ===
|
|
52486
|
-
const ploc = ctx.at([...
|
|
52590
|
+
const loc2 = ctx.at(edit.step);
|
|
52591
|
+
const isStop = loc2.step.kind === "fail" || loc2.step.expr?.kind === "throw";
|
|
52592
|
+
if (!isStop) refuse(`The step at line ${loc2.step.line} is not a Stop (${q(sayStep(loc2.step))}).`);
|
|
52593
|
+
const parent = loc2.parent;
|
|
52594
|
+
if (parent && parent.expr?.kind === "if" && parent.children?.length === 1 && parent.children[0] === loc2.step && !parent.otherwise?.length) {
|
|
52595
|
+
const ploc = ctx.at([...loc2.path.slice(0, -1)]);
|
|
52487
52596
|
removeAt(ctx, ploc);
|
|
52488
|
-
return `Removed the Stop ${q(sayStep(
|
|
52597
|
+
return `Removed the Stop ${q(sayStep(loc2.step))} and its question ${q(sayStep(parent))}`;
|
|
52489
52598
|
}
|
|
52490
|
-
removeAt(ctx,
|
|
52491
|
-
return `Removed the Stop ${q(sayStep(
|
|
52599
|
+
removeAt(ctx, loc2);
|
|
52600
|
+
return `Removed the Stop ${q(sayStep(loc2.step))}`;
|
|
52492
52601
|
}
|
|
52493
52602
|
function opAddInput(ctx, edit) {
|
|
52494
52603
|
const { item: item4, language } = ctx;
|
|
@@ -52706,9 +52815,9 @@ function applyEdit(state, edit) {
|
|
|
52706
52815
|
shape: stepShape(m.item.steps),
|
|
52707
52816
|
at(sel) {
|
|
52708
52817
|
if (sel == null) refuse('Say which step (its id, its line as "line:N", or its path such as "2" or "1.0").');
|
|
52709
|
-
const
|
|
52710
|
-
if (!
|
|
52711
|
-
return
|
|
52818
|
+
const loc2 = locateStep(m.item.steps, sel, { flowSteps: m.item.steps });
|
|
52819
|
+
if (!loc2) refuse(`${m.item.name} has no step ${JSON.stringify(sel)}.`);
|
|
52820
|
+
return loc2;
|
|
52712
52821
|
},
|
|
52713
52822
|
// Steps edited by tree are written after every other kind of change is planned (their lines do not move).
|
|
52714
52823
|
treeEdits: [],
|
|
@@ -52843,7 +52952,7 @@ function maskSteps(steps, line) {
|
|
|
52843
52952
|
var hasInner = (shape, names) => (shape || []).some((s) => s.e?.kind === "function" && names.has(s.e.name) || hasInner(s.c, names) || hasInner(s.o, names) || hasInner(s.a, names) || (s.h || []).some((h) => hasInner(h.c, names)));
|
|
52844
52953
|
var maskInner = (shape, names) => (shape || []).map((s) => s.e?.kind === "function" && names.has(s.e.name) ? { e: { kind: "code", text: `(the edited function ${s.e.name})` }, c: [] } : { ...s, c: maskInner(s.c, names), ...s.o ? { o: maskInner(s.o, names) } : {}, ...s.a ? { a: maskInner(s.a, names) } : {}, ...s.h ? { h: s.h.map((h) => ({ ...h, c: maskInner(h.c, names) })) } : {} });
|
|
52845
52954
|
function proveChange(before, after, plans) {
|
|
52846
|
-
const
|
|
52955
|
+
const problems2 = [];
|
|
52847
52956
|
const edited = { status: "proven", checks: [] };
|
|
52848
52957
|
const readOf = (files, path) => {
|
|
52849
52958
|
const src = files.get(path);
|
|
@@ -52868,41 +52977,41 @@ function proveChange(before, after, plans) {
|
|
|
52868
52977
|
if (p.added) {
|
|
52869
52978
|
const r2 = readOf(after, p.added.path);
|
|
52870
52979
|
if (r2.error) {
|
|
52871
|
-
|
|
52980
|
+
problems2.push(`${p.added.path} could not be read after the change: ${r2.error}`);
|
|
52872
52981
|
continue;
|
|
52873
52982
|
}
|
|
52874
52983
|
const it2 = memberKeys(r2.reading).find((x) => x.item.name === p.added.name);
|
|
52875
52984
|
editedKeys.add(`${p.added.path}|${it2?.key}`);
|
|
52876
52985
|
if (!it2) {
|
|
52877
|
-
|
|
52986
|
+
problems2.push(`The new function ${p.added.name} is not read from the changed file.`);
|
|
52878
52987
|
continue;
|
|
52879
52988
|
}
|
|
52880
52989
|
const d2 = firstShapeDifference(p.added.shape, stepShape(it2.item.steps));
|
|
52881
|
-
if (d2)
|
|
52882
|
-
if (JSON.stringify(it2.item.inputs.map((x) => x.name)) !== JSON.stringify(p.added.inputs))
|
|
52990
|
+
if (d2) problems2.push(`${p.added.name}: ${d2}.`);
|
|
52991
|
+
if (JSON.stringify(it2.item.inputs.map((x) => x.name)) !== JSON.stringify(p.added.inputs)) problems2.push(`${p.added.name} takes ${it2.item.inputs.map((x) => x.name).join(", ") || "nothing"}, not ${p.added.inputs.join(", ") || "nothing"}.`);
|
|
52883
52992
|
edited.checks.push({ member: p.added.name, file: p.added.path, result: d2 ? "different" : "exact", steps: p.added.shape.length });
|
|
52884
52993
|
continue;
|
|
52885
52994
|
}
|
|
52886
52995
|
const mm = p.member;
|
|
52887
52996
|
const r = readOf(after, mm.path);
|
|
52888
52997
|
if (r.error) {
|
|
52889
|
-
|
|
52998
|
+
problems2.push(`${mm.path} could not be read after the change: ${r.error}`);
|
|
52890
52999
|
continue;
|
|
52891
53000
|
}
|
|
52892
|
-
const
|
|
52893
|
-
const it = memberKeys(r.reading).find((x) => x.key ===
|
|
52894
|
-
editedKeys.add(`${mm.path}|${
|
|
53001
|
+
const key2 = renamed ? mm.key.replace(/^[^#]+/, mm.name) : mm.key;
|
|
53002
|
+
const it = memberKeys(r.reading).find((x) => x.key === key2);
|
|
53003
|
+
editedKeys.add(`${mm.path}|${key2}`);
|
|
52895
53004
|
if (!it) {
|
|
52896
|
-
|
|
53005
|
+
problems2.push(`${mm.name} is no longer read from ${mm.path} after the change.`);
|
|
52897
53006
|
edited.checks.push({ member: mm.name, file: mm.path, result: "missing" });
|
|
52898
53007
|
continue;
|
|
52899
53008
|
}
|
|
52900
53009
|
const d = firstShapeDifference(mm.shape, stepShape(it.item.steps));
|
|
52901
|
-
if (d)
|
|
53010
|
+
if (d) problems2.push(`${mm.name}: ${d}.`);
|
|
52902
53011
|
const gotInputs = it.item.inputs.map((x) => x.name);
|
|
52903
53012
|
const inputsOk = !mm.inputs || (Array.isArray(mm.inputs) ? JSON.stringify(gotInputs) === JSON.stringify(mm.inputs) : gotInputs.includes(mm.inputs.added) && JSON.stringify(gotInputs.filter((x) => x !== mm.inputs.added)) === JSON.stringify(mm.inputs.was));
|
|
52904
|
-
if (!inputsOk)
|
|
52905
|
-
if (mm.returns && String(it.item.returns ?? "").replace(/\s+/g, "") !== String(mm.returns).replace(/\s+/g, "") && !String(it.item.returns ?? "").includes(String(mm.returns).replace(/^\(|\)$/g, "")))
|
|
53013
|
+
if (!inputsOk) problems2.push(`${mm.name} takes ${it.item.inputs.map((x) => x.name).join(", ")} after the change, not ${Array.isArray(mm.inputs) ? mm.inputs.join(", ") : [...mm.inputs.was, mm.inputs.added].join(", ")}.`);
|
|
53014
|
+
if (mm.returns && String(it.item.returns ?? "").replace(/\s+/g, "") !== String(mm.returns).replace(/\s+/g, "") && !String(it.item.returns ?? "").includes(String(mm.returns).replace(/^\(|\)$/g, ""))) problems2.push(`${mm.name} gives back ${it.item.returns ?? "nothing declared"} after the change, not ${mm.returns}.`);
|
|
52906
53015
|
edited.checks.push({ member: mm.name, file: mm.path, result: d ? "different" : "exact", steps: mm.shape.length });
|
|
52907
53016
|
const rb = readOf(before, mm.path);
|
|
52908
53017
|
const old = !rb.error && memberKeys(rb.reading).find((x) => x.key === mm.key);
|
|
@@ -52911,7 +53020,7 @@ function proveChange(before, after, plans) {
|
|
|
52911
53020
|
ranges.get(mm.path).push({ before: [old.item.line, memberEnd(old.item)], after: [it.item.line, memberEnd(it.item)] });
|
|
52912
53021
|
}
|
|
52913
53022
|
}
|
|
52914
|
-
if (
|
|
53023
|
+
if (problems2.length) edited.status = "failed";
|
|
52915
53024
|
const items = [];
|
|
52916
53025
|
const editedInner = /* @__PURE__ */ new Map();
|
|
52917
53026
|
const insideEdited = /* @__PURE__ */ new Map();
|
|
@@ -52930,10 +53039,10 @@ function proveChange(before, after, plans) {
|
|
|
52930
53039
|
innerDefs(p.member.shape, insideEdited.get(p.member.path));
|
|
52931
53040
|
}
|
|
52932
53041
|
for (const k of editedKeys) {
|
|
52933
|
-
const [path,
|
|
52934
|
-
if (!
|
|
53042
|
+
const [path, key2] = k.split("|");
|
|
53043
|
+
if (!key2 || key2 === "undefined") continue;
|
|
52935
53044
|
if (!editedInner.has(path)) editedInner.set(path, /* @__PURE__ */ new Set());
|
|
52936
|
-
editedInner.get(path).add(
|
|
53045
|
+
editedInner.get(path).add(key2.split("#")[0]);
|
|
52937
53046
|
}
|
|
52938
53047
|
for (const p of plans) if (p.member && editedInner.has(p.member.path)) {
|
|
52939
53048
|
editedInner.get(p.member.path).add(p.member.key.split("#")[0]);
|
|
@@ -52943,7 +53052,7 @@ function proveChange(before, after, plans) {
|
|
|
52943
53052
|
for (const path of touched) {
|
|
52944
53053
|
const a = readOf(before, path), b = readOf(after, path);
|
|
52945
53054
|
if (a.error || b.error) {
|
|
52946
|
-
|
|
53055
|
+
problems2.push(`${path} could not be read ${a.error ? "before" : "after"} the change.`);
|
|
52947
53056
|
continue;
|
|
52948
53057
|
}
|
|
52949
53058
|
const olds = memberKeys(a.reading), news = memberKeys(b.reading);
|
|
@@ -53009,9 +53118,9 @@ function proveChange(before, after, plans) {
|
|
|
53009
53118
|
}
|
|
53010
53119
|
}
|
|
53011
53120
|
const bad = items.filter((x) => x.status !== "same");
|
|
53012
|
-
for (const b of bad)
|
|
53121
|
+
for (const b of bad) problems2.push(`${b.name} (${b.file}) ${b.status === "missing" ? "is missing after the change" : b.status === "new" ? "appeared, though it was not asked for" : `reads differently after the change: ${b.reason}`}.`);
|
|
53013
53122
|
const unchanged = { status: bad.length ? "failed" : "same", checked: items.length, items };
|
|
53014
|
-
return { ok: !
|
|
53123
|
+
return { ok: !problems2.length, edited, unchanged, problems: problems2 };
|
|
53015
53124
|
}
|
|
53016
53125
|
function numbered(source, a, b) {
|
|
53017
53126
|
const L = linesOf(source);
|
|
@@ -53689,9 +53798,9 @@ function promoteDecision(item4, { file = item4.file || "" } = {}) {
|
|
|
53689
53798
|
const { notes, refs, renames, names, types, rules, decisionName, run, all } = model;
|
|
53690
53799
|
const results = [...item4.rules.map((r) => r.result), item4.otherwise.result];
|
|
53691
53800
|
const chosen = [];
|
|
53692
|
-
const
|
|
53801
|
+
const key2 = (a) => names.map((n) => lit4(a[n])).join("|");
|
|
53693
53802
|
const add2 = (a, label) => {
|
|
53694
|
-
if (chosen.length >= 10 || chosen.some((c) =>
|
|
53803
|
+
if (chosen.length >= 10 || chosen.some((c) => key2(c.a) === key2(a) || c.label === label)) return;
|
|
53695
53804
|
chosen.push({ a, label, result: run(a).result });
|
|
53696
53805
|
};
|
|
53697
53806
|
rules.forEach((r, i) => {
|
|
@@ -53862,7 +53971,7 @@ var LANGS = {
|
|
|
53862
53971
|
}
|
|
53863
53972
|
}
|
|
53864
53973
|
};
|
|
53865
|
-
var TRANSLATE_LANGUAGES = Object.entries(LANGS).map(([
|
|
53974
|
+
var TRANSLATE_LANGUAGES = Object.entries(LANGS).map(([key2, l]) => ({ key: key2, label: l.label }));
|
|
53866
53975
|
function translateDecisionsWithDiagnostics(ast, lang) {
|
|
53867
53976
|
const L = LANGS[lang];
|
|
53868
53977
|
if (!L) throw new Error(`Unknown language ${lang}. Use one of: ${Object.keys(LANGS).join(", ")}.`);
|
|
@@ -54130,7 +54239,7 @@ var TOOLS = [
|
|
|
54130
54239
|
},
|
|
54131
54240
|
{
|
|
54132
54241
|
name: "intent_verify_diff",
|
|
54133
|
-
description: "THE AI-LOOP GATE.
|
|
54242
|
+
description: "THE AI-LOOP GATE. Check, deterministically, which of an intent's guarantees and never-rules a code change upholds or breaks, by matching patterns in the code (a check, not a proof; tests and people still own correctness). Returns verdict PASS or BLOCK. Blocks on regressions (a claim that held on `before` and broke on `after`) and guardrail hits (an added line pushing a protected secret into a log/response). Call this on your own proposed change before shipping it.",
|
|
54134
54243
|
inputSchema: {
|
|
54135
54244
|
type: "object",
|
|
54136
54245
|
required: ["intent", "after"],
|
|
@@ -54145,7 +54254,7 @@ var TOOLS = [
|
|
|
54145
54254
|
},
|
|
54146
54255
|
{
|
|
54147
54256
|
name: "intent_prove",
|
|
54148
|
-
description: "Emit the durable intent-proof-v1 artifact for .intent source: per-claim verdicts (verified / failed / planned / needs_verification, each bound to the named test that
|
|
54257
|
+
description: "Emit the durable intent-proof-v1 artifact for .intent source: per-claim verdicts (verified / failed / planned / needs_verification, each bound to the named test that checks it, with its evidence word: Tested, Partially checked, Unverified, or Violated) plus the freshness tuple (intent hash, compiler version, commit, dependency lockfile) that lets `thunder verify` mark the proof STALE later. Mirrors `thunder prove`; an unverified claim never reads as passed. Call it after the gate passes to record what was checked, and how.",
|
|
54149
54258
|
inputSchema: {
|
|
54150
54259
|
type: "object",
|
|
54151
54260
|
required: ["source"],
|
|
@@ -54168,14 +54277,7 @@ var TOOLS = [
|
|
|
54168
54277
|
diagnostics,
|
|
54169
54278
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
54170
54279
|
});
|
|
54171
|
-
|
|
54172
|
-
const byId = new Map(resolved.obligations.map((o) => [o.id, o]));
|
|
54173
|
-
const applyStatus = (claim) => {
|
|
54174
|
-
const o = byId.get(claim.id);
|
|
54175
|
-
return o ? { ...claim, status: CLAIM_MAP[o.status], provenBy: o.provenBy || null } : claim;
|
|
54176
|
-
};
|
|
54177
|
-
proof.guarantees = proof.guarantees.map(applyStatus);
|
|
54178
|
-
proof.neverRules = proof.neverRules.map(applyStatus);
|
|
54280
|
+
foldObligations(proof, resolved);
|
|
54179
54281
|
proof.freshness = proofFreshness(proof, environment);
|
|
54180
54282
|
const ok = proof.verification.semanticPassed && resolved.tests.ok !== false && resolved.failed === 0;
|
|
54181
54283
|
return { ok, proofId: `proof-${proof.sourceHash.replace("sha256:", "").slice(0, 6)}`, ...proof, tests: resolved.tests };
|
|
@@ -54252,7 +54354,7 @@ var TOOLS = [
|
|
|
54252
54354
|
},
|
|
54253
54355
|
{
|
|
54254
54356
|
name: "intent_test",
|
|
54255
|
-
description: "Run the in-file test blocks (case/scenario) in .intent source through the deterministic runtime.
|
|
54357
|
+
description: "Run the in-file test blocks (case/scenario) in .intent source through the deterministic runtime. A passing case is Tested evidence for its own inputs, not a proof of every input.",
|
|
54256
54358
|
inputSchema: { type: "object", required: ["source"], properties: { source: str3 } },
|
|
54257
54359
|
run: ({ source }) => runTests(parseIntent(String(source)))
|
|
54258
54360
|
},
|
|
@@ -54812,7 +54914,383 @@ function buildManifest(files, opts = {}) {
|
|
|
54812
54914
|
};
|
|
54813
54915
|
}
|
|
54814
54916
|
|
|
54917
|
+
// src/symbols.mjs
|
|
54918
|
+
var isTestPath2 = (p) => /(^|\/)tests\//.test(p);
|
|
54919
|
+
var projectOf = (p) => {
|
|
54920
|
+
const m = /^(.*?)(?:^|\/)(?:src|tests)\//.exec(p);
|
|
54921
|
+
return m ? m[1] : "";
|
|
54922
|
+
};
|
|
54923
|
+
var isCore = (f) => /\.thunder$/i.test(f.path) && fileKind(f.source).kind === "program";
|
|
54924
|
+
var KIND_WORDS3 = { function: "function", type: "data type", alternative: "alternative", value: "value", local: "value", input: "input" };
|
|
54925
|
+
function spanAt(text2, col, name, plural6 = false) {
|
|
54926
|
+
const words14 = String(name).trim().split(/\s+/);
|
|
54927
|
+
let i = col - 1;
|
|
54928
|
+
if (i < 0) return null;
|
|
54929
|
+
for (let w = 0; w < words14.length; w++) {
|
|
54930
|
+
if (w > 0) {
|
|
54931
|
+
const sp = /^\s+/.exec(text2.slice(i));
|
|
54932
|
+
if (!sp) return null;
|
|
54933
|
+
i += sp[0].length;
|
|
54934
|
+
}
|
|
54935
|
+
const word = words14[w];
|
|
54936
|
+
if (text2.slice(i, i + word.length).toLowerCase() !== word.toLowerCase()) return null;
|
|
54937
|
+
i += word.length;
|
|
54938
|
+
}
|
|
54939
|
+
let isPlural = false;
|
|
54940
|
+
if (plural6 && /^s(?![\p{L}\p{N}_])/u.test(text2.slice(i))) {
|
|
54941
|
+
i += 1;
|
|
54942
|
+
isPlural = true;
|
|
54943
|
+
}
|
|
54944
|
+
if (/^[\p{L}\p{N}_]/u.test(text2.slice(i))) return null;
|
|
54945
|
+
return { length: i - (col - 1), plural: isPlural };
|
|
54946
|
+
}
|
|
54947
|
+
function compileProject(coreFiles) {
|
|
54948
|
+
const results = [];
|
|
54949
|
+
for (const f of coreFiles.filter((x) => !isTestPath2(x.path))) results.push({ ...compileCore(f.source, { file: f.path }), parsed: parseCore(f.source), path: f.path, source: f.source, kind: "src" });
|
|
54950
|
+
for (const f of coreFiles.filter((x) => isTestPath2(x.path))) {
|
|
54951
|
+
const root = projectOf(f.path);
|
|
54952
|
+
const seen = results.filter((r) => r.kind === "src" && projectOf(r.path) === root);
|
|
54953
|
+
results.push({ ...compileCore(f.source, { file: f.path, imported: seen }), parsed: parseCore(f.source, { seed: seedFrom(seen) }), path: f.path, source: f.source, kind: "test" });
|
|
54954
|
+
}
|
|
54955
|
+
return results;
|
|
54956
|
+
}
|
|
54957
|
+
function localsOf(fn) {
|
|
54958
|
+
const out = new Set(fn.params.map((p) => p.name));
|
|
54959
|
+
const walk = (n) => {
|
|
54960
|
+
if (Array.isArray(n)) return n.forEach(walk);
|
|
54961
|
+
if (!n || typeof n !== "object") return;
|
|
54962
|
+
if (n.k === "set" && n.target?.k === "name") out.add(n.target.name);
|
|
54963
|
+
if (n.k === "each") for (const v of n.vars ?? []) out.add(v.name);
|
|
54964
|
+
if (n.k === "range" && n.v) out.add(n.v.name);
|
|
54965
|
+
for (const v of Object.values(n)) if (v && typeof v === "object") walk(v);
|
|
54966
|
+
};
|
|
54967
|
+
walk(fn.body);
|
|
54968
|
+
return out;
|
|
54969
|
+
}
|
|
54970
|
+
function coreOccurrences(coreFiles) {
|
|
54971
|
+
const results = compileProject(coreFiles);
|
|
54972
|
+
const occ = [];
|
|
54973
|
+
const values = /* @__PURE__ */ new Set();
|
|
54974
|
+
const altRecords = /* @__PURE__ */ new Map();
|
|
54975
|
+
for (const r of results) for (const s of r.parsed?.body ?? []) {
|
|
54976
|
+
if (s.k === "keep" || s.k === "store") values.add(s.name);
|
|
54977
|
+
if (s.k === "set" && s.target?.k === "name") values.add(s.target.name);
|
|
54978
|
+
if (s.k === "each") for (const v of s.vars ?? []) values.add(v.name);
|
|
54979
|
+
if (s.k === "record" && s.alts) for (const a of s.alts) altRecords.set(a.name, [...altRecords.get(a.name) ?? [], s.name]);
|
|
54980
|
+
}
|
|
54981
|
+
for (const r of results) {
|
|
54982
|
+
const lines = r.source.replace(/\r\n?/g, "\n").split("\n");
|
|
54983
|
+
const add2 = (o) => {
|
|
54984
|
+
if (o.col == null || o.line == null || !o.text) return;
|
|
54985
|
+
const sp = spanAt(lines[o.line - 1] ?? "", o.col, o.text, o.kind === "type");
|
|
54986
|
+
if (!sp) return;
|
|
54987
|
+
const dup = occ.find((x) => x.id === o.id && x.path === r.path && x.line === o.line && x.col === o.col);
|
|
54988
|
+
if (dup) {
|
|
54989
|
+
dup.def = dup.def || o.def;
|
|
54990
|
+
return;
|
|
54991
|
+
}
|
|
54992
|
+
occ.push({ ...o, path: r.path, length: sp.length, plural: sp.plural, written: (lines[o.line - 1] ?? "").substr(o.col - 1, sp.length) });
|
|
54993
|
+
};
|
|
54994
|
+
const altOf = (alt, record2) => {
|
|
54995
|
+
const recs = record2 ? [record2] : altRecords.get(alt) ?? [];
|
|
54996
|
+
return recs.length === 1 ? recs[0] : null;
|
|
54997
|
+
};
|
|
54998
|
+
const walk = (n, ctx) => {
|
|
54999
|
+
if (Array.isArray(n)) {
|
|
55000
|
+
n.forEach((x) => walk(x, ctx));
|
|
55001
|
+
return;
|
|
55002
|
+
}
|
|
55003
|
+
if (!n || typeof n !== "object") return;
|
|
55004
|
+
const skip = /* @__PURE__ */ new Set();
|
|
55005
|
+
const nameRef = (node2, def) => {
|
|
55006
|
+
const local = ctx.locals?.has(node2.name);
|
|
55007
|
+
if (local) add2({ id: `local:${r.path}:${ctx.fn.name}:${node2.name}`, kind: ctx.params?.has(node2.name) ? "input" : "local", name: node2.name, text: node2.text, line: node2.line, col: node2.col, def, ...ctx.fn.endpoint && ctx.params?.has(node2.name) ? { endpoint: ctx.fn.text } : {} });
|
|
55008
|
+
else if (values.has(node2.name)) add2({ id: `value:${node2.name}`, kind: "value", name: node2.name, text: node2.text, line: node2.line, col: node2.col, def });
|
|
55009
|
+
};
|
|
55010
|
+
switch (n.k) {
|
|
55011
|
+
case "func": {
|
|
55012
|
+
if (!n.endpoint) add2({ id: `function:${n.name}`, kind: "function", name: n.name, text: n.text, line: n.line, col: n.col, def: true });
|
|
55013
|
+
const locals = localsOf(n);
|
|
55014
|
+
const inner = { fn: n, locals, params: new Set(n.params.map((p) => p.name)) };
|
|
55015
|
+
for (const p of n.params) {
|
|
55016
|
+
add2({ id: `local:${r.path}:${n.name}:${p.name}`, kind: "input", name: p.name, text: p.text, line: p.line, col: p.col, def: true, ...n.endpoint ? { endpoint: n.text } : {} });
|
|
55017
|
+
walk(p.type, inner);
|
|
55018
|
+
walk(p.dflt, inner);
|
|
55019
|
+
}
|
|
55020
|
+
walk(n.body, inner);
|
|
55021
|
+
return;
|
|
55022
|
+
}
|
|
55023
|
+
case "record":
|
|
55024
|
+
if (Array.isArray(n.fields)) {
|
|
55025
|
+
add2({ id: `type:${n.name}`, kind: "type", name: n.name, text: n.text, line: n.line, col: n.col, def: true });
|
|
55026
|
+
for (const a of n.alts ?? []) {
|
|
55027
|
+
add2({ id: `alternative:${n.name}:${a.name}`, kind: "alternative", name: a.name, text: a.text, line: a.line, col: a.col, def: true });
|
|
55028
|
+
for (const f of a.fields) walk(f.type, ctx);
|
|
55029
|
+
}
|
|
55030
|
+
for (const f of n.fields) if (!f.hidden && !n.alts) walk(f.type, ctx);
|
|
55031
|
+
walk(n.rules, ctx);
|
|
55032
|
+
return;
|
|
55033
|
+
}
|
|
55034
|
+
add2({ id: `type:${n.name}`, kind: "type", name: n.name, text: n.name, line: n.line, col: n.col, def: false });
|
|
55035
|
+
return;
|
|
55036
|
+
case "new":
|
|
55037
|
+
if (n.recordCol) add2({ id: `type:${n.record}`, kind: "type", name: n.record, text: n.record, line: n.line, col: n.recordCol, def: false });
|
|
55038
|
+
if (n.alt && n.altCol) add2({ id: `alternative:${n.record}:${n.alt}`, kind: "alternative", name: n.alt, text: n.altText ?? n.alt, line: n.line, col: n.altCol, def: false });
|
|
55039
|
+
for (const f of n.fields ?? []) walk(f.e, ctx);
|
|
55040
|
+
return;
|
|
55041
|
+
case "isAlt": {
|
|
55042
|
+
const rec2 = altOf(n.alt);
|
|
55043
|
+
if (rec2) add2({ id: `alternative:${rec2}:${n.alt}`, kind: "alternative", name: n.alt, text: n.text, line: n.line, col: n.col, def: false });
|
|
55044
|
+
walk(n.e, ctx);
|
|
55045
|
+
return;
|
|
55046
|
+
}
|
|
55047
|
+
case "depending":
|
|
55048
|
+
walk(n.subject, ctx);
|
|
55049
|
+
for (const c of n.cases) {
|
|
55050
|
+
const rec2 = altOf(c.alt);
|
|
55051
|
+
if (rec2) add2({ id: `alternative:${rec2}:${c.alt}`, kind: "alternative", name: c.alt, text: c.text, line: c.line, col: c.col, def: false });
|
|
55052
|
+
walk(c.body, ctx);
|
|
55053
|
+
}
|
|
55054
|
+
walk(n.otherwise, ctx);
|
|
55055
|
+
return;
|
|
55056
|
+
case "set":
|
|
55057
|
+
if (n.target?.k === "name") {
|
|
55058
|
+
nameRef(n.target, true);
|
|
55059
|
+
skip.add("target");
|
|
55060
|
+
}
|
|
55061
|
+
break;
|
|
55062
|
+
case "keep":
|
|
55063
|
+
case "store":
|
|
55064
|
+
add2({ id: `value:${n.name}`, kind: "value", name: n.name, text: n.text, line: n.line, col: n.col, def: true });
|
|
55065
|
+
break;
|
|
55066
|
+
case "each":
|
|
55067
|
+
for (const v of n.vars ?? []) nameRef({ ...v, line: n.line }, true);
|
|
55068
|
+
skip.add("vars");
|
|
55069
|
+
break;
|
|
55070
|
+
case "range":
|
|
55071
|
+
if (n.v) nameRef({ ...n.v, line: n.line }, true);
|
|
55072
|
+
skip.add("v");
|
|
55073
|
+
break;
|
|
55074
|
+
case "name":
|
|
55075
|
+
nameRef(n, false);
|
|
55076
|
+
return;
|
|
55077
|
+
case "call":
|
|
55078
|
+
add2({ id: `function:${n.name}`, kind: "function", name: n.name, text: n.text, line: n.line, col: n.col, def: false });
|
|
55079
|
+
break;
|
|
55080
|
+
default:
|
|
55081
|
+
}
|
|
55082
|
+
for (const [k, v] of Object.entries(n)) if (!skip.has(k) && v && typeof v === "object") walk(v, ctx);
|
|
55083
|
+
};
|
|
55084
|
+
walk(r.parsed?.body ?? [], {});
|
|
55085
|
+
}
|
|
55086
|
+
return { occ, results };
|
|
55087
|
+
}
|
|
55088
|
+
var MISSION_BLOCKS = /^(decision|lifecycle|data|service|event|api|scenario|property|capability|component|interface|command|database|artifact|evaluation|metric|outcome|persona|experience|pattern|release|result|learning)\s+([A-Za-z_][\w]*)\s*$/;
|
|
55089
|
+
var FIELD_BLOCKS = /* @__PURE__ */ new Set(["input", "output", "data"]);
|
|
55090
|
+
var PROSE_BLOCKS = /* @__PURE__ */ new Set(["goal", "why", "note", "guarantees", "never", "assumptions", "risks", "problem", "evidence", "scope", "non_goal", "question", "unknown", "assumption", "title", "customer", "persona", "owner"]);
|
|
55091
|
+
var codeOnly2 = (line) => {
|
|
55092
|
+
let out = "", q2 = null;
|
|
55093
|
+
for (let i = 0; i < line.length; i++) {
|
|
55094
|
+
const c = line[i];
|
|
55095
|
+
if (q2) {
|
|
55096
|
+
out += " ";
|
|
55097
|
+
if (c === q2) q2 = null;
|
|
55098
|
+
continue;
|
|
55099
|
+
}
|
|
55100
|
+
if (c === '"' || c === "`") {
|
|
55101
|
+
q2 = c;
|
|
55102
|
+
out += " ";
|
|
55103
|
+
continue;
|
|
55104
|
+
}
|
|
55105
|
+
if (c === "#") {
|
|
55106
|
+
out += " ".repeat(line.length - i);
|
|
55107
|
+
break;
|
|
55108
|
+
}
|
|
55109
|
+
out += c;
|
|
55110
|
+
}
|
|
55111
|
+
return out;
|
|
55112
|
+
};
|
|
55113
|
+
function missionOccurrences(file) {
|
|
55114
|
+
const lines = file.source.replace(/\r\n?/g, "\n").split("\n");
|
|
55115
|
+
const decls = /* @__PURE__ */ new Map();
|
|
55116
|
+
let block = null, prose = false;
|
|
55117
|
+
lines.forEach((raw, i) => {
|
|
55118
|
+
const text2 = codeOnly2(raw);
|
|
55119
|
+
if (!text2.trim()) return;
|
|
55120
|
+
const top = !/^\s/.test(raw);
|
|
55121
|
+
if (top) {
|
|
55122
|
+
const head = text2.trim();
|
|
55123
|
+
const word = head.split(/\s+/)[0];
|
|
55124
|
+
block = FIELD_BLOCKS.has(head) ? head : MISSION_BLOCKS.test(head) ? word : word;
|
|
55125
|
+
prose = PROSE_BLOCKS.has(word);
|
|
55126
|
+
const m = MISSION_BLOCKS.exec(head);
|
|
55127
|
+
if (m && !decls.has(m[2])) decls.set(m[2], { line: i + 1, col: raw.indexOf(m[2], raw.indexOf(m[1]) + m[1].length) + 1, kind: m[1] });
|
|
55128
|
+
if (word === "data" && m) block = "data";
|
|
55129
|
+
return;
|
|
55130
|
+
}
|
|
55131
|
+
const rule = /^\s+rule\s+([A-Za-z_]\w*)\s*$/.exec(text2);
|
|
55132
|
+
if (rule && block === "decision" && !decls.has(rule[1])) decls.set(rule[1], { line: i + 1, col: text2.indexOf(rule[1], text2.indexOf("rule") + 4) + 1, kind: "rule" });
|
|
55133
|
+
const field = /^\s+([A-Za-z_]\w*)\s*:/.exec(text2);
|
|
55134
|
+
if (field && FIELD_BLOCKS.has(block) && !decls.has(field[1])) decls.set(field[1], { line: i + 1, col: text2.indexOf(field[1]) + 1, kind: `${block} field` });
|
|
55135
|
+
});
|
|
55136
|
+
const occ = [];
|
|
55137
|
+
block = null;
|
|
55138
|
+
prose = false;
|
|
55139
|
+
lines.forEach((raw, i) => {
|
|
55140
|
+
const text2 = codeOnly2(raw);
|
|
55141
|
+
if (!/^\s/.test(raw) && text2.trim()) prose = PROSE_BLOCKS.has(text2.trim().split(/\s+/)[0]);
|
|
55142
|
+
if (prose || /^\s*(?:because|case|scenario)\b/.test(text2)) return;
|
|
55143
|
+
for (const m of text2.matchAll(/[A-Za-z_]\w*/g)) {
|
|
55144
|
+
const d = decls.get(m[0]);
|
|
55145
|
+
if (!d) continue;
|
|
55146
|
+
const col = m.index + 1;
|
|
55147
|
+
occ.push({ id: `mission:${file.path}:${m[0]}`, kind: "mission", what: d.kind, name: m[0], text: m[0], path: file.path, line: i + 1, col, length: m[0].length, def: d.line === i + 1 && d.col === col, written: m[0] });
|
|
55148
|
+
}
|
|
55149
|
+
});
|
|
55150
|
+
return occ;
|
|
55151
|
+
}
|
|
55152
|
+
function symbolIndex(files) {
|
|
55153
|
+
const list3 = (files ?? []).filter((f) => f && typeof f.source === "string");
|
|
55154
|
+
const core = list3.filter(isCore);
|
|
55155
|
+
const { occ, results } = core.length ? coreOccurrences(core) : { occ: [], results: [] };
|
|
55156
|
+
for (const f of list3.filter((x) => !isCore(x))) occ.push(...missionOccurrences(f));
|
|
55157
|
+
return { occurrences: occ, results };
|
|
55158
|
+
}
|
|
55159
|
+
function symbolAt(files, path, { line, col }, index = symbolIndex(files)) {
|
|
55160
|
+
const here = index.occurrences.find((o) => o.path === path && o.line === line && col >= o.col && col < o.col + o.length) ?? index.occurrences.find((o) => o.path === path && o.line === line && col === o.col + o.length);
|
|
55161
|
+
if (!here) return null;
|
|
55162
|
+
const all = index.occurrences.filter((o) => o.id === here.id).sort((a, b) => a.path === b.path ? a.line - b.line || a.col - b.col : a.path < b.path ? -1 : 1);
|
|
55163
|
+
const defs = all.filter((o) => o.def);
|
|
55164
|
+
const definitions = here.kind === "local" || here.kind === "value" ? defs.slice(0, 1) : defs;
|
|
55165
|
+
return { id: here.id, kind: here.kind, what: KIND_WORDS3[here.kind] ?? here.what, name: here.name, at: here, definitions, references: all };
|
|
55166
|
+
}
|
|
55167
|
+
var article3 = (w) => `${/^[aeiou]/i.test(w) ? "an" : "a"} ${w}`;
|
|
55168
|
+
var loc = (o) => ({ path: o.path, line: o.line, col: o.col, length: o.length });
|
|
55169
|
+
function definitionsAt(files, path, pos) {
|
|
55170
|
+
const s = symbolAt(files, path, pos);
|
|
55171
|
+
return s ? s.definitions.map(loc) : [];
|
|
55172
|
+
}
|
|
55173
|
+
function referencesAt(files, path, pos, { declaration: declaration2 = true } = {}) {
|
|
55174
|
+
const s = symbolAt(files, path, pos);
|
|
55175
|
+
if (!s) return [];
|
|
55176
|
+
return s.references.filter((o) => declaration2 || !o.def).map(loc);
|
|
55177
|
+
}
|
|
55178
|
+
var problems = (files) => {
|
|
55179
|
+
const out = /* @__PURE__ */ new Map();
|
|
55180
|
+
const { results } = symbolIndex(files);
|
|
55181
|
+
for (const r of results) out.set(r.path, (r.diagnostics ?? []).filter((d) => d.severity !== "warning" && d.code !== "TC120").length);
|
|
55182
|
+
return out;
|
|
55183
|
+
};
|
|
55184
|
+
function cased(newName, written) {
|
|
55185
|
+
const first = written[0] ?? "";
|
|
55186
|
+
if (first && first === first.toUpperCase() && first !== first.toLowerCase()) return newName[0].toUpperCase() + newName.slice(1);
|
|
55187
|
+
if (first && first === first.toLowerCase() && first !== first.toUpperCase()) return newName[0].toLowerCase() + newName.slice(1);
|
|
55188
|
+
return newName;
|
|
55189
|
+
}
|
|
55190
|
+
function renameAt(files, path, pos, newName) {
|
|
55191
|
+
const index = symbolIndex(files);
|
|
55192
|
+
const s = symbolAt(files, path, pos, index);
|
|
55193
|
+
if (!s) return { ok: false, problem: "There is no name here that Thunder can rename: put the cursor on a function, data type, alternative, value, or input (in a mission: a decision, rule, field, or other named block)." };
|
|
55194
|
+
const endpoint = s.references.find((o) => o.endpoint)?.endpoint;
|
|
55195
|
+
if (endpoint) return { ok: false, problem: `${s.at.written} is what callers send to ${endpoint}, so renaming it here would change the API. Go to definition and find references still work.` };
|
|
55196
|
+
const wanted = String(newName ?? "").trim().replace(/\s+/g, " ");
|
|
55197
|
+
if (s.kind === "mission") {
|
|
55198
|
+
if (!/^[A-Za-z_]\w*$/.test(wanted)) return { ok: false, problem: `"${wanted}" can't be a name in a mission: use one word of letters, digits, and _ (like ${s.name}).` };
|
|
55199
|
+
} else {
|
|
55200
|
+
if (!/^[\p{L}_][\p{L}\p{N}_]*(?: [\p{L}_][\p{L}\p{N}_]*)*$/u.test(wanted)) return { ok: false, problem: `"${wanted}" can't be a name: use words of letters and digits, separated by spaces.` };
|
|
55201
|
+
if (/^(?:a|an|the) /i.test(wanted)) return { ok: false, problem: `Thunder skips "a", "an", and "the" at the start of a name, so "${wanted}" would not be the name you see.` };
|
|
55202
|
+
const reserved = wanted.split(" ").find((w) => RESERVED2.has(w.toLowerCase()));
|
|
55203
|
+
if (reserved) return { ok: false, problem: `A name can't contain the word "${reserved}", because it belongs to Thunder.` };
|
|
55204
|
+
}
|
|
55205
|
+
const key2 = s.kind === "mission" ? wanted : wanted.toLowerCase();
|
|
55206
|
+
if (key2 === s.name) return { ok: false, problem: `It is already called ${s.at.written}.` };
|
|
55207
|
+
const scopeOf2 = (o) => o.kind === "local" || o.kind === "input" ? o.id.split(":").slice(0, 3).join(":") : o.kind === "mission" ? `mission:${o.path}` : "global";
|
|
55208
|
+
const clash = index.occurrences.find((o) => o.name === key2 && o.def && (o.kind === "mission" ? scopeOf2(o) === scopeOf2(s.at) : s.kind === "mission" ? false : scopeOf2(o) === "global" || scopeOf2(o) === scopeOf2(s.at)));
|
|
55209
|
+
if (clash) return { ok: false, problem: `"${wanted}" is already the name of ${article3(KIND_WORDS3[clash.kind] ?? clash.what)} (${clash.path}, line ${clash.line}). Choose another name.` };
|
|
55210
|
+
const edits = s.references.map((o) => ({ ...loc(o), newText: cased(wanted, o.written) + (o.plural ? "s" : "") }));
|
|
55211
|
+
if (s.kind !== "mission") {
|
|
55212
|
+
const before = problems(files);
|
|
55213
|
+
const after = problems(applyRename(files, edits));
|
|
55214
|
+
for (const [p, n] of after) {
|
|
55215
|
+
if (n > (before.get(p) ?? 0)) return { ok: false, problem: `Renaming to "${wanted}" would give ${p} a problem it does not have now, so nothing was renamed. Choose another name.` };
|
|
55216
|
+
}
|
|
55217
|
+
}
|
|
55218
|
+
return { ok: true, symbol: { id: s.id, kind: s.kind, what: s.what, name: s.name }, edits };
|
|
55219
|
+
}
|
|
55220
|
+
function applyRename(files, edits) {
|
|
55221
|
+
return files.map((f) => {
|
|
55222
|
+
const mine = edits.filter((e) => e.path === f.path);
|
|
55223
|
+
if (!mine.length) return f;
|
|
55224
|
+
const lines = f.source.split("\n");
|
|
55225
|
+
for (const e of [...mine].sort((a, b) => b.line - a.line || b.col - a.col)) {
|
|
55226
|
+
const t = lines[e.line - 1];
|
|
55227
|
+
lines[e.line - 1] = t.slice(0, e.col - 1) + e.newText + t.slice(e.col - 1 + e.length);
|
|
55228
|
+
}
|
|
55229
|
+
return { ...f, source: lines.join("\n") };
|
|
55230
|
+
});
|
|
55231
|
+
}
|
|
55232
|
+
|
|
55233
|
+
// src/core/project-root.mjs
|
|
55234
|
+
var import_node_fs5 = require("node:fs");
|
|
55235
|
+
var import_node_path6 = require("node:path");
|
|
55236
|
+
var PROJECT_FILE = "thunder.toml";
|
|
55237
|
+
function findProjectRoot(start) {
|
|
55238
|
+
let dir = (0, import_node_path6.resolve)(start);
|
|
55239
|
+
if ((0, import_node_fs5.existsSync)(dir) && !(0, import_node_fs5.statSync)(dir).isDirectory()) dir = (0, import_node_path6.dirname)(dir);
|
|
55240
|
+
for (; ; ) {
|
|
55241
|
+
if ((0, import_node_fs5.existsSync)((0, import_node_path6.join)(dir, PROJECT_FILE))) return dir;
|
|
55242
|
+
const up = (0, import_node_path6.dirname)(dir);
|
|
55243
|
+
if (up === dir) return null;
|
|
55244
|
+
dir = up;
|
|
55245
|
+
}
|
|
55246
|
+
}
|
|
55247
|
+
|
|
54815
55248
|
// src/lsp.mjs
|
|
55249
|
+
var import_node_url = require("node:url");
|
|
55250
|
+
var import_node_path7 = require("node:path");
|
|
55251
|
+
var isCoreText = (uri, text2) => /\.thunder$/i.test(uri) && fileKind(text2).kind === "program";
|
|
55252
|
+
var pathOf = (uri) => {
|
|
55253
|
+
try {
|
|
55254
|
+
return (0, import_node_url.fileURLToPath)(uri);
|
|
55255
|
+
} catch {
|
|
55256
|
+
return null;
|
|
55257
|
+
}
|
|
55258
|
+
};
|
|
55259
|
+
function workspaceFor(uri, docs) {
|
|
55260
|
+
const text2 = docs.get(uri) ?? "";
|
|
55261
|
+
const file = pathOf(uri);
|
|
55262
|
+
const root = file && isCoreText(uri, text2) ? findProjectRoot(file) : null;
|
|
55263
|
+
if (!root) {
|
|
55264
|
+
const path2 = file ? (0, import_node_path7.basename)(file) : uri;
|
|
55265
|
+
return { files: [{ path: path2, source: text2 }], path: path2, uriOf: (p) => p === path2 ? uri : null };
|
|
55266
|
+
}
|
|
55267
|
+
const open = new Map([...docs].map(([u, t]) => [pathOf(u), t]).filter(([p]) => p));
|
|
55268
|
+
let files = [];
|
|
55269
|
+
try {
|
|
55270
|
+
files = coreFilesIn(root, root);
|
|
55271
|
+
} catch {
|
|
55272
|
+
files = [];
|
|
55273
|
+
}
|
|
55274
|
+
files = files.map((f) => ({ ...f, source: open.get((0, import_node_path7.join)(root, f.path)) ?? f.source }));
|
|
55275
|
+
const path = (0, import_node_path7.relative)(root, file).split(import_node_path7.sep).join("/");
|
|
55276
|
+
if (!files.some((f) => f.path === path)) files.push({ path, source: text2 });
|
|
55277
|
+
return { files, path, uriOf: (p) => (0, import_node_url.pathToFileURL)((0, import_node_path7.join)(root, p)).href };
|
|
55278
|
+
}
|
|
55279
|
+
var range = (o) => ({ start: { line: o.line - 1, character: o.col - 1 }, end: { line: o.line - 1, character: o.col - 1 + o.length } });
|
|
55280
|
+
function toCoreDiagnostic(d, lines) {
|
|
55281
|
+
const line = Math.max(0, (d.line ?? 1) - 1);
|
|
55282
|
+
const text2 = lines[line] ?? "";
|
|
55283
|
+
const start = d.hole?.col ? d.hole.col - 1 : Math.max(0, text2.length - text2.trimStart().length);
|
|
55284
|
+
return {
|
|
55285
|
+
range: { start: { line, character: start }, end: { line, character: Math.max(start + 1, text2.length) } },
|
|
55286
|
+
severity: d.severity === "warning" ? 2 : 1,
|
|
55287
|
+
code: d.code,
|
|
55288
|
+
source: "thunder",
|
|
55289
|
+
message: d.message + (d.hint ? `
|
|
55290
|
+
|
|
55291
|
+
${d.hint}` : "")
|
|
55292
|
+
};
|
|
55293
|
+
}
|
|
54816
55294
|
var COMPLETION_KIND = { keyword: 14, semantic_type: 7, field: 5, snippet: 15, value: 12, block: 14 };
|
|
54817
55295
|
var SEVERITY = { error: 1, warning: 2, info: 3 };
|
|
54818
55296
|
function anchorLine(message2, lines) {
|
|
@@ -54867,9 +55345,22 @@ function startLspServer({ readable = process.stdin, writable = process.stdout }
|
|
|
54867
55345
|
writable.write(payload);
|
|
54868
55346
|
};
|
|
54869
55347
|
const respond = (id2, result) => send({ jsonrpc: "2.0", id: id2, result });
|
|
55348
|
+
const refuse2 = (id2, message2) => send({ jsonrpc: "2.0", id: id2, error: { code: -32803, message: message2 } });
|
|
54870
55349
|
const notify = (method, params) => send({ jsonrpc: "2.0", method, params });
|
|
54871
55350
|
const publish = (uri) => {
|
|
54872
55351
|
const lines = (docs.get(uri) || "").split("\n");
|
|
55352
|
+
if (isCoreText(uri, docs.get(uri) || "")) {
|
|
55353
|
+
let diags2 = [];
|
|
55354
|
+
try {
|
|
55355
|
+
const w = workspaceFor(uri, docs);
|
|
55356
|
+
const r = symbolIndex(w.files).results.find((x) => x.path === w.path);
|
|
55357
|
+
diags2 = (r?.diagnostics ?? []).map((d) => toCoreDiagnostic(d, lines));
|
|
55358
|
+
} catch {
|
|
55359
|
+
diags2 = [];
|
|
55360
|
+
}
|
|
55361
|
+
notify("textDocument/publishDiagnostics", { uri, diagnostics: diags2 });
|
|
55362
|
+
return;
|
|
55363
|
+
}
|
|
54873
55364
|
let diags;
|
|
54874
55365
|
try {
|
|
54875
55366
|
diags = semanticDiagnostics(parseIntent(docs.get(uri) || ""));
|
|
@@ -54886,7 +55377,10 @@ function startLspServer({ readable = process.stdin, writable = process.stdout }
|
|
|
54886
55377
|
textDocumentSync: 1,
|
|
54887
55378
|
// full document sync
|
|
54888
55379
|
completionProvider: { triggerCharacters: [" "] },
|
|
54889
|
-
hoverProvider: true
|
|
55380
|
+
hoverProvider: true,
|
|
55381
|
+
definitionProvider: true,
|
|
55382
|
+
referencesProvider: true,
|
|
55383
|
+
renameProvider: { prepareProvider: true }
|
|
54890
55384
|
},
|
|
54891
55385
|
serverInfo: { name: "thunderlang-lsp", version: COMPILER_VERSION }
|
|
54892
55386
|
});
|
|
@@ -54936,6 +55430,65 @@ function startLspServer({ readable = process.stdin, writable = process.stdout }
|
|
|
54936
55430
|
respond(msg.id, hover);
|
|
54937
55431
|
break;
|
|
54938
55432
|
}
|
|
55433
|
+
case "textDocument/definition":
|
|
55434
|
+
case "textDocument/references": {
|
|
55435
|
+
const uri = msg.params.textDocument.uri;
|
|
55436
|
+
const p = msg.params.position;
|
|
55437
|
+
let out = [];
|
|
55438
|
+
try {
|
|
55439
|
+
const w = workspaceFor(uri, docs);
|
|
55440
|
+
const s = symbolAt(w.files, w.path, { line: p.line + 1, col: p.character + 1 });
|
|
55441
|
+
const list3 = !s ? [] : msg.method === "textDocument/definition" ? s.definitions : s.references.filter((o) => msg.params.context?.includeDeclaration !== false || !o.def);
|
|
55442
|
+
out = list3.map((o) => ({ uri: w.uriOf(o.path), range: range(o) })).filter((l) => l.uri);
|
|
55443
|
+
} catch {
|
|
55444
|
+
out = [];
|
|
55445
|
+
}
|
|
55446
|
+
respond(msg.id, out);
|
|
55447
|
+
break;
|
|
55448
|
+
}
|
|
55449
|
+
case "textDocument/prepareRename": {
|
|
55450
|
+
const uri = msg.params.textDocument.uri;
|
|
55451
|
+
const p = msg.params.position;
|
|
55452
|
+
try {
|
|
55453
|
+
const w = workspaceFor(uri, docs);
|
|
55454
|
+
const s = symbolAt(w.files, w.path, { line: p.line + 1, col: p.character + 1 });
|
|
55455
|
+
if (!s) {
|
|
55456
|
+
refuse2(msg.id, "There is no name here that Thunder can rename: put the cursor on a function, data type, alternative, value, or input (in a mission: a decision, rule, field, or other named block).");
|
|
55457
|
+
break;
|
|
55458
|
+
}
|
|
55459
|
+
const endpoint = s.references.find((o) => o.endpoint)?.endpoint;
|
|
55460
|
+
if (endpoint) {
|
|
55461
|
+
refuse2(msg.id, `${s.at.written} is what callers send to ${endpoint}, so renaming it here would change the API.`);
|
|
55462
|
+
break;
|
|
55463
|
+
}
|
|
55464
|
+
respond(msg.id, { range: range(s.at), placeholder: s.at.written });
|
|
55465
|
+
} catch {
|
|
55466
|
+
respond(msg.id, null);
|
|
55467
|
+
}
|
|
55468
|
+
break;
|
|
55469
|
+
}
|
|
55470
|
+
case "textDocument/rename": {
|
|
55471
|
+
const uri = msg.params.textDocument.uri;
|
|
55472
|
+
const p = msg.params.position;
|
|
55473
|
+
try {
|
|
55474
|
+
const w = workspaceFor(uri, docs);
|
|
55475
|
+
const r = renameAt(w.files, w.path, { line: p.line + 1, col: p.character + 1 }, msg.params.newName);
|
|
55476
|
+
if (!r.ok) {
|
|
55477
|
+
refuse2(msg.id, r.problem);
|
|
55478
|
+
break;
|
|
55479
|
+
}
|
|
55480
|
+
const changes = {};
|
|
55481
|
+
for (const e of r.edits) {
|
|
55482
|
+
const u = w.uriOf(e.path);
|
|
55483
|
+
if (!u) continue;
|
|
55484
|
+
(changes[u] ??= []).push({ range: range(e), newText: e.newText });
|
|
55485
|
+
}
|
|
55486
|
+
respond(msg.id, { changes });
|
|
55487
|
+
} catch (e) {
|
|
55488
|
+
refuse2(msg.id, `Thunder could not rename this: ${e.message}`);
|
|
55489
|
+
}
|
|
55490
|
+
break;
|
|
55491
|
+
}
|
|
54939
55492
|
default:
|
|
54940
55493
|
if (msg.id != null) respond(msg.id, null);
|
|
54941
55494
|
}
|
|
@@ -55327,7 +55880,7 @@ function side(files) {
|
|
|
55327
55880
|
const base2 = `${stemKey2(m.file)}#${nameKey(thingName.get(m.owner) ?? "")}#${nameKey(m.name)}`;
|
|
55328
55881
|
const nth = (seen.get(base2) || 0) + 1;
|
|
55329
55882
|
seen.set(base2, nth);
|
|
55330
|
-
const
|
|
55883
|
+
const key2 = nth > 1 ? `${base2}#${nth}` : base2;
|
|
55331
55884
|
let text2;
|
|
55332
55885
|
try {
|
|
55333
55886
|
text2 = modelText(model, m.id).split("\n").filter((l) => l.trim() && !/^\s*Author's note:/.test(l)).map(stripLine);
|
|
@@ -55338,9 +55891,9 @@ function side(files) {
|
|
|
55338
55891
|
const end2 = Math.max(m.lines[1], bodyEnd2(all, m.lines[0], m.language) ?? 0);
|
|
55339
55892
|
m.reviewLines = [m.lines[0], end2];
|
|
55340
55893
|
const lines = all.slice(m.lines[0] - 1, end2);
|
|
55341
|
-
const entry3 = { key, m, model, text: text2, sig: text2.slice(1).join("\n"), code: lines, tokens: codeTokens(lines.join("\n"), m.language) };
|
|
55894
|
+
const entry3 = { key: key2, m, model, text: text2, sig: text2.slice(1).join("\n"), code: lines, tokens: codeTokens(lines.join("\n"), m.language) };
|
|
55342
55895
|
members.push(entry3);
|
|
55343
|
-
byKey.set(
|
|
55896
|
+
byKey.set(key2, entry3);
|
|
55344
55897
|
}
|
|
55345
55898
|
return { model, sources, members, byKey };
|
|
55346
55899
|
}
|
|
@@ -55376,16 +55929,16 @@ function item3(kind, severity, subject, where, says, evidence2) {
|
|
|
55376
55929
|
}
|
|
55377
55930
|
var whereOf3 = (e, line) => ({ file: e.m.file, line: line ?? e.m.lines[0] });
|
|
55378
55931
|
var subjectOf = (e) => e.m.route ? e.m.route : `${e.m.label}${e.m.yesNo ? "?" : ""}`;
|
|
55379
|
-
function pairBy(as, bs,
|
|
55932
|
+
function pairBy(as, bs, key2) {
|
|
55380
55933
|
const left = /* @__PURE__ */ new Map();
|
|
55381
55934
|
for (const a of as) {
|
|
55382
|
-
const k =
|
|
55935
|
+
const k = key2(a);
|
|
55383
55936
|
if (!left.has(k)) left.set(k, []);
|
|
55384
55937
|
left.get(k).push(a);
|
|
55385
55938
|
}
|
|
55386
55939
|
const out = [];
|
|
55387
55940
|
for (const b of bs) {
|
|
55388
|
-
const list3 = left.get(
|
|
55941
|
+
const list3 = left.get(key2(b));
|
|
55389
55942
|
out.push([list3?.length ? list3.shift() : void 0, b]);
|
|
55390
55943
|
}
|
|
55391
55944
|
for (const list3 of left.values()) for (const a of list3) out.push([a, void 0]);
|
|
@@ -55543,7 +56096,13 @@ function compareMember(o, n, items, { extracted = false } = {}) {
|
|
|
55543
56096
|
if (o.m.rule && n.m.rule && !o.m.rule.partial && !n.m.rule.partial) {
|
|
55544
56097
|
const r = comparePlainRules(o.m.rule, n.m.rule);
|
|
55545
56098
|
if (r.same) {
|
|
55546
|
-
|
|
56099
|
+
items.push(item3(
|
|
56100
|
+
renamedOrMoved.length ? moveKind : "form",
|
|
56101
|
+
"form",
|
|
56102
|
+
subject,
|
|
56103
|
+
whereOf3(n),
|
|
56104
|
+
`${renamedOrMoved.length ? `${cap5(renamedOrMoved.join(" and "))}. ` : ""}The code changed, but the answers are the same: Tested on ${r.capped ? `the first ${r.tried} of ${r.total}` : `all ${r.tried}`} edge cases, run on both versions (not every input).`
|
|
56105
|
+
));
|
|
55547
56106
|
return "form";
|
|
55548
56107
|
}
|
|
55549
56108
|
noteMove();
|
|
@@ -55578,8 +56137,8 @@ function summaryOf(e) {
|
|
|
55578
56137
|
return parts.length ? `: ${parts.join("; ")}` : "";
|
|
55579
56138
|
}
|
|
55580
56139
|
function compareThings(A, B, items) {
|
|
55581
|
-
const
|
|
55582
|
-
let pairs2 = pairBy(A.model.things, B.model.things,
|
|
56140
|
+
const key2 = (t) => `${stemKey2(t.file)}#${nameKey(t.name)}`;
|
|
56141
|
+
let pairs2 = pairBy(A.model.things, B.model.things, key2);
|
|
55583
56142
|
const count2 = (list3) => {
|
|
55584
56143
|
const c = /* @__PURE__ */ new Map();
|
|
55585
56144
|
for (const t of list3) c.set(nameKey(t.name), (c.get(nameKey(t.name)) || 0) + 1);
|
|
@@ -55871,7 +56430,7 @@ function evidenceBlock(ev) {
|
|
|
55871
56430
|
}
|
|
55872
56431
|
function renderReview(r, { title = "Thunder review", maxChars = 6e4, footer = "" } = {}) {
|
|
55873
56432
|
const out = [REVIEW_MARKER, `### ${title}`, "", `**${r.says}**`, ""];
|
|
55874
|
-
out.push('Read from the code by the Thunder compiler, with no AI. "Only the form changed" is said only when it is shown: the code is identical apart from spacing, comments, or names it declares itself
|
|
56433
|
+
out.push('Read from the code by the Thunder compiler, with no AI. "Only the form changed" is said only when it is shown: the code is identical apart from spacing, comments, or names it declares itself. A rule whose code changed but whose answers match on every edge case tried is listed here too, marked Tested: other inputs were not tried.', "");
|
|
55875
56434
|
const alsoIn = (x) => x.also?.length ? [` <details><summary>Also in ${x.also.length} more</summary>`, "", ...x.also.slice(0, 50).map((a) => ` - **${a.subject}** \xB7 \`${a.where.file}:${a.where.line}\``), ...x.also.length > 50 ? [` - and ${x.also.length - 50} more`] : [], "", " </details>"] : [];
|
|
55876
56435
|
const line = (x) => [`- **${x.subject}** \xB7 \`${x.where.file}:${x.where.line}\`: ${x.says}`, ...evidenceBlock(x.evidence).map((l) => l ? ` ${l}` : ""), ...alsoIn(x)];
|
|
55877
56436
|
const section = (sev, head) => {
|
|
@@ -55887,7 +56446,7 @@ function renderReview(r, { title = "Thunder review", maxChars = 6e4, footer = ""
|
|
|
55887
56446
|
};
|
|
55888
56447
|
section("risk", "Needs a careful look");
|
|
55889
56448
|
section("meaning", "Changes in meaning");
|
|
55890
|
-
section("form", "Only the form changed");
|
|
56449
|
+
section("form", "Only the form changed, or the same answers where tested");
|
|
55891
56450
|
if (r.notRead.length) out.push(`Also changed, not read by Thunder: ${r.notRead.slice(0, 20).map((f) => `\`${f.path}\``).join(", ")}${r.notRead.length > 20 ? `, and ${r.notRead.length - 20} more` : ""}.`, "");
|
|
55892
56451
|
if (footer) out.push(footer, "");
|
|
55893
56452
|
let text2 = out.join("\n");
|
|
@@ -56308,7 +56867,7 @@ function ruleRegion(source, decision, index) {
|
|
|
56308
56867
|
}
|
|
56309
56868
|
var view = (it) => JSON.stringify({ kind: it.kind, name: it.name, says: it.says, thunder: it.thunder, rules: it.rules?.map((r) => [r.when, r.result]), otherwise: it.otherwise?.result, guards: it.guards?.map((g) => g.says ?? g.when) });
|
|
56310
56869
|
function writeRule({ source, language, file = "", decision: name, line = null, rule, when = null, answer = null }) {
|
|
56311
|
-
const fail3 = (...
|
|
56870
|
+
const fail3 = (...problems3) => ({ schema: WRITE_SCHEMA, ok: false, source, problems: problems3 });
|
|
56312
56871
|
if (when == null && answer == null) return fail3("Say what to change: a new condition (when) or a new answer.");
|
|
56313
56872
|
const reading = readCode(source, { language, file });
|
|
56314
56873
|
const lang = reading.language;
|
|
@@ -56372,7 +56931,7 @@ function writeRule({ source, language, file = "", decision: name, line = null, r
|
|
|
56372
56931
|
if (!real.length) return fail3("Nothing would change: the rule already reads that way.");
|
|
56373
56932
|
let next = source;
|
|
56374
56933
|
for (const e of real) next = next.slice(0, e.start) + e.text + next.slice(e.end);
|
|
56375
|
-
const
|
|
56934
|
+
const problems2 = [];
|
|
56376
56935
|
let after;
|
|
56377
56936
|
try {
|
|
56378
56937
|
after = readCode(next, { language: lang, file });
|
|
@@ -56382,23 +56941,23 @@ function writeRule({ source, language, file = "", decision: name, line = null, r
|
|
|
56382
56941
|
const d2 = findDecision(after, name, d.line);
|
|
56383
56942
|
if (!d2) return fail3(`${name} is no longer read as a decision after the change.`);
|
|
56384
56943
|
const wantResult = answer ?? target.result;
|
|
56385
|
-
if (d2.rules.length !== d.rules.length)
|
|
56944
|
+
if (d2.rules.length !== d.rules.length) problems2.push("The number of rules changed.");
|
|
56386
56945
|
d.rules.forEach((r, i) => {
|
|
56387
56946
|
const r2 = d2.rules[i];
|
|
56388
56947
|
if (!r2) return;
|
|
56389
56948
|
const w = i === index ? newWhen : normWhen(r.when);
|
|
56390
56949
|
const res = i === index ? wantResult : r.result;
|
|
56391
|
-
if (normWhen(r2.when) !== w)
|
|
56392
|
-
if (r2.result !== res)
|
|
56950
|
+
if (normWhen(r2.when) !== w) problems2.push(`Rule ${i + 1} reads "${sayCondition(r2.when)}" after the change, not "${sayCondition(w)}".`);
|
|
56951
|
+
if (r2.result !== res) problems2.push(`Rule ${i + 1} answers ${r2.result} after the change, not ${res}.`);
|
|
56393
56952
|
});
|
|
56394
56953
|
const wantOtherwise = index === "otherwise" ? wantResult : d.otherwise.result;
|
|
56395
|
-
if (d2.otherwise?.result !== wantOtherwise)
|
|
56954
|
+
if (d2.otherwise?.result !== wantOtherwise) problems2.push(`The fallback answers ${d2.otherwise?.result} after the change, not ${wantOtherwise}.`);
|
|
56396
56955
|
const others = reading.items.filter((i) => i !== d), others2 = after.items.filter((i) => i !== d2);
|
|
56397
|
-
if (others.length !== others2.length)
|
|
56956
|
+
if (others.length !== others2.length) problems2.push("Another part of the file reads differently after the change.");
|
|
56398
56957
|
else others.forEach((o, i) => {
|
|
56399
|
-
if (view(o) !== view(others2[i]))
|
|
56958
|
+
if (view(o) !== view(others2[i])) problems2.push(`${o.name} (line ${o.line}) reads differently after the change.`);
|
|
56400
56959
|
});
|
|
56401
|
-
if (
|
|
56960
|
+
if (problems2.length) return fail3(...problems2);
|
|
56402
56961
|
const starts = lineStartsOf(source);
|
|
56403
56962
|
const lineOf7 = (off) => {
|
|
56404
56963
|
let lo = 0, hi = starts.length - 1;
|
|
@@ -56601,10 +57160,148 @@ function examplesOf(source, { file = "main.thunder", kind = null } = {}) {
|
|
|
56601
57160
|
return { schema: EXAMPLES_SCHEMA, kind: k, ...r };
|
|
56602
57161
|
}
|
|
56603
57162
|
|
|
57163
|
+
// src/template.mjs
|
|
57164
|
+
var TEMPLATE_SCHEMA = "thunder-template-v1";
|
|
57165
|
+
var ATOMIC = {
|
|
57166
|
+
number: { input: "number", type: { k: "number" }, text: "number" },
|
|
57167
|
+
"whole number": { input: "count", type: { k: "whole" }, text: "whole number" },
|
|
57168
|
+
text: { input: "text", type: { k: "text" }, text: "text" },
|
|
57169
|
+
money: { input: "amount", type: { k: "money" }, text: "money" },
|
|
57170
|
+
"yes/no": { input: "answer", type: { k: "bool" }, text: "yes/no" },
|
|
57171
|
+
date: { input: "date", type: { k: "date" }, text: "date" }
|
|
57172
|
+
};
|
|
57173
|
+
var key = (s) => String(s ?? "").trim().toLowerCase().replace(/\s+/g, " ").replace(/^(?:a|an|the)\s+/, "");
|
|
57174
|
+
function kindText(t, textOf5) {
|
|
57175
|
+
const name = (x) => x?.k === "record" ? { ...x, text: textOf5.get(x.name) ?? x.text } : x?.of ? { ...x, of: name(x.of) } : x;
|
|
57176
|
+
return typeWords4(name(t)).replace(/^an? /, "");
|
|
57177
|
+
}
|
|
57178
|
+
function recursion(type, self) {
|
|
57179
|
+
const t = type?.k === "optional" ? type.of : type;
|
|
57180
|
+
if (t?.k === "record" && t.name === self) return "self";
|
|
57181
|
+
if (t?.k === "list" && t.of?.k === "record" && t.of.name === self) return "list of self";
|
|
57182
|
+
return null;
|
|
57183
|
+
}
|
|
57184
|
+
function related(type, self, out) {
|
|
57185
|
+
const t = type?.k === "optional" ? type.of : type;
|
|
57186
|
+
if (t?.k === "record" && t.name !== self) out.add(t.text ?? t.name);
|
|
57187
|
+
if ((t?.k === "list" || t?.k === "optional") && t.of) related(t.of, self, out);
|
|
57188
|
+
}
|
|
57189
|
+
function singular5(list3, taken) {
|
|
57190
|
+
const last = list3.split(" ").pop();
|
|
57191
|
+
const one = last === "children" ? "child" : /(?:ches|shes|xes|sses)$/.test(last) ? last.slice(0, -2) : /[^s]s$/.test(last) ? last.slice(0, -1) : null;
|
|
57192
|
+
const name = one ? list3.replace(/\S+$/, one) : `${list3} item`;
|
|
57193
|
+
return taken.includes(name) ? `${list3} item` : name;
|
|
57194
|
+
}
|
|
57195
|
+
function caseLines(fields, { input, fn, hole, prefix, indent }) {
|
|
57196
|
+
const lines = [];
|
|
57197
|
+
const recursive = [];
|
|
57198
|
+
const out = fields.map((f) => {
|
|
57199
|
+
const local = prefix ? `${input} ${f.name}` : f.name;
|
|
57200
|
+
lines.push(`${indent}Set ${local} to ${input}'s ${f.name}`);
|
|
57201
|
+
const r = recursion(f.type, fn.self);
|
|
57202
|
+
if (r) recursive.push({ local, r });
|
|
57203
|
+
return { name: f.name, kind: kindText(f.type, fn.textOf), local, recursion: r };
|
|
57204
|
+
});
|
|
57205
|
+
for (const { local, r } of recursive) {
|
|
57206
|
+
if (r === "self") lines.push(`${indent}Set ${local} result to ${fn.name} with ${local}`);
|
|
57207
|
+
else {
|
|
57208
|
+
const item4 = singular5(local, out.map((x) => x.local));
|
|
57209
|
+
lines.push(`${indent}For each ${item4} in ${local}:`, `${indent} Set ${item4} result to ${fn.name} with ${item4}`);
|
|
57210
|
+
}
|
|
57211
|
+
}
|
|
57212
|
+
lines.push(`${indent}Give ${hole}`);
|
|
57213
|
+
return { lines, fields: out };
|
|
57214
|
+
}
|
|
57215
|
+
function build(def, opts, prefix) {
|
|
57216
|
+
const { fnName, hole, textOf: textOf5 } = opts;
|
|
57217
|
+
const fn = { name: fnName, self: def.name, textOf: textOf5 };
|
|
57218
|
+
const head = [`To ${fnName}:`, ` Receive ${def.input} as ${def.text}`];
|
|
57219
|
+
const cases = [];
|
|
57220
|
+
if (def.form === "atomic") {
|
|
57221
|
+
cases.push({ alternative: null, fields: [] });
|
|
57222
|
+
return { text: [...head, ` Give ${hole}`].join("\n") + "\n", cases };
|
|
57223
|
+
}
|
|
57224
|
+
if (def.form === "compound") {
|
|
57225
|
+
const c = caseLines(def.fields, { input: def.input, fn, hole, prefix, indent: " " });
|
|
57226
|
+
cases.push({ alternative: null, fields: c.fields });
|
|
57227
|
+
return { text: [...head, ...c.lines].join("\n") + "\n", cases };
|
|
57228
|
+
}
|
|
57229
|
+
const body2 = [` Depending on ${def.input}:`];
|
|
57230
|
+
for (const a of def.alts) {
|
|
57231
|
+
const c = caseLines(a.fields, { input: def.input, fn, hole, prefix, indent: " " });
|
|
57232
|
+
body2.push(` ${a.text}:`, ...c.lines);
|
|
57233
|
+
cases.push({ alternative: a.text, fields: c.fields });
|
|
57234
|
+
}
|
|
57235
|
+
return { text: [...head, ...body2].join("\n") + "\n", cases };
|
|
57236
|
+
}
|
|
57237
|
+
function check(source, text2, file) {
|
|
57238
|
+
const base2 = source.trim() ? `${source.replace(/\s+$/, "")}
|
|
57239
|
+
|
|
57240
|
+
` : "";
|
|
57241
|
+
const offset = base2 ? base2.split("\n").length - 1 : 0;
|
|
57242
|
+
const r = compileCore(base2 + text2, { file });
|
|
57243
|
+
const mine = (r.diagnostics ?? []).filter((d) => d.line > offset && d.severity !== "warning");
|
|
57244
|
+
const holes = mine.filter((d) => d.code === "TC120").length;
|
|
57245
|
+
const problems2 = mine.filter((d) => d.code !== "TC120").map((d) => ({ line: d.line - offset, code: d.code, message: d.message }));
|
|
57246
|
+
return { draft: problems2.length === 0, holes, problems: problems2 };
|
|
57247
|
+
}
|
|
57248
|
+
function templateOf(source, type, { name = null, gives = null, file = "main.thunder" } = {}) {
|
|
57249
|
+
const src = String(source ?? "");
|
|
57250
|
+
const want = key(type);
|
|
57251
|
+
const fail3 = (problem, known4 = []) => ({ schema: TEMPLATE_SCHEMA, ok: false, problem, known: known4 });
|
|
57252
|
+
if (!want) return fail3("Say which data type to write a template for, for example: Payment.");
|
|
57253
|
+
if (src.trim() && fileKind(src).kind === "mission") return fail3("Templates are for Thunder Core programs; this file is a mission.");
|
|
57254
|
+
const records = (parseCore(src, { file }).body ?? []).filter((s) => s.k === "record");
|
|
57255
|
+
const known3 = [...records.map((r) => r.text), ...Object.values(ATOMIC).map((a) => a.text)];
|
|
57256
|
+
let def;
|
|
57257
|
+
if (ATOMIC[want]) {
|
|
57258
|
+
const a = ATOMIC[want];
|
|
57259
|
+
def = { form: "atomic", name: want, text: a.text, input: a.input, recursive: false };
|
|
57260
|
+
} else {
|
|
57261
|
+
const rec2 = records.find((r) => r.name === want) ?? records.find((r) => r.name === want.replace(/s$/, ""));
|
|
57262
|
+
if (!rec2) {
|
|
57263
|
+
const names = records.map((r) => r.text);
|
|
57264
|
+
return fail3(names.length ? `There is no data type "${type}" in this file. Its data types are ${names.join(", ")}; the atomic kinds are ${Object.keys(ATOMIC).join(", ")}.` : `There is no data type "${type}" in this file. Define one first ("A ${type} has:" or "A ${type} is one of:"), or use an atomic kind: ${Object.keys(ATOMIC).join(", ")}.`, known3);
|
|
57265
|
+
}
|
|
57266
|
+
const fields = (rec2.fields ?? []).filter((f) => !f.hidden);
|
|
57267
|
+
def = rec2.alts ? { form: "alternatives", name: rec2.name, text: rec2.text, input: rec2.name, alts: rec2.alts } : { form: "compound", name: rec2.name, text: rec2.text, input: rec2.name, fields };
|
|
57268
|
+
def.recursive = (rec2.alts ? rec2.alts.flatMap((a) => a.fields) : fields).some((f) => recursion(f.type, rec2.name));
|
|
57269
|
+
}
|
|
57270
|
+
const fnName = key(name) || `handle ${def.input}`;
|
|
57271
|
+
const givesKey = gives == null ? null : String(gives).trim();
|
|
57272
|
+
const textOf5 = new Map(records.map((r) => [r.name, r.text]));
|
|
57273
|
+
const opts = { fnName, hole: givesKey ? `?${givesKey}` : "?", textOf: textOf5 };
|
|
57274
|
+
const allFields = def.form === "alternatives" ? def.alts.flatMap((a) => a.fields) : def.fields ?? [];
|
|
57275
|
+
let prefix = allFields.some((f) => f.name === def.input || f.name === fnName);
|
|
57276
|
+
let out = build(def, opts, prefix);
|
|
57277
|
+
let checked = check(src, out.text, file);
|
|
57278
|
+
if (!checked.draft && !prefix && allFields.length) {
|
|
57279
|
+
const again = build(def, opts, true);
|
|
57280
|
+
const c = check(src, again.text, file);
|
|
57281
|
+
if (c.draft) {
|
|
57282
|
+
prefix = true;
|
|
57283
|
+
out = again;
|
|
57284
|
+
checked = c;
|
|
57285
|
+
}
|
|
57286
|
+
}
|
|
57287
|
+
const rel2 = /* @__PURE__ */ new Set();
|
|
57288
|
+
for (const f of allFields) related(f.type, def.name, rel2);
|
|
57289
|
+
return {
|
|
57290
|
+
schema: TEMPLATE_SCHEMA,
|
|
57291
|
+
ok: true,
|
|
57292
|
+
type: { name: def.name, text: def.text, form: def.form, recursive: def.recursive },
|
|
57293
|
+
function: { name: fnName, input: def.input, gives: givesKey },
|
|
57294
|
+
cases: out.cases,
|
|
57295
|
+
related: [...rel2].map((n) => textOf5.get(n) ?? n).sort(),
|
|
57296
|
+
text: out.text,
|
|
57297
|
+
check: checked
|
|
57298
|
+
};
|
|
57299
|
+
}
|
|
57300
|
+
|
|
56604
57301
|
// src/passport-fs.mjs
|
|
56605
57302
|
var import_node_child_process5 = require("node:child_process");
|
|
56606
|
-
var
|
|
56607
|
-
var
|
|
57303
|
+
var import_node_fs6 = require("node:fs");
|
|
57304
|
+
var import_node_path8 = require("node:path");
|
|
56608
57305
|
|
|
56609
57306
|
// src/passport.mjs
|
|
56610
57307
|
var PASSPORT_SCHEMA = "thunder-passport-v1";
|
|
@@ -56876,16 +57573,16 @@ function packagesIn2(root) {
|
|
|
56876
57573
|
if (depth > 4) return;
|
|
56877
57574
|
let names = [];
|
|
56878
57575
|
try {
|
|
56879
|
-
names = (0,
|
|
57576
|
+
names = (0, import_node_fs6.readdirSync)(dir).sort();
|
|
56880
57577
|
} catch {
|
|
56881
57578
|
return;
|
|
56882
57579
|
}
|
|
56883
57580
|
for (const n of names) {
|
|
56884
57581
|
if (SKIP3.has(n)) continue;
|
|
56885
|
-
const full = (0,
|
|
57582
|
+
const full = (0, import_node_path8.join)(dir, n);
|
|
56886
57583
|
let st;
|
|
56887
57584
|
try {
|
|
56888
|
-
st = (0,
|
|
57585
|
+
st = (0, import_node_fs6.statSync)(full);
|
|
56889
57586
|
} catch {
|
|
56890
57587
|
continue;
|
|
56891
57588
|
}
|
|
@@ -56893,18 +57590,18 @@ function packagesIn2(root) {
|
|
|
56893
57590
|
walk(full, depth + 1);
|
|
56894
57591
|
continue;
|
|
56895
57592
|
}
|
|
56896
|
-
const rel2 = (0,
|
|
57593
|
+
const rel2 = (0, import_node_path8.relative)(root, full).split("\\").join("/");
|
|
56897
57594
|
try {
|
|
56898
57595
|
if (n === "package.json") {
|
|
56899
|
-
const j = JSON.parse((0,
|
|
57596
|
+
const j = JSON.parse((0, import_node_fs6.readFileSync)(full, "utf8"));
|
|
56900
57597
|
for (const k of ["dependencies", "devDependencies"]) for (const [name, version] of Object.entries(j[k] ?? {})) out.push({ name, version: String(version), from: rel2, ...k === "devDependencies" ? { dev: true } : {} });
|
|
56901
57598
|
} else if (n === "requirements.txt") {
|
|
56902
|
-
for (const line of (0,
|
|
57599
|
+
for (const line of (0, import_node_fs6.readFileSync)(full, "utf8").split("\n")) {
|
|
56903
57600
|
const m = line.replace(/#.*/, "").trim().match(/^([A-Za-z0-9_.-]+)\s*(.*)$/);
|
|
56904
57601
|
if (m) out.push({ name: m[1], ...m[2] ? { version: m[2] } : {}, from: rel2 });
|
|
56905
57602
|
}
|
|
56906
57603
|
} else if (/\.csproj$/.test(n)) {
|
|
56907
|
-
for (const m of (0,
|
|
57604
|
+
for (const m of (0, import_node_fs6.readFileSync)(full, "utf8").matchAll(/<PackageReference\s+Include="([^"]+)"(?:\s+Version="([^"]+)")?/g)) out.push({ name: m[1], ...m[2] ? { version: m[2] } : {}, from: rel2 });
|
|
56908
57605
|
}
|
|
56909
57606
|
} catch {
|
|
56910
57607
|
}
|
|
@@ -56961,14 +57658,14 @@ function buildPassport({ parts, base: base2 = null, head = null, run = [], purpo
|
|
|
56961
57658
|
if (!parts?.length) throw new Error("name at least one folder to describe.");
|
|
56962
57659
|
const names = /* @__PURE__ */ new Set();
|
|
56963
57660
|
const read = parts.map((dir) => {
|
|
56964
|
-
const root = (0,
|
|
57661
|
+
const root = (0, import_node_path8.resolve)(dir);
|
|
56965
57662
|
let ok = false;
|
|
56966
57663
|
try {
|
|
56967
|
-
ok = (0,
|
|
57664
|
+
ok = (0, import_node_fs6.statSync)(root).isDirectory();
|
|
56968
57665
|
} catch {
|
|
56969
57666
|
}
|
|
56970
57667
|
if (!ok) throw new Error(`${dir} is not a folder.`);
|
|
56971
|
-
const name = (0,
|
|
57668
|
+
const name = (0, import_node_path8.basename)(root);
|
|
56972
57669
|
if (names.has(name)) throw new Error(`two parts are called "${name}"; give folders with different names.`);
|
|
56973
57670
|
names.add(name);
|
|
56974
57671
|
const top = git3(root, ["rev-parse", "--show-toplevel"])?.trim() ?? null;
|
|
@@ -56986,7 +57683,7 @@ function buildPassport({ parts, base: base2 = null, head = null, run = [], purpo
|
|
|
56986
57683
|
changes = changesSince(root, base2);
|
|
56987
57684
|
}
|
|
56988
57685
|
const files = collectReadableFiles(root).map((f) => ({ path: f.path, source: f.source }));
|
|
56989
|
-
return { name, root, path: (0,
|
|
57686
|
+
return { name, root, path: (0, import_node_path8.relative)(relativeTo, root).split("\\").join("/") || ".", sha, dirty, files, packages: packagesIn2(root), ...changes ? { changes } : {} };
|
|
56990
57687
|
});
|
|
56991
57688
|
const runs = run.map((spec) => {
|
|
56992
57689
|
const m = String(spec).match(/^([A-Za-z0-9_.-]+):\s+(.+)$/);
|
|
@@ -56998,7 +57695,7 @@ function buildPassport({ parts, base: base2 = null, head = null, run = [], purpo
|
|
|
56998
57695
|
const output = `${r.stdout ?? ""}${r.error ? `
|
|
56999
57696
|
(${r.error.message})` : ""}${r.signal ? `
|
|
57000
57697
|
(stopped by ${r.signal})` : ""}`;
|
|
57001
|
-
return { command, part, cwd: (0,
|
|
57698
|
+
return { command, part, cwd: (0, import_node_path8.relative)(relativeTo, cwd).split("\\").join("/") || ".", exitCode, output };
|
|
57002
57699
|
});
|
|
57003
57700
|
const extra = [];
|
|
57004
57701
|
const partOf = (file) => {
|
|
@@ -57021,14 +57718,14 @@ function buildPassport({ parts, base: base2 = null, head = null, run = [], purpo
|
|
|
57021
57718
|
return assemblePassport({ parts: read, change, runs, purpose, extra, builtAt, thunder: COMPILER_VERSION });
|
|
57022
57719
|
}
|
|
57023
57720
|
function checkPassportOnDisk(passport, { baseDir = process.cwd(), dirs = {} } = {}) {
|
|
57024
|
-
const where = new Map(passport.subject.parts.map((p) => [p.name, dirs[p.name] ? (0,
|
|
57721
|
+
const where = new Map(passport.subject.parts.map((p) => [p.name, dirs[p.name] ? (0, import_node_path8.resolve)(dirs[p.name]) : (0, import_node_path8.resolve)(baseDir, p.path)]));
|
|
57025
57722
|
return checkPassport(passport, {
|
|
57026
57723
|
read: (part, file) => {
|
|
57027
57724
|
const root = where.get(part);
|
|
57028
57725
|
if (!root) return null;
|
|
57029
|
-
const full = (0,
|
|
57726
|
+
const full = (0, import_node_path8.join)(root, file);
|
|
57030
57727
|
try {
|
|
57031
|
-
return (0,
|
|
57728
|
+
return (0, import_node_fs6.existsSync)(full) ? (0, import_node_fs6.readFileSync)(full, "utf8") : null;
|
|
57032
57729
|
} catch {
|
|
57033
57730
|
return null;
|
|
57034
57731
|
}
|
|
@@ -57047,6 +57744,7 @@ function checkPassportOnDisk(passport, { baseDir = process.cwd(), dirs = {} } =
|
|
|
57047
57744
|
BLOCKABLE_PHASES,
|
|
57048
57745
|
BRAND_PATHS,
|
|
57049
57746
|
CHANGES_SCHEMA,
|
|
57747
|
+
CLAIM_STATUS,
|
|
57050
57748
|
CLAIM_STATUSES,
|
|
57051
57749
|
CLASSIFICATIONS,
|
|
57052
57750
|
CODEGEN_SCHEMA,
|
|
@@ -57066,6 +57764,8 @@ function checkPassportOnDisk(passport, { baseDir = process.cwd(), dirs = {} } =
|
|
|
57066
57764
|
ENTRY_TYPES,
|
|
57067
57765
|
ERROR_KINDS,
|
|
57068
57766
|
EVENT_LOG_SCHEMA,
|
|
57767
|
+
EVIDENCE_LEVELS,
|
|
57768
|
+
EVIDENCE_WORDS,
|
|
57069
57769
|
EXAMPLES_SCHEMA,
|
|
57070
57770
|
EXPORT_FORMATS,
|
|
57071
57771
|
EXPR_SCHEMA,
|
|
@@ -57147,6 +57847,7 @@ function checkPassportOnDisk(passport, { baseDir = process.cwd(), dirs = {} } =
|
|
|
57147
57847
|
STYLE_SCHEMA,
|
|
57148
57848
|
SUPPORTED_LANGUAGES,
|
|
57149
57849
|
SYNC_SCHEMA,
|
|
57850
|
+
TEMPLATE_SCHEMA,
|
|
57150
57851
|
TEST_SCHEMA,
|
|
57151
57852
|
THUNDER_TEXT_EXT,
|
|
57152
57853
|
THUNDER_VISUAL,
|
|
@@ -57171,6 +57872,7 @@ function checkPassportOnDisk(passport, { baseDir = process.cwd(), dirs = {} } =
|
|
|
57171
57872
|
analyzePrivacy,
|
|
57172
57873
|
analyzeStyle,
|
|
57173
57874
|
applyEdits,
|
|
57875
|
+
applyRename,
|
|
57174
57876
|
applyWaivers,
|
|
57175
57877
|
approvalFor,
|
|
57176
57878
|
approvalsFor,
|
|
@@ -57202,8 +57904,10 @@ function checkPassportOnDisk(passport, { baseDir = process.cwd(), dirs = {} } =
|
|
|
57202
57904
|
checkDrift,
|
|
57203
57905
|
checkPassport,
|
|
57204
57906
|
checkPassportOnDisk,
|
|
57907
|
+
claimStatus,
|
|
57205
57908
|
classify,
|
|
57206
57909
|
collectReadableFiles,
|
|
57910
|
+
combineEvidence,
|
|
57207
57911
|
compileExpr,
|
|
57208
57912
|
compileGuard,
|
|
57209
57913
|
compileSource,
|
|
@@ -57218,6 +57922,7 @@ function checkPassportOnDisk(passport, { baseDir = process.cwd(), dirs = {} } =
|
|
|
57218
57922
|
coreServiceFacts,
|
|
57219
57923
|
correctionsFor,
|
|
57220
57924
|
coverageView,
|
|
57925
|
+
definitionsAt,
|
|
57221
57926
|
describeEdit,
|
|
57222
57927
|
detailOf,
|
|
57223
57928
|
detectConflicts,
|
|
@@ -57236,6 +57941,8 @@ function checkPassportOnDisk(passport, { baseDir = process.cwd(), dirs = {} } =
|
|
|
57236
57941
|
evaluateOutcomes,
|
|
57237
57942
|
eventsFor,
|
|
57238
57943
|
eventsOfType,
|
|
57944
|
+
evidenceMeaning,
|
|
57945
|
+
evidenceWord,
|
|
57239
57946
|
examplesOf,
|
|
57240
57947
|
expandNode,
|
|
57241
57948
|
explain,
|
|
@@ -57324,7 +58031,9 @@ function checkPassportOnDisk(passport, { baseDir = process.cwd(), dirs = {} } =
|
|
|
57324
58031
|
recordRejection,
|
|
57325
58032
|
recordRiskAcceptance,
|
|
57326
58033
|
recordVerification,
|
|
58034
|
+
referencesAt,
|
|
57327
58035
|
regionMetrics,
|
|
58036
|
+
renameAt,
|
|
57328
58037
|
renameNodeType,
|
|
57329
58038
|
renameRelationshipType,
|
|
57330
58039
|
renderLensDoc,
|
|
@@ -57375,6 +58084,8 @@ function checkPassportOnDisk(passport, { baseDir = process.cwd(), dirs = {} } =
|
|
|
57375
58084
|
stepRoundTrip,
|
|
57376
58085
|
styleDiagnostics,
|
|
57377
58086
|
subjectName,
|
|
58087
|
+
symbolAt,
|
|
58088
|
+
templateOf,
|
|
57378
58089
|
thunderReview,
|
|
57379
58090
|
thunderText,
|
|
57380
58091
|
thunderWrite,
|