dsh-git-push 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +76 -48
  2. package/cli.mjs +4 -3
  3. package/lib/app/apply.js +11 -9
  4. package/lib/app/command-registry.js +4 -2
  5. package/lib/app/handlers/http-constants.js +8 -0
  6. package/lib/app/handlers/preprocess.js +3 -6
  7. package/lib/app/handlers/repo-actions.js +0 -1
  8. package/lib/app/handlers/repos.js +137 -10
  9. package/lib/app/handlers/settings.js +34 -15
  10. package/lib/app/index.js +1 -1
  11. package/lib/app/inject-text.js +3 -18
  12. package/lib/app/schema.js +20 -10
  13. package/lib/app/settings-bridge.js +60 -8
  14. package/lib/app/tool-call.js +26 -22
  15. package/lib/cli/commands-vcs.mjs +35 -1
  16. package/lib/cli/shared.mjs +1 -1
  17. package/lib/client/index.js +11 -16
  18. package/lib/client-parts/git/account.js +21 -12
  19. package/lib/client-parts/git/actions.js +23 -77
  20. package/lib/client-parts/git/apply.js +8 -2
  21. package/lib/client-parts/git/browser.js +1 -1
  22. package/lib/client-parts/git/const.js +33 -1
  23. package/lib/client-parts/git/controller.js +175 -176
  24. package/lib/client-parts/git/icons.js +1 -1
  25. package/lib/client-parts/git/loader.js +1 -1
  26. package/lib/client-parts/git/npm.js +56 -37
  27. package/lib/client-parts/git/page.js +53 -1
  28. package/lib/client-parts/git/repo.js +8 -1
  29. package/lib/client-parts/git/settings.js +13 -1
  30. package/lib/client-parts/git/state.js +237 -0
  31. package/lib/client-parts/git/utils.js +1 -1
  32. package/lib/client.js +631 -312
  33. package/lib/commit-push/pre-commit-engine.js +584 -32
  34. package/lib/commit-push.js +63 -47
  35. package/lib/context/index.js +7 -5
  36. package/lib/core/config.js +1 -27
  37. package/lib/core/exec.js +2 -11
  38. package/lib/git/identity-rewrite.js +1 -1
  39. package/lib/git/index.js +1 -1
  40. package/lib/git/push.js +2 -17
  41. package/lib/git/repo-index.js +8 -3
  42. package/lib/npm/install.js +1 -1
  43. package/lib/npm/registry.js +2 -2
  44. package/lib/plugin/auto-push.js +3 -6
  45. package/lib/preprocess/providers.js +5 -1
  46. package/lib/self/index.js +1 -1
  47. package/package.json +4 -7
  48. package/skills/dev/dsh-git-push.md +9 -9
  49. package/skills/guide/guide-commit-push.md +11 -13
  50. package/skills/workflow/README.md +0 -1
  51. package/skills/workflow/task-completion-report.md +2 -2
  52. package/.auditignore +0 -30
  53. package/.gitignore +0 -43
  54. package/lib/BUGFIX-NOTES-2026-09-14.md +0 -278
  55. package/lib/app/schema-preprocess.js +0 -42
  56. package/lib/user-requirements.json +0 -15
  57. package/scripts/build-client.mjs +0 -133
  58. package/scripts/bump-version.mjs +0 -178
  59. package/scripts/check.mjs +0 -205
  60. package/scripts/doc-func.mjs +0 -212
  61. package/scripts/doc-tree.mjs +0 -458
  62. package/scripts/doc-version.mjs +0 -149
  63. package/scripts/local-registry.mjs +0 -38
  64. package/scripts/scan-version.mjs +0 -125
  65. package/scripts/version-source.mjs +0 -173
@@ -1,4 +1,4 @@
1
- /* ─── 第 12/13 片 · Controller 动作注入(接 controller.js 的类体,方法声明不可拆出类外) ─────────────────── */
1
+ /* ─── 第 13/14 片 · Controller 动作注入(接 controller.js 的类体,方法声明不可拆出类外) ─────────────────── */
2
2
  setStatus(msg) {
3
3
  this.statusMsg = String(msg || '');
4
4
  if (this.statusTimer) clearTimeout(this.statusTimer);
@@ -8,26 +8,10 @@
8
8
  }, dshgp_SAVED_MSG_MS);
9
9
  }
10
10
 
