beads/cmd/bd/setup/plugin_layout_test.go
sms 1cfb6e5d97 fix(plugin): move claude agent out of shared codex dir to fix plugin install
the claude plugin manifest declared agents at ./skills/beads/agents/, which
also contains openai.yaml (codex interface metadata). claude code's plugin
loader scans that dir and rejects non-md files, failing manifest validation
with 'agents: Invalid input'.

move task-agent.md back to plugins/beads/agents/ (the claude default, what
v1.0.0 used) and drop the explicit agents key from .claude-plugin/plugin.json.
codex's openai.yaml stays at skills/beads/agents/openai.yaml where bd setup
codex writes it and where the embed in internal/templates/ lives.

shared skill tree and dual claude/codex manifests are preserved per #3664.

Fixes #3741
2026-05-06 08:18:36 -04:00

75 lines
2.5 KiB
Go

package setup
import (
"encoding/json"
"os"
"path/filepath"
"testing"
)
func TestPluginLayoutUsesSharedBeadsRoot(t *testing.T) {
root := filepath.Join("..", "..", "..")
var claudeMarketplace struct {
Plugins []struct {
Source string `json:"source"`
} `json:"plugins"`
}
readJSONFile(t, filepath.Join(root, ".claude-plugin", "marketplace.json"), &claudeMarketplace)
if len(claudeMarketplace.Plugins) != 1 {
t.Fatalf("expected one Claude marketplace plugin, got %d", len(claudeMarketplace.Plugins))
}
if got := claudeMarketplace.Plugins[0].Source; got != "./plugins/beads" {
t.Fatalf("Claude marketplace source = %q, want ./plugins/beads", got)
}
var claudeManifest struct {
Skills string `json:"skills"`
Commands string `json:"commands"`
Agents *string `json:"agents"`
}
readJSONFile(t, filepath.Join(root, "plugins", "beads", ".claude-plugin", "plugin.json"), &claudeManifest)
if claudeManifest.Skills != "./skills/" {
t.Fatalf("Claude skills path = %q, want ./skills/", claudeManifest.Skills)
}
if claudeManifest.Commands != "./skills/beads/commands/" {
t.Fatalf("Claude commands path = %q, want ./skills/beads/commands/", claudeManifest.Commands)
}
if claudeManifest.Agents != nil {
t.Fatalf("Claude agents path = %q, want unset (default ./agents/) so the loader does not scan codex yaml as agents", *claudeManifest.Agents)
}
var codexManifest struct {
Skills string `json:"skills"`
}
readJSONFile(t, filepath.Join(root, "plugins", "beads", ".codex-plugin", "plugin.json"), &codexManifest)
if codexManifest.Skills != "./skills/" {
t.Fatalf("Codex manifest skills path = %q, want ./skills/", codexManifest.Skills)
}
requireRepoFile(t, root, "plugins", "beads", "skills", "beads", "SKILL.md")
requireRepoFile(t, root, "plugins", "beads", "skills", "beads", "agents", "openai.yaml")
requireRepoFile(t, root, "plugins", "beads", "agents", "task-agent.md")
requireRepoFile(t, root, "plugins", "beads", "skills", "beads", "commands", "ready.md")
}
func readJSONFile(t *testing.T, path string, dest interface{}) {
t.Helper()
data, err := os.ReadFile(path)
if err != nil {
t.Fatalf("read %s: %v", path, err)
}
if err := json.Unmarshal(data, dest); err != nil {
t.Fatalf("parse %s: %v", path, err)
}
}
func requireRepoFile(t *testing.T, root string, parts ...string) {
t.Helper()
path := filepath.Join(append([]string{root}, parts...)...)
if info, err := os.Stat(path); err != nil {
t.Fatalf("expected file %s: %v", path, err)
} else if info.IsDir() {
t.Fatalf("expected file %s, got directory", path)
}
}