OpenAI Codex 與 Codex CLI 設定
請先依照 5 分鐘快速開始 安裝 WPF DevTools,再使用 generated Codex registration command。
一般 Codex setup 請使用 5-Minute Setup 的 installer path,不要使用 portable ZIP extraction。Portable ZIP checks 只適用於已審查本機 archive 或 offline validation。
Register
Installer 會寫入:
<InstallRoot>\<arch>\client-registration\codex.txt
請在 Codex CLI 可用的 shell 中執行該檔案列出的 command。它應指向:
<InstallRoot>\<arch>\current\bin\wpf-devtools-<arch>.exe
Verify
啟動 client 前,設定 reviewed target path 與 scene summary read gate:
$target = 'C:\Path\To\YourApp.exe'
$env:WPFDEVTOOLS_MCP_ALLOWED_TARGETS = $target
$env:WPFDEVTOOLS_INJECTION_ALLOWED_TARGETS = $target
$env:WPFDEVTOOLS_MCP_ALLOW_SENSITIVE_READS = 'true'
接著要求 Codex:
Use the WPF DevTools MCP server. Connect to the allowlisted WPF target and return get_ui_summary(depthMode: "semantic").
需要更深工具時的 gates
第一次 Codex session 先保持範圍小;後續只啟用下一個已核准 tool 需要的 gate:
WPFDEVTOOLS_MCP_ALLOW_SCREENSHOTS=true用於element_screenshot。WPFDEVTOOLS_MCP_ALLOW_VIEWMODEL_INSPECTION=true用於get_viewmodel、command metadata,以及 snapshot 或batch_mutate內的 ViewModel scopes。WPFDEVTOOLS_MCP_ALLOW_DESTRUCTIVE_TOOLS=true用於capture_state_snapshot、batch_mutate、interaction、event drain 與 restore workflows。- 對已確認的
apply_ui_blueprint與apply_ui_project_integrationwrites,請先設定WPFDEVTOOLS_MCP_ALLOW_DESTRUCTIVE_TOOLS=true、WPFDEVTOOLS_MCP_ALLOW_PROJECT_WRITES=true與 exactWPFDEVTOOLS_MCP_ALLOWED_PROJECT_ROOTSmatch,再啟動 fresh MCP server process。請先閱讀 UI Composer apply 與 project-integration workflow。
在 mutation 或有順序的 batch_mutate 前,先呼叫 capture_state_snapshot,再檢查 get_state_diff,並在 workflow 需要 rollback 時 restore。
Troubleshooting
- 以 generated
codex.txtcommand 作為真源。 - 切換 architecture 或 install root 後重新註冊。
- 若 target 以系統管理員/elevated 身分執行,請用 matching elevated shell 啟動 client,或在 policy 擋下 elevation 時 prefer SDK-hosted diagnostics。
- Wrapper 不應寫入 stdout,因為 server transport 是 STDIO。