SuperAPI AI Directory

rock-cli

General & other

View repository

Updated 10-16 07:23

About this skill

ROCK CLI User Guide (v2.7)

Installation and Updates

# 安装
bash -c "$(curl -fsSL http://xrl.alibaba-inc.com/install.sh)"

# 升级(推荐)
rockcli update

After installation, you can use rockcli or rc. patch/beta upgrades complete silently, minor upgrades are automatic, major requires confirmation.

Authentication Configuration

export ROCK_API_KEY=your-api-key          # 方式一:环境变量(优先级最高)
rockcli --api-key your-key <command>      # 方式二:全局参数
# 方式三:配置文件 ~/.rock/setting.json
rc login --api-key <key>                  # 保存凭据到配置文件
rc whoami                                 # 查看当前身份

Scenario Guide

For detailed parameters, see references/sandbox.md。

Scenario 1: Quick Start / One-off Tasks

Applicable: temporarily executing scripts, verifying the environment, running a snippet of code

rockcli sandbox start --wait-for-alive      # 启动并阻塞等待 alive
rockcli sandbox <id> exec 'python -c "print(1+1)"'
rockcli sandbox <id> stop

Scenario 2: Upload Code → Execute → Download Results

Applicable: running local projects and batch tasks in a sandbox

rockcli sandbox start --memory 16g --cpus 4 --disk 100g --wait-for-alive

# 递归上传(注意:-r 短参数无效,必须用 --recursive)
rockcli sandbox <id> upload --dir ./my-project --target-path /app --recursive
# 包含隐藏文件(如 .env)加 -a
rockcli sandbox <id> upload --dir ./my-project --target-path /app --recursive -a

rockcli sandbox <id> exec 'cd /app && python main.py'
rockcli sandbox <id> download --file /app/output.csv   # 下载到当前目录
rockcli sandbox <id> stop

Scenario 3: Interactive Development (attach REPL)

Applicable: debugging, exploring the environment, needing multiple rounds of interaction (the sandbox must be in alive state)

rockcli sandbox <id> attach

For built-in REPL commands, see references/sandbox.md - attach. Key differences:

  • /exit — disconnect, keeping the sandbox and session for reconnection
  • /close — permanently close the session

Scenario 4: View Historical Operation Records

Applicable: tracing back all API operations on a sandbox (complete HTTP request history for start/exec/upload, etc.)

rockcli sandbox <id> history

Scenario 5: Replay Requests

Applicable: reproducing historical request sequences for testing or troubleshooting

# 自动从该沙箱的日志历史中拉取请求并回放
rockcli sandbox <id> replay

Scenario 6: View Sandbox Status

rockcli sandbox <id> status
rockcli sandbox <id> status --output json   # JSON 格式输出

State transitions:pending → alive → stopping → stopped

Supports querying the status of stopped/deleted sandboxes. Status output is displayed in sections and includes a state timeline.

Scenario 6-b: Restart a Stopped Sandbox

rockcli sandbox <id> restart
rockcli sandbox <id> restart --wait-for-alive --timeout 120

Scenario 7: Run AI Agent Evaluation Tasks

Applicable: executing AI agent evaluation tasks via the Python rock-sdk (requires Python >= 3.11)

# Config 模式:从本地 YAML 文件运行
rockcli agent run --config job.yaml

# 覆盖 YAML 中的任务
rockcli agent run --config job.yaml --task astropy__astropy-7606

# Bench 模式:从 benchhub 模板运行
rockcli agent run --bench aone-bench --task codereview-20789198 --agent claude-code

# 异步模式(提交后立即返回 sandbox_id)
rockcli agent run --config job.yaml --async

# 静默模式(前台只显示摘要和日志路径,详细日志写入 ~/.rock/jobs/)
rockcli agent run --config job.yaml --quiet

# 使用预发环境
rockcli agent run --config job.yaml --pre

Scenario 8: View Agent Job/Task/Trial Information

Applicable: viewing experiment lists, Job status, Task progress, Trial results, and execution traces

# 列举所有实验
rockcli agent view -E

# 列举指定实验的 Jobs
rockcli agent view -e exp-id

# 按条件过滤 Jobs
rockcli agent view -e exp-id --agent claude-code --date today --sort avg_reward:desc

# 全文搜索
rockcli agent view -e exp-id --q "keyword"

# 查看 Job 详情
rockcli agent view -j my-job

# 查看 Trial 完整执行轨迹
rockcli agent view -j my-job --trajectory

