dsh-kaogong 1.14.0 → 1.15.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/CLAUDE.md CHANGED
@@ -107,3 +107,17 @@
107
107
  - **㉛(入口纪律·用户明确要求)**:方法论**不设独立一级导航**,入口 = 「🎯 专题 → 📖 方法论」分区(`data-kg-hub-tab=method`),该分区内主视图即花生十三体系(`data-kg-hs13-root`);原 kaogong-skill 十主题降为默认折叠「另见」区。**新增业务视图一律先问「该不该进一级导航」,本插件倾向收敛进专题枢纽**;render 断言按属性锚定(`data-kg-hs13-tab` / `data-kg-hub-tab`),禁按文本匹配(「花生十三体系」与「方法论」标签会撞名)。
108
108
  - **㉜(检索噪声的正确处理)**:中文 bigram 下任何中文串都会产生命中,实测**噪声分数反而高于真实短查询**(「数量」1.68 vs「不存在的词」4.79)→ 阈值过滤会误杀真实查询。正解 = **只裁尾**(`score < max(1.0, top×0.15)` 且**永留首条**)+ 三档 `confidence`/`phraseHit` 提示,**低置信度结果不丢弃**。教训:**给「相关性」建模前先实测分数分布,别用直觉阈值。**
109
109
  - **㉝(R28 打包卫生:声明的文件必须在包里)**:awesome-dsh-plugin 维护者实测 tarball 发现 `cordis.patch.yml` **不在** 1.11.0/1.12.0/1.13.0 的 npm 包里,而 `package.json` 的 `dsh.bundle.patch` 指向它 —— 按市场条目 npm 安装会拿到**缺 patch 的 bundle**(装了等于没装)。根因:`files` 白名单漏列。修法:把 `cordis.patch.yml` 与随包模板 `data/study-plan.md` 加入 `files`,并加 `prepare` 脚本让**源码安装**也能构建(此前只有 `prepack`,且 `.gitignore` 排除 `dist/` → GitHub 装法不可用)。**机器守卫(R28 族)**:smoke 直接跑 `npm pack --dry-run --json --ignore-scripts` 核对「声明 → 实体」零断链,并**反向**断言「语料/本地调试 overlay 不得入包」(`cordis.local.yml` 含绝对路径,入包会污染他人环境)。**规矩:凡 `package.json` 里被其他字段引用的文件(patch/模板/icon),一律同时进 `files` 并以 pack 实测断言守卫;「声明 vs 实体」必须同源可核——扩展名换了,v1.8 白盒假阳性的同一条纪律仍然成立。**
