dsh-ws-recency 0.10.5 → 0.10.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/client.js +58 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -68,7 +68,7 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
68
68
  会话下方统计条上的「用量分析」,或会话「…」菜单 →「Token 消耗统计」:
69
69
 
70
70
  - **真实账单**(每步记录的 usage):步数、输入(未缓存)、缓存命中、输出、合计;
71
- - **消耗分布图**(按内容估算):主 agent 自己(思考 / 回复 / 用户消息 / 系统提示)vs 每个工具,每个来源一条带颜色的横条,按占用长度直观对比;
71
+ - **消耗分布图**(按内容估算):主 agent 自己(思考 / 回复 / 用户消息 / 系统提示)vs 每个工具,每个来源一条带颜色的横条,按占用长度直观对比;色相由工具身份决定(常用工具人工指定,其余按名字哈希,跨会话稳定),明艳度随占比排名递减;
72
72
  - **明细表**:调用次数、参数估算、结果估算、合计、占比,按合计降序,默认折叠,点「显示明细」展开。
73
73
 
74
74
  口径说明:prompt 的 token 是「整段上下文每一步都计费」,没法精确归属到某一条消息,所以「主 agent / 工具」的拆分是按内容长度估算(中文≈1 token/字,英文≈4 字符/token),用来比较占比;**总量是真的**。数据从会话日志算,跨重启也能看。大会话第一次打开约 1–2 秒(29MB 日志实测 1.2 秒),10 秒内重复打开走缓存。
@@ -110,7 +110,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
110
110
  或固定版本的预构建包:
111
111
 
112
112
  ```powershell
113
- dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.10.5/dsh-ws-recency-0.10.5.tgz
113
+ dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.10.6/dsh-ws-recency-0.10.6.tgz
114
114
  ```
115
115
 
116
116
  装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
package/client.js CHANGED
@@ -1138,6 +1138,57 @@
1138
1138
  return row;
1139
1139
  }
1140
1140
 
1141
+ /**
1142
+ * Colour identity for a source.
1143
+ *
1144
+ * The tool set is open - every plugin and MCP server adds tools - so it
1145
+ * cannot be enumerated. A curated hue for the common tools plus a stable
1146
+ * hash for everything else keeps one name on one hue across sessions, and
1147
+ * the rank only modulates how vivid it is: the heaviest source reads
1148
+ * strongest, the tail fades back.
1149
+ */
1150
+ var TOOL_HUES = {
1151
+ pwsh: 32, powershell: 32, shell: 32, bash: 32, command: 32,
1152
+ read: 152, write: 217, edit: 268, grep: 190, glob: 88,
1153
+ todo_write: 292, todo_read: 292, todo: 292,
1154
+ job_output: 330, job_list: 330, job_kill: 330,
1155
+ web_fetch: 205, web_search: 205, platform_search: 205, multi_search: 205, advanced_search: 205,
1156
+ subagent: 250, subagent_fork: 250, workflow: 250, spawn_teammate: 250, send_message: 250, wait_agent: 250,
1157
+ ask_user_question: 12, present: 12,
1158
+ skill: 60, create_goal: 60, update_goal: 60,
1159
+ };
1160
+ var TOOL_PREFIX_HUES = [
1161
+ ["mcp__", 235],
1162
+ ["browser_", 0],
1163
+ ["univer_", 175],
1164
+ ["weknora_", 300],
1165
+ ["job_", 330],
1166
+ ["team_", 250],
1167
+ ];
1168
+
1169
+ function hashHue(name) {
1170
+ var hash = 0;
1171
+ for (var i = 0; i < name.length; i += 1) hash = (hash * 31 + name.charCodeAt(i)) % 360;
1172
+ return hash;
1173
+ }
1174
+
1175
+ function sourceHue(name) {
1176
+ if (typeof name !== "string" || name === "") return 210;
1177
+ var key = name.toLowerCase();
1178
+ if (TOOL_HUES[key] !== undefined) return TOOL_HUES[key];
1179
+ for (var i = 0; i < TOOL_PREFIX_HUES.length; i += 1) {
1180
+ if (key.indexOf(TOOL_PREFIX_HUES[i][0]) === 0) return TOOL_PREFIX_HUES[i][1];
1181
+ }
1182
+ return hashHue(key);
1183
+ }
1184
+
1185
+ /** Rank 0 is the heaviest source; later ranks fade towards grey. */
1186
+ function sourceColor(hue, rank) {
1187
+ var saturation = Math.max(40, 88 - rank * 8);
1188
+ var lightness = Math.min(64, 50 + rank * 2);
1189
+ return "hsl(" + hue + ", " + saturation + "%, " + lightness + "%)";
1190
+ }
1191
+
1141
1192
  function renderStats(body, stats) {
1142
1193
  body.textContent = "";
1143
1194
  while (body.firstChild !== null) body.removeChild(body.firstChild);
@@ -1163,10 +1214,14 @@
1163
1214
  body.appendChild(grid);
1164
1215
 
1165
1216
  var tools = estimate.tools || [];
1166
- var palette = ["#d97706", "#059669", "#7c3aed", "#db2777", "#0891b2", "#65a30d", "#9333ea", "#dc2626"];
1167
- var entries = [{ name: t("stats.agent"), value: agent.total || 0, share: agent.share || 0, color: "#4b8bf5" }];
1217
+ var entries = [{ name: t("stats.agent"), value: agent.total || 0, share: agent.share || 0, color: sourceColor(217, 0) }];
1168
1218
  for (var j = 0; j < tools.length; j += 1) {
1169
- entries.push({ name: tools[j].name, value: tools[j].total || 0, share: tools[j].share || 0, color: palette[j % palette.length] });
1219
+ entries.push({
1220
+ name: tools[j].name,
1221
+ value: tools[j].total || 0,
1222
+ share: tools[j].share || 0,
1223
+ color: sourceColor(sourceHue(tools[j].name), j + 1),
1224
+ });
1170
1225
  }
1171
1226
 
1172
1227
  /* The picture first: one bar per source, sized against the largest. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ws-recency",
3
- "version": "0.10.5",
3
+ "version": "0.10.6",
4
4
  "description": "Sidebar session management for DeepSeek Harness: workspace groups sorted by latest activity, stale history folded, a global pinned section, follow-up marks, session delete into a recoverable trash, and per-session token statistics split by tool.",
5
5
  "license": "MIT",
6
6
  "author": "chyxhtc",