@better-i18n/cli 0.6.2 → 0.7.2

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/dist/analyzer/index.d.ts.map +1 -1
  3. package/dist/analyzer/index.js +43 -0
  4. package/dist/analyzer/index.js.map +1 -1
  5. package/dist/analyzer/types.d.ts +33 -0
  6. package/dist/analyzer/types.d.ts.map +1 -1
  7. package/dist/commands/pull.d.ts +8 -0
  8. package/dist/commands/pull.d.ts.map +1 -1
  9. package/dist/commands/pull.js +72 -14
  10. package/dist/commands/pull.js.map +1 -1
  11. package/dist/commands/translate.d.ts +3 -6
  12. package/dist/commands/translate.d.ts.map +1 -1
  13. package/dist/doctor/index.d.ts +5 -0
  14. package/dist/doctor/index.d.ts.map +1 -1
  15. package/dist/doctor/index.js +6 -3
  16. package/dist/doctor/index.js.map +1 -1
  17. package/dist/index.js +3 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/lefine/client.d.ts +92 -0
  20. package/dist/lefine/client.d.ts.map +1 -0
  21. package/dist/lefine/client.js +198 -0
  22. package/dist/lefine/client.js.map +1 -0
  23. package/dist/lefine/credentials.d.ts +38 -0
  24. package/dist/lefine/credentials.d.ts.map +1 -0
  25. package/dist/lefine/credentials.js +72 -0
  26. package/dist/lefine/credentials.js.map +1 -0
  27. package/dist/lefine/icu-args.d.ts +9 -0
  28. package/dist/lefine/icu-args.d.ts.map +1 -0
  29. package/dist/lefine/icu-args.js +110 -0
  30. package/dist/lefine/icu-args.js.map +1 -0
  31. package/dist/lefine/mcp-bridge.d.ts +34 -0
  32. package/dist/lefine/mcp-bridge.d.ts.map +1 -0
  33. package/dist/lefine/mcp-bridge.js +130 -0
  34. package/dist/lefine/mcp-bridge.js.map +1 -0
  35. package/dist/lefine/mcp-tools.d.ts +93 -0
  36. package/dist/lefine/mcp-tools.d.ts.map +1 -0
  37. package/dist/lefine/mcp-tools.js +145 -0
  38. package/dist/lefine/mcp-tools.js.map +1 -0
  39. package/dist/lefine/safe-text.d.ts +10 -0
  40. package/dist/lefine/safe-text.d.ts.map +1 -0
  41. package/dist/lefine/safe-text.js +25 -0
  42. package/dist/lefine/safe-text.js.map +1 -0
  43. package/dist/lefine-mcp.d.ts +11 -0
  44. package/dist/lefine-mcp.d.ts.map +1 -0
  45. package/dist/lefine-mcp.js +47 -0
  46. package/dist/lefine-mcp.js.map +1 -0
  47. package/dist/reporters/doctor-eslint.d.ts +2 -1
  48. package/dist/reporters/doctor-eslint.d.ts.map +1 -1
  49. package/dist/reporters/doctor-eslint.js +3 -2
  50. package/dist/reporters/doctor-eslint.js.map +1 -1
  51. package/dist/rules/health/placeholder-mismatch.d.ts +2 -3
  52. package/dist/rules/health/placeholder-mismatch.d.ts.map +1 -1
  53. package/dist/rules/health/placeholder-mismatch.js +2 -3
  54. package/dist/rules/health/placeholder-mismatch.js.map +1 -1
  55. package/dist/utils/cdn-client.d.ts +23 -1
  56. package/dist/utils/cdn-client.d.ts.map +1 -1
  57. package/dist/utils/cdn-client.js +97 -4
  58. package/dist/utils/cdn-client.js.map +1 -1
  59. package/dist/utils/changes-report.d.ts +13 -0
  60. package/dist/utils/changes-report.d.ts.map +1 -0
  61. package/dist/utils/changes-report.js +59 -0
  62. package/dist/utils/changes-report.js.map +1 -0
  63. package/dist/utils/colors.d.ts +6 -1
  64. package/dist/utils/colors.d.ts.map +1 -1
  65. package/dist/utils/colors.js +20 -8
  66. package/dist/utils/colors.js.map +1 -1
  67. package/package.json +4 -4
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The Lefine MCP bridge: stdio on one side, Lefine's remote MCP server (POST /v1/mcp) on the other.
3
+ * For clients that only start local servers (Claude Desktop config, some IDEs). It adds the access key
4
+ * and forwards each message as it is; the server holds every tool and every rule, so the bridge never
5
+ * needs a release when an action is added.
6
+ *
7
+ * Both MCP eras pass through. A modern (2026-07-28) message names its version in `_meta`, and the bridge
8
+ * mirrors it in the MCP-Protocol-Version, Mcp-Method and Mcp-Name headers the server checks. A legacy
9
+ * message gets the version the `initialize` answer agreed on.
10
+ *
11
+ * Two tools are answered here, not by the server: lefine_find_similar_key and lefine_add_key (mcp-tools.ts).
12
+ * They are added to the first page of tools/list.
13
+ *
14
+ * stdout carries only JSON-RPC, one message per line; anything for people goes to stderr.
15
+ */
16
+ export interface BridgeAuth {
17
+ token: string;
18
+ apiUrl: string;
19
+ }
20
+ export interface BridgeDeps {
21
+ /** Null when there is no key: every request is answered with how to sign in. */
22
+ auth: BridgeAuth | null;
23
+ fetch: typeof fetch;
24
+ /** One JSON-RPC message, already serialized, for stdout. */
25
+ write: (line: string) => void;
26
+ log: (line: string) => void;
27
+ clientVersion: string;
28
+ }
29
+ export declare function createBridge(deps: BridgeDeps): {
30
+ handle: (line: string) => Promise<void>;
31
+ };
32
+ /** Reads newline-delimited JSON-RPC from a stream and handles each message; messages may run concurrently. */
33
+ export declare function runBridge(input: AsyncIterable<string | Buffer>, deps: BridgeDeps): Promise<void>;
34
+ //# sourceMappingURL=mcp-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-bridge.d.ts","sourceRoot":"","sources":["../../src/lefine/mcp-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,gFAAgF;IAChF,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,4DAA4D;IAC5D,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;CACvB;AAcD,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU;mBASf,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;EAqEnD;AAED,8GAA8G;AAC9G,wBAAsB,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBtG"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * The Lefine MCP bridge: stdio on one side, Lefine's remote MCP server (POST /v1/mcp) on the other.
3
+ * For clients that only start local servers (Claude Desktop config, some IDEs). It adds the access key
4
+ * and forwards each message as it is; the server holds every tool and every rule, so the bridge never
5
+ * needs a release when an action is added.
6
+ *
7
+ * Both MCP eras pass through. A modern (2026-07-28) message names its version in `_meta`, and the bridge
8
+ * mirrors it in the MCP-Protocol-Version, Mcp-Method and Mcp-Name headers the server checks. A legacy
9
+ * message gets the version the `initialize` answer agreed on.
10
+ *
11
+ * Two tools are answered here, not by the server: lefine_find_similar_key and lefine_add_key (mcp-tools.ts).
12
+ * They are added to the first page of tools/list.
13
+ *
14
+ * stdout carries only JSON-RPC, one message per line; anything for people goes to stderr.
15
+ */
16
+ import { LOCAL_TOOLS, callLocalTool } from "./mcp-tools.js";
17
+ const NO_KEY = "Lefine is not signed in. Run `npx lefine login`, or set LEFINE_TOKEN to a key from Settings > API keys (tick Content or Studio there if the agent needs them).";
18
+ /** Header-safe ASCII, or the `=?base64?...?=` sentinel the spec defines for other values. */
19
+ function headerValue(value) {
20
+ if (/^[\x20-\x7e]*$/.test(value))
21
+ return value;
22
+ const bytes = new TextEncoder().encode(value);
23
+ return `=?base64?${Buffer.from(bytes).toString("base64")}?=`;
24
+ }
25
+ export function createBridge(deps) {
26
+ /** The legacy version `initialize` agreed on; sent on every later legacy request. */
27
+ let legacyVersion;
28
+ const reply = (id, code, message) => {
29
+ if (id === undefined || id === null)
30
+ return;
31
+ deps.write(JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } }));
32
+ };
33
+ async function handle(line) {
34
+ const text = line.trim();
35
+ if (!text)
36
+ return;
37
+ let msg;
38
+ try {
39
+ msg = JSON.parse(text);
40
+ }
41
+ catch {
42
+ deps.write(JSON.stringify({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "The message is not JSON." } }));
43
+ return;
44
+ }
45
+ // A response from the client (to a server request) has no method; this server never sends requests.
46
+ if (typeof msg.method !== "string")
47
+ return;
48
+ if (!deps.auth) {
49
+ reply(msg.id, -32001, NO_KEY);
50
+ return;
51
+ }
52
+ if (msg.method === "tools/call" && LOCAL_TOOLS.some((t) => t.name === msg.params?.name)) {
53
+ const result = await callLocalTool(deps.auth, String(msg.params?.name), (msg.params?.arguments ?? {}));
54
+ deps.write(JSON.stringify({ jsonrpc: "2.0", id: msg.id, result }));
55
+ return;
56
+ }
57
+ const meta = (msg.params?._meta ?? {});
58
+ const modernVersion = typeof meta["io.modelcontextprotocol/protocolVersion"] === "string" ? meta["io.modelcontextprotocol/protocolVersion"] : undefined;
59
+ const headers = {
60
+ "content-type": "application/json",
61
+ accept: "application/json, text/event-stream",
62
+ authorization: `Bearer ${deps.auth.token}`,
63
+ "user-agent": `lefine-mcp/${deps.clientVersion}`,
64
+ };
65
+ if (modernVersion) {
66
+ headers["mcp-protocol-version"] = modernVersion;
67
+ headers["mcp-method"] = msg.method;
68
+ const name = msg.params?.name ?? msg.params?.uri;
69
+ if (typeof name === "string")
70
+ headers["mcp-name"] = headerValue(name);
71
+ }
72
+ else if (legacyVersion && msg.method !== "initialize") {
73
+ headers["mcp-protocol-version"] = legacyVersion;
74
+ }
75
+ let res;
76
+ try {
77
+ res = await deps.fetch(`${deps.auth.apiUrl}/v1/mcp`, { method: "POST", headers, body: text });
78
+ }
79
+ catch {
80
+ reply(msg.id, -32603, `Could not reach Lefine at ${deps.auth.apiUrl}. Check the connection and try again.`);
81
+ return;
82
+ }
83
+ if (res.status === 202)
84
+ return;
85
+ const body = await res.text();
86
+ let parsed = null;
87
+ try {
88
+ parsed = body ? JSON.parse(body) : null;
89
+ }
90
+ catch {
91
+ parsed = null;
92
+ }
93
+ if (!parsed) {
94
+ reply(msg.id, -32603, `Lefine answered HTTP ${res.status} without a JSON-RPC message.`);
95
+ return;
96
+ }
97
+ if (msg.method === "initialize" && typeof parsed.result?.protocolVersion === "string")
98
+ legacyVersion = parsed.result.protocolVersion;
99
+ if (res.status === 401)
100
+ deps.log("lefine-mcp: the key was refused. Run `npx lefine login` again or check LEFINE_TOKEN.");
101
+ // The server answers some refusals (no key, bad JSON) before it reads the id; the client is waiting for its own.
102
+ if (parsed.id === null && msg.id !== undefined && msg.id !== null)
103
+ parsed = { ...parsed, id: msg.id };
104
+ const tools = parsed.result?.tools;
105
+ if (msg.method === "tools/list" && Array.isArray(tools) && !msg.params?.cursor)
106
+ parsed = { ...parsed, result: { ...parsed.result, tools: [...tools, ...LOCAL_TOOLS] } };
107
+ deps.write(JSON.stringify(parsed));
108
+ }
109
+ return { handle };
110
+ }
111
+ /** Reads newline-delimited JSON-RPC from a stream and handles each message; messages may run concurrently. */
112
+ export async function runBridge(input, deps) {
113
+ const bridge = createBridge(deps);
114
+ const pending = new Set();
115
+ let buffer = "";
116
+ for await (const chunk of input) {
117
+ buffer += chunk.toString();
118
+ let at;
119
+ while ((at = buffer.indexOf("\n")) >= 0) {
120
+ const line = buffer.slice(0, at);
121
+ buffer = buffer.slice(at + 1);
122
+ const p = bridge.handle(line).finally(() => pending.delete(p));
123
+ pending.add(p);
124
+ }
125
+ }
126
+ if (buffer.trim())
127
+ pending.add(bridge.handle(buffer));
128
+ await Promise.all(pending);
129
+ }
130
+ //# sourceMappingURL=mcp-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-bridge.js","sourceRoot":"","sources":["../../src/lefine/mcp-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAmB5D,MAAM,MAAM,GACV,gKAAgK,CAAC;AAEnK,6FA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I,KAAK,EAAE,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC3B,IAAI,EAAU,CAAC;QACf,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACjC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/D,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,EAAE;QAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACtD,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Two tools `lefine mcp` adds next to the server's, so a coding agent adds strings the way a careful person
3
+ * would (oss SDK audit, idea C): look for an existing key first, and refuse the mistakes agents make. The
4
+ * reference incident: an agent made 1005 phantom keys by creating in the wrong namespace instead of updating.
5
+ */
6
+ import { type OpClient } from "./client.js";
7
+ import type { BridgeAuth } from "./mcp-bridge.js";
8
+ export declare const LOCAL_TOOLS: readonly [{
9
+ readonly name: "lefine_find_similar_key";
10
+ readonly description: string;
11
+ readonly inputSchema: {
12
+ readonly type: "object";
13
+ readonly properties: {
14
+ readonly appId: {
15
+ readonly type: "string";
16
+ readonly description: "The app id, app_... (lefine.ts in the project has it).";
17
+ };
18
+ readonly text: {
19
+ readonly type: "string";
20
+ readonly description: "The source-language text you want to show.";
21
+ };
22
+ readonly key: {
23
+ readonly type: "string";
24
+ readonly description: "The key name you had in mind, e.g. checkout.coupon_applied.";
25
+ };
26
+ };
27
+ readonly required: readonly ["appId"];
28
+ };
29
+ }, {
30
+ readonly name: "lefine_add_key";
31
+ readonly description: string;
32
+ readonly inputSchema: {
33
+ readonly type: "object";
34
+ readonly properties: {
35
+ readonly appId: {
36
+ readonly type: "string";
37
+ readonly description: "The app id, app_...";
38
+ };
39
+ readonly namespace: {
40
+ readonly type: "string";
41
+ readonly description: "An existing namespace, e.g. checkout. Check with lefine_find_similar_key.";
42
+ };
43
+ readonly key: {
44
+ readonly type: "string";
45
+ readonly description: "The key inside the namespace, e.g. coupon_applied (dots make groups).";
46
+ };
47
+ readonly sourceText: {
48
+ readonly type: "string";
49
+ readonly description: "The text in the app's source language. ICU: {name}, {n, plural, one {# item} other {# items}}.";
50
+ };
51
+ readonly description: {
52
+ readonly type: "string";
53
+ readonly description: "Where it shows and what it means, for translators.";
54
+ };
55
+ readonly newNamespace: {
56
+ readonly type: "boolean";
57
+ readonly description: "true only to create a namespace that does not exist.";
58
+ };
59
+ readonly reuse: {
60
+ readonly type: "boolean";
61
+ readonly description: "Default true: refuse when the same text already has a key. false only after you checked it is different.";
62
+ };
63
+ };
64
+ readonly required: readonly ["appId", "namespace", "key", "sourceText"];
65
+ };
66
+ }];
67
+ /** 1 for the same text (case, punctuation and argument names aside), else the share of words in common. */
68
+ export declare function similarity(a: string, b: string): number;
69
+ type Args = Record<string, unknown>;
70
+ export declare function findSimilar(ops: OpClient, args: Args): Promise<{
71
+ isError?: boolean | undefined;
72
+ content: {
73
+ type: string;
74
+ text: string;
75
+ }[];
76
+ }>;
77
+ export declare function addKey(ops: OpClient, args: Args): Promise<{
78
+ isError?: boolean | undefined;
79
+ content: {
80
+ type: string;
81
+ text: string;
82
+ }[];
83
+ }>;
84
+ /** A tools/call for one of LOCAL_TOOLS, answered here; null for the server's tools. */
85
+ export declare function callLocalTool(auth: BridgeAuth, name: string, args: Args): Promise<{
86
+ isError?: boolean | undefined;
87
+ content: {
88
+ type: string;
89
+ text: string;
90
+ }[];
91
+ } | null>;
92
+ export {};
93
+ //# sourceMappingURL=mcp-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-tools.d.ts","sourceRoot":"","sources":["../../src/lefine/mcp-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AASlD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCd,CAAC;AAKX,2GAA2G;AAC3G,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAOvD;AAuBD,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC,wBAAsB,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI;;;;;;GAgB1D;AAED,wBAAsB,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI;;;;;;GAmCrD;AAED,uFAAuF;AACvF,wBAAsB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;;;;;;UAS7E"}
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Two tools `lefine mcp` adds next to the server's, so a coding agent adds strings the way a careful person
3
+ * would (oss SDK audit, idea C): look for an existing key first, and refuse the mistakes agents make. The
4
+ * reference incident: an agent made 1005 phantom keys by creating in the wrong namespace instead of updating.
5
+ */
6
+ import { createOpClient } from "./client.js";
7
+ import { icuArgs } from "./icu-args.js";
8
+ export const LOCAL_TOOLS = [
9
+ {
10
+ name: "lefine_find_similar_key",
11
+ description: "Find keys of a Lefine app whose name or source text is like the one you want to add. ALWAYS call this before lefine_add_key: " +
12
+ "reuse an existing key instead of adding a duplicate. Give the app id (app_...) and the source text, the key, or both. " +
13
+ "Returns up to 10 keys with their id (key_...), namespace and source text, closest first. To change a key you found, use the server's strings.keys.update (its text or description) with that id.",
14
+ inputSchema: {
15
+ type: "object",
16
+ properties: {
17
+ appId: { type: "string", description: "The app id, app_... (lefine.ts in the project has it)." },
18
+ text: { type: "string", description: "The source-language text you want to show." },
19
+ key: { type: "string", description: "The key name you had in mind, e.g. checkout.coupon_applied." },
20
+ },
21
+ required: ["appId"],
22
+ },
23
+ },
24
+ {
25
+ name: "lefine_add_key",
26
+ description: "Add ONE new key with its source text to a Lefine app. It refuses, and says why, when: the key already exists in any namespace " +
27
+ "(change its text with strings.keys.update; its id comes from lefine_find_similar_key); a key with the same source text exists (reuse it, or pass reuse: false after checking); the namespace " +
28
+ "does not exist yet (pass newNamespace: true only if a new namespace is really meant); the text is not valid ICU. " +
29
+ "A new key is not live: a person publishes it. Other languages: strings.translations.set writes one translation (asks first). Call lefine_find_similar_key first.",
30
+ inputSchema: {
31
+ type: "object",
32
+ properties: {
33
+ appId: { type: "string", description: "The app id, app_..." },
34
+ namespace: { type: "string", description: "An existing namespace, e.g. checkout. Check with lefine_find_similar_key." },
35
+ key: { type: "string", description: "The key inside the namespace, e.g. coupon_applied (dots make groups)." },
36
+ sourceText: { type: "string", description: "The text in the app's source language. ICU: {name}, {n, plural, one {# item} other {# items}}." },
37
+ description: { type: "string", description: "Where it shows and what it means, for translators." },
38
+ newNamespace: { type: "boolean", description: "true only to create a namespace that does not exist." },
39
+ reuse: { type: "boolean", description: "Default true: refuse when the same text already has a key. false only after you checked it is different." },
40
+ },
41
+ required: ["appId", "namespace", "key", "sourceText"],
42
+ },
43
+ },
44
+ ];
45
+ const norm = (s) => s.toLowerCase().replace(/\{[^}]*\}/g, "{}").replace(/[^\p{L}\p{N}{}]+/gu, " ").trim();
46
+ const words = (s) => new Set(norm(s).split(" ").filter(Boolean));
47
+ /** 1 for the same text (case, punctuation and argument names aside), else the share of words in common. */
48
+ export function similarity(a, b) {
49
+ if (!a || !b)
50
+ return 0;
51
+ if (norm(a) === norm(b))
52
+ return 1;
53
+ const x = words(a);
54
+ const y = words(b);
55
+ const common = [...x].filter((w) => y.has(w)).length;
56
+ return common / Math.max(x.size, y.size, 1);
57
+ }
58
+ const text = (body, isError = false) => ({ content: [{ type: "text", text: body }], ...(isError ? { isError: true } : {}) });
59
+ async function sourceOf(ops, appId) {
60
+ const got = await ops.callOp("strings.app.get", { appId });
61
+ return { sourceLocale: got.app.sourceLocale, namespaces: got.namespaces.map((n) => n.name) };
62
+ }
63
+ async function search(ops, appId, locale, query) {
64
+ if (!query.trim())
65
+ return [];
66
+ const page = await ops.callOp("strings.keys.list", { appId, locale, search: query.trim().slice(0, 200), limit: 50 });
67
+ return page.items ?? [];
68
+ }
69
+ /** Keys the server finds for the text, the key, or the text's longer words (it matches substrings, not meaning). */
70
+ async function candidates(ops, appId, locale, text, key = "") {
71
+ const pool = new Map();
72
+ const queries = [text, key, ...[...words(text)].filter((w) => w.length > 3).slice(0, 4)];
73
+ for (const q of queries)
74
+ for (const item of await search(ops, appId, locale, q))
75
+ pool.set(`${item.namespace}:${item.key}`, item);
76
+ return [...pool.values()];
77
+ }
78
+ export async function findSimilar(ops, args) {
79
+ const appId = String(args.appId ?? "");
80
+ const want = typeof args.text === "string" ? args.text : "";
81
+ const key = typeof args.key === "string" ? args.key : "";
82
+ if (!want && !key)
83
+ return text("Give text, key, or both.", true);
84
+ const { sourceLocale } = await sourceOf(ops, appId);
85
+ const scored = (await candidates(ops, appId, sourceLocale, want, key))
86
+ .map((item) => {
87
+ const source = item.translations?.[sourceLocale]?.text ?? "";
88
+ const score = Math.max(similarity(want, source), key ? similarity(key.replace(/[._]/g, " "), item.key.replace(/[._]/g, " ")) : 0);
89
+ return { ...(item.id ? { keyId: item.id } : {}), namespace: item.namespace, key: item.key, sourceText: source, score: Math.round(score * 100) / 100 };
90
+ })
91
+ .filter((s) => s.score > 0.3)
92
+ .sort((a, b) => b.score - a.score)
93
+ .slice(0, 10);
94
+ return text(scored.length === 0 ? "No similar key. A new one is fine." : JSON.stringify(scored, null, 1));
95
+ }
96
+ export async function addKey(ops, args) {
97
+ const appId = String(args.appId ?? "");
98
+ const namespace = String(args.namespace ?? "").trim();
99
+ const key = String(args.key ?? "").trim();
100
+ const sourceText = String(args.sourceText ?? "");
101
+ if (!namespace || !key || !sourceText.trim())
102
+ return text("namespace, key and sourceText are needed.", true);
103
+ if (icuArgs(sourceText) === null)
104
+ return text(`"${sourceText}" is not valid ICU. Check the braces: {name}, {n, plural, one {# x} other {# xs}}.`, true);
105
+ const { sourceLocale, namespaces } = await sourceOf(ops, appId);
106
+ if (!namespaces.includes(namespace) && args.newNamespace !== true) {
107
+ return text(`Namespace "${namespace}" does not exist. Namespaces: ${namespaces.join(", ") || "none"}. Use one of them, or pass newNamespace: true if a new one is meant.`, true);
108
+ }
109
+ const sameKey = (await search(ops, appId, sourceLocale, key)).filter((k) => k.key === key);
110
+ if (sameKey.length > 0) {
111
+ const where = sameKey.map((k) => `${k.namespace}.${k.key}`).join(", ");
112
+ const ids = sameKey.filter((k) => k.id).map((k) => k.id).join(", ");
113
+ return text(`The key already exists: ${where}. Do not add it again; change its text with strings.keys.update${ids ? ` (keyId ${ids})` : ""}.`, true);
114
+ }
115
+ if (args.reuse !== false) {
116
+ const same = (await candidates(ops, appId, sourceLocale, sourceText)).filter((k) => similarity(sourceText, k.translations?.[sourceLocale]?.text ?? "") === 1);
117
+ if (same.length > 0) {
118
+ return text(`This text already has a key: ${same.map((k) => `${k.namespace}.${k.key}`).join(", ")}. Use it in code. If yours means something else, call again with reuse: false.`, true);
119
+ }
120
+ }
121
+ await ops.callOp("strings.keys.create", {
122
+ appId,
123
+ namespace,
124
+ key,
125
+ sourceText,
126
+ ...(typeof args.description === "string" && args.description.trim() ? { description: args.description.trim() } : {}),
127
+ });
128
+ const typed = Object.keys(icuArgs(sourceText) ?? {});
129
+ return text(`Added ${namespace}.${key}. It is not live until someone publishes in Lefine. Run \`npx lefine strings types\` so the editor knows it${typed.length ? ` (arguments: ${typed.join(", ")})` : ""}.`);
130
+ }
131
+ /** A tools/call for one of LOCAL_TOOLS, answered here; null for the server's tools. */
132
+ export async function callLocalTool(auth, name, args) {
133
+ const ops = createOpClient(auth.apiUrl, auth.token);
134
+ try {
135
+ if (name === "lefine_find_similar_key")
136
+ return await findSimilar(ops, args);
137
+ if (name === "lefine_add_key")
138
+ return await addKey(ops, args);
139
+ return null;
140
+ }
141
+ catch (err) {
142
+ return text(`Lefine refused: ${err instanceof Error ? err.message : String(err)}`, true);
143
+ }
144
+ }
145
+ //# sourceMappingURL=mcp-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-tools.js","sourceRoot":"","sources":["../../src/lefine/mcp-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAiB,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAUxC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB;QACE,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EACT,+HAA+H;YAC/H,wHAAwH;YACxH,kMAAkM;QACpM,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,wDAAwD,EAAE;gBAChG,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,4CAA4C,EAAE;gBACnF,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6DAA6D,EAAE;aACpG;YACD,QAAQ,EAAE,CAAC,OAAO,CAAC;SACpB;KACF;IACD;QACE,IAAI,EAAE,gBAAgB;Q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B;YAAE,OAAO,MAAM,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5E,IAAI,IAAI,KAAK,gBAAgB;YAAE,OAAO,MAAM,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,IAAI,CAAC,mBAAmB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC3F,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Text from the server, from translators or from files is printed to a
3
+ * terminal, where ESC, C0 and C1 control characters can rewrite the screen
4
+ * (clear lines, fake a "published" line). Everything not typed by the CLI
5
+ * itself goes through `safeText` first, and JSON through `safeJson`.
6
+ */
7
+ export declare function safeText(value: unknown): string;
8
+ /** JSON.stringify, then DEL, C1 and bidi controls as \\uXXXX: still valid JSON that parses to the same value. */
9
+ export declare function safeJson(value: unknown, indent?: number): string;
10
+ //# sourceMappingURL=safe-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-text.d.ts","sourceRoot":"","sources":["../../src/lefine/safe-text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAM/C;AAKD,iHAAiH;AACjH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhE"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Text from the server, from translators or from files is printed to a
3
+ * terminal, where ESC, C0 and C1 control characters can rewrite the screen
4
+ * (clear lines, fake a "published" line). Everything not typed by the CLI
5
+ * itself goes through `safeText` first, and JSON through `safeJson`.
6
+ */
7
+ // Tab stays. Newline, carriage return, other C0, DEL and C1 become visible escapes,
8
+ // so a multi-line text cannot fake extra lines either. Bidi overrides and line
9
+ // separators reorder or break lines, so they are shown as escapes too.
10
+ // eslint-disable-next-line no-control-regex -- matching control characters is what this does
11
+ const UNSAFE = new RegExp("[\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069]", "g");
12
+ export function safeText(value) {
13
+ const text = typeof value === "string" ? value : String(value ?? "");
14
+ return text.replace(UNSAFE, (ch) => {
15
+ const code = ch.codePointAt(0);
16
+ return code <= 0xff ? `\\x${code.toString(16).padStart(2, "0")}` : `\\u${code.toString(16).padStart(4, "0")}`;
17
+ });
18
+ }
19
+ // JSON.stringify escapes C0 (\x00-\x1f) but not DEL, C1 or bidi controls: a C1 CSI (\x9b) can still drive a terminal.
20
+ const UNSAFE_IN_JSON = new RegExp("[\\x7f-\\x9f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069]", "g");
21
+ /** JSON.stringify, then DEL, C1 and bidi controls as \\uXXXX: still valid JSON that parses to the same value. */
22
+ export function safeJson(value, indent) {
23
+ return JSON.stringify(value, null, indent).replace(UNSAFE_IN_JSON, (ch) => `\\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`);
24
+ }
25
+ //# sourceMappingURL=safe-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-text.js","sourceRoot":"","sources":["../../src/lefine/safe-text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oFAAoF;AACpF,+EAA+E;AAC/E,uEAAuE;AACvE,6FAA6F;AAC7F,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,iFAAiF,EAAE,GAAG,CAAC,CAAC;AAElH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IACrE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE;QACjC,MAAM,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC;QAChC,OAAO,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IAChH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,sHAAsH;AACtH,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC,2DAA2D,EAAE,GAAG,CAAC,CAAC;AAEpG,iHAAiH;AACjH,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAE,MAAe;IACtD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AACrI,CAAC"}
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `lefine-mcp`: Lefine's MCP server for clients that start a local process (Claude Desktop, IDE configs).
4
+ * It bridges stdio to https://dash.lefine.ai/v1/mcp with your key. Clients that speak remote MCP can
5
+ * use that URL directly instead.
6
+ *
7
+ * Key: LEFINE_TOKEN, else the one `lefine login` saved. No project env files are read, on purpose: a
8
+ * cloned project must not be able to redirect the key (same rule as the `lefine` CLI).
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=lefine-mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lefine-mcp.d.ts","sourceRoot":"","sources":["../src/lefine-mcp.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG"}
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `lefine-mcp`: Lefine's MCP server for clients that start a local process (Claude Desktop, IDE configs).
4
+ * It bridges stdio to https://dash.lefine.ai/v1/mcp with your key. Clients that speak remote MCP can
5
+ * use that URL directly instead.
6
+ *
7
+ * Key: LEFINE_TOKEN, else the one `lefine login` saved. No project env files are read, on purpose: a
8
+ * cloned project must not be able to redirect the key (same rule as the `lefine` CLI).
9
+ */
10
+ import { readFileSync } from "node:fs";
11
+ import { resolveLefineAuth } from "./lefine/credentials.js";
12
+ import { runBridge } from "./lefine/mcp-bridge.js";
13
+ const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
14
+ const args = process.argv.slice(2);
15
+ if (args.includes("--version")) {
16
+ process.stdout.write(`${pkg.version}\n`);
17
+ process.exit(0);
18
+ }
19
+ if (args.includes("--help")) {
20
+ process.stderr.write([
21
+ "lefine-mcp: Lefine as a local MCP server (stdio).",
22
+ "",
23
+ "Sign in once: npx lefine login (or set LEFINE_TOKEN)",
24
+ 'Claude Desktop: { "mcpServers": { "lefine": { "command": "npx", "args": ["-y", "@lefine/mcp"] } } }',
25
+ "Remote clients can skip this and use https://dash.lefine.ai/v1/mcp with the header Authorization: Bearer <key>.",
26
+ "",
27
+ ].join("\n"));
28
+ process.exit(0);
29
+ }
30
+ let auth = null;
31
+ try {
32
+ const found = resolveLefineAuth({});
33
+ auth = found ? { token: found.token, apiUrl: found.apiUrl } : null;
34
+ }
35
+ catch (error) {
36
+ process.stderr.write(`lefine-mcp: ${error instanceof Error ? error.message : String(error)}\n`);
37
+ }
38
+ if (!auth)
39
+ process.stderr.write("lefine-mcp: not signed in. Run `npx lefine login` or set LEFINE_TOKEN.\n");
40
+ await runBridge(process.stdin, {
41
+ auth,
42
+ fetch,
43
+ write: (line) => process.stdout.write(`${line}\n`),
44
+ log: (line) => process.stderr.write(`${line}\n`),
45
+ clientVersion: pkg.version,
46
+ });
47
+ //# sourceMappingURL=lefine-mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lefine-mcp.js","sourceRoot":"","sources":["../src/lefine-mcp.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAwB,CAAC;AAElH,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;IAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AACD,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB;QACE,mDAAmD;QACnD,EAAE;QACF,6DAA6D;QAC7D,qGAAqG;QACrG,iHAAiH;QACjH,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,IAAI,GAA6C,IAAI,CAAC;AAC1D,IAAI,CAAC;IACH,MAAM,KAAK,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACpC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACrE,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAClG,CAAC;AACD,IAAI,CAAC,IAAI;IAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0EAA0E,CAAC,CAAC;AAE5G,MAAM,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE;IAC7B,IAAI;IACJ,KAAK;IACL,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;IAClD,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;IAChD,aAAa,EAAE,GAAG,CAAC,OAAO;CAC3B,CAAC,CAAC"}
@@ -5,5 +5,6 @@
5
5
  * Visual hierarchy: score card → categories → diagnostics → tips.
