dsh-git-push 2.20.19 → 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.
- package/README.md +3 -2
- package/cli-tool.mjs +2 -4
- package/cli.mjs +7 -1
- package/lib/app/apply.js +4 -4
- package/lib/app/command-registry.js +22 -17
- package/lib/app/handlers/meta.js +2 -2
- package/lib/app/handlers/preprocess.js +107 -0
- package/lib/app/handlers/repo-actions.js +2 -2
- package/lib/app/http-handlers.js +13 -42
- package/lib/app/index.js +2 -1
- package/lib/app/inject-text.js +3 -3
- package/lib/app/preprocess-client.js +136 -0
- package/lib/app/repo-ownership.js +1 -1
- package/lib/app/schema.js +3 -3
- package/lib/app/severity.js +14 -0
- package/lib/app/slash-commands.js +5 -164
- package/lib/app/tool-call.js +73 -144
- package/lib/cli/commands-preprocess.mjs +74 -0
- package/lib/cli/commands-tool.mjs +3 -2
- package/lib/cli/commands-vcs.mjs +4 -4
- package/lib/cli/shared.mjs +35 -9
- package/lib/commit-push/pre-commit-engine.js +57 -10
- package/lib/commit-push.js +71 -27
- package/lib/{exempt/index.js → git/exempt-markers.js} +8 -1
- package/lib/git/ignore.js +1 -1
- package/lib/git/repos.js +2 -2
- package/lib/git/sensitive.js +1 -1
- package/lib/npm/publish.js +20 -5
- package/lib/plugin/auto-push.js +2 -2
- package/lib/preprocess/providers.js +191 -0
- package/lib/self/index.js +1 -1
- package/lib/skip-dirs.js +14 -55
- package/package.json +29 -37
- package/scripts/build-client.mjs +2 -0
- package/scripts/check.mjs +4 -2
- package/scripts/local-registry.mjs +2 -1
- package/cli-audit.mjs +0 -141
- package/lib/app/audit-api.js +0 -173
- package/lib/app/handlers/audit.js +0 -150
- package/lib/app/host-doc-checks.js +0 -25
- package/lib/app/scope-check.js +0 -69
- package/lib/ast/brace.js +0 -120
- package/lib/ast/callgraph.js +0 -135
- package/lib/ast/code-lines.js +0 -175
- package/lib/ast/consts.js +0 -12
- package/lib/ast/control-flow.js +0 -470
- package/lib/ast/credential.js +0 -315
- package/lib/ast/dataflow.js +0 -391
- package/lib/ast/dup-code.js +0 -165
- package/lib/ast/fs-hotspots.js +0 -154
- package/lib/ast/index.js +0 -38
- package/lib/ast/io-risk-const.js +0 -95
- package/lib/ast/io-risk-fn.js +0 -208
- package/lib/ast/io-risk-loop.js +0 -308
- package/lib/ast/io-risk.js +0 -314
- package/lib/ast/lang.js +0 -156
- package/lib/ast/line-count.js +0 -52
- package/lib/ast/magic-number.js +0 -272
- package/lib/ast/naming.js +0 -292
- package/lib/ast/perf.js +0 -488
- package/lib/ast/scope-collisions.js +0 -228
- package/lib/ast/scope.js +0 -241
- package/lib/ast/shell.js +0 -131
- package/lib/ast/size.js +0 -448
- package/lib/ast/symbol-index.js +0 -399
- package/lib/ast/tokenizer.js +0 -421
- package/lib/ast/treesitter.js +0 -413
- package/lib/audit/analysis-coverage.js +0 -98
- package/lib/audit/audit-file.js +0 -205
- package/lib/audit/auditignore-rules.js +0 -148
- package/lib/audit/checks.js +0 -17
- package/lib/audit/client-entry.js +0 -93
- package/lib/audit/collector.js +0 -610
- package/lib/audit/ext-runner.js +0 -80
- package/lib/audit/file-context.js +0 -391
- package/lib/audit/finding.js +0 -101
- package/lib/audit/gitignore-match.js +0 -113
- package/lib/audit/glob.js +0 -63
- package/lib/audit/history-report.js +0 -100
- package/lib/audit/history.js +0 -126
- package/lib/audit/ignore-blind.js +0 -102
- package/lib/audit/index.js +0 -33
- package/lib/audit/orchestrate.js +0 -672
- package/lib/audit/public.js +0 -24
- package/lib/audit/repo-level.js +0 -30
- package/lib/audit/report-yaml.js +0 -90
- package/lib/audit/scope-policy.js +0 -110
- package/lib/audit/slot.js +0 -66
- package/lib/audit-rules/audit-rules-comment.yml +0 -199
- package/lib/audit-rules/audit-rules-cpp.yml +0 -114
- package/lib/audit-rules/audit-rules-csharp.yml +0 -82
- package/lib/audit-rules/audit-rules-docs.yml +0 -32
- package/lib/audit-rules/audit-rules-dsh.yml +0 -177
- package/lib/audit-rules/audit-rules-filehealth.yml +0 -42
- package/lib/audit-rules/audit-rules-folder.yml +0 -99
- package/lib/audit-rules/audit-rules-frontend.yml +0 -335
- package/lib/audit-rules/audit-rules-go.yml +0 -103
- package/lib/audit-rules/audit-rules-i18n.yml +0 -45
- package/lib/audit-rules/audit-rules-java.yml +0 -105
- package/lib/audit-rules/audit-rules-nodejs.yml +0 -662
- package/lib/audit-rules/audit-rules-npm.yml +0 -187
- package/lib/audit-rules/audit-rules-paths.yml +0 -98
- package/lib/audit-rules/audit-rules-performance.yml +0 -245
- package/lib/audit-rules/audit-rules-php.yml +0 -101
- package/lib/audit-rules/audit-rules-private.yml +0 -24
- package/lib/audit-rules/audit-rules-python.yml +0 -106
- package/lib/audit-rules/audit-rules-robustness.yml +0 -31
- package/lib/audit-rules/audit-rules-rust.yml +0 -109
- package/lib/audit-rules/audit-rules-structure.yml +0 -158
- package/lib/audit-rules/audit-rules-swift.yml +0 -99
- package/lib/audit-rules/audit-rules-template.yml +0 -108
- package/lib/audit-ui-sdk/contract.js +0 -117
- package/lib/audit-ui-sdk/index.js +0 -17
- package/lib/checks/button-bind.js +0 -347
- package/lib/checks/common.js +0 -170
- package/lib/checks/credential-file.js +0 -43
- package/lib/checks/dataflow.js +0 -40
- package/lib/checks/dispatch.js +0 -117
- package/lib/checks/dup-code.js +0 -69
- package/lib/checks/dup-const.js +0 -232
- package/lib/checks/file-health.js +0 -150
- package/lib/checks/filter.js +0 -137
- package/lib/checks/folder.js +0 -173
- package/lib/checks/fs-scanner.js +0 -57
- package/lib/checks/hardcoded-path.js +0 -98
- package/lib/checks/index.js +0 -49
- package/lib/checks/io.js +0 -66
- package/lib/checks/magic-number.js +0 -42
- package/lib/checks/npm-json.js +0 -273
- package/lib/checks/private.js +0 -64
- package/lib/checks/regex.js +0 -298
- package/lib/checks/scope-collision.js +0 -68
- package/lib/checks/semantic.js +0 -134
- package/lib/checks/structural.js +0 -281
- package/lib/cli/commands-audit.mjs +0 -142
- package/lib/cli/commands-doc.mjs +0 -127
- package/lib/client-parts/audit/audit.js +0 -301
- package/lib/exempt/tool.js +0 -198
- package/lib/git/module-splitter.js +0 -47
- package/lib/link-check/index.js +0 -187
- package/lib/lint-adapter/detect.js +0 -161
- package/lib/lint-adapter/index.js +0 -50
- package/lib/lint-adapter/runner.js +0 -133
- package/lib/preprocess/audit.js +0 -98
- package/lib/preprocess/index.js +0 -78
- package/lib/rule/compilers/credential.js +0 -62
- package/lib/rule/compilers/dataflow.js +0 -38
- package/lib/rule/compilers/file-health.js +0 -75
- package/lib/rule/compilers/frontend.js +0 -86
- package/lib/rule/compilers/func.js +0 -35
- package/lib/rule/compilers/helpers.js +0 -71
- package/lib/rule/compilers/index.js +0 -29
- package/lib/rule/compilers/link-semantic.js +0 -45
- package/lib/rule/compilers/list-kinds.js +0 -12
- package/lib/rule/compilers/numeric-kinds.js +0 -73
- package/lib/rule/compilers/regex.js +0 -78
- package/lib/rule/compilers/structure.js +0 -107
- package/lib/rule/compilers.js +0 -17
- package/lib/rule/homoglyph.js +0 -45
- package/lib/rule/loader.js +0 -274
- package/lib/rule/registry.js +0 -122
- package/lib/rule/scope.js +0 -67
- package/lib/score/docs-score.js +0 -166
- package/lib/score/index.js +0 -234
- package/scripts/__pycache__/module-splitter.cpython-38.pyc +0 -0
- package/scripts/audit-ext/_example-readme-present.mjs +0 -34
- package/scripts/audit-ext/dsh-inject-declarations.mjs +0 -209
- package/scripts/audit-ext/variable-min-length.mjs +0 -102
- package/scripts/audit-gate.mjs +0 -235
- package/scripts/audit-runner.mjs +0 -35
- package/scripts/audit-runtime-check.mjs +0 -129
- package/scripts/browser-page-probe.mjs +0 -271
- package/scripts/check-js-scope.mjs +0 -87
- package/scripts/clean-date-comments.py +0 -102
- package/scripts/cpu-sample.mjs +0 -188
- package/scripts/doc-drift.mjs +0 -200
- package/scripts/hot-path-probe-cjs.cjs +0 -71
- package/scripts/hot-path-probe-fs-shim.mjs +0 -28
- package/scripts/hot-path-probe-fsp-shim.mjs +0 -31
- package/scripts/hot-path-probe.mjs +0 -153
- package/scripts/module-splitter.py +0 -800
- package/scripts/picker-repro.mjs +0 -115
- package/scripts/platform-scan.mjs +0 -168
- package/scripts/probe-recheck.mjs +0 -47
- package/scripts/rename-locator.mjs +0 -97
- package/scripts/rule-switch.mjs +0 -97
- package/scripts/rules-solo-audit.mjs +0 -173
- package/scripts/scan-file-io.mjs +0 -717
- package/scripts/scan-fs-hotspots.mjs +0 -107
- package/scripts/symbol-index.mjs +0 -85
- package/scripts/verify-prestep.mjs +0 -100
- package/skills/dev/audit-rule-authoring.md +0 -58
- package/skills/guide/guide-audit.md +0 -270
- /package/lib/{audit → app}/ownership.js +0 -0
- /package/lib/app/{schema-audit.js → schema-preprocess.js} +0 -0
- /package/lib/{audit-defaults.js → git/defaults.js} +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
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 { id, label, endpoints, actions }
|
|
11
|
+
*
|
|
12
|
+
* 解析顺序(与既有行为一致):环境变量 → 插件 node_modules → 平级 sibling。
|
|
13
|
+
* 环境变量名同样按 provider 生成(`DSH_PREPROCESS_<ID>_CLI`),不再有 audit 专属变量。
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync } from 'node:fs';
|
|
16
|
+
import { dirname, join, resolve } from 'node:path';
|
|
17
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
18
|
+
|
|
19
|
+
const PLUGIN_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 内置 provider 列表。
|
|
23
|
+
*
|
|
24
|
+
* 字段说明:
|
|
25
|
+
* id 稳定标识(配置键前缀、日志、API 都用它)
|
|
26
|
+
* label 面向人的名字(只用于展示)
|
|
27
|
+
* packageName npm 包名(找包用)
|
|
28
|
+
* cliRel 包内可执行入口相对路径
|
|
29
|
+
* legacyEnv 历史环境变量名(向后兼容;新代码请用生成的 DSH_PREPROCESS_<ID>_CLI)
|
|
30
|
+
*/
|
|
31
|
+
export const PROVIDERS = Object.freeze([
|
|
32
|
+
Object.freeze({
|
|
33
|
+
id: 'audit',
|
|
34
|
+
label: '审计',
|
|
35
|
+
packageName: 'audit-sluice',
|
|
36
|
+
cliRel: 'cli.mjs',
|
|
37
|
+
legacyEnv: 'DSH_AUDIT_SLUICE_CLI',
|
|
38
|
+
}),
|
|
39
|
+
// 将来的 provider 在此追加一条即可;通用层(引擎/拦截/路由/工具)无需改动。
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
/** 缺省 provider:提交门禁当前只跑审计这一个预处理。 */
|
|
43
|
+
export const DEFAULT_PROVIDER_ID = 'audit';
|
|
44
|
+
|
|
45
|
+
/** 按 id 找 provider 定义(未知 id 返回 null,由调用方决定怎么报错)。 */
|
|
46
|
+
export function getProviderDefinition(providerId = DEFAULT_PROVIDER_ID) {
|
|
47
|
+
return PROVIDERS.find((provider) => provider.id === providerId) || null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** provider 专属的环境变量名(新口径)。 */
|
|
51
|
+
export function providerEnvName(providerId) {
|
|
52
|
+
return `DSH_PREPROCESS_${String(providerId).toUpperCase()}_CLI`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 解析某个 provider 的可执行入口。
|
|
57
|
+
* @param {string} providerId
|
|
58
|
+
* @returns {{ok: true, path: string, source: string, provider: object} | {ok: false, error: string}}
|
|
59
|
+
*/
|
|
60
|
+
export function resolveProvider(providerId = DEFAULT_PROVIDER_ID) {
|
|
61
|
+
const definition = getProviderDefinition(providerId);
|
|
62
|
+
if (!definition) {
|
|
63
|
+
return { ok: false, error: `未知的预处理 provider「${providerId}」(已注册:${PROVIDERS.map((p) => p.id).join(' / ')})` };
|
|
64
|
+
}
|
|
65
|
+
const candidates = [];
|
|
66
|
+
// 1) 显式指定(新变量优先,旧变量兜底)
|
|
67
|
+
const fromEnv = String(process.env[providerEnvName(definition.id)] || process.env[definition.legacyEnv] || '').trim();
|
|
68
|
+
if (fromEnv) candidates.push({ path: fromEnv, source: `env:${providerEnvName(definition.id)}` });
|
|
69
|
+
// 2) 插件自己的 node_modules(npm 安装形态)
|
|
70
|
+
candidates.push({
|
|
71
|
+
path: join(PLUGIN_ROOT, 'node_modules', definition.packageName, definition.cliRel),
|
|
72
|
+
source: 'node_modules',
|
|
73
|
+
});
|
|
74
|
+
// 3) 与本插件平级(开发/并列部署形态)
|
|
75
|
+
candidates.push({
|
|
76
|
+
path: join(PLUGIN_ROOT, '..', definition.packageName, definition.cliRel),
|
|
77
|
+
source: 'sibling',
|
|
78
|
+
});
|
|
79
|
+
for (const candidate of candidates) {
|
|
80
|
+
if (existsSync(candidate.path)) {
|
|
81
|
+
return { ok: true, path: resolve(candidate.path), source: candidate.source, provider: definition };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
ok: false,
|
|
86
|
+
error: `找不到预处理实现「${definition.label}」(包 ${definition.packageName}/${definition.cliRel})`
|
|
87
|
+
+ `(已查:${candidates.map((c) => c.path).join(' / ')})。`
|
|
88
|
+
+ `修复:把它装到插件 node_modules、与本插件平级放置,或用 ${providerEnvName(definition.id)} 指定入口。`,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 解析「提交门禁要用的 provider」。
|
|
94
|
+
* 现在只有一个(审计);将来若支持多预处理串行,这里返回有序列表。
|
|
95
|
+
* @returns {{ok: true, provider: object, path: string, source: string} | {ok: false, error: string}}
|
|
96
|
+
*/
|
|
97
|
+
export function resolveGateProvider() {
|
|
98
|
+
return resolveProvider(DEFAULT_PROVIDER_ID);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { PLUGIN_ROOT as preprocessPluginRoot };
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 读取「所有在位 provider 的声明」。
|
|
105
|
+
*
|
|
106
|
+
* 声明来自各包的 `<pkgRoot>/lib/manifest.js`(导出 preprocessManifest)。
|
|
107
|
+
* **这是唯一的能力真相**:CLI 转发、HTTP 路由、工具入口都靠它找「谁提供了什么」,
|
|
108
|
+
* 宿主不写死任何具体实现的能力清单。
|
|
109
|
+
* 不在位(没装/装坏)的 provider 会被跳过并记一条 reason,不抛错——
|
|
110
|
+
* 热插拔语义要求「少一个扩展不影响其他扩展与主流程」。
|
|
111
|
+
*
|
|
112
|
+
* @returns {Promise<{manifests: Array<{provider: object, root: string, manifest: object}>,
|
|
113
|
+
* missing: Array<{provider: object, reason: string}>}>}
|
|
114
|
+
*/
|
|
115
|
+
export async function listProviderManifests() {
|
|
116
|
+
const manifests = [];
|
|
117
|
+
const missing = [];
|
|
118
|
+
for (const definition of PROVIDERS) {
|
|
119
|
+
const resolved = resolveProvider(definition.id);
|
|
120
|
+
if (!resolved.ok) { missing.push({ provider: definition, reason: resolved.error }); continue; }
|
|
121
|
+
const root = dirname(resolved.path);
|
|
122
|
+
const manifestFile = join(root, 'lib', 'manifest.js');
|
|
123
|
+
if (!existsSync(manifestFile)) {
|
|
124
|
+
missing.push({ provider: definition, reason: `缺少声明文件 ${manifestFile}` });
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
const loaded = await import(pathToFileURL(manifestFile).href);
|
|
129
|
+
const manifest = loaded.preprocessManifest || loaded.default;
|
|
130
|
+
if (!manifest || typeof manifest !== 'object') {
|
|
131
|
+
missing.push({ provider: definition, reason: `${manifestFile} 未导出 preprocessManifest` });
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
manifests.push({ provider: definition, root, manifest });
|
|
135
|
+
} catch (error) {
|
|
136
|
+
missing.push({ provider: definition, reason: `加载 ${manifestFile} 失败:${error?.message || error}` });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return { manifests, missing };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 从所有在位 provider 的声明里,找到「声明了这个 action 的那个」。
|
|
144
|
+
* CLI 的 `preprocess <action>` 与 HTTP 的 `/api/preprocess/<action>` 都走这里,
|
|
145
|
+
* 两边口径自然一致(同一份声明、同一套查找)。
|
|
146
|
+
* @param {string} action
|
|
147
|
+
* @returns {Promise<{provider: object, root: string, manifest: object, action: object} | null>}
|
|
148
|
+
*/
|
|
149
|
+
export async function findActionProvider(action) {
|
|
150
|
+
const name = String(action || '').trim();
|
|
151
|
+
if (!name) return null;
|
|
152
|
+
const { manifests } = await listProviderManifests();
|
|
153
|
+
for (const entry of manifests) {
|
|
154
|
+
const declared = Array.isArray(entry.manifest.actions) ? entry.manifest.actions : [];
|
|
155
|
+
const hit = declared.find((item) => item && item.action === name);
|
|
156
|
+
if (hit) return { ...entry, action: hit };
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 从所有在位 provider 的声明里,找到「声明了这个 HTTP 子端点的那个」。
|
|
163
|
+
* 与 findActionProvider 同源(同一份 manifest),只是查 endpoints 而不是 actions。
|
|
164
|
+
* @param {string} subPath 子端点路径,如 'rule-slots'
|
|
165
|
+
* @param {string} [method] HTTP 方法(给了就一并匹配)
|
|
166
|
+
*/
|
|
167
|
+
export async function findEndpointProvider(subPath, method) {
|
|
168
|
+
const target = String(subPath || '').replace(/^\/+/, '');
|
|
169
|
+
const { manifests } = await listProviderManifests();
|
|
170
|
+
for (const entry of manifests) {
|
|
171
|
+
const declared = Array.isArray(entry.manifest.endpoints) ? entry.manifest.endpoints : [];
|
|
172
|
+
const hit = declared.find((item) => item && item.path === target
|
|
173
|
+
&& (!method || String(item.method || 'GET').toUpperCase() === String(method).toUpperCase()));
|
|
174
|
+
if (hit) return { ...entry, endpoint: hit };
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** 所有已声明能力的汇总(供 help / 路由清单展示)。 */
|
|
180
|
+
export async function listDeclaredCapabilities() {
|
|
181
|
+
const { manifests, missing } = await listProviderManifests();
|
|
182
|
+
return {
|
|
183
|
+
actions: manifests.flatMap((entry) => (entry.manifest.actions || []).map((action) => ({
|
|
184
|
+
provider: entry.provider.id, root: entry.root, ...action,
|
|
185
|
+
}))),
|
|
186
|
+
endpoints: manifests.flatMap((entry) => (entry.manifest.endpoints || []).map((endpoint) => ({
|
|
187
|
+
provider: entry.provider.id, root: entry.root, ...endpoint,
|
|
188
|
+
}))),
|
|
189
|
+
missing,
|
|
190
|
+
};
|
|
191
|
+
}
|
package/lib/self/index.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
export const VERSION = '
|
|
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:
|
|
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
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
36
|
-
*
|
|
12
|
+
* 跳过目录基线。
|
|
13
|
+
* - `node_modules` / `.git`:任何仓库都该跳
|
|
14
|
+
* - `node_modules.orig` / `node_modules.bak`:安装/降级留下的完整副本,
|
|
15
|
+
* 里面同样是依赖代码,扫它既慢又会产生大量无关敏感命中
|
|
16
|
+
* 其余目录(dist/build/vendor/.dsh/.trash…)不写死——需要时由调用方显式传参。
|
|
37
17
|
*/
|
|
38
|
-
export
|
|
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
|
-
*
|
|
61
|
-
*
|
|
21
|
+
* 最终跳过目录集合。
|
|
22
|
+
* 保留函数形态(而非直接导出 Set)是为了调用方不必关心「以后会不会再合并别的来源」。
|
|
62
23
|
*/
|
|
63
24
|
export function getSkipSet() {
|
|
64
|
-
|
|
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,22 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-git-push",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.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
19
|
"scripts",
|
|
17
20
|
"assets",
|
|
18
21
|
"cli.mjs",
|
|
19
|
-
"cli-audit.mjs",
|
|
20
22
|
"cli-tool.mjs",
|
|
21
23
|
"cordis.patch.yml",
|
|
22
24
|
"README.md",
|
|
@@ -24,11 +26,31 @@
|
|
|
24
26
|
".auditignore",
|
|
25
27
|
".gitignore"
|
|
26
28
|
],
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"audit-sluice": "./cli-audit.mjs",
|
|
30
|
-
"tool-sluice": "./cli-tool.mjs"
|
|
29
|
+
"optionalDependencies": {
|
|
30
|
+
"audit-sluice": "0.1.0"
|
|
31
31
|
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.0.0"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build:client": "node scripts/build-client.mjs",
|
|
37
|
+
"prepare": "node scripts/build-client.mjs",
|
|
38
|
+
"prepack": "node scripts/build-client.mjs",
|
|
39
|
+
"test": "node test/run-tests.mjs",
|
|
40
|
+
"check": "node scripts/check.mjs"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"dsh",
|
|
44
|
+
"dsh-plugin",
|
|
45
|
+
"deepseek-harness",
|
|
46
|
+
"git",
|
|
47
|
+
"commit",
|
|
48
|
+
"push",
|
|
49
|
+
"audit",
|
|
50
|
+
"cli"
|
|
51
|
+
],
|
|
52
|
+
"author": "EIGHTfs",
|
|
53
|
+
"license": "MIT",
|
|
32
54
|
"dsh": {
|
|
33
55
|
"bundle": {
|
|
34
56
|
"patch": "./cordis.patch.yml"
|
|
@@ -44,7 +66,6 @@
|
|
|
44
66
|
"./skills/dsh-repo-index.md",
|
|
45
67
|
"./skills/dev/dsh-git-push.md",
|
|
46
68
|
"./skills/dev/git-push-live-fix.md",
|
|
47
|
-
"./skills/guide/guide-audit.md",
|
|
48
69
|
"./skills/guide/guide-cli-scripts.md",
|
|
49
70
|
"./skills/guide/guide-clone-repos.md",
|
|
50
71
|
"./skills/guide/guide-commit-push.md",
|
|
@@ -61,8 +82,6 @@
|
|
|
61
82
|
"./skills/workflow/versioning-rule.md"
|
|
62
83
|
]
|
|
63
84
|
},
|
|
64
|
-
"license": "MIT",
|
|
65
|
-
"author": "EIGHTfs",
|
|
66
85
|
"repository": {
|
|
67
86
|
"type": "git",
|
|
68
87
|
"url": "git+https://github.com/EIGHTfs/dsh-git-push.git"
|
|
@@ -71,37 +90,10 @@
|
|
|
71
90
|
"url": "https://github.com/EIGHTfs/dsh-git-push/issues"
|
|
72
91
|
},
|
|
73
92
|
"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
93
|
"peerDependencies": {
|
|
88
94
|
"@deepseek-ai/dsh-tools": ">=0.1.6-0 <0.3.0-0",
|
|
89
95
|
"@deepseek-ai/schemastery": ">=3.0.0 <4.0.0-0"
|
|
90
96
|
},
|
|
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
97
|
"dshScopeCheck": {
|
|
106
98
|
"note": "拼接产物作用域检查:files 里每个文件都查「同作用域重名 / 顶层声明 / 命名前缀」。查法:git-sluice scope-check(无参数即读本块 files);其它项目只要在自己的 package.json 写同名字段即可复用同一套判定",
|
|
107
99
|
"files": [
|
package/scripts/build-client.mjs
CHANGED
|
@@ -33,6 +33,8 @@ export const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
|
33
33
|
// 也不会因「缺片」报错(缺片检查只针对 PART_ORDER 里列出的片)。
|
|
34
34
|
export const PARTS_DIR = join(ROOT, 'lib', 'client-parts', 'git');
|
|
35
35
|
/** 不参与构建的分片目录(只做归档,构建脚本不读、不校验)。 */
|
|
36
|
+
// 审计前端分片已随审计能力迁出宿主(现在在 audit-sluice 包的 lib/ui/audit-tab.js)。
|
|
37
|
+
// 这里保留一个只读路径常量供历史脚本引用;目录不存在时调用方应按「无归档分片」处理。
|
|
36
38
|
export const ARCHIVE_PARTS_DIR = join(ROOT, 'lib', 'client-parts', 'audit');
|
|
37
39
|
export const OUT_FILE = join(ROOT, 'lib', 'client.js');
|
|
38
40
|
|
package/scripts/check.mjs
CHANGED
|
@@ -43,7 +43,9 @@ function collectJson(dir, acc = []) {
|
|
|
43
43
|
|
|
44
44
|
// 三个 CLI 入口都要做语法检查:它们不是 lib/ 下的文件,靠 collectJs 收不到——
|
|
45
45
|
// 漏检的后果是「新入口语法错,但门禁全绿」(与被拆出来的入口一起构成盲区)。
|
|
46
|
-
|
|
46
|
+
// 只检查现存入口:审计 CLI 已随审计能力独立成包(audit-sluice),宿主不再提供 cli-audit.mjs。
|
|
47
|
+
const CLI_ENTRY_FILES = ['cli.mjs', 'cli-tool.mjs'];
|
|
48
|
+
const CLI_ENTRIES = CLI_ENTRY_FILES.map((name) => join(ROOT, name));
|
|
47
49
|
const files = [...collectJs(join(ROOT, 'lib')), ...CLI_ENTRIES];
|
|
48
50
|
// docs/*.json 也必须能解析:版本表与发版说明直接依赖 docs/releases.json,
|
|
49
51
|
// 而它曾在 2.8.4 因一个尾随逗号变成非法 JSON 却**四项门禁全绿**(缺口)——这类错误必须在门禁里变红 ✗
|
|
@@ -96,7 +98,7 @@ try {
|
|
|
96
98
|
// ① 同作用域重名(var/function 静默覆盖的触发条件,始终检查);
|
|
97
99
|
// ② 文件顶层零声明;③ 共享作用域命名前缀。
|
|
98
100
|
try {
|
|
99
|
-
const { analyzeScopeCollisions } = await import('
|
|
101
|
+
const { analyzeScopeCollisions } = await import('../../audit-sluice/lib/ast/scope-collisions.js');
|
|
100
102
|
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
|
|
101
103
|
const cfg = pkg?.dshScopeCheck;
|
|
102
104
|
const files = Array.isArray(cfg?.files) && cfg.files.length ? cfg.files : [];
|
|
@@ -20,7 +20,8 @@ if (args.includes('--selftest')) {
|
|
|
20
20
|
const r = await runLocalPreview({
|
|
21
21
|
dir: repo,
|
|
22
22
|
tag: 'beta',
|
|
23
|
-
|
|
23
|
+
// 只验包自己的公开面:审计子路径(dsh-git-push/audit)已随审计能力迁出
|
|
24
|
+
entrySpecs: ['dsh-git-push'],
|
|
24
25
|
});
|
|
25
26
|
for (const s of r.steps) console.log(` ${s.ok ? 'OK ' : 'FAIL'} ${s.step}${s.distTags ? ` → dist-tags ${JSON.stringify(s.distTags)}` : ''}`);
|
|
26
27
|
if (r.failures.length) console.log('失败:\n' + r.failures.map((f) => ` - ${f}`).join('\n'));
|
package/cli-audit.mjs
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// dsh-skip-i18n: CLI 输出硬编码中文为产品行为(无 i18n 需求)
|
|
3
|
-
/**
|
|
4
|
-
* dsh-git-push 独立 CLI · **审计侧**(bin: audit-sluice)
|
|
5
|
-
* 不依赖 DSH 运行时,可独立运行。
|
|
6
|
-
*
|
|
7
|
-
* 为什么单独一个入口(而不是继续挂在 git-sluice 里):
|
|
8
|
-
* 审计引擎上一轮已经解耦成「可配置子进程」,但入口层如果还共用,用户仍得敲
|
|
9
|
-
* `git-sluice audit` 才能跑到审计——「审计侧独立」只做了一半。现在审计有自己的 CLI,
|
|
10
|
-
* 换引擎(含换语言重写)与换 CLI 组合互不影响。
|
|
11
|
-
*
|
|
12
|
-
* ⚠️⚠️ 两条**纯副作用 import** 是本入口的生命线(删了不报错、少了不报错,只会让功能静默失效):
|
|
13
|
-
* ① ./lib/app/host-doc-checks.js —— 目录树漂移 / 函数列表漂移两类检查器由宿主注入。
|
|
14
|
-
* 漏搬后果:同一棵树上这两类 finding **整类消失**(实测少 4 条),审计照常「通过」。
|
|
15
|
-
* ② ./lib/rule/compilers.js —— 规则编译函数注册(13 种)。
|
|
16
|
-
* 漏搬后果:`ruleset` 命令编译出 0 条规则却报「OK」。
|
|
17
|
-
* (`audit` 走 lib/audit/index.js,那条路径自身也会注册编译器;但 `ruleset` 不走审计编排,
|
|
18
|
-
* 必须靠本文件的显式 import。两处都留是刻意的冗余——这类静默失效不值得省一行 import。)
|
|
19
|
-
*
|
|
20
|
-
* 本文件只保留:命令表 + HELP 文本 + 薄壳。解析/打印/分发/跨侧提示都在 lib/cli/shared.mjs。
|
|
21
|
-
*/
|
|
22
|
-
import './lib/app/host-doc-checks.js'; // 副作用①:文档漂移检查器接线(审计专用)
|
|
23
|
-
import './lib/rule/compilers.js'; // 副作用②:规则编译函数注册(audit / ruleset 依赖)
|
|
24
|
-
|
|
25
|
-
import { VERSION } from './lib/self/index.js';
|
|
26
|
-
import { loadRuleFiles } from './lib/rule/loader.js';
|
|
27
|
-
import { compileAllRules } from './lib/rule/registry.js';
|
|
28
|
-
|
|
29
|
-
import {
|
|
30
|
-
cmdAudit, cmdScan, pluginEqualAuditOpts, pluginEqualWeights, cliPluginConfig,
|
|
31
|
-
} from './lib/cli/commands-audit.mjs';
|
|
32
|
-
import { cmdLinkCheck } from './lib/cli/commands-vcs.mjs';
|
|
33
|
-
import { cmdFileIo, cmdTreeDoc, cmdFunctions } from './lib/cli/commands-doc.mjs';
|
|
34
|
-
import {
|
|
35
|
-
CLI_AUDIT, CLI_ENTRIES, printToolResult, parseArgv, parseVia, runAsEntry, runCli,
|
|
36
|
-
} from './lib/cli/shared.mjs';
|
|
37
|
-
|
|
38
|
-
export const CLI_NAME = CLI_AUDIT;
|
|
39
|
-
|
|
40
|
-
/** parseArgv 认识的选项白名单(本侧 HELP 写着的那批;self-check 机器比对本表与 HELP 文本)。
|
|
41
|
-
* 注:**注册表驱动**命令(file-io / link-check / scope-check)的参数由
|
|
42
|
-
* lib/app/command-registry.js 的 params 校验,与本表无关;本侧 HELP 写了的 flag 必须在本表出现。 */
|
|
43
|
-
export const KNOWN_FLAGS = [
|
|
44
|
-
'--allowlist', '--files', '--full', '--history', '--include-ignored', '--json', '--out', '--prefix', '--readme',
|
|
45
|
-
'--repo', '--root', '--ruleset', '--since', '--skip-empty', '--top-level-must-be-empty', '--until', '--weights',
|
|
46
|
-
'--write', '--write-only',
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
const HELP = `audit-sluice v${VERSION} — ${CLI_ENTRIES[CLI_AUDIT].intro}
|
|
50
|
-
|
|
51
|
-
快速开始(第一次用——不用查源码):
|
|
52
|
-
audit-sluice audit . ① 审计当前仓库(默认只看本次改动)
|
|
53
|
-
audit-sluice audit . --full ② 全量审计(评分 + 问题明细)
|
|
54
|
-
audit-sluice ruleset ③ 规则包是否能编译(改规则后先跑它)
|
|
55
|
-
audit-sluice help 全部命令与参数
|
|
56
|
-
|
|
57
|
-
其它 CLI(本入口不含,敲错会给出替代命令):
|
|
58
|
-
git-sluice 提交/推送/克隆/账号/仓库扫描: scan commit clone remote-create rename set-visibility identity-rewrite account-check cred-env gen-ssh-key git api repos index npm-publish unpublish
|
|
59
|
-
tool-sluice 工具链: module-splitter yaml-template readme-template self-check
|
|
60
|
-
|
|
61
|
-
用法(每行写的参数就是该命令真实接受的写法,照抄即可):
|
|
62
|
-
audit-sluice version 查看版本
|
|
63
|
-
audit-sluice audit <root> [--full] [--ruleset <目录>] [--weights <JSON>] [--include-ignored] [--history [--since <提交>] [--until <提交>] [--out <目录>]] [--json]
|
|
64
|
-
审计目录(默认 diff 范围;--full=全量;--ruleset=自定规则目录;--weights=权重覆盖 JSON;
|
|
65
|
-
--include-ignored=连 .gitignore 忽略的文件也扫描;--history=历史提交审计——逐提交快照全量审计并落盘报告,
|
|
66
|
-
--since/--until 起始~结束提交(皆缺省=全部历史、含两端),--out 报告保存目录(缺省=git 根 audit-history/))
|
|
67
|
-
audit-sluice ruleset [槽位...] 编译规则包并输出统计(默认全部槽位)
|
|
68
|
-
audit-sluice file-io [路径] [--write-only]
|
|
69
|
-
文件读写调用扫描(同步 I/O 在异步路径会阻塞;写/删/改名涉及数据安全);--write-only=只看写操作。
|
|
70
|
-
按类型/操作/风险分组的明细走 code_audit 工具的 io_scan 结果
|
|
71
|
-
audit-sluice link-check <路径> 检查 md/文本中的链接有效性(只 warning,flaky 域名打折)
|
|
72
|
-
audit-sluice scope-check [文件...] [--files <文件,文件>] [--repo <目录>] [--prefix <前缀>] [--allowlist <名,名>] [--top-level-must-be-empty] [--json]
|
|
73
|
-
拼接产物作用域撞名(多段 JS 拼进同一作用域):同一函数帧内重名会让后者静默顶掉前者,运行期毫无线索;
|
|
74
|
-
判定按真实作用域帧(两个不同函数里的同名局部变量不算撞名);顶层声明与命名前缀按被查项目自己的 package.json(dshScopeCheck)判定,
|
|
75
|
-
没声明就只查同帧重名(不拿本项目的命名前缀去要求别人);不给文件时取该项目 dshScopeCheck.files
|
|
76
|
-
audit-sluice functions <analyze|apply> [目录] [--skip-empty] [--json]
|
|
77
|
-
函数索引与函数文档:analyze 生成 functions-index.json(含签名/注释槽位);
|
|
78
|
-
apply 读 JSON(人工补 comment 后)生成 docs/函数 下的 md(文件删除归档 _archived,注释不丢)
|
|
79
|
-
audit-sluice tree-doc <sync|gen|check|apply> [--root <目录>] [--readme <路径>] [--write]
|
|
80
|
-
README 目录结构维护:sync 索引同步(新增自动加键/删除自动删键);gen 生成树;
|
|
81
|
-
check 检查漂移;apply 覆盖 README/FILE-TREE 标记块(封装 scripts/doc-tree.mjs)
|
|
82
|
-
audit-sluice help 显示本帮助
|
|
83
|
-
`;
|
|
84
|
-
|
|
85
|
-
/** 子命令:ruleset — 编译规则包输出统计(依赖本文件顶部的 compilers 副作用 import)。 */
|
|
86
|
-
export function cmdRuleset(slots = []) {
|
|
87
|
-
const order = slots.length ? slots : null; // null=动态发现全部槽位
|
|
88
|
-
const { ok, merged, errors, files, order: effective } = loadRuleFiles(order);
|
|
89
|
-
const ctx = { errors: [] };
|
|
90
|
-
const compiled = compileAllRules(merged.rules, ctx);
|
|
91
|
-
if (!ok || ctx.errors.length) {
|
|
92
|
-
console.error('规则编译失败:');
|
|
93
|
-
for (const failure of [...errors, ...ctx.errors]) console.error(' ✗ ' + failure);
|
|
94
|
-
process.exitCode = 1;
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
console.log(`规则包编译 OK(${effective.join('+')})`);
|
|
98
|
-
console.log(` 文件: ${files.length} 个槽位, 规则条目 ${merged.rules.length}, 编译成功 ${compiled.length}`);
|
|
99
|
-
const byKind = {};
|
|
100
|
-
for (const rule of compiled) {
|
|
101
|
-
const kind = rule.kind || rule.type || 'other';
|
|
102
|
-
byKind[kind] = (byKind[kind] || 0) + 1;
|
|
103
|
-
}
|
|
104
|
-
for (const [kind, count] of Object.entries(byKind)) console.log(` ${kind}: ${count}`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** 命令表(本侧独有的 COMMANDS;注册表驱动的 file-io / link-check / scope-check 由 shared 分发)。 */
|
|
108
|
-
export const COMMANDS = new Map([
|
|
109
|
-
['ruleset', (rest) => cmdRuleset(rest)],
|
|
110
|
-
// audit 不走注册表——CLI 独立审计需完整 findings(不依赖宿主 API);工具 code_audit 输出 API 指引
|
|
111
|
-
['audit', parseVia((flags, positional) => cmdAudit(positional[0] || '.', flags))],
|
|
112
|
-
['functions', parseVia((flags, positional) => cmdFunctions(positional[0] || '', positional[1] || '', flags))],
|
|
113
|
-
['tree-doc', parseVia((flags, positional) => cmdTreeDoc(positional[0] || '', flags))],
|
|
114
|
-
// 兼容:scan 属于 git 侧(注册表 git_scan);此处保留导出给老代码直调,不注册进命令表
|
|
115
|
-
]);
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* 入口 main。
|
|
119
|
-
* @param {string[]} argv
|
|
120
|
-
* @returns {Promise<number|undefined>}
|
|
121
|
-
*/
|
|
122
|
-
export async function main(argv = process.argv.slice(2)) {
|
|
123
|
-
return await runCli({
|
|
124
|
-
cliName: CLI_AUDIT,
|
|
125
|
-
argv,
|
|
126
|
-
commands: COMMANDS,
|
|
127
|
-
helpText: HELP,
|
|
128
|
-
getConfig: cliPluginConfig,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
runAsEntry(import.meta.url, main);
|
|
133
|
-
|
|
134
|
-
// 兼容导出(审计侧实现的老引用路径)
|
|
135
|
-
export { cmdAudit, cmdScan, cmdLinkCheck, cmdFileIo, cmdTreeDoc, cmdFunctions };
|
|
136
|
-
export { pluginEqualAuditOpts, pluginEqualWeights, cliPluginConfig, parseArgv, printToolResult };
|
|
137
|
-
|
|
138
|
-
/** 子命令:version(三入口同一实现,只有名字不同)。 */
|
|
139
|
-
export function cmdVersion() {
|
|
140
|
-
console.log(`audit-sluice v${VERSION} — dsh-git-push(统一函数入口架构)`);
|
|
141
|
-
}
|