@realsee/vr-cli 0.1.5 → 0.2.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.
package/README.md CHANGED
@@ -5,7 +5,8 @@
5
5
  ## 核心能力
6
6
 
7
7
  - 通过 `create` 创建 Viewer 项目并安装依赖。
8
- - 通过 `doctor` 检查开发环境、项目结构、依赖配置和关键实现约束。
8
+ - 生成项目通过 `npm run package:vibe-release` 完成干净构建并输出可上传的 Vibe Release 源码 ZIP。
9
+ - 通过 `doctor` 检查开发环境、项目结构、发布清单、依赖配置和关键实现约束。
9
10
  - 通过 `policy` 输出版本化的空间能力策略。
10
11
 
11
12
  ## 安装与执行
@@ -41,13 +42,14 @@ CI 和自动化生成流程应使用明确版本。当前版本示例:
41
42
 
42
43
  ```bash
43
44
  npm exec --yes \
44
- --package=@realsee/vr-cli@0.1.5 \
45
+ --package=@realsee/vr-cli@0.2.0 \
45
46
  -- vr-cli create ./my-vrapp --no-install
46
47
 
47
48
  cd ./my-vrapp
48
49
  npm ci
49
50
  npm run check
50
51
  npm run build
52
+ npm run package:vibe-release
51
53
  ```
52
54
 
53
55
  ## 快速开始
@@ -59,9 +61,18 @@ cd ./my-vrapp
59
61
  npm run setup
60
62
  ```
61
63
 
62
- 在 Realsee China Portal 的 onboarding 页面完成组织、开发者应用和空间项目选择,点击“复制本地配置”,将单行 `realsee-setup:v1:...` 配置包粘贴到隐藏输入中。配置包由 UTF-8 JSON 经 Base64URL 编码,兼容 Windows、macOS 和 Linux;Base64URL 仅提供稳定的单行传输格式,不是加密。不要把配置包放入聊天、命令参数、管道、重定向、Shell 历史、源码或日志。
64
+ `npm run setup` 默认走 Portal 配对:命令打印验证链接与 `XXXX-XXXX` 短码,用户在浏览器中打开链接核对并确认,命令轮询到服务端终态后原子写入 gitignored 的服务端 `.env.development`。只把命令最终输出交给用户的 Agent harness 必须使用分段流程:
63
65
 
64
- `npm run setup` 校验 AK、SK 和 `resourceCode` 后,原子写入 gitignored 的服务端 `.env.development`。POSIX 系统使用 `0600`,Windows 使用当前用户 ACL。首次接入未成功时可以重新运行同一命令并完整覆盖本地配置;首次运行后的凭据轮换和默认项目切换属于独立管理流程。
66
+ ```bash
67
+ npm run setup -- --no-wait --json # 输出 {ok:true,data:{status:"pending",...}},退出码 2
68
+ npm run setup -- --complete # 用户确认后执行,轮询到终态并写盘
69
+ ```
70
+
71
+ `poll_secret` 不进入 stdout、日志或命令行参数,只存在于进程内存与 `0600`、已 gitignore 的 `.realsee/pairing-continuation.json`。成功以 stdout 的 `{"ok":true,...}` 表示,判定必须用 `ok===true`(不能看 `code` 字段);失败在 stderr 输出 `{"ok":false,"error":{code,message,hint}}`,退出码:`0` 已写入、`2` pending、`3` 用户拒绝(不得自动重发)、`4` 请求过期、`5` 网络或服务端不可用、`1` 其他错误。输出中只会出现掩码后的 AK。
72
+
73
+ CI 或无人值守环境可直接提供 `REALSEE_GATEWAY_APP_KEY`/`REALSEE_GATEWAY_APP_SECRET` 环境变量:它们优先级最高,设置后跳过配对直接写盘。回退路径 `npm run setup -- --paste` 保留隐藏输入:在 Realsee China Portal 的空间应用创建页完成组织、开发者应用和空间项目选择,点击“复制本地配置”,将单行 `realsee-setup:v1:...` 配置包粘贴到隐藏输入中。配置包由 UTF-8 JSON 经 Base64URL 编码,兼容 Windows、macOS 和 Linux;Base64URL 仅提供稳定的单行传输格式,不是加密。不要把配置包放入聊天、命令参数、管道、重定向、Shell 历史、源码或日志。
74
+
75
+ 配对与回退路径都必须校验 AK、SK,并在提供时校验可选的 `resourceCode` fallback,然后原子写入 gitignored 的服务端 `.env.development`;省略或留空 `resourceCode` 时不会写入 `REALSEE_DEFAULT_RESOURCE_CODE`。现有三字段 v1 payload 继续兼容。POSIX 系统使用 `0600`,Windows 使用当前用户 ACL。首次接入未成功时可以重新运行同一命令并完整覆盖本地配置;首次运行后的凭据轮换和默认项目切换属于独立管理流程。
65
76
 
66
77
  启动开发环境:
67
78
 
@@ -69,14 +80,24 @@ npm run setup
69
80
  npm run dev
70
81
  ```
