feat: dev plugin install flow + smoke-platform

- .gitignore: add plugins/ (local dev install, never committed)
- scripts/install-dev-plugins.sh: install dist package from ../verstak-official-plugins/dist/ into ./plugins/
- scripts/smoke-platform.sh: headless verification of plugin discovery, manifest, capabilities, contributions
- cmd/smoke-platform/main.go: Go smoke command for headless plugin verification
- docs/DEV_PLUGINS.md: dev plugin flow documentation
This commit is contained in:
2026-06-16 16:46:00 +08:00
parent d72ebeb7ec
commit 1c75389535
5 changed files with 368 additions and 0 deletions
+172
View File
@@ -0,0 +1,172 @@
// Smoke-platform validates that the platform-test plugin is discovered correctly
// by the Verstak desktop runtime. This runs headless — no Wails GUI needed.
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/verstak/verstak-desktop/internal/core/capability"
"github.com/verstak/verstak-desktop/internal/core/plugin"
)
func main() {
exitCode := 0
defer func() {
os.Exit(exitCode)
}()
root, _ := os.Getwd()
pluginDir := filepath.Join(root, "plugins")
fmt.Printf("=== smoke-platform: headless plugin verification ===\n\n")
fmt.Printf(" plugin dir: %s\n", pluginDir)
// ── 1. Discover plugins ──
fmt.Printf("\n[discovery]\n")
plugins, errs := plugin.DiscoverPlugins([]string{pluginDir})
if len(errs) > 0 {
for _, e := range errs {
fmt.Printf(" ⚠️ discovery warning: %v\n", e)
}
}
if len(plugins) == 0 {
fmt.Printf(" ❌ no plugins discovered\n")
exitCode = 1
return
}
fmt.Printf(" ✅ discovered %d plugin(s)\n", len(plugins))
// ── 2. Find platform-test ──
fmt.Printf("\n[platform-test lookup]\n")
var target *plugin.Plugin
for i, p := range plugins {
if p.Manifest.ID == "verstak.platform-test" {
target = &plugins[i]
break
}
}
if target == nil {
fmt.Printf(" ❌ platform-test (id=verstak.platform-test) not found among discovered plugins\n")
exitCode = 1
return
}
fmt.Printf(" ✅ found: %s\n", target.Manifest.ID)
// ── 3. Validate manifest fields ──
fmt.Printf("\n[manifest validation]\n")
allGood := true
m := &target.Manifest
checks := []struct {
name string
value string
}{
{"name", m.Name},
{"version", m.Version},
{"apiVersion", m.APIVersion},
}
for _, c := range checks {
if c.value == "" {
fmt.Printf(" ❌ manifest.%s is empty\n", c.name)
allGood = false
} else {
fmt.Printf(" ✅ %s: %s\n", c.name, c.value)
}
}
if m.SchemaVersion != 1 {
fmt.Printf(" ❌ schemaVersion: expected 1, got %d\n", m.SchemaVersion)
allGood = false
} else {
fmt.Printf(" ✅ schemaVersion: 1\n")
}
// ── 4. provides ──
fmt.Printf("\n[provides]\n")
if len(m.Provides) == 0 {
fmt.Printf(" ❌ provides is empty\n")
allGood = false
} else {
for _, p := range m.Provides {
fmt.Printf(" ✅ provides: %s\n", p)
}
}
// ── 5. requires / optionalRequires ──
fmt.Printf("\n[requires]\n")
if len(m.Requires) > 0 {
for _, r := range m.Requires {
fmt.Printf(" ✅ requires: %s\n", r)
}
} else {
fmt.Printf(" ️ requires: none\n")
}
fmt.Printf("\n[optionalRequires]\n")
if len(m.OptionalRequires) > 0 {
for _, r := range m.OptionalRequires {
fmt.Printf(" ✅ optionalRequires: %s\n", r)
}
} else {
fmt.Printf(" ️ optionalRequires: none\n")
}
// ── 6. contributions ──
fmt.Printf("\n[contributions]\n")
if m.Contributes != nil {
c := m.Contributes
if len(c.Views) > 0 {
for _, v := range c.Views {
fmt.Printf(" ✅ view: %s (%s)\n", v.ID, v.Title)
}
}
if len(c.Commands) > 0 {
for _, cmd := range c.Commands {
fmt.Printf(" ✅ command: %s (%s)\n", cmd.ID, cmd.Title)
}
}
if len(c.SidebarItems) > 0 {
for _, s := range c.SidebarItems {
fmt.Printf(" ✅ sidebarItem: %s (%s)\n", s.ID, s.Title)
}
}
if len(c.StatusBarItems) > 0 {
for _, s := range c.StatusBarItems {
fmt.Printf(" ✅ statusBarItem: %s (%s)\n", s.ID, s.Label)
}
}
if len(c.Views)+len(c.Commands)+len(c.SidebarItems)+len(c.StatusBarItems) == 0 {
fmt.Printf(" ️ contributes: empty sections only\n")
}
} else {
fmt.Printf(" ️ contributes: none\n")
}
// ── 7. Capability registration ──
fmt.Printf("\n[capability registration]\n")
reg := capability.NewRegistry()
for _, p := range m.Provides {
err := reg.Register(target.Manifest.ID, []string{p})
if err != nil {
fmt.Printf(" ❌ register capability %s: %v\n", p, err)
allGood = false
} else {
fmt.Printf(" ✅ registered capability: %s\n", p)
}
}
// ── 8. Summary ──
fmt.Printf("\n=== summary ===\n")
if allGood {
fmt.Printf("✅ smoke-platform passed\n")
} else {
fmt.Printf("❌ smoke-platform failed\n")
exitCode = 1
}
}