@skillstech/thunderlang 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillstech/thunderlang",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "Thunder™, the human programming language: the deterministic ThunderLang™ compiler, CLI, and Language Server. No AI required. Reads code in seventeen languages into Thunder, changes TypeScript, JavaScript, Python, and Go code from Thunder with a proof, compiles rules to six languages, and executes them: run decisions, simulate lifecycles, and check outcome contracts. Interops with DMN, BPMN, JSON Schema, and OpenAPI.",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
@@ -33,6 +33,15 @@
33
33
  "import": "./src/learn.mjs",
34
34
  "require": "./dist/learn.cjs"
35
35
  },
36
+ "./program": {
37
+ "types": "./src/program.d.mts",
38
+ "import": "./src/program.mjs"
39
+ },
40
+ "./react": {
41
+ "types": "./src/react/reading.d.mts",
42
+ "import": "./src/react/reading.mjs"
43
+ },
44
+ "./react/reading.css": "./src/react/reading.css",
36
45
  "./package.json": "./package.json"
37
46
  },
38
47
  "bin": {
@@ -64,6 +73,14 @@
64
73
  "devDependencies": {
65
74
  "esbuild": "^0.28.1"
66
75
  },
76
+ "peerDependencies": {
77
+ "react": ">=18"
78
+ },
79
+ "peerDependenciesMeta": {
80
+ "react": {
81
+ "optional": true
82
+ }
83
+ },
67
84
  "keywords": [
68
85
  "thunder",
69
86
  "thunder-programming-language",
package/src/cli-home.mjs CHANGED
@@ -9,7 +9,7 @@ import { findPython, findProjectRoot } from './core/project.mjs';
9
9
  import { paint, useColor } from './term.mjs';
10
10
 
11
11
  /** The commands `thunder` understands besides those listed in the full help (kept in sync by a test). */
12
- export const EXTRA_COMMANDS = ['doctor', 'completion', 'plain', 'ai', 'coverage', 'completions', 'hover', 'format', 'help', 'version', 'mission', 'why', 'trace', 'graph', 'proof', 'build'];
12
+ export const EXTRA_COMMANDS = ['doctor', 'completion', 'plain', 'ai', 'coverage', 'completions', 'hover', 'format', 'help', 'version', 'mission', 'why', 'trace', 'passport', 'graph', 'proof', 'build'];
13
13
 
14
14
  /** Every command name: the ones the full help lists, plus EXTRA_COMMANDS. */
15
15
  export function knownCommands(fullHelp) {
package/src/cli.mjs CHANGED
@@ -27,6 +27,7 @@ import { readCode, searchReading } from './read.mjs';
27
27
  import { readRepo, searchRepo, groupByFile } from './read-repo.mjs';
28
28
  import { promoteDecision } from './promote.mjs';
29
29
  import { collectReadableFiles } from './read-repo-fs.mjs';
30
+ import { accessFlow, accessText } from './flow/access.mjs';
30
31
  import { translateDecisions } from './translate.mjs';
31
32
  import {
32
33
  buildContractGraph, buildArchitectureGraph, buildImplementationPlan,
@@ -51,6 +52,8 @@ import { runtimeOverlay, runtimeText, fromTrace, fromStack, fromLogs, fromOtlp,
51
52
  import { thunderModel } from './model.mjs';
52
53
  import { LEVELS, readLevel, renderLevel, findFocus, nearestLevel } from './read-level.mjs';
53
54
  import { traceMain } from './trace-cli.mjs';
55
+ import { passportMain } from './passport-cli.mjs';
56
+ import { isWriteAcross, writeAcrossMain } from './write-across-cli.mjs';
54
57
  import { whyMain } from './why-cli.mjs';
55
58
  import { tryMain } from './try-cli.mjs';
56
59
  import { replayMain } from './replay-cli.mjs';
@@ -370,6 +373,7 @@ function parseArgs(argv) {
370
373
  else if (a === '--mission') args.mission = true;
371
374
  else if (a === '--core') args.core = true;
372
375
  else if (a === '--as-core') args.asCore = true;
376
+ else if (a === '--access') args.access = true;
373
377
  else if (a === '--write' || a === '-w') args.write = true;
374
378
  else if (a === '--check') args.check = true;
375
379
  else if (a === '--schema') args.schema = true;
@@ -487,6 +491,7 @@ Read and understand code
487
491
  read <file|dir> --level big-picture|flow|details|text|original [--focus "<action or rule>"] [--json]
488
492
  read at one depth, from the same model OpenThunder shows: the big picture, one action's flow,
489
493
  its exact details, its Thunder Text, or the original lines
494
+ read <dir> --access which web routes limit a record chosen by the request to the caller (TypeScript/JavaScript)
490
495
  read <file.py> --as-core the same code as Thunder Core you can edit and run (Python for now); lines it cannot say exactly are marked
491
496
  for a folder also: [--answer <Outcome>] [--input <name>] [--lang go,rust] [--path <prefix>] [--limit n]
492
497
  --promote <decision> [--out <file>] turn a recovered decision into a contract with starter examples
@@ -501,6 +506,8 @@ Read and understand code
501
506
  when omitted), as Markdown for a pull request comment; read from git, no network
502
507
  trace <folder…> [--json] [--out f] Thunder Trace: routes, requests, and events linked across repositories, cited repo@sha:file:line
503
508
  trace impact <thing | --diff [--base ref]> <folder…> what a change can affect in other repositories (one hop, ranked by risk)
509
+ passport <folder…> [--base ref] [--run "part: cmd"…] [--purpose …] an evidence record: behavior, links, effects, evidence with its limits, what is not verified
510
+ passport check <passport.json> which of its claims are still about the code as it is now (current or stale)
504
511
  repo <owner/repo | github url | folder> [--json] [--max-files n] Thunder a whole repository (read-only; nothing is executed)
505
512
  thunderize <folder | owner/repo> [--out <dir>] [--json] the whole app in Thunder Text: one .thunder-text per file + APP.thunder-text
506
513
 
@@ -514,6 +521,9 @@ Change code
514
521
  write <file> --decision <name> --rule <n|otherwise> [--when "<condition>"] [--answer <Outcome>] [--write] [--json]
515
522
  Thunder write: change a number, comparison, text value, or answer in a recovered rule;
516
523
  previews the exact code change and the cases whose answer changes; --write saves it
524
+ write <folder…> --decision <name> --rule <n> --when "<condition>" [--write] [--run "part: cmd"] [--passport f.json]
525
+ one rule change in every service that implements it (TypeScript, C#, Python…):
526
+ the plan first; --write changes all of them or none; tests and a passport as proof
517
527
 
518
528
  ────────────────────────────────────────────────────────────────────────
519
529
  Advanced: rules and missions (ThunderLang™ intent files), proofs, and tools for editors and CI.
@@ -640,6 +650,7 @@ function main() {
640
650
  if (!known.includes(cmd) && !cmd.startsWith('-') && !existsSync(cmd)) { console.error(paint(unknownCommandText(cmd, known), useColor(process.stderr))); process.exitCode = 2; return; }
641
651
  // Thunder Trace: links between repositories and what a change can affect (src/trace-cli.mjs).
642
652
  if (cmd === 'trace') { process.exitCode = traceMain(restArgv); return; }
653
+ if (cmd === 'passport') { passportMain(restArgv).then((code) => { process.exitCode = code; }); return; }
643
654
  // Thunder Why: an AI agent's run explained in plain words, from its OpenTelemetry record (src/why-cli.mjs).
644
655
  if (cmd === 'why') { process.exitCode = whyMain(restArgv); return; }
645
656
  // Thunder Try: try a rule from your code with your own values, and see the answer and why (src/try-cli.mjs).
@@ -672,6 +683,16 @@ function main() {
672
683
  console.log(paint(renderLevel(r, { sources: Object.fromEntries(files.map((f) => [f.path, f.source])), file })));
673
684
  return;
674
685
  }
686
+ if (args.access) {
687
+ // Ownership on web routes: the same accessFlow() the readings and OpenThunder use (docs/access-flow.md).
688
+ const isDir = statSync(file).isDirectory();
689
+ const files = isDir ? collectReadableFiles(file, { maxFiles: 20000 }).filter((f) => f.source) : [{ path: basename(file), source: readFileSync(file, 'utf8') }];
690
+ const report = accessFlow(files);
691
+ if (args.json) { console.log(JSON.stringify(report, null, 2)); return; }
692
+ console.log(paint(accessText(report)));
693
+ if (report.summary.unguarded) process.exitCode = 1;
694
+ return;
695
+ }
675
696
  if (statSync(file).isDirectory()) { readFolder(file, args); return; }
676
697
  if (args.asCore) {
677
698
  // Reading and writing are one language: the reader's meaning tree printed as Thunder Core (docs/core.md).
@@ -728,6 +749,8 @@ function main() {
728
749
  } catch (e) { console.error(`thunder read: ${e.message}`); process.exitCode = 2; }
729
750
  return;
730
751
  }
752
+ // One rule change written into every service that implements it (src/write-across-cli.mjs).
753
+ if (cmd === 'write' && isWriteAcross(restArgv)) { writeAcrossMain(restArgv).then((code) => { process.exitCode = code; }); return; }
731
754
  if (cmd === 'write' && args.edit) {
732
755
  try {
733
756
  if (!file) throw new Error('Use thunder write <file> --edit \'{"op":"setValue","member":"name","step":"line:12","to":10}\' [--apply] [--test "<cmd>"].');
package/src/core.d.ts CHANGED
@@ -33,6 +33,19 @@ export interface Screen {
33
33
  role?: 'page' | 'top' | 'part'; roleWhy?: string;
34
34
  }
35
35
  export interface ScreenLine { says: string; line?: number; kids?: ScreenLine[]; otherwise?: { says: string; line?: number; kids: ScreenLine[] }; notRead?: boolean; /** for a not-read line: the code, without the "not read:" words */ code?: string }
36
+ /** A step on an access path, linked to its source line. */
37
+ export interface AccessStep { kind: 'input' | 'identity' | 'lookup' | 'change' | 'guard' | 'response' | 'stopped'; says: string; file: string; line: number | null }
38
+ export type AccessVerdict = 'guarded' | 'unguarded' | 'cannot tell';
39
+ /** One path from the request to a response or a change, about one record (src/flow/access.mjs). */
40
+ export interface AccessPath { verdict: AccessVerdict; why: string; steps: AccessStep[]; record: string | null; lines: number[] }
41
+ /** One web route's ownership verdict; null when it reads or changes no stored record chosen by the request. */
42
+ export interface AccessRoute { method: string; path: string; framework: string; file: string; line: number; verdict: AccessVerdict | null; why: string; identity: { says: string; file: string; line: number } | null; paths: AccessPath[] }
43
+ export interface AccessReport { schema: 'thunder-access-v1'; routes: AccessRoute[]; summary: { routes: number; guarded: number; unguarded: number; cannotTell: number; noLookup: number }; unread: Array<{ file: string; line: number | null; why: string }> }
44
+ export const ACCESS_SCHEMA: 'thunder-access-v1';
45
+ /** Does every path that hands back or changes a record chosen by the request limit it to the caller? TypeScript/JavaScript. */
46
+ export function accessFlow(files: Array<{ path: string; source: string }>, options?: { maxRoutes?: number }): AccessReport;
47
+ export function accessText(report: AccessReport): string;
48
+ export function ownershipWords(route: AccessRoute): string | null;
36
49
  export function readScreens(files: Array<{ path: string; source: string }>, options?: { members?: unknown[] }): Screen[];
37
50
  export function screenText(screen: Screen): string;
38
51
  export { RUNNING_SCHEMA, runtimeOverlay, runtimeText, explainError, parseStack, parseStacks, fromTrace, fromStack, fromLogs, fromOtlp, nodeNote } from './running.mjs';
@@ -159,3 +172,35 @@ export { readRepo, searchRepo, groupByFile, readableLanguage, readableFile, read
159
172
  export type { RepoItem, RepoFacet, RepoReading, RepoFilter } from './read-repo.mjs';
160
173
  export { promoteDecision, PROMOTE_SCHEMA } from './promote.mjs';
161
174
  export type { Promotion } from './promote.mjs';
175
+
176
+ // Everything OpenThunder's Read in Thunder and Thunder Live use (see src/core.mjs).
177
+ export { COLORS, SYMBOLS, DOES } from './visual.mjs';
178
+ export type { ColorRole as VisualColorRole } from './visual.mjs';
179
+ export type { ThunderModel, Member, Thing, FlowNode, Flow, LevelView } from './model.mjs';
180
+ export { terminatorEffect, toThunderCondition, toThunderOutcome, sayCondition } from './read.mjs';
181
+ export type { ReadStep } from './read.mjs';
182
+ export { PASSPORT_SCHEMA, ALWAYS_NOT_VERIFIED, assemblePassport, summarize, checkPassport, renderPassportSummary, renderPassportMarkdown } from './passport.mjs';
183
+ export type { Passport, PassportEvidence, PassportCheck, PassportInput } from './passport.mjs';
184
+ export { formatValue } from './plain-contract.mjs';
185
+ export type { PlainInput } from './plain-contract.mjs';
186
+ export type { RulePart, WriteChange, ChangedCase, ChangedCases } from './write.mjs';
187
+
188
+ // One rule change written into every service that implements it (src/write-across.mjs, docs/thunder-write.md).
189
+ export const WRITE_ACROSS_SCHEMA: 'thunder-write-across-v1';
190
+ export interface WriteAcrossFile { part?: string; path: string; source: string }
191
+ export interface WriteAcrossPlace { part?: string; file: string; language: string; decision: string; rule: number; line: number; why: string }
192
+ export interface WriteAcrossLookalike extends WriteAcrossPlace { when: string; result: string; decisionLine: number }
193
+ export function findSameRule(files: WriteAcrossFile[], options: { decision: string; rule: number | string }): { ok: boolean; anchor?: WriteAcrossLookalike; same?: WriteAcrossLookalike[]; notIncluded?: WriteAcrossLookalike[]; problems: string[] };
194
+ export interface WriteAcrossResult {
195
+ schema: 'thunder-write-across-v1'; ok: boolean; rule?: { before: string; after: string };
196
+ plan: Array<WriteAcrossPlace & { before: string; after: string; change: Array<{ line: number; column: number; before: string; after: string }> }>;
197
+ notIncluded: WriteAcrossLookalike[]; tests: Array<{ part?: string; file: string; line: number; text: string }>;
198
+ /** "part/path" -> the new contents of each changed file; empty unless ok. */
199
+ files: Record<string, string>; problems: string[];
200
+ }
201
+ export function writeRuleAcross(files: WriteAcrossFile[], options: { decision: string; rule: number | string; when: string }): WriteAcrossResult;
202
+ export function writeAcrossEvidence(result: WriteAcrossResult | { ok: false }): Array<{ kind: 'rule-write'; status: 'read'; claim: string; basis: unknown; scope: string; inputs: Array<{ part?: string; file: string }> }>;
203
+
204
+ // What a reading shows and in what order (src/reading-layout.mjs).
205
+ export { READING_LAYOUT_SCHEMA, READING_LABELS, readingLayout, thingCard, dataCard, ioBoxes, memberSymbolId } from './reading-layout.mjs';
206
+ export type { ReadingLayout, ThingCardLayout, DataCardLayout, IOBoxesLayout, KnowsLine, ThunderSymbolId } from './reading-layout.d.mts';
package/src/core.mjs CHANGED
@@ -11,11 +11,13 @@ export { ANCHOR_SCHEMA, spanRange, spanText, replaceSpan, editStep, anchorReport
11
11
  export { WRITE_SCHEMA, writeRule, changedCases, ruleParts, joinRuleParts, COMPARISON_CHOICES } from './write.mjs';
12
12
  export { STEPS_SCHEMA, classifyStatement } from './steps.mjs';
13
13
  export { WRITE_STEPS_SCHEMA, WRITE_STEPS_LANGUAGES, EDIT_OPS, thunderWrite, proveChange, describeEdit, unifiedDiff } from './write-steps.mjs';
14
+ export { WRITE_ACROSS_SCHEMA, findSameRule, writeRuleAcross, writeAcrossEvidence } from './write-across.mjs';
14
15
  // The meaning model under every step (thunder-expr-v1): parse, write back, and say every detail. Browser-safe.
15
16
  export { EXPR_SCHEMA, RENDER_LANGUAGES, parseExpr, parseStatement, renderExpr, renderStatement, sayFull, detailParts, detailOf, exprCounts, normalizeExpr, sameExpr, wordsAgree } from './meaning.mjs';
16
17
  export { VISUAL_SCHEMA, THUNDER_VISUAL, LEVELS, PLACES, visualFor, visualForStep, thunderText, thunderTokens } from './visual.mjs';
17
18
  export { MODEL_SCHEMA, THING_LANGUAGES, thunderModel, modelText, readLevel, flowOf, ruleFlow, askAsQuestion, stepDoes, pathsOf } from './model.mjs';
18
19
  export { readScreens, screenText } from './screens.mjs';
20
+ export { ACCESS_SCHEMA, accessFlow, accessText, ownershipWords } from './flow/access.mjs';
19
21
  // The running system (browser-safe): runs, stack traces, logs, and spans placed on Thunder's flows.
20
22
  export { RUNNING_SCHEMA, runtimeOverlay, runtimeText, explainError, parseStack, parseStacks, fromTrace, fromStack, fromLogs, fromOtlp, nodeNote } from './running.mjs';
21
23
  export { linkSystem, callsSummary, areaOf } from './system.mjs';
@@ -125,3 +127,16 @@ export { readCode, searchReading, detectLanguage, READ_SCHEMA, READ_LANGUAGES, I
125
127
  // Read a whole repository (pure: the caller passes file contents) and turn a recovered decision into a contract.
126
128
  export { readRepo, searchRepo, groupByFile, readableLanguage, readableFile, readFiles, readingOf, READ_REPO_SCHEMA, READ_SKIP_DIRS } from './read-repo.mjs';
127
129
  export { promoteDecision, PROMOTE_SCHEMA } from './promote.mjs';
130
+
131
+
132
+ // Everything OpenThunder's Read in Thunder and Thunder Live use, so no app needs paths into this package's files.
133
+ export { COLORS, SYMBOLS, DOES, FORMS, ZOOM, LINES, STEP_MARKS, ELEMENTS, LANGUAGES as VISUAL_LANGUAGES, BEGINNER } from './visual.mjs';
134
+ export { withArticle } from './model.mjs';
135
+ export { terminatorEffect, toThunderCondition, toThunderOutcome, sayCondition } from './read.mjs';
136
+ export { recoverModel } from './promote.mjs';
137
+ export { stepShape } from './write-steps.mjs';
138
+ // The Thunder Software Passport, pure half (assemble, check, render). buildPassport (folders, git, runs) is in the root entry.
139
+ export { PASSPORT_SCHEMA, ALWAYS_NOT_VERIFIED, assemblePassport, summarize, checkPassport, renderPassportSummary, renderPassportMarkdown } from './passport.mjs';
140
+ export { formatValue } from './plain-contract.mjs';
141
+ // What a reading shows and in what order (the drawing kit, @skillstech/thunderlang/react, draws from it).
142
+ export { READING_LAYOUT_SCHEMA, READING_LABELS, readingLayout, thingCard, dataCard, ioBoxes, memberSymbolId } from './reading-layout.mjs';
package/src/emit.mjs CHANGED
@@ -30,7 +30,7 @@ export function notesSummary(ast) {
30
30
  };
31
31
  }
32
32
 
33
- export const COMPILER_VERSION = '1.3.0';
33
+ export const COMPILER_VERSION = '1.4.1';
34
34
  export const PROOF_SCHEMA_VERSION = '0.1.0';
35
35
  // Identifies which ecosystem product emitted this proof. Consumed by SkillsTech
36
36
  // Certified to key cert proofs to the compiler. Stable slug per the coordination bus.
package/src/faithful.mjs CHANGED
@@ -128,7 +128,10 @@ export function accountsFor(code, said, tree = null) {
128
128
  const bare = stripQuoted(String(said).replace(/`[^`]*`/g, 'Q'));
129
129
  if (/&&|\|\||[!=]==?|<=|>=|\s[<>]\s|^\s*[<>]|\bis is\b/.test(bare)) return false;
130
130
  const c = tree && tree.kind !== 'code' ? exprCounts(tree) : codeCounts(code), w = wordCounts(said);
131
- return c.neg === w.neg && c.logic === w.logic && w.compare >= c.compare;
131
+ // C#'s String.IsNullOrEmpty / IsNullOrWhiteSpace asks two things in one call (null, or empty): its "or" is in the
132
+ // name, so "x is empty or missing" keeps the code's logic exactly.
133
+ const named = (String(code).match(/\bIsNullOr(?:Empty|WhiteSpace)\s*\(/g) || []).length;
134
+ return c.neg === w.neg && c.logic + named === w.logic && w.compare >= c.compare;
132
135
  }
133
136
 
134
137
  /** A piece of code shown as code: in backticks, shortened visibly when it is long. */