71
82
 
72
- 访问以下地址,Starter 会使用 Setup 保存的首次运行项目:
83
+ 显式资源路由始终可用,建议访问:
73
84
 
74
85
  ```text
75
- http://127.0.0.1:8087/
86
+ http://127.0.0.1:8087/{resourceCode}
76
87
  ```
77
88
 
89
+ 只有 setup payload 提供了可选 fallback 时,根地址 `http://127.0.0.1:8087/` 才会通过 `GET /api/work` 加载该资源;未配置 fallback 时根 Work 请求返回清晰的受控 400,且不会请求上游。
90
+
78
91
  开发环境由 Vite 提供浏览器应用,并将 `/api` 请求代理至 Fastify BFF。使用 `--no-install` 创建项目时,需要先在生成目录中执行 `npm ci`。
79
92
 
93
+ 生成 Vibe Release 可上传源码包:
94
+
95
+ ```bash
96
+ npm run package:vibe-release
97
+ ```
98
+
99
+ 命令会重新执行 `npm ci` 和标准生产构建,然后生成 `release/<项目名>-node-vite-bff-v1.zip`。本地 `dist`、`node_modules`、`.env*`、凭据及编辑器/Agent 状态不会进入 ZIP;运行配置值应在 Vibe Release 中单独配置。默认 `deploy.json.requiredEnv` 仅包含 `REALSEE_GATEWAY_APP_KEY` 和 `REALSEE_GATEWAY_APP_SECRET`;`REALSEE_DEFAULT_RESOURCE_CODE` 只是可选的根路由 fallback。
100
+
80
101
  ## CLI 参考
81
102
 
82
103
  以下示例使用全局安装后的命令形式。临时执行时,可通过 `npm exec --yes --package=@realsee/vr-cli@<version> --` 调用相同命令。
@@ -89,11 +110,11 @@ http://127.0.0.1:8087/
89
110
  vr-cli create <directory> [options]
90
111
  ```
91
112
 
92
- | 参数 | 说明 |
93
- | --- | --- |
94
- | `--name <npm-name>` | 指定生成项目的 npm 包名 |
95
- | `--preset viewer` | 使用 `viewer` 项目模板 |
96
- | `--no-install` | 生成文件后不执行 `npm ci` |
113
+ | 参数 | 说明 |
114
+ | ------------------- | ------------------------- |
115
+ | `--name <npm-name>` | 指定生成项目的 npm 包名 |
116
+ | `--preset viewer` | 使用 `viewer` 项目模板 |
117
+ | `--no-install` | 生成文件后不执行 `npm ci` |
97
118
 
98
119
  目标目录必须不存在或为空。未指定 `--name` 时,CLI 根据目标目录名称生成 npm 包名。
99
120
 
@@ -158,16 +179,16 @@ vr-cli help
158
179
 
159
180
  ## 生成项目核心依赖与版本要求
160
181
 
161
- | 依赖 | 版本要求 | 用途 |
162
- | --- | --- | --- |
163
- | Node.js | `>=22.18.0`,推荐 `22.23.2` | CLI 与生成项目运行环境 |
164
- | npm | `>=11.19.0` | 依赖安装与项目脚本 |
165
- | `@realsee/five` | `>=6.8.9` | 空间 Viewer 运行时 |
166
- | `@realsee/dnalogel` | `>=3.81.2` | Five 插件能力 |
167
- | `@realsee/vapor` | `>=0.2.12` | Viewer 界面组件 |
168
- | `three` | `0.117.1` | Three.js 运行时 |
169
- | `react` / `react-dom` | `>=18.3.1` | 浏览器界面运行时 |
170
- | `fastify` | `>=5.12.1` | 服务端应用运行时 |
182
+ | 依赖 | 版本要求 | 用途 |
183
+ | --------------------- | --------------------------- | ---------------------- |
184
+ | Node.js | `>=22.18.0`,推荐 `22.23.2` | CLI 与生成项目运行环境 |
185
+ | npm | `>=11.19.0` | 依赖安装与项目脚本 |
186
+ | `@realsee/five` | `>=6.8.9` | 空间 Viewer 运行时 |
187
+ | `@realsee/dnalogel` | `>=3.81.2` | Five 插件能力 |
188
+ | `@realsee/vapor` | `>=0.2.12` | Viewer 界面组件 |
189
+ | `three` | `0.117.1` | Three.js 运行时 |
190
+ | `react` / `react-dom` | `>=18.3.1` | 浏览器界面运行时 |
191
+ | `fastify` | `>=5.12.1` | 服务端应用运行时 |
171
192
 
172
193
  ## 常见问题
173
194
 
@@ -187,13 +208,13 @@ nvm use
187
208
 
188
209
  ### 开发服务提示本地配置未完成
189
210
 
190
- 运行 `npm run setup`,从 Portal 一次复制并粘贴完整配置。配置完成后重新启动开发服务。
211
+ 运行 `npm run setup`,在浏览器中打开打印出的验证链接并确认配对(无法轮询时用 `npm run setup -- --paste` 粘贴 Portal 配置)。配置完成后重新启动开发服务。
191
212
 
192
213
  ### Work 加载失败
193
214
 
194
215
  依次确认:
195
216
 
196
- 1. Setup 中选择的 `resourceCode` 正确;
217
+ 1. URL 中的显式 `resourceCode` 是否正确,或根路由是否确实配置了可选的 `REALSEE_DEFAULT_RESOURCE_CODE` fallback;
197
218
  2. 开放平台应用有权访问对应资源;
198
219
  3. `REALSEE_GATEWAY_ENDPOINT` 配置正确;
199
220
  4. BFF 日志中的上游 HTTP 状态符合预期;
@@ -203,7 +224,7 @@ nvm use
203
224
 
204
225
  - npm 包:`@realsee/vr-cli`。
205
226
  - 可执行命令:`vr-cli`。
206
- - 当前版本:`0.1.5`。
227
+ - 当前版本:`0.2.0`。
207
228
 
208
229
  `0.x` 版本可能调整模板、检查规则和生成内容。生产环境与 CI 应固定 CLI 版本,并在升级时审查生成差异。
209
230
 
@@ -13,13 +13,14 @@ npm run lint
13
13
  npm run format:check
14
14
  npm run check
15
15
  npm run build
16
+ npm run package:vibe-release
16
17
  npm start
17
18
  node .agents/skills/realsee-vr-app/scripts/verify-project.mjs .
18
19
  ```
