dbx-plugin-skill 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/LICENSE +201 -0
- package/README.md +238 -0
- package/bin/dbx-plugin-skill.mjs +330 -0
- package/lib/installer.mjs +256 -0
- package/package.json +49 -0
- package/skill/SKILL.md +268 -0
- package/skill/references/cli.md +225 -0
- package/skill/references/contributions.md +229 -0
- package/skill/references/debugging.md +210 -0
- package/skill/references/host-api.md +195 -0
- package/skill/references/manifest.md +229 -0
- package/skill/references/packaging.md +183 -0
- package/skill/references/publishing.md +374 -0
- package/skill/references/sidecar-protocol.md +242 -0
- package/skill/references/troubleshooting.md +171 -0
- package/skill/scripts/check-project.mjs +915 -0
- package/skill/scripts/dev-logs.mjs +191 -0
- package/skill/scripts/inspect-dbxp.mjs +400 -0
- package/skill/scripts/make-candidate.mjs +413 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2024] [ eryajf of copyright https://github.com/eryajf ]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# dbx-plugin-skill
|
|
2
|
+
|
|
3
|
+
一个用于 **DBX 插件开发** 的 agent skill(技能包),覆盖从创建到上架官方商店的全链路:
|
|
4
|
+
|
|
5
|
+
**创建 → 开发 → 调试 → 打包 → 发布 Release → 提交 dbx-store 候选 PR → 审核签名**
|
|
6
|
+
|
|
7
|
+
技能名:`dbx-plugin`(安装到 `~/.dsh/skills`、`~/.claude/skills`、`~/.agents/skills`)。
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 快速安装
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# 方式一:直接安装(推荐)
|
|
15
|
+
npx dbx-plugin-skill install
|
|
16
|
+
|
|
17
|
+
# 方式二:全局安装后使用
|
|
18
|
+
npm install --global dbx-plugin-skill
|
|
19
|
+
dbx-plugin-skill install
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
安装后**重启 agent 会话**(技能目录在会话启动时扫描),然后即可通过自然语言触发,例如:
|
|
23
|
+
|
|
24
|
+
> 帮我创建一个 DBX 插件,用 Svelte 模板,id 是 com.example.demo
|
|
25
|
+
> 我的 DBX 插件打包报错 `manifest UI entry ... is not covered by [package].include`,帮我看下
|
|
26
|
+
> 帮我把这个插件发布到 dbx-store,生成候选 JSON
|
|
27
|
+
> 检查一下这个 .dbxp 包里有没有不该发布的东西
|
|
28
|
+
|
|
29
|
+
### 安装选项
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
dbx-plugin-skill install [--target all|dsh,claude,agents] [--scope user|project] [--link] [--force]
|
|
33
|
+
|
|
34
|
+
dbx-plugin-skill status # 查看各目标安装状态
|
|
35
|
+
dbx-plugin-skill doctor # 环境自检(Node / dbx-plugin CLI / skill 安装 / 当前项目)
|
|
36
|
+
dbx-plugin-skill path # 打印安装路径
|
|
37
|
+
dbx-plugin-skill uninstall # 卸载(仅移除本安装器写入的内容)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
| 选项 | 说明 |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `--target` | 安装目标,默认 `all`:`dsh` = DeepSeek Harness,`claude` = Claude Code,`agents` = 共享 agents 目录 |
|
|
43
|
+
| `--scope` | `user`(默认,家目录)或 `project`(当前目录下的 `.dsh/skills`、`.claude/skills`、`.agents/skills`) |
|
|
44
|
+
| `--link` | 安装为符号链接,便于从源码仓库直接迭代(仅 user scope 下最有用) |
|
|
45
|
+
| `--force` | 覆盖非本安装器写入的同名目录 |
|
|
46
|
+
|
|
47
|
+
安装器会在目标目录写入 `.dbx-plugin-skill.json` 标记文件;卸载时据此判断归属,**不会误删手工安装的同名技能**。
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 前置依赖
|
|
52
|
+
|
|
53
|
+
| 依赖 | 版本 | 用途 |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| Node.js | ≥ 18(`dbx-plugin dev` 需 **≥ 22**) | 运行随附脚本与安装器 |
|
|
56
|
+
| `@dbx-app/plugin-cli` | 建议最新 | 创建/调试/打包插件 |
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install --global @dbx-app/plugin-cli
|
|
60
|
+
dbx-plugin --help
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> 检查版本:`dbx-plugin version`。若明显落后于 npm 上的最新版,建议 `npm install --global @dbx-app/plugin-cli@latest`。
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Skill 内容
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
skill/
|
|
71
|
+
├── SKILL.md # 入口:心智模型、路由表、标准工作流、硬性约束
|
|
72
|
+
├── references/
|
|
73
|
+
│ ├── manifest.md # Manifest v1 字段、权限、入口、国际化、打包期重写
|
|
74
|
+
│ ├── contributions.md # 5 类贡献点、连接表单/binding、文件系统 RPC
|
|
75
|
+
│ ├── host-api.md # window.dbxPlugin、context 规则、主题、CSP、资源
|
|
76
|
+
│ ├── sidecar-protocol.md # 协议 v1、JSONL/framed、Rust/Go SDK、错误码
|
|
77
|
+
│ ├── cli.md # create / dev / package / keygen 全参数与环境变量
|
|
78
|
+
│ ├── debugging.md # dev host、DBX_UI_BUILD_SUCCESS、诊断 API、能力边界
|
|
79
|
+
│ ├── packaging.md # dbx-plugin.toml、打包流程、.dbxp 结构、体积限制
|
|
80
|
+
│ ├── publishing.md # .dbx-store.json、候选 JSON、审核签名、校验规则
|
|
81
|
+
│ └── troubleshooting.md # 报错原文 → 原因 → 修法 对照表
|
|
82
|
+
└── scripts/
|
|
83
|
+
├── check-project.mjs # 打包前预检
|
|
84
|
+
├── inspect-dbxp.mjs # 解包检查(含 ZIP 读取与 checksums 校验)
|
|
85
|
+
├── make-candidate.mjs # 生成候选与 release-candidates.json
|
|
86
|
+
└── dev-logs.mjs # 读取 dev host 脱敏日志
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 随附脚本
|
|
90
|
+
|
|
91
|
+
四个脚本都是**零依赖**的 Node 程序(只用内置模块),可直接运行:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# 1) 打包前预检:manifest / dbx-plugin.toml / include 覆盖 / 资源存在 / 前后端一致 / 权限语法
|
|
95
|
+
node skill/scripts/check-project.mjs [项目目录] [--json] [--quiet]
|
|
96
|
+
|
|
97
|
+
# 2) 解包检查 .dbxp:条目、manifest、checksums 逐条校验、签名状态、bin target 一致性
|
|
98
|
+
node skill/scripts/inspect-dbxp.mjs dist/my-plugin-0.1.0-universal.dbxp [--json] [--extract DIR] [--no-verify]
|
|
99
|
+
|
|
100
|
+
# 3) 生成上架 JSON,并复核每个包的 sha256/size
|
|
101
|
+
node skill/scripts/make-candidate.mjs [项目目录] [--repo owner/name] [--tag v1.0.0] [--release-notes "..."]
|
|
102
|
+
|
|
103
|
+
# 4) 读取 dev host 日志(自动沿用 nextAfter + instanceId 游标)
|
|
104
|
+
node skill/scripts/dev-logs.mjs --port 5190 [--level error] [--follow] [--json]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`check-project.mjs` 与 `make-candidate.mjs` 以退出码表达结果:`0` 通过,`1` 发现问题(错误详情在 stderr 或 `--json` 的 `findings` 里)。
|
|
108
|
+
|
|
109
|
+
安装 skill 后,agent 会自动在合适的时机调用这些脚本;你也可以手动跑。
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 开发本仓库
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
git clone https://github.com/eryajf/dbx-plugin-skill.git
|
|
117
|
+
cd dbx-plugin-skill
|
|
118
|
+
npm test # 运行 65 项端到端自检
|
|
119
|
+
|
|
120
|
+
# 以符号链接方式边改边用
|
|
121
|
+
node bin/dbx-plugin-skill.mjs install --link --target dsh
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`npm test` 覆盖:skill 结构完整性(frontmatter / 引用完整性)、预检脚本的正反例、`.dbxp` 校验与篡改检测、候选生成与哈希复核、安装器完整生命周期(在临时 HOME 中进行,不触碰真实环境)。
|
|
125
|
+
|
|
126
|
+
常用脚本:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npm test # 端到端自检(CI 在 Node 18/20/22 上跑)
|
|
130
|
+
npm run verify:package # 校验 npm 打包内容与元数据
|
|
131
|
+
npm run upstream:check # 对比上游 DBX 契约是否变化
|
|
132
|
+
npm run upstream:update # 更新后重新基线化
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 仓库与仓库设置
|
|
138
|
+
|
|
139
|
+
仓库地址:<https://github.com/eryajf/dbx-plugin-skill>(公开仓库,`--provenance` 需要公开仓库才能生成可验证的来源证明)。
|
|
140
|
+
|
|
141
|
+
如果你要 fork 成自己的包发布,记得同步改 `package.json` 里的 `name`、`repository`、`homepage`、`bugs`,以及 `.github/workflows/release.yml` 里 Trusted Publisher 相关的注释。
|
|
142
|
+
|
|
143
|
+
仓库维护者需要在 GitHub **Settings** 里确认:
|
|
144
|
+
|
|
145
|
+
| 位置 | 建议 |
|
|
146
|
+
| --- | --- |
|
|
147
|
+
| Secrets and variables → Actions | 加 `NPM_TOKEN` —— 仅首次发布 npm 需要,之后切 Trusted Publishing 就可以删掉(见下) |
|
|
148
|
+
| Features → Issues | 保持开启(`upstream-drift.yml` 会开 issue 提醒) |
|
|
149
|
+
| Actions → General → Workflow permissions | **无需修改**。三个 workflow 都显式声明了自己的 `permissions:`(`contents: write` / `id-token: write` / `issues: write`),会覆盖仓库默认值。只有当组织策略禁止 workflow 申请写权限时才需要处理 |
|
|
150
|
+
|
|
151
|
+
> 排查提示:判断 `GITHUB_TOKEN` 的能力**不要**看 `GET /repos/{owner}/{repo}` 里的 `.permissions.push` —— 那个字段描述的是**用户角色**,对 app token 恒为 `false`,会造成误判。
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 自动化(GitHub Actions)
|
|
156
|
+
|
|
157
|
+
仓库内置三个 workflow:
|
|
158
|
+
|
|
159
|
+
| Workflow | 触发 | 作用 |
|
|
160
|
+
| --- | --- | --- |
|
|
161
|
+
| `ci.yml` | push `main` / PR / 手动 | 在 Node 18/20/22 上跑 `npm test`;单独 job 校验 npm 打包内容并产出 `dbx-plugin-<version>.zip` 构建产物 |
|
|
162
|
+
| `release.yml` | 打 `v*` tag / 手动(可 dry-run) | 校验 tag 与版本一致 → 跑测试 → 校验打包 → **发布 npm** → 创建 GitHub Release 并附带 `.tgz`、`.zip`、`SHA256SUMS.txt` |
|
|
163
|
+
| `upstream-drift.yml` | 每周一 02:00 UTC / 手动 | 抓取上游 `manifest.schema.json`、`plugin-candidate.schema.json` 指纹与 npm 上 `@dbx-app/plugin-cli` 版本,与基线对比;有变化就创建或更新一个 `upstream-drift` issue |
|
|
164
|
+
|
|
165
|
+
### 发一个新版本
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
npm version patch # 或 minor / major:更新 package.json 并打 tag
|
|
169
|
+
git push --follow-tags # 推送提交与 tag → 自动触发 release.yml
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`release.yml` 会做四件事:**校验 tag 与 `package.json` 版本一致**(不一致直接失败)、跑测试、发布 npm、创建 Release。想先空跑一次可以手动触发并勾选 `dry-run`。
|
|
173
|
+
|
|
174
|
+
### npm 发布认证
|
|
175
|
+
|
|
176
|
+
> ⚠️ **2025 年 11 月起 npm 只支持 Granular Access Token,经典 / Automation token 已被移除。**
|
|
177
|
+
> 另外,**带 Bypass 2FA 的「直接发布」token 正在被废弃,2027 年 1 月起将无法再用它直接发布新版本**。
|
|
178
|
+
> 因此长期方案是 **Trusted Publishing(OIDC)**,token 只用于完成首次发布。
|
|
179
|
+
|
|
180
|
+
**第 1 步:首次发布(二选一)**
|
|
181
|
+
|
|
182
|
+
- **本地手动发布(最省事)**:`npm login && npm publish --access public`。交互式 2FA 能正常完成,不必建 token。
|
|
183
|
+
- **用 Granular Access Token**:npmjs.com → Access Tokens → Generate New Token → **Granular Access Token**,然后:
|
|
184
|
+
- **勾选 `Bypass two-factor authentication (2FA)`** —— CI 里没有交互式 2FA,不勾选会在发布时卡在 2FA 校验上失败;
|
|
185
|
+
- `Packages and scopes` → **`Read and write (publish and stage)`**;
|
|
186
|
+
- `Select packages` → 首次发布只能选 **`All packages`**(包还不存在,下拉里选不到它);发布成功后建议收窄到 `dbx-plugin-skill`;
|
|
187
|
+
- `Organizations` → **`No access`**(组织权限只用于管理组织设置与成员,**与发布包无关**,给读写属于越权);
|
|
188
|
+
- `Expiration` → 记下到期日,到期后 CI 会直接认证失败。
|
|
189
|
+
- 把 token 加到仓库 Secret `NPM_TOKEN`。
|
|
190
|
+
|
|
191
|
+
**第 2 步:切到 Trusted Publishing(推荐,长期方案)**
|
|
192
|
+
|
|
193
|
+
包首次发布后,在 npmjs.com 该包的 **Settings → Trusted Publisher** 添加:
|
|
194
|
+
|
|
195
|
+
| 字段 | 值 |
|
|
196
|
+
| --- | --- |
|
|
197
|
+
| Provider | GitHub Actions |
|
|
198
|
+
| Organization or user | `eryajf` |
|
|
199
|
+
| Repository | `dbx-plugin-skill` |
|
|
200
|
+
| Workflow filename | `release.yml`(只填文件名,必须与 `.github/workflows/` 下的文件同名) |
|
|
201
|
+
| Allowed actions | 勾选允许 **`npm publish`**(否则只能 `npm stage publish`) |
|
|
202
|
+
|
|
203
|
+
然后**从仓库删掉 `NPM_TOKEN`**,`release.yml` 会自动走 OIDC,不再有 token 过期问题。
|
|
204
|
+
|
|
205
|
+
要求:npm CLI ≥ 11.5.1 且 Node ≥ 22.14.0(`release.yml` 已 `npm install -g npm@latest`)。仅支持 GitHub 托管 runner,自建 runner 不支持。
|
|
206
|
+
|
|
207
|
+
`release.yml` 会先判断 `NPM_TOKEN` 是否存在:有就用 token,没有就走 OIDC —— 两种配置都能跑,可平滑迁移;发布失败时会额外打印常见原因提示。
|
|
208
|
+
|
|
209
|
+
### 上游漂移检查
|
|
210
|
+
|
|
211
|
+
skill 大量记录 DBX 的**契约细节**(字段枚举、权限语法、协议常量、商店校验规则)。上游一改,文档就可能过期。`upstream-drift.yml` 每周把这个契约的指纹与 `.github/upstream-baseline.json` 里的基线比对:
|
|
212
|
+
|
|
213
|
+
- **只开 issue,不自动改基线** —— 保证提醒不会被静默吞掉。
|
|
214
|
+
- 维护者按 issue 里的步骤核对并更新 `skill/references/*.md`,然后 `npm run upstream:update` 重新基线化并提交。
|
|
215
|
+
- 只有 sha256 变化、事实无差异时,通常只是上游排版变动,确认后直接重新基线化即可。
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## 更新已安装的 skill
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
dbx-plugin-skill doctor # 会对比 npm 上的最新版本并给出升级提示
|
|
223
|
+
npm install --global dbx-plugin-skill@latest && dbx-plugin-skill install
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
`install` 是幂等的:重新执行即覆盖为当前版本。想从源码跟随(不装 npm 包)就用 `--link`。
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## 事实来源
|
|
231
|
+
|
|
232
|
+
本 skill 的内容对齐以下权威来源,并在文档中标注了「文档 vs 脚本」的已知冲突:
|
|
233
|
+
|
|
234
|
+
- 官方文档:<https://dbxio.com/cn/docs/plugin-development>
|
|
235
|
+
- 上游平台仓库 `t8y2/dbx`:`plugins/manifest.schema.json`、`plugins/README.md`(完整贡献点与协议)、`plugins/RELEASING.md`、`plugins/sdk/{cli,packager,dev-host,rust,go}`
|
|
236
|
+
- 官方商店仓库 `t8y2/dbx-store`:`CONTRIBUTING.md`、`schemas/plugin-candidate.schema.json`、`scripts/validate.mjs`、同步与签名 Workflow
|
|
237
|
+
|
|
238
|
+
> 插件上架 PR 提到 **`t8y2/dbx-store`**,不是 `t8y2/dbx`。普通插件源码留在你自己的仓库。
|