@oisin-ee/pi-dogsled 0.34.1 → 0.35.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 (33) hide show
  1. package/README.md +28 -4
  2. package/package.json +1 -1
  3. package/pi/activity.ts +159 -36
  4. package/pi/observation.ts +15 -2
  5. package/pi/todo/README.md +16 -2
  6. package/pi/todo/src/branch-state.ts +223 -0
  7. package/pi/todo/src/delta-fixture.ts +141 -0
  8. package/pi/todo/src/delta-review-fixture.ts +63 -0
  9. package/pi/todo/src/delta-sequence-fixture.ts +59 -0
  10. package/pi/todo/src/delta-validation.ts +78 -0
  11. package/pi/todo/src/delta-worker-fixture.ts +102 -0
  12. package/pi/todo/src/delta.ts +152 -0
  13. package/pi/todo/src/generated/todo_core.d.ts +9 -0
  14. package/pi/todo/src/generated/todo_core.js +24 -0
  15. package/pi/todo/src/generated/todo_core_bg.wasm +0 -0
  16. package/pi/todo/src/generated/todo_core_bg.wasm.d.ts +1 -0
  17. package/pi/todo/src/history.ts +54 -0
  18. package/pi/todo/src/old-lifecycle-fixture.ts +106 -0
  19. package/pi/todo/src/old-provider-fixture.ts +290 -0
  20. package/pi/todo/src/old-reminder-fixture.ts +31 -0
  21. package/pi/todo/src/old-state-fixture.ts +106 -0
  22. package/pi/todo/src/old-tool-fixture.ts +61 -0
  23. package/pi/todo/src/order-index.ts +109 -0
  24. package/pi/todo/src/provenance.ts +54 -0
  25. package/pi/todo/src/provider.ts +34 -33
  26. package/pi/todo/src/reminder.ts +67 -17
  27. package/pi/todo/src/seal-reference-fixture.ts +59 -0
  28. package/pi/todo/src/snapshot-reference-fixture.ts +88 -0
  29. package/pi/todo/src/state.ts +88 -92
  30. package/pi/todo/src/tool.ts +4 -3
  31. package/pi/todo/src/wasm.ts +1 -0
  32. package/plugins/dogsled/skills/dogsled/references/commands.md +18 -0
  33. package/plugins/dogsled/skills/dogsled/references/land.md +1 -1
package/README.md CHANGED
@@ -13,13 +13,13 @@ Install the binary on each Herdr host. Use the same release tag in each command.
13
13
  Binary:
14
14
 
15
15
  ```sh
16
- mise use github:oisin-ee/dogsled@v0.34.1 # x-release-please-version
16
+ mise use github:oisin-ee/dogsled@v0.35.0 # x-release-please-version
17
17
  ```
18
18
 
19
19
  Pi (extension, tools, the `todo` tool, and skill), from npm:
20
20
 
21
21
  ```sh
22
- pi install npm:@oisin-ee/pi-dogsled@0.34.1 # x-release-please-version
22
+ pi install npm:@oisin-ee/pi-dogsled@0.35.0 # x-release-please-version
23
23
  ```
24
24
 
25
25
  At session start the extension compares its version with `dogsled --version` and warns when they differ.
@@ -58,8 +58,10 @@ The bot uses `GITHUB_TOKEN`, so its release-PR updates do not start CI.
58
58
  Nothing auto-merges the release PR.
59
59
 
60
60
  When the user requests a release, merge the open release-please PR.
61
- The merge runs the full CI suite on the release commit through the reusable CI workflow.
62
- After CI passes, the publish job creates `vX.Y.Z` at that release commit and dispatches dist.
61
+ The release commit changes only version files and the changelog.
62
+ Every passing CI run records the tree it tested, so the release gate reuses the PR's proof when the release commit sits on a tree that a run already proved.
63
+ Only otherwise does the merge run the full CI suite on the release commit through the reusable CI workflow.
64
+ After that gate, the publish job creates `vX.Y.Z` at that release commit and dispatches dist.
63
65
  Dist publishes the binaries and calls the existing npm publisher.
64
66
  The publish job changes `autorelease: pending` to `autorelease: tagged` so release-please can prepare the next release.