19
20
 
20
21
  Use Node.js 22.23.2 from `.nvmrc`/`.node-version`, with `engines.node` set to the oldest supported runtime floor `>=22.18.0`; the generated BFF relies on native TypeScript type stripping being enabled by default. Use npm 11.19.0 from `packageManager`. Keep `package-lock.json` authoritative, use `npm ci` for clean installs, and do not bypass `typecheck`, ESLint or Prettier.
21
22
 
22
- Every direct dependency except `three` must use an open `>=` minimum no lower than the generated baseline. Use `npm update` to move the lockfile to newer releases, or `npm install <pkg>@latest` to raise one declared minimum; then run `npm run check` and `npm run build`. Keep `package-lock.json` authoritative and use `npm ci` for clean installs. `three` is the only hard-locked dependency and must stay exactly at the generated version because Five targets that Three release. Updating Five, dnalogel or Vapor requires re-checking the versioned contract fixtures and validating spatial behavior in a browser. Never run `npm audit fix --force`.
23
+ Every application dependency except `three` must use an open `>=` minimum no lower than the generated baseline. The release-only `adm-zip` development dependency must remain exactly `0.6.0`. Use `npm update` to move the application lockfile to newer releases, or `npm install <pkg>@latest` to raise one declared minimum; then run `npm run check`, `npm run build` and `npm run package:vibe-release`. Keep `package-lock.json` authoritative and use `npm ci` for clean installs. `three` must stay exactly at the generated version because Five targets that Three release. Updating Five, dnalogel or Vapor requires re-checking the versioned contract fixtures and validating spatial behavior in a browser. Never run `npm audit fix --force`.
23
24
 
24
25
  ## TypeScript rules
25
26
 
@@ -92,9 +93,10 @@ Every direct dependency except `three` must use an open `>=` minimum no lower th
92
93
  - `Mapview` is the three-dimensional overview; `Topview` is the map/floor structure.
93
94
  - Never directly edit `work.json`, downloaded Work, or customer Work. The default Viewer is read-only; persistence needs an authoritative editor/API/BFF/source contract and user confirmation. Otherwise propose a typed patch or keep the feature runtime-only.
94
95
  - Use only Work-provided, approved API/CDN or user-authorized media/model assets; never introduce an unrelated third-party URL.
