@skillstech/thunderlang 0.5.10 → 0.5.12
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 +450 -0
- package/dist/core.cjs +30434 -7577
- package/dist/index.cjs +28576 -5328
- package/dist/learn.cjs +24201 -5367
- package/package.json +12 -3
- package/src/bicep.mjs +167 -0
- package/src/cli.mjs +169 -3
- package/src/commands.mjs +464 -0
- package/src/core.d.ts +12 -4
- package/src/core.mjs +12 -4
- package/src/emit.mjs +1 -1
- package/src/executed.d.mts +53 -0
- package/src/executed.mjs +465 -0
- package/src/faithful.mjs +137 -0
- package/src/file-formats.mjs +35 -0
- package/src/hcl.mjs +94 -0
- package/src/index.d.ts +7 -1
- package/src/index.mjs +6 -1
- package/src/infra-bicep.mjs +312 -0
- package/src/infra-cloud.mjs +348 -0
- package/src/infra-compose.mjs +315 -0
- package/src/infra-containers.mjs +100 -0
- package/src/infra-docker.mjs +267 -0
- package/src/infra-expr.mjs +509 -0
- package/src/infra-gha.mjs +350 -0
- package/src/infra-k8s.mjs +657 -0
- package/src/infra-terraform.mjs +499 -0
- package/src/infra-words.mjs +811 -0
- package/src/libraries.mjs +202 -0
- package/src/lift.mjs +49 -6
- package/src/meaning.d.mts +89 -0
- package/src/meaning.mjs +2544 -0
- package/src/model.d.mts +65 -14
- package/src/model.mjs +496 -80
- package/src/powershell.mjs +1361 -0
- package/src/read-repo-fs.mjs +29 -7
- package/src/read-repo.d.mts +5 -1
- package/src/read-repo.mjs +33 -7
- package/src/read.d.mts +21 -1
- package/src/read.mjs +1017 -42
- package/src/review.d.mts +35 -0
- package/src/review.mjs +671 -0
- package/src/rlang.mjs +1084 -0
- package/src/round-trip.d.mts +12 -0
- package/src/round-trip.mjs +174 -0
- package/src/runners/thunder-generate.mjs +56 -0
- package/src/runners/thunder-trace.cjs +284 -0
- package/src/runners/thunder_trace.py +599 -0
- package/src/running.d.mts +104 -0
- package/src/running.mjs +787 -0
- package/src/same.d.mts +1 -0
- package/src/same.mjs +24 -3
- package/src/shell.mjs +1212 -0
- package/src/sql.mjs +3 -2
- package/src/steps.d.mts +6 -1
- package/src/steps.mjs +1448 -86
- package/src/system.d.mts +12 -0
- package/src/system.mjs +845 -0
- package/src/things-langs.mjs +275 -0
- package/src/thunderize.mjs +3 -3
- package/src/visual.d.mts +5 -5
- package/src/visual.mjs +24 -3
- package/src/write-steps.d.mts +64 -0
- package/src/write-steps.mjs +1608 -0
- package/src/write.mjs +2 -1
- package/src/yaml.mjs +403 -0
package/src/same.d.mts
CHANGED
|
@@ -6,5 +6,6 @@ export interface SameItem { name: string; status: SameStatus; reason: string; ol
|
|
|
6
6
|
export interface SameReport { schema: 'thunder-same-v1'; verdict: 'same' | 'different' | 'partly-checked'; counts: Record<SameStatus, number>; items: SameItem[]; unreadable: { path: string; reason: string }[] }
|
|
7
7
|
export function nameKey(name: string): string;
|
|
8
8
|
export function compareRules(oldItem: unknown, newItem: unknown): { same: boolean; tried: number; reason?: string; counterexample?: SameItem['counterexample'] } | null;
|
|
9
|
+
export function comparePlainRules(a: unknown, b: unknown): { same: boolean; tried: number; reason?: string; counterexample?: SameItem['counterexample'] };
|
|
9
10
|
export function sameMeaning(oldFiles: { path: string; source: string }[], newFiles: { path: string; source: string }[]): SameReport;
|
|
10
11
|
export function renderSame(report: SameReport): string;
|
package/src/same.mjs
CHANGED
|
@@ -28,7 +28,7 @@ function compact(it, key, file, language) {
|
|
|
28
28
|
function readAll(files) {
|
|
29
29
|
const items = new Map(), byName = new Map(), unreadable = [];
|
|
30
30
|
for (const f of files) {
|
|
31
|
-
const language = readableLanguage(f.path);
|
|
31
|
+
const language = readableLanguage(f.path, f.source);
|
|
32
32
|
if (!language || !f.source) continue;
|
|
33
33
|
let reading;
|
|
34
34
|
try { reading = readingOf(f, language); } catch (e) { unreadable.push({ path: f.path, reason: e.message }); continue; }
|
|
@@ -73,6 +73,11 @@ export function compareRules(oldItem, newItem) {
|
|
|
73
73
|
let a, b;
|
|
74
74
|
try { a = plainFromReading(oldItem); b = plainFromReading(newItem); } catch { a = b = null; }
|
|
75
75
|
if (!a || !b) return null;
|
|
76
|
+
return comparePlainRules(a, b);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** compareRules for two rules already drawn as cards (plainFromReading), such as a model member's `rule`. */
|
|
80
|
+
export function comparePlainRules(a, b) {
|
|
76
81
|
// Inputs are matched by meaning (their readable label), not by spelling: distance_km and distanceKm are one fact.
|
|
77
82
|
const key = (i) => `${nameKey(i.label)}:${i.kind}`;
|
|
78
83
|
const toA = new Map(a.inputs.map((i) => [key(i), i.id]));
|
|
@@ -91,8 +96,19 @@ export function compareRules(oldItem, newItem) {
|
|
|
91
96
|
|
|
92
97
|
// Each step flattened in reading order: `sig` is what is compared (kind and wording, case- and punctuation-blind),
|
|
93
98
|
// `text` is what a person is shown. Code that is not explained compares as code, never by its wording.
|
|
99
|
+
// A step's code as a language-neutral signature: its names (any convention: delivery_fee = deliveryFee), operators,
|
|
100
|
+
// and values, without syntax (const, let, def, semicolons, braces). Two steps whose words match but whose signatures
|
|
101
|
+
// differ are not proven the same: a + b and a - b read alike in short words, and must never be called "same".
|
|
102
|
+
// Control words are syntax here: the step's kind (a question, a repeat) already carries their meaning.
|
|
103
|
+
const SYNTAX = new Set('const let var val final auto def fn func function return await async new public private protected static self this my local export mut ref out in of for foreach if elif elsif while do then end each as range'.split(' '));
|
|
104
|
+
const OPS = { '&&': 'and', '||': 'or', '!': 'not', '===': '==', '!==': '!=', '<>': '!=', '**': '^', and: 'and', or: 'or', not: 'not', is: '==', None: 'null', nil: 'null', undefined: 'null', NULL: 'null', nullptr: 'null', True: 'true', False: 'false' };
|
|
105
|
+
export function stepSignature(code) {
|
|
106
|
+
const t = String(code || '').replace(/(\/\/|#)[^\n]*$/gm, '');
|
|
107
|
+
const toks = t.match(/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|-?\d+(?:\.\d+)?|[A-Za-z_$][\w$]*|===|!==|==|!=|<=|>=|&&|\|\||\*\*|<>|[-+*\/%<>=!]/g) || [];
|
|
108
|
+
return toks.filter((x) => !SYNTAX.has(x)).map((x) => OPS[x] ?? (/^["'`]/.test(x) ? `"${x.slice(1, -1)}"` : /^[A-Za-z_$]/.test(x) ? x.replace(/[_$]/g, '').toLowerCase() : x)).join(' ');
|
|
109
|
+
}
|
|
94
110
|
const flatSteps = (steps, depth = 0) => (steps || []).flatMap((s) => [
|
|
95
|
-
{ sig: `${depth}:${s.restates ? 'code' : s.kind}:${s.restates || s.kind === 'other' ? '' : norm(s.says)}`, text: s.restates || s.kind === 'other' ? `\`${s.code ?? s.says}\`` : s.says },
|
|
111
|
+
{ sig: `${depth}:${s.restates ? 'code' : s.kind}:${s.restates || s.kind === 'other' ? '' : norm(s.says)}`, code: stepSignature(s.code), raw: String(s.code ?? ''), text: s.restates || s.kind === 'other' ? `\`${s.code ?? s.says}\`` : s.says },
|
|
96
112
|
...flatSteps(s.children, depth + 1),
|
|
97
113
|
]);
|
|
98
114
|
|
|
@@ -116,7 +132,12 @@ function compareItems(o, n) {
|
|
|
116
132
|
}
|
|
117
133
|
const so = o.flat, sn = n.flat;
|
|
118
134
|
const at = so.findIndex((s, i) => s.sig !== sn[i]?.sig);
|
|
119
|
-
if (at === -1 && so.length === sn.length)
|
|
135
|
+
if (at === -1 && so.length === sn.length) {
|
|
136
|
+
// Same words is not proof: the code under them must say the same too (names, operators, values).
|
|
137
|
+
const differs = so.findIndex((s, i) => s.code && sn[i].code && s.code !== sn[i].code);
|
|
138
|
+
if (differs >= 0) return { status: 'cannot-check', reason: `Thunder reads these the same, but the code differs at step ${differs + 1}: \`${so[differs].raw.trim()}\` before, \`${sn[differs].raw.trim()}\` after. Check this step.`, ...where };
|
|
139
|
+
return { status: 'same', reason: `Same ${so.length} steps.`, ...where };
|
|
140
|
+
}
|
|
120
141
|
const i = at === -1 ? Math.min(so.length, sn.length) : at;
|
|
121
142
|
return { status: 'different', reason: `Steps differ from step ${i + 1}: "${so[i]?.text ?? '(nothing)'}" became "${sn[i]?.text ?? '(nothing)'}".`, ...where };
|
|
122
143
|
}
|