@trazum/cli 1.82.0 → 1.85.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.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Providers whose tokens an optional package can count exactly, by provider id.
3
+ *
4
+ * Its own module rather than a constant inside the command, because two
5
+ * different readers need it: the CLI, to decide whether to try loading one, and
6
+ * `band-family.test.js`, which walks every priced provider and asserts that the
7
+ * ones this tool cannot count are refused by name. That suite's whole design is
8
+ * that a family leaves its assertions by *becoming countable* rather than by
9
+ * anybody editing the test -- which only works if there is one place that says
10
+ * which families those are.
11
+ *
12
+ * A map rather than a list, so the refusal for a family that is not installed
13
+ * can name the package that would fix it.
14
+ */
15
+ export const OPTIONAL_COUNTERS: Readonly<Record<string, string>> = Object.freeze({
16
+ openai: '@trazum/tokenizer-openai',
17
+ });
18
+
19
+ /** Whether some optional package exists that counts this provider exactly. */
20
+ export const countableLocally = (provider: string | null | undefined): boolean =>
21
+ provider !== null && provider !== undefined && provider in OPTIONAL_COUNTERS;
package/src/style.ts CHANGED
@@ -13,6 +13,18 @@
13
13
  * bytes their script was written against.
14
14
  */
15
15
 
16
+ /**
17
+ * The variables the decision below reads.
18
+ *
19
+ * Exported for the same reason `LOCALE_ENV_VARS` is: the test suite has to
20
+ * neutralise the machine before asserting on output, and a list of what to
21
+ * neutralise kept in the test file drifts from the list that is read here. It
22
+ * drifted once already, in the other direction: `env.mjs` set `NO_COLOR` and
23
+ * left `FORCE_COLOR` alone, so a contributor whose shell exports `FORCE_COLOR`
24
+ * ran the whole CLI suite against painted output and twenty-nine tests failed.
25
+ */
26
+ export const COLOUR_ENV_VARS = ['FORCE_COLOR', 'NO_COLOR'] as const;
27
+
16
28
  const forced = process.env.FORCE_COLOR === '1';
17
29
  export const useColor = forced || (process.stdout.isTTY === true && process.env.NO_COLOR === undefined);
18
30