11
- /** 上下调整规则包次序(下覆盖上)。 */
12
- moveSlot(slot, dir) {
13
- const arr = [...this.ruleOrder];
14
- const i = arr.indexOf(slot);
15
- const j = i + dir;
16
- if (i < 0 || j < 0 || j >= arr.length) return;
17
- [arr[i], arr[j]] = [arr[j], arr[i]];
18
- this.ruleOrder = arr;
19
- this.publish();
20
- // 次序持久化走 HTTP settings-set(写插件私有 config.json)。
21
- // 不再 scope.set——scope.set 会把 auditRuleOrder 写进公共 settings.yaml
22
- // (跨实例锁竞争 + isLoopback=memory 陷阱,见 settings-bridge.js 头部说明)。
23
- this.persistSetting('auditRuleOrder', arr);
24
- this.setStatus('✅ 规则包次序已保存:' + arr.join(' → '));
25
- }
26
11
 
27
12
  /**
28
- * 前端设置写入通用入口(抽公共函数消除 toggle 系列重复)。
29
- * 统一四件套:标记 editedKeys(防 loadSettingsFromHttp 异步 GET 旧值覆盖弹回)
30
- * → publish(UI 立即反映)→ persistSetting(HTTP 落盘 config.json + loopback scope 双通道)。
13
+ * 前端设置写入通用入口(统一三件事:标记 editedKeys 防异步 GET 旧值弹回
14
+ * → publish 让 UI 立即反映 → persistSetting 走 HTTP 落盘 config.json)。
31
15
  * @param {string} key 设置键
32
16
  * @param {unknown} value 值
33
17
  * @param {string} okMsg flashSaved 成功文案(空=静默)
@@ -38,18 +22,6 @@
38
22
  this.persistSetting(key, value, okMsg);
39
23
  }
40
24
 
41
- /** 审计开关(写回 auditEnabled)。 */
42
- toggleAudit(checked) {
43
- this.auditEnabled = !!checked;
44
- // 交互修正:关闭父开关时**不再**把子开关的勾选抹掉。
45
- // 子开关的勾选状态独立保存,父开关只管「此刻生不生效」(host 侧注入由
46
- // cfg.auditEnabled && cfg.injectRequirements 门控)。原实现静默清勾选,
47
- // 重开父开关时还得再点一遍子开关,且看不出勾选是被谁清掉的。
48
- this.commitSetting('auditEnabled', this.auditEnabled, this.auditEnabled
49
- ? '✅ 已开启:提交前自动审计'
50
- : '✅ 已关闭:提交前不审计');
51
- }
52
-
53
25
  /**
54
26
  * 设置持久化统一入口(**零 scope.set**,单通道走 host HTTP /settings-set → 写插件私有
55
27
  * config.json)。彻底移除 scope.set:
@@ -97,22 +69,11 @@
97
69
  }
98
70
 
99
71
  /**
100
- * 注入开发者要求清单开关(auditEnabled 的子开关)。
101
- * 父开关关闭时**仍可勾选**(保留偏好、只置灰、不注入)——原实现在这里直接 return,
102
- * 用户点了没任何反应,必须先开父开关再点一次(两遍)。
103
- */
104
- toggleInjectRequirements(checked) {
105
- this.injectRequirements = !!checked;
106
- this.commitSetting('injectRequirements', this.injectRequirements, this.injectRequirements
107
- ? (this.auditEnabled ? '✅ 已开启:注入开发者要求清单' : '✅ 已勾选:待开启「提交前自动审计」后生效')
108
- : '✅ 已关闭:不注入要求清单');
109
- }
110
72
 
111
73
  /**
112
74
  * 注入总开关(写回 injectSystemPrompt;默认开)。
113
75
  * 关 = host 侧 systemPrompt 段全部返回空串 + 上下文注入不注入;
114
- * 开 = 功能用法/README 提醒/要求清单走系统提示词,环境(工作区/工具/skill 入口)走上下文首条注入。
115
- * 注入段里的「开发者要求清单」仍受 auditEnabled + injectRequirements 双重门控。
76
+ * 开 = 功能用法/README 提醒走系统提示词,环境(工作区/工具/skill 入口)走上下文首条注入。
116
77
  */
117
78
  toggleInjectSystemPrompt(checked) {
118
79
  this.injectSystemPrompt = !!checked;
@@ -124,36 +85,16 @@
124
85
  }
125
86
 
