@weibaohui/context-razor 0.2.0 → 0.3.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 +1 -0
- package/client/bundle.js +8 -1
- package/client/index.js +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
- **逐条列出**:当前会话模型可见的每条上下文(用户/助手/工具结果)按序排列,带预览、字符数与 ≈token 估算,点 ⋯ 查看全文与真实 usage
|
|
13
13
|
- **超阈值标红**:可调阈值(默认 500 token,本地记忆),超限条目红色高亮;「只看超阈值」过滤 + 「token 高→低」排序,大头一眼可见
|
|
14
14
|
- **精确裁剪**:勾选任意条目一键删除——连续段自动合并处理。删除走宿主 surface replace 协议(与官方 compaction 同款机制),**不经 LLM 总结**,删了什么、删了多少完全由你决定
|
|
15
|
+
- **不重排**:本插件不会改变上下文条目顺序,只会剔除选中条目;排序下拉仅影响页面显示(上下文顺序 / 原始序号 / token 高→低),模型可见顺序始终由会话 surface 决定
|
|
15
16
|
- **安全护栏**:会话运行中禁止裁剪(等当前回合结束);每次替换附带一条 notice 标记消息,模型知道这段历史被你移除了,需要时会主动向你确认
|
|
16
17
|
- **非破坏**:append-only 日志保留全部痕迹(宿主机制如此)。「删除」= 从模型视野与界面投影中移除
|
|
17
18
|
|
package/client/bundle.js
CHANGED
|
@@ -64,7 +64,9 @@ window.__ModuleLoader__.load({
|
|
|
64
64
|
busyTag: '运行中',
|
|
65
65
|
sortLabel: '排序',
|
|
66
66
|
sortOrder: '上下文顺序',
|
|
67
|
+
sortSeq: '原始序号',
|
|
67
68
|
sortTokens: 'token 高→低',
|
|
69
|
+
orderNote: '本插件不会改变上下文条目顺序,只会剔除选中条目。',
|
|
68
70
|
selectVisible: '选中可见',
|
|
69
71
|
selectVisibleHint: '选中当前显示的全部条目(配合色块筛选)',
|
|
70
72
|
clearSelect: '清空选择',
|
|
@@ -101,7 +103,9 @@ window.__ModuleLoader__.load({
|
|
|
101
103
|
busyTag: 'running',
|
|
102
104
|
sortLabel: 'Sort',
|
|
103
105
|
sortOrder: 'Context order',
|
|
106
|
+
sortSeq: 'Original seq',
|
|
104
107
|
sortTokens: 'tokens high→low',
|
|
108
|
+
orderNote: 'This plugin never reorders context entries; it only removes the selected ones.',
|
|
105
109
|
selectVisible: 'Select shown',
|
|
106
110
|
selectVisibleHint: 'Select every currently shown entry (pairs with tier filters)',
|
|
107
111
|
clearSelect: 'Clear selection',
|
|
@@ -137,8 +141,9 @@ window.__ModuleLoader__.load({
|
|
|
137
141
|
|
|
138
142
|
const kindI18n = (key) => 'kind' + key[0].toUpperCase() + key.slice(1)
|
|
139
143
|
|
|
140
|
-
/** 排序:order =
|
|
144
|
+
/** 排序:order = 投影原序(模型可见序);seq = 原始序号升序(裁剪过的会话里与 order 不同:标记消息 seq 大但在中间);tokens = 降序(并列按 seq,缺 token 沉底)。 */
|
|
141
145
|
function sortEntries(entries, sortBy) {
|
|
146
|
+
if (sortBy === 'seq') return [...entries].sort((a, b) => a.seq - b.seq)
|
|
142
147
|
if (sortBy !== 'tokens') return entries
|
|
143
148
|
return [...entries].sort((a, b) => {
|
|
144
149
|
const va = a.tokens, vb = b.tokens
|
|
@@ -405,6 +410,7 @@ window.__ModuleLoader__.load({
|
|
|
405
410
|
!sessionId && h('div', { className: 'rz-empty' }, t('pickSession')),
|
|
406
411
|
sessionId && ctxLoading && h('div', { className: 'rz-loading' }, t('loading')),
|
|
407
412
|
sessionId && !ctxLoading && context && [
|
|
413
|
+
h('div', { key: 'note', className: 'rz-hint' }, t('orderNote')),
|
|
408
414
|
h('div', { key: 'bar', className: 'rz-stats' },
|
|
409
415
|
h('span', null, t('stats', { nodes: context.nodes, tokens: formatNum(context.totalTokens), mode: context.encoder === 'heuristic' ? t('modeHeuristic') : '' })),
|
|
410
416
|
h('span', { className: 'rz-legend' + (tierFilter.size > 0 ? ' filtering' : ''), title: t('legendTitle') },
|
|
@@ -415,6 +421,7 @@ window.__ModuleLoader__.load({
|
|
|
415
421
|
t('selectVisible') + (visible.length ? ` (${visible.length})` : '')),
|
|
416
422
|
h('select', { className: 'rz-select', value: sortBy, onChange: e => setSortBy(e.target.value), title: t('sortLabel'), 'aria-label': t('sortLabel') },
|
|
417
423
|
h('option', { value: 'order' }, t('sortOrder')),
|
|
424
|
+
h('option', { value: 'seq' }, t('sortSeq')),
|
|
418
425
|
h('option', { value: 'tokens' }, t('sortTokens'))),
|
|
419
426
|
h('button', { className: 'rz-btn', onClick: refreshAll, title: t('refresh') }, t('refresh'))),
|
|
420
427
|
selected.size > 0 && h('div', { key: 'sel', className: 'rz-stats' },
|
package/client/index.js
CHANGED
|
@@ -54,7 +54,9 @@ const ZH = {
|
|
|
54
54
|
busyTag: '运行中',
|
|
55
55
|
sortLabel: '排序',
|
|
56
56
|
sortOrder: '上下文顺序',
|
|
57
|
+
sortSeq: '原始序号',
|
|
57
58
|
sortTokens: 'token 高→低',
|
|
59
|
+
orderNote: '本插件不会改变上下文条目顺序,只会剔除选中条目。',
|
|
58
60
|
selectVisible: '选中可见',
|
|
59
61
|
selectVisibleHint: '选中当前显示的全部条目(配合色块筛选)',
|
|
60
62
|
clearSelect: '清空选择',
|
|
@@ -91,7 +93,9 @@ const EN = {
|
|
|
91
93
|
busyTag: 'running',
|
|
92
94
|
sortLabel: 'Sort',
|
|
93
95
|
sortOrder: 'Context order',
|
|
96
|
+
sortSeq: 'Original seq',
|
|
94
97
|
sortTokens: 'tokens high→low',
|
|
98
|
+
orderNote: 'This plugin never reorders context entries; it only removes the selected ones.',
|
|
95
99
|
selectVisible: 'Select shown',
|
|
96
100
|
selectVisibleHint: 'Select every currently shown entry (pairs with tier filters)',
|
|
97
101
|
clearSelect: 'Clear selection',
|
|
@@ -127,8 +131,9 @@ const PAGE_SIZE = 150
|
|
|
127
131
|
|
|
128
132
|
const kindI18n = (key) => 'kind' + key[0].toUpperCase() + key.slice(1)
|
|
129
133
|
|
|
130
|
-
/** 排序:order =
|
|
134
|
+
/** 排序:order = 投影原序(模型可见序);seq = 原始序号升序(裁剪过的会话里与 order 不同:标记消息 seq 大但在中间);tokens = 降序(并列按 seq,缺 token 沉底)。 */
|
|
131
135
|
function sortEntries(entries, sortBy) {
|
|
136
|
+
if (sortBy === 'seq') return [...entries].sort((a, b) => a.seq - b.seq)
|
|
132
137
|
if (sortBy !== 'tokens') return entries
|
|
133
138
|
return [...entries].sort((a, b) => {
|
|
134
139
|
const va = a.tokens, vb = b.tokens
|
|
@@ -395,6 +400,7 @@ function RazorPage({ t, fixedSessionId }) {
|
|
|
395
400
|
!sessionId && h('div', { className: 'rz-empty' }, t('pickSession')),
|
|
396
401
|
sessionId && ctxLoading && h('div', { className: 'rz-loading' }, t('loading')),
|
|
397
402
|
sessionId && !ctxLoading && context && [
|
|
403
|
+
h('div', { key: 'note', className: 'rz-hint' }, t('orderNote')),
|
|
398
404
|
h('div', { key: 'bar', className: 'rz-stats' },
|
|
399
405
|
h('span', null, t('stats', { nodes: context.nodes, tokens: formatNum(context.totalTokens), mode: context.encoder === 'heuristic' ? t('modeHeuristic') : '' })),
|
|
400
406
|
h('span', { className: 'rz-legend' + (tierFilter.size > 0 ? ' filtering' : ''), title: t('legendTitle') },
|
|
@@ -405,6 +411,7 @@ function RazorPage({ t, fixedSessionId }) {
|
|
|
405
411
|
t('selectVisible') + (visible.length ? ` (${visible.length})` : '')),
|
|
406
412
|
h('select', { className: 'rz-select', value: sortBy, onChange: e => setSortBy(e.target.value), title: t('sortLabel'), 'aria-label': t('sortLabel') },
|
|
407
413
|
h('option', { value: 'order' }, t('sortOrder')),
|
|
414
|
+
h('option', { value: 'seq' }, t('sortSeq')),
|
|
408
415
|
h('option', { value: 'tokens' }, t('sortTokens'))),
|
|
409
416
|
h('button', { className: 'rz-btn', onClick: refreshAll, title: t('refresh') }, t('refresh'))),
|
|
410
417
|
selected.size > 0 && h('div', { key: 'sel', className: 'rz-stats' },
|