65
67
 
@@ -336,6 +338,22 @@ These reports do not change release decisions.
336
338
 
337
339
  See [Agent lifecycle and recovery](docs/lifecycle.md) for command limits, custody, origin release certificates, and migration.
338
340
 
341
+ ## Transfers
342
+
343
+ ```sh
344
+ dogsled transfer send worker --files notes.md
345
+ dogsled transfer send worker --changes --include-worktree
346
+ dogsled transfer list
347
+ dogsled transfer show TRANSFER_ID
348
+ dogsled transfer apply TRANSFER_ID --check
349
+ dogsled transfer apply TRANSFER_ID
350
+ dogsled transfer drop TRANSFER_ID
351
+ ```
352
+
353
+ A transfer stores files or changes for another agent and puts one notice in its inbox.
354
+ Nothing is applied until the recipient runs `apply`, which writes working files only.
355
+ See [Send files and changes to another agent](docs/transfer.md).
356
+
339
357
  ## Inbox
340
358
 
341
359
  Every message to an agent goes through one inbox on the agent's host: a child's final reply, a blocked report, an admitted ticket, a launch failure, and a message from another agent.
@@ -615,6 +633,12 @@ dogsled repo list --json
615
633
  ```
616
634
 
617
635
  The portal’s New picker searches repository names and descriptions, newest pushes first.
636
+ It receives catalogue updates through the existing portal stream, without another subscription or polling.
637
+ A successful hourly refresh clears the warning in the open picker without losing your draft or valid selection.
638
+ If the selected repository disappears, select a repository before sending. The picker never switches targets silently.
639
+ Portal snapshots use version 2; observation IPC remains version 1.
640
+ After a coordinated release rollout, restart `serve` and `web`, then reload existing portal tabs.
641
+ Older portal clients can report a decoding error until reloaded.
618
642
  `GET /api/repos` and `repo list --json` return `{repos, error}` from the published catalogue.
619
643
  Each repository contains `slug`, `description`, `pushed_at`, and `private`.
620
644
  Without a publication, readers report that the catalogue is unavailable.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oisin-ee/pi-dogsled",
3
- "version": "0.34.1",
3
+ "version": "0.35.0",
4
4
  "description": "Pi extension for dogsled: the board, the /dogsled panel, the inbox reader, and the dogsled tools. Needs the dogsled binary of the same version.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/pi/activity.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  // Session-scoped telemetry. Hooks reduce compact facts; only the publisher performs I/O.
2
2
  import { randomUUID } from "node:crypto";
3
+ import { existsSync } from "node:fs";
3
4
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
4
5
  import type { PortalClient } from "./portal-client.ts";
5
6
 
@@ -16,7 +17,13 @@ export type Payload =
16
17
  | { kind: "closed" };
17
18
  export type ActivityEvent =
18
19
  | { type: "agent_start" | "agent_end" | "settled" | "message_end" }
19
- | { type: "block"; index: number; phase: "thinking" | "responding"; ended: boolean; delta?: string }
20
+ | {
21
+ type: "block";
22
+ index: number;
23
+ phase: "thinking" | "responding";
24
+ ended: boolean;
25
+ delta?: string;
26
+ }
20
27
  | { type: "tool_start"; tool: ActiveTool }
21
28
  | { type: "tool_end"; id: string };
22
29
 
@@ -77,7 +84,10 @@ export class ActivityReducer {
77
84
  this.blocks.delete(event.index);
78
85
  if (!event.ended) this.blocks.set(event.index, event.phase);
79
86
  if (event.phase === "thinking") {
80
- this.thoughts.set(event.index, (this.thoughts.get(event.index) ?? "") + (event.delta ?? ""));
87
+ this.thoughts.set(
88
+ event.index,
89
+ (this.thoughts.get(event.index) ?? "") + (event.delta ?? ""),
90
+ );
81
91
  }
82
92
  } else if (event.type === "tool_start") {
83
93
  this.idle = false;
@@ -107,7 +117,10 @@ export class ActivityReducer {
107
117
  .join("\n\n"),
108
118
  16 * 1024,
109
119
  );
110
- return { kind: "snapshot", state: { phase, active_tools, ...(reasoning ? { reasoning } : {}) } };
120
+ return {
121
+ kind: "snapshot",
122
+ state: { phase, active_tools, ...(reasoning ? { reasoning } : {}) },
123
+ };
111
124
  }
112
125
  }
113
126
 
@@ -176,21 +189,44 @@ export class ActivityPublisher {
176
189
  private retryAt = -Infinity;
177
190
  private retryDelay = 500;
178
191
  private timer: ReturnType<typeof setTimeout> | undefined;
179
- private heartbeat: ReturnType<typeof setInterval>;
192
+ private heartbeat: ReturnType<typeof setInterval> | undefined;
180
193
  private controller: AbortController | undefined;
181
194
  private flight: Promise<void> | undefined;
182
195
  private readonly client: Client;
183
196
  private readonly pane: string;
184
197
  private readonly evidence: Evidence;
198
+ private readonly exists: (path: string) => boolean;
199
+ private readonly report: (message: string) => void;
185
200
 
186
- constructor(client: Client, pane: string, evidence: Evidence, idle: boolean) {
201
+ constructor(
202
+ client: Client,
203
+ pane: string,
204
+ evidence: Evidence,
205
+ idle: boolean,
206
+ report: (message: string) => void,
207
+ exists: (path: string) => boolean = existsSync,
208
+ ) {
187
209
  this.client = client;
188
210
  this.pane = pane;
189
211
  this.evidence = { ...evidence };
212
+ this.exists = exists;
213
+ this.report = report;
190
214
  this.path = `/api/agents/local/${encodeURIComponent(pane)}/activity`;
191
215
  this.reducer = new ActivityReducer(idle);
192
216
  this.pending = this.reducer.snapshot();
193
- this.request = { method: "GET", path: this.path };
217
+ this.evidenceReady();
218
+ }
219
+
220
+ evidenceReady(): void {
221
+ if (
222
+ this.disposed ||
223
+ this.stopped ||
224
+ this.request ||
225
+ this.stamp ||
226
+ !this.exists(this.evidence.session_file)
227
+ )
228
+ return;
229
+ this.request = this.registration(null, 0);
194
230
  this.heartbeat = setInterval(() => {
195
231
  if (this.disposed || this.stopped) return;
196
232
  this.pending = this.reducer.snapshot();
@@ -207,7 +243,14 @@ export class ActivityPublisher {
207
243
  }
208
244
 
209
245
  private schedule(): void {
210
- if (this.disposed || this.stopped || this.busy || this.timer) return;
246
+ if (
247
+ this.disposed ||
248
+ this.stopped ||
249
+ this.busy ||
250
+ this.timer ||
251
+ (!this.request && !this.stamp)
252
+ )
253
+ return;
211
254
  this.timer = setTimeout(
212
255
  () => {
213
256
  if (this.disposed) return;
@@ -242,7 +285,7 @@ export class ActivityPublisher {
242
285
  deadline = setTimeout(() => {
243
286
  controller.abort();
244
287
  reject(new Error("activity request deadline"));
245
- }, 1000);
288
+ }, 6000);
246
289
  deadline.unref();
247
290
  }),
248
291
  ]);
@@ -276,13 +319,54 @@ export class ActivityPublisher {
276
319
  const { status, body } = await this.send(request, controller);
277
320
  if (this.disposed) return;
278
321
  if (status < 200 || status >= 300) {
279
- const code = record(body) && typeof body["error"] === "string" ? body["code"] : undefined;
322
+ const receivedCode =
323
+ record(body) && typeof body["error"] === "string" ? body["code"] : undefined;
324
+ const code =
325
+ [
326
+ "invalid_request",
327
+ "unsupported_version",
328
+ "unauthorized",
329
+ "sequence_conflict",
330
+ "agent_missing",
331
+ "session_unverified",
332
+ "upstream_unavailable",
333
+ "session_changed",
334
+ "stale_generation",
335
+ "producer_closed",
336
+ "capacity",
337
+ "upstream_invalid",
338
+ ].find((known) => known === receivedCode) ?? "unknown";
280
339
  if (
281
- (request.method === "POST" &&
282
- (code === "session_changed" ||
340
+ code === "invalid_request" ||
341
+ code === "unsupported_version" ||
342
+ code === "unauthorized" ||
343
+ code === "sequence_conflict" ||
344
+ (status === 404 && code !== "agent_missing")
345
+ ) {
346
+ this.stop(status, code);
347
+ return;
348
+ }
349
+ // A 5xx may follow a committed mutation, even with a typed error body.
350
+ // Discovery failures return to POST so startup keeps cheap sampling alive.
351
+ if (
352
+ status >= 500 ||
353
+ code === "agent_missing" ||
354
+ code === "session_unverified" ||
355
+ code === "upstream_unavailable"
356
+ ) {
357
+ if (
358
+ request.method === "GET" &&
359
+ (code === "agent_missing" ||
283
360
  code === "session_unverified" ||
284
- code === "upstream_unavailable" ||
285
- code === "stale_generation")) ||
361
+ code === "upstream_unavailable")
362
+ )
363
+ this.request = this.registration(null, 0);
364
+ this.backoff();
365
+ return;
366
+ }
367
+ if (
368
+ (request.method === "POST" &&
369
+ (code === "session_changed" || code === "stale_generation")) ||
286
370
  (request.method === "PUT" &&
287
371
  (code === "stale_generation" ||
288
372
  code === "session_changed" ||
@@ -292,13 +376,10 @@ export class ActivityPublisher {
292
376
  this.sequence = 0;
293
377
  this.pending = this.reducer.snapshot();
294
378
  this.request = { method: "GET", path: this.path };
295
- this.retryAt = performance.now() + this.retryDelay;
296
- this.retryDelay = Math.min(5000, this.retryDelay * 2);
379
+ this.backoff();
297
380
  return;
298
381
  }
299
- // A server failure may follow a committed mutation. Retry this exact request.
300
- if (status >= 500) return;
301
- this.stop();
382
+ this.stop(status, code);
302
383
  return;
303
384
  }
304
385
  if (request.method === "GET") {
@@ -309,30 +390,30 @@ export class ActivityPublisher {
309
390
  !text(body["epoch"], 256) ||
310
391
  !record(body["producer"]) ||
311
392
  !counter(body["producer"]["generation"]) ||
312
- (body["producer"]["id"] !== null && body["producer"]["id"] !== undefined)
393
+ (body["producer"]["id"] !== null && !text(body["producer"]["id"], 256))
313
394
  ) {
314
- this.stop();
395
+ this.stop(status);
315
396
  return;
316
397
  }
317
- // Freeze fresh compare-and-swap evidence only while the pane is unowned.
318
- this.request = {
319
- method: "POST",
320
- path: `${this.path}/producer`,
321
- body: {
322
- version: 1,
323
- epoch: body["epoch"],
324
- expected_generation: body["producer"]["generation"],
325
- producer_id: this.producer,
326
- evidence: { ...this.evidence },
327
- },
328
- };
398
+ const detail = body["detail"];
399
+ const retired =
400
+ record(detail) &&
401
+ detail["availability"] === "unavailable" &&
402
+ (detail["reason"] === "producer_closed" || detail["reason"] === "expired");
403
+ if (body["producer"]["id"] !== null && !retired) {
404
+ // Generation-0 probes renew sampling interest by design without claiming the live generation.
405
+ this.request = this.registration(null, 0);
406
+ this.backoff();
407
+ return;
408
+ }
409
+ this.request = this.registration(body["epoch"], body["producer"]["generation"]);
329
410
  } else {
330
411
  if (
331
412
  !acknowledgement(body, this.pane, this.producer) ||
332
413
  body.sequence !== (request.method === "POST" ? 0 : this.sequence) ||
333
414
  (request.method === "POST" &&
334
415
  record(request.body) &&
335
- (body.epoch !== request.body["epoch"] ||
416
+ ((request.body["epoch"] !== null && body.epoch !== request.body["epoch"]) ||
336
417
  !counter(request.body["expected_generation"]) ||
337
418
  body.generation <= request.body["expected_generation"])) ||
338
419
  (this.stamp &&
@@ -340,7 +421,7 @@ export class ActivityPublisher {
340
421
  body.generation !== this.stamp.generation ||
341
422
  body.session !== this.stamp.session))
342
423
  ) {
343
- this.stop();
424
+ this.stop(status);
344
425
  return;
345
426
  }
346
427
  this.stamp = {
@@ -356,6 +437,7 @@ export class ActivityPublisher {
356
437
  } catch {
357
438
  // Offline and ambiguous outcomes are telemetry gaps, never hook failures.
358
439
  if (this.disposed) return;
440
+ this.backoff();
359
441
  } finally {
360
442
  if (!this.disposed) {
361
443
  this.busy = false;
@@ -365,10 +447,31 @@ export class ActivityPublisher {
365
447
  }
366
448
  }
367
449
 
368
- private stop(): void {
450
+ private registration(epoch: string | null, generation: number): Request {
451
+ return {
452
+ method: "POST",
453
+ path: `${this.path}/producer`,
454
+ body: {
455
+ version: 1,
456
+ epoch,
457
+ expected_generation: generation,
458
+ producer_id: this.producer,
459
+ evidence: { ...this.evidence },
460
+ },
461
+ };
462
+ }
463
+
464
+ private backoff(): void {
465
+ this.retryAt = performance.now() + this.retryDelay;
466
+ this.retryDelay = Math.min(5000, this.retryDelay * 2);
467
+ }
468
+
469
+ private stop(status: number, code = "invalid_response"): void {
470
+ if (this.stopped) return;
369
471
  this.stopped = true;
370
472
  clearInterval(this.heartbeat);
371
473
  if (this.timer) clearTimeout(this.timer);
474
+ this.report(`Dogsled live activity stopped: ${code} (HTTP ${status})`);
372
475
  }
373
476
 
374
477
  dispose(): void {
@@ -412,7 +515,19 @@ export function registerActivity(pi: ExtensionAPI, client: Client, pane: string
412
515
  const session_id = ctx.sessionManager.getSessionId();
413
516
  if (!session_file || !text(session_file, 4096) || !text(session_id, 1024) || !text(pane, 128))
414
517
  return;
415
- runtime = new ActivityPublisher(client, pane, { session_file, session_id }, ctx.isIdle());
518
+ runtime = new ActivityPublisher(
519
+ client,
520
+ pane,
521
+ { session_file, session_id },
522
+ ctx.isIdle(),
523
+ (message) => {
524
+ try {
525
+ ctx.ui.notify(message, "warning");
526
+ } catch {
527
+ /* A notification failure must not escape telemetry. */
528
+ }
529
+ },
530
+ );
416
531
  } catch {
417
532
  /* Missing native evidence leaves detail unavailable. */
418
533
  }
@@ -429,6 +544,13 @@ export function registerActivity(pi: ExtensionAPI, client: Client, pane: string
429
544
  });
430
545
  pi.on("agent_settled", () => {
431
546
  runtime?.event({ type: "settled" });
547
+ runtime?.evidenceReady();
548
+ });
549
+ pi.on("turn_end", () => {
550
+ runtime?.evidenceReady();
551
+ });
552
+ pi.on("message_start", () => {
553
+ runtime?.evidenceReady();
432
554
  });
433
555
  pi.on("message_update", (event) => {
434
556
  if (event.message.role !== "assistant") return;
@@ -452,6 +574,7 @@ export function registerActivity(pi: ExtensionAPI, client: Client, pane: string
452
574
  });
453
575
  pi.on("message_end", (event) => {
454
576
  if (event.message.role === "assistant") runtime?.event({ type: "message_end" });
577
+ runtime?.evidenceReady();
455
578
  });
456
579
  pi.on("tool_execution_start", (event) => {
457
580
  runtime?.event({
package/pi/observation.ts CHANGED
@@ -24,12 +24,19 @@ export type Spawn = (binary: string, args: string[]) => Watcher;
24
24
 
25
25
  const spawnWatcher: Spawn = (binary, args) => spawn(binary, args, { stdio: ["ignore", "pipe", "pipe"] });
26
26
 
27
+ /** A publication result, or the CLI's terminal JSON error from stdout. */
28
+ type Parsed = Observed & { terminal?: true };
29
+
27
30
  /** One line of `dogsled board --watch --json`. */
28
- export function parseFrame(line: string): Observed {
31
+ export function parseFrame(line: string): Parsed {
29
32
  let value: unknown;
30
33
  try { value = JSON.parse(line); } catch { return { error: "Dogsled observation sent an invalid frame" }; }
31
34
  if (!value || typeof value !== "object") return { error: "Dogsled observation sent an invalid frame" };
32
35
  const frame = value as Record<string, unknown>;
36
+ // main emits { error, deadline } on failure, outside the revisioned publication stream.
37
+ if (!("revision" in frame) && typeof frame["error"] === "string" && typeof frame["deadline"] === "boolean") {
38
+ return { error: clean(frame["error"]), terminal: true };
39
+ }
33
40
  if (typeof frame["revision"] !== "number") return { error: "Dogsled observation sent an invalid frame" };
34
41
  if (typeof frame["error"] === "string") return { error: clean(frame["error"]) };
35
42
  try {
@@ -72,12 +79,17 @@ export class Observation {
72
79
  }
73
80
  this.watcher = watcher;
74
81
  let stderr = "";
82
+ let terminalError: string | undefined;
75
83
  watcher.stderr?.setEncoding("utf8");
76
84
  watcher.stderr?.on("data", (chunk: string) => { stderr = (stderr + chunk).slice(-2_000); });
77
85
  const lines = createInterface({ input: watcher.stdout! });
78
86
  lines.on("line", line => {
79
87
  if (!current()) return;
80
88
  const observed = parseFrame(line);
89
+ if (observed.terminal) {
90
+ terminalError = observed.error;
91
+ return;
92
+ }
81
93
  // Revisions only move forward within one subscription.
82
94
  if (observed.frame) {
83
95
  if (observed.frame.revision <= this.revision) return;
@@ -93,7 +105,8 @@ export class Observation {
93
105
  if (!current()) return;
94
106
  this.watcher = undefined;
95
107
  this.revision = 0;
96
- this.listener({ error: `Dogsled observation unavailable: ${clean(detail)}` });
108
+ // Report the CLI cause once, after stdout has drained, rather than its generic exit code.
109
+ this.listener({ error: terminalError ?? `Dogsled observation unavailable: ${clean(detail)}` });
97
110
  };
98
111
  watcher.once("close", code => ended(stderr.trim() || `dogsled board exited with ${code ?? "a signal"}`));
99
112
  watcher.once("error", error => ended(String(error)));
package/pi/todo/README.md CHANGED
@@ -74,9 +74,23 @@ An active unit stays required for the sessions that implement code.
74
74
 
75
75
  ## State
76
76
 
77
- Each task change is saved as a `todo-state` entry on the session branch. A resumed session, a `/tree` move,
78
- and calls made from inside codemode all see the list of the current branch.
77
+ Task changes use `todo-delta` entries when they are smaller than a full `todo-state` snapshot.
78
+ Version 1 deltas contain changed roots or subtasks by unit ID, removed IDs, and order changes.
79
+ Each order change places one ID after another ID under a parent, or at the start when `after` is null.
80
+ A null parent identifies the root list. Changing one child does not copy its siblings.
81
+ Full snapshots replace the preceding list. Lists without stable IDs use full snapshots.
82
+ Before the first delta, the writer adds a `todo-state` fence with `format: "todo-delta/1"`.
83
+ The fence carries the current list. Every later full snapshot carries the same format key.
84
+ A plain snapshot after a fence fails with `INVALID_TODO_DELTA: unfenced snapshot after delta history`.
85
+ Each delta's changed tasks are validated on read. Cross-task rules are validated on the list each reader returns.
86
+
87
+ All readers replay the entries on the current branch. A resumed session, a `/tree` move,
88
+ and calls made from inside codemode see that branch's list.
89
+ Contract revisions and seals keep the identity of the entry that first introduced them.
90
+ A delta applies to the preceding list with those origins resolved, as each task mutation does.
79
91
  Old flat snapshots retain their recorded statuses and read with empty subtasks.
92
+ Older extensions refuse a session after its first delta. Use the updated extension to read or change that session.
93
+ Sessions without a fence remain readable by both versions.
80
94
 
81
95
  ## Widget
82
96