Repository navigation
Conversation
47edc51 to
fec03fd
Compare
fec03fd to
36e896d
Compare
…the command line sync prompts and watch take --project, --config-key, and --key, and plan only the variations that they name. The checks run before any LaunchDarkly request, and a project that the filter leaves out is not read. add and detach take the same flags instead of asking. attach and link take --project. Sync flags no longer take values from LD_* environment variables or the ldcli configuration file. Global flags such as --access-token keep that behavior.
36e896d to
3881023
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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 3881023. Configure here.
|
|
||
| // Read both sides again, so that no action uses state from before the review. | ||
| current, err := workspace.loadState(client) | ||
| current, err := workspace.loadState(client, options.syncAction().Filter) |
There was a problem hiding this comment.
Filter treats other projects as dropped
High Severity
A filtered sync plans only matching variations, but cleanupOrphanedAttachments and RemoveUnusedAttachments still look at every compiled file and ignore sync.lock. Missing files in another project—still tracked, and normally restored—look unused, so --yes can delete that project's tool and skill files and drop their lock rows.
Triggered by learned rule: Orphaned attachments: keep without --yes; recheck before delete
Reviewed by Cursor Bugbot for commit 3881023. Configure here.


Context
ldcli sync promptskeeps local prompt files in step with the variations of LaunchDarkly AI Configs. Its commands have two problems:project-key/config-key/variation-keyselectors. The project, AI Config, and variation questions have no flag, so a script cannot skip them.LD_<FLAG>environment variable or the ldcli configuration file. For example,LD_CONFLICT=bogus ldcli sync prompts --dry-runfails withinvalid conflict resolution "bogus". New flags read these sources too. ThenLD_YES, orLD_PROJECT, whichldcli config --set projectwrites, can change what a repository sync plans or applies.What changes
--project,--config-key, and--key.--keyis repeatable.sync promptsandwatch, the flags limit the plan. Local files andsync.lockrows outside the filter drop out before any read from LaunchDarkly.sync.lockstores the state that a working copy last agreed on with LaunchDarkly.addanddetach, the flags answer the questions. Without a terminal, the error names the missing flags, for example--config-key and --key are required with --no-input.attachandlink, only--projectexists. It skips the project question, and it fails if it disagrees with--to.--resolve, and--tostill work. Selectors together with target flags fail.--config-keywith no synced variations gets its own error..launchdarkly/directory,sync prompts --project demostarts the first-run add in that project.link, a 404 from the first read in the project becomesproject "demo" was not found in LaunchDarkly, or the access token cannot read it.The help examples now use the flags:
A key that is not synced fails before any request:
Design notes
validators.Validate()copies environment and configuration values into every flag and marks the flag as set.validatedArgsnow records which sync flags the command line set before that call. After the call, it resets every other sync flag to its default.BaselineStore.Loadreads the remote manifest only for the projects that the caller passes. Before, it read every project insync.lock, and a failed read there made a filtered sync fail. The remote manifest is a shared copy of the sync state in LaunchDarkly, one for each project.Savesends only the entries that changed, so sync never writes a project thatLoaddid not read.SyncAction,AddAction, andDetachAction.AttachActionandLinkActioncarry only a project key, so the sync afterattachorlinkstays a full sync.--keyhelp onaddanddetachreadsRepeat for more variations, becauseRepeat to add more variationsdid not fitdetach.Review focus
validatedArgscover every sync flag and leave every global flag alone?--projectonattachandlinkdoes not limit the sync that runs after them?Verification
go test ./...golangci-lint run(v2.9.0)TestValidatedArgsKeepsSyncFlagsFromTheCommandLineOnlyfails without the reset invalidatedArgs.TestPromptIgnoresSyncFlagsFromTheEnvironmentsetsLD_YES,LD_CONFLICT,LD_PROJECT,LD_KEY, andLD_NO_INPUT, and none of them has an effect.TestPromptReadsTheAccessTokenFromTheEnvironmentshows thatLD_ACCESS_TOKENstill works.TestPromptFilterSyncsOnlyTheNamedVariationsends no request for another project and keeps itssync.lockrow.TestPromptTargetFlagErrorsComeBeforeAnyRequestmakes sure that each targeting error sends no request.ldcliand ran it against a local stand-in for the LaunchDarkly API. The runs covered the filters, the errors,addanddetachwith each combination of flags, the--tomismatch, andLD_*variables. The request log showed no request for an error case or for a project outside the filter.Related changes
--diffflagNote
Overview
Adds
--project,--config-key, and repeatable--keytoldcli sync promptsso scripts can scope work and skip interactive project/config/variation prompts. On sync and watch, those flags narrow the plan (and API reads) to matching resources;sync.lockrows for other projects stay untouched becauseBaselineStore.Loadnow fetches remote manifests only for the projects in scope.addanddetachaccept the same flags as alternatives to positionalproject/config/variationselectors (not both).attach/linkadd--projectonly (must match--to). Validation errors for unknown or unsynced targets fail before any LaunchDarkly request.Sync-specific flags (
--yes,--conflict,--key, etc.) are CLI-only:validatedArgsresets values thatvalidators.Validate()pulled fromLD_*or config, while global flags like--access-tokenstill use env/config.Reviewed by Cursor Bugbot for commit 3881023. Bugbot is set up for automated code reviews on this repo. Configure here.