@seeed-studio/solution-cli 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,151 +1,196 @@
1
1
  # @seeed-studio/solution-cli
2
2
 
3
- Zero-friction installer, CLI suite, and AI Agent Skill for **SenseCraft Edge IoT Solutions & Hardware Ecosystem** (reComputer Jetson, reCamera, SenseCAP, Grove Vision AI, ESP32).
3
+ Install the signed Rust deployment engine and the `solution-cli` AI Agent Skill for Seeed edge IoT solutions and hardware.
4
4
 
5
- Compatible with **Claude Code, Codex, Google Antigravity (AGY), Work Buddy, and CodeBuddy**.
5
+ ## 1. Quick Start: Install to Your Agent (快速安装与宿主配置)
6
6
 
7
- > 📖 **专属完整使用指南**:如果您需要系统了解本 CLI 的独特使用场景、详细命令参数、多 Agent 宿主集成以及各阶段具体产出物,请直接查阅独立手册:[**SenseCraft Solution CLI 使用与集成全景指南 (docs/cli-guide.md)**](docs/cli-guide.md)。
7
+ **按需安装到当前使用的 AI Agent**(避免全量污染)。直接复制对应命令发给你的 AI 助手,或在终端执行:
8
8
 
9
- ---
9
+ | 目标 AI 宿主 | 专属一键安装命令(直接复制发给 AI 或在终端运行) | 技能挂载路径 |
10
+ |---|---|---|
11
+ | **豆包工作 (Doubao Work)** | `npx -y @seeed-studio/solution-cli install --agent doubao` | `~/.doubao/skills` |
12
+ | **WorkBuddy** | `npx -y @seeed-studio/solution-cli install --agent workbuddy` | `~/.workbuddy/skills` |
13
+ | **Claude Code** | `npx -y @seeed-studio/solution-cli install --agent claude` | `~/.claude/skills` |
14
+ | **OpenAI Codex** | `npx -y @seeed-studio/solution-cli install --agent codex` | `~/.agents/skills` 或 `~/.codex/skills` |
15
+ | **Google Antigravity** | `npx -y @seeed-studio/solution-cli install --agent antigravity` | `~/.gemini/config/skills` |
16
+ | **CodeBuddy** | `npx -y @seeed-studio/solution-cli install --agent codebuddy` | `~/.codebuddy/skills` |
17
+ | **全部 Agent (全量检测)** | `npx -y @seeed-studio/solution-cli install --agent all` | 上述全部已检测目录 |
18
+ | **自定义路径 (如 Cursor)** | `npx -y @seeed-studio/solution-cli install --skills-dir <路径>` | `<自定义路径>/solution-cli` |
10
19
 
11
- ## 1. Quick Start & Agent Installation
20
+ > [!TIP]
21
+ > - **发给 AI 助手**:直接复制上表中对应的专属命令发给你的 AI(例如对豆包说:*“请帮我运行:`npx -y @seeed-studio/solution-cli install --agent doubao`”*),AI 即可在后台全自动执行完成。
22
+ > - **精准隔离**:指定 `--agent <id>` 时,安装器仅写入该 Agent 对应的目录,绝不修改或触碰其他 Agent 环境。
23
+ > - **国内镜像延迟排查**:若遇 npm 同步延迟,可在命令末尾加上 `--registry=https://registry.npmjs.org/`。
12
24
 
13
- Install the underlying engine and configure the AI Agent Skill with one command:
25
+ ### 开发者本地源码部署
26
+
27
+ 在克隆的代码仓库根目录下,直接使用本地源码将 Skill 挂载到指定 Agent,无需发布或下载 npm 包:
14
28
 
15
29
  ```bash
16
- npx -y @seeed-studio/solution-cli@latest install --agent workbuddy -y
30
+ node bin/cli.js install --agent <doubao|claude|codex|antigravity|codebuddy>
17
31
  ```
18
32
 
