@dp-bohrium/widget-cli 0.2.0 → 0.4.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/dist/core.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as resolveWidgetProjects, l as compileAuthorManifest, n as scaffoldDshWidget, r as buildWidgetPackage, s as checkWidgetProject, t as auditDshPlugin } from "./dsh-BzxDpEcZ.mjs";
1
+ import { c as resolveWidgetProjects, l as compileAuthorManifest, n as scaffoldDshWidget, r as buildWidgetPackage, s as checkWidgetProject, t as auditDshPlugin } from "./dsh-BvnlfCRX.mjs";
2
2
  //#region src/core.mjs
3
3
  /** Validate a community template before registering it in a custom CLI. */
4
4
  function defineWidgetTemplate(template) {
@@ -95,9 +95,9 @@ function collectReferencedFileIds(request) {
95
95
  return referenced;
96
96
  }
97
97
  //#endregion
98
- //#region ../widget-sdk/dist/runtime-RyAEhkyn.js
98
+ //#region ../widget-sdk/dist/runtime-D7KxTtdu.js
99
99
  /** 从当前安装的 SDK package.json 读取版本,插件作者不需要重复填写。 */
100
- const WIDGET_SDK_VERSION = "0.4.1";
100
+ const WIDGET_SDK_VERSION = "0.6.0";
101
101
  //#endregion
102
102
  //#region ../widget-sdk/dist/index.js
103
103
  function compiledContribution(contribution) {
@@ -6824,7 +6824,7 @@ var require_json_schema_2020_12 = /* @__PURE__ */ __commonJSMin(((exports) => {
6824
6824
  exports.default = addMetaSchema2020;
6825
6825
  }));
6826
6826
  //#endregion
6827
- //#region ../contract-testing/dist/manifest-validator-DCdGSuVM.js
6827
+ //#region ../contract-testing/dist/manifest-validator-DUzSsw8D.js
6828
6828
  var import__2020 = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
6829
6829
  Object.defineProperty(exports, "__esModule", { value: true });
6830
6830
  exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv2020 = void 0;
@@ -7036,12 +7036,15 @@ const widgetManifestSchema = {
7036
7036
  } }
7037
7037
  },
7038
7038
  "TasksCapabilityRequest": {
7039
- "description": "任务观察能力的申请;watch 固定为 true。",
7039
+ "description": "任务发现与观察能力的申请;list / watch 至少显式申请一项,已申请项固定为 true。",
7040
7040
  "title": "TasksCapabilityRequest",
7041
7041
  "type": "object",
7042
7042
  "additionalProperties": false,
7043
- "required": ["watch"],
7044
- "properties": { "watch": { "const": true } }
7043
+ "minProperties": 1,
7044
+ "properties": {
7045
+ "list": { "const": true },
7046
+ "watch": { "const": true }
7047
+ }
7045
7048
  },
7046
7049
  "StateCapabilityRequest": {
7047
7050
  "description": "受限 UI 状态读写能力的申请;read / write 分别声明。",
@@ -7471,6 +7474,9 @@ const widgetRuntimeContractsSchema = {
7471
7474
  "taskObservationSnapshot": { "$ref": "#/$defs/TaskObservationSnapshot" },
7472
7475
  "taskObservationEvent": { "$ref": "#/$defs/TaskObservationEvent" },
7473
7476
  "taskObservationBatch": { "$ref": "#/$defs/TaskObservationBatch" },
7477
+ "taskListField": { "$ref": "#/$defs/TaskListField" },
7478
+ "taskListItem": { "$ref": "#/$defs/TaskListItem" },
7479
+ "taskListPage": { "$ref": "#/$defs/TaskListPage" },
7474
7480
  "toolResultEnvelope": { "$ref": "#/$defs/ToolResultEnvelope" },
7475
7481
  "uiStateResult": { "$ref": "#/$defs/UiStateResult" },
7476
7482
  "uiStateWriteResult": { "$ref": "#/$defs/UiStateWriteResult" },
@@ -7861,6 +7867,18 @@ const widgetRuntimeContractsSchema = {
7861
7867
  "cancelled"
7862
7868
  ] } }
