Repository navigation
fix(generate): a generated client carries its library's version, not 0.0.1 - #1164
Merged
Merged
Conversation
…0.0.1 `codefly generate client` wrote package.json and pyproject.toml once, from a scaffold that says 0.0.1, and never touched them again. The library's own version (library.codefly.yaml: the producer's declared version for one contract, the existing one for an aggregate) never reached them, so the document store's client library said 0.1.14 while its TypeScript package said 0.0.1 and was published as that. Every generation now sets the package manifest's version to the library's. package.json's top-level "version" member is found by walking the document's tokens and only its value is replaced; pyproject.toml's project version line likewise. Hand-edits stay byte-for-byte. A library with no version is refused by name. Go's version is its tag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves pkg/generators/client.go against #1169's staged generation: the version stamp runs after each staged language is applied, and a library with no version is refused before anything is staged, so the library is untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 26, 2026
Merged
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.
What was wrong
codefly generate clientwritestypescript/package.jsonandpython/pyproject.tomlfrom a scaffold that says0.0.1, once (writeFileIfMissing), and never updates the version again. The library's own version, the valuelibrary.codefly.yamlrecords, never reached them. Live example: obin-ai/module-document-storeclients/library.codefly.yamlsaysversion: 0.1.14(producercodefly/documents@0.1.14), whileclients/typescript/package.jsonsays"version": "0.0.1", which is what gets published.Fix
libraryVersion(output, entries)is the one source of the library's version. It is the logicwriteLibraryManifestalready had: for a single contract, the producer's declared version (the composed module package's, or the local service's); for an aggregate, the existing top-level version. It is computed once per run and used for the manifest and for every language.stampPackageVersionruns after each language generates:package.json's top-level"version"member is found by walking the JSON tokens, and only its value bytes are replaced. Formatting, key order and hand-edits stay byte-for-byte; a nested"version"key is never touched.pyproject.toml'sversion = "…"project line, in place, the same wayensurePythonDependenciesalready edits that file.No new input or flag: the version is what the module already declares (Codefly generates every value).
Tests
pkg/generators/client_version_test.go(ungated):package.jsonwith a nested"version"keeps every other bytepyproject.tomlwith a hand-added section keeps itlibraryVersionreturns the producer's versioncmd/generate/client_test.goTestGenerateClientPreservesHandEditedFiles(gated,CODEFLY_GENERATE_QUALIFY=1): after a regenerate,package.json's version equalslibrary.codefly.yaml's and is not0.0.1. Ran locally: PASS. With the stamp call removed it FAILS:package.json version = 0.0.1, library.codefly.yaml version = "0.0.0".Classification
Fix, at the place that writes the package manifests. Reused: the library-version rule
writeLibraryManifestalready applied, and the in-place edit pattern ofensurePythonDependencies. Not done: the local-service fallback0.0.1inresolveLocalSource(a service that declares no version) is unchanged.Not verified: the rest of the gated
cmd/generatequalify suite; CI does not run gated tests.🤖 Generated with Claude Code