@skillstech/thunderlang 0.5.4 → 0.5.6

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": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "Deterministic ThunderLang compiler, CLI, and Language Server. No AI required. Turns .thunder files into the canonical Intent Graph, docs, and a proof, and EXECUTES the intent: 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",
@@ -16,6 +16,11 @@
16
16
  "import": "./src/core.mjs",
17
17
  "require": "./dist/core.cjs"
18
18
  },
19
+ "./learn": {
20
+ "types": "./src/learn.d.mts",
21
+ "import": "./src/learn.mjs",
22
+ "require": "./dist/learn.cjs"
23
+ },
19
24
  "./package.json": "./package.json"
20
25
  },
21
26
  "bin": {
@@ -47,6 +52,10 @@
47
52
  "esbuild": "^0.28.1"
48
53
  },
49
54
  "keywords": [
55
+ "thunder",
56
+ "thunder-programming-language",
57
+ "programming-language",
58
+ "human-native-programming",
50
59
  "intent",
51
60
  "thunderlang",
52
61
  "intent-oriented-programming",
package/src/cli.mjs CHANGED
@@ -13,11 +13,13 @@
13
13
  // --no-ai is the default and only mode today; the flag is accepted for forward-compatibility.
14
14
 
15
15
  import { readFileSync, writeFileSync, mkdirSync, readdirSync, statSync, existsSync } from 'node:fs';
16
- import { basename, join, relative, dirname } from 'node:path';
16
+ import { basename, join, relative, dirname, resolve } from 'node:path';
17
17
  import { parseIntent, slug, subjectName, KNOWN_LENSES } from './parse.mjs';
18
18
  import { previewHumanContract, renderHumanContract } from './human-contract.mjs';
19
19
  import { previewPlainContract } from './plain-contract.mjs';
20
- import { thunderRepo, renderThunderRepo } from './thunder-repo.mjs';
20
+ import { thunderRepo, renderThunderRepo, parseGitHub, cloneGitHub } from './thunder-repo.mjs';
21
+ import { thunderizeFiles, THUNDER_TEXT_EXT } from './thunderize.mjs';
22
+ import { sameMeaning, renderSame } from './same.mjs';
21
23
  import { anchorReport } from './anchor.mjs';
22
24
  import { writeRule } from './write.mjs';
23
25
  import { readCode, searchReading } from './read.mjs';
@@ -441,6 +443,8 @@ Graph & IR
441
443
  Thunder write: change a number, comparison, text value, or answer in a recovered rule;
442
444
  previews the exact code change and the cases whose answer changes; --write saves it
443
445
  repo <owner/repo | github url | folder> [--json] [--max-files n] Thunder a whole repository (read-only; nothing is executed)
446
+ thunderize <folder | owner/repo> [--out <dir>] [--json] the whole app in Thunder Text: one .thunder-text per file + APP.thunder-text
447
+ same <old> <new> [--json] does the new code mean the same as the old? (files or folders, any languages; rules are run on every edge case)
444
448
  text <file> [--json | --format source] experimental Thunder Text rule (.thunder-plain): run its examples [alias: plain]
445
449
  read <file|dir> [--search q] [--kind decision,function,error,test] [--in <lang>] [--from <lang>] [--json]
446
450
  for a folder also: [--answer <Outcome>] [--input <name>] [--lang go,rust] [--path <prefix>] [--limit n]
@@ -508,6 +512,7 @@ function main() {
508
512
  if (!items.length) console.log('\nNothing matches. Try fewer words or remove --kind.');
509
513
  for (const it of items) {
510
514
  console.log(`\n[${it.kind}${it.status === 'partial' ? ', partly read' : ''}] ${it.name} (line ${it.line})`);
515
+ if (it.doc) console.log(` Author's note: "${it.doc}"`);
511
516
  console.log(` ${it.says}`);
512
517
  if (it.thunder) {
513
518
  console.log('');
@@ -572,6 +577,44 @@ function main() {
572
577
  } catch (e) { console.error(`thunder repo: ${e.message}`); process.exitCode = 2; }
573
578
  return;
574
579
  }
580
+ if (cmd === 'thunderize') {
581
+ let cleanup = () => {};
582
+ try {
583
+ if (!file) throw new Error('Use thunder thunderize <folder | owner/repo> [--out <dir>] [--json].');
584
+ let root = file, name = basename(resolve(file));
585
+ const gh = !existsSync(file) && parseGitHub(file);
586
+ if (gh) { const c = cloneGitHub(gh); root = c.root; cleanup = c.cleanup; name = `${gh.owner}/${gh.repo}`; }
587
+ else if (!existsSync(file) || !statSync(file).isDirectory()) throw new Error(`${file} is not a folder or a GitHub repository.`);
588
+ const app = thunderizeFiles(collectReadableFiles(root), { name });
589
+ if (args.out) {
590
+ for (const f of app.files) { const dest = join(args.out, f.out); mkdirSync(dirname(dest), { recursive: true }); writeFileSync(dest, f.text); }
591
+ mkdirSync(args.out, { recursive: true });
592
+ writeFileSync(join(args.out, `APP${THUNDER_TEXT_EXT}`), app.index);
593
+ }
594
+ if (args.json) console.log(JSON.stringify(app, null, 2));
595
+ else {
596
+ process.stdout.write(app.index);
597
+ if (args.out) console.log(`\nWrote ${app.files.length + 1} Thunder Text files to ${args.out} (start with APP${THUNDER_TEXT_EXT}).`);
598
+ else console.log(`\nAdd --out <dir> to write every file's Thunder Text.`);
599
+ }
600
+ } catch (e) { console.error(`thunder thunderize: ${e.message}`); process.exitCode = 2; }
601
+ finally { cleanup(); }
602
+ return;
603
+ }
604
+ if (cmd === 'same') {
605
+ try {
606
+ const [a, b] = args._;
607
+ if (!a || !b) throw new Error('Use thunder same <old> <new> [--json]. Each can be a file or a folder, in any language Thunder reads.');
608
+ const load = (p) => {
609
+ if (!existsSync(p)) throw new Error(`${p} does not exist.`);
610
+ return statSync(p).isDirectory() ? collectReadableFiles(p) : [{ path: basename(p), source: readFileSync(p, 'utf8') }];
611
+ };
612
+ const r = sameMeaning(load(a), load(b));
613
+ console.log(args.json ? JSON.stringify(r, null, 2) : renderSame(r).trimEnd());
614
+ process.exitCode = r.verdict === 'same' ? 0 : 1;
615
+ } catch (e) { console.error(`thunder same: ${e.message}`); process.exitCode = 2; }
616
+ return;
617
+ }
575
618
  if (cmd === 'plain' || cmd === 'text') {
576
619
  try {
577
620
  if (!file) throw new Error('Use thunder plain <file> [--json | --format source].');
package/src/core.d.ts CHANGED
@@ -11,6 +11,18 @@ export { HumanContractPreview, compileHumanContract, previewHumanContract, rende
11
11
  export { ANCHOR_SCHEMA, spanRange, spanText, replaceSpan, editStep, anchorReport } from './anchor.mjs';
12
12
  export { WRITE_SCHEMA, writeRule, changedCases, ruleParts, joinRuleParts, COMPARISON_CHOICES } from './write.mjs';
13
13
  export { STEPS_SCHEMA, classifyStatement } from './steps.mjs';
14
+ export { VISUAL_SCHEMA, THUNDER_VISUAL, visualFor, visualForStep, thunderText, thunderTokens } from './visual.mjs';
15
+ export { MODEL_SCHEMA, THING_LANGUAGES, thunderModel, modelText, flowOf, ruleFlow, askAsQuestion, stepDoes } from './model.mjs';
16
+ export { THUNDERIZE_SCHEMA, THUNDER_TEXT_EXT, thunderizeFile, thunderizeFiles } from './thunderize.mjs';
17
+ export { SAME_SCHEMA, sameMeaning, compareRules, renderSame } from './same.mjs';
18
+ export type { ColorRole, ElementKind, Provenance as VisualProvenance, Visual } from './visual.mjs';
19
+ export { plainFromReading } from './plain-contract.mjs';
20
+ export function conditionText(model: unknown, condition: unknown): string;
21
+ export function getCompletions(source: string, position: { line: number; column: number }): unknown;
22
+ export function getHover(source: string, position: { line: number; column: number }): unknown;
23
+ export function autocorrectSource(source: string): { source: string; changes: unknown[] };
24
+ export function getCodeActions(source: string, diagnostics?: unknown[]): unknown[];
25
+ export const SEMANTIC_TYPES: string[];
14
26
  export { PLAIN_SCHEMA, PlainModel, PlainPreview, PlainExplanation, parsePlainContract, renderPlainContract, plainToThunder, compilePlainContract, previewPlainContract, explainPlain } from './plain-contract.mjs';
15
27
 
16
28
  // Parser + graph + in-memory compile.
@@ -112,6 +124,8 @@ export type { TranslateLanguage } from './translate.mjs';
112
124
  // Read code you don't know.
113
125
  export { readCode, searchReading, detectLanguage, READ_SCHEMA, READ_LANGUAGES } from './read.mjs';
114
126
  export type { Reading, ReadItem, ReadKind } from './read.mjs';
127
+ export function completenessOf(item: unknown): { level: 'explained' | 'partly explained' | 'found' | 'executed'; reasons: string[] };
128
+ export function displayLabel(name: string): string;
115
129
  export { readRepo, searchRepo, groupByFile, readableLanguage, READ_REPO_SCHEMA, READ_SKIP_DIRS } from './read-repo.mjs';
116
130
  export type { RepoItem, RepoFacet, RepoReading, RepoFilter } from './read-repo.mjs';
117
131
  export { promoteDecision, PROMOTE_SCHEMA } from './promote.mjs';
package/src/core.mjs CHANGED
@@ -10,6 +10,13 @@ export { compileHumanContract, previewHumanContract, renderHumanContract, render
10
10
  export { ANCHOR_SCHEMA, spanRange, spanText, replaceSpan, editStep, anchorReport } from './anchor.mjs';
11
11
  export { WRITE_SCHEMA, writeRule, changedCases, ruleParts, joinRuleParts, COMPARISON_CHOICES } from './write.mjs';
12
12
  export { STEPS_SCHEMA, classifyStatement } from './steps.mjs';
13
+ export { VISUAL_SCHEMA, THUNDER_VISUAL, visualFor, visualForStep, thunderText, thunderTokens } from './visual.mjs';
14
+ export { MODEL_SCHEMA, THING_LANGUAGES, thunderModel, modelText, flowOf, ruleFlow, askAsQuestion, stepDoes } from './model.mjs';
15
+ export { THUNDERIZE_SCHEMA, THUNDER_TEXT_EXT, thunderizeFile, thunderizeFiles } from './thunderize.mjs';
16
+ export { SAME_SCHEMA, sameMeaning, compareRules, renderSame } from './same.mjs';
17
+ export { plainFromReading, conditionText } from './plain-contract.mjs';
18
+ // Editor help (browser-safe): completions, hover, autocorrect, quick fixes, and the semantic type vocabulary.
19
+ export { getCompletions, getHover, autocorrectSource, getCodeActions, SEMANTIC_TYPES } from './intellisense.mjs';
13
20
  export { PLAIN_SCHEMA, parsePlainContract, renderPlainContract, plainToThunder, compilePlainContract, previewPlainContract, explainPlain } from './plain-contract.mjs';
14
21
 
15
22
  // Classification model (observed/inferred/proposed/... + isFactual). Node-free.
@@ -102,7 +109,7 @@ export { runTests, TEST_SCHEMA } from './testing.mjs';
102
109
  // Decisions -> readable typed source in six languages (browser-safe; same translators as the targets).
103
110
  export { translateDecisions, TRANSLATE_LANGUAGES } from './translate.mjs';
104
111
  // Read code you don't know: decisions recovered from six languages as ThunderLang + plain English.
105
- export { readCode, searchReading, detectLanguage, READ_SCHEMA, READ_LANGUAGES } from './read.mjs';
112
+ export { readCode, searchReading, detectLanguage, READ_SCHEMA, READ_LANGUAGES, completenessOf, displayLabel } from './read.mjs';
106
113
  // Read a whole repository (pure: the caller passes file contents) and turn a recovered decision into a contract.
107
114
  export { readRepo, searchRepo, groupByFile, readableLanguage, READ_REPO_SCHEMA, READ_SKIP_DIRS } from './read-repo.mjs';
108
115
  export { promoteDecision, PROMOTE_SCHEMA } from './promote.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 = '0.5.4';
33
+ export const COMPILER_VERSION = '0.5.6';
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/index.d.ts CHANGED
@@ -739,6 +739,9 @@ export function changeReport(pairs: Array<{ path: string; before: IntentGraph |
739
739
 
740
740
  // Read code you don't know.
741
741
  export { readCode, searchReading, detectLanguage, READ_SCHEMA, READ_LANGUAGES } from './read.mjs';
742
+ export { VISUAL_SCHEMA, THUNDER_VISUAL, visualFor, visualForStep, thunderText } from './visual.mjs';
743
+ export { thunderizeFiles, THUNDER_TEXT_EXT } from './thunderize.mjs';
744
+ export { sameMeaning, renderSame } from './same.mjs';
742
745
  export type { Reading, ReadItem, ReadKind } from './read.mjs';
743
746
  export { readRepo, searchRepo, groupByFile, readableLanguage, READ_REPO_SCHEMA, READ_SKIP_DIRS } from './read-repo.mjs';
744
747
  export type { RepoItem, RepoFacet, RepoReading, RepoFilter } from './read-repo.mjs';
package/src/index.mjs CHANGED
@@ -190,6 +190,9 @@ export { resolveObligations } from './obligations.mjs';
190
190
  // Read code you don't know: one file, a whole repository, files from disk, and promotion of a recovered decision
191
191
  // into a contract with edge-case examples.
192
192
  export { readCode, searchReading, detectLanguage, READ_SCHEMA, READ_LANGUAGES } from "./read.mjs";
193
+ export { VISUAL_SCHEMA, THUNDER_VISUAL, visualFor, visualForStep, thunderText } from "./visual.mjs";
194
+ export { thunderizeFiles, THUNDER_TEXT_EXT } from "./thunderize.mjs";
195
+ export { sameMeaning, renderSame } from "./same.mjs";
193
196
  export { readRepo, searchRepo, groupByFile, readableLanguage, READ_REPO_SCHEMA, READ_SKIP_DIRS } from "./read-repo.mjs";
194
197
  export { collectReadableFiles } from "./read-repo-fs.mjs";
195
198
  export { promoteDecision, PROMOTE_SCHEMA } from "./promote.mjs";