7863
7869
  },
7870
+ "TaskStatus": {
7871
+ "description": "Host 投影给 Widget 的统一任务状态。",
7872
+ "title": "TaskStatus",
7873
+ "enum": [
7874
+ "queued",
7875
+ "running",
7876
+ "succeeded",
7877
+ "failed",
7878
+ "cancelled",
7879
+ "expired"
7880
+ ]
7881
+ },
7864
7882
  "TaskObservationSnapshot": {
7865
7883
  "description": "任务观察的当前快照:taskId、status 与 updatedAt;progress、message 可选。",
7866
7884
  "title": "TaskObservationSnapshot",
@@ -7877,14 +7895,7 @@ const widgetRuntimeContractsSchema = {
7877
7895
  "minLength": 1,
7878
7896
  "maxLength": 256
7879
7897
  },
7880
- "status": { "enum": [
7881
- "queued",
7882
- "running",
7883
- "succeeded",
7884
- "failed",
7885
- "cancelled",
7886
- "expired"
7887
- ] },
7898
+ "status": { "$ref": "#/$defs/TaskStatus" },
7888
7899
  "progress": {
7889
7900
  "type": "number",
7890
7901
  "minimum": 0,
@@ -7968,6 +7979,110 @@ const widgetRuntimeContractsSchema = {
7968
7979
  }
7969
7980
  }
7970
7981
  },
7982
+ "TaskListField": {
7983
+ "description": "任务列表中的受限展示字段;key 是稳定机器键,value 是 Host 裁剪后的展示文本。",
7984
+ "title": "TaskListField",
7985
+ "type": "object",
7986
+ "additionalProperties": false,
7987
+ "required": ["key", "value"],
7988
+ "properties": {
7989
+ "key": {
7990
+ "description": "展示字段的稳定机器键,例如 machine 或 command。",
7991
+ "type": "string",
7992
+ "minLength": 1,
7993
+ "maxLength": 64,
7994
+ "pattern": "^[A-Za-z][A-Za-z0-9_.:-]*$"
7995
+ },
7996
+ "value": {
7997
+ "description": "Host 完成授权与裁剪后的展示文本。",
7998
+ "type": "string",
7999
+ "maxLength": 16384
8000
+ }
8001
+ }
8002
+ },
8003
+ "TaskListItem": {
8004
+ "description": "Host 已授权发现的任务摘要;taskId 是可继续传给 tasks.watch 的不透明引用。",
8005
+ "title": "TaskListItem",
8006
+ "type": "object",
8007
+ "additionalProperties": false,
8008
+ "required": [
8009
+ "taskId",
8010
+ "kind",
8011
+ "name",
8012
+ "status",
8013
+ "updatedAt",
8014
+ "fields"
8015
+ ],
8016
+ "properties": {
8017
+ "taskId": {
8018
+ "description": "可继续传给 tasks.watch 的 Host 不透明任务引用。",
8019
+ "type": "string",
8020
+ "minLength": 1,
8021
+ "maxLength": 256
8022
+ },
8023
+ "kind": {
8024
+ "description": "任务来源类型的稳定机器键。",
8025
+ "type": "string",
8026
+ "minLength": 1,
8027
+ "maxLength": 64,
8028
+ "pattern": "^[A-Za-z][A-Za-z0-9_.:-]*$"
8029
+ },
8030
+ "name": {
8031
+ "description": "任务的安全展示名称。",
8032
+ "type": "string",
8033
+ "minLength": 1,
8034
+ "maxLength": 256
8035
+ },
8036
+ "status": { "$ref": "#/$defs/TaskStatus" },
8037
+ "progress": {
8038
+ "description": "可选执行进度,取值范围为 0 到 1。",
8039
+ "type": "number",
8040
+ "minimum": 0,
8041
+ "maximum": 1
8042
+ },
8043
+ "message": {
8044
+ "description": "Host 裁剪后的可选状态说明。",
8045
+ "type": "string",
8046
+ "maxLength": 1024
8047
+ },
8048
+ "updatedAt": {
8049
+ "description": "任务摘要最后更新时间,使用 UTC ISO 8601 字符串。",
8050
+ "type": "string",
8051
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T[^ ]+Z$"
8052
+ },
8053
+ "fields": {
8054
+ "description": "任务面板可展示的受限附加字段。",
8055
+ "type": "array",
8056
+ "maxItems": 32,
8057
+ "items": { "$ref": "#/$defs/TaskListField" }
8058
+ }
8059
+ }
8060
+ },
8061
+ "TaskListPage": {
8062
+ "description": "Host 已授权任务摘要的一页结果;nextCursor 缺失表示当前页已到末尾。",
8063
+ "title": "TaskListPage",
8064
+ "type": "object",
8065
+ "additionalProperties": false,
8066
+ "required": ["schemaVersion", "tasks"],
8067
+ "properties": {
8068
+ "schemaVersion": {
8069
+ "description": "任务列表页结构版本,当前固定为 1。",
8070
+ "const": 1
8071
+ },
8072
+ "tasks": {
8073
+ "description": "当前页中 Host 已授权的任务摘要。",
8074
+ "type": "array",
8075
+ "maxItems": 100,
8076
+ "items": { "$ref": "#/$defs/TaskListItem" }
8077
+ },
8078
+ "nextCursor": {
8079
+ "description": "下一页的不透明游标;缺失表示当前列表已到末尾。",
8080
+ "type": "string",
8081
+ "minLength": 1,
8082
+ "maxLength": 512
8083
+ }
8084
+ }
8085
+ },
7971
8086
  "ToolResultMetric": {
7972
8087
  "description": "工具结果中的单个指标。",
7973
8088
  "title": "ToolResultMetric",
@@ -8346,6 +8461,40 @@ const widgetRuntimeContractsSchema = {
8346
8461
  }
8347
8462
  }
