@ian-pascoe/pi-todo 0.1.2 → 0.1.3

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.3",
4
4
  "private": false,
5
5
  "description": "Minimal session-native Todo List for Pi agents.",
6
6
  "keywords": [
@@ -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)