@skillstech/thunderlang 1.4.0 → 1.4.1
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 +28 -0
- package/dist/core.cjs +120 -4
- package/dist/index.cjs +1 -1
- package/dist/learn.cjs +3355 -1184
- package/package.json +15 -2
- package/src/core.d.ts +4 -0
- package/src/core.mjs +2 -0
- package/src/emit.mjs +1 -1
- package/src/learn-lessons.mjs +145 -0
- package/src/learn.mjs +17 -0
- package/src/react/reading.css +119 -0
- package/src/react/reading.d.mts +15 -0
- package/src/react/reading.mjs +87 -0
- package/src/reading-layout.d.mts +40 -0
- package/src/reading-layout.mjs +112 -0
- package/src/write-across.mjs +13 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
# 1.4.1
|
|
2
|
+
|
|
3
|
+
**Upgrade note.** No command, flag, exit code, or JSON shape changed. New: the drawing kit entry
|
|
4
|
+
`@skillstech/thunderlang/react` (with `react/reading.css`; React >=18 is an optional peer dependency) and
|
|
5
|
+
`readingLayout()` in `./core` (schema `thunder-reading-layout-v1`). One behavior fix: `thunder write <folder…>` now
|
|
6
|
+
lists, instead of changing, a rule with the same condition in a decision whose name shares no word with the chosen one.
|
|
7
|
+
|
|
8
|
+
- **The Thunder drawing kit, `@skillstech/thunderlang/react` (first part).** One set of components so OpenThunder,
|
|
9
|
+
thunderlang.dev, and the Skills Tech Talk course draw a reading the same way: `ThingCard` ("A Thing", "It knows",
|
|
10
|
+
the "It can" buttons, "How a new … starts"), `DataCard` (a record or choices), `BigPicture`, and `ThunderSymbol`.
|
|
11
|
+
Every word and its order come from `readingLayout(model, { focus })` in `./core` (`thunder-reading-layout-v1`),
|
|
12
|
+
which zooms with focus: the whole app or a file (Things, then records, then choices), a Thing (its card and its
|
|
13
|
+
file's Data), or an action or rule (`ioBoxes`: "You give it", "You get back", "It can stop with", "Part of …").
|
|
14
|
+
Styling is one stylesheet, `@skillstech/thunderlang/react/reading.css`: plain `tl-` classes, every color a CSS
|
|
15
|
+
variable (a dark and a light set; `--language-accent` is honored), one column under 560px, 44px touch targets.
|
|
16
|
+
React is an optional peer dependency; no Tailwind, no build step. thunderlang.dev now draws its Thing and Data
|
|
17
|
+
cards with it. The Flow and Details views and the drawn IO boxes join next.
|
|
18
|
+
- **Three lessons on changing real code, in `@skillstech/thunderlang/learn`.** "Does every route keep each
|
|
19
|
+
customer's records to them?" (`thunder read --access`), "Change one rule in every service at once"
|
|
20
|
+
(`thunder write <folder…>`), and "Keep the evidence for a change" (`thunder passport`, `passport check`). They are
|
|
21
|
+
write lessons (now 10, 22 lessons in all), and like every lesson, each quiz answer is worked out by the tool itself
|
|
22
|
+
on the lesson's files, so the build fails if a tool ever disagrees with what a lesson teaches.
|
|
23
|
+
- **Fix: `thunder write <folder…>` no longer changes a different rule that happens to share a condition.** A
|
|
24
|
+
decision with the same condition but a name that shares no word with the chosen one (`coupon_allowed` next to
|
|
25
|
+
`shippingFee`, both `subtotal >= 50`) is now listed as "check by hand" instead of being changed. Names are compared
|
|
26
|
+
as words, leaving out words like get, is, and calculate, so `shippingNote`, `ShippingFee`, and `get_shipping_fee`
|
|
27
|
+
still match.
|
|
28
|
+
|
|
1
29
|
# 1.4.0
|
|
2
30
|
|
|
3
31
|
**Upgrade note.** Every existing command, flag, exit code, and JSON output is unchanged. New: the Software Passport
|
package/dist/core.cjs
CHANGED
|
@@ -89,6 +89,8 @@ __export(core_exports, {
|
|
|
89
89
|
PROOF_SCHEMA: () => PROOF_SCHEMA,
|
|
90
90
|
PROOF_STATUSES: () => PROOF_STATUSES,
|
|
91
91
|
PROVENANCE: () => PROVENANCE2,
|
|
92
|
+
READING_LABELS: () => READING_LABELS,
|
|
93
|
+
READING_LAYOUT_SCHEMA: () => READING_LAYOUT_SCHEMA,
|
|
92
94
|
READ_LANGUAGES: () => READ_LANGUAGES,
|
|
93
95
|
READ_REPO_SCHEMA: () => READ_REPO_SCHEMA,
|
|
94
96
|
READ_SCHEMA: () => READ_SCHEMA,
|
|
@@ -180,6 +182,7 @@ __export(core_exports, {
|
|
|
180
182
|
confidenceFromClassification: () => confidenceFromClassification,
|
|
181
183
|
contradictionsView: () => contradictionsView,
|
|
182
184
|
coverageView: () => coverageView,
|
|
185
|
+
dataCard: () => dataCard,
|
|
183
186
|
describeEdit: () => describeEdit,
|
|
184
187
|
detailOf: () => detailOf,
|
|
185
188
|
detailParts: () => detailParts,
|
|
@@ -216,6 +219,7 @@ __export(core_exports, {
|
|
|
216
219
|
intentGraphJsonSchema: () => intentGraphJsonSchema,
|
|
217
220
|
intentProofJsonSchema: () => intentProofJsonSchema,
|
|
218
221
|
intentRefId: () => intentRefId,
|
|
222
|
+
ioBoxes: () => ioBoxes,
|
|
219
223
|
isCaseResult: () => isCaseResult,
|
|
220
224
|
isFactual: () => isFactual,
|
|
221
225
|
isFactualProvenance: () => isFactualProvenance,
|
|
@@ -227,6 +231,7 @@ __export(core_exports, {
|
|
|
227
231
|
linkSystem: () => linkSystem,
|
|
228
232
|
makeEvent: () => makeEvent,
|
|
229
233
|
makeScope: () => makeScope,
|
|
234
|
+
memberSymbolId: () => memberSymbolId,
|
|
230
235
|
mergeGraphs: () => mergeGraphs,
|
|
231
236
|
minorUnitsFor: () => minorUnitsFor,
|
|
232
237
|
modelText: () => modelText,
|
|
@@ -258,6 +263,7 @@ __export(core_exports, {
|
|
|
258
263
|
readScreens: () => readScreens,
|
|
259
264
|
readableFile: () => readableFile,
|
|
260
265
|
readableLanguage: () => readableLanguage,
|
|
266
|
+
readingLayout: () => readingLayout,
|
|
261
267
|
readingOf: () => readingOf,
|
|
262
268
|
recoverModel: () => recoverModel,
|
|
263
269
|
renderExampleTable: () => renderExampleTable,
|
|
@@ -312,6 +318,7 @@ __export(core_exports, {
|
|
|
312
318
|
subjectName: () => subjectName,
|
|
313
319
|
summarize: () => summarize2,
|
|
314
320
|
terminatorEffect: () => terminatorEffect,
|
|
321
|
+
thingCard: () => thingCard,
|
|
315
322
|
thunderModel: () => thunderModel,
|
|
316
323
|
thunderReview: () => thunderReview,
|
|
317
324
|
thunderText: () => thunderText,
|
|
@@ -19398,7 +19405,7 @@ function notesSummary(ast) {
|
|
|
19398
19405
|
byLens
|
|
19399
19406
|
};
|
|
19400
19407
|
}
|
|
19401
|
-
var COMPILER_VERSION = "1.4.
|
|
19408
|
+
var COMPILER_VERSION = "1.4.1";
|
|
19402
19409
|
var PROOF_SCHEMA_VERSION = "0.1.0";
|
|
19403
19410
|
var SOURCE_PRODUCT = "skillstech-compiler";
|
|
19404
19411
|
function buildContractGraph(ast, generatedAt) {
|
|
@@ -38186,7 +38193,7 @@ function readLevel(model, level, focus, { full = false } = {}) {
|
|
|
38186
38193
|
links: (model.links || []).filter((l) => l.from === t.id || l.to === t.id).map((l) => ({ from: l.from, to: l.to, kind: l.kind, ...l.line ? { line: l.line } : {} }))
|
|
38187
38194
|
});
|
|
38188
38195
|
const resource = thing?.kind === "resource" ? thing : null;
|
|
38189
|
-
const
|
|
38196
|
+
const thingCard2 = (t) => ({ id: t.id, label: t.label, ...t.doc ? { doc: t.doc } : {}, knows: t.knows.map((k) => ({ label: k.label, ...k.start ? { start: k.start } : {} })), can: model.members.filter((m) => m.owner === t.id && m.kind !== "setup" && !m.callback).map(short6) });
|
|
38190
38197
|
return {
|
|
38191
38198
|
...base2,
|
|
38192
38199
|
...about,
|
|
@@ -38195,7 +38202,7 @@ function readLevel(model, level, focus, { full = false } = {}) {
|
|
|
38195
38202
|
const p = thing ? thing.doc ?? model.files.find((f) => f.path === thing.file)?.purpose : model.files.length === 1 ? model.files[0]?.purpose : null;
|
|
38196
38203
|
return p ? { purpose: p } : {};
|
|
38197
38204
|
})(),
|
|
38198
|
-
things: (resource ? [] : thing ? [thing] : model.things.filter((t) => t.kind === "thing" && !t.screen)).map(
|
|
38205
|
+
things: (resource ? [] : thing ? [thing] : model.things.filter((t) => t.kind === "thing" && !t.screen)).map(thingCard2),
|
|
38199
38206
|
resources: (resource ? [resource] : thing ? [] : model.things.filter((t) => t.kind === "resource")).map(resourceCard),
|
|
38200
38207
|
...thing ? {} : { permissions: model.permissions ?? [], settings: model.settings ?? [], facts: model.facts ?? [] },
|
|
38201
38208
|
data: thing ? [] : model.things.filter((t) => t.kind !== "thing" && t.kind !== "resource").map((t) => ({ id: t.id, label: t.label, symbol: SYMBOL_OF[t.kind], ...t.choices.length ? { choices: t.choices } : {}, knows: t.knows.map((k) => k.label) })),
|
|
@@ -40134,6 +40141,12 @@ var editable2 = (t) => t.t === "num" || t.t === "str" || t.t === "op" && ["<", "
|
|
|
40134
40141
|
var keyOf = (t) => t.t === "id" ? `id:${words13(t.v)}` : t.t === "str" ? `str:${JSON.stringify(t.v)}` : `${t.t}:${t.v}`;
|
|
40135
40142
|
var shapeOf = (t) => t.t === "id" ? "id" : editable2(t) ? t.t === "op" ? "cmp" : t.t : `${t.t}:${t.v}`;
|
|
40136
40143
|
var join3 = (toks2) => toks2.map((t) => t.t === "str" ? JSON.stringify(t.v) : String(t.v)).join(" ");
|
|
40144
|
+
var FILLER = /* @__PURE__ */ new Set(["get", "is", "has", "can", "should", "calc", "calculate", "compute", "check", "find", "the", "a", "an", "of", "for", "to", "by"]);
|
|
40145
|
+
var nameWords2 = (name) => new Set(words13(name).split(" ").filter((w) => w && !FILLER.has(w)));
|
|
40146
|
+
var sharesWord = (a, b) => {
|
|
40147
|
+
const A = nameWords2(a);
|
|
40148
|
+
return [...nameWords2(b)].some((w) => A.has(w));
|
|
40149
|
+
};
|
|
40137
40150
|
var toks = (when) => {
|
|
40138
40151
|
try {
|
|
40139
40152
|
return tokenize(when);
|
|
@@ -40183,7 +40196,8 @@ function findSameRule(files, { decision, rule }) {
|
|
|
40183
40196
|
const k = x.toks.map(keyOf).join(" ");
|
|
40184
40197
|
const said = sayCondition(x.when);
|
|
40185
40198
|
if (k === key) {
|
|
40186
|
-
same.push({ ...x, why: `the same condition: ${said} (names compared as words)` });
|
|
40199
|
+
if (sharesWord(x.decision, anchor.decision)) same.push({ ...x, why: `the same condition: ${said} (names compared as words)` });
|
|
40200
|
+
else notIncluded.push({ ...x, why: `the same condition (${said}) in ${x.decision}, whose name shares no word with ${anchor.decision}; it may be a different rule that happens to use the same limit` });
|
|
40187
40201
|
continue;
|
|
40188
40202
|
}
|
|
40189
40203
|
if (x.toks.map(shapeOf).join(" ") !== shape) continue;
|
|
@@ -46183,6 +46197,101 @@ function renderPassportMarkdown(p) {
|
|
|
46183
46197
|
L.push("", "## History", "", `- Base: ${p.history.base ?? "(none: a snapshot)"}`, `- Head: ${p.history.head ?? "(working tree)"}`, ...p.history.changedFiles.map((c) => `- ${c.status}: ${c.part}/${c.file}`), `- Built: ${p.history.builtAt}${p.history.thunder ? ` with Thunder ${p.history.thunder}` : ""}`, `- Fingerprint: ${p.fingerprint}`, "");
|
|
46184
46198
|
return L.join("\n");
|
|
46185
46199
|
}
|
|
46200
|
+
|
|
46201
|
+
// src/reading-layout.mjs
|
|
46202
|
+
var READING_LAYOUT_SCHEMA = "thunder-reading-layout-v1";
|
|
46203
|
+
var READING_LABELS = Object.freeze({
|
|
46204
|
+
thing: "A Thing",
|
|
46205
|
+
knows: "It knows",
|
|
46206
|
+
can: "It can",
|
|
46207
|
+
starts: (label) => `How a new ${label} starts`,
|
|
46208
|
+
startsWithKnows: (label) => `A new ${label} starts with what it knows above`,
|
|
46209
|
+
record: "Data: a record",
|
|
46210
|
+
choices: "Data: choices",
|
|
46211
|
+
recordSymbol: "Record",
|
|
46212
|
+
choicesSymbol: "Choices",
|
|
46213
|
+
things: "Things",
|
|
46214
|
+
data: "Data",
|
|
46215
|
+
give: "You give it",
|
|
46216
|
+
getBack: "You get back",
|
|
46217
|
+
stops: "It can stop with",
|
|
46218
|
+
givesNothing: "Nothing",
|
|
46219
|
+
getsNothing: "Nothing it hands back",
|
|
46220
|
+
partOf: (label) => `Part of ${label}`,
|
|
46221
|
+
io: "What goes in and out"
|
|
46222
|
+
});
|
|
46223
|
+
var memberSymbolId = (m) => m.kind === "action" || m.kind === "pipeline" ? "action" : m.kind === "rule" ? "rule" : m.kind === "setup" ? "setup" : m.kind === "not-read" ? "not-read" : "steps";
|
|
46224
|
+
var knowsLine = (k) => {
|
|
46225
|
+
const detail = [k.kind, k.start].filter(Boolean).join(", ");
|
|
46226
|
+
return { name: k.name, label: k.label, detail: detail || null, ...k.secret ? { secret: true } : {}, line: k.line ?? null };
|
|
46227
|
+
};
|
|
46228
|
+
function thingCard(model, thing) {
|
|
46229
|
+
const members = new Map(model.members.map((m) => [m.id, m]));
|
|
46230
|
+
const can = thing.can.map((id2) => members.get(id2)).filter(Boolean);
|
|
46231
|
+
const setup = can.find((m) => m.kind === "setup") ?? null;
|
|
46232
|
+
return {
|
|
46233
|
+
kind: "thing",
|
|
46234
|
+
id: thing.id,
|
|
46235
|
+
label: thing.label,
|
|
46236
|
+
doc: thing.doc ?? null,
|
|
46237
|
+
heading: READING_LABELS.thing,
|
|
46238
|
+
symbol: "thing",
|
|
46239
|
+
knows: { heading: READING_LABELS.knows, items: thing.knows.map(knowsLine) },
|
|
46240
|
+
can: { heading: READING_LABELS.can, items: can.filter((m) => m !== setup).map((m) => ({ id: m.id, label: `${m.label}${m.yesNo ? "?" : ""}`, symbol: memberSymbolId(m) })) },
|
|
46241
|
+
starts: setup ? { id: setup.id, text: READING_LABELS.starts(thing.label) } : { id: null, text: READING_LABELS.startsWithKnows(thing.label) }
|
|
46242
|
+
};
|
|
46243
|
+
}
|
|
46244
|
+
function dataCard(thing) {
|
|
46245
|
+
const record = thing.kind === "record";
|
|
46246
|
+
return {
|
|
46247
|
+
kind: record ? "record" : "choices",
|
|
46248
|
+
id: thing.id,
|
|
46249
|
+
label: thing.label,
|
|
46250
|
+
doc: thing.doc ?? null,
|
|
46251
|
+
heading: record ? READING_LABELS.record : READING_LABELS.choices,
|
|
46252
|
+
symbol: record ? "record" : "choices",
|
|
46253
|
+
symbolLabel: record ? READING_LABELS.recordSymbol : READING_LABELS.choicesSymbol,
|
|
46254
|
+
choices: [...thing.choices],
|
|
46255
|
+
knows: thing.knows.map(knowsLine)
|
|
46256
|
+
};
|
|
46257
|
+
}
|
|
46258
|
+
function ioBoxes(model, member) {
|
|
46259
|
+
const owner = member.owner ? model.things.find((t) => t.id === member.owner) : null;
|
|
46260
|
+
const kinds = member.inputKinds ?? {};
|
|
46261
|
+
const stops = (member.flow?.nodes ?? []).filter((n) => n.kind === "stop").map((n) => ({ text: n.text.replace(/^Stop:\s*/, ""), line: n.line ?? null }));
|
|
46262
|
+
return {
|
|
46263
|
+
kind: "io",
|
|
46264
|
+
id: member.id,
|
|
46265
|
+
label: `${member.label}${member.yesNo ? "?" : ""}`,
|
|
46266
|
+
doc: member.doc ?? null,
|
|
46267
|
+
symbol: memberSymbolId(member),
|
|
46268
|
+
give: { heading: READING_LABELS.give, items: member.youGive.map((label) => ({ label, kind: kinds[label] ?? null })), empty: READING_LABELS.givesNothing },
|
|
46269
|
+
getBack: { heading: READING_LABELS.getBack, text: member.youGetBack ?? null, empty: READING_LABELS.getsNothing },
|
|
46270
|
+
stops: { heading: READING_LABELS.stops, items: stops },
|
|
46271
|
+
partOf: owner ? { id: owner.id, text: READING_LABELS.partOf(owner.label) } : null
|
|
46272
|
+
};
|
|
46273
|
+
}
|
|
46274
|
+
var sectionsFor = (model, things) => {
|
|
46275
|
+
const cards = things.filter((t) => t.kind === "thing").map((t) => thingCard(model, t));
|
|
46276
|
+
const data = [...things.filter((t) => t.kind === "record"), ...things.filter((t) => t.kind === "choices")].map(dataCard);
|
|
46277
|
+
return [
|
|
46278
|
+
...cards.length ? [{ id: "things", heading: READING_LABELS.things, cards }] : [],
|
|
46279
|
+
...data.length ? [{ id: "data", heading: READING_LABELS.data, cards: data }] : []
|
|
46280
|
+
];
|
|
46281
|
+
};
|
|
46282
|
+
function readingLayout(model, { focus = null } = {}) {
|
|
46283
|
+
const base2 = { schema: READING_LAYOUT_SCHEMA };
|
|
46284
|
+
if (focus == null) return { ...base2, focus: { kind: "app", id: null }, sections: sectionsFor(model, model.things) };
|
|
46285
|
+
const member = model.members.find((m) => m.id === focus);
|
|
46286
|
+
if (member) return { ...base2, focus: { kind: "member", id: focus }, sections: [{ id: "io", heading: READING_LABELS.io, cards: [ioBoxes(model, member)] }] };
|
|
46287
|
+
const thing = model.things.find((t) => t.id === focus);
|
|
46288
|
+
if (thing) {
|
|
46289
|
+
const rest2 = model.things.filter((t) => t !== thing && t.file === thing.file && t.kind !== "thing");
|
|
46290
|
+
return { ...base2, focus: { kind: "thing", id: focus }, sections: sectionsFor(model, [thing, ...rest2]) };
|
|
46291
|
+
}
|
|
46292
|
+
if (model.files.some((f) => f.path === focus)) return { ...base2, focus: { kind: "file", id: focus }, sections: sectionsFor(model, model.things.filter((t) => t.file === focus)) };
|
|
46293
|
+
return { ...base2, focus: { kind: "unknown", id: focus }, sections: [] };
|
|
46294
|
+
}
|
|
46186
46295
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46187
46296
|
0 && (module.exports = {
|
|
46188
46297
|
ACCESSIBILITY_CLASSIFICATION,
|
|
@@ -46254,6 +46363,8 @@ function renderPassportMarkdown(p) {
|
|
|
46254
46363
|
PROOF_SCHEMA,
|
|
46255
46364
|
PROOF_STATUSES,
|
|
46256
46365
|
PROVENANCE,
|
|
46366
|
+
READING_LABELS,
|
|
46367
|
+
READING_LAYOUT_SCHEMA,
|
|
46257
46368
|
READ_LANGUAGES,
|
|
46258
46369
|
READ_REPO_SCHEMA,
|
|
46259
46370
|
READ_SCHEMA,
|
|
@@ -46345,6 +46456,7 @@ function renderPassportMarkdown(p) {
|
|
|
46345
46456
|
confidenceFromClassification,
|
|
46346
46457
|
contradictionsView,
|
|
46347
46458
|
coverageView,
|
|
46459
|
+
dataCard,
|
|
46348
46460
|
describeEdit,
|
|
46349
46461
|
detailOf,
|
|
46350
46462
|
detailParts,
|
|
@@ -46381,6 +46493,7 @@ function renderPassportMarkdown(p) {
|
|
|
46381
46493
|
intentGraphJsonSchema,
|
|
46382
46494
|
intentProofJsonSchema,
|
|
46383
46495
|
intentRefId,
|
|
46496
|
+
ioBoxes,
|
|
46384
46497
|
isCaseResult,
|
|
46385
46498
|
isFactual,
|
|
46386
46499
|
isFactualProvenance,
|
|
@@ -46392,6 +46505,7 @@ function renderPassportMarkdown(p) {
|
|
|
46392
46505
|
linkSystem,
|
|
46393
46506
|
makeEvent,
|
|
46394
46507
|
makeScope,
|
|
46508
|
+
memberSymbolId,
|
|
46395
46509
|
mergeGraphs,
|
|
46396
46510
|
minorUnitsFor,
|
|
46397
46511
|
modelText,
|
|
@@ -46423,6 +46537,7 @@ function renderPassportMarkdown(p) {
|
|
|
46423
46537
|
readScreens,
|
|
46424
46538
|
readableFile,
|
|
46425
46539
|
readableLanguage,
|
|
46540
|
+
readingLayout,
|
|
46426
46541
|
readingOf,
|
|
46427
46542
|
recoverModel,
|
|
46428
46543
|
renderExampleTable,
|
|
@@ -46477,6 +46592,7 @@ function renderPassportMarkdown(p) {
|
|
|
46477
46592
|
subjectName,
|
|
46478
46593
|
summarize,
|
|
46479
46594
|
terminatorEffect,
|
|
46595
|
+
thingCard,
|
|
46480
46596
|
thunderModel,
|
|
46481
46597
|
thunderReview,
|
|
46482
46598
|
thunderText,
|
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.
|
|
2588
|
+
var COMPILER_VERSION = "1.4.1";
|
|
2589
2589
|
var PROOF_SCHEMA_VERSION = "0.1.0";
|
|
2590
2590
|
var SOURCE_PRODUCT = "skillstech-compiler";
|
|
2591
2591
|
function buildContractGraph(ast, generatedAt) {
|