Skip to content

Commit 0fa02ae

Browse files
committed
feat: add codex agent conversion and install support
1 parent 4feb0cd commit 0fa02ae

File tree

7 files changed

+202
-8
lines changed

7 files changed

+202
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ integrations/qwen/agents/
7878
integrations/kimi/*/
7979
!integrations/openclaw/README.md
8080
!integrations/kimi/README.md
81+
integrations/codex/agents/*

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ quickstart guide wearing an agent costume does not.
220220

221221
**Qwen Code Compatibility**: Agent bodies support `${variable}` templating for dynamic context (e.g., `${project_name}`, `${task_description}`). Qwen SubAgents use minimal frontmatter: only `name` and `description` are required; `color`, `emoji`, and `version` fields are omitted as Qwen doesn't use them.
222222

223+
**Codex Compatibility**: Codex custom agents are generated as standalone TOML files. The Codex integration keeps a minimal 1:1 mapping: `name` and `description` are copied from frontmatter, and the Markdown body becomes `developer_instructions`. Source-only metadata such as `color`, `emoji`, `vibe`, and other unsupported frontmatter fields are omitted.
224+
223225
### What Makes a Great Agent?
224226

225227
**Great agents have**:

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Each agent file contains:
4444

4545
Browse the agents below and copy/adapt the ones you need!
4646

47-
### Option 3: Use with Other Tools (Cursor, Aider, Windsurf, Gemini CLI, OpenCode, Kimi Code)
47+
### Option 3: Use with Other Tools (Cursor, Aider, Windsurf, Gemini CLI, OpenCode, Kimi Code, Codex)
4848

4949
```bash
5050
# Step 1 -- generate integration files for all supported tools
@@ -59,6 +59,7 @@ Browse the agents below and copy/adapt the ones you need!
5959
./scripts/install.sh --tool aider
6060
./scripts/install.sh --tool windsurf
6161
./scripts/install.sh --tool kimi
62+
./scripts/install.sh --tool codex
6263
```
6364

6465
See the [Multi-Tool Integrations](#-multi-tool-integrations) section below for full details.
@@ -522,6 +523,7 @@ The Agency works natively with Claude Code, and ships conversion + install scrip
522523
- **[OpenClaw](https://github.com/openclaw/openclaw)**`SOUL.md` + `AGENTS.md` + `IDENTITY.md` per agent
523524
- **[Qwen Code](https://github.com/QwenLM/qwen-code)**`.md` SubAgent files → `~/.qwen/agents/`
524525
- **[Kimi Code](https://github.com/MoonshotAI/kimi-cli)** — YAML agent specs → `~/.config/kimi/agents/`
526+
- **[Codex](https://developers.openai.com/codex/overview)** — TOML custom agents → `~/.codex/agents/`
525527

526528
---
527529

@@ -559,8 +561,9 @@ The installer scans your system for installed tools, shows a checkbox UI, and le
559561
[ ] 9) [ ] Windsurf (.windsurfrules)
560562
[ ] 10) [ ] Qwen Code (~/.qwen/agents)
561563
[ ] 11) [ ] Kimi Code (~/.config/kimi/agents)
564+
[ ] 12) [ ] Codex (~/.codex/agents)
562565
563-
[1-11] toggle [a] all [n] none [d] detected
566+
[1-12] toggle [a] all [n] none [d] detected
564567
[Enter] install [q] quit
565568
```
566569

@@ -570,6 +573,7 @@ The installer scans your system for installed tools, shows a checkbox UI, and le
570573
./scripts/install.sh --tool opencode
571574
./scripts/install.sh --tool openclaw
572575
./scripts/install.sh --tool antigravity
576+
./scripts/install.sh --tool codex
573577
```
574578

575579
**Non-interactive (CI/scripts):**
@@ -796,6 +800,24 @@ See [integrations/kimi/README.md](integrations/kimi/README.md) for details.
796800

797801
</details>
798802

803+
<details>
804+
<summary><strong>Codex</strong></summary>
805+
806+
Each agent is converted into a Codex custom agent TOML file and installed to `~/.codex/agents/`.
807+
808+
```bash
809+
./scripts/convert.sh --tool codex
810+
./scripts/install.sh --tool codex
811+
```
812+
813+
Then reference the custom agent by name in Codex:
814+
```
815+
Use the Frontend Developer agent to review this component.
816+
```
817+
818+
See [integrations/codex/README.md](integrations/codex/README.md) for details.
819+
</details>
820+
799821
---
800822

801823
### Regenerating After Changes
@@ -805,6 +827,7 @@ When you add new agents or edit existing ones, regenerate all integration files:
805827
```bash
806828
./scripts/convert.sh # regenerate all (serial)
807829
./scripts/convert.sh --parallel # regenerate all in parallel (faster)
830+
./scripts/convert.sh --tool codex # regenerate just one tool
808831
./scripts/convert.sh --tool cursor # regenerate just one tool
809832
```
810833

@@ -814,7 +837,7 @@ When you add new agents or edit existing ones, regenerate all integration files:
814837

815838
- [ ] Interactive agent selector web tool
816839
- [x] Multi-agent workflow examples -- see [examples/](examples/)
817-
- [x] Multi-tool integration scripts (Claude Code, GitHub Copilot, Antigravity, Gemini CLI, OpenCode, OpenClaw, Cursor, Aider, Windsurf, Qwen Code, Kimi Code)
840+
- [x] Multi-tool integration scripts (Claude Code, GitHub Copilot, Antigravity, Gemini CLI, OpenCode, OpenClaw, Cursor, Aider, Windsurf, Qwen Code, Kimi Code, Codex)
818841
- [ ] Video tutorials on agent design
819842
- [ ] Community agent marketplace
820843
- [ ] Agent "personality quiz" for project matching

integrations/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ supported agentic coding tools.
1515
- **[Aider](#aider)**`CONVENTIONS.md` in `aider/`
1616
- **[Windsurf](#windsurf)**`.windsurfrules` in `windsurf/`
1717
- **[Kimi Code](#kimi-code)** — YAML agent specs in `kimi/`
18+
- **[Codex](#codex)**`.toml` custom agents in `codex/`
1819

1920
## Quick Install
2021

@@ -27,6 +28,7 @@ supported agentic coding tools.
2728
./scripts/install.sh --tool copilot
2829
./scripts/install.sh --tool openclaw
2930
./scripts/install.sh --tool claude-code
31+
./scripts/install.sh --tool codex
3032

3133
# Gemini CLI needs generated integration files on a fresh clone
3234
./scripts/convert.sh --tool gemini-cli
@@ -176,6 +178,18 @@ See [windsurf/README.md](windsurf/README.md) for details.
176178

177179
---
178180

181+
## Qwen Code
182+
183+
Each agent becomes a project-scoped `.md` SubAgent file in `.qwen/agents/`.
184+
185+
```bash
186+
cd /your/project && /path/to/agency-agents/scripts/install.sh --tool qwen
187+
```
188+
189+
See [../README.md#tool-specific-instructions](../README.md#tool-specific-instructions) for usage details.
190+
191+
---
192+
179193
## Kimi Code
180194

181195
Each agent is converted to a Kimi Code CLI agent specification (YAML format with
@@ -206,3 +220,20 @@ kimi --agent-file ~/.config/kimi/agents/frontend-developer/agent.yaml \
206220
```
207221

208222
See [kimi/README.md](kimi/README.md) for details.
223+
224+
---
225+
226+
## Codex
227+
228+
Each agent is converted into a standalone Codex custom agent TOML file and
229+
installed to `~/.codex/agents/`.
230+
231+
Because Codex uses generated TOML files rather than the source Markdown
232+
directly, run the converter before installing from a fresh clone:
233+
234+
```bash
235+
./scripts/convert.sh --tool codex
236+
./scripts/install.sh --tool codex
237+
```
238+
239+
See [codex/README.md](codex/README.md) for details.

integrations/codex/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Codex Integration
2+
3+
Converts all Agency agents into Codex custom agent TOML files. Each source
4+
agent becomes one standalone `.toml` file containing the minimal Codex-required
5+
fields: `name`, `description`, and `developer_instructions`.
6+
7+
## Installation
8+
9+
### Prerequisites
10+
11+
- [Codex](https://developers.openai.com/codex/overview) installed
12+
13+
### Convert And Install
14+
15+
```bash
16+
# Generate integration files (required on fresh clone)
17+
./scripts/convert.sh --tool codex
18+
19+
# Install agents
20+
./scripts/install.sh --tool codex
21+
```
22+
23+
This copies generated agent files to `~/.codex/agents/`.
24+
25+
## Generated Format
26+
27+
Each generated file lives in:
28+
29+
```text
30+
integrations/codex/agents/<slug>.toml
31+
```
32+
33+
The mapping is intentionally minimal:
34+
35+
- `name` is copied from the source frontmatter unchanged
36+
- `description` is copied from the source frontmatter unchanged
37+
- `developer_instructions` contains the full Markdown body unchanged
38+
39+
Source-only metadata such as `color`, `emoji`, `vibe`, and other unsupported
40+
frontmatter fields are omitted.
41+
42+
## Usage
43+
44+
After installation, reference the custom agent by name in Codex:
45+
46+
```text
47+
Use the Frontend Developer agent to review this component.
48+
```
49+
50+
Codex uses the `name` field inside the TOML file as the source of truth, so the
51+
generated filename slug is only for filesystem safety.
52+
53+
## Regenerate
54+
55+
After modifying source agents:
56+
57+
```bash
58+
./scripts/convert.sh --tool codex
59+
./scripts/install.sh --tool codex
60+
```
61+
62+
## Troubleshooting
63+
64+
### Codex integration not found
65+
66+
Generate the Codex artifacts before installing:
67+
68+
```bash
69+
./scripts/convert.sh --tool codex
70+
```
71+
72+
### Codex not detected
73+
74+
Make sure `codex` is in your PATH, or that `~/.codex/` already exists:
75+
76+
```bash
77+
which codex
78+
codex --help
79+
```

scripts/convert.sh

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# openclaw — OpenClaw SOUL.md files (openclaw_workspace/<agent>/SOUL.md)
2020
# qwen — Qwen Code SubAgent files (~/.qwen/agents/*.md)
2121
# kimi — Kimi Code CLI agent files (~/.config/kimi/agents/)
22+
# codex — Codex custom agent TOML files (~/.codex/agents/*.toml)
2223
# all — All tools (default)
2324
#
2425
# Output is written to integrations/<tool>/ relative to the repo root.
@@ -104,6 +105,21 @@ slugify() {
104105
echo "$1" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//'
105106
}
106107

108+
# Escape a value for a TOML basic string, including control characters that
109+
# cannot appear raw in TOML source.
110+
toml_escape_string() {
111+
printf '%s' "$1" | perl -0pe '
112+
s/\\/\\\\/g;
113+
s/"/\\"/g;
114+
s/\n/\\n/g;
115+
s/\r/\\r/g;
116+
s/\t/\\t/g;
117+
s/\f/\\f/g;
118+
s/\x08/\\b/g;
119+
s/([\x00-\x07\x0B\x0E-\x1F\x7F])/sprintf("\\u%04X", ord($1))/ge;
120+
'
121+
}
122+
107123
# --- Per-tool converters ---
108124

109125
convert_antigravity() {
@@ -132,6 +148,28 @@ ${body}
132148
HEREDOC
133149
}
134150

151+
convert_codex() {
152+
local file="$1"
153+
local name description slug outfile body
154+
155+
name="$(get_field "name" "$file")"
156+
description="$(get_field "description" "$file")"
157+
slug="$(slugify "$name")"
158+
body="$(get_body "$file")"
159+
160+
outfile="$OUT_DIR/codex/agents/${slug}.toml"
161+
mkdir -p "$(dirname "$outfile")"
162+
163+
# Codex custom agent format: one TOML file per agent with minimal required
164+
# fields only. Use a TOML basic string so control characters in the source
165+
# body are encoded safely instead of producing invalid TOML.
166+
cat > "$outfile" <<HEREDOC
167+
name = "$(toml_escape_string "$name")"
168+
description = "$(toml_escape_string "$description")"
169+
developer_instructions = "$(toml_escape_string "$body")"
170+
HEREDOC
171+
}
172+
135173
convert_gemini_cli() {
136174
local file="$1"
137175
local name description slug outdir outfile body
@@ -499,6 +537,7 @@ run_conversions() {
499537

500538
case "$tool" in
501539
antigravity) convert_antigravity "$file" ;;
540+
codex) convert_codex "$file" ;;
502541
gemini-cli) convert_gemini_cli "$file" ;;
503542
opencode) convert_opencode "$file" ;;
504543
cursor) convert_cursor "$file" ;;
@@ -535,7 +574,7 @@ main() {
535574
esac
536575
done
537576

538-
local valid_tools=("antigravity" "gemini-cli" "opencode" "cursor" "aider" "windsurf" "openclaw" "qwen" "kimi" "all")
577+
local valid_tools=("antigravity" "gemini-cli" "opencode" "cursor" "aider" "windsurf" "openclaw" "qwen" "kimi" "codex" "all")
539578
local valid=false
540579
for t in "${valid_tools[@]}"; do [[ "$t" == "$tool" ]] && valid=true && break; done
541580
if ! $valid; then
@@ -554,7 +593,7 @@ main() {
554593

555594
local tools_to_run=()
556595
if [[ "$tool" == "all" ]]; then
557-
tools_to_run=("antigravity" "gemini-cli" "opencode" "cursor" "aider" "windsurf" "openclaw" "qwen" "kimi")
596+
tools_to_run=("antigravity" "gemini-cli" "opencode" "cursor" "aider" "windsurf" "openclaw" "qwen" "kimi" "codex")
558597
else
559598
tools_to_run=("$tool")
560599
fi
@@ -565,7 +604,7 @@ main() {
565604

566605
if $use_parallel && [[ "$tool" == "all" ]]; then
567606
# Tools that write to separate dirs can run in parallel; buffer output so each tool's output stays together
568-
local parallel_tools=(antigravity gemini-cli opencode cursor openclaw qwen)
607+
local parallel_tools=(antigravity gemini-cli opencode cursor openclaw qwen codex)
569608
local parallel_out_dir
570609
parallel_out_dir="$(mktemp -d)"
571610
info "Converting: ${#parallel_tools[@]}/${n_tools} tools in parallel (output buffered per tool)..."
@@ -577,7 +616,7 @@ main() {
577616
[[ -f "$parallel_out_dir/$t" ]] && cat "$parallel_out_dir/$t"
578617
done
579618
rm -rf "$parallel_out_dir"
580-
local idx=7
619+
local idx=8
581620
for t in aider windsurf; do
582621
progress_bar "$idx" "$n_tools"
583622
printf "\n"

0 commit comments

Comments
 (0)