@perrylink/dsh-plugin-doctor 0.1.2 → 0.1.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/lib/checks-package.mjs +6 -4
- package/package.json +1 -1
package/lib/checks-package.mjs
CHANGED
|
@@ -67,11 +67,13 @@ export function addChecks(doctor, ctx) {
|
|
|
67
67
|
const p = path.resolve(repoPath, patch)
|
|
68
68
|
if (!existsSync(p)) return fail(`patch 文件不存在: ${patch}`)
|
|
69
69
|
const text = readFileSync(p, 'utf8')
|
|
70
|
+
// YAML 注释行剔除后再做启发式(示例配置注释里常出现 name: xxx)
|
|
71
|
+
const active = text.split(/\r?\n/).filter((l) => !/^\s*#/.test(l)).join('\n')
|
|
70
72
|
const problems = []
|
|
71
|
-
if (!/-\s+insert\s*:/.test(
|
|
72
|
-
const ids = [...
|
|
73
|
+
if (!/-\s+insert\s*:/.test(active)) problems.push('未找到 "- insert:" 结构')
|
|
74
|
+
const ids = [...active.matchAll(/(?:^|\n)\s*-?\s*id:\s*["']?([^"'\s]+)/g)].map((m) => m[1])
|
|
73
75
|
if (!ids.length) problems.push('未找到 id 行(行 id 必须存在,供上层整行替换定位)')
|
|
74
|
-
const names = [...
|
|
76
|
+
const names = [...active.matchAll(/(?:^|\n)\s*name:\s*["']?([^"'\s,]+)|[,\s]name:\s*["']?([^"'\s,]+)/g)]
|
|
75
77
|
.map((m) => m[1] ?? m[2]).filter(Boolean)
|
|
76
78
|
const badNames = names.filter((n) => n !== pkgName && !n.startsWith(`${pkgName}/`))
|
|
77
79
|
if (names.length && badNames.length) problems.push(`行 name 与包名不一致: ${[...new Set(badNames)].join(', ')}(name 必须经 profile node_modules 解析,应为包名)`)
|
|
@@ -121,7 +123,7 @@ export function addChecks(doctor, ctx) {
|
|
|
121
123
|
const importsCordis = srcFiles.some((f) => { try { return /from\s+['"]@deepseek-ai\/cordis['"]|require\(['"]@deepseek-ai\/cordis['"]\)/.test(readFileSync(f, 'utf8')) } catch { return false } })
|
|
122
124
|
if (!peer && !dep) {
|
|
123
125
|
if (importsCordis) problems.push('源码 import @deepseek-ai/cordis 但未声明任何依赖')
|
|
124
|
-
else
|
|
126
|
+
else return pass('未声明 @deepseek-ai/cordis 且源码无 import(纯 JS 仓可无 cordis 运行时依赖)')
|
|
125
127
|
} else if (!peer) {
|
|
126
128
|
problems.push('@deepseek-ai/cordis 只在 dependencies(官方口径:peerDependencies + devDependencies 同时声明)')
|
|
127
129
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perrylink/dsh-plugin-doctor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Zero-dependency static + sandbox smoke detector for DeepSeek Harness (dsh) plugins: package-structure gates (R), cordis contract scans (K), keyless-headless sandbox smoke (D), and ecosystem-listing checks (CC).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "doctor.mjs",
|