dsh-git-push 2.8.4 → 2.9.1

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.
Files changed (46) hide show
  1. package/README.md +22 -3
  2. package/assets/minihost.sh +35 -0
  3. package/assets/preview.html +36703 -0
  4. package/assets/start.sh +396 -0
  5. package/assets/tree-sitter/LICENSE +21 -0
  6. package/assets/tree-sitter/README.md +69 -0
  7. package/assets/tree-sitter/VERSIONS.txt +1 -0
  8. package/assets/tree-sitter/tree-sitter-javascript.wasm +0 -0
  9. package/assets/tree-sitter/tree-sitter-python.wasm +0 -0
  10. package/assets/tree-sitter/tree-sitter-typescript.wasm +0 -0
  11. package/assets/tree-sitter/tree-sitter.js +3980 -0
  12. package/assets/tree-sitter/tree-sitter.wasm +0 -0
  13. package/lib/app/apply.js +15 -2
  14. package/lib/app/audit-api.js +1 -1
  15. package/lib/app/command-registry.js +6 -2
  16. package/lib/app/handlers/workspace-paths.js +107 -0
  17. package/lib/app/http-handlers.js +19 -2
  18. package/lib/app/inject-text.js +1 -0
  19. package/lib/app/tool-call.js +38 -4
  20. package/lib/app/tools.js +5 -11
  21. package/lib/ast/code-lines.js +52 -0
  22. package/lib/ast/index.js +1 -1
  23. package/lib/ast/tokenizer.js +7 -2
  24. package/lib/ast/treesitter.js +208 -0
  25. package/lib/audit/audit-file.js +3 -3
  26. package/lib/audit/orchestrate.js +38 -0
  27. package/lib/audit-rules/audit-rules-nodejs.yml +2 -2
  28. package/lib/audit-rules/audit-rules-paths.yml +1 -1
  29. package/lib/audit-rules/audit-rules-performance.yml +12 -0
  30. package/lib/checks/dispatch.js +3 -3
  31. package/lib/checks/filter.js +7 -1
  32. package/lib/checks/regex.js +19 -4
  33. package/lib/commit-push.js +8 -4
  34. package/lib/core/workspace-paths.js +100 -0
  35. package/lib/git/push.js +9 -3
  36. package/lib/npm/publish.js +6 -2
  37. package/lib/npm/registry.js +23 -2
  38. package/lib/rule/registry.js +7 -0
  39. package/lib/self/index.js +4 -1
  40. package/lib/user-requirements.json +2 -1
  41. package/package.json +2 -1
  42. package/scripts/cpu-sample.mjs +188 -0
  43. package/scripts/sync-plugin-install.mjs +84 -21
  44. package/scripts/sync-plugin.mjs +14 -9
  45. package/skills/guide/guide-cli-scripts.md +1 -1
  46. package/skills/guide/guide-commit-push.md +33 -0
