Skip to content

refactor: share the selection of a new variation, and check any kind before an add - #952

Open
ctawiah wants to merge 1 commit into
ctawiah/create-attachment-flags-1e8afrom
ctawiah/share-variation-selection-1e8a
Open

ctawiah wants to merge 1 commit into
ctawiah/create-attachment-flags-1e8afrom
ctawiah/share-variation-selection-1e8a

Conversation

@ctawiah

@ctawiah ctawiah commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Context

sync prompts link creates a variation whose prompt is in an external file. It asks for the project, the config, and the model config, or reads them from flags. The next PRs let sync prompts add create a variation from flags, with the same questions and lookups. This PR moves that shared code into the create package, and prepares two checks that the create needs. Behavior does not change. The variation create is in three PRs to keep each one small.

What changes

  • create.SelectConfig, create.SelectModelConfig, and create.FindModelConfig replace the same code in link. link calls them, and keeps its key, name, and content form.
  • create.Catalog replaces link.Catalog.
  • bootstrap.CheckNotSynced also checks a variation for a local file and a sync.lock row, and names sync prompts in its errors:
variation demo/support/default is already synced. Edit .launchdarkly/demo/configs/support/default.prompt.md and run ldcli sync prompts.
variation demo/support/default has a sync.lock entry but no local file. Run ldcli sync prompts to restore it.
  • local.ResourcePath and Store.ResourceExists replace the tool and skill versions, and work for every kind.
  • bootstrap.SyncCommand names the sync of a kind, and AddCommand uses it.
  • A config read keeps the keys of its archived variations in Config.ArchivedVariationKeys. Variations still leaves them out, and the plan still treats them as absent.

Design notes

  • The key, name, and content form stays in link, because its defaults come from the linked file. The key comes from the file name, and the content question shows only when the file has no prompt. add asks for the key and the name with the forms that the tool and skill create already use.
  • link_test.go does not change. The new create/prompt_test.go tests the moved functions directly.
  • ArchivedVariationKeys has no caller in this PR. The next PR uses it to refuse a new variation whose key an archived variation holds, because LaunchDarkly returns 409 for that key.

Review focus

  • Does link work exactly as before, in a terminal and with flags?

Verification

  • go test ./... and golangci-lint run (v2.9.0) pass. link_test.go passes without edits.
  • New tests: FindModelConfig, the missing-project error of SelectConfig, the archived keys of a config, and the variation checks of CheckNotSynced.
  • I built ldcli and ran link with flags against a stand-in for the LaunchDarkly API. The output is the same as before this PR. The flag-only script of the sync commands also gives the same output.
  • I also ran link in a terminal. The config question, the model config question, and the key and name form work as before.

Related changes

This stack builds on #937 to #941, which are merged.

  1. fix: exclude expanded tools from prompt diffs #957: Exclude expanded tools from prompt diffs (ctawiah/fix-prompt-tool-diff-5b1c)
  2. fix: plan a tool or skill row when a variation newly references it #945: Plan a tool or skill row when a variation newly references it (ctawiah/plan-referenced-attachments-1e8a)
  3. feat: keep unused tools and skills, and detach any resource kind #946: Keep unused tools and skills, and detach any resource kind (ctawiah/keep-unused-attachments-1e8a)
  4. feat: add tools and skills from LaunchDarkly #947: Add tools and skills from LaunchDarkly (ctawiah/add-attachments-1e8a)
  5. feat: route sync, add, and detach by scope #948: Route sync, add, and detach by scope (ctawiah/route-scopes-1e8a)
  6. feat: add the sync all, sync tools, and sync skills commands #949: Add the sync all, sync tools, and sync skills commands (ctawiah/scope-commands-1e8a)
  7. feat: create a tool or a skill from the content of an add #950: Create a tool or a skill from the content of an add (ctawiah/create-attachments-1e8a)
  8. feat: add the create flags of sync tools add and sync skills add #951: Add the create flags of sync tools add and sync skills add (ctawiah/create-attachment-flags-1e8a)
  9. This PR: share the selection of a new variation, and check any kind before an add (ctawiah/share-variation-selection-1e8a)
  10. feat: create a prompt variation from the content of an add #953: Create a prompt variation from the content of an add (ctawiah/create-variations-1e8a)
  11. feat: add the create flags of sync prompts add #954: Add the create flags of sync prompts add (ctawiah/create-variation-flags-1e8a)

