WidgetStore CLI:让其它 AI Agent 用命令操作组件世界
组件世界电脑版自带命令行工具 widgetstore:脚本和 Claude Code、Codex 等 AI Agent 可以用它读写你的组件、我的数据、专注和空间,还能当本机 MCP 服务器一行接入。安装、登录、命令、安全说明。
组件世界电脑版自带一个命令行工具 widgetstore。其它 AI Agent(Claude Code、Codex、Gemini CLI、Cursor…)和你的脚本都能用它操作组件世界:
- 云端能力(和我们的 MCP 服务器 是同一套工具):读我的空间、改组件、往「我的数据」加记录、加待办、记专注、AI 搭空间……网站新增的能力会自动出现在命令里。
- 这台电脑的能力:开始 / 结束专注计时、把组件钉到桌面、打开页面或启动器、发系统通知、读 AI 用量、让本机的 Agent 跑一个任务。
安装
打开电脑版 → 侧栏 Agents →「命令行」→ 安装命令行工具:
- macOS:放到
/usr/local/bin/widgetstore(会弹出系统密码框);取消的话放到~/.local/bin,并告诉你怎么加到 PATH。 - Windows:把安装目录加到你这个用户的 PATH(不需要管理员),新开的终端里就能用。
- Linux:.deb / .rpm 安装的本来就有
/usr/bin/widgetstore;AppImage 会链接到~/.local/bin/widgetstore。
装好后新开一个终端,运行 widgetstore status 看看。
登录
- 有电脑版的电脑(推荐):在「命令行」里点 连接账号,浏览器里确认要给的权限(可以去掉不想给的)。授权保存在系统钥匙串里(Linux 是只有你能读的文件),命令行进程拿不到令牌,由电脑版代为调用。在网站「设置 → API 与 AI 连接 → 已连接的 AI 应用」里随时可以断开。
- 没有电脑版的机器(服务器 / CI):在网站「设置 → API 与 AI 连接」新建一个个人令牌,设成环境变量
WIDGETSTORE_TOKEN=wsp_…;或者widgetstore login --token -(从输入读入,存进钥匙串)。
用法
widgetstore tools # 列出所有命令(云端 + 这台电脑)
widgetstore get_my_space --json # 机器可读的输出
widgetstore add_record --help # 某个命令的参数
widgetstore focus_start --minutes 25 --task "写周报"
widgetstore ask claude "根据最近的提交写发布说明" --cwd ~/code/app --wait
widgetstore mcp # 本机 MCP 服务器(stdio)
- 参数来自每个工具的 JSON Schema:
--名字 值、--开关/--no-开关、数组可以重复写,--args '{"…":…}'一次给全部;值写@文件或@-(从输入读)。 - 加
--json输出固定格式:成功{"ok":true,"tool":…,"data":…,"text":…},失败{"ok":false,"error":{"code","message","exit"}}。 - 退出码:0 成功 · 1 工具 / 服务端错误 · 2 用法错误 · 3 没有登录或权限不够 · 4 电脑版没在运行(本机命令)· 5 你在电脑版里拒绝了。
接到你的 Agent 里
一行把 widgetstore mcp 接成本机 MCP 服务器(同一套工具):
| Agent | 命令 / 配置 |
|---|---|
| Claude Code | claude mcp add widgetstore -- widgetstore mcp |
| Codex CLI | codex mcp add widgetstore -- widgetstore mcp |
| Gemini CLI | gemini mcp add widgetstore widgetstore mcp |
| Cursor | ~/.cursor/mcp.json:{"mcpServers":{"widgetstore":{"command":"widgetstore","args":["mcp"]}}} |
| opencode | opencode.json:{"mcp":{"widgetstore":{"type":"local","command":["widgetstore","mcp"]}}} |
也可以不用 MCP,直接在项目的 AGENTS.md / CLAUDE.md 里写一段(「命令行」页有现成的可以复制):
## WidgetStore
- The `widgetstore` CLI is installed. Run `widgetstore tools --json` to see every command and its JSON schema.
- Call a tool with `widgetstore <tool> --option value --json` (exit code 0 = ok).
- Local actions (opening pages, pinning widgets, agent tasks) need the user to confirm in the WidgetStore desktop app. Cloud writes are logged and can be undone with `widgetstore undo`.
安全
- 权限在服务端按令牌的范围执行;每一次修改都记在「操作日志」里,可以撤销(
widgetstore undo)。没有任何命令能删除数据、改账号或花钱;会花火花的工具在命令行里默认关闭(「命令行」→ 安全里可以打开)。 - 这台电脑上的命令走本机通道:只有你这个系统用户能连,还要带电脑版每次启动生成的随机口令。
- 打开页面 / 启动器、钉组件、让 Agent 跑任务都会在电脑版里弹出确认窗口,写清要做什么,你点「允许」才继续。可以在「命令行」→ 安全里信任「打开类」的请求和只读的 Agent 任务;会改文件或「全部自动批准」的任务永远要确认。
- 命令行进程看不到你的登录态和令牌;电脑版让 Agent 运行时也不会把它们传过去。
最后更新:2026年11月14日