@skillstech/thunderlang 1.6.1 → 1.8.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +10 -3
  3. package/dist/core.cjs +264 -47
  4. package/dist/index.cjs +9118 -1077
  5. package/dist/learn.cjs +1419 -90
  6. package/package.json +1 -1
  7. package/src/ai.mjs +2 -1
  8. package/src/atlas.mjs +2 -1
  9. package/src/behaviour.mjs +246 -0
  10. package/src/cli-main.mjs +3015 -0
  11. package/src/cli.mjs +9 -2799
  12. package/src/conflict.mjs +0 -0
  13. package/src/core/ThunderDotnet.cs +195 -0
  14. package/src/core/check.mjs +316 -10
  15. package/src/core/cli.mjs +67 -10
  16. package/src/core/csharp-run.mjs +29 -8
  17. package/src/core/diagnostics.mjs +12 -1
  18. package/src/core/engine-core.mjs +161 -20
  19. package/src/core/engine-values.mjs +1 -0
  20. package/src/core/engine.mjs +131 -7
  21. package/src/core/go-run.mjs +3 -2
  22. package/src/core/index.mjs +6 -2
  23. package/src/core/java-run.mjs +3 -3
  24. package/src/core/kind.mjs +45 -0
  25. package/src/core/lexer.mjs +16 -2
  26. package/src/core/parser.mjs +254 -22
  27. package/src/core/project-root.mjs +18 -0
  28. package/src/core/project.mjs +18 -18
  29. package/src/core/react-run.mjs +3 -3
  30. package/src/core/runtime-go/thunder_runtime.go +269 -1
  31. package/src/core/runtime-npm.mjs +79 -0
  32. package/src/core/runtime-python.mjs +365 -3
  33. package/src/core/runtime-react.mjs +2 -1
  34. package/src/core/runtime-typescript.mjs +155 -6
  35. package/src/core/rust-run.mjs +3 -2
  36. package/src/core/serving.mjs +12 -0
  37. package/src/core/store-format.mjs +110 -0
  38. package/src/core/target-csharp.mjs +5 -1
  39. package/src/core/target-go.mjs +11 -4
  40. package/src/core/target-python.mjs +39 -6
  41. package/src/core/target-rust.mjs +1 -1
  42. package/src/core/target-typescript.mjs +95 -7
  43. package/src/core/typescript-run.mjs +14 -7
  44. package/src/core-changes-fs.mjs +28 -0
  45. package/src/core-changes.d.mts +67 -0
  46. package/src/core-changes.mjs +603 -0
  47. package/src/core-rules.mjs +146 -0
  48. package/src/core-services.d.mts +4 -0
  49. package/src/core-services.mjs +49 -0
  50. package/src/decision.mjs +2 -1
  51. package/src/distributed.mjs +2 -1
  52. package/src/emit.mjs +2 -2
  53. package/src/evidence.mjs +28 -0
  54. package/src/examples.d.mts +21 -0
  55. package/src/examples.mjs +175 -0
  56. package/src/focus.mjs +2 -1
  57. package/src/index.d.ts +4 -0
  58. package/src/index.mjs +4 -0
  59. package/src/intent-atlas.mjs +4 -3
  60. package/src/mcp.mjs +52 -6
  61. package/src/passport-fs.mjs +2 -1
  62. package/src/passport.mjs +2 -1
  63. package/src/privacy.mjs +2 -1
  64. package/src/program.d.mts +4 -0
  65. package/src/program.mjs +4 -0
  66. package/src/read-repo-fs.mjs +2 -1
  67. package/src/read-repo.mjs +3 -2
  68. package/src/report.mjs +3 -2
  69. package/src/review.mjs +71 -4
  70. package/src/select.mjs +2 -1
  71. package/src/semantic-diff.mjs +7 -6
  72. package/src/system.mjs +3 -2
  73. package/src/text-order.mjs +6 -0
  74. package/src/thunderize.mjs +2 -1
  75. package/src/trace-cli.mjs +8 -3
  76. package/src/trace-data.mjs +3 -2
  77. package/src/trace-fs.mjs +29 -3
  78. package/src/trace.mjs +27 -10
  79. package/src/write-across-cli.mjs +22 -4
  80. package/src/write-across.mjs +2 -1
  81. package/syntaxes/thunder.tmLanguage.json +196 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,124 @@
