Skip to content

feat: add prismic gen slice-index and regenerate index files on slice updates - #258

Open
angeloashmore wants to merge 5 commits into
mainfrom
aa/gen-index
Open

feat: add prismic gen slice-index and regenerate index files on slice updates#258
angeloashmore wants to merge 5 commits into
mainfrom
aa/gen-index

Conversation

@angeloashmore

@angeloashmore angeloashmore commented Aug 14, 2026

Copy link
Copy Markdown
Member

Resolves:

Description

The CLI regenerated slice index files only when a slice was created or deleted. A slice update did not regenerate them. For example, a renamed slice kept its old component name in the index file.

This PR makes updateSlice regenerate the index file of the changed library. Now every slice change (create, update, delete) regenerates the index file.

This PR also adds a new command: prismic gen slice-index. The command regenerates the slice index file of each slice library. Use it to repair a stale or hand-edited index file without a model change. For example, it converts index files that Slice Machine generated to the CLI format.

Checklist

  • A comprehensive Linear ticket, providing sufficient context and details to facilitate the review of the PR, is linked to the PR.
  • 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

$ npx prismic@pr-258 gen slice-index
Generated the slice index file.

A project with more than one slice library prints the count:

$ npx prismic@pr-258 gen slice-index
Generated 7 slice index files.

How to QA 1

This PR is published to npm as prismic@pr-258. You can run it in a project with npx, with no installation.

  1. In a project with a slice, run npx prismic@pr-258 slice edit <id> --name <NewName>. Make sure that the index file shows the new component name.
  2. Edit or delete a slice index file by hand. Run npx prismic@pr-258 gen slice-index. Make sure that the CLI regenerates the file.

🤖 Generated with Claude Code

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.

angeloashmore and others added 2 commits August 14, 2026 01:28
The adapter regenerated the index file only on slice create and
delete. A renamed slice kept its old component name in the index
file. Now updateSlice regenerates the index file, the same as
createSlice and deleteSlice.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The command regenerates the slice index file of each slice library.
Use it to repair stale or hand-edited index files without a model
change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@angeloashmore angeloashmore changed the title feat: add prismic gen index and regenerate index files on slice updates feat: add prismic gen slice-index and regenerate index files on slice updates Aug 14, 2026
angeloashmore and others added 3 commits August 14, 2026 01:53
The eval gives an agent a slice index file that does not contain the
project's slice. The agent must run `prismic gen slice-index` to
regenerate the file.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The default test slice ID contains a dash. A dash makes an invalid
key in the generated components map. Some agents saw the invalid ID
as part of the fault and recreated the slice with a new ID. Now the
fixture uses a snake_case ID, so the stale index is the only fault.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The eval used a snake_case slice ID to work around unquoted keys in
the generated index file. PR #259 quotes IDs that are not valid
identifiers, so the standard test slice works. Run the eval only
after this branch includes that fix.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@angeloashmore
angeloashmore marked this pull request as ready for review August 14, 2026 02:25
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.

2 participants