@trazum/cli 1.29.0 → 1.30.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/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +10 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +10 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/types.d.ts +20 -0
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/index.js +56 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/i18n/en.ts +15 -0
- package/src/i18n/es.ts +15 -0
- package/src/i18n/types.ts +20 -0
- package/src/index.ts +69 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { readdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { join, resolve as resolvePath } from 'node:path';
|
|
4
4
|
import { gunzipSync } from 'node:zlib';
|
|
5
|
-
import { applyRewrites, BASELINE_FILENAME, BASELINE_VERSION, breaches, cacheableMinimum, analyzeCachePrefix, billLevers, cacheEconomics, cacheHitRate, contextPressure, comparePrompts, compareToBaseline, computeSavings, countTokensAnthropic, DEFAULT_USAGE, detectFromSource, driversBetween, estimateTokens, evaluate, extractPrompts, findExamples, formatBaseline, formatSignedUsd, formatUsd, getMessages, getModel, hasMarker, LOCALES, MAX_BASELINE_BYTES, moneyIsComparable, mostSpecificMatch, nearestName, optimize, parseBaseline, PHRASE_LANGUAGES, plannedCalls, profilePrompt, profileToCsv, profileUsage, promptId, providerFromEnv, pruneExamples, refineWithLlm, rejectionText, reorderForCache, repriceProfile, reviewAgeDays, reviewExamples, RULES, sharedPrefixes, sharesOf, SOURCE_EXTENSIONS, suggestRewrites, toOtlpMetrics, toPromptfoo, TTL_1H_MS, UNLABELLED, withExactTokenCounts, } from '@trazum/core';
|
|
5
|
+
import { applyRewrites, BASELINE_FILENAME, BASELINE_VERSION, breaches, cacheableMinimum, analyzeCachePrefix, billLevers, cacheEconomics, cacheHitRate, contextPressure, comparePrompts, compareToBaseline, computeSavings, countTokensAnthropic, DEFAULT_USAGE, detectFromSource, coverageDrift, driversBetween, estimateTokens, evaluate, extractPrompts, findExamples, formatBaseline, formatSignedUsd, formatUsd, getMessages, getModel, hasMarker, LOCALES, MAX_BASELINE_BYTES, moneyIsComparable, mostSpecificMatch, nearestName, optimize, parseBaseline, PHRASE_LANGUAGES, plannedCalls, profilePrompt, profileToCsv, profileUsage, promptId, providerFromEnv, pruneExamples, refineWithLlm, rejectionText, reorderForCache, repriceProfile, reviewAgeDays, reviewExamples, RULES, sharedPrefixes, sharesOf, SOURCE_EXTENSIONS, suggestRewrites, toOtlpMetrics, toPromptfoo, TTL_1H_MS, UNLABELLED, withExactTokenCounts, } from '@trazum/core';
|
|
6
6
|
import { cacheDir, cacheStats, cachingProvider, clearCache } from './suggest-cache.js';
|
|
7
7
|
import { dayOf, formatGap, median, spanDays } from './time.js';
|
|
8
8
|
// Everything that reads the filesystem, on its own entry point so the web
|
|
@@ -1791,7 +1791,27 @@ async function commandProfile(args, config, pricing, t) {
|
|
|
1791
1791
|
}
|
|
1792
1792
|
if (typeof args.flags.get('max-growth-usd') === 'string' && againstDelta !== null) {
|
|
1793
1793
|
const maxGrowth = numberFlag(args, 'max-growth-usd', 0, t);
|
|
1794
|
-
|
|
1794
|
+
/**
|
|
1795
|
+
* A comparison that went blind fails before it is judged.
|
|
1796
|
+
*
|
|
1797
|
+
* The dollars can hold flat while the current log stopped recording a
|
|
1798
|
+
* field the previous one carried — and every finding that needed the
|
|
1799
|
+
* field is now silent for a reason that has nothing to do with spend.
|
|
1800
|
+
* A gate passing there would be certifying a comparison it could not
|
|
1801
|
+
* make: "not measured" is not "did not grow", the same refusal
|
|
1802
|
+
* --max-day-usd makes on a clockless log and --max-session-usd on a
|
|
1803
|
+
* sessionless one. Only a collapse fails; a field that appeared means
|
|
1804
|
+
* this side can see more, which is never a reason to refuse.
|
|
1805
|
+
*/
|
|
1806
|
+
const blinded = previous !== null
|
|
1807
|
+
? coverageDrift(previous.fieldCoverage, report.fieldCoverage).filter((d) => d.delta < 0)
|
|
1808
|
+
: [];
|
|
1809
|
+
const worst = blinded[0];
|
|
1810
|
+
if (worst !== undefined) {
|
|
1811
|
+
console.error(c.red(t.profile.maxGrowthCoverageLost(blinded.map((d) => t.profile.coverageField(d.field)).join(', '), pct(worst.was), pct(worst.now))));
|
|
1812
|
+
process.exitCode = 1;
|
|
1813
|
+
}
|
|
1814
|
+
else if (againstDelta > maxGrowth) {
|
|
1795
1815
|
console.error(c.red(t.profile.maxGrowthUsdFailed(formatSignedUsd(againstDelta), formatUsd(maxGrowth))));
|
|
1796
1816
|
process.exitCode = 1;
|
|
1797
1817
|
}
|
|
@@ -2945,6 +2965,40 @@ async function commandProfile(args, config, pricing, t) {
|
|
|
2945
2965
|
console.log(` ${d.delta > 0 ? c.yellow(line) : c.dim(line)}`);
|
|
2946
2966
|
}
|
|
2947
2967
|
}
|
|
2968
|
+
/**
|
|
2969
|
+
* What the comparison stopped being able to see.
|
|
2970
|
+
*
|
|
2971
|
+
* Every figure above is dollars, and dollars cannot tell a finding that
|
|
2972
|
+
* was fixed from a finding whose field the log stopped recording — both
|
|
2973
|
+
* are silence. This is the only section that can, so it is loud: a
|
|
2974
|
+
* collapse in coverage invalidates whichever findings depended on it,
|
|
2975
|
+
* and reading the drop as good news is the specific mistake it exists
|
|
2976
|
+
* to prevent.
|
|
2977
|
+
*/
|
|
2978
|
+
const drifts = coverageDrift(previous.fieldCoverage, report.fieldCoverage);
|
|
2979
|
+
if (drifts.length > 0) {
|
|
2980
|
+
console.log();
|
|
2981
|
+
for (const drift of drifts) {
|
|
2982
|
+
const line = t.profile.coverageDrift(t.profile.coverageField(drift.field), pct(drift.was), pct(drift.now));
|
|
2983
|
+
console.log(drift.delta < 0
|
|
2984
|
+
? ` ${c.yellow('!')} ${c.bold(wrap(line, 74, ' '))}`
|
|
2985
|
+
: ` ${c.dim(wrap(line, 74, ' '))}`);
|
|
2986
|
+
/**
|
|
2987
|
+
* Which findings went with it, named. "Some findings are silent" is
|
|
2988
|
+
* not something a reader can act on; knowing that conversation
|
|
2989
|
+
* growth and the cache-TTL fit are now silence rather than absence
|
|
2990
|
+
* tells them exactly which sections of this report to distrust.
|
|
2991
|
+
*/
|
|
2992
|
+
if (drift.delta < 0) {
|
|
2993
|
+
const silenced = t.profile.coverageSilenced(drift.field);
|
|
2994
|
+
if (silenced !== '')
|
|
2995
|
+
console.log(` ${c.dim(wrap(silenced, 72, ' '))}`);
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
if (drifts.some((d) => d.delta < 0)) {
|
|
2999
|
+
console.log(` ${c.dim(wrap(t.profile.coverageDriftWhy(), 74, ' '))}`);
|
|
3000
|
+
}
|
|
3001
|
+
}
|
|
2948
3002
|
}
|
|
2949
3003
|
}
|
|
2950
3004
|
for (const [heading, rows] of [
|