1
+ # 1.8.0
2
+
3
+ - **Behaviour changes across services** (roadmap 3.4 + D.5, part 2). Thunder Trace reads Thunder Core programs:
4
+ each endpoint is a route and each `the answer from GET "https://…"` a request, so other services link to them and
5
+ they link to others. A Thunder endpoint also changes when a rule it uses changes: `thunder trace impact --diff` says
6
+ "POST /orders/{number}/refunds changed (through review limit, which changed), and 1 caller in other repositories
7
+ depends on it", and, from running both versions, what changes in its answers. `thunder review --services
8
+ <folder,…>` adds an item for each changed endpoint another service calls, naming the callers. `thunder review
9
+ --evidence` gives the comparison as an `evidence-event-v1` event (`behaviour.compared`, safe-derived). The MCP tool
10
+ `intent_trace` with `diff` carries the same. `buildTrace` stays free of the Core compiler: `readRepoDir` reads
11
+ the Core facts, or pass `buildTrace(repos, { core: coreServiceFacts })`.
12
+
13
+ - **Behaviour changes in Thunder Core programs, and what to look at again** (roadmap 3.4 + D.5, part 1).
14
+ `thunder review` now reads `.thunder` programs instead of listing them as not read. Each rule has a stable name
15
+ from what it is (`function:decide refund`, `keep:review limit`, `endpoint:POST /orders`, a Never rule, a test), so
16
+ moved or re-spaced code is unchanged and a renamed function is a rename. A function whose steps changed, or that
17
+ uses something that changed, is run before and after on the same inputs (made from the numbers and text in both
18
+ versions), and the answers that differ are said in words with the input that decides them: "now a review Refund
19
+ instead of an approved Refund when amount is from $50.00 to $99.99". Tests that reach a change run before and
20
+ after; one that now fails comes first. Every change lists what to look at again. The rest of a changed program's
21
+ project is read from git for this. Tested evidence on the inputs tried, not a proof; programs run on the Thunder
22
+ engine only (no files, network, or saved data; step and time limits), and functions that use saved data or another
23
+ service are not run and say so.
24
+ - **`thunder affected <rule…> [--in <folder>]`**: the functions and endpoints that use a rule, the tests and Expect
25
+ lines that reach it, and the Never rules and stored lists they rely on, each with its file and line. Library:
26
+ `coreChanges(oldFiles, newFiles)` and `affectedBy(files, change)` from `@skillstech/thunderlang/program`
27
+ (`thunder-core-changes-v1`, `thunder-affected-v1`). MCP: `intent_core_changes` and `intent_affected` (local only).
28
+
29
+ - **Faster everyday commands (roadmap 2.0, Speed).** Each command now loads only the parts of the compiler it uses,
30
+ instead of all ~180 files every time. CPU time on Node 22: `thunder check` 80 → 40 ms, `thunder run` and
31
+ `thunder test` 90 → 40 ms, `thunder read` of a small file 110 → 60 ms, of 4,300 lines of Go 350 → 230 ms,
32
+ `thunder --version` 80 → 20 ms. Nothing a command prints changed. (For contributors: `compiler/scripts/lazy-cli.mjs`
33
+ works out, from the code, which modules each command can reach; after adding an import or a command to
34
+ `cli-main.mjs`, run it. A test fails if it is out of date.)
35
+
36
+ - **The reference application: Refund Desk** (`examples/apps/refund-desk`). Products and stock, orders, and refunds
37
+ decided by one rule, with saved data, an HTTP API, and tests, built only from shipped features. Its tests pass, and
38
+ a client session gets the same bytes, on Python, compiled TypeScript, and the Thunder engine. Building it fixed:
39
+ - `Stop … and status 404` can be written in a helper, not only in an endpoint (`Give … with status` stays in the
40
+ endpoint, TC218).
41
+ - Tests in `tests/` can call the endpoints in `src/`.
42
+ - While `src/` has problems, those are reported alone, not again as unknown names in the tests.
43
+ - **New TC219:** inside `where` or `sorted by`, a name that is both each item's field and your own value
44
+ (`orders where number is number` kept every order). The message says which is used and how to rename.
45
+ - JSON for an either/or value carries `which` and only its alternative's fields, and a request may name a two-word
46
+ input the way answers write it (`order_number`).
47
+
48
+ - **HTTP: answer requests and call other services.** `When someone calls GET /habits/{name}:` is an endpoint;
49
+ `thunder run` answers on `http://127.0.0.1:8080` (`--port` to change it), one request at a time, with inputs read by
50
+ kind from the path, query, or JSON body, and answers written as JSON by kind (as in a stored list). `Give … with
51
+ status 201` and `Stop with "…" and status 404` set the status; a broken Never rule answers 422, any other failure 500
52
+ in words. `the answer from GET "…" as Rate` calls another service (TC510 when it fails). Tests call endpoints
53
+ directly (`calling GET /habits/walk`). Python, TypeScript, and the Thunder engine give the same statuses and bytes;
54
+ other targets refuse it for now (TC411).
55
+ - **The CLI refuses an option it doesn't know** instead of ignoring it (`--core --target go` written as one word used
56
+ to run the default target), and suggests the closest one.
57
+ - **Either/or data types.** `A Payment is one of:` with one alternative per line (`Successful with amount as money`,
58
+ `Pending`). Build one with `a successful Payment with amount $5`; choose with `Depending on payment:`, which must
59
+ cover every alternative or say `Otherwise:` (TC215); read an alternative's field only where it is known, inside its
60
+ case or under `If payment is successful:` (TC216); a name that isn't an alternative says which ones are (TC217).
61
+ Alternatives can hold the same type, so trees and lists are written directly. It runs the same on every target.
62
+ - **Drafts with holes.** Write `?` or `?number` (`?money`, `?Habit`, …) where you don't know the value yet. Thunder
63
+ checks the rest, says what each hole needs (written, or expected where it stands) and what in scope already fits,
64
+ and never chooses a value (TC120). A draft never runs or builds; `thunder check` calls it a draft and counts holes
65
+ apart from problems. `compileCore` gives `holes` and `draft` for editors and OpenThunder.
66
+ - **Saved data: stored lists.** `Store habits as a list of Habit` keeps a list of records between runs, in
67
+ `data/habits.json` (plain JSON, each field written by its kind; money and numbers exact). It is filled when the
68
+ program starts and saved only when it finishes well; tests start empty and never save. Python, compiled TypeScript,
69
+ compiled Go, and the Thunder engine read and write the same file, byte for byte; other targets refuse it for now
70
+ (new TC410). A damaged file is reported at the `Store` line with the item and field (TC509), the same on every engine.
71
+ - **`examplesOf(source)`: every example in a file, as data.** From `@skillstech/thunderlang/program` (and the main
72
+ entry): each Core `Expect` and each mission `case` or `scenario`, with its line, the function or decision it checks,
73
+ its inputs as written, and the expected answer (`thunder-examples-v1`). Examples are read even while another part of
74
+ the file does not compile. Tools such as OpenThunder's Check can stop parsing Thunder text.
75
+
76
+ # 1.7.0
77
+
78
+ - **.NET and NuGet from Thunder Core.** `Use "System.IO.Path" from .NET as paths` and `Use "Humanizer.NumberToWordsExtension"
79
+ from NuGet "Humanizer.Core" version "2.14.1" as words` give a program compiled to C# the .NET ecosystem. Static
80
+ methods and properties are called by name; the overload is chosen by which parameters every value fits; numbers come
81
+ back exact (`decimal` as written, `double` as it prints). The NuGet package and its version go into the generated
82
+ project. Programs that use .NET libraries run with real culture data, pinned to en-US. A failure is TC508 with its
83
+ real cause; every other target and the Thunder engine refuse a .NET library (new TC409).
84
+ - **See what a change does: `thunder write --behaviour`.** For Python, Thunder runs each edited function before and
85
+ after the change on inputs made from its own code (its numbers and one either side, its text, yes/no, the edges)
86
+ and lists the inputs whose answer changed: `amount 100, days 29, refunded False: before 'approve', after
87
+ 'review'`. Printed output and errors count. It runs your code, so it is opt-in; a changed file that no longer
88
+ loads is reported and not saved. Also `behaviour: true` on the MCP tool `intent_write`. Tested evidence on those
89
+ inputs, never called a proof. Across services too: `thunder write web orders billing --decision … --when …
90
+ --behaviour` runs each Python implementation (the checkout demo shows `subtotal 40: before 5.99, after 0`).
91
+ - **The read ↔ write round trip runs on made inputs too.** `docs/core-read-write.md` now also compares the original
92
+ Python with Core compiled back to Python on inputs made from each function's code: 11 of 11 functions, 134 of 134
93
+ inputs give the same results (alongside the 53 hand-picked inputs).
94
+ - **A `.thunder` file says what it is.** Outside a project, a file whose first line cannot start a mission
95
+ (`say "Hello"`, `Set total to 0`, `To greet:`, `A Trade has:`) is now run, tested, and checked as Thunder Core
96
+ without `--core`: `thunder run hello.thunder` just works. Files that start with a mission keyword stay missions,
97
+ so no existing mission changes meaning; a file that could be either (`use csv` alone) stays a mission, and
98
+ `--mission` / `--core` still decide when given. A mission check that finds no mission now says how to read the
99
+ file as a program.
100
+ - **One map of the language.** New docs page, *The Thunder language*: Thunder Text, Thunder Core, and missions side
101
+ by side with the same rule in each, which to use when, and how a file's kind is decided.
102
+ - **npm packages from Thunder Core.** `Use "date-fns" from npm as dates` gives a program compiled to TypeScript the npm
103
+ ecosystem, the way `Use csv as csv` gives Python programs Python's. Values cross the boundary in plain rules (lists
104
+ become arrays, records become objects, dates become a local-midnight `Date`), and numbers come back as the exact
105
+ decimal they are written as, so `0.07 + 0.01` is still exactly `0.08`. Scoped packages, paths inside a package,
106
+ `node:` built-ins, and one-function CommonJS packages (`.default`) work. A failure inside the package, a missing
107
+ name, or a promise is TC508 in words, against the Thunder line that called it. Every other target, and the Thunder
108
+ engine, refuses an npm package (new TC408) instead of guessing. `npm_packages.d.ts` keeps `tsc --strict` passing for
109
+ packages without types. `Use csv from Python as csv` is accepted too.
110
+ - **Faster start.** Every command starts about a quarter faster in CPU time: the Unicode collation data no longer loads
111
+ at start (sorting is by character order now, the same on every machine, where it used to depend on the machine's
112
+ locale), and on Node 22.1+ Thunder turns on Node's compile cache, so the compiler is not parsed again on every
113
+ command. `compiler/scripts/speed.mjs` measures everyday commands.
114
+ - **The engine never runs a program that did not compile.** `runInProcess`, `recordedRun`, and `testInProcess` (used by
115
+ the site and OpenThunder) now refuse with the program's problems; before, a test could pass on a broken program.
116
+ - **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:
117
+ Thunder skips "a", "an", and "the" in names`, with a suggestion, instead of `"Receive" is missing a name`.
118
+ - **On thunderlang.dev:** a Thunder playground (write a program; see what it prints, try its functions with your own
119
+ values, run its tests, step through it; share it by link), and ThunderBench, an open benchmark with every result
120
+ published (`thunderbench/`).
121
+
1
122
  # 1.6.1
2
123
 
3
124
  - **Fix: Thunder write wrote names the code does not have.** A word that is no name in the function or file
package/README.md CHANGED
@@ -55,6 +55,12 @@ thunder diff <before> <after> thunder merge <base> <ours> <theirs>
55
55
 
56
56
  # Code <-> intent
57
57
  thunder lift <file> thunder approve <file> thunder drift <file>
58
+
59
+ # What a change does
60
+ thunder review main # what changed in meaning since main; Core programs compared rule by rule and run
61
+ thunder review main --services ../web,../billing # also the services that call a changed endpoint
62
+ thunder affected "review limit" --in app/ # what to look at again when a rule changes: functions, tests, Never rules
63
+ thunder trace impact --diff ../web ../orders # what the current changes can affect across repositories
58
64
  ```
