@dp-bohrium/widget-cli 0.4.0 → 0.5.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/llms.txt CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  > Widget 工程的本地创建、迁移、校验、开发、构建和打包工具;可由 Bohr CLI 桥接或调度。
4
4
 
5
- 要求 Node.js >=20。CLI 发布包固定 SDK/compiler、contracts/Schema、校验器和模板,
6
- 提供文档站地址,不再内置 skills。生成工程仍安装自己的精确版本依赖。
5
+ 要求 Node.js >=20;默认生成工程构建器要求 `^22.18.0 || >=24.11.0`。
6
+ 生成工程精确依赖 SDK 与构建器,类型、Schema 和工程命令均由 SDK 提供。
7
7
 
8
8
  先看全局帮助,再按命令查看参数、默认值、示例和必要提示:
9
9
 
@@ -19,14 +19,15 @@ pnpm exec bohr-widget --version --json
19
19
  `<命令路径> --help` 与 `help <命令路径>` 查看对应层级;例如 `dev -h`、`pack --help` 或
20
20
  `migrate dsh --help`。`-v` / `--version` 等价于 `version`,`--version --json` 等价于 `version --json`。
21
21
  帮助仅输出本地文本,不执行所选命令或联网获取文档。npm 的全局帮助用
22
- `npx --no-install bohr-widget --help`,其他命令同样替换前缀;未安装时可用
23
- 新工程优先用 `pnpm dlx @dp-bohrium/widget-sdk --help`;本包入口在兼容期保持可用。
22
+ `npx --no-install bohr-widget --help`,其他命令同样替换前缀。
23
+ 创建新工程可使用 `pnpm dlx @dp-bohrium/widget-sdk --help`;工具集成可使用
24
+ `pnpm dlx @dp-bohrium/widget-cli --help`,并核对实际执行包的身份、版本与 SDK profile。
24
25
 
25
26
  ## Agent 入口
26
27
 
27
28
  - [Agent 使用说明](./AGENTS.md): 命令参数、执行顺序、错误恢复和安全边界。
28
29
  - [README](./README.md): 安装、模板和公开 core 出口。
