dsh-git-push 2.20.19 → 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 (239) hide show
  1. package/README.md +76 -47
  2. package/cli-tool.mjs +2 -4
  3. package/cli.mjs +11 -4
  4. package/lib/app/apply.js +15 -13
  5. package/lib/app/command-registry.js +26 -19
  6. package/lib/app/handlers/http-constants.js +8 -0
  7. package/lib/app/handlers/meta.js +2 -2
  8. package/lib/app/handlers/preprocess.js +104 -0
  9. package/lib/app/handlers/repo-actions.js +2 -3
  10. package/lib/app/handlers/repos.js +137 -10
  11. package/lib/app/handlers/settings.js +34 -15
  12. package/lib/app/http-handlers.js +13 -42
  13. package/lib/app/index.js +3 -2
  14. package/lib/app/inject-text.js +6 -21
  15. package/lib/app/preprocess-client.js +136 -0
  16. package/lib/app/repo-ownership.js +1 -1
  17. package/lib/app/schema.js +20 -10
  18. package/lib/app/settings-bridge.js +60 -8
  19. package/lib/app/severity.js +14 -0
  20. package/lib/app/slash-commands.js +5 -164
  21. package/lib/app/tool-call.js +96 -163
  22. package/lib/cli/commands-preprocess.mjs +74 -0
  23. package/lib/cli/commands-tool.mjs +3 -2
  24. package/lib/cli/commands-vcs.mjs +39 -5
  25. package/lib/cli/shared.mjs +36 -10
  26. package/lib/client/index.js +11 -16
  27. package/lib/client-parts/git/account.js +21 -12
  28. package/lib/client-parts/git/actions.js +23 -77
  29. package/lib/client-parts/git/apply.js +8 -2
  30. package/lib/client-parts/git/browser.js +1 -1
  31. package/lib/client-parts/git/const.js +33 -1
  32. package/lib/client-parts/git/controller.js +175 -176
  33. package/lib/client-parts/git/icons.js +1 -1
  34. package/lib/client-parts/git/loader.js +1 -1
  35. package/lib/client-parts/git/npm.js +56 -37
  36. package/lib/client-parts/git/page.js +53 -1
  37. package/lib/client-parts/git/repo.js +8 -1
  38. package/lib/client-parts/git/settings.js +13 -1
  39. package/lib/client-parts/git/state.js +237 -0
  40. package/lib/client-parts/git/utils.js +1 -1
  41. package/lib/client.js +631 -312
  42. package/lib/commit-push/pre-commit-engine.js +629 -30
  43. package/lib/commit-push.js +127 -67
  44. package/lib/context/index.js +7 -5
  45. package/lib/core/config.js +1 -27
  46. package/lib/core/exec.js +2 -11
  47. package/lib/{exempt/index.js → git/exempt-markers.js} +8 -1
  48. package/lib/git/identity-rewrite.js +1 -1
  49. package/lib/git/ignore.js +1 -1
  50. package/lib/git/index.js +1 -1
  51. package/lib/git/push.js +2 -17
  52. package/lib/git/repo-index.js +8 -3
  53. package/lib/git/repos.js +2 -2
  54. package/lib/git/sensitive.js +1 -1
  55. package/lib/npm/install.js +1 -1
  56. package/lib/npm/publish.js +20 -5
  57. package/lib/npm/registry.js +2 -2
  58. package/lib/plugin/auto-push.js +5 -8
  59. package/lib/preprocess/providers.js +195 -0
  60. package/lib/self/index.js +1 -1
  61. package/lib/skip-dirs.js +14 -55
  62. package/package.json +31 -42
  63. package/skills/dev/dsh-git-push.md +9 -9
  64. package/skills/guide/guide-commit-push.md +11 -13
  65. package/skills/workflow/README.md +0 -1
  66. package/skills/workflow/task-completion-report.md +2 -2
  67. package/.auditignore +0 -30
  68. package/.gitignore +0 -43
  69. package/cli-audit.mjs +0 -141
  70. package/lib/BUGFIX-NOTES-2026-09-14.md +0 -278
  71. package/lib/app/audit-api.js +0 -173
  72. package/lib/app/handlers/audit.js +0 -150
  73. package/lib/app/host-doc-checks.js +0 -25
  74. package/lib/app/schema-audit.js +0 -42
  75. package/lib/app/scope-check.js +0 -69
  76. package/lib/ast/brace.js +0 -120
  77. package/lib/ast/callgraph.js +0 -135
  78. package/lib/ast/code-lines.js +0 -175
  79. package/lib/ast/consts.js +0 -12
  80. package/lib/ast/control-flow.js +0 -470
  81. package/lib/ast/credential.js +0 -315
  82. package/lib/ast/dataflow.js +0 -391
  83. package/lib/ast/dup-code.js +0 -165
  84. package/lib/ast/fs-hotspots.js +0 -154
  85. package/lib/ast/index.js +0 -38
  86. package/lib/ast/io-risk-const.js +0 -95
  87. package/lib/ast/io-risk-fn.js +0 -208
  88. package/lib/ast/io-risk-loop.js +0 -308
  89. package/lib/ast/io-risk.js +0 -314
  90. package/lib/ast/lang.js +0 -156
  91. package/lib/ast/line-count.js +0 -52
  92. package/lib/ast/magic-number.js +0 -272
  93. package/lib/ast/naming.js +0 -292
  94. package/lib/ast/perf.js +0 -488
  95. package/lib/ast/scope-collisions.js +0 -228
  96. package/lib/ast/scope.js +0 -241
  97. package/lib/ast/shell.js +0 -131
  98. package/lib/ast/size.js +0 -448
  99. package/lib/ast/symbol-index.js +0 -399
  100. package/lib/ast/tokenizer.js +0 -421
  101. package/lib/ast/treesitter.js +0 -413
  102. package/lib/audit/analysis-coverage.js +0 -98
  103. package/lib/audit/audit-file.js +0 -205
  104. package/lib/audit/auditignore-rules.js +0 -148
  105. package/lib/audit/checks.js +0 -17
  106. package/lib/audit/client-entry.js +0 -93
  107. package/lib/audit/collector.js +0 -610
  108. package/lib/audit/ext-runner.js +0 -80
  109. package/lib/audit/file-context.js +0 -391
  110. package/lib/audit/finding.js +0 -101
  111. package/lib/audit/gitignore-match.js +0 -113
  112. package/lib/audit/glob.js +0 -63
  113. package/lib/audit/history-report.js +0 -100
  114. package/lib/audit/history.js +0 -126
  115. package/lib/audit/ignore-blind.js +0 -102
  116. package/lib/audit/index.js +0 -33
  117. package/lib/audit/orchestrate.js +0 -672
  118. package/lib/audit/public.js +0 -24
  119. package/lib/audit/repo-level.js +0 -30
  120. package/lib/audit/report-yaml.js +0 -90
  121. package/lib/audit/scope-policy.js +0 -110
  122. package/lib/audit/slot.js +0 -66
  123. package/lib/audit-rules/audit-rules-comment.yml +0 -199
  124. package/lib/audit-rules/audit-rules-cpp.yml +0 -114
  125. package/lib/audit-rules/audit-rules-csharp.yml +0 -82
  126. package/lib/audit-rules/audit-rules-docs.yml +0 -32
  127. package/lib/audit-rules/audit-rules-dsh.yml +0 -177
  128. package/lib/audit-rules/audit-rules-filehealth.yml +0 -42
  129. package/lib/audit-rules/audit-rules-folder.yml +0 -99
  130. package/lib/audit-rules/audit-rules-frontend.yml +0 -335
  131. package/lib/audit-rules/audit-rules-go.yml +0 -103
  132. package/lib/audit-rules/audit-rules-i18n.yml +0 -45
  133. package/lib/audit-rules/audit-rules-java.yml +0 -105
  134. package/lib/audit-rules/audit-rules-nodejs.yml +0 -662
  135. package/lib/audit-rules/audit-rules-npm.yml +0 -187
  136. package/lib/audit-rules/audit-rules-paths.yml +0 -98
  137. package/lib/audit-rules/audit-rules-performance.yml +0 -245
  138. package/lib/audit-rules/audit-rules-php.yml +0 -101
  139. package/lib/audit-rules/audit-rules-private.yml +0 -24
  140. package/lib/audit-rules/audit-rules-python.yml +0 -106
  141. package/lib/audit-rules/audit-rules-robustness.yml +0 -31
  142. package/lib/audit-rules/audit-rules-rust.yml +0 -109
  143. package/lib/audit-rules/audit-rules-structure.yml +0 -158
  144. package/lib/audit-rules/audit-rules-swift.yml +0 -99
  145. package/lib/audit-rules/audit-rules-template.yml +0 -108
  146. package/lib/audit-ui-sdk/contract.js +0 -117
  147. package/lib/audit-ui-sdk/index.js +0 -17
  148. package/lib/checks/button-bind.js +0 -347
  149. package/lib/checks/common.js +0 -170
  150. package/lib/checks/credential-file.js +0 -43
  151. package/lib/checks/dataflow.js +0 -40
  152. package/lib/checks/dispatch.js +0 -117
  153. package/lib/checks/dup-code.js +0 -69
  154. package/lib/checks/dup-const.js +0 -232
  155. package/lib/checks/file-health.js +0 -150
  156. package/lib/checks/filter.js +0 -137
  157. package/lib/checks/folder.js +0 -173
  158. package/lib/checks/fs-scanner.js +0 -57
  159. package/lib/checks/hardcoded-path.js +0 -98
  160. package/lib/checks/index.js +0 -49
  161. package/lib/checks/io.js +0 -66
  162. package/lib/checks/magic-number.js +0 -42
  163. package/lib/checks/npm-json.js +0 -273
  164. package/lib/checks/private.js +0 -64
  165. package/lib/checks/regex.js +0 -298
  166. package/lib/checks/scope-collision.js +0 -68
  167. package/lib/checks/semantic.js +0 -134
  168. package/lib/checks/structural.js +0 -281
  169. package/lib/cli/commands-audit.mjs +0 -142
  170. package/lib/cli/commands-doc.mjs +0 -127
  171. package/lib/client-parts/audit/audit.js +0 -301
  172. package/lib/exempt/tool.js +0 -198
  173. package/lib/git/module-splitter.js +0 -47
  174. package/lib/link-check/index.js +0 -187
  175. package/lib/lint-adapter/detect.js +0 -161
  176. package/lib/lint-adapter/index.js +0 -50
  177. package/lib/lint-adapter/runner.js +0 -133
  178. package/lib/preprocess/audit.js +0 -98
  179. package/lib/preprocess/index.js +0 -78
  180. package/lib/rule/compilers/credential.js +0 -62
  181. package/lib/rule/compilers/dataflow.js +0 -38
  182. package/lib/rule/compilers/file-health.js +0 -75
  183. package/lib/rule/compilers/frontend.js +0 -86
  184. package/lib/rule/compilers/func.js +0 -35
  185. package/lib/rule/compilers/helpers.js +0 -71
  186. package/lib/rule/compilers/index.js +0 -29
  187. package/lib/rule/compilers/link-semantic.js +0 -45
  188. package/lib/rule/compilers/list-kinds.js +0 -12
  189. package/lib/rule/compilers/numeric-kinds.js +0 -73
  190. package/lib/rule/compilers/regex.js +0 -78
  191. package/lib/rule/compilers/structure.js +0 -107
  192. package/lib/rule/compilers.js +0 -17
  193. package/lib/rule/homoglyph.js +0 -45
  194. package/lib/rule/loader.js +0 -274
  195. package/lib/rule/registry.js +0 -122
  196. package/lib/rule/scope.js +0 -67
  197. package/lib/score/docs-score.js +0 -166
  198. package/lib/score/index.js +0 -234
  199. package/lib/user-requirements.json +0 -15
  200. package/scripts/__pycache__/module-splitter.cpython-38.pyc +0 -0
  201. package/scripts/audit-ext/_example-readme-present.mjs +0 -34
  202. package/scripts/audit-ext/dsh-inject-declarations.mjs +0 -209
  203. package/scripts/audit-ext/variable-min-length.mjs +0 -102
  204. package/scripts/audit-gate.mjs +0 -235
  205. package/scripts/audit-runner.mjs +0 -35
  206. package/scripts/audit-runtime-check.mjs +0 -129
  207. package/scripts/browser-page-probe.mjs +0 -271
  208. package/scripts/build-client.mjs +0 -131
  209. package/scripts/bump-version.mjs +0 -178
  210. package/scripts/check-js-scope.mjs +0 -87
  211. package/scripts/check.mjs +0 -203
  212. package/scripts/clean-date-comments.py +0 -102
  213. package/scripts/cpu-sample.mjs +0 -188
  214. package/scripts/doc-drift.mjs +0 -200
  215. package/scripts/doc-func.mjs +0 -212
  216. package/scripts/doc-tree.mjs +0 -458
  217. package/scripts/doc-version.mjs +0 -149
  218. package/scripts/hot-path-probe-cjs.cjs +0 -71
  219. package/scripts/hot-path-probe-fs-shim.mjs +0 -28
  220. package/scripts/hot-path-probe-fsp-shim.mjs +0 -31
  221. package/scripts/hot-path-probe.mjs +0 -153
  222. package/scripts/local-registry.mjs +0 -37
  223. package/scripts/module-splitter.py +0 -800
  224. package/scripts/picker-repro.mjs +0 -115
  225. package/scripts/platform-scan.mjs +0 -168
  226. package/scripts/probe-recheck.mjs +0 -47
  227. package/scripts/rename-locator.mjs +0 -97
  228. package/scripts/rule-switch.mjs +0 -97
  229. package/scripts/rules-solo-audit.mjs +0 -173
  230. package/scripts/scan-file-io.mjs +0 -717
  231. package/scripts/scan-fs-hotspots.mjs +0 -107
  232. package/scripts/scan-version.mjs +0 -125
  233. package/scripts/symbol-index.mjs +0 -85
  234. package/scripts/verify-prestep.mjs +0 -100
  235. package/scripts/version-source.mjs +0 -173
  236. package/skills/dev/audit-rule-authoring.md +0 -58
  237. package/skills/guide/guide-audit.md +0 -270
  238. /package/lib/{audit → app}/ownership.js +0 -0
  239. /package/lib/{audit-defaults.js → git/defaults.js} +0 -0
