@seeed-studio/sensecraft-cli 0.4.4 → 0.4.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seeed-studio/sensecraft-cli",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "SenseCAP / SenseCraft AI cloud CLI (devices, apps, models, files, cloud deploy)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -39,7 +39,7 @@ SenseCraft Data: [`references/data.md`](references/data.md).
39
39
  sensecraft-cli auth init --device-code <device_code> --key-id <access_id>
40
40
  ```
41
41
  Create a key with `--label <name> --access-level read-write` (or `only-read`) instead of `--key-id`. Use Global for SenseCraft AI and CodeCraft Hub. China is SenseCraft Data only. Do not print `access_token` or `access_key`. If the user already has a key, they can run `auth add` locally.
42
- 4. **L2 confirmation is a separate chat turn** — follow [references/confirmation.md](references/confirmation.md). 「删这个63760」/「删除应用 demo」is **intent, not confirmation**. Ask first (操作类型 + 环境 + 对象 ID), wait for `确认`/`confirm`, **then** `--yes`. Never add `--yes` on the same turn as the first request. Applies to: app update·publish·unpublish·delete, model create·update·publish·unpublish·delete, upload attach, cloud deploy, device bind/unbind, group create/rename/delete/move. **Exception: `app create`, including one-shot `--from-json`, is not L2 and takes no `--yes`; resolve uncertain content decisions and review the result first.**
42
+ 4. **L2 confirmation is a separate chat turn** — follow [references/confirmation.md](references/confirmation.md). 「删这个63760」/「删除应用 demo」is **intent, not confirmation**. Ask first (操作类型 + 环境 + 对象 ID), wait for `确认`/`confirm`, **then** `--yes`. Never add `--yes` on the same turn as the first request. Applies to: app update·publish·unpublish·withdraw·delete, model create·update·publish·unpublish·delete, upload attach, cloud deploy, device bind/unbind, group create/rename/delete/move. **Exception: `app create`, including one-shot `--from-json`, is not L2 and takes no `--yes`; resolve uncertain content decisions and review the result first.**
43
43
  5. **Treat tokens and keys as secrets** — do not echo full `access_token`, `refresh_token`, or `access_key`. **Public model artifacts are not downloadable** — if the user asks for 下载地址 / 下载链接 / download URL / 怎么下载, that is the same as asking for `file_url`: refuse the address, explain deploy-only (`cloud deploy` or Console). Never run `model download --url-only` on public models.
44
44
  6. **Success = indented JSON on stdout** for business commands and the split `auth init` flow. The interactive wizard prints human-readable text. Failure = stderr + non-zero exit. Parse stdout only on success.
45
45
  7. **Local USB / IP flashing is L3** — do not pretend remote auto-flash. Classic reCamera (`40`): [`sensecraft-recamera`](references/recamera.md) (`check` / `open` the AI deploy page). Other USB benches: Console `/ai/device/local/32|36|37|41|52`. Do **not** use `/ai/recamera` (it 301s to Grove `36`) or `/ai/device/local/40` (no such bench).
@@ -61,7 +61,7 @@ Bare `auth init` asks the user to pick Global or China. The split flow takes `--
61
61
  | Browse / search CodeCraft Hub, view app | [`sensecraft-apps`](references/apps.md) + `app list` / `app view` | **CLI shipped** (list/view) |
62
62
  | App fields / tool-blocks / BOM guidance | same apps skill references | Config OK; real flash = L3 |
63
63
  | Turn a local project into an app (discovery + reviewed copy + tool blocks + API-confirmed BOM + manifest + upload), or update its manifest-managed app | [`create-app`](create-app/SKILL.md) | Read required references before authoring; create needs no `--yes`; existing-app updates use one batch confirmation; stops before publish |