8348
8463
  },
8464
+ {
8465
+ "type": "object",
8466
+ "additionalProperties": false,
8467
+ "required": ["name", "limits"],
8468
+ "properties": {
8469
+ "name": { "const": "tasks.list" },
8470
+ "limits": {
8471
+ "type": "object",
8472
+ "additionalProperties": false,
8473
+ "required": [
8474
+ "callsPerMinute",
8475
+ "pageSize",
8476
+ "minPollMs"
8477
+ ],
8478
+ "properties": {
8479
+ "callsPerMinute": {
8480
+ "type": "integer",
8481
+ "minimum": 1,
8482
+ "maximum": 9007199254740991
8483
+ },
8484
+ "pageSize": {
8485
+ "type": "integer",
8486
+ "minimum": 1,
8487
+ "maximum": 100
8488
+ },
8489
+ "minPollMs": {
8490
+ "type": "integer",
8491
+ "minimum": 1e3,
8492
+ "maximum": 6e4
8493
+ }
8494
+ }
8495
+ }
8496
+ }
8497
+ },
8349
8498
  {
8350
8499
  "type": "object",
8351
8500
  "additionalProperties": false,
@@ -8831,6 +8980,30 @@ const widgetRuntimeContractsSchema = {
8831
8980
  }
8832
8981
  }
8833
8982
  },
