@suifei/dsh-ai-team 0.4.130 → 0.4.131

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.131 - 2026-11-18
4
+
5
+ **在线人才库走 npmmirror 整包;内容型弹窗放大到 90%,补单色图标**
6
+
7
+ - 实机发现:npmmirror 的按文件接口只对白名单包开放(`cnpm/unpkg-white-list`),`@suifei/dsh-ai-team-catalog` 的 `/files/index.json` 返回 403,
8
+ 0.4.130 的「同步在线库」实际每次都退到 jsDelivr(本机 `current.json` 记的是 `mirror: jsdelivr`,单次约 20 秒)。
9
+ - **registry 型镜像改为下整包**:npmmirror、npmjs 与私有源(`DSH_AI_TEAM_CATALOG_MIRROR`)按 `<源>/<包>/<版本>` 取 `dist.tarball` 与 `dist.integrity`,
10
+ 下载 tgz 后先核对 sha512 integrity,再在内存里解 tar(ustar + pax 长路径),之后照旧逐文件核对 `index.json` 的大小与 sha256。不需要白名单。
11
+ jsDelivr 仍按文件取,作为第二个镜像;npmjs 官方源作为第三个。镜像顺序:npmmirror → jsDelivr → npmjs。
12
+ 真实镜像实测(`r51`):npmmirror 0.6 秒、jsDelivr 21 秒、npmjs 1.7 秒,均同步 91 个文件。
13
+ - **弹窗**:添加成员 / 人才市场、成员资料、新建项目、组队四个内容型弹窗改为插件页面的 90% 宽高(底部按钮贴底);确认框、工作区路径、快捷键等小弹窗保持紧凑。
14
+ - **图标**:沿用插件现有的单色线性图标(随文字颜色),补同步、退回、复制、招聘、在线、已改、自建、进化、人才市场、组队、新建项目等图标,用在弹窗标题、页签、按钮与标签上。
15
+ - 测试:`test/catalog-sync.test.js` 的假镜像改为 registry(latest / manifest / tgz)+ CDN 两种形态;新增整包 integrity 不符换 CDN、pax 长路径解包。
16
+
3
17
  ## 0.4.130 - 2026-11-18
4
18
 
5
19
  **人才市场(第 3 步):官方在线人才库同步**
package/README.md CHANGED
@@ -35,7 +35,7 @@
35
35
  - **存为人才**:成员资料「存为人才」把项目里这位成员此刻的岗位、职责、性格、模型与技能存成可复用的人才(技能按成员实际读取的路径拷进人才文件夹,找不到正文的会提示),换个项目照样招。新建与存为都不会静默覆盖已有人才,撞名自动加序号。
36
36
  - **组队、建项目选团队**:「新建项目」里选团队(内置或自建),按它种成员、负责人当主理人;「组一个新团队」从人才里挑人(同一人才可招多位)、指定负责人即可保存。插件设置 `teamPreset` 只是不选时的默认值。
37
37
  - **改内置人才、进化技能**:内置人才点「复制为可编辑」得到同 id 的副本(随时「恢复内置」);成员资料里技能旁的「进化」会让该成员用 SkillOpt 优化那份技能——内置的先自动复制,插件里的原文件不动。