126
87
  /**
127
- * 审计扫描范围切换:diff=仅本次变动(auditChanged,默认)/ full=全量(auditFull)。
128
- * 按钮式单击切换;持久化走 host HTTP(persistence=memory 陷阱绕开方案,见 settings-bridge.js)。
129
- */
130
- toggleAuditScanScope(scope) {
131
- const next = scope === 'full' ? 'full' : 'diff';
132
- if (this.auditScanScope === next) return;
133
- this.auditScanScope = next;
134
- this.commitSetting('auditScanScope', next, next === 'full'
135
- ? '✅ 已切换:审计扫描范围 = 全量(auditFull)'
136
- : '✅ 已切换:审计扫描范围 = 部分(auditChanged,仅本次变动)');
137
- }
138
-
139
- /** 权重维度编辑(合并写回 weightOverrides JSON)。 */
140
- editWeight(key, value) {
141
- this.weightValues = { ...(this.weightValues || {}), [key]: value };
142
- const json = JSON.stringify(this.weightValues);
143
- this.commitSetting('weightOverrides', json, '✅ 权重已保存(合计 ' + dshgp_DIMENSIONS.reduce((a, d) => a + (this.weightValues[d.key] != null ? this.weightValues[d.key] : d.def), 0) + '),下次审计生效');
144
- }
145
-
146
- /**
147
- * 新增 / 收敛:审计进阶 / 推送通道设置项通用提交。
88
+ * 设置项的通用提交入口(下拉/数字/开关都走这里)。
148
89
  * 更新本地镜像 → 走 commitSetting(HTTP settings-set → config.json)→ 即时反馈。
149
- * @param {string} key maxScanFiles|pushMethod
90
+ * @param {string} key preCommitEnabled|pushMethod|pushGate|maxCloneFileMB|cloneConcurrency|autoPush*
150
91
  * @param {unknown} value 新值
151
92
  */
