feat(cc): switch action JSON Schema from anyOf to oneOf#94
Open
mvanhorn wants to merge 1 commit intoanipotts:mainfrom
Open
feat(cc): switch action JSON Schema from anyOf to oneOf#94mvanhorn wants to merge 1 commit intoanipotts:mainfrom
mvanhorn wants to merge 1 commit intoanipotts:mainfrom
Conversation
Resolves anipotts#82. `zodToJsonSchema(...)` with `target: "jsonSchema7"` emits an `anyOf` for the discriminated union, but the file's own comment + tool surface language already describe the schema as a `oneOf`. Discriminated unions SHOULD use `oneOf` per JSON Schema 2020-12 + OpenAPI, and some MCP clients treat `anyOf` permissively (multi-branch match) whereas `oneOf` is exclusive. Post-process the generator output to rename `anyOf` -> `oneOf`. This keeps every other byte of the schema stable (changing the target to `openApi3` would also alter nullable handling, refs, etc., breaking the byte-stability invariant). Tests in `action.test.ts` updated accordingly.
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.
Resolves #82.
zodToJsonSchema(...)withtarget: "jsonSchema7"emits ananyOffor the discriminated union, but the file's own comment + tool-surface language already describe the schema as aoneOf. The issue notes:oneOfoneOf+discriminatoranyOfpermissively whereasoneOfis exclusiveApproach
Post-process the generator output to rename
anyOf->oneOfrather than switching the generator target toopenApi3. The post-process keeps every other byte stable, which preserves the existing byte-stability invariant that theACTION_JSON_SCHEMAis cached at module load and reused across sessions for prompt-cache hits. Switching the target would also alter nullable handling and ref behavior.Changes
plugins/cc/lib/action.ts: extractanyOffrom the generator output and re-emit asoneOfvia a single object spread.plugins/cc/tests/action.test.ts: update assertions to referenceoneOf(the byte-stability test continues to compareJSON.stringify(ACTION_JSON_SCHEMA)across re-imports).bun test tests/action.test.tspasses (19/19).Acceptance
tools/listinputSchema usesoneOf(notanyOf)