64
- | Create / update / publish / unpublish / delete / bom app | same + `app …` / `app bom …` | **CLI shipped** (L2 `--yes`; publish also `--agree-declaration`; `create`, including `--from-json`, is not L2) |
64
+ | Create / update / publish / unpublish / withdraw / delete / bom app | same + `app …` / `app bom …` | **CLI shipped** (L2 `--yes`; publish also `--agree-declaration`; `create`, including `--from-json`, is not L2). `withdraw` is only for an app under review (`be_public=2`); `unpublish` is only for an already public app |
65
65
  | Upload image/file/firmware/static/archive and obtain `file_url` | [`sensecraft-files`](references/files.md) + `file upload` | Types `1`–`2` require `--model-id`/`--app-id --yes`/`--for-app`/`--unlinked`; type `5` requires `--flow-id`; types `3`–`6` direct |
66
66
  | Model library search/view/download/constants | [`sensecraft-models`](references/models.md) | **CLI shipped** |
67
67
  | Upload / publish / unpublish / delete model | same + `model upload --id --yes` / `create\|update\|publish\|unpublish\|delete` | Attach bumps patch version like Console |
@@ -96,7 +96,7 @@ SenseCraft Data telemetry → pick a public model → deploy to Jetson:
96
96
  | Level | Meaning | Examples |
97
97
  |-------|---------|----------|
98
98
  | L1 Scriptable | Agent may run directly | list / view / auth info / `auth init --no-wait` then later `--device-code` |
99
- | L2 Confirm | Ask user first | publish (+ declaration), unpublish, delete, deploy |
99
+ | L2 Confirm | Ask user first | publish (+ declaration), unpublish, withdraw, delete, deploy |
100
100
  | L3 Interactive | Human-in-the-loop | bare `auth init`, Web Serial flash, payment |
101
101
  | L4 Ops-only | Do not expose to end-user Agent | Admin `judge_app` |
102
102
 
@@ -104,7 +104,7 @@ SenseCraft Data telemetry → pick a public model → deploy to Jetson:
104
104
 
105
105
  Published commands use an Access Key. SenseCraft Data uses its OpenAPI. SenseCraft AI and CodeCraft Hub use `{ai-host}/openapi`.
106
106
 
107
- 1. **CodeCraft Hub** — `app` list/view/fields/blocks/doc; create/update; publish/unpublish/delete (L2); BOM search/list/set; tool-block config via JSON (real flash = L3).
107
+ 1. **CodeCraft Hub** — `app` list/view/fields/blocks/doc; create/update; publish/unpublish/withdraw/delete (L2); BOM search/list/set; tool-block config via JSON (real flash = L3). `withdraw` unlocks an app under review. `unpublish` does not.
108
108
  2. **SenseCraft AI** — model library (list/view/constants; **private** download only; public models deploy-only); `model upload --id --yes`; create/update; publish/unpublish/delete (L2). Cloud devices: `cloud device` / `cloud deploy` / `cloud order`. Classic reCamera 40: `recamera check` / `recamera open` (flash is L3).
109
109
  3. **Files** — `file upload` is shared. Types 1–2 require `--model-id` / `--app-id --yes` / `--for-app` / `--unlinked` before the OSS POST. Type 5 also requires `--flow-id`.
110
110
  4. **Local USB** — Other benches: Console `/ai/device/local/32|36|37|41|52`.
