Clarify Zod requirement for tool args, document Zod vs TypeBox layers

OpenCode's registry calls z.object(def.args) on every plugin tool definition,
so Zod is mandatory for the tool schema — no JSON Schema escape hatch. TypeBox
is used for our own config validation where we control the schema. The two
serve different layers with different constraints. Updated both the overview
and ADR-001 with a clear table showing which library serves which concern.
This commit is contained in:
2026-04-29 07:36:23 +00:00
parent c241aaaf7a
commit 27e2763d02
2 changed files with 13 additions and 2 deletions

View File

@@ -27,7 +27,7 @@ This follows the pattern established by open-memory, which exposes 9 operations
- `op` field name is unambiguous in OpenCode's context
**Negative:**
- The `op` and `args` fields are not individually validated by the outer schema — validation happens inside the dispatch handler
- The `op` and `args` fields are not individually validated by the outer Zod schema — validation happens inside the dispatch handler
- Agent must call help to discover operations; the tool description can only hint
- Slightly more overhead per call (string dispatch vs direct function call)
@@ -36,6 +36,10 @@ This follows the pattern established by open-memory, which exposes 9 operations
- Validation errors are clear and include usage guidance
- The help operation provides complete reference with examples
## Zod Requirement
The tool args schema **must** use Zod because OpenCode's registry calls `z.object(def.args)` on every plugin tool definition. There is no JSON Schema alternative for tool definitions — this is the SDK's contract. TypeBox is used for internal config validation where we control the schema, but the tool definition boundary requires Zod. This is a small surface area (one schema for one tool) and doesn't extend beyond the `taskgraph` tool definition.
## Note on Schema Libraries
The tool's outer parameter schema uses **Zod** (from `@opencode-ai/plugin`'s `tool()` helper) because that's what OpenCode's plugin SDK provides for tool definitions. The plugin's internal config schema uses **TypeBox** (from `@alkdev/typebox`, already a dependency via `@alkdev/taskgraph`) for compile-time types and runtime `Value.Check()`. These are two different concerns: Zod for OpenCode's tool interface, TypeBox for our own config. No conflict — each is used where it's the native choice.