@skillstech/thunderlang 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/dist/core.cjs +135 -60
- package/dist/index.cjs +394 -89
- package/dist/learn.cjs +81 -22
- package/package.json +1 -1
- package/src/ai.mjs +2 -1
- package/src/atlas.mjs +2 -1
- package/src/behaviour.mjs +246 -0
- package/src/cli-main.mjs +2818 -0
- package/src/cli.mjs +9 -2799
- package/src/conflict.mjs +0 -0
- package/src/core/ThunderDotnet.cs +195 -0
- package/src/core/check.mjs +4 -4
- package/src/core/cli.mjs +7 -2
- package/src/core/csharp-run.mjs +29 -8
- package/src/core/diagnostics.mjs +3 -1
- package/src/core/engine-core.mjs +20 -1
- package/src/core/go-run.mjs +3 -2
- package/src/core/java-run.mjs +3 -3
- package/src/core/kind.mjs +42 -0
- package/src/core/parser.mjs +54 -7
- package/src/core/project.mjs +3 -0
- package/src/core/react-run.mjs +3 -3
- package/src/core/runtime-npm.mjs +79 -0
- package/src/core/runtime-react.mjs +2 -1
- package/src/core/runtime-typescript.mjs +7 -3
- package/src/core/rust-run.mjs +3 -2
- package/src/core/target-csharp.mjs +5 -1
- package/src/core/target-go.mjs +1 -1
- package/src/core/target-python.mjs +1 -1
- package/src/core/target-rust.mjs +1 -1
- package/src/core/target-typescript.mjs +33 -1
- package/src/core/typescript-run.mjs +9 -4
- package/src/decision.mjs +2 -1
- package/src/distributed.mjs +2 -1
- package/src/emit.mjs +2 -2
- package/src/focus.mjs +2 -1
- package/src/intent-atlas.mjs +4 -3
- package/src/mcp.mjs +10 -3
- package/src/passport-fs.mjs +2 -1
- package/src/passport.mjs +2 -1
- package/src/privacy.mjs +2 -1
- package/src/read-repo.mjs +3 -2
- package/src/report.mjs +3 -2
- package/src/review.mjs +2 -1
- package/src/select.mjs +2 -1
- package/src/semantic-diff.mjs +7 -6
- package/src/system.mjs +2 -1
- package/src/text-order.mjs +6 -0
- package/src/thunderize.mjs +2 -1
- package/src/trace-data.mjs +3 -2
- package/src/trace.mjs +4 -3
- package/src/write-across-cli.mjs +22 -4
- package/src/write-across.mjs +2 -1
- package/src/write-steps.mjs +14 -3
- package/src/write-words.mjs +59 -2
- package/syntaxes/thunder.tmLanguage.json +196 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
1
|
+
# 1.7.0
|
|
2
|
+
|
|
3
|
+
- **.NET and NuGet from Thunder Core.** `Use "System.IO.Path" from .NET as paths` and `Use "Humanizer.NumberToWordsExtension"
|
|
4
|
+
from NuGet "Humanizer.Core" version "2.14.1" as words` give a program compiled to C# the .NET ecosystem. Static
|
|
5
|
+
methods and properties are called by name; the overload is chosen by which parameters every value fits; numbers come
|
|
6
|
+
back exact (`decimal` as written, `double` as it prints). The NuGet package and its version go into the generated
|
|
7
|
+
project. Programs that use .NET libraries run with real culture data, pinned to en-US. A failure is TC508 with its
|
|
8
|
+
real cause; every other target and the Thunder engine refuse a .NET library (new TC409).
|
|
9
|
+
- **See what a change does: `thunder write --behaviour`.** For Python, Thunder runs each edited function before and
|
|
10
|
+
after the change on inputs made from its own code (its numbers and one either side, its text, yes/no, the edges)
|
|
11
|
+
and lists the inputs whose answer changed: `amount 100, days 29, refunded False: before 'approve', after
|
|
12
|
+
'review'`. Printed output and errors count. It runs your code, so it is opt-in; a changed file that no longer
|
|
13
|
+
loads is reported and not saved. Also `behaviour: true` on the MCP tool `intent_write`. Tested evidence on those
|
|
14
|
+
inputs, never called a proof. Across services too: `thunder write web orders billing --decision … --when …
|
|
15
|
+
--behaviour` runs each Python implementation (the checkout demo shows `subtotal 40: before 5.99, after 0`).
|
|
16
|
+
- **The read ↔ write round trip runs on made inputs too.** `docs/core-read-write.md` now also compares the original
|
|
17
|
+
Python with Core compiled back to Python on inputs made from each function's code: 11 of 11 functions, 134 of 134
|
|
18
|
+
inputs give the same results (alongside the 53 hand-picked inputs).
|
|
19
|
+
- **A `.thunder` file says what it is.** Outside a project, a file whose first line cannot start a mission
|
|
20
|
+
(`say "Hello"`, `Set total to 0`, `To greet:`, `A Trade has:`) is now run, tested, and checked as Thunder Core
|
|
21
|
+
without `--core`: `thunder run hello.thunder` just works. Files that start with a mission keyword stay missions,
|
|
22
|
+
so no existing mission changes meaning; a file that could be either (`use csv` alone) stays a mission, and
|
|
23
|
+
`--mission` / `--core` still decide when given. A mission check that finds no mission now says how to read the
|
|
24
|
+
file as a program.
|
|
25
|
+
- **One map of the language.** New docs page, *The Thunder language*: Thunder Text, Thunder Core, and missions side
|
|
26
|
+
by side with the same rule in each, which to use when, and how a file's kind is decided.
|
|
27
|
+
- **npm packages from Thunder Core.** `Use "date-fns" from npm as dates` gives a program compiled to TypeScript the npm
|
|
28
|
+
ecosystem, the way `Use csv as csv` gives Python programs Python's. Values cross the boundary in plain rules (lists
|
|
29
|
+
become arrays, records become objects, dates become a local-midnight `Date`), and numbers come back as the exact
|
|
30
|
+
decimal they are written as, so `0.07 + 0.01` is still exactly `0.08`. Scoped packages, paths inside a package,
|
|
31
|
+
`node:` built-ins, and one-function CommonJS packages (`.default`) work. A failure inside the package, a missing
|
|
32
|
+
name, or a promise is TC508 in words, against the Thunder line that called it. Every other target, and the Thunder
|
|
33
|
+
engine, refuses an npm package (new TC408) instead of guessing. `npm_packages.d.ts` keeps `tsc --strict` passing for
|
|
34
|
+
packages without types. `Use csv from Python as csv` is accepted too.
|
|
35
|
+
- **Faster start.** Every command starts about a quarter faster in CPU time: the Unicode collation data no longer loads
|
|
36
|
+
at start (sorting is by character order now, the same on every machine, where it used to depend on the machine's
|
|
37
|
+
locale), and on Node 22.1+ Thunder turns on Node's compile cache, so the compiler is not parsed again on every
|
|
38
|
+
command. `compiler/scripts/speed.mjs` measures everyday commands.
|
|
39
|
+
- **The engine never runs a program that did not compile.** `runInProcess`, `recordedRun`, and `testInProcess` (used by
|
|
40
|
+
the site and OpenThunder) now refuse with the program's problems; before, a test could pass on a broken program.
|
|
41
|
+
- **Clearer: a name that is only "a", "an", or "the".** `Receive a and b` now says `"a" can't be a name on its own:
|
|
42
|
+
Thunder skips "a", "an", and "the" in names`, with a suggestion, instead of `"Receive" is missing a name`.
|
|
43
|
+
- **On thunderlang.dev:** a Thunder playground (write a program; see what it prints, try its functions with your own
|
|
44
|
+
values, run its tests, step through it; share it by link), and ThunderBench, an open benchmark with every result
|
|
45
|
+
published (`thunderbench/`).
|
|
46
|
+
|
|
47
|
+
# 1.6.1
|
|
48
|
+
|
|
49
|
+
- **Fix: Thunder write wrote names the code does not have.** A word that is no name in the function or file
|
|
50
|
+
(`"amount is big"`, `"total is at least 75"` when the input is `amount`) was written as a new name
|
|
51
|
+
(`if amount == big:`) and passed the proof; code with such a name (`amount >= total`) was written too. Both are now
|
|
52
|
+
refused, naming the function's inputs (`its inputs are "amount", "coupon"`). The function's own names, the file's
|
|
53
|
+
names, the language's built-ins (`len`, `Math`, …), names an earlier edit in the list added, and a new local the
|
|
54
|
+
step itself sets (`total = amount * 2`) are all still accepted. Reported by Skills Tech Talk.
|
|
55
|
+
|
|
1
56
|
# 1.6.0
|
|
2
57
|
|
|
3
58
|
- **Thunder write in Thunder's words.** `thunder write <file> --edit` (step edits: inputs, questions, Stops, steps,
|
package/dist/core.cjs
CHANGED
|
@@ -1778,7 +1778,7 @@ function literalDecimal(n) {
|
|
|
1778
1778
|
return null;
|
|
1779
1779
|
}
|
|
1780
1780
|
function renderExpr(src, inputs, D, money = {}, dialect = "js") {
|
|
1781
|
-
const
|
|
1781
|
+
const known2 = new Set(inputs);
|
|
1782
1782
|
const isMoney = (n) => n.k === "ref" && Object.prototype.hasOwnProperty.call(money, n.path);
|
|
1783
1783
|
const moneyRefs = (n, out = []) => {
|
|
1784
1784
|
if (isMoney(n)) out.push(n.path);
|
|
@@ -1839,7 +1839,7 @@ function renderExpr(src, inputs, D, money = {}, dialect = "js") {
|
|
|
1839
1839
|
case "lit":
|
|
1840
1840
|
return typeof n.v === "string" ? JSON.stringify(n.v) : typeof n.v === "boolean" ? D.bool(n.v) : D.num ? D.num(n.v) : String(n.v);
|
|
1841
1841
|
case "ref":
|
|
1842
|
-
return
|
|
1842
|
+
return known2.has(n.path) || known2.has(n.path.split(".")[0]) ? n.path : JSON.stringify(n.path);
|
|
1843
1843
|
default:
|
|
1844
1844
|
return D.nil;
|
|
1845
1845
|
}
|
|
@@ -10134,8 +10134,8 @@ function commandSays(cmd) {
|
|
|
10134
10134
|
case "bunx": {
|
|
10135
10135
|
const rest2 = args.filter((a) => a !== "--yes" && a !== "-y" && !a.startsWith("--package"));
|
|
10136
10136
|
const name = (rest2[0] ?? "").replace(/^(@[^/]+\/)?([^@]+).*$/, "$2");
|
|
10137
|
-
const
|
|
10138
|
-
return
|
|
10137
|
+
const known2 = JS_TOOLS[name]?.(rest2.slice(1));
|
|
10138
|
+
return known2 ?? (name ? `Runs ${name}` : null);
|
|
10139
10139
|
}
|
|
10140
10140
|
case "node": {
|
|
10141
10141
|
if (args[0] === "-p" || args[0] === "-e" || args[0] === "--eval" || args[0] === "--print") {
|
|
@@ -11648,7 +11648,7 @@ function actionWords(uses, w) {
|
|
|
11648
11648
|
if (w.cache) s += ", reusing saved downloads";
|
|
11649
11649
|
return s;
|
|
11650
11650
|
}
|
|
11651
|
-
const
|
|
11651
|
+
const known2 = {
|
|
11652
11652
|
"pnpm/action-setup": () => `Sets up pnpm${ver(w.version)}`,
|
|
11653
11653
|
"oven-sh/setup-bun": () => `Sets up Bun${ver(w["bun-version"])}`,
|
|
11654
11654
|
"denoland/setup-deno": () => "Sets up Deno",
|
|
@@ -11685,7 +11685,7 @@ function actionWords(uses, w) {
|
|
|
11685
11685
|
"codecov/codecov-action": () => "Sends test coverage to Codecov",
|
|
11686
11686
|
"actions/dependency-review-action": () => "Checks new dependencies for known problems"
|
|
11687
11687
|
}[key];
|
|
11688
|
-
if (
|
|
11688
|
+
if (known2) return known2();
|
|
11689
11689
|
return `Uses ${repo}`;
|
|
11690
11690
|
}
|
|
11691
11691
|
function readWorkflow(src, file = "workflow.yml") {
|
|
@@ -14175,12 +14175,12 @@ function secretLiteral(name, value) {
|
|
|
14175
14175
|
return !/^(true|false|yes|no|on|off|\d+|enabled|disabled|none|null|changeme|<.*>)$/i.test(v);
|
|
14176
14176
|
}
|
|
14177
14177
|
var HOST_KEY = /(host|hostname|addr|address|url|uri|server|servers|endpoint|dsn|broker|brokers|connection|conn)$/i;
|
|
14178
|
-
function servicesNamed(key, value,
|
|
14178
|
+
function servicesNamed(key, value, known2) {
|
|
14179
14179
|
const out = [];
|
|
14180
14180
|
const v = String(value ?? "").trim();
|
|
14181
14181
|
const add = (h) => {
|
|
14182
14182
|
const host = String(h).toLowerCase();
|
|
14183
|
-
if ((!
|
|
14183
|
+
if ((!known2 || known2.has(host)) && !out.includes(host) && !/^(localhost|0\.0\.0\.0|127\.0\.0\.1)$/.test(host)) out.push(host);
|
|
14184
14184
|
};
|
|
14185
14185
|
for (const part of v.split(/[,\s]+/)) {
|
|
14186
14186
|
if (!part) continue;
|
|
@@ -17261,8 +17261,8 @@ function classifyWords(raw, { inner = 0 } = {}) {
|
|
|
17261
17261
|
const everyday = value ? sayPython(value) || sayCommon(value) : null;
|
|
17262
17262
|
if (everyday) return { kind: "set", says: `Sets ${target} to ${everyday}`, code: code3 };
|
|
17263
17263
|
if (c2 && wholeValueCall(value)) {
|
|
17264
|
-
const
|
|
17265
|
-
if (
|
|
17264
|
+
const known2 = sayCall(c2, firstArgs(value));
|
|
17265
|
+
if (known2) return { kind: "call", says: `${known2}, keeping the result as ${target}`, code: code3, callee: c2 };
|
|
17266
17266
|
if (/^new\s/.test(value) || makesType(c2) && (LANG !== "cpp" || sameType(c2, m[1]))) return { kind: "set", says: `Creates a new ${c2.split(".").pop()} as ${target}`, code: code3 };
|
|
17267
17267
|
return { kind: "set", says: `Works out ${target} from ${callWords2(c2, value)}`, code: code3, callee: c2 };
|
|
17268
17268
|
}
|
|
@@ -17334,8 +17334,8 @@ function classifyWords(raw, { inner = 0 } = {}) {
|
|
|
17334
17334
|
if (common) return { kind: "set", says: `Sets ${target} to ${common}`, code: code3 };
|
|
17335
17335
|
const c2 = callee(value);
|
|
17336
17336
|
if (c2 && wholeValueCall(value)) {
|
|
17337
|
-
const
|
|
17338
|
-
if (
|
|
17337
|
+
const known2 = sayCall(c2, firstArgs(value));
|
|
17338
|
+
if (known2) return { kind: "call", says: `${known2}, keeping the result as ${target}`, code: code3, callee: c2 };
|
|
17339
17339
|
if (/^new\s/.test(value) || makesType(c2) && (LANG !== "cpp" || sameType(c2, declType))) return { kind: "set", says: `Creates a new ${c2.split(".").pop()} as ${target}`, code: code3 };
|
|
17340
17340
|
return { kind: "set", says: `Works out ${target} from ${callWords2(c2, value)}`, code: code3, callee: c2 };
|
|
17341
17341
|
}
|
|
@@ -17398,8 +17398,8 @@ function classifyWords(raw, { inner = 0 } = {}) {
|
|
|
17398
17398
|
}
|
|
17399
17399
|
const c = callee(head);
|
|
17400
17400
|
if (c) {
|
|
17401
|
-
const
|
|
17402
|
-
if (
|
|
17401
|
+
const known2 = sayCall(c, firstArgs(head));
|
|
17402
|
+
if (known2) return { kind: "call", says: known2, code: code3, callee: c };
|
|
17403
17403
|
const o = head.indexOf("("), cl = o >= 0 ? closeOf(head, o) : -1;
|
|
17404
17404
|
const only = cl > o && /^\s*;?\s*$/.test(head.slice(cl + 1)) ? splitTopArgs(head.slice(o + 1, cl)) : [];
|
|
17405
17405
|
if ((LANG === "typescript" || LANG === "javascript" || LANG === "python") && only.length === 1 && !/^\s*(?:async\s*)?(?:\(|function\b|[A-Za-z_$][\w$]*\s*=>)/.test(only[0]) && !/^(?:exec|eval|compile|__import__|execfile|Function|setTimeout|setInterval)$/.test(c)) {
|
|
@@ -17411,9 +17411,9 @@ function classifyWords(raw, { inner = 0 } = {}) {
|
|
|
17411
17411
|
}
|
|
17412
17412
|
if ((m = head.match(/^([a-z_][\w.]*[?!]?)\s+(?![=<>!+\-*/%]|and\b|or\b|if\b|unless\b)(.+)$/)) && !/^(?:if|for|while|return|else|elsif|when|case|def|class|module|end|not|const|let|var|val|new|await|typeof|delete|void|in|of|throw|import|export|from|as|is)$/.test(m[1])) {
|
|
17413
17413
|
if (/^assert/.test(m[1])) return { kind: "check", says: `Checks: ${clip(head, 60)}`, code: code3 };
|
|
17414
|
-
const
|
|
17414
|
+
const known2 = sayCall(m[1], m[2]);
|
|
17415
17415
|
const named2 = /^[:'"]([\w ]+)['"]?/.exec(m[2].trim())?.[1];
|
|
17416
|
-
return { kind: "call", says:
|
|
17416
|
+
return { kind: "call", says: known2 || (named2 ? `Calls ${lastWords(m[1])}: ${words7(named2)}` : `Calls ${lastWords(m[1])}`), code: code3, callee: m[1] };
|
|
17417
17417
|
}
|
|
17418
17418
|
return { kind: "other", says: clip(head, 70), code: code3 };
|
|
17419
17419
|
}
|
|
@@ -18876,6 +18876,9 @@ var BLOCKABLE_PHASES = [
|
|
|
18876
18876
|
"release"
|
|
18877
18877
|
];
|
|
18878
18878
|
|
|
18879
|
+
// src/text-order.mjs
|
|
18880
|
+
var byText = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
18881
|
+
|
|
18879
18882
|
// src/conflict.mjs
|
|
18880
18883
|
var norm = (s) => String(s ?? "").trim().toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
18881
18884
|
var NEG = /\b(no|not|never|forbidden|prohibited|unavailable|disallowed|without)\b/;
|
|
@@ -18917,7 +18920,7 @@ function detectConflicts(ast) {
|
|
|
18917
18920
|
}
|
|
18918
18921
|
}
|
|
18919
18922
|
}
|
|
18920
|
-
return out.sort((a, b) => `${a.type}\0${a.name}
|
|
18923
|
+
return out.sort((a, b) => byText(`${a.type}\0${a.name}`, `${b.type}\0${b.name}`));
|
|
18921
18924
|
}
|
|
18922
18925
|
|
|
18923
18926
|
// src/distributed.mjs
|
|
@@ -18947,7 +18950,7 @@ function analyzeDistributed(ast) {
|
|
|
18947
18950
|
findings2.push({ code: "IL-DIST-005", target: h.trigger, message: `Duplicate handler references undeclared event "${m[1]}".` });
|
|
18948
18951
|
}
|
|
18949
18952
|
}
|
|
18950
|
-
return findings2.sort((a, b) => `${a.code} ${a.target}
|
|
18953
|
+
return findings2.sort((a, b) => byText(`${a.code} ${a.target}`, `${b.code} ${b.target}`));
|
|
18951
18954
|
}
|
|
18952
18955
|
|
|
18953
18956
|
// src/decision.mjs
|
|
@@ -18971,7 +18974,7 @@ function analyzeDecision(dec) {
|
|
|
18971
18974
|
}
|
|
18972
18975
|
}
|
|
18973
18976
|
}
|
|
18974
|
-
return findings2.sort((a, b) => `${a.code} ${a.message}
|
|
18977
|
+
return findings2.sort((a, b) => byText(`${a.code} ${a.message}`, `${b.code} ${b.message}`));
|
|
18975
18978
|
}
|
|
18976
18979
|
|
|
18977
18980
|
// src/privacy.mjs
|
|
@@ -19033,7 +19036,7 @@ function analyzePrivacy(ast) {
|
|
|
19033
19036
|
});
|
|
19034
19037
|
}
|
|
19035
19038
|
}
|
|
19036
|
-
out.sort((a, b) => (a.code + a.path
|
|
19039
|
+
out.sort((a, b) => byText(a.code + a.path, b.code + b.path));
|
|
19037
19040
|
return out;
|
|
19038
19041
|
}
|
|
19039
19042
|
|
|
@@ -19407,7 +19410,7 @@ function notesSummary(ast) {
|
|
|
19407
19410
|
byLens
|
|
19408
19411
|
};
|
|
19409
19412
|
}
|
|
19410
|
-
var COMPILER_VERSION = "1.
|
|
19413
|
+
var COMPILER_VERSION = "1.7.0";
|
|
19411
19414
|
var PROOF_SCHEMA_VERSION = "0.1.0";
|
|
19412
19415
|
var SOURCE_PRODUCT = "skillstech-compiler";
|
|
19413
19416
|
function buildContractGraph(ast, generatedAt) {
|
|
@@ -19480,7 +19483,7 @@ function semanticDiagnostics(ast) {
|
|
|
19480
19483
|
err(
|
|
19481
19484
|
"missing-subject",
|
|
19482
19485
|
"No mission, service, event, api, database, or experience declared.",
|
|
19483
|
-
"Every file must declare one subject so the compiler knows what it is reasoning about.",
|
|
19486
|
+
"Every mission file must declare one subject so the compiler knows what it is reasoning about. If this file is a Thunder program (code that runs), add --core, or put it in a project (thunder new).",
|
|
19484
19487
|
[{ label: "Add a mission declaration", insert: "mission MyMission", block: "top" }]
|
|
19485
19488
|
);
|
|
19486
19489
|
}
|
|
@@ -22874,8 +22877,8 @@ function simpleSaysInner(n, ctx = null) {
|
|
|
22874
22877
|
return { kind: "fail", says: `Fails with exit code ${DIES.get(name)}${msg ? `: "${msg}"` : ""}`, error: `exit code ${DIES.get(name)}`, ...msg ? { message: msg } : {}, callee: name };
|
|
22875
22878
|
}
|
|
22876
22879
|
if (KNOWN_FNS.has(name)) return out(`Runs ${words9(name)}${args.length ? ` with ${list2(args.slice(0, 4).map(sayWord))}${args.length > 4 ? ", \u2026" : ""}` : ""}`, { callee: name });
|
|
22877
|
-
const
|
|
22878
|
-
if (
|
|
22880
|
+
const known2 = sayCommand(name, args, sayWord);
|
|
22881
|
+
if (known2) return out(known2, { callee: name });
|
|
22879
22882
|
if (/^"?\$/.test(name)) return out(`Runs the command in ${sayWord(name)}`, { callee: name });
|
|
22880
22883
|
if (scriptPath(name)) return out(`Runs the script ${sayWord(name)}`, { callee: name });
|
|
22881
22884
|
return out(`Runs ${name}${args[0] && /^[a-z][\w-]*$/.test(args[0]) ? ` ${args[0]}` : ""}`, { callee: name });
|
|
@@ -24075,8 +24078,8 @@ function commandWords(toks2, ctx = {}) {
|
|
|
24075
24078
|
return `${VERB[verb]} the ${many ? pluralNoun(noun) : noun}${object ? dup ? ` named by ${object}` : ` ${object}` : ""}${more}`;
|
|
24076
24079
|
}
|
|
24077
24080
|
const raws = argGroups(rest2).map(toksCode);
|
|
24078
|
-
const
|
|
24079
|
-
if (
|
|
24081
|
+
const known2 = sayCommand(raw.replace(/\.exe$/i, ""), raws, (w) => sayValue2(tokenize3(w)) ?? quoteText(w));
|
|
24082
|
+
if (known2) return known2;
|
|
24080
24083
|
if (/[\\/]|\.ps1$/i.test(raw)) return `Runs the script ${quoteText(raw)}${withArgs(a)}`;
|
|
24081
24084
|
return `Runs ${raw}${withArgs(a)}`;
|
|
24082
24085
|
}
|
|
@@ -27069,13 +27072,13 @@ var WRAPS_FUNCTION = /^(?:React\.)?(?:useCallback|useMemo|memo|forwardRef|useEve
|
|
|
27069
27072
|
var TEST_CALLS = /^(?:describe|it|test|context|suite|specify|before|after|beforeEach|afterEach|beforeAll|afterAll|setup|teardown|x?it|f?it|xdescribe|fdescribe|xtest|bench)(?:\.\w+)*$/;
|
|
27070
27073
|
function jsMoreFunctions(src, fns) {
|
|
27071
27074
|
const clean = stripCommentsKeepLayout(src);
|
|
27072
|
-
const
|
|
27075
|
+
const known2 = new Set(fns.map((f) => f.bodyStart));
|
|
27073
27076
|
const found = [];
|
|
27074
27077
|
const add = (fnIdx, paramsOpen, paramsClose, arrowParam, bo) => {
|
|
27075
|
-
if (
|
|
27078
|
+
if (known2.has(bo + 1)) return null;
|
|
27076
27079
|
const bc = matchClose(src, bo);
|
|
27077
27080
|
if (bc < 0) return null;
|
|
27078
|
-
|
|
27081
|
+
known2.add(bo + 1);
|
|
27079
27082
|
const line = lineAt(src, fnIdx);
|
|
27080
27083
|
const params = arrowParam != null ? parseParams2(arrowParam, "typescript") : parseParams2(src.slice(paramsOpen + 1, paramsClose), "typescript");
|
|
27081
27084
|
const f = { key: `fn@${fnIdx}`, line, params, returns: null, bodyStart: bo + 1, body: src.slice(bo + 1, bc), at: fnIdx, end: bc };
|
|
@@ -27105,7 +27108,7 @@ function jsMoreFunctions(src, fns) {
|
|
|
27105
27108
|
const arrowRe = /=>\s*\{/g;
|
|
27106
27109
|
while (m = arrowRe.exec(clean)) {
|
|
27107
27110
|
const bo = m.index + m[0].length - 1;
|
|
27108
|
-
if (
|
|
27111
|
+
if (known2.has(bo + 1)) continue;
|
|
27109
27112
|
let j = m.index - 1;
|
|
27110
27113
|
while (j >= 0 && /\s/.test(clean[j])) j--;
|
|
27111
27114
|
let start, paramText = null, pOpen = -1, pClose = -1;
|
|
@@ -30962,6 +30965,31 @@ var lit4 = (type, value, raw) => ({ kind: "literal", type, value, raw });
|
|
|
30962
30965
|
var NULL_RAW = { python: "None", go: "nil", typescript: "null", javascript: "null" };
|
|
30963
30966
|
var Unsaid = class extends Error {
|
|
30964
30967
|
};
|
|
30968
|
+
var Unknown = class extends Error {
|
|
30969
|
+
constructor(word) {
|
|
30970
|
+
super(word);
|
|
30971
|
+
this.word = word;
|
|
30972
|
+
}
|
|
30973
|
+
};
|
|
30974
|
+
function inputsOf2(scope) {
|
|
30975
|
+
const code3 = codeOnly(scope || ""), open = code3.indexOf("(");
|
|
30976
|
+
if (open < 0) return [];
|
|
30977
|
+
let depth = 0, end2 = open;
|
|
30978
|
+
for (; end2 < code3.length; end2++) {
|
|
30979
|
+
if (code3[end2] === "(") depth++;
|
|
30980
|
+
else if (code3[end2] === ")" && --depth === 0) break;
|
|
30981
|
+
}
|
|
30982
|
+
const out = [];
|
|
30983
|
+
for (const part of code3.slice(open + 1, end2).split(",")) {
|
|
30984
|
+
const id2 = part.replace(/^\s*[*&.]*\s*/, "").match(/^[A-Za-z_]\w*/)?.[0];
|
|
30985
|
+
if (id2 && !KEYWORDS.has(id2) && id2 !== "self" && id2 !== "cls" && !out.includes(id2)) out.push(id2);
|
|
30986
|
+
}
|
|
30987
|
+
return out;
|
|
30988
|
+
}
|
|
30989
|
+
var unknownWord = (word, scope) => {
|
|
30990
|
+
const inputs = inputsOf2(scope);
|
|
30991
|
+
return `"${word}" is not a name in this function or file${inputs.length ? `; its inputs are ${inputs.map((i) => `"${nameWords2(i) || i}"`).join(", ")}` : ""}. Use one of its names, or add an input first (addInput).`;
|
|
30992
|
+
};
|
|
30965
30993
|
var no2 = (why) => {
|
|
30966
30994
|
throw new Unsaid(why);
|
|
30967
30995
|
};
|
|
@@ -30984,8 +31012,8 @@ function toTree(n, language, names) {
|
|
|
30984
31012
|
case "nothing":
|
|
30985
31013
|
return lit4("null", null, NULL_RAW[language]);
|
|
30986
31014
|
case "name": {
|
|
30987
|
-
const id2 = names.get(n.name)
|
|
30988
|
-
if (!id2)
|
|
31015
|
+
const id2 = names.get(n.name);
|
|
31016
|
+
if (!id2) throw new Unknown(n.name);
|
|
30989
31017
|
return nm(id2);
|
|
30990
31018
|
}
|
|
30991
31019
|
case "field":
|
|
@@ -31055,8 +31083,8 @@ function toTree(n, language, names) {
|
|
|
31055
31083
|
}
|
|
31056
31084
|
function parseThunder(text2, source, scope) {
|
|
31057
31085
|
const names = namesOf(source, scope);
|
|
31058
|
-
const
|
|
31059
|
-
const ep = new ExprParser({ known, fields: new Set(names.keys()), records: /* @__PURE__ */ new Set(), recordFields: /* @__PURE__ */ new Map(), funcInputs: /* @__PURE__ */ new Map(), recordText: /* @__PURE__ */ new Map(), screens: /* @__PURE__ */ new Map() });
|
|
31086
|
+
const known2 = new Map([...names.keys()].map((k) => [k, "var"]));
|
|
31087
|
+
const ep = new ExprParser({ known: known2, fields: new Set(names.keys()), records: /* @__PURE__ */ new Set(), recordFields: /* @__PURE__ */ new Map(), funcInputs: /* @__PURE__ */ new Map(), recordText: /* @__PURE__ */ new Map(), screens: /* @__PURE__ */ new Map() });
|
|
31060
31088
|
const lexed = tokenizeLine(String(text2), 1);
|
|
31061
31089
|
const tokens = Array.isArray(lexed) ? lexed : lexed.tokens;
|
|
31062
31090
|
return { node: ep.parse(tokens, 1), names };
|
|
@@ -31072,6 +31100,7 @@ function thunderTree(text2, language, source, scope = "") {
|
|
|
31072
31100
|
return { tree: toTree(parsed.node, language, parsed.names) };
|
|
31073
31101
|
} catch (e) {
|
|
31074
31102
|
if (e instanceof Unsaid) return { error: `Thunder write cannot say ${e.message} in ${language} yet.` };
|
|
31103
|
+
if (e instanceof Unknown) return { error: unknownWord(e.word, scope), unknown: e.word };
|
|
31075
31104
|
throw e;
|
|
31076
31105
|
}
|
|
31077
31106
|
}
|
|
@@ -31093,6 +31122,42 @@ function thunderStep(text2, language, source, scope = "") {
|
|
|
31093
31122
|
}
|
|
31094
31123
|
return null;
|
|
31095
31124
|
}
|
|
31125
|
+
var BUILTINS = {
|
|
31126
|
+
python: "abs all any ascii bin bool bytearray bytes callable chr dict dir divmod enumerate filter float format frozenset getattr globals hasattr hash hex id int isinstance issubclass iter len list locals map max min next object oct open ord pow print range repr reversed round set setattr slice sorted str sum super tuple type vars zip Exception ValueError TypeError KeyError IndexError RuntimeError AttributeError NotImplementedError StopIteration LookupError ArithmeticError ZeroDivisionError OSError NotImplemented Ellipsis __name__ __file__",
|
|
31127
|
+
typescript: "Math JSON Object Array String Number Boolean Date Error TypeError RangeError Promise Map Set WeakMap Symbol BigInt RegExp console parseInt parseFloat isNaN isFinite undefined NaN Infinity globalThis window document process require module exports",
|
|
31128
|
+
go: "len cap append make new copy delete panic recover print println close complex real imag min max clear error string int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float32 float64 bool byte rune any iota fmt errors strings strconv"
|
|
31129
|
+
};
|
|
31130
|
+
BUILTINS.javascript = BUILTINS.typescript;
|
|
31131
|
+
function unknownName(tree, language, source, scope = "") {
|
|
31132
|
+
const known2 = new Set(BUILTINS[language]?.split(" ") ?? []);
|
|
31133
|
+
for (const text2 of [codeOnly(source), codeOnly(scope)]) for (const m of text2.matchAll(/\b[A-Za-z_][A-Za-z0-9_]*\b/g)) known2.add(m[0]);
|
|
31134
|
+
for (const k of KEYWORDS) known2.add(k);
|
|
31135
|
+
const bound = /* @__PURE__ */ new Set();
|
|
31136
|
+
const all = [];
|
|
31137
|
+
const walk = (n) => {
|
|
31138
|
+
if (Array.isArray(n)) {
|
|
31139
|
+
n.forEach(walk);
|
|
31140
|
+
return;
|
|
31141
|
+
}
|
|
31142
|
+
if (!n || typeof n !== "object") return;
|
|
31143
|
+
if (n.kind === "lambda" || n.kind === "code") {
|
|
31144
|
+
bound.add("*");
|
|
31145
|
+
return;
|
|
31146
|
+
}
|
|
31147
|
+
if (n.kind === "name") all.push(n.name);
|
|
31148
|
+
if ((n.kind === "assign" || n.kind === "declare") && n.target?.kind === "name") bound.add(n.target.name);
|
|
31149
|
+
if (n.kind === "declare" && typeof n.name === "string") bound.add(n.name);
|
|
31150
|
+
if (n.kind === "loop") for (const v of [n.variable, n.var, n.name, n.target]) {
|
|
31151
|
+
if (typeof v === "string") bound.add(v);
|
|
31152
|
+
else if (v?.kind === "name") bound.add(v.name);
|
|
31153
|
+
}
|
|
31154
|
+
for (const [k, v] of Object.entries(n)) if (k !== "raw" && v && typeof v === "object") walk(v);
|
|
31155
|
+
};
|
|
31156
|
+
walk(tree);
|
|
31157
|
+
if (bound.has("*")) return null;
|
|
31158
|
+
return all.find((id2) => !known2.has(id2) && !bound.has(id2)) ?? null;
|
|
31159
|
+
}
|
|
31160
|
+
var unknownNameReason = (word, scope) => unknownWord(word, scope);
|
|
31096
31161
|
|
|
31097
31162
|
// src/read-repo.mjs
|
|
31098
31163
|
var READ_REPO_SCHEMA = "thunder-repo-reading-v1";
|
|
@@ -31233,7 +31298,7 @@ function summarize(items, files) {
|
|
|
31233
31298
|
inputs.get(p.name).push(it.id);
|
|
31234
31299
|
}
|
|
31235
31300
|
}
|
|
31236
|
-
const byUse = (m) => [...m].map(([name, ids]) => ({ name, decisions: ids })).sort((a, b) => b.decisions.length - a.decisions.length || a.name
|
|
31301
|
+
const byUse = (m) => [...m].map(([name, ids]) => ({ name, decisions: ids })).sort((a, b) => b.decisions.length - a.decisions.length || byText(a.name, b.name));
|
|
31237
31302
|
return { files, items, counts, languages, folders, answers: byUse(answers), inputs: byUse(inputs) };
|
|
31238
31303
|
}
|
|
31239
31304
|
function searchRepo(index, { query = "", kinds = [], status = [], languages = [], path = "", answer = "", input = "" } = {}) {
|
|
@@ -31257,7 +31322,7 @@ function groupByFile(items) {
|
|
|
31257
31322
|
if (!groups3.has(it.file)) groups3.set(it.file, []);
|
|
31258
31323
|
groups3.get(it.file).push(it);
|
|
31259
31324
|
}
|
|
31260
|
-
return [...groups3].sort(([a], [b]) => a
|
|
31325
|
+
return [...groups3].sort(([a], [b]) => byText(a, b)).map(([file, list3]) => ({ file, language: list3[0].language, items: list3 }));
|
|
31261
31326
|
}
|
|
31262
31327
|
function readFiles(files) {
|
|
31263
31328
|
return files.map((f) => {
|
|
@@ -31356,8 +31421,8 @@ function parseCondition(text2, inputs, line) {
|
|
|
31356
31421
|
}
|
|
31357
31422
|
fail3(line, `Compare ${input.label} with at least, at most, under, over, or exactly. For example: "${input.label} is at most ${formatValue(input, 100)}".`);
|
|
31358
31423
|
}
|
|
31359
|
-
const
|
|
31360
|
-
fail3(line, `This condition does not name an input. Start with one of: ${
|
|
31424
|
+
const known2 = inputs.map((i) => i.kind === "yesno" ? `"it is ${i.yes}"` : `"${i.label} is \u2026"`).join(", ");
|
|
31425
|
+
fail3(line, `This condition does not name an input. Start with one of: ${known2}.`);
|
|
31361
31426
|
}
|
|
31362
31427
|
function parsePlainContract(source) {
|
|
31363
31428
|
if (typeof source !== "string" || source.length > 1e5) throw new Error("A plain contract must be text of at most 100 KB.");
|
|
@@ -34953,7 +35018,7 @@ function callsSummary(model) {
|
|
|
34953
35018
|
else p.calls++;
|
|
34954
35019
|
if (p.examples.length < 3) p.examples.push({ from: a.id, to: b.id, says: l.kind === "sends-to" ? `${a.label} sends ${l.method ? `${l.method} ${l.path}` : l.event ? `the event ${l.event}` : `a task`} to ${b.label}` : `${a.label} calls ${b.label}` });
|
|
34955
35020
|
}
|
|
34956
|
-
return [...pairs2.values()].sort((x, y) => y.calls + y.sends - (x.calls + x.sends) || x.from
|
|
35021
|
+
return [...pairs2.values()].sort((x, y) => y.calls + y.sends - (x.calls + x.sends) || byText(x.from, y.from) || byText(x.to, y.to));
|
|
34957
35022
|
}
|
|
34958
35023
|
|
|
34959
35024
|
// src/flow/ts-parse.mjs
|
|
@@ -39304,11 +39369,17 @@ function exprFrom(input, language, what = "expression") {
|
|
|
39304
39369
|
if (looksThunder(input) && words15().tree) return words15().tree;
|
|
39305
39370
|
for (const l of PARSE_ORDER(language)) {
|
|
39306
39371
|
const t = parseExpr(input, l);
|
|
39307
|
-
if (t && t.kind !== "code" && !misreadIs(t)) return adapt(t, language);
|
|
39372
|
+
if (t && t.kind !== "code" && !misreadIs(t)) return known(adapt(t, language), language);
|
|
39308
39373
|
}
|
|
39309
39374
|
if (words15().tree) return words15().tree;
|
|
39375
|
+
if (said?.unknown) refuse(`The ${what} "${input}" could not be read: ${said.error}`);
|
|
39310
39376
|
refuse(`The ${what} "${input}" could not be read${said?.error ? ` (${said.error})` : ""}. Write it in Thunder's words, for example "days is more than 10 and not member's vip", or as code.`);
|
|
39311
39377
|
}
|
|
39378
|
+
function known(tree, language) {
|
|
39379
|
+
const word = unknownName(tree, language, wordsSource, wordsScope);
|
|
39380
|
+
if (word) refuse(`It cannot be written: ${unknownNameReason(word, wordsScope)}`);
|
|
39381
|
+
return tree;
|
|
39382
|
+
}
|
|
39312
39383
|
function adapt(tree, language) {
|
|
39313
39384
|
const t = cloneShape(tree);
|
|
39314
39385
|
for (const n of nodesOf(t)) {
|
|
@@ -39338,9 +39409,10 @@ function statementFrom(input, language) {
|
|
|
39338
39409
|
const a = adapt(t, language);
|
|
39339
39410
|
try {
|
|
39340
39411
|
renderStatement(a, language);
|
|
39341
|
-
return a;
|
|
39342
39412
|
} catch {
|
|
39413
|
+
continue;
|
|
39343
39414
|
}
|
|
39415
|
+
return known(a, language);
|
|
39344
39416
|
}
|
|
39345
39417
|
}
|
|
39346
39418
|
refuse(`The step "${input}" could not be read as one statement.`);
|
|
@@ -40337,6 +40409,9 @@ function opAddFunction(state, edit) {
|
|
|
40337
40409
|
if (language === "go" && inputs.some((p) => !p.type)) refuse("Go needs a type for every input.");
|
|
40338
40410
|
const ctx = { language, source, item: { name, line: 1 } };
|
|
40339
40411
|
if (language === "go" && edit.returns) ctx.goResults = edit.returns;
|
|
40412
|
+
wordsScope = `${name}(${inputs.map((p) => p.name).join(", ")})`;
|
|
40413
|
+
wordsSource = `${wordsScope}
|
|
40414
|
+
${source}`;
|
|
40340
40415
|
const nodes2 = (edit.steps || []).map((s) => stepSpec(s, { ...ctx, source: `${source}
|
|
40341
40416
|
func ${name}() (${edit.returns || ""}) {}` }));
|
|
40342
40417
|
if (!nodes2.length) refuse("A new function needs at least one step.");
|
|
@@ -41038,7 +41113,7 @@ function settingsIn(files) {
|
|
|
41038
41113
|
}
|
|
41039
41114
|
}
|
|
41040
41115
|
}
|
|
41041
|
-
return out.sort((a, b) => a.file
|
|
41116
|
+
return out.sort((a, b) => byText(a.file, b.file) || a.line - b.line || byText(a.key, b.key));
|
|
41042
41117
|
}
|
|
41043
41118
|
var NAME = '((?:[`"\\[]?[A-Za-z_][\\w$]*[`"\\]]?\\.){0,2}[`"\\[]?[A-Za-z_][\\w$]*[`"\\]]?)';
|
|
41044
41119
|
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"]);
|
|
@@ -41108,7 +41183,7 @@ function tablesIn(files) {
|
|
|
41108
41183
|
if (seen.has(k)) return false;
|
|
41109
41184
|
seen.add(k);
|
|
41110
41185
|
return true;
|
|
41111
|
-
}).sort((a, b) => a.file
|
|
41186
|
+
}).sort((a, b) => byText(a.file, b.file) || a.line - b.line || byText(a.table, b.table));
|
|
41112
41187
|
}
|
|
41113
41188
|
var DEFINES = /* @__PURE__ */ new Set(["creates", "alters", "drops"]);
|
|
41114
41189
|
|
|
@@ -41253,8 +41328,8 @@ function linkRepos(read) {
|
|
|
41253
41328
|
return true;
|
|
41254
41329
|
});
|
|
41255
41330
|
};
|
|
41256
|
-
links.splice(0, links.length, ...once(links).sort((a, b) => sortKey(a)
|
|
41257
|
-
notLinked.splice(0, notLinked.length, ...once(notLinked).sort((a, b) => sortKey(a)
|
|
41331
|
+
links.splice(0, links.length, ...once(links).sort((a, b) => byText(sortKey(a), sortKey(b))));
|
|
41332
|
+
notLinked.splice(0, notLinked.length, ...once(notLinked).sort((a, b) => byText(sortKey(a), sortKey(b))));
|
|
41258
41333
|
const repos = read.map(({ unknown, ...r }) => ({ ...r, unknown: unknown ?? [], packages: pk(r), settings: r.settings ?? [], tables: tb(r) }));
|
|
41259
41334
|
const body2 = { schema: TRACE_SCHEMA, rulesVersion: TRACE_RULES_VERSION, repos, links, notLinked, shared };
|
|
41260
41335
|
return { ...body2, fingerprint: sha256(JSON.stringify(body2)) };
|
|
@@ -41402,7 +41477,7 @@ function writeRuleAcross(files, { decision, rule, when }) {
|
|
|
41402
41477
|
}
|
|
41403
41478
|
result.files[k] = source;
|
|
41404
41479
|
}
|
|
41405
|
-
result.plan.sort((a, b) => where(a)
|
|
41480
|
+
result.plan.sort((a, b) => byText(where(a), where(b)) || a.line - b.line);
|
|
41406
41481
|
if (problems.length) return { ...base2, files: {}, plan: [], rule: result.rule, notIncluded: result.notIncluded, tests: result.tests, problems: ["Nothing was changed: every implementation must be written exactly, or none is.", ...problems] };
|
|
41407
41482
|
return { ...result, ok: true };
|
|
41408
41483
|
}
|
|
@@ -42302,7 +42377,7 @@ function thunderizeFiles(files, { name = "app" } = {}) {
|
|
|
42302
42377
|
skipped.push({ path: f.path, reason: `could not be read: ${e.message}` });
|
|
42303
42378
|
}
|
|
42304
42379
|
}
|
|
42305
|
-
out.sort((a, b) => a.path
|
|
42380
|
+
out.sort((a, b) => byText(a.path, b.path));
|
|
42306
42381
|
const total = { files: out.length, actions: 0, rules: 0, functions: 0, notReadYet: 0 };
|
|
42307
42382
|
for (const f of out) for (const k of ["actions", "rules", "functions", "notReadYet"]) total[k] += f.counts[k];
|
|
42308
42383
|
const langs = [...new Set(out.map((f) => LANGUAGE_NAMES[f.language] || f.language))].sort();
|
|
@@ -43094,7 +43169,7 @@ function thunderReview(oldFiles, newFiles) {
|
|
|
43094
43169
|
for (const x of rest2) items.splice(items.indexOf(x), 1);
|
|
43095
43170
|
}
|
|
43096
43171
|
for (const x of items) if (x.also) x.subject = `${x.subject} and ${x.also.length} more`;
|
|
43097
|
-
items.sort((a, b) => SEVERITY_ORDER.indexOf(a.severity) - SEVERITY_ORDER.indexOf(b.severity) || KIND_ORDER.indexOf(a.kind) - KIND_ORDER.indexOf(b.kind) || String(a.where.file)
|
|
43172
|
+
items.sort((a, b) => SEVERITY_ORDER.indexOf(a.severity) - SEVERITY_ORDER.indexOf(b.severity) || KIND_ORDER.indexOf(a.kind) - KIND_ORDER.indexOf(b.kind) || byText(String(a.where.file), String(b.where.file)) || (a.where.line ?? 0) - (b.where.line ?? 0));
|
|
43098
43173
|
const count2 = (s) => items.filter((x) => x.severity === s).length;
|
|
43099
43174
|
const summary2 = { meaning: count2("meaning"), risk: count2("risk"), form: count2("form"), unchanged, files: paths.filter((p) => A.sources.get(p) !== B.sources.get(p)).length };
|
|
43100
43175
|
const onlyNotRead = !items.length && summary2.files && notRead.length === summary2.files;
|
|
@@ -44437,9 +44512,9 @@ function diffGraphs(before, after) {
|
|
|
44437
44512
|
const bn = bNodes.get(id2);
|
|
44438
44513
|
if (bn && contentKey(bn) !== contentKey(an)) changedNodes.push({ id: id2, type: an.type, before: bn, after: an });
|
|
44439
44514
|
}
|
|
44440
|
-
addedNodes.sort((a, b) => a.id
|
|
44441
|
-
removedNodes.sort((a, b) => a.id
|
|
44442
|
-
changedNodes.sort((a, b) => a.id
|
|
44515
|
+
addedNodes.sort((a, b) => byText(a.id, b.id));
|
|
44516
|
+
removedNodes.sort((a, b) => byText(a.id, b.id));
|
|
44517
|
+
changedNodes.sort((a, b) => byText(a.id, b.id));
|
|
44443
44518
|
const bRel = new Set((before.relationships || []).map(relKey));
|
|
44444
44519
|
const aRel = new Set((after.relationships || []).map(relKey));
|
|
44445
44520
|
const addedRelationships = (after.relationships || []).filter((r) => !bRel.has(relKey(r)));
|
|
@@ -44524,11 +44599,11 @@ function mergeGraphs(base2, ours, theirs) {
|
|
|
44524
44599
|
const present = inO !== inB ? inO : inT;
|
|
44525
44600
|
if (present) mergedRels.push(r);
|
|
44526
44601
|
}
|
|
44527
|
-
mergedRels.sort((a, b2) => relKey(a)
|
|
44602
|
+
mergedRels.sort((a, b2) => byText(relKey(a), relKey(b2)));
|
|
44528
44603
|
return {
|
|
44529
44604
|
schema: "intent-merge-v1",
|
|
44530
|
-
merged: { nodes: [...merged.values()].sort((a, b2) => a.id
|
|
44531
|
-
conflicts: conflicts.sort((a, b2) => a.id
|
|
44605
|
+
merged: { nodes: [...merged.values()].sort((a, b2) => byText(a.id, b2.id)), relationships: mergedRels },
|
|
44606
|
+
conflicts: conflicts.sort((a, b2) => byText(a.id, b2.id)),
|
|
44532
44607
|
clean: conflicts.length === 0,
|
|
44533
44608
|
summary: { nodes: merged.size, relationships: mergedRels.length, conflicts: conflicts.length }
|
|
44534
44609
|
};
|
|
@@ -45780,10 +45855,10 @@ function buildAtlas(graphs, opts = {}) {
|
|
|
45780
45855
|
for (const n of g.nodes) if (!nodes2.has(n.id)) nodes2.set(n.id, n);
|
|
45781
45856
|
for (const r of g.relationships) relationships.push(r);
|
|
45782
45857
|
}
|
|
45783
|
-
const nodeList = [...nodes2.values()].sort((a, b) => a.id
|
|
45858
|
+
const nodeList = [...nodes2.values()].sort((a, b) => byText(a.id, b.id));
|
|
45784
45859
|
const byType = {};
|
|
45785
45860
|
for (const n of nodeList) byType[n.type] = (byType[n.type] || 0) + 1;
|
|
45786
|
-
missions.sort((a, b) => a.id
|
|
45861
|
+
missions.sort((a, b) => byText(a.id, b.id));
|
|
45787
45862
|
return {
|
|
45788
45863
|
schema: ATLAS_SCHEMA,
|
|
45789
45864
|
product: opts.product || null,
|
|
@@ -45816,7 +45891,7 @@ function searchAtlas(atlas, query, opts = {}) {
|
|
|
45816
45891
|
};
|
|
45817
45892
|
let hits = atlas.nodes.filter((n) => `${n.id} ${n.title || ""} ${n.description || ""}`.toLowerCase().includes(q2));
|
|
45818
45893
|
if (opts.type) hits = hits.filter((n) => n.type === opts.type);
|
|
45819
|
-
hits.sort((a, b) => score(a) - score(b) || a.type
|
|
45894
|
+
hits.sort((a, b) => score(a) - score(b) || byText(a.type, b.type) || byText(a.id, b.id));
|
|
45820
45895
|
return hits.slice(0, opts.limit || 25);
|
|
45821
45896
|
}
|
|
45822
45897
|
|
|
@@ -45879,7 +45954,7 @@ function buildMissionIndex(files, opts = {}) {
|
|
|
45879
45954
|
reviewed: ast.approval?.reviewed === true
|
|
45880
45955
|
};
|
|
45881
45956
|
}).filter((m) => m.mission);
|
|
45882
|
-
missions.sort((a, b) => a.mission
|
|
45957
|
+
missions.sort((a, b) => byText(a.mission, b.mission));
|
|
45883
45958
|
const byArea = {};
|
|
45884
45959
|
for (const m of missions) {
|
|
45885
45960
|
const a = m.area || "uncategorized";
|
|
@@ -46187,7 +46262,7 @@ function buildFocusGraph(atlas, { seeds = [], depth = 2, scope = null } = {}) {
|
|
|
46187
46262
|
}
|
|
46188
46263
|
frontier = next;
|
|
46189
46264
|
}
|
|
46190
|
-
const focusNodes = [...included.values()].map(({ node: node2, reason, depth: dd }) => ({ id: node2.id, type: node2.type, title: node2.title || node2.id, focusReason: reason, depth: dd, confidence: node2.confidence || null, provenance: node2.provenance || null })).sort((a, b) => a.depth - b.depth || a.id
|
|
46265
|
+
const focusNodes = [...included.values()].map(({ node: node2, reason, depth: dd }) => ({ id: node2.id, type: node2.type, title: node2.title || node2.id, focusReason: reason, depth: dd, confidence: node2.confidence || null, provenance: node2.provenance || null })).sort((a, b) => a.depth - b.depth || byText(a.id, b.id));
|
|
46191
46266
|
const idSet = new Set(focusNodes.map((n) => n.id));
|
|
46192
46267
|
const focusRels = rels2.filter((r) => idSet.has(r.from) && idSet.has(r.to));
|
|
46193
46268
|
const byReason = {};
|
|
@@ -47145,7 +47220,7 @@ function assemblePassport({ parts, change = null, runs = [], purpose = null, ext
|
|
|
47145
47220
|
notRead.push({ part: p.name, file: u.file, line: u.line, what: owner ? `${owner.label}: ${u.why}` : u.why });
|
|
47146
47221
|
}
|
|
47147
47222
|
}
|
|
47148
|
-
const order = (a, b) => `${a.part}/${a.file}
|
|
47223
|
+
const order = (a, b) => byText(`${a.part}/${a.file}`, `${b.part}/${b.file}`) || (a.lines?.[0] ?? a.line ?? 0) - (b.lines?.[0] ?? b.line ?? 0);
|
|
47149
47224
|
behavior.sort(order);
|
|
47150
47225
|
effects.sort(order);
|
|
47151
47226
|
notRead.sort(order);
|