@oisin-ee/pi-dogsled 0.26.1 → 0.28.1

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 (44) hide show
  1. package/README.md +138 -29
  2. package/package.json +18 -7
  3. package/pi/board.ts +17 -10
  4. package/pi/index.ts +33 -5
  5. package/pi/interview.ts +112 -141
  6. package/pi/plan-mode.ts +7 -7
  7. package/pi/todo/CHANGELOG.md +133 -0
  8. package/pi/todo/README.md +133 -0
  9. package/pi/todo/src/contract-fixture.ts +103 -0
  10. package/pi/todo/src/display.ts +78 -0
  11. package/pi/todo/src/embedded.ts +105 -0
  12. package/pi/todo/src/gate.ts +89 -0
  13. package/pi/todo/src/generated/todo_core.d.ts +573 -0
  14. package/pi/todo/src/generated/todo_core.js +970 -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 +22 -0
  17. package/pi/todo/src/guidance.ts +16 -0
  18. package/pi/todo/src/handoff.ts +91 -0
  19. package/pi/todo/src/import-fixture.ts +63 -0
  20. package/pi/todo/src/index.ts +100 -0
  21. package/pi/todo/src/lease-fixture.ts +95 -0
  22. package/pi/todo/src/lifecycle.ts +105 -0
  23. package/pi/todo/src/plan-approved.ts +78 -0
  24. package/pi/todo/src/presentation.ts +70 -0
  25. package/pi/todo/src/provider-fixture.ts +50 -0
  26. package/pi/todo/src/provider.ts +289 -0
  27. package/pi/todo/src/registration-fixture.ts +126 -0
  28. package/pi/todo/src/reminder.ts +30 -0
  29. package/pi/todo/src/repository.ts +31 -0
  30. package/pi/todo/src/runtime-fixture.ts +255 -0
  31. package/pi/todo/src/schema.ts +99 -0
  32. package/pi/todo/src/source.ts +51 -0
  33. package/pi/todo/src/state.ts +105 -0
  34. package/pi/todo/src/tool.ts +60 -0
  35. package/pi/todo/src/wasm.ts +64 -0
  36. package/pi/todo/src/widget.ts +77 -0
  37. package/pi/todo/src/work.ts +180 -0
  38. package/pi/unit-bridge.ts +29 -16
  39. package/pi/unit-protocol.ts +35 -16
  40. package/pi/unit-worker.ts +7 -11
  41. package/pi/work-panel.ts +9 -8
  42. package/pi/work-todo.ts +30 -88
  43. package/plugins/dogsled/skills/dogsled/SKILL.md +2 -2
  44. package/plugins/dogsled/skills/dogsled/references/review.md +2 -3
package/pi/interview.ts CHANGED
@@ -1,15 +1,9 @@
1
- // The `interview` tool: the model asks the user a structured form, and the
2
- // portal's form server carries the questions and the answers. The tool keeps
3
- // the name, the parameters, and the result shape of pi-interview 0.13.0, so
4
- // the model asks the way it always did. Only the transport differs: the form
5
- // lives on the loopback portal server, not in a local window.
6
- import { randomUUID } from "node:crypto";
1
+ // Interviews live in the portal inbox. The owner opens the portal; asking a
2
+ // question never opens a browser or starts a temporary form server.
7
3
  import { readFileSync } from "node:fs";
8
- import { mkdtemp, rm, writeFile } from "node:fs/promises";
9
- import { tmpdir } from "node:os";
10
4
  import { isAbsolute, join } from "node:path";
11
5
  import type { AgentToolResult, AgentToolUpdateCallback, ExtensionAPI, ExtensionToolContext } from "@earendil-works/pi-coding-agent";
12
- import { openInBrowser, PortalClient, PortalDown, portalUrl, sleep, startOneShot } from "./portal-client.ts";
6
+ import { PortalClient, PortalDown, portalUrl, sleep } from "./portal-client.ts";
13
7
 
14
8
  /** How long the tool waits between two polls for the answers. */
15
9
  const POLL_MS = 500;
