| 1 | package cli |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | "strings" |
| 7 | "testing" |
| 8 | |
| 9 | "reasonix/internal/pluginpkg" |
| 10 | ) |
| 11 | |
| 12 | func TestPluginsSlashShowsInstalledPluginDetails(t *testing.T) { |
| 13 | home := t.TempDir() |
| 14 | t.Setenv("REASONIX_HOME", home) |
| 15 | root := filepath.Join(home, "plugins", "superpowers") |
| 16 | writePluginTestFile(t, filepath.Join(root, pluginpkg.CodexManifest), `{ |
| 17 | "name": "superpowers", |
| 18 | "version": "6.1.0", |
| 19 | "description": "Planning workflows", |
| 20 | "skills": "skills" |
| 21 | }`) |
| 22 | writePluginTestFile(t, filepath.Join(root, "skills", "plan", "SKILL.md"), "---\ndescription: Plan work\n---\nbody") |
| 23 | if err := pluginpkg.Upsert(home, pluginpkg.InstalledPlugin{Name: "superpowers", Root: "plugins/superpowers", Version: "6.1.0", ManifestKind: "codex", Enabled: true}); err != nil { |
| 24 | t.Fatal(err) |
| 25 | } |
| 26 | |
| 27 | m := newTestChatTUI() |
| 28 | if cmd := m.runSlashCommand("/plugins show superpowers"); cmd != nil { |
| 29 | t.Fatal("/plugins show should render locally") |
| 30 | } |
| 31 | out := strings.Join(m.transcript, "\n") |
| 32 | for _, want := range []string{"plugin superpowers [enabled]", "/superpowers:plan", "usage: enabled plugins load into new sessions"} { |
| 33 | if !strings.Contains(out, want) { |
| 34 | t.Fatalf("/plugins show output missing %q:\n%s", want, out) |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | func writePluginTestFile(t *testing.T, path, body string) { |
| 40 | t.Helper() |
| 41 | if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { |
| 42 | t.Fatal(err) |
| 43 | } |
| 44 | if err := os.WriteFile(path, []byte(body), 0o644); err != nil { |
| 45 | t.Fatal(err) |
| 46 | } |
| 47 | } |
| 48 |