# aidc CLI

AIDC Developer 的命令行，也是智能体使用 AIDC 的首选入口：每条命令都能输出 JSON、退出码稳定、不停下来等人（例外只有两个，都只在你自己的终端里：`aidc login` 问账号和密码；直接敲 `aidc` 进入交互界面，在里面和智能体对话）。所有业务逻辑都在 API 里，CLI 只做参数、文件与输出。

## 安装

```bash
curl -fsSL https://www.ai-dc.ai/developer/cli/install.sh | sh
```

需要 Node 18 以上。安装脚本把单文件 CLI 下载到 `~/.aidc/bin/aidc`，并在 PATH 里第一个 `$HOME` 下的可写目录（`~/.local/bin`、`~/bin`…）放一个链接；输出的最后一行 `下一步：… login` 就是这台机器上能用的命令（没有合适的目录时是完整路径 `~/.aidc/bin/aidc`）。也可以直接 `node aidc.mjs …`（下载地址 `https://www.ai-dc.ai/developer/cli/aidc.mjs`）。`aidc video` 与长音频转写需要 ffmpeg。

## 更新

```bash
aidc update
```

把本机的 aidc 换成线上最新版：从安装脚本用的同一个地址下载，先在同目录跑一次 `--version` 核对，再整体换上；旧的一份留在 `~/.aidc/bin/aidc.mjs.prev`，要退回就把它改回 `aidc.mjs`。登录、Key 与 `~/.aidc/config.json` 不受影响。与安装脚本一样不用登录。

| 命令 | 说明 |
| --- | --- |
| `aidc update` | 有新版就更新；已是最新时什么都不改 |
| `aidc update --check` | 只看线上版本：`{current, latest, updateAvailable, path}`，不改文件 |
| `aidc update --dry-run` | 说明会从哪个版本换成哪个版本，不改文件 |
| `aidc update --force` | 线上与本机同版或更旧也换（降级、修复损坏的安装） |

只更新安装脚本装的那一份（`~/.aidc/bin/aidc.mjs`，同目录有 `aidc` 链接）；直接 `node aidc.mjs` 跑的、别处拷来的文件不改，退出码 2，请重新跑安装脚本。只从 https 地址下载（跳转的每一跳都算；本机开发的 `http://localhost` 除外）。下载失败或下到的不是 aidc 时退出码 8，本机文件不动；目录写不进去退出码 4；另一个 `aidc update` 正在换时退出码 6（上次被打断留下的锁，确认没有别的在跑后加 `--force`）。

## 对话（交互界面）

在终端里直接敲 `aidc`（或 `aidc chat`）进入交互界面：首屏是 AIDC 标志、账号、运行时与目录，下面是输入框。没登录时先在界面里登录（账号 + 密码，或 `ctrl+b` 在浏览器里批准），然后连上运行时开始对话。说过的话按顺序留在终端自己的滚动历史里，可以用终端原生的滚动、选择、复制；底部只有正在生成的部分、输入框和一行状态。

**运行时**：交互界面只管「人怎么看、怎么说」，真正干活的是运行时，五选一（`/runtime` 随时换，`aidc runtimes` 看本机能用哪些）：

| 运行时 | `--runtime` | 是什么 | 需要 |
| --- | --- | --- | --- |
| AIDH | `aidh` | 本机的 Harness 引擎，经 ACP（Agent Client Protocol）对话；能读写文件、跑命令，有风险的操作先问你 | 本机装了 AIDH（`aidh` 命令） |
| Codex | `codex` | OpenAI Codex，经 `codex app-server`；沙箱里干活，越界时先问你 | 本机装了 `codex` 并登录过 |
| Pi | `pi` | Pi coding agent，经 `pi --mode rpc` | 本机装了 `pi` 并配置了模型 |
| Engine | `engine` | AIDC 模型（`/api/v1/models`）：只聊天、不动本机，账单记在登录的公司 | 登录 |
| 数字员工 | `agent` | 云端的数字员工（Agent API），会话在云端 | 环境变量 `AIDC_AGENT_KEY` |

另外 `aidc chat --runtime acp -- <命令…>` 能接任何实现了 ACP 的智能体。没指定时用上次用的，本机没有就按上表顺序取第一个能用的。AIDH 的档案用 `--profile <名字>` 或 `/profile` 选：引擎自己的命名档案，或这台电脑上开出来的数字员工（`<公司>/<智能体>`）。

```bash
aidc                                          # 进入交互界面
aidc chat "看看这个仓库的结构"                  # 进来先发这一句
aidc chat --runtime codex --model <模型>       # 指定运行时与模型
aidc chat --continue                          # 续上这个目录里最近一次的对话
aidc chat --resume [会话 id]                   # 续上指定的对话（不带 id 打开列表）
aidc chat -p "总结一下 README" --json          # 不进界面：跑一轮就退出（脚本 / 智能体用）
```

**输入**：`⏎` 发送；`⌥⏎`、`⇧⏎`（终端支持时）、`ctrl+j` 或行尾 `\` 再回车换行；`↑ ↓` 在多行里移动、到头翻历史；`tab` 补全；`@` 引用文件（补全当前目录下的路径）；粘贴大段文字会折叠成「[粘贴 #1 · 120 行]」，发送时展开。回答进行中也能打字，发出去的排在这一轮之后。

**快捷键**：`esc` 中断正在进行的回答；`ctrl+c` 清空输入，空输入时连按两次退出；`ctrl+d` 空输入时退出；`ctrl+l` 清屏；`ctrl+z` 挂起；`?`（空输入时）看快捷键；`/help` 列出全部命令与快捷键。

**命令**（输入 `/` 出补全列表；运行时自己的命令接在后面，例如 AIDH 的 `/compress`、`/steer`）：

| 命令 | 说明 |
| --- | --- |
| `/help` | 命令与快捷键（打进对话记录，能滚动回看） |
| `/new` · `/clear` | 开一个新对话（`/clear` 同时清屏） |
| `/resume` | 续上之前的对话 |
| `/runtime [id]` · `/model [模型]` · `/profile [档案]` | 换运行时、模型、AIDH 档案（不带参数打开列表） |
| `/status` | 账号、运行时、会话、用量与上下文 |
| `/copy` | 复制上一条回答 |
| `/thinking` | 展开 / 收起思考过程 |
| `/theme [auto\|light\|dark]` | 浅色 / 深色（缺省按终端背景自动判断） |
| `/login` · `/logout` | 换账号或公司 / 退出登录 |
| `/exit` | 退出 |

**确认**：智能体要执行命令、改文件、联网等有风险的操作时，输入框的位置换成确认面板（会响一声；同时来几个就一个一个问）：`1`–`9` 或 `↑ ↓` + `⏎` 选择，`esc` 拒绝。`aidc chat -p` 里没人可问：缺省拒绝（写进结果的 `denied`），加 `--yes` 自动允许。

**`aidc chat -p`**：不进界面，跑一轮就退出。stdout 是终端时回答边生成边打出来，否则（或加 `--json`）最后输出 `{runtime, model, sessionId, text, stopReason, usage, tools, denied}`；运行时出错退出码 8，被中断 130。提示也可以从 stdin 传入：`git diff | aidc chat -p "帮我写提交说明"`。

**终端**：浅色 / 深色按终端背景自动判断（问不到时看 `COLORFGBG`），`AIDC_THEME=light|dark` 或 `/theme` 固定；`NO_COLOR` 关颜色，`AIDC_REDUCED_MOTION=1` 关动效。中日韩文字与 emoji 按两格排版，中文输入法的候选框跟着输入框里的光标；窗口尺寸变了按新宽度重画。选择记在 `~/.aidc/config.json` 的 `tui` 里（运行时、档案、每个运行时的模型、配色、最近的会话），输入历史在 `~/.aidc/history`。

## 登录

**一律登录（2026-09-29）**：除 `aidc login`、`aidc logout`、`aidc update`、`aidc help`、`aidc --version` 外，每条命令都要先登录（没登录退出码 3）——包括只在本机跑的 `app init / check / export / dev`、`ui`、`data profile`、`modeling estimate`、`evolve slots`。**member 起步**：公司成员也能登录，能调用本公司已发布的应用（`aidc app call`）、在本机开发、`aidc whoami` 看自己；部署、发布、数据与管理命令要这家公司的 developer。自带凭证的 `aidc stream pipe`（`AIDC_PUBLISH_KEY`）与 `aidc connect send`（`AIDC_AGENT_KEY`）照旧。

```text
$ aidc login
登录 AIDC Developer（https://www.ai-dc.ai）
还没有账号？在 https://www.ai-dc.ai/login 点「注册」创建（建议用公司邮箱）；开发公司应用还需要公司发给你的 developer 授权码。

账号（用户名或邮箱）：zhang.san@example.com
密码：
已登录：张三（zhang.san）· 示例公司（cell-example）
```

| 命令 | 说明 |
| --- | --- |
| `aidc login` | 在终端里输入 AIDC 账号（用户名或邮箱）和密码（不回显），拿到一把代表你所在公司的开发者 Key |
| `aidc login --user <账号> [-n <cellId>]` | 预先给账号；账号能代表几家公司（AIDC 平台员工）时用 `-n` 指定，不给就在终端里选 |
| `aidc login --with-key < key.txt` | 从 stdin 读开发者 Key（CI） |
| `aidc login --browser [--no-wait]` | 身边没有终端的智能体：打印链接与授权码，人在浏览器里批准；`--no-wait --json` 只打印链接，随后 `aidc login --continue` 完成 |
| `aidc login --continue --no-wait --json` | 浏览器批准只查一次：没批准返回 `{"event":"authorization_pending"}`、退出码 3，批准了完成登录（`--continue` 不带 `--no-wait` 会一直等到批准或过期） |
| `aidc whoami` · `aidc keys` | 身份、Key 列表 |
| `aidc logout [--revoke]` | 删除本机 Key；`--revoke` 同时在服务端吊销 |

- **只在交互终端里问**：`aidc login` 是唯一会停下来问人的命令。stdin 不是终端（智能体、CI、管道）时立即以退出码 2 报错、说明该怎么做，不会挂着等输入。密码只在提示处输入——不收命令行参数、环境变量或 stdin。
- **还没有账号**：在 `https://www.ai-dc.ai/login` 点「注册」。使用 AIDC Developer 至少要是一家公司的 member：公司发给你的授权码（License）在 `https://www.ai-dc.ai/account` 输入；没有时登录会报「这个账号还不属于任何公司」（退出码 4）。部署、发布还要 developer 授权码。
- **密码**：与网页登录是同一个密码、同一套规则——连续输错 5 次锁 15 分钟（终端和网页算在一起），终端里最多连输三次。忘了就在登录页点「忘记密码？」重设；临时密码、邮箱没验证时先去网页登录处理。只用邮箱验证码登录、没设过密码的账号，也在「忘记密码？」里设一个。
- **Key 代表谁**：签给输入密码的这个账号、代表一家公司，按这个人在这家公司的角色（developer 或 member，`aidc whoami` / `aidc keys` 看得到），用量记在这家公司。重复登录会签新的 Key，旧的仍然有效——换机器或不用了 `aidc logout --revoke`。

凭证读取顺序：环境变量 `AIDC_API_KEY` → `~/.aidc/config.json`（0600）。API 根：`--api` → `AIDC_API_BASE` → 配置文件 → `https://www.ai-dc.ai`。

## 命令一览

```text
aidc me [--period month|30d|YYYY-MM]                # 我的工作台：身份核验、席位与配额、分身（我自己的智能体）、用量（计算秒）、存储（我的文件 + Space，回收站单列）
aidc me org [--period …] [--sort storage]           # 组织用量：每个人、每个数字员工的计算秒、token、回合、存储与席位（组织管理员）；--sort storage 按存储排

aidc ui components [组件]                           # 界面 SDK：组件、类与示例标记（本机，不联网）
aidc ui tokens [--mode light|dark] [--theme aidc|signal] [--css]
aidc ui add [目录] [--dry-run]                      # 给已有应用接上界面 SDK（入口页加 ui.css、清单 sdk 加 ui；幂等）

aidc models
aidc model chat -m <模型> "<提示>" [--system …] [--image 图…] [--json-object] [--stream]
aidc model decide --state "<文本>" --question id=说明 --choice id:选项=判据 …

# ── Engine：组织统一管理智能体的回复规范、模型、推理强度与 skill（要这家公司的 developer）──
aidc engine agents                                    # 智能体与生效配置（回复规范、模型、推理、预载的 skill、来源、生效状态）
aidc engine show <agentId> [--full]                   # 一个智能体；--full 打印下一轮带给它的回复规范全文
aidc engine test <agentId> "<消息>" [--template ste100 | --instructions-file 规则.md] [--reply-template 模板.md] [--extra "补充"] \
                 [--model 通道/模型] [--reasoning none|low|medium|high|xhigh] [--session <id>]
                                                      # 试运行：草稿只对这一轮生效，不改配置；同一个 --session 续同一段对话
aidc engine apply --org --all --prompt <id> --dry-run # 计划：全部智能体用这份回复规范（组织默认，撤掉各自的覆盖）；去掉 --dry-run 就应用
aidc engine apply --agents ops,sales --model deepseek/deepseek-v4-pro --reasoning low --preload semantic-loops [--note …]
aidc engine prompts [--archived] · prompt <id> [--version N] · templates
aidc engine prompt create "<名字>" (--template ste100|concise|report|service|data | --file 规则.md) [--reply-template 模板.md]
aidc engine prompt save <id> --file 规则.md [--reply-template 模板.md] [--note …]   # 存新版本（跟最新版的智能体下一轮就用它）
aidc engine prompt rename <id> "<新名字>" · prompt archive <id> · prompt unarchive <id>
aidc engine skills · models · changes · change <id> · revert <id>

aidc modeling models                                  # 建模 SDK：Marble 模型、价目、当前策略、上游是否已配置
aidc modeling estimate [-m marble-1.1] [--input text|image|pano|multi-image|video]   # 本机估价，不联网
aidc modeling budget                                  # 本月额度：公司上限 / 已结算 / 进行中预留 / 剩余
aidc modeling generate --text "…" | --image 图 [--image 图 … --reconstruct] [--azimuth 0,90…] | --pano 全景图 | --video 视频
                       [-m marble-1.0-draft] [--name …] [--seed N] [--tag …] [--max-credits N] [--no-recaption]
                       [--regenerate] [--idempotency-key K] [--dry-run] [--no-wait]
aidc modeling list [--status running] [--limit 30] · get <id> · wait <id>
aidc modeling upload <图片或视频>                        # 换签名地址后字节直传 World Labs，打印 mediaId
aidc modeling anchors <id> --file anchors.json [--if-rev N] [--dry-run]
aidc modeling export <id> --ply [--resolution full_res] | --mesh [--variant textured|vertex_colored] [--dry-run]
aidc modeling download <id> [--out 目录] [--quality 100k|500k|full_res] [--with-pano]
aidc modeling import --world-id <id> | --snapshot world.json [--name …] [-m 模型] [--input-kind text --text …]   # AIDC 平台账号
aidc modeling delete <id> [--purge] [--dry-run]

aidc vision inspect <图片…> --task "<检查什么>" [--criteria …] [-m gpt-6-luna]
aidc vision detect <图片…> [--labels 人,叉车] [--prompt …] [--max 50] [-m gpt-6-luna]   # 物体检测
aidc vision camera list | show <名字>                        # 公司的网络摄像机 / NVR（经平台转发的 RTSP）
AIDC_CAMERA_PASSWORD=… aidc vision camera add <名字> --host <外网地址> [--port 554] [--vendor dahua|hikvision|generic] \
    [--path 模板] [--username …] [--channels 1:大门,2:仓库] [--default-stream sub] [--max-viewers 4] [--allow-main-live] [--dry-run]
                                                               # 口令只从 AIDC_CAMERA_PASSWORD 或 --password-stdin 读
aidc vision camera probe <名字> [--channels 1-16] [--main]    # 连上、认证、读编码（不拉流）；口令被拒立即停
aidc vision camera snapshot <名字> [--channel 1] [--sub] [-o a.jpg]   # 截一帧（缺省主码流高清），本机 ffmpeg 转图片
aidc vision camera remove <名字> --yes [--dry-run]
aidc voice transcribe <音频/视频> [--language zh] [-m gpt-transcribe]
aidc voice translate "<文本>" --to ja,en,ar-EG,bn
aidc voice minutes <逐字稿.txt> [--title …]
aidc video frames <视频> --every <秒> [--out 目录] [--max N]
aidc video inspect <视频> --every <秒> --task "<检查什么>" [--transcribe]

# ── Semantic（数据平台）：对象、Action、订阅、数据从哪来、SQL、访问、自动化、日志与用量 ──
# Ontology（Ontology REST API v2 / OSDK 形状；读命令都收 --branch <分支>，读分支上的定义）
aidc semantic ontology                                # 全貌：Object Type（主键、链接）、Action Type、Interface
aidc semantic object-types [apiName] · action-types [apiName] · interfaces [apiName] · value-types · shared-properties
aidc semantic objects <类型> [--where '{"stage":"付费","seats":{"$gt":30}}'] [--order-by seats:desc] [--select a,b] [--page-size n] [--page-token t]
aidc semantic object <类型> <主键> [--select a,b] · links <类型> <主键> <链接>
aidc semantic aggregate <类型> --select '{"$count":"unordered","costUsd:sum":"desc"}' [--group-by '{"month":"exact"}'] [--where …] [--interface]
aidc semantic object-set <对象集.json|'{…}'> [--aggregate '{"$select":{…}}']
aidc semantic subscribe <类型> [--where '{…}'] [--properties a,b]   # 实时订阅对象集（OSDK subscribe）：● 进来 / 变了 ✗ 离开，--json 输出 JSON 行
aidc semantic apply <Action> [--param 名=值 …] [--params '{…}'] [--validate-only] [--return-edits]   # 改数据的唯一方式；校验不通过 → 退出码 2
aidc semantic apply-batch <Action> <参数数组.json> [--return-edits]                                 # 最多 20 个，一个事务
# 函数（Function）：在隔离的运行时里执行；语义化版本，发布后不能改（同一内容 = unchanged，内容不同 → 冲突，退出码 6）
aidc semantic functions publish <源码.js> --api-name <camelCase> --version <1.0.0> --output '{"type":"integer"}' \
    [--parameters '{"status":{"dataType":{"type":"string"},"required":false}}' | 参数.json] [--edit-function] \
    [--display-name …] [--description …] [--timeout-ms N] [--dry-run]                            # 只给开发者；智能体（AIDC_AGENT_ID）只能发预发布版本（1.1.0-rc.1）
aidc semantic functions list                                                                    # 每个函数的最新版本与全部版本（不带源码）
aidc semantic edits-history <类型> [--pk 主键] [--previous]
aidc semantic security test <类型> [--user <账号 id>] [--pk 主键,…] [--object '{…}' …] [--policy 策略.json]   # 试安全策略（开发者；不回属性值）
# 建本体：智能体在分支上改、开提案，人在网页上审核合并（设 AIDC_AGENT_ID=<智能体> 时作者记为智能体）
aidc semantic define <文件.json|目录> [--dry-run]     # 定义（有则改）；数据源写在 Object Type 的 datasources 里
aidc semantic types · archive <apiName> · publish [--notes …] · releases · describe [--markdown]
aidc semantic branch list · create <分支> [--description …] · show <分支>
aidc semantic branch modify <分支> <文件|目录> [--archive a,b] [--expected-version N] [--dry-run]
aidc semantic branch validate <分支> · conflicts <分支> · rebase <分支> [--keep a,b] [--take-main c] · discard <分支> [资源…] · lock <分支> [--unlock]
aidc semantic branch propose <分支> --title … --trigger "为什么要改" [--self-test "自测结果"] [--description …]   # 打印审核网页地址
aidc semantic proposals [--status OPEN|MERGED|CLOSED] · proposal <id> · proposal close <id> [--note …]
# 数据从哪来（Data Connection：发布端 → 数据流 → Object Type 定义里的 datasources）；流名可写 <流名> 或 <命名空间>/<流名>
aidc semantic streams create <流名> --title … [--key 主键] --field 名:类型[:显示名] … [--retention N] [--spec 文件.json]
aidc semantic streams list · status <流名> · get <流名> · tail <流名> [--after N] · delete <流名> [--dry-run]
aidc semantic streams key <流名> --label "装在哪" · keys <流名> · revoke <流名> --prefix aidc-pk-…
aidc semantic streams publish <流名> --event '{…}' | --file 事件.json
aidc semantic streams pipe <命名空间>/<流名> -- <适配器命令…>   # 边缘发布端（发布 Key 读 AIDC_PUBLISH_KEY）
               [--heartbeat 30] [--full-every 360] [--stale-after 15]   # 秒 / 分 / 分
aidc semantic datasource list [类型]                  # 每个类型的数据源与同步进度
aidc semantic datasource sync                         # 平台数据源立即同步（= /semantic 的「立即同步」；AIDC 组织还同步 AWS 数据源）
aidc semantic datasource set <类型> --stream <流名> --map 属性=列 … [--mode mirror|upsert] [--dry-run]   # 写进类型定义（智能体作者要走分支）
aidc semantic datasource remove <类型> --stream <流名> [--dry-run] · resync <类型> --stream <流名>
# Media sets（图片、文档、音视频等文件，字节在公司自己的 S3 里；对象用媒体引用属性指向它们）
aidc semantic media-sets list | show <媒体集 RID> | create --name 巡检照片 --schema IMAGERY [--transactional] [--virtual <源文件夹>] [--extra TXT,DOCX]
aidc semantic media-sets upload <RID> <文件> [--path <路径>] [--transaction <id>]   # > 4.4 MB 自动走直传 S3（≤ 50 GB）
aidc semantic media-sets items <RID> [--path <路径>（版本历史）] [--prefix <前缀>] | sync <RID>（虚拟媒体集：登记源文件夹里的新文件）
aidc semantic media-sets metadata <RID> <媒体项 RID> | download <RID> <媒体项 RID> [--out 文件] | text <RID> <媒体项 RID>（PDF / TXT 全文）
aidc semantic media-sets clear <RID> --path <路径>（软删）| retention <RID> [--older-than 天] [--overwritten-after 天] | transaction <RID> open | commit <id> | abort <id>
aidc semantic upload-media <类型> <属性> <文件> [--media-item-path <路径>] [--content-type <类型>]   # 往媒体引用属性直传公司的 S3 → MediaReference（一小时内交给 apply 的 --params）

# Semantic 数据库（Ontology SQL：一条 SELECT、≤ 10,000 行、20 秒；表名 = Object Type API name）
aidc semantic sql "SELECT … FROM <Object Type>" [--param 值 …] [--row-limit N] [--explain] [--csv] · sql --file q.sql
aidc semantic database [--sync] · database --rotate      # 表与列、我用的角色；开发者轮换口令拿只读直连串
# 访问：Private / Group / Public / Open to Internet（Ontology、Object Type、数字员工、文件、文件夹 / Project）与账号
aidc semantic filesystem list [--scope public|organization|shared|mine] [--type ontology|objectType|agent|file|folder]
aidc semantic filesystem show <rid> · roles <rid>
aidc semantic filesystem access <rid> --tier private|group|public|internet      # 一步设档位（Owner）
aidc semantic filesystem share <rid> (--user <账号 id> | --group <组 id|cell-…|cell-…:developers> | --everyone | --internet) [--role viewer|editor|owner]
aidc semantic filesystem unshare <rid> (--user … | --group … | --everyone | --internet) --role <角色>
aidc semantic filesystem link <rid> [--days 30]                                  # 邀请链接（Group，只有 Viewer）
aidc semantic admin whoami · admin members list · admin members import <名单.json|.csv> --source <来源名> [--dry-run]   # 本公司成员；导入已有名单
# 数据安全：Markings（强制控制：只有成员能访问，不看角色）；对象 / 属性安全策略写在 Object Type 定义里
aidc semantic admin marking-categories list · show <id> · create --name … [--disjunctive] [--hidden] · rename <id> --name …
aidc semantic admin markings list · show <id> · create --name … --category <类别 id> [--member <主体>,…] · rename <id> --name …
aidc semantic admin markings members <id> · add-members <id> <主体…> · remove-members <id> <主体…>          # 只有 ADMINISTER
aidc semantic admin markings roles <id> · grant <id> ADMINISTER|DECLASSIFY|USE <主体…> · revoke <id> <角色> <主体…>
aidc semantic admin markings mine [--user <账号 id>]                             # 是哪些 Marking 的成员
aidc semantic filesystem markings <rid> · mark <rid> <Marking id…> · unmark <rid> <Marking id…>   # 挂上要 USE、去掉要 DECLASSIFY + USE，都要是 Owner
aidc share <应用> --company | --user <用户名或邮箱> | --public [--role viewer|editor] [--days 30] [--note …]   # 应用的分享
# Data Connection 与 Automate（ConnectivityV2 / Automate：平台的 worker 用只读 SQL 读源系统，写成 dataset 的事务，只把变了的行索引成对象；automation 替代 cron）
aidc semantic connectivity agents|connections --ontology <cell-…>                   # agent proxy（客户网络里，只出站）与 Connection（秘密只有名字）
aidc semantic connectivity agent register --ontology <cell-…> --api-name <名字> --display-name <显示名> [--rotate-token] [--dry-run]   # 凭证只给一次 + 三步安装
aidc semantic connectivity egress list --ontology <cell-…> · egress create --ontology <cell-…> --file <策略.json> [--dry-run] · egress show|revoke <策略 RID>   # 出口策略：只能吊销
aidc semantic connectivity connection --ontology <cell-…> --file <定义.json> [--dry-run]   # jdbc / rest + Foundry worker（出口策略）；口令写一次，平台加密
aidc semantic connectivity config <connectionRid> · secret <connectionRid> <秘密名> [--from-env <变量>] [--dry-run]   # 秘密的值从标准输入或环境变量读
aidc semantic connectivity migrate <connectionRid> --policies <策略 RID,…> --yes · revert-migration <connectionRid>   # 旧版 agent worker → Foundry worker（30 天内可退回）
aidc semantic connectivity explore <connectionRid> [--search <字>] · explore <connectionRid> --table <schema.表名> [--preview --rows 20]   # 建 sync 之前看源里的表、结构与样本（样本只在直连的 source 上）
aidc semantic connectivity imports <connectionRid> · import <connectionRid> --file <TableImport.json> [--dry-run]
aidc semantic connectivity execute <connectionRid> <tableImportRid> [--full] [--wait]   # 执行一次：查询 → dataset 事务 → 只写变了的对象
aidc semantic connectivity build <buildRid> · dataset <datasetRid> [--rows 20]        # Build 状态；dataset 当前视图（CSV）
aidc semantic transforms list --ontology <cell-…> · put --ontology <cell-…> --file <transform.json> [--dry-run]   # 加工：从 dataset 算出新的 dataset（一条 DuckDB SELECT）
aidc semantic transforms show <transformRid> · build <transformRid> [--force] [--wait] · delete <transformRid> [--dry-run]   # 输入一有新数据就自动构建；没变化不跑（--force 照跑）
aidc semantic connectivity webhooks --ontology <cell-…> [--connection <数据源>] · webhook put --ontology <cell-…> --file <webhook.json> [--dry-run]   # REST API 数据源上的 webhook
aidc semantic connectivity webhook get|delete <webhookRid> · webhook test <webhookRid> [--inputs '<JSON>' | --inputs-file <文件，- 是标准输入>] [--dry-run]   # 手动试：--dry-run 只渲染（秘密打码）
aidc semantic automations list --ontology <cell-…> · upsert --ontology <cell-…> --file <automation.json> [--dry-run]
aidc semantic automations show|run|pause|resume|delete <automationRid>                # 条件 + 效果：替代 cron
aidc semantic automations runs --ontology <cell-…> [--automation <rid|apiName>] [--status failed] [--since <ISO>]   # History：全组织的运行，新的在前
#   效果：action（以拥有者的身份执行 Action）、function（执行已发布的函数）、notification（邮件）；效果输入 $effectInput、重试、fallbackEffects
#   钉钉 / 企业微信通知与 agentScript 已停用：新建不收（automate_legacy_effect，退出码 2），已有的照常运行（闭环 · 迁移表）
aidc share list [应用] · aidc share revoke <分享 id>
# 自动化（Automate：数据变化 / 定时 → Action、模型分析、通知）
aidc semantic automate capabilities [--app slug]      # 能力目录：● 清单 exports 显式导出  ○ 从登记的类型 / Action 自动提取
aidc semantic automate list · get <slug> [--channel test]
aidc semantic automate run <slug> [--input '{…}'] [--param 名=值 …] [--preview] [--channel test] [--no-wait] [--idempotency-key k] [--dry-run]
aidc semantic automate runs <slug> [--limit 20] · status <slug> <运行 id> · watch <slug> <运行 id>
# 日志与用量
aidc semantic observability summary [应用] [--days 7] · events [--app …] [--kind feedback] [--status open] · feedback <id> --status done
aidc semantic usage summary [--app slug] [--month 2026-09] [--budget 美元] [--fx 7.1]   # 今日 / 本月 / 累计、按应用 / Key / 模型 / 天、月底预测、未计价
aidc semantic usage records [--app …] [--month …|--from … --to …] [--model …] [--lane app|developer] [--limit 100] [--all] [--csv]
aidc semantic usage check [--month …] [--app …]       # 对账；对不上退出码 1
aidc semantic usage prices                            # 价目（网页上的价目照样公开）
aidc semantic usage estimate -m <模型> --calls N [--per day|month] [--input N] [--cached N] [--output N] [--seconds N] [--kind video] [--off-peak 0.3] [--budget 美元] | --file 估算.json
# 旧命令照样能用（1.20.0 起都是 Semantic 的一部分）：aidc stream = semantic streams、aidc resources = semantic filesystem、aidc members = semantic admin members、
# aidc workflow = semantic automate、aidc log = semantic observability、aidc billing = semantic usage；aidc semantic act（旧的执行 Action）；
# aidc data query|get|create|update|delete|import|aggregate|watch|bind|bindings|resync|unbind（旧的数据层；直接写对象只给开发者）、aidc data profile|group（本地分析）；
# aidc connect datasets · report <数据集> [--report overview]（Semantic 之前的固定报告）· aidc connect send "<消息>" [--session <id>]（智能体，Agent Key 读 AIDC_AGENT_KEY）

aidc evolve slots [目录]                                # 本机：页面上的槽位（data-evolve）与清单 evolve 声明（不联网）
aidc evolve list <应用> [--status proposed] [--scope app|personal] [--kind overlay|request] · show <应用> <id>
aidc evolve compile <应用> "<一句话>" [--slot chat] [--model gpt-5.4-mini]   # 看一句话会变成什么指令（不保存）
aidc evolve save <应用> --ops 指令.json --title "…" [--scope app|personal] [--dry-run]
aidc evolve adopt|reject|revert|propose <应用> <id> [--note …] [--dry-run]
aidc evolve overlay <应用> [--scope app] [--css] · bake <应用> [--dir 应用目录] [--dry-run]   # 固化：全员改进写进源码，版本 +1
aidc evolve evidence [应用] · suggest [应用] [--file f] [--skill SKILL.md] [--conversation f] [--max 5]   # 证据 / 模型起草提案
aidc evolve proposals [--status open] · propose --spec 提案.json · accept <id> · reject <id> · apply <id> [--version 1.2.0]
# propose / reject 两边都有：带 <应用> <id> 两个参数的是应用里的改进，其余是提案。aidc improve …（1.2–1.20 的自提升）是旧名，子命令不变

aidc app init <slug> [--format plugin|aidc] [--template skills|blank|camera|voice|data|semantic|workflow|modeling] [--title …] [-n <命名空间>]
               [--device-type desktop|mobile] [--object-type <Object Type>] [--action-type <Action>]   # 手机应用；semantic 模板读哪个类型、执行哪个 Action
aidc app export [目录] [-n <命名空间>] [--out plugin.zip] # 标准包；输出到应用目录外
aidc app check [目录]
aidc app dev [目录] [--port 5173]
aidc app deploy [目录] [--notes …] [--dry-run]         # 版本号 = 清单 version，内容变了就要升
aidc app publish <slug|目录> [--version 1.2.0] [--notes …] [--dry-run]
aidc app rollback <slug> --version 1.1.0 [--notes …]
aidc app status <slug> · aidc app history <slug> · aidc app list   # slug 也可写 <命名空间>/<slug>
aidc app registry                                      # 应用登记表：每个应用用了哪些 SDK / 资源
aidc app card [slug|目录]                              # 应用卡片：负责部门、版本、SDK、连了哪些数据、对外能力与依赖
aidc app usage <slug>                                  # 资源用量：本月计算分钟 / 全部上限 / 定时 / 今天的通知与邮件通道
aidc app about <slug|命名空间/slug> [--channel test]   # 应用说明（给智能体读：APIs、Skills 全文、示例说法；同 <应用地址>/about.md）
aidc app apis <slug|命名空间/slug> [--channel test]    # 应用的 APIs：名字、参数、返回、调用口；Skills；用到的 AIDC 能力
aidc app call <slug|命名空间/slug> <API> [--param 名=值 …] [--input '{…}'] [--preview] [--channel test] [--idempotency-key k] [--dry-run]
                                                       # 调应用的一个 API（应用 × 成员角色执行；写入先 --preview）

aidc notify test [--dry-run]                           # 给自己发一封测试邮件，验证工作流 notify 步骤的邮件通道
```