@@ -25,8 +25,8 @@ import { runGit } from '../git/exec.js';
25
25
 
26
26
  /* ───────── 自动推送常量 ───────── */
27
27
  const AUTO_PUSH_SETTLE_MS = 800; // 回合结束后等收尾落盘的防抖时长
28
- // 扫描仓库下钻深度默认值:与 lib/git/repos.js 共用同一来源(lib/audit-defaults.js)
29
- import { DEFAULT_SCAN_DEPTH } from '../audit-defaults.js';
28
+ // 扫描仓库下钻深度默认值:与 lib/git/repos.js 共用同一来源(lib/git/defaults.js)
29
+ import { DEFAULT_SCAN_DEPTH } from '../git/defaults.js';
30
30
 
31
31
  /** 触发面开关(默认全关——保守:自动推送与审计都不默认开,需用户经 UI 显式开启)。 */
32
32
 
@@ -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) {
@@ -0,0 +1,195 @@
1
+ /**
2
+ * 预处理 provider 注册表(宿主侧)。
3
+ *
4
+ * 为什么要有这一层:**预处理是通用机制,审计只是它的第一个实现**。
5
+ * 将来还会有 lint / 许可证 / 签名校验等 provider。通用层(引擎调用、拦截判定、
6
+ * HTTP 路由、工具入口)一律面向 `provider` 抽象,不得把某个具体实现的包名写死。
7
+ *
8
+ * provider 契约(外部实现按此对齐,见 audit-sluice 的 manifest):
9
+ * - 可执行入口:`<pkg>/<cliRel>`,stdout 单行 JSON + exit 0|1|2
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 名字猜语义。
15
+ *
16
+ * 解析顺序(与既有行为一致):环境变量 → 插件 node_modules → 平级 sibling。
17
+ * 环境变量名同样按 provider 生成(`DSH_PREPROCESS_<ID>_CLI`),不再有 audit 专属变量。
18
+ */
19
+ import { existsSync } from 'node:fs';
20
+ import { dirname, join, resolve } from 'node:path';
21
+ import { fileURLToPath, pathToFileURL } from 'node:url';
22
+
23
+ const PLUGIN_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');
24
+
25
+ /**
26
+ * 内置 provider 列表。
27
+ *
28
+ * 字段说明:
29
+ * id 稳定标识(配置键前缀、日志、API 都用它)
30
+ * label 面向人的名字(只用于展示)
31
+ * packageName npm 包名(找包用)
32
+ * cliRel 包内可执行入口相对路径
33
+ * legacyEnv 历史环境变量名(向后兼容;新代码请用生成的 DSH_PREPROCESS_<ID>_CLI)
34
+ */
35
+ export const PROVIDERS = Object.freeze([
36
+ Object.freeze({
37
+ id: 'audit',
38
+ label: '审计',
39
+ packageName: 'audit-sluice',
40
+ cliRel: 'cli.mjs',
41
+ legacyEnv: 'DSH_AUDIT_SLUICE_CLI',
42
+ }),
43
+ // 将来的 provider 在此追加一条即可;通用层(引擎/拦截/路由/工具)无需改动。
44
+ ]);
45
+
46
+ /** 缺省 provider:提交门禁当前只跑审计这一个预处理。 */
47
+ export const DEFAULT_PROVIDER_ID = 'audit';
48
+
49
+ /** 按 id 找 provider 定义(未知 id 返回 null,由调用方决定怎么报错)。 */
50
+ export function getProviderDefinition(providerId = DEFAULT_PROVIDER_ID) {
51
+ return PROVIDERS.find((provider) => provider.id === providerId) || null;
52
+ }
53
+
54
+ /** provider 专属的环境变量名(新口径)。 */
55
+ export function providerEnvName(providerId) {
56
+ return `DSH_PREPROCESS_${String(providerId).toUpperCase()}_CLI`;
57
+ }
58
+
59
+ /**
60
+ * 解析某个 provider 的可执行入口。
61
+ * @param {string} providerId
62
+ * @returns {{ok: true, path: string, source: string, provider: object} | {ok: false, error: string}}
63
+ */
64
+ export function resolveProvider(providerId = DEFAULT_PROVIDER_ID) {
65
+ const definition = getProviderDefinition(providerId);
66
+ if (!definition) {
67
+ return { ok: false, error: `未知的预处理 provider「${providerId}」(已注册:${PROVIDERS.map((p) => p.id).join(' / ')})` };
68
+ }
69
+ const candidates = [];
70
+ // 1) 显式指定(新变量优先,旧变量兜底)
71
+ const fromEnv = String(process.env[providerEnvName(definition.id)] || process.env[definition.legacyEnv] || '').trim();
72
+ if (fromEnv) candidates.push({ path: fromEnv, source: `env:${providerEnvName(definition.id)}` });
73
+ // 2) 插件自己的 node_modules(npm 安装形态)
74
+ candidates.push({
75
+ path: join(PLUGIN_ROOT, 'node_modules', definition.packageName, definition.cliRel),
76
+ source: 'node_modules',
77
+ });
78
+ // 3) 与本插件平级(开发/并列部署形态)
79
+ candidates.push({
80
+ path: join(PLUGIN_ROOT, '..', definition.packageName, definition.cliRel),
81
+ source: 'sibling',
82
+ });
83
+ for (const candidate of candidates) {
84
+ if (existsSync(candidate.path)) {
85
+ return { ok: true, path: resolve(candidate.path), source: candidate.source, provider: definition };
86
+ }
87
+ }
88
+ return {
89
+ ok: false,
90
+ error: `找不到预处理实现「${definition.label}」(包 ${definition.packageName}/${definition.cliRel})`
91
+ + `(已查:${candidates.map((c) => c.path).join(' / ')})。`
92
+ + `修复:把它装到插件 node_modules、与本插件平级放置,或用 ${providerEnvName(definition.id)} 指定入口。`,
93
+ };
94
+ }
95
+
96
+ /**
97
+ * 解析「提交门禁要用的 provider」。
98
+ * 现在只有一个(审计);将来若支持多预处理串行,这里返回有序列表。
99
+ * @returns {{ok: true, provider: object, path: string, source: string} | {ok: false, error: string}}
100
+ */
101
+ export function resolveGateProvider() {
102
+ return resolveProvider(DEFAULT_PROVIDER_ID);
103
+ }
104
+
105
+ export { PLUGIN_ROOT as preprocessPluginRoot };
106
+
107
+ /**
108
+ * 读取「所有在位 provider 的声明」。
109
+ *
110
+ * 声明来自各包的 `<pkgRoot>/lib/manifest.js`(导出 preprocessManifest)。
111
+ * **这是唯一的能力真相**:CLI 转发、HTTP 路由、工具入口都靠它找「谁提供了什么」,
112
+ * 宿主不写死任何具体实现的能力清单。
113
+ * 不在位(没装/装坏)的 provider 会被跳过并记一条 reason,不抛错——
114
+ * 热插拔语义要求「少一个扩展不影响其他扩展与主流程」。
115
+ *
116
+ * @returns {Promise<{manifests: Array<{provider: object, root: string, manifest: object}>,
117
+ * missing: Array<{provider: object, reason: string}>}>}
118
+ */
119
+ export async function listProviderManifests() {
120
+ const manifests = [];
121
+ const missing = [];
122
+ for (const definition of PROVIDERS) {
123
+ const resolved = resolveProvider(definition.id);
124
+ if (!resolved.ok) { missing.push({ provider: definition, reason: resolved.error }); continue; }
125
+ const root = dirname(resolved.path);
126
+ const manifestFile = join(root, 'lib', 'manifest.js');
127
+ if (!existsSync(manifestFile)) {
128
+ missing.push({ provider: definition, reason: `缺少声明文件 ${manifestFile}` });
129
+ continue;
130
+ }
131
+ try {
132
+ const loaded = await import(pathToFileURL(manifestFile).href);
133
+ const manifest = loaded.preprocessManifest || loaded.default;
134
+ if (!manifest || typeof manifest !== 'object') {
135
+ missing.push({ provider: definition, reason: `${manifestFile} 未导出 preprocessManifest` });
136
+ continue;
137
+ }
138
+ manifests.push({ provider: definition, root, manifest });
139
+ } catch (error) {
140
+ missing.push({ provider: definition, reason: `加载 ${manifestFile} 失败:${error?.message || error}` });
141
+ }
142
+ }
143
+ return { manifests, missing };
144
+ }
145
+
146
+ /**
147
+ * 从所有在位 provider 的声明里,找到「声明了这个 action 的那个」。
148
+ * CLI 的 `preprocess <action>` 与 HTTP 的 `/api/preprocess/<action>` 都走这里,
149
+ * 两边口径自然一致(同一份声明、同一套查找)。
150
+ * @param {string} action
151
+ * @returns {Promise<{provider: object, root: string, manifest: object, action: object} | null>}
152
+ */
153
+ export async function findActionProvider(action) {
154
+ const name = String(action || '').trim();
155
+ if (!name) return null;
156
+ const { manifests } = await listProviderManifests();
157
+ for (const entry of manifests) {
158
+ const declared = Array.isArray(entry.manifest.actions) ? entry.manifest.actions : [];
159
+ const hit = declared.find((item) => item && item.action === name);
160
+ if (hit) return { ...entry, action: hit };
161
+ }
162
+ return null;
163
+ }
164
+
165
+ /**
166
+ * 从所有在位 provider 的声明里,找到「声明了这个 HTTP 子端点的那个」。
167
+ * 与 findActionProvider 同源(同一份 manifest),只是查 endpoints 而不是 actions。
168
+ * @param {string} subPath 子端点路径,如 'rule-slots'
169
+ * @param {string} [method] HTTP 方法(给了就一并匹配)
170
+ */
171
+ export async function findEndpointProvider(subPath, method) {
172
+ const target = String(subPath || '').replace(/^\/+/, '');
173
+ const { manifests } = await listProviderManifests();
174
+ for (const entry of manifests) {
175
+ const declared = Array.isArray(entry.manifest.endpoints) ? entry.manifest.endpoints : [];
176
+ const hit = declared.find((item) => item && item.path === target
177
+ && (!method || String(item.method || 'GET').toUpperCase() === String(method).toUpperCase()));
178
+ if (hit) return { ...entry, endpoint: hit };
179
+ }
180
+ return null;
181
+ }
182
+
183
+ /** 所有已声明能力的汇总(供 help / 路由清单展示)。 */
184
+ export async function listDeclaredCapabilities() {
185
+ const { manifests, missing } = await listProviderManifests();
186
+ return {
187
+ actions: manifests.flatMap((entry) => (entry.manifest.actions || []).map((action) => ({
188
+ provider: entry.provider.id, root: entry.root, ...action,
189
+ }))),
190
+ endpoints: manifests.flatMap((entry) => (entry.manifest.endpoints || []).map((endpoint) => ({
191
+ provider: entry.provider.id, root: entry.root, ...endpoint,
192
+ }))),
193
+ missing,
194
+ };
195
+ }
package/lib/self/index.js CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
 
12
- export const VERSION = '2.20.19'; // 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/lib/skip-dirs.js CHANGED
@@ -1,67 +1,26 @@
1
1
  /**
2
- * 统一「无条件跳过目录」名单(收敛)。
2
+ * 统一「无条件跳过目录」名单(宿主侧只剩硬编码基线)。
3
3
  *
4
- * 组成 = 硬编码基线 + yml 黑名单关键词:
5
- * - 硬编码基线:**只允许 node_modules 和 .git 两个**——禁止在本文件追加目录名
6
- * (dist/build/vendor/coverage/.dsh/.trash/.npm/.pnpm-store/.tmp-build 等一律不许写死在代码里)。
7
- * - yml 黑名单关键词:从审计规则 yml 的 `exclude_dirs` 字段加载(各规则的黑名单目录并集,
8
- * 如 folder 规则的 dist/build/vendor/.dsh/.trash 等)。要新增跳过目录 → 改 yml,不改代码。
4
+ * 历史:本模块原设计是「硬编码基线(node_modules/.git)+ 从审计规则 yml 的 exclude_dirs 取黑名单」。
5
+ * 审计实现与规则 yml 已整体迁入独立包(audit-sluice)⇒ 宿主读不到 yml,yml 那半段已删除。
6
+ * 需要按规则排除目录的场景属于审计侧职责,不该再回到宿主。
9
7
  *
10
- * 白名单(gitignore negation)不受影响:collector walk 对「被忽略目录」按前缀跳过,
11
- * 但 gitignore 白名单恢复的目录仍会进入(黑名单初筛 + 白名单补充)。
12
- *
13
- * 消费方:lib/audit/collector.js(审计文件收集)、lib/git/sensitive.js(敏感扫描)。
8
+ * 消费方:lib/git/sensitive.js(敏感文件扫描时剪枝)。
14
9
  */
15
- import { existsSync, readFileSync, readdirSync } from 'node:fs';
16
- import { join, dirname } from 'node:path';
17
- import { fileURLToPath } from 'node:url';
18
- // js-yaml 走 npm 依赖(仓库内不保存副本)。
19
- // 这里**故意用静态 import**:规则加载是启动关键路径,依赖没装上就应当在模块加载期
20
- // 抛 ERR_MODULE_NOT_FOUND(错误里带包名,够响亮),而不是被 try/catch 吞成「0 条规则」
21
- // 继续跑——静默无规则比启动失败更危险(口径见 docs/2026-10-28-弃零依赖引入npm与AST优先规则方案.MD D5)。
22
- import { load as yamlLoad } from 'js-yaml';
23
-
24
- /** 硬编码基线:只许这两个(勿改)。 */
25
- export const SKIP_DIRS = new Set(['node_modules', '.git']);
26
-
27
- /** 规则 yml 目录(audit-rules-*.yml,与本模块同级的 audit-rules/)。 */
28
- export function auditRulesDir() {
29
- return join(dirname(fileURLToPath(import.meta.url)), 'audit-rules');
30
- }
31
-
32
- let ymlBlacklistCache = null;
33
10
 
34
11
  /**
35
- * 从规则 yml 的 exclude_dirs 字段收集黑名单目录关键词(跨 yml 并集)。
36
- * 加载失败返回空集(不因规则文件损坏阻塞扫描)。
12
+ * 跳过目录基线。
13
+ * - `node_modules` / `.git`:任何仓库都该跳
14
+ * - `node_modules.orig` / `node_modules.bak`:安装/降级留下的完整副本,
15
+ * 里面同样是依赖代码,扫它既慢又会产生大量无关敏感命中
16
+ * 其余目录(dist/build/vendor/.dsh/.trash…)不写死——需要时由调用方显式传参。
37
17
  */
38
- export function loadYamlBlacklistDirs() {
39
- if (ymlBlacklistCache) return ymlBlacklistCache;
40
- const out = new Set();
41
- const dir = auditRulesDir();
42
- try {
43
- for (const f of readdirSync(dir)) {
44
- if (!f.endsWith('.yml')) continue;
45
- let doc;
46
- try { doc = yamlLoad(readFileSync(join(dir, f), 'utf8')); } catch { continue; }
47
- const rules = doc && Array.isArray(doc.rules) ? doc.rules : [];
48
- for (const r of rules) {
49
- if (Array.isArray(r && r.exclude_dirs)) {
50
- for (const n of r.exclude_dirs) if (typeof n === 'string' && n.trim()) out.add(n.trim());
51
- }
52
- }
53
- }
54
- } catch { /* 目录缺失/不可读:返回空集 */ }
55
- ymlBlacklistCache = out;
56
- return out;
57
- }
18
+ export const SKIP_DIRS = new Set(['node_modules', 'node_modules.orig', 'node_modules.bak', '.git']);
58
19
 
59
20
  /**
60
- * 最终跳过目录集合 = 硬编码基线 ∪ yml 黑名单关键词。
61
- * 消费方在遍历剪枝时对目录名命中此集合即整棵跳过。
21
+ * 最终跳过目录集合。
22
+ * 保留函数形态(而非直接导出 Set)是为了调用方不必关心「以后会不会再合并别的来源」。
62
23
  */
63
24
  export function getSkipSet() {
64
- const set = new Set(SKIP_DIRS);
65
- for (const n of loadYamlBlacklistDirs()) set.add(n);
66
- return set;
25
+ return new Set(SKIP_DIRS);
67
26
  }
package/package.json CHANGED
@@ -1,34 +1,53 @@
1
1
  {
2
2
  "name": "dsh-git-push",
3
- "version": "2.20.19",
3
+ "version": "3.1.0",
4
4
  "description": "DSH git 自动提交推送插件——统一函数入口架构(规则/审计/git/自身/侧边栏/评分/豁免/上下文/HTTP/测试十大总入口)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
8
8
  ".": "./lib/index.js",
9
9
  "./client": "./lib/client.js",
10
- "./audit": "./lib/audit/public.js",
11
10
  "./package.json": "./package.json"
12
11
  },
12
+ "bin": {
13
+ "git-sluice": "./cli.mjs",
14
+ "tool-sluice": "./cli-tool.mjs"
15
+ },
13
16
  "files": [
14
17
  "lib",
15
18
  "skills",
16
- "scripts",
17
- "assets",
19
+ "scripts/scan-repos.mjs",
18
20
  "cli.mjs",
19
- "cli-audit.mjs",
20
21
  "cli-tool.mjs",
21
22
  "cordis.patch.yml",
22
23
  "README.md",
23
- "LICENSE",
24
- ".auditignore",
25
- ".gitignore"
24
+ "LICENSE"
26
25
  ],
27
- "bin": {
28
- "git-sluice": "./cli.mjs",
29
- "audit-sluice": "./cli-audit.mjs",
30
- "tool-sluice": "./cli-tool.mjs"
26
+ "optionalDependencies": {
27
+ "audit-sluice": "0.1.1"
31
28
  },
29
+ "engines": {
30
+ "node": ">=18.0.0"
31
+ },
32
+ "scripts": {
33
+ "build:client": "node scripts/build-client.mjs",
34
+ "prepare": "node scripts/build-client.mjs",
35
+ "prepack": "node scripts/build-client.mjs",
36
+ "test": "node test/run-tests.mjs",
37
+ "check": "node scripts/check.mjs"
38
+ },
39
+ "keywords": [
40
+ "dsh",
41
+ "dsh-plugin",
42
+ "deepseek-harness",
43
+ "git",
44
+ "commit",
45
+ "push",
46
+ "audit",
47
+ "cli"
48
+ ],
49
+ "author": "EIGHTfs",
50
+ "license": "MIT",
32
51
  "dsh": {
33
52
  "bundle": {
34
53
  "patch": "./cordis.patch.yml"
@@ -44,7 +63,6 @@
44
63
  "./skills/dsh-repo-index.md",
45
64
  "./skills/dev/dsh-git-push.md",
46
65
  "./skills/dev/git-push-live-fix.md",
47
- "./skills/guide/guide-audit.md",
48
66
  "./skills/guide/guide-cli-scripts.md",
49
67
  "./skills/guide/guide-clone-repos.md",
50
68
  "./skills/guide/guide-commit-push.md",
@@ -61,8 +79,6 @@
61
79
  "./skills/workflow/versioning-rule.md"
62
80
  ]
63
81
  },
64
- "license": "MIT",
65
- "author": "EIGHTfs",
66
82
  "repository": {
67
83
  "type": "git",
68
84
  "url": "git+https://github.com/EIGHTfs/dsh-git-push.git"
@@ -71,37 +87,10 @@
71
87
  "url": "https://github.com/EIGHTfs/dsh-git-push/issues"
72
88
  },
73
89
  "homepage": "https://github.com/EIGHTfs/dsh-git-push#readme",
74
- "keywords": [
75
- "dsh",
76
- "dsh-plugin",
77
- "deepseek-harness",
78
- "git",
79
- "commit",
80
- "push",
81
- "audit",
82
- "cli"
83
- ],
84
- "engines": {
85
- "node": ">=18.0.0"
86
- },
87
90
  "peerDependencies": {
88
91
  "@deepseek-ai/dsh-tools": ">=0.1.6-0 <0.3.0-0",
89
92
  "@deepseek-ai/schemastery": ">=3.0.0 <4.0.0-0"
90
93
  },
91
- "scripts": {
92
- "build:client": "node scripts/build-client.mjs",
93
- "prepare": "node scripts/build-client.mjs",
94
- "prepack": "node scripts/build-client.mjs",
95
- "test": "node test/run-tests.mjs",
96
- "check": "node scripts/check.mjs",
97
- "scan-version": "node scripts/scan-version.mjs",
98
- "check:drift": "node scripts/doc-drift.mjs"
99
- },
100
- "dependencies": {
101
- "js-yaml": "4.1.0",
102
- "tree-sitter-wasms": "0.1.13",
103
- "web-tree-sitter": "0.25.10"
104
- },
105
94
  "dshScopeCheck": {
106
95
  "note": "拼接产物作用域检查:files 里每个文件都查「同作用域重名 / 顶层声明 / 命名前缀」。查法:git-sluice scope-check(无参数即读本块 files);其它项目只要在自己的 package.json 写同名字段即可复用同一套判定",
107
96
  "files": [
@@ -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
  ```
@@ -19,7 +19,7 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
19
19
  | 凭据托管 | GitHub token 与 SSH 公钥统一存在插件配置目录,推送时自动注入,无需手动配 git 凭据 |
20
20
  | 推送通道 | `ssh`(默认,推本地 HEAD,远端 sha 与本地一致)/ `api`(Git Data API 重建提交)/ `auto`(有私钥走 ssh,否则 api) |
21
21
  | 后台任务 | commit+push 注册为宿主官方后台 job,工具立即返回 `jobId`;宿主无 job 控制器时同步执行保底 |
22
- | 门禁开关 | `requirementsConfirmed`(开发者要求核对)、`pushConfirmed`(推送门禁放行)、`force`(强推)、`dryRun`(只预演) |
22
+ | 门禁开关 | `pushConfirmed`(推送门禁放行)、`force`(强推)、`dryRun`(只预演) |
23
23
  | 任务完成自动推送 | 开关开启后,AI 回合结束的回复里含指定完成文案,自动对目标仓库走同一套门禁提交推送 |
24
24
  | 私有库豁免 | 远端可见性 = private 时,审计只报告不拦截;敏感文件只扫描报告、不改写忽略配置 |
25
25
 
@@ -32,11 +32,10 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
32
32
  | `repo` | string | ✅ | — | 本地 git 仓库根目录路径 |
33
33
  | `message` | string | ✅ | — | commit message;空/纯空白直接拒绝 |
34
34
  | `push` | boolean | — | `true` | `false` = 只提交不推送 |
35
- | `audit` | boolean | — | 取配置 `auditEnabled`(默认关) | `true` 强制审计、`false` 跳过本次审计 |
35
+ | `audit` | boolean | — | 取配置 `preCommit.enabled`(默认关) | `true` 强制过门禁、`false` 跳过本次 |
36
36
  | `dryRun` | boolean | — | `false` | 只预演:跑门禁与流程、不写盘、不 commit、不 push |
37
37
  | `force` | boolean | — | `false` | 强推覆盖远端历史(SSH 用 `--force`;API 通道重建提交、不挂旧 parent) |
38
38
  | `ignorePatterns` | string | — | 空 | 追加进 `.gitignore` 的自定义忽略项(逗号/换行分隔,幂等) |
39
- | `requirementsConfirmed` | boolean | — | `false` | 开发者要求清单已逐条核对达标才置 `true`,否则被拦 |
40
39
  | `pushConfirmed` | boolean | — | `false` | 推送门禁(配置 `pushGate`)开启时,推必须显式放行 |
41
40
  | `paths` | string | — | 空 | 精确 add 路径(逗号分隔,相对仓库);空 = 全量暂存 |
42
41
 
@@ -50,7 +49,7 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
50
49
  | `jobFallback` | `true` = 宿主后台 job 不可用,已自动降级为同步执行(结果就在 `result`) |
51
50
  | `audit` | 审计摘要(`summary` 各级数量 / `quality` 评分 / `blocked` 拦截明细 / `privateExempt` 私有库豁免标记);未开审计时为 `null` |
52
51
  | `hint` | 查询提示文案 |
53
- | `error` / `blocked` / `code` | 失败或拦截说明;`code` 取值 `USER_REQUIREMENTS`、`PUSH_GATE` |
52
+ | `error` / `blocked` / `code` | 失败或拦截说明;`code` 取值如 `PUSH_GATE` |
54
53
 
55
54
  ### 返回字段(最终结果 `result`——后台 job 完成输出,或同步执行直接返回)
56
55
 
@@ -74,7 +73,7 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
74
73
  **① 标准提交推送**(要求清单存在时必须带核对标记)
75
74
 
76
75
  ```js
77
- git_commit_push({ repo: "<仓库路径>", message: "feat: 新增 XX 能力", requirementsConfirmed: true })
76
+ git_commit_push({ repo: "<仓库路径>", message: "feat: 新增 XX 能力" })
78
77
  ```
79
78
 
80
79
  预期:`{ ok:true, async:true, jobId:"git-push-1", audit:{ summary:{...}, quality:{...} } }`;job 完成后输出 `{ ok:true, commitSha:"a1b2c3d…", pushed:true, push:{ method:"ssh", branch:"master" }, indexUpdated:true }`。
@@ -82,12 +81,12 @@ git_commit_push({ repo: "<仓库路径>", message: "feat: 新增 XX 能力", req
82
81
  **② 只提交不推送 / 先预演 / 只提交指定文件**
83
82
 
84
83
  ```js
85
- git_commit_push({ repo: "<仓库路径>", message: "docs: 更新说明", push: false, requirementsConfirmed: true })
84
+ git_commit_push({ repo: "<仓库路径>", message: "docs: 更新说明", push: false })
86
85
  git_commit_push({ repo: "<仓库路径>", message: "feat: 试跑", dryRun: true })
87
86
  // 零改动也照样调用:没有新提交时同样返回 ok:true(committed:false),
88
87
  // 而「本地领先远端」的已提交内容会照常推上去 —— 不要因为「没东西可提交」改去手敲 git
89
- git_commit_push({ repo: "<仓库路径>", message: "(零改动时用不到)", requirementsConfirmed: true })
90
- git_commit_push({ repo: "<仓库路径>", message: "fix: 修正解析", paths: "src/parser.js,README.md", requirementsConfirmed: true })
88
+ git_commit_push({ repo: "<仓库路径>", message: "(零改动时用不到)" })
89
+ git_commit_push({ repo: "<仓库路径>", message: "fix: 修正解析", paths: "src/parser.js,README.md" })
91
90
  ```
92
91
 
93
92
  预演预期:`{ ok:true, async:true, jobId:"git-push-2" }`,完成后 `{ ok:true, dryRun:true, steps:["预检","commit","push"] }`(无任何写入)。
@@ -95,15 +94,15 @@ git_commit_push({ repo: "<仓库路径>", message: "fix: 修正解析", paths: "
95
94
  **③ 推送门禁已开启时显式放行 / 强推**
96
95
 
97
96
  ```js
98
- git_commit_push({ repo: "<仓库路径>", message: "chore: 同步", requirementsConfirmed: true, pushConfirmed: true })
99
- git_commit_push({ repo: "<仓库路径>", message: "chore: 重写历史后同步", force: true, requirementsConfirmed: true, pushConfirmed: true })
97
+ git_commit_push({ repo: "<仓库路径>", message: "chore: 同步", pushConfirmed: true })
98
+ git_commit_push({ repo: "<仓库路径>", message: "chore: 重写历史后同步", force: true, pushConfirmed: true })
100
99
  ```
101
100
 
102
101
  **④ 被拦后的典型返回**
103
102
 
104
103
  ```json
105
104
  { "ok": false, "blocked": true, "error": "审计拦截:2 个 blocker → src/a.js:12(凭据硬编码);docs/b.md:3(沟通措辞残留)" }
106
- { "ok": false, "blocked": true, "code": "USER_REQUIREMENTS", "error": "开发者特殊要求未核对:…" }
105
+ { "ok": false, "blocked": true, "code": "PUSH_GATE", "error": "推送门禁已开启,需 pushConfirmed:true 后重试" }
107
106
  { "ok": false, "blocked": true, "code": "PUSH_GATE", "commitSha": "a1b2c3d…", "push": { "pushed": false, "reason": "push-gate" } }
108
107
  ```
109
108
 
@@ -112,7 +111,6 @@ git_commit_push({ repo: "<仓库路径>", message: "chore: 重写历史后同步
112
111
  | 现象 | 原因 | 处理 |
113
112
  |---|---|---|
114
113
  | `ok:false, blocked:true`(审计拦截) | 审计命中 blocker(凭据硬编码、语法错误、沟通措辞等) | 先按 `audit.blocked` 列表修文件,再重调;`public`/`unknown` 可见性一律保守拦截 |
115
- | 返回 `code:"USER_REQUIREMENTS"` | 存在开发者要求清单,但未带 `requirementsConfirmed:true` | 逐条核对达标后置 `true` 重调 |
116
114
  | 返回 `code:"PUSH_GATE"` | 配置 `pushGate` 已开启,未带 `pushConfirmed:true` | 确认要推时带 `pushConfirmed:true` 重调(**可沿用本次 commit,不会重复提交**) |
117
115
  | `非 git 仓库` / `commit message 必填` | `repo` 下无 `.git`,或 `message` 为空 | 先确认仓库路径、补 message |
118
116
  | `HEAD 处于 detached 状态` | 当前在游离 HEAD 上 | 先 `git checkout <分支>` 再提交 |
@@ -168,7 +166,7 @@ git_commit_push({ repo: "<仓库路径>", message: "chore: 重写历史后同步
168
166
  "message": "fix(audit): 修 secret-email 把 @2x 资源名当邮箱的误报",
169
167
  "messageItems": [
170
168
  { "what": "pattern 增加资源后缀负向前瞻", "type": "fix", "scope": "audit-rules",
171
- "why": "视网膜文件名被当成 x@y.tld", "verify": "双向自测 6 例通过" },
169
+ "why": "视网膜文件名被当成邮箱地址", "verify": "双向自测 6 例通过" },
172
170
  "门禁四项绿;全量测试 0 失败"
173
171
  ]
174
172
  }
@@ -17,5 +17,4 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
17
17
 
18
18
  ## 已内置化
19
19
 
20
- - 开发者要求清单 → `lib/user-requirements.json`(随插件分发;v2 未移植,待验收)
21
20
  - 仓库索引 → 废弃 md 表格,改用 JSON 索引(生成于插件配置目录的 `dsh-repo-index.jsonl`)