@skillstech/thunderlang 1.1.0 → 1.3.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 +212 -0
- package/README.md +4 -1
- package/dist/core.cjs +2080 -278
- package/dist/index.cjs +12742 -10943
- package/dist/learn.cjs +12976 -3598
- package/package.json +2 -2
- package/src/cli-home.mjs +242 -0
- package/src/cli.mjs +135 -41
- package/src/core/ThunderRuntime.cs +1367 -0
- package/src/core/check.mjs +158 -2
- package/src/core/cli.mjs +208 -17
- package/src/core/csharp-run.mjs +184 -0
- package/src/core/diagnostics.mjs +13 -0
- package/src/core/engine-core.mjs +855 -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 +191 -3
- package/src/core/go-run.mjs +106 -0
- package/src/core/index.mjs +3 -1
- package/src/core/java/thunder/T.java +6 -0
- package/src/core/java/thunder/ThunderRuntime.java +1374 -0
- package/src/core/java-run.mjs +89 -0
- package/src/core/parser.mjs +331 -5
- package/src/core/project.mjs +43 -8
- package/src/core/react-run.mjs +96 -0
- package/src/core/runtime-go/thunder_runtime.go +3038 -0
- package/src/core/runtime-react.mjs +133 -0
- package/src/core/runtime-typescript.mjs +119 -0
- package/src/core/rust/thunder_runtime.rs +1645 -0
- package/src/core/rust-run.mjs +192 -0
- package/src/core/screen-values.mjs +30 -0
- package/src/core/target-csharp.mjs +484 -0
- package/src/core/target-go.mjs +555 -0
- package/src/core/target-java.mjs +587 -0
- package/src/core/target-python.mjs +2 -1
- package/src/core/target-react.mjs +270 -0
- package/src/core/target-rust.mjs +534 -0
- package/src/core/target-typescript.mjs +466 -0
- package/src/core/typescript-run.mjs +114 -0
- package/src/core.d.ts +18 -0
- package/src/core.mjs +1 -0
- package/src/emit.mjs +1 -1
- package/src/faithful.mjs +30 -0
- package/src/learn-lessons.mjs +245 -1
- package/src/learn.d.mts +8 -0
- package/src/learn.mjs +40 -4
- package/src/libraries.mjs +10 -3
- package/src/model.mjs +50 -8
- package/src/read-level.mjs +192 -0
- package/src/read-repo-fs.mjs +3 -1
- package/src/read.mjs +28 -5
- package/src/replay-cli.mjs +123 -0
- package/src/say-less.mjs +152 -11
- package/src/screens.mjs +833 -0
- package/src/steps.mjs +430 -19
- package/src/term.mjs +132 -0
- package/src/try-cli.mjs +225 -0
- package/src/why-cli.mjs +17 -7
- package/src/why.d.mts +17 -7
- package/src/why.mjs +114 -33
package/src/why.mjs
CHANGED
|
@@ -142,38 +142,64 @@ function messagesOf(a, which) {
|
|
|
142
142
|
return out;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
// ── What a step does to the world ─────────────────────────────────────────────────────────────────────────────
|
|
146
|
+
// Kinds, most serious first. A step's effect comes from the strongest evidence the record has:
|
|
147
|
+
// declared the tool says so (MCP annotations from --tools, or a thunder.effect attribute on the span)
|
|
148
|
+
// method the HTTP request method operation the database operation
|
|
149
|
+
// name the tool's name: every word counts, and the most serious one wins (get_and_delete deletes)
|
|
150
|
+
export const EFFECT_KINDS = ['money', 'delete', 'send', 'create', 'change', 'read'];
|
|
151
|
+
const VERBS = {
|
|
152
|
+
money: 'charge pay payment refund transfer payout withdraw deposit purchase buy checkout bill',
|
|
153
|
+
delete: 'delete remove drop purge destroy erase truncate wipe unlink rm del',
|
|
154
|
+
send: 'send email mail notify message sms text tweet reply publish broadcast page post dm alert',
|
|
155
|
+
create: 'create add insert new make book reserve schedule upload register submit open issue generate',
|
|
156
|
+
change: 'update set edit modify change write save store cancel approve reject close assign grant revoke rename move archive restore reset deploy merge push apply patch enable disable mark replace upsert',
|
|
157
|
+
read: 'get list search find lookup look fetch read query retrieve check view show describe count load browse inspect peek verify validate calculate compute estimate summarize download scan',
|
|
158
|
+
};
|
|
159
|
+
const VERB_KIND = new Map();
|
|
160
|
+
for (const k of [...EFFECT_KINDS].reverse()) for (const v of VERBS[k].split(' ')) VERB_KIND.set(v, k);
|
|
161
|
+
|
|
162
|
+
/** MCP tool annotations (from --tools) as an effect kind, or null when they say nothing. */
|
|
163
|
+
function declaredFromAnnotations(ann) {
|
|
164
|
+
if (!ann || typeof ann !== 'object') return null;
|
|
165
|
+
if (ann.readOnlyHint === true) return 'read';
|
|
166
|
+
if (ann.readOnlyHint === false || ann.destructiveHint != null) return ann.destructiveHint === false ? 'change' : 'delete'; // the MCP default for a tool that writes is "may be destructive"
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
147
169
|
|
|
148
|
-
/**
|
|
149
|
-
function effectOf(s) {
|
|
170
|
+
/** What this step does to the world: { effect, basis, resource }. */
|
|
171
|
+
function effectOf(s, tools) {
|
|
150
172
|
if (s.kind === 'model' || s.kind === 'agent') return { effect: 'none', basis: 'kind' };
|
|
173
|
+
if (s.declared && EFFECT_KINDS.includes(s.declared)) return { effect: s.declared, basis: 'declared' };
|
|
174
|
+
if (s.kind === 'tool') {
|
|
175
|
+
const d = declaredFromAnnotations(tools?.get(s.tool));
|
|
176
|
+
if (d) return { effect: d, basis: 'declared' };
|
|
177
|
+
}
|
|
151
178
|
if (s.kind === 'retrieve') return { effect: 'read', basis: 'kind' };
|
|
152
179
|
if (s.kind === 'http') {
|
|
153
180
|
const m = String(s.method).toUpperCase();
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return { effect: 'unknown', basis: 'method' };
|
|
181
|
+
const kind = { GET: 'read', HEAD: 'read', OPTIONS: 'read', POST: 'change', PUT: 'change', PATCH: 'change', DELETE: 'delete' }[m];
|
|
182
|
+
return { effect: kind ?? 'unknown', basis: 'method' };
|
|
157
183
|
}
|
|
158
184
|
if (s.kind === 'db') {
|
|
159
185
|
const op = String(s.dbOp || '').toUpperCase();
|
|
160
186
|
if (/^(SELECT|FIND|GET|SCAN|QUERY|COUNT|AGGREGATE|SHOW|DESCRIBE|EXPLAIN|MGET|HGET|HGETALL|EXISTS)/.test(op)) return { effect: 'read', basis: 'operation' };
|
|
161
|
-
if (/^(
|
|
187
|
+
if (/^(DELETE|DROP|TRUNCATE|DEL\b|DEL$|HDEL|UNLINK)/.test(op)) return { effect: 'delete', basis: 'operation' };
|
|
188
|
+
if (/^(INSERT|CREATE|LPUSH|RPUSH|SADD|XADD)/.test(op)) return { effect: 'create', basis: 'operation' };
|
|
189
|
+
if (/^(UPDATE|UPSERT|MERGE|REPLACE|ALTER|SET|HSET|PUT|INCR|DECR)/.test(op)) return { effect: 'change', basis: 'operation' };
|
|
162
190
|
return { effect: 'unknown', basis: 'operation' };
|
|
163
191
|
}
|
|
164
192
|
if (s.kind === 'tool') {
|
|
165
193
|
const words = String(s.tool).replace(/([a-z0-9])([A-Z])/g, '$1 $2').toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
return { effect: 'unknown', basis: 'name' };
|
|
194
|
+
const kinds = words.map((w) => VERB_KIND.get(w)).filter(Boolean);
|
|
195
|
+
const worst = EFFECT_KINDS.find((k) => kinds.includes(k));
|
|
196
|
+
return { effect: worst ?? 'unknown', basis: 'name' };
|
|
171
197
|
}
|
|
172
198
|
return { effect: 'unknown', basis: 'kind' };
|
|
173
199
|
}
|
|
174
200
|
|
|
175
201
|
/** A raw span as a step: what kind of thing happened, with the facts the story needs. */
|
|
176
|
-
function stepOf(r) {
|
|
202
|
+
function stepOf(r, tools) {
|
|
177
203
|
const a = r.attrs;
|
|
178
204
|
const op = String(a['gen_ai.operation.name'] ?? '').toLowerCase();
|
|
179
205
|
const oi = String(a['openinference.span.kind'] ?? '').toUpperCase();
|
|
@@ -192,6 +218,7 @@ function stepOf(r) {
|
|
|
192
218
|
durationMs: r.start != null && r.end != null && r.end >= r.start ? (r.end - r.start) / 1e6 : null,
|
|
193
219
|
kind,
|
|
194
220
|
};
|
|
221
|
+
if (a['thunder.effect'] != null) s.declared = String(a['thunder.effect']).toLowerCase();
|
|
195
222
|
if (kind === 'agent') s.agent = a['gen_ai.agent.name'] ?? (r.name.replace(/^invoke_agent\s*/i, '') || r.name);
|
|
196
223
|
if (kind === 'tool') { s.tool = String(tool ?? r.name.replace(/^execute_tool\s*/i, '')); s.args = a['gen_ai.tool.call.arguments'] ?? a['tool.parameters'] ?? a['input.value']; s.result = a['gen_ai.tool.call.result'] ?? a['output.value']; }
|
|
197
224
|
if (kind === 'model') {
|
|
@@ -228,7 +255,7 @@ function stepOf(r) {
|
|
|
228
255
|
};
|
|
229
256
|
}
|
|
230
257
|
if (kind === 'model' && !s.failed && ['length', 'max_tokens', 'content_filter'].includes(String(s.finish))) s.warning = String(s.finish);
|
|
231
|
-
Object.assign(s, effectOf(s));
|
|
258
|
+
Object.assign(s, effectOf(s, tools));
|
|
232
259
|
return s;
|
|
233
260
|
}
|
|
234
261
|
|
|
@@ -300,6 +327,15 @@ function outcome(s) {
|
|
|
300
327
|
if (s.kind === 'model' || s.kind === 'agent') return '';
|
|
301
328
|
return 'it worked';
|
|
302
329
|
}
|
|
330
|
+
/** A step's name, for short lines: "refund_payment", pay.example.com, the database. */
|
|
331
|
+
const nameOf = (s) => s.kind === 'tool' ? `"${s.tool}"` : s.kind === 'http' ? (() => { try { return new URL(s.url).host; } catch { return s.url || s.name; } })() : s.kind === 'db' ? `the database${s.table ? ` (${s.table})` : ''}` : s.kind === 'model' ? 'the AI' : `"${s.name}"`;
|
|
332
|
+
/** One short line for a step that had trouble but carried on, or a problem: "\"search_web\" worked on the second try; …". */
|
|
333
|
+
function shortTrouble(s) {
|
|
334
|
+
const first = (s.tries || []).find((t) => t.failed);
|
|
335
|
+
if (!s.failed && first) return `${nameOf(s)} worked on the ${ordinal(s.tries.length)} try; the first time, ${lower(plainError(first.error).what)}`;
|
|
336
|
+
return `${nameOf(s)}: ${lower(plainError({ ...s.error, finish: s.finish ?? s.warning }).what)}`;
|
|
337
|
+
}
|
|
338
|
+
|
|
303
339
|
const sentence = (s) => {
|
|
304
340
|
const o = outcome(s);
|
|
305
341
|
const tries = s.tries?.length > 1 && !(s.tries || []).every((t, i, xs) => i === xs.length - 1 || t.failed) ? '' : s.tries?.length > 1 && s.failed ? ` (${s.tries.length} tries)` : '';
|
|
@@ -353,7 +389,14 @@ const flatten = (steps, depth = 0, out = []) => { for (const s of steps) { out.p
|
|
|
353
389
|
* Explain one agent run. `input` is the record's text (or parsed JSON). Options: { run } picks a trace id when the
|
|
354
390
|
* record holds several runs (default: the latest).
|
|
355
391
|
*/
|
|
356
|
-
|
|
392
|
+
/** MCP tool definitions (a tools/list result, or an array of tools) as name -> annotations. */
|
|
393
|
+
export function toolAnnotations(input) {
|
|
394
|
+
const v = typeof input === 'string' ? JSON.parse(input) : input;
|
|
395
|
+
const list = Array.isArray(v) ? v : v?.tools ?? v?.result?.tools ?? [];
|
|
396
|
+
return new Map(list.filter((t) => t && t.name).map((t) => [String(t.name), t.annotations ?? null]));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export function explainRun(input, { run, tools = null, allow = null } = {}) {
|
|
357
400
|
const raw = collectSpans(parseInput(input)).filter((r) => r.id);
|
|
358
401
|
if (!raw.length) {
|
|
359
402
|
return { ok: false, why: 'Thunder found no steps in this file. It reads OpenTelemetry traces: an OTLP JSON export, the collector\'s file exporter, or the Python console exporter.' };
|
|
@@ -367,7 +410,7 @@ export function explainRun(input, { run } = {}) {
|
|
|
367
410
|
chosen = runs.find((r) => r.id.startsWith(String(run).toLowerCase()));
|
|
368
411
|
if (!chosen) return { ok: false, why: `No run in this file starts with ${run}. The runs are: ${runs.map((r) => r.id.slice(0, 8)).join(', ')}.` };
|
|
369
412
|
}
|
|
370
|
-
const all = chosen.spans.map(stepOf);
|
|
413
|
+
const all = chosen.spans.map((r) => stepOf(r, tools));
|
|
371
414
|
const t0 = Number.isFinite(chosen.start) ? chosen.start : null;
|
|
372
415
|
const tree = arrange(all);
|
|
373
416
|
const flat = flatten(tree);
|
|
@@ -397,6 +440,7 @@ export function explainRun(input, { run } = {}) {
|
|
|
397
440
|
const parentStep = flat.map((f) => f.step).find((s) => s.id === problemStep.parent && MEANINGFUL.has(s.kind) && s.kind !== 'agent');
|
|
398
441
|
problem = {
|
|
399
442
|
step: problemStep.n,
|
|
443
|
+
short: `${lower(plain.what).replace(/\.$/, '')}${problemStep.kind === 'http' ? ` (${nameOf(problemStep)})` : ''}${parentStep?.kind === 'tool' ? `, while using "${parentStep.tool}"` : problemStep.kind === 'tool' ? `, in ${nameOf(problemStep)}` : ''}${tries > 1 ? `. It tried ${tries} times` : ''}.`,
|
|
400
444
|
inside: parentStep ? { step: parentStep.n, text: parentStep.kind === 'tool' ? `"${parentStep.tool}"` : doing(parentStep) } : null,
|
|
401
445
|
what: `${doing(problemStep)}: ${lower(plain.what)}`.replace(/\.?$/, '.'),
|
|
402
446
|
tries,
|
|
@@ -410,14 +454,19 @@ export function explainRun(input, { run } = {}) {
|
|
|
410
454
|
}
|
|
411
455
|
|
|
412
456
|
const stepById = new Map(flat.map((f) => [f.step.id, f.step]));
|
|
413
|
-
const underChange = (s) => { for (let p = stepById.get(s.parent); p; p = stepById.get(p.parent)) if (p.effect
|
|
414
|
-
|
|
415
|
-
|
|
457
|
+
const underChange = (s) => { for (let p = stepById.get(s.parent); p; p = stepById.get(p.parent)) if ((EFFECT_KINDS.includes(p.effect) && p.effect !== 'read') || p.effect === 'unknown') return true; return false; };
|
|
458
|
+
// Effects: what the run did to the world, outermost step only (a tool's own request is not counted again).
|
|
459
|
+
const effects = flat.map((f) => f.step).filter((s) => EFFECT_KINDS.includes(s.effect) && !underChange(s)).map((s) => ({
|
|
460
|
+
step: s.n, kind: s.effect, basis: s.basis, text: doing(s), name: s.tool ?? (s.kind === 'http' ? `${s.method} ${hostPath(s.url)}` : s.kind === 'db' ? `${s.db} ${s.table ?? ''}`.trim() : s.name),
|
|
461
|
+
worked: !s.failed, tries: s.tries?.length ?? 1,
|
|
416
462
|
}));
|
|
463
|
+
const changes = effects.filter((e) => e.kind !== 'read');
|
|
464
|
+
const allowed = allow ? new Set(allow) : null;
|
|
465
|
+
const notAllowed = allowed ? effects.filter((e) => !allowed.has(e.kind)) : [];
|
|
417
466
|
const unknown = flat.map((f) => f.step).filter((s) => s.effect === 'unknown' && !underChange(s)).map((s) => ({ step: s.n, text: doing(s) }));
|
|
418
467
|
const recovered = stopped ? [] : [...failedSteps, ...flat.map((f) => f.step).filter((s) => !s.failed && (s.tries || []).some((t) => t.failed))]
|
|
419
|
-
.sort((x, y) => x.n - y.n).map((s) => ({ step: s.n, text: sentence(s) }));
|
|
420
|
-
const warnings = flat.map((f) => f.step).filter((s) => s.warning).map((s) => ({ step: s.n, text: plainError({ finish: s.warning }).what }));
|
|
468
|
+
.sort((x, y) => x.n - y.n).map((s) => ({ step: s.n, text: sentence(s), short: shortTrouble(s) }));
|
|
469
|
+
const warnings = flat.map((f) => f.step).filter((s) => s.warning).map((s) => ({ step: s.n, text: plainError({ finish: s.warning }).what, short: plainError({ finish: s.warning }).what }));
|
|
421
470
|
|
|
422
471
|
const status = stopped ? 'stopped' : recovered.length || warnings.length ? 'finished-with-problems' : 'finished';
|
|
423
472
|
const who = agentName ? `The agent "${agentName}"` : 'The agent';
|
|
@@ -433,7 +482,8 @@ export function explainRun(input, { run } = {}) {
|
|
|
433
482
|
status, headline,
|
|
434
483
|
asked: ask ? short(hide(ask), 200) : null,
|
|
435
484
|
answered: !stopped && lastFinal ? short(hide(lastFinal.said), 200) : null,
|
|
436
|
-
problem, recovered, warnings, changes, unknown,
|
|
485
|
+
problem, recovered, warnings, effects, changes, unknown,
|
|
486
|
+
...(allowed ? { allowed: [...allowed], notAllowed } : {}),
|
|
437
487
|
durationMs,
|
|
438
488
|
steps: flat.map(({ step: s, depth }) => ({
|
|
439
489
|
n: s.n, depth, kind: s.kind, text: doing(s), outcome: outcome(s), sentence: sentence(s), failed: !!s.failed, effect: s.effect,
|
|
@@ -460,10 +510,44 @@ function detailsOf(s) {
|
|
|
460
510
|
// ── Printing ──────────────────────────────────────────────────────────────────────────────────────────────────
|
|
461
511
|
|
|
462
512
|
const at = (ms) => (ms == null ? '' : `+${(ms / 1000).toFixed(1)}s`);
|
|
463
|
-
const basisNote = { name:
|
|
513
|
+
const basisNote = { name: 'guessed from its name', declared: 'the tool says so', method: 'from the request method', operation: 'from the database operation' };
|
|
514
|
+
// What each kind of effect is called, as a past action and as an attempt.
|
|
515
|
+
const DID = { money: 'Moved money', delete: 'Deleted something', send: 'Sent something', create: 'Created something', change: 'Changed something', read: 'Read' };
|
|
516
|
+
const TRIED = { money: 'Tried to move money', delete: 'Tried to delete something', send: 'Tried to send something', create: 'Tried to create something', change: 'Tried to change something', read: 'Tried to read' };
|
|
517
|
+
const effectName = (e) => (/^[A-Z]+ /.test(e.name) ? e.name : `"${e.name}"`);
|
|
518
|
+
const effectLine = (e) => `${e.worked ? DID[e.kind] : TRIED[e.kind]} with ${effectName(e)}${e.basis === 'name' || e.basis === 'declared' ? ` (${basisNote[e.basis]})` : ''}.${e.worked ? '' : ' It did not go through, but may have partly happened.'}`;
|
|
519
|
+
const andList = (xs) => (xs.length > 1 ? `${xs.slice(0, -1).join(', ')} and ${xs[xs.length - 1]}` : xs.join(''));
|
|
520
|
+
|
|
521
|
+
/** The short story: a few lines anyone can read. Every step is one flag away (--steps). */
|
|
522
|
+
export function renderWhy(r, { file = 'run.json' } = {}) {
|
|
523
|
+
if (!r.ok) return r.why;
|
|
524
|
+
const who = r.headline.match(/^The agent( "[^"]+")?/)[0];
|
|
525
|
+
const took = r.durationMs != null ? ` ${r.status === 'stopped' ? 'after' : 'in'} ${secs(r.durationMs)}` : '';
|
|
526
|
+
const head = r.status === 'stopped' ? `✗ ${who} stopped${took}.`
|
|
527
|
+
: r.status === 'finished-with-problems' ? `✓ ${who} finished${took}, with ${r.recovered.length + r.warnings.length === 1 ? 'one problem' : `${r.recovered.length + r.warnings.length} problems`} along the way.`
|
|
528
|
+
: `✓ ${who} finished${took}.`;
|
|
529
|
+
const L = [head];
|
|
530
|
+
if (r.asked) L.push(` Asked: ${quote(r.asked, 100)}`);
|
|
531
|
+
if (r.answered) L.push(` Answered: ${quote(r.answered, 100)}`);
|
|
532
|
+
L.push('');
|
|
533
|
+
const row = (label, text) => L.push(` ${label.padEnd(9)} ${text}`);
|
|
534
|
+
if (r.problem) {
|
|
535
|
+
const p = r.problem;
|
|
536
|
+
row('Why:', p.short.charAt(0).toUpperCase() + p.short.slice(1));
|
|
537
|
+
}
|
|
538
|
+
for (const x of [...r.recovered, ...r.warnings]) row('Problem:', `${x.short.charAt(0).toUpperCase()}${x.short.slice(1)}`.replace(/\.?$/, '.'));
|
|
539
|
+
const did = r.changes.length ? r.changes.map(effectLine) : [r.effects.length ? 'Only read things.' : 'Nothing that changes anything.'];
|
|
540
|
+
did.forEach((t, i) => row(i ? '' : 'Did:', t));
|
|
541
|
+
if (r.unknown.length) row('Unclear:', `can't tell what ${r.unknown.map((u) => u.text.replace(/^Used /, '').split(' with ')[0]).join(', ')} does.`);
|
|
542
|
+
for (const e of r.notAllowed ?? []) row('Not OK:', `${effectName(e)} ${e.worked ? DID[e.kind].toLowerCase() : TRIED[e.kind].toLowerCase()}. Only ${andList(r.allowed)} ${r.allowed.length === 1 ? 'is' : 'are'} allowed.`);
|
|
543
|
+
if (r.problem?.next) row('Next:', r.problem.next);
|
|
544
|
+
L.push('', ` Every step: thunder why ${file} --steps`);
|
|
545
|
+
if (r.otherRuns.length) L.push(` This file has ${r.otherRuns.length + 1} runs; this is the latest. Others: --run ${r.otherRuns.map((x) => x.slice(0, 8)).join(', ')}`);
|
|
546
|
+
return L.join('\n');
|
|
547
|
+
}
|
|
464
548
|
|
|
465
|
-
/** The story
|
|
466
|
-
export function
|
|
549
|
+
/** The whole story: what happened, what went wrong, what changed, step by step, how sure. */
|
|
550
|
+
export function renderFull(r) {
|
|
467
551
|
if (!r.ok) return r.why;
|
|
468
552
|
const L = [];
|
|
469
553
|
L.push('What happened');
|
|
@@ -488,13 +572,10 @@ export function renderWhy(r) {
|
|
|
488
572
|
L.push('');
|
|
489
573
|
}
|
|
490
574
|
|
|
491
|
-
L.push('What it
|
|
492
|
-
if (!r.changes.length) L.push(` Nothing
|
|
493
|
-
for (const c of r.changes) {
|
|
494
|
-
|
|
495
|
-
L.push(c.worked ? ` Step ${c.step}. Changed: ${c.text}${how}.`
|
|
496
|
-
: ` Step ${c.step}. Tried to change, but it did not work: ${c.text}${how}. The record can't show whether anything was partly done.`);
|
|
497
|
-
}
|
|
575
|
+
L.push('What it did');
|
|
576
|
+
if (!r.changes.length) L.push(` Nothing that changes anything${r.unknown.length ? ', but some steps could not be judged (below)' : ''}.`);
|
|
577
|
+
for (const c of r.changes) L.push(` Step ${c.step}. ${effectLine(c)}`);
|
|
578
|
+
for (const e of r.notAllowed ?? []) L.push(` Not allowed: step ${e.step} ${DID[e.kind].toLowerCase()}${e.worked ? '' : ' (tried)'}. Allowed: ${r.allowed.join(', ')}.`);
|
|
498
579
|
if (r.unknown.length) L.push(` Could not judge whether ${r.unknown.length === 1 ? 'this step changes' : 'these steps change'} anything: ${r.unknown.map((u) => `step ${u.step} (${u.text})`).join('; ')}.`);
|
|
499
580
|
L.push('');
|
|
500
581
|
|