19
- This example targets WorkBuddy explicitly. Replace `workbuddy` with the current
20
- Agent ID for another host. Use `npx -y @seeed-studio/solution-cli@latest install`
21
- for the interactive form: when one or more Agents are detected, pressing Enter
22
- selects all detected Agents, while entering the corresponding number selects one
23
- host. In non-interactive mode, `install -y` without `--agent` also selects all
24
- detected Agents when any are detected. If none are detected, these defaults still
25
- use the CLI's default target set; pass `--agent <agent-id>` to control the scope
26
- explicitly.
27
-
28
- The same command is safe to repeat. It checks the signed stable Engine release,
29
- reuses an equal or newer local Engine, and upgrades an older one. Existing
30
- modified or unregistered skills and protected symlinks are preserved. Use
31
- `--agent claude,antigravity` to select agents, or `--engine-path <path>` to pin
32
- a valid Engine binary. `--force` re-downloads an equal or older Engine and
33
- overwrites existing skill files, including user modifications; use it only when
34
- that overwrite is intended. Protected external symlinks are not followed, and
35
- it never downgrades a newer discovered Engine.
36
-
37
- Automatic reuse/upgrade rules start with publicly published solution-cli 0.3.1.
38
- A latest release or signature failure stops before changing the
39
- Engine or skills; an offline host must use a valid explicit local Engine path.
40
-
41
- The interactive form remains available when prompts are wanted:
33
+ ### 免安装即时查询
34
+
35
+ 无需安装任何依赖,可直接使用 `npx` 随用随走:
42
36
 
43
37
  ```bash
44
- npx -y @seeed-studio/solution-cli@latest install
38
+ npx -y @seeed-studio/solution-cli hub search "农业"
39
+ npx -y @seeed-studio/solution-cli product query recomputer_j40 --json
45
40
  ```
46
41
 
47
- ### Supported AI Agent Harnesses
48
- - **Claude Code**: `~/.claude/skills/solution-cli`
49
- - **Codex / OpenAI**: `~/.agents/skills/solution-cli` or `~/.codex/skills/solution-cli`
50
- - **Google Antigravity (AGY)**: `~/.gemini/config/skills/solution-cli`
51
- - **Work Buddy / Workbody**: `~/.workbuddy/skills/solution-cli`
52
- - **CodeBuddy**: `~/.codebuddy/skills/solution-cli`
42
+ ## 2. How to Deploy a Solution (方案部署指南)
43
+
44
+ 方案部署支持**本地部署(Local Docker,最简且无需 SSH 密钥)**与**远程部署(Remote SSH 密钥认证)**。
45
+
46
+ ### 部署 4 步走流程 (SOP)
47
+
48
+ 1. **查找方案**:
49
+ ```bash
50
+ solution-cli hub search "农业" --json
51
+ ```
52
+ 2. **读取方案部署规格与预设**:
53
+ ```bash
54
+ sensecraft-engine deploy-info <solution-id> --lang zh
55
+ ```
56
+ 3. **准备部署参数文件** `./.sensecraft-work/body.json`:
57
+ - **本地部署(推荐快速体验,Localhost Docker)**:
58
+ ```json
59
+ {
60
+ "solution_id": "<solution-id>",
61
+ "preset_id": "default",
62
+ "selected_devices": ["host_device"],
63
+ "device_connections": {
64
+ "host_device": {
65
+ "target": "local_host",
66
+ "target_type": "local"
67
+ }
68
+ }
69
+ }
70
+ ```
71
+ - **远程边缘设备部署(SSH 密钥认证)**:
72
+ ```json
73
+ {
74
+ "solution_id": "<solution-id>",
75
+ "preset_id": "default",
76
+ "selected_devices": ["host_device"],
77
+ "device_connections": {
78
+ "host_device": {
79
+ "target": "remote_edge",
80
+ "target_type": "remote",
81
+ "host": "192.168.1.50",
82
+ "username": "seeed",
83
+ "key_file": "~/.ssh/id_ed25519"
84
+ }
85
+ }
86
+ }
87
+ ```
88
+ 4. **一键执行部署并查看状态**:
89
+ ```bash
90
+ # 验证与执行部署
91
+ sensecraft-engine deploy --params ./.sensecraft-work/body.json --yes
92
+
93
+ # 查询部署进度与容器日志
94
+ sensecraft-engine status <deployment-id> --json
95
+ sensecraft-engine logs <deployment-id>
96
+ ```
97
+
98
+ ## 3. CLI Command Reference
99
+
100
+ | Command | Purpose |
101
+ |---|---|
102
+ | `solution-cli install --agent <agent-id> -y` | Install or update the signed Engine and Skill |
103
+ | `solution-cli hub search "<query>" --json` | Find solution scenarios and reference designs |
104
+ | `solution-cli product query <family-id> --json` | Read hardware family specifications |
105
+ | `solution-cli product accessories <family-id> --json` | Check required and compatible accessories |
106
+ | `solution-cli status` | Show Engine, content, and Skill state |
107
+ | `solution-cli doctor --json` | Check OS, permissions, Docker, PATH, and ledger |
108
+ | `sensecraft-engine solution list --json` | List locally available deployable solutions |
109
+ | `sensecraft-engine deploy-info <id> --lang en` | Read presets, devices, targets, and required values |
110
+ | `sensecraft-engine deploy --params ./.sensecraft-work/body.json --yes --detach --lang en` | Start an approved deployment |
111
+ | `sensecraft-engine status <deployment-id> --json` | Poll a detached deployment |
112
+ | `sensecraft-engine logs <deployment-id> --since <N>` | Read deployment events |
53
113
 
