shrinker-ai 0.1.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 +363 -295
- package/dist/src/cli.js +18 -18
- package/dist/src/metrics/dashboard.js +65 -65
- package/dist/src/metrics/stats-store.js +43 -43
- package/integrations/macos/install.sh +152 -0
- package/integrations/macos/shrinker-profile.zsh +98 -0
- package/integrations/macos/uninstall.sh +70 -0
- package/integrations/windows/install.ps1 +113 -0
- package/integrations/{shrinker-profile.ps1 → windows/shrinker-profile.ps1} +136 -136
- package/integrations/windows/uninstall.ps1 +57 -0
- package/package.json +39 -31
- package/templates/agent-rules.md +18 -18
- package/.copilot-instructions.md +0 -2
- package/CLAUDE.md +0 -2
- package/integrations/install-shrinker.ps1 +0 -166
- package/integrations/install.ps1 +0 -46
- package/integrations/uninstall-shrinker.ps1 +0 -79
- package/integrations/uninstall.ps1 +0 -35
package/README.md
CHANGED
|
@@ -1,295 +1,363 @@
|
|
|
1
|
-
# shrinker
|
|
2
|
-
|
|
3
|
-
A small local CLI proof of concept that removes noise from command output before a coding agent or LLM reads it.
|
|
4
|
-
|
|
5
|
-
this POC proves that a few conservative, deterministic filters can save useful context without requiring an API key, service, UI, database, or agent-specific integration.
|
|
6
|
-
|
|
7
|
-
## What the POC demonstrates
|
|
8
|
-
|
|
9
|
-
- Explicit cross-agent command wrapping: `shrinker exec -- <command>`.
|
|
10
|
-
- Filters for Git status, Git diff, test output, and generic logs.
|
|
11
|
-
- Failures, warnings, changed paths, and command exit codes are preserved.
|
|
12
|
-
- Omitted raw output is saved locally for recovery.
|
|
13
|
-
- Optional per-run metrics report bytes and approximate before/after tokens.
|
|
14
|
-
- Local SQLite statistics accumulate savings across runs.
|
|
15
|
-
- No command output leaves the machine.
|
|
16
|
-
|
|
17
|
-
## Quick start
|
|
18
|
-
|
|
19
|
-
Requires Node.js 22.13 or newer. This is the first Node 22 release where the built-in SQLite module no longer requires an experimental flag.
|
|
20
|
-
|
|
21
|
-
### One-command install (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
.
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
shrinker
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
1
|
+
# shrinker
|
|
2
|
+
|
|
3
|
+
A small local CLI proof of concept that removes noise from command output before a coding agent or LLM reads it.
|
|
4
|
+
|
|
5
|
+
this POC proves that a few conservative, deterministic filters can save useful context without requiring an API key, service, UI, database, or agent-specific integration.
|
|
6
|
+
|
|
7
|
+
## What the POC demonstrates
|
|
8
|
+
|
|
9
|
+
- Explicit cross-agent command wrapping: `shrinker exec -- <command>`.
|
|
10
|
+
- Filters for Git status, Git diff, test output, and generic logs.
|
|
11
|
+
- Failures, warnings, changed paths, and command exit codes are preserved.
|
|
12
|
+
- Omitted raw output is saved locally for recovery.
|
|
13
|
+
- Optional per-run metrics report bytes and approximate before/after tokens.
|
|
14
|
+
- Local SQLite statistics accumulate savings across runs.
|
|
15
|
+
- No command output leaves the machine.
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
Requires Node.js 22.13 or newer. This is the first Node 22 release where the built-in SQLite module no longer requires an experimental flag.
|
|
20
|
+
|
|
21
|
+
### One-command install (macOS zsh)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
curl -fsSL https://raw.githubusercontent.com/ivanduplenskikh/shrinker/main/integrations/macos/install.sh | bash
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### One-command install (Windows PowerShell)
|
|
28
|
+
|
|
29
|
+
```powershell
|
|
30
|
+
irm https://raw.githubusercontent.com/ivanduplenskikh/shrinker/main/integrations/windows/install.ps1 | iex
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Install from npm package
|
|
34
|
+
|
|
35
|
+
Windows PowerShell:
|
|
36
|
+
|
|
37
|
+
```powershell
|
|
38
|
+
npm install --global shrinker-ai --registry=https://registry.npmjs.org
|
|
39
|
+
$pkg = Join-Path ((npm root --global).Trim()) "shrinker-ai"
|
|
40
|
+
pwsh -ExecutionPolicy Bypass -File (Join-Path $pkg "integrations\\windows\\install.ps1") -Local -SkipNpmInstall -SkipBuild -SkipLink
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
To enable automatic PowerShell routing, add `-EnableProfileRouting` to the final command.
|
|
44
|
+
|
|
45
|
+
macOS zsh:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install --global shrinker-ai --registry=https://registry.npmjs.org
|
|
49
|
+
pkg="$(npm root --global)/shrinker-ai"
|
|
50
|
+
bash "$pkg/integrations/macos/install.sh" --local --skip-npm-install --skip-build --skip-link --enable-profile-routing
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Install from local checkout
|
|
54
|
+
|
|
55
|
+
Windows PowerShell:
|
|
56
|
+
|
|
57
|
+
```powershell
|
|
58
|
+
pwsh -ExecutionPolicy Bypass -File .\integrations\windows\install.ps1 -Local
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
macOS zsh:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
bash ./integrations/macos/install.sh --local
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
This writes managed guidance blocks globally to:
|
|
68
|
+
|
|
69
|
+
- `~/.copilot/copilot-instructions.md`
|
|
70
|
+
- `~/.claude/CLAUDE.md`
|
|
71
|
+
|
|
72
|
+
The shared guidance source is `templates/agent-rules.md`; the files above are created in the corresponding global agent directory.
|
|
73
|
+
|
|
74
|
+
The rules tell agents to prefer `shrinker <command>` for high-volume commands while leaving native commands untouched.
|
|
75
|
+
|
|
76
|
+
### Uninstall
|
|
77
|
+
|
|
78
|
+
If you installed from npm, remove the package first:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm uninstall --global shrinker-ai --registry=https://registry.npmjs.org
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
If you also installed profile/rules through the package scripts, run the matching local uninstaller from the installed package before uninstalling:
|
|
85
|
+
|
|
86
|
+
Windows PowerShell:
|
|
87
|
+
|
|
88
|
+
```powershell
|
|
89
|
+
$pkg = Join-Path ((npm root --global).Trim()) "shrinker-ai"
|
|
90
|
+
pwsh -ExecutionPolicy Bypass -File (Join-Path $pkg "integrations\\windows\\uninstall.ps1") -SkipUnlink
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
macOS zsh:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pkg="$(npm root --global)/shrinker-ai"
|
|
97
|
+
bash "$pkg/integrations/macos/uninstall.sh" --skip-unlink
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
macOS one-liner uninstall:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
curl -fsSL https://raw.githubusercontent.com/ivanduplenskikh/shrinker/main/integrations/macos/uninstall.sh | bash
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Local repo install/uninstall (contributors)
|
|
107
|
+
|
|
108
|
+
If you cloned this repository and want to run scripts directly from the local path:
|
|
109
|
+
|
|
110
|
+
```powershell
|
|
111
|
+
pwsh -ExecutionPolicy Bypass -File .\integrations\windows\install.ps1 -Local
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Or on macOS:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
bash ./integrations/macos/install.sh --local
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
To uninstall:
|
|
121
|
+
|
|
122
|
+
```powershell
|
|
123
|
+
pwsh -ExecutionPolicy Bypass -File .\integrations\windows\install.ps1 -Uninstall
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Or on macOS:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
bash ./integrations/macos/install.sh --uninstall
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Uninstall options:
|
|
133
|
+
|
|
134
|
+
```powershell
|
|
135
|
+
# Keep shrinker command installed, but remove profile integration and managed rules
|
|
136
|
+
pwsh -ExecutionPolicy Bypass -File .\integrations\windows\install.ps1 -Uninstall -SkipUnlink
|
|
137
|
+
|
|
138
|
+
# Keep managed rules files unchanged while uninstalling command/profile hooks
|
|
139
|
+
pwsh -ExecutionPolicy Bypass -File .\integrations\windows\install.ps1 -Uninstall -SkipAgentRules
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
macOS uninstall options:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Keep shrinker command installed, but remove profile integration and managed rules
|
|
146
|
+
bash ./integrations/macos/install.sh --uninstall --skip-unlink
|
|
147
|
+
|
|
148
|
+
# Keep managed rules files unchanged while uninstalling command/profile hooks
|
|
149
|
+
bash ./integrations/macos/install.sh --uninstall --skip-agent-rules
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
If your current terminal had already loaded `shrinker-profile.ps1` or `shrinker-profile.zsh`, restart terminal (or remove loaded wrapper functions) to fully return to native command behavior.
|
|
153
|
+
|
|
154
|
+
```powershell
|
|
155
|
+
npm install
|
|
156
|
+
npm run build
|
|
157
|
+
node dist\src\cli.js exec -- git status
|
|
158
|
+
node dist\src\cli.js exec -- git diff
|
|
159
|
+
node dist\src\cli.js exec -- git log -n 10
|
|
160
|
+
node dist\src\cli.js exec -- npm test
|
|
161
|
+
Get-Content .\tests\fixtures\generic-log.txt -Raw |
|
|
162
|
+
node dist\src\cli.js pipe --kind log
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
To install the `shrinker` command locally:
|
|
166
|
+
|
|
167
|
+
```powershell
|
|
168
|
+
npm link
|
|
169
|
+
shrinker git status
|
|
170
|
+
shrinker git log -n 10
|
|
171
|
+
shrinker npm test
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## CLI
|
|
175
|
+
|
|
176
|
+
```text
|
|
177
|
+
shrinker <command> [args...]
|
|
178
|
+
shrinker exec [options] [--] <command> [args...]
|
|
179
|
+
shrinker pipe [options]
|
|
180
|
+
shrinker stats [--json]
|
|
181
|
+
shrinker last [--path]
|
|
182
|
+
shrinker raw <capture-id> [--path]
|
|
183
|
+
shrinker help
|
|
184
|
+
|
|
185
|
+
--kind <auto|git-status|git-diff|git-log|test|log>
|
|
186
|
+
--max-lines <number> default: 120
|
|
187
|
+
--per-file-lines <number> default: 40
|
|
188
|
+
--raw bypass filtering
|
|
189
|
+
--metrics print per-run savings and duration
|
|
190
|
+
--no-save do not save omitted raw output
|
|
191
|
+
--no-stats do not record this run
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
`help`, `stats`, `last`, `raw`, `pipe`, and `exec` are reserved shrinker commands. Every other top-level token starts a wrapped command, so `shrinker git log` is equivalent to `shrinker exec git log`. The `--` separator remains optional because npm's PowerShell shim may consume it. `pipe` reads existing text from stdin and defaults to the generic log filter unless `--kind` is specified.
|
|
195
|
+
|
|
196
|
+
## Automatic PowerShell routing
|
|
197
|
+
|
|
198
|
+
The optional profile integration routes allowlisted commands through `shrinker` and invokes the native executable for everything else. Install it after `npm link`:
|
|
199
|
+
|
|
200
|
+
```powershell
|
|
201
|
+
if (!(Test-Path $PROFILE)) {
|
|
202
|
+
New-Item -ItemType File -Path $PROFILE -Force | Out-Null
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
$integration = (Resolve-Path .\integrations\windows\shrinker-profile.ps1).Path
|
|
206
|
+
Add-Content $PROFILE "`n. `"$integration`""
|
|
207
|
+
. $PROFILE
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
macOS zsh profile integration:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
echo '' >> ~/.zshrc
|
|
214
|
+
echo '# >>> shrinker integration >>>' >> ~/.zshrc
|
|
215
|
+
echo 'source "'"$(pwd)/integrations/macos/shrinker-profile.zsh"'"' >> ~/.zshrc
|
|
216
|
+
echo '# <<< shrinker integration <<<' >> ~/.zshrc
|
|
217
|
+
source ~/.zshrc
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The default rules are:
|
|
221
|
+
|
|
222
|
+
```text
|
|
223
|
+
git status -> shrinker git status
|
|
224
|
+
git diff -> shrinker git diff
|
|
225
|
+
git log -> shrinker git log
|
|
226
|
+
npm test -> shrinker npm test
|
|
227
|
+
docker ps -> shrinker docker ps
|
|
228
|
+
kubectl get -> shrinker kubectl get
|
|
229
|
+
gh pr list -> shrinker gh pr list
|
|
230
|
+
rg/find/tail/cat/ls/dir -> shrinker <command>
|
|
231
|
+
|
|
232
|
+
git push, git fetch, and all other commands -> native executable
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Edit `$global:ShrinkPowerShellRules` in `integrations\windows\shrinker-profile.ps1` to change the allowlist. The router is now option-aware for common global flags, so forms like `git -C <path> log` and `kubectl --context prod get pods` are routed correctly.
|
|
236
|
+
|
|
237
|
+
## Savings statistics
|
|
238
|
+
|
|
239
|
+
Filtered runs are recorded locally in `~/.shrinker/stats.db`. The database stores only measurements, filter kind, executable basename, duration, omission state, and exit code. It does **not** store command arguments or command output.
|
|
240
|
+
|
|
241
|
+
```powershell
|
|
242
|
+
node dist\src\cli.js stats
|
|
243
|
+
node dist\src\cli.js stats --json
|
|
244
|
+
node dist\src\cli.js stats --chart
|
|
245
|
+
node dist\src\cli.js stats --dashboard
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
The summary shows all-time and last-seven-day savings plus a breakdown by filter. Use `--no-stats` before `--` to opt out for an individual run:
|
|
249
|
+
|
|
250
|
+
`stats --chart` shows daily runs, estimated tokens saved, reduction percentage, and an activity bar for the last 30 days.
|
|
251
|
+
`stats --dashboard` writes a self-contained browser dashboard to `~/.shrinker/dashboard.html` with a line chart and filter breakdown.
|
|
252
|
+
|
|
253
|
+
```powershell
|
|
254
|
+
node dist\src\cli.js exec --no-stats -- git log -n 10
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Detailed per-run measurements are hidden by default so agents do not spend tokens reading wrapper telemetry. Enable them for benchmarking or demos:
|
|
258
|
+
|
|
259
|
+
```powershell
|
|
260
|
+
shrinker --metrics git log -n 10
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
When meaningful content is omitted, the full capture is saved under `~/.shrinker/raw` and a compact exact-recovery hint such as `[full: shrinker raw ab12cd34]` is printed instead of an absolute path. Retrieve it only when needed:
|
|
264
|
+
|
|
265
|
+
```powershell
|
|
266
|
+
shrinker raw ab12cd34
|
|
267
|
+
shrinker raw ab12cd34 --path
|
|
268
|
+
shrinker last
|
|
269
|
+
shrinker last --path
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
`raw` retrieves the exact capture referenced by a hint; `last` is a convenience for human use. The cache uses atomic publication and best-effort rotation to retain up to 20 recent files. File names contain only the executable name, not command arguments. Wrapped `git log` output never creates a recovery file or hint because the full history can be reproduced by rerunning Git; piped Git-log text still gets a recovery hint when meaningful content is omitted. Use `--no-save` for other output that should not be persisted.
|
|
273
|
+
|
|
274
|
+
## Demo
|
|
275
|
+
|
|
276
|
+
```powershell
|
|
277
|
+
npm run demo
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Current representative fixtures:
|
|
281
|
+
|
|
282
|
+
| Output | Estimated token reduction |
|
|
283
|
+
|---|---:|
|
|
284
|
+
| Git status | 62% |
|
|
285
|
+
| Git diff | 26% |
|
|
286
|
+
| Git log with commit bodies | 39% |
|
|
287
|
+
| Git log with one short commit | 69%, but only 27 estimated tokens |
|
|
288
|
+
| Test failure | 51% |
|
|
289
|
+
| Noisy log | 39% |
|
|
290
|
+
| **Average** | **48%** |
|
|
291
|
+
|
|
292
|
+
The token estimate uses `ceil(characters / 4)`. It is suitable for relative before/after comparisons, not billing claims. Byte counts and absolute estimated tokens saved are also reported; gains below 50 tokens are labeled as small.
|
|
293
|
+
|
|
294
|
+
## Architecture
|
|
295
|
+
|
|
296
|
+
```text
|
|
297
|
+
command/stdin
|
|
298
|
+
|
|
|
299
|
+
v
|
|
300
|
+
capture output + exit code
|
|
301
|
+
|
|
|
302
|
+
v
|
|
303
|
+
select deterministic filter
|
|
304
|
+
|
|
|
305
|
+
+--> git status: group files by state
|
|
306
|
+
+--> git diff: retain changed lines, drop metadata/context
|
|
307
|
+
+--> git log: retain short hash, refs, subject, author, date,
|
|
308
|
+
| and up to three useful body lines
|
|
309
|
+
+--> tests: collapse passes, retain failures and summaries
|
|
310
|
+
+--> logs: collapse progress and repeated lines
|
|
311
|
+
|
|
|
312
|
+
v
|
|
313
|
+
compact output + optional metrics + meaningful-omission recovery hint
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Filters are pure functions, so the same pipeline can later sit behind a GitHub Copilot hook or MCP server without rewriting the compression logic.
|
|
317
|
+
|
|
318
|
+
## Safety and limitations
|
|
319
|
+
|
|
320
|
+
- The tool does not execute through a shell. Compound shell expressions and interactive commands are out of scope.
|
|
321
|
+
- Stdout and stderr are captured separately and presented as stdout followed by stderr; exact interleaving is not preserved.
|
|
322
|
+
- Filtering is conservative, but any lossy transform can hide useful context. The recovery file and `--raw` are escape hatches.
|
|
323
|
+
- Git log patch/stat/name-list flags and explicit custom formats are preserved rather than destructively reinterpreted.
|
|
324
|
+
- Git log does not impose hidden commit limits or suppress merge commits.
|
|
325
|
+
- This measures command-output reduction, not total Copilot usage, total conversation context, or billing.
|
|
326
|
+
- Streaming, agent hooks, MCP, telemetry, dashboards, custom configuration, and a broad command registry are deliberately deferred.
|
|
327
|
+
|
|
328
|
+
## Validation
|
|
329
|
+
|
|
330
|
+
```powershell
|
|
331
|
+
npm test
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Tests cover information retention, reduction targets, ANSI cleanup, filter selection, command capture, and non-zero exit-code propagation.
|
|
335
|
+
|
|
336
|
+
## Release to npm
|
|
337
|
+
|
|
338
|
+
A GitHub Actions workflow publishes this CLI to npm:
|
|
339
|
+
|
|
340
|
+
- Workflow file: `.github/workflows/publish-npm.yml`
|
|
341
|
+
- Triggers:
|
|
342
|
+
- Tag push matching `v*` (for example `v0.2.0`)
|
|
343
|
+
- Manual run via workflow_dispatch
|
|
344
|
+
- Pipeline steps:
|
|
345
|
+
- `npm ci`
|
|
346
|
+
- `npm test`
|
|
347
|
+
- `npm publish` to `https://registry.npmjs.org`
|
|
348
|
+
|
|
349
|
+
How to publish:
|
|
350
|
+
|
|
351
|
+
1. Push your changes to GitHub.
|
|
352
|
+
2. Push a version tag (or run the workflow manually):
|
|
353
|
+
- `git tag v0.2.0`
|
|
354
|
+
- `git push origin v0.2.0`
|
|
355
|
+
3. After the workflow succeeds, install from npm:
|
|
356
|
+
- `npm install -g shrinker-ai`
|
|
357
|
+
|
|
358
|
+
## Suggested roadmap
|
|
359
|
+
|
|
360
|
+
1. Validate the POC with real Copilot/Agency workflows and identify the highest-volume commands.
|
|
361
|
+
2. Add a GitHub Copilot pre-tool hook for transparent rewriting.
|
|
362
|
+
3. Expose the executor and filters through MCP for other agents.
|
|
363
|
+
4. Add filters only when measured usage justifies them.
|