dsh-git-push 2.20.18 → 3.0.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 (198) hide show
  1. package/README.md +3 -2
  2. package/cli-tool.mjs +2 -4
  3. package/cli.mjs +36 -2
  4. package/lib/app/apply.js +9 -9
  5. package/lib/app/command-registry.js +44 -20
  6. package/lib/app/handlers/meta.js +7 -142
  7. package/lib/app/handlers/npm.js +18 -1
  8. package/lib/app/handlers/preprocess.js +107 -0
  9. package/lib/app/handlers/repo-actions.js +2 -2
  10. package/lib/app/http-handlers.js +25 -12
  11. package/lib/app/index.js +2 -1
  12. package/lib/app/inject-text.js +3 -2
  13. package/lib/app/preprocess-client.js +136 -0
  14. package/lib/app/repo-ownership.js +1 -1
  15. package/lib/app/schema.js +3 -3
  16. package/lib/app/severity.js +14 -0
  17. package/lib/app/slash-commands.js +5 -164
  18. package/lib/app/tool-call.js +75 -140
  19. package/lib/app/tools.js +13 -6
  20. package/lib/cli/commands-preprocess.mjs +74 -0
  21. package/lib/cli/commands-tool.mjs +3 -2
  22. package/lib/cli/commands-vcs.mjs +4 -4
  23. package/lib/cli/shared.mjs +42 -13
  24. package/lib/client-parts/git/controller.js +2 -2
  25. package/lib/client.js +2 -2
  26. package/lib/commit-push/pre-commit-engine.js +57 -10
  27. package/lib/commit-push.js +125 -36
  28. package/lib/{exempt/index.js → git/exempt-markers.js} +8 -1
  29. package/lib/git/ignore.js +1 -1
  30. package/lib/git/repos.js +2 -2
  31. package/lib/git/sensitive.js +1 -1
  32. package/lib/npm/publish.js +20 -5
  33. package/lib/plugin/auto-push.js +2 -2
  34. package/lib/preprocess/providers.js +191 -0
  35. package/lib/self/index.js +1 -1
  36. package/lib/skip-dirs.js +14 -55
  37. package/package.json +29 -37
  38. package/scripts/build-client.mjs +2 -0
  39. package/scripts/check.mjs +4 -2
  40. package/scripts/local-registry.mjs +2 -1
  41. package/skills/dev/dsh-git-push.md +5 -0
  42. package/cli-audit.mjs +0 -141
  43. package/lib/app/audit-api.js +0 -173
  44. package/lib/app/host-doc-checks.js +0 -25
  45. package/lib/app/scope-check.js +0 -69
  46. package/lib/ast/brace.js +0 -120
  47. package/lib/ast/callgraph.js +0 -135
  48. package/lib/ast/code-lines.js +0 -175
  49. package/lib/ast/consts.js +0 -12
  50. package/lib/ast/control-flow.js +0 -470
  51. package/lib/ast/credential.js +0 -315
  52. package/lib/ast/dataflow.js +0 -391
  53. package/lib/ast/dup-code.js +0 -165
  54. package/lib/ast/fs-hotspots.js +0 -154
  55. package/lib/ast/index.js +0 -38
  56. package/lib/ast/io-risk-const.js +0 -95
  57. package/lib/ast/io-risk-fn.js +0 -208
  58. package/lib/ast/io-risk-loop.js +0 -308
  59. package/lib/ast/io-risk.js +0 -314
  60. package/lib/ast/lang.js +0 -156
  61. package/lib/ast/line-count.js +0 -52
  62. package/lib/ast/magic-number.js +0 -272
  63. package/lib/ast/naming.js +0 -292
  64. package/lib/ast/perf.js +0 -488
  65. package/lib/ast/scope-collisions.js +0 -228
  66. package/lib/ast/scope.js +0 -241
  67. package/lib/ast/shell.js +0 -131
  68. package/lib/ast/size.js +0 -448
  69. package/lib/ast/symbol-index.js +0 -399
  70. package/lib/ast/tokenizer.js +0 -421
  71. package/lib/ast/treesitter.js +0 -413
  72. package/lib/audit/analysis-coverage.js +0 -98
  73. package/lib/audit/audit-file.js +0 -205
  74. package/lib/audit/auditignore-rules.js +0 -148
  75. package/lib/audit/checks.js +0 -17
  76. package/lib/audit/client-entry.js +0 -93
  77. package/lib/audit/collector.js +0 -610
  78. package/lib/audit/ext-runner.js +0 -80
  79. package/lib/audit/file-context.js +0 -391
  80. package/lib/audit/finding.js +0 -101
  81. package/lib/audit/gitignore-match.js +0 -113
  82. package/lib/audit/glob.js +0 -63
  83. package/lib/audit/history-report.js +0 -100
  84. package/lib/audit/history.js +0 -126
  85. package/lib/audit/ignore-blind.js +0 -102
  86. package/lib/audit/index.js +0 -33
  87. package/lib/audit/orchestrate.js +0 -672
  88. package/lib/audit/public.js +0 -24
  89. package/lib/audit/repo-level.js +0 -30
  90. package/lib/audit/report-yaml.js +0 -90
  91. package/lib/audit/scope-policy.js +0 -110
  92. package/lib/audit/slot.js +0 -66
  93. package/lib/audit-rules/audit-rules-comment.yml +0 -199
  94. package/lib/audit-rules/audit-rules-cpp.yml +0 -114
  95. package/lib/audit-rules/audit-rules-csharp.yml +0 -82
  96. package/lib/audit-rules/audit-rules-docs.yml +0 -32
  97. package/lib/audit-rules/audit-rules-dsh.yml +0 -177
  98. package/lib/audit-rules/audit-rules-filehealth.yml +0 -42
  99. package/lib/audit-rules/audit-rules-folder.yml +0 -99
  100. package/lib/audit-rules/audit-rules-frontend.yml +0 -335
  101. package/lib/audit-rules/audit-rules-go.yml +0 -103
  102. package/lib/audit-rules/audit-rules-i18n.yml +0 -45
  103. package/lib/audit-rules/audit-rules-java.yml +0 -105
  104. package/lib/audit-rules/audit-rules-nodejs.yml +0 -662
  105. package/lib/audit-rules/audit-rules-npm.yml +0 -187
  106. package/lib/audit-rules/audit-rules-paths.yml +0 -98
  107. package/lib/audit-rules/audit-rules-performance.yml +0 -245
  108. package/lib/audit-rules/audit-rules-php.yml +0 -101
  109. package/lib/audit-rules/audit-rules-private.yml +0 -24
  110. package/lib/audit-rules/audit-rules-python.yml +0 -106
  111. package/lib/audit-rules/audit-rules-robustness.yml +0 -31
  112. package/lib/audit-rules/audit-rules-rust.yml +0 -109
  113. package/lib/audit-rules/audit-rules-structure.yml +0 -158
  114. package/lib/audit-rules/audit-rules-swift.yml +0 -99
  115. package/lib/audit-rules/audit-rules-template.yml +0 -108
  116. package/lib/audit-ui-sdk/contract.js +0 -117
  117. package/lib/audit-ui-sdk/index.js +0 -17
  118. package/lib/checks/button-bind.js +0 -347
  119. package/lib/checks/common.js +0 -170
  120. package/lib/checks/credential-file.js +0 -43
  121. package/lib/checks/dataflow.js +0 -40
  122. package/lib/checks/dispatch.js +0 -117
  123. package/lib/checks/dup-code.js +0 -69
  124. package/lib/checks/dup-const.js +0 -232
  125. package/lib/checks/file-health.js +0 -150
  126. package/lib/checks/filter.js +0 -137
  127. package/lib/checks/folder.js +0 -173
  128. package/lib/checks/fs-scanner.js +0 -57
  129. package/lib/checks/hardcoded-path.js +0 -98
  130. package/lib/checks/index.js +0 -49
  131. package/lib/checks/io.js +0 -66
  132. package/lib/checks/magic-number.js +0 -42
  133. package/lib/checks/npm-json.js +0 -273
  134. package/lib/checks/private.js +0 -64
  135. package/lib/checks/regex.js +0 -298
  136. package/lib/checks/scope-collision.js +0 -68
  137. package/lib/checks/semantic.js +0 -134
  138. package/lib/checks/structural.js +0 -281
  139. package/lib/cli/commands-audit.mjs +0 -142
  140. package/lib/cli/commands-doc.mjs +0 -127
  141. package/lib/client-parts/audit/audit.js +0 -301
  142. package/lib/exempt/tool.js +0 -198
  143. package/lib/git/module-splitter.js +0 -47
  144. package/lib/link-check/index.js +0 -187
  145. package/lib/lint-adapter/detect.js +0 -161
  146. package/lib/lint-adapter/index.js +0 -50
  147. package/lib/lint-adapter/runner.js +0 -133
  148. package/lib/rule/compilers/credential.js +0 -62
  149. package/lib/rule/compilers/dataflow.js +0 -38
  150. package/lib/rule/compilers/file-health.js +0 -75
  151. package/lib/rule/compilers/frontend.js +0 -86
  152. package/lib/rule/compilers/func.js +0 -35
  153. package/lib/rule/compilers/helpers.js +0 -71
  154. package/lib/rule/compilers/index.js +0 -29
  155. package/lib/rule/compilers/link-semantic.js +0 -45
  156. package/lib/rule/compilers/list-kinds.js +0 -12
  157. package/lib/rule/compilers/numeric-kinds.js +0 -73
  158. package/lib/rule/compilers/regex.js +0 -78
  159. package/lib/rule/compilers/structure.js +0 -107
  160. package/lib/rule/compilers.js +0 -17
  161. package/lib/rule/homoglyph.js +0 -45
  162. package/lib/rule/loader.js +0 -274
  163. package/lib/rule/registry.js +0 -122
  164. package/lib/rule/scope.js +0 -67
  165. package/lib/score/docs-score.js +0 -166
  166. package/lib/score/index.js +0 -234
  167. package/scripts/__pycache__/module-splitter.cpython-38.pyc +0 -0
  168. package/scripts/audit-ext/_example-readme-present.mjs +0 -34
  169. package/scripts/audit-ext/dsh-inject-declarations.mjs +0 -209
  170. package/scripts/audit-ext/variable-min-length.mjs +0 -102
  171. package/scripts/audit-gate.mjs +0 -235
  172. package/scripts/audit-runner.mjs +0 -35
  173. package/scripts/audit-runtime-check.mjs +0 -129
  174. package/scripts/browser-page-probe.mjs +0 -271
  175. package/scripts/check-js-scope.mjs +0 -87
  176. package/scripts/clean-date-comments.py +0 -102
  177. package/scripts/cpu-sample.mjs +0 -188
  178. package/scripts/doc-drift.mjs +0 -200
  179. package/scripts/hot-path-probe-cjs.cjs +0 -71
  180. package/scripts/hot-path-probe-fs-shim.mjs +0 -28
  181. package/scripts/hot-path-probe-fsp-shim.mjs +0 -31
  182. package/scripts/hot-path-probe.mjs +0 -153
  183. package/scripts/module-splitter.py +0 -800
  184. package/scripts/picker-repro.mjs +0 -115
  185. package/scripts/platform-scan.mjs +0 -168
  186. package/scripts/probe-recheck.mjs +0 -47
  187. package/scripts/rename-locator.mjs +0 -97
  188. package/scripts/rule-switch.mjs +0 -97
  189. package/scripts/rules-solo-audit.mjs +0 -173
  190. package/scripts/scan-file-io.mjs +0 -717
  191. package/scripts/scan-fs-hotspots.mjs +0 -107
  192. package/scripts/symbol-index.mjs +0 -85
  193. package/scripts/verify-prestep.mjs +0 -100
  194. package/skills/dev/audit-rule-authoring.md +0 -58
  195. package/skills/guide/guide-audit.md +0 -270
  196. /package/lib/{audit → app}/ownership.js +0 -0
  197. /package/lib/app/{schema-audit.js → schema-preprocess.js} +0 -0
  198. /package/lib/{audit-defaults.js → git/defaults.js} +0 -0
