From ad13778745ad5be6daa871dd3868af3953616e98 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Thu, 19 Nov 2026 17:23:52 +0000 Subject: [PATCH 1/2] aitools: pin every registry agent in a contract test ## Changes Adds `TestRegistryContract` to `libs/aitools/agents/registry_test.go`. It is a table test that pins, for every agent in `Registry`: - the display name and the binary looked up on `PATH` - the plugin installed for it (marketplace, ID, source, shared flag), or none - the marker file needed to confirm it is installed (`MandatoryFile`) - the global skills directory, derived from a temporary home directory - whether it supports project scope and, if so, its project skills directory The test also checks that the registry holds exactly these agents, in this order. Per-agent override environment variables (`CLAUDE_CONFIG_DIR`, `PI_CODING_AGENT_DIR`, `GEMINI_CLI_HOME`, `GOOSE_PATH_ROOT`, `XDG_CONFIG_HOME`, `APPDATA`) are cleared so every path comes from the temporary home. The Goose global directory has its own expected value on Windows. This PR only adds a test. No production code changes. ## Why Each registry entry decides where the CLI writes skills and which plugin it installs for that agent. Until now, nothing caught an accidental edit to an entry, such as a renamed directory, a dropped plugin or a flipped project-scope flag. With this test, any change to an agent's behavior also has to update the table, so the change shows up in review. ## Tests - `go test ./libs/aitools/agents/ -run TestRegistryContract -v` passes, including one subtest for each of the 10 agents. Co-authored-by: Isaac --- libs/aitools/agents/registry_test.go | 73 ++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/libs/aitools/agents/registry_test.go b/libs/aitools/agents/registry_test.go index 20eca404cdf..00143d8ec79 100644 --- a/libs/aitools/agents/registry_test.go +++ b/libs/aitools/agents/registry_test.go @@ -68,3 +68,76 @@ func TestDetectProjectInstalled(t *testing.T) { } assert.ElementsMatch(t, []string{NamePi, NameGemini, NameGoose, NameKiro}, names) } + +// TestRegistryContract pins what each registry agent promises users: the binary +// probed on PATH, the plugin installed for it, where its skills are written and +// whether it supports project scope. Adding, removing or changing an agent must +// update this table, so an accidental edit to the registry fails here. +func TestRegistryContract(t *testing.T) { + home := t.TempDir() + cwd := t.TempDir() + ctx := env.WithUserHomeDir(t.Context(), home) + // Clear the per-agent overrides so every directory derives from home. + for _, v := range []string{"CLAUDE_CONFIG_DIR", "PI_CODING_AGENT_DIR", "GEMINI_CLI_HOME", "GOOSE_PATH_ROOT", "XDG_CONFIG_HOME", "APPDATA"} { + t.Setenv(v, "") + } + + gooseGlobalDir := filepath.Join(home, ".config", "goose", "skills") + if runtime.GOOS == "windows" { + gooseGlobalDir = filepath.Join(home, "AppData", "Roaming", "Block", "goose", "config", "skills") + } + databricks := &PluginSpec{Marketplace: "databricks-agent-skills", ID: "databricks", Source: "databricks/databricks-agent-skills"} + claude := &PluginSpec{Marketplace: "claude-plugins-official", ID: "databricks", Source: "anthropics/claude-plugins-official", Shared: true} + + tests := []struct { + name string + displayName string + binary string + plugin *PluginSpec + mandatoryFile string + globalDir string + // projectDir is empty for agents without project scope. + projectDir string + }{ + {NameClaudeCode, "Claude Code", "claude", claude, "", filepath.Join(home, ".claude", "skills"), filepath.Join(cwd, ".claude", "skills")}, + {NameCursor, "Cursor", "cursor-agent", nil, "", filepath.Join(home, ".cursor", "skills"), ""}, + {NameCodex, "Codex CLI", "codex", databricks, "", filepath.Join(home, ".codex", "skills"), ""}, + {NameOpenCode, "OpenCode", "opencode", nil, "", filepath.Join(home, ".config", "opencode", "skills"), ""}, + {NameCopilot, "GitHub Copilot", "copilot", databricks, "", filepath.Join(home, ".copilot", "skills"), ""}, + {NameAntigravity, "Antigravity", "", nil, "", filepath.Join(home, ".gemini", "antigravity", "global_skills"), ""}, + {NamePi, "Pi", "pi", nil, "", filepath.Join(home, ".pi", "agent", "skills"), filepath.Join(cwd, ".pi", "skills")}, + {NameGemini, "Gemini CLI", "gemini", nil, "projects.json", filepath.Join(home, ".gemini", "skills"), filepath.Join(cwd, ".gemini", "skills")}, + {NameGoose, "Goose", "goose", nil, "", gooseGlobalDir, filepath.Join(cwd, ".goose", "skills")}, + {NameKiro, "Kiro", "kiro", nil, "", filepath.Join(home, ".kiro", "skills"), filepath.Join(cwd, ".kiro", "skills")}, + } + + var names []string + for _, a := range Registry { + names = append(names, a.Name) + } + var want []string + for _, tc := range tests { + want = append(want, tc.name) + } + require.Equal(t, want, names, "registry agents or their order changed; update this table") + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + a := ByName(tc.name) + require.NotNil(t, a) + assert.Equal(t, tc.displayName, a.DisplayName) + assert.Equal(t, tc.binary, a.Binary) + assert.Equal(t, tc.plugin, a.Plugin) + assert.Equal(t, tc.mandatoryFile, a.MandatoryFile) + + globalDir, err := a.SkillsDir(ctx) + require.NoError(t, err) + assert.Equal(t, tc.globalDir, globalDir) + + assert.Equal(t, tc.projectDir != "", a.SupportsProjectScope) + if tc.projectDir != "" { + assert.Equal(t, tc.projectDir, a.ProjectSkillsDir(cwd)) + } + }) + } +} From 91fa135c523fd7525df2e5e8c38e18060fa2027a Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Thu, 19 Nov 2026 23:06:07 +0000 Subject: [PATCH 2/2] aitools: tighten the registry contract test Remove TestSkillAgentRegistryPaths, which duplicated four rows of the contract table. Write agent names as string literals so a renamed agent fails the test. Point XDG_CONFIG_HOME and APPDATA at non-default directories so the OpenCode and Goose rows pin that those overrides are honored. Narrow the doc comment to the fields the table covers. Co-authored-by: Isaac --- libs/aitools/agents/registry_test.go | 89 +++++++++------------------- 1 file changed, 28 insertions(+), 61 deletions(-) diff --git a/libs/aitools/agents/registry_test.go b/libs/aitools/agents/registry_test.go index 00143d8ec79..2326a780326 100644 --- a/libs/aitools/agents/registry_test.go +++ b/libs/aitools/agents/registry_test.go @@ -11,48 +11,6 @@ import ( "github.com/stretchr/testify/require" ) -func TestSkillAgentRegistryPaths(t *testing.T) { - home := t.TempDir() - cwd := t.TempDir() - ctx := env.WithUserHomeDir(t.Context(), home) - ctx = env.Set(ctx, "XDG_CONFIG_HOME", filepath.Join(home, ".config")) - ctx = env.Set(ctx, "APPDATA", "") - - gooseGlobalDir := filepath.Join(home, ".config", "goose", "skills") - if runtime.GOOS == "windows" { - gooseGlobalDir = filepath.Join(home, "AppData", "Roaming", "Block", "goose", "config", "skills") - } - - tests := []struct { - name string - binary string - displayName string - globalDir string - projectDir string - }{ - {NamePi, "pi", "Pi", filepath.Join(home, ".pi", "agent", "skills"), filepath.Join(cwd, ".pi", "skills")}, - {NameGemini, "gemini", "Gemini CLI", filepath.Join(home, ".gemini", "skills"), filepath.Join(cwd, ".gemini", "skills")}, - {NameGoose, "goose", "Goose", gooseGlobalDir, filepath.Join(cwd, ".goose", "skills")}, - {NameKiro, "kiro", "Kiro", filepath.Join(home, ".kiro", "skills"), filepath.Join(cwd, ".kiro", "skills")}, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - a := ByName(tc.name) - require.NotNil(t, a) - assert.Equal(t, tc.binary, a.Binary) - assert.Equal(t, tc.displayName, a.DisplayName) - assert.True(t, a.SupportsProjectScope) - assert.Nil(t, a.Plugin) - - globalDir, err := a.SkillsDir(ctx) - require.NoError(t, err) - assert.Equal(t, tc.globalDir, globalDir) - assert.Equal(t, tc.projectDir, a.ProjectSkillsDir(cwd)) - }) - } -} - func TestDetectProjectInstalled(t *testing.T) { cwd := t.TempDir() for _, name := range []string{NamePi, NameGemini, NameGoose, NameKiro} { @@ -69,22 +27,31 @@ func TestDetectProjectInstalled(t *testing.T) { assert.ElementsMatch(t, []string{NamePi, NameGemini, NameGoose, NameKiro}, names) } -// TestRegistryContract pins what each registry agent promises users: the binary -// probed on PATH, the plugin installed for it, where its skills are written and -// whether it supports project scope. Adding, removing or changing an agent must -// update this table, so an accidental edit to the registry fails here. +// TestRegistryContract pins each registry agent's name, display name, the +// binary probed on PATH, the plugin installed for it, its marker file, where +// its skills are written and whether it supports project scope. Adding, +// removing or changing one of these fields must update this table. The MCP +// spec and plugin manifest readers are not covered here. func TestRegistryContract(t *testing.T) { home := t.TempDir() cwd := t.TempDir() ctx := env.WithUserHomeDir(t.Context(), home) - // Clear the per-agent overrides so every directory derives from home. - for _, v := range []string{"CLAUDE_CONFIG_DIR", "PI_CODING_AGENT_DIR", "GEMINI_CLI_HOME", "GOOSE_PATH_ROOT", "XDG_CONFIG_HOME", "APPDATA"} { + // Clear the per-agent overrides so these directories derive from home. + for _, v := range []string{"CLAUDE_CONFIG_DIR", "PI_CODING_AGENT_DIR", "GEMINI_CLI_HOME", "GOOSE_PATH_ROOT"} { t.Setenv(v, "") } - - gooseGlobalDir := filepath.Join(home, ".config", "goose", "skills") + // Point the config roots away from their defaults so the OpenCode and Goose + // rows fail if either agent stops honoring them. + xdg := filepath.Join(home, "xdg") + appData := filepath.Join(home, "appdata") + t.Setenv("XDG_CONFIG_HOME", xdg) + t.Setenv("APPDATA", appData) + + openCodeGlobalDir := filepath.Join(xdg, "opencode", "skills") + gooseGlobalDir := filepath.Join(xdg, "goose", "skills") if runtime.GOOS == "windows" { - gooseGlobalDir = filepath.Join(home, "AppData", "Roaming", "Block", "goose", "config", "skills") + openCodeGlobalDir = filepath.Join(appData, "opencode", "skills") + gooseGlobalDir = filepath.Join(appData, "Block", "goose", "config", "skills") } databricks := &PluginSpec{Marketplace: "databricks-agent-skills", ID: "databricks", Source: "databricks/databricks-agent-skills"} claude := &PluginSpec{Marketplace: "claude-plugins-official", ID: "databricks", Source: "anthropics/claude-plugins-official", Shared: true} @@ -99,16 +66,16 @@ func TestRegistryContract(t *testing.T) { // projectDir is empty for agents without project scope. projectDir string }{ - {NameClaudeCode, "Claude Code", "claude", claude, "", filepath.Join(home, ".claude", "skills"), filepath.Join(cwd, ".claude", "skills")}, - {NameCursor, "Cursor", "cursor-agent", nil, "", filepath.Join(home, ".cursor", "skills"), ""}, - {NameCodex, "Codex CLI", "codex", databricks, "", filepath.Join(home, ".codex", "skills"), ""}, - {NameOpenCode, "OpenCode", "opencode", nil, "", filepath.Join(home, ".config", "opencode", "skills"), ""}, - {NameCopilot, "GitHub Copilot", "copilot", databricks, "", filepath.Join(home, ".copilot", "skills"), ""}, - {NameAntigravity, "Antigravity", "", nil, "", filepath.Join(home, ".gemini", "antigravity", "global_skills"), ""}, - {NamePi, "Pi", "pi", nil, "", filepath.Join(home, ".pi", "agent", "skills"), filepath.Join(cwd, ".pi", "skills")}, - {NameGemini, "Gemini CLI", "gemini", nil, "projects.json", filepath.Join(home, ".gemini", "skills"), filepath.Join(cwd, ".gemini", "skills")}, - {NameGoose, "Goose", "goose", nil, "", gooseGlobalDir, filepath.Join(cwd, ".goose", "skills")}, - {NameKiro, "Kiro", "kiro", nil, "", filepath.Join(home, ".kiro", "skills"), filepath.Join(cwd, ".kiro", "skills")}, + {"claude-code", "Claude Code", "claude", claude, "", filepath.Join(home, ".claude", "skills"), filepath.Join(cwd, ".claude", "skills")}, + {"cursor", "Cursor", "cursor-agent", nil, "", filepath.Join(home, ".cursor", "skills"), ""}, + {"codex", "Codex CLI", "codex", databricks, "", filepath.Join(home, ".codex", "skills"), ""}, + {"opencode", "OpenCode", "opencode", nil, "", openCodeGlobalDir, ""}, + {"copilot", "GitHub Copilot", "copilot", databricks, "", filepath.Join(home, ".copilot", "skills"), ""}, + {"antigravity", "Antigravity", "", nil, "", filepath.Join(home, ".gemini", "antigravity", "global_skills"), ""}, + {"pi", "Pi", "pi", nil, "", filepath.Join(home, ".pi", "agent", "skills"), filepath.Join(cwd, ".pi", "skills")}, + {"gemini", "Gemini CLI", "gemini", nil, "projects.json", filepath.Join(home, ".gemini", "skills"), filepath.Join(cwd, ".gemini", "skills")}, + {"goose", "Goose", "goose", nil, "", gooseGlobalDir, filepath.Join(cwd, ".goose", "skills")}, + {"kiro", "Kiro", "kiro", nil, "", filepath.Join(home, ".kiro", "skills"), filepath.Join(cwd, ".kiro", "skills")}, } var names []string