Files
skillshare/internal/plugin/targets.go
Willie 4556438575 fix(plugin): let OMP and Pi plugin updates through without uninstalling (#833) (#837)
* fix(plugin): let OMP and Pi plugin updates through without uninstalling (#833)

Every OMP update was blocked, because OMP's native upgrade replaces cache
folders that projects outside its inventory may still use. The only way to
move an OMP binding to a new commit was to uninstall first. An update now
runs the same pair a source change already uses: the scoped removal
adapter (cache kept), then an install under a fresh marketplace and cache
identity. A refresh always takes a new identity, because OMP installs from
the catalog it cached when the marketplace was added, and that catalog
still names the old version. If the removal cannot be verified, the
update is blocked; update --all still skips it with the reason.

Pi was blocked whenever the catalog plugin name differed from its
package.json name. That happens after an upstream npm rename, for example
when npm refused the original name. Pi installs by path, and Skillshare
keys the binding by the catalog name, so the npm name never reaches
either, and the check only stopped working installs.

Updating one package across several Agents stopped every Agent as soon as
one was blocked. Each failing Agent is now reported with its reason while
the others update, and the command exits non-zero. A single --target, or
a package with no other Agent to update, stays blocked as before, so a
dry-run still fails when nothing would update.

* fix(plugin): let one update --all refresh several OMP packages

Every OMP removal proves itself against a fingerprint of the whole native
registry and lock. In a single update --all plan, the first package's
removal and reinstall rewrite those shared files. The second package's
removal therefore saw "OMP native files changed", so only one OMP
package could update per run. The same applied to a sync that replaced
the sources of several OMP packages.

A removal now also fingerprints only its own installation: its registry
entry, its lock entry, its package manifest and its runtime link. After
an earlier change in the same apply has written to that OMP target, the
removal re-reads the files and runs every ownership check again. It goes
ahead only if that own fingerprint still matches the preview. A change
outside Skillshare to the package's own entries still blocks it. Without
an earlier write in the apply, the full-file check is unchanged.

The fake OMP in the tests now merges installs into the registry and lock
and lists them in a stable order, as the real one keeps other plugins.
2026-11-10 21:46:42 +08:00

36 lines
2.5 KiB
Go

package plugin
// TargetDefinition is the shared capability contract for CLI, TUI and dashboard.
// An empty operation list means discovery-only, not an installed/usable target.
type TargetDefinition struct {
Target string `json:"target"`
Label string `json:"label"`
Project bool `json:"project"`
Operations []string `json:"operations"`
Reason string `json:"reason,omitempty"`
// ReasonKey names Reason for the dashboard to translate; Reason is the fallback.
ReasonKey string `json:"reasonKey,omitempty"`
// Npm marks a target that installs npm: packages (see pi_npm.go).
Npm bool `json:"npm,omitempty"`
}
func TargetDefinitions() []TargetDefinition {
all := []string{"add", "import", "sync", "check", "update", "remove", "enable", "disable"}
definitions := []TargetDefinition{
{Target: "claude", Label: "Claude Code", Project: true, Operations: all},
{Target: "codex", Label: "Codex", Operations: all},
{Target: "cursor", Label: "Cursor", Operations: []string{"add", "sync", "check", "update", "remove", "enable", "disable"}},
{Target: "antigravity", Label: "Antigravity Desktop", Project: true, Operations: []string{"add", "sync", "check", "update", "remove", "enable", "disable"}},
{Target: "pi", Label: "Pi", Project: true, Operations: all},
{Target: "opencode", Label: "OpenCode", Project: true, Operations: all},
{Target: "omp", Label: "Oh My Pi", Project: true, Operations: []string{"add", "import", "sync", "check", "update", "remove", "enable", "disable"}, Reason: "Reviewed marketplace installs, updates and scoped removals are supported. Updates reinstall into a fresh cache; removal retains shared cache and settings, and OMP's native upgrade never runs because it can damage other projects.", ReasonKey: "plugins.reason.omp"},
{Target: "antigravity-cli", Label: "Antigravity CLI", Operations: all},
{Target: "copilot", Label: "GitHub Copilot CLI", Operations: all},
{Target: "grok", Label: "Grok Build", Operations: []string{"import", "sync", "check", "remove", "enable", "disable"}, Reason: "Install or update in Grok to complete native trust, then import.", ReasonKey: "plugins.reason.grok"},
{Target: "kimi", Label: "Kimi Code", Operations: []string{}, Reason: automationProblem("kimi"), ReasonKey: "plugins.problem.kimi"},
{Target: "hermes", Label: "Hermes", Operations: []string{}, Reason: automationProblem("hermes"), ReasonKey: "plugins.problem.hermes"},
{Target: "devin", Label: "Devin", Operations: []string{}, Reason: automationProblem("devin"), ReasonKey: "plugins.problem.devin"},
}
return definitions
}