smart-compaction 0.2.0 → 0.2.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 +12 -2
  2. package/index.js +13 -8
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -87,8 +87,18 @@ installs cleanly and just reports `available: false` instead of erroring.
87
87
 
88
88
  ### Tell the model when to use it
89
89
 
90
- Neither tool calls itself — nothing uses them unless instructed to. Add something like this to
91
- your `AGENTS.md` (or whatever your profile injects as standing instructions):
90
+ This is baked into both tools' own descriptions, so it works out of the box with no setup: each
91
+ tool's description tells the model to check `context_status` right after finishing a
92
+ self-contained step (e.g. right after `todo_write` marks an item `completed`) and to follow up
93
+ with `compact_now` once usage climbs past roughly 70-90%. Since both descriptions are sent to the
94
+ model on every request automatically, no `AGENTS.md` edit is required for this behavior — unlike
95
+ an early version of this plugin, which relied entirely on a hand-written `AGENTS.md` rule and
96
+ (measured directly against real session logs) got essentially no organic use as a result: the
97
+ description alone wasn't a strong enough signal.
98
+
99
+ That said, standing instructions carry more weight than a tool description competing against
100
+ everything else in a long tool catalog. If you want to reinforce it further, add something like
101
+ this to your `AGENTS.md` (or whatever your profile injects as standing instructions):
92
102
 
93
103
  > After marking a todo item `completed` (never while one is `in_progress`), call `context_status`.
94
104
  > If usage is climbing past roughly 70-80% of the context window, call `compact_now` too. Both are
package/index.js CHANGED
@@ -33,9 +33,12 @@ const DESCRIPTION =
33
33
  'Voluntarily compact older conversation history now, at a point you know is safe: '
34
34
  + 'right after finishing a concrete step (e.g. just marked a todo item completed), '
35
35
  + 'never mid-edit or with unfinished work pending. Use this instead of waiting to be '
36
- + 'interrupted by automatic compaction, if the conversation feels like it has gotten '
37
- + 'long. Harmless to call speculatively — it no-ops if there is not enough history to '
38
- + 'compact yet.'
36
+ + 'interrupted by automatic compaction. Call context_status first if unsure whether now '
37
+ + 'is a good time — usage past roughly 70-90% of the context window is a concrete signal '
38
+ + 'to call this proactively, not just a vague feeling that the conversation has gotten '
39
+ + 'long. As a habit: check context_status after every completed step, and call this '
40
+ + 'whenever that check comes back high. Harmless to call speculatively either way — it '
41
+ + 'no-ops if there is not enough history to compact yet.'
39
42
 
40
43
  /**
41
44
  * @param {import('@deepseek-ai/cordis').Context} ctx
@@ -125,11 +128,13 @@ export function apply(ctx) {
125
128
  const CONTEXT_STATUS_DESCRIPTION =
126
129
  'Check real, current context-window usage for this session: tokens used so far and the '
127
130
  + 'model\'s actual context-window size, whatever model this session happens to be running. '
128
- + 'Use this instead of guessing whether the conversation "feels long" before deciding to call '
129
- + 'compact_now — automatic compaction generally triggers well before the window fills, '
130
- + 'typically somewhere around 70-90% depending on profile config, so usage climbing past that '
131
- + 'range is a good signal to call compact_now proactively rather than wait to be interrupted. '
132
- + 'Harmless to call anytime; read-only, never modifies the session.'
131
+ + 'Call this right after finishing any self-contained step — e.g. right after todo_write '
132
+ + 'marks an item completed, never mid-edit or with unfinished work pending — instead of '
133
+ + 'guessing whether the conversation "feels long." Automatic compaction generally triggers '
134
+ + 'well before the window fills, typically somewhere around 70-90% depending on profile '
135
+ + 'config, so if percentUsed comes back past that range, follow up by calling compact_now '
136
+ + 'proactively rather than wait to be interrupted. Harmless to call anytime — read-only, '
137
+ + 'never modifies the session.'
133
138
 
134
139
  function renderContextStatus(value) {
135
140
  if (!value.available) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-compaction",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "dsh plugin: a compact_now tool letting the model trigger compaction itself at a safe point, plus a context_status tool so it can check real token usage against its context window, instead of only the automatic token-threshold trigger.",
5
5
  "type": "module",
6
6
  "main": "./index.js",