@sliday/tamp 0.8.17 → 0.8.20
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 +66 -3
- package/bin/tamp.js +80 -6
- package/compress.js +27 -1
- package/config.js +3 -1
- package/lib/rules-generator.js +8 -5
- package/metadata.js +13 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ The plugin adds `/tamp:status` and `/tamp:config` commands. It auto-starts Tamp
|
|
|
20
20
|
{ "env": { "ANTHROPIC_BASE_URL": "http://localhost:7778" } }
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
That line makes Claude Code depend on Tamp. Run `tamp install-service` in the same sitting so the proxy is up at every login, and keep `~/.claude/settings.json.backup` until you trust the setup. To undo, delete the `ANTHROPIC_BASE_URL` key.
|
|
24
|
+
|
|
23
25
|
### 🦞 OpenClaw
|
|
24
26
|
|
|
25
27
|
```bash
|
|
@@ -70,6 +72,20 @@ curl -s http://localhost:8788/health # Verify: {"status":"ok","model_loaded":tru
|
|
|
70
72
|
tamp stop && tamp -y # restart Tamp, health endpoint will show `sidecar: ok`
|
|
71
73
|
```
|
|
72
74
|
|
|
75
|
+
**What it will not touch.** LLMLingua-2 paraphrases, and a paraphrased file path is a broken file path. At the default rate of 0.7 it turned real command output into this:
|
|
76
|
+
|
|
77
|
+
| Before | After |
|
|
78
|
+
|--------|-------|
|
|
79
|
+
| `/Users/x/.config/tamp/tamp.err.log` | `/Users/x./tamp..` |
|
|
80
|
+
| `"version":"0.8.17"` | `"version""0.. 17"` |
|
|
81
|
+
| `launchctl bootout gui/501/dev.tamp.proxy` | `launchctl bootout gui/501/dev..` |
|
|
82
|
+
|
|
83
|
+
So Tamp skips the sidecar for any block carrying paths, URLs, JSON separators, hex ids, or semver, and sends only prose. Across Tamp's own benchmark fixtures that guard fires on 92% of text blocks, which is the honest measure of how much `llmlingua` contributes to a coding agent: very little. Keep it for doc-heavy and web-fetch traffic, drop it if you want a fully lossless pipeline:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
TAMP_STAGES=cmd-strip,minify,toon,strip-lines,whitespace,dedup,diff,read-diff,prune tamp -y
|
|
87
|
+
```
|
|
88
|
+
|
|
73
89
|
## Quick Start
|
|
74
90
|
|
|
75
91
|
```bash
|
|
@@ -138,6 +154,29 @@ opencode **silently ignores** `OPENAI_API_BASE` / `OPENAI_BASE_URL`. Configure b
|
|
|
138
154
|
|
|
139
155
|
Restart opencode. Tamp's adapter table routes each provider to the correct upstream.
|
|
140
156
|
|
|
157
|
+
### Kimi Code
|
|
158
|
+
|
|
159
|
+
Config lives at `~/.kimi-code/config.toml` (not `~/.kimi/`), and the provider table is named after the managed provider:
|
|
160
|
+
|
|
161
|
+
```toml
|
|
162
|
+
[providers."managed:kimi-code"]
|
|
163
|
+
base_url = "http://localhost:7778/kimi/coding/v1"
|
|
164
|
+
|
|
165
|
+
# Moonshot API key instead of a subscription:
|
|
166
|
+
[providers.moonshot]
|
|
167
|
+
base_url = "http://localhost:7778/moonshot/v1"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
> **Read this before you edit that file.** Kimi Code stores its OAuth token under a key derived from the provider environment, and `base_url` is part of that key. Change the URL and the CLI loses the token it already has:
|
|
171
|
+
>
|
|
172
|
+
> ```
|
|
173
|
+
> No token for "kimi-code-env-92f579c50dab5f50". Run /login to authenticate.
|
|
174
|
+
> ```
|
|
175
|
+
>
|
|
176
|
+
> Every running agent fails at once, including background ones. Run `/login` in Kimi after the edit to re-authenticate under the new key, or leave `base_url` alone and accept no compression on Kimi. Restoring the original URL restores the original token.
|
|
177
|
+
|
|
178
|
+
An API-key Moonshot setup has no such problem; only the OAuth subscription path is affected.
|
|
179
|
+
|
|
141
180
|
### VS Code
|
|
142
181
|
|
|
143
182
|
#### Cline (recommended)
|
|
@@ -317,10 +356,34 @@ npx @sliday/tamp
|
|
|
317
356
|
# npm global
|
|
318
357
|
npm install -g @sliday/tamp
|
|
319
358
|
tamp
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Keep it running
|
|
362
|
+
|
|
363
|
+
Read this before you point an agent at Tamp permanently. Once `ANTHROPIC_BASE_URL` (or a `config.toml` `base_url`) names `localhost:7778`, that agent talks to nothing when Tamp is down. Every session fails until you start it again.
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
tamp install-service # launchd on macOS, systemd user unit on Linux
|
|
367
|
+
tamp status # confirm it came up
|
|
368
|
+
tamp uninstall-service # remove it
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
macOS installs `~/Library/LaunchAgents/dev.tamp.proxy.plist` with `RunAtLoad` and `KeepAlive`, so Tamp starts at login and restarts if it dies. Logs land in `~/.config/tamp/tamp.err.log`.
|
|
372
|
+
|
|
373
|
+
If you would rather not add a background service, keep the agent on its normal endpoint and start Tamp by hand when you want the savings.
|
|
320
374
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
375
|
+
### Verify a global install actually replaced the old one
|
|
376
|
+
|
|
377
|
+
`npm install -g` writes to `npm config get prefix`, which is not always the directory your shell resolves from. Check the copy you actually run:
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
grep '"version"' "$(dirname "$(readlink -f "$(command -v tamp)")")/../package.json"
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
If that disagrees with `npm view @sliday/tamp version`, install into the prefix your PATH uses:
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
npm install -g --prefix "$(dirname "$(dirname "$(readlink -f "$(command -v tamp)")")")" @sliday/tamp
|
|
324
387
|
```
|
|
325
388
|
|
|
326
389
|
## Monitoring
|
package/bin/tamp.js
CHANGED
|
@@ -220,9 +220,66 @@ if (subcommand === 'settings' || subcommand === 'config') {
|
|
|
220
220
|
instance = render(h(LevelPicker, { version: VERSION, envLevel, onSelect, onCancel }))
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
// macOS LaunchAgent. Pointing an agent's base URL at Tamp makes that agent
|
|
224
|
+
// depend on Tamp being up, so "run it by hand in a terminal" is not a real
|
|
225
|
+
// answer once you route Claude Code or Codex through it.
|
|
226
|
+
const LAUNCH_AGENT_LABEL = 'dev.tamp.proxy'
|
|
227
|
+
const LAUNCH_AGENT_PATH = join(homedir(), 'Library', 'LaunchAgents', `${LAUNCH_AGENT_LABEL}.plist`)
|
|
228
|
+
|
|
229
|
+
if (subcommand === 'install-service' && process.platform === 'darwin') {
|
|
230
|
+
const nodeBin = process.execPath
|
|
231
|
+
const tampBin = join(__dirname, 'tamp.js')
|
|
232
|
+
const logDir = join(homedir(), '.config', 'tamp')
|
|
233
|
+
mkdirSync(logDir, { recursive: true })
|
|
234
|
+
mkdirSync(dirname(LAUNCH_AGENT_PATH), { recursive: true })
|
|
235
|
+
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
236
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
237
|
+
<plist version="1.0">
|
|
238
|
+
<dict>
|
|
239
|
+
<key>Label</key><string>${LAUNCH_AGENT_LABEL}</string>
|
|
240
|
+
<key>ProgramArguments</key>
|
|
241
|
+
<array>
|
|
242
|
+
<string>${nodeBin}</string>
|
|
243
|
+
<string>${tampBin}</string>
|
|
244
|
+
<string>-y</string>
|
|
245
|
+
<string>--force</string>
|
|
246
|
+
</array>
|
|
247
|
+
<key>RunAtLoad</key><true/>
|
|
248
|
+
<key>KeepAlive</key><true/>
|
|
249
|
+
<key>StandardOutPath</key><string>${join(logDir, 'tamp.out.log')}</string>
|
|
250
|
+
<key>StandardErrorPath</key><string>${join(logDir, 'tamp.err.log')}</string>
|
|
251
|
+
</dict>
|
|
252
|
+
</plist>
|
|
253
|
+
`
|
|
254
|
+
writeFileSync(LAUNCH_AGENT_PATH, plist)
|
|
255
|
+
const uid = process.getuid()
|
|
256
|
+
try { execFileSync('launchctl', ['bootout', `gui/${uid}/${LAUNCH_AGENT_LABEL}`], { stdio: 'ignore' }) } catch {}
|
|
257
|
+
try {
|
|
258
|
+
execFileSync('launchctl', ['bootstrap', `gui/${uid}`, LAUNCH_AGENT_PATH], { stdio: 'inherit' })
|
|
259
|
+
execFileSync('launchctl', ['enable', `gui/${uid}/${LAUNCH_AGENT_LABEL}`], { stdio: 'ignore' })
|
|
260
|
+
console.log(`\nLaunchAgent installed: ${LAUNCH_AGENT_PATH}`)
|
|
261
|
+
console.log(' Status: tamp status')
|
|
262
|
+
console.log(` Logs: tail -f ${join(logDir, 'tamp.err.log')}`)
|
|
263
|
+
console.log(` Stop: launchctl bootout gui/${uid}/${LAUNCH_AGENT_LABEL}`)
|
|
264
|
+
console.log(' Remove: tamp uninstall-service')
|
|
265
|
+
} catch (e) {
|
|
266
|
+
console.error('launchctl failed:', e.message)
|
|
267
|
+
process.exit(1)
|
|
268
|
+
}
|
|
269
|
+
process.exit(0)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (subcommand === 'uninstall-service' && process.platform === 'darwin') {
|
|
273
|
+
const uid = process.getuid()
|
|
274
|
+
try { execFileSync('launchctl', ['bootout', `gui/${uid}/${LAUNCH_AGENT_LABEL}`], { stdio: 'ignore' }) } catch {}
|
|
275
|
+
try { unlinkSync(LAUNCH_AGENT_PATH) } catch {}
|
|
276
|
+
console.log('LaunchAgent removed.')
|
|
277
|
+
process.exit(0)
|
|
278
|
+
}
|
|
279
|
+
|
|
223
280
|
if (subcommand === 'install-service') {
|
|
224
281
|
if (process.platform !== 'linux') {
|
|
225
|
-
console.error('Service installation requires Linux (systemd).')
|
|
282
|
+
console.error('Service installation requires Linux (systemd) or macOS (launchd).')
|
|
226
283
|
process.exit(1)
|
|
227
284
|
}
|
|
228
285
|
const nodeBin = process.execPath
|
|
@@ -262,7 +319,7 @@ WantedBy=default.target
|
|
|
262
319
|
|
|
263
320
|
if (subcommand === 'uninstall-service') {
|
|
264
321
|
if (process.platform !== 'linux') {
|
|
265
|
-
console.error('Service management requires Linux (systemd).')
|
|
322
|
+
console.error('Service management requires Linux (systemd) or macOS (launchd).')
|
|
266
323
|
process.exit(1)
|
|
267
324
|
}
|
|
268
325
|
const unitPath = join(homedir(), '.config', 'systemd', 'user', 'tamp.service')
|
|
@@ -385,8 +442,8 @@ if (subcommand === 'help' || subcommand === '--help' || subcommand === '-h' || p
|
|
|
385
442
|
console.log(' init Create config file (~/.config/tamp/config)')
|
|
386
443
|
console.log(' settings Edit compression level and stages')
|
|
387
444
|
console.log(' status Check if proxy is running')
|
|
388
|
-
console.log(' install-service
|
|
389
|
-
console.log(' uninstall-service Remove
|
|
445
|
+
console.log(' install-service Keep Tamp running (launchd on macOS, systemd on Linux)')
|
|
446
|
+
console.log(' uninstall-service Remove the service')
|
|
390
447
|
console.log(' help Show this help')
|
|
391
448
|
console.log('')
|
|
392
449
|
console.log('Options:')
|
|
@@ -399,8 +456,25 @@ if (subcommand === 'help' || subcommand === '--help' || subcommand === '-h' || p
|
|
|
399
456
|
const skipPrompt = process.argv.includes('-y') || process.argv.includes('--no-interactive') || !process.stdin.isTTY
|
|
400
457
|
const forceReplace = process.argv.includes('--force')
|
|
401
458
|
|
|
402
|
-
|
|
403
|
-
|
|
459
|
+
// TAMP_STAGES may come from the environment or from ~/.config/tamp/config.
|
|
460
|
+
// Reading only process.env meant a stage list written to the config file was
|
|
461
|
+
// silently overwritten by DEFAULT_STAGES on every `tamp -y`, so the documented
|
|
462
|
+
// knob did nothing on the non-interactive path most people use.
|
|
463
|
+
function readStagesSetting() {
|
|
464
|
+
if (process.env.TAMP_STAGES) return process.env.TAMP_STAGES
|
|
465
|
+
try {
|
|
466
|
+
const line = readFileSync(CONFIG_PATH, 'utf8')
|
|
467
|
+
.split('\n')
|
|
468
|
+
.map(l => l.trim())
|
|
469
|
+
.filter(l => l && !l.startsWith('#'))
|
|
470
|
+
.find(l => l.startsWith('TAMP_STAGES='))
|
|
471
|
+
return line ? line.slice('TAMP_STAGES='.length).trim() : null
|
|
472
|
+
} catch { return null }
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const stagesSetting = readStagesSetting()
|
|
476
|
+
const envStages = stagesSetting
|
|
477
|
+
? new Set(stagesSetting.split(',').map(s => s.trim()).filter(Boolean))
|
|
404
478
|
: null
|
|
405
479
|
|
|
406
480
|
async function ensurePortFree(port) {
|
package/compress.js
CHANGED
|
@@ -373,6 +373,22 @@ async function textpressCompress(text, config) {
|
|
|
373
373
|
return null
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
+
// Content an agent must be able to copy back out byte for byte. Neural
|
|
377
|
+
// compressors paraphrase, and a paraphrased path is a broken path.
|
|
378
|
+
const VERBATIM_CRITICAL = [
|
|
379
|
+
/(?:^|[\s"'(=])\.{0,2}\/[\w.\-]+\/[\w.\-]+/, // /usr/local, ./src/app, ../a/b
|
|
380
|
+
/[A-Za-z]:\\[\w.\-]+\\/, // C:\Users\x\
|
|
381
|
+
/\bhttps?:\/\//, // urls
|
|
382
|
+
/"\s*:\s*/, // json key/value separators
|
|
383
|
+
/[{[]\s*"/, // json object/array openers
|
|
384
|
+
/\b[0-9a-f]{7,}\b/, // sha/commit/hex ids
|
|
385
|
+
/\bv?\d+\.\d+\.\d+\b/, // semver
|
|
386
|
+
]
|
|
387
|
+
|
|
388
|
+
export function hasVerbatimCriticalContent(text) {
|
|
389
|
+
return VERBATIM_CRITICAL.some(re => re.test(text))
|
|
390
|
+
}
|
|
391
|
+
|
|
376
392
|
// --- Core compression ---
|
|
377
393
|
export function compressText(text, config) {
|
|
378
394
|
if (text.length < config.minSize) { if (config.log !== false) process.stderr.write(`[tamp] skip: too small (${text.length} < ${config.minSize})\n`); return null }
|
|
@@ -410,7 +426,17 @@ export function compressText(text, config) {
|
|
|
410
426
|
return { text: processed, method, originalLen: text.length, compressedLen: processed.length, originalTokens: countTokens(text), compressedTokens: countTokens(processed) }
|
|
411
427
|
}
|
|
412
428
|
if (config.stages.includes('llmlingua') && config.llmLinguaUrl) {
|
|
413
|
-
|
|
429
|
+
// LLMLingua-2 is a prose compressor. On tool output it drops characters
|
|
430
|
+
// from the middle of tokens the agent has to reuse verbatim:
|
|
431
|
+
// /Users/x/.config/tamp/tamp.err.log -> /Users/x./tamp..
|
|
432
|
+
// "version":"0.8.17" -> "version""0.. 17"
|
|
433
|
+
// A path the agent cannot cat is worse than a payload it cannot shrink,
|
|
434
|
+
// so anything carrying paths, URLs, JSON or hashes skips the sidecar.
|
|
435
|
+
if (hasVerbatimCriticalContent(processed)) {
|
|
436
|
+
if (config.log !== false) process.stderr.write('[tamp] skip: llmlingua (verbatim-critical content: paths/JSON/urls/hashes)\n')
|
|
437
|
+
} else {
|
|
438
|
+
return { async: true, asyncMethod: 'llmlingua', text: processed, cls }
|
|
439
|
+
}
|
|
414
440
|
}
|
|
415
441
|
if (config.stages.includes('foundation-models') && config.foundationModelsPath) {
|
|
416
442
|
return { async: true, asyncMethod: 'foundation-models', text: processed, cls }
|
package/config.js
CHANGED
|
@@ -278,7 +278,9 @@ export const CONFIG_TEMPLATE = `# Tamp configuration
|
|
|
278
278
|
# Compression level 1..9 (or: conservative, balanced, aggressive, max)
|
|
279
279
|
# level=5
|
|
280
280
|
|
|
281
|
-
# Compression preset (conservative | balanced | aggressive)
|
|
281
|
+
# Compression preset (conservative | balanced | aggressive | recommended)
|
|
282
|
+
# "recommended" is the measured best trade-off: aggressive minus llmlingua.
|
|
283
|
+
# Pair it with TAMP_MIN_SIZE=1024 (see whitepaper, Recommended Defaults).
|
|
282
284
|
# TAMP_COMPRESSION_PRESET=balanced
|
|
283
285
|
|
|
284
286
|
# Explicit stages (overrides preset if set)
|
package/lib/rules-generator.js
CHANGED
|
@@ -14,15 +14,18 @@ const SAFE_TASK_PATTERNS = [
|
|
|
14
14
|
/^(format|lint|fmt)|run linter/i,
|
|
15
15
|
]
|
|
16
16
|
|
|
17
|
-
// Dangerous task patterns: require detailed output
|
|
17
|
+
// Dangerous task patterns: require detailed output.
|
|
18
|
+
// Keyword alternations need \b on both ends: unanchored, `latest`/`contest` hit
|
|
19
|
+
// `test` and `specific`/`inspect` hit `spec`, and one false positive disables
|
|
20
|
+
// disclosure (compress.js:136) and bm25-trim (compress.js:168) for the session.
|
|
18
21
|
const DANGEROUS_TASK_PATTERNS = [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
/\bsecurity\b|\bvulnerabilit\w*|\bexploit\w*|\battack\w*/i,
|
|
23
|
+
/\bdebug\w*|\binvestigat\w*|\bdiagnos\w*|\btroubleshoot\w*/i,
|
|
24
|
+
/\bmemory leak\b|\bperforman\w*|\boptimi[sz]\w*/i,
|
|
22
25
|
/^refactor|^architecture|^design/i,
|
|
23
26
|
/^fix\s+bug/i,
|
|
24
27
|
/^explain|^why|^how\s+(does|work)/i,
|
|
25
|
-
|
|
28
|
+
/\btest(s|ing)?\b|\bspecs?\b|\bcoverage\b/i,
|
|
26
29
|
]
|
|
27
30
|
|
|
28
31
|
/**
|
package/metadata.js
CHANGED
|
@@ -139,6 +139,19 @@ export const COMPRESSION_PRESETS = Object.freeze({
|
|
|
139
139
|
risk: 'Medium (may lose comments, verbose text)',
|
|
140
140
|
level: 8,
|
|
141
141
|
},
|
|
142
|
+
// Autoresearch study (v0.8.19, deepseek-v4-flash judge): aggressive minus
|
|
143
|
+
// llmlingua scored 79.95% input savings at 20/20 fact retention, vs 68.51%
|
|
144
|
+
// for full aggressive — llmlingua shadowed textpress on large blocks and
|
|
145
|
+
// corrupted numerals on small ones. Pair with TAMP_MIN_SIZE=1024.
|
|
146
|
+
// See bench/recommend-eval.js and the whitepaper's Recommended Defaults section.
|
|
147
|
+
recommended: {
|
|
148
|
+
name: 'Recommended',
|
|
149
|
+
description: 'Best measured savings/quality trade-off (aggressive minus llmlingua; use TAMP_MIN_SIZE=1024)',
|
|
150
|
+
stages: ['cmd-strip', 'minify', 'toon', 'strip-lines', 'whitespace', 'dedup', 'diff', 'read-diff', 'prune', 'strip-comments', 'textpress', 'br-cache', 'disclosure', 'bm25-trim'],
|
|
151
|
+
expectedSavings: '63-80%',
|
|
152
|
+
risk: 'Medium (may lose comments, paraphrase verbose text)',
|
|
153
|
+
level: null,
|
|
154
|
+
},
|
|
142
155
|
})
|
|
143
156
|
|
|
144
157
|
// Flat 1..9 compression ladder, parallel to the named presets. Each level
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"sidecar/server.py",
|
|
15
15
|
"sidecar/requirements.txt"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.8.
|
|
17
|
+
"version": "0.8.20",
|
|
18
18
|
"description": "Token compression proxy for coding agents. Works with Claude Code, Aider, Cursor, Cline, Windsurf. 60-70% combined input+output savings with Caveman-integrated presets and per-command rewriters.",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"main": "index.js",
|