29
- - [更新记录](./CHANGELOG.md): 当前 CLI 的使用者可感知变化;配套包职责与 npm 链接见 README。
30
+ - [更新记录](./CHANGELOG.md): 版本与更新记录。
30
31
  - [文档站索引](https://dev.dp.tech/bohrium-widget-sdk/llms.txt): 先按任务选择教程或参考。
31
32
  - [完整文档](https://dev.dp.tech/bohrium-widget-sdk/llms-full.txt): 文档站自动生成的全文。
32
33
  - 自闭环范围:本包负责本地工程闭环;上传、平台预览、版本发布和 Agent 绑定不在本包内执行。
@@ -37,12 +38,12 @@ pnpm exec bohr-widget --version --json
37
38
 
38
39
  ## 本地闭环
39
40
 
40
- - `integration --json`: `interfaceVersion=2`,返回固定 profile、执行器位置、
41
- `toolchain.formatVersion=2` 和 `documentation { url, quickStart, cli, llms, llmsFull }`,
41
+ - `integration --json`: `interfaceVersion=3`,返回固定 profile、执行器位置、
42
+ `toolchain.formatVersion=3` 和 `documentation { url, quickStart, cli, llms, llmsFull }`,
42
43
  不返回 `skills`。已有工程加 `--project <目录>` 核对锁定,再读取对应参考。
43
- - `create`: 创建 vanilla 或 React 工程并写 `widget-toolchain.json`;工作区文件面板使用
44
- `--panel-id workspace-files`。
45
- - `adopt`: 为旧工程显式写入工具链锁,先核对精确依赖、实际 SDK/contracts、Manifest 和 samples。
44
+ - `create`: 创建 vanilla 或 React 工程并写 `widget-toolchain.json`;Panel ID 可自定义,
45
+ `--panel-id workspace-files` 是可选的文件浏览面板预设。
46
+ - `adopt`: 为旧工程显式写入工具链锁,先核对精确依赖、实际 SDK 与内置协议摘要、Manifest 和 samples。
46
47
  - SDK 0.5.0 的任务 Panel 在 Manifest 声明 `capabilities.tasks.list`;需要观察单个任务时再声明
47
48
  `tasks.watch`。列表刷新遵守 grant 的 `minPollMs`,面板不可见后停止轮询;CLI 校验通过不代表
48
49
  目标 Host 已签发 grant,详见 AGENTS.md。
@@ -53,10 +54,11 @@ pnpm exec bohr-widget --version --json
53
54
  当前工作目录为根,找不到工程时返回 `WIDGET_CLI_NO_WIDGET_PROJECT`,不会静默通过。
54
55
  - `dev`: 启动本地开发服务器和 Host Bridge 连接;每轮重建检查锁定信息和实际依赖,失败时保留上一轮。
55
56
  - `build`: 委托工程自己的构建命令,并拒绝“退出 0 但仍有未解析依赖”的结果,写入构建 receipt。
56
- - `pack`: 生成可交给平台的 ZIP,并输出 SHA-256 digest、Manifest 摘要和 CLI/SDK/Contracts 版本。
57
+ - `pack`: 生成可交给平台的 ZIP,并输出 SHA-256 digest、Manifest 摘要、执行器身份与版本、
58
+ SDK profile 和协议标识。
57
59
  `--no-build` 要求 `.widget-build-receipt.json` 的工具链、实际依赖、输入和产物摘要全部匹配。
58
60
  执行摘要仅含 `compiler`、`validators`、`schemas`、`templates`;文档站正文更新不影响
59
- receipt,也不要求 CLI 发版。
61
+ receipt。
60
62
  - `doctor`: 输出 Node、固定 profile 和工程状态;始终核对候选 profile 的精确依赖,已有锁定时再核对
61
63
  profile,`ready` 还要求锁定、依赖和入口。
62
64
  - `schema`: 输出插件 Manifest Schema 路径。
@@ -68,8 +70,8 @@ pnpm exec bohr-widget --version --json
68
70
 
69
71
  `--host-compat <文件>` 接受平台 statement 与调用方 observation。状态 `unknown` 表示无声明,
70
72
  `snapshot` 表示匹配的快照或过期声明,`confirmed` 表示调用方报告在线取得、仍有效且匹配当前
71
- profile;它不代表发布成功。无效声明或不匹配 profile 会报错。当前完成 A、B 本地能力,平台在线
72
- 发现接口和 Bohr 获取声明仍需后续接入。
73
+ profile;它不代表发布成功。无效声明或不匹配 profile 会报错。
74
+ CLI 不自动获取线上声明,调用方需提供目标 Host 的兼容证据。
73
75
 
74
76
  ## 平台侧动作
75
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dp-bohrium/widget-cli",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Bohrium Widget 插件工程的创建、校验、开发和打包工具。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,47 +24,43 @@
24
24
  "import": "./dist/cli.mjs"
25
25
  },
26
26
  "./core": {
27
- "types": "./src/core.d.mts",
27
+ "types": "./dist/core.d.mts",
28
28
  "import": "./dist/core.mjs"
29
29
  },
30
30
  "./development-host": {
31
- "types": "./src/development-host.d.mts"
31
+ "types": "./dist/development-host.d.mts"
32
32
  },
33
33
  "./package.json": "./package.json"
34
34
  },
35
35
  "files": [
36
36
  "dist",
37
37
  "assets",
38
- "src/core.d.mts",
39
- "src/development-host.d.mts",
40
38
  "README.md",
41
39
  "AGENTS.md",
42
40
  "llms.txt",
43
41
  "CHANGELOG.md",
44
42
  "LICENSE"
45
43
  ],
46
- "publishConfig": {
47
- "access": "public"
48
- },
49
44
  "devDependencies": {
50
45
  "@biomejs/biome": "^2.2.0",
51
46
  "@types/node": "^22.15.0",
52
47
  "tsdown": "0.22.14",
53
48
  "typescript": "5.9.3",
54
- "@dp-bohrium/widget-contract-testing": "0.1.0-alpha.0",
55
- "@dp-bohrium/widget-contracts": "0.6.0",
56
- "@dp-bohrium/widget-sdk": "0.6.0"
49
+ "@dp-bohrium/widget-sdk": "0.8.0"
57
50
  },
