@sliday/tamp 0.5.5 → 0.5.8
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 +49 -0
- package/bin/tamp.js +20 -5
- package/bin/ui/Banner.js +21 -7
- package/metadata.js +40 -0
- package/package.json +1 -1
- package/providers.js +126 -0
package/README.md
CHANGED
|
@@ -80,6 +80,55 @@ wire_api = "responses"
|
|
|
80
80
|
|
|
81
81
|
Then `export OPENAI_API_KEY=sk-...` and run `codex` or `codex exec "..."` as usual. Tamp routes `/v1/responses` through the `openai-responses` adapter and compresses every `function_call_output` block.
|
|
82
82
|
|
|
83
|
+
### Cursor
|
|
84
|
+
|
|
85
|
+
1. Start Tamp: `npx @sliday/tamp -y`
|
|
86
|
+
2. Open Cursor → **Settings** (`⌘,`) → **Models**
|
|
87
|
+
3. Scroll to **OpenAI API Key**, paste your `sk-...` key
|
|
88
|
+
4. Click **"Override OpenAI Base URL"**, paste `http://localhost:7778/v1`
|
|
89
|
+
5. Click **Verify**, then enable any OpenAI-family model (`gpt-4o`, `gpt-5-codex`, etc.)
|
|
90
|
+
6. Use Cursor as normal — Tamp compresses every tool call
|
|
91
|
+
|
|
92
|
+
> Cursor's bundled `cursor-*` and `claude-*` models go through Cursor's own servers and bypass the override. Pick an OpenAI model to route through Tamp.
|
|
93
|
+
|
|
94
|
+
### VS Code
|
|
95
|
+
|
|
96
|
+
#### Cline (recommended)
|
|
97
|
+
|
|
98
|
+
1. Install [Cline](https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev) from the VS Code marketplace
|
|
99
|
+
2. Start Tamp: `npx @sliday/tamp -y`
|
|
100
|
+
3. Click the Cline icon in the activity bar → **Settings** (⚙️)
|
|
101
|
+
4. **API Provider**: `OpenAI Compatible`
|
|
102
|
+
5. **Base URL**: `http://localhost:7778/v1`
|
|
103
|
+
6. **API Key**: your `sk-...`
|
|
104
|
+
7. **Model ID**: `gpt-4o`, `claude-sonnet-4-5`, or any model your key supports
|
|
105
|
+
|
|
106
|
+
Cline talks directly to the configured base URL for every request — works seamlessly through Tamp.
|
|
107
|
+
|
|
108
|
+
#### Continue
|
|
109
|
+
|
|
110
|
+
1. Install [Continue](https://marketplace.visualstudio.com/items?itemName=Continue.continue)
|
|
111
|
+
2. Start Tamp: `npx @sliday/tamp -y`
|
|
112
|
+
3. Open `~/.continue/config.json` and add:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"models": [
|
|
117
|
+
{
|
|
118
|
+
"title": "GPT-4o (via Tamp)",
|
|
119
|
+
"provider": "openai",
|
|
120
|
+
"model": "gpt-4o",
|
|
121
|
+
"apiKey": "sk-...",
|
|
122
|
+
"apiBase": "http://localhost:7778/v1"
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### GitHub Copilot
|
|
129
|
+
|
|
130
|
+
Copilot does not expose a base URL setting and routes everything through GitHub's servers. Tamp **cannot** intercept Copilot traffic. Use Cline or Continue instead if you want compression in VS Code.
|
|
131
|
+
|
|
83
132
|
## Configuration
|
|
84
133
|
|
|
85
134
|
Run `tamp init` to create `~/.config/tamp/config`. All variables work via env or config file.
|
package/bin/tamp.js
CHANGED
|
@@ -5,7 +5,7 @@ import { spawn, execFileSync } from 'node:child_process'
|
|
|
5
5
|
import { fileURLToPath } from 'node:url'
|
|
6
6
|
import { dirname, join } from 'node:path'
|
|
7
7
|
import { homedir } from 'node:os'
|
|
8
|
-
import { DEFAULT_STAGES, EXTRA_STAGES, STAGE_DESCRIPTIONS, VERSION } from '../metadata.js'
|
|
8
|
+
import { DEFAULT_STAGES, EXTRA_STAGES, STAGE_DESCRIPTIONS, STAGE_HINTS, VERSION, isLossy } from '../metadata.js'
|
|
9
9
|
import { CONFIG_PATH, CONFIG_TEMPLATE } from '../config.js'
|
|
10
10
|
import {
|
|
11
11
|
checkPort,
|
|
@@ -295,17 +295,32 @@ if (skipPrompt) {
|
|
|
295
295
|
console.error(` ${c.dim}Claude Code:${c.reset} ANTHROPIC_BASE_URL=${c.yellow}${url}${c.reset}`)
|
|
296
296
|
console.error(` ${c.dim}Aider/Cursor:${c.reset} OPENAI_API_BASE=${c.yellow}${url}${c.reset}`)
|
|
297
297
|
console.error('')
|
|
298
|
-
|
|
298
|
+
const total = DEFAULT_STAGES.length + EXTRA_STAGES.length
|
|
299
|
+
console.error(` ${c.bold}Stages${c.reset} ${c.dim}(${active.length} of ${total} active)${c.reset}`)
|
|
299
300
|
for (const s of defaultActive) {
|
|
300
301
|
const extra = s === 'llmlingua' && config.llmLinguaUrl ? ` ${c.dim}(${config.llmLinguaUrl})${c.reset}` : ''
|
|
301
302
|
console.error(` ${c.green}\u2713${c.reset} ${c.cyan}${s}${c.reset}${extra}`)
|
|
302
303
|
}
|
|
303
304
|
for (const s of extraActive) {
|
|
304
|
-
|
|
305
|
+
const tag = isLossy(s) ? '(lossy)' : '(opt-in)'
|
|
306
|
+
console.error(` ${c.yellow}\u2713${c.reset} ${c.yellow}${s}${c.reset} ${c.dim}${tag}${c.reset}`)
|
|
305
307
|
}
|
|
308
|
+
|
|
306
309
|
const disabled = [...DEFAULT_STAGES, ...EXTRA_STAGES].filter(s => !active.includes(s))
|
|
307
|
-
if (disabled.length
|
|
308
|
-
console.error(
|
|
310
|
+
if (disabled.length) {
|
|
311
|
+
console.error('')
|
|
312
|
+
console.error(` ${c.bold}Available${c.reset} ${c.dim}(not active — opt in for more savings)${c.reset}`)
|
|
313
|
+
for (const s of disabled) {
|
|
314
|
+
const hint = STAGE_HINTS[s]
|
|
315
|
+
if (hint) {
|
|
316
|
+
console.error(` ${c.dim}\u25EF${c.reset} ${c.cyan}${s}${c.reset} ${c.dim}— ${hint.summary}${c.reset}`)
|
|
317
|
+
if (hint.setup) {
|
|
318
|
+
console.error(` ${c.dim}\u2192 ${hint.setup}${c.reset}`)
|
|
319
|
+
}
|
|
320
|
+
} else {
|
|
321
|
+
console.error(` ${c.dim}\u25EF ${s}${c.reset}`)
|
|
322
|
+
}
|
|
323
|
+
}
|
|
309
324
|
}
|
|
310
325
|
console.error('')
|
|
311
326
|
}
|
package/bin/ui/Banner.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { Box, Text } from 'ink'
|
|
3
3
|
import { Badge } from '@inkjs/ui'
|
|
4
|
-
import { ALL_STAGES, DEFAULT_STAGES, EXTRA_STAGES } from '../../metadata.js'
|
|
4
|
+
import { ALL_STAGES, DEFAULT_STAGES, EXTRA_STAGES, STAGE_HINTS, isLossy } from '../../metadata.js'
|
|
5
5
|
|
|
6
6
|
const h = React.createElement
|
|
7
7
|
|
|
@@ -34,7 +34,7 @@ export function Banner({ version, port, stages, llmLinguaUrl }) {
|
|
|
34
34
|
),
|
|
35
35
|
),
|
|
36
36
|
h(Text, null, ''),
|
|
37
|
-
h(Text, { bold: true }, `Stages `, h(Text, { dimColor: true }, `(${stages.length} active)`)),
|
|
37
|
+
h(Text, { bold: true }, `Stages `, h(Text, { dimColor: true }, `(${stages.length} of ${ALL_STAGES.length} active)`)),
|
|
38
38
|
h(Box, { paddingLeft: 2, flexDirection: 'column' },
|
|
39
39
|
...defaultActive.map(s =>
|
|
40
40
|
h(Text, { key: s },
|
|
@@ -47,13 +47,27 @@ export function Banner({ version, port, stages, llmLinguaUrl }) {
|
|
|
47
47
|
h(Text, { key: s },
|
|
48
48
|
h(Text, { color: 'yellow' }, '\u2713 '),
|
|
49
49
|
h(Text, { color: 'yellow' }, s),
|
|
50
|
-
h(Text, { dimColor: true }, ' (lossy)'),
|
|
50
|
+
h(Text, { dimColor: true }, isLossy(s) ? ' (lossy)' : ' (opt-in)'),
|
|
51
51
|
)
|
|
52
52
|
),
|
|
53
|
-
...(disabled.length && disabled.length <= 4
|
|
54
|
-
? [h(Text, { key: 'disabled', dimColor: true }, `\u2717 ${disabled.join(', ')}`)]
|
|
55
|
-
: []
|
|
56
|
-
),
|
|
57
53
|
),
|
|
54
|
+
disabled.length ? h(Text, null, '') : null,
|
|
55
|
+
disabled.length ? h(Text, { bold: true }, 'Available ', h(Text, { dimColor: true }, '(not active — opt in for more savings)')) : null,
|
|
56
|
+
disabled.length ? h(Box, { paddingLeft: 2, flexDirection: 'column' },
|
|
57
|
+
...disabled.flatMap(s => {
|
|
58
|
+
const hint = STAGE_HINTS[s]
|
|
59
|
+
const lines = [
|
|
60
|
+
h(Text, { key: s },
|
|
61
|
+
h(Text, { dimColor: true }, '\u25EF '),
|
|
62
|
+
h(Text, { color: 'cyan' }, s),
|
|
63
|
+
hint ? h(Text, { dimColor: true }, ` \u2014 ${hint.summary}`) : null,
|
|
64
|
+
)
|
|
65
|
+
]
|
|
66
|
+
if (hint?.setup) {
|
|
67
|
+
lines.push(h(Text, { key: s + '-setup', dimColor: true }, ` \u2192 ${hint.setup}`))
|
|
68
|
+
}
|
|
69
|
+
return lines
|
|
70
|
+
})
|
|
71
|
+
) : null,
|
|
58
72
|
)
|
|
59
73
|
}
|
package/metadata.js
CHANGED
|
@@ -27,6 +27,46 @@ export const ALL_STAGES = Object.freeze([
|
|
|
27
27
|
...EXTRA_STAGES,
|
|
28
28
|
])
|
|
29
29
|
|
|
30
|
+
// Stages that can drop or paraphrase content (semantic/neural/comment removal).
|
|
31
|
+
// `graph` is opt-in but fully lossless — it substitutes a reference marker for
|
|
32
|
+
// content the model has already seen earlier in the same session.
|
|
33
|
+
export const LOSSY_STAGES = Object.freeze(new Set([
|
|
34
|
+
'llmlingua',
|
|
35
|
+
'foundation-models',
|
|
36
|
+
'textpress',
|
|
37
|
+
'strip-comments',
|
|
38
|
+
]))
|
|
39
|
+
|
|
40
|
+
export function isLossy(stage) {
|
|
41
|
+
return LOSSY_STAGES.has(stage)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Hints shown in the banner when a stage is NOT active. summary describes
|
|
45
|
+
// the value the user is missing; setup is a copy-pasteable enable command
|
|
46
|
+
// (or null if the stage just needs TAMP_STAGES=...,<name>).
|
|
47
|
+
export const STAGE_HINTS = Object.freeze({
|
|
48
|
+
llmlingua: {
|
|
49
|
+
summary: 'neural text compression, +7-12% savings',
|
|
50
|
+
setup: 'install uv: curl -LsSf https://astral.sh/uv/install.sh | sh',
|
|
51
|
+
},
|
|
52
|
+
graph: {
|
|
53
|
+
summary: 'cross-request dedup, lossless, -99% on re-reads',
|
|
54
|
+
setup: 'TAMP_STAGES=...,graph',
|
|
55
|
+
},
|
|
56
|
+
'strip-comments': {
|
|
57
|
+
summary: 'remove code comments (lossy)',
|
|
58
|
+
setup: null,
|
|
59
|
+
},
|
|
60
|
+
textpress: {
|
|
61
|
+
summary: 'LLM semantic compression via Ollama/OpenRouter (lossy)',
|
|
62
|
+
setup: null,
|
|
63
|
+
},
|
|
64
|
+
'foundation-models': {
|
|
65
|
+
summary: 'Apple Intelligence neural (macOS 15+, lossy)',
|
|
66
|
+
setup: null,
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
|
|
30
70
|
export const STAGE_DESCRIPTIONS = Object.freeze({
|
|
31
71
|
minify: 'Strip JSON whitespace (lossless)',
|
|
32
72
|
toon: 'Columnar array encoding (lossless)',
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"stats.js",
|
|
13
13
|
"lib/"
|
|
14
14
|
],
|
|
15
|
-
"version": "0.5.
|
|
15
|
+
"version": "0.5.8",
|
|
16
16
|
"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.",
|
|
17
17
|
"type": "module",
|
|
18
18
|
"main": "index.js",
|
package/providers.js
CHANGED
|
@@ -50,6 +50,47 @@ function extractAnthropicMessageTargets(msg, mi) {
|
|
|
50
50
|
return targets
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
function getLastUserTextFromAnthropicMessages(messages) {
|
|
54
|
+
if (!Array.isArray(messages)) return null
|
|
55
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
56
|
+
const msg = messages[i]
|
|
57
|
+
if (msg?.role !== 'user') continue
|
|
58
|
+
if (typeof msg.content === 'string') return msg.content
|
|
59
|
+
if (Array.isArray(msg.content)) {
|
|
60
|
+
for (const b of msg.content) {
|
|
61
|
+
if (b?.type === 'text' && typeof b.text === 'string') return b.text
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return null
|
|
65
|
+
}
|
|
66
|
+
return null
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function appendToLastUserMessageAnthropic(messages, text) {
|
|
70
|
+
if (!Array.isArray(messages) || !text) return false
|
|
71
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
72
|
+
const msg = messages[i]
|
|
73
|
+
if (msg?.role !== 'user') continue
|
|
74
|
+
if (typeof msg.content === 'string') {
|
|
75
|
+
msg.content = msg.content + '\n\n' + text
|
|
76
|
+
return true
|
|
77
|
+
}
|
|
78
|
+
if (Array.isArray(msg.content)) {
|
|
79
|
+
for (let j = msg.content.length - 1; j >= 0; j--) {
|
|
80
|
+
const b = msg.content[j]
|
|
81
|
+
if (b?.type === 'text' && typeof b.text === 'string') {
|
|
82
|
+
b.text = b.text + '\n\n' + text
|
|
83
|
+
return true
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
msg.content.push({ type: 'text', text })
|
|
87
|
+
return true
|
|
88
|
+
}
|
|
89
|
+
return false
|
|
90
|
+
}
|
|
91
|
+
return false
|
|
92
|
+
}
|
|
93
|
+
|
|
53
94
|
const anthropic = {
|
|
54
95
|
name: 'anthropic',
|
|
55
96
|
match(method, url) {
|
|
@@ -66,6 +107,12 @@ const anthropic = {
|
|
|
66
107
|
apply(body, targets) {
|
|
67
108
|
applyTargets(body, targets)
|
|
68
109
|
},
|
|
110
|
+
getLastUserText(body) {
|
|
111
|
+
return getLastUserTextFromAnthropicMessages(body?.messages)
|
|
112
|
+
},
|
|
113
|
+
injectOutputHint(body, text) {
|
|
114
|
+
return appendToLastUserMessageAnthropic(body?.messages, text)
|
|
115
|
+
},
|
|
69
116
|
}
|
|
70
117
|
|
|
71
118
|
function extractOpenAIChatTargets(msg, i) {
|
|
@@ -103,6 +150,27 @@ const openai = {
|
|
|
103
150
|
apply(body, targets) {
|
|
104
151
|
applyTargets(body, targets)
|
|
105
152
|
},
|
|
153
|
+
getLastUserText(body) {
|
|
154
|
+
if (!body?.messages?.length) return null
|
|
155
|
+
for (let i = body.messages.length - 1; i >= 0; i--) {
|
|
156
|
+
const msg = body.messages[i]
|
|
157
|
+
if (msg?.role === 'user' && typeof msg.content === 'string') return msg.content
|
|
158
|
+
}
|
|
159
|
+
return null
|
|
160
|
+
},
|
|
161
|
+
injectOutputHint(body, text) {
|
|
162
|
+
if (!body?.messages?.length || !text) return false
|
|
163
|
+
for (let i = body.messages.length - 1; i >= 0; i--) {
|
|
164
|
+
const msg = body.messages[i]
|
|
165
|
+
if (msg?.role !== 'user') continue
|
|
166
|
+
if (typeof msg.content === 'string') {
|
|
167
|
+
msg.content = msg.content + '\n\n' + text
|
|
168
|
+
return true
|
|
169
|
+
}
|
|
170
|
+
return false
|
|
171
|
+
}
|
|
172
|
+
return false
|
|
173
|
+
},
|
|
106
174
|
}
|
|
107
175
|
|
|
108
176
|
function extractGeminiContentTargets(content, ci) {
|
|
@@ -138,6 +206,36 @@ const gemini = {
|
|
|
138
206
|
|
|
139
207
|
return body.contents.flatMap(extractGeminiContentTargets)
|
|
140
208
|
},
|
|
209
|
+
getLastUserText(body) {
|
|
210
|
+
if (!body?.contents?.length) return null
|
|
211
|
+
for (let i = body.contents.length - 1; i >= 0; i--) {
|
|
212
|
+
const c = body.contents[i]
|
|
213
|
+
if (c?.role && c.role !== 'user') continue
|
|
214
|
+
if (!Array.isArray(c?.parts)) continue
|
|
215
|
+
for (const p of c.parts) {
|
|
216
|
+
if (typeof p?.text === 'string') return p.text
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return null
|
|
220
|
+
},
|
|
221
|
+
injectOutputHint(body, text) {
|
|
222
|
+
if (!body?.contents?.length || !text) return false
|
|
223
|
+
for (let i = body.contents.length - 1; i >= 0; i--) {
|
|
224
|
+
const c = body.contents[i]
|
|
225
|
+
if (c?.role && c.role !== 'user') continue
|
|
226
|
+
if (!Array.isArray(c?.parts)) continue
|
|
227
|
+
for (let j = c.parts.length - 1; j >= 0; j--) {
|
|
228
|
+
const p = c.parts[j]
|
|
229
|
+
if (typeof p?.text === 'string') {
|
|
230
|
+
p.text = p.text + '\n\n' + text
|
|
231
|
+
return true
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
c.parts.push({ text })
|
|
235
|
+
return true
|
|
236
|
+
}
|
|
237
|
+
return false
|
|
238
|
+
},
|
|
141
239
|
apply(body, targets) {
|
|
142
240
|
for (const t of targets) {
|
|
143
241
|
if (t.skip || !t.compressed) continue
|
|
@@ -191,6 +289,34 @@ const openaiResponses = {
|
|
|
191
289
|
apply(body, targets) {
|
|
192
290
|
applyTargets(body, targets)
|
|
193
291
|
},
|
|
292
|
+
getLastUserText(body) {
|
|
293
|
+
if (!Array.isArray(body?.input) || !body.input.length) return null
|
|
294
|
+
for (let i = body.input.length - 1; i >= 0; i--) {
|
|
295
|
+
const item = body.input[i]
|
|
296
|
+
if (item?.role !== 'user' || !Array.isArray(item.content)) continue
|
|
297
|
+
for (const block of item.content) {
|
|
298
|
+
if (block?.type === 'input_text' && typeof block.text === 'string') return block.text
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return null
|
|
302
|
+
},
|
|
303
|
+
injectOutputHint(body, text) {
|
|
304
|
+
if (!Array.isArray(body?.input) || !body.input.length || !text) return false
|
|
305
|
+
for (let i = body.input.length - 1; i >= 0; i--) {
|
|
306
|
+
const item = body.input[i]
|
|
307
|
+
if (item?.role !== 'user' || !Array.isArray(item.content)) continue
|
|
308
|
+
for (let j = item.content.length - 1; j >= 0; j--) {
|
|
309
|
+
const block = item.content[j]
|
|
310
|
+
if (block?.type === 'input_text' && typeof block.text === 'string') {
|
|
311
|
+
block.text = block.text + '\n\n' + text
|
|
312
|
+
return true
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
item.content.push({ type: 'input_text', text })
|
|
316
|
+
return true
|
|
317
|
+
}
|
|
318
|
+
return false
|
|
319
|
+
},
|
|
194
320
|
}
|
|
195
321
|
|
|
196
322
|
const providers = [anthropic, openai, openaiResponses, gemini]
|