59
65
 
60
66
  Run `thunder help` for the full reference.
@@ -158,11 +164,12 @@ scannable location: `contract-graph.json`, `architecture-graph.json`,
158
164
 
159
165
  ## Status
160
166
 
161
- Deterministic and tested (330+ tests: unit, property, fuzz, composition). Five-profile
167
+ Deterministic and tested (about 2,000 tests: unit, property, fuzz, composition, and cross-language conformance).
168
+ 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
169
  language with an executable runtime, first-class tests, outcome contracts, style intent,
163
170
  governance/privacy, and security/type checks; nine export adapters
164
171
  (DMN/BPMN/NuSMV/JSON-Schema/OpenAPI/Design-Tokens/CSS/Mermaid/Playwright), DMN/BPMN import,
165
172
  native graph<->source round-trip, schema migrations, a canonical proof envelope
166
- (`intent-proof-v1`), and SARIF code-scanning output. Draft (pre-1.0): the language and
167
- `intent-graph-v1` schema version independently and may still change. See the
173
+ (`intent-proof-v1`), and SARIF code-scanning output. The language may still change before 2.0.0;
174
+ from 2.0.0, programs stay compatible or `thunder upgrade` updates them. The `intent-graph-v1` schema versions on its own. See the
168
175
  [docs](https://thunderlang.dev/docs) and the [spec](https://thunderlang.dev/docs/spec).