@skillstech/thunderlang 0.5.2 → 0.5.5
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 +132 -0
- package/dist/core.cjs +10204 -6621
- package/dist/index.cjs +3867 -1771
- package/package.json +1 -1
- package/src/anchor.d.mts +12 -0
- package/src/anchor.mjs +127 -0
- package/src/cli.mjs +148 -39
- package/src/codegen.mjs +27 -9
- package/src/core.d.ts +24 -0
- package/src/core.mjs +19 -1
- package/src/emit.mjs +1 -1
- package/src/index.d.ts +26 -0
- package/src/index.mjs +14 -0
- package/src/mcp.mjs +19 -32
- package/src/model.d.mts +18 -0
- package/src/model.mjs +456 -0
- package/src/obligations.d.mts +9 -0
- package/src/obligations.mjs +35 -0
- package/src/plain-contract.d.mts +30 -0
- package/src/plain-contract.mjs +339 -0
- package/src/promote.mjs +19 -5
- package/src/read.d.mts +25 -1
- package/src/read.mjs +415 -23
- package/src/review-atlas.d.mts +19 -0
- package/src/review-atlas.mjs +136 -0
- package/src/same.d.mts +10 -0
- package/src/same.mjs +160 -0
- package/src/steps.d.mts +2 -0
- package/src/steps.mjs +599 -0
- package/src/target-types.mjs +39 -4
- package/src/testing.mjs +12 -9
- package/src/thunder-repo.mjs +96 -0
- package/src/thunderize.d.mts +14 -0
- package/src/thunderize.mjs +82 -0
- package/src/visual.d.mts +40 -0
- package/src/visual.mjs +304 -0
- package/src/write.d.mts +24 -0
- package/src/write.mjs +263 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skillstech/thunderlang",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
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",
|
package/src/anchor.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const ANCHOR_SCHEMA: 'thunder-anchor-v1';
|
|
2
|
+
export interface Span { startLine: number; endLine: number; start?: number; end?: number; exact: 'offset' | 'lines' }
|
|
3
|
+
export function spanRange(source: string, span: Span): [number, number];
|
|
4
|
+
export function spanText(source: string, span: Span): string;
|
|
5
|
+
export function replaceSpan(source: string, span: Span, replacement: string): string;
|
|
6
|
+
export function editStep(args: { source: string; language?: string; file?: string; functionName: string; line?: number | null; path: number[]; replacement: string }):
|
|
7
|
+
| { ok: true; source: string; problems: []; change: { startLine: number; endLine: number; before: string; after: string; startOffset: number; linesBefore: number }; reread: { kind: string; says: string } }
|
|
8
|
+
| { ok: false; source: string; problems: string[] };
|
|
9
|
+
export function anchorReport(source: string, opts?: { language?: string; file?: string }): {
|
|
10
|
+
schema: 'thunder-anchor-v1'; language: string; coverage: number;
|
|
11
|
+
functions: Array<{ name: string; line: number; coverage: number; codeLines: number; missing: number[]; steps: Array<{ path: string; kind: string; says: string; span: Span }> }>;
|
|
12
|
+
};
|
package/src/anchor.mjs
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Lossless anchoring: every Thunder step points at its exact place in the original file, so a change made
|
|
2
|
+
// in Thunder can be written back to exactly that place and nowhere else. This is the foundation for
|
|
3
|
+
// Thunder write. Deterministic and browser-safe; it edits text only and never runs code.
|
|
4
|
+
import { readCode, pyNoComment, rbNoComment } from './read.mjs';
|
|
5
|
+
|
|
6
|
+
export const ANCHOR_SCHEMA = 'thunder-anchor-v1';
|
|
7
|
+
|
|
8
|
+
const lineStarts = (source) => { const out = [0]; for (let i = 0; i < source.length; i++) if (source[i] === '\n') out.push(i + 1); return out; };
|
|
9
|
+
|
|
10
|
+
/** [start, end) character range of a span. Offsets when exact; whole lines otherwise. */
|
|
11
|
+
export function spanRange(source, span) {
|
|
12
|
+
if (span.exact === 'offset' && span.start != null && span.end != null) return [span.start, span.end];
|
|
13
|
+
const starts = lineStarts(source);
|
|
14
|
+
const a = starts[span.startLine - 1] ?? source.length;
|
|
15
|
+
const nextLine = starts[span.endLine];
|
|
16
|
+
const b = nextLine != null ? nextLine - 1 : source.length;
|
|
17
|
+
return [a, b];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The exact original text a span covers. */
|
|
21
|
+
export function spanText(source, span) {
|
|
22
|
+
const [a, b] = spanRange(source, span);
|
|
23
|
+
return source.slice(a, b);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Replace exactly the text a span covers. Everything else is untouched, byte for byte. */
|
|
27
|
+
export function replaceSpan(source, span, replacement) {
|
|
28
|
+
const [a, b] = spanRange(source, span);
|
|
29
|
+
// Whole-line spans keep the original indentation (it carries meaning in Python and Ruby).
|
|
30
|
+
if (span.exact !== 'offset') {
|
|
31
|
+
const indent = (source.slice(a, b).match(/^[ \t]*/) || [''])[0];
|
|
32
|
+
const lines = String(replacement).replace(/\s+$/, '').split('\n');
|
|
33
|
+
const base = (lines[0].match(/^[ \t]*/) || [''])[0].length;
|
|
34
|
+
replacement = lines.map((l) => (l.trim() ? indent + l.slice(Math.min(base, (l.match(/^[ \t]*/) || [''])[0].length)) : l)).join('\n');
|
|
35
|
+
}
|
|
36
|
+
// The span ends before a statement's own ";"; don't double it.
|
|
37
|
+
if (source[b] === ';') replacement = String(replacement).replace(/;\s*$/, '');
|
|
38
|
+
return source.slice(0, a) + replacement + source.slice(b);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The trailing # comment on a Python or Ruby line, with the spaces before it; '' when there is none. */
|
|
42
|
+
function trailingComment(text, language) {
|
|
43
|
+
const strip = language === 'python' ? pyNoComment : language === 'ruby' ? rbNoComment : null;
|
|
44
|
+
if (!strip) return '';
|
|
45
|
+
const last = String(text).split('\n').pop();
|
|
46
|
+
const rest = last.slice(strip(last).replace(/\s+$/, '').length);
|
|
47
|
+
return /^\s*#/.test(rest) ? rest : '';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Find a step by path: [3] is the 4th top-level step, [1, 0] the first step inside the 2nd. */
|
|
51
|
+
function stepAt(steps, path) {
|
|
52
|
+
let list = steps, step = null;
|
|
53
|
+
for (const i of path) { step = list?.[i]; if (!step) return null; list = step.children; }
|
|
54
|
+
return step;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function flatten(steps, path = [], out = []) {
|
|
58
|
+
steps.forEach((s, i) => { out.push({ path: [...path, i], step: s }); if (s.children) flatten(s.children, [...path, i], out); });
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Compare code ignoring indentation and a trailing ";".
|
|
63
|
+
const norm = (t) => String(t).split('\n').map((l) => l.trim()).join('\n').replace(/;\s*$/, '').trim();
|
|
64
|
+
|
|
65
|
+
function findFunction(reading, name, line) {
|
|
66
|
+
const fns = reading.items.filter((i) => i.name === name && i.steps);
|
|
67
|
+
if (!fns.length) return null;
|
|
68
|
+
if (line == null) return fns[0];
|
|
69
|
+
return fns.reduce((best, f) => (Math.abs(f.line - line) < Math.abs(best.line - line) ? f : best));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Write one step back to the original code and verify the result.
|
|
74
|
+
* Returns { ok, source, change, reread, problems }. On any problem, ok is false and `source` is the original.
|
|
75
|
+
*/
|
|
76
|
+
export function editStep({ source, language, file = '', functionName, line = null, path, replacement }) {
|
|
77
|
+
const problems = [];
|
|
78
|
+
const before = readCode(source, { language, file });
|
|
79
|
+
const fn = findFunction(before, functionName, line);
|
|
80
|
+
if (!fn) return { ok: false, source, problems: [`No function named ${functionName} with steps was found.`] };
|
|
81
|
+
const step = stepAt(fn.steps, path);
|
|
82
|
+
if (!step?.span) return { ok: false, source, problems: [`Step ${path.join('.')} does not exist in ${functionName}.`] };
|
|
83
|
+
const original = spanText(source, step.span);
|
|
84
|
+
// Whole-line spans include a trailing # comment; keep it unless the replacement brings its own.
|
|
85
|
+
const comment = step.span.exact !== 'offset' ? trailingComment(original, before.language) : '';
|
|
86
|
+
if (comment && !String(replacement).includes('#')) replacement = String(replacement).replace(/\s+$/, '') + comment;
|
|
87
|
+
const next = replaceSpan(source, step.span, replacement);
|
|
88
|
+
|
|
89
|
+
// Verify: re-read, the function is still there, the edited step reads as the new code, others unchanged.
|
|
90
|
+
let after;
|
|
91
|
+
try { after = readCode(next, { language, file }); } catch (e) { return { ok: false, source, problems: [`The changed file could not be read: ${e.message}`] }; }
|
|
92
|
+
const fn2 = findFunction(after, functionName, fn.line);
|
|
93
|
+
if (!fn2) return { ok: false, source, problems: [`${functionName} is no longer found after the change.`] };
|
|
94
|
+
const key = path.join('.');
|
|
95
|
+
// Ancestors contain the edited step and its descendants are replaced with it; every other step must be unchanged.
|
|
96
|
+
const isAncestor = (p) => key.startsWith(`${p}.`);
|
|
97
|
+
const others = flatten(fn.steps).filter((x) => { const k = x.path.join('.'); return k !== key && !k.startsWith(`${key}.`) && !isAncestor(k); });
|
|
98
|
+
const others2 = new Map(flatten(fn2.steps).map((x) => [x.path.join('.'), x.step]));
|
|
99
|
+
for (const o of others) {
|
|
100
|
+
const twin = others2.get(o.path.join('.'));
|
|
101
|
+
if (!twin) { problems.push(`Step ${o.path.join('.')} disappeared.`); continue; }
|
|
102
|
+
// Steps after the edit may have moved; compare their text, not their position.
|
|
103
|
+
if (norm(spanText(source, o.step.span)) !== norm(spanText(next, twin.span))) problems.push(`Step ${o.path.join('.')} changed unexpectedly.`);
|
|
104
|
+
}
|
|
105
|
+
const edited = stepAt(fn2.steps, path);
|
|
106
|
+
if (!edited) problems.push('The edited step is no longer read as a step.');
|
|
107
|
+
else if (norm(spanText(next, edited.span)) !== norm(replacement)) problems.push('The edited step does not match the new code exactly.');
|
|
108
|
+
if (problems.length) return { ok: false, source, problems };
|
|
109
|
+
const starts = lineStarts(source);
|
|
110
|
+
return {
|
|
111
|
+
ok: true, source: next, problems: [],
|
|
112
|
+
change: { startLine: step.span.startLine, endLine: step.span.endLine, before: original, after: replacement, startOffset: spanRange(source, step.span)[0], linesBefore: starts.length },
|
|
113
|
+
reread: { kind: edited.kind, says: edited.says },
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Anchoring report for every function: coverage and whether each step's span matches its statement. */
|
|
118
|
+
export function anchorReport(source, { language, file = '' } = {}) {
|
|
119
|
+
const reading = readCode(source, { language, file });
|
|
120
|
+
const functions = reading.items.filter((i) => i.anchor).map((f) => ({
|
|
121
|
+
name: f.name, line: f.line, coverage: f.anchor.coverage, codeLines: f.anchor.codeLines, missing: f.anchor.missing,
|
|
122
|
+
steps: flatten(f.steps).map(({ path, step }) => ({ path: path.join('.'), kind: step.kind, says: step.says, span: step.span })),
|
|
123
|
+
}));
|
|
124
|
+
const total = functions.reduce((n, f) => n + f.codeLines, 0);
|
|
125
|
+
const covered = functions.reduce((n, f) => n + Math.round(f.coverage * f.codeLines), 0);
|
|
126
|
+
return { schema: ANCHOR_SCHEMA, language: reading.language, functions, coverage: total ? Math.round((covered / total) * 1000) / 1000 : 1 };
|
|
127
|
+
}
|
package/src/cli.mjs
CHANGED
|
@@ -13,9 +13,15 @@
|
|
|
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
|
+
import { previewPlainContract } from './plain-contract.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';
|
|
23
|
+
import { anchorReport } from './anchor.mjs';
|
|
24
|
+
import { writeRule } from './write.mjs';
|
|
19
25
|
import { readCode, searchReading } from './read.mjs';
|
|
20
26
|
import { readRepo, searchRepo, groupByFile } from './read-repo.mjs';
|
|
21
27
|
import { promoteDecision } from './promote.mjs';
|
|
@@ -47,6 +53,7 @@ import { buildMissionIndex } from './atlas.mjs';
|
|
|
47
53
|
import { parseSelection, regionMetrics, selectCandidate } from './select.mjs';
|
|
48
54
|
import { buildIntentGraph, safeGraph } from './intent-graph.mjs';
|
|
49
55
|
import { buildAtlas, searchAtlas, expandNode } from './intent-atlas.mjs';
|
|
56
|
+
import { buildReviewAtlas, renderReviewBrief, reviewAtlasExitCode } from './review-atlas.mjs';
|
|
50
57
|
import { buildFocusGraph, intentBrief, makeScope } from './focus.mjs';
|
|
51
58
|
import { comprehensionLevel, comprehensionReport, LEVELS as COMPREHENSION_LEVELS } from './comprehension.mjs';
|
|
52
59
|
import { twelveFactorReport } from './twelve-factor.mjs';
|
|
@@ -106,6 +113,7 @@ function runLiveTarget(ast, target) {
|
|
|
106
113
|
}
|
|
107
114
|
import { importIntent, importReport, detectFormat, IMPORT_FORMATS } from './importers.mjs';
|
|
108
115
|
import { runTests } from './testing.mjs';
|
|
116
|
+
import { resolveObligations } from './obligations.mjs';
|
|
109
117
|
import { toEvidenceEvents, verifyDiffToEvidence, conformToEvidence, driftToEvidence } from './evidence.mjs';
|
|
110
118
|
import { evaluateOutcomes } from './outcome.mjs';
|
|
111
119
|
import { analyzeStyle } from './style.mjs';
|
|
@@ -192,43 +200,6 @@ function collectIntents(root, acc = []) {
|
|
|
192
200
|
return acc;
|
|
193
201
|
}
|
|
194
202
|
|
|
195
|
-
// Resolve every guarantee/never obligation against the SPECIFIC test that verifies it.
|
|
196
|
-
// Shared by `thunder test --contracts` and `thunder prove` so both agree per-claim.
|
|
197
|
-
// States: verified (proven by a passing named test), failed (its test fails), declared
|
|
198
|
-
// (a verification is named/classified but not runnable in-file), unverified (nothing).
|
|
199
|
-
function resolveObligations(ast) {
|
|
200
|
-
const t = runTests(ast);
|
|
201
|
-
const testPass = new Map();
|
|
202
|
-
for (const res of (t.results || [])) {
|
|
203
|
-
const cur = testPass.get(res.target);
|
|
204
|
-
testPass.set(res.target, cur === undefined ? !!res.pass : cur && !!res.pass);
|
|
205
|
-
}
|
|
206
|
-
const norm = (s) => String(s).toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
207
|
-
const matchTest = (verifyText) => {
|
|
208
|
-
const v = norm(verifyText); if (!v) return null;
|
|
209
|
-
for (const [name, pass] of testPass) { const n = norm(name); if (n && (n === v || n.includes(v) || v.includes(n))) return { name, pass }; }
|
|
210
|
-
return null;
|
|
211
|
-
};
|
|
212
|
-
const build = (kind, o) => {
|
|
213
|
-
const verify = o.verify || [];
|
|
214
|
-
const kinds = [...new Set((o.verifications || []).map((v) => v.kind).filter((k) => k && k !== 'unclassified'))];
|
|
215
|
-
let status, provenBy = null;
|
|
216
|
-
if (!verify.length) status = 'unverified';
|
|
217
|
-
else {
|
|
218
|
-
let m = null;
|
|
219
|
-
for (const vt of verify) { const x = matchTest(vt); if (x) { m = x; if (!x.pass) break; } }
|
|
220
|
-
if (m) { status = m.pass ? 'verified' : 'failed'; provenBy = m.name; } else status = 'declared';
|
|
221
|
-
}
|
|
222
|
-
return { kind, id: o.id, text: o.statement, status, verify, kinds, provenBy };
|
|
223
|
-
};
|
|
224
|
-
const obligations = [
|
|
225
|
-
...ast.guarantees.map((g) => build('guarantee', g)),
|
|
226
|
-
...ast.neverRules.map((n) => build('prohibition', n)),
|
|
227
|
-
];
|
|
228
|
-
const count = (s) => obligations.filter((o) => o.status === s).length;
|
|
229
|
-
return { obligations, tests: t, verified: count('verified'), declared: count('declared'), unverified: count('unverified'), failed: count('failed') };
|
|
230
|
-
}
|
|
231
|
-
|
|
232
203
|
// Proof freshness: a proof is valid only for a specific (intent, implementation, dependencies,
|
|
233
204
|
// compiler, environment) tuple. These helpers capture that tuple so `verify` can mark a proof STALE.
|
|
234
205
|
const gitCmd = (c) => { try { return execSync(`git ${c}`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] }).trim() || null; } catch { return null; } };
|
|
@@ -275,6 +246,12 @@ function parseArgs(argv) {
|
|
|
275
246
|
else if (a === '--by') args.by = argv[++i];
|
|
276
247
|
else if (a === '--at') args.at = argv[++i];
|
|
277
248
|
else if (a === '--json') args.json = true;
|
|
249
|
+
else if (a === '--review') args.review = true;
|
|
250
|
+
else if (a === '--agent-brief') args.agentBrief = true;
|
|
251
|
+
else if (a === '--openthunder') {
|
|
252
|
+
if (!argv[i + 1] || argv[i + 1].startsWith('--')) throw new Error('--openthunder requires a JSON report path');
|
|
253
|
+
args.openthunder = argv[++i];
|
|
254
|
+
}
|
|
278
255
|
else if (a === '--targets') args.targets = (argv[++i] || '').split(',').filter(Boolean);
|
|
279
256
|
else if (a === '--product') args.product = argv[++i];
|
|
280
257
|
else if (a === '--allow-pending') args.allowPending = true;
|
|
@@ -296,6 +273,8 @@ function parseArgs(argv) {
|
|
|
296
273
|
else if (a === '--inputs') args.inputs = argv[++i];
|
|
297
274
|
else if (a === '--events') args.events = (argv[++i] || '').split(',').map((s) => s.trim()).filter(Boolean);
|
|
298
275
|
else if (a === '--decision') args.decision = argv[++i];
|
|
276
|
+
else if (a === '--rule') args.rule = argv[++i];
|
|
277
|
+
else if (a === '--when') args.when = argv[++i];
|
|
299
278
|
else if (a === '--to') args.to = argv[++i];
|
|
300
279
|
else if (a === '--force') args.force = true;
|
|
301
280
|
else if (a === '--write' || a === '-w') args.write = true;
|
|
@@ -419,6 +398,8 @@ Inspect
|
|
|
419
398
|
docs <file> [--lens <lens>] [--out <dir>] render a mission as Markdown docs (per-audience with --lens)
|
|
420
399
|
index <dir> the Mission Atlas inventory
|
|
421
400
|
atlas <dir> [--search q | --expand id] the whole-system Atlas
|
|
401
|
+
atlas <dir> --review [--json | --agent-brief] [--openthunder report.json] [--strict]
|
|
402
|
+
execute contract cases, rank review gaps, compare OpenThunder snapshots
|
|
422
403
|
|
|
423
404
|
Run & test
|
|
424
405
|
run <file> --inputs '<json>' execute the decision(s) deterministically
|
|
@@ -456,6 +437,15 @@ Real code vs intent (drift)
|
|
|
456
437
|
|
|
457
438
|
Graph & IR
|
|
458
439
|
human <file> [--json | --format source] experimental compact authoring and a decision reading view
|
|
440
|
+
--version print the Thunder compiler version
|
|
441
|
+
anchor <file> [--json] show every Thunder step with its exact place in the file, and line coverage
|
|
442
|
+
write <file> --decision <name> --rule <n|otherwise> [--when "<condition>"] [--answer <Outcome>] [--write] [--json]
|
|
443
|
+
Thunder write: change a number, comparison, text value, or answer in a recovered rule;
|
|
444
|
+
previews the exact code change and the cases whose answer changes; --write saves it
|
|
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)
|
|
448
|
+
text <file> [--json | --format source] experimental Thunder Text rule (.thunder-plain): run its examples [alias: plain]
|
|
459
449
|
read <file|dir> [--search q] [--kind decision,function,error,test] [--in <lang>] [--from <lang>] [--json]
|
|
460
450
|
for a folder also: [--answer <Outcome>] [--input <name>] [--lang go,rust] [--path <prefix>] [--limit n]
|
|
461
451
|
--promote <decision> [--out <file>] turn a recovered decision into a contract with starter examples
|
|
@@ -485,6 +475,10 @@ function main() {
|
|
|
485
475
|
const [cmd, ...restArgv] = process.argv.slice(2);
|
|
486
476
|
const args = parseArgs(restArgv);
|
|
487
477
|
const file = args._[0];
|
|
478
|
+
if (cmd === '--version' || cmd === '-v' || cmd === 'version') {
|
|
479
|
+
console.log(`thunder ${COMPILER_VERSION} (the Thunder compiler, also called ThunderLang)`);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
488
482
|
if (!cmd || cmd === 'help' || cmd === '--help' || cmd === '-h') {
|
|
489
483
|
console.log(HELP);
|
|
490
484
|
process.exit(cmd ? 0 : 2);
|
|
@@ -518,6 +512,7 @@ function main() {
|
|
|
518
512
|
if (!items.length) console.log('\nNothing matches. Try fewer words or remove --kind.');
|
|
519
513
|
for (const it of items) {
|
|
520
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}"`);
|
|
521
516
|
console.log(` ${it.says}`);
|
|
522
517
|
if (it.thunder) {
|
|
523
518
|
console.log('');
|
|
@@ -533,6 +528,108 @@ function main() {
|
|
|
533
528
|
} catch (e) { console.error(`thunder read: ${e.message}`); process.exitCode = 2; }
|
|
534
529
|
return;
|
|
535
530
|
}
|
|
531
|
+
if (cmd === 'write') {
|
|
532
|
+
try {
|
|
533
|
+
if (!file || !args.decision || !args.rule || (args.when == null && args.answer == null)) throw new Error('Use thunder write <file> --decision <name> --rule <n|otherwise> --when "<condition>" | --answer <Outcome> [--write].');
|
|
534
|
+
const source = readFileSync(file, 'utf8');
|
|
535
|
+
const r = writeRule({ source, language: args.from, file: basename(file), decision: args.decision, rule: args.rule === 'otherwise' ? 'otherwise' : Number(args.rule), when: args.when ?? null, answer: args.answer ?? null });
|
|
536
|
+
if (r.ok && args.write) writeFileSync(file, r.source);
|
|
537
|
+
if (args.json) { const { source: _s, ...rest } = r; console.log(JSON.stringify({ ...rest, written: !!(r.ok && args.write) }, null, 2)); if (!r.ok) process.exitCode = 1; return; }
|
|
538
|
+
if (!r.ok) {
|
|
539
|
+
console.error(`Not changed. ${file} is untouched.`);
|
|
540
|
+
for (const p of r.problems) console.error(` ${p}`);
|
|
541
|
+
process.exitCode = 1;
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
console.log(`${r.decision}, rule ${r.rule}`);
|
|
545
|
+
console.log(` was: ${r.before}`);
|
|
546
|
+
console.log(` now: ${r.after}`);
|
|
547
|
+
console.log('\nCode change (only these characters):');
|
|
548
|
+
for (const c of r.change) console.log(` line ${c.line}, column ${c.column}: ${c.before} -> ${c.after}`);
|
|
549
|
+
console.log('\nChecked by reading the file again: this rule reads as intended; every other rule and function reads exactly as before.');
|
|
550
|
+
console.log(`\n${r.cases.note}`);
|
|
551
|
+
const names = r.cases.changed[0] ? Object.keys(r.cases.changed[0].inputs) : [];
|
|
552
|
+
for (const c of r.cases.changed.slice(0, 8)) console.log(` ${names.map((n) => `${n} ${JSON.stringify(c.inputs[n])}`).join(', ')}: ${c.before} -> ${c.after}`);
|
|
553
|
+
if (r.cases.changed.length > 8) console.log(` ...and ${r.cases.changed.length - 8} more (use --json for all).`);
|
|
554
|
+
console.log(args.write ? `\nSaved ${file}. Run your tests before you commit.` : '\nPreview only; nothing was saved. Add --write to save the change.');
|
|
555
|
+
} catch (e) { console.error(`thunder write: ${e.message}`); process.exitCode = 2; }
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
if (cmd === 'anchor') {
|
|
559
|
+
try {
|
|
560
|
+
if (!file) throw new Error('Use thunder anchor <file> [--json].');
|
|
561
|
+
const r = anchorReport(readFileSync(file, 'utf8'), { language: args.from, file: basename(file) });
|
|
562
|
+
if (args.json) { console.log(JSON.stringify(r, null, 2)); return; }
|
|
563
|
+
console.log(`${basename(file)} (${r.language}): ${Math.round(r.coverage * 1000) / 10}% of code lines are anchored to a Thunder step.`);
|
|
564
|
+
for (const f of r.functions) {
|
|
565
|
+
console.log(`\n${f.name} (line ${f.line}) ${Math.round(f.coverage * 100)}% anchored${f.missing.length ? `; not yet anchored: line ${f.missing.join(', ')}` : ''}`);
|
|
566
|
+
for (const s of f.steps) console.log(` ${s.path.padEnd(5)} ${s.span.startLine === s.span.endLine ? `L${s.span.startLine}` : `L${s.span.startLine}-${s.span.endLine}`}`.padEnd(18) + `${s.kind.padEnd(7)} ${s.says}`);
|
|
567
|
+
}
|
|
568
|
+
} catch (e) { console.error(`thunder anchor: ${e.message}`); process.exitCode = 2; }
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
if (cmd === 'repo') {
|
|
572
|
+
try {
|
|
573
|
+
if (!file) throw new Error('Use thunder repo <owner/repo | https://github.com/owner/repo | folder> [--json].');
|
|
574
|
+
const report = thunderRepo(file, { maxFiles: args.maxFiles ? Number(args.maxFiles) : undefined });
|
|
575
|
+
console.log(args.json ? JSON.stringify(report, null, 2) : renderThunderRepo(report));
|
|
576
|
+
process.exitCode = report.errors.length ? 1 : 0;
|
|
577
|
+
} catch (e) { console.error(`thunder repo: ${e.message}`); process.exitCode = 2; }
|
|
578
|
+
return;
|
|
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
|
+
}
|
|
618
|
+
if (cmd === 'plain' || cmd === 'text') {
|
|
619
|
+
try {
|
|
620
|
+
if (!file) throw new Error('Use thunder plain <file> [--json | --format source].');
|
|
621
|
+
if (args.format && args.format !== 'source') throw new Error('The supported format is source; omit --format to run the examples.');
|
|
622
|
+
const report = previewPlainContract(readFileSync(file, 'utf8'));
|
|
623
|
+
if (args.json) console.log(JSON.stringify(report, null, 2));
|
|
624
|
+
else if (args.format === 'source') process.stdout.write(report.canonicalSource);
|
|
625
|
+
else {
|
|
626
|
+
console.log(`${report.model.title}: ${report.tests.passed} of ${report.tests.total} examples pass. Application: not checked.`);
|
|
627
|
+
for (const r of report.tests.results) if (!r.pass) console.log(` failed: ${r.name}: expected ${r.expected}, got ${r.actual}`);
|
|
628
|
+
}
|
|
629
|
+
process.exitCode = report.tests.failed ? 1 : 0;
|
|
630
|
+
} catch (e) { console.error(`thunder plain: ${e.message}`); process.exitCode = 2; }
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
536
633
|
if (cmd === 'human') {
|
|
537
634
|
try {
|
|
538
635
|
if (!file) throw new Error('Use thunder human <file> [--json | --format source].');
|
|
@@ -792,7 +889,10 @@ function main() {
|
|
|
792
889
|
const code = generate(ast);
|
|
793
890
|
if (args.outExplicit) {
|
|
794
891
|
const ext = target.startsWith('ts') || target === 'typescript' ? 'ts' : target === 'python' ? 'py' : target === 'csharp' ? 'cs' : target;
|
|
795
|
-
|
|
892
|
+
// Java requires a public class to live in a file of exactly its name (RefundDecision.java).
|
|
893
|
+
const subject = subjectName(ast) || 'intent';
|
|
894
|
+
const fileName = ext === 'java' ? `${(subject[0].toUpperCase() + subject.slice(1)).replace(/[^A-Za-z0-9]/g, '')}.java` : `${slug(subject)}.${ext}`;
|
|
895
|
+
const p = writeText(args.out, fileName, code.endsWith('\n') ? code : code + '\n');
|
|
796
896
|
console.log(`wrote ${p.replace(process.cwd() + '/', '')}`);
|
|
797
897
|
return;
|
|
798
898
|
}
|
|
@@ -1862,6 +1962,15 @@ test Example
|
|
|
1862
1962
|
// Intent Atlas: the navigable/searchable whole-system map over the Intent Graph.
|
|
1863
1963
|
if (cmd === 'atlas') {
|
|
1864
1964
|
const root = file || '.';
|
|
1965
|
+
if (args.review || args.agentBrief || args.openthunder) {
|
|
1966
|
+
if (args.search || args.expand) throw new Error('Review mode cannot be combined with graph search or expansion.');
|
|
1967
|
+
const files = collectIntents(root).map((f) => ({ path: relative(root, f) || basename(f), source: readFileSync(f, 'utf8') }));
|
|
1968
|
+
const evidence = args.openthunder ? JSON.parse(readFileSync(args.openthunder, 'utf8')) : undefined;
|
|
1969
|
+
const review = buildReviewAtlas(files, { product: args.product, evidence });
|
|
1970
|
+
console.log(args.json ? JSON.stringify(review, null, 2) : renderReviewBrief(review));
|
|
1971
|
+
process.exitCode = reviewAtlasExitCode(review, { strict: args.strict });
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1865
1974
|
const graphs = collectIntents(root).map((f) => buildIntentGraph(parseIntent(readFileSync(f, 'utf8'))));
|
|
1866
1975
|
const atlas = buildAtlas(graphs, { product: args.product });
|
|
1867
1976
|
if (args.search) {
|
package/src/codegen.mjs
CHANGED
|
@@ -9,6 +9,15 @@
|
|
|
9
9
|
|
|
10
10
|
import { exprToJs, exprToCSharp, exprToJava, exprToPython } from './expr.mjs';
|
|
11
11
|
import { subjectName } from './parse.mjs';
|
|
12
|
+
import { inputNames, inferInputTypes } from './target-types.mjs';
|
|
13
|
+
|
|
14
|
+
// Decision inputs as plain names with one type each (declared, else from the examples, else from how the rules use
|
|
15
|
+
// them), so generated code type-checks: `amount >= 0` needs a number, not unknown or Object.
|
|
16
|
+
const decisionParams = (ast, d) => { const names = inputNames(d); const types = inferInputTypes(ast, d); return names.map((name) => ({ name, type: types[name] })); };
|
|
17
|
+
const TS_PARAM = { number: 'number', bool: 'boolean', string: 'string' };
|
|
18
|
+
const CS_PARAM = { number: 'double', bool: 'bool', string: 'string' };
|
|
19
|
+
const JAVA_PARAM = { number: 'double', bool: 'boolean', string: 'String' };
|
|
20
|
+
const PY_PARAM = { number: 'float', bool: 'bool', string: 'str' };
|
|
12
21
|
|
|
13
22
|
export const CODEGEN_SCHEMA = 'intent-codegen-v1';
|
|
14
23
|
|
|
@@ -60,8 +69,9 @@ export function toTypeScript(ast) {
|
|
|
60
69
|
|
|
61
70
|
// Decisions , real, first-hit logic (the intent already executes these).
|
|
62
71
|
for (const d of ast.decisions || []) {
|
|
63
|
-
const
|
|
64
|
-
const
|
|
72
|
+
const ps = decisionParams(ast, d);
|
|
73
|
+
const inputs = ps.map((x) => x.name);
|
|
74
|
+
const params = ps.map((x) => `${x.name}: ${TS_PARAM[x.type]}`).join(', ');
|
|
65
75
|
L.push(`// decision ${d.name} , first matching rule wins.`);
|
|
66
76
|
L.push(`export function ${lower(pascal(d.name))}(${params}): string {`);
|
|
67
77
|
for (const r of d.rules || []) {
|
|
@@ -78,7 +88,10 @@ export function toTypeScript(ast) {
|
|
|
78
88
|
const inName = (ast.inputs || []).length ? `${subject}Input` : 'void';
|
|
79
89
|
const outName = (ast.outputs || []).length ? `${subject}Output` : 'void';
|
|
80
90
|
const arg = inName === 'void' ? '' : `input: ${inName}`;
|
|
81
|
-
|
|
91
|
+
// A decision often shares the mission's name (RefundDecision); the mission function is then `run`, as in Java and Python.
|
|
92
|
+
const decisionFns = new Set((ast.decisions || []).map((d) => lower(pascal(d.name))));
|
|
93
|
+
const missionFn = decisionFns.has(lower(subject)) ? 'run' : lower(subject);
|
|
94
|
+
L.push(`export function ${missionFn}(${arg}): ${outName} {`);
|
|
82
95
|
for (const r of ast.requires || []) L.push(` // precondition: ${r} , TODO: validate`);
|
|
83
96
|
for (const n of ast.neverRules || []) L.push(` // NEVER: ${n.statement} , your code must not do this`);
|
|
84
97
|
for (const g of ast.guarantees || []) L.push(` // GUARANTEE: ${g.statement} , your code must uphold this${g.verify?.length ? ` (verify: ${g.verify.join(', ')})` : ''}`);
|
|
@@ -133,9 +146,12 @@ export function toCSharp(ast) {
|
|
|
133
146
|
if ((ast.outputs || []).length) L.push(...rec(`${subject}Output`, ast.outputs));
|
|
134
147
|
L.push(`public static class ${subject}`, '{');
|
|
135
148
|
for (const d of ast.decisions || []) {
|
|
136
|
-
const
|
|
149
|
+
const ps = decisionParams(ast, d);
|
|
150
|
+
const inputs = ps.map((x) => x.name);
|
|
151
|
+
// A C# member cannot share its class's name (CS0542): a decision named like the mission becomes Decide.
|
|
152
|
+
const method = pascal(d.name) === subject ? 'Decide' : pascal(d.name);
|
|
137
153
|
L.push(` // decision ${d.name} , first matching rule wins.`);
|
|
138
|
-
L.push(` public static string ${
|
|
154
|
+
L.push(` public static string ${method}(${ps.map((x) => `${CS_PARAM[x.type]} ${x.name}`).join(', ')})`);
|
|
139
155
|
L.push(' {');
|
|
140
156
|
for (const r of d.rules || []) {
|
|
141
157
|
let cond; try { cond = exprToCSharp(r.when, { inputs }); } catch { cond = `false /* TODO: could not translate "${r.when}" */`; }
|
|
@@ -189,9 +205,10 @@ export function toJava(ast) {
|
|
|
189
205
|
if ((ast.inputs || []).length) L.push(...rec(`${subject}Input`, ast.inputs));
|
|
190
206
|
if ((ast.outputs || []).length) L.push(...rec(`${subject}Output`, ast.outputs));
|
|
191
207
|
for (const d of ast.decisions || []) {
|
|
192
|
-
const
|
|
208
|
+
const ps = decisionParams(ast, d);
|
|
209
|
+
const inputs = ps.map((x) => x.name);
|
|
193
210
|
L.push(` // decision ${d.name} , first matching rule wins.`);
|
|
194
|
-
L.push(` public static String ${lower(pascal(d.name))}(${
|
|
211
|
+
L.push(` public static String ${lower(pascal(d.name))}(${ps.map((x) => `${JAVA_PARAM[x.type]} ${x.name}`).join(', ')}) {`);
|
|
195
212
|
for (const r of d.rules || []) {
|
|
196
213
|
let cond; try { cond = exprToJava(r.when, { inputs }); } catch { cond = `false /* TODO: could not translate "${r.when}" */`; }
|
|
197
214
|
L.push(` if (${cond}) return ${JSON.stringify(r.result)}; // rule ${r.name}`);
|
|
@@ -247,9 +264,10 @@ export function toPython(ast) {
|
|
|
247
264
|
if ((ast.inputs || []).length) L.push(...cls(`${subject}Input`, ast.inputs));
|
|
248
265
|
if ((ast.outputs || []).length) L.push(...cls(`${subject}Output`, ast.outputs));
|
|
249
266
|
for (const d of ast.decisions || []) {
|
|
250
|
-
const
|
|
267
|
+
const ps = decisionParams(ast, d);
|
|
268
|
+
const inputs = ps.map((x) => x.name);
|
|
251
269
|
L.push(`# decision ${d.name} , first matching rule wins.`);
|
|
252
|
-
L.push(`def ${snake(d.name)}(${
|
|
270
|
+
L.push(`def ${snake(d.name)}(${ps.map((x) => `${x.name}: ${PY_PARAM[x.type]}`).join(', ')}) -> str:`);
|
|
253
271
|
for (const r of d.rules || []) {
|
|
254
272
|
let cond, note = '';
|
|
255
273
|
try { cond = exprToPython(r.when, { inputs }); }
|
package/src/core.d.ts
CHANGED
|
@@ -6,7 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
// The canonical hash (byte-identical to node:crypto).
|
|
8
8
|
export { sha256, sha256hex } from './index';
|
|
9
|
+
export { runTests, TEST_SCHEMA, TestReport, resolveObligations, ObligationResolution } from './index';
|
|
9
10
|
export { HumanContractPreview, compileHumanContract, previewHumanContract, renderHumanContract, renderExampleTable } from './human-contract.mjs';
|
|
11
|
+
export { ANCHOR_SCHEMA, spanRange, spanText, replaceSpan, editStep, anchorReport } from './anchor.mjs';
|
|
12
|
+
export { WRITE_SCHEMA, writeRule, changedCases, ruleParts, joinRuleParts, COMPARISON_CHOICES } from './write.mjs';
|
|
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[];
|
|
26
|
+
export { PLAIN_SCHEMA, PlainModel, PlainPreview, PlainExplanation, parsePlainContract, renderPlainContract, plainToThunder, compilePlainContract, previewPlainContract, explainPlain } from './plain-contract.mjs';
|
|
10
27
|
|
|
11
28
|
// Parser + graph + in-memory compile.
|
|
12
29
|
export {
|
|
@@ -34,6 +51,7 @@ export {
|
|
|
34
51
|
} from './index';
|
|
35
52
|
|
|
36
53
|
// Intent Atlas + navigation.
|
|
54
|
+
export { buildReviewAtlas, renderReviewBrief, reviewAtlasExitCode, REVIEW_ATLAS_SCHEMA, ReviewFile, ReviewStatus, ReviewAtlasRow, ReviewAtlas } from './review-atlas.mjs';
|
|
37
55
|
export {
|
|
38
56
|
ATLAS_SCHEMA, IntentAtlas, buildAtlas, atlasNode, expandNode, searchAtlas,
|
|
39
57
|
} from './index';
|
|
@@ -106,3 +124,9 @@ export type { TranslateLanguage } from './translate.mjs';
|
|
|
106
124
|
// Read code you don't know.
|
|
107
125
|
export { readCode, searchReading, detectLanguage, READ_SCHEMA, READ_LANGUAGES } from './read.mjs';
|
|
108
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;
|
|
129
|
+
export { readRepo, searchRepo, groupByFile, readableLanguage, READ_REPO_SCHEMA, READ_SKIP_DIRS } from './read-repo.mjs';
|
|
130
|
+
export type { RepoItem, RepoFacet, RepoReading, RepoFilter } from './read-repo.mjs';
|
|
131
|
+
export { promoteDecision, PROMOTE_SCHEMA } from './promote.mjs';
|
|
132
|
+
export type { Promotion } from './promote.mjs';
|
package/src/core.mjs
CHANGED
|
@@ -7,6 +7,17 @@
|
|
|
7
7
|
// AI-implementation helpers (unchanged , keeps existing /core consumers working).
|
|
8
8
|
export * from './ai-core.mjs';
|
|
9
9
|
export { compileHumanContract, previewHumanContract, renderHumanContract, renderExampleTable } from './human-contract.mjs';
|
|
10
|
+
export { ANCHOR_SCHEMA, spanRange, spanText, replaceSpan, editStep, anchorReport } from './anchor.mjs';
|
|
11
|
+
export { WRITE_SCHEMA, writeRule, changedCases, ruleParts, joinRuleParts, COMPARISON_CHOICES } from './write.mjs';
|
|
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';
|
|
20
|
+
export { PLAIN_SCHEMA, parsePlainContract, renderPlainContract, plainToThunder, compilePlainContract, previewPlainContract, explainPlain } from './plain-contract.mjs';
|
|
10
21
|
|
|
11
22
|
// Classification model (observed/inferred/proposed/... + isFactual). Node-free.
|
|
12
23
|
export { CLASSIFICATIONS, CONFIDENCE, UNSETTLED, classify, isFactual, BLOCKABLE_PHASES } from './classification.mjs';
|
|
@@ -76,6 +87,7 @@ export { toFinding, universalPack, RISK_CATEGORIES, FABLE_SCHEMA } from './fable
|
|
|
76
87
|
export { VIEW_SCHEMA, VIEWS, coverageView, unverifiedView, gapsView, risksView, unknownsView, contradictionsView } from './scan-queries.mjs';
|
|
77
88
|
// Intent Atlas (whole-system map) + navigation primitives.
|
|
78
89
|
export { buildAtlas, atlasNode, expandNode, searchAtlas, ATLAS_SCHEMA } from './intent-atlas.mjs';
|
|
90
|
+
export { buildReviewAtlas, renderReviewBrief, reviewAtlasExitCode, REVIEW_ATLAS_SCHEMA } from './review-atlas.mjs';
|
|
79
91
|
// Intent Lens: Intent Scope + Focus Graph + Intent Brief (a focused subgraph of the Atlas).
|
|
80
92
|
export { FOCUS_SCHEMA, SCOPE_TYPES, FOCUS_REASONS, makeScope, buildFocusGraph, intentBrief } from './focus.mjs';
|
|
81
93
|
// Comprehension Contract: the C0..C7 understanding level (browser-safe; every product reads it).
|
|
@@ -91,7 +103,13 @@ export { TWELVE_FACTOR_SCHEMA, twelveFactorReport, twelveFactorSummary } from '.
|
|
|
91
103
|
export { diffGraphs, mergeGraphs } from './semantic-diff.mjs';
|
|
92
104
|
// Graph -> source (native round-trip) so a browser editor can regenerate .intent.
|
|
93
105
|
export { graphToSource, GRAPH_SOURCE_SCHEMA } from './graph-source.mjs';
|
|
106
|
+
|
|
107
|
+
export { resolveObligations } from './obligations.mjs';
|
|
108
|
+
export { runTests, TEST_SCHEMA } from './testing.mjs';
|
|
94
109
|
// Decisions -> readable typed source in six languages (browser-safe; same translators as the targets).
|
|
95
110
|
export { translateDecisions, TRANSLATE_LANGUAGES } from './translate.mjs';
|
|
96
111
|
// Read code you don't know: decisions recovered from six languages as ThunderLang + plain English.
|
|
97
|
-
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';
|
|
113
|
+
// Read a whole repository (pure: the caller passes file contents) and turn a recovered decision into a contract.
|
|
114
|
+
export { readRepo, searchRepo, groupByFile, readableLanguage, READ_REPO_SCHEMA, READ_SKIP_DIRS } from './read-repo.mjs';
|
|
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.
|
|
33
|
+
export const COMPILER_VERSION = '0.5.5';
|
|
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.
|