Note

Overview
Refactors sync so new variation flows (project/config/model selection) live in internal/sync/create, and sync prompts link delegates to SelectConfig, SelectModelConfig, and FindModelConfig instead of duplicating that logic. Intended behavior for link is unchanged; link-specific key/name/content prompts stay in link.

Bootstrap / local prep for sync prompts add: CheckNotSynced now applies to variations as well as tools/skills (local file or sync.lock), with errors pointing at ldcli sync prompts. SyncCommand centralizes the per-kind sync CLI name; AddCommand uses it. ResourcePath / ResourceExists replace attachment-only helpers and cover all resource kinds.

Catalog API: When unmarshaling a config, archived variations are still omitted from Variations, but their keys are stored on ArchivedVariationKeys (for a follow-up PR to block reusing archived keys).

Reviewed by Cursor Bugbot for commit 1b2ca0b. Bugbot is set up for automated code reviews on this repo. Configure here.

@ctawiah
ctawiah added this pull request to stack #955 October 22, 2026 22:19
@cursor
cursor Bot force-pushed the ctawiah/share-variation-selection-1e8a branch from 1bcb5f2 to 3dc9217 Compare October 23, 2026 00:13
@ctawiah
ctawiah removed this pull request from stack #955 October 23, 2026 00:15
@ctawiah
ctawiah added this pull request to stack #960 October 23, 2026 00:16
@ctawiah
ctawiah marked this pull request as ready for review October 23, 2026 14:11
@ctawiah
ctawiah requested a review from a team as a code owner October 23, 2026 14:11
@ctawiah
ctawiah requested review from ld-ahartmann and nkester-ld and removed request for a team October 23, 2026 14:11
@cursor
cursor Bot force-pushed the ctawiah/share-variation-selection-1e8a branch from 3dc9217 to 65d8cc9 Compare October 23, 2026 14:27
@cursor
cursor Bot force-pushed the ctawiah/share-variation-selection-1e8a branch 2 times, most recently from f37b1a8 to b166011 Compare October 23, 2026 14:44
@cursor
cursor Bot force-pushed the ctawiah/share-variation-selection-1e8a branch from b166011 to 5fa87f9 Compare October 23, 2026 14:56
@cursor
cursor Bot force-pushed the ctawiah/share-variation-selection-1e8a branch from 5fa87f9 to 0f34218 Compare October 23, 2026 17:07
@cursor
cursor Bot force-pushed the ctawiah/share-variation-selection-1e8a branch from 0f34218 to 3ca293a Compare October 23, 2026 21:17
@cursor
cursor Bot force-pushed the ctawiah/share-variation-selection-1e8a branch from 3ca293a to 1b2ca0b Compare October 23, 2026 21:26
…before an add

The config and model config questions of link, and its model config
lookup, move into the create package as SelectConfig, SelectModelConfig,
and FindModelConfig. link calls them, and keeps the key, name, and
content form, because the defaults of that form come from the linked
file. The behavior of link does not change.

CheckNotSynced now also checks a variation for a local file and a
sync.lock entry, and names sync prompts in its errors. ResourcePath and
ResourceExists replace the tool and skill versions. A config read keeps
the keys of its archived variations, so that a create can refuse one.

The next change uses these to create a variation from the flags of
sync prompts add.
@cursor
cursor Bot force-pushed the ctawiah/share-variation-selection-1e8a branch from 1b2ca0b to ce81c0b Compare October 23, 2026 21:39
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