8983
+ {
8984
+ "type": "object",
8985
+ "additionalProperties": false,
8986
+ "required": ["operation", "input"],
8987
+ "properties": {
8988
+ "operation": { "const": "tasks.list" },
8989
+ "input": {
8990
+ "type": "object",
8991
+ "additionalProperties": false,
8992
+ "properties": {
8993
+ "cursor": {
8994
+ "type": "string",
8995
+ "minLength": 1,
8996
+ "maxLength": 512
8997
+ },
8998
+ "limit": {
8999
+ "type": "integer",
9000
+ "minimum": 1,
9001
+ "maximum": 100
9002
+ }
9003
+ }
9004
+ }
9005
+ }
9006
+ },
8834
9007
  {
8835
9008
  "type": "object",
8836
9009
  "additionalProperties": false,
@@ -11265,9 +11438,9 @@ function activate(context: WidgetContext) {
11265
11438
 
11266
11439
  export { activate };
11267
11440
  `;
11268
- function projectFiles({ name, displayName, data, source = panelSource, capabilities, placement, sdkVersion, contractsVersion }) {
11441
+ function projectFiles({ name, displayName, data, source = panelSource, capabilities, placement, sdkVersion }) {
11269
11442
  const manifest = {
11270
- $schema: "@dp-bohrium/widget-contracts/schemas/widget-plugin-manifest.schema.json",
11443
+ $schema: "@dp-bohrium/widget-sdk/schemas/widget-plugin-manifest.schema.json",
11271
11444
  name,
11272
11445
  version: "0.1.0",
11273
11446
  displayName,
@@ -11344,10 +11517,13 @@ function projectFiles({ name, displayName, data, source = panelSource, capabilit
11344
11517
  name: `@dp-bohrium/${name}`,
11345
11518
  private: true,
11346
11519
  type: "module",
11347
- scripts: { build: "tsc --noEmit && tsdown && node scripts/rename-iife.mjs" },
11520
+ scripts: {
11521
+ build: "tsc --noEmit && tsdown && node scripts/rename-iife.mjs",
11522
+ check: "bohr-widget check .",
11523
+ "widget:pack": "bohr-widget pack ."
11524
+ },
11348
11525
  dependencies: { "@dp-bohrium/widget-sdk": sdkVersion },
11349
11526
  devDependencies: {
11350
- "@dp-bohrium/widget-contracts": contractsVersion,
11351
11527
  tsdown: "0.22.14",
11352
11528
  typescript: "5.9.3"
11353
11529
  }
@@ -11404,7 +11580,6 @@ const DSH_RECIPES = [
11404
11580
  mode: "replace"
11405
11581
  } },
11406
11582
  sdkVersion: options.sdkVersion,
11407
- contractsVersion: options.contractsVersion,
11408
11583
  data: {
11409
11584
  source: "dsh-better-sidebar",
11410
11585
  behavior: "session-scoped right rail replacement shell",
@@ -11430,7 +11605,6 @@ const DSH_RECIPES = [
11430
11605
  name: "dsh-tool-calculator-widget",
11431
11606
  displayName: "DSH Calculator · Bohrium Widget",
11432
11607
  sdkVersion: options.sdkVersion,
11433
- contractsVersion: options.contractsVersion,
11434
11608
  data: {
11435
11609
  source: "@deepseek-ai/dsh-tool-calculator",
11436
11610
  behavior: "safe expression evaluation",
@@ -11456,7 +11630,6 @@ const DSH_RECIPES = [
11456
11630
  name: "dsh-plugin-academic-writing-widget",
11457
11631
  displayName: "Academic Writing · Bohrium Widget",
11458
11632
  sdkVersion: options.sdkVersion,
11459
- contractsVersion: options.contractsVersion,
11460
11633
  data: {
11461
11634
  source: "dsh-plugin-academic-writing",
11462
11635
  behavior: "outline/title/abstract/citation/checklist",
@@ -11477,7 +11650,6 @@ const DSH_RECIPES = [
11477
11650
  name: "dsh-academic-research-widget",
11478
11651
  displayName: "Academic Research · Bohrium Widget",
11479
11652
  sdkVersion: options.sdkVersion,
11480
- contractsVersion: options.contractsVersion,
11481
11653
  data: {
11482
11654
  source: "@onpeople/dsh-academic-research",
11483
11655
  behavior: "Crossref/OpenAlex evidence records",
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # @dp-bohrium/widget-cli
2
2
 
3
- > Widget 工程的本地创建、校验、开发、构建和打包工具;可由 Bohr CLI 桥接或调度。
3
+ > Widget 工程的本地创建、迁移、校验、开发、构建和打包工具;可由 Bohr CLI 桥接或调度。
4
4
 
5
5
  要求 Node.js >=20。CLI 发布包固定 SDK/compiler、contracts/Schema、校验器和模板,
6
6
  提供文档站地址,不再内置 skills。生成工程仍安装自己的精确版本依赖。
@@ -20,7 +20,7 @@ pnpm exec bohr-widget --version --json
20
20
  `migrate dsh --help`。`-v` / `--version` 等价于 `version`,`--version --json` 等价于 `version --json`。
21
21
  帮助仅输出本地文本,不执行所选命令或联网获取文档。npm 的全局帮助用
22
22
  `npx --no-install bohr-widget --help`,其他命令同样替换前缀;未安装时可用
23
- `pnpm dlx @dp-bohrium/widget-cli --help` 查看入口。
23
+ 新工程优先用 `pnpm dlx @dp-bohrium/widget-sdk --help`;本包入口在兼容期保持可用。
24
24
 
25
25
  ## Agent 入口
26
26
 
@@ -31,6 +31,10 @@ pnpm exec bohr-widget --version --json
31
31
  - [完整文档](https://dev.dp.tech/bohrium-widget-sdk/llms-full.txt): 文档站自动生成的全文。
32
32
  - 自闭环范围:本包负责本地工程闭环;上传、平台预览、版本发布和 Agent 绑定不在本包内执行。
33
33
 
34
+ ## 准备迁移候选
35
+
36
+ 保留已有源码、跨 profile 升级或准备候选工程时,先读[准备迁移候选](https://dev.dp.tech/bohrium-widget-sdk/guides/migration),由该指南维护准备、应用与验收边界。
37
+
34
38
  ## 本地闭环
35
39
 
36
40
  - `integration --json`: `interfaceVersion=2`,返回固定 profile、执行器位置、
@@ -39,7 +43,10 @@ pnpm exec bohr-widget --version --json
39
43
  - `create`: 创建 vanilla 或 React 工程并写 `widget-toolchain.json`;工作区文件面板使用
40
44
  `--panel-id workspace-files`。
41
45
  - `adopt`: 为旧工程显式写入工具链锁,先核对精确依赖、实际 SDK/contracts、Manifest 和 samples。
42
- - SDK 0.4.0 文件读写按需在 Manifest 声明 `capabilities.files.read/write`,再实现
46
+ - SDK 0.5.0 的任务 Panel 在 Manifest 声明 `capabilities.tasks.list`;需要观察单个任务时再声明
47
+ `tasks.watch`。列表刷新遵守 grant 的 `minPollMs`,面板不可见后停止轮询;CLI 校验通过不代表
48
+ 目标 Host 已签发 grant,详见 AGENTS.md。
49
+ - SDK 0.5.0 文件读写按需在 Manifest 声明 `capabilities.files.read/write`,再实现
43
50
  `context.files.read/write`;创建命令和模板保持原样。保存使用读取回执的内容版本与 mutationId,
44
51
  缺授权、版本或完整性证据时只读;冲突/未知结果保留草稿且不自动重试,详见 AGENTS.md。
45
52
  - `check` / `validate`: 校验作者清单、Manifest、entry、samples 和 fixtures;`check all` 以
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dp-bohrium/widget-cli",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Bohrium Widget 插件工程的创建、校验、开发和打包工具。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -52,8 +52,8 @@
52
52
  "tsdown": "0.22.14",
53
53
  "typescript": "5.9.3",
54
54
  "@dp-bohrium/widget-contract-testing": "0.1.0-alpha.0",
55
- "@dp-bohrium/widget-sdk": "0.4.1",
56
- "@dp-bohrium/widget-contracts": "0.4.1"
55
+ "@dp-bohrium/widget-contracts": "0.6.0",
56
+ "@dp-bohrium/widget-sdk": "0.6.0"
57
57
  },
58
58
  "sideEffects": false,
59
59
  "scripts": {