@tuya-sat/microapp-kit 0.1.26-alpha.0 → 0.1.26-alpha.1

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/CHANGELOG.md CHANGED
@@ -1,8 +1,16 @@
1
1
  # 更新日志
2
2
 
3
- ## 0.1.26-alpha.0(内测,待发布)
3
+ ## 0.1.26-alpha.1(内测,待发布)
4
4
 
5
- - 本次为 alpha 内测包,发布标签使用 `alpha`,不更新 `latest`;内测用户按精确版本或 `@alpha` 安装。
5
+ - 通用安装与开发指引不再写死开发包当前版本:从完整包元数据核对实际名称、版本和完整性;已有可信包及项目锁继续复用。README 使用内测通道,解析后固定精确版本;生成安装页仍自动填入对应版本,元数据不一致时拒绝生成。
6
+ - 修复安装依赖后直接执行 `npm pack` / `npm publish` 的清单污染:仅排除开发包根目录的安装产物,模板中的前后端锁文件继续进入归档并严格校验。
7
+ - 新增离线 `check:release`,并接入 `prepublishOnly`:对普通 npm 打包生成的真实归档进行解包和完整性检查,失败阻止发布,不访问发布源或修改分发标签。
8
+ - 补齐带安装产物的普通打包、离线安装、setup/doctor,以及模板锁文件缺失、篡改和归档遗漏的回归。安装与升级指引同步为公司包 `0.1.26-alpha.1`,仍使用 `alpha` 标签。
9
+ - 已发布的 `alpha.0` 归档及用户缓存不改写;修复包须另发新版本。发布者在正式源验收新包后处理旧版弃用提示和实际分发标签。
10
+
11
+ ## 0.1.26-alpha.0(内测)
12
+
13
+ - alpha 内测包设计使用 `alpha` 标签。该版实际发布归档的清单包含根目录安装产物,接入校验失败;请使用修复版本,实际分发标签由发布者核对。
6
14
  - 公司包名确定为 `@tuya-sat/microapp-kit`,安装、升级检测、生成指引及归档使用同一身份;个人旧包名仅保留为历史说明及迁移来源。
7
15
 
8
16
  - 后端模板默认接通 HTTP 入口、验签与请求异常日志,贯通服务端请求编号;未捕获异常及依赖阶段保留安全错误分类和 SQLSTATE,不输出 SQL、凭据或原始异常。补齐接线审阅提示、实际 HTTP/并发/脱敏回归和 Skill 验收要求;已有项目仍须显式同步业务源码。
@@ -20,7 +28,7 @@
20
28
  - 支持个人 `@xuqinghua/microapp-kit@0.1.24`、`0.1.25` 直接到 `@tuya-sat/microapp-kit` 公司包的一次性迁移,保留可核验的原目标及源码、身份、数据、凭据、发布记录和缓存,0.1.24 无需中转升级。
21
29
  - 目标不明、在途/未知请求或未完成会话阻止迁移;迁移纳入升级事务和崩溃恢复,用户后续编辑不被覆盖。
22
30
  - 安装指引和更新检测由实际分发包名驱动;维护者修改包名后需 refresh、检查并验证归档。Libra 发布仍由发布负责人操作。
23
- - 已发布包及用户缓存保持原样;本分支未发布 npm 或部署服务,真实正式/预发联调与跨系统实机验收单独进行。
31
+ - 已发布包及用户缓存保持原样;真实正式/预发联调与跨系统实机验收单独进行。
24
32
 
25
33
  ## 0.1.25
26
34
 
package/MAINTAINING.md CHANGED
@@ -32,6 +32,18 @@ npm run pack:npm -- /absolute/path/outside-package/new-release
32
32
 
33
33
  The packer assembles the package, verifies npm's actual archive bytes and generates a separate `install-guide-<version>/tuya-microapp-kit-install.md`. The package includes templates and their hidden files; it excludes credentials, `node_modules`, repository metadata and maintainer evaluations. `_gitignore` templates are restored to `.gitignore` during project initialization.
34
34
 
35
+ The integrity inventory excludes only these dependency-installation paths at the
36
+ package root: `node_modules/`, `yarn.lock`, `package-lock.json` and `pnpm-lock.yaml`.
37
+ Template lockfiles remain distributed and verified. Other unexpected product
38
+ files, missing files and changed contents still fail verification.
39
+
40
+ Run `npm run check:release` to refresh and verify the actual ordinary npm archive
41
+ offline, including after CI has installed dependencies. `prepublishOnly` runs
42
+ this gate before ordinary `npm publish`; its internal `npm pack --ignore-scripts`
43
+ avoids recursive hooks. `prepack` refreshes the inventory again immediately before
44
+ packing. A failed archive check blocks publication. Do not bypass lifecycle scripts
45
+ to conceal an archive failure. This check neither publishes nor changes registry tags.
46
+
35
47
  Before an authorized publication:
36
48
 
37
49
  1. Verify the exact version and archive digest, release notes, resource validation and relevant tests.
@@ -39,21 +51,44 @@ Before an authorized publication:
39
51
  3. Publish that verified archive to the configured official npm registry. Use npm's normal login and per-publication security verification; credentials must not enter commands, package files or logs.
40
52
  4. Wait for the exact version to be available, verify the downloaded archive and the intended distribution tag, then repeat clean installation and tool invocation. A publish acceptance response is not download verification.
41
53
 
42
- The current prerelease is `0.1.26-alpha.0`, with `publishConfig.tag=alpha`.
43
- For Libra, use this exact version and ensure the publishing component retains
54
+ Read the intended exact version from `package.json.version` and the publication
55
+ channel from `publishConfig.tag`. The current channel is `alpha`.
56
+ For Libra, use that exact version and ensure the publishing component retains
44
57
  the `alpha` tag (or explicitly supplies `--tag alpha`); do not let it rewrite
45
58
  only `package.json` or override the tag with `latest`. Verify the final archive
46
59
  version and all integrity manifests before publishing. Internal testers install
47
60
  the actual distribution package at `@alpha` or the exact prerelease version.
48
61
  Stable update detection continues to use `latest`; it does not opt users into
49
- alpha releases. Subsequent changed alpha packages use `0.1.26-alpha.1`, and so on.
62
+ alpha releases. Changed published content requires a new prerelease identifier;
63
+ never overwrite an existing published version.
50
64
  Before a stable release, align all version metadata and explicitly change the
51
65
  publishing tag back to `latest`.
52
66
 
67
+ The published alpha.0 archive has an invalid inventory and must not be rewritten
68
+ or patched inside user caches. After an authorized replacement prerelease publication, download
69
+ the exact public archive, verify it and exercise setup/doctor before notifying
70
+ testers. Check actual `alpha` and `latest` tags; a prerelease must not occupy the
71
+ stable tag. If no stable company version exists, the release owner removes an
72
+ incorrect `latest` rather than pointing it at an invented stable version. Mark
73
+ alpha.0 deprecated with the replacement version after the replacement is usable.
74
+ These remote changes require separate publication authorization.
75
+
53
76
  Publication and website updates require their own user authorization. The external installation page is optional: an Agent may obtain an exact complete package directly from npm and then read its `START-HERE.md`.
54
77
 
55
78
  ## Installation page
56
79
 
80
+ Keep `START-HERE.md` and the development guide independent of the package's own
81
+ release number. They read and cross-check the acquired package metadata; they do
82
+ not resolve `latest` again for an already verified bundle or replace a project
83
+ lock. README prompts may select a release channel, resolved once to an exact
84
+ version. Historical compatibility boundaries and the Node safety baseline remain
85
+ explicit in their own contracts.
86
+
87
+ The generated installation page intentionally contains an exact version. Its
88
+ builder reads `package.json` and checks it against the verified bundle manifest;
89
+ metadata disagreement or tampering stops generation before writing output. A
90
+ normal release-number change must not require editing the general guides.
91
+
57
92
  The page source is `bootstrap/install.md.in`:
58
93
 
