{
  "canonical_name": "openai/codex",
  "compilation_id": "pack_a5cf1914e0b24d569db4a763fddeeb57",
  "created_at": "2026-05-13T10:35:20.668145+00:00",
  "created_by": "project-pack-compiler",
  "feedback": {
    "carrier_selection_notes": [
      "viable_asset_types=skill, recipe, host_instruction, eval, preflight",
      "recommended_asset_types=skill, recipe, host_instruction, eval, preflight"
    ],
    "evidence_delta": {
      "confirmed_claims": [
        "identity_anchor_present",
        "capability_and_host_targets_present",
        "install_path_declared_or_better"
      ],
      "missing_required_fields": [],
      "must_verify_forwarded": [
        "Run or inspect `npm i -g @openai/codex` in an isolated environment.",
        "Confirm the project exposes the claimed capability to at least one target host."
      ],
      "quickstart_execution_scope": "allowlisted_sandbox_smoke",
      "sandbox_command": "npm i -g @openai/codex",
      "sandbox_container_image": "node:22-slim",
      "sandbox_execution_backend": "docker",
      "sandbox_planner_decision": "deterministic_isolated_install",
      "sandbox_validation_id": "sbx_85dda9c946e943f28f9bbcf35e1b1fe0"
    },
    "feedback_event_type": "project_pack_compilation_feedback",
    "learning_candidate_reasons": [],
    "template_gaps": []
  },
  "identity": {
    "canonical_id": "project_a74197d521a2cca19f2473b20f4634b1",
    "canonical_name": "openai/codex",
    "homepage_url": null,
    "license": "unknown",
    "repo_url": "https://github.com/openai/codex",
    "slug": "codex",
    "source_packet_id": "phit_5b1ff2e81b0049aa9cdbd54c70f75c79",
    "source_validation_id": "dval_f21347d8e3f84f7f902de098e84d2a89"
  },
  "merchandising": {
    "best_for": "需要软件开发与交付能力，并使用 chatgpt的用户",
    "github_forks": 11886,
    "github_stars": 82254,
    "one_liner_en": "Lightweight coding agent that runs in your terminal",
    "one_liner_zh": "Lightweight coding agent that runs in your terminal",
    "primary_category": {
      "category_id": "software-development",
      "confidence": "high",
      "name_en": "Software Development",
      "name_zh": "软件开发与交付",
      "reason": "matched_keywords:code, coding, git"
    },
    "target_user": "使用 chatgpt 等宿主 AI 的用户",
    "title_en": "codex",
    "title_zh": "codex 能力包",
    "visible_tags": [
      {
        "label_en": "Browser Agents",
        "label_zh": "浏览器 Agent",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "product_domain-browser-agents",
        "type": "product_domain"
      },
      {
        "label_en": "Web Task Automation",
        "label_zh": "网页任务自动化",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "user_job-web-task-automation",
        "type": "user_job"
      },
      {
        "label_en": "Browser Automation",
        "label_zh": "浏览器自动化",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "core_capability-browser-automation",
        "type": "core_capability"
      },
      {
        "label_en": "Checkpoint Resume",
        "label_zh": "断点恢复流程",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "workflow_pattern-checkpoint-resume",
        "type": "workflow_pattern"
      },
      {
        "label_en": "Local-first",
        "label_zh": "本地优先",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "selection_signal-local-first",
        "type": "selection_signal"
      }
    ]
  },
  "packet_id": "phit_5b1ff2e81b0049aa9cdbd54c70f75c79",
  "page_model": {
    "artifacts": {
      "artifact_slug": "codex",
      "files": [
        "PROJECT_PACK.json",
        "QUICK_START.md",
        "PROMPT_PREVIEW.md",
        "HUMAN_MANUAL.md",
        "AI_CONTEXT_PACK.md",
        "BOUNDARY_RISK_CARD.md",
        "PITFALL_LOG.md",
        "REPO_INSPECTION.json",
        "REPO_INSPECTION.md",
        "CAPABILITY_CONTRACT.json",
        "EVIDENCE_INDEX.json",
        "CLAIM_GRAPH.json"
      ],
      "required_files": [
        "PROJECT_PACK.json",
        "QUICK_START.md",
        "PROMPT_PREVIEW.md",
        "HUMAN_MANUAL.md",
        "AI_CONTEXT_PACK.md",
        "BOUNDARY_RISK_CARD.md",
        "PITFALL_LOG.md",
        "REPO_INSPECTION.json"
      ]
    },
    "detail": {
      "capability_source": "Project Hit Packet + DownstreamValidationResult",
      "commands": [
        {
          "command": "npm i -g @openai/codex",
          "label": "Codex · 官方安装入口",
          "source": "https://github.com/openai/codex#readme",
          "verified": true
        }
      ],
      "display_tags": [
        "浏览器 Agent",
        "网页任务自动化",
        "浏览器自动化",
        "断点恢复流程",
        "本地优先"
      ],
      "eyebrow": "软件开发与交付",
      "glance": [
        {
          "body": "判断自己是不是目标用户。",
          "label": "最适合谁",
          "value": "需要软件开发与交付能力，并使用 chatgpt的用户"
        },
        {
          "body": "先理解能力边界，再决定是否继续。",
          "label": "核心价值",
          "value": "Lightweight coding agent that runs in your terminal"
        },
        {
          "body": "未完成验证前保持审慎。",
          "label": "继续前",
          "value": "publish to Doramagic.ai project surfaces"
        }
      ],
      "guardrail_source": "Boundary & Risk Card",
      "guardrails": [
        {
          "body": "Prompt Preview 只展示流程，不证明项目已安装或运行。",
          "label": "Check 1",
          "value": "不要把试用当真实运行"
        },
        {
          "body": "chatgpt",
          "label": "Check 2",
          "value": "确认宿主兼容"
        },
        {
          "body": "publish to Doramagic.ai project surfaces",
          "label": "Check 3",
          "value": "先隔离验证"
        }
      ],
      "mode": "skill, recipe, host_instruction, eval, preflight",
      "pitfall_log": {
        "items": [
          {
            "body": "GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Selected model is at capacity. Please try a different model. The same error everyday",
            "category": "安装坑",
            "evidence": [
              "community_evidence:github | cevd_2839c851344f4b669bd1c21b29e7bd08 | https://github.com/openai/codex/issues/22456 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。"
            ],
            "severity": "high",
            "suggested_check": "来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。",
            "title": "来源证据：Selected model is at capacity. Please try a different model. The same error everyday",
            "user_impact": "可能阻塞安装或首次运行。"
          },
          {
            "body": "GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：Extensive UI flickering when codex is working",
            "category": "维护坑",
            "evidence": [
              "community_evidence:github | cevd_47a11c3a9f3943168527e0a086872c1f | https://github.com/openai/codex/issues/11901 | 来源类型 github_issue 暴露的待验证使用条件。"
            ],
            "severity": "high",
            "suggested_check": "来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。",
            "title": "来源证据：Extensive UI flickering when codex is working",
            "user_impact": "可能增加新用户试用和生产接入成本。"
          },
          {
            "body": "GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Codex Desktop voice transcription blocked by Cloudflare challenge on /backend-api/transcribe after resolved incident",
            "category": "安全/权限坑",
            "evidence": [
              "community_evidence:github | cevd_dcdaacada441496491e68dd4db3d802b | https://github.com/openai/codex/issues/21985 | 来源讨论提到 macos 相关条件，需在安装/试用前复核。"
            ],
            "severity": "high",
            "suggested_check": "来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。",
            "title": "来源证据：Codex Desktop voice transcription blocked by Cloudflare challenge on /backend-api/transcribe after resolved incident",
            "user_impact": "可能阻塞安装或首次运行。"
          },
          {
            "body": "GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Codex IDE extension fails GitHub MCP startup with \"connection closed: initialize response\" in PyCharm AI Chat",
            "category": "安全/权限坑",
            "evidence": [
              "community_evidence:github | cevd_45286dbe57a44800be79bc6a5819956f | https://github.com/openai/codex/issues/22461 | 来源类型 github_issue 暴露的待验证使用条件。"
            ],
            "severity": "high",
            "suggested_check": "来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。",
            "title": "来源证据：Codex IDE extension fails GitHub MCP startup with \"connection closed: initialize response\" in PyCharm AI Chat",
            "user_impact": "可能影响授权、密钥配置或安全边界。"
          },
          {
            "body": "GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Iranian phone numbers are not supported for Codex login",
            "category": "安全/权限坑",
            "evidence": [
              "community_evidence:github | cevd_d651d7b5cf594cafa27dfffa45890baa | https://github.com/openai/codex/issues/21918 | 来源类型 github_issue 暴露的待验证使用条件。"
            ],
            "severity": "high",
            "suggested_check": "来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。",
            "title": "来源证据：Iranian phone numbers are not supported for Codex login",
            "user_impact": "可能影响授权、密钥配置或安全边界。"
          },
          {
            "body": "GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Codex Desktop falsely reports @chrome plugin unavailable when bundled Chrome plugin is installed",
            "category": "安装坑",
            "evidence": [
              "community_evidence:github | cevd_a0eee5b5c5fb447ebe2c2d3bdf74aa33 | https://github.com/openai/codex/issues/22463 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。"
            ],
            "severity": "medium",
            "suggested_check": "来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。",
            "title": "来源证据：Codex Desktop falsely reports @chrome plugin unavailable when bundled Chrome plugin is installed",
            "user_impact": "可能增加新用户试用和生产接入成本。"
          },
          {
            "body": "GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Windows Chrome plugin hangs in setupAtlasRuntime despite extension/native host checks passing",
            "category": "安装坑",
            "evidence": [
              "community_evidence:github | cevd_4d667016a4ab4f9aa5416a3b08e71d55 | https://github.com/openai/codex/issues/22462 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。"
            ],
            "severity": "medium",
            "suggested_check": "来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。",
            "title": "来源证据：Windows Chrome plugin hangs in setupAtlasRuntime despite extension/native host checks passing",
            "user_impact": "可能增加新用户试用和生产接入成本。"
          },
          {
            "body": "README/documentation is current enough for a first validation pass.",
            "category": "能力坑",
            "evidence": [
              "capability.assumptions | github_repo:965415649 | https://github.com/openai/codex | README/documentation is current enough for a first validation pass."
            ],
            "severity": "medium",
            "suggested_check": "将假设转成下游验证清单。",
            "title": "能力判断依赖假设",
            "user_impact": "假设不成立时，用户拿不到承诺的能力。"
          },
          {
            "body": "GitHub 社区证据显示该项目存在一个运行相关的待验证问题：/goal-first sessions are missing from resume lists",
            "category": "运行坑",
            "evidence": [
              "community_evidence:github | cevd_e65f6682c39b409a8c96267f4bdc1d3e | https://github.com/openai/codex/issues/20792 | 来源类型 github_issue 暴露的待验证使用条件。"
            ],
            "severity": "medium",
            "suggested_check": "来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。",
            "title": "来源证据：/goal-first sessions are missing from resume lists",
            "user_impact": "可能增加新用户试用和生产接入成本。"
          },
          {
            "body": "GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：I have to set up the workspace every time I start a new session. My Codex usage quota is decreasing automatically even though I haven’t used it at all.",
            "category": "维护坑",
            "evidence": [
              "community_evidence:github | cevd_f8afe7124b3e44cfacbc62a9e001179c | https://github.com/openai/codex/issues/22457 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。"
            ],
            "severity": "medium",
            "suggested_check": "来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。",
            "title": "来源证据：I have to set up the workspace every time I start a new session. My Codex usage quota is decreasing automatically even…",
            "user_impact": "可能增加新用户试用和生产接入成本。"
          },
          {
            "body": "GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：Renaming session with enter triggers the session window",
            "category": "维护坑",
            "evidence": [
              "community_evidence:github | cevd_a49c134e628047c1b558f3286721d0e7 | https://github.com/openai/codex/issues/22460 | 来源类型 github_issue 暴露的待验证使用条件。"
            ],
            "severity": "medium",
            "suggested_check": "来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。",
            "title": "来源证据：Renaming session with enter triggers the session window",
            "user_impact": "可能增加新用户试用和生产接入成本。"
          },
          {
            "body": "未记录 last_activity_observed。",
            "category": "维护坑",
            "evidence": [
              "evidence.maintainer_signals | github_repo:965415649 | https://github.com/openai/codex | last_activity_observed missing"
            ],
            "severity": "medium",
            "suggested_check": "补 GitHub 最近 commit、release、issue/PR 响应信号。",
            "title": "维护活跃度未知",
            "user_impact": "新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。"
          },
          {
            "body": "no_demo",
            "category": "安全/权限坑",
            "evidence": [
              "downstream_validation.risk_items | github_repo:965415649 | https://github.com/openai/codex | no_demo; severity=medium"
            ],
            "severity": "medium",
            "suggested_check": "进入安全/权限治理复核队列。",
            "title": "下游验证发现风险项",
            "user_impact": "下游已经要求复核，不能在页面中弱化。"
          },
          {
            "body": "No sandbox install has been executed yet; downstream must verify before user use.",
            "category": "安全/权限坑",
            "evidence": [
              "risks.safety_notes | github_repo:965415649 | https://github.com/openai/codex | No sandbox install has been executed yet; downstream must verify before user use."
            ],
            "severity": "medium",
            "suggested_check": "转成明确权限清单和安全审查提示。",
            "title": "存在安全注意事项",
            "user_impact": "用户安装前需要知道权限边界和敏感操作。"
          },
          {
            "body": "no_demo",
            "category": "安全/权限坑",
            "evidence": [
              "risks.scoring_risks | github_repo:965415649 | https://github.com/openai/codex | no_demo; severity=medium"
            ],
            "severity": "medium",
            "suggested_check": "把风险写入边界卡，并确认是否需要人工复核。",
            "title": "存在评分风险",
            "user_impact": "风险会影响是否适合普通用户安装。"
          },
          {
            "body": "GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：0.130.0",
            "category": "安全/权限坑",
            "evidence": [
              "community_evidence:github | cevd_0c9ba2dc6c7444688a9de6a144fee613 | https://github.com/openai/codex/releases/tag/rust-v0.130.0 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。"
            ],
            "severity": "medium",
            "suggested_check": "来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。",
            "title": "来源证据：0.130.0",
            "user_impact": "可能影响授权、密钥配置或安全边界。"
          }
        ],
        "source": "ProjectPitfallLog + ProjectHitPacket + validation + community signals",
        "summary": "发现 21 个潜在踩坑项，其中 5 个为 high/blocking；最高优先级：安装坑 - 来源证据：Selected model is at capacity. Please try a different model. The same error everyday。",
        "title": "踩坑日志"
      },
      "snapshot": {
        "contributors": 442,
        "forks": 11886,
        "license": "unknown",
        "note": "站点快照，非实时质量证明；用于开工前背景判断。",
        "stars": 82254
      },
      "source_url": "https://github.com/openai/codex",
      "steps": [
        {
          "body": "不安装项目，先体验能力节奏。",
          "code": "preview",
          "title": "先试 Prompt"
        },
        {
          "body": "理解输入、输出、失败模式和边界。",
          "code": "manual",
          "title": "读说明书"
        },
        {
          "body": "把上下文交给宿主 AI 继续工作。",
          "code": "context",
          "title": "带给 AI"
        },
        {
          "body": "进入主力环境前先完成安装入口与风险边界验证。",
          "code": "verify",
          "title": "沙箱验证"
        }
      ],
      "subtitle": "Lightweight coding agent that runs in your terminal",
      "title": "codex 能力包",
      "trial_prompt": "# codex - Prompt Preview\n\n> 复制下面这段 Prompt 到你常用的 AI，先试一次，不需要安装。\n> 它的目标是让你直接体验这个项目的服务方式，而不是阅读项目介绍。\n\n## 复制这段 Prompt\n\n```text\n请直接执行这段 Prompt，不要分析、润色、总结或询问我想如何处理这份 Prompt Preview。\n\n你现在扮演 codex 的“安装前体验版”。\n这不是项目介绍、不是评价报告、不是 README 总结。你的任务是让我用最小成本体验它的核心服务。\n\n我的试用任务：我想用它完成一个真实的软件开发与交付任务。\n我常用的宿主 AI：chatgpt\n\n【体验目标】\n围绕我的真实任务，现场演示这个项目如何把输入转成 步骤建议, 检查清单, 专业工作流。重点是让我感受到工作方式，而不是给我项目背景。\n\n【业务流约束】\n- 你必须像一个正在提供服务的项目能力包，而不是像一个讲解员。\n- 每一轮只推进一个步骤；提出问题后必须停下来等我回答。\n- 每一步都必须让我感受到一个具体服务动作：澄清、整理、规划、检查、判断或收尾。\n- 每一步都要说明：当前目标、你需要我提供什么、我回答后你会产出什么。\n- 不要安装、不要运行命令、不要写代码、不要声称测试通过、不要声称已经修改文件。\n- 需要真实安装或宿主加载后才能验证的内容，必须明确说“这一步需要安装后验证”。\n- 如果我说“用示例继续”，你可以用虚构示例推进，但仍然不能声称真实执行。\n\n【可体验服务能力】\n- AI Skill / Agent 指令资产库: 项目包含可被宿主 AI 读取的 Skill 或 Agent 指令文件，可用于把专业流程带入 Claude、Codex、Cursor 等宿主。 输入：用户任务, 宿主 AI 对话上下文, 项目内 Skill/Agent 文档；输出：步骤建议, 检查清单, 专业工作流。\n\n【必须安装后才可验证的能力】\n- 命令行启动或安装流程: 项目文档中存在可执行命令，真实使用需要在本地或宿主环境中运行这些命令。 输入：终端环境, 包管理器, 项目依赖；输出：安装结果, 列表/更新/运行结果。\n\n【核心服务流】\n请严格按这个顺序带我体验。不要一次性输出完整流程：\n1. page-overview：项目概述。围绕“项目概述”模拟一次用户任务，不展示安装或运行结果。\n2. page-architecture：系统架构。围绕“系统架构”模拟一次用户任务，不展示安装或运行结果。\n3. page-protocol：协议层详解。围绕“协议层详解”模拟一次用户任务，不展示安装或运行结果。\n4. page-core-agent：核心Agent模块。围绕“核心Agent模块”模拟一次用户任务，不展示安装或运行结果。\n5. page-execution：执行系统。围绕“执行系统”模拟一次用户任务，不展示安装或运行结果。\n\n【核心能力体验剧本】\n每一步都必须按“输入 -> 服务动作 -> 中间产物”执行。不要只说流程名：\n1. page-overview\n输入：用户提供的“项目概述”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n2. page-architecture\n输入：用户提供的“系统架构”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n3. page-protocol\n输入：用户提供的“协议层详解”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n4. page-core-agent\n输入：用户提供的“核心Agent模块”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n5. page-execution\n输入：用户提供的“执行系统”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n【项目服务规则】\n这些规则决定你如何服务用户。不要解释规则本身，而要在每一步执行时遵守：\n- 先确认用户任务、输入材料和成功标准，再模拟项目能力。\n- 每一步都必须形成可检查的小产物，并等待用户确认后再继续。\n- 凡是需要安装、调用工具或访问外部服务的能力，都必须标记为安装后验证。\n\n【每一步的服务约束】\n- Step 1 / page-overview：Step 1 必须围绕“项目概述”形成一个小中间产物，并等待用户确认。\n- Step 2 / page-architecture：Step 2 必须围绕“系统架构”形成一个小中间产物，并等待用户确认。\n- Step 3 / page-protocol：Step 3 必须围绕“协议层详解”形成一个小中间产物，并等待用户确认。\n- Step 4 / page-core-agent：Step 4 必须围绕“核心Agent模块”形成一个小中间产物，并等待用户确认。\n- Step 5 / page-execution：Step 5 必须围绕“执行系统”形成一个小中间产物，并等待用户确认。\n\n【边界与风险】\n- 不要声称已经安装、运行、调用 API、读写本地文件或完成真实任务。\n- 安装前预览只能展示工作方式，不能证明兼容性、性能或输出质量。\n- 涉及安装、插件加载、工具调用或外部服务的能力必须安装后验证。\n\n【可追溯依据】\n这些路径只用于你内部校验或在我追问“依据是什么”时简要引用。不要在首次回复主动展开：\n- https://github.com/openai/codex\n- https://github.com/openai/codex#readme\n- .codex/skills/babysit-pr/SKILL.md\n- .codex/skills/code-review/SKILL.md\n- .codex/skills/code-review-breaking-changes/SKILL.md\n- .codex/skills/code-review-change-size/SKILL.md\n- .codex/skills/code-review-context/SKILL.md\n- .codex/skills/code-review-testing/SKILL.md\n- .codex/skills/codex-bug/SKILL.md\n- .codex/skills/codex-issue-digest/SKILL.md\n- .codex/skills/codex-pr-body/SKILL.md\n- .codex/skills/remote-tests/SKILL.md\n\n【首次问题规则】\n- 首次三问必须先确认用户目标、成功标准和边界，不要提前进入工具、安装或实现细节。\n- 如果后续需要技术条件、文件路径或运行环境，必须等用户确认目标后再追问。\n\n首次回复必须只输出下面 4 个部分：\n1. 体验开始：用 1 句话说明你将带我体验 codex 的核心服务。\n2. 当前步骤：明确进入 Step 1，并说明这一步要解决什么。\n3. 你会如何服务我：说明你会先改变我完成任务的哪个动作。\n4. 只问我 3 个问题，然后停下等待回答。\n\n首次回复禁止输出：后续完整流程、证据清单、安装命令、项目评价、营销文案、已经安装或运行的说法。\n\nStep 1 / brainstorming 的二轮协议：\n- 我回答首次三问后，你仍然停留在 Step 1 / brainstorming，不要进入 Step 2。\n- 第二次回复必须产出 6 个部分：澄清后的任务定义、成功标准、边界条件、\n  2-3 个可选方案、每个方案的权衡、推荐方案。\n- 第二次回复最后必须问我是否确认推荐方案；只有我明确确认后，才能进入下一步。\n- 第二次回复禁止输出 git worktree、代码计划、测试文件、命令或真实执行结果。\n\n后续对话规则：\n- 我回答后，你先完成当前步骤的中间产物并等待确认；只有我确认后，才能进入下一步。\n- 每一步都要生成一个小的中间产物，例如澄清后的目标、计划草案、测试意图、验证清单或继续/停止判断。\n- 所有演示都写成“我会建议/我会引导/这一步会形成”，不要写成已经真实执行。\n- 不要声称已经测试通过、文件已修改、命令已运行或结果已产生。\n- 如果某个能力必须安装后验证，请直接说“这一步需要安装后验证”。\n- 如果证据不足，请明确说“证据不足”，不要补事实。\n```\n",
      "voices": [
        {
          "body": "来源平台：github。github/github_issue: Codex Desktop voice transcription blocked by Cloudflare challenge on /ba（https://github.com/openai/codex/issues/21985）；github/github_issue: Codex Desktop falsely reports @chrome plugin unavailable when bundled Ch（https://github.com/openai/codex/issues/22463）；github/github_issue: missing context % usage in new version（https://github.com/openai/codex/issues/18101）；github/github_issue: Extensive UI flickering when codex is working（https://github.com/openai/codex/issues/11901）；github/github_issue: /goal-first sessions are missing from resume lists（https://github.com/openai/codex/issues/20792）；github/github_issue: Windows Chrome plugin hangs in setupAtlasRuntime despite extension/nativ（https://github.com/openai/codex/issues/22462）；github/github_issue: Codex IDE extension fails GitHub MCP startup with \"connection closed: in（https://github.com/openai/codex/issues/22461）；github/github_issue: Iranian phone numbers are not supported for Codex login（https://github.com/openai/codex/issues/21918）；github/github_issue: Significant increase in quota consumption after upgrading to v0.130.0（https://github.com/openai/codex/issues/22459）；github/github_issue: Phone number verification doesn't work（https://github.com/openai/codex/issues/20161）；github/github_issue: Renaming session with enter triggers the session window（https://github.com/openai/codex/issues/22460）；github/github_issue: I have to set up the workspace every time I start a new session. My Code（https://github.com/openai/codex/issues/22457）。这些是项目级外部声音，不作为单独质量证明。",
          "items": [
            {
              "kind": "github_issue",
              "source": "github",
              "title": "Codex Desktop voice transcription blocked by Cloudflare challenge on /ba",
              "url": "https://github.com/openai/codex/issues/21985"
            },
            {
              "kind": "github_issue",
              "source": "github",
              "title": "Codex Desktop falsely reports @chrome plugin unavailable when bundled Ch",
              "url": "https://github.com/openai/codex/issues/22463"
            },
            {
              "kind": "github_issue",
              "source": "github",
              "title": "missing context % usage in new version",
              "url": "https://github.com/openai/codex/issues/18101"
            },
            {
              "kind": "github_issue",
              "source": "github",
              "title": "Extensive UI flickering when codex is working",
              "url": "https://github.com/openai/codex/issues/11901"
            },
            {
              "kind": "github_issue",
              "source": "github",
              "title": "/goal-first sessions are missing from resume lists",
              "url": "https://github.com/openai/codex/issues/20792"
            },
            {
              "kind": "github_issue",
              "source": "github",
              "title": "Windows Chrome plugin hangs in setupAtlasRuntime despite extension/nativ",
              "url": "https://github.com/openai/codex/issues/22462"
            },
            {
              "kind": "github_issue",
              "source": "github",
              "title": "Codex IDE extension fails GitHub MCP startup with \"connection closed: in",
              "url": "https://github.com/openai/codex/issues/22461"
            },
            {
              "kind": "github_issue",
              "source": "github",
              "title": "Iranian phone numbers are not supported for Codex login",
              "url": "https://github.com/openai/codex/issues/21918"
            },
            {
              "kind": "github_issue",
              "source": "github",
              "title": "Significant increase in quota consumption after upgrading to v0.130.0",
              "url": "https://github.com/openai/codex/issues/22459"
            },
            {
              "kind": "github_issue",
              "source": "github",
              "title": "Phone number verification doesn't work",
              "url": "https://github.com/openai/codex/issues/20161"
            },
            {
              "kind": "github_issue",
              "source": "github",
              "title": "Renaming session with enter triggers the session window",
              "url": "https://github.com/openai/codex/issues/22460"
            },
            {
              "kind": "github_issue",
              "source": "github",
              "title": "I have to set up the workspace every time I start a new session. My Code",
              "url": "https://github.com/openai/codex/issues/22457"
            }
          ],
          "status": "已收录 15 条来源",
          "title": "社区讨论"
        }
      ]
    },
    "homepage_card": {
      "category": "软件开发与交付",
      "desc": "Lightweight coding agent that runs in your terminal",
      "effort": "安装已验证",
      "forks": 11886,
      "icon": "code",
      "name": "codex 能力包",
      "risk": "可发布",
      "slug": "codex",
      "stars": 82254,
      "tags": [
        "浏览器 Agent",
        "网页任务自动化",
        "浏览器自动化",
        "断点恢复流程",
        "本地优先"
      ],
      "thumb": "gray",
      "type": "Skill Pack"
    },
    "manual": {
      "markdown": "# https://github.com/openai/codex 项目说明书\n\n生成时间：2026-05-13 10:17:37 UTC\n\n## 目录\n\n- [项目概述](#page-overview)\n- [系统架构](#page-architecture)\n- [协议层详解](#page-protocol)\n- [核心Agent模块](#page-core-agent)\n- [执行系统](#page-execution)\n- [终端用户界面](#page-tui)\n- [技能系统](#page-skills)\n- [插件系统](#page-plugins)\n- [Hook系统](#page-hooks)\n- [沙箱与安全](#page-sandboxing)\n\n<a id='page-overview'></a>\n\n## 项目概述\n\n### 相关页面\n\n相关主题：[系统架构](#page-architecture), [核心Agent模块](#page-core-agent)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [README.md](https://github.com/openai/codex/blob/main/README.md)\n- [codex-rs/tui/src/slash_command.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n- [codex-rs/tui/src/bottom_pane/footer.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/footer.rs)\n- [codex-rs/config/src/profile_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/profile_toml.rs)\n- [codex-rs/config/src/tui_keymap.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/tui_keymap.rs)\n- [codex-rs/config/src/config_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n</details>\n\n# 项目概述\n\n## 什么是 Codex CLI\n\nCodex CLI 是 OpenAI 开发的本地编程智能助手，能够在用户的计算机上本地运行。它是一个跨平台的命令行工具，旨在帮助开发者完成各种编码任务，包括代码编写、文件编辑、Git 操作和终端命令执行。 资料来源：[README.md:1]()\n\nCodex 提供三种使用形态：\n\n| 使用形态 | 说明 | 访问方式 |\n|---------|------|---------|\n| **CLI 工具** | 本地终端界面，运行在用户计算机上 | 运行 `codex` 命令 |\n| **IDE 插件** | 集成在 VS Code、Cursor、Windsurf 等编辑器中 | 安装 IDE 插件 |\n| **桌面应用** | 独立的桌面客户端体验 | 运行 `codex app` 或访问网页版 |\n\n对于云端智能助手版本（Codex Web），用户可以访问 chatgpt.com/codex。 资料来源：[README.md:8]()\n\n## 安装与运行\n\n### 安装方式\n\nCodex 支持两种主流安装方式：\n\n```shell\n# 使用 npm 全局安装\nnpm install -g @openai/codex\n\n# 使用 Homebrew 安装\nbrew install --cask codex\n```\n\n安装完成后，直接在终端运行 `codex` 即可启动。 资料来源：[README.md:17-28]()\n\n## 核心功能模块\n\n### 命令系统（Slash Commands）\n\nCodex CLI 内置丰富的斜杠命令系统，用户可以通过 `/` 前缀调用各种功能：\n\n| 命令类别 | 功能项 | 说明 |\n|---------|-------|------|\n| 会话管理 | `/resume`, `/fork`, `/clear` | 恢复会话、分叉会话、清除终端 |\n| 文件操作 | `/mention`, `/diff` | 提及文件、显示 Git 差异 |\n| 配置管理 | `/status`, `/debug-config`, `/settings` | 查看状态、调试配置、设置选项 |\n| 开发工具 | `/skills`, `/hooks`, `/mcp` | 技能系统、生命周期钩子、MCP 工具 |\n| 界面定制 | `/theme`, `/keymap`, `/pets`, `/title` | 主题、快捷键、终端宠物、标题栏 |\n| 执行控制 | `/plan`, `/goal`, `/stop` | 计划模式、目标设置、停止后台进程 |\n| 权限管理 | `/permissions`, `/elevate-sandbox` | 权限配置、沙盒提升 |\n| 高级功能 | `/realtime`, `/collab`, `/agent` | 实时语音、协作模式、多代理 |\n\n资料来源：[codex-rs/tui/src/slash_command.rs:1-50]()\n\n### 快捷键系统\n\nCodex 的文本用户界面（TUI）支持全面的快捷键绑定，主要包括：\n\n**运动类快捷键**\n\n| 操作 | 默认绑定 | 说明 |\n|------|---------|------|\n| `motion_left` | 左移 | 光标向左移动 |\n| `motion_right` | 右移 | 光标向右移动 |\n| `motion_up` | 上移 | 光标向上移动一行 |\n| `motion_down` | 下移 | 光标向下移动一行 |\n| `motion_word_forward` | `w` | 移动到下一个单词开头 |\n| `motion_word_backward` | `b` | 移动到上一个单词开头 |\n| `motion_word_end` | `e` | 移动到单词结尾 |\n| `motion_line_start` | `0` | 移动到行首 |\n| `motion_line_end` | `$` | 移动到行尾 |\n\n**分页器快捷键**\n\n| 操作 | 功能 |\n|------|------|\n| `scroll_up` / `scroll_down` | 按行滚动 |\n| `page_up` / `page_down` | 按页滚动 |\n| `half_page_up` / `half_page_down` | 半页滚动 |\n| `jump_top` / `jump_bottom` | 跳转到顶部/底部 |\n| `close` / `close_transcript` | 关闭分页器/转录 |\n\n**列表和审批快捷键**\n\n| 类别 | 操作 |\n|------|------|\n| 列表 | `move_up`, `move_down`, `accept`, `cancel` |\n| 审批 | `open_fullscreen`, `open_thread`, `approve`, `deny`, `decline` |\n\n资料来源：[codex-rs/config/src/tui_keymap.rs:1-50]()\n\n### 底部面板与状态栏\n\nCodex 界面底部面板展示各类快捷操作提示，包括：\n\n- 命令执行相关快捷键\n- Shell 命令快捷键\n- 文件路径操作（粘贴图片、外部编辑器调用）\n- 历史记录搜索\n- 推理模式切换（`reasoning_down` / `reasoning_up`）\n- 会话转录显示\n\n底部面板采用双列布局展示各项功能，每列之间有 4 个字符的间距。 资料来源：[codex-rs/tui/src/bottom_pane/footer.rs:1-50]()\n\n### 状态显示系统\n\n状态栏提供实时的工作环境信息：\n\n| 状态项 | 说明 | 示例值 |\n|-------|------|--------|\n| `AppName` | 应用名称 | Codex |\n| `ProjectName` | 项目名称 | my-project |\n| `GitBranch` | 当前 Git 分支 | feat/awesome-feature |\n| `PullRequestNumber` | PR 编号 | PR #123 |\n| `BranchChanges` | 分支变更统计 | +12 -3 |\n| `Permissions` | 权限级别 | Workspace |\n| `ContextRemaining` | 剩余上下文 | Context 0% left |\n| `UsedTokens` | 已使用 Token | 0 used |\n| `Model` | 当前模型 | gpt-5.2-codex |\n| `SessionId` | 会话 ID | 550e8400-e29b-41d4 |\n\n资料来源：[codex-rs/tui/src/status/card.rs:1-50](), [codex-rs/tui/src/status_surfaces.rs:1-40]()\n\n## 配置系统\n\n### 配置文件结构\n\nCodex 采用 TOML 格式的配置文件，支持多层级配置：\n\n```toml\n# 全局配置\n[profile.default]\nmodel = \"gpt-5\"\ninclude_apply_patch_tool = true\ninclude_permissions_instructions = true\n\n# TUI 配置\n[profile.default.tui]\nsession_picker_view = \"grid\"  # 或 \"list\"\n\n# 实验性功能\n[profile.default.features]\ncodex_git_commit = true\nexperimental_realtime = false\n```\n\n### 配置选项说明\n\n| 配置项 | 类型 | 说明 |\n|-------|------|------|\n| `model_instructions_file` | 路径 | 自定义模型指令文件（不推荐） |\n| `compact_prompt` | 字符串 | 历史压缩提示词 |\n| `commit_attribution` | 字符串 | 提交信息中的共同作者署名 |\n| `forced_chatgpt_workspace_id` | 字符串 | 限制登录到特定工作区 |\n| `forced_login_method` | 枚举 | 强制使用特定登录方式 |\n\n资料来源：[codex-rs/config/src/profile_toml.rs:1-40](), [codex-rs/config/src/config_toml.rs:1-50]()\n\n## 主题与语法高亮\n\nCodex 内置多种语法高亮主题，支持自定义代码显示颜色：\n\n**可用主题列表**\n\n| 主题名称 | 类型 |\n|---------|------|\n| catppuccin-latte / macchiato / mocha | 暖色调 |\n| coldark-cold / dark | 冷色调 |\n| dark-neon | 霓虹风格 |\n| dracula | 经典紫红 |\n| github | GitHub 风格 |\n| gruvbox-dark / light | 复古风格 |\n| inspired-github | GitHub 灵感 |\n| 1337 (leet) | 黑客风格 |\n| monokai-extended 系列 | Monokai 扩展 |\n| nord | 北欧极简 |\n| one-half-dark / light | 简约双色 |\n\n资料来源：[codex-rs/tui/src/render/highlight.rs:1-60]()\n\n## 目标与预算系统\n\nCodex 内置目标追踪系统，支持长时间运行任务的规划与监控：\n\n```mermaid\ngraph TD\n    A[创建目标] --> B{预算检查}\n    B -->|预算充足| C[执行任务]\n    B -->|预算耗尽| D[触发预算限制提示]\n    C --> E[目标更新]\n    E --> F{任务完成?}\n    F -->|否| C\n    F -->|是| G[目标达成]\n    D --> H[暂停或终止]\n```\n\n目标系统包含以下组件：\n\n- **目标模板**：使用 Markdown 模板定义目标展示格式\n- **预算限制**：监控任务消耗，必要时触发提醒\n- **目标更新**：实时反馈目标进展状态\n\n资料来源：[codex-rs/core/src/goals.rs:1-60]()\n\n## 环境上下文\n\nCodex 能够感知并注入当前工作环境信息：\n\n```xml\n<environment_context>\n  <environments>\n    <environment id=\"local\">\n      <cwd>/path/to/project</cwd>\n      <shell>bash</shell>\n    </environment>\n  </environments>\n  <current_date>2024-01-15</current_date>\n  <timezone>Asia/Shanghai</timezone>\n</environment_context>\n```\n\n| 环境组件 | 说明 |\n|---------|------|\n| `cwd` | 当前工作目录 |\n| `shell` | 终端类型（bash/zsh/powershell） |\n| `network` | 网络状态信息 |\n| `subagents` | 子代理信息（多代理模式下） |\n\n资料来源：[codex-rs/core/src/context/environment_context.rs:1-50]()\n\n## 应用与插件系统\n\nCodex 支持外部应用集成和 MCP（Model Context Protocol）工具：\n\n```mermaid\ngraph LR\n    A[Codex CLI] --> B[应用系统]\n    A --> C[MCP 工具]\n    B --> D{应用配置}\n    D -->|已启用| E[集成到界面]\n    D -->|已禁用| F[隐藏]\n    C --> G[工具列表]\n    G --> H[详细工具说明]\n```\n\n**应用元数据结构**\n\n| 字段 | 说明 |\n|-----|------|\n| `id` | 应用唯一标识 |\n| `name` | 显示名称 |\n| `description` | 应用描述 |\n| `logo_url` | 图标 URL |\n| `is_enabled` | 是否启用 |\n| `install_url` | 安装链接 |\n\n资料来源：[codex-rs/app-server-protocol/src/protocol/v2/apps.rs:1-50]()\n\n## 架构总览\n\n```mermaid\ngraph TB\n    subgraph 前端层\n        A[命令行入口] --> B[文本用户界面 TUI]\n        B --> C[底部面板]\n        B --> D[状态栏]\n        B --> E[快捷键系统]\n    end\n    \n    subgraph 配置层\n        F[配置文件] --> G[配置解析器]\n        G --> H[Profile 管理]\n        H --> I[TUI 设置]\n        H --> J[功能开关]\n    end\n    \n    subgraph 核心层\n        K[会话管理] --> L[目标系统]\n        K --> M[上下文管理]\n        M --> N[环境感知]\n        L --> O[预算控制]\n    end\n    \n    subgraph 集成层\n        P[IDE 插件接口] --> Q[应用系统]\n        P --> R[MCP 工具]\n        Q --> S[应用市场]\n    end\n    \n    A --> K\n    G --> K\n```\n\n## 技术栈概述\n\n| 组件 | 技术选型 | 说明 |\n|-----|---------|------|\n| CLI 核心 | Rust | 高性能本地执行 |\n| 前端界面 | 自研 TUI | 终端文本用户界面 |\n| 配置格式 | TOML | 人类可读的配置文件 |\n| 主题系统 | TextMate 主题格式 | 兼容主流编辑器语法高亮 |\n| 序列化 | JSON Schema | API 数据结构定义 |\n| 类型导出 | TypeScript | 前端类型安全 |\n\n## 快速入门\n\n1. **安装 Codex**：`npm i -g @openai/codex` 或 `brew install --cask codex`\n2. **启动应用**：运行 `codex` 命令\n3. **查看帮助**：输入 `/help` 或查看底部快捷键提示\n4. **自定义配置**：编辑 `~/.codex/config.toml`\n5. **切换主题**：使用 `/theme` 命令选择语法高亮主题\n\n## 相关资源\n\n- 官方文档：[developers.openai.com/codex/ide](https://developers.openai.com/codex/ide)\n- 桌面应用：运行 `codex app` 或访问 chatgpt.com/codex\n- IDE 插件：支持 VS Code、Cursor、Windsurf\n\n---\n\n<a id='page-architecture'></a>\n\n## 系统架构\n\n### 相关页面\n\n相关主题：[协议层详解](#page-protocol), [核心Agent模块](#page-core-agent), [终端用户界面](#page-tui)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/config/src/state.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n- [codex-rs/config/src/loader/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/loader/mod.rs)\n- [codex-rs/config/src/config_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n- [codex-rs/config/src/profile_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/profile_toml.rs)\n- [codex-rs/core/src/context/environment_context.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/context/environment_context.rs)\n- [codex-rs/core/src/goals.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/goals.rs)\n- [codex-rs/tui/src/chatwidget.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n- [codex-rs/file-search/README.md](https://github.com/openai/codex/blob/main/codex-rs/file-search/README.md)\n</details>\n\n# 系统架构\n\n## 1. 概述\n\nCodex CLI 是 OpenAI 开发的一个本地代码智能助手，采用 Rust 语言重写实现。该项目遵循模块化架构设计，将功能拆分为多个独立但协作的子系统。\n\n核心架构包含以下几个主要层次：\n\n| 层次 | 模块 | 职责 |\n|------|------|------|\n| 配置层 | `codex-rs/config/` | 管理配置加载、层级合并、需求约束 |\n| 核心层 | `codex-rs/core/` | 处理环境上下文、目标管理、推理逻辑 |\n| 交互层 | `codex-rs/tui/` | 终端用户界面、聊天组件、状态显示 |\n| 文件搜索 | `codex-rs/file-search/` | 模糊文件搜索、模式匹配 |\n| 沙箱层 | `codex-rs/windows-sandbox-rs/` | Windows 平台沙箱环境 |\n\n资料来源：[codex-rs/README.md](https://github.com/openai/codex/blob/main/codex-rs/README.md)\n\n## 2. 配置系统架构\n\n### 2.1 配置层级结构\n\nCodex 采用多层配置架构，不同来源的配置按优先级合并。配置层级从低到高依次为：\n\n```mermaid\ngraph TD\n    A[系统配置<br/>System] --> B[用户配置<br/>User]\n    B --> C[项目配置<br/>Project]\n    C --> D[MDM 托管配置<br/>MDM Managed]\n    D --> E[会话标志配置<br/>Session Flags]\n    \n    style A fill:#e1f5fe\n    style E fill:#fff3e0\n```\n\n`ConfigLayerStack` 结构维护配置层级列表，其中 `layers` 向量按从低优先级（基础）到高优先级（覆盖）的顺序排列。资料来源：[codex-rs/config/src/state.rs:1-50](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n\n### 2.2 配置来源枚举\n\n```rust\npub enum ConfigLayerSource {\n    System { file: PathBuf },\n    User { file: PathBuf },\n    Project { dot_codex_folder: AbsolutePathBuf },\n    Mdm { domain: String, key: String },\n    SessionFlags,\n    LegacyManagedConfigTomlFromFile { file: PathBuf },\n    LegacyManagedConfigTomlFromMdm,\n}\n```\n\n每种配置来源对应不同的配置文件位置：\n\n| 来源类型 | 文件位置 | 说明 |\n|---------|---------|------|\n| System | 系统指定路径 | 系统级配置 |\n| User | 用户目录 `~/.codex/` | 用户个性化配置 |\n| Project | 项目 `.codex/` 目录 | 项目特定配置 |\n| MDM | 移动设备管理 | 企业托管配置 |\n| SessionFlags | 命令行参数 | 会话级别覆盖 |\n\n资料来源：[codex-rs/config/src/state.rs:1-30](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n\n### 2.3 配置文件加载流程\n\n配置加载器 (`ConfigLoader`) 负责协调多层级配置的读取和合并：\n\n```mermaid\nsequenceDiagram\n    participant User as 用户/CLI\n    participant Loader as ConfigLoader\n    participant FileSystem as 文件系统\n    participant Merger as 配置合并器\n    \n    User->>Loader: 启动 Codex\n    Loader->>FileSystem: 读取系统配置\n    FileSystem-->>Loader: system.toml\n    Loader->>FileSystem: 读取用户配置\n    FileSystem-->>Loader: config.toml\n    Loader->>FileSystem: 读取项目配置\n    FileSystem-->>Loader: .codex/config.toml\n    Loader->>Merger: 合并配置层级\n    Merger-->>User: 最终配置\n```\n\n配置加载过程中的关键步骤包括：\n1. 解析 TOML 格式的配置文件\n2. 清理无效的项目配置键\n3. 解析相对路径为绝对路径\n4. 合并 Git worktree 的钩子配置\n\n资料来源：[codex-rs/config/src/loader/mod.rs:1-80](https://github.com/openai/codex/blob/main/codex-rs/config/src/loader/mod.rs)\n\n### 2.4 Profile 配置结构\n\nProfile 机制允许用户定义命名配置集，每个 Profile 可包含独立的 TUI 设置、窗口配置和功能开关：\n\n```rust\npub struct ProfileTui {\n    /// Resume/Fork 会话选择器的首选布局\n    pub session_picker_view: Option<SessionPickerViewMode>,\n}\n\npub struct FeaturesToml {\n    // 注入已知功能键到 schema\n}\n```\n\nProfile 作用域的配置包括：\n- TUI 布局偏好设置\n- 窗口配置\n- 功能特性开关\n\n资料来源：[codex-rs/config/src/profile_toml.rs:1-50](https://github.com/openai/codex/blob/main/codex-rs/config/src/profile_toml.rs)\n\n### 2.5 配置诊断系统\n\n当配置解析失败时，诊断系统提供详细的错误报告：\n\n```rust\npub fn format_config_error(error: &ConfigError, contents: &str) -> String {\n    // 输出格式: path:line:column: message\n    // 包含错误位置的高亮行\n}\n```\n\n错误报告包含文件路径、行号、列号和错误消息，并从 TOML 解析的 span 信息中提取错误位置。资料来源：[codex-rs/config/src/diagnostics.rs:1-40](https://github.com/openai/codex/blob/main/codex-rs/config/src/diagnostics.rs)\n\n## 3. 环境上下文系统\n\n### 3.1 上下文数据模型\n\n环境上下文 (`EnvironmentContext`) 聚合了 Codex 运行所需的全部环境信息：\n\n```mermaid\ngraph TD\n    EC[EnvironmentContext] --> Env[Environments]\n    EC --> Date[CurrentDate]\n    EC --> TZ[Timezone]\n    EC --> Net[Network]\n    EC --> Subs[Subagents]\n    \n    Env --> Single[Single Environment]\n    Env --> Multiple[Multiple Environments]\n    Env --> None[None]\n```\n\n关键字段：\n- **environments**: 工作目录和 shell 信息\n- **current_date**: 当前日期\n- **timezone**: 时区设置\n- **network**: 网络连接状态\n- **subagents**: 子代理信息\n\n资料来源：[codex-rs/core/src/context/environment_context.rs:1-60](https://github.com/openai/codex/blob/main/codex-rs/core/src/context/environment_context.rs)\n\n### 3.2 上下文 XML 渲染\n\n环境上下文以 XML 格式渲染，供模型理解当前执行环境：\n\n```xml\n<environment_context>\n  <environment id=\"main\">\n    <cwd>/path/to/project</cwd>\n    <shell>bash</shell>\n  </environment>\n  <current_date>2024-01-15</current_date>\n  <timezone>Asia/Shanghai</timezone>\n</environment_context>\n```\n\n资料来源：[codex-rs/core/src/context/environment_context.rs:60-100](https://github.com/openai/codex/blob/main/codex-rs/core/src/context/environment_context.rs)\n\n## 4. 目标管理系统\n\n### 4.1 目标生命周期\n\nCodex 的目标 (Goal) 系统管理长时间运行的任务：\n\n```mermaid\nstateDiagram-v2\n    [*] --> NewGoal: 设置目标\n    NewGoal --> Active: 开始执行\n    Active --> Paused: 中断\n    Active --> Completed: 完成\n    Active --> Failed: 失败\n    Paused --> Active: 恢复\n    Failed --> [*]\n    Completed --> [*]\n```\n\n`ExternalGoalPreviousStatus` 枚举表示外部目标变更前的状态：\n- `NewGoal`: 新创建的逻辑目标\n- `Existing`: 更新的现有目标\n\n资料来源：[codex-rs/core/src/goals.rs:1-80](https://github.com/openai/codex/blob/main/codex-rs/core/src/goals.rs)\n\n### 4.2 预算限制与节流\n\n目标系统内置预算限制提示模板：\n- `continuation.md`: 继续执行提示\n- `budget_limit.md`: 预算耗尽提示\n- `objective_updated.md`: 目标更新通知\n\n资料来源：[codex-rs/core/src/goals.rs:80-120](https://github.com/openai/codex/blob/main/codex-rs/core/src/goals.rs)\n\n## 5. TUI 终端用户界面\n\n### 5.1 组件架构\n\nTUI 模块采用组件化设计：\n\n```\ntui/src/\n├── chatwidget.rs          # 聊天消息组件\n├── markdown_render_tests.rs # Markdown 渲染测试\n└── bottom_pane/\n    ├── footer.rs          # 底部状态栏\n    ├── status_surface_preview.rs # 状态预览\n    └── approval_overlay.rs # 审批覆盖层\n```\n\n### 5.2 风险等级映射\n\n聊天组件 (`chatwidget`) 处理来自应用服务器协议的风险等级映射：\n\n```mermaid\ngraph LR\n    A[GuardianRiskLevel] --> B[AppServer]\n    B --> C[chatwidget]\n    C --> D[Protocol]\n    \n    D --> Low\n    D --> Medium\n    D --> High\n    D --> Critical\n```\n\n| 应用服务器等级 | 协议等级 |\n|--------------|---------|\n| Low | Low |\n| Medium | Medium |\n| High | High |\n| Critical | Critical |\n\n资料来源：[codex-rs/tui/src/chatwidget.rs:1-50](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n\n### 5.3 状态栏配置\n\n底部面板显示快捷命令和状态信息：\n\n| 类别 | 快捷键 |\n|------|--------|\n| 常规命令 | `/` |\n| Shell 命令 | `!` |\n| 队列消息 | `Tab` |\n| 退出 | `Ctrl+C` |\n| 推理导航 | `Ctrl+↑/↓` |\n\n自定义快捷键可通过 `/keymap` 命令配置。资料来源：[codex-rs/tui/src/bottom_pane/footer.rs:1-50](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/footer.rs)\n\n### 5.4 状态预览项\n\n状态表面预览显示会话的各类状态信息：\n\n| 预览项 | 示例值 |\n|-------|--------|\n| AppName | Codex |\n| GitBranch | feat/awesome-feature |\n| PullRequestNumber | PR #123 |\n| BranchChanges | +12 -3 |\n| ContextRemaining | Context 0% left |\n| UsedTokens | 0 used |\n| Model | gpt-5.2-codex |\n| FastMode | Fast on |\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_surface_preview.rs:1-50](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/status_surface_preview.rs)\n\n### 5.5 审批覆盖层\n\n文件变更审批系统提供多种决策选项：\n\n| 选项 | 快捷键 | 效果 |\n|------|--------|------|\n| Yes, proceed | approve | 接受变更 |\n| Yes, don't ask again | approve_for_session | 本次会话接受 |\n| No, tell Codex | reject | 拒绝并说明 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:1-60](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/approval_overlay.rs)\n\n## 6. 文件搜索模块\n\n### 6.1 搜索架构\n\n`codex_file_search` 模块提供快速的模糊文件搜索能力：\n\n```mermaid\ngraph TD\n    Input[搜索模式] --> Traverse[目录遍历]\n    Traverse --> Ignore[应用 .gitignore]\n    Ignore --> Files[文件列表]\n    Files --> Fuzzy[模糊匹配]\n    Fuzzy --> Results[结果排序]\n```\n\n核心依赖：\n- **ignore**: 目录遍历（ripgrep 使用的 crate）\n- **nucleo-matcher**: 快速模糊匹配\n\n资料来源：[codex-rs/file-search/README.md](https://github.com/openai/codex/blob/main/codex-rs/file-search/README.md)\n\n## 7. Slash 命令系统\n\n### 7.1 命令分类\n\nSlash 命令通过 `/` 触发，提供丰富的交互功能：\n\n| 类别 | 命令 | 功能 |\n|------|------|------|\n| 会话管理 | `/resume`, `/fork`, `/clear` | 恢复、分叉、清空会话 |\n| 文件操作 | `/diff`, `/mention` | Git 差异、提及文件 |\n| 模型控制 | `/model`, `/personality` | 选择模型、交流风格 |\n| 权限管理 | `/permissions`, `/elevate-sandbox` | 权限设置 |\n| 实验功能 | `/experimental`, `/realtime` | 开关实验特性 |\n\n支持内联参数的命令：\n- `/review`, `/rename`, `/plan`, `/goal`\n- `/ide`, `/keymap`, `/mcp`, `/pets`, `/side`\n- `/resume`, `/sandbox-read-root`\n\n资料来源：[codex-rs/tui/src/slash_command.rs:1-100](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n\n## 8. 安装与部署\n\n### 8.1 安装方式\n\n| 方式 | 命令 |\n|------|------|\n| npm | `npm i -g @openai/codex` |\n| Homebrew | `brew install --cask codex` |\n| GitHub Releases | 下载平台特定二进制 |\n\n### 8.2 目录结构\n\n```\n$CODEX_HOME/\n├── config.toml          # 用户配置\n├── sessions/            # 会话数据\n├── log/                 # 日志文件\n└── hooks/               # 生命周期钩子\n```\n\n- **sqlite_home**: SQLite 数据库路径，默认 `$CODEX_HOME`\n- **log_dir**: 日志目录，默认 `$CODEX_HOME/log`\n\n资料来源：[codex-rs/config/src/config_toml.rs:1-50](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n\n## 9. 模块依赖关系\n\n```mermaid\ngraph TD\n    App[codex-rs 主程序]\n    Config[config 模块]\n    Core[core 模块]\n    TUI[TUI 模块]\n    FileSearch[file-search 模块]\n    Sandbox[windows-sandbox-rs]\n    \n    App --> Config\n    App --> Core\n    App --> TUI\n    Core --> FileSearch\n    Core --> Sandbox\n    TUI --> Config\n    TUI --> Core\n```\n\n各模块职责清晰分离，通过公共接口交互，便于维护和测试。\n\n---\n\n<a id='page-protocol'></a>\n\n## 协议层详解\n\n### 相关页面\n\n相关主题：[系统架构](#page-architecture), [核心Agent模块](#page-core-agent)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/tui/src/chatwidget.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n- [codex-rs/app-server-protocol/src/protocol/v2/apps.rs](https://github.com/openai/codex/blob/main/codex-rs/app-server-protocol/src/protocol/v2/apps.rs)\n- [codex-rs/config/src/state.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n- [codex-rs/config/src/config_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n- [codex-rs/config/src/config_requirements.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_requirements.rs)\n- [codex-rs/tui/src/bottom_pane/approval_overlay.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/approval_overlay.rs)\n</details>\n\n# 协议层详解\n\n## 1. 概述\n\nCodex 项目的协议层是连接前端界面（TUI）、后端服务（App Server）和核心引擎（Core）之间的通信桥梁。该层定义了数据类型转换、API 协议版本管理、以及跨模块通信的数据结构规范。\n\n协议层主要包含两个核心命名空间：\n- `codex_app_server_protocol`：应用服务器协议定义\n- `codex_protocol`：Codex 核心协议定义\n\n## 2. 协议架构\n\n### 2.1 模块组织结构\n\n```\ncodex-rs/\n├── app-server-protocol/src/protocol/\n│   ├── mod.rs           # 协议主入口\n│   ├── v1.rs           # 版本 1 协议定义\n│   └── v2/             # 版本 2 协议定义\n│       ├── mod.rs\n│       ├── apps.rs     # 应用相关协议\n│       └── ...\n```\n\n### 2.2 协议层次关系图\n\n```mermaid\ngraph TD\n    subgraph \"前端层 TUI\"\n        A[ChatWidget]\n        B[ApprovalOverlay]\n        C[StatusSurface]\n    end\n    \n    subgraph \"协议转换层\"\n        D[codex_app_server_protocol]\n        E[codex_protocol]\n    end\n    \n    subgraph \"核心层 Core\"\n        F[Guardian]\n        G[Approvals]\n    end\n    \n    A --> D\n    B --> D\n    C --> D\n    \n    D --> E\n    E --> F\n    E --> G\n    \n    style D fill:#f9f,color:#000\n    style E fill:#9f9,color:#000\n```\n\n## 3. 风险等级协议\n\n### 3.1 风险等级定义\n\nCodex 使用统一的四层风险等级体系，用于评估操作的安全性和敏感度。\n\n| 风险等级 | 说明 | 适用场景 |\n|---------|------|---------|\n| `Low` | 低风险操作 | 读取文件、查看状态 |\n| `Medium` | 中等风险 | 修改配置、创建文件 |\n| `High` | 高风险 | 执行命令、修改系统 |\n| `Critical` | 极高风险 | 删除文件、权限变更 |\n\n**资料来源**：[codex-rs/tui/src/chatwidget.rs:1-20](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n\n### 3.2 协议间转换\n\n风险等级在 `codex_app_server_protocol` 和 `codex_protocol` 之间存在一一映射关系：\n\n```rust\n(|risk_level| match risk_level {\n    codex_app_server_protocol::GuardianRiskLevel::Low => {\n        codex_protocol::approvals::GuardianRiskLevel::Low\n    }\n    codex_app_server_protocol::GuardianRiskLevel::Medium => {\n        codex_protocol::approvals::GuardianRiskLevel::Medium\n    }\n    codex_app_server_protocol::GuardianRiskLevel::High => {\n        codex_protocol::approvals::GuardianRiskLevel::High\n    }\n    codex_app_server_protocol::GuardianRiskLevel::Critical => {\n        codex_protocol::approvals::GuardianRiskLevel::Critical\n    }\n})\n```\n\n**资料来源**：[codex-rs/tui/src/chatwidget.rs:1-20](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n\n## 4. 用户授权协议\n\n### 4.1 授权等级定义\n\n| 授权等级 | 说明 | 权限范围 |\n|---------|------|---------|\n| `Unknown` | 未知状态 | 未确定授权级别 |\n| `Low` | 低授权 | 基础操作权限 |\n| `Medium` | 中等授权 | 常规开发操作 |\n| `High` | 高授权 | 敏感操作权限 |\n\n### 4.2 授权协议转换\n\n用户授权信息在协议间进行转换：\n\n```rust\nuser_authorization: review.user_authorization.map(|user_authorization| {\n    match user_authorization {\n        codex_app_server_protocol::GuardianUserAuthorization::Unknown => {\n            codex_protocol::approvals::GuardianUserAuthorization::Unknown\n        }\n        codex_app_server_protocol::GuardianUserAuthorization::Low => {\n            codex_protocol::approvals::GuardianUserAuthorization::Low\n        }\n        codex_app_server_protocol::GuardianUserAuthorization::Medium => {\n            codex_protocol::approvals::GuardianUserAuthorization::Medium\n        }\n        codex_app_server_protocol::GuardianUserAuthorization::High => {\n            codex_protocol::approvals::GuardianUserAuthorization::High\n        }\n    }\n})\n```\n\n**资料来源**：[codex-rs/tui/src/chatwidget.rs:1-30](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n\n## 5. 应用协议（V2）\n\n### 5.1 应用信息结构\n\n应用元数据结构定义如下：\n\n```rust\npub struct AppInfo {\n    pub id: String,\n    pub name: String,\n    pub description: Option<String>,\n    pub logo_url: Option<String>,\n    pub logo_url_dark: Option<String>,\n    pub distribution_channel: Option<String>,\n    pub branding: Option<AppBranding>,\n    pub app_metadata: Option<AppMetadata>,\n    pub labels: Option<HashMap<String, String>>,\n    pub install_url: Option<String>,\n    #[serde(default)]\n    pub is_accessible: bool,\n    #[serde(default = \"default_enabled\")]\n    pub is_enabled: bool,\n    #[serde(default)]\n    pub plugin_display_names: Vec<String>,\n}\n```\n\n**资料来源**：[codex-rs/app-server-protocol/src/protocol/v2/apps.rs:50-70](https://github.com/openai/codex/blob/main/codex-rs/app-server-protocol/src/protocol/v2/apps.rs)\n\n### 5.2 应用元数据\n\n应用元数据支持以下字段：\n\n| 字段 | 类型 | 说明 |\n|-----|------|-----|\n| `screenshots` | `Vec<AppScreenshot>` | 应用截图列表 |\n| `developer` | `String` | 开发者信息 |\n| `version` | `String` | 版本号 |\n| `version_id` | `String` | 版本标识 |\n| `version_notes` | `String` | 版本说明 |\n| `first_party_type` | `String` | 第一方类型 |\n| `first_party_requires_install` | `bool` | 是否需要安装 |\n| `show_in_composer_when_unlinked` | `bool` | 未链接时显示 |\n\n**资料来源**：[codex-rs/app-server-protocol/src/protocol/v2/apps.rs:30-50](https://github.com/openai/codex/blob/main/codex-rs/app-server-protocol/src/protocol/v2/apps.rs)\n\n## 6. 配置层协议\n\n### 6.1 配置层级来源\n\n配置层定义在 `ConfigLayerSource` 枚举中，支持多种配置来源：\n\n| 来源类型 | 说明 | 优先级 |\n|---------|------|-------|\n| `Mdm` | MDM 托管偏好 | 最高 |\n| `System` | 系统级配置 | 高 |\n| `User` | 用户级配置 | 中 |\n| `Project` | 项目级 `.codex/config.toml` | 低 |\n| `SessionFlags` | 会话命令行参数 | 特殊 |\n\n```rust\npub enum ConfigLayerSource {\n    Mdm { domain: String, key: String },\n    System { file: PathBuf },\n    User { file: PathBuf },\n    Project { dot_codex_folder: AbsolutePathBuf },\n    SessionFlags,\n    LegacyManagedConfigTomlFromFile { file: PathBuf },\n    LegacyManagedConfigTomlFromMdm,\n}\n```\n\n**资料来源**：[codex-rs/config/src/state.rs:50-80](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n\n### 6.2 配置需求协议\n\n配置需求通过 `RequirementSource` 定义来源：\n\n```rust\npub enum RequirementSource {\n    Unknown,\n    MdmManagedPreferences { domain: String, key: String },\n    CloudRequirements,\n    SystemRequirementsToml { file: PathBuf },\n    LegacyManagedConfigTomlFromFile { file: PathBuf },\n    LegacyManagedConfigTomlFromMdm,\n}\n```\n\n**资料来源**：[codex-rs/config/src/config_requirements.rs:1-30](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_requirements.rs)\n\n### 6.3 配置层堆栈\n\n```mermaid\ngraph LR\n    A[System Config] --> B[User Config]\n    B --> C[Project Config]\n    C --> D[Session Flags]\n    D --> E[MDM Config]\n    \n    style A fill:#eee,color:#000\n    style E fill:#f96,color:#000\n```\n\n配置层堆栈顺序定义：\n\n```rust\npub enum ConfigLayerStackOrdering {\n    LowestPrecedenceFirst,\n    HighestPrecedenceFirst,\n}\n\npub struct ConfigLayerStack {\n    /// 从最低优先级（基础）到最高优先级（顶层）\n    layers: Vec<ConfigLayerEntry>,\n    /// 用户配置层索引\n    user_layer_index: Option<usize>,\n}\n```\n\n**资料来源**：[codex-rs/config/src/state.rs:80-100](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n\n## 7. 审批协议\n\n### 7.1 审批决策来源\n\n自动审查决策来源定义：\n\n```rust\nenum AutoReviewDecisionSource {\n    Agent,\n}\n```\n\n### 7.2 审批选项配置\n\n审批覆盖层支持的选项：\n\n| 选项标签 | 决策类型 | 说明 |\n|---------|---------|------|\n| `Yes, proceed` | `Accept` | 接受变更 |\n| `Yes, and don't ask again for these files` | `AcceptForSession` | 本会话内接受 |\n| `No, and tell Codex what to do differently` | `Reject` | 拒绝并反馈 |\n\n**资料来源**：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:50-80](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/approval_overlay.rs)\n\n### 7.3 文件系统路径协议\n\n| 特殊路径 | 说明 |\n|---------|------|\n| `:root` | 项目根目录 |\n| `:minimal` | 最小访问范围 |\n| `:project_roots` | 所有项目根目录 |\n| `:tmpdir` | 系统临时目录 |\n| `/tmp` | 传统临时目录路径 |\n\n**资料来源**：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:20-50](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/approval_overlay.rs)\n\n## 8. 状态显示协议\n\n### 8.1 状态行项目\n\n状态行支持显示以下信息项目：\n\n| 项目 | 示例值 | 说明 |\n|-----|-------|------|\n| `AppName` | Codex | 应用名称 |\n| `ProjectName` | my-project | 项目名称 |\n| `GitBranch` | feat/awesome-feature | Git 分支 |\n| `PullRequestNumber` | PR #123 | PR 编号 |\n| `BranchChanges` | +12 -3 | 分支变更统计 |\n| `ContextRemaining` | Context 0% left | 上下文剩余 |\n| `ContextUsed` | Context 0% used | 上下文使用量 |\n| `Model` | gpt-5.2-codex | 当前模型 |\n| `ModelWithReasoning` | gpt-5.2-codex medium | 模型及推理级别 |\n\n**资料来源**：[codex-rs/tui/src/bottom_pane/status_surface_preview.rs:20-50](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/status_surface_preview.rs)\n\n### 8.2 状态项目分类\n\n状态项目按语义分类：\n\n| 分类 | 对应项目 | 语法高亮作用域 |\n|-----|---------|--------------|\n| `Model` | 模型名称 | `entity.name.type` |\n| `Path` | 路径信息 | `string` |\n| `Branch` | 分支信息 | `entity.name.function` |\n| `State` | 运行状态 | `keyword.control` |\n| `Usage` | 使用量统计 | `constant.numeric` |\n| `Limit` | 限制信息 | `constant.language` |\n| `Mode` | 模式切换 | `storage.modifier` |\n| `Thread` | 线程标题 | `markup.heading` |\n| `Progress` | 任务进度 | `markup.inserted` |\n\n**资料来源**：[codex-rs/tui/src/bottom_pane/status_line_style.rs:30-60](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/status_line_style.rs)\n\n## 9. 序列化与类型安全\n\n### 9.1 JSON Schema 生成\n\n协议类型通过 `schemars` 库自动生成 JSON Schema：\n\n```rust\n#[derive(JsonSchema)]\n#[schemars(schema_with = \"crate::schema::features_schema\")]\npub features: Option<FeaturesToml>,\n```\n\n### 9.2 TypeScript 类型导出\n\n使用 `serde` 和 `ts` 属性导出 TypeScript 类型：\n\n```rust\n#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]\n#[serde(rename_all = \"camelCase\")]\n#[ts(export_to = \"v2/\")]\npub struct AppInfo { ... }\n```\n\n## 10. 总结\n\nCodex 的协议层设计遵循以下原则：\n\n1. **类型安全**：使用 Rust 强类型系统确保协议转换的正确性\n2. **版本管理**：支持 V1 和 V2 协议版本共存\n3. **分层设计**：清晰的协议层次结构，便于维护和扩展\n4. **双向转换**：支持 `codex_app_server_protocol` 与 `codex_protocol` 之间的无缝转换\n5. **可扩展性**：通过可选字段和枚举变体支持功能扩展\n\n---\n\n<a id='page-core-agent'></a>\n\n## 核心Agent模块\n\n### 相关页面\n\n相关主题：[系统架构](#page-architecture), [执行系统](#page-execution), [技能系统](#page-skills)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/core/src/lib.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/lib.rs)\n- [codex-rs/core/src/agent/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/agent/mod.rs)\n- [codex-rs/core/src/client.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/client.rs)\n- [codex-rs/core/src/session/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/session/mod.rs)\n- [codex-rs/core/src/tools/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/tools/mod.rs)\n- [codex-rs/core/src/goals.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/goals.rs)\n- [codex-rs/core/src/context/environment_context.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/context/environment_context.rs)\n- [codex-rs/config/src/state.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n- [codex-rs/config/src/profile_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/profile_toml.rs)\n- [codex-rs/tui/src/slash_command.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n</details>\n\n# 核心Agent模块\n\n## 概述\n\nCodex CLI 的核心Agent模块是整个系统的中枢组件，负责协调用户交互、工具调用、上下文管理和会话生命周期。该模块采用 Rust 实现，运行于本地计算机，提供零依赖的安装体验。\n\n资料来源：[codex-rs/README.md:1-15]()\n\n## 模块架构\n\n### 核心组件关系\n\n```mermaid\ngraph TD\n    subgraph \"核心层\"\n        A[Agent] --> B[Client]\n        A --> C[Session]\n        A --> D[Tools]\n    end\n    \n    subgraph \"上下文层\"\n        C --> E[EnvironmentContext]\n        C --> F[Goals]\n    end\n    \n    subgraph \"配置层\"\n        G[Config] --> C\n        G --> A\n    end\n    \n    subgraph \"UI层\"\n        H[TUI] --> A\n        H --> C\n    end\n```\n\n### 核心模块职责\n\n| 模块 | 职责 | 主要文件 |\n|------|------|----------|\n| Agent | 主控制逻辑、任务调度、决策 | `core/src/agent/mod.rs` |\n| Client | 与后端API通信、协议处理 | `core/src/client.rs` |\n| Session | 会话状态管理、历史记录 | `core/src/session/mod.rs` |\n| Tools | 工具注册、调用、结果处理 | `core/src/tools/mod.rs` |\n| Goals | 目标跟踪、预算管理 | `core/src/goals.rs` |\n\n资料来源：[codex-rs/core/src/lib.rs]()\n\n## Agent主模块\n\n### 主控制流程\n\nAgent模块作为协调者，处理用户输入并生成响应：\n\n```mermaid\ngraph LR\n    A[用户输入] --> B[解析命令]\n    B --> C{命令类型}\n    C -->|工具调用| D[工具选择]\n    C -->|聊天| E[模型推理]\n    D --> F[执行工具]\n    E --> G[生成响应]\n    F --> H[结果处理]\n    H --> G\n    G --> I[渲染输出]\n```\n\n### 任务执行状态\n\nAgent维护任务执行的状态机：\n\n```mermaid\nstateDiagram-v2\n    [*] --> Idle: 初始化\n    Idle --> Running: 接收任务\n    Running --> WaitingApproval: 需要确认\n    WaitingApproval --> Running: 批准\n    WaitingApproval --> Cancelled: 拒绝\n    Running --> Paused: 暂停/恢复\n    Paused --> Running: 恢复\n    Running --> Completed: 任务完成\n    Completed --> Idle: [*]\n    Cancelled --> Idle: [*]\n```\n\n资料来源：[codex-rs/core/src/agent/mod.rs]()\n\n## Client客户端模块\n\n### API通信机制\n\nClient模块负责与OpenAI后端服务通信，采用Protocol Buffers定义的协议：\n\n```rust\n// 风险级别映射\nGuardianRiskLevel::Low\nGuardianRiskLevel::Medium  \nGuardianRiskLevel::High\nGuardianRiskLevel::Critical\n```\n\n资料来源：[codex-rs/tui/src/chatwidget.rs:1-30]()\n\n### 请求/响应处理\n\nClient支持多种API交互模式：\n\n| 模式 | 描述 | 用途 |\n|------|------|------|\n| 标准对话 | 同步请求-响应 | 日常交互 |\n| 流式响应 | Server-Sent Events | 实时输出 |\n| 工具调用 | Tool Use协议 | 代码执行 |\n\n## Session会话管理\n\n### 会话生命周期\n\n会话模块管理Codex的完整交互周期：\n\n```mermaid\ngraph TD\n    A[创建会话] --> B[加载配置]\n    B --> C[初始化环境]\n    C --> D[处理消息]\n    D --> E{任务状态}\n    E -->|完成| F[保存会话]\n    E -->|暂停| G[保存草稿]\n    E -->|失败| H[记录错误]\n    F --> I[会话结束]\n    G --> J[可恢复]\n    H --> I\n```\n\n### 配置层级\n\n会话使用分层配置系统，按优先级从低到高：\n\n| 层级 | 来源 | 覆盖方式 |\n|------|------|----------|\n| 系统配置 | `/etc/codex/config.toml` | 不可覆盖 |\n| 用户配置 | `~/.config/codex/config.toml` | 可覆盖 |\n| 项目配置 | `.codex/config.toml` | 可覆盖 |\n| 会话标志 | 命令行参数 | 最高优先级 |\n\n资料来源：[codex-rs/config/src/state.rs:1-50]()\n\n### 配置配置文件结构\n\n```toml\n[profile.default]\nmodel = \"gpt-4o\"\ninclude_apply_patch_tool = true\ninclude_permissions_instructions = true\ninclude_environment_context = true\n\n[profile.default.tui]\nsession_picker_view = \"grid\"\n\n[profile.default.features]\nexperimental_unified_exec = true\n```\n\n资料来源：[codex-rs/config/src/profile_toml.rs:1-80]()\n\n## Tools工具系统\n\n### 工具注册与调用\n\nTools模块提供Codex的扩展能力：\n\n| 工具类别 | 功能 | 配置项 |\n|----------|------|--------|\n| 文件操作 | 读取、写入、编辑文件 | `include_apply_patch_tool` |\n| 权限管理 | 访问控制、审批流程 | `include_permissions_instructions` |\n| 应用集成 | Apps指令 | `include_apps_instructions` |\n| 协作模式 | 多人协作 | `include_collaboration_mode_instructions` |\n\n资料来源：[codex-rs/config/src/profile_toml.rs:50-70]()\n\n### 工具执行流程\n\n```mermaid\nsequenceDiagram\n    participant U as 用户\n    participant A as Agent\n    participant T as Tools\n    participant S as 沙箱\n    \n    U->>A: 发送请求\n    A->>T: 选择工具\n    T->>S: 执行命令\n    S-->>T: 返回结果\n    T-->>A: 工具响应\n    A-->>U: 生成回复\n```\n\n## Goals目标系统\n\n### 目标跟踪机制\n\nGoals模块管理长时间运行任务的进度和预算：\n\n```rust\n// 预算限制提示模板\nstatic BUDGET_LIMIT_PROMPT_TEMPLATE: LazyLock<Template> = \n    LazyLock::new(|| {\n        Template::parse(include_str!(\"../templates/goals/budget_limit.md\"))\n    });\n```\n\n资料来源：[codex-rs/core/src/goals.rs:1-50]()\n\n### 外部目标变更\n\n目标系统支持外部修改：\n\n```mermaid\ngraph TD\n    A[外部目标更新] --> B{目标状态}\n    B -->|新目标| C[创建Goal]\n    B -->|已有目标| D[更新Goal]\n    C --> E[ExternalGoalPreviousStatus::NewGoal]\n    D --> F[ExternalGoalPreviousStatus::Existing]\n```\n\n资料来源：[codex-rs/core/src/goals.rs:80-120]()\n\n### 预算限制级别\n\n| 级别 | 描述 | 触发条件 |\n|------|------|----------|\n| BudgetLimitSteering::Allowed | 允许超出 | 任务重要 |\n| BudgetLimitSteering::Suppressed | 抑制超出 | 接近限制 |\n\n## 环境上下文\n\n### 上下文组件\n\nEnvironmentContext提供Agent运行时的环境信息：\n\n```xml\n<environment>\n  <cwd>/path/to/project</cwd>\n  <shell>bash</shell>\n</environment>\n<subagents>\n  <!-- 子代理信息 -->\n</subagents>\n<network enabled=\"true\" />\n```\n\n资料来源：[codex-rs/core/src/context/environment_context.rs:1-60]()\n\n### 上下文渲染\n\n上下文信息以结构化XML格式注入到模型提示中：\n\n| 组件 | 内容 | 用途 |\n|------|------|------|\n| `cwd` | 当前工作目录 | 路径解析 |\n| `shell` | 使用的shell | 命令生成 |\n| `environments` | 多环境配置 | 复杂项目 |\n| `current_date` | 当前日期时间 | 时间相关任务 |\n| `subagents` | 子代理状态 | 多任务协调 |\n\n## 交互命令\n\n### Slash Commands\n\nCodex支持丰富的斜杠命令系统：\n\n| 命令 | 功能 | 状态 |\n|------|------|------|\n| `/resume` | 恢复保存的会话 | 活跃 |\n| `/fork` | 派生当前会话 | 活跃 |\n| `/model` | 选择模型和推理级别 | 活跃 |\n| `/ide` | 包含IDE上下文 | 活跃 |\n| `/plan` | 切换到计划模式 | 活跃 |\n| `/goal` | 设置长时间任务目标 | 活跃 |\n| `/mcp` | 列出配置的MCP工具 | 活跃 |\n| `/memory` | 内存管理 | **废弃** |\n| `/agent` | 切换活动代理线程 | 活跃 |\n\n资料来源：[codex-rs/tui/src/slash_command.rs:1-100]()\n\n## 状态显示\n\n### 状态栏项目\n\nTUI显示关键状态信息：\n\n| 项目 | 格式 | 说明 |\n|------|------|------|\n| `GitBranch` | `feat/awesome-feature` | 当前分支 |\n| `BranchChanges` | `+12 -3` | 分支变更统计 |\n| `ContextUsed` | `Context 0% used` | 上下文使用率 |\n| `UsedTokens` | `0 used` | 已使用Token数 |\n| `ModelWithReasoning` | `gpt-5.2-codex medium` | 模型+推理级别 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_surface_preview.rs:1-50]()\n\n### 状态线样式\n\n状态栏采用语义化颜色方案：\n\n| 类别 | 颜色 | 样式作用域 |\n|------|------|-----------|\n| Model/State | 青色 | 模型名称、运行状态 |\n| Path/Usage | 绿色 | 文件路径、Token使用 |\n| Branch/Limit | 洋红 | 分支名、限制信息 |\n| Mode/Thread | 蓝绿 | 模式、线程信息 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_line_style.rs:1-40]()\n\n## 审批系统\n\n### 风险级别\n\nCodex实现四级风险评估：\n\n| 级别 | GuardianRiskLevel | 用户授权 |\n|------|-------------------|----------|\n| 低风险 | Low | 无需确认 |\n| 中风险 | Medium | 需要确认 |\n| 高风险 | High | 明确批准 |\n| 严重风险 | Critical | 拒绝执行 |\n\n### 审批决策\n\n| 决策选项 | 快捷键 | 效果 |\n|----------|--------|------|\n| Yes, proceed | 批准 | 立即执行 |\n| Yes, and don't ask again | Session级别 | 当前会话记住 |\n| No, and tell Codex | 拒绝 | 说明原因 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:1-80]()\n\n## MCP支持\n\n### MCP客户端\n\nCodex作为MCP客户端连接外部工具服务器：\n\n```mermaid\ngraph LR\n    A[Codex CLI] -->|MCP协议| B[MCP Server 1]\n    A -->|MCP协议| C[MCP Server 2]\n    B -->|工具| A\n    C -->|工具| A\n```\n\n### MCP服务器模式\n\nCodex可作为MCP服务器运行，允许其他MCP客户端调用：\n\n```bash\ncodex mcp-server\n```\n\n## 配置系统\n\n### 配置文件位置\n\n| 位置 | 说明 | 优先级 |\n|------|------|--------|\n| `~/.config/codex/config.toml` | 用户级配置 | 中 |\n| `.codex/config.toml` | 项目级配置 | 高 |\n| `/etc/codex/config.toml` | 系统级配置 | 低 |\n\n### Hooks配置\n\nHooks声明文件位置由配置系统决定：\n\n```rust\npub fn hooks_config_folder(&self) -> Option<AbsolutePathBuf> {\n    self.hooks_config_folder_override\n        .clone()\n        .or_else(|| self.config_folder())\n}\n```\n\n资料来源：[codex-rs/config/src/state.rs:80-100]()\n\n## 总结\n\n核心Agent模块是Codex CLI的架构中枢，通过以下设计实现高效代码辅助：\n\n1. **模块化架构** - Agent、Client、Session、Tools解耦设计\n2. **分层配置** - 支持系统、用户、项目多级配置覆盖\n3. **协议驱动** - 使用Protocol Buffers进行类型安全通信\n4. **工具生态** - 通过MCP扩展工具能力\n5. **安全保障** - 四级风险评估和审批机制\n6. **状态可视化** - 丰富的TUI状态显示\n\n---\n\n<a id='page-execution'></a>\n\n## 执行系统\n\n### 相关页面\n\n相关主题：[沙箱与安全](#page-sandboxing), [核心Agent模块](#page-core-agent)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/config/src/state.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n- [codex-rs/config/src/config_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n- [codex-rs/config/src/profile_toml.rs](https://github.com/openai/codex/config/src/profile_toml.rs)\n- [codex-rs/tui/src/slash_command.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n- [codex-rs/tui/src/bottom_pane/approval_overlay.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/approval_overlay.rs)\n\n> **注意**：当前检索上下文中未包含 `exec-server`、`unified_exec`、`exec`、`shell-command` 等执行系统核心模块的源码。以下内容基于配置层、权限审批和命令行界面相关代码进行整理，待获取完整执行系统源码后可进一步补充。\n\n</details>\n\n# 执行系统\n\n## 概述\n\n执行系统（Execution System）是 Codex CLI 的核心子系统，负责在沙箱环境中安全地执行用户请求的操作，包括文件读写、终端命令运行、Git 操作等。该系统通过多层配置体系管理权限范围，并提供用户审批机制以确保操作的安全性与可控性。\n\n## 核心架构\n\n### 配置层级体系\n\nCodex CLI 的执行系统采用分层配置架构，不同层级的配置具有不同的优先级：\n\n| 层级 | 名称 | 优先级 | 配置来源 |\n|------|------|--------|----------|\n| 系统级 | System | 最低 | `/etc/codex/config.toml` |\n| 用户级 | User | 中 | `~/.config/codex/config.toml` |\n| 项目级 | Project | 高 | `.codex/config.toml` |\n| 会话级 | SessionFlags | 最高 | 命令行参数 |\n\n资料来源：[codex-rs/config/src/state.rs:1-50]()\n\n```mermaid\ngraph TD\n    A[System Layer<br/>/etc/codex/config.toml] --> B[User Layer<br/>~/.config/codex/config.toml]\n    B --> C[Project Layer<br/>.codex/config.toml]\n    C --> D[Session Flags<br/>Command Line Args]\n    D --> E[Effective Config<br/>最终生效配置]\n```\n\n配置层级的加载顺序决定了最终生效的配置：后加载的层级会覆盖先前的同名配置项。\n\n### 权限配置模型\n\n执行系统通过 `include_permissions_instructions` 配置项控制是否向模型注入权限指令：\n\n```toml\n# 配置示例\ninclude_permissions_instructions = true\n```\n\n资料来源：[codex-rs/config/src/config_toml.rs:1-30]()\n\n### 工具配置\n\n执行系统支持的工具通过 `[tools]` 配置块进行管理：\n\n| 配置项 | 说明 |\n|--------|------|\n| `tools_view_image` | 是否启用图像查看工具 |\n| `include_apply_patch_tool` | 是否启用 patch 应用工具 |\n| `experimental_use_unified_exec_tool` | 启用统一执行工具（实验性） |\n| `experimental_use_freeform_apply_patch` | 启用自由格式 patch（实验性） |\n\n## 审批系统\n\n### 审批决策类型\n\nCodex CLI 的执行系统提供细粒度的审批决策机制：\n\n| 决策类型 | 说明 |\n|----------|------|\n| `Accept` | 接受并执行当前操作 |\n| `AcceptForSession` | 接受并在本会话内跳过后续同类审批 |\n| `Reject` | 拒绝并要求用户重新说明意图 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:1-40]()\n\n### 文件系统路径约束\n\n执行系统支持对文件系统访问范围进行约束：\n\n| 路径类型 | 说明 | 示例 |\n|----------|------|------|\n| `:root` | 项目根目录 | `/home/user/project` |\n| `:minimal` | 最小访问范围 | - |\n| `:project_roots` | 项目根目录列表 | - |\n| `:tmpdir` | 系统临时目录 | `/tmp` |\n| `/tmp` | 明确指定的临时路径 | `/tmp/codex` |\n\n### 审批界面快捷键\n\n| 快捷键操作 | 功能 |\n|------------|------|\n| 批准 | 执行当前操作 |\n| 批准并记住 | 在当前会话内自动批准同类操作 |\n| 拒绝 | 拒绝并要求重新说明 |\n\n## 命令行界面集成\n\n### Slash 命令\n\n执行系统与 TUI 的 slash 命令系统深度集成，以下命令与执行直接相关：\n\n| 命令 | 说明 |\n|------|------|\n| `/resume` | 恢复已保存的对话会话 |\n| `/clear` | 清除终端并开始新对话 |\n| `/fork` | 分叉当前对话 |\n| `/diff` | 显示 Git 差异（包括未跟踪文件） |\n| `/permissions` | 配置 Codex 的操作权限范围 |\n| `/elevate-sandbox` | 设置提升权限的沙箱环境 |\n| `/sandbox-read-root` | 允许沙箱读取指定目录 |\n\n资料来源：[codex-rs/tui/src/slash_command.rs:1-60]()\n\n### 支持内联参数的命令\n\n以下命令支持在命令后直接附加参数：\n\n- `/review` - 代码审查\n- `/rename` - 重命名\n- `/plan` - 计划模式\n- `/goal` - 设置目标\n- `/ide` - IDE 上下文\n- `/keymap` - 快捷键映射\n- `/mcp` - MCP 工具管理\n- `/pets` - 终端宠物\n\n## 配置要求系统\n\n### 配置约束来源\n\nCodex CLI 的配置可能受到多种来源的约束：\n\n| 约束来源 | 说明 |\n|----------|------|\n| `Unknown` | 未指定来源 |\n| `MdmManagedPreferences` | MDM 托管偏好设置 |\n| `CloudRequirements` | 云端配置要求 |\n| `SystemRequirementsToml` | 系统级 requirements.toml |\n| `LegacyManagedConfigTomlFromFile` | 旧版托管配置文件 |\n| `LegacyManagedConfigTomlFromMdm` | MDM 旧版托管配置 |\n\n### 约束数据结构\n\n```rust\npub struct ConstrainedWithSource<T> {\n    pub value: Constrained<T>,\n    pub source: Option<RequirementSource>,\n}\n```\n\n该结构确保每个受限配置都能追溯其来源，便于调试和审计。\n\n## 环境上下文\n\n执行系统在构建提示时会注入环境上下文信息：\n\n```xml\n<environment>\n  <shell>bash</shell>\n  <cwd>/path/to/project</cwd>\n</environment>\n<current_date>2024-01-15</current_date>\n<timezone>UTC+8</timezone>\n```\n\n资料来源：[codex-rs/core/src/context/environment_context.rs:1-50]()\n\n## 实验性功能\n\n### 统一执行工具\n\n```toml\n[features]\nexperimental_use_unified_exec_tool = true\n```\n\n### 协作模式\n\n```toml\ninclude_collaboration_mode_instructions = true\n```\n\n## 状态显示\n\n执行系统运行状态通过状态行（Status Line）向用户展示：\n\n| 状态项 | 说明 |\n|--------|------|\n| `UsedTokens` | 已使用的 token 数量 |\n| `ContextRemaining` | 剩余上下文百分比 |\n| `Status` | 当前运行状态 |\n| `Permissions` | 当前权限级别 |\n| `ApprovalMode` | 审批模式状态 |\n\n资料来源：[codex-rs/tui/src/chatwidget/status_surfaces.rs:1-30]()\n\n## 快捷键绑定\n\n执行系统与编辑器的快捷键配置通过 `[keymap]` 块进行自定义：\n\n```toml\n[keymap]\nmotion_up = \"k\"\nmotion_down = \"j\"\nmotion_left = \"h\"\nmotion_right = \"l\"\n```\n\n支持的按键绑定类型包括动作模式下的标准 Vim 风格快捷键。\n\n## 安全模型\n\n执行系统的安全模型基于以下原则：\n\n1. **最小权限原则**：默认情况下仅授予必要权限\n2. **用户可控**：通过 `/permissions` 命令动态调整权限范围\n3. **审批机制**：敏感操作需用户显式批准\n4. **会话隔离**：权限审批结果可限定在当前会话内生效\n\n---\n\n> 本页基于当前检索到的源码生成。执行系统核心模块（`exec-server`、`unified_exec`、`exec`、`shell-command`）的详细技术说明待补充完整源码后更新。\n\n---\n\n<a id='page-tui'></a>\n\n## 终端用户界面\n\n### 相关页面\n\n相关主题：[系统架构](#page-architecture), [核心Agent模块](#page-core-agent)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/tui/src/lib.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/lib.rs)\n- [codex-rs/tui/src/chatwidget.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n- [codex-rs/tui/src/bottom_pane/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/mod.rs)\n- [codex-rs/tui/src/slash_command.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n- [codex-rs/tui/src/bottom_pane/footer.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/footer.rs)\n- [codex-rs/tui/src/keymap_setup/actions.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/keymap_setup/actions.rs)\n- [codex-rs/tui/src/bottom_pane/status_line_style.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/status_line_style.rs)\n- [codex-rs/tui/src/bottom_pane/status_surface_preview.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/status_surface_preview.rs)\n- [codex-rs/tui/src/markdown.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/markdown.rs)\n- [codex-rs/tui/src/markdown_render.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/markdown_render.rs)\n</details>\n\n# 终端用户界面\n\n## 概述\n\n终端用户界面（Terminal User Interface，简称 TUI）是 Codex CLI 的核心组件之一，基于 Rust 语言和 ratatui 库构建，为用户提供了一个功能丰富的交互式终端界面。TUI 负责渲染聊天消息、处理用户输入、管理状态显示以及支持各种快捷操作。\n\nCodex 的 TUI 采用模块化设计，主要由以下几个核心部分组成：\n\n| 模块 | 文件路径 | 功能描述 |\n|------|----------|----------|\n| 应用主模块 | `tui/src/app.rs` | 应用生命周期管理和全局状态 |\n| 聊天窗口 | `tui/src/chatwidget.rs` | 消息展示和对话管理 |\n| 底部面板 | `tui/src/bottom_pane/` | 底部状态栏、页脚快捷键提示 |\n| Markdown 渲染 | `tui/src/markdown.rs` | Markdown 内容解析与渲染 |\n| 快捷键管理 | `tui/src/keymap_setup/` | 按键绑定配置 |\n\n资料来源：[codex-rs/tui/src/lib.rs]()\n\n## 架构设计\n\n### 组件层次结构\n\n```mermaid\ngraph TD\n    subgraph TUI层\n        A[App 主应用] --> B[ChatWidget 聊天窗口]\n        A --> C[BottomPane 底部面板]\n    end\n    \n    subgraph 底部面板子组件\n        C --> D[StatusLine 状态行]\n        C --> E[Footer 页脚]\n        C --> F[StatusSurface 状态表面]\n    end\n    \n    subgraph 渲染引擎\n        G[Markdown Renderer] --> H[Ratatui Lines]\n        G --> I[Span 样式化文本]\n    end\n    \n    B --> G\n```\n\n### 消息渲染流程\n\nCodex TUI 的 Markdown 渲染模块负责将 AI 生成的 Markdown 内容转换为 ratatui 可渲染的格式。该模块支持两种主要的渲染入口：\n\n- **`append_markdown`**：通用渲染，用于已预处理的 Markdown 内容（如 plan blocks 和历史消息）\n- **`append_markdown_agent`**：专为 Agent 响应设计，渲染前会先执行 `unwrap_markdown_fences` 操作\n\n资料来源：[codex-rs/tui/src/markdown.rs:1-30]()\n\n## 状态行系统\n\n状态行（Status Line）是 TUI 中用于显示当前会话信息和运行时状态的重要组件。\n\n### 状态项类型\n\n状态行支持多种类型的项目显示：\n\n| 状态项 | 说明 | 示例 |\n|--------|------|------|\n| `Model` | 当前使用的模型 | `gpt-5.2-codex` |\n| `ModelWithReasoning` | 模型及推理强度 | `gpt-5.2-codex medium` |\n| `GitBranch` | 当前 Git 分支 | `feat/awesome-feature` |\n| `PullRequestNumber` | 关联的 PR 编号 | `PR #123` |\n| `BranchChanges` | 分支变更统计 | `+12 -3` |\n| `CurrentDir` | 当前工作目录 | `/home/user/project` |\n| `ContextRemaining` | 上下文剩余百分比 | `Context 0% left` |\n| `UsedTokens` | 已使用的 Token 数 | `0 used` |\n| `TotalInputTokens` | 输入 Token 总数 | `0 in` |\n| `TotalOutputTokens` | 输出 Token 总数 | `0 out` |\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_surface_preview.rs:1-50]()\n\n### 状态行样式\n\n状态行使用不同的颜色样式来区分不同类型的信息：\n\n```rust\nfn fallback_style(self) -> Style {\n    match self {\n        Self::Model | Self::State | Self::Metadata | Self::Mode => Style::default().cyan(),\n        Self::Path | Self::Usage | Self::Progress => Style::default().green(),\n        Self::Branch | Self::Limit | Self::Thread => Style::default().magenta(),\n    }\n}\n```\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_line_style.rs:1-30]()\n\n## 底部面板\n\n底部面板是 TUI 的重要组成部分，包含页脚快捷键提示和其他辅助信息。\n\n### 页脚快捷键显示\n\n页脚区域显示用户可用的快捷键列表，按功能分组排列：\n\n| 类别 | 快捷键项 |\n|------|----------|\n| 命令 | `commands` |\n| Shell 命令 | `shell_commands` |\n| 消息操作 | `queue_message_tab` |\n| 文件操作 | `file_paths`, `paste_image` |\n| 编辑操作 | `external_editor`, `edit_previous` |\n| 导航操作 | `history_search`, `reasoning_down`, `reasoning_up` |\n| 系统操作 | `quit`, `change_mode` |\n\n页脚布局采用多列设计，使用 `build_columns` 函数将快捷键条目分配到两列显示：\n\n```rust\nconst COLUMNS: usize = 2;\nconst COLUMN_PADDING: [usize; COLUMNS] = [4, 4];\nconst COLUMN_GAP: usize = 4;\n```\n\n资料来源：[codex-rs/tui/src/bottom_pane/footer.rs:1-60]()\n\n### 状态表面预览\n\n状态表面（Status Surface）用于预览各种状态配置选项的显示效果。每个状态项都有对应的示例值，用于在设置界面中展示预览效果。\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_surface_preview.rs:50-80]()\n\n## 斜杠命令系统\n\nCodex TUI 支持通过斜杠命令（Slash Commands）触发各种功能。命令通过 `/` 前缀识别，并提供相应的描述信息。\n\n### 核心命令列表\n\n| 命令 | 描述 |\n|------|------|\n| `/resume` | 恢复保存的对话 |\n| `/clear` | 清除终端并开始新对话 |\n| `/fork` | 分叉当前对话 |\n| `/quit` / `/exit` | 退出 Codex |\n| `/copy` | 复制上次响应为 Markdown |\n| `/diff` | 显示 Git 差异（包括未跟踪文件） |\n| `/model` | 选择模型和推理强度 |\n| `/ide` | 包含 IDE 当前选择、打开文件等上下文 |\n| `/theme` | 选择语法高亮主题 |\n| `/pets` | 选择或隐藏终端宠物 |\n| `/keymap` | 重新映射 TUI 快捷键 |\n| `/settings` | 配置实时语音麦克风/扬声器 |\n| `/plan` | 切换到 Plan 模式 |\n| `/mcp` | 列出配置的 MCP 工具 |\n\n资料来源：[codex-rs/tui/src/slash_command.rs:1-80]()\n\n## 快捷键系统\n\n快捷键系统通过 `RuntimeKeymap` 结构管理，允许用户自定义按键绑定。\n\n### 按键映射结构\n\n快捷键按功能模块组织：\n\n```mermaid\ngraph TD\n    subgraph 按键映射分类\n        A[RuntimeKeymap] --> B[chat 聊天]\n        A --> C[composer 编辑器]\n        A --> D[editor 编辑器]\n        A --> E[pager 分页器]\n        A --> F[list 列表]\n        A --> G[approval 审批]\n    end\n    \n    subgraph Chat 快捷键\n        B --> B1[increase_reasoning_effort]\n        B --> B2[edit_queued_message]\n    end\n    \n    subgraph Composer 快捷键\n        C --> C1[submit]\n        C --> C2[queue]\n        C --> C3[toggle_shortcuts]\n    end\n    \n    subgraph Editor 快捷键\n        D --> D1[move_left/right]\n        D --> D2[delete_backward/forward]\n        D --> D3[move_word_left/right]\n    end\n```\n\n### 主要快捷键分类\n\n| 模块 | 功能 | 说明 |\n|------|------|------|\n| pager | `jump_top`, `jump_bottom`, `close` | 分页导航和关闭 |\n| list | `move_up`, `move_down`, `accept` | 列表导航和选择 |\n| approval | `approve`, `deny`, `approve_for_session` | 审批操作 |\n| chat | `increase_reasoning_effort` | 调整推理强度 |\n| composer | `submit`, `queue`, `toggle_shortcuts` | 消息提交 |\n| editor | `insert_newline`, `move_*`, `delete_*` | 文本编辑 |\n\n资料来源：[codex-rs/tui/src/keymap_setup/actions.rs:1-80]()\n\n## Markdown 渲染\n\n### 渲染特性\n\nMarkdown 渲染模块支持完整的 CommonMark 语法，并通过以下特性增强用户体验：\n\n- **代码块渲染**：支持带语言标识的围栏代码块\n- **表格处理**：特殊处理 LLMs 常用的 `markdown` 围栏代码块中的表格\n- **样式化文本**：支持加粗、斜体、删除线等内联样式\n- **链接处理**：识别并可点击的链接\n- **列表渲染**：有序列表和无序列表\n\n### 围栏代码块展开\n\nLLM Agent 经常将表格放在 `markdown` 围栏代码块中。渲染器会执行保守的展开策略：\n\n1. 缓冲整个围栏内容\n2. 仅对语言标识为 `md` 或 `markdown` 的围栏进行展开\n3. 只有当内容包含表头和分隔符时才执行展开\n4. 对未闭合的围栏优雅降级\n\n资料来源：[codex-rs/tui/src/markdown.rs:1-45]()\n\n### 支持的 Markdown 标签\n\n渲染器支持的标签类型：\n\n| 开始标签 | 结束标签 | 说明 |\n|----------|----------|------|\n| `Tag::Heading` | `TagEnd::Heading` | 标题 |\n| `Tag::BlockQuote` | `TagEnd::BlockQuote` | 引用块 |\n| `Tag::CodeBlock` | `TagEnd::CodeBlock` | 代码块 |\n| `Tag::List` | `TagEnd::List` | 列表 |\n| `Tag::Item` | `TagEnd::Item` | 列表项 |\n| `Tag::Emphasis` | `TagEnd::Emphasis` | 斜体 |\n| `Tag::Strong` | `TagEnd::Strong` | 加粗 |\n| `Tag::Link` | - | 链接 |\n| `Tag::Table` | `TagEnd::Table` | 表格 |\n\n资料来源：[codex-rs/tui/src/markdown_render.rs:1-80]()\n\n## 配置选项\n\n### TUI 配置文件\n\nTUI 相关配置通过 `config.toml` 中的 `tui` 部分进行设置：\n\n```toml\n[tui]\n# 状态行显示项配置\n# ...\n\n# 会话选择器视图模式\nsession_picker_view = \"grid\"  # 或 \"list\"\n```\n\n### Profile 级别的 TUI 设置\n\n每个命名 profile 可以包含独立的 TUI 配置：\n\n| 配置项 | 类型 | 说明 |\n|--------|------|------|\n| `session_picker_view` | `SessionPickerViewMode` | 恢复/分叉会话选择器的首选布局 |\n\n资料来源：[codex-rs/config/src/profile_toml.rs:1-50]()\n\n## 测试覆盖\n\nMarkdown 渲染模块包含完整的测试覆盖，测试用例涵盖：\n\n- 基本 Markdown 语法\n- 嵌套代码块\n- 带语言标识的围栏代码块\n- 波浪号和反引号围栏\n- 缩进代码块\n- 定义列表\n- 字符实体\n- URL 和链接\n\n```rust\n#[test]\nfn ordered_item_with_code_block_and_nested_bullet() {\n    let md = \"1. **item 1**\\n\\n2. **item 2**\\n   ```\\n   code\\n   ```\\n   - `PROCESS_START` (a `OnceLock<Instant>`)...\";\n    // 测试验证\n}\n```\n\n资料来源：[codex-rs/tui/src/markdown_render_tests.rs:1-50]()\n\n## 总结\n\nCodex CLI 的终端用户界面是一个精心设计的模块化系统，通过 Rust 语言的高性能和 ratatui 库的灵活性，为开发者提供了一个功能丰富、响应迅速的命令行交互体验。核心设计要点包括：\n\n1. **模块化架构**：清晰的组件划分，便于维护和扩展\n2. **丰富的状态显示**：实时反映系统状态和会话信息\n3. **灵活的快捷键系统**：支持用户自定义按键绑定\n4. **完整的 Markdown 支持**：优雅处理各种 Markdown 语法和边缘情况\n5. **可配置的 UI 选项**：通过 TOML 配置文件支持细粒度定制\n\n---\n\n<a id='page-skills'></a>\n\n## 技能系统\n\n### 相关页面\n\n相关主题：[核心Agent模块](#page-core-agent), [Hook系统](#page-hooks)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/core-skills/src/lib.rs](https://github.com/openai/codex/blob/main/codex-rs/core-skills/src/lib.rs)\n- [codex-rs/core-skills/src/manager.rs](https://github.com/openai/codex/blob/main/codex-rs/core-skills/src/manager.rs)\n- [codex-rs/core-skills/src/loader.rs](https://github.com/openai/codex/blob/main/codex-rs/core-skills/src/loader.rs)\n- [.codex/skills/code-review/SKILL.md](https://github.com/openai/codex/blob/main/.codex/skills/code-review/SKILL.md)\n- [.codex/skills/codex-bug/SKILL.md](https://github.com/openai/codex/blob/main/.codex/skills/codex-bug/SKILL.md)\n</details>\n\n# 技能系统\n\n## 概述\n\n技能系统（Skills System）是 Codex CLI 中的一个可扩展机制，允许用户通过自定义技能配置来增强 Codex 执行特定任务的能力。技能系统为 Codex 提供了额外的上下文信息和行为指导，使其能够更精准地理解和处理特定的开发任务场景。\n\n根据源码注释，技能系统的主要用途是：**\"use skills to improve how Codex performs specific tasks\"**（使用技能来改进 Codex 执行特定任务的方式）。\n\n## 核心架构\n\n### 模块结构\n\n技能系统的核心实现位于 `codex-rs/core-skills/` 目录下，采用模块化设计：\n\n| 模块 | 文件路径 | 职责 |\n|------|----------|------|\n| 核心接口 | `codex-rs/core-skills/src/lib.rs` | 定义技能系统的公共 API 和数据结构 |\n| 技能管理器 | `codex-rs/core-skills/src/manager.rs` | 负责技能的生命周期管理和调用逻辑 |\n| 技能加载器 | `codex-rs/core-skills/src/loader.rs` | 处理技能配置的加载和解析 |\n\n### 架构图\n\n```mermaid\ngraph TD\n    A[用户通过 /skills 命令触发] --> B[技能管理器 manager.rs]\n    B --> C[技能加载器 loader.rs]\n    C --> D[读取 .codex/skills/ 目录]\n    D --> E[解析 SKILL.md 配置文件]\n    E --> F[加载技能定义]\n    F --> G[向主上下文注入技能指令]\n    G --> H[增强 Codex 任务执行能力]\n    \n    style A fill:#e1f5fe\n    style H fill:#c8e6c9\n```\n\n## 技能定义格式\n\n### SKILL.md 文件结构\n\n技能通过 `.codex/skills/` 目录下的 `SKILL.md` 文件定义。每个技能目录代表一个独立的技能模块。\n\n技能配置采用 Markdown 格式，包含以下关键部分：\n\n| 组成部分 | 说明 |\n|----------|------|\n| 技能名称 | 技能的标识名称 |\n| 触发条件 | 定义何时激活该技能 |\n| 行为指令 | 告诉 Codex 如何处理特定任务的指令集 |\n| 示例用法 | 提供技能使用的示例场景 |\n\n### 现有技能示例\n\n仓库中预置了两个技能：\n\n| 技能名称 | 路径 | 用途 |\n|----------|------|------|\n| code-review | `.codex/skills/code-review/SKILL.md` | 代码审查技能 |\n| codex-bug | `.codex/skills/codex-bug/SKILL.md` | Bug 定位与修复技能 |\n\n## 技能管理器\n\n技能管理器（`manager.rs`）是技能系统的核心组件，负责以下职责：\n\n### 主要功能\n\n| 功能 | 描述 |\n|------|------|\n| 技能注册 | 将可用的技能注册到系统中 |\n| 技能选择 | 根据上下文选择合适的技能 |\n| 技能激活 | 在适当时机触发技能生效 |\n| 技能卸载 | 清理不再需要的技能资源 |\n\n### 管理器状态\n\n```mermaid\nstateDiagram-v2\n    [*] --> 未初始化: 系统启动\n    未初始化 --> 已加载: loader 解析成功\n    已加载 --> 就绪: 技能注册完成\n    就绪 --> 激活: 满足触发条件\n    激活 --> 就绪: 任务完成\n    激活 --> 已加载: 技能禁用\n    已加载 --> [*]: 系统关闭\n```\n\n## 技能加载器\n\n技能加载器（`loader.rs`）负责从文件系统读取和解析技能配置：\n\n### 加载流程\n\n```mermaid\ngraph LR\n    A[扫描 skills 目录] --> B[读取 SKILL.md]\n    B --> C[解析 Markdown]\n    C --> D[验证技能格式]\n    D --> E[构建技能对象]\n    E --> F[返回技能实例]\n    \n    D -->|格式错误| G[记录诊断信息]\n```\n\n### 配置路径\n\n| 路径类型 | 位置 | 说明 |\n|----------|------|------|\n| 用户级技能 | `~/.codex/skills/` | 用户自定义技能 |\n| 项目级技能 | `.codex/skills/` | 特定项目的技能配置 |\n| 系统级技能 | 内置 | Codex 预置的默认技能 |\n\n## 使用方式\n\n### 命令行交互\n\n用户可以通过斜杠命令（Slash Command）来访问技能功能：\n\n```bash\n/codex skills\n```\n\n此命令将显示可用的技能列表并允许用户选择激活特定技能。\n\n### 技能触发机制\n\n技能可以通过以下方式激活：\n\n| 触发方式 | 描述 |\n|----------|------|\n| 手动激活 | 用户通过 `/skills` 命令显式选择 |\n| 自动检测 | 系统根据任务上下文自动推荐相关技能 |\n| 规则匹配 | 根据文件路径或任务类型自动匹配技能 |\n\n## 配置与扩展\n\n### 添加自定义技能\n\n创建自定义技能的步骤：\n\n1. 在 `.codex/skills/` 目录下创建新的技能文件夹\n2. 在文件夹中创建 `SKILL.md` 文件\n3. 按照技能定义格式编写技能配置\n4. 重启 Codex 或使用 `/skills reload` 重新加载技能\n\n### 技能优先级\n\n当多个技能同时匹配时，系统按照以下优先级处理：\n\n| 优先级 | 来源 | 说明 |\n|--------|------|------|\n| 1 (最高) | 命令行参数 | 通过 `--skill` 参数指定的技能 |\n| 2 | 项目级技能 | `.codex/skills/` 中的配置 |\n| 3 | 用户级技能 | `~/.codex/skills/` 中的配置 |\n| 4 (最低) | 系统内置 | Codex 默认技能 |\n\n## 与其他系统集成\n\n### 与上下文系统集成\n\n技能系统的输出会作为环境上下文的一部分传递给 Codex：\n\n```xml\n<environment>\n  <skills>\n    <!-- 激活的技能配置 -->\n  </skills>\n</environment>\n```\n\n### 与权限系统集成\n\n技能执行受到权限系统（Permissions System）的约束，确保技能操作在用户授权范围内进行。\n\n### 与配置系统集成\n\n技能配置通过主配置系统（`codex-rs/config/`）进行管理，支持按配置文件 profiles 进行作用域限定。\n\n## 诊断与调试\n\n### 技能状态检查\n\n使用 `/debug-config` 命令可以查看技能相关的配置层和来源信息。\n\n### 常见问题排查\n\n| 问题 | 可能原因 | 解决方案 |\n|------|----------|----------|\n| 技能未显示 | 配置文件格式错误 | 检查 SKILL.md 语法 |\n| 技能不生效 | 触发条件未满足 | 确认任务上下文匹配 |\n| 加载失败 | 文件权限问题 | 检查文件读取权限 |\n\n## 相关命令\n\n| 命令 | 功能 |\n|------|------|\n| `/skills` | 列出和管理可用技能 |\n| `/debug-config` | 显示配置层和技能来源 |\n| `/permissions` | 管理技能执行权限 |\n\n## 最佳实践\n\n1. **技能粒度**：保持技能职责单一，每个技能专注于一个特定任务类型\n2. **命名规范**：使用清晰描述性的技能名称，便于识别和选择\n3. **文档完善**：在 SKILL.md 中提供详细的使用说明和示例\n4. **版本兼容**：定期更新技能配置以适配 Codex 版本变化\n5. **权限考虑**：明确技能所需权限，避免过度授权\n\n## 参考资料\n\n- 技能核心实现：[codex-rs/core-skills/src/lib.rs](https://github.com/openai/codex/blob/main/codex-rs/core-skills/src/lib.rs)\n- 技能管理器：[codex-rs/core-skills/src/manager.rs](https://github.com/openai/codex/blob/main/codex-rs/core-skills/src/manager.rs)\n- 技能加载器：[codex-rs/core-skills/src/loader.rs](https://github.com/openai/codex/blob/main/codex-rs/core-skills/src/loader.rs)\n- 代码审查技能示例：[.codex/skills/code-review/SKILL.md](https://github.com/openai/codex/blob/main/.codex/skills/code-review/SKILL.md)\n- Bug 定位技能示例：[.codex/skills/codex-bug/SKILL.md](https://github.com/openai/codex/blob/main/.codex/skills/codex-bug/SKILL.md)\n- 斜杠命令定义：[codex-rs/tui/src/slash_command.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n- 配置系统集成：[codex-rs/config/src/state.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n\n---\n\n<a id='page-plugins'></a>\n\n## 插件系统\n\n### 相关页面\n\n相关主题：[技能系统](#page-skills)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/tui/src/slash_command.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n- [codex-rs/README.md](https://github.com/openai/codex/blob/main/codex-rs/README.md)\n- [codex-rs/config/src/config_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n- [codex-rs/config/src/profile_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/profile_toml.rs)\n- [codex-rs/README.md](https://github.com/openai/codex/blob/main/codex-rs/README.md)\n</details>\n\n# 插件系统\n\n## 概述\n\nCodex CLI 的插件系统（Plugins）是扩展主程序功能的核心模块，允许用户通过插件机制定制和增强 Codex 的行为。该系统与应用程序管理（Apps）和 MCP（Model Context Protocol）协议共同构成了 Codex 的可扩展性架构。\n\n插件系统的主要入口是通过命令行斜杠命令 `/plugins` 访问，用户可以浏览已安装的插件。 资料来源：[codex-rs/tui/src/slash_command.rs:行53]()\n\n## 架构组成\n\n### 核心组件\n\n| 组件 | 功能描述 |\n|------|----------|\n| Apps 管理 | 管理和启动独立的应用程序实例 |\n| MCP 客户端 | 连接外部 MCP 服务器以使用第三方工具 |\n| MCP 服务器 | 将 Codex 作为 MCP 服务器暴露给其他客户端 |\n| 插件框架 | 允许第三方代码扩展 Codex 的核心功能 |\n\n### 配置文件支持\n\nCodex 在配置层面支持插件相关功能，通过 `config.toml` 和 `profile.toml` 中的字段控制插件行为：\n\n```toml\n# 包含应用指令\ninclude_apps_instructions = true  # 控制是否注入应用相关指令\n```\n\n资料来源：[codex-rs/config/src/config_toml.rs:行1-100]()\n\n```toml\n[features]\n# 可在 profile 中配置特性开关\n```\n\n资料来源：[codex-rs/config/src/profile_toml.rs:行1-50]()\n\n## 命令行接口\n\n### 斜杠命令\n\n| 命令 | 功能 |\n|------|------|\n| `/plugins` | 浏览可用插件 |\n| `/apps` | 管理系统应用 |\n| `/mcp` | 列出已配置的 MCP 工具 |\n\n资料来源：[codex-rs/tui/src/slash_command.rs:行48-55]()\n\n```rust\nSlashCommand::Plugins => \"browse plugins\",\nSlashCommand::Apps => \"manage apps\",\nSlashCommand::Mcp => \"list configured MCP tools; use /mcp verbose for details\",\n```\n\n## MCP 协议集成\n\n### MCP 客户端模式\n\nCodex CLI 作为 MCP 客户端，可在启动时连接到外部 MCP 服务器。这种模式允许 Codex 访问由第三方提供的工具和服务。\n\n> 注意：详细配置方法请参阅[配置文档](../docs/config.md#connecting-to-mcp-servers)\n\n资料来源：[codex-rs/README.md:行1-100]()\n\n### MCP 服务器模式（实验性）\n\nCodex 可以作为 MCP 服务器运行，允许其他 MCP 客户端连接到 Codex 并使用其功能：\n\n```shell\ncodex mcp-server\n```\n\n资料来源：[codex-rs/README.md:行1-100]()\n\n## 工作流程图\n\n```mermaid\ngraph TD\n    A[用户启动 Codex] --> B{插件配置检查}\n    B -->|有 MCP 配置| C[连接 MCP 服务器]\n    B -->|有 Apps 配置| D[加载应用模块]\n    B -->|有 Plugins 配置| E[初始化插件]\n    C --> F[Codex 运行中]\n    D --> F\n    E --> F\n    F --> G[用户可通过 /plugins 浏览插件]\n    F --> H[用户可通过 /apps 管理应用]\n    F --> I[用户可通过 /mcp 查看 MCP 工具]\n```\n\n## 配置层级\n\n插件系统的配置遵循 Codex 的配置层级架构：\n\n```mermaid\ngraph TD\n    A[配置层级架构]\n    A --> B[System 配置]\n    A --> C[User 配置]\n    A --> D[Project 配置]\n    A --> E[Session Flags]\n    B --> F[最终生效配置]\n    C --> F\n    D --> F\n    E --> F\n```\n\n| 配置层级 | 说明 |\n|----------|------|\n| System | 系统级配置文件 |\n| User | 用户主目录配置 |\n| Project | 项目 .codex 目录配置 |\n| Session Flags | 会话级别命令行参数 |\n\n资料来源：[codex-rs/config/src/state.rs:行1-50]()\n\n## 应用与插件的集成\n\nApps（应用程序）和 Plugins（插件）在功能上有重叠和互补关系：\n\n- **Apps** 通常指完整的应用程序模块，可以通过 `/apps` 命令管理\n- **Plugins** 指可插拔的功能扩展，通过 `/plugins` 浏览\n\n两者都可以在配置中启用或禁用，通过 `include_apps_instructions` 配置项控制是否向模型注入应用相关的指令提示。\n\n资料来源：[codex-rs/config/src/profile_toml.rs:行1-50]()\n\n## 使用场景\n\n### 场景一：连接外部工具\n\n用户可以配置 MCP 服务器以连接外部开发工具：\n\n```toml\n[mcp]\nservers = [\"my-mcp-server\"]\n```\n\n### 场景二：安装应用\n\n通过 Apps 系统，用户可以安装和管理预配置的应用程序：\n\n```shell\n/apps install <app-name>\n```\n\n### 场景三：浏览插件\n\n```shell\n/plugins browse\n```\n\n## 相关命令速查\n\n| 命令 | 描述 |\n|------|------|\n| `/plugins` | 浏览已安装插件 |\n| `/apps` | 管理应用程序 |\n| `/mcp` | 查看 MCP 工具列表 |\n| `/mcp verbose` | 查看 MCP 详细配置 |\n| `codex mcp-server` | 启动 MCP 服务器模式 |\n\n## 下一步\n\n- 详细配置方法：参见[配置文档](../docs/config.md)\n- 快速入门：参见[入门指南](../docs/getting-started.md)\n- MCP 服务器配置：参见 [Model Context Protocol 支持](../docs/config.md#connecting-to-mcp-servers)\n\n---\n\n<a id='page-hooks'></a>\n\n## Hook系统\n\n### 相关页面\n\n相关主题：[技能系统](#page-skills), [核心Agent模块](#page-core-agent)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/hooks/src/lib.rs](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/lib.rs)\n- [codex-rs/hooks/src/engine/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/mod.rs)\n- [codex-rs/hooks/src/declarations.rs](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/declarations.rs)\n- [codex-rs/hooks/schema/generated](https://github.com/openai/codex/blob/main/codex-rs/hooks/schema/generated)\n</details>\n\n# Hook系统\n\n## 概述\n\nHook系统是Codex CLI中用于在关键生命周期节点注入自定义逻辑的核心扩展机制。通过Hook，管理员、用户和项目开发者可以在Codex执行过程中的特定时刻介入，控制行为、注入上下文、验证权限或收集反馈。 资料来源：[codex-rs/tui/src/slash_command.rs:15]()\n\n## 核心概念\n\n### Hook的本质\n\nHook是一种声明式的回调机制，允许外部代码在Codex运行时截获特定事件并返回响应。每个Hook由以下要素组成：\n\n| 要素 | 说明 |\n|------|------|\n| 事件类型 | Hook被触发的时机 |\n| 源配置 | Hook定义来自哪个配置层级 |\n| 执行逻辑 | Hook被触发时运行的代码 |\n| 返回结果 | Hook对后续行为的指导 |\n\n### 配置层级\n\nHook的配置遵循Codex的分层配置体系，从低优先级到高优先级依次为：\n\n1. **系统级（System）** - 管理员全局配置\n2. **MDM级（Mdm）** - 移动设备管理配置\n3. **云端要求（CloudRequirements）** - 云端下发的强制要求\n4. **项目级（Project）** - `.codex/`目录中的项目配置\n5. **用户级（User）** - 用户个人配置\n6. **会话标志（SessionFlags）** - 命令行会话参数\n7. **插件（Plugin）** - 第三方插件提供\n\n资料来源：[codex-rs/tui/src/hooks_browser_view.rs:45-58]()\n\n## 事件类型\n\nCodex Hook系统在以下事件节点触发Hook：\n\n| 事件名称 | 触发时机 | 典型用途 |\n|----------|----------|----------|\n| `SessionStart` | 会话启动时 | 初始化上下文、设置会话级别变量 |\n| `UserPromptSubmit` | 用户提交提示词时 | 验证输入、注入额外上下文 |\n| `PreToolUse` | 工具执行前 | 权限检查、参数修改、拒绝执行 |\n| `PostToolUse` | 工具执行后 | 记录日志、处理结果、添加反馈 |\n| `PreCompact` | 历史压缩前 | 选择性保留关键对话 |\n| `PostCompact` | 历史压缩后 | 验证压缩结果 |\n| `PermissionRequest` | 权限请求时 | 自定义权限审批流程 |\n| `Stop` | Codex结束回合前 | 最终清理、状态保存 |\n\n资料来源：[codex-rs/tui/src/history_cell/hook_cell.rs:30-42]()\n\n## Hook输出类型\n\nHook可以向用户或系统返回多种类型的输出：\n\n| 输出类型 | 前缀标识 | 含义 |\n|----------|----------|------|\n| `Warning` | `warning:` | 警告信息，Hook继续执行 |\n| `Stop` | `stop:` | 停止当前操作 |\n| `Feedback` | `feedback:` | 向用户提供反馈文本 |\n| `Context` | `hook context:` | 注入额外上下文信息 |\n| `Error` | `error:` | 错误信息，终止操作 |\n\n资料来源：[codex-rs/tui/src/history_cell/hook_cell.rs:12-17]()\n\n## 系统架构\n\n```mermaid\ngraph TD\n    A[Codex运行时] --> B[Hook引擎]\n    B --> C{事件类型判断}\n    C -->|PreToolUse| D[执行PreToolUse Hooks]\n    C -->|PostToolUse| E[执行PostToolUse Hooks]\n    C -->|SessionStart| F[执行SessionStart Hooks]\n    C -->|UserPromptSubmit| G[执行UserPromptSubmit Hooks]\n    C -->|其他事件| H[执行对应Hooks]\n    \n    D --> I[收集输出结果]\n    E --> I\n    F --> I\n    G --> I\n    H --> I\n    \n    I --> J{Hook决定}\n    J -->|继续| K[执行下一阶段]\n    J -->|停止| L[终止操作]\n    J -->|上下文| M[注入上下文后继续]\n    J -->|反馈| N[显示反馈信息]\n    \n    K --> O[返回结果给调用方]\n    L --> P[返回错误/停止原因]\n    N --> O\n    \n    style B fill:#e1f5fe\n    style D fill:#fff3e0\n    style I fill:#f3e5f5\n```\n\n## 配置管理\n\n### Hook配置文件位置\n\nHook的配置文件位置遵循以下优先级规则：\n\n```rust\npub fn hooks_config_folder(&self) -> Option<AbsolutePathBuf> {\n    self.hooks_config_folder_override\n        .clone()\n        .or_else(|| self.config_folder())\n}\n```\n\n对于不同配置源，Hook配置文件夹的确定方式为：\n\n| 配置源 | 配置文件夹位置 |\n|--------|----------------|\n| System | `file.parent()` |\n| User | `file.parent()` |\n| Project | `dot_codex_folder`（`.codex/`目录） |\n| MDM/SessionFlags | 无专用文件夹 |\n\n资料来源：[codex-rs/config/src/state.rs:140-152]()\n\n### 命名规则\n\nHook配置文件通常命名为 `hooks.toml`，位于各层级的配置目录中。\n\n## TUI集成\n\n### Hook浏览器视图\n\n在TUI中，用户可以通过 `/hooks` 命令访问Hook浏览器，查看当前会话可用的所有Hook：\n\n```mermaid\ngraph LR\n    A[/hooks命令] --> B[Hook浏览器视图]\n    B --> C[按源分组显示]\n    C --> D[显示Hook元数据]\n    D --> E[显示Hook详情]\n```\n\n### Hook元数据显示\n\nHook浏览器中显示的关键信息包括：\n\n| 显示项 | 来源 | 说明 |\n|--------|------|------|\n| 源标签 | `HookSource` | System/User/Project等 |\n| 插件ID | `plugin_id` | 插件提供的Hook专属 |\n| 源路径 | `source_path` | 配置文件路径 |\n| 事件类型 | `HookEventName` | 触发的事件 |\n\n资料来源：[codex-rs/tui/src/hooks_browser_view.rs:35-60]()\n\n## 使用方式\n\n### 命令行接口\n\n| 命令 | 功能 |\n|------|------|\n| `/hooks` | 查看和管理局域网Hook |\n\n资料来源：[codex-rs/tui/src/slash_command.rs:15]()\n\n### 快捷键配置\n\nHook相关的快捷键可通过 `/keymap` 命令自定义配置：\n\n| 操作 | 默认快捷键 |\n|------|------------|\n| Hook浏览器导航 | 方向键 |\n\n## 权限与安全\n\n### 权限级别\n\nHook的执行受Codex权限系统约束：\n\n- **管理员Hook** - 可执行高权限操作\n- **用户Hook** - 受用户权限限制\n- **项目Hook** - 受项目配置限制\n- **插件Hook** - 受插件声明的权限限制\n\n### 风险级别\n\nHook执行结果会映射到Guardian风险级别：\n\n| Hook决定 | 风险级别 |\n|----------|----------|\n| 允许继续 | Low |\n| 添加条件 | Medium |\n| 要求确认 | High |\n| 拒绝执行 | Critical |\n\n## 高级特性\n\n### 实验性Hook\n\n部分Hook功能标记为实验性：\n\n- `experimental_compact_prompt_file` - 自定义压缩提示词文件\n- `experimental_use_unified_exec_tool` - 统一执行工具\n- `experimental_use_freeform_apply_patch` - 自由格式补丁\n\n资料来源：[codex-rs/config/src/profile_toml.rs:25-35]()\n\n### 状态行显示\n\nHook执行状态可显示在TUI状态行：\n\n| 状态项 | 显示内容 |\n|--------|----------|\n| Hook输出 | Warning/Stop/Error等标记 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_line_style.rs:20-30]()\n\n## 与其他系统集成\n\n### 配置系统\n\nHook声明是配置层级的组成部分，支持完整的配置诊断：\n\n```rust\nfn config_toml_path_for_layer(\n    layer: &ConfigLayerEntry, \n    config_toml_file: &str\n) -> Option<PathBuf> {\n    match &layer.name {\n        ConfigLayerSource::System { file } => Some(file.to_path_buf()),\n        ConfigLayerSource::User { file } => Some(file.to_path_buf()),\n        ConfigLayerSource::Project { dot_codex_folder } => {\n            Some(dot_codex_folder.as_path().join(config_toml_file))\n        }\n        _ => None,\n    }\n}\n```\n\n资料来源：[codex-rs/config/src/diagnostics.rs:15-27]()\n\n### 工具系统\n\nPreToolUse和PostToolUse Hook与工具系统紧密集成：\n\n```mermaid\nsequenceDiagram\n    participant U as 用户\n    participant C as Codex\n    participant H as PreToolUse Hook\n    participant T as 工具\n    participant P as PostToolUse Hook\n    \n    U->>C: 执行工具请求\n    C->>H: 触发PreToolUse\n    H-->>C: 决定：允许/拒绝/修改\n    alt 允许执行\n        C->>T: 调用工具\n        T-->>C: 返回结果\n        C->>P: 触发PostToolUse\n        P-->>C: 反馈/上下文\n        C-->>U: 显示结果\n    else 拒绝执行\n        C-->>U: 显示拒绝原因\n    end\n```\n\n## 故障排查\n\n### 常见问题\n\n| 问题 | 可能原因 | 解决方案 |\n|------|----------|----------|\n| Hook未触发 | 事件类型不匹配 | 检查Hook声明的事件类型 |\n| Hook无效 | 配置解析错误 | 运行 `/debug-config` 检查 |\n| 权限不足 | Hook源权限受限 | 提升配置层级权限 |\n\n### 调试命令\n\n| 命令 | 用途 |\n|------|------|\n| `/debug-config` | 显示配置层级和来源 |\n| `/status` | 查看当前会话配置 |\n\n## 最佳实践\n\n1. **分层管理** - 按优先级合理分配Hook到不同配置层级\n2. **最小权限** - 仅授予Hook必要的权限\n3. **清晰命名** - 使用描述性的Hook名称便于维护\n4. **错误处理** - 在Hook中实现健壮的错误处理\n5. **测试验证** - 在非生产环境测试Hook行为\n\n## 相关文档\n\n- [配置系统](../config.md) - 了解配置层级\n- [权限系统](../permissions.md) - 权限管理详情\n- [插件系统](../plugins.md) - 第三方扩展开发\n- [TUI快捷键](../keymap.md) - 自定义快捷键配置\n\n---\n\n<a id='page-sandboxing'></a>\n\n## 沙箱与安全\n\n### 相关页面\n\n相关主题：[执行系统](#page-execution)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/tui/src/bottom_pane/approval_overlay.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/approval_overlay.rs)\n- [codex-rs/config/src/state.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n- [codex-rs/config/src/loader/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/loader/mod.rs)\n- [codex-rs/config/src/config_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n- [codex-rs/config/src/diagnostics.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/diagnostics.rs)\n</details>\n\n# 沙箱与安全\n\nCodex CLI 的沙箱与安全系统是保护用户系统免受恶意操作或意外文件修改的核心机制。该系统通过多层次的权限控制、审批流程和文件系统路径限制来确保代码执行的安全性。\n\n## 系统架构概述\n\nCodex 的安全架构采用分层设计，将配置源、权限决策和文件系统隔离有机结合。系统支持多种配置层，包括系统级、用户级和项目级配置，每一层都有独立的权限优先级和作用范围。\n\n```mermaid\ngraph TD\n    A[用户操作] --> B{权限检查}\n    B --> C{文件路径类型}\n    C --> D[:root - 根目录]\n    C --> E[:minimal - 最小路径]\n    C --> F[:project_roots - 项目根目录]\n    C --> G[/tmp - 临时目录]\n    D --> H{审批决策}\n    E --> H\n    F --> H\n    G --> H\n    H --> I[Approval - 执行]\n    H --> J[AcceptForSession - 本次会话接受]\n    H --> K[Reject - 拒绝执行]\n```\n\n## 权限配置系统\n\n### 配置层源\n\nCodex 使用 `ConfigLayerSource` 枚举来管理不同来源的配置层级，每个层级对应不同的安全边界和应用范围。\n\n| 配置层类型 | 说明 | 优先级 |\n|-----------|------|--------|\n| System | 系统级配置文件 | 最低 |\n| User | 用户主目录配置 | 中低 |\n| Project | `.codex/` 项目配置 | 中高 |\n| Mdm | 移动设备管理配置 | 高 |\n| SessionFlags | 会话级命令行标志 | 最高 |\n\n资料来源：[codex-rs/config/src/state.rs:1-20]()\n\n### 权限决策类型\n\n权限审批系统通过 `ApprovalDecision` 和 `FileChangeApprovalDecision` 枚举处理用户对文件操作的授权决策。\n\n```rust\npub enum ApprovalDecision {\n    FileChange(FileChangeApprovalDecision),\n    // ... 其他变体\n}\n\npub enum FileChangeApprovalDecision {\n    Accept,              // 立即执行\n    AcceptForSession,    // 本次会话接受，后续不再询问\n    // 拒绝决策由用户交互产生\n}\n```\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:1-50]()\n\n### 特殊文件系统路径\n\n系统定义了特殊的文件系统路径标识符，用于限制 Codex 的操作范围：\n\n| 路径标识 | 说明 | 示例 |\n|---------|------|------|\n| `:root` | 文件系统根目录 | `/` |\n| `:minimal` | 最小限制路径 | 用户定义的最小访问范围 |\n| `:project_roots` | 项目根目录 | 包含 `.codex/` 的目录 |\n| `:tmpdir` | 系统临时目录 | `/tmp` |\n| `:unknown` | 未识别的特殊路径 | 自定义路径 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:80-95]()\n\n## 文件审批流程\n\n### 审批选项\n\n当 Codex 需要修改文件或执行敏感操作时，会向用户展示审批选项界面：\n\n| 选项标签 | 决策类型 | 快捷键 |\n|---------|---------|--------|\n| \"Yes, proceed\" | Accept | 可自定义 |\n| \"Yes, and don't ask again for these files\" | AcceptForSession | 可自定义 |\n| \"No, and tell Codex what to do differently\" | Reject | 可自定义 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:150-170]()\n\n### 路径显示格式化\n\n系统通过 `path_label` 函数将文件系统路径转换为用户可读的格式：\n\n```rust\nfn path_label(base: &str, subpath: &Option<PathBuf>) -> String {\n    match subpath {\n        Some(subpath) => format!(\"{base}/{}\", subpath.display()),\n        None => base.to_string(),\n    }\n}\n```\n\n该函数处理带有子路径的特殊路径标识符，例如 `:project_roots/subdir` 会被格式化为用户友好的显示形式。\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:75-82]()\n\n## 配置验证与诊断\n\n### 配置错误处理\n\nCodex 提供配置诊断功能，能够检测并报告配置文件中的错误，包括权限相关的配置问题。\n\n```rust\npub fn format_config_error(error: &ConfigError, contents: &str) -> String {\n    let mut output = String::new();\n    let start = error.range.start;\n    write!(\n        output,\n        \"{}:{}:{}: {}\",\n        error.path.display(),\n        start.line,\n        start.column,\n        error.message\n    );\n    // ...\n}\n```\n\n诊断系统会显示错误的具体位置（文件路径、行号、列号）和错误消息，帮助用户修正配置问题。\n\n资料来源：[codex-rs/config/src/diagnostics.rs:40-55]()\n\n### 配置文件定位\n\n系统根据配置层类型自动定位对应的配置文件路径：\n\n| 配置层源 | 返回路径 |\n|---------|---------|\n| System | 系统配置文件路径 |\n| User | 用户配置文件路径 |\n| Project | `.codex/config.toml` |\n| Mdm | MDM 配置文件路径 |\n| SessionFlags | 无对应文件（None） |\n\n资料来源：[codex-rs/config/src/diagnostics.rs:1-20]()\n\n## 项目级配置隔离\n\n### 钩子配置文件夹\n\n项目层级配置使用独立的 `.codex/` 文件夹存储钩子声明。系统支持 Git 工作树链接场景，主仓库和工作树可以共享钩子配置。\n\n```rust\npub fn hooks_config_folder(&self) -> Option<AbsolutePathBuf> {\n    self.hooks_config_folder_override\n        .clone()\n        .or_else(|| self.config_folder())\n}\n```\n\n该方法优先返回覆盖值，否则回退到常规配置文件夹位置。\n\n资料来源：[codex-rs/config/src/state.rs:80-90]()\n\n### 项目配置合并\n\n加载项目配置时会执行多项安全检查：\n\n1. 验证配置文件格式有效性\n2. 忽略不受支持的配置键并记录警告\n3. 解析相对路径为绝对路径\n4. 合并主仓库与工作树的钩子配置\n\n```rust\nlet ignored_project_config_keys = sanitize_project_config(&mut config);\nlet config = resolve_relative_paths_in_config_toml(config, dot_codex_abs.as_path())?;\nlet config = merge_root_checkout_project_hooks(\n    fs,\n    config,\n    hooks_config_folder_override.as_ref(),\n    decision.is_trusted(),\n)\n.await?;\n```\n\n资料来源：[codex-rs/config/src/loader/mod.rs:1-50]()\n\n## 安全边界控制\n\n### 信任决策\n\n配置加载器根据 `decision.is_trusted()` 判断当前操作是否来自可信来源。可信来源享有更严格的错误报告机制，而不可信来源则采用容错处理。\n\n### 相对路径解析\n\n为防止路径遍历攻击，所有相对路径在加载时都会被解析为绝对路径：\n\n```rust\npub fn resolve_relative_paths_in_config_toml(\n    config: TomlValue,\n    base_path: &Path,\n) -> Result<TomlValue, ConfigError> {\n    // 将所有相对路径转换为基于 base_path 的绝对路径\n}\n```\n\n资料来源：[codex-rs/config/src/loader/mod.rs:30-40]()\n\n## 权限相关配置项\n\n### 文件系统操作权限\n\n| 配置项 | 类型 | 说明 |\n|-------|------|------|\n| `include_permissions_instructions` | bool | 是否注入权限指令 |\n| `include_environment_context` | bool | 是否注入环境上下文 |\n| `include_apply_patch_tool` | bool | 是否包含补丁应用工具 |\n| `experimental_use_freeform_apply_patch` | bool | 自由形式补丁应用（实验性） |\n\n资料来源：[codex-rs/config/src/config_toml.rs:1-30]()\n\n### 审批模式显示\n\n系统根据配置显示当前权限状态和审批模式：\n\n```rust\nStatusLineItem::Permissions => Some(permissions_display(&self.config)),\nStatusLineItem::ApprovalMode => Some(approval_mode_display(&self.config)),\n```\n\n用户可以在状态栏直接查看当前工作区的权限级别和审批模式设置。\n\n资料来源：[codex-rs/tui/src/chatwidget/status_surfaces.rs:1-30]()\n\n## 快捷键自定义\n\n用户可以通过 `/keymap` 命令自定义安全相关的快捷键，包括审批决策的快捷键映射：\n\n| 快捷键 ID | 说明 |\n|----------|------|\n| Approval | 审批确认 |\n| ApprovalForSession | 本次会话接受 |\n| ExternalEditor | 外部编辑器 |\n| FilePaths | 文件路径显示 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/footer.rs:1-50]()\n\n## 总结\n\nCodex 的沙箱与安全系统通过以下核心机制保护用户系统：\n\n- **多层级配置管理**：系统、用户、项目级配置各有独立的安全边界\n- **文件审批流程**：敏感操作需用户明确授权\n- **路径隔离**：使用特殊路径标识符限制操作范围\n- **配置验证**：实时检测并报告配置错误\n- **路径规范化**：防止路径遍历和相对路径攻击\n\n该系统设计确保了 Codex 在执行代码操作时既有足够的灵活性，又不会在未经授权的情况下损害用户系统的完整性。\n\n---\n\n---\n\n## Doramagic 踩坑日志\n\n项目：openai/codex\n\n摘要：发现 21 个潜在踩坑项，其中 5 个为 high/blocking；最高优先级：安装坑 - 来源证据：Selected model is at capacity. Please try a different model. The same error everyday。\n\n## 1. 安装坑 · 来源证据：Selected model is at capacity. Please try a different model. The same error everyday\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Selected model is at capacity. Please try a different model. The same error everyday\n- 对用户的影响：可能阻塞安装或首次运行。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_2839c851344f4b669bd1c21b29e7bd08 | https://github.com/openai/codex/issues/22456 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 2. 维护坑 · 来源证据：Extensive UI flickering when codex is working\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：Extensive UI flickering when codex is working\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_47a11c3a9f3943168527e0a086872c1f | https://github.com/openai/codex/issues/11901 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 3. 安全/权限坑 · 来源证据：Codex Desktop voice transcription blocked by Cloudflare challenge on /backend-api/transcribe after resolved incident\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Codex Desktop voice transcription blocked by Cloudflare challenge on /backend-api/transcribe after resolved incident\n- 对用户的影响：可能阻塞安装或首次运行。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_dcdaacada441496491e68dd4db3d802b | https://github.com/openai/codex/issues/21985 | 来源讨论提到 macos 相关条件，需在安装/试用前复核。\n\n## 4. 安全/权限坑 · 来源证据：Codex IDE extension fails GitHub MCP startup with \"connection closed: initialize response\" in PyCharm AI Chat\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Codex IDE extension fails GitHub MCP startup with \"connection closed: initialize response\" in PyCharm AI Chat\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_45286dbe57a44800be79bc6a5819956f | https://github.com/openai/codex/issues/22461 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 5. 安全/权限坑 · 来源证据：Iranian phone numbers are not supported for Codex login\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Iranian phone numbers are not supported for Codex login\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_d651d7b5cf594cafa27dfffa45890baa | https://github.com/openai/codex/issues/21918 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 6. 安装坑 · 来源证据：Codex Desktop falsely reports @chrome plugin unavailable when bundled Chrome plugin is installed\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Codex Desktop falsely reports @chrome plugin unavailable when bundled Chrome plugin is installed\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_a0eee5b5c5fb447ebe2c2d3bdf74aa33 | https://github.com/openai/codex/issues/22463 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 7. 安装坑 · 来源证据：Windows Chrome plugin hangs in setupAtlasRuntime despite extension/native host checks passing\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Windows Chrome plugin hangs in setupAtlasRuntime despite extension/native host checks passing\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_4d667016a4ab4f9aa5416a3b08e71d55 | https://github.com/openai/codex/issues/22462 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 8. 能力坑 · 能力判断依赖假设\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：README/documentation is current enough for a first validation pass.\n- 对用户的影响：假设不成立时，用户拿不到承诺的能力。\n- 建议检查：将假设转成下游验证清单。\n- 防护动作：假设必须转成验证项；没有验证结果前不能写成事实。\n- 证据：capability.assumptions | github_repo:965415649 | https://github.com/openai/codex | README/documentation is current enough for a first validation pass.\n\n## 9. 运行坑 · 来源证据：/goal-first sessions are missing from resume lists\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个运行相关的待验证问题：/goal-first sessions are missing from resume lists\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_e65f6682c39b409a8c96267f4bdc1d3e | https://github.com/openai/codex/issues/20792 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 10. 维护坑 · 来源证据：I have to set up the workspace every time I start a new session. My Codex usage quota is decreasing automatically even…\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：I have to set up the workspace every time I start a new session. My Codex usage quota is decreasing automatically even though I haven’t used it at all.\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_f8afe7124b3e44cfacbc62a9e001179c | https://github.com/openai/codex/issues/22457 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 11. 维护坑 · 来源证据：Renaming session with enter triggers the session window\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：Renaming session with enter triggers the session window\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_a49c134e628047c1b558f3286721d0e7 | https://github.com/openai/codex/issues/22460 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 12. 维护坑 · 维护活跃度未知\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：未记录 last_activity_observed。\n- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。\n- 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。\n- 防护动作：维护活跃度未知时，推荐强度不能标为高信任。\n- 证据：evidence.maintainer_signals | github_repo:965415649 | https://github.com/openai/codex | last_activity_observed missing\n\n## 13. 安全/权限坑 · 下游验证发现风险项\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：下游已经要求复核，不能在页面中弱化。\n- 建议检查：进入安全/权限治理复核队列。\n- 防护动作：下游风险存在时必须保持 review/recommendation 降级。\n- 证据：downstream_validation.risk_items | github_repo:965415649 | https://github.com/openai/codex | no_demo; severity=medium\n\n## 14. 安全/权限坑 · 存在安全注意事项\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：No sandbox install has been executed yet; downstream must verify before user use.\n- 对用户的影响：用户安装前需要知道权限边界和敏感操作。\n- 建议检查：转成明确权限清单和安全审查提示。\n- 防护动作：安全注意事项必须面向用户前置展示。\n- 证据：risks.safety_notes | github_repo:965415649 | https://github.com/openai/codex | No sandbox install has been executed yet; downstream must verify before user use.\n\n## 15. 安全/权限坑 · 存在评分风险\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：风险会影响是否适合普通用户安装。\n- 建议检查：把风险写入边界卡，并确认是否需要人工复核。\n- 防护动作：评分风险必须进入边界卡，不能只作为内部分数。\n- 证据：risks.scoring_risks | github_repo:965415649 | https://github.com/openai/codex | no_demo; severity=medium\n\n## 16. 安全/权限坑 · 来源证据：0.130.0\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：0.130.0\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_0c9ba2dc6c7444688a9de6a144fee613 | https://github.com/openai/codex/releases/tag/rust-v0.130.0 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 17. 安全/权限坑 · 来源证据：Phone number verification doesn't work\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Phone number verification doesn't work\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_0ebeea7c4b5c455f9d14f2518dc6d37a | https://github.com/openai/codex/issues/20161 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 18. 安全/权限坑 · 来源证据：Significant increase in quota consumption after upgrading to v0.130.0\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Significant increase in quota consumption after upgrading to v0.130.0\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_b4d50b3a9b2045c4bd31cd218d7d8d05 | https://github.com/openai/codex/issues/22459 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 19. 安全/权限坑 · 来源证据：missing context % usage in new version\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：missing context % usage in new version\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_a8cf9679679847ddb595ef1ca2bf0757 | https://github.com/openai/codex/issues/18101 | 来源讨论提到 api key 相关条件，需在安装/试用前复核。\n\n## 20. 维护坑 · issue/PR 响应质量未知\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：issue_or_pr_quality=unknown。\n- 对用户的影响：用户无法判断遇到问题后是否有人维护。\n- 建议检查：抽样最近 issue/PR，判断是否长期无人处理。\n- 防护动作：issue/PR 响应未知时，必须提示维护风险。\n- 证据：evidence.maintainer_signals | github_repo:965415649 | https://github.com/openai/codex | issue_or_pr_quality=unknown\n\n## 21. 维护坑 · 发布节奏不明确\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：release_recency=unknown。\n- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。\n- 建议检查：确认最近 release/tag 和 README 安装命令是否一致。\n- 防护动作：发布节奏未知或过期时，安装说明必须标注可能漂移。\n- 证据：evidence.maintainer_signals | github_repo:965415649 | https://github.com/openai/codex | release_recency=unknown\n\n<!-- canonical_name: openai/codex; human_manual_source: deepwiki_human_wiki -->\n",
      "markdown_key": "codex",
      "pages": "draft",
      "source_refs": [
        {
          "evidence_id": "github_repo:965415649",
          "kind": "repo",
          "supports_claim_ids": [
            "claim_identity",
            "claim_distribution",
            "claim_capability"
          ],
          "url": "https://github.com/openai/codex"
        },
        {
          "evidence_id": "art_4e55146ebc8d45a0a817b338599d9049",
          "kind": "docs",
          "supports_claim_ids": [
            "claim_identity",
            "claim_distribution",
            "claim_capability"
          ],
          "url": "https://github.com/openai/codex#readme"
        }
      ],
      "summary": "DeepWiki/Human Wiki 完整输出，末尾追加 Discovery Agent 踩坑日志。",
      "title": "codex 说明书",
      "toc": [
        "https://github.com/openai/codex 项目说明书",
        "目录",
        "项目概述",
        "什么是 Codex CLI",
        "安装与运行",
        "使用 npm 全局安装",
        "使用 Homebrew 安装",
        "核心功能模块",
        "Doramagic 踩坑日志"
      ]
    }
  },
  "quality_gate": {
    "blocking_gaps": [],
    "category_confidence": "medium",
    "compile_status": "ready_for_review",
    "five_assets_present": true,
    "install_sandbox_verified": true,
    "missing_evidence": [],
    "next_action": "publish to Doramagic.ai project surfaces",
    "prompt_preview_boundary_ok": true,
    "publish_status": "publishable",
    "quick_start_verified": true,
    "repo_clone_verified": true,
    "repo_commit": "9c5dfa7b1a8ee8672e1313859ca0d11b3817b932",
    "repo_inspection_error": null,
    "repo_inspection_files": [
      "pnpm-lock.yaml",
      "package.json",
      "README.md",
      "docs/example-config.md",
      "docs/execpolicy.md",
      "docs/exec.md",
      "docs/contributing.md",
      "docs/authentication.md",
      "docs/skills.md",
      "docs/getting-started.md",
      "docs/sandbox.md",
      "docs/install.md",
      "docs/slash_commands.md",
      "docs/agents_md.md",
      "docs/open-source-fund.md",
      "docs/CLA.md",
      "docs/config.md",
      "docs/license.md"
    ],
    "repo_inspection_verified": true,
    "review_reasons": [],
    "tag_count_ok": true,
    "unsupported_claims": []
  },
  "schema_version": "0.1",
  "user_assets": {
    "ai_context_pack": {
      "asset_id": "ai_context_pack",
      "filename": "AI_CONTEXT_PACK.md",
      "markdown": "# codex-monorepo - Doramagic AI Context Pack\n\n> 定位：安装前体验与判断资产。它帮助宿主 AI 有一个好的开始，但不代表已经安装、执行或验证目标项目。\n\n## 充分原则\n\n- **充分原则，不是压缩原则**：AI Context Pack 应该充分到让宿主 AI 在开工前理解项目价值、能力边界、使用入口、风险和证据来源；它可以分层组织，但不以最短摘要为目标。\n- **压缩策略**：只压缩噪声和重复内容，不压缩会影响判断和开工质量的上下文。\n\n## 给宿主 AI 的使用方式\n\n你正在读取 Doramagic 为 codex-monorepo 编译的 AI Context Pack。请把它当作开工前上下文：帮助用户理解适合谁、能做什么、如何开始、哪些必须安装后验证、风险在哪里。不要声称你已经安装、运行或执行了目标项目。\n\n## Claim 消费规则\n\n- **事实来源**：Repo Evidence + Claim/Evidence Graph；Human Wiki 只提供显著性、术语和叙事结构。\n- **事实最低状态**：`supported`\n- `supported`：可以作为项目事实使用，但回答中必须引用 claim_id 和证据路径。\n- `weak`：只能作为低置信度线索，必须要求用户继续核实。\n- `inferred`：只能用于风险提示或待确认问题，不能包装成项目事实。\n- `unverified`：不得作为事实使用，应明确说证据不足。\n- `contradicted`：必须展示冲突来源，不得替用户强行选择一个版本。\n\n## 它最适合谁\n\n- **正在使用 Claude/Codex/Cursor/Gemini 等宿主 AI 的开发者**：README 或插件配置提到多个宿主 AI。 证据：`README.md` Claim：`clm_0003` supported 0.86\n- **希望把专业流程带进宿主 AI 的用户**：仓库包含 Skill 文档。 证据：`.codex/skills/babysit-pr/SKILL.md`, `.codex/skills/code-review/SKILL.md`, `.codex/skills/code-review-breaking-changes/SKILL.md`, `.codex/skills/code-review-change-size/SKILL.md` 等 Claim：`clm_0004` supported 0.86\n\n## 它能做什么\n\n- **AI Skill / Agent 指令资产库**（可做安装前预览）：项目包含可被宿主 AI 读取的 Skill 或 Agent 指令文件，可用于把专业流程带入 Claude、Codex、Cursor 等宿主。 证据：`.codex/skills/babysit-pr/SKILL.md`, `.codex/skills/code-review/SKILL.md`, `.codex/skills/code-review-breaking-changes/SKILL.md`, `.codex/skills/code-review-change-size/SKILL.md` 等 Claim：`clm_0001` supported 0.86\n- **命令行启动或安装流程**（需要安装后验证）：项目文档中存在可执行命令，真实使用需要在本地或宿主环境中运行这些命令。 证据：`README.md`, `docs/install.md` Claim：`clm_0002` supported 0.86\n\n## 怎么开始\n\n- `npm install -g @openai/codex` 证据：`README.md` Claim：`clm_0005` supported 0.86\n- `git clone https://github.com/openai/codex.git` 证据：`docs/install.md` Claim：`clm_0006` supported 0.86\n- `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y` 证据：`docs/install.md` Claim：`clm_0007` supported 0.86\n\n## 继续前判断卡\n\n- **当前建议**：先做权限沙盒试用\n- **为什么**：项目存在安装命令、宿主配置或本地写入线索，不建议直接进入主力环境，应先在隔离环境试装。\n\n### 30 秒判断\n\n- **现在怎么做**：先做权限沙盒试用\n- **最小安全下一步**：先跑 Prompt Preview；若仍要安装，只在隔离环境试装\n- **先别相信**：工具权限边界不能在安装前相信。\n- **继续会触碰**：命令执行、宿主 AI 配置、本地环境或项目文件\n\n### 现在可以相信\n\n- **适合人群线索：正在使用 Claude/Codex/Cursor/Gemini 等宿主 AI 的开发者**（supported）：有 supported claim 或项目证据支撑，但仍不等于真实安装效果。 证据：`README.md` Claim：`clm_0003` supported 0.86\n- **适合人群线索：希望把专业流程带进宿主 AI 的用户**（supported）：有 supported claim 或项目证据支撑，但仍不等于真实安装效果。 证据：`.codex/skills/babysit-pr/SKILL.md`, `.codex/skills/code-review/SKILL.md`, `.codex/skills/code-review-breaking-changes/SKILL.md`, `.codex/skills/code-review-change-size/SKILL.md` 等 Claim：`clm_0004` supported 0.86\n- **能力存在：AI Skill / Agent 指令资产库**（supported）：可以相信项目包含这类能力线索；是否适合你的具体任务仍要试用或安装后验证。 证据：`.codex/skills/babysit-pr/SKILL.md`, `.codex/skills/code-review/SKILL.md`, `.codex/skills/code-review-breaking-changes/SKILL.md`, `.codex/skills/code-review-change-size/SKILL.md` 等 Claim：`clm_0001` supported 0.86\n- **能力存在：命令行启动或安装流程**（supported）：可以相信项目包含这类能力线索；是否适合你的具体任务仍要试用或安装后验证。 证据：`README.md`, `docs/install.md` Claim：`clm_0002` supported 0.86\n- **存在 Quick Start / 安装命令线索**（supported）：可以相信项目文档出现过启动或安装入口；不要因此直接在主力环境运行。 证据：`README.md` Claim：`clm_0005` supported 0.86\n\n### 现在还不能相信\n\n- **工具权限边界不能在安装前相信。**（unverified）：MCP/tool 类项目通常会触碰文件、网络、浏览器或外部 API，必须真实检查权限和日志。\n- **真实输出质量不能在安装前相信。**（unverified）：Prompt Preview 只能展示引导方式，不能证明真实项目中的结果质量。\n- **宿主 AI 版本兼容性不能在安装前相信。**（unverified）：Claude、Cursor、Codex、Gemini 等宿主加载规则和版本差异必须在真实环境验证。\n- **不会污染现有宿主 AI 行为，不能直接相信。**（inferred）：Skill、plugin、AGENTS/CLAUDE/GEMINI 指令可能改变宿主 AI 的默认行为。 证据：`.codex/skills/babysit-pr/SKILL.md`, `.codex/skills/code-review-breaking-changes/SKILL.md`, `.codex/skills/code-review-change-size/SKILL.md`, `.codex/skills/code-review-context/SKILL.md` 等\n- **可安全回滚不能默认相信。**（unverified）：除非项目明确提供卸载和恢复说明，否则必须先在隔离环境验证。\n- **真实安装后是否与用户当前宿主 AI 版本兼容？**（unverified）：兼容性只能通过实际宿主环境验证。\n- **项目输出质量是否满足用户具体任务？**（unverified）：安装前预览只能展示流程和边界，不能替代真实评测。\n- **安装命令是否需要网络、权限或全局写入？**（unverified）：这影响企业环境和个人环境的安装风险。 证据：`README.md`\n\n### 继续会触碰什么\n\n- **命令执行**：包管理器、网络下载、本地插件目录、项目配置或用户主目录。 原因：运行第一条命令就可能产生环境改动；必须先判断是否值得跑。 证据：`README.md`, `docs/install.md`\n- **宿主 AI 配置**：Claude/Codex/Cursor/Gemini/OpenCode 等宿主的 plugin、Skill 或规则加载配置。 原因：宿主配置会改变 AI 后续工作方式，可能和用户已有规则冲突。 证据：`.codex/skills/babysit-pr/SKILL.md`, `.codex/skills/code-review-breaking-changes/SKILL.md`, `.codex/skills/code-review-change-size/SKILL.md`, `.codex/skills/code-review-context/SKILL.md` 等\n- **本地环境或项目文件**：安装结果、插件缓存、项目配置或本地依赖目录。 原因：安装前无法证明写入范围和回滚方式，需要隔离验证。 证据：`README.md`, `docs/install.md`\n- **宿主 AI 上下文**：AI Context Pack、Prompt Preview、Skill 路由、风险规则和项目事实。 原因：导入上下文会影响宿主 AI 后续判断，必须避免把未验证项包装成事实。\n\n### 最小安全下一步\n\n- **先跑 Prompt Preview**：用安装前交互式试用判断工作方式是否匹配，不需要授权或改环境。（适用：任何项目都适用，尤其是输出质量未知时。）\n- **只在隔离目录或测试账号试装**：避免安装命令污染主力宿主 AI、真实项目或用户主目录。（适用：存在命令执行、插件配置或本地写入线索时。）\n- **先备份宿主 AI 配置**：Skill、plugin、规则文件可能改变 Claude/Cursor/Codex 的默认行为。（适用：存在插件 manifest、Skill 或宿主规则入口时。）\n- **安装后只验证一个最小任务**：先验证加载、兼容、输出质量和回滚，再决定是否深用。（适用：准备从试用进入真实工作流时。）\n\n### 退出方式\n\n- **保留安装前状态**：记录原始宿主配置和项目状态，后续才能判断是否可恢复。\n- **准备移除宿主 plugin / Skill / 规则入口**：如果试装后行为异常，可以把宿主 AI 恢复到试装前状态。\n- **记录安装命令和写入路径**：没有明确卸载说明时，至少要知道哪些目录或配置需要手动清理。\n- **如果没有回滚路径，不进入主力环境**：不可回滚是继续前阻断项，不应靠信任或运气继续。\n\n## 哪些只能预览\n\n- 解释项目适合谁和能做什么\n- 基于项目文档演示典型对话流程\n- 帮助用户判断是否值得安装或继续研究\n\n## 哪些必须安装后验证\n\n- 真实安装 Skill、插件或 CLI\n- 执行脚本、修改本地文件或访问外部服务\n- 验证真实输出质量、性能和兼容性\n\n## 边界与风险判断卡\n\n- **把安装前预览误认为真实运行**：用户可能高估项目已经完成的配置、权限和兼容性验证。 处理方式：明确区分 prompt_preview_can_do 与 runtime_required。 Claim：`clm_0008` inferred 0.45\n- **命令执行会修改本地环境**：安装命令可能写入用户主目录、宿主插件目录或项目配置。 处理方式：先在隔离环境或测试账号中运行。 证据：`README.md`, `docs/install.md` Claim：`clm_0009` supported 0.86\n- **待确认**：真实安装后是否与用户当前宿主 AI 版本兼容？。原因：兼容性只能通过实际宿主环境验证。\n- **待确认**：项目输出质量是否满足用户具体任务？。原因：安装前预览只能展示流程和边界，不能替代真实评测。\n- **待确认**：安装命令是否需要网络、权限或全局写入？。原因：这影响企业环境和个人环境的安装风险。\n\n## 开工前工作上下文\n\n### 加载顺序\n\n- 先读取 how_to_use.host_ai_instruction，建立安装前判断资产的边界。\n- 读取 claim_graph_summary，确认事实来自 Claim/Evidence Graph，而不是 Human Wiki 叙事。\n- 再读取 intended_users、capabilities 和 quick_start_candidates，判断用户是否匹配。\n- 需要执行具体任务时，优先查 role_skill_index，再查 evidence_index。\n- 遇到真实安装、文件修改、网络访问、性能或兼容性问题时，转入 risk_card 和 boundaries.runtime_required。\n\n### 任务路由\n\n- **AI Skill / Agent 指令资产库**：先基于 role_skill_index / evidence_index 帮用户挑选可用角色、Skill 或工作流。 边界：可做安装前 Prompt 体验。 证据：`.codex/skills/babysit-pr/SKILL.md`, `.codex/skills/code-review/SKILL.md`, `.codex/skills/code-review-breaking-changes/SKILL.md`, `.codex/skills/code-review-change-size/SKILL.md` 等 Claim：`clm_0001` supported 0.86\n- **命令行启动或安装流程**：先说明这是安装后验证能力，再给出安装前检查清单。 边界：必须真实安装或运行后验证。 证据：`README.md`, `docs/install.md` Claim：`clm_0002` supported 0.86\n\n### 上下文规模\n\n- 文件总数：3948\n- 重要文件覆盖：40/3948\n- 证据索引条目：80\n- 角色 / Skill 条目：16\n\n### 证据不足时的处理\n\n- **missing_evidence**：说明证据不足，要求用户提供目标文件、README 段落或安装后验证记录；不要补全事实。\n- **out_of_scope_request**：说明该任务超出当前 AI Context Pack 证据范围，并建议用户先查看 Human Manual 或真实安装后验证。\n- **runtime_request**：给出安装前检查清单和命令来源，但不要替用户执行命令或声称已执行。\n- **source_conflict**：同时展示冲突来源，标记为待核实，不要强行选择一个版本。\n\n## Prompt Recipes\n\n### 适配判断\n\n- 目标：判断这个项目是否适合用户当前任务。\n- 预期输出：适配结论、关键理由、证据引用、安装前可预览内容、必须安装后验证内容、下一步建议。\n\n```text\n请基于 codex-monorepo 的 AI Context Pack，先问我 3 个必要问题，然后判断它是否适合我的任务。回答必须包含：适合谁、能做什么、不能做什么、是否值得安装、证据来自哪里。所有项目事实必须引用 evidence_refs、source_paths 或 claim_id。\n```\n\n### 安装前体验\n\n- 目标：让用户在安装前感受核心工作流，同时避免把预览包装成真实能力或营销承诺。\n- 预期输出：一段带边界标签的体验剧本、安装后验证清单和谨慎建议；不含真实运行承诺或强营销表述。\n\n```text\n请把 codex-monorepo 当作安装前体验资产，而不是已安装工具或真实运行环境。\n\n请严格输出四段：\n1. 先问我 3 个必要问题。\n2. 给出一段“体验剧本”：用 [安装前可预览]、[必须安装后验证]、[证据不足] 三种标签展示它可能如何引导工作流。\n3. 给出安装后验证清单：列出哪些能力只有真实安装、真实宿主加载、真实项目运行后才能确认。\n4. 给出谨慎建议：只能说“值得继续研究/试装”“先补充信息后再判断”或“不建议继续”，不得替项目背书。\n\n硬性边界：\n- 不要声称已经安装、运行、执行测试、修改文件或产生真实结果。\n- 不要写“自动适配”“确保通过”“完美适配”“强烈建议安装”等承诺性表达。\n- 如果描述安装后的工作方式，必须使用“如果安装成功且宿主正确加载 Skill，它可能会……”这种条件句。\n- 体验剧本只能写成“示例台词/假设流程”：使用“可能会询问/可能会建议/可能会展示”，不要写“已写入、已生成、已通过、正在运行、正在生成”。\n- Prompt Preview 不负责给安装命令；如用户准备试装，只能提示先阅读 Quick Start 和 Risk Card，并在隔离环境验证。\n- 所有项目事实必须来自 supported claim、evidence_refs 或 source_paths；inferred/unverified 只能作风险或待确认项。\n\n```\n\n### 角色 / Skill 选择\n\n- 目标：从项目里的角色或 Skill 中挑选最匹配的资产。\n- 预期输出：候选角色或 Skill 列表，每项包含适用场景、证据路径、风险边界和是否需要安装后验证。\n\n```text\n请读取 role_skill_index，根据我的目标任务推荐 3-5 个最相关的角色或 Skill。每个推荐都要说明适用场景、可能输出、风险边界和 evidence_refs。\n```\n\n### 风险预检\n\n- 目标：安装或引入前识别环境、权限、规则冲突和质量风险。\n- 预期输出：环境、权限、依赖、许可、宿主冲突、质量风险和未知项的检查清单。\n\n```text\n请基于 risk_card、boundaries 和 quick_start_candidates，给我一份安装前风险预检清单。不要替我执行命令，只说明我应该检查什么、为什么检查、失败会有什么影响。\n```\n\n### 宿主 AI 开工指令\n\n- 目标：把项目上下文转成一次对话开始前的宿主 AI 指令。\n- 预期输出：一段边界明确、证据引用明确、适合复制给宿主 AI 的开工前指令。\n\n```text\n请基于 codex-monorepo 的 AI Context Pack，生成一段我可以粘贴给宿主 AI 的开工前指令。这段指令必须遵守 not_runtime=true，不能声称项目已经安装、运行或产生真实结果。\n```\n\n\n## 角色 / Skill 索引\n\n- 共索引 16 个角色 / Skill / 项目文档条目。\n\n- **babysit-pr**（skill）：Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep watching open PRs so fresh review feedback is surfaced promptly. Use when the user asks Codex to monitor… 激活提示：当用户任务与“babysit-pr”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`.codex/skills/babysit-pr/SKILL.md`\n- **code-breaking-changes**（skill）：Breaking changes 激活提示：当用户任务与“code-breaking-changes”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`.codex/skills/code-review-breaking-changes/SKILL.md`\n- **code-review-change-size**（skill）：Change size guidance 800 lines 激活提示：当用户任务与“code-review-change-size”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`.codex/skills/code-review-change-size/SKILL.md`\n- **code-review-context**（skill）：Model visible context 激活提示：当用户任务与“code-review-context”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`.codex/skills/code-review-context/SKILL.md`\n- **code-review-testing**（skill）：Test authoring guidance 激活提示：当用户任务与“code-review-testing”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`.codex/skills/code-review-testing/SKILL.md`\n- **code-review**（skill）：Run a final code review on a pull request 激活提示：当用户任务与“code-review”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`.codex/skills/code-review/SKILL.md`\n- **codex-bug**（skill）：Diagnose GitHub bug reports in openai/codex. Use when given a GitHub issue URL from openai/codex and asked to decide next steps such as verifying against the repo, requesting more info, or explaining why it is not a bug; follow any additional user-provided instructions. 激活提示：当用户任务与“codex-bug”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`.codex/skills/codex-bug/SKILL.md`\n- **codex-issue-digest**（skill）：Run a GitHub issue digest for openai/codex by feature-area labels, all areas, and configurable time windows. Use when asked to summarize recent Codex bug reports or enhancement requests, especially for owner-specific labels such as tui, exec, app, or similar areas. 激活提示：当用户任务与“codex-issue-digest”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`.codex/skills/codex-issue-digest/SKILL.md`\n- **codex-pr-body**（skill）：Update the title and body of one or more pull requests. 激活提示：当用户任务与“codex-pr-body”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`.codex/skills/codex-pr-body/SKILL.md`\n- **remote-tests**（skill）：How to run tests using remote executor. 激活提示：当用户任务与“remote-tests”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`.codex/skills/remote-tests/SKILL.md`\n- **test-tui**（skill）：Guide for testing Codex TUI interactively 激活提示：当用户任务与“test-tui”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`.codex/skills/test-tui/SKILL.md`\n- **imagegen**（skill）：Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output should be a bitmap asset rather than repo-native code or vector. Do not use when the task is better handl… 激活提示：当用户任务与“imagegen”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`codex-rs/skills/src/assets/samples/imagegen/SKILL.md`\n- **openai-docs**（skill）：Use when the user asks how to build with OpenAI products or APIs and needs up-to-date official documentation with citations, help choosing the latest model for a use case, or model upgrade and prompt-upgrade guidance; prioritize OpenAI docs MCP tools, use bundled references only as helper context, and restrict any fallback browsing to official OpenAI domains. 激活提示：当用户任务与“openai-docs”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`codex-rs/skills/src/assets/samples/openai-docs/SKILL.md`\n- **plugin-creator**（skill）：Create and scaffold plugin directories for Codex with a required .codex-plugin/plugin.json , optional plugin folders/files, and baseline placeholders you can edit before publishing or testing. Use when Codex needs to create a new personal plugin, add optional plugin structure, or generate or update personal or repo-root .agents/plugins/marketplace.json entries for plugin ordering and availability metadata. 激活提示：当用户任务与“plugin-creator”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`codex-rs/skills/src/assets/samples/plugin-creator/SKILL.md`\n- **skill-creator**（skill）：Guide for creating effective skills. This skill should be used when users want to create a new skill or update an existing skill that extends Codex's capabilities with specialized knowledge, workflows, or tool integrations. 激活提示：当用户任务与“skill-creator”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`codex-rs/skills/src/assets/samples/skill-creator/SKILL.md`\n- **skill-installer**（skill）：Install Codex skills into $CODEX HOME/skills from a curated list or a GitHub repo path. Use when a user asks to list installable skills, install a curated skill, or install a skill from another repo including private repos . 激活提示：当用户任务与“skill-installer”描述的流程高度相关时，先用它做安装前体验，再决定是否安装。 证据：`codex-rs/skills/src/assets/samples/skill-installer/SKILL.md`\n\n## 证据索引\n\n- 共索引 80 条证据。\n\n- **Contributing**（documentation）：External contributions are by invitation only 证据：`docs/contributing.md`\n- **Installing & building**（documentation）：Requirement Details --------------------------- --------------------------------------------------------------- Operating systems macOS 12+, Ubuntu 20.04+/Debian 10+, or Windows 11 via WSL2 Git optional, recommended 2.23+ for built-in PR helpers RAM 4-GB minimum 8-GB recommended 证据：`docs/install.md`\n- **Containerized Development**（documentation）：- devcontainer.json keeps the existing Codex contributor setup for working on this repository. - devcontainer.secure.json adds a customer-oriented profile with stricter outbound network controls. 证据：`.devcontainer/README.md`\n- **Rust/codex-rs**（documentation）：In the codex-rs folder where the rust code lives: 证据：`AGENTS.md`\n- **Quickstart**（documentation）：npm i -g @openai/codex or brew install --cask codex Codex CLI is a coding agent from OpenAI that runs locally on your computer. If you want Codex in your code editor VS Code, Cursor, Windsurf , install in your IDE. If you want the desktop app experience, run codex app or visit the Codex App page . If you are looking for the cloud-based agent from OpenAI, Codex Web , go to chatgpt.com/codex . 证据：`README.md`\n- **Codex CLI Rust Implementation**（documentation）：We provide Codex CLI as a standalone executable to ensure a zero-dependency install. 证据：`codex-rs/README.md`\n- **Workflow Strategy**（documentation）：The workflows in this directory are split so that pull requests get fast, review-friendly signal while main still gets the full cross-platform verification pass. 证据：`.github/workflows/README.md`\n- **npm releases**（documentation）：Use the staging helper in the repo root to generate npm tarballs for a release. For example, to stage the CLI, responses proxy, and SDK packages for version 0.6.0 : 证据：`codex-cli/scripts/README.md`\n- **oai-codex-ansi-escape**（documentation）：Small helper functions that wrap functionality from : 证据：`codex-rs/ansi-escape/README.md`\n- **codex-app-server-client**（documentation）：Shared in-process app-server client used by conversational CLI surfaces: 证据：`codex-rs/app-server-client/README.md`\n- **codex-app-server-daemon**（documentation）：codex-app-server-daemon is experimental and its lifecycle contract may change while the remote-management flow is still being developed. 证据：`codex-rs/app-server-daemon/README.md`\n- **App Server Test Client**（documentation）：App Server Test Client Quickstart for running and hitting codex app-server . 证据：`codex-rs/app-server-test-client/README.md`\n- **codex-app-server**（documentation）：codex app-server is the interface Codex uses to power rich interfaces such as the Codex VS Code extension https://marketplace.visualstudio.com/items?itemName=openai.chatgpt . 证据：`codex-rs/app-server/README.md`\n- **ChatGPT**（documentation）：This crate pertains to first party ChatGPT APIs and products such as Codex agent. 证据：`codex-rs/chatgpt/README.md`\n- **codex-api**（documentation）：Typed clients for Codex/OpenAI APIs built on top of the generic transport in codex-client . 证据：`codex-rs/codex-api/README.md`\n- **codex-client**（documentation）：Generic transport layer that wraps HTTP requests, retries, and streaming primitives without any Codex/OpenAI awareness. 证据：`codex-rs/codex-client/README.md`\n- **codex-config loader**（documentation）：This module is the canonical place to load and describe Codex configuration layers user config, CLI/session overrides, managed config, and MDM-managed preferences and to produce: 证据：`codex-rs/config/src/loader/README.md`\n- **codex-core**（documentation）：This crate implements the business logic for Codex. It is designed to be used by the various Codex UIs written in Rust. 证据：`codex-rs/core/README.md`\n- **codex-debug-client**（documentation）：WARNING: this code is mainly generated by Codex and should not be used in production 证据：`codex-rs/debug-client/README.md`\n- **codex-exec-server**（documentation）：codex-exec-server is the library backing codex exec-server , a small JSON-RPC server for spawning and controlling subprocesses through codex-utils-pty . 证据：`codex-rs/exec-server/README.md`\n- **codex-execpolicy-legacy**（documentation）：This crate hosts the original execpolicy implementation. The newer prefix-rule engine lives in codex-execpolicy . 证据：`codex-rs/execpolicy-legacy/README.md`\n- **codex-execpolicy**（documentation）：- Policy engine and CLI built around prefix rule pattern= ... , decision?, justification?, match?, not match? plus host executable name=..., paths= ... . - This release covers the prefix-rule subset of the execpolicy language plus host executable metadata; a richer language will follow. - Tokens are matched in order; any pattern element may be a list to denote alternatives. decision defaults to allow ; valid values: allow , prompt , forbidden . - justification is an optional human-readable rationale for why a rule exists. It can be provided for any decision and may be surfaced in different contexts for example, in approval prompts or rejection messages . When decision = \"forbidden\" is used,… 证据：`codex-rs/execpolicy/README.md`\n- **codex file search**（documentation）：Fast fuzzy file search tool for Codex. 证据：`codex-rs/file-search/README.md`\n- **codex-git-utils**（documentation）：Helpers for interacting with git, including patch application. The crate also exposes a lightweight baseline API for internal directories that use git only as a resettable diff mechanism: ensure git baseline repository preserves a usable root/.git baseline or creates one when it is missing or unusable, reset git repository replaces root/.git with a fresh one-commit baseline, and diff since latest init returns structured file changes plus a unified diff from that baseline to the current directory contents. 证据：`codex-rs/git-utils/README.md`\n- **codex-linux-sandbox**（documentation）：This crate is responsible for producing: 证据：`codex-rs/linux-sandbox/README.md`\n- **Memories**（documentation）：This directory owns reusable memory crates and the memory pipeline documentation. 证据：`codex-rs/memories/README.md`\n- **codex-network-proxy**（documentation）：codex-network-proxy is Codex's local network policy enforcement proxy. It runs: 证据：`codex-rs/network-proxy/README.md`\n- **codex-otel**（documentation）：codex-otel is the OpenTelemetry integration crate for Codex. It provides: 证据：`codex-rs/otel/README.md`\n- **codex-process-hardening**（documentation）：This crate provides pre main hardening , which is designed to be called pre- main using ctor::ctor to perform various process hardening steps, such as 证据：`codex-rs/process-hardening/README.md`\n- **codex-protocol**（documentation）：This crate defines the \"types\" for the protocol used by Codex CLI, which includes both \"internal types\" for communication between codex-core and codex-tui , as well as \"external types\" used with codex app-server . 证据：`codex-rs/protocol/README.md`\n- **codex-responses-api-proxy**（documentation）：Launch the proxy, dump request/response pairs to /tmp/proxy cd path/to/codex/codex-rs cargo build echo $OPENAI API KEY ./target/debug/codex-responses-api-proxy \\ --port 60001 \\ --dump-dir /tmp/proxy 证据：`codex-rs/responses-api-proxy/README.md`\n- **@openai/codex-responses-api-proxy**（documentation）：npm i -g @openai/codex-responses-api-proxy to install codex-responses-api-proxy 证据：`codex-rs/responses-api-proxy/npm/README.md`\n- **Rollout Trace**（documentation）：Privacy: Rollout tracing is not telemetry. Codex does not upload or report these traces; it writes local bundles only when CODEX ROLLOUT TRACE ROOT is set. Those local bundles can contain prompts, responses, tool inputs/outputs, terminal output, and paths, so treat them as sensitive. 证据：`codex-rs/rollout-trace/README.md`\n- **codex-shell-escalation**（documentation）：This crate contains the Unix shell-escalation protocol implementation and the codex-execve-wrapper executable. 证据：`codex-rs/shell-escalation/README.md`\n- **codex-stdio-to-uds**（documentation）：Traditionally, there are two transport mechanisms for an MCP server: stdio and HTTP. 证据：`codex-rs/stdio-to-uds/README.md`\n- **ThreadManager Sample**（documentation）：Small one-shot binary that starts a Codex thread with ThreadManager from codex-core-api , submits a single user turn, and prints the final assistant message. 证据：`codex-rs/thread-manager-sample/README.md`\n- **Thread Store**（documentation）：codex-thread-store is the storage boundary for Codex threads. It defines the ThreadStore trait plus local and in-memory implementations. Other storage implementations may live outside this repository. 证据：`codex-rs/thread-store/README.md`\n- **codex-tool-api**（documentation）：codex-tool-api is the minimal extension-facing contract for contributed function tools that can be injected into Codex without making codex-core depend on the tool owner's crate. 证据：`codex-rs/tool-api/README.md`\n- **codex-tools**（documentation）：codex-tools is the host-side support crate for building, adapting, and planning tool sets outside codex-core . 证据：`codex-rs/tools/README.md`\n- **TUI bottom pane state machines**（documentation）：When changing the paste-burst or chat-composer state machines in this folder, keep the docs in sync: 证据：`codex-rs/tui/src/bottom_pane/AGENTS.md`\n- **codex-utils-cargo-bin runfiles strategy**（documentation）：codex-utils-cargo-bin runfiles strategy 证据：`codex-rs/utils/cargo-bin/README.md`\n- **codex-utils-pty**（documentation）：Lightweight helpers for spawning interactive processes either under a PTY pseudo terminal or regular pipes. The public API is minimal and mirrors both backends so callers can switch based on their needs e.g., enabling or disabling TTY . 证据：`codex-rs/utils/pty/README.md`\n- **codex-utils-stream-parser**（documentation）：Small, dependency-free utilities for parsing streamed text incrementally. 证据：`codex-rs/utils/stream-parser/README.md`\n- **codex-utils-template**（documentation）：Small, strict string templating for prompt and text assets. 证据：`codex-rs/utils/template/README.md`\n- **Readme**（documentation）：Many container runtime tools like systemd-nspawn , docker , etc. focus on providing infrastructure for system administrators and orchestration tools e.g. Kubernetes to run containers. 证据：`codex-rs/vendor/bubblewrap/README.md`\n- **Codex CLI Runtime for Python SDK**（documentation）：Platform-specific runtime package consumed by the published openai-codex . 证据：`sdk/python-runtime/README.md`\n- **OpenAI Codex Python SDK Experimental**（documentation）：OpenAI Codex Python SDK Experimental 证据：`sdk/python/README.md`\n- **Python SDK Examples**（documentation）：Each example folder contains runnable versions: 证据：`sdk/python/examples/README.md`\n- **Codex SDK**（documentation）：Embed the Codex agent in your workflows and apps. 证据：`sdk/typescript/README.md`\n- **rusty v8 Consumer Artifacts**（documentation）：This directory wires the v8 crate to exact-version Bazel inputs. Bazel consumer builds use: 证据：`third_party/v8/README.md`\n- **argument-comment-lint**（documentation）：Isolated Dylint https://github.com/trailofbits/dylint library for enforcing Rust argument comments in the exact / param / shape. 证据：`tools/argument-comment-lint/README.md`\n- **Package**（package_manifest）：{ \"name\": \"@openai/codex\", \"version\": \"0.0.0-dev\", \"license\": \"Apache-2.0\", \"bin\": { \"codex\": \"bin/codex.js\" }, \"type\": \"module\", \"engines\": { \"node\": \" =16\" }, \"files\": \"bin\", \"vendor\" , \"repository\": { \"type\": \"git\", \"url\": \"git+https://github.com/openai/codex.git\", \"directory\": \"codex-cli\" }, \"packageManager\": \"pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319\" } 证据：`codex-cli/package.json`\n- **Package**（package_manifest）：{ \"name\": \"codex-monorepo\", \"private\": true, \"description\": \"Tools for repo-wide maintenance.\", \"scripts\": { \"format\": \"prettier --check .json .md docs/ .md .github/workflows/ .yml / .js\", \"format:fix\": \"prettier --write .json .md docs/ .md .github/workflows/ .yml / .js\", \"write-hooks-schema\": \"cargo run --manifest-path ./codex-rs/Cargo.toml -p codex-hooks --bin write hooks schema fixtures\" }, \"devDependencies\": { \"prettier\": \"^3.5.3\" }, \"resolutions\": { \"@modelcontextprotocol/sdk\": \"1.26.0\", \"braces\": \"^3.0.3\", \"flatted\": \"3.4.2\", \"glob@10.4.5\": \"10.5.0\", \"handlebars\": \"4.7.9\", \"micromatch\": \"^4.0.8\", \"minimatch@3.1.2\": \"3.1.4\", \"minimatch@9.0.5\": \"9.0.7\", \"path-to-regexp\": \"8.4.0\", \"picom… 证据：`package.json`\n- **Package**（package_manifest）：{ \"name\": \"codex-devcontainer-install\", \"private\": true, \"description\": \"Locked Codex CLI install boundary for the secure devcontainer.\", \"dependencies\": { \"@openai/codex\": \"0.121.0\" }, \"engines\": { \"node\": \" =22\", \"pnpm\": \" =10.33.0\" }, \"packageManager\": \"pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319\" } 证据：`.devcontainer/codex-install/package.json`\n- **Package**（package_manifest）：{ \"name\": \"@openai/codex-responses-api-proxy\", \"version\": \"0.0.0-dev\", \"license\": \"Apache-2.0\", \"bin\": { \"codex-responses-api-proxy\": \"bin/codex-responses-api-proxy.js\" }, \"type\": \"module\", \"engines\": { \"node\": \" =16\" }, \"files\": \"bin\", \"vendor\" , \"repository\": { \"type\": \"git\", \"url\": \"git+https://github.com/openai/codex.git\", \"directory\": \"codex-rs/responses-api-proxy/npm\" }, \"packageManager\": \"pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319\" } 证据：`codex-rs/responses-api-proxy/npm/package.json`\n- **Package**（package_manifest）：{ \"name\": \"@openai/codex-sdk\", \"version\": \"0.0.0-dev\", \"description\": \"TypeScript SDK for Codex APIs.\", \"repository\": { \"type\": \"git\", \"url\": \"git+https://github.com/openai/codex.git\", \"directory\": \"sdk/typescript\" }, \"keywords\": \"openai\", \"codex\", \"sdk\", \"typescript\", \"api\" , \"license\": \"Apache-2.0\", \"type\": \"module\", \"engines\": { \"node\": \" =18\" }, \"module\": \"./dist/index.js\", \"types\": \"./dist/index.d.ts\", \"exports\": { \".\": { \"import\": \"./dist/index.js\", \"types\": \"./dist/index.d.ts\" } }, \"files\": \"dist\" , \"sideEffects\": false, \"scripts\": { \"clean\": \"rm -rf dist\", \"build\": \"tsup\", \"build:watch\": \"tsup --watch\", \"lint\": \"pnpm eslint \\\"src/ / .ts\\\" \\\"tests/ / .ts\\\"\", \"lint:fix\": \"pnpm eslint… 证据：`sdk/typescript/package.json`\n- **PR Babysitter**（skill_instruction）：Objective Babysit a PR persistently until one of these terminal outcomes occurs: 证据：`.codex/skills/babysit-pr/SKILL.md`\n- **Skill**（skill_instruction）：Search for breaking changes in external integration surfaces: - app-server APIs - CLI parameters - configuration loading - resuming sessions from existing rollouts 证据：`.codex/skills/code-review-breaking-changes/SKILL.md`\n- **Skill**（skill_instruction）：Unless the change is mechanical the total number of changed lines should not exceed 800 lines. For complex logic changes the size should be under 500 lines. 证据：`.codex/skills/code-review-change-size/SKILL.md`\n- **Skill**（skill_instruction）：Codex maintains a context history of messages that is sent to the model in inference requests. 证据：`.codex/skills/code-review-context/SKILL.md`\n- 其余 20 条证据见 `AI_CONTEXT_PACK.json` 或 `EVIDENCE_INDEX.json`。\n\n## 宿主 AI 必须遵守的规则\n\n- **把本资产当作开工前上下文，而不是运行环境。**：AI Context Pack 只包含证据化项目理解，不包含目标项目的可执行状态。 证据：`docs/contributing.md`, `docs/install.md`, `.devcontainer/README.md`\n- **回答用户时区分可预览内容与必须安装后才能验证的内容。**：安装前体验的消费者价值来自降低误装和误判，而不是伪装成真实运行。 证据：`docs/contributing.md`, `docs/install.md`, `.devcontainer/README.md`\n\n## 用户开工前应该回答的问题\n\n- 你准备在哪个宿主 AI 或本地环境中使用它？\n- 你只是想先体验工作流，还是准备真实安装？\n- 你最在意的是安装成本、输出质量、还是和现有规则的冲突？\n\n## 验收标准\n\n- 所有能力声明都能回指到 evidence_refs 中的文件路径。\n- AI_CONTEXT_PACK.md 没有把预览包装成真实运行。\n- 用户能在 3 分钟内看懂适合谁、能做什么、如何开始和风险边界。\n\n---\n\n## Doramagic Context Augmentation\n\n下面内容用于强化 Repomix/AI Context Pack 主体。Human Manual 只提供阅读骨架；踩坑日志会被转成宿主 AI 必须遵守的工作约束。\n\n## Human Manual 骨架\n\n使用规则：这里只是项目阅读路线和显著性信号，不是事实权威。具体事实仍必须回到 repo evidence / Claim Graph。\n\n宿主 AI 硬性规则：\n- 不得把页标题、章节顺序、摘要或 importance 当作项目事实证据。\n- 解释 Human Manual 骨架时，必须明确说它只是阅读路线/显著性信号。\n- 能力、安装、兼容性、运行状态和风险判断必须引用 repo evidence、source path 或 Claim Graph。\n\n- **项目概述**：importance `high`\n  - source_paths: README.md, AGENTS.md\n- **系统架构**：importance `high`\n  - source_paths: codex-rs/app-server-protocol/src/lib.rs, codex-rs/app-server/src/lib.rs, codex-rs/app-server-transport/src/lib.rs\n- **协议层详解**：importance `high`\n  - source_paths: codex-rs/app-server-protocol/src/protocol/mod.rs, codex-rs/app-server-protocol/src/protocol/v1.rs, codex-rs/app-server-protocol/src/protocol/v2/mod.rs, codex-rs/app-server-protocol/schema/json\n- **核心Agent模块**：importance `high`\n  - source_paths: codex-rs/core/src/lib.rs, codex-rs/core/src/agent/mod.rs, codex-rs/core/src/client.rs, codex-rs/core/src/session/mod.rs, codex-rs/core/src/tools/mod.rs\n- **执行系统**：importance `high`\n  - source_paths: codex-rs/exec-server/src/lib.rs, codex-rs/core/src/unified_exec/mod.rs, codex-rs/core/src/exec.rs, codex-rs/shell-command/src/lib.rs\n- **终端用户界面**：importance `high`\n  - source_paths: codex-rs/tui/src/lib.rs, codex-rs/tui/src/chatwidget.rs, codex-rs/tui/src/bottom_pane/mod.rs, codex-rs/tui/src/app.rs\n- **技能系统**：importance `medium`\n  - source_paths: codex-rs/core-skills/src/lib.rs, codex-rs/core-skills/src/manager.rs, codex-rs/core-skills/src/loader.rs, .codex/skills/code-review/SKILL.md, .codex/skills/codex-bug/SKILL.md\n- **插件系统**：importance `medium`\n  - source_paths: codex-rs/core-plugins/src/lib.rs, codex-rs/core-plugins/src/manager.rs, codex-rs/core-plugins/src/marketplace.rs, codex-rs/ext/extension-api/src/lib.rs\n\n## Repo Inspection Evidence / 源码检查证据\n\n- repo_clone_verified: true\n- repo_inspection_verified: true\n- repo_commit: `9c5dfa7b1a8ee8672e1313859ca0d11b3817b932`\n- inspected_files: `pnpm-lock.yaml`, `package.json`, `README.md`, `docs/example-config.md`, `docs/execpolicy.md`, `docs/exec.md`, `docs/contributing.md`, `docs/authentication.md`, `docs/skills.md`, `docs/getting-started.md`, `docs/sandbox.md`, `docs/install.md`, `docs/slash_commands.md`, `docs/agents_md.md`, `docs/open-source-fund.md`, `docs/CLA.md`, `docs/config.md`, `docs/license.md`\n\n宿主 AI 硬性规则：\n- 没有 repo_clone_verified=true 时，不得声称已经读过源码。\n- 没有 repo_inspection_verified=true 时，不得把 README/docs/package 文件判断写成事实。\n- 没有 quick_start_verified=true 时，不得声称 Quick Start 已跑通。\n\n## Doramagic Pitfall Constraints / 踩坑约束\n\n这些规则来自 Doramagic 发现、验证或编译过程中的项目专属坑点。宿主 AI 必须把它们当作工作约束，而不是普通说明文字。\n\n### Constraint 1: 来源证据：Selected model is at capacity. Please try a different model. The same error everyday\n\n- Trigger: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Selected model is at capacity. Please try a different model. The same error everyday\n- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- Why it matters: 可能阻塞安装或首次运行。\n- Evidence: community_evidence:github | cevd_2839c851344f4b669bd1c21b29e7bd08 | https://github.com/openai/codex/issues/22456 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 2: 来源证据：Extensive UI flickering when codex is working\n\n- Trigger: GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：Extensive UI flickering when codex is working\n- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- Why it matters: 可能增加新用户试用和生产接入成本。\n- Evidence: community_evidence:github | cevd_47a11c3a9f3943168527e0a086872c1f | https://github.com/openai/codex/issues/11901 | 来源类型 github_issue 暴露的待验证使用条件。\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 3: 来源证据：Codex Desktop voice transcription blocked by Cloudflare challenge on /backend-api/transcribe after resolved incident\n\n- Trigger: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Codex Desktop voice transcription blocked by Cloudflare challenge on /backend-api/transcribe after resolved incident\n- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- Why it matters: 可能阻塞安装或首次运行。\n- Evidence: community_evidence:github | cevd_dcdaacada441496491e68dd4db3d802b | https://github.com/openai/codex/issues/21985 | 来源讨论提到 macos 相关条件，需在安装/试用前复核。\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 4: 来源证据：Codex IDE extension fails GitHub MCP startup with \"connection closed: initialize response\" in PyCharm AI Chat\n\n- Trigger: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Codex IDE extension fails GitHub MCP startup with \"connection closed: initialize response\" in PyCharm AI Chat\n- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- Why it matters: 可能影响授权、密钥配置或安全边界。\n- Evidence: community_evidence:github | cevd_45286dbe57a44800be79bc6a5819956f | https://github.com/openai/codex/issues/22461 | 来源类型 github_issue 暴露的待验证使用条件。\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 5: 来源证据：Iranian phone numbers are not supported for Codex login\n\n- Trigger: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Iranian phone numbers are not supported for Codex login\n- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- Why it matters: 可能影响授权、密钥配置或安全边界。\n- Evidence: community_evidence:github | cevd_d651d7b5cf594cafa27dfffa45890baa | https://github.com/openai/codex/issues/21918 | 来源类型 github_issue 暴露的待验证使用条件。\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 6: 来源证据：Codex Desktop falsely reports @chrome plugin unavailable when bundled Chrome plugin is installed\n\n- Trigger: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Codex Desktop falsely reports @chrome plugin unavailable when bundled Chrome plugin is installed\n- Host AI rule: 来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- Why it matters: 可能增加新用户试用和生产接入成本。\n- Evidence: community_evidence:github | cevd_a0eee5b5c5fb447ebe2c2d3bdf74aa33 | https://github.com/openai/codex/issues/22463 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 7: 来源证据：Windows Chrome plugin hangs in setupAtlasRuntime despite extension/native host checks passing\n\n- Trigger: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Windows Chrome plugin hangs in setupAtlasRuntime despite extension/native host checks passing\n- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- Why it matters: 可能增加新用户试用和生产接入成本。\n- Evidence: community_evidence:github | cevd_4d667016a4ab4f9aa5416a3b08e71d55 | https://github.com/openai/codex/issues/22462 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 8: 能力判断依赖假设\n\n- Trigger: README/documentation is current enough for a first validation pass.\n- Host AI rule: 将假设转成下游验证清单。\n- Why it matters: 假设不成立时，用户拿不到承诺的能力。\n- Evidence: capability.assumptions | github_repo:965415649 | https://github.com/openai/codex | README/documentation is current enough for a first validation pass.\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 9: 来源证据：/goal-first sessions are missing from resume lists\n\n- Trigger: GitHub 社区证据显示该项目存在一个运行相关的待验证问题：/goal-first sessions are missing from resume lists\n- Host AI rule: 来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- Why it matters: 可能增加新用户试用和生产接入成本。\n- Evidence: community_evidence:github | cevd_e65f6682c39b409a8c96267f4bdc1d3e | https://github.com/openai/codex/issues/20792 | 来源类型 github_issue 暴露的待验证使用条件。\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 10: 来源证据：I have to set up the workspace every time I start a new session. My Codex usage quota is decreasing automatically even…\n\n- Trigger: GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：I have to set up the workspace every time I start a new session. My Codex usage quota is decreasing automatically even though I haven’t used it at all.\n- Host AI rule: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- Why it matters: 可能增加新用户试用和生产接入成本。\n- Evidence: community_evidence:github | cevd_f8afe7124b3e44cfacbc62a9e001179c | https://github.com/openai/codex/issues/22457 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n",
      "summary": "给宿主 AI 的上下文和工作边界。",
      "title": "AI Context Pack / 带给我的 AI"
    },
    "boundary_risk_card": {
      "asset_id": "boundary_risk_card",
      "filename": "BOUNDARY_RISK_CARD.md",
      "markdown": "# Boundary & Risk Card / 安装前决策卡\n\n项目：openai/codex\n\n## Doramagic 试用结论\n\n当前结论：可以进入发布前推荐检查；首次使用仍应从最小权限、临时目录和可回滚配置开始。\n\n## 用户现在可以做\n\n- 可以先阅读 Human Manual，理解项目目的和主要工作流。\n- 可以复制 Prompt Preview 做安装前体验；这只验证交互感，不代表真实运行。\n- 可以把官方 Quick Start 命令放到隔离环境中验证，不要直接进主力环境。\n\n## 现在不要做\n\n- 不要把 Prompt Preview 当成项目实际运行结果。\n- 不要把 metadata-only validation 当成沙箱安装验证。\n- 不要把未验证能力写成“已支持、已跑通、可放心安装”。\n- 不要在首次试用时交出生产数据、私人文件、真实密钥或主力配置目录。\n\n## 安装前检查\n\n- 宿主 AI 是否匹配：chatgpt\n- 官方安装入口状态：已发现官方入口\n- 是否在临时目录、临时宿主或容器中验证：必须是\n- 是否能回滚配置改动：必须能\n- 是否需要 API Key、网络访问、读写文件或修改宿主配置：未确认前按高风险处理\n- 是否记录了安装命令、实际输出和失败日志：必须记录\n\n## 当前阻塞项\n\n- 无阻塞项。\n\n## 项目专属踩坑\n\n- 来源证据：Selected model is at capacity. Please try a different model. The same error everyday（high）：可能阻塞安装或首次运行。 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 来源证据：Extensive UI flickering when codex is working（high）：可能增加新用户试用和生产接入成本。 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 来源证据：Codex Desktop voice transcription blocked by Cloudflare challenge on /backend-api/transcribe after resolved incident（high）：可能阻塞安装或首次运行。 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 来源证据：Codex IDE extension fails GitHub MCP startup with \"connection closed: initialize response\" in PyCharm AI Chat（high）：可能影响授权、密钥配置或安全边界。 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 来源证据：Iranian phone numbers are not supported for Codex login（high）：可能影响授权、密钥配置或安全边界。 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n\n## 风险与权限提示\n\n- no_demo: medium\n\n## 证据缺口\n\n- 暂未发现结构化证据缺口。\n",
      "summary": "安装、权限、验证和推荐前风险。",
      "title": "Boundary & Risk Card / 边界与风险卡"
    },
    "human_manual": {
      "asset_id": "human_manual",
      "filename": "HUMAN_MANUAL.md",
      "markdown": "# https://github.com/openai/codex 项目说明书\n\n生成时间：2026-05-13 10:17:37 UTC\n\n## 目录\n\n- [项目概述](#page-overview)\n- [系统架构](#page-architecture)\n- [协议层详解](#page-protocol)\n- [核心Agent模块](#page-core-agent)\n- [执行系统](#page-execution)\n- [终端用户界面](#page-tui)\n- [技能系统](#page-skills)\n- [插件系统](#page-plugins)\n- [Hook系统](#page-hooks)\n- [沙箱与安全](#page-sandboxing)\n\n<a id='page-overview'></a>\n\n## 项目概述\n\n### 相关页面\n\n相关主题：[系统架构](#page-architecture), [核心Agent模块](#page-core-agent)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [README.md](https://github.com/openai/codex/blob/main/README.md)\n- [codex-rs/tui/src/slash_command.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n- [codex-rs/tui/src/bottom_pane/footer.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/footer.rs)\n- [codex-rs/config/src/profile_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/profile_toml.rs)\n- [codex-rs/config/src/tui_keymap.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/tui_keymap.rs)\n- [codex-rs/config/src/config_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n</details>\n\n# 项目概述\n\n## 什么是 Codex CLI\n\nCodex CLI 是 OpenAI 开发的本地编程智能助手，能够在用户的计算机上本地运行。它是一个跨平台的命令行工具，旨在帮助开发者完成各种编码任务，包括代码编写、文件编辑、Git 操作和终端命令执行。 资料来源：[README.md:1]()\n\nCodex 提供三种使用形态：\n\n| 使用形态 | 说明 | 访问方式 |\n|---------|------|---------|\n| **CLI 工具** | 本地终端界面，运行在用户计算机上 | 运行 `codex` 命令 |\n| **IDE 插件** | 集成在 VS Code、Cursor、Windsurf 等编辑器中 | 安装 IDE 插件 |\n| **桌面应用** | 独立的桌面客户端体验 | 运行 `codex app` 或访问网页版 |\n\n对于云端智能助手版本（Codex Web），用户可以访问 chatgpt.com/codex。 资料来源：[README.md:8]()\n\n## 安装与运行\n\n### 安装方式\n\nCodex 支持两种主流安装方式：\n\n```shell\n# 使用 npm 全局安装\nnpm install -g @openai/codex\n\n# 使用 Homebrew 安装\nbrew install --cask codex\n```\n\n安装完成后，直接在终端运行 `codex` 即可启动。 资料来源：[README.md:17-28]()\n\n## 核心功能模块\n\n### 命令系统（Slash Commands）\n\nCodex CLI 内置丰富的斜杠命令系统，用户可以通过 `/` 前缀调用各种功能：\n\n| 命令类别 | 功能项 | 说明 |\n|---------|-------|------|\n| 会话管理 | `/resume`, `/fork`, `/clear` | 恢复会话、分叉会话、清除终端 |\n| 文件操作 | `/mention`, `/diff` | 提及文件、显示 Git 差异 |\n| 配置管理 | `/status`, `/debug-config`, `/settings` | 查看状态、调试配置、设置选项 |\n| 开发工具 | `/skills`, `/hooks`, `/mcp` | 技能系统、生命周期钩子、MCP 工具 |\n| 界面定制 | `/theme`, `/keymap`, `/pets`, `/title` | 主题、快捷键、终端宠物、标题栏 |\n| 执行控制 | `/plan`, `/goal`, `/stop` | 计划模式、目标设置、停止后台进程 |\n| 权限管理 | `/permissions`, `/elevate-sandbox` | 权限配置、沙盒提升 |\n| 高级功能 | `/realtime`, `/collab`, `/agent` | 实时语音、协作模式、多代理 |\n\n资料来源：[codex-rs/tui/src/slash_command.rs:1-50]()\n\n### 快捷键系统\n\nCodex 的文本用户界面（TUI）支持全面的快捷键绑定，主要包括：\n\n**运动类快捷键**\n\n| 操作 | 默认绑定 | 说明 |\n|------|---------|------|\n| `motion_left` | 左移 | 光标向左移动 |\n| `motion_right` | 右移 | 光标向右移动 |\n| `motion_up` | 上移 | 光标向上移动一行 |\n| `motion_down` | 下移 | 光标向下移动一行 |\n| `motion_word_forward` | `w` | 移动到下一个单词开头 |\n| `motion_word_backward` | `b` | 移动到上一个单词开头 |\n| `motion_word_end` | `e` | 移动到单词结尾 |\n| `motion_line_start` | `0` | 移动到行首 |\n| `motion_line_end` | `$` | 移动到行尾 |\n\n**分页器快捷键**\n\n| 操作 | 功能 |\n|------|------|\n| `scroll_up` / `scroll_down` | 按行滚动 |\n| `page_up` / `page_down` | 按页滚动 |\n| `half_page_up` / `half_page_down` | 半页滚动 |\n| `jump_top` / `jump_bottom` | 跳转到顶部/底部 |\n| `close` / `close_transcript` | 关闭分页器/转录 |\n\n**列表和审批快捷键**\n\n| 类别 | 操作 |\n|------|------|\n| 列表 | `move_up`, `move_down`, `accept`, `cancel` |\n| 审批 | `open_fullscreen`, `open_thread`, `approve`, `deny`, `decline` |\n\n资料来源：[codex-rs/config/src/tui_keymap.rs:1-50]()\n\n### 底部面板与状态栏\n\nCodex 界面底部面板展示各类快捷操作提示，包括：\n\n- 命令执行相关快捷键\n- Shell 命令快捷键\n- 文件路径操作（粘贴图片、外部编辑器调用）\n- 历史记录搜索\n- 推理模式切换（`reasoning_down` / `reasoning_up`）\n- 会话转录显示\n\n底部面板采用双列布局展示各项功能，每列之间有 4 个字符的间距。 资料来源：[codex-rs/tui/src/bottom_pane/footer.rs:1-50]()\n\n### 状态显示系统\n\n状态栏提供实时的工作环境信息：\n\n| 状态项 | 说明 | 示例值 |\n|-------|------|--------|\n| `AppName` | 应用名称 | Codex |\n| `ProjectName` | 项目名称 | my-project |\n| `GitBranch` | 当前 Git 分支 | feat/awesome-feature |\n| `PullRequestNumber` | PR 编号 | PR #123 |\n| `BranchChanges` | 分支变更统计 | +12 -3 |\n| `Permissions` | 权限级别 | Workspace |\n| `ContextRemaining` | 剩余上下文 | Context 0% left |\n| `UsedTokens` | 已使用 Token | 0 used |\n| `Model` | 当前模型 | gpt-5.2-codex |\n| `SessionId` | 会话 ID | 550e8400-e29b-41d4 |\n\n资料来源：[codex-rs/tui/src/status/card.rs:1-50](), [codex-rs/tui/src/status_surfaces.rs:1-40]()\n\n## 配置系统\n\n### 配置文件结构\n\nCodex 采用 TOML 格式的配置文件，支持多层级配置：\n\n```toml\n# 全局配置\n[profile.default]\nmodel = \"gpt-5\"\ninclude_apply_patch_tool = true\ninclude_permissions_instructions = true\n\n# TUI 配置\n[profile.default.tui]\nsession_picker_view = \"grid\"  # 或 \"list\"\n\n# 实验性功能\n[profile.default.features]\ncodex_git_commit = true\nexperimental_realtime = false\n```\n\n### 配置选项说明\n\n| 配置项 | 类型 | 说明 |\n|-------|------|------|\n| `model_instructions_file` | 路径 | 自定义模型指令文件（不推荐） |\n| `compact_prompt` | 字符串 | 历史压缩提示词 |\n| `commit_attribution` | 字符串 | 提交信息中的共同作者署名 |\n| `forced_chatgpt_workspace_id` | 字符串 | 限制登录到特定工作区 |\n| `forced_login_method` | 枚举 | 强制使用特定登录方式 |\n\n资料来源：[codex-rs/config/src/profile_toml.rs:1-40](), [codex-rs/config/src/config_toml.rs:1-50]()\n\n## 主题与语法高亮\n\nCodex 内置多种语法高亮主题，支持自定义代码显示颜色：\n\n**可用主题列表**\n\n| 主题名称 | 类型 |\n|---------|------|\n| catppuccin-latte / macchiato / mocha | 暖色调 |\n| coldark-cold / dark | 冷色调 |\n| dark-neon | 霓虹风格 |\n| dracula | 经典紫红 |\n| github | GitHub 风格 |\n| gruvbox-dark / light | 复古风格 |\n| inspired-github | GitHub 灵感 |\n| 1337 (leet) | 黑客风格 |\n| monokai-extended 系列 | Monokai 扩展 |\n| nord | 北欧极简 |\n| one-half-dark / light | 简约双色 |\n\n资料来源：[codex-rs/tui/src/render/highlight.rs:1-60]()\n\n## 目标与预算系统\n\nCodex 内置目标追踪系统，支持长时间运行任务的规划与监控：\n\n```mermaid\ngraph TD\n    A[创建目标] --> B{预算检查}\n    B -->|预算充足| C[执行任务]\n    B -->|预算耗尽| D[触发预算限制提示]\n    C --> E[目标更新]\n    E --> F{任务完成?}\n    F -->|否| C\n    F -->|是| G[目标达成]\n    D --> H[暂停或终止]\n```\n\n目标系统包含以下组件：\n\n- **目标模板**：使用 Markdown 模板定义目标展示格式\n- **预算限制**：监控任务消耗，必要时触发提醒\n- **目标更新**：实时反馈目标进展状态\n\n资料来源：[codex-rs/core/src/goals.rs:1-60]()\n\n## 环境上下文\n\nCodex 能够感知并注入当前工作环境信息：\n\n```xml\n<environment_context>\n  <environments>\n    <environment id=\"local\">\n      <cwd>/path/to/project</cwd>\n      <shell>bash</shell>\n    </environment>\n  </environments>\n  <current_date>2024-01-15</current_date>\n  <timezone>Asia/Shanghai</timezone>\n</environment_context>\n```\n\n| 环境组件 | 说明 |\n|---------|------|\n| `cwd` | 当前工作目录 |\n| `shell` | 终端类型（bash/zsh/powershell） |\n| `network` | 网络状态信息 |\n| `subagents` | 子代理信息（多代理模式下） |\n\n资料来源：[codex-rs/core/src/context/environment_context.rs:1-50]()\n\n## 应用与插件系统\n\nCodex 支持外部应用集成和 MCP（Model Context Protocol）工具：\n\n```mermaid\ngraph LR\n    A[Codex CLI] --> B[应用系统]\n    A --> C[MCP 工具]\n    B --> D{应用配置}\n    D -->|已启用| E[集成到界面]\n    D -->|已禁用| F[隐藏]\n    C --> G[工具列表]\n    G --> H[详细工具说明]\n```\n\n**应用元数据结构**\n\n| 字段 | 说明 |\n|-----|------|\n| `id` | 应用唯一标识 |\n| `name` | 显示名称 |\n| `description` | 应用描述 |\n| `logo_url` | 图标 URL |\n| `is_enabled` | 是否启用 |\n| `install_url` | 安装链接 |\n\n资料来源：[codex-rs/app-server-protocol/src/protocol/v2/apps.rs:1-50]()\n\n## 架构总览\n\n```mermaid\ngraph TB\n    subgraph 前端层\n        A[命令行入口] --> B[文本用户界面 TUI]\n        B --> C[底部面板]\n        B --> D[状态栏]\n        B --> E[快捷键系统]\n    end\n    \n    subgraph 配置层\n        F[配置文件] --> G[配置解析器]\n        G --> H[Profile 管理]\n        H --> I[TUI 设置]\n        H --> J[功能开关]\n    end\n    \n    subgraph 核心层\n        K[会话管理] --> L[目标系统]\n        K --> M[上下文管理]\n        M --> N[环境感知]\n        L --> O[预算控制]\n    end\n    \n    subgraph 集成层\n        P[IDE 插件接口] --> Q[应用系统]\n        P --> R[MCP 工具]\n        Q --> S[应用市场]\n    end\n    \n    A --> K\n    G --> K\n```\n\n## 技术栈概述\n\n| 组件 | 技术选型 | 说明 |\n|-----|---------|------|\n| CLI 核心 | Rust | 高性能本地执行 |\n| 前端界面 | 自研 TUI | 终端文本用户界面 |\n| 配置格式 | TOML | 人类可读的配置文件 |\n| 主题系统 | TextMate 主题格式 | 兼容主流编辑器语法高亮 |\n| 序列化 | JSON Schema | API 数据结构定义 |\n| 类型导出 | TypeScript | 前端类型安全 |\n\n## 快速入门\n\n1. **安装 Codex**：`npm i -g @openai/codex` 或 `brew install --cask codex`\n2. **启动应用**：运行 `codex` 命令\n3. **查看帮助**：输入 `/help` 或查看底部快捷键提示\n4. **自定义配置**：编辑 `~/.codex/config.toml`\n5. **切换主题**：使用 `/theme` 命令选择语法高亮主题\n\n## 相关资源\n\n- 官方文档：[developers.openai.com/codex/ide](https://developers.openai.com/codex/ide)\n- 桌面应用：运行 `codex app` 或访问 chatgpt.com/codex\n- IDE 插件：支持 VS Code、Cursor、Windsurf\n\n---\n\n<a id='page-architecture'></a>\n\n## 系统架构\n\n### 相关页面\n\n相关主题：[协议层详解](#page-protocol), [核心Agent模块](#page-core-agent), [终端用户界面](#page-tui)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/config/src/state.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n- [codex-rs/config/src/loader/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/loader/mod.rs)\n- [codex-rs/config/src/config_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n- [codex-rs/config/src/profile_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/profile_toml.rs)\n- [codex-rs/core/src/context/environment_context.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/context/environment_context.rs)\n- [codex-rs/core/src/goals.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/goals.rs)\n- [codex-rs/tui/src/chatwidget.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n- [codex-rs/file-search/README.md](https://github.com/openai/codex/blob/main/codex-rs/file-search/README.md)\n</details>\n\n# 系统架构\n\n## 1. 概述\n\nCodex CLI 是 OpenAI 开发的一个本地代码智能助手，采用 Rust 语言重写实现。该项目遵循模块化架构设计，将功能拆分为多个独立但协作的子系统。\n\n核心架构包含以下几个主要层次：\n\n| 层次 | 模块 | 职责 |\n|------|------|------|\n| 配置层 | `codex-rs/config/` | 管理配置加载、层级合并、需求约束 |\n| 核心层 | `codex-rs/core/` | 处理环境上下文、目标管理、推理逻辑 |\n| 交互层 | `codex-rs/tui/` | 终端用户界面、聊天组件、状态显示 |\n| 文件搜索 | `codex-rs/file-search/` | 模糊文件搜索、模式匹配 |\n| 沙箱层 | `codex-rs/windows-sandbox-rs/` | Windows 平台沙箱环境 |\n\n资料来源：[codex-rs/README.md](https://github.com/openai/codex/blob/main/codex-rs/README.md)\n\n## 2. 配置系统架构\n\n### 2.1 配置层级结构\n\nCodex 采用多层配置架构，不同来源的配置按优先级合并。配置层级从低到高依次为：\n\n```mermaid\ngraph TD\n    A[系统配置<br/>System] --> B[用户配置<br/>User]\n    B --> C[项目配置<br/>Project]\n    C --> D[MDM 托管配置<br/>MDM Managed]\n    D --> E[会话标志配置<br/>Session Flags]\n    \n    style A fill:#e1f5fe\n    style E fill:#fff3e0\n```\n\n`ConfigLayerStack` 结构维护配置层级列表，其中 `layers` 向量按从低优先级（基础）到高优先级（覆盖）的顺序排列。资料来源：[codex-rs/config/src/state.rs:1-50](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n\n### 2.2 配置来源枚举\n\n```rust\npub enum ConfigLayerSource {\n    System { file: PathBuf },\n    User { file: PathBuf },\n    Project { dot_codex_folder: AbsolutePathBuf },\n    Mdm { domain: String, key: String },\n    SessionFlags,\n    LegacyManagedConfigTomlFromFile { file: PathBuf },\n    LegacyManagedConfigTomlFromMdm,\n}\n```\n\n每种配置来源对应不同的配置文件位置：\n\n| 来源类型 | 文件位置 | 说明 |\n|---------|---------|------|\n| System | 系统指定路径 | 系统级配置 |\n| User | 用户目录 `~/.codex/` | 用户个性化配置 |\n| Project | 项目 `.codex/` 目录 | 项目特定配置 |\n| MDM | 移动设备管理 | 企业托管配置 |\n| SessionFlags | 命令行参数 | 会话级别覆盖 |\n\n资料来源：[codex-rs/config/src/state.rs:1-30](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n\n### 2.3 配置文件加载流程\n\n配置加载器 (`ConfigLoader`) 负责协调多层级配置的读取和合并：\n\n```mermaid\nsequenceDiagram\n    participant User as 用户/CLI\n    participant Loader as ConfigLoader\n    participant FileSystem as 文件系统\n    participant Merger as 配置合并器\n    \n    User->>Loader: 启动 Codex\n    Loader->>FileSystem: 读取系统配置\n    FileSystem-->>Loader: system.toml\n    Loader->>FileSystem: 读取用户配置\n    FileSystem-->>Loader: config.toml\n    Loader->>FileSystem: 读取项目配置\n    FileSystem-->>Loader: .codex/config.toml\n    Loader->>Merger: 合并配置层级\n    Merger-->>User: 最终配置\n```\n\n配置加载过程中的关键步骤包括：\n1. 解析 TOML 格式的配置文件\n2. 清理无效的项目配置键\n3. 解析相对路径为绝对路径\n4. 合并 Git worktree 的钩子配置\n\n资料来源：[codex-rs/config/src/loader/mod.rs:1-80](https://github.com/openai/codex/blob/main/codex-rs/config/src/loader/mod.rs)\n\n### 2.4 Profile 配置结构\n\nProfile 机制允许用户定义命名配置集，每个 Profile 可包含独立的 TUI 设置、窗口配置和功能开关：\n\n```rust\npub struct ProfileTui {\n    /// Resume/Fork 会话选择器的首选布局\n    pub session_picker_view: Option<SessionPickerViewMode>,\n}\n\npub struct FeaturesToml {\n    // 注入已知功能键到 schema\n}\n```\n\nProfile 作用域的配置包括：\n- TUI 布局偏好设置\n- 窗口配置\n- 功能特性开关\n\n资料来源：[codex-rs/config/src/profile_toml.rs:1-50](https://github.com/openai/codex/blob/main/codex-rs/config/src/profile_toml.rs)\n\n### 2.5 配置诊断系统\n\n当配置解析失败时，诊断系统提供详细的错误报告：\n\n```rust\npub fn format_config_error(error: &ConfigError, contents: &str) -> String {\n    // 输出格式: path:line:column: message\n    // 包含错误位置的高亮行\n}\n```\n\n错误报告包含文件路径、行号、列号和错误消息，并从 TOML 解析的 span 信息中提取错误位置。资料来源：[codex-rs/config/src/diagnostics.rs:1-40](https://github.com/openai/codex/blob/main/codex-rs/config/src/diagnostics.rs)\n\n## 3. 环境上下文系统\n\n### 3.1 上下文数据模型\n\n环境上下文 (`EnvironmentContext`) 聚合了 Codex 运行所需的全部环境信息：\n\n```mermaid\ngraph TD\n    EC[EnvironmentContext] --> Env[Environments]\n    EC --> Date[CurrentDate]\n    EC --> TZ[Timezone]\n    EC --> Net[Network]\n    EC --> Subs[Subagents]\n    \n    Env --> Single[Single Environment]\n    Env --> Multiple[Multiple Environments]\n    Env --> None[None]\n```\n\n关键字段：\n- **environments**: 工作目录和 shell 信息\n- **current_date**: 当前日期\n- **timezone**: 时区设置\n- **network**: 网络连接状态\n- **subagents**: 子代理信息\n\n资料来源：[codex-rs/core/src/context/environment_context.rs:1-60](https://github.com/openai/codex/blob/main/codex-rs/core/src/context/environment_context.rs)\n\n### 3.2 上下文 XML 渲染\n\n环境上下文以 XML 格式渲染，供模型理解当前执行环境：\n\n```xml\n<environment_context>\n  <environment id=\"main\">\n    <cwd>/path/to/project</cwd>\n    <shell>bash</shell>\n  </environment>\n  <current_date>2024-01-15</current_date>\n  <timezone>Asia/Shanghai</timezone>\n</environment_context>\n```\n\n资料来源：[codex-rs/core/src/context/environment_context.rs:60-100](https://github.com/openai/codex/blob/main/codex-rs/core/src/context/environment_context.rs)\n\n## 4. 目标管理系统\n\n### 4.1 目标生命周期\n\nCodex 的目标 (Goal) 系统管理长时间运行的任务：\n\n```mermaid\nstateDiagram-v2\n    [*] --> NewGoal: 设置目标\n    NewGoal --> Active: 开始执行\n    Active --> Paused: 中断\n    Active --> Completed: 完成\n    Active --> Failed: 失败\n    Paused --> Active: 恢复\n    Failed --> [*]\n    Completed --> [*]\n```\n\n`ExternalGoalPreviousStatus` 枚举表示外部目标变更前的状态：\n- `NewGoal`: 新创建的逻辑目标\n- `Existing`: 更新的现有目标\n\n资料来源：[codex-rs/core/src/goals.rs:1-80](https://github.com/openai/codex/blob/main/codex-rs/core/src/goals.rs)\n\n### 4.2 预算限制与节流\n\n目标系统内置预算限制提示模板：\n- `continuation.md`: 继续执行提示\n- `budget_limit.md`: 预算耗尽提示\n- `objective_updated.md`: 目标更新通知\n\n资料来源：[codex-rs/core/src/goals.rs:80-120](https://github.com/openai/codex/blob/main/codex-rs/core/src/goals.rs)\n\n## 5. TUI 终端用户界面\n\n### 5.1 组件架构\n\nTUI 模块采用组件化设计：\n\n```\ntui/src/\n├── chatwidget.rs          # 聊天消息组件\n├── markdown_render_tests.rs # Markdown 渲染测试\n└── bottom_pane/\n    ├── footer.rs          # 底部状态栏\n    ├── status_surface_preview.rs # 状态预览\n    └── approval_overlay.rs # 审批覆盖层\n```\n\n### 5.2 风险等级映射\n\n聊天组件 (`chatwidget`) 处理来自应用服务器协议的风险等级映射：\n\n```mermaid\ngraph LR\n    A[GuardianRiskLevel] --> B[AppServer]\n    B --> C[chatwidget]\n    C --> D[Protocol]\n    \n    D --> Low\n    D --> Medium\n    D --> High\n    D --> Critical\n```\n\n| 应用服务器等级 | 协议等级 |\n|--------------|---------|\n| Low | Low |\n| Medium | Medium |\n| High | High |\n| Critical | Critical |\n\n资料来源：[codex-rs/tui/src/chatwidget.rs:1-50](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n\n### 5.3 状态栏配置\n\n底部面板显示快捷命令和状态信息：\n\n| 类别 | 快捷键 |\n|------|--------|\n| 常规命令 | `/` |\n| Shell 命令 | `!` |\n| 队列消息 | `Tab` |\n| 退出 | `Ctrl+C` |\n| 推理导航 | `Ctrl+↑/↓` |\n\n自定义快捷键可通过 `/keymap` 命令配置。资料来源：[codex-rs/tui/src/bottom_pane/footer.rs:1-50](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/footer.rs)\n\n### 5.4 状态预览项\n\n状态表面预览显示会话的各类状态信息：\n\n| 预览项 | 示例值 |\n|-------|--------|\n| AppName | Codex |\n| GitBranch | feat/awesome-feature |\n| PullRequestNumber | PR #123 |\n| BranchChanges | +12 -3 |\n| ContextRemaining | Context 0% left |\n| UsedTokens | 0 used |\n| Model | gpt-5.2-codex |\n| FastMode | Fast on |\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_surface_preview.rs:1-50](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/status_surface_preview.rs)\n\n### 5.5 审批覆盖层\n\n文件变更审批系统提供多种决策选项：\n\n| 选项 | 快捷键 | 效果 |\n|------|--------|------|\n| Yes, proceed | approve | 接受变更 |\n| Yes, don't ask again | approve_for_session | 本次会话接受 |\n| No, tell Codex | reject | 拒绝并说明 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:1-60](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/approval_overlay.rs)\n\n## 6. 文件搜索模块\n\n### 6.1 搜索架构\n\n`codex_file_search` 模块提供快速的模糊文件搜索能力：\n\n```mermaid\ngraph TD\n    Input[搜索模式] --> Traverse[目录遍历]\n    Traverse --> Ignore[应用 .gitignore]\n    Ignore --> Files[文件列表]\n    Files --> Fuzzy[模糊匹配]\n    Fuzzy --> Results[结果排序]\n```\n\n核心依赖：\n- **ignore**: 目录遍历（ripgrep 使用的 crate）\n- **nucleo-matcher**: 快速模糊匹配\n\n资料来源：[codex-rs/file-search/README.md](https://github.com/openai/codex/blob/main/codex-rs/file-search/README.md)\n\n## 7. Slash 命令系统\n\n### 7.1 命令分类\n\nSlash 命令通过 `/` 触发，提供丰富的交互功能：\n\n| 类别 | 命令 | 功能 |\n|------|------|------|\n| 会话管理 | `/resume`, `/fork`, `/clear` | 恢复、分叉、清空会话 |\n| 文件操作 | `/diff`, `/mention` | Git 差异、提及文件 |\n| 模型控制 | `/model`, `/personality` | 选择模型、交流风格 |\n| 权限管理 | `/permissions`, `/elevate-sandbox` | 权限设置 |\n| 实验功能 | `/experimental`, `/realtime` | 开关实验特性 |\n\n支持内联参数的命令：\n- `/review`, `/rename`, `/plan`, `/goal`\n- `/ide`, `/keymap`, `/mcp`, `/pets`, `/side`\n- `/resume`, `/sandbox-read-root`\n\n资料来源：[codex-rs/tui/src/slash_command.rs:1-100](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n\n## 8. 安装与部署\n\n### 8.1 安装方式\n\n| 方式 | 命令 |\n|------|------|\n| npm | `npm i -g @openai/codex` |\n| Homebrew | `brew install --cask codex` |\n| GitHub Releases | 下载平台特定二进制 |\n\n### 8.2 目录结构\n\n```\n$CODEX_HOME/\n├── config.toml          # 用户配置\n├── sessions/            # 会话数据\n├── log/                 # 日志文件\n└── hooks/               # 生命周期钩子\n```\n\n- **sqlite_home**: SQLite 数据库路径，默认 `$CODEX_HOME`\n- **log_dir**: 日志目录，默认 `$CODEX_HOME/log`\n\n资料来源：[codex-rs/config/src/config_toml.rs:1-50](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n\n## 9. 模块依赖关系\n\n```mermaid\ngraph TD\n    App[codex-rs 主程序]\n    Config[config 模块]\n    Core[core 模块]\n    TUI[TUI 模块]\n    FileSearch[file-search 模块]\n    Sandbox[windows-sandbox-rs]\n    \n    App --> Config\n    App --> Core\n    App --> TUI\n    Core --> FileSearch\n    Core --> Sandbox\n    TUI --> Config\n    TUI --> Core\n```\n\n各模块职责清晰分离，通过公共接口交互，便于维护和测试。\n\n---\n\n<a id='page-protocol'></a>\n\n## 协议层详解\n\n### 相关页面\n\n相关主题：[系统架构](#page-architecture), [核心Agent模块](#page-core-agent)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/tui/src/chatwidget.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n- [codex-rs/app-server-protocol/src/protocol/v2/apps.rs](https://github.com/openai/codex/blob/main/codex-rs/app-server-protocol/src/protocol/v2/apps.rs)\n- [codex-rs/config/src/state.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n- [codex-rs/config/src/config_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n- [codex-rs/config/src/config_requirements.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_requirements.rs)\n- [codex-rs/tui/src/bottom_pane/approval_overlay.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/approval_overlay.rs)\n</details>\n\n# 协议层详解\n\n## 1. 概述\n\nCodex 项目的协议层是连接前端界面（TUI）、后端服务（App Server）和核心引擎（Core）之间的通信桥梁。该层定义了数据类型转换、API 协议版本管理、以及跨模块通信的数据结构规范。\n\n协议层主要包含两个核心命名空间：\n- `codex_app_server_protocol`：应用服务器协议定义\n- `codex_protocol`：Codex 核心协议定义\n\n## 2. 协议架构\n\n### 2.1 模块组织结构\n\n```\ncodex-rs/\n├── app-server-protocol/src/protocol/\n│   ├── mod.rs           # 协议主入口\n│   ├── v1.rs           # 版本 1 协议定义\n│   └── v2/             # 版本 2 协议定义\n│       ├── mod.rs\n│       ├── apps.rs     # 应用相关协议\n│       └── ...\n```\n\n### 2.2 协议层次关系图\n\n```mermaid\ngraph TD\n    subgraph \"前端层 TUI\"\n        A[ChatWidget]\n        B[ApprovalOverlay]\n        C[StatusSurface]\n    end\n    \n    subgraph \"协议转换层\"\n        D[codex_app_server_protocol]\n        E[codex_protocol]\n    end\n    \n    subgraph \"核心层 Core\"\n        F[Guardian]\n        G[Approvals]\n    end\n    \n    A --> D\n    B --> D\n    C --> D\n    \n    D --> E\n    E --> F\n    E --> G\n    \n    style D fill:#f9f,color:#000\n    style E fill:#9f9,color:#000\n```\n\n## 3. 风险等级协议\n\n### 3.1 风险等级定义\n\nCodex 使用统一的四层风险等级体系，用于评估操作的安全性和敏感度。\n\n| 风险等级 | 说明 | 适用场景 |\n|---------|------|---------|\n| `Low` | 低风险操作 | 读取文件、查看状态 |\n| `Medium` | 中等风险 | 修改配置、创建文件 |\n| `High` | 高风险 | 执行命令、修改系统 |\n| `Critical` | 极高风险 | 删除文件、权限变更 |\n\n**资料来源**：[codex-rs/tui/src/chatwidget.rs:1-20](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n\n### 3.2 协议间转换\n\n风险等级在 `codex_app_server_protocol` 和 `codex_protocol` 之间存在一一映射关系：\n\n```rust\n(|risk_level| match risk_level {\n    codex_app_server_protocol::GuardianRiskLevel::Low => {\n        codex_protocol::approvals::GuardianRiskLevel::Low\n    }\n    codex_app_server_protocol::GuardianRiskLevel::Medium => {\n        codex_protocol::approvals::GuardianRiskLevel::Medium\n    }\n    codex_app_server_protocol::GuardianRiskLevel::High => {\n        codex_protocol::approvals::GuardianRiskLevel::High\n    }\n    codex_app_server_protocol::GuardianRiskLevel::Critical => {\n        codex_protocol::approvals::GuardianRiskLevel::Critical\n    }\n})\n```\n\n**资料来源**：[codex-rs/tui/src/chatwidget.rs:1-20](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n\n## 4. 用户授权协议\n\n### 4.1 授权等级定义\n\n| 授权等级 | 说明 | 权限范围 |\n|---------|------|---------|\n| `Unknown` | 未知状态 | 未确定授权级别 |\n| `Low` | 低授权 | 基础操作权限 |\n| `Medium` | 中等授权 | 常规开发操作 |\n| `High` | 高授权 | 敏感操作权限 |\n\n### 4.2 授权协议转换\n\n用户授权信息在协议间进行转换：\n\n```rust\nuser_authorization: review.user_authorization.map(|user_authorization| {\n    match user_authorization {\n        codex_app_server_protocol::GuardianUserAuthorization::Unknown => {\n            codex_protocol::approvals::GuardianUserAuthorization::Unknown\n        }\n        codex_app_server_protocol::GuardianUserAuthorization::Low => {\n            codex_protocol::approvals::GuardianUserAuthorization::Low\n        }\n        codex_app_server_protocol::GuardianUserAuthorization::Medium => {\n            codex_protocol::approvals::GuardianUserAuthorization::Medium\n        }\n        codex_app_server_protocol::GuardianUserAuthorization::High => {\n            codex_protocol::approvals::GuardianUserAuthorization::High\n        }\n    }\n})\n```\n\n**资料来源**：[codex-rs/tui/src/chatwidget.rs:1-30](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n\n## 5. 应用协议（V2）\n\n### 5.1 应用信息结构\n\n应用元数据结构定义如下：\n\n```rust\npub struct AppInfo {\n    pub id: String,\n    pub name: String,\n    pub description: Option<String>,\n    pub logo_url: Option<String>,\n    pub logo_url_dark: Option<String>,\n    pub distribution_channel: Option<String>,\n    pub branding: Option<AppBranding>,\n    pub app_metadata: Option<AppMetadata>,\n    pub labels: Option<HashMap<String, String>>,\n    pub install_url: Option<String>,\n    #[serde(default)]\n    pub is_accessible: bool,\n    #[serde(default = \"default_enabled\")]\n    pub is_enabled: bool,\n    #[serde(default)]\n    pub plugin_display_names: Vec<String>,\n}\n```\n\n**资料来源**：[codex-rs/app-server-protocol/src/protocol/v2/apps.rs:50-70](https://github.com/openai/codex/blob/main/codex-rs/app-server-protocol/src/protocol/v2/apps.rs)\n\n### 5.2 应用元数据\n\n应用元数据支持以下字段：\n\n| 字段 | 类型 | 说明 |\n|-----|------|-----|\n| `screenshots` | `Vec<AppScreenshot>` | 应用截图列表 |\n| `developer` | `String` | 开发者信息 |\n| `version` | `String` | 版本号 |\n| `version_id` | `String` | 版本标识 |\n| `version_notes` | `String` | 版本说明 |\n| `first_party_type` | `String` | 第一方类型 |\n| `first_party_requires_install` | `bool` | 是否需要安装 |\n| `show_in_composer_when_unlinked` | `bool` | 未链接时显示 |\n\n**资料来源**：[codex-rs/app-server-protocol/src/protocol/v2/apps.rs:30-50](https://github.com/openai/codex/blob/main/codex-rs/app-server-protocol/src/protocol/v2/apps.rs)\n\n## 6. 配置层协议\n\n### 6.1 配置层级来源\n\n配置层定义在 `ConfigLayerSource` 枚举中，支持多种配置来源：\n\n| 来源类型 | 说明 | 优先级 |\n|---------|------|-------|\n| `Mdm` | MDM 托管偏好 | 最高 |\n| `System` | 系统级配置 | 高 |\n| `User` | 用户级配置 | 中 |\n| `Project` | 项目级 `.codex/config.toml` | 低 |\n| `SessionFlags` | 会话命令行参数 | 特殊 |\n\n```rust\npub enum ConfigLayerSource {\n    Mdm { domain: String, key: String },\n    System { file: PathBuf },\n    User { file: PathBuf },\n    Project { dot_codex_folder: AbsolutePathBuf },\n    SessionFlags,\n    LegacyManagedConfigTomlFromFile { file: PathBuf },\n    LegacyManagedConfigTomlFromMdm,\n}\n```\n\n**资料来源**：[codex-rs/config/src/state.rs:50-80](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n\n### 6.2 配置需求协议\n\n配置需求通过 `RequirementSource` 定义来源：\n\n```rust\npub enum RequirementSource {\n    Unknown,\n    MdmManagedPreferences { domain: String, key: String },\n    CloudRequirements,\n    SystemRequirementsToml { file: PathBuf },\n    LegacyManagedConfigTomlFromFile { file: PathBuf },\n    LegacyManagedConfigTomlFromMdm,\n}\n```\n\n**资料来源**：[codex-rs/config/src/config_requirements.rs:1-30](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_requirements.rs)\n\n### 6.3 配置层堆栈\n\n```mermaid\ngraph LR\n    A[System Config] --> B[User Config]\n    B --> C[Project Config]\n    C --> D[Session Flags]\n    D --> E[MDM Config]\n    \n    style A fill:#eee,color:#000\n    style E fill:#f96,color:#000\n```\n\n配置层堆栈顺序定义：\n\n```rust\npub enum ConfigLayerStackOrdering {\n    LowestPrecedenceFirst,\n    HighestPrecedenceFirst,\n}\n\npub struct ConfigLayerStack {\n    /// 从最低优先级（基础）到最高优先级（顶层）\n    layers: Vec<ConfigLayerEntry>,\n    /// 用户配置层索引\n    user_layer_index: Option<usize>,\n}\n```\n\n**资料来源**：[codex-rs/config/src/state.rs:80-100](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n\n## 7. 审批协议\n\n### 7.1 审批决策来源\n\n自动审查决策来源定义：\n\n```rust\nenum AutoReviewDecisionSource {\n    Agent,\n}\n```\n\n### 7.2 审批选项配置\n\n审批覆盖层支持的选项：\n\n| 选项标签 | 决策类型 | 说明 |\n|---------|---------|------|\n| `Yes, proceed` | `Accept` | 接受变更 |\n| `Yes, and don't ask again for these files` | `AcceptForSession` | 本会话内接受 |\n| `No, and tell Codex what to do differently` | `Reject` | 拒绝并反馈 |\n\n**资料来源**：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:50-80](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/approval_overlay.rs)\n\n### 7.3 文件系统路径协议\n\n| 特殊路径 | 说明 |\n|---------|------|\n| `:root` | 项目根目录 |\n| `:minimal` | 最小访问范围 |\n| `:project_roots` | 所有项目根目录 |\n| `:tmpdir` | 系统临时目录 |\n| `/tmp` | 传统临时目录路径 |\n\n**资料来源**：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:20-50](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/approval_overlay.rs)\n\n## 8. 状态显示协议\n\n### 8.1 状态行项目\n\n状态行支持显示以下信息项目：\n\n| 项目 | 示例值 | 说明 |\n|-----|-------|------|\n| `AppName` | Codex | 应用名称 |\n| `ProjectName` | my-project | 项目名称 |\n| `GitBranch` | feat/awesome-feature | Git 分支 |\n| `PullRequestNumber` | PR #123 | PR 编号 |\n| `BranchChanges` | +12 -3 | 分支变更统计 |\n| `ContextRemaining` | Context 0% left | 上下文剩余 |\n| `ContextUsed` | Context 0% used | 上下文使用量 |\n| `Model` | gpt-5.2-codex | 当前模型 |\n| `ModelWithReasoning` | gpt-5.2-codex medium | 模型及推理级别 |\n\n**资料来源**：[codex-rs/tui/src/bottom_pane/status_surface_preview.rs:20-50](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/status_surface_preview.rs)\n\n### 8.2 状态项目分类\n\n状态项目按语义分类：\n\n| 分类 | 对应项目 | 语法高亮作用域 |\n|-----|---------|--------------|\n| `Model` | 模型名称 | `entity.name.type` |\n| `Path` | 路径信息 | `string` |\n| `Branch` | 分支信息 | `entity.name.function` |\n| `State` | 运行状态 | `keyword.control` |\n| `Usage` | 使用量统计 | `constant.numeric` |\n| `Limit` | 限制信息 | `constant.language` |\n| `Mode` | 模式切换 | `storage.modifier` |\n| `Thread` | 线程标题 | `markup.heading` |\n| `Progress` | 任务进度 | `markup.inserted` |\n\n**资料来源**：[codex-rs/tui/src/bottom_pane/status_line_style.rs:30-60](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/status_line_style.rs)\n\n## 9. 序列化与类型安全\n\n### 9.1 JSON Schema 生成\n\n协议类型通过 `schemars` 库自动生成 JSON Schema：\n\n```rust\n#[derive(JsonSchema)]\n#[schemars(schema_with = \"crate::schema::features_schema\")]\npub features: Option<FeaturesToml>,\n```\n\n### 9.2 TypeScript 类型导出\n\n使用 `serde` 和 `ts` 属性导出 TypeScript 类型：\n\n```rust\n#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]\n#[serde(rename_all = \"camelCase\")]\n#[ts(export_to = \"v2/\")]\npub struct AppInfo { ... }\n```\n\n## 10. 总结\n\nCodex 的协议层设计遵循以下原则：\n\n1. **类型安全**：使用 Rust 强类型系统确保协议转换的正确性\n2. **版本管理**：支持 V1 和 V2 协议版本共存\n3. **分层设计**：清晰的协议层次结构，便于维护和扩展\n4. **双向转换**：支持 `codex_app_server_protocol` 与 `codex_protocol` 之间的无缝转换\n5. **可扩展性**：通过可选字段和枚举变体支持功能扩展\n\n---\n\n<a id='page-core-agent'></a>\n\n## 核心Agent模块\n\n### 相关页面\n\n相关主题：[系统架构](#page-architecture), [执行系统](#page-execution), [技能系统](#page-skills)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/core/src/lib.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/lib.rs)\n- [codex-rs/core/src/agent/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/agent/mod.rs)\n- [codex-rs/core/src/client.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/client.rs)\n- [codex-rs/core/src/session/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/session/mod.rs)\n- [codex-rs/core/src/tools/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/tools/mod.rs)\n- [codex-rs/core/src/goals.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/goals.rs)\n- [codex-rs/core/src/context/environment_context.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/context/environment_context.rs)\n- [codex-rs/config/src/state.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n- [codex-rs/config/src/profile_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/profile_toml.rs)\n- [codex-rs/tui/src/slash_command.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n</details>\n\n# 核心Agent模块\n\n## 概述\n\nCodex CLI 的核心Agent模块是整个系统的中枢组件，负责协调用户交互、工具调用、上下文管理和会话生命周期。该模块采用 Rust 实现，运行于本地计算机，提供零依赖的安装体验。\n\n资料来源：[codex-rs/README.md:1-15]()\n\n## 模块架构\n\n### 核心组件关系\n\n```mermaid\ngraph TD\n    subgraph \"核心层\"\n        A[Agent] --> B[Client]\n        A --> C[Session]\n        A --> D[Tools]\n    end\n    \n    subgraph \"上下文层\"\n        C --> E[EnvironmentContext]\n        C --> F[Goals]\n    end\n    \n    subgraph \"配置层\"\n        G[Config] --> C\n        G --> A\n    end\n    \n    subgraph \"UI层\"\n        H[TUI] --> A\n        H --> C\n    end\n```\n\n### 核心模块职责\n\n| 模块 | 职责 | 主要文件 |\n|------|------|----------|\n| Agent | 主控制逻辑、任务调度、决策 | `core/src/agent/mod.rs` |\n| Client | 与后端API通信、协议处理 | `core/src/client.rs` |\n| Session | 会话状态管理、历史记录 | `core/src/session/mod.rs` |\n| Tools | 工具注册、调用、结果处理 | `core/src/tools/mod.rs` |\n| Goals | 目标跟踪、预算管理 | `core/src/goals.rs` |\n\n资料来源：[codex-rs/core/src/lib.rs]()\n\n## Agent主模块\n\n### 主控制流程\n\nAgent模块作为协调者，处理用户输入并生成响应：\n\n```mermaid\ngraph LR\n    A[用户输入] --> B[解析命令]\n    B --> C{命令类型}\n    C -->|工具调用| D[工具选择]\n    C -->|聊天| E[模型推理]\n    D --> F[执行工具]\n    E --> G[生成响应]\n    F --> H[结果处理]\n    H --> G\n    G --> I[渲染输出]\n```\n\n### 任务执行状态\n\nAgent维护任务执行的状态机：\n\n```mermaid\nstateDiagram-v2\n    [*] --> Idle: 初始化\n    Idle --> Running: 接收任务\n    Running --> WaitingApproval: 需要确认\n    WaitingApproval --> Running: 批准\n    WaitingApproval --> Cancelled: 拒绝\n    Running --> Paused: 暂停/恢复\n    Paused --> Running: 恢复\n    Running --> Completed: 任务完成\n    Completed --> Idle: [*]\n    Cancelled --> Idle: [*]\n```\n\n资料来源：[codex-rs/core/src/agent/mod.rs]()\n\n## Client客户端模块\n\n### API通信机制\n\nClient模块负责与OpenAI后端服务通信，采用Protocol Buffers定义的协议：\n\n```rust\n// 风险级别映射\nGuardianRiskLevel::Low\nGuardianRiskLevel::Medium  \nGuardianRiskLevel::High\nGuardianRiskLevel::Critical\n```\n\n资料来源：[codex-rs/tui/src/chatwidget.rs:1-30]()\n\n### 请求/响应处理\n\nClient支持多种API交互模式：\n\n| 模式 | 描述 | 用途 |\n|------|------|------|\n| 标准对话 | 同步请求-响应 | 日常交互 |\n| 流式响应 | Server-Sent Events | 实时输出 |\n| 工具调用 | Tool Use协议 | 代码执行 |\n\n## Session会话管理\n\n### 会话生命周期\n\n会话模块管理Codex的完整交互周期：\n\n```mermaid\ngraph TD\n    A[创建会话] --> B[加载配置]\n    B --> C[初始化环境]\n    C --> D[处理消息]\n    D --> E{任务状态}\n    E -->|完成| F[保存会话]\n    E -->|暂停| G[保存草稿]\n    E -->|失败| H[记录错误]\n    F --> I[会话结束]\n    G --> J[可恢复]\n    H --> I\n```\n\n### 配置层级\n\n会话使用分层配置系统，按优先级从低到高：\n\n| 层级 | 来源 | 覆盖方式 |\n|------|------|----------|\n| 系统配置 | `/etc/codex/config.toml` | 不可覆盖 |\n| 用户配置 | `~/.config/codex/config.toml` | 可覆盖 |\n| 项目配置 | `.codex/config.toml` | 可覆盖 |\n| 会话标志 | 命令行参数 | 最高优先级 |\n\n资料来源：[codex-rs/config/src/state.rs:1-50]()\n\n### 配置配置文件结构\n\n```toml\n[profile.default]\nmodel = \"gpt-4o\"\ninclude_apply_patch_tool = true\ninclude_permissions_instructions = true\ninclude_environment_context = true\n\n[profile.default.tui]\nsession_picker_view = \"grid\"\n\n[profile.default.features]\nexperimental_unified_exec = true\n```\n\n资料来源：[codex-rs/config/src/profile_toml.rs:1-80]()\n\n## Tools工具系统\n\n### 工具注册与调用\n\nTools模块提供Codex的扩展能力：\n\n| 工具类别 | 功能 | 配置项 |\n|----------|------|--------|\n| 文件操作 | 读取、写入、编辑文件 | `include_apply_patch_tool` |\n| 权限管理 | 访问控制、审批流程 | `include_permissions_instructions` |\n| 应用集成 | Apps指令 | `include_apps_instructions` |\n| 协作模式 | 多人协作 | `include_collaboration_mode_instructions` |\n\n资料来源：[codex-rs/config/src/profile_toml.rs:50-70]()\n\n### 工具执行流程\n\n```mermaid\nsequenceDiagram\n    participant U as 用户\n    participant A as Agent\n    participant T as Tools\n    participant S as 沙箱\n    \n    U->>A: 发送请求\n    A->>T: 选择工具\n    T->>S: 执行命令\n    S-->>T: 返回结果\n    T-->>A: 工具响应\n    A-->>U: 生成回复\n```\n\n## Goals目标系统\n\n### 目标跟踪机制\n\nGoals模块管理长时间运行任务的进度和预算：\n\n```rust\n// 预算限制提示模板\nstatic BUDGET_LIMIT_PROMPT_TEMPLATE: LazyLock<Template> = \n    LazyLock::new(|| {\n        Template::parse(include_str!(\"../templates/goals/budget_limit.md\"))\n    });\n```\n\n资料来源：[codex-rs/core/src/goals.rs:1-50]()\n\n### 外部目标变更\n\n目标系统支持外部修改：\n\n```mermaid\ngraph TD\n    A[外部目标更新] --> B{目标状态}\n    B -->|新目标| C[创建Goal]\n    B -->|已有目标| D[更新Goal]\n    C --> E[ExternalGoalPreviousStatus::NewGoal]\n    D --> F[ExternalGoalPreviousStatus::Existing]\n```\n\n资料来源：[codex-rs/core/src/goals.rs:80-120]()\n\n### 预算限制级别\n\n| 级别 | 描述 | 触发条件 |\n|------|------|----------|\n| BudgetLimitSteering::Allowed | 允许超出 | 任务重要 |\n| BudgetLimitSteering::Suppressed | 抑制超出 | 接近限制 |\n\n## 环境上下文\n\n### 上下文组件\n\nEnvironmentContext提供Agent运行时的环境信息：\n\n```xml\n<environment>\n  <cwd>/path/to/project</cwd>\n  <shell>bash</shell>\n</environment>\n<subagents>\n  <!-- 子代理信息 -->\n</subagents>\n<network enabled=\"true\" />\n```\n\n资料来源：[codex-rs/core/src/context/environment_context.rs:1-60]()\n\n### 上下文渲染\n\n上下文信息以结构化XML格式注入到模型提示中：\n\n| 组件 | 内容 | 用途 |\n|------|------|------|\n| `cwd` | 当前工作目录 | 路径解析 |\n| `shell` | 使用的shell | 命令生成 |\n| `environments` | 多环境配置 | 复杂项目 |\n| `current_date` | 当前日期时间 | 时间相关任务 |\n| `subagents` | 子代理状态 | 多任务协调 |\n\n## 交互命令\n\n### Slash Commands\n\nCodex支持丰富的斜杠命令系统：\n\n| 命令 | 功能 | 状态 |\n|------|------|------|\n| `/resume` | 恢复保存的会话 | 活跃 |\n| `/fork` | 派生当前会话 | 活跃 |\n| `/model` | 选择模型和推理级别 | 活跃 |\n| `/ide` | 包含IDE上下文 | 活跃 |\n| `/plan` | 切换到计划模式 | 活跃 |\n| `/goal` | 设置长时间任务目标 | 活跃 |\n| `/mcp` | 列出配置的MCP工具 | 活跃 |\n| `/memory` | 内存管理 | **废弃** |\n| `/agent` | 切换活动代理线程 | 活跃 |\n\n资料来源：[codex-rs/tui/src/slash_command.rs:1-100]()\n\n## 状态显示\n\n### 状态栏项目\n\nTUI显示关键状态信息：\n\n| 项目 | 格式 | 说明 |\n|------|------|------|\n| `GitBranch` | `feat/awesome-feature` | 当前分支 |\n| `BranchChanges` | `+12 -3` | 分支变更统计 |\n| `ContextUsed` | `Context 0% used` | 上下文使用率 |\n| `UsedTokens` | `0 used` | 已使用Token数 |\n| `ModelWithReasoning` | `gpt-5.2-codex medium` | 模型+推理级别 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_surface_preview.rs:1-50]()\n\n### 状态线样式\n\n状态栏采用语义化颜色方案：\n\n| 类别 | 颜色 | 样式作用域 |\n|------|------|-----------|\n| Model/State | 青色 | 模型名称、运行状态 |\n| Path/Usage | 绿色 | 文件路径、Token使用 |\n| Branch/Limit | 洋红 | 分支名、限制信息 |\n| Mode/Thread | 蓝绿 | 模式、线程信息 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_line_style.rs:1-40]()\n\n## 审批系统\n\n### 风险级别\n\nCodex实现四级风险评估：\n\n| 级别 | GuardianRiskLevel | 用户授权 |\n|------|-------------------|----------|\n| 低风险 | Low | 无需确认 |\n| 中风险 | Medium | 需要确认 |\n| 高风险 | High | 明确批准 |\n| 严重风险 | Critical | 拒绝执行 |\n\n### 审批决策\n\n| 决策选项 | 快捷键 | 效果 |\n|----------|--------|------|\n| Yes, proceed | 批准 | 立即执行 |\n| Yes, and don't ask again | Session级别 | 当前会话记住 |\n| No, and tell Codex | 拒绝 | 说明原因 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:1-80]()\n\n## MCP支持\n\n### MCP客户端\n\nCodex作为MCP客户端连接外部工具服务器：\n\n```mermaid\ngraph LR\n    A[Codex CLI] -->|MCP协议| B[MCP Server 1]\n    A -->|MCP协议| C[MCP Server 2]\n    B -->|工具| A\n    C -->|工具| A\n```\n\n### MCP服务器模式\n\nCodex可作为MCP服务器运行，允许其他MCP客户端调用：\n\n```bash\ncodex mcp-server\n```\n\n## 配置系统\n\n### 配置文件位置\n\n| 位置 | 说明 | 优先级 |\n|------|------|--------|\n| `~/.config/codex/config.toml` | 用户级配置 | 中 |\n| `.codex/config.toml` | 项目级配置 | 高 |\n| `/etc/codex/config.toml` | 系统级配置 | 低 |\n\n### Hooks配置\n\nHooks声明文件位置由配置系统决定：\n\n```rust\npub fn hooks_config_folder(&self) -> Option<AbsolutePathBuf> {\n    self.hooks_config_folder_override\n        .clone()\n        .or_else(|| self.config_folder())\n}\n```\n\n资料来源：[codex-rs/config/src/state.rs:80-100]()\n\n## 总结\n\n核心Agent模块是Codex CLI的架构中枢，通过以下设计实现高效代码辅助：\n\n1. **模块化架构** - Agent、Client、Session、Tools解耦设计\n2. **分层配置** - 支持系统、用户、项目多级配置覆盖\n3. **协议驱动** - 使用Protocol Buffers进行类型安全通信\n4. **工具生态** - 通过MCP扩展工具能力\n5. **安全保障** - 四级风险评估和审批机制\n6. **状态可视化** - 丰富的TUI状态显示\n\n---\n\n<a id='page-execution'></a>\n\n## 执行系统\n\n### 相关页面\n\n相关主题：[沙箱与安全](#page-sandboxing), [核心Agent模块](#page-core-agent)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/config/src/state.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n- [codex-rs/config/src/config_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n- [codex-rs/config/src/profile_toml.rs](https://github.com/openai/codex/config/src/profile_toml.rs)\n- [codex-rs/tui/src/slash_command.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n- [codex-rs/tui/src/bottom_pane/approval_overlay.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/approval_overlay.rs)\n\n> **注意**：当前检索上下文中未包含 `exec-server`、`unified_exec`、`exec`、`shell-command` 等执行系统核心模块的源码。以下内容基于配置层、权限审批和命令行界面相关代码进行整理，待获取完整执行系统源码后可进一步补充。\n\n</details>\n\n# 执行系统\n\n## 概述\n\n执行系统（Execution System）是 Codex CLI 的核心子系统，负责在沙箱环境中安全地执行用户请求的操作，包括文件读写、终端命令运行、Git 操作等。该系统通过多层配置体系管理权限范围，并提供用户审批机制以确保操作的安全性与可控性。\n\n## 核心架构\n\n### 配置层级体系\n\nCodex CLI 的执行系统采用分层配置架构，不同层级的配置具有不同的优先级：\n\n| 层级 | 名称 | 优先级 | 配置来源 |\n|------|------|--------|----------|\n| 系统级 | System | 最低 | `/etc/codex/config.toml` |\n| 用户级 | User | 中 | `~/.config/codex/config.toml` |\n| 项目级 | Project | 高 | `.codex/config.toml` |\n| 会话级 | SessionFlags | 最高 | 命令行参数 |\n\n资料来源：[codex-rs/config/src/state.rs:1-50]()\n\n```mermaid\ngraph TD\n    A[System Layer<br/>/etc/codex/config.toml] --> B[User Layer<br/>~/.config/codex/config.toml]\n    B --> C[Project Layer<br/>.codex/config.toml]\n    C --> D[Session Flags<br/>Command Line Args]\n    D --> E[Effective Config<br/>最终生效配置]\n```\n\n配置层级的加载顺序决定了最终生效的配置：后加载的层级会覆盖先前的同名配置项。\n\n### 权限配置模型\n\n执行系统通过 `include_permissions_instructions` 配置项控制是否向模型注入权限指令：\n\n```toml\n# 配置示例\ninclude_permissions_instructions = true\n```\n\n资料来源：[codex-rs/config/src/config_toml.rs:1-30]()\n\n### 工具配置\n\n执行系统支持的工具通过 `[tools]` 配置块进行管理：\n\n| 配置项 | 说明 |\n|--------|------|\n| `tools_view_image` | 是否启用图像查看工具 |\n| `include_apply_patch_tool` | 是否启用 patch 应用工具 |\n| `experimental_use_unified_exec_tool` | 启用统一执行工具（实验性） |\n| `experimental_use_freeform_apply_patch` | 启用自由格式 patch（实验性） |\n\n## 审批系统\n\n### 审批决策类型\n\nCodex CLI 的执行系统提供细粒度的审批决策机制：\n\n| 决策类型 | 说明 |\n|----------|------|\n| `Accept` | 接受并执行当前操作 |\n| `AcceptForSession` | 接受并在本会话内跳过后续同类审批 |\n| `Reject` | 拒绝并要求用户重新说明意图 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:1-40]()\n\n### 文件系统路径约束\n\n执行系统支持对文件系统访问范围进行约束：\n\n| 路径类型 | 说明 | 示例 |\n|----------|------|------|\n| `:root` | 项目根目录 | `/home/user/project` |\n| `:minimal` | 最小访问范围 | - |\n| `:project_roots` | 项目根目录列表 | - |\n| `:tmpdir` | 系统临时目录 | `/tmp` |\n| `/tmp` | 明确指定的临时路径 | `/tmp/codex` |\n\n### 审批界面快捷键\n\n| 快捷键操作 | 功能 |\n|------------|------|\n| 批准 | 执行当前操作 |\n| 批准并记住 | 在当前会话内自动批准同类操作 |\n| 拒绝 | 拒绝并要求重新说明 |\n\n## 命令行界面集成\n\n### Slash 命令\n\n执行系统与 TUI 的 slash 命令系统深度集成，以下命令与执行直接相关：\n\n| 命令 | 说明 |\n|------|------|\n| `/resume` | 恢复已保存的对话会话 |\n| `/clear` | 清除终端并开始新对话 |\n| `/fork` | 分叉当前对话 |\n| `/diff` | 显示 Git 差异（包括未跟踪文件） |\n| `/permissions` | 配置 Codex 的操作权限范围 |\n| `/elevate-sandbox` | 设置提升权限的沙箱环境 |\n| `/sandbox-read-root` | 允许沙箱读取指定目录 |\n\n资料来源：[codex-rs/tui/src/slash_command.rs:1-60]()\n\n### 支持内联参数的命令\n\n以下命令支持在命令后直接附加参数：\n\n- `/review` - 代码审查\n- `/rename` - 重命名\n- `/plan` - 计划模式\n- `/goal` - 设置目标\n- `/ide` - IDE 上下文\n- `/keymap` - 快捷键映射\n- `/mcp` - MCP 工具管理\n- `/pets` - 终端宠物\n\n## 配置要求系统\n\n### 配置约束来源\n\nCodex CLI 的配置可能受到多种来源的约束：\n\n| 约束来源 | 说明 |\n|----------|------|\n| `Unknown` | 未指定来源 |\n| `MdmManagedPreferences` | MDM 托管偏好设置 |\n| `CloudRequirements` | 云端配置要求 |\n| `SystemRequirementsToml` | 系统级 requirements.toml |\n| `LegacyManagedConfigTomlFromFile` | 旧版托管配置文件 |\n| `LegacyManagedConfigTomlFromMdm` | MDM 旧版托管配置 |\n\n### 约束数据结构\n\n```rust\npub struct ConstrainedWithSource<T> {\n    pub value: Constrained<T>,\n    pub source: Option<RequirementSource>,\n}\n```\n\n该结构确保每个受限配置都能追溯其来源，便于调试和审计。\n\n## 环境上下文\n\n执行系统在构建提示时会注入环境上下文信息：\n\n```xml\n<environment>\n  <shell>bash</shell>\n  <cwd>/path/to/project</cwd>\n</environment>\n<current_date>2024-01-15</current_date>\n<timezone>UTC+8</timezone>\n```\n\n资料来源：[codex-rs/core/src/context/environment_context.rs:1-50]()\n\n## 实验性功能\n\n### 统一执行工具\n\n```toml\n[features]\nexperimental_use_unified_exec_tool = true\n```\n\n### 协作模式\n\n```toml\ninclude_collaboration_mode_instructions = true\n```\n\n## 状态显示\n\n执行系统运行状态通过状态行（Status Line）向用户展示：\n\n| 状态项 | 说明 |\n|--------|------|\n| `UsedTokens` | 已使用的 token 数量 |\n| `ContextRemaining` | 剩余上下文百分比 |\n| `Status` | 当前运行状态 |\n| `Permissions` | 当前权限级别 |\n| `ApprovalMode` | 审批模式状态 |\n\n资料来源：[codex-rs/tui/src/chatwidget/status_surfaces.rs:1-30]()\n\n## 快捷键绑定\n\n执行系统与编辑器的快捷键配置通过 `[keymap]` 块进行自定义：\n\n```toml\n[keymap]\nmotion_up = \"k\"\nmotion_down = \"j\"\nmotion_left = \"h\"\nmotion_right = \"l\"\n```\n\n支持的按键绑定类型包括动作模式下的标准 Vim 风格快捷键。\n\n## 安全模型\n\n执行系统的安全模型基于以下原则：\n\n1. **最小权限原则**：默认情况下仅授予必要权限\n2. **用户可控**：通过 `/permissions` 命令动态调整权限范围\n3. **审批机制**：敏感操作需用户显式批准\n4. **会话隔离**：权限审批结果可限定在当前会话内生效\n\n---\n\n> 本页基于当前检索到的源码生成。执行系统核心模块（`exec-server`、`unified_exec`、`exec`、`shell-command`）的详细技术说明待补充完整源码后更新。\n\n---\n\n<a id='page-tui'></a>\n\n## 终端用户界面\n\n### 相关页面\n\n相关主题：[系统架构](#page-architecture), [核心Agent模块](#page-core-agent)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/tui/src/lib.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/lib.rs)\n- [codex-rs/tui/src/chatwidget.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/chatwidget.rs)\n- [codex-rs/tui/src/bottom_pane/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/mod.rs)\n- [codex-rs/tui/src/slash_command.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n- [codex-rs/tui/src/bottom_pane/footer.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/footer.rs)\n- [codex-rs/tui/src/keymap_setup/actions.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/keymap_setup/actions.rs)\n- [codex-rs/tui/src/bottom_pane/status_line_style.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/status_line_style.rs)\n- [codex-rs/tui/src/bottom_pane/status_surface_preview.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/status_surface_preview.rs)\n- [codex-rs/tui/src/markdown.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/markdown.rs)\n- [codex-rs/tui/src/markdown_render.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/markdown_render.rs)\n</details>\n\n# 终端用户界面\n\n## 概述\n\n终端用户界面（Terminal User Interface，简称 TUI）是 Codex CLI 的核心组件之一，基于 Rust 语言和 ratatui 库构建，为用户提供了一个功能丰富的交互式终端界面。TUI 负责渲染聊天消息、处理用户输入、管理状态显示以及支持各种快捷操作。\n\nCodex 的 TUI 采用模块化设计，主要由以下几个核心部分组成：\n\n| 模块 | 文件路径 | 功能描述 |\n|------|----------|----------|\n| 应用主模块 | `tui/src/app.rs` | 应用生命周期管理和全局状态 |\n| 聊天窗口 | `tui/src/chatwidget.rs` | 消息展示和对话管理 |\n| 底部面板 | `tui/src/bottom_pane/` | 底部状态栏、页脚快捷键提示 |\n| Markdown 渲染 | `tui/src/markdown.rs` | Markdown 内容解析与渲染 |\n| 快捷键管理 | `tui/src/keymap_setup/` | 按键绑定配置 |\n\n资料来源：[codex-rs/tui/src/lib.rs]()\n\n## 架构设计\n\n### 组件层次结构\n\n```mermaid\ngraph TD\n    subgraph TUI层\n        A[App 主应用] --> B[ChatWidget 聊天窗口]\n        A --> C[BottomPane 底部面板]\n    end\n    \n    subgraph 底部面板子组件\n        C --> D[StatusLine 状态行]\n        C --> E[Footer 页脚]\n        C --> F[StatusSurface 状态表面]\n    end\n    \n    subgraph 渲染引擎\n        G[Markdown Renderer] --> H[Ratatui Lines]\n        G --> I[Span 样式化文本]\n    end\n    \n    B --> G\n```\n\n### 消息渲染流程\n\nCodex TUI 的 Markdown 渲染模块负责将 AI 生成的 Markdown 内容转换为 ratatui 可渲染的格式。该模块支持两种主要的渲染入口：\n\n- **`append_markdown`**：通用渲染，用于已预处理的 Markdown 内容（如 plan blocks 和历史消息）\n- **`append_markdown_agent`**：专为 Agent 响应设计，渲染前会先执行 `unwrap_markdown_fences` 操作\n\n资料来源：[codex-rs/tui/src/markdown.rs:1-30]()\n\n## 状态行系统\n\n状态行（Status Line）是 TUI 中用于显示当前会话信息和运行时状态的重要组件。\n\n### 状态项类型\n\n状态行支持多种类型的项目显示：\n\n| 状态项 | 说明 | 示例 |\n|--------|------|------|\n| `Model` | 当前使用的模型 | `gpt-5.2-codex` |\n| `ModelWithReasoning` | 模型及推理强度 | `gpt-5.2-codex medium` |\n| `GitBranch` | 当前 Git 分支 | `feat/awesome-feature` |\n| `PullRequestNumber` | 关联的 PR 编号 | `PR #123` |\n| `BranchChanges` | 分支变更统计 | `+12 -3` |\n| `CurrentDir` | 当前工作目录 | `/home/user/project` |\n| `ContextRemaining` | 上下文剩余百分比 | `Context 0% left` |\n| `UsedTokens` | 已使用的 Token 数 | `0 used` |\n| `TotalInputTokens` | 输入 Token 总数 | `0 in` |\n| `TotalOutputTokens` | 输出 Token 总数 | `0 out` |\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_surface_preview.rs:1-50]()\n\n### 状态行样式\n\n状态行使用不同的颜色样式来区分不同类型的信息：\n\n```rust\nfn fallback_style(self) -> Style {\n    match self {\n        Self::Model | Self::State | Self::Metadata | Self::Mode => Style::default().cyan(),\n        Self::Path | Self::Usage | Self::Progress => Style::default().green(),\n        Self::Branch | Self::Limit | Self::Thread => Style::default().magenta(),\n    }\n}\n```\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_line_style.rs:1-30]()\n\n## 底部面板\n\n底部面板是 TUI 的重要组成部分，包含页脚快捷键提示和其他辅助信息。\n\n### 页脚快捷键显示\n\n页脚区域显示用户可用的快捷键列表，按功能分组排列：\n\n| 类别 | 快捷键项 |\n|------|----------|\n| 命令 | `commands` |\n| Shell 命令 | `shell_commands` |\n| 消息操作 | `queue_message_tab` |\n| 文件操作 | `file_paths`, `paste_image` |\n| 编辑操作 | `external_editor`, `edit_previous` |\n| 导航操作 | `history_search`, `reasoning_down`, `reasoning_up` |\n| 系统操作 | `quit`, `change_mode` |\n\n页脚布局采用多列设计，使用 `build_columns` 函数将快捷键条目分配到两列显示：\n\n```rust\nconst COLUMNS: usize = 2;\nconst COLUMN_PADDING: [usize; COLUMNS] = [4, 4];\nconst COLUMN_GAP: usize = 4;\n```\n\n资料来源：[codex-rs/tui/src/bottom_pane/footer.rs:1-60]()\n\n### 状态表面预览\n\n状态表面（Status Surface）用于预览各种状态配置选项的显示效果。每个状态项都有对应的示例值，用于在设置界面中展示预览效果。\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_surface_preview.rs:50-80]()\n\n## 斜杠命令系统\n\nCodex TUI 支持通过斜杠命令（Slash Commands）触发各种功能。命令通过 `/` 前缀识别，并提供相应的描述信息。\n\n### 核心命令列表\n\n| 命令 | 描述 |\n|------|------|\n| `/resume` | 恢复保存的对话 |\n| `/clear` | 清除终端并开始新对话 |\n| `/fork` | 分叉当前对话 |\n| `/quit` / `/exit` | 退出 Codex |\n| `/copy` | 复制上次响应为 Markdown |\n| `/diff` | 显示 Git 差异（包括未跟踪文件） |\n| `/model` | 选择模型和推理强度 |\n| `/ide` | 包含 IDE 当前选择、打开文件等上下文 |\n| `/theme` | 选择语法高亮主题 |\n| `/pets` | 选择或隐藏终端宠物 |\n| `/keymap` | 重新映射 TUI 快捷键 |\n| `/settings` | 配置实时语音麦克风/扬声器 |\n| `/plan` | 切换到 Plan 模式 |\n| `/mcp` | 列出配置的 MCP 工具 |\n\n资料来源：[codex-rs/tui/src/slash_command.rs:1-80]()\n\n## 快捷键系统\n\n快捷键系统通过 `RuntimeKeymap` 结构管理，允许用户自定义按键绑定。\n\n### 按键映射结构\n\n快捷键按功能模块组织：\n\n```mermaid\ngraph TD\n    subgraph 按键映射分类\n        A[RuntimeKeymap] --> B[chat 聊天]\n        A --> C[composer 编辑器]\n        A --> D[editor 编辑器]\n        A --> E[pager 分页器]\n        A --> F[list 列表]\n        A --> G[approval 审批]\n    end\n    \n    subgraph Chat 快捷键\n        B --> B1[increase_reasoning_effort]\n        B --> B2[edit_queued_message]\n    end\n    \n    subgraph Composer 快捷键\n        C --> C1[submit]\n        C --> C2[queue]\n        C --> C3[toggle_shortcuts]\n    end\n    \n    subgraph Editor 快捷键\n        D --> D1[move_left/right]\n        D --> D2[delete_backward/forward]\n        D --> D3[move_word_left/right]\n    end\n```\n\n### 主要快捷键分类\n\n| 模块 | 功能 | 说明 |\n|------|------|------|\n| pager | `jump_top`, `jump_bottom`, `close` | 分页导航和关闭 |\n| list | `move_up`, `move_down`, `accept` | 列表导航和选择 |\n| approval | `approve`, `deny`, `approve_for_session` | 审批操作 |\n| chat | `increase_reasoning_effort` | 调整推理强度 |\n| composer | `submit`, `queue`, `toggle_shortcuts` | 消息提交 |\n| editor | `insert_newline`, `move_*`, `delete_*` | 文本编辑 |\n\n资料来源：[codex-rs/tui/src/keymap_setup/actions.rs:1-80]()\n\n## Markdown 渲染\n\n### 渲染特性\n\nMarkdown 渲染模块支持完整的 CommonMark 语法，并通过以下特性增强用户体验：\n\n- **代码块渲染**：支持带语言标识的围栏代码块\n- **表格处理**：特殊处理 LLMs 常用的 `markdown` 围栏代码块中的表格\n- **样式化文本**：支持加粗、斜体、删除线等内联样式\n- **链接处理**：识别并可点击的链接\n- **列表渲染**：有序列表和无序列表\n\n### 围栏代码块展开\n\nLLM Agent 经常将表格放在 `markdown` 围栏代码块中。渲染器会执行保守的展开策略：\n\n1. 缓冲整个围栏内容\n2. 仅对语言标识为 `md` 或 `markdown` 的围栏进行展开\n3. 只有当内容包含表头和分隔符时才执行展开\n4. 对未闭合的围栏优雅降级\n\n资料来源：[codex-rs/tui/src/markdown.rs:1-45]()\n\n### 支持的 Markdown 标签\n\n渲染器支持的标签类型：\n\n| 开始标签 | 结束标签 | 说明 |\n|----------|----------|------|\n| `Tag::Heading` | `TagEnd::Heading` | 标题 |\n| `Tag::BlockQuote` | `TagEnd::BlockQuote` | 引用块 |\n| `Tag::CodeBlock` | `TagEnd::CodeBlock` | 代码块 |\n| `Tag::List` | `TagEnd::List` | 列表 |\n| `Tag::Item` | `TagEnd::Item` | 列表项 |\n| `Tag::Emphasis` | `TagEnd::Emphasis` | 斜体 |\n| `Tag::Strong` | `TagEnd::Strong` | 加粗 |\n| `Tag::Link` | - | 链接 |\n| `Tag::Table` | `TagEnd::Table` | 表格 |\n\n资料来源：[codex-rs/tui/src/markdown_render.rs:1-80]()\n\n## 配置选项\n\n### TUI 配置文件\n\nTUI 相关配置通过 `config.toml` 中的 `tui` 部分进行设置：\n\n```toml\n[tui]\n# 状态行显示项配置\n# ...\n\n# 会话选择器视图模式\nsession_picker_view = \"grid\"  # 或 \"list\"\n```\n\n### Profile 级别的 TUI 设置\n\n每个命名 profile 可以包含独立的 TUI 配置：\n\n| 配置项 | 类型 | 说明 |\n|--------|------|------|\n| `session_picker_view` | `SessionPickerViewMode` | 恢复/分叉会话选择器的首选布局 |\n\n资料来源：[codex-rs/config/src/profile_toml.rs:1-50]()\n\n## 测试覆盖\n\nMarkdown 渲染模块包含完整的测试覆盖，测试用例涵盖：\n\n- 基本 Markdown 语法\n- 嵌套代码块\n- 带语言标识的围栏代码块\n- 波浪号和反引号围栏\n- 缩进代码块\n- 定义列表\n- 字符实体\n- URL 和链接\n\n```rust\n#[test]\nfn ordered_item_with_code_block_and_nested_bullet() {\n    let md = \"1. **item 1**\\n\\n2. **item 2**\\n   ```\\n   code\\n   ```\\n   - `PROCESS_START` (a `OnceLock<Instant>`)...\";\n    // 测试验证\n}\n```\n\n资料来源：[codex-rs/tui/src/markdown_render_tests.rs:1-50]()\n\n## 总结\n\nCodex CLI 的终端用户界面是一个精心设计的模块化系统，通过 Rust 语言的高性能和 ratatui 库的灵活性，为开发者提供了一个功能丰富、响应迅速的命令行交互体验。核心设计要点包括：\n\n1. **模块化架构**：清晰的组件划分，便于维护和扩展\n2. **丰富的状态显示**：实时反映系统状态和会话信息\n3. **灵活的快捷键系统**：支持用户自定义按键绑定\n4. **完整的 Markdown 支持**：优雅处理各种 Markdown 语法和边缘情况\n5. **可配置的 UI 选项**：通过 TOML 配置文件支持细粒度定制\n\n---\n\n<a id='page-skills'></a>\n\n## 技能系统\n\n### 相关页面\n\n相关主题：[核心Agent模块](#page-core-agent), [Hook系统](#page-hooks)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/core-skills/src/lib.rs](https://github.com/openai/codex/blob/main/codex-rs/core-skills/src/lib.rs)\n- [codex-rs/core-skills/src/manager.rs](https://github.com/openai/codex/blob/main/codex-rs/core-skills/src/manager.rs)\n- [codex-rs/core-skills/src/loader.rs](https://github.com/openai/codex/blob/main/codex-rs/core-skills/src/loader.rs)\n- [.codex/skills/code-review/SKILL.md](https://github.com/openai/codex/blob/main/.codex/skills/code-review/SKILL.md)\n- [.codex/skills/codex-bug/SKILL.md](https://github.com/openai/codex/blob/main/.codex/skills/codex-bug/SKILL.md)\n</details>\n\n# 技能系统\n\n## 概述\n\n技能系统（Skills System）是 Codex CLI 中的一个可扩展机制，允许用户通过自定义技能配置来增强 Codex 执行特定任务的能力。技能系统为 Codex 提供了额外的上下文信息和行为指导，使其能够更精准地理解和处理特定的开发任务场景。\n\n根据源码注释，技能系统的主要用途是：**\"use skills to improve how Codex performs specific tasks\"**（使用技能来改进 Codex 执行特定任务的方式）。\n\n## 核心架构\n\n### 模块结构\n\n技能系统的核心实现位于 `codex-rs/core-skills/` 目录下，采用模块化设计：\n\n| 模块 | 文件路径 | 职责 |\n|------|----------|------|\n| 核心接口 | `codex-rs/core-skills/src/lib.rs` | 定义技能系统的公共 API 和数据结构 |\n| 技能管理器 | `codex-rs/core-skills/src/manager.rs` | 负责技能的生命周期管理和调用逻辑 |\n| 技能加载器 | `codex-rs/core-skills/src/loader.rs` | 处理技能配置的加载和解析 |\n\n### 架构图\n\n```mermaid\ngraph TD\n    A[用户通过 /skills 命令触发] --> B[技能管理器 manager.rs]\n    B --> C[技能加载器 loader.rs]\n    C --> D[读取 .codex/skills/ 目录]\n    D --> E[解析 SKILL.md 配置文件]\n    E --> F[加载技能定义]\n    F --> G[向主上下文注入技能指令]\n    G --> H[增强 Codex 任务执行能力]\n    \n    style A fill:#e1f5fe\n    style H fill:#c8e6c9\n```\n\n## 技能定义格式\n\n### SKILL.md 文件结构\n\n技能通过 `.codex/skills/` 目录下的 `SKILL.md` 文件定义。每个技能目录代表一个独立的技能模块。\n\n技能配置采用 Markdown 格式，包含以下关键部分：\n\n| 组成部分 | 说明 |\n|----------|------|\n| 技能名称 | 技能的标识名称 |\n| 触发条件 | 定义何时激活该技能 |\n| 行为指令 | 告诉 Codex 如何处理特定任务的指令集 |\n| 示例用法 | 提供技能使用的示例场景 |\n\n### 现有技能示例\n\n仓库中预置了两个技能：\n\n| 技能名称 | 路径 | 用途 |\n|----------|------|------|\n| code-review | `.codex/skills/code-review/SKILL.md` | 代码审查技能 |\n| codex-bug | `.codex/skills/codex-bug/SKILL.md` | Bug 定位与修复技能 |\n\n## 技能管理器\n\n技能管理器（`manager.rs`）是技能系统的核心组件，负责以下职责：\n\n### 主要功能\n\n| 功能 | 描述 |\n|------|------|\n| 技能注册 | 将可用的技能注册到系统中 |\n| 技能选择 | 根据上下文选择合适的技能 |\n| 技能激活 | 在适当时机触发技能生效 |\n| 技能卸载 | 清理不再需要的技能资源 |\n\n### 管理器状态\n\n```mermaid\nstateDiagram-v2\n    [*] --> 未初始化: 系统启动\n    未初始化 --> 已加载: loader 解析成功\n    已加载 --> 就绪: 技能注册完成\n    就绪 --> 激活: 满足触发条件\n    激活 --> 就绪: 任务完成\n    激活 --> 已加载: 技能禁用\n    已加载 --> [*]: 系统关闭\n```\n\n## 技能加载器\n\n技能加载器（`loader.rs`）负责从文件系统读取和解析技能配置：\n\n### 加载流程\n\n```mermaid\ngraph LR\n    A[扫描 skills 目录] --> B[读取 SKILL.md]\n    B --> C[解析 Markdown]\n    C --> D[验证技能格式]\n    D --> E[构建技能对象]\n    E --> F[返回技能实例]\n    \n    D -->|格式错误| G[记录诊断信息]\n```\n\n### 配置路径\n\n| 路径类型 | 位置 | 说明 |\n|----------|------|------|\n| 用户级技能 | `~/.codex/skills/` | 用户自定义技能 |\n| 项目级技能 | `.codex/skills/` | 特定项目的技能配置 |\n| 系统级技能 | 内置 | Codex 预置的默认技能 |\n\n## 使用方式\n\n### 命令行交互\n\n用户可以通过斜杠命令（Slash Command）来访问技能功能：\n\n```bash\n/codex skills\n```\n\n此命令将显示可用的技能列表并允许用户选择激活特定技能。\n\n### 技能触发机制\n\n技能可以通过以下方式激活：\n\n| 触发方式 | 描述 |\n|----------|------|\n| 手动激活 | 用户通过 `/skills` 命令显式选择 |\n| 自动检测 | 系统根据任务上下文自动推荐相关技能 |\n| 规则匹配 | 根据文件路径或任务类型自动匹配技能 |\n\n## 配置与扩展\n\n### 添加自定义技能\n\n创建自定义技能的步骤：\n\n1. 在 `.codex/skills/` 目录下创建新的技能文件夹\n2. 在文件夹中创建 `SKILL.md` 文件\n3. 按照技能定义格式编写技能配置\n4. 重启 Codex 或使用 `/skills reload` 重新加载技能\n\n### 技能优先级\n\n当多个技能同时匹配时，系统按照以下优先级处理：\n\n| 优先级 | 来源 | 说明 |\n|--------|------|------|\n| 1 (最高) | 命令行参数 | 通过 `--skill` 参数指定的技能 |\n| 2 | 项目级技能 | `.codex/skills/` 中的配置 |\n| 3 | 用户级技能 | `~/.codex/skills/` 中的配置 |\n| 4 (最低) | 系统内置 | Codex 默认技能 |\n\n## 与其他系统集成\n\n### 与上下文系统集成\n\n技能系统的输出会作为环境上下文的一部分传递给 Codex：\n\n```xml\n<environment>\n  <skills>\n    <!-- 激活的技能配置 -->\n  </skills>\n</environment>\n```\n\n### 与权限系统集成\n\n技能执行受到权限系统（Permissions System）的约束，确保技能操作在用户授权范围内进行。\n\n### 与配置系统集成\n\n技能配置通过主配置系统（`codex-rs/config/`）进行管理，支持按配置文件 profiles 进行作用域限定。\n\n## 诊断与调试\n\n### 技能状态检查\n\n使用 `/debug-config` 命令可以查看技能相关的配置层和来源信息。\n\n### 常见问题排查\n\n| 问题 | 可能原因 | 解决方案 |\n|------|----------|----------|\n| 技能未显示 | 配置文件格式错误 | 检查 SKILL.md 语法 |\n| 技能不生效 | 触发条件未满足 | 确认任务上下文匹配 |\n| 加载失败 | 文件权限问题 | 检查文件读取权限 |\n\n## 相关命令\n\n| 命令 | 功能 |\n|------|------|\n| `/skills` | 列出和管理可用技能 |\n| `/debug-config` | 显示配置层和技能来源 |\n| `/permissions` | 管理技能执行权限 |\n\n## 最佳实践\n\n1. **技能粒度**：保持技能职责单一，每个技能专注于一个特定任务类型\n2. **命名规范**：使用清晰描述性的技能名称，便于识别和选择\n3. **文档完善**：在 SKILL.md 中提供详细的使用说明和示例\n4. **版本兼容**：定期更新技能配置以适配 Codex 版本变化\n5. **权限考虑**：明确技能所需权限，避免过度授权\n\n## 参考资料\n\n- 技能核心实现：[codex-rs/core-skills/src/lib.rs](https://github.com/openai/codex/blob/main/codex-rs/core-skills/src/lib.rs)\n- 技能管理器：[codex-rs/core-skills/src/manager.rs](https://github.com/openai/codex/blob/main/codex-rs/core-skills/src/manager.rs)\n- 技能加载器：[codex-rs/core-skills/src/loader.rs](https://github.com/openai/codex/blob/main/codex-rs/core-skills/src/loader.rs)\n- 代码审查技能示例：[.codex/skills/code-review/SKILL.md](https://github.com/openai/codex/blob/main/.codex/skills/code-review/SKILL.md)\n- Bug 定位技能示例：[.codex/skills/codex-bug/SKILL.md](https://github.com/openai/codex/blob/main/.codex/skills/codex-bug/SKILL.md)\n- 斜杠命令定义：[codex-rs/tui/src/slash_command.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n- 配置系统集成：[codex-rs/config/src/state.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n\n---\n\n<a id='page-plugins'></a>\n\n## 插件系统\n\n### 相关页面\n\n相关主题：[技能系统](#page-skills)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/tui/src/slash_command.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/slash_command.rs)\n- [codex-rs/README.md](https://github.com/openai/codex/blob/main/codex-rs/README.md)\n- [codex-rs/config/src/config_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n- [codex-rs/config/src/profile_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/profile_toml.rs)\n- [codex-rs/README.md](https://github.com/openai/codex/blob/main/codex-rs/README.md)\n</details>\n\n# 插件系统\n\n## 概述\n\nCodex CLI 的插件系统（Plugins）是扩展主程序功能的核心模块，允许用户通过插件机制定制和增强 Codex 的行为。该系统与应用程序管理（Apps）和 MCP（Model Context Protocol）协议共同构成了 Codex 的可扩展性架构。\n\n插件系统的主要入口是通过命令行斜杠命令 `/plugins` 访问，用户可以浏览已安装的插件。 资料来源：[codex-rs/tui/src/slash_command.rs:行53]()\n\n## 架构组成\n\n### 核心组件\n\n| 组件 | 功能描述 |\n|------|----------|\n| Apps 管理 | 管理和启动独立的应用程序实例 |\n| MCP 客户端 | 连接外部 MCP 服务器以使用第三方工具 |\n| MCP 服务器 | 将 Codex 作为 MCP 服务器暴露给其他客户端 |\n| 插件框架 | 允许第三方代码扩展 Codex 的核心功能 |\n\n### 配置文件支持\n\nCodex 在配置层面支持插件相关功能，通过 `config.toml` 和 `profile.toml` 中的字段控制插件行为：\n\n```toml\n# 包含应用指令\ninclude_apps_instructions = true  # 控制是否注入应用相关指令\n```\n\n资料来源：[codex-rs/config/src/config_toml.rs:行1-100]()\n\n```toml\n[features]\n# 可在 profile 中配置特性开关\n```\n\n资料来源：[codex-rs/config/src/profile_toml.rs:行1-50]()\n\n## 命令行接口\n\n### 斜杠命令\n\n| 命令 | 功能 |\n|------|------|\n| `/plugins` | 浏览可用插件 |\n| `/apps` | 管理系统应用 |\n| `/mcp` | 列出已配置的 MCP 工具 |\n\n资料来源：[codex-rs/tui/src/slash_command.rs:行48-55]()\n\n```rust\nSlashCommand::Plugins => \"browse plugins\",\nSlashCommand::Apps => \"manage apps\",\nSlashCommand::Mcp => \"list configured MCP tools; use /mcp verbose for details\",\n```\n\n## MCP 协议集成\n\n### MCP 客户端模式\n\nCodex CLI 作为 MCP 客户端，可在启动时连接到外部 MCP 服务器。这种模式允许 Codex 访问由第三方提供的工具和服务。\n\n> 注意：详细配置方法请参阅[配置文档](../docs/config.md#connecting-to-mcp-servers)\n\n资料来源：[codex-rs/README.md:行1-100]()\n\n### MCP 服务器模式（实验性）\n\nCodex 可以作为 MCP 服务器运行，允许其他 MCP 客户端连接到 Codex 并使用其功能：\n\n```shell\ncodex mcp-server\n```\n\n资料来源：[codex-rs/README.md:行1-100]()\n\n## 工作流程图\n\n```mermaid\ngraph TD\n    A[用户启动 Codex] --> B{插件配置检查}\n    B -->|有 MCP 配置| C[连接 MCP 服务器]\n    B -->|有 Apps 配置| D[加载应用模块]\n    B -->|有 Plugins 配置| E[初始化插件]\n    C --> F[Codex 运行中]\n    D --> F\n    E --> F\n    F --> G[用户可通过 /plugins 浏览插件]\n    F --> H[用户可通过 /apps 管理应用]\n    F --> I[用户可通过 /mcp 查看 MCP 工具]\n```\n\n## 配置层级\n\n插件系统的配置遵循 Codex 的配置层级架构：\n\n```mermaid\ngraph TD\n    A[配置层级架构]\n    A --> B[System 配置]\n    A --> C[User 配置]\n    A --> D[Project 配置]\n    A --> E[Session Flags]\n    B --> F[最终生效配置]\n    C --> F\n    D --> F\n    E --> F\n```\n\n| 配置层级 | 说明 |\n|----------|------|\n| System | 系统级配置文件 |\n| User | 用户主目录配置 |\n| Project | 项目 .codex 目录配置 |\n| Session Flags | 会话级别命令行参数 |\n\n资料来源：[codex-rs/config/src/state.rs:行1-50]()\n\n## 应用与插件的集成\n\nApps（应用程序）和 Plugins（插件）在功能上有重叠和互补关系：\n\n- **Apps** 通常指完整的应用程序模块，可以通过 `/apps` 命令管理\n- **Plugins** 指可插拔的功能扩展，通过 `/plugins` 浏览\n\n两者都可以在配置中启用或禁用，通过 `include_apps_instructions` 配置项控制是否向模型注入应用相关的指令提示。\n\n资料来源：[codex-rs/config/src/profile_toml.rs:行1-50]()\n\n## 使用场景\n\n### 场景一：连接外部工具\n\n用户可以配置 MCP 服务器以连接外部开发工具：\n\n```toml\n[mcp]\nservers = [\"my-mcp-server\"]\n```\n\n### 场景二：安装应用\n\n通过 Apps 系统，用户可以安装和管理预配置的应用程序：\n\n```shell\n/apps install <app-name>\n```\n\n### 场景三：浏览插件\n\n```shell\n/plugins browse\n```\n\n## 相关命令速查\n\n| 命令 | 描述 |\n|------|------|\n| `/plugins` | 浏览已安装插件 |\n| `/apps` | 管理应用程序 |\n| `/mcp` | 查看 MCP 工具列表 |\n| `/mcp verbose` | 查看 MCP 详细配置 |\n| `codex mcp-server` | 启动 MCP 服务器模式 |\n\n## 下一步\n\n- 详细配置方法：参见[配置文档](../docs/config.md)\n- 快速入门：参见[入门指南](../docs/getting-started.md)\n- MCP 服务器配置：参见 [Model Context Protocol 支持](../docs/config.md#connecting-to-mcp-servers)\n\n---\n\n<a id='page-hooks'></a>\n\n## Hook系统\n\n### 相关页面\n\n相关主题：[技能系统](#page-skills), [核心Agent模块](#page-core-agent)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/hooks/src/lib.rs](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/lib.rs)\n- [codex-rs/hooks/src/engine/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/mod.rs)\n- [codex-rs/hooks/src/declarations.rs](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/declarations.rs)\n- [codex-rs/hooks/schema/generated](https://github.com/openai/codex/blob/main/codex-rs/hooks/schema/generated)\n</details>\n\n# Hook系统\n\n## 概述\n\nHook系统是Codex CLI中用于在关键生命周期节点注入自定义逻辑的核心扩展机制。通过Hook，管理员、用户和项目开发者可以在Codex执行过程中的特定时刻介入，控制行为、注入上下文、验证权限或收集反馈。 资料来源：[codex-rs/tui/src/slash_command.rs:15]()\n\n## 核心概念\n\n### Hook的本质\n\nHook是一种声明式的回调机制，允许外部代码在Codex运行时截获特定事件并返回响应。每个Hook由以下要素组成：\n\n| 要素 | 说明 |\n|------|------|\n| 事件类型 | Hook被触发的时机 |\n| 源配置 | Hook定义来自哪个配置层级 |\n| 执行逻辑 | Hook被触发时运行的代码 |\n| 返回结果 | Hook对后续行为的指导 |\n\n### 配置层级\n\nHook的配置遵循Codex的分层配置体系，从低优先级到高优先级依次为：\n\n1. **系统级（System）** - 管理员全局配置\n2. **MDM级（Mdm）** - 移动设备管理配置\n3. **云端要求（CloudRequirements）** - 云端下发的强制要求\n4. **项目级（Project）** - `.codex/`目录中的项目配置\n5. **用户级（User）** - 用户个人配置\n6. **会话标志（SessionFlags）** - 命令行会话参数\n7. **插件（Plugin）** - 第三方插件提供\n\n资料来源：[codex-rs/tui/src/hooks_browser_view.rs:45-58]()\n\n## 事件类型\n\nCodex Hook系统在以下事件节点触发Hook：\n\n| 事件名称 | 触发时机 | 典型用途 |\n|----------|----------|----------|\n| `SessionStart` | 会话启动时 | 初始化上下文、设置会话级别变量 |\n| `UserPromptSubmit` | 用户提交提示词时 | 验证输入、注入额外上下文 |\n| `PreToolUse` | 工具执行前 | 权限检查、参数修改、拒绝执行 |\n| `PostToolUse` | 工具执行后 | 记录日志、处理结果、添加反馈 |\n| `PreCompact` | 历史压缩前 | 选择性保留关键对话 |\n| `PostCompact` | 历史压缩后 | 验证压缩结果 |\n| `PermissionRequest` | 权限请求时 | 自定义权限审批流程 |\n| `Stop` | Codex结束回合前 | 最终清理、状态保存 |\n\n资料来源：[codex-rs/tui/src/history_cell/hook_cell.rs:30-42]()\n\n## Hook输出类型\n\nHook可以向用户或系统返回多种类型的输出：\n\n| 输出类型 | 前缀标识 | 含义 |\n|----------|----------|------|\n| `Warning` | `warning:` | 警告信息，Hook继续执行 |\n| `Stop` | `stop:` | 停止当前操作 |\n| `Feedback` | `feedback:` | 向用户提供反馈文本 |\n| `Context` | `hook context:` | 注入额外上下文信息 |\n| `Error` | `error:` | 错误信息，终止操作 |\n\n资料来源：[codex-rs/tui/src/history_cell/hook_cell.rs:12-17]()\n\n## 系统架构\n\n```mermaid\ngraph TD\n    A[Codex运行时] --> B[Hook引擎]\n    B --> C{事件类型判断}\n    C -->|PreToolUse| D[执行PreToolUse Hooks]\n    C -->|PostToolUse| E[执行PostToolUse Hooks]\n    C -->|SessionStart| F[执行SessionStart Hooks]\n    C -->|UserPromptSubmit| G[执行UserPromptSubmit Hooks]\n    C -->|其他事件| H[执行对应Hooks]\n    \n    D --> I[收集输出结果]\n    E --> I\n    F --> I\n    G --> I\n    H --> I\n    \n    I --> J{Hook决定}\n    J -->|继续| K[执行下一阶段]\n    J -->|停止| L[终止操作]\n    J -->|上下文| M[注入上下文后继续]\n    J -->|反馈| N[显示反馈信息]\n    \n    K --> O[返回结果给调用方]\n    L --> P[返回错误/停止原因]\n    N --> O\n    \n    style B fill:#e1f5fe\n    style D fill:#fff3e0\n    style I fill:#f3e5f5\n```\n\n## 配置管理\n\n### Hook配置文件位置\n\nHook的配置文件位置遵循以下优先级规则：\n\n```rust\npub fn hooks_config_folder(&self) -> Option<AbsolutePathBuf> {\n    self.hooks_config_folder_override\n        .clone()\n        .or_else(|| self.config_folder())\n}\n```\n\n对于不同配置源，Hook配置文件夹的确定方式为：\n\n| 配置源 | 配置文件夹位置 |\n|--------|----------------|\n| System | `file.parent()` |\n| User | `file.parent()` |\n| Project | `dot_codex_folder`（`.codex/`目录） |\n| MDM/SessionFlags | 无专用文件夹 |\n\n资料来源：[codex-rs/config/src/state.rs:140-152]()\n\n### 命名规则\n\nHook配置文件通常命名为 `hooks.toml`，位于各层级的配置目录中。\n\n## TUI集成\n\n### Hook浏览器视图\n\n在TUI中，用户可以通过 `/hooks` 命令访问Hook浏览器，查看当前会话可用的所有Hook：\n\n```mermaid\ngraph LR\n    A[/hooks命令] --> B[Hook浏览器视图]\n    B --> C[按源分组显示]\n    C --> D[显示Hook元数据]\n    D --> E[显示Hook详情]\n```\n\n### Hook元数据显示\n\nHook浏览器中显示的关键信息包括：\n\n| 显示项 | 来源 | 说明 |\n|--------|------|------|\n| 源标签 | `HookSource` | System/User/Project等 |\n| 插件ID | `plugin_id` | 插件提供的Hook专属 |\n| 源路径 | `source_path` | 配置文件路径 |\n| 事件类型 | `HookEventName` | 触发的事件 |\n\n资料来源：[codex-rs/tui/src/hooks_browser_view.rs:35-60]()\n\n## 使用方式\n\n### 命令行接口\n\n| 命令 | 功能 |\n|------|------|\n| `/hooks` | 查看和管理局域网Hook |\n\n资料来源：[codex-rs/tui/src/slash_command.rs:15]()\n\n### 快捷键配置\n\nHook相关的快捷键可通过 `/keymap` 命令自定义配置：\n\n| 操作 | 默认快捷键 |\n|------|------------|\n| Hook浏览器导航 | 方向键 |\n\n## 权限与安全\n\n### 权限级别\n\nHook的执行受Codex权限系统约束：\n\n- **管理员Hook** - 可执行高权限操作\n- **用户Hook** - 受用户权限限制\n- **项目Hook** - 受项目配置限制\n- **插件Hook** - 受插件声明的权限限制\n\n### 风险级别\n\nHook执行结果会映射到Guardian风险级别：\n\n| Hook决定 | 风险级别 |\n|----------|----------|\n| 允许继续 | Low |\n| 添加条件 | Medium |\n| 要求确认 | High |\n| 拒绝执行 | Critical |\n\n## 高级特性\n\n### 实验性Hook\n\n部分Hook功能标记为实验性：\n\n- `experimental_compact_prompt_file` - 自定义压缩提示词文件\n- `experimental_use_unified_exec_tool` - 统一执行工具\n- `experimental_use_freeform_apply_patch` - 自由格式补丁\n\n资料来源：[codex-rs/config/src/profile_toml.rs:25-35]()\n\n### 状态行显示\n\nHook执行状态可显示在TUI状态行：\n\n| 状态项 | 显示内容 |\n|--------|----------|\n| Hook输出 | Warning/Stop/Error等标记 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/status_line_style.rs:20-30]()\n\n## 与其他系统集成\n\n### 配置系统\n\nHook声明是配置层级的组成部分，支持完整的配置诊断：\n\n```rust\nfn config_toml_path_for_layer(\n    layer: &ConfigLayerEntry, \n    config_toml_file: &str\n) -> Option<PathBuf> {\n    match &layer.name {\n        ConfigLayerSource::System { file } => Some(file.to_path_buf()),\n        ConfigLayerSource::User { file } => Some(file.to_path_buf()),\n        ConfigLayerSource::Project { dot_codex_folder } => {\n            Some(dot_codex_folder.as_path().join(config_toml_file))\n        }\n        _ => None,\n    }\n}\n```\n\n资料来源：[codex-rs/config/src/diagnostics.rs:15-27]()\n\n### 工具系统\n\nPreToolUse和PostToolUse Hook与工具系统紧密集成：\n\n```mermaid\nsequenceDiagram\n    participant U as 用户\n    participant C as Codex\n    participant H as PreToolUse Hook\n    participant T as 工具\n    participant P as PostToolUse Hook\n    \n    U->>C: 执行工具请求\n    C->>H: 触发PreToolUse\n    H-->>C: 决定：允许/拒绝/修改\n    alt 允许执行\n        C->>T: 调用工具\n        T-->>C: 返回结果\n        C->>P: 触发PostToolUse\n        P-->>C: 反馈/上下文\n        C-->>U: 显示结果\n    else 拒绝执行\n        C-->>U: 显示拒绝原因\n    end\n```\n\n## 故障排查\n\n### 常见问题\n\n| 问题 | 可能原因 | 解决方案 |\n|------|----------|----------|\n| Hook未触发 | 事件类型不匹配 | 检查Hook声明的事件类型 |\n| Hook无效 | 配置解析错误 | 运行 `/debug-config` 检查 |\n| 权限不足 | Hook源权限受限 | 提升配置层级权限 |\n\n### 调试命令\n\n| 命令 | 用途 |\n|------|------|\n| `/debug-config` | 显示配置层级和来源 |\n| `/status` | 查看当前会话配置 |\n\n## 最佳实践\n\n1. **分层管理** - 按优先级合理分配Hook到不同配置层级\n2. **最小权限** - 仅授予Hook必要的权限\n3. **清晰命名** - 使用描述性的Hook名称便于维护\n4. **错误处理** - 在Hook中实现健壮的错误处理\n5. **测试验证** - 在非生产环境测试Hook行为\n\n## 相关文档\n\n- [配置系统](../config.md) - 了解配置层级\n- [权限系统](../permissions.md) - 权限管理详情\n- [插件系统](../plugins.md) - 第三方扩展开发\n- [TUI快捷键](../keymap.md) - 自定义快捷键配置\n\n---\n\n<a id='page-sandboxing'></a>\n\n## 沙箱与安全\n\n### 相关页面\n\n相关主题：[执行系统](#page-execution)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [codex-rs/tui/src/bottom_pane/approval_overlay.rs](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/approval_overlay.rs)\n- [codex-rs/config/src/state.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/state.rs)\n- [codex-rs/config/src/loader/mod.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/loader/mod.rs)\n- [codex-rs/config/src/config_toml.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/config_toml.rs)\n- [codex-rs/config/src/diagnostics.rs](https://github.com/openai/codex/blob/main/codex-rs/config/src/diagnostics.rs)\n</details>\n\n# 沙箱与安全\n\nCodex CLI 的沙箱与安全系统是保护用户系统免受恶意操作或意外文件修改的核心机制。该系统通过多层次的权限控制、审批流程和文件系统路径限制来确保代码执行的安全性。\n\n## 系统架构概述\n\nCodex 的安全架构采用分层设计，将配置源、权限决策和文件系统隔离有机结合。系统支持多种配置层，包括系统级、用户级和项目级配置，每一层都有独立的权限优先级和作用范围。\n\n```mermaid\ngraph TD\n    A[用户操作] --> B{权限检查}\n    B --> C{文件路径类型}\n    C --> D[:root - 根目录]\n    C --> E[:minimal - 最小路径]\n    C --> F[:project_roots - 项目根目录]\n    C --> G[/tmp - 临时目录]\n    D --> H{审批决策}\n    E --> H\n    F --> H\n    G --> H\n    H --> I[Approval - 执行]\n    H --> J[AcceptForSession - 本次会话接受]\n    H --> K[Reject - 拒绝执行]\n```\n\n## 权限配置系统\n\n### 配置层源\n\nCodex 使用 `ConfigLayerSource` 枚举来管理不同来源的配置层级，每个层级对应不同的安全边界和应用范围。\n\n| 配置层类型 | 说明 | 优先级 |\n|-----------|------|--------|\n| System | 系统级配置文件 | 最低 |\n| User | 用户主目录配置 | 中低 |\n| Project | `.codex/` 项目配置 | 中高 |\n| Mdm | 移动设备管理配置 | 高 |\n| SessionFlags | 会话级命令行标志 | 最高 |\n\n资料来源：[codex-rs/config/src/state.rs:1-20]()\n\n### 权限决策类型\n\n权限审批系统通过 `ApprovalDecision` 和 `FileChangeApprovalDecision` 枚举处理用户对文件操作的授权决策。\n\n```rust\npub enum ApprovalDecision {\n    FileChange(FileChangeApprovalDecision),\n    // ... 其他变体\n}\n\npub enum FileChangeApprovalDecision {\n    Accept,              // 立即执行\n    AcceptForSession,    // 本次会话接受，后续不再询问\n    // 拒绝决策由用户交互产生\n}\n```\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:1-50]()\n\n### 特殊文件系统路径\n\n系统定义了特殊的文件系统路径标识符，用于限制 Codex 的操作范围：\n\n| 路径标识 | 说明 | 示例 |\n|---------|------|------|\n| `:root` | 文件系统根目录 | `/` |\n| `:minimal` | 最小限制路径 | 用户定义的最小访问范围 |\n| `:project_roots` | 项目根目录 | 包含 `.codex/` 的目录 |\n| `:tmpdir` | 系统临时目录 | `/tmp` |\n| `:unknown` | 未识别的特殊路径 | 自定义路径 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:80-95]()\n\n## 文件审批流程\n\n### 审批选项\n\n当 Codex 需要修改文件或执行敏感操作时，会向用户展示审批选项界面：\n\n| 选项标签 | 决策类型 | 快捷键 |\n|---------|---------|--------|\n| \"Yes, proceed\" | Accept | 可自定义 |\n| \"Yes, and don't ask again for these files\" | AcceptForSession | 可自定义 |\n| \"No, and tell Codex what to do differently\" | Reject | 可自定义 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:150-170]()\n\n### 路径显示格式化\n\n系统通过 `path_label` 函数将文件系统路径转换为用户可读的格式：\n\n```rust\nfn path_label(base: &str, subpath: &Option<PathBuf>) -> String {\n    match subpath {\n        Some(subpath) => format!(\"{base}/{}\", subpath.display()),\n        None => base.to_string(),\n    }\n}\n```\n\n该函数处理带有子路径的特殊路径标识符，例如 `:project_roots/subdir` 会被格式化为用户友好的显示形式。\n\n资料来源：[codex-rs/tui/src/bottom_pane/approval_overlay.rs:75-82]()\n\n## 配置验证与诊断\n\n### 配置错误处理\n\nCodex 提供配置诊断功能，能够检测并报告配置文件中的错误，包括权限相关的配置问题。\n\n```rust\npub fn format_config_error(error: &ConfigError, contents: &str) -> String {\n    let mut output = String::new();\n    let start = error.range.start;\n    write!(\n        output,\n        \"{}:{}:{}: {}\",\n        error.path.display(),\n        start.line,\n        start.column,\n        error.message\n    );\n    // ...\n}\n```\n\n诊断系统会显示错误的具体位置（文件路径、行号、列号）和错误消息，帮助用户修正配置问题。\n\n资料来源：[codex-rs/config/src/diagnostics.rs:40-55]()\n\n### 配置文件定位\n\n系统根据配置层类型自动定位对应的配置文件路径：\n\n| 配置层源 | 返回路径 |\n|---------|---------|\n| System | 系统配置文件路径 |\n| User | 用户配置文件路径 |\n| Project | `.codex/config.toml` |\n| Mdm | MDM 配置文件路径 |\n| SessionFlags | 无对应文件（None） |\n\n资料来源：[codex-rs/config/src/diagnostics.rs:1-20]()\n\n## 项目级配置隔离\n\n### 钩子配置文件夹\n\n项目层级配置使用独立的 `.codex/` 文件夹存储钩子声明。系统支持 Git 工作树链接场景，主仓库和工作树可以共享钩子配置。\n\n```rust\npub fn hooks_config_folder(&self) -> Option<AbsolutePathBuf> {\n    self.hooks_config_folder_override\n        .clone()\n        .or_else(|| self.config_folder())\n}\n```\n\n该方法优先返回覆盖值，否则回退到常规配置文件夹位置。\n\n资料来源：[codex-rs/config/src/state.rs:80-90]()\n\n### 项目配置合并\n\n加载项目配置时会执行多项安全检查：\n\n1. 验证配置文件格式有效性\n2. 忽略不受支持的配置键并记录警告\n3. 解析相对路径为绝对路径\n4. 合并主仓库与工作树的钩子配置\n\n```rust\nlet ignored_project_config_keys = sanitize_project_config(&mut config);\nlet config = resolve_relative_paths_in_config_toml(config, dot_codex_abs.as_path())?;\nlet config = merge_root_checkout_project_hooks(\n    fs,\n    config,\n    hooks_config_folder_override.as_ref(),\n    decision.is_trusted(),\n)\n.await?;\n```\n\n资料来源：[codex-rs/config/src/loader/mod.rs:1-50]()\n\n## 安全边界控制\n\n### 信任决策\n\n配置加载器根据 `decision.is_trusted()` 判断当前操作是否来自可信来源。可信来源享有更严格的错误报告机制，而不可信来源则采用容错处理。\n\n### 相对路径解析\n\n为防止路径遍历攻击，所有相对路径在加载时都会被解析为绝对路径：\n\n```rust\npub fn resolve_relative_paths_in_config_toml(\n    config: TomlValue,\n    base_path: &Path,\n) -> Result<TomlValue, ConfigError> {\n    // 将所有相对路径转换为基于 base_path 的绝对路径\n}\n```\n\n资料来源：[codex-rs/config/src/loader/mod.rs:30-40]()\n\n## 权限相关配置项\n\n### 文件系统操作权限\n\n| 配置项 | 类型 | 说明 |\n|-------|------|------|\n| `include_permissions_instructions` | bool | 是否注入权限指令 |\n| `include_environment_context` | bool | 是否注入环境上下文 |\n| `include_apply_patch_tool` | bool | 是否包含补丁应用工具 |\n| `experimental_use_freeform_apply_patch` | bool | 自由形式补丁应用（实验性） |\n\n资料来源：[codex-rs/config/src/config_toml.rs:1-30]()\n\n### 审批模式显示\n\n系统根据配置显示当前权限状态和审批模式：\n\n```rust\nStatusLineItem::Permissions => Some(permissions_display(&self.config)),\nStatusLineItem::ApprovalMode => Some(approval_mode_display(&self.config)),\n```\n\n用户可以在状态栏直接查看当前工作区的权限级别和审批模式设置。\n\n资料来源：[codex-rs/tui/src/chatwidget/status_surfaces.rs:1-30]()\n\n## 快捷键自定义\n\n用户可以通过 `/keymap` 命令自定义安全相关的快捷键，包括审批决策的快捷键映射：\n\n| 快捷键 ID | 说明 |\n|----------|------|\n| Approval | 审批确认 |\n| ApprovalForSession | 本次会话接受 |\n| ExternalEditor | 外部编辑器 |\n| FilePaths | 文件路径显示 |\n\n资料来源：[codex-rs/tui/src/bottom_pane/footer.rs:1-50]()\n\n## 总结\n\nCodex 的沙箱与安全系统通过以下核心机制保护用户系统：\n\n- **多层级配置管理**：系统、用户、项目级配置各有独立的安全边界\n- **文件审批流程**：敏感操作需用户明确授权\n- **路径隔离**：使用特殊路径标识符限制操作范围\n- **配置验证**：实时检测并报告配置错误\n- **路径规范化**：防止路径遍历和相对路径攻击\n\n该系统设计确保了 Codex 在执行代码操作时既有足够的灵活性，又不会在未经授权的情况下损害用户系统的完整性。\n\n---\n\n---\n\n## Doramagic 踩坑日志\n\n项目：openai/codex\n\n摘要：发现 21 个潜在踩坑项，其中 5 个为 high/blocking；最高优先级：安装坑 - 来源证据：Selected model is at capacity. Please try a different model. The same error everyday。\n\n## 1. 安装坑 · 来源证据：Selected model is at capacity. Please try a different model. The same error everyday\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Selected model is at capacity. Please try a different model. The same error everyday\n- 对用户的影响：可能阻塞安装或首次运行。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_2839c851344f4b669bd1c21b29e7bd08 | https://github.com/openai/codex/issues/22456 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 2. 维护坑 · 来源证据：Extensive UI flickering when codex is working\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：Extensive UI flickering when codex is working\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_47a11c3a9f3943168527e0a086872c1f | https://github.com/openai/codex/issues/11901 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 3. 安全/权限坑 · 来源证据：Codex Desktop voice transcription blocked by Cloudflare challenge on /backend-api/transcribe after resolved incident\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Codex Desktop voice transcription blocked by Cloudflare challenge on /backend-api/transcribe after resolved incident\n- 对用户的影响：可能阻塞安装或首次运行。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_dcdaacada441496491e68dd4db3d802b | https://github.com/openai/codex/issues/21985 | 来源讨论提到 macos 相关条件，需在安装/试用前复核。\n\n## 4. 安全/权限坑 · 来源证据：Codex IDE extension fails GitHub MCP startup with \"connection closed: initialize response\" in PyCharm AI Chat\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Codex IDE extension fails GitHub MCP startup with \"connection closed: initialize response\" in PyCharm AI Chat\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_45286dbe57a44800be79bc6a5819956f | https://github.com/openai/codex/issues/22461 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 5. 安全/权限坑 · 来源证据：Iranian phone numbers are not supported for Codex login\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Iranian phone numbers are not supported for Codex login\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_d651d7b5cf594cafa27dfffa45890baa | https://github.com/openai/codex/issues/21918 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 6. 安装坑 · 来源证据：Codex Desktop falsely reports @chrome plugin unavailable when bundled Chrome plugin is installed\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Codex Desktop falsely reports @chrome plugin unavailable when bundled Chrome plugin is installed\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_a0eee5b5c5fb447ebe2c2d3bdf74aa33 | https://github.com/openai/codex/issues/22463 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 7. 安装坑 · 来源证据：Windows Chrome plugin hangs in setupAtlasRuntime despite extension/native host checks passing\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Windows Chrome plugin hangs in setupAtlasRuntime despite extension/native host checks passing\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_4d667016a4ab4f9aa5416a3b08e71d55 | https://github.com/openai/codex/issues/22462 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 8. 能力坑 · 能力判断依赖假设\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：README/documentation is current enough for a first validation pass.\n- 对用户的影响：假设不成立时，用户拿不到承诺的能力。\n- 建议检查：将假设转成下游验证清单。\n- 防护动作：假设必须转成验证项；没有验证结果前不能写成事实。\n- 证据：capability.assumptions | github_repo:965415649 | https://github.com/openai/codex | README/documentation is current enough for a first validation pass.\n\n## 9. 运行坑 · 来源证据：/goal-first sessions are missing from resume lists\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个运行相关的待验证问题：/goal-first sessions are missing from resume lists\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_e65f6682c39b409a8c96267f4bdc1d3e | https://github.com/openai/codex/issues/20792 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 10. 维护坑 · 来源证据：I have to set up the workspace every time I start a new session. My Codex usage quota is decreasing automatically even…\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：I have to set up the workspace every time I start a new session. My Codex usage quota is decreasing automatically even though I haven’t used it at all.\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_f8afe7124b3e44cfacbc62a9e001179c | https://github.com/openai/codex/issues/22457 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 11. 维护坑 · 来源证据：Renaming session with enter triggers the session window\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：Renaming session with enter triggers the session window\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_a49c134e628047c1b558f3286721d0e7 | https://github.com/openai/codex/issues/22460 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 12. 维护坑 · 维护活跃度未知\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：未记录 last_activity_observed。\n- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。\n- 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。\n- 防护动作：维护活跃度未知时，推荐强度不能标为高信任。\n- 证据：evidence.maintainer_signals | github_repo:965415649 | https://github.com/openai/codex | last_activity_observed missing\n\n## 13. 安全/权限坑 · 下游验证发现风险项\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：下游已经要求复核，不能在页面中弱化。\n- 建议检查：进入安全/权限治理复核队列。\n- 防护动作：下游风险存在时必须保持 review/recommendation 降级。\n- 证据：downstream_validation.risk_items | github_repo:965415649 | https://github.com/openai/codex | no_demo; severity=medium\n\n## 14. 安全/权限坑 · 存在安全注意事项\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：No sandbox install has been executed yet; downstream must verify before user use.\n- 对用户的影响：用户安装前需要知道权限边界和敏感操作。\n- 建议检查：转成明确权限清单和安全审查提示。\n- 防护动作：安全注意事项必须面向用户前置展示。\n- 证据：risks.safety_notes | github_repo:965415649 | https://github.com/openai/codex | No sandbox install has been executed yet; downstream must verify before user use.\n\n## 15. 安全/权限坑 · 存在评分风险\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：风险会影响是否适合普通用户安装。\n- 建议检查：把风险写入边界卡，并确认是否需要人工复核。\n- 防护动作：评分风险必须进入边界卡，不能只作为内部分数。\n- 证据：risks.scoring_risks | github_repo:965415649 | https://github.com/openai/codex | no_demo; severity=medium\n\n## 16. 安全/权限坑 · 来源证据：0.130.0\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：0.130.0\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_0c9ba2dc6c7444688a9de6a144fee613 | https://github.com/openai/codex/releases/tag/rust-v0.130.0 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 17. 安全/权限坑 · 来源证据：Phone number verification doesn't work\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Phone number verification doesn't work\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_0ebeea7c4b5c455f9d14f2518dc6d37a | https://github.com/openai/codex/issues/20161 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 18. 安全/权限坑 · 来源证据：Significant increase in quota consumption after upgrading to v0.130.0\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Significant increase in quota consumption after upgrading to v0.130.0\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_b4d50b3a9b2045c4bd31cd218d7d8d05 | https://github.com/openai/codex/issues/22459 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 19. 安全/权限坑 · 来源证据：missing context % usage in new version\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：missing context % usage in new version\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_a8cf9679679847ddb595ef1ca2bf0757 | https://github.com/openai/codex/issues/18101 | 来源讨论提到 api key 相关条件，需在安装/试用前复核。\n\n## 20. 维护坑 · issue/PR 响应质量未知\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：issue_or_pr_quality=unknown。\n- 对用户的影响：用户无法判断遇到问题后是否有人维护。\n- 建议检查：抽样最近 issue/PR，判断是否长期无人处理。\n- 防护动作：issue/PR 响应未知时，必须提示维护风险。\n- 证据：evidence.maintainer_signals | github_repo:965415649 | https://github.com/openai/codex | issue_or_pr_quality=unknown\n\n## 21. 维护坑 · 发布节奏不明确\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：release_recency=unknown。\n- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。\n- 建议检查：确认最近 release/tag 和 README 安装命令是否一致。\n- 防护动作：发布节奏未知或过期时，安装说明必须标注可能漂移。\n- 证据：evidence.maintainer_signals | github_repo:965415649 | https://github.com/openai/codex | release_recency=unknown\n\n<!-- canonical_name: openai/codex; human_manual_source: deepwiki_human_wiki -->\n",
      "summary": "DeepWiki/Human Wiki 完整输出，末尾追加 Discovery Agent 踩坑日志。",
      "title": "Human Manual / 人类版说明书"
    },
    "pitfall_log": {
      "asset_id": "pitfall_log",
      "filename": "PITFALL_LOG.md",
      "markdown": "# Pitfall Log / 踩坑日志\n\n项目：openai/codex\n\n摘要：发现 21 个潜在踩坑项，其中 5 个为 high/blocking；最高优先级：安装坑 - 来源证据：Selected model is at capacity. Please try a different model. The same error everyday。\n\n## 1. 安装坑 · 来源证据：Selected model is at capacity. Please try a different model. The same error everyday\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Selected model is at capacity. Please try a different model. The same error everyday\n- 对用户的影响：可能阻塞安装或首次运行。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_2839c851344f4b669bd1c21b29e7bd08 | https://github.com/openai/codex/issues/22456 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 2. 维护坑 · 来源证据：Extensive UI flickering when codex is working\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：Extensive UI flickering when codex is working\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_47a11c3a9f3943168527e0a086872c1f | https://github.com/openai/codex/issues/11901 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 3. 安全/权限坑 · 来源证据：Codex Desktop voice transcription blocked by Cloudflare challenge on /backend-api/transcribe after resolved incident\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Codex Desktop voice transcription blocked by Cloudflare challenge on /backend-api/transcribe after resolved incident\n- 对用户的影响：可能阻塞安装或首次运行。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_dcdaacada441496491e68dd4db3d802b | https://github.com/openai/codex/issues/21985 | 来源讨论提到 macos 相关条件，需在安装/试用前复核。\n\n## 4. 安全/权限坑 · 来源证据：Codex IDE extension fails GitHub MCP startup with \"connection closed: initialize response\" in PyCharm AI Chat\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Codex IDE extension fails GitHub MCP startup with \"connection closed: initialize response\" in PyCharm AI Chat\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_45286dbe57a44800be79bc6a5819956f | https://github.com/openai/codex/issues/22461 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 5. 安全/权限坑 · 来源证据：Iranian phone numbers are not supported for Codex login\n\n- 严重度：high\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Iranian phone numbers are not supported for Codex login\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_d651d7b5cf594cafa27dfffa45890baa | https://github.com/openai/codex/issues/21918 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 6. 安装坑 · 来源证据：Codex Desktop falsely reports @chrome plugin unavailable when bundled Chrome plugin is installed\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Codex Desktop falsely reports @chrome plugin unavailable when bundled Chrome plugin is installed\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_a0eee5b5c5fb447ebe2c2d3bdf74aa33 | https://github.com/openai/codex/issues/22463 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 7. 安装坑 · 来源证据：Windows Chrome plugin hangs in setupAtlasRuntime despite extension/native host checks passing\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Windows Chrome plugin hangs in setupAtlasRuntime despite extension/native host checks passing\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_4d667016a4ab4f9aa5416a3b08e71d55 | https://github.com/openai/codex/issues/22462 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 8. 能力坑 · 能力判断依赖假设\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：README/documentation is current enough for a first validation pass.\n- 对用户的影响：假设不成立时，用户拿不到承诺的能力。\n- 建议检查：将假设转成下游验证清单。\n- 防护动作：假设必须转成验证项；没有验证结果前不能写成事实。\n- 证据：capability.assumptions | github_repo:965415649 | https://github.com/openai/codex | README/documentation is current enough for a first validation pass.\n\n## 9. 运行坑 · 来源证据：/goal-first sessions are missing from resume lists\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个运行相关的待验证问题：/goal-first sessions are missing from resume lists\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_e65f6682c39b409a8c96267f4bdc1d3e | https://github.com/openai/codex/issues/20792 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 10. 维护坑 · 来源证据：I have to set up the workspace every time I start a new session. My Codex usage quota is decreasing automatically even…\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：I have to set up the workspace every time I start a new session. My Codex usage quota is decreasing automatically even though I haven’t used it at all.\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_f8afe7124b3e44cfacbc62a9e001179c | https://github.com/openai/codex/issues/22457 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 11. 维护坑 · 来源证据：Renaming session with enter triggers the session window\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：Renaming session with enter triggers the session window\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_a49c134e628047c1b558f3286721d0e7 | https://github.com/openai/codex/issues/22460 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 12. 维护坑 · 维护活跃度未知\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：未记录 last_activity_observed。\n- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。\n- 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。\n- 防护动作：维护活跃度未知时，推荐强度不能标为高信任。\n- 证据：evidence.maintainer_signals | github_repo:965415649 | https://github.com/openai/codex | last_activity_observed missing\n\n## 13. 安全/权限坑 · 下游验证发现风险项\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：下游已经要求复核，不能在页面中弱化。\n- 建议检查：进入安全/权限治理复核队列。\n- 防护动作：下游风险存在时必须保持 review/recommendation 降级。\n- 证据：downstream_validation.risk_items | github_repo:965415649 | https://github.com/openai/codex | no_demo; severity=medium\n\n## 14. 安全/权限坑 · 存在安全注意事项\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：No sandbox install has been executed yet; downstream must verify before user use.\n- 对用户的影响：用户安装前需要知道权限边界和敏感操作。\n- 建议检查：转成明确权限清单和安全审查提示。\n- 防护动作：安全注意事项必须面向用户前置展示。\n- 证据：risks.safety_notes | github_repo:965415649 | https://github.com/openai/codex | No sandbox install has been executed yet; downstream must verify before user use.\n\n## 15. 安全/权限坑 · 存在评分风险\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：风险会影响是否适合普通用户安装。\n- 建议检查：把风险写入边界卡，并确认是否需要人工复核。\n- 防护动作：评分风险必须进入边界卡，不能只作为内部分数。\n- 证据：risks.scoring_risks | github_repo:965415649 | https://github.com/openai/codex | no_demo; severity=medium\n\n## 16. 安全/权限坑 · 来源证据：0.130.0\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：0.130.0\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_0c9ba2dc6c7444688a9de6a144fee613 | https://github.com/openai/codex/releases/tag/rust-v0.130.0 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 17. 安全/权限坑 · 来源证据：Phone number verification doesn't work\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Phone number verification doesn't work\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_0ebeea7c4b5c455f9d14f2518dc6d37a | https://github.com/openai/codex/issues/20161 | 来源类型 github_issue 暴露的待验证使用条件。\n\n## 18. 安全/权限坑 · 来源证据：Significant increase in quota consumption after upgrading to v0.130.0\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Significant increase in quota consumption after upgrading to v0.130.0\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_b4d50b3a9b2045c4bd31cd218d7d8d05 | https://github.com/openai/codex/issues/22459 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。\n\n## 19. 安全/权限坑 · 来源证据：missing context % usage in new version\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：missing context % usage in new version\n- 对用户的影响：可能影响授权、密钥配置或安全边界。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_a8cf9679679847ddb595ef1ca2bf0757 | https://github.com/openai/codex/issues/18101 | 来源讨论提到 api key 相关条件，需在安装/试用前复核。\n\n## 20. 维护坑 · issue/PR 响应质量未知\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：issue_or_pr_quality=unknown。\n- 对用户的影响：用户无法判断遇到问题后是否有人维护。\n- 建议检查：抽样最近 issue/PR，判断是否长期无人处理。\n- 防护动作：issue/PR 响应未知时，必须提示维护风险。\n- 证据：evidence.maintainer_signals | github_repo:965415649 | https://github.com/openai/codex | issue_or_pr_quality=unknown\n\n## 21. 维护坑 · 发布节奏不明确\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：release_recency=unknown。\n- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。\n- 建议检查：确认最近 release/tag 和 README 安装命令是否一致。\n- 防护动作：发布节奏未知或过期时，安装说明必须标注可能漂移。\n- 证据：evidence.maintainer_signals | github_repo:965415649 | https://github.com/openai/codex | release_recency=unknown\n",
      "summary": "用户实践前最可能遇到的身份、安装、配置、运行和安全坑。",
      "title": "Pitfall Log / 踩坑日志"
    },
    "prompt_preview": {
      "asset_id": "prompt_preview",
      "filename": "PROMPT_PREVIEW.md",
      "markdown": "# codex - Prompt Preview\n\n> 复制下面这段 Prompt 到你常用的 AI，先试一次，不需要安装。\n> 它的目标是让你直接体验这个项目的服务方式，而不是阅读项目介绍。\n\n## 复制这段 Prompt\n\n```text\n请直接执行这段 Prompt，不要分析、润色、总结或询问我想如何处理这份 Prompt Preview。\n\n你现在扮演 codex 的“安装前体验版”。\n这不是项目介绍、不是评价报告、不是 README 总结。你的任务是让我用最小成本体验它的核心服务。\n\n我的试用任务：我想用它完成一个真实的软件开发与交付任务。\n我常用的宿主 AI：chatgpt\n\n【体验目标】\n围绕我的真实任务，现场演示这个项目如何把输入转成 步骤建议, 检查清单, 专业工作流。重点是让我感受到工作方式，而不是给我项目背景。\n\n【业务流约束】\n- 你必须像一个正在提供服务的项目能力包，而不是像一个讲解员。\n- 每一轮只推进一个步骤；提出问题后必须停下来等我回答。\n- 每一步都必须让我感受到一个具体服务动作：澄清、整理、规划、检查、判断或收尾。\n- 每一步都要说明：当前目标、你需要我提供什么、我回答后你会产出什么。\n- 不要安装、不要运行命令、不要写代码、不要声称测试通过、不要声称已经修改文件。\n- 需要真实安装或宿主加载后才能验证的内容，必须明确说“这一步需要安装后验证”。\n- 如果我说“用示例继续”，你可以用虚构示例推进，但仍然不能声称真实执行。\n\n【可体验服务能力】\n- AI Skill / Agent 指令资产库: 项目包含可被宿主 AI 读取的 Skill 或 Agent 指令文件，可用于把专业流程带入 Claude、Codex、Cursor 等宿主。 输入：用户任务, 宿主 AI 对话上下文, 项目内 Skill/Agent 文档；输出：步骤建议, 检查清单, 专业工作流。\n\n【必须安装后才可验证的能力】\n- 命令行启动或安装流程: 项目文档中存在可执行命令，真实使用需要在本地或宿主环境中运行这些命令。 输入：终端环境, 包管理器, 项目依赖；输出：安装结果, 列表/更新/运行结果。\n\n【核心服务流】\n请严格按这个顺序带我体验。不要一次性输出完整流程：\n1. page-overview：项目概述。围绕“项目概述”模拟一次用户任务，不展示安装或运行结果。\n2. page-architecture：系统架构。围绕“系统架构”模拟一次用户任务，不展示安装或运行结果。\n3. page-protocol：协议层详解。围绕“协议层详解”模拟一次用户任务，不展示安装或运行结果。\n4. page-core-agent：核心Agent模块。围绕“核心Agent模块”模拟一次用户任务，不展示安装或运行结果。\n5. page-execution：执行系统。围绕“执行系统”模拟一次用户任务，不展示安装或运行结果。\n\n【核心能力体验剧本】\n每一步都必须按“输入 -> 服务动作 -> 中间产物”执行。不要只说流程名：\n1. page-overview\n输入：用户提供的“项目概述”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n2. page-architecture\n输入：用户提供的“系统架构”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n3. page-protocol\n输入：用户提供的“协议层详解”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n4. page-core-agent\n输入：用户提供的“核心Agent模块”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n5. page-execution\n输入：用户提供的“执行系统”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n【项目服务规则】\n这些规则决定你如何服务用户。不要解释规则本身，而要在每一步执行时遵守：\n- 先确认用户任务、输入材料和成功标准，再模拟项目能力。\n- 每一步都必须形成可检查的小产物，并等待用户确认后再继续。\n- 凡是需要安装、调用工具或访问外部服务的能力，都必须标记为安装后验证。\n\n【每一步的服务约束】\n- Step 1 / page-overview：Step 1 必须围绕“项目概述”形成一个小中间产物，并等待用户确认。\n- Step 2 / page-architecture：Step 2 必须围绕“系统架构”形成一个小中间产物，并等待用户确认。\n- Step 3 / page-protocol：Step 3 必须围绕“协议层详解”形成一个小中间产物，并等待用户确认。\n- Step 4 / page-core-agent：Step 4 必须围绕“核心Agent模块”形成一个小中间产物，并等待用户确认。\n- Step 5 / page-execution：Step 5 必须围绕“执行系统”形成一个小中间产物，并等待用户确认。\n\n【边界与风险】\n- 不要声称已经安装、运行、调用 API、读写本地文件或完成真实任务。\n- 安装前预览只能展示工作方式，不能证明兼容性、性能或输出质量。\n- 涉及安装、插件加载、工具调用或外部服务的能力必须安装后验证。\n\n【可追溯依据】\n这些路径只用于你内部校验或在我追问“依据是什么”时简要引用。不要在首次回复主动展开：\n- https://github.com/openai/codex\n- https://github.com/openai/codex#readme\n- .codex/skills/babysit-pr/SKILL.md\n- .codex/skills/code-review/SKILL.md\n- .codex/skills/code-review-breaking-changes/SKILL.md\n- .codex/skills/code-review-change-size/SKILL.md\n- .codex/skills/code-review-context/SKILL.md\n- .codex/skills/code-review-testing/SKILL.md\n- .codex/skills/codex-bug/SKILL.md\n- .codex/skills/codex-issue-digest/SKILL.md\n- .codex/skills/codex-pr-body/SKILL.md\n- .codex/skills/remote-tests/SKILL.md\n\n【首次问题规则】\n- 首次三问必须先确认用户目标、成功标准和边界，不要提前进入工具、安装或实现细节。\n- 如果后续需要技术条件、文件路径或运行环境，必须等用户确认目标后再追问。\n\n首次回复必须只输出下面 4 个部分：\n1. 体验开始：用 1 句话说明你将带我体验 codex 的核心服务。\n2. 当前步骤：明确进入 Step 1，并说明这一步要解决什么。\n3. 你会如何服务我：说明你会先改变我完成任务的哪个动作。\n4. 只问我 3 个问题，然后停下等待回答。\n\n首次回复禁止输出：后续完整流程、证据清单、安装命令、项目评价、营销文案、已经安装或运行的说法。\n\nStep 1 / brainstorming 的二轮协议：\n- 我回答首次三问后，你仍然停留在 Step 1 / brainstorming，不要进入 Step 2。\n- 第二次回复必须产出 6 个部分：澄清后的任务定义、成功标准、边界条件、\n  2-3 个可选方案、每个方案的权衡、推荐方案。\n- 第二次回复最后必须问我是否确认推荐方案；只有我明确确认后，才能进入下一步。\n- 第二次回复禁止输出 git worktree、代码计划、测试文件、命令或真实执行结果。\n\n后续对话规则：\n- 我回答后，你先完成当前步骤的中间产物并等待确认；只有我确认后，才能进入下一步。\n- 每一步都要生成一个小的中间产物，例如澄清后的目标、计划草案、测试意图、验证清单或继续/停止判断。\n- 所有演示都写成“我会建议/我会引导/这一步会形成”，不要写成已经真实执行。\n- 不要声称已经测试通过、文件已修改、命令已运行或结果已产生。\n- 如果某个能力必须安装后验证，请直接说“这一步需要安装后验证”。\n- 如果证据不足，请明确说“证据不足”，不要补事实。\n```\n",
      "summary": "不安装项目也能感受能力节奏的安全试用 Prompt。",
      "title": "Prompt Preview / 安装前试用 Prompt"
    },
    "quick_start": {
      "asset_id": "quick_start",
      "filename": "QUICK_START.md",
      "markdown": "# Quick Start / 官方入口\n\n项目：openai/codex\n\n## 官方安装入口\n\n### Codex · 官方安装入口\n\n```bash\nnpm i -g @openai/codex\n```\n\n来源：https://github.com/openai/codex#readme\n\n## 来源\n\n- repo: https://github.com/openai/codex\n- docs: https://github.com/openai/codex#readme\n",
      "summary": "从项目官方 README 或安装文档提取的开工入口。",
      "title": "Quick Start / 官方入口"
    }
  },
  "validation_id": "dval_f21347d8e3f84f7f902de098e84d2a89"
}
