Skill install: also refresh Codex's copy under $CODEX_HOME/skills

This commit is contained in:
2026-11-04 16:43:55 +00:00
parent bc7ce15f40
commit 6870c81960
3 changed files with 68 additions and 1 deletions
+3 -1
View File
@@ -174,7 +174,9 @@ covers the requested loopback address and port (wildcard or matching family);
malformed or non-matching bindings fail clearly, and a loopback `wss` endpoint
is rejected as having no supported local TLS mapping rather than downgraded to
plaintext. nvim remains a client-side editor.
`./install` installs/updates the global skill and format reference. Plain
`./install` installs/updates the global skill and format reference for OpenCode,
Claude Code (`~/.claude/skills`) and Codex (`$CODEX_HOME/skills`, default
`~/.codex/skills`). Plain
`go install` users run `pipelines skill install` separately. Shared login/config
and user-modified skills are preserved; harness permissions remain in effect.
+21
View File
@@ -12,6 +12,9 @@ func TestInstallAllSkillsInstallsClaudeCodeCopy(t *testing.T) {
claudeConfig := t.TempDir()
t.Setenv("CLAUDE_CONFIG_DIR", claudeConfig)
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
t.Setenv("CODEX_HOME", "")
t.Setenv("HOME", t.TempDir())
t.Setenv("PATH", "")
dirs, err := InstallAllSkills()
if err != nil {
t.Fatal(err)
@@ -45,3 +48,21 @@ func TestClaudeSkillDirectoryHonoursConfigOverride(t *testing.T) {
t.Fatalf("directory: %q ok=%v", dir, ok)
}
}
func TestInstallAllSkillsInstallsCodexCopy(t *testing.T) {
codexHome := t.TempDir()
t.Setenv("CODEX_HOME", codexHome)
t.Setenv("CLAUDE_CONFIG_DIR", t.TempDir())
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
dirs, err := InstallAllSkills()
if err != nil {
t.Fatal(err)
}
codexDir := filepath.Join(codexHome, "skills", "pipelines")
if len(dirs) != 3 || dirs[2] != codexDir {
t.Fatalf("installed directories: %+v", dirs)
}
if body, err := os.ReadFile(filepath.Join(codexDir, "references", "practices.md")); err != nil || len(body) == 0 {
t.Fatalf("Codex skill not installed: %v", err)
}
}
+44
View File
@@ -77,6 +77,43 @@ func InstallClaudeSkill() (string, error) {
return dir, nil
}
// CodexSkillDirectory is Codex's home skill root ($CODEX_HOME/skills, default
// ~/.codex/skills) when Codex is installed or configured; ok is false otherwise.
func CodexSkillDirectory() (string, bool) {
if dir := os.Getenv("CODEX_HOME"); dir != "" {
absolute, err := filepath.Abs(dir)
if err != nil {
return "", false
}
return filepath.Join(absolute, "skills", "pipelines"), true
}
home, err := os.UserHomeDir()
if err != nil {
return "", false
}
config := filepath.Join(home, ".codex")
if info, err := os.Stat(config); err == nil && info.IsDir() {
return filepath.Join(config, "skills", "pipelines"), true
}
if _, err := exec.LookPath("codex"); err == nil {
return filepath.Join(config, "skills", "pipelines"), true
}
return "", false
}
// InstallCodexSkill refreshes Codex's copy of the workflow skill. It returns an
// empty directory when Codex is not present.
func InstallCodexSkill() (string, error) {
dir, ok := CodexSkillDirectory()
if !ok {
return "", nil
}
if err := installSkillIn(dir); err != nil {
return "", err
}
return dir, nil
}
// InstallAllSkills refreshes every detected agent skill root with the bundled
// workflow skill. A failure leaves the successful targets installed and names
// the failure, so one harness cannot silently shadow another.
@@ -94,6 +131,13 @@ func InstallAllSkills() ([]string, error) {
if claudeDir != "" {
installed = append(installed, claudeDir)
}
codexDir, err := InstallCodexSkill()
if err != nil {
return installed, err
}
if codexDir != "" {
installed = append(installed, codexDir)
}
return installed, nil
}