Skip to content

feat: add push, pull, and fetch commands#164

Merged
angeloashmore merged 13 commits intomainfrom
aa/push-pull-fetch
Apr 30, 2026
Merged

feat: add push, pull, and fetch commands#164
angeloashmore merged 13 commits intomainfrom
aa/push-pull-fetch

Conversation

@angeloashmore
Copy link
Copy Markdown
Member

@angeloashmore angeloashmore commented Apr 30, 2026

Resolves:

Description

Adds three new commands for a local-first modeling workflow:

  • prismic push — push local types and slices to the remote.
  • prismic pull — pull remote types and slices to local files.
  • prismic fetch — refresh the local snapshot of the remote (no file writes).

A snapshot of the remote is persisted under the user's config dir so push and pull can detect drift and require --force for destructive changes.

sync is simplified to only support --watch for compatibility. In a future PR, sync will be deprecated and/or removed. The Type Builder instructions and docs will be updated for push/pull before that change.

Pairs with #163 (modeling commands operate on local files only). Either can land first.

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


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Note

Medium Risk
Adds new commands that can create/update/delete local or remote models and introduces snapshot-based drift detection; incorrect diffing or snapshot handling could lead to unintended overwrites or deletions despite --force safeguards.

Overview
Introduces a local-first modeling workflow with three new CLI commands: prismic pull (remote → local), prismic push (local → remote), and prismic fetch (refresh remote snapshot only), all using a persisted snapshot to detect drift and require --force before overwriting changes.

Moves one-time sync logic out of the adapter by deleting Adapter.syncModels/syncSlices/syncCustomTypes, adds a shared diffArrays helper for insert/update/delete planning, and updates init to perform an initial pull + type generation and then write the snapshot. sync is simplified to watch-only polling that applies remote diffs to local files, writes snapshots on change, and has adjusted error handling/limits.

Adds snapshot persistence under the user config directory keyed by project+repo, exports CONFIG_DIR for reuse, wires new commands into the CLI router, and expands E2E tests to cover fetch/pull/push behavior and drift/--force safeguards.

Reviewed by Cursor Bugbot for commit 369a68e. 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.

angeloashmore and others added 7 commits April 30, 2026 00:18
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Splits the previous sync command into two commands: pull (mirror remote
to local) and fetch (refresh snapshot only). Push now auto-establishes a
snapshot on first run and uses snapshot-based drift detection in both
directions, removing the destructive-change confirmation in favor of
clearer per-direction guidance.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Restores src/commands/sync.ts, test/sync.test.ts, and src/lib/segment.ts
to their state on main. Re-registers sync in src/index.ts. Brings the
writeLocalCustomType test helper from the modeling refactor branch since
push/pull/fetch tests need it.
Previously, when no snapshot existed, pull treated remote as the
baseline, which flagged drift in either direction. This incorrectly
refused pulls when remote had new changes that the user was trying
to fetch. Now, without a snapshot, only flag drift if local has
changes not present on remote.

Also extract drift comparisons into named variables in push for
readability.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment out push, pull, and fetch from the command router to keep
them unlisted while preserving the implementations. Init points back
to sync until the new workflow is surfaced.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread src/commands/pull.ts Outdated
angeloashmore and others added 2 commits April 30, 2026 01:06
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread src/index.ts
Comment thread src/commands/push.ts Outdated
angeloashmore and others added 2 commits April 30, 2026 01:38
Remove the syncModels/syncSlices/syncCustomTypes adapter methods now that
pull handles one-time syncing. The sync command is watch-only (requires
--watch) and inlines the loop logic; init inlines the same merge logic.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@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.

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 0265df2. Configure here.

Comment thread src/commands/push.ts Outdated
Comment thread src/commands/sync.ts
Comment thread src/commands/init.ts
angeloashmore and others added 2 commits April 30, 2026 02:11
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@angeloashmore angeloashmore merged commit ef09ffa into main Apr 30, 2026
13 checks passed
@angeloashmore angeloashmore deleted the aa/push-pull-fetch branch April 30, 2026 02:47
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