dsh-ollama-usage 0.1.13 → 0.1.15

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.en.md CHANGED
@@ -114,7 +114,7 @@ Since DSH 0.2.1 the compatibility gate prefers `engines.dsh`. This plugin declar
114
114
 
115
115
  > Only versions that were **actually run** are listed; untested versions are omitted.
116
116
 
117
- v0.1.13 targets DSH **≥0.1.5-rc.1** (the `@deepseek-ai/dsh-*` peer was relaxed to `>=0.1.7-rc.1`), verified on **0.1.5-rc.1 / 0.1.5-rc.2 / 0.1.6-alpha.2 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1** (all RPC envelope probes pass; on 0.1.7-rc.2 the `/ollama-usage/snapshot` endpoint returns as measured; on 0.2.0-rc.1 it passes the new compatibility gate and loads normally; on 0.2.1-rc.1 the gate and RPC envelope probes pass, and 0.2.1-rc.2 passes the gate); for older DSH (0.1.0-rc.5 ~ rc.8) use the last compatible npm version, **0.1.5**.
117
+ v0.1.15 targets DSH **≥0.1.5-rc.1** (the `@deepseek-ai/dsh-*` peer was relaxed to `>=0.1.7-rc.1`), verified on **0.1.5-rc.1 / 0.1.5-rc.2 / 0.1.6-alpha.2 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1** (all RPC envelope probes pass; on 0.1.7-rc.2 the `/ollama-usage/snapshot` endpoint returns as measured; on 0.2.0-rc.1 it passes the new compatibility gate and loads normally; on 0.2.1-rc.1 the gate and RPC envelope probes pass, and 0.2.1-rc.2 passes the gate); for older DSH (0.1.0-rc.5 ~ rc.8) use the last compatible npm version, **0.1.5**.
118
118
 
119
119
  ## 🛠️ 开发 / Develop
120
120
 
