Skip to content

refactor: re-implement sync command without plugin system#7

Merged
angeloashmore merged 2 commits intomainfrom
aa/new-sync
Mar 6, 2026
Merged

refactor: re-implement sync command without plugin system#7
angeloashmore merged 2 commits intomainfrom
aa/new-sync

Conversation

@angeloashmore
Copy link
Member

@angeloashmore angeloashmore commented Mar 5, 2026

Resolves:

Description

Remove the dependency on @prismicio/plugin-kit and the Slice Machine plugin system from the sync command. Instead, the CLI now handles all sync operations natively.

Framework adapters: New FrameworkAdapter abstraction with concrete implementations for Next.js, Nuxt, and SvelteKit. The implementations are based on the original Slice Machine adapters.

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

How to QA 1


Note

High Risk
Large refactor of the prismic sync flow plus changes to token validation in isAuthenticated(); mistakes could cause sync to write/delete the wrong local files or incorrectly treat users as logged out.

Overview
prismic sync is reimplemented to no longer rely on the Slice Machine plugin system. It now detects the project framework (Next.js/Nuxt/SvelteKit) via package.json and syncs slices/custom types by directly reading/writing local model files through a new FrameworkAdapter abstraction.

Adds concrete adapters for Next.js, Nuxt, and SvelteKit, including template generation for slice components and framework-specific scaffolding/config tweaks (e.g., Nuxt module registration, Next.js preview/simulator routes, SvelteKit preview routing and Vite allowlist).

Separately, updates auth verification to validate the stored prismic-auth token via the user-service profile endpoint (dropping refresh-token parsing), and introduces small supporting utilities (dedent, addDependencies, globbing/indent detection) with new dev dependencies.

Written by Cursor Bugbot for commit 3466e03. This will update automatically on new commits. 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.

angeloashmore and others added 2 commits March 4, 2026 18:08
Replace plugin-system-based sync with direct file operations via a new
Next.js-specific module. This removes the dependency on @prismicio/plugin-kit
and handles custom type/slice CRUD, component scaffolding, and library
index generation natively.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace Slice Machine plugin-based framework handling with direct
framework adapters. Each adapter manages slice component generation,
library index files, and framework-specific templates natively.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@angeloashmore angeloashmore marked this pull request as ready for review March 6, 2026 01:39
@angeloashmore angeloashmore merged commit 89da59b into main Mar 6, 2026
12 checks passed
@angeloashmore angeloashmore deleted the aa/new-sync branch March 6, 2026 01:39
@cursor cursor bot mentioned this pull request Mar 6, 2026
Copy link

@cursor cursor bot left a comment

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 and found 3 potential issues.

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

await rename(existingCustomTypeDirectory, newCustomTypeDirectory);
const { modelPath } = await this.#writeCustomTypeModel(model);
return { modelPath };
}
Copy link

Choose a reason for hiding this comment

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

renameCustomType renames directory to itself

Medium Severity

renameCustomType computes both existingCustomTypeDirectory and newCustomTypeDirectory by calling #getCustomTypeDirectory(model.id) with the same model.id, producing identical paths. The rename() call is a no-op. Compare with renameSlice, which correctly uses the existing on-disk directory vs a newly computed directory from model.name.

Additional Locations (1)

Fix in Cursor Fix in Web

}
const projectRoot = new URL("./", packageJsonPath);
return projectRoot;
}
Copy link

Choose a reason for hiding this comment

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

Entire nextjs.ts file is unused dead code

Medium Severity

src/lib/nextjs.ts is a 391-line file with exported functions (initProject, createSlice, readSlice, updateSlice, etc.) that duplicates the functionality already implemented in FrameworkAdapter and NextJsFramework. No file in the codebase imports from ./lib/nextjs. This appears to be a leftover from an earlier implementation approach that was superseded by the class-based framework-adapter.ts system.

Fix in Cursor Fix in Web

if (customTypesChanged) {
await syncCustomTypes(repo, framework);
lastRemoteCustomTypesHash = remoteCustomTypesHash;
}
Copy link

Choose a reason for hiding this comment

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

Watch loop double-fetches remote data on sync

Low Severity

In watchForChanges, each poll cycle fetches remote slices and custom types for hash comparison. When changes are detected, syncSlices and syncCustomTypes each fetch the same data again from the API, doubling API calls on every change detection cycle. The already-fetched data from the hash check could be passed through instead.

Fix in Cursor Fix in Web

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