dsh-git-push 3.0.0 → 3.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.
Files changed (65) hide show
  1. package/README.md +76 -48
  2. package/cli.mjs +4 -3
  3. package/lib/app/apply.js +11 -9
  4. package/lib/app/command-registry.js +4 -2
  5. package/lib/app/handlers/http-constants.js +8 -0
  6. package/lib/app/handlers/preprocess.js +3 -6
  7. package/lib/app/handlers/repo-actions.js +0 -1
  8. package/lib/app/handlers/repos.js +137 -10
  9. package/lib/app/handlers/settings.js +34 -15
  10. package/lib/app/index.js +1 -1
  11. package/lib/app/inject-text.js +3 -18
  12. package/lib/app/schema.js +20 -10
  13. package/lib/app/settings-bridge.js +60 -8
  14. package/lib/app/tool-call.js +26 -22
  15. package/lib/cli/commands-vcs.mjs +35 -1
  16. package/lib/cli/shared.mjs +1 -1
  17. package/lib/client/index.js +11 -16
  18. package/lib/client-parts/git/account.js +21 -12
  19. package/lib/client-parts/git/actions.js +23 -77
  20. package/lib/client-parts/git/apply.js +8 -2
  21. package/lib/client-parts/git/browser.js +1 -1
  22. package/lib/client-parts/git/const.js +33 -1
  23. package/lib/client-parts/git/controller.js +175 -176
  24. package/lib/client-parts/git/icons.js +1 -1
  25. package/lib/client-parts/git/loader.js +1 -1
  26. package/lib/client-parts/git/npm.js +56 -37
  27. package/lib/client-parts/git/page.js +53 -1
  28. package/lib/client-parts/git/repo.js +8 -1
  29. package/lib/client-parts/git/settings.js +13 -1
  30. package/lib/client-parts/git/state.js +237 -0
  31. package/lib/client-parts/git/utils.js +1 -1
  32. package/lib/client.js +631 -312
  33. package/lib/commit-push/pre-commit-engine.js +584 -32
  34. package/lib/commit-push.js +63 -47
  35. package/lib/context/index.js +7 -5
  36. package/lib/core/config.js +1 -27
  37. package/lib/core/exec.js +2 -11
  38. package/lib/git/identity-rewrite.js +1 -1
  39. package/lib/git/index.js +1 -1
  40. package/lib/git/push.js +2 -17
  41. package/lib/git/repo-index.js +8 -3
  42. package/lib/npm/install.js +1 -1
  43. package/lib/npm/registry.js +2 -2
  44. package/lib/plugin/auto-push.js +3 -6
  45. package/lib/preprocess/providers.js +5 -1
  46. package/lib/self/index.js +1 -1
  47. package/package.json +4 -7
  48. package/skills/dev/dsh-git-push.md +9 -9
  49. package/skills/guide/guide-commit-push.md +11 -13
  50. package/skills/workflow/README.md +0 -1
  51. package/skills/workflow/task-completion-report.md +2 -2
  52. package/.auditignore +0 -30
  53. package/.gitignore +0 -43
  54. package/lib/BUGFIX-NOTES-2026-09-14.md +0 -278
  55. package/lib/app/schema-preprocess.js +0 -42
  56. package/lib/user-requirements.json +0 -15
  57. package/scripts/build-client.mjs +0 -133
  58. package/scripts/bump-version.mjs +0 -178
  59. package/scripts/check.mjs +0 -205
  60. package/scripts/doc-func.mjs +0 -212
  61. package/scripts/doc-tree.mjs +0 -458
  62. package/scripts/doc-version.mjs +0 -149
  63. package/scripts/local-registry.mjs +0 -38
  64. package/scripts/scan-version.mjs +0 -125
  65. package/scripts/version-source.mjs +0 -173
@@ -1,5 +1,5 @@
1
1
  /**
2
- * dsh-git-push — 审计提交总入口(commitWithAudit)
2
+ * dsh-git-push — 提交总入口(提交前预处理门禁 + commit + push)
3
3
  * dsh-skip-i18n: 插件为中文零依赖,用户可见文案硬编码为产品设计
4
4
  *
5
5
  * git_commit_push 工具的核心逻辑抽成独立函数:
@@ -18,11 +18,14 @@ import * as auditClient from './app/preprocess-client.js';
18
18
  // 换引擎(含换语言重写)只改配置,git 侧零改动。
19
19
  // ⚠️ 文档漂移检查器的接线也随之搬进引擎入口(审计包 CLI 里 import 一次);
20
20
  // 宿主自己的工具/HTTP 侧仍由 lib/app/tool-call.js 接线,不依赖本文件。
21
- import { runPreCommitEngine } from './commit-push/pre-commit-engine.js';
21
+ import { runPreCommitPipeline, resolvePreCommitEnabled } from './commit-push/pre-commit-engine.js';
22
22
  import { commitAndPush } from './git/index.js';
23
23
  import { defaultConfig } from './client/index.js';
24
24
  import { resolveRepoVisibility } from './git/index.js';
25
25
 
26
+ /** 拦截清单里单条 message 的截断长度(字符):回执要短,完整内容仍在 audit.findings 里。 */
27
+ const BLOCKED_MESSAGE_PREVIEW_CHARS = 80;
28
+
26
29
 
27
30
  /**
28
31
  * 预处理渲染的**兜底文案**(刻意留在 git 侧)。
@@ -52,57 +55,51 @@ export function defaultPreprocessRender(ctx = {}) {
52
55
  }
53
56
 
54
57
  /**
55
- * 同步执行审计门禁(不跑 git)。供 git_commit_push 后台化方案复用:审计同步即时
58
+ * 同步执行提交前预处理门禁(不跑 git)。供 git_commit_push 后台化方案复用:门禁同步即时
56
59
  * 拦截,通过后再把 commit+push 丢后台。返回 { ok, blocked?, error?, audit }。
57
- * @param {object} p { repoPath, audit?, rulesetDir?, slots?, cfg?, visibility? }
60
+ * 命名说明:本函数是**预处理通用入口**(审计只是当前唯一的 provider),
61
+ * 返回里的 `audit` 字段是该 provider 的结果体,字段名沿用既有对外契约。
62
+ * @param {object} p { repoPath, audit?, rulesetDir?, cfg?, visibility?, auditExemptPaths?, auditExemptReason? }
58
63
  * (删除 auditLevel——审计固定完整流程,不留强度参数)
59
64
  * visibility:远端可见性(private|public|unknown)——private 时审计只报告不拦截
60
65
  * (README「④ 私有库豁免」);缺省按 origin 探测,探测失败按 unknown(保守拦截)。
61
66
  * 显式传入可免网络探测(测试/已知场景)。
62
67
  */
