@verbaly/compiler 0.73.0 → 0.75.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/README.md +3 -1
- package/dist/{claude-Baoc6pYL.js → claude-DcV4YBbO.js} +2 -2
- package/dist/{claude-Baoc6pYL.js.map → claude-DcV4YBbO.js.map} +1 -1
- package/dist/cli.js +77 -19
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +46 -23
- package/dist/index.js.map +1 -1
- package/dist/{text-BMBWE8tL.js → text-BtTS6qL7.js} +40 -4
- package/dist/text-BtTS6qL7.js.map +1 -0
- package/package.json +3 -2
- package/dist/text-BMBWE8tL.js.map +0 -1
package/README.md
CHANGED
|
@@ -378,7 +378,7 @@ import {
|
|
|
378
378
|
transformSource,
|
|
379
379
|
} from '@verbaly/compiler';
|
|
380
380
|
|
|
381
|
-
const cfg = await loadConfig(process.cwd());
|
|
381
|
+
const cfg = await loadConfig(process.cwd(), options, { plugin: true });
|
|
382
382
|
const catalogs = loadCatalogs(cfg);
|
|
383
383
|
const registry = new MessageRegistry();
|
|
384
384
|
|
|
@@ -389,6 +389,8 @@ const { messages, result } = transformSource(code, id, registry);
|
|
|
389
389
|
runBuildGate(cfg, registry);
|
|
390
390
|
```
|
|
391
391
|
|
|
392
|
+
Your plugin's options go second and `{ plugin: true }` third: when one the command line also reads (`sourceLocale`, `locales`, `dir`, `include`, `exclude`) differs from `verbaly.config`, the build says once to move it there, since `verbaly check` never reads a bundler config.
|
|
393
|
+
|
|
392
394
|
A build that scans first, as the Vite plugin does to sync the catalogs, keeps that scan with `extractProject(cfg, { keepSource: true })` and passes it as the fourth argument of `transformSource`: a file it read unchanged is not parsed a second time. Call `reportOutsideInclude(cfg)` once when your build starts: it names every file outside `include` that writes a `` t`…` ``, which no build translates. It reads the project itself, so a cached transform never hides one. `writeDts(cfg, catalog)` writes the types where the config resolves them and returns the file and whether it changed.
|
|
393
395
|
|
|
394
396
|
A dev server that writes the catalogs goes through `syncProject`, the same path `extract`, the MCP server and Studio take: it scans (or takes the registry you hold), syncs, writes the catalogs and the types, and keeps `verbaly.lock` in step, in that order; its `findings` say once when that file first appears. Pass `confirm: true` when your registry is built file by file, so a file that changed on disk unseen is read again before its text is written back. `createDevReporter` then says each of its findings once, says it again if it goes away and comes back, and keeps a long list to a few lines.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as counted, o as isModuleNotFound } from "./text-
|
|
1
|
+
import { n as counted, o as isModuleNotFound } from "./text-BtTS6qL7.js";
|
|
2
2
|
//#region src/providers/claude.ts
|
|
3
3
|
const DEFAULT_MODEL = "claude-sonnet-5-5";
|
|
4
4
|
const FALLBACK_MODELS = /* @__PURE__ */ new Set([
|
|
@@ -91,4 +91,4 @@ async function loadSdk(load = () => import("@anthropic-ai/sdk")) {
|
|
|
91
91
|
//#endregion
|
|
92
92
|
export { claudeProvider };
|
|
93
93
|
|
|
94
|
-
//# sourceMappingURL=claude-
|
|
94
|
+
//# sourceMappingURL=claude-DcV4YBbO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-
|
|
1
|
+
{"version":3,"file":"claude-DcV4YBbO.js","names":[],"sources":["../src/providers/claude.ts"],"sourcesContent":["import { isModuleNotFound } from '../config';\nimport { counted } from '../text';\nimport type { TranslateProvider, TranslateRequest } from '../translate';\n\nexport interface ClaudeProviderOptions {\n model?: string;\n apiKey?: string;\n maxTokens?: number;\n}\n\n// balanced default for translation: the current Sonnet, at the price of the one before it\nconst DEFAULT_MODEL = 'claude-sonnet-5-5';\n\n// the models that take fallbacks \"default\": a batch one declines is answered by another model\nconst FALLBACK_MODELS = new Set([\n 'claude-sonnet-5-5',\n 'claude-opus-5-5',\n 'claude-opus-5',\n 'claude-fable-5-1',\n]);\nconst FALLBACK_BETA = 'server-side-fallback-2026-07-01';\n\n// the least thinking each model takes: disabled is a 400 on the newest, and the oldest never think\nexport function thinkingFor(model: string): { type: 'between_tools' | 'disabled' } | undefined {\n if (model === 'claude-sonnet-5-5') return { type: 'between_tools' };\n if (model === 'claude-sonnet-5' || model === 'claude-opus-5') return { type: 'disabled' };\n return undefined;\n}\n\nconst SYSTEM = `You translate UI strings for the Verbaly i18n library.\nRules:\n- Translate only the human-readable text, naturally for the target locale.\n- Preserve verbatim: placeholders like {name}, format specs like {price:currency/EUR}, variant blocks like {count | one: ... | other: # ...} (translate only the text inside each variant, keep keys and # as-is), ICU syntax, named tags like <em>...</em> and escapes {{ }} || ##.\n- Keys are opaque identifiers: return exactly the same keys, never translate or rename them.`;\n\nexport function systemPrompt(instructions?: string): string {\n return instructions ? `${SYSTEM}\\n\\nProject instructions:\\n${instructions}` : SYSTEM;\n}\n\nexport function claudeProvider(options: ClaudeProviderOptions = {}): TranslateProvider {\n // one client per provider: a batch is a request, not a reason to rebuild the transport\n let client: Promise<InstanceType<typeof import('@anthropic-ai/sdk').default>> | undefined;\n\n return async (request: TranslateRequest) => {\n client ??= loadSdk().then(\n (Anthropic) => new Anthropic(options.apiKey ? { apiKey: options.apiKey } : {}),\n );\n const model = options.model ?? DEFAULT_MODEL;\n const thinking = thinkingFor(model);\n const response = await (\n await client\n ).beta.messages.create({\n model,\n max_tokens: options.maxTokens ?? 16000,\n ...(thinking && { thinking }),\n ...(FALLBACK_MODELS.has(model) && { betas: [FALLBACK_BETA], fallbacks: 'default' as const }),\n system: systemPrompt(request.instructions),\n messages: [{ role: 'user', content: buildPrompt(request) }],\n output_config: { format: batchFormat(request) },\n });\n const batch = counted(Object.keys(request.messages).length, 'message');\n if (response.stop_reason === 'max_tokens') {\n throw new Error(\n `[verbaly] the model ran out of output room on a batch of ${batch}: lower translate.batchSize (or raise maxTokens on the provider)`,\n );\n }\n // a decline is about the content, so asking again gets the same answer: a 400 is never retried\n if (response.stop_reason === 'refusal') {\n const category = response.stop_details?.category;\n throw Object.assign(\n new Error(\n `[verbaly] the model declined a batch of ${batch}${category ? ` (${category})` : ''}, so they stay untranslated: translate them by hand or with another provider`,\n ),\n { status: 400 },\n );\n }\n const text = response.content.find((block) => block.type === 'text')?.text ?? '{}';\n try {\n return JSON.parse(text) as Record<string, string>;\n } catch (error) {\n throw new Error('[verbaly] the model did not answer with the JSON object it was asked for', {\n cause: error,\n });\n }\n };\n}\n\nexport function buildPrompt(request: TranslateRequest): string {\n return (\n `Translate each value from \"${request.sourceLocale}\" to \"${request.targetLocale}\". ` +\n `Return a JSON object with the same keys and translated values.\\n\\n` +\n JSON.stringify(request.messages, null, 2) +\n glossarySection(request) +\n originsSection(request)\n );\n}\n\n// the glossary is a requirement, not a hint: it exists because a brand name came back translated\nfunction glossarySection(request: TranslateRequest): string {\n const glossary = request.glossary;\n if (!glossary || Object.keys(glossary).length === 0) return '';\n const lines = Object.entries(glossary).map(([term, rendering]) => ` ${term} -> ${rendering}`);\n return `\\n\\nGlossary, these renderings are required wherever the term appears:\\n${lines.join('\\n')}`;\n}\n\nfunction originsSection(request: TranslateRequest): string {\n const origins = request.origins;\n if (!origins || Object.keys(origins).length === 0) return '';\n const lines = Object.entries(origins).map(([key, files]) => ` ${key}: ${files.join(', ')}`);\n return `\\n\\nWhere each string appears (context for tone and length, do not translate these paths):\\n${lines.join('\\n')}`;\n}\n\nexport function batchFormat(request: TranslateRequest) {\n const keys = Object.keys(request.messages);\n return {\n type: 'json_schema' as const,\n schema: {\n type: 'object',\n properties: Object.fromEntries(keys.map((key) => [key, { type: 'string' }])),\n required: keys,\n additionalProperties: false,\n },\n };\n}\n\ntype SdkModule = { default: typeof import('@anthropic-ai/sdk').default };\n\n// injectable for tests\nexport async function loadSdk(\n load: () => Promise<SdkModule> = () => import('@anthropic-ai/sdk'),\n): Promise<SdkModule['default']> {\n try {\n const mod = await load();\n return mod.default;\n } catch (error) {\n if (isModuleNotFound(error, '@anthropic-ai/sdk')) {\n throw new Error(\n '[verbaly] the claude translate provider needs @anthropic-ai/sdk: install it as a dev dependency (e.g. `pnpm add -D @anthropic-ai/sdk`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AK,QAAQ,CAAC,KAAK,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC;GAC3E,UAAU;GACV,sBAAsB;EACxB;CACF;AACF;AAKA,eAAsB,QACpB,aAAuC,OAAO,sBACf;CAC/B,IAAI;EAEF,QAAO,MADW,KAAK,EAAA,CACZ;CACb,SAAS,OAAO;EACd,IAAI,iBAAiB,OAAO,mBAAmB,GAC7C,MAAM,IAAI,MACR,mMACA,EAAE,OAAO,MAAM,CACjB;EAEF,MAAM;CACR;AACF"}
|
package/dist/cli.js
CHANGED
|
@@ -697,11 +697,14 @@ function tokenText(token) {
|
|
|
697
697
|
}
|
|
698
698
|
function blockEnd(tokens, start, pairs) {
|
|
699
699
|
let depth = 0;
|
|
700
|
+
let head = true;
|
|
700
701
|
for (let k = start; k < tokens.length; k++) {
|
|
701
702
|
const token = tokens[k];
|
|
702
703
|
if (typeof token !== "string") {
|
|
703
704
|
if (token.head) depth += 1;
|
|
704
|
-
} else if (token === "
|
|
705
|
+
} else if (token === "|" && depth === 1) head = false;
|
|
706
|
+
else if (token === "}" && head && depth === 1) return k;
|
|
707
|
+
else if (token === "{" || token === "}") {
|
|
705
708
|
if (tokens[k + 1] === token && (token === "{" || !(pairs && depth > 1))) k += 1;
|
|
706
709
|
else {
|
|
707
710
|
depth += token === "{" ? 1 : -1;
|
|
@@ -1032,7 +1035,26 @@ function byCodeUnit(a, b) {
|
|
|
1032
1035
|
}
|
|
1033
1036
|
//#endregion
|
|
1034
1037
|
//#region src/validate.ts
|
|
1035
|
-
|
|
1038
|
+
let remembered = /* @__PURE__ */ new Map();
|
|
1039
|
+
let reading;
|
|
1040
|
+
function read(message) {
|
|
1041
|
+
if (!reading) return parse(message, parseIcu);
|
|
1042
|
+
let tree = reading.get(message);
|
|
1043
|
+
if (!tree) {
|
|
1044
|
+
tree = remembered.get(message) ?? parse(message, parseIcu);
|
|
1045
|
+
reading.set(message, tree);
|
|
1046
|
+
}
|
|
1047
|
+
return tree;
|
|
1048
|
+
}
|
|
1049
|
+
function gatePass(run) {
|
|
1050
|
+
reading = /* @__PURE__ */ new Map();
|
|
1051
|
+
try {
|
|
1052
|
+
return run();
|
|
1053
|
+
} finally {
|
|
1054
|
+
remembered = reading;
|
|
1055
|
+
reading = void 0;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1036
1058
|
const PLURAL_CATEGORIES = /* @__PURE__ */ new Set([
|
|
1037
1059
|
"zero",
|
|
1038
1060
|
"one",
|
|
@@ -1601,6 +1623,14 @@ function pseudoCatalogs(cfg, catalogs, locale = PSEUDO_LOCALE) {
|
|
|
1601
1623
|
return Object.keys(target).filter((key) => target[key]);
|
|
1602
1624
|
}
|
|
1603
1625
|
//#endregion
|
|
1626
|
+
//#region src/warn.ts
|
|
1627
|
+
const warned = /* @__PURE__ */ new Set();
|
|
1628
|
+
function warnOnce(message, dedupeKey = message) {
|
|
1629
|
+
if (warned.has(dedupeKey)) return;
|
|
1630
|
+
warned.add(dedupeKey);
|
|
1631
|
+
console.warn(`[verbaly] ${message}`);
|
|
1632
|
+
}
|
|
1633
|
+
//#endregion
|
|
1604
1634
|
//#region src/config.ts
|
|
1605
1635
|
const SOURCE_EXTENSIONS = "{js,jsx,ts,tsx,mjs,mts,svelte,vue,astro}";
|
|
1606
1636
|
function resolveConfig(config = {}) {
|
|
@@ -1680,12 +1710,37 @@ function isModuleNotFound(error, name) {
|
|
|
1680
1710
|
function targetLocales(cfg, override) {
|
|
1681
1711
|
return (override ?? cfg.locales).filter((locale) => locale !== cfg.sourceLocale && cfg.locales.includes(locale));
|
|
1682
1712
|
}
|
|
1683
|
-
async function loadConfig(root, overrides = {}) {
|
|
1713
|
+
async function loadConfig(root, overrides = {}, from = {}) {
|
|
1714
|
+
const fileConfig = await loadConfigFile(root);
|
|
1715
|
+
if (from.plugin) warnPluginOnly(root, fileConfig, overrides);
|
|
1684
1716
|
return resolveConfig({
|
|
1685
|
-
...
|
|
1717
|
+
...fileConfig,
|
|
1718
|
+
...definedOnly(overrides),
|
|
1719
|
+
root
|
|
1720
|
+
});
|
|
1721
|
+
}
|
|
1722
|
+
const READ_BY_CLI = [
|
|
1723
|
+
"sourceLocale",
|
|
1724
|
+
"locales",
|
|
1725
|
+
"dir",
|
|
1726
|
+
"include",
|
|
1727
|
+
"exclude"
|
|
1728
|
+
];
|
|
1729
|
+
function warnPluginOnly(root, file, overrides) {
|
|
1730
|
+
const cli = resolveConfig({
|
|
1731
|
+
...file,
|
|
1732
|
+
root
|
|
1733
|
+
});
|
|
1734
|
+
const build = resolveConfig({
|
|
1735
|
+
...file,
|
|
1686
1736
|
...definedOnly(overrides),
|
|
1687
1737
|
root
|
|
1688
1738
|
});
|
|
1739
|
+
const keys = READ_BY_CLI.filter((key) => overrides[key] !== void 0 && JSON.stringify(cli[key]) !== JSON.stringify(build[key]));
|
|
1740
|
+
if (keys.length === 0) return;
|
|
1741
|
+
const names = keys.length > 1 ? `${keys.slice(0, -1).join(", ")} and ${keys.at(-1)}` : keys[0];
|
|
1742
|
+
const [verb, pronoun] = keys.length > 1 ? ["are", "them"] : ["is", "it"];
|
|
1743
|
+
warnOnce(`${names} ${verb} set in the plugin options, which \`verbaly check\` and \`verbaly extract\` never read: move ${pronoun} to verbaly.config so the command line checks what the build ships`, `plugin-only:${root}`);
|
|
1689
1744
|
}
|
|
1690
1745
|
function definedOnly(config) {
|
|
1691
1746
|
return Object.fromEntries(Object.entries(config).filter(([, value]) => value !== void 0));
|
|
@@ -2383,6 +2438,9 @@ function gatePasses(result) {
|
|
|
2383
2438
|
return result.missing.length === 0 && result.unknown.length === 0 && result.collisions.length === 0 && !result.broken.some((entry) => entry.severity === "error");
|
|
2384
2439
|
}
|
|
2385
2440
|
function check(cfg, catalogs, registry, fingerprints = {}) {
|
|
2441
|
+
return gatePass(() => checkPass(cfg, catalogs, registry, fingerprints));
|
|
2442
|
+
}
|
|
2443
|
+
function checkPass(cfg, catalogs, registry, fingerprints) {
|
|
2386
2444
|
const extracted = registry.messages();
|
|
2387
2445
|
const flat = {};
|
|
2388
2446
|
for (const locale of cfg.locales) flat[locale] = flatten(catalogs[locale] ?? {});
|
|
@@ -2677,14 +2735,6 @@ function includeTypes(root, file) {
|
|
|
2677
2735
|
writeFileSync(read.path, applyEdits(read.text, edits));
|
|
2678
2736
|
return "added";
|
|
2679
2737
|
}
|
|
2680
|
-
//#endregion
|
|
2681
|
-
//#region src/warn.ts
|
|
2682
|
-
const warned = /* @__PURE__ */ new Set();
|
|
2683
|
-
function warnOnce(message, dedupeKey = message) {
|
|
2684
|
-
if (warned.has(dedupeKey)) return;
|
|
2685
|
-
warned.add(dedupeKey);
|
|
2686
|
-
console.warn(`[verbaly] ${message}`);
|
|
2687
|
-
}
|
|
2688
2738
|
const DTS_HEADER = "// generated by verbaly: do not edit";
|
|
2689
2739
|
function generateDts(catalog, options = {}) {
|
|
2690
2740
|
const lines = [];
|
|
@@ -2876,14 +2926,20 @@ function suggestedPattern(rel) {
|
|
|
2876
2926
|
const slash = rel.indexOf("/");
|
|
2877
2927
|
return slash < 0 ? rel : `${rel.slice(0, slash)}/**/*.${SOURCE_EXTENSIONS}`;
|
|
2878
2928
|
}
|
|
2879
|
-
function
|
|
2880
|
-
if (cfg.include.length === 0) return () => void 0;
|
|
2929
|
+
function outsidePath(cfg) {
|
|
2881
2930
|
const included = picomatch(cfg.include);
|
|
2882
2931
|
const excluded = picomatch(cfg.exclude);
|
|
2883
|
-
return (
|
|
2932
|
+
return (id) => {
|
|
2884
2933
|
const rel = relativeId(cfg, id);
|
|
2885
|
-
|
|
2886
|
-
|
|
2934
|
+
return rel.startsWith("..") || included(rel) || excluded(rel) ? void 0 : rel;
|
|
2935
|
+
};
|
|
2936
|
+
}
|
|
2937
|
+
function createOutsideCheck(cfg) {
|
|
2938
|
+
if (cfg.include.length === 0) return () => void 0;
|
|
2939
|
+
const outside = outsidePath(cfg);
|
|
2940
|
+
return (code, id) => {
|
|
2941
|
+
const rel = outside(id);
|
|
2942
|
+
if (rel === void 0 || !TAGGED_HINT.test(code)) return void 0;
|
|
2887
2943
|
if (analyzeFile(code, id).tagged.length === 0) return void 0;
|
|
2888
2944
|
return {
|
|
2889
2945
|
file: id,
|
|
@@ -2894,6 +2950,7 @@ function createOutsideCheck(cfg) {
|
|
|
2894
2950
|
async function filesOutsideInclude(cfg) {
|
|
2895
2951
|
if (cfg.include.length === 0) return [];
|
|
2896
2952
|
const check = createOutsideCheck(cfg);
|
|
2953
|
+
const outside = outsidePath(cfg);
|
|
2897
2954
|
const files = await glob([`**/*.${SOURCE_EXTENSIONS}`], {
|
|
2898
2955
|
cwd: cfg.root,
|
|
2899
2956
|
ignore: [...NOT_SOURCE, ...cfg.exclude],
|
|
@@ -2901,14 +2958,15 @@ async function filesOutsideInclude(cfg) {
|
|
|
2901
2958
|
});
|
|
2902
2959
|
const found = [];
|
|
2903
2960
|
for (const file of files.sort()) {
|
|
2961
|
+
if (outside(file) === void 0) continue;
|
|
2904
2962
|
let code;
|
|
2905
2963
|
try {
|
|
2906
2964
|
code = readFileSync(file, "utf8");
|
|
2907
2965
|
} catch {
|
|
2908
2966
|
continue;
|
|
2909
2967
|
}
|
|
2910
|
-
const
|
|
2911
|
-
if (
|
|
2968
|
+
const entry = check(code, file);
|
|
2969
|
+
if (entry) found.push(entry);
|
|
2912
2970
|
}
|
|
2913
2971
|
return found;
|
|
2914
2972
|
}
|