upgradeProject() embedded helper + --json upgrade output - #34
Merged
Conversation
…json
Goal 3 of the upgrade-safety brief: give host applications an in-memory
orchestration API and serializable output so they can build PR-creation
flows without Packkit touching the repo.
- upgradeProject({ definition, currentFiles, currentPackageJson?, policy? })
recreates the project with the current Packkit version (validating the
definition and preserving extension add/replace semantics), diffs it
against the repo, and returns { generatedProject, plan, patch, diagnostics,
metadata } — entirely in memory. No filesystem, git, network, or command
execution. The host decides whether to write, commit, or open a PR.
- summarizeUpgrade(plan) → { safeChanges, reviewChanges, conflicts }, shared
by the metadata and the JSON output. (conflicts is 0 until baseline lands.)
- `packkit upgrade --json` emits a versioned, machine-readable plan and
nothing else — no human log lines mixed in. schemaVersion: 1, from/to
versions, summary, classified files, packageJson delta, diagnostics.
- Both surface an UPGRADE_BASELINE_UNAVAILABLE warning so a consumer never
assumes a differing value is safe without baseline metadata.
108 tests pass (upgradeProject in-memory/empty-patch/requires-currentFiles,
summarizeUpgrade counts); --json verified as pure JSON via the real CLI.
No core change, so the web bundle is untouched.
Next: baseline metadata (three-way diff), partial-upgrade provenance, and
service deployment contracts.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Goal 3 of the upgrade-safety brief: an in-memory orchestration API and serializable output, so a host application can build a PR-creation flow without Packkit ever touching the repository.
upgradeProject()Recreates the project with the current Packkit version (validating the definition and preserving extension
add/replacesemantics), diffs it againstcurrentFiles, and returns{ generatedProject, plan, patch, diagnostics, metadata }. No filesystem, git, network, or command execution — the host decides whether to write the patch, commit, or open a PR.metadata:fromPackkitVersion,toPackkitVersion,baselineAvailable,hasConflicts,hasSafeChanges.--jsonpackkit upgrade --jsonemits a versioned, machine-readable plan and nothing else — verified pure JSON (first byte{, no human log lines):{ "schemaVersion": 1, "fromPackkitVersion": "3.0.0", "toPackkitVersion": "3.2.0", "baselineAvailable": false, "summary": { "safeChanges": 1, "reviewChanges": 1, "conflicts": 0 }, "files": [ { "path": ".editorconfig", "status": "new-generated-file", "safeToApply": true } ], "packageJson": { … }, "diagnostics": [ { "code": "UPGRADE_BASELINE_UNAVAILABLE", … } ] }summarizeUpgrade(plan)is shared by the metadata and JSON. Both surfaceUPGRADE_BASELINE_UNAVAILABLEso a consumer never assumes a differing value is safe without baseline metadata.108 tests pass. No core change → web bundle untouched.
Next: baseline metadata (three-way diff), partial-upgrade provenance, service deployment contracts.
🤖 Generated with Claude Code