63
- export async function runAudit({
64
- repoPath = '', audit, rulesetDir, slots, cfg: extCfg, visibility: extVisibility,
68
+ export async function runPreprocess({
69
+ repoPath = '', audit, rulesetDir, cfg: extCfg, visibility: extVisibility,
65
70
  auditExemptPaths = [], auditExemptReason = '',
71
+ stages = null, // 本次调用的预处理链(覆盖配置)
66
72
  ...unknownKeys // 未知参数一律报错:
67
73
  }) { // 参数名与工具参数(auditExemptPaths 等)曾不一致,
68
74
  const unknown = Object.keys(unknownKeys); // 传错名过去是**静默无效且不报错**(实测踩到),
69
75
  if (unknown.length) { // 这个校验把它变成立刻可见的错误。
70
- throw new Error(`runAudit 收到未知参数:${unknown.join(', ')}(可用:repoPath/audit/rulesetDir/slots/cfg/visibility/auditExemptPaths/auditExemptReason)`);
76
+ throw new Error(`runPreprocess 收到未知参数:${unknown.join(', ')}(可用:repoPath/audit/rulesetDir/cfg/visibility/auditExemptPaths/auditExemptReason/stages)`);
71
77
  }
72
78
  const cfg = extCfg || defaultConfig();
73
- const doAudit = audit ?? cfg.auditEnabled;
74
- if (!doAudit) return { ok: true, audit: null };
75
- // ⚠️ auditRuleOrder 的语义是「槽位**加载顺序**」(见 schema 描述),**不是白名单** ✗。
76
- // 历史缺陷:这里把它当 slots 传下去,而 loadRuleFiles 把 slots 当「只加载列出的包」用,
77
- // 于是清单外的规则包(python/cpp/go/java/php/rust/swift/template…)被**静默丢弃** ✗——
78
- // 实测:一个 105 个 .py 的项目上 7 条 python/* 规则零命中、连 python 槽位都不存在;
79
- // 把该字段置空后同一项目 60 条 → 197 条、python/* 命中 0 → 5 ✓。
80
- // 现在只保留显式传入的 slots(API/工具级白名单);配置里的顺序不再当白名单(禁用请用 auditDisabledSlots ✓)。
81
- const slotOrder = Array.isArray(slots) && slots.length ? slots : undefined;
82
- // 修复:提交前审计同样消费侧边栏权重覆盖(cfg.weightOverrides,config.json 回读),
83
- // 与 code_audit 工具同源——此前传空权重,评分恒用默认权重表(侧边栏权重设置对提交审计无效)。
84
- // 权重在 git 侧解析(配置语义留在插件侧),再序列化传给引擎:引擎只做「解析 → 用」。
85
- let auditWeights = {};
86
- if (typeof cfg.weightOverrides === 'string' && cfg.weightOverrides.trim()) {
87
- try { auditWeights = JSON.parse(cfg.weightOverrides) || {}; } catch { /* 非法 JSON 回退默认 */ }
88
- }
79
+ // 跑不跑预处理是**宿主自己的门禁策略**(preCommit.enabled);旧版开关键由
80
+ // resolvePreCommitEnabled 一次性读回并标注来源,避免「本来开着的门禁悄悄关掉」。
81
+ const switchState = resolvePreCommitEnabled(cfg);
82
+ const doAudit = audit ?? switchState.enabled;
83
+ // 沿用旧配置键时把来源透出:否则「配置里写着开、实际按新键缺省关」这种偏差
84
+ // 只能靠用户自己发现。只在真的沿用了旧键时才带这个字段(正常路径返回值不变)。
85
+ const preprocessSwitchMeta = switchState.source === 'legacy'
86
+ ? { enabledFrom: 'legacy', note: '本次沿用旧版开关键的值;新键为 preCommit.enabled,迁移后旧键可删除' }
87
+ : null;
88
+ if (!doAudit) return { ok: true, audit: null, ...(preprocessSwitchMeta ? { preprocessSwitch: preprocessSwitchMeta } : {}) };
89
89
  // ── 解耦点:审计与评分不再在进程内跑,改为调配置化引擎子进程 ──
90
- // 传给引擎的东西只有「本来就在传的选项」:scope / maxScanFiles / rulesetDir /
91
- // slots / disabledSlots / weights。maxScanFiles 每次都必须传:它的默认值是 3000,
92
- // 而加载层把 0 当「不限」,漏传会让大仓门禁退化成全量扫描。
93
- const engineRes = await runPreCommitEngine({
90
+ // 这次调用只传「宿主才知道的调用上下文」:仓库路径 / 可见性 / 本次临时豁免。
91
+ // **不传审计自己的配置**(扫描范围 / 权重 / 规则槽位 / 文件数上限)——
92
+ // 那些已随分家搬进预处理实现自己的 config.json,由它读自己的配置当默认值。
93
+ // 宿主一旦还替它传,就等于两包仍在共享一份配置(耦合),只是换了个字段名而已。
94
+ const engineRes = await runPreCommitPipeline({
94
95
  repoPath: repoPath || '.',
95
- scope: cfg.auditScanScope || 'diff',
96
- rulesetDir: rulesetDir || '', // 自定规则目录已从设置移除,只认显式传参(工具 ruleset 参数)
97
- weights: auditWeights,
98
- maxScanFiles: cfg.maxScanFiles,
99
- slots: slotOrder,
100
- disabledSlots: Array.isArray(cfg.auditDisabledSlots) ? cfg.auditDisabledSlots : [],
96
+ rulesetDir: rulesetDir || '', // 调用方显式指定的规则目录(工具 ruleset 参数),不是配置
101
97
  // 可见性:显式传入时直接给引擎;未传则留空(引擎按 unknown 保守处理,gitpush 稍后按需探测)
102
98
  visibility: extVisibility,
103
99
  // 临时豁免:**参数名映射**(工具参数 auditExemptPaths → 审计包 --exempt-paths)
104
100
  exemptPaths: Array.isArray(auditExemptPaths) ? auditExemptPaths : [],
105
101
  exemptReason: auditExemptReason || '',
102
+ stages: Array.isArray(stages) && stages.length ? stages : null, // 调用参数 > 配置(见 resolveStages)
106
103
  cfg,
107
104
  });
108
105
  // 引擎不可用(崩/超时/退出码 2/输出不合契约)一律 fail-closed:拒绝提交并给出可诊断原因。
@@ -110,7 +107,24 @@ export async function runAudit({
110
107
  // 例外:预处理实现不在位(preprocessSkipped)——那是「扩展没插」,不是「引擎坏了」。
111
108
  // 按热插拔语义放行主流程,但必须把「本次未做预处理」透出给调用方(不静默)。
112
109
  // 字段名刻意用 preprocess* 而不是 audit*:预处理是通用机制,审计只是它的一个实现。
113
- if (!engineRes.ok) return { ok: false, blocked: false, error: engineRes.error, audit: null };
110
+ // 阶段链的 additive 回执(只有配了 preCommit.stages 才会有这两个字段;
111
+ // 单命令/单阶段模式不追加任何字段 ⇒ 与升级前逐字段一致)
112
+ const stageMeta = {
113
+ ...(Array.isArray(engineRes.preprocessStages) ? { preprocessStages: engineRes.preprocessStages } : {}),
114
+ ...(Array.isArray(engineRes.preprocessWarnings) && engineRes.preprocessWarnings.length
115
+ ? { preprocessWarnings: engineRes.preprocessWarnings } : {}),
116
+ };
117
+ if (!engineRes.ok) {
118
+ return {
119
+ ok: false,
120
+ blocked: false,
121
+ error: engineRes.error,
122
+ audit: null,
123
+ // 失败在被拦的那个阶段之前可能已经跑过几个阶段(例如 format 成功、audit 崩了):
124
+ // 把已跑阶段的回执带上,用户才知道"哪些阶段做过事"
125
+ ...(Object.keys(stageMeta).length ? { preprocessStages: stageMeta.preprocessStages || [], ...(stageMeta.preprocessWarnings ? { preprocessWarnings: stageMeta.preprocessWarnings } : {}) } : {}),
126
+ };
127
+ }
114
128
  if (engineRes.preprocessSkipped) {
115
129
  return {
116
130
  ok: true,
@@ -118,11 +132,14 @@ export async function runAudit({
118
132
  audit: null,
119
133
  preprocessSkipped: engineRes.preprocessSkipped,
120
134
  skipReason: engineRes.skipReason || '',
135
+ ...stageMeta,
121
136
  };
122
137
  }
123
138
  const engineAudit = engineRes.audit || {};
124
139
  const findings = Array.isArray(engineAudit.findings) ? engineAudit.findings : [];
125
140
  const auditOut = {
141
+ // 阶段链回执(additive):每个阶段跑了多久、成败、onFail 语义、跳过的原因
142
+ ...stageMeta,
126
143
  summary: engineAudit.summary,
127
144
  quality: engineAudit.quality,
128
145
  // 引擎溯源(新增字段,只增不改):出问题时能一眼看到「用的哪个引擎、退出码几」,
@@ -137,12 +154,12 @@ export async function runAudit({
137
154
  // 豁免四类(代码标记 / 测试夹具 / 示例目录 / 临时豁免)加私有库降级都在包内完成,
138
155
  // gitpush 这层不再重复实现一遍 —— 两份实现并存时最危险的是「某一天两边算得不一样」,
139
156
  // 而那时门禁到底拦不拦取决于走了哪条分支,几乎无法排查。
140
- // 拦截结论**只认审计包的**:宿主不再有第二套豁免/拦截实现(回滚路径已随旧引擎删除)
157
+ // 拦截结论**只认审计包的**:宿主不再有第二套豁免/拦截实现
141
158
  auditOut.blocked = Array.isArray(engineAudit.blocked) ? engineAudit.blocked : [];
142
159
  // 示例目录豁免条数(summary.blocker 与 blocked 的差值来源之一),原样透传供排查
143
160
  if (Number.isFinite(Number(engineAudit.sampleExemptCount))) auditOut.sampleExemptCount = Number(engineAudit.sampleExemptCount);
144
- // exempt 回显:新引擎(审计包)自己给;回滚路径(内置旧引擎)这里保底构造,
145
- // 语义与切包前一致(记录而非判断:豁免了哪些文件、命中哪些规则、共几条 finding)。
161
+ // exempt 回显:审计包自己给;它没给时这里按同一语义构造(记录而非判断:
162
+ // 豁免了哪些文件、命中哪些规则、共几条 finding),保证回显字段不因实现更换而消失。
146
163
  if (engineAudit.exempt) {
147
164
  auditOut.exempt = engineAudit.exempt;
148
165
  } else {
@@ -169,7 +186,7 @@ export async function runAudit({
169
186
  if (!Array.isArray(engineAudit.blocked) || engineAudit.blocked.length === 0) {
170
187
  // 私有库时包把 blocked 归零,但报告形态仍给原始清单(租户侧读取 audit.blocked 展示)
171
188
  auditOut.blocked = findings.filter((f) => f.severity === 'blocker' || f.severity === 'error')
172
- .map((f) => ({ file: f.file, line: f.line, rule: f.rule, message: String(f.message || '').slice(0, 80) }));
189
+ .map((f) => ({ file: f.file, line: f.line, rule: f.rule, message: String(f.message || '').slice(0, BLOCKED_MESSAGE_PREVIEW_CHARS) }));
173
190
  }
174
191
  }
175
192
  const blocked = auditOut.blocked;
@@ -236,7 +253,7 @@ export async function runAudit({
236
253
  * 带审计门禁的提交推送(git_commit_push 工具旧同步实现,仍保留供外部插件/批量复用)。
237
254
  * @param {object} p
238
255
  * { repoPath, message, push?, dryRun?, audit?, rulesetDir? }
239
- * audit 缺省取插件配置 auditEnabled;rulesetDir 只认显式传参(设置项已移除)。
256
+ * audit 缺省取预处理开关(preCommit.enabled);rulesetDir 只认显式传参。
240
257
  * @returns {Promise<object>} 审计放行 → commitAndPush 结果(含 audit 摘要);
241
258
  * blocker 命中 → { ok:false, blocked:true, audit },不执行 git 操作
242
259
  */
@@ -247,36 +264,35 @@ export async function commitWithAudit({
247
264
  dryRun = false,
248
265
  audit,
249
266
  rulesetDir,
250
- slots,
251
267
  customIgnorePatterns = '',
252
- requirementsConfirmed = false,
253
268
  force = false,
254
269
  pushMethod,
255
270
  pushGate = false,
256
271
  pushConfirmed = false,
257
272
  paths = '', // 精确 add 路径(逗号分隔,相对 repoPath);空 = git add -A
273
+ stages = null, // 本次调用的预处理链(覆盖配置里的 preCommit.stages)
258
274
  } = {}) {
259
275
  const cfg = defaultConfig();
260
- const a = await runAudit({ repoPath, audit, rulesetDir, slots });
261
- // blocked 用 runAudit 的真实结论(缺省仍按拦截处理,保持旧行为):
276
+ const a = await runPreprocess({ repoPath, audit, rulesetDir, stages });
277
+ // blocked 用 runPreprocess 的真实结论(缺省仍按拦截处理):
262
278
  // 审计判定拦截 = true;引擎不可用 = false(那是「没跑起来」,不是「审计不通过」,
263
279
  // 工具侧据此显示「未完成:<原因>」而不是「推送被拦截」)。
264
280
  if (!a.ok) return { ok: false, blocked: a.blocked ?? true, error: a.error, audit: a.audit };
265
281
  // 推送通道缺省取插件配置(默认 ssh:推本地 HEAD、远端 sha 与本地一致)
266
- const r = await commitAndPush({ repoPath, message, push, dryRun, customIgnorePatterns, requirementsConfirmed, force, pushMethod: pushMethod || cfg.pushMethod || 'ssh', pushGate, pushConfirmed, paths });
282
+ const r = await commitAndPush({ repoPath, message, push, dryRun, customIgnorePatterns, force, pushMethod: pushMethod || cfg.pushMethod || 'ssh', pushGate, pushConfirmed, paths });
267
283
  return { ok: r.ok !== false, ...r, audit: a.audit };
268
284
  }
269
285
 
270
286
  /**
271
287
  * 批量提交推送(D16 commitMany):对每个仓库依次 commitAndPush,返回逐仓结果数组。
272
288
  * 注意:仅做提交推送(不含审计门禁)——审计请用 commitWithAudit 逐仓调用。
273
- * @param {{repos: string[], message: string, push?: boolean, dryRun?: boolean, requirementsConfirmed?: boolean, customIgnorePatterns?: string}} opts
289
+ * @param {{repos: string[], message: string, push?: boolean, dryRun?: boolean, customIgnorePatterns?: string}} opts
274
290
  * @returns {Promise<Array<{repo: string, ...commitAndPush 结果}>>}
275
291
  */
276
- export async function commitMany({ repos = [], message = '', push = true, dryRun = false, requirementsConfirmed = false, customIgnorePatterns = '' } = {}) {
292
+ export async function commitMany({ repos = [], message = '', push = true, dryRun = false, customIgnorePatterns = '' } = {}) {
277
293
  const results = [];
278
294
  for (const repoPath of repos) {
279
- results.push({ repo: repoPath, ...(await commitAndPush({ repoPath, message, push, dryRun, customIgnorePatterns, requirementsConfirmed })) });
295
+ results.push({ repo: repoPath, ...(await commitAndPush({ repoPath, message, push, dryRun, customIgnorePatterns })) });
280
296
  }
281
297
  return results;
282
298
  }
@@ -22,12 +22,14 @@ const PROBE_TIMEOUT_MS = 8000; // 工具路径/版本探测子进程超时
22
22
  const VERSION_MAX_LEN = 120; // 版本串截断长度
23
23
 
24
24
  /** 默认工具清单(探测失败时的静态兜底;探测成功以实测路径为准)。 */
25
+ // 静态兜底清单(探测失败时用):只写**命令名**,不写任何安装位置 ——
26
+ // 写死的绝对路径换机即失效,且在 Windows/容器里根本不存在。
25
27
  export const DEFAULT_TOOLS = {
26
- git: '/usr/bin/git',
27
- node: '/usr/bin/node',
28
- npm: '/usr/bin/npm',
29
- python3: '/usr/bin/python3',
30
- curl: '/usr/bin/curl',
28
+ git: 'git',
29
+ node: 'node',
30
+ npm: 'npm',
31
+ python3: 'python3',
32
+ curl: 'curl',
31
33
  };
32
34
 
33
35
  /** 默认探测的工具清单(名称 → 版本参数;null 表示只查路径)。 */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Git 执行层 · 路径与配置
3
3
  *
4
- * 职责:插件根目录定位(PLUGIN_ROOT)与开发者要求清单读取(loadRequirements)。
4
+ * 职责:插件根目录定位(PLUGIN_ROOT)。
5
5
  */
6
6
 
7
7
  import { existsSync, readFileSync } from 'node:fs';
@@ -12,29 +12,3 @@ import { credentialsDir } from './credentials.js';
12
12
  /** 插件根(lib/git/index.js → lib → 插件根;requirements.json 内置清单定位用)。 */
13
13
  export const PLUGIN_ROOT = dirname(dirname(dirname(fileURLToPath(import.meta.url))));
14
14
 
15
- /**
16
- * 开发者特殊要求清单(D13):
17
- * 三来源依次尝试(首个有效即返回):
18
- * 1) credentialsDir()/requirements.json(用户外挂)
19
- * 2) PLUGIN_ROOT/lib/user-requirements.json(内置默认清单)
20
- * 3) PLUGIN_ROOT/user-requirements.json
21
- * 返回 { user, found, items, files };无清单时 found:false(门禁放行)。
22
- */
23
- export function loadRequirements() {
24
- const candidates = [
25
- join(credentialsDir(), 'requirements.json'),
26
- join(PLUGIN_ROOT, 'lib', 'user-requirements.json'),
27
- join(PLUGIN_ROOT, 'user-requirements.json'),
28
- ];
29
- for (const f of candidates) {
30
- try {
31
- if (!f || !existsSync(f)) continue;
32
- const parsed = JSON.parse(readFileSync(f, 'utf8'));
33
- const items = Array.isArray(parsed?.items) ? parsed.items.map((x) => String(x).trim()).filter(Boolean) : [];
34
- if (items.length) {
35
- return { user: String(parsed.user || '') || '默认开发者', found: true, items, files: [{ file: f, items }] };
36
- }
37
- } catch { /* 坏 JSON 换下一来源 */ }
38
- }
39
- return { user: '默认开发者', found: false, items: [], files: [] };
40
- }
package/lib/core/exec.js CHANGED
@@ -22,14 +22,6 @@ import { delimiter as pathDelimiter, join } from 'node:path';
22
22
  * 改为显式解析 + 明确的缺失提示,避免同类误诊。
23
23
  * 优先级:DSH_GIT_BIN 环境变量 → PATH 各目录 → 常见绝对路径。
24
24
  */
25
- const GIT_CANDIDATES = [
26
- // POSIX 常见位置
27
- '/var/packages/git/target/bin/git', '/usr/local/bin/git', '/usr/bin/git', '/bin/git',
28
- // Windows 常见安装位置(Git for Windows 的 cmd\ 目录;PATH 未配置时兜底)
29
- 'C:\\Program Files\\Git\\cmd\\git.exe',
30
- 'C:\\Program Files (x86)\\Git\\cmd\\git.exe',
31
- ];
32
-
33
25
  /**
34
26
  * 组装「到哪找 git」的搜索计划(纯函数,便于跨平台单测)。
35
27
  *
@@ -63,9 +55,8 @@ export function resolveGitBin() {
63
55
  try { if (existsSync(p) && statSync(p).isFile()) { _gitBin = p; return _gitBin; } } catch { /* 继续找 */ }
64
56
  }
65
57
  }
66
- for (const p of GIT_CANDIDATES) {
67
- try { if (existsSync(p)) { _gitBin = p; return _gitBin; } } catch { /* 继续找 */ }
68
- }
58
+ // 刻意**不写死**任何安装位置:写死的路径在换机/换平台后必然失效,还会悄悄指向错的可执行文件。
59
+ // 找不到就返回空串,由 GIT_MISSING_MSG 给出可操作的修复方式(加入 PATH 或用 DSH_GIT_BIN 指定)。
69
60
  _gitBin = '';
70
61
  return _gitBin;
71
62
  }
@@ -239,7 +239,7 @@ export function rewriteIdentities(repoPaths = [], opts = {}) {
239
239
  * 仓库历史里**遗留的**非规范身份统计(只报告,不改任何东西)。
240
240
  *
241
241
  * 用途:提交时顺带提醒「以前」留下的身份问题 —— 自动提交只要带正确身份即可,
242
- * 历史要不要统一由用户决定,所以这里只给出「还有多少条、都是谁」,不做任何改写。
242
+ * 历史是否统一属于使用者的判断,所以这里只给出「还有多少条、都是谁」,不做任何改写。
243
243
  * @param {string} repoPath 仓库路径
244
244
  * @param {{runGit:Function, wrongEmails?:string[], branch?:string}} opts
245
245
  * @returns {{count:number, emails:string[]}}
package/lib/git/index.js CHANGED
@@ -22,7 +22,7 @@
22
22
  */
23
23
 
24
24
  export { runGit, runGitAsync, gitRaw } from './exec.js';
25
- export { PLUGIN_ROOT, loadRequirements } from './config.js';
25
+ export { PLUGIN_ROOT } from './config.js';
26
26
  export { credentialsDir, resolveSshKey, resolveToken, maskToken, readSshPub, persistGithubToken, persistSshPub, persistNpmToken, readNpmToken, generateSshKey } from './credentials.js';
27
27
  export { GH_API, githubFetch, parseGithubOwnerRepo, isBadCredentials, detectRepoVisibility } from './api.js';
28
28
  export { resolveRepoVisibility } from './visibility.js';
package/lib/git/push.js CHANGED
@@ -11,7 +11,6 @@ import { waitForCi } from './ci.js';
11
11
  import { existsSync } from 'node:fs';
12
12
  import { join } from 'node:path';
13
13
  import { autoTagDSHProject, ensureAuxSshRemote, readPkgVersion, updateRemoteTrackingRef } from './post-push.js';
14
- import { loadRequirements } from './config.js';
15
14
  import { resolveSshKeys, resolveToken } from './credentials.js';
16
15
  import { runGit } from './exec.js';
17
16
  import { buildWrappedGitEnv } from './wrapped-git.js';
@@ -58,12 +57,12 @@ import { resolveRepoVisibility, cachedVisibility } from './visibility.js';
58
57
  */
59
58
  export async function commitAndPush({
60
59
  repoPath = '', message = '', messageItems = null, push = true, dryRun = false, token = '',
61
- customIgnorePatterns = '', requirementsConfirmed = false, force = false, pushMethod = 'ssh',
60
+ customIgnorePatterns = '', force = false, pushMethod = 'ssh',
62
61
  pushGate = false, pushConfirmed = false, paths = '', remote = '',
63
62
  // 推送后是否等 CI 结果(默认不等:多数推送不需要阻塞);ciTimeoutSec 为等待上限
64
63
  waitCi = false, ciTimeoutSec = 900,
65
64
  // 敏感文件扫描是否执行:**与审计同一开关**(audit 关 ⇒ 不扫),不再享有「强制全仓」特权。
66
- // 缺省 true 仅为兼容直接调用方(CLI/测试);工具路径由 tool-call 按 cfg.auditEnabled 显式传入。
65
+ // 缺省 true 供直接调用方(CLI/测试)使用;工具路径由 tool-call 按预处理开关显式传入。
67
66
  scanSensitive = true,
68
67
  } = {}) {
69
68
  const steps = [];
@@ -80,20 +79,6 @@ export async function commitAndPush({
80
79
  const built = buildCommitMessage(msgInput);
81
80
  if (!built.ok) return { ok: false, steps: ['预检'], error: built.error };
82
81
  const commitMessage = built.message;
83
- // D13 开发者要求门禁(commitPushPreflight 语义):要求清单存在且未核对 → 拦截。
84
- // 清单来源:credentialsDir()/requirements.json(外挂)→ PLUGIN_ROOT/lib/user-requirements.json(内置)。
85
- const userReqs = loadRequirements();
86
- if (userReqs.found && userReqs.items?.length && !requirementsConfirmed) {
87
- return {
88
- ok: false,
89
- blocked: true,
90
- code: 'USER_REQUIREMENTS',
91
- steps: ['预检'],
92
- error: '开发者特殊要求未核对:AI 需先逐条核对要求全部达标,再带 requirementsConfirmed:true 重新调用',
93
- requirements: userReqs,
94
- repo: repoPath,
95
- };
96
- }
97
82
  // D14 detached HEAD 防护(commitPushPreflight 语义):HEAD 处于 detached 状态时拒绝提交,
98
83
  // 避免在无分支的游离 HEAD 上 commit 后无法推送(v1: 'HEAD 处于 detached 状态,请先 checkout 分支')
99
84
  // ⚠ 必须区分「git 调用失败」与「真的是游离 HEAD」:此前只看 stdout,git 因 PATH 缺 git /
@@ -72,6 +72,8 @@ export function readRepoIndexMap(workspaceRoot) {
72
72
  remoteHeadAt: r.remoteHeadAt || '',
73
73
  synced: !!r.synced,
74
74
  remoteStateAt: r.remoteStateAt || '',
75
+ // 本地状态快照(分支/未提交数/最近提交 + 采集时间)——列表请求的零 spawn 数据源
76
+ localState: (r.localState && typeof r.localState === 'object') ? r.localState : null,
75
77
  };
76
78
  }
77
79
  return map;
@@ -369,14 +371,14 @@ function mergeFreshIntoExisting(existing, freshContent) {
369
371
  * syncTarget, offline, maxRepos, mode, cloudRepos, repoName, remoteState }
370
372
  * @returns {Promise<{ok:boolean, indexUpdated:boolean, target?:string, updated?:number, error?:string}>}
371
373
  */
372
- export async function updateRepoIndex({ workspaceRoot = '', token = '', owner = 'EIGHTfs', depth = 20, extraRepos = [], extraReposFile = '', syncTarget = '', offline = false, maxRepos = 200, mode = 'rebuild', cloudRepos = [], repoName = '', remoteState = {} } = {}) {
374
+ export async function updateRepoIndex({ workspaceRoot = '', token = '', owner = 'EIGHTfs', depth = 20, extraRepos = [], extraReposFile = '', syncTarget = '', offline = false, maxRepos = 200, mode = 'rebuild', cloudRepos = [], repoName = '', remoteState = {}, localState = null } = {}) {
373
375
  try {
374
376
  if (mode === 'merge-cloud') {
375
377
  const r = mergeCloudReposIntoIndex({ workspaceRoot, owner, cloudRepos, syncTarget });
376
378
  return { ...r, indexUpdated: r.ok === true };
377
379
  }
378
380
  if (mode === 'single') {
379
- const r = updateRepoRemoteStateInIndex({ workspaceRoot, repoName, remoteState, syncTarget });
381
+ const r = updateRepoRemoteStateInIndex({ workspaceRoot, repoName, remoteState, localState, syncTarget });
380
382
  return { ...r, indexUpdated: r.ok === true };
381
383
  }
382
384
  // rebuild(默认):全量重建 → 与现有索引合并(不全量覆盖)
@@ -494,7 +496,7 @@ export function mergeCloudReposIntoIndex({ workspaceRoot = '', owner = 'EIGHTfs'
494
496
  * visibility 传空/未传 = 不改动既有值(避免把已知可见性抹成「未知」)
495
497
  * @returns {{ok:boolean, target?:string, error?}}
496
498
  */
497
- export function updateRepoRemoteStateInIndex({ workspaceRoot = '', repoName = '', remoteState = {}, syncTarget = '' } = {}) {
499
+ export function updateRepoRemoteStateInIndex({ workspaceRoot = '', repoName = '', remoteState = {}, localState = null, syncTarget = '' } = {}) {
498
500
  try {
499
501
  const target = syncTarget || locateRepoIndex(workspaceRoot) || join(credentialsDir({ workspaceRoot: workspaceRoot || '' }), INDEX_FILE);
500
502
  let index = null;
@@ -514,6 +516,9 @@ export function updateRepoRemoteStateInIndex({ workspaceRoot = '', repoName = ''
514
516
  // 直接写会把云端扫描/手工标注得到的好值抹掉。
515
517
  if (visibility) hit.visibility = visibility;
516
518
  hit.remoteStateAt = new Date().toISOString();
519
+ // 本地状态(分支/未提交数/最近提交)一并缓存:列表请求据此零 spawn 渲染,
520
+ // 不必每仓 describeRepo + git log(CIFS 上每仓 ≈4 次慢 spawn)。
521
+ if (localState && typeof localState === 'object') hit.localState = localState;
517
522
  index.generatedAt = new Date().toISOString();
518
523
  const written = syncRepoIndex({ content: serializeIndex(index), workspaceRoot, owner: index.owner || 'EIGHTfs', syncTarget });
519
524
  return { ok: true, ...written };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * npm 安装编排(Step 3):校验 → 加锁 → 调 npm install → 回执 + 日志留痕。
3
3
  *
4
- * 安全默认(用户确认方案时定):**默认加 `--ignore-scripts`**(装包会执行 postinstall 任意代码),
4
+ * 安全默认:**默认加 `--ignore-scripts`**(装包会执行 postinstall 任意代码),
5
5
  * UI 必须显式勾选才关闭;默认**不全局**(避免污染宿主 node 环境),全局需显式勾选;
6
6
  * registry 与凭据一律走我们自己的 npmrc(--userconfig),不碰用户全局配置。
7
7
  */
@@ -42,12 +42,12 @@ export function resolveNpmBin({ env = process.env } = {}) {
42
42
  }
43
43
  }
44
44
  const nodeDir = dirname(String(process.execPath || ''));
45
+ // 只查「node 可执行文件旁边」这些位置:node 装在哪,npm 就在哪附近 —— 这比写死
46
+ // /usr/bin、/usr/local/bin 更可靠(换机/容器/Windows 都成立)。
45
47
  const candidates = [
46
48
  join(nodeDir, 'npm'),
47
49
  join(nodeDir, '..', '.local', 'bin', 'npm'),
48
50
  join(nodeDir, '..', 'bin', 'npm'),
49
- '/usr/local/bin/npm',
50
- '/usr/bin/npm',
51
51
  ];
52
52
  for (const p of candidates) if (probe(p)) return p;
53
53
  return 'npm';
@@ -104,17 +104,14 @@ export function registerAutoPush(ctx, { cfg = {}, onPushAfterCommit } = {}) {
104
104
  return { paths: [], error: `会话目录不在 git 仓库(${cwd})` };
105
105
  }
106
106
 
107
- /** 对一个仓库执行带门禁的自动提交(复用 commitWithAudit:审计 blocker 拦截 + requirements + pushGate)。 */
107
+ /** 对一个仓库执行带门禁的自动提交(复用 commitWithAudit:审计 blocker 拦截 + pushGate)。 */
108
108
  async function gateCommit(repoPath) {
109
109
  // commit+push 走 commit-push.js 的 commitWithAudit——完整门禁(L0 审计 / requirements /
110
110
  // pushGate)与 git_commit_push 同源,绝不裸提交。审计 audit=true 强制开启(自动推送不因
111
- // 手动开关 auditEnabled=false 而绕过审计——交付门禁对自动通道更高)。
112
- // requirementsConfirmed=true:自动推送是用户「开启 autoPushEnabled」显式授权的自动化通道,
113
- // 不再要求 AI 回合内手动核对清单(那会破坏自动化);门禁仍拦真实 blocker(token/敏感
114
- // 信息/语法错误)。pushConfirmed=true 同理(用户开开关即显式授权推送)。
111
+ // 手动关掉预处理开关而绕过门禁——交付门禁对自动通道更高)。
115
112
  const { commitWithAudit } = await import('../commit-push.js');
116
113
  const message = cfg.autoPushMessage || 'chore(ai): 任务完成自动提交';
117
- return commitWithAudit({ repoPath, message, push: true, audit: true, requirementsConfirmed: true, pushGate: cfg.pushGate === true, pushConfirmed: true });
114
+ return commitWithAudit({ repoPath, message, push: true, audit: true, pushGate: cfg.pushGate === true, pushConfirmed: true });
118
115
  }
119
116
 
120
117
  async function runAutoPush(session, turn, log2) {
@@ -7,7 +7,11 @@
7
7
  *
8
8
  * provider 契约(外部实现按此对齐,见 audit-sluice 的 manifest):
9
9
  * - 可执行入口:`<pkg>/<cliRel>`,stdout 单行 JSON + exit 0|1|2
10
- * - 可选 manifest:`<pkg>/lib/manifest.js` 导出 preprocessManifest { id, label, endpoints, actions }
10
+ * - 可选 manifest:`<pkg>/lib/manifest.js` 导出 preprocessManifest
11
+ * { id, label, endpoints, actions, defaultOnFail?: 'block'|'warn'|'skip' }
12
+ * 其中 defaultOnFail 是本阶段失败时的默认语义(缺省 = 'block',即 fail-closed)。
13
+ * 想"失败只警告、继续后续阶段"的实现(例如格式化器)在自己的 manifest 里声明 'warn' 即可 ——
14
+ * 宿主不按 provider 名字猜语义。
11
15
  *
12
16
  * 解析顺序(与既有行为一致):环境变量 → 插件 node_modules → 平级 sibling。
13
17
  * 环境变量名同样按 provider 生成(`DSH_PREPROCESS_<ID>_CLI`),不再有 audit 专属变量。
package/lib/self/index.js CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
 
12
- export const VERSION = '3.0.0'; // 2.20.17:修桌面端(dsh-app://)所有写接口 403 NO_ORIGIN + 本地列表超时改预算传播 + 放行判据加固。① 桌面壳 forwardWebRequest 转发 /api/* 时显式剥离 Origin,checkOrigin 对无 Origin 的写请求一律拒,导致设置页所有保存/开关/按钮失效且不留日志 → 无 Origin 时要求「Content-Type=application/json + 本机来源」同时成立才放行;② 本机判定以 TCP 对端地址(socket.remoteAddress,内核给出不可伪造)为准,Host 仅在拿不到 socket 时兜底——只信 Host 会被 `Host: 127.0.0.1` 伪造绕过;isLoopbackHost 补裸 IPv6 与 ::ffff: 映射形态;③ 恢复 403 拒绝日志 http-rejects.log(query 凭据键打码);④ settings-set 凭据类回显改「(已保存)」;⑤ 前端保存先 await 写入结果再提示;⑥ clone-progress 改 GET 轮询;⑦ 本地列表 SSH 探测改为预算传播(每步 timeoutMs = min(单步上限, 剩余预算)),扫描长轮询 60s→20s、前端单请求 25s,轮次耗尽不再误报「扫描完成」。历史:2.20.15:
12
+ export const VERSION = '3.1.0'; // 3.1.0:提交前预处理升级为有序阶段链(preCommit.stages,调用参数 preprocessStages 可覆盖配置;onFail 缺省 block);改动可见(快照差集 preprocessChanges);阶段环境变量与占位符;去掉写死的可执行文件路径(改 env→PATH)。历史:2.20.17:修桌面端(dsh-app://)所有写接口 403 NO_ORIGIN + 本地列表超时改预算传播 + 放行判据加固。① 桌面壳 forwardWebRequest 转发 /api/* 时显式剥离 Origin,checkOrigin 对无 Origin 的写请求一律拒,导致设置页所有保存/开关/按钮失效且不留日志 → 无 Origin 时要求「Content-Type=application/json + 本机来源」同时成立才放行;② 本机判定以 TCP 对端地址(socket.remoteAddress,内核给出不可伪造)为准,Host 仅在拿不到 socket 时兜底——只信 Host 会被 `Host: 127.0.0.1` 伪造绕过;isLoopbackHost 补裸 IPv6 与 ::ffff: 映射形态;③ 恢复 403 拒绝日志 http-rejects.log(query 凭据键打码);④ settings-set 凭据类回显改「(已保存)」;⑤ 前端保存先 await 写入结果再提示;⑥ clone-progress 改 GET 轮询;⑦ 本地列表 SSH 探测改为预算传播(每步 timeoutMs = min(单步上限, 剩余预算)),扫描长轮询 60s→20s、前端单请求 25s,轮次耗尽不再误报「扫描完成」。历史:2.20.15:
13
13
  // 实测后果:该目录有 package.json ⇒ npm 去打包整棵 DSH 树、输出 2.1MB > spawnSync 默认 maxBuffer 1MB ⇒ ENOBUFS(npm_publish 的体检与真发全部失败);
14
14
  // 该目录没有 package.json 时报 ENOENT。现 publish 的两个调用点显式传 cwd=目标包目录,并给 runNpm 加 16MB maxBuffer。
15
15
  // 2.8.3:文案修正——「零改动 / 无新提交」明确为**正常成功路径**(注入用法、工具描述、README、skill 同批改),并修 job 输出自相矛盾(cleanSkipCommit 路径补 committed:false,不再显示「已提交,未推送」)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-git-push",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "DSH git 自动提交推送插件——统一函数入口架构(规则/审计/git/自身/侧边栏/评分/豁免/上下文/HTTP/测试十大总入口)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -16,18 +16,15 @@
16
16
  "files": [
17
17
  "lib",
18
18
  "skills",
19
- "scripts",
20
- "assets",
19
+ "scripts/scan-repos.mjs",
21
20
  "cli.mjs",
22
21
  "cli-tool.mjs",
23
22
  "cordis.patch.yml",
24
23
  "README.md",
25
- "LICENSE",
26
- ".auditignore",
27
- ".gitignore"
24
+ "LICENSE"
28
25
  ],
29
26
  "optionalDependencies": {
30
- "audit-sluice": "0.1.0"
27
+ "audit-sluice": "0.1.1"
31
28
  },
32
29
  "engines": {
33
30
  "node": ">=18.0.0"
@@ -16,7 +16,7 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
16
16
  | 工具 | 参数 | 说明 |
17
17
  |---|---|---|
18
18
  | `git_scan` | `root?`, `paths?`, `extraReposFile?` | 扫描全部 git 仓库 → 分支/remote/未提交变更数/最近活动 |
19
- | `git_commit_push` | `repo`(必填), `message`(必填), `push?`, `dryRun?`, `audit?`(默认 true), `requirementsConfirmed?` | **先审计** → `git add -A` → commit → push;审计有 blocker 时拦截 |
19
+ | `git_commit_push` | `repo`(必填), `message`(必填), `push?`, `dryRun?`, `audit?`(默认取配置 `preCommit.enabled`) | **先过提交前预处理门禁** → `git add -A` → commit → push;命中 blocker 时拦截 |
20
20
  | `code_audit` | `repo`, `scope?`, `llm?`, `ruleset?`, `weights?` | 审计仓库:L0 静态检查 + 10 维度质量评分;`scope=full` 全量;`ruleset` 指向自定规则目录(整体替换规则包);**审计固定走完整流程**(正则初筛 + AST 语义检查,无强度档位);`weights` JSON 覆盖权重 |
21
21
  | `git_clone` | `target`(必填), `dest?`, `branch?` | 经 `api.github.com` Git Data API 克隆(不跟随 302、不直连 codeload) |
22
22
  | `git_remote_create` | `repo`, `visibility?`(默认 private), `dryRun?` | 按目录名建远程仓库并设 origin(走 api.github.com) |
@@ -151,7 +151,7 @@ pnpm add github:EIGHTfs/dsh-git-push#<commit>
151
151
  1. **本机要有 `npm`** —— pnpm 构建 git 来源的包时会在临时目录执行 `npm install`;缺 npm 报
152
152
  `ERR_PNPM_PREPARE_PACKAGE` + `spawn ENOENT: npm: command not found`。
153
153
  (本机已装:npm 10.9.2 解包到 `<APP>/lib/node_modules/npm`,链到
154
- `/var/packages/DeepSeekHarness-NAS/target/.local/bin/npm` —— `/usr/local/bin` 不可写。)
154
+ `<APP>/target/.local/bin/npm` —— 系统级 bin 目录不可写。)
155
155
  2. **pnpm 11 默认禁止 git 源依赖执行构建脚本**(供应链策略),而本插件**有 `prepare`/`prepack`**
156
156
  (构建不入库的 `lib/client.js`)⇒ 必须先在 profile 的 `pnpm-workspace.yaml` 放行:
157
157
 
@@ -196,7 +196,7 @@ pnpm add github:EIGHTfs/dsh-git-push#<commit>
196
196
  **用户决策**:删设置配置卡(`settings.plugin.item`),只保留侧边栏独立页(`settings.section`),页面重写为**三个大选项卡**(对齐插件市场 .tabs/.tab/.on,参考 skill 记分板):
197
197
 
198
198
  1. **账号信息**(纯展示):`GET /api/git-push/account-check` → GitHub 登录态/用户名/公钥指纹/套餐,`block` 文本直接展示。
199
- 2. **审计**:① 审计开关(`auditEnabled`,settingsScope.set 即时保存)② 审计权重 10 维度(可读性/可维护性/健壮性/安全性/性能/测试覆盖/可观测性/可部署性/文档/开发者体验,默认合计 100;改即写 `weightOverrides` JSON)③ 规则包列表(`GET /api/git-push/rule-slots` 动态发现;↑↓ 调次序写 `auditRuleOrder`(下覆盖上);单击展开 → `GET /api/git-push/rule-detail?slot=<名>` 显示拦截/警告/通过数量统计 + 规则表格(规则名/简介/级别/作者))。
199
+ 2. **审计 Tab 已移出构建**:前端只剩「账号信息 / 设置」两个页签。审计的实现与配置住在独立包 `audit-sluice`,本插件只保留「提交前预处理」一个总开关(`preCommitEnabled`)。
200
200
  3. **设置**:GitHub token(写 `githubToken`)+ SSH 公钥(写 `sshPub`)+ 邮箱 + 一键生成(`POST /api/git-push/gen-ssh-key`,公钥填入 SSH 框并复制剪贴板)。
201
201
 
202
202
  **配套后端**:
@@ -208,7 +208,7 @@ pnpm add github:EIGHTfs/dsh-git-push#<commit>
208
208
  - 只注册 `settings.section`;`settings.plugin.item` 已删除(`clientModuleInfo().slots` 同步为 `['settings.section']`)。
209
209
  - Controller 命名 `dshgp_*` 前缀防 combo 撞名;组件 `dshgp_AccountTab` / `dshgp_AuditTab` / `dshgp_SettingsTab` + `dshgp_GitPushPage` 装配。
210
210
  - 文件顶层零声明 + `load` 顶部(client-modules 聚合 bundle 兼容),详见 7.2 形态铁律。
211
- - 测试适配:`clientModuleInfo().slots` 断言删 plugin.item;`审计相关开关默认关` 改断言 `this.auditEnabled = false`;CSS 变量名 `dshgp_css`。
211
+ - 测试适配:`clientModuleInfo().slots` 断言删 plugin.item;默认关断言 `this.preCommitEnabled = false`;CSS 变量名 `dshgp_css`。
212
212
 
213
213
  **验证**:`npm test` 430 全绿;combo 拼接解析通过;apply 只注册 section(plugin.item=0)。
214
214
 
@@ -270,7 +270,7 @@ pnpm add github:EIGHTfs/dsh-git-push#<commit>
270
270
  | 工具 | 参数(必填加粗) | 返回 / 实现 |
271
271
  |------|------------------|-------------|
272
272
  | `git_scan` | `root?`、`paths?`(逗号分隔额外仓库)、`extraReposFile?`(每行一个,`#` 注释,实时读) | 各仓库分支/remote/未提交数/最近活动;`lib/git/index.js` `scanRepos` |
273
- | `git_commit_push` | **`repo`**、**`message`**、`audit`(默认 true)、`push`(默认 true)、`dryRun`(false)、`force`、`requirementsConfirmed`、`paths?` | 审计 → 敏感文件加 .gitignore → add → commit → push;push 前 fetch 检查 ahead/behind,远端领先不推;`commitAndPush` |
273
+ | `git_commit_push` | **`repo`**、**`message`**、`audit`(默认取配置 `preCommit.enabled`)、`push`(默认 true)、`dryRun`(false)、`force`、`pushConfirmed`、`paths?` | 预处理门禁 → 敏感文件加 .gitignore → add → commit → push;push 前 fetch 检查 ahead/behind,远端领先不推;`commitAndPush` |
274
274
  | `code_audit` | **`repo`**、`scope`(`full`/缺省=仅变动,非 git 目录退化全量)、`llm?`、`ruleset?`(自定规则目录=整体替换)、`weights?`(JSON 覆盖) | blocker/warning 清单 + quality 0-100(A/B/C/D);`auditWithScope`/`auditFull`/`auditChanged` |
275
275
  | `git_clone` | **`target`**、`dest?`(非空目录拒绝防覆盖)、`branch?` | 只走 api.github.com Git Data API(`git/trees`+`git/blobs`),不跟随 302、不直连 codeload;`cloneViaApi` |
276
276
  | `git_remote_create` | **`repo`**、`visibility?`(默认 private)、`dryRun?` | 同名存在则复用,否则创建并把 origin 指向 API 地址;`ensureRemoteRepo` |
@@ -297,7 +297,7 @@ pnpm add github:EIGHTfs/dsh-git-push#<commit>
297
297
 
298
298
  ## 附录 C、设置项与三处同源
299
299
 
300
- - 设置项:`auditEnabled`(默认 false)、`auditScanScope`(diff|full)、`maxScanFiles`、`weightOverrides`、`pushMethod`、`pushGate`、`maxCloneFileMB`、`cloneConcurrency` 等
300
+ - 设置项(真源 `lib/app/handlers/settings.js` 的 `ALLOWED_SETTING_KEYS`,14 个):`preCommitEnabled`、`injectSystemPrompt`、`maxCloneFileMB`、`cloneConcurrency`、`pushMethod`、`pushGate`、`githubToken`、`sshPub`、`npmToken`、`npmRegistry`、`autoPushEnabled`、`autoPushTriggerText`、`autoPushScope`、`autoPushMessage`(审计自己的配置不在本插件)
301
301
  - **三处同源**(新增项必须三处同加,`test-client.mjs` 断言一致性):`lib/index.js` 的 `Config`(服务端 schema)+ `lib/client/index.js` 的 `SETTINGS_SCHEMA` + `client.js` 的 `SCHEMA`/`zh`
302
302
  - 审计固定完整流程(无强度档位):正则/黑名单/凭据/路径/同步 IO/空 catch + AST 语义检查(func-lines / 复杂度 / 嵌套深度 / 文件行数 / 重复串 / 语义 / 凭据文件 / 命名长度)
303
303
  - 自定规则包:目录里每个 `audit-rules-<名>.yml` 即一个槽位,放文件即生效、删文件即移除;指向空目录会装载 0 条规则(`errors` 有记录),不静默沿用内置包
@@ -358,7 +358,7 @@ pnpm add github:EIGHTfs/dsh-git-push#<commit>
358
358
  ⑤ 重启环境:test_env({ action:'stop' }) → test_env({ action:'start' })
359
359
  ⑥ 取访问令牌:`grep -oE 'token=[A-Za-z0-9._-]+' <测试环境>/dsh-env.log | tail -1`
360
360
  (**不要把它打印到会话里**)
361
- ⑦ 换 cookie:`curl -c /tmp/tc.txt "http://127.0.0.1:<port>/?token=<token>"`
361
+ ⑦ 换 cookie:`curl -c ./tc.txt "http://127.0.0.1:<port>/?token=<token>"`
362
362
  —— 不带 cookie 直接打 API 会得到 401 unauthorized。
363
363
  ⑧ 验证完停环境:test_env({ action:'stop' })
364
364
  ```
@@ -367,12 +367,12 @@ pnpm add github:EIGHTfs/dsh-git-push#<commit>
367
367
 
368
368
  ```bash
369
369
  # 桌面端转发形态(无 Origin + JSON)—— 期望 200
370
- curl -b /tmp/tc.txt -X POST -H 'Content-Type: application/json' \
370
+ curl -b ./tc.txt -X POST -H 'Content-Type: application/json' \
371
371
  -d '{"key":"npmRegistry","value":"https://registry.npmjs.org/"}' \
372
372
  http://127.0.0.1:<port>/api/git-push/settings-set
373
373
 
374
374
  # 跨站表单形态(无 Origin + text/plain)—— 期望 403 NO_ORIGIN
375
- curl -b /tmp/tc.txt -X POST -H 'Content-Type: text/plain' \
375
+ curl -b ./tc.txt -X POST -H 'Content-Type: text/plain' \
376
376
  -d '{"key":"npmRegistry","value":"x"}' \
377
377
  http://127.0.0.1:<port>/api/git-push/settings-set
378
378
  ```