tirtc-device-builder 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,7 @@ import {
12
12
  import { homedir } from "node:os";
13
13
  import { dirname, join, resolve } from "node:path";
14
14
  import { fileURLToPath } from "node:url";
15
+ import { runEsp32Setup } from "./setup-esp32.js";
15
16
 
16
17
  const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
17
18
  const PACKAGE = JSON.parse(
@@ -35,6 +36,7 @@ function printHelp() {
35
36
  Usage:
36
37
  tirtc-device-builder list
37
38
  tirtc-device-builder install <platform> [--skills-dir <path>] [--force]
39
+ tirtc-device-builder setup <platform> [setup options]
38
40
  tirtc-device-builder doctor <platform> [doctor options]
39
41
  tirtc-device-builder --version
40
42
 
@@ -43,11 +45,14 @@ Platforms:
43
45
 
44
46
  Examples:
45
47
  npx tirtc-device-builder install esp32
48
+ npx tirtc-device-builder setup esp32
49
+ npx tirtc-device-builder setup esp32 --install
46
50
  npx tirtc-device-builder install esp32 --skills-dir /absolute/path/skills
47
51
  npx tirtc-device-builder doctor esp32 --project /absolute/path/project
48
52
 
49
53
  Install defaults to ${"$"}{CODEX_HOME:-~/.codex}/skills. Existing skills are
50
- preserved unless --force is explicitly supplied.`);
54
+ preserved unless --force is explicitly supplied. Setup checks are read-only;
55
+ setup --install installs missing user-space components without running sudo.`);
51
56
  }
52
57
 
53
58
  function fail(message) {
@@ -187,7 +192,7 @@ function main(args) {
187
192
  }
188
193
 
189
194
  const [command, identifier, ...rest] = args;
190
- if (command !== "install" && command !== "doctor") {
195
+ if (command !== "install" && command !== "doctor" && command !== "setup") {
191
196
  return fail(`unknown command: ${command}; run with --help`);
192
197
  }
193
198
  if (!identifier) {
@@ -201,6 +206,18 @@ function main(args) {
201
206
  if (command === "doctor") {
202
207
  return runDoctor(platform, rest);
203
208
  }
209
+ if (command === "setup") {
210
+ if (platform.name !== "esp32") {
211
+ return fail(`setup is not available for platform: ${platform.name}`);
212
+ }
213
+ return runEsp32Setup(rest, {
214
+ cliPath: fileURLToPath(import.meta.url),
215
+ defaultSkillsDir: defaultSkillsDir(),
216
+ packageRoot: PACKAGE_ROOT,
217
+ packageVersion: PACKAGE.version,
218
+ platform,
219
+ });
220
+ }
204
221
 
205
222
  try {
206
223
  const options = parseInstallOptions(rest);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tirtc-device-builder",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Install and run TiRTC device-development skills for Codex.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -45,6 +45,7 @@
45
45
  "registry": "https://registry.npmjs.org/"
46
46
  },
47
47
  "scripts": {
48
+ "pack:esp32-kit": "node scripts/pack-esp32-kit.js",
48
49
  "test": "npm run test:node && npm run test:python && npm run validate && npm run validate:tarball && npm run test:package",
49
50
  "test:node": "node --test test/*.test.js",
50
51
  "test:python": "python3 -m unittest discover -s skills/tirtc-esp32-builder/scripts -p 'test_*.py'",
@@ -9,15 +9,16 @@ Turn board evidence into an evidence-backed ESP-IDF project. Treat the Hardware
9
9
 
10
10
  ## Start
11
11
 
12
- 1. Locate the ThingConnect root containing `device-sim/` using the explicit input, `TIRTC_THING_CONNECT_ROOT`, or workspace discovery. Read its applicable `AGENTS.md` and preserve its public protocol contracts.
13
- 2. Read [environment.md](references/environment.md) and run `python3 <skill-dir>/scripts/doctor.py --expected-idf 5.5 --target esp32s3`. Add `--require-workspace` when generation or repository reference documents are needed; a self-contained generated project can instead resolve its bundled SDK through `--project`. Resolve every required failure before claiming build readiness. Installation, cloning, or shell-profile changes require an explicit destination and the applicable authorization.
14
- 3. Read [workflow.md](references/workflow.md). Select the registered-board, new-board intake, or existing-project branch. The branch is selected when every supplied artifact has been accounted for and the exact board revision is known or explicitly unresolved.
15
- 4. Read [hardware-ir.md](references/hardware-ir.md) when a Hardware IR must be created or updated. Record a source and verification level for every hardware fact that affects a requested feature.
16
- 5. Run `python3 <skill-dir>/scripts/hardware_ir.py validate <hardware-ir.json>` and then `assess --strict`. Generation may proceed for a requested feature only when it is `READY_TO_PORT` or `HIL_VERIFIED`; otherwise report the exact missing evidence and continue with safe discovery or scaffolding only.
12
+ 1. Read [environment.md](references/environment.md). For a first-time setup or a request to check/install prerequisites, prefer `npx tirtc-device-builder@latest setup esp32`. Run its `--install` mode only when the user explicitly authorizes installation at the displayed destinations. The installer may create user-space files but never grants permission for `sudo` or persistent shell-profile edits.
13
+ 2. Locate the versioned ESP32 Device Kit root containing `device-sim/` using the explicit input, `TIRTC_THING_CONNECT_ROOT`, the managed setup configuration, or workspace discovery. Treat its manifest and packaged protocol documents as the generation facts. If the user explicitly supplies a full ThingConnect source workspace, also read its applicable `AGENTS.md`.
14
+ 3. Run the Doctor through the managed environment helper when one exists; otherwise run `python3 <skill-dir>/scripts/doctor.py --expected-idf 5.5 --target esp32s3`. Add `--require-workspace` when generation or repository reference documents are needed; a self-contained generated project can instead resolve its bundled SDK through `--project`. Resolve every required failure before claiming build readiness.
15
+ 4. Read [workflow.md](references/workflow.md). Select the registered-board, new-board intake, or existing-project branch. The branch is selected when every supplied artifact has been accounted for and the exact board revision is known or explicitly unresolved.
16
+ 5. Read [hardware-ir.md](references/hardware-ir.md) when a Hardware IR must be created or updated. Record a source and verification level for every hardware fact that affects a requested feature.
17
+ 6. Run `python3 <skill-dir>/scripts/hardware_ir.py validate <hardware-ir.json>` and then `assess --strict`. Generation may proceed for a requested feature only when it is `READY_TO_PORT` or `HIL_VERIFIED`; otherwise report the exact missing evidence and continue with safe discovery or scaffolding only.
17
18
 
18
19
  ## Build the project
19
20
 
20
- Run `<thing-connect-root>/device-sim/scripts/create_esp32_project.py` for the current ESP32-S3 H5/AI starter. Keep ThingConnect onboarding, H5, AI, TiRTC lifecycle, callback, stream, and generation behavior in the existing deep modules. Put board-specific camera, microphone, encoder, codec, amplifier, GPIO, DMA, and task behavior behind the `starter_media` seam or a board media adapter owned by it.
21
+ Run `<device-kit-root>/device-sim/scripts/create_esp32_project.py` for the current ESP32-S3 H5/AI starter. Keep ThingConnect onboarding, H5, AI, TiRTC lifecycle, callback, stream, and generation behavior in the existing deep modules. Put board-specific camera, microphone, encoder, codec, amplifier, GPIO, DMA, and task behavior behind the `starter_media` seam or a board media adapter owned by it.
21
22
 
22
23
  Before changing media code, read [capability-rules.md](references/capability-rules.md) and the repository documents it routes to. A camera sensor alone does not establish H5 video support; the complete H.264 Annex-B and key-frame path must be evidenced. Choose half duplex for AI when the supplied hardware and BSP do not establish a usable full-duplex/AEC path.
23
24
 
@@ -1,5 +1,14 @@
1
1
  # TiRTC ESP32 Builder 使用说明
2
2
 
3
+ ## 一键准备
4
+
5
+ ```bash
6
+ npx tirtc-device-builder@latest setup esp32
7
+ npx tirtc-device-builder@latest setup esp32 --install
8
+ ```
9
+
10
+ 第一条命令只检查;第二条命令自动安装用户目录内缺失的 Skill、带校验的 ESP32 Device Kit、ESP-IDF 5.5.4 和 ESP32-S3 工具链,最后复跑 Doctor。它不执行 `sudo`,也不修改 shell 配置。安装完成后新开 Codex 会话即可调用 Skill。
11
+
3
12
  安装后可在 Codex 中显式调用:
4
13
 
5
14
  ```text
@@ -14,25 +23,21 @@ $tirtc-esp32-builder
14
23
  - 产品页或资料链接:...
15
24
  - 原理图:/absolute/path/board-schematic.pdf
16
25
  - BSP 或示例工程:/absolute/path/vendor-bsp
17
- - ThingConnect:/absolute/path/tirtc-server-example/thing-connect
18
26
  - 输出目录:/absolute/path/my-tirtc-device
19
27
 
20
28
  先完成能力分析;具备条件后生成并编译。只有我明确指定串口时才烧录。
21
29
  ```
22
30
 
23
- ## ThingConnect 工作区
31
+ ## ESP32 Device Kit
24
32
 
25
- 这个 Skill 不复制 ThingConnect 源码和 TiRTC 静态库。首次使用可以准备公开仓库:
33
+ 一键安装会下载固定版本的最小资源包并校验 SHA-256,不需要克隆 ThingConnect 服务端仓库。安装路径由下面的文件记录:
26
34
 
27
35
  ```bash
28
- git clone https://github.com/tangeai/tirtc-server-example.git \
29
- /absolute/path/tirtc-server-example
30
-
31
- export TIRTC_THING_CONNECT_ROOT=\
32
- /absolute/path/tirtc-server-example/thing-connect
36
+ source ~/.tirtc-device-builder/env.sh
37
+ printf '%s\n' "$TIRTC_THING_CONNECT_ROOT"
33
38
  ```
34
39
 
35
- 也可以在调用 Skill 时直接给出 ThingConnect 绝对路径,不需要设置持久环境变量。
40
+ 已有完整 ThingConnect 工作区仍可通过 `--thing-connect-root` 显式复用,主要用于维护模板或协议时的开发场景。
36
41
 
37
42
  ## 常见输入方式
38
43
 
@@ -45,7 +50,7 @@ $tirtc-esp32-builder 分析 <厂商> <型号> <硬件版本>,目标是 H5 实
45
50
  提供本地资料:
46
51
 
47
52
  ```text
48
- $tirtc-esp32-builder 使用原理图 /path/board.pdf、BSP /path/vendor-project 和 ThingConnect /path/tirtc-server-example/thing-connect,为该板生成 TiRTC H5/AI ESP-IDF 工程并编译。
53
+ $tirtc-esp32-builder 使用原理图 /path/board.pdf、BSP /path/vendor-project 和一键安装的 Device Kit,为该板生成 TiRTC H5/AI ESP-IDF 工程并编译。
49
54
  ```
50
55
 
51
56
  完整实机流程:
@@ -64,7 +69,7 @@ $tirtc-esp32-builder 使用 /path/hardware-ir.json 生成工程,编译后烧
64
69
  python3 <skill-dir>/scripts/doctor.py \
65
70
  --expected-idf 5.5 \
66
71
  --target esp32s3 \
67
- --thing-connect-root /absolute/path/tirtc-server-example/thing-connect \
72
+ --thing-connect-root ~/.tirtc-device-builder/kits/esp32s3/1.0.0 \
68
73
  --require-workspace
69
74
  ```
70
75
 
@@ -1,5 +1,26 @@
1
1
  # ESP-IDF environment
2
2
 
3
+ ## Managed one-command setup
4
+
5
+ Prefer the packaged setup entrypoint for a new machine:
6
+
7
+ ```bash
8
+ npx tirtc-device-builder@latest setup esp32
9
+ npx tirtc-device-builder@latest setup esp32 --install
10
+ ```
11
+
12
+ The first command is read-only. The second command is explicit authorization to install missing user-space components at the printed destinations. Its default root is `~/.tirtc-device-builder`; it downloads and verifies the pinned ESP32 Device Kit, installs the Skill, clones or reuses ESP-IDF 5.5.4, runs Espressif's `install.sh esp32s3`, writes `config.json` and `env.sh`, and reruns the Doctor inside the activated environment.
13
+
14
+ The automatic branch never runs `sudo` or modifies a persistent shell profile. When system dependencies are missing, report its exact blocker and let the user perform the displayed system action. Existing incomplete directories are preserved as blockers. Rerunning the same command resumes completed stages.
15
+
16
+ When `<setup-root>/env.sh` exists, use it only as an activation prefix for the current command:
17
+
18
+ ```bash
19
+ bash -lc '. "<setup-root>/env.sh" && python3 "<skill-dir>/scripts/doctor.py" --expected-idf 5.5 --target esp32s3 --require-workspace'
20
+ ```
21
+
22
+ The helper contains paths, not device or network credentials. Read `<setup-root>/config.json` when exact managed paths are needed; the environment helper does not authorize unrelated downloads, shell-profile changes, flashing, or credential writes.
23
+
3
24
  Run the doctor before generation, build, flash, or monitor:
4
25
 
5
26
  ```bash
@@ -11,18 +32,18 @@ python3 <skill-dir>/scripts/doctor.py \
11
32
 
12
33
  Add `--project <generated-project>` after generation so the doctor can compare `sdkconfig` or `sdkconfig.defaults` with the TiRTC SDK build contract. Use `--json` when the result will be included in another report.
13
34
 
14
- ## ThingConnect workspace
35
+ ## ESP32 Device Kit
15
36
 
16
- This distributable skill does not bundle the ThingConnect source tree or TiRTC static library. Resolve the public ThingConnect workspace in this order:
37
+ The automatic setup downloads a versioned minimal Kit instead of cloning the ThingConnect server repository. Resolve the generation root in this order:
17
38
 
18
39
  1. an explicit `--thing-connect-root <path>`;
19
40
  2. `TIRTC_THING_CONNECT_ROOT`;
20
41
  3. an ancestor of the project or current directory containing `device-sim/scripts/create_esp32_project.py`;
21
42
  4. an ancestor whose `thing-connect/` child contains that generator.
22
43
 
23
- The public source is `https://github.com/tangeai/tirtc-server-example`. Clone it only into an explicit destination. The root accepted by the doctor may be either the repository root or its `thing-connect/` child.
44
+ The default managed root is `<setup-root>/kits/esp32s3/<kit-version>`. The public ThingConnect workspace remains an optional legacy/development input; the doctor accepts either a Device Kit root, a repository root, or its `thing-connect/` child.
24
45
 
25
- SDK resolution is independent after generation: an explicit `--sdk-dir` wins, followed by `<project>/third_party/tirtc`, then the SDK packaged in the resolved ThingConnect workspace. The generated project path therefore remains diagnosable after it is moved away from the source repository.
46
+ SDK resolution is independent after generation: an explicit `--sdk-dir` wins, followed by `<project>/third_party/tirtc`, then the SDK packaged in the resolved Device Kit or legacy workspace. The generated project remains diagnosable after it is moved away from the Kit.
26
47
 
27
48
  ## Required checks
28
49
 
@@ -204,7 +204,7 @@ def resolve_sdk_dir(
204
204
  if bundled.is_dir():
205
205
  return bundled, "generated project"
206
206
  if thing_connect_root is not None:
207
- return thing_connect_root / DEFAULT_SDK_RELATIVE_PATH, "ThingConnect workspace"
207
+ return thing_connect_root / DEFAULT_SDK_RELATIVE_PATH, "Device Kit or legacy workspace"
208
208
  return None, "not found"
209
209
 
210
210
 
@@ -272,7 +272,7 @@ def diagnose(args: argparse.Namespace) -> dict[str, Any]:
272
272
  )
273
273
  checks.append(
274
274
  check(
275
- "ThingConnect workspace",
275
+ "ESP32 Device Kit",
276
276
  workspace_status,
277
277
  (
278
278
  f"{thing_connect_root} ({thing_connect_source})"
@@ -286,7 +286,7 @@ def diagnose(args: argparse.Namespace) -> dict[str, Any]:
286
286
  )
287
287
  if args.require_workspace and thing_connect_root is None:
288
288
  next_actions.append(
289
- "Clone the public ThingConnect repository or pass its absolute path with "
289
+ "Run setup esp32 --install or pass an existing Device Kit path with "
290
290
  "--thing-connect-root."
291
291
  )
292
292
 
@@ -414,7 +414,7 @@ def parse_args() -> argparse.Namespace:
414
414
  parser.add_argument(
415
415
  "--require-workspace",
416
416
  action="store_true",
417
- help="fail when a ThingConnect workspace with the ESP32 generator is unavailable",
417
+ help="fail when a Device Kit or legacy workspace with the ESP32 generator is unavailable",
418
418
  )
419
419
  parser.add_argument("--sdk-dir", type=Path)
420
420
  parser.add_argument("--project", type=Path)