@tokensapi/dsh-plugin-check 0.3.2 → 0.3.3
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 +7 -3
- package/lib/cowork-plugin.mjs +38 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,15 +52,19 @@ npx @tokensapi/dsh-plugin-check --package @scope/name@1.2.3 --runtime 0.1.3-alph
|
|
|
52
52
|
|
|
53
53
|
## 会话内体检(装进 Cowork)
|
|
54
54
|
|
|
55
|
-
本包同时是一个 Cowork 插件。装进宿主后会注册 `plugin_check` 工具,在会话里直接问"这个插件能装吗"
|
|
55
|
+
本包同时是一个 Cowork 插件。装进宿主后会注册 `plugin_check` 工具,在会话里直接问"这个插件能装吗",不必记命令行:
|
|
56
56
|
|
|
57
57
|
```
|
|
58
|
+
# 正在开发、还没发布的插件 —— 直接读工作区
|
|
59
|
+
plugin_check(path="D:/code/my-plugin")
|
|
60
|
+
|
|
61
|
+
# 已经发布到 npm 的包
|
|
58
62
|
plugin_check(package="@scope/name", version="1.2.3")
|
|
59
63
|
```
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
**发版前用 `path`**:读的是你本地的 `package.json` 与 `cordis.patch.yml`,不需要先 `npm publish`,改一行问一次都行。已发布的包用 `package`,跑的是**清单规则 + 包内补丁行检查**:工具会把已发布的 tarball 取下来,解出 `cordis.patch.yml` 真读补丁行——只看 registry 清单会漏掉"补丁行 `name` 写成 cordis 插件名而不是 npm 包名"这类装上即让整棵插件树崩溃的缺陷。取不到包时如实标注补丁未检查(warning),不会因网络问题把插件判成不合格。
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
隔离启动冒烟要装依赖、起子进程,不在宿主进程里执行;完整体检仍走 CLI 或 Plugin Check workflow。
|
|
64
68
|
|
|
65
69
|
## `dsh.engine` 字段
|
|
66
70
|
|
package/lib/cowork-plugin.mjs
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/* ============================================================
|
|
2
2
|
* Cowork 插件入口:会话内插件体检工具
|
|
3
3
|
* ============================================================
|
|
4
|
-
* 装进 TokensCowork 后注册 plugin_check
|
|
4
|
+
* 装进 TokensCowork 后注册 plugin_check 工具:对本地插件目录或
|
|
5
|
+
* 任意 npm 插件包
|
|
5
6
|
* 跑清单规则 + 包内补丁行检查(与 CLI 的清单阶段同源),模型或
|
|
6
7
|
* 用户在会话里即可判断"这个插件装进来会不会有问题"。补丁行会
|
|
7
8
|
* 从 tarball 里真读出来 —— 只看 registry 清单会漏掉"补丁行 name
|
|
8
9
|
* 写成插件名"这类装上即崩的缺陷。含隔离启动冒烟的完整体检仍走
|
|
9
10
|
* CLI:npx @tokensapi/dsh-plugin-check --package <name@ver>。
|
|
10
11
|
* ============================================================ */
|
|
12
|
+
import { resolve } from 'node:path'
|
|
11
13
|
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
14
|
+
import { checkManifest } from './manifest-check.mjs'
|
|
12
15
|
import { checkPublishedPackage } from './registry-check.mjs'
|
|
13
16
|
|
|
14
17
|
/** 缺省比对的运行时版本;宿主升级后可通过插件配置覆盖。 */
|
|
@@ -44,19 +47,25 @@ export function apply(ctx, config = {}) {
|
|
|
44
47
|
const runtime = typeof config.runtime === 'string' && config.runtime !== '' ? config.runtime : DEFAULT_RUNTIME
|
|
45
48
|
ctx.tools.register(defineTool({
|
|
46
49
|
name: 'plugin_check',
|
|
47
|
-
description: 'Check whether a
|
|
48
|
-
+ '
|
|
49
|
-
+ '
|
|
50
|
-
+ '
|
|
50
|
+
description: 'Check whether a DSH/TokensCowork plugin is safe to install: forbidden lifecycle '
|
|
51
|
+
+ 'scripts, dual-kernel core dependencies, missing or out-of-scope cordis patch rows, and '
|
|
52
|
+
+ 'runtime/peer compatibility against the current DSH runtime. Returns ok=false with per-rule '
|
|
53
|
+
+ 'findings when the plugin would break the host. '
|
|
54
|
+
+ 'Pass "path" for a plugin the user is developing locally (checks the working tree, no publish '
|
|
55
|
+
+ 'needed) — prefer this whenever the user asks about their own plugin before releasing it. '
|
|
56
|
+
+ 'Pass "package" for an already published npm package. Exactly one of the two is required.',
|
|
51
57
|
parameters: {
|
|
58
|
+
path: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: 'Local plugin directory containing package.json. Use for unpublished/in-development plugins.',
|
|
61
|
+
},
|
|
52
62
|
package: {
|
|
53
63
|
type: 'string',
|
|
54
|
-
|
|
55
|
-
description: 'npm package name, e.g. "@tokensapi/dsh-progressive-tools".',
|
|
64
|
+
description: 'Published npm package name, e.g. "@tokensapi/dsh-progressive-tools".',
|
|
56
65
|
},
|
|
57
66
|
version: {
|
|
58
67
|
type: 'string',
|
|
59
|
-
description: 'Exact version to check. Defaults to the latest dist-tag.',
|
|
68
|
+
description: 'Exact version to check with "package". Defaults to the latest dist-tag.',
|
|
60
69
|
},
|
|
61
70
|
},
|
|
62
71
|
output: {
|
|
@@ -65,6 +74,27 @@ export function apply(ctx, config = {}) {
|
|
|
65
74
|
},
|
|
66
75
|
isConcurrencySafe: () => true,
|
|
67
76
|
async execute(args) {
|
|
77
|
+
const hasPath = typeof args.path === 'string' && args.path !== ''
|
|
78
|
+
const hasPackage = typeof args.package === 'string' && args.package !== ''
|
|
79
|
+
if (hasPath === hasPackage) {
|
|
80
|
+
throw new Error('plugin_check 需要且只需要一个目标:本地目录传 path,已发布包传 package')
|
|
81
|
+
}
|
|
82
|
+
if (hasPath) {
|
|
83
|
+
// 本地工作区体检:发版前就能判,不需要先 publish。隔离冒烟要装
|
|
84
|
+
// 依赖起子进程,宿主进程里不做,如实告知走 CLI。
|
|
85
|
+
const local = checkManifest(resolve(args.path), { runtime })
|
|
86
|
+
return {
|
|
87
|
+
path: resolve(args.path),
|
|
88
|
+
package: local.manifest?.name,
|
|
89
|
+
version: local.manifest?.version,
|
|
90
|
+
runtime,
|
|
91
|
+
ok: !local.findings.some(finding => finding.level === 'error'),
|
|
92
|
+
inspectedPatch: true,
|
|
93
|
+
findings: local.findings,
|
|
94
|
+
note: '以上为清单规则 + 补丁行检查(读的是本地工作区);隔离启动冒烟请在插件目录运行 '
|
|
95
|
+
+ 'npx @tokensapi/dsh-plugin-check --runtime ' + runtime,
|
|
96
|
+
}
|
|
97
|
+
}
|
|
68
98
|
const manifest = await fetchManifest(args.package, args.version ?? 'latest')
|
|
69
99
|
const { findings, inspectedPatch } = await checkPublishedPackage(manifest, runtime)
|
|
70
100
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokensapi/dsh-plugin-check",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "TokensCowork/DSH \u63d2\u4ef6\u5408\u683c\u6027\u4f53\u68c0:CLI \u4e00\u6761\u547d\u4ee4\u5224\u5b9a\u63d2\u4ef6\u80fd\u5426\u5b89\u5168\u88c5\u5165\u5bbf\u4e3b;\u88c5\u5165 Cowork \u540e\u63d0\u4f9b\u4f1a\u8bdd\u5185 plugin_check \u5de5\u5177\u3002",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|