bareloop 0.47.1 → 0.49.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 +56 -0
- package/README.md +16 -9
- package/bareloop.context.md +70 -46
- package/bin/bareloop.mjs +2 -0
- package/package.json +3 -3
- package/src/bundle.js +36 -9
- package/src/bundleref.js +103 -0
- package/src/bundlerun.js +134 -17
- package/src/cli.js +138 -144
- package/src/config.js +1 -1
- package/src/draftspend.js +88 -34
- package/src/facts.js +1 -1
- package/src/interviewrun.js +11 -11
- package/src/invoke.js +3 -2
- package/src/launcher.js +122 -12
- package/src/learn.js +34 -20
- package/src/learnstore.js +30 -14
- package/src/pagedropwords.js +1 -0
- package/src/pagedry.js +77 -6
- package/src/pagemap.js +17 -3
- package/src/pagerules.js +2 -1
- package/src/panel/authorsession.js +7 -13
- package/src/panel/index.html +30 -7
- package/src/panel/runroutes.js +28 -14
- package/src/panel/server.js +69 -118
- package/src/prompts.js +50 -0
- package/src/reuse.js +1 -1
- package/src/runexport.js +162 -0
- package/src/runfiles.js +65 -0
- package/src/runlist.js +72 -0
- package/src/userrun.js +17 -13
- package/types/bundle.d.ts +16 -0
- package/types/bundleref.d.ts +63 -0
- package/types/bundlerun.d.ts +10 -3
- package/types/cli.d.ts +2 -1
- package/types/draftspend.d.ts +7 -23
- package/types/launcher.d.ts +67 -2
- package/types/learn.d.ts +29 -15
- package/types/learnstore.d.ts +31 -10
- package/types/pagedry.d.ts +26 -0
- package/types/pagemap.d.ts +1 -0
- package/types/panel/server.d.ts +7 -3
- package/types/prompts.d.ts +21 -0
- package/types/reuse.d.ts +3 -0
- package/types/runexport.d.ts +58 -0
- package/types/runfiles.d.ts +40 -0
- package/types/runlist.d.ts +55 -0
package/src/interviewrun.js
CHANGED
|
@@ -754,8 +754,8 @@ export async function main(argv, deps = {}) {
|
|
|
754
754
|
}
|
|
755
755
|
|
|
756
756
|
// ── 6. the paid step, which is a DIFFERENT process under a DIFFERENT ceiling ─
|
|
757
|
-
//
|
|
758
|
-
const
|
|
757
|
+
// `bareloop author` left the CLI (PRD v1.114): the paid step is `scripts/run-author.mjs`, which takes the same flags
|
|
758
|
+
const AUTHOR_SCRIPT = fileURLToPath(new URL('../scripts/run-author.mjs', import.meta.url));
|
|
759
759
|
const childArgs = [
|
|
760
760
|
'--source', TREE, '--answers', answersFile, '--draft', draftFile,
|
|
761
761
|
'--verdict', VERDICT, '--out', OUT,
|
|
@@ -775,7 +775,7 @@ export async function main(argv, deps = {}) {
|
|
|
775
775
|
say(`It runs under the AUTHORING ceiling (${CEILING_USD === null ? 'UNBOUNDED — you gave no --budget' : `$${CEILING_USD}`}), which is not the job's $${draft.budgetUsd}.`);
|
|
776
776
|
say('It stops at prepareSigning: it never signs, and it never runs the job.');
|
|
777
777
|
} else {
|
|
778
|
-
say('NEXT — running
|
|
778
|
+
say('NEXT — running scripts/run-author.mjs on this source stops right away, at $0: no scout, no confirm turn, no model call.');
|
|
779
779
|
say('It never signs and never runs the job — bareloop has no checks for this kind of job yet.');
|
|
780
780
|
}
|
|
781
781
|
say('');
|
|
@@ -790,7 +790,7 @@ export async function main(argv, deps = {}) {
|
|
|
790
790
|
const worker = resolveWorker(keyRowsNow, { provider: PROVIDER, baseUrl: draft.baseUrl, model: modelArg });
|
|
791
791
|
const providerEnvKey = worker.ok ? worker.row.envName : null;
|
|
792
792
|
say(` ${providerEnvKey ?? 'YOUR_KEY_NAME'}=... ${commandFor('author', deps.invokedAs)} ${childArgs.join(' ')}`);
|
|
793
|
-
if (!worker.ok) say(` (${worker.say.replace(' Nothing was spent.', '')} —
|
|
793
|
+
if (!worker.ok) say(` (${worker.say.replace(' Nothing was spent.', '')} — scripts/run-author.mjs stops at $0 until it is)`);
|
|
794
794
|
// NO KEY, NO OFFER. `run-author.mjs` refuses without one and exits 2 at its own door, before a spine exists — so with the shell
|
|
795
795
|
// unkeyed this question has exactly one possible outcome for the person, and putting it anyway spends their attention on a choice
|
|
796
796
|
// they do not have. F181 — a key that IS set can still carry a shape run-author will refuse (a line break/control char/stray
|
|
@@ -801,11 +801,11 @@ export async function main(argv, deps = {}) {
|
|
|
801
801
|
if (!KEYED) {
|
|
802
802
|
say('');
|
|
803
803
|
if (providerEnvKey && keyProblem) {
|
|
804
|
-
say(` (${providerEnvKey} is set but ${keyProblem} —
|
|
804
|
+
say(` (${providerEnvKey} is set but ${keyProblem} — scripts/run-author.mjs refuses without a clean key; secrets are never trimmed or repaired, only reported)`);
|
|
805
805
|
} else {
|
|
806
806
|
say(providerEnvKey
|
|
807
|
-
? ` (${providerEnvKey} is not set in this shell —
|
|
808
|
-
: ' (no key row serves this model yet —
|
|
807
|
+
? ` (${providerEnvKey} is not set in this shell — scripts/run-author.mjs refuses without it; secrets load from the environment, never the tree)`
|
|
808
|
+
: ' (no key row serves this model yet — scripts/run-author.mjs refuses it at $0; this is not a key problem)');
|
|
809
809
|
}
|
|
810
810
|
// The repair, in plain words and WITHOUT a command: which secret store a person
|
|
811
811
|
// keeps their key in is theirs, and printing one specific incantation would be
|
|
@@ -822,9 +822,9 @@ export async function main(argv, deps = {}) {
|
|
|
822
822
|
: null;
|
|
823
823
|
if (depsGapAtHandoff) {
|
|
824
824
|
say('');
|
|
825
|
-
say(` The copy still has no installed packages (${depsGapAtHandoff.reason}) —
|
|
825
|
+
say(` The copy still has no installed packages (${depsGapAtHandoff.reason}) — scripts/run-author.mjs would only instrument-stop on it.`);
|
|
826
826
|
say(` cd ${prep.tree} && ${depsGapAtHandoff.command}`);
|
|
827
|
-
say(' then run
|
|
827
|
+
say(' then run scripts/run-author.mjs yourself with the command above.');
|
|
828
828
|
}
|
|
829
829
|
say('');
|
|
830
830
|
// The default is NO, and it is the same lean the pause's doors take: the answer that
|
|
@@ -853,9 +853,9 @@ export async function main(argv, deps = {}) {
|
|
|
853
853
|
exitCode = 0;
|
|
854
854
|
} else {
|
|
855
855
|
say('');
|
|
856
|
-
const child = spawnSyncFn(process.execPath, [
|
|
856
|
+
const child = spawnSyncFn(process.execPath, [AUTHOR_SCRIPT, ...childArgs], { stdio: 'inherit' });
|
|
857
857
|
if (child.error) {
|
|
858
|
-
say(`
|
|
858
|
+
say(`scripts/run-author.mjs could not be started (${child.error.message}) — the command above still stands.`);
|
|
859
859
|
exitCode = 2;
|
|
860
860
|
} else {
|
|
861
861
|
// the child's own exit is the answer: a refusal there is a RESULT, and flattening
|
package/src/invoke.js
CHANGED
|
@@ -16,7 +16,8 @@ const SCRIPT = /** @type {const} */ ({ 'run-u': 'run-u', interview: 'run-intervi
|
|
|
16
16
|
* @returns {string}
|
|
17
17
|
*/
|
|
18
18
|
export function commandFor(flow, invokedAs) {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// `interview` and `author` left the `bareloop` CLI (PRD v1.114): they are only ever the source-tree scripts
|
|
20
|
+
return flow === 'run-u' && invokedAs !== undefined && /^bareloop(\s|$)/.test(invokedAs)
|
|
21
|
+
? 'bareloop run-u'
|
|
21
22
|
: `node scripts/${SCRIPT[flow]}.mjs`;
|
|
22
23
|
}
|
package/src/launcher.js
CHANGED
|
@@ -18,6 +18,7 @@ import { keysHome, keysFilePath, ensureKeysFile } from './keysfile.js';
|
|
|
18
18
|
import { openInOs } from './opener.js';
|
|
19
19
|
import { PLAIN } from './tty-colour.js';
|
|
20
20
|
import { runsListForCount, packageVersion, panelUrl } from './panel/server.js';
|
|
21
|
+
import { dateTimeWords } from './schedulewords.js';
|
|
21
22
|
|
|
22
23
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
23
24
|
/** the first port tried, and how many in a row (4700..4709) */
|
|
@@ -28,6 +29,8 @@ const WAIT_DEADLINE_MS = 10_000;
|
|
|
28
29
|
/** how long `start` keeps asking a TAKEN port that stays silent before it refuses to open another panel next to it */
|
|
29
30
|
const SILENT_PORT_WAIT_MS = 10_000;
|
|
30
31
|
const POLL_MS = 100;
|
|
32
|
+
/** not in the signed text: how long `npm install -g` may run before its own child is killed */
|
|
33
|
+
const NPM_DEADLINE_MS = 300_000;
|
|
31
34
|
const MIN_NODE_MAJOR = 22;
|
|
32
35
|
const RULE_WIDTH = 56;
|
|
33
36
|
|
|
@@ -35,6 +38,7 @@ const RULE_WIDTH = 56;
|
|
|
35
38
|
* @typedef {object} Panel one answered probe
|
|
36
39
|
* @property {number} port @property {number} pid @property {string} version @property {number} drafts @property {number} schedules
|
|
37
40
|
* @property {string} url
|
|
41
|
+
* @property {string|null} [startedAt] ISO time the panel process started (`whoami`); absent on an older panel
|
|
38
42
|
*/
|
|
39
43
|
|
|
40
44
|
/**
|
|
@@ -47,6 +51,10 @@ const RULE_WIDTH = 56;
|
|
|
47
51
|
* @property {number} [silentWaitMs] how long start keeps asking a taken, silent port (default 10 s)
|
|
48
52
|
* @property {string} [nodeVersion] default process.versions.node
|
|
49
53
|
* @property {typeof fetch} [fetchImpl]
|
|
54
|
+
* @property {(cmd: string, args: string[], o: object) => any} [npmSpawn] runs `npm install -g bareloop@latest` for `update` (default node:child_process spawn, no shell)
|
|
55
|
+
* @property {number} [npmDeadlineMs] how long `update`'s npm install may run before its child is killed (default 300 s)
|
|
56
|
+
* @property {boolean} [terminal] false = no person at a terminal (piped / redirected stdin): `update` then never installs, it prints the command (absent = ask)
|
|
57
|
+
* @property {typeof fetch} [npmFetch] the registry check of `update` only (default the global fetch); nothing else ever goes online
|
|
50
58
|
* @property {(cmd: string, args: string[], o: object) => any} [spawnFn] default node:child_process spawn
|
|
51
59
|
* @property {(pid: number, sig: string|number) => void} [kill] default process.kill
|
|
52
60
|
* @property {((target: string) => Promise<boolean>)} [open] default the shared OS opener
|
|
@@ -124,6 +132,7 @@ export async function probePort(o) {
|
|
|
124
132
|
drafts: Number(j.drafts) || 0,
|
|
125
133
|
schedules: Number(j.schedules) || 0,
|
|
126
134
|
url: panelUrl(port),
|
|
135
|
+
startedAt: typeof j.startedAt === 'string' && Number.isFinite(Date.parse(j.startedAt)) ? j.startedAt : null,
|
|
127
136
|
},
|
|
128
137
|
};
|
|
129
138
|
} catch (e) {
|
|
@@ -142,6 +151,12 @@ export async function probePanels(o) {
|
|
|
142
151
|
return /** @type {Panel[]} */ (answers.flatMap((a) => (a.state === 'panel' ? [a.panel] : [])));
|
|
143
152
|
}
|
|
144
153
|
|
|
154
|
+
/**
|
|
155
|
+
* ` · started 10/24 21:40` (local, the panel's own date style: `dateTimeWords`); '' for an older panel that reports no start time.
|
|
156
|
+
* @param {Panel} p @returns {string}
|
|
157
|
+
*/
|
|
158
|
+
const startedWords = (p) => (p.startedAt ? ` · started ${dateTimeWords(Date.parse(p.startedAt))}` : '');
|
|
159
|
+
|
|
145
160
|
/** @param {LauncherDeps} d @returns {number[]} */
|
|
146
161
|
function portsOf(d) {
|
|
147
162
|
if (d.ports) return d.ports;
|
|
@@ -168,8 +183,8 @@ export async function buildHeader(d) {
|
|
|
168
183
|
const sep = P.grey(' · ');
|
|
169
184
|
const where = panels.length === 0
|
|
170
185
|
? `panel ${P.grey('not running')}`
|
|
171
|
-
: `panel${panels.length > 1 ? 's' : ''} ${P.green('running')} at ${panels.map((p) => P.cyan(p.url) + (p.version !== version ? P.yellow(` (version ${p.version} — stop and start to use ${version})`) : '')).join(', ')}`;
|
|
172
|
-
const state = inst.ok ? P.green('installed ✓') : `${P.red('not installed')} — ${inst.problem}, pick ${P.boldCyan('
|
|
186
|
+
: `panel${panels.length > 1 ? 's' : ''} ${P.green('running')} at ${panels.map((p) => P.cyan(p.url) + (p.startedAt ? P.grey(startedWords(p)) : '') + (p.version !== version ? P.yellow(` (version ${p.version} — stop and start to use ${version})`) : '')).join(', ')}`;
|
|
187
|
+
const state = inst.ok ? P.green('installed ✓') : `${P.red('not installed')} — ${inst.problem}, pick ${P.boldCyan('5')} install`;
|
|
173
188
|
const first = `${P.boldCyan('bareloop')} ${P.grey(version)}${sep}${state}${sep}${where}`;
|
|
174
189
|
let second;
|
|
175
190
|
try {
|
|
@@ -257,7 +272,7 @@ export async function installCmd(io, d, shown) {
|
|
|
257
272
|
return 1;
|
|
258
273
|
}
|
|
259
274
|
}
|
|
260
|
-
if (made.length === 0) { io.out('Already
|
|
275
|
+
if (made.length === 0) { io.out('Already set up. This does not update bareloop. Pick 6 update for that.'); return 0; }
|
|
261
276
|
io.out('Installed. Created:');
|
|
262
277
|
for (const m of made) io.out(` ${m}`);
|
|
263
278
|
return 0;
|
|
@@ -276,12 +291,75 @@ export async function statusCmd(io, d, shown) {
|
|
|
276
291
|
return shown ? 0 : 3;
|
|
277
292
|
}
|
|
278
293
|
for (const p of h.panels) {
|
|
279
|
-
const body = `pid ${p.pid} · version ${p.version} · ${plural(p.drafts, 'draft', 'drafts')} open · ${plural(p.schedules, 'schedule', 'schedules')} on`;
|
|
294
|
+
const body = `pid ${p.pid} · version ${p.version} · ${plural(p.drafts, 'draft', 'drafts')} open · ${plural(p.schedules, 'schedule', 'schedules')} on${startedWords(p)}`;
|
|
280
295
|
io.out(h.panels.length > 1 ? `${p.url} · ${body}` : body);
|
|
281
296
|
}
|
|
282
297
|
return 0;
|
|
283
298
|
}
|
|
284
299
|
|
|
300
|
+
/** @param {string} v @returns {number[]|null} major, minor, patch of `1.2.3` (a `-pre` tail is ignored); null when it is not that shape */
|
|
301
|
+
function parseVersion(v) {
|
|
302
|
+
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
|
|
303
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** @param {number[]} a @param {number[]} b @returns {boolean} a is newer than b */
|
|
307
|
+
const isNewer = (a, b) => ((a[0] - b[0]) || (a[1] - b[1]) || (a[2] - b[2])) > 0;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* `bareloop update` — the only launcher command that goes online, and only when pressed: reads the newest published version from the npm
|
|
311
|
+
* registry (5 s deadline) and says whether there is a newer one. It installs nothing; it tells the person the command.
|
|
312
|
+
* @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string}} d @param {{lines: string[], panels: Panel[]}} [shown]
|
|
313
|
+
* @returns {Promise<number>}
|
|
314
|
+
*/
|
|
315
|
+
export async function updateCmd(io, d, shown) {
|
|
316
|
+
await headerOnce(io, d, shown);
|
|
317
|
+
const mine = d.version ?? packageVersion();
|
|
318
|
+
/** @type {number[]|null} */
|
|
319
|
+
let latest = null;
|
|
320
|
+
/** @type {string} */
|
|
321
|
+
let latestText = '';
|
|
322
|
+
try {
|
|
323
|
+
const res = await (d.npmFetch ?? fetch)('https://registry.npmjs.org/bareloop/latest', { signal: AbortSignal.timeout(5000) });
|
|
324
|
+
if (res.ok) {
|
|
325
|
+
const j = /** @type {{version?: unknown}} */ (await res.json());
|
|
326
|
+
latestText = typeof j?.version === 'string' ? j.version : '';
|
|
327
|
+
latest = parseVersion(latestText);
|
|
328
|
+
}
|
|
329
|
+
} catch { /* offline, timeout, bad JSON: the one plain line below */ }
|
|
330
|
+
const have = parseVersion(mine);
|
|
331
|
+
if (!latest || !have) {
|
|
332
|
+
fail(io, d, 'Could not reach npm to check. Try again later.');
|
|
333
|
+
return 1;
|
|
334
|
+
}
|
|
335
|
+
if (!isNewer(latest, have)) { io.out(`You have the newest bareloop (${mine}).`); return 0; }
|
|
336
|
+
const manual = 'npm install -g bareloop@latest';
|
|
337
|
+
io.out(`bareloop ${latestText} is out. You have ${mine}.`);
|
|
338
|
+
if (!d.ask || d.terminal === false) { io.out(`To update: ${manual}`); return 0; }
|
|
339
|
+
// an empty Enter or other text asks once more; a second one ends as "no"
|
|
340
|
+
let yes = false;
|
|
341
|
+
for (let i = 0; i < 2; i += 1) {
|
|
342
|
+
const a = (await d.ask('Update now? (y/n) ')).trim().toLowerCase();
|
|
343
|
+
if (a === 'y' || a === 'yes') { yes = true; break; }
|
|
344
|
+
if (a === 'n' || a === 'no' || a === 'q') break;
|
|
345
|
+
}
|
|
346
|
+
if (!yes) { io.out(`Not updated. To update later: ${manual}`); return 0; }
|
|
347
|
+
const ok = await new Promise((resolve) => {
|
|
348
|
+
let timer;
|
|
349
|
+
const end = (/** @type {boolean} */ v) => { clearTimeout(timer); resolve(v); };
|
|
350
|
+
try {
|
|
351
|
+
const child = (d.npmSpawn ?? realSpawn)('npm', ['install', '-g', 'bareloop@latest'], { stdio: 'inherit' });
|
|
352
|
+
// not in the signed text: npm may run this long, then its own child is ended (aligned with fwdloop)
|
|
353
|
+
timer = setTimeout(() => { try { child.kill('SIGTERM'); } catch { /* already gone */ } end(false); }, d.npmDeadlineMs ?? NPM_DEADLINE_MS);
|
|
354
|
+
child.once('error', () => end(false));
|
|
355
|
+
child.once('close', (code) => end(code === 0));
|
|
356
|
+
} catch { end(false); }
|
|
357
|
+
});
|
|
358
|
+
if (!ok) { fail(io, d, `The update did not finish. Run it yourself: ${manual}`); return 1; }
|
|
359
|
+
io.out(`Updated to ${latestText}. Then ${shown ? 'pick 3 restart' : 'run bareloop restart'}.`); // the menu door (shown) has the menu; the subcommand door has none
|
|
360
|
+
return 0;
|
|
361
|
+
}
|
|
362
|
+
|
|
285
363
|
/**
|
|
286
364
|
* Wait until `port` stops (gone=true) or starts (gone=false) answering whoami as bareloop.
|
|
287
365
|
* @param {LauncherDeps} d @param {number} port @param {boolean} gone
|
|
@@ -352,7 +430,7 @@ export async function startCmd(io, d, shown) {
|
|
|
352
430
|
const verdict = await askTakenPort(d, p);
|
|
353
431
|
if (verdict.state === 'panel') return alreadyRunning(verdict.panel);
|
|
354
432
|
if (verdict.state === 'silent') {
|
|
355
|
-
fail(io, d, `Port ${p} is taken and not answering. If it
|
|
433
|
+
fail(io, d, `Port ${p} is taken and not answering. To see what holds it: lsof -i :${p}. If it is a stuck bareloop, end it: kill <pid>`);
|
|
356
434
|
return 1;
|
|
357
435
|
}
|
|
358
436
|
}
|
|
@@ -452,8 +530,33 @@ export async function stopCmd(args, io, d, shown) {
|
|
|
452
530
|
}
|
|
453
531
|
|
|
454
532
|
/**
|
|
455
|
-
*
|
|
456
|
-
*
|
|
533
|
+
* `bareloop restart [--yes]` — the existing stop (same open-drafts warning and ask; `--yes` skips it), then the existing start, on the
|
|
534
|
+
* port the panel had when it is free again (else the normal first-free-port rule). No panel running: says so and just starts.
|
|
535
|
+
* No new process model, no pid file.
|
|
536
|
+
* @param {string[]} args
|
|
537
|
+
* @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string}} d @param {{lines: string[], panels: Panel[]}} [shown]
|
|
538
|
+
* @returns {Promise<number>}
|
|
539
|
+
*/
|
|
540
|
+
export async function restartCmd(args, io, d, shown) {
|
|
541
|
+
const h = await headerOnce(io, d, shown);
|
|
542
|
+
if (h.panels.length === 0) {
|
|
543
|
+
io.out('Panel not running — starting it.');
|
|
544
|
+
return startCmd(io, d, { lines: h.lines, panels: [] });
|
|
545
|
+
}
|
|
546
|
+
const rc = await stopCmd(args, io, d, h);
|
|
547
|
+
if (rc !== 0) return rc;
|
|
548
|
+
// a declined "Stop the panel?" is exit 0 too: only start when the panel is really gone
|
|
549
|
+
if ((await probeAll(d)).length > 0) return 0;
|
|
550
|
+
const was = h.panels[0].port;
|
|
551
|
+
const ports = [was, ...portsOf(d).filter((p) => p !== was)];
|
|
552
|
+
return startCmd(io, { ...d, ports }, { lines: h.lines, panels: [] });
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* The bare `bareloop` menu (PRD v1.114, one menu): the panel's six choices, the four job commands, one question. Runs the chosen command
|
|
557
|
+
* and returns its exit code. The job commands (7 export, 8 run, 9 resume, 10 history) are `d.jobs`, supplied by the CLI: each prompts for
|
|
558
|
+
* what it needs on the same asker this menu uses.
|
|
559
|
+
* @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string, jobs?: {export: () => Promise<number>, run: () => Promise<number>, resume: () => Promise<number>, history: () => Promise<number>}}} d
|
|
457
560
|
* @returns {Promise<number>}
|
|
458
561
|
*/
|
|
459
562
|
export async function menuCmd(io, d) {
|
|
@@ -463,15 +566,22 @@ export async function menuCmd(io, d) {
|
|
|
463
566
|
const P = d.paint ?? PLAIN;
|
|
464
567
|
if (!P.on) io.out('');
|
|
465
568
|
const n = (/** @type {string} */ k) => P.boldCyan(k);
|
|
466
|
-
const
|
|
467
|
-
io.out(
|
|
569
|
+
const ind = P.on ? ' ' : '';
|
|
570
|
+
io.out(`${ind}panel: ${n('1')} start ${n('2')} stop ${n('3')} restart ${n('4')} status ${n('5')} install ${n('6')} update`);
|
|
571
|
+
io.out(`${ind}jobs: ${n('7')} export ${n('8')} run ${n('9')} resume ${n('10')} history`);
|
|
572
|
+
io.out(`${ind}${n('q')} quit`);
|
|
468
573
|
const choice = ask ? (await ask(`${P.cyan('>')} `)).trim().toLowerCase() : 'q';
|
|
469
574
|
// the header is already on screen: the chosen command reuses it instead of printing it a second time
|
|
470
575
|
if (choice === '1' || choice === 'start') return startCmd(io, d, h);
|
|
471
576
|
if (choice === '2' || choice === 'stop') return stopCmd([], io, d, h);
|
|
472
|
-
if (choice === '3' || choice === '
|
|
473
|
-
if (choice === '4' || choice === '
|
|
577
|
+
if (choice === '3' || choice === 'restart') return restartCmd([], io, d, h);
|
|
578
|
+
if (choice === '4' || choice === 'status') return statusCmd(io, d, h);
|
|
579
|
+
if (choice === '5' || choice === 'install') return installCmd(io, d, h);
|
|
580
|
+
if (choice === '6' || choice === 'update') return updateCmd(io, d, h);
|
|
581
|
+
const jobChoices = { 7: 'export', export: 'export', 8: 'run', run: 'run', 9: 'resume', resume: 'resume', 10: 'history', history: 'history' };
|
|
582
|
+
const job = Object.hasOwn(jobChoices, choice) ? jobChoices[choice] : undefined; // never `constructor` / `__proto__`
|
|
583
|
+
if (job !== undefined && d.jobs) return d.jobs[/** @type {'export'|'run'|'resume'|'history'} */ (job)]();
|
|
474
584
|
if (choice === '' || choice === 'q' || choice === 'quit') return 0;
|
|
475
|
-
fail(io, d, `unknown choice ${JSON.stringify(choice)} — one of: 1, 2, 3, 4, q`);
|
|
585
|
+
fail(io, d, `unknown choice ${JSON.stringify(choice)} — one of: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, q`);
|
|
476
586
|
return 1;
|
|
477
587
|
}
|
package/src/learn.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
// Graduated from the proofs in .claude/scratch/poc-learn/ (pocA2 candidates, pocC cards, pocE2 fold) as a REWRITE.
|
|
16
16
|
// The 60% threshold is FITTED on known cards (a fit, not a proof; the unseen-card proof is OPEN 2).
|
|
17
17
|
|
|
18
|
+
import { homedir } from 'node:os';
|
|
18
19
|
import { redactSecrets } from './validate.js';
|
|
19
20
|
|
|
20
21
|
// ── constants (every number here is a ruling, not a tuning knob) ─────────────────────────────────
|
|
@@ -555,13 +556,14 @@ export function foldCards(cards) {
|
|
|
555
556
|
* @property {string[]} runIds
|
|
556
557
|
* @property {string} firstSeen
|
|
557
558
|
* @property {string} lastSeen
|
|
558
|
-
* @property {string|null} specHash the signed hash the lesson was last seen under (a
|
|
559
|
+
* @property {string|null} specHash the signed hash the lesson was last seen under (a record only; the job version is `workflowKey`)
|
|
560
|
+
* @property {string|null} [workflowKey] the workflow key (Reuse's rule: caps, time, source, destination, inputs and model do not move it) the lesson was last seen under; a workflow row of another key is never matched or read. Absent on rows an older version wrote: those match any version
|
|
559
561
|
* @property {string} key check + sorted kinds (job-independent); information only since R2 removed the check-wide set-aside
|
|
560
562
|
*/
|
|
561
563
|
/**
|
|
562
564
|
* @typedef {object} Pending
|
|
563
565
|
* @property {string} runid @property {string} at @property {string} workflow @property {string|null} place
|
|
564
|
-
* @property {string|null} specHash @property {Card[]} cards
|
|
566
|
+
* @property {string|null} specHash @property {string|null} [workflowKey] @property {Card[]} cards
|
|
565
567
|
*/
|
|
566
568
|
/**
|
|
567
569
|
* @typedef {object} Ledger
|
|
@@ -606,11 +608,12 @@ function rowId(c) {
|
|
|
606
608
|
export const isDecayed = (r, now) => { const t = Date.parse(r.lastSeen); return Number.isFinite(t) && now.getTime() - t > DECAY_DAYS * DAY_MS; };
|
|
607
609
|
|
|
608
610
|
/**
|
|
609
|
-
* Is this workflow row from another job version (a different
|
|
610
|
-
* `
|
|
611
|
-
*
|
|
611
|
+
* Is this workflow row from another job version (a different workflow key than this run's)? Decided from the stored
|
|
612
|
+
* `workflowKey`, read-time, never stored. The key ignores the Reuse-editable fields (caps, source, destination, inputs, model), so a
|
|
613
|
+
* Reuse with a new cap is the same version. An unknown key on either side (a row an older version wrote) is the same version.
|
|
614
|
+
* @param {Row} r @param {string} workflow @param {string|null|undefined} workflowKey
|
|
612
615
|
*/
|
|
613
|
-
export const otherJobVersion = (r, workflow,
|
|
616
|
+
export const otherJobVersion = (r, workflow, workflowKey) => r.level === 'workflow' && r.workflow === workflow && r.workflowKey != null && workflowKey != null && r.workflowKey !== workflowKey;
|
|
614
617
|
|
|
615
618
|
/** Drop the retired stored `status`/`expiredBy` fields an older ledger file may carry, and reset a stored `level` (never read; stripped on the next write). @param {Row} r */
|
|
616
619
|
const stripLegacy = (r) => { const { status: _s, expiredBy: _e, ...rest } = /** @type {Row & {status?: unknown, expiredBy?: unknown}} */ (r); return /** @type {Row} */ ({ ...rest, level: 'workflow' }); };
|
|
@@ -623,19 +626,19 @@ const byRank = (/** @type {Row} */ a, /** @type {Row} */ b) => b.count - a.count
|
|
|
623
626
|
*
|
|
624
627
|
* +1 per RUN per row: the run's own cards are folded into lessons first, and a row whose `runIds` already holds the
|
|
625
628
|
* run id is never counted twice (a resumed run, one id, never double counts) but IS refreshed: the resumed leg's card
|
|
626
|
-
* replaces the sample, lesson, key, lastSeen, hash and place (a leg-1 NEVER FIXED row becomes the leg-2 FIXED one). A
|
|
629
|
+
* replaces the sample, lesson, key, lastSeen, hash, key and place (a leg-1 NEVER FIXED row becomes the leg-2 FIXED one). A
|
|
627
630
|
* matching lesson replaces the row's sample, bumps the model count and appends the run id (a row last seen 56+ days ago counts +1 and is read again);
|
|
628
631
|
* otherwise it opens a new row at count 1. NEVER FIXED cards count like FIXED ones (RULING 3). A workflow row of
|
|
629
|
-
* another
|
|
632
|
+
* another workflow key is never matched here: the new version opens its own rows. Nothing is ever deleted or stamped.
|
|
630
633
|
* @param {Ledger} ledger
|
|
631
|
-
* @param {{runid: string, cards: Card[], workflow: string, place: string|null, specHash: string|null, trust: 'deterministic'|'rubric', now: Date}} o
|
|
634
|
+
* @param {{runid: string, cards: Card[], workflow: string, place: string|null, specHash: string|null, workflowKey?: string|null, trust: 'deterministic'|'rubric', now: Date}} o
|
|
632
635
|
* @returns {Ledger}
|
|
633
636
|
*/
|
|
634
|
-
export function countLedger(ledger, { runid, cards, workflow, place, specHash, trust, now }) {
|
|
637
|
+
export function countLedger(ledger, { runid, cards, workflow, place, specHash, workflowKey = null, trust, now }) {
|
|
635
638
|
const rows = ledger.rows.map((r) => ({ ...stripLegacy(r), runIds: [...r.runIds], models: { ...r.models } }));
|
|
636
639
|
for (const group of foldCards(cards)) {
|
|
637
640
|
const rep = group.reduce((a, c) => (c.at >= a.at ? c : a));
|
|
638
|
-
const hit = [...rows].sort(byRank).find((r) => r.workflow === workflow && !otherJobVersion(r, workflow,
|
|
641
|
+
const hit = [...rows].sort(byRank).find((r) => r.workflow === workflow && !otherJobVersion(r, workflow, workflowKey) && cardsMatch(rep, r.sample).match);
|
|
639
642
|
if (hit) {
|
|
640
643
|
// A row already holding this run id is the run's OWN row (a resumed leg re-reads the whole spine): refresh it from
|
|
641
644
|
// the new card, but the count, the model tally and the run id stay one per run.
|
|
@@ -652,6 +655,7 @@ export function countLedger(ledger, { runid, cards, workflow, place, specHash, t
|
|
|
652
655
|
hit.key = keyOfCard(rep);
|
|
653
656
|
hit.lastSeen = rep.at;
|
|
654
657
|
hit.specHash = specHash;
|
|
658
|
+
hit.workflowKey = workflowKey;
|
|
655
659
|
hit.place = place ?? hit.place;
|
|
656
660
|
}
|
|
657
661
|
} else {
|
|
@@ -659,7 +663,7 @@ export function countLedger(ledger, { runid, cards, workflow, place, specHash, t
|
|
|
659
663
|
for (let n = 2; rows.some((r) => r.id === id); n += 1) id = `${rowId(rep)}-${n}`;
|
|
660
664
|
rows.push({
|
|
661
665
|
id, lesson: lessonOf(rep), count: 1, sample: rep, models: { [rep.model ?? 'unknown']: 1 }, workflow, place, level: 'workflow',
|
|
662
|
-
trust, runIds: [runid], firstSeen: rep.at, lastSeen: rep.at, specHash, key: keyOfCard(rep),
|
|
666
|
+
trust, runIds: [runid], firstSeen: rep.at, lastSeen: rep.at, specHash, workflowKey, key: keyOfCard(rep),
|
|
663
667
|
});
|
|
664
668
|
}
|
|
665
669
|
}
|
|
@@ -723,12 +727,12 @@ export function climb(rows) {
|
|
|
723
727
|
* Hold a run's cards until a human Accept. NO LONGER CALLED for new runs (v1.112: a rubric run's lessons count at run
|
|
724
728
|
* end); kept so a hold already in a ledger file still has a writer for tests and a reader in {@link releasePending}. Pure.
|
|
725
729
|
* @param {Ledger} ledger
|
|
726
|
-
* @param {{runid: string, cards: Card[], workflow: string, place: string|null, specHash: string|null, at: string}} o
|
|
730
|
+
* @param {{runid: string, cards: Card[], workflow: string, place: string|null, specHash: string|null, workflowKey?: string|null, at: string}} o
|
|
727
731
|
* @param {Date} now @returns {Ledger}
|
|
728
732
|
*/
|
|
729
|
-
export function holdPending(ledger, { runid, cards, workflow, place, specHash, at }, now) {
|
|
733
|
+
export function holdPending(ledger, { runid, cards, workflow, place, specHash, workflowKey = null, at }, now) {
|
|
730
734
|
const pending = ledger.pending.filter((p) => p.runid !== runid);
|
|
731
|
-
if (cards.length) pending.push({ runid, at, workflow, place, specHash, cards });
|
|
735
|
+
if (cards.length) pending.push({ runid, at, workflow, place, specHash, workflowKey, cards });
|
|
732
736
|
return finish({ ...ledger, pending }, now);
|
|
733
737
|
}
|
|
734
738
|
|
|
@@ -743,7 +747,7 @@ export function releasePending(ledger, runid, now) {
|
|
|
743
747
|
if (!p) return { ledger, released: 0 };
|
|
744
748
|
const rest = { ...ledger, pending: ledger.pending.filter((x) => x.runid !== runid) };
|
|
745
749
|
if (now.getTime() - Date.parse(p.at) > PENDING_DAYS * DAY_MS) return { ledger: finish(rest, now), released: 0 };
|
|
746
|
-
const counted = countLedger(rest, { runid, cards: p.cards, workflow: p.workflow, place: p.place, specHash: p.specHash, trust: 'rubric', now });
|
|
750
|
+
const counted = countLedger(rest, { runid, cards: p.cards, workflow: p.workflow, place: p.place, specHash: p.specHash, workflowKey: p.workflowKey ?? null, trust: 'rubric', now });
|
|
747
751
|
return { ledger: counted, released: p.cards.length };
|
|
748
752
|
}
|
|
749
753
|
|
|
@@ -854,13 +858,13 @@ function hintText(r, n) {
|
|
|
854
858
|
* derived HERE by {@link climb} over the rows not decayed at `now` only; the stored level is never read.
|
|
855
859
|
* Order: this job's, then this place's, then all-jobs LAST (R2: climbing wins, so an all-jobs hint only uses leftover
|
|
856
860
|
* room); inside each level highest count first (ties: most recent lastSeen, then id), so the order is total and stable.
|
|
857
|
-
* @param {Ledger} ledger @param {{workflow: string, place: string|null,
|
|
861
|
+
* @param {Ledger} ledger @param {{workflow: string, place: string|null, workflowKey?: string|null, now: Date}} o
|
|
858
862
|
* @returns {Row[]}
|
|
859
863
|
*/
|
|
860
|
-
export function readableRows(ledger, { workflow, place,
|
|
864
|
+
export function readableRows(ledger, { workflow, place, workflowKey = null, now }) {
|
|
861
865
|
return climb(ledger.rows.filter((r) => !isDecayed(r, now))).filter((r) => {
|
|
862
866
|
if (r.runIds.length === 0) return false;
|
|
863
|
-
if (r.level === 'workflow') return r.workflow === workflow && !otherJobVersion(r, workflow,
|
|
867
|
+
if (r.level === 'workflow') return r.workflow === workflow && !otherJobVersion(r, workflow, workflowKey);
|
|
864
868
|
if (r.level === 'place') return place !== null && r.place === place;
|
|
865
869
|
return true;
|
|
866
870
|
}).sort((a, b) => LEVEL_RANK[a.level] - LEVEL_RANK[b.level] || byRank(a, b));
|
|
@@ -869,7 +873,7 @@ export function readableRows(ledger, { workflow, place, specHash = null, now })
|
|
|
869
873
|
/**
|
|
870
874
|
* THE one render: the block the PLANNER reads at draft and at the first replan. Byte-for-byte reproducible from the
|
|
871
875
|
* ledger as it stood. Stops at 2,000 characters; a hint is added whole or not at all; nothing readable -> empty text.
|
|
872
|
-
* @param {Ledger} ledger @param {{workflow: string, place: string|null,
|
|
876
|
+
* @param {Ledger} ledger @param {{workflow: string, place: string|null, workflowKey?: string|null, now: Date}} o
|
|
873
877
|
* @returns {{text: string, ids: string[]}}
|
|
874
878
|
*/
|
|
875
879
|
export function renderHints(ledger, o) {
|
|
@@ -901,6 +905,16 @@ export function renderHints(ledger, o) {
|
|
|
901
905
|
|
|
902
906
|
const HINT_HEAD_RE = /^(\d+)\. \[(this job|this place|all jobs), seen (\d+) times?\] (.*)$/;
|
|
903
907
|
|
|
908
|
+
/**
|
|
909
|
+
* The one plain-words line for a learnings file that could not be read (the Audit prints it; the spine keeps the full
|
|
910
|
+
* reason). The person's home folder is written `~`, so the line stays short and the file can still be found.
|
|
911
|
+
* @param {string} reason @param {string} [userHome] defaults to the OS home @returns {string}
|
|
912
|
+
*/
|
|
913
|
+
export function hintsErrorLine(reason, userHome = homedir()) {
|
|
914
|
+
const short = userHome.length > 1 ? reason.split(`${userHome}/`).join('~/') : reason;
|
|
915
|
+
return `The learnings file could not be read, so no lessons were given: ${short}`;
|
|
916
|
+
}
|
|
917
|
+
|
|
904
918
|
/**
|
|
905
919
|
* Split a block {@link renderHints} wrote back into its hints. The ONLY reader of that text: it lives beside the
|
|
906
920
|
* writer ({@link hintText}, {@link lessonOf}) and a test renders real blocks and parses them back. A hint it cannot
|
package/src/learnstore.js
CHANGED
|
@@ -9,6 +9,7 @@ import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, writeFil
|
|
|
9
9
|
import { join, dirname } from 'node:path';
|
|
10
10
|
import { keysHome } from './keysfile.js';
|
|
11
11
|
import { readConfig } from './config.js';
|
|
12
|
+
import { redactSecrets } from './validate.js';
|
|
12
13
|
import { emptyLedger, redactDeep, countLedger, releasePending, recordHealth, buildCards, placeOf, renderHints } from './learn.js';
|
|
13
14
|
import { stageQuestionsByName } from './stagewords.js';
|
|
14
15
|
|
|
@@ -59,15 +60,15 @@ export function writeLedger(ledger, home) {
|
|
|
59
60
|
/**
|
|
60
61
|
* Fold ONE finished run into the ledger on disk: every run's cards COUNT now, rubric jobs too (trust kept on new rows;
|
|
61
62
|
* v1.112). `held` is always 0 (kept in the shape for callers). The run's health line is recorded. Never throws on a bad ledger file: it reports `problem` and writes nothing.
|
|
62
|
-
* @param {{home?: string, runid: string, build: import('./learn.js').CardBuild, workflow: string, place: string|null, specHash: string|null, trust: 'deterministic'|'rubric', at: string, now?: Date}} o
|
|
63
|
+
* @param {{home?: string, runid: string, build: import('./learn.js').CardBuild, workflow: string, place: string|null, specHash: string|null, workflowKey?: string|null, trust: 'deterministic'|'rubric', at: string, now?: Date}} o
|
|
63
64
|
* @returns {{wrote: boolean, counted: number, held: number, problem: string|null}}
|
|
64
65
|
*/
|
|
65
|
-
export function foldRunIntoLedger({ home, runid, build, workflow, place, specHash, trust, at, now = new Date() }) {
|
|
66
|
+
export function foldRunIntoLedger({ home, runid, build, workflow, place, specHash, workflowKey = null, trust, at, now = new Date() }) {
|
|
66
67
|
const cur = readLedger(home);
|
|
67
68
|
if (cur.problem) return { wrote: false, counted: 0, held: 0, problem: cur.problem };
|
|
68
69
|
let L = cur.ledger;
|
|
69
70
|
const before = L.rows.reduce((n, r) => n + r.runIds.filter((x) => x === runid).length, 0);
|
|
70
|
-
L = countLedger(L, { runid, cards: build.cards, workflow, place, specHash, trust, now });
|
|
71
|
+
L = countLedger(L, { runid, cards: build.cards, workflow, place, specHash, workflowKey, trust, now });
|
|
71
72
|
const counted = L.rows.reduce((n, r) => n + r.runIds.filter((x) => x === runid).length, 0) - before;
|
|
72
73
|
L = recordHealth(L, runid, build, at, now);
|
|
73
74
|
writeLedger(L, home);
|
|
@@ -88,14 +89,14 @@ export function releaseRun({ home, runid, now = new Date() }) {
|
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
/**
|
|
91
|
-
* The ONE setting: `learningHints` in config.json. Ships
|
|
92
|
-
*
|
|
92
|
+
* The ONE setting: `learningHints` in config.json. Ships ON (hamr 2026-10-24): absent = on; only an explicit `false` turns it off. OFF still writes
|
|
93
|
+
* the tally ($0) and the planner is simply handed nothing. An unreadable config reads as OFF (the safe side).
|
|
93
94
|
* @param {string} [home]
|
|
94
95
|
* @returns {boolean}
|
|
95
96
|
*/
|
|
96
97
|
export function learningHintsOn(home) {
|
|
97
98
|
const c = readConfig({ home });
|
|
98
|
-
return c.problem === null && c.config.learningHints
|
|
99
|
+
return c.problem === null && c.config.learningHints !== false;
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
/** @param {string} p @returns {any[]} the parsed rows of a JSONL file; missing or torn lines are skipped */
|
|
@@ -118,29 +119,44 @@ const realOr = (p) => { try { return realpathSync(p); } catch { return p; } };
|
|
|
118
119
|
* ledger (a rubric job's count too, trust kept). Called once from the one engine's run-end block (src/userrun.js
|
|
119
120
|
* `execute`, shared by the panel, the CLI and the bundle runner), inside its own try/catch: it is a record, never a verdict,
|
|
120
121
|
* and can never change a run's outcome, exit code or spend. It runs whether the hints setting is on or off.
|
|
121
|
-
* @param {{home?: string, runid: string, events: any[], auditFiles?: string[], spec: any, specHash: string|null, workdir: string|null, trust: 'deterministic'|'rubric', now?: Date}} o
|
|
122
|
+
* @param {{home?: string, runid: string, events: any[], auditFiles?: string[], spec: any, specHash: string|null, workflowKey?: string|null, workdir: string|null, trust: 'deterministic'|'rubric', now?: Date}} o
|
|
122
123
|
* @returns {{wrote: boolean, counted: number, held: number, problem: string|null, noise: string|null, cards: number}}
|
|
123
124
|
*/
|
|
124
|
-
export function learnAtRunEnd({ home, runid, events, auditFiles = [], spec, specHash, workdir, trust, now = new Date() }) {
|
|
125
|
+
export function learnAtRunEnd({ home, runid, events, auditFiles = [], spec, specHash, workflowKey = null, workdir, trust, now = new Date() }) {
|
|
125
126
|
const audit = auditFiles.flatMap(readJsonl);
|
|
126
127
|
const build = buildCards({ runid, events, audit, workdir, spec, questions: stageQuestionsByName(spec) });
|
|
127
128
|
const at = events.findLast((e) => e?.type === 'job-end')?.ts ?? now.toISOString();
|
|
128
129
|
const r = foldRunIntoLedger({
|
|
129
|
-
home, runid, build, workflow: String(spec.job), place: placeOf(spec, realOr), specHash, trust, at, now,
|
|
130
|
+
home, runid, build, workflow: String(spec.job), place: placeOf(spec, realOr), specHash, workflowKey, trust, at, now,
|
|
130
131
|
});
|
|
131
132
|
return { ...r, noise: build.noise, cards: build.cards.length };
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
/**
|
|
135
136
|
* The block the planner is handed for this job, made ONCE at run start from the ledger as it stood — empty when the
|
|
136
|
-
* setting is off, when there is no ledger, or when
|
|
137
|
-
*
|
|
137
|
+
* setting is off, when there is no ledger, or when no lesson fits; an unreadable ledger THROWS (use {@link handedHints}, which
|
|
138
|
+
* hands nothing and keeps the reason). The one `renderHints` render, never a second.
|
|
139
|
+
* @param {{home?: string, spec: any, workflowKey?: string|null, now?: Date}} o
|
|
138
140
|
* @returns {{text: string, ids: string[]}|null}
|
|
139
141
|
*/
|
|
140
|
-
export function hintsForRun({ home, spec,
|
|
142
|
+
export function hintsForRun({ home, spec, workflowKey = null, now = new Date() }) {
|
|
141
143
|
if (!learningHintsOn(home)) return null;
|
|
142
144
|
const cur = readLedger(home);
|
|
143
|
-
if (cur.problem)
|
|
144
|
-
const r = renderHints(cur.ledger, { workflow: String(spec.job), place: placeOf(spec, realOr),
|
|
145
|
+
if (cur.problem) throw new Error(cur.problem); // an unreadable ledger is never the same as "no lessons yet": the caller hands nothing AND records why
|
|
146
|
+
const r = renderHints(cur.ledger, { workflow: String(spec.job), place: placeOf(spec, realOr), workflowKey, now });
|
|
145
147
|
return r.text ? r : null;
|
|
146
148
|
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* {@link hintsForRun} for the engine: never throws. A broken ledger hands the planner nothing and the reason comes back
|
|
152
|
+
* (first line, secrets masked) so the run records it beside the hints; the run itself goes on.
|
|
153
|
+
* @param {{home?: string, spec: any, workflowKey?: string|null, now?: Date}} o
|
|
154
|
+
* @returns {{hints: {text: string, ids: string[]}|null, error: string|null}}
|
|
155
|
+
*/
|
|
156
|
+
export function handedHints(o) {
|
|
157
|
+
try {
|
|
158
|
+
return { hints: hintsForRun(o), error: null };
|
|
159
|
+
} catch (/** @type {any} */ e) {
|
|
160
|
+
return { hints: null, error: redactSecrets(String(e?.message ?? e)).split('\n')[0] };
|
|
161
|
+
}
|
|
162
|
+
}
|
package/src/pagedropwords.js
CHANGED
|
@@ -22,6 +22,7 @@ const WORDS = /** @type {Record<string, (d: Dropped) => string>} */ ({
|
|
|
22
22
|
'limit-unit': (d) => `Only the first 10 units are used; "${d.word}" was left out.`,
|
|
23
23
|
'unit-too-long': (d) => `"${d.word}" is longer than 100 characters, so it was not used.`,
|
|
24
24
|
'reads-no-result': () => "the price rule could not read a price in the page's results, so it is not checked.",
|
|
25
|
+
'reads-no-time': (d) => `the page never shows a time right after "${d.other}", so it is not checked.`,
|
|
25
26
|
'phrase-no-result': (d) => `"${d.other}" is on the page but in none of its results, so it is not checked.`,
|
|
26
27
|
'person-left': () => 'You chose to leave it Not checked.',
|
|
27
28
|
'bad-shape': (d) => `The AI named a kind of value for "${d.fact}" that a check cannot read.`,
|