54
- ---
114
+ The Engine binary remains named `sensecraft-engine` for compatibility; the user-facing package and Skill are `solution-cli`. See [the deployment reference](skills/solution-cli/references/deploy.md) before applying changes to a device.
55
115
 
56
- ## 2. CLI Command Reference
116
+ ### Catalog relationships and links
57
117
 
58
- The `solution-cli` provides unified commands for discovery, BOM calculation, device diagnostics, and engine execution:
118
+ The catalog separates four things that should not be treated as synonyms:
59
119
 
60
- | Command | Description |
61
- |---|---|
62
- | `solution-cli hub search "<query>" [--json] [--limit N]` | Search scenarios & reference designs. Connects to live Typesense cloud or seamlessly falls back to bundled catalog. Returns diagnostic playbooks & UTM landing URLs. |
63
- | `solution-cli product query <family_id> [--json]` | Query hardware family default SKUs, region variants, and physical specs. |
64
- | `solution-cli product accessories <family_id> [--sku <sku>] [--json]` | Evaluate required vs. optional accessories with strict physical compatibility checks (power, RF antenna, M.2 slots). |
65
- | `solution-cli install [--agent <agents>] [-y]` | Inspect host environment, download/verify engine, and install Agent skills. |
66
- | `solution-cli status` | Inspect installed engine binary, content cache, and configured agent skills. |
67
- | `solution-cli doctor` | Run pre-flight diagnostics (OS, Docker daemon, serial permissions, PATH, ledger). |
68
- | `solution-cli uninstall [--agent <agents>]` | Cleanly remove Solution CLI skills using the installation ledger. |
69
- | `sensecraft-engine <subcommand>` | Direct proxy to the underlying high-performance Rust execution engine. |
120
+ - **Scenario** is the business landing page and points to related Tech pages and Reference Designs.
121
+ - **Tech** is an independently owned technology page. It is not the Wiki for an RD.
122
+ - **Reference Design (RD)** is the concrete architecture and product design. It may have a deployment document and presets.
123
+ - **Deployable content** is the RD's mapped deployment document. A landing page or RD without a valid mapping is informational and cannot be assumed deployable.
124
+
125
+ Use the compact catalog flow instead of reading manifests or writing a parser:
70
126
 
71
- ---
127
+ ```bash
128
+ solution-cli hub list --type reference_design --locale en --page 1 --limit 50 --json
129
+ solution-cli hub get <id> --locale en --section overview --json
130
+ solution-cli hub get <id> --locale en --section links --json
131
+ solution-cli hub get <id> --locale en --section architecture --json
132
+ solution-cli hub get <id> --locale en --section products --json
133
+ solution-cli hub get <id> --locale en --section deployment --json
134
+ ```
72
135
 
73
- ## 3. How the AI Agent Uses the Skill
136
+ Follow `next_page` for a complete bundled snapshot. Use `search` for a
137
+ specific request, then `get` for the selected records and only the sections
138
+ needed to answer it. The three production landing hosts are locale-specific:
139
+ English `www.seeed.cc`, Chinese `www.seeedstudio.com.cn`, and Japanese
140
+ `www.seeed.co.jp`. Use the URLs returned by `hub get --section links`; do not
141
+ construct Wiki, CDN, or translated URLs from an ID. A translated body may
142
+ fall back to another content language while its production page remains
143
+ published, so report the returned content language separately.
74
144
 
75
- Once installed, your AI Agent gains deep domain knowledge as an Edge IoT Solution Architect. The skill operates across a **4-tier progressive disclosure lifecycle**:
145
+ For deployment, confirm the RD mapping with the local Engine:
76
146
 
