installEntityToApp installs an entity directly into an app directory for testing the list command's installed-scan behavior.
(t *testing.T, home string, kind entities.Kind, name, content, app string)
| 26 | // installEntityToApp installs an entity directly into an app directory for |
| 27 | // testing the list command's installed-scan behavior. |
| 28 | func installEntityToApp(t *testing.T, home string, kind entities.Kind, name, content, app string) { |
| 29 | t.Helper() |
| 30 | apps := entities.AppPathsFor(kind) |
| 31 | dest, ok := apps[app] |
| 32 | if !ok { |
| 33 | t.Fatalf("unknown app %q for kind %s", app, kind) |
| 34 | } |
| 35 | resolved := os.ExpandEnv(strings.ReplaceAll(dest, "~", home)) |
| 36 | switch kind { |
| 37 | case entities.KindPrompt, entities.KindInstruction: |
| 38 | if err := os.MkdirAll(filepath.Dir(resolved), 0o755); err != nil { |
| 39 | t.Fatal(err) |
| 40 | } |
| 41 | if err := os.WriteFile(resolved, []byte(content), 0o600); err != nil { |
| 42 | t.Fatal(err) |
| 43 | } |
| 44 | case entities.KindSkill: |
| 45 | dir := filepath.Join(resolved, name) |
| 46 | if err := os.MkdirAll(dir, 0o755); err != nil { |
| 47 | t.Fatal(err) |
| 48 | } |
| 49 | if err := os.WriteFile(filepath.Join(dir, "SKILL.md"), []byte(content), 0o600); err != nil { |
| 50 | t.Fatal(err) |
| 51 | } |
| 52 | case entities.KindAgent: |
| 53 | dir := filepath.Join(resolved, name) |
| 54 | if err := os.MkdirAll(dir, 0o755); err != nil { |
| 55 | t.Fatal(err) |
| 56 | } |
| 57 | if err := os.WriteFile(filepath.Join(dir, "AGENT.md"), []byte(content), 0o600); err != nil { |
| 58 | t.Fatal(err) |
| 59 | } |
| 60 | case entities.KindPlugin: |
| 61 | dir := filepath.Join(resolved, name) |
| 62 | if err := os.MkdirAll(dir, 0o755); err != nil { |
| 63 | t.Fatal(err) |
| 64 | } |
| 65 | if err := os.WriteFile(filepath.Join(dir, "manifest.json"), []byte(content), 0o600); err != nil { |
| 66 | t.Fatal(err) |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | // ============================================================================ |
| 72 | // list — shows what's installed across code agents |
no test coverage detected