Skip to content

upgradeProject() embedded helper + --json upgrade output - #34

Merged
DanMat merged 1 commit into
mainfrom
feat/upgrade-embedded-orchestration
Aug 1, 2026
Merged

upgradeProject() embedded helper + --json upgrade output#34
DanMat merged 1 commit into
mainfrom
feat/upgrade-embedded-orchestration

Conversation

@DanMat

@DanMat DanMat commented Aug 1, 2026

Copy link
Copy Markdown
Owner

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()

import { upgradeProject } from 'create-packkit/embedded';

const result = upgradeProject({ definition, currentFiles, currentPackageJson, policy });
if (result.metadata.hasConflicts) { /* present for review / open a PR */ }

Recreates the project with the current Packkit version (validating the definition and preserving extension add/replace semantics), diffs it against currentFiles, 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.

--json

packkit upgrade --json emits 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 surface UPGRADE_BASELINE_UNAVAILABLE so 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

…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>
@DanMat
DanMat merged commit 9f5ccde into main Aug 1, 2026
5 checks passed
@DanMat
DanMat deleted the feat/upgrade-embedded-orchestration branch August 1, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant