@xynogen/pix-todo 0.1.12 → 0.1.13

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": "@xynogen/pix-todo",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Pi tool — durable execution checklist (todo)",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/todo.test.ts CHANGED
@@ -26,6 +26,7 @@ function makeHost(
26
26
  data?: unknown;
27
27
  }> = [],
28
28
  ) {
29
+ let capturedParameters: unknown;
29
30
  let capturedExecute:
30
31
  | ((
31
32
  id: string,
@@ -50,9 +51,11 @@ function makeHost(
50
51
  const pi = {
51
52
  registerTool(def: {
52
53
  name: string;
54
+ parameters: unknown;
53
55
  execute: typeof capturedExecute;
54
56
  renderResult?: typeof capturedRender;
55
57
  }) {
58
+ capturedParameters = def.parameters;
56
59
  capturedExecute = def.execute;
57
60
  if (def.renderResult) capturedRender = def.renderResult;
58
61
  },
@@ -82,6 +85,10 @@ function makeHost(
82
85
  return {
83
86
  pi,
84
87
  sessionManager,
88
+ get parameters() {
89
+ if (!capturedParameters) throw new Error("parameters not captured");
90
+ return capturedParameters;
91
+ },
85
92
  get execute() {
86
93
  if (!capturedExecute) throw new Error("execute not captured");
87
94
  return capturedExecute;
@@ -119,6 +126,30 @@ function text(result: { content: Array<{ type: string; text: string }> }) {
119
126
  return result.content.map((c) => c.text).join("\n");
120
127
  }
121
128
 
129
+ // ─── Tool schema ────────────────────────────────────────────────────────────
130
+
131
+ test("todo exposes action and status as guided string enums", () => {
132
+ const host = makeHost();
133
+ registerTodo(host.pi);
134
+ const schema = host.parameters as {
135
+ properties: {
136
+ action: { type?: string; enum?: string[]; description?: string };
137
+ status: { type?: string; enum?: string[]; description?: string };
138
+ };
139
+ };
140
+ const action = schema.properties.action;
141
+ const status = schema.properties.status;
142
+
143
+ expect(action.type).toBe("string");
144
+ expect(action.enum).toEqual(["list", "set", "add", "update", "clear"]);
145
+ expect(action.description).toContain('"list" shows items');
146
+ expect(action.description).toContain('"update" changes one item by id');
147
+ expect(status?.type).toBe("string");
148
+ expect(status?.enum).toEqual(["pending", "in_progress", "done", "blocked"]);
149
+ expect(status?.description).toContain('"pending" = not started');
150
+ expect(status?.description).toContain('"blocked" = cannot proceed');
151
+ });
152
+
122
153
  // ─── parseItems (via set/add) ───────────────────────────────────────────────
123
154
 
124
155
  describe("todo actions", () => {
package/src/todo.ts CHANGED
@@ -178,16 +178,11 @@ export default function registerTodo(pi: ExtensionAPI): void {
178
178
  "Call `todo(action:'list')` to recover your place after long runs or context compaction.",
179
179
  ],
180
180
  parameters: Type.Object({
181
- action: Type.Union(
182
- [
183
- Type.Literal("list"),
184
- Type.Literal("set"),
185
- Type.Literal("add"),
186
- Type.Literal("update"),
187
- Type.Literal("clear"),
188
- ],
189
- { description: "Operation to perform" },
190
- ),
181
+ action: Type.Enum(["list", "set", "add", "update", "clear"] as const, {
182
+ type: "string",
183
+ description:
184
+ 'Required operation: "list" shows items; "set" replaces all from items; "add" appends items; "update" changes one item by id; "clear" removes all.',
185
+ }),
191
186
  items: Type.Optional(
192
187
  Type.String({
193
188
  description: "For set/add: newline-separated or numbered list of todo texts.",
@@ -195,15 +190,11 @@ export default function registerTodo(pi: ExtensionAPI): void {
195
190
  ),
196
191
  id: Type.Optional(Type.Number({ description: "For update: target todo id." })),
197
192
  status: Type.Optional(
198
- Type.Union(
199
- [
200
- Type.Literal("pending"),
201
- Type.Literal("in_progress"),
202
- Type.Literal("done"),
203
- Type.Literal("blocked"),
204
- ],
205
- { description: "For update: new status." },
206
- ),
193
+ Type.Enum(["pending", "in_progress", "done", "blocked"] as const, {
194
+ type: "string",
195
+ description:
196
+ 'For update: "pending" = not started; "in_progress" = active; "done" = finished; "blocked" = cannot proceed.',
197
+ }),
207
198
  ),
208
199
  text: Type.Optional(
209
200
  Type.String({