Skip to content

Add Codex-native agent sync - #10

Merged
k1064190 merged 1 commit into
masterfrom
feat/codex-native-agent-sync
Jul 20, 2026
Merged

k1064190 merged 1 commit into
masterfrom
feat/codex-native-agent-sync

Conversation

@k1064190

Copy link
Copy Markdown
Owner

What changed

  • add a Codex-only codex-agents item type for native TOML custom agents
  • route user and project scope to .codex/agents/ while skipping unsupported platforms
  • support discovery, interactive sync, refresh, status, and documentation
  • add regression tests for TOML discovery and platform routing

Why

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 ./...
  • installed the built binary and verified claude-sync --status reports Codex linked=1 broken=0 for codex-agents
  • git diff --check

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +120 to +123
// collectCodexAgentFiles returns native Codex custom-agent TOML definitions.
func collectCodexAgentFiles(srcDir string) ([]string, error) {
return collectFilesBySuffix(srcDir, ".toml")
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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 ""
}

Comment on lines +178 to +201
// 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)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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)
	}
}

@k1064190
k1064190 marked this pull request as ready for review July 20, 2026 09:20
Copilot AI review requested due to automatic review settings July 20, 2026 09:20
@k1064190
k1064190 merged commit cf26451 into master Jul 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants