智能体命令

智能体用来维护项目网站列表的命令,也就是 AirBuild App 里「网站」标签页显示的列表。

website 维护属于某个项目的网站列表:也就是大家在 AirBuild App 里项目的网站标签页中看到的那些网站。智能体用标题和地址添加一个网站,AirBuild 随后读取页面,获取它的图标和主题色。这个列表和项目一起保存在 AirBuild 中,项目文件里没有任何关于它的描述。

在哪里运行

云端团队和 Mac 团队的智能体都能使用同一个命令。登录凭据来自智能体的运行环境,无需任何设置。命令依赖 curl 和 jq,运行环境已经提供。两种团队的区别见选择智能体的运行位置。

用法概要

website [--project <project-id>] list
website [--project <project-id>] add --title T --url U [--source PATH] [--worker NAME] [--color #RRGGBB]
website [--project <project-id>] edit <id|url> [--title T] [--url U] [--source PATH] [--worker NAME] [--color #RRGGBB]
website [--project <project-id>] move <id|url> --to N
website [--project <project-id>] refresh <id|url>
website [--project <project-id>] remove <id|url> --confirm
website --help

--project 可以放在命令行的任意位置。所有选项也都接受 --option=value 写法。

哪个项目

在项目文件夹内运行时,website 会自己判断是哪个项目。在其他位置,请用 --project 传入项目 id(UUID)。两者都没有时,会报错停止:

Error: cannot tell which Project this is. Run website from inside a Project directory, or pass --project <project-id> (the uuid from list_projects).

指定网站

edit、move、refresh 和 remove 通过 id(来自 website list)或地址来指定网站。地址末尾有没有斜杠都能匹配。

命令

Command 作用 输出
list 按顺序显示项目的网站。不接受参数。 每个网站一行(见输出),或 No websites listed for this Project yet. Add one with website add --title … --url ….
add 在列表末尾添加一个网站。--title 和 --url 为必填。添加后会读取页面的图标和主题色。 Added <title> — <url> (id <id>). The page is being read for its icon and colour.
edit 只修改你传入的字段;至少需要一个。传入空值("")可清除 --source、--worker 或 --color。换了新地址会重新读取页面。 Updated <title> — <url>.
move 把网站放到第 N 个位置;0 是第一个。超过末尾的位置会放到最后。 按新顺序输出整个列表。
refresh 重新读取页面的图标和主题色。 Reading the page again; website list shows the result in a moment.
remove 从列表中移除网站。需要 --confirm。 Removed.

字段

Option 取值 含义
--title 1–80 个字符 网站在列表中的名称。
--url 绝对的 http:// 或 https:// 地址 网站地址。同一地址在一个项目的列表中只出现一次。
--source 相对项目根目录的路径,最多 512 个字符 网站代码在项目中的位置。
--worker worker 名称 托管该网站的 AirHost worker。网站托管在别处时不填。
--color #RRGGBB 网站的主题色。用这种方式设置的颜色在重新读取页面时会保留;用 "" 清除后,从页面 theme-color 读取的颜色会生效。
--to 整数,0 或更大 仅用于 move:新的位置。
--confirm — 仅用于 remove:确认移除。
--project 项目 id(UUID) 要操作的项目。在项目文件夹内可省略。

一个项目最多列出 50 个网站。

输出

list 和 move 按顺序每个网站输出一行:

<id>  <title> — <url>  worker=<name>  source=<path>  color=<#RRGGBB>  icon

worker=、source= 和 color= 只在已知时出现。AirBuild 已获取页面图标时行尾为 icon,否则为 no-icon。

退出码

Code 含义
0 成功。
2 任何错误。stderr 上的消息以 Error: 开头。

错误

Message 处理方法
Error: cannot tell which Project this is. … 在项目文件夹内运行,或传入 --project。
Error: --project expects a Project id (uuid), got: … 传入项目的 UUID,而不是名称。
Error: no website with the address '…' in this Project. Run website list. 对照 website list 检查地址,或改用网站的 id。
Error: website add needs --url. 加上 --url。缺少 --title 时会输出 add 的用法行。
Error: website edit needs at least one of --title, --url, --source, --worker, --color. 传入要修改的字段。
Error: usage: website move … --to N --to 需要一个整数。
Error: removing a site from the list needs --confirm. 加上 --confirm。
Error: unknown option '…' for website <command>. Run website --help. 对照上面的表格检查选项。
Error: could not reach the Airbuild service. 重试。
Error: <reason> AirBuild 拒绝了请求:例如标题不在 1–80 个字符之间、地址不是绝对的 http(s) 地址、项目已列出该地址、颜色不是 #RRGGBB,或列表已有 50 个网站。原因里会说明是哪一种;修正后重新运行命令。

示例

添加 App 的支持页面并设置颜色:

终端窗口
website add --title "Support" --url https://example.com/support --color "#1E88E5"

记录某个网站由 worker 托管、由项目中的某个文件夹构建:

终端窗口
website edit https://example.com --worker example-site --source web/

把某个网站放到第一位并查看列表:

终端窗口
website move https://example.com/privacy --to 0
website list

移除一个网站:

终端窗口
website remove 6f1c2d3e-0000-4000-8000-000000000000 --confirm