38
- - **在线人才库同步**:人才市场顶部「同步在线库」从官方在线人才库 [`@suifei/dsh-ai-team-catalog`](https://www.npmjs.com/package/@suifei/dsh-ai-team-catalog)(npmmirror → jsDelivr)取最新的人才与团队,按 `index.json` 逐文件核对 sha256 后整体替换,落到 `~/.dsh/ai-team/catalog/official/<版本>/`;失败不动现有的。优先级:自建 > 在线 > 内置(插件升级后内置版本更高的人才用内置)。「退回内置」删掉本机在线库。内网可设环境变量 `DSH_AI_TEAM_CATALOG_MIRROR` 指向 npmmirror 同形的私有源。在线人才同样只读,可「复制为可编辑」。
38
+ - **在线人才库同步**:人才市场顶部「同步在线库」从官方在线人才库 [`@suifei/dsh-ai-team-catalog`](https://www.npmjs.com/package/@suifei/dsh-ai-team-catalog)(npmmirror → jsDelivr → npmjs;registry 下整包核对 integrity)取最新的人才与团队,按 `index.json` 逐文件核对 sha256 后整体替换,落到 `~/.dsh/ai-team/catalog/official/<版本>/`;失败不动现有的。优先级:自建 > 在线 > 内置(插件升级后内置版本更高的人才用内置)。「退回内置」删掉本机在线库。内网可设环境变量 `DSH_AI_TEAM_CATALOG_MIRROR` 指向 npmmirror 同形的私有源。在线人才同样只读,可「复制为可编辑」。
39
39
  - 成员在账本里记下来源人才与版本、职责;人才文件之后再改,不会悄悄改动已招成员的性格与职责。已有项目不受新团队影响。文件写坏时跳过它并在诊断日志记 `catalog.load.fail` / `catalog.team.fail`。
40
40
 
41
41
  ---
package/client.js CHANGED
@@ -1268,7 +1268,7 @@ window.__ModuleLoader__.load({
1268
1268
  .at-msgimg { display: block; line-height: 0; }
1269
1269
  .at-msgimg img { max-width: min(320px, 100%); max-height: 240px; width: auto; height: auto; border: 1px solid var(--dsw-alias-border-l2); border-radius: var(--dsw-radius-sm); object-fit: contain; background: var(--dsw-alias-bg-base); }
1270
1270
  .at-mode { display: inline-flex; overflow: hidden; border: 1px solid var(--dsw-alias-border-l2); border-radius: var(--dsw-radius-sm); }
1271
- .at-mode button { min-height: 24px; padding: 0 8px; border: 0; background: transparent; color: var(--dsw-alias-label-tertiary); font: inherit; font-size: 11px; line-height: 16px; cursor: pointer; }
1271
+ .at-mode button { display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 0 8px; border: 0; background: transparent; color: var(--dsw-alias-label-tertiary); font: inherit; font-size: 11px; line-height: 16px; cursor: pointer; }
1272
1272
  .at-mode button[aria-pressed="true"] { background: var(--dsw-alias-button-ghost-active-fill); color: var(--dsw-alias-label-primary); }
1273
1273
  .at-hint { min-width: 0; color: var(--dsw-alias-label-caption); font-size: 10px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1274
1274
  .at-send { margin-left: auto; min-height: 28px; padding: 0 12px; border: 1px solid transparent; border-radius: var(--dsw-radius-sm); background: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-inverted); font: inherit; font-size: 12px; line-height: 18px; cursor: pointer; white-space: nowrap; }
@@ -1324,7 +1324,7 @@ window.__ModuleLoader__.load({
1324
1324
  .at-emptybody { max-width: 46ch; color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 18px; }
1325
1325
  .at-empty .at-btn { align-self: center; margin-top: 8px; }
1326
1326
  .at-empty-compact .at-btn { align-self: flex-start; }
1327
- .at-btn { min-height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; border: 1px solid var(--dsw-alias-border-l2); border-radius: var(--dsw-radius-sm); background: var(--dsw-alias-button-elevated-fill); color: var(--dsw-alias-label-primary); font: inherit; font-size: 12px; line-height: 18px; cursor: pointer; white-space: nowrap; }
1327
+ .at-btn { min-height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 0 14px; border: 1px solid var(--dsw-alias-border-l2); border-radius: var(--dsw-radius-sm); background: var(--dsw-alias-button-elevated-fill); color: var(--dsw-alias-label-primary); font: inherit; font-size: 12px; line-height: 18px; cursor: pointer; white-space: nowrap; }
1328
1328
  .at-btn:hover { background: var(--dsw-alias-interactive-bg-hover); }
1329
1329
  .at-btn-primary { border-color: transparent; background: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-inverted); }
1330
1330
  .at-btn-primary:hover { background: var(--dsw-alias-button-primary-hover); }
@@ -1393,8 +1393,12 @@ window.__ModuleLoader__.load({
1393
1393
  .at-fieldrow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
1394
1394
  .at-modalback { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 20px; background: color-mix(in srgb, var(--dsw-alias-bg-base) 72%, transparent); }
1395
1395
  .at-modal { width: min(420px, 100%); max-height: 86vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--dsw-alias-border-l1); border-radius: 12px; background: var(--dsw-alias-bg-layer-2); }
1396
- .at-modaltitle { margin: 0 0 2px; font-size: 15px; font-weight: 600; color: var(--dsw-alias-label-primary); }
1397
- .at-modal.at-modal-wide { width: min(640px, 100%); }
1396
+ .at-modaltitle { display: flex; align-items: center; gap: 6px; margin: 0 0 2px; font-size: 15px; font-weight: 600; color: var(--dsw-alias-label-primary); }
1397
+ .at-modaltitle svg, .at-btn svg, .at-talentduty svg, .at-mode button svg, .at-catalogstate svg { flex: none; }
1398
+ /* 内容型弹窗(添加成员 / 人才市场、成员资料、新建项目、组队):插件页面的 90% 宽高;确认框等小弹窗保持紧凑。 */
1399
+ .at-modalback:has(> .at-modal-wide) { padding: 0; }
1400
+ .at-modal.at-modal-wide { width: 90%; height: 90%; max-height: 90%; }
1401
+ .at-modal-wide > .at-modalactions:last-child { margin-top: auto; }
1398
1402
  .at-addtabs { align-self: flex-start; }
1399
1403
  .at-tcskills { display: flex; flex-wrap: wrap; gap: 6px; }
1400
1404
  .at-tcskill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: rgba(127,127,127,0.15); font-size: 12px; }
@@ -1408,6 +1412,7 @@ window.__ModuleLoader__.load({
1408
1412
  .at-teampickrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
1409
1413
  .at-teampickrow > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1410
1414
  .at-market { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
1415
+ .at-catalogstate { display: inline-flex; align-items: center; gap: 5px; }
1411
1416
  .at-catalogbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
1412
1417
  .at-marketsearch { width: 100%; padding: 6px 8px; border: 1px solid var(--dsw-alias-border-l2); border-radius: var(--dsw-radius-sm); background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font: inherit; font-size: 12px; }
1413
1418
  .at-marketcats { display: flex; flex-wrap: wrap; gap: 4px; }
@@ -1418,7 +1423,7 @@ window.__ModuleLoader__.load({
1418
1423
  .at-talenthead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
1419
1424
  .at-talentname { color: var(--dsw-alias-label-primary); font-size: 13px; font-weight: 600; }
1420
1425
  .at-talentrole { color: var(--dsw-alias-label-secondary); font-size: 12px; }
1421
- .at-talentduty { padding: 0 6px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 999px; color: var(--dsw-alias-label-tertiary); font-size: 10.5px; line-height: 16px; }
1426
+ .at-talentduty { display: inline-flex; align-items: center; gap: 3px; padding: 0 6px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 999px; color: var(--dsw-alias-label-tertiary); font-size: 10.5px; line-height: 16px; }
1422
1427
  .at-talentdesc { color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 18px; }
1423
1428
  .at-talentfoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
1424
1429
  .at-modalmeta { color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 16px; }
@@ -1548,10 +1553,26 @@ window.__ModuleLoader__.load({
1548
1553
  if (name === 'layers') return h('svg', common, h('path', { d: 'M8 2.5 14 6 8 9.5 2 6Z' }), h('path', { d: 'M2 9.5 8 13l6-3.5' }));
1549
1554
  if (name === 'chevron') return h('svg', common, h('path', { d: 'M6 3.5 10.5 8 6 12.5' }));
1550
1555
  if (name === 'down') return h('svg', common, h('path', { d: 'M8 3v10M3.5 8.5 8 13l4.5-4.5' }));
1556
+ if (name === 'sync') return h('svg', common, h('path', { d: 'M13 6.5A5 5 0 0 0 3.6 5' }), h('path', { d: 'M3.5 2.5V5H6' }), h('path', { d: 'M3 9.5A5 5 0 0 0 12.4 11' }), h('path', { d: 'M12.5 13.5V11H10' }));
1557
+ if (name === 'undo') return h('svg', common, h('path', { d: 'M5.5 3.5 2.5 6.5l3 3' }), h('path', { d: 'M2.5 6.5H10a3.5 3.5 0 0 1 0 7H7' }));
1558
+ if (name === 'copy') return h('svg', common, h('rect', { x: 5.5, y: 5.5, width: 8, height: 8, rx: 1.5 }), h('path', { d: 'M10.5 5.5V3.5a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2' }));
1559
+ if (name === 'user') return h('svg', common, h('circle', { cx: 8, cy: 5.5, r: 2.8 }), h('path', { d: 'M2.5 13.5a5.5 5.5 0 0 1 11 0' }));
1560
+ if (name === 'userPlus') return h('svg', common, h('circle', { cx: 6.5, cy: 5.5, r: 2.6 }), h('path', { d: 'M1.5 13.5a5 5 0 0 1 10 0' }), h('path', { d: 'M12.5 4v4M10.5 6h4' }));
1561
+ if (name === 'users') return h('svg', common, h('circle', { cx: 6, cy: 5.5, r: 2.4 }), h('path', { d: 'M1.5 13.5a4.5 4.5 0 0 1 9 0' }), h('path', { d: 'M10 3.3a2.4 2.4 0 0 1 0 4.4M12 9.5a4.5 4.5 0 0 1 2.5 4' }));
1562
+ if (name === 'cloud') return h('svg', common, h('path', { d: 'M4.5 12.5h7a3 3 0 0 0 .4-6 4 4 0 0 0-7.7.9 2.6 2.6 0 0 0 .3 5.1Z' }));
1563
+ if (name === 'pen') return h('svg', common, h('path', { d: 'M10.5 3 13 5.5 6 12.5H3.5V10Z' }), h('path', { d: 'M9 4.5 11.5 7' }));
1564
+ if (name === 'spark') return h('svg', common, h('path', { d: 'M8 2v3M8 11v3M2 8h3M11 8h3' }), h('path', { d: 'M8 5.5 9 7l1.5 1L9 9l-1 1.5L7 9 5.5 8 7 7Z' }));
1565
+ if (name === 'store') return h('svg', common, h('path', { d: 'M2.5 6 3.5 3h9l1 3' }), h('path', { d: 'M2.5 6a1.8 1.8 0 0 0 3.7 0 1.8 1.8 0 0 0 3.6 0 1.8 1.8 0 0 0 3.7 0' }), h('path', { d: 'M3.5 8v5.5h9V8' }));
1566
+ if (name === 'folderPlus') return h('svg', common, h('path', { d: 'M2.5 4.5a1 1 0 0 1 1-1h3l1.5 1.5h4.5a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1Z' }), h('path', { d: 'M8 7.5v3M6.5 9h3' }));
1551
1567
  if (name === 'loop') return h('svg', { width: 18, height: 18, viewBox: '0 0 32 32', fill: 'none', 'aria-hidden': 'true', focusable: 'false' }, h('rect', { x: 2.5, y: 5.5, width: 21, height: 21, rx: 6.5, stroke: 'currentColor', strokeWidth: 2.6 }), h('circle', { cx: 23.5, cy: 16, r: 4.8, fill: 'var(--dsw-alias-state-business-primary)' }));
1552
1568
  return null;
1553
1569
  }
1554
1570
 
1571
+ /** 图标 + 文字(按钮、标题、标签共用;图标单色随文字色)。 */
1572
+ function withIco(name, label, size = 13) {
1573
+ return [h(Ico, { key: 'i', name, size }), h('span', { key: 't' }, label)];
1574
+ }
1575
+
1555
1576
  function StatusGlyph({ status }) {
1556
1577
  const common = { width: 12, height: 12, viewBox: '0 0 12 12', fill: 'none', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': 'true', focusable: 'false' };
1557
1578
  if (status === 'done') return h('svg', common, h('path', { d: 'M2.5 6.2l2.3 2.3 4.7-4.7' }));
@@ -2728,10 +2749,10 @@ window.__ModuleLoader__.load({
2728
2749
  return h('div', { className: 'at-market' },
2729
2750
  h('div', { className: 'at-modalmeta' }, t('talentHint')),
2730
2751
  onSync ? h('div', { className: 'at-catalogbar' },
2731
- h('span', { className: 'at-modalmeta' }, catalog ? tf(t, 'catalogAt', { version: catalog.version, time: catalog.syncedAt ? new Date(catalog.syncedAt).toLocaleString() : '' }) : t('catalogNone')),
2752
+ h('span', { className: 'at-modalmeta at-catalogstate' }, h(Ico, { name: 'cloud', size: 13 }), catalog ? tf(t, 'catalogAt', { version: catalog.version, time: catalog.syncedAt ? new Date(catalog.syncedAt).toLocaleString() : '' }) : t('catalogNone')),
2732
2753
  h('span', { className: 'at-tcpick' },
2733
- catalog && onClear ? h('button', { type: 'button', className: 'at-btn at-btn-small', disabled: catalogBusy, onClick: onClear }, t('catalogClear')) : null,
2734
- h('button', { type: 'button', className: 'at-btn at-btn-small', title: t('catalogSyncHint'), disabled: catalogBusy, onClick: onSync }, catalogBusy ? t('catalogSyncing') : t('catalogSync')))) : null,
2754
+ catalog && onClear ? h('button', { type: 'button', className: 'at-btn at-btn-small', disabled: catalogBusy, onClick: onClear }, withIco('undo', t('catalogClear'))) : null,
2755
+ h('button', { type: 'button', className: 'at-btn at-btn-small', title: t('catalogSyncHint'), disabled: catalogBusy, onClick: onSync }, withIco('sync', catalogBusy ? t('catalogSyncing') : t('catalogSync'))))) : null,
2735
2756
  catalogNote ? h('div', { className: 'at-modalmeta', role: 'status' }, catalogNote) : null,
2736
2757
  h('input', { className: 'at-marketsearch', type: 'search', value: query, placeholder: t('talentSearch'), 'aria-label': t('talentSearch'), onChange: (event) => onQuery(event.target.value), autoFocus: true }),
2737
2758
  categories.length > 1 ? h('div', { className: 'at-marketcats', role: 'group', 'aria-label': t('talentMarket') },
@@ -2750,15 +2771,15 @@ window.__ModuleLoader__.load({
2750
2771
  h('span', { className: 'at-talentname' }, talent.name),
2751
2772
  h('span', { className: 'at-talentrole' }, talent.role),
2752
2773
  talent.duty ? h('span', { className: 'at-talentduty' }, t(DUTY_LABEL[talent.duty])) : null,
2753
- talent.forked ? h('span', { className: 'at-talentduty' }, t('talentForked')) : talent.source === 'user' ? h('span', { className: 'at-talentduty' }, t('talentUser')) : talent.source === 'official' ? h('span', { className: 'at-talentduty' }, t('talentOfficial')) : null),
2774
+ talent.forked ? h('span', { className: 'at-talentduty' }, withIco('pen', t('talentForked'), 10)) : talent.source === 'user' ? h('span', { className: 'at-talentduty' }, withIco('user', t('talentUser'), 10)) : talent.source === 'official' ? h('span', { className: 'at-talentduty' }, withIco('cloud', t('talentOfficial'), 10)) : null),
2754
2775
  talent.description ? h('div', { className: 'at-talentdesc' }, talent.description) : null,
2755
2776
  talent.skills?.length ? h('div', { className: 'at-modalmeta' }, tf(t, 'talentSkills', { skills: talent.skills.join('、') })) : null,
2756
2777
  h('div', { className: 'at-talentfoot' },
2757
2778
  h('span', { className: 'at-modalmeta' }, [talent.category, ...(talent.tags ?? [])].filter(Boolean).join(' · ')),
2758
2779
  h('span', { className: 'at-tcpick' },
2759
- talent.source !== 'user' && onFork ? h('button', { type: 'button', className: 'at-btn at-btn-small', title: t('talentForkHint'), onClick: () => onFork(talent) }, t('talentFork')) : null,
2760
- talent.forked && onRestore ? h('button', { type: 'button', className: 'at-btn at-btn-small', onClick: () => onRestore(talent) }, t('talentRestore')) : null,
2761
- h('button', { type: 'button', className: 'at-btn at-btn-primary', onClick: () => onHire(talent) }, t('talentHire'))))))),
2780
+ talent.source !== 'user' && onFork ? h('button', { type: 'button', className: 'at-btn at-btn-small', title: t('talentForkHint'), onClick: () => onFork(talent) }, withIco('copy', t('talentFork'))) : null,
2781
+ talent.forked && onRestore ? h('button', { type: 'button', className: 'at-btn at-btn-small', onClick: () => onRestore(talent) }, withIco('undo', t('talentRestore'))) : null,
2782
+ h('button', { type: 'button', className: 'at-btn at-btn-primary', onClick: () => onHire(talent) }, withIco('userPlus', t('talentHire')))))))),
2762
2783
  h('div', { className: 'at-modalactions' },
2763
2784
  h('button', { className: 'at-btn', type: 'button', onClick: onCancel }, t('cancel'))));
2764
2785
  }
@@ -5288,17 +5309,17 @@ window.__ModuleLoader__.load({
5288
5309
  }) : null,
5289
5310
  addOpen ? h(ModalBack, { onClose: () => setAddOpen(false) },
5290
5311
  h('form', {
5291
- className: mTab === 'market' && !(mCopy && !mCopy.talent) ? 'at-modal at-modal-wide' : 'at-modal',
5312
+ className: 'at-modal at-modal-wide',
5292
5313
  role: 'dialog',
5293
5314
  'aria-modal': 'true',
5294
5315
  'aria-label': t('addAgentTitle'),
5295
5316
  onSubmit: (event) => { event.preventDefault(); createAgent(); },
5296
5317
  },
5297
- h('h2', { className: 'at-modaltitle' }, mCopy && !mCopy.talent ? t('memberCopy') : t('addAgentTitle')),
5318
+ h('h2', { className: 'at-modaltitle' }, withIco(mCopy && !mCopy.talent ? 'copy' : 'userPlus', mCopy && !mCopy.talent ? t('memberCopy') : t('addAgentTitle'), 16)),
5298
5319
  mCopy && !mCopy.talent ? null : h('div', { className: 'at-mode at-addtabs', role: 'group', 'aria-label': t('addAgentTitle') },
5299
- h('button', { type: 'button', 'aria-pressed': mTab === 'market' ? 'true' : 'false', onClick: () => setMTab('market') }, t('talentMarket')),
5300
- h('button', { type: 'button', 'aria-pressed': mTab === 'custom' ? 'true' : 'false', onClick: () => setMTab('custom') }, t('talentCustom')),
5301
- h('button', { type: 'button', 'aria-pressed': mTab === 'create' ? 'true' : 'false', onClick: () => setMTab('create') }, t('talentCreate'))),
5320
+ h('button', { type: 'button', 'aria-pressed': mTab === 'market' ? 'true' : 'false', onClick: () => setMTab('market') }, withIco('store', t('talentMarket'), 12)),
5321
+ h('button', { type: 'button', 'aria-pressed': mTab === 'custom' ? 'true' : 'false', onClick: () => setMTab('custom') }, withIco('pen', t('talentCustom'), 12)),
5322
+ h('button', { type: 'button', 'aria-pressed': mTab === 'create' ? 'true' : 'false', onClick: () => setMTab('create') }, withIco('plus', t('talentCreate'), 12))),
5302
5323
  mTab === 'market' && !(mCopy && !mCopy.talent) ? h(TalentMarket, {
5303
5324
  t,
5304
5325
  talents,
@@ -5351,13 +5372,13 @@ window.__ModuleLoader__.load({
5351
5372
  h('button', { className: 'at-btn at-btn-primary', type: 'submit', disabled: mBusy || !mName.trim() }, mBusy ? t('memberAdding') : t('memberCreate')))])) : null,
5352
5373
  profileAgent ? h(ModalBack, { onClose: () => setProfileAgent(null) },
5353
5374
  h('form', {
5354
- className: 'at-modal',
5375
+ className: 'at-modal at-modal-wide',
5355
5376
  role: 'dialog',
5356
5377
  'aria-modal': 'true',
5357
5378
  'aria-label': t('memberProfileTitle'),
5358
5379
  onSubmit: (event) => { event.preventDefault(); saveProfile(); },
5359
5380
  },
5360
- h('h2', { className: 'at-modaltitle' }, tf(t, 'memberProfileTitleName', { name: profileAgent.name })),
5381
+ h('h2', { className: 'at-modaltitle' }, withIco('user', tf(t, 'memberProfileTitleName', { name: profileAgent.name }), 16)),
5361
5382
  h('div', { className: 'at-modalmeta' },
5362
5383
  tf(t, 'memberProfileMeta', {
5363
5384
  status: t(AGENT_STATUS[profileAgent.status] ?? 'agentIdle'),
@@ -5372,7 +5393,7 @@ window.__ModuleLoader__.load({
5372
5393
  ? h('div', { className: 'at-tcskills', 'aria-label': t('memberSkills') },
5373
5394
  h('span', { className: 'at-modalmeta' }, t('memberSkills') + ':'),
5374
5395
  profileAgent.skills.map((name) => h('span', { key: name, className: 'at-tcskill' }, name,
5375
- h('button', { type: 'button', className: 'at-btn at-btn-small', title: t('skillEvolveHint'), onClick: () => void evolveSkill(profileAgent, name) }, t('skillEvolve')))))
5396
+ h('button', { type: 'button', className: 'at-btn at-btn-small', title: t('skillEvolveHint'), onClick: () => void evolveSkill(profileAgent, name) }, withIco('spark', t('skillEvolve'), 12)))))
5376
5397
  : null,
5377
5398
  pEvolve ? h('div', { className: 'at-modalmeta', role: 'status' }, pEvolve) : null,
5378
5399
  profileAgent.notes?.length ? h('div', { className: 'at-modalmeta' }, t('memberNotes') + ':' + profileAgent.notes.slice(-3).join(';')) : null,
@@ -5458,13 +5479,13 @@ window.__ModuleLoader__.load({
5458
5479
  h('button', { className: 'at-btn at-btn-primary', type: 'submit', disabled: workspaceBusy || !workspaceDraft.trim() }, workspaceBusy ? t('saving') : t('workspaceSave'))))) : null,
5459
5480
  newOpen ? h(ModalBack, { onClose: () => setNewOpen(false) },
5460
5481
  h('form', {
5461
- className: 'at-modal',
5482
+ className: 'at-modal at-modal-wide',
5462
5483
  role: 'dialog',
5463
5484
  'aria-modal': 'true',
5464
5485
  'aria-label': t('newProjectTitle'),
5465
5486
  onSubmit: (event) => { event.preventDefault(); createProject(); },
5466
5487
  },
5467
- h('h2', { className: 'at-modaltitle' }, t('newProjectTitle')),
5488
+ h('h2', { className: 'at-modaltitle' }, withIco('folderPlus', t('newProjectTitle'), 16)),
5468
5489
  h('label', { className: 'at-field' }, h('span', null, t('projectName')),
5469
5490
  h('input', { value: nName, onChange: (event) => setNName(event.target.value), autoFocus: true })),
5470
5491
  h('label', { className: 'at-field' }, h('span', null, t('projectGoal')),
@@ -5487,7 +5508,7 @@ window.__ModuleLoader__.load({
5487
5508
  h('button', { className: 'at-btn at-btn-primary', type: 'submit', disabled: nBusy || !nName.trim() || !nWorkspace.trim() }, nBusy ? t('saving') : t('projectCreate'))))) : null,
5488
5509
  teamComposeOpen ? h(ModalBack, { onClose: () => setTeamComposeOpen(false) },
5489
5510
  h('div', { className: 'at-modal at-modal-wide', role: 'dialog', 'aria-modal': 'true', 'aria-label': t('teamComposeTitle') },
5490
- h('h2', { className: 'at-modaltitle' }, t('teamComposeTitle')),
5511
+ h('h2', { className: 'at-modaltitle' }, withIco('users', t('teamComposeTitle'), 16)),
5491
5512
  h(TeamComposer, { t, talents, onSaved: (team) => { setTeamComposeOpen(false); void loadTeams(team && team.id); }, onCancel: () => setTeamComposeOpen(false) }))) : null,
5492
5513
  dialog ? h(WorkbenchDialog, { key: dialogSeqRef.current, t, dialog, onDismiss: () => setDialog(null) }) : null,
5493
5514
  shortcutsOpen ? h(ModalBack, { onClose: () => setShortcutsOpen(false) },
@@ -3,9 +3,12 @@
3
3
  *
4
4
  * 在线库是独立 npm 包 `@suifei/dsh-ai-team-catalog`,内容与插件内置同格式(talents/ + teams/),
5
5
  * 包根多一份 `index.json`:列出每个文件的相对路径、字节数与 sha256。同步时:
6
- * 1. 按镜像顺序(npmmirror → jsDelivr)问最新版本号;与本地 `current.json` 相同就不动;
7
- * 2. 取 index.json,校验格式号、版本、插件最低版本、路径白名单与大小上限;
8
- * 3. 逐个文件下载并核对 sha256,全部落进临时目录后整体改名为 `official/<版本>/`,再写 `current.json`;
6
+ * 1. 按镜像顺序(npmmirror → jsDelivr → npmjs)问最新版本号;与本地 `current.json` 相同就不动;
7
+ * 2. 取包内容:registry 型镜像下整个 tgz(核对 registry 给的 dist.integrity,再在内存里解 tar),
8
+ * CDN 型(jsDelivr)按文件取。npmmirror 的按文件接口只对白名单包开放(cnpm/unpkg-white-list,实测 403),
9
+ * 所以 registry 一律走 tgz;
10
+ * 3. 校验 index.json(格式号、版本、插件最低版本、路径白名单与大小上限),每个文件核对字节数与 sha256,
11
+ * 全部落进临时目录后整体改名为 `official/<版本>/`,再写 `current.json`;
9
12
  * 中途任何一步失败都丢掉临时目录,旧版本原样保留。
10
13
  * 读取时 `officialRoot()` 给出当前版本目录,插在用户自建与插件内置之间(lib/domain/catalog.js)。
11
14
  *
@@ -15,6 +18,7 @@
15
18
  import { createHash, randomBytes } from 'node:crypto';
16
19
  import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
17
20
  import { dirname, join, relative, sep } from 'node:path';
21
+ import { gunzipSync } from 'node:zlib';
18
22
 
19
23
  export const CATALOG_PACKAGE = '@suifei/dsh-ai-team-catalog';
20
24
  /** index.json 的格式号;格式变了才升。 */
@@ -24,6 +28,8 @@ export const CATALOG_MIN_PLUGIN = '0.4.130';
24
28
  export const MAX_FILE_BYTES = 256 * 1024;
25
29
  export const MAX_TOTAL_BYTES = 8 * 1024 * 1024;
26
30
  export const MAX_FILES = 2000;
31
+ /** 整包 tgz 的上限(压缩前后)。 */
32
+ export const MAX_TARBALL_BYTES = 16 * 1024 * 1024;
27
33
 
28
34
  const SEMVER = /^(\d+)\.(\d+)\.(\d+)$/;
29
35
  const SLUG = '[a-z0-9][a-z0-9-]{0,63}';
@@ -31,18 +37,22 @@ const SKILL = '[A-Za-z0-9][A-Za-z0-9._-]{0,63}';
31
37
  const CATALOG_PATH = new RegExp(`^(?:talents/${SLUG}/talent\\.yml|teams/${SLUG}/team\\.yml|(?:talents|teams)/${SLUG}/skills/(?:${SKILL}/SKILL|${SKILL})\\.md)$`);
32
38
  const HEX64 = /^[0-9a-f]{64}$/;
33
39
 
34
- /** 镜像:先国内(npmmirror),再 jsDelivr。每个镜像自带「问最新版本」与「按文件取」两个地址。 */
40
+ /** registry 型镜像:`<base>/<pkg>/latest` 给版本,`<base>/<pkg>/<版本>` 给 dist(tarball + integrity),按整包取。 */
41
+ export function registryMirror(name, base) {
42
+ const root = String(base).replace(/\/+$/, '');
43
+ return Object.freeze({ name, kind: 'registry', latest: (pkg) => `${root}/${pkg}/latest`, manifest: (pkg, version) => `${root}/${pkg}/${version}` });
44
+ }
45
+
46
+ /** 镜像:先国内(npmmirror),再 jsDelivr(按文件取),最后 npmjs 官方源。 */
35
47
  export const MIRRORS = Object.freeze([
36
- Object.freeze({
37
- name: 'npmmirror',
38
- latest: (pkg) => `https://registry.npmmirror.com/${pkg}/latest`,
39
- file: (pkg, version, path) => `https://registry.npmmirror.com/${pkg}/${version}/files/${path}`,
40
- }),
48
+ registryMirror('npmmirror', 'https://registry.npmmirror.com'),
41
49
  Object.freeze({
42
50
  name: 'jsdelivr',
51
+ kind: 'cdn',
43
52
  latest: (pkg) => `https://data.jsdelivr.com/v1/packages/npm/${pkg}/resolved?specifier=latest`,
44
53
  file: (pkg, version, path) => `https://cdn.jsdelivr.net/npm/${pkg}@${version}/${path}`,
45
54
  }),
55
+ registryMirror('npmjs', 'https://registry.npmjs.org'),
46
56
  ]);
47
57
 
48
58
  /**
@@ -52,7 +62,7 @@ export const MIRRORS = Object.freeze([
52
62
  export function catalogMirrors(env = process.env) {
53
63
  const base = typeof env?.DSH_AI_TEAM_CATALOG_MIRROR === 'string' ? env.DSH_AI_TEAM_CATALOG_MIRROR.trim().replace(/\/+$/, '') : '';
54
64
  if (!/^https?:\/\//.test(base)) return MIRRORS;
55
- return [{ name: 'custom', latest: (pkg) => `${base}/${pkg}/latest`, file: (pkg, version, path) => `${base}/${pkg}/${version}/files/${path}` }];
65
+ return [registryMirror('custom', base)];
56
66
  }
57
67
 
58
68
  /** 在线库里允许出现的文件:人才 talent.yml、团队 team.yml、两者 skills/ 下的技能 Markdown。不允许 `..`、绝对路径、脚本。 */
@@ -179,11 +189,72 @@ export async function latestVersion({ fetchImpl = globalThis.fetch, mirrors = ca
179
189
  throw new Error(`取不到在线人才库版本(${errors.join(';')})`);
180
190
  }
181
191
 
192
+ function tarString(block, start, length) {
193
+ const end = block.indexOf(0, start);
194
+ return block.toString('utf8', start, end === -1 || end > start + length ? start + length : end);
195
+ }
196
+
197
+ /**
198
+ * 解 npm 包的 tar(ustar,含 pax 扩展头里的 path):返回 `package/` 下普通文件的 Map(相对路径 → 内容)。
199
+ * 只在内存里读,不写盘;目录、链接等其它类型忽略。
200
+ */
201
+ export function untar(buffer) {
202
+ const files = new Map();
203
+ let offset = 0;
204
+ let paxPath = null;
205
+ while (offset + 512 <= buffer.length) {
206
+ const block = buffer.subarray(offset, offset + 512);
207
+ if (block.every((byte) => byte === 0)) break;
208
+ const size = Number.parseInt(tarString(block, 124, 12).trim() || '0', 8);
209
+ if (!Number.isFinite(size) || size < 0) throw new Error('tar 头损坏');
210
+ const type = String.fromCharCode(block[156] || 48);
211
+ const prefix = tarString(block, 257, 6) === 'ustar' ? tarString(block, 345, 155) : '';
212
+ const name = paxPath ?? (prefix ? `${prefix}/${tarString(block, 0, 100)}` : tarString(block, 0, 100));
213
+ const body = buffer.subarray(offset + 512, offset + 512 + size);
214
+ if (body.length !== size) throw new Error('tar 被截断');
215
+ offset += 512 + Math.ceil(size / 512) * 512;
216
+ if (type === 'x') {
217
+ const match = /(?:^|\n)\d+ path=([^\n]*)\n/.exec(body.toString('utf8'));
218
+ paxPath = match ? match[1] : null;
219
+ continue;
220
+ }
221
+ paxPath = null;
222
+ if ((type !== '0' && type !== '7') || !name.startsWith('package/')) continue;
223
+ files.set(name.slice('package/'.length), Buffer.from(body));
224
+ }
225
+ return files;
226
+ }
227
+
228
+ /** 用 registry 给的 integrity(`sha512-<base64>`)核对整包。 */
229
+ function checkIntegrity(buffer, integrity) {
230
+ const entry = String(integrity ?? '').split(/\s+/).find((x) => x.startsWith('sha512-'));
231
+ if (entry === undefined) throw new Error('registry 没给 sha512 integrity');
232
+ if (createHash('sha512').update(buffer).digest('base64') !== entry.slice('sha512-'.length)) throw new Error('整包 integrity 校验不符');
233
+ }
234
+
235
+ /** 取包里文件的方法:registry 型一次下整包、核对 integrity 后从内存取;CDN 型按文件下。 */
236
+ async function packageReader(mirror, { fetchImpl, pkg, version, timeoutMs }) {
237
+ if (mirror.kind !== 'registry') {
238
+ return async (path) => Buffer.from(await (await fetchOk(fetchImpl, mirror.file(pkg, version, path), timeoutMs)).arrayBuffer());
239
+ }
240
+ const manifest = await (await fetchOk(fetchImpl, mirror.manifest(pkg, version), timeoutMs)).json();
241
+ if (manifest?.version !== version || typeof manifest?.dist?.tarball !== 'string') throw new Error('registry 没给出这个版本的 tarball');
242
+ const tgz = Buffer.from(await (await fetchOk(fetchImpl, manifest.dist.tarball, timeoutMs)).arrayBuffer());
243
+ if (tgz.length > MAX_TARBALL_BYTES) throw new Error('整包超限');
244
+ checkIntegrity(tgz, manifest.dist.integrity);
245
+ const files = untar(gunzipSync(tgz, { maxOutputLength: MAX_TARBALL_BYTES * 2 }));
246
+ return async (path) => {
247
+ const buffer = files.get(path);
248
+ if (buffer === undefined) throw new Error(`包里缺文件:${path}`);
249
+ return buffer;
250
+ };
251
+ }
252
+
182
253
  async function downloadFrom(mirror, { fetchImpl, pkg, version, pluginVersion, timeoutMs, staging }) {
183
- const indexRes = await fetchOk(fetchImpl, mirror.file(pkg, version, 'index.json'), timeoutMs);
184
- const files = validateIndex(JSON.parse(Buffer.from(await indexRes.arrayBuffer()).toString('utf8')), { version, pluginVersion });
254
+ const read = await packageReader(mirror, { fetchImpl, pkg, version, timeoutMs });
255
+ const files = validateIndex(JSON.parse((await read('index.json')).toString('utf8')), { version, pluginVersion });
185
256
  for (const file of files) {
186
- const buffer = Buffer.from(await (await fetchOk(fetchImpl, mirror.file(pkg, version, file.path), timeoutMs)).arrayBuffer());
257
+ const buffer = await read(file.path);
187
258
  if (buffer.length !== file.size || sha256(buffer) !== file.sha256) throw new Error(`校验不符:${file.path}`);
188
259
  const target = join(staging, ...file.path.split('/'));
189
260
  mkdirSync(dirname(target), { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.130",
3
+ "version": "0.4.131",
4
4
  "type": "module",
5
5
  "description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
6
6
  "license": "MIT",