mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
* feat(omp): add native Oh My Pi support Support OMP skills, instructions, MCP, code hooks and guarded extension selection using its verified native contracts rather than Pi aliases. Add reviewed marketplace plugin installation, cache-preserving scoped removal and fresh-cache reinstall. Align Pi/OMP extension cards and localize inventory guidance while keeping native ownership and read-only constraints. Include regression coverage, isolated E2E runbooks, documentation and verification policies. Native plugin updates and unverified runtime platforms remain guarded. Refs #409 * fix(omp): guard runtime ownership and localize inventory guidance Native install recursively replaces its runtime destination, and a missing cache manifest could leave the real runtime link installed after removal. Bind and recheck an absent reviewed destination, and recover removal names only from verified scope-local links. Localize fixed backend reasons and warnings across dashboard locales while preserving paths and external diagnostics. Restore the reviewed source in the existing reinstall fixture and record real native verification. * fix(omp): allow forgetting natively removed plugins A different plugin can retain node_modules after native uninstall deletes this installation. When its cache, registration and known runtime state are absent, forget only the stale Skillshare binding instead of demanding runtime-name proof for unrelated files. Extend the existing removal recovery test with a failing-before-fix case that verifies the binding is dropped and unrelated native lock bytes and plugin files are preserved. make check passes.
57 lines
1.9 KiB
Go
57 lines
1.9 KiB
Go
package server
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestMCPOmpDashboard(t *testing.T) {
|
|
s, source := newTestServerWithExtras(t, nil, "")
|
|
home := t.TempDir()
|
|
t.Setenv("HOME", home)
|
|
t.Setenv("PI_CODING_AGENT_DIR", "")
|
|
if err := os.WriteFile(s.configPath(), []byte("source: "+source+"\ntargets: {}\nmcp: {targets: [omp], servers: {}}\n"), 0600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
list := httptest.NewRecorder()
|
|
s.handleMCPList(list, httptest.NewRequest(http.MethodGet, "/api/mcp", nil))
|
|
var view struct {
|
|
Paths map[string]string
|
|
ImportSources map[string][]struct{ Target, Path, PiExtension string }
|
|
}
|
|
path := filepath.Join(home, ".omp", "agent", "mcp.json")
|
|
if list.Code != http.StatusOK || json.Unmarshal(list.Body.Bytes(), &view) != nil || view.Paths["omp"] != path {
|
|
t.Fatalf("OMP list: %s", list.Body.String())
|
|
}
|
|
found := false
|
|
for _, item := range view.ImportSources[""] {
|
|
if item.Target == "omp" {
|
|
found = item.Path == path && item.PiExtension == ""
|
|
}
|
|
}
|
|
if !found {
|
|
t.Fatal("OMP import source missing or treated as a Pi adapter")
|
|
}
|
|
body := `{"mutation":{"name":"docs","server":{"url":"https://example.com/mcp","targets":["omp"]}}}`
|
|
render := httptest.NewRecorder()
|
|
s.handleMCPRender(render, httptest.NewRequest(http.MethodPost, "/api/mcp/render", strings.NewReader(body)))
|
|
var preview struct {
|
|
Rendered []struct{ Target, Path, Content, Error string }
|
|
}
|
|
if render.Code != http.StatusOK || json.Unmarshal(render.Body.Bytes(), &preview) != nil || len(preview.Rendered) != 1 {
|
|
t.Fatalf("OMP render: %s", render.Body.String())
|
|
}
|
|
item := preview.Rendered[0]
|
|
if item.Target != "omp" || item.Path != path || item.Error != "" || !strings.Contains(item.Content, `"type": "http"`) {
|
|
t.Fatalf("OMP preview: %+v", item)
|
|
}
|
|
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
|
t.Fatal("render created the native file")
|
|
}
|
|
}
|