@seeed-studio/sensecraft-cli 0.2.1 → 0.2.2

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.
@@ -43,7 +43,7 @@ async function main() {
43
43
  await runInstall();
44
44
  } catch (err) {
45
45
  console.error('');
46
- console.error('安装失败:', err.message);
46
+ console.error('Install failed:', err.message);
47
47
  console.error('');
48
48
  process.exit(1);
49
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seeed-studio/sensecraft-cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "SenseCAP / SenseCraft AI cloud CLI (devices, apps, models, files, cloud deploy)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,7 +27,7 @@ function getGlobalCliPath() {
27
27
 
28
28
  function installGlobally() {
29
29
  const packageRoot = getPackageRoot();
30
- console.log('正在全局安装 sensecraft-cli...');
30
+ console.log('Installing sensecraft-cli globally...');
31
31
  execSync(`npm install -g ${JSON.stringify(packageRoot)}`, {
32
32
  stdio: 'inherit',
33
33
  env: process.env,
@@ -35,7 +35,7 @@ function installGlobally() {
35
35
 
36
36
  const cliPath = getGlobalCliPath();
37
37
  if (!fs.existsSync(cliPath)) {
38
- throw new Error(`全局命令未找到: ${cliPath},请确认 npm 全局 bin 目录在 PATH 中`);
38
+ throw new Error(`Global command not found: ${cliPath}. Add the npm global bin directory to PATH.`);
39
39
  }
40
40
  return cliPath;
41
41
  }
@@ -43,20 +43,20 @@ function installGlobally() {
43
43
  function runInitIfNeeded(cliPath) {
44
44
  if (isInitialized()) {
45
45
  console.log('');
46
- console.log('✓ 配置文件已存在,跳过初始化');
46
+ console.log('Config file already exists; skipped initialization');
47
47
  console.log(' sensecraft-cli auth info');
48
48
  return;
49
49
  }
50
50
 
51
51
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
52
52
  console.log('');
53
- console.log('未检测到交互式终端,已跳过自动初始化。');
54
- console.log('请稍后运行: sensecraft-cli auth init');
53
+ console.log('No interactive terminal; skipped automatic initialization.');
54
+ console.log('Run later: sensecraft-cli auth init');
55
55
  return;
56
56
  }
57
57
 
58
58
  console.log('');
59
- console.log('未检测到配置文件,开始自动初始化...');
59
+ console.log('No config file found; starting initialization...');
60
60
  console.log('');
61
61
 
62
62
  const result = spawnSync(cliPath, ['auth', 'init'], {
@@ -76,12 +76,12 @@ function runInitIfNeeded(cliPath) {
76
76
  function printDone(globalCliPath) {
77
77
  const globalBin = getGlobalBinDir();
78
78
  console.log('');
79
- console.log('✓ 安装完成');
80
- console.log(` 命令: sensecraft-cli`);
81
- console.log(` 路径: ${globalCliPath}`);
79
+ console.log('Install complete');
80
+ console.log(' Command: sensecraft-cli');
81
+ console.log(` Path: ${globalCliPath}`);
82
82
  if (!process.env.PATH || !process.env.PATH.split(path.delimiter).includes(globalBin)) {
83
83
  console.log('');
84
- console.log('提示: 若无法直接运行 sensecraft-cli,请将以下目录加入 PATH:');
84
+ console.log('If sensecraft-cli is not on PATH, add this directory:');
85
85
  console.log(` ${globalBin}`);
86
86
  }
87
87
  console.log('');
@@ -62,7 +62,7 @@ China 与 Global 使用同一个 AI host,账号中心不同。网页控制台
62
62
  | App fields / tool-blocks / BOM guidance | same apps skill references | `sensecap` | Config OK; real flash = L3 |
63
63
  | Author a new app (create + info + images + BOM + blocks) | [`sensecraft-apps/create-app`](../sensecraft-apps/create-app/SKILL.md) | `sensecap` | One batch confirmation; stops before publish |
64
64
  | Create / update / publish / unpublish / delete / bom app | same + `app …` / `app bom …` | `sensecap` | **CLI shipped** (L2 `--yes`; publish also `--agree-declaration`; bare `create --name` not L2) |
65
- | Upload image/file/firmware/doc/archive and obtain `file_url` | [`sensecraft-files`](../sensecraft-files/SKILL.md) + `file upload` | `sensecap` | Types `1`–`2` require `--model-id`/`--app-id --yes`/`--for-app`/`--unlinked`; types `3`–`6` direct |
65
+ | Upload image/file/firmware/static/archive and obtain `file_url` | [`sensecraft-files`](../sensecraft-files/SKILL.md) + `file upload` | `sensecap` | 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`](../sensecraft-models/SKILL.md) | `sensecap` | **CLI shipped** |
67
67
  | Upload / publish / unpublish / delete model | same + `model upload --id --yes` / `create\|update\|publish\|unpublish\|delete` | `sensecap` | Attach bumps patch version like Console |
68
68
  | Classic reCamera (`40`) pick / check / open deploy page | [`sensecraft-recamera`](../sensecraft-recamera/SKILL.md) + `app/model list --uniform-type 40` + `recamera check` / `open` | `sensecap` | **CLI shipped**. Flash is Console L3 (IP/USB). Not `cloud deploy`. Not Pro `53`. |
@@ -105,7 +105,7 @@ SenseCAP telemetry → pick public model → deploy to Jetson:
105
105
  Published commands use **SenseCAP Access Key** (`kind=sensecap`) → `{ai-host}/openapi`:
106
106
 
107
107
  1. **Apps** — list/view/fields/blocks; create/update; publish/unpublish/delete (L2); BOM search/list/set; tool-block config via JSON (real flash = L3).
108
- 2. **Files** — `file upload` for image/model/app/firmware/doc/archive; types 1–2 require `--model-id` / `--app-id --yes` / `--for-app` / `--unlinked` before PUT (bare upload fails).
108
+ 2. **Files** — `file upload` for image/model/app/firmware/static/archive; types 1–2 require `--model-id` / `--app-id --yes` / `--for-app` / `--unlinked` before the OSS POST (bare upload fails). Type 5 also requires `--flow-id`.
109
109
  3. **Model library** — list/view/constants; **private** download only; public models deploy-only (no `file_url`); `model upload --id --yes` attaches and auto-bumps patch version; create/update; publish/unpublish/delete (L2).
110
110
  4. **Cloud devices** — `cloud device` / `cloud deploy` / `cloud order`.
111
111
  5. **Classic reCamera 40** — `recamera check` / `recamera open` (Console AI deploy page; flash is L3).
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: sensecraft-files
3
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
4
+ Uploads images, model binaries, app files, firmware, static resources, and archives
5
+ to SenseCraft AI with acquire_file_url + OSS form POST. Use when another workflow needs
6
6
  a file_url. Requires Access Key (`auth init --kind sensecap`).
7
7
  ---
8
8
 
@@ -14,23 +14,23 @@ Auth: **Access Key** → `{ai-host}/openapi`. Parent: [`../sensecraft-ai/SKILL.m
14
14
 
15
15
  1. Run `sensecraft-cli auth info` first.
16
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
17
+ - `1` image — **≤5 MB** (model `pic_url` and app `images[]`); JPG/JPEG/PNG/GIF/WebP; no SVG
18
18
  - `2` generic file / model (default; **≤100 MB**)
19
19
  - `3` app (**≤100 MB**)
20
20
  - `4` firmware (**≤100 MB**)
21
- - `5` document (**≤100 MB**)
21
+ - `5` static resource (**≤100 MB**; **`--flow-id` required**)
22
22
  - `6` archive / ZIP (**≤100 MB**)
23
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):
24
+ 4. **Attach before upload.** Types `1`/`2` refuse the OSS POST without association. If the user provides a file without a model/app id, **ask first** (do not call upload):
25
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
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`.
27
+ - Model example image (`pic_url`): `file upload --path <img> --type 1 --unlinked` (**5 MB**), then put `file_url` into model JSON as `pic_url`.
28
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
29
  5. Treat returned signed/upload URLs and private file URLs as secrets.
30
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
31
  7. Do not pass oversized files or more than 16 app image URLs; CLI rejects them before upload/update.
32
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 ≤ **100 MB**; images 2 MB (model) / 5 MB (app). Upload frequency is enforced by the server, not this CLI.
33
+ 9. **Security gates**: empty (0 B) files rejected; type 2–6 ≤ **100 MB**; every image ≤ **5 MB**. The CLI does not count uploads. A rate limit comes back as `11209` or `11210`.
34
34
 
35
35
  ## Examples
36
36
 
@@ -44,15 +44,15 @@ sensecraft-cli file upload --path ./cover.png --type 1 --app-id <app_id> --yes
44
44
  # Unlinked app image for later images[] JSON:
45
45
  sensecraft-cli file upload --path ./cover.png --type 1 --for-app
46
46
 
47
- # Model inference example image → pic_url (2 MB)
47
+ # Model inference example image → pic_url (5 MB)
48
48
  sensecraft-cli file upload --path ./demo.png --type 1 --unlinked
49
49
 
50
50
  # Unlinked only when creating a brand-new model (then put file_url into model create)
51
51
  sensecraft-cli model upload --path ./model.rknn --unlinked
52
52
 
53
- # Firmware, document, and archive (no model/app attach)
53
+ # Firmware, static resource, and archive (no model/app attach)
54
54
  sensecraft-cli file upload --path ./firmware.bin --type 4 --checksum
55
- sensecraft-cli file upload --path ./guide.pdf --type 5
55
+ sensecraft-cli file upload --path ./guide.pdf --type 5 --flow-id <flow_id>
56
56
  sensecraft-cli file upload --path ./dataset.zip --type 6 --checksum
57
57
 
58
58
  # Offline exercise: no network
@@ -4,31 +4,32 @@ Binary: `sensecraft-cli`. Auth: Access Key (`auth init --kind sensecap`).
4
4
 
5
5
  ## `file upload`
6
6
 
7
- Acquires an upload URL, PUTs the local bytes, and prints the permanent `file_url`.
7
+ Acquires an OSS POST policy, uploads the local file with multipart/form-data, and prints the permanent `file_url`.
8
8
 
9
9
  | Flag | Required | Default | Notes |
10
10
  |------|----------|---------|-------|
11
11
  | `--path` | yes | — | Local file |
12
- | `--type` | no | `2` | `1=image`, `2=file/model`, `3=app`, `4=firmware`, `5=doc`, `6=archive/zip` |
12
+ | `--type` | no | `2` | `1=image`, `2=file/model`, `3=app`, `4=firmware`, `5=static resource`, `6=archive/zip` |
13
+ | `--flow-id` | type 5 | — | Required for static resources; omitted for other types |
13
14
  | `--checksum` | no | false | Compute local MD5 and include it in output |
14
15
  | `--model-id` | no | — | Attach to this model (implies type=2 + checksum; **L2 `--yes`**; bumps version) |
15
16
  | `--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
+ | `--for-app` | no | false | Unlinked type-1 for later app `images[]` JSON (same **5 MB** cap as every image) |
17
18
  | `--unlinked` | types 1–2 | — | Explicit orphan opt-in for later create/update JSON; required when no `--model-id`/`--app-id`/`--for-app` |
18
19
  | `--yes` | with attach | — | Required when `--model-id` or `--app-id` is set |
19
20
  | `--sandbox` | no | false | No network; return sample JSON |
20
21
 
21
- **Size / format (Console `upload.vue` / `infoForm` / `model/add.vue`):**
22
+ **Size / format:**
22
23
 
23
24
  | type | Max size | Formats / notes |
24
25
  |------|----------|-----------------|
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 |
26
+ | `1` image (model `pic_url` and app `images[]`) | **5 MB** | JPG/JPEG/PNG/GIF/WebP (SVG rejected); app `images[]` max **16** |
27
+ | `2`–`4`, `6` | **100 MB** | suffix not checked locally |
28
+ | `5` static resource | **100 MB** | requires `--flow-id` |
28
29
 
29
30
  `app create/update --from-json` with `images[]` also enforces **max 16** URLs (Console `maxImageCount`).
30
31
 
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
+ `--model-id` and `--app-id` are mutually exclusive. Types `1`/`2` without attach/`--for-app`/`--unlinked` exit non-zero **before** the OSS POST (`ErrAttachRequired`). Types `3`–`6` upload directly. Type `5` without `--flow-id` exits before acquire.
32
33
 
33
34
  ```bash
34
35
  sensecraft-cli file upload --path ./cover.png --type 1 --for-app
@@ -38,7 +39,7 @@ sensecraft-cli file upload --path ./model.rknn --type 2 --checksum --unlinked
38
39
  sensecraft-cli file upload --path ./model.rknn --model-id <model_id> --yes
39
40
  sensecraft-cli file upload --path ./application.zip --type 3 --checksum
40
41
  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 ./manual.pdf --type 5 --flow-id <flow_id>
42
43
  sensecraft-cli file upload --path ./dataset.zip --type 6 --checksum
43
44
  ```
44
45
 
@@ -167,7 +167,7 @@ Detection framework→algorithm and full upload constraints are in [reference-mo
167
167
  | Supported devices | `adapteds` / `uniform_types` | multi-select device types |
168
168
  | Tech | `version`, `precision`, `checksum`, `model_size`, `attr.conf`/`iou` | device-dependent |
169
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`) |
170
+ | Cover / demo | `pic_url` | inference example image (required on create UI; **≤5 MB** when uploading with `file upload --type 1`) |
171
171
  | Visibility | `be_public` | `0` private · `1` public · `2` under review (display) |
172
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
173
 
@@ -109,7 +109,7 @@ Unsupported combinations print structured JSON and exit non-zero.
109
109
  | `--yes` | with `--id` | L2; without it, attach does **not** upload |
110
110
  | `--sandbox` | no | Sample JSON, no network |
111
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`.
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** the OSS upload. Interactive TTY guides association; agents must ask the user first. JSON includes `attached`, `model_id`, `previous_version`, `version`.
113
113
 
114
114
  ```bash
115
115
  # Existing model: attach + bump version
@@ -9,7 +9,7 @@ Aligned with Console `views/model/add.vue`, `detail.vue`, and `constants/sensecr
9
9
  | `name` | text | yes | max **64** (`SENSECRAFT_MODEL_NAME_MAX_LENGTH`); trim before API |
10
10
  | `description` | text | yes | max **300** |
11
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 |
12
+ | `pic_url` | image URL | yes | inference example image; upload via `file upload --type 1` (**≤5 MB**); JPG/PNG/GIF/WebP; must be http(s) URL |
13
13
  | `scenario` | option | yes | id from `get_constant` **`scenarios_array`** (not app `app_scenarios_array`); CLI rejects unknown ids |
14
14
  | `precision` | option | yes | id from **`model_precision_array`** (1=INT8, 2=FLOAT16, 3=FLOAT32 typical); CLI rejects unknown ids |
15
15
  | `file_url` | URL | yes | model binary URL; http(s); extension must match `model_format` |