dsh-git-push 2.9.9 → 2.10.4
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 +26 -15
- package/assets/tree-sitter/LICENSE +0 -0
- package/assets/tree-sitter/README.md +0 -0
- package/assets/tree-sitter/tree-sitter-javascript.wasm +0 -0
- package/assets/tree-sitter/tree-sitter-python.wasm +0 -0
- package/assets/tree-sitter/tree-sitter-typescript.wasm +0 -0
- package/assets/tree-sitter/tree-sitter.js +0 -0
- package/assets/tree-sitter/tree-sitter.wasm +0 -0
- package/lib/ARCHITECTURE.md +27 -0
- package/lib/app/apply.js +0 -0
- package/lib/app/command-registry.js +1 -0
- package/lib/app/handlers/repos.js +18 -2
- package/lib/app/handlers/settings.js +0 -0
- package/lib/app/handlers/workspace-paths.js +0 -0
- package/lib/app/schema.js +0 -0
- package/lib/app/settings-bridge.js +0 -0
- package/lib/app/tool-call.js +6 -2
- package/lib/ast/brace.js +15 -0
- package/lib/ast/code-lines.js +0 -0
- package/lib/ast/fs-hotspots.js +0 -0
- package/lib/ast/index.js +0 -0
- package/lib/ast/size.js +68 -1
- package/lib/ast/tokenizer.js +0 -0
- package/lib/ast/treesitter.js +0 -0
- package/lib/audit/collector.js +13 -4
- package/lib/audit/ignore-blind.js +5 -4
- package/lib/audit/orchestrate.js +2 -1
- package/lib/audit-rules/audit-rules-frontend.yml +4 -4
- package/lib/checks/button-bind.js +61 -13
- package/lib/checks/dispatch.js +1 -1
- package/lib/checks/fs-scanner.js +0 -0
- package/lib/checks/private.js +2 -1
- package/lib/checks/regex.js +0 -0
- package/lib/checks/structural.js +10 -3
- package/lib/client-parts/{10-account.js → account.js} +1 -1
- package/lib/client-parts/{41-actions.js → actions.js} +3 -2
- package/lib/client-parts/{99-apply.js → apply.js} +2 -1
- package/lib/client-parts/{21-audit.js → audit.js} +5 -5
- package/lib/client-parts/{11-browser.js → browser.js} +15 -4
- package/lib/client-parts/{01-const.js → const.js} +11 -5
- package/lib/client-parts/{40-controller.js → controller.js} +4 -4
- package/lib/client-parts/{03-icons.js → icons.js} +1 -1
- package/lib/client-parts/{00-loader.js → loader.js} +1 -0
- package/lib/client-parts/{23-npm.js → npm.js} +3 -2
- package/lib/client-parts/{30-page.js → page.js} +1 -1
- package/lib/client-parts/{20-repo.js → repo.js} +2 -2
- package/lib/client-parts/{22-settings.js → settings.js} +1 -1
- package/lib/client-parts/{02-utils.js → utils.js} +1 -1
- package/lib/client.js +51 -30
- package/lib/context/index.js +2 -1
- package/lib/core/atomic-json.js +1 -1
- package/lib/core/workspace-paths.js +0 -0
- package/lib/exempt/index.js +7 -2
- package/lib/exempt/tool.js +0 -0
- package/lib/git/clone-history-mode.js +22 -9
- package/lib/git/clone-replay-io.js +10 -4
- package/lib/git/clone.js +8 -2
- package/lib/git/commit-message.js +0 -0
- package/lib/git/index-format.js +182 -0
- package/lib/git/index.js +1 -0
- package/lib/git/init-compat.js +118 -0
- package/lib/git/push-diagnose.js +0 -0
- package/lib/git/repo-index.js +41 -30
- package/lib/git/scan-runner.js +1 -1
- package/lib/npm/publish.js +14 -12
- package/lib/self/index.js +1 -1
- package/package.json +1 -1
- package/scripts/build-client.mjs +19 -14
- package/scripts/check.mjs +68 -0
- package/scripts/cpu-sample.mjs +0 -0
- package/scripts/picker-repro.mjs +115 -0
- package/scripts/scan-fs-hotspots.mjs +0 -0
- package/skills/dsh-repo-index.md +1 -1
- package/skills/guide/guide-audit.md +106 -3
- package/skills/guide/guide-cli-scripts.md +1 -1
- package/skills/guide/guide-clone-repos.md +2 -2
- package/skills/guide/guide-inject-ui.md +2 -2
- package/skills/workflow/README.md +1 -1
package/lib/checks/private.js
CHANGED
|
@@ -9,6 +9,7 @@ import { globToRegex } from '../audit/glob.js';
|
|
|
9
9
|
import { execFileSync } from 'node:child_process';
|
|
10
10
|
|
|
11
11
|
import { makeFinding } from '../audit/index.js';
|
|
12
|
+
import { GIT_GLOBAL_ARGS } from '../core/exec.js';
|
|
12
13
|
|
|
13
14
|
/* ───────── 私密检查常量 ───────── */
|
|
14
15
|
const LS_FILES_TIMEOUT_MS = 10000; // git ls-files 超时
|
|
@@ -28,7 +29,7 @@ export function checkPrivateFiles({ root, visibility = 'unknown', privateFiles =
|
|
|
28
29
|
try {
|
|
29
30
|
// 显式捕获 stderr——execFileSync 未设 stdio 时异常会把子进程 stderr 直通父进程
|
|
30
31
|
// (非 git 目录跑 git ls-files 会打印「致命错误:不是 git 仓库」污染 audit --json 输出)
|
|
31
|
-
const out = execFileSync('git', ['ls-files'], { cwd: root, encoding: 'utf8', timeout: LS_FILES_TIMEOUT_MS, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
32
|
+
const out = execFileSync('git', [...GIT_GLOBAL_ARGS, 'ls-files'], { cwd: root, encoding: 'utf8', timeout: LS_FILES_TIMEOUT_MS, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
32
33
|
tracked = out.split('\n').filter(Boolean);
|
|
33
34
|
} catch (e) { /* 非 git 仓库 / git 不可用 → 跳过 */
|
|
34
35
|
if (String(e?.stderr || '').trim()) { /* stderr 已捕获,静默 */ }
|
package/lib/checks/regex.js
CHANGED
|
File without changes
|
package/lib/checks/structural.js
CHANGED
|
@@ -133,7 +133,7 @@ export function checkComplexity({ file, text, rules }) {
|
|
|
133
133
|
for (const hit of checkComplexityAst(text, { warn: threshold, block: blockThreshold })) {
|
|
134
134
|
// 作用域豁免(P1):启动路径函数豁免圈复杂度;P4:public 不豁免
|
|
135
135
|
if (rule.scopeRules?.length && fnScope2.get(hit.name) !== 'public' && resolveScopeAction(rule.scopeRules, { path: classifyFunctionPath(hit.name), functionName: hit.name }) === 'exempt') continue;
|
|
136
|
-
//
|
|
136
|
+
// 分档提示(按复杂度区间):11~20 中等 / 21~50 高风险应拆分 / 50+ 极难维护(拦)
|
|
137
137
|
const grade = hit.complexity > blockThreshold
|
|
138
138
|
? '极难维护(几乎不可测)'
|
|
139
139
|
: (hit.complexity > 20 ? '高风险' : '中等(开始难测)');
|
|
@@ -211,12 +211,19 @@ export function checkMaxLines({ file, text, rules, fileScope = '' }) {
|
|
|
211
211
|
scoreImpact: 0,
|
|
212
212
|
})];
|
|
213
213
|
}
|
|
214
|
+
// 分两种「非聚合型」情形,文案必须各说各的事实:
|
|
215
|
+
// · 有超大函数 → 臃肿型(先拆函数)
|
|
216
|
+
// · 一个函数都没有(顶层语句堆叠的脚本/数据文件)→ 不能说「藏着超大函数」
|
|
217
|
+
// (此前统一套「最大函数 0 行(臃肿型:文件大因藏着超大函数)」——0 行显然不是超大函数,
|
|
218
|
+
// 文案自相矛盾;外部项目实测反馈即指向这句)
|
|
219
|
+
const headline = maxFuncLen > 0
|
|
220
|
+
? `最大函数 ${maxFuncLen} 行(臃肿型:文件大是因藏着超大函数),应先拆函数再考虑拆文件`
|
|
221
|
+
: '文件内未识别到函数(顶层语句堆叠的脚本/数据形态),应拆分为模块';
|
|
214
222
|
return [makeFinding({
|
|
215
223
|
file, line: 1, rule: rule?.id || 'max-lines', kind: 'max-lines',
|
|
216
224
|
severity: capSeverity(rule.severity, level),
|
|
217
225
|
// 判定按非注释部分(codeLines);总行数/注释行数一并展示便于判断拆分空间
|
|
218
|
-
message: `文件 ${codeLines} 行代码(总 ${lines} 行,其中注释 ${commentLines} 行,阈值 ${threshold}
|
|
219
|
-
+ `最大函数 ${maxFuncLen} 行(臃肿型:文件大因藏着超大函数),应拆分`,
|
|
226
|
+
message: `文件 ${codeLines} 行代码(总 ${lines} 行,其中注释 ${commentLines} 行,阈值 ${threshold})——${headline}`,
|
|
220
227
|
dimensions: rule?.dimensions || ['可维护性'],
|
|
221
228
|
exemptHint: 'dsh-skip-size(文件头,文件级属性)',
|
|
222
229
|
scoreImpact: level === 'blocker' ? 2 : 1,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* ─── 第 5/14 片 · 账号信息 Tab(AcctHead/AccountCard/AccountTab) ─────────────────── */
|
|
2
2
|
/** 账号卡片头部:GitHub 图标 + 标题 + 状态徽标。 */
|
|
3
3
|
function dshgp_AcctHead(props) {
|
|
4
4
|
return jsx.jsxs('div', {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* ─── 第 13/14 片 · Controller 动作注入(接 controller.js 的类体,方法声明不可拆出类外) ─────────────────── */
|
|
1
2
|
setStatus(msg) {
|
|
2
3
|
this.statusMsg = String(msg || '');
|
|
3
4
|
if (this.statusTimer) clearTimeout(this.statusTimer);
|
|
@@ -41,9 +42,9 @@
|
|
|
41
42
|
toggleAudit(checked) {
|
|
42
43
|
this.auditEnabled = !!checked;
|
|
43
44
|
// 交互修正:关闭父开关时**不再**把子开关的勾选抹掉。
|
|
44
|
-
//
|
|
45
|
+
// 子开关的勾选状态独立保存,父开关只管「此刻生不生效」(host 侧注入由
|
|
45
46
|
// cfg.auditEnabled && cfg.injectRequirements 门控)。原实现静默清勾选,
|
|
46
|
-
//
|
|
47
|
+
// 重开父开关时还得再点一遍子开关,且看不出勾选是被谁清掉的。
|
|
47
48
|
this.commitSetting('auditEnabled', this.auditEnabled, this.auditEnabled
|
|
48
49
|
? '✅ 已开启:提交前自动审计'
|
|
49
50
|
: '✅ 已关闭:提交前不审计');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* ─── 第 14/14 片 · 收尾:注册 settings.section + factory 返回(必须末片) ─────────────────── */
|
|
1
2
|
function apply(ctx) {
|
|
2
3
|
// 【常驻诊断 · 前端接线失败可见化】apply 整体包一层 try/catch,把真实异常打到控制台。
|
|
3
4
|
// 背景:cordis 只把失败的 client entry 标成 failed(页面仅显示
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
const controller = new dshgp_Controller(scope);
|
|
29
30
|
const store = controller.store;
|
|
30
31
|
// (修复「重启后不预读」):**每次进设置页都预读**账号信息 + 本地仓库列表
|
|
31
|
-
// (读 account-status.json / dsh-repo-index.
|
|
32
|
+
// (读 account-status.json / dsh-repo-index.jsonl,本地文件幂等便宜)——此前的模块级
|
|
32
33
|
// `dshgp_startupLoaded` 标记在 DSH bundle 常驻(浏览器不刷新)时保持 true,
|
|
33
34
|
// 导致「第一次预读后,重启/重进设置页不再预读」。改为每次 apply 都读,跟随最新 json。
|
|
34
35
|
// 后续仍可手动「重新检测 / 扫描」在线刷新。
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* ─── 第 9/14 片 · 审计 Tab(WeightRows/RuleRow/AuditSwitchBlock/InjectPromptSwitchBlock/CommentWordingBlock/AuditAdvancedBlock/RuleListBlock/AuditTab) ─────────────────── */
|
|
2
2
|
/** 10 维度权重行(值来自 state.weightValues,改即写回 weightOverrides JSON)。 */
|
|
3
3
|
function dshgp_WeightRows(props) {
|
|
4
4
|
const s = props.state;
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
/**
|
|
193
|
+
/** 代码禁交流残留词开关块(控制 comment 槽位启停)。 */
|
|
194
194
|
function dshgp_CommentWordingBlock(props) {
|
|
195
195
|
const s = props.state;
|
|
196
196
|
return jsx.jsxs('div', {
|
|
@@ -199,11 +199,11 @@
|
|
|
199
199
|
jsx.jsxs('div', {
|
|
200
200
|
className: 'dshgp_switchrow',
|
|
201
201
|
children: [
|
|
202
|
-
jsx.jsx('span', { className: 'dshgp_switchlabel', children: '
|
|
203
|
-
jsx.jsx('input', { type: 'checkbox', checked: !((s.slotMeta && s.slotMeta['comment']) || {}).disabled, onChange: () => props.toggleDisabled('comment'), 'aria-label': '
|
|
202
|
+
jsx.jsx('span', { className: 'dshgp_switchlabel', children: '代码禁交流残留词(命中 Block 提交)' }),
|
|
203
|
+
jsx.jsx('input', { type: 'checkbox', checked: !((s.slotMeta && s.slotMeta['comment']) || {}).disabled, onChange: () => props.toggleDisabled('comment'), 'aria-label': '代码禁交流残留词' }),
|
|
204
204
|
],
|
|
205
205
|
}),
|
|
206
|
-
jsx.jsx('p', { className: 'dshgp_hint', children: '
|
|
206
|
+
jsx.jsx('p', { className: 'dshgp_hint', children: '代码注释/文档出现交流残留措辞(见 comment 规则包黑名单)→ blocker 拦截提交;白名单业务词(用户ID/用户登录等)自动豁免。' }),
|
|
207
207
|
],
|
|
208
208
|
});
|
|
209
209
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* ─── 第 6/14 片 · 目录选择器(browseEnsureDom/browseLoad/browseOpen/browseClose/browseAttach) ─────────────────── */
|
|
2
2
|
let dshgp_browseTarget = null; // 当前打开的输入框(null = 走 onPick 回调)
|
|
3
3
|
// 移植 gamebanana-mods-downloader 的 path-picker 小模块:一行接入 📂 按钮 // 当前打开的输入框(null = 走 onPick 回调)
|
|
4
4
|
let dshgp_browseOpt = null; // { onPick } 确认回调(clone 场景)
|
|
5
5
|
let dshgp_browsePath = ''; // 弹窗当前所在目录
|
|
6
|
+
// 单层最多渲染的目录条数:node_modules / .git 展开动辄上千条,全量 innerHTML 会把弹窗卡死。
|
|
7
|
+
// 逐层浏览本就是该弹窗的用法,截断 + 明示剩余数量即可。
|
|
8
|
+
const dshgp_BROWSE_MAX_DIRS = 200;
|
|
6
9
|
function dshgp_browseEnsureDom() {
|
|
7
10
|
if (typeof document === 'undefined' || document.getElementById('dshgp-browse-mask')) return;
|
|
8
11
|
const mask = document.createElement('div');
|
|
@@ -51,14 +54,22 @@
|
|
|
51
54
|
dshgp_browsePath = browseRes.path;
|
|
52
55
|
dshgp_browseRemember(browseRes.path);
|
|
53
56
|
crumb.textContent = browseRes.path;
|
|
57
|
+
crumb.title = browseRes.path; // 超长路径:CSS 已省略号截断,hover 看全量
|
|
54
58
|
up.style.display = browseRes.parent ? 'block' : 'none';
|
|
55
59
|
up.dataset.path = browseRes.parent || '';
|
|
60
|
+
// 条目上限:深目录(如 node_modules 展开)可能有上千个子目录,全量渲染会卡死弹窗。
|
|
61
|
+
// 截断到 BROWSE_MAX_DIRS 条并在末尾提示,需要时逐层进入即可(弹窗本来就是逐层浏览的)。
|
|
62
|
+
const allDirs = Array.isArray(browseRes.dirs) ? browseRes.dirs : [];
|
|
63
|
+
const shown = allDirs.length > dshgp_BROWSE_MAX_DIRS ? allDirs.slice(0, dshgp_BROWSE_MAX_DIRS) : allDirs;
|
|
56
64
|
let html = '';
|
|
57
|
-
if (!
|
|
58
|
-
|
|
65
|
+
if (!shown.length) html += '<div class="dshgp_browsehint">(无子目录)</div>';
|
|
66
|
+
shown.forEach((dirName) => {
|
|
59
67
|
const full = browseRes.path === '/' ? '/' + dirName : browseRes.path + '/' + dirName;
|
|
60
|
-
html += '<div class="dshgp_browsedir" data-path="' + String(full).replace(/"/g, '"') + '">📁 ' + String(dirName).replace(/</g, '<') + '</div>';
|
|
68
|
+
html += '<div class="dshgp_browsedir" data-path="' + String(full).replace(/"/g, '"') + '">📁 ' + String(dirName).replace(/</g, '<').replace(/>/g, '>') + '</div>';
|
|
61
69
|
});
|
|
70
|
+
if (allDirs.length > shown.length) {
|
|
71
|
+
html += '<div class="dshgp_browsehint">…另有 ' + (allDirs.length - shown.length) + ' 个目录未显示(上限 ' + dshgp_BROWSE_MAX_DIRS + ' 条,可进入子目录继续浏览)</div>';
|
|
72
|
+
}
|
|
62
73
|
list.innerHTML = html;
|
|
63
74
|
list.querySelectorAll('.dshgp_browsedir').forEach((el) => {
|
|
64
75
|
el.addEventListener('click', () => dshgp_browseLoad(el.dataset.path));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* ─── 第 2/14 片 · 常量区(NS/维度表/样式串) ─────────────────── */
|
|
2
2
|
// 面板「忙碌中」状态键的前缀(clone / vis / push 三类操作共用**同一出处**)。
|
|
3
3
|
// 此前这三个字面量散落在组件与类方法里各写一遍,改一处不会同步另一处;
|
|
4
4
|
// 命名带 dshgp_ 前缀,符合本文件的形态铁律(防 combo 拼接撞名)。
|
|
@@ -192,14 +192,20 @@
|
|
|
192
192
|
'.dshgp_browsebtn{flex-shrink:0;font-size:12px;padding:4px 8px;border:.5px solid var(--dsw-alias-border-l4);border-radius:8px;background:var(--dsw-alias-bg-layer-2);cursor:pointer}',
|
|
193
193
|
// 目录选择弹窗(移植 gbmd path-picker:一行接入 📂 按钮)
|
|
194
194
|
'.dshgp_browsemask{position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.4)}',
|
|
195
|
-
'.dshgp_browsedialog{width:min(480px,88vw);max-height:70vh;display:flex;flex-direction:column;gap:8px;padding:14px;border:.5px solid var(--dsw-alias-border-l4);border-radius:14px;background:var(--dsw-alias-bg-layer-3);box-shadow:0 12px 40px rgba(0,0,0,.35)}',
|
|
195
|
+
'.dshgp_browsedialog{width:min(480px,88vw);max-height:70vh;min-height:0;display:flex;flex-direction:column;gap:8px;padding:14px;border:.5px solid var(--dsw-alias-border-l4);border-radius:14px;background:var(--dsw-alias-bg-layer-3);box-shadow:0 12px 40px rgba(0,0,0,.35)}',
|
|
196
196
|
'.dshgp_browsehead{display:flex;align-items:center;justify-content:space-between}',
|
|
197
197
|
'.dshgp_browsetitle{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary)}',
|
|
198
198
|
'.dshgp_browseclose{font:inherit;font-size:13px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;padding:2px 6px}',
|
|
199
|
-
'.dshgp_browsepath{font-size:11px;color:var(--dsw-alias-label-secondary);
|
|
199
|
+
'.dshgp_browsepath{font-size:11px;color:var(--dsw-alias-label-secondary);padding:6px 8px;border:.5px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-base);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-shrink:0}',
|
|
200
200
|
'.dshgp_browseup{font-size:12px;color:var(--dsw-alias-brand-primary);cursor:pointer;padding:3px 2px}',
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
// list 本身是纵向 flex 容器 ⇒ 每个目录行是 flex 子项。子项默认 flex-shrink:1,
|
|
202
|
+
// 而行上又写了 overflow:hidden(为省略号截断),overflow:hidden 会让它的
|
|
203
|
+
// automatic minimum size 变成 0 ⇒ 内容超出容器时行被**无限压扁**而不是滚动。
|
|
204
|
+
// 实测(73 条、1080px 视口):行高从应有的 27px 被压到 10px,文字几乎不可读,
|
|
205
|
+
// 即「列表非常多时才积压」的现象。修法:flex:0 0 auto 禁止收缩,
|
|
206
|
+
// 让溢出交给容器的 overflow-y:auto 滚动。
|
|
207
|
+
'.dshgp_browselist{flex:1;min-height:0;max-height:38vh;overflow-y:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:2px}',
|
|
208
|
+
'.dshgp_browsedir{flex:0 0 auto;font-size:12px;color:var(--dsw-alias-label-primary);cursor:pointer;padding:5px 8px;border-radius:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
203
209
|
'.dshgp_browsedir:hover{background:color-mix(in srgb,var(--dsw-alias-brand-primary) 12%,transparent)}',
|
|
204
210
|
'.dshgp_browsehint{font-size:12px;color:var(--dsw-alias-label-tertiary);padding:8px}',
|
|
205
211
|
'.dshgp_browsefoot{display:flex;justify-content:flex-end}',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* ─── 第 12/14 片 · Controller(状态机 + 数据加载 + 动作注入) ─────────────────── */
|
|
2
2
|
class dshgp_Controller {
|
|
3
3
|
constructor(scope) {
|
|
4
4
|
this.scope = scope;
|
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
* @param {string|string[]} [parts='all'] 要刷新的部分,可传单个字符串、数组、或 'all':
|
|
230
230
|
* · 'settings' —— 设置(/settings-get 读宿主 scope 已落盘值,覆盖前端字段)
|
|
231
231
|
* · 'account' —— 账号信息(/account-status 离线读凭据真源 + 徽标)
|
|
232
|
-
* · 'repos' —— 本地仓库列表(/repos-local 读 dsh-repo-index.
|
|
232
|
+
* · 'repos' —— 本地仓库列表(/repos-local 读 dsh-repo-index.jsonl;可配 path/rebuild)
|
|
233
233
|
* · 'cloud' —— 云端仓库列表(/repos-cloud 走 token 列账号名下仓库)
|
|
234
234
|
* · 'slots' —— 规则槽位(/rule-slots 动态发现 yml + 统计)
|
|
235
235
|
* · 'all' —— 以上全部(默认)
|
|
@@ -633,7 +633,7 @@
|
|
|
633
633
|
await this.refreshAccount(); // 离线读回在线校验落盘的 json
|
|
634
634
|
}
|
|
635
635
|
|
|
636
|
-
/** 扫描本地仓库(列表只从 dsh-repo-index.
|
|
636
|
+
/** 扫描本地仓库(列表只从 dsh-repo-index.jsonl 读取)。
|
|
637
637
|
* rebuild=true:**离线重建索引**(扫描本地 .git,author 与离线账号 json 一致的登记,
|
|
638
638
|
* 含本地新增,全程不联网)后再读回;缺省:直接读索引返回(不复扫、不联网)。 */
|
|
639
639
|
async scanLocalRepos(path, rebuild, { silent = false } = {}) {
|
|
@@ -770,7 +770,7 @@
|
|
|
770
770
|
const idxHint = cloudRes.indexUpdated ? ',索引已刷新 ' + cloudRes.indexUpdated + ' 条' : '';
|
|
771
771
|
this.cloudMsg = '共 ' + this.cloudRepos.length + ' 个仓库(按最近更新排序)' + idxHint;
|
|
772
772
|
// 云端获取后**重新读索引刷新本地列表**——后端已把云端仓库(含
|
|
773
|
-
// defaultBranch/pushedAt/visibility 云端真源)写进 dsh-repo-index.
|
|
773
|
+
// defaultBranch/pushedAt/visibility 云端真源)写进 dsh-repo-index.jsonl,
|
|
774
774
|
// 侧边栏本地面板的远端状态(默认分支/云端更新/仅云端标记)随之更新。
|
|
775
775
|
void this.scanLocalRepos(this.localPath, false);
|
|
776
776
|
} else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* ─── 第 4/14 片 · 图标区(ghIcon/refreshIcon) ─────────────────── */
|
|
2
2
|
/* ═══════════════════ 选项卡一:账号信息(美化版:渐变卡片 + GitHub 图标 + 状态徽标) ═══════════════════ */
|
|
3
3
|
const dshgp_ghIcon = jsx.jsx('svg', {
|
|
4
4
|
width: '22', height: '22', viewBox: '0 0 24 24', fill: 'none',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// dsh-skip-func-length: NPM 子页为自包含组件(自有 useState/useEffect,不依赖 controller),拆分会改动 hook 顺序与状态归属,风险高于收益
|
|
2
|
+
/* ─── 第 8/14 片 · NPM 面板(账号卡 + 装包表单 + 已装列表 + npm 凭据字段) ───────────────────
|
|
2
3
|
* 设计取舍:完全自包含(自己 useState/useEffect + 直接走 HTTP),不碰 40-controller(884 行)与 41-actions,
|
|
3
4
|
* 把 Step 4 的改动面压到最小;数据源:/npm-account、/npm-packages、/npm-install、/settings-set、/status。
|
|
4
5
|
* 安全默认与后端一致:`ignore-scripts` 默认勾选(不执行 postinstall)、默认非全局、**安装需二次确认**。
|
|
@@ -183,7 +184,7 @@
|
|
|
183
184
|
className: 'dshgp_section',
|
|
184
185
|
children: [
|
|
185
186
|
// 账号卡已上移到顶部账号区(与 GitHub 卡**同位置、滑动切换**)⇒ 这里不再重复渲染
|
|
186
|
-
// 说明:原先自创的「安装包」表单(包名输入 + 目录输入 +
|
|
187
|
+
// 说明:原先自创的「安装包」表单(包名输入 + 目录输入 + 两个复选框)已**停用**——
|
|
187
188
|
// 改为照 GitHub 的四段交互:行内「安装」→ 选择目录 / 全局安装 → 进度轮询 → 回执。
|
|
188
189
|
// 组件 dshgp_NpmInstallForm 的源码暂留备查,不再渲染(comment-not-delete:只停用不删代码)。
|
|
189
190
|
jsx.jsxs('div', {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* ─── 第 7/14 片 · 仓库管理卡(RepoManagerCard/RepoLocalPane/RepoCloudPane) ─────────────────── */
|
|
2
2
|
function dshgp_RepoManagerCard(props) {
|
|
3
3
|
const s = props.state;
|
|
4
4
|
const [view, setView] = react.useState('local');
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
function dshgp_CloneProgress(props) {
|
|
306
306
|
const p = props.p || {};
|
|
307
307
|
const mb = (n) => (n / 1024 / 1024).toFixed(1);
|
|
308
|
-
// 停滞超过 45s
|
|
308
|
+
// 停滞超过 45s 才提示「可能卡住」;只提示,不自动中断(是否中断由人工判断)
|
|
309
309
|
const stalled = (p.stalledMs || 0) > 45_000;
|
|
310
310
|
const phaseText = p.phase === 'done' ? '收尾中' : '下载中';
|
|
311
311
|
return jsx.jsxs('div', { className: 'dshgp_cloneprog', children: [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* ─── 第 3/14 片 · 工具区(ensureCss/getJson/postJson/tokenConfigured/copyText) ─────────────────── */
|
|
2
2
|
function dshgp_ensureCss() {
|
|
3
3
|
if (typeof document === 'undefined') return;
|
|
4
4
|
if (document.querySelector('style[data-plugin-css="dsh-git-push"]')) return;
|
package/lib/client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dsh-git-push v2 设置侧边栏(settings.section 独立页)
|
|
3
|
+
* 分片顺序锚点:第 1/14 片(顺序唯一权威 = scripts/build-client.mjs 的 PART_ORDER)
|
|
3
4
|
* ============================================================================
|
|
4
5
|
* 重写(三选项卡版):
|
|
5
6
|
* - 纯中文:删 zh/en 键值对字典,用户可见文案直接硬编码中文(产品设计)。
|
|
@@ -31,7 +32,7 @@ window.__ModuleLoader__.load({
|
|
|
31
32
|
const NS = 'git-push';
|
|
32
33
|
const SETTINGS_NS = 'git-push';
|
|
33
34
|
|
|
34
|
-
/*
|
|
35
|
+
/* ─── 第 2/14 片 · 常量区(NS/维度表/样式串) ─────────────────── */
|
|
35
36
|
// 面板「忙碌中」状态键的前缀(clone / vis / push 三类操作共用**同一出处**)。
|
|
36
37
|
// 此前这三个字面量散落在组件与类方法里各写一遍,改一处不会同步另一处;
|
|
37
38
|
// 命名带 dshgp_ 前缀,符合本文件的形态铁律(防 combo 拼接撞名)。
|
|
@@ -225,20 +226,26 @@ window.__ModuleLoader__.load({
|
|
|
225
226
|
'.dshgp_browsebtn{flex-shrink:0;font-size:12px;padding:4px 8px;border:.5px solid var(--dsw-alias-border-l4);border-radius:8px;background:var(--dsw-alias-bg-layer-2);cursor:pointer}',
|
|
226
227
|
// 目录选择弹窗(移植 gbmd path-picker:一行接入 📂 按钮)
|
|
227
228
|
'.dshgp_browsemask{position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.4)}',
|
|
228
|
-
'.dshgp_browsedialog{width:min(480px,88vw);max-height:70vh;display:flex;flex-direction:column;gap:8px;padding:14px;border:.5px solid var(--dsw-alias-border-l4);border-radius:14px;background:var(--dsw-alias-bg-layer-3);box-shadow:0 12px 40px rgba(0,0,0,.35)}',
|
|
229
|
+
'.dshgp_browsedialog{width:min(480px,88vw);max-height:70vh;min-height:0;display:flex;flex-direction:column;gap:8px;padding:14px;border:.5px solid var(--dsw-alias-border-l4);border-radius:14px;background:var(--dsw-alias-bg-layer-3);box-shadow:0 12px 40px rgba(0,0,0,.35)}',
|
|
229
230
|
'.dshgp_browsehead{display:flex;align-items:center;justify-content:space-between}',
|
|
230
231
|
'.dshgp_browsetitle{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary)}',
|
|
231
232
|
'.dshgp_browseclose{font:inherit;font-size:13px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;padding:2px 6px}',
|
|
232
|
-
'.dshgp_browsepath{font-size:11px;color:var(--dsw-alias-label-secondary);
|
|
233
|
+
'.dshgp_browsepath{font-size:11px;color:var(--dsw-alias-label-secondary);padding:6px 8px;border:.5px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-base);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-shrink:0}',
|
|
233
234
|
'.dshgp_browseup{font-size:12px;color:var(--dsw-alias-brand-primary);cursor:pointer;padding:3px 2px}',
|
|
234
|
-
|
|
235
|
-
|
|
235
|
+
// list 本身是纵向 flex 容器 ⇒ 每个目录行是 flex 子项。子项默认 flex-shrink:1,
|
|
236
|
+
// 而行上又写了 overflow:hidden(为省略号截断),overflow:hidden 会让它的
|
|
237
|
+
// automatic minimum size 变成 0 ⇒ 内容超出容器时行被**无限压扁**而不是滚动。
|
|
238
|
+
// 实测(73 条、1080px 视口):行高从应有的 27px 被压到 10px,文字几乎不可读,
|
|
239
|
+
// 即「列表非常多时才积压」的现象。修法:flex:0 0 auto 禁止收缩,
|
|
240
|
+
// 让溢出交给容器的 overflow-y:auto 滚动。
|
|
241
|
+
'.dshgp_browselist{flex:1;min-height:0;max-height:38vh;overflow-y:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:2px}',
|
|
242
|
+
'.dshgp_browsedir{flex:0 0 auto;font-size:12px;color:var(--dsw-alias-label-primary);cursor:pointer;padding:5px 8px;border-radius:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
236
243
|
'.dshgp_browsedir:hover{background:color-mix(in srgb,var(--dsw-alias-brand-primary) 12%,transparent)}',
|
|
237
244
|
'.dshgp_browsehint{font-size:12px;color:var(--dsw-alias-label-tertiary);padding:8px}',
|
|
238
245
|
'.dshgp_browsefoot{display:flex;justify-content:flex-end}',
|
|
239
246
|
].join('');
|
|
240
247
|
|
|
241
|
-
/*
|
|
248
|
+
/* ─── 第 3/14 片 · 工具区(ensureCss/getJson/postJson/tokenConfigured/copyText) ─────────────────── */
|
|
242
249
|
function dshgp_ensureCss() {
|
|
243
250
|
if (typeof document === 'undefined') return;
|
|
244
251
|
if (document.querySelector('style[data-plugin-css="dsh-git-push"]')) return;
|
|
@@ -300,7 +307,7 @@ window.__ModuleLoader__.load({
|
|
|
300
307
|
return Promise.resolve();
|
|
301
308
|
}
|
|
302
309
|
|
|
303
|
-
/*
|
|
310
|
+
/* ─── 第 4/14 片 · 图标区(ghIcon/refreshIcon) ─────────────────── */
|
|
304
311
|
/* ═══════════════════ 选项卡一:账号信息(美化版:渐变卡片 + GitHub 图标 + 状态徽标) ═══════════════════ */
|
|
305
312
|
const dshgp_ghIcon = jsx.jsx('svg', {
|
|
306
313
|
width: '22', height: '22', viewBox: '0 0 24 24', fill: 'none',
|
|
@@ -312,7 +319,7 @@ window.__ModuleLoader__.load({
|
|
|
312
319
|
stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round',
|
|
313
320
|
children: jsx.jsx('path', { d: 'M21 12a9 9 0 1 1-2.64-6.36M21 3v6h-6' }),
|
|
314
321
|
});
|
|
315
|
-
/*
|
|
322
|
+
/* ─── 第 5/14 片 · 账号信息 Tab(AcctHead/AccountCard/AccountTab) ─────────────────── */
|
|
316
323
|
/** 账号卡片头部:GitHub 图标 + 标题 + 状态徽标。 */
|
|
317
324
|
function dshgp_AcctHead(props) {
|
|
318
325
|
return jsx.jsxs('div', {
|
|
@@ -395,11 +402,14 @@ window.__ModuleLoader__.load({
|
|
|
395
402
|
});
|
|
396
403
|
}
|
|
397
404
|
|
|
398
|
-
/*
|
|
405
|
+
/* ─── 第 6/14 片 · 目录选择器(browseEnsureDom/browseLoad/browseOpen/browseClose/browseAttach) ─────────────────── */
|
|
399
406
|
let dshgp_browseTarget = null; // 当前打开的输入框(null = 走 onPick 回调)
|
|
400
407
|
// 移植 gamebanana-mods-downloader 的 path-picker 小模块:一行接入 📂 按钮 // 当前打开的输入框(null = 走 onPick 回调)
|
|
401
408
|
let dshgp_browseOpt = null; // { onPick } 确认回调(clone 场景)
|
|
402
409
|
let dshgp_browsePath = ''; // 弹窗当前所在目录
|
|
410
|
+
// 单层最多渲染的目录条数:node_modules / .git 展开动辄上千条,全量 innerHTML 会把弹窗卡死。
|
|
411
|
+
// 逐层浏览本就是该弹窗的用法,截断 + 明示剩余数量即可。
|
|
412
|
+
const dshgp_BROWSE_MAX_DIRS = 200;
|
|
403
413
|
function dshgp_browseEnsureDom() {
|
|
404
414
|
if (typeof document === 'undefined' || document.getElementById('dshgp-browse-mask')) return;
|
|
405
415
|
const mask = document.createElement('div');
|
|
@@ -448,14 +458,22 @@ window.__ModuleLoader__.load({
|
|
|
448
458
|
dshgp_browsePath = browseRes.path;
|
|
449
459
|
dshgp_browseRemember(browseRes.path);
|
|
450
460
|
crumb.textContent = browseRes.path;
|
|
461
|
+
crumb.title = browseRes.path; // 超长路径:CSS 已省略号截断,hover 看全量
|
|
451
462
|
up.style.display = browseRes.parent ? 'block' : 'none';
|
|
452
463
|
up.dataset.path = browseRes.parent || '';
|
|
464
|
+
// 条目上限:深目录(如 node_modules 展开)可能有上千个子目录,全量渲染会卡死弹窗。
|
|
465
|
+
// 截断到 BROWSE_MAX_DIRS 条并在末尾提示,需要时逐层进入即可(弹窗本来就是逐层浏览的)。
|
|
466
|
+
const allDirs = Array.isArray(browseRes.dirs) ? browseRes.dirs : [];
|
|
467
|
+
const shown = allDirs.length > dshgp_BROWSE_MAX_DIRS ? allDirs.slice(0, dshgp_BROWSE_MAX_DIRS) : allDirs;
|
|
453
468
|
let html = '';
|
|
454
|
-
if (!
|
|
455
|
-
|
|
469
|
+
if (!shown.length) html += '<div class="dshgp_browsehint">(无子目录)</div>';
|
|
470
|
+
shown.forEach((dirName) => {
|
|
456
471
|
const full = browseRes.path === '/' ? '/' + dirName : browseRes.path + '/' + dirName;
|
|
457
|
-
html += '<div class="dshgp_browsedir" data-path="' + String(full).replace(/"/g, '"') + '">📁 ' + String(dirName).replace(/</g, '<') + '</div>';
|
|
472
|
+
html += '<div class="dshgp_browsedir" data-path="' + String(full).replace(/"/g, '"') + '">📁 ' + String(dirName).replace(/</g, '<').replace(/>/g, '>') + '</div>';
|
|
458
473
|
});
|
|
474
|
+
if (allDirs.length > shown.length) {
|
|
475
|
+
html += '<div class="dshgp_browsehint">…另有 ' + (allDirs.length - shown.length) + ' 个目录未显示(上限 ' + dshgp_BROWSE_MAX_DIRS + ' 条,可进入子目录继续浏览)</div>';
|
|
476
|
+
}
|
|
459
477
|
list.innerHTML = html;
|
|
460
478
|
list.querySelectorAll('.dshgp_browsedir').forEach((el) => {
|
|
461
479
|
el.addEventListener('click', () => dshgp_browseLoad(el.dataset.path));
|
|
@@ -490,7 +508,7 @@ window.__ModuleLoader__.load({
|
|
|
490
508
|
}
|
|
491
509
|
|
|
492
510
|
/* ═══════════════════ 账号卡片:本地/云端 仓库管理 ═══════════════════ */
|
|
493
|
-
/*
|
|
511
|
+
/* ─── 第 7/14 片 · 仓库管理卡(RepoManagerCard/RepoLocalPane/RepoCloudPane) ─────────────────── */
|
|
494
512
|
function dshgp_RepoManagerCard(props) {
|
|
495
513
|
const s = props.state;
|
|
496
514
|
const [view, setView] = react.useState('local');
|
|
@@ -797,7 +815,7 @@ window.__ModuleLoader__.load({
|
|
|
797
815
|
function dshgp_CloneProgress(props) {
|
|
798
816
|
const p = props.p || {};
|
|
799
817
|
const mb = (n) => (n / 1024 / 1024).toFixed(1);
|
|
800
|
-
// 停滞超过 45s
|
|
818
|
+
// 停滞超过 45s 才提示「可能卡住」;只提示,不自动中断(是否中断由人工判断)
|
|
801
819
|
const stalled = (p.stalledMs || 0) > 45_000;
|
|
802
820
|
const phaseText = p.phase === 'done' ? '收尾中' : '下载中';
|
|
803
821
|
return jsx.jsxs('div', { className: 'dshgp_cloneprog', children: [
|
|
@@ -864,7 +882,8 @@ window.__ModuleLoader__.load({
|
|
|
864
882
|
] });
|
|
865
883
|
}
|
|
866
884
|
|
|
867
|
-
|
|
885
|
+
// dsh-skip-func-length: NPM 子页为自包含组件(自有 useState/useEffect,不依赖 controller),拆分会改动 hook 顺序与状态归属,风险高于收益
|
|
886
|
+
/* ─── 第 8/14 片 · NPM 面板(账号卡 + 装包表单 + 已装列表 + npm 凭据字段) ───────────────────
|
|
868
887
|
* 设计取舍:完全自包含(自己 useState/useEffect + 直接走 HTTP),不碰 40-controller(884 行)与 41-actions,
|
|
869
888
|
* 把 Step 4 的改动面压到最小;数据源:/npm-account、/npm-packages、/npm-install、/settings-set、/status。
|
|
870
889
|
* 安全默认与后端一致:`ignore-scripts` 默认勾选(不执行 postinstall)、默认非全局、**安装需二次确认**。
|
|
@@ -1049,7 +1068,7 @@ window.__ModuleLoader__.load({
|
|
|
1049
1068
|
className: 'dshgp_section',
|
|
1050
1069
|
children: [
|
|
1051
1070
|
// 账号卡已上移到顶部账号区(与 GitHub 卡**同位置、滑动切换**)⇒ 这里不再重复渲染
|
|
1052
|
-
// 说明:原先自创的「安装包」表单(包名输入 + 目录输入 +
|
|
1071
|
+
// 说明:原先自创的「安装包」表单(包名输入 + 目录输入 + 两个复选框)已**停用**——
|
|
1053
1072
|
// 改为照 GitHub 的四段交互:行内「安装」→ 选择目录 / 全局安装 → 进度轮询 → 回执。
|
|
1054
1073
|
// 组件 dshgp_NpmInstallForm 的源码暂留备查,不再渲染(comment-not-delete:只停用不删代码)。
|
|
1055
1074
|
jsx.jsxs('div', {
|
|
@@ -1247,7 +1266,7 @@ window.__ModuleLoader__.load({
|
|
|
1247
1266
|
});
|
|
1248
1267
|
}
|
|
1249
1268
|
|
|
1250
|
-
/*
|
|
1269
|
+
/* ─── 第 9/14 片 · 审计 Tab(WeightRows/RuleRow/AuditSwitchBlock/InjectPromptSwitchBlock/CommentWordingBlock/AuditAdvancedBlock/RuleListBlock/AuditTab) ─────────────────── */
|
|
1251
1270
|
/** 10 维度权重行(值来自 state.weightValues,改即写回 weightOverrides JSON)。 */
|
|
1252
1271
|
function dshgp_WeightRows(props) {
|
|
1253
1272
|
const s = props.state;
|
|
@@ -1439,7 +1458,7 @@ window.__ModuleLoader__.load({
|
|
|
1439
1458
|
});
|
|
1440
1459
|
}
|
|
1441
1460
|
|
|
1442
|
-
/**
|
|
1461
|
+
/** 代码禁交流残留词开关块(控制 comment 槽位启停)。 */
|
|
1443
1462
|
function dshgp_CommentWordingBlock(props) {
|
|
1444
1463
|
const s = props.state;
|
|
1445
1464
|
return jsx.jsxs('div', {
|
|
@@ -1448,11 +1467,11 @@ window.__ModuleLoader__.load({
|
|
|
1448
1467
|
jsx.jsxs('div', {
|
|
1449
1468
|
className: 'dshgp_switchrow',
|
|
1450
1469
|
children: [
|
|
1451
|
-
jsx.jsx('span', { className: 'dshgp_switchlabel', children: '
|
|
1452
|
-
jsx.jsx('input', { type: 'checkbox', checked: !((s.slotMeta && s.slotMeta['comment']) || {}).disabled, onChange: () => props.toggleDisabled('comment'), 'aria-label': '
|
|
1470
|
+
jsx.jsx('span', { className: 'dshgp_switchlabel', children: '代码禁交流残留词(命中 Block 提交)' }),
|
|
1471
|
+
jsx.jsx('input', { type: 'checkbox', checked: !((s.slotMeta && s.slotMeta['comment']) || {}).disabled, onChange: () => props.toggleDisabled('comment'), 'aria-label': '代码禁交流残留词' }),
|
|
1453
1472
|
],
|
|
1454
1473
|
}),
|
|
1455
|
-
jsx.jsx('p', { className: 'dshgp_hint', children: '
|
|
1474
|
+
jsx.jsx('p', { className: 'dshgp_hint', children: '代码注释/文档出现交流残留措辞(见 comment 规则包黑名单)→ blocker 拦截提交;白名单业务词(用户ID/用户登录等)自动豁免。' }),
|
|
1456
1475
|
],
|
|
1457
1476
|
});
|
|
1458
1477
|
}
|
|
@@ -1548,7 +1567,7 @@ window.__ModuleLoader__.load({
|
|
|
1548
1567
|
}
|
|
1549
1568
|
|
|
1550
1569
|
/* ═══════════════════ 选项卡三:设置 ═══════════════════ */
|
|
1551
|
-
/*
|
|
1570
|
+
/* ─── 第 10/14 片 · 设置 Tab(SettingsTab) ─────────────────── */
|
|
1552
1571
|
function dshgp_CredentialBlock(props) {
|
|
1553
1572
|
const s = props.state;
|
|
1554
1573
|
return jsx.jsxs('div', {
|
|
@@ -1694,7 +1713,7 @@ window.__ModuleLoader__.load({
|
|
|
1694
1713
|
});
|
|
1695
1714
|
}
|
|
1696
1715
|
|
|
1697
|
-
/*
|
|
1716
|
+
/* ─── 第 11/14 片 · 页面装配(GitPushPage:三选项卡聚合) ─────────────────── */
|
|
1698
1717
|
function dshgp_GitPushPage(props) {
|
|
1699
1718
|
dshgp_ensureCss();
|
|
1700
1719
|
const [tab, setTab] = react.useState('account');
|
|
@@ -1750,7 +1769,7 @@ window.__ModuleLoader__.load({
|
|
|
1750
1769
|
});
|
|
1751
1770
|
}
|
|
1752
1771
|
|
|
1753
|
-
/*
|
|
1772
|
+
/* ─── 第 12/14 片 · Controller(状态机 + 数据加载 + 动作注入) ─────────────────── */
|
|
1754
1773
|
class dshgp_Controller {
|
|
1755
1774
|
constructor(scope) {
|
|
1756
1775
|
this.scope = scope;
|
|
@@ -1981,7 +2000,7 @@ window.__ModuleLoader__.load({
|
|
|
1981
2000
|
* @param {string|string[]} [parts='all'] 要刷新的部分,可传单个字符串、数组、或 'all':
|
|
1982
2001
|
* · 'settings' —— 设置(/settings-get 读宿主 scope 已落盘值,覆盖前端字段)
|
|
1983
2002
|
* · 'account' —— 账号信息(/account-status 离线读凭据真源 + 徽标)
|
|
1984
|
-
* · 'repos' —— 本地仓库列表(/repos-local 读 dsh-repo-index.
|
|
2003
|
+
* · 'repos' —— 本地仓库列表(/repos-local 读 dsh-repo-index.jsonl;可配 path/rebuild)
|
|
1985
2004
|
* · 'cloud' —— 云端仓库列表(/repos-cloud 走 token 列账号名下仓库)
|
|
1986
2005
|
* · 'slots' —— 规则槽位(/rule-slots 动态发现 yml + 统计)
|
|
1987
2006
|
* · 'all' —— 以上全部(默认)
|
|
@@ -2385,7 +2404,7 @@ window.__ModuleLoader__.load({
|
|
|
2385
2404
|
await this.refreshAccount(); // 离线读回在线校验落盘的 json
|
|
2386
2405
|
}
|
|
2387
2406
|
|
|
2388
|
-
/** 扫描本地仓库(列表只从 dsh-repo-index.
|
|
2407
|
+
/** 扫描本地仓库(列表只从 dsh-repo-index.jsonl 读取)。
|
|
2389
2408
|
* rebuild=true:**离线重建索引**(扫描本地 .git,author 与离线账号 json 一致的登记,
|
|
2390
2409
|
* 含本地新增,全程不联网)后再读回;缺省:直接读索引返回(不复扫、不联网)。 */
|
|
2391
2410
|
async scanLocalRepos(path, rebuild, { silent = false } = {}) {
|
|
@@ -2522,7 +2541,7 @@ window.__ModuleLoader__.load({
|
|
|
2522
2541
|
const idxHint = cloudRes.indexUpdated ? ',索引已刷新 ' + cloudRes.indexUpdated + ' 条' : '';
|
|
2523
2542
|
this.cloudMsg = '共 ' + this.cloudRepos.length + ' 个仓库(按最近更新排序)' + idxHint;
|
|
2524
2543
|
// 云端获取后**重新读索引刷新本地列表**——后端已把云端仓库(含
|
|
2525
|
-
// defaultBranch/pushedAt/visibility 云端真源)写进 dsh-repo-index.
|
|
2544
|
+
// defaultBranch/pushedAt/visibility 云端真源)写进 dsh-repo-index.jsonl,
|
|
2526
2545
|
// 侧边栏本地面板的远端状态(默认分支/云端更新/仅云端标记)随之更新。
|
|
2527
2546
|
void this.scanLocalRepos(this.localPath, false);
|
|
2528
2547
|
} else {
|
|
@@ -2842,6 +2861,7 @@ window.__ModuleLoader__.load({
|
|
|
2842
2861
|
}
|
|
2843
2862
|
|
|
2844
2863
|
/** 审计 tab 顶部即时反馈(区别于设置 tab 的 flashSaved)。 */
|
|
2864
|
+
/* ─── 第 13/14 片 · Controller 动作注入(接 controller.js 的类体,方法声明不可拆出类外) ─────────────────── */
|
|
2845
2865
|
setStatus(msg) {
|
|
2846
2866
|
this.statusMsg = String(msg || '');
|
|
2847
2867
|
if (this.statusTimer) clearTimeout(this.statusTimer);
|
|
@@ -2885,9 +2905,9 @@ window.__ModuleLoader__.load({
|
|
|
2885
2905
|
toggleAudit(checked) {
|
|
2886
2906
|
this.auditEnabled = !!checked;
|
|
2887
2907
|
// 交互修正:关闭父开关时**不再**把子开关的勾选抹掉。
|
|
2888
|
-
//
|
|
2908
|
+
// 子开关的勾选状态独立保存,父开关只管「此刻生不生效」(host 侧注入由
|
|
2889
2909
|
// cfg.auditEnabled && cfg.injectRequirements 门控)。原实现静默清勾选,
|
|
2890
|
-
//
|
|
2910
|
+
// 重开父开关时还得再点一遍子开关,且看不出勾选是被谁清掉的。
|
|
2891
2911
|
this.commitSetting('auditEnabled', this.auditEnabled, this.auditEnabled
|
|
2892
2912
|
? '✅ 已开启:提交前自动审计'
|
|
2893
2913
|
: '✅ 已关闭:提交前不审计');
|
|
@@ -3121,6 +3141,7 @@ window.__ModuleLoader__.load({
|
|
|
3121
3141
|
|
|
3122
3142
|
const inject = ['slots'];
|
|
3123
3143
|
|
|
3144
|
+
/* ─── 第 14/14 片 · 收尾:注册 settings.section + factory 返回(必须末片) ─────────────────── */
|
|
3124
3145
|
function apply(ctx) {
|
|
3125
3146
|
// 【常驻诊断 · 前端接线失败可见化】apply 整体包一层 try/catch,把真实异常打到控制台。
|
|
3126
3147
|
// 背景:cordis 只把失败的 client entry 标成 failed(页面仅显示
|
|
@@ -3151,7 +3172,7 @@ window.__ModuleLoader__.load({
|
|
|
3151
3172
|
const controller = new dshgp_Controller(scope);
|
|
3152
3173
|
const store = controller.store;
|
|
3153
3174
|
// (修复「重启后不预读」):**每次进设置页都预读**账号信息 + 本地仓库列表
|
|
3154
|
-
// (读 account-status.json / dsh-repo-index.
|
|
3175
|
+
// (读 account-status.json / dsh-repo-index.jsonl,本地文件幂等便宜)——此前的模块级
|
|
3155
3176
|
// `dshgp_startupLoaded` 标记在 DSH bundle 常驻(浏览器不刷新)时保持 true,
|
|
3156
3177
|
// 导致「第一次预读后,重启/重进设置页不再预读」。改为每次 apply 都读,跟随最新 json。
|
|
3157
3178
|
// 后续仍可手动「重新检测 / 扫描」在线刷新。
|
package/lib/context/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
15
15
|
import { hostname as osHostname, networkInterfaces } from 'node:os';
|
|
16
16
|
import { fileURLToPath } from 'node:url';
|
|
17
17
|
import { writeJsonAtomic } from '../git/atomic-json.js';
|
|
18
|
+
import { GIT_GLOBAL_ARGS } from '../core/exec.js';
|
|
18
19
|
|
|
19
20
|
/* ───────── 工具探测常量 ───────── */
|
|
20
21
|
const PROBE_TIMEOUT_MS = 8000; // 工具路径/版本探测子进程超时
|
|
@@ -210,7 +211,7 @@ export function mapWorkspaceDirs({ workspaceRoot = '', cwd = process.cwd(), maxC
|
|
|
210
211
|
const root = workspaceRoot ? resolve(workspaceRoot) : cur;
|
|
211
212
|
let projectDir = root;
|
|
212
213
|
try {
|
|
213
|
-
const gitProbe = spawnSync('git', ['rev-parse', '--show-toplevel'], {
|
|
214
|
+
const gitProbe = spawnSync('git', [...GIT_GLOBAL_ARGS, 'rev-parse', '--show-toplevel'], {
|
|
214
215
|
cwd: cur, encoding: 'utf8', timeout: PROBE_TIMEOUT_MS, stdio: ['pipe', 'pipe', 'ignore'],
|
|
215
216
|
});
|
|
216
217
|
const top = String(gitProbe.stdout || '').trim();
|
package/lib/core/atomic-json.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* 统一 JSON 文件原子读写(收敛:多处重复的「读 JSON → 改 → 原子写回」抽成一份)。
|
|
3
3
|
*
|
|
4
4
|
* 消费方(原各自实现):settings-bridge(config.json)、account-status(account-status.json)、
|
|
5
|
-
* scan-runner(scan-live.json)、repo-index(dsh-repo-index.
|
|
5
|
+
* scan-runner(scan-live.json)、repo-index(dsh-repo-index.jsonl,JSONL 逐行原子写)、credentials 等。
|
|
6
6
|
*
|
|
7
7
|
* 原子写语义:写同目录 `.tmp` 再 rename(同卷原子替换,避免写一半崩溃留坏文件);
|
|
8
8
|
* CIFS 可能改不了 mode,chmod 失败静默(与各原实现一致)。
|
|
File without changes
|