@seeed-studio/sensecraft-cli 0.1.2 → 0.1.4

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.
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: sensecraft-devices-cloud
3
+ description: >-
4
+ Manages SenseCraft AI cloud devices (Jetson / kit fleet via {ai-host}/openapi
5
+ list_node): list/view devices, deploy models with update_stream, poll order
6
+ records. Use when the user mentions Jetson 部署, 云端设备, cloud device,
7
+ Requires Access Key (`auth init --kind sensecap`). Not SenseCAP device CLI,
8
+ not Fleet, not local USB flash.
9
+ ---
10
+
11
+ # SenseCraft Devices Cloud
12
+
13
+ Auth: **Access Key** (`auth init --kind sensecap`) → `{ai-host}/openapi`. Parent: [`../sensecraft-ai/SKILL.md`](../sensecraft-ai/SKILL.md).
14
+
15
+ ## Agent rules
16
+
17
+ 1. `sensecraft-cli auth info` first — need SenseCAP Access Key for `{ai-host}/openapi`.
18
+ 2. **Never** use SenseCAP `device` commands here (`device list` = SenseCAP OpenAPI).
19
+ 3. **L2 confirm is a separate chat turn** ([`../confirmation.md`](../confirmation.md)) before `cloud deploy --yes` (and device output / order writes). 「部署到这台设备」is **not** confirmation — ask (部署 + 环境 + EUI + model_id), wait for `确认`, then `--yes`. Never pass `--yes` on the same turn as the first request.
20
+ 4. Local USB / Web Serial = **L3** → guide Console `/ai/device/local/...`.
21
+ 5. Fleet Docker install = [`sensecraft-fleet`](../sensecraft-fleet/SKILL.md) + `fleet …`;**same `sensecraft-ai` token**, different API host (`api.seeed-fleet.com`).
22
+ 6. **reCamera Pro** (`uniform_type=53`) local IP/USB RC2/ALPKG deploy is **not** `cloud deploy` / `update_stream` — guide users to Console device workspace (L3).
23
+
24
+ ## CLI status
25
+
26
+ | Command | Status |
27
+ |---------|--------|
28
+ | `cloud device list` / `view` | **Implemented** |
29
+ | `cloud deploy` / `cloud order` | **Implemented** (L2 deploy) |
30
+
31
+ ## Workflows
32
+
33
+ ```bash
34
+ sensecraft-cli cloud device list --uniform-type 26 --page 1 --length 20
35
+ sensecraft-cli cloud device list --uniform-type 26 --adapteds <adapted_id> --name "Jetson"
36
+ sensecraft-cli cloud device view --eui <EUI>
37
+ # confirm with user:
38
+ sensecraft-cli cloud deploy --eui <EUI> --model-id <id> --from-json ./stream.json --yes
39
+ sensecraft-cli cloud order --request-id <request_id> --device-uuid <uuid>
40
+ ```
41
+
42
+ `uniform_type` 26 is common for Jetson fleet UI; model deploy pages may pass other types / `adapteds`.
43
+
44
+ Full flag reference and copyable examples: [commands.md](commands.md).
45
+
46
+ ## Disambiguation
47
+
48
+ | Want | Use |
49
+ |------|-----|
50
+ | SenseCAP node/gateway telemetry | `sensecraft-cli device …` (Access Key) |
51
+ | Jetson / AI cloud kit | `cloud device …` (this skill) |
52
+ | Fleet multi-host Docker apps | `fleet …` + [`sensecraft-fleet`](../sensecraft-fleet/SKILL.md) |
53
+ | USB flash | Console local device (L3) |
@@ -0,0 +1,58 @@
1
+ # sensecraft-devices-cloud — CLI commands
2
+
3
+ Binary: `sensecraft-cli`. Auth: active **`sensecraft-ai`** profile.
4
+
5
+ ## `cloud device list`
6
+
7
+ | Flag | Default | Notes |
8
+ |------|---------|-------|
9
+ | `--uniform-type` | `26` | Device type; Jetson fleet UI commonly uses `26` |
10
+ | `--adapteds` | — | Optional adapted-device/model filter |
11
+ | `--name` | — | Filter by `device_name` |
12
+ | `--page` / `--length` | `1` / `20` | Pagination |
13
+ | `--sandbox` | false | No network; sample JSON |
14
+
15
+ ```bash
16
+ sensecraft-cli cloud device list --uniform-type 26 --page 1 --length 20
17
+ sensecraft-cli cloud device list --uniform-type 26 --adapteds <adapted_id> --name "Jetson"
18
+ ```
19
+
20
+ ## `cloud device view`
21
+
22
+ ```bash
23
+ sensecraft-cli cloud device view --eui <device_eui>
24
+ ```
25
+
26
+ `--eui` is required. Add `--sandbox` for an offline sample.
27
+
28
+ ## `cloud deploy` — L2
29
+
30
+ Requires explicit user confirmation and `--yes`.
31
+
32
+ ```bash
33
+ # Minimal model selection
34
+ sensecraft-cli cloud deploy \
35
+ --eui <device_eui> --model-id <model_id> --yes
36
+
37
+ # Stream settings supplied as a JSON object
38
+ sensecraft-cli cloud deploy \
39
+ --eui <device_eui> --model-id <model_id> \
40
+ --from-json ./stream.json --yes
41
+ ```
42
+
43
+ The response contains a `request_id`; poll it with `cloud order`.
44
+
45
+ ## `cloud order`
46
+
47
+ ```bash
48
+ sensecraft-cli cloud order --request-id <request_id>
49
+ ```
50
+
51
+ This command only polls deployment status and is not L2.
52
+
53
+ ## Disambiguation
54
+
55
+ - `cloud device …`: SenseCraft AI Jetson / cloud kit.
56
+ - `device …`: SenseCAP node/gateway OpenAPI.
57
+ - `fleet …`: Seeed Fleet Docker apps.
58
+ - Local USB / Web Serial flashing: Console L3, not this CLI.
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: sensecraft-files
3
+ description: >-
4
+ Uploads images, model binaries, app files, firmware, documents, and archives
5
+ to SenseCraft AI with acquire_file_url + PUT. Use when another workflow needs
6
+ a file_url. Requires Access Key (`auth init --kind sensecap`).
7
+ ---
8
+
9
+ # SenseCraft File Upload
10
+
11
+ Auth: **Access Key** → `{ai-host}/openapi`. Parent: [`../sensecraft-ai/SKILL.md`](../sensecraft-ai/SKILL.md).
12
+
13
+ ## Agent rules
14
+
15
+ 1. Run `sensecraft-cli auth info` first.
16
+ 2. Use the correct `--type`; do not invent a file type:
17
+ - `1` image — default **≤2 MB** (model `pic_url` / Console default); with `--for-app` or `--app-id` **≤5 MB** (app `images[]`); JPG/JPEG/PNG/GIF/WebP; no SVG
18
+ - `2` generic file / model (default; **≤100 MB**)
19
+ - `3` app (**≤100 MB**)
20
+ - `4` firmware (**≤100 MB**)
21
+ - `5` document (**≤100 MB**)
22
+ - `6` archive / ZIP (**≤100 MB**)
23
+ 3. Use `--checksum` when the downstream payload needs an MD5 (model uploads usually do).
24
+ 4. **Attach before upload.** Types `1`/`2` refuse OSS PUT without association. If the user provides a file without a model/app id, **ask first** (do not call upload):
25
+ - Existing model file: `model update --id <model_id> --path <file> --yes` or `model upload --path <file> --id <model_id> --yes` (auto-increments patch version, same as Console).
26
+ - App cover: `file upload --path <img> --type 1 --app-id <app_id> --yes` (or unlinked `--type 1 --for-app`; max **16** images).
27
+ - Model example image (`pic_url`): `file upload --path <img> --type 1 --unlinked` (**2 MB**), then put `file_url` into model JSON as `pic_url`.
28
+ - Brand-new model binary only: `model upload --path <file> --unlinked` (or `file upload --type 2 --unlinked`) then put `file_url` into `model create --from-json`. Never bare `model upload --path` / `file upload --path` — CLI exits non-zero (`ErrAttachRequired`).
29
+ 5. Treat returned signed/upload URLs and private file URLs as secrets.
30
+ 6. Upload alone is not L2; attaching to a model/app (`--id` / `--model-id` / `--app-id`) **is L2**. Follow [`../confirmation.md`](../confirmation.md): ask first, wait for `确认`, then `--yes`. Never pass `--yes` on the same turn as the first request. `--unlinked` is an explicit orphan opt-in (not L2).
31
+ 7. Do not pass oversized files or more than 16 app image URLs; CLI rejects them before upload/update.
32
+ 8. Types `3`–`6` have no model/app attach path and upload directly (no `--unlinked` needed).
33
+ 9. **Security gates**: empty (0 B) files rejected; type 2–6 / train sample zips ≤ **100 MB**; images 2 MB (model) / 5 MB (app). Upload rate limited to **8 / 10s** and **30 / minute** (client `acquire_file_url` + train multipart).
34
+
35
+ ## Examples
36
+
37
+ ```bash
38
+ # Existing private model: attach + bump version (preferred)
39
+ sensecraft-cli model upload --path ./model.rknn --id <model_id> --yes
40
+ # equivalent: sensecraft-cli file upload --path ./model.rknn --model-id <model_id> --yes
41
+
42
+ # App cover image (5 MB)
43
+ sensecraft-cli file upload --path ./cover.png --type 1 --app-id <app_id> --yes
44
+ # Unlinked app image for later images[] JSON:
45
+ sensecraft-cli file upload --path ./cover.png --type 1 --for-app
46
+
47
+ # Model inference example image → pic_url (2 MB)
48
+ sensecraft-cli file upload --path ./demo.png --type 1 --unlinked
49
+
50
+ # Unlinked only when creating a brand-new model (then put file_url into model create)
51
+ sensecraft-cli model upload --path ./model.rknn --unlinked
52
+
53
+ # Firmware, document, and archive (no model/app attach)
54
+ sensecraft-cli file upload --path ./firmware.bin --type 4 --checksum
55
+ sensecraft-cli file upload --path ./guide.pdf --type 5
56
+ sensecraft-cli file upload --path ./dataset.zip --type 6 --checksum
57
+
58
+ # Offline exercise: no network
59
+ sensecraft-cli file upload --path ./fixture.bin --type 2 --checksum --unlinked --sandbox
60
+ ```
61
+
62
+ Success JSON contains `file_name`, `file_type`, `file_url`, `size`, optional `checksum`, and `attached`.
63
+ When attached to a model it also includes `model_id`, `previous_version`, `version`. Explicit `--unlinked` / `--for-app` sets `attached: false` and a `hint`.
64
+
65
+ ## Model shortcut
66
+
67
+ For model artifacts, this wrapper fixes `type=2` and enables checksum. Pass `--id` to attach and bump version:
68
+
69
+ ```bash
70
+ sensecraft-cli model upload --path ./model.rknn --id <model_id> --yes
71
+ ```
72
+
73
+ See [commands.md](commands.md) for the flag reference.
@@ -0,0 +1,61 @@
1
+ # sensecraft-files — CLI commands
2
+
3
+ Binary: `sensecraft-cli`. Auth: active **`sensecraft-ai`** profile.
4
+
5
+ ## `file upload`
6
+
7
+ Acquires an upload URL, PUTs the local bytes, and prints the permanent `file_url`.
8
+
9
+ | Flag | Required | Default | Notes |
10
+ |------|----------|---------|-------|
11
+ | `--path` | yes | — | Local file |
12
+ | `--type` | no | `2` | `1=image`, `2=file/model`, `3=app`, `4=firmware`, `5=doc`, `6=archive/zip` |
13
+ | `--checksum` | no | false | Compute local MD5 and include it in output |
14
+ | `--model-id` | no | — | Attach to this model (implies type=2 + checksum; **L2 `--yes`**; bumps version) |
15
+ | `--app-id` | no | — | Attach as app cover (implies type=1, **5 MB**; **L2 `--yes`**; app `images[]` max **16**) |
16
+ | `--for-app` | no | false | Unlinked type-1 for app `images[]` (**5 MB**); without it type-1 is **2 MB** (model `pic_url`) |
17
+ | `--unlinked` | types 1–2 | — | Explicit orphan opt-in for later create/update JSON; required when no `--model-id`/`--app-id`/`--for-app` |
18
+ | `--yes` | with attach | — | Required when `--model-id` or `--app-id` is set |
19
+ | `--sandbox` | no | false | No network; return sample JSON |
20
+
21
+ **Size / format (Console `upload.vue` / `infoForm` / `model/add.vue`):**
22
+
23
+ | type | Max size | Formats / notes |
24
+ |------|----------|-----------------|
25
+ | `1` image (default / model `pic_url`) | **2 MB** | JPG/JPEG/PNG/GIF/WebP (SVG rejected); Console model example image |
26
+ | `1` + `--for-app` or `--app-id` | **5 MB** | same formats; app `images[]` max **16** |
27
+ | `2`–`6` | **100 MB** | per Console accept rules |
28
+
29
+ `app create/update --from-json` with `images[]` also enforces **max 16** URLs (Console `maxImageCount`).
30
+
31
+ `--model-id` and `--app-id` are mutually exclusive. Types `1`/`2` without attach/`--for-app`/`--unlinked` exit non-zero **before** PUT (`ErrAttachRequired`). Types `3`–`6` upload directly.
32
+
33
+ ```bash
34
+ sensecraft-cli file upload --path ./cover.png --type 1 --for-app
35
+ sensecraft-cli file upload --path ./cover.png --type 1 --app-id <app_id> --yes
36
+ sensecraft-cli file upload --path ./model-demo.png --type 1 --unlinked
37
+ sensecraft-cli file upload --path ./model.rknn --type 2 --checksum --unlinked
38
+ sensecraft-cli file upload --path ./model.rknn --model-id <model_id> --yes
39
+ sensecraft-cli file upload --path ./application.zip --type 3 --checksum
40
+ sensecraft-cli file upload --path ./firmware.bin --type 4 --checksum
41
+ sensecraft-cli file upload --path ./manual.pdf --type 5
42
+ sensecraft-cli file upload --path ./dataset.zip --type 6 --checksum
43
+ ```
44
+
45
+ Output:
46
+
47
+ Unlinked (`--unlinked` / `--for-app`) output includes `"attached": false` and `hint`. Attached model output:
48
+
49
+ ```json
50
+ {
51
+ "file_name": "model.rknn",
52
+ "file_type": 2,
53
+ "file_url": "https://…",
54
+ "size": 123456,
55
+ "checksum": "…",
56
+ "attached": true,
57
+ "model_id": "63754",
58
+ "previous_version": "1.0.0",
59
+ "version": "1.0.1"
60
+ }
61
+ ```
@@ -0,0 +1,196 @@
1
+ ---
2
+ name: sensecraft-models
3
+ description: >-
4
+ Browses and manages the SenseCraft model library: search public/my models,
5
+ view tech metadata (task, format, classes, devices), download, upload, publish/
6
+ unpublish, delete. Use when the user mentions 模型库, Model Library, upload model,
7
+ download model, model classes/labels, or CodeCraft model invoke links.
8
+ Requires Access Key (`auth init --kind sensecap`). Not for SenseCAP telemetry or App Plaza clone.
9
+ ---
10
+
11
+ # SenseCraft Models (Model Library)
12
+
13
+ Domain skill for **SenseCraft AI models**. Auth: **Access Key** → `{ai-host}/openapi`.
14
+
15
+ Parent: [`../sensecraft-ai/SKILL.md`](../sensecraft-ai/SKILL.md).
16
+ Apps: [`../sensecraft-apps/SKILL.md`](../sensecraft-apps/SKILL.md).
17
+ Training artifacts (train job model download): [`sensecraft-train`](../sensecraft-train/SKILL.md) + `train model download` — distinct from library `model download`.
18
+
19
+ ## Agent rules
20
+
21
+ 1. Auth first:
22
+ ```bash
23
+ sensecraft-cli auth info
24
+ ```
25
+ Prefer **SenseCAP Access Key** (`auth init --kind sensecap`) → `{ai-host}/openapi` Basic. Missing key → user runs `auth init --kind sensecap`. **Never** run init for them.
26
+ 2. **L2 confirm is a separate chat turn** ([`../confirmation.md`](../confirmation.md)) before: `publish` / `unpublish` / `delete` / `create` / `model update` / attach-upload. 「删这个63760」is **not** confirmation — ask `将从{环境}环境删除模型 63760。删除后可能无法恢复。是否确认执行?`, wait for `确认`, then `--yes`. Never pass `--yes` on the same turn as the first request.
27
+ 3. When the user **attaches a model file** ("上传这个模型文件" / "更新模型"):
28
+ - **Own My Models** (including already published `be_public=1`): after chat confirm, `model update --id <model_id> --path <file> --yes`. Same as Console 编辑模型. If it is **already public**, the confirm question must say 模型信息更新后将重新进入审核流程. CLI sends `be_public=1` like Console `requestConfirmFn`. JSON includes `re_review: true`.
29
+ - `model upload --path <file> --id <model_id> --yes` is the same attach path.
30
+ - Do **not** unlinked-upload then a second `model update` just to bump version.
31
+ - If they did not give an id, **ask** whether this replaces an existing private/own model or creates a new one. Do **not** call upload yet — bare `model upload --path` / `file upload --path` exits non-zero (`ErrAttachRequired`) and must not be used to "probe".
32
+ - Brand-new model only: `model upload --path <file> --unlinked` then `model create --from-json`.
33
+ - **Someone else's public library** id: refuse (no clone). New models only: `--unlinked` upload then `model create --from-json`.
34
+ - Metadata-only edit: `model update --id <model_id> --from-json patch.json --yes`. Labels change also auto-increments version like Console.
35
+ - **Delete** only when `be_public=0` (Console hides delete for published/under-review). Unpublish first.
36
+ 4. Model **publish** API uses `status: 1` (to public library) / `status: 0` (privatize) — **different from apps** (`privacy` 2/0). Do not mix.
37
+ 5. **Public models are deploy-only.** For public / under-review models (`be_public≠0`):
38
+ - **Do not clone** — the platform has no model clone (unlike `app clone`). Do not copy `model view` JSON into `model create` (including `id` / `model_id` / `from_id` / `file_url` / checksum). CLI `model create` refuses public-library sources. Tell the user to **deploy** instead.
39
+ - **Do not download.** Phrases like 下载地址 / 下载链接 / `file_url` / download URL / 怎么下载 / 给我链接 are the **same leak** as `model download --url-only`. Do **not** run `model download` (`--apply` / `--url-only` included).
40
+ - Do **not** print, quote, or reconstruct `file_url`, `apply_model` URLs, CDN/OSS paths, or signed query strings — even if they appear in a tool error, browser, or prior message.
41
+ - Answer the **method**, not an address: browse metadata, then deploy so the device pulls firmware at apply time (`cloud deploy` for Jetson/`26`, or classic reCamera `40` via [`sensecraft-recamera`](../sensecraft-recamera/SKILL.md)).
42
+ - Owner file download is only for **private** My Models (`be_public=0`). Even then, do not paste signed URLs into chat unless the user explicitly needs `--url-only` for a local script; prefer `--out` file path. Treat remaining `file_url`, checksums, and tokens as secrets.
43
+ 6. Success = indented JSON stdout; failure = stderr + non-zero exit.
44
+ 7. Classic reCamera (`uniform_type=40`): list with `--uniform-type 40`, then [`sensecraft-recamera`](../sensecraft-recamera/SKILL.md) `check` / `open`. **Do not** `cloud deploy`. **Do not** download public models. reCamera Pro (`53`) is a different device — use `model recamera-pro resolve`, then Console local L3 (not this 40 flow).
45
+
46
+ ## CLI status
47
+
48
+ | Area | Status |
49
+ |------|--------|
50
+ | Auth `--kind sensecap` | **Implemented** (`{ai-host}/openapi` Basic) |
51
+ | `model list` / `model view` / `model download` | **Implemented** |
52
+ | `model create` / `update` / `publish` / `unpublish` / `delete` | **Implemented** (L2: `--yes`; create needs `file_url` in JSON) |
53
+ | `model upload` / `file upload` | **Implemented** (types 1–2 require `--id`/`--model-id`/`--app-id`/`--for-app`/`--unlinked`; attach auto-increments patch version like Console) |
54
+ | `model constants` | **Implemented** (`get_constant`) |
55
+ | `model recamera-pro resolve` | **Implemented** (local task/framework/algorithm/format validation) |
56
+
57
+ ## Typical workflows
58
+
59
+ ### Find a suitable public model
60
+
61
+ ```bash
62
+ sensecraft-cli auth info
63
+ sensecraft-cli model list --public --task <task_id> --name "<keyword>"
64
+ sensecraft-cli model list --public --uniform-type 40
65
+ sensecraft-cli model list --mine --name "<keyword>"
66
+ sensecraft-cli model view --id <model_id>
67
+ ```
68
+
69
+ Report: name, description, **task/category**, **supported devices** (`uniform_types` / adapteds), format, classes/labels, size/version, any invoke/deep-link fields.
70
+
71
+ If they ask to **clone** a public model into My Models, refuse. There is no `model clone`. Do not `model create` from that model's view JSON. Reply that others' public models cannot be cloned; deploy instead:
72
+
73
+ > 他人公开模型不支持克隆。Jetson/云套件用 `cloud deploy`;经典 reCamera(40)用 `recamera check` / `recamera open` 后在 Console 点部署;Pro(53)走 Console 本地工作区。
74
+
75
+ If they ask for a **download address / link / URL / 怎么下载** on a public model, do **not** fetch a URL. Reply that public models have no download link; the way to get the artifact is to **deploy** (device pulls firmware). Example:
76
+
77
+ > 公开模型不提供下载地址。Jetson/云套件用 `cloud deploy`;经典 reCamera(40)用 `recamera open` 后在 Console 点部署。设备会在 apply 时拉取固件。
78
+
79
+ ### Download (private / My Models only)
80
+
81
+ ```bash
82
+ sensecraft-cli model download --id <model_id> [--out ./path]
83
+ sensecraft-cli model download --id <model_id> --apply [--out ./path]
84
+ sensecraft-cli model download --id <model_id> --url-only
85
+ ```
86
+
87
+ - Allowed only when `be_public=0` (owner private library). Public / under-review models **refuse** download — deploy instead.
88
+ - Default: owner library `view_model.file_url`
89
+ - `--apply`: deploy snapshot via `apply_model` → `model_snapshot.arguments.url` (still private-only; not a public-library shortcut)
90
+ - File downloads omit `url` from JSON unless `--url-only`. Never paste signed URLs into chat.
91
+
92
+ ### Deploy a public model (no download)
93
+
94
+ ```bash
95
+ # Jetson / cloud kit — device pulls firmware at apply time
96
+ sensecraft-cli cloud deploy --eui <EUI> --model-id <id> --yes
97
+
98
+ # reCamera Pro / USB local — Console workspace (L3); CLI does not fetch the binary
99
+ ```
100
+
101
+ ### Upload + publish (L2)
102
+
103
+ **Replace an existing private model's file** (user attached a binary / “上传这个模型文件” / “更新模型”):
104
+
105
+ ```bash
106
+ sensecraft-cli model update --id <model_id> --path ./model.rknn --yes
107
+ # same attach: sensecraft-cli model upload --path ./model.rknn --id <model_id> --yes
108
+ # file + metadata: sensecraft-cli model update --id <model_id> --path ./model.rknn --from-json ./patch.json --yes
109
+ ```
110
+
111
+ This writes `file_url` / `checksum` / `model_size` and auto-increments the patch version (Console: `1.0.0` → `1.0.1`). Do not follow with a separate `model update` just to bump version. If the model is **already published** (`be_public=1`), warn that it will **re-enter review**, then proceed with `--yes` (CLI sends `be_public=1` like Console).
112
+
113
+ **Brand-new model** only:
114
+
115
+ 1. Gather fields from [reference-model-fields.md](reference-model-fields.md)
116
+ 2. Explicit unlinked upload, then put `file_url` (+ `checksum`, `size` as `model_size`) into create JSON:
117
+ ```bash
118
+ sensecraft-cli model upload --path ./model.rknn --unlinked
119
+ sensecraft-cli model create --from-json ./model.json --yes
120
+ sensecraft-cli model create --from-json ./pro-model.json --target recamera-pro --yes
121
+ ```
122
+
123
+ Publish / unpublish / delete still need a **chat confirm first**, then `--yes` (never same-turn as 「删这个 / 发布 / 下架」):
124
+ ```bash
125
+ # only after the user replies 确认 to your question
126
+ sensecraft-cli model publish --id <model_id> --yes
127
+ sensecraft-cli model unpublish --id <model_id> --yes
128
+ sensecraft-cli model delete --id <model_id> --yes
129
+ ```
130
+
131
+ Successful `model create` JSON includes `model_id` and `console_url` (Console detail: `/ai/model/detail?id=…&tab=custom`). Show that link to the user.
132
+
133
+ Create must contain the complete field set in [reference-model-fields.md](reference-model-fields.md). Update may be an incremental input patch: CLI loads `view_model`, merges and validates it, then submits the normalized complete Console form so removed conditional fields (such as Pro Classification `ai_framework`) do not remain stale.
134
+
135
+ Model publish uses **`status` 1/0** — not app `privacy` 2/0. Never set `be_public=1` in create/update JSON.
136
+
137
+ ### reCamera Pro compatibility
138
+
139
+ When an `adapteds` entry resolves through `get_constant.device_type_array` to `uniform_type=53`, create/update applies Pro validation automatically. Use `--target recamera-pro` only as an additional assertion:
140
+
141
+ ```bash
142
+ sensecraft-cli model recamera-pro resolve --task <task_id> [--ai-framework <id>]
143
+ sensecraft-cli model create --from-json ./pro.json --target recamera-pro --yes
144
+ ```
145
+
146
+ - Detection (`task=1`): framework ids `1,2,8,9,10,11,12,13,14,15`.
147
+ - Classification (`task=2`): algorithm is fixed to `classify`; omit `ai_framework`.
148
+ - Pose (`task=4`): only YOLOV8 (`ai_framework=2`), mapped to `yolov8_pose`.
149
+ - Audio (`task=6`): omit framework; upload `.alpkg` (`model_format=7`) or `.zip` (`8`).
150
+ - Tracking (`task=7`): algorithm fixed to `bytetrack`; omit framework.
151
+ - Segmentation (`3`) and Generation (`5`) are hidden/unsupported for reCamera Pro upload/deploy.
152
+ - All supported non-audio tasks use `.rknn` (`model_format=6`).
153
+
154
+ Detection framework→algorithm and full upload constraints are in [reference-model-fields.md](reference-model-fields.md).
155
+
156
+ ## Field summary (library card / detail)
157
+
158
+ | Concept | API / field hints | Notes |
159
+ |---------|-------------------|--------|
160
+ | Name | `name` | max **64** chars |
161
+ | Intro | `description` | max **300** (UI) |
162
+ | Detail body | `content` | rich text / HTML |
163
+ | Category / task | `task` | from `get_constant` → `model_task_array` (vision detect/classify, audio, …) — **do not invent ids** |
164
+ | AI framework | `ai_framework` | required for some device+task combos (e.g. reCamera Pro detection); from `ai_framework_array` |
165
+ | Format | `model_format` | from `model_format_array` (e.g. rknn, alpkg, zip, …) |
166
+ | Classes | `labels[]` with `object_name` | at least one valid class when UI requires |
167
+ | Supported devices | `adapteds` / `uniform_types` | multi-select device types |
168
+ | Tech | `version`, `precision`, `checksum`, `model_size`, `attr.conf`/`iou` | device-dependent |
169
+ | File | `file_url` | uploaded model artifact; **omitted from public list/view stdout** |
170
+ | Cover / demo | `pic_url` | inference example image (required on create UI; **≤2 MB** when uploading with `file upload --type 1`) |
171
+ | Visibility | `be_public` | `0` private · `1` public · `2` under review (display) |
172
+ | Invoke / CodeCraft | detail or env deep links | Surface any API-provided invoke URL; CodeCraft workspace base from product env — **do not implement CodeCraft compile inside this skill** |
173
+
174
+ Full create/edit compliance: [reference-model-fields.md](reference-model-fields.md).
175
+
176
+ ## APIs (wiring reference)
177
+
178
+ Base: `{host}/openapi`, HTTP Basic (`key_id`:`access_key`).
179
+
180
+ | Action | Method | Path |
181
+ |--------|--------|------|
182
+ | List public | GET | `/model/list_model` (optional `uniform_type` / `adapteds`) |
183
+ | List mine | GET | `/model/list_custom_model` |
184
+ | View | GET | `/model/view_model` |
185
+ | Create | POST | `/model/create_model` |
186
+ | Edit | POST | `/model/edit_model` |
187
+ | Publish / privatize | POST | `/model/publish_model` (JSON number `model_id`, `status` 1\|0) |
188
+ | Delete | POST | `/model/delete_model` |
189
+ | Upload URL | GET | `/user/acquire_file_url` |
190
+ | Apply / deploy snapshot | GET | `/model/apply_model` |
191
+ | Constants (tasks/formats) | GET | `/user/get_constant` |
192
+
193
+ ## Additional resources
194
+
195
+ - [commands.md](commands.md)
196
+ - [reference-model-fields.md](reference-model-fields.md)
@@ -0,0 +1,180 @@
1
+ # sensecraft-models — CLI commands
2
+
3
+ Binary: `sensecraft-cli`. Auth: **Access Key** (`auth init --kind sensecap`) → `{ai-host}/openapi`.
4
+
5
+ > Status: **shipped**. Every command below is implemented — run it rather than describing it.
6
+
7
+ ## Prerequisite
8
+
9
+ ```bash
10
+ sensecraft-cli auth info
11
+ # user-only:
12
+ sensecraft-cli auth init --kind sensecap
13
+ ```
14
+
15
+ ## Commands
16
+
17
+ ### `model list`
18
+
19
+ **Status: implemented.**
20
+
21
+ | Flag | Notes |
22
+ |------|-------|
23
+ | `--public` | `list_model` (default if neither flag) |
24
+ | `--mine` | `list_custom_model` |
25
+ | `--name` | keyword → API `search` (Console model library search box) |
26
+ | `--task` | task id from constants |
27
+ | `--uniform-type` | device type → API `uniform_type` (`40` reCamera, `32` XIAO ESP32S3, `53` reCamera Pro) |
28
+ | `--adapteds` | device id → API `adapteds` (Console cardList SKU filter) |
29
+ | `--page` / `--length` | pagination |
30
+ | `--sandbox` | sample JSON |
31
+
32
+ ```bash
33
+ # Public library (default when neither --public nor --mine is set)
34
+ sensecraft-cli model list --public --task 1 --name "vision" --page 1 --length 20
35
+ sensecraft-cli model list --public --uniform-type 40
36
+ sensecraft-cli model list --mine --uniform-type 40
37
+
38
+ # My Models
39
+ sensecraft-cli model list --mine --name "custom"
40
+ ```
41
+
42
+ Classic reCamera (`40`) pick-and-open: [`../sensecraft-recamera/commands.md`](../sensecraft-recamera/commands.md). Do not `cloud deploy` those models.
43
+
44
+ ### `model view --id <id>`
45
+
46
+ **Status: implemented.** Return name, description, task, format, labels/classes, uniform_types, version, size, be_public, etc.
47
+
48
+ Public / under-review models **omit `file_url`**. Do not treat the missing field as a bug.
49
+
50
+ ```bash
51
+ sensecraft-cli model view --id <model_id>
52
+ ```
53
+
54
+ ### `model download --id <id> [--out path]`
55
+
56
+ **Status: implemented.** Private owner models only (`be_public=0`).
57
+
58
+ | Flag | Notes |
59
+ |------|-------|
60
+ | `--id` | required |
61
+ | `--out` | file or directory (default: URL basename in cwd) |
62
+ | `--apply` | use `apply_model` snapshot URL instead of `file_url` (still private-only) |
63
+ | `--url-only` | print JSON with URL; do not write a file |
64
+ | `--sandbox` | sample bytes / sample URL |
65
+
66
+ Stdout JSON: `model_id`, `source` (`file_url`\|`apply_model`), optional `path`/`bytes`/`filename`. `url` is included **only** with `--url-only`.
67
+
68
+ Public library models exit non-zero: deploy via `cloud deploy` or Console so the device pulls firmware at apply time.
69
+
70
+ If the user asks for a download **address** (URL / 链接 / `file_url`) or **how to download** a public model, do **not** retry `--url-only` or dump view JSON. Tell them there is no download URL; the method is deploy-time firmware pull.
71
+
72
+ ### `model constants`
73
+
74
+ **Status: implemented.** Dumps `get_constant` (`model_task_array`, `model_format_array`, `ai_framework_array`, …) for Agent id↔name mapping.
75
+
76
+ ```bash
77
+ sensecraft-cli model constants
78
+ ```
79
+
80
+ ### `model recamera-pro resolve`
81
+
82
+ **Status: implemented.** Local compatibility check; no auth or network required. It validates a reCamera Pro task/framework combination and returns the device-side `algorithm`, required model format, file extension, and deploy mode.
83
+
84
+ ```bash
85
+ # Detection: task 1 + YOLOV8 framework id 2 → algorithm yolov8
86
+ sensecraft-cli model recamera-pro resolve --task 1 --ai-framework 2
87
+
88
+ # Classification → algorithm classify
89
+ sensecraft-cli model recamera-pro resolve --task 2
90
+
91
+ # Pose only accepts YOLOV8 id 2 → algorithm yolov8_pose
92
+ sensecraft-cli model recamera-pro resolve --task 4 --ai-framework 2
93
+
94
+ # Audio accepts .alpkg (format 7) or .zip (format 8)
95
+ sensecraft-cli model recamera-pro resolve --task 6
96
+ ```
97
+
98
+ Unsupported combinations print structured JSON and exit non-zero.
99
+
100
+ ### `model upload --path <file>`
101
+
102
+ **Status: implemented.** Uploads `file_type=2` with checksum.
103
+
104
+ | Flag | Required | Notes |
105
+ |------|----------|-------|
106
+ | `--path` | yes | Local model binary |
107
+ | `--id` | one of `--id` / `--unlinked` | Private My Models id to attach; public ids refused |
108
+ | `--unlinked` | one of `--id` / `--unlinked` | Explicit orphan for brand-new `model create` only |
109
+ | `--yes` | with `--id` | L2; without it, attach does **not** upload |
110
+ | `--sandbox` | no | Sample JSON, no network |
111
+
112
+ When replacing an existing private model's artifact, pass `--id` so the file is attached and the **patch version auto-increments** (Console `incrementVersion`: `1.0.0` → `1.0.1` when `file_url` changes). This is L2 (`--yes`). Bare `model upload --path` (no `--id`/`--unlinked`) exits non-zero **before** PUT. Interactive TTY guides association; agents must ask the user first. JSON includes `attached`, `model_id`, `previous_version`, `version`.
113
+
114
+ ```bash
115
+ # Existing model: attach + bump version
116
+ sensecraft-cli model upload --path ./model.rknn --id <model_id> --yes
117
+
118
+ # New model only: capture file_url for model create --from-json
119
+ sensecraft-cli model upload --path ./model.rknn --unlinked
120
+ ```
121
+
122
+ ### `model create` / `model update` (L2)
123
+
124
+ **Status: implemented.**
125
+
126
+ | Command | Flags |
127
+ |---------|--------|
128
+ | `create` | `--from-json` (required, complete payload), `--yes`, optional assertion `--target recamera-pro` |
129
+ | `update` | `--id`, `--from-json` and/or `--path`, `--yes`, optional assertion `--target recamera-pro` |
130
+
131
+ Both commands load current `get_constant`. Create validates the complete payload; update first merges the patch with `view_model`, then applies the same checks and submits a normalized complete form. `--path` uploads first (type=2 + checksum) and overwrites `file_url`/`checksum`/`model_size` on the patch — same as Console edit. If `labels` or `file_url` change and the version string was left unchanged, patch version auto-increments (`1.0.0` → `1.0.1`). **Own published** models (`be_public=1`) can be updated; CLI sends `be_public=1` so they **re-enter review** (Console add.vue). Others' public-library ids are refused. Enforced checks include required fields, name/description lengths, labels, version, option ids, device-family exclusivity, device→format/file extension, checksum, and Pro task/framework rules. Non-Pro payloads strip `ai_framework`.
132
+
133
+ reCamera Pro is detected automatically when an `adapteds` entry resolves to `uniform_type=53`; `--target recamera-pro` is only an extra assertion. See [reference-model-fields.md](reference-model-fields.md).
134
+
135
+ `create` refuses payloads that still carry a **public-library** `id` / `model_id` / `from_id` (others' public models cannot be cloned). Upload your own file via `model upload`, then create. Public models are deploy-only.
136
+
137
+ `create` response always includes `model_id` + `console_url` (Console `/ai/model/detail?id=…&tab=custom`). Show `console_url` to the user after success.
138
+
139
+ ```bash
140
+ sensecraft-cli model create --from-json ./model.json --yes
141
+ sensecraft-cli model create --from-json ./pro-model.json --target recamera-pro --yes
142
+ sensecraft-cli model update --id <model_id> --from-json ./model.json --yes
143
+ sensecraft-cli model update --id <model_id> --path ./model.tflite --yes
144
+ sensecraft-cli model update --id <model_id> --path ./model.tflite --from-json ./patch.json --yes
145
+ ```
146
+
147
+ ### `model publish` / `model unpublish` (L2)
148
+
149
+ **Status: implemented.**
150
+
151
+ | Command | API `status` |
152
+ |---------|----------------|
153
+ | `publish` | `1` |
154
+ | `unpublish` | `0` |
155
+
156
+ Require a **separate chat confirmation** (see [`../confirmation.md`](../confirmation.md)), then `--yes`. 「发布这个 / 下架 / 删这个」is intent — ask first.
157
+
158
+ ```bash
159
+ # After the user replies 确认:
160
+ # Submit to public library
161
+ sensecraft-cli model publish --id <model_id> --yes
162
+
163
+ # Return to private
164
+ sensecraft-cli model unpublish --id <model_id> --yes
165
+ ```
166
+
167
+ ### `model delete --id <id>` (L2)
168
+
169
+ **Status: implemented.** Maps to `delete_model`; requires `--yes`. Refuses `be_public≠0` (unpublish first).
170
+
171
+ User 「删这个63760」→ ask `将从{环境}环境删除模型 63760。删除后可能无法恢复。是否确认执行?` → wait for `确认` → then:
172
+
173
+ ```bash
174
+ sensecraft-cli model delete --id <model_id> --yes
175
+ ```
176
+
177
+ ## Output
178
+
179
+ Success: indented JSON on stdout.
180
+ Failure: stderr + non-zero exit.