Repository navigation
Add Codex-native agent sync - #10
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for native Codex custom-agent TOML definitions under a new codex-agents item type, ensuring they are synced exclusively to the Codex platform. The changes include updating file discovery, platform routing, and adding corresponding tests. The reviewer feedback suggests adding a helper function extractTomlDescription to parse descriptions from the TOML files to prevent potential nil pointer dereference panics in the TUI, along with a corresponding unit test.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| // collectCodexAgentFiles returns native Codex custom-agent TOML definitions. | ||
| func collectCodexAgentFiles(srcDir string) ([]string, error) { | ||
| return collectFilesBySuffix(srcDir, ".toml") | ||
| } |
There was a problem hiding this comment.
To support extracting descriptions from Codex agent TOML files and avoid a nil pointer dereference panic in the TUI, we should define a package-level helper function extractTomlDescription. This function reads the TOML file line-by-line, parses the description key, and strips any surrounding quotes.
// collectCodexAgentFiles returns native Codex custom-agent TOML definitions.
func collectCodexAgentFiles(srcDir string) ([]string, error) {
return collectFilesBySuffix(srcDir, ".toml")
}
// extractTomlDescription reads a TOML file and extracts the value of the "description" key.
func extractTomlDescription(path string) string {
file, err := os.Open(path)
if err != nil {
return ""
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if !strings.Contains(line, "=") {
continue
}
parts := strings.SplitN(line, "=", 2)
key := strings.TrimSpace(parts[0])
if key == "description" {
val := strings.TrimSpace(parts[1])
// Strip surrounding quotes
if len(val) >= 2 && ((val[0] == '"' && val[len(val)-1] == '"') || (val[0] == '\'' && val[len(val)-1] == '\'')) {
return val[1 : len(val)-1]
}
return val
}
}
return ""
}| // TestCollectCodexAgentFiles verifies that native Codex custom-agent | ||
| // discovery includes TOML definitions and excludes Markdown persona agents. | ||
| func TestCollectCodexAgentFiles(t *testing.T) { | ||
| tempDir := t.TempDir() | ||
| srcDir := filepath.Join(tempDir, "codex-agents") | ||
| if err := os.MkdirAll(filepath.Join(srcDir, "review"), 0o755); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.WriteFile(filepath.Join(srcDir, "review", "adversarial.toml"), []byte("name = \"reviewer\""), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.WriteFile(filepath.Join(srcDir, "persona.md"), []byte("ignored"), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| items, err := collectCodexAgentFiles(srcDir) | ||
| if err != nil { | ||
| t.Fatalf("collectCodexAgentFiles: %v", err) | ||
| } | ||
| want := []string{filepath.Join("review", "adversarial.toml")} | ||
| if len(items) != len(want) || items[0] != want[0] { | ||
| t.Errorf("collectCodexAgentFiles = %v; want %v", items, want) | ||
| } | ||
| } |
There was a problem hiding this comment.
Let's add a unit test for the new extractTomlDescription helper function to verify that it correctly parses the description from TOML files and handles various edge cases (e.g., single/double quotes, missing keys).
// TestCollectCodexAgentFiles verifies that native Codex custom-agent
// discovery includes TOML definitions and excludes Markdown persona agents.
func TestCollectCodexAgentFiles(t *testing.T) {
tempDir := t.TempDir()
srcDir := filepath.Join(tempDir, "codex-agents")
if err := os.MkdirAll(filepath.Join(srcDir, "review"), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(srcDir, "review", "adversarial.toml"), []byte("name = \"reviewer\""), 0o644); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(srcDir, "persona.md"), []byte("ignored"), 0o644); err != nil {
t.Fatal(err)
}
items, err := collectCodexAgentFiles(srcDir)
if err != nil {
t.Fatalf("collectCodexAgentFiles: %v", err)
}
want := []string{filepath.Join("review", "adversarial.toml")}
if len(items) != len(want) || items[0] != want[0] {
t.Errorf("collectCodexAgentFiles = %v; want %v", items, want)
}
}
func TestExtractTomlDescription(t *testing.T) {
tempDir := t.TempDir()
path := filepath.Join(tempDir, "agent.toml")
content := "\nname = \"reviewer\"\ndescription = \"An adversarial code reviewer agent\"\nversion = \"1.0\"\n"
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
t.Fatal(err)
}
got := extractTomlDescription(path)
want := "An adversarial code reviewer agent"
if got != want {
t.Errorf("extractTomlDescription() = %q; want %q", got, want)
}
}
What changed
codex-agentsitem type for native TOML custom agents.codex/agents/while skipping unsupported platformsWhy
Shared Markdown persona agents are not native Codex custom agents. A separate item type prevents incompatible agent formats from being synced to Claude, Antigravity, or Opencode.
Validation
TMPDIR=/var/tmp/claude-sync-tests go test ./...claude-sync --statusreportsCodex linked=1 broken=0forcodex-agentsgit diff --check