dsh-session-title-stamp 0.4.4 → 0.6.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/README.md CHANGED
@@ -13,6 +13,9 @@ title. Beyond automatic naming:
13
13
  100-message freeze; forks and user-pinned titles are skipped.
14
14
  - **Generate title** — the conversation-header ↻ button, the session row's
15
15
  **Generate title** menu item, or `/retitle`.
16
+ - **Copy title** — an extra item in the session `···` menu copies the full title.
17
+ - **Optional category emoji** — `categoryEmoji: true` renders titles such as
18
+ `1027 | ⚡ 优化 | ...`.
16
19
  - **Hover stats** — elapsed time, estimated CNY cost, and token count on the
17
20
  session hover card.
18
21
  - **Category language** — `categoryPreset: zh | en`, or your own `categories`.
@@ -30,7 +33,8 @@ For example, with `categoryPreset: en`:
30
33
  ```text
31
34
  1028 | Analysis | Short-drama platform verification
32
35
  1027 | Fix | Four-device acceptance rework
33
- 1026 | Deploy | Ubuntu environment setup
36
+ 1026 | Release | Ubuntu environment setup
37
+ 1025 | Optimize | Reduce memory usage in the renderer
34
38
  ```
35
39
 
36
40
  Dates are computed by the plugin from the session's creation time, never by the
@@ -59,7 +63,7 @@ and mirrors conventions used by other coding agents.
59
63
  Add this market index source in **Plugins → Discover → Index sources**:
60
64
 
61
65
  ```text
62
- https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.4.4/market/index.json
66
+ https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.6.0/market/index.json
63
67
  ```
64
68
 
65
69
  Then install **Session title stamp** from the list. The plugin installs as a
@@ -129,14 +133,14 @@ mode using `retitleEvery`.
129
133
 
130
134
  ### Header button and hover stats
131
135
 
132
- 0.4.4 adds a small browser half:
136
+ 0.6.0 adds a small browser half:
133
137
 
134
138
  - a **refresh icon** in the conversation header; it runs the same `/retitle`
135
139
  command as typing it, and is disabled while the session is running.
136
140
  - a **hover-card line** under the native relative time, for example
137
141
  `Duration 1h 51m · est. ≈¥4.11 · 131.7M tokens`;
138
- - a **Generate title** item at the top of the session row's `···` menu. It
139
- runs the same `/retitle` command and adds no dialog.
142
+ - a **Generate title** item at the top of the session row's `···` menu, plus a
143
+ **Copy title** item below the native Copy Session ID. Neither adds a dialog.
140
144
 
141
145
  The hover line is derived from the `sessionStats` and `tokenUsage` projections,
142
146
  priced with the current DeepSeek CNY rate table, and labelled as an estimate.
@@ -187,6 +191,7 @@ Override the row in the profile's `cordis.patch.yml`:
187
191
  | `timeZone` | host local | IANA zone used for date/time placeholders |
188
192
  | `categoryPreset` | `zh` | Built-in category language: `zh` or `en` |
189
193
  | `categories` | preset | Explicit category list; overrides `categoryPreset` |
194
+ | `categoryEmoji` | `false` | Prefix the category with its emoji (⚡ 优化, 🐛 修复, ...) |
190
195
  | `maxNameChars` | `20` | Character cap before the byte cap applies |
191
196
  | `maxTitleBytes` | service cap (`80`) | Effective cap is the smaller of this and `session-title`'s cap |
192
197
  | `recentMessages` | `8` | First message plus this many recent messages are sent |
@@ -209,7 +214,7 @@ typo is visible instead of silently disappearing. The template owns the final
209
214
  format; `maxTitleBytes` still clips the result.
210
215
 
211
216
  The default taxonomy is Chinese. `categoryPreset: en` switches it to
212
- `Analysis / Build / Fix / Debug / QA / Deploy / Docs / Other`; `categories`
217
+ `Analysis / Build / Fix / Optimize / Debug / QA / Release / Docs / Other`; `categories`
213
218
  overrides either preset with any labels you want. The prompt lists the configured
214
219
  labels and the local fallback maps common keywords onto them.
215
220
 
package/README.zh.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  - **自动重算**:回答完成后更新,2 分钟冷却,超过 100 条消息后冻结;fork、子代理和手动固定的标题跳过。
8
8
  - **生成标题**:会话头 ↻ 按钮、会话行 `···` 菜单「自动生成标题」、或 `/retitle`。