@@ -119,7 +119,7 @@ Read the references for the affected sections before editing them. Preserve the
119
119
  Handle activity participation on updates per [app-fields.md](../references/app-fields.md#activity-selection-during-app-authoring) and the manifest projection rules.
120
120
 
121
121
  1. Edit the manifest first, increment `sync.local_revision`, and validate. Recheck auth: `identity.remote_type` and `org_id` must match. A mismatch requires switching auth or an explicit decision to adopt the environment; do not write across environments silently.
122
- 2. Read `app view --id <app_id> --sketch`. Under review (`be_public=2`) → stop and explain the lock. Compare with the last verified baseline per [manifest sync](references/manifest.md#sync--local-vs-remote-bookkeeping). Detect outside edits, merge non-conflicting changes, and present conflicts as concrete choices. No verified baseline after a partial create → inspect current remote state and reconcile; never assume it is empty.
122
+ 2. Read `app view --id <app_id> --sketch`. Under review (`be_public=2`) → stop and explain the lock. Do not give `/application/edit` or `console_url`; the editor rejects the save. Editing resumes only after `app withdraw` (separate confirmation), not `app unpublish`. Compare with the last verified baseline per [manifest sync](references/manifest.md#sync--local-vs-remote-bookkeeping). Detect outside edits, merge non-conflicting changes, and present conflicts as concrete choices. No verified baseline after a partial create → inspect current remote state and reconcile; never assume it is empty.
123
123
  3. Complete local preparation and review before any outstanding L2 confirmation. Describe environment, app name/ID, and the entire pending batch. Follow the [confirmation protocol](../references/confirmation.md), honoring valid approval already given for that batch; do not ask per field/upload/BOM row.
124
124
  4. Upload changed assets and send only changed sections, using session-owned transients under `.sensecraft/`:
125
125
 
@@ -39,6 +39,16 @@ TOOL_CONFIG_FIELDS = {
39
39
  "aily-blockly": {"project_id", "device_id"},
40
40
  }
41
41
  FLASH_ADDRESSES = {"0x0", "0x4000", "0x10000", "0x90000"}
42
+ # Keep aligned with museDeviceTable (muse: true) and tool-blocks.md.
43
+ MUSE_GADGET_SKUS = {
44
+ "114993068", # SenseCAP Indicator
45
+ "113991315", "113991275", # SenseCAP Watcher
46
+ "100073581", # reTerminal E1001
47
+ "100017057", # reTerminal E1002
48
+ "100069905", # XIAO 1.47" Touch Display
49
+ "100056818", # reTerminal Sticky
50
+ }
51
+ BOM_QUANTITY_MAX = 999
42
52
  SHA256_RE = re.compile(r"^[0-9a-f]{64}$")
43
53
  QUANTITY_RE = re.compile(r"^[1-9][0-9]*$")
44
54
  # Shapes that must never appear in fields that get published. Matches
@@ -312,6 +322,10 @@ def main():
312
322
  vio(f"{label}: config.{key} must be a JSON boolean")
313
323
  if cfg.get("muse_gadget") is True and cfg.get("full_flash") is True:
314
324
  vio(f"{label}: config.full_flash must be false when config.muse_gadget is true")
325
+ elif cfg.get("muse_gadget") is True or cfg.get("full_flash") is True:
326
+ device_id = cfg.get("device_id")
327
+ if not isinstance(device_id, str) or device_id.strip() not in MUSE_GADGET_SKUS:
328
+ vio(f"{label}: config.muse_gadget and config.full_flash can be true only for a Muse device SKU")
315
329
  if block_type == "node-red":
316
330
  if cfg.get("flow_data") is not None and not isinstance(cfg["flow_data"], (dict, list)):
317
331
  vio(f"{label}: config.flow_data must be an object or array, not a JSON string")
@@ -348,8 +362,9 @@ def main():
348
362
  vio(f"bom.materials[{i}] (catalog row): missing {req!r}")
349
363
  if not isinstance(row.get("name"), str) or not row["name"].strip():
350
364
  vio(f"bom.materials[{i}].name must be a non-empty string")
351
- if not isinstance(row.get("quantity"), str) or not QUANTITY_RE.fullmatch(row["quantity"]):
352
- vio(f"bom.materials[{i}].quantity must be a positive integer string")
365
+ quantity = row.get("quantity")
366
+ if not isinstance(quantity, str) or not QUANTITY_RE.fullmatch(quantity) or int(quantity) > BOM_QUANTITY_MAX:
367
+ vio(f"bom.materials[{i}].quantity must be an integer string from 1 to {BOM_QUANTITY_MAX}")
353
368
  if "note" in row and not isinstance(row["note"], str):
354
369
  vio(f"bom.materials[{i}].note must be a string")
355
370
  if "buy_url" in row and row["buy_url"] != "" and not http_url(row["buy_url"]):
@@ -68,7 +68,7 @@ Flat ordered array, copied through to the payload unchanged. Blocks before the f
68
68
 
69
69
  Seeed catalog rows carry `id` (SKU), `quantity`, `name`, `note`, `buy_url` — never `price`/`pic_url` (resolved by SKU server-side). Set `id` from the live `app bom search` result's `sku`, not an internal product ID. Preserve the lookup evidence in review notes. Custom rows carry `name` + `quantity` (required) and optionally `note` / `buy_url` — no `id`, no image, no price. Read [catalog verification and BOM fields](../../references/app-fields.md#catalog-verification-before-authoring-a-bom) before writing rows; custom entries are not API-confirmed catalog products.
70
70
 
71
- Names are non-empty strings and quantities are positive integer strings such as `"1"`. A custom row omits `id` entirely; `"id": null` is not a custom row. Notes and purchase URLs, when supplied, are strings; an optional empty purchase URL is allowed, but a non-empty one must be HTTP(S). Local shape validation cannot prove a catalog match or the correct quantity.
71
+ Names are non-empty strings and quantities are integer strings from `"1"` to `"999"`. A custom row omits `id` entirely; `"id": null` is not a custom row. Notes and purchase URLs, when supplied, are strings; an optional empty purchase URL is allowed, but a non-empty one must be HTTP(S). Local shape validation cannot prove a catalog match or the correct quantity.
72
72
 
73
73
  ## `sync` — local vs remote bookkeeping
74
74
 
@@ -179,9 +179,9 @@ When `--activity-id` is set and this JSON does not include `allow_clone`, CLI se
179
179
 
180
180
  **Status: implemented.**
181
181
 
182
- - `publish` → `privacy=2` (submit review). Same path as Console **发布草稿** when the app is already public (`is_sketch` + `be_public=1`). Result may include `draft_publish`. Refused if already `be_public=2` or not owner. stdout `detail_url` is `/view-application/<id>-<slug>` with no query. Give the user that URL. Do not append navigation params or replace it with `/application/detail/<id>`.
182
+ - `publish` → `privacy=2` (submit review). Same path as Console **发布草稿** when the app is already public (`is_sketch` + `be_public=1`). Result may include `draft_publish`. Refused if already `be_public=2` or not owner. stdout `detail_url` is `/view-application/<id>-<slug>` with no query. Give the user that URL only. Do not include `console_url` or `/application/edit`: review locks editing, and opening the editor returns `The application must not allow editing`. Do not append navigation params or replace the detail URL with `/application/detail/<id>`.
183
183
  - **Publish Declaration (required for `publish` only):** matches Console 「发布确认」`warrantyAccepted`. Before passing `--agree-declaration`, show the user:
184
- - Review will lock editing until approval (or `unpublish`)
184
+ - Review will lock editing until approval (or `app withdraw`). Do not use `unpublish` to leave review
185
185
  - Declaration URL: https://sensecraft.seeed.cc/legal/en/declaration
186
186
  - Do **not** pass `--agree-declaration` unless the user explicitly agreed
187
187
  - `unpublish` → `privacy=0` for an **already public** app (make it private). Owner only. No declaration flag. Do **not** use it to withdraw a review.
@@ -65,6 +65,8 @@ For an existing app, preserve participation unless changing it is part of the re
65
65
 
66
66
  API: `POST /flow/app/v3/edit_privacy_app` (CLI name: `publish` / `unpublish`).
67
67
 
68
+ Leaving review is not `privacy=0`. `app unpublish` only turns an already public app (`be_public=1`) private. An app under review (`be_public=2`) uses `app withdraw` (`POST /flow/app/v3/callback_sketch`). While it is under review, do not give `console_url` or `/application/edit`.
69
+
68
70
  ## BOM (`materials[]`)
69
71
 
70
72
  ### Catalog verification before authoring a BOM
@@ -87,7 +89,7 @@ Catalog verification proves product identity; it does not prove the app saved th
87
89
  | ---------- | -------- | ----------------------------------------- |
88
90
  | `id` | yes | product **SKU** |
89
91
  | `name` | yes | product name |
90
- | `quantity` | yes | string |
92
+ | `quantity` | yes | integer string from 1 to 999 |
91
93
  | `note` | yes | remark (may be empty string if UI allows) |
92
94
  | `buy_url` | yes | purchase link |
93
95
 
@@ -103,7 +105,7 @@ Pick products with `app bom search` (filters `material_options` from `get_produc
103
105
  | Field | Required | Notes |
104
106
  | ---------- | -------- | ------------------------------------------------------------------------------------------- |
105
107
  | `name` | yes | product name |
106
- | `quantity` | yes | string (Console UI integer stepper; API often string) |
108
+ | `quantity` | yes | integer string from 1 to 999 |
107
109
  | `note` | no | optional remark (Console placeholder: optional) |
108
110
  | `buy_url` | no | optional purchase link (invalid URL may become `""`) |
109
111
  | `id` | **omit** | custom rows must **not** include `id` |
@@ -21,7 +21,7 @@ Child skill: [`../create-app/SKILL.md`](../create-app/SKILL.md) — turn a local
21
21
  4. Tool-block **configuration** may be written into `deployment.blocks`. **Executing** flash / USB deploy / container install on hardware is **L3**. Classic reCamera (`40`): [`sensecraft-recamera`](recamera.md) (`check` / `open`). Other benches: Console `/ai/device/local/32|36|37|41|52`. `flash-firmware` run is out of scope this pass.
22
22
  5. Parse indented JSON on stdout; on failure read stderr + exit code. After `app update`, **re-read** the app — success body may be `{}`.
23
23
  6. **Rename / edit info**: sparse `{"app_name":"…"}` is OK (CLI merges other info fields from sketch). Do not invent HTTP; do **not** put `be_public=1` in user JSON. For **already published** apps the CLI injects `be_public=1` (Console info save) and returns `sketch_saved` — plaza copy is unchanged until `app publish`.
24
- 7. **Lifecycle vs Console**: edit / publish / unpublish / delete / BOM / cover only for **your** apps (`user_id` == profile). Another user's plaza app cannot be edited. `be_public=2` locks owner edit. `be_public=1` owner may save sketch then `app publish` (草稿). Delete only `be_public=0`.
24
+ 7. **Lifecycle vs Console**: edit / publish / unpublish / withdraw / delete / BOM / cover only for **your** apps (`user_id` == profile). Another user's plaza app cannot be edited. `be_public=2` locks owner edit and has no editor link; unlock with `app withdraw`, not `app unpublish`. `be_public=1` owner may save sketch then `app publish` (草稿). `app unpublish` is only for an already public app. Delete only `be_public=0`.
25
25
  8. **Never blind-retry `app create`**: names are not unique. If create output lacks `app_id` or looks empty, run `app list --mine` before creating again.
26
26
 
27
27
  ## CLI status
@@ -84,11 +84,12 @@ sensecraft-cli app update --id <app_id> --cancel-activity-id 1 --yes
84
84
  ```bash
85
85
  # After user agrees to Publish Declaration + confirms submit:
86
86
  sensecraft-cli app publish --id <app_id> --agree-declaration --yes
87
- sensecraft-cli app unpublish --id <app_id> --yes # privacy=0 private / withdraw review
87
+ sensecraft-cli app unpublish --id <app_id> --yes # already public (be_public=1) → private
88
+ sensecraft-cli app withdraw --id <app_id> --yes # under review (be_public=2) only
88
89
  sensecraft-cli app delete --id <app_id> --yes # private only (be_public=0)
89
90
  ```
90
91
 
91
- `app publish` matches Console 「发布确认」: show https://sensecraft.seeed.cc/legal/en/declaration and warn that review locks editing; only then pass `--agree-declaration --yes`. Missing either flag → non-zero. API body is still only `{app_id, privacy:2}` (agreement is client-side, like Console `warrantyAccepted`). stdout includes `detail_url`: `https://codecraft.seeed.cc/hub/view-application/<id>-<slug>`. Give the user that URL as printed. Do not append `from`, `section`, `state`, or `tab`. Do **not** invent `/application/detail/<id>`.
92
+ `app publish` matches Console 「发布确认」: show https://sensecraft.seeed.cc/legal/en/declaration and warn that review locks editing until approval or `app withdraw`; only then pass `--agree-declaration --yes`. Missing either flag → non-zero. API body is still only `{app_id, privacy:2}` (agreement is client-side, like Console `warrantyAccepted`). stdout includes `detail_url`: `https://codecraft.seeed.cc/hub/view-application/<id>-<slug>`. Give the user that URL as printed. Do not include `console_url` or `/application/edit`. Do not append `from`, `section`, `state`, or `tab`. Do **not** invent `/application/detail/<id>`.
92
93
 
93
94
  **Never** send `privacy=1` (ops-approved public). After editing a **published** app, tell the user plaza is unchanged until they confirm `app publish --agree-declaration --yes`.
94
95
 
@@ -133,7 +134,7 @@ For a local project/repository or an existing `codecraft-app.json`, use [create-
133
134
  sensecraft-cli app create --name "My App"
134
135
  sensecraft-cli app update --id <app_id> --from-json ./app.json --yes
135
136
  ```
136
- 5. User agrees to Publish Declaration + confirms → `app publish --agree-declaration --yes` (submit review)
137
+ 5. User agrees to Publish Declaration + confirms → `app publish --agree-declaration --yes` (submit review). After that, give `detail_url` only. `be_public=2` has no editor link.
137
138
 
138
139
  Never put `be_public=1` / `privacy=1` in JSON; use `app publish`.
139
140
 
@@ -7,8 +7,8 @@
7
7
  These are **not** confirmation. Do **not** pass `--yes` on the same turn:
8
8
 
9
9
  - 「删这个63760」「删除应用 demo」「把模型下架」「发布这个模型」
10
- - 「delete this」「unpublish」「deploy to the device」
11
- - Any first mention of create / modify / publish / unpublish / delete / deploy / stop / bind / unbind
10
+ - 「delete this」「unpublish」「withdraw the review」「deploy to the device」
11
+ - Any first mention of create / modify / publish / unpublish / withdraw / delete / deploy / stop / bind / unbind
12
12
 
13
13
  ## Required chat question (before any L2 CLI)
14
14
 
@@ -73,7 +73,7 @@ Write every field below inside **`block.config`**. Keep `id` and `type` on the b
73
73
  | `muse_gadget` | JSON boolean, default `false`; write `true`/`false`, never strings or numbers. Some read paths coerce non-booleans by truthiness, so `"false"` can enable the option. `true` shows the Muse SDK token input under the flash button in preview |
74
74
  | `full_flash` | JSON boolean, default `false`. Kept only on the Muse SKUs below; any other device is reset to `false`. `true` erases the whole flash before the write. When `muse_gadget` is `true`, set `full_flash` to `false`. The editor hides the checkbox while Muse is on |
75
75
 
76
- `muse_gadget: true` is kept only for these SKUs. Any other device written `true` is reset to `false` by the editor. `full_flash` uses the same SKU list:
76
+ `muse_gadget: true` is kept only for these SKUs. The CLI and `validate_manifest.py` reject `muse_gadget: true` or `full_flash: true` for any other `device_id`. The editor resets those flags to `false` when the document is opened. `full_flash` uses the same SKU list:
77
77
 
78
78
  | Device | `device_id` (SKU) |
79
79
  |--------|-------------------|