GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing atomgit.com — openeuler/witty-token-compressor - AtomGit

A capability enhancement component for openEuler agent runtime focusing on token cost governance. Built‑in 10+ local token compression algorithms, supports CLI and multi‑sdk/runtime(witty-cli、xiaoO、opencode...) integration.

Branch2Tags0

Access rate limit exceeded. Please log in to continue.

witty-token-compressor

面向 openEuler 智能体运行时的能力增强组件,聚焦 token 成本治理。内置 10+ 种本地 token 压缩算法,支持 CLI 与多 SDK/运行时(witty-cli、xiaoO、opencode 等)集成。

配套的 token 压缩效果评测工具 sweval(SWE-bench 双轮对照评测)见 tests/sweval/README.md。

核心库算法组

  1. Schema 工具定义压缩;
  2. RTK 命令重写降噪;
  3. 工具返回 Json 压缩;
  4. TOON ;
  5. 剥离终端颜色码;
  6. 折叠连续重复行;
  7. 折叠路径清单;
  8. 剥离 git diff 的 index 行;
  9. ...

新增算法接入流程

以 token-compressor-text(无损折叠)为例,新算法按五步接入:

  1. 实现算法 crate:新建 crates/<算法名>,须满足安全范式——可逆算法通过逐字节 round-trip 自校验、候选更小才采纳、永不截断。
  2. CLI 子命令:在 token-compressor-cli 新增 clap 子命令,用 ValueEnum 映射算法枚举,避免算法 crate 依赖 clap。
  3. stats 落盘:在 token-compressor-stats 的 OperationType 新增变体(enum / as_str / FromStr 三处同步),stats summary 自动分组渲染。
  4. 配置开关:在 stats/config.rs 新增配置节,接入既有开关链——总开关 TOKEN_COMPRESSOR_COMPRESSION_ENABLED → 算法专属环境变量 → config.toml → 默认值;同步 config get/set/list 白名单。
  5. 构建与测试:workspace members 与 justfile test recipe 注册新 crate,cargo test 全绿后合入;合规上,纯自研文件添加三行版权头,移植代码不加头并在 NOTICE 声明上游。

已接入的效果演示

以无损折叠(fold-compress)为例,每组输入相同,一条原样、一条压缩,可直接运行对比。

剥离终端颜色码(--algorithm ansi)

ls --color=always /usr/bin | head -6 | cat -A    # 原样:含 ^[[01;32m 等转义码
ls --color=always /usr/bin | head -6 | token-compressor fold-compress --algorithm ansi

仅剥离 SGR 颜色码(\x1b[…m),颜色对模型无语义,实测样例节省 44%。

折叠连续重复行(--algorithm runs)

{ for i in $(seq 1 8); do echo "connection lost, retrying"; done; echo "connection restored"; }
{ for i in $(seq 1 8); do echo "connection lost, retrying"; done; echo "connection restored"; } | token-compressor fold-compress --algorithm runs

9 行折叠为 3 行,可逆:

connection lost, retrying
... (repeated 8 times)
connection restored

折叠路径清单(--algorithm paths)

find crates -name '*.rs' | head -40    # 原样:全路径
find crates -name '*.rs' | head -40 | token-compressor fold-compress --algorithm paths

折叠为目录头 + basename 形式,实测 4650 → 2244 字符(-52%),可逆;浅短路径清单因收益不足按"更小才采纳"守卫原样返回。

剥离 git diff 的 index 行(--algorithm diff)

git diff | token-compressor fold-compress --algorithm diff

删除 index <sha>..<sha> [mode] 行,hunk 完整保留、仍可 apply,实测 -28%。

统计与开关

token-compressor stats summary               # 各算法节省率自动落盘(compress-fold-*)
token-compressor config list | grep fold     # fold.enabled 开关(默认开启)

来源与许可证

本仓库以 MIT License 发布。第三方与衍生代码的归属见 NOTICE。NOTICE 只记录来源和版权,不改变许可证条款。

开源衍生 - Fork from:

  • https://github.com/agentic-os-org/ANOLISA/tree/main/src/tokenless
  • https://github.com/headroomlabs-ai/headroom

Introduction

A capability enhancement component for openEuler agent runtime focusing on token cost governance. Built‑in 10+ local token compression algorithms, supports CLI and multi‑sdk/runtime(witty-cli、xiaoO、opencode...) integration.

MIT Python11Commits
sqlite
Customize your domain
README
Rulesets
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.