@@ -0,0 +1,208 @@
1
+ /**
2
+ * AST 实现层 · tree-sitter(真语法树 · WASM)
3
+ *
4
+ * 定位:**可选增强,绝不是必需依赖**。任何一步失败(资产缺失 / wasm 加载失败 / 无对应语法 /
5
+ * 解析出语法错误 / 超出预算)都返回「未使用」信号,由调用方**回退**到
6
+ * lib/ast/code-lines.js 的 token 级判定(行级 + 列级,2.8.9 已落地)。
7
+ *
8
+ * 为什么这么设计:审计是提交门禁的一部分,**不能因为增强件坏了就整体失效** ✗。
9
+ * 回退不是异常路径,而是常态路径之一 ✓。
10
+ *
11
+ * 资产:assets/tree-sitter/(web-tree-sitter@0.27.1 + 各语言预编译 grammar;MIT)
12
+ * 来源、版本、sha256、可复现下载命令见该目录 README.md ✓
13
+ *
14
+ * 语言口径(既定口径):**加载哪些语言 = lib/audit-rules/ 里存在哪些语言规则包**
15
+ * (**空占位包也算**:cpp/go/php/rust/swift)。语法文件不存在时该语言自动走回退 ✓。
16
+ */
17
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
18
+ import { createHash } from 'node:crypto';
19
+ import { fileURLToPath, pathToFileURL } from 'node:url';
20
+ import { dirname, join } from 'node:path';
21
+
22
+ /** 资产目录(插件根/assets/tree-sitter)——本文件在 lib/ast/,故上溯两级。
23
+ * 可用 env `DSH_GIT_PUSH_TS_ASSETS` 覆盖:**回退路径测试**把它指向不存在的目录即可
24
+ * (测试禁止改动真实资产目录 ✗)。注意:本常量在**模块加载时**求值,测试需用子进程改 env ✓ */
25
+ export const ASSETS_DIR = process.env.DSH_GIT_PUSH_TS_ASSETS
26
+ || join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'assets', 'tree-sitter');
27
+
28
+ /** 扩展名 → 语法名(grammar)。没有映射的扩展名一律走回退 ✓。 */
29
+ export const EXT_TO_GRAMMAR = {
30
+ js: 'javascript', mjs: 'javascript', cjs: 'javascript', jsx: 'javascript',
31
+ ts: 'typescript', tsx: 'typescript', mts: 'typescript', cts: 'typescript',
32
+ py: 'python',
33
+ };
34
+
35
+ /** 单文件解析预算(字符数):超此长度不解析,直接回退(避免大文件拖慢审计)。 */
36
+ const MAX_PARSE_CHARS = Number(process.env.DSH_GIT_PUSH_TS_MAX_CHARS || 400000) || 400000;
37
+ /** 语法树缓存条数上限(按内容 hash 命中)。 */
38
+ const TREE_CACHE_MAX = Number(process.env.DSH_GIT_PUSH_TS_TREE_CACHE || 64) || 64;
39
+
40
+ /** 惰性状态(模块级):web-tree-sitter 模块 / 初始化 Promise / 语言与解析器缓存。 */
41
+ let modPromise = null;
42
+ let initPromise = null;
43
+ const langCache = new Map();
44
+ const parserCache = new Map();
45
+ const treeCache = new Map(); // hash → tree(简单 FIFO 淘汰)
46
+
47
+ /** 资产是否就位(供调用方与自检使用)。 */
48
+ export function treesitterAvailable() {
49
+ try {
50
+ return existsSync(join(ASSETS_DIR, 'tree-sitter.js')) && existsSync(join(ASSETS_DIR, 'tree-sitter.wasm'));
51
+ } catch { return false; }
52
+ }
53
+
54
+ /** 当前资产里实际可用的语法名列表(按目录里存在的 wasm 推断)。 */
55
+ export function availableGrammars() {
56
+ try {
57
+ return readdirSync(ASSETS_DIR)
58
+ .map((f) => /^tree-sitter-(.+)\.wasm$/.exec(f))
59
+ .filter(Boolean)
60
+ .map((m) => m[1])
61
+ .sort();
62
+ } catch { return []; }
63
+ }
64
+
65
+ /** 由扩展名(可带点)取语法名;无映射返回 ''。 */
66
+ export function grammarForExt(ext = '') {
67
+ const e = String(ext).toLowerCase().replace(/^\./, '');
68
+ return EXT_TO_GRAMMAR[e] || '';
69
+ }
70
+
71
+ /** 懒加载 web-tree-sitter 运行时(ESM 具名导出:Parser / Language / Query)。
72
+ * 文件名用上游原名:0.25.10 是 `tree-sitter.js` / `tree-sitter.wasm`(0.27.x 才是 web-tree-sitter.* ✗ 且与
73
+ * tree-sitter-wasms@0.1.13 的语法不兼容 —— 实测 0.27.1 在 getDylinkMetadata 处报空消息错误 ✗)。 */
74
+ async function loadModule() {
75
+ if (!modPromise) {
76
+ modPromise = import(pathToFileURL(join(ASSETS_DIR, 'tree-sitter.js')).href);
77
+ }
78
+ return modPromise;
79
+ }
80
+
81
+ /** 初始化一次(定位运行时 wasm)。失败返回 null(调用方回退)。 */
82
+ async function ensureInit() {
83
+ if (!initPromise) {
84
+ initPromise = (async () => {
85
+ const { Parser } = await loadModule();
86
+ // locateFile:告诉运行时去哪里取 web-tree-sitter.wasm(默认会按 URL 猜,容器里不可靠)
87
+ await Parser.init({ locateFile: (f) => join(ASSETS_DIR, f) });
88
+ return true;
89
+ })().catch(() => null);
90
+ }
91
+ return initPromise;
92
+ }
93
+
94
+ /** 取(并缓存)某语言的 Parser;不可用返回 null。 */
95
+ async function getParser(grammar) {
96
+ if (!grammar || !existsSync(join(ASSETS_DIR, `tree-sitter-${grammar}.wasm`))) return null;
97
+ if (parserCache.has(grammar)) return parserCache.get(grammar);
98
+ try {
99
+ if (!(await ensureInit())) return null;
100
+ const { Parser, Language } = await loadModule();
101
+ let lang = langCache.get(grammar);
102
+ if (!lang) {
103
+ // 传**字节**而不是路径:0.27.x 的 load(路径) 会静默失败(Node 分支虽会 readFile,但 dylink 不兼容);
104
+ // 字节是唯一被实测验证可用的入口(0.25.10 ✓)
105
+ lang = await Language.load(readFileSync(join(ASSETS_DIR, `tree-sitter-${grammar}.wasm`)));
106
+ langCache.set(grammar, lang);
107
+ }
108
+ const parser = new Parser();
109
+ parser.setLanguage(lang);
110
+ parserCache.set(grammar, parser);
111
+ return parser;
112
+ } catch {
113
+ return null; // 任何异常都退化为「不可用」⇒ 调用方回退 ✓
114
+ }
115
+ }
116
+
117
+ /** 解析文本(按内容 hash 缓存语法树);失败返回 null。 */
118
+ export async function parseText(text, grammar) {
119
+ const src = String(text ?? '');
120
+ if (!grammar || src.length > MAX_PARSE_CHARS) return null;
121
+ const hash = `${grammar}:${createHash('sha1').update(src).digest('hex')}`;
122
+ if (treeCache.has(hash)) return treeCache.get(hash);
123
+ const parser = await getParser(grammar);
124
+ if (!parser) return null;
125
+ try {
126
+ const tree = parser.parse(src);
127
+ if (!tree || !tree.rootNode || tree.rootNode.hasError) return null; // 语法错误 ⇒ 不信任该树,回退 ✓
128
+ treeCache.set(hash, tree);
129
+ while (treeCache.size > TREE_CACHE_MAX) treeCache.delete(treeCache.keys().next().value);
130
+ return tree;
131
+ } catch {
132
+ return null;
133
+ }
134
+ }
135
+
136
+ /** 节点或其祖先是否属于「不透明」构造(字符串/注释/模板/正则字面量)。 */
137
+ export function isOpaqueNode(node) {
138
+ for (let n = node; n; n = n.parent) {
139
+ const t = String(n.type || '');
140
+ if (/^(string|string_fragment|template_string|comment|line_comment|block_comment|regex|regex_pattern|interpreted_string_literal|raw_string_literal)$/.test(t)) return true;
141
+ if (/comment|string/.test(t)) return true; // 各语言命名差异的兜底
142
+ }
143
+ return false;
144
+ }
145
+
146
+ /**
147
+ * 用语法树确认一批命中是否为**真实代码**。
148
+ *
149
+ * @param {{text:string, ext?:string, grammar?:string, hits:Array<{line:number, col:number}>}} p
150
+ * @returns {Promise<{used:boolean, keep:boolean[], reason?:string}>}
151
+ * used=false ⇒ **调用方必须回退**到 token 级判定(keep 无意义);
152
+ * used=true ⇒ keep[i] 表示第 i 个命中是否为真代码(true=保留上报)。
153
+ */
154
+ export async function confirmHits({ text, ext = '', grammar = '', hits = [] } = {}) {
155
+ const g = grammar || grammarForExt(ext);
156
+ if (!g || !hits.length) return { used: false, keep: [], reason: 'no-grammar-or-hits' };
157
+ const tree = await parseText(text, g);
158
+ if (!tree) return { used: false, keep: [], reason: 'parse-unavailable' };
159
+ try {
160
+ const keep = hits.map((h) => {
161
+ const line = Number(h?.line);
162
+ const col = Number(h?.col);
163
+ if (!Number.isFinite(line) || line < 1) return true; // 拿不到位置 ⇒ 不拦(宁可放行不误杀)
164
+ const column = Number.isFinite(col) && col > 0 ? col - 1 : 0;
165
+ const node = tree.rootNode.descendantForPosition({ row: line - 1, column });
166
+ if (!node) return true;
167
+ return !isOpaqueNode(node);
168
+ });
169
+ return { used: true, keep };
170
+ } catch {
171
+ return { used: false, keep: [], reason: 'confirm-failed' };
172
+ }
173
+ }
174
+
175
+ /**
176
+ * 把已解析的语法树包成**同步**确认函数(供同步的检查器 lib/checks/* 调用)。
177
+ *
178
+ * 为什么需要:检查器是同步的,而解析是异步的 —— 由编排层(async)**预解析**后,
179
+ * 把同步闭包传下去,避免把整条检查链改成 async ✗。
180
+ *
181
+ * @param {object|null} tree parseText 的返回值
182
+ * @returns {null|((line:number, col:number)=>boolean|null)} 返回 null 表示「无法判定」,
183
+ * 调用方应回退到 token 级判定(行级 + 列级)✓
184
+ */
185
+ export function makeSyncConfirmer(tree) {
186
+ if (!tree || !tree.rootNode) return null;
187
+ return (line, col) => {
188
+ try {
189
+ const l = Number(line);
190
+ if (!Number.isFinite(l) || l < 1) return null;
191
+ const c = Number(col);
192
+ const column = Number.isFinite(c) && c > 0 ? c - 1 : 0;
193
+ const node = tree.rootNode.descendantForPosition({ row: l - 1, column });
194
+ if (!node) return null;
195
+ return !isOpaqueNode(node);
196
+ } catch {
197
+ return null;
198
+ }
199
+ };
200
+ }
201
+
202
+ /** 清空全部缓存(测试与长驻进程内存回收用)。 */
203
+ export function resetTreeSitterCache() { modPromise = null;
204
+ initPromise = null;
205
+ langCache.clear();
206
+ parserCache.clear();
207
+ treeCache.clear();
208
+ }
@@ -119,7 +119,7 @@ export function auditFile({ file, relPath, text, grouped }, opts = {}) {
119
119
  && !/no-empty-catch/.test(String(r?.id || '')));
