@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,139 @@
1
+ # Model library & upload field reference
2
+
3
+ Aligned with Console `views/model/add.vue`, `detail.vue`, and `constants/sensecraftModel.js`.
4
+
5
+ ## Identity & copy
6
+
7
+ | Field | Type | Required (create UI) | Compliance |
8
+ |-------|------|----------------------|------------|
9
+ | `name` | text | yes | max **64** (`SENSECRAFT_MODEL_NAME_MAX_LENGTH`); trim before API |
10
+ | `description` | text | yes | max **300** |
11
+ | `content` | rich text | yes | model detail / documentation body |
12
+ | `pic_url` | image URL | yes | inference example image; upload via `file upload --type 1` (**≤2 MB**, Console `model/add.vue` max-size=2); JPG/PNG/GIF/WebP; must be http(s) URL |
13
+ | `scenario` | option | yes | id from `get_constant` **`scenarios_array`** (not app `app_scenarios_array`); CLI rejects unknown ids |
14
+ | `precision` | option | yes | id from **`model_precision_array`** (1=INT8, 2=FLOAT16, 3=FLOAT32 typical); CLI rejects unknown ids |
15
+ | `file_url` | URL | yes | model binary URL; http(s); extension must match `model_format` |
16
+ | `preparation` | string[] | often | prep steps (UI list) |
17
+
18
+ ## Classification & devices
19
+
20
+ | Field | Type | Required | Compliance |
21
+ |-------|------|----------|------------|
22
+ | `task` | option (id) | yes | From **`get_constant` → `model_task_array`**. Product categories include vision detection, vision classification, audio, vibration-related tasks, etc. **Resolve names→ids from constants**; do not hardcode stale enums in Agent replies when constants are available. |
23
+ | `ai_framework` | option (id) | conditional | From `ai_framework_array`, filtered by device/task (e.g. reCamera Pro detection). Classification/audio may hide framework and map algorithm by task. |
24
+ | `adapteds` | multi device | yes | Supported device entries; drives `uniform_types` and accept filters |
25
+ | `model_format` | option | yes | From `model_format_array` (examples in code comments: alpkg=`7`, zip=`8`; rknn common for vision). Accept filter follows format + task (e.g. audio → `.rknn` / `.alpkg` / `.zip` rules in UI). |
26
+
27
+ ## Classes / labels
28
+
29
+ | Field | Type | Required | Compliance |
30
+ |-------|------|----------|------------|
31
+ | `labels[]` | list | usually yes | Each item: `object_id` (**number or numeric string, not JSON `null`**), `object_name` (non-empty, pass `validateClassName`) |
32
+ | classes | derived | — | Often mirrored from label names for deploy |
33
+
34
+ Empty or invalid class names block save/deploy in Console.
35
+
36
+ CLI-enforced class-name rule matches Console `validateClassName`: ASCII letters, digits, and spaces only; at least one letter; the first character cannot be a digit.
37
+
38
+ ## Device family and format matrix
39
+
40
+ `adapteds` contains device option ids, not uniform types. Create/update resolves every id through the current `get_constant.device_type_array` and enforces the same selection families as Console:
41
+
42
+ | Resolved `uniform_type` | Selection | Allowed `model_format` / file |
43
+ |-------------------------|-----------|-------------------------------|
44
+ | `32`, `52` | group may multi-select; cannot mix with other families | `2` / `.tflite` |
45
+ | `36`, `37`, `41` | group may multi-select; cannot mix with other families | `2` / `.tflite` |
46
+ | `26` | Jetson/reComputer entries may multi-select | `3` / `.engine` or `4` / `.pt` |
47
+ | `40` | single selection | `5` / `.cvimodel` |
48
+ | `53` | single selection | Pro matrix below |
49
+ | other | single selection | current format option except `2`; extension follows format |
50
+
51
+ Non-Pro payloads do not submit `ai_framework`, matching Console.
52
+
53
+ ## reCamera Pro (`uniform_type=53`)
54
+
55
+ Create/update automatically recognizes Pro from `adapteds`. The resolver remains useful for planning:
56
+
57
+ ```bash
58
+ sensecraft-cli model recamera-pro resolve --task <task> [--ai-framework <id>]
59
+ ```
60
+
61
+ ### Supported task/format matrix
62
+
63
+ | Task id | Meaning | `ai_framework` | Device algorithm | Format / file |
64
+ |---------|---------|----------------|------------------|---------------|
65
+ | `1` | Detection | required; see map below | mapped framework algorithm | `6` / `.rknn` |
66
+ | `2` | Classification | omit | `classify` | `6` / `.rknn` |
67
+ | `4` | Pose | only `2` (YOLOV8) | `yolov8_pose` | `6` / `.rknn` |
68
+ | `6` | Audio | omit | package-defined | `7` / `.alpkg` or `8` / `.zip` |
69
+ | `7` | Tracking | omit | `bytetrack` | `6` / `.rknn` |
70
+ | `3`, `5` | Segmentation, Generation | — | — | hidden/unsupported |
71
+
72
+ ### Detection framework map
73
+
74
+ | `ai_framework` id | Device `algorithm` |
75
+ |-------------------|--------------------|
76
+ | `1` | `yolov5` |
77
+ | `2` | `yolov8` |
78
+ | `8` | `yolov5u` |
79
+ | `9` | `yolov10` |
80
+ | `10` | `yolo11` |
81
+ | `11` | `yolo12` |
82
+ | `12` | `yolo26` |
83
+ | `13` | `nanodet` |
84
+ | `14` | `yolox` |
85
+ | `15` | `detr` |
86
+
87
+ The IDs must still exist in the current `get_constant` response. Do not substitute display names for IDs in library payloads.
88
+
89
+ reCamera Pro deployment is local device IP/USB (Console workspace). It does not use cloud `update_stream`; the CLI resolver validates metadata but does not pretend to complete physical deployment.
90
+
91
+ ## File & tech metadata
92
+
93
+ | Field | Type | Required | Compliance |
94
+ |-------|------|----------|------------|
95
+ | `file_url` | URL | yes | Via `acquire_file_url` upload (`upload-type` model); http(s); extension must match `model_format` |
96
+ | `checksum` | string | yes in UI | MD5/checksum from upload; keep in sync with `file_url` |
97
+ | `model_size` | number/string | from upload | bytes / display size |
98
+ | `version` | text | yes | exact `major.minor.patch`; major `1–99`, minor/patch `0–99`, no leading zeros; update cannot decrease; unchanged version auto-increments when labels/file changes |
99
+ | `precision` | option | yes | id from `model_precision_array`; CLI rejects unknown ids |
100
+ | `attr.conf` / `attr.iou` | number | Watcher-related | sliders when adapted devices include Watcher |
101
+
102
+ CLI create/update validates the **complete** merged payload (Console save rules) before calling the API: empty/overlong `name`/`description`, missing required fields, invalid option ids (`task`/`scenario`/`precision`/`model_format`), bad labels, device/format matrix, and http(s) `pic_url`/`file_url`. Invalid input → non-zero exit + field-level error (not opaque API text). Sparse update patches are merged with `view_model` first, then validated.
103
+
104
+ ## Visibility lifecycle
105
+
106
+ | `be_public` | Meaning |
107
+ |-------------|---------|
108
+ | `0` | Private (My Models). Delete allowed. |
109
+ | `1` | Public library. **Owner** may edit (re-enters review; CLI `edit_model` sends `be_public=1`). Others: deploy-only, no clone/download/edit. |
110
+ | `2` | Under review. Owner may edit; delete hidden until unpublished. |
111
+
112
+ ### Update API
113
+
114
+ `POST /model/edit_model` requires **`model_id` and `id`** (same value). CLI `model update` sets both.
115
+
116
+ ### Publish API (not the same as apps)
117
+
118
+ `POST /model/publish_model`
119
+
120
+ | Intent | Body |
121
+ |--------|------|
122
+ | Publish to public library | `{ "model_id": <id>, "status": 1 }` |
123
+ | Privatize / unpublish | `{ "model_id": <id>, "status": 0 }` |
124
+
125
+ `model_id` must be a **JSON number** (e.g. `63758`, not `"63758"`). CLI converts a numeric `--id` before POST. String `model_id` returns aiserver **11202**.
126
+
127
+ **L2 user confirmation required.** Do not confuse with app `edit_privacy_app` (`privacy` 2/0).
128
+
129
+ ## Download & invoke
130
+
131
+ | Path | Who | Behavior |
132
+ |------|-----|----------|
133
+ | Detail `file_url` | **Private owner** download in UI / CLI | Console: owner-only file box. CLI: `model download` only when `be_public=0`. Public list/view **omit** `file_url`. |
134
+ | `GET /model/apply_model` | Deploy pipelines (device pull) | Snapshot URL for device apply — **not** a user-facing download for public models. Jetson: `cloud deploy`. reCamera Pro: Console local L3. |
135
+ | CodeCraft | External | If detail or product config exposes workspace/compile invoke links, **return them to the user**. This skill does **not** run CodeCraft compilation. Bases (prod/test) live in Console `envApi` (`codecraftHomeUrl` / `codecraftWorkspaceUrl`). |
136
+
137
+ ## Delete
138
+
139
+ `POST /model/delete_model` with `{ model_id }` — **L2 confirm**; owner **private** only (`be_public=0`). Published / under-review: `model unpublish` first.
@@ -0,0 +1,79 @@
1
+ ---
2
+ name: sensecraft-recamera
3
+ description: >-
4
+ Picks classic reCamera (uniform_type 40) public or My Apps / My Models, checks
5
+ compatibility, then opens the Console AI deploy page so the user flashes over
6
+ IP or USB. Use when the user mentions reCamera, 烧录, 刷机, 部署到 recamera,
7
+ uniform_type 40, or picking a model/app for reCamera. Not reCamera Pro (53),
8
+ not Jetson cloud deploy, not CodeCraft App Square.
9
+ ---
10
+
11
+ # SenseCraft reCamera (classic, uniform_type 40)
12
+
13
+ Orchestration skill: **list → pick → check → open Console → user clicks Deploy**.
14
+
15
+ Parent: [`../sensecraft-ai/SKILL.md`](../sensecraft-ai/SKILL.md).
16
+ List/view/clone: [`../sensecraft-apps/SKILL.md`](../sensecraft-apps/SKILL.md), [`../sensecraft-models/SKILL.md`](../sensecraft-models/SKILL.md).
17
+ Commands: [`commands.md`](commands.md).
18
+
19
+ **This skill does not flash.** Flash is L3 in the browser (IP or USB). There is no `recamera deploy` and no device HTTP in this CLI.
20
+
21
+ ## Agent rules
22
+
23
+ 1. Auth first:
24
+ ```bash
25
+ sensecraft-cli auth info
26
+ ```
27
+ Need **SenseCAP Access Key** (`auth init --kind sensecap`) for `app` / `model` / `recamera`. Never run init for them.
28
+ 2. **Classic reCamera only (`40`)**. Do **not** treat Pro `53`, XIAO `32`, or Grove `36` as the same device. `/ai/recamera` redirects to Grove `36` — do not send users there.
29
+ 3. Filter **only** with API `--uniform-type 40`. Do not guess from local materials, SKU strings, or adapteds-only. Public **and** mine:
30
+ ```bash
31
+ sensecraft-cli app list --public --uniform-type 40
32
+ sensecraft-cli app list --mine --uniform-type 40
33
+ sensecraft-cli model list --public --uniform-type 40
34
+ sensecraft-cli model list --mine --uniform-type 40
35
+ ```
36
+ 4. **Empty list: say so and stop.** Do not drop `--uniform-type` or widen to 53/32.
37
+ 5. After the user picks an app or model, `recamera check`. If `ok` is false, say it is not classic reCamera and stop.
38
+ 6. **Multiple firmwares / models** (`ask_pick: true` or several candidates): **ask again** which one to flash. Do not pick for them.
39
+ 7. Both allowed:
40
+ - Flash the model already on the app `deploy-ai-model` block
41
+ - Flash a **separately picked** model from the 40 list
42
+ 8. **Public models are deploy-only.** Never `model download`, never print `file_url`, never clone a public model into My Models. Private My Models may be used as-is. **Apps may be cloned** (`app clone`, L2) if the user wants their own copy — clone is optional, not required to flash.
43
+ 9. **Do not `cloud deploy`.** That path is Jetson / cloud kit (`26`), not reCamera.
44
+ 10. **`flash-firmware` blocks are out of scope** this pass. Do not invent a firmware-flash CLI.
45
+ 11. After a successful check, if the user wants to flash, run `recamera open` (or `--print-only` if they will paste the URL). Success = they say the Console page worked and they clicked Deploy. Opening a page is **not** an L2 `--yes` write.
46
+ 12. If there is **no device / no IP**: still open the Console deploy page and stop. Do not invent a device protocol. Do not require an IP to confirm.
47
+ 13. Retry list/check/open at most **5 times per run**. Then stop and report the last error.
48
+ 14. CodeCraft App Square is unrelated — do not route plaza-upload work here.
49
+
50
+ ## Typical workflow
51
+
52
+ ```bash
53
+ sensecraft-cli auth info
54
+ sensecraft-cli model list --public --uniform-type 40
55
+ sensecraft-cli app list --public --uniform-type 40
56
+ # optional: mine
57
+ sensecraft-cli model list --mine --uniform-type 40
58
+ sensecraft-cli app list --mine --uniform-type 40
59
+
60
+ sensecraft-cli recamera check --model-id <id>
61
+ # or
62
+ sensecraft-cli recamera check --app-id <id>
63
+
64
+ # After the user chose the item (and, if ask_pick, which firmware):
65
+ sensecraft-cli recamera open --model-id <id>
66
+ # or --print-only if a browser cannot be opened
67
+ ```
68
+
69
+ Then tell the user: on the opened **model/app detail** page, click **Deploy**, connect classic reCamera over **IP or USB**, and finish in Console. Do not download the public weights.
70
+
71
+ ## CLI status
72
+
73
+ | Area | Status |
74
+ |------|--------|
75
+ | `app/model list --uniform-type 40` | **Implemented** |
76
+ | `recamera check` / `recamera open` | **Implemented** (P2) |
77
+ | `app clone` | Use apps skill (L2) |
78
+ | Device flash / `recamera deploy` | **Not implemented** (L3 Console) |
79
+ | `model recamera-pro resolve` | Pro `53` only — not this skill |
@@ -0,0 +1,87 @@
1
+ # sensecraft-recamera — CLI commands
2
+
3
+ Target binary: `sensecraft-cli` (this repo). Auth: active **SenseCAP Access Key** (`auth init --kind sensecap`) → `{ai-host}/openapi`.
4
+
5
+ > Status: **shipped (P1 list + P2 check/open)**. Flash stays in Console. There is no `recamera deploy`.
6
+
7
+ ## Auth prerequisite
8
+
9
+ ```bash
10
+ sensecraft-cli auth info
11
+ sensecraft-cli auth init --kind sensecap # user only, interactive
12
+ ```
13
+
14
+ ## List (existing commands)
15
+
16
+ Always pass `--uniform-type 40`. Empty list → stop.
17
+
18
+ ```bash
19
+ sensecraft-cli app list --public --uniform-type 40
20
+ sensecraft-cli app list --mine --uniform-type 40
21
+ sensecraft-cli model list --public --uniform-type 40
22
+ sensecraft-cli model list --mine --uniform-type 40
23
+ ```
24
+
25
+ ## `recamera check`
26
+
27
+ **Status: implemented.**
28
+
29
+ Verify the id is classic reCamera (`40`). Does not open a browser.
30
+
31
+ | Flag | Required | Notes |
32
+ | ------------ | -------- | ------------------------------------------ |
33
+ | `--model-id` | one of | Model id |
34
+ | `--app-id` | one of | App id |
35
+ | `--sandbox` | no | Sample JSON, no network |
36
+
37
+ Exactly one of `--model-id` / `--app-id`.
38
+
39
+ Stdout JSON includes `ok`, `device` (40), `flash` (`local`), `console_url`, `candidates`, `ask_pick`.
40
+ `ok=false` → non-zero exit. Do not loosen the filter.
41
+
42
+ ```bash
43
+ sensecraft-cli recamera check --model-id <model_id>
44
+ sensecraft-cli recamera check --app-id <app_id>
45
+ ```
46
+
47
+ If `ask_pick` is true, ask the user which candidate to flash.
48
+
49
+ ## `recamera open`
50
+
51
+ **Status: implemented.**
52
+
53
+ Runs the same check, then opens `console_url` (or prints it). Sandbox never opens a browser.
54
+
55
+ | Flag | Required | Notes |
56
+ | ------------- | -------- | --------------------------------------------- |
57
+ | `--model-id` | one of | Model detail = AI deploy page (click 部署) |
58
+ | `--app-id` | one of | App detail; plaza omits `from=my-apps` |
59
+ | `--print-only`| no | Print URL only |
60
+ | `--sandbox` | no | Sample JSON; never open a browser |
61
+
62
+ ```bash
63
+ sensecraft-cli recamera open --model-id <model_id>
64
+ sensecraft-cli recamera open --app-id <app_id> --print-only
65
+ ```
66
+
67
+ `console_url` is `/ai/model/detail?id=…` or `/ai/application/detail/…`.
68
+ **Not** `/ai/device/local/40` (that family is 32/36/37/41/52). **Not** `/ai/recamera` (301 → Grove 36).
69
+
70
+ ## Out of scope
71
+
72
+ | Action | What to do instead |
73
+ |--------|--------------------|
74
+ | `cloud deploy` | Jetson / cloud kit only |
75
+ | Public model download / clone | Refuse; deploy-only |
76
+ | `recamera deploy` / device HTTP | Do not invent; user flashes in Console |
77
+ | `flash-firmware` block | Later |
78
+ | reCamera Pro `53` | `sensecraft-models` + `model recamera-pro resolve` |
79
+ | CodeCraft App Square | Unrelated |
80
+
81
+ ## Optional: clone an app first (L2)
82
+
83
+ ```bash
84
+ sensecraft-cli app clone --id <app_id> --agree-disclaimer --yes
85
+ ```
86
+
87
+ Follow [`../confirmation.md`](../confirmation.md). Clone is not required to open the plaza app and click Deploy.