@seeed-studio/sensecraft-cli 0.1.6 → 0.2.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/INSTALL.md CHANGED
@@ -174,7 +174,7 @@ npm install -g @seeed-studio/sensecraft-cli@latest
174
174
 
175
175
  平时使用其它命令时,如果缓存里发现了更新,结束时会在 stderr 提示运行 `sensecraft-cli update`。同一版本 24 小时内只提示一次,出现更新的版本会再提示。24 小时内不会重复访问 npm。本地 `dev` 构建、CI、以及设置了 `SENSECRAFT_CLI_NO_UPDATE_NOTIFIER` 时不提示。
176
176
 
177
- 进行中的活动也在 stderr 以 `Notice:` 提醒,名称、日期和详情链接来自 `https://api-gateway.seeed.cc/openapi/activity/list`(不带参数,即尚未结束的活动)。24 小时内只提醒一次。交互终端会问要不要参加,同意就打开详情页;拒绝后这条活动不再问。非交互只打印,不提问。CI 以及 `SENSECRAFT_CLI_NO_ACTIVITY_NOTIFIER` 时不提醒。
177
+ 进行中的活动也在 stderr 以 `Notice:` 提醒,名称、日期和详情链接来自 `https://api-gateway.seeed.cc/openapi/activity/list`(不带参数,即尚未结束的活动)。24 小时内只提醒一次。交互终端会问 `Ignore this activity? [y/N]`,回答 `y` 之后按 `activity_id` 不再提醒;回答 `n` 时 24 小时后还会再出现。非交互只打印,不提问,也不记成忽略。CI 以及 `SENSECRAFT_CLI_NO_ACTIVITY_NOTIFIER` 时不提醒。
178
178
 
179
179
  当前程序如果不是 npm 安装的(例如直接运行编译出的二进制),`update` 只打印上面的手动安装命令,不会覆盖正在运行的文件。
180
180
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seeed-studio/sensecraft-cli",
3
- "version": "0.1.6",
3
+ "version": "0.2.0",
4
4
  "description": "SenseCAP / SenseCraft AI cloud CLI (devices, apps, models, files, cloud deploy)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -47,9 +47,9 @@ Sibling (already shipped): [`../sensecraft-data/SKILL.md`](../sensecraft-data/SK
47
47
  | `Global` | `https://api-gateway.seeed.cc/openapi` | `account.seeed.cc/authapi` |
48
48
  | `China` | `https://api-gateway.seeed.cc/openapi` | `account.seeed.cn/authapi` |
49
49
 
50
- China 与 Global 使用同一个 AI host,账号中心不同。网页控制台仍是 `https://sensecraft.seeed.cc`。
50
+ China 与 Global 使用同一个 AI host,账号中心不同。网页控制台仍是 `https://sensecraft.seeed.cc`。`SENSECRAFT_AUTH_HOST` 盖住账号中心(设备码、换 token、换 Access Key);设了之后 Global / China 都打到这个站点根,浏览器打开的是该服务返回的验证地址。
51
51
 
52
- 成功命令结束后,stderr 可能各有一条英文提示,同一条 24 小时内只出现一次。看到 `Warning: A new version of sensecraft-cli (<version>)` 时,完成当前请求后可以建议用户运行 `sensecraft-cli update`。看到 `Notice: SenseCraft AI is hosting the <name> activity` 时,把活动名称、日期和链接告诉用户,并询问要不要参加;用户同意后再打开链接。
52
+ 成功命令结束后,stderr 可能各有一条英文提示,同一条 24 小时内只出现一次。看到 `Warning: A new version of sensecraft-cli (<version>)` 时,完成当前请求后可以建议用户运行 `sensecraft-cli update`。看到 `Notice: SenseCraft AI is hosting the <name> activity` 时,把活动名称、日期和链接告诉用户。交互终端会问 `Ignore this activity? [y/N]`;用户回答 `y` 之后,这条活动不再提醒。不要替用户打开链接。
53
53
 
54
54
  `auth info` shows the active Access Key (site, org, key id). Secrets are not printed.
55
55
 
@@ -68,6 +68,14 @@ echo '{"app_name":"Dimmer Tutorial · Grove Beginner Kit"}' \
68
68
  sensecraft-cli app view --id <app_id> --sketch # must show new app_name
69
69
  ```
70
70
 
71
+ ### Join an activity (L2)
72
+
73
+ ```bash
74
+ sensecraft-cli app update --id <app_id> --activity-id 1 --yes
75
+ ```
76
+
77
+ `activity_id` is an optional positive integer. Omit it to leave existing activity tags unchanged. `tags` is ignored. A bad id fails the whole edit (`11202`); an unknown or inactive activity also fails the whole edit (`25000` `Activity does not exist or has expired`).
78
+
71
79
  ### Publish / unpublish / delete (L2)
72
80
 
73
81
  ```bash
