@pi-archimedes/todo 2.13.0 → 2.14.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-archimedes/todo",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/archimedes-codes/pi-archimedes.git"
@@ -19,16 +19,14 @@
19
19
  "./prepare-args": "./src/prepare-args.ts"
20
20
  },
21
21
  "dependencies": {
22
- "@pi-archimedes/core": "2.13.0"
22
+ "@pi-archimedes/core": "2.14.0"
23
23
  },
24
24
  "peerDependencies": {
25
- "@earendil-works/pi-ai": ">=0.99.0",
26
25
  "@earendil-works/pi-coding-agent": ">=0.99.0",
27
26
  "@earendil-works/pi-tui": ">=0.99.0",
28
27
  "typebox": ">=1.1.0"
29
28
  },
30
29
  "devDependencies": {
31
- "@earendil-works/pi-ai": "1.4.0",
32
30
  "@earendil-works/pi-coding-agent": "1.4.0",
33
31
  "@earendil-works/pi-tui": "1.4.0",
34
32
  "typebox": "^1.1.38",
package/src/tool.test.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { describe, it, expect } from "vitest";
2
+ import { Value } from "typebox/value";
2
3
  import type { AgentToolResult, Theme } from "@earendil-works/pi-coding-agent";
3
4
  import { createManageTodoListTool } from "./tool.js";
5
+ import type { ManageTodoListInput } from "./tool.js";
6
+ import { ManageTodoListParams } from "./tool.js";
4
7
  import { TodoStateManager } from "./state-manager.js";
5
8
  import type { TodoDetails } from "./types.js";
6
9
 
@@ -112,6 +115,27 @@ describe("tool schema", () => {
112
115
  });
113
116
  });
114
117
 
118
+ // Parity guards for the schema's enum plumbing. `StringEnum` used to come from
119
+ // pi-ai; it now lives in tool.ts, built on Type.Unsafe. Two ways that move can
120
+ // go silently wrong, so both are pinned here: the emitted JSON Schema can stop
121
+ // rejecting out-of-vocabulary values (caught below by Value.Check), and the
122
+ // derived TypeScript type can widen from a narrow union to `string` — invisible
123
+ // to every runtime assertion, so it is caught at compile time.
124
+ describe("schema enum guards", () => {
125
+ it("rejects out-of-vocabulary operation values at runtime", () => {
126
+ expect(Value.Check(ManageTodoListParams, { operation: "nope" })).toBe(false);
127
+ expect(Value.Check(ManageTodoListParams, { operation: "read" })).toBe(true);
128
+ });
129
+
130
+ it("keeps operation a narrow union at the type level", () => {
131
+ const good: ManageTodoListInput = { operation: "read" };
132
+ // @ts-expect-error "nope" is not a member of the operation union
133
+ const bad: ManageTodoListInput = { operation: "nope" };
134
+ void good;
135
+ void bad;
136
+ });
137
+ });
138
+
115
139
  describe("renderResult — successful results unchanged", () => {
116
140
  it("renders the completed counter from details.todos", () => {
117
141
  const result = {
package/src/tool.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Static, StringEnum, Type } from "@earendil-works/pi-ai";
1
+ import { Type, type Static } from "typebox";
2
2
  import type { AgentToolResult, EventBus, ExtensionContext, Theme, ToolRenderResultOptions } from "@earendil-works/pi-coding-agent";
3
3
  import { Text } from "@earendil-works/pi-tui";
4
4
  import { Events, emitOn } from "@pi-archimedes/core/events";
@@ -8,6 +8,24 @@ import type { TodoStateManager } from "./state-manager.js";
8
8
  import { STATUS_ICONS } from "./types.js";
9
9
  import type { TodoDetails, TodoItem, TodoStatus } from "./types.js";
10
10
 
11
+ /**
12
+ * pi-ai shipped this helper; typebox has no equivalent, and pi 1.5.0 dropped
13
+ * pi-ai's typebox re-exports, so the suite no longer takes schema symbols from
14
+ * the host. Emits the identical JSON Schema: { type: "string", enum: [...] }.
15
+ * pi-ai's version also accepted a `default`; no caller here does, so it is not
16
+ * carried.
17
+ */
18
+ function StringEnum<T extends readonly string[]>(
19
+ values: readonly [...T],
20
+ options?: { description?: string },
21
+ ) {
22
+ return Type.Unsafe<T[number]>({
23
+ type: "string",
24
+ enum: [...values],
25
+ ...(options?.description ? { description: options.description } : {}),
26
+ });
27
+ }
28
+
11
29
  const TodoItemSchema = Type.Object({
12
30
  content: Type.String({
13
31
  description: "Short imperative label for the task (3-10 words). Displayed in UI. Example: \"Fix the auth middleware\".",