Scenario 9: Agent File Operations (view/download Job artifacts)

Applicable: viewing the file list of a job/trial, reading logs and result files, downloading artifacts, viewing artifacts

# 列出 job 根目录文件
rockcli agent fs ls -e exp-id -j my-job

# 读取 trial 的 result.json
rockcli agent fs cat result.json -e exp-id -j my-job -t my-task

# 下载 trajectory 到本地
rockcli agent fs download trajectory.json -e exp-id -j my-job -t my-task -o /tmp/

# 查看 trial artifacts 和 manifest
rockcli agent fs artifacts -e exp-id -j my-job -t my-task

Scenario 10: Experiment Sandbox Management (batch view/stop)

Applicable: viewing the sandbox list under an experiment, batch-stopping all sandboxes of an experiment

# 查看实验沙箱概况
rc expr aone-bench-test

# 查询实验下沙箱列表
rc expr aone-bench-test sandboxes

# 预览批量停止影响范围
rc expr aone-bench-test sandboxes stop --dry-run

# 批量停止并跳过确认
rc expr aone-bench-test sandboxes stop -y --concurrency 10

Scenario 11: Image Dump (inter-registry images / sandbox transfer)

Applicable: mirroring Docker images from a source registry to a target registry, batch-moving images via sandboxes, managing dump tasks

# skopeo 模式批量镜像(推荐,默认)
rc image mirror docker:dind --mode skopeo
rc image mirror -f images.txt --mode skopeo --concurrency 10 --copy-concurrency 8

# 仓库间镜像单个镜像
rc image mirror nginx:latest \
  --target-registry registry.example.com \
  --target-username user --target-password pass

# 使用本地 Docker(无需沙箱)
rc image mirror nginx:latest --mode local \
  --target-registry registry.example.com \
  --target-username user --target-password pass

# 在沙箱中构建并推送镜像
rc image build . -t my-image:v1
rc image build . -t my-image:dev --mode local --push

# 管理转储任务(task)
rc image task list                  # 列出所有任务
rc image task status <task-id> -v   # 查看任务状态(含每条镜像详情)
rc image task delete <task-id>      # 删除任务

Scenario 12: Dataset Management

Applicable: viewing, querying, uploading ROCK datasets, importing datasets from Hugging Face

# 列出数据集
rc datasets list
rc datasets list --prod

# 查看数据集详情(省略 action 时默认 detail)
rc datasets my-org/swe-bench

# 查看数据集 split 列表
rc datasets my-org/swe-bench splits

# 查询任务列表(支持分页、搜索、排序)
rc datasets my-org/swe-bench tasks --split test --filter "keyword" --limit 50

# 查看单个任务详情
rc datasets my-org/swe-bench task --task task-id --split test

# 上传本地目录到数据集
rc datasets my-org/swe-bench upload ./tasks --split v1
rc datasets upload --org my-org --dataset swe-bench --dir ./tasks --concurrency 8

# 从 Hugging Face 导入数据集
HF_TOKEN=xxx rc datasets upload --org my-org --dataset swe-bench --split test \
  --from hf --hf-name SWE-bench/SWE-bench --hf-split test

# 数据集文件操作
rc datasets my-org/swe-bench fs ls --task task-1                     # 列出文件
rc datasets my-org/swe-bench fs get --task task-1 --path result.json # 查看内容
rc datasets my-org/swe-bench fs download --task task-1 --path file.txt --dest ./  # 下载

Scenario 13: Windows Sandbox

Applicable: needing to run tasks in a Windows environment

# 启动 Windows 沙箱(自动使用固定 cluster 和镜像)
rc sandbox start --image-os windows --wait-for-alive

For detailed parameters, see references/agent.md、references/experiment.md、references/image.md and references/datasets.md。


Global Options

Option Description
--verbose, -v Log level (-v: warning, -vv: info, -vvv: debug, including API request debugging)
--base-url <url> Server address (default https://xrl.alibaba-inc.com)
--style <dark|light> Terminal output style
--api-key <key> API key
-c, --cluster <id> Cluster identifier
--user-id <id> User ID (employee number)
--experiment-id <id> Experiment ID
--image <name> Docker image
--cpus <n> CPU specification (Core)
--memory <size> Memory specification (positive numbers are treated as GiB, supports g/m units)
--disk <size> Disk size (positive numbers are treated as GiB, supports g/m units, default 50g)
-H, --extra-header Additional HTTP request headers (format:Key=Value)