@dp-bohrium/widget-cli 0.0.0-stage → 0.1.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/AGENTS.md +94 -0
- package/CHANGELOG.md +36 -0
- package/LICENSE +21 -0
- package/README.md +122 -2
- package/dist/cli.mjs +2251 -0
- package/dist/core.mjs +39 -0
- package/dist/dsh-DgkNH7L-.mjs +11395 -0
- package/llms.txt +25 -0
- package/package.json +66 -3
- package/src/core.d.mts +58 -0
- package/src/development-host.d.mts +119 -0
package/llms.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @dp-bohrium/widget-cli
|
|
2
|
+
|
|
3
|
+
> Widget 工程的本地创建、校验、开发、构建和打包工具;可由 Bohr CLI 桥接或调度。
|
|
4
|
+
|
|
5
|
+
## Agent 入口
|
|
6
|
+
|
|
7
|
+
- [Agent 使用说明](./AGENTS.md): 命令参数、执行顺序、错误恢复和安全边界。
|
|
8
|
+
- [README](./README.md): 安装、模板和公开 core 出口。
|
|
9
|
+
- 自闭环范围:本包负责本地工程闭环;上传、平台预览、版本发布和 Agent 绑定不在本包内执行。
|
|
10
|
+
|
|
11
|
+
## 本地闭环
|
|
12
|
+
|
|
13
|
+
- `create`: 创建 vanilla 或 React 工程;工作区文件面板使用 `--panel-id workspace-files`。
|
|
14
|
+
- `check` / `validate`: 校验作者清单、Manifest、entry、samples 和 fixtures;`check all` 以
|
|
15
|
+
当前工作目录为根,找不到工程时返回 `WIDGET_CLI_NO_WIDGET_PROJECT`,不会静默通过。
|
|
16
|
+
- `dev`: 启动本地开发服务器和 Host Bridge 连接。
|
|
17
|
+
- `build`: 委托工程自己的构建命令,并拒绝“退出 0 但仍有未解析依赖”的结果。
|
|
18
|
+
- `pack`: 生成可交给平台的 ZIP,并输出 SHA-256 digest、Manifest 摘要和 CLI/SDK/Contracts 版本。
|
|
19
|
+
- `doctor`: 输出 Node、SDK、Contracts 和工程状态(`ok` 看工程骨架,`ready` 再看依赖与构建入口)。
|
|
20
|
+
- `schema`: 输出插件 Manifest Schema 路径。
|
|
21
|
+
|
|
22
|
+
## 平台侧动作
|
|
23
|
+
|
|
24
|
+
upload、preview、commit、Widget version publish 和 Agent binding 由 Bohr CLI 或平台服务
|
|
25
|
+
负责,Widget CLI 不提供这些动作。
|
package/package.json
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dp-bohrium/widget-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Bohrium Widget 插件工程的创建、校验、开发和打包工具。",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"bohrium",
|
|
12
|
+
"dp-bohrium",
|
|
13
|
+
"widget",
|
|
14
|
+
"plugin",
|
|
15
|
+
"cli"
|
|
16
|
+
],
|
|
17
|
+
"author": "Bohrium",
|
|
18
|
+
"homepage": "https://www.npmjs.com/package/@dp-bohrium/widget-cli",
|
|
19
|
+
"bin": {
|
|
20
|
+
"bohr-widget": "./dist/cli.mjs"
|
|
21
|
+
},
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./dist/cli.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./core": {
|
|
27
|
+
"types": "./src/core.d.mts",
|
|
28
|
+
"import": "./dist/core.mjs"
|
|
29
|
+
},
|
|
30
|
+
"./development-host": {
|
|
31
|
+
"types": "./src/development-host.d.mts"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"src/core.d.mts",
|
|
38
|
+
"src/development-host.d.mts",
|
|
39
|
+
"README.md",
|
|
40
|
+
"AGENTS.md",
|
|
41
|
+
"llms.txt",
|
|
42
|
+
"CHANGELOG.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
],
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@dp-bohrium/widget-contracts": "0.3.0",
|
|
50
|
+
"@dp-bohrium/widget-sdk": "0.3.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@biomejs/biome": "^2.2.0",
|
|
54
|
+
"@types/node": "^22.15.0",
|
|
55
|
+
"tsdown": "0.22.14",
|
|
56
|
+
"typescript": "5.9.3",
|
|
57
|
+
"@dp-bohrium/widget-contract-testing": "0.1.0-alpha.0"
|
|
58
|
+
},
|
|
59
|
+
"sideEffects": false,
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "tsdown && node --check dist/cli.mjs",
|
|
62
|
+
"typecheck": "node --check src/cli.mjs && node --check src/core.mjs && node --check src/templates.mjs",
|
|
63
|
+
"test": "node --test test/*.test.mjs",
|
|
64
|
+
"lint": "biome check src test",
|
|
65
|
+
"format:check": "biome check --linter-enabled=false src test",
|
|
66
|
+
"package:contents": "node ../../scripts/quality/check-widget-cli-package-contents.mjs ../../.artifacts/dp-bohrium-widget-cli-*.tgz",
|
|
67
|
+
"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"
|
|
68
|
+
}
|
|
6
69
|
}
|
package/src/core.d.mts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export interface WidgetDevelopmentEndpointSetV1 {
|
|
2
|
+
readonly claim: string;
|
|
3
|
+
readonly status: string;
|
|
4
|
+
readonly events: string;
|
|
5
|
+
readonly control: string;
|
|
6
|
+
readonly profile: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface WidgetDevelopmentDescriptorV1 {
|
|
10
|
+
readonly protocol: "bohrium.widget-development-host";
|
|
11
|
+
readonly protocolVersion: 1;
|
|
12
|
+
readonly sessionId: string;
|
|
13
|
+
readonly issuedAt: string;
|
|
14
|
+
readonly expiresAt: string;
|
|
15
|
+
readonly origin: string;
|
|
16
|
+
readonly endpoints: WidgetDevelopmentEndpointSetV1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface WidgetDevelopmentClaimV1 {
|
|
20
|
+
readonly tokenType: "Bearer";
|
|
21
|
+
readonly accessToken: string;
|
|
22
|
+
readonly expiresAt: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface WidgetDevelopmentAssetV1 {
|
|
26
|
+
readonly path: string;
|
|
27
|
+
readonly bytes: number;
|
|
28
|
+
readonly digest: `sha256:${string}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface WidgetDevelopmentPresentationRequestV1 {
|
|
32
|
+
readonly requestId: string;
|
|
33
|
+
readonly key: string;
|
|
34
|
+
readonly surface: "workspace" | "floating" | "overlay";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface WidgetDevelopmentPanelProjectionV1 {
|
|
38
|
+
readonly key: string;
|
|
39
|
+
readonly runId: string;
|
|
40
|
+
readonly widgetId: string;
|
|
41
|
+
readonly widgetVersionId: string;
|
|
42
|
+
readonly snapshot: Readonly<{
|
|
43
|
+
id: string;
|
|
44
|
+
title?: string;
|
|
45
|
+
state: "loading" | "partial" | "complete" | "error";
|
|
46
|
+
data: unknown;
|
|
47
|
+
}>;
|
|
48
|
+
readonly presentation: Readonly<{
|
|
49
|
+
allowedSurfaces: readonly ("workspace" | "floating" | "overlay")[];
|
|
50
|
+
defaultSurface: "workspace" | "floating" | "overlay";
|
|
51
|
+
movable: boolean;
|
|
52
|
+
resizable: boolean;
|
|
53
|
+
}>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface WidgetDevelopmentRuntimeDescriptorV1 {
|
|
57
|
+
readonly profileUrl: string;
|
|
58
|
+
readonly statusUrl: string;
|
|
59
|
+
readonly panel?: WidgetDevelopmentPanelProjectionV1;
|
|
60
|
+
readonly presentationRequests?: readonly WidgetDevelopmentPresentationRequestV1[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface WidgetDevelopmentStatusV1 {
|
|
64
|
+
readonly protocolVersion: 1;
|
|
65
|
+
readonly state: "ready" | "stopping" | "build-failed";
|
|
66
|
+
readonly sessionId: string;
|
|
67
|
+
readonly revision: number;
|
|
68
|
+
readonly generation: number;
|
|
69
|
+
readonly updateAvailable: boolean;
|
|
70
|
+
readonly descriptor: WidgetDevelopmentRuntimeDescriptorV1;
|
|
71
|
+
readonly presentationRequests: readonly WidgetDevelopmentPresentationRequestV1[];
|
|
72
|
+
readonly digest: `sha256:${string}`;
|
|
73
|
+
readonly assets: readonly WidgetDevelopmentAssetV1[];
|
|
74
|
+
readonly watch: boolean;
|
|
75
|
+
readonly lastBuild: Readonly<Record<string, unknown>>;
|
|
76
|
+
readonly lastBuildError: Readonly<Record<string, unknown>> | null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type WidgetDevelopmentEventTypeV1 =
|
|
80
|
+
| "generation-ready"
|
|
81
|
+
| "generation-failed"
|
|
82
|
+
| "reload-requested"
|
|
83
|
+
| "session-stopping"
|
|
84
|
+
| "disconnected";
|
|
85
|
+
|
|
86
|
+
export interface WidgetDevelopmentEventV1 {
|
|
87
|
+
readonly protocolVersion: 1;
|
|
88
|
+
readonly eventId: string;
|
|
89
|
+
readonly type: WidgetDevelopmentEventTypeV1;
|
|
90
|
+
readonly data: Readonly<Record<string, unknown>>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface WidgetDevelopmentControlRequestV1 {
|
|
94
|
+
readonly protocolVersion: 1;
|
|
95
|
+
readonly action: "reload" | "disconnect";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface WidgetDevelopmentBridgeRequestV1 {
|
|
99
|
+
readonly protocol: "bohrium.widget-development-host";
|
|
100
|
+
readonly protocolVersion: 1;
|
|
101
|
+
readonly sessionId: string;
|
|
102
|
+
readonly descriptorUrl: string;
|
|
103
|
+
readonly expiresAt: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface WidgetDevelopmentBridgeResponseV1 {
|
|
107
|
+
readonly accepted: true;
|
|
108
|
+
readonly protocolVersion: 1;
|
|
109
|
+
readonly sessionId: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface WidgetDevelopmentCliEnvelopeV1<
|
|
113
|
+
T = Readonly<Record<string, unknown>>,
|
|
114
|
+
> {
|
|
115
|
+
readonly protocol: "bohrium.widget-development-cli";
|
|
116
|
+
readonly version: 1;
|
|
117
|
+
readonly type: string;
|
|
118
|
+
readonly data: T;
|
|
119
|
+
}
|