refactor(scripts/typegen): use guts/zod serializer via local package#38
Merged
Conversation
Delete the hand-rolled zod.go serializer and use zod.AsSchemas from github.com/coder/guts/zod (PR coder/guts#85) instead. The mutation rewrites the guts AST to Zod v4 schema nodes, then SerializeInOrder emits only the wanted types in dependency order. guts v1.7.0 -> v1.7.1-0.20260529230818-2f30faf483eb (feat/zod-mutation)
202f650 to
ab86eb6
Compare
3e060b9 to
859c17f
Compare
…ckage Move the Zod AST serializer from the deleted zod.go into a self-contained typegen/zod package, sourced from coder/guts#85 (feat/zod-mutation). The package provides AsSchemas (AST mutation) and SortByDependencies (topological ordering), replacing both the old string-builder serializer and the local topoSort. main.go keeps resolveTransitive and collectRefs for filtering to the wanted type subset. guts v1.7.0 -> v1.7.1 (walk changes from coder/guts#86).
859c17f to
f187acc
Compare
johnstcn
approved these changes
Jun 4, 2026
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.
Extract the Zod v4 AST serializer from coder/guts#85 into a self-contained
scripts/typegen/zod/package. This replaces the hand-rolledzod.gostring builder with the upstreamAsSchemasmutation andSortByDependenciestopological sort.The serializer is vendored locally because only the walk changes (guts#86/v1.7.1) have merged; the
zodpackage itself hasn't landed yet. Once it does, the local copy can be replaced with a direct import.Changes:
scripts/typegen/zod/zod.go: Vendored from gutsfeat/zod-mutationbranch. ProvidesAsSchemas(AST mutation) andSortByDependencies(Kahn's topo-sort).scripts/typegen/main.go: Replaced manual serialization loop and localtopoSortwithzod.AsSchemas+zod.SortByDependenciesviaSerializeInOrder. KeptresolveTransitive/collectRefsfor filtering to the wanted type subset.scripts/typegen/zod.go: Deleted (261 lines).v1.7.0->v1.7.1.