shadok-ai 0.14.9 → 0.14.11

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.
@@ -68,6 +68,16 @@ sentence is what siblings are shown in the `⟦ledger⟧` block pushed ahead of
68
68
  messages — the entity name alone cannot tell them what changed about it. Put the
69
69
  consequence first, details after.
70
70
 
71
+ **The label NAMES the topic; the note says what happened to it.** Keep the
72
+ entity under ~80 characters — `partner-page hospital logo`, not `13 August
73
+ Resources articles: C3 and A1 published, 11 drafts waiting on the daily go`.
74
+ The second is a note wearing a label's clothes. The block that carries your
75
+ update to your siblings names every row that changed, but it is pasted into
76
+ their session in pieces and each piece costs them a fraction of a second of
77
+ waiting, so a label that is three times too long makes everyone wait for words
78
+ their note already carries. Nothing refuses a long label — the row is saved
79
+ either way — but only its first 80 characters reach that block.
80
+
71
81
  ## Is it a task, a fact, or a decision?
72
82
 
73
83
  A **task** has a lifecycle, so a status is the right thing to carry and closing
@@ -15,6 +15,7 @@ export interface LedgerCoreRow {
15
15
  }
16
16
  export type LedgerKind = "task" | "fact" | "decision";
17
17
  export const KINDS: LedgerKind[];
18
+ export const LABEL_MAX: number;
18
19
  export function normEntity(s: unknown): string;
19
20
  export function normKind(k: unknown): LedgerKind | null;
20
21
  export function rowKind(entry: unknown): LedgerKind;
@@ -42,6 +42,20 @@ export function resolveId(entries, idOrPrefix) {
42
42
 
43
43
  export const KINDS = ["task", "fact", "decision"];
44
44
 
45
+ /**
46
+ * How much of an entity LABEL is worth carrying, in characters. A label NAMES
47
+ * the topic; the note says what happened to it. The two drifted together once
48
+ * the pushed delta started carrying a headline: labels grew into sentences
49
+ * ("[modif] 13 articles Ressources d'août : C3 et A1 publiés, 11 brouillons…"),
50
+ * which is a note wearing a label's clothes — and on one instance that took the
51
+ * rendered row to a 156-character median, so a 9-row delta could name exactly
52
+ * one of them. Enforced on BOTH sides, because neither alone holds: the CLI
53
+ * warns at write time (it teaches, and the table keeps the full text), the block
54
+ * truncates at render time (it guarantees, whatever any agent writes). Never a
55
+ * refusal — a refused write is a lost fact.
56
+ */
57
+ export const LABEL_MAX = 80;
58
+
45
59
  /** The status a kind with NO lifecycle gets when none is given, so an agent is
46
60
  * never pushed into inventing a word for a thing that has no phases. Keeping
47
61
  * `status` always present is what leaves every existing reader — the pushed
@@ -10,7 +10,7 @@ import fs from "node:fs";
10
10
  import os from "node:os";
11
11
  import path from "node:path";
12
12
  import crypto from "node:crypto";
13
- import { upsertEntry, searchEntries, ageDays, resolveId, normEntity, rowKind, KINDS } from "./ledger-core.mjs";
13
+ import { upsertEntry, searchEntries, ageDays, resolveId, normEntity, rowKind, KINDS, LABEL_MAX } from "./ledger-core.mjs";
14
14
 
15
15
  const FILE =
16
16
  (process.env.SHADOK_LEDGER_FILE || "").trim() ||
@@ -144,6 +144,16 @@ if (cmd === "check") {
144
144
  const row = byId ? resolveId(rows, f.id) : rows.find((r) => normEntity(r.entity) === normEntity(f.entity));
145
145
  const k = rowKind(row);
146
146
  console.log(`recorded: ${row.entity} — ${row.status}${k === "task" ? "" : ` · ${k}`} [${row.id}]`);
147
+ // Say it, don't enforce it: the row is already saved (a refused write is a
148
+ // lost fact) and the full label stays in the table. But the delta pushed to
149
+ // siblings only carries the first LABEL_MAX characters of it, and a label
150
+ // that grew into a sentence is what makes a 9-row delta name one row.
151
+ if (row.entity.length > LABEL_MAX) {
152
+ console.log(
153
+ `note: that label is ${row.entity.length} characters — a label NAMES the topic, the note says what happened. ` +
154
+ `Only the first ${LABEL_MAX} reach the ⟦ledger⟧ block your siblings are pushed.`,
155
+ );
156
+ }
147
157
  } else if (cmd === "list") {
148
158
  const rows = searchEntries(load(), "").strong;
149
159
  console.log(rows.length ? rows.map((e) => fmt(e, now)).join("\n") : "(ledger empty)");
package/dist/detect.d.ts CHANGED
@@ -137,10 +137,10 @@ export interface TypeOptions {
137
137
  /** How long to wait for the box to actually read empty after Ctrl-U. */
138
138
  clearMs?: number;
139
139
  /**
140
- * Injected context to put in the box BEFORE the message, as its own paste —
141
- * not concatenated into it. See `typeIntoBox` for why that distinction is a
142
- * correctness one.
140
+ * Injected context to put in the box BEFORE the message, as its OWN paste(s)
141
+ * — not concatenated into it. See `typeIntoBox` for why that distinction is a
142
+ * correctness one, and why SEVERAL of them buy room a single one cannot.
143
143
  */
144
- prelude?: string;
144
+ prelude?: string | string[];
145
145
  }
