focus-guard 3.5.1 → 3.5.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 +17 -5
- package/README.zh-CN.md +15 -5
- package/assets/NOTICE.md +2 -0
- package/docs/ARCH-MAP.md +33 -20
- package/docs/BENCH.md +21 -12
- package/docs/RELEASE-POLICY.md +84 -19
- package/docs/RULES.md +75 -55
- package/docs/THREAT-MODEL.md +1 -1
- package/docs/WRITING-STYLE.md +1 -1
- package/package.json +11 -6
- package/skills/focus-plan/SKILL.md +77 -0
- package/skills/focus-rules/SKILL.md +267 -0
- package/skills/focus-thinking/SKILL.md +8 -255
- package/src/adapters/dsh/eligibility-gate.mjs +43 -23
- package/src/adapters/dsh/session.mjs +22 -0
- package/src/core/approvals.mjs +10 -4
- package/src/core/audit-writer.mjs +5 -2
- package/src/core/checkEligibility.mjs +190 -129
- package/src/core/constants.mjs +1 -1
- package/src/core/decisionEngine.mjs +16 -13
- package/src/core/env.mjs +18 -0
- package/src/core/patterns.mjs +3 -1
- package/src/core/prefixStability.mjs +27 -3
- package/src/core/session.mjs +23 -0
- package/src/dsh/audit.mjs +21 -7
- package/src/dsh/bridgeCheck.mjs +81 -0
- package/src/dsh/compactionWatch/announce.mjs +2 -1
- package/src/dsh/compactionWatch.mjs +2 -1
- package/src/dsh/guard/authz.mjs +2 -2
- package/src/dsh/guard/retryGuard.mjs +96 -0
- package/src/dsh/guard/risk.mjs +61 -16
- package/src/dsh/guard/runtime.mjs +30 -5
- package/src/dsh/guard/tooling.mjs +5 -9
- package/src/dsh/guard/writing-gate.mjs +117 -0
- package/src/dsh/index.js +4 -7
- package/src/dsh/pipeline.mjs +66 -5
- package/src/dsh/preGuard.mjs +11 -2
- package/src/dsh/repeatGuard.mjs +5 -4
- package/src/dsh/seams/session-start.mjs +49 -10
- package/src/dsh/seams/shared.mjs +8 -5
- package/src/dsh/search-hints.mjs +15 -1
- package/src/dsh/sessionScope.mjs +11 -11
- package/src/dsh/stopGuard.mjs +2 -7
- package/src/dsh/tools.mjs +39 -1
- package/src/dsh/traceMeta.mjs +5 -11
- package/src/memory/index.mjs +4 -4
- package/src/memory/workspace.mjs +41 -19
- package/tools/capture-fixtures.mjs +3 -24
- package/tools/collect-panel.mjs +3 -24
- package/tools/dead-export.mjs +2 -17
- package/tools/docs-book.mjs +234 -0
- package/tools/docs-drift.mjs +165 -0
- package/tools/docs-lint.mjs +24 -0
- package/tools/first-run-sweep.mjs +13 -2
- package/tools/gate-audit.mjs +3 -24
- package/tools/handoff.mjs +3 -1
- package/tools/install-check.mjs +294 -0
- package/tools/layering-audit.mjs +7 -1
- package/tools/legacy-audit.mjs +83 -0
- package/tools/lib/case-tool.mjs +8 -2
- package/tools/lib/docs-ack.mjs +95 -0
- package/tools/lib/docs-core.mjs +38 -22
- package/tools/lib/docs-files.mjs +73 -0
- package/tools/lib/docs-status.mjs +143 -0
- package/tools/lib/idioms.mjs +149 -0
- package/tools/lib/import-graph.mjs +8 -3
- package/tools/lib/legacy-core.mjs +178 -0
- package/tools/lib/markdown.mjs +202 -0
- package/tools/lib/modules-doc.mjs +96 -0
- package/tools/lib/modules-list.mjs +382 -0
- package/tools/lib/modules.mjs +312 -0
- package/tools/lib/prefix-cost.mjs +5 -3
- package/tools/library-book.mjs +7 -92
- package/tools/lint.mjs +5 -0
- package/tools/memory-audit.mjs +32 -6
- package/tools/memory-recall-eval.mjs +408 -0
- package/tools/module-audit.mjs +2 -17
- package/tools/modules-audit.mjs +108 -0
- package/tools/panel-baseline.mjs +172 -0
- package/tools/prefix-audit.mjs +10 -2
- package/tools/prefix-drift.mjs +9 -4
- package/tools/registry-check.mjs +194 -0
- package/tools/release.mjs +374 -0
- package/tools/schema-fingerprint.mjs +3 -24
- package/tools/version.mjs +12 -8
- package/docs/AB-PROMPTS.md +0 -123
- package/docs/AB-SESSION.md +0 -161
- package/docs/BENCH-BASELINE.json +0 -95
- package/docs/BRAIN-VIZ.md +0 -94
- package/docs/GATE-INPUTS.json +0 -10
- package/docs/HANDOFF-2026-10-27.md +0 -736
- package/docs/HOOK-ORDERING.md +0 -139
- package/docs/LEGISLATION-LAW.md +0 -104
- package/docs/MCP-4.0-PLAN.md +0 -184
- package/docs/MEMORY-4.5-PLAN.md +0 -415
- package/docs/PROFILE-TUNING.md +0 -147
- package/docs/RATCHET.json +0 -72
- package/docs/TOOL-SCHEMA.json +0 -6
- package/docs/VERSION-PLAN.md +0 -604
- package/docs/architecture-map.mermaid +0 -186
- package/docs/deepseek-pricing-audit.md +0 -65
- package/src/dsh/guard/superpowers.mjs +0 -70
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* docs:drift(2026-11-22)
|
|
4
|
+
*
|
|
5
|
+
* 文档漂移扫描器:把「文档里写死的事实」拿代码对一遍,出清单而不是靠人眼。
|
|
6
|
+
* 三类判据(都只认可机器验证的):
|
|
7
|
+
* 1. `npm run <script>`:package.json 的 scripts 里必须存在;
|
|
8
|
+
* 2. 反引号里的仓库相对路径:文件/目录必须存在(占位符与通配符跳过);
|
|
9
|
+
* 3. `FG_*` 环境变量:`packages/core/src` 里必须出现过。
|
|
10
|
+
*
|
|
11
|
+
* 不判:示例里的外部 URL、<占位符>、执行结果、版本号(版本面已由 docs:lint / version.mjs 管)。
|
|
12
|
+
*
|
|
13
|
+
* 用法:
|
|
14
|
+
* node packages/core/tools/docs-drift.mjs # 人读清单
|
|
15
|
+
* node packages/core/tools/docs-drift.mjs --json # 机器读
|
|
16
|
+
* node packages/core/tools/docs-drift.mjs --strict # 有漂移则退出码 1(默认 0,只报告)
|
|
17
|
+
*/
|
|
18
|
+
import { readFileSync, existsSync, statSync, readdirSync } from 'node:fs'
|
|
19
|
+
import { dirname, join, resolve, relative } from 'node:path'
|
|
20
|
+
import { fileURLToPath } from 'node:url'
|
|
21
|
+
|
|
22
|
+
const HERE = dirname(fileURLToPath(import.meta.url))
|
|
23
|
+
const ROOT = resolve(HERE, '..', '..', '..')
|
|
24
|
+
|
|
25
|
+
const args = process.argv.slice(2)
|
|
26
|
+
const asJson = args.includes('--json')
|
|
27
|
+
const strict = args.includes('--strict')
|
|
28
|
+
|
|
29
|
+
/** 扫描范围:docs 树 + 入口文档;归档与 vault 笔记不扫(历史材料,改了也不该被当前事实约束)。 */
|
|
30
|
+
function walkDocs(dir, out = []) {
|
|
31
|
+
let entries
|
|
32
|
+
try {
|
|
33
|
+
entries = readdirSync(dir, { withFileTypes: true })
|
|
34
|
+
} catch {
|
|
35
|
+
return out
|
|
36
|
+
}
|
|
37
|
+
for (const e of entries) {
|
|
38
|
+
if (e.name === 'archive' || e.name === 'vault-notes' || e.name === 'node_modules') continue
|
|
39
|
+
const p = join(dir, e.name)
|
|
40
|
+
if (e.isDirectory()) walkDocs(p, out)
|
|
41
|
+
else if (e.name.endsWith('.md')) out.push(p)
|
|
42
|
+
}
|
|
43
|
+
return out
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const FILES = [
|
|
47
|
+
...walkDocs(join(ROOT, 'docs')),
|
|
48
|
+
...walkDocs(join(ROOT, 'packages/core/docs')),
|
|
49
|
+
join(ROOT, 'README.md'),
|
|
50
|
+
join(ROOT, 'INSTALL.md'),
|
|
51
|
+
join(ROOT, 'packages/core/README.md'),
|
|
52
|
+
join(ROOT, 'packages/core/README.zh-CN.md'),
|
|
53
|
+
].filter((f) => existsSync(f) && !/HANDOFF-/.test(f))
|
|
54
|
+
|
|
55
|
+
const scripts = Object.keys(JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8')).scripts || {})
|
|
56
|
+
|
|
57
|
+
/** FG_* 变量名集合:从 src 全量收集(只读,不猜)。 */
|
|
58
|
+
function collectEnvNames() {
|
|
59
|
+
const names = new Set()
|
|
60
|
+
const walk = (dir) => {
|
|
61
|
+
let entries
|
|
62
|
+
try {
|
|
63
|
+
entries = readdirSync(dir, { withFileTypes: true })
|
|
64
|
+
} catch {
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
for (const e of entries) {
|
|
68
|
+
if (e.name === 'node_modules') continue
|
|
69
|
+
const p = join(dir, e.name)
|
|
70
|
+
if (e.isDirectory()) walk(p)
|
|
71
|
+
else if (/\.(mjs|js)$/.test(e.name)) {
|
|
72
|
+
const text = readFileSync(p, 'utf8')
|
|
73
|
+
for (const m of text.matchAll(/\bFG_[A-Z0-9_]+\b/g)) names.add(m[0])
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
walk(join(ROOT, 'packages/core'))
|
|
78
|
+
return names
|
|
79
|
+
}
|
|
80
|
+
const ENV_NAMES = collectEnvNames()
|
|
81
|
+
|
|
82
|
+
const SKIP_PATH = /\s|<|>|\*|\?|\{|\}|\.\.\.|…|^https?:|^file:|^[A-Za-z]:|^~|^\$|^%|^you$|^\.\.$/
|
|
83
|
+
|
|
84
|
+
/** 运行期产物目录:文档里写它们只在说「会生成到哪」,不该被要求当前就存在。 */
|
|
85
|
+
const RUNTIME_PREFIX = /^(?:\.focus-guard|\.ai|\.stryker-tmp|reports|\.dsh|library|notes|output|archive)\//
|
|
86
|
+
|
|
87
|
+
/** 只认本仓自己的目录前缀;`memory-core/`、`plugins/` 这类是外部项目引用,不归本仓查。 */
|
|
88
|
+
const REPO_PREFIX = /^(?:packages|docs|\.ai|\.githooks|\.github|\.claude-plugin|\.zcode-plugin|src|tests|tools|hooks|skills|presets|assets|scripts)\//
|
|
89
|
+
const PATHISH = /^(?:packages|docs|\.ai|\.githooks|\.github|\.claude-plugin|\.zcode-plugin)\//
|
|
90
|
+
const EXT = /\.(?:md|mjs|js|json|yml|yaml|html|css|txt|sh|ps1|bat)$/
|
|
91
|
+
|
|
92
|
+
const rows = []
|
|
93
|
+
function report(file, line, rule, snippet, detail) {
|
|
94
|
+
rows.push({ file: relative(ROOT, file).replace(/\\/g, '/'), line, rule, snippet, detail })
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function checkScript(file, line, name) {
|
|
98
|
+
const head = name.split(/\s+/)[0]
|
|
99
|
+
if (!head || head.startsWith('-')) return
|
|
100
|
+
if (scripts.includes(head)) return
|
|
101
|
+
report(file, line, 'npm-script', `npm run ${head}`, `package.json scripts 里没有 ${head}`)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function checkPath(file, line, token, lineText = '') {
|
|
105
|
+
const t = token.trim()
|
|
106
|
+
if (!t || SKIP_PATH.test(t)) return
|
|
107
|
+
const bare = t.replace(/[.,;:))】]+$/, '').replace(/^['"]|['"]$/g, '')
|
|
108
|
+
if (!REPO_PREFIX.test(bare) && !PATHISH.test(bare)) return
|
|
109
|
+
if (RUNTIME_PREFIX.test(bare)) return
|
|
110
|
+
if (!EXT.test(bare) && !bare.endsWith('/')) return
|
|
111
|
+
if (bare.includes('*')) return
|
|
112
|
+
// 文档里的路径有三种写法,逐一试:仓库根相对、文档同目录相对、包内相对(packages/core/…)。
|
|
113
|
+
const candidates = [
|
|
114
|
+
join(ROOT, bare),
|
|
115
|
+
resolve(dirname(file), bare),
|
|
116
|
+
resolve(dirname(file), '..', bare),
|
|
117
|
+
join(ROOT, 'packages/core', bare),
|
|
118
|
+
join(ROOT, 'packages/core/src', bare),
|
|
119
|
+
join(ROOT, 'packages/core/src/dsh', bare),
|
|
120
|
+
]
|
|
121
|
+
for (const c of candidates) {
|
|
122
|
+
try {
|
|
123
|
+
if (existsSync(c) && statSync(c)) return
|
|
124
|
+
} catch {
|
|
125
|
+
/* keep trying */
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// 计划/设计类段落里的路径是「将来要建」,不是当前事实;只报告已建成文档里的死路径。
|
|
129
|
+
if (/计划|待做|未做|目标|将|拟|设计/.test(lineText)) return
|
|
130
|
+
report(file, line, 'repo-path', bare, '文件或目录不存在')
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function checkEnv(file, line, name) {
|
|
134
|
+
if (ENV_NAMES.has(name)) return
|
|
135
|
+
report(file, line, 'fg-env', name, 'packages/core/src 里没有这个环境变量')
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
for (const file of FILES) {
|
|
139
|
+
const lines = readFileSync(file, 'utf8').split('\n')
|
|
140
|
+
lines.forEach((text, i) => {
|
|
141
|
+
const line = i + 1
|
|
142
|
+
for (const m of text.matchAll(/npm run ([A-Za-z0-9:_-]+)/g)) checkScript(file, line, m[1])
|
|
143
|
+
for (const m of text.matchAll(/\bFG_[A-Z0-9_]+\b/g)) checkEnv(file, line, m[0])
|
|
144
|
+
// 只查反引号包裹的路径;代码块里没有反引号,靠行内格式,避免把命令参数当路径。
|
|
145
|
+
for (const m of text.matchAll(/`([^`\n]+)`/g)) checkPath(file, line, m[1], text)
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
rows.sort((a, b) => (a.file === b.file ? a.line - b.line : a.file < b.file ? -1 : 1))
|
|
150
|
+
|
|
151
|
+
if (asJson) {
|
|
152
|
+
console.log(JSON.stringify({ scanned: FILES.length, issues: rows.length, rows }, null, 2))
|
|
153
|
+
} else {
|
|
154
|
+
console.log(`[docs:drift] 扫描 ${FILES.length} 份文档 → 漂移 ${rows.length} 条`)
|
|
155
|
+
let last = ''
|
|
156
|
+
for (const r of rows) {
|
|
157
|
+
if (r.file !== last) {
|
|
158
|
+
console.log(`\n${r.file}`)
|
|
159
|
+
last = r.file
|
|
160
|
+
}
|
|
161
|
+
console.log(` :${r.line} [${r.rule}] ${r.snippet} — ${r.detail}`)
|
|
162
|
+
}
|
|
163
|
+
if (!rows.length) console.log(' 无漂移。')
|
|
164
|
+
}
|
|
165
|
+
process.exit(strict && rows.length ? 1 : 0)
|
package/tools/docs-lint.mjs
CHANGED
|
@@ -6,16 +6,20 @@
|
|
|
6
6
|
* node packages/core/tools/docs-lint.mjs --brief # 一行(供 npm run check)
|
|
7
7
|
* node packages/core/tools/docs-lint.mjs --json # 机器读
|
|
8
8
|
* node packages/core/tools/docs-lint.mjs --strict # 有问题即 exit 1
|
|
9
|
+
* node packages/core/tools/docs-lint.mjs --sync-status # 重新生成 docs/STATUS.md
|
|
9
10
|
*
|
|
10
11
|
* 闸门是棘轮:`BUDGET` 记当前存量(初始 0),只许降不许升。
|
|
11
12
|
* 这是 3.5「文档重置完成」的前置尺子(D5);README 硬指标、数字单点、状态头分别归 D1/D4/D2。
|
|
12
13
|
*/
|
|
14
|
+
import { writeFileSync } from 'node:fs'
|
|
15
|
+
import { join } from 'node:path'
|
|
13
16
|
import { fileURLToPath } from 'node:url'
|
|
14
17
|
import {
|
|
15
18
|
listMarkdownFiles,
|
|
16
19
|
checkVersionFace,
|
|
17
20
|
checkRelativeLinks,
|
|
18
21
|
checkCodePathRefs,
|
|
22
|
+
checkScriptRefs,
|
|
19
23
|
checkStatusHeaders,
|
|
20
24
|
checkIndexCoverage,
|
|
21
25
|
allDocFiles,
|
|
@@ -23,12 +27,16 @@ import {
|
|
|
23
27
|
checkCitationStyle,
|
|
24
28
|
} from './lib/docs-core.mjs'
|
|
25
29
|
import { checkVersionClaims, checkReadmeVersionFace } from './lib/docs-version.mjs'
|
|
30
|
+
import { checkAckFreshness } from './lib/docs-ack.mjs'
|
|
31
|
+
import { STATUS_DOC, collectDocStatus, renderStatusTable, checkStatusTable } from './lib/docs-status.mjs'
|
|
32
|
+
import { checkModulePaths, checkModuleIds, checkModuleOverlap, checkModuleCoverage } from './lib/modules.mjs'
|
|
26
33
|
|
|
27
34
|
const ROOT = fileURLToPath(new URL('../../../', import.meta.url))
|
|
28
35
|
const argv = process.argv.slice(2)
|
|
29
36
|
const AS_JSON = argv.includes('--json')
|
|
30
37
|
const BRIEF = argv.includes('--brief')
|
|
31
38
|
const STRICT = argv.includes('--strict')
|
|
39
|
+
const SYNC_STATUS = argv.includes('--sync-status')
|
|
32
40
|
const BUDGET = 0
|
|
33
41
|
|
|
34
42
|
/**
|
|
@@ -41,16 +49,32 @@ const BUDGET = 0
|
|
|
41
49
|
const RULE_BUDGET = { 'dead-code-path': 0 }
|
|
42
50
|
|
|
43
51
|
const files = listMarkdownFiles(ROOT)
|
|
52
|
+
|
|
53
|
+
// `--sync-status` 只做生成,不跑判据:生成器不该顺便当闸门,否则"红着生成"会把人搞糊涂。
|
|
54
|
+
if (SYNC_STATUS) {
|
|
55
|
+
const data = collectDocStatus(ROOT, files)
|
|
56
|
+
writeFileSync(join(ROOT, STATUS_DOC), renderStatusTable(data))
|
|
57
|
+
console.log(`已生成 ${STATUS_DOC}:${data.rows.length} 份文档,当前版本 ${data.current}。`)
|
|
58
|
+
process.exit(0)
|
|
59
|
+
}
|
|
60
|
+
|
|
44
61
|
const findings = [
|
|
45
62
|
...checkVersionFace(ROOT),
|
|
46
63
|
...checkRelativeLinks(ROOT, files),
|
|
47
64
|
...checkCodePathRefs(ROOT, files),
|
|
65
|
+
...checkScriptRefs(ROOT, files),
|
|
48
66
|
...checkStatusHeaders(ROOT),
|
|
49
67
|
...checkIndexCoverage(ROOT, allDocFiles(ROOT)),
|
|
68
|
+
...checkStatusTable(ROOT, files),
|
|
69
|
+
...checkModulePaths(ROOT),
|
|
70
|
+
...checkModuleIds(),
|
|
71
|
+
...checkModuleOverlap(ROOT),
|
|
72
|
+
...checkModuleCoverage(ROOT),
|
|
50
73
|
...checkReadmeMetrics(ROOT),
|
|
51
74
|
...checkCitationStyle(ROOT),
|
|
52
75
|
...checkVersionClaims(ROOT),
|
|
53
76
|
...checkReadmeVersionFace(ROOT),
|
|
77
|
+
...checkAckFreshness(ROOT, files),
|
|
54
78
|
]
|
|
55
79
|
const byRule = {}
|
|
56
80
|
for (const f of findings) byRule[f.rule] = (byRule[f.rule] || 0) + 1
|
|
@@ -28,10 +28,21 @@
|
|
|
28
28
|
* (`.focus-guard/AUDIT.log`、`.ai/CASE_FILE.md` 就是验证安装是否生效的那两行)。
|
|
29
29
|
* 写在这里不新增任何暴露面,反而少一次"名字藏在配置文件里、哪天配置文件丢了就失效"。
|
|
30
30
|
*
|
|
31
|
+
* ## 什么时候跑(2026-11-18 变更:不再挂 `postinstall`)
|
|
32
|
+
*
|
|
33
|
+
* 原先挂在 `postinstall` 上,装完即清。**这条挂载把安装搞挂了**:包里带 lifecycle 脚本
|
|
34
|
+
* → pnpm 10 报 `ERR_PNPM_IGNORED_BUILDS` 并非零退出 → `dsh plugin` 作为 pnpm 的薄转发器,
|
|
35
|
+
* pnpm 一失败,它后面「把声明了 `dsh.bundle` 的依赖对账进 `dsh.profile.bundles`」那步
|
|
36
|
+
* 就被整段跳过。结果是包进了 `dependencies`、却没进 loader 清单,dsh 启动后插件根本不加载。
|
|
37
|
+
* 第三方验证平台看到的就是「装成功、清单里没有」(2026-11-17 实测)。
|
|
38
|
+
*
|
|
39
|
+
* 现在由会话启动缝调起(`src/dsh/seams/session-start.mjs` 的 `sweepOnce()`,每进程一次,
|
|
40
|
+
* 异步、失败静默)。清洁晚一步,换**装得上**——这笔交易值。
|
|
41
|
+
*
|
|
31
42
|
* 用法:
|
|
32
43
|
* node packages/core/tools/first-run-sweep.mjs # 检查并清理
|
|
33
44
|
* node packages/core/tools/first-run-sweep.mjs --dry # 只说会删什么
|
|
34
|
-
* 退出码:恒 0
|
|
45
|
+
* 退出码:恒 0(清洁失败不该让任何事失败)
|
|
35
46
|
*/
|
|
36
47
|
|
|
37
48
|
import { existsSync, readFileSync, realpathSync, rmSync } from 'node:fs'
|
|
@@ -118,6 +129,6 @@ function main() {
|
|
|
118
129
|
try {
|
|
119
130
|
main()
|
|
120
131
|
} catch (e) {
|
|
121
|
-
/*
|
|
132
|
+
/* 由会话启动缝异步调起:清洁失败不该让用户装不上包,也不该让会话起不来。只报,不抛。 */
|
|
122
133
|
process.stdout.write(`[sweep] 跳过(${e.message})\n`)
|
|
123
134
|
}
|
package/tools/gate-audit.mjs
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* 用法:node packages/core/tools/gate-audit.mjs [--limit 20] [--json]
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { decodeSession as decode } from './lib/sessionDump.mjs'
|
|
19
|
-
import {
|
|
18
|
+
import { decodeSession as decode, walkSessionFiles } from './lib/sessionDump.mjs'
|
|
19
|
+
import { readFileSync } from 'node:fs'
|
|
20
20
|
import { join, dirname } from 'node:path'
|
|
21
21
|
import { fileURLToPath } from 'node:url'
|
|
22
22
|
|
|
@@ -28,32 +28,11 @@ const argv = process.argv.slice(2)
|
|
|
28
28
|
const LIMIT = Number(argv.includes('--limit') ? argv[argv.indexOf('--limit') + 1] : 20) || 20
|
|
29
29
|
const AS_JSON = argv.includes('--json')
|
|
30
30
|
|
|
31
|
-
function walk(dir, out = []) {
|
|
32
|
-
let entries = []
|
|
33
|
-
try {
|
|
34
|
-
entries = readdirSync(dir)
|
|
35
|
-
} catch {
|
|
36
|
-
return out
|
|
37
|
-
}
|
|
38
|
-
for (const e of entries) {
|
|
39
|
-
const p = join(dir, e)
|
|
40
|
-
let st
|
|
41
|
-
try {
|
|
42
|
-
st = statSync(p)
|
|
43
|
-
} catch {
|
|
44
|
-
continue
|
|
45
|
-
}
|
|
46
|
-
if (st.isDirectory()) walk(p, out)
|
|
47
|
-
else if (e === 'session.v4.jsonl.zstd') out.push({ file: p, mtime: st.mtimeMs })
|
|
48
|
-
}
|
|
49
|
-
return out
|
|
50
|
-
}
|
|
51
|
-
|
|
52
31
|
/** 多帧 zstd:按魔数 0x28B52FFD 分帧解压(单帧 API 只解第一帧)。 */
|
|
53
32
|
|
|
54
33
|
/** 从会话里取真实工具表:{ 工具名: Set(参数键) }。 */
|
|
55
34
|
function realToolSchema(limit) {
|
|
56
|
-
const files =
|
|
35
|
+
const files = walkSessionFiles(SESSIONS).slice(0, limit).map((x) => ({ file: x.f, mtime: x.m }))
|
|
57
36
|
const schema = new Map()
|
|
58
37
|
let usedSessions = 0
|
|
59
38
|
for (const f of files) {
|
package/tools/handoff.mjs
CHANGED
|
@@ -48,7 +48,9 @@ const block = (label, items) => {
|
|
|
48
48
|
}
|
|
49
49
|
if (items.length > 5) console.log(`- …(共 ${items.length} 条,其余见 workspace.json)`)
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
// 决策块已下架(2026-11-26):它打印的是人类指令原文,不是决策。见
|
|
52
|
+
// `src/memory/workspace.mjs` 文件头「下架声明」。新旧会话都不再展示,
|
|
53
|
+
// 避免"简报里看着像结论、其实是问句"。
|
|
52
54
|
block('约束(被人否决过的命令)', record.constraints)
|
|
53
55
|
block('下一步', record.next_action)
|
|
54
56
|
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 安装自检(2026-11-18)
|
|
4
|
+
*
|
|
5
|
+
* ## 起因
|
|
6
|
+
*
|
|
7
|
+
* 3.5.1 及以前,包里带着 `postinstall`。pnpm 10 起对未批准的构建脚本报
|
|
8
|
+
* `ERR_PNPM_IGNORED_BUILDS` 并**非零退出**;而 `dsh plugin` 是 pnpm 的薄转发器,
|
|
9
|
+
* pnpm 一失败,它后面「把声明了 `dsh.bundle` 的依赖对账进 `dsh.profile.bundles`」
|
|
10
|
+
* 那一步就被整段跳过。结果是包躺在 `dependencies` 里、却进不了 loader 清单——
|
|
11
|
+
* **装上了,不加载**。
|
|
12
|
+
*
|
|
13
|
+
* 三条路都碰不到这个缺陷,所以它活了很久:
|
|
14
|
+
* ① 开发机用 `link:` 装,pnpm 对链接依赖不跑构建脚本;
|
|
15
|
+
* ② 文档在 3.5.1 之前一直教 `github:…#path:` 或本地路径;
|
|
16
|
+
* ③ CI 只跑源码树,从不执行「装进 profile → 起 dsh → 看清单」。
|
|
17
|
+
* 最后是第三方验证平台报 `L5.4 not-found` 才发现的。
|
|
18
|
+
*
|
|
19
|
+
* ## 判据
|
|
20
|
+
*
|
|
21
|
+
* 静态(默认跑,CI 也跑;都不需要 dsh):
|
|
22
|
+
* A `lifecycle-free` package.json 不得含 install 系脚本(preinstall / install /
|
|
23
|
+
* postinstall / prepare / prepublish)——**这条就是根因的回归防线**
|
|
24
|
+
* B `patch-exists` `dsh.bundle.patch` 指向的文件必须在包内
|
|
25
|
+
* C `entry-shape` 入口必须导出 `name` 与 `apply`(cordis 插件形态)
|
|
26
|
+
* D `engines-dsh` 兼容声明必须写在 `engines.dsh`(dsh 只认这个位置,见下)
|
|
27
|
+
*
|
|
28
|
+
* 安装(`--install`,需要 dsh):
|
|
29
|
+
* E `bundles-registered` 把**本地 tarball**装进一次性 profile,断言
|
|
30
|
+
* `dsh.profile.bundles` 里出现本包,然后拆掉现场
|
|
31
|
+
*
|
|
32
|
+
* D 的由来(2026-11-19):dsh 0.2 的 `unmetRequirements` 是「有 `engines.dsh` 就只看它,
|
|
33
|
+
* `peerDependencies` 全部忽略;没有才退回去扫 `@deepseek-ai/dsh*` 的 peer」。我们一直只写了
|
|
34
|
+
* peer(3.0.6 起),判定其实一直在生效——但**外部验证平台只认 `engines.dsh`**,于是页面显示
|
|
35
|
+
* 「作者未声明 dsh 版本要求」。约束存在而不可见,等于半个没有。
|
|
36
|
+
*
|
|
37
|
+
* 缺 `dsh` 时 D 记 **skip 并明说**,不静默通过——「没查」与「查过没问题」
|
|
38
|
+
* 必须能分开(本仓为此栽过:判据缺失静默返回空)。
|
|
39
|
+
*
|
|
40
|
+
* 用法:
|
|
41
|
+
* node tools/install-check.mjs # 静态四项
|
|
42
|
+
* node tools/install-check.mjs --install # 再加一次真装
|
|
43
|
+
* node tools/install-check.mjs --strict # 有任何 finding 即 exit 1
|
|
44
|
+
*/
|
|
45
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync } from 'node:fs'
|
|
46
|
+
import { homedir, tmpdir } from 'node:os'
|
|
47
|
+
import { join } from 'node:path'
|
|
48
|
+
import { spawnSync } from 'node:child_process'
|
|
49
|
+
import { fileURLToPath } from 'node:url'
|
|
50
|
+
|
|
51
|
+
const ROOT = fileURLToPath(new URL('..', import.meta.url))
|
|
52
|
+
const STRICT = process.argv.includes('--strict')
|
|
53
|
+
const WITH_INSTALL = process.argv.includes('--install')
|
|
54
|
+
if (process.env.FG_TRACE) {
|
|
55
|
+
process.stderr.write(
|
|
56
|
+
`[trace] pid=${process.pid} ppid=${process.ppid} lifecycle=${process.env.npm_lifecycle_event || '-'} argv=${process.argv.slice(1).join(' ')}\n`,
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 防重入(2026-11-19):跑 `--install` 时会**再起一个本脚本**(pid 不同、profile 名不同),
|
|
61
|
+
* 两个进程各建一套现场;内层那套装成功了却没被拆掉,于是每次自检在 `~/.dsh/profiles`
|
|
62
|
+
* 里留一个 `fg-selfcheck-<pid>`。
|
|
63
|
+
*
|
|
64
|
+
* 先试过环境变量,**不生效**——内层进程看不到外层设的 `FG_INSTALL_CHECK`(那条链中间
|
|
65
|
+
* 有人重置了环境)。改成系统临时目录里的锁文件:不依赖环境继承,只看「有没有人在跑」。
|
|
66
|
+
* 持有者 pid 已死则接管,避免崩溃留下死锁。
|
|
67
|
+
*/
|
|
68
|
+
const LOCK = join(tmpdir(), 'fg-install-check.lock')
|
|
69
|
+
|
|
70
|
+
function acquireLock() {
|
|
71
|
+
const me = JSON.stringify({ pid: process.pid, ppid: process.ppid, at: Date.now(), argv: process.argv.slice(1) })
|
|
72
|
+
try {
|
|
73
|
+
writeFileSync(LOCK, me, { flag: 'wx' })
|
|
74
|
+
return true
|
|
75
|
+
} catch {
|
|
76
|
+
let holder = null
|
|
77
|
+
try {
|
|
78
|
+
holder = JSON.parse(readFileSync(LOCK, 'utf8'))
|
|
79
|
+
} catch {
|
|
80
|
+
holder = null
|
|
81
|
+
}
|
|
82
|
+
if (holder && typeof holder.pid === 'number') {
|
|
83
|
+
try {
|
|
84
|
+
process.kill(holder.pid, 0)
|
|
85
|
+
// 持有者还活着:把双方身份都记下来,冲突才有据可查。
|
|
86
|
+
notes.push(`锁被 pid ${holder.pid}(父 ${holder.ppid})持有,本人 pid ${process.pid}(父 ${process.ppid})`)
|
|
87
|
+
return false
|
|
88
|
+
} catch {
|
|
89
|
+
/* 持有者已死,接管 */
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
writeFileSync(LOCK, me)
|
|
94
|
+
return true
|
|
95
|
+
} catch {
|
|
96
|
+
return false
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function releaseLock() {
|
|
102
|
+
try {
|
|
103
|
+
rmSync(LOCK, { force: true })
|
|
104
|
+
} catch {
|
|
105
|
+
/* 释放失败不影响判定 */
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Windows 上 `dsh` / `npm` 是 .cmd 垫片,不经 shell 调用就得补后缀(走 shell 会被静态扫描判为注入面)。 */
|
|
109
|
+
const BIN = (n) => (process.platform === 'win32' ? `${n}.cmd` : n)
|
|
110
|
+
|
|
111
|
+
/** pnpm 会拦的构建脚本。`prepare` 也在内:本地安装时同样会跑。 */
|
|
112
|
+
const LIFECYCLE = ['preinstall', 'install', 'postinstall', 'prepare', 'prepublish', 'prepublishOnly']
|
|
113
|
+
|
|
114
|
+
const findings = []
|
|
115
|
+
const notes = []
|
|
116
|
+
|
|
117
|
+
function readPkg() {
|
|
118
|
+
return JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** A:install 系脚本一律不许有。 */
|
|
122
|
+
function checkLifecycle(pkg) {
|
|
123
|
+
const hit = LIFECYCLE.filter((k) => pkg.scripts && pkg.scripts[k])
|
|
124
|
+
if (!hit.length) return
|
|
125
|
+
findings.push({
|
|
126
|
+
rule: 'lifecycle-script',
|
|
127
|
+
detail: `package.json 含 install 系脚本 ${hit.join(' / ')}——pnpm 会报 ERR_PNPM_IGNORED_BUILDS 并非零退出,dsh 的 bundles 对账随之被跳过`,
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** B:`dsh.bundle.patch` 必须是包内真实文件(字符串或数组都认)。 */
|
|
132
|
+
function checkPatch(pkg) {
|
|
133
|
+
const declared = pkg.dsh && pkg.dsh.bundle && pkg.dsh.bundle.patch
|
|
134
|
+
if (declared === undefined) {
|
|
135
|
+
findings.push({ rule: 'patch-missing', detail: 'package.json 没有 dsh.bundle.patch——dsh 不会把它当 profile bundle' })
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
const list = typeof declared === 'string' ? [declared] : Array.isArray(declared) ? declared : null
|
|
139
|
+
if (!list) {
|
|
140
|
+
findings.push({ rule: 'patch-missing', detail: 'dsh.bundle.patch 既不是字符串也不是数组' })
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
for (const rel of list) {
|
|
144
|
+
if (!existsSync(join(ROOT, rel))) findings.push({ rule: 'patch-missing', detail: `dsh.bundle.patch 指向的 ${rel} 不存在` })
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** C:入口得是 cordis 认的形状(`name` + `apply`)。读源码而不 import——不为了检查去执行副作用。 */
|
|
149
|
+
function checkEntry(pkg) {
|
|
150
|
+
const entry = pkg.main || (pkg.exports && pkg.exports['.'])
|
|
151
|
+
const rel = typeof entry === 'string' ? entry : entry && entry.default
|
|
152
|
+
if (!rel) {
|
|
153
|
+
findings.push({ rule: 'entry-shape', detail: 'package.json 没有 main/exports,dsh 无从加载' })
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
const abs = join(ROOT, rel)
|
|
157
|
+
if (!existsSync(abs)) {
|
|
158
|
+
findings.push({ rule: 'entry-shape', detail: `入口 ${rel} 不存在` })
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
const src = readFileSync(abs, 'utf8')
|
|
162
|
+
for (const need of [/export\s+(?:const|let)\s+name\s*=/, /export\s+(?:async\s+)?function\s+apply\s*\(/]) {
|
|
163
|
+
if (!need.test(src)) findings.push({ rule: 'entry-shape', detail: `入口 ${rel} 缺 ${need.source}——不是 cordis 插件形态` })
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** D:兼容范围得写在 `engines.dsh`——那是 dsh 唯一「说了算」的位置。 */
|
|
168
|
+
function checkEnginesDsh(pkg) {
|
|
169
|
+
const range = pkg.engines && pkg.engines.dsh
|
|
170
|
+
if (typeof range !== 'string' || !range.trim()) {
|
|
171
|
+
findings.push({
|
|
172
|
+
rule: 'engines-dsh',
|
|
173
|
+
detail: 'package.json 没有 engines.dsh——版本约束只写在 peerDependencies 里时,dsh 仍会校验(退路),但外部平台与读者都看不见,等于半个声明',
|
|
174
|
+
})
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
// dsh 的 `workspace:` 特例只对 peer 生效;写进 engines 会被当成普通范围,永不满足。
|
|
178
|
+
if (range.includes('workspace:')) {
|
|
179
|
+
findings.push({
|
|
180
|
+
rule: 'engines-dsh',
|
|
181
|
+
detail: `engines.dsh 写成了 ${range}——workspace: 只在 peerDependencies 里被解析,放进 engines 等于永不满足`,
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** profile 目录可能落在 DSH_HOME(指向 .dsh 本身或它的父目录)或默认 ~/.dsh。 */
|
|
187
|
+
function findProfile(name) {
|
|
188
|
+
const homes = [process.env.DSH_HOME, join(homedir(), '.dsh')].filter(Boolean)
|
|
189
|
+
const cands = []
|
|
190
|
+
for (const h of homes) {
|
|
191
|
+
cands.push(join(h, 'profiles', name), join(h, '.dsh', 'profiles', name))
|
|
192
|
+
}
|
|
193
|
+
return cands.find((p) => existsSync(join(p, 'package.json')))
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** D:真装一次。用**本地 tarball**,不是 registry 上那个已发布版本——检查的是这一棵树。 */
|
|
197
|
+
function checkInstall(pkg) {
|
|
198
|
+
// Windows 上 `dsh` / `npm` 是 .cmd 垫片,Node 不经 shell 无法执行它们(CVE-2024-27980 之后的限制)。
|
|
199
|
+
// 这里敢开 shell:**参数全是内部常量**——profile 名只有 pid,tarball 用文件名 + cwd 定位,
|
|
200
|
+
// 仓库路径走 spawn 的 cwd 选项而不进命令行。没有一处来自环境变量或用户输入。
|
|
201
|
+
const WIN = process.platform === 'win32'
|
|
202
|
+
const dsh = spawnSync(BIN('dsh'), ['--version'], { encoding: 'utf8', shell: WIN })
|
|
203
|
+
if (dsh.status !== 0) {
|
|
204
|
+
notes.push('skip 安装档:本机没有可用的 dsh 命令(静态四项已覆盖根因)')
|
|
205
|
+
return
|
|
206
|
+
}
|
|
207
|
+
// 现场放系统临时目录,不放包内 node_modules:pnpm 对「另一个包 node_modules 下的 tarball」
|
|
208
|
+
// 有额外语义(实测会装成空 bundle),把测量工具自己的位置变成一个变量。
|
|
209
|
+
const tmp = join(tmpdir(), `fg-install-check-${process.pid}`)
|
|
210
|
+
const name = `fg-selfcheck-${process.pid}`
|
|
211
|
+
let packed = ''
|
|
212
|
+
/** 现场目录在 finally 里拆——**任何提前 return 都不能留下 profile**。 */
|
|
213
|
+
let profileDir = ''
|
|
214
|
+
try {
|
|
215
|
+
rmSync(tmp, { recursive: true, force: true })
|
|
216
|
+
mkdirSync(tmp, { recursive: true })
|
|
217
|
+
const pack = spawnSync(BIN('npm'), ['pack'], { cwd: ROOT, encoding: 'utf8', shell: WIN })
|
|
218
|
+
if (pack.status !== 0) {
|
|
219
|
+
findings.push({ rule: 'install-skip', detail: `npm pack 失败:${(pack.stderr || '').trim().slice(0, 200)}` })
|
|
220
|
+
return
|
|
221
|
+
}
|
|
222
|
+
packed = readdirSync(ROOT).find((f) => f.endsWith('.tgz')) || ''
|
|
223
|
+
if (!packed) {
|
|
224
|
+
findings.push({ rule: 'install-skip', detail: 'npm pack 没有产出 .tgz' })
|
|
225
|
+
return
|
|
226
|
+
}
|
|
227
|
+
// 仓库与系统临时目录可能不在同一个盘,rename 会 EXDEV——复制后删原件。
|
|
228
|
+
copyFileSync(join(ROOT, packed), join(tmp, packed))
|
|
229
|
+
rmSync(join(ROOT, packed), { force: true })
|
|
230
|
+
// 必须用**绝对路径**:`dsh plugin` 会把 pnpm 的 cwd 切到 profile 目录,
|
|
231
|
+
// 相对路径的 tarball 在那里解析不到——pnpm 静默装了个空,bundles 自然没有。
|
|
232
|
+
// Windows 上走 shell,路径要自己加引号(Node 在 shell 模式下不做转义)。
|
|
233
|
+
const tgzAbs = join(tmp, packed)
|
|
234
|
+
const spec = WIN ? `"${tgzAbs}"` : tgzAbs
|
|
235
|
+
const add = spawnSync(BIN('dsh'), ['plugin', '--profile', name, 'add', spec], {
|
|
236
|
+
cwd: tmp,
|
|
237
|
+
encoding: 'utf8',
|
|
238
|
+
shell: WIN,
|
|
239
|
+
})
|
|
240
|
+
profileDir = findProfile(name) || ''
|
|
241
|
+
if (!profileDir) {
|
|
242
|
+
findings.push({
|
|
243
|
+
rule: 'install-profile',
|
|
244
|
+
detail: `装完找不到 profile 目录(dsh exit ${add.status}):${(add.stdout || add.stderr || '').trim().slice(0, 200)}`,
|
|
245
|
+
})
|
|
246
|
+
return
|
|
247
|
+
}
|
|
248
|
+
const installed = JSON.parse(readFileSync(join(profileDir, 'package.json'), 'utf8'))
|
|
249
|
+
const bundles = (installed.dsh && installed.dsh.profile && installed.dsh.profile.bundles) || []
|
|
250
|
+
if (!bundles.includes(pkg.name)) {
|
|
251
|
+
findings.push({
|
|
252
|
+
rule: 'bundles-registered',
|
|
253
|
+
detail: `装完 dsh.profile.bundles 里没有 ${pkg.name}(现有:${bundles.join(' / ') || '空'})——装上了但不会加载`,
|
|
254
|
+
})
|
|
255
|
+
}
|
|
256
|
+
} finally {
|
|
257
|
+
// 清理失败不改变判定,但也不能吞得无声无息:留一行 note,下次才知道地上有垃圾。
|
|
258
|
+
if (profileDir) {
|
|
259
|
+
try {
|
|
260
|
+
rmSync(profileDir, { recursive: true, force: true })
|
|
261
|
+
} catch (e) {
|
|
262
|
+
notes.push(`profile 现场未拆净(${profileDir}):${e.code || e.message}`)
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
rmSync(tmp, { recursive: true, force: true })
|
|
266
|
+
if (packed && existsSync(join(ROOT, packed))) rmSync(join(ROOT, packed), { force: true })
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const pkg = readPkg()
|
|
271
|
+
checkLifecycle(pkg)
|
|
272
|
+
checkPatch(pkg)
|
|
273
|
+
checkEntry(pkg)
|
|
274
|
+
checkEnginesDsh(pkg)
|
|
275
|
+
if (WITH_INSTALL) {
|
|
276
|
+
// 拿不到锁时 acquireLock 已把冲突双方写进 notes,这里不重复记。
|
|
277
|
+
if (acquireLock()) {
|
|
278
|
+
try {
|
|
279
|
+
checkInstall(pkg)
|
|
280
|
+
} finally {
|
|
281
|
+
releaseLock()
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const head = `安装自检:${WITH_INSTALL ? '静态 4 项 + 安装档' : '静态 4 项'}`
|
|
287
|
+
if (!findings.length) {
|
|
288
|
+
process.stdout.write(`[install-check] ${head},问题 0 条${notes.length ? `;${notes.join(';')}` : ''}\n`)
|
|
289
|
+
} else {
|
|
290
|
+
process.stdout.write(`[install-check] ${head},问题 ${findings.length} 条\n`)
|
|
291
|
+
for (const f of findings) process.stdout.write(` ✗ [${f.rule}] ${f.detail}\n`)
|
|
292
|
+
if (notes.length) process.stdout.write(` · ${notes.join(';')}\n`)
|
|
293
|
+
if (STRICT) process.exit(1)
|
|
294
|
+
}
|
package/tools/layering-audit.mjs
CHANGED
|
@@ -35,7 +35,13 @@ const HOST_MARKS = {
|
|
|
35
35
|
const TOOL_NAMES = /\b(?:Bash|Write|Edit|MultiEdit|Read|Grep|Glob|run_code)(?![\w-])/
|
|
36
36
|
// 白名单:规则文本(SESSION_RULES)里提到 Grep/head_limit 属面向模型的表述。
|
|
37
37
|
const ALLOW = {
|
|
38
|
-
toolNames: [
|
|
38
|
+
toolNames: [
|
|
39
|
+
'src/core/constants.mjs',
|
|
40
|
+
// 2026-11-20:`PS_CMDLET` 的动词表里含 `Write`(`Write-Content` 这类 cmdlet 的动词),
|
|
41
|
+
// 命中 TOOL_NAMES 属误报——那里检测的是**命令文本方言**,与宿主工具名无关。
|
|
42
|
+
// 判据本身没错(PowerShell 动词确实不该出现在 bash 里),只是它长得像工具名。
|
|
43
|
+
'src/core/env.mjs',
|
|
44
|
+
],
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
function walk(dir, out = []) {
|