package/README.md CHANGED
@@ -117,7 +117,7 @@ DSH 0.2.1 起兼容门禁优先读取 `engines.dsh`。本插件声明 **`engines
117
117
 
118
118
  > 只列出**实际跑过**的版本;未实测的不列。
119
119
 
120
- v0.1.13 支持 DSH **≥0.1.5-rc.1**(`@deepseek-ai/dsh-*` peer 放宽为 `>=0.1.7-rc.1`),已在 **0.1.5-rc.1 / 0.1.5-rc.2 / 0.1.6-alpha.2 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1** 实测(RPC envelope 探针全过;0.1.7-rc.2 上 `/ollama-usage/snapshot` 实测返回;0.2.0-rc.1 上通过新的兼容性门禁并正常加载;0.2.1-rc.1 上兼容门禁与 RPC envelope 探针通过,0.2.1-rc.2 门禁通过);旧版 DSH(0.1.0-rc.5 ~ rc.8)请使用最后兼容的 npm 版本 **0.1.5**。
120
+ v0.1.15 支持 DSH **≥0.1.5-rc.1**(`@deepseek-ai/dsh-*` peer 放宽为 `>=0.1.7-rc.1`),已在 **0.1.5-rc.1 / 0.1.5-rc.2 / 0.1.6-alpha.2 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1** 实测(RPC envelope 探针全过;0.1.7-rc.2 上 `/ollama-usage/snapshot` 实测返回;0.2.0-rc.1 上通过新的兼容性门禁并正常加载;0.2.1-rc.1 上兼容门禁与 RPC envelope 探针通过,0.2.1-rc.2 门禁通过);旧版 DSH(0.1.0-rc.5 ~ rc.8)请使用最后兼容的 npm 版本 **0.1.5**。
121
121
 
122
122
  ## 🛠️ 开发 / Develop
123
123
 
package/lib/client.js CHANGED
@@ -93,13 +93,21 @@ window.__ModuleLoader__.load({
93
93
  '.olusa-skeleton.is-wide{width:56%}',
94
94
 
95
95
  // ── 侧栏双横条 ──────────────────────────────────────────────
96
- '.olusa-bars{display:flex;flex-direction:column;gap:8px;padding:6px 8px;width:120px;min-width:120px;flex-shrink:0;box-sizing:border-box;background:transparent;border:none}',
97
- '.olusa-barsrow{display:flex;flex-direction:column;gap:2px;min-width:0}',
98
- '.olusa-barshead{display:flex;justify-content:space-between;align-items:baseline;gap:6px}',
99
- '.olusa-barslabel{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-secondary);white-space:nowrap}',
100
- '.olusa-barsval{font:var(--dsw-font-xxxs-strong-11);font-weight:600;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);white-space:nowrap}',
101
- '.olusa-minibar{height:6px;border-radius:999px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 12%,transparent);overflow:hidden}',
102
- '.olusa-minibarfill{height:100%;border-radius:999px;transition:width .2s ease}',
96
+ // 侧栏底部空间窄:用 5px 圆点把标签和填充色绑定,数值右对齐,进度条压到 5px;
97
+ // 填充色由行内 --olusa-fill 注入,达到 70%/90% 阈值时切换警告/错误语义色,
98
+ // 与面板里的用量配色保持一致。
99
+ '.olusa-bars{display:flex;flex-direction:column;gap:10px;padding:0;width:100%;min-width:0;flex:1 1 auto;box-sizing:border-box;background:transparent;border:none}',
100
+ '.olusa-barsrow{display:flex;flex-direction:column;gap:4px;min-width:0}',
101
+ '.olusa-barshead{display:flex;align-items:center;justify-content:space-between;gap:8px;min-width:0}',
102
+ '.olusa-barslabel{display:inline-flex;align-items:center;gap:5px;min-width:0;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-secondary);white-space:nowrap}',
103
+ '.olusa-barsdot{width:5px;height:5px;border-radius:999px;flex:none;background:var(--olusa-fill,var(--dsw-alias-brand-primary))}',
104
+ '.olusa-barsval{font:var(--dsw-font-xxxs-strong-11);font-weight:600;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);white-space:nowrap;min-width:34px;text-align:right}',
105
+ '.olusa-minibar{height:5px;border-radius:999px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 8%,transparent);overflow:hidden}',
106
+ '.olusa-minibarfill{height:100%;border-radius:999px;background:var(--olusa-fill,var(--dsw-alias-brand-primary));transition:width .3s cubic-bezier(.2,.7,.3,1),background-color .2s ease}',
107
+ '.olusa-barsrow[data-tone=warn] .olusa-barsval{color:var(--dsw-alias-state-warn-primary)}',
108
+ '.olusa-barsrow[data-tone=error] .olusa-barsval{color:var(--dsw-alias-state-error-primary)}',
109
+ '.olusa-barsempty{display:inline-flex;align-items:center;gap:6px;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary);white-space:nowrap}',
110
+ '.olusa-barsempty::before{content:"";width:5px;height:5px;border-radius:999px;flex:none;background:var(--dsw-alias-state-idle-primary)}',
103
111
 
104
112
  '@media (prefers-reduced-motion:reduce){.olusa-barfill,.olusa-minibarfill{transition:none}}',
105
113
  ].join('\n')
@@ -360,7 +368,7 @@ window.__ModuleLoader__.load({
360
368
  React.createElement('button', { className: 'olusa-btn', disabled: busy, onClick: () => doCheck('') }, busy ? '查询中…' : '刷新')
361
369
  ),
362
370
  body,
363
- React.createElement('div', { className: 'olusa-ver' }, 'dsh-ollama-usage · v0.1.13')
371
+ React.createElement('div', { className: 'olusa-ver' }, 'dsh-ollama-usage · v0.1.15')
364
372
  )
365
373
  }
366
374
 
@@ -387,23 +395,62 @@ window.__ModuleLoader__.load({
387
395
 
388
396
  const sp = data && typeof data.sessionPercent === 'number' ? Math.min(100, Math.max(0, data.sessionPercent)) : null
389
397
  const wp = data && typeof data.weeklyPercent === 'number' ? Math.min(100, Math.max(0, data.weeklyPercent)) : null
390
- const tip = sp === null
391
- ? 'Ollama 用量:未登录(插件列表 → dsh-ollama-usage 配置)'
392
- : 'Ollama 会话用量(每 5 小时):' + (Math.round(sp * 10) / 10) + '% · 周用量:' + (Math.round(wp * 10) / 10) + '%' + (updatedAt ? ' · 更新于 ' + fmtTime(updatedAt) : '')
398
+ const fmtPct = (p) => {
399
+ if (p === null) return '—'
400
+ const v = Math.round(p * 10) / 10
401
+ return (Number.isInteger(v) ? String(v) : v.toFixed(1)) + '%'
402
+ }
403
+ const resetNote = (iso) => {
404
+ const text = iso ? fmtCountdown(iso) : null
405
+ return text ? ' · ' + text + '后重置' : ''
406
+ }
407
+ const toneOf = (p) => (p !== null && p >= 90 ? 'error' : p !== null && p >= 70 ? 'warn' : undefined)
408
+ const fillOf = (p, base) => (p === null
409
+ ? 'var(--dsw-alias-state-idle-primary)'
410
+ : p >= 90
411
+ ? 'var(--dsw-alias-state-error-primary)'
412
+ : p >= 70
413
+ ? 'var(--dsw-alias-state-warn-primary)'
414
+ : base)
415
+ // 极小百分比也要留下可见的圆头:0.2% 在 120px 容器里不足 1px。
416
+ const widthOf = (p) => (p === null || p <= 0 ? 0 : Math.max(p, 2))
417
+ const tip = sp === null && wp === null
418
+ ? 'Ollama 用量:未登录,点击插件列表中的 dsh-ollama-usage 完成登录'
419
+ : 'Ollama 用量 · 会话 5h ' + fmtPct(sp) + resetNote(data && data.sessionResetAt) +
420
+ ' · 本周 ' + fmtPct(wp) + resetNote(data && data.weeklyResetAt) +
421
+ (updatedAt ? ' · 更新于 ' + fmtTime(updatedAt) : '')
393
422
  const rows = [
394
- { label: '会话5h', p: sp, color: SESSION_COLOR },
395
- { label: '周用量', p: wp, color: WEEKLY_COLOR },
423
+ { label: '会话 5h', aria: '会话 5 小时用量', p: sp, base: SESSION_COLOR, resetAt: data && data.sessionResetAt },
424
+ { label: '周用量', aria: '本周用量', p: wp, base: WEEKLY_COLOR, resetAt: data && data.weeklyResetAt },
396
425
  ]
397
- return React.createElement('div', { className: 'olusa-bars', title: tip },
398
- rows.map((b) => React.createElement('div', { className: 'olusa-barsrow', key: b.label },
399
- React.createElement('div', { className: 'olusa-barshead' },
400
- React.createElement('span', { className: 'olusa-barslabel' }, b.label),
401
- React.createElement('span', { className: 'olusa-barsval' }, b.p === null ? '—' : (Math.round(b.p * 10) / 10) + '%')
402
- ),
403
- React.createElement('div', { className: 'olusa-minibar' },
404
- React.createElement('div', { className: 'olusa-minibarfill', style: { width: (b.p === null ? 0 : b.p) + '%', background: b.color } })
426
+ if (sp === null && wp === null) {
427
+ return React.createElement('div', { className: 'olusa-bars', title: tip, role: 'group', 'aria-label': 'Ollama 用量' },
428
+ React.createElement('span', { className: 'olusa-barsempty' }, 'Ollama 未登录'))
429
+ }
430
+ return React.createElement('div', { className: 'olusa-bars', title: tip, role: 'group', 'aria-label': 'Ollama Cloud 用量' },
431
+ rows.map((b) => {
432
+ const tone = toneOf(b.p)
433
+ const fill = fillOf(b.p, b.base)
434
+ return React.createElement('div', { className: 'olusa-barsrow', key: b.label, 'data-tone': tone },
435
+ React.createElement('div', { className: 'olusa-barshead' },
436
+ React.createElement('span', { className: 'olusa-barslabel' },
437
+ React.createElement('span', { className: 'olusa-barsdot', style: { '--olusa-fill': fill } }),
438
+ b.label
439
+ ),
440
+ React.createElement('span', { className: 'olusa-barsval' }, fmtPct(b.p))
441
+ ),
442
+ React.createElement('div', {
443
+ className: 'olusa-minibar',
444
+ role: 'progressbar',
445
+ 'aria-label': b.aria,
446
+ 'aria-valuemin': 0,
447
+ 'aria-valuemax': 100,
448
+ 'aria-valuenow': b.p === null ? 0 : Math.round(b.p),
449
+ },
450
+ React.createElement('div', { className: 'olusa-minibarfill', style: { width: widthOf(b.p) + '%', '--olusa-fill': fill } })
451
+ )
405
452
  )
406
- ))
453
+ })
407
454
  )
408
455
  }
409
456
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ollama-usage",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "DeepSeek Harness 插件:可视化 Ollama Cloud 账号用量余量(每 5 小时会话用量 + 周用量),支持侧边栏双横条、插件详情页完整面板、API Key 与用量快照持久化、自动刷新与登录引导。Ollama Pro usage & remaining-quota visualization for DeepSeek Harness: 5-hour session + weekly quota bars in the sidebar footer, a full panel on the plugin's own detail page, persisted API key and usage snapshots, auto-refresh and login guidance.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",