95
- - Resolve the onboarding Work from `/` through same-origin `/api/work`, backed by the server-only `REALSEE_DEFAULT_RESOURCE_CODE`. Keep `/{resourceCode}` and `/api/work/{resourceCode}` only as explicit development compatibility routes. Never add `VITE_WORK_URL`, a local `/work.json` fallback or browser-side OpenAPI credentials.
96
- - The generated Fastify BFF is an example adapter: `realsee-open-api.ts` owns token exchange/cache and upstream calls, `work-service.ts` owns the framework-neutral envelope, and `work-route.ts` owns HTTP. Preserve `GET /api/work` when replacing it with Go or another backend.
97
- - The generated project has one `.env.example`; `npm run setup` is the only first-onboarding writer for `.env.development`. It accepts one hidden, versioned Portal payload containing AK, SK and `resourceCode`. Only the server reads `REALSEE_GATEWAY_ENDPOINT`, `REALSEE_GATEWAY_APP_KEY`, `REALSEE_GATEWAY_APP_SECRET` and `REALSEE_DEFAULT_RESOURCE_CODE`. `APP_ID` and `REALSEE_SOURCE` are optional deployment metadata.
96
+ - Resolve Work identity from `/{resourceCode}` and call same-origin `/api/work/{resourceCode}`; this explicit route always works independently of fallback configuration. `/` and `/api/work` may use the optional server-only `REALSEE_DEFAULT_RESOURCE_CODE`; without it, the root Work route returns a controlled `RESOURCE_CODE_REQUIRED` 4xx before any upstream request. Never add `VITE_WORK_URL`, a local `/work.json` fallback or browser-side OpenAPI credentials.
97
+ - The generated Fastify BFF is an example adapter: `realsee-open-api.ts` owns token exchange/cache and upstream calls, `work-service.ts` owns the framework-neutral envelope, and `work-route.ts` owns HTTP. Preserve `GET /api/work/{resourceCode}` and the optional root fallback contract when replacing it with Go or another backend.
98
+ - The generated project has one `.env.example`; `npm run setup` is the only first-onboarding writer for `.env.development`. The default path pairs this machine with the Portal: it prints a verification link plus a short code, polls until the server reports a terminal state, then atomically writes the gitignored, server-only file (`0600` on POSIX, current-user ACL on Windows). `npm run setup -- --no-wait --json` starts the same request, prints one `{"ok":true,"data":{"status":"pending",...}}` envelope, and exits `2`; `poll_secret` never reaches stdout, logs or arguments, and is kept only in memory plus the 0600, gitignored `.realsee/pairing-continuation.json`. `npm run setup -- --complete` resumes that request after the user confirms in the Portal. `npm run setup -- --paste` keeps the hidden-input fallback for one versioned `realsee-setup:v1:` payload containing AK, SK and an optional `resourceCode`; existing three-field v1 payloads remain supported. `REALSEE_GATEWAY_APP_KEY`/`REALSEE_GATEWAY_APP_SECRET` environment variables take precedence over both paths and skip pairing. Success prints `{"ok":true,...}` on stdout — judge it with `ok===true`, never a `code` field — and only a masked AK appears anywhere in the output; failures print `{"ok":false,"error":{code,message,hint}}` on stderr with exit code `0` written, `2` pending, `3` denied, `4` expired, `5` service unavailable, `1` otherwise. Never re-send a denied request automatically.
99
+ - Only the server reads `REALSEE_GATEWAY_ENDPOINT`, `REALSEE_GATEWAY_APP_KEY`, `REALSEE_GATEWAY_APP_SECRET` and optional `REALSEE_DEFAULT_RESOURCE_CODE`. The default `deploy.json.requiredEnv` contains only AK/SK; `APP_ID` and `REALSEE_SOURCE` are optional deployment metadata.
98
100
  - Keep the real `REALSEE_GATEWAY_APP_SECRET`, AK/SK and token in the BFF environment or secret manager. They must not enter `VITE_*`, `src/`, Vite `define/envPrefix`, browser requests, logs or bundles.
99
101
  - AK/SK authorize the BFF's upstream access. If an internet-facing deployment requires caller or tenant authorization, enforce it before the Work route; never satisfy that requirement by exposing AK/SK to the browser.
100
102
  - Construct and append Five only after its host has positive dimensions; use `five.refresh` for later positive resizes.
@@ -104,7 +106,7 @@ Every direct dependency except `three` must use an open `>=` minimum no lower th
104
106
 
105
107
  ## Validation
106
108
 
107
- Run type checking and production build. For spatial changes, validate at `http://127.0.0.1:8087/` in a real browser; the template uses local IPv4 loopback and non-privileged port 8087, not privileged port 517. Inspect Five state/readiness, native surface dimensions, spatial-tag anchors/renderers, Three coordinates/resources, plugin lifecycle, layer rectangles and hit targets rather than relying only on screenshots.
109
+ Run type checking and production build. For spatial changes, validate at `http://127.0.0.1:8087/{resourceCode}` in a real browser; use `/` only when the optional server fallback is configured. The template uses local IPv4 loopback and non-privileged port 8087, not privileged port 517. Inspect Five state/readiness, native surface dimensions, spatial-tag anchors/renderers, Three coordinates/resources, plugin lifecycle, layer rectangles and hit targets rather than relying only on screenshots.
108
110
 
109
111
  ## Model floorplan contract
110
112