dsh-git-push 2.18.2 → 2.20.17
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/.gitignore +4 -0
- package/README.md +12 -5
- package/cli-audit.mjs +141 -0
- package/cli-tool.mjs +86 -0
- package/cli.mjs +116 -324
- package/lib/ARCHITECTURE.md +3 -0
- package/lib/app/audit-api.js +1 -1
- package/lib/app/command-registry.js +16 -3
- package/lib/app/constants.js +9 -0
- package/lib/app/handlers/clone.js +12 -3
- package/lib/app/handlers/http-constants.js +11 -2
- package/lib/app/handlers/npm.js +4 -2
- package/lib/app/handlers/repos.js +10 -1
- package/lib/app/handlers/settings.js +9 -1
- package/lib/app/http-handlers.js +24 -3
- package/lib/app/inject-text.js +1 -0
- package/lib/app/schema-audit.js +42 -0
- package/lib/app/schema.js +19 -19
- package/lib/app/scope-check.js +69 -0
- package/lib/app/settings-bridge.js +51 -0
- package/lib/app/tool-call.js +56 -7
- package/lib/ast/credential.js +130 -14
- package/lib/ast/dataflow.js +127 -10
- package/lib/ast/index.js +2 -0
- package/lib/ast/naming.js +9 -1
- package/lib/ast/scope-collisions.js +228 -0
- package/lib/ast/treesitter.js +142 -1
- package/lib/audit/history.js +1 -1
- package/lib/audit/orchestrate.js +93 -6
- package/lib/audit/scope-policy.js +110 -0
- package/lib/audit-rules/audit-rules-dsh.yml +16 -1
- package/lib/audit-rules/audit-rules-nodejs.yml +21 -6
- package/lib/audit-rules/audit-rules-paths.yml +7 -1
- package/lib/audit-ui-sdk/contract.js +117 -0
- package/lib/audit-ui-sdk/index.js +17 -0
- package/lib/checks/common.js +4 -4
- package/lib/checks/dispatch.js +5 -0
- package/lib/checks/index.js +2 -0
- package/lib/checks/regex.js +8 -3
- package/lib/checks/scope-collision.js +68 -0
- package/lib/cli/commands-audit.mjs +13 -18
- package/lib/cli/commands-tool.mjs +93 -0
- package/lib/cli/commands-vcs.mjs +2 -1
- package/lib/cli/shared.mjs +448 -0
- package/lib/client-parts/{account.js → git/account.js} +1 -1
- package/lib/client-parts/{actions.js → git/actions.js} +26 -11
- package/lib/client-parts/{apply.js → git/apply.js} +1 -1
- package/lib/client-parts/{browser.js → git/browser.js} +1 -1
- package/lib/client-parts/{const.js → git/const.js} +6 -1
- package/lib/client-parts/{controller.js → git/controller.js} +23 -11
- package/lib/client-parts/{icons.js → git/icons.js} +1 -1
- package/lib/client-parts/{loader.js → git/loader.js} +1 -1
- package/lib/client-parts/{npm.js → git/npm.js} +1 -1
- package/lib/client-parts/{page.js → git/page.js} +11 -21
- package/lib/client-parts/{repo.js → git/repo.js} +1 -1
- package/lib/client-parts/{settings.js → git/settings.js} +1 -1
- package/lib/client-parts/{utils.js → git/utils.js} +1 -1
- package/lib/client.js +75 -354
- package/lib/commit-push/pre-commit-engine.js +388 -0
- package/lib/commit-push.js +44 -17
- package/lib/exempt/index.js +5 -2
- package/lib/git/ignore.js +6 -4
- package/lib/git/init-compat.js +83 -4
- package/lib/git/push.js +25 -2
- package/lib/git/sensitive.js +30 -1
- package/lib/git/transport.js +31 -10
- package/lib/http/index.js +82 -10
- package/lib/lint-adapter/detect.js +161 -0
- package/lib/lint-adapter/index.js +50 -0
- package/lib/lint-adapter/runner.js +133 -0
- package/lib/npm/npmrc.js +22 -5
- package/lib/rule/compilers/structure.js +24 -0
- package/lib/score/index.js +36 -4
- package/lib/self/index.js +1 -1
- package/package.json +25 -2
- package/scripts/audit-gate.mjs +235 -0
- package/scripts/build-client.mjs +15 -8
- package/scripts/bump-version.mjs +20 -5
- package/scripts/check-js-scope.mjs +87 -0
- package/scripts/check.mjs +51 -4
- package/scripts/scan-file-io.mjs +5 -1
- package/scripts/scan-version.mjs +10 -7
- package/skills/dev/dsh-git-push.md +70 -2
- package/skills/guide/guide-audit.md +11 -11
- package/skills/guide/guide-cli-scripts.md +3 -3
- package/skills/guide/guide-commit-push.md +2 -2
- package/skills/guide/guide-inject-ui.md +0 -16
- package/assets/start.sh +0 -396
- package/scripts/scan-hardcoded-paths.mjs +0 -125
- /package/lib/client-parts/{audit.js → audit/audit.js} +0 -0
package/scripts/bump-version.mjs
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* node scripts/bump-version.mjs --message "…" --apply # 真写盘
|
|
16
16
|
* node scripts/bump-version.mjs --to 2.11.0 --message "…" --apply # 指定版本(默认 patch +1)
|
|
17
17
|
* node scripts/bump-version.mjs --message-file /tmp/msg.txt --apply
|
|
18
|
+
* node scripts/bump-version.mjs --message "…" --comment "VERSION 行用的短摘要(可选)" --apply
|
|
18
19
|
*
|
|
19
20
|
* 约定:
|
|
20
21
|
* · **默认 dry-run**——只打印将要改动的三处(旧值 → 新值),不落盘;确认无误再加 --apply。
|
|
@@ -36,13 +37,14 @@ const RELEASES = join(ROOT, 'docs', 'releases.json');
|
|
|
36
37
|
|
|
37
38
|
/** 解析命令行参数(只认 --flag value 与布尔 --apply)。 */
|
|
38
39
|
function parseArgs(argv) {
|
|
39
|
-
const out = { apply: false, to: '', message: '', messageFile: '' };
|
|
40
|
+
const out = { apply: false, to: '', message: '', messageFile: '', comment: '' };
|
|
40
41
|
for (let i = 0; i < argv.length; i++) {
|
|
41
42
|
const a = argv[i];
|
|
42
43
|
if (a === '--apply') { out.apply = true; continue; }
|
|
43
44
|
if (a === '--message' || a === '-m') { out.message = argv[++i] || ''; continue; }
|
|
44
45
|
if (a === '--message-file') { out.messageFile = argv[++i] || ''; continue; }
|
|
45
46
|
if (a === '--to') { out.to = argv[++i] || ''; continue; }
|
|
47
|
+
if (a === '--comment') { out.comment = argv[++i] || ''; continue; }
|
|
46
48
|
}
|
|
47
49
|
return out;
|
|
48
50
|
}
|
|
@@ -71,8 +73,14 @@ function readJson(p) {
|
|
|
71
73
|
* 拼新的 VERSION 行。
|
|
72
74
|
* 旧注释形如:`2.10.4:本次说明。历史:2.10.3:更早说明。` → 把「本次说明」降级进历史链,
|
|
73
75
|
* 只保留最近 2 条,避免每版都把整串历史再抄一遍(实测 2.9.x 之后该行已接近不可读)。
|
|
76
|
+
*
|
|
77
|
+
* ⚠️ **行注释必须单行**:`--message-file` 常带多段落,若原样写进 `//` 后面的注释,
|
|
78
|
+
* 换行会把文件撕成多行 → 整个 lib/self/index.js 语法错误(ESM 加载期就炸,
|
|
79
|
+
* `node cli.mjs` 直接 TypeError)。故此处按「首段首句」压成一行摘要,
|
|
80
|
+
* 正文完整内容仍原样进 docs/releases.json(那边是 JSON 字符串,换行合法)。
|
|
81
|
+
* 需要更长摘要时用 `--comment` 显式给。
|
|
74
82
|
*/
|
|
75
|
-
function buildVersionLine(oldLine, newVer, oldVer, message) {
|
|
83
|
+
function buildVersionLine(oldLine, newVer, oldVer, message, commentOverride = '') {
|
|
76
84
|
const m = /export const VERSION = '([^']+)';\s*\/\/(.*)$/.exec(oldLine);
|
|
77
85
|
const oldComment = m ? m[2].trim() : '';
|
|
78
86
|
// 旧版本的「本次说明」= 历史链之前的那一段
|
|
@@ -82,8 +90,12 @@ function buildVersionLine(oldLine, newVer, oldVer, message) {
|
|
|
82
90
|
// 历史链:新压入的旧版摘要 + 原有最近 1 条
|
|
83
91
|
const prev = oldMain ? [`${oldVer}:${oldMain}`] : [];
|
|
84
92
|
const kept = oldHist ? oldHist.split(/。\s*(?=[\d.]+:)/).slice(0, 1).map((s) => s.replace(/。$/, '')) : [];
|
|
85
|
-
const chain = [...prev, ...kept].join('。');
|
|
86
|
-
|
|
93
|
+
const chain = prev.length || kept.length ? [...prev, ...kept].join('。').replace(/。+/g, '。') : '';
|
|
94
|
+
// 本轮摘要:显式覆盖优先;否则取首段首句,超长截断
|
|
95
|
+
const oneLine = String(commentOverride || message).replace(/\s+/g, ' ').trim();
|
|
96
|
+
const firstSentence = oneLine.split(/。/)[0].trim();
|
|
97
|
+
const summary = firstSentence.length > 160 ? `${firstSentence.slice(0, 160)}…` : firstSentence;
|
|
98
|
+
const comment = `${newVer}:${summary}。` + (chain ? `历史:${chain}。` : '');
|
|
87
99
|
return `export const VERSION = '${newVer}'; // ${comment}`;
|
|
88
100
|
}
|
|
89
101
|
|
|
@@ -107,7 +119,10 @@ const selfLines = selfSrc.split('\n');
|
|
|
107
119
|
const vi = selfLines.findIndex((l) => /^export const VERSION = '/.test(l));
|
|
108
120
|
if (vi < 0) fail('lib/self/index.js 未找到 VERSION 行');
|
|
109
121
|
const oldLine = selfLines[vi];
|
|
110
|
-
const newLine = buildVersionLine(oldLine, target, cur, message);
|
|
122
|
+
const newLine = buildVersionLine(oldLine, target, cur, message, args.comment);
|
|
123
|
+
// 硬门禁:行注释一旦带换行就把整个 lib/self/index.js 撕成多行(ESM 加载期直接抛
|
|
124
|
+
// "Invalid or unexpected token",cli.mjs / 插件入口全部起不来)。宁可在写盘前失败。
|
|
125
|
+
if (/[\r\n]/.test(newLine)) fail('VERSION 行必须是单行(注释里的换行会破坏整个模块语法)');
|
|
111
126
|
|
|
112
127
|
// ── 预览(默认 dry-run)
|
|
113
128
|
console.log(`升版:${cur} → ${target}${args.apply ? '(--apply 真写盘)' : '(dry-run,未写盘)'}`);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 拼接产物作用域撞名检查(独立 CLI;判定与策略逻辑在 lib/,与 `git-sluice scope-check` 同一份)。
|
|
4
|
+
*
|
|
5
|
+
* 用法:
|
|
6
|
+
* node scripts/check-js-scope.mjs <file.js> [...] [--prefix=dshgp_] [--allowlist=a,b] [--top=true|false] [--json]
|
|
7
|
+
* node scripts/check-js-scope.mjs --config package.json # 读该 package.json 的 dshScopeCheck.files
|
|
8
|
+
*
|
|
9
|
+
* 参数名与 `git-sluice scope-check` 对齐(allowlist,旧写法 --allow 仍认)。
|
|
10
|
+
* 约定按**文件所属项目**取:别人项目没声明 dshScopeCheck 时只查「同帧重名」,
|
|
11
|
+
* 不会拿本项目的 dshgp_ 前缀去要求它(实测:那会刷一屏与它无关的告警)。
|
|
12
|
+
*/
|
|
13
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
14
|
+
import { dirname, join, resolve } from 'node:path';
|
|
15
|
+
import { fileURLToPath } from 'node:url';
|
|
16
|
+
|
|
17
|
+
import { runScopeCheck } from '../lib/app/scope-check.js';
|
|
18
|
+
|
|
19
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
20
|
+
const argv = process.argv.slice(2);
|
|
21
|
+
const VALUE_FLAGS = new Set(['config', 'prefix', 'allowlist', 'allow', 'top']);
|
|
22
|
+
|
|
23
|
+
const { flags, positional } = (() => {
|
|
24
|
+
const out = { flags: new Map(), positional: [] };
|
|
25
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
26
|
+
const token = argv[i];
|
|
27
|
+
if (!token.startsWith('--')) { out.positional.push(token); continue; }
|
|
28
|
+
const body = token.slice(2);
|
|
29
|
+
if (body.includes('=')) {
|
|
30
|
+
const [k, ...rest] = body.split('=');
|
|
31
|
+
out.flags.set(k, rest.join('='));
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (VALUE_FLAGS.has(body) && i + 1 < argv.length && !argv[i + 1].startsWith('--')) {
|
|
35
|
+
out.flags.set(body, argv[i + 1]);
|
|
36
|
+
i += 1;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
out.flags.set(body, 'true');
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
})();
|
|
43
|
+
const wantJson = flags.has('json');
|
|
44
|
+
|
|
45
|
+
/** --config 指定的项目:只用它的 files 列表,**不**把它的 prefix 套给别的项目文件。 */
|
|
46
|
+
function filesFromConfig(path) {
|
|
47
|
+
if (!path || !existsSync(path)) return [];
|
|
48
|
+
try {
|
|
49
|
+
const cfg = JSON.parse(readFileSync(path, 'utf8'))?.dshScopeCheck;
|
|
50
|
+
const base = dirname(resolve(path));
|
|
51
|
+
return Array.isArray(cfg?.files) ? cfg.files.map((f) => resolve(base, f)) : [];
|
|
52
|
+
} catch { return []; }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const configPath = flags.get('config') || '';
|
|
56
|
+
const targets = positional.length ? positional.map((f) => resolve(f)) : filesFromConfig(configPath);
|
|
57
|
+
if (!targets.length) {
|
|
58
|
+
console.error('用法:node scripts/check-js-scope.mjs <file.js> [...] [--prefix=dshgp_] [--allowlist=a,b] [--json]');
|
|
59
|
+
console.error(' 或 node scripts/check-js-scope.mjs --config package.json(读 dshScopeCheck.files)');
|
|
60
|
+
process.exit(2);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const topFlag = flags.get('top');
|
|
64
|
+
const result = runScopeCheck({
|
|
65
|
+
files: targets,
|
|
66
|
+
prefix: flags.get('prefix') || '',
|
|
67
|
+
// allowlist 为主名(与 git-sluice scope-check 对齐),allow 是旧写法别名
|
|
68
|
+
allowlist: String(flags.get('allowlist') || flags.get('allow') || '').split(',').map((x) => x.trim()).filter(Boolean),
|
|
69
|
+
...(topFlag === 'true' || topFlag === 'false' ? { topLevelMustBeEmpty: topFlag === 'true' } : {}),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (wantJson) {
|
|
73
|
+
console.log(JSON.stringify(result, null, 2));
|
|
74
|
+
} else {
|
|
75
|
+
// 输出头自证策略来源:避免「继承了本项目默认值」被误读成对方的约定
|
|
76
|
+
for (const src of result.policySources) console.log(`策略来源:${src}`);
|
|
77
|
+
for (const r of result.reports) {
|
|
78
|
+
const rel = r.file.replace(process.cwd() + '/', '');
|
|
79
|
+
if (r.ok) {
|
|
80
|
+
console.log(`✔ ${rel}:${r.declarations.length} 个声明,无同帧重名`);
|
|
81
|
+
} else {
|
|
82
|
+
console.error(`✗ ${rel}:`);
|
|
83
|
+
for (const v of r.violations) console.error(` - ${v}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
process.exit(result.ok ? 0 : 1);
|
package/scripts/check.mjs
CHANGED
|
@@ -41,7 +41,10 @@ function collectJson(dir, acc = []) {
|
|
|
41
41
|
return acc;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
// 三个 CLI 入口都要做语法检查:它们不是 lib/ 下的文件,靠 collectJs 收不到——
|
|
45
|
+
// 漏检的后果是「新入口语法错,但门禁全绿」(与被拆出来的入口一起构成盲区)。
|
|
46
|
+
const CLI_ENTRIES = ['cli.mjs', 'cli-audit.mjs', 'cli-tool.mjs'].map((name) => join(ROOT, name));
|
|
47
|
+
const files = [...collectJs(join(ROOT, 'lib')), ...CLI_ENTRIES];
|
|
45
48
|
// docs/*.json 也必须能解析:版本表与发版说明直接依赖 docs/releases.json,
|
|
46
49
|
// 而它曾在 2.8.4 因一个尾随逗号变成非法 JSON 却**四项门禁全绿**(缺口)——这类错误必须在门禁里变红 ✗
|
|
47
50
|
const jsonFiles = [...collectJson(join(ROOT, 'lib')), ...collectJson(join(ROOT, 'docs'))];
|
|
@@ -83,6 +86,42 @@ try {
|
|
|
83
86
|
console.error(`✗ 分片构建校验失败:${e.message}`);
|
|
84
87
|
}
|
|
85
88
|
|
|
89
|
+
// ── 拼接产物作用域门禁(2026-11-05)───────────────────────────────────
|
|
90
|
+
// 背景:lib/client-parts/*.js 是**平铺拼接**的片段,14 个分片最终落在**同一个 factory
|
|
91
|
+
// 函数作用域**里。JS 的 var/function 提升规则是「同名后者覆盖前者且不报错」——
|
|
92
|
+
// 一处重名就让某分片功能在运行时静默失效,且没有任何报错可查。
|
|
93
|
+
// 构建脚本头部早写了「顶层零声明 + dshgp_ 前缀」两条铁律,但此前**只是注释**:
|
|
94
|
+
// 新鲜度门禁只保证「产物 == 分片拼接」,保证不了「拼出来的不撞名」。
|
|
95
|
+
// 检查项(通用实现在 lib/ast/scope-collisions.js,项目差异走 package.json 的 dshScopeCheck):
|
|
96
|
+
// ① 同作用域重名(var/function 静默覆盖的触发条件,始终检查);
|
|
97
|
+
// ② 文件顶层零声明;③ 共享作用域命名前缀。
|
|
98
|
+
try {
|
|
99
|
+
const { analyzeScopeCollisions } = await import('../lib/ast/scope-collisions.js');
|
|
100
|
+
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
|
|
101
|
+
const cfg = pkg?.dshScopeCheck;
|
|
102
|
+
const files = Array.isArray(cfg?.files) && cfg.files.length ? cfg.files : [];
|
|
103
|
+
if (!files.length) {
|
|
104
|
+
console.log('✔ 拼接产物作用域:未配置 dshScopeCheck.files,跳过');
|
|
105
|
+
}
|
|
106
|
+
for (const rel of files) {
|
|
107
|
+
const abs = join(ROOT, rel);
|
|
108
|
+
const scope = analyzeScopeCollisions(readFileSync(abs, 'utf8'), {
|
|
109
|
+
prefix: String(cfg.prefix || ''),
|
|
110
|
+
allowlist: Array.isArray(cfg.allowlist) ? cfg.allowlist.map(String) : [],
|
|
111
|
+
topLevelMustBeEmpty: cfg.topLevelMustBeEmpty !== false,
|
|
112
|
+
});
|
|
113
|
+
if (scope.ok) {
|
|
114
|
+
console.log(`✔ ${rel} 作用域契约(顶层零声明 · 共享作用域 ${scope.declarations.filter((d) => d.frameId === scope.sharedFrameId).length} 个声明均合规 · 无同帧重名)`);
|
|
115
|
+
} else {
|
|
116
|
+
fail += 1;
|
|
117
|
+
for (const v of scope.violations) console.error(`✗ ${rel} 作用域:${v}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
} catch (e) {
|
|
121
|
+
fail += 1;
|
|
122
|
+
console.error(`✗ 拼接产物作用域检查失败:${e.message}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
86
125
|
// ── 层边界门禁(2026-10-24)────────────────────────────────────────────
|
|
87
126
|
// 背景:审计引擎与提交推送**决定不拆成两个 npm 包**(拆包的持续成本——双包版本同步、
|
|
88
127
|
// 固定发布顺序、依赖范围——换不到真实收益:外部使用者要的是「提交前拦截」这个整体,
|
|
@@ -92,12 +131,20 @@ try {
|
|
|
92
131
|
// 不变量:
|
|
93
132
|
// ① 审计层任何文件都不得 import git/npm/commit-push 层(方向唯一:git → audit);
|
|
94
133
|
// ② 反向接缝数量有预算上限——允许存在(提交门禁必须调审计),但要能看见它在膨胀。
|
|
95
|
-
|
|
134
|
+
// lint-adapter(外部 linter 委托层)纳入审计层口径:编排层(audit)直接依赖它 ⇒ 它属于审计子图,
|
|
135
|
+
// 同样不得伸手 git 层(委托层只读项目文件 + 跑外部二进制,不需要凭据/git)。
|
|
136
|
+
const AUDIT_DIRS = new Set(['ast', 'audit', 'audit-rules', 'checks', 'exempt', 'rule', 'score', 'lint-adapter']);
|
|
96
137
|
const GIT_DIRS = new Set(['git', 'npm']);
|
|
97
138
|
const GIT_TOP = new Set(['commit-push.js']);
|
|
98
139
|
const AUDIT_TOP = new Set(['audit-defaults.js', 'skip-dirs.js']);
|
|
99
|
-
/**
|
|
100
|
-
|
|
140
|
+
/**
|
|
141
|
+
* 反向接缝预算:实测 **5 处**;上调需写明理由。
|
|
142
|
+
*
|
|
143
|
+
* 2026-11-13 从 7 降到 5:提交前预处理解耦后,`lib/commit-push.js` 不再 import `audit/index.js` 与
|
|
144
|
+
* `score/index.js`(改调外部引擎子进程),只剩 `exempt/index.js` 这一条(示例目录豁免要用)。
|
|
145
|
+
* 预算跟着实收紧,是为了让这个成果**被门禁钉住**——以后谁再往 git 侧加审计 import,5→6 就会红。
|
|
146
|
+
*/
|
|
147
|
+
const SEAM_BUDGET = 5;
|
|
101
148
|
|
|
102
149
|
const layerOf = (rel) => {
|
|
103
150
|
const top = rel.split('/')[0];
|
package/scripts/scan-file-io.mjs
CHANGED
|
@@ -556,7 +556,10 @@ export function main(argv = process.argv.slice(2)) {
|
|
|
556
556
|
const defaults = targets.length ? targets : [
|
|
557
557
|
join(root, '..', 'lib'),
|
|
558
558
|
join(root, '..', 'scripts'),
|
|
559
|
+
// 三个 CLI 入口都在默认扫描集里:入口按侧拆分后,漏掉新入口 = file-io 默认静默漏扫
|
|
559
560
|
join(root, '..', 'cli.mjs'),
|
|
561
|
+
join(root, '..', 'cli-audit.mjs'),
|
|
562
|
+
join(root, '..', 'cli-tool.mjs'),
|
|
560
563
|
join(root, '..', 'lib', 'client.js'),
|
|
561
564
|
];
|
|
562
565
|
const files = collectFiles(defaults);
|
|
@@ -582,7 +585,8 @@ export function scanFileIo(opts = {}) {
|
|
|
582
585
|
const root = dirname(fileURLToPath(import.meta.url));
|
|
583
586
|
const dirs = targets.length ? targets : [
|
|
584
587
|
join(root, '..', 'lib'), join(root, '..', 'scripts'),
|
|
585
|
-
join(root, '..', 'cli.mjs'), join(root, '..', '
|
|
588
|
+
join(root, '..', 'cli.mjs'), join(root, '..', 'cli-audit.mjs'), join(root, '..', 'cli-tool.mjs'),
|
|
589
|
+
join(root, '..', 'lib', 'client.js'),
|
|
586
590
|
];
|
|
587
591
|
const files = collectFiles(dirs);
|
|
588
592
|
let hits = [];
|
package/scripts/scan-version.mjs
CHANGED
|
@@ -74,13 +74,16 @@ function main() {
|
|
|
74
74
|
const vi = versionInfo(pkgJson);
|
|
75
75
|
if (!vi.ok) errors.push(vi.error);
|
|
76
76
|
// 3) cli.mjs HELP 文本(源码里是 v${VERSION} 模板,运行时渲染为 v<版本>)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
// 三个 CLI 入口都必须在 HELP 首行引用 v${VERSION} 模板(入口拆成三个后,只查 cli.mjs 会漏掉另外两个)
|
|
78
|
+
for (const entryFile of ['cli.mjs', 'cli-audit.mjs', 'cli-tool.mjs']) {
|
|
79
|
+
const entryPath = join(ROOT, entryFile);
|
|
80
|
+
let entryText = '';
|
|
81
|
+
if (existsSync(entryPath)) {
|
|
82
|
+
try { entryText = readFileSync(entryPath, 'utf8'); } catch { /* 忽略 */ }
|
|
83
|
+
}
|
|
84
|
+
if (!entryText.includes('v${VERSION}')) {
|
|
85
|
+
errors.push(`${entryFile} HELP 未引用 v${VERSION} 模板(应在 HELP 首行 <CLI名> v${VERSION})`);
|
|
86
|
+
}
|
|
84
87
|
}
|
|
85
88
|
// 4) 版本列表宿主(适配分体式:优先 docs/CHANGELOG.md 的 dshgp-version
|
|
86
89
|
// 标记块——README 不再内嵌版本表,只有链接引用;无标记块回退 README 章节)
|
|
@@ -11,7 +11,7 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
|
|
|
11
11
|
> 定位:把「扫描仓库 → 审计门禁 → 一键 commit+push」固化为代码管道(零 token、确定性)。
|
|
12
12
|
> 本手册是使用说明;正常情况优先直接调用插件工具。
|
|
13
13
|
|
|
14
|
-
## 一、
|
|
14
|
+
## 一、21 个工具
|
|
15
15
|
|
|
16
16
|
| 工具 | 参数 | 说明 |
|
|
17
17
|
|---|---|---|
|
|
@@ -30,7 +30,12 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
|
|
|
30
30
|
| `git_cred_env` | — | 输出凭据环境变量前缀(SSH `GIT_SSH_COMMAND` / HTTPS `GIT_ASKPASS`,不含明文) |
|
|
31
31
|
| `git_gen_ssh_key` | `email`(必填), `force?` | 生成 SSH 密钥对(写入插件配置目录;私钥不出本机,公钥整行回传) |
|
|
32
32
|
| `git_sluice` | `args`(必填) | git 命令透传(凭据自动注入;返回 status + stdout/stderr 原文) |
|
|
33
|
-
| `git_api` | `path?`, `method?`, `query?`, `body?` | **直接调用本插件
|
|
33
|
+
| `git_api` | `path?`, `method?`, `query?`, `body?` | **直接调用本插件 36 条 HTTP API**(内部走 `handleHttp` 同一条代码路径,不另写实现);不传 `path` 则列出全部接口 |
|
|
34
|
+
| `npm_publish` | `dir?`, `dryRun?`(默认 true), `tag?`, `otp?`, `confirm?`, `skipSmoke?`, `localPreview?` | npm 发包(后台 job):默认只体检 + `npm publish --dry-run`;真发必须 `confirm=true` 且 `dryRun=false`;凭据由插件托管(无需 npm login) |
|
|
35
|
+
| `npm_unpublish` | `name`(必填), `version?`, `wholePackage?`, `dryRun?`(默认 true), `confirm?` | 撤包(不可逆):默认只预检(72h 窗口 / dist-tag 悬空 / 唯一版本冷却),真撤需 `dryRun=false` + `confirm=true` |
|
|
36
|
+
| `git_remote_rename` | `repo`(必填), `newName`(必填), `dryRun?`(默认 true), `updateRemotes?` | 远程仓库改名:默认只报告旧名出现位置,确认后 `dryRun=false` 才真改并同步本地 remote |
|
|
37
|
+
| `exempt` | `action`(必填), `repo?`, `path?`, `line?`, `scope?`, `rule?`, `marker?`, `reason?` | 注释豁免:按 `rule` 推导正确标记、写前校验真生效、`check` 识别死标记 |
|
|
38
|
+
| `scope_check` | `files?`, `repo?`, `prefix?`, `allowlist?`, `topLevelMustBeEmpty?` | 拼接产物作用域撞名(按真实作用域帧):同帧重名会**后者静默顶掉前者**;`files` 空=读项目 `dshScopeCheck.files`,前缀/顶层零声明按项目契约(没声明就只查同帧重名,不拿 `dshgp_` 要求别人) |
|
|
34
39
|
|
|
35
40
|
典型流程:`git_scan` 看改动 → `code_audit` 自查 → `git_commit_push`(审计通过才推)。
|
|
36
41
|
|
|
@@ -182,6 +187,12 @@ pnpm add github:EIGHTfs/dsh-git-push#<commit>
|
|
|
182
187
|
|
|
183
188
|
### 7.3 客户端 UI 三选项卡重写(2026-09-12)
|
|
184
189
|
|
|
190
|
+
> ⚠️ **现状变更(2026-11-08)**:UI 与审计解耦后,**审计 Tab 已移出构建**,页面现为**两选项卡**
|
|
191
|
+
> (账号信息 / 设置)。审计侧分片归档在 `lib/client-parts/audit/`(不参与构建),
|
|
192
|
+
> git 侧分片在 `lib/client-parts/git/`(13 片,参与构建)。**后端审计能力完全不变**
|
|
193
|
+
> (提交门禁、code_audit 等 5 个工具、4 个 HTTP 接口、审计设置键全部保留)。
|
|
194
|
+
> 下文的「三选项卡」描述的是当时形态,保留作历史记录。
|
|
195
|
+
|
|
185
196
|
**用户决策**:删设置配置卡(`settings.plugin.item`),只保留侧边栏独立页(`settings.section`),页面重写为**三个大选项卡**(对齐插件市场 .tabs/.tab/.on,参考 skill 记分板):
|
|
186
197
|
|
|
187
198
|
1. **账号信息**(纯展示):`GET /api/git-push/account-check` → GitHub 登录态/用户名/公钥指纹/套餐,`block` 文本直接展示。
|
|
@@ -265,6 +276,7 @@ pnpm add github:EIGHTfs/dsh-git-push#<commit>
|
|
|
265
276
|
| `git_remote_create` | **`repo`**、`visibility?`(默认 private)、`dryRun?` | 同名存在则复用,否则创建并把 origin 指向 API 地址;`ensureRemoteRepo` |
|
|
266
277
|
| `git_set_visibility` | **`repo`**、**`visibility`** | `PATCH /repos/{owner}/{repo}` 的 private 字段;改 public 前须确认无凭据暴露;`setVisibility` |
|
|
267
278
|
| `link_check` | `path?`(缺省 workspaceRoot) | 分级扣分(404/403 −3、DNS −2、超时/5xx −1,flaky 域名 ×0.2);**只 warning 永不 blocker**;并发 10;`checkLinks`/`probeLinks` |
|
|
279
|
+
| `scope_check` | `files?`(逗号分隔,空=项目 `dshScopeCheck.files`)、`repo?`、`prefix?`、`allowlist?`、`topLevelMustBeEmpty?` | 按真实作用域帧查同帧重名;判定 `analyzeScopeCollisions`(`lib/ast/scope-collisions.js`)、契约 `readProjectScopePolicy`(`lib/audit/scope-policy.js`)、执行 `runScopeCheck`(`lib/app/scope-check.js`);违规时 CLI 退出码 1 |
|
|
268
280
|
|
|
269
281
|
**接线层**(`lib/plugin/index.js`,Host 侧四段真实 API):工具 `ctx.inject(['tools'])` → `register(defineTool(spec))`(`output.render` **必须返回块数组**);提示词注入 `inject(['systemPrompt'])` → `section({name, order, text})`;HTTP `inject(['webServer'])` → `register({kind:'prefix', path, handler})`;客户端**不在此注册**(由 package.json `dsh.client` + `exports["./client"]` 自动发现)。
|
|
270
282
|
|
|
@@ -311,8 +323,64 @@ pnpm add github:EIGHTfs/dsh-git-push#<commit>
|
|
|
311
323
|
| 豁免写了没用 | 整文件豁免须在前 3 行;行级豁免须写在命中行 |
|
|
312
324
|
| 函数/复杂度被报为 blocker | 规则 `severity` 是上限,检查器不越级;报 blocker 说明 yml 里写的就是 error/blocker |
|
|
313
325
|
| 克隆大文件反复失败 | 失败项的分片必须保留(`.dsh-parts`)才能跨轮 Range 续传;同轮清理分片会让大文件永远从 0 重来 |
|
|
326
|
+
| **桌面端(`dsh-app://`)设置页保存全部失效、GET 正常** | 桌面壳 `forwardWebRequest` 转发 `/api/*` 时**显式剥离 Origin**(`headers.delete('origin')`,只补 cookie),插件写请求鉴权对无 Origin 一律 403。2.20.17 起放行「无 Origin + `Content-Type: application/json` + **本机来源**」,本机判定以 TCP 对端地址(`req.socket.remoteAddress`)为准、`Host` 只做兜底——`Host` 可被客户端伪造(`Host: 127.0.0.1`),且实测某些转发链路会丢 Host;仍不通就看 `<DSH_HOME>/git-push/http-rejects.log`(2.20.17 恢复,记 method/url/origin/host/code);**排查前先完全退出应用重开**——见下一行 |
|
|
327
|
+
| **补丁改了不生效,误判「补丁无效」** | DSH 宿主的 HMR `profileRoots` 只收集**符号链接**形式的插件包;**复制安装(真实目录)** 的插件在插件页开关切换只重启 fiber,**ESM 缓存仍是旧代码**。⇒ 验证服务端补丁必须**完全退出应用重开**,否则会把「缓存没刷新」误判成「改错了」(外部报告实测踩到,2026-11-13 记入) |
|
|
314
328
|
| 建了远端但推送报「远端查不到分支 master(API 404 / ls-remote 无该分支)」 | `git_remote_create` 旧版把 origin 写成 **REST API 端点**(`https://api.github.com/repos/<o>/<r>` ✗ 那不是 git remote)⇒ `git push/fetch origin` 必然失败。2026-10-09 已修(`lib/git/remote.js`):origin 统一写 `https://github.com/<o>/<r>`,并**自愈**——仓库已存在但 origin 仍是 API 形态时 `set-url` 改回;返回体新增 `originAction`(`add`/`repair`/`keep`)。旧仓库手工修:`git remote set-url origin ssh://git@ssh.github.com:443/<o>/<r>.git` 再 `git push -u origin master`(凭据用插件 `id_rsa` + `-p 443`)。⚠️ `lib/git/clone.js` 仍写 API 形态 origin(设计如此,插件自身推送不受影响,但 `git push origin` 会失败) |
|
|
315
329
|
|
|
330
|
+
## 附录 F、在测试环境真机验证插件改动(可复用步骤)
|
|
331
|
+
|
|
332
|
+
> 2026-11-13 实测走通(验证 2.20.17 的桌面端鉴权修复)。用途:改完插件要拿真实 HTTP 验证时,
|
|
333
|
+
> 不必影响主实例。**三个坑不处理就永远 404 / 加载失败**,按下面顺序做。
|
|
334
|
+
|
|
335
|
+
### 步骤
|
|
336
|
+
|
|
337
|
+
```
|
|
338
|
+
① 起环境:test_env({ action:'start', plugin:'<插件根>' })
|
|
339
|
+
⚠️ 坑 1:`plugin` 参数**不会真的安装插件**,local-plugins/ 仍为空 ⇒ API 全 404。
|
|
340
|
+
② 显式安装 + 注册:
|
|
341
|
+
sync_plugin({ dshHome:'<测试环境目录>', pluginName:'<插件名>',
|
|
342
|
+
source:'<插件根>', write:true, register:true })
|
|
343
|
+
③ 补运行时依赖(插件有静态 import 时必需):
|
|
344
|
+
cp -r <插件根>/node_modules <测试环境>/profiles/web/local-plugins/<插件名>/node_modules
|
|
345
|
+
⚠️ 坑 2:不复制会在加载期缺 js-yaml / web-tree-sitter / tree-sitter-wasms。
|
|
346
|
+
(不要用软链把外部 node_modules 挂进项目——那是 no-symlink 禁止的形态)
|
|
347
|
+
④ 建 bundle 解析路径:
|
|
348
|
+
mkdir -p <测试环境>/profiles/web/node_modules
|
|
349
|
+
ln -s ../local-plugins/<插件名> <测试环境>/profiles/web/node_modules/<插件名>
|
|
350
|
+
⚠️ 坑 3:DSH 从 profiles/web/node_modules 解析 profile bundle,
|
|
351
|
+
缺这条会报 `cannot resolve profile bundle "<插件名>"`。这是**部署安装形态**
|
|
352
|
+
(与主实例一致:dependencies 用 link:local-plugins/<插件名>),不是项目内软链。
|
|
353
|
+
⑤ 重启环境:test_env({ action:'stop' }) → test_env({ action:'start' })
|
|
354
|
+
⑥ 取访问令牌:`grep -oE 'token=[A-Za-z0-9._-]+' <测试环境>/dsh-env.log | tail -1`
|
|
355
|
+
(**不要把它打印到会话里**)
|
|
356
|
+
⑦ 换 cookie:`curl -c /tmp/tc.txt "http://127.0.0.1:<port>/?token=<token>"`
|
|
357
|
+
—— 不带 cookie 直接打 API 会得到 401 unauthorized。
|
|
358
|
+
⑧ 验证完停环境:test_env({ action:'stop' })
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### 验证鉴权类改动时的请求形态对照
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
# 桌面端转发形态(无 Origin + JSON)—— 期望 200
|
|
365
|
+
curl -b /tmp/tc.txt -X POST -H 'Content-Type: application/json' \
|
|
366
|
+
-d '{"key":"npmRegistry","value":"https://registry.npmjs.org/"}' \
|
|
367
|
+
http://127.0.0.1:<port>/api/git-push/settings-set
|
|
368
|
+
|
|
369
|
+
# 跨站表单形态(无 Origin + text/plain)—— 期望 403 NO_ORIGIN
|
|
370
|
+
curl -b /tmp/tc.txt -X POST -H 'Content-Type: text/plain' \
|
|
371
|
+
-d '{"key":"npmRegistry","value":"x"}' \
|
|
372
|
+
http://127.0.0.1:<port>/api/git-push/settings-set
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### 判据与副作用
|
|
376
|
+
|
|
377
|
+
- **拒绝日志**:每次 403 都会写 `<测试环境>/git-push/http-rejects.log`(method/url/origin/host/code),
|
|
378
|
+
`cat` 它就能确认「拒绝确实发生、原因是什么」——这是验证可诊断性的唯一直接证据。
|
|
379
|
+
- **远端 socket 造不出来**:真机只能证明「本机 socket 放行」;
|
|
380
|
+
「远端 socket + 伪造 Host ⇒ 拒」必须靠单测传 `remoteAddress` 断言(本仓库 `test-origin-desktop.mjs` 第 15 例)。
|
|
381
|
+
- **副作用**:测试环境是隔离 DSH_HOME,往里写假凭据无害;但它会占端口(3083–3182)与磁盘
|
|
382
|
+
(node_modules 副本约 50MB+),验证完按低负载纪律停掉。
|
|
383
|
+
|
|
316
384
|
## 端点:AI 自设工作区路径(workspace-paths)
|
|
317
385
|
|
|
318
386
|
环境注入里的「当前工作目录 cwd」原先取自**会话文件**(`agent.session.header.cwd`),实测可能是**陈旧路径**
|
|
@@ -14,7 +14,7 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
|
|
|
14
14
|
|
|
15
15
|
| 场景 | 必须做的 |
|
|
16
16
|
|---|---|
|
|
17
|
-
| 要审计一个仓库 | 会话内用工具 `code_audit`;只看聚合明细用 HTTP `/api/git-push/audit`;脱离 DSH 用 `
|
|
17
|
+
| 要审计一个仓库 | 会话内用工具 `code_audit`;只看聚合明细用 HTTP `/api/git-push/audit`;脱离 DSH 用 `audit-sluice audit` |
|
|
18
18
|
| 判断能否提交 | 门禁只认 `blocker`,命中即拦;`warning` / `notice` 只提示不拦 |
|
|
19
19
|
| 遇到误报 | 先按判定类型选已有豁免机制;结构性误报优先修审计判定,不靠注释掩盖 |
|
|
20
20
|
| 新增 / 停用规则 | 只改规则 yml(放文件即生效、删文件即移除),不改代码 |
|
|
@@ -28,7 +28,7 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
|
|
|
28
28
|
|---|---|---|
|
|
29
29
|
| 工具 | `code_audit` | 默认精简输出(评分 / 各级数量 / 豁免统计 / API 指引);`includeFindings=true` 出全量 |
|
|
30
30
|
| HTTP | `GET/POST /api/git-push/audit` | 请求时聚合:分组 / 严重级过滤 / 条数截断;默认全量范围 |
|
|
31
|
-
| CLI | `
|
|
31
|
+
| CLI | `audit-sluice audit <目录>` | 独立运行(零第三方依赖,Node ≥18 + 本机 git),`--json` 出全量 |
|
|
32
32
|
|
|
33
33
|
### 2. 工具 `code_audit` 参数
|
|
34
34
|
|
|
@@ -61,16 +61,16 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
|
|
|
61
61
|
|
|
62
62
|
返回:`ok`、`repo`、`scope`、`files`、`summary`、`quality{score,level}`、`groups[]`(按条数降序,每组含一条 `sample`)、`total`、`filtered`、`exemptStats`、`groupByTypes`、`blocked[]`。
|
|
63
63
|
|
|
64
|
-
### 4. CLI(`
|
|
64
|
+
### 4. CLI(`audit-sluice audit`)
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
audit-sluice audit . # 变动范围(非 git 目录自动全量)
|
|
68
|
+
audit-sluice audit . --full # 全量
|
|
69
|
+
audit-sluice audit . --ruleset <规则目录> # 自定规则目录
|
|
70
|
+
audit-sluice audit . --weights '{"安全性":25}' # 权重覆盖 JSON
|
|
71
|
+
audit-sluice audit . --include-ignored # 连 .gitignore 忽略的文件也扫
|
|
72
|
+
audit-sluice audit . --json # 全量 findings + yaml
|
|
73
|
+
audit-sluice audit . --history --since <提交> --until <提交> --out <目录>
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
CLI 读与插件同一份配置(`$DSH_HOME/git-push/config.json`);权重优先级:显式 `--weights` > 配置 `weightOverrides` > 默认权重表。CLI 与插件用同一实现、同一配置,同一仓库同一参数结果一致。
|
|
@@ -133,7 +133,7 @@ console.log(x); // dsh-skip-residue: 本行为刻意保留的调试输出样本
|
|
|
133
133
|
|
|
134
134
|
### 10. 链接检查(link_check)
|
|
135
135
|
|
|
136
|
-
工具 `link_check`(`path` = 文件或目录,默认工作区)、CLI `
|
|
136
|
+
工具 `link_check`(`path` = 文件或目录,默认工作区)、CLI `audit-sluice link-check <路径>`、斜杠命令 `/link-check [文件或目录]`。扫描 md / 文本内 URL 并访问验证:404 / 403 / 410 / 451 → 扣 3,DNS 失败 → 扣 2,超时 / 连接失败 / 5xx → 扣 1;只 warning,永不 blocker。配置 `linkCheckEnabled` 默认关(需要网络)。
|
|
137
137
|
|
|
138
138
|
### 11. 文档漂移检查(函数列表 / 目录树 / 版本表)
|
|
139
139
|
|
|
@@ -41,11 +41,11 @@ CLI 是同一引擎的独立入口,**不另写一份逻辑**:
|
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
43
|
git-sluice version
|
|
44
|
-
|
|
44
|
+
audit-sluice audit . --full --json
|
|
45
45
|
git-sluice repos /path/to/workspace --max 50 --json
|
|
46
46
|
git-sluice index /path/to/workspace --owner EIGHTfs --offline
|
|
47
|
-
git-sluice commit /path/to/repo
|
|
48
|
-
|
|
47
|
+
git-sluice commit /path/to/repo --message "fix: 修正 xx" --no-push
|
|
48
|
+
tool-sluice self-check
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
## 二、随插件发布的独立脚本
|
|
@@ -181,9 +181,9 @@ git_commit_push({ repo: "<仓库路径>", message: "chore: 重写历史后同步
|
|
|
181
181
|
2. 需要 **why / verify 溯源**(评审时要能看出「为什么改」与「怎么验证的」✓)
|
|
182
182
|
|
|
183
183
|
**不该硬用** ✗:一句话就能说清时用字符串即可 ✓(强行结构化只增加噪音)。
|
|
184
|
-
CLI(`git-sluice commit <仓库>
|
|
184
|
+
CLI(`git-sluice commit <仓库> --message "msg"`)只支持字符串 ✓;`messageItems` 走工具/HTTP API ✓。
|
|
185
185
|
|
|
186
186
|
**该用却没用会怎样**:不会失败 ✓;但当单串信息偏长(>150 字符或含换行)时,工具结果会带
|
|
187
187
|
`usageHint` 提醒改用 `messageItems` ✓;采用率留痕在 `<DSH_HOME>/git-push/commit-usage.log`
|
|
188
188
|
(每行一条 JSON:`structured` / `items` / `msgLen` / `repo` ✓,可据此统计实际采用率)。
|
|
189
|
-
| CLI | `git-sluice commit <仓库>
|
|
189
|
+
| CLI | `git-sluice commit <仓库> --message "msg"` 与工具同源(审计门禁一致);CLI 默认只提交,加 `--push` 才推 |
|
|
@@ -17,7 +17,6 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
|
|
|
17
17
|
| 判断「AI 为什么看得到/看不到插件功能」 | 先看总开关「注入系统提示词/上下文」;它同时门控两条通道(系统提示词 + 上下文),关掉后两条都不注入 |
|
|
18
18
|
| 确认某个注入段是否生效 | 按生效条件逐项核对,不能只看总开关:要求清单段还要「提交前自动审计」+「↳ 注入开发者要求清单」同时开 |
|
|
19
19
|
| 改插件配置/开关 | 只改插件私有 `config.json`(侧边栏保存即写它);不要写公共 `settings.yaml` |
|
|
20
|
-
| 看界面上的真实数据 | 用 `assets/start.sh` 起预览反代(默认真实后端),不要只看静态 HTML 文件 |
|
|
21
20
|
| 刷新账号信息 / 本地仓库列表 | 只在三种时机读取;不轮询、不监听索引文件,页面切 tab 不会刷新 |
|
|
22
21
|
| 改了前端界面代码 | 先用 dsh-useful-tools 的 `preview` 工具(`action=gen`)重生成预览页再看,否则看的是旧界面 |
|
|
23
22
|
|
|
@@ -113,21 +112,6 @@ generatedBy: deepseek-official/deepseek-v4-flash · EIGHTfs 2026-10-02
|
|
|
113
112
|
|
|
114
113
|
登录判定为「或」:SSH 或 token 任一有效即视为已登录,用户名取有效者。
|
|
115
114
|
|
|
116
|
-
### 2.6 界面预览页(assets/preview.html,真实后端数据)
|
|
117
|
-
|
|
118
|
-
预览页由 **dsh-useful-tools** 的 `preview` 工具生成(`action=gen`)(内联真实前端代码,只垫片宿主环境),界面与真实插件一致;用 `assets/start.sh` 起本地反代服务访问:
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
./assets/start.sh start [--port 31000] # 默认 30999;端口被别的项目占用时用 --port 错开
|
|
122
|
-
./assets/start.sh status / restart / stop
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
- 访问 `http://<本机IP>:30999`(默认端口)。反代把 `/api/git-push/*` 全部转发到真实 DSH 后端(默认 `http://<本机IP>:30800`),并自动完成 token 认证——账号信息 / 本地仓库 / 云端仓库 / 规则包 / 审计结果 / 设置全部来自真实后端,读取与写入都真实。
|
|
126
|
-
- 指定后端或直接跑:`preview` 工具 `action=serve`(port / backend 参数)(同一入口还有 `--direct` 直连插件 handleHttp、`--local` 每请求 fork 子进程跑工作区最新代码);token 解析顺序:`--token` > 环境变量 `DSH_PREVIEW_TOKEN` > 解析 `dsh-proxy.log` 兜底。
|
|
127
|
-
- 离线调试:URL 加 `?mock=1` 切内置假数据(改动只留页面内、不写文件);跨后端实测:URL 加 `?backend=http://<本机IP>:端口`。
|
|
128
|
-
- 全部可点:三选项卡切换、审计开关、注入系统提示词开关、注入要求清单子开关(含置灰联动)、规则包启停与调序、权重编辑、token/SSH 保存、邮箱一键生成 SSH 并回填。
|
|
129
|
-
- 健康检查 `GET /preview-ping`;PID 落 `dsh-git-push.pid`(插件根);日志 `assets/preview-server.log`(超 10 MB 轮转)。
|
|
130
|
-
- 改了前端代码后同步预览:`preview` 工具 `action=gen`。
|
|
131
115
|
|
|
132
116
|
### 2.7 配置持久化位置
|
|
133
117
|
|