@@ -13,10 +13,7 @@ import { access } from 'node:fs/promises';
13
13
  import { join, resolve, dirname } from 'node:path';
14
14
  import { fileURLToPath } from 'node:url';
15
15
  import { spawnSync } from 'node:child_process';
16
- import './host-doc-checks.js'; // 审计包边界:文档漂移检查器由宿主注入(导入即接线,见 lib/app/host-doc-checks.js)
17
- import { auditWithScope, auditFull, summarize, isBlockerFinding } from '../audit/index.js';
18
- import { formatAnalysisCoverageLine } from '../audit/analysis-coverage.js';
19
- import { scoreQuality } from '../score/index.js';
16
+ // 评分统一经中间层(唯一调用 scoreQuality 的地方);工具侧只传权重覆盖
20
17
  import {
21
18
  pushInitialContent,
22
19
  cloneViaApi, previewClone, resolveMaxCloneFileMB, ensureRemoteRepo, setVisibility, renameRepo, maintainRepoIndex, updateRepoIndex, resolveToken, commitAndPush,
@@ -24,16 +21,13 @@ import {
24
21
  refreshAccountStatus,
25
22
  } from '../git/index.js';
26
23
  import { runAudit } from '../commit-push.js';
24
+ // 审计能力统一经客户端调审计包(拆包后审计实现不在本仓库;此处只做参数映射与结果转交)
25
+ import * as auditClient from './preprocess-client.js';
27
26
 
28
27
  /* ───────── 工具调用常量 ───────── */
29
28
  import { defaultConfig } from '../client/index.js';
30
- import { checkLinks, sumLinkPenalty } from '../link-check/index.js';
31
- import { scanFileIo } from '../../scripts/scan-file-io.mjs';
32
- import { runModuleSplitter } from '../git/module-splitter.js';
33
29
  import { callIdentityRewrite } from './handlers/identity-rewrite.js';
34
30
  import { MSG_REPO_REQUIRED } from './constants.js';
35
- import { buildAuditApiGuide } from './inject-text.js';
36
- import { exemptStatsOf, GROUP_BY_KEYS } from './audit-api.js';
37
31
  import { setLastSlotHitStats } from './slot-stats.js';
38
32
  import { getDefaultScanRoot } from './scan-root.js';
39
33
  import { probeRepoOwnership } from './repo-ownership.js';
@@ -408,8 +402,8 @@ async function callCommitPush(args, env, cfg, log, jobs, exec) {
408
402
  slots: undefined, // auditRuleOrder 是「加载顺序」不是白名单 ✗(详见 lib/commit-push.js 注释;禁用槽位用 auditDisabledSlots ✓)
409
403
  cfg,
410
404
  // 本次提交的按文件临时豁免(不落盘):列入的文件 finding 不参与拦截判定(含 blocker)
411
- exemptPaths: Array.isArray(args.auditExemptPaths) ? args.auditExemptPaths : [],
412
- exemptReason: args.auditExemptReason,
405
+ auditExemptPaths: Array.isArray(args.auditExemptPaths) ? args.auditExemptPaths : [],
406
+ auditExemptReason: args.auditExemptReason,
413
407
  });