58
51
  "sideEffects": false,
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
59
55
  "scripts": {
60
- "build:assets": "node scripts/build-assets.mjs",
61
- "build:inputs": "pnpm --filter @dp-bohrium/widget-sdk... run build && pnpm --filter @dp-bohrium/widget-contract-testing run build",
62
- "build": "pnpm build:inputs && pnpm build:assets && tsdown && node --check dist/cli.mjs",
63
- "typecheck": "node --check src/cli.mjs && node --check src/help.mjs && node --check src/core.mjs && node --check src/templates.mjs && node --check src/toolchain.mjs && node --check src/project-executor.mjs && node --check scripts/build-assets.mjs",
64
- "test": "pnpm build:inputs && pnpm build:assets && node --test test/*.test.mjs",
56
+ "package:contents": "node ../../scripts/quality/check-widget-cli-package-contents.mjs ../../.artifacts/dp-bohrium-widget-cli-*.tgz",
57
+ "build": "node ../../scripts/build/widget-build.mjs cli",
58
+ "typecheck": "node --check src/cli.mjs && node --check src/help.mjs && node --check src/core.mjs && node --check src/templates.mjs && node --check src/toolchain.mjs && node --check src/project-executor.mjs && node --check scripts/build-assets.mjs && tsc --project tsconfig.project.json",
59
+ "test": "node ../../scripts/build/with-build.mjs all -- node --test test/*.test.mjs test/project/*.test.mjs",
65
60
  "lint": "biome check src test scripts",
66
61
  "format:check": "biome check --linter-enabled=false src test scripts",
67
- "package:contents": "node ../../scripts/quality/check-widget-cli-package-contents.mjs ../../.artifacts/dp-bohrium-widget-cli-*.tgz",
68
- "check": "pnpm --filter @dp-bohrium/widget-contracts build && pnpm --filter @dp-bohrium/widget-contract-testing build && pnpm --filter widget-project build && pnpm typecheck && pnpm test && pnpm lint && pnpm format:check && pnpm build"
62
+ "check": "pnpm typecheck && pnpm test && pnpm lint && pnpm format:check && pnpm build",
63
+ "test:coverage": "node ../../scripts/build/with-build.mjs all -- node --experimental-test-coverage --test-coverage-include=src/project/*.mjs --test-coverage-lines=80 --test-coverage-functions=80 --test-coverage-branches=70 --test test/project/*.test.mjs",
64
+ "build:tools": "node ../../scripts/build/widget-build.mjs tools"
69
65
  }
70
66
  }
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 DP Technology
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/src/core.d.mts DELETED
@@ -1,58 +0,0 @@
1
- export interface WidgetTemplateContext {
2
- readonly name: string;
3
- readonly ui?: "vanilla" | "react" | string;
4
- }
5
-
6
- export interface WidgetTemplate {
7
- readonly id: string;
8
- readonly description?: string;
9
- manifest(context: WidgetTemplateContext): Record<string, unknown>;
10
- sample(context: WidgetTemplateContext): Record<string, unknown>;
11
- readonly source: string | ((context: WidgetTemplateContext) => string);
12
- }
13
-
14
- export interface WidgetTemplateRegistry {
15
- register(template: WidgetTemplate): WidgetTemplate;
16
- get(id: string): WidgetTemplate | undefined;
17
- list(): readonly WidgetTemplate[];
18
- }
19
-
20
- export declare function defineWidgetTemplate(
21
- template: WidgetTemplate,
22
- ): WidgetTemplate;
23
- export declare function createWidgetTemplateRegistry(
24
- initialTemplates?: readonly WidgetTemplate[],
25
- ): WidgetTemplateRegistry;
26
-
27
- export declare function compileAuthorManifest(
28
- manifest: Record<string, unknown>,
29
- options?: Record<string, unknown>,
30
- ): Record<string, unknown>;
31
- export declare function checkWidgetProject(
32
- projectRoot: string,
33
- options?: Record<string, unknown>,
34
- ): Promise<Record<string, unknown>>;
35
- export declare function resolveWidgetProjects(input: string): readonly string[];
36
- export declare function auditDshPlugin(
37
- input: string,
38
- ): Promise<Record<string, unknown>>;
39
- export declare function scaffoldDshWidget(
40
- input: string,
41
- output: string,
42
- options?: Record<string, unknown>,
43
- ): Promise<Record<string, unknown>>;
44
- export declare function buildWidgetPackage(
45
- project: Record<string, unknown>,
46
- options?: Record<string, unknown>,
47
- ): Uint8Array;
48
-
49
- export declare const widgetCliCore: {
50
- readonly buildWidgetPackage: typeof buildWidgetPackage;
51
- readonly checkWidgetProject: typeof checkWidgetProject;
52
- readonly compileAuthorManifest: typeof compileAuthorManifest;
53
- readonly resolveWidgetProjects: typeof resolveWidgetProjects;
54
- readonly createWidgetTemplateRegistry: typeof createWidgetTemplateRegistry;
55
- readonly defineWidgetTemplate: typeof defineWidgetTemplate;
56
- readonly auditDshPlugin: typeof auditDshPlugin;
57
- readonly scaffoldDshWidget: typeof scaffoldDshWidget;
58
- };