120
120
  if (keep.length) scoped[kind] = keep;
121
121
  }
122
- let findings = runChecks({ file, relPath, text, grouped: scoped }, { level: opts?.level, repoHasJsYamlImport: opts?.repoHasJsYamlImport, repoLevelRules: opts?.repoLevelRules, repoPath: opts?.repoPath });
122
+ let findings = runChecks({ file, relPath, text, grouped: scoped }, { level: opts?.level, repoHasJsYamlImport: opts?.repoHasJsYamlImport, repoLevelRules: opts?.repoLevelRules, repoPath: opts?.repoPath, treeConfirm: opts?.treeConfirm });
123
123
  // 产物超长是属性非问题;内置行级检查(quality/empty-catch 等)与残余行级规则也屏蔽——
124
124
  // 混淆单行 10万+ 字符上 catch{} 等模式天然密集,非真实缺陷。
125
125
  const keepRule = /^secret-|^cred|security\/no-hardcoded-credentials|security\/no-path-traversal/; // 构建/混淆产物:健康度(行长/大小)是产物属性非问题,只留凭据/路径安全
@@ -132,7 +132,7 @@ export function auditFile({ file, relPath, text, grouped }, opts = {}) {
132
132
  const isTestFile = /(^|[/\\])(test|tests|__tests__|spec)[/\\]|\.(test|spec)\.(js|mjs|cjs|ts)$/i.test(String(relPath || file));
133
133
  const maintainabilityScoped = !isCode || isTestFile;
134
134
  const scopedGrouped = maintainabilityScoped ? { ...grouped, 'repeated-string': undefined, 'min-occurrences': undefined } : grouped;
135
- let findings = runChecks({ file, relPath, text, grouped: scopedGrouped }, { level: opts?.level, repoHasJsYamlImport: opts?.repoHasJsYamlImport, repoLevelRules: opts?.repoLevelRules, repoPath: opts?.repoPath });
135
+ let findings = runChecks({ file, relPath, text, grouped: scopedGrouped }, { level: opts?.level, repoHasJsYamlImport: opts?.repoHasJsYamlImport, repoLevelRules: opts?.repoLevelRules, repoPath: opts?.repoPath, treeConfirm: opts?.treeConfirm });
136
136
  const isRuleDefFile = /(^|[/\\])audit-rules-[a-z0-9-]+\.ya?ml$/i.test(String(relPath || file));
137
137
  const fileLines = String(text || '').split('\n');
138
138
  // 语义级豁免:纯 regex 规则看不到的上下文在此兜底——
@@ -145,7 +145,7 @@ export function auditFile({ file, relPath, text, grouped }, opts = {}) {
145
145
  // 规则定义文件:规则驱动命中(secret/regex/path-regex/func-lines 等 yml 规则)全豁免
146
146
  if (isRuleDefFile && f.rule !== 'quality/empty-catch' && f.rule !== 'robustness/io-risk') return false;
147
147
  // 技能/规则文档豁免:skills/ 下的 skill 文档与 rules/ 文档里的
148
- // 沟通措辞是「触发场景/规则描述」设计文本(如 whenToUse 触发场景描述),非代码残留——comment 规则不拦;
148
+ // 文档用语是「触发场景/规则描述」设计文本(如 whenToUse 触发场景描述),非代码残留——comment 规则不拦;
149
149
  // version 规则同理:版本规则文档自身描述 0.x 例外(如 versioning-rule §二「内置模块从 0 开始」),
150
150
  // 文档里的版本号示例是规则文本而非违规版本标记
151
151
  const isSkillDoc = /(^|[/\\])skills([/\\]|$)/.test(String(relPath || file));
@@ -7,6 +7,7 @@ import { groupByKind, HINT_QUALITY, checkFolderRules, checkPrivateFiles, checkDu
7
7
  import { loadRuleFiles } from '../rule/loader.js';
8
8
  import { compileAllRules } from '../rule/registry.js';
9
9
  import { auditFile } from './audit-file.js';
10
+ import { grammarForExt, parseText, makeSyncConfirmer } from '../ast/treesitter.js';
10
11
  import { detectRepoJsYamlImport } from './file-context.js';
11
12
  import { decorateTestExemptHint, makeFinding, summarize } from './finding.js';
12
13
  import { pickRepoLevelAnchorFile, repoLevelSemanticRuleIds } from './repo-level.js';
@@ -105,6 +106,39 @@ function appendIgnoreBlindSpot(findings, repoPath, scanned) {
105
106
  * @param {Array<{path?:string, rel?:string, full:string, status?:string}>} files 待审计文件(path 优先,rel 兜底)
106
107
  * @param {object} opts { scope, compiled, slots, rulesetDir, disabledSlots, auditLevel, privateFiles, visibility, truncated }
107
108
  */
109
+ /**
110
+ * 为单个文件准备 tree-sitter 的**同步**确认函数(编排层是 async,检查器是同步)。
111
+ *
112
+ * 何时才解析(性能纪律,别把所有文件都解析 ✗):
113
+ * ① 该文件扩展名有可用语法(grammarForExt ✓)
114
+ * ② 该文件的规则集里**确实存在**声明 astConfirmSpan 的规则(否则解析纯属浪费 ✓)
115
+ * 任何失败(无语法 / 资产缺失 / 解析出错 / 超预算)都返回 null
116
+ * ⇒ 检查器自动回退 token 级判定(2.8.9 行为)✓ —— 回退是常态路径,不是异常路径 ✓
117
+ *
118
+ * @returns {Promise<null|((line:number, col:number)=>boolean|null)>}
119
+ */
120
+ async function buildTreeConfirmer(relPath, text, grouped) {
121
+ try {
122
+ // ⚠️ 取**扩展名**(不是整条路径)——grammarForExt 收的是扩展名 ✓
123
+ // 按 basename 的最后一个点取:避免 `docs/.vitepress/theme/index.ts` 这类**带点目录**踩坑 ✗
124
+ // (本项目 lib/checks/filter.js 已因同类写法修过一次 ✓)
125
+ const base = String(relPath || '').split(/[\\/]/).pop();
126
+ const ext = base.includes('.') ? base.slice(base.lastIndexOf('.') + 1) : '';
127
+ const grammar = grammarForExt(ext);
128
+ if (!grammar) return null;
129
+ let need = false;
130
+ for (const rules of Object.values(grouped || {})) {
131
+ if (!Array.isArray(rules)) continue;
132
+ if (rules.some((r) => r?.astConfirmSpan === true)) { need = true; break; }
133
+ }
134
+ if (!need) return null;
135
+ const tree = await parseText(text, grammar);
136
+ return tree ? makeSyncConfirmer(tree) : null;
137
+ } catch {
138
+ return null;
139
+ }
140
+ }
141
+
108
142
  async function auditFiles(repoPath, files, opts = {}) {
109
143
  // 归一化:full 收集项用 path,changed 用 rel → 统一取 path
110
144
  const normFiles = files.map((f) => ({ path: f.path ?? f.rel, full: f.full, status: f.status }));
@@ -182,9 +216,13 @@ async function auditFiles(repoPath, files, opts = {}) {
182
216
  const text = readText(f.full);
183
217
  fileTexts.push({ path: f.path, text });
184
218
  const skipRepoLevel = repoLevelRules.size > 0 && f.path !== repoLevelAnchor;
219
+ // tree-sitter 预解析(异步):有语法 + 本文件规则集确实要 astConfirmSpan 才解析;
220
+ // 拿不到语法树 ⇒ treeConfirm 为 null ⇒ 检查器回退 token 级判定 ✓
221
+ const treeConfirm = await buildTreeConfirmer(f.path, text, grouped);
185
222
  findings.push(...auditFile({ file: f.path, relPath: f.path, text, grouped }, {
186
223
  level: opts.auditLevel, repoHasJsYamlImport, repoPath,
187
224
  repoLevelRules: skipRepoLevel ? repoLevelRules : null,
225
+ treeConfirm,
188
226
  }));
189
227
  }
190
228
  // 跨文件重复代码检测(maintainability/no-duplicate-code,该抽公共函数)。
@@ -427,8 +427,8 @@ rules:
427
427
  name: "真实邮箱入库(隐私泄漏)"
428
428
  category: "security"
429
429
  severity: "error"
430
- description: "疑似真实个人邮箱硬编码/入库(隐私信息),请确认——示例域(example.com)、GitHub 匿名邮箱(users.noreply.github.com)、SSH 地址(git@github.com / git@ssh.github.com)、GitHub token 前缀用户名(ghp_/gho_/ghu_/ghs_/ghr_/github_pat_ 开头的用户名 + github.com 域;token 本体由 secret-github-pat 规则拦截)、本地虚拟域(.local/.lan/.internal/.test)豁免;真实邮箱(如 QQ 号@qq.com 等)一旦进公开仓库可被爬取,招致营销骚扰/社工"
431
- pattern: "\\b(?!git@(?:ssh\\.)?github\\.com\\b|(?:gh[opsur]_|github_pat_)[A-Za-z0-9_]+@github\\.com\\b)[A-Za-z0-9._%+-]+@(?!example\\.com\\b|users\\.noreply\\.github\\.com\\b|[A-Za-z0-9-]+\\.(?:local|lan|internal|test|invalid|localhost)\\b)[A-Za-z0-9-]+\\.[A-Za-z]{2,}\\b"
430
+ description: "疑似真实个人邮箱硬编码/入库(隐私信息),请确认——示例域(example.com)、GitHub 匿名邮箱(users.noreply.github.com)、SSH 地址(git@github.com / git@ssh.github.com)、GitHub token 前缀用户名(ghp_/gho_/ghu_/ghs_/ghr_/github_pat_ 开头的用户名 + github.com 域;token 本体由 secret-github-pat 规则拦截)、本地虚拟域(.local/.lan/.internal/.test)豁免;真实邮箱(如 QQ 号@qq.com 等)一旦进公开仓库可被爬取,招致营销骚扰/社工;确需提交(公开联系方式/测试夹具/版权声明等)时可临时关闭审计再推送(插件设置 →「提交前审计」auditEnabled=false)"
431
+ pattern: "\\b(?!git@(?:ssh\\.)?github\\.com\\b|(?:gh[opsur]_|github_pat_)[A-Za-z0-9_]+@github\\.com\\b)[A-Za-z0-9._%+-]+@(?!example\\.com\\b|users\\.noreply\\.github\\.com\\b|[A-Za-z0-9-]+\\.(?:local|lan|internal|test|invalid|localhost)\\b|[A-Za-z0-9-]+\\.(?:png|jpe?g|gif|webp|svg|avif|ico|bmp|js|mjs|cjs|ts|tsx|jsx|css|scss|less|html?|json|ya?ml|md|markdown|txt|zip|gz|tgz|mp[34]|webm|pdf|woff2?|ttf|eot)\\b)[A-Za-z0-9-]+\\.[A-Za-z]{2,}\\b"
432
432
  fixable: false
433
433
  mitigation: "真实邮箱不写进代码/文档;示例一律用 your-name@example.com 占位;GitHub 匿名邮箱 users.noreply.github.com 豁免(git 提交默认 author);已入库的用 git filter 清历史"
434
434
  - id: credfile-common
@@ -44,7 +44,7 @@ rules:
44
44
  name: "路径穿越防护"
45
45
  category: "security"
46
46
  severity: "error"
47
- description: "直接使用用户输入作为文件路径存在目录遍历风险"
47
+ description: "人工核查提示:请核对本仓库是否存在「用户输入直接拼进文件路径」的目录遍历风险(本规则是**人工核查占位**,不指向具体行;命中行号仅作锚点)"
48
48
  fixable: false
49
49
  mitigation: "使用 path.resolve + startsWith 白名单校验"
50
50
 
@@ -11,6 +11,14 @@ metadata:
11
11
  rules:
12
12
  # ── 内存爆炸检测(文档 §13 示例规则落地:子模式 + per-pattern message)──
13
13
  - id: performance/memory-bomb
14
+ # astConfirm: 正则只做初筛,命中行必须再经 token 级确认「真在代码里」——
15
+ # 已消除**注释行**里的示例文本误报(如讲解「while(true) 占死线程」的注释 ✗)。
16
+ # 已知边界(2026-10-15 已修):匹配落在**字符串字面量内**时也曾误报 ——
17
+ # astConfirmSpan(**按规则 opt-in**)在行级确认之上再做**列级**确认:
18
+ # 命中位置落在字符串/模板串/注释区间内 ⇒ 不算真实代码。本规则开启它 ✓
19
+ # ⚠️ 不可无条件对所有 astConfirm 规则开启:硬编码路径/凭据等规则的命中**本来就该在字符串里**。
20
+ astConfirm: true
21
+ astConfirmSpan: true
14
22
  name: "检测可能导致内存爆炸的代码"
15
23
  category: "performance"
16
24
  severity: "warning"
@@ -135,6 +143,10 @@ rules:
135
143
 
136
144
  # ── 无界循环 / 高 CPU 轮询(性能补充)──
137
145
  - id: performance/busy-wait-loop
146
+ # 同上:注释里的 while(true) 已不再误报 ✓;
147
+ # 并开启 astConfirmSpan ⇒ 字符串字面量里的 'while (true) {}'(测试用)也不再误报 ✓
148
+ astConfirm: true
149
+ astConfirmSpan: true
138
150
  name: "忙等待循环(高 CPU 空转)"
139
151
  category: "performance"
140
152
  severity: "warning"
@@ -63,9 +63,9 @@ export function runChecks({ file, relPath, text, grouped }, opts = {}) {
63
63
  // 三层审计 L1——file_patterns 文件内容级初筛(未命中 = 非候选,剔除进 L2)
64
64
  grouped = filterRulesByFileText(grouped, text);
65
65
  let findings = [];
66
- if (grouped['[FUNC]']) findings = findings.concat(checkRegexRules({ file, text, rules: grouped['[FUNC]'], repoPath: opts?.repoPath }));
67
- if (grouped['credential-ref']) findings = findings.concat(checkRegexRules({ file, text, rules: grouped['credential-ref'], repoPath: opts?.repoPath }));
68
- if (grouped['regex']) findings = findings.concat(checkRegexRules({ file, text, rules: grouped['regex'], repoPath: opts?.repoPath }));
66
+ if (grouped['[FUNC]']) findings = findings.concat(checkRegexRules({ file, text, rules: grouped['[FUNC]'], repoPath: opts?.repoPath, treeConfirm: opts?.treeConfirm }));
67
+ if (grouped['credential-ref']) findings = findings.concat(checkRegexRules({ file, text, rules: grouped['credential-ref'], repoPath: opts?.repoPath, treeConfirm: opts?.treeConfirm }));
68
+ if (grouped['regex']) findings = findings.concat(checkRegexRules({ file, text, rules: grouped['regex'], repoPath: opts?.repoPath, treeConfirm: opts?.treeConfirm }));
69
69
  if (grouped['path-regex']) findings = findings.concat(checkPathRegexRules({ file, relPath, rules: grouped['path-regex'] }));
70
70
  if (!quick && grouped['func-lines']) findings = findings.concat(checkFuncLines({ file, text, rules: grouped['func-lines'] }));
71
71
  // 此前 9 个 kind 编译后无人消费(死桶)
@@ -30,7 +30,13 @@
30
30
  * @returns {object} 过滤后的 grouped(规则数组已按 exts 裁剪)
31
31
  */
32
32
  export function filterRulesByExt(grouped, relPath) {
33
- const ext = String(relPath || '').split('.').pop().toLowerCase();
33
+ // 取扩展名必须**先取 basename 再取最后一个点之后**:
34
+ // 旧实现 String(relPath).split('.').pop() 对含点目录的路径会取错 ✗ ——
35
+ // 例:docs/.vitepress/theme/index.ts ⇒ 得到 "vitepress/theme/index"(不是 ts)
36
+ // ⇒ 该文件所有声明了 exts 的规则**全部匹配不上**(审计实测:.vitepress 下文件只拿到通用规则)。
37
+ // 另:无扩展名文件(Makefile 等)返回空串,声明 exts 的规则自然不匹配(正确语义)。
38
+ const base = String(relPath || '').replace(/\\/g, '/').split('/').pop() || '';
39
+ const ext = base.includes('.') ? base.split('.').pop().toLowerCase() : '';
34
40
  const out = {};
35
41
  for (const [kind, rules] of Object.entries(grouped || {})) {
36
42
  if (!Array.isArray(rules)) { out[kind] = rules; continue; }
@@ -6,7 +6,7 @@
6
6
  * 避免「正则命中即报」造成误报。
7
7
  */
8
8
 
9
- import { makeCodeLineFilter, checkMagicNumberSmartAst } from '../ast/index.js';
9
+ import { makeCodeSpanFilter, checkMagicNumberSmartAst } from '../ast/index.js';
10
10
  import { RISK_BADGE, RISK_LABEL } from '../ast/io-risk.js';
11
11
  // 硬编码绝对路径精筛(paths 槽位 / astConfirmKind: "hardcoded-abs-path")——引擎侧唯一实现:
12
12
  // fs 可访问性判断 + 相对路径换算(正则做不到的两件事)。脚本调用本实现,不自带第二份 PATTERNS。
@@ -51,7 +51,7 @@ import { credentialValueLines, placeholderCredentialLines, shortFuncNameLines, s
51
51
 
52
52
  /** 检查文本是否符合 regex 型规则(regex / secret / credential-ref)。
53
53
  * @param {object} args { file, text, rules, source? , repoPath? } repoPath:仓库根(写目标命中 .gitignore 的精筛需要) */
54
- export function checkRegexRules({ file, text, rules, source = '新增行', repoPath = '' }) {
54
+ export function checkRegexRules({ file, text, rules, source = '新增行', repoPath = '', treeConfirm = null }) {
55
55
  const findings = [];
56
56
  const lines = text.split('\n');
57
57
  for (const rule of rules || []) {
@@ -78,7 +78,7 @@ export function checkRegexRules({ file, text, rules, source = '新增行', repoP
78
78
  if (patterns.some((p) => { p.lastIndex = 0; return p.test(line); })) candidates.push(i + 1);
79
79
  }
80
80
  }
81
- const codeFilter = rule.astConfirm ? makeCodeLineFilter(text, candidates, { file }) : null;
81
+ const codeFilter = rule.astConfirm ? makeCodeSpanFilter(text, candidates, { file }) : null;
82
82
  // readability/magic-number(唯一声明 astConfirm: magic-number 的规则)已合并进
83
83
  // magic-number-smart;本分支保留机制(自定义规则包可复用),当前无内置规则消费。
84
84
  const magicSmartLines = rule.astConfirm === 'magic-number' ? smartHitLines(text) : null;
@@ -137,7 +137,22 @@ export function checkRegexRules({ file, text, rules, source = '新增行', repoP
137
137
  if (hasKindAllow && !kindFilter.lines.has(i + 1)) continue; // 仅白名单行可报(token 级精筛)
138
138
  for (let j = 0; j < patterns.length; j++) {
139
139
  const p = patterns[j];
140
- if (line && p.test(line)) {
140
+ p.lastIndex = 0;
141
+ const m = line ? p.exec(line) : null;
142
+ if (m) {
143
+ // 列级/语法级精筛(**按规则 opt-in**:rule.astConfirmSpan === true)。
144
+ // ① 优先**语法树**:编排层已(异步)预解析本文件并传入同步确认函数 treeConfirm ✓
145
+ // —— verdict === false ⇒ 命中处是不透明构造(字符串/注释/模板)⇒ 丢弃;
146
+ // verdict === true ⇒ 真代码 ⇒ 放行(不再看 ②);
147
+ // verdict === null ⇒ 无法判定(无语法/解析失败)⇒ 回退 ②
148
+ // ② 回退 **token 级列级判定**(2.8.9 实现):命中列落在字符串/注释区间内 ⇒ 丢弃
149
+ // 为什么必须 opt-in、且绝不覆盖 kindFilter(allow):硬编码路径/凭据类规则的命中
150
+ // 本来就写在字符串里(实测:无条件开启会让 paths/hardcoded-absolute-path 从 5 条掉到 0 条 ✗)
151
+ if (rule.astConfirmSpan === true && !hasKindAllow) {
152
+ const verdict = typeof treeConfirm === 'function' ? treeConfirm(i + 1, m.index + 1) : null;
153
+ if (verdict === false) continue;
154
+ if (verdict !== true && codeFilter?.isCodeHit && !codeFilter.isCodeHit(i + 1, m.index + 1)) continue;
155
+ }
141
156
  // I/O 风险:message 用 AST 的分级详情(四级徽标 + 上下文 + 理由),
142
157
  // 否则只剩 yml 的 description,看不出这条是高还是低(正则路径特性)
143
158
  const ioHit = rule.astConfirmKind === 'io-risk' ? kindFilter?.detail?.get(i + 1) : null;
@@ -34,9 +34,13 @@ export async function runAudit({ repoPath = '', audit, rulesetDir, slots, cfg: e
34
34
  const cfg = extCfg || defaultConfig();
35
35
  const doAudit = audit ?? cfg.auditEnabled;
36
36
  if (!doAudit) return { ok: true, audit: null };
37
- const slotOrder = Array.isArray(slots) && slots.length ? slots
38
- : Array.isArray(cfg.auditRuleOrder) && cfg.auditRuleOrder.length ? cfg.auditRuleOrder
39
- : undefined;
37
+ // ⚠️ auditRuleOrder 的语义是「槽位**加载顺序**」(见 schema 描述),**不是白名单** ✗。
38
+ // 历史缺陷:这里把它当 slots 传下去,而 loadRuleFiles 把 slots 当「只加载列出的包」用,
39
+ // 于是清单外的规则包(python/cpp/go/java/php/rust/swift/template…)被**静默丢弃** ✗——
40
+ // 实测:一个 105 个 .py 的项目上 7 条 python/* 规则零命中、连 python 槽位都不存在;
41
+ // 把该字段置空后同一项目 60 条 → 197 条、python/* 命中 0 → 5 ✓。
42
+ // 现在只保留显式传入的 slots(API/工具级白名单);配置里的顺序不再当白名单(禁用请用 auditDisabledSlots ✓)。
43
+ const slotOrder = Array.isArray(slots) && slots.length ? slots : undefined;
40
44
  const auditRes = await auditWithScope(repoPath || '.', {
41
45
  scope: cfg.auditScanScope || 'diff',
42
46
  maxScanFiles: cfg.maxScanFiles,
@@ -62,7 +66,7 @@ export async function runAudit({ repoPath = '', audit, rulesetDir, slots, cfg: e
62
66
  // 修复背景:私有库被拦的回归——
63
67
  // 此前拦截判定只看「示例目录」、没有可见性分级,
64
68
  // comment / docs / security 等槽位规则不受 private 槽位(凭据 glob)约束,私有留痕仓库被拦。
65
- // 承诺原文:「私密文件与工作留痕(会话记录/凭据/留痕)在私有仓库可正常提交推送,
69
+ // 承诺原文:「私密文件与工作留痕(留痕记录/凭据/笔记)在私有仓库可正常提交推送,
66
70
  // 不需要额外豁免标记」。此前拦截判定只看「示例目录」、没有任何可见性分级,而
67
71
  // conv-*/docs/security 等槽位规则不受 private 槽位(凭据 glob)的可见性分级约束 →
68
72
  // 私有留痕仓库被上百条 conv-* blocker 拦下(实测回归:ai-work-archive 192 条)。
@@ -0,0 +1,100 @@
1
+ /**
2
+ * 核心层 · AI 自设工作区路径(数组,多个)
3
+ *
4
+ * 背景:环境注入里的「当前工作目录 cwd」原先取自**会话文件**(agent.session.header.cwd)。
5
+ * 实测问题:会话 header 里存的可能是**陈旧路径**(本机实测注入出 `…/0.1.6-alpha.1/工作区/dsh-git-push`,
6
+ * 而真实工作区在 `…/VirtualDSM/DeepSeekHarness/工作区/dsh-git-push`)⇒ 注入反而误导 ✗。
7
+ *
8
+ * 设计:让 **AI 自己**登记真实工作区路径(可多个),注入时优先显示这份自设清单
9
+ * ⇒ AI 每轮看到的都是自己设的那份(这就是「自己提醒自己」的实际作用,不需要额外机制)。
10
+ *
11
+ * 存放:<配置目录>/workspace-paths.json(结构化列表用 JSON 承载,不走 env;配置目录见 credentialsDir())
12
+ * { "paths": ["<绝对路径>", …], "updatedAt": "ISO", "updatedBy": "ai" | "user" }
13
+ *
14
+ * 校验口径(宁缺毋滥,避免把错路径写进去再误导自己):
15
+ * · 只收**绝对路径**(相对路径没有稳定基准 ✗)
16
+ * · 必须**存在且是目录**
17
+ * · 去重(同一路径只留一次)+ 上限 20 条
18
+ * · 写入原子化(先写临时文件再 rename),坏 JSON 读取时降级为空清单
19
+ */
20
+ import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
21
+ import { dirname, isAbsolute, join, resolve } from 'node:path';
22
+ import { credentialsDir } from './credentials.js';
23
+
24
+ /** 自设路径上限(注入要短,太多会挤占上下文)。 */
25
+ export const MAX_WORKSPACE_PATHS = 20;
26
+
27
+ /** 自设路径状态文件路径。 */
28
+ export function workspacePathsFile() {
29
+ return join(credentialsDir(), 'workspace-paths.json');
30
+ }
31
+
32
+ /**
33
+ * 读自设工作区路径。
34
+ * @returns {{paths: string[], updatedAt: string, updatedBy: string}} 读不到/坏 JSON ⇒ 空清单(不抛错)
35
+ */
36
+ export function loadWorkspacePaths() {
37
+ const empty = { paths: [], updatedAt: '', updatedBy: '' };
38
+ try {
39
+ const f = workspacePathsFile();
40
+ if (!existsSync(f)) return empty;
41
+ const j = JSON.parse(readFileSync(f, 'utf8'));
42
+ const paths = Array.isArray(j?.paths) ? j.paths.map((x) => String(x || '').trim()).filter(Boolean) : [];
43
+ return { paths, updatedAt: String(j?.updatedAt || ''), updatedBy: String(j?.updatedBy || '') };
44
+ } catch {
45
+ return empty;
46
+ }
47
+ }
48
+
49
+ /**
50
+ * 写自设工作区路径(带校验)。
51
+ * @param {string[]} paths 待写入的路径数组(绝对路径)
52
+ * @param {{by?: string}} [opts] by: 写入方标识('ai' / 'user'),默认 'ai'
53
+ * @returns {{ok: boolean, paths: string[], rejected: Array<{path: string, reason: string}>, file: string}}
54
+ */
55
+ export function saveWorkspacePaths(paths, { by = 'ai' } = {}) {
56
+ const rejected = [];
57
+ const kept = [];
58
+ for (const raw of Array.isArray(paths) ? paths : []) {
59
+ const p = String(raw || '').trim();
60
+ if (!p) continue;
61
+ if (!isAbsolute(p)) { rejected.push({ path: p, reason: '不是绝对路径' }); continue; }
62
+ const abs = resolve(p);
63
+ let ok = false;
64
+ try { ok = statSync(abs).isDirectory(); } catch { ok = false; }
65
+ if (!ok) { rejected.push({ path: p, reason: '不存在或不是目录' }); continue; }
66
+ if (!kept.includes(abs)) kept.push(abs);
67
+ }
68
+ const over = kept.splice(MAX_WORKSPACE_PATHS);
69
+ for (const p of over) rejected.push({ path: p, reason: `超过上限 ${MAX_WORKSPACE_PATHS} 条` });
70
+
71
+ const file = workspacePathsFile();
72
+ try {
73
+ mkdirSync(dirname(file), { recursive: true });
74
+ const tmp = `${file}.tmp-${process.pid}`;
75
+ writeFileSync(tmp, JSON.stringify({ paths: kept, updatedAt: new Date().toISOString(), updatedBy: String(by || 'ai') }, null, 2) + '\n', 'utf8');
76
+ renameSync(tmp, file); // 原子替换:避免读到半截 JSON
77
+ } catch (e) {
78
+ return { ok: false, paths: kept, rejected: [...rejected, { path: file, reason: `写入失败:${e?.message || e}` }], file };
79
+ }
80
+ return { ok: true, paths: kept, rejected, file };
81
+ }
82
+
83
+ /**
84
+ * 生成注入用的「AI 自设工作区」文本块(无自设时返回 '')。
85
+ *
86
+ * 措辞要点:① 明确这是 **AI 自己登记的**(不是宿主探测 ⇒ 不准确就是自己写错了)
87
+ * ② 给出修改入口(同一个 API),让下一轮的自己知道怎么改 ✓
88
+ * @param {string} [sep] 行分隔符(默认换行)
89
+ * @returns {string} 多行文本;无自设 ⇒ ''
90
+ */
91
+ export function workspacePathsInjectionText(sep = '\n') {
92
+ const { paths, updatedAt, updatedBy } = loadWorkspacePaths();
93
+ if (!paths.length) return '';
94
+ const L = [`【AI 自设工作区(${paths.length} 个 · 由 ${updatedBy || 'ai'} 于 ${String(updatedAt).slice(0, 16) || '未知时间'} 登记)】`];
95
+ paths.forEach((p, i) => L.push(`- ${i + 1}. ${p}`));
96
+ L.push('(这是**你自己**登记的清单,优先级高于会话 cwd;要增删改用 API:'
97
+ + "git_api({path:'workspace-paths', method:'POST', body:'{\"paths\":[\"<绝对路径>\", …]}'})"
98
+ + ',GET 同路径可读回当前值)');
99
+ return L.join(sep);
100
+ }
package/lib/git/push.js CHANGED
@@ -54,13 +54,19 @@ import { resolveRepoVisibility } from './visibility.js';
54
54
  * customIgnorePatterns:逗号/换行分隔的 gitignore pattern,追加进 .gitignore(幂等)
55
55
  * @returns {{ok, steps: string[], commitSha?, pushed?, push?, remoteHeads?, error?}}
56
56
  */
57
- export async function commitAndPush({ repoPath = '', message = '', push = true, dryRun = false, token = '', customIgnorePatterns = '', requirementsConfirmed = false, force = false, pushMethod = 'ssh', pushGate = false, pushConfirmed = false, paths = '' } = {}) {
57
+ export async function commitAndPush({ repoPath = '', message = '', messageItems = null, push = true, dryRun = false, token = '', customIgnorePatterns = '', requirementsConfirmed = false, force = false, pushMethod = 'ssh', pushGate = false, pushConfirmed = false, paths = '' } = {}) {
58
58
  const steps = [];
59
59
  if (!repoPath || !existsSync(join(repoPath, '.git'))) return { ok: false, steps: ['预检'], error: `非 git 仓库: ${repoPath || '(空)'}` };
60
60
  // message 支持三种形态(字符串 / 数组 / {subject,items}):在预检处**单点**组装成规范提交信息,
61
61
  // 后续流程(add / commit -m / 回执)只用 built.message —— 避免多处各自解析导致行为分叉。
62
62
  // 字符串形态原样透传(既有调用方行为不变);数组/对象形态由 lib/git/commit-message.js 组装。
63
- const built = buildCommitMessage(message);
63
+ // message(字符串)与 messageItems(数组)合并:字符串作**标题**、数组作要点与正文 ✓
64
+ // 为什么数组不走 message 本身:宿主在进插件前按工具 schema 校验参数,而它只认标量类型
65
+ // (anyOf / 类型数组都被读成 string ✗)⇒ 非字符串根本到不了插件 ✓(见 command-registry 注释)
66
+ const msgInput = Array.isArray(messageItems) && messageItems.length
67
+ ? { subject: String(message || '').trim(), items: messageItems }
68
+ : message;
69
+ const built = buildCommitMessage(msgInput);
64
70
  if (!built.ok) return { ok: false, steps: ['预检'], error: built.error };
65
71
  const commitMessage = built.message;
66
72
  // D13 开发者要求门禁(commitPushPreflight 语义):要求清单存在且未核对 → 拦截。
@@ -121,7 +127,7 @@ export async function commitAndPush({ repoPath = '', message = '', push = true,
121
127
  const gi = privateExempt
122
128
  ? { added: 0, files: (await scanSensitiveFiles(repoPath)).map((h) => h.path), baseline: 0, custom: 0, tracked: [], unstaged: [], skipped: 'private-repo-exempt' }
123
129
  : await ensureGitignore(repoPath, { customIgnorePatterns });
124
- // 敏感文件只报告不动作(用户指令:扫描到不改动 git 忽略,由仓库方自行处理)
130
+ // 敏感文件只报告不动作(既定行为:扫描到不改动 git 忽略,由仓库方自行处理)
125
131
  if (gi.files.length) steps.push(`sensitive-scan(${gi.files.length}文件, 只报告)`);
126
132
  else if (gi?.added > 0) steps.push(`.gitignore(+${gi.added}条)`);
127
133
  if (privateExempt) steps.push(`private-exempt(${visReason})`);
@@ -72,7 +72,9 @@ export function packDryRun({ dir, registry = DEFAULT_REGISTRY, workspaceRoot = '
72
72
  const merged = { ...process.env };
73
73
  const rc = writeNpmrc({ workspaceRoot, registry, token });
74
74
  if (!rc.ok) return { ok: false, error: rc.error || 'npmrc 写入失败' };
75
- const r = runNpm(['pack', '--dry-run', '--json', ...npmArgs({ npmrcFile: rc.file, registry })], { timeoutMs, env: merged });
75
+ // cwd 必须显式给:npm pack 以「工作目录」为目标包,继承宿主 cwd 会去错目录
76
+ // (实测:宿主 cwd 无 package.json ⇒ ENOENT;有 ⇒ 打包整棵树 ⇒ ENOBUFS)
77
+ const r = runNpm(['pack', '--dry-run', '--json', ...npmArgs({ npmrcFile: rc.file, registry })], { timeoutMs, env: merged, cwd: dir });
76
78
  if (!r.ok) return { ok: false, error: r.error || 'npm pack --dry-run 失败', stdout: r.stdout };
77
79
  let info = null;
78
80
  try {
@@ -142,7 +144,9 @@ export async function publishPackage({
142
144
  if (otp) args.push('--otp', String(otp));
143
145
 
144
146
  const logPath = appendPublishLog(`publish START dryRun=${dryRun} ${info.name}@${info.version} tag=${tg} files=${pack.files.length}`, { workspaceRoot });
145
- const r = runNpm(args, { timeoutMs, env: { NO_UPDATE_NOTIFIER: '1' } });
147
+ // 同 pack:npm publish 也以「工作目录」为目标包,必须显式指向 info.dir,
148
+ // 否则会去发布宿主 cwd 下的包(或不存在的包)—— 这是发包类操作里最危险的一种错。
149
+ const r = runNpm(args, { timeoutMs, env: { NO_UPDATE_NOTIFIER: '1' }, cwd: info.dir });
146
150
  appendPublishLog(`publish END dryRun=${dryRun} ok=${r.ok} code=${r.code} err=${String(r.error || '').slice(0, 200)}`, { workspaceRoot });
147
151
  return {
148
152
  ok: !!r.ok,