fix(plugin): preserve cross-zod tool arg metadata#2372
Open
code-yeongyu wants to merge 1 commit intodevfrom
Open
fix(plugin): preserve cross-zod tool arg metadata#2372code-yeongyu wants to merge 1 commit intodevfrom
code-yeongyu wants to merge 1 commit intodevfrom
Conversation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <[email protected]>
There was a problem hiding this comment.
1 issue found across 3 files
Confidence score: 4/5
- This PR is likely safe to merge, with a small but real risk coming from a medium-severity, high-confidence test fragility in
src/plugin/normalize-tool-arg-schemas.test.ts. - Hardcoding
node_modulesin the test can fail in hoisted or nonstandard package layouts, which may cause avoidable CI/test regressions even if runtime behavior is unchanged. - Pay close attention to
src/plugin/normalize-tool-arg-schemas.test.ts- replace hardcodednode_modulesresolution with dynamiczodpackage path discovery to keep tests environment-agnostic.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/plugin/normalize-tool-arg-schemas.test.ts">
<violation number="1" location="src/plugin/normalize-tool-arg-schemas.test.ts:24">
P2: Do not hardcode `node_modules` paths, as dependency hoisting can cause this directory to not exist. Resolve the `zod` package location dynamically instead.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| async function loadSeparateHostZodModule(): Promise<typeof import("zod")> { | ||
| const pluginPackageDirectory = dirname(Bun.resolveSync("@opencode-ai/plugin/package.json", import.meta.dir)) | ||
| const sourceZodDirectory = join(pluginPackageDirectory, "node_modules", "zod") |
There was a problem hiding this comment.
P2: Do not hardcode node_modules paths, as dependency hoisting can cause this directory to not exist. Resolve the zod package location dynamically instead.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/plugin/normalize-tool-arg-schemas.test.ts, line 24:
<comment>Do not hardcode `node_modules` paths, as dependency hoisting can cause this directory to not exist. Resolve the `zod` package location dynamically instead.</comment>
<file context>
@@ -0,0 +1,97 @@
+
+async function loadSeparateHostZodModule(): Promise<typeof import("zod")> {
+ const pluginPackageDirectory = dirname(Bun.resolveSync("@opencode-ai/plugin/package.json", import.meta.dir))
+ const sourceZodDirectory = join(pluginPackageDirectory, "node_modules", "zod")
+ const tempDirectory = mkdtempSync(join(tmpdir(), "omo-host-zod-"))
+ const copiedZodDirectory = join(tempDirectory, "zod")
</file context>
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.
Summary
Verification
bun testbun test src/plugin/normalize-tool-arg-schemas.test.tsbun run typecheckbun run buildSummary by cubic
Preserves tool arg descriptions and metadata across different Zod instances by normalizing schemas during tool registration. Fixes metadata loss reported in issue 2314.
Written for commit d84c28d. Summary will update on new commits.