smartcompact 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. package/README.md +59 -59
  2. package/README.zh-CN.md +109 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,61 +1,54 @@
1
1
  # SmartCompact
2
2
 
3
- **English summary.** SmartCompact makes long coding-agent sessions compact *earlier, at the right moment* — once the context is past a threshold (200k tokens by default) and a piece of work has just been finished, typically a commit. Every request re-reads the whole context, so keeping it smaller saves money; picking the moment right after a commit avoids interrupting work. It never compacts in the middle of a task by itself. It works with Claude Code (CLI and desktop app), [pi](https://github.com/earendil-works/pi) and the Codex CLI. In controlled A/B runs (18–30 consecutive coding tasks, 3 runs per arm) it cut cost by 7–22% with no loss in hidden acceptance tests or recall questions. Details: [docs/TEST-REPORT.md](docs/TEST-REPORT.md) (Chinese).
3
+ **English** · [中文](https://github.com/coffeecoproject/SmartCompact/blob/main/README.zh-CN.md)
4
4
 
5
- ---
5
+ [![npm](https://img.shields.io/npm/v/smartcompact)](https://www.npmjs.com/package/smartcompact)
6
+ [![GitHub stars](https://img.shields.io/github/stars/coffeecoproject/SmartCompact?style=social)](https://github.com/coffeecoproject/SmartCompact/stargazers)
7
+ [![License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/coffeecoproject/SmartCompact/blob/main/LICENSE)
6
8
 
7
- 让长会话早点、挑对时机压缩:降低成本,同时不损失结果。
9
+ **SmartCompact lets long coding-agent sessions compact earlier, right after a piece of work is finished.** On 18–60 consecutive coding tasks it cut cost by **7–44%** with no loss in hidden acceptance tests; the longer the session, the more it saves. In the longest runs (60 tasks, native sessions reaching 820k–960k tokens) the model missed 6 of 180 recall questions about details mentioned in passing much earlier ([test report](https://github.com/coffeecoproject/SmartCompact/blob/main/docs/TEST-REPORT.md), in Chinese).
8
10
 
9
- ## 为什么
11
+ Every request re-reads the whole context, so a long context makes every step expensive. Native auto-compaction waits until the context is nearly full (close to 1M tokens in Claude Code, up to 800k in Codex if configured), and it ignores timing, so it often lands in the middle of a task. SmartCompact works with Claude Code (CLI and desktop app), [Pi](https://github.com/earendil-works/pi) and the Codex CLI:
10
12
 
11
- agent 每发一次请求,都要把整段上下文重新读一遍。上下文越长,每一步越贵。原生的自动压缩通常要等到快满了才触发(Claude Code 接近 100 万,Codex 可以配到 80 万),在那之前每一步都在为很长的上下文付钱;而且原生压缩不看时机,常常发生在一件事做到一半的时候。
13
+ - **Compact at the right moment.** Once the context passes the **allow line** (200k tokens by default), it waits for a piece of work to finish: a commit, tests passing, a task completed.
14
+ - **Never in the middle of work.** It does not compact on its own mid-task, nor while tests or the build are failing, errors keep repeating, or a background job is running.
15
+ - **A fallback.** If no good moment comes and the context passes the **grace line** (allow line × 1.3), it compacts at the end of a turn.
16
+ - **A progress ledger bridges the gap.** Files changed, the latest commit and test result, and decisions the agent recorded are handed back to the model after compaction.
17
+ - **No pointless compactions.** It skips compaction when it would not free enough space.
12
18
 
13
- SmartCompact 的做法:
19
+ ## Results
14
20
 
15
- - 上下文超过**允许压缩线**(默认 20 万)以后,等到**刚做完一件事**(一次提交、测试刚通过、任务完成)再压缩。
16
- - 不在一件事做到一半时主动压缩;测试失败、构建失败、连续报错或后台任务还在跑时也不压缩。
17
- - 一直等不到合适时机、上下文超过**宽限线**(允许压缩线 × 1.3)时,在一轮结束时压缩,作为兜底。
18
- - 压缩前后用一份**进度笔记**接上:改过的文件、最近的提交和测试结果、记下的决定,压缩后补回给模型。
19
- - 预计腾不出足够空间时不压缩,避免刚压缩完又压缩。
21
+ The same codebase and 18–30 consecutive development tasks, where later tasks change the results of earlier ones; each platform run 3 times with and 3 times without SmartCompact. Acceptance is graded by hidden tests the model never sees; after each round the model answers recall questions, including details mentioned in passing much earlier.
20
22
 
21
- ## 效果
22
-
23
- 同一个代码库、连续 18~30 个开发任务(后面的任务会修改前面任务的结果),每个平台装与不装各跑 3 次。验收由脚本跑模型看不到的隐藏测试;每轮结束问几道记忆题,包括很早之前随口提到的细节。
24
-
25
- | 平台(模型) | 原生压缩点 | 成本 | 任务验收 | 记忆题 |
23
+ | Platform (model) | Native compaction | Cost | Tasks accepted | Recall |
26
24
  |---|---|---|---|---|
27
- | Codex(gpt-6-astra) | 80 万 | **−19%** | 两组都 18/18 | 两组都 54/54 |
28
- | pi(gpt-5.5) | 约 25.6 万 | −11%~−22% | 两组都 18/18 | 原生 51/54,插件 53/54 |
29
- | Claude Code(Haiku 5.5,30 题) | 接近 100 万 | −7%(波动较大) | 两组都 30/30 | 两组都 90/90 |
30
-
31
- 成本按各家价格比例折算成"缓存读取 token 当量"。规律:原生压缩得越晚、会话涨得越快,省得越多;会话没超过 20 万时插件不起作用,也没有坏处。完整方法、数据、代价和局限见 [docs/TEST-REPORT.md](docs/TEST-REPORT.md)。
25
+ | Codex (gpt-6-astra) | 800k | **−19%** | 18/18 both | 54/54 both |
26
+ | Pi (gpt-5.5) | about 256k | −11% to −22% | 18/18 both | native 51/54, SmartCompact 53/54 |
27
+ | Claude Code (Haiku 5.5, 30 tasks) | close to 1M | −7% (noisy) | 30/30 both | 90/90 both |
28
+ | Claude Code (Haiku 5.5, 60 tasks) | close to 1M | **−44%** | native 59–60/60, SmartCompact 60/60 | native 180/180, SmartCompact 174/180 |
32
29
 
33
- ## 安装
30
+ Cost is converted to cached-input-token equivalents using each provider's price ratios. The later native compaction kicks in and the faster a session grows, the more it saves. Below 200k SmartCompact does nothing, so it costs nothing either. After a compaction the model spends extra requests getting familiar with the code again; that is included in the cost above. These are small samples on one codebase and one kind of task; the [report](https://github.com/coffeecoproject/SmartCompact/blob/main/docs/TEST-REPORT.md) has the method, the data and the limitations.
34
31
 
35
- ### Claude Code(终端和桌面 App)
32
+ ## Install
36
33
 
37
- 需要 Claude Code ≥ 2.1.295。
34
+ **Claude Code** (2.1.295 or later)
38
35
 
39
36
  ```
40
37
  /plugin marketplace add coffeecoproject/SmartCompact
41
38
  /plugin install smartcompact@smartcompact
42
39
  ```
43
40
 
44
- 装好后新开会话生效。插件会把原生自动压缩线调到宽限线附近,`/smartcompact pause` 可以让当前会话恢复原生行为。
41
+ It takes effect in new sessions. The plugin moves the native auto-compaction to about the grace line; `/smartcompact pause` returns the current session to native behavior.
45
42
 
46
- ### pi
43
+ **Pi**
47
44
 
48
- ```bash
45
+ ```
49
46
  pi install npm:smartcompact
50
47
  ```
51
48
 
52
- 也可以从 GitHub 装:`pi install git:github.com/coffeecoproject/SmartCompact`。
53
-
54
- pi 默认配置下,插件在一轮结束(`agent_settled`)时挑阶段节点主动压缩。如果你把 `reserveTokens` 调大、让 pi 的原生压缩提前,插件会在那个点按工作状态决定是否推迟。
49
+ With Pi's default settings, SmartCompact compacts at a finished piece of work when a turn ends (`agent_settled`). If you raise `reserveTokens` so that Pi's native compaction comes earlier, SmartCompact decides at that point whether to postpone it, based on the state of the work.
55
50
 
56
- ### Codex 命令行
57
-
58
- 需要 Node ≥ 22.18(直接运行 TypeScript)和 Codex CLI ≥ 0.162。
51
+ **Codex CLI** (0.162 or later, Node.js 22.18 or later)
59
52
 
60
53
  ```bash
61
54
  git clone https://github.com/coffeecoproject/SmartCompact.git
@@ -63,47 +56,54 @@ cd SmartCompact
63
56
  node scripts/codex.ts install
64
57
  ```
65
58
 
66
- 安装脚本只在 `~/.codex/config.toml`(或 `$CODEX_HOME/config.toml`)末尾写入一段带标记的 hook 配置,改之前备份原文件;`node scripts/codex.ts uninstall` 移除。下次启动 Codex 时按提示信任这 4 个 hook。升级 Node 或移动仓库后重新运行一次 install。
59
+ The script only appends one marked block of hooks to `~/.codex/config.toml` (or `$CODEX_HOME/config.toml`), backing up the file first. Trust the 4 hooks when Codex asks on its next start. Run install again after upgrading Node or moving the repository.
67
60
 
68
- Codex 的 hook 不能推迟一轮中间的压缩,所以插件在一轮结束时判断,需要压缩就通过 Codex 的共享后台服务(交互界面默认会用它)在会话空闲时发起。`codex exec` 和 Codex App(ChatGPT.app)默认不走共享后台服务,这时插件只补回进度笔记,压缩仍按 Codex 原生规则。
61
+ Codex hooks cannot postpone a compaction in the middle of a turn, so SmartCompact decides when a turn ends and, if it should compact, starts the compaction through Codex's shared background server once the session is idle (the interactive UI uses it by default). `codex exec` does not use the shared server by default, and the Codex App (ChatGPT.app) currently cannot; there SmartCompact only hands back the progress ledger, and compaction follows Codex's native rules. For a fallback there, add Codex's own `model_post_turn_compact_threshold_percent` at the top of `config.toml`: it compacts after a turn ends once the context passes that percentage of the usable window (31 is about 260k for an 872k window; see the test report).
69
62
 
70
- ## 参数
63
+ ## Settings
71
64
 
72
- | 参数 | 默认 | 含义 |
65
+ | Setting | Default | Meaning |
73
66
  |---|---|---|
74
- | 允许压缩线 | 200000 | 超过它且刚做完一件事时压缩 |
75
- | 宽限倍数 | 1.3 | 超过 允许压缩线 × 倍数 时不再等阶段节点 |
76
- | 最少腾出空间 | 60000 | 预计腾出的空间少于它时不压缩 |
67
+ | Allow line | 200000 | Above it, compact right after a piece of work is finished |
68
+ | Grace factor | 1.3 | Above allow line × factor, stop waiting for a finished piece of work |
69
+ | Minimum freed | 60000 | Skip compaction if it is expected to free less than this |
70
+
71
+ - Claude Code: the plugin options `allowLineTokens`, `graceFactor` and `minFreedTokens`; leave them empty for the defaults.
72
+ - Pi: the flags `--smartcompact-allow-line`, `--smartcompact-grace` and `--smartcompact-min-freed`.
73
+ - Codex: the environment variables `SMARTCOMPACT_ALLOW_LINE`, `SMARTCOMPACT_GRACE` and `SMARTCOMPACT_MIN_FREED`.
74
+
75
+ ## Seeing what it did
76
+
77
+ - Claude Code and Pi: `/smartcompact` (or `/smartcompact report`) shows the three lines, the finished-work signals it saw and a cost estimate; `/smartcompact pause` and `resume` turn it off and on for the session. The model can also call a `checkpoint` tool to record decisions, which come back with the ledger after compaction.
78
+ - Codex: `node adapters/codex/report.ts <session ID>`; records are kept in `~/.codex/smartcompact/`.
79
+
80
+ ## FAQ
77
81
 
78
- - Claude Code:安装插件时的配置项(`allowLineTokens`、`graceFactor`、`minFreedTokens`),留空用默认值。
79
- - pi:命令行开关 `--smartcompact-allow-line`、`--smartcompact-grace`、`--smartcompact-min-freed`。
80
- - Codex:环境变量 `SMARTCOMPACT_ALLOW_LINE`、`SMARTCOMPACT_GRACE`、`SMARTCOMPACT_MIN_FREED`。
82
+ **How does it know a piece of work is finished?** From the commands the agent runs. A commit counts if `git commit` actually ran and the tool call did not fail. A test command piped into something else (`| tail`) without `pipefail` does not count, since its exit code cannot be trusted.
81
83
 
82
- ## 查看效果
84
+ **Will the model forget things after compaction?** Sometimes, for details mentioned in passing. The ledger only records files, commits, tests and decisions the model chose to record. Details the user mentions in passing are kept by asking the compaction summary to keep every specific fact the user stated. On Pi this clearly reduced losses, but it is not a guarantee.
83
85
 
84
- - Claude Code 和 pi:`/smartcompact`(或 `/smartcompact report`)查看三条线、阶段节点计数和成本估算;`/smartcompact pause` / `resume` 暂停或恢复。Claude Code 和 pi 里模型还可以调用 checkpoint 工具记下决定,压缩后一起补回。
85
- - Codex:`node adapters/codex/report.ts <会话 ID>`,记录在 `~/.codex/smartcompact/`。
86
+ **Anything specific to Claude Code?** SmartCompact's fallback point is close to the native compaction point it moves. If it cannot recognize a finished piece of work for a long time, native compaction may still fire mid-turn. SmartCompact moves the native compaction point by setting `CLAUDE_CODE_AUTO_COMPACT_WINDOW` in the session, and processes started from that session inherit it: a `claude -p` or script the agent runs will compact at about 260k as well. Unset the variable for such processes if that matters.
86
87
 
87
- ## 局限
88
+ **How do I remove it?**
88
89
 
89
- - 判断"刚做完一件事"靠识别命令:提交只要真的执行了 `git commit` 且没报错就算;测试命令接了管道(`| tail`)又没开 `pipefail` 时退出码不可信,不算测试结果。
90
- - 进度笔记只记文件、提交、测试和模型主动记下的决定。用户在对话里随口交代的细节靠压缩时的说明要求摘要保留,pi 上能明显减少丢失,但不能保证不丢。
91
- - Claude Code 上,插件的兜底压缩点和它调整后的原生压缩点接近;长时间认不出阶段节点时,可能由原生压缩在一轮中间触发。
92
- - 评测只用了一个代码库和一种任务类型,Claude 只测了 Haiku。
90
+ - Claude Code: `/plugin uninstall smartcompact@smartcompact`.
91
+ - Pi: `pi remove npm:smartcompact`.
92
+ - Codex: `node scripts/codex.ts uninstall` in the repository.
93
93
 
94
- ## 开发
94
+ ## Development
95
95
 
96
96
  ```bash
97
97
  sh scripts/check.sh
98
98
  ```
99
99
 
100
- 结构校验、core 依赖边界检查和全部测试。目录:
100
+ This runs the structure checks, the core dependency boundary check and all tests. Layout:
101
101
 
102
- - `plugin/`:Claude Code 插件;`plugin/src/core/` 是和平台无关的决策、信号、进度笔记和成本估算,其他适配都复用它。
103
- - `adapters/pi/`、`adapters/codex/`:pi 和 Codex 的适配。
104
- - `eval/`:对照评测脚本(Claude、pi、Codex 各一个),任务格式见 `eval/day.py`;评测用的题目和隐藏测试涉及内部项目,没有放进仓库。
105
- - `DESIGN.md`:设计说明;`docs/TEST-REPORT.md`:测试报告。
102
+ - `plugin/`: the Claude Code plugin. `plugin/src/core/` holds the platform-independent decisions, signals, ledger and cost estimate that every adapter reuses.
103
+ - `adapters/pi/`, `adapters/codex/`: the Pi and Codex adapters.
104
+ - `eval/`: the A/B evaluation scripts (one each for Claude, Pi and Codex); the task format is described in `eval/day.py`. The tasks and hidden tests come from an internal project and are not published.
105
+ - `DESIGN.md`: design notes; `docs/TEST-REPORT.md`: the test report (both in Chinese).
106
106
 
107
- ## 许可证
107
+ ## License
108
108
 
109
- [MIT](LICENSE)
109
+ MIT. See [LICENSE](https://github.com/coffeecoproject/SmartCompact/blob/main/LICENSE).
@@ -0,0 +1,109 @@
1
+ # SmartCompact
2
+
3
+ [English](https://github.com/coffeecoproject/SmartCompact/blob/main/README.md) · **中文**
4
+
5
+ [![npm](https://img.shields.io/npm/v/smartcompact)](https://www.npmjs.com/package/smartcompact)
6
+ [![GitHub stars](https://img.shields.io/github/stars/coffeecoproject/SmartCompact?style=social)](https://github.com/coffeecoproject/SmartCompact/stargazers)
7
+ [![License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/coffeecoproject/SmartCompact/blob/main/LICENSE)
8
+
9
+ **SmartCompact 让编程 agent 的长会话早点压缩,挑在刚做完一件事的时候。** 在 18~60 个连续开发任务上,成本降低 **7%~44%**,隐藏验收测试没有损失,会话越长省得越多。最长的一组(60 个任务,原生组上下文到 82 万~96 万)里,很早之前随口提到的细节,180 道记忆题少答对 6 道([测试报告](https://github.com/coffeecoproject/SmartCompact/blob/main/docs/TEST-REPORT.md))。
10
+
11
+ agent 每发一次请求,都要把整段上下文重新读一遍,上下文越长,每一步越贵。原生的自动压缩要等到快满了才触发(Claude Code 接近 100 万,Codex 可以配到 80 万),而且不看时机,常常发生在一件事做到一半的时候。SmartCompact 支持 Claude Code(终端和桌面 App)、[Pi](https://github.com/earendil-works/pi) 和 Codex 命令行:
12
+
13
+ - **挑对时机压缩。** 上下文超过**允许压缩线**(默认 20 万)以后,等到刚做完一件事(一次提交、测试刚通过、任务完成)再压缩。
14
+ - **不在做到一半时压缩。** 不在一件事做到一半时主动压缩;测试失败、构建失败、连续报错或后台任务还在跑时也不压缩。
15
+ - **有兜底。** 一直等不到合适时机、上下文超过**宽限线**(允许压缩线 × 1.3)时,在一轮结束时压缩。
16
+ - **用进度笔记接上。** 改过的文件、最近的提交和测试结果、记下的决定,压缩后补回给模型。
17
+ - **不做白费的压缩。** 预计腾不出足够空间时不压缩,避免刚压缩完又压缩。
18
+
19
+ ## 实验结果
20
+
21
+ 同一个代码库、连续 18~30 个开发任务(后面的任务会修改前面任务的结果),每个平台装与不装各跑 3 次。验收由脚本跑模型看不到的隐藏测试;每轮结束问几道记忆题,包括很早之前随口提到的细节。
22
+
23
+ | 平台(模型) | 原生压缩点 | 成本 | 任务验收 | 记忆题 |
24
+ |---|---|---|---|---|
25
+ | Codex(gpt-6-astra) | 80 万 | **−19%** | 两组都 18/18 | 两组都 54/54 |
26
+ | Pi(gpt-5.5) | 约 25.6 万 | −11%~−22% | 两组都 18/18 | 原生 51/54,插件 53/54 |
27
+ | Claude Code(Haiku 5.5,30 个任务) | 接近 100 万 | −7%(波动较大) | 两组都 30/30 | 两组都 90/90 |
28
+ | Claude Code(Haiku 5.5,60 个任务) | 接近 100 万 | **−44%** | 原生 59~60/60,插件 60/60 | 原生 180/180,插件 174/180 |
29
+
30
+ 成本按各家价格比例折算成"缓存读取 token 当量"。原生压缩得越晚、会话涨得越快,省得越多;会话没超过 20 万时插件不起作用,也没有额外开销。压缩后模型要多花一些请求重新熟悉代码,这部分已计入上面的成本。样本小,只用了一个代码库和一种任务类型;方法、数据和局限见[测试报告](https://github.com/coffeecoproject/SmartCompact/blob/main/docs/TEST-REPORT.md)。
31
+
32
+ ## 安装
33
+
34
+ **Claude Code**(2.1.295 及以上)
35
+
36
+ ```
37
+ /plugin marketplace add coffeecoproject/SmartCompact
38
+ /plugin install smartcompact@smartcompact
39
+ ```
40
+
41
+ 装好后新开会话生效。插件会把原生自动压缩线调到宽限线附近,`/smartcompact pause` 可以让当前会话恢复原生行为。
42
+
43
+ **Pi**
44
+
45
+ ```
46
+ pi install npm:smartcompact
47
+ ```
48
+
49
+ Pi 默认配置下,插件在一轮结束(`agent_settled`)时挑刚做完一件事的时机压缩。如果你把 `reserveTokens` 调大、让 Pi 的原生压缩提前,插件会在那个点按工作状态决定是否推迟。
50
+
51
+ **Codex 命令行**(0.162 及以上,Node.js 22.18 及以上)
52
+
53
+ ```bash
54
+ git clone https://github.com/coffeecoproject/SmartCompact.git
55
+ cd SmartCompact
56
+ node scripts/codex.ts install
57
+ ```
58
+
59
+ 安装脚本只在 `~/.codex/config.toml`(或 `$CODEX_HOME/config.toml`)末尾写入一段带标记的 hook 配置,改之前备份原文件。下次启动 Codex 时按提示信任这 4 个 hook。升级 Node 或移动仓库后重新运行一次 install。
60
+
61
+ Codex 的 hook 不能推迟一轮中间的压缩,所以插件在一轮结束时判断,需要压缩就通过 Codex 的共享后台服务(交互界面默认会用它)在会话空闲时发起。`codex exec` 默认不走共享后台服务,Codex App(ChatGPT.app)目前走不了,这时插件只补回进度笔记,压缩仍按 Codex 原生规则。想给它们也加个兜底,可以在 `config.toml` 顶部加上 Codex 自带的 `model_post_turn_compact_threshold_percent`:上下文超过可用窗口的这个百分比时,在一轮结束后压缩(窗口 87.2 万时设 31,约 26 万;详见测试报告)。
62
+
63
+ ## 参数
64
+
65
+ | 参数 | 默认 | 含义 |
66
+ |---|---|---|
67
+ | 允许压缩线 | 200000 | 超过它且刚做完一件事时压缩 |
68
+ | 宽限倍数 | 1.3 | 超过 允许压缩线 × 倍数 时不再等刚做完一件事 |
69
+ | 最少腾出空间 | 60000 | 预计腾出的空间少于它时不压缩 |
70
+
71
+ - Claude Code:插件配置项 `allowLineTokens`、`graceFactor`、`minFreedTokens`,留空用默认值。
72
+ - Pi:命令行开关 `--smartcompact-allow-line`、`--smartcompact-grace`、`--smartcompact-min-freed`。
73
+ - Codex:环境变量 `SMARTCOMPACT_ALLOW_LINE`、`SMARTCOMPACT_GRACE`、`SMARTCOMPACT_MIN_FREED`。
74
+
75
+ ## 查看效果
76
+
77
+ - Claude Code 和 Pi:`/smartcompact`(或 `/smartcompact report`)查看三条线、识别到的阶段节点和成本估算;`/smartcompact pause` / `resume` 暂停或恢复当前会话。模型还可以调用 `checkpoint` 工具记下决定,压缩后和进度笔记一起补回。
78
+ - Codex:`node adapters/codex/report.ts <会话 ID>`,记录在 `~/.codex/smartcompact/`。
79
+
80
+ ## 常见问题
81
+
82
+ **怎么判断"刚做完一件事"?** 靠识别 agent 执行的命令。提交只要真的执行了 `git commit` 且工具调用没报错就算;测试命令接了管道(`| tail`)又没开 `pipefail` 时退出码不可信,不算测试结果。
83
+
84
+ **压缩后模型会不会忘事?** 随口提到的细节有时会丢。进度笔记只记文件、提交、测试和模型主动记下的决定。用户在对话里随口交代的细节,靠压缩时要求摘要原样保留用户说过的具体信息。Pi 上这样做明显减少了丢失,但不能保证不丢。
85
+
86
+ **Claude Code 上有什么要注意的?** 插件的兜底压缩点和它调整后的原生压缩点接近;长时间认不出刚做完一件事时,原生压缩仍可能在一轮中间触发。插件是通过在会话里设置 `CLAUDE_CODE_AUTO_COMPACT_WINDOW` 来调整原生压缩点的,从这个会话里启动的进程会继承它:agent 运行的 `claude -p` 或脚本里启动的 Claude,也会在 26 万左右压缩。需要的话,启动这类进程前去掉这个变量。
87
+
88
+ **怎么卸载?**
89
+
90
+ - Claude Code:`/plugin uninstall smartcompact@smartcompact`。
91
+ - Pi:`pi remove npm:smartcompact`。
92
+ - Codex:在仓库目录里运行 `node scripts/codex.ts uninstall`。
93
+
94
+ ## 开发
95
+
96
+ ```bash
97
+ sh scripts/check.sh
98
+ ```
99
+
100
+ 运行结构校验、core 依赖边界检查和全部测试。目录:
101
+
102
+ - `plugin/`:Claude Code 插件;`plugin/src/core/` 是和平台无关的决策、信号、进度笔记和成本估算,其他适配都复用它。
103
+ - `adapters/pi/`、`adapters/codex/`:Pi 和 Codex 的适配。
104
+ - `eval/`:对照评测脚本(Claude、Pi、Codex 各一个),任务格式见 `eval/day.py`;评测用的题目和隐藏测试来自内部项目,没有放进仓库。
105
+ - `DESIGN.md`:设计说明;`docs/TEST-REPORT.md`:测试报告。
106
+
107
+ ## 许可证
108
+
109
+ MIT,见 [LICENSE](https://github.com/coffeecoproject/SmartCompact/blob/main/LICENSE)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartcompact",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "Compact long agent sessions earlier, at a finished piece of work, to cut cost without losing results (Claude Code, pi, Codex)",
6
6
  "license": "MIT",