Skip to content

Commit 47fa122

Browse files
committed
docs(codex): update archcore context for cwd bugs
1 parent 3572ae9 commit 47fa122

6 files changed

Lines changed: 61 additions & 29 deletions

File tree

.archcore/plugin/codex-local-plugin-testing.guide.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ tags:
1818
- Local marketplaces: Codex reads repo marketplaces from `$REPO_ROOT/.agents/plugins/marketplace.json` and personal marketplaces from `~/.agents/plugins/marketplace.json`.
1919
- Installed plugins are loaded from the Codex plugin cache under `~/.codex/plugins/cache/<marketplace>/<plugin>/<version>/`; do not edit the cache as the source of truth.
2020
- When testing plugin-managed MCP, avoid relying only on this repo's project config. A project `.codex/config.toml` may register an `archcore` MCP server directly and hide plugin packaging defects.
21+
- For end-to-end MCP validation, run Codex from a directory **outside the plugin source repo** (e.g., `cd $(mktemp -d)`). The plugin source dir accidentally contains `bin/archcore` relative to CWD, which can mask `cwd: "."` mistakes in `.codex.mcp.json`. See `plugin/codex-path-resolution.adr.md`.
2122

2223
## Steps
2324

@@ -49,8 +50,8 @@ tags:
4950
Confirm these invariants:
5051
- `.codex-plugin/plugin.json` points to `"./skills/"`, `"./hooks/codex.hooks.json"`, and `"./.codex.mcp.json"`.
5152
- `.agents/plugins/marketplace.json` has one `archcore` entry, `source.source = "local"`, `source.path = "./"`, `policy.installation`, `policy.authentication`, and `category`.
52-
- `.codex.mcp.json` points at the plugin-relative launcher `./bin/archcore` with `args: ["mcp"]`.
53-
- `hooks/codex.hooks.json` uses plugin-relative `./bin/...` commands, not host-specific root environment variables.
53+
- `.codex.mcp.json` points at the plugin-relative launcher `./bin/archcore` with `args: ["mcp"]` AND `cwd: "."`. The `cwd: "."` is required: Codex's `normalize_plugin_mcp_server_value` rebases it to the plugin install root so the relative command resolves correctly. Without it, Codex spawns from the user's project CWD and the MCP fails with ENOENT.
54+
- `hooks/codex.hooks.json` uses `${PLUGIN_ROOT}/bin/...` commands (Codex's canonical, host-neutral env var). Do NOT use `${CLAUDE_PLUGIN_ROOT}` (Codex provides it only as a backward-compat alias for old Claude plugins) or `./bin/...` (would resolve against the user's project CWD).
5455

5556
4. Register this checkout as a local repo marketplace.
5657

