@trazum/cli 1.56.2 → 1.60.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/index.js CHANGED
@@ -4,7 +4,7 @@ import { open, readdir, readFile, stat, writeFile } from 'node:fs/promises';
4
4
  import { dirname, join, resolve as resolvePath } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { gunzipSync } from 'node:zlib';
7
- import { CONTRACT_NAMES, applyRewrites, BASELINE_FILENAME, BASELINE_VERSION, breaches, cacheableMinimum, analyzeCachePrefix, billLevers, bucketedCacheEconomics, bucketedProfile, buildHistory, buildPlan, connectorFor, CONNECTORS, normalizeAnthropicUsage, normalizeOpenAIUsage, bucketsFromRecords, evaluateWatch, firedKey, pruneRecords, recordsFromBuckets, storeInventory, storedReportFrom, verifyPlan, cacheEconomics, cacheHitRate, contextPressure, comparePrompts, compareToBaseline, computeSavings, bandGoverns, countTokensAnthropic, DEFAULT_USAGE, budgetPositions, conform, BREAK_EVEN_BAND, allocate, annualRecord, replayCommitment, coversTheTerm, runExperiment, qualityGate, semanticPassCost, verifySemanticProposals, SEMANTIC_SYSTEM_PROMPT, ladderPosition, validateLadder, outcomeReport, rankPerOutcome, FAILURE_POLICIES, detectFromSource, matchLocale, parsePlanDocument, waiverDay, waiverHistory, proposeInit, MIN_RATE_DAYS, parseConfig, coverageDrift, driversBetween, explainGateFailure, assignSources, fleetRollup, rollUp, heartbeats, ruleYield, labelCoverage, measuredUsage, gateMargin, GATE_MARGIN_TIGHT, estimateTokens, evaluate, extractPrompts, findExamples, formatBaseline, formatSignedUsd, formatUsd, getMessages, getModel, hasMarker, LOCALES, MAX_BASELINE_BYTES, moneyIsComparable, mostSpecificMatch, nearestName, optimize, parseBaseline, PHRASE_LANGUAGES, languagesWithStanding, 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';
7
+ import { CONTRACT_NAMES, applyRewrites, BASELINE_FILENAME, BASELINE_VERSION, breaches, cacheableMinimum, analyzeCachePrefix, billLevers, bucketedCacheEconomics, bucketedProfile, buildHistory, buildPlan, connectorFor, CONNECTORS, normalizeAnthropicUsage, normalizeOpenAIUsage, bucketsFromRecords, evaluateWatch, firedKey, pruneRecords, recordsFromBuckets, storeInventory, storedReportFrom, verifyPlan, cacheEconomics, cacheHitRate, contextPressure, comparePrompts, compareToBaseline, computeSavings, bandGoverns, countTokensAnthropic, DEFAULT_USAGE, budgetPositions, conform, BREAK_EVEN_BAND, allocate, annualRecord, replayCommitment, coversTheTerm, runExperiment, qualityGate, semanticPassCost, verifySemanticProposals, SEMANTIC_SYSTEM_PROMPT, ladderPosition, validateLadder, outcomeReport, rankPerOutcome, FAILURE_POLICIES, detectFromSource, matchLocale, parsePlanDocument, waiverDay, waiverHistory, proposeInit, MIN_RATE_DAYS, parseConfig, coverageDrift, driversBetween, explainGateFailure, assignSources, fleetRollup, rollUp, heartbeats, ruleYield, labelCoverage, measuredUsage, gateMargin, GATE_MARGIN_TIGHT, estimateTokens, evaluate, extractPrompts, findExamples, formatBaseline, formatSignedUsd, formatUsd, getMessages, getModel, hasMarker, LOCALES, MAX_BASELINE_BYTES, moneyIsComparable, mostSpecificMatch, nearestName, optimize, parseBaseline, PHRASE_LANGUAGES, detectTextLanguage, dictionaryStanding, languagesWithStanding, 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';
8
8
  import { cacheDir, cacheStats, cachingProvider, clearCache } from './suggest-cache.js';
9
9
  import { dayOf, formatGap, median, spanDays } from './time.js';
10
10
  // Everything that reads the filesystem, on its own entry point so the web
@@ -569,6 +569,25 @@ measured = null) {
569
569
  if (result.rules.length > 0) {
570
570
  console.log();
571
571
  console.log(c.bold(t.report.rulesApplied()));
572
+ /**
573
+ * Whose judgement just edited this prompt.
574
+ *
575
+ * Five of the seven dictionaries were written without anybody who reads the
576
+ * language agreeing to an entry, and the branch where that matters most is
577
+ * this one: the rules did not stay silent, they changed somebody's text.
578
+ * The coverage line under `nothingToTrim` cannot cover it — by then the
579
+ * prompt is untouched.
580
+ *
581
+ * Gated on the prompt's own detected language, so an English or Spanish
582
+ * prompt never sees it and it never becomes a footer. `detectTextLanguage`
583
+ * answers null on a short or mixed prompt, and this stays silent then:
584
+ * not-detected is not not-unreviewed, and guessing the language in order to
585
+ * warn about it would be the same overreach the detector exists to refuse.
586
+ */
587
+ const promptLanguage = detectTextLanguage(result.original);
588
+ if (promptLanguage !== null && dictionaryStanding(promptLanguage)?.standing === 'unreviewed') {
589
+ console.log(c.yellow(t.report.dictionaryAppliedUnreviewed(t.languages[promptLanguage] ?? promptLanguage)));
590
+ }
572
591
  for (const rule of result.rules) {
573
592
  const tag = rule.level === 'aggressive'
574
593
  ? c.yellow(t.report.levelAggressive())
@@ -1268,6 +1287,7 @@ async function commandInit(args, config, pricing, t) {
1268
1287
  const host = detectHost();
1269
1288
  const prompts = await walkPrompts(root, {
1270
1289
  extensions: config.extensions ?? DEFAULT_EXTENSIONS,
1290
+ ignore: config.ignore,
1271
1291
  });
1272
1292
  /**
1273
1293
  * Source files, read only to be asked which provider they call.
@@ -1281,6 +1301,7 @@ async function commandInit(args, config, pricing, t) {
1281
1301
  const sourceWalk = await walkPrompts(root, {
1282
1302
  extensions: SOURCE_EXTENSIONS,
1283
1303
  maxFiles: INIT_MAX_SOURCE_FILES,
1304
+ ignore: config.ignore,
1284
1305
  });
1285
1306
  const sightings = [];
1286
1307
  for (const relative of sourceWalk.files) {
@@ -2823,7 +2844,7 @@ async function commandRulesMeasure(args, config, pricing, t) {
2823
2844
  if (level !== 'safe' && level !== 'aggressive')
2824
2845
  throw new Error(t.errors.badLevel(level));
2825
2846
  const extensions = config.extensions ?? [...DEFAULT_EXTENSIONS, ...SOURCE_EXTENSIONS];
2826
- const { files, truncated } = await walkPrompts(root, { extensions });
2847
+ const { files, truncated } = await walkPrompts(root, { extensions, ignore: config.ignore });
2827
2848
  if (files.length === 0)
2828
2849
  throw new Error(t.errors.noPromptsFound(root, extensions.join(' ')));
2829
2850
  const prompts = [];
@@ -6837,7 +6858,7 @@ async function scanPrompts(root, args, flagBudget, config, counter, level, t, lo
6837
6858
  // to be fully implemented and completely undiscoverable; an unmarked source
6838
6859
  // file costs one `includes()` and is dropped.
6839
6860
  const extensions = config.extensions ?? [...DEFAULT_EXTENSIONS, ...SOURCE_EXTENSIONS];
6840
- const { files, truncated } = await walkPrompts(root, { extensions });
6861
+ const { files, truncated } = await walkPrompts(root, { extensions, ignore: config.ignore });
6841
6862
  if (files.length === 0) {
6842
6863
  throw new Error(t.errors.noPromptsFound(root, extensions.join(' ')));
6843
6864
  }
@@ -7631,7 +7652,7 @@ async function commandRank(args, config, pricing, t, locale) {
7631
7652
  const level = levelFlag(args, config, t);
7632
7653
  const usage = usageFrom(args, config, t);
7633
7654
  const extensions = config.extensions ?? [...DEFAULT_EXTENSIONS, ...SOURCE_EXTENSIONS];
7634
- const { files, truncated } = await walkPrompts(root, { extensions });
7655
+ const { files, truncated } = await walkPrompts(root, { extensions, ignore: config.ignore });
7635
7656
  if (files.length === 0) {
7636
7657
  throw new Error(t.errors.noPromptsFound(root, extensions.join(' ')));
7637
7658
  }
@@ -8021,7 +8042,7 @@ async function commandDoctor(args, config, pricing, t, locale) {
8021
8042
  const level = levelFlag(args, config, t);
8022
8043
  const usage = usageFrom(args, config, t);
8023
8044
  const extensions = config.extensions ?? [...DEFAULT_EXTENSIONS, ...SOURCE_EXTENSIONS];
8024
- const { files, truncated } = await walkPrompts(root, { extensions });
8045
+ const { files, truncated } = await walkPrompts(root, { extensions, ignore: config.ignore });
8025
8046
  if (files.length === 0) {
8026
8047
  throw new Error(t.errors.noPromptsFound(root, extensions.join(' ')));
8027
8048
  }
@@ -8245,8 +8266,8 @@ async function diffDirectories(beforeRoot, afterRoot, args, config, pricing, t,
8245
8266
  const optimizeBoth = boolFlag(args, 'optimized');
8246
8267
  const extensions = config.extensions ?? [...DEFAULT_EXTENSIONS, ...SOURCE_EXTENSIONS];
8247
8268
  const [beforeWalk, afterWalk] = await Promise.all([
8248
- walkPrompts(beforeRoot, { extensions }),
8249
- walkPrompts(afterRoot, { extensions }),
8269
+ walkPrompts(beforeRoot, { extensions, ignore: config.ignore }),
8270
+ walkPrompts(afterRoot, { extensions, ignore: config.ignore }),
8250
8271
  ]);
8251
8272
  if (beforeWalk.files.length === 0 && afterWalk.files.length === 0) {
8252
8273
  throw new Error(t.errors.noPromptsFound(`${beforeRoot}, ${afterRoot}`, extensions.join(' ')));