feat: add field management commands#76
Merged
angeloashmore merged 13 commits intomainfrom Mar 28, 2026
Merged
Conversation
93f91ff to
ade75cc
Compare
Adds CLI commands for managing fields on slices, page types, and custom types. Includes `field add`, `field list`, and `field remove` with target flags (`--slice`, `--page-type`, `--custom-type`) to specify where fields are managed. Also refactors `createCommand` to support declarative `required` validation on positionals and options, removing manual checks across all existing commands. Resolves #21 Resolves #22 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Moves `resolveModel` and `TARGET_OPTIONS` into `src/models.ts` so they can be reused outside the field command tree. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace --slice/--page-type/--custom-type flags with a single --to flag that accepts a relative path to the model directory. Inline upsert helpers into adapter methods, extract shared test builders, and add integration tests for field add/remove/list commands. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f86f5aa to
a889870
Compare
Add dedicated commands for each field type (color, date, embed, geopoint, integration, number, text, timestamp, uid) with type-specific flags and validation. Update the field-add router to dispatch to these subcommands and extend the models module with field type definitions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add dedicated `field add` subcommands for content-relationship, image, link-to-media, rich-text, select, and table fields with type-specific options and tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds `resolveFieldTarget` to resolve dot-separated field paths (e.g., `group.fieldName`) so fields can be added inside groups. Updates all field-add commands to use the new resolution and defers label derivation until after the field ID is resolved. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These commands read from a source rather than writing to a target, so `--from` better communicates intent. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Uses `resolveFieldTarget` to support dot notation (e.g. `my_group.subtitle`) for removing fields inside groups. Also fixes number parsing to use `Number()` instead of `Number.parseInt()` for decimal support. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…veModel` Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Matches the editor's behavior where omitting block types enables all of them. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| throw new CommandError(`--${optionName} must be a valid number, got "${value}"`); | ||
| } | ||
| return number; | ||
| } |
There was a problem hiding this comment.
parseNumber silently accepts empty strings and Infinity
Low Severity
parseNumber uses Number(value) followed by a Number.isNaN() check, but Number("") returns 0 (not NaN) and Number("Infinity") returns Infinity. This means --min "" is silently accepted as 0, and --min Infinity is accepted as Infinity, both bypassing the validation intended to reject non-numeric input.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Resolves: #21, #22
Description
Adds a
prismic fieldcommand group for managing fields on local slice, page type, and custom type models. This enables full content modeling from the CLI without needing to use the Prismic editor.Commands:
prismic field add <type> <id> --to <model>— Add a field to a model.prismic field list --from <model>— List all fields on a model.prismic field remove <id> --from <model>— Remove a field from a model.Supported field types for
field add:booleancolordateembedgeopointnumbertexttimestamprich-textselecttableimagelinklink-to-mediacontent-relationshipintegrationgroupuid(page types and custom types only)Each field type has its own subcommand with type-specific flags (e.g.
--default-value,--placeholder,--allow).The
--toflag accepts a relative path to amodel.json(slice) orindex.json(page/custom type). For slices,--variationselects the variation (defaults to"default"). For types,--tabselects the tab (defaults to"Main").Field IDs support dot-notation paths (e.g.
my_group.my_field) to target fields nested inside groups.Checklist
Preview
How to QA 1
Note
Medium Risk
Adds new CLI surface area that mutates local slice/custom type JSON models (including nested group targeting), so mistakes could overwrite models or generate incorrect types despite having good e2e coverage.
Overview
Introduces a new
prismic fieldcommand group withadd,list, andremovesubcommands to manage fields on local slice and custom type models, and wires it into the main CLI router.field addsupports multiple field-type subcommands (e.g. boolean, rich-text, link, uid, etc.), applies type-specific flags, prevents overwriting existing fields, and regenerates types after saving. Model targeting is centralized in newresolveModel/resolveFieldTargethelpers to support--to/--from, slice--variation, type--tab, and dot-notation for nested group fields; extensive new tests cover add/list/remove flows and error cases.Written by Cursor Bugbot for commit 44cc21e. This will update automatically on new commits. Configure here.
Footnotes
Please use these labels when submitting a review:
⚠️ #issue: Strongly suggest a change.
❓ #ask: Ask a question.
💡 #idea: Suggest an idea.
🎉 #nice: Share a compliment. ↩