集成
你可以在脚本和 CI 中运行一次任务,也可以把 CrystalCode.Engine 接入自己的前端。
运行单个任务
crystal run 执行一次任务后退出,适合脚本或 CI。Windows 上使用 CrystalCode。
crystal run --workspace . "Fix the failing test."GitHub Actions
crystal run 不需要交互式终端。工作流可以先安装 Crystal Code,然后在仓库中执行一次任务,并在退出码非零时让作业失败。
如果不使用集成包,下面的工作流会安装 Crystal Code,然后在仓库中执行一次任务。提供商密钥放在仓库 Secret 中。这里直接调用 CrystalCode,因为 CI 运行器不会加载安装脚本设置的 shell 别名。
name: Crystal Code review
on: pull_request
permissions:
contents: read
jobs:
review:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Install Crystal Code
run: |
curl --fail --location --show-error https://crystalcode.ink/install.sh | sh
echo "$HOME/.crystal/binaries/code" >> "$GITHUB_PATH"
- name: Review changes
env:
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
run: |
CrystalCode run --workspace . --workspace-trust off \
--plan --duration 600 \
"Review the changes on this branch and list the risks."
示例用 --plan 做只读审查,并用 --workspace-trust off,因为 CI 目录无法应答信任提示。这不会把该目录记为已信任。
基于引擎构建
引擎是一个类库。其他前端可以直接引用它,不需要复制代码。模型端点由你提供。