9
+ - **复制标题**:会话行 `···` 菜单多一项复制完整标题。
10
+ - **可选 emoji 分类**:`categoryEmoji: true` 后标题形如 `1027 | ⚡ 优化 | ...`。
9
11
  - **悬停统计**:会话行悬停显示耗时、估算 CNY 成本、token 数。
10
12
  - **分类语言**:`categoryPreset: zh | en`,也可以用 `categories` 自定义。
11
13
  - **失败保护**:重算失败保留当前标题,不被兜底标题覆盖。
@@ -21,8 +23,9 @@
21
23
 
22
24
  ```text
23
25
  1028 | 分析 | 绿洲短剧平台验证
24
- 1027 | 整改 | 四台设备第十题验收返修
25
- 1026 | 部署 | Ubuntu 环境初始化
26
+ 1027 | 修复 | 四台设备第十题验收返修
27
+ 1026 | 发布 | Ubuntu 环境初始化
28
+ 1025 | 优化 | 降低渲染器内存占用
26
29
  ```
27
30
 
28
31
  日期由插件从**会话创建时间**计算,不交给模型;分类只能从可配置词表中选择,并在本地校验;模型只负责提出分类和名称,最终格式由模板决定。
@@ -43,7 +46,7 @@
43
46
  在 **插件 → 发现(Discover)→ 索引源** 添加:
44
47
 
45
48
  ```text
46
- https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.4.4/market/index.json
49
+ https://cdn.jsdelivr.net/gh/xuedipiaofei/dsh-session-title-stamp@v0.6.0/market/index.json
47
50
  ```
48
51
 
49
52
  然后在列表里安装 **Session title stamp / 会话标题印章**。插件以 profile bundle 的形式安装,之后可在插件页启停。
@@ -93,13 +96,13 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
93
96
 
94
97
  ### 会话头按钮与悬停统计
95
98
 
96
- 0.4.4 增加了一个很小的浏览器半边:
99
+ 0.6.0 增加了一个很小的浏览器半边:
97
100
 
98
101
  - 会话头有一个**刷新图标**,效果等同输入 `/retitle`,会话运行中禁用;
99
102
  - 鼠标悬停会话行时,在原生相对时间下面多一行:
100
103
  `耗时 1h 51m · 估算 ≈¥4.11 · 131.7M tokens`;
101
- - 会话行 `···` 菜单最上面多一项「自动生成标题」;同样调用 `/retitle`,
102
- 不新开弹窗。
104
+ - 会话行 `···` 菜单最上面多一项「自动生成标题」,下面多一项「复制标题」;
105
+ 两者都不新开弹窗。
103
106
 
104
107
  数字来自 `sessionStats` / `tokenUsage` 投影,按 DeepSeek 当前 CNY 价格估算,并标注「估算」。只在悬停时向宿主请求,不会为了显示数字去恢复未加载的会话。DSH 原生已经有运行中/待交互/完成未读的状态点与 loader,所以本插件**不再加一层状态颜色**。
105
108
 
@@ -141,6 +144,7 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
141
144
  | `timeZone` | 本机时区 | 日期/时间占位符使用的 IANA 时区 |
142
145
  | `categoryPreset` | `zh` | 内置分类语言:`zh` 或 `en` |
143
146
  | `categories` | 预设 | 显式分类词表,优先级高于 `categoryPreset` |
147
+ | `categoryEmoji` | `false` | 给分类加 emoji 前缀(⚡ 优化、🐛 修复……) |
144
148
  | `maxNameChars` | `20` | 名称字符上限(最终还受字节上限约束) |
145
149
  | `maxTitleBytes` | 标题服务上限(`80`) | 实际取它与 `session-title` 的较小值 |
146
150
  | `recentMessages` | `8` | 发送首条消息 + 最近 N 条消息 |
@@ -161,7 +165,7 @@ fork 子会话、子代理会话,以及用户手动改名固定的标题都会
161
165
  不认识的占位符会**原样保留**(`{MMDD} {bogus}` 会保留 `{bogus}`),方便一眼看出模板写错,而不是悄悄消失。最终仍受 `maxTitleBytes` 截断。
162
166
 
163
167
  默认分类是中文。`categoryPreset: en` 可切到
164
- `Analysis / Build / Fix / Debug / QA / Deploy / Docs / Other`;`categories`
168
+ `Analysis / Build / Fix / Optimize / Debug / QA / Release / Docs / Other`;`categories`
165
169
  可以覆盖任意预设。提示词使用配置的标签,本地兜底也会把常见中英文关键词映射过去。
166
170
 
167
171
  ## 隐私与成本
