agent-converter
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAgent Converter
Agent 转换器
Objective
目标
Convert agent definitions between two formats:
- Markdown format (with YAML frontmatter) — Rich format with explicit tool restrictions
.md - TOML format () — Simple format for Codex agents with sandbox modes
.toml
在两种格式之间转换Agent定义:
- Markdown格式(,带YAML前置元数据)—— 支持明确工具限制的富格式
.md - TOML格式()—— 适用于带沙箱模式的Codex风格Agent的简易格式
.toml
Inputs
输入项
- Source file: Path to an agent file (or directory of agents)
.md - Output format: (default) or
tomlmd - Output directory: Where to write converted files (default: same as source)
- 源文件:Agent的文件路径(或Agent所在目录)
.md - 输出格式:(默认)或
tomlmd - 输出目录:转换后文件的写入路径(默认:与源文件同目录)
Commands
命令
Convert single agent MD → TOML
转换单个Agent(MD → TOML)
bash
python3 skills/agent-converter/scripts/convert_agent.py <input.md> [--output <dir>]bash
python3 skills/agent-converter/scripts/convert_agent.py <input.md> [--output <dir>]Convert all agents in directory
批量转换目录下所有Agent
bash
python3 skills/agent-converter/scripts/convert_agent.py --batch <input_dir> [--output <dir>]bash
python3 skills/agent-converter/scripts/convert_agent.py --batch <input_dir> [--output <dir>]Convert TOML → MD
转换TOML → MD
bash
python3 skills/agent-converter/scripts/convert_agent.py <input.toml> --to-md [--output <dir>]bash
python3 skills/agent-converter/scripts/convert_agent.py <input.toml> --to-md [--output <dir>]Format Mapping
格式映射
| MD Frontmatter | TOML Field |
|---|---|
| (derived from filename) |
| Included in |
| Mapped to |
| Markdown body | |
| MD前置元数据 | TOML字段 |
|---|---|
| (从文件名派生) |
| 纳入 |
| 映射到 |
| Markdown正文 | |
Tool → Sandbox Mode Mapping
工具→沙箱模式映射
| Tools | Sandbox Mode |
|---|---|
| |
| Any Write/Edit tools | |
| No tools specified | |
| 工具 | 沙箱模式 |
|---|---|
仅包含 | |
| 包含任何写入/编辑工具 | |
| 未指定工具 | |
Sandbox Mode → Tool Mapping (reverse)
沙箱模式→工具映射(反向)
| Sandbox Mode | Tools |
|---|---|
| |
| |
| 沙箱模式 | 工具 |
|---|---|
| |
| |
Example Conversion
转换示例
Input: explorer.md
explorer.md输入:explorer.md
explorer.mdmarkdown
---
name: explorer
description: >
Read-only codebase explorer.
tools:
- Read
- Grep
- Glob
---markdown
---
name: explorer
description: >
只读代码库探索器。
tools:
- Read
- Grep
- Glob
---Explorer — Read-Only Codebase Navigator
Explorer — 只读代码库导航器
You are a read-only explorer agent...
undefined你是一个只读的探索器Agent...
undefinedOutput: explorer.toml
explorer.toml输出:explorer.toml
explorer.tomltoml
sandbox_mode = "read-only"
developer_instructions = """
Role: Read-only codebase explorer.
Tools: Read, Grep, Glob
---toml
sandbox_mode = "read-only"
developer_instructions = """
角色:只读代码库探索器。
工具:Read, Grep, Glob
---Explorer — Read-Only Codebase Navigator
Explorer — 只读代码库导航器
You are a read-only explorer agent...
"""
undefined你是一个只读的探索器Agent...
"""
undefinedWorkflow
工作流程
- Parse source file (MD or TOML)
- Extract metadata and instructions
- Map format-specific fields
- Write output in target format
- Report conversion summary
- 解析源文件(MD或TOML)
- 提取元数据和说明内容
- 映射格式专属字段
- 以目标格式写入输出文件
- 生成转换汇总报告
Error Handling
错误处理
| Error | Resolution |
|---|---|
| Missing frontmatter | Treat as plain markdown, use defaults |
| Invalid TOML | Report parse error with line number |
| Unknown tools | Warn and include in output as-is |
| File exists | Prompt user or use |
| 错误类型 | 解决方法 |
|---|---|
| 缺少前置元数据 | 视为纯Markdown,使用默认配置 |
| 无效TOML | 报告包含行号的解析错误 |
| 未知工具 | 发出警告并原样保留在输出中 |
| 文件已存在 | 提示用户或使用 |
References
参考资料
- Format specification:
skills/agent-converter/references/format-spec.md - Example agents:
.agents/sub-agents/
- 格式规范:
skills/agent-converter/references/format-spec.md - 示例Agent:
.agents/sub-agents/