@skillstech/thunderlang 1.0.4 → 1.2.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 +221 -0
- package/README.md +4 -1
- package/dist/core.cjs +2568 -462
- package/dist/index.cjs +7562 -5084
- package/dist/learn.cjs +16994 -8339
- package/intent-graph.schema.json +11 -0
- package/package.json +6 -2
- package/src/cli-home.mjs +242 -0
- package/src/cli.mjs +241 -89
- package/src/codegen.mjs +145 -55
- package/src/conformance.mjs +15 -6
- package/src/core/check.mjs +725 -0
- package/src/core/cli.mjs +184 -0
- package/src/core/diagnostics.mjs +82 -0
- package/src/core/engine-core.mjs +572 -0
- package/src/core/engine-values.mjs +1054 -0
- package/src/core/engine-worker.mjs +15 -0
- package/src/core/engine.mjs +63 -0
- package/src/core/format.mjs +20 -0
- package/src/core/from-python.mjs +645 -0
- package/src/core/index.mjs +39 -0
- package/src/core/lexer.mjs +115 -0
- package/src/core/parser.mjs +742 -0
- package/src/core/project.mjs +177 -0
- package/src/core/round-trip.mjs +150 -0
- package/src/core/runtime-python.mjs +801 -0
- package/src/core/runtime-typescript.mjs +119 -0
- package/src/core/target-python.mjs +487 -0
- package/src/core/target-typescript.mjs +466 -0
- package/src/core/typescript-run.mjs +114 -0
- package/src/core.d.ts +5 -2
- package/src/core.mjs +5 -2
- package/src/data-schema.mjs +8 -1
- package/src/emit.mjs +1 -1
- package/src/evidence.mjs +1 -1
- package/src/expr.mjs +81 -4
- package/src/form-words.mjs +2 -0
- package/src/index.d.ts +8 -1
- package/src/index.mjs +5 -1
- package/src/intent-schema.mjs +1 -0
- package/src/learn-lessons.mjs +245 -1
- package/src/learn.d.mts +8 -0
- package/src/learn.mjs +40 -4
- package/src/mcp.mjs +23 -0
- package/src/meaning.mjs +45 -6
- package/src/model.d.mts +7 -3
- package/src/model.mjs +19 -6
- package/src/money.d.mts +18 -0
- package/src/money.mjs +124 -0
- package/src/plain-contract.mjs +18 -2
- package/src/read-level.mjs +146 -0
- package/src/read.d.mts +11 -0
- package/src/read.mjs +40 -6
- package/src/review-comment.d.mts +16 -0
- package/src/review-comment.mjs +145 -0
- package/src/say-less.mjs +1432 -0
- package/src/system.mjs +153 -44
- package/src/target-cs.mjs +39 -34
- package/src/target-elixir.mjs +40 -30
- package/src/target-go.mjs +41 -36
- package/src/target-java.mjs +34 -27
- package/src/target-kotlin.mjs +43 -35
- package/src/target-py.mjs +57 -55
- package/src/target-result.d.mts +48 -0
- package/src/target-result.mjs +112 -0
- package/src/target-rust.mjs +42 -38
- package/src/target-scala.mjs +45 -35
- package/src/target-ts.mjs +37 -45
- package/src/target-types.mjs +41 -5
- package/src/target-util.mjs +55 -2
- package/src/term.mjs +89 -0
- package/src/trace-cli.mjs +58 -0
- package/src/trace-fs.mjs +76 -0
- package/src/trace.mjs +261 -0
- package/src/translate.d.mts +3 -0
- package/src/translate.mjs +62 -32
- package/src/try-cli.mjs +225 -0
- package/src/why-cli.mjs +41 -0
- package/src/why.d.mts +38 -0
- package/src/why.mjs +613 -0
- package/src/write-steps.mjs +22 -5
package/src/write-steps.mjs
CHANGED
|
@@ -206,6 +206,16 @@ function findMember(state, ref) {
|
|
|
206
206
|
if (!rd) continue;
|
|
207
207
|
for (const { key, item } of memberKeys(rd.reading)) if (item.name === r.name) candidates.push({ path, key, item, language: rd.language, reading: rd.reading, source: f });
|
|
208
208
|
}
|
|
209
|
+
// A model id writes a route handler's name without spaces ("POST/api/orders"): match it ignoring spaces.
|
|
210
|
+
if (!candidates.length && r.name) {
|
|
211
|
+
const bare = String(r.name).replace(/\s+/g, '');
|
|
212
|
+
for (const [path, f] of state.files) {
|
|
213
|
+
if (r.file && path !== r.file && !path.endsWith(`/${r.file}`)) continue;
|
|
214
|
+
const rd = state.read(path);
|
|
215
|
+
if (!rd) continue;
|
|
216
|
+
for (const { key, item } of memberKeys(rd.reading)) if (String(item.name).replace(/\s+/g, '') === bare) candidates.push({ path, key, item, language: rd.language, reading: rd.reading, source: f });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
209
219
|
if (!candidates.length) refuse(`No function named ${r.name}${r.file ? ` in ${r.file}` : ''} was found.`);
|
|
210
220
|
if (r.line == null && candidates.length > 1) refuse(`${r.name} is in more than one place (${candidates.map((c) => `${c.path}:${c.item.line}`).join(', ')}); say which with its id or line.`);
|
|
211
221
|
return candidates.reduce((best, c) => (r.line == null || Math.abs(c.item.line - r.line) < Math.abs(best.item.line - r.line) ? c : best));
|
|
@@ -1247,17 +1257,24 @@ function applyEdit(state, edit) {
|
|
|
1247
1257
|
return {
|
|
1248
1258
|
files,
|
|
1249
1259
|
plan: { member: { path: m.path, key: m.key, name: m.item.name, shape: ctx.shape, inputs: ctx.expectInputs ?? null, returns: ctx.expectReturns ?? null } },
|
|
1250
|
-
says: reworded(says, ctx.treeEdits, { path: m.path, source, language: m.language }),
|
|
1260
|
+
says: reworded(says, ctx.treeEdits, { path: m.path, source, language: m.language }, m.item),
|
|
1251
1261
|
};
|
|
1252
1262
|
}
|
|
1253
|
-
/** "…; it now reads "If days_since is more than 10"":
|
|
1254
|
-
function
|
|
1263
|
+
/** "…; it now reads "If days_since is more than 10"": each edited step's new Thunder words, once, read from the new
|
|
1264
|
+
* code. Only the edited function is looked at, and on a line holding several steps only the step of the same kind. */
|
|
1265
|
+
function reworded(says, treeEdits, f, member) {
|
|
1255
1266
|
if (!treeEdits.length) return says;
|
|
1256
1267
|
let reading;
|
|
1257
1268
|
try { reading = readFile(f).reading; } catch { return says; }
|
|
1269
|
+
const items = membersOf(reading).filter((it) => !member || it.name === member.name);
|
|
1270
|
+
const mine = member && items.length > 1 ? [items.reduce((b, it) => (Math.abs(it.line - member.line) < Math.abs(b.line - member.line) ? it : b))] : items;
|
|
1258
1271
|
const now = [];
|
|
1259
|
-
|
|
1260
|
-
|
|
1272
|
+
for (const t of treeEdits) {
|
|
1273
|
+
let hit = null;
|
|
1274
|
+
const walk = (list) => (list || []).forEach((s) => { if (hit) return; if (s.line === t.step.line && (!t.step.kind || s.kind === t.step.kind)) { hit = s; return; } walk(s.children); walk(s.otherwise); });
|
|
1275
|
+
for (const it of mine) walk(it.steps);
|
|
1276
|
+
if (hit?.says && hit.says !== t.step.says && !now.includes(hit.says)) now.push(hit.says);
|
|
1277
|
+
}
|
|
1261
1278
|
return now.length ? `${says}; it now reads ${now.map((x) => `"${x}"`).join(', ')}` : says;
|
|
1262
1279
|
}
|
|
1263
1280
|
function stepPathOf(steps, step) {
|