package/client.js CHANGED
@@ -27,6 +27,8 @@ window.__ModuleLoader__.load({
27
27
  running: '会话运行中,稍后再试',
28
28
  duration: '耗时',
29
29
  estimate: '估算',
30
+ copyTitle: '复制标题',
31
+ copyHint: '复制完整会话标题',
30
32
  },
31
33
  en: {
32
34
  menu: 'Generate title',
@@ -34,6 +36,8 @@ window.__ModuleLoader__.load({
34
36
  running: 'Session is running; try again later',
35
37
  duration: 'Duration',
36
38
  estimate: 'est.',
39
+ copyTitle: 'Copy title',
40
+ copyHint: 'Copy the full session title',
37
41
  },
38
42
  }
39
43
 
@@ -205,8 +209,57 @@ window.__ModuleLoader__.load({
205
209
  )
206
210
  }
207
211
 
212
+ function CopyIcon() {
213
+ return h(
214
+ 'svg',
215
+ {
216
+ width: 14,
217
+ height: 14,
218
+ viewBox: '0 0 16 16',
219
+ fill: 'none',
220
+ stroke: 'currentColor',
221
+ strokeWidth: 1.5,
222
+ strokeLinecap: 'round',
223
+ strokeLinejoin: 'round',
224
+ 'aria-hidden': 'true',
225
+ },
226
+ h('rect', { x: 5, y: 4, width: 8, height: 9, rx: 1.5 }),
227
+ h('path', { d: 'M11 4V3.5A1.5 1.5 0 0 0 9.5 2h-6A1.5 1.5 0 0 0 2 3.5v7A1.5 1.5 0 0 0 3.5 12H5' }),
228
+ )
229
+ }
230
+
231
+ function CopyTitleMenuItem({ displayTitle, useMenuOpenState, t }) {
232
+ const menuState =
233
+ typeof useMenuOpenState === 'function' ? useMenuOpenState() : null
234
+ const disabled = typeof displayTitle !== 'string' || displayTitle === ''
235
+ return h(
236
+ 'button',
237
+ {
238
+ type: 'button',
239
+ role: 'menuitem',
240
+ className: 'dsh-title-menu-item',
241
+ disabled,
242
+ title: t('copyHint'),
243
+ onClick: async () => {
244
+ if (disabled) return
245
+ if (Array.isArray(menuState) && typeof menuState[1] === 'function') {
246
+ menuState[1](false)
247
+ }
248
+ try {
249
+ await navigator.clipboard.writeText(displayTitle)
250
+ } catch (error) {
251
+ console.warn('session-title-stamp: copy title failed', error)
252
+ }
253
+ },
254
+ },
255
+ h('span', { className: 'dsh-title-menu-icon', 'aria-hidden': 'true' }, h(CopyIcon)),
256
+ h('span', null, t('copyTitle')),
257
+ )
258
+ }
259
+
208
260
  const STYLE_ID = 'dsh-session-title-stamp-style'
209
261
 
262
+
210
263
  function installStyle(ctx) {
211
264
  const style = document.createElement('style')
212
265
  style.id = STYLE_ID
@@ -261,6 +314,18 @@ window.__ModuleLoader__.load({
261
314
  ),
262
315
  )
263
316
 
317
+ ctx.slots.inject('sidebar.workspaces.session.menu.item', () =>
318
+ ctx.slots.register(
319
+ {
320
+ name: 'sidebar.workspaces.session.menu.item',
321
+ id: 'session-title-stamp-copy',
322
+ order: 460,
323
+ inject: () => ({ t }),
324
+ },
325
+ CopyTitleMenuItem,
326
+ ),
327
+ )
328
+
264
329
  ctx.slots.inject('sidebar.session.row.hover', () =>
265
330
  ctx.slots.register(
266
331
  {
package/lib/format.js CHANGED
@@ -7,12 +7,40 @@
7
7
  */
8
8
 
9
9
  export const CATEGORY_PRESETS = Object.freeze({
10
- zh: ['分析', '实现', '整改', '排查', '验收', '部署', '文档', '其他'],
11
- en: ['Analysis', 'Build', 'Fix', 'Debug', 'QA', 'Deploy', 'Docs', 'Other'],
10
+ zh: ['分析', '实现', '修复', '优化', '排查', '验收', '发布', '文档', '其他'],
11
+ en: ['Analysis', 'Build', 'Fix', 'Optimize', 'Debug', 'QA', 'Release', 'Docs', 'Other'],
12
12
  })
13
13
 
14
14
  export const DEFAULT_CATEGORIES = [...CATEGORY_PRESETS.zh]
15
15
 
16
+ /** Opt-in emoji prefixes; titles stay plain unless `categoryEmoji: true`. */
17
+ export const CATEGORY_EMOJI = Object.freeze({
18
+ 分析: '🔍',
19
+ 实现: '✨',
20
+ 修复: '🐛',
21
+ 优化: '⚡',
22
+ 排查: '🔎',
23
+ 验收: '✅',
24
+ 发布: '🚀',
25
+ 文档: '📝',
26
+ 其他: '📌',
27
+ Analysis: '🔍',
28
+ Build: '✨',
29
+ Fix: '🐛',
30
+ Optimize: '⚡',
31
+ Debug: '🔎',
32
+ QA: '✅',
33
+ Release: '🚀',
34
+ Docs: '📝',
35
+ Other: '📌',
36
+ })
37
+
38
+ /** Prefix a configured category with its emoji when one exists. */
39
+ export function categoryWithEmoji(category) {
40
+ const emoji = CATEGORY_EMOJI[category]
41
+ return emoji === undefined ? category : `${emoji} ${category}`
42
+ }
43
+
16
44
  /** Default template: `1028 | 分析 | 登录超时`. `{date}` honours `dateFormat`. */
17
45
  export const DEFAULT_TEMPLATE = '{date} | {type} | {topic}'
18
46
 
@@ -20,18 +48,20 @@ export const DEFAULT_TEMPLATE = '{date} | {type} | {topic}'
20
48
  export const CATEGORY_HINTS = {
21
49
  分析: '调研、评估、方案对比、根因分析、可行性判断',
22
50
  实现: '新功能开发、编码、脚本实现',
23
- 整改: '修复缺陷、返工、验收问题整改',
51
+ 修复: '修复缺陷、返工、验收问题修复',
52
+ 优化: '性能优化、内存/体积优化、重构、提速',
24
53
  排查: '故障定位、调试、日志排查',
25
54
  验收: '测试、验收、逐项核对、复测',
26
- 部署: '上线、发布、环境配置、运维',
55
+ 发布: '上线、发布、环境配置、运维',
27
56
  文档: '文档编写、整理、总结',
28
57
  其他: '以上都不合适',
29
58
  Analysis: 'research, evaluation, options, root-cause analysis',
30
59
  Build: 'new implementation, coding, scripts',
31
60
  Fix: 'defect repair, rework, acceptance fixes',
61
+ Optimize: 'performance, memory/size, refactoring, speed',
32
62
  Debug: 'troubleshooting, diagnosis, logs',
33
63
  QA: 'testing, acceptance, verification',
34
- Deploy: 'release, environment setup, operations',
64
+ Release: 'release, deployment, environment setup, operations',
35
65
  Docs: 'documentation, cleanup, summary',
36
66
  Other: 'none of the above',
37
67
  }
@@ -47,21 +77,27 @@ const CATEGORY_ALIASES = {
47
77
  开发: '实现',
48
78
  编码: '实现',
49
79
  功能: '实现',
50
- 修复: '整改',
51
- 返工: '整改',
52
- 缺陷: '整改',
53
- bug: '整改',
54
- 问题: '整改',
80
+ 修复: '修复',
81
+ 返工: '修复',
82
+ 缺陷: '修复',
83
+ bug: '修复',
84
+ 问题: '修复',
85
+ 整改: '修复',
86
+ 优化: '优化',
87
+ 性能: '优化',
88
+ 重构: '优化',
89
+ 提速: '优化',
55
90
  调试: '排查',
56
91
  定位: '排查',
57
92
  故障: '排查',
58
93
  测试: '验收',
59
94
  复测: '验收',
60
95
  核对: '验收',
61
- 上线: '部署',
62
- 发布: '部署',
63
- 运维: '部署',
64
- 环境: '部署',
96
+ 上线: '发布',
97
+ 发布: '发布',
98
+ 运维: '发布',
99
+ 环境: '发布',
100
+ 部署: '发布',
65
101
  写作: '文档',
66
102
  整理: '文档',
67
103
  说明: '文档',
@@ -69,16 +105,18 @@ const CATEGORY_ALIASES = {
69
105
 
70
106
  /** Ordered keyword table for the deterministic fallback classifier. */
71
107
  const CATEGORY_KEYWORDS = [
72
- ['整改', ['整改', '修复', '返工', '缺陷', 'bug', '报错', '不通过', '失败', '问题']],
108
+ ['修复', ['修复', '整改', '返工', '缺陷', 'bug', '报错', '不通过', '失败', '问题', 'fix', 'repair']],
109
+ ['优化', ['优化', '性能', '内存', '重构', '提速', 'optimize', 'performance', 'refactor', 'memory', 'speed']],
73
110
  ['验收', ['验收', '测试', '复测', '核对', '检查', 'acceptance', 'validation']],
74
- ['部署', ['部署', '上线', '发布', '环境', '运维', 'docker', 'nginx', 'deploy', 'release']],
111
+ ['发布', ['发布', '部署', '上线', '环境', '运维', 'docker', 'nginx', 'deploy', 'release', 'ship']],
75
112
  ['排查', ['排查', '定位', '调试', '诊断', '崩溃', '异常', 'debug', 'troubleshoot', 'traceback']],
76
113
  ['文档', ['文档', 'readme', '整理', '总结', '说明', 'document']],
77
114
  ['实现', ['实现', '开发', '新增', '编码', '功能', 'implement', 'develop', 'feature']],
78
115
  ['分析', ['分析', '评估', '调研', '方案', '对比', '验证', '研究', 'analyze', 'research', 'review']],
79
116
  ['Fix', ['fix', 'bug', 'repair', 'defect', 'error', 'issue', 'broken']],
117
+ ['Optimize', ['optimize', 'performance', 'refactor', 'memory', 'speed', 'tune']],
80
118
  ['QA', ['test', 'acceptance', 'verify', 'qa', 'validation']],
81
- ['Deploy', ['deploy', 'release', 'ops', 'environment', 'docker', 'nginx', 'ship']],
119
+ ['Release', ['release', 'deploy', 'ops', 'environment', 'docker', 'nginx', 'ship']],
82
120
  ['Debug', ['debug', 'troubleshoot', 'diagnose', 'crash', 'traceback', 'log']],
83
121
  ['Docs', ['doc', 'readme', 'document', 'writeup', 'summarize']],
84
122
  ['Build', ['build', 'implement', 'develop', 'feature', 'code', 'script']],
@@ -186,6 +224,7 @@ export function resolveSettings(raw, serviceMaxBytes) {
186
224
  ? config.timeZone.trim()
187
225
  : undefined,
188
226
  categories,
227
+ categoryEmoji: config.categoryEmoji === true,
189
228
  maxTitleBytes,
190
229
  maxNameChars: Math.min(40, Math.max(4, positiveInteger(config.maxNameChars, 20))),
191
230
  recentMessages: Math.min(20, Math.max(2, positiveInteger(config.recentMessages, 8))),
package/lib/index.js CHANGED
@@ -19,6 +19,7 @@ import { join } from 'node:path'
19
19
  import {
20
20
  buildInput,
21
21
  buildSystemPrompt,
22
+ categoryWithEmoji,
22
23
  cleanName,
23
24
  composeTitle,
24
25
  inferCategory,
@@ -454,7 +455,8 @@ export function apply(ctx, config) {
454
455
  name = cleanName(undefined, settings, sourceText)
455
456
  }
456
457
 
457
- const title = composeTitle(timestamp, category, name, settings)
458
+ const displayCategory = settings.categoryEmoji ? categoryWithEmoji(category) : category
459
+ const title = composeTitle(timestamp, displayCategory, name, settings)
458
460
  if (previousTitle !== undefined && normalizeTitle(previousTitle) === normalizeTitle(title)) {
459
461
  logger?.info?.('session-title-stamp: title unchanged after retitle')
460
462
  }
package/market/index.json CHANGED
@@ -57,12 +57,12 @@
57
57
  },
58
58
  "versions": [
59
59
  {
60
- "version": "0.4.4",
61
- "publishTimestamp": 1793459953,
60
+ "version": "0.6.0",
61
+ "publishTimestamp": 1793714709,
62
62
  "source": {
63
63
  "type": "git",
64
64
  "url": "https://github.com/xuedipiaofei/dsh-session-title-stamp",
65
- "commit": "ab95b6ce864fcf608c4479173d620b0c78d89686"
65
+ "commit": "cfe08afebb3fd605cdb0af44acf22d8906bba400"
66
66
  },
67
67
  "engines": {
68
68
  "dsh": ">=0.2.1-rc.3 <0.3.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-title-stamp",
3
- "version": "0.4.4",
3
+ "version": "0.6.0",
4
4
  "description": "DSH session titles in a DATE | CATEGORY | NAME template, with turn-aware auto-generation, a Generate title button, and hover cost/duration.",
5
5
  "keywords": [
6
6
  "dsh",