fix: move zod to peerDependencies #278
Merged
Merged
Conversation
…tance ## High level changes - `packages/opencode-plugin/package.json`: Moved `zod` from `dependencies` to `peerDependencies` (version `>=4.1.8`), marked as non-optional - `pnpm-lock.yaml`: Updated to reflect the dependency change - `.vibe/development-plan-fix-opencode-plugin-parameter-descriptions.md`: Added EPCC plan documenting root cause analysis and fix strategy ## Motivation Parameter descriptions defined via `.describe()` on Zod schemas in our plugin tools were silently stripped from the JSON Schema sent to the LLM. This caused the AI to not understand parameter meanings — most critically, which workflow names are valid for `start_development`, leading to incorrect workflow selection. Root cause: our plugin loaded its own Zod 4.3.6 instance while OpenCode used Zod 4.1.8. In Zod v4, `.describe()` stores descriptions in a module-level `globalRegistry` singleton. Since two separate instances were loaded, the plugin registered descriptions in its own registry, but OpenCode's `z.toJSONSchema()` read from its own (empty) registry — resulting in all descriptions being absent. ## Details - `tsup.config.ts` already had `external: ['zod']`, meaning zod was architecturally intended to be provided by the host — but `package.json` still listed it as a `dependency`, causing pnpm to install a separate copy in the plugin's `node_modules` - Moving zod to `peerDependencies` ensures consumers (OpenCode) provide their own zod instance, so both sides share a single `globalRegistry` - All 5 tool handlers that use `.describe()` benefit: `start_development`, `proceed_to_phase`, `conduct_review`, `reset_development`, `setup_project_docs` - No source code changes required — the `.describe()` calls in tool handlers remain identical
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
so plugin shares OpenCode's zod instance
High level changes
packages/opencode-plugin/package.json: MovedzodfromdependenciestopeerDependencies(version>=4.1.8), marked as non-optionalpnpm-lock.yaml: Updated to reflect the dependency change.vibe/development-plan-fix-opencode-plugin-parameter-descriptions.md: Added EPCC plan documenting root cause analysis and fix strategyMotivation
Parameter descriptions defined via
.describe()on Zod schemas in our plugin tools were silently stripped from the JSON Schema sent to the LLM. This caused the AI to not understand parameter meanings — most critically, which workflow names are valid forstart_development, leading to incorrect workflow selection.Root cause: our plugin loaded its own Zod 4.3.6 instance while OpenCode used Zod 4.1.8. In Zod v4,
.describe()stores descriptions in a module-levelglobalRegistrysingleton. Since two separate instances were loaded, the plugin registered descriptions in its own registry, but OpenCode'sz.toJSONSchema()read from its own (empty) registry — resulting in all descriptions being absent.Details
tsup.config.tsalready hadexternal: ['zod'], meaning zod was architecturally intended to be provided by the host — butpackage.jsonstill listed it as adependency, causing pnpm to install a separate copy in the plugin'snode_modulespeerDependenciesensures consumers (OpenCode) provide their own zod instance, so both sides share a singleglobalRegistry.describe()benefit:start_development,proceed_to_phase,conduct_review,reset_development,setup_project_docs.describe()calls in tool handlers remain identical