mirror of
https://github.com/openai/codex.git
synced 2026-05-01 03:42:05 +03:00
## Why This PR expands the migration path so Codex can detect and import MCP server config, hooks, commands, and subagents configs in a Codex-native shape. ## What changed - Added a `codex-external-agent-migration` crate that owns conversion logic for external-agent MCP servers, hooks, commands, and subagents. - Extended the app-server external-agent config detection/import API with migration item types for MCP server config, hooks, commands, and subagents. ## Migration strategy The migration is intentionally conservative: Codex only imports external-agent config that can be represented safely in Codex today. Unsupported or ambiguous config is skipped instead of being partially translated into behavior that may not match the source system. - **MCP servers**: import supported stdio and HTTP MCP server definitions into `mcp_servers`. Disabled servers and servers filtered out by source `enabledMcpjsonServers` / `disabledMcpjsonServers` are skipped. Project-scoped MCP entries from `.claude.json` are included when they match the repo path. - **Hooks**: import only supported command hooks into `.codex/hooks.json`. Unsupported hook features such as conditional groups, async handlers, prompt/http hooks, or unknown fields are skipped. Referenced hook scripts are copied into `.codex/hooks/`, preserving any existing target scripts. - **Commands**: import supported external commands as Codex skills under `.agents/skills/source-command-*`. Commands that rely on source runtime expansion such as `$ARGUMENTS`, `$1`, `@file` references, shell interpolation, or colliding generated names are skipped. - **Subagents**: import valid subagent Markdown files into `.codex/agents/*.toml` when they have the minimum Codex agent fields. Source model names are not migrated, so imported agents keep the user’s Codex default model; compatible reasoning effort and sandbox mode are migrated when present. - **Skills and project guidance**: copy missing skill directories into `.agents/skills` and migrate `CLAUDE.md` guidance into `AGENTS.md`, rewriting source-agent terminology to Codex terminology where appropriate. - **Detection details**: detected migration items include lightweight details for UI preview, such as MCP server names, hook event names, generated command skill names, and subagent names. Import still recomputes from disk instead of trusting details as the source of truth. - Adds focused coverage for the new migration behavior and app-server import flow. ## Verification - `cargo test -p codex-external-agent-migration` - `cargo test -p codex-hooks` - `cargo test -p codex-app-server external_agent_config` - `just bazel-lock-check`
194 lines
3.9 KiB
JSON
Generated
194 lines
3.9 KiB
JSON
Generated
{
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
"definitions": {
|
|
"CommandMigration": {
|
|
"properties": {
|
|
"name": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"name"
|
|
],
|
|
"type": "object"
|
|
},
|
|
"ExternalAgentConfigMigrationItem": {
|
|
"properties": {
|
|
"cwd": {
|
|
"description": "Null or empty means home-scoped migration; non-empty means repo-scoped migration.",
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
]
|
|
},
|
|
"description": {
|
|
"type": "string"
|
|
},
|
|
"details": {
|
|
"anyOf": [
|
|
{
|
|
"$ref": "#/definitions/MigrationDetails"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
]
|
|
},
|
|
"itemType": {
|
|
"$ref": "#/definitions/ExternalAgentConfigMigrationItemType"
|
|
}
|
|
},
|
|
"required": [
|
|
"description",
|
|
"itemType"
|
|
],
|
|
"type": "object"
|
|
},
|
|
"ExternalAgentConfigMigrationItemType": {
|
|
"enum": [
|
|
"AGENTS_MD",
|
|
"CONFIG",
|
|
"SKILLS",
|
|
"PLUGINS",
|
|
"MCP_SERVER_CONFIG",
|
|
"SUBAGENTS",
|
|
"HOOKS",
|
|
"COMMANDS",
|
|
"SESSIONS"
|
|
],
|
|
"type": "string"
|
|
},
|
|
"HookMigration": {
|
|
"properties": {
|
|
"name": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"name"
|
|
],
|
|
"type": "object"
|
|
},
|
|
"McpServerMigration": {
|
|
"properties": {
|
|
"name": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"name"
|
|
],
|
|
"type": "object"
|
|
},
|
|
"MigrationDetails": {
|
|
"properties": {
|
|
"commands": {
|
|
"default": [],
|
|
"items": {
|
|
"$ref": "#/definitions/CommandMigration"
|
|
},
|
|
"type": "array"
|
|
},
|
|
"hooks": {
|
|
"default": [],
|
|
"items": {
|
|
"$ref": "#/definitions/HookMigration"
|
|
},
|
|
"type": "array"
|
|
},
|
|
"mcpServers": {
|
|
"default": [],
|
|
"items": {
|
|
"$ref": "#/definitions/McpServerMigration"
|
|
},
|
|
"type": "array"
|
|
},
|
|
"plugins": {
|
|
"default": [],
|
|
"items": {
|
|
"$ref": "#/definitions/PluginsMigration"
|
|
},
|
|
"type": "array"
|
|
},
|
|
"sessions": {
|
|
"default": [],
|
|
"items": {
|
|
"$ref": "#/definitions/SessionMigration"
|
|
},
|
|
"type": "array"
|
|
},
|
|
"subagents": {
|
|
"default": [],
|
|
"items": {
|
|
"$ref": "#/definitions/SubagentMigration"
|
|
},
|
|
"type": "array"
|
|
}
|
|
},
|
|
"type": "object"
|
|
},
|
|
"PluginsMigration": {
|
|
"properties": {
|
|
"marketplaceName": {
|
|
"type": "string"
|
|
},
|
|
"pluginNames": {
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"type": "array"
|
|
}
|
|
},
|
|
"required": [
|
|
"marketplaceName",
|
|
"pluginNames"
|
|
],
|
|
"type": "object"
|
|
},
|
|
"SessionMigration": {
|
|
"properties": {
|
|
"cwd": {
|
|
"type": "string"
|
|
},
|
|
"path": {
|
|
"type": "string"
|
|
},
|
|
"title": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
]
|
|
}
|
|
},
|
|
"required": [
|
|
"cwd",
|
|
"path"
|
|
],
|
|
"type": "object"
|
|
},
|
|
"SubagentMigration": {
|
|
"properties": {
|
|
"name": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"name"
|
|
],
|
|
"type": "object"
|
|
}
|
|
},
|
|
"properties": {
|
|
"migrationItems": {
|
|
"items": {
|
|
"$ref": "#/definitions/ExternalAgentConfigMigrationItem"
|
|
},
|
|
"type": "array"
|
|
}
|
|
},
|
|
"required": [
|
|
"migrationItems"
|
|
],
|
|
"title": "ExternalAgentConfigImportParams",
|
|
"type": "object"
|
|
} |