59
94
  ```bash
package/README.md CHANGED
@@ -14,9 +14,9 @@
14
14
 
15
15
  将下面这句话直接复制给 Coding Agent:
16
16
 
17
- > 请先确定微应用业务目录,从 npm 获取 @tuya-sat/microapp-kit@0.1.26-alpha.0:中国网络优先用 npmmirror,中国以外用官方源,镜像缺少目标版本则回退官方源;读取包内 START-HERE.md,按指引安装并开始需求澄清、开发和预览。
17
+ > 请先确定微应用业务目录,从 npm 获取 @tuya-sat/microapp-kit@alpha,解析并锁定精确版本:中国网络优先用 npmmirror,中国以外用官方源,镜像缺少目标版本则回退官方源;读取包内 START-HERE.md,按指引安装并开始需求澄清、开发和预览。
18
18
 
19
- 当前为 alpha 内测版;发布后可按上述精确版本或 `@alpha` 获取,`@latest` 用于正式版。
19
+ 当前为 alpha 内测通道,`@latest` 用于正式版。需要固定某次发布时可指定精确版本;实际包名和版本以取得的完整包元数据及校验结果为准,标签只解析一次。已有可信且匹配目标的完整包直接复用。
20
20
 
21
21
  随后描述需求,例如:
22
22
 
@@ -38,7 +38,7 @@ Agent 根据任务复杂度推进;小修改直接处理,重要业务和权
38
38
 
39
39
  将下面这句话交给当前项目的 Agent:
40
40
 
41
- > 请将当前项目的开发包升级到 @tuya-sat/microapp-kit@0.1.26-alpha.0,按包内升级流程检查并重新加载 Skill,保留业务代码、数据、凭据和发布记录。
41
+ > 请将当前项目的开发包升级到 @tuya-sat/microapp-kit@alpha,解析并锁定精确版本,按包内升级流程检查并重新加载 Skill,保留业务代码、数据、凭据和发布记录。
42
42
 
43
43
  工具升级不会自动改写业务源码;涉及源码适配时,Agent 会说明影响并按任务继续处理。
44
44
 
package/START-HERE.md CHANGED
@@ -12,7 +12,11 @@
12
12
 
13
13
  ## 2. 从npm获取精确完整包
14
14
 
15
- 本版为 `@tuya-sat/microapp-kit@0.1.26-alpha.0`。明确安装此内测版时使用该精确版本;用户指定 `@alpha` 时解析该标签一次后固定实际版本,不用 `latest` 替代。默认正式版更新检测仍只查询 `latest`,不自动将普通用户升级到内测版。
15
+ 开发包自身的实际身份读取自同一完整包的 `package.json.name`、`package.json.version`,并核对 `bundle.json.version`;如清单声明 `packageName`,同时核对包名。名称和版本必须与用户已确认的目标、可信来源一致;文档、目录名或文件名不能代替元数据。版本不一致或完整性校验失败时停止,不改清单、项目锁或旧缓存来绕过。
16
+
17
+ 已有可信且完整性通过的完整包、用户也未指定其他目标时,直接复用其实际版本,不因本文没有版本号而重新查找 `latest`。已安装项目继续使用 `.tuya-microapp/toolchain.json` 锁定的精确版本和 `bundleSha256`,仅在用户要求升级时按目标包执行升级检查。
18
+
19
+ 用户指定精确版本时保持该目标;指定 `@alpha` 或 `@latest` 时只解析相应标签一次并固定实际版本,不在通道之间替换。普通用户默认正式版检测仍只查询 `latest`,不自动加入内测通道;若正式标签返回预发布版,说明标签异常并停止本次正式版获取,不静默安装或另选版本。
16
20
 
17
21
  正式包为`@tuya-sat/microapp-kit`。按[下载源与回退规则](skills/micro-app-development/references/npm-registry.md),已知中国网络优先用 https://registry.npmmirror.com/,中国以外用 https://registry.npmjs.org/;网络未知默认官方源,不按对话语言或部署区域猜测。只用单次命令 --registry,不改全局npm配置。用户指定版本则核实该版本;latest按官方元数据确认一次,后续固定精确版本。目标已确认后不因下载源变化重新解析latest。
18
22
 
@@ -29,7 +33,7 @@
29
33
  "<Node绝对路径>" "<完整包目录>/setup.mjs" --project "<同一业务目录>" --agent <实际宿主>
30
34
  ```
31
35
 
32
- 参数由Agent按实际情况填入。普通用户的新工作区默认正式发布目标,不询问环境;内部预发及个人 0.1.24/0.1.25 到公司包的迁移见[发布目标与工作区](skills/micro-app-development/references/workspace-environments.md)。已有项目明确要求升级时,使用目标包的`cli.mjs update --check/update`,按[升级流程](skills/micro-app-development/references/tool-update.md)处理;不用setup覆盖原锁。缓存按版本+摘要保留,不删除旧缓存或手改锁绕过冲突;保留业务源码、身份、凭据、迁移、DEV数据和发布记录。
36
+ 参数由Agent按实际情况填入。普通用户的新工作区默认正式发布目标,不询问环境;内部预发及个人包到公司包的迁移见[发布目标与工作区](skills/micro-app-development/references/workspace-environments.md),由目标工具核对受支持的来源版本。已有项目明确要求升级时,使用目标包的`cli.mjs update --check/update`,按[升级流程](skills/micro-app-development/references/tool-update.md)处理;不用setup覆盖原锁。缓存按版本+摘要保留,不删除旧缓存或手改锁绕过冲突;保留业务源码、身份、凭据、迁移、DEV数据和发布记录。
33
37
 
34
38
  按[Agent工作流](skills/micro-app-development/references/agent-workflow.md)实际读取当前项目宿主目录的micro-app-development Skill,运行其启动器doctor并核对项目锁。工具调用通过不等于宿主自动发现Skill;必要且无法自动完成时,只引导用户重载/新会话这一必要动作。安装不等于Node绑定、业务依赖、Docker或预览已就绪,分别验证。
35
39
 
@@ -20,14 +20,16 @@ export function buildInstallPage(destination, bundleRoot = source) {
20
20
  throw new Error('OUTPUT_EXISTS');
21
21
  }
22
22
  const manifest = verifyBundle(root);
23
+ const pkg = distributionPackage(root);
24
+ if (pkg.version !== manifest.version) throw new Error('PACKAGE_VERSION_MISMATCH');
23
25
  const page = readFileSync(join(root, 'bootstrap/install.md.in'), 'utf8')
24
- .replaceAll('{{GUIDE_VERSION}}', manifest.version)
25
- .replaceAll('{{PACKAGE_NAME}}', distributionPackage(root).name);
26
+ .replaceAll('{{GUIDE_VERSION}}', pkg.version)
27
+ .replaceAll('{{PACKAGE_NAME}}', pkg.name);
26
28
  mkdirSync(destination, { recursive: true });