@@ -20,7 +14,7 @@ const interviewParameters = {
20
14
  required: ["questions"],
21
15
  properties: {
22
16
  questions: { type: "string", description: "Inline JSON string with questions, or path to a questions JSON file" },
23
- timeout: { type: "number", description: "Seconds before auto-timeout", default: 600 },
17
+ timeout: { type: "number", description: "Optional timeout in seconds. Without it, wait until the user answers or rejects the interview.", minimum: 1 },
24
18
  verbose: { type: "boolean", description: "Enable debug logging", default: false },
25
19
  async: { type: "boolean", description: "Return immediately instead of waiting for the user. The answer arrives later as a message tagged with the returned interview ID; keep working and do not poll.", default: false },
26
20
  theme: {
@@ -40,7 +34,8 @@ const interviewParameters = {
40
34
  /** The interview description with the portal's browser transport. */
41
35
  const interviewDescription =
42
36
  "Present an interactive form to gather user responses. " +
43
- "Opens the Dogsled portal, or a fallback browser tab when the portal is not running. " +
37
+ "Adds the form to the Dogsled portal inbox without opening a browser tab. Assume the user can open the portal. " +
38
+ "The user can answer or reject the interview with a reason. No timeout applies unless you explicitly set one. " +
44
39
  "Use proactively when: choosing between multiple approaches, gathering requirements before implementation, " +
45
40
  "exploring design tradeoffs, or when decisions have multiple dimensions worth discussing. " +
46
41
  "Provides better UX than back-and-forth chat for structured input. " +
@@ -48,6 +43,7 @@ const interviewDescription =
48
43
  "Pass questions as inline JSON string directly (preferred) or as a path to a JSON file. " +
49
44
  'Questions JSON format: { "title": "...", "description": "...", "questions": [{ "id": "q1", "type": "single|multi|text|image|info", "question": "...", "options": ["A", "B"], "content": { "source": "...", "lang": "ts" }, "media": { "type": "image|chart|mermaid|table|html", ... } }] }. ' +
50
45
  "Options can be strings or objects: { label: string, content?: { source, lang?, file?, lines?, highlights?, title?, showSource? } }. " +
46
+ "Every single and multi question automatically offers Other with a free-text answer; selected options also accept extra context. " +
51
47
  "Always set recommended with context explaining your reasoning. Recommended options show a 'Recommended' badge and are pre-selected for the user. " +
52
48
  'Use conviction: "slight" when unsure (does NOT pre-select), conviction: "strong" when very confident (shows Recommended badge). ' +
53
49
  "Omit conviction for normal recommendations (pre-selects). " +
@@ -60,14 +56,15 @@ const interviewDescription =
60
56
  /** One answer to one question, as the portal returns it. */
61
57
  export interface ResponseItem {
62
58
  id: string;
63
- value: string | string[] | { option: string; note?: string } | { option: string; note?: string }[];
59
+ value: string | { option: string; note?: string } | (string | { option: string; note?: string })[];
64
60
  attachments?: string[];
65
61
  }
66
62
 
67
63
  /** The result shape of pi-interview 0.13.0. */
68
64
  export interface InterviewDetails {
69
- status: "completed" | "cancelled" | "timeout" | "aborted" | "queued" | "started";
65
+ status: "completed" | "rejected" | "cancelled" | "timeout" | "aborted" | "queued" | "started";
70
66
  responses: ResponseItem[];
67
+ reason?: string;
71
68
  url: string;
72
69
  }
73
70
 
@@ -87,19 +84,13 @@ function isChoiceValue(value: unknown): value is { option: string; note?: string
87
84
 
88
85
  /** The value of one answer, as the model reads it. */
89
86
  function formatResponseValue(value: ResponseItem["value"]): string {
90
- if (Array.isArray(value)) {
91
- if (value.every(isChoiceValue)) return value.map(item => item.note ? `${item.option} (${item.note})` : item.option).join(", ");
92
- return value.join(", ");
93
- }
87
+ if (Array.isArray(value)) return value.map(formatResponseValue).join(", ");
94
88
  if (isChoiceValue(value)) return value.note ? `${value.option} (${value.note})` : value.option;
95
89
  return value;
96
90
  }
97
91
 
98
92
  function hasAnswerValue(value: ResponseItem["value"]): boolean {
99
- if (Array.isArray(value)) {
100
- if (value.every(isChoiceValue)) return value.some(item => item.option.trim() !== "");
101
- return value.some(item => typeof item === "string" && item.trim() !== "");
102
- }
93
+ if (Array.isArray(value)) return value.some(hasAnswerValue);
103
94
  if (isChoiceValue(value)) return value.option.trim() !== "";
104
95
  return typeof value === "string" && value.trim() !== "";
105
96
  }
@@ -240,12 +231,20 @@ function attachmentUrl(path: string): string {
240
231
  * the tool names the answers from the questions the model sent. Any other
241
232
  * body is an error that names the shape it expected.
242
233
  */
243
- function parseAnswers(value: unknown): ResponseItem[] {
244
- const payload = value as { id?: unknown; responses?: unknown } | null;
234
+ function parseAnswers(value: unknown): { responses: ResponseItem[]; rejection?: { reason: string } } {
235
+ const payload = value as { id?: unknown; responses?: unknown; rejection?: unknown } | null;
245
236
  if (!payload || typeof payload !== "object" || Array.isArray(payload) || typeof payload.id !== "string" || !Array.isArray(payload.responses)) {
246
237
  throw new Error('dogsled web returned an unexpected answer shape: expected {"id": string, "responses": ResponseItem[]}');
247
238
  }
248
- return payload.responses.filter(isResponseItem);
239
+ if (!payload.responses.every(isResponseItem)) throw new Error("dogsled web returned an invalid response item");
240
+ if (payload.rejection !== undefined) {
241
+ const rejection = payload.rejection as { reason?: unknown } | null;
242
+ if (!rejection || typeof rejection !== "object" || typeof rejection.reason !== "string" || payload.responses.length !== 0) {
243
+ throw new Error("dogsled web returned an invalid rejection");
244
+ }
245
+ return { responses: [], rejection: { reason: rejection.reason } };
246
+ }
247
+ return { responses: payload.responses };
249
248
  }
250
249
 
251
250
  /** One answer of the portal, in the shape the contract names. */
@@ -256,17 +255,22 @@ function isResponseItem(value: unknown): value is ResponseItem {
256
255
  return item.attachments === undefined || Array.isArray(item.attachments);
257
256
  }
258
257
 
258
+ interface Outcome {
259
+ status: "completed" | "rejected" | "cancelled" | "timeout" | "aborted";
260
+ text: string;
261
+ responses: ResponseItem[];
262
+ reason?: string;
263
+ }
264
+
259
265
  /** The `interview` tool: ask the user a form through the portal and wait for the answers. */
260
266
  export class InterviewTool {
261
267
  private readonly client: PortalClient;
262
268
  private readonly deliver: (content: string) => void;
263
- private readonly open: (url: string) => void;
264
269
  /** The background waits of the async interviews, so the session can close them. */
265
- private readonly pending = new Set<AbortController>();
266
- constructor(client: PortalClient = new PortalClient(), deliver: (content: string) => void = () => undefined, open: (url: string) => void = openInBrowser) {
270
+ private readonly pending = new Map<AbortController, Promise<Outcome>>();
271
+ constructor(client: PortalClient = new PortalClient(), deliver: (content: string) => void = () => undefined) {
267
272
  this.client = client;
268
273
  this.deliver = deliver;
269
- this.open = open;
270
274
  }
271
275
 
272
276
  /** Run one interview. The tool's `signal` withdraws the form. */
@@ -277,113 +281,50 @@ export class InterviewTool {
277
281
  // The questions are parsed before the call, so a broken file or bad JSON
278
282
  // is a tool error and never reaches the portal.
279
283
  const file = loadQuestions(params.questions, cwd);
280
- let created: { id?: unknown };
281
- try {
282
- // The images of the form are uploaded first, so the browser loads
283
- // them from the portal instead of from the agent's own disk.
284
- const questions = await this.uploadMedia(file, cwd, signal);
285
- created = await this.client.json<{ id?: unknown }>("POST", "/api/questions", {
286
- questions, pane, session, cwd,
287
- }, signal);
288
- } catch (error) {
289
- if (!(error instanceof PortalDown)) throw error;
290
- // The portal is down, so the form goes to the one-shot interview
291
- // with the questions as the model wrote them.
292
- return this.fallback(file, params, ctx, signal);
284
+ if (params.timeout !== undefined && (!Number.isFinite(params.timeout) || params.timeout < 1 || params.timeout > 2_147_483)) {
285
+ throw new Error("Interview timeout must be between 1 and 2147483 seconds.");
293
286
  }
287
+ const uploaded = await this.uploadMedia(file, cwd, signal);
288
+ const created = await this.client.json<{ id?: unknown }>("POST", "/api/questions", {
289
+ questions: uploaded, pane, session, cwd,
290
+ }, signal);
294
291
  const id = typeof created?.id === "string" ? created.id : "";
295
292
  if (!id) throw new Error("dogsled web did not return an interview id");
296
293
  const url = portalUrl(`/?question=${encodeURIComponent(id)}&pane=${encodeURIComponent(pane)}`, this.client.env);
297
- this.open(url);
298
294
  onUpdate?.({
299
- content: [{ type: "text", text: `Interview ${id} started: ${url}. Waiting for your answers.` }],
295
+ content: [{ type: "text", text: `Interview ${id} is in the Dogsled inbox: ${url}. Waiting for answers or rejection.` }],
300
296
  details: { status: "started", responses: [], url },
301
297
  });
302
298
 
299
+ const own = new AbortController();
300
+ const operation = params.async || !signal ? own.signal : AbortSignal.any([own.signal, signal]);
301
+ if (signal?.aborted) own.abort();
302
+ const answer = this.wait(id, file, operation, params.timeout)
303
+ .finally(() => { this.pending.delete(own); });
304
+ this.pending.set(own, answer);
303
305
  if (params.async) {
304
- // The form runs on its own: the tool's own signal no longer owns it, and the
305
- // answers arrive as a message, like pi-interview does.
306
- const own = new AbortController();
307
- this.pending.add(own);
308
- void this.wait(id, file, own.signal, params.timeout)
309
- .then(answers => { this.deliver(`Interview ${id} finished.\n\n${answers.text}`); })
310
- .catch(error => { this.deliver(`Interview ${id} did not finish: ${error instanceof Error ? error.message : String(error)}`); })
311
- .finally(() => { this.pending.delete(own); });
306
+ void answer.then(outcome => {
307
+ if (!own.signal.aborted) this.deliver(`Interview ${id} ${outcome.status}.\n\n${outcome.text}`);
308
+ }).catch(error => {
309
+ if (!own.signal.aborted) this.deliver(`Interview ${id} did not finish: ${error instanceof Error ? error.message : String(error)}`);
310
+ });
312
311
  return {
313
- content: [{ type: "text", text: `Interview ${id} started: ${url}. The answer arrives later as a message; keep working and do not poll.` }],
312
+ content: [{ type: "text", text: `Interview ${id} is in the Dogsled inbox: ${url}. The outcome arrives later as a message; keep working and do not poll.` }],
314
313
  details: { status: "started", responses: [], url },
315
314
  };
316
315
  }
317
-
318
- try {
319
- const answers = await this.wait(id, file, signal, params.timeout);
320
- return {
321
- content: [{ type: "text", text: `User completed the interview form: ${url}\n\nAnswered responses:\n${answers.text}` }],
322
- details: { status: "completed", responses: answers.responses, url },
323
- };
324
- } catch (error) {
325
- // An aborted interview withdraws its form, so the portal does not wait for an answer.
326
- if (signal?.aborted) {
327
- await this.client.request("DELETE", `/api/questions/${encodeURIComponent(id)}`).catch(() => undefined);
328
- return { content: [{ type: "text", text: "Interview was aborted." }], details: { status: "aborted", responses: [], url } };
329
- }
330
- throw error;
331
- }
332
- }
333
-
334
- /** Run the same form on a temporary server when the portal cannot be reached. */
335
- private async fallback(file: QuestionsFile, params: { timeout?: number; async?: boolean }, ctx: ExtensionToolContext, signal: AbortSignal | undefined): Promise<AgentToolResult<InterviewDetails>> {
336
- const directory = await mkdtemp(join(tmpdir(), "dogsled-interview-"));
337
- const own = new AbortController();
338
- const abort = params.async || !signal ? own.signal : AbortSignal.any([own.signal, signal]);
339
- this.pending.add(own);
340
- let background = false;
341
- try {
342
- const path = join(directory, "questions.json");
343
- await writeFile(path, JSON.stringify(file), { mode: 0o600 });
344
- const command = startOneShot([
345
- "interview", "--file", path, "--pane", process.env["HERDR_PANE_ID"] ?? "",
346
- "--session", ctx.sessionManager.getSessionId(), "--cwd", ctx.cwd,
347
- "--timeout", String(Math.max(1, Math.ceil(params.timeout ?? 600))),
348
- ], this.client.env, abort);
349
- await command.started;
350
- const answer = command.result.then(stdout => parseAnswers(JSON.parse(stdout)));
351
- if (params.async) {
352
- const id = randomUUID();
353
- background = true;
354
- void answer.finally(async () => {
355
- this.pending.delete(own);
356
- await rm(directory, { recursive: true, force: true });
357
- }).then(responses => {
358
- this.deliver(`Interview ${id} finished.\n\n${formatAnsweredResponses(responses, formQuestions(file))}`);
359
- }).catch(error => {
360
- if (!own.signal.aborted) this.deliver(`Interview ${id} did not finish: ${error instanceof Error ? error.message : String(error)}`);
361
- });
362
- return {
363
- content: [{ type: "text", text: `Interview ${id} started. The answer arrives later as a message; keep working and do not poll.` }],
364
- details: { status: "started", responses: [], url: "" },
365
- };
366
- }
367
- const responses = await answer;
368
- return {
369
- content: [{ type: "text", text: `User completed the interview form.\n\nAnswered responses:\n${formatAnsweredResponses(responses, formQuestions(file))}` }],
370
- details: { status: "completed", responses, url: "" },
371
- };
372
- } catch (error) {
373
- if (abort.aborted) return { content: [{ type: "text", text: "Interview was aborted." }], details: { status: "aborted", responses: [], url: "" } };
374
- throw error;
375
- } finally {
376
- if (!background) {
377
- this.pending.delete(own);
378
- await rm(directory, { recursive: true, force: true });
379
- }
380
- }
316
+ const { text, ...details } = await answer;
317
+ return { content: [{ type: "text", text: `${text}\n\n${url}` }], details: { ...details, url } };
381
318
  }
382
319
 
383
- /** Close the background waits of the async interviews. */
384
- close(): void {
385
- for (const controller of this.pending) controller.abort();
320
+ /** Finish withdrawal before the extension runtime exits or is replaced. */
321
+ async close(): Promise<void> {
322
+ for (const controller of this.pending.keys()) controller.abort();
323
+ const results = await Promise.allSettled(this.pending.values());
386
324
  this.pending.clear();
325
+ for (const result of results) {
326
+ if (result.status === "rejected") throw result.reason;
327
+ }
387
328
  }
388
329
 
389
330
  /**
@@ -395,9 +336,7 @@ export class InterviewTool {
395
336
  * attachment, and the `src` becomes the URL the portal serves.
396
337
  *
397
338
  * The portal is asked whether it is there before the first local file is
398
- * read, so a portal that is down falls back to the one-shot interview
399
- * with the questions as the model wrote them, and a missing file stays a
400
- * tool error only when there is a portal to upload it to.
339
+ * read. If it is down, report that directly without starting another server.
401
340
  */
402
341
  private async uploadMedia(file: QuestionsFile, cwd: string, signal: AbortSignal | undefined): Promise<QuestionsFile> {
403
342
  const list = file["questions"];
@@ -451,9 +390,8 @@ export class InterviewTool {
451
390
  /**
452
391
  * The bytes of an image, as an attachment of the portal.
453
392
  *
454
- * A portal that cannot be reached is a `PortalDown` error, so the form
455
- * falls back to the one-shot interview. A portal that refuses the image
456
- * is an error that names the file.
393
+ * A portal that cannot be reached is a `PortalDown` error.
394
+ * A portal that refuses the image is an error that names the file.
457
395
  */
458
396
  private async uploadAttachment(bytes: Buffer, path: string, signal: AbortSignal | undefined): Promise<string> {
459
397
  let response: Response;
@@ -484,29 +422,62 @@ export class InterviewTool {
484
422
  return attachmentUrl(payload.path);
485
423
  }
486
424
 
487
- /** Poll the portal until it has the answers, the form is withdrawn, or the wait ends. */
488
- private async wait(id: string, file: QuestionsFile, signal: AbortSignal | undefined, timeout: number | undefined): Promise<{ text: string; responses: ResponseItem[] }> {
489
- const seconds = timeout ?? 600;
490
- const deadline = Date.now() + Math.max(1, seconds) * 1000;
491
- for (;;) {
492
- if (signal?.aborted) throw new Error("Interview was aborted.");
493
- const response = await this.client.request("GET", `/api/questions/${encodeURIComponent(id)}/answer`, { signal });
494
- if (response.status === 204) {
495
- if (Date.now() >= deadline) throw new Error(`Interview form timed out after ${seconds} seconds.`);
496
- await sleep(POLL_MS, signal);
497
- continue;
425
+ /** Resolve saved outcomes consistently in sync, async, and cancellation races. */
426
+ private outcome(payload: unknown, file: QuestionsFile): Outcome {
427
+ const { responses, rejection } = parseAnswers(payload);
428
+ if (rejection) return {
429
+ status: "rejected", responses: [], reason: rejection.reason,
430
+ text: `User rejected the interview. Do not treat this as approval.\n\nReason: ${rejection.reason || "No reason given."}`,
431
+ };
432
+ return { status: "completed", responses, text: `User completed the interview form.\n\nAnswered responses:\n${formatAnsweredResponses(responses, formQuestions(file))}` };
433
+ }
434
+
435
+ /** Cancel abandoned forms, but recover a terminal outcome that won the race. */
436
+ private async withdraw(id: string, file: QuestionsFile): Promise<Outcome | undefined> {
437
+ const signal = AbortSignal.timeout(5_000);
438
+ const path = `/api/questions/${encodeURIComponent(id)}`;
439
+ const response = await this.client.request("DELETE", path, { signal });
440
+ if (response.status === 409) {
441
+ const saved = await this.client.json<unknown>("GET", `${path}/answer?wait=0`, undefined, signal);
442
+ return this.outcome(saved, file);
443
+ }
444
+ if (!response.ok && response.status !== 410) throw new Error(`Could not withdraw interview ${id}: HTTP ${response.status}`);
445
+ return undefined;
446
+ }
447
+
448
+ /** No implicit deadline: the owner can leave the form in the inbox until ready. */
449
+ private async wait(id: string, file: QuestionsFile, signal: AbortSignal, timeout: number | undefined): Promise<Outcome> {
450
+ const deadline = new AbortController();
451
+ const timer = timeout === undefined ? undefined : setTimeout(() => deadline.abort(), timeout * 1000);
452
+ timer?.unref();
453
+ const operation = AbortSignal.any([signal, deadline.signal]);
454
+ try {
455
+ for (;;) {
456
+ operation.throwIfAborted();
457
+ const response = await this.client.request("GET", `/api/questions/${encodeURIComponent(id)}/answer`, { signal: operation });
458
+ if (response.status === 204) {
459
+ await sleep(POLL_MS, operation);
460
+ continue;
461
+ }
462
+ if (response.status === 410) return { status: "cancelled", responses: [], text: "The interview was withdrawn." };
463
+ if (!response.ok) throw new Error(`dogsled web GET /api/questions/${id}/answer failed: ${response.status} ${(await response.text()).trim()}`);
464
+ return this.outcome(await response.json(), file);
498
465
  }
499
- if (response.status === 410) throw new Error("The interview form was withdrawn before it was answered.");
500
- if (!response.ok) throw new Error(`dogsled web GET /api/questions/${id}/answer failed: ${response.status} ${(await response.text()).trim()}`);
501
- const responses = parseAnswers(await response.json());
502
- return { text: formatAnsweredResponses(responses, formQuestions(file)), responses };
466
+ } catch (error) {
467
+ const saved = await this.withdraw(id, file);
468
+ if (saved) return saved;
469
+ if (signal.aborted) return { status: "aborted", responses: [], text: "Interview was aborted." };
470
+ if (deadline.signal.aborted) return { status: "timeout", responses: [], text: `Interview timed out after ${timeout} seconds and was removed from the inbox.` };
471
+ throw error;
472
+ } finally {
473
+ if (timer) clearTimeout(timer);
503
474
  }
504
475
  }
505
476
  }
506
477
 
507
478
  /** Register the `interview` tool. */
508
479
  export function registerInterview(pi: ExtensionAPI, client: PortalClient = new PortalClient()): InterviewTool {
509
- const tool = new InterviewTool(client, content => { pi.sendUserMessage(content); });
480
+ const tool = new InterviewTool(client, content => { pi.sendUserMessage(content, { deliverAs: "steer" }); });
510
481
  pi.registerTool({
511
482
  name: "interview",
512
483
  label: "Interview",
package/pi/plan-mode.ts CHANGED
@@ -36,7 +36,7 @@ export interface Decision {
36
36
  plan_content: string;
37
37
  }
38
38
 
39
- /** The payload the plan-approved event carries, as pi-todo consumes it. */
39
+ /** The approved document and reviewer feedback passed to pi-todo. */
40
40
  export interface PlanApproved {
41
41
  cwd: string;
42
42
  planFilePath: string;
@@ -46,7 +46,6 @@ export interface PlanApproved {
46
46
 
47
47
  /** The parts of the extension API that plan mode uses. */
48
48
  export interface PlanHost {
49
- events: ExtensionAPI["events"];
50
49
  sendUserMessage(content: string, options?: { deliverAs?: "steer" | "followUp" }): void;
51
50
  sendMessage(message: { customType: string; content: string; display: boolean }, options?: { triggerTurn?: boolean; deliverAs?: "steer" | "followUp" }): void;
52
51
  getActiveTools(): string[];
@@ -118,6 +117,7 @@ export class PlanMode {
118
117
  private readonly pi: PlanHost;
119
118
  private readonly client: PortalClient;
120
119
  private readonly open: (url: string) => void;
120
+ private readonly approved: (plan: PlanApproved, ctx: ExtensionContext) => void;
121
121
  private planning = false;
122
122
  private framed = false;
123
123
  private watching: AbortController | undefined;
@@ -127,8 +127,9 @@ export class PlanMode {
127
127
  /** The reviews the portal acknowledged. A review that was delivered but not acked is acked again, not delivered again. */
128
128
  private readonly acked = new Set<string>();
129
129
 
130
- constructor(pi: PlanHost, client: PortalClient = new PortalClient(), open: (url: string) => void = openInBrowser) {
130
+ constructor(pi: PlanHost, approved: (plan: PlanApproved, ctx: ExtensionContext) => void, client: PortalClient = new PortalClient(), open: (url: string) => void = openInBrowser) {
131
131
  this.pi = pi;
132
+ this.approved = approved;
132
133
  this.client = client;
133
134
  this.open = open;
134
135
  }
@@ -279,7 +280,7 @@ export class PlanMode {
279
280
  planContent: typeof decision.plan_content === "string" ? decision.plan_content : "",
280
281
  ...(message ? { feedback: message } : {}),
281
282
  };
282
- this.pi.events.emit("dogsled:plan-approved", approved);
283
+ this.approved(approved, ctx);
283
284
  this.stop();
284
285
  }
285
286
  }
@@ -303,15 +304,14 @@ export class PlanMode {
303
304
  }
304
305
 
305
306
  /** Register the plan mode: the submit tool, the command, and the shortcut. */
306
- export function registerPlanMode(pi: ExtensionAPI, client: PortalClient = new PortalClient(), open: (url: string) => void = openInBrowser): PlanMode {
307
+ export function registerPlanMode(pi: ExtensionAPI, approved: (plan: PlanApproved, ctx: ExtensionContext) => void, client: PortalClient = new PortalClient(), open: (url: string) => void = openInBrowser): PlanMode {
307
308
  const host: PlanHost = {
308
- events: pi.events,
309
309
  sendUserMessage: (content, options) => { pi.sendUserMessage(content, options); },
310
310
  sendMessage: (message, options) => { pi.sendMessage(message, options); },
311
311
  getActiveTools: () => pi.getActiveTools(),
312
312
  setActiveTools: names => { pi.setActiveTools(names); },
313
313
  };
314
- const mode = new PlanMode(host, client, open);
314
+ const mode = new PlanMode(host, approved, client, open);
315
315
  pi.registerTool({
316
316
  name: SUBMIT_PLAN,
317
317
  label: "Submit plan",
@@ -0,0 +1,133 @@
1
+ # @oisin-ee/pi-todo
2
+
3
+ ## 0.12.1
4
+
5
+ No changes in this release.
6
+
7
+ ## 0.12.0
8
+
9
+ ### Minor Changes
10
+
11
+ - [#40](https://github.com/oisin-ee/oisinpi/pull/40) [`7fcdc45`](https://github.com/oisin-ee/oisinpi/commit/7fcdc45f08c065faf38c3841c0b2d2133ad9322f) Thanks [@momo-momokaya](https://github.com/apps/momo-momokaya)! - Continue plans approved in Dogsled plan mode through the existing todo tool in the same session. Receive plan approvals without additional configuration.
12
+
13
+ Document Dogsled plan mode as the owner of planning restrictions.
14
+
15
+ ## 0.11.1
16
+
17
+ No changes in this release.
18
+
19
+ ## 0.11.0
20
+
21
+ ### Patch Changes
22
+
23
+ - [`0e37d82`](https://github.com/oisin-ee/oisinpi/commit/0e37d8259d4a7cb4cffbeccfce2a36caa0274b6e) Thanks [@momo-momokaya[bot]](https://github.com/momo-momokaya%5Bbot%5D)! - Skip the todo activation check for the planning selections `tier/plan-claude` and `tier/plan-gpt`. Every other selection still needs an active local unit.
24
+
25
+ ## 0.10.2
26
+
27
+ ### Patch Changes
28
+
29
+ - [#35](https://github.com/oisin-ee/oisinpi/pull/35) [`a4554dc`](https://github.com/oisin-ee/oisinpi/commit/a4554dc2e64ba6e82fe5731992ba26c0c31c59b2) Thanks [@momo-momokaya](https://github.com/apps/momo-momokaya)! - A worker can call `dogsled done` after it closes its seeded todo leaf. Before, the todo gate blocked `mcp__dogsled__done`, so a finished worker could not report done.
30
+
31
+ ## 0.10.1
32
+
33
+ ### Patch Changes
34
+
35
+ - [#33](https://github.com/oisin-ee/oisinpi/pull/33) [`ac2e931`](https://github.com/oisin-ee/oisinpi/commit/ac2e931bf8d907eced3d075ebae2e9707713ea6f) Thanks [@momo-momokaya](https://github.com/apps/momo-momokaya)! - The owning lead can close any open leaf with `done` and a short note, or with `drop`. Closing a leaf that a worker holds clears the binding, records the execution as released, and frees its paths. A late settlement for a released execution is a no-op.
36
+
37
+ ## 0.10.0
38
+
39
+ ### Minor Changes
40
+
41
+ - [#30](https://github.com/oisin-ee/oisinpi/pull/30) [`5ab2bcc`](https://github.com/oisin-ee/oisinpi/commit/5ab2bcc44215d4f22e319d93dc57e8af12499b28) Thanks [@momo-momokaya](https://github.com/apps/momo-momokaya)! - Publish todo status groups as typed data. The work protocol is now version 3: the version 2 snapshot plus `display.sections`, four sections (`in_progress`, `pending`, `completed`, `abandoned`) that each carry a count and items with text, review flag, contract summary, and subtasks. Pi-todo no longer answers version 2 requests, so an older presenter falls back to standalone todos. Todos also gain an optional `description` on outcomes and subtasks: `content` is now a short headline and the description holds the detail. `update` sets or clears it, `view` prints it under the headline, and `display.sections` carries it for presenters; the Pi widget still shows headlines only.
42
+
43
+ ## 0.9.3
44
+
45
+ No changes in this release.
46
+
47
+ ## 0.9.2
48
+
49
+ No changes in this release.
50
+
51
+ ## 0.9.1
52
+
53
+ No changes in this release.
54
+
55
+ ## 0.9.0
56
+
57
+ No changes in this release.
58
+
59
+ ## 0.8.0
60
+
61
+ ### Minor Changes
62
+
63
+ - [`50877ec`](https://github.com/oisin-ee/oisinpi/commit/50877ec0f9bba71b7f70d8bf8d3754191ac73364) Thanks [@oisincoveney](https://github.com/oisincoveney)! - Add executable task contracts, local activation gates, and profile-assigned worker handoff. Import exact worker contracts before their first task request. Attach returned evidence without accepting the lead task automatically.
64
+
65
+ Use the executor-owned seed path capability with compatible Dogsled tooling. Require Pi 1.3.0 for the loaded startup guard. Prewalk recognizes validated activation and preserves its post-edit model switch.
66
+
67
+ ## 0.7.2
68
+
69
+ No changes in this release.
70
+
71
+ ## 0.7.1
72
+
73
+ ### Patch Changes
74
+
75
+ - [`b2ebd5a`](https://github.com/oisin-ee/oisinpi/commit/b2ebd5aefa0a52d84e7685c014fef5203e30e3a3) Thanks [@momo-momokaya[bot]](https://github.com/momo-momokaya%5Bbot%5D)! - Show completion reminders in the conversation. Reminder limits and continuation behavior remain unchanged.
76
+
77
+ ## 0.7.0
78
+
79
+ No changes in this release.
80
+
81
+ ## 0.6.0
82
+
83
+ ### Minor Changes
84
+
85
+ - [`eb67440`](https://github.com/oisin-ee/oisinpi/commit/eb674408bf1dfbdfec7fd319c3863ad05b3d730d) Thanks [@momo-momokaya[bot]](https://github.com/momo-momokaya%5Bbot%5D)! - Add two-level outcomes and bounded subtasks with exact parent-scoped targets. Creation stays pending, and explicit starts preserve parallel active work. Automatic activation is removed.
86
+
87
+ Keep parents open for explicit integration review after children close. Reject premature completion atomically. Preserve completed children when dropping a parent.
88
+
89
+ Show hierarchy and separate progress in shared rendering, model output, and reminders. Add work-unit guidance to tool results and approved-plan continuation. Old flat snapshots remain readable.
90
+
91
+ Pi-todo now supplies the renderer hosted by Wrangle's inline widget through display protocol version 2. Shared presentation requires a matching Wrangle release. Older integrations retain standalone todos instead of flattening subtasks.
92
+
93
+ ## 0.5.1
94
+
95
+ No changes in this release.
96
+
97
+ ## 0.5.0
98
+
99
+ No changes in this release.
100
+
101
+ ## 0.4.0
102
+
103
+ ### Minor Changes
104
+
105
+ - [`0a1434e`](https://github.com/oisin-ee/oisinpi/commit/0a1434eedb156c21abd36ae611a124b06f0ad1d8) Thanks [@momo-momokaya[bot]](https://github.com/momo-momokaya%5Bbot%5D)! - Continue approved Plannotator plans with the existing todo tool when external execution is enabled. Keep one branch-backed task list instead of a separate Plannotator checklist.
106
+
107
+ - [`74a563f`](https://github.com/oisin-ee/oisinpi/commit/74a563f9fa806902d9c0cf7d1d2e01edea255dec) Thanks [@momo-momokaya[bot]](https://github.com/momo-momokaya%5Bbot%5D)! - Publish validated todo snapshots for Wrangle's shared work display. Keep task state on the Pi session branch and restore the standalone widget when shared presentation ends.
108
+
109
+ ## 0.3.0
110
+
111
+ ### Minor Changes
112
+
113
+ - [`7f33497`](https://github.com/oisin-ee/oisinpi/commit/7f3349706861ab943f0be931ab3cff49e74d5f37) Thanks [@momo-momokaya[bot]](https://github.com/momo-momokaya%5Bbot%5D)! - Show only in-progress tasks in a themed, width-aware widget by default. Alt+T and /todos toggle grouped upcoming, done, and dropped tasks inline. Use /todos list for the full text summary.
114
+
115
+ ## 0.2.0
116
+
117
+ ### Minor Changes
118
+
119
+ - [#10](https://github.com/oisin-ee/oisinpi/pull/10) [`1c8612b`](https://github.com/oisin-ee/oisinpi/commit/1c8612b7dd1ce00e948d6fd6d3a421f956629e1a) Thanks [@momo-momokaya](https://github.com/apps/momo-momokaya)! - `@oisin-ee/oisinpi` replaces `@oisin-ee/pi-prewalk-kit`. It bundles pi-prewalk, pi-todo, pi-guardrails, and
120
+ pi-wrangle 0.11.0. `@oisin-ee/pi-guardrails` is new: the agent hook policies for pi, Claude Code (`agent-hook`), and
121
+ Codex, ported from the dotfiles hooks runtime.
122
+
123
+ ## 0.1.1
124
+
125
+ ### Patch Changes
126
+
127
+ - [#8](https://github.com/oisin-ee/pi-prewalk/pull/8) [`785734f`](https://github.com/oisin-ee/pi-prewalk/commit/785734ff387908f263c9031d8b16392ece7198f5) Thanks [@momo-momokaya](https://github.com/apps/momo-momokaya)! - `/prewalk on` arms a handoff, the same as `/prewalk`. The todo widget is hidden while the list has no tasks.
128
+
129
+ ## 0.1.0
130
+
131
+ ### Minor Changes
132
+
133
+ - [#7](https://github.com/oisin-ee/pi-prewalk/pull/7) [`f528eab`](https://github.com/oisin-ee/pi-prewalk/commit/f528eab26e4d2de300e1fdb9a3d5ec52e06ca9b6) Thanks [@momo-momokaya](https://github.com/apps/momo-momokaya)! - First release: the `todo` tool, the prewalk planner-to-executor handoff, and the kit that installs both.