dsh-oh-my-token 0.0.1 → 0.0.2
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 +56 -15
- package/README_EN.md +55 -14
- package/client.js +1053 -187
- package/cordis.patch.yml +15 -3
- package/index.js +218 -60
- package/lib/config.js +26 -0
- package/lib/gate.js +9 -2
- package/lib/messages.js +55 -8
- package/lib/modes.js +125 -13
- package/lib/rtk.js +107 -0
- package/lib/system-prompt.js +25 -88
- package/lib/text.js +261 -19
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -13,7 +13,13 @@
|
|
|
13
13
|
| 按命令与输出形状压缩 | [RTK](https://github.com/rtk-ai/rtk)(Apache-2.0) | 先解析模型已运行的命令,只保留结论和失败细节;命令过滤器没命中时,再按内容形状压缩:git diff/status/log、构建日志、grep/find/ls/tree、重复日志、编号文件与搜索结果。纯 JS,无二进制。 |
|
|
14
14
|
| 检索符号而非整文件 | [codegraph](https://github.com/isink17/codegraph) | 把超大且未指定范围的 `read` 变成符号大纲,并限制过大的 `grep` 结果。无 SQLite 图库、无 MCP 服务。 |
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
外加两项模型根本不需要读取的变换(可分别开关):对可判定为散文的行,按一张**可自定义的词表**删去或替换「谢谢」「请」「please」「thanks」等词(默认删,也可配成替换成别的词);以及整理标点——段首的标点删去、挨在一起的两个标点只保留一个(逗号+句号留句号,其余强弱类推)、再删去句末**连续的** `.`、`。`、`,`、`,`(ASCII 省略号 `...` / `…` 除外)。它们作用于工具输出、你亲手输入的消息、助手的回复,以及历史对话——历史部分在组装请求时剥离,因此模型永远不会看到这些内容,而磁盘上的会话文件保持逐字节不变。
|
|
17
|
+
|
|
18
|
+
还能顺手做的两件事:
|
|
19
|
+
|
|
20
|
+
- **对话内容编辑**:在设置页直接改写最近的消息(你自己发的或模型回的)。改写只写进下一次请求,不落盘、不改历史日志;点「恢复原内容」即撤销。
|
|
21
|
+
- **聊天里的红线**:你自己发的消息和模型回复的**正文**里,被自动删掉的词都在原位置画红线,替换成新词的部分是绿色。消息走宿主的文本规则接口,回复正文由宿主渲染 Markdown、没有文本钩子,所以插件在渲染完成后把被删的字插回原位做标记(重渲染会自动补回)。
|
|
22
|
+
- **自动变换记录**:设置页把最近每次散文步骤的改动按 diff 展开——被删掉的词用红色划线,替换或新出现的字用绿色,像看 GitHub 的改动文件一样一眼看到程序动了哪里。记录会写进配置目录,重启 DSH 后仍然在。
|
|
17
23
|
|
|
18
24
|
## 它保留了什么
|
|
19
25
|
|
|
@@ -25,7 +31,7 @@
|
|
|
25
31
|
- `tsc` → 每条 `error TSxxxx` 加总数;告警丢弃。
|
|
26
32
|
- `npm/pnpm/yarn/bun/pip/uv/poetry` 安装 → 成功留摘要行,失败留错误行。
|
|
27
33
|
- 其他命令 → 只做 ANSI、回车重绘、重复行与进度条清理。命令字符串永不改写。
|
|
28
|
-
- 命令过滤器没命中时(或对历史中的旧工具结果),RTK 结构压缩按形状接管:`git diff/status/log` 保留文件名、计数与 hunk 头;构建日志保留错误、告警与摘要;`grep/find/ls/tree/search-list` 按文件/目录分组并给出计数;重复日志折叠;超长无结构内容保留头尾。它只收缩,不放大。
|
|
34
|
+
- 命令过滤器没命中时(或对历史中的旧工具结果),RTK 结构压缩按形状接管:`git diff/status/log` 保留文件名、计数与 hunk 头;构建日志保留错误、告警与摘要;`cargo build/test` 折叠 Compiling/Checking 进度、保留 `error[E…]`、`test result:` 与 Finished;`go test` 把所有 `ok`/`?` 包折叠成一行结论、失败时保留首个 FAIL 起的细节;`eslint` 紧凑格式按文件分组计数;`grep/find/ls/tree/search-list` 按文件/目录分组并给出计数;重复日志折叠;超长无结构内容保留头尾。它只收缩,不放大。
|
|
29
35
|
|
|
30
36
|
结果仍超预算时,全文通过 `ctx.spillStore` 保存,标记会告诉模型去哪里取。如果没挂载 spill store,标记会说明如何重跑或重新读取——插件绝不丢弃无法恢复的文本。
|
|
31
37
|
|
|
@@ -47,11 +53,15 @@ dsh plugin --profile web add file:/path/to/dsh-oh-my-token
|
|
|
47
53
|
|
|
48
54
|
## 设置页面
|
|
49
55
|
|
|
50
|
-
**设置 → 省 Token**
|
|
56
|
+
**设置 → 省 Token** 是管理面板,顶部按 **概览 / 压缩 / 散文 / 对话 / 提示词 / 关于** 分栏,不再是一整页长表单(「关于」页显示插件名、从 `package.json` 读出的版本号,以及一个打开 GitHub 仓库的按钮):
|
|
51
57
|
|
|
52
|
-
- 每个变换一个开关(5 个命令过滤器、RTK 结构压缩、2
|
|
58
|
+
- 每个变换一个开关(5 个命令过滤器、RTK 结构压缩、2 个检索变换、标点整理);
|
|
59
|
+
- 压缩力度:省着压 / 默认 / 狠压三档一键设置字符上限与最小改写阈值,展开「高级数字」仍可逐项精调;
|
|
53
60
|
- 高级配置:预算、`minChars`/`minGain`、检索阈值、超预算处理(`spill`/`rerun`/`none`)与 `logEvery`,以及插件总开关;
|
|
54
|
-
-
|
|
61
|
+
- 散文变换(标点 / 词语)共用的三档范围(`off` / 仅散文输出 / 所有散文);
|
|
62
|
+
- 词语表(规则)编辑:每行「词 + 替换」(替换留空即删除);内置规则含「谢谢 / 请 / please / thanks」以及「啊 / 呀 / 吧 / 呢 / 嘛 / 哦」等语气词,语气词只在句尾或标点前删,「酒吧」「网吧」「毛呢」「哗啦」不会被拆;
|
|
63
|
+
- 对话内容编辑:改写最近消息,只在下次请求发给模型,历史不动,可恢复原内容;聊天里每条消息(当前这一轮)还有「改写」按钮,按原文匹配,**不需要宿主先认识这个会话**,重启后立刻可用;
|
|
64
|
+
- 自动变换记录:最近每次散文步骤的改动按 diff 展开,删掉的词红色划线、替换或新增的字绿色(同一行只显示变动附近的内容);
|
|
55
65
|
- 节省记录:本次进程与历史累计、移除的 token 与字符、节省比例、按工具明细表,以及消息/回复剥离计数;
|
|
56
66
|
- 选择被写入的配置目录,方便确认开关是否真的落盘。
|
|
57
67
|
|
|
@@ -59,15 +69,13 @@ dsh plugin --profile web add file:/path/to/dsh-oh-my-token
|
|
|
59
69
|
|
|
60
70
|
页面由三条精确路由支撑:`/dsh-oh-my-token/state`、`/dsh-oh-my-token/stats` 与 `/dsh-oh-my-token/prompt`(读取当前生效的系统提示词)。
|
|
61
71
|
|
|
62
|
-
##
|
|
72
|
+
## 完整提示词
|
|
63
73
|
|
|
64
|
-
|
|
74
|
+
「设置 → 省 Token」里的「完整提示词」卡片不是编辑器,是**只读查看**:点「获取提示词」,插件会在宿主真正组装系统提示词的那一刻抓一份当前结果返回,所以看到的就是下一次请求实际会发的内容——核心提示词、宿主上下文,以及**其他插件注入的段落**都在里面,顺序也一致。变量(如 `{{provider}}`、`{{model}}`)已替换成当前值;当前没有值的变量保持字面量,不会因此报错。
|
|
65
75
|
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
- `{{变量}}`:目前 DSH 内置 `{{provider}}`(当前模型供应商)与 `{{model}}`(当前模型名),保存后这两个写法会被替换成当前值;其他写法保持字面量,不报错。
|
|
70
|
-
- 「恢复默认提示词」:立即按当前注册实时组装一份系统提示词(首次使用、未发过消息也能读到),按空行**拆成多张卡片**放进编辑器,方便在原默认内容上重新改写;读到的始终是未注入定制文本的原始提示词。
|
|
76
|
+
- 「复制全文」把读到的内容放进剪贴板;
|
|
77
|
+
- 卡片标题右侧显示「N 段 · M 字符」,方便核对拼接结果;
|
|
78
|
+
- 插件不修改系统提示词,只读不写。
|
|
71
79
|
|
|
72
80
|
## 配置
|
|
73
81
|
|
|
@@ -86,8 +94,9 @@ dsh plugin --profile web add file:/path/to/dsh-oh-my-token
|
|
|
86
94
|
| `retrieval.readOutlineOverLines` | `400` | 仅当行数超过此值且调用未带 `offset`/`limit` 时才生成大纲。 |
|
|
87
95
|
| `retrieval.maxOutlineSymbols` | `60` | |
|
|
88
96
|
| `retrieval.maxGrepMatches` | `50` | |
|
|
89
|
-
| `prose.stripTrailingPeriod` | `true` |
|
|
90
|
-
| `prose.stripPoliteness` | `true` |
|
|
97
|
+
| `prose.stripTrailingPeriod` | `true` | 标点整理:段首标点删去;相邻两个标点只留一个(逗号+句号留句号,同强保留右边);再删句末**连续的** `.` / `。` / `,` / `,`(省略号除外)。 |
|
|
98
|
+
| `prose.stripPoliteness` | `true` | 按 `politenessWords` 词表删去或替换散文行里的词。 |
|
|
99
|
+
| `prose.politenessWords` | 内置规则 + 语气词 | 每项 `{ word, replace? }`:`replace` 留空或省略 = 删除,填字符串 = 替换。整表未配置时用内置规则:「谢谢 / 请 / please / thanks…」以及「啊 / 呀 / 吧 / 呢 / 嘛 / 哦…」等语气词(语气词只在句尾或标点前删,含护栏防拆词);配置空表 `[]` 则关闭词变换。 |
|
|
91
100
|
| `prose.scope` | `filtered` | `filtered` = 仅命令过滤器标记为散文的输出(如 `git log`);`all`;`off`。 |
|
|
92
101
|
| `recovery` | `spill` | `spill` \| `rerun` \| `none`。 |
|
|
93
102
|
| `logEvery` | `0` | 每 N 次改写打印一条节省日志;`0` 为静默。 |
|
|
@@ -99,7 +108,7 @@ dsh plugin --profile web add file:/path/to/dsh-oh-my-token
|
|
|
99
108
|
删掉文件名、URL、版本号或代码行里的句号,为了省一个 token 而损坏数据,代价太大。因此 `isProseLine` 会拒绝:
|
|
100
109
|
|
|
101
110
|
- 围栏代码、diff 行、以 `{ [ <` 开头或以 `;{}=` 结尾的行,以及带 `= ( ) ; { } [ ]` 等代码标点又以逗号结尾的行;
|
|
102
|
-
- 赋值/声明/语句行(含 `= ; { }` 或以 `const`/`function`/`import`
|
|
111
|
+
- 赋值/声明/语句行(含 `= ; { }` 或以 `const`/`function`/`import` 等开头),规则删除不会碰它们;
|
|
103
112
|
- 含 URL、邮箱、带扩展名路径的行;
|
|
104
113
|
- 看起来像版本号(`2.2.0`)或 `host:port` 的内容;
|
|
105
114
|
- 列表项(`- `、`*`)、省略号,以及 `e.g.` / `i.e.`。
|
|
@@ -117,6 +126,16 @@ oh-my-token map <file|dir> # read 会生成的大纲
|
|
|
117
126
|
oh-my-token lint [config.json] # 校验行配置,不启动 DSH
|
|
118
127
|
```
|
|
119
128
|
|
|
129
|
+
## 还能压什么
|
|
130
|
+
|
|
131
|
+
把「模型要据此决策的字节」逐个过一遍,结论如下:
|
|
132
|
+
|
|
133
|
+
- **命令输出**(收益最大):已有 5 个命令过滤器 + 17 种 RTK 结构压缩器,覆盖 pytest / git / tsc / 包管理器 / eslint / cargo / go test / grep / find / ls / tree 等。剩下的长尾命令(docker、kubectl、make…)按 RTK 的形状识别走 generic + smart-truncate,不再逐个写解析器——每加一个解析器都是一份要维护的回归测试。
|
|
134
|
+
- **读文件**:大 `read` 出符号大纲、大 `grep` 截断。再往下压(只给 AST、跳过 import 块)会把「模型能直接引用的文本」换成「模型要再问一次才能拿到的摘要」,省得不多还容易漏关键行,不做。
|
|
135
|
+
- **JSON / 图片**:JSON 数组折叠(同结构 N 份只留一份 + 计数)是下一步候选,但 `package-lock` 这类文件删一行就可能让模型拿错版本号,风险不对称,暂缓;图片字节不是文本,属于上游多模态编码的开销,插件层没有安全的压缩点。
|
|
136
|
+
- **对话文本**:本轮加了词删除/替换、标点整理、对话编辑。更激进的「语义摘要历史消息」需要额外一次 LLM 调用才能做,违背「不起外部进程」的约束,不做。
|
|
137
|
+
- **系统提示词**:只读不改。提示词里每一个词都是你写来约束模型的,插件不做自动裁剪,也不追加内容。
|
|
138
|
+
|
|
120
139
|
## 设计约束
|
|
121
140
|
|
|
122
141
|
- **工具结果只追加。** 替换发生在 `tools/post-execute`,因此被记录的就是替换后的内容。不用 `sessionProjections`、不做追溯修改、不会让前缀缓存失效。聊天文本与旧工具结果则有意不同:历史句号与旧工具结果的 RTK 压缩只在派生请求(`session.deriveMessages()`)中发生,从不写入持久化日志。
|
|
@@ -132,6 +151,28 @@ oh-my-token lint [config.json] # 校验行配置,不启动 DSH
|
|
|
132
151
|
- **符号图。** 大纲来自语言感知的正则。LSP 解析器更好,但那也是本插件拒绝引入的构建依赖。
|
|
133
152
|
- **输入框下方的小卡片。** 页面放在设置里——人找策略时会去那里;输入框下方的卡片会在每个屏幕重复同样的数字。
|
|
134
153
|
|
|
154
|
+
## 打赏支持
|
|
155
|
+
|
|
156
|
+
这个插件在 MIT 许可下完全开源,维护靠个人时间。如果你用起来觉得确实省了 token,欢迎请我喝杯咖啡:
|
|
157
|
+
|
|
158
|
+

|
|
159
|
+
|
|
160
|
+
不强制也不承诺什么——代码已经归你用了。
|
|
161
|
+
|
|
162
|
+
## 贡献者
|
|
163
|
+
|
|
164
|
+
名单按 GitHub 的实时数据渲染,不在仓库里写死:
|
|
165
|
+
|
|
166
|
+
<a href="https://github.com/dtyg123/dsh-oh-my-token/graphs/contributors">
|
|
167
|
+
<img src="https://contrib.rocks/image?repo=dtyg123/dsh-oh-my-token" alt="Contributors" />
|
|
168
|
+
</a>
|
|
169
|
+
|
|
170
|
+
## Star
|
|
171
|
+
|
|
172
|
+
[](https://star-history.com/#dtyg123/dsh-oh-my-token&Date)
|
|
173
|
+
|
|
174
|
+

|
|
175
|
+
|
|
135
176
|
## 致谢
|
|
136
177
|
|
|
137
178
|
- **[RTK](https://github.com/rtk-ai/rtk)(Apache-2.0)** — 按命令过滤工具输出的思路来自 RTK;本插件的命令过滤器与结构过滤器都是纯 JS 实现。
|
package/README_EN.md
CHANGED
|
@@ -13,7 +13,13 @@ It internalises two ideas rather than bundling two tools:
|
|
|
13
13
|
| Command- and structure-aware compaction | [RTK](https://github.com/rtk-ai/rtk) (Apache-2.0) | Parses the command the model already ran and keeps the verdict plus failure detail; when no command filter matched, compacts by output shape: git diff/status/log, build logs, grep/find/ls/tree, duplicate logs, numbered dumps and search lists. Pure JS, no binary. |
|
|
14
14
|
| Retrieve symbols, not files | [codegraph](https://github.com/isink17/codegraph) | Turns a large un-ranged `read` into a symbol outline and caps huge `grep` results. No SQLite graph, no MCP server. |
|
|
15
15
|
|
|
16
|
-
Plus two transformations the model never needs to read (independently switchable): on a line that is provably prose,
|
|
16
|
+
Plus two transformations the model never needs to read (independently switchable): on a line that is provably prose, a configurable word table deletes or replaces words (`谢谢`, `请`, `please`, `thanks`, … — delete by default, or swap one word for another), and punctuation is tidied: a mark opening a paragraph is dropped, two stuck-together marks collapse to one (a comma and a period keep the period; the same strength rule applies to the rest), and the run of **sentence-final** `.`, `。`, `,` and `,` marks is removed (an ASCII ellipsis is kept). They apply to tool output, your own typed messages, the assistant's replies, and past turns — the last of these is stripped while the request is assembled, so the model never sees those bytes while the stored session files stay byte-for-byte unchanged.
|
|
17
|
+
|
|
18
|
+
Plus two extras on the same derived path:
|
|
19
|
+
|
|
20
|
+
- **Conversation editing** — rewrite any recent message from the settings page. The rewrite is only carried in the next request; it is never written to the durable log, and "restore" puts the original back.
|
|
21
|
+
- **Red lines in the chat** — in your own messages and in the **body** of the model's replies, every word the plugin drops is drawn where it was: struck through in red, a replacement in green. Your messages use the harness's text-rule hook; a reply body is harness-rendered Markdown with no text hook, so the plugin puts the removed words back into the finished DOM (a re-render is decorated again).
|
|
22
|
+
- **Transform record** — the settings page expands each recent prose change as a diff: removed words struck through in red, replaced or new text in green, the way a changed file reads on GitHub. The record is written to the profile directory, so it survives a restart.
|
|
17
23
|
|
|
18
24
|
## What it keeps
|
|
19
25
|
|
|
@@ -25,7 +31,7 @@ Filtering is only allowed to drop text that carries no decision. Concretely:
|
|
|
25
31
|
- `tsc` → every `error TSxxxx` line and a total count; warnings drop.
|
|
26
32
|
- `npm/pnpm/yarn/bun/pip/uv/poetry` install → the summary line, or the error lines on failure.
|
|
27
33
|
- Any other command → ANSI, carriage-return repaints, repeated lines and progress bars only. The command string is never rewritten.
|
|
28
|
-
- When no command filter matched (or for old tool results in history), RTK structure compaction takes over by shape: git diff/status/log keep names, counts and hunk headers; build logs keep errors, warnings and the summary; grep/find/ls/tree/search-list group and count; duplicate log lines collapse; an unstructured blob keeps head and tail. It only ever shrinks.
|
|
34
|
+
- When no command filter matched (or for old tool results in history), RTK structure compaction takes over by shape: git diff/status/log keep names, counts and hunk headers; build logs keep errors, warnings and the summary; `cargo build/test` folds the Compiling/Checking progress and keeps `error[E…]`, `test result:` and Finished; `go test` collapses every `ok`/`?` package into one verdict line and, on failure, keeps the detail from the first FAIL; `eslint` compact output groups and counts by file; grep/find/ls/tree/search-list group and count; duplicate log lines collapse; an unstructured blob keeps head and tail. It only ever shrinks.
|
|
29
35
|
|
|
30
36
|
When a result is still over budget, the full text is saved through `ctx.spillStore` and the marker tells the model where it went. If no spill store is mounted, the marker says how to re-run or re-read instead — the plugin never elides text it cannot recover.
|
|
31
37
|
|
|
@@ -47,11 +53,15 @@ To change a budget, add the field under that row in the profile's `cordis.patch.
|
|
|
47
53
|
|
|
48
54
|
## Settings page
|
|
49
55
|
|
|
50
|
-
**Settings → 省 Token** is the management panel:
|
|
56
|
+
**Settings → 省 Token** is the management panel, split into **Overview / Compression / Prose / Chat / Prompt / About** tabs instead of one long page (About shows the plugin name, the version read from `package.json`, and a button that opens the GitHub repository):
|
|
51
57
|
|
|
52
|
-
- One switch per transform (5 command filters, RTK structure compaction, 2 retrieval transforms, the
|
|
58
|
+
- One switch per transform (5 command filters, RTK structure compaction, 2 retrieval transforms, the punctuation tidy);
|
|
59
|
+
- A plain-language compression-strength pick (gentle / default / aggressive) that sets the budgets and min-rewrite thresholds in one click, with the raw numbers still available under "advanced";
|
|
53
60
|
- Advanced: budgets, `minChars`/`minGain`, retrieval thresholds, over-budget recovery (`spill`/`rerun`/`none`), `logEvery`, and the plugin master switch;
|
|
54
|
-
- A three-way scope shared by the prose
|
|
61
|
+
- A three-way scope shared by the prose transforms (punctuation / words) (`off` / prose outputs only / all prose);
|
|
62
|
+
- The word table (rules) editor: one row per word with an optional replacement (empty = delete), saved as `prose.politenessWords`; the built-in rules cover politeness words and speech particles (啊 / 呀 / 吧 / 呢 / 嘛 / 哦…), and a particle is only dropped at the end of a phrase so 酒吧 / 网吧 / 毛呢 / 哗啦 stay intact;
|
|
63
|
+
- Conversation editing: rewrite recent messages; the rewrite only ships in the next request, never the durable log, and can be restored. Each message of the live turn also has a 改写 button in the chat; it matches on the message text, so it needs no session knowledge and works right after a restart;
|
|
64
|
+
- The transform record: each recent prose change shown as a diff, removed words struck through in red and new text in green;
|
|
55
65
|
- The savings record: this process and all time, tokens and characters removed, the saved share, a per-tool table, and a message/reply strip count;
|
|
56
66
|
- The profile directory the choice is written to, so you can see whether a switch actually persisted.
|
|
57
67
|
|
|
@@ -59,15 +69,13 @@ Changes apply on the next tool call — no restart. The choice is written to `ds
|
|
|
59
69
|
|
|
60
70
|
Three exact routes back the page: `/dsh-oh-my-token/state`, `/dsh-oh-my-token/stats`, and `/dsh-oh-my-token/prompt` (reads the currently effective system prompt).
|
|
61
71
|
|
|
62
|
-
##
|
|
72
|
+
## Full prompt
|
|
63
73
|
|
|
64
|
-
|
|
74
|
+
The 完整提示词 card in Settings → 省 Token is **read-only**, not an editor: press 获取提示词 and the plugin asks the host to assemble the system prompt right now, so what you see is exactly what the next request would carry — the core prompt, the host's context, and **sections other plugins injected**, in the same order. Variables such as `{{provider}}` and `{{model}}` are substituted with their current values; a variable with no value stays literal instead of failing the read.
|
|
65
75
|
|
|
66
|
-
-
|
|
67
|
-
- card
|
|
68
|
-
-
|
|
69
|
-
- `{{variables}}`: DSH currently ships `{{provider}}` (the active model provider) and `{{model}}` (the active model). Both are replaced with their current value on save; any other spelling stays literal without error.
|
|
70
|
-
- 「恢复默认提示词」live-assembles the currently effective system prompt — readable from the very first use, before any message is sent — and **splits it into cards** on the blank-line boundaries, so you can rewrite on top of the default. It always reads the original prompt without your injected text.
|
|
76
|
+
- 复制全文 copies the text to the clipboard;
|
|
77
|
+
- the card's header shows `N sections · M characters`, so a composed prompt can be checked at a glance;
|
|
78
|
+
- the plugin never edits the prompt — it only reads it.
|
|
71
79
|
|
|
72
80
|
## Configuration
|
|
73
81
|
|
|
@@ -86,8 +94,9 @@ At the bottom of Settings → 省 Token, the 系统提示词 card lets you enabl
|
|
|
86
94
|
| `retrieval.readOutlineOverLines` | `400` | Outline a `read` only above this line count, and only when the call had no `offset`/`limit`. |
|
|
87
95
|
| `retrieval.maxOutlineSymbols` | `60` | |
|
|
88
96
|
| `retrieval.maxGrepMatches` | `50` | |
|
|
89
|
-
| `prose.stripTrailingPeriod` | `true` |
|
|
90
|
-
| `prose.stripPoliteness` | `true` |
|
|
97
|
+
| `prose.stripTrailingPeriod` | `true` | Tidy punctuation: drop a mark opening a paragraph; collapse two stuck-together marks to one (a comma and a period keep the period, same-strength keeps the right one); then drop the run of trailing `.` / `。` / `,` / `,` (an ASCII ellipsis is kept). |
|
|
98
|
+
| `prose.stripPoliteness` | `true` | Delete or replace words on prose lines via the `politenessWords` table. |
|
|
99
|
+
| `prose.politenessWords` | built-in rules + particles | Each entry is `{ word, replace? }`: empty/omitted `replace` deletes the word, a string replaces it. Unset = the built-in rules (谢谢 / 请 / please / thanks, … plus particles 啊 / 呀 / 吧 / 呢 / 嘛 / 哦, …, deleted only at a phrase end and guarded against splitting 酒吧 / 网吧 / 毛呢 / 哗啦); an explicit empty list turns the word step off. |
|
|
91
100
|
| `prose.scope` | `filtered` | `filtered` = only output a command filter marked as prose (e.g. `git log`); `all`; `off`. |
|
|
92
101
|
| `recovery` | `spill` | `spill` \| `rerun` \| `none`. |
|
|
93
102
|
| `logEvery` | `0` | Log a savings line every N rewritten results; `0` is quiet. |
|
|
@@ -117,6 +126,16 @@ oh-my-token map <file|dir> # the outline `read` would produce
|
|
|
117
126
|
oh-my-token lint [config.json] # validate a row config without starting DSH
|
|
118
127
|
```
|
|
119
128
|
|
|
129
|
+
## Where else it could compress
|
|
130
|
+
|
|
131
|
+
Walked through "every byte the model could act on" once more:
|
|
132
|
+
|
|
133
|
+
- **Command output** (the big one): 5 command filters + 17 RTK structural compactors already cover pytest / git / tsc / package managers / eslint / cargo / go test / grep / find / ls / tree. The long tail (docker, kubectl, make…) runs through shape detection + generic cleanup + smart-truncation instead of one more hand-written parser — every parser is a regression-test surface to maintain.
|
|
134
|
+
- **File reads**: large `read` gets a symbol outline, large `grep` gets capped. Going further (AST-only, skip import blocks) would trade "text the model can quote" for "a summary the model has to ask for again", with a real chance of dropping the one line that matters. Not worth it.
|
|
135
|
+
- **JSON / images**: collapsing repeated JSON objects is the next candidate, but for a lockfile one deleted line can send the model after the wrong version — asymmetric risk, deferred. Image bytes are not text; that cost lives in the upstream multimodal encoder, where no plugin-side compression is safe.
|
|
136
|
+
- **Conversation text**: covered by the word table, punctuation tidy and the conversation editor. Anything more aggressive (summarising history) needs another LLM call, which breaks the no-helper-process constraint.
|
|
137
|
+
- **System prompt**: read-only. Every word in a prompt is a constraint the user chose, so the plugin never trims it and never appends to it.
|
|
138
|
+
|
|
120
139
|
## Design constraints
|
|
121
140
|
|
|
122
141
|
- **Append-only tool results.** The replacement is produced in `tools/post-execute`, so it is what gets logged. No `sessionProjections`, no retroactive edits, no prefix cache invalidation. Chat text and old tool results are different by design: historical periods and RTK compaction of old tool results happen only in the derived request (`session.deriveMessages()`), never in the durable session log.
|
|
@@ -132,6 +151,28 @@ oh-my-token lint [config.json] # validate a row config without starting DSH
|
|
|
132
151
|
- **A symbol graph.** Outlines come from language-aware regexes. An LSP-backed resolver would be better; it is also a build dependency this plugin refuses to take.
|
|
133
152
|
- **A composer-dock chip.** The page is under Settings, where a person looks for a policy; a chip below the composer would repeat the same numbers on every screen.
|
|
134
153
|
|
|
154
|
+
## Sponsor
|
|
155
|
+
|
|
156
|
+
This plugin is fully open-source under the MIT licence and maintained on personal time. If it saves you enough tokens to feel worth a coffee, you can support me here:
|
|
157
|
+
|
|
158
|
+

|
|
159
|
+
|
|
160
|
+
Not required, not expected, and it doesn't buy any promises — the code is already yours.
|
|
161
|
+
|
|
162
|
+
## Contributors
|
|
163
|
+
|
|
164
|
+
Rendered from GitHub's live data — nothing is hard-coded in the repository:
|
|
165
|
+
|
|
166
|
+
<a href="https://github.com/dtyg123/dsh-oh-my-token/graphs/contributors">
|
|
167
|
+
<img src="https://contrib.rocks/image?repo=dtyg123/dsh-oh-my-token" alt="Contributors" />
|
|
168
|
+
</a>
|
|
169
|
+
|
|
170
|
+
## Stars
|
|
171
|
+
|
|
172
|
+
[](https://star-history.com/#dtyg123/dsh-oh-my-token&Date)
|
|
173
|
+
|
|
174
|
+

|
|
175
|
+
|
|
135
176
|
## Acknowledgements
|
|
136
177
|
|
|
137
178
|
- **[RTK](https://github.com/rtk-ai/rtk) (Apache-2.0)** — the per-command output-filtering idea comes from RTK; this plugin implements both the command filters and the structural filters in pure JS.
|