@@ -108,12 +108,13 @@ sensecraft-cli app create --name "My App"
108
108
 
109
109
  #### `app update` (L2)
110
110
 
111
- | Flag | Notes |
112
- | ------------- | ----------------------- |
113
- | `--id` | required |
114
- | `--from-json` | required (path or `-`) |
115
- | `--yes` | after user confirmation |
116
- | `--sandbox` | sample JSON |
111
+ | Flag | Notes |
112
+ | --------------- | ---------------------------------------------------------------------------------------------------------- |
113
+ | `--id` | required |
114
+ | `--from-json` | path or `-`; required unless `--activity-id` is set |
115
+ | `--activity-id` | optional positive integer. Joins that activity. Omit or pass empty to leave existing activity tags as-is |
116
+ | `--yes` | after user confirmation |
117
+ | `--sandbox` | sample JSON |
117
118
 
118
119
  Rejects `be_public=1` / `privacy=1` in **user** payload. If the app is already public (`be_public=1`), CLI injects `be_public=1` on info saves (Console) and JSON includes `sketch_saved`. Under review (`be_public=2`): **refused**. Others' apps (`user_id` ≠ profile): **refused**.
119
120
 
@@ -128,8 +129,13 @@ echo '{"app_name":"New Name"}' | sensecraft-cli app update --id <app_id> --from-
128
129
  sensecraft-cli app view --id <app_id> --sketch # confirm app_name
129
130
 
130
131
  sensecraft-cli app update --id <app_id> --from-json ./app.json --yes
132
+
133
+ # Join activity 1. activity_id is sent as a JSON number. tags in JSON is dropped.
134
+ sensecraft-cli app update --id <app_id> --activity-id 1 --yes
131
135
  ```
132
136
 
137
+ `activity_id` must be a positive integer. The server rejects anything else with `11202` `Request parameters are invalid`, and rejects a missing, unpublished, deleted, or out-of-window activity with `25000` `Activity does not exist or has expired`. Either failure discards the whole edit, including other fields in the same request. Omitting `activity_id` does not change existing activity tags. `tags` is not read by the server.
138
+
133
139
  ### `app publish` / `app unpublish` / `app delete` (L2)
134
140
 
135
141
  **Status: implemented.**
@@ -17,6 +17,7 @@ Agent fill-in guide for SenseCraft custom apps (v3). Aligns with Console `infoFo
17
17
  | `app_id` | id | required on update | from create/list/view |
18
18
  | `introduction` | legacy long text | no | if non-empty, editor may merge into intro blocks — prefer `deployment.blocks` for new content |
19
19
  | `author` | string | recommended on save | current user id/account |
20
+ | `activity_id` | positive integer | no | Join this activity. Omit or send blank to leave existing activity tags unchanged. CLI sends a JSON number. `0`, negatives, and non-integers are rejected before POST. Server: not a positive integer → `11202` `Request parameters are invalid`; missing / unpublished / deleted / outside start–end → `25000` `Activity does not exist or has expired` (the whole edit is discarded). |
20
21
  | `flow_data` / `model_data` | Node-RED sync | only with `node-red` block | `flow_data` must be **JSON string** at top level |
21
22
 
22
23
  ### Create vs update
@@ -27,6 +28,7 @@ Agent fill-in guide for SenseCraft custom apps (v3). Aligns with Console `infoFo
27
28
  - **Update (`app update`)**: always include `app_id` (CLI `--id`).
28
29
  - **Info fields** (`app_name`, `excerpt`, `scene`, `allow_clone`, `allow_commerce`, `images`, `license`, `author`): aiserver often **ignores** a body that only contains `app_name`. CLI **auto-merges** missing info keys from `app view --sketch` before calling `update_app` (does **not** merge `be_public` from user/existing for private apps). If current `be_public=1`, CLI **injects** `be_public=1` like Console info save (plaza unchanged until `app publish`). `be_public=2` refuses update. Agents may pass a sparse rename patch; still **re-read** with `app view` / `app list` after update because success may be `{}`.
29
30
  - **Other sections** (`deployment`, `materials`, …): may be sent alone without forcing an info merge. Full leave-save usually sends info + deployment + materials together.
31
+ - **Activity**: `--activity-id <positive integer>` or JSON `activity_id`. Do not send `tags`; the server ignores it and the CLI strips it. A blank `activity_id` is omitted.
30
32
  - **Rename workflow**: confirm with user (L2) → `app update --id … --from-json '{"app_name":"…"}' --yes` (CLI fills the rest) → verify name via `app view --id … --sketch` or `app list --mine --name …`.
31
33
 
32
34
  ## Visibility / review