@agy-daddy/plugin-template 1.1.0 → 1.1.2
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 +81 -1
- package/agy-plugin.json +39 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,87 @@
|
|
|
1
1
|
# @agy-daddy/plugin-template
|
|
2
2
|
|
|
3
|
-
Agy-Daddy
|
|
3
|
+
Agy-Daddy 官方微内核 v2 插件开发入门模板:标准化隔离世界、全托管设置、声明式命令与样式自注入。
|
|
4
4
|
|
|
5
|
+
- **npm 包名**:`@agy-daddy/plugin-template`
|
|
6
|
+
- **Layer 层级**:Starter Template(第三方插件标准模版)
|
|
7
|
+
- **信任等级**:社区 `T2` 规范(声明最小化 `dom:write` 权限)
|
|
8
|
+
- **适用场景**:开发者基于 Agy-Daddy 微内核 SDK 快速开发、验证并发布自己的第三方 CDP 插件。
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 核心功能与安全默认值
|
|
13
|
+
|
|
14
|
+
- **微内核契约 v2 规范**:完全运行于 `isolated` 隔离世界,不污染宿主全局 Window 对象,支持无痕销毁(零残留 `dispose`)。
|
|
15
|
+
- **全托管配置与声明式命令**:配置项由宿主根据 `settings.schema.json` 自动渲染,命令由宿主统一部署在命令面板,无需自制繁琐 UI。
|
|
16
|
+
- **设计风格自适应**:支持自动注入隔离样式,适配 Antigravity 原生暗色/亮色外观,禁止硬编码主题色。
|
|
17
|
+
- **安全默认值**:
|
|
18
|
+
- 严格限制权限仅声明 `dom:write`;
|
|
19
|
+
- 契约测试开箱即用,通过 `@agy-daddy/sdk` Mock Harness 验证生命周期。
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 安装与启用方式
|
|
24
|
+
|
|
25
|
+
### 1. 基于模板创建新插件
|
|
26
|
+
```sh
|
|
27
|
+
# 克隆或复制本目录作为开发起点
|
|
28
|
+
cp -r agy-daddy-plugin-template my-awesome-plugin
|
|
29
|
+
cd my-awesome-plugin
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 2. 插件安装与调试
|
|
33
|
+
```sh
|
|
34
|
+
# 链接本地开发目录进行调试
|
|
35
|
+
agy-daddy plugin link .
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 3. 宿主设置中心与顶栏交互
|
|
39
|
+
安装后自动激活(`onStartup`)。在顶栏(order: 90)挂载示例徽章(`hello-badge`),点击即可展开浮窗并执行问候操作;在设置中心进入「示例插件设置」可修改欢迎文本。
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 配置项说明表
|
|
44
|
+
|
|
45
|
+
对照 `settings.schema.json`:
|
|
46
|
+
|
|
47
|
+
| Key | 类型 | 默认值 | 说明 |
|
|
48
|
+
|---|---|---|---|
|
|
49
|
+
| `greeting` | `string` | `"Hello Agy-Daddy"` | 欢迎语:点击示例胶囊或执行问候命令时展示的提示文本 |
|
|
50
|
+
| `showBadge` | `boolean` | `true` | 显示顶栏示例胶囊:在顶栏右侧集群挂载示例状态胶囊入口 |
|
|
51
|
+
|
|
52
|
+
### 声明式操作(Actions)
|
|
53
|
+
- **立即发送问候 (`greet-now`)**:触发命令 `hello.greet`。
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 提供的服务 / 事件 / 命令 / 扩展位
|
|
58
|
+
|
|
59
|
+
严格依据 `agy-plugin.json` 声明:
|
|
60
|
+
|
|
61
|
+
- **Permissions**:`dom:write`
|
|
62
|
+
- **Requires Anchors**:
|
|
63
|
+
- `topbar.rightCluster`:顶栏右侧集群锚点(用于挂载示例状态徽章)
|
|
64
|
+
- **Services (provides)**:
|
|
65
|
+
- `hello`(版本 `1.0.0`,realm: `node`)
|
|
66
|
+
- **States (provides)**:
|
|
67
|
+
- `state:hello.greeting@1`:示例问候状态
|
|
68
|
+
- **Surfaces (provides)**:
|
|
69
|
+
- `[]`(空数组)
|
|
70
|
+
- **Commands (contributes)**:
|
|
71
|
+
- `hello.greet`:发送示例问候
|
|
72
|
+
- **Topbar Units & Popovers (contributes)**:
|
|
73
|
+
- Topbar Unit: `hello-badge`(order: `90`)
|
|
74
|
+
- Topbar Popover: `hello-popover`(anchorId: `hello-badge`)
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 使用示例与本地测试
|
|
79
|
+
|
|
80
|
+
### 使用示例
|
|
81
|
+
开发者可直接修改 `src/renderer.js` 与 `src/node.js` 实现业务逻辑,修改 `agy-plugin.json` 扩展服务或界面插槽。
|
|
82
|
+
|
|
83
|
+
### 本地测试
|
|
84
|
+
在模板目录下执行契约与生命周期测试:
|
|
5
85
|
```sh
|
|
6
86
|
npm test
|
|
7
87
|
```
|
package/agy-plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"id": "example.hello",
|
|
4
4
|
"publisher": "example",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.2",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"displayName": {
|
|
8
8
|
"zh-CN": "Hello 示例插件",
|
|
@@ -19,25 +19,54 @@
|
|
|
19
19
|
"main": "./src/node.js",
|
|
20
20
|
"renderer": "./src/renderer.js",
|
|
21
21
|
"world": "isolated",
|
|
22
|
-
"activationEvents": [
|
|
22
|
+
"activationEvents": [
|
|
23
|
+
"onStartup"
|
|
24
|
+
],
|
|
23
25
|
"requires": {
|
|
24
|
-
"anchors": [
|
|
26
|
+
"anchors": [
|
|
27
|
+
"topbar.rightCluster"
|
|
28
|
+
]
|
|
25
29
|
},
|
|
26
30
|
"provides": {
|
|
27
31
|
"services": {
|
|
28
|
-
"hello": {
|
|
32
|
+
"hello": {
|
|
33
|
+
"version": "1.0.0",
|
|
34
|
+
"realm": "node"
|
|
35
|
+
}
|
|
29
36
|
},
|
|
30
|
-
"states": [
|
|
37
|
+
"states": [
|
|
38
|
+
"state:hello.greeting@1"
|
|
39
|
+
],
|
|
31
40
|
"surfaces": []
|
|
32
41
|
},
|
|
33
|
-
"permissions": [
|
|
42
|
+
"permissions": [
|
|
43
|
+
"dom:write"
|
|
44
|
+
],
|
|
34
45
|
"contributes": {
|
|
35
|
-
"topbar.units": [
|
|
36
|
-
|
|
46
|
+
"topbar.units": [
|
|
47
|
+
{
|
|
48
|
+
"id": "hello-badge",
|
|
49
|
+
"order": 90
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"topbar.popovers": [
|
|
53
|
+
{
|
|
54
|
+
"id": "hello-popover",
|
|
55
|
+
"anchorId": "hello-badge"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
37
58
|
"commands": [
|
|
38
|
-
{
|
|
59
|
+
{
|
|
60
|
+
"id": "hello.greet",
|
|
61
|
+
"title": {
|
|
62
|
+
"zh-CN": "发送示例问候",
|
|
63
|
+
"en": "Run Sample Greeting"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
39
66
|
],
|
|
40
|
-
"settings": {
|
|
67
|
+
"settings": {
|
|
68
|
+
"schema": "./settings.schema.json"
|
|
69
|
+
},
|
|
41
70
|
"locales": "./locales"
|
|
42
71
|
}
|
|
43
72
|
}
|