bareloop 0.54.1 → 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.
Files changed (149) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/bareloop.context.md +67 -6
  3. package/package.json +3 -3
  4. package/src/authorflow.js +217 -238
  5. package/src/authoring.js +22 -6
  6. package/src/authorjob.js +138 -30
  7. package/src/authorreadout.js +15 -4
  8. package/src/authorrun.js +13 -4
  9. package/src/authorscout.js +9 -6
  10. package/src/behaviour.js +14 -0
  11. package/src/blockasks.js +43 -0
  12. package/src/cardschedule.js +42 -0
  13. package/src/checkblock.js +772 -0
  14. package/src/checklist.js +128 -0
  15. package/src/checkpick.js +294 -0
  16. package/src/checksuggest.js +28 -0
  17. package/src/checkwords.js +27 -0
  18. package/src/cli.js +1 -1
  19. package/src/config.js +24 -1
  20. package/src/declaredclose.js +30 -1
  21. package/src/destpoint.js +151 -0
  22. package/src/draftspend.js +85 -0
  23. package/src/facts.js +8 -1
  24. package/src/factwords.js +14 -1
  25. package/src/fitcheck.js +5 -3
  26. package/src/job.js +81 -1
  27. package/src/jobblock.js +9 -0
  28. package/src/labelscan.js +11 -0
  29. package/src/launcher.js +3 -2
  30. package/src/mcpchecks.js +52 -0
  31. package/src/mcppick.js +36 -0
  32. package/src/mcpsources.js +77 -0
  33. package/src/mcpuse.js +97 -0
  34. package/src/natural.js +23 -0
  35. package/src/pagemap.js +20 -5
  36. package/src/panel/authorroutes.js +105 -18
  37. package/src/panel/authorsession.js +293 -44
  38. package/src/panel/index.html +873 -41
  39. package/src/panel/jobgrid.js +117 -0
  40. package/src/panel/jobplan.js +103 -35
  41. package/src/panel/scheduler.js +80 -13
  42. package/src/panel/schedules.js +189 -28
  43. package/src/panel/schedulestart.js +44 -13
  44. package/src/panel/server.js +471 -39
  45. package/src/panel/settingsroutes.js +133 -3
  46. package/src/panel/status.js +19 -1
  47. package/src/panel/tickets.js +44 -0
  48. package/src/pickrecord.js +163 -0
  49. package/src/placerule.js +355 -0
  50. package/src/plan.js +31 -2
  51. package/src/planrun.js +71 -15
  52. package/src/prcheckout.js +259 -0
  53. package/src/promptregisters.js +11 -0
  54. package/src/questionbox.js +112 -0
  55. package/src/readshim.js +3 -2
  56. package/src/revises.js +56 -0
  57. package/src/rowedit.js +115 -0
  58. package/src/rubricstep.js +265 -132
  59. package/src/run.js +19 -2
  60. package/src/runexport.js +2 -0
  61. package/src/runlist.js +3 -2
  62. package/src/schedulewords.js +46 -4
  63. package/src/source.js +81 -7
  64. package/src/stepmcp.js +86 -0
  65. package/src/ticket.js +113 -0
  66. package/src/ticketfilter.js +76 -0
  67. package/src/ticketlabels.js +79 -0
  68. package/src/ticketmcp.js +111 -0
  69. package/src/ticketnext.js +35 -0
  70. package/src/ticketrepo.js +98 -0
  71. package/src/ticketschedule.js +32 -0
  72. package/src/ticketshape.js +45 -0
  73. package/src/tools.js +9 -0
  74. package/src/trigger.js +14 -2
  75. package/src/triggerclock.js +7 -3
  76. package/src/triggerfiles.js +19 -11
  77. package/src/triggertickets.js +244 -0
  78. package/src/userrun.js +191 -10
  79. package/src/validate.js +3 -1
  80. package/src/worktree.js +43 -1
  81. package/types/authorflow.d.ts +86 -93
  82. package/types/authorjob.d.ts +35 -4
  83. package/types/authorreadout.d.ts +4 -3
  84. package/types/authorscout.d.ts +4 -2
  85. package/types/behaviour.d.ts +12 -0
  86. package/types/blockasks.d.ts +37 -0
  87. package/types/cardschedule.d.ts +24 -0
  88. package/types/checkblock.d.ts +361 -0
  89. package/types/checklist.d.ts +134 -0
  90. package/types/checkpick.d.ts +160 -0
  91. package/types/checksuggest.d.ts +30 -0
  92. package/types/checkwords.d.ts +14 -0
  93. package/types/config.d.ts +7 -0
  94. package/types/declaredclose.d.ts +4 -0
  95. package/types/destpoint.d.ts +89 -0
  96. package/types/draftspend.d.ts +37 -0
  97. package/types/factwords.d.ts +7 -0
  98. package/types/fitcheck.d.ts +7 -1
  99. package/types/job.d.ts +13 -0
  100. package/types/jobblock.d.ts +9 -0
  101. package/types/labelscan.d.ts +7 -0
  102. package/types/launcher.d.ts +2 -2
  103. package/types/mcpchecks.d.ts +8 -0
  104. package/types/mcppick.d.ts +33 -0
  105. package/types/mcpsources.d.ts +51 -0
  106. package/types/mcpuse.d.ts +15 -0
  107. package/types/natural.d.ts +2 -0
  108. package/types/pagemap.d.ts +6 -1
  109. package/types/panel/authorroutes.d.ts +11 -2
  110. package/types/panel/authorsession.d.ts +69 -3
  111. package/types/panel/jobgrid.d.ts +405 -0
  112. package/types/panel/jobplan.d.ts +55 -11
  113. package/types/panel/scheduler.d.ts +7 -2
  114. package/types/panel/schedules.d.ts +124 -4
  115. package/types/panel/schedulestart.d.ts +21 -3
  116. package/types/panel/server.d.ts +432 -10
  117. package/types/panel/settingsroutes.d.ts +4 -2
  118. package/types/panel/status.d.ts +16 -2
  119. package/types/panel/tickets.d.ts +61 -0
  120. package/types/pickrecord.d.ts +100 -0
  121. package/types/placerule.d.ts +194 -0
  122. package/types/plan.d.ts +1 -0
  123. package/types/prcheckout.d.ts +151 -0
  124. package/types/questionbox.d.ts +87 -0
  125. package/types/readshim.d.ts +4 -3
  126. package/types/revises.d.ts +23 -0
  127. package/types/rowedit.d.ts +32 -0
  128. package/types/rubricstep.d.ts +100 -48
  129. package/types/run.d.ts +27 -1
  130. package/types/runlist.d.ts +6 -3
  131. package/types/schedulewords.d.ts +29 -2
  132. package/types/source.d.ts +40 -4
  133. package/types/stepmcp.d.ts +40 -0
  134. package/types/ticket.d.ts +114 -0
  135. package/types/ticketfilter.d.ts +34 -0
  136. package/types/ticketlabels.d.ts +44 -0
  137. package/types/ticketmcp.d.ts +84 -0
  138. package/types/ticketnext.d.ts +33 -0
  139. package/types/ticketrepo.d.ts +118 -0
  140. package/types/ticketschedule.d.ts +21 -0
  141. package/types/ticketshape.d.ts +37 -0
  142. package/types/tools.d.ts +1 -0
  143. package/types/trigger.d.ts +9 -1
  144. package/types/triggerclock.d.ts +6 -2
  145. package/types/triggerfiles.d.ts +13 -5
  146. package/types/triggertickets.d.ts +110 -0
  147. package/types/userrun.d.ts +50 -0
  148. package/types/validate.d.ts +1 -0
  149. package/types/worktree.d.ts +19 -0
@@ -0,0 +1,361 @@
1
+ /** the card lines: rows in, lines out. ONE pure function of the rows; nothing else may feed it. @param {Row[]} rows */
2
+ export function renderCard(rows: Row[]): {
3
+ key: any;
4
+ line: any;
5
+ by: any;
6
+ state: any;
7
+ reason: any;
8
+ text: string;
9
+ }[];
10
+ /**
11
+ * A row. `kind`: rule, fact, phrase, count, cited, numbers, floor. `by`: you (`~`), agent (`!`), default (`$`). A `~` row may carry `links` (the look's facts tied to it),
12
+ * `pick`, `aiReading`, `left`. `state` is built or not-checked; a not-checked row always has a plain `reason`.
13
+ * @typedef {Record<string, any>} Row
14
+ */
15
+ /** the card's fixed words, one spelling (the renderer reads them; a test reads them too) */
16
+ export const CARD_T: Readonly<{
17
+ agreed: "you agreed:";
18
+ count: "result count";
19
+ cited: "every claim is backed by a quote copied from";
20
+ theInput: "the input";
21
+ numbers: "every number in the text is in a checked quote of line";
22
+ withWords: "with the words";
23
+ }>;
24
+ /** the four row edits an AI reply may hold */
25
+ export const EDIT_OPS: readonly string[];
26
+ /** the plain reasons code gives, in one place (the card, the Job tab and the Audit read them from the row) */
27
+ export const REASON: Readonly<{
28
+ left: "You chose to leave it Not checked, so you judge it at Accept.";
29
+ nothingOnPage: "Your own words are on the line; the machine has no check for them, so you judge it at Accept.";
30
+ cantCheck: "I can't check this on the page; waiting for your answer";
31
+ noRule: "No rule can check this, so you judge it at Accept.";
32
+ waitingPick: "waiting for your answer on the proposed check";
33
+ waitingReading: "waiting for your answer on the reading";
34
+ onePerLine: "this line finds facts, so it has no text to quote";
35
+ manyInputs: "the job has more than one input and code cannot pick which one the claims quote";
36
+ oneSidedTime: "a time limit the AI proposes must be a range, so you judge it at Accept.";
37
+ countNeedsFact: "a result count needs a fact to count; this line has none";
38
+ lookNoWords: "the page does not hold the words of the look's fact for this rule";
39
+ afterLast: "no more tries: Start over (rows are never changed by the AI after the last try)";
40
+ noPick: "No check was picked for it, so you judge it at Accept.";
41
+ negated: "it says what is not needed, so there is nothing to check";
42
+ dropped: "You dropped it.";
43
+ suggested: "Suggested: not in your job, so it is not checked unless you add it.";
44
+ }>;
45
+ export class CheckBlock {
46
+ /** @param {{texts: Record<string, string>, labels: string[], maxTries?: number, countScope?: (ruleText: string) => boolean, asks?: boolean, split?: boolean}} o the frozen input texts, their labels, how many AI replies (tries) may still change a row, whether code scopes a counting `~` rule in (a pick is asked), and whether a person can be asked at all (`asks`: false = a rule code cannot settle is Not checked, a reading code proposes is built as the AI's proposal) */
47
+ constructor({ texts, labels, maxTries, countScope, asks, split }: {
48
+ texts: Record<string, string>;
49
+ labels: string[];
50
+ maxTries?: number;
51
+ countScope?: (ruleText: string) => boolean;
52
+ asks?: boolean;
53
+ split?: boolean;
54
+ });
55
+ /** the product path sets it: `!` rows split into job-derived and suggested, a suggestion code cannot build is hidden (hamr 2026-11-13). Off, every `!` row is built as before (the older callers and their tests) */
56
+ split: boolean;
57
+ countScope: (ruleText: string) => boolean;
58
+ asks: boolean;
59
+ texts: Record<string, string>;
60
+ labels: string[];
61
+ maxTries: number;
62
+ /** @type {Row[]} the ONE store */
63
+ rows: Row[];
64
+ /** @type {{n: number, text: string}[]} */
65
+ lines: {
66
+ n: number;
67
+ text: string;
68
+ }[];
69
+ /** @type {any[]} the look's facts as given (a `reading` edit names one) */
70
+ lookFacts: any[];
71
+ /** @type {{facts: any[], dropped: any[]}|null} the look as the draft gate reads it (null = no look report: the gate proves a label against the list code made) */
72
+ look: {
73
+ facts: any[];
74
+ dropped: any[];
75
+ } | null;
76
+ /** @type {any[]} replies waiting to be applied by `drive` */
77
+ queue: any[];
78
+ /** @type {any[]} the open questions, set by `ask` */
79
+ open: any[];
80
+ /** @type {string[]} the keys of questions a person did not answer */
81
+ unanswered: string[];
82
+ tries: number;
83
+ /** @type {any[]} every reply's record: each edit, kept or refused with its own reason */
84
+ deltaLog: any[];
85
+ /** @type {any} */
86
+ closeCache: any;
87
+ textOf(source: string | undefined): string;
88
+ /** @param {number} line @param {string} [kind] */
89
+ rowsOn(line: number, kind?: string): Row[];
90
+ ruleRows(line: number): Row[];
91
+ /** every word the person wrote on a line: the line and its `~` rules */
92
+ said(line: number): string;
93
+ /** @param {Row} r @returns {Row} the row as stored (a repeated key gets `#2`) */
94
+ addRow(r: Row): Row;
95
+ /** @param {{n: number, text: string, rules?: string[]}[]} jobLines */
96
+ fromJob(jobLines: {
97
+ n: number;
98
+ text: string;
99
+ rules?: string[];
100
+ }[]): void;
101
+ /**
102
+ * @param {any[]} facts the look's kept facts @param {any[]} [dropped] the look's drops (`look.dropped`): a whole fact a page rule left out. Its plain sentence (src/pagedropwords.js)
103
+ * becomes the `why` of the `~` rule it was tied to, or a Not checked `!` row of its own, so every drop shows under Not checked.
104
+ */
105
+ addLook(facts: any[], dropped?: any[]): void;
106
+ match(): void;
107
+ /** a `!` row: the agent's fact, phrase or count (a look fact tied to a rule is a link on that rule's row, never a row of its own) */
108
+ isBang(r: Row): boolean;
109
+ /**
110
+ * The job's own word for a `!` row: when none of its page words is in the job line or its `~` rules but a proper name the job holds (capital or digit first, 3+ characters) is a whole-word part of one
111
+ * page word and the page holds it, the row's words become that job word. The page's long name is kept as `pageWords`; the row's other fields are untouched.
112
+ */
113
+ takeJobWord(r: Row): void;
114
+ /** are the row's words (or its count number, or the name it asks for a fact by) in the job line or its `~` rules? Normalised, case-insensitive */
115
+ inJob(r: Row): any;
116
+ /** a `~` line an agreed answer wrote (or a carried pair partner) is checked by the rule it was agreed from: one check, both numbers */
117
+ matchFollow(r: Row): void;
118
+ /** a `!` count row is built unless a `~` rule on its line already names the number */
119
+ matchCount(r: Row): void;
120
+ matchRule(r: Row): void;
121
+ /** a `~` rule that counts words, bullets, lines or sections: a settled pick builds it; else code proposes the check and asks */
122
+ matchCountRule(r: Row): void;
123
+ /** a `!` fact or phrase row: its words must be on the page; a version or a date is true only today, so only a place rule's fit may carry it */
124
+ matchBang(r: Row): void;
125
+ build(): any;
126
+ /** build the line as if this held row were on: when it builds, `offer` is the row as the card would draw it; else the row is hidden with code's reason. The rows' own state is restored */
127
+ trialOffer(r: Row): void;
128
+ /** one line's parts: a pick part per count rule, ONE fact part carrying every fact row of the line (and its result count), then the `$` defaults */
129
+ buildLine(l: {
130
+ n: number;
131
+ text: string;
132
+ }, lineParts: any[], lineRows: string[][], factLines: Set<number>): void;
133
+ /** the follow rows of a row (its agreed or carried `~` lines) */
134
+ followsOf(r: Row): Row[];
135
+ /**
136
+ * The fact(s) a fact-like row builds, checked alone through the bareguard shapes and against the facts already on the line.
137
+ * @param {Row} r @param {any[]} onLine the facts already built on this line @returns {{fresh: any[], src: string, names: string[]} | {why: string}}
138
+ */
139
+ factsOf(r: Row, onLine: any[]): {
140
+ fresh: any[];
141
+ src: string;
142
+ names: string[];
143
+ } | {
144
+ why: string;
145
+ };
146
+ /** the `$` defaults of a line, decided from what the line ended with: a text line quotes its input (one input only) and ties its numbers to the fact lines before it */
147
+ buildDefaults(l: {
148
+ n: number;
149
+ }, lineParts: any[], lineRows: string[][], factLines: Set<number>): void;
150
+ ask(): any[];
151
+ hasOpenQuestions(): boolean;
152
+ hasPendingDelta(): boolean;
153
+ /** @param {string} qKey @param {string} choice @param {string} [text] @returns {{ok: true} | {ok: false, why: string}} */
154
+ applyAnswer(qKey: string, choice: string, text?: string): {
155
+ ok: true;
156
+ } | {
157
+ ok: false;
158
+ why: string;
159
+ };
160
+ /** the `~` row `partner` is checked by `source` (one check, both rule numbers) */
161
+ follow(source: Row, partner: Row): void;
162
+ /**
163
+ * Revise keeps the picks of the last draft (am17/am18/am21, `src/pickrecord.js` `matchRecord`): a kept pick settles its rule and its added `~` line follows it; a kept left rule is
164
+ * left; an edited added line (`pairRule`) is the row asked and its source follows it.
165
+ * @param {{picks?: {line: number, rule: number, check: any, added?: string, own?: boolean}[], left?: {line: number, rule: number}[]}} kept
166
+ * @param {{line: number, rule: number, pairRule?: number}[]} [asked] the rules still asked (a `pairRule` marks an edited added line)
167
+ */
168
+ carry({ picks, left }: {
169
+ picks?: {
170
+ line: number;
171
+ rule: number;
172
+ check: any;
173
+ added?: string;
174
+ own?: boolean;
175
+ }[];
176
+ left?: {
177
+ line: number;
178
+ rule: number;
179
+ }[];
180
+ }, asked?: {
181
+ line: number;
182
+ rule: number;
183
+ pairRule?: number;
184
+ }[]): void;
185
+ /** @param {{label?: string, pre?: boolean, edits?: any[]}} delta `pre` = a reply that is not a drafter try (the suggest call): it does not count against the tries */
186
+ applyDelta(delta: {
187
+ label?: string;
188
+ pre?: boolean;
189
+ edits?: any[];
190
+ }): {
191
+ label: string | undefined;
192
+ pre: boolean;
193
+ edits: any[];
194
+ };
195
+ applyEdit(e: any, kept: {
196
+ adds: number;
197
+ }): {
198
+ accepted: boolean;
199
+ landedKey: any;
200
+ refusedBecause?: undefined;
201
+ } | {
202
+ refusedBecause: string;
203
+ };
204
+ editAdd(e: any): {
205
+ refusedBecause: string;
206
+ accepted?: undefined;
207
+ landedKey?: undefined;
208
+ } | {
209
+ accepted: boolean;
210
+ landedKey: any;
211
+ refusedBecause?: undefined;
212
+ };
213
+ /** @returns {string|null} the plain reason an add repeats what the list already holds (a look fact tied to a `~` rule, a `~` rule's own words, another `!` row), else null */
214
+ onTheList(line: number, name: string, words: string[]): string | null;
215
+ addCount(e: any): {
216
+ refusedBecause: string;
217
+ accepted?: undefined;
218
+ landedKey?: undefined;
219
+ } | {
220
+ accepted: boolean;
221
+ landedKey: any;
222
+ refusedBecause?: undefined;
223
+ };
224
+ /** the `~` rule rows of a line an edit names by number */
225
+ targetsOf(e: any): any;
226
+ /** the one owner of "what do the person's own words say": code's reading of a `~` rule for a money/time fact, or undefined when it cannot read it */
227
+ wordsReading(l: any, text: string): {
228
+ op: "lt" | "lte" | "gt" | "gte";
229
+ value: number;
230
+ } | {
231
+ op: "between";
232
+ lo: number | string;
233
+ hi: number | string;
234
+ } | undefined;
235
+ editReading(e: any): {
236
+ refusedBecause: string;
237
+ accepted?: undefined;
238
+ landedKey?: undefined;
239
+ } | {
240
+ accepted: boolean;
241
+ landedKey: any;
242
+ refusedBecause?: undefined;
243
+ };
244
+ editPick(e: any): {
245
+ refusedBecause: string;
246
+ accepted?: undefined;
247
+ landedKey?: undefined;
248
+ } | {
249
+ accepted: boolean;
250
+ landedKey: any;
251
+ refusedBecause?: undefined;
252
+ };
253
+ editNot(e: any): {
254
+ refusedBecause: string;
255
+ accepted?: undefined;
256
+ landedKey?: undefined;
257
+ } | {
258
+ accepted: boolean;
259
+ landedKey: any;
260
+ refusedBecause?: undefined;
261
+ };
262
+ reconcile(): any;
263
+ /** the loop: while a question is open or a reply waits, apply it and reconcile the WHOLE list again. `answer(q)` gives {choice, text} or null (a person who did not answer) */
264
+ drive({ answer }: {
265
+ answer: any;
266
+ }): this;
267
+ card(): {
268
+ key: any;
269
+ line: any;
270
+ by: any;
271
+ state: any;
272
+ reason: any;
273
+ text: string;
274
+ }[];
275
+ /**
276
+ * The rows as the close shape the card readers (`checksOfClose`, `refusedOf`, `cardOfClose`) already read: the block's stages, the picks code records and the signed list. The confirm card
277
+ * and the signed card read the rows through the SAME readers, so a row shown at confirm is the row signed. Reconciles first (the whole list, every time).
278
+ */
279
+ closeView(): {
280
+ stages: any;
281
+ picks: {
282
+ line: number;
283
+ part: any;
284
+ }[];
285
+ list: {
286
+ [k: string]: any;
287
+ }[];
288
+ };
289
+ /** the picks code records: a countable part carrying the `~` rule numbers it settles @param {{parts: any[], map: {part: number, line: number}[]}} c the build @returns {{line: number, part: any}[]} */
290
+ picksOf(c: {
291
+ parts: any[];
292
+ map: {
293
+ part: number;
294
+ line: number;
295
+ }[];
296
+ }): {
297
+ line: number;
298
+ part: any;
299
+ }[];
300
+ /** the standing ruling "a run needs one check": one row that is not the floor is built */
301
+ hasBuiltCheck(): boolean;
302
+ /**
303
+ * The signed list (`closeDecl.list`): the signed fields of every row, never its words. A suggestion not added is signed `dropped` ("suggested, not added"), a suggestion code could not build
304
+ * `dropped` with code's reason (it is on the Audit, never on the card), and a built row carries the names of the facts it made (`facts`), so every reader can tag each fact by its row's kind.
305
+ */
306
+ signedRows(): {
307
+ [k: string]: any;
308
+ }[];
309
+ /** the suggestions code has proved it can build, as the card offers them (Add): `{key, line, text}` */
310
+ suggestedView(): {
311
+ dropped?: boolean | undefined;
312
+ key: any;
313
+ line: any;
314
+ text: string;
315
+ }[];
316
+ /** the suggestions code could not build, in one plain sentence each: the Audit's draft lines (never the card) */
317
+ unbuiltSuggestions(): {
318
+ line: any;
319
+ text: string;
320
+ }[];
321
+ /**
322
+ * The person's Drop or Add on a `!` row (hamr 2026-11-13: instant, $0, no AI; the choice decides). The whole list is reconciled again, so an Add is judged by code like every other row.
323
+ * @param {string} key @param {'drop'|'add'} choice @returns {{ok: true} | {ok: false, why: string}}
324
+ */
325
+ rowChoice(key: string, choice: "drop" | "add"): {
326
+ ok: true;
327
+ } | {
328
+ ok: false;
329
+ why: string;
330
+ };
331
+ /** the person's Drop/Add choices, tied to the line's words (not its number) and the row's own name, so a Revise keeps them @returns {{lineWords: string, occurrence: number, tail: string, choice: string}[]} */
332
+ choicesRecord(): {
333
+ lineWords: string;
334
+ occurrence: number;
335
+ tail: string;
336
+ choice: string;
337
+ }[];
338
+ /** a Revise keeps the last draft's Drop/Add choices on the rows that are still there (same line words, same row); code still judges every one @param {{lineWords: string, occurrence: number, tail: string, choice: string}[]} rec */
339
+ carryChoices(rec: {
340
+ lineWords: string;
341
+ occurrence: number;
342
+ tail: string;
343
+ choice: string;
344
+ }[]): void;
345
+ /**
346
+ * per line, the shape of `retentionOfList` (counts only): `aiParts` = the rows the agent proposed (and the default cited), `kept` = those built, `dropped` = the rest, `picks` = a `~` row built from a pick
347
+ * @returns {{line: number, aiParts: number, kept: number, dropped: number, picks: boolean}[]}
348
+ */
349
+ retention(): {
350
+ line: number;
351
+ aiParts: number;
352
+ kept: number;
353
+ dropped: number;
354
+ picks: boolean;
355
+ }[];
356
+ }
357
+ /**
358
+ * A row. `kind`: rule, fact, phrase, count, cited, numbers, floor. `by`: you (`~`), agent (`!`), default (`$`). A `~` row may carry `links` (the look's facts tied to it),
359
+ * `pick`, `aiReading`, `left`. `state` is built or not-checked; a not-checked row always has a plain `reason`.
360
+ */
361
+ export type Row = Record<string, any>;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * A check that needs exact words from the input is true only while the input stays as it is when those words hold a VERSION-like token (1.2 or 1.2.3, not after a currency sign or before
3
+ * a percent) or a DATE-like token (2026-11-04, 04/11/2026, "Nov 4, 2026", "4 November 2026", "November 2026"). Code refuses it; a `~` rule is the person's own and is never refused by this.
4
+ * @param {unknown} t @returns {boolean}
5
+ */
6
+ export function weekOnly(t: unknown): boolean;
7
+ /**
8
+ * The version-like and date-like tokens a text holds (the very tokens {@link weekOnly} reads), each once. Pure.
9
+ * @param {unknown} t @returns {string[]}
10
+ */
11
+ export function weekTokens(t: unknown): string[];
12
+ /** @param {{n: number, text: string, rules?: string[], rule?: string}[]} jobLines @param {Record<string, string>} texts @returns {string} */
13
+ export function ledgerUserText(jobLines: {
14
+ n: number;
15
+ text: string;
16
+ rules?: string[];
17
+ rule?: string;
18
+ }[], texts: Record<string, string>): string;
19
+ /**
20
+ * The one paid call; its spend is booked like the look's. An unusable answer is NOT a guessed list: it yields no `!` proposals and says why.
21
+ * @param {{jobLines: any[], texts: Record<string, string>, generate: Function, ceilingUsd?: number|null, onCall?: (c: any) => void, priorCalls?: any[], priorRaws?: any[]}} o
22
+ * @returns {Promise<{extra: any[], reason: string|null, calls: any[], raws: any[]}>}
23
+ */
24
+ export function runLedgerSuggest({ jobLines, texts, generate, ceilingUsd, onCall, priorCalls, priorRaws }: {
25
+ jobLines: any[];
26
+ texts: Record<string, string>;
27
+ generate: Function;
28
+ ceilingUsd?: number | null;
29
+ onCall?: (c: any) => void;
30
+ priorCalls?: any[];
31
+ priorRaws?: any[];
32
+ }): Promise<{
33
+ extra: any[];
34
+ reason: string | null;
35
+ calls: any[];
36
+ raws: any[];
37
+ }>;
38
+ /** at most this many `!` checks come from the call */
39
+ export const MAX_BANG: 3;
40
+ /** the reason a check on a version or a date goes under Not checked: it is true only for the input as it is today */
41
+ export const WEEK_ONLY_WORDS: "It names a version or a date from the input, true only for the input as it is today, so you judge it at Accept.";
42
+ /** the label of the list call, as the drafting book and the draft log see it */
43
+ export const LEDGER_LABEL: "ledger-suggest";
44
+ export const LEDGER_TOOL: "suggest_extra_checks";
45
+ /** the reason the empty list is logged with */
46
+ export const EMPTY_LIST_WORDS: "empty list: nothing to check";
47
+ export function isEmptyList(rows: Row[]): boolean;
48
+ export function ledgerRecord(rows: Row[]): ({
49
+ key: string;
50
+ line: number;
51
+ rowKind: "fact" | "phrase" | "rule" | "count" | "numbers" | "cited" | "floor";
52
+ from: "rule" | "agent" | "default" | "pick" | "look";
53
+ by: "you" | "agent" | "default";
54
+ words: string[];
55
+ state: "dropped" | "not-checked" | "built" | "listed";
56
+ reason: string | null;
57
+ } | {
58
+ key: string;
59
+ line: number;
60
+ rowKind: string;
61
+ from: string;
62
+ by: string;
63
+ words: never[];
64
+ state: string;
65
+ reason: string;
66
+ })[];
67
+ /** the list call's own system text (model-facing; used only by the list call of a rubric job with input text) */
68
+ export const LEDGER_SYSTEM: "You look at the inputs of a job and name checks the inputs themselves support, beyond the guardrails the person wrote.\nCall suggest_extra_checks once with up to 3 entries, or with an empty list.\n- kind \"count\": how many results the input shows or the job asks for (min and/or max, whole numbers).\n- kind \"phrase\": fixed words copied verbatim from an input (phrase, and source = that input's label).\nUse only what you can see in the inputs. Do not repeat a guardrail the person wrote. If the inputs support none, send an empty list.";
69
+ export const LEDGER_SCHEMA: Readonly<{
70
+ type: "object";
71
+ properties: {
72
+ extra: {
73
+ type: string;
74
+ maxItems: number;
75
+ items: {
76
+ type: string;
77
+ properties: {
78
+ line: {
79
+ type: string;
80
+ minimum: number;
81
+ description: string;
82
+ };
83
+ kind: {
84
+ enum: string[];
85
+ };
86
+ source: {
87
+ type: string;
88
+ description: string;
89
+ };
90
+ phrase: {
91
+ type: string;
92
+ description: string;
93
+ };
94
+ min: {
95
+ type: string;
96
+ minimum: number;
97
+ };
98
+ max: {
99
+ type: string;
100
+ minimum: number;
101
+ };
102
+ };
103
+ required: string[];
104
+ additionalProperties: boolean;
105
+ };
106
+ };
107
+ };
108
+ required: string[];
109
+ additionalProperties: false;
110
+ }>;
111
+ export type Row = {
112
+ key: string;
113
+ line: number;
114
+ kind: "rule" | "fact" | "cited" | "count" | "phrase" | "numbers" | "floor";
115
+ from: "rule" | "pick" | "look" | "agent" | "default";
116
+ by: "you" | "agent" | "default";
117
+ words: string[];
118
+ text?: string;
119
+ rule?: number;
120
+ part?: {
121
+ line: number;
122
+ part: number;
123
+ };
124
+ source?: string;
125
+ name?: string;
126
+ min?: number;
127
+ max?: number;
128
+ pick?: string;
129
+ after?: number[];
130
+ state: "listed" | "built" | "not-checked" | "dropped";
131
+ reason: string | null;
132
+ forRule?: number;
133
+ reading?: import("./pagerules.js").Reading;
134
+ };
@@ -0,0 +1,160 @@
1
+ /** every whole-output word number in a guardrail ("under 600 words" -> [600]); a "<n> words each" / "per section" size is never listed here @param {unknown} g @returns {number[]} */
2
+ export function guardrailWordNumbers(g: unknown): number[];
3
+ /** every standalone number in a guardrail's own text (digits not joined to letters) @param {unknown} g @returns {number[]} */
4
+ export function guardrailStandaloneNumbers(g: unknown): number[];
5
+ /** the "<n> words each" / "<n> words per section" size, or null @param {unknown} g @returns {number|null} */
6
+ export function guardrailWordsPerSection(g: unknown): number | null;
7
+ /** the first "<N> sections" in a guardrail (digits, or one..ten), or null @param {unknown} g @returns {number|null} */
8
+ export function guardrailSectionCount(g: unknown): number | null;
9
+ /** the first "<N> bullets / list items / items / lines / points" in a guardrail (digits, or one..ten), or null @param {unknown} g @returns {number|null} */
10
+ export function guardrailItemCount(g: unknown): number | null;
11
+ /** @typedef {{line: number, rule: number, text: string}} Rule */
12
+ /**
13
+ * Every `~` rule of a rubric job that this call settles, in line order. `rule` is the rule's number on its line (the number a part's `rules` and the answers use). A rule a
14
+ * kept page word already carries (the look tied it by line and rule number) or that the look already put under Not checked is left to that, EXCEPT a countable rule (`isCountable`: a word, list-item/line or section count), which always comes here: the look's fact stays beside the pick (keep-both). A repeated text on a line is
15
+ * one rule here, asked once.
16
+ * @param {{n: number, rule?: string, rules?: string[]}[]} jobLines @param {{inputs?: {value?: string}[]|null, look?: any}} [o]
17
+ * @returns {Rule[]}
18
+ */
19
+ export function scopedRules(jobLines: {
20
+ n: number;
21
+ rule?: string;
22
+ rules?: string[];
23
+ }[], { inputs, look }?: {
24
+ inputs?: {
25
+ value?: string;
26
+ }[] | null;
27
+ look?: any;
28
+ }): Rule[];
29
+ /**
30
+ * Keep a suggestion only if its rule is on bareguard's list, it carries only that rule's own fields, every number in it is a number the guardrail names and every word in it
31
+ * is a word of the guardrail. Anything else is dropped, with the reason. `none` is a drop with the reason `none`.
32
+ * @param {string} guardrail @param {any} sug the model's entry for this guardrail
33
+ * @returns {{kept: true, check: Record<string, any>}|{kept: false, why: string}}
34
+ */
35
+ export function keepOrDrop(guardrail: string, sug: any): {
36
+ kept: true;
37
+ check: Record<string, any>;
38
+ } | {
39
+ kept: false;
40
+ why: string;
41
+ };
42
+ /**
43
+ * The user message: the job's lines, and under a line only the guardrails this call settles, numbered by their rule number on the line.
44
+ * @param {{n: number, text: string}[]} lines @param {Rule[]} scoped @returns {string}
45
+ */
46
+ export function suggestUserText(lines: {
47
+ n: number;
48
+ text: string;
49
+ }[], scoped: Rule[]): string;
50
+ /**
51
+ * The check CODE proposes for a count rule when the call yields none (R10, ours; fwd has no such fallback): a bullets / list-items / points count -> listItems N (exact; "at most / up to / no more than / fewer than / under / below" -> maxListItems, "at least / minimum / no fewer than / more than" -> minListItems, F315), a lines count ->
52
+ * maxLines N, ONE word number -> minWords N when the rule says "at least / minimum / more than", else maxWords N. A section count names no sections, so none is built; a rule naming two different counts ("3 bullets under 80 words") is not built either; a rule with
53
+ * several word numbers or a range ("between 100 and 200 words") is not guessed. The result passes `keepOrDrop`, so every number is one the rule names.
54
+ * @param {string} text @returns {Record<string, any>|null}
55
+ */
56
+ export function countCheck(text: string): Record<string, any> | null;
57
+ /**
58
+ * What the call's answer comes to, one row per scoped rule: the check kept (or null) and why it was dropped. A rule the answer never mentions is dropped as `no entry`; an
59
+ * entry for a rule that was not sent is ignored.
60
+ * @param {Rule[]} scoped @param {any} args the tool call's arguments
61
+ * @returns {(Rule & {check: Record<string, any>|null, why: string|null})[]}
62
+ */
63
+ export function rowsFromAnswer(scoped: Rule[], args: any): (Rule & {
64
+ check: Record<string, any> | null;
65
+ why: string | null;
66
+ })[];
67
+ /** a part of a rubric-step stage, from a pick: the check's own fields, the rule's words, and the `~` rule numbers it carries out @param {Record<string, any>} check @param {string} text @param {number[]} rules */
68
+ export function partOfPick(check: Record<string, any>, text: string, rules: number[]): {
69
+ rules: number[];
70
+ text: string;
71
+ class: string;
72
+ check: any;
73
+ };
74
+ /** the one tool the suggestion call uses */
75
+ export const SUGGEST_TOOL: "suggest_checks";
76
+ export function isCountable(g: unknown): boolean;
77
+ export function isUrlInput(v: unknown): boolean;
78
+ export function hasRoutingInput(inputs: {
79
+ value?: string;
80
+ }[] | null | undefined): boolean;
81
+ export function codeScope(inputs: {
82
+ value?: string;
83
+ }[] | null | undefined, g: string): "in" | "out";
84
+ export function sameRuleWords(a: unknown, b: unknown): boolean;
85
+ export const SUGGEST_SYSTEM: string;
86
+ /** the tool's parameter schema: one `anyOf` variant per offered rule, plus `none` */
87
+ export const SUGGEST_SCHEMA: Readonly<{
88
+ type: "object";
89
+ properties: {
90
+ checks: {
91
+ type: string;
92
+ description: string;
93
+ items: {
94
+ anyOf: any[];
95
+ };
96
+ };
97
+ };
98
+ required: string[];
99
+ additionalProperties: false;
100
+ }>;
101
+ /** the instruction a retry carries (the structured ladder's own words, naming this tool) */
102
+ export const SUGGEST_INSTRUCTION: "Your reply did not deliver exactly one suggest_checks call. Call suggest_checks exactly once, with one entry per guardrail as its arguments. Do not write the answer as text.";
103
+ export function suggestTool(box: {
104
+ calls: any[];
105
+ }): {
106
+ name: string;
107
+ description: string;
108
+ parameters: Readonly<{
109
+ type: "object";
110
+ properties: {
111
+ checks: {
112
+ type: string;
113
+ description: string;
114
+ items: {
115
+ anyOf: any[];
116
+ };
117
+ };
118
+ };
119
+ required: string[];
120
+ additionalProperties: false;
121
+ }>;
122
+ execute: (args: any) => Promise<string>;
123
+ };
124
+ export function suggestChannel(): {
125
+ name: string;
126
+ instruction: string;
127
+ textPath: string;
128
+ tool: (box: {
129
+ calls: any[];
130
+ }) => {
131
+ name: string;
132
+ description: string;
133
+ parameters: Readonly<{
134
+ type: "object";
135
+ properties: {
136
+ checks: {
137
+ type: string;
138
+ description: string;
139
+ items: {
140
+ anyOf: any[];
141
+ };
142
+ };
143
+ };
144
+ required: string[];
145
+ additionalProperties: false;
146
+ }>;
147
+ execute: (args: any) => Promise<string>;
148
+ };
149
+ };
150
+ /** the can't-check ask, as the signed words say it */
151
+ export const CANT_CHECK_WORDS: "I can't check this. Your own words, or Not checked?";
152
+ export function HOW_TO_ANSWER(line: number, agree: boolean): string;
153
+ export type Rule = {
154
+ line: number;
155
+ rule: number;
156
+ text: string;
157
+ };
158
+ import { plainWords } from './checkwords.js';
159
+ import { OFFERED } from './checkwords.js';
160
+ export { plainWords, OFFERED };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @param {{jobLines: {n: number, text: string}[], scoped: {line: number, rule: number, text: string}[], generate: Function, ceilingUsd?: number|null,
3
+ * onCall?: (call: any) => void, priorCalls?: any[], priorRaws?: any[]}} o
4
+ * @returns {Promise<{state: 'ok'|'absent', reason: string|null, rows: ReturnType<typeof rowsFromAnswer>, calls: any[], raws: any[]}>}
5
+ */
6
+ export function runCheckSuggest({ jobLines, scoped, generate, ceilingUsd, onCall, priorCalls, priorRaws }: {
7
+ jobLines: {
8
+ n: number;
9
+ text: string;
10
+ }[];
11
+ scoped: {
12
+ line: number;
13
+ rule: number;
14
+ text: string;
15
+ }[];
16
+ generate: Function;
17
+ ceilingUsd?: number | null;
18
+ onCall?: (call: any) => void;
19
+ priorCalls?: any[];
20
+ priorRaws?: any[];
21
+ }): Promise<{
22
+ state: "ok" | "absent";
23
+ reason: string | null;
24
+ rows: ReturnType<typeof rowsFromAnswer>;
25
+ calls: any[];
26
+ raws: any[];
27
+ }>;
28
+ /** the label of the call, as the drafting book and the draft log see it */
29
+ export const SUGGEST_LABEL: "check-suggest";
30
+ import { rowsFromAnswer } from './checkpick.js';