mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
* Add --all flag to plugin update and enable agy Add -a/--all to skillshare plugin update so users can update all tracked plugins in a single command without tying slow target CLI runs to skillshare update --all or sync --all. - Reject --all outside plugin update or when combined with a plugin name or --source-ref - Share source repository discoveries and discovery errors across the Preview and Apply lifecycle via Service.WithDiscoveryCache so multi- plugin marketplaces are cloned at most once per command - Isolate source, manifest, and target failures per binding when --all is active so healthy plugins update while partial failures exit non-zero and leave failed bindings unchanged in config.yaml - Skip unfiltered OMP bindings during --all updates so sibling targets on the same package still update without failing the batch - Enable plugin update for antigravity-cli while skipping disabled plugins when agy extensions list reports an entry as disabled Closes #653 * Add plugin update --all to docs and completions Advertise -a/--all for skillshare plugin across all five shell completion scripts and document the bulk update workflow and antigravity-cli update support in the user and built-in skill docs. - Add --all and -a to plugin completions in bash, zsh, fish, PowerShell, and Nushell with TestPluginCompletionsIncludeAllFlag - Document update [NAME | --all], -a/--all, and antigravity-cli source updates in website/docs/reference/commands/plugin.md (and its zh-Hans, zh-Hant, ja, and ko translations), sharing-plugins.md, and quick-reference.md - Document plugin update --all and antigravity-cli enablement checks in skills/skillshare/references/plugins.md * Require known enabled state for native updates Require a matching EnabledKnown && Enabled inventory entry before updating copilot or antigravity-cli bindings, and align the localized plugin workflow pages with the English docs. - Skip copilot and antigravity-cli updates in Service.Preview and refuse reinstallation in applyNativeTarget when the binding is absent from native inventory or not known to be enabled - Cover absent native inventory in TestAntigravityCLIUpdateRespectsEnablement - Synchronize plugin update [name | --all] and Antigravity CLI update guidance across the ja, ko, zh-Hans, and zh-Hant copies of quick-reference.md and sharing-plugins.md
170 lines
5.5 KiB
Go
170 lines
5.5 KiB
Go
package plugin
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// These clients do not yet expose a verified non-interactive lifecycle contract.
|
|
// Discovery still reports their native manifests without promising installation.
|
|
func automationProblem(target string) string {
|
|
switch target {
|
|
case "kimi":
|
|
return "Kimi plugin discovery only: install with /plugins in Kimi; a non-interactive lifecycle adapter is not yet verified."
|
|
case "hermes":
|
|
return "Hermes plugin discovery only: native profile inventory and capability-consent handling are not yet verified. Use hermes plugins."
|
|
case "devin":
|
|
return "Devin plugin discovery only: local inventory, trust, and personal-cloud removal are not yet verified for automation. Use devin plugins."
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func commandTarget(target string) bool {
|
|
return target == "copilot" || target == "antigravity-cli" || target == "grok"
|
|
}
|
|
|
|
func (s *Service) commandHost(ctx context.Context, target string) Host {
|
|
h := Host{Target: target, Status: HostReady, Installed: []Installed{}, NoteKey: "plugins.note.native", Note: "Plugin registrations only; resource loading and native trust are verified in the Agent."}
|
|
if s.ProjectRoot != "" {
|
|
h.block("plugins.error.globalScopeOnly", "This plugin adapter supports global scope only; project operations never fall back to global.")
|
|
return h
|
|
}
|
|
version, err := s.run(ctx, target, "--version")
|
|
h.Version = strings.TrimSpace(string(version))
|
|
if err != nil {
|
|
h.fail(err)
|
|
return h
|
|
}
|
|
{
|
|
agent := s.agentOf(target)
|
|
args := []string{"plugin", "list", "--json"}
|
|
var data []byte
|
|
data, err = s.run(ctx, target, args...)
|
|
if err == nil {
|
|
h.Installed, err = parseCommandInventory(agent, data)
|
|
h.Fingerprint = hash(data)
|
|
}
|
|
}
|
|
if err != nil {
|
|
h.fail(err)
|
|
}
|
|
return h
|
|
}
|
|
|
|
func parseCommandInventory(target string, data []byte) ([]Installed, error) {
|
|
if target == "antigravity-cli" {
|
|
trimmed := strings.TrimSpace(string(data))
|
|
if trimmed == "" || trimmed == "[]" || trimmed == "No imported plugins." || trimmed == "No plugins installed." {
|
|
return []Installed{}, nil
|
|
}
|
|
var envelope struct {
|
|
Imports json.RawMessage `json:"imports"`
|
|
}
|
|
if err := json.Unmarshal(data, &envelope); err == nil && envelope.Imports != nil {
|
|
data = envelope.Imports
|
|
}
|
|
}
|
|
var rows []struct {
|
|
Name string `json:"name"`
|
|
Marketplace string `json:"marketplace"`
|
|
Version string `json:"version"`
|
|
Enabled *bool `json:"enabled"`
|
|
Source string `json:"source"`
|
|
}
|
|
if json.Unmarshal(data, &rows) != nil || rows == nil {
|
|
return nil, fmt.Errorf("unrecognized %s plugin inventory", target)
|
|
}
|
|
result := []Installed{}
|
|
for _, row := range rows {
|
|
if !namePattern.MatchString(row.Name) {
|
|
return nil, fmt.Errorf("invalid native plugin name")
|
|
}
|
|
id := row.Name
|
|
if target == "copilot" && row.Marketplace != "" {
|
|
id += "@" + row.Marketplace
|
|
}
|
|
if !validTargetID(target, id) {
|
|
return nil, fmt.Errorf("invalid native plugin identifier")
|
|
}
|
|
item := Installed{ID: id, Name: row.Name, Version: row.Version, Installed: true, Scope: "user", EnabledKnown: row.Enabled != nil}
|
|
if row.Enabled != nil {
|
|
item.Enabled = *row.Enabled
|
|
}
|
|
result = append(result, item)
|
|
}
|
|
return result, nil
|
|
}
|
|
|
|
func (s *Service) verifyNativeTarget(ctx context.Context, target, action, id string) error {
|
|
agent := s.agentOf(target)
|
|
if s.ProjectRoot != "" {
|
|
return fmt.Errorf("%s project plugin operations are unsupported", target)
|
|
}
|
|
if !validTargetID(agent, id) {
|
|
return fmt.Errorf("invalid plugin identifier")
|
|
}
|
|
if agent == "grok" && (action == "install" || action == "update") {
|
|
return fmt.Errorf("Grok requires native trust confirmation; install or update in Grok, then import. Skillshare never supplies --trust automatically")
|
|
}
|
|
command := action
|
|
if action == "remove" || action == "uninstall" {
|
|
command = "uninstall"
|
|
}
|
|
if action == "update" && agent == "antigravity-cli" {
|
|
command = "install"
|
|
}
|
|
// agy handles --help on subcommands as ordinary arguments; its parent help is safe.
|
|
args := []string{"plugin", command, "--help"}
|
|
if agent == "antigravity-cli" {
|
|
args = []string{"plugin", "--help"}
|
|
}
|
|
_, err := s.run(ctx, target, args...)
|
|
return err
|
|
}
|
|
|
|
func (s *Service) applyNativeTarget(ctx context.Context, c Change, b Binding, root string) error {
|
|
remove := c.Action == "remove" || c.Action == "uninstall"
|
|
command, argument := "install", root
|
|
if remove {
|
|
command, argument = "uninstall", b.ID
|
|
}
|
|
if !remove && root == "" {
|
|
return fmt.Errorf("this imported plugin has no reviewed reinstall source; install in the native client and import again")
|
|
}
|
|
// Reinstallation may reset a disabled native plugin. Require the native client
|
|
// to update those installations rather than silently changing enablement.
|
|
if c.Action == "update" {
|
|
enabled := false
|
|
for _, item := range s.host(ctx, c.Target).Installed {
|
|
if item.ID == b.ID && item.EnabledKnown && item.Enabled {
|
|
enabled = true
|
|
break
|
|
}
|
|
}
|
|
if !enabled {
|
|
return fmt.Errorf("update this plugin in the native client to preserve its native enabled state")
|
|
}
|
|
}
|
|
if _, err := s.run(ctx, c.Target, "plugin", command, argument); err != nil {
|
|
return err
|
|
}
|
|
h := s.host(ctx, c.Target)
|
|
if h.Error != "" {
|
|
return fmt.Errorf("native operation completed but verification failed: %s", h.Error)
|
|
}
|
|
for _, item := range h.Installed {
|
|
if item.ID == b.ID {
|
|
if remove {
|
|
return fmt.Errorf("plugin remains installed")
|
|
}
|
|
return nil
|
|
}
|
|
}
|
|
if remove {
|
|
return nil
|
|
}
|
|
return fmt.Errorf("plugin was not found after native installation")
|
|
}
|