You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: record exhaustive registry bridge research in development plan
Documents all 13 investigated approaches to obtaining host's globalRegistry,
Zod v4 internals (how descriptions are stored/read), and why the dynamic import
approach was chosen as the production-viable solution.
Copy file name to clipboardExpand all lines: .vibe/development-plan-fix-opencode-plugin-parameter-descriptions.md
+85Lines changed: 85 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,6 +83,91 @@ The `tool.definition` hook bridges registries:
83
83
-`toJSONSchema({ metadata: pluginRegistry })`: works but can't change OC's hardcoded call
84
84
- Dynamic import approach: cleanest workable solution for production
85
85
86
+
### All Investigated Approaches to Get Host's globalRegistry
87
+
88
+
The core challenge: from within the plugin, we needed a reference to OpenCode's `globalRegistry` object (a `$ZodRegistry` instance). All approaches tried:
89
+
90
+
**1. Static import of `'zod'` (plugin's own copy)**
91
+
-`import { globalRegistry } from 'zod'` → resolves to plugin's zod 4.3.6 registry (wrong)
92
+
- Even after moving to peerDep, monorepo still has plugin/node_modules/zod@4.3.6 (pulled by another workspace pkg)
93
+
94
+
**2. Dynamic import of `'zod'` (production-only fix)**
95
+
-`await import('zod')` from plugin code → also resolves to plugin's local zod in dev/monorepo
96
+
- In **production** (no local node_modules/zod), this correctly resolves to host's zod ✅
97
+
- Chosen approach — acceptable since dev uses known setup
98
+
99
+
**3. `_zod.bag` property on schema**
100
+
- Hypothesis: descriptions stored in `_zod.bag` (a per-instance metadata bag)
101
+
- Result: `_zod.bag` is always `{}` for described schemas — NOT used for descriptions
-`$ZodRegistry.get()` inherits from parent: `{ ...parentMeta, ...schemaOwnMeta }`
106
+
- Result: `toJSONSchema` treats `_zod.parent` as a `$ref` clone relationship, outputs only `{ description }` with NO type info — field type entirely lost ❌
0 commit comments