152
93
  setAdvanced(key, value) {
153
- const ok = /^(maxScanFiles|maxCloneFileMB|cloneConcurrency|pushMethod|pushGate|autoPushEnabled|autoPushTriggerText|autoPushScope)$/.test(key);
94
+ const ok = /^(preCommitEnabled|maxCloneFileMB|cloneConcurrency|pushMethod|pushGate|autoPushEnabled|autoPushTriggerText|autoPushScope)$/.test(key);
154
95
  if (!ok) { this.setStatus('❌ 未知设置键: ' + key); return; }
155
- const numKeys = { maxScanFiles: 1, maxCloneFileMB: 1, cloneConcurrency: 1 };
156
- const boolKeys = { pushGate: 1, autoPushEnabled: 1 };
96
+ const numKeys = { maxCloneFileMB: 1, cloneConcurrency: 1 };
97
+ const boolKeys = { pushGate: 1, autoPushEnabled: 1, preCommitEnabled: 1 };
157
98
  const enumKeys = { pushMethod: ['ssh', 'api', 'auto'], autoPushScope: ['session', 'all'] };
158
99
  let v = value;
159
100
  if (boolKeys[key]) v = value === true;
@@ -250,17 +191,22 @@
250
191
  save: () => { void this.save(); },
251
192
  discard: () => this.discard(),
252
193
  genKey: () => { void this.genKey(); },
253
- toggleAudit: (checked) => this.toggleAudit(checked),
254
- // 子开关动作必须在这里暴露:页面 props 来自 inject(),漏了会让 onChange 调到 undefined
255
- toggleInjectRequirements: (checked) => this.toggleInjectRequirements(checked),
194
+ // 动作必须在这里暴露:页面 props 来自 inject(),漏了会让 onChange 调到 undefined
195
+ togglePreCommit: (checked) => this.setAdvanced('preCommitEnabled', checked === true),
256
196
  toggleInjectSystemPrompt: (checked) => this.toggleInjectSystemPrompt(checked),
257
- toggleAuditScanScope: (scope) => this.toggleAuditScanScope(scope),
258
- editWeight: (key, value) => this.editWeight(key, value),
259
197
  setAdvanced: (key, value) => this.setAdvanced(key, value),
260
- moveSlot: (slot, dir) => this.moveSlot(slot, dir),
261
- toggleDisabled: (slot) => { void this.toggleDisabled(slot); },
262
- // 统一刷新入口(参数控制刷哪部分)——设置 / 账号 / 本地仓库 / 云端 / 槽位
198
+ // 统一刷新入口(参数控制刷哪部分)——设置 / 账号 / 本地仓库 / 云端
263
199
  refresh: (parts, opts) => { void this.refresh(parts, opts); },
200
+ // §三:面板重建(切 tab 重挂载)后——①补读"没读过/已过期"的资源(幂等,不制造请求风暴)
201
+ // ②按当前值重放显示态(R3)。两个动作都不产生重复请求。
202
+ panelRebuilt: () => {
203
+ void this.uiState.ensureFresh(['settings', 'account', 'npm']);
204
+ this.uiState.markRebuilt();
205
+ },
206
+ // §四:某资源读取失败后的重试入口(不清空已有内容,只重读它)
207
+ retryResource: (name) => { void this.uiState.reload(name); },
208
+ // npm 子页「已装依赖」:按目录重读(数据归工厂,组件不再自己 fetch)
209
+ reloadNpmPackages: (dir) => { void this.uiState.reload('npmPackages', { dir: dir || '' }); },
264
210
  refreshAccount: () => { void this.refresh('account'); }, // 离线读 json(启动/push后/渲染)
265
211
  recheckAccount: () => { void this.recheckAccount(); }, // 在线校验写 json(「重新检测」)
266
212
  // npm 账号:与 GitHub 账号**同一套注入与语义**(离线刷新 / 在线校验 / 名下包列表)
@@ -278,7 +224,7 @@
278
224
  startScan: (path) => { void this.startScan(path); }, // 扫描按钮:独立进程后台扫描 + 逐条追加
279
225
  loadCloudRepos: () => { void this.refresh('cloud'); },
280
226
  pushLocalRepo: (path) => { void this.pushLocalRepo(path); },
281
- commitLocalRepo: (path) => { void this.commitLocalRepo(path); }, // 本地 commit(复用提交审计)
227
+ commitLocalRepo: (path) => { void this.commitLocalRepo(path); }, // 本地 commit(走 commitAndPush 门禁链路)
282
228
  cloneFlow: (repo) => this.cloneFlow(repo),
283
229
  requestVisSwitch: (fullName, target) => this.requestVisSwitch(fullName, target), // 弹独立确认面板(1.5.4)
284
230
  confirmVisSwitch: () => { void this.confirmVisSwitch(); },
@@ -1,4 +1,4 @@
1
- /* ─── 第 13/13 片 · 收尾:注册 settings.section + factory 返回(必须末片) ─────────────────── */
1
+ /* ─── 第 14/14 片 · 收尾:注册 settings.section + factory 返回(必须末片) ─────────────────── */
2
2
  function apply(ctx) {
3
3
  // 【常驻诊断 · 前端接线失败可见化】apply 整体包一层 try/catch,把真实异常打到控制台。
4
4
  // 背景:cordis 只把失败的 client entry 标成 failed(页面仅显示
@@ -36,7 +36,11 @@
36
36
  // 读取复用「本地仓库列表选择的路径」(localStorage dshgp-scan-path,本地面板扫描时写入);
37
37
  // 没选过则空 → 后端自动识别 DSH 家根。
38
38
  let savedPath = dshgp_localGet('dshgp-scan-path');
39
- void controller.refreshAccount();
39
+ // ── R2:读回早于首次渲染 ──
40
+ // 首屏必需资源(设置/账号/npm)由状态工厂 loadAll 一次读齐;读齐前 SectionPage
41
+ // 渲染骨架而不是"默认值当成事实"的内容。列表单独读(它自带加载态,不拖首屏)。
42
+ // 仍然不 await:cordis apply 有激活超时预算,长 await 会让整个插件激活失败。
43
+ void controller.uiState.loadAll({ names: controller.uiFirstPaintNames });
40
44
  void controller.scanLocalRepos(savedPath, false); // 只读索引(不重建,读 json)
41
45
  // uSES 桥:SnapshotStore 是裸 observable,用 useSyncExternalStore 自建 selector hook
42
46
  const useCardState = (selector) => {
@@ -48,6 +52,8 @@
48
52
  function SectionPage() {
49
53
  const state = useCardState((s) => s);
50
54
  if (!state.available) return null;
55
+ // R2 门禁:首屏必需资源未读齐 ⇒ 骨架(明确"正在读"),绝不渲染默认值冒充事实
56
+ if (!state.uiReady) return jsx.jsx(dshgp_LoadingSkeleton, {});
51
57
  const props = makeProps(state);
52
58
  return jsx.jsx(dshgp_GitPushPage, props);
53
59
  }
@@ -1,4 +1,4 @@
1
- /* ─── 第 6/13 片 · 目录选择器(browseEnsureDom/browseLoad/browseOpen/browseClose/browseAttach) ─────────────────── */
1
+ /* ─── 第 7/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 场景)
@@ -1,4 +1,4 @@
1
- /* ─── 第 2/13 片 · 常量区(NS/维度表/样式串) ─────────────────── */
1
+ /* ─── 第 2/14 片 · 常量区(NS/维度表/样式串) ─────────────────── */
2
2
  // 面板「忙碌中」状态键的前缀(clone / vis / push 三类操作共用**同一出处**)。
3
3
  // 此前这三个字面量散落在组件与类方法里各写一遍,改一处不会同步另一处;
4
4
  // 命名带 dshgp_ 前缀,符合本文件的形态铁律(防 combo 拼接撞名)。
@@ -34,6 +34,29 @@
34
34
  const dshgp_SAVED_MSG_MS = 4000; // 「已保存」提示显示时长
35
35
  const dshgp_LOG_TRUNCATE = 40; // 调试日志 value 截断长度
36
36
 
37
+ /**
38
+ * 设置类字段的默认值 —— **客户端分片内的唯一来源**(§五)。
39
+ *
40
+ * 为什么收在这里:这些值此前在 controller 构造函数里逐行手写(maxCloneFileMB=10、
41
+ * cloneConcurrency=6、pushMethod='ssh'…),而 lib/client/index.js 的 SETTINGS_SCHEMA
42
+ * 里还有一份,两处靠人眼保持一致。改一处漏另一处就会出现「首帧显示 10、读回变 20」
43
+ * 这种谁也说不清的现象。现在 controller 直接 Object.assign 这份,
44
+ * 测试再断言它与 SETTINGS_SCHEMA 逐键一致(两处都要有,缺一即红)。
45
+ */
46
+ const dshgp_DEFAULT_SETTINGS = {
47
+ preCommitEnabled: false, // 提交前预处理开关(默认关)
48
+ injectSystemPrompt: true, // 注入总开关(默认开)
49
+ maxCloneFileMB: 10, // clone 单文件体积上限(MB);0=不限
50
+ cloneConcurrency: 6, // clone 并发下载数
51
+ pushMethod: 'ssh', // 推送通道:ssh | api | auto
52
+ pushGate: false, // 推送门禁(开启后 push 需显式放行)
53
+ // 任务完成自动推送(SETTINGS_SCHEMA 里声明了,首帧也必须给值 ——
54
+ // 否则勾选框/文本框读到 undefined,显示为空而不是默认值)
55
+ autoPushEnabled: false,
56
+ autoPushTriggerText: '✅任务完成',
57
+ autoPushScope: 'session',
58
+ };
59
+
37
60
  const dshgp_css = [
38
61
  // 选项卡条(对齐插件市场)
39
62
  '.dshgp_tabs{display:flex;align-items:flex-end;gap:2px;border-bottom:1px solid var(--dsw-alias-border-l2);margin:0 0 12px}',
@@ -214,5 +237,14 @@
214
237
  '.dshgp_browsedir:hover{background:color-mix(in srgb,var(--dsw-alias-brand-primary) 12%,transparent)}',
215
238
  '.dshgp_browsehint{font-size:12px;color:var(--dsw-alias-label-tertiary);padding:8px}',
216
239
  '.dshgp_browsefoot{display:flex;justify-content:flex-end}',
240
+ // 首屏骨架(R2 门禁等待期)+ 资源状态条(读取中/失败可重试/过期同步中)
241
+ '.dshgp_skel{display:flex;flex-direction:column;gap:10px;padding:4px 2px}',
242
+ '.dshgp_skelblock{border-radius:10px;padding:14px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 6%,transparent)}',
243
+ '.dshgp_skelline{height:10px;border-radius:6px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 13%,transparent);margin:6px 0}',
244
+ '.dshgp_skelline_s{width:38%}',
245
+ '.dshgp_skelline_m{width:62%}',
246
+ '.dshgp_resstatus{font-size:12px;padding:6px 10px;border-radius:8px;margin:6px 0}',
247
+ '.dshgp_resstatus_err{background:color-mix(in srgb,var(--dsw-alias-label-danger,#d33) 12%,transparent);color:var(--dsw-alias-label-primary)}',
248
+ '.dshgp_resstatus_stale{background:color-mix(in srgb,var(--dsw-alias-label-primary) 7%,transparent);color:var(--dsw-alias-label-secondary)}',
217
249
  ].join('');
218
250