@skillstech/thunderlang 1.4.3 → 1.5.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/dist/index.cjs CHANGED
@@ -2585,7 +2585,7 @@ function notesSummary(ast) {
2585
2585
  byLens
2586
2586
  };
2587
2587
  }
2588
- var COMPILER_VERSION = "1.4.3";
2588
+ var COMPILER_VERSION = "1.5.0";
2589
2589
  var PROOF_SCHEMA_VERSION = "0.1.0";
2590
2590
  var SOURCE_PRODUCT = "skillstech-compiler";
2591
2591
  function buildContractGraph(ast, generatedAt) {
@@ -16786,11 +16786,11 @@ function jsxChildren(src, j, tag) {
16786
16786
  }
16787
16787
  var VOID = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"]);
16788
16788
  function parseTemplate(html, fileSrc = null, offset = 0) {
16789
- const lineOf6 = (i2) => fileSrc ? lineAt(fileSrc, offset + i2) : lineAt(html, i2);
16789
+ const lineOf7 = (i2) => fileSrc ? lineAt(fileSrc, offset + i2) : lineAt(html, i2);
16790
16790
  let i = 0;
16791
16791
  const parseNodes = (stopTag, stopBrace) => {
16792
16792
  const out = [];
16793
- let text2 = "", tl = lineOf6(i);
16793
+ let text2 = "", tl = lineOf7(i);
16794
16794
  const flush = () => {
16795
16795
  if (text2.trim()) out.push(textNode(text2, tl));
16796
16796
  text2 = "";
@@ -16817,17 +16817,17 @@ function parseTemplate(html, fileSrc = null, offset = 0) {
16817
16817
  flush();
16818
16818
  const b = parseBlock();
16819
16819
  if (b) out.push(b);
16820
- tl = lineOf6(i);
16820
+ tl = lineOf7(i);
16821
16821
  continue;
16822
16822
  }
16823
16823
  if (html[i] === "<" && /[A-Za-z]/.test(html[i + 1] ?? "")) {
16824
16824
  flush();
16825
16825
  const el = parseElement();
16826
16826
  if (el) out.push(el);
16827
- tl = lineOf6(i);
16827
+ tl = lineOf7(i);
16828
16828
  continue;
16829
16829
  }
16830
- if (!text2) tl = lineOf6(i);
16830
+ if (!text2) tl = lineOf7(i);
16831
16831
  text2 += html[i];
16832
16832
  i++;
16833
16833
  }
@@ -16846,7 +16846,7 @@ function parseTemplate(html, fileSrc = null, offset = 0) {
16846
16846
  return { type: "text", parts, line };
16847
16847
  };
16848
16848
  const parseElement = () => {
16849
- const line = lineOf6(i);
16849
+ const line = lineOf7(i);
16850
16850
  const tm = /^<([A-Za-z][\w:-]*)/.exec(html.slice(i));
16851
16851
  const tag = tm[1];
16852
16852
  i += tm[0].length;
@@ -16892,7 +16892,7 @@ function parseTemplate(html, fileSrc = null, offset = 0) {
16892
16892
  return { type: "el", tag, attrs, kids: kids2, line };
16893
16893
  };
16894
16894
  const parseBlock = () => {
16895
- const line = lineOf6(i);
16895
+ const line = lineOf7(i);
16896
16896
  const m = /^@(\w+)\s*(?:\(([^)]*(?:\([^)]*\)[^)]*)*)\))?\s*\{/.exec(html.slice(i));
16897
16897
  if (!m) {
16898
16898
  const e = html.indexOf("\n", i);
@@ -18042,8 +18042,8 @@ function exactText(inner, code3) {
18042
18042
  function exactIn(inner, code3, open) {
18043
18043
  if (!/«|…/.test(inner) && inner.length && [`'${inner}'`, `"${inner}"`, `\`${inner}\``].some((q2) => String(code3).includes(q2))) return true;
18044
18044
  if (!/«|…/.test(inner) && inner.trim().length) {
18045
- const esc3 = inner.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
18046
- if (new RegExp(`(?:^|[\\s#%/:+=(\\-{"'])${esc3}(?=$|[\\s}/)"';|])`).test(String(code3))) return true;
18045
+ const esc4 = inner.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
18046
+ if (new RegExp(`(?:^|[\\s#%/:+=(\\-{"'])${esc4}(?=$|[\\s}/)"';|])`).test(String(code3))) return true;
18047
18047
  }
18048
18048
  const cut = /…$/.test(inner);
18049
18049
  const w = textSkeleton(inner.replace(/…$/, ""), true);
@@ -18059,10 +18059,10 @@ function exactIn(inner, code3, open) {
18059
18059
  for (let i = 0; i < parts.length; i++) {
18060
18060
  const f = parts[i].trim();
18061
18061
  if (!f) continue;
18062
- const esc3 = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
18062
+ const esc4 = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
18063
18063
  const lead = i === 0 ? B : "[\"'`\\s,|]";
18064
18064
  const tail = i === parts.length - 1 ? cut ? "" : E : "[\"'`\\s,]";
18065
- const src = `${lead}${esc3}${tail ? `(?=${tail})` : ""}`;
18065
+ const src = `${lead}${esc4}${tail ? `(?=${tail})` : ""}`;
18066
18066
  let re = FRAG_RE.get(src);
18067
18067
  if (!re) {
18068
18068
  if (FRAG_RE.size > 5e3) FRAG_RE.clear();
@@ -19402,10 +19402,10 @@ function lexSql(src, from = 0, to = src.length, dialect = "pg") {
19402
19402
  }
19403
19403
  const pre = /[EeNnBbXx]/.test(c) && src[i + 1] === "'" && !/[\w$]/.test(src[i - 1] || "");
19404
19404
  if (c === "'" || pre) {
19405
- const esc3 = dialect === "mysql" || pre && /[Ee]/.test(c);
19405
+ const esc4 = dialect === "mysql" || pre && /[Ee]/.test(c);
19406
19406
  let j = i + (pre ? 2 : 1);
19407
19407
  for (; j < to; j++) {
19408
- if (esc3 && src[j] === "\\") {
19408
+ if (esc4 && src[j] === "\\") {
19409
19409
  j++;
19410
19410
  continue;
19411
19411
  }
@@ -19947,12 +19947,12 @@ function bodySteps(toks, ctx, opts = {}) {
19947
19947
  const n = toks.length;
19948
19948
  const labels = [];
19949
19949
  const peek = (k = 0) => toks[i + k];
19950
- const lineOf6 = (tok) => ctx.lineAt(tok.s);
19951
- const baseOf2 = (a, b) => ({ line: lineOf6(toks[a]), span: { startLine: lineOf6(toks[a]), endLine: lineOf6(toks[Math.max(a, b - 1)]) } });
19950
+ const lineOf7 = (tok) => ctx.lineAt(tok.s);
19951
+ const baseOf2 = (a, b) => ({ line: lineOf7(toks[a]), span: { startLine: lineOf7(toks[a]), endLine: lineOf7(toks[Math.max(a, b - 1)]) } });
19952
19952
  const textOf4 = (a, b) => ctx.src.slice(toks[a].s, toks[b - 1].e);
19953
19953
  const semi = ctx.dialect !== "tsql";
19954
19954
  const expect = (cond, what) => {
19955
- if (!cond) throw new Unmatched(`${what} (line ${peek() ? lineOf6(peek()) : "end"})`);
19955
+ if (!cond) throw new Unmatched(`${what} (line ${peek() ? lineOf7(peek()) : "end"})`);
19956
19956
  };
19957
19957
  const skipSemis = () => {
19958
19958
  while (isP(peek(), ";")) i++;
@@ -20148,19 +20148,19 @@ function bodySteps(toks, ctx, opts = {}) {
20148
20148
  const [c0, c1] = condUntil((x) => isW(x, "THEN"));
20149
20149
  i++;
20150
20150
  const step2 = branch(c0, c1, block(endsWith("ELSIF", "ELSEIF", "ELSE", "END")));
20151
- step2.line = lineOf6(toks[a]);
20151
+ step2.line = lineOf7(toks[a]);
20152
20152
  let tail = step2;
20153
20153
  while (isW(peek(), "ELSIF", "ELSEIF")) {
20154
20154
  const at2 = i;
20155
20155
  i++;
20156
20156
  const [e0, e1] = condUntil((x) => isW(x, "THEN"));
20157
20157
  i++;
20158
- const next = branch(e0, e1, block(endsWith("ELSIF", "ELSEIF", "ELSE", "END")), null, lineOf6(toks[at2]));
20158
+ const next = branch(e0, e1, block(endsWith("ELSIF", "ELSEIF", "ELSE", "END")), null, lineOf7(toks[at2]));
20159
20159
  tail.otherwise = [next];
20160
20160
  tail = next;
20161
20161
  }
20162
20162
  if (isW(peek(), "ELSE")) {
20163
- tail.otherwiseLine = lineOf6(peek());
20163
+ tail.otherwiseLine = lineOf7(peek());
20164
20164
  i++;
20165
20165
  tail.otherwise = block(endsWith("END"));
20166
20166
  }
@@ -20173,9 +20173,9 @@ function bodySteps(toks, ctx, opts = {}) {
20173
20173
  const kids2 = tsqlBody();
20174
20174
  skipSemis();
20175
20175
  const step2 = branch(c0, c1, kids2);
20176
- step2.line = lineOf6(toks[a]);
20176
+ step2.line = lineOf7(toks[a]);
20177
20177
  if (isW(peek(), "ELSE")) {
20178
- step2.otherwiseLine = lineOf6(peek());
20178
+ step2.otherwiseLine = lineOf7(peek());
20179
20179
  i++;
20180
20180
  step2.otherwise = tsqlBody();
20181
20181
  }
@@ -20199,7 +20199,7 @@ function bodySteps(toks, ctx, opts = {}) {
20199
20199
  expect(arms.length, "CASE without WHEN");
20200
20200
  let elseKids = null, elseLine = null;
20201
20201
  if (isW(peek(), "ELSE")) {
20202
- elseLine = lineOf6(peek());
20202
+ elseLine = lineOf7(peek());
20203
20203
  i++;
20204
20204
  elseKids = block(endsWith("END"));
20205
20205
  }
@@ -20212,14 +20212,14 @@ function bodySteps(toks, ctx, opts = {}) {
20212
20212
  text2 = vals.length === 1 ? `${subj} = ${vals[0]}` : `${subj} IN (${vals.join(", ")})`;
20213
20213
  } else text2 = code2(textOf4(arm.w0, arm.w1));
20214
20214
  const w = condWords(text2, ctx);
20215
- return { kind: "branch", says: `If ${w ?? asCodeWords(text2, 400)}`, code: text2, cond: text2, line: lineOf6(toks[arm.at]), span: { startLine: lineOf6(toks[arm.at]), endLine: lineOf6(toks[arm.w1 - 1]) }, children: arm.kids };
20215
+ return { kind: "branch", says: `If ${w ?? asCodeWords(text2, 400)}`, code: text2, cond: text2, line: lineOf7(toks[arm.at]), span: { startLine: lineOf7(toks[arm.at]), endLine: lineOf7(toks[arm.w1 - 1]) }, children: arm.kids };
20216
20216
  });
20217
20217
  for (let k = 0; k < steps.length - 1; k++) steps[k].otherwise = [steps[k + 1]];
20218
20218
  const last = steps.at(-1);
20219
20219
  if (elseKids) {
20220
20220
  last.otherwise = elseKids;
20221
20221
  last.otherwiseLine = elseLine;
20222
- } else last.otherwise = [{ kind: "fail", says: "Fails with an error: no WHEN matched and there is no ELSE (case not found)", error: "case not found", code: code2(textOf4(a, i)), line: lineOf6(toks[a]) }];
20222
+ } else last.otherwise = [{ kind: "fail", says: "Fails with an error: no WHEN matched and there is no ELSE (case not found)", error: "case not found", code: code2(textOf4(a, i)), line: lineOf7(toks[a]) }];
20223
20223
  return [steps[0]];
20224
20224
  }
20225
20225
  if (up === "LOOP" && semi) {
@@ -20315,7 +20315,7 @@ function bodySteps(toks, ctx, opts = {}) {
20315
20315
  closeWith("TRY", "BEGIN TRY");
20316
20316
  skipSemis();
20317
20317
  expect(isW(peek(), "BEGIN") && isW(peek(1), "CATCH"), "BEGIN TRY without BEGIN CATCH");
20318
- const hLine = lineOf6(peek());
20318
+ const hLine = lineOf7(peek());
20319
20319
  i += 2;
20320
20320
  const handler = block(endsWith("END"));
20321
20321
  closeWith("CATCH", "BEGIN CATCH");
@@ -20338,7 +20338,7 @@ function bodySteps(toks, ctx, opts = {}) {
20338
20338
  i++;
20339
20339
  const names = toks.slice(c0, c1).filter((x) => !isW(x, "OR", "SQLSTATE")).map((x) => x.t === "str" ? `error ${strText(x)}` : words5(x.v));
20340
20340
  const any = toks.slice(c0, c1).some((x) => isW(x, "OTHERS"));
20341
- handlers.push({ says: any ? "If anything goes wrong" : `If ${names.join(" or ")} goes wrong`, line: lineOf6(toks[hAt]), steps: block(endsWith("WHEN", "END")) });
20341
+ handlers.push({ says: any ? "If anything goes wrong" : `If ${names.join(" or ")} goes wrong`, line: lineOf7(toks[hAt]), steps: block(endsWith("WHEN", "END")) });
20342
20342
  }
20343
20343
  }
20344
20344
  ctx.depth--;
@@ -20456,9 +20456,9 @@ function bodySteps(toks, ctx, opts = {}) {
20456
20456
  if (isP(peek(), ";")) i++;
20457
20457
  return [{ kind: "call", says: `Jumps to ${toks[a + 1]?.v ?? "a label"}`, code: code2(textOf4(a, e2)), jump: "break", ...baseOf2(a, e2) }];
20458
20458
  }
20459
- if (!semi && (up === "ELSE" || up === "END")) throw new Unmatched(`${up} without its IF or BEGIN (line ${lineOf6(t)})`);
20460
- if (semi && (up === "ELSE" || up === "ELSIF" || up === "ELSEIF" || up === "WHEN" || up === "UNTIL" || up === "EXCEPTION")) throw new Unmatched(`${up} outside its block (line ${lineOf6(t)})`);
20461
- if (semi && up === "END" && !ctx.allowEnd) throw new Unmatched(`END without its BEGIN (line ${lineOf6(t)})`);
20459
+ if (!semi && (up === "ELSE" || up === "END")) throw new Unmatched(`${up} without its IF or BEGIN (line ${lineOf7(t)})`);
20460
+ if (semi && (up === "ELSE" || up === "ELSIF" || up === "ELSEIF" || up === "WHEN" || up === "UNTIL" || up === "EXCEPTION")) throw new Unmatched(`${up} outside its block (line ${lineOf7(t)})`);
20461
+ if (semi && up === "END" && !ctx.allowEnd) throw new Unmatched(`END without its BEGIN (line ${lineOf7(t)})`);
20462
20462
  const e = Math.max(simpleEnd(a), a + 1);
20463
20463
  i = e;
20464
20464
  if (isP(peek(), ";")) i++;
@@ -20480,10 +20480,10 @@ function sqlDialect(src) {
20480
20480
  return "pg";
20481
20481
  }
20482
20482
  var ROUTINE_WORDS = ["FUNCTION", "PROCEDURE", "PROC"];
20483
- function sqlRoutines(src, lineAt4, dialect = sqlDialect(src)) {
20483
+ function sqlRoutines(src, lineAt5, dialect = sqlDialect(src)) {
20484
20484
  const toks = lexSql(src, 0, src.length, dialect);
20485
20485
  const out = [];
20486
- const lineOf6 = (k) => lineAt4(toks[Math.min(k, toks.length - 1)].s);
20486
+ const lineOf7 = (k) => lineAt5(toks[Math.min(k, toks.length - 1)].s);
20487
20487
  for (let k = 0; k < toks.length; k++) {
20488
20488
  const start = k;
20489
20489
  let j = k;
@@ -20629,7 +20629,7 @@ function sqlRoutines(src, lineAt4, dialect = sqlDialect(src)) {
20629
20629
  }
20630
20630
  }
20631
20631
  let steps = [], bodyEnd3 = end2;
20632
- const ctx = { src, lineAt: lineAt4, dialect: bodyDialect, routine, setof, trigger, depth: 0 };
20632
+ const ctx = { src, lineAt: lineAt5, dialect: bodyDialect, routine, setof, trigger, depth: 0 };
20633
20633
  try {
20634
20634
  if (dialect === "pg") {
20635
20635
  if (bodyToks && language !== "c" && language !== "internal") {
@@ -20668,8 +20668,8 @@ function sqlRoutines(src, lineAt4, dialect = sqlDialect(src)) {
20668
20668
  steps = [];
20669
20669
  }
20670
20670
  if (dialect === "tsql" || dialect === "mysql") end2 = bodyEnd3;
20671
- const endLine = lineOf6(Math.max(end2, start));
20672
- out.push({ name, line: lineOf6(start), endLine, kind: routine, inputs: inputs2, outs, returns, setof, trigger, steps, ...unreadWhy ? { unreadWhy } : {}, headerEnd: lineOf6(Math.max(start, j - 1)) });
20671
+ const endLine = lineOf7(Math.max(end2, start));
20672
+ out.push({ name, line: lineOf7(start), endLine, kind: routine, inputs: inputs2, outs, returns, setof, trigger, steps, ...unreadWhy ? { unreadWhy } : {}, headerEnd: lineOf7(Math.max(start, j - 1)) });
20673
20673
  k = Math.max(k, Math.min(end2, toks.length - 1));
20674
20674
  }
20675
20675
  return out;
@@ -20835,7 +20835,7 @@ function sqlCondition(cond, { aliases = {}, vars = false, keepAt = true, raw = f
20835
20835
  }
20836
20836
  function readSchema(src) {
20837
20837
  const m = mask(src);
20838
- const lineAt4 = lineFinder(src);
20838
+ const lineAt5 = lineFinder(src);
20839
20839
  const tables = [], choices = [], rules = [];
20840
20840
  const docs = /* @__PURE__ */ new Map();
20841
20841
  for (const c of src.matchAll(/COMMENT\s+ON\s+TABLE\s+([\w."]+)\s+IS\s+'((?:[^']|'')*)'/gi)) docs.set(bare(c[1]).toLowerCase(), c[2].replace(/''/g, "'"));
@@ -20844,10 +20844,10 @@ function readSchema(src) {
20844
20844
  const close = parenEnd(m, open);
20845
20845
  if (close < 0) continue;
20846
20846
  const name = bare(src.slice(t.index, open).match(/([\w."[\]`]+)\s*$/)[1]);
20847
- const table = { name, lines: [lineAt4(t.index), lineAt4(close)], doc: docs.get(name.toLowerCase()) ?? docAbove(src, t.index), columns: [], checks: [], uniques: [], refs: [] };
20847
+ const table = { name, lines: [lineAt5(t.index), lineAt5(close)], doc: docs.get(name.toLowerCase()) ?? docAbove(src, t.index), columns: [], checks: [], uniques: [], refs: [] };
20848
20848
  for (const part of splitTop2(src.slice(open + 1, close), m.slice(open + 1, close))) {
20849
20849
  const text2 = part.text.trim().replace(/\s+/g, " ");
20850
- const line = lineAt4(open + 1 + part.at + (part.text.length - part.text.trimStart().length));
20850
+ const line = lineAt5(open + 1 + part.at + (part.text.length - part.text.trimStart().length));
20851
20851
  let x;
20852
20852
  if (x = text2.match(/^(?:CONSTRAINT\s+([\w"]+)\s+)?CHECK\s*\((.*)\)$/i)) {
20853
20853
  table.checks.push({ name: x[1] && unquote(x[1]), cond: x[2], line });
@@ -20880,7 +20880,7 @@ function readSchema(src) {
20880
20880
  const close = parenEnd(m, open);
20881
20881
  if (close < 0) continue;
20882
20882
  const values = [...src.slice(open + 1, close).matchAll(/'((?:[^']|'')*)'/g)].map((v) => v[1].replace(/''/g, "'").replace(/_/g, " "));
20883
- choices.push({ name: bare(e[1]), lines: [lineAt4(e.index), lineAt4(close)], doc: docAbove(src, e.index), values });
20883
+ choices.push({ name: bare(e[1]), lines: [lineAt5(e.index), lineAt5(close)], doc: docAbove(src, e.index), values });
20884
20884
  }
20885
20885
  for (const t of tables) {
20886
20886
  for (const c of t.checks) rules.push({ table: t.name, kind: "check", ...c });
@@ -20983,7 +20983,7 @@ function sqlTemplateReason(src) {
20983
20983
  }
20984
20984
  function sqlItems(src) {
20985
20985
  const m = mask(src);
20986
- const lineAt4 = lineFinder(src);
20986
+ const lineAt5 = lineFinder(src);
20987
20987
  const items = [];
20988
20988
  const push = (name, line, steps, extra = {}) => {
20989
20989
  const code3 = steps.filter((s) => s.kind === "other").length;
@@ -21013,9 +21013,9 @@ function sqlItems(src) {
21013
21013
  const end2 = m.indexOf(";", v.index);
21014
21014
  const query = src.slice(v.index + v[0].length, end2 < 0 ? src.length : end2);
21015
21015
  const name = bare(v[1]);
21016
- push(name, lineAt4(v.index), selectSteps(query, lineAt4(v.index + v[0].length)), { doc: docAbove(src, v.index), endLine: lineAt4(end2 < 0 ? src.length : end2), says: `${words5(name)} is a saved query.`, headline: `${words5(name)}: a saved query.` });
21016
+ push(name, lineAt5(v.index), selectSteps(query, lineAt5(v.index + v[0].length)), { doc: docAbove(src, v.index), endLine: lineAt5(end2 < 0 ? src.length : end2), says: `${words5(name)} is a saved query.`, headline: `${words5(name)}: a saved query.` });
21017
21017
  }
21018
- for (const r of sqlRoutines(src, lineAt4)) {
21018
+ for (const r of sqlRoutines(src, lineAt5)) {
21019
21019
  const inputs2 = r.inputs.map(({ name, type }) => ({ name, type }));
21020
21020
  const returns = r.returns ?? (r.outs.length ? listWords2(r.outs.map((o) => words5(o.name))) : null);
21021
21021
  const steps = r.unreadWhy ? [] : r.steps;
@@ -21033,7 +21033,7 @@ function sqlItems(src) {
21033
21033
  const events = t[3].split(/\s+OR\s+/i).map((e) => ({ INSERT: "added", UPDATE: "changed", DELETE: "removed", TRUNCATE: "emptied" })[e.trim().split(/\s+/)[0].toUpperCase()] || words5(e)).filter(Boolean);
21034
21034
  const what = article(singular2(words5(bare(t[4]))));
21035
21035
  const when = `${t[2].toUpperCase() === "BEFORE" ? "Before" : t[2].toUpperCase() === "AFTER" ? "After" : "Instead of when"} ${what} is ${events.join(" or ")}`;
21036
- push(bare(t[1]), lineAt4(t.index), [{ kind: "call", says: `${when}, runs ${words5(bare(t[5]))}`, code: t[0].replace(/\s+/g, " "), line: lineAt4(t.index) }], { says: `${when}, the database runs ${words5(bare(t[5]))}.`, headline: `${when}.`, doc: docAbove(src, t.index) });
21036
+ push(bare(t[1]), lineAt5(t.index), [{ kind: "call", says: `${when}, runs ${words5(bare(t[5]))}`, code: t[0].replace(/\s+/g, " "), line: lineAt5(t.index) }], { says: `${when}, the database runs ${words5(bare(t[5]))}.`, headline: `${when}.`, doc: docAbove(src, t.index) });
21037
21037
  }
21038
21038
  for (const r of readSchema(src).rules) {
21039
21039
  const table = words5(r.table);
@@ -23467,7 +23467,7 @@ function scanInterp(src, j, dialect) {
23467
23467
  }
23468
23468
  return j;
23469
23469
  }
23470
- function tokenize2(src, dialect, from = 0, to = src.length, lineAt4 = lineIndex(src)) {
23470
+ function tokenize2(src, dialect, from = 0, to = src.length, lineAt5 = lineIndex(src)) {
23471
23471
  const hcl = dialect === "hcl";
23472
23472
  const toks = [], comments = [];
23473
23473
  let i = from;
@@ -23485,14 +23485,14 @@ function tokenize2(src, dialect, from = 0, to = src.length, lineAt4 = lineIndex(
23485
23485
  if (c === "#" || c === "/" && src[i + 1] === "/") {
23486
23486
  let j = i;
23487
23487
  while (j < to && src[j] !== "\n") j++;
23488
- comments.push({ line: lineAt4(i), endLine: lineAt4(i), text: src.slice(i, j).replace(/^(#|\/\/)\s?/, "").trim(), s: i });
23488
+ comments.push({ line: lineAt5(i), endLine: lineAt5(i), text: src.slice(i, j).replace(/^(#|\/\/)\s?/, "").trim(), s: i });
23489
23489
  i = j;
23490
23490
  continue;
23491
23491
  }
23492
23492
  if (c === "/" && src[i + 1] === "*") {
23493
23493
  let j = src.indexOf("*/", i + 2);
23494
23494
  if (j < 0 || j > to) j = to - 2;
23495
- comments.push({ line: lineAt4(i), endLine: lineAt4(j), text: src.slice(i + 2, j).replace(/^\s*\*+/gm, "").trim(), s: i });
23495
+ comments.push({ line: lineAt5(i), endLine: lineAt5(j), text: src.slice(i + 2, j).replace(/^\s*\*+/gm, "").trim(), s: i });
23496
23496
  i = j + 2;
23497
23497
  continue;
23498
23498
  }
@@ -23567,12 +23567,12 @@ function tokenize2(src, dialect, from = 0, to = src.length, lineAt4 = lineIndex(
23567
23567
  }
23568
23568
  var BIN = { "??": 1, "||": 2, "&&": 3, "==": 4, "!=": 4, "=~": 4, "!~": 4, "<": 5, ">": 5, "<=": 5, ">=": 5, "+": 6, "-": 6, "*": 7, "/": 7, "%": 7 };
23569
23569
  var Parser2 = class _Parser {
23570
- constructor(src, toks, dialect, lineAt4, hooks = {}) {
23570
+ constructor(src, toks, dialect, lineAt5, hooks = {}) {
23571
23571
  this.src = src;
23572
23572
  this.toks = toks;
23573
23573
  this.i = 0;
23574
23574
  this.dialect = dialect;
23575
- this.lineAt = lineAt4;
23575
+ this.lineAt = lineAt5;
23576
23576
  this.hooks = hooks;
23577
23577
  this.skipNl = [false];
23578
23578
  }
@@ -24085,9 +24085,9 @@ function docAbove2(comments, line) {
24085
24085
  }
24086
24086
  function parseHcl(src) {
24087
24087
  const text2 = String(src ?? "").replace(/^/, "");
24088
- const lineAt4 = lineIndex(text2);
24089
- const { toks, comments } = tokenize2(text2, "hcl", 0, text2.length, lineAt4);
24090
- const p = new Parser2(text2, toks, "hcl", lineAt4);
24088
+ const lineAt5 = lineIndex(text2);
24089
+ const { toks, comments } = tokenize2(text2, "hcl", 0, text2.length, lineAt5);
24090
+ const p = new Parser2(text2, toks, "hcl", lineAt5);
24091
24091
  const errors = [];
24092
24092
  const body2 = [];
24093
24093
  for (; ; ) {
@@ -24102,7 +24102,7 @@ function parseHcl(src) {
24102
24102
  p.i = resync(toks, start);
24103
24103
  }
24104
24104
  }
24105
- return { body: body2, comments, errors, lineAt: lineAt4, src: text2 };
24105
+ return { body: body2, comments, errors, lineAt: lineAt5, src: text2 };
24106
24106
  }
24107
24107
  function resync(toks, i) {
24108
24108
  let depth = 0, seen = false;
@@ -25097,9 +25097,9 @@ function ingressFacts(d, fact) {
25097
25097
  // src/bicep.mjs
25098
25098
  function parseBicep(src) {
25099
25099
  const text2 = String(src ?? "").replace(/^/, "");
25100
- const lineAt4 = lineIndex(text2);
25101
- const { toks, comments } = tokenize2(text2, "bicep", 0, text2.length, lineAt4);
25102
- const p = new Parser2(text2, toks, "bicep", lineAt4, { objectKey: nestedResource });
25100
+ const lineAt5 = lineIndex(text2);
25101
+ const { toks, comments } = tokenize2(text2, "bicep", 0, text2.length, lineAt5);
25102
+ const p = new Parser2(text2, toks, "bicep", lineAt5, { objectKey: nestedResource });
25103
25103
  const decls = [], errors = [];
25104
25104
  let decorators = [];
25105
25105
  for (; ; ) {
@@ -25128,7 +25128,7 @@ function parseBicep(src) {
25128
25128
  decorators = [];
25129
25129
  }
25130
25130
  }
25131
- return { decls, comments, errors, lineAt: lineAt4, src: text2 };
25131
+ return { decls, comments, errors, lineAt: lineAt5, src: text2 };
25132
25132
  }
25133
25133
  function resync2(toks, i) {
25134
25134
  let depth = 0;
@@ -28825,7 +28825,7 @@ function sayNode(n) {
28825
28825
  }
28826
28826
  var CODE_MAX = 160;
28827
28827
  function makeStepper(src) {
28828
- const lineAt4 = lineFinder2(src);
28828
+ const lineAt5 = lineFinder2(src);
28829
28829
  const codeOf = (n) => {
28830
28830
  const t = src.slice(n.at, n.end).replace(/\s+/g, " ").trim();
28831
28831
  return t.length > CODE_MAX ? `${t.slice(0, CODE_MAX - 1)}\u2026` : t;
@@ -28834,8 +28834,8 @@ function makeStepper(src) {
28834
28834
  const t = src.slice(n.at, n.end).split("\n")[0].trim();
28835
28835
  return t.length > CODE_MAX ? `${t.slice(0, CODE_MAX - 1)}\u2026` : t;
28836
28836
  };
28837
- const span = (n) => ({ startLine: lineAt4(n.at), endLine: lineAt4(Math.max(n.at, n.end - 1)) });
28838
- const base2 = (n, code3 = codeOf(n)) => ({ code: code3, line: lineAt4(n.at), span: span(n) });
28837
+ const span = (n) => ({ startLine: lineAt5(n.at), endLine: lineAt5(Math.max(n.at, n.end - 1)) });
28838
+ const base2 = (n, code3 = codeOf(n)) => ({ code: code3, line: lineAt5(n.at), span: span(n) });
28839
28839
  function steps(nodes2) {
28840
28840
  const out = [];
28841
28841
  for (let k = 0; k < nodes2.length; k++) {
@@ -28847,7 +28847,7 @@ function makeStepper(src) {
28847
28847
  if (ex && (ex.kind === "fail" || ex.failCode) && !ex.message) {
28848
28848
  const code3 = ex.exitCode ?? ex.failCode;
28849
28849
  const what = ex.exitCode ? `exit code ${code3}` : `return code ${code3}`;
28850
- out.push({ kind: "fail", says: `Fails with ${what}: "${got[0].stderr}"`, error: what, message: got[0].stderr, code: `${codeOf(n)}; ${codeOf(next)}`, line: lineAt4(n.at), span: { startLine: lineAt4(n.at), endLine: lineAt4(next.end - 1) } });
28850
+ out.push({ kind: "fail", says: `Fails with ${what}: "${got[0].stderr}"`, error: what, message: got[0].stderr, code: `${codeOf(n)}; ${codeOf(next)}`, line: lineAt5(n.at), span: { startLine: lineAt5(n.at), endLine: lineAt5(next.end - 1) } });
28851
28851
  k++;
28852
28852
  continue;
28853
28853
  }
@@ -28900,7 +28900,7 @@ function makeStepper(src) {
28900
28900
  case "if": {
28901
28901
  let first = null, tail = null;
28902
28902
  for (const c of n.clauses) {
28903
- const b = { kind: "branch", says: `If ${condWords2(c.cond)}`, code: src.slice(c.at, src.indexOf("\n", c.at) < 0 ? void 0 : src.indexOf("\n", c.at)).trim().slice(0, CODE_MAX), line: lineAt4(c.at), span: first ? { startLine: lineAt4(c.at), endLine: lineAt4(n.end - 1) } : span(n) };
28903
+ const b = { kind: "branch", says: `If ${condWords2(c.cond)}`, code: src.slice(c.at, src.indexOf("\n", c.at) < 0 ? void 0 : src.indexOf("\n", c.at)).trim().slice(0, CODE_MAX), line: lineAt5(c.at), span: first ? { startLine: lineAt5(c.at), endLine: lineAt5(n.end - 1) } : span(n) };
28904
28904
  const kids2 = steps(c.body);
28905
28905
  if (kids2.length) b.children = kids2;
28906
28906
  if (!first) first = b;
@@ -28913,7 +28913,7 @@ function makeStepper(src) {
28913
28913
  if (n.otherwise) {
28914
28914
  const kids2 = steps(n.otherwise);
28915
28915
  tail.otherwise = kids2;
28916
- tail.otherwiseLine = lineAt4(n.elseAt);
28916
+ tail.otherwiseLine = lineAt5(n.elseAt);
28917
28917
  }
28918
28918
  return [first];
28919
28919
  }
@@ -28962,7 +28962,7 @@ function makeStepper(src) {
28962
28962
  says = `When it is ${ws.length > 1 ? `${ws.slice(0, -1).join(", ")} or ${ws.at(-1)}` : ws[0]}`;
28963
28963
  } else says = `When it matches ${pats.map((p) => asCode3(p)).join(" or ")}`;
28964
28964
  const kids2 = steps(a.body);
28965
- return { kind: "check", says, caseLabel: true, code: src.slice(a.at, src.indexOf(")", a.at) + 1).trim().slice(0, 90), line: lineAt4(a.at), span: { startLine: lineAt4(a.at), endLine: lineAt4(Math.max(a.at, a.end - 1)) }, ...kids2.length ? { children: kids2 } : {} };
28965
+ return { kind: "check", says, caseLabel: true, code: src.slice(a.at, src.indexOf(")", a.at) + 1).trim().slice(0, 90), line: lineAt5(a.at), span: { startLine: lineAt5(a.at), endLine: lineAt5(Math.max(a.at, a.end - 1)) }, ...kids2.length ? { children: kids2 } : {} };
28966
28966
  });
28967
28967
  return [{ kind: "branch", says: `Chooses by ${sayWord(n.word)}`, ...base2(n, headOf2(n)), ...arms.length ? { children: arms } : {} }];
28968
28968
  }
@@ -29021,7 +29021,7 @@ function makeStepper(src) {
29021
29021
  };
29022
29022
  return build(0);
29023
29023
  }
29024
- return { steps, lineAt: lineAt4, codeOf, headOf: headOf2 };
29024
+ return { steps, lineAt: lineAt5, codeOf, headOf: headOf2 };
29025
29025
  }
29026
29026
  function docAbove3(lines, line) {
29027
29027
  const run = [];
@@ -29142,7 +29142,7 @@ function shellReading(src, file = "") {
29142
29142
  const last = f.body[f.body.length - 1];
29143
29143
  if (last?.type === "simple" && last.words[0] === "exit" && /^[1-9]\d*$/.test(last.words[1] ?? "")) DIES.set(f.name, last.words[1]);
29144
29144
  }
29145
- const { steps, lineAt: lineAt4 } = makeStepper(src);
29145
+ const { steps, lineAt: lineAt5 } = makeStepper(src);
29146
29146
  const errors = /* @__PURE__ */ new Map();
29147
29147
  const noteErrors = (list3) => {
29148
29148
  for (const s of list3 || []) {
@@ -29152,19 +29152,19 @@ function shellReading(src, file = "") {
29152
29152
  }
29153
29153
  };
29154
29154
  for (const f of all) {
29155
- const line = lineAt4(f.at);
29155
+ const line = lineAt5(f.at);
29156
29156
  const st = steps(f.body);
29157
- if (!st.length) st.push({ kind: "return", says: "Does nothing", code: src.slice(f.at, f.end).replace(/\s+/g, " ").trim().slice(0, 160), line, span: { startLine: line, endLine: lineAt4(f.end - 1) } });
29157
+ if (!st.length) st.push({ kind: "return", says: "Does nothing", code: src.slice(f.at, f.end).replace(/\s+/g, " ").trim().slice(0, 160), line, span: { startLine: line, endLine: lineAt5(f.end - 1) } });
29158
29158
  noteErrors(st);
29159
29159
  const first = f.body[0], lastN = f.body[f.body.length - 1];
29160
- fns.push({ name: f.name, line, params: inputsOf(f.body, src), doc: docAbove3(lines, line), steps: st, body: first ? [lineAt4(first.at), lineAt4(lastN.end - 1)] : null });
29160
+ fns.push({ name: f.name, line, params: inputsOf(f.body, src), doc: docAbove3(lines, line), steps: st, body: first ? [lineAt5(first.at), lineAt5(lastN.end - 1)] : null });
29161
29161
  }
29162
29162
  const top = nodes2.filter((n) => n.type !== "function");
29163
29163
  if (top.length) {
29164
29164
  const st = steps(top);
29165
29165
  noteErrors(st);
29166
29166
  const name = file ? String(file).split(/[\\/]/).pop() : "script";
29167
- fns.push({ name, line: lineAt4(top[0].at), params: inputsOf(top, src), doc: headerDoc(lines), steps: st, body: [lineAt4(top[0].at), lineAt4(top[top.length - 1].end - 1)], topLevel: true, headline: `Runs ${name}, from top to bottom.` });
29167
+ fns.push({ name, line: lineAt5(top[0].at), params: inputsOf(top, src), doc: headerDoc(lines), steps: st, body: [lineAt5(top[0].at), lineAt5(top[top.length - 1].end - 1)], topLevel: true, headline: `Runs ${name}, from top to bottom.` });
29168
29168
  }
29169
29169
  fns.sort((a, b) => a.line - b.line);
29170
29170
  KNOWN_FNS = /* @__PURE__ */ new Set();
@@ -30216,7 +30216,7 @@ function docBefore(toks, idx) {
30216
30216
  }
30217
30217
  function makeReader(src) {
30218
30218
  const toks = tokenize3(src);
30219
- const lineAt4 = lineFinder3(src);
30219
+ const lineAt5 = lineFinder3(src);
30220
30220
  const fns = [], things = [], errors = /* @__PURE__ */ new Map(), tests = [];
30221
30221
  const code3 = (s, e) => {
30222
30222
  const t = src.slice(toks[s].at, toks[e - 1].end).replace(/\s+/g, " ").trim();
@@ -30226,8 +30226,8 @@ function makeReader(src) {
30226
30226
  const t = src.slice(toks[s].at, toks[e - 1].end).split("\n")[0].trim();
30227
30227
  return t.length > 160 ? `${t.slice(0, 159)}\u2026` : t;
30228
30228
  };
30229
- const spanOf2 = (s, e) => ({ startLine: lineAt4(toks[s].at), endLine: lineAt4(toks[e - 1].end - 1) });
30230
- const base2 = (s, e, c = code3(s, e)) => ({ code: c, line: lineAt4(toks[s].at), span: spanOf2(s, e) });
30229
+ const spanOf2 = (s, e) => ({ startLine: lineAt5(toks[s].at), endLine: lineAt5(toks[e - 1].end - 1) });
30230
+ const base2 = (s, e, c = code3(s, e)) => ({ code: c, line: lineAt5(toks[s].at), span: spanOf2(s, e) });
30231
30231
  const nextTok = (i, to) => {
30232
30232
  while (i < to && (toks[i].t === "nl" || toks[i].t === "comment")) i++;
30233
30233
  return i;
@@ -30266,7 +30266,7 @@ function makeReader(src) {
30266
30266
  const blk = blockAt(toks[p].match + 1, e);
30267
30267
  if (!blk) break;
30268
30268
  const cond = toks.slice(p + 1, toks[p].match);
30269
- const b = { kind: "branch", says: `If ${gated(cond, condWords3(cond, false)) ?? asCodeWords(code3(p + 1, toks[p].match))}`, cond: condJs(cond), code: head(i, blk[1] + 1), line: lineAt4(toks[i].at), span: first ? spanOf2(i, e) : spanOf2(s, e) };
30269
+ const b = { kind: "branch", says: `If ${gated(cond, condWords3(cond, false)) ?? asCodeWords(code3(p + 1, toks[p].match))}`, cond: condJs(cond), code: head(i, blk[1] + 1), line: lineAt5(toks[i].at), span: first ? spanOf2(i, e) : spanOf2(s, e) };
30270
30270
  const kids2 = stepsIn(blk[0], blk[1], ctx);
30271
30271
  if (kids2.length) b.children = kids2;
30272
30272
  if (!first) first = b;
@@ -30282,7 +30282,7 @@ function makeReader(src) {
30282
30282
  const blk = blockAt(i + 1, e);
30283
30283
  if (!blk) break;
30284
30284
  tail.otherwise = stepsIn(blk[0], blk[1], ctx);
30285
- tail.otherwiseLine = lineAt4(toks[i].at);
30285
+ tail.otherwiseLine = lineAt5(toks[i].at);
30286
30286
  i = blk[1] + 1;
30287
30287
  continue;
30288
30288
  }
@@ -30363,7 +30363,7 @@ function makeReader(src) {
30363
30363
  if (!body2) break;
30364
30364
  const kids2 = stepsIn(body2[0], body2[1], ctx);
30365
30365
  const label = /^default$/i.test(pat.text) ? "Otherwise" : pat.text === "{" ? `When ${gated(toks.slice(patStart + 1, pat.match), condWords3(toks.slice(patStart + 1, pat.match), false)) ?? asCodeWords(code3(patStart + 1, pat.match))}` : flags2.includes("-regex") ? `When it matches the pattern ${sayValue2([pat])}` : flags2.includes("-wildcard") ? `When it matches ${sayValue2([pat])}` : `When it is ${sayValue2(toks.slice(patStart, k)) ?? pat.text}`;
30366
- arms.push({ kind: "check", says: label, caseLabel: true, code: head(patStart, body2[1] + 1).slice(0, 90), line: lineAt4(pat.at), span: spanOf2(patStart, body2[1] + 1), ...kids2.length ? { children: kids2 } : {}, _pat: pat });
30366
+ arms.push({ kind: "check", says: label, caseLabel: true, code: head(patStart, body2[1] + 1).slice(0, 90), line: lineAt5(pat.at), span: spanOf2(patStart, body2[1] + 1), ...kids2.length ? { children: kids2 } : {}, _pat: pat });
30367
30367
  k = body2[1] + 1;
30368
30368
  }
30369
30369
  for (const a of arms) delete a._pat;
@@ -30394,14 +30394,14 @@ function makeReader(src) {
30394
30394
  } finally {
30395
30395
  IN_CATCH--;
30396
30396
  }
30397
- (step.handlers ||= []).push({ says: types.length ? `If ${types.join(" or ")} goes wrong` : "If anything goes wrong", line: lineAt4(toks[i].at), steps: hs });
30397
+ (step.handlers ||= []).push({ says: types.length ? `If ${types.join(" or ")} goes wrong` : "If anything goes wrong", line: lineAt5(toks[i].at), steps: hs });
30398
30398
  i = nextTok(b[1] + 1, e);
30399
30399
  continue;
30400
30400
  }
30401
30401
  if (w === "finally") {
30402
30402
  const b = blockAt(i + 1, e);
30403
30403
  if (!b) break;
30404
- step.always = { line: lineAt4(toks[i].at), steps: stepsIn(b[0], b[1], ctx) };
30404
+ step.always = { line: lineAt5(toks[i].at), steps: stepsIn(b[0], b[1], ctx) };
30405
30405
  i = nextTok(b[1] + 1, e);
30406
30406
  continue;
30407
30407
  }
@@ -30437,8 +30437,8 @@ function makeReader(src) {
30437
30437
  msg = null;
30438
30438
  name = varWords2(rest2[0].name);
30439
30439
  } else if (!rest2.length) return [{ kind: "fail", says: "Fails again with the same error", error: "the same error", ...base2(s, e) }];
30440
- if (msg) errors.set(msg, errors.get(msg) ?? lineAt4(t.at));
30441
- else if (name !== "an error") errors.set(name, errors.get(name) ?? lineAt4(t.at));
30440
+ if (msg) errors.set(msg, errors.get(msg) ?? lineAt5(t.at));
30441
+ else if (name !== "an error") errors.set(name, errors.get(name) ?? lineAt5(t.at));
30442
30442
  return [{ kind: "fail", says: `Fails with ${name}${msg ? `: "${msg}"` : ""}`, error: name, ...msg ? { message: msg } : {}, ...base2(s, e) }];
30443
30443
  }
30444
30444
  case "return": {
@@ -30498,7 +30498,7 @@ function makeReader(src) {
30498
30498
  if (/^(describe|context|it)$/i.test(t.text) && toks[nextTok(s + 1, e)]?.t === "str") {
30499
30499
  const name = stringText(toks[nextTok(s + 1, e)]);
30500
30500
  const blk = toks.slice(s, e).find((x) => x.text === "{" && x.match != null);
30501
- if (/^it$/i.test(t.text)) tests.push({ name, line: lineAt4(t.at) });
30501
+ if (/^it$/i.test(t.text)) tests.push({ name, line: lineAt5(t.at) });
30502
30502
  else if (blk) stepsIn(blk.i + 1, blk.match, ctx);
30503
30503
  return [];
30504
30504
  }
@@ -30563,7 +30563,7 @@ function makeReader(src) {
30563
30563
  const msg = a.named.message ? sayValue2(a.named.message) : a.pos[0] ? sayValue2(a.pos[0]) : null;
30564
30564
  const text2 = msg ? msg.replace(/^"|"$/g, "") : null;
30565
30565
  const stops = STOP_ON_ERROR || /stop/i.test(a.named.erroraction?.map((x) => x.text).join("") ?? "");
30566
- if (text2) errors.set(text2, errors.get(text2) ?? lineAt4(head0.at));
30566
+ if (text2) errors.set(text2, errors.get(text2) ?? lineAt5(head0.at));
30567
30567
  return [stops ? { kind: "fail", says: `Fails with an error${text2 ? `: "${text2}"` : ""}`, error: "an error", ...text2 ? { message: text2 } : {}, ...base2(s, e) } : { kind: "call", says: `Reports an error${text2 ? `: "${text2}"` : ""} and carries on`, ...base2(s, e) }];
30568
30568
  }
30569
30569
  const lg = groups(list3);
@@ -30651,7 +30651,7 @@ function makeReader(src) {
30651
30651
  if (!steps.length) steps.push({ kind: "return", says: "Does nothing", ...base2(s, e, head(s, e)) });
30652
30652
  lastValueToReturn(steps);
30653
30653
  const first = nextTok(parts.from, blk[1]);
30654
- fns.push({ name, line: lineAt4(nameTok.at), params, doc, steps, body: first < blk[1] ? [lineAt4(toks[first].at), lineAt4(toks[blk[1]].at)] : null, _range: [parts.from, blk[1]] });
30654
+ fns.push({ name, line: lineAt5(nameTok.at), params, doc, steps, body: first < blk[1] ? [lineAt5(toks[first].at), lineAt5(toks[blk[1]].at)] : null, _range: [parts.from, blk[1]] });
30655
30655
  }
30656
30656
  function podeRoute(s, e) {
30657
30657
  const a = argsOf(toks.slice(s + 1, e));
@@ -30661,14 +30661,14 @@ function makeReader(src) {
30661
30661
  const sb = a.named.scriptblock;
30662
30662
  if (!sb || sb[0].text !== "{") return;
30663
30663
  const open = sb[0].i;
30664
- fns.push({ name: `${method} ${path}`, line: lineAt4(toks[s].at), params: [], route: { method, path }, steps: stepsIn(open + 1, sb[0].match), body: [lineAt4(toks[nextTok(open + 1, sb[0].match)]?.at ?? toks[open].at), lineAt4(toks[sb[0].match].at)] });
30664
+ fns.push({ name: `${method} ${path}`, line: lineAt5(toks[s].at), params: [], route: { method, path }, steps: stepsIn(open + 1, sb[0].match), body: [lineAt5(toks[nextTok(open + 1, sb[0].match)]?.at ?? toks[open].at), lineAt5(toks[sb[0].match].at)] });
30665
30665
  }
30666
30666
  function defineType(s, e, kw) {
30667
30667
  const nameTok = toks[nextTok(s + 1, e)];
30668
30668
  const blk = toks.slice(s, e).find((x) => x.text === "{" && x.match != null);
30669
30669
  if (!nameTok || !blk) return;
30670
30670
  const open = blk.i, close = blk.match;
30671
- const lines = [lineAt4(toks[s].at), lineAt4(toks[close].at)];
30671
+ const lines = [lineAt5(toks[s].at), lineAt5(toks[close].at)];
30672
30672
  const doc = docBefore(toks, s);
30673
30673
  if (kw === "enum") {
30674
30674
  const choices = [];
@@ -30685,7 +30685,7 @@ function makeReader(src) {
30685
30685
  const type = st.slice(0, v).reverse().find((x) => x.t === "type");
30686
30686
  const eq2 = st.findIndex((x, i) => i > v && x.text === "=");
30687
30687
  const def = eq2 > 0 ? st.slice(eq2 + 1) : null;
30688
- thing.knows.push({ name: st[v].name, type: type?.name ?? null, start: def ? def.map((x) => x.text).join(" ") : null, line: lineAt4(st[v].at) });
30688
+ thing.knows.push({ name: st[v].name, type: type?.name ?? null, start: def ? def.map((x) => x.text).join(" ") : null, line: lineAt5(st[v].at) });
30689
30689
  continue;
30690
30690
  }
30691
30691
  const nameAt = st.findIndex((x, i) => x.t === "word" && st[i + 1]?.text === "(");
@@ -30701,7 +30701,7 @@ function makeReader(src) {
30701
30701
  const first = nextTok(bOpen + 1, body2.match);
30702
30702
  const ret = st.slice(0, nameAt).reverse().find((x) => x.t === "type");
30703
30703
  if (mTok.text !== nameTok.text) thing.methods++;
30704
- fns.push({ name: mTok.text, line: lineAt4(mTok.at), params, returns: ret && !/^void$/i.test(ret.name) ? ret.name : null, doc: docBefore(toks, st[0].i), steps, body: first < body2.match ? [lineAt4(toks[first].at), lineAt4(toks[body2.match].at)] : null, _range: [bOpen + 1, body2.match] });
30704
+ fns.push({ name: mTok.text, line: lineAt5(mTok.at), params, returns: ret && !/^void$/i.test(ret.name) ? ret.name : null, doc: docBefore(toks, st[0].i), steps, body: first < body2.match ? [lineAt5(toks[first].at), lineAt5(toks[body2.match].at)] : null, _range: [bOpen + 1, body2.match] });
30705
30705
  if (mTok.text === nameTok.text) {
30706
30706
  for (const [x, y] of splitStatements(toks, bOpen + 1, body2.match)) {
30707
30707
  const st2 = at0(toks.slice(x, y));
@@ -30712,7 +30712,7 @@ function makeReader(src) {
30712
30712
  const start = param ? param.default ? { param: param.default } : { given: true } : val.map((q2) => q2.text).join(" ");
30713
30713
  if (k2) {
30714
30714
  if (k2.start == null || param) k2.start = start;
30715
- } else thing.knows.push({ name: st2[2].text, type: null, start, line: lineAt4(st2[0].at) });
30715
+ } else thing.knows.push({ name: st2[2].text, type: null, start, line: lineAt5(st2[0].at) });
30716
30716
  }
30717
30717
  }
30718
30718
  }
@@ -30720,7 +30720,7 @@ function makeReader(src) {
30720
30720
  delete thing.methods;
30721
30721
  things.push(thing);
30722
30722
  }
30723
- return { toks, fns, things, errors, tests, stepsIn, lineAt: lineAt4, splitStatements: () => splitStatements(toks, 0, toks.length), statement: statement2, nextTok, code: code3, cleanSteps };
30723
+ return { toks, fns, things, errors, tests, stepsIn, lineAt: lineAt5, splitStatements: () => splitStatements(toks, 0, toks.length), statement: statement2, nextTok, code: code3, cleanSteps };
30724
30724
  }
30725
30725
  var fixedOf = (toks) => {
30726
30726
  const v = at0(toks || []);
@@ -31799,7 +31799,7 @@ var KNOWN_FNS3 = /* @__PURE__ */ new Set();
31799
31799
  function makeReader2(src) {
31800
31800
  SRC = src;
31801
31801
  const toks = tokenize4(src);
31802
- const lineAt4 = lineFinder4(src);
31802
+ const lineAt5 = lineFinder4(src);
31803
31803
  const fns = [], things = [], errors = /* @__PURE__ */ new Map(), tests = [], defs = [];
31804
31804
  const code3 = (s, e) => {
31805
31805
  const t = src.slice(toks[s].at, toks[e - 1].end).replace(/\s+/g, " ").trim();
@@ -31809,8 +31809,8 @@ function makeReader2(src) {
31809
31809
  const t = src.slice(toks[s].at, toks[e - 1].end).split("\n")[0].trim();
31810
31810
  return t.length > 160 ? `${t.slice(0, 159)}\u2026` : t;
31811
31811
  };
31812
- const spanOf2 = (s, e) => ({ startLine: lineAt4(toks[s].at), endLine: lineAt4(toks[e - 1].end - 1) });
31813
- const base2 = (s, e, c = code3(s, e)) => ({ code: c, line: lineAt4(toks[s].at), span: spanOf2(s, e) });
31812
+ const spanOf2 = (s, e) => ({ startLine: lineAt5(toks[s].at), endLine: lineAt5(toks[e - 1].end - 1) });
31813
+ const base2 = (s, e, c = code3(s, e)) => ({ code: c, line: lineAt5(toks[s].at), span: spanOf2(s, e) });
31814
31814
  const next = (i, to) => {
31815
31815
  while (i < to && (toks[i].t === "nl" || toks[i].t === "comment")) i++;
31816
31816
  return i;
@@ -31862,7 +31862,7 @@ function makeReader2(src) {
31862
31862
  thenTo = elseAt >= 0 ? elseAt : e;
31863
31863
  }
31864
31864
  const c = condSaid(condT);
31865
- const step = { kind: "branch", says: `If ${c ?? `\`${code3(open + 1, close)}\``}`, cond: condJs2(condT), code: head(s, e), line: lineAt4(toks[s].at), span: spanOf2(s, e) };
31865
+ const step = { kind: "branch", says: `If ${c ?? `\`${code3(open + 1, close)}\``}`, cond: condJs2(condT), code: head(s, e), line: lineAt5(toks[s].at), span: spanOf2(s, e) };
31866
31866
  const kids2 = stepsOfBody(close + 1, thenTo, ctx);
31867
31867
  if (kids2.length) step.children = kids2;
31868
31868
  if (elseAt >= 0) {
@@ -31876,7 +31876,7 @@ function makeReader2(src) {
31876
31876
  }
31877
31877
  } else {
31878
31878
  step.otherwise = stepsOfBody(elseAt + 1, e, ctx);
31879
- step.otherwiseLine = lineAt4(toks[elseAt].at);
31879
+ step.otherwiseLine = lineAt5(toks[elseAt].at);
31880
31880
  }
31881
31881
  }
31882
31882
  return step;
@@ -31969,7 +31969,7 @@ function makeReader2(src) {
31969
31969
  const fnSteps = stepsOfBody(fv.from, fv.to, { last: true, fn: true });
31970
31970
  if (!fnSteps.length) fnSteps.push({ kind: "return", says: "Does nothing", ...base2(nameTok.i, fv.to, head(nameTok.i, fv.to)) });
31971
31971
  const [a, b] = bodyRange2(fv.from, fv.to);
31972
- const f = { name: route && !name ? `${route.method} ${route.path}` : name, line: lineAt4(nameTok.at), params, doc, steps: fnSteps, body: a < b && next(a, b) < b ? [lineAt4(toks[next(a, b)].at), lineAt4(toks[b - 1].end - 1)] : null, ...route ? { route } : {}, _fv: fv, ...owner ? { owner } : {} };
31972
+ const f = { name: route && !name ? `${route.method} ${route.path}` : name, line: lineAt5(nameTok.at), params, doc, steps: fnSteps, body: a < b && next(a, b) < b ? [lineAt5(toks[next(a, b)].at), lineAt5(toks[b - 1].end - 1)] : null, ...route ? { route } : {}, _fv: fv, ...owner ? { owner } : {} };
31973
31973
  fns.push(f);
31974
31974
  return f;
31975
31975
  }
@@ -32125,11 +32125,11 @@ function makeReader2(src) {
32125
32125
  const fv = fnValue(a.toks);
32126
32126
  const r = at02(a.toks).length ? range(at02(a.toks)) : null;
32127
32127
  if (a.name === "finally") {
32128
- step.always = { line: lineAt4(at02(a.toks)[0]?.at ?? toks[s].at), steps: r ? stepsOfBody(r[0], r[1], { ...ctx, last: false }) : [] };
32128
+ step.always = { line: lineAt5(at02(a.toks)[0]?.at ?? toks[s].at), steps: r ? stepsOfBody(r[0], r[1], { ...ctx, last: false }) : [] };
32129
32129
  continue;
32130
32130
  }
32131
32131
  const says = a.name === "error" ? "If anything goes wrong" : a.name === "warning" ? "If there is a warning" : a.name === "message" ? "If a message is written" : a.name === "interrupt" ? "If it is stopped" : `If ${a.name} goes wrong`;
32132
- (step.handlers ||= []).push({ says, line: lineAt4(at02(a.toks)[0]?.at ?? toks[s].at), steps: fv ? stepsOfBody(fv.from, fv.to, { ...ctx, last: !!target || ctx.last, fn: true }) : [] });
32132
+ (step.handlers ||= []).push({ says, line: lineAt5(at02(a.toks)[0]?.at ?? toks[s].at), steps: fv ? stepsOfBody(fv.from, fv.to, { ...ctx, last: !!target || ctx.last, fn: true }) : [] });
32133
32133
  }
32134
32134
  if (target) {
32135
32135
  for (const list3 of [step.children, ...(step.handlers || []).map((h) => h.steps)]) if (list3?.length) giveValue2({ kind: "branch", children: list3 }, target);
@@ -32150,7 +32150,7 @@ function makeReader2(src) {
32150
32150
  pending = [];
32151
32151
  const r = vtoks.length ? range(vtoks) : null;
32152
32152
  const kids2 = r ? stepsOfBody(r[0], r[1], ctx) : [];
32153
- 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: lineAt4(vtoks[0]?.at ?? toks[s].at), span: r ? spanOf2(r[0], r[1]) : spanOf2(s, e), ...kids2.length ? { children: kids2 } : {} });
32153
+ 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 } : {} });
32154
32154
  }
32155
32155
  return { kind: "branch", says: `Chooses by ${sayValue3(subject?.toks ?? []) ?? "value"}`, ...base2(s, e, head(s, e)), ...arms.length ? { children: arms } : {} };
32156
32156
  }
@@ -32176,7 +32176,7 @@ function makeReader2(src) {
32176
32176
  const isVar = parts.length === 1 && one.length === 1 && one[0].t === "id";
32177
32177
  const single = !isVar && oneValue(parts) ? sayValue3(parts[0].toks) : null;
32178
32178
  const msg = isVar || single || !parts.length ? null : textOf3(parts, "", bare2 === "cli_abort" || bare2 === "ui_abort");
32179
- if (msg) errors.set(msg, errors.get(msg) ?? lineAt4(toks[s].at));
32179
+ if (msg) errors.set(msg, errors.get(msg) ?? lineAt5(toks[s].at));
32180
32180
  const cls = args.find((a) => a.name === "class");
32181
32181
  const name = cls ? at02(cls.toks)[0]?.value ?? "an error" : "an error";
32182
32182
  const says = isVar ? `Fails with the error in ${rWords(one[0].text)}` : single ? `Fails with the error ${/^the result of /.test(single) ? single.replace(/^the result of /, "made by ") : `in ${single}`}` : `Fails with ${name}${msg ? `: "${msg}"` : ""}`;
@@ -32204,7 +32204,7 @@ function makeReader2(src) {
32204
32204
  if (bare2 === "try") {
32205
32205
  const r = args[0] && at02(args[0].toks).length ? range(at02(args[0].toks)) : null;
32206
32206
  const kids2 = r ? stepsOfBody(r[0], r[1], { ...ctx, last: false }) : [];
32207
- 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: lineAt4(toks[s].at), steps: [] }] }];
32207
+ 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: [] }] }];
32208
32208
  }
32209
32209
  if (bare2 === "on.exit") {
32210
32210
  const r = args[0] && at02(args[0].toks).length ? range(at02(args[0].toks)) : null;
@@ -32218,7 +32218,7 @@ function makeReader2(src) {
32218
32218
  }
32219
32219
  if (bare2 === "test_that") {
32220
32220
  const name = at02(args[0]?.toks ?? [])[0]?.value;
32221
- if (name) tests.push({ name, line: lineAt4(toks[s].at) });
32221
+ if (name) tests.push({ name, line: lineAt5(toks[s].at) });
32222
32222
  return [];
32223
32223
  }
32224
32224
  if (bare2 === "return" || bare2 === "invisible") {
@@ -32255,7 +32255,7 @@ function makeReader2(src) {
32255
32255
  return [val ? { kind: "call", says: `Works out ${val}`, ...base2(s, e) } : { kind: "other", says: code3(s, e), ...base2(s, e) }];
32256
32256
  }
32257
32257
  function defineThing(name, call2, s, e) {
32258
- const lines = [lineAt4(toks[s].at), lineAt4(toks[e - 1].end - 1)];
32258
+ const lines = [lineAt5(toks[s].at), lineAt5(toks[e - 1].end - 1)];
32259
32259
  const className = at02(call2.args[0]?.toks ?? [])[0]?.value ?? at02(call2.args.find((a) => a.name === "Classname")?.toks ?? [])[0]?.value ?? name;
32260
32260
  const { doc } = docAbove5(s);
32261
32261
  const thing = { kind: "record", name: className || name, lines, ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
@@ -32268,13 +32268,13 @@ function makeReader2(src) {
32268
32268
  for (const a of args || []) {
32269
32269
  if (!a.name) {
32270
32270
  const sv = at02(a.toks)[0];
32271
- if (sv?.t === "str") thing.knows.push({ name: sv.value, type: null, start: null, line: lineAt4(sv.at) });
32271
+ if (sv?.t === "str") thing.knows.push({ name: sv.value, type: null, start: null, line: lineAt5(sv.at) });
32272
32272
  continue;
32273
32273
  }
32274
32274
  const vt = at02(a.toks);
32275
32275
  if (fnValue(vt)) continue;
32276
32276
  const tv = typed && vt.length === 1 && vt[0].t === "str" ? vt[0].value : null;
32277
- thing.knows.push({ name: a.name, type: tv ? R_TYPE[tv] ?? tv : null, start: typed ? null : vt.map((x) => x.text).join(""), line: lineAt4(vt[0]?.at ?? toks[s].at) });
32277
+ thing.knows.push({ name: a.name, type: tv ? R_TYPE[tv] ?? tv : null, start: typed ? null : vt.map((x) => x.text).join(""), line: lineAt5(vt[0]?.at ?? toks[s].at) });
32278
32278
  }
32279
32279
  };
32280
32280
  let methods = 0;
@@ -32283,7 +32283,7 @@ function makeReader2(src) {
32283
32283
  const fv = a.name ? fnValue(a.toks) : null;
32284
32284
  if (!fv) continue;
32285
32285
  const f = defineFunction(a.name, fv, at02(a.toks)[0].i, toks[at02(a.toks)[0].i - 2] ?? toks[s]);
32286
- f.line = lineAt4(toks[at02(a.toks)[0].i - 2]?.at ?? toks[s].at);
32286
+ f.line = lineAt5(toks[at02(a.toks)[0].i - 2]?.at ?? toks[s].at);
32287
32287
  if (a.name !== "initialize") methods++;
32288
32288
  if (a.name === "initialize") {
32289
32289
  const byName = new Map(fv.params.map((p) => [p.name, p.default ? at02(p.default).map((x) => x.text).join("") : null]));
@@ -32297,7 +32297,7 @@ function makeReader2(src) {
32297
32297
  const start = val.length === 1 && byName.has(val[0].text) ? { param: byName.get(val[0].text) } : val.map((q2) => q2.text).join("");
32298
32298
  if (k) {
32299
32299
  if (k.start == null || typeof start === "object") k.start = start;
32300
- } else thing.knows.push({ name: field, type: null, start, line: lineAt4(st[0].at) });
32300
+ } else thing.knows.push({ name: field, type: null, start, line: lineAt5(st[0].at) });
32301
32301
  }
32302
32302
  }
32303
32303
  }
@@ -32322,7 +32322,7 @@ function makeReader2(src) {
32322
32322
  thing._methods = methods;
32323
32323
  things.push(thing);
32324
32324
  }
32325
- return { toks, fns, things, errors, tests, stepsIn, lineAt: lineAt4, next, statement: statement2, code: code3, base: base2 };
32325
+ return { toks, fns, things, errors, tests, stepsIn, lineAt: lineAt5, next, statement: statement2, code: code3, base: base2 };
32326
32326
  }
32327
32327
  function decisionOf2(r, fv) {
32328
32328
  const { toks } = r;
@@ -34215,7 +34215,7 @@ function swiftImplicitResult(text2, returns) {
34215
34215
  var rebind = (guard, name, subject) => guard.replace(new RegExp(`\\b${name}\\b`, "g"), subject);
34216
34216
  function switchArms(body2, language, baseLine) {
34217
34217
  const arms = [];
34218
- const lineOf6 = (idx) => baseLine + lineAt2(body2, idx) - 1;
34218
+ const lineOf7 = (idx) => baseLine + lineAt2(body2, idx) - 1;
34219
34219
  if (language === "rust" || language === "csharp-expr") {
34220
34220
  let i = 0;
34221
34221
  while (i < body2.length) {
@@ -34238,7 +34238,7 @@ function switchArms(body2, language, baseLine) {
34238
34238
  value = body2.slice(j, end2).trim();
34239
34239
  }
34240
34240
  const g = head.match(/^(.*?)\s+(?:if|when)\s+(.+)$/s);
34241
- arms.push({ pattern: (g ? g[1] : head).trim(), guard: g ? g[2].trim() : null, value, line: lineOf6(i) });
34241
+ arms.push({ pattern: (g ? g[1] : head).trim(), guard: g ? g[2].trim() : null, value, line: lineOf7(i) });
34242
34242
  i = end2 + 1;
34243
34243
  }
34244
34244
  return arms;
@@ -34277,8 +34277,8 @@ function switchArms(body2, language, baseLine) {
34277
34277
  }
34278
34278
  const patterns = [...pending, pattern2];
34279
34279
  pending = [];
34280
- if (patterns.includes(null)) arms.push({ pattern: null, guard: null, value, line: lineOf6(starts[k]) });
34281
- else arms.push({ pattern: patterns.join(language === "go" && patterns.length === 1 ? "" : ", ") || patterns[0], guard: g ? g[2].trim() : null, value, line: lineOf6(starts[k]) });
34280
+ if (patterns.includes(null)) arms.push({ pattern: null, guard: null, value, line: lineOf7(starts[k]) });
34281
+ else arms.push({ pattern: patterns.join(language === "go" && patterns.length === 1 ? "" : ", ") || patterns[0], guard: g ? g[2].trim() : null, value, line: lineOf7(starts[k]) });
34282
34282
  }
34283
34283
  return arms;
34284
34284
  }
@@ -34571,12 +34571,12 @@ function readBraceStatements(stmts, language, inputs2) {
34571
34571
  }
34572
34572
  let rest2 = t;
34573
34573
  let ok = true;
34574
- const lineOf6 = (part) => {
34574
+ const lineOf7 = (part) => {
34575
34575
  const at2 = t.lastIndexOf(part);
34576
34576
  return st.line + (at2 > 0 ? (t.slice(0, at2).match(/\n/g) || []).length : 0);
34577
34577
  };
34578
34578
  while (rest2) {
34579
- const here = lineOf6(rest2);
34579
+ const here = lineOf7(rest2);
34580
34580
  const head2 = rest2.match(/^(?:else\s+)?if\b\s*/);
34581
34581
  if (!head2) break;
34582
34582
  rest2 = rest2.slice(head2[0].length);
@@ -34629,9 +34629,9 @@ function readBraceStatements(stmts, language, inputs2) {
34629
34629
  const elseBody = remaining.replace(/^else\s*/, "");
34630
34630
  const v = elseBody.startsWith("{") ? blockValue(elseBody) : elseBody.startsWith("return ") ? elseBody.slice(7).replace(/;$/, "") : null;
34631
34631
  if (v == null) {
34632
- unread.push({ line: lineOf6(remaining), text: "else", reason: "The fallback branch does more than choose an answer." });
34632
+ unread.push({ line: lineOf7(remaining), text: "else", reason: "The fallback branch does more than choose an answer." });
34633
34633
  ok = false;
34634
- } else take(null, v, lineOf6(remaining));
34634
+ } else take(null, v, lineOf7(remaining));
34635
34635
  }
34636
34636
  rest2 = "";
34637
34637
  }
@@ -35975,12 +35975,12 @@ function plainFromReading(item4) {
35975
35975
  const whens = (item4.rules ?? []).map((r) => r.when ?? "").join(" and ");
35976
35976
  const typed = (item4.inputs ?? []).map((i) => {
35977
35977
  if (i.type) return i;
35978
- const esc3 = i.name.replace(/[$]/g, "\\$");
35979
- if (new RegExp(`\\b${esc3}\\s*(>=|<=|<|>|==)\\s*-?\\d`).test(whens)) {
35978
+ const esc4 = i.name.replace(/[$]/g, "\\$");
35979
+ if (new RegExp(`\\b${esc4}\\s*(>=|<=|<|>|==)\\s*-?\\d`).test(whens)) {
35980
35980
  inferred.push(i.name);
35981
35981
  return { ...i, type: "number" };
35982
35982
  }
35983
- if (new RegExp(`(^|\\s|not\\s+|!)${esc3}(\\s|$)`).test(whens)) {
35983
+ if (new RegExp(`(^|\\s|not\\s+|!)${esc4}(\\s|$)`).test(whens)) {
35984
35984
  inferred.push(i.name);
35985
35985
  return { ...i, type: "boolean" };
35986
35986
  }
@@ -36407,7 +36407,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36407
36407
  return { name, label: words14(name.replace(/^[_$]+|_$/g, "")), kind, start: said, line };
36408
36408
  };
36409
36409
  function curlyThings(src, file, language) {
36410
- const lineAt4 = lineFinder5(src);
36410
+ const lineAt5 = lineFinder5(src);
36411
36411
  const out = [];
36412
36412
  const kw = {
36413
36413
  java: /(?:^|\n)[ \t]*(?:@\w+(?:\([^)]*\))?\s*)*(?:(?:public|private|protected|static|final|abstract|sealed|non-sealed)\s+)*(class|enum|record)\s+(\w+)\s*(?:<[^>{]*>)?\s*(\([^)]*\))?[^{;]*\{/g,
@@ -36434,7 +36434,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36434
36434
  kind: isEnum ? "choices" : isRecord ? "record" : "thing",
36435
36435
  name,
36436
36436
  file,
36437
- lines: [lineAt4(declAt), lineAt4(close >= 0 ? close : m.index + head.length)],
36437
+ lines: [lineAt5(declAt), lineAt5(close >= 0 ? close : m.index + head.length)],
36438
36438
  ...docAbove4(src, declAt) ? { doc: docAbove4(src, declAt) } : {},
36439
36439
  knows: [],
36440
36440
  choices: []
@@ -36502,7 +36502,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36502
36502
  return out;
36503
36503
  }
36504
36504
  function goThings(src, file) {
36505
- const lineAt4 = lineFinder5(src);
36505
+ const lineAt5 = lineFinder5(src);
36506
36506
  const out = [];
36507
36507
  const byName = /* @__PURE__ */ new Map();
36508
36508
  for (const m of src.matchAll(/(?:^|\n)type\s+(\w+)\s+struct\s*\{/g)) {
@@ -36510,7 +36510,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36510
36510
  const open = m.index + m[0].length - 1;
36511
36511
  const close = braceEnd(src, open);
36512
36512
  if (close < 0) continue;
36513
- const t = { kind: "record", name: m[1], file, lines: [lineAt4(at2), lineAt4(close)], ...goDoc(src, at2, m[1]) ? { doc: goDoc(src, at2, m[1]) } : {}, knows: [], choices: [], memberRanges: [] };
36513
+ const t = { kind: "record", name: m[1], file, lines: [lineAt5(at2), lineAt5(close)], ...goDoc(src, at2, m[1]) ? { doc: goDoc(src, at2, m[1]) } : {}, knows: [], choices: [], memberRanges: [] };
36514
36514
  for (const raw of src.slice(open + 1, close).split("\n")) {
36515
36515
  const f = raw.replace(/\/\/.*$/, "").replace(/`[^`]*`/g, "").trim().match(/^([A-Za-z_]\w*(?:\s*,\s*[A-Za-z_]\w*)*)\s+(\S.*)$/);
36516
36516
  if (f) for (const n of f[1].split(",")) t.knows.push(know(n.trim(), f[2].trim(), null, {}));
@@ -36525,7 +36525,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36525
36525
  const open = src.indexOf("{", at2);
36526
36526
  const close = open >= 0 ? braceEnd(src, open) : -1;
36527
36527
  t.kind = "thing";
36528
- t.memberRanges.push([lineAt4(at2), lineAt4(close >= 0 ? close : at2)]);
36528
+ t.memberRanges.push([lineAt5(at2), lineAt5(close >= 0 ? close : at2)]);
36529
36529
  }
36530
36530
  for (const m of src.matchAll(/func\s+New(\w+)\s*\(([^)]*)\)[^{]*\{/g)) {
36531
36531
  const t = byName.get(m[1]);
@@ -36559,19 +36559,19 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36559
36559
  const label = f[3] && /^"/.test(f[3].trim()) ? f[3].trim().slice(1, -1) : words14(f[1].replace(new RegExp(`^${name}`), "") || f[1]);
36560
36560
  choices.push(label);
36561
36561
  }
36562
- if (choices.length) out.push({ kind: "choices", name, file, lines: [lineAt4(at2), lineAt4(at2)], ...goDoc(src, at2, name) ? { doc: goDoc(src, at2, name) } : {}, knows: [], choices });
36562
+ if (choices.length) out.push({ kind: "choices", name, file, lines: [lineAt5(at2), lineAt5(at2)], ...goDoc(src, at2, name) ? { doc: goDoc(src, at2, name) } : {}, knows: [], choices });
36563
36563
  }
36564
36564
  return out;
36565
36565
  }
36566
36566
  function rustThings(src, file) {
36567
- const lineAt4 = lineFinder5(src);
36567
+ const lineAt5 = lineFinder5(src);
36568
36568
  const out = [];
36569
36569
  const byName = /* @__PURE__ */ new Map();
36570
36570
  for (const m of src.matchAll(/(?:^|\n)[ \t]*(?:#\[[^\]]*\]\s*)*(?:pub(?:\([^)]*\))?\s+)?(struct|enum)\s+(\w+)\s*(?:<[^>{]*>)?\s*(?:where[^{]*)?(\{|\(|;)/g)) {
36571
36571
  const at2 = m.index + (m[0].startsWith("\n") ? 1 : 0);
36572
36572
  const doc = docAbove4(src, at2);
36573
36573
  if (m[3] !== "{") {
36574
- const t2 = { kind: "record", name: m[2], file, lines: [lineAt4(at2), lineAt4(at2)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
36574
+ const t2 = { kind: "record", name: m[2], file, lines: [lineAt5(at2), lineAt5(at2)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
36575
36575
  out.push(t2);
36576
36576
  byName.set(m[2], t2);
36577
36577
  continue;
@@ -36580,7 +36580,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36580
36580
  const close = braceEnd(src, open);
36581
36581
  if (close < 0) continue;
36582
36582
  const body2 = ownLevel(src.slice(open + 1, close));
36583
- const t = { kind: m[1] === "enum" ? "choices" : "record", name: m[2], file, lines: [lineAt4(at2), lineAt4(close)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
36583
+ const t = { kind: m[1] === "enum" ? "choices" : "record", name: m[2], file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
36584
36584
  if (m[1] === "enum") {
36585
36585
  for (const v of splitParams2(body2.replace(/\/\/[^\n]*/g, "").replace(/#\[[^\]]*\]/g, ""))) {
36586
36586
  const n = v.trim().match(/^(\w+)/);
@@ -36604,7 +36604,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36604
36604
  if (/\bfn\s+\w+\s*(?:<[^>]*>)?\s*\(\s*&?(?:mut\s+)?self\b/.test(src.slice(at2, close))) {
36605
36605
  if (t.kind === "record") t.kind = "thing";
36606
36606
  }
36607
- t.memberRanges.push([lineAt4(at2), lineAt4(close)]);
36607
+ t.memberRanges.push([lineAt5(at2), lineAt5(close)]);
36608
36608
  const block = src.slice(at2, close);
36609
36609
  const fnNew = block.match(/fn\s+new\s*\(([^)]*)\)[^{;]*\{/);
36610
36610
  const fnOpen = fnNew ? fnNew.index + fnNew[0].length - 1 : -1;
@@ -36756,7 +36756,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36756
36756
  }
36757
36757
  function cThings(src, file) {
36758
36758
  const code3 = src.replace(/^[ \t]*#.*(?:\\\r?\n.*)*$/gm, (m) => m.replace(/[^\n]/g, " "));
36759
- const lineAt4 = lineFinder5(code3);
36759
+ const lineAt5 = lineFinder5(code3);
36760
36760
  const out = [];
36761
36761
  for (const m of code3.matchAll(/(?:^|\n)[ \t]*(typedef\s+)?(struct|union|enum)\b\s*(\w+)?\s*\{/g)) {
36762
36762
  const at2 = m.index + (m[0].startsWith("\n") ? 1 : 0);
@@ -36767,7 +36767,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36767
36767
  const name = alias || m[3];
36768
36768
  if (!name) continue;
36769
36769
  const doc = cDocAbove(code3, at2);
36770
- const t = { kind: m[2] === "enum" ? "choices" : "record", name, ...m[3] && m[3] !== name ? { tag: m[3] } : {}, file, lines: [lineAt4(at2), lineAt4(close)], ...doc ? { doc } : {}, knows: [], choices: [] };
36770
+ const t = { kind: m[2] === "enum" ? "choices" : "record", name, ...m[3] && m[3] !== name ? { tag: m[3] } : {}, file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: [] };
36771
36771
  const body2 = code3.slice(open + 1, close);
36772
36772
  if (m[2] === "enum") {
36773
36773
  t.choices = enumNames(splitParams2(body2.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "")).map((x) => (x.trim().match(/^(\w+)/) || [])[1]).filter(Boolean)).map((n) => words14(n));
@@ -36817,7 +36817,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36817
36817
  }
36818
36818
  function cppThings(src, file) {
36819
36819
  const code3 = src.replace(/^[ \t]*#.*(?:\\\r?\n.*)*$/gm, (m) => m.replace(/[^\n]/g, " "));
36820
- const lineAt4 = lineFinder5(code3);
36820
+ const lineAt5 = lineFinder5(code3);
36821
36821
  const out = [];
36822
36822
  const byName = /* @__PURE__ */ new Map();
36823
36823
  for (const m of code3.matchAll(/(?:^|\n)[ \t]*(?:template\s*<[^>{;]*>\s*)?(?:(class|struct|union)\s+(?:alignas\([^)]*\)\s*)?(?:[A-Z_][A-Z0-9_]*\s+)*(\w+)(?:\s+final)?\s*(?::[^{;]*)?|enum(?:\s+(?:class|struct))?\s+(\w+)(?:\s*:\s*[\w:]+)?\s*)\{/g)) {
@@ -36830,10 +36830,10 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36830
36830
  const body2 = code3.slice(open + 1, close);
36831
36831
  if (m[3]) {
36832
36832
  const vals = splitParams2(body2.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "")).map((x) => (x.trim().match(/^(\w+)/) || [])[1]).filter(Boolean);
36833
- out.push({ kind: "choices", name, file, lines: [lineAt4(at2), lineAt4(close)], ...doc ? { doc } : {}, knows: [], choices: enumNames(vals).map((n) => words14(n)) });
36833
+ out.push({ kind: "choices", name, file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: enumNames(vals).map((n) => words14(n)) });
36834
36834
  continue;
36835
36835
  }
36836
- const t = { kind: "record", name, file, lines: [lineAt4(at2), lineAt4(close)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
36836
+ const t = { kind: "record", name, file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
36837
36837
  let methods = false;
36838
36838
  const inits = {}, params = {};
36839
36839
  for (const mem of members(body2)) {
@@ -36872,7 +36872,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36872
36872
  if (brace < 0 || semi >= 0 && semi < brace || /[()]/.test(code3.slice(pClose + 1, brace).replace(/:\s*[\s\S]*$/, ""))) continue;
36873
36873
  methods = true;
36874
36874
  const bClose = braceEnd(code3, brace);
36875
- t.memberRanges.push([lineAt4(d.index), lineAt4(bClose >= 0 ? bClose : brace)]);
36875
+ t.memberRanges.push([lineAt5(d.index), lineAt5(bClose >= 0 ? bClose : brace)]);
36876
36876
  if (d[1] === name) cppCtor(code3.slice(pOpen + 1, pClose), (code3.slice(pClose + 1, brace).match(/^\s*(?:noexcept\s*)?:\s*([\s\S]+)$/) || [])[1], bClose > 0 ? code3.slice(brace + 1, bClose) : "", params, inits);
36877
36877
  }
36878
36878
  for (const k of t.knows) {
@@ -36903,7 +36903,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36903
36903
  for (const a of String(bodyText || "").matchAll(/(?:this->)?(\w+)\s*=\s*([^;\n]+);/g)) if (inits[a[1]] == null) inits[a[1]] = a[2];
36904
36904
  }
36905
36905
  function swiftThings(src, file) {
36906
- const lineAt4 = lineFinder5(src);
36906
+ const lineAt5 = lineFinder5(src);
36907
36907
  const out = [];
36908
36908
  const byName = /* @__PURE__ */ new Map();
36909
36909
  for (const m of src.matchAll(/(?:^|\n)[ \t]*(?:@\w+(?:\([^)\n]*\))?\s+)*(?:(?:public|private|internal|fileprivate|open|final|indirect|nonisolated)\s+)*(class|struct|enum|actor|protocol)\s+(\w+)(?:<[^>{\n]*>)?[ \t]*(?::[ \t]*([^{\n]+?))?[ \t]*\{/g)) {
@@ -36914,7 +36914,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36914
36914
  if (close < 0) continue;
36915
36915
  const doc = docAbove4(src, at2);
36916
36916
  const body2 = src.slice(open + 1, close);
36917
- const t = { kind: m[1] === "enum" ? "choices" : "record", name: m[2], file, lines: [lineAt4(at2), lineAt4(close)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
36917
+ const t = { kind: m[1] === "enum" ? "choices" : "record", name: m[2], file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
36918
36918
  const mems = members(body2, { newlines: true });
36919
36919
  if (m[1] === "enum") {
36920
36920
  for (const { head } of mems) {
@@ -36963,7 +36963,7 @@ function makeThingReaders({ words: words14, kindWords: kindWords3, startValue: s
36963
36963
  const at2 = m.index + (m[0].startsWith("\n") ? 1 : 0);
36964
36964
  const close = braceEnd(src, m.index + m[0].length - 1);
36965
36965
  if (close < 0) continue;
36966
- t.memberRanges.push([lineAt4(at2), lineAt4(close)]);
36966
+ t.memberRanges.push([lineAt5(at2), lineAt5(close)]);
36967
36967
  if (t.kind === "record" && /(?:^|\s)func\s/.test(src.slice(at2, close))) t.kind = "thing";
36968
36968
  }
36969
36969
  return out;
@@ -40249,13 +40249,13 @@ var Analyzer = class {
40249
40249
  const sawRecord = data.some((a) => a.recs?.length || a.recFields?.length);
40250
40250
  const sawCaller = data.some((a) => a.ident?.length);
40251
40251
  const sawInput = data.some((a) => a.input?.length || a.unknown?.length);
40252
- const baseName = String(name).split(".").pop();
40253
- if ((sawRecord || sawCaller) && (GUARDISH.test(baseName) || sawRecord && sawCaller)) st.unresolved = uniq(st.unresolved, [{ ...ev, says: `${name}(\u2026) might check who may see it` }]);
40252
+ const baseName2 = String(name).split(".").pop();
40253
+ if ((sawRecord || sawCaller) && (GUARDISH.test(baseName2) || sawRecord && sawCaller)) st.unresolved = uniq(st.unresolved, [{ ...ev, says: `${name}(\u2026) might check who may see it` }]);
40254
40254
  const out = joinAll(data.map(dataOf));
40255
- if (sawCaller && !GUARDISH.test(baseName)) out.clientFor = { says: `${name}(\u2026)`, file: ctx.file, line };
40255
+ if (sawCaller && !GUARDISH.test(baseName2)) out.clientFor = { says: `${name}(\u2026)`, file: ctx.file, line };
40256
40256
  const parts = String(name).split(".");
40257
40257
  const ownerName = parts.length > 1 ? parts[parts.length - 2] : "";
40258
- const dataLike = name !== "fetch" && !NOT_DATA_PACKAGE.test(calleeVal?.pkg ?? "") && !["path", "fs", "os", "url", "crypto", "util", "process", "console", "JSON", "Math", "Date", BUF].includes(parts[0]) && (LOOKUP_NAME.test(baseName) || parts.length > 1 && LOOKUP_OWNER.test(ownerName) && !/^(set|add|log|emit|send|push|on|use)$/.test(baseName));
40258
+ const dataLike = name !== "fetch" && !NOT_DATA_PACKAGE.test(calleeVal?.pkg ?? "") && !["path", "fs", "os", "url", "crypto", "util", "process", "console", "JSON", "Math", "Date", BUF].includes(parts[0]) && (LOOKUP_NAME.test(baseName2) || parts.length > 1 && LOOKUP_OWNER.test(ownerName) && !/^(set|add|log|emit|send|push|on|use)$/.test(baseName2));
40259
40259
  if ((sawInput || calleeVal?.recs?.length) && dataLike) out.unknown = uniq(out.unknown, [{ ...ev, says: `${name}(\u2026)` }]);
40260
40260
  if (calleeVal && hasData(calleeVal)) return join2(out, dataOf(calleeVal));
40261
40261
  return out;
@@ -42091,10 +42091,182 @@ ${model.settings.map((x) => ` Setting ${x.name}: ${settingWords(x, model)} (li
42091
42091
  return { ...base2, ...about, language: member ?? thing ? member?.language ?? model.files.find((f) => f.path === thing.file)?.language ?? null : model.files[0]?.language ?? null };
42092
42092
  }
42093
42093
 
42094
+ // src/trace-data.mjs
42095
+ var lineAt4 = (text2, index) => {
42096
+ let n = 1;
42097
+ for (let i = 0; i < index && i < text2.length; i++) if (text2.charCodeAt(i) === 10) n++;
42098
+ return n;
42099
+ };
42100
+ var lineOf6 = (text2, re) => {
42101
+ const lines = text2.split("\n");
42102
+ for (let i = 0; i < lines.length; i++) if (re.test(lines[i])) return i + 1;
42103
+ return null;
42104
+ };
42105
+ var esc2 = (s) => s.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
42106
+ var baseName = (path) => path.split("/").pop();
42107
+ var dirOf4 = (path) => path.includes("/") ? path.slice(0, path.lastIndexOf("/")) : "";
42108
+ function isManifest(path) {
42109
+ const n = baseName(path);
42110
+ return n === "package.json" || n === "go.mod" || n === "requirements.txt" || /\.csproj$/i.test(n);
42111
+ }
42112
+ function packagesIn(files) {
42113
+ const publishes = [], depends = [];
42114
+ for (const f of files) {
42115
+ if (!isManifest(f.path)) continue;
42116
+ const text2 = String(f.source ?? "");
42117
+ const n = baseName(f.path);
42118
+ try {
42119
+ if (n === "package.json") {
42120
+ const j = JSON.parse(text2);
42121
+ if (typeof j.name === "string" && j.name.trim()) publishes.push({ package: j.name, ...j.version ? { version: String(j.version) } : {}, file: f.path, line: lineOf6(text2, /^\s*"name"\s*:/), root: dirOf4(f.path) });
42122
+ for (const k of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) {
42123
+ for (const [name, version] of Object.entries(j[k] ?? {})) {
42124
+ depends.push({ package: name, version: String(version), ...k === "devDependencies" ? { dev: true } : {}, ...k === "peerDependencies" ? { peer: true } : {}, file: f.path, line: lineOf6(text2, new RegExp(`^\\s*"${esc2(name)}"\\s*:`)) });
42125
+ }
42126
+ }
42127
+ } else if (n === "go.mod") {
42128
+ const lines = text2.split("\n");
42129
+ let inRequire = false;
42130
+ lines.forEach((raw, i) => {
42131
+ const line = raw.replace(/\/\/.*$/, "").trim();
42132
+ let m;
42133
+ if (m = line.match(/^module\s+(\S+)/)) publishes.push({ package: m[1], file: f.path, line: i + 1, root: dirOf4(f.path) });
42134
+ else if (/^require\s*\($/.test(line)) inRequire = true;
42135
+ else if (inRequire && line === ")") inRequire = false;
42136
+ else if (m = inRequire ? line.match(/^(\S+)\s+(v\S+)/) : line.match(/^require\s+(\S+)\s+(v\S+)/)) depends.push({ package: m[1], version: m[2], file: f.path, line: i + 1 });
42137
+ });
42138
+ } else if (n === "requirements.txt") {
42139
+ text2.split("\n").forEach((raw, i) => {
42140
+ const line = raw.replace(/#.*/, "").trim();
42141
+ if (!line || line.startsWith("-")) return;
42142
+ const m = line.match(/^([A-Za-z0-9][A-Za-z0-9_.-]*)(?:\[[^\]]*\])?\s*(.*)$/);
42143
+ if (m) depends.push({ package: m[1].toLowerCase().replace(/_/g, "-"), ...m[2] ? { version: m[2].replace(/\s*;.*$/, "").trim() } : {}, file: f.path, line: i + 1 });
42144
+ });
42145
+ } else {
42146
+ for (const m of text2.matchAll(/<PackageReference\s+Include="([^"]+)"(?:\s+Version="([^"]+)")?/g)) depends.push({ package: m[1], ...m[2] ? { version: m[2] } : {}, file: f.path, line: lineAt4(text2, m.index) });
42147
+ const id2 = text2.match(/<PackageId>\s*([^<\s]+)\s*<\/PackageId>/);
42148
+ if (id2) publishes.push({ package: id2[1], file: f.path, line: lineAt4(text2, id2.index), root: dirOf4(f.path) });
42149
+ }
42150
+ } catch {
42151
+ }
42152
+ }
42153
+ return { publishes, depends };
42154
+ }
42155
+ var LOCAL_VERSION = /^(workspace:|file:|link:|portal:|\.{0,2}\/|git\+|github:|https?:)/;
42156
+ var KEY = "([A-Za-z_][A-Za-z0-9_]*)";
42157
+ var Q = `["'\`]`;
42158
+ var SETTING_READS = [
42159
+ new RegExp(`\\bprocess\\.env\\.${KEY}`, "g"),
42160
+ new RegExp(`\\bprocess\\.env\\[\\s*${Q}${KEY}${Q}\\s*\\]`, "g"),
42161
+ new RegExp(`\\bimport\\.meta\\.env\\.${KEY}`, "g"),
42162
+ new RegExp(`\\bDeno\\.env\\.get\\(\\s*${Q}${KEY}${Q}`, "g"),
42163
+ new RegExp(`\\b(?:os\\.)?environ(?:\\.get)?\\s*[\\[(]\\s*${Q}${KEY}${Q}`, "g"),
42164
+ new RegExp(`\\bos\\.getenv\\(\\s*${Q}${KEY}${Q}`, "g"),
42165
+ new RegExp(`\\bos\\.(?:Getenv|LookupEnv)\\(\\s*"${KEY}"`, "g"),
42166
+ new RegExp(`\\bSystem\\.getenv\\(\\s*"${KEY}"`, "g"),
42167
+ new RegExp(`\\bEnvironment\\.GetEnvironmentVariable\\(\\s*"${KEY}"`, "g"),
42168
+ new RegExp(`\\bENV(?:\\.fetch\\(\\s*|\\[\\s*)${Q}${KEY}${Q}`, "g"),
42169
+ new RegExp(`\\benv::var(?:_os)?\\(\\s*"${KEY}"`, "g"),
42170
+ new RegExp(`\\bgetenv\\(\\s*${Q}${KEY}${Q}`, "g"),
42171
+ new RegExp(`\\$_ENV\\[\\s*${Q}${KEY}${Q}`, "g")
42172
+ ];
42173
+ var isGenericSetting = (key) => GENERIC_SETTINGS.has(key) || /^(VERCEL_|EAS_BUILD|GITHUB_|RUNNER_|npm_|NETLIFY|RENDER_|RAILWAY_|FLY_|HEROKU_|AWS_LAMBDA_|K_SERVICE|KUBERNETES_)/.test(key);
42174
+ 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"]);
42175
+ function settingsIn(files) {
42176
+ const out = [];
42177
+ for (const f of files) {
42178
+ if (isManifest(f.path) || /\.sql$/i.test(f.path)) continue;
42179
+ const text2 = String(f.source ?? "");
42180
+ if (!/env/i.test(text2)) continue;
42181
+ const seen = /* @__PURE__ */ new Set();
42182
+ for (const re of SETTING_READS) {
42183
+ for (const m of text2.matchAll(re)) {
42184
+ const line = lineAt4(text2, m.index);
42185
+ const k = `${m[1]}|${line}`;
42186
+ if (seen.has(k)) continue;
42187
+ seen.add(k);
42188
+ out.push({ key: m[1], file: f.path, line });
42189
+ }
42190
+ }
42191
+ }
42192
+ return out.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.key.localeCompare(b.key));
42193
+ }
42194
+ var NAME = '((?:[`"\\[]?[A-Za-z_][\\w$]*[`"\\]]?\\.){0,2}[`"\\[]?[A-Za-z_][\\w$]*[`"\\]]?)';
42195
+ var NOT_TABLES = /* @__PURE__ */ new Set(["select", "set", "where", "values", "dual", "lateral", "unnest", "only", "table", "if", "exists", "not", "the", "a", "an", "my", "your", "this", "that", "each", "all", "json_table", "information_schema", "pg_catalog", "sys"]);
42196
+ function tableName(raw) {
42197
+ const name = raw.replace(/[`"[\]]/g, "");
42198
+ return { table: name.split(".").pop().toLowerCase(), name };
42199
+ }
42200
+ function usesIn(sql, offsetOf, push) {
42201
+ const re = new RegExp(`\\b(DELETE\\s+FROM|INSERT\\s+(?:OR\\s+\\w+\\s+)?INTO|MERGE\\s+INTO|UPDATE|FROM|JOIN)\\s+${NAME}(\\s*\\()?`, "gi");
42202
+ for (const m of sql.matchAll(re)) {
42203
+ const kw = m[1].toUpperCase().replace(/\s+/g, " ");
42204
+ if (m[3] && (kw === "FROM" || kw === "JOIN")) continue;
42205
+ const { table, name } = tableName(m[2]);
42206
+ if (NOT_TABLES.has(table) || NOT_TABLES.has(name.toLowerCase())) continue;
42207
+ if (kw === "UPDATE" && (/\b(DO|FOR|KEY)\s*$/i.test(sql.slice(Math.max(0, m.index - 12), m.index)) || !/^\s*(?:(?:AS\s+)?\w+\s+)?SET\b/i.test(sql.slice(m.index + m[0].length)))) continue;
42208
+ push({ table, name, access: kw === "FROM" || kw === "JOIN" ? "reads" : "writes", at: offsetOf(m.index) });
42209
+ }
42210
+ }
42211
+ var SQL_SHAPES = [
42212
+ /^\s*SELECT\b[\s\S]*?\bFROM\s/i,
42213
+ /^\s*INSERT\s+(?:OR\s+\w+\s+)?INTO\s/i,
42214
+ /^\s*UPDATE\s+[\w."`[\]]+\s+(?:(?:AS\s+)?\w+\s+)?SET\s/i,
42215
+ /^\s*DELETE\s+FROM\s/i,
42216
+ /^\s*WITH\s+(?:RECURSIVE\s+)?\w+\s+AS\s*\(/i,
42217
+ /^\s*MERGE\s+INTO\s/i
42218
+ ];
42219
+ var isSql = (text2) => SQL_SHAPES.some((re) => re.test(text2));
42220
+ var CODE_STRINGS = /"""([\s\S]*?)"""|'''([\s\S]*?)'''|`((?:\\[\s\S]|[^`\\])*)`|"((?:\\.|[^"\\\n])*)"|'((?:\\.|[^'\\\n])*)'/g;
42221
+ function tablesIn(files) {
42222
+ const out = [];
42223
+ for (const f of files) {
42224
+ if (isManifest(f.path)) continue;
42225
+ const text2 = String(f.source ?? "");
42226
+ const push = (u) => out.push({ table: u.table, name: u.name, access: u.access, file: f.path, line: lineAt4(text2, u.at), ...u.end != null ? { lines: [lineAt4(text2, u.at), lineAt4(text2, u.end)] } : {} });
42227
+ if (/\.sql$/i.test(f.path)) {
42228
+ const clean = text2.replace(/--[^\n]*/g, (s) => " ".repeat(s.length)).replace(/\/\*[\s\S]*?\*\//g, (s) => s.replace(/[^\n]/g, " "));
42229
+ const ddl = new RegExp(`\\b(CREATE(?:\\s+OR\\s+REPLACE)?(?:\\s+(?:TEMP|TEMPORARY|UNLOGGED|GLOBAL|LOCAL))*\\s+TABLE|ALTER\\s+TABLE|DROP\\s+TABLE)(?:\\s+IF\\s+(?:NOT\\s+)?EXISTS)?(?:\\s+ONLY)?\\s+${NAME}`, "gi");
42230
+ const ddlSpans = [];
42231
+ for (const m of clean.matchAll(ddl)) {
42232
+ const { table, name } = tableName(m[2]);
42233
+ if (NOT_TABLES.has(table)) continue;
42234
+ const kw = m[1].toUpperCase();
42235
+ if (/TEMP/.test(kw)) continue;
42236
+ const end2 = clean.indexOf(";", m.index);
42237
+ const stop = end2 < 0 ? clean.length : end2;
42238
+ ddlSpans.push([m.index, stop]);
42239
+ push({ table, name, access: kw.startsWith("CREATE") ? "creates" : kw.startsWith("ALTER") ? "alters" : "drops", at: m.index, end: stop });
42240
+ }
42241
+ const roles = [...clean.matchAll(/\b(?:GRANT|REVOKE)\b[^;]*/gi)].map((m) => [m.index, m.index + m[0].length]);
42242
+ const skip = [...ddlSpans, ...roles];
42243
+ usesIn(clean, (i) => i, (u) => {
42244
+ if (!skip.some(([a, b]) => u.at >= a && u.at <= b)) push(u);
42245
+ });
42246
+ continue;
42247
+ }
42248
+ if (!/\b(SELECT|INSERT|UPDATE|DELETE|MERGE)\b/i.test(text2)) continue;
42249
+ for (const m of text2.matchAll(CODE_STRINGS)) {
42250
+ const body2 = m[1] ?? m[2] ?? m[3] ?? m[4] ?? m[5] ?? "";
42251
+ if (!isSql(body2)) continue;
42252
+ const start = m.index + m[0].indexOf(body2);
42253
+ usesIn(body2, (i) => start + i, push);
42254
+ }
42255
+ }
42256
+ const seen = /* @__PURE__ */ new Set();
42257
+ return out.filter((t) => {
42258
+ const k = `${t.file}|${t.line}|${t.table}|${t.access}`;
42259
+ if (seen.has(k)) return false;
42260
+ seen.add(k);
42261
+ return true;
42262
+ }).sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.table.localeCompare(b.table));
42263
+ }
42264
+ var DEFINES = /* @__PURE__ */ new Set(["creates", "alters", "drops"]);
42265
+
42094
42266
  // src/trace.mjs
42095
42267
  var TRACE_SCHEMA = "thunder-trace-v1";
42096
42268
  var TRACE_IMPACT_SCHEMA = "thunder-trace-impact-v1";
42097
- var TRACE_RULES_VERSION = "1";
42269
+ var TRACE_RULES_VERSION = "2";
42098
42270
  function isTestFile(file) {
42099
42271
  return /(^|\/)(tests?|__tests__|specs?|__mocks__|mocks?|fixtures?|__fixtures__|e2e|testdata|test-data)\//i.test(file) || /\.(test|spec|e2e)\.[a-z0-9]+$/i.test(file) || /(^|\/)test_[^/]+\.py$/.test(file) || /_test\.(go|py|rb|exs?)$/.test(file) || /(Tests?|Spec|IT)\.(cs|java|kt|scala)$/.test(file);
42100
42272
  }
@@ -42114,7 +42286,8 @@ function buildTrace(repos) {
42114
42286
  const model = thunderModel(r.files, { name: r.name });
42115
42287
  const facts = serviceFacts(model, r.files);
42116
42288
  const real = (x) => !isTestFile(x.file);
42117
- const testItems = ["routes", "listeners", "requests", "publishes"].reduce((n, k) => n + facts[k].filter((x) => !real(x)).length, 0);
42289
+ const data = dataFacts(r.files, model);
42290
+ const testItems = ["routes", "listeners", "requests", "publishes"].reduce((n, k) => n + facts[k].filter((x) => !real(x)).length, 0) + data.testItems;
42118
42291
  return {
42119
42292
  name: r.name,
42120
42293
  sha: r.sha ?? null,
@@ -42126,11 +42299,35 @@ function buildTrace(repos) {
42126
42299
  requests: facts.requests.filter(real),
42127
42300
  publishes: facts.publishes.filter(real),
42128
42301
  unknown: facts.unknown.filter(real),
42302
+ packages: data.packages,
42303
+ settings: data.settings,
42304
+ tables: data.tables,
42129
42305
  testItems
42130
42306
  };
42131
42307
  });
42132
42308
  return linkRepos(read);
42133
42309
  }
42310
+ function memberAt(model, file, line) {
42311
+ let best = null;
42312
+ for (const m of model.members) {
42313
+ if (m.file !== file || !m.lines || line < m.lines[0] || line > m.lines[1]) continue;
42314
+ if (!best || m.lines[1] - m.lines[0] < best.lines[1] - best.lines[0]) best = m;
42315
+ }
42316
+ return best ? { member: best.id, label: best.label } : { member: null, label: file.split("/").pop() };
42317
+ }
42318
+ function dataFacts(files, model) {
42319
+ const real = (x) => !isTestFile(x.file);
42320
+ const pk = packagesIn(files), settings = settingsIn(files), tables = tablesIn(files);
42321
+ const place = (x) => ({ ...x, ...memberAt(model, x.file, x.line) });
42322
+ const manifest = (x) => ({ ...x, member: null, label: x.file });
42323
+ const testItems = [...pk.publishes, ...pk.depends, ...settings, ...tables].filter((x) => !real(x)).length;
42324
+ return {
42325
+ packages: { publishes: pk.publishes.filter(real).map(manifest), depends: pk.depends.filter(real).map(manifest) },
42326
+ settings: settings.filter(real).map(place),
42327
+ tables: tables.filter(real).map((t) => /\.sql$/i.test(t.file) ? { ...t, member: null, label: t.file } : place(t)),
42328
+ testItems
42329
+ };
42330
+ }
42134
42331
  function linkRepos(read) {
42135
42332
  const links = [], notLinked = [];
42136
42333
  for (const repo of read) {
@@ -42172,7 +42369,33 @@ function linkRepos(read) {
42172
42369
  if (!found) notLinked.push({ kind: "event", call: `event ${p.event}`, from, why: `no listener Thunder read in the traced repositories waits for ${p.event}` });
42173
42370
  }
42174
42371
  }
42175
- const sortKey = (l) => `${l.from.cite}|${l.to?.cite ?? ""}|${l.kind}|${l.call ?? l.event ?? l.path ?? ""}`;
42372
+ const pk = (r) => r.packages ?? { publishes: [], depends: [] };
42373
+ const publishers = /* @__PURE__ */ new Map();
42374
+ for (const repo of read) for (const p of pk(repo).publishes) (publishers.get(p.package) ?? publishers.set(p.package, []).get(p.package)).push({ repo, p });
42375
+ for (const repo of read) {
42376
+ const own = new Set(pk(repo).publishes.map((p) => p.package));
42377
+ for (const d of pk(repo).depends) {
42378
+ if (own.has(d.package)) continue;
42379
+ const pubs = (publishers.get(d.package) ?? []).filter((x) => x.repo !== repo);
42380
+ const byRepo = [...new Map(pubs.map((x) => [x.repo.name, x])).values()];
42381
+ if (byRepo.length === 1) links.push({ kind: "package", package: d.package, version: d.version ?? null, ...d.dev ? { dev: true } : {}, from: end(repo, d), to: end(byRepo[0].repo, byRepo[0].p) });
42382
+ else if (byRepo.length > 1) notLinked.push({ kind: "package", call: `package ${d.package}`, from: end(repo, d), why: `${byRepo.length} repositories publish ${d.package} (${byRepo.map((x) => x.repo.name).join(", ")}), so none is chosen` });
42383
+ }
42384
+ }
42385
+ const tb = (r) => r.tables ?? [];
42386
+ const creators = /* @__PURE__ */ new Map();
42387
+ for (const repo of read) for (const t of tb(repo)) if (t.access === "creates") (creators.get(t.table) ?? creators.set(t.table, []).get(t.table)).push({ repo, t });
42388
+ for (const repo of read) {
42389
+ const own = new Set(tb(repo).filter((t) => t.access === "creates").map((t) => t.table));
42390
+ for (const t of tb(repo)) {
42391
+ if (DEFINES.has(t.access) || own.has(t.table)) continue;
42392
+ const owners = [...new Map((creators.get(t.table) ?? []).filter((x) => x.repo !== repo).map((x) => [x.repo.name, x])).values()];
42393
+ if (owners.length === 1) links.push({ kind: "data", table: t.table, access: t.access, from: end(repo, t), to: end(owners[0].repo, owners[0].t) });
42394
+ else if (owners.length > 1) notLinked.push({ kind: "data", call: `table ${t.name}`, from: end(repo, t), why: `${owners.length} repositories create a table named ${t.table} (${owners.map((x) => x.repo.name).join(", ")}), so none is chosen` });
42395
+ }
42396
+ }
42397
+ const shared = sharedFacts(read);
42398
+ const sortKey = (l) => `${l.from.cite}|${l.to?.cite ?? ""}|${l.kind}|${l.call ?? l.event ?? l.path ?? l.package ?? l.table ?? ""}`;
42176
42399
  const once = (xs) => {
42177
42400
  const seen = /* @__PURE__ */ new Set();
42178
42401
  return xs.filter((x) => {
@@ -42184,10 +42407,29 @@ function linkRepos(read) {
42184
42407
  };
42185
42408
  links.splice(0, links.length, ...once(links).sort((a, b) => sortKey(a).localeCompare(sortKey(b))));
42186
42409
  notLinked.splice(0, notLinked.length, ...once(notLinked).sort((a, b) => sortKey(a).localeCompare(sortKey(b))));
42187
- const repos = read.map(({ unknown, ...r }) => ({ ...r, unknown: unknown ?? [] }));
42188
- const body2 = { schema: TRACE_SCHEMA, rulesVersion: TRACE_RULES_VERSION, repos, links, notLinked };
42410
+ const repos = read.map(({ unknown, ...r }) => ({ ...r, unknown: unknown ?? [], packages: pk(r), settings: r.settings ?? [], tables: tb(r) }));
42411
+ const body2 = { schema: TRACE_SCHEMA, rulesVersion: TRACE_RULES_VERSION, repos, links, notLinked, shared };
42189
42412
  return { ...body2, fingerprint: sha256(JSON.stringify(body2)) };
42190
42413
  }
42414
+ function sharedFacts(read) {
42415
+ const group = (items) => {
42416
+ const m = /* @__PURE__ */ new Map();
42417
+ for (const [k, repo, x] of items) (m.get(k) ?? m.set(k, []).get(k)).push({ repo, x });
42418
+ return m;
42419
+ };
42420
+ const manyRepos = (xs) => new Set(xs.map((y) => y.repo.name)).size > 1;
42421
+ const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
42422
+ 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(([key, xs]) => ({ key, readers: xs.map(({ repo, x }) => end(repo, x)) }));
42423
+ 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 })) }));
42424
+ const drift = [];
42425
+ 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)) {
42426
+ const versions = group(xs.map(({ repo, x }) => [x.version, repo, x]));
42427
+ const perRepo = new Set([...group(xs.map(({ repo, x }) => [repo.name, repo, x])).values()].map((ys) => [...new Set(ys.map((y) => y.x.version))].sort().join("|")));
42428
+ if (!manyRepos(xs) || versions.size < 2 || perRepo.size < 2) continue;
42429
+ drift.push({ package: name, versions: [...versions.entries()].sort(byKey).map(([version, ys]) => ({ version, at: ys.map(({ repo, x }) => end(repo, x)) })) });
42430
+ }
42431
+ return { settings, tables, drift };
42432
+ }
42191
42433
  var methodOk = (route, req) => route === req || route === "ANY" || route === "ALL";
42192
42434
  var within = (line, ranges) => line != null && ranges.some(([a, b]) => line >= a && line <= b);
42193
42435
  var overlaps = (lines, ranges) => !!lines && ranges.some(([a, b]) => a <= lines[1] && b >= lines[0]);
@@ -42195,14 +42437,16 @@ function traceImpact(trace, changes) {
42195
42437
  const byName = new Map(trace.repos.map((r) => [r.name, r]));
42196
42438
  const findings2 = [];
42197
42439
  const touched = [];
42440
+ const packagesDone = /* @__PURE__ */ new Set();
42441
+ const usesElsewhere = (repo, table) => trace.repos.filter((o) => o.name !== repo.name).flatMap((o) => (o.tables ?? []).filter((t) => t.table === table && !DEFINES.has(t.access)).map((t) => ({ ...end(o, t), how: `${t.access} ${t.name}` })));
42198
42442
  for (const c of changes) {
42199
42443
  const repo = byName.get(c.repo);
42200
42444
  if (!repo) continue;
42445
+ const found = findings2.length;
42201
42446
  const hit = (x) => x.file === c.file && (c.status === "added" || overlaps(x.lines, c.ranges) || within(x.line, c.ranges));
42202
42447
  const routes = repo.routes.filter(hit), listeners = repo.listeners.filter(hit);
42203
42448
  const requests = repo.requests.filter((x) => x.file === c.file && (c.status === "added" || within(x.line, c.ranges) || overlaps(x.lines, c.ranges)));
42204
42449
  const publishes = repo.publishes.filter((x) => x.file === c.file && (c.status === "added" || within(x.line, c.ranges) || overlaps(x.lines, c.ranges)));
42205
- if (routes.length || listeners.length || requests.length || publishes.length || c.before) touched.push({ repo: c.repo, file: c.file, status: c.status });
42206
42450
  for (const r of routes) {
42207
42451
  const callers = trace.links.filter((l) => l.kind === "http" && l.to.repo === repo.name && l.to.member === r.member);
42208
42452
  findings2.push({ risk: callers.length ? "high" : "low", kind: "route-changed", says: callers.length ? `${r.method} ${r.path} changed, and ${count(callers.length, "caller")} in other repositories ${callers.length === 1 ? "depends" : "depend"} on it` : `${r.method} ${r.path} changed; no traced repository calls it`, at: end(repo, r), dependents: callers.map((l) => ({ ...l.from, how: l.base === "computed" ? "matched by path; the base address is set when it runs" : l.base === "this app" ? "same path from another app" : `through ${l.base}` })) });
@@ -42219,6 +42463,35 @@ function traceImpact(trace, changes) {
42219
42463
  const senders = trace.links.filter((l) => l.kind === "event" && l.to.repo === repo.name && l.to.member === x.member);
42220
42464
  findings2.push({ risk: "low", kind: "listener-changed", says: `the handler for ${x.event} changed${senders.length ? `; ${count(senders.length, "publisher")} in other repositories ${senders.length === 1 ? "sends" : "send"} it` : ""}`, at: end(repo, x), dependents: senders.map((l) => ({ ...l.from, how: `publishes ${x.event}` })) });
42221
42465
  }
42466
+ const lineHit = (x) => x.file === c.file && (c.status === "added" || overlaps(x.lines, c.ranges) || within(x.line, c.ranges));
42467
+ const tablesHere = (repo.tables ?? []).filter(lineHit);
42468
+ for (const t of tablesHere.filter((x) => x.access === "creates" || x.access === "alters")) {
42469
+ const users = trace.links.filter((l) => l.kind === "data" && l.to.repo === repo.name && l.table === t.table);
42470
+ findings2.push({ risk: users.length ? "high" : "low", kind: "table-changed", says: users.length ? `the ${t.name} table's ${t.access === "creates" ? "definition" : "ALTER TABLE"} changed, and ${count(users.length, "place")} in other repositories ${users.length === 1 ? "uses" : "use"} the table` : `the ${t.name} table's ${t.access === "creates" ? "definition" : "ALTER TABLE"} changed; no traced repository uses the table`, at: end(repo, t), dependents: users.map((l) => ({ ...l.from, how: `${l.access} ${t.table}` })) });
42471
+ }
42472
+ for (const t of tablesHere.filter((x) => x.access === "drops")) {
42473
+ const users = usesElsewhere(repo, t.table);
42474
+ findings2.push({ risk: users.length ? "high" : "low", kind: "table-dropped", says: users.length ? `DROP TABLE ${t.name}, but ${count(users.length, "place")} in other repositories still ${users.length === 1 ? "uses" : "use"} it` : `DROP TABLE ${t.name}; no traced repository uses it`, at: end(repo, t), dependents: users });
42475
+ }
42476
+ for (const t of tablesHere.filter((x) => !DEFINES.has(x.access))) {
42477
+ const l = trace.links.find((x) => x.kind === "data" && x.from.repo === repo.name && x.from.file === t.file && x.from.line === t.line && x.table === t.table);
42478
+ if (l) findings2.push({ risk: "medium", kind: "query-changed", says: `SQL that ${t.access} ${t.name} changed; the table is created in ${l.to.repo}`, at: end(repo, t), dependents: [{ ...l.to, how: `creates ${t.table}` }] });
42479
+ }
42480
+ for (const k of (repo.settings ?? []).filter(lineHit)) {
42481
+ const others = (trace.shared?.settings?.find((x) => x.key === k.key)?.readers ?? []).filter((r) => r.repo !== repo.name);
42482
+ if (others.length) findings2.push({ risk: "low", kind: "setting-changed", says: `code that reads the setting ${k.key} changed; ${count(new Set(others.map((o) => o.repo)).size, "other repository")} ${new Set(others.map((o) => o.repo)).size === 1 ? "reads" : "read"} it too`, at: end(repo, k), dependents: others.map((o) => ({ ...o, how: `reads ${k.key}` })) });
42483
+ }
42484
+ if (!isTestFile(c.file)) {
42485
+ for (const p of repo.packages?.publishes ?? []) {
42486
+ if (p.root && c.file !== p.root && !c.file.startsWith(`${p.root}/`)) continue;
42487
+ const key = `${repo.name}|${p.package}`;
42488
+ if (packagesDone.has(key)) continue;
42489
+ const deps = trace.links.filter((l) => l.kind === "package" && l.to.repo === repo.name && l.package === p.package);
42490
+ if (!deps.length) continue;
42491
+ packagesDone.add(key);
42492
+ 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}` : ""}` })) });
42493
+ }
42494
+ }
42222
42495
  if (c.before) {
42223
42496
  const nowRoutes = new Set(repo.routes.filter((r) => r.file === c.file).map((r) => `${r.method} ${r.path}`));
42224
42497
  for (const r of c.before.routes || []) {
@@ -42239,7 +42512,14 @@ function traceImpact(trace, changes) {
42239
42512
  }
42240
42513
  findings2.push({ risk: ls.length ? "high" : "low", kind: "event-removed", says: ls.length ? `${p.event} is no longer published here, but ${count(ls.length, "listener")} in other repositories ${ls.length === 1 ? "waits" : "wait"} for it` : `${p.event} is no longer published here; nothing else listens for it`, at: { repo: repo.name, file: c.file, line: p.line, label: p.label, cite: `${cite(repo, p)} (before the change)` }, dependents: ls });
42241
42514
  }
42515
+ const createsNow = new Set((repo.tables ?? []).filter((t) => t.access === "creates").map((t) => t.table));
42516
+ for (const t of (c.before.tables || []).filter((x) => x.access === "creates")) {
42517
+ if (createsNow.has(t.table)) continue;
42518
+ const users = usesElsewhere(repo, t.table);
42519
+ findings2.push({ risk: users.length ? "high" : "low", kind: "table-removed", says: users.length ? `the ${t.name} table is no longer created here, but ${count(users.length, "place")} in other repositories still ${users.length === 1 ? "uses" : "use"} it` : `the ${t.name} table is no longer created here; no traced repository uses it`, at: { repo: repo.name, file: c.file, line: t.line, label: t.file, cite: `${cite(repo, t)} (before the change)` }, dependents: users });
42520
+ }
42242
42521
  }
42522
+ if (findings2.length > found || routes.length || listeners.length || requests.length || publishes.length || c.before) touched.push({ repo: c.repo, file: c.file, status: c.status });
42243
42523
  }
42244
42524
  const rank = { high: 0, medium: 1, low: 2 };
42245
42525
  findings2.sort((a, b) => rank[a.risk] - rank[b.risk] || a.at.cite.localeCompare(b.at.cite));
@@ -42250,10 +42530,14 @@ function traceImpactOf(trace, term) {
42250
42530
  const t = String(term).trim();
42251
42531
  const changes = [];
42252
42532
  const matched = [];
42253
- const http = t.match(/^(?:(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|ANY)\s+)?(\/\S*)$/i);
42254
- const place = t.match(/^([^:\s]+):([^:\s]+?)(?::(\d+))?$/);
42533
+ const pre = t.match(/^(table|setting|package):\s*(.+)$/i);
42534
+ const data = pre && !byNameOf(trace, pre[1]) ? { kind: pre[1].toLowerCase(), name: pre[2].trim() } : null;
42535
+ const http = !data && t.match(/^(?:(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|ANY)\s+)?(\/\S*)$/i);
42536
+ const place = !data && t.match(/^([^:\s]+):([^:\s]+?)(?::(\d+))?$/);
42255
42537
  for (const repo of trace.repos) {
42256
- if (http) {
42538
+ if (data) {
42539
+ dataChanges(repo, data, changes, matched);
42540
+ } else if (http) {
42257
42541
  const segs = http[2].split("/").filter(Boolean).map((s) => /^(:\w+|\{[^}]+\}|\*)$/.test(s) ? "*" : s);
42258
42542
  for (const r2 of repo.routes) if ((!http[1] || methodOk(r2.method, http[1].toUpperCase())) && pathMatch(r2.segs, segs) >= 0 && r2.segs.length === segs.length) {
42259
42543
  changes.push({ repo: repo.name, file: r2.file, ranges: [r2.lines ?? [r2.line, r2.line]], status: "changed" });
@@ -42275,14 +42559,48 @@ function traceImpactOf(trace, term) {
42275
42559
  }
42276
42560
  }
42277
42561
  }
42562
+ let asked = data;
42563
+ if (!data && !http && !(place && byNameOf(trace, place[1])) && !changes.length) {
42564
+ for (const kind of ["table", "setting", "package"]) {
42565
+ for (const repo of trace.repos) dataChanges(repo, { kind, name: t }, changes, matched);
42566
+ if (changes.length) {
42567
+ asked = { kind, name: t };
42568
+ break;
42569
+ }
42570
+ }
42571
+ }
42278
42572
  const r = traceImpact(trace, changes);
42279
- if (!http && !(place && byNameOf(trace, place[1]))) r.findings = r.findings.filter((f) => /^(event-|listener-)/.test(f.kind) && f.says.includes(t));
42573
+ if (asked) {
42574
+ const kinds = { table: /^(table-|query-)/, setting: /^setting-/, package: /^package-/ }[asked.kind];
42575
+ r.findings = r.findings.filter((f) => kinds.test(f.kind));
42576
+ } else if (!http && !(place && byNameOf(trace, place[1]))) {
42577
+ r.findings = r.findings.filter((f) => /^(event-|listener-)/.test(f.kind) && f.says.includes(t));
42578
+ }
42280
42579
  return { ...r, term: t, matched };
42281
42580
  }
42581
+ function dataChanges(repo, ask, changes, matched) {
42582
+ if (ask.kind === "table") {
42583
+ const want = ask.name.replace(/[`"[\]]/g, "").split(".").pop().toLowerCase();
42584
+ for (const x of (repo.tables ?? []).filter((y) => y.table === want && (y.access === "creates" || y.access === "alters"))) {
42585
+ changes.push({ repo: repo.name, file: x.file, ranges: [[x.line, x.line]], status: "changed" });
42586
+ matched.push(`${repo.name}: ${x.access} table ${x.name}`);
42587
+ }
42588
+ } else if (ask.kind === "setting") {
42589
+ for (const x of (repo.settings ?? []).filter((y) => y.key === ask.name)) {
42590
+ changes.push({ repo: repo.name, file: x.file, ranges: [[x.line, x.line]], status: "changed" });
42591
+ matched.push(`${repo.name}: reads setting ${x.key}`);
42592
+ }
42593
+ } else {
42594
+ for (const x of (repo.packages?.publishes ?? []).filter((y) => y.package === ask.name)) {
42595
+ changes.push({ repo: repo.name, file: x.file, ranges: [[x.line, x.line]], status: "changed" });
42596
+ matched.push(`${repo.name}: publishes package ${x.package}`);
42597
+ }
42598
+ }
42599
+ }
42282
42600
  var byNameOf = (trace, name) => trace.repos.some((r) => r.name === name);
42283
42601
  function renderImpact(r) {
42284
42602
  const out = [];
42285
- if (r.matched && !r.matched.length) return `"${r.term}" matched nothing: no route, event, or file by that name in the traced repositories.`;
42603
+ if (r.matched && !r.matched.length) return `"${r.term}" matched nothing: no route, event, file, table, setting, or package by that name in the traced repositories.`;
42286
42604
  const high = r.findings.filter((f) => f.risk === "high").length;
42287
42605
  out.push(r.findings.length ? `Thunder Trace impact: ${count(r.findings.length, "finding")}, ${high} high risk. Stops at the first hop.` : `Thunder Trace impact: nothing this change touches is called from, or calls into, another traced repository.`);
42288
42606
  if (r.matched) out.push(`Read "${r.term}" as: ${r.matched.join("; ")}`);
@@ -42316,7 +42634,7 @@ function shebangShell(full, size) {
42316
42634
  }
42317
42635
  }
42318
42636
  var MANIFEST = /^(go\.mod|package\.json|tsconfig\.json|jsconfig\.json)$/;
42319
- function collectReadableFiles(root, { maxFiles = 5e3, maxFileBytes = 4e5, manifests = false, templates = false } = {}) {
42637
+ function collectReadableFiles(root, { maxFiles = 5e3, maxFileBytes = 4e5, manifests = false, manifestNames = MANIFEST, templates = false } = {}) {
42320
42638
  const out = [];
42321
42639
  const walk = (dir) => {
42322
42640
  let names;
@@ -42337,7 +42655,7 @@ function collectReadableFiles(root, { maxFiles = 5e3, maxFileBytes = 4e5, manife
42337
42655
  }
42338
42656
  const path = (0, import_node_path.relative)(root, full).split("\\").join("/");
42339
42657
  if (st.isDirectory()) walk(full);
42340
- else if (manifests && MANIFEST.test(name) && st.size <= maxFileBytes) out.push({ path, source: (0, import_node_fs.readFileSync)(full, "utf8"), manifest: true });
42658
+ else if (manifests && manifestNames.test(name) && st.size <= maxFileBytes) out.push({ path, source: (0, import_node_fs.readFileSync)(full, "utf8"), manifest: true });
42341
42659
  else if (templates && /\.component\.html$/i.test(name) && st.size <= maxFileBytes) out.push({ path, source: (0, import_node_fs.readFileSync)(full, "utf8"), template: true });
42342
42660
  else if (readableLanguage(path) || !name.includes(".") && shebangShell(full, st.size)) {
42343
42661
  out.push(st.size > maxFileBytes ? { path, source: "", size: st.size } : { path, source: (0, import_node_fs.readFileSync)(full, "utf8") });
@@ -42352,6 +42670,7 @@ function collectReadableFiles(root, { maxFiles = 5e3, maxFileBytes = 4e5, manife
42352
42670
  }
42353
42671
 
42354
42672
  // src/trace-fs.mjs
42673
+ var TRACE_MANIFESTS = /^(go\.mod|package\.json|tsconfig\.json|jsconfig\.json|requirements\.txt|.+\.csproj)$/i;
42355
42674
  var git2 = (dir, args) => {
42356
42675
  try {
42357
42676
  return (0, import_node_child_process.execFileSync)("git", ["-C", dir, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], maxBuffer: 64 * 1024 * 1024 });
@@ -42370,7 +42689,7 @@ function readRepoDir(dir, { maxFiles = 5e3 } = {}) {
42370
42689
  const top = git2(root, ["rev-parse", "--show-toplevel"])?.trim();
42371
42690
  const sha = top ? git2(root, ["rev-parse", "HEAD"])?.trim() || null : null;
42372
42691
  const dirty = top ? !!git2(root, ["status", "--porcelain"])?.trim() : false;
42373
- return { name: (0, import_node_path2.basename)(root), root, sha, dirty, files: collectReadableFiles(root, { maxFiles }) };
42692
+ return { name: (0, import_node_path2.basename)(root), root, sha, dirty, files: collectReadableFiles(root, { maxFiles, manifests: true, manifestNames: TRACE_MANIFESTS }) };
42374
42693
  }
42375
42694
  function baseOf(dir, base2) {
42376
42695
  if (base2) return git2(dir, ["rev-parse", "--verify", `${base2}^{commit}`])?.trim() ? base2 : null;
@@ -42397,7 +42716,7 @@ function gitChanges(repo, base2) {
42397
42716
  else if (cur && line.startsWith("deleted file mode")) cur.status = "removed";
42398
42717
  else if (cur && (m = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/))) {
42399
42718
  const start = Number(m[1]), n = m[2] === void 0 ? 1 : Number(m[2]);
42400
- cur.ranges.push(n === 0 ? [Math.max(1, start), Math.max(1, start)] : [start, start + n - 1]);
42719
+ cur.ranges.push(n === 0 ? [start + 0.5, start + 0.5] : [start, start + n - 1]);
42401
42720
  }
42402
42721
  }
42403
42722
  for (const f of (git2(dir, ["ls-files", "--others", "--exclude-standard", "--", "."]) ?? "").split("\n").filter(Boolean)) {
@@ -42415,7 +42734,7 @@ function gitChanges(repo, base2) {
42415
42734
  try {
42416
42735
  const files = [{ path: file, source: old }];
42417
42736
  const f = serviceFacts(thunderModel(files), files);
42418
- before = { routes: f.routes, listeners: f.listeners, publishes: f.publishes };
42737
+ before = { routes: f.routes, listeners: f.listeners, publishes: f.publishes, tables: tablesIn(files) };
42419
42738
  } catch {
42420
42739
  before = null;
42421
42740
  }
@@ -43294,13 +43613,13 @@ var TOOLS = [
43294
43613
  },
43295
43614
  {
43296
43615
  name: "intent_trace",
43297
- description: 'ASK THUNDER TRACE BEFORE CHANGING CODE THAT OTHER REPOSITORIES USE (local only). Give the repository folders. With "thing" (a route like "POST /api/orders", an event name, or "repo:file[:line]") or "diff": true (the branch and uncommitted changes), it answers what the change can affect in the OTHER repositories: callers of a changed or removed route, listeners of a published event, ranked high/medium/low, one hop out, every item cited repo@sha:file:line. With neither, it gives the links between the repositories. Read from code; nothing is run; a call whose address is worked out when it runs is listed as not linked, never guessed.',
43616
+ description: 'ASK THUNDER TRACE BEFORE CHANGING CODE THAT OTHER REPOSITORIES USE (local only). Give the repository folders. With "thing" (a route like "POST /api/orders", an event name, "table:orders", "setting:ORDERS_URL", "package:@acme/client", or "repo:file[:line]") or "diff": true (the branch and uncommitted changes), it answers what the change can affect in the OTHER repositories: callers of a changed or removed route, listeners of a published event, code that uses a changed, dropped, or removed table, other readers of a setting, dependents of a published package, ranked high/medium/low, one hop out, every item cited repo@sha:file:line. With neither, it gives the links between the repositories (HTTP, events, tables, packages) and what they share (settings, tables, package versions that differ). Read from code; nothing is run; a call whose address is worked out when it runs is listed as not linked, never guessed.',
43298
43617
  inputSchema: {
43299
43618
  type: "object",
43300
43619
  required: ["paths"],
43301
43620
  properties: {
43302
43621
  paths: { type: "array", minItems: 1, maxItems: 50, items: { ...str3, description: "a repository folder" } },
43303
- thing: { ...str3, description: 'what changes: "POST /api/orders", "order.placed", or "repo:src/file.ts:12"' },
43622
+ thing: { ...str3, description: 'what changes: "POST /api/orders", "order.placed", "table:orders", "setting:ORDERS_URL", "package:@acme/client", or "repo:src/file.ts:12"' },
43304
43623
  diff: { type: "boolean", description: "use the current changes (since the branch left main, plus uncommitted)" },
43305
43624
  base: { ...str3, description: "with diff: the commit or branch to compare against" }
43306
43625
  }
@@ -44966,7 +45285,7 @@ function countsLine(c) {
44966
45285
  if (c.notRead) parts.push(`${plural5(c.notRead, "file")} Thunder does not read`);
44967
45286
  return `${parts.join(" \xB7 ")}.`;
44968
45287
  }
44969
- var esc2 = (s) => String(s).replace(/[<>]/g, (ch) => ch === "<" ? "&lt;" : "&gt;");
45288
+ var esc3 = (s) => String(s).replace(/[<>]/g, (ch) => ch === "<" ? "&lt;" : "&gt;");
44970
45289
  var fence2 = (lines) => ["```", ...lines.map((l) => l.replace(/```/g, "'''")), "```"];
44971
45290
  var cutLines = (lines, max) => lines.length > max ? [...lines.slice(0, max), `\u2026 ${lines.length - max} more lines`] : lines;
44972
45291
  function evidence(ev, maxLines) {
@@ -44984,7 +45303,7 @@ var HEADINGS = {
44984
45303
  };
44985
45304
  function renderReviewComment(r, { maxChars = 6e4, fileUrl = null, notes = [], footer = "", evidenceLines = 40 } = {}) {
44986
45305
  const where = (w) => {
44987
- const label = `\`${esc2(w.file)}:${w.line}\``;
45306
+ const label = `\`${esc3(w.file)}:${w.line}\``;
44988
45307
  const url = fileUrl?.(w.file, w.line);
44989
45308
  return url ? `[${label}](${url})` : label;
44990
45309
  };
@@ -45005,12 +45324,12 @@ function renderReviewComment(r, { maxChars = 6e4, fileUrl = null, notes = [], fo
45005
45324
  const close = sev === "form" ? ["</details>", ""] : [];
45006
45325
  const memberBlocks = [...members.values()].map((xs) => {
45007
45326
  const render = (compact2) => {
45008
- const lines = [`- **${esc2(xs[0].subject)}** \xB7 ${where(xs[0].where)}`];
45327
+ const lines = [`- **${esc3(xs[0].subject)}** \xB7 ${where(xs[0].where)}`];
45009
45328
  const list4 = compact2 ? xs.slice(0, COMPACT_SENTENCES) : xs;
45010
45329
  for (const x of list4) {
45011
45330
  const ev = sev === "form" ? [] : evidence(x.evidence, evidenceLines);
45012
45331
  const at2 = x.where.line !== xs[0].where.line || x.where.file !== xs[0].where.file ? ` (${where(x.where)})` : "";
45013
- lines.push(` - ${esc2(x.says)}${at2}${compact2 && (ev.length || x.also?.length) ? " _(Before and after, and other places: in the job summary.)_" : ""}`);
45332
+ lines.push(` - ${esc3(x.says)}${at2}${compact2 && (ev.length || x.also?.length) ? " _(Before and after, and other places: in the job summary.)_" : ""}`);
45014
45333
  if (compact2) continue;
45015
45334
  if (ev.length) lines.push("", ` <details><summary>Before and after</summary>`, "", ...ev.map((l) => l ? ` ${l}` : ""), "", " </details>", "");
45016
45335
  if (x.also?.length) {
@@ -45018,7 +45337,7 @@ function renderReviewComment(r, { maxChars = 6e4, fileUrl = null, notes = [], fo
45018
45337
  "",
45019
45338
  ` <details><summary>The same in ${x.also.length} more</summary>`,
45020
45339
  "",
45021
- ...x.also.slice(0, 50).map((a) => ` - **${esc2(a.subject)}** \xB7 ${where(a.where)}`),
45340
+ ...x.also.slice(0, 50).map((a) => ` - **${esc3(a.subject)}** \xB7 ${where(a.where)}`),
45022
45341
  ...x.also.length > 50 ? [` - and ${x.also.length - 50} more`] : [],
45023
45342
  "",
45024
45343
  " </details>",
@@ -45034,7 +45353,7 @@ function renderReviewComment(r, { maxChars = 6e4, fileUrl = null, notes = [], fo
45034
45353
  blocks2.push({ open, close, members: memberBlocks });
45035
45354
  }
45036
45355
  const tail = [];
45037
- if (r.notRead?.length) tail.push(`Also changed, not read by Thunder (check ${r.notRead.length === 1 ? "it" : "them"} yourself if ${r.notRead.length === 1 ? "it matters" : "they matter"}): ${r.notRead.slice(0, 20).map((f) => `\`${esc2(f.path)}\``).join(", ")}${r.notRead.length > 20 ? `, and ${r.notRead.length - 20} more` : ""}.`, "");
45356
+ if (r.notRead?.length) tail.push(`Also changed, not read by Thunder (check ${r.notRead.length === 1 ? "it" : "them"} yourself if ${r.notRead.length === 1 ? "it matters" : "they matter"}): ${r.notRead.slice(0, 20).map((f) => `\`${esc3(f.path)}\``).join(", ")}${r.notRead.length > 20 ? `, and ${r.notRead.length - 20} more` : ""}.`, "");
45038
45357
  const foot = ["---", `<sub>Read from the code by the Thunder compiler, with no AI and without running the code. "Only the form changed" is said only when it is shown. Thunder describes the change; a person still decides whether it is right. [How this works](${DOCS_URL}) \xB7 [thunderlang.dev](${SITE_URL})${footer ? ` \xB7 ${footer}` : ""}</sub>`, ""];
45039
45358
  const size = (lines) => lines.join("\n").length + 1;
45040
45359
  const total = r.items.length;
@@ -45432,7 +45751,7 @@ function writeRule({ source, language, file = "", decision: name, line = null, r
45432
45751
  });
45433
45752
  if (problems.length) return fail3(...problems);
45434
45753
  const starts = lineStartsOf(source);
45435
- const lineOf6 = (off) => {
45754
+ const lineOf7 = (off) => {
45436
45755
  let lo = 0, hi = starts.length - 1;
45437
45756
  while (lo < hi) {
45438
45757
  const m = lo + hi + 1 >> 1;
@@ -45441,7 +45760,7 @@ function writeRule({ source, language, file = "", decision: name, line = null, r
45441
45760
  }
45442
45761
  return lo + 1;
45443
45762
  };
45444
- const change = real.slice().reverse().map((e) => ({ line: lineOf6(e.start), column: e.start - starts[lineOf6(e.start) - 1] + 1, before: e.was, after: e.text }));
45763
+ const change = real.slice().reverse().map((e) => ({ line: lineOf7(e.start), column: e.start - starts[lineOf7(e.start) - 1] + 1, before: e.was, after: e.text }));
45445
45764
  const label = (r) => r === "otherwise" ? "Otherwise" : `If ${sayCondition(r.when)}`;
45446
45765
  const beforeRule = index === "otherwise" ? `Otherwise, the answer is ${target.result}` : `${label(target)}, the answer is ${target.result}`;
45447
45766
  const afterRule = index === "otherwise" ? `Otherwise, the answer is ${wantResult}` : `If ${sayCondition(newWhen)}, the answer is ${wantResult}`;
@@ -47333,7 +47652,8 @@ function assemblePassport({ parts, change = null, runs = [], purpose = null, ext
47333
47652
  }
47334
47653
  const shownBehavior = behavior.slice(0, MAX_BEHAVIOR);
47335
47654
  const trace = buildTrace(parts.map((p) => ({ name: p.name, sha: p.sha ?? null, dirty: !!p.dirty, files: p.files.filter((f) => !f.manifest) })));
47336
- const links = trace.links.map((l) => ({ kind: l.kind, says: l.kind === "http" ? `${l.from.repo} calls ${l.to.repo}: ${l.method} ${l.path} (handled by ${l.to.label ?? l.route})` : `${l.from.repo} publishes ${l.event}, and ${l.to.repo} listens`, from: l.from.cite, to: l.to.cite }));
47655
+ const linkSays = (l) => l.kind === "http" ? `${l.from.repo} calls ${l.to.repo}: ${l.method} ${l.path} (handled by ${l.to.label ?? l.route})` : l.kind === "event" ? `${l.from.repo} publishes ${l.event}, and ${l.to.repo} listens` : l.kind === "data" ? `${l.from.repo} ${l.access} the ${l.table} table, which ${l.to.repo} creates` : `${l.from.repo} depends on the package ${l.package}, which ${l.to.repo} publishes`;
47656
+ const links = trace.links.map((l) => ({ kind: l.kind, says: linkSays(l), from: l.from.cite, to: l.to.cite }));
47337
47657
  const services = [];
47338
47658
  for (const r of trace.repos) for (const q2 of r.requests ?? []) if (q2.base && q2.base !== "this app") services.push({ part: r.name, calls: `${q2.method} ${q2.base}${q2.path}`, at: `${r.name}:${q2.file}:${q2.line}` });
47339
47659
  const evidence2 = [];
@@ -47354,7 +47674,7 @@ function assemblePassport({ parts, change = null, runs = [], purpose = null, ext
47354
47674
  add({
47355
47675
  kind: "trace-link",
47356
47676
  status: "read",
47357
- claim: l.kind === "http" ? `${l.from.repo} calls ${l.to.repo} with ${l.method} ${l.path}, and ${l.to.repo} handles it.` : `${l.from.repo} publishes "${l.event}", and ${l.to.repo} listens for it.`,
47677
+ claim: l.kind === "http" ? `${l.from.repo} calls ${l.to.repo} with ${l.method} ${l.path}, and ${l.to.repo} handles it.` : l.kind === "event" ? `${l.from.repo} publishes "${l.event}", and ${l.to.repo} listens for it.` : l.kind === "data" ? `${l.from.repo} ${l.access} the ${l.table} table, and ${l.to.repo} creates it.` : `${l.from.repo} depends on the package ${l.package}, and ${l.to.repo} publishes it.`,
47358
47678
  basis: { from: l.from.cite, to: l.to.cite, rules: `thunder-trace rules v${trace.rulesVersion}` },
47359
47679
  scope: "Read from code; nothing was run. It does not show that the call succeeds or what it answers.",
47360
47680
  inputs: [inputOf(l.from.repo, l.from.file), inputOf(l.to.repo, l.to.file)]
@@ -47526,7 +47846,7 @@ var git3 = (dir, args) => {
47526
47846
  }
47527
47847
  };
47528
47848
  var SKIP2 = /* @__PURE__ */ new Set(["node_modules", ".git", "bin", "obj", "dist", "build", "__pycache__", ".venv", "venv", "target", ".next"]);
47529
- function packagesIn(root) {
47849
+ function packagesIn2(root) {
47530
47850
  const out = [];
47531
47851
  const walk = (dir, depth) => {
47532
47852
  if (depth > 4) return;
@@ -47642,7 +47962,7 @@ function buildPassport({ parts, base: base2 = null, head = null, run = [], purpo
47642
47962
  changes = changesSince(root, base2);
47643
47963
  }
47644
47964
  const files = collectReadableFiles(root).map((f) => ({ path: f.path, source: f.source }));
47645
- return { name, root, path: (0, import_node_path5.relative)(relativeTo, root).split("\\").join("/") || ".", sha, dirty, files, packages: packagesIn(root), ...changes ? { changes } : {} };
47965
+ return { name, root, path: (0, import_node_path5.relative)(relativeTo, root).split("\\").join("/") || ".", sha, dirty, files, packages: packagesIn2(root), ...changes ? { changes } : {} };
47646
47966
  });
47647
47967
  const runs = run.map((spec) => {
47648
47968
  const m = String(spec).match(/^([A-Za-z0-9_.-]+):\s+(.+)$/);