Skip to content

feat: route sync, add, and detach by scope - #948

Merged
ctawiah merged 2 commits into
mainfrom
ctawiah/route-scopes-1e8a
Oct 26, 2026
Merged

ctawiah merged 2 commits into
mainfrom
ctawiah/route-scopes-1e8a

Conversation

@ctawiah

@ctawiah ctawiah commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Context

Since #939, the sync code has a scope: prompts, tools, skills, or all. Only the sync uses it, through SyncAction. So add and detach always work on variations, and every message talks about prompts. This PR routes sync, add, and detach by scope, so that the next PR only adds the commands.

What changes

  • Scope moves from SyncAction to Options, so that every action gets it. AddAction.Variations becomes Resources.
  • In a repository without sync files, sync all fails with Nothing to sync in this repository. To start, run ldcli sync prompts add, ldcli sync tools add, or ldcli sync skills add.
  • In such a repository, a sync of tools or of skills starts the add of that kind, as a sync of prompts does today.
  • Add and detach use the kind of the scope.
  • Without a terminal, the conflict error names --resolve only in the prompts scope, because only sync prompts has it.
  • An empty plan names the add of the scope, for example No tools are synced in this repository. To start, run ldcli sync tools add.
  • A prompts plan notes the tool and skill files that it leaves out:
Note: 1 standalone skill and 1 standalone tool are not in this plan. Run ldcli sync all to include them.
  • A sync of tools or skills does not write variations. So after it pushes a tool, a note names each local variation that uses the tool:
Note: Prompt production/support/default uses tool search. It repins on the next ldcli sync prompts or ldcli sync all.

Design notes

  • The standalone count reads only paths (ParseManagedPath), so an invalid standalone file never breaks sync prompts. Only a prompts plan counts. A tool or skill with a row in the plan, for example a row from the first PR of this stack, is not counted.
  • Tool and skill rows get an unexported usedBy, set in the same loop that sets SyncedElsewhere. The repin note is its only user. The other option, a second compile of the variations after the apply, reads the files twice.
  • applyConflictResolutions now copies the rows of the plan before it changes them, so the reviewed plan stays as it was.
  • This PR must ship in the same ldcli release as feat: apply tool and skill rows in a sync #941, with the previous PR and the next PR, which adds the commands.

Review focus

  • Does every message name a command that exists in its scope?
  • Is the standalone count right with a filter, and with a tool that has a row?

Verification

  • go test ./... and golangci-lint run (v2.9.0) pass.
  • New acceptance tests through Runner.Run:
    • a workspace with only one tool
    • the standalone count, with no read of the counted files
    • no count for a tool that has a row
    • a repository without sync files, in each scope
    • add and detach of tools
    • a shared tool conflict that a sync of that one tool resolves, after which the next sync of every kind only repins the variation
  • TestWritePlanReviewNamesTheAddOfAnEmptyScope checks the empty-plan message of each scope.

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. This PR: 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. refactor: share the selection of a new variation, and check any kind before an add #952: 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
Sync, add, and detach are driven by command scope (prompts, tools, skills, or all) via Options.Scope, replacing scope on SyncAction. AddAction now takes generic Resources instead of variation-only Variations, and add/detach/bootstrap use the scope’s resource kind for filters, selections, and validation.

Behavior and UX changes: sync all in an empty repo errors with a message pointing at ldcli sync prompts/tools/skills add; scoped tool/skill sync still auto-starts add like prompts today. Tools/skills scopes reject --config-key and variation-style positional args. Prompt-only plans note standalone tools/skills left out of the plan; after a tools/skills push, notes tell users which prompts need a follow-up repin. Empty-plan and non-interactive conflict messages are scope-specific (--resolve only mentioned for prompts).

Planning: Plans carry Scope and optional standalone counts (path-only, prompts scope); tool/skill rows track usedBy variations for repin notes. Filter.Validate rejects --config-key for non-variation kinds.

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

@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/prompt/action.go
@cursor
cursor Bot force-pushed the ctawiah/route-scopes-1e8a branch from 84d0406 to d41ab35 Compare October 23, 2026 14:27
@cursor
cursor Bot force-pushed the ctawiah/route-scopes-1e8a branch from d41ab35 to 31dcddf Compare October 23, 2026 14:40
@cursor
cursor Bot force-pushed the ctawiah/route-scopes-1e8a branch from 31dcddf to 000e9ee Compare October 23, 2026 14:44

@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/prompt/state.go
@cursor
cursor Bot force-pushed the ctawiah/route-scopes-1e8a branch from 000e9ee to 5b45276 Compare October 23, 2026 14:56
@cursor
cursor Bot force-pushed the ctawiah/route-scopes-1e8a branch from 5b45276 to 720df6f Compare October 23, 2026 17:07
@cursor
cursor Bot force-pushed the ctawiah/route-scopes-1e8a branch from 720df6f to 01513f2 Compare October 26, 2026 19:37

@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 01513f2. Configure here.

Comment thread internal/sync/prompt/action.go
@ctawiah
ctawiah force-pushed the ctawiah/route-scopes-1e8a branch 3 times, most recently from 743062e to 7614d8d Compare October 26, 2026 20:36
Base automatically changed from ctawiah/add-attachments-1e8a to main October 26, 2026 20:51
The scope moves from SyncAction to Options, so that every action has it.
A sync of prompts, tools, skills, or all kinds plans only its scope. An
add or a detach takes resources of the kind of the scope, and the add of
tools and skills uses the add from the bootstrap package.

A sync of every kind in a repository without sync files fails with a
message that names the three add commands. A sync of tools or skills
starts its add, as a sync of prompts does. An empty scope names its add
command.

A sync of prompts notes the tool and skill files that no variation uses,
because its plan leaves them out. The note counts paths and reads no
file. After a sync of tools or skills pushes a tool or skill, a note
names each local variation that repins on the next sync of prompts.

Without a terminal, an unresolved conflict outside the prompts scope
names only --conflict, because only sync prompts has --resolve.
@ctawiah
ctawiah force-pushed the ctawiah/route-scopes-1e8a branch from 7614d8d to 597ac2d Compare October 26, 2026 20:51
@ctawiah
ctawiah merged commit 3599292 into main Oct 26, 2026
10 checks passed
@ctawiah
ctawiah deleted the ctawiah/route-scopes-1e8a branch October 26, 2026 21:02
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