@trazum/core 1.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/LICENSE +21 -0
- package/README.md +163 -0
- package/dist/advisories.d.ts +23 -0
- package/dist/advisories.d.ts.map +1 -0
- package/dist/advisories.js +376 -0
- package/dist/advisories.js.map +1 -0
- package/dist/aws-sigv4.d.ts +88 -0
- package/dist/aws-sigv4.d.ts.map +1 -0
- package/dist/aws-sigv4.js +117 -0
- package/dist/aws-sigv4.js.map +1 -0
- package/dist/baseline.d.ts +171 -0
- package/dist/baseline.d.ts.map +1 -0
- package/dist/baseline.js +273 -0
- package/dist/baseline.js.map +1 -0
- package/dist/cache.d.ts +26 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +28 -0
- package/dist/cache.js.map +1 -0
- package/dist/changes.d.ts +29 -0
- package/dist/changes.d.ts.map +1 -0
- package/dist/changes.js +142 -0
- package/dist/changes.js.map +1 -0
- package/dist/compare.d.ts +65 -0
- package/dist/compare.d.ts.map +1 -0
- package/dist/compare.js +58 -0
- package/dist/compare.js.map +1 -0
- package/dist/config-schema.d.ts +118 -0
- package/dist/config-schema.d.ts.map +1 -0
- package/dist/config-schema.js +315 -0
- package/dist/config-schema.js.map +1 -0
- package/dist/config.d.ts +47 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +112 -0
- package/dist/config.js.map +1 -0
- package/dist/detect.d.ts +70 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +228 -0
- package/dist/detect.js.map +1 -0
- package/dist/evaluate.d.ts +98 -0
- package/dist/evaluate.d.ts.map +1 -0
- package/dist/evaluate.js +110 -0
- package/dist/evaluate.js.map +1 -0
- package/dist/extract.d.ts +81 -0
- package/dist/extract.d.ts.map +1 -0
- package/dist/extract.js +280 -0
- package/dist/extract.js.map +1 -0
- package/dist/gcp-auth.d.ts +58 -0
- package/dist/gcp-auth.d.ts.map +1 -0
- package/dist/gcp-auth.js +113 -0
- package/dist/gcp-auth.js.map +1 -0
- package/dist/glob.d.ts +49 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +154 -0
- package/dist/glob.js.map +1 -0
- package/dist/host.d.ts +30 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +69 -0
- package/dist/host.js.map +1 -0
- package/dist/i18n/en.d.ts +4 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +168 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/es.d.ts +4 -0
- package/dist/i18n/es.d.ts.map +1 -0
- package/dist/i18n/es.js +168 -0
- package/dist/i18n/es.js.map +1 -0
- package/dist/i18n/index.d.ts +36 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +50 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/types.d.ts +180 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +11 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/llm.d.ts +226 -0
- package/dist/llm.d.ts.map +1 -0
- package/dist/llm.js +485 -0
- package/dist/llm.js.map +1 -0
- package/dist/nearest.d.ts +20 -0
- package/dist/nearest.d.ts.map +1 -0
- package/dist/nearest.js +54 -0
- package/dist/nearest.js.map +1 -0
- package/dist/net.d.ts +90 -0
- package/dist/net.d.ts.map +1 -0
- package/dist/net.js +203 -0
- package/dist/net.js.map +1 -0
- package/dist/node.d.ts +32 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +33 -0
- package/dist/node.js.map +1 -0
- package/dist/openrouter.d.ts +25 -0
- package/dist/openrouter.d.ts.map +1 -0
- package/dist/openrouter.js +72 -0
- package/dist/openrouter.js.map +1 -0
- package/dist/optimize.d.ts +38 -0
- package/dist/optimize.d.ts.map +1 -0
- package/dist/optimize.js +183 -0
- package/dist/optimize.js.map +1 -0
- package/dist/otlp.d.ts +91 -0
- package/dist/otlp.d.ts.map +1 -0
- package/dist/otlp.js +102 -0
- package/dist/otlp.js.map +1 -0
- package/dist/phrases.d.ts +169 -0
- package/dist/phrases.d.ts.map +1 -0
- package/dist/phrases.js +939 -0
- package/dist/phrases.js.map +1 -0
- package/dist/pricing-overlay.d.ts +55 -0
- package/dist/pricing-overlay.d.ts.map +1 -0
- package/dist/pricing-overlay.js +241 -0
- package/dist/pricing-overlay.js.map +1 -0
- package/dist/pricing.d.ts +115 -0
- package/dist/pricing.d.ts.map +1 -0
- package/dist/pricing.js +400 -0
- package/dist/pricing.js.map +1 -0
- package/dist/profile.d.ts +71 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +55 -0
- package/dist/profile.js.map +1 -0
- package/dist/promptfoo.d.ts +58 -0
- package/dist/promptfoo.d.ts.map +1 -0
- package/dist/promptfoo.js +149 -0
- package/dist/promptfoo.js.map +1 -0
- package/dist/prune.d.ts +91 -0
- package/dist/prune.d.ts.map +1 -0
- package/dist/prune.js +110 -0
- package/dist/prune.js.map +1 -0
- package/dist/reorder.d.ts +82 -0
- package/dist/reorder.d.ts.map +1 -0
- package/dist/reorder.js +215 -0
- package/dist/reorder.js.map +1 -0
- package/dist/review.d.ts +54 -0
- package/dist/review.d.ts.map +1 -0
- package/dist/review.js +131 -0
- package/dist/review.js.map +1 -0
- package/dist/rules.d.ts +5 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/rules.js +279 -0
- package/dist/rules.js.map +1 -0
- package/dist/savings.d.ts +36 -0
- package/dist/savings.d.ts.map +1 -0
- package/dist/savings.js +83 -0
- package/dist/savings.js.map +1 -0
- package/dist/segment.d.ts +8 -0
- package/dist/segment.d.ts.map +1 -0
- package/dist/segment.js +74 -0
- package/dist/segment.js.map +1 -0
- package/dist/shared-prefix.d.ts +63 -0
- package/dist/shared-prefix.d.ts.map +1 -0
- package/dist/shared-prefix.js +151 -0
- package/dist/shared-prefix.js.map +1 -0
- package/dist/similarity.d.ts +13 -0
- package/dist/similarity.d.ts.map +1 -0
- package/dist/similarity.js +30 -0
- package/dist/similarity.js.map +1 -0
- package/dist/structure.d.ts +144 -0
- package/dist/structure.d.ts.map +1 -0
- package/dist/structure.js +455 -0
- package/dist/structure.js.map +1 -0
- package/dist/suggest.d.ts +100 -0
- package/dist/suggest.d.ts.map +1 -0
- package/dist/suggest.js +151 -0
- package/dist/suggest.js.map +1 -0
- package/dist/tokenizer.d.ts +57 -0
- package/dist/tokenizer.d.ts.map +1 -0
- package/dist/tokenizer.js +157 -0
- package/dist/tokenizer.js.map +1 -0
- package/dist/types.d.ts +296 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/walk.d.ts +40 -0
- package/dist/walk.d.ts.map +1 -0
- package/dist/walk.js +95 -0
- package/dist/walk.js.map +1 -0
- package/package.json +56 -0
- package/src/advisories.ts +431 -0
- package/src/aws-sigv4.ts +174 -0
- package/src/baseline.ts +390 -0
- package/src/cache.ts +54 -0
- package/src/changes.ts +158 -0
- package/src/compare.ts +131 -0
- package/src/config-schema.ts +451 -0
- package/src/config.ts +161 -0
- package/src/detect.ts +312 -0
- package/src/evaluate.ts +188 -0
- package/src/extract.ts +336 -0
- package/src/gcp-auth.ts +166 -0
- package/src/glob.ts +160 -0
- package/src/host.ts +90 -0
- package/src/i18n/en.ts +236 -0
- package/src/i18n/es.ts +236 -0
- package/src/i18n/index.ts +68 -0
- package/src/i18n/types.ts +230 -0
- package/src/index.ts +228 -0
- package/src/llm.ts +708 -0
- package/src/nearest.ts +61 -0
- package/src/net.ts +233 -0
- package/src/node.ts +63 -0
- package/src/openrouter.ts +125 -0
- package/src/optimize.ts +228 -0
- package/src/otlp.ts +179 -0
- package/src/phrases.ts +1047 -0
- package/src/pricing-overlay.ts +319 -0
- package/src/pricing.ts +468 -0
- package/src/profile.ts +124 -0
- package/src/promptfoo.ts +213 -0
- package/src/prune.ts +211 -0
- package/src/reorder.ts +307 -0
- package/src/review.ts +180 -0
- package/src/rules.ts +324 -0
- package/src/savings.ts +121 -0
- package/src/segment.ts +106 -0
- package/src/shared-prefix.ts +198 -0
- package/src/similarity.ts +28 -0
- package/src/structure.ts +652 -0
- package/src/suggest.ts +254 -0
- package/src/tokenizer.ts +190 -0
- package/src/types.ts +323 -0
- package/src/walk.ts +117 -0
package/dist/glob.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small, bounded glob matcher.
|
|
3
|
+
*
|
|
4
|
+
* Trazum has zero runtime dependencies and that is a security property, not a
|
|
5
|
+
* preference: a prompt optimiser reads your prompts, and every dependency is
|
|
6
|
+
* someone else's code doing that too. So the config file's budget patterns are
|
|
7
|
+
* matched here rather than by pulling in a glob library.
|
|
8
|
+
*
|
|
9
|
+
* **It is deliberately not a regex translation.** Turning `**` into
|
|
10
|
+
* `(?:[^/]*\/)*` produces exactly the nested-quantifier shape that makes a
|
|
11
|
+
* pattern take exponential time on the wrong input, and these patterns come
|
|
12
|
+
* from a file in a repository — which on a pull request means from whoever
|
|
13
|
+
* opened it. A segment-wise dynamic program has no such shape: it is O(pattern
|
|
14
|
+
* segments x path segments), and each segment match is O(pattern chars x path
|
|
15
|
+
* chars) with no backtracking beyond a single remembered star.
|
|
16
|
+
*
|
|
17
|
+
* Supported, and nothing else:
|
|
18
|
+
* `*` any run of characters within one path segment
|
|
19
|
+
* `**` any number of whole path segments, including none
|
|
20
|
+
* `?` exactly one character within one path segment
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Longest pattern and path this will consider.
|
|
24
|
+
*
|
|
25
|
+
* The matcher is quadratic in both, so a pattern nobody would write by hand is
|
|
26
|
+
* declined rather than allowed to spend the CI runner's afternoon. Both limits
|
|
27
|
+
* are far above any real prompt path.
|
|
28
|
+
*/
|
|
29
|
+
const MAX_PATTERN_LENGTH = 1024;
|
|
30
|
+
const MAX_PATH_LENGTH = 4096;
|
|
31
|
+
/** Normalises separators and strips the noise a hand-written path collects. */
|
|
32
|
+
function toSegments(value) {
|
|
33
|
+
return value
|
|
34
|
+
.replace(/\\/g, '/')
|
|
35
|
+
.split('/')
|
|
36
|
+
.filter((segment) => segment.length > 0 && segment !== '.');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Matches one path segment against one pattern segment (`*` and `?` only).
|
|
40
|
+
*
|
|
41
|
+
* Linear-with-backtracking over a single remembered star, which is the classic
|
|
42
|
+
* bounded algorithm: on a mismatch it retreats to the last star and advances
|
|
43
|
+
* the input by one, so the work is O(pattern x input) and never exponential.
|
|
44
|
+
*/
|
|
45
|
+
function matchSegment(pattern, value) {
|
|
46
|
+
let p = 0;
|
|
47
|
+
let v = 0;
|
|
48
|
+
let star = -1;
|
|
49
|
+
let mark = 0;
|
|
50
|
+
while (v < value.length) {
|
|
51
|
+
if (p < pattern.length && (pattern[p] === '?' || pattern[p] === value[v])) {
|
|
52
|
+
p++;
|
|
53
|
+
v++;
|
|
54
|
+
}
|
|
55
|
+
else if (p < pattern.length && pattern[p] === '*') {
|
|
56
|
+
star = p++;
|
|
57
|
+
mark = v;
|
|
58
|
+
}
|
|
59
|
+
else if (star >= 0) {
|
|
60
|
+
p = star + 1;
|
|
61
|
+
v = ++mark;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
while (p < pattern.length && pattern[p] === '*')
|
|
68
|
+
p++;
|
|
69
|
+
return p === pattern.length;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* True when `path` matches `pattern`.
|
|
73
|
+
*
|
|
74
|
+
* Both sides are treated as relative paths with `/` separators; a leading `./`
|
|
75
|
+
* and duplicate separators are ignored, and backslashes are read as separators
|
|
76
|
+
* so a Windows-shaped path still matches a pattern written with slashes.
|
|
77
|
+
*/
|
|
78
|
+
export function matchGlob(pattern, path) {
|
|
79
|
+
if (pattern.length > MAX_PATTERN_LENGTH || path.length > MAX_PATH_LENGTH)
|
|
80
|
+
return false;
|
|
81
|
+
const p = toSegments(pattern);
|
|
82
|
+
const s = toSegments(path);
|
|
83
|
+
// reachable[j] === true means "the first j pattern segments can consume the
|
|
84
|
+
// path segments seen so far". Walking the path once and updating this row is
|
|
85
|
+
// the whole algorithm; `**` is the only segment that can stay put.
|
|
86
|
+
let reachable = new Array(p.length + 1).fill(false);
|
|
87
|
+
reachable[0] = true;
|
|
88
|
+
// Leading `**` segments match nothing at all, so they are reachable up front.
|
|
89
|
+
for (let j = 0; j < p.length && p[j] === '**'; j++)
|
|
90
|
+
reachable[j + 1] = true;
|
|
91
|
+
for (const segment of s) {
|
|
92
|
+
const next = new Array(p.length + 1).fill(false);
|
|
93
|
+
for (let j = 0; j < p.length; j++) {
|
|
94
|
+
if (!reachable[j] && !(p[j] === '**' && next[j]))
|
|
95
|
+
continue;
|
|
96
|
+
if (p[j] === '**') {
|
|
97
|
+
// Consume this segment and stay on the same `**`, or step past it.
|
|
98
|
+
next[j] = true;
|
|
99
|
+
next[j + 1] = true;
|
|
100
|
+
}
|
|
101
|
+
else if (matchSegment(p[j], segment)) {
|
|
102
|
+
next[j + 1] = true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// A `**` that has just been stepped past may be followed by another one,
|
|
106
|
+
// which can also match nothing. Propagate that before moving on.
|
|
107
|
+
for (let j = 0; j < p.length; j++) {
|
|
108
|
+
if (next[j] && p[j] === '**')
|
|
109
|
+
next[j + 1] = true;
|
|
110
|
+
}
|
|
111
|
+
reachable = next;
|
|
112
|
+
}
|
|
113
|
+
return reachable[p.length] === true;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* How specific a pattern is, for deciding which of two matching patterns wins.
|
|
117
|
+
*
|
|
118
|
+
* "Most specific" needs a definition that is stated rather than felt, because
|
|
119
|
+
* a budget silently resolved from the wrong pattern is a budget nobody can
|
|
120
|
+
* debug. The rule: **more literal characters wins**, and a longer pattern
|
|
121
|
+
* breaks a tie. So `prompts/system.txt` beats `prompts/*.txt`, which beats
|
|
122
|
+
* `prompts/**`, which beats `**`.
|
|
123
|
+
*/
|
|
124
|
+
export function specificity(pattern) {
|
|
125
|
+
const literals = pattern.replace(/[*?]/g, '').length;
|
|
126
|
+
// The multiplier has to exceed every possible tie-breaker value, or the
|
|
127
|
+
// primary rule stops holding: at a multiplier of 1,000 a pattern with one
|
|
128
|
+
// literal and 1,024 characters scores the same as one with two literals and
|
|
129
|
+
// 24, and the stated "more literals wins" quietly becomes a coin toss.
|
|
130
|
+
return literals * (MAX_PATTERN_LENGTH + 1) + pattern.length;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The most specific pattern in `patterns` that matches `path`, or null.
|
|
134
|
+
*
|
|
135
|
+
* Ties on specificity are broken by lexical order rather than by insertion
|
|
136
|
+
* order: object key order is easy to reorder by accident, and a budget that
|
|
137
|
+
* changes because two keys swapped places is the kind of bug that gets blamed
|
|
138
|
+
* on the tool.
|
|
139
|
+
*/
|
|
140
|
+
export function mostSpecificMatch(patterns, path) {
|
|
141
|
+
let best = null;
|
|
142
|
+
let bestScore = -1;
|
|
143
|
+
for (const pattern of patterns) {
|
|
144
|
+
if (!matchGlob(pattern, path))
|
|
145
|
+
continue;
|
|
146
|
+
const score = specificity(pattern);
|
|
147
|
+
if (score > bestScore || (score === bestScore && best !== null && pattern < best)) {
|
|
148
|
+
best = pattern;
|
|
149
|
+
bestScore = score;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return best;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=glob.js.map
|
package/dist/glob.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;GAMG;AACH,MAAM,kBAAkB,GAAG,IAAI,CAAC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QAC/B,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC;YAAE,SAAS;QACxC,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,KAAK,GAAG,SAAS,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC;YAClF,IAAI,GAAG,OAAO,CAAC;YACf,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which tool Trazum is running inside.
|
|
3
|
+
*
|
|
4
|
+
* On the Node entry point rather than the browser-safe one, because it reads the
|
|
5
|
+
* process environment. Nothing about the optimisation changes with the answer —
|
|
6
|
+
* the same prompt optimises the same way everywhere, as it must, and that is a
|
|
7
|
+
* standing constraint rather than a coincidence.
|
|
8
|
+
*
|
|
9
|
+
* What the answer earns is the right to stop quoting a monthly dollar saving to
|
|
10
|
+
* somebody on a flat-rate plan. Inside Cursor or a Claude Code subscription the
|
|
11
|
+
* per-call saving is real arithmetic about tokens and **not money anybody gets
|
|
12
|
+
* back**, and "$184/month" is wrong in the direction that matters most.
|
|
13
|
+
*/
|
|
14
|
+
export interface HostEnvironment {
|
|
15
|
+
id: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
/**
|
|
18
|
+
* How the host bills.
|
|
19
|
+
*
|
|
20
|
+
* `unknown` is honest rather than lazy: a VS Code terminal says nothing about
|
|
21
|
+
* whether the prompts written in it go to a metered API or a subscription, and
|
|
22
|
+
* guessing either way would be worse than saying so.
|
|
23
|
+
*/
|
|
24
|
+
billing: 'per-token' | 'subscription' | 'unknown';
|
|
25
|
+
/** The variable that gave it away, so the answer is checkable rather than magic. */
|
|
26
|
+
evidence: string | null;
|
|
27
|
+
}
|
|
28
|
+
/** The host, or a plain terminal when nothing identifies itself. */
|
|
29
|
+
export declare function detectHost(env?: NodeJS.ProcessEnv): HostEnvironment;
|
|
30
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,OAAO,EAAE,WAAW,GAAG,cAAc,GAAG,SAAS,CAAC;IAClD,oFAAoF;IACpF,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAqDD,oEAAoE;AACpE,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,eAAe,CAQhF"}
|
package/dist/host.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which tool Trazum is running inside.
|
|
3
|
+
*
|
|
4
|
+
* On the Node entry point rather than the browser-safe one, because it reads the
|
|
5
|
+
* process environment. Nothing about the optimisation changes with the answer —
|
|
6
|
+
* the same prompt optimises the same way everywhere, as it must, and that is a
|
|
7
|
+
* standing constraint rather than a coincidence.
|
|
8
|
+
*
|
|
9
|
+
* What the answer earns is the right to stop quoting a monthly dollar saving to
|
|
10
|
+
* somebody on a flat-rate plan. Inside Cursor or a Claude Code subscription the
|
|
11
|
+
* per-call saving is real arithmetic about tokens and **not money anybody gets
|
|
12
|
+
* back**, and "$184/month" is wrong in the direction that matters most.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Hosts recognised by an environment variable they set.
|
|
16
|
+
*
|
|
17
|
+
* A miss is harmless: it falls through to `terminal` and nothing changes. That
|
|
18
|
+
* asymmetry is why the list can include entries verified only by documentation
|
|
19
|
+
* rather than by running under them — the cost of a wrong row is a detection
|
|
20
|
+
* that never fires, not a wrong report.
|
|
21
|
+
*
|
|
22
|
+
* Ordered most-specific first. Cursor is a VS Code fork and sets
|
|
23
|
+
* `TERM_PROGRAM=vscode` as well, so a VS Code row above it would swallow every
|
|
24
|
+
* Cursor session.
|
|
25
|
+
*/
|
|
26
|
+
const HOSTS = [
|
|
27
|
+
{
|
|
28
|
+
id: 'claude-code',
|
|
29
|
+
displayName: 'Claude Code',
|
|
30
|
+
billing: 'subscription',
|
|
31
|
+
test: (e) => (e.CLAUDECODE ? 'CLAUDECODE' : null),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'codex',
|
|
35
|
+
displayName: 'Codex',
|
|
36
|
+
billing: 'subscription',
|
|
37
|
+
test: (e) => (e.CODEX_SANDBOX ? 'CODEX_SANDBOX' : e.CODEX_HOME ? 'CODEX_HOME' : null),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'cursor',
|
|
41
|
+
displayName: 'Cursor',
|
|
42
|
+
billing: 'subscription',
|
|
43
|
+
test: (e) => (e.CURSOR_TRACE_ID ? 'CURSOR_TRACE_ID' : null),
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 'github-actions',
|
|
47
|
+
displayName: 'GitHub Actions',
|
|
48
|
+
billing: 'per-token',
|
|
49
|
+
test: (e) => (e.GITHUB_ACTIONS ? 'GITHUB_ACTIONS' : null),
|
|
50
|
+
},
|
|
51
|
+
{ id: 'ci', displayName: 'CI', billing: 'per-token', test: (e) => (e.CI ? 'CI' : null) },
|
|
52
|
+
{
|
|
53
|
+
id: 'vscode',
|
|
54
|
+
displayName: 'VS Code',
|
|
55
|
+
billing: 'unknown',
|
|
56
|
+
test: (e) => (e.TERM_PROGRAM === 'vscode' ? 'TERM_PROGRAM' : null),
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
/** The host, or a plain terminal when nothing identifies itself. */
|
|
60
|
+
export function detectHost(env = process.env) {
|
|
61
|
+
for (const host of HOSTS) {
|
|
62
|
+
const evidence = host.test(env);
|
|
63
|
+
if (evidence !== null) {
|
|
64
|
+
return { id: host.id, displayName: host.displayName, billing: host.billing, evidence };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return { id: 'terminal', displayName: 'terminal', billing: 'unknown', evidence: null };
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=host.js.map
|
package/dist/host.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAiBH;;;;;;;;;;;GAWG;AACH,MAAM,KAAK,GAKN;IACH;QACE,EAAE,EAAE,aAAa;QACjB,WAAW,EAAE,aAAa;QAC1B,OAAO,EAAE,cAAc;QACvB,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;KAClD;IACD;QACE,EAAE,EAAE,OAAO;QACX,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,cAAc;QACvB,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;KACtF;IACD;QACE,EAAE,EAAE,QAAQ;QACZ,WAAW,EAAE,QAAQ;QACrB,OAAO,EAAE,cAAc;QACvB,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC;KAC5D;IACD;QACE,EAAE,EAAE,gBAAgB;QACpB,WAAW,EAAE,gBAAgB;QAC7B,OAAO,EAAE,WAAW;QACpB,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,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AiF;AACjF,eAAO,MAAM,EAAE,EAAE,YAsOhB,CAAC"}
|
package/dist/i18n/en.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
const n = (value) => value.toLocaleString('en-US');
|
|
2
|
+
/** English catalogue. This is the source of truth every other locale mirrors. */
|
|
3
|
+
export const en = {
|
|
4
|
+
locale: 'en',
|
|
5
|
+
numberLocale: 'en-US',
|
|
6
|
+
rules: {
|
|
7
|
+
'duplicate-blocks': {
|
|
8
|
+
title: 'Repeated paragraphs',
|
|
9
|
+
rationale: 'Removes whole paragraphs that already appear earlier in the prompt. Common when prompts are assembled by concatenating templates: the same block of instructions goes in twice and is paid for twice.',
|
|
10
|
+
},
|
|
11
|
+
'near-duplicate-blocks': {
|
|
12
|
+
title: 'Near-identical paragraphs',
|
|
13
|
+
rationale: 'Removes paragraphs sharing 92% or more of their words with an earlier one, catching instructions reworded to say the same thing twice. Aggressive level: read the diff, because the 8% that differs may be exactly the nuance you cared about.',
|
|
14
|
+
},
|
|
15
|
+
'duplicate-lines': {
|
|
16
|
+
title: 'Repeated lines',
|
|
17
|
+
rationale: 'Removes lines identical to one that appeared earlier, ignoring case, accents and punctuation. Only touches lines of 25 characters or more, so bullets and legitimate separators survive.',
|
|
18
|
+
},
|
|
19
|
+
'verbose-phrases': {
|
|
20
|
+
title: 'Wordy phrasing',
|
|
21
|
+
rationale: 'Replaces long constructions with their short equivalent ("in order to" → "to", "con el fin de" → "para"). The meaning is identical; only the token count changes.',
|
|
22
|
+
},
|
|
23
|
+
politeness: {
|
|
24
|
+
title: 'Politeness formulas',
|
|
25
|
+
rationale: 'Strips "please", "thank you", "kindly", "por favor"... The model does not answer better for being asked nicely, and every formula is paid for on every call.',
|
|
26
|
+
},
|
|
27
|
+
filler: {
|
|
28
|
+
title: 'Filler and throat-clearing',
|
|
29
|
+
rationale: 'Removes empty openers such as "basically", "it is important to note that" or "cabe destacar que", which carry no instruction.',
|
|
30
|
+
},
|
|
31
|
+
hedges: {
|
|
32
|
+
title: 'Hedging',
|
|
33
|
+
rationale: 'Removes "I think", "in my opinion", "creo que". Inside an instruction they weaken the request without adding information.',
|
|
34
|
+
},
|
|
35
|
+
intensifiers: {
|
|
36
|
+
title: 'Intensifiers',
|
|
37
|
+
rationale: 'Strips "very", "really", "extremely", "muy"... They rarely change the task. Aggressive level because in a specific prompt the nuance can matter.',
|
|
38
|
+
},
|
|
39
|
+
'self-check': {
|
|
40
|
+
title: 'Self-verification instructions',
|
|
41
|
+
rationale: 'Removes "double-check your work", "verifica tu respuesta". Current models already verify their own output; asking explicitly triggers extra steps paid for in output tokens. Disable this rule if your workflow depends on that verification.',
|
|
42
|
+
},
|
|
43
|
+
emphasis: {
|
|
44
|
+
title: 'Shouted emphasis',
|
|
45
|
+
rationale: 'Lowercases shouted words (MUST, NEVER, CRITICAL) and drops prefixes like "IMPORTANT:". Uppercase splits into more tokens than lowercase, and on current models excessive emphasis makes the instruction over-trigger.',
|
|
46
|
+
},
|
|
47
|
+
decoration: {
|
|
48
|
+
title: 'Decorative separators',
|
|
49
|
+
rationale: 'Removes lines made only of repeated characters (====, ----, ****) and runs of exclamation marks. They add no structure the model uses and cost tokens on every call.',
|
|
50
|
+
},
|
|
51
|
+
whitespace: {
|
|
52
|
+
title: 'Stray whitespace',
|
|
53
|
+
rationale: 'Trims trailing spaces, collapses repeated spaces inside a line and reduces consecutive blank lines to one. Leading indentation is preserved so lists and nested markdown keep working.',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
llm: {
|
|
57
|
+
emptyResponse: () => 'The model returned an empty response.',
|
|
58
|
+
protectedContentAltered: (count) => `The model altered ${count} protected fragment(s) (code, URL or template placeholder). Discarded so the prompt is not broken.`,
|
|
59
|
+
notShorter: (after, before) => `The result is not shorter (${after} vs ${before} tokens). Keeping the deterministic version.`,
|
|
60
|
+
suspiciousShrink: (retainedPct) => `The result keeps only ${retainedPct}% of the tokens. That looks like a summary rather than compression: review it by hand before using it.`,
|
|
61
|
+
},
|
|
62
|
+
suggest: {
|
|
63
|
+
'not-found': () => 'the quoted phrase is not in the prompt — the model paraphrased what it was copying',
|
|
64
|
+
'touches-protected': () => 'it would edit code, a URL, a placeholder or a tag, which are copied verbatim',
|
|
65
|
+
'introduces-protected': () => 'the replacement adds a placeholder or URL that was not there',
|
|
66
|
+
'no-saving': () => 'it is no shorter than what it replaces',
|
|
67
|
+
overlaps: () => 'it shares text with a suggestion already accepted',
|
|
68
|
+
},
|
|
69
|
+
advisories: {
|
|
70
|
+
contextOverflow: ({ tokens, modelName, contextWindow }) => ({
|
|
71
|
+
title: 'The prompt does not fit in the context window',
|
|
72
|
+
detail: `The optimised prompt is ~${n(tokens)} tokens and ${modelName} accepts ${n(contextWindow)}. The call will fail: split the content or move to a model with a larger window.`,
|
|
73
|
+
}),
|
|
74
|
+
promptCaching: ({ placeholder, prefixTokens, totalTokens, minTokens, modelName, hitRatePct, readPct, writePct, explicit, }) => {
|
|
75
|
+
const scope = placeholder
|
|
76
|
+
? `The stable prefix — everything before the first placeholder ${placeholder} — is ~${n(prefixTokens)} of the prompt's ${n(totalTokens)} tokens, and clears ${modelName}'s ${n(minTokens)}-token cacheable minimum.`
|
|
77
|
+
: `The prompt has no variable placeholders, so the whole thing is a cacheable prefix and it clears ${modelName}'s ${n(minTokens)}-token minimum.`;
|
|
78
|
+
const how = explicit
|
|
79
|
+
? 'Put the cache marker at the end of the stable prefix: any byte that changes before the cut invalidates everything after it.'
|
|
80
|
+
: `${modelName} caches automatically above its minimum, so there is nothing to set — but the same rule applies: any byte that changes before the cut invalidates everything after it.`;
|
|
81
|
+
return {
|
|
82
|
+
title: 'Turn on prompt caching for the stable prefix',
|
|
83
|
+
detail: `${scope} At a ${hitRatePct}% hit rate, a cache read costs ${readPct}% of the input price and a write costs ${writePct}%. ${how}`,
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
promptCachingNotWorthIt: () => ({
|
|
87
|
+
title: 'At that hit rate, caching does not pay off',
|
|
88
|
+
detail: 'A cache write costs 125% of the input price and a read costs 10%. Below roughly a 28% hit rate you pay more than you save. Either raise prefix reuse or leave caching off.',
|
|
89
|
+
}),
|
|
90
|
+
belowCacheMinimum: ({ modelName, minTokens, placeholder, prefixTokens, totalTokens, mentionLowerMinimum, }) => {
|
|
91
|
+
const reason = placeholder
|
|
92
|
+
? `here the first variable placeholder (${placeholder}) shows up at ~${n(prefixTokens)} tokens and only what precedes it can be cached`
|
|
93
|
+
: `this prompt has ~${n(totalTokens)}`;
|
|
94
|
+
return {
|
|
95
|
+
title: 'Below the cacheable minimum',
|
|
96
|
+
detail: `${modelName} needs at least ${n(minTokens)} prefix tokens to cache; ${reason}. Setting cache_control will not error, it simply will not cache.` +
|
|
97
|
+
(mentionLowerMinimum
|
|
98
|
+
? ' Claude Opus 5 lowers that minimum to 512 tokens, so short prompts that miss here would cache there.'
|
|
99
|
+
: ''),
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
cachePrefixReorder: ({ staticTokensAfter, sharePct, placeholder }) => ({
|
|
103
|
+
title: 'Move the stable instructions ahead of the first placeholder',
|
|
104
|
+
detail: `About ~${n(staticTokensAfter)} tokens of stable content (${sharePct}% of the prompt) sit after the first variable placeholder ${placeholder}, so today they never get cached. Reorder the template — fixed instructions and context first, placeholders last — and that content starts being read from cache at 10% of the price. Check that reordering does not change what the prompt asks for.`,
|
|
105
|
+
}),
|
|
106
|
+
batchApi: () => ({
|
|
107
|
+
title: 'If the work tolerates latency, use the Batch API',
|
|
108
|
+
detail: 'The Batch API applies a 50% discount on both input and output. Most batches finish in under an hour, with a 24-hour maximum. It fits bulk classification, data enrichment or evaluations: anything that is not answering a user in real time.',
|
|
109
|
+
}),
|
|
110
|
+
modelDowngrade: ({ modelName, tier, candidateName, currentUsd, candidateUsd }) => ({
|
|
111
|
+
title: `This task may not need ${modelName}`,
|
|
112
|
+
detail: `By length and vocabulary the prompt looks like "${tier}" complexity. On ${candidateName} you would go from ${currentUsd} to ${candidateUsd} per month. This is a keyword heuristic, not a judgement about answer quality: measure the difference with your own evaluations before switching in production.`,
|
|
113
|
+
}),
|
|
114
|
+
outputDominated: ({ outputUsd, inputUsd }) => ({
|
|
115
|
+
title: 'Your cost is in the output, not the prompt',
|
|
116
|
+
detail: `Output accounts for ${outputUsd} per month against ${inputUsd} of input. Shortening the prompt has a low ceiling here. The two controls that move the needle are the effort parameter (lower it when the task is not reasoning-heavy) and explicitly asking for concise answers.`,
|
|
117
|
+
}),
|
|
118
|
+
promoPricing: ({ modelName, promoInput, promoOutput, until, listInput, listOutput }) => ({
|
|
119
|
+
title: 'You are costing this with promotional pricing',
|
|
120
|
+
detail: `${modelName} has introductory pricing of ${promoInput}/${promoOutput} per million tokens until ${until}. After that date it moves to ${listInput}/${listOutput}: your bill goes up even if you change nothing.`,
|
|
121
|
+
}),
|
|
122
|
+
contradictoryInstructions: ({ axis, firstValue, firstSnippet, secondValue, secondSnippet, otherCount, }) => ({
|
|
123
|
+
title: `Two instructions disagree about ${axis}`,
|
|
124
|
+
detail: `One says ${firstValue} ("${firstSnippet}") and another says ${secondValue} ("${secondSnippet}"). ` +
|
|
125
|
+
'The model has to pick one, and which one it picks can change between calls — so this is a correctness problem before it is a cost one. ' +
|
|
126
|
+
'Deleting the instruction you did not mean also shortens the prompt.' +
|
|
127
|
+
(otherCount > 0
|
|
128
|
+
? ` ${otherCount} other ${otherCount === 1 ? 'pair' : 'pairs'} of instructions disagree too.`
|
|
129
|
+
: ''),
|
|
130
|
+
}),
|
|
131
|
+
redundantExamples: ({ redundantCount, totalCount, redundantTokens, topSimilarityPct }) => ({
|
|
132
|
+
title: `${redundantCount} of ${totalCount} examples repeat an earlier one`,
|
|
133
|
+
detail: `They share ${topSimilarityPct}% or more of their wording with an example that comes before them, and account for about ${n(redundantTokens)} tokens paid for on every call. ` +
|
|
134
|
+
'Few-shot examples earn their cost by teaching something new; two that demonstrate the same pattern teach it once. ' +
|
|
135
|
+
'Read them before deleting: an example that looks redundant may be showing a boundary case on purpose.',
|
|
136
|
+
}),
|
|
137
|
+
movableSchema: ({ blocks, tokens, keyList, cue }) => ({
|
|
138
|
+
title: 'The output schema could travel in the request instead of the prompt',
|
|
139
|
+
detail: `${blocks === 1 ? 'A schema block' : `${blocks} schema blocks`} introduced by "${cue}" defines ${keyList}, costing about ${n(tokens)} tokens on every call. ` +
|
|
140
|
+
'Every major API now takes a response schema as a request parameter — output_config.format, response_format, responseSchema — and moving it there is the rare change that is both cheaper and stricter: prose asks the model to comply, a parameter makes the decoder comply. ' +
|
|
141
|
+
'Trazum cannot make this edit, because it changes the call rather than the prompt, and it does not check whether your provider offers the parameter — if it does not, this is not available to you.',
|
|
142
|
+
}),
|
|
143
|
+
restatedOutputFormat: ({ restatedCount, totalCount, restatedTokens, keyList }) => ({
|
|
144
|
+
title: 'The output format is specified twice',
|
|
145
|
+
detail: `The prose describes ${restatedCount} of the ${totalCount} fields your schema already defines (${keyList}), costing about ${n(restatedTokens)} tokens on every call. ` +
|
|
146
|
+
'The code block is the version worth keeping: it is unambiguous, and Trazum never edits it. ' +
|
|
147
|
+
'Check the two agree before deleting either — when a prompt says one thing in prose and another in its schema, the prose is usually the one that went stale.',
|
|
148
|
+
}),
|
|
149
|
+
},
|
|
150
|
+
contradictionAxes: {
|
|
151
|
+
'response-language': 'the language of the answer',
|
|
152
|
+
'output-format': 'the output format',
|
|
153
|
+
'response-length': 'how long the answer should be',
|
|
154
|
+
'reasoning-visibility': 'whether to show the reasoning',
|
|
155
|
+
},
|
|
156
|
+
contradictionValues: {
|
|
157
|
+
'fixed-language': 'always the same language',
|
|
158
|
+
'mirror-language': "the reader's own language",
|
|
159
|
+
'format-json': 'JSON',
|
|
160
|
+
'format-markdown': 'Markdown',
|
|
161
|
+
'format-plain-text': 'plain text',
|
|
162
|
+
'length-brief': 'keep it brief',
|
|
163
|
+
'length-detailed': 'go into detail',
|
|
164
|
+
'reasoning-shown': 'show the reasoning',
|
|
165
|
+
'reasoning-hidden': 'hide the reasoning',
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=en.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en.js","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AAEnE,iFAAiF;AACjF,MAAM,CAAC,MAAM,EAAE,GAAiB;IAC9B,MAAM,EAAE,IAAI;IACZ,YAAY,EAAE,OAAO;IAErB,KAAK,EAAE;QACL,kBAAkB,EAAE;YAClB,KAAK,EAAE,qBAAqB;YAC5B,SAAS,EACP,uMAAuM;SAC1M;QACD,uBAAuB,EAAE;YACvB,KAAK,EAAE,2BAA2B;YAClC,SAAS,EACP,gPAAgP;SACnP;QACD,iBAAiB,EAAE;YACjB,KAAK,EAAE,gBAAgB;YACvB,SAAS,EACP,0LAA0L;SAC7L;QACD,iBAAiB,EAAE;YACjB,KAAK,EAAE,gBAAgB;YACvB,SAAS,EACP,mKAAmK;SACtK;QACD,UAAU,EAAE;YACV,KAAK,EAAE,qBAAqB;YAC5B,SAAS,EACP,8JAA8J;SACjK;QACD,MAAM,EAAE;YACN,KAAK,EAAE,4BAA4B;YACnC,SAAS,EACP,+HAA+H;SAClI;QACD,MAAM,EAAE;YACN,KAAK,EAAE,SAAS;YAChB,SAAS,EACP,2HAA2H;SAC9H;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,cAAc;YACrB,SAAS,EACP,kJAAkJ;SACrJ;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,gCAAgC;YACvC,SAAS,EACP,+OAA+O;SAClP;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,kBAAkB;YACzB,SAAS,EACP,uNAAuN;SAC1N;QACD,UAAU,EAAE;YACV,KAAK,EAAE,uBAAuB;YAC9B,SAAS,EACP,sKAAsK;SACzK;QACD,UAAU,EAAE;YACV,KAAK,EAA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