414
408
  if (!auditGate.ok) return auditGate; // { ok:false, blocked:true, audit }
415
409
  const doPush = () => pushWithPostSteps(args, env, cfg);
@@ -472,13 +466,15 @@ function buildAuditOpts(args, cfg, scope) {
472
466
  */
473
467
  async function runHistoryAuditTool(args, env, cfg, jobs, exec, weights) {
474
468
  const repo = args.repo;
475
- const { runHistoryAudit } = await import('../audit/history.js');
476
- const { resolveReportDir } = await import('../audit/history-report.js');
469
+ // 历史审计的遍历与评分都在审计包内;宿主只决定「是否起后台 job / 报告目录」
477
470
  const auditOpts = buildAuditOpts(args, cfg, 'full');
478
- const reportDir = resolveReportDir(repo, args.outDir || '');
471
+ let reportDir = '';
479
472
  const doHistory = async () => {
480
- const r = await runHistoryAudit(repo, { since: args.since, until: args.until, outDir: reportDir, auditOpts, weights });
481
- return { status: r.ok ? 'completed' : 'failed', detail: r.ok ? 'history audit done' : String(r.error || 'failed'), output: JSON.stringify(r) };
473
+ const r = await withAuditPackage(() => auditClient.auditHistory({
474
+ repo, since: args.since, until: args.until, outDir: args.outDir || '', auditOpts, weights,
475
+ }));
476
+ reportDir = r?.reportDir || '';
477
+ return { status: r?.ok ? 'completed' : 'failed', detail: r?.ok ? 'history audit done' : String(r?.error || 'failed'), output: JSON.stringify(r) };
482
478
  };
483
479
  if (!jobs || typeof jobs.start !== 'function') {
484
480
  const r = await doHistory();
@@ -512,48 +508,26 @@ async function callCodeAudit(args, env, cfg, log, jobs, exec) {
512
508
  return runStandardAuditTool(args, env, cfg, log, weights);
513
509
  }
514
510
 
515
- /** standard 模式:diff/full 审计 + 评分 + block 总结。 */
511
+ /** standard 模式:diff/full 审计 + 评分 + block 总结(审计与报告整形都在审计包内)。 */
516
512
  async function runStandardAuditTool(args, env, cfg, log, weights) {
517
513
  const repo = args.repo;
518
- const auditOpts = buildAuditOpts(args, cfg, 'diff');
519
- // existsSync → fs.promises.access 异步化(消除 io-risk 高风险警告;语义不变)
520
- let isGitDir = true;
521
- try { await access(join(repo, '.git')); } catch { isGitDir = false; }
522
- const fullScope = args.scope === 'full' || !isGitDir;
523
- const auditResult = fullScope
524
- ? await auditFull(repo, auditOpts)
525
- : await auditWithScope(repo, auditOpts);
526
- const summary = summarize(auditResult.findings);
527
- // 0 文件(空目录/diff 0 变动)不评分——scoreQuality 返回 emptyResult 防满分
528
- const quality = scoreQuality(auditResult.findings, weights, { files: auditResult.files, dimFileCounts: auditResult.dimFileCounts, dimRuleCounts: auditResult.dimRuleCounts });
529
- // 审计后直接输出豁免类型统计 + 聚合类型 + 拦截列表(blocker 详情不用查 API)
530
- const exemptStats = exemptStatsOf(auditResult.findings);
531
- const blocked = auditResult.findings
532
- // 统一口径:error 也属拦截级(与 summarize 一致)。此前只筛 'blocker' ⇒
533
- // 出现「summary.blocker=10 但这里只枚举 7」的差额(差的正是 error 级)✗
534
- .filter(isBlockerFinding)
535
- .map((f) => ({ file: f.file, line: f.line, rule: f.rule, message: String(f.message || '').slice(0, MAX_MSG_PREVIEW) }));
536
- // 审计输出改为「级别数量 + 评分 + API 查询用法」——审计明细由聚合 API
537
- // (/api/git-push/audit)查询,不再内联输出 findings/审计内容(有聚合 API 消费审计结果)。
538
- const apiGuide = buildAuditApiGuide(repo, { scope: auditResult.scope, summary, quality, exemptStats, blocked, groupByTypes: GROUP_BY_KEYS });
539
- // 分析覆盖率由审计编排层统一计算(CLI 与工具同一口径,见 lib/audit/orchestrate.js),这里只做透传与展示。
540
- const analysisCoverage = auditResult.analysisCoverage || null;
541
- // 缓存按规则包命中数供给 HTTP /rule-slots(侧边栏规则包列表显示实际命中数)
542
- if (auditResult.slotStats) setLastSlotHitStats(auditResult.slotStats, repo);
543
- log?.info?.(`code_audit ${repo} → ${quality.emptyResult ? '未评分(0 文件)' : quality.score + '/' + quality.level}(blocker ${summary.blocker} / warning ${summary.warning} / notice ${summary.notice})`);
544
- // 默认**返回全量审计结果**(findings + yaml):调用方(AI/脚本)拿到的就该是能直接读的问题明细,
545
- // 而不是只有分数再自己去查聚合 API —— 多一跳就多一次漏看的可能。
546
- // 需要精简(大仓库结果过大、或只要结论)时显式传 includeFindings=false / summaryOnly=true。
547
- const withFindings = args.includeFindings !== false && args.summaryOnly !== true;
548
- const out = { ok: true, scope: auditResult.scope, files: auditResult.files, summary, quality, exemptStats, blocked, groupByTypes: GROUP_BY_KEYS, apiGuide, slotStats: auditResult.slotStats };
549
- if (analysisCoverage) {
550
- out.analysisCoverage = analysisCoverage;
551
- out.apiGuide = `${apiGuide}\n${formatAnalysisCoverageLine(analysisCoverage)}`;
552
- }
553
- if (withFindings) {
554
- out.findings = auditResult.findings;
555
- if (auditResult.yaml) out.yaml = auditResult.yaml;
556
- }
514
+ // 审计包的 auditReport 已按同样口径处理「非 git 目录退化成 full」与「0 文件不评分」
515
+ const out = await withAuditPackage(() => auditClient.auditReport({
516
+ repo,
517
+ scope: args.scope === 'full' ? 'full' : 'diff',
518
+ weights,
519
+ rulesetDir: args.rulesetDir || '',
520
+ maxScanFiles: cfg?.maxScanFiles,
521
+ slots: Array.isArray(args.slots) ? args.slots : undefined,
522
+ disabledSlots: Array.isArray(cfg?.auditDisabledSlots) ? cfg.auditDisabledSlots : undefined,
523
+ includeFindings: args.includeFindings !== false && args.summaryOnly !== true,
524
+ // 覆盖率是信息项(不影响 summary/quality);工具参数 coverage:false 时关掉
525
+ ...(args.coverage === false ? { coverage: false } : {}),
526
+ }));
527
+ if (out?.ok === false) return out;
528
+ // 宿主侧副作用:缓存按规则包命中数,供 HTTP /rule-slots 在侧边栏显示实际命中数
529
+ if (out.slotStats) setLastSlotHitStats(out.slotStats, repo);
530
+ log?.info?.(`code_audit ${repo} → ${out.quality?.emptyResult ? '未评分(0 文件)' : `${out.quality?.score}/${out.quality?.level}`}(blocker ${out.summary?.blocker} / warning ${out.summary?.warning} / notice ${out.summary?.notice})`);
557
531
  return out;
558
532
  }
559
533
 
@@ -574,20 +548,18 @@ export async function callTool(toolName, args = {}, env = {}, cfg = defaultConfi
574
548
  case 'git_commit_push':
575
549
  return callCommitPush(args, env, cfg, log, jobs, exec);
576
550
  case 'exempt': {
577
- // 注释豁免工具:add/remove/list/check(标记映射读同进程 EXEMPT_MARKERS,单一真源)
578
- const { addExempt, removeExempt, listExempt, checkExempt } = await import('../exempt/tool.js');
579
- const action = String(args.action || '');
580
- const repoPath = String(args.repo || process.cwd());
581
- if (action === 'add') {
582
- return addExempt({
583
- repoPath, path: args.path, line: args.line, scope: args.scope,
584
- rule: args.rule, marker: args.marker, reason: args.reason, dryRun: args.dryRun === true,
585
- });
586
- }
587
- if (action === 'remove') return removeExempt({ repoPath, path: args.path, marker: args.marker, dryRun: args.dryRun === true });
588
- if (action === 'list') return listExempt({ repoPath });
589
- if (action === 'check') return checkExempt({ repoPath });
590
- return { ok: false, error: `未知 action:${action || '(空)'}(add/remove/list/check)` };
551
+ // 注释豁免工具:add/remove/list/check —— 实现归审计包(标记映射与审计判定同源)
552
+ return withAuditPackage(() => auditClient.exemptAction({
553
+ action: String(args.action || ''),
554
+ repo: String(args.repo || process.cwd()),
555
+ path: args.path,
556
+ line: args.line,
557
+ scope: args.scope,
558
+ rule: args.rule,
559
+ marker: args.marker,
560
+ reason: args.reason,
561
+ dryRun: args.dryRun === true,
562
+ }));
591
563
  }
592
564
  case 'code_audit':
593
565
  return callCodeAudit(args, env, cfg, log, jobs, exec);
@@ -652,18 +624,10 @@ export async function callTool(toolName, args = {}, env = {}, cfg = defaultConfi
652
624
  dryRun: args.dryRun !== false, updateRemotes: args.updateRemotes !== false,
653
625
  });
654
626
  case 'io_scan': {
655
- // 复用 scripts/scan-file-io.mjs(AST 四级分级,与审计 robustness/io-risk 同标准)
656
- // 不在此另写扫描逻辑,避免两套判定漂移。
627
+ // IO 风险扫描:实现在审计包(AST 四级分级,与 robustness/io-risk 同一份)
657
628
  const root = args.repo || env.workspaceRoot;
658
629
  if (!root) return { ok: false, error: 'repo 必填(或用会话工作区)' };
659
- const hits = scanFileIo({
660
- targets: [root],
661
- writeOnly: args.writeOnly === true,
662
- });
663
- const byRisk = { high: 0, medium: 0, low: 0, safe: 0 };
664
- for (const hit of hits) if (byRisk[hit.risk] != null) byRisk[hit.risk] += 1;
665
- const sync = hits.filter((hit) => hit.type === 'sync').length;
666
- return { ok: true, root, total: hits.length, sync, byRisk, items: hits };
630
+ return withAuditPackage(() => auditClient.ioScan({ root, writeOnly: args.writeOnly === true }));
667
631
  }
668
632
  case 'git_clone_preview': {
669
633
  if (!args.target) return { ok: false, error: 'target 必填' };
@@ -676,22 +640,7 @@ export async function callTool(toolName, args = {}, env = {}, cfg = defaultConfi
676
640
  }
677
641
  case 'link_check': {
678
642
  const path = args.path || env.workspaceRoot;
679
- const links = await checkLinks({ file: path, text: readTextSafe(path) });
680
- return { ok: true, count: links.length, penalty: sumLinkPenalty(links), findings: links };
681
- }
682
- case 'module_splitter': {
683
- // 巨型单文件拆分(复用 scripts/module-splitter.py,python3 零依赖)。
684
- // python3 调用逻辑抽到 lib/git/module-splitter.js(与 cli cmdModuleSplitter 共用),
685
- // 此处只做参数映射与结果返回。
686
- const command = String(args.command || '').trim();
687
- const target = String((command === 'analyze' ? args.file : args.plan) || '').trim();
688
- if (!target) {
689
- return { ok: false, error: command === 'analyze' ? 'analyze 需要 file(待拆 .js 路径)' : `${command} 需要 plan(plan.json 文件路径)` };
690
- }
691
- if (!existsSync(target)) return { ok: false, error: `目标不存在:${target}` };
692
- const r = runModuleSplitter({ sub: command, target, dryRun: args.dryRun === true });
693
- if (!r.ok) return { ok: false, error: r.error };
694
- return { ok: true, command: r.sub, target: r.target, dryRun: r.dryRun, output: r.output };
643
+ return withAuditPackage(() => auditClient.linkCheck({ path }));
695
644
  }
696
645
  case 'git_account_check': {
697
646
  if (args.sshPub) persistSshPub(String(args.sshPub), { workspaceRoot: env.workspaceRoot });
@@ -730,8 +679,13 @@ export async function callTool(toolName, args = {}, env = {}, cfg = defaultConfi
730
679
  const endpoints = [...new Set(src.match(/case '\/api\/git-push\/[A-Za-z0-9/_-]+'/g) || [])]
731
680
  .map((s) => s.replace("case '/api/git-push/", '').replace(/'$/, ''))
732
681
  .sort();
733
- const ep = String(args.path || '').trim().replace(/^\/+/, '').replace(/^api\/git-push\//, '');
734
- if (!ep) return { ok: true, count: endpoints.length, endpoints, note: '传 path 调用具体接口(如 path=status)' };
682
+ // path 三种写法都认(AI 面契约:短名不写死前缀,也别让调用方记全路径):
683
+ // ① 短名 `rule-slots` → 走 /api/git-push/rule-slots(git/共享侧)
684
+ // ② 前缀相对 `preprocess/rule-slots` → /api/preprocess/rule-slots(预处理侧,推荐写法)
685
+ // ③ 完整路径 `/api/preprocess/rule-slots` → 原样
686
+ const rawPath = String(args.path || '').trim();
687
+ const ep = rawPath.replace(/^\/+/, '').replace(/^api\//, '');
688
+ if (!ep) return { ok: true, count: endpoints.length, endpoints, note: '传 path 调用具体接口(如 path=status;预处理接口推荐 path=preprocess/audit)' };
735
689
  const method = String(args.method || 'GET').toUpperCase();
736
690
  let query = {};
737
691
  let body;
@@ -745,7 +699,8 @@ export async function callTool(toolName, args = {}, env = {}, cfg = defaultConfi
745
699
  const bodyText = body === undefined ? '' : JSON.stringify(body);
746
700
  const out = await handleHttp({
747
701
  method,
748
- url: `/api/git-push/${ep}${qs ? '?' + qs : ''}`,
702
+ // 已带前缀(preprocess/… 或 git-push/…)就用它;短名默认走 git-push(git/共享侧)
703
+ url: `/api/${/^(preprocess|git-push)\//.test(ep) ? ep : `git-push/${ep}`}${qs ? '?' + qs : ''}`,
749
704
  origin: 'http://localhost', // 内部调用 = 本机同源(写类接口的 CSRF 门禁据此放行)
750
705
  headers: { host: 'localhost', 'content-length': String(bodyText.length) },
751
706
  body: bodyText,
@@ -753,55 +708,35 @@ export async function callTool(toolName, args = {}, env = {}, cfg = defaultConfi
753
708
  return { ok: out?.status === 200 && out?.body?.ok !== false, status: out?.status, endpoint: ep, result: out?.body };
754
709
  }
755
710
  case 'scope_check': {
756
- // 拼接产物作用域撞名:判定在 lib/ast/scope-collisions.js、契约在 lib/audit/scope-policy.js、
757
- // 执行流程在 lib/app/scope-check.js —— 与 scripts/check-js-scope.mjs、审计规则
758
- // kind=scope-collision 三方共用同一份实现,此处只做参数映射与结果整形。
759
- const { runScopeCheck } = await import('./scope-check.js');
760
- const { readProjectScopePolicy } = await import('../audit/scope-policy.js');
761
- const repoRoot = resolve(String(args.repo || env.workspaceRoot || process.cwd()));
762
- const splitList = (value) => String(value || '').split(/[,;\s]+/).map((s) => s.trim()).filter(Boolean);
763
- let targets = splitList(args.files).map((f) => resolve(repoRoot, f));
764
- if (!targets.length) {
765
- // 缺省取项目自己声明的产物清单(dshScopeCheck.files)——不猜文件名,
766
- // 否则「哪些文件是拼接产物」这件事会散成两处判断(本文件 + package.json)。
767
- const policy = readProjectScopePolicy(join(repoRoot, 'package.json'));
768
- const base = policy.configPath ? dirname(policy.configPath) : repoRoot;
769
- targets = policy.files.map((f) => resolve(base, f));
770
- if (!targets.length) {
771
- return { ok: false, error: `未指定 files,且 ${join(repoRoot, 'package.json')} 未声明 dshScopeCheck.files` };
772
- }
773
- }
774
- const result = runScopeCheck({
775
- files: targets,
711
+ // 拼接产物作用域撞名:判定(ast/scope-collisions)+ 契约(engine/scope-policy)都在审计包,
712
+ // 本处只做参数映射与错误包装。
713
+ return withAuditPackage(() => auditClient.scopeCheck({
714
+ repo: String(args.repo || env.workspaceRoot || process.cwd()),
715
+ files: args.files,
776
716
  prefix: String(args.prefix || ''),
777
- allowlist: splitList(args.allowlist),
717
+ allowlist: args.allowlist,
778
718
  ...(typeof args.topLevelMustBeEmpty === 'boolean' ? { topLevelMustBeEmpty: args.topLevelMustBeEmpty } : {}),
779
- });
780
- const lines = result.policySources.map((src) => `策略来源:${src}`);
781
- for (const report of result.reports) {
782
- const rel = report.file.startsWith(`${repoRoot}/`) ? report.file.slice(repoRoot.length + 1) : report.file;
783
- if (report.ok) {
784
- lines.push(`✔ ${rel}:${(report.declarations || []).length} 个声明,无同帧重名`);
785
- continue;
786
- }
787
- lines.push(`✗ ${rel}:`);
788
- for (const violation of report.violations || []) lines.push(` - ${violation}`);
789
- }
790
- const violationCount = result.reports.reduce((sum, report) => sum + (report.violations || []).length, 0);
791
- return {
792
- ok: result.ok,
793
- count: result.reports.length,
794
- violations: violationCount,
795
- policySources: result.policySources,
796
- reports: result.reports,
797
- lines,
798
- };
719
+ }));
799
720
  }
800
721
  default:
801
722
  return { ok: false, error: `未知工具: ${toolName}` };
802
723
  }
803
724
  }
804
725
 
726
+ /**
727
+ * 调审计包的统一包装:把「包加载失败」变成工具可见的 `{ ok:false, error }`。
728
+ * 为什么不在每处 try/catch:五个工具用同一份错误格式,AI 才能一致地判读失败原因。
729
+ * @param {Function} call 实际调用(返回 Promise 或值)
730
+ * @returns {Promise<object>}
731
+ */
732
+ async function withAuditPackage(call) {
733
+ try {
734
+ return await call();
735
+ } catch (e) {
736
+ return { ok: false, error: `审计包不可用:${e?.message || e}` };
737
+ }
738
+ }
739
+
805
740
  /** 按 shell 规则拆分参数串(支持单双引号包裹含空格的路径)。 */
806
741
  function shellSplit(input) {
807
742
  const out = [];
package/lib/app/tools.js CHANGED
@@ -6,12 +6,17 @@
6
6
  * CLI 命令 / 宿主工具 schema / 帮助文档自动对齐(方案 B,免维护)。
7
7
  */
8
8
 
9
- import { TOOL_REGISTRY } from './command-registry.js';
9
+ import { TOOL_REGISTRY, resolveEntryParams } from './command-registry.js';
10
10
 
11
- /** 注册表 params({flag,type,desc,...})→ 宿主工具 parameters 对象格式。 */
12
- function paramsToParameters(params = []) {
11
+ /**
12
+ * 注册表 params({flag,type,desc,...})→ 宿主工具 parameters 对象格式。
13
+ * @param {Array|Function} params 数组,或 (cfg) => 数组 的函数形态(参数按配置动态组装)
14
+ * @param {object} [cfg] 函数形态时传入
15
+ */
16
+ function paramsToParameters(params = [], cfg) {
17
+ const list = typeof params === 'function' ? (params(cfg || {}) || []) : (params || []);
13
18
  const out = {};
14
- for (const p of params) {
19
+ for (const p of list) {
15
20
  // 参数类型 → JSON schema:**只产出宿主认的标量类型**(boolean / string / array)——
16
21
  // 实测宿主校验不认 anyOf、也不认 JSON Schema 的「类型数组」写法(都按 string 处理 ✗,
17
22
  // 报 invalid arguments: "x" must be a string)⇒ 复杂形态一律拆成独立参数 ✓
@@ -25,10 +30,12 @@ function paramsToParameters(params = []) {
25
30
  }
26
31
 
27
32
  /** 工具清单(名 + 说明 + 参数 spec——由注册表生成,单源;lib/plugin/normalizeParameters 转 DSH 形状注册)。 */
28
- export function listTools() {
33
+ export function listTools(cfg, hasBuiltinEngine) {
29
34
  return TOOL_REGISTRY.map((t) => ({
30
35
  name: t.name,
31
36
  description: t.description,
32
- parameters: paramsToParameters(t.params),
37
+ // 用 resolveEntryParams:函数形态的 params 按当前 cfg 求值 ⇒ 未启用的预处理参数不出现在签名里
38
+ // hasBuiltinEngine 只为测试注入(生产不传 ⇒ 真实文件存在性判断);必须透传,否则「不可用态」测不出来
39
+ parameters: paramsToParameters(resolveEntryParams(t, cfg, hasBuiltinEngine), cfg),
33
40
  }));
34
41
  }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * CLI 命令 · 预处理域(从「所有在位 provider 的声明」里找能力并转发)。
3
+ *
4
+ * 为什么不是写死 `audit`:预处理是通用机制,审计只是第一个实现。
5
+ * 本命令只做三件事:① 问 providers 层「谁声明了这个 action」 ② 找不到就说清有哪些可用
6
+ * ③ 找到就 spawn 那个 provider 的 CLI 并把退出码原样透传(脚本可判定失败)。
7
+ *
8
+ * HTTP 侧(/api/preprocess/<action>)用的是同一个查找函数(findActionProvider / findEndpointProvider),
9
+ * 所以 CLI 与 HTTP 的能力面天然一致,不会一边有、一边没有。
10
+ */
11
+ import { spawn } from 'node:child_process';
12
+
13
+ import { findActionProvider, listDeclaredCapabilities, resolveProvider } from '../preprocess/providers.js';
14
+
15
+ /**
16
+ * 列出当前可用的预处理能力(供 help / 报错提示)。
17
+ * @returns {Promise<string>} 多行文本
18
+ */
19
+ export async function describePreprocessCapabilities() {
20
+ const caps = await listDeclaredCapabilities();
21
+ const lines = [];
22
+ if (caps.actions.length === 0) {
23
+ lines.push('当前没有任何在位 provider 声明 action(预处理扩展未安装)');
24
+ } else {
25
+ lines.push('可用预处理动作:');
26
+ for (const action of caps.actions) {
27
+ const params = Array.isArray(action.params) ? action.params.length : 0;
28
+ lines.push(` ${action.action} [${action.provider}] ${params} 个参数 ${action.desc || ''}`.trimEnd());
29
+ }
30
+ }
31
+ for (const miss of caps.missing) {
32
+ lines.push(` · ${miss.provider.id} 不可用:${miss.reason}`);
33
+ }
34
+ return lines.join('\n');
35
+ }
36
+
37
+ /**
38
+ * 执行一次预处理转发。
39
+ * @param {string[]} positional 命令名之后的参数:第一个是 action,其余原样转发
40
+ * @returns {Promise<number>} 退出码(0 成功 / 1 被拦 / 2 参数或执行错误)
41
+ */
42
+ export async function cmdPreprocess(positional = []) {
43
+ const [action, ...forwardArgs] = positional;
44
+ if (!action) {
45
+ console.error(await describePreprocessCapabilities());
46
+ console.error('\n用法:preprocess <action> [参数…]');
47
+ return 2;
48
+ }
49
+ const hit = await findActionProvider(action);
50
+ if (!hit) {
51
+ const caps = await listDeclaredCapabilities();
52
+ const known = caps.actions.map((item) => item.action);
53
+ console.error(`没有 provider 声明动作「${action}」${known.length ? `(可用:${known.join(' / ')})` : '(当前没有任何 provider 在位)'}`);
54
+ console.error(await describePreprocessCapabilities());
55
+ return 2;
56
+ }
57
+ const resolved = resolveProvider(hit.provider.id);
58
+ if (!resolved.ok) {
59
+ console.error(resolved.error);
60
+ return 2;
61
+ }
62
+ // 转发:provider 自己的 CLI 认得同样的 action 名(声明与实现同名,避免映射表漂移)
63
+ const child = spawn(process.execPath, [resolved.path, action, ...forwardArgs], { stdio: 'inherit' });
64
+ return await new Promise((resolvePromise) => {
65
+ child.on('error', (error) => {
66
+ console.error(`启动预处理实现失败:${error?.message || error}`);
67
+ resolvePromise(2);
68
+ });
69
+ child.on('close', (code, signal) => {
70
+ if (signal) { console.error(`预处理实现被信号中断:${signal}`); resolvePromise(2); return; }
71
+ resolvePromise(typeof code === 'number' ? code : 2);
72
+ });
73
+ });
74
+ }
@@ -13,9 +13,10 @@ import { readFileSync } from 'node:fs';
13
13
  import { CLI_ENTRIES, allCommands, parseEntrySourceMeta, readEntrySource } from './shared.mjs';
14
14
 
15
15
  /** 入口文件清单(bin → 源文件)。自检逐个核对。 */
16
+ // 审计 CLI 已随审计能力独立成包(audit-sluice),本插件只剩 git / tool 两侧,
17
+ // 故自检不再遍历 audit 入口(文件已不存在)。
16
18
  export const ENTRY_FILES = [
17
19
  { cliName: 'git-sluice', file: 'cli.mjs' },
18
- { cliName: 'audit-sluice', file: 'cli-audit.mjs' },
19
20
  { cliName: 'tool-sluice', file: 'cli-tool.mjs' },
20
21
  ];
21
22
 
@@ -87,7 +88,7 @@ export function cmdSelfCheck() {
87
88
  // 一次性并入(不在循环里逐条 push:既少一层循环,也让「失败清单来自一处」更好读)
88
89
  failures.push(...entryFailures);
89
90
  for (const failure of entryFailures) console.error(` ✗ ${failure}`);
90
- if (!entryFailures.length) console.log(` ✓ 命令覆盖:三入口共 ${allCommands().length} 个命令都有用法行`);
91
+ if (!entryFailures.length) console.log(` ✓ 命令覆盖:各入口共 ${allCommands().length} 个命令都有用法行`);
91
92
  process.exitCode = failures.length > 0 ? 1 : 0;
92
93
  return failures.length > 0 ? 1 : 0;
93
94
  }
@@ -13,8 +13,8 @@ import { scanRepos } from '../git/repos.js';
13
13
  import { updateRepoIndex } from '../git/repo-index.js';
14
14
  import { runWrappedGit } from '../git/wrapped-git.js';
15
15
  import { commitWithAudit } from '../commit-push.js';
16
- import { checkLinks, sumLinkPenalty } from '../link-check/index.js';
17
- import { collectTextFiles, readText } from '../audit/collector.js';
16
+
17
+ import * as auditClient from '../app/preprocess-client.js';
18
18
  import { cloneViaApi, previewClone } from '../git/clone.js';
19
19
  import { DEFAULT_MAX_FILE_MB } from '../git/clone-download.js';
20
20
  import { resolveToken } from '../git/credentials.js';
@@ -123,10 +123,10 @@ export async function cmdCommit(root, flags) {
123
123
 
124
124
  /** 子命令:link-check — 检查文本文件的链接有效性(只 warning,不拦提交)。 */
125
125
  export async function cmdLinkCheck(root = '.') {
126
- const files = (await collectTextFiles(root, { depth: 5 })).filter((f) => /\.(md|markdown|txt)$/i.test(f.path));
126
+ const files = (await await (await auditClient.hostApi()).collectTextFiles(root, { depth: 5 })).filter((f) => /\.(md|markdown|txt)$/i.test(f.path));
127
127
  const all = [];
128
128
  for (const f of files) {
129
- const findings = await checkLinks({ file: f.path, text: readText(f.full) });
129
+ const findings = await checkLinks({ file: f.path, text: await (await auditClient.hostApi()).readText(f.full) });
130
130
  if (findings.length) all.push(...findings);
131
131
  }
132
132
  console.log(`链接检查 ${root}(${files.length} 个文档)`);
@@ -15,21 +15,21 @@ import { readFileSync, realpathSync } from 'node:fs';
15
15
  import { fileURLToPath } from 'node:url';
16
16
 
17
17
  import { VERSION } from '../self/index.js';
18
- import { registryByCli, parseRegistryArgs } from '../app/command-registry.js';
18
+ import { registryByCli, parseRegistryArgs, resolveEntryParams } from '../app/command-registry.js';
19
19
  import { callTool } from '../app/tool-call.js';
20
20
  import { readSettings, applySettingsToCfg } from '../app/settings-bridge.js';
21
21
  import { defaultConfig } from '../client/index.js';
22
22
 
23
23
  /** 三个入口的名字(也是 bin 名)。 */
24
24
  export const CLI_GIT = 'git-sluice';
25
- export const CLI_AUDIT = 'audit-sluice';
26
25
  export const CLI_TOOL = 'tool-sluice';
27
26
 
28
27
  /**
29
- * 三入口的切割线(唯一真相)。
28
+ * CLI 切割线(唯一真相):审计 CLI 已随审计实现独立成包(audit-sluice)
29
+ * ——宿主不再提供审计入口,故这里只有 git / tool 两侧。
30
30
  * commands:该 CLI 独占的命令名(含注册表驱动与 COMMANDS 表两种来源);
31
31
  * fallback:未知命令的处置——只有 git 侧把未知命令透传给 git(`git-sluice status` = `git status`),
32
- * 另外两侧遇到未知命令必须报错(审计/工具 CLI 不该悄悄执行 git 命令)。
32
+ * tool 侧遇到未知命令必须报错(不该悄悄执行 git 命令)。
33
33
  */
34
34
  export const CLI_ENTRIES = {
35
35
  [CLI_GIT]: {
@@ -39,20 +39,33 @@ export const CLI_ENTRIES = {
39
39
  'scan', 'commit', 'clone', 'clone-preview', 'remote-create', 'rename', 'set-visibility',
40
40
  'identity-rewrite', 'account-check', 'cred-env', 'gen-ssh-key', 'git', 'api', 'repos', 'index',
41
41
  'npm-publish', 'unpublish',
42
+ // 通用预处理入口:从所有在位 provider 的声明里找 action 并转发(审计只是其中之一)
43
+ 'preprocess',
42
44
  ],
43
45
  },
44
- [CLI_AUDIT]: {
45
- intro: 'dsh-git-push 审计侧 CLI(审计/规则/评分/静态检查;脱离 DSH 运行)',
46
- fallback: 'error',
47
- commands: ['audit', 'ruleset', 'file-io', 'link-check', 'scope-check', 'functions', 'tree-doc'],
48
- },
49
46
  [CLI_TOOL]: {
50
47
  intro: 'dsh-git-push 工具链 CLI(拆分/模板/自检;不含 git 与审计命令)',
51
48
  fallback: 'error',
52
- commands: ['module-splitter', 'yaml-template', 'readme-template', 'self-check'],
49
+ commands: ['yaml-template', 'readme-template', 'self-check'],
53
50
  },
54
51
  };
55
52
 
53
+ /**
54
+ * 已随能力迁出宿主的命令 → 现在该去哪个包敲。
55
+ *
56
+ * 为什么单独列:审计 CLI 独立成包后,这些命令名在宿主侧「既不属于 git 也不属于 tool」,
57
+ * 若落进「未知命令」分支,git 侧会把 `audit` 当 git 子命令透传出去(跑出莫名其妙的 git 报错)。
58
+ * 明确告诉用户「已迁到哪个包 + 怎么敲」,才是可行动的提示。
59
+ */
60
+ export const MIGRATED_COMMANDS = Object.freeze({
61
+ audit: 'audit-sluice',
62
+ manifest: 'audit-sluice',
63
+ io_scan: 'audit-sluice',
64
+ link_check: 'audit-sluice',
65
+ scope_check: 'audit-sluice',
66
+ exempt_hint: 'audit-sluice',
67
+ });
68
+
56
69
  /** 命令 → 所属 CLI(未登记返回空串)。 */
57
70
  export function commandOwner(command) {
58
71
  const name = String(command || '');
@@ -277,6 +290,17 @@ export function resolveDispatch({ cliName = CLI_GIT, argv = [], commands = new M
277
290
  if (!command || command === 'help' || command === '--help' || command === '-h') return { kind: 'help' };
278
291
  if (command === 'version' || command === '-v' || command === '--version') return { kind: 'version' };
279
292
  const owner = commandOwner(command);
293
+ // ⓪ 已迁出宿主的命令:说清「去了哪个包 + 怎么敲」,别落进未知命令分支被当 git 子命令透传
294
+ const migratedTo = MIGRATED_COMMANDS[command];
295
+ if (migratedTo) {
296
+ return {
297
+ kind: 'migrated',
298
+ command,
299
+ targetPackage: migratedTo,
300
+ hint: `命令 "${command}" 已随能力迁到独立包 ${migratedTo}(宿主不再内置)。\n`
301
+ + `请改用:git-sluice preprocess ${command} ${rest.join(' ')}(等价:${migratedTo} ${command} …)`.trim(),
302
+ };
303
+ }
280
304
  // ① 跨侧:明确报错并给出可照抄的替代命令(绝不静默转发)
281
305
  if (owner && owner !== cliName) {
282
306
  return { kind: 'cross', command, targetCli: owner, hint: buildCrossCliHint({ command, argvRest: rest, fromCli: cliName }) };
@@ -347,14 +371,19 @@ export async function runCli({
347
371
  passthroughGit = null, getConfig = () => undefined,
348
372
  } = {}) {
349
373
  const plan = resolveDispatch({ cliName, argv, commands });
350
- if (plan.kind === 'help') { console.log(helpText); return; }
374
+ // helpText 允许是函数:git 侧 HELP 里与「审计预处理」绑定的参数要按当前配置决定出不出现
375
+ if (plan.kind === 'help') { console.log(typeof helpText === 'function' ? helpText() : helpText); return; }
351
376
  if (plan.kind === 'version') { printVersion(cliName); return; }
352
377
  if (plan.kind === 'cross') { console.error(plan.hint); process.exitCode = 1; return 1; }
378
+ // 命令已随能力迁出宿主(如审计侧 → audit-sluice 包):给可照抄的提示,不当未知命令
379
+ if (plan.kind === 'migrated') { console.error(plan.hint); process.exitCode = 1; return 1; }
353
380
  if (plan.kind === 'unknown') { console.error(plan.error); process.exitCode = 1; return 1; }
354
381
  if (plan.kind === 'command') return await plan.handler(argv.slice(1));
355
382
  if (plan.kind === 'registry') {
356
- const { argv: normalizedArgv, negated } = normalizeRegistryArgv(argv.slice(1), plan.entry.params);
357
- const { args, error } = parseRegistryArgs(normalizedArgv, plan.entry.params);
383
+ // 函数形态的 params 按当前插件配置求值(未启用的预处理参数不参与解析 ⇒ 传了报未知参数)
384
+ const entryParams = resolveEntryParams(plan.entry, cliPluginConfig());
385
+ const { argv: normalizedArgv, negated } = normalizeRegistryArgv(argv.slice(1), entryParams);
386
+ const { args, error } = parseRegistryArgs(normalizedArgv, entryParams);
358
387
  // 参数错统一 exit 2(与 parseVia 一致、符合「用法错误」惯例);
359
388
  // 其余失败(执行/网络/跨侧指引)保持 1,两者语义不同。
360
389
  if (error) { console.error(error); process.exitCode = 2; return 2; }
@@ -363,7 +363,7 @@
363
363
  this.slotError = '';
364
364
  this.publish();
365
365
  try {
366
- const slotsRes = await dshgp_getJson('/api/git-push/rule-slots');
366
+ const slotsRes = await dshgp_getJson('/api/git-audit/rule-slots');
367
367
  if (slotsRes && slotsRes.ok && slotsRes.slots) {
368
368
  const meta = slotsRes.slots.meta || {};
369
369
  // 用后端返回的生效顺序;private 恒末尾
@@ -1088,7 +1088,7 @@
1088
1088
  this.setStatus(!nowDisabled ? '✅ 已禁用 ' + slot + '(该槽位规则不再加载)' : '✅ 已启用 ' + slot);
1089
1089
  this.publish();
1090
1090
  try {
1091
- const toggleRes = await dshgp_postJson('/api/git-push/toggle-rule', { slot, disabled: !nowDisabled });
1091
+ const toggleRes = await dshgp_postJson('/api/git-audit/toggle-rule', { slot, disabled: !nowDisabled });
1092
1092
  if (toggleRes && toggleRes.ok) {
1093
1093
  void this.loadSlots(); // 后台重载对账(yml 解析结果)
1094
1094
  } else {
package/lib/client.js CHANGED
@@ -1828,7 +1828,7 @@ window.__ModuleLoader__.load({
1828
1828
  this.slotError = '';
1829
1829
  this.publish();
1830
1830
  try {
1831
- const slotsRes = await dshgp_getJson('/api/git-push/rule-slots');
1831
+ const slotsRes = await dshgp_getJson('/api/git-audit/rule-slots');
1832
1832
  if (slotsRes && slotsRes.ok && slotsRes.slots) {
1833
1833
  const meta = slotsRes.slots.meta || {};
1834
1834
  // 用后端返回的生效顺序;private 恒末尾
@@ -2553,7 +2553,7 @@ window.__ModuleLoader__.load({
2553
2553
  this.setStatus(!nowDisabled ? '✅ 已禁用 ' + slot + '(该槽位规则不再加载)' : '✅ 已启用 ' + slot);
2554
2554
  this.publish();
2555
2555
  try {
2556
- const toggleRes = await dshgp_postJson('/api/git-push/toggle-rule', { slot, disabled: !nowDisabled });
2556
+ const toggleRes = await dshgp_postJson('/api/git-audit/toggle-rule', { slot, disabled: !nowDisabled });
2557
2557
  if (toggleRes && toggleRes.ok) {
2558
2558
  void this.loadSlots(); // 后台重载对账(yml 解析结果)
2559
2559
  } else {