Files
skillshare/internal/plugin/local_bundle_test.go
T
Willie 829cbb176d fix(plugins): honor native OMP marketplace builds (#588)
* fix(plugins): honor native OMP marketplace builds

Resolve OMP entries from their native marketplace when present and inspect package.json extension-only plugins. Keep target-specific source paths, marketplace identities and components so Claude adoption and hybrid manifests remain valid.\n\nShow separate builds in text discovery without changing logical JSON selection, and cover native precedence, invalid catalogs, manifestless and hybrid packages, global/project materialization and CLI output with regression tests. Update the plugin docs and existing translations.\n\nFixes #587

* fix(plugins): preserve native build metadata across consumers

Keep OMP catalog versions in target discovery metadata and materialized marketplace entries so previews, cache guards, and native installs use the same version, including legacy catalog fallback. Cover catalog versions that differ from package manifests.

Show each dashboard discovery target's own version, components, and source path instead of presenting a merged candidate as one build.

* fix(plugins): avoid ambiguous shared build versions

Derive candidate versions from agreement across supported targets and recompute after catalog overrides. No-Agent records and lists no longer inherit an arbitrary native build version; equal versions remain available and unknown versions stay unknown.

Keep Cursor and Antigravity inventory target-specific when manifests disagree. Cover no-Agent preview and persistence, equal and unknown versions, catalog overrides, and mixed-manifest local inventories. Align English and translated plugin references.

* fix(plugins): accept Pi extension manifests for OMP catalogs

Reuse the existing OMP extension detector instead of requiring an OMP-specific manifest key. Native OMP accepts Pi extension manifests too, so the extra gate rejected supported native catalog entries.

Cover Pi-only discovery with scoped package names and global/project materialization. Align the English plugin references and all existing translations.
2026-10-20 12:22:05 +08:00

77 lines
2.5 KiB
Go

package plugin
import (
"os"
"path/filepath"
"testing"
)
func TestLocalInventoryUsesTargetVersion(t *testing.T) {
for _, target := range []string{"cursor", "antigravity"} {
t.Run(target, func(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
s := &Service{}
root, _, err := s.localRoot(target)
if err != nil {
t.Fatal(err)
}
manifest := "plugin.json"
if target == "cursor" {
manifest = ".cursor-plugin/plugin.json"
}
writePluginFile(t, root, "demo/"+manifest, `{"name":"demo","version":"1.0.0"}`)
writePluginFile(t, root, "demo/package.json", `{"name":"demo","version":"2.0.0","pi":{"extensions":["./index.ts"]}}`)
installed, _, err := s.localInventory(target)
if err != nil || len(installed) != 1 || installed[0].Version != "1.0.0" {
t.Fatalf("lost native target version: %+v %v", installed, err)
}
})
}
}
// A config root reached through a linked ancestor (macOS /var, a linked home or
// CLAUDE_CONFIG_DIR) is the user's choice; links inside the root are refused.
func TestNoSymlinkTrustsOnlyTheRootAndAbove(t *testing.T) {
base := t.TempDir()
volume := filepath.Join(base, "volume")
outside := filepath.Join(base, "outside")
for _, dir := range []string{filepath.Join(volume, "agent", "real"), outside} {
if err := os.MkdirAll(dir, 0o755); err != nil {
t.Fatal(err)
}
}
link := func(target, name string) {
t.Helper()
if err := os.Symlink(target, name); err != nil {
t.Fatal(err)
}
}
linked := filepath.Join(base, "linked")
link(volume, linked)
root := filepath.Join(linked, "agent")
link(filepath.Join(outside, "settings.json"), filepath.Join(root, "settings.json"))
link(outside, filepath.Join(root, "plugins"))
linkedRoot := filepath.Join(base, "linked-agent")
link(filepath.Join(volume, "agent"), linkedRoot)
for _, tc := range []struct {
name, root, path string
ok bool
}{
{"linked ancestor", root, filepath.Join(root, "real", "config.json"), true},
{"linked root", linkedRoot, filepath.Join(linkedRoot, "real", "config.json"), true},
{"missing path", root, filepath.Join(root, "new", "config.json"), true},
{"linked config file", root, filepath.Join(root, "settings.json"), false},
{"linked folder inside root", root, filepath.Join(root, "plugins", "demo"), false},
{"outside root", root, filepath.Join(base, "volume", "other.json"), false},
} {
t.Run(tc.name, func(t *testing.T) {
if err := noSymlink(tc.root, tc.path); (err == nil) != tc.ok {
t.Fatalf("noSymlink(%s, %s) = %v", tc.root, tc.path, err)
}
})
}
}