6
6
  */
7
7
  import type { DoctorReport } from "../doctor/index.js";
8
- export declare function reportEslint(report: DoctorReport, verbose?: boolean): void;
8
+ /** `brand`: the name after "i18n Doctor" in the box (the lefine CLI passes "lefine"). */
9
+ export declare function reportEslint(report: DoctorReport, verbose?: boolean, brand?: string): void;
9
10
  //# sourceMappingURL=doctor-eslint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"doctor-eslint.d.ts","sourceRoot":"","sources":["../../src/reporters/doctor-eslint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA4HvD,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,UAAQ,GAAG,IAAI,CA8IxE"}
1
+ {"version":3,"file":"doctor-eslint.d.ts","sourceRoot":"","sources":["../../src/reporters/doctor-eslint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA4HvD,yFAAyF;AACzF,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,UAAQ,EAAE,KAAK,SAAgB,GAAG,IAAI,CA8I/F"}
@@ -104,7 +104,8 @@ const MAX_RULE_GROUPS = 5;
104
104
  const MAX_ITEMS_PER_GROUP = 5;
105
105
  const MAX_ITEMS_PER_GROUP_VERBOSE = 20;
106
106
  // ── Main Reporter ───────────────────────────────────────────────────
107
- export function reportEslint(report, verbose = false) {
107
+ /** `brand`: the name after "i18n Doctor" in the box (the lefine CLI passes "lefine"). */
108
+ export function reportEslint(report, verbose = false, brand = "better-i18n") {
108
109
  const { score, summary, diagnostics } = report;
109
110
  const { color, letter } = getGrade(score.total);
110
111
  // ── Framed Score Card ───────────────────────────────────────────
@@ -123,7 +124,7 @@ export function reportEslint(report, verbose = false) {
123
124
  const statLine = statParts.length > 0 ? statParts.join(" · ") : "No issues";
124
125
  const metaLine = `${summary.filesScanned} files · ${summary.keysChecked} keys · ${summary.localesChecked} locales · ${(report.durationMs / 1000).toFixed(1)}s`;
125
126
  const boxLines = [
126
- fl("i18n Doctor · better-i18n", `${bold("i18n Doctor")} ${dim("·")} ${dim("better-i18n")}`),
127
+ fl(`i18n Doctor · ${brand}`, `${bold("i18n Doctor")} ${dim("·")} ${dim(brand)}`),
127
128
  fl(""), // empty line
128
129
  fl(`${bar.plain} ${scoreStr}/100 ${letter}`, `${bar.rendered} ${color(bold(scoreStr))}${dim("/100")} ${color(bold(letter))}`),
129
130
  fl(`${statusText} (threshold: ${score.passThreshold})`, `${statusColor(statusText)} ${dim(`(threshold: ${score.passThreshold})`)}`),