@weibaohui/context-razor 0.3.0 → 0.4.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
@@ -12,7 +12,7 @@
12
12
  - **逐条列出**:当前会话模型可见的每条上下文(用户/助手/工具结果)按序排列,带预览、字符数与 ≈token 估算,点 ⋯ 查看全文与真实 usage
13
13
  - **超阈值标红**:可调阈值(默认 500 token,本地记忆),超限条目红色高亮;「只看超阈值」过滤 + 「token 高→低」排序,大头一眼可见
14
14
  - **精确裁剪**:勾选任意条目一键删除——连续段自动合并处理。删除走宿主 surface replace 协议(与官方 compaction 同款机制),**不经 LLM 总结**,删了什么、删了多少完全由你决定
15
- - **不重排**:本插件不会改变上下文条目顺序,只会剔除选中条目;排序下拉仅影响页面显示(上下文顺序 / 原始序号 / token 高→低),模型可见顺序始终由会话 surface 决定
15
+ - **不重排**:本插件不会改变上下文条目顺序,只会剔除选中条目;「token 高→低」排序仅影响页面显示,模型可见顺序始终由会话 surface 决定
16
16
  - **安全护栏**:会话运行中禁止裁剪(等当前回合结束);每次替换附带一条 notice 标记消息,模型知道这段历史被你移除了,需要时会主动向你确认
17
17
  - **非破坏**:append-only 日志保留全部痕迹(宿主机制如此)。「删除」= 从模型视野与界面投影中移除
18
18
 
package/client/bundle.js CHANGED
@@ -64,7 +64,6 @@ window.__ModuleLoader__.load({
64
64
  busyTag: '运行中',
65
65
  sortLabel: '排序',
66
66
  sortOrder: '上下文顺序',
67
- sortSeq: '原始序号',
68
67
  sortTokens: 'token 高→低',
69
68
  orderNote: '本插件不会改变上下文条目顺序,只会剔除选中条目。',
70
69
  selectVisible: '选中可见',
@@ -103,7 +102,6 @@ window.__ModuleLoader__.load({
103
102
  busyTag: 'running',
104
103
  sortLabel: 'Sort',
105
104
  sortOrder: 'Context order',
106
- sortSeq: 'Original seq',
107
105
  sortTokens: 'tokens high→low',
108
106
  orderNote: 'This plugin never reorders context entries; it only removes the selected ones.',
109
107
  selectVisible: 'Select shown',
@@ -141,9 +139,10 @@ window.__ModuleLoader__.load({
141
139
 
142
140
  const kindI18n = (key) => 'kind' + key[0].toUpperCase() + key.slice(1)
143
141
 
144
- /** 排序:order = 投影原序(模型可见序);seq = 原始序号升序(裁剪过的会话里与 order 不同:标记消息 seq 大但在中间);tokens = 降序(并列按 seq,缺 token 沉底)。 */
142
+ /** 排序:order = 投影原序(模型可见序);tokens = 降序(并列按 seq,缺 token 沉底)。
143
+ * 只有两档且都是显示层——裁剪过的会话里 seq 升序 ≠ 模型可见序(replace 标记 seq 大但位置在中间),
144
+ * 与「本页展示模型可见上下文」相悖,故不提供 seq 档。 */
145
145
  function sortEntries(entries, sortBy) {
146
- if (sortBy === 'seq') return [...entries].sort((a, b) => a.seq - b.seq)
147
146
  if (sortBy !== 'tokens') return entries
148
147
  return [...entries].sort((a, b) => {
149
148
  const va = a.tokens, vb = b.tokens
@@ -421,7 +420,6 @@ window.__ModuleLoader__.load({
421
420
  t('selectVisible') + (visible.length ? ` (${visible.length})` : '')),
422
421
  h('select', { className: 'rz-select', value: sortBy, onChange: e => setSortBy(e.target.value), title: t('sortLabel'), 'aria-label': t('sortLabel') },
423
422
  h('option', { value: 'order' }, t('sortOrder')),
424
- h('option', { value: 'seq' }, t('sortSeq')),
425
423
  h('option', { value: 'tokens' }, t('sortTokens'))),
426
424
  h('button', { className: 'rz-btn', onClick: refreshAll, title: t('refresh') }, t('refresh'))),
427
425
  selected.size > 0 && h('div', { key: 'sel', className: 'rz-stats' },
package/client/index.js CHANGED
@@ -54,7 +54,6 @@ const ZH = {
54
54
  busyTag: '运行中',
55
55
  sortLabel: '排序',
56
56
  sortOrder: '上下文顺序',
57
- sortSeq: '原始序号',
58
57
  sortTokens: 'token 高→低',
59
58
  orderNote: '本插件不会改变上下文条目顺序,只会剔除选中条目。',
60
59
  selectVisible: '选中可见',
@@ -93,7 +92,6 @@ const EN = {
93
92
  busyTag: 'running',
94
93
  sortLabel: 'Sort',
95
94
  sortOrder: 'Context order',
96
- sortSeq: 'Original seq',
97
95
  sortTokens: 'tokens high→low',
98
96
  orderNote: 'This plugin never reorders context entries; it only removes the selected ones.',
99
97
  selectVisible: 'Select shown',
@@ -131,9 +129,10 @@ const PAGE_SIZE = 150
131
129
 
132
130
  const kindI18n = (key) => 'kind' + key[0].toUpperCase() + key.slice(1)
133
131
 
134
- /** 排序:order = 投影原序(模型可见序);seq = 原始序号升序(裁剪过的会话里与 order 不同:标记消息 seq 大但在中间);tokens = 降序(并列按 seq,缺 token 沉底)。 */
132
+ /** 排序:order = 投影原序(模型可见序);tokens = 降序(并列按 seq,缺 token 沉底)。
133
+ * 只有两档且都是显示层——裁剪过的会话里 seq 升序 ≠ 模型可见序(replace 标记 seq 大但位置在中间),
134
+ * 与「本页展示模型可见上下文」相悖,故不提供 seq 档。 */
135
135
  function sortEntries(entries, sortBy) {
136
- if (sortBy === 'seq') return [...entries].sort((a, b) => a.seq - b.seq)
137
136
  if (sortBy !== 'tokens') return entries
138
137
  return [...entries].sort((a, b) => {
139
138
  const va = a.tokens, vb = b.tokens
@@ -411,7 +410,6 @@ function RazorPage({ t, fixedSessionId }) {
411
410
  t('selectVisible') + (visible.length ? ` (${visible.length})` : '')),
412
411
  h('select', { className: 'rz-select', value: sortBy, onChange: e => setSortBy(e.target.value), title: t('sortLabel'), 'aria-label': t('sortLabel') },
413
412
  h('option', { value: 'order' }, t('sortOrder')),
414
- h('option', { value: 'seq' }, t('sortSeq')),
415
413
  h('option', { value: 'tokens' }, t('sortTokens'))),
416
414
  h('button', { className: 'rz-btn', onClick: refreshAll, title: t('refresh') }, t('refresh'))),
417
415
  selected.size > 0 && h('div', { key: 'sel', className: 'rz-stats' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weibaohui/context-razor",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "dsh 插件 · 上下文剃刀:把当前会话上下文逐条列出(角色/预览/≈token,cl100k 估算),超阈值标红,勾选后精确裁剪——不经 LLM 总结,删了什么一目了然。",
5
5
  "license": "MIT",
6
6
  "keywords": [