@skillstech/thunderlang 1.7.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +153 -1
- package/README.md +15 -3
- package/dist/core.cjs +303 -41
- package/dist/index.cjs +9906 -1387
- package/dist/learn.cjs +1420 -93
- package/package.json +17 -15
- package/src/cli-main.mjs +381 -149
- package/src/core/ThunderRuntime.cs +22 -1
- package/src/core/check.mjs +320 -6
- package/src/core/cli.mjs +60 -8
- package/src/core/csharp-run.mjs +2 -2
- package/src/core/diagnostics.mjs +9 -0
- package/src/core/engine-core.mjs +148 -19
- package/src/core/engine-values.mjs +3 -0
- package/src/core/engine.mjs +131 -7
- package/src/core/from-python.mjs +1 -1
- package/src/core/go-run.mjs +5 -3
- package/src/core/index.mjs +12 -3
- package/src/core/java/thunder/ThunderRuntime.java +1 -0
- package/src/core/java-run.mjs +2 -2
- package/src/core/kind.mjs +6 -0
- package/src/core/lexer.mjs +16 -2
- package/src/core/parser.mjs +215 -29
- package/src/core/project-root.mjs +18 -0
- package/src/core/project.mjs +34 -16
- package/src/core/react-run.mjs +2 -2
- package/src/core/runtime-go/thunder_runtime.go +310 -2
- package/src/core/runtime-python.mjs +365 -3
- package/src/core/runtime-typescript.mjs +150 -5
- package/src/core/rust/thunder_runtime.rs +1 -0
- package/src/core/rust-run.mjs +2 -2
- package/src/core/serving.mjs +12 -0
- package/src/core/store-format.mjs +110 -0
- package/src/core/target-csharp.mjs +14 -0
- package/src/core/target-go.mjs +24 -3
- package/src/core/target-java.mjs +14 -0
- package/src/core/target-python.mjs +46 -5
- package/src/core/target-rust.mjs +14 -0
- package/src/core/target-typescript.mjs +76 -6
- package/src/core/typescript-run.mjs +6 -4
- package/src/core-changes-fs.mjs +28 -0
- package/src/core-changes.d.mts +67 -0
- package/src/core-changes.mjs +603 -0
- package/src/core-rules.mjs +146 -0
- package/src/core-services.d.mts +4 -0
- package/src/core-services.mjs +49 -0
- package/src/emit.mjs +3 -3
- package/src/evidence-words.d.mts +6 -0
- package/src/evidence-words.mjs +47 -0
- package/src/evidence.mjs +36 -1
- package/src/examples.d.mts +21 -0
- package/src/examples.mjs +175 -0
- package/src/index.d.ts +19 -0
- package/src/index.mjs +8 -1
- package/src/learn-lessons.mjs +1 -1
- package/src/lsp.mjs +110 -0
- package/src/mcp.mjs +47 -12
- package/src/obligations.d.mts +5 -0
- package/src/obligations.mjs +30 -2
- package/src/program.d.mts +7 -0
- package/src/program.mjs +7 -0
- package/src/read-repo-fs.mjs +2 -1
- package/src/review.mjs +75 -6
- package/src/same.mjs +16 -6
- package/src/scan-queries.mjs +2 -1
- package/src/symbols.d.mts +23 -0
- package/src/symbols.mjs +351 -0
- package/src/system.mjs +1 -1
- package/src/template.d.mts +31 -0
- package/src/template.mjs +189 -0
- package/src/trace-cli.mjs +8 -3
- package/src/trace-fs.mjs +29 -3
- package/src/trace.mjs +23 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,155 @@
|
|
|
1
|
+
# 2.0.0
|
|
2
|
+
|
|
3
|
+
**Thunder 2.0: a stable language.** Thunder language 2 is specified and frozen for every 2.x release
|
|
4
|
+
([docs/spec-2.md](../docs/spec-2.md)): its grammar, its meaning on every target ([docs/meaning.md](../docs/meaning.md),
|
|
5
|
+
each rule tied to the tests that run it on Python, the Thunder engine, TypeScript, C#, Rust, Go, and Java), its
|
|
6
|
+
diagnostic codes, and a compatibility promise: a valid 2.0 program stays valid, and means the same, in every 2.x
|
|
7
|
+
release. Programs written for 1.x are read as language 2 with no changes, apart from the Never-rule fix below, which
|
|
8
|
+
makes a broken rule on a list stop the change as the rule always said.
|
|
9
|
+
|
|
10
|
+
**Upgrading from 1.8:** nothing to rewrite. New projects get `language = "2"` in `thunder.toml`. If a program added to
|
|
11
|
+
a list that a `Never allow` rule watches and relied on the rule being skipped, it now stops with TC504 at that line.
|
|
12
|
+
|
|
13
|
+
Also in 2.0: templates from data definitions (`thunder template`), go to definition, find references, and rename in
|
|
14
|
+
VS Code and every LSP editor, Core diagnostics in the editor, and one set of evidence words (Proven, Tested, Partially
|
|
15
|
+
checked, Unverified, Violated) everywhere Thunder says how strongly something is checked. Everyday commands stay
|
|
16
|
+
under the 2.0 speed targets (`thunder check`, `run`, and `test` 40 ms of CPU on Node 22).
|
|
17
|
+
|
|
18
|
+
- **Test runs no longer leave temporary folders behind** (the Go build check, and the passport, write, read, and MCP
|
|
19
|
+
tests).
|
|
20
|
+
|
|
21
|
+
- **The Thunder 2.0 language specification** (roadmap 4.1). `docs/spec-2.md`: the grammar of Thunder Core, its
|
|
22
|
+
meaning (docs/meaning.md), the diagnostic codes (frozen: never removed, renamed, or reused in 2.x), and the
|
|
23
|
+
compatibility promise (a valid 2.0 program stays valid and means the same in every 2.x release; a breaking change
|
|
24
|
+
waits for language 3, with warnings first and `thunder upgrade`). `test/spec-2.test.mjs` compiles every example in
|
|
25
|
+
it and checks its code table against the compiler's.
|
|
26
|
+
- **Language version.** `thunder.toml` names it (`[project] language = "2"`; `thunder new` writes it). A project
|
|
27
|
+
without it is read as language 2; one that names a newer major version is refused with what to install, never read
|
|
28
|
+
as something else. `thunder --version` prints `language 2`.
|
|
29
|
+
|
|
30
|
+
- **Thunder's meaning, written down** (roadmap 3.1). `docs/meaning.md` gives every rule for decimals, division,
|
|
31
|
+
rounding, text, nothing, changing values, errors, large numbers, and effects, each tied to the cross-target tests
|
|
32
|
+
that check it, and lists what no cross-target test covers yet. New `core-meaning.test.mjs` closes the gaps found:
|
|
33
|
+
shared lists and records, whole numbers past 64 bits, 28-digit decimals, text length and order by code point,
|
|
34
|
+
Unicode case, nothing in a comparison, and If this fails.
|
|
35
|
+
- **Fix: a Never rule now watches Add and Remove on a list, on every target.** Adding to a record's list field never
|
|
36
|
+
checked the record's rules, and adding to a watched list name was refused but kept the item. Now a watched list is
|
|
37
|
+
changed on a copy, checked, then kept: a refused change leaves the list as it was, like any other value.
|
|
38
|
+
- **Fix: lowercase on Go and C#.** A word-final `Σ` became `σ` instead of `ς` (Go and C#), and `İ` stayed `İ` (C#);
|
|
39
|
+
both now match Python, the Thunder engine, TypeScript, Rust, and Java.
|
|
40
|
+
- **docs/core.md:** rounding is half away from zero (`round -2.5` is `-3`); it was described as "half up".
|
|
41
|
+
|
|
42
|
+
- **Evidence words** (roadmap 4.5). Everywhere Thunder says how strongly something is checked, it now uses one of
|
|
43
|
+
five words with one meaning (docs/evidence-words.md): **Proven** (every possible input; today only structural facts,
|
|
44
|
+
like `thunder write`'s tree comparison), **Tested** (passed on the cases that ran, only those), **Partially
|
|
45
|
+
checked**, **Unverified**, **Violated**. `thunder prove` and `thunder test --contracts` print the words with the test
|
|
46
|
+
behind each claim; `thunder same` says Tested (with the count) or Partially checked; `thunder review` no longer calls
|
|
47
|
+
a rule whose code changed "only the form changed" when its answers matched on sampled edge cases (it says Tested);
|
|
48
|
+
`thunder write` labels each check. `thunder coverage` and `thunder report` say a claim *names* a check, not that it
|
|
49
|
+
is verified. Machine fields are unchanged; obligations, evidence records, `thunder same --json`, and evidence events
|
|
50
|
+
add `evidenceLevel`/`evidenceWord` (or `evidence`). Library: `EVIDENCE_WORDS`, `evidenceWord`, `combineEvidence`,
|
|
51
|
+
and one `foldObligations` / `claimStatus` used by the CLI, MCP, and the website (four copies of the status table
|
|
52
|
+
are gone).
|
|
53
|
+
- **Fixes found on the way:** a mission with any `verify` block marked every guarantee "planned" in a fresh evidence
|
|
54
|
+
record, even ones naming no check (now `needs_verification`); `thunder same` said "same answer on all N edge cases"
|
|
55
|
+
when it stopped at its 4,096-case limit (now "the first N of M"); MCP tool descriptions and site pages no longer say
|
|
56
|
+
"proves" for pattern checks and declared test cases.
|
|
57
|
+
|
|
58
|
+
- **Go to definition, find references, and rename in VS Code and any LSP editor** (roadmap 2.4). In Thunder Core
|
|
59
|
+
programs: functions, data types, alternatives, kept and stored values, top-level values, and a function's inputs
|
|
60
|
+
and values (scoped to that function), across a project's `src/` and `tests/`, using unsaved editor text. In
|
|
61
|
+
missions: decisions, rules, the fields under `input`/`output`/`data`, and other named blocks. A rename keeps each
|
|
62
|
+
use's capital letter and plural, and is refused with the reason when the name is invalid, already used, would
|
|
63
|
+
give a file a new problem (Core files are compiled again to check), or is an endpoint input callers send. Fields
|
|
64
|
+
are not covered yet. Library: `symbolAt`, `definitionsAt`, `referencesAt`, `renameAt`, `applyRename` from
|
|
65
|
+
`@skillstech/thunderlang/program`.
|
|
66
|
+
- **Thunder Core programs get Core diagnostics in the editor.** The language server used to run the mission checks
|
|
67
|
+
on every file, so a Core program showed false problems ("Unrecognized top-level block"); it now shows the Core
|
|
68
|
+
compiler's own problems at their lines, with the hint.
|
|
69
|
+
|
|
70
|
+
- **Templates from data** (roadmap D.4, the Design Recipe's template step). `thunder template <file> <data type>`
|
|
71
|
+
writes the shape of a function from a data definition: the input and a hole for an atomic kind, one `Set` line per
|
|
72
|
+
field for a record, `Depending on` with a case per alternative for an either/or type, and a call to the function
|
|
73
|
+
itself for each recursive part (`For each child in children:` for a list of the same type), with holes for the
|
|
74
|
+
answers. Checked before it is shown: added to the file it is a draft with only holes. `--name`, `--gives <kind>`,
|
|
75
|
+
`--write` (writes nothing if the template would cause a problem), `--json`. Deterministic. Library:
|
|
76
|
+
`templateOf(source, type, { name, gives })` from `@skillstech/thunderlang/program` (`thunder-template-v1`).
|
|
77
|
+
|
|
78
|
+
# 1.8.0
|
|
79
|
+
|
|
80
|
+
- **Behaviour changes across services** (roadmap 3.4 + D.5, part 2). Thunder Trace reads Thunder Core programs:
|
|
81
|
+
each endpoint is a route and each `the answer from GET "https://…"` a request, so other services link to them and
|
|
82
|
+
they link to others. A Thunder endpoint also changes when a rule it uses changes: `thunder trace impact --diff` says
|
|
83
|
+
"POST /orders/{number}/refunds changed (through review limit, which changed), and 1 caller in other repositories
|
|
84
|
+
depends on it", and, from running both versions, what changes in its answers. `thunder review --services
|
|
85
|
+
<folder,…>` adds an item for each changed endpoint another service calls, naming the callers. `thunder review
|
|
86
|
+
--evidence` gives the comparison as an `evidence-event-v1` event (`behaviour.compared`, safe-derived). The MCP tool
|
|
87
|
+
`intent_trace` with `diff` carries the same. `buildTrace` stays free of the Core compiler: `readRepoDir` reads
|
|
88
|
+
the Core facts, or pass `buildTrace(repos, { core: coreServiceFacts })`.
|
|
89
|
+
|
|
90
|
+
- **Behaviour changes in Thunder Core programs, and what to look at again** (roadmap 3.4 + D.5, part 1).
|
|
91
|
+
`thunder review` now reads `.thunder` programs instead of listing them as not read. Each rule has a stable name
|
|
92
|
+
from what it is (`function:decide refund`, `keep:review limit`, `endpoint:POST /orders`, a Never rule, a test), so
|
|
93
|
+
moved or re-spaced code is unchanged and a renamed function is a rename. A function whose steps changed, or that
|
|
94
|
+
uses something that changed, is run before and after on the same inputs (made from the numbers and text in both
|
|
95
|
+
versions), and the answers that differ are said in words with the input that decides them: "now a review Refund
|
|
96
|
+
instead of an approved Refund when amount is from $50.00 to $99.99". Tests that reach a change run before and
|
|
97
|
+
after; one that now fails comes first. Every change lists what to look at again. The rest of a changed program's
|
|
98
|
+
project is read from git for this. Tested evidence on the inputs tried, not a proof; programs run on the Thunder
|
|
99
|
+
engine only (no files, network, or saved data; step and time limits), and functions that use saved data or another
|
|
100
|
+
service are not run and say so.
|
|
101
|
+
- **`thunder affected <rule…> [--in <folder>]`**: the functions and endpoints that use a rule, the tests and Expect
|
|
102
|
+
lines that reach it, and the Never rules and stored lists they rely on, each with its file and line. Library:
|
|
103
|
+
`coreChanges(oldFiles, newFiles)` and `affectedBy(files, change)` from `@skillstech/thunderlang/program`
|
|
104
|
+
(`thunder-core-changes-v1`, `thunder-affected-v1`). MCP: `intent_core_changes` and `intent_affected` (local only).
|
|
105
|
+
|
|
106
|
+
- **Faster everyday commands (roadmap 2.0, Speed).** Each command now loads only the parts of the compiler it uses,
|
|
107
|
+
instead of all ~180 files every time. CPU time on Node 22: `thunder check` 80 → 40 ms, `thunder run` and
|
|
108
|
+
`thunder test` 90 → 40 ms, `thunder read` of a small file 110 → 60 ms, of 4,300 lines of Go 350 → 230 ms,
|
|
109
|
+
`thunder --version` 80 → 20 ms. Nothing a command prints changed. (For contributors: `compiler/scripts/lazy-cli.mjs`
|
|
110
|
+
works out, from the code, which modules each command can reach; after adding an import or a command to
|
|
111
|
+
`cli-main.mjs`, run it. A test fails if it is out of date.)
|
|
112
|
+
|
|
113
|
+
- **The reference application: Refund Desk** (`examples/apps/refund-desk`). Products and stock, orders, and refunds
|
|
114
|
+
decided by one rule, with saved data, an HTTP API, and tests, built only from shipped features. Its tests pass, and
|
|
115
|
+
a client session gets the same bytes, on Python, compiled TypeScript, and the Thunder engine. Building it fixed:
|
|
116
|
+
- `Stop … and status 404` can be written in a helper, not only in an endpoint (`Give … with status` stays in the
|
|
117
|
+
endpoint, TC218).
|
|
118
|
+
- Tests in `tests/` can call the endpoints in `src/`.
|
|
119
|
+
- While `src/` has problems, those are reported alone, not again as unknown names in the tests.
|
|
120
|
+
- **New TC219:** inside `where` or `sorted by`, a name that is both each item's field and your own value
|
|
121
|
+
(`orders where number is number` kept every order). The message says which is used and how to rename.
|
|
122
|
+
- JSON for an either/or value carries `which` and only its alternative's fields, and a request may name a two-word
|
|
123
|
+
input the way answers write it (`order_number`).
|
|
124
|
+
|
|
125
|
+
- **HTTP: answer requests and call other services.** `When someone calls GET /habits/{name}:` is an endpoint;
|
|
126
|
+
`thunder run` answers on `http://127.0.0.1:8080` (`--port` to change it), one request at a time, with inputs read by
|
|
127
|
+
kind from the path, query, or JSON body, and answers written as JSON by kind (as in a stored list). `Give … with
|
|
128
|
+
status 201` and `Stop with "…" and status 404` set the status; a broken Never rule answers 422, any other failure 500
|
|
129
|
+
in words. `the answer from GET "…" as Rate` calls another service (TC510 when it fails). Tests call endpoints
|
|
130
|
+
directly (`calling GET /habits/walk`). Python, TypeScript, and the Thunder engine give the same statuses and bytes;
|
|
131
|
+
other targets refuse it for now (TC411).
|
|
132
|
+
- **The CLI refuses an option it doesn't know** instead of ignoring it (`--core --target go` written as one word used
|
|
133
|
+
to run the default target), and suggests the closest one.
|
|
134
|
+
- **Either/or data types.** `A Payment is one of:` with one alternative per line (`Successful with amount as money`,
|
|
135
|
+
`Pending`). Build one with `a successful Payment with amount $5`; choose with `Depending on payment:`, which must
|
|
136
|
+
cover every alternative or say `Otherwise:` (TC215); read an alternative's field only where it is known, inside its
|
|
137
|
+
case or under `If payment is successful:` (TC216); a name that isn't an alternative says which ones are (TC217).
|
|
138
|
+
Alternatives can hold the same type, so trees and lists are written directly. It runs the same on every target.
|
|
139
|
+
- **Drafts with holes.** Write `?` or `?number` (`?money`, `?Habit`, …) where you don't know the value yet. Thunder
|
|
140
|
+
checks the rest, says what each hole needs (written, or expected where it stands) and what in scope already fits,
|
|
141
|
+
and never chooses a value (TC120). A draft never runs or builds; `thunder check` calls it a draft and counts holes
|
|
142
|
+
apart from problems. `compileCore` gives `holes` and `draft` for editors and OpenThunder.
|
|
143
|
+
- **Saved data: stored lists.** `Store habits as a list of Habit` keeps a list of records between runs, in
|
|
144
|
+
`data/habits.json` (plain JSON, each field written by its kind; money and numbers exact). It is filled when the
|
|
145
|
+
program starts and saved only when it finishes well; tests start empty and never save. Python, compiled TypeScript,
|
|
146
|
+
compiled Go, and the Thunder engine read and write the same file, byte for byte; other targets refuse it for now
|
|
147
|
+
(new TC410). A damaged file is reported at the `Store` line with the item and field (TC509), the same on every engine.
|
|
148
|
+
- **`examplesOf(source)`: every example in a file, as data.** From `@skillstech/thunderlang/program` (and the main
|
|
149
|
+
entry): each Core `Expect` and each mission `case` or `scenario`, with its line, the function or decision it checks,
|
|
150
|
+
its inputs as written, and the expected answer (`thunder-examples-v1`). Examples are read even while another part of
|
|
151
|
+
the file does not compile. Tools such as OpenThunder's Check can stop parsing Thunder text.
|
|
152
|
+
|
|
1
153
|
# 1.7.0
|
|
2
154
|
|
|
3
155
|
- **.NET and NuGet from Thunder Core.** `Use "System.IO.Path" from .NET as paths` and `Use "Humanizer.NumberToWordsExtension"
|
|
@@ -1610,7 +1762,7 @@ The executable + interoperable release. Everything is deterministic and requires
|
|
|
1610
1762
|
returns the canonical graph + flat PM fields; `proposeIntent(structured, { base })` regenerates
|
|
1611
1763
|
ThunderLang source with a reviewable diff, surfaced ambiguities (non-factual nodes), round-trip
|
|
1612
1764
|
fidelity gaps, and validation , never a silent rewrite. Browser-safe via `/core` (for Studio).
|
|
1613
|
-
- **Comment-preserving structural editing (`intent-patch-v1`).** `
|
|
1765
|
+
- **Comment-preserving structural editing (`intent-patch-v1`).** `applyRename(source, edits)`
|
|
1614
1766
|
applies field-level edits (`setField`, `add/removeGuarantee`, `add/removeNever`,
|
|
1615
1767
|
`add/removeField`, `setFieldType` on inputs/outputs, `add/removeMetric`, `setMetricField`,
|
|
1616
1768
|
`add/removeOutcome`, and decision rules `add/removeRule`/`setRule`/`setDefault`) directly to
|
package/README.md
CHANGED
|
@@ -8,6 +8,11 @@ result, so intent can be diffed, merged, tested, and trusted.
|
|
|
8
8
|
|
|
9
9
|
Part of [ThunderLang](https://thunderlang.dev), the intent language for AI-era software.
|
|
10
10
|
|
|
11
|
+
**Thunder 2.0 is a stable language.** Thunder language 2 is [specified](https://thunderlang.dev/docs/spec-2) and frozen
|
|
12
|
+
for every 2.x release: the grammar, [what every program means on every target](https://thunderlang.dev/docs/meaning)
|
|
13
|
+
(each rule tied to the tests that run it on Python, the Thunder engine, TypeScript, C#, Rust, Go, and Java), the
|
|
14
|
+
diagnostic codes, and a compatibility promise. `thunder --version` prints the language it speaks.
|
|
15
|
+
|
|
11
16
|
**Learn ThunderLang:** the [10-minute tutorial](https://thunderlang.dev/learn), then the
|
|
12
17
|
[full course on Skills Tech Talk](https://app.skillstechtalk.com/learn/technology/t/thunderlang).
|
|
13
18
|
The tutorial also ships in this package as data (`@skillstech/thunderlang/learn`): 12 lessons on reading code, and
|
|
@@ -55,6 +60,12 @@ thunder diff <before> <after> thunder merge <base> <ours> <theirs>
|
|
|
55
60
|
|
|
56
61
|
# Code <-> intent
|
|
57
62
|
thunder lift <file> thunder approve <file> thunder drift <file>
|
|
63
|
+
|
|
64
|
+
# What a change does
|
|
65
|
+
thunder review main # what changed in meaning since main; Core programs compared rule by rule and run
|
|
66
|
+
thunder review main --services ../web,../billing # also the services that call a changed endpoint
|
|
67
|
+
thunder affected "review limit" --in app/ # what to look at again when a rule changes: functions, tests, Never rules
|
|
68
|
+
thunder trace impact --diff ../web ../orders # what the current changes can affect across repositories
|
|
58
69
|
```
|
|
59
70
|
|
|
60
71
|
Run `thunder help` for the full reference.
|
|
@@ -158,11 +169,12 @@ scannable location: `contract-graph.json`, `architecture-graph.json`,
|
|
|
158
169
|
|
|
159
170
|
## Status
|
|
160
171
|
|
|
161
|
-
Deterministic and tested (
|
|
172
|
+
Deterministic and tested (about 2,000 tests: unit, property, fuzz, composition, and cross-language conformance).
|
|
173
|
+
Each command loads only the parts of the compiler it uses (`thunder check` takes about 40 ms of CPU on Node 22). Five-profile
|
|
162
174
|
language with an executable runtime, first-class tests, outcome contracts, style intent,
|
|
163
175
|
governance/privacy, and security/type checks; nine export adapters
|
|
164
176
|
(DMN/BPMN/NuSMV/JSON-Schema/OpenAPI/Design-Tokens/CSS/Mermaid/Playwright), DMN/BPMN import,
|
|
165
177
|
native graph<->source round-trip, schema migrations, a canonical proof envelope
|
|
166
|
-
(`intent-proof-v1`), and SARIF code-scanning output.
|
|
167
|
-
`intent-graph-v1` schema
|
|
178
|
+
(`intent-proof-v1`), and SARIF code-scanning output. The language may still change before 2.0.0;
|
|
179
|
+
from 2.0.0, programs stay compatible or `thunder upgrade` updates them. The `intent-graph-v1` schema versions on its own. See the
|
|
168
180
|
[docs](https://thunderlang.dev/docs) and the [spec](https://thunderlang.dev/docs/spec).
|