bareloop 0.55.0 → 0.56.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 +47 -0
- package/bareloop.context.md +4 -2
- package/package.json +2 -2
- package/src/authorflow.js +141 -264
- package/src/authoring.js +2 -3
- package/src/authorjob.js +117 -88
- package/src/authorreadout.js +9 -15
- package/src/authorrun.js +13 -4
- package/src/behaviour.js +14 -0
- package/src/blockasks.js +43 -0
- package/src/checkblock.js +772 -0
- package/src/checklist.js +128 -0
- package/src/checkpick.js +30 -312
- package/src/checkwords.js +3 -1
- package/src/declaredclose.js +30 -1
- package/src/destpoint.js +3 -1
- package/src/draftspend.js +46 -0
- package/src/facts.js +8 -1
- package/src/fitcheck.js +5 -3
- package/src/pagemap.js +15 -3
- package/src/panel/authorroutes.js +15 -3
- package/src/panel/authorsession.js +133 -46
- package/src/panel/index.html +194 -22
- package/src/panel/jobplan.js +85 -33
- package/src/panel/server.js +52 -7
- package/src/pickrecord.js +19 -1
- package/src/placerule.js +355 -0
- package/src/promptregisters.js +11 -0
- package/src/questionbox.js +112 -0
- package/src/rowedit.js +115 -0
- package/src/rubricstep.js +212 -125
- package/src/run.js +10 -2
- package/src/userrun.js +46 -1
- package/types/authorflow.d.ts +32 -139
- package/types/authorjob.d.ts +24 -6
- package/types/authorreadout.d.ts +4 -10
- package/types/behaviour.d.ts +12 -0
- package/types/blockasks.d.ts +37 -0
- package/types/checkblock.d.ts +361 -0
- package/types/checklist.d.ts +134 -0
- package/types/checkpick.d.ts +3 -140
- package/types/declaredclose.d.ts +4 -0
- package/types/destpoint.d.ts +2 -0
- package/types/draftspend.d.ts +21 -0
- package/types/fitcheck.d.ts +7 -1
- package/types/pagemap.d.ts +4 -0
- package/types/panel/authorsession.d.ts +13 -2
- package/types/panel/jobgrid.d.ts +8 -8
- package/types/panel/jobplan.d.ts +48 -10
- package/types/panel/server.d.ts +14 -13
- package/types/pickrecord.d.ts +12 -0
- package/types/placerule.d.ts +194 -0
- package/types/questionbox.d.ts +87 -0
- package/types/rowedit.d.ts +32 -0
- package/types/rubricstep.d.ts +91 -48
- package/types/run.d.ts +10 -1
package/src/draftspend.js
CHANGED
|
@@ -280,6 +280,51 @@ export function readDraftChecks(dir) {
|
|
|
280
280
|
return out;
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
+
/**
|
|
284
|
+
* The suggested checks code could not build, one plain sentence each (the last `draft-notbuilt` line of the log): the Audit's draft lines. `[]` when there are none.
|
|
285
|
+
* @param {string} dir
|
|
286
|
+
* @returns {{line: number, text: string}[]}
|
|
287
|
+
*/
|
|
288
|
+
export function readDraftNotBuilt(dir) {
|
|
289
|
+
/** @type {string} */
|
|
290
|
+
let text;
|
|
291
|
+
try { text = readFileSync(join(dir, DRAFT_LOG_FILE), 'utf8'); } catch { return []; }
|
|
292
|
+
/** @type {{line: number, text: string}[]} */
|
|
293
|
+
let out = [];
|
|
294
|
+
for (const line of text.split('\n')) {
|
|
295
|
+
if (!line.includes('"draft-notbuilt"')) continue;
|
|
296
|
+
try {
|
|
297
|
+
const ev = JSON.parse(line);
|
|
298
|
+
if (ev?.kind === 'draft-notbuilt' && Array.isArray(ev.rows)) out = ev.rows.filter((/** @type {any} */ c) => c && Number.isInteger(c.line) && typeof c.text === 'string');
|
|
299
|
+
} catch { /* a torn line */ }
|
|
300
|
+
}
|
|
301
|
+
return out;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The check list's rows as the drafting ended (draft log `ledger` rows of phase `final`, the last one per key): each row's own words, so the Job tab can name a
|
|
306
|
+
* Not checked row in the person's words. `null` when the session has no readable log or no final row (a CLI run, an imported run, a deleted session). Never throws.
|
|
307
|
+
* @param {string} dir
|
|
308
|
+
* @returns {{key: string, rowKind: string, words: string[], state: string}[]|null}
|
|
309
|
+
*/
|
|
310
|
+
export function readDraftLedger(dir) {
|
|
311
|
+
/** @type {string} */
|
|
312
|
+
let text;
|
|
313
|
+
try { text = readFileSync(join(dir, DRAFT_LOG_FILE), 'utf8'); } catch { return null; }
|
|
314
|
+
/** @type {Map<string, {key: string, rowKind: string, words: string[], state: string}>} */
|
|
315
|
+
const byKey = new Map();
|
|
316
|
+
for (const line of text.split('\n')) {
|
|
317
|
+
if (!line.includes('"ledger"')) continue;
|
|
318
|
+
try {
|
|
319
|
+
const ev = JSON.parse(line);
|
|
320
|
+
if (ev?.kind === 'ledger' && ev.phase === 'final' && typeof ev.key === 'string') {
|
|
321
|
+
byKey.set(ev.key, { key: ev.key, rowKind: String(ev.rowKind), words: Array.isArray(ev.words) ? ev.words.filter((/** @type {any} */ w) => typeof w === 'string' && w) : [], state: String(ev.state) });
|
|
322
|
+
}
|
|
323
|
+
} catch { /* a torn line */ }
|
|
324
|
+
}
|
|
325
|
+
return byKey.size ? [...byKey.values()] : null;
|
|
326
|
+
}
|
|
327
|
+
|
|
283
328
|
/**
|
|
284
329
|
* The DRAFTING PART of a run (hamr 2026-10-06, option A): the first part of the run's views, built from the session's
|
|
285
330
|
* drafting log. `null` when the run did not come out of a panel session, or the log carries no metered call (a Reuse
|
|
@@ -307,5 +352,6 @@ export function draftingPartFor(row, spine, opts = {}) {
|
|
|
307
352
|
draftSteps: steps,
|
|
308
353
|
draftLabel: readDraftLabel(dir),
|
|
309
354
|
draftChecks: readDraftChecks(dir),
|
|
355
|
+
draftNotBuilt: readDraftNotBuilt(dir),
|
|
310
356
|
};
|
|
311
357
|
}
|
package/src/facts.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// the check. The claim TEXT that bareguard's number scan reads is written by code from the values, never by the worker.
|
|
11
11
|
|
|
12
12
|
import { rubricVocabulary } from 'bareguard';
|
|
13
|
+
import { placeRuleProblem } from './placerule.js';
|
|
13
14
|
|
|
14
15
|
/** the shapes a fact may have (bareguard's value kinds, plus `phrase` = a presence decide) */
|
|
15
16
|
export const FACT_SHAPES = Object.freeze(['money', 'number', 'date', 'time', 'phrase', 'text']);
|
|
@@ -18,7 +19,7 @@ export const FACT_OPS = Object.freeze(['lt', 'lte', 'gt', 'gte', 'between']);
|
|
|
18
19
|
/** bareguard signs at most this many decides on one `cited` check */
|
|
19
20
|
export const MAX_FACTS = 10;
|
|
20
21
|
/** every field a fact may carry */
|
|
21
|
-
const FACT_FIELDS = Object.freeze(['name', 'shape', 'unit', 'currency', 'phrase', 'anchor', 'until', 'rule', 'aiProposal', 'lang', 'decimal']);
|
|
22
|
+
const FACT_FIELDS = Object.freeze(['name', 'shape', 'unit', 'currency', 'phrase', 'anchor', 'until', 'rule', 'aiProposal', 'lang', 'decimal', 'place']);
|
|
22
23
|
/** the languages whose month names bareguard 0.27 reads on a `date` fact (its `lang`), each with the name a person reads; absent `lang` = ISO YYYY-MM-DD only */
|
|
23
24
|
export const FACT_LANGS = Object.freeze({ en: 'English', de: 'German', fr: 'French', es: 'Spanish', it: 'Italian', pt: 'Portuguese', nl: 'Dutch' });
|
|
24
25
|
/** the decimal marks a number or money fact may sign (bareguard 0.27 `decimal`); absent = "." */
|
|
@@ -124,6 +125,10 @@ export function factShapeReds(part, w, red) {
|
|
|
124
125
|
if (!nonEmpty(f.phrase)) red('invalid-value', `${fw}.phrase`, 'the fixed words the quote must contain, copied from the input');
|
|
125
126
|
for (const k of ['anchor', 'until', 'rule']) if (has(k)) red('invalid-value', `${fw}.${k}`, 'a phrase is fixed words the quote must contain; it has no anchor, until or rule');
|
|
126
127
|
} else if (has('phrase')) red('invalid-value', `${fw}.phrase`, 'only a phrase fact carries phrase');
|
|
128
|
+
if (has('place')) {
|
|
129
|
+
const bad = f.shape === 'phrase' ? placeRuleProblem(f.place) : 'only a phrase fact carries a place rule';
|
|
130
|
+
if (bad !== null) red('invalid-value', `${fw}.place`, bad);
|
|
131
|
+
}
|
|
127
132
|
if (has('anchor') && !nonEmpty(f.anchor)) red('invalid-value', `${fw}.anchor`, 'a label copied VERBATIM from the input');
|
|
128
133
|
if (has('until') && !nonEmpty(f.until)) red('invalid-value', `${fw}.until`, 'a label copied VERBATIM from the input');
|
|
129
134
|
if (has('until') && !has('anchor') && f.shape !== 'phrase') red('invalid-value', `${fw}.until`, 'until needs an anchor');
|
|
@@ -257,6 +262,8 @@ export function ruleWords(f) {
|
|
|
257
262
|
* @returns {string}
|
|
258
263
|
*/
|
|
259
264
|
export function factSentence(f, source) {
|
|
265
|
+
// PLACE RULES: a check that reads WHERE the newest value sits, not what it is; the phrase shown is the signed drafting example (the value a run read is in its Audit)
|
|
266
|
+
if (f.shape === 'phrase' && isRec(f.place)) return `${f.place.kind === 'headingDateAfter' ? 'date' : 'version'} in the newest "${f.place.prefix}" heading (last read ${f.phrase})`;
|
|
260
267
|
/** @type {string[]} */
|
|
261
268
|
const bits = [];
|
|
262
269
|
if (f.shape === 'phrase') bits.push('phrase', `must say "${f.phrase}"`);
|
package/src/fitcheck.js
CHANGED
|
@@ -91,12 +91,14 @@ export const notFoundList = (notFound) => notFound.map((x) => `${x.ask} (line ${
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* The one question, worded by code.
|
|
94
|
-
* @param {{found: number, total: number, notFound: {line: number, ask: string}[]}} o
|
|
94
|
+
* @param {{found: number, total: number, notFound: {line: number, ask: string}[], foundAsks?: {line: number, ask: string}[]}} o
|
|
95
95
|
* @returns {string}
|
|
96
96
|
*/
|
|
97
|
-
export const fitQuestionText = ({ found, total, notFound }) => redactSecrets(
|
|
98
|
-
`I found ${found} of ${total} of your asks on this page.
|
|
97
|
+
export const fitQuestionText = ({ found, total, notFound, foundAsks = [] }) => redactSecrets(
|
|
98
|
+
`I found ${found} of ${total} of your asks on this page${found > 0 && foundAsks.length ? `: ${notFoundList(foundAsks)}` : ''}. Not found: ${notFoundList(notFound)}.${FIT_ANSWER}`,
|
|
99
99
|
);
|
|
100
|
+
/** the answer words the question ends with (said once, here; the panel's question box shows the question without them and has the buttons instead) */
|
|
101
|
+
export const FIT_ANSWER = ' Type go on to keep drafting, or anything else to stop and change the job or the page.';
|
|
100
102
|
|
|
101
103
|
/** the default loop seam - one spelling of how this repo drives a model */
|
|
102
104
|
const defaultLoop = (/** @type {any} */ { system, onLlmResult, provider, rates }) =>
|
package/src/pagemap.js
CHANGED
|
@@ -221,9 +221,18 @@ export const stripAgreeLead = (text) => {
|
|
|
221
221
|
|
|
222
222
|
/** the words of a reading ask: the ONE spelling, and {@link readingOfQuestion} reads it back (the Result tab's "(you confirmed)") */
|
|
223
223
|
const READING_HEAD = ' I read it as: ';
|
|
224
|
-
const
|
|
224
|
+
const READING_ASKED = '. Agree?';
|
|
225
|
+
/** the part of a reading ask that tells the CLI's typed words (the panel's question box shows the question without it: src/questionbox.js) */
|
|
226
|
+
const READING_ANSWER = ' Answer "agree"';
|
|
227
|
+
const READING_TAIL = `${READING_ASKED}${READING_ANSWER}`;
|
|
228
|
+
/** @param {number} n @returns {string} the rest of a reading ask after its answer words */
|
|
229
|
+
const readingRest = (n) => `, or type your own reading (your answer is added as a new ~ rule on line ${n}).`;
|
|
230
|
+
/** @param {number} n @returns {string} the answer words a reading ask ends with (said once, here, and cut in the panel) */
|
|
231
|
+
export const readingTail = (n) => `${READING_ANSWER}${readingRest(n)}`;
|
|
232
|
+
/** @param {number} n @returns {string} the answer words a can't-check ask ends with (said once, here, and cut in the panel) */
|
|
233
|
+
export const cantCheckTail = (n) => ` Answer "${DROP_IT}", or type how to check it (your answer is added as a new ~ rule on line ${n}).`;
|
|
225
234
|
/** @param {number} n @param {string} rule @param {string} reading @returns {string} */
|
|
226
|
-
const readingQuestion = (n, rule, reading) => `Your line ${n} says "${rule}".${READING_HEAD}${reading}${READING_TAIL}
|
|
235
|
+
export const readingQuestion = (n, rule, reading) => `Your line ${n} says "${rule}".${READING_HEAD}${reading}${READING_TAIL}${readingRest(n)}`;
|
|
227
236
|
/** @param {unknown} q a recorded question @returns {string|null} the reading a reading ask proposed, or null when it was another kind of question */
|
|
228
237
|
export function readingOfQuestion(q) {
|
|
229
238
|
const s = String(q ?? '');
|
|
@@ -232,6 +241,9 @@ export function readingOfQuestion(q) {
|
|
|
232
241
|
return a >= 0 && b > a ? s.slice(a + READING_HEAD.length, b) : null;
|
|
233
242
|
}
|
|
234
243
|
|
|
244
|
+
/** @param {number} n @param {string} rule @returns {string} the can't-check ask of a rule the page cannot check */
|
|
245
|
+
export const cantCheckQuestion = (n, rule) => `Your line ${n} says "${rule}". I can't check this on the page. Drop it?${cantCheckTail(n)}`;
|
|
246
|
+
|
|
235
247
|
/**
|
|
236
248
|
* PRD v1.107 Part 5b ("the look reads, code asks"): the early asks CODE forces before any paid drafting, from the look's own result. Every `~` rule is
|
|
237
249
|
* one of three kinds:
|
|
@@ -277,7 +289,7 @@ export function askableFromLook(look, jobLines) {
|
|
|
277
289
|
seen.add(key);
|
|
278
290
|
cants.push({
|
|
279
291
|
line: l.n, rule: n, source: 'look', ask: 'cant-check', ruleText: rule,
|
|
280
|
-
question:
|
|
292
|
+
question: cantCheckQuestion(l.n, rule),
|
|
281
293
|
});
|
|
282
294
|
});
|
|
283
295
|
}
|
|
@@ -22,7 +22,7 @@ import { spawn as realSpawn } from 'node:child_process';
|
|
|
22
22
|
import { openSync, existsSync } from 'node:fs';
|
|
23
23
|
import { join } from 'node:path';
|
|
24
24
|
import { readFileSync } from 'node:fs';
|
|
25
|
-
import { planMatchesClose } from '../rubricstep.js';
|
|
25
|
+
import { planMatchesClose, listMatchesClose } from '../rubricstep.js';
|
|
26
26
|
import { ticketNumberOf } from '../ticketshape.js';
|
|
27
27
|
import { newestUnrunTicket } from '../ticketnext.js';
|
|
28
28
|
import { readRunList } from '../runlist.js';
|
|
@@ -48,6 +48,7 @@ import { thinkingForLine } from '../thinking.js';
|
|
|
48
48
|
import { panelMoney2 } from '../panelmoney.js';
|
|
49
49
|
import { apiKeyProblem, checkProviderReachable } from '../providers.js';
|
|
50
50
|
import { reviseRefusal, sessionsRootOf } from '../revises.js';
|
|
51
|
+
import { CHOICE_SAYS } from '../questionbox.js';
|
|
51
52
|
|
|
52
53
|
/** @returns {string} a fresh per-process token — never persisted, never logged */
|
|
53
54
|
export function mintToken() {
|
|
@@ -432,7 +433,7 @@ export function createAuthorRoutes(opts) {
|
|
|
432
433
|
return true;
|
|
433
434
|
}
|
|
434
435
|
|
|
435
|
-
const m = /^\/api\/author\/([A-Za-z0-9]+)(\/(send|sign-prepare|sign|check-deps|abandon))?$/.exec(pathname);
|
|
436
|
+
const m = /^\/api\/author\/([A-Za-z0-9]+)(\/(send|sign-prepare|sign|check-deps|abandon|row-edit))?$/.exec(pathname);
|
|
436
437
|
if (!m) { send(404, { ok: false, error: 'not found' }); return true; }
|
|
437
438
|
const session = sessions.get(m[1]);
|
|
438
439
|
if (!session) { send(404, { ok: false, error: 'no such session' }); return true; }
|
|
@@ -447,7 +448,9 @@ export function createAuthorRoutes(opts) {
|
|
|
447
448
|
if (req.method !== 'POST') { send(405, { ok: false, error: 'POST only' }); return true; }
|
|
448
449
|
|
|
449
450
|
if (sub === 'send') {
|
|
450
|
-
|
|
451
|
+
// hamr 2026-11-12 (fwd M10 am32 A): while a question is open the page always posts the button's typed choice; an answer with none is from an old page and is refused, nothing logged, the question stays open
|
|
452
|
+
if (session.state.pendingAsk?.kind === 'answer' && body?.choice === undefined) { send(400, { ok: false, refused: 'bad-choice', error: CHOICE_SAYS.outOfDate, state: session.state }); return true; }
|
|
453
|
+
const r =session.send(String(body?.text ?? ''), body?.choice);
|
|
451
454
|
send(r.ok ? 200 : 400, { ...r, state: session.state });
|
|
452
455
|
return true;
|
|
453
456
|
}
|
|
@@ -464,6 +467,12 @@ export function createAuthorRoutes(opts) {
|
|
|
464
467
|
send(r.ok ? 200 : 400, { ...r, state: session.state });
|
|
465
468
|
return true;
|
|
466
469
|
}
|
|
470
|
+
if (sub === 'row-edit') {
|
|
471
|
+
// hamr 2026-11-13 (N-2): the confirm card's Drop / Add. $0 and instant: a row edit through the live check block, never a model call
|
|
472
|
+
const r = session.rowEdit(body?.op, body?.key);
|
|
473
|
+
send(r.ok ? 200 : 400, { ...r, state: session.state });
|
|
474
|
+
return true;
|
|
475
|
+
}
|
|
467
476
|
if (sub === 'sign-prepare') {
|
|
468
477
|
const r = session.signPrepare();
|
|
469
478
|
send(r.ok ? 200 : 400, { ...r, state: session.state });
|
|
@@ -523,6 +532,9 @@ export function signRun(session, claimedHash, o) {
|
|
|
523
532
|
const spec = JSON.parse(readFileSync(session.state.resolvedSpecPath, 'utf8'));
|
|
524
533
|
const m = planMatchesClose(session.state.finalPlan.checkItems, spec.closeDecl);
|
|
525
534
|
if (!m.ok) return { ok: false, error: m.error };
|
|
535
|
+
// B2: a close that carries the one check list must agree with it: every built row points at a check the close runs, and every check has a row
|
|
536
|
+
const lm = listMatchesClose(spec.closeDecl);
|
|
537
|
+
if (!lm.ok) return { ok: false, error: lm.error };
|
|
526
538
|
} catch { return { ok: false, error: 'could not read the signed spec to compare it with the plan you were shown — refusing to sign' }; }
|
|
527
539
|
}
|
|
528
540
|
// PIECE 9 (R7): the Schedule the card picked is signed WITH the job it is a field of (`spec.trigger`), written OFF beside the run about to start; the first green run turns it on. Before the
|