110
+
111
+ ## cycle-19 事故与教训(v1.14.0 研究文档体系 + 白盒量化增强)
112
+ - **㉞(对账假漂移第三例·UI 壳混入对账)**:沙箱旅程实测 `/api/capabilities.reconciliation.missingProducers=["/"]`——同源通道把 UI 页面壳(rel="/")记进遥测端点表,被「消费 ∧ ¬声明」判成漂移。与 v1.8 遥测口径、cycle-18 影子端点同族。根修双层:`isDeclaredEndpoint` 排除 `/` 与 `/index.html`;`/api/capabilities` 对账消费集再过滤壳路径与 `__unmatched__` 桶。守卫=smoke R-OBS-03。**教训:遥测「记什么」与「对账什么」是两个口径——前者可宽(观测余量),后者必须严(判定语义);漏斗每一层都要显式声明自己过滤什么。**
113
+ - **㉟(工具输出标记行)**:六工具输出统一尾部 `kgMarkTail` 标记行(`[kaogong vX.Y.Z · 服务:up|down · ws:<ns>]`,dsh-ops host-contract 卡片模式)——版本锚/服务态/隔离键三要素让「数据来自哪代服务」一眼可辨,是㉑「呈现层同源」纪律的推论。守卫=smoke R-OUT-01/02(tail 调用数 ≥ 工具注册数)。
114
+ - **㊱(生命周期量化口径)**:lifecycle.jsonl 只记事件时间戳,无显式 duration——`cumMs` 用「阶段 at − 进程首事件 ts」计算(自启动累计耗时),`bootMs` 用「最近 server-listen − 首事件」;字段可选缺失即 UI 徽章降级,绝不臆造 0 值。**教训:给既有数据「补量化」时先声明口径(从什么基准起算),面板数字才可解释。**
115
+ - **㊲(文档引用也是声明·断言也要对准事实)**:smoke RDOC 抽验文档引用的代码符号(R14 事实基座);R-GRAPH-01 首跑失败因断言字符串与实际函数签名不符——**断言与源码签名漂移和「文档与代码漂移」同罪**,守卫自己也要被验证。
116
+ - **㊳(npm publish 的 cwd 陷阱)**:`npm publish` 在错误 cwd(如宿主 profile 根)执行会读到别的 package.json(version 无 version 字段 → semver.parse(null).prerelease 抛 TypeError)。修法:发布脚本显式 `process.chdir(发布仓根)` 再 spawn npm。**教训:子进程工具的「当前目录」是隐式参数,必须显式固定并写进脚本,不能依赖调用环境的 cwd。**
117
+ - **㊴(研究文档落地纪律)**:docs/research/ 每篇五段式(数学定义→代码落地文件:行号→中文场景启发→工程价值→可运行验证);「只写有落地的」是硬门槛——smoke RDOC-01/02 守卫存在性与引用真实性,杜绝空谈型文档。
118
+
119
+ ## cycle-20 P0 事故(v1.14.0 后热修:R11 第三次复发)
120
+ - **㊵(门禁裸 tsc 覆写 combo → 插件启动失败/宿主崩溃)**:cycle-19 收口时 `gate-check --record` 的 G3 执行 `.cycles/config.yml` 里 `build_commands: ["npx tsc"]`,**绕过 npm scripts** 把 `dist/client/client.js` 从 combo factory 重写回裸 ESM(7 处行首 `import`);主力 profile 是 `link:` 到开发仓,宿主下次启动(13:44)读到裸 ESM → 组合加载器 `SyntaxError: Unexpected token 'export'` → Client 半不激活("插件启动失败"),异常未隔离时可能拖垮宿主。**这是 R11 的第三次复发(v1.4 裸 ESM、cycle-13 eval-runner 预热竞态、本次门禁),教训②「先 tsc 的 npm scripts 必须接 bundler」只覆盖了 npm scripts,没覆盖「任何直接调 tsc 的外部工具」。**
121
+ **根治三层**:① `.cycles/config.yml` 的 `build_cmd`/`G3.build_commands` 全部改 `npm run build`(门禁不再裸 tsc),smoke `R11-GUARD-01` 静态守卫禁裸 tsc 回归;② 新增 `scripts/assert-combo.mjs` 产物形态硬守卫(行首 import/export + load 头 + return{inject,apply}),挂到 build/prepack/prepare/test/test:render/test:all 末尾与 `postbuild`——**只判不修,构建期发现污染必须响亮失败**;`prepare` 带 `--fix`(安装期可自愈);③ smoke `R11-GUARD-02/03/04` 守卫「所有产出脚本接 bundler+守卫 / 守卫存在 / 当前 combo 形态」。
122
+ **发布物影响面取证**:npm tarball `dsh-kaogong@1.14.0` 的 `dist/client/client.js` 行首 import=0(prepack/prepare 接了 bundler)——**已发布包是好的,无需回滚**;坏产物只在本地开发仓,link: 才让它进宿主。
123
+ **规矩(写入硬性纪律)**:**凡「构建命令」写进任何配置(门禁/CI/Makefile/编辑器任务),必须与 package.json 的 npm scripts 同源,禁止复制裸编译命令**;宿主用 `link:` 的开发仓时,产物形态就是宿主启动的先验条件——构建污染 = 启动事故。`smoke.test.mjs` 的 `readClientBundle()` 自愈只保护测试读取窗口,不保护宿主启动窗口,两者不可互替。
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # dsh-kaogong — 考公备考整合插件(DSH 宿主原生面板)· v1.14.0
1
+ # dsh-kaogong — 考公备考整合插件(DSH 宿主原生面板)· v1.15.0
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/dsh-kaogong.svg?label=npm&color=cb3837)](https://www.npmjs.com/package/dsh-kaogong)
4
4
  [![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
5
5
  [![dsh-plugin](https://img.shields.io/badge/topic-dsh--plugin-6366f1)](https://github.com/topics/dsh-plugin)
6
- [![tests](https://img.shields.io/badge/tests-smoke%20276%20%C2%B7%20render%2050-10b981)](#-开发与验证)
6
+ [![tests](https://img.shields.io/badge/tests-smoke%20293%20%C2%B7%20render%2051-10b981)](#-开发与验证)
7
7
 
8
8
  > **一句话**:把 **16 个**优秀开源考公仓库整合为 [DeepSeek Harness](https://github.com/deepseek-ai)(DSH)宿主内的**原生**学习平台 ——
9
9
  > 刷题 / SRS 错题本 / 真题卷 / 整卷模考 / 申论评改 / **花生十三体系方法论** / 可交互知识图谱 / 白盒可观测,**完全离线可用**。
@@ -45,7 +45,7 @@
45
45
 
46
46
  # 2) 刷新 GUI → 点左栏「📚 考公学习」→ 进入「📦 题库管理」
47
47
 
48
- # 3) 点「🚀 一键安装必选包」→ 完成后即可刷题 / 查方法论
48
+ # 3) 点「🚀 一键安装全部必选」→ 完成后即可刷题 / 查方法论
49
49
  ```
50
50
 
51
51
  国内网络建议先在「题库管理 → 镜像代理」填 `https://gh-proxy.com/` 再安装,克隆速度显著提升。
@@ -102,7 +102,7 @@ plugin_manager install_bundle <克隆目录>/dsh-kaogong
102
102
 
103
103
  1. 打开左栏「📚 考公学习」→ **📦 题库管理**
104
104
  2. (国内网络)在「镜像代理」填 `https://gh-proxy.com/` 并保存
105
- 3. 点「🚀 一键安装必选包」,或逐项安装:
105
+ 3. 点「🚀 **一键安装全部必选**」(服务端队列化,并发 2 自动补位,可看批次进度条),也可逐项安装:
106
106
 
107
107
  | 级 | 仓库 | 体积 | 装完可用的功能 |
108
108
  |---|---|---|---|
@@ -116,6 +116,17 @@ plugin_manager install_bundle <克隆目录>/dsh-kaogong
116
116
 
117
117
  > 体积以面板分级列表为准(单一事实源 `REPOS_META`),本文不写死合计值,避免漂移。
118
118
 
119
+ **面板自带的故障恢复能力**(cycle-20):
120
+
121
+ | 能力 | 行为 |
122
+ |---|---|
123
+ | 半成品自动清理 | clone 中断留下的空目录会被自动清理并重装(不会卡在「目录已存在拒绝覆盖」) |
124
+ | 作业历史 | 「🕘 最近作业」保留失败原因与耗时,上次为什么失败一目了然 |
125
+ | 健康巡检 | 空仓库 / 缺 `.git` / 半成品会被显式徽章标记,不再混在「已安装」里 |
126
+ | 旧根提示 | 切换数据根后提示「旧根仍有 N 个仓库(数据未删除)」+ 一键切回 |
127
+ | 空间与可写预检 | 面板显示可用磁盘空间;安装前校验数据根可写与上游地址形状 |
128
+ | 配置校验 | 数据根须为绝对路径、镜像须为 http(s),非法输入不落盘 |
129
+
119
130
  装完即可用。未装对应数据时相关视图会**诚实降级并给出安装引导**,不会白屏、不会假报成功。
120
131
 
121
132
  ## 🔧 升级 / 卸载 / 自检
@@ -331,11 +342,11 @@ src/
331
342
 
332
343
  ```bash
333
344
  npm run build # tsc 类型门 → scripts/bundle-client.mjs 合并 14 模块为宿主单 combo
334
- node smoke.test.mjs # 276 断言 E2E(信标/adopt/隔离/SRS 闭环/图谱算法确定性/专项记忆/
345
+ node smoke.test.mjs # 293 断言 E2E(信标/adopt/隔离/SRS 闭环/图谱算法确定性/专项记忆/
335
346
  # 三布局/流动粒子/白盒三件套/题库管理 R-P-01..06/
336
347
  # 方法论 HS13-01..10 六端点+降级语义+跨 ws 隔离/
337
348
  # 打包卫生 R28: bundle patch 与随包模板必须入包、语料与调试 overlay 不得入包)
338
- node render.test.mjs # 50 断言真实 React 18 + 真实 client.js 集成渲染(零 role=alert 降级;
349
+ node render.test.mjs # 51 断言真实 React 18 + 真实 client.js 集成渲染(零 role=alert 降级;
339
350
  # 含 C18-01..08 方法论五分区 + 专题枢纽锚点 + 白盒链路卡)
340
351
  npm run test:all # 上面两步一起跑
341
352
  ```
@@ -6296,6 +6296,37 @@ const RP_TIERS = {
6296
6296
  optional: { label: '可选', color: '#6366f1', tip: '增强素材,按需拉取避免一次下载过大' },
6297
6297
  };
6298
6298
  const RP_TIER_ORDER = ['required', 'recommended', 'optional'];
6299
+ /** cycle-20 G6:健康巡检徽章(与 server repoState.health 词表同源;字段缺失降级为「未知」) */
6300
+ const RP2_HEALTH = {
6301
+ ok: { text: '健康', color: '#059669', bg: 'rgba(16,185,129,.12)' },
6302
+ empty: { text: '空仓库', color: '#b45309', bg: 'rgba(245,158,11,.14)' },
6303
+ 'half-clone': { text: '半成品', color: '#b45309', bg: 'rgba(245,158,11,.14)' },
6304
+ 'no-git': { text: '缺 .git', color: '#dc2626', bg: 'rgba(239,68,68,.12)' },
6305
+ absent: { text: '未安装', color: '#64748b', bg: 'rgba(148,163,184,.12)' },
6306
+ };
6307
+ /** 最近更新时间人读化(lastCommitAt 毫秒;缺失/无效 → 空串由调用方降级) */
6308
+ function rp2Ago(ms) {
6309
+ const v = Number(ms);
6310
+ if (!isFinite(v) || v <= 0)
6311
+ return '';
6312
+ const d = Math.floor((Date.now() - v) / 86400000);
6313
+ if (d <= 0)
6314
+ return '今天更新';
6315
+ if (d === 1)
6316
+ return '昨天更新';
6317
+ if (d < 30)
6318
+ return d + ' 天前更新';
6319
+ if (d < 365)
6320
+ return Math.floor(d / 30) + ' 个月前更新';
6321
+ return Math.floor(d / 365) + ' 年前更新';
6322
+ }
6323
+ /** 字节数人读化(磁盘可用空间;null 降级) */
6324
+ function rp2Size(mb) {
6325
+ const v = Number(mb);
6326
+ if (!isFinite(v) || v < 0)
6327
+ return '';
6328
+ return v >= 1024 ? (v / 1024).toFixed(1) + ' GB' : Math.round(v) + ' MB';
6329
+ }
6299
6330
  /** 状态徽章(present/isGit/job 三源合成) */
6300
6331
  function rpBadge(r) {
6301
6332
  if (r.job && r.job.state === 'running')
@@ -6346,8 +6377,11 @@ function NativeReposView({ api }) {
6346
6377
  const [busyKey, setBusyKey] = React.useState('');
6347
6378
  const [browse, setBrowse] = React.useState(null); // { key, sub, items, total, truncated, error? }
6348
6379
  const [cfgDraft, setCfgDraft] = React.useState({ root: '', mirror: '' });
6380
+ const [batch, setBatch] = React.useState(null); // cycle-20 G2:一键批量安装进度 { id,state,items,done,total }
6381
+ const [jobsOpen, setJobsOpen] = React.useState(false); // cycle-20 G3:最近作业折叠开关
6349
6382
  const aliveRef = React.useRef(true);
6350
6383
  const pollRef = React.useRef(null);
6384
+ const batchRef = React.useRef(null);
6351
6385
  const load = React.useCallback(async () => {
6352
6386
  try {
6353
6387
  const d = await api('/repos');
@@ -6371,9 +6405,23 @@ function NativeReposView({ api }) {
6371
6405
  }
6372
6406
  catch { } };
6373
6407
  }, [load]);
6374
- // 轮询:存在 running 作业 → 2s 刷新一次;全部结束自动清表(省电)
6408
+ /** cycle-20 G2:批次进度轮询(仅批次运行时;读到 done 即停) */
6409
+ const pollBatch = React.useCallback(async (id) => {
6410
+ try {
6411
+ const d = await api('/repos/batch?id=' + encodeURIComponent(id));
6412
+ if (!aliveRef.current || !d || !d.batch)
6413
+ return;
6414
+ setBatch(d.batch);
6415
+ if (d.batch.state !== 'running') {
6416
+ batchRef.current = null;
6417
+ load();
6418
+ }
6419
+ }
6420
+ catch { /* 批次查询失败不打断主面板 */ }
6421
+ }, [api, load]);
6422
+ // 轮询:存在 running 作业或未完成批次 → 2s 刷新一次;全部结束自动清表(省电)
6375
6423
  React.useEffect(() => {
6376
- const running = data && data.summary && data.summary.running > 0;
6424
+ const running = (data && data.summary && data.summary.running > 0) || (batch && batch.state === 'running');
6377
6425
  if (!running) {
6378
6426
  if (pollRef.current) {
6379
6427
  clearInterval(pollRef.current);
@@ -6383,12 +6431,13 @@ function NativeReposView({ api }) {
6383
6431
  }
6384
6432
  if (pollRef.current)
6385
6433
  return;
6386
- pollRef.current = setInterval(() => { load(); }, 2000);
6434
+ pollRef.current = setInterval(() => { load(); if (batchRef.current)
6435
+ pollBatch(batchRef.current); }, 2000);
6387
6436
  return () => { if (pollRef.current) {
6388
6437
  clearInterval(pollRef.current);
6389
6438
  pollRef.current = null;
6390
6439
  } };
6391
- }, [data, load]);
6440
+ }, [data, batch, load]);
6392
6441
  const post = React.useCallback(async (path, body) => {
6393
6442
  setBusyKey('');
6394
6443
  try {
@@ -6404,7 +6453,28 @@ function NativeReposView({ api }) {
6404
6453
  }
6405
6454
  }, [api, load]);
6406
6455
  const doInstall = (key) => { setBusyKey(key); post('/repos/install', { key }); };
6456
+ /** cycle-20 G2:一键批量安装必选——单次请求交给服务端队列,UI 只跟踪 batchId 进度 */
6457
+ const doInstallBatch = async () => {
6458
+ setErr('');
6459
+ try {
6460
+ const r = await api('/repos/install-batch', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({}) });
6461
+ if (r && r.error) {
6462
+ setErr(r.error);
6463
+ return;
6464
+ }
6465
+ if (r && r.batch) {
6466
+ setBatch(r.batch);
6467
+ batchRef.current = r.batchId;
6468
+ }
6469
+ await load();
6470
+ }
6471
+ catch (e) {
6472
+ setErr(String((e && e.message) || e));
6473
+ }
6474
+ };
6407
6475
  const doCancel = (key) => post('/repos/cancel', { key });
6476
+ /** cycle-20 G4:一键切回旧数据根(消解「换根后数据消失」恐慌) */
6477
+ const doSwitchBack = (root) => post('/repos/config', { root });
6408
6478
  const doRemove = (key) => {
6409
6479
  if (!window.confirm('确定删除本地目录 ' + key + '?(仅删除已下载数据,不影响学习进度)'))
6410
6480
  return;
@@ -6437,34 +6507,52 @@ function NativeReposView({ api }) {
6437
6507
  return h('div', {}, err ? h('div', { style: { fontSize: 11.5, color: '#b45309', marginBottom: 8 } }, '⚠ ' + err) : null,
6438
6508
  /* ⓪ 关于本项目(GitHub/Release/Issue/npm 跳转 + 版本徽章) */
6439
6509
  h(RpAboutProject, { self: data.self }),
6440
- /* ① 总览 */
6441
- h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit,minmax(130px,1fr))', gap: 10, marginBottom: 14 } }, h(Stat, { v: (sum.present || 0) + '/' + (sum.total || 0), l: '仓库就绪', color: requiredReady ? '#10b981' : '#ef4444' }), h(Stat, { v: sum.requiredMissing && sum.requiredMissing.length ? sum.requiredMissing.length : 0, l: '必选缺失', color: sum.requiredMissing && sum.requiredMissing.length ? '#ef4444' : '#10b981' }), h(Stat, { v: sum.running || 0, l: '进行中作业', color: (sum.running || 0) ? '#6366f1' : undefined }), data.git === false ? h(Stat, { v: '✗', l: 'git 不可用', color: '#ef4444' }) : h(Stat, { v: '✓', l: 'git 可用', color: '#10b981' })),
6510
+ /* ① 总览(cycle-20:健康汇总 + 可用空间如实呈现,null 即降级不臆造) */
6511
+ h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit,minmax(130px,1fr))', gap: 10, marginBottom: 14 } }, h(Stat, { v: (sum.present || 0) + '/' + (sum.total || 0), l: '仓库就绪', color: requiredReady ? '#10b981' : '#ef4444' }), h(Stat, { v: sum.requiredMissing && sum.requiredMissing.length ? sum.requiredMissing.length : 0, l: '必选缺失', color: sum.requiredMissing && sum.requiredMissing.length ? '#ef4444' : '#10b981' }), h(Stat, { v: sum.running || 0, l: '进行中作业', color: (sum.running || 0) ? '#6366f1' : undefined }), sum.health ? h(Stat, { v: (sum.health.ok || 0) + '/' + (sum.present || 0), l: '健康仓库', color: (sum.health['no-git'] || sum.health['half-clone'] || sum.health.empty) ? '#f59e0b' : '#10b981' }) : null, data.diskFreeMB != null ? h(Stat, { v: rp2Size(data.diskFreeMB), l: '可用空间', color: data.diskFreeMB < 1024 ? '#f59e0b' : undefined }) : null, data.git === false ? h(Stat, { v: '✗', l: 'git 不可用', color: '#ef4444' }) : h(Stat, { v: '✓', l: 'git 可用', color: '#10b981' })),
6512
+ /* ①b cycle-20 G4:旧根提示——换根后旧数据仍在原处,一键切回 */
6513
+ data.previousRoot && data.previousRootRepos > 0
6514
+ ? h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', marginBottom: 12, padding: '8px 12px', borderRadius: 10, background: 'rgba(245,158,11,.08)', border: '1px solid rgba(245,158,11,.25)' } }, h('span', { style: { fontSize: 11.5, color: '#92400e' } }, 'ℹ 上一个数据根 ' + String(data.previousRoot) + ' 仍有 ' + data.previousRootRepos + ' 个仓库(数据未删除,只是当前根不指向它)'), btn('↩ 切回旧根', false, () => doSwitchBack(String(data.previousRoot))))
6515
+ : null,
6442
6516
  /* ② 数据根与镜像配置 */
6443
6517
  h(Card, { title: '🗂 数据根与镜像代理' }, h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', alignItems: 'center', marginBottom: 8 } }, h('span', { style: KV_TAG }, '生效根: ' + String(data.root || '—')), data.rootSource ? h('span', { style: KV_TAG }, '来源: ' + data.rootSource) : null), h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap', marginBottom: 6 } }, h('input', { value: cfgDraft.root, placeholder: '自定义数据根目录(绝对路径,留空=自动)', onChange: (e) => setCfgDraft((c) => Object.assign({}, c, { root: e.target.value })), style: { flex: '1 1 240px', padding: '6px 10px', borderRadius: 8, border: '1.5px solid rgba(148,163,184,.35)', fontSize: 12, fontFamily: 'inherit', background: 'var(--surface-card,#fff)', color: 'var(--text-primary,#0f172a)' } }), btn('保存根目录', false, () => post('/repos/config', { root: cfgDraft.root }))), h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap' } }, h('input', { value: cfgDraft.mirror, placeholder: '镜像前缀(如 https://gh-proxy.com/),留空=直连', onChange: (e) => setCfgDraft((c) => Object.assign({}, c, { mirror: e.target.value })), style: { flex: '1 1 240px', padding: '6px 10px', borderRadius: 8, border: '1.5px solid rgba(148,163,184,.35)', fontSize: 12, fontFamily: 'inherit', background: 'var(--surface-card,#fff)', color: 'var(--text-primary,#0f172a)' } }), btn('保存镜像', false, () => post('/repos/config', { mirror: cfgDraft.mirror }))), h('div', { style: { fontSize: 10.5, color: '#94a3b8', marginTop: 6 } }, '镜像前缀对 clone/pull 同时生效;国内网络建议 https://gh-proxy.com/')),
6444
- /* ③ 一键必选 */
6518
+ /* ③ 一键必选(cycle-20 G2:真·一键——单次请求交给服务端队列,UI 显示批次进度) */
6445
6519
  !requiredReady
6446
6520
  ? h(Card, { title: '🚀 一键安装必选包' }, h('div', { style: { fontSize: 12, color: '#64748b', marginBottom: 8 } }, '缺失必选:' + (sum.requiredMissing || []).join('、') + ' —— 装完即可用刷题 / 方法论 / 图推三大核心视图'),
6447
6521
  // cycle-18:不再写死「合计约 363MB」——必选集随版本会变(本轮新增 huasheng13,
6448
6522
  // 且 kaogong-skill 已降为推荐),硬编码体积必然漂移成谎报(R22 陈旧文案教训)。
6449
6523
  // 各仓库体积已在下方分级卡片逐条显示,总览这里只给可执行指引。
6450
- h('div', { style: { fontSize: 10.5, color: '#94a3b8', marginBottom: 8 } }, '国内网络建议先在上方「镜像代理」填 https://gh-proxy.com/ 再安装;各仓库体积见下方分级列表。'), h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap' } }, (sum.requiredMissing || []).map((k) => btn('⬇ ' + k, false, () => doInstall(k), { background: 'linear-gradient(135deg,#6366f1,#8b5cf6)', color: '#fff', border: 0, padding: '7px 16px' }))))
6524
+ h('div', { style: { fontSize: 10.5, color: '#94a3b8', marginBottom: 8 } }, '国内网络建议先在上方「镜像代理」填 https://gh-proxy.com/ 再安装;各仓库体积见下方分级列表。'), h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap', alignItems: 'center' } }, btn('🚀 一键安装全部必选', false, doInstallBatch, { background: 'linear-gradient(135deg,#6366f1,#8b5cf6)', color: '#fff', border: 0, padding: '7px 16px', fontWeight: 700 }), h('span', { style: { fontSize: 10.5, color: '#94a3b8' } }, '服务端队列化(并发 2),无需逐个点击')),
6525
+ // 批次进度条(仅批次存在时显示;字段缺失即降级)
6526
+ batch ? h('div', { style: { marginTop: 10, padding: '8px 10px', borderRadius: 9, background: 'rgba(99,102,241,.06)', border: '1px solid rgba(99,102,241,.18)' } }, h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', fontSize: 11.5, fontWeight: 700, color: '#4338ca', marginBottom: 6 } }, '📦 批次 ' + String(batch.id || '').slice(0, 12) + ' · ' + (batch.state === 'running' ? '进行中' : '已结束') + ' · ' + (batch.done || 0) + '/' + (batch.total || 0)), h('div', { style: { height: 6, borderRadius: 3, background: 'rgba(148,163,184,.25)', overflow: 'hidden' } }, h('i', { style: { display: 'block', height: '100%', width: (batch.total ? Math.round((batch.done || 0) / batch.total * 100) : 0) + '%', background: 'linear-gradient(90deg,#6366f1,#8b5cf6)', borderRadius: 3 } })), h('div', { style: { display: 'flex', gap: 5, flexWrap: 'wrap', marginTop: 6 } }, (batch.items || []).map((it) => h('span', { key: it.key, style: { ...KV_TAG, fontSize: 9.5, background: it.state === 'done' ? 'rgba(16,185,129,.12)' : it.state === 'failed' || it.state === 'skipped' ? 'rgba(239,68,68,.12)' : 'rgba(148,163,184,.14)', color: it.state === 'done' ? '#059669' : it.state === 'failed' || it.state === 'skipped' ? '#dc2626' : '#475569' }, title: it.error || '' }, it.key + ' ' + it.state))))
6527
+ : null)
6528
+ : null,
6529
+ /* ③b cycle-20 G3:最近作业归档(失败原因/耗时可追溯,折叠省空间) */
6530
+ Array.isArray(data.recentJobs) && data.recentJobs.length
6531
+ ? h(Card, { title: '🕘 最近作业 · ' + data.recentJobs.length + ' 条' }, h('button', { style: KV_BTN, onClick: () => setJobsOpen(v => !v) }, jobsOpen ? '▾ 收起' : '▸ 展开历史'), jobsOpen ? h('div', { style: { marginTop: 6 } }, data.recentJobs.map((j, i) => h('div', { key: 'rj' + i, style: { display: 'flex', gap: 8, flexWrap: 'wrap', padding: '4px 0', borderBottom: '1px dashed rgba(148,163,184,.15)', fontSize: 10.5, color: '#64748b' } }, h('span', { style: { fontFamily: 'monospace', minWidth: 130 } }, String(j.key || '?')), h('span', { style: { color: j.state === 'done' ? '#059669' : j.state === 'failed' ? '#dc2626' : '#475569', fontWeight: 700 } }, j.state + ' · ' + String(j.action || '')), h('span', null, (j.elapsedSec || 0) + 's'), j.error ? h('span', { style: { color: '#b45309' }, title: j.error }, '⚠ ' + String(j.error).slice(0, 60)) : null))) : null)
6451
6532
  : null,
6452
6533
  /* ④ 分级仓库卡片 */
6453
6534
  RP_TIER_ORDER.map(tier => h(Card, { key: 'tier-' + tier, title: (RP_TIERS[tier].label) + ' · ' + grouped[tier].length + ' 个(' + tier + ')' }, h('div', { style: { fontSize: 10.5, color: '#94a3b8', marginBottom: 8 } }, RP_TIERS[tier].tip), grouped[tier].map((r) => {
6454
6535
  const b = rpBadge(r);
6455
6536
  const running = r.job && r.job.state === 'running';
6456
- return h('div', { key: r.key, style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', padding: '7px 0', borderBottom: '1px dashed rgba(148,163,184,.18)' } }, h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: RP_TIERS[tier].color, flexShrink: 0 } }), h('span', { title: r.desc, style: { fontWeight: 700, fontSize: 12, minWidth: 150 } }, r.key), h('span', { style: { ...KV_TAG, background: b.bg, color: b.fg } }, b.text), r.size ? h('span', { style: { fontSize: 10.5, color: '#94a3b8' } }, r.size) : null, r.present ? h('span', { style: { fontSize: 10.5, color: '#94a3b8' } }, r.files + ' 项') : null, h('span', { style: { marginLeft: 'auto', display: 'flex', gap: 5, flexWrap: 'wrap' } }, running ? btn('⏹ 取消', false, () => doCancel(r.key)) : null, !running ? btn(busyKey === r.key ? '…' : (r.present && r.isGit ? '🔄 更新' : '⬇ 安装'), false, () => doInstall(r.key), r.present && r.isGit ? {} : { background: 'rgba(99,102,241,.1)', color: '#4f46e5', borderColor: 'rgba(99,102,241,.4)', fontWeight: 700 }) : null, r.present ? btn('👁 浏览', false, () => doBrowse(r.key, '')) : null, r.present ? btn('🗑 删除', false, () => doRemove(r.key)) : null, r.upstream ? h('a', { href: r.upstream, target: '_blank', rel: 'noreferrer', title: '上游仓库(致敬原作者)', style: { fontSize: 11, color: '#6366f1', textDecoration: 'none', alignSelf: 'center' } }, '↗') : null), h(RpJobLog, { job: r.job }));
6537
+ return h('div', { key: r.key, style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', padding: '7px 0', borderBottom: '1px dashed rgba(148,163,184,.18)' } }, h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: RP_TIERS[tier].color, flexShrink: 0 } }), h('span', { title: r.desc, style: { fontWeight: 700, fontSize: 12, minWidth: 150 } }, r.key), h('span', { style: { ...KV_TAG, background: b.bg, color: b.fg } }, b.text), r.size ? h('span', { style: { fontSize: 10.5, color: '#94a3b8' } }, r.size) : null, r.present ? h('span', { style: { fontSize: 10.5, color: '#94a3b8' } }, r.files + ' 项') : null,
6538
+ // cycle-20 G6:健康徽章(非 ok 态才显示,避免视觉噪音)+ 最近更新时间
6539
+ r.health && r.health !== 'ok' && r.present
6540
+ ? h('span', { style: { ...KV_TAG, fontSize: 9.5, background: (RP2_HEALTH[r.health] || RP2_HEALTH.absent).bg, color: (RP2_HEALTH[r.health] || RP2_HEALTH.absent).color } }, (RP2_HEALTH[r.health] || RP2_HEALTH.absent).text)
6541
+ : null, rp2Ago(r.lastCommitAt) ? h('span', { style: { fontSize: 9.5, color: '#94a3b8' } }, rp2Ago(r.lastCommitAt)) : null, h('span', { style: { marginLeft: 'auto', display: 'flex', gap: 5, flexWrap: 'wrap' } }, running ? btn('⏹ 取消', false, () => doCancel(r.key)) : null, !running ? btn(busyKey === r.key ? '…' : (r.present && r.isGit ? '🔄 更新' : '⬇ 安装'), false, () => doInstall(r.key), r.present && r.isGit ? {} : { background: 'rgba(99,102,241,.1)', color: '#4f46e5', borderColor: 'rgba(99,102,241,.4)', fontWeight: 700 }) : null, r.present ? btn('👁 浏览', false, () => doBrowse(r.key, '')) : null, r.present ? btn('🗑 删除', false, () => doRemove(r.key)) : null, r.upstream ? h('a', { href: r.upstream, target: '_blank', rel: 'noreferrer', title: '上游仓库(致敬原作者)', style: { fontSize: 11, color: '#6366f1', textDecoration: 'none', alignSelf: 'center' } }, '↗') : null), h(RpJobLog, { job: r.job }));
6457
6542
  }))),
6458
6543
  /* ⑤ 浏览抽屉 */
6459
6544
  browse
6460
- ? h(Card, { title: '👁 浏览 · ' + browse.key + (browse.sub ? ' / ' + browse.sub : '') }, browse.error ? h('div', { style: { fontSize: 12, color: '#b45309' } }, browse.error) : null, browse.sub ? h('div', { style: { marginBottom: 6 } }, btn('← 上级', false, () => doBrowse(browse.key, browse.sub.split('/').slice(0, -1).join('/')))) : null, (browse.items || []).slice(0, 120).map((it) => h('div', {
6545
+ ? h(Card, { title: '👁 浏览 · ' + browse.key + (browse.sub ? ' / ' + browse.sub : '') }, browse.error ? h('div', { style: { fontSize: 12, color: '#b45309' } }, browse.error) : null, browse.sub ? h('div', { style: { marginBottom: 6 } }, btn('← 上级', false, () => doBrowse(browse.key, browse.sub.split('/').slice(0, -1).join('/')))) : null,
6546
+ // cycle-20 G7:渲染服务端返回的 items 全量(limit 由服务端控制),
6547
+ // 文案由 truncated + 真实 total/items.length 派生——杜绝「前 120 项(共 X)」口径矛盾。
6548
+ (browse.items || []).map((it) => h('div', {
6461
6549
  key: it.name,
6462
6550
  style: { display: 'flex', gap: 8, alignItems: 'center', padding: '3px 2px', borderBottom: '1px solid rgba(148,163,184,.1)', fontSize: 11.5, cursor: it.dir ? 'pointer' : 'default' },
6463
6551
  onClick: it.dir ? () => doBrowse(browse.key, (browse.sub ? browse.sub + '/' : '') + it.name) : undefined,
6464
- }, h('span', { style: { width: 18, textAlign: 'center' } }, it.dir ? '📁' : '·'), h('span', { style: { flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, it.name), !it.dir && it.size != null ? h('span', { style: { color: '#94a3b8', fontSize: 10 } }, it.size > 1048576 ? (it.size / 1048576).toFixed(1) + 'MB' : it.size > 1024 ? (it.size / 1024).toFixed(1) + 'KB' : it.size + 'B') : null)), browse.truncated ? h('div', { style: { fontSize: 10.5, color: '#94a3b8', marginTop: 4 } }, '仅显示前 120 项(共 ' + browse.total + ')') : null, h('div', { style: { marginTop: 6 } }, btn('✕ 关闭', false, () => setBrowse(null))))
6552
+ }, h('span', { style: { width: 18, textAlign: 'center' } }, it.dir ? '📁' : '·'), h('span', { style: { flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, it.name), !it.dir && it.size != null ? h('span', { style: { color: '#94a3b8', fontSize: 10 } }, it.size > 1048576 ? (it.size / 1048576).toFixed(1) + 'MB' : it.size > 1024 ? (it.size / 1024).toFixed(1) + 'KB' : it.size + 'B') : null)), browse.truncated ? h('div', { style: { fontSize: 10.5, color: '#94a3b8', marginTop: 4 } }, '仅显示 ' + (browse.items || []).length + ' / ' + (browse.total || 0) + ' 项(服务端上限 ' + (browse.limit || (browse.items || []).length) + ')') : null, h('div', { style: { marginTop: 6 } }, btn('✕ 关闭', false, () => setBrowse(null))))
6465
6553
  : null,
6466
6554
  /* ⑥ 口径说明 */
6467
- h('div', { style: { fontSize: 10.5, color: '#94a3b8', lineHeight: 1.8 } }, '口径:安装=git clone --depth 1(浅克隆省流量)· 已装仓库再点=git pull --ff-only 更新 · 删除仅清本地数据目录(学习进度在 data/progress 不受影响)· ', '非 git 目录受保护拒绝覆盖 · 并发上限 2 · 全部数据归上游仓库作者所有(点 ↗ 致敬原作者)。'));
6555
+ h('div', { style: { fontSize: 10.5, color: '#94a3b8', lineHeight: 1.8 } }, '口径:安装=git clone --depth 1(浅克隆省流量)· 已装仓库再点=git pull --ff-only 更新 · 一键必选走服务端队列(并发 2)· ', '删除仅清本地数据目录(学习进度在 data/progress 不受影响)· clone 失败的半成品自动清理可重装 · ', '健康巡检:空仓库/缺 .git/半成品显式标记 · 非 git 的用户数据目录受保护拒绝覆盖 · ', '全部数据归上游仓库作者所有(点 ↗ 致敬原作者)。'));
6468
6556
  }
6469
6557
 
6470
6558
  __kgM('client/repos-view', { NativeReposView })
@@ -18,6 +18,37 @@ const RP_TIERS = {
18
18
  optional: { label: '可选', color: '#6366f1', tip: '增强素材,按需拉取避免一次下载过大' },
19
19
  };
20
20
  const RP_TIER_ORDER = ['required', 'recommended', 'optional'];
21
+ /** cycle-20 G6:健康巡检徽章(与 server repoState.health 词表同源;字段缺失降级为「未知」) */
22
+ const RP2_HEALTH = {
23
+ ok: { text: '健康', color: '#059669', bg: 'rgba(16,185,129,.12)' },
24
+ empty: { text: '空仓库', color: '#b45309', bg: 'rgba(245,158,11,.14)' },
25
+ 'half-clone': { text: '半成品', color: '#b45309', bg: 'rgba(245,158,11,.14)' },
26
+ 'no-git': { text: '缺 .git', color: '#dc2626', bg: 'rgba(239,68,68,.12)' },
27
+ absent: { text: '未安装', color: '#64748b', bg: 'rgba(148,163,184,.12)' },
28
+ };
29
+ /** 最近更新时间人读化(lastCommitAt 毫秒;缺失/无效 → 空串由调用方降级) */
30
+ function rp2Ago(ms) {
31
+ const v = Number(ms);
32
+ if (!isFinite(v) || v <= 0)
33
+ return '';
34
+ const d = Math.floor((Date.now() - v) / 86400000);
35
+ if (d <= 0)
36
+ return '今天更新';
37
+ if (d === 1)
38
+ return '昨天更新';
39
+ if (d < 30)
40
+ return d + ' 天前更新';
41
+ if (d < 365)
42
+ return Math.floor(d / 30) + ' 个月前更新';
43
+ return Math.floor(d / 365) + ' 年前更新';
44
+ }
45
+ /** 字节数人读化(磁盘可用空间;null 降级) */
46
+ function rp2Size(mb) {
47
+ const v = Number(mb);
48
+ if (!isFinite(v) || v < 0)
49
+ return '';
50
+ return v >= 1024 ? (v / 1024).toFixed(1) + ' GB' : Math.round(v) + ' MB';
51
+ }
21
52
  /** 状态徽章(present/isGit/job 三源合成) */
22
53
  function rpBadge(r) {
23
54
  if (r.job && r.job.state === 'running')
@@ -68,8 +99,11 @@ export function NativeReposView({ api }) {
68
99
  const [busyKey, setBusyKey] = React.useState('');
69
100
  const [browse, setBrowse] = React.useState(null); // { key, sub, items, total, truncated, error? }
70
101
  const [cfgDraft, setCfgDraft] = React.useState({ root: '', mirror: '' });
102
+ const [batch, setBatch] = React.useState(null); // cycle-20 G2:一键批量安装进度 { id,state,items,done,total }
103
+ const [jobsOpen, setJobsOpen] = React.useState(false); // cycle-20 G3:最近作业折叠开关
71
104
  const aliveRef = React.useRef(true);
72
105
  const pollRef = React.useRef(null);
106
+ const batchRef = React.useRef(null);
73
107
  const load = React.useCallback(async () => {
74
108
  try {
75
109
  const d = await api('/repos');
@@ -93,9 +127,23 @@ export function NativeReposView({ api }) {
93
127
  }
94
128
  catch { } };
95
129
  }, [load]);
96
- // 轮询:存在 running 作业 → 2s 刷新一次;全部结束自动清表(省电)
130
+ /** cycle-20 G2:批次进度轮询(仅批次运行时;读到 done 即停) */
131
+ const pollBatch = React.useCallback(async (id) => {
132
+ try {
133
+ const d = await api('/repos/batch?id=' + encodeURIComponent(id));
134
+ if (!aliveRef.current || !d || !d.batch)
135
+ return;
136
+ setBatch(d.batch);
137
+ if (d.batch.state !== 'running') {
138
+ batchRef.current = null;
139
+ load();
140
+ }
141
+ }
142
+ catch { /* 批次查询失败不打断主面板 */ }
143
+ }, [api, load]);
144
+ // 轮询:存在 running 作业或未完成批次 → 2s 刷新一次;全部结束自动清表(省电)
97
145
  React.useEffect(() => {
98
- const running = data && data.summary && data.summary.running > 0;
146
+ const running = (data && data.summary && data.summary.running > 0) || (batch && batch.state === 'running');
99
147
  if (!running) {
100
148
  if (pollRef.current) {
101
149
  clearInterval(pollRef.current);
@@ -105,12 +153,13 @@ export function NativeReposView({ api }) {
105
153
  }
106
154
  if (pollRef.current)
107
155
  return;
108
- pollRef.current = setInterval(() => { load(); }, 2000);
156
+ pollRef.current = setInterval(() => { load(); if (batchRef.current)
157
+ pollBatch(batchRef.current); }, 2000);
109
158
  return () => { if (pollRef.current) {
110
159
  clearInterval(pollRef.current);
111
160
  pollRef.current = null;
112
161
  } };
113
- }, [data, load]);
162
+ }, [data, batch, load]);
114
163
  const post = React.useCallback(async (path, body) => {
115
164
  setBusyKey('');
116
165
  try {
@@ -126,7 +175,28 @@ export function NativeReposView({ api }) {
126
175
  }
127
176
  }, [api, load]);
128
177
  const doInstall = (key) => { setBusyKey(key); post('/repos/install', { key }); };
178
+ /** cycle-20 G2:一键批量安装必选——单次请求交给服务端队列,UI 只跟踪 batchId 进度 */
179
+ const doInstallBatch = async () => {
180
+ setErr('');
181
+ try {
182
+ const r = await api('/repos/install-batch', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({}) });
183
+ if (r && r.error) {
184
+ setErr(r.error);
185
+ return;
186
+ }
187
+ if (r && r.batch) {
188
+ setBatch(r.batch);
189
+ batchRef.current = r.batchId;
190
+ }
191
+ await load();
192
+ }
193
+ catch (e) {
194
+ setErr(String((e && e.message) || e));
195
+ }
196
+ };
129
197
  const doCancel = (key) => post('/repos/cancel', { key });
198
+ /** cycle-20 G4:一键切回旧数据根(消解「换根后数据消失」恐慌) */
199
+ const doSwitchBack = (root) => post('/repos/config', { root });
130
200
  const doRemove = (key) => {
131
201
  if (!window.confirm('确定删除本地目录 ' + key + '?(仅删除已下载数据,不影响学习进度)'))
132
202
  return;
@@ -159,32 +229,50 @@ export function NativeReposView({ api }) {
159
229
  return h('div', {}, err ? h('div', { style: { fontSize: 11.5, color: '#b45309', marginBottom: 8 } }, '⚠ ' + err) : null,
160
230
  /* ⓪ 关于本项目(GitHub/Release/Issue/npm 跳转 + 版本徽章) */
161
231
  h(RpAboutProject, { self: data.self }),
162
- /* ① 总览 */
163
- h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit,minmax(130px,1fr))', gap: 10, marginBottom: 14 } }, h(Stat, { v: (sum.present || 0) + '/' + (sum.total || 0), l: '仓库就绪', color: requiredReady ? '#10b981' : '#ef4444' }), h(Stat, { v: sum.requiredMissing && sum.requiredMissing.length ? sum.requiredMissing.length : 0, l: '必选缺失', color: sum.requiredMissing && sum.requiredMissing.length ? '#ef4444' : '#10b981' }), h(Stat, { v: sum.running || 0, l: '进行中作业', color: (sum.running || 0) ? '#6366f1' : undefined }), data.git === false ? h(Stat, { v: '✗', l: 'git 不可用', color: '#ef4444' }) : h(Stat, { v: '✓', l: 'git 可用', color: '#10b981' })),
232
+ /* ① 总览(cycle-20:健康汇总 + 可用空间如实呈现,null 即降级不臆造) */
233
+ h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit,minmax(130px,1fr))', gap: 10, marginBottom: 14 } }, h(Stat, { v: (sum.present || 0) + '/' + (sum.total || 0), l: '仓库就绪', color: requiredReady ? '#10b981' : '#ef4444' }), h(Stat, { v: sum.requiredMissing && sum.requiredMissing.length ? sum.requiredMissing.length : 0, l: '必选缺失', color: sum.requiredMissing && sum.requiredMissing.length ? '#ef4444' : '#10b981' }), h(Stat, { v: sum.running || 0, l: '进行中作业', color: (sum.running || 0) ? '#6366f1' : undefined }), sum.health ? h(Stat, { v: (sum.health.ok || 0) + '/' + (sum.present || 0), l: '健康仓库', color: (sum.health['no-git'] || sum.health['half-clone'] || sum.health.empty) ? '#f59e0b' : '#10b981' }) : null, data.diskFreeMB != null ? h(Stat, { v: rp2Size(data.diskFreeMB), l: '可用空间', color: data.diskFreeMB < 1024 ? '#f59e0b' : undefined }) : null, data.git === false ? h(Stat, { v: '✗', l: 'git 不可用', color: '#ef4444' }) : h(Stat, { v: '✓', l: 'git 可用', color: '#10b981' })),
234
+ /* ①b cycle-20 G4:旧根提示——换根后旧数据仍在原处,一键切回 */
235
+ data.previousRoot && data.previousRootRepos > 0
236
+ ? h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', marginBottom: 12, padding: '8px 12px', borderRadius: 10, background: 'rgba(245,158,11,.08)', border: '1px solid rgba(245,158,11,.25)' } }, h('span', { style: { fontSize: 11.5, color: '#92400e' } }, 'ℹ 上一个数据根 ' + String(data.previousRoot) + ' 仍有 ' + data.previousRootRepos + ' 个仓库(数据未删除,只是当前根不指向它)'), btn('↩ 切回旧根', false, () => doSwitchBack(String(data.previousRoot))))
237
+ : null,
164
238
  /* ② 数据根与镜像配置 */
165
239
  h(Card, { title: '🗂 数据根与镜像代理' }, h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', alignItems: 'center', marginBottom: 8 } }, h('span', { style: KV_TAG }, '生效根: ' + String(data.root || '—')), data.rootSource ? h('span', { style: KV_TAG }, '来源: ' + data.rootSource) : null), h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap', marginBottom: 6 } }, h('input', { value: cfgDraft.root, placeholder: '自定义数据根目录(绝对路径,留空=自动)', onChange: (e) => setCfgDraft((c) => Object.assign({}, c, { root: e.target.value })), style: { flex: '1 1 240px', padding: '6px 10px', borderRadius: 8, border: '1.5px solid rgba(148,163,184,.35)', fontSize: 12, fontFamily: 'inherit', background: 'var(--surface-card,#fff)', color: 'var(--text-primary,#0f172a)' } }), btn('保存根目录', false, () => post('/repos/config', { root: cfgDraft.root }))), h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap' } }, h('input', { value: cfgDraft.mirror, placeholder: '镜像前缀(如 https://gh-proxy.com/),留空=直连', onChange: (e) => setCfgDraft((c) => Object.assign({}, c, { mirror: e.target.value })), style: { flex: '1 1 240px', padding: '6px 10px', borderRadius: 8, border: '1.5px solid rgba(148,163,184,.35)', fontSize: 12, fontFamily: 'inherit', background: 'var(--surface-card,#fff)', color: 'var(--text-primary,#0f172a)' } }), btn('保存镜像', false, () => post('/repos/config', { mirror: cfgDraft.mirror }))), h('div', { style: { fontSize: 10.5, color: '#94a3b8', marginTop: 6 } }, '镜像前缀对 clone/pull 同时生效;国内网络建议 https://gh-proxy.com/')),
166
- /* ③ 一键必选 */
240
+ /* ③ 一键必选(cycle-20 G2:真·一键——单次请求交给服务端队列,UI 显示批次进度) */
167
241
  !requiredReady
168
242
  ? h(Card, { title: '🚀 一键安装必选包' }, h('div', { style: { fontSize: 12, color: '#64748b', marginBottom: 8 } }, '缺失必选:' + (sum.requiredMissing || []).join('、') + ' —— 装完即可用刷题 / 方法论 / 图推三大核心视图'),
169
243
  // cycle-18:不再写死「合计约 363MB」——必选集随版本会变(本轮新增 huasheng13,
170
244
  // 且 kaogong-skill 已降为推荐),硬编码体积必然漂移成谎报(R22 陈旧文案教训)。
171
245
  // 各仓库体积已在下方分级卡片逐条显示,总览这里只给可执行指引。
172
- h('div', { style: { fontSize: 10.5, color: '#94a3b8', marginBottom: 8 } }, '国内网络建议先在上方「镜像代理」填 https://gh-proxy.com/ 再安装;各仓库体积见下方分级列表。'), h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap' } }, (sum.requiredMissing || []).map((k) => btn('⬇ ' + k, false, () => doInstall(k), { background: 'linear-gradient(135deg,#6366f1,#8b5cf6)', color: '#fff', border: 0, padding: '7px 16px' }))))
246
+ h('div', { style: { fontSize: 10.5, color: '#94a3b8', marginBottom: 8 } }, '国内网络建议先在上方「镜像代理」填 https://gh-proxy.com/ 再安装;各仓库体积见下方分级列表。'), h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap', alignItems: 'center' } }, btn('🚀 一键安装全部必选', false, doInstallBatch, { background: 'linear-gradient(135deg,#6366f1,#8b5cf6)', color: '#fff', border: 0, padding: '7px 16px', fontWeight: 700 }), h('span', { style: { fontSize: 10.5, color: '#94a3b8' } }, '服务端队列化(并发 2),无需逐个点击')),
247
+ // 批次进度条(仅批次存在时显示;字段缺失即降级)
248
+ batch ? h('div', { style: { marginTop: 10, padding: '8px 10px', borderRadius: 9, background: 'rgba(99,102,241,.06)', border: '1px solid rgba(99,102,241,.18)' } }, h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', fontSize: 11.5, fontWeight: 700, color: '#4338ca', marginBottom: 6 } }, '📦 批次 ' + String(batch.id || '').slice(0, 12) + ' · ' + (batch.state === 'running' ? '进行中' : '已结束') + ' · ' + (batch.done || 0) + '/' + (batch.total || 0)), h('div', { style: { height: 6, borderRadius: 3, background: 'rgba(148,163,184,.25)', overflow: 'hidden' } }, h('i', { style: { display: 'block', height: '100%', width: (batch.total ? Math.round((batch.done || 0) / batch.total * 100) : 0) + '%', background: 'linear-gradient(90deg,#6366f1,#8b5cf6)', borderRadius: 3 } })), h('div', { style: { display: 'flex', gap: 5, flexWrap: 'wrap', marginTop: 6 } }, (batch.items || []).map((it) => h('span', { key: it.key, style: { ...KV_TAG, fontSize: 9.5, background: it.state === 'done' ? 'rgba(16,185,129,.12)' : it.state === 'failed' || it.state === 'skipped' ? 'rgba(239,68,68,.12)' : 'rgba(148,163,184,.14)', color: it.state === 'done' ? '#059669' : it.state === 'failed' || it.state === 'skipped' ? '#dc2626' : '#475569' }, title: it.error || '' }, it.key + ' ' + it.state))))
249
+ : null)
250
+ : null,
251
+ /* ③b cycle-20 G3:最近作业归档(失败原因/耗时可追溯,折叠省空间) */
252
+ Array.isArray(data.recentJobs) && data.recentJobs.length
253
+ ? h(Card, { title: '🕘 最近作业 · ' + data.recentJobs.length + ' 条' }, h('button', { style: KV_BTN, onClick: () => setJobsOpen(v => !v) }, jobsOpen ? '▾ 收起' : '▸ 展开历史'), jobsOpen ? h('div', { style: { marginTop: 6 } }, data.recentJobs.map((j, i) => h('div', { key: 'rj' + i, style: { display: 'flex', gap: 8, flexWrap: 'wrap', padding: '4px 0', borderBottom: '1px dashed rgba(148,163,184,.15)', fontSize: 10.5, color: '#64748b' } }, h('span', { style: { fontFamily: 'monospace', minWidth: 130 } }, String(j.key || '?')), h('span', { style: { color: j.state === 'done' ? '#059669' : j.state === 'failed' ? '#dc2626' : '#475569', fontWeight: 700 } }, j.state + ' · ' + String(j.action || '')), h('span', null, (j.elapsedSec || 0) + 's'), j.error ? h('span', { style: { color: '#b45309' }, title: j.error }, '⚠ ' + String(j.error).slice(0, 60)) : null))) : null)
173
254
  : null,
174
255
  /* ④ 分级仓库卡片 */
175
256
  RP_TIER_ORDER.map(tier => h(Card, { key: 'tier-' + tier, title: (RP_TIERS[tier].label) + ' · ' + grouped[tier].length + ' 个(' + tier + ')' }, h('div', { style: { fontSize: 10.5, color: '#94a3b8', marginBottom: 8 } }, RP_TIERS[tier].tip), grouped[tier].map((r) => {
176
257
  const b = rpBadge(r);
177
258
  const running = r.job && r.job.state === 'running';
178
- return h('div', { key: r.key, style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', padding: '7px 0', borderBottom: '1px dashed rgba(148,163,184,.18)' } }, h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: RP_TIERS[tier].color, flexShrink: 0 } }), h('span', { title: r.desc, style: { fontWeight: 700, fontSize: 12, minWidth: 150 } }, r.key), h('span', { style: { ...KV_TAG, background: b.bg, color: b.fg } }, b.text), r.size ? h('span', { style: { fontSize: 10.5, color: '#94a3b8' } }, r.size) : null, r.present ? h('span', { style: { fontSize: 10.5, color: '#94a3b8' } }, r.files + ' 项') : null, h('span', { style: { marginLeft: 'auto', display: 'flex', gap: 5, flexWrap: 'wrap' } }, running ? btn('⏹ 取消', false, () => doCancel(r.key)) : null, !running ? btn(busyKey === r.key ? '…' : (r.present && r.isGit ? '🔄 更新' : '⬇ 安装'), false, () => doInstall(r.key), r.present && r.isGit ? {} : { background: 'rgba(99,102,241,.1)', color: '#4f46e5', borderColor: 'rgba(99,102,241,.4)', fontWeight: 700 }) : null, r.present ? btn('👁 浏览', false, () => doBrowse(r.key, '')) : null, r.present ? btn('🗑 删除', false, () => doRemove(r.key)) : null, r.upstream ? h('a', { href: r.upstream, target: '_blank', rel: 'noreferrer', title: '上游仓库(致敬原作者)', style: { fontSize: 11, color: '#6366f1', textDecoration: 'none', alignSelf: 'center' } }, '↗') : null), h(RpJobLog, { job: r.job }));
259
+ return h('div', { key: r.key, style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', padding: '7px 0', borderBottom: '1px dashed rgba(148,163,184,.18)' } }, h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: RP_TIERS[tier].color, flexShrink: 0 } }), h('span', { title: r.desc, style: { fontWeight: 700, fontSize: 12, minWidth: 150 } }, r.key), h('span', { style: { ...KV_TAG, background: b.bg, color: b.fg } }, b.text), r.size ? h('span', { style: { fontSize: 10.5, color: '#94a3b8' } }, r.size) : null, r.present ? h('span', { style: { fontSize: 10.5, color: '#94a3b8' } }, r.files + ' 项') : null,
260
+ // cycle-20 G6:健康徽章(非 ok 态才显示,避免视觉噪音)+ 最近更新时间
261
+ r.health && r.health !== 'ok' && r.present
262
+ ? h('span', { style: { ...KV_TAG, fontSize: 9.5, background: (RP2_HEALTH[r.health] || RP2_HEALTH.absent).bg, color: (RP2_HEALTH[r.health] || RP2_HEALTH.absent).color } }, (RP2_HEALTH[r.health] || RP2_HEALTH.absent).text)
263
+ : null, rp2Ago(r.lastCommitAt) ? h('span', { style: { fontSize: 9.5, color: '#94a3b8' } }, rp2Ago(r.lastCommitAt)) : null, h('span', { style: { marginLeft: 'auto', display: 'flex', gap: 5, flexWrap: 'wrap' } }, running ? btn('⏹ 取消', false, () => doCancel(r.key)) : null, !running ? btn(busyKey === r.key ? '…' : (r.present && r.isGit ? '🔄 更新' : '⬇ 安装'), false, () => doInstall(r.key), r.present && r.isGit ? {} : { background: 'rgba(99,102,241,.1)', color: '#4f46e5', borderColor: 'rgba(99,102,241,.4)', fontWeight: 700 }) : null, r.present ? btn('👁 浏览', false, () => doBrowse(r.key, '')) : null, r.present ? btn('🗑 删除', false, () => doRemove(r.key)) : null, r.upstream ? h('a', { href: r.upstream, target: '_blank', rel: 'noreferrer', title: '上游仓库(致敬原作者)', style: { fontSize: 11, color: '#6366f1', textDecoration: 'none', alignSelf: 'center' } }, '↗') : null), h(RpJobLog, { job: r.job }));
179
264
  }))),
180
265
  /* ⑤ 浏览抽屉 */
181
266
  browse
182
- ? h(Card, { title: '👁 浏览 · ' + browse.key + (browse.sub ? ' / ' + browse.sub : '') }, browse.error ? h('div', { style: { fontSize: 12, color: '#b45309' } }, browse.error) : null, browse.sub ? h('div', { style: { marginBottom: 6 } }, btn('← 上级', false, () => doBrowse(browse.key, browse.sub.split('/').slice(0, -1).join('/')))) : null, (browse.items || []).slice(0, 120).map((it) => h('div', {
267
+ ? h(Card, { title: '👁 浏览 · ' + browse.key + (browse.sub ? ' / ' + browse.sub : '') }, browse.error ? h('div', { style: { fontSize: 12, color: '#b45309' } }, browse.error) : null, browse.sub ? h('div', { style: { marginBottom: 6 } }, btn('← 上级', false, () => doBrowse(browse.key, browse.sub.split('/').slice(0, -1).join('/')))) : null,
268
+ // cycle-20 G7:渲染服务端返回的 items 全量(limit 由服务端控制),
269
+ // 文案由 truncated + 真实 total/items.length 派生——杜绝「前 120 项(共 X)」口径矛盾。
270
+ (browse.items || []).map((it) => h('div', {
183
271
  key: it.name,
184
272
  style: { display: 'flex', gap: 8, alignItems: 'center', padding: '3px 2px', borderBottom: '1px solid rgba(148,163,184,.1)', fontSize: 11.5, cursor: it.dir ? 'pointer' : 'default' },
185
273
  onClick: it.dir ? () => doBrowse(browse.key, (browse.sub ? browse.sub + '/' : '') + it.name) : undefined,
186
- }, h('span', { style: { width: 18, textAlign: 'center' } }, it.dir ? '📁' : '·'), h('span', { style: { flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, it.name), !it.dir && it.size != null ? h('span', { style: { color: '#94a3b8', fontSize: 10 } }, it.size > 1048576 ? (it.size / 1048576).toFixed(1) + 'MB' : it.size > 1024 ? (it.size / 1024).toFixed(1) + 'KB' : it.size + 'B') : null)), browse.truncated ? h('div', { style: { fontSize: 10.5, color: '#94a3b8', marginTop: 4 } }, '仅显示前 120 项(共 ' + browse.total + ')') : null, h('div', { style: { marginTop: 6 } }, btn('✕ 关闭', false, () => setBrowse(null))))
274
+ }, h('span', { style: { width: 18, textAlign: 'center' } }, it.dir ? '📁' : '·'), h('span', { style: { flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, it.name), !it.dir && it.size != null ? h('span', { style: { color: '#94a3b8', fontSize: 10 } }, it.size > 1048576 ? (it.size / 1048576).toFixed(1) + 'MB' : it.size > 1024 ? (it.size / 1024).toFixed(1) + 'KB' : it.size + 'B') : null)), browse.truncated ? h('div', { style: { fontSize: 10.5, color: '#94a3b8', marginTop: 4 } }, '仅显示 ' + (browse.items || []).length + ' / ' + (browse.total || 0) + ' 项(服务端上限 ' + (browse.limit || (browse.items || []).length) + ')') : null, h('div', { style: { marginTop: 6 } }, btn('✕ 关闭', false, () => setBrowse(null))))
187
275
  : null,
188
276
  /* ⑥ 口径说明 */
189
- h('div', { style: { fontSize: 10.5, color: '#94a3b8', lineHeight: 1.8 } }, '口径:安装=git clone --depth 1(浅克隆省流量)· 已装仓库再点=git pull --ff-only 更新 · 删除仅清本地数据目录(学习进度在 data/progress 不受影响)· ', '非 git 目录受保护拒绝覆盖 · 并发上限 2 · 全部数据归上游仓库作者所有(点 ↗ 致敬原作者)。'));
277
+ h('div', { style: { fontSize: 10.5, color: '#94a3b8', lineHeight: 1.8 } }, '口径:安装=git clone --depth 1(浅克隆省流量)· 已装仓库再点=git pull --ff-only 更新 · 一键必选走服务端队列(并发 2)· ', '删除仅清本地数据目录(学习进度在 data/progress 不受影响)· clone 失败的半成品自动清理可重装 · ', '健康巡检:空仓库/缺 .git/半成品显式标记 · 非 git 的用户数据目录受保护拒绝覆盖 · ', '全部数据归上游仓库作者所有(点 ↗ 致敬原作者)。'));
190
278
  }