@sliday/tamp 0.5.9 → 0.8.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 +80 -13
- package/bin/lifecycle.js +16 -4
- package/bin/tamp.js +149 -6
- package/bin/ui/App.js +11 -3
- package/bin/ui/Banner.js +16 -6
- package/bin/ui/LevelPicker.js +107 -0
- package/compress.js +160 -6
- package/config.js +177 -21
- package/detect.js +10 -0
- package/index.js +105 -14
- package/lib/bm25.js +194 -0
- package/lib/br-cache.js +157 -0
- package/lib/disclosure.js +124 -0
- package/lib/path-extract.js +49 -0
- package/lib/read-cache.js +55 -0
- package/lib/rewriters/commands/cargo.js +50 -0
- package/lib/rewriters/commands/docker.js +54 -0
- package/lib/rewriters/commands/git.js +81 -0
- package/lib/rewriters/commands/jest.js +49 -0
- package/lib/rewriters/commands/npm.js +82 -0
- package/lib/rewriters/commands/pip.js +58 -0
- package/lib/rewriters/commands/prisma.js +50 -0
- package/lib/rewriters/commands/pytest.js +55 -0
- package/lib/rewriters/commands/terraform.js +49 -0
- package/lib/rewriters/commands/wget-curl.js +67 -0
- package/lib/rewriters/index.js +77 -0
- package/lib/rules-generator.js +45 -2
- package/metadata.js +90 -5
- package/package.json +5 -3
- package/providers.js +281 -4
- package/session-graph.js +36 -3
- package/stats.js +12 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Targets:
|
|
2
|
+
// curl -O/-o <url>, curl <url>
|
|
3
|
+
// wget <url>
|
|
4
|
+
//
|
|
5
|
+
// Strips: the "% Total ... Time ... Current" header block and all mid-download
|
|
6
|
+
// percentage rows from curl; the tick-mark ASCII bar + per-line percentage
|
|
7
|
+
// rows from wget; leaves the final summary row / "100%" tail line intact.
|
|
8
|
+
// Keeps: final size/time summary, error lines, HTTP response headers if
|
|
9
|
+
// requested (-v / --verbose are untouched — we only match the download grid).
|
|
10
|
+
|
|
11
|
+
const CURL_HEADER = /^\s*%\s+Total\s+%\s+Received/;
|
|
12
|
+
const CURL_SECOND_HEADER = /^\s+Dload\s+Upload/;
|
|
13
|
+
const CURL_ROW = /^\s*\d{1,3}\s+\d[\d.kKMmGgTt]*\s+\d{1,3}\s+\d[\d.kKMmGgTt]*\s+\d+\s+\d+\s+\d[\d.kKMmGgTt]*\s+\d+\s+/;
|
|
14
|
+
const WGET_PROGRESS = /^\s*\d{1,3}%\s*\[[=> .]+\]/;
|
|
15
|
+
const WGET_TICKS = /^\s*[\d,]+[KMG]?\s+[.=]+\s+\d+%/;
|
|
16
|
+
const WGET_SIG = /(^|\n)(--\d{4}-\d{2}-\d{2}|Resolving |Connecting to |HTTP request sent|Length: |Saving to: )/;
|
|
17
|
+
const CURL_SIG = /(^|\n)\s*%\s+Total\s+%\s+Received/;
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
name: 'wget-curl',
|
|
21
|
+
|
|
22
|
+
match(text) {
|
|
23
|
+
if (typeof text !== 'string' || text.length === 0) return false;
|
|
24
|
+
return CURL_SIG.test(text) || WGET_SIG.test(text);
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
rewrite(text) {
|
|
28
|
+
if (!text) return text;
|
|
29
|
+
const lines = text.split('\n');
|
|
30
|
+
const out = [];
|
|
31
|
+
let lastCurlRow = null;
|
|
32
|
+
|
|
33
|
+
for (const line of lines) {
|
|
34
|
+
if (CURL_HEADER.test(line)) continue;
|
|
35
|
+
if (CURL_SECOND_HEADER.test(line)) continue;
|
|
36
|
+
if (WGET_PROGRESS.test(line)) continue;
|
|
37
|
+
if (WGET_TICKS.test(line)) continue;
|
|
38
|
+
|
|
39
|
+
if (CURL_ROW.test(line)) {
|
|
40
|
+
// Keep only the final row (last one seen) — buffer it.
|
|
41
|
+
lastCurlRow = line;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (lastCurlRow !== null) {
|
|
46
|
+
// Flush the last curl row right before the next non-row line.
|
|
47
|
+
out.push(lastCurlRow);
|
|
48
|
+
lastCurlRow = null;
|
|
49
|
+
}
|
|
50
|
+
out.push(line);
|
|
51
|
+
}
|
|
52
|
+
if (lastCurlRow !== null) out.push(lastCurlRow);
|
|
53
|
+
|
|
54
|
+
const collapsed = [];
|
|
55
|
+
let blank = 0;
|
|
56
|
+
for (const l of out) {
|
|
57
|
+
if (l.trim() === '') {
|
|
58
|
+
blank++;
|
|
59
|
+
if (blank > 1) continue;
|
|
60
|
+
} else {
|
|
61
|
+
blank = 0;
|
|
62
|
+
}
|
|
63
|
+
collapsed.push(l);
|
|
64
|
+
}
|
|
65
|
+
return collapsed.join('\n');
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Per-command stdout rewriters for the `cmd-strip` stage.
|
|
2
|
+
// Each rewriter module lives in ./commands/<name>.js and exports:
|
|
3
|
+
// { name, match(text) -> bool, rewrite(text) -> string }
|
|
4
|
+
//
|
|
5
|
+
// Priority order is frozen — most specific signatures first so that a noisy
|
|
6
|
+
// output like `npm install` never gets eaten by a looser matcher.
|
|
7
|
+
|
|
8
|
+
import npm from './commands/npm.js';
|
|
9
|
+
import pip from './commands/pip.js';
|
|
10
|
+
import cargo from './commands/cargo.js';
|
|
11
|
+
import docker from './commands/docker.js';
|
|
12
|
+
import prisma from './commands/prisma.js';
|
|
13
|
+
import terraform from './commands/terraform.js';
|
|
14
|
+
import git from './commands/git.js';
|
|
15
|
+
import pytest from './commands/pytest.js';
|
|
16
|
+
import jest from './commands/jest.js';
|
|
17
|
+
import wgetCurl from './commands/wget-curl.js';
|
|
18
|
+
|
|
19
|
+
const REGISTRY = Object.freeze({
|
|
20
|
+
npm,
|
|
21
|
+
pip,
|
|
22
|
+
cargo,
|
|
23
|
+
docker,
|
|
24
|
+
prisma,
|
|
25
|
+
terraform,
|
|
26
|
+
git,
|
|
27
|
+
pytest,
|
|
28
|
+
jest,
|
|
29
|
+
'wget-curl': wgetCurl,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export const PRIORITY = Object.freeze([
|
|
33
|
+
'npm',
|
|
34
|
+
'pip',
|
|
35
|
+
'cargo',
|
|
36
|
+
'docker',
|
|
37
|
+
'prisma',
|
|
38
|
+
'terraform',
|
|
39
|
+
'git',
|
|
40
|
+
'pytest',
|
|
41
|
+
'jest',
|
|
42
|
+
'wget-curl',
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
export function getRewriter(name) {
|
|
46
|
+
if (!name) return null;
|
|
47
|
+
return REGISTRY[name] || null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function rewriteCommandOutput(text) {
|
|
51
|
+
if (typeof text !== 'string' || text.length === 0) {
|
|
52
|
+
return { text: text ?? '', rewriter: null, savedBytes: 0 };
|
|
53
|
+
}
|
|
54
|
+
for (const name of PRIORITY) {
|
|
55
|
+
const mod = REGISTRY[name];
|
|
56
|
+
if (!mod) continue;
|
|
57
|
+
let hit = false;
|
|
58
|
+
try {
|
|
59
|
+
hit = !!mod.match(text);
|
|
60
|
+
} catch {
|
|
61
|
+
hit = false;
|
|
62
|
+
}
|
|
63
|
+
if (!hit) continue;
|
|
64
|
+
let out = text;
|
|
65
|
+
try {
|
|
66
|
+
out = mod.rewrite(text);
|
|
67
|
+
} catch {
|
|
68
|
+
out = text;
|
|
69
|
+
}
|
|
70
|
+
if (typeof out !== 'string') out = text;
|
|
71
|
+
const savedBytes = Math.max(0, Buffer.byteLength(text, 'utf8') - Buffer.byteLength(out, 'utf8'));
|
|
72
|
+
return { text: out, rewriter: mod.name || name, savedBytes };
|
|
73
|
+
}
|
|
74
|
+
return { text, rewriter: null, savedBytes: 0 };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default { getRewriter, rewriteCommandOutput, PRIORITY };
|
package/lib/rules-generator.js
CHANGED
|
@@ -25,6 +25,34 @@ const DANGEROUS_TASK_PATTERNS = [
|
|
|
25
25
|
/test|spec|coverage/i,
|
|
26
26
|
]
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Per-agent rule overrides. Keyed by `config.agent` (lowercased short name).
|
|
30
|
+
* Shape: { <agent>: { safe?: string, dangerous?: string, complex?: string, conservative?: string } }
|
|
31
|
+
*
|
|
32
|
+
* Hook: populate these tables to tune phrasing per agent. A missing entry
|
|
33
|
+
* falls through to the shared rules. Codex CLI's post-processor already
|
|
34
|
+
* strips explanations, so we use terser phrasing there — other agents get
|
|
35
|
+
* the default rules until we have evidence they benefit from variants.
|
|
36
|
+
*/
|
|
37
|
+
export const PER_AGENT_OVERRIDES = Object.freeze({
|
|
38
|
+
codex: {
|
|
39
|
+
safe: `## Token-Efficient Output (Balanced / Codex)
|
|
40
|
+
- Code only. No prose, no preamble, no summary.
|
|
41
|
+
- Single-line status after the change (e.g., "done", "noop").
|
|
42
|
+
`,
|
|
43
|
+
complex: `## Token-Efficient Output (Balanced / Codex)
|
|
44
|
+
- Terse bullets. No filler sentences.
|
|
45
|
+
- Skip "Here's what I'll do" intros — just do it.
|
|
46
|
+
- Return code first; explanation only if non-obvious.
|
|
47
|
+
`,
|
|
48
|
+
},
|
|
49
|
+
// Intentionally empty — add overrides here if evidence warrants it.
|
|
50
|
+
cursor: {},
|
|
51
|
+
cline: {},
|
|
52
|
+
aider: {},
|
|
53
|
+
'claude-code': {},
|
|
54
|
+
})
|
|
55
|
+
|
|
28
56
|
/**
|
|
29
57
|
* Detect task type from user message
|
|
30
58
|
* @param {string} userMessage - User's input message
|
|
@@ -49,6 +77,15 @@ export function detectTaskType(userMessage) {
|
|
|
49
77
|
return 'complex'
|
|
50
78
|
}
|
|
51
79
|
|
|
80
|
+
/**
|
|
81
|
+
* True if the user's latest message matches a DANGEROUS_TASK_PATTERNS entry.
|
|
82
|
+
* Used by lossy stages (e.g., disclosure) to bypass when the task demands
|
|
83
|
+
* full fidelity (security/debug/refactor/test).
|
|
84
|
+
*/
|
|
85
|
+
export function isDangerousTask(userMessage) {
|
|
86
|
+
return detectTaskType(userMessage) === 'dangerous'
|
|
87
|
+
}
|
|
88
|
+
|
|
52
89
|
/**
|
|
53
90
|
* Output compression intensity levels
|
|
54
91
|
*/
|
|
@@ -83,14 +120,16 @@ export const OUTPUT_MODES = Object.freeze({
|
|
|
83
120
|
* Generate optimized CLAUDE.md rules for output compression
|
|
84
121
|
* @param {string} mode - Output mode (conservative | balanced | aggressive)
|
|
85
122
|
* @param {string} taskType - Task type (safe | dangerous | complex)
|
|
123
|
+
* @param {string} [agent] - Optional agent name for per-agent overrides
|
|
86
124
|
* @returns {string} - Optimized CLAUDE.md rules text
|
|
87
125
|
*/
|
|
88
|
-
export function generateOutputRules(mode = 'balanced', taskType = 'complex') {
|
|
126
|
+
export function generateOutputRules(mode = 'balanced', taskType = 'complex', agent) {
|
|
89
127
|
const modeConfig = OUTPUT_MODES[mode] || OUTPUT_MODES.balanced
|
|
90
128
|
|
|
91
129
|
// Conservative mode always generates minimal rules (for all task types)
|
|
92
130
|
if (mode === 'conservative') {
|
|
93
|
-
|
|
131
|
+
const override = agent && PER_AGENT_OVERRIDES[agent]?.conservative
|
|
132
|
+
return override || generateConservativeRules()
|
|
94
133
|
}
|
|
95
134
|
|
|
96
135
|
// Determine if we should compress based on mode + task type
|
|
@@ -105,6 +144,10 @@ export function generateOutputRules(mode = 'balanced', taskType = 'complex') {
|
|
|
105
144
|
return ''
|
|
106
145
|
}
|
|
107
146
|
|
|
147
|
+
// Check per-agent override for this (agent, taskType) pair
|
|
148
|
+
const override = agent && PER_AGENT_OVERRIDES[agent]?.[taskType]
|
|
149
|
+
if (override) return override
|
|
150
|
+
|
|
108
151
|
// Generate rules based on mode
|
|
109
152
|
const rules = {
|
|
110
153
|
balanced: generateBalancedRules(taskType),
|
package/metadata.js
CHANGED
|
@@ -5,6 +5,7 @@ const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url),
|
|
|
5
5
|
export const VERSION = pkg.version
|
|
6
6
|
|
|
7
7
|
export const DEFAULT_STAGES = Object.freeze([
|
|
8
|
+
'cmd-strip',
|
|
8
9
|
'minify',
|
|
9
10
|
'toon',
|
|
10
11
|
'strip-lines',
|
|
@@ -12,6 +13,7 @@ export const DEFAULT_STAGES = Object.freeze([
|
|
|
12
13
|
'llmlingua',
|
|
13
14
|
'dedup',
|
|
14
15
|
'diff',
|
|
16
|
+
'read-diff',
|
|
15
17
|
'prune',
|
|
16
18
|
])
|
|
17
19
|
|
|
@@ -20,6 +22,9 @@ export const EXTRA_STAGES = Object.freeze([
|
|
|
20
22
|
'textpress',
|
|
21
23
|
'foundation-models',
|
|
22
24
|
'graph',
|
|
25
|
+
'br-cache',
|
|
26
|
+
'disclosure',
|
|
27
|
+
'bm25-trim',
|
|
23
28
|
])
|
|
24
29
|
|
|
25
30
|
export const ALL_STAGES = Object.freeze([
|
|
@@ -29,12 +34,18 @@ export const ALL_STAGES = Object.freeze([
|
|
|
29
34
|
|
|
30
35
|
// Stages that can drop or paraphrase content (semantic/neural/comment removal).
|
|
31
36
|
// `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.
|
|
37
|
+
// content the model has already seen earlier in the same session. `br-cache`
|
|
38
|
+
// is also lossless: it's a disk-backed store for large bodies, not a rewriter.
|
|
39
|
+
// `disclosure` IS lossy: it drops body content from the outgoing turn and
|
|
40
|
+
// relies on the model quoting the marker to trigger rehydration next turn.
|
|
41
|
+
// `bm25-trim` drops low-relevance lines from huge tool_results (lossy).
|
|
33
42
|
export const LOSSY_STAGES = Object.freeze(new Set([
|
|
34
43
|
'llmlingua',
|
|
35
44
|
'foundation-models',
|
|
36
45
|
'textpress',
|
|
37
46
|
'strip-comments',
|
|
47
|
+
'disclosure',
|
|
48
|
+
'bm25-trim',
|
|
38
49
|
]))
|
|
39
50
|
|
|
40
51
|
export function isLossy(stage) {
|
|
@@ -53,6 +64,10 @@ export const STAGE_HINTS = Object.freeze({
|
|
|
53
64
|
summary: 'cross-request dedup, lossless, -99% on re-reads',
|
|
54
65
|
setup: 'TAMP_STAGES=...,graph',
|
|
55
66
|
},
|
|
67
|
+
'read-diff': {
|
|
68
|
+
summary: 'replace re-reads with diffs, lossless, -80% on common flows',
|
|
69
|
+
setup: 'enabled by default in balanced preset',
|
|
70
|
+
},
|
|
56
71
|
'strip-comments': {
|
|
57
72
|
summary: 'remove code comments (lossy)',
|
|
58
73
|
setup: null,
|
|
@@ -65,9 +80,22 @@ export const STAGE_HINTS = Object.freeze({
|
|
|
65
80
|
summary: 'Apple Intelligence neural (macOS 15+, lossy)',
|
|
66
81
|
setup: null,
|
|
67
82
|
},
|
|
83
|
+
'br-cache': {
|
|
84
|
+
summary: 'Brotli disk cache, persists across sessions, enables Phase 5 disclosure',
|
|
85
|
+
setup: 'TAMP_STAGES=...,br-cache',
|
|
86
|
+
},
|
|
87
|
+
disclosure: {
|
|
88
|
+
summary: 'progressive disclosure for >32KB tool_results, model can quote hash to expand',
|
|
89
|
+
setup: 'TAMP_STAGES=...,disclosure (requires br-cache)',
|
|
90
|
+
},
|
|
91
|
+
'bm25-trim': {
|
|
92
|
+
summary: 'query-aware line ranking, preserves first+last, bypasses dangerous tasks',
|
|
93
|
+
setup: 'TAMP_STAGES=...,bm25-trim',
|
|
94
|
+
},
|
|
68
95
|
})
|
|
69
96
|
|
|
70
97
|
export const STAGE_DESCRIPTIONS = Object.freeze({
|
|
98
|
+
'cmd-strip': 'Strip progress bars and spinners from command output (lossless)',
|
|
71
99
|
minify: 'Strip JSON whitespace (lossless)',
|
|
72
100
|
toon: 'Columnar array encoding (lossless)',
|
|
73
101
|
'strip-lines': 'Remove line-number prefixes',
|
|
@@ -76,32 +104,89 @@ export const STAGE_DESCRIPTIONS = Object.freeze({
|
|
|
76
104
|
'foundation-models': 'Apple Intelligence neural compression (macOS 15+, Apple Silicon, 100% local)',
|
|
77
105
|
dedup: 'Deduplicate identical tool_results',
|
|
78
106
|
diff: 'Replace similar re-reads with diffs',
|
|
107
|
+
'read-diff': 'Session-scoped unified diff for re-reads (lossless, opt-in)',
|
|
79
108
|
prune: 'Strip lockfile hashes & npm metadata',
|
|
80
109
|
'strip-comments': 'Remove code comments (lossy)',
|
|
81
110
|
textpress: 'LLM semantic compression (Ollama/OpenRouter)',
|
|
82
111
|
graph: 'Session-scoped dedup across requests (lossless, opt-in)',
|
|
112
|
+
'br-cache': 'Disk-backed Brotli store for large tool_results (lossless, opt-in)',
|
|
113
|
+
disclosure: '3-tier summary for huge tool_results with on-demand rehydration (lossy, aggressive-only)',
|
|
114
|
+
'bm25-trim': 'Drop low-relevance lines from huge tool_results via BM25 (lossy, aggressive-only)',
|
|
83
115
|
})
|
|
84
116
|
|
|
85
117
|
export const COMPRESSION_PRESETS = Object.freeze({
|
|
86
118
|
conservative: {
|
|
87
119
|
name: 'Conservative',
|
|
88
120
|
description: 'Safe, lossless compression only',
|
|
89
|
-
stages: ['minify', 'toon', 'strip-lines', 'whitespace', 'dedup', 'diff'],
|
|
121
|
+
stages: ['cmd-strip', 'minify', 'toon', 'strip-lines', 'whitespace', 'dedup', 'diff'],
|
|
90
122
|
expectedSavings: '45-50%',
|
|
91
123
|
risk: 'None',
|
|
124
|
+
level: 4,
|
|
92
125
|
},
|
|
93
126
|
balanced: {
|
|
94
127
|
name: 'Balanced',
|
|
95
128
|
description: 'Default, includes semantic compression',
|
|
96
|
-
stages: ['minify', 'toon', 'strip-lines', 'whitespace', 'llmlingua', 'dedup', 'diff', 'prune'],
|
|
129
|
+
stages: ['cmd-strip', 'minify', 'toon', 'strip-lines', 'whitespace', 'llmlingua', 'dedup', 'diff', 'read-diff', 'prune'],
|
|
97
130
|
expectedSavings: '52-58%',
|
|
98
131
|
risk: 'Low',
|
|
132
|
+
level: 5,
|
|
99
133
|
},
|
|
100
134
|
aggressive: {
|
|
101
135
|
name: 'Aggressive',
|
|
102
136
|
description: 'Maximum compression, lossy stages enabled',
|
|
103
|
-
stages: ['minify', 'toon', 'strip-lines', 'whitespace', 'llmlingua', 'dedup', 'diff', 'prune', 'strip-comments', 'textpress'],
|
|
104
|
-
expectedSavings: '
|
|
137
|
+
stages: ['cmd-strip', 'minify', 'toon', 'strip-lines', 'whitespace', 'llmlingua', 'dedup', 'diff', 'read-diff', 'prune', 'strip-comments', 'textpress', 'br-cache', 'disclosure', 'bm25-trim'],
|
|
138
|
+
expectedSavings: '65-72%',
|
|
105
139
|
risk: 'Medium (may lose comments, verbose text)',
|
|
140
|
+
level: 8,
|
|
106
141
|
},
|
|
107
142
|
})
|
|
143
|
+
|
|
144
|
+
// Flat 1..9 compression ladder, parallel to the named presets. Each level
|
|
145
|
+
// extends the previous level's stage list (prefix-preserving). L4/L5/L8 are
|
|
146
|
+
// set-equal to conservative/balanced/aggressive respectively; L6-L7 interpolate
|
|
147
|
+
// between balanced and aggressive; L9 extends past aggressive (max).
|
|
148
|
+
//
|
|
149
|
+
// NOTE: `lossy` goes true at L5 because `llmlingua` lives in the balanced
|
|
150
|
+
// preset (= L5). The ladder is aligned to preset semantics per spec.
|
|
151
|
+
function extend(base, adds) { return Object.freeze([...base, ...adds]) }
|
|
152
|
+
|
|
153
|
+
const L1_STAGES = extend([], ['minify'])
|
|
154
|
+
const L2_STAGES = extend(L1_STAGES, ['whitespace', 'strip-lines'])
|
|
155
|
+
const L3_STAGES = extend(L2_STAGES, ['cmd-strip'])
|
|
156
|
+
const L4_STAGES = extend(L3_STAGES, ['toon', 'dedup', 'diff'])
|
|
157
|
+
const L5_STAGES = extend(L4_STAGES, ['llmlingua', 'read-diff', 'prune'])
|
|
158
|
+
const L6_STAGES = extend(L5_STAGES, ['strip-comments'])
|
|
159
|
+
const L7_STAGES = extend(L6_STAGES, ['textpress', 'br-cache'])
|
|
160
|
+
const L8_STAGES = extend(L7_STAGES, ['disclosure', 'bm25-trim'])
|
|
161
|
+
const L9_STAGES = extend(L8_STAGES, ['graph', 'foundation-models'])
|
|
162
|
+
|
|
163
|
+
export const COMPRESSION_LEVELS = Object.freeze({
|
|
164
|
+
1: Object.freeze({ stages: L1_STAGES, lossy: false, savings: '~15%' }),
|
|
165
|
+
2: Object.freeze({ stages: L2_STAGES, lossy: false, savings: '~25%' }),
|
|
166
|
+
3: Object.freeze({ stages: L3_STAGES, lossy: false, savings: '~35%' }),
|
|
167
|
+
4: Object.freeze({ stages: L4_STAGES, lossy: false, savings: '~45%' }),
|
|
168
|
+
5: Object.freeze({ stages: L5_STAGES, lossy: true, savings: '~53%' }),
|
|
169
|
+
6: Object.freeze({ stages: L6_STAGES, lossy: true, savings: '~58%' }),
|
|
170
|
+
7: Object.freeze({ stages: L7_STAGES, lossy: true, savings: '~62%' }),
|
|
171
|
+
8: Object.freeze({ stages: L8_STAGES, lossy: true, savings: '~67%' }),
|
|
172
|
+
9: Object.freeze({ stages: L9_STAGES, lossy: true, savings: '~72%' }),
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
export const DEFAULT_LEVEL = 5
|
|
176
|
+
|
|
177
|
+
export const LEVEL_ALIASES = Object.freeze({
|
|
178
|
+
conservative: 4,
|
|
179
|
+
balanced: 5,
|
|
180
|
+
aggressive: 8,
|
|
181
|
+
max: 9,
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
export function resolveLevel(input) {
|
|
185
|
+
if (typeof input === 'number' && Number.isInteger(input) && input >= 1 && input <= 9) {
|
|
186
|
+
return COMPRESSION_LEVELS[input]
|
|
187
|
+
}
|
|
188
|
+
if (typeof input === 'string' && input in LEVEL_ALIASES) {
|
|
189
|
+
return COMPRESSION_LEVELS[LEVEL_ALIASES[input]]
|
|
190
|
+
}
|
|
191
|
+
return null
|
|
192
|
+
}
|
package/package.json
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"stats.js",
|
|
13
13
|
"lib/"
|
|
14
14
|
],
|
|
15
|
-
"version": "0.
|
|
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.",
|
|
15
|
+
"version": "0.8.0",
|
|
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 and per-command rewriters.",
|
|
17
17
|
"type": "module",
|
|
18
18
|
"main": "index.js",
|
|
19
19
|
"bin": {
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"test": "node --test test/*.test.js",
|
|
25
25
|
"test:sidecar": "node test/capture-golden.js --verify",
|
|
26
26
|
"bench:semantic": "node bench/semantic-eval.js",
|
|
27
|
-
"test:quality": "node bench/quality-eval.js"
|
|
27
|
+
"test:quality": "node bench/quality-eval.js",
|
|
28
|
+
"compat:probe": "node test/compat/probe-proxy.js",
|
|
29
|
+
"compat:run": "node test/compat/run.mjs"
|
|
28
30
|
},
|
|
29
31
|
"keywords": [
|
|
30
32
|
"claude",
|