@skillstech/thunderlang 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -0
- package/README.md +10 -3
- package/dist/core.cjs +234 -20
- package/dist/index.cjs +8853 -1045
- package/dist/learn.cjs +1339 -69
- package/package.json +1 -1
- package/src/cli-main.mjs +312 -115
- package/src/core/check.mjs +312 -6
- package/src/core/cli.mjs +60 -8
- package/src/core/csharp-run.mjs +2 -2
- package/src/core/diagnostics.mjs +9 -0
- package/src/core/engine-core.mjs +141 -19
- package/src/core/engine-values.mjs +1 -0
- package/src/core/engine.mjs +131 -7
- package/src/core/go-run.mjs +2 -2
- package/src/core/index.mjs +6 -2
- package/src/core/java-run.mjs +2 -2
- package/src/core/kind.mjs +3 -0
- package/src/core/lexer.mjs +16 -2
- package/src/core/parser.mjs +200 -15
- package/src/core/project-root.mjs +18 -0
- package/src/core/project.mjs +15 -18
- package/src/core/react-run.mjs +2 -2
- package/src/core/runtime-go/thunder_runtime.go +269 -1
- package/src/core/runtime-python.mjs +365 -3
- package/src/core/runtime-typescript.mjs +150 -5
- package/src/core/rust-run.mjs +2 -2
- package/src/core/serving.mjs +12 -0
- package/src/core/store-format.mjs +110 -0
- package/src/core/target-go.mjs +10 -3
- package/src/core/target-python.mjs +38 -5
- package/src/core/target-typescript.mjs +62 -6
- package/src/core/typescript-run.mjs +6 -4
- package/src/core-changes-fs.mjs +28 -0
- package/src/core-changes.d.mts +67 -0
- package/src/core-changes.mjs +603 -0
- package/src/core-rules.mjs +146 -0
- package/src/core-services.d.mts +4 -0
- package/src/core-services.mjs +49 -0
- package/src/emit.mjs +1 -1
- package/src/evidence.mjs +28 -0
- package/src/examples.d.mts +21 -0
- package/src/examples.mjs +175 -0
- package/src/index.d.ts +4 -0
- package/src/index.mjs +4 -0
- package/src/mcp.mjs +42 -3
- package/src/program.d.mts +4 -0
- package/src/program.mjs +4 -0
- package/src/read-repo-fs.mjs +2 -1
- package/src/review.mjs +69 -3
- package/src/system.mjs +1 -1
- package/src/trace-cli.mjs +8 -3
- package/src/trace-fs.mjs +29 -3
- package/src/trace.mjs +23 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skillstech/thunderlang",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Thunder™, the human programming language: the deterministic ThunderLang™ compiler, CLI, and Language Server. No AI required. Reads code in seventeen languages into Thunder, changes TypeScript, JavaScript, Python, and Go code from Thunder with a proof, compiles rules to six languages, and executes them: run decisions, simulate lifecycles, and check outcome contracts. Interops with DMN, BPMN, JSON Schema, and OpenAPI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.mjs",
|
package/src/cli-main.mjs
CHANGED
|
@@ -13,103 +13,247 @@
|
|
|
13
13
|
|
|
14
14
|
import { readFileSync, writeFileSync, mkdirSync, readdirSync, statSync, existsSync } from 'node:fs';
|
|
15
15
|
import { basename, join, relative, dirname, resolve } from 'node:path';
|
|
16
|
-
import { parseIntent, slug, subjectName, KNOWN_LENSES } from './parse.mjs';
|
|
17
|
-
import { previewHumanContract, renderHumanContract } from './human-contract.mjs';
|
|
18
|
-
import { previewPlainContract } from './plain-contract.mjs';
|
|
19
|
-
import { thunderRepo, renderThunderRepo, parseGitHub, cloneGitHub } from './thunder-repo.mjs';
|
|
20
|
-
import { thunderizeFiles, THUNDER_TEXT_EXT } from './thunderize.mjs';
|
|
21
|
-
import { sameMeaning, renderSame } from './same.mjs';
|
|
22
|
-
import { anchorReport } from './anchor.mjs';
|
|
23
|
-
import { writeRule } from './write.mjs';
|
|
24
|
-
import { thunderWrite } from './write-steps.mjs';
|
|
25
|
-
import { readCode, searchReading } from './read.mjs';
|
|
26
|
-
import { readRepo, searchRepo, groupByFile } from './read-repo.mjs';
|
|
27
|
-
import { promoteDecision } from './promote.mjs';
|
|
28
|
-
import { collectReadableFiles } from './read-repo-fs.mjs';
|
|
29
|
-
import { accessFlow, accessText } from './flow/access.mjs';
|
|
30
|
-
import { translateDecisions } from './translate.mjs';
|
|
31
|
-
import {
|
|
32
|
-
buildContractGraph, buildArchitectureGraph, buildImplementationPlan,
|
|
33
|
-
semanticDiagnostics, buildProof, sha256, COMPILER_VERSION,
|
|
34
|
-
} from './emit.mjs';
|
|
35
|
-
import { toSarif } from './sarif.mjs';
|
|
36
|
-
import { renderMarkdown, renderLensDoc, renderMermaid, renderTestplan } from './compile.mjs';
|
|
37
|
-
import { getCompletions, getHover, getCodeActions, autocorrectSource } from './intellisense.mjs';
|
|
38
|
-
import { startLspServer } from './lsp.mjs';
|
|
39
|
-
import { startMcpServer } from './mcp.mjs';
|
|
40
|
-
import { formatSource } from './format.mjs';
|
|
41
|
-
import { applyEdits } from './patch.mjs';
|
|
42
|
-
import { buildReport } from './report.mjs';
|
|
43
|
-
import { scanProject } from './scan.mjs';
|
|
44
|
-
import { VIEWS } from './scan-queries.mjs';
|
|
45
|
-
import { guardianReport } from './guardian.mjs';
|
|
46
|
-
import { simulateChange } from './simulate.mjs';
|
|
47
|
-
import { verifyLedger, explain as ledgerExplain } from './ledger.mjs';
|
|
48
|
-
import { verifyDiff } from './verify-diff.mjs';
|
|
49
|
-
import { verifyRun, executedText, mergeTraces } from './executed.mjs';
|
|
50
|
-
import { runtimeOverlay, runtimeText, fromTrace, fromStack, fromLogs, fromOtlp, parseStacks, explainError, countWords } from './running.mjs';
|
|
51
|
-
import { thunderModel } from './model.mjs';
|
|
52
|
-
import { LEVELS, readLevel, renderLevel, findFocus, nearestLevel } from './read-level.mjs';
|
|
53
|
-
import { traceMain } from './trace-cli.mjs';
|
|
54
|
-
import { passportMain } from './passport-cli.mjs';
|
|
55
|
-
import { isWriteAcross, writeAcrossMain } from './write-across-cli.mjs';
|
|
56
|
-
import { whyMain } from './why-cli.mjs';
|
|
57
|
-
import { tryMain } from './try-cli.mjs';
|
|
58
|
-
import { replayMain } from './replay-cli.mjs';
|
|
59
|
-
import { homeText, helpFor, knownCommands, unknownCommandText, noProjectText, doctorMain, completionMain } from './cli-home.mjs';
|
|
60
|
-
import { paint, paintHelp, paintThunder, useColor } from './term.mjs';
|
|
61
|
-
import { coreMain } from './core/cli.mjs';
|
|
62
|
-
import { behaviourCheck } from './behaviour.mjs';
|
|
63
|
-
import { findProjectRoot } from './core/project.mjs';
|
|
64
|
-
import { pythonToCore } from './core/from-python.mjs';
|
|
65
|
-
import { guardSummary } from './guard.mjs';
|
|
66
|
-
import { draftIntent } from './draft.mjs';
|
|
67
|
-
import { liftSource, liftAll, liftRepo, languageForFile } from './lift.mjs';
|
|
68
|
-
import { approveIntent, checkDrift, buildDriftHandoff } from './drift.mjs';
|
|
69
|
-
import { buildMissionIndex } from './atlas.mjs';
|
|
70
|
-
import { parseSelection, regionMetrics, selectCandidate } from './select.mjs';
|
|
71
|
-
import { buildIntentGraph, safeGraph } from './intent-graph.mjs';
|
|
72
|
-
import { buildAtlas, searchAtlas, expandNode } from './intent-atlas.mjs';
|
|
73
|
-
import { buildReviewAtlas, renderReviewBrief, reviewAtlasExitCode } from './review-atlas.mjs';
|
|
74
|
-
import { buildFocusGraph, intentBrief, makeScope } from './focus.mjs';
|
|
75
|
-
import { comprehensionLevel, comprehensionReport, LEVELS as COMPREHENSION_LEVELS } from './comprehension.mjs';
|
|
76
|
-
import { twelveFactorReport } from './twelve-factor.mjs';
|
|
77
|
-
import { GENERATORS, generateWithDiagnostics } from './codegen.mjs';
|
|
78
|
-
import { changeReport } from './changes.mjs';
|
|
79
16
|
import { execSync, execFileSync, spawnSync } from 'node:child_process';
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
17
|
+
// <lazy-imports> generated by scripts/lazy-cli.mjs: run it after changing imports or commands
|
|
18
|
+
// Thunder's own modules, loaded by preload(cmd) only for the commands that use them (see that script for how).
|
|
19
|
+
let parseIntent, slug, subjectName, KNOWN_LENSES, previewHumanContract, renderHumanContract, previewPlainContract,
|
|
20
|
+
thunderRepo, renderThunderRepo, parseGitHub, cloneGitHub, thunderizeFiles, THUNDER_TEXT_EXT, sameMeaning,
|
|
21
|
+
renderSame, anchorReport, writeRule, thunderWrite, readCode, searchReading, readRepo, searchRepo,
|
|
22
|
+
groupByFile, promoteDecision, collectReadableFiles, accessFlow, accessText, translateDecisions,
|
|
23
|
+
buildContractGraph, buildArchitectureGraph, buildImplementationPlan, semanticDiagnostics, buildProof,
|
|
24
|
+
sha256, COMPILER_VERSION, toSarif, renderMarkdown, renderLensDoc, renderMermaid, renderTestplan,
|
|
25
|
+
getCompletions, getHover, getCodeActions, autocorrectSource, startLspServer, startMcpServer, formatSource,
|
|
26
|
+
applyEdits, buildReport, scanProject, VIEWS, guardianReport, simulateChange, verifyLedger, ledgerExplain,
|
|
27
|
+
verifyDiff, verifyRun, executedText, mergeTraces, runtimeOverlay, runtimeText, fromTrace, fromStack,
|
|
28
|
+
fromLogs, fromOtlp, parseStacks, explainError, countWords, thunderModel, LEVELS, readLevel, renderLevel,
|
|
29
|
+
findFocus, nearestLevel, traceMain, passportMain, isWriteAcross, writeAcrossMain, whyMain, tryMain,
|
|
30
|
+
replayMain, homeText, helpFor, knownCommands, unknownCommandText, noProjectText, doctorMain,
|
|
31
|
+
completionMain, paint, paintHelp, paintThunder, useColor, coreMain, behaviourCheck, findProjectRoot,
|
|
32
|
+
pythonToCore, guardSummary, draftIntent, liftSource, liftAll, liftRepo, languageForFile, approveIntent,
|
|
33
|
+
checkDrift, buildDriftHandoff, buildMissionIndex, parseSelection, regionMetrics, selectCandidate,
|
|
34
|
+
buildIntentGraph, safeGraph, buildAtlas, searchAtlas, expandNode, buildReviewAtlas, renderReviewBrief,
|
|
35
|
+
reviewAtlasExitCode, buildFocusGraph, intentBrief, makeScope, comprehensionLevel, comprehensionReport,
|
|
36
|
+
COMPREHENSION_LEVELS, twelveFactorReport, GENERATORS, generateWithDiagnostics, changeReport, diffGraphs,
|
|
37
|
+
mergeGraphs, applyWaivers, governanceDiagnostics, exportIntent, EXPORT_FORMATS, evaluateDecision,
|
|
38
|
+
simulateLifecycle, runProperties, runMutations, thunderReview, renderReview, addServiceCallers,
|
|
39
|
+
buildTrace, traceImpact, readRepoDir, gitChanges, coreChanges, affectedBy, renderAffected,
|
|
40
|
+
withCoreBehaviour, coreFilesIn, buildConformance, semanticCoverage, runTypescriptTarget, runPythonTarget,
|
|
41
|
+
pythonAvailable, runCSharpTarget, csharpAvailable, runJavaTarget, javaAvailable, runGoTarget, goAvailable,
|
|
42
|
+
runRustTarget, rustAvailable, runKotlinTarget, kotlinAvailable, runScalaTarget, scalaAvailable,
|
|
43
|
+
runElixirTarget, elixirAvailable, errorResult, runFailure, byText, importIntent, importReport,
|
|
44
|
+
detectFormat, IMPORT_FORMATS, runTests, resolveObligations, toEvidenceEvents, verifyDiffToEvidence,
|
|
45
|
+
conformToEvidence, driftToEvidence, behaviourToEvidence, evaluateOutcomes, analyzeStyle,
|
|
46
|
+
intentProofJsonSchema, validateProof, graphToSource, migrateGraph, validateGraph, SCHEMA_VERSION,
|
|
47
|
+
NODE_TYPES, RELATIONSHIP_TYPES, DIAGNOSTIC_RULES, ALL_DIAGNOSTICS, intentGraphJsonSchema, CLASSIFICATIONS,
|
|
48
|
+
buildManifest, buildImplementationPrompt, resolveState, productionGate, adoptRegion, parseMarkers,
|
|
49
|
+
contractHash, implementationHash, recordDecision, approvalFor, emptyApprovals, makeEvent, parseEventLog,
|
|
50
|
+
serializeEventLog, recordEvent, timeline;
|
|
51
|
+
const LAZY = {
|
|
52
|
+
'./parse.mjs': (m) => ({ parseIntent, slug, subjectName, KNOWN_LENSES } = m),
|
|
53
|
+
'./human-contract.mjs': (m) => ({ previewHumanContract, renderHumanContract } = m),
|
|
54
|
+
'./plain-contract.mjs': (m) => ({ previewPlainContract } = m),
|
|
55
|
+
'./thunder-repo.mjs': (m) => ({ thunderRepo, renderThunderRepo, parseGitHub, cloneGitHub } = m),
|
|
56
|
+
'./thunderize.mjs': (m) => ({ thunderizeFiles, THUNDER_TEXT_EXT } = m),
|
|
57
|
+
'./same.mjs': (m) => ({ sameMeaning, renderSame } = m),
|
|
58
|
+
'./anchor.mjs': (m) => ({ anchorReport } = m),
|
|
59
|
+
'./write.mjs': (m) => ({ writeRule } = m),
|
|
60
|
+
'./write-steps.mjs': (m) => ({ thunderWrite } = m),
|
|
61
|
+
'./read.mjs': (m) => ({ readCode, searchReading } = m),
|
|
62
|
+
'./read-repo.mjs': (m) => ({ readRepo, searchRepo, groupByFile } = m),
|
|
63
|
+
'./promote.mjs': (m) => ({ promoteDecision } = m),
|
|
64
|
+
'./read-repo-fs.mjs': (m) => ({ collectReadableFiles } = m),
|
|
65
|
+
'./flow/access.mjs': (m) => ({ accessFlow, accessText } = m),
|
|
66
|
+
'./translate.mjs': (m) => ({ translateDecisions } = m),
|
|
67
|
+
'./emit.mjs': (m) => ({ buildContractGraph, buildArchitectureGraph, buildImplementationPlan, semanticDiagnostics, buildProof, sha256, COMPILER_VERSION } = m),
|
|
68
|
+
'./sarif.mjs': (m) => ({ toSarif } = m),
|
|
69
|
+
'./compile.mjs': (m) => ({ renderMarkdown, renderLensDoc, renderMermaid, renderTestplan } = m),
|
|
70
|
+
'./intellisense.mjs': (m) => ({ getCompletions, getHover, getCodeActions, autocorrectSource } = m),
|
|
71
|
+
'./lsp.mjs': (m) => ({ startLspServer } = m),
|
|
72
|
+
'./mcp.mjs': (m) => ({ startMcpServer } = m),
|
|
73
|
+
'./format.mjs': (m) => ({ formatSource } = m),
|
|
74
|
+
'./patch.mjs': (m) => ({ applyEdits } = m),
|
|
75
|
+
'./report.mjs': (m) => ({ buildReport } = m),
|
|
76
|
+
'./scan.mjs': (m) => ({ scanProject } = m),
|
|
77
|
+
'./scan-queries.mjs': (m) => ({ VIEWS } = m),
|
|
78
|
+
'./guardian.mjs': (m) => ({ guardianReport } = m),
|
|
79
|
+
'./simulate.mjs': (m) => ({ simulateChange } = m),
|
|
80
|
+
'./ledger.mjs': (m) => ({ verifyLedger, explain: ledgerExplain } = m),
|
|
81
|
+
'./verify-diff.mjs': (m) => ({ verifyDiff } = m),
|
|
82
|
+
'./executed.mjs': (m) => ({ verifyRun, executedText, mergeTraces } = m),
|
|
83
|
+
'./running.mjs': (m) => ({ runtimeOverlay, runtimeText, fromTrace, fromStack, fromLogs, fromOtlp, parseStacks, explainError, countWords } = m),
|
|
84
|
+
'./model.mjs': (m) => ({ thunderModel } = m),
|
|
85
|
+
'./read-level.mjs': (m) => ({ LEVELS, readLevel, renderLevel, findFocus, nearestLevel } = m),
|
|
86
|
+
'./trace-cli.mjs': (m) => ({ traceMain } = m),
|
|
87
|
+
'./passport-cli.mjs': (m) => ({ passportMain } = m),
|
|
88
|
+
'./write-across-cli.mjs': (m) => ({ isWriteAcross, writeAcrossMain } = m),
|
|
89
|
+
'./why-cli.mjs': (m) => ({ whyMain } = m),
|
|
90
|
+
'./try-cli.mjs': (m) => ({ tryMain } = m),
|
|
91
|
+
'./replay-cli.mjs': (m) => ({ replayMain } = m),
|
|
92
|
+
'./cli-home.mjs': (m) => ({ homeText, helpFor, knownCommands, unknownCommandText, noProjectText, doctorMain, completionMain } = m),
|
|
93
|
+
'./term.mjs': (m) => ({ paint, paintHelp, paintThunder, useColor } = m),
|
|
94
|
+
'./core/cli.mjs': (m) => ({ coreMain } = m),
|
|
95
|
+
'./behaviour.mjs': (m) => ({ behaviourCheck } = m),
|
|
96
|
+
'./core/project-root.mjs': (m) => ({ findProjectRoot } = m),
|
|
97
|
+
'./core/from-python.mjs': (m) => ({ pythonToCore } = m),
|
|
98
|
+
'./guard.mjs': (m) => ({ guardSummary } = m),
|
|
99
|
+
'./draft.mjs': (m) => ({ draftIntent } = m),
|
|
100
|
+
'./lift.mjs': (m) => ({ liftSource, liftAll, liftRepo, languageForFile } = m),
|
|
101
|
+
'./drift.mjs': (m) => ({ approveIntent, checkDrift, buildDriftHandoff } = m),
|
|
102
|
+
'./atlas.mjs': (m) => ({ buildMissionIndex } = m),
|
|
103
|
+
'./select.mjs': (m) => ({ parseSelection, regionMetrics, selectCandidate } = m),
|
|
104
|
+
'./intent-graph.mjs': (m) => ({ buildIntentGraph, safeGraph } = m),
|
|
105
|
+
'./intent-atlas.mjs': (m) => ({ buildAtlas, searchAtlas, expandNode } = m),
|
|
106
|
+
'./review-atlas.mjs': (m) => ({ buildReviewAtlas, renderReviewBrief, reviewAtlasExitCode } = m),
|
|
107
|
+
'./focus.mjs': (m) => ({ buildFocusGraph, intentBrief, makeScope } = m),
|
|
108
|
+
'./comprehension.mjs': (m) => ({ comprehensionLevel, comprehensionReport, LEVELS: COMPREHENSION_LEVELS } = m),
|
|
109
|
+
'./twelve-factor.mjs': (m) => ({ twelveFactorReport } = m),
|
|
110
|
+
'./codegen.mjs': (m) => ({ GENERATORS, generateWithDiagnostics } = m),
|
|
111
|
+
'./changes.mjs': (m) => ({ changeReport } = m),
|
|
112
|
+
'./semantic-diff.mjs': (m) => ({ diffGraphs, mergeGraphs } = m),
|
|
113
|
+
'./governance.mjs': (m) => ({ applyWaivers, governanceDiagnostics } = m),
|
|
114
|
+
'./exporters.mjs': (m) => ({ exportIntent, EXPORT_FORMATS } = m),
|
|
115
|
+
'./runtime.mjs': (m) => ({ evaluateDecision, simulateLifecycle } = m),
|
|
116
|
+
'./property.mjs': (m) => ({ runProperties } = m),
|
|
117
|
+
'./mutate.mjs': (m) => ({ runMutations } = m),
|
|
118
|
+
'./review.mjs': (m) => ({ thunderReview, renderReview, addServiceCallers } = m),
|
|
119
|
+
'./trace.mjs': (m) => ({ buildTrace, traceImpact } = m),
|
|
120
|
+
'./trace-fs.mjs': (m) => ({ readRepoDir, gitChanges } = m),
|
|
121
|
+
'./core-changes.mjs': (m) => ({ coreChanges, affectedBy, renderAffected, withCoreBehaviour } = m),
|
|
122
|
+
'./core-changes-fs.mjs': (m) => ({ coreFilesIn } = m),
|
|
123
|
+
'./conformance.mjs': (m) => ({ buildConformance } = m),
|
|
124
|
+
'./coverage.mjs': (m) => ({ semanticCoverage } = m),
|
|
125
|
+
'./target-ts.mjs': (m) => ({ runTypescriptTarget } = m),
|
|
126
|
+
'./target-py.mjs': (m) => ({ runPythonTarget, pythonAvailable } = m),
|
|
127
|
+
'./target-cs.mjs': (m) => ({ runCSharpTarget, csharpAvailable } = m),
|
|
128
|
+
'./target-java.mjs': (m) => ({ runJavaTarget, javaAvailable } = m),
|
|
129
|
+
'./target-go.mjs': (m) => ({ runGoTarget, goAvailable } = m),
|
|
130
|
+
'./target-rust.mjs': (m) => ({ runRustTarget, rustAvailable } = m),
|
|
131
|
+
'./target-kotlin.mjs': (m) => ({ runKotlinTarget, kotlinAvailable } = m),
|
|
132
|
+
'./target-scala.mjs': (m) => ({ runScalaTarget, scalaAvailable } = m),
|
|
133
|
+
'./target-elixir.mjs': (m) => ({ runElixirTarget, elixirAvailable } = m),
|
|
134
|
+
'./target-result.mjs': (m) => ({ errorResult, runFailure } = m),
|
|
135
|
+
'./text-order.mjs': (m) => ({ byText } = m),
|
|
136
|
+
'./importers.mjs': (m) => ({ importIntent, importReport, detectFormat, IMPORT_FORMATS } = m),
|
|
137
|
+
'./testing.mjs': (m) => ({ runTests } = m),
|
|
138
|
+
'./obligations.mjs': (m) => ({ resolveObligations } = m),
|
|
139
|
+
'./evidence.mjs': (m) => ({ toEvidenceEvents, verifyDiffToEvidence, conformToEvidence, driftToEvidence, behaviourToEvidence } = m),
|
|
140
|
+
'./outcome.mjs': (m) => ({ evaluateOutcomes } = m),
|
|
141
|
+
'./style.mjs': (m) => ({ analyzeStyle } = m),
|
|
142
|
+
'./proof-schema.mjs': (m) => ({ intentProofJsonSchema, validateProof } = m),
|
|
143
|
+
'./graph-source.mjs': (m) => ({ graphToSource } = m),
|
|
144
|
+
'./migrate.mjs': (m) => ({ migrateGraph, validateGraph } = m),
|
|
145
|
+
'./intent-schema.mjs': (m) => ({ SCHEMA_VERSION, NODE_TYPES, RELATIONSHIP_TYPES, DIAGNOSTIC_RULES, ALL_DIAGNOSTICS, intentGraphJsonSchema } = m),
|
|
146
|
+
'./classification.mjs': (m) => ({ CLASSIFICATIONS } = m),
|
|
147
|
+
'./ai.mjs': (m) => ({ buildManifest, buildImplementationPrompt, resolveState, productionGate, adoptRegion, parseMarkers, contractHash, implementationHash, recordDecision, approvalFor, emptyApprovals, makeEvent } = m),
|
|
148
|
+
'./ai-events.mjs': (m) => ({ parseEventLog, serializeEventLog, recordEvent, timeline } = m),
|
|
149
|
+
};
|
|
150
|
+
// The modules each command can reach. A command that is not listed loads them all.
|
|
151
|
+
const COMMAND_MODULES = {
|
|
152
|
+
"": [15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
153
|
+
"--help": [15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
154
|
+
"--version": [15, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
155
|
+
"-h": [15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
156
|
+
"-v": [15, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
157
|
+
"12factor": [0, 25, 40, 41, 44, 57, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
158
|
+
"affected": [25, 40, 41, 44, 69, 70, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
159
|
+
"ai": [0, 25, 40, 41, 44, 48, 51, 73, 74, 75, 76, 77, 78, 79, 80, 81, 95, 96],
|
|
160
|
+
"anchor": [6, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
161
|
+
"apply-fix": [0, 15, 18, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
162
|
+
"approve": [25, 40, 41, 44, 49, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
163
|
+
"atlas": [0, 25, 40, 41, 44, 52, 53, 54, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
164
|
+
"build": [0, 15, 17, 24, 25, 40, 41, 42, 44, 52, 73, 74, 75, 76, 77, 78, 79, 80, 81, 95],
|
|
165
|
+
"changes": [0, 25, 40, 41, 44, 52, 59, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
166
|
+
"check": [0, 15, 16, 24, 25, 40, 41, 42, 44, 61, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
167
|
+
"code-actions": [0, 15, 18, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
168
|
+
"completion": [25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
169
|
+
"completions": [0, 15, 18, 24, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
170
|
+
"comprehension": [0, 25, 40, 41, 44, 56, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
171
|
+
"conform": [0, 15, 25, 40, 41, 44, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 87],
|
|
172
|
+
"diff": [0, 25, 40, 41, 44, 52, 53, 60, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
173
|
+
"docs": [0, 17, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
174
|
+
"doctor": [15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
175
|
+
"draft": [25, 40, 41, 44, 47, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
176
|
+
"drift": [0, 15, 25, 40, 41, 44, 48, 49, 73, 74, 75, 76, 77, 78, 79, 80, 81, 87],
|
|
177
|
+
"edit": [22, 24, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
178
|
+
"evidence": [0, 15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 86, 87],
|
|
179
|
+
"explain": [25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 93],
|
|
180
|
+
"export": [0, 25, 40, 41, 44, 62, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
181
|
+
"fmt": [21, 24, 25, 40, 41, 42, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
182
|
+
"focus": [0, 25, 40, 41, 44, 52, 53, 55, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
183
|
+
"format": [0, 15, 24, 25, 40, 41, 42, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
184
|
+
"gen": [0, 25, 40, 41, 44, 58, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
185
|
+
"graph": [0, 15, 24, 25, 40, 41, 44, 52, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
186
|
+
"guard": [0, 25, 40, 41, 44, 46, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
187
|
+
"guardian": [25, 26, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
188
|
+
"handoff": [0, 25, 40, 41, 44, 49, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
189
|
+
"help": [15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
190
|
+
"hover": [0, 15, 18, 24, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
191
|
+
"human": [1, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
192
|
+
"impact": [25, 27, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
193
|
+
"import": [0, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 84],
|
|
194
|
+
"index": [25, 40, 41, 44, 50, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
195
|
+
"init": [25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
196
|
+
"ledger": [25, 28, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
197
|
+
"lift": [0, 25, 40, 41, 44, 48, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
198
|
+
"lsp": [19, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
199
|
+
"mcp": [20, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
200
|
+
"merge": [0, 25, 40, 41, 44, 52, 53, 60, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
201
|
+
"migrate": [0, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 92],
|
|
202
|
+
"mission": [0, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83],
|
|
203
|
+
"new": [25, 40, 41, 42, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
204
|
+
"notes": [0, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
205
|
+
"outcomes": [0, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 88],
|
|
206
|
+
"passport": [25, 35, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
207
|
+
"plain": [2, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
208
|
+
"proof": [0, 15, 24, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 90],
|
|
209
|
+
"prove": [0, 15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 86],
|
|
210
|
+
"read": [0, 1, 9, 10, 11, 12, 13, 14, 25, 32, 33, 40, 41, 44, 45, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
211
|
+
"replay": [25, 39, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
212
|
+
"repo": [3, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
213
|
+
"report": [23, 24, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
214
|
+
"review": [15, 25, 40, 41, 44, 66, 67, 68, 69, 73, 74, 75, 76, 77, 78, 79, 80, 81, 87],
|
|
215
|
+
"rules": [25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 93],
|
|
216
|
+
"run": [0, 25, 40, 41, 42, 44, 63, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
217
|
+
"runtime": [12, 25, 30, 31, 32, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
218
|
+
"same": [0, 5, 12, 15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
219
|
+
"scan": [24, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
220
|
+
"schema": [25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 93, 94],
|
|
221
|
+
"simulate": [0, 25, 40, 41, 44, 63, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
222
|
+
"source": [0, 25, 40, 41, 44, 52, 73, 74, 75, 76, 77, 78, 79, 80, 81, 91],
|
|
223
|
+
"style": [0, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 89],
|
|
224
|
+
"test": [0, 25, 40, 41, 42, 44, 64, 65, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 85, 86],
|
|
225
|
+
"text": [2, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
226
|
+
"thunderize": [3, 4, 12, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
227
|
+
"trace": [25, 34, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
228
|
+
"try": [25, 38, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
229
|
+
"twelve-factor": [0, 25, 40, 41, 44, 57, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
230
|
+
"validate": [25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 92],
|
|
231
|
+
"verify": [0, 15, 25, 30, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 90],
|
|
232
|
+
"verify-diff": [0, 15, 25, 29, 40, 41, 44, 48, 73, 74, 75, 76, 77, 78, 79, 80, 81, 87],
|
|
233
|
+
"version": [15, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
234
|
+
"why": [25, 37, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
235
|
+
"write": [7, 8, 25, 36, 40, 41, 43, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
|
|
236
|
+
};
|
|
237
|
+
async function preload(cmd) {
|
|
238
|
+
const specs = Object.keys(LAZY);
|
|
239
|
+
const wanted = COMMAND_MODULES[cmd ?? '']?.map((i) => specs[i]) ?? specs;
|
|
240
|
+
await Promise.all(wanted.map(async (s) => LAZY[s](await import(s))));
|
|
241
|
+
}
|
|
242
|
+
// </lazy-imports>
|
|
100
243
|
|
|
101
244
|
// The live-target registry: one entry per canonical target that can be compiled + executed.
|
|
102
245
|
// `available()` is a (cached) toolchain probe; TypeScript/JS runs in-process so it is always live.
|
|
246
|
+
// Each entry calls through an arrow, so a runner's module loads only for the commands that run targets.
|
|
103
247
|
const LIVE_TARGETS = [
|
|
104
|
-
{ key: 'typescript', run: runTypescriptTarget, available: () => true },
|
|
105
|
-
{ key: 'python', run: runPythonTarget, available: pythonAvailable },
|
|
106
|
-
{ key: 'csharp', run: runCSharpTarget, available: csharpAvailable },
|
|
107
|
-
{ key: 'java', run: runJavaTarget, available: javaAvailable },
|
|
108
|
-
{ key: 'go', run: runGoTarget, available: goAvailable },
|
|
109
|
-
{ key: 'rust', run: runRustTarget, available: rustAvailable },
|
|
110
|
-
{ key: 'kotlin', run: runKotlinTarget, available: kotlinAvailable },
|
|
111
|
-
{ key: 'scala', run: runScalaTarget, available: scalaAvailable },
|
|
112
|
-
{ key: 'elixir', run: runElixirTarget, available: elixirAvailable },
|
|
248
|
+
{ key: 'typescript', run: (ast) => runTypescriptTarget(ast), available: () => true },
|
|
249
|
+
{ key: 'python', run: (ast) => runPythonTarget(ast), available: () => pythonAvailable() },
|
|
250
|
+
{ key: 'csharp', run: (ast) => runCSharpTarget(ast), available: () => csharpAvailable() },
|
|
251
|
+
{ key: 'java', run: (ast) => runJavaTarget(ast), available: () => javaAvailable() },
|
|
252
|
+
{ key: 'go', run: (ast) => runGoTarget(ast), available: () => goAvailable() },
|
|
253
|
+
{ key: 'rust', run: (ast) => runRustTarget(ast), available: () => rustAvailable() },
|
|
254
|
+
{ key: 'kotlin', run: (ast) => runKotlinTarget(ast), available: () => kotlinAvailable() },
|
|
255
|
+
{ key: 'scala', run: (ast) => runScalaTarget(ast), available: () => scalaAvailable() },
|
|
256
|
+
{ key: 'elixir', run: (ast) => runElixirTarget(ast), available: () => elixirAvailable() },
|
|
113
257
|
];
|
|
114
258
|
const LIVE_BY_KEY = new Map(LIVE_TARGETS.map((t) => [t.key, t]));
|
|
115
259
|
LIVE_BY_KEY.set('javascript', LIVE_BY_KEY.get('typescript')); // js is the same in-process runner
|
|
@@ -161,22 +305,6 @@ function caseResultsOf(ast, run) {
|
|
|
161
305
|
const caseLine = (c) => (c.status === 'error'
|
|
162
306
|
? `ERROR ${c.key} , ${c.kind === 'not-translated' ? 'not translated' : c.kind === 'missing-input' ? 'missing input' : c.kind}: ${c.message}`
|
|
163
307
|
: `FAIL ${c.key} , expected ${c.expected}, got ${c.actual === null ? 'null' : c.actual}`);
|
|
164
|
-
import { importIntent, importReport, detectFormat, IMPORT_FORMATS } from './importers.mjs';
|
|
165
|
-
import { runTests } from './testing.mjs';
|
|
166
|
-
import { resolveObligations } from './obligations.mjs';
|
|
167
|
-
import { toEvidenceEvents, verifyDiffToEvidence, conformToEvidence, driftToEvidence } from './evidence.mjs';
|
|
168
|
-
import { evaluateOutcomes } from './outcome.mjs';
|
|
169
|
-
import { analyzeStyle } from './style.mjs';
|
|
170
|
-
import { intentProofJsonSchema, validateProof } from './proof-schema.mjs';
|
|
171
|
-
import { graphToSource } from './graph-source.mjs';
|
|
172
|
-
import { migrateGraph, validateGraph } from './migrate.mjs';
|
|
173
|
-
import { SCHEMA_VERSION, NODE_TYPES, RELATIONSHIP_TYPES, DIAGNOSTIC_RULES, ALL_DIAGNOSTICS, intentGraphJsonSchema } from './intent-schema.mjs';
|
|
174
|
-
import { CLASSIFICATIONS } from './classification.mjs';
|
|
175
|
-
import {
|
|
176
|
-
buildManifest, buildImplementationPrompt, resolveState, productionGate, adoptRegion, parseMarkers,
|
|
177
|
-
contractHash, implementationHash, recordDecision, approvalFor, emptyApprovals, makeEvent,
|
|
178
|
-
} from './ai.mjs';
|
|
179
|
-
import { parseEventLog, serializeEventLog, recordEvent, timeline } from './ai-events.mjs';
|
|
180
308
|
|
|
181
309
|
// Recursively collect supported source files, skipping vendored / build dirs.
|
|
182
310
|
// Kept in sync with lift.mjs languageForFile(): every language the lift adapters support,
|
|
@@ -254,7 +382,8 @@ function collectIntents(root, acc = []) {
|
|
|
254
382
|
// compiler, environment) tuple. These helpers capture that tuple so `verify` can mark a proof STALE.
|
|
255
383
|
/**
|
|
256
384
|
* Read the files that changed between two commits (or a commit and the working tree, when head is null) and review
|
|
257
|
-
* them in Thunder. Only git is run (show, diff, ls-files)
|
|
385
|
+
* them in Thunder. Only git is run (show, diff, ls-files, ls-tree) and nothing is fetched. Thunder Core programs are run
|
|
386
|
+
* on the Thunder engine inside the review (no files, network, or saved data; step and time limits) to compare answers.
|
|
258
387
|
*/
|
|
259
388
|
function reviewGit(base, head, paths = []) {
|
|
260
389
|
const git = (...a) => execFileSync('git', a, { encoding: 'utf8', maxBuffer: 256 * 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
@@ -283,7 +412,45 @@ function reviewGit(base, head, paths = []) {
|
|
|
283
412
|
if (c.old) { const s = at(base, c.old); if (s != null) oldFiles.push({ path: c.old, source: s }); }
|
|
284
413
|
if (c.new) { const s = head ? at(head, c.new) : disk(c.new); if (s != null) newFiles.push({ path: c.new, source: s }); }
|
|
285
414
|
}
|
|
286
|
-
|
|
415
|
+
// A changed Thunder Core program is compared with the rest of its project (the folder above src/ or tests/, or its
|
|
416
|
+
// own folder): its tests are run before and after, and what uses a change is listed.
|
|
417
|
+
const context = { old: [], new: [] };
|
|
418
|
+
const changed = new Set(changes.flatMap((c) => [c.old, c.new]).filter(Boolean));
|
|
419
|
+
const roots = new Set(changes.flatMap((c) => [c.old, c.new]).filter((p) => p && p.endsWith('.thunder')).map((p) => {
|
|
420
|
+
const m = /(^|\/)(src|tests)\//.exec(p);
|
|
421
|
+
return m ? p.slice(0, m.index + m[1].length) : p.includes('/') ? p.slice(0, p.lastIndexOf('/') + 1) : '';
|
|
422
|
+
}));
|
|
423
|
+
const list = (args) => { try { return git(...args).split('\0').filter((p) => p.endsWith('.thunder')); } catch { return []; } };
|
|
424
|
+
for (const root of roots) {
|
|
425
|
+
const where = root ? [root] : ['.'];
|
|
426
|
+
const before = list(['ls-tree', '-r', '-z', '--name-only', base, '--', ...where]);
|
|
427
|
+
const after = head ? list(['ls-tree', '-r', '-z', '--name-only', head, '--', ...where]) : list(['ls-files', '-z', '--cached', '--others', '--exclude-standard', '--', ...where]);
|
|
428
|
+
for (const p of before.filter((x) => !changed.has(x)).slice(0, 300)) { const s = at(base, p); if (s != null) context.old.push({ path: p, source: s }); }
|
|
429
|
+
for (const p of after.filter((x) => !changed.has(x)).slice(0, 300)) { const s = head ? at(head, p) : disk(p); if (s != null) context.new.push({ path: p, source: s }); }
|
|
430
|
+
}
|
|
431
|
+
const review = Object.assign(thunderReview(oldFiles, newFiles, { core: coreChanges, context }), { base, head: head ?? 'working tree' });
|
|
432
|
+
Object.defineProperty(review, 'root', { value: root, enumerable: false }); // for --services; not in the JSON
|
|
433
|
+
return review;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* thunder review --services <folder,…>: the other services are read and linked with Thunder Trace, and each changed
|
|
438
|
+
* endpoint (or a Thunder Core endpoint whose rules changed) that one of them calls becomes an item naming the callers.
|
|
439
|
+
* Trace reads the folders as they are on disk, so the new side must be the working tree (or the commit checked out).
|
|
440
|
+
*/
|
|
441
|
+
function withServices(review, base, head, folders) {
|
|
442
|
+
if (head) {
|
|
443
|
+
const at = (ref) => execFileSync('git', ['rev-parse', `${ref}^{commit}`], { encoding: 'utf8' }).trim();
|
|
444
|
+
if (at(head) !== at('HEAD')) throw new Error(`--services reads the folders as they are on disk, so check out ${head} first (or leave out the head to review the working tree).`);
|
|
445
|
+
}
|
|
446
|
+
const self = readRepoDir(review.root);
|
|
447
|
+
const others = folders.map((d) => readRepoDir(d));
|
|
448
|
+
if (others.some((o) => o.root === self.root)) throw new Error('--services lists other services; this repository is already the one reviewed.');
|
|
449
|
+
const trace = buildTrace([self, ...others]);
|
|
450
|
+
const g = gitChanges(self, base);
|
|
451
|
+
const impact = withCoreBehaviour(traceImpact(trace, g.changes ?? []), new Map(review.core ? [[self.name, review.core]] : []));
|
|
452
|
+
addServiceCallers(review, impact);
|
|
453
|
+
review.services = { repos: [self, ...others].map((x) => x.name), links: trace.links.length, findings: impact.findings.length };
|
|
287
454
|
}
|
|
288
455
|
|
|
289
456
|
const gitCmd = (c) => { try { return execSync(`git ${c}`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] }).trim() || null; } catch { return null; } };
|
|
@@ -359,6 +526,7 @@ function parseArgs(argv) {
|
|
|
359
526
|
else if (a === '--base') args.base = argv[++i];
|
|
360
527
|
else if (a === '--head') args.head = argv[++i];
|
|
361
528
|
else if (a === '--paths') args.paths = (argv[++i] || '').split(/[,\n]/).map((p) => p.trim()).filter(Boolean);
|
|
529
|
+
else if (a === '--services') args.services = (argv[++i] || '').split(/[,\n]/).map((p) => p.trim()).filter(Boolean);
|
|
362
530
|
else if (a === '--inputs') args.inputs = argv[++i];
|
|
363
531
|
else if (a === '--events') args.events = (argv[++i] || '').split(',').map((s) => s.trim()).filter(Boolean);
|
|
364
532
|
else if (a === '--decision') args.decision = argv[++i];
|
|
@@ -504,9 +672,16 @@ Read and understand code
|
|
|
504
672
|
try <file> [--focus "<rule>"] [--with "name=value, …"] [--json] try a rule from your code with your own values: the answer and why (rules only; nothing changes)
|
|
505
673
|
why <run.json> [--step n] [--json] what an AI agent did and why it stopped, in plain words, from its OpenTelemetry record
|
|
506
674
|
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)
|
|
507
|
-
review <base-ref> [head-ref] [--format markdown|json] [--paths <glob,...>] [--out <file>]
|
|
675
|
+
review <base-ref> [head-ref] [--format markdown|json] [--paths <glob,...>] [--services <folder,...>] [--out <file>]
|
|
508
676
|
review in Thunder: what changed in meaning between two git commits (head: the working tree
|
|
509
|
-
when omitted), as Markdown for a pull request comment; read from git, no network
|
|
677
|
+
when omitted), as Markdown for a pull request comment; read from git, no network.
|
|
678
|
+
Thunder Core programs are compared rule by rule, and run before and after.
|
|
679
|
+
--services: other services' folders; a changed endpoint they call is named, with its callers.
|
|
680
|
+
--evidence: the Thunder Core comparison as evidence-event-v1 (behaviour.compared)
|
|
681
|
+
affected <rule…> [--in <folder|file>] [--json]
|
|
682
|
+
what to look at again when a Thunder Core rule changes ("decide refund", "review limit",
|
|
683
|
+
"POST /orders"): the functions and endpoints that use it, the tests and examples that reach
|
|
684
|
+
it, the Never rules and stored lists they rely on; read only, nothing is run
|
|
510
685
|
trace <folder…> [--json] [--out f] Thunder Trace: routes, events, tables, and packages linked across repositories, cited repo@sha:file:line
|
|
511
686
|
trace impact <thing | --diff [--base ref]> <folder…> what a change can affect in other repositories (one hop, ranked by risk)
|
|
512
687
|
passport <folder…> [--base ref] [--run "part: cmd"…] [--purpose …] an evidence record: behavior, links, effects, evidence with its limits, what is not verified
|
|
@@ -663,8 +838,12 @@ function main() {
|
|
|
663
838
|
if (cmd === 'replay') { replayMain(restArgv).then((code) => { process.exitCode = code; }); return; }
|
|
664
839
|
// Thunder Core (programs you write and run): thunder new <dir>, and run/build/test/check/format inside a
|
|
665
840
|
// project with thunder.toml (or with --core). Mission files fall through unchanged. See src/core/cli.mjs.
|
|
666
|
-
|
|
667
|
-
|
|
841
|
+
// (Only Core's own commands can be Core programs: the list is core/cli.mjs CORE_COMMANDS, kept equal by a test, and
|
|
842
|
+
// written out here so other commands don't load Thunder Core at all.)
|
|
843
|
+
if (['new', 'run', 'build', 'test', 'check', 'format', 'fmt'].includes(cmd)) {
|
|
844
|
+
const coreCode = coreMain(cmd, restArgv);
|
|
845
|
+
if (coreCode !== null) { process.exitCode = coreCode; return; }
|
|
846
|
+
}
|
|
668
847
|
if (cmd === 'read') {
|
|
669
848
|
try {
|
|
670
849
|
if (!file) throw new Error('Use thunder read <file> [--search q] [--kind decision,function,error,test] [--in <lang>] [--json].');
|
|
@@ -897,12 +1076,30 @@ function main() {
|
|
|
897
1076
|
if (args.format && !['markdown', 'json'].includes(args.format)) throw new Error(`--format ${args.format} is not one of markdown, json.`);
|
|
898
1077
|
const json = args.json || args.format === 'json';
|
|
899
1078
|
const r = reviewGit(base, head ?? null, args.paths ?? []);
|
|
1079
|
+
if (args.services) withServices(r, base, head, args.services);
|
|
1080
|
+
if (args.evidence) {
|
|
1081
|
+
// evidence-event-v1 for the shared proof spine: what the Thunder Core comparison found, safe-derived.
|
|
1082
|
+
console.log(JSON.stringify(behaviourToEvidence(r.core ?? { changes: [] }, { compilerVersion: COMPILER_VERSION, occurredAt: new Date().toISOString(), base, head: head ?? 'working tree' }), null, 2));
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
900
1085
|
const text = json ? JSON.stringify(r, null, 2) : renderReview(r, { footer: `<sub>\`thunder review ${base}${head ? ` ${head}` : ''}\` · Thunder compiler ${COMPILER_VERSION}</sub>` }).trimEnd();
|
|
901
1086
|
if (args.outExplicit) { mkdirSync(dirname(resolve(args.out)), { recursive: true }); writeFileSync(args.out, `${text}\n`); console.log(`thunder review: ${r.says} Wrote ${args.out}.`); }
|
|
902
1087
|
else console.log(text);
|
|
903
1088
|
} catch (e) { console.error(`thunder review: ${e.message}`); process.exitCode = 2; }
|
|
904
1089
|
return;
|
|
905
1090
|
}
|
|
1091
|
+
if (cmd === 'affected') {
|
|
1092
|
+
try {
|
|
1093
|
+
if (!args._.length) throw new Error('Use thunder affected <rule…> [--in <folder|file>] [--json], for example: thunder affected "review limit" --in examples/apps/refund-desk');
|
|
1094
|
+
const target = resolve(args.inLang ?? ".");
|
|
1095
|
+
if (!existsSync(target)) throw new Error(`${args.inLang} does not exist.`);
|
|
1096
|
+
const r = affectedBy(coreFilesIn(target), args._);
|
|
1097
|
+
if (args.json) console.log(JSON.stringify(r, null, 2));
|
|
1098
|
+
else console.log(renderAffected(r));
|
|
1099
|
+
process.exitCode = r.of.length ? 0 : 2;
|
|
1100
|
+
} catch (e) { console.error(`thunder affected: ${e.message}`); process.exitCode = 2; }
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
906
1103
|
if (cmd === 'same') {
|
|
907
1104
|
try {
|
|
908
1105
|
const [a, b] = args._;
|
|
@@ -2815,4 +3012,4 @@ function missingFile(e) {
|
|
|
2815
3012
|
return true;
|
|
2816
3013
|
}
|
|
2817
3014
|
process.on('uncaughtException', (e) => { if (!missingFile(e)) { console.error(e); process.exitCode = 1; } });
|
|
2818
|
-
try { main(); } catch (e) { if (!missingFile(e)) throw e; }
|
|
3015
|
+
try { await preload(process.argv[2]); main(); } catch (e) { if (!missingFile(e)) throw e; }
|