dsh-plugin-trim 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,7 @@ dsh plugin --profile web add dsh-plugin-trim
13
13
  从 GitHub Release 安装(备用,无需 npm):
14
14
 
15
15
  ```bash
16
- dsh plugin --profile web add "https://github.com/Starlit-Sky-code/dsh-experience-optimizer/releases/download/v0.3.6/dsh-plugin-trim-0.3.6.tgz"
16
+ dsh plugin --profile web add "https://github.com/Starlit-Sky-code/dsh-experience-optimizer/releases/download/v0.3.7/dsh-plugin-trim-0.3.7.tgz"
17
17
  ```
18
18
 
19
19
  本地开发:
package/client.js CHANGED
@@ -25,6 +25,7 @@ window.__ModuleLoader__.load({
25
25
 
26
26
  const LOCALE_KEY = 'dsh-experience-optimizer.locale'
27
27
  const ONBOARDING_KEY = 'dsh-experience-optimizer.onboarding.v1'
28
+ const MAIN_GUIDE_KEY = 'dsh-experience-optimizer.main-guide.v1'
28
29
  const ABOUT_LINKS = {
29
30
  repo: 'https://github.com/Starlit-Sky-code/dsh-experience-optimizer',
30
31
  npmTrim: 'https://www.npmjs.com/package/dsh-plugin-trim',
@@ -283,9 +284,32 @@ window.__ModuleLoader__.load({
283
284
  .eo-density-compact .eo-stack,.eo-stack.eo-density-compact{gap:8px}
284
285
  .eo-density-compact .eo-item{padding:7px 0}
285
286
  .eo-density-compact .eo-metric{padding:9px 11px}
286
- .eo-layout-two.eo-stack{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
287
- .eo-layout-two>.eo-viewbar,.eo-layout-two>.eo-metrics,.eo-layout-two>[data-section="draft"],.eo-layout-two>[data-section="inventory"],.eo-layout-two>[data-section="result"],.eo-layout-two>[data-section="dedupe"],.eo-layout-two>[data-section="diagnostics"]{grid-column:1/-1}
288
- .eo-layout-two>[data-section="compat"],.eo-layout-two>[data-section="context"]{grid-column:span 1}
287
+ .eo-layout-two .eo-findings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 18px}
288
+ .eo-layout-two .eo-finding{padding:8px 0}
289
+ .eo-layout-two .eo-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 18px}
290
+ .eo-layout-two .eo-item{padding:8px 0}
291
+ .eo-layout-two .eo-owner-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 18px}
292
+ .eo-inventory-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
293
+ .eo-inventory-card{border:.5px solid var(--eo-border);border-radius:8px;padding:9px 10px;min-width:0}
294
+ .eo-inventory-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}
295
+ .eo-inventory-card code{font:400 11px/16px var(--eo-code);word-break:break-all;color:var(--eo-secondary)}
296
+ .eo-inventory-card-meta{display:flex;gap:10px;flex-wrap:wrap;margin-top:6px;color:var(--eo-tertiary);font-size:11px}
297
+ .eo-main-guide{position:fixed;right:24px;left:auto;bottom:24px;z-index:30;width:min(340px,calc(100vw - 32px));padding:14px 16px;border:.5px solid var(--dsw-alias-border-l4,rgba(127,127,127,.25));border-radius:14px;background:var(--dsw-alias-bg-layer-1,#fff);box-shadow:0 14px 44px rgba(0,0,0,.2);color:var(--eo-primary);font-size:13px;line-height:20px}
298
+ .eo-guide-arrow{position:absolute;left:-16px;top:-20px;width:44px;height:44px;border-radius:50%;display:grid;place-items:center;background:var(--dsw-alias-button-primary-fill,var(--eo-primary));color:var(--dsw-alias-label-primary-inverted,#fff);transform:rotate(-12deg);box-shadow:0 8px 20px rgba(0,0,0,.18)}
299
+ .eo-guide-kicker{margin:0 0 3px;color:var(--eo-tertiary);font:500 10px/16px var(--eo-code);letter-spacing:.12em}
300
+ .eo-main-guide h3{margin:0 0 8px;font-size:16px;line-height:23px}
301
+ .eo-guide-path{display:flex;align-items:center;gap:5px;flex-wrap:wrap;margin:0 0 8px;font-size:12px;font-weight:500}
302
+ .eo-guide-path span{padding:2px 7px;border-radius:5px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.08))}
303
+ .eo-guide-path i{font-style:normal;color:var(--eo-tertiary)}
304
+ .eo-guide-note{margin:0;color:var(--eo-tertiary);font-size:11px;line-height:17px}
305
+ .eo-guide-steps{max-height:220px;overflow:auto;margin:10px 0 0;padding:0;list-style:none;border-top:.5px solid var(--eo-border)}
306
+ .eo-guide-steps li{display:flex;gap:7px;align-items:flex-start;padding:7px 0;border-bottom:.5px solid var(--eo-border)}
307
+ .eo-guide-steps b{font:500 10px/18px var(--eo-code);color:var(--eo-tertiary);flex:0 0 auto}
308
+ .eo-guide-steps span{flex:0 0 auto;font-weight:500;font-size:12px}
309
+ .eo-guide-steps small{color:var(--eo-tertiary);font-size:11px;line-height:17px}
310
+ .eo-guide-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:12px}
311
+ .eo-main-guide .eo-btn{height:28px;font-size:11px;padding:0 9px}
312
+ @media(max-width:600px){.eo-main-guide{left:12px;right:12px;bottom:12px;width:auto}.eo-guide-arrow{display:none}}
289
313
  .eo-about-hero{display:block;width:100%;height:auto;border-radius:12px;background:#0b1422;margin:0 0 10px}
290
314
  .eo-card-title{margin:0;font-size:14px;line-height:22px;font-weight:500;letter-spacing:0}
291
315
  .eo-card-sub{margin:2px 0 0;font-size:12px;line-height:18px;color:var(--eo-tertiary)}
@@ -377,6 +401,14 @@ window.__ModuleLoader__.load({
377
401
  .eo-note{padding:9px 12px;border:1px solid var(--dsw-alias-border-l3);border-radius:8px;background:var(--dsw-alias-bg-layer-3);color:var(--eo-secondary);font-size:12px;line-height:19px}
378
402
  .eo-code{font:400 11px/16px var(--eo-code);color:var(--eo-secondary);word-break:break-all}
379
403
  .eo-steps{margin:0;padding-left:20px;color:var(--eo-secondary);font-size:13px;line-height:22px}
404
+ .eo-tutorial-flow{position:relative;display:flex;flex-direction:column;gap:0}
405
+ .eo-tutorial-step{display:flex;gap:12px;position:relative;padding:0 0 14px}
406
+ .eo-tutorial-step:before{content:"";position:absolute;left:16px;top:34px;bottom:0;width:1px;background:var(--eo-border)}
407
+ .eo-tutorial-step:last-child:before{display:none}
408
+ .eo-tutorial-num{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;flex:0 0 auto;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.08));border:1px solid var(--eo-border);color:var(--eo-secondary);font:500 10px/1 var(--eo-code)}
409
+ .eo-tutorial-copy{min-width:0;padding-top:1px}
410
+ .eo-tutorial-copy strong{display:block;font-size:13px;line-height:21px;color:var(--eo-primary)}
411
+ .eo-tutorial-copy p{margin:1px 0 0;color:var(--eo-tertiary);font-size:12px;line-height:19px}
380
412
  .eo-steps li{margin:0 0 8px;padding-left:2px}
381
413
  .eo-steps strong{color:var(--eo-primary);font-weight:500}
382
414
  .eo-settings-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 18px}
@@ -394,14 +426,18 @@ window.__ModuleLoader__.load({
394
426
  .eo-spacer{height:0}
395
427
  @keyframes eo-spin{to{transform:rotate(360deg)}}
396
428
  @keyframes eo-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
397
- @media(max-width:820px){.eo-layout-two.eo-stack{grid-template-columns:1fr}.eo-layout-two>*{grid-column:1/-1!important}.eo-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.eo-metric:nth-child(2){border-right:0}.eo-metric:nth-child(-n+2){border-bottom:.5px solid var(--eo-border)}.eo-form-grid{grid-template-columns:1fr}.eo-hero{flex-wrap:wrap}.eo-hero-actions{margin-left:0}}
429
+ @media(max-width:820px){.eo-layout-two .eo-findings,.eo-layout-two .eo-list,.eo-layout-two .eo-owner-list,.eo-inventory-grid{grid-template-columns:1fr}.eo-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.eo-metric:nth-child(2){border-right:0}.eo-metric:nth-child(-n+2){border-bottom:.5px solid var(--eo-border)}.eo-form-grid{grid-template-columns:1fr}.eo-hero{flex-wrap:wrap}.eo-hero-actions{margin-left:0}}
398
430
  @media(max-width:520px){.eo-metrics{grid-template-columns:1fr}.eo-metric{border-right:0;border-bottom:.5px solid var(--eo-border)}.eo-metric:last-child{border-bottom:0}}
399
431
  `
400
432
 
401
433
 
402
434
  function injectCss() {
403
435
  if (typeof document === 'undefined') return
404
- if (document.querySelector('style[data-plugin-css="' + CSS_ID + '"]')) return
436
+ const existing = document.querySelector('style[data-plugin-css="' + CSS_ID + '"]')
437
+ if (existing !== null) {
438
+ existing.textContent = CSS
439
+ return
440
+ }
405
441
  const tag = document.createElement('style')
406
442
  tag.dataset.pluginCss = CSS_ID
407
443
  tag.textContent = CSS
@@ -665,6 +701,7 @@ window.__ModuleLoader__.load({
665
701
  ['rect', { x: '14', y: '14', width: '6', height: '6', rx: '1' }],
666
702
  ],
667
703
  chevron: [['path', { d: 'M6 9l6 6 6-6' }]],
704
+ arrow: [['path', { d: 'M19 5L5 19M5 9v10h10' }]],
668
705
  }
669
706
 
670
707
  function Icon({ name, size = 16 }) {
@@ -831,6 +868,55 @@ window.__ModuleLoader__.load({
831
868
  )
832
869
  }
833
870
 
871
+ function MainGuide() {
872
+ const [visible, setVisible] = useState(() => {
873
+ const storage = browserStorage()
874
+ try { return storage ? storage.getItem(MAIN_GUIDE_KEY) !== '1' : true } catch { return true }
875
+ })
876
+ const [stepsOpen, setStepsOpen] = useState(false)
877
+ const dismiss = () => {
878
+ const storage = browserStorage()
879
+ try { if (storage) storage.setItem(MAIN_GUIDE_KEY, '1') } catch { /* ignore */ }
880
+ setVisible(false)
881
+ }
882
+ if (!visible) return null
883
+ const steps = [
884
+ [tr('点击「更多」', 'Open “More”'), tr('在 DSH 主界面打开更多菜单。', 'Open the More menu on the DSH main screen.')],
885
+ [tr('点击「设置」', 'Open “Settings”'), tr('进入设置页。', 'Open Settings.')],
886
+ [tr('点击「体验优化」', 'Open “Experience Optimizer”'), tr('在 Agent 预设下方或插件页签里找到体验优化。', 'Find it below Agent presets or in the plugins tab.')],
887
+ [tr('生成减负方案', 'Build a slim plan'), tr('选任务或写目标,先看依据,再决定是否应用。', 'Pick a task or goal, read the evidence, then decide.')],
888
+ [tr('需要时看教程', 'Open the guide'), tr('教程、常见问题和关于都在同一页。', 'Guide, FAQ, and About live in the same panel.')],
889
+ ]
890
+ return h(
891
+ 'div',
892
+ { className: 'eo-main-guide', role: 'dialog', 'aria-label': tr('初次使用路径', 'First-run path') },
893
+ h('div', { className: 'eo-guide-arrow' }, h(Icon, { name: 'arrow', size: 22 })),
894
+ h('p', { className: 'eo-guide-kicker' }, tr('初次使用', 'FIRST RUN')),
895
+ h('h3', null, tr('从这里打开体验优化', 'Open Experience Optimizer here')),
896
+ h(
897
+ 'div',
898
+ { className: 'eo-guide-path' },
899
+ h('span', null, tr('更多', 'More')),
900
+ h('i', null, '→'),
901
+ h('span', null, tr('设置', 'Settings')),
902
+ h('i', null, '→'),
903
+ h('span', null, tr('体验优化', 'Experience Optimizer')),
904
+ ),
905
+ h('p', { className: 'eo-guide-note' }, tr('打开后会自动出现 5 步教程;也可以先看这里的路径。', 'A five-step guide opens there; you can follow this path first.')),
906
+ stepsOpen
907
+ ? h('ol', { className: 'eo-guide-steps' }, steps.map(([title, body], index) =>
908
+ h('li', { key: title }, h('b', null, String(index + 1).padStart(2, '0')), h('span', null, title), h('small', null, body)),
909
+ ))
910
+ : null,
911
+ h(
912
+ 'div',
913
+ { className: 'eo-guide-actions' },
914
+ h(Button, { variant: 'ghost', onClick: () => setStepsOpen((value) => !value) }, stepsOpen ? tr('收起步骤', 'Hide steps') : tr('查看 5 步教程', 'Show 5 steps')),
915
+ h(Button, { variant: 'accent', onClick: dismiss }, tr('知道了', 'Got it')),
916
+ ),
917
+ )
918
+ }
919
+
834
920
  function ExperiencePanel() {
835
921
 
836
922
  const [tab, setTab] = useState('trim')
@@ -876,6 +962,8 @@ window.__ModuleLoader__.load({
876
962
  const [settings, setSettings] = useState(null)
877
963
  const [settingsBusy, setSettingsBusy] = useState(false)
878
964
  const [settingsError, setSettingsError] = useState('')
965
+ const [updateInfo, setUpdateInfo] = useState(null)
966
+ const [updateBusy, setUpdateBusy] = useState(false)
879
967
  CURRENT_LOCALE = locale
880
968
 
881
969
  const notify = useCallback((message, kind) => {
@@ -960,6 +1048,22 @@ window.__ModuleLoader__.load({
960
1048
  }
961
1049
  }, [])
962
1050
 
1051
+ const checkUpdate = useCallback(async () => {
1052
+ setUpdateBusy(true)
1053
+ try {
1054
+ setUpdateInfo(await fetchJson(API + '/update'))
1055
+ } catch (err) {
1056
+ setUpdateInfo({
1057
+ current: '0.3.6',
1058
+ latest: null,
1059
+ updateAvailable: false,
1060
+ error: err instanceof Error ? err.message : String(err),
1061
+ })
1062
+ } finally {
1063
+ setUpdateBusy(false)
1064
+ }
1065
+ }, [])
1066
+
963
1067
  const findings = useMemo(() => {
964
1068
  if (!overview) return []
965
1069
  const query = findingQuery.trim().toLowerCase()
@@ -1342,12 +1446,26 @@ window.__ModuleLoader__.load({
1342
1446
  { className: 'eo-stack' },
1343
1447
  h(
1344
1448
  Card,
1345
- { title: tr('5 分钟上手', 'Five-minute guide'), subtitle: tr('从扫描到应用,每一步都可恢复', 'From scan to apply, every step is recoverable') },
1449
+ {
1450
+ title: tr('5 分钟上手', 'Five-minute guide'),
1451
+ subtitle: tr('从扫描到应用,每一步都可恢复', 'From scan to apply, every step is recoverable'),
1452
+ extra: h(Badge, { tone: 'info' }, tr('5 步', '5 steps')),
1453
+ },
1346
1454
  h(
1347
- 'ol',
1348
- { className: 'eo-steps' },
1455
+ 'div',
1456
+ { className: 'eo-tutorial-flow' },
1349
1457
  steps.map(([zhTitle, enTitle, zhBody, enBody], index) =>
1350
- h('li', { key: enTitle }, h('strong', null, tr(zhTitle, enTitle)), tr(zhBody, enBody)),
1458
+ h(
1459
+ 'div',
1460
+ { className: 'eo-tutorial-step', key: enTitle },
1461
+ h('div', { className: 'eo-tutorial-num' }, String(index + 1).padStart(2, '0')),
1462
+ h(
1463
+ 'div',
1464
+ { className: 'eo-tutorial-copy' },
1465
+ h('strong', null, tr(zhTitle, enTitle)),
1466
+ h('p', null, tr(zhBody, enBody)),
1467
+ ),
1468
+ ),
1351
1469
  ),
1352
1470
  ),
1353
1471
  ),
@@ -1426,6 +1544,79 @@ window.__ModuleLoader__.load({
1426
1544
  return h(
1427
1545
  'div',
1428
1546
  { className: 'eo-stack' },
1547
+ h(
1548
+ Card,
1549
+ {
1550
+ title: tr('界面偏好', 'Interface preferences'),
1551
+ subtitle: tr('只作用于插件减负页;偏好保存在本浏览器', 'Applies to the Plugin diet page; saved in this browser'),
1552
+ },
1553
+ h(
1554
+ 'div',
1555
+ { className: 'eo-settings-row' },
1556
+ h('span', null, tr('内容排列', 'Content layout')),
1557
+ h(
1558
+ 'div',
1559
+ { className: 'eo-inline' },
1560
+ h(Button, { variant: 'ghost', className: layout === 'standard' ? 'eo-btn-active' : '', onClick: () => changeLayout('standard') }, tr('标准', 'Standard')),
1561
+ h(Button, { variant: 'ghost', className: layout === 'two' ? 'eo-btn-active' : '', onClick: () => changeLayout('two') }, tr('双列', 'Two-column')),
1562
+ ),
1563
+ ),
1564
+ h(
1565
+ 'div',
1566
+ { className: 'eo-settings-row' },
1567
+ h('span', null, tr('密度', 'Density')),
1568
+ h(
1569
+ 'div',
1570
+ { className: 'eo-inline' },
1571
+ h(Button, { variant: 'ghost', className: density === 'comfortable' ? 'eo-btn-active' : '', onClick: () => changeDensity('comfortable') }, tr('舒适', 'Comfortable')),
1572
+ h(Button, { variant: 'ghost', className: density === 'compact' ? 'eo-btn-active' : '', onClick: () => changeDensity('compact') }, tr('紧凑', 'Compact')),
1573
+ ),
1574
+ ),
1575
+ h(
1576
+ 'div',
1577
+ { className: 'eo-settings-row' },
1578
+ h('span', null, tr('卡片', 'Cards')),
1579
+ h(
1580
+ 'div',
1581
+ { className: 'eo-inline' },
1582
+ h(Button, { variant: 'ghost', onClick: collapseAllCards }, tr('全部折叠', 'Collapse all')),
1583
+ h(Button, { variant: 'ghost', onClick: expandAllCards }, tr('全部展开', 'Expand all')),
1584
+ ),
1585
+ ),
1586
+ ),
1587
+ h(
1588
+ Card,
1589
+ {
1590
+ title: tr('更新与反馈', 'Updates & feedback'),
1591
+ subtitle: tr('检查 npm 最新版本;反馈请走 GitHub Issues', 'Check the latest npm version; feedback via GitHub Issues'),
1592
+ },
1593
+ h(
1594
+ 'div',
1595
+ { className: 'eo-settings-row' },
1596
+ h('span', null, tr('当前版本', 'Current version')),
1597
+ h('code', null, updateInfo?.current || '0.3.6'),
1598
+ ),
1599
+ h(
1600
+ 'div',
1601
+ { className: 'eo-settings-row' },
1602
+ h('span', null, tr('最新版本', 'Latest version')),
1603
+ h('code', null, updateInfo ? (updateInfo.latest || tr('检查失败', 'Check failed')) : tr('未检查', 'Not checked')),
1604
+ ),
1605
+ updateInfo && updateInfo.updateAvailable
1606
+ ? h('div', { className: 'eo-issue' }, h('span', null, tr('发现新版本:', 'New version available: ') + updateInfo.latest + ' · '), h('a', { href: updateInfo.url, target: '_blank', rel: 'noreferrer' }, tr('查看 npm', 'View npm')))
1607
+ : updateInfo && updateInfo.latest
1608
+ ? h('div', { className: 'eo-issue' }, h('span', null, tr('已是最新版本。', 'You are on the latest version.')))
1609
+ : updateInfo && updateInfo.error
1610
+ ? h('div', { className: 'eo-issue eo-issue-warn' }, h('span', null, tr('检查失败:', 'Check failed: ') + updateInfo.error))
1611
+ : null,
1612
+ h(
1613
+ 'div',
1614
+ { className: 'eo-inline', style: { marginTop: '10px' } },
1615
+ h(Button, { variant: 'accent', onClick: () => void checkUpdate(), disabled: updateBusy }, updateBusy ? tr('检查中…', 'Checking…') : tr('检查更新', 'Check for updates')),
1616
+ h('a', { className: 'eo-btn eo-btn-ghost', href: 'https://github.com/Starlit-Sky-code/dsh-experience-optimizer/issues/new/choose', target: '_blank', rel: 'noreferrer' }, tr('新建 Issue', 'New issue')),
1617
+ h('a', { className: 'eo-btn eo-btn-ghost', href: ABOUT_LINKS.issues, target: '_blank', rel: 'noreferrer' }, tr('问题列表', 'Issues')),
1618
+ ),
1619
+ ),
1429
1620
  h(
1430
1621
  Card,
1431
1622
  {
@@ -1512,7 +1703,7 @@ window.__ModuleLoader__.load({
1512
1703
  { className: 'eo-about-card' },
1513
1704
  h('div', { className: 'eo-inline', style: { marginBottom: '8px' } }, h(Icon, { name: 'shield', size: 24 }), h('strong', null, 'DSH Experience Optimizer')),
1514
1705
  h('p', null, tr('少一点插件负担,多一点兼容确定性。', 'Less plugin overhead, more compatibility certainty.')),
1515
- h('p', null, tr('版本:', 'Version: ') + '0.3.6 · AGPL-3.0-only'),
1706
+ h('p', null, tr('版本:', 'Version: ') + '0.3.7 · AGPL-3.0-only'),
1516
1707
  h('p', null, tr('作者:Starlit Sky', 'Author: Starlit Sky')),
1517
1708
  ),
1518
1709
  h(
@@ -1588,6 +1779,51 @@ window.__ModuleLoader__.load({
1588
1779
  }
1589
1780
 
1590
1781
  function renderTrim() {
1782
+ const renderInventoryCards = () =>
1783
+ h(
1784
+ 'div',
1785
+ { className: 'eo-inventory-grid' },
1786
+ filteredBundles.slice(0, showAllBundles ? 200 : 12).map((bundle) =>
1787
+ h(
1788
+ 'div',
1789
+ { className: 'eo-inventory-card', key: bundle.name },
1790
+ h(
1791
+ 'div',
1792
+ { className: 'eo-inventory-card-head' },
1793
+ h('code', null, bundle.name),
1794
+ h(
1795
+ Badge,
1796
+ { tone: bundle.enabled ? 'ok' : 'neutral' },
1797
+ bundle.enabled ? tr('已启用', 'Enabled') : tr('已禁用', 'Disabled'),
1798
+ ),
1799
+ ),
1800
+ bundle.description ? h('div', { className: 'eo-muted' }, bundle.description) : null,
1801
+ h(
1802
+ 'div',
1803
+ { className: 'eo-inventory-card-meta' },
1804
+ h('span', null, tr('上下文', 'Context') + ' ' + formatNumber(bundle.contextTokens)),
1805
+ h(
1806
+ 'span',
1807
+ null,
1808
+ tr('占比', 'Share') +
1809
+ ' ' +
1810
+ (totalContextTokens > 0
1811
+ ? Math.round((bundle.contextTokens / totalContextTokens) * 100) + '%'
1812
+ : '—'),
1813
+ ),
1814
+ h(
1815
+ 'span',
1816
+ null,
1817
+ tr('调用', 'Calls') +
1818
+ ' ' +
1819
+ formatNumber((bundle.usage?.calls ?? 0) + (bundle.usage?.sessionCalls ?? 0)),
1820
+ ),
1821
+ bundle.protected ? h('span', null, tr('受保护', 'Protected')) : null,
1822
+ h('span', null, bundle.guardStatus ? guardLabel(bundle.guardStatus) : '—'),
1823
+ ),
1824
+ ),
1825
+ ),
1826
+ )
1591
1827
  return h(
1592
1828
  'div',
1593
1829
  {
@@ -1596,63 +1832,6 @@ window.__ModuleLoader__.load({
1596
1832
  (layout === 'two' ? ' eo-layout-two' : '') +
1597
1833
  (density === 'compact' ? ' eo-density-compact' : ''),
1598
1834
  },
1599
- h(
1600
- 'div',
1601
- { className: 'eo-viewbar' },
1602
- h('span', { className: 'eo-viewbar-label' }, tr('视图', 'View')),
1603
- h(
1604
- 'div',
1605
- { className: 'eo-inline' },
1606
- h(
1607
- Button,
1608
- {
1609
- variant: 'ghost',
1610
- className: layout === 'standard' ? 'eo-btn-active' : '',
1611
- onClick: () => changeLayout('standard'),
1612
- },
1613
- tr('标准', 'Standard'),
1614
- ),
1615
- h(
1616
- Button,
1617
- {
1618
- variant: 'ghost',
1619
- className: layout === 'two' ? 'eo-btn-active' : '',
1620
- onClick: () => changeLayout('two'),
1621
- },
1622
- tr('双列', 'Two-column'),
1623
- ),
1624
- ),
1625
- h('span', { className: 'eo-viewbar-label' }, tr('密度', 'Density')),
1626
- h(
1627
- 'div',
1628
- { className: 'eo-inline' },
1629
- h(
1630
- Button,
1631
- {
1632
- variant: 'ghost',
1633
- className: density === 'comfortable' ? 'eo-btn-active' : '',
1634
- onClick: () => changeDensity('comfortable'),
1635
- },
1636
- tr('舒适', 'Comfortable'),
1637
- ),
1638
- h(
1639
- Button,
1640
- {
1641
- variant: 'ghost',
1642
- className: density === 'compact' ? 'eo-btn-active' : '',
1643
- onClick: () => changeDensity('compact'),
1644
- },
1645
- tr('紧凑', 'Compact'),
1646
- ),
1647
- ),
1648
- h('span', { className: 'eo-viewbar-label', style: { marginLeft: 'auto' } }, tr('折叠', 'Collapse')),
1649
- h(
1650
- 'div',
1651
- { className: 'eo-inline' },
1652
- h(Button, { variant: 'ghost', onClick: collapseAllCards }, tr('全部折叠', 'Collapse all')),
1653
- h(Button, { variant: 'ghost', onClick: expandAllCards }, tr('全部展开', 'Expand all')),
1654
- ),
1655
- ),
1656
1835
  h('div', { className: 'eo-grid eo-metrics' }, [
1657
1836
  h(Metric, {
1658
1837
  key: 'tokens',
@@ -1946,7 +2125,9 @@ window.__ModuleLoader__.load({
1946
2125
  ),
1947
2126
  filteredBundles.length === 0
1948
2127
  ? h('div', { className: 'eo-empty' }, tr('没有匹配的插件。', 'No matching plugins.'))
1949
- : h(
2128
+ : layout === 'two'
2129
+ ? renderInventoryCards()
2130
+ : h(
1950
2131
  'div',
1951
2132
  { className: 'eo-table-wrap' },
1952
2133
  h(
@@ -2720,6 +2901,16 @@ window.__ModuleLoader__.load({
2720
2901
 
2721
2902
  function apply(ctx) {
2722
2903
  injectCss()
2904
+ ctx.slots.inject('shell.overlay', () =>
2905
+ ctx.slots.register(
2906
+ {
2907
+ name: 'shell.overlay',
2908
+ id: 'experience-optimizer-guide',
2909
+ order: 10,
2910
+ },
2911
+ MainGuide,
2912
+ ),
2913
+ )
2723
2914
  ctx.slots.inject('settings.plugins.tab', () =>
2724
2915
  ctx.slots.register(
2725
2916
  {
package/dist/index.js CHANGED
@@ -4588,6 +4588,8 @@ function registerCompatTool(ctx, config) {
4588
4588
  }
4589
4589
  // src/api.ts
4590
4590
  const API_PREFIX = "/api/dsh-experience-optimizer";
4591
+ const CURRENT_VERSION = "0.3.7";
4592
+ let updateCache;
4591
4593
  const TASK_TAGS = [
4592
4594
  "bugfix",
4593
4595
  "feature",
@@ -4648,6 +4650,13 @@ async function handle(req, res, ctx, config, ledger) {
4648
4650
  });
4649
4651
  return;
4650
4652
  }
4653
+ if (req.method === "GET" && path === "/update") {
4654
+ sendJson(res, 200, {
4655
+ ok: true,
4656
+ data: await checkForUpdate()
4657
+ });
4658
+ return;
4659
+ }
4651
4660
  if (req.method === "POST" && path === "/suggest") {
4652
4661
  sendJson(res, 200, {
4653
4662
  ok: true,
@@ -4674,6 +4683,53 @@ async function handle(req, res, ctx, config, ledger) {
4674
4683
  sendError(res, 500, error instanceof Error ? error.message : String(error));
4675
4684
  }
4676
4685
  }
4686
+ function compareVersions(left, right) {
4687
+ const parse = (value) => value.replace(/^v/, "").split("-")[0].split(".").map((part) => Number.parseInt(part, 10) || 0);
4688
+ const a = parse(left);
4689
+ const b = parse(right);
4690
+ for (let index = 0; index < Math.max(a.length, b.length); index++) {
4691
+ const difference = (a[index] ?? 0) - (b[index] ?? 0);
4692
+ if (difference !== 0) return difference > 0 ? 1 : -1;
4693
+ }
4694
+ return 0;
4695
+ }
4696
+ async function checkForUpdate() {
4697
+ if (updateCache !== void 0 && Date.now() - updateCache.at < 6e4) return updateCache.value;
4698
+ const base = {
4699
+ current: CURRENT_VERSION,
4700
+ package: "dsh-plugin-trim",
4701
+ url: "https://www.npmjs.com/package/dsh-plugin-trim"
4702
+ };
4703
+ try {
4704
+ const response = await fetch("https://registry.npmjs.org/dsh-plugin-trim/latest", {
4705
+ headers: { accept: "application/json" },
4706
+ signal: AbortSignal.timeout(4e3)
4707
+ });
4708
+ if (!response.ok) throw new Error(`registry HTTP ${response.status}`);
4709
+ const metadata = await response.json();
4710
+ const latest = typeof metadata.version === "string" ? metadata.version : void 0;
4711
+ if (latest === void 0) throw new Error("registry response has no version");
4712
+ const value = {
4713
+ ...base,
4714
+ latest,
4715
+ updateAvailable: compareVersions(latest, CURRENT_VERSION) > 0,
4716
+ checkedAt: (/* @__PURE__ */ new Date()).toISOString()
4717
+ };
4718
+ updateCache = {
4719
+ at: Date.now(),
4720
+ value
4721
+ };
4722
+ return value;
4723
+ } catch (error) {
4724
+ return {
4725
+ ...base,
4726
+ latest: null,
4727
+ updateAvailable: false,
4728
+ error: error instanceof Error ? error.message : String(error),
4729
+ checkedAt: (/* @__PURE__ */ new Date()).toISOString()
4730
+ };
4731
+ }
4732
+ }
4677
4733
  function publicConfig(ctx, config) {
4678
4734
  const profile = resolveProfileFacts(ctx);
4679
4735
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-trim",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "DSH plugin ecosystem diet and compatibility analyzer",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",