@ian-pascoe/pi-todo 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ian-pascoe/pi-todo",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "description": "Minimal session-native Todo List for Pi agents.",
6
6
  "keywords": [
@@ -2,6 +2,7 @@
2
2
  name: pi-todo
3
3
  description: Diagnose Pi Todo when its tool, restored Todo List, model context, clear command, transcript rendering, or widget is missing or incorrect.
4
4
  license: MIT
5
+ disable-model-invocation: true
5
6
  ---
6
7
 
7
8
  # Pi Todo
@@ -13,8 +13,10 @@ import {
13
13
  type TodoStateSnapshot,
14
14
  type TodoStatus,
15
15
  type TodoTask,
16
+ TodoOperationError,
16
17
  type TodoToolDetails,
17
18
  } from "./todo-list.js";
19
+ import { TROUBLESHOOTING_HINT } from "./troubleshooting-skill.js";
18
20
 
19
21
  const TODO_STATE_ENTRY_TYPE = "pi-todo-state";
20
22
  const JOURNAL_FAULT = Symbol.for("@ian-pascoe/pi-todo/journal-fault");
@@ -161,7 +163,15 @@ export default function piTodoExtension(pi: ExtensionAPI): void {
161
163
  executionMode: "sequential",
162
164
  async execute(_toolCallId, params, signal, _onUpdate, context) {
163
165
  signal?.throwIfAborted();
164
- const result = runTodoAction(params, context);
166
+ let result: ReturnType<typeof runTodoAction>;
167
+ try {
168
+ result = runTodoAction(params, context);
169
+ } catch (cause) {
170
+ // Task-operation errors are model-fixable input errors; anything else is a journal failure.
171
+ if (cause instanceof TodoOperationError) throw cause;
172
+ const message = cause instanceof Error ? cause.message : String(cause);
173
+ throw new Error(`${message}\n\n${TROUBLESHOOTING_HINT}`, { cause });
174
+ }
165
175
  return {
166
176
  content: [{ type: "text", text: result.message }],
167
177
  details: result.details,
@@ -23,6 +23,13 @@ const ProjectionDetails = Type.Object(
23
23
  { additionalProperties: false },
24
24
  );
25
25
 
26
+ /** Context handlers never receive system messages, so anchors must skip Pi's system state. */
27
+ function conversationMessage(entry: SessionEntry): Message | undefined {
28
+ return buildSessionContext([entry], entry.id).messages.find(
29
+ (message) => message.role !== "system",
30
+ );
31
+ }
32
+
26
33
  /** Validates both the serialized shape and Todo List invariants at the journal boundary. */
27
34
  export function todoStateFromEntry(entry: SessionEntry): TodoStateSnapshot | undefined {
28
35
  if (
@@ -93,7 +100,7 @@ export function projectTodoContext(
93
100
  const checkpointIndex = branch.indexOf(checkpoint);
94
101
  if (start < 0 || start > checkpointIndex)
95
102
  throw new Error("Todo checkpoint cutoff is unavailable");
96
- anchor = buildSessionContext([checkpoint], checkpoint.id).messages[0];
103
+ anchor = conversationMessage(checkpoint);
97
104
  for (const entry of branch.slice(0, start).toReversed()) {
98
105
  const state = todoStateFromEntry(entry);
99
106
  if (!state) continue;
@@ -120,7 +127,7 @@ export function projectTodoContext(
120
127
  previousContent = content;
121
128
  continue;
122
129
  }
123
- const message = buildSessionContext([entry], entry.id).messages[0];
130
+ const message = conversationMessage(entry);
124
131
  if (!message) continue;
125
132
  if (message.role === "assistant") {
126
133
  if (outstanding.size > 0 && pending.length > 0)
@@ -0,0 +1,9 @@
1
+ import { fileURLToPath } from "node:url";
2
+
3
+ /** Absolute path of this package's user-invoked troubleshooting Skill. */
4
+ export const TROUBLESHOOTING_SKILL_PATH = fileURLToPath(
5
+ new URL("../skills/pi-todo/SKILL.md", import.meta.url),
6
+ );
7
+
8
+ /** Model-facing pointer appended to failures this package's Skill diagnoses. */
9
+ export const TROUBLESHOOTING_HINT = `For diagnosis, read the pi-todo troubleshooting Skill at ${TROUBLESHOOTING_SKILL_PATH}.`;