@@ -115,7 +116,7 @@ tags:
115116
codex mcp list --json | jq '.[] | select(.name == "archcore")'
116117
```
117118

118-
A plugin-managed Archcore MCP entry should be enabled. If the command shown is `./bin/archcore`, Codex is reading the plugin bundle. If the command is plain `archcore`, a project or user-level MCP config may be contributing the server; inspect configs before treating this as proof of plugin-managed MCP.
119+
A plugin-managed Archcore MCP entry should be enabled. Critical end-to-end check: from the same neutral directory, start a fresh Codex session and call any `mcp__archcore__*` tool. If the MCP starts and answers — `cwd: "."` rebase is working. If the MCP fails with `MCP startup failed: No such file or directory (os error 2)`, the `cwd` field is missing or wrong in `.codex.mcp.json`. Inspect the entry with `codex mcp get archcore`: the `cwd` column should show an absolute path inside `~/.codex/plugins/cache/<marketplace>/archcore/<version>/`, not a dash.
119120

120121
9. Verify slash commands and skills from a new Codex thread.
121122

@@ -138,9 +139,9 @@ tags:
138139
- `/plugins` shows `Archcore` under the expected marketplace tab and the details screen shows `Installed`.
139140
- `~/.codex/config.toml` contains `[plugins."archcore@<marketplace>"]` with `enabled = true`.
140141
- `~/.codex/plugins/cache/<marketplace>/archcore/<version>/` contains the plugin bundle.
141-
- `codex mcp list --json` includes an enabled `archcore` server. In a neutral directory, prefer seeing the plugin-relative `./bin/archcore` command when validating plugin-managed MCP.
142+
- `codex mcp list --json` includes an enabled `archcore` server. From a directory **outside** the plugin source repo, calling an `mcp__archcore__*` tool succeeds (proves the `cwd: "."` rebase works); `codex mcp get archcore` shows a non-dash `cwd` pointing into the plugin cache.
142143
- A new Codex thread can discover Archcore slash commands via `/archcore:` and Archcore skills via `@`, without manual `codex mcp add`.
143-
- Optional hook verification: with Codex hook runtime support enabled, `hooks/codex.hooks.json` should load `SessionStart`, `PreToolUse`, and `PostToolUse` guardrails. Keep this as a runtime smoke test because hook execution depends on Codex's `codex_hooks` feature support.
144+
- Optional hook verification: with `codex features enable plugin_hooks`, `hooks/codex.hooks.json` should load `SessionStart`, `PreToolUse`, and `PostToolUse` guardrails. Keep this as a runtime smoke test because the `plugin_hooks` feature is `under development, false` by default in Codex 0.130.0.
144145

145146
## Common Issues
146147

@@ -164,6 +165,10 @@ Open the plugin details and select `Install plugin`. Pressing `Space` toggles en
164165

165166
Run `codex mcp list --json` from a neutral temporary directory. Project-level `.codex/config.toml` can register `archcore` directly and shadow a missing plugin-managed MCP entry. For plugin-managed MCP validation, inspect the command and confirm it comes from the installed bundle, not from a manual global server config.
166167

168+
### MCP tool calls fail with `MCP startup failed: No such file or directory (os error 2)`
169+
170+
Symptom: `codex mcp list` shows `archcore` enabled, but any `mcp__archcore__*` tool call from a project directory returns ENOENT. Cause: `.codex.mcp.json` has `command: "./bin/archcore"` but is missing `cwd: "."`. Codex spawns the MCP from the project's CWD instead of the plugin install dir, and `./bin/archcore` doesn't exist there. Fix: add `"cwd": "."` to the server entry. Verify by `codex mcp get archcore` — the `cwd` column should show a real absolute path under `~/.codex/plugins/cache/...`, not a dash. See `plugin/codex-path-resolution.adr.md`.
171+
167172
### Skill discovery works only after restart
168173

169174
Expected. The official Codex flow requires using a new thread after plugin installation. Close the existing session and start a new one before testing `@` skill discovery.
@@ -174,7 +179,7 @@ Codex installs a copy into `~/.codex/plugins/cache/...`. Restart Codex after sou
174179

175180
### Hook guardrails do not fire
176181

177-
The plugin can package `hooks/codex.hooks.json`, but live hook execution depends on Codex hook runtime support. Enable `[features] codex_hooks = true` only in environments where the Codex version supports that feature, then retest with a fresh session.
182+
The plugin can package `hooks/codex.hooks.json`, but live hook execution depends on Codex's `plugin_hooks` feature flag. Run `codex features enable plugin_hooks` and retest with a fresh session. If the feature is unavailable in your Codex version (it's `under development, false` by default in Codex 0.130.0), upgrade Codex or treat plugin hooks as best-effort until it stabilizes.
178183

179184
### `codex debug prompt-input` fails with session permission errors
180185

@@ -188,5 +193,7 @@ The plugin MCP command uses the bundled launcher. In online development, the lau
188193

189194
- OpenAI Codex Plugins overview: https://developers.openai.com/codex/plugins
190195
- OpenAI Build plugins guide: https://developers.openai.com/codex/plugins/build
196+
- Codex MCP and Hooks Path Resolution ADR: `.archcore/plugin/codex-path-resolution.adr.md` (canonical reference for `cwd` rebase vs `${PLUGIN_ROOT}` substitution)
197+
- Upstream issue tracking full `${PLUGIN_ROOT}` MCP parity: https://github.com/openai/codex/issues/19582
191198
- Related Archcore guide: `.archcore/plugin/plugin-testing.guide.md`
192199
- Related Archcore spec: `.archcore/plugin/multi-host-compatibility-layer.spec.md`

0 commit comments

Comments
 (0)