@skillstech/thunderlang 0.5.2 → 0.5.4
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 +36 -0
- package/dist/core.cjs +8381 -6614
- package/dist/index.cjs +2672 -1710
- package/package.json +1 -1
- package/src/anchor.d.mts +12 -0
- package/src/anchor.mjs +127 -0
- package/src/cli.mjs +104 -38
- package/src/codegen.mjs +27 -9
- package/src/core.d.ts +10 -0
- package/src/core.mjs +11 -0
- package/src/emit.mjs +1 -1
- package/src/index.d.ts +23 -0
- package/src/index.mjs +11 -0
- package/src/mcp.mjs +19 -32
- 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.mjs +142 -7
- package/src/review-atlas.d.mts +19 -0
- package/src/review-atlas.mjs +136 -0
- package/src/steps.d.mts +2 -0
- package/src/steps.mjs +297 -0
- package/src/target-types.mjs +39 -4
- package/src/testing.mjs +12 -9
- package/src/thunder-repo.mjs +96 -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.4",
|
|
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
|
@@ -16,6 +16,10 @@ import { readFileSync, writeFileSync, mkdirSync, readdirSync, statSync, existsSy
|
|
|
16
16
|
import { basename, join, relative, dirname } 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 } from './thunder-repo.mjs';
|
|
21
|
+
import { anchorReport } from './anchor.mjs';
|
|
22
|
+
import { writeRule } from './write.mjs';
|
|
19
23
|
import { readCode, searchReading } from './read.mjs';
|
|
20
24
|
import { readRepo, searchRepo, groupByFile } from './read-repo.mjs';
|
|
21
25
|
import { promoteDecision } from './promote.mjs';
|
|
@@ -47,6 +51,7 @@ import { buildMissionIndex } from './atlas.mjs';
|
|
|
47
51
|
import { parseSelection, regionMetrics, selectCandidate } from './select.mjs';
|
|
48
52
|
import { buildIntentGraph, safeGraph } from './intent-graph.mjs';
|
|
49
53
|
import { buildAtlas, searchAtlas, expandNode } from './intent-atlas.mjs';
|
|
54
|
+
import { buildReviewAtlas, renderReviewBrief, reviewAtlasExitCode } from './review-atlas.mjs';
|
|
50
55
|
import { buildFocusGraph, intentBrief, makeScope } from './focus.mjs';
|
|
51
56
|
import { comprehensionLevel, comprehensionReport, LEVELS as COMPREHENSION_LEVELS } from './comprehension.mjs';
|
|
52
57
|
import { twelveFactorReport } from './twelve-factor.mjs';
|
|
@@ -106,6 +111,7 @@ function runLiveTarget(ast, target) {
|
|
|
106
111
|
}
|
|
107
112
|
import { importIntent, importReport, detectFormat, IMPORT_FORMATS } from './importers.mjs';
|
|
108
113
|
import { runTests } from './testing.mjs';
|
|
114
|
+
import { resolveObligations } from './obligations.mjs';
|
|
109
115
|
import { toEvidenceEvents, verifyDiffToEvidence, conformToEvidence, driftToEvidence } from './evidence.mjs';
|
|
110
116
|
import { evaluateOutcomes } from './outcome.mjs';
|
|
111
117
|
import { analyzeStyle } from './style.mjs';
|
|
@@ -192,43 +198,6 @@ function collectIntents(root, acc = []) {
|
|
|
192
198
|
return acc;
|
|
193
199
|
}
|
|
194
200
|
|
|
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
201
|
// Proof freshness: a proof is valid only for a specific (intent, implementation, dependencies,
|
|
233
202
|
// compiler, environment) tuple. These helpers capture that tuple so `verify` can mark a proof STALE.
|
|
234
203
|
const gitCmd = (c) => { try { return execSync(`git ${c}`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] }).trim() || null; } catch { return null; } };
|
|
@@ -275,6 +244,12 @@ function parseArgs(argv) {
|
|
|
275
244
|
else if (a === '--by') args.by = argv[++i];
|
|
276
245
|
else if (a === '--at') args.at = argv[++i];
|
|
277
246
|
else if (a === '--json') args.json = true;
|
|
247
|
+
else if (a === '--review') args.review = true;
|
|
248
|
+
else if (a === '--agent-brief') args.agentBrief = true;
|
|
249
|
+
else if (a === '--openthunder') {
|
|
250
|
+
if (!argv[i + 1] || argv[i + 1].startsWith('--')) throw new Error('--openthunder requires a JSON report path');
|
|
251
|
+
args.openthunder = argv[++i];
|
|
252
|
+
}
|
|
278
253
|
else if (a === '--targets') args.targets = (argv[++i] || '').split(',').filter(Boolean);
|
|
279
254
|
else if (a === '--product') args.product = argv[++i];
|
|
280
255
|
else if (a === '--allow-pending') args.allowPending = true;
|
|
@@ -296,6 +271,8 @@ function parseArgs(argv) {
|
|
|
296
271
|
else if (a === '--inputs') args.inputs = argv[++i];
|
|
297
272
|
else if (a === '--events') args.events = (argv[++i] || '').split(',').map((s) => s.trim()).filter(Boolean);
|
|
298
273
|
else if (a === '--decision') args.decision = argv[++i];
|
|
274
|
+
else if (a === '--rule') args.rule = argv[++i];
|
|
275
|
+
else if (a === '--when') args.when = argv[++i];
|
|
299
276
|
else if (a === '--to') args.to = argv[++i];
|
|
300
277
|
else if (a === '--force') args.force = true;
|
|
301
278
|
else if (a === '--write' || a === '-w') args.write = true;
|
|
@@ -419,6 +396,8 @@ Inspect
|
|
|
419
396
|
docs <file> [--lens <lens>] [--out <dir>] render a mission as Markdown docs (per-audience with --lens)
|
|
420
397
|
index <dir> the Mission Atlas inventory
|
|
421
398
|
atlas <dir> [--search q | --expand id] the whole-system Atlas
|
|
399
|
+
atlas <dir> --review [--json | --agent-brief] [--openthunder report.json] [--strict]
|
|
400
|
+
execute contract cases, rank review gaps, compare OpenThunder snapshots
|
|
422
401
|
|
|
423
402
|
Run & test
|
|
424
403
|
run <file> --inputs '<json>' execute the decision(s) deterministically
|
|
@@ -456,6 +435,13 @@ Real code vs intent (drift)
|
|
|
456
435
|
|
|
457
436
|
Graph & IR
|
|
458
437
|
human <file> [--json | --format source] experimental compact authoring and a decision reading view
|
|
438
|
+
--version print the Thunder compiler version
|
|
439
|
+
anchor <file> [--json] show every Thunder step with its exact place in the file, and line coverage
|
|
440
|
+
write <file> --decision <name> --rule <n|otherwise> [--when "<condition>"] [--answer <Outcome>] [--write] [--json]
|
|
441
|
+
Thunder write: change a number, comparison, text value, or answer in a recovered rule;
|
|
442
|
+
previews the exact code change and the cases whose answer changes; --write saves it
|
|
443
|
+
repo <owner/repo | github url | folder> [--json] [--max-files n] Thunder a whole repository (read-only; nothing is executed)
|
|
444
|
+
text <file> [--json | --format source] experimental Thunder Text rule (.thunder-plain): run its examples [alias: plain]
|
|
459
445
|
read <file|dir> [--search q] [--kind decision,function,error,test] [--in <lang>] [--from <lang>] [--json]
|
|
460
446
|
for a folder also: [--answer <Outcome>] [--input <name>] [--lang go,rust] [--path <prefix>] [--limit n]
|
|
461
447
|
--promote <decision> [--out <file>] turn a recovered decision into a contract with starter examples
|
|
@@ -485,6 +471,10 @@ function main() {
|
|
|
485
471
|
const [cmd, ...restArgv] = process.argv.slice(2);
|
|
486
472
|
const args = parseArgs(restArgv);
|
|
487
473
|
const file = args._[0];
|
|
474
|
+
if (cmd === '--version' || cmd === '-v' || cmd === 'version') {
|
|
475
|
+
console.log(`thunder ${COMPILER_VERSION} (the Thunder compiler, also called ThunderLang)`);
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
488
478
|
if (!cmd || cmd === 'help' || cmd === '--help' || cmd === '-h') {
|
|
489
479
|
console.log(HELP);
|
|
490
480
|
process.exit(cmd ? 0 : 2);
|
|
@@ -533,6 +523,70 @@ function main() {
|
|
|
533
523
|
} catch (e) { console.error(`thunder read: ${e.message}`); process.exitCode = 2; }
|
|
534
524
|
return;
|
|
535
525
|
}
|
|
526
|
+
if (cmd === 'write') {
|
|
527
|
+
try {
|
|
528
|
+
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].');
|
|
529
|
+
const source = readFileSync(file, 'utf8');
|
|
530
|
+
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 });
|
|
531
|
+
if (r.ok && args.write) writeFileSync(file, r.source);
|
|
532
|
+
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; }
|
|
533
|
+
if (!r.ok) {
|
|
534
|
+
console.error(`Not changed. ${file} is untouched.`);
|
|
535
|
+
for (const p of r.problems) console.error(` ${p}`);
|
|
536
|
+
process.exitCode = 1;
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
console.log(`${r.decision}, rule ${r.rule}`);
|
|
540
|
+
console.log(` was: ${r.before}`);
|
|
541
|
+
console.log(` now: ${r.after}`);
|
|
542
|
+
console.log('\nCode change (only these characters):');
|
|
543
|
+
for (const c of r.change) console.log(` line ${c.line}, column ${c.column}: ${c.before} -> ${c.after}`);
|
|
544
|
+
console.log('\nChecked by reading the file again: this rule reads as intended; every other rule and function reads exactly as before.');
|
|
545
|
+
console.log(`\n${r.cases.note}`);
|
|
546
|
+
const names = r.cases.changed[0] ? Object.keys(r.cases.changed[0].inputs) : [];
|
|
547
|
+
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}`);
|
|
548
|
+
if (r.cases.changed.length > 8) console.log(` ...and ${r.cases.changed.length - 8} more (use --json for all).`);
|
|
549
|
+
console.log(args.write ? `\nSaved ${file}. Run your tests before you commit.` : '\nPreview only; nothing was saved. Add --write to save the change.');
|
|
550
|
+
} catch (e) { console.error(`thunder write: ${e.message}`); process.exitCode = 2; }
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
if (cmd === 'anchor') {
|
|
554
|
+
try {
|
|
555
|
+
if (!file) throw new Error('Use thunder anchor <file> [--json].');
|
|
556
|
+
const r = anchorReport(readFileSync(file, 'utf8'), { language: args.from, file: basename(file) });
|
|
557
|
+
if (args.json) { console.log(JSON.stringify(r, null, 2)); return; }
|
|
558
|
+
console.log(`${basename(file)} (${r.language}): ${Math.round(r.coverage * 1000) / 10}% of code lines are anchored to a Thunder step.`);
|
|
559
|
+
for (const f of r.functions) {
|
|
560
|
+
console.log(`\n${f.name} (line ${f.line}) ${Math.round(f.coverage * 100)}% anchored${f.missing.length ? `; not yet anchored: line ${f.missing.join(', ')}` : ''}`);
|
|
561
|
+
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}`);
|
|
562
|
+
}
|
|
563
|
+
} catch (e) { console.error(`thunder anchor: ${e.message}`); process.exitCode = 2; }
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
if (cmd === 'repo') {
|
|
567
|
+
try {
|
|
568
|
+
if (!file) throw new Error('Use thunder repo <owner/repo | https://github.com/owner/repo | folder> [--json].');
|
|
569
|
+
const report = thunderRepo(file, { maxFiles: args.maxFiles ? Number(args.maxFiles) : undefined });
|
|
570
|
+
console.log(args.json ? JSON.stringify(report, null, 2) : renderThunderRepo(report));
|
|
571
|
+
process.exitCode = report.errors.length ? 1 : 0;
|
|
572
|
+
} catch (e) { console.error(`thunder repo: ${e.message}`); process.exitCode = 2; }
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
if (cmd === 'plain' || cmd === 'text') {
|
|
576
|
+
try {
|
|
577
|
+
if (!file) throw new Error('Use thunder plain <file> [--json | --format source].');
|
|
578
|
+
if (args.format && args.format !== 'source') throw new Error('The supported format is source; omit --format to run the examples.');
|
|
579
|
+
const report = previewPlainContract(readFileSync(file, 'utf8'));
|
|
580
|
+
if (args.json) console.log(JSON.stringify(report, null, 2));
|
|
581
|
+
else if (args.format === 'source') process.stdout.write(report.canonicalSource);
|
|
582
|
+
else {
|
|
583
|
+
console.log(`${report.model.title}: ${report.tests.passed} of ${report.tests.total} examples pass. Application: not checked.`);
|
|
584
|
+
for (const r of report.tests.results) if (!r.pass) console.log(` failed: ${r.name}: expected ${r.expected}, got ${r.actual}`);
|
|
585
|
+
}
|
|
586
|
+
process.exitCode = report.tests.failed ? 1 : 0;
|
|
587
|
+
} catch (e) { console.error(`thunder plain: ${e.message}`); process.exitCode = 2; }
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
536
590
|
if (cmd === 'human') {
|
|
537
591
|
try {
|
|
538
592
|
if (!file) throw new Error('Use thunder human <file> [--json | --format source].');
|
|
@@ -792,7 +846,10 @@ function main() {
|
|
|
792
846
|
const code = generate(ast);
|
|
793
847
|
if (args.outExplicit) {
|
|
794
848
|
const ext = target.startsWith('ts') || target === 'typescript' ? 'ts' : target === 'python' ? 'py' : target === 'csharp' ? 'cs' : target;
|
|
795
|
-
|
|
849
|
+
// Java requires a public class to live in a file of exactly its name (RefundDecision.java).
|
|
850
|
+
const subject = subjectName(ast) || 'intent';
|
|
851
|
+
const fileName = ext === 'java' ? `${(subject[0].toUpperCase() + subject.slice(1)).replace(/[^A-Za-z0-9]/g, '')}.java` : `${slug(subject)}.${ext}`;
|
|
852
|
+
const p = writeText(args.out, fileName, code.endsWith('\n') ? code : code + '\n');
|
|
796
853
|
console.log(`wrote ${p.replace(process.cwd() + '/', '')}`);
|
|
797
854
|
return;
|
|
798
855
|
}
|
|
@@ -1862,6 +1919,15 @@ test Example
|
|
|
1862
1919
|
// Intent Atlas: the navigable/searchable whole-system map over the Intent Graph.
|
|
1863
1920
|
if (cmd === 'atlas') {
|
|
1864
1921
|
const root = file || '.';
|
|
1922
|
+
if (args.review || args.agentBrief || args.openthunder) {
|
|
1923
|
+
if (args.search || args.expand) throw new Error('Review mode cannot be combined with graph search or expansion.');
|
|
1924
|
+
const files = collectIntents(root).map((f) => ({ path: relative(root, f) || basename(f), source: readFileSync(f, 'utf8') }));
|
|
1925
|
+
const evidence = args.openthunder ? JSON.parse(readFileSync(args.openthunder, 'utf8')) : undefined;
|
|
1926
|
+
const review = buildReviewAtlas(files, { product: args.product, evidence });
|
|
1927
|
+
console.log(args.json ? JSON.stringify(review, null, 2) : renderReviewBrief(review));
|
|
1928
|
+
process.exitCode = reviewAtlasExitCode(review, { strict: args.strict });
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1865
1931
|
const graphs = collectIntents(root).map((f) => buildIntentGraph(parseIntent(readFileSync(f, 'utf8'))));
|
|
1866
1932
|
const atlas = buildAtlas(graphs, { product: args.product });
|
|
1867
1933
|
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,12 @@
|
|
|
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 { PLAIN_SCHEMA, PlainModel, PlainPreview, PlainExplanation, parsePlainContract, renderPlainContract, plainToThunder, compilePlainContract, previewPlainContract, explainPlain } from './plain-contract.mjs';
|
|
10
15
|
|
|
11
16
|
// Parser + graph + in-memory compile.
|
|
12
17
|
export {
|
|
@@ -34,6 +39,7 @@ export {
|
|
|
34
39
|
} from './index';
|
|
35
40
|
|
|
36
41
|
// Intent Atlas + navigation.
|
|
42
|
+
export { buildReviewAtlas, renderReviewBrief, reviewAtlasExitCode, REVIEW_ATLAS_SCHEMA, ReviewFile, ReviewStatus, ReviewAtlasRow, ReviewAtlas } from './review-atlas.mjs';
|
|
37
43
|
export {
|
|
38
44
|
ATLAS_SCHEMA, IntentAtlas, buildAtlas, atlasNode, expandNode, searchAtlas,
|
|
39
45
|
} from './index';
|
|
@@ -106,3 +112,7 @@ export type { TranslateLanguage } from './translate.mjs';
|
|
|
106
112
|
// Read code you don't know.
|
|
107
113
|
export { readCode, searchReading, detectLanguage, READ_SCHEMA, READ_LANGUAGES } from './read.mjs';
|
|
108
114
|
export type { Reading, ReadItem, ReadKind } from './read.mjs';
|
|
115
|
+
export { readRepo, searchRepo, groupByFile, readableLanguage, READ_REPO_SCHEMA, READ_SKIP_DIRS } from './read-repo.mjs';
|
|
116
|
+
export type { RepoItem, RepoFacet, RepoReading, RepoFilter } from './read-repo.mjs';
|
|
117
|
+
export { promoteDecision, PROMOTE_SCHEMA } from './promote.mjs';
|
|
118
|
+
export type { Promotion } from './promote.mjs';
|
package/src/core.mjs
CHANGED
|
@@ -7,6 +7,10 @@
|
|
|
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 { PLAIN_SCHEMA, parsePlainContract, renderPlainContract, plainToThunder, compilePlainContract, previewPlainContract, explainPlain } from './plain-contract.mjs';
|
|
10
14
|
|
|
11
15
|
// Classification model (observed/inferred/proposed/... + isFactual). Node-free.
|
|
12
16
|
export { CLASSIFICATIONS, CONFIDENCE, UNSETTLED, classify, isFactual, BLOCKABLE_PHASES } from './classification.mjs';
|
|
@@ -76,6 +80,7 @@ export { toFinding, universalPack, RISK_CATEGORIES, FABLE_SCHEMA } from './fable
|
|
|
76
80
|
export { VIEW_SCHEMA, VIEWS, coverageView, unverifiedView, gapsView, risksView, unknownsView, contradictionsView } from './scan-queries.mjs';
|
|
77
81
|
// Intent Atlas (whole-system map) + navigation primitives.
|
|
78
82
|
export { buildAtlas, atlasNode, expandNode, searchAtlas, ATLAS_SCHEMA } from './intent-atlas.mjs';
|
|
83
|
+
export { buildReviewAtlas, renderReviewBrief, reviewAtlasExitCode, REVIEW_ATLAS_SCHEMA } from './review-atlas.mjs';
|
|
79
84
|
// Intent Lens: Intent Scope + Focus Graph + Intent Brief (a focused subgraph of the Atlas).
|
|
80
85
|
export { FOCUS_SCHEMA, SCOPE_TYPES, FOCUS_REASONS, makeScope, buildFocusGraph, intentBrief } from './focus.mjs';
|
|
81
86
|
// Comprehension Contract: the C0..C7 understanding level (browser-safe; every product reads it).
|
|
@@ -91,7 +96,13 @@ export { TWELVE_FACTOR_SCHEMA, twelveFactorReport, twelveFactorSummary } from '.
|
|
|
91
96
|
export { diffGraphs, mergeGraphs } from './semantic-diff.mjs';
|
|
92
97
|
// Graph -> source (native round-trip) so a browser editor can regenerate .intent.
|
|
93
98
|
export { graphToSource, GRAPH_SOURCE_SCHEMA } from './graph-source.mjs';
|
|
99
|
+
|
|
100
|
+
export { resolveObligations } from './obligations.mjs';
|
|
101
|
+
export { runTests, TEST_SCHEMA } from './testing.mjs';
|
|
94
102
|
// Decisions -> readable typed source in six languages (browser-safe; same translators as the targets).
|
|
95
103
|
export { translateDecisions, TRANSLATE_LANGUAGES } from './translate.mjs';
|
|
96
104
|
// Read code you don't know: decisions recovered from six languages as ThunderLang + plain English.
|
|
97
105
|
export { readCode, searchReading, detectLanguage, READ_SCHEMA, READ_LANGUAGES } from './read.mjs';
|
|
106
|
+
// Read a whole repository (pure: the caller passes file contents) and turn a recovered decision into a contract.
|
|
107
|
+
export { readRepo, searchRepo, groupByFile, readableLanguage, READ_REPO_SCHEMA, READ_SKIP_DIRS } from './read-repo.mjs';
|
|
108
|
+
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.4';
|
|
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
|
@@ -204,6 +204,7 @@ export interface IntentGraph {
|
|
|
204
204
|
export function buildIntentGraph(ast: IntentAst): IntentGraph;
|
|
205
205
|
|
|
206
206
|
// Intent Atlas (whole-system navigable map over the graph)
|
|
207
|
+
export { buildReviewAtlas, renderReviewBrief, reviewAtlasExitCode, REVIEW_ATLAS_SCHEMA, ReviewFile, ReviewStatus, ReviewAtlasRow, ReviewAtlas } from './review-atlas.mjs';
|
|
207
208
|
export const ATLAS_SCHEMA: string;
|
|
208
209
|
export interface IntentAtlas {
|
|
209
210
|
schema: string; product: string | null;
|
|
@@ -460,6 +461,17 @@ export interface TestReport {
|
|
|
460
461
|
results: Array<{ target: string | null; case: string; kind: string; expected?: unknown; actual?: unknown; valid?: boolean; expectValid?: boolean | null; pass: boolean; error?: string; note?: string }>;
|
|
461
462
|
}
|
|
462
463
|
export function runTests(ast: IntentAst): TestReport;
|
|
464
|
+
export interface ObligationResolution {
|
|
465
|
+
kind: 'guarantee' | 'prohibition'; id?: string; text: string;
|
|
466
|
+
status: 'verified' | 'failed' | 'declared' | 'unverified';
|
|
467
|
+
verify: string[]; kinds: string[]; provenBy: string | null;
|
|
468
|
+
evidence: Array<{ name: string; pass: boolean | null; cases: number }>;
|
|
469
|
+
unresolved: string[];
|
|
470
|
+
}
|
|
471
|
+
export function resolveObligations(ast: IntentAst): {
|
|
472
|
+
obligations: ObligationResolution[]; tests: TestReport;
|
|
473
|
+
verified: number; failed: number; declared: number; unverified: number;
|
|
474
|
+
};
|
|
463
475
|
|
|
464
476
|
// Outcome contracts (executable commitments)
|
|
465
477
|
export const OUTCOME_SCHEMA: string;
|
|
@@ -724,3 +736,14 @@ export interface ChangeReport {
|
|
|
724
736
|
touchedNodeIds: string[];
|
|
725
737
|
}
|
|
726
738
|
export function changeReport(pairs: Array<{ path: string; before: IntentGraph | null; after: IntentGraph | null }>): ChangeReport;
|
|
739
|
+
|
|
740
|
+
// Read code you don't know.
|
|
741
|
+
export { readCode, searchReading, detectLanguage, READ_SCHEMA, READ_LANGUAGES } from './read.mjs';
|
|
742
|
+
export type { Reading, ReadItem, ReadKind } from './read.mjs';
|
|
743
|
+
export { readRepo, searchRepo, groupByFile, readableLanguage, READ_REPO_SCHEMA, READ_SKIP_DIRS } from './read-repo.mjs';
|
|
744
|
+
export type { RepoItem, RepoFacet, RepoReading, RepoFilter } from './read-repo.mjs';
|
|
745
|
+
export function collectReadableFiles(root: string, options?: { maxFiles?: number; maxFileBytes?: number }): Array<{ path: string; source: string; size?: number }>;
|
|
746
|
+
export { promoteDecision, PROMOTE_SCHEMA } from './promote.mjs';
|
|
747
|
+
export type { Promotion } from './promote.mjs';
|
|
748
|
+
export { WRITE_SCHEMA, writeRule, changedCases, ruleParts, joinRuleParts, COMPARISON_CHOICES } from './write.mjs';
|
|
749
|
+
export type { ChangedCase, ChangedCases, WriteChange, RulePart } from './write.mjs';
|
package/src/index.mjs
CHANGED
|
@@ -64,6 +64,7 @@ export { parseSelection, regionMetrics, selectCandidate } from './select.mjs';
|
|
|
64
64
|
export { buildIntentGraph, INTENT_GRAPH_SCHEMA } from './intent-graph.mjs';
|
|
65
65
|
// Intent Atlas , the navigable/searchable whole-system map over the graph (directive #4)
|
|
66
66
|
export { buildAtlas, atlasNode, expandNode, searchAtlas, ATLAS_SCHEMA } from './intent-atlas.mjs';
|
|
67
|
+
export { buildReviewAtlas, renderReviewBrief, reviewAtlasExitCode, REVIEW_ATLAS_SCHEMA } from './review-atlas.mjs';
|
|
67
68
|
export { diffGraphs, mergeGraphs } from './semantic-diff.mjs';
|
|
68
69
|
export { CLASSIFICATIONS, CONFIDENCE, UNSETTLED, classify, isFactual, BLOCKABLE_PHASES } from './classification.mjs';
|
|
69
70
|
export { composeConstraints, detectConflicts } from './conflict.mjs';
|
|
@@ -184,3 +185,13 @@ export { startLspServer } from "./lsp.mjs";
|
|
|
184
185
|
|
|
185
186
|
// Formatter , canonical .intent formatting (whitespace only)
|
|
186
187
|
export { formatSource, isFormatted } from "./format.mjs";
|
|
188
|
+
|
|
189
|
+
export { resolveObligations } from './obligations.mjs';
|
|
190
|
+
// Read code you don't know: one file, a whole repository, files from disk, and promotion of a recovered decision
|
|
191
|
+
// into a contract with edge-case examples.
|
|
192
|
+
export { readCode, searchReading, detectLanguage, READ_SCHEMA, READ_LANGUAGES } from "./read.mjs";
|
|
193
|
+
export { readRepo, searchRepo, groupByFile, readableLanguage, READ_REPO_SCHEMA, READ_SKIP_DIRS } from "./read-repo.mjs";
|
|
194
|
+
export { collectReadableFiles } from "./read-repo-fs.mjs";
|
|
195
|
+
export { promoteDecision, PROMOTE_SCHEMA } from "./promote.mjs";
|
|
196
|
+
// Thunder write: change a recovered rule and write exactly those characters back, verified by re-reading.
|
|
197
|
+
export { WRITE_SCHEMA, writeRule, changedCases, ruleParts, joinRuleParts, COMPARISON_CHOICES } from "./write.mjs";
|