Repository navigation
fix(agent-core-v2): update import-from-cc-codex for current Claude Code and Codex layouts - #4331
Conversation
…de and Codex layouts Honor CLAUDE_CONFIG_DIR and CODEX_HOME, import project CLAUDE.md, CLAUDE.local.md, Claude rules, Codex AGENTS.override.md, and Claude project-local MCP servers, and map the current Claude Code and Codex MCP fields. Stop scanning .claude/AGENTS.md, .codex/AGENTS.md, and .codex/skills, which neither tool reads.
🦋 Changeset detectedLatest commit: 1e9d234 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f7916d1d2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03f4b37192
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…cc-codex The skill renderer substitutes argument and KIMI placeholders anywhere in a skill body, so the migration guidance reached the model with the session ID and a builtin path in place of the Kimi placeholder names, and invocation arguments were spliced into the prose. Name the placeholders without their literal forms and pin the rendered body in a test.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e9d23461a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| - `startup_timeout_sec` (may be fractional) -> `startupTimeoutMs` | ||
| - `startup_timeout_ms` -> `startupTimeoutMs` | ||
| - `tool_timeout_sec` -> `toolTimeoutMs` |
There was a problem hiding this comment.
Convert Codex timeout seconds to milliseconds
When a Codex MCP entry specifies startup_timeout_sec or tool_timeout_sec, this mapping no longer tells the model to multiply the value by 1000 before writing Kimi's *TimeoutMs field. Codex defines both fields in seconds (upstream definition), so a normal value such as 10 becomes 10 ms rather than 10 seconds and will make many imported servers time out immediately. Restore the unit conversion and specify that startup_timeout_sec takes precedence when both startup fields exist.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
| current working directory. The project root is the nearest parent | ||
| directory containing `.git`; if no `.git` exists, use the current working | ||
| directory. |
There was a problem hiding this comment.
Honor Codex's configured project root
For users who set project_root_markers in Codex, fixing the source project root to the nearest .git scans the wrong instruction chain: a custom marker below the Git root causes unrelated ancestor instructions to be imported, while a marker above it causes active instructions to be missed. Codex derives this boundary from the effective marker configuration and even allows an empty list to disable parent traversal (discovery implementation); resolve the Codex source range with those settings instead of reusing Kimi's Git-root destination boundary.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
| - Read `disabledMcpServers` from that project's object before normalizing | ||
| candidates. Skip any Claude user-scope or local-scope candidate whose name | ||
| is listed there, and report it as "disabled in the source project; not | ||
| imported". This is a project-specific choice, so do not turn it into a | ||
| user-global `enabled: false` entry or silently re-enable the server. |
There was a problem hiding this comment.
Preserve disabled user MCP servers outside this project
When the current Claude project disables a user-scoped server, these instructions discard that global candidate entirely, so after migration it is also unavailable in every other Kimi project. Claude stores disabledMcpServers as a per-project preference while user-scoped servers remain available across projects (scope documentation, disable behavior); preserve the global entry and represent the current project's opt-out with a complete project-local enabled: false override instead.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
| - `type: sse` -> `transport: "sse"` | ||
| - `command`, `args`, `env`, `url`, `headers` -> same names | ||
| - `timeout` -> `toolTimeoutMs` | ||
| - `alwaysLoad: true` -> `deferred: false` |
There was a problem hiding this comment.
Map explicit Claude deferral to Kimi
For a Claude server with alwaysLoad: false, this one-sided mapping omits Kimi's deferred field, whose effective default is false, and therefore changes explicitly deferred tools into eagerly exposed tools. Claude documents that alwaysLoad: false keeps every tool behind tool search, including tools the server author marked for upfront loading (Claude MCP documentation); map it to deferred: true while retaining the existing true mapping.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
| Claude Code expands `@path` import lines (`@./docs/style.md`, `@~/notes.md`) | ||
| inside `CLAUDE.md` files, ignoring `@` inside fenced code blocks, inline code | ||
| spans, and HTML comments. Kimi does not expand imports at all. For each | ||
| imported block that contains such lines, inline the referenced file's content | ||
| in place of the line when the file exists, is a text file, and lives inside |
There was a problem hiding this comment.
Parse Claude imports as tokens rather than whole lines
For valid Claude instructions such as See @README for context or @Design\ Docs/rules.md, treating imports as standalone lines either misses the import or replaces surrounding instruction text and resolves the wrong truncated path. Claude permits imports anywhere outside code spans and fences and uses backslash-escaped spaces rather than quoted paths (Claude memory documentation); parse and replace the import token itself instead of replacing an assumed whole line.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
| Kimi's stdio servers inherit the parent process environment and then apply | ||
| `env` on top, so pass-through declarations (Codex `env_vars`, Claude | ||
| `"KEY": "${KEY}"`) need no Kimi equivalent; drop them and note that the | ||
| variable is inherited. |
There was a problem hiding this comment.
Verify pass-through variables before dropping them
When an env_vars or ${KEY} pass-through names a variable supplied only by Claude settings or by the process that launched Codex, the Kimi process running this importer need not contain it; dropping the declaration and claiming inheritance then produces an MCP server with a missing credential or setting. Check the current Kimi environment before dropping each pass-through and block or warn on absent variables rather than reporting that they are inherited.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
| - `url` -> `url` | ||
| - `bearer_token_env_var` -> `bearerTokenEnvVar` | ||
| - `http_headers` -> `headers` | ||
| - `auth = "oauth"` -> `auth: "oauth"` (also Codex's default; omit when absent) |
There was a problem hiding this comment.
Preserve Codex's default OAuth mode
For a remote Codex server that omits auth, especially one with additional http_headers, this instruction removes Codex's default OAuth mode instead of translating it. Codex defaults McpServerAuth to OAuth (upstream definition), while Kimi treats a header-bearing entry without auth: "oauth" as non-OAuth in mcpManagementService.ts and connection-manager.ts, so sign-in is not offered and authentication failures are not classified correctly. Emit auth: "oauth" for the absent Codex value as well as the explicit one.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
| - Read selected `config.toml` files only if MCP was selected. | ||
| - Look for `[mcp_servers.<name>]` tables. |
There was a problem hiding this comment.
Merge Codex MCP layers before normalizing servers
For a newly discovered nested .codex/config.toml that only overrides part of a user server, reading each [mcp_servers.<name>] table independently does not reproduce Codex's effective configuration. Codex recursively merges project configuration over lower layers (loader documentation), whereas Kimi replaces an entire same-name server entry; for example, a project layer containing only enabled = false is invalid by itself and leaves the imported global server running. Materialize each complete effective server after applying the Codex layer stack before generating the scoped Kimi entries.
AGENTS.md reference: AGENTS.md:L112-L112
Useful? React with 👍 / 👎.
| - any filename listed under `project_doc_fallback_filenames` in a Codex | ||
| `config.toml`, only when neither file above exists in `<dir>` and the | ||
| name is not already covered by another source in this list |
There was a problem hiding this comment.
Reject fallback paths that Codex ignores
When project_doc_fallback_filenames contains a path-like value such as ../CLAUDE.md, these instructions can traverse outside <dir> and import it even though Codex rejects that value and never treats the file as instructions. Codex filters empty names, ./.., NUL, path separators, and Windows-invalid separators before probing (upstream validation); apply the same validation before scanning fallback filenames.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
| - Claude instructions, per directory `<dir>`: | ||
| - `<dir>/CLAUDE.md` | ||
| - `<dir>/.claude/CLAUDE.md` | ||
| - `<dir>/CLAUDE.local.md` (private, usually gitignored) | ||
| - `<dir>/.claude/rules/*.md` (recursive) |
There was a problem hiding this comment.
Honor Claude instruction exclusion settings
For users whose claudeMdExcludes matches one of the newly scanned .claude/rules/*.md or CLAUDE.md files, this unconditional source list imports inactive content and makes it active in Kimi. Claude applies exclusion globs from its settings layers to absolute instruction paths, including symlink paths and targets (Claude memory documentation); resolve those settings during discovery and omit or clearly report excluded files rather than importing them.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
Requirement or Bug
内置 skill
/import-from-cc-codex的扫描路径和字段映射已落后于当前 Claude Code(v2.1.300)与 Codex 的配置布局,导入结果不完整或映射错误。Bug Reproduction Steps
CLAUDE_CONFIG_DIR或CODEX_HOME指向非默认目录后运行/import-from-cc-codex:skill 只扫~/.claude/~/.codex,报告"没有找到"。CLAUDE.md(Kimi 不读该文件):skill 明确跳过它,指令无法导入。~/.claude.json里的条目使用 Claude 真实字段type: "http"+timeout:skill 按不存在于 Claude 的字段名(startupTimeoutMs、bearerTokenEnvVar等)去读,timeout被丢弃。AGENTS.override.md、Claude rules 或嵌套项目指令后运行导入:旧指引不扫描这些来源;仍有效的项目技能目录也需要继续支持。Root Cause
skill 文本自 #582 之后没有随两个上游更新:用户级 skills 已支持
.agents/skills,同时仍兼容原用户技能根和项目.codex/skills;新增AGENTS.override.md、MCP 字段大量变化(startup_timeout_ms、auth、environment_id等,旧的experimental_environment已不存在);Claude Code 的rules/、CLAUDE.local.md、.claude.json里projects[...]的本地 MCP 作用域、${VAR}占位符都未覆盖,而.claude/AGENTS.md、项目.codex/AGENTS.md和.codex/CLAUDE.md不应作为独立入口扫描;有效来源的软链接和@path引用仍需展开。这是根本修复:对照两边当前源码重写来源清单与字段映射,并逐条回到源码核对。
Code Changes
只改一个内置 skill 的 markdown(纯 prompt 文本,无 TypeScript 逻辑变化)和一个 changeset。
事实来源:Claude Code v2.1.300 解包源码(记忆文件加载、skills 目录扫描、MCP zod schema 与作用域解析);Codex 仓库
codex-rs/config/src/mcp_types.rs、codex-home/src/instructions、exec-server/src/discoverV2/capability_locations.rs、core/src/agents_md.rs及其自带的external-agent-migration;Kimi 侧mcpCore/config-schema.ts、skill/catalog/skillRoots.ts、agent/profile/context.ts、skill/catalog/parser.ts。Behavior Changes and Affected Users
本 PR 只改 prompt 文本。受影响人群:在 TUI、desktop、web 中手动运行
/import-from-cc-codex的用户(skill 带disable-model-invocation,模型不会自行触发)。写入前仍要求用户预览并确认,MCP 仍不直接写文件、仍通过/mcp-config手动跟进。~/.claude、~/.codexCLAUDE_CONFIG_DIR、CODEX_HOME,未设置时不变~/.claude/AGENTS.md、<root>/.claude/AGENTS.mdCLAUDE.md的软链接或@path仍会展开.claude/AGENTS.md的用户CLAUDE.md后再导入.codex/AGENTS.md、.codex/CLAUDE.md,以及<codex home>/CLAUDE.mdCLAUDE.md、CLAUDE.local.md~/.claude/rules、.claude/rulespaths则导入正文;含paths则全部跳过并报告源路径、glob 和作用域不兼容原因paths的规则手动适配<name>.md.md放进 skills 目录的用户.kimi-code/skills(Kimi 支持扁平 skill)ws/sdk/claudeai-proxy条目丢弃并报告.claude.jsonprojects[...])<cwd>/.kimi-code/mcp.json的预览;当前项目禁用名命中的用户/本地候选跳过并说明experimental_environmentenvironment_id≠local、auth=chatgpt/ema_auth条目丢弃并报告<root>/.kimi-code/AGENTS.md<dir>/.kimi-code/AGENTS.md受影响模块与测试覆盖:
paths规则跳过,恢复的项目技能及支持文件完整复制,禁用 MCP 未进入待应用 JSON,未直接写任何mcp.json。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.