Skip to content

feat(sync): add scriptable prompt commands - #854

Merged
ctawiah merged 4 commits into
mainfrom
ctawiah/sync-scriptable-commands
Oct 8, 2026
Merged

ctawiah merged 4 commits into
mainfrom
ctawiah/sync-scriptable-commands

Conversation

@ctawiah

@ctawiah ctawiah commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Context

Prompt sync currently exposes several different workflows through flags on one command. That works interactively, but it makes automation difficult because an agent must combine flags whose relationships are not obvious and can still encounter an unexpected prompt.

This layer gives each workflow a focused subcommand and a complete non-interactive path. Interactive selection remains available when identifiers are omitted, while scripts and agents can provide stable resource keys and explicit conflict policies.

What changes

  • Replaces the prompt action flags with watch, add, attach, detach, and link subcommands.
  • Uses project-key/config-key/variation-key selectors consistently in arguments, flags, help, and validation errors.
  • Adds explicit non-interactive inputs for attachment targets, linked variations, model config keys, names, and prompt content.
  • Adds --no-input to fail instead of opening an interactive selector or confirmation.
  • Adds --conflict for a default conflict policy and repeatable --resolve flags for variation-specific choices.
  • Keeps backend search for projects, configs, tools, and skills when users choose resources interactively.
  • Supports outputFormat through variation create, update, pull, fingerprint, and clear operations.
  • Preserves specific LaunchDarkly API errors while adding the project and resource context needed to correct them.
  • Includes command examples in help output for both interactive and non-interactive workflows.
  • Rejects unsafe selectors and blank link metadata before making API or filesystem changes.
  • Loads explicitly selected projects when detaching so manifest-only resources can still be removed safely.
  • Stops watch mode with an error when an explicit conflict policy chooses abort.

The old --add, --attach-tool, --attach-skill, --detach, --link, and --watch action flags are removed. Their workflows now use subcommands.

Command examples

Add one existing LaunchDarkly variation to the workspace:

ldcli sync prompt add production/support/default --no-input

Attach a tool or skill to a variation that is already synced:

ldcli sync prompt attach tool web-search \
  --to production/support/default \
  --yes --no-input

ldcli sync prompt attach skill summarize \
  --to production/support/default \
  --yes --no-input

Link a Markdown file as a new variation:

ldcli sync prompt link prompts/support.md \
  --format plain-markdown \
  --to production/support/support-agent \
  --model-config-key claude \
  --yes --no-input

Apply a default conflict policy or override one variation:

ldcli sync prompt --yes --no-input --conflict=local

ldcli sync prompt --yes --no-input \
  --conflict=abort \
  --resolve=production/support/default=launchdarkly

Stop syncing a variation or watch for local changes:

ldcli sync prompt detach production/support/default --no-input
ldcli sync prompt watch --yes --no-input

Running add, attach tool, attach skill, or detach without identifiers keeps the interactive selection flow.

Review focus

  • Are the subcommands and selector shapes easy to discover and understand?
  • Can every interactive workflow be completed deterministically with arguments and flags?
  • Does --no-input prevent every unexpected prompt?
  • Do default and per-variation conflict policies behave correctly for shared tools and skills?
  • Do explicit add, detach, attach, and link operations preserve the existing sync and manifest behavior?
  • Does outputFormat converge when it is added, changed, pulled, or removed?
  • Are API failures specific enough to identify the project and resource without hiding the server error?

Verification

  • go test -p 1 ./cmd/sync ./internal/sync/...
  • go test -p 1 ./...
  • go vet ./internal/sync/... ./cmd/sync
  • git diff --check

Related changes

Review the stack in this order:

  1. Confirm destructive watch actions
  2. Guarantee prompt fingerprint convergence
  3. Add searchable attachment API foundations
  4. Reconcile variation attachments
  5. Attach tools and skills to variations
  6. Render attachment-aware review output
  7. Safely clean unreferenced attachments
  8. Persist sync manifests in LaunchDarkly
  9. Scriptable prompt sync commands

Made with Cursor

@ctawiah
ctawiah added this pull request to stack #844 October 7, 2026 18:54
@ctawiah
ctawiah marked this pull request as ready for review October 7, 2026 19:03
@ctawiah
ctawiah requested a review from a team as a code owner October 7, 2026 19:03

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

Stale Bugbot comment from a previous run.

Comment thread internal/sync/detach/detach.go

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

similarly looks good to me but got some agent guidance - do with it what you will:

'Explicit detach succeeds when nothing is synced. Run returns nil on an empty resource list before validateSelections, so detach production/support/default --no-input against an empty workspace is a successful no-op. The same selector fails once any other variation exists.

Validate explicit selectors first and return variation … is not synced.'

Base automatically changed from ctawiah/sync-remote-manifests to main October 8, 2026 01:00
@ctawiah
ctawiah force-pushed the ctawiah/sync-scriptable-commands branch from 6d098de to 719799f Compare October 8, 2026 01:05
Put each shared rule in the domain package once. The rules are key
validation, variation validation, lookup keys, attachment loading,
version pins, and attachment comparison. A compiled local variation now
holds a typed Variation instead of a JSON payload.

Split the api, local, and prompt packages into files by concern. The api
client uses one read helper and one write helper. The local package owns
the directory layout in one file, and its writes share one staging path.
The prompt package has one file for each step of a sync.

Fix the manifest store. If a patch failed without a response but
LaunchDarkly applied it, Update returned an empty manifest for the
project.

Add a golden test that pins the fingerprints that remote manifests store.
An explicit detach selector skipped validation when no resource was
synced. The command then reported success and did nothing. Detach now
checks each named selector first, so a selector that is not synced always
fails. The empty-workspace message stays for the interactive flow.

@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 default effort and found 1 potential issue.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit 8479c70. Configure here.

Comment thread internal/sync/api/attachment.go
The refactor sent each search result through the strict decoder, which
requires a positive version. One result without a version then failed the
whole page, and interactive attach could not list tools or skills.

Search results now use a decoder that does not check the identity. A tool
result still gets the strict check when the client reads the tool again
for its latest version.
@ctawiah
ctawiah merged commit 771608c into main Oct 8, 2026
9 checks passed
@ctawiah
ctawiah deleted the ctawiah/sync-scriptable-commands branch October 8, 2026 03:46
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