`aidc app check` / `aidc app deploy` 发现成本问题时在 stderr 打 ⚠️ 告警（`--json` 时在 `warnings` 字段），不拦部署：工作流定时 ≤ 1 小时一次、`limits` 高于缺省、代码里 `setInterval` 拉数据。见[发布 SDK · 资源上限](publish.md#资源上限与成本告警)。

Semantic（含数据流、访问、自动化、日志、用量）、分享、自进化、建模命令的命名空间缺省 = 当前登录的公司（`-n cell-…` 可以指定；AIDC 平台账号可以 `-n public`）。`aidc modeling generate` 缺省等世界生成完成（约 5 分钟，进度打在 stderr），本地文件先直传 World Labs（`--dry-run` 不上传、不花钱）；生成失败退出码 8，额度 / 单次上限不够退出码 7。`aidc semantic automate run` 缺省等运行结束并逐步打印进度（stderr），运行失败退出码 1。

流名可以写 `<流名>`（命名空间取当前登录的公司）或 `<命名空间>/<流名>`。`aidc semantic streams pipe` 常驻运行（systemd 服务，不是定时器），适配器协议见 [数据流与数据源](connect.md)。

通用参数：`--json`（stdout 不是终端时默认开启）、`--dry-run`、`--api <根地址>`、`-n/--namespace`。

## 输出与退出码

- JSON 模式下，成功输出命令的数据对象；失败输出 `{ ok: false, error: { code, message, status, details, requestId } }`。进度提示一律在 stderr。
- `aidc login --json`：成功输出 `{"event":"logged_in","username":…,"cellId":…,"companyName":…,"keyPrefix":…}`（提示仍在 stderr）；`--browser` 时先逐行输出 `{"event":"authorize","url":…,"userCode":…}`。

| 退出码 | 含义 |
| --- | --- |
| 0 | 成功 |
| 1 | 一般错误 |
| 2 | 参数错误 / 校验不通过 |
| 3 | 未登录或凭证无效 |
| 4 | 无权限 |
| 5 | 不存在 |
| 6 | 冲突（例如发布未测过的版本、内容变了没升版本号） |
| 7 | 限流或额度用完 |
| 8 | 上游或网络故障 |

## 外部程序

`aidc video` 与长音频转写通过 ffmpeg 抽帧、转码、分段（`AIDC_FFMPEG` / `AIDC_FFPROBE` 可指定路径）。没装时命令报错并给出安装方式，不会退化成不完整的实现。
