Skip to content

feat: add prismic slice upgrade-legacy - #388

Merged
lihbr merged 17 commits into
mainfrom
claude/focused-pascal-2fffvf
Oct 1, 2026
Merged

lihbr merged 17 commits into
mainfrom
claude/focused-pascal-2fffvf

Conversation

@angeloashmore

@angeloashmore angeloashmore commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Resolves: DT-3535

Description

Before this PR, only Slice Machine's /labs upgrader could upgrade legacy slices, the slices that the Legacy Builder defines inside a type.

After this PR, prismic slice upgrade-legacy upgrades one legacy slice at a time and says how its content changes. status, init, and the commands from #390 point at it. Content in Prismic does not change: the Content API returns upgraded slices through legacyPaths.

People and AI agents both run this command. When the right choice is unclear, the command lists the options and leaves the choice to the project's owner:

Slice "hero" already exists. How do you want to upgrade legacy slice "hero" of "landing_page"? This changes how editors pick slices, so the project's owner should choose:
  Add it to slice "hero" as a new variation: prismic slice upgrade-legacy hero --from landing_page --to hero
  Upgrade it to a separate slice: prismic slice upgrade-legacy hero --from landing_page --to <new-slice-id>

prismic init turning on the Type Builder is in #389.

Checklist

  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

How to QA 1

In a project with legacy slices, run npx prismic slice list --legacy, then npx prismic slice upgrade-legacy <id> --from <type>. The evals "upgrades a legacy slice" and "asks before combining legacy slices" cover the agent flow.

🤖 Generated with Claude Code

https://claude.ai/code/session_01H4jg7fmGVLhLJjo27eC7Mj


Note

Medium Risk
Changes custom type and slice models and editor-facing slice zones; mistakes in merge/variation or legacyPaths could mis-map live content until components are updated and pushed.

Overview
Adds prismic slice upgrade-legacy so legacy slices embedded in custom types can be converted to SharedSlice models locally, with legacyPaths wired for content compatibility after prismic push.

The command supports --from, optional --slice-zone, --to, and --variation (new slice, merge into an existing variation, or add as a variation). When a target slice already exists, it fails with guided options instead of picking a modeling choice. getLegacySlices now carries the slice zone for updating zone choices in place.

init, status, slice list, type view, and getSlice messaging now point at upgrade instead of “cannot edit legacy slices.” Agent evals cover single-type upgrades and asking before combining duplicate legacy IDs across types.

Coverage includes unit/integration tests and an isolated-repo push test.

Reviewed by Cursor Bugbot for commit c47782a. Bugbot is set up for automated code reviews on this repo. Configure here.

Footnotes

  1. Please use these labels when submitting a review:
    ❓ #ask: Ask a question.
    💡 #idea: Suggest an idea.
    ⚠️ #issue: Strongly suggest a change.
    🎉 #nice: Share a compliment. ↩

Legacy Builder repositories have legacy slices inside slice zones. The
CLI and the Type Builder cannot edit them. This command converts them
to shared slices, the same way as the Slice Machine upgrader.

- Without arguments, it lists legacy slices and a command for each.
- With an ID, it creates a shared slice, adds a variation with --to,
  or merges into an identical variation.
- It writes `legacyPaths`, so Prismic serves old content as the new
  shared slice.
- It tells the developer how the content shape changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4jg7fmGVLhLJjo27eC7Mj
`prismic init` stopped with an error when a repository used the Legacy
Builder, and only support could fix it. It now turns on the Type
Builder with the new wroom endpoint and saves the detected framework.
Only an administrator can do this.

After the models sync, init tells the developer how many legacy slices
need conversion with `prismic slice migrate`.

The endpoint is POST /app/settings/enableTypeBuilder in wroom. Deploy
it before this change is released.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4jg7fmGVLhLJjo27eC7Mj
- Remove the --id option. --to covers slices with the same ID.
- Compare fields with isDeepStrictEqual.
- Print one line for the content change and one for the next step.
- Remove the temporary state in init.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4jg7fmGVLhLJjo27eC7Mj
Call PATCH /repository/type-builder in obelix instead of a new wroom
endpoint. Also call it when the saved framework is not the project's
framework, because the editor shows code snippets for that framework.
If only the framework is wrong and the user is not an administrator,
init shows a warning and continues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4jg7fmGVLhLJjo27eC7Mj
Replaces `slice migrate` with `slice upgrade-legacy <id> --from <type>`.
The slice zone defaults to "body", invalid legacy IDs are converted, and
`--to` targets a new or existing slice. When the target slice already
exists, the error lists the options so agents ask the user.

`slice list`, `type view`, `status`, and `init` now point at legacy
slices, and editing commands explain how to upgrade one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4jg7fmGVLhLJjo27eC7Mj
@angeloashmore angeloashmore changed the title feat: migrate Legacy Builder repositories to the Type Builder feat: upgrade Legacy Builder repositories to the Type Builder Oct 1, 2026
claude added 2 commits October 1, 2026 00:35
Throws a `CommandError` for legacy slices instead of a new error class.
`getLegacySlices` returns the slice zone, so the upgrade edits it
directly. Tests share one legacy type fixture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4jg7fmGVLhLJjo27eC7Mj
@angeloashmore angeloashmore changed the title feat: upgrade Legacy Builder repositories to the Type Builder feat: add prismic slice upgrade-legacy Oct 1, 2026
claude added 3 commits October 1, 2026 00:43
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4jg7fmGVLhLJjo27eC7Mj
`slice list` marks legacy slices with * and shows the type that defines
them. `slice list --legacy` lists only legacy slices. `type view` lists
the slices in each slice zone and marks legacy ones. Commands that edit
a slice now say when the slice is a legacy slice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4jg7fmGVLhLJjo27eC7Mj
@angeloashmore
angeloashmore changed the base branch from main to claude/focused-pascal-2fffvf-legacy October 1, 2026 00:48
@angeloashmore
angeloashmore marked this pull request as ready for review October 1, 2026 01:02

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0a828f6. Configure here.

Comment thread src/commands/slice-upgrade-legacy.ts
When the target slice ID was the key of a different legacy slice in the
same slice zone, the upgrade removed that legacy slice from the zone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4jg7fmGVLhLJjo27eC7Mj
Base automatically changed from claude/focused-pascal-2fffvf-legacy to main October 1, 2026 01:59
claude added 2 commits October 1, 2026 01:59
…-2fffvf

# Conflicts:
#	src/adapters/index.ts
#	src/commands/slice-list.ts
#	src/commands/type-view.ts
#	src/lib/prismic/models.ts
#	test/slice-list.test.ts
#	test/slice-view.test.ts
The help text and the "slice already exists" error no longer tell the
reader to ask the user. They say that combining slices is a choice for
the project's owner, which keeps agents from deciding on their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4jg7fmGVLhLJjo27eC7Mj
@lihbr
lihbr merged commit c74832a into main Oct 1, 2026
16 checks passed
@lihbr
lihbr deleted the claude/focused-pascal-2fffvf branch October 1, 2026 02:12
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.

3 participants