146
146
  export declare function typeIntoBox(pilot: TypingPilot, text: string, { attempts, appearMs, settleMs, clearMs, prelude }?: TypeOptions): Promise<boolean>;
package/dist/detect.js CHANGED
@@ -257,21 +257,31 @@ export async function typeIntoBox(pilot, text, { attempts = 6, appearMs = 2_000,
257
257
  // Only "" and the resting state count as an empty box; anything else the
258
258
  // box shows once we paste is our paste (whole, or collapsed).
259
259
  const before = inputText(pilot.screen());
260
- if (prelude) {
261
- // TWO pastes, and the second must be the message. Claude Code keeps only
262
- // the CURRENT paste inline and leaves every earlier one collapsed, so
263
- // pasting separately is what puts the injected context inside the
264
- // `<pasted_content>` wrapper and leaves the user's words outside it.
265
- // Waiting for the first to land is load-bearing: fired back to back they
266
- // can reach the pane as one paste event, which is exactly the single
267
- // blob this exists to stop being.
268
- pilot.paste(prelude);
260
+ // N+1 pastes, and the LAST must be the message. Claude Code decides whether
261
+ // a paste stays inline when it is the CURRENT one and leaves every earlier
262
+ // one as it then became, so pasting separately is what puts the injected
263
+ // context inside the `<pasted_content>` wrapper and leaves the user's words
264
+ // outside it. The threshold (800 chars, 2 newlines) is applied PER PASTE,
265
+ // which is why the prelude may be a LIST: measured on a live agent, eight
266
+ // chunks and a message carried 1272 characters over nine lines with nothing
267
+ // wrapped at all — a ceiling a single paste cannot reach by any formatting.
268
+ // Waiting for each to land is load-bearing: fired back to back they reach
269
+ // the pane as ONE paste event, which is exactly the single blob this exists
270
+ // to stop being.
271
+ for (const chunk of prelude ? (Array.isArray(prelude) ? prelude : [prelude]) : []) {
272
+ if (!chunk)
273
+ continue;
274
+ const seen = pilot.screen();
275
+ pilot.paste(chunk);
269
276
  try {
270
- await pilot.waitFor((s) => inputText(s) !== before, { timeoutMs: appearMs });
277
+ // The SCREEN, not `inputText`: that helper reads the `❯` line alone, so
278
+ // once a chunk has filled it every later one lands on a continuation
279
+ // line and the box's visible text stops moving.
280
+ await pilot.waitFor((s) => s !== seen, { timeoutMs: appearMs });
271
281
  }
272
282
  catch {
273
- // The prelude never showed. Fall through and paste the message anyway:
274
- // losing the context is survivable, losing the message is not.
283
+ // A chunk never showed. Fall through and paste the rest anyway: losing
284
+ // the context is survivable, losing the message is not.
275
285
  }
276
286
  }
277
287
  // The SCREEN, not `inputText`: the box's visible text is read off its `❯`
@@ -1 +1 @@
1
- {"version":3,"file":"detect.js","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,cAAc,GAClB,wDAAwD,CAAC;AAE3D,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,QAAQ,CACtB,MAAc,EACd,UAAkB,EAClB,WAAmB,EACnB,GAAW,EACX,QAAgB;IAEhB,IAAI,eAAe,CAAC,MAAM,CAAC,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QACrD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAC7D,CAAC;IACD,4EAA4E;IAC5E,0CAA0C;IAC1C,MAAM,KAAK,GAAG,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC;IACpD,OAAO,EAAE,IAAI,EAAE,GAA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AAC;YACF,yEAAyE;YACzE,kEAAkE;YAClE,0EAA0E;YAC1E,wEAAwE;YACxE,2EAA2E;YAC3E,0EAA0E;YAC1E,2EAA2E;YAC3E,wEAAwE;YACxE,wEAAwE;YACxE,2EAA2E;YAC3E,4DAA4D;YAC5D,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;gBAC7D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC7B,KAAK,CAAC,UAAU,EAAE,CAAC;gBACnB,IAAI,CAAC;oBACH,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC;oBAC9E,MAAM;gBACR,CAAC;gBAAC,MAAM,CAAC;oBACP,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/C,CAAC"}
package/dist/ledger.d.ts CHANGED
@@ -66,12 +66,29 @@ export declare function deltaSince(rows: LedgerRow[], watermark: number, cap: nu
66
66
  */
67
67
  export declare function headline(note: string | undefined, max?: number): string;
68
68
  /**
69
- * The delta block the agent sees ahead of a prompt. English (it is written into
70
- * the transcript — repo side). ONE line, within `BLOCK_MAX` (see above): per row
71
- * `• [id] entity — status (source)`, the kind when it is not the default `task`,
72
- * and `↳ <headline>` for what actually happened. Rows that do not fit the budget
73
- * become the overflow pointer rather than a second line.
69
+ * The delta the agent sees ahead of a prompt, as the LIST OF PASTES it travels
70
+ * in. English (it is written into the transcript — repo side).
71
+ *
72
+ * The ordering rule is "never lose a row, lose the detail first", because the
73
+ * two failures are not comparable: a row the reader is never told about is a
74
+ * silo this feature exists to close, while a row named without its sentence is
75
+ * one `ledger list` away. So the budget is spent in this order, and degrades in
76
+ * the opposite one:
77
+ *
78
+ * 1. every changed row gets `• [id] entity — status (source)`;
79
+ * 2. the newest `HEADLINE_ROWS` of them also get `↳ <what happened>`;
80
+ * 3. only if even step 1 does not fit the chunk ceiling do the oldest rows
81
+ * collapse into the overflow mark, which still carries their IDS;
82
+ * 4. and only when there are more of them than we hold does it fall back to
83
+ * a bare count.
84
+ *
85
+ * Each chunk is one line ending in a newline, under `PASTE_MAX`, so each is
86
+ * judged on its own by the paste rule and stays in the clear.
74
87
  */
88
+ export declare function formatLedgerChunks(rows: LedgerRow[], total: number): string[];
89
+ /** The same delta as ONE string — what lands in the transcript, and what the
90
+ * display then strips. The pastes are concatenated by the TUI exactly like
91
+ * this, so this is the text, not a rendering of it. */
75
92
  export declare function formatLedgerBlock(rows: LedgerRow[], total: number): string;
76
93
  /** Prepend the block as its own leading line. Idempotent.
77
94
  *
package/dist/ledger.js CHANGED
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import crypto from "node:crypto";
5
- import { rowKind } from "../context/ledger-skill/ledger-core.mjs";
5
+ import { rowKind, LABEL_MAX } from "../context/ledger-skill/ledger-core.mjs";
6
6
  /** The per-instance ledger file, keyed by the launch dir (same encoding as
7
7
  * channels/crons). Distinct launch dirs → distinct ledgers. */
8
8
  export function ledgerFileFor(cwd) {
@@ -106,28 +106,77 @@ const LEDGER_HEAD = "⟦ledger · ";
106
106
  * lines 1–3 → 0 of 324 wrapped chars 430 on one line → not wrapped
107
107
  * lines 4+ → ~30% of 162 wrapped chars 910 on one line → wrapped
108
108
  *
109
- * A prompt is `⟦web⟧ header` + the message, so a one-line human message leaves
110
- * the block exactly one line of room. The old multi-line block spent 2+ and put
111
- * EVERY non-empty delta over the cliff: 85 real prompts, 24% of those carrying a
112
- * block, had the human's message neutralised this way. Hence: one line, and a
113
- * character budget inside it.
109
+ * The old multi-line block spent 2+ lines and put EVERY non-empty delta over
110
+ * the cliff: 85 real prompts, 24% of those carrying a block, had the human's
111
+ * message neutralised this way.
112
+ *
113
+ * Since #261 the block travels as its OWN paste, so it is judged ALONE — and
114
+ * the rule it is judged by is the binary's own, read out of it rather than
115
+ * bisected: `body.length <= 800 && newlines <= 2` (`var xK=800`). Two things
116
+ * follow, and they move the budget.
117
+ *
118
+ * - The cliff for the block is 800, not the 430 measured when it still had
119
+ * to share a prompt with the user's message. That measurement was of the
120
+ * WHOLE prompt and does not bound this paste.
121
+ * - The rule is applied PER PASTE, and we choose how many pastes there are.
122
+ * So 800 is not a ceiling on what the delta may carry at all: it is the
123
+ * size of one CHUNK. Measured on a live agent, eight chunks plus the
124
+ * message carried 1272 characters over nine lines with nothing wrapped and
125
+ * the order obeyed — a payload no single paste can deliver in the clear by
126
+ * any formatting.
127
+ *
128
+ * So the block is a LIST of one-line chunks (`formatLedgerChunks`), and what
129
+ * bounds it is no longer the wrapper but LATENCY: every chunk must be waited
130
+ * for before the next is pasted, or two reach the pane as one paste event and
131
+ * the whole split is undone. That is the budget `PRELUDE_MAX_CHUNKS` spends —
132
+ * seconds between "send" and the message leaving, on the most fragile path
133
+ * here — and it is why no row is ever dropped for size while the DETAIL is.
114
134
  * ------------------------------------------------------------------ */
115
135
  /** Marks what follows the row, inline: "and here is what happened". */
116
136
  const CONT_MARK = "↳";
117
137
  /** Historical multi-line blocks, still replayed out of old transcripts. */
118
138
  const CONT_LINE = /^\s*↳ /;
119
- /** How much of a note reaches the block. */
120
- const HEADLINE_MAX = 120;
139
+ /**
140
+ * How much of a note reaches the block. 120 cut the first sentence of a real
141
+ * `decision` row at 126 characters — "aucune action directe déclenchée par…",
142
+ * whose missing complement ("par un mail") carried the whole decision, so what
143
+ * was left could be read as its opposite. 19% of this table's notes were cut at
144
+ * 120, 13% at 160. It stops at 160 rather than going further because a headline
145
+ * is only ever served WHOLE (see `formatLedgerBlock`): a larger cap does not buy
146
+ * better headlines, it buys fewer of them — the long ones stop fitting the room
147
+ * left after the labels and are dropped entirely.
148
+ */
149
+ const HEADLINE_MAX = 160;
121
150
  /** Below this, a sentence boundary is not believed — see `headline`. */
122
151
  const HEADLINE_MIN = 24;
123
152
  /**
124
- * The whole block's character ceiling. Chosen from the measurement above with
125
- * room left for the ⟦web⟧ header and an ordinary message: a long enough single
126
- * line collapses into a paste just as a fourth line does, so the budget is what
127
- * keeps the one-line rule from being defeated by content. Rows that do not fit
128
- * collapse into the overflow pointer, which is what it has always been for.
153
+ * How many rows the block carries a HEADLINE for. Every changed row is named
154
+ * whatever happens (see `formatLedgerChunks`); this only bounds how many of
155
+ * them also say what happened, because that detail is what the reader can get
156
+ * back from `ledger list` in one call.
157
+ */
158
+ const HEADLINE_ROWS = 3;
159
+ /**
160
+ * One paste's character bound. Claude Code keeps a paste inline only below 800
161
+ * characters AND 2 newlines (`xK` in the binary) — and applies that PER PASTE,
162
+ * deciding each one as it is made. So the prelude is a LIST of pastes: measured
163
+ * on a live agent, eight chunks plus the message carried 1272 characters over
164
+ * nine lines with nothing wrapped, which no single paste can do by any
165
+ * formatting. 760 leaves margin under 800; a chunk holds ONE line and its
166
+ * trailing newline, well inside the 2 the rule allows.
167
+ */
168
+ const PASTE_MAX = 760;
169
+ /**
170
+ * The whole prelude's bound, across every chunk. Not a formatting limit — a
171
+ * LATENCY one: each chunk must be waited for before the next is pasted, or two
172
+ * reach the pane as one paste event and the split is undone. So every extra
173
+ * chunk is roughly half a second between "send" and the message leaving, on the
174
+ * most fragile path in this codebase (the one that delivered a header twice and
175
+ * the text nowhere for nine days). Eight chunks is the ceiling; a delta that
176
+ * large belongs to an agent coming back from days away, which is exactly when
177
+ * the backlog is worth the wait.
129
178
  */
130
- const BLOCK_MAX = 320;
179
+ const PRELUDE_MAX_CHUNKS = 8;
131
180
  /**
132
181
  * The one line of the note that says WHAT happened, DERIVED rather than asked
133
182
  * for. The block used to carry `[id] entity — status` and nothing else, so the
@@ -163,40 +212,104 @@ export function headline(note, max = HEADLINE_MAX) {
163
212
  // Break on a word unless that would throw away most of the line.
164
213
  return (sp > max * 0.6 ? cut.slice(0, sp) : cut).trimEnd() + "…";
165
214
  }
215
+ /** `• [id] entity — status (source)` — the part of a row the reader cannot
216
+ * reconstruct from anywhere else. The label is capped at render time, never in
217
+ * the table: `check` and `list` still print it whole, and the `[id]` stays the
218
+ * handle to quote (see `LABEL_MAX`). */
219
+ function bareRow(r) {
220
+ const handle = r.id ? `[${r.id}] ` : "";
221
+ const src = r.source ? ` (${r.source})` : "";
222
+ // A `fact` has no lifecycle and a `decision` is not a phase of one, so the
223
+ // reader must not take their status for a position in open → resolved.
224
+ // `task` is the default and nearly the whole table: tagging it would be noise.
225
+ const kind = rowKind(r);
226
+ const tag = kind === "task" ? "" : ` · ${kind}`;
227
+ const label = r.entity.length > LABEL_MAX ? r.entity.slice(0, LABEL_MAX - 1).trimEnd() + "…" : r.entity;
228
+ return ` • ${handle}${label} — ${r.status}${tag}${src}`;
229
+ }
166
230
  /**
167
- * The delta block the agent sees ahead of a prompt. English (it is written into
168
- * the transcript — repo side). ONE line, within `BLOCK_MAX` (see above): per row
169
- * `• [id] entity — status (source)`, the kind when it is not the default `task`,
170
- * and `↳ <headline>` for what actually happened. Rows that do not fit the budget
171
- * become the overflow pointer rather than a second line.
231
+ * What stands for the rows the budget could not name. It carries their IDS: an
232
+ * id is the handle `record --id` takes and `check` resolves, so a reader that
233
+ * recognises one can act on it, while `+8 more` leaves it with all of them or
234
+ * none. The count and the list are kept HONEST apart, because the delta is
235
+ * capped (`LEDGER_PUSH_CAP`) and `total` can exceed the rows we were handed —
236
+ * announcing `+8 : <7 ids>` would quietly lose one.
172
237
  */
238
+ function overflowMark(rows, shown, total) {
239
+ const missing = total - shown;
240
+ if (missing <= 0)
241
+ return "";
242
+ const ids = rows.slice(shown).map((r) => r.id).filter(Boolean);
243
+ const tail = " — run: ledger list)";
244
+ if (!ids.length)
245
+ return ` • (+${missing} more${tail}`;
246
+ if (ids.length === missing)
247
+ return ` • (+${missing} : ${ids.join(" ")}${tail}`;
248
+ return ` • (+${missing} more, ${ids.length} newest: ${ids.join(" ")}${tail}`;
249
+ }
250
+ /**
251
+ * The delta the agent sees ahead of a prompt, as the LIST OF PASTES it travels
252
+ * in. English (it is written into the transcript — repo side).
253
+ *
254
+ * The ordering rule is "never lose a row, lose the detail first", because the
255
+ * two failures are not comparable: a row the reader is never told about is a
256
+ * silo this feature exists to close, while a row named without its sentence is
257
+ * one `ledger list` away. So the budget is spent in this order, and degrades in
258
+ * the opposite one:
259
+ *
260
+ * 1. every changed row gets `• [id] entity — status (source)`;
261
+ * 2. the newest `HEADLINE_ROWS` of them also get `↳ <what happened>`;
262
+ * 3. only if even step 1 does not fit the chunk ceiling do the oldest rows
263
+ * collapse into the overflow mark, which still carries their IDS;
264
+ * 4. and only when there are more of them than we hold does it fall back to
265
+ * a bare count.
266
+ *
267
+ * Each chunk is one line ending in a newline, under `PASTE_MAX`, so each is
268
+ * judged on its own by the paste rule and stays in the clear.
269
+ */
270
+ export function formatLedgerChunks(rows, total) {
271
+ const head = `${LEDGER_HEAD}${total} update${total === 1 ? "" : "s"}⟧`;
272
+ // Step 1 + 2: what each row is worth saying. The headline is attached to the
273
+ // newest few only — detail is the thing that degrades, and the newest rows
274
+ // are the ones a sibling is most likely to be about to act on.
275
+ const pieces = rows.map((r, i) => {
276
+ const h = i < HEADLINE_ROWS ? headline(r.note) : "";
277
+ return bareRow(r) + (h ? ` ${CONT_MARK} ${h}` : "");
278
+ });
279
+ // Pack greedily into one-line chunks. A row is never split across two pastes:
280
+ // half a row in the clear and half in another reads as two rows.
281
+ const pack = (n) => {
282
+ const parts = [...pieces.slice(0, n), overflowMark(rows, n, total)].filter(Boolean);
283
+ const out = [];
284
+ let line = head;
285
+ for (const part of parts) {
286
+ if (line !== head && line.length + part.length > PASTE_MAX) {
287
+ out.push(line + "\n");
288
+ line = "";
289
+ }
290
+ line += part;
291
+ }
292
+ if (line)
293
+ out.push(line + "\n");
294
+ return out;
295
+ };
296
+ // Step 3: how many rows fit at all. The ceiling is counted on the PACKED
297
+ // result, never estimated from a character budget: greedy packing leaves a
298
+ // chunk short whenever the next row does not fit, so the two do not agree —
299
+ // and the quantity that costs (a wait per paste) is the chunk count.
300
+ // Always carry at least one row: a block that announces a delta and names
301
+ // nothing is worse than a long one.
302
+ let kept = pieces.length;
303
+ let chunks = pack(kept);
304
+ while (kept > 1 && chunks.length > PRELUDE_MAX_CHUNKS)
305
+ chunks = pack(--kept);
306
+ return chunks;
307
+ }
308
+ /** The same delta as ONE string — what lands in the transcript, and what the
309
+ * display then strips. The pastes are concatenated by the TUI exactly like
310
+ * this, so this is the text, not a rendering of it. */
173
311
  export function formatLedgerBlock(rows, total) {
174
- let line = `${LEDGER_HEAD}${total} update${total === 1 ? "" : "s"}⟧`;
175
- let shown = 0;
176
- for (const r of rows) {
177
- const handle = r.id ? `[${r.id}] ` : "";
178
- const src = r.source ? ` (${r.source})` : "";
179
- // A `fact` has no lifecycle and a `decision` is not a phase of one, so the
180
- // reader must not take their status for a position in open → resolved.
181
- // `task` is the default and nearly the whole table: tagging it would be noise.
182
- const kind = rowKind(r);
183
- const tag = kind === "task" ? "" : ` · ${kind}`;
184
- const bare = ` • ${handle}${r.entity} — ${r.status}${tag}${src}`;
185
- // Always carry at least one row: an empty block would say a delta arrived
186
- // and name nothing, which is worse than a long line.
187
- if (shown > 0 && line.length + bare.length > BLOCK_MAX)
188
- break;
189
- line += bare;
190
- shown++;
191
- const h = headline(r.note);
192
- if (h && line.length + h.length + 3 <= BLOCK_MAX)
193
- line += ` ${CONT_MARK} ${h}`;
194
- }
195
- if (shown < total)
196
- line += ` • (+${total - shown} more — run: ledger list)`;
197
- // Defensive: one oversized entity must not be able to defeat the one-line rule
198
- // by length, which costs exactly as much as a second line would.
199
- return line.length > BLOCK_MAX * 2 ? line.slice(0, BLOCK_MAX * 2 - 1) + "…" : line;
312
+ return formatLedgerChunks(rows, total).join("").replace(/\n$/, "");
200
313
  }
201
314
  /** Prepend the block as its own leading line. Idempotent.
202
315
  *
@@ -237,7 +350,11 @@ export function stripLedgerBlock(text) {
237
350
  return text;
238
351
  const lines = text.split("\n");
239
352
  let i = 1; // drop the header line
240
- while (i < lines.length && (lines[i].startsWith("• ") || CONT_LINE.test(lines[i])))
353
+ // A continuation chunk starts with the ` • ` of its first row, so the bullet
354
+ // test is made on the TRIMMED line: the leading space is a separator between
355
+ // rows, not indentation, and anchoring on it would leave every chunk but the
356
+ // first sitting in the displayed message.
357
+ while (i < lines.length && (lines[i].trimStart().startsWith("• ") || CONT_LINE.test(lines[i])))
241
358
  i++;
242
359
  // …and the blank lines it leaves behind. The block now travels as its OWN
243
360
  // paste, so the transcript holds `</pasted_content>` and a blank line between
@@ -1 +1 @@
1
- {"version":3,"file":"ledger.js","sourceRoot":"","sources":["../src/ledger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAmClE;gEACgE;AAChE,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;IAC5D,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,C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CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AAChD,CAAC;AAED;gEACgE;AAChE,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,IAAY,EACZ,SAAiB,EACjB,EAAU,EACV,IAA0B;IAE1B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAC9B,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;QACpB,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,IAAI,GAAG,MAAM,CAAC;QAC1B,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;YACxF,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QACH,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,6CAA6C;IAC/C,CAAC;AACH,CAAC"}
package/dist/server.js CHANGED
@@ -41,7 +41,7 @@ import { peerFileFor, loadPeers, savePeers, peerFromToken, signPeerToken, newPee
41
41
  import { loadCrons, saveCrons, upsertCron, removeCron, resolveCronId, nextRunFor, nextRunAfterFailure, isTransient, CRON_MAX_RETRIES, markCronPrompt, normalizeSchedule, onceAt, stateAfterFire, scheduleLabel, cronTimeZone, defaultTimeZone, systemTimeZone, isValidTimeZone, } from "./crons.js";
42
42
  import { markPromptMeta, promptMetaHeader } from "./promptmeta.js";
43
43
  import { runRefusal, isShellMode } from "./bang.js";
44
- import { ledgerFileFor, ensureLedgerFile, loadLedger, deltaSince, formatLedgerBlock, ledgerSeenFileFor, seenFor, recordSeen, } from "./ledger.js";
44
+ import { ledgerFileFor, ensureLedgerFile, loadLedger, deltaSince, formatLedgerChunks, ledgerSeenFileFor, seenFor, recordSeen, } from "./ledger.js";
45
45
  // The skill's pure core is the single source of the ledger's logic (CLAUDE.md):
46
46
  // the server imports it rather than keeping a second copy of the kind inference.
47
47
  import { rowKind } from "../context/ledger-skill/ledger-core.mjs";
@@ -1768,9 +1768,13 @@ let autoUpdate = loadConfig().autoUpdate ?? /^(1|true|yes|on)$/i.test(process.en
1768
1768
  // Gates the pilot-prompt paragraph; a live agent picks it up at next respawn.
1769
1769
  const ledgerEnv = (process.env.SHADOK_LEDGER ?? "").trim();
1770
1770
  let ledgerEnabled = loadConfig().ledgerEnabled ?? (ledgerEnv ? /^(1|true|yes|on)$/i.test(ledgerEnv) : true);
1771
- // Most ledger changes to push ahead of one human prompt; the rest collapse to a
1772
- // "+N more" line. Deltas are usually tiny, so this rarely bites.
1773
- const LEDGER_PUSH_CAP = 8;
1771
+ // Most ledger changes to push ahead of one human prompt. It used to be 8 and
1772
+ // the rest collapsed to a "+N more" line — i.e. a returning agent was told a
1773
+ // number and not the rows, which is the silo this feature exists to close. The
1774
+ // block is a LIST of pastes now, so what bounds it is the chunk ceiling in
1775
+ // `formatLedgerChunks` (latency, not the paste wrapper) and no longer a count:
1776
+ // this stays only as a second belt against a pathological table.
1777
+ const LEDGER_PUSH_CAP = 40;
1774
1778
  // Which release stream this instance follows: "alpha" (every merge) or "beta"
1775
1779
  // (promoted versions only). Absent config → beta, so an instance that predates
1776
1780
  // the setting keeps updating, just on the calmer channel.
@@ -3663,8 +3667,10 @@ wss.on("connection", (ws, req) => {
3663
3667
  if (ledgerEnabled) {
3664
3668
  const { rows, total } = deltaSince(loadLedger(ledgerFileFor(process.cwd())), session.ledgerSeenAt ?? 0, LEDGER_PUSH_CAP);
3665
3669
  ledgerSeen = Date.now();
3670
+ // One paste per chunk, and the threshold is applied per paste —
3671
+ // which is what lets the whole delta travel in the clear.
3666
3672
  if (rows.length)
3667
- ledgerPrelude = formatLedgerBlock(rows, total) + "\n";
3673
+ ledgerPrelude = formatLedgerChunks(rows, total);
3668
3674
  }
3669
3675
  await session.pilot.submit(submitText, ledgerPrelude);
3670
3676
  if (ledgerSeen !== null) {