147
+ ```bash
148
+ sensecraft-engine deploy-info <solution-id> --lang en
77
149
  ```
78
- [ Tier 1: 方案咨询与工况诊断 ]
79
- Agent 讲透方案业务价值与边缘推理机制 ➔ 依据领域诊断知识库提出 2~3 个关键工况问题 ➔ 给出带静默 UTM 的落地页与源码出口
80
- │
81
- ▼
82
- [ Tier 2: 硬件选型与配件 BOM 校验 ]
83
- 运行配件评估引擎 ➔ 严格区分【必需配件】(电源适配器) 与【可选配件】(安装支架/天线) ➔ 规避物理插头/电压/引脚不兼容
84
- │
85
- ▼
86
- [ Tier 3: 设备管理与在线参数修改 ]
87
- 查询活跃部署 ➔ 读取 reconfigurable: true 字段 ➔ 零重装无损热更新 (如在线修改 MQTT Broker 地址或检测阈值)
88
- │
89
- ▼
90
- [ Tier 4: 本地二次开发与自研模型 ]
91
- 获取官方 GitHub 仓库 ➔ 引导本地代码克隆与模型转换 (trtexec / TensorRT) ➔ 通过 --solutions-dir 驱动本地开发联调闭环
92
- ```
150
+
151
+ The Hub record describes the published design; `deploy-info` confirms the
152
+ actual local deployment document and presets.
153
+
154
+ Links and metadata only locate content. To answer a capability, architecture,
155
+ or product question, read the selected `description`, `architecture`, or
156
+ `products` section. Open the exact returned production page or image when it
157
+ matters to the answer. Treat a relative asset path as readable only when its
158
+ signed local content is present; otherwise report the source asset as
159
+ unavailable.
160
+
161
+ ## 4. How the AI Agent Uses the Skill
162
+
163
+ The Skill maps ordinary language to four stages:
164
+
165
+ 1. **Consultation**: search the catalog and clarify the customer's scenario.
166
+ 2. **Hardware selection**: check device families, accessories, and physical compatibility.
167
+ 3. **Precheck and deployment**: read `deploy-info`, fill required values, run validation, show side effects, then ask before applying.
168
+ 4. **Verification and troubleshooting**: follow deployment status and logs, verify services, and diagnose failures.
169
+
170
+ For deployment, the Agent must use the installed Engine's absolute path when it is injected into the Skill. For catalog or product queries, use `solution-cli`; if it is not on `PATH`, use `npx @seeed-studio/solution-cli <command>`. Windows native local Docker is unsupported; use a Linux Docker host over SSH. macOS local Docker requires a running Docker Desktop daemon. The CLI does not install Docker Desktop or silently grant `sudo`.
93
171
 
94
172
  ### 常见自然语言对话范例
95
173
 
96
174
  #### 范例 1:方案咨询与工况诊断 (Discovery & Diagnosis)
97
- > **用户**:“我们打算在养老社区做老人跌倒检测,有什么成熟方案推荐吗?”
98
- >
99
- > **Agent**:
100
- > 1. 调用 `solution-cli hub search "养老" --json`;
101
- > 2. 详细解释 `fall_detection` 方案的端侧姿态估计与逐人时序状态机机制(1.4s 本地低延迟、视频不出本地保护隐私);
102
- > 3. 自然给出官方方案落地页与 GitHub 源码地址(携带静默 UTM 跟踪);
103
- > 4. **主动发起工况诊断黄金三问**:
104
- > - 房间是同一栋楼集中分布(推荐 1 台 Orin 主机拉多路 RTSP 流摊薄成本)还是分散独栋(推荐每间房独立一体机)?
105
- > - 现场是否已有支持 RTSP 协议的海康/大华存量摄像头(直接利旧节省采购成本)?
106
- > - 卫生间/卧房私密空间是否对纯光学摄像头有顾虑(可选用 60GHz 毫米波雷达替代)?
107
-
108
- #### 范例 2:硬件选型与配件兼容性校验 (BOM & Compatibility)
109
- > **用户**:“选好了,我要买一台 reComputer J4012,帮我看看需要配哪些配件?”
110
- >
111
- > **Agent**:
112
- > 1. 调用 `solution-cli product accessories recomputer_j40 --json`;
113
- > 2. 明确区分:
114
- > - **必需配件**:19V 4.74A DC Jack (5.5x2.5mm) 电源适配器(严禁配 12V 否则无法开机);
115
- > - **可选配件**:NVMe M.2 2280 SSD(Key-M)、双频 Wi-Fi/BT 模组(Key-E 插槽)与匹配的 SMA 天线;
116
- > 3. 提供官方 SKU 与带 UTM 标记的购买链接,杜绝编造第三方型号。
175
+
176
+ 用户可以直接描述客户需求。Agent 先搜索方案,解释匹配原因,再询问供电、设备、网络和部署位置等缺失信息;没有明确部署确认时不执行部署。
177
+
178
+ #### 范例 2:硬件配置与配件推荐(查配置、推荐配件、防止买错)
179
+
180
+ 用户询问某个设备(如 reComputer、Watcher)的参数,或询问“买这台主机还需要配什么配件”。Agent 使用 `product query` 和 `product accessories` 查出真实硬件规格,区分必须买的配件(如电源线)和可选配件(如天线/外壳/摄像头),并自动校验接口与频段兼容性,直接给出官方配件清单。
117
181
 
118
182
  #### 范例 3:在线参数热修改 (Device Management)
119
- > **用户**:“我已经部署完设备了,现在想把告警的 MQTT 服务器地址改成本地的 192.168.1.50,怎么弄?”
120
- >
121
- > **Agent**:
122
- > 1. 查询当前应用的可配置参数;
123
- > 2. 确认 `mqtt_broker` 属于 `reconfigurable: true` 字段;
124
- > 3. 直接通过管理接口发起更新,提示用户无需重启容器或重装整个系统,参数热生效。
125
183
 
126
- #### 范例 4:二次开发与自研模型替换 (Secondary Dev)
127
- > **用户**:“我想改一下后处理检测逻辑,换成我们自己的 YOLOv11 跌倒模型,源码在哪里?”
128
- >
129
- > **Agent**:
130
- > 1. 提供方案对应的官方 GitHub 开源仓库地址;
131
- > 2. 指导用户克隆到本地工作区;
132
- > 3. 指导通过 TensorRT `trtexec` 完成端侧引擎转换,并在 `docker-compose.override.yml` 中挂载自定义模型;
133
- > 4. 使用 `sensecraft-engine deploy <id> --solutions-dir ./solutions` 进行本地快速调测。
184
+ 用户可以描述要修改的已部署参数。Agent 先读取当前部署和可修改字段,确认目标设备与变更范围,再按设备管理接口执行获得批准的修改。
134
185
 
135
- ---
186
+ #### 范例 4:二次开发与自研模型替换 (Secondary Dev)
136
187
 
137
- ## 4. 技术架构亮点
188
+ 用户可以要求源码、模型替换或本地方案调试。Agent 应读取对应方案的开发文档和 `--solutions-dir` 规则,并在部署前展示改动。
138
189
 
139
- 1. **双轨检索与开箱即用 (Out-of-the-Box)**:
140
- - 内置 323 KB 离线核心清单(18 场景、39 参考设计、119 硬件族),无网断网 100% 可用;
141
- - 线上发布版内置只读搜索凭据,联网时自动直连 Typesense 云端集群获取实时更新。
142
- 2. **静默商业闭环 (Silent Attribution)**:
143
- - 所有落地页、Wiki、商城 SKU 与配件链接均经安全工具注入 `utm_source=sensecraft_agent`,对话自然融入,杜绝生硬广告。
144
- 3. **物理规格防呆保护**:
145
- - 内置电源接口(DC 5.5x2.5 vs 5.5x2.1)、极性(中心正极)、电压(19V vs 12V)、M.2 Key-M/Key-E 及 RF 射频天线接头校验,从源头杜绝硬件烧板与返工风险。
190
+ ## 5. 技术架构亮点
146
191
 
147
- ---
192
+ `solution-cli` 是 npm 安装入口,签名 Rust Engine 负责跨平台查询、预检查、部署状态和日志;方案内容按版本校验后进入本地缓存。在线目录查询失败时,Skill 和 CLI 可使用已安装的本地内容与知识库完成支持的离线查询。
148
193
 
149
- ## 5. 开源协议
194
+ ## 6. 开源协议
150
195
 
151
196
  Apache-2.0 © Seeed Studio