📚AI 编程官方教程中文版
官方教程中文版产品入口

配置本地运行环境

Local environments 用来为 worktrees 配置 setup steps,也可以为 project 配置常用 actions。

Local environments 用来为 worktrees 配置 setup steps,也可以为 project 配置常用 actions。

配置入口在 Codex App settings pane。生成的配置文件可以提交到项目的 Git repository,方便团队共享。

Codex 会把这份配置存放在 project root 的 .codex folder 中。如果你的 repository 包含多个 projects,打开那个包含 shared .codex folder 的 project directory。

Setup scripts

worktrees 和 local tasks 运行在不同目录里,所以新 worktree 可能还没完成 setup,也可能缺少 dependencies,或者缺少未提交到 repository 的文件。

当 Codex 在新 thread 开始时创建 new worktree,setup scripts 会自动运行。

setup script 用来执行配置环境所需的命令,例如:

  • 安装 dependencies。
  • 运行 build process。
  • 生成项目运行需要的本地文件。

TypeScript project 示例:

npm install
npm run build

如果 setup 和平台相关,可以分别为 macOS、Windows 或 Linux 定义 setup scripts,用它们覆盖 default。

Actions

Actions 用来定义项目常用任务,例如启动 app development server,或运行 test suite。

这些 actions 会显示在 Codex App top bar,方便快速启动。它们会在 App 的 integrated terminal 中运行。

Actions 的价值是减少重复输入。常见例子:

  • 触发项目 build。
  • 启动 development server。
  • 跑 test suite。

一次性 quick debugging 可以直接使用 integrated terminal。

官方截图:

Node.js project 可以创建一个名为 "Run" 的 action,脚本如下:

npm start

如果 action 的 commands 和平台相关,可以分别为 macOS、Windows 和 Linux 定义 platform-specific scripts。

为了方便识别 actions,可以为每个 action 选择一个相关 icon。

On this page