27
29
  try {
28
30
  const file = join(destination, INSTALL_PAGE);
29
31
  writeFileSync(file, page);
30
- return { directory: destination, file, version: manifest.version };
32
+ return { directory: destination, file, version: pkg.version };
31
33
  } catch (error) {
32
34
  rmSync(destination, { recursive: true, force: true });
33
35
  throw error;
@@ -18,7 +18,7 @@
18
18
 
19
19
  镜像对已确认目标返回E404/ETARGET或对应归档404时,说明“镜像尚未同步目标版本,改从官方源获取同一版本”,回退 https://registry.npmjs.org/ 一次,保持包名、精确版本和业务目录不变;官方也没有则停止,不改用旧版。摘要/名称/版本不符时不执行包;DNS、超时、TLS、权限等错误单独处理,不当作同步延迟、不循环换源。用户明确指定的其他可信源不自动切到公共源。
20
20
 
21
- 在业务目录外的独立暂存目录,用选定Node/npm及本次--registry获取完整包,例如npm pack精确包后解包,或npm install --prefix独立目录 --save-exact --ignore-scripts --no-audit --no-fund精确包。不得在业务根目录npm install开发包而产生工具依赖文件。让npm核验归档完整性;已有官方dist.integrity时同时比较,解包后核对实际name/version及完整包校验。只读取此次精确完整包的START-HERE.md,不搜索相邻源码、其他项目或历史包替代。完整包已存在且版本匹配则直接复用。
21
+ 在业务目录外的独立暂存目录,用选定Node/npm及本次--registry获取完整包,例如npm pack精确包后解包,或npm install --prefix独立目录 --save-exact --ignore-scripts --no-audit --no-fund精确包。不得在业务根目录npm install开发包而产生工具依赖文件。让npm核验归档完整性;已有官方dist.integrity时同时比较,解包后读取package.json.name、package.json.version,核对bundle.json.version和如有的packageName,与用户目标及可信来源一致后完成完整性校验。只读取此次精确完整包的START-HERE.md,不搜索相邻源码、其他项目或历史包替代。完整包已存在且版本匹配则直接复用,不因通用文档未写版本号而重查latest。
22
22
 
23
23
  ## 3. 调用现有setup/update并继续开发
24
24
 
package/bundle.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "format": "tuya-microapp-kit-v1",
3
3
  "protocolVersion": 1,
4
- "version": "0.1.26-alpha.0",
4
+ "version": "0.1.26-alpha.1",
5
5
  "skills": [
6
6
  "micro-app-backend-development",
7
7
  "micro-app-cloud-integration",
@@ -19,16 +19,15 @@
19
19
  },
20
20
  "files": {
21
21
  "AUDIT.md": "143c5031aff8af4c146e82ccfe94674fb46b4a7bd658f00a3f70189f85a2289c",
22
- "bootstrap/build-install-page.mjs": "5f870b60fe677e0aa873309e8820e4d451e16a3bf0901bd952332475ab004fd4",
22
+ "bootstrap/build-install-page.mjs": "8905c64fee704a0373ce1ba6c759bd7657e3f2752afd4e7bf88beec874516d3f",
23
23
  "bootstrap/install-node.ps1": "c9c6dd7fc6ffadeda8e78c107d540a419866636a6b3fb125a456a06eb5dd28d2",
24
24
  "bootstrap/install-node.sh": "cc008205c7a424b472cc28090166b5737247bf5358aa1f27687a52711c76a874",
25
- "bootstrap/install.md.in": "4e2d490b4c2ee3ef8bb944af28a129e0c4e2bc1cfd5d22ba12facd990e6fee44",
26
- "CHANGELOG.md": "169874f6554d17a387cf8d3de5f3149660ce8b6ce389d1018b0296ec581cbe49",
25
+ "bootstrap/install.md.in": "154df227319d364110cf8f84740ed292733ff37b98f1ba1b7564a85dbe46d182",
26
+ "CHANGELOG.md": "072f01fafc6003941001da8eb5569cd9e04fa0a22abaf92c8e747ca17a7c46c0",
27
27
  "cli.mjs": "2ab380f72367f8347ceb783b55cf83e1c1aa30c2c24e01723d761848e856d9c5",
28
- "MAINTAINING.md": "a3295e0cca16456810a22f3171ed383eee8a65c33c610d475a2eacdbc0e7a985",
29
- "node_modules/.yarn-integrity": "77e45a5f7ff620fcb4f449ce41bb3d99df194eeb8fb7535889fcf24c2744ee53",
30
- "package.json": "f658d453f714876f170b0ed142b9cac6482da53fa0558ec371f70ce9c214ae98",
31
- "README.md": "fadd3ef656c79f67d276eb09fb1be1548a4f29bfdf7b16fcfd165356fa021728",
28
+ "MAINTAINING.md": "3ddccfc3a04a53da333f43e2fb7658a111fa597ba5fa79049a317e95e89004d8",
29
+ "package.json": "4417883774088b0ffd1c1d072d8244bbadf60cda8f16783a0cf5e3684a7d6e39",
30
+ "README.md": "343b11ca4ecec777c2099a7aeb50b29a1a64062ca8ca85b901c898b162c8c170",
32
31
  "resources/contracts/project-permissions.json": "c40f26157b50a9cdfcad58ab11c1d382e52edc62b0857cff3b0a036e9aa8aee8",
33
32
  "resources/contracts/standard-api.catalog.json": "2ea2098ea67b0786a85f28869e05465ce13d715a788f214b4b58c15eb70cb6f1",
34
33
  "resources/examples/group-display.mjs": "5fac5f8bab7ca0452b93de5fafe759aed2c1f5b1d5f3c6fe5b2a7db07db8bb0d",
@@ -54,7 +53,7 @@
54
53
  "resources/preview/server.mjs": "5fd9308987e5595be5e8066ca1b2705e402ba458640d84764b2f1001518c2bc9",
55
54
  "resources/preview/theme-tokens.mjs": "ec3d10a4c2bbc312cd59017242d4211f1880ac714e4bd6918d2db1ea08a38096",
56
55
  "resources/preview/themes.json": "8233f3a1c5f157675cd54f2537b47bc241878063fc7b2ee4058430c00e75e0e3",
57
- "resources/resource-manifest.json": "094b4b907f6092be044e6a7397dc8bc52431c6c0615ee38fda64a9c01b404f39",
56
+ "resources/resource-manifest.json": "1e99d5d51df11c7d5f5587cc6acfaa9f101b3a909d3dd7320fa4d0e44334b98f",
58
57
  "resources/scripts/backend-build-context.mjs": "83065a33e257474a8858ba954286ba5136c134f7e63cacd82ec563c065ffcccb",
59
58
  "resources/scripts/backend-runtime.mjs": "0ed797402a17e4c1381cf4000e9983d70214fafe3f9884910d1b8cde03bfd967",
60
59
  "resources/scripts/build-backend-image.sh": "db8bfdc7b04da965a9c205f96c5e0226c2d09f16c9874e92e9287749494ea85b",
@@ -225,7 +224,7 @@
225
224
  "resources/tests/submission-errors.test.mjs": "3d6a9d881799a49d87a735b36798b2a53f4174d39954432c9ffeee75bd9891ea",
226
225
  "resources/tests/version-description-package.test.mjs": "ff3fbd1a8f5cb620c77c4d5bc1fc84a46ad47d2aa15a5b39920455a60690fa74",
227
226
  "resources/ui/component-sources.json": "bd67ddcd54407ed3343d0feec3b09cee7cd590fd209ea650168023fa57fe6a62",
228
- "runtime/assemble.mjs": "e23c51a622699743a9175a4389147386e6f8655d77dcebd1f835f1681ceb476f",
227
+ "runtime/assemble.mjs": "730c990cafa5ee3d6ac4134af87ceaa9ea9b476ead15937703b26c9c9edf6a61",
229
228
  "runtime/auth/hidden-input.mjs": "b52e914e5cc633741eff69ce701aa23cd69c2bf81657cb5247289f617e028f4a",
230
229
  "runtime/auth/macos-credentials.js": "f8c34af5dcb002b6822ec831b04e7e3ec7bb89343785c794f6d0287172448927",
231
230
  "runtime/auth/manager.mjs": "d823f65017106fd4c94b0e3b7e00d7527d9ac5ea0e820ef43cda26c174748716",
@@ -240,7 +239,7 @@
240
239
  "runtime/errors.mjs": "fafdfad85775f4ec8ce7a16f6319b51218b6a4a8c717d7e10a1552c42bec7d28",
241
240
  "runtime/install-receipt.mjs": "f6b53e9c8c3f7d474286b333963986877b96b4ada4a0818f53d560e18298ae24",
242
241
  "runtime/installation.mjs": "0640d00e584cf022d718d2eef5c0e09d6f8dd952187fde3497294b40886f7825",
243
- "runtime/integrity.mjs": "0f5d62ebae2fc6eae2207b97c106c23e320e358ad84e40ea4dc828a83b2ad1c3",
242
+ "runtime/integrity.mjs": "70c283a2dc089c3d558c9e332c77aa36ecb8fa1ce7d8933ae0f7c0e55051a596",
244
243
  "runtime/launcher.mjs": "be5abad803724b89a58e620975479be57382f3c6ee3be55bf32d6ba4c3b9d68a",
245
244
  "runtime/pack-npm.mjs": "0ed767be3a4ace4b432fbee79d62e1ea7af8456873534a86d49ff51b03796981",
246
245
  "runtime/package-cache.mjs": "d84534203ef221e962d5308ecd2083817fc5768b839777f4907ce4f7d30f9fe3",
@@ -258,10 +257,11 @@
258
257
  "runtime/tests/dev-provider.test.mjs": "3990e437abc5c64274cb147e82c2cdd79bc165b9184eaf22888e3b31fc795651",
259
258
  "runtime/tests/diagnostics.test.mjs": "0796b6adb96020fb1b58e8289ed03a3b8da3cc5de3a25c7f2f5f08b215ade9e7",
260
259
  "runtime/tests/helpers/tar-fixture.mjs": "8ae6299c327681dbcd2dd90d04b26671b567a802266904ffed7dd6503e1b93d7",
261
- "runtime/tests/install-page.test.mjs": "f9f828f861e093d429d5fcecd4425bf166249078ecc23238ec4cd907305a94ac",
260
+ "runtime/tests/install-page.test.mjs": "be29fab8e4c6ed8c7c42293c75328e31f6d2cf9bdec572f232270f5747f0a959",
262
261
  "runtime/tests/install.test.mjs": "06b3e889f1149dd17befc0dae1d10752f9efdafacbc1943665e92521707e10bf",
263
262
  "runtime/tests/node-bootstrap.test.mjs": "f09b8aea28ee2fd7a9185793dc46d9aeb721fbb13011d99aa0cc031c96908032",
264
- "runtime/tests/npm-distribution.test.mjs": "06601c26e650b15169537ab1ac7e923dd036fca68fc2a7fdfd8247320a66c676",
263
+ "runtime/tests/npm-distribution.test.mjs": "be099c91958d74a0afa411b865b3222a50463409e33f762ec45e7521354450aa",
264
+ "runtime/tests/npm-release-check.test.mjs": "e1a50c9732d878abf25ef2304cba0ae98945e5091ea5873011ee73a995e1b544",
265
265
  "runtime/tests/package-cache.test.mjs": "8e3a765419143a1693cfc5d65c4b8b5b2a0d95419fba5375062cce97f4413b95",
266
266
  "runtime/tests/package-migration.test.mjs": "a6143ef67da95c9a9d1cef82ba3fb601a15168e0d23be62241ed47727b64ce1e",
267
267
  "runtime/tests/preview-hosts.test.mjs": "ab3c64dc2bddc3b275efeb908f9c55c39c969886091a0fe46cd0fc8f28247404",
@@ -269,7 +269,7 @@
269
269
  "runtime/tests/project-identity.test.mjs": "69ac79218baedd13f25ae0200dd01cbb0820088b8b0acf494ec1d7ba4a6046f4",
270
270
  "runtime/tests/publication.test.mjs": "d7997e0bde2a3b7ab1f6a7052bbb258ca0e1b31b197e2b40189660db76ec4c9d",
271
271
  "runtime/tests/release-recovery.test.mjs": "f50e4076cdf27a960ff75188c6251dd0ef7374c40871ca171a83d448b299d17a",
272
- "runtime/tests/repository-source.test.mjs": "d8ad1534cf9081551d34f47615ae5e4df5a73590c12818ec8a9ad88dfae48f35",
272
+ "runtime/tests/repository-source.test.mjs": "710be6ece0ff0bc8f486627b28167c16c7f8b711857ad86a0eab9712c050cf10",
273
273
  "runtime/tests/skill-set-update.test.mjs": "2e9cd0a6d13617243e5678a7638ac5e1131db451786e3e792d412b08f05cc359",
274
274
  "runtime/tests/standalone.test.mjs": "65514440dfbb29d04ef79366d6238c3a38abc049f1299dba3911dbca946f1c21",
275
275
  "runtime/tests/update-check.test.mjs": "9bf1ac1d77b3cfeb2d1d61cde00792cdc68d38dc8f01dd9c0836e73d8a4e5180",
@@ -278,6 +278,7 @@
278
278
  "runtime/update-check.mjs": "da37297616641e8f426a37b2159986e9d171715ae304345c6282fdf91ebcd34c",
279
279
  "runtime/update-state.mjs": "9a3e922595ee06d8a40603ddab8edeceb5436d507f4105686e33549690e64182",
280
280
  "runtime/update.mjs": "9a7d60518d1f8700ca62d541513bb236aaa7fca2852b4c9b05fbbc5a592f9437",
281
+ "runtime/verify-npm-release.mjs": "e5aadf4b85da9982a659a7e79750a201b5d106f601cc6d45d1dd42e74ecf1754",
281
282
  "runtime/workspace-migration.mjs": "9b0d295df92b93c719e1f9cadef66f44c48c02a6fcead8311314927f5581bd85",
282
283
  "runtime/workspace.mjs": "4b2eea8a74200f3bc54cddf0fc8bfc3007e86a932953ad9d2cfeedd1c2a9f110",
283
284
  "schemas/toolchain.schema.json": "99cdce421e3c0e8d44c1178368704edab23bcedeee293e3daa82821a1fbab47e",
@@ -312,7 +313,7 @@
312
313
  "skills/micro-app-cloud-integration/references/preview-agent-open.md": "a2ffe871545f694bb1771f31407cacf8520af094439365732352d1c4e8e6f343",
313
314
  "skills/micro-app-cloud-integration/references/server-to-server-integration.md": "4aa71aa71144bb10d7329a0e5842afa15e5de5c9ae08f5d9480cd092b9784b64",
314
315
  "skills/micro-app-cloud-integration/scripts/microapp-kit.mjs": "0b09383f3c9d1db37a117336d7be8969d8ed1679bccbd3810c93c9a2fe47ef1d",
315
- "skills/micro-app-cloud-integration/SKILL.md": "24b3bbc2b6e4ded6509795cc46b6ff2538c6f678efaacc8b59817118e8ead5de",
316
+ "skills/micro-app-cloud-integration/SKILL.md": "f6dcfd9763175fa66d9abf5f6085dc20e597509c0ccdc4050b3db9a3ed0869fe",
316
317
  "skills/micro-app-cloud-integration/tests/behavior-scenarios.md": "c5d0e61f60609eeb51c46a4b5eab480148e9f934b73e874caf83e12650da568f",
317
318
  "skills/micro-app-design/agents/openai.yaml": "436d2656a1d54acd86bfecc1493a7384b2738796f18dd298de541bf52a00d9a9",
318
319
  "skills/micro-app-design/assets/tuya-design-system/assets/components/TuyaCapsuleSearch.html": "5ddc3134eb6cf01e43d383e73c4e1d8a6769abf7e58458d52e071e21abecf300",
@@ -770,12 +771,12 @@
770
771
  "skills/micro-app-development/references/delivery-checklist.md": "46787b9380b0386b805940a869612e4911cd89f91b6b4c3fc00345a82454c6bf",
771
772
  "skills/micro-app-development/references/design-workflow.md": "b42eff65486fb71ee25a2e2a0339308ecae0ccd5897f41fc1f058ffa7158ff89",
772
773
  "skills/micro-app-development/references/developer-credentials.md": "4aacf78ba7d39443686aad153beed01bb75ae85e2175de920ea3b0fb6e053d29",
773
- "skills/micro-app-development/references/development-guide.md": "4d54fa262510018b505e23e4fb32a82a586f66fd317d1cd4d2324bdc193c56a4",
774
+ "skills/micro-app-development/references/development-guide.md": "e28ead5c74eb9b8a612401ab08e572a5b1a8219ddcbbb83da36453c2cbadd6ab",
774
775
  "skills/micro-app-development/references/environment-progress.md": "4953232799f002565b66361b195d98704a0c8bcd5d70fa3dfb03df6fbdfc4b5f",
775
776
  "skills/micro-app-development/references/joint-acceptance.md": "79c7286da56165dae378a64d53e9dad8644c0b4971597507e1b521311624b16c",
776
777
  "skills/micro-app-development/references/local-development.md": "0acad62c8fcf8200e55ce596c0e1e270447b69774742c17a791113ab9e642ce4",
777
778
  "skills/micro-app-development/references/manifest-v1.2.md": "2393b1560726382a9b000c26834e1d4361d277aba08ed8bf2ed00f0cc4d4f2d1",
778
- "skills/micro-app-development/references/npm-registry.md": "179142cd8abd91c0738603ffd5ff1edc473a6565d33f14dc66f8f2ad53f57fb1",
779
+ "skills/micro-app-development/references/npm-registry.md": "b177a0d6129b6c123a74cf89c4d3b5d2028d6ce89560c177d861273132a77f84",
779
780
  "skills/micro-app-development/references/platform-operations.md": "8379437405ea0486e9ba9cc07faf0886ded57ad4ada5a6b6e5b8b8ea4fa68637",
780
781
  "skills/micro-app-development/references/project-workflow.md": "1ea7ba71f0892a6dc4a3823779352653f51513d49aca0fd8baa9c2e704b3f75f",
781
782
  "skills/micro-app-development/references/publication-intent.md": "761ede4d95aec0e63f67214705d18b41caad94e9a3faa69c4036548a3d737331",
@@ -783,8 +784,8 @@
783
784
  "skills/micro-app-development/references/requirement-intake.md": "c837ad15076a4432f0e4959288f7c90fe4c44c4d11acd67afc94a3d6b3e41802",
784
785
  "skills/micro-app-development/references/runtime-requirements.md": "7e5def2a5d797b0f6882b622e5b98be27fdc750f6e0d50ad18d3d0e010129264",
785
786
  "skills/micro-app-development/references/space-permission-boundaries.md": "594129af5a1e150ead461ef9b7c738273b9ecd2f15b3c96e8e012982ad299044",
786
- "skills/micro-app-development/references/tool-update.md": "003171dea33e6bfadd64d1e9741d8449aaff2dbd57030d2a1e3099d5ee771631",
787
- "skills/micro-app-development/references/toolchain-access.md": "85e8a2b5b3819b6a90da6def195d710e830b3882a3ef401660bd1d217b0eda34",
787
+ "skills/micro-app-development/references/tool-update.md": "f3c479dc72c436c5ff75976ab20d811d537cf99cbb9c15294910ee3d02c25c42",
788
+ "skills/micro-app-development/references/toolchain-access.md": "7346bbb1fba7cb8bbe8ba2abd28d69ab324eacde56e0d3e8aaa97ef6f17f7f01",
788
789
  "skills/micro-app-development/references/user-journey.md": "d8609e40ed690b60719a8f709ed9c22fc1eebb4561418d76ddcdc13c76612ae8",
789
790
  "skills/micro-app-development/references/workspace-environments.md": "71b285868fcb9bcbe10b4f82822120f77c958e94f4f10a56101f03375bd9330c",
790
791
  "skills/micro-app-development/scripts/application-icon.mjs": "86597a1b090edddb62d305e02aaab1cf77861f705cdcadaa68f94f7b39f72123",
@@ -836,8 +837,7 @@
836
837
  "skills/micro-app-solution-design/scripts/microapp-kit.mjs": "0b09383f3c9d1db37a117336d7be8969d8ed1679bccbd3810c93c9a2fe47ef1d",
837
838
  "skills/micro-app-solution-design/SKILL.md": "b940fe917e8d4921015aae1acc867c36a2492f9cf6d12c881f3eda0e728f8641",
838
839
  "skills/micro-app-solution-design/tests/behavior-scenarios.md": "90458dd1aad60abfa0044d2f0ce67ebd95d70d75070d67d27d3b41cf1690d180",
839
- "START-HERE.md": "0424923f205565d8924ea95ff753ed2fd09a4cf55f49c3bd409a6a230350bca8",
840
- "yarn.lock": "38df2378ed26e20124d8c38a945af1b4a058656aab3b3b1f71a9d8a629cc0d81"
840
+ "START-HERE.md": "50a1d8d09c3e68823664794d13e364eeb3b2d3e43523fa54482d0f2f5c6fc2f3"
841
841
  },
842
842
  "updateCompatibility": {
843
843
  "protocolVersion": 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/microapp-kit",
3
- "version": "0.1.26-alpha.0",
3
+ "version": "0.1.26-alpha.1",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -20,6 +20,8 @@
20
20
  "assemble": "node runtime/assemble.mjs",
21
21
  "pack:npm": "node runtime/pack-npm.mjs",
22
22
  "prepack": "node runtime/assemble.mjs --refresh",
23
+ "check:release": "node runtime/verify-npm-release.mjs",
24
+ "prepublishOnly": "npm run check:release",
23
25
  "validate": "node resources/scripts/validate-resources.mjs && node skills/micro-app-design/tests/validate-design-skill.mjs",
24
26
  "build:install-page": "node bootstrap/build-install-page.mjs",
25
27
  "build": "npm run validate"
@@ -42,6 +44,8 @@
42
44
  "microappKitRelease": {
43
45
  "format": 1,
44
46
  "summary": [
47
+ "Keep general installation and development guidance version-independent; read verified package metadata and pin exact versions after channel resolution.",
48
+ "Fix direct npm packing after dependency installation, preserve template lockfiles and verify the actual archive before publication.",
45
49
  "Default new workspaces to production and allow explicit machine-local preproduction workspace configuration.",
46
50
  "Support an explicit, state-preserving migration from the personal 0.1.24 or 0.1.25 package directly to a company-scoped distribution.",
47
51
  "Resolve update and installation package identity from the distribution metadata.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "format": "local-resource-lock-v1",
3
- "version": "0.1.26-alpha.0",
3
+ "version": "0.1.26-alpha.1",
4
4
  "upstreamCommit": "4dc5fc2",
5
5
  "registrationStatus": "pending",
6
6
  "files": {
@@ -2,7 +2,7 @@
2
2
  import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
3
3
  import { resolve, join, sep } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
- import { tree, verifyBundle, realPathOnly } from './integrity.mjs';
5
+ import { bundleFiles, verifyBundle, realPathOnly } from './integrity.mjs';
6
6
  import { hashes, includeResource } from '../resources/scripts/resource-files.mjs';
7
7
  import { distributionPackage, refreshPackageGuidance } from './package-identity.mjs';
8
8
  const root = fileURLToPath(new URL('../', import.meta.url));
@@ -15,7 +15,7 @@ export function refreshBundle(directory = root) {
15
15
  writeFileSync(resourcePath, JSON.stringify({ ...resource, files: hashes(scenario) }, null, 2) + '\n');
16
16
  const manifestPath = join(directory, 'bundle.json');
17
17
  const manifest = JSON.parse(readFileSync(manifestPath));
18
- const files = tree(directory, { exclude: ['bundle.json', 'evals'] });
18
+ const files = bundleFiles(directory);
19
19
  const skills = Object.keys(files)
20
20
  .map(file => /^skills\/([a-z0-9-]+)\/SKILL\.md$/.exec(file)?.[1])
21
21
  .filter(Boolean)
@@ -60,7 +60,7 @@ if (process.argv[1] && realPathOnly(process.argv[1]) === realPathOnly(fileURLToP
60
60
  try {
61
61
  if (process.argv[2] === '--refresh') {
62
62
  refreshBundle();
63
- console.log('Updated integrity manifests');
63
+ console.error('Updated integrity manifests');
64
64
  } else console.log(buildBundle(process.argv[2]));
65
65
  } catch (error) { console.error(error.message); process.exitCode = 1; }
66
66
  }
@@ -7,7 +7,7 @@ import {
7
7
  } from "node:fs";
8
8
  import { join, resolve, relative, sep, dirname } from "node:path";
9
9
  import { createHash } from "node:crypto";
10
- export const VERSION = "0.1.26-alpha.0";
10
+ export const VERSION = "0.1.26-alpha.1";
11
11
  // Repository-only files are not part of an installed, versioned capability bundle.
12
12
  export const REPOSITORY_METADATA = new Set([
13
13
  ".git",
@@ -85,6 +85,17 @@ export function tree(root, { exclude = [] } = {}) {
85
85
  walk(root);
86
86
  return files;
87
87
  }
88
+
89
+ // Exact root paths only: template lockfiles and nested additions stay protected.
90
+ export function bundleFiles(root) {
91
+ return tree(root, {
92
+ exclude: [
93
+ "bundle.json", "evals", "node_modules", "yarn.lock",
94
+ "package-lock.json", "pnpm-lock.yaml",
95
+ ],
96
+ });
97
+ }
98
+
88
99
  export function verifyBundle(root) {
89
100
  const bytes = readFileSync(join(realPathOnly(root), "bundle.json"));
90
101
  const manifest = JSON.parse(bytes);
@@ -99,7 +110,7 @@ export function verifyBundle(root) {
99
110
  && manifest.packageName !== JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')).name)
100
111
  throw new Error("INVALID_BUNDLE");
101
112
  // Maintainer evaluations and generated reports are never part of the delivered capability package.
102
- const actual = tree(root, { exclude: ["bundle.json", "evals"] });
113
+ const actual = bundleFiles(root);
103
114
  if (
104
115
  !manifest.files ||
105
116
  Object.keys(actual).length !== Object.keys(manifest.files).length ||
@@ -1,10 +1,11 @@
1
1
  import test from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
- import { mkdtempSync, readdirSync, readFileSync, rmSync, existsSync } from 'node:fs';
3
+ import { mkdtempSync, readdirSync, readFileSync, writeFileSync, rmSync, existsSync } from 'node:fs';
4
4
  import { tmpdir } from 'node:os';
5
5
  import { join } from 'node:path';
6
6
  import { buildInstallPage, INSTALL_PAGE } from '../../bootstrap/build-install-page.mjs';
7
7
  import { verifyBundle } from '../integrity.mjs';
8
+ import { buildBundle, refreshBundle } from '../assemble.mjs';
8
9
  import { fileURLToPath } from 'node:url';
9
10
  const bundle = fileURLToPath(new URL('../../', import.meta.url));
10
11
 
@@ -39,3 +40,44 @@ test('guide generation refuses output inside its source and missing output witho
39
40
  assert.throws(() => buildInstallPage(directory), /OUTPUT_INSIDE_SOURCE/);
40
41
  assert.equal(existsSync(directory), false);
41
42
  });
43
+
44
+ for (const version of ['7.8.9-alpha.4', '7.8.9']) {
45
+ test('metadata alone selects the generated exact version without rewriting general guides: ' + version, t => {
46
+ const root = mkdtempSync(join(tmpdir(), 'metadata install guide '));
47
+ t.after(() => rmSync(root, { recursive: true, force: true }));
48
+ const source = buildBundle(join(root, 'source'));
49
+ const guides = ['START-HERE.md', 'skills/micro-app-development/references/development-guide.md', 'README.md'];
50
+ const before = guides.map(file => readFileSync(join(source, file), 'utf8'));
51
+ for (const text of before) assert.doesNotMatch(text, /@tuya-sat\/microapp-kit@\d/);
52
+ for (const name of ['package.json', 'bundle.json', 'resources/resource-manifest.json']) {
53
+ const file = join(source, name), value = JSON.parse(readFileSync(file, 'utf8'));
54
+ writeFileSync(file, JSON.stringify({ ...value, version }));
55
+ }
56
+ refreshBundle(source);
57
+ const result = buildInstallPage(join(root, 'generated'), source);
58
+ assert.equal(result.version, version);
59
+ assert.ok(readFileSync(result.file, 'utf8').includes('@tuya-sat/microapp-kit@' + version));
60
+ assert.deepEqual(guides.map(file => readFileSync(join(source, file), 'utf8')), before);
61
+ assert.match(before[0], /package\.json\.version/);
62
+ assert.match(before[0], /bundle\.json\.version/);
63
+ assert.match(before[1], /bundleSha256/);
64
+ assert.match(before[2], /@tuya-sat\/microapp-kit@alpha/);
65
+ });
66
+ }
67
+
68
+ test('metadata disagreement and tampered instructions stop guide generation without writing output', t => {
69
+ const root = mkdtempSync(join(tmpdir(), 'invalid metadata guide '));
70
+ t.after(() => rmSync(root, { recursive: true, force: true }));
71
+ const source = buildBundle(join(root, 'source'));
72
+ const file = join(source, 'package.json'), pkg = JSON.parse(readFileSync(file, 'utf8'));
73
+ writeFileSync(file, JSON.stringify({ ...pkg, version: '99.0.0' }));
74
+ refreshBundle(source);
75
+ const output = join(root, 'generated');
76
+ assert.throws(() => buildInstallPage(output, source), /PACKAGE_VERSION_MISMATCH/);
77
+ assert.equal(existsSync(output), false);
78
+ writeFileSync(file, JSON.stringify(pkg));
79
+ refreshBundle(source);
80
+ writeFileSync(join(source, 'START-HERE.md'), 'tampered instructions');
81
+ assert.throws(() => buildInstallPage(output, source), /BUNDLE_INTEGRITY_MISMATCH/);
82
+ assert.equal(existsSync(output), false);
83
+ });
@@ -6,13 +6,12 @@ import { join } from 'node:path';
6
6
  import { spawnSync } from 'node:child_process';
7
7
  import { packNpm } from '../pack-npm.mjs';
8
8
  import { verifyBundle } from '../integrity.mjs';
9
+ import { buildBundle } from '../assemble.mjs';
10
+ import { buildInstallPage } from '../../bootstrap/build-install-page.mjs';
9
11
 
10
- test('npm tarball installs offline with complete templates; installed bin and cached launcher work', t => {
12
+ for (const ordinary of [false, true]) test(`${ordinary ? 'ordinary npm pack after CI installation' : 'isolated packer'} installs offline with complete templates; setup and cached launcher work`, t => {
11
13
  const temporary = mkdtempSync(join(tmpdir(), 'microapp npm test '));
12
14
  t.after(() => rmSync(temporary, { recursive: true, force: true }));
13
- const artifact = packNpm(join(temporary, 'artifacts'));
14
- assert.equal(artifact.name, '@tuya-sat/microapp-kit');
15
- assert.deepEqual(readdirSync(artifact.installGuideDirectory), ['tuya-microapp-kit-install.md']);
16
15
  const consumer = join(temporary, 'consumer');
17
16
  mkdirSync(consumer);
18
17
  const userConfig = join(temporary, 'npmrc');
@@ -23,7 +22,32 @@ test('npm tarball installs offline with complete templates; installed bin and ca
23
22
  npm_config_userconfig: userConfig,
24
23
  npm_config_cache: join(temporary, 'npm-cache'),
25
24
  npm_config_logs_max: '0',
25
+ npm_config_ignore_scripts: 'false',
26
26
  };
27
+ let artifact;
28
+ if (ordinary) {
29
+ const source = buildBundle(join(temporary, 'source'));
30
+ mkdirSync(join(source, 'node_modules'));
31
+ writeFileSync(join(source, 'node_modules/.yarn-integrity'), '{}');
32
+ writeFileSync(join(source, 'yarn.lock'), '# generated during CI dependency installation\n');
33
+ writeFileSync(join(source, 'package-lock.json'), JSON.stringify({ lockfileVersion: 3 }));
34
+ writeFileSync(join(source, 'pnpm-lock.yaml'), 'lockfileVersion: 9.0\n');
35
+ const output = join(temporary, 'artifacts'); mkdirSync(output);
36
+ const packed = spawnSync('npm', ['pack', '--json', '--offline', '--pack-destination', output], {
37
+ cwd: source, env: environment, encoding: 'utf8', timeout: 60_000,
38
+ });
39
+ assert.equal(packed.status, 0, packed.stderr + packed.stdout);
40
+ const [result] = JSON.parse(packed.stdout);
41
+ const files = new Set(result.files.map(item => item.path));
42
+ for (const name of ['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml', 'node_modules/.yarn-integrity']) {
43
+ assert.equal(files.has(name), false, name);
44
+ assert.equal(verifyBundle(source).files[name], undefined, name);
45
+ }
46
+ const guide = buildInstallPage(join(temporary, 'guide'), source);
47
+ artifact = { name: result.name, version: result.version, file: join(output, result.filename), installGuideDirectory: guide.directory };
48
+ } else artifact = packNpm(join(temporary, 'artifacts'));
49
+ assert.equal(artifact.name, '@tuya-sat/microapp-kit');
50
+ assert.deepEqual(readdirSync(artifact.installGuideDirectory), ['tuya-microapp-kit-install.md']);
27
51
  const installed = spawnSync('npm', [
28
52
  'install', artifact.file, '--offline', '--ignore-scripts', '--package-lock=false', '--no-audit', '--no-fund',
29
53
  ], { cwd: consumer, env: environment, encoding: 'utf8', timeout: 60_000 });
@@ -37,6 +61,9 @@ test('npm tarball installs offline with complete templates; installed bin and ca
37
61
  const guide = readFileSync(join(artifact.installGuideDirectory, 'tuya-microapp-kit-install.md'), 'utf8');
38
62
  assert.ok(guide.includes(artifact.name + '@' + artifact.version));
39
63
  assert.equal(guide.includes('@xuqinghua/microapp-kit'), false);
64
+ for (const name of ['START-HERE.md', 'skills/micro-app-development/references/development-guide.md', 'README.md']) {
65
+ assert.equal(readFileSync(join(bundle, name), 'utf8').includes(artifact.version), false, name);
66
+ }
40
67
  assert.equal(existsSync(join(bundle, 'evals')), false);
41
68
  for (const name of ['.git', '.gitignore', '.gitattributes', 'AGENTS.md']) {
42
69
  assert.equal(existsSync(join(bundle, name)), false, name);
@@ -58,6 +85,11 @@ test('npm tarball installs offline with complete templates; installed bin and ca
58
85
  ]) assert.ok(existsSync(join(bundle, file)), file);
59
86
  const project = join(temporary, 'project');
60
87
  const home = join(temporary, 'test-home');
88
+ const checked = spawnSync(process.execPath, [join(bundle, 'cli.mjs'), 'setup', '--check',
89
+ '--project', project, '--home', home, '--agent', 'codex'], { env: environment, encoding: 'utf8', timeout: 60_000 });
90
+ assert.equal(checked.status, 0, checked.stderr + checked.stdout);
91
+ assert.equal(JSON.parse(checked.stdout).operation, 'setup.check');
92
+ assert.equal(existsSync(project), false);
61
93
  const setup = spawnSync('npm', [
62
94
  'exec', '--offline', '--', 'tuya-microapp-kit', 'setup', '--project', project, '--home', home, '--agent', 'codex',
63
95
  ], { cwd: consumer, env: environment, encoding: 'utf8', timeout: 60_000 });
@@ -0,0 +1,48 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { mkdtempSync, mkdirSync, readFileSync, writeFileSync, rmSync } from 'node:fs';
4
+ import { tmpdir } from 'node:os';
5
+ import { join } from 'node:path';
6
+ import { spawnSync } from 'node:child_process';
7
+ import { buildBundle } from '../assemble.mjs';
8
+ import { verifyBundle } from '../integrity.mjs';
9
+ import { verifyNpmRelease } from '../verify-npm-release.mjs';
10
+
11
+ function fixture(t) {
12
+ const root = mkdtempSync(join(tmpdir(), 'npm release gate '));
13
+ t.after(() => rmSync(root, { recursive: true, force: true }));
14
+ const source = buildBundle(join(root, 'source'));
15
+ mkdirSync(join(source, 'node_modules'));
16
+ writeFileSync(join(source, 'node_modules/.yarn-integrity'), '{}');
17
+ writeFileSync(join(source, 'yarn.lock'), '# generated during CI dependency installation\n');
18
+ return { root, source };
19
+ }
20
+
21
+ test('prepublishOnly verifies the real ordinary archive after dependency installation without publishing', t => {
22
+ const { root, source } = fixture(t);
23
+ const config = join(root, 'npmrc'); writeFileSync(config, '');
24
+ const child = spawnSync('npm', ['run', 'prepublishOnly', '--offline'], {
25
+ cwd: source, encoding: 'utf8', timeout: 60_000,
26
+ env: { PATH: process.env.PATH, HOME: process.env.HOME,
27
+ npm_config_userconfig: config, npm_config_cache: join(root, 'cache'), npm_config_logs_max: '0' },
28
+ });
29
+ assert.equal(child.status, 0, child.stderr + child.stdout);
30
+ assert.match(child.stdout, /"operation":"npm.release.check","status":"verified"/);
31
+ const manifest = verifyBundle(source);
32
+ assert.equal(manifest.files['yarn.lock'], undefined);
33
+ assert.equal(manifest.files['node_modules/.yarn-integrity'], undefined);
34
+ assert.equal(readFileSync(join(source, 'node_modules/.yarn-integrity'), 'utf8'), '{}');
35
+ });
36
+
37
+ test('release gate rejects source files that npm omits instead of blessing an incomplete archive', t => {
38
+ const { source } = fixture(t);
39
+ writeFileSync(join(source, 'unexpected.mjs'), 'export const unexpected = true;');
40
+ assert.throws(() => verifyNpmRelease(source), /BUNDLE_INTEGRITY_MISMATCH/);
41
+ });
42
+
43
+ test('release gate refuses a version changed without aligning its manifest', t => {
44
+ const { source } = fixture(t), file = join(source, 'package.json');
45
+ const pkg = JSON.parse(readFileSync(file, 'utf8'));
46
+ writeFileSync(file, JSON.stringify({ ...pkg, version: '99.0.0' }));
47
+ assert.throws(() => verifyNpmRelease(source), /PACKAGE_VERSION_MISMATCH/);
48
+ });
@@ -27,7 +27,7 @@ test('repository exclusions do not hide product additions, tampering or nested m
27
27
  const root = mkdtempSync(join(tmpdir(), 'kit-repository-boundary-'));
28
28
  t.after(() => rmSync(root, { recursive: true, force: true }));
29
29
  const bundle = buildBundle(join(root, 'bundle'));
30
- for (const name of ['unexpected.mjs', 'runtime/.gitignore', 'resources/template/backend/AGENTS.md']) {
30
+ for (const name of ['unexpected.mjs', 'runtime/.gitignore', 'runtime/yarn.lock', 'resources/template/backend/AGENTS.md']) {
31
31
  writeFileSync(join(bundle, name), 'unexpected');
32
32
  assert.throws(() => verifyBundle(bundle), /BUNDLE_INTEGRITY_MISMATCH/);
33
33
  rmSync(join(bundle, name));
@@ -36,3 +36,34 @@ test('repository exclusions do not hide product additions, tampering or nested m
36
36
  writeFileSync(template, 'tampered');
37
37
  assert.throws(() => verifyBundle(bundle), /BUNDLE_INTEGRITY_MISMATCH/);
38
38
  });
39
+
40
+ test('root install artifacts do not enter bundle identity while template lockfiles remain protected', t => {
41
+ const root = mkdtempSync(join(tmpdir(), 'kit-installed-source-'));
42
+ t.after(() => rmSync(root, { recursive: true, force: true }));
43
+ const bundle = buildBundle(join(root, 'bundle'));
44
+ const before = verifyBundle(bundle).bundleSha256;
45
+ mkdirSync(join(bundle, 'node_modules'));
46
+ writeFileSync(join(bundle, 'node_modules/.yarn-integrity'), '{}');
47
+ for (const name of ['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml']) {
48
+ writeFileSync(join(bundle, name), 'install-generated');
49
+ }
50
+ assert.equal(verifyBundle(bundle).bundleSha256, before);
51
+ assert.equal(refreshBundle(bundle).bundleSha256, before);
52
+ const manifest = JSON.parse(readFileSync(join(bundle, 'bundle.json')));
53
+ assert.equal(Object.keys(manifest.files).some(file => file.startsWith('node_modules/')), false);
54
+ for (const name of ['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml']) assert.equal(manifest.files[name], undefined);
55
+ for (const name of ['resources/template/micro-app/yarn.lock', 'resources/template/backend/pnpm-lock.yaml']) {
56
+ const path = join(bundle, name), original = readFileSync(path);
57
+ assert.ok(manifest.files[name], name);
58
+ writeFileSync(path, 'tampered');
59
+ assert.throws(() => verifyBundle(bundle), /BUNDLE_INTEGRITY_MISMATCH/, name);
60
+ writeFileSync(path, original);
61
+ rmSync(path);
62
+ assert.throws(() => verifyBundle(bundle), /BUNDLE_INTEGRITY_MISMATCH/, name);
63
+ writeFileSync(path, original);
64
+ }
65
+ // An already broken published manifest cannot be accepted by ignoring its missing entries.
66
+ manifest.files['yarn.lock'] = 'a'.repeat(64);
67
+ writeFileSync(join(bundle, 'bundle.json'), JSON.stringify(manifest));
68
+ assert.throws(() => verifyBundle(bundle), /BUNDLE_INTEGRITY_MISMATCH/);
69
+ });
@@ -0,0 +1,43 @@
1
+ // Verify the ordinary npm publishing path without registry access or recursion.
2
+ import { mkdtempSync, mkdirSync, readFileSync, rmSync } from 'node:fs';
3
+ import { tmpdir } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { spawnSync } from 'node:child_process';
7
+ import { refreshBundle } from './assemble.mjs';
8
+ import { realPathOnly, verifyBundle } from './integrity.mjs';
9
+
10
+ const root = fileURLToPath(new URL('../', import.meta.url));
11
+
12
+ export function verifyNpmRelease(directory = root) {
13
+ directory = realPathOnly(directory);
14
+ const manifest = refreshBundle(directory);
15
+ const pkg = JSON.parse(readFileSync(join(directory, 'package.json'), 'utf8'));
16
+ if (pkg.version !== manifest.version) throw new Error('PACKAGE_VERSION_MISMATCH');
17
+ const temporary = mkdtempSync(join(tmpdir(), 'microapp-release-check-'));
18
+ try {
19
+ // Ignore lifecycle scripts here: prepublishOnly is already running this gate.
20
+ const packed = spawnSync('npm', [
21
+ 'pack', '--ignore-scripts', '--json', '--offline', '--pack-destination', temporary,
22
+ '--cache', join(temporary, 'npm-cache'), '--logs-max=0',
23
+ ], { cwd: directory, encoding: 'utf8', timeout: 60_000,
24
+ env: { PATH: process.env.PATH, HOME: process.env.HOME } });
25
+ if (packed.status !== 0) throw new Error('NPM_ARCHIVE_FAILED');
26
+ const archive = join(temporary, `${pkg.name.replace(/^@/, '').replace('/', '-')}-${pkg.version}.tgz`);
27
+ const extracted = join(temporary, 'extracted');
28
+ mkdirSync(extracted);
29
+ const unpacked = spawnSync('tar', ['-xzf', archive, '-C', extracted], { encoding: 'utf8', timeout: 30_000 });
30
+ if (unpacked.status !== 0) throw new Error('NPM_ARCHIVE_VERIFICATION_FAILED');
31
+ const verified = verifyBundle(join(extracted, 'package'));
32
+ if (verified.bundleSha256 !== manifest.bundleSha256) throw new Error('NPM_ARCHIVE_INTEGRITY_MISMATCH');
33
+ return { operation: 'npm.release.check', status: 'verified', name: pkg.name,
34
+ version: pkg.version, bundleSha256: verified.bundleSha256 };
35
+ } finally {
36
+ rmSync(temporary, { recursive: true, force: true });
37
+ }
38
+ }
39
+
40
+ if (process.argv[1] && realPathOnly(process.argv[1]) === realPathOnly(fileURLToPath(import.meta.url))) {
41
+ try { console.log(JSON.stringify(verifyNpmRelease())); }
42
+ catch (error) { console.error(error.message); process.exitCode = 1; }
43
+ }
@@ -3,7 +3,7 @@ name: micro-app-cloud-integration
3
3
  description: >
4
4
  Determine API integration contracts for micro-apps: frontend-facing Tuya standard APIs, custom-aicoding-api gateway and trusted-context integration, and server-to-server APIs when authoritative contracts are supplied. Route custom backend business implementation to micro-app-backend-development.
5
5
  metadata:
6
- version: "0.1.26-alpha.0"
6
+ version: "0.1.26-alpha.1"
7
7
  api-contract-date: "2026-11-17"
8
8
  ---
9
9
 
@@ -12,13 +12,15 @@
12
12
 
13
13
  ## 开始使用
14
14
 
15
- 安装流程统一为:检查当前Node/npm及开发包自己的Node缓存,必要时独立准备Node24;在业务目录外从npm获取精确完整包;调用现有setup/update并验证Skill。环境准备由Agent按固定官方指引执行,保留原有全局环境,不遍历各种版本管理器。
15
+ 安装流程以当前可信完整包的 `START-HERE.md` 为准。开发包名和实际版本读取同一包的 `package.json.name`、`package.json.version`,与 `bundle.json.version` 及清单中的 `packageName`(如有)核对,再校验完整性。本文不声明开发包自身版本。已有可信、匹配目标的完整包直接复用;已安装项目继续使用项目锁的精确版本和 `bundleSha256`,不因文档未写版本而重查 `latest` 或切换工具。
16
16
 
17
- 下载站点只提供一份带产品前缀的简明安装页,不再为新版本生成整流程Shell/PowerShell安装器。包内仍保留仅负责独立Node准备的辅助脚本。已发布0.1.17和已有CDN入口保持可用;新说明页尚待发行上传。详见[工具接入](toolchain-access.md);说明页生成规则在完整包根目录的 `MAINTAINING.md`。
17
+ 检查当前Node/npm及开发包自己的Node缓存,必要时独立准备Node24;尚未取得目标包时在业务目录外从npm获取精确完整包;调用同一包的setup/update并验证Skill。用户指定版本或通道时,按[下载源规则](npm-registry.md)核实一次并锁定精确版本;不跨通道替换,不改锁或跳过完整性校验。环境准备由Agent按固定官方指引执行,保留原有全局环境,不遍历各种版本管理器。
18
+
19
+ 下载站点提供带产品前缀的简明安装页,其精确版本由构建时的包元数据生成,不手工写入通用开发指引。包内仍保留仅负责独立Node准备的辅助脚本。历史脚本和已有CDN入口不改写;兼容边界见[工具接入](toolchain-access.md),说明页生成规则在完整包根目录的 `MAINTAINING.md`。
18
20
 
19
21
  在 Coding Agent 中复制下面这段话:
20
22
 
21
- > 请先确定微应用业务目录,在目录外从 npmjs 获取 @tuya-sat/microapp-kit@0.1.26-alpha.0,按包内 START-HERE.md 准备独立 Node 24 并完成接入,再引导我描述需求、开发和预览。
23
+ > 请先确定微应用业务目录,按当前可信的 @tuya-sat/microapp-kit 完整包中的 START-HERE.md 读取元数据、锁定精确版本并完成接入,再引导我描述需求、开发和预览。
22
24
 
23
25
  随后直接描述需求,例如:
24
26
 
@@ -42,7 +44,7 @@ Agent 会在需要时询问数据组织方式、谁可以操作等业务选择
42
44
 
43
45
  繁体中文统一使用 `zh_tw`,新项目创建 `_locales/zh_tw.json` 和 `src/lang/zh_tw.ts`。已有 `tw` 声明和同名词典继续可用,新构建产物与平台登记/查询归一为 `zh_tw`,不改写源文件或历史归档。不能同时声明 `tw`、`zh_tw`,同一套元数据或页面资源也不能同时保留两种文件名。历史包仍可由平台读取;迁移业务项目时同步声明、文件和运行时,详见[多语言兼容规则](../../micro-app-frontend-development/references/i18n-and-theme.md#项目支持语言)。
44
46
 
45
- 本版本包含0.1.22多语言支持;上传额外语种前,需确认配套平台发布服务已更新;已有项目需显式升级工具,并由Agent保留业务代码补充语言文件和运行时注册,不能只改manifest。已发布包、缓存和已有用户项目不会自动改写。
47
+ 上传额外语种前,需确认配套平台发布服务支持对应语种;已有项目需显式升级工具,并由Agent保留业务代码补充语言文件和运行时注册,不能只改manifest。已发布包、缓存和已有用户项目不会自动改写。
46
48
 
47
49
  ## 继续使用
48
50
 
@@ -159,7 +161,7 @@ Agent 负责本地开发、预览、打包、注册上传和原任务状态跟
159
161
 
160
162
  再次上传时,工具在同工作区、服务、开发者和 code 范围内比较实际前后端内容,忽略打包时间戳等元数据:未完成则接续原发布,完成则向平台发布服务复核后复用,内容变化才发起新请求。微应用版本号始终由平台发布服务分配,失败和在途版本也占用构建号。release history/plan 用于查看本地记录和候选;不可恢复失败或取消需要新目录配合 --new-attempt,可恢复的上传过期及未知结果不能绕过。原包丢失会阻断重复发版,跨机器自动发现尚未实现。详见[版本与请求恢复](publication-recovery.md)。
161
163
 
162
- 已安装项目可使用**目标版本完整包中的 CLI**执行 `update --project <项目> --check` 检查,再执行 `update --project <项目>`。工具成套更新受管 Skill、runtime/resources 引用和项目锁,保留业务代码、DEV 数据、凭据与旧缓存;冲突、在途任务或不兼容状态会阻断。中断用 `update --recover`,成功升级后的工具回退用 `rollback [--to <历史版本>]`。完成后 Agent 仍须重载并读取新版 Skill、执行 doctor/help 验证生效;详见[工具升级](tool-update.md)。上述能力从0.1.2提供,旧npm0.1.1没有升级命令。目标包由Agent按[npm下载源](npm-registry.md)在业务目录外取得,再使用同一完整包执行检查和切换;不通过重新解析latest或更换镜像改变目标。
164
+ 已安装项目可使用**目标版本完整包中的 CLI**执行 `update --project <项目> --check` 检查,再执行 `update --project <项目>`。工具成套更新受管 Skill、runtime/resources 引用和项目锁,保留业务代码、DEV 数据、凭据与旧缓存;冲突、在途任务或不兼容状态会阻断。中断用 `update --recover`,成功升级后的工具回退用 `rollback [--to <历史版本>]`。完成后 Agent 仍须重载并读取新版 Skill、执行 doctor/help 验证生效;详见[工具升级](tool-update.md)。历史工具的升级能力与兼容边界按目标CLI及上述专题指引核对。目标包由Agent按[npm下载源](npm-registry.md)在业务目录外取得,再使用同一完整包执行检查和切换;不通过重新解析latest或更换镜像改变目标。
163
165
 
164
166
 
165
167
  ## 构建日志
@@ -12,9 +12,11 @@
12
12
 
13
13
  ## 先固定目标,再取完整包
14
14
 
15
+ 已有完整包时,先读取该包的 `package.json.name`、`package.json.version`,核对 `bundle.json.version`、清单中如有的 `packageName`、已确认的用户目标及可信来源,完整性通过后锁定精确身份与摘要。不要从文档示例、路径或文件名推断版本;用户未要求其他目标时复用已核验的包,已安装项目则继续使用项目锁。文档没有版本号不是重新解析 `latest` 的理由。
16
+
15
17
  用户明确指定 alpha 内测时,按精确预发布版本获取,或解析明确指定的 `alpha` 标签一次后锁定精确版本;不改用 `latest`、不因镜像未同步而降级到正式旧版。普通用户的默认正式版更新检测保持查询 `latest`,不自动加入 alpha 通道。
16
18
 
17
- 复用已核验的精确目标版本;用户指定版本时不得替换为镜像最新旧版。用户要求 latest 时,以官方版本元数据确认一次,然后锁定精确版本;元数据查询和大归档下载可以分别使用官方源与镜像源,不为下载镜像重新解析 latest。无法确认官方 latest 时明确“官方最新版暂时无法确认”,继续已安装版本的开发;不能把镜像的旧 latest 或本地开发版说成官方最新版。目标已确认时不重复查询 latest。
19
+ 复用已核验的精确目标版本;用户指定版本时不得替换为镜像最新旧版。用户要求 latest 时,以官方版本元数据确认一次,然后锁定精确版本;正式标签意外返回预发布版时说明标签异常并停止本次正式版获取,不自动改装内测版或另选版本。元数据查询和大归档下载可以分别使用官方源与镜像源,不为下载镜像重新解析 latest。无法确认官方 latest 时明确“官方最新版暂时无法确认”,继续已安装版本的开发;不能把镜像的旧 latest 或本地开发版说成官方最新版。目标已确认时不重复查询 latest。
18
20
 
19
21
  已有可信且版本/摘要匹配的完整包直接复用。需要下载时,在业务目录外用 `npm pack`,或 `npm install --prefix ... --save-exact --ignore-scripts --no-audit --no-fund`,对同一精确包指定选定 registry。命令由 Agent 填入实际包名、版本和路径,不让用户替换占位符。
20
22
 
@@ -4,6 +4,8 @@
4
4
 
5
5
  用户要求更新开发包时,使用**目标版本完整包中的 CLI**,不要让旧版 setup 覆盖已有安装,也不要手改项目锁。Skill、脚本、runtime/resources 统一按同一个精确版本和摘要升级;微应用组合版本仍由平台发布服务分配,与工具版本无关。
6
6
 
7
+ 历史个人包的 update 能力从 0.1.2 提供,0.1.1 自身没有升级命令;目标完整包是否支持旧安装,仍须按真实兼容边界检查,不因此绕过下面的跨包名迁移限制。
8
+
7
9
  个人 0.1.24 或 0.1.25 升级到公司正式包时,先读[发布目标与一次性迁移](workspace-environments.md#个人包到公司包)。两者均可直接迁移,无需额外中转版本。使用公司目标完整包执行检查,保留可核验的原服务目标;不能因新版默认正式而切换旧预发记录。包名以目标分发元数据为准。
8
10
 
9
11
  ## Agent 流程
@@ -16,6 +16,8 @@ setup 必须显式指定最终业务根目录;先确定目录再安装 Skill
16
16
 
17
17
  获取 npm 包的临时目录位于业务目录外,精确版本由可信源核实;只读取所获取完整包的入口,不以相邻源码或其他项目文档替代。已有业务源码不通过移动文件伪装空目录。npm 安装材料误放业务目录时先识别,只清理由本轮获取明确产生的材料,不能自动移动用户业务文件。
18
18
 
19
+ 完整包的实际名称和版本按 `START-HERE.md` 从 `package.json`、`bundle.json` 核对,通用文档不重复声明自身版本。用户未要求其他目标时复用已核验完整包;已接入项目继续按项目锁执行,不因文档没有版本号而查询 `latest` 或重做接入。
20
+
19
21
  下载来源按[npm 源规则](npm-registry.md):中国优先npmmirror,中国以外官方;镜像缺少目标时仅回退官方源一次,固定同一精确版本并保留完整性验证。只用本次--registry,不改全局npm配置,不把下载源当作微应用工作区服务或部署区域。
20
22
 
21
23
  ## 缓存与项目锁