@verbaly/mcp 0.67.0 → 0.69.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 +5 -5
- package/dist/cli.js +150 -87
- package/dist/cli.js.map +1 -1
- package/dist/index.js +150 -87
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -40,11 +40,11 @@ The server reads the project from its working directory; pass `--root <path>` (o
|
|
|
40
40
|
| `verbaly_init` | Create the config and the catalogs, and detect the bundler or meta-framework so the answer names what to add. Writes files, keeps what is already there, and writes `pt-BR` for a `pt_BR` it was given. |
|
|
41
41
|
| `verbaly_doctor` | Diagnose the whole setup: config, catalogs, plugin, types, unreadable files, orphan keys, every gate failure. Start here. Read-only. |
|
|
42
42
|
| `verbaly_wrap` | Find hardcoded text in JSX/TSX and wrap it so the compiler can extract it. This is how an existing codebase is onboarded. |
|
|
43
|
-
| `verbaly_extract` | Scan sources, add new messages to the catalogs, refresh the generated types. `dryRun` previews; `prune` drops dead keys and their drafts, and waits while any file does not parse. Names
|
|
44
|
-
| `verbaly_status` | Coverage per locale: total messages, translated counts, drafts awaiting review, translations written for an older source text. Read-only. |
|
|
45
|
-
| `verbaly_missing` | Missing translations, unknown keys and broken ones (the same gate `verbaly check` runs in CI), plus what never fails it: keys only a translation has, keys with two texts, a catalog that contradicts the code, outdated translations. Read-only. |
|
|
43
|
+
| `verbaly_extract` | Scan sources, add new messages to the catalogs, refresh the generated types. `dryRun` previews; `prune` drops dead keys and their drafts, and waits while any file does not parse. Names, with file and line, everything `verbaly extract` prints: files it could not read, keys written with two texts, `t` used under another name, source texts the code wrote over (with the text they had), and values a translator would see as `{_0}`. |
|
|
44
|
+
| `verbaly_status` | Coverage per locale: total messages, translated counts, drafts awaiting review, translations written for an older source text. A state file it cannot read is reported in `stateProblem`, never as a failed call. Read-only. |
|
|
45
|
+
| `verbaly_missing` | Missing translations, unknown keys and broken ones (the same gate `verbaly check` runs in CI), plus what never fails it: keys only a translation has, keys with two texts, a catalog that contradicts the code, outdated translations. Every path is relative to the project, as in `verbaly_extract`. Read-only. |
|
|
46
46
|
| `verbaly_translate` | Fill missing entries with the configured provider (default: Claude). Output is saved as drafts awaiting human review. |
|
|
47
|
-
| `verbaly_write_drafts` | Save translations the agent wrote itself. Each one is checked like a provider's (params, tags and plural cases must survive), written only for keys the source has,
|
|
47
|
+
| `verbaly_write_drafts` | Save translations the agent wrote itself. Each one is checked like a provider's (params, tags and plural cases must survive) against the text that ships, the one `verbaly_missing` reads, written only for keys the source has, marked as a draft and stamped for that text, so a source that changes later shows it as outdated. `overwrite` rewrites an outdated one. |
|
|
48
48
|
| `verbaly_drafts` | Every machine translation still waiting for a human, each with its source text and what the provider wrote. Read-only, and it cannot approve. |
|
|
49
49
|
|
|
50
50
|
Machine translations stay drafts until a human accepts them (`verbaly review --approve`), so an agent can fill gaps without silently shipping unreviewed text. **No tool here can approve a draft**, on purpose. That includes the agent's own work: `verbaly_write_drafts` is how it lands without anyone editing a catalog or `.verbaly-state.json` by hand, and it lands as a draft. `verbaly_drafts` is the other half of that promise: it shows each one next to its source, so the human deciding can actually read what they are accepting. Approving lives where a person is looking at the text: `verbaly review --approve`, or [`@verbaly/studio`](https://www.npmjs.com/package/@verbaly/studio).
|
|
@@ -56,7 +56,7 @@ Reading the project is an address, not a call, so these cost no tool invocation:
|
|
|
56
56
|
| Resource | What it holds |
|
|
57
57
|
| ---------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
58
58
|
| `verbaly://config` | Source locale, every locale, the catalog directory and where the language lives in the url. Read it first. |
|
|
59
|
-
| `verbaly://catalog/{locale}` | Every message of one locale, flattened the way the runtime reads it. An empty value means untranslated.
|
|
59
|
+
| `verbaly://catalog/{locale}` | Every message of one locale, flattened the way the runtime reads it, with the text your code ships where the code owns it. An empty value means untranslated. |
|
|
60
60
|
|
|
61
61
|
**This is the only way to read what a message says.** Every tool works in keys and counts, which is enough to report a gap and not enough to review a translation or write one in context.
|
|
62
62
|
|
package/dist/cli.js
CHANGED
|
@@ -3,8 +3,7 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
5
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
-
import { check, collectOrigins,
|
|
7
|
-
import { readFileSync } from "node:fs";
|
|
6
|
+
import { check, collectOrigins, counted, doctor, effectiveDrafts, extractProject, formatCheckResult, formatCheckWarnings, formatDoctorEntry, formatFinding, formatStatusResult, formatTranslateFailures, init, loadCatalogs, loadConfig, loadState, mergeTranslations, readState, recordTranslations, resolveProvider, shippedCatalogs, status, syncProject, translateCatalogs, wrapProject, writeDrafts } from "@verbaly/compiler";
|
|
8
7
|
import { relative } from "node:path";
|
|
9
8
|
import { z } from "zod";
|
|
10
9
|
//#region src/server.ts
|
|
@@ -29,12 +28,41 @@ const byLocale = (record) => Object.entries(record).map(([locale, keys]) => ({
|
|
|
29
28
|
locale,
|
|
30
29
|
keys
|
|
31
30
|
}));
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
const sourceSite = z.object({
|
|
32
|
+
file: z.string(),
|
|
33
|
+
line: z.number().optional(),
|
|
34
|
+
message: z.string()
|
|
35
|
+
});
|
|
36
|
+
function relativeTo(root) {
|
|
37
|
+
return (file) => relative(root, file).replaceAll("\\", "/");
|
|
38
|
+
}
|
|
39
|
+
function relativeCheck(root, result) {
|
|
40
|
+
const rel = relativeTo(root);
|
|
41
|
+
return {
|
|
42
|
+
...result,
|
|
43
|
+
unknown: result.unknown.map((entry) => ({
|
|
44
|
+
...entry,
|
|
45
|
+
files: entry.files.map(rel)
|
|
46
|
+
})),
|
|
47
|
+
extra: result.extra.map((entry) => ({
|
|
48
|
+
...entry,
|
|
49
|
+
files: entry.files.map(rel)
|
|
50
|
+
})),
|
|
51
|
+
collisions: result.collisions.map((entry) => ({
|
|
52
|
+
...entry,
|
|
53
|
+
sites: entry.sites.map((at) => ({
|
|
54
|
+
...at,
|
|
55
|
+
file: rel(at.file)
|
|
56
|
+
}))
|
|
57
|
+
})),
|
|
58
|
+
divergent: result.divergent.map((entry) => ({
|
|
59
|
+
...entry,
|
|
60
|
+
code: {
|
|
61
|
+
...entry.code,
|
|
62
|
+
file: rel(entry.code.file)
|
|
63
|
+
}
|
|
64
|
+
}))
|
|
65
|
+
};
|
|
38
66
|
}
|
|
39
67
|
function createVerbalyMcp(options = {}) {
|
|
40
68
|
const server = new McpServer({
|
|
@@ -84,7 +112,7 @@ function createVerbalyMcp(options = {}) {
|
|
|
84
112
|
})) };
|
|
85
113
|
} }), {
|
|
86
114
|
title: "Locale catalog",
|
|
87
|
-
description: "Every message of one locale, keyed the way the runtime sees them: a nested catalog arrives flattened, and an empty value means untranslated. This is the only way to read what a message actually says.",
|
|
115
|
+
description: "Every message of one locale, keyed the way the runtime sees them: a nested catalog arrives flattened, a text the code owns reads as the code has it, and an empty value means untranslated. This is the only way to read what a message actually says.",
|
|
88
116
|
mimeType: "application/json"
|
|
89
117
|
}, async (uri, { locale }) => {
|
|
90
118
|
const cfg = await config();
|
|
@@ -93,7 +121,8 @@ function createVerbalyMcp(options = {}) {
|
|
|
93
121
|
const have = cfg.locales.join(", ");
|
|
94
122
|
throw new Error(`[verbaly] unknown locale "${name}": the project has ${have}`);
|
|
95
123
|
}
|
|
96
|
-
const
|
|
124
|
+
const registry = await extractProject(cfg);
|
|
125
|
+
const catalog = shippedCatalogs(cfg, loadCatalogs(cfg), registry, { newKeys: false })[name] ?? {};
|
|
97
126
|
return { contents: [{
|
|
98
127
|
uri: uri.href,
|
|
99
128
|
mimeType: "application/json",
|
|
@@ -240,68 +269,85 @@ function createVerbalyMcp(options = {}) {
|
|
|
240
269
|
})).describe("Source files the parser could not read: their messages are not extracted, and prune drops nothing until they parse"),
|
|
241
270
|
collisions: z.array(z.object({
|
|
242
271
|
key: z.string(),
|
|
243
|
-
sites: z.array(
|
|
244
|
-
file: z.string(),
|
|
245
|
-
line: z.number().optional(),
|
|
246
|
-
message: z.string()
|
|
247
|
-
}))
|
|
272
|
+
sites: z.array(sourceSite)
|
|
248
273
|
})).describe("Keys written with more than one text: every place shows the text of the first site, so give each text its own key"),
|
|
249
274
|
renamed: z.array(z.object({
|
|
250
275
|
file: z.string(),
|
|
251
276
|
line: z.number().optional(),
|
|
252
277
|
name: z.string()
|
|
253
|
-
})).describe("Tagged templates on t under another name (const tr = useT()): never extracted, so they stay in the source language until the binding is named t")
|
|
278
|
+
})).describe("Tagged templates on t under another name (const tr = useT()): never extracted, so they stay in the source language until the binding is named t"),
|
|
279
|
+
replaced: z.array(z.object({
|
|
280
|
+
key: z.string(),
|
|
281
|
+
before: z.string(),
|
|
282
|
+
code: sourceSite
|
|
283
|
+
})).describe("Source texts the code wrote over: before is what the catalog said, code is the text that ships. An edit made in the code reads like this too"),
|
|
284
|
+
positional: z.array(z.object({
|
|
285
|
+
params: z.array(z.string()),
|
|
286
|
+
code: sourceSite
|
|
287
|
+
})).describe("Messages that hand a translator a nameless value like {_0}: put the value in a named variable first"),
|
|
288
|
+
escaped: z.array(z.object({
|
|
289
|
+
slice: z.string(),
|
|
290
|
+
code: sourceSite
|
|
291
|
+
})).describe("Plural or format blocks inside a tagged template, which render as literal text"),
|
|
292
|
+
stateProblem: z.string().optional().describe("The state file could not be read or written: the catalogs were written, drafts and outdated tracking were not")
|
|
254
293
|
}
|
|
255
294
|
}, guarded(async ({ root, prune, dryRun }) => {
|
|
256
295
|
const cfg = await config(root);
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (!dryRun) {
|
|
269
|
-
for (const locale of cfg.locales) writeCatalog(cfg, locale, catalogs[locale] ?? {});
|
|
270
|
-
writeDts(cfg, catalogs[cfg.sourceLocale] ?? {});
|
|
271
|
-
updateState(cfg, catalogs);
|
|
272
|
-
}
|
|
273
|
-
const rel = (file) => relative(cfg.root, file).replaceAll("\\", "/");
|
|
274
|
-
const collisions = collisionEntries(registry).map(({ key, sites }) => ({
|
|
275
|
-
key,
|
|
276
|
-
sites: sites.map((at) => ({
|
|
277
|
-
...at,
|
|
278
|
-
file: rel(at.file)
|
|
279
|
-
}))
|
|
280
|
-
}));
|
|
281
|
-
const renamed = registry.missed().map(({ name, file, start }) => ({
|
|
282
|
-
file: rel(file),
|
|
283
|
-
line: lineOf(file, start),
|
|
284
|
-
name
|
|
285
|
-
}));
|
|
286
|
-
const messages = registry.messages().size;
|
|
287
|
-
lines.unshift(`${counted(messages, "message")} · locales: ${cfg.locales.join(", ")}${dryRun ? " (dry run, nothing written)" : ""}`);
|
|
288
|
-
for (const { locale, keys } of added) lines.push(`${locale}: ${dryRun ? `would add ${keys.length}` : `+${keys.length} added`}`);
|
|
289
|
-
for (const { file, message } of unparsed) lines.push(`${file}: could not be parsed (${message}), its messages were not extracted`);
|
|
290
|
-
for (const { key, sites } of collisions) {
|
|
291
|
-
const where = sites.map((at) => at.line ? `${at.file}:${at.line}` : at.file).join(", ");
|
|
292
|
-
lines.push(`${key}: one key with ${counted(sites.length, "text")} (${where}), every place shows the first`);
|
|
293
|
-
}
|
|
294
|
-
for (const { file, line, name } of renamed) lines.push(`${file}${line ? `:${line}` : ""}: ${name}\`…\` is never extracted, name the binding t`);
|
|
295
|
-
return reply(lines.join("\n"), {
|
|
296
|
-
messages,
|
|
296
|
+
const result = await syncProject(cfg, {
|
|
297
|
+
prune,
|
|
298
|
+
dryRun
|
|
299
|
+
});
|
|
300
|
+
const rel = relativeTo(cfg.root);
|
|
301
|
+
const at = (code) => ({
|
|
302
|
+
...code,
|
|
303
|
+
file: rel(code.file)
|
|
304
|
+
});
|
|
305
|
+
const data = {
|
|
306
|
+
messages: result.registry.messages().size,
|
|
297
307
|
locales: cfg.locales,
|
|
298
308
|
dryRun: dryRun === true,
|
|
299
|
-
added,
|
|
300
|
-
pruned,
|
|
301
|
-
unparsed,
|
|
302
|
-
collisions,
|
|
303
|
-
renamed
|
|
309
|
+
added: byLocale(result.added),
|
|
310
|
+
pruned: byLocale(result.pruned),
|
|
311
|
+
unparsed: [],
|
|
312
|
+
collisions: [],
|
|
313
|
+
renamed: [],
|
|
314
|
+
replaced: [],
|
|
315
|
+
positional: [],
|
|
316
|
+
escaped: [],
|
|
317
|
+
...result.stateProblem && { stateProblem: result.stateProblem }
|
|
318
|
+
};
|
|
319
|
+
for (const finding of result.findings) if (finding.kind === "unparsed") data.unparsed.push({
|
|
320
|
+
file: rel(finding.file),
|
|
321
|
+
message: finding.message
|
|
322
|
+
});
|
|
323
|
+
else if (finding.kind === "collision") data.collisions.push({
|
|
324
|
+
key: finding.key,
|
|
325
|
+
sites: finding.sites.map(at)
|
|
326
|
+
});
|
|
327
|
+
else if (finding.kind === "renamed") data.renamed.push({
|
|
328
|
+
...finding,
|
|
329
|
+
file: rel(finding.file)
|
|
304
330
|
});
|
|
331
|
+
else if (finding.kind === "replaced") data.replaced.push({
|
|
332
|
+
key: finding.key,
|
|
333
|
+
before: finding.before,
|
|
334
|
+
code: at(finding.site)
|
|
335
|
+
});
|
|
336
|
+
else if (finding.kind === "positional") data.positional.push({
|
|
337
|
+
params: finding.params,
|
|
338
|
+
code: at(finding.site)
|
|
339
|
+
});
|
|
340
|
+
else if (finding.kind === "escaped") data.escaped.push({
|
|
341
|
+
slice: finding.slice,
|
|
342
|
+
code: at(finding.site)
|
|
343
|
+
});
|
|
344
|
+
const lines = [`${counted(data.messages, "message")} · locales: ${cfg.locales.join(", ")}${dryRun ? " (dry run, nothing written)" : ""}`];
|
|
345
|
+
if (result.pruneBlocked) lines.push("prune skipped: an unparsed file may read any key, so it waits until every file parses");
|
|
346
|
+
for (const { locale, keys } of data.pruned) lines.push(dryRun ? `${locale}: would prune ${keys.length}: ${keys.join(", ")}` : `${locale}: ${keys.length} pruned`);
|
|
347
|
+
for (const { locale, keys } of data.added) lines.push(`${locale}: ${dryRun ? `would add ${keys.length}` : `+${keys.length} added`}`);
|
|
348
|
+
for (const finding of result.findings) lines.push(formatFinding(finding, cfg.root));
|
|
349
|
+
if (result.stateProblem) lines.push(`${result.stateProblem}, so drafts and outdated translations were not updated`);
|
|
350
|
+
return reply(lines.join("\n"), data);
|
|
305
351
|
}));
|
|
306
352
|
server.registerTool("verbaly_status", {
|
|
307
353
|
title: "Translation coverage",
|
|
@@ -317,15 +363,20 @@ function createVerbalyMcp(options = {}) {
|
|
|
317
363
|
drafts: z.number().describe("Machine translations awaiting human review"),
|
|
318
364
|
broken: z.number().describe("Present but not rendering what the source renders"),
|
|
319
365
|
outdated: z.number().describe("Translated from an older source text: update them, or a human keeps them")
|
|
320
|
-
}))
|
|
366
|
+
})),
|
|
367
|
+
stateProblem: z.string().optional().describe("The state file could not be read, so drafts and outdated are counted as zero")
|
|
321
368
|
},
|
|
322
369
|
annotations: { readOnlyHint: true }
|
|
323
370
|
}, guarded(async ({ root }) => {
|
|
324
371
|
const cfg = await config(root);
|
|
325
372
|
const registry = await extractProject(cfg);
|
|
326
|
-
const state =
|
|
373
|
+
const { state, problem } = readState(cfg);
|
|
327
374
|
const result = status(cfg, loadCatalogs(cfg), registry, state.drafts, state.fingerprints);
|
|
328
|
-
|
|
375
|
+
const body = formatStatusResult(result);
|
|
376
|
+
return reply(problem ? `${body}\n${problem}, so drafts and outdated are not counted` : body, {
|
|
377
|
+
...result,
|
|
378
|
+
...problem && { stateProblem: problem }
|
|
379
|
+
});
|
|
329
380
|
}));
|
|
330
381
|
server.registerTool("verbaly_missing", {
|
|
331
382
|
title: "Missing and broken translations",
|
|
@@ -358,30 +409,26 @@ function createVerbalyMcp(options = {}) {
|
|
|
358
409
|
})).describe("Keys only a translation has; files are where the code reads one, which the source language then shows as the key itself. Never fails the gate"),
|
|
359
410
|
collisions: z.array(z.object({
|
|
360
411
|
key: z.string(),
|
|
361
|
-
sites: z.array(
|
|
362
|
-
file: z.string(),
|
|
363
|
-
line: z.number().optional(),
|
|
364
|
-
message: z.string()
|
|
365
|
-
}))
|
|
412
|
+
sites: z.array(sourceSite)
|
|
366
413
|
})).describe("One key, several texts: every place shows the first site. Never fails the gate"),
|
|
367
414
|
divergent: z.array(z.object({
|
|
368
415
|
key: z.string(),
|
|
369
416
|
catalog: z.string(),
|
|
370
|
-
code:
|
|
371
|
-
file: z.string(),
|
|
372
|
-
line: z.number().optional(),
|
|
373
|
-
message: z.string()
|
|
374
|
-
})
|
|
417
|
+
code: sourceSite
|
|
375
418
|
})).describe("The source catalog says one text and the code another: the code's text ships. Never fails the gate"),
|
|
376
419
|
outdated: perLocaleEntries.describe("Translations written for an older source text: rewrite them, or a human keeps them with verbaly review --approve. Never fails the gate"),
|
|
377
|
-
unreviewed: perLocale
|
|
420
|
+
unreviewed: perLocale,
|
|
421
|
+
stateProblem: z.string().optional().describe("The state file could not be read, so outdated translations are not listed")
|
|
378
422
|
},
|
|
379
423
|
annotations: { readOnlyHint: true }
|
|
380
424
|
}, guarded(async ({ root, drafts }) => {
|
|
381
425
|
const cfg = await config(root);
|
|
382
426
|
const registry = await extractProject(cfg);
|
|
383
427
|
const catalogs = loadCatalogs(cfg);
|
|
384
|
-
const state =
|
|
428
|
+
const { state, problem } = drafts ? {
|
|
429
|
+
state: loadState(cfg),
|
|
430
|
+
problem: void 0
|
|
431
|
+
} : readState(cfg);
|
|
385
432
|
const result = check(cfg, catalogs, registry, state.fingerprints);
|
|
386
433
|
const unreviewed = drafts ? byLocale(effectiveDrafts(state.drafts, catalogs)) : [];
|
|
387
434
|
const lines = [];
|
|
@@ -389,9 +436,11 @@ function createVerbalyMcp(options = {}) {
|
|
|
389
436
|
const warnings = formatCheckWarnings(result, cfg.root);
|
|
390
437
|
if (warnings) lines.push(`warnings (the gate still passes):\n${warnings}`);
|
|
391
438
|
for (const { locale, keys } of unreviewed) if (keys.length) lines.push(`[${locale}] ${keys.length} unreviewed: ${keys.join(", ")}`);
|
|
439
|
+
if (problem) lines.push(`${problem}, so outdated translations are not listed`);
|
|
392
440
|
return reply(lines.length === 0 ? "all translations complete" : lines.join("\n"), {
|
|
393
|
-
...result,
|
|
394
|
-
unreviewed
|
|
441
|
+
...relativeCheck(cfg.root, result),
|
|
442
|
+
unreviewed,
|
|
443
|
+
...problem && { stateProblem: problem }
|
|
395
444
|
});
|
|
396
445
|
}));
|
|
397
446
|
server.registerTool("verbaly_translate", {
|
|
@@ -416,7 +465,9 @@ function createVerbalyMcp(options = {}) {
|
|
|
416
465
|
}
|
|
417
466
|
}, guarded(async ({ root, locales, dryRun }) => {
|
|
418
467
|
const cfg = await config(root);
|
|
419
|
-
|
|
468
|
+
if (!dryRun) loadState(cfg);
|
|
469
|
+
const registry = await extractProject(cfg);
|
|
470
|
+
const catalogs = shippedCatalogs(cfg, loadCatalogs(cfg), registry, { newKeys: false });
|
|
420
471
|
const provider = await resolveProvider(cfg);
|
|
421
472
|
const result = await translateCatalogs(cfg, catalogs, provider, {
|
|
422
473
|
locales,
|
|
@@ -424,7 +475,7 @@ function createVerbalyMcp(options = {}) {
|
|
|
424
475
|
concurrency: cfg.translate.concurrency,
|
|
425
476
|
retries: cfg.translate.retries,
|
|
426
477
|
dryRun,
|
|
427
|
-
origins: dryRun ? void 0 : await collectOrigins(cfg)
|
|
478
|
+
origins: dryRun ? void 0 : await collectOrigins(cfg, registry)
|
|
428
479
|
});
|
|
429
480
|
if (dryRun) {
|
|
430
481
|
const pending = byLocale(result.pending);
|
|
@@ -439,17 +490,25 @@ function createVerbalyMcp(options = {}) {
|
|
|
439
490
|
};
|
|
440
491
|
return reply(lines.length === 0 ? "nothing to translate" : lines.join("\n"), data);
|
|
441
492
|
}
|
|
442
|
-
const drafts = loadDrafts(cfg);
|
|
443
493
|
const written = {};
|
|
444
494
|
const kept = {};
|
|
495
|
+
const writes = [];
|
|
445
496
|
for (const [locale, keys] of Object.entries(result.translated)) {
|
|
446
|
-
const
|
|
447
|
-
|
|
497
|
+
const catalog = catalogs[locale] ?? {};
|
|
498
|
+
const landed = mergeTranslations(cfg, locale, catalog, keys);
|
|
499
|
+
writes.push({
|
|
500
|
+
locale,
|
|
501
|
+
draft: true,
|
|
502
|
+
entries: landed.map((key) => ({
|
|
503
|
+
key,
|
|
504
|
+
text: catalog[key]
|
|
505
|
+
}))
|
|
506
|
+
});
|
|
448
507
|
if (landed.length > 0) written[locale] = landed;
|
|
449
508
|
const left = keys.filter((key) => !landed.includes(key));
|
|
450
509
|
if (left.length > 0) kept[locale] = left;
|
|
451
510
|
}
|
|
452
|
-
if (
|
|
511
|
+
if (writes.length > 0) recordTranslations(cfg, catalogs[cfg.sourceLocale] ?? {}, writes);
|
|
453
512
|
const data = {
|
|
454
513
|
dryRun: false,
|
|
455
514
|
translated: byLocale(written),
|
|
@@ -487,7 +546,11 @@ function createVerbalyMcp(options = {}) {
|
|
|
487
546
|
}
|
|
488
547
|
}, guarded(async ({ root, locale, entries, overwrite }) => {
|
|
489
548
|
const cfg = await config(root);
|
|
490
|
-
const
|
|
549
|
+
const registry = await extractProject(cfg);
|
|
550
|
+
const result = writeDrafts(cfg, locale, entries, {
|
|
551
|
+
overwrite,
|
|
552
|
+
registry
|
|
553
|
+
});
|
|
491
554
|
const lines = [];
|
|
492
555
|
if (result.written.length > 0) lines.push(`${locale}: +${result.written.length} saved as drafts, awaiting human review`);
|
|
493
556
|
if (result.kept.length > 0) lines.push(`${locale}: ${result.kept.length} already translated, kept: ${result.kept.join(", ")}`);
|
|
@@ -515,8 +578,8 @@ function createVerbalyMcp(options = {}) {
|
|
|
515
578
|
}, guarded(async ({ root, locales }) => {
|
|
516
579
|
const cfg = await config(root);
|
|
517
580
|
const catalogs = loadCatalogs(cfg);
|
|
518
|
-
const source = catalogs[cfg.sourceLocale] ?? {};
|
|
519
|
-
const pending = effectiveDrafts(
|
|
581
|
+
const source = shippedCatalogs(cfg, catalogs, await extractProject(cfg))[cfg.sourceLocale] ?? {};
|
|
582
|
+
const pending = effectiveDrafts(loadState(cfg).drafts, catalogs);
|
|
520
583
|
const wanted = locales ?? cfg.locales;
|
|
521
584
|
const entries = Object.entries(pending).filter(([locale]) => wanted.includes(locale)).flatMap(([locale, keys]) => keys.map((key) => ({
|
|
522
585
|
locale,
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/server.ts","../src/cli.ts"],"sourcesContent":["import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport {\n check,\n collisionEntries,\n collectOrigins,\n counted,\n doctor,\n effectiveDrafts,\n extractProject,\n formatCheckResult,\n formatCheckWarnings,\n formatDoctorEntry,\n formatStatusResult,\n formatTranslateFailures,\n init,\n loadCatalogs,\n loadConfig,\n loadDrafts,\n loadState,\n markDrafts,\n mergeTranslations,\n pruneCatalogs,\n resolveProvider,\n saveDrafts,\n status,\n syncCatalogs,\n translateCatalogs,\n updateState,\n wrapProject,\n writeCatalog,\n writeDrafts,\n writeDts,\n type ResolvedConfig,\n} from '@verbaly/compiler';\nimport { readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { relative } from 'node:path';\nimport { z } from 'zod';\n\nconst { version } = createRequire(import.meta.url)('../package.json') as { version: string };\n\nexport interface VerbalyMcpOptions {\n root?: string;\n}\n\n// text stays the fallback for a client that reads no schema, structuredContent is what agents parse\nconst reply = (body: string, data: Record<string, unknown>): CallToolResult => ({\n content: [{ type: 'text', text: body }],\n structuredContent: data,\n});\n\nconst rootInput = z\n .string()\n .optional()\n .describe('Project root holding verbaly.config (defaults to the server working directory)');\n\nconst perLocale = z.array(z.object({ locale: z.string(), keys: z.array(z.string()) }));\n\nconst perLocaleEntries = z.array(z.object({ locale: z.string(), key: z.string() }));\n\n// a locale-keyed record is a dynamic schema an agent cannot read ahead: lists enumerate\nconst byLocale = (record: Record<string, string[]>): Array<{ locale: string; keys: string[] }> =>\n Object.entries(record).map(([locale, keys]) => ({ locale, keys }));\n\n// a line number from the source the scan read; a file gone since then has none\nfunction lineOf(file: string, offset: number): number | undefined {\n try {\n return readFileSync(file, 'utf8').slice(0, offset).split('\\n').length;\n } catch {\n return undefined;\n }\n}\n\nexport function createVerbalyMcp(options: VerbalyMcpOptions = {}): McpServer {\n const server = new McpServer({ name: 'verbaly', version });\n\n const config = (root?: string): Promise<ResolvedConfig> =>\n loadConfig(root ?? options.root ?? process.cwd());\n\n // agents act on messages, not stack traces: every failure comes back as actionable text\n const guarded =\n <A>(run: (args: A) => Promise<CallToolResult>) =>\n async (args: A): Promise<CallToolResult> => {\n try {\n return await run(args);\n } catch (error) {\n return {\n content: [{ type: 'text', text: error instanceof Error ? error.message : String(error) }],\n isError: true,\n };\n }\n };\n\n // resources, not tools: reading the project is an address, and it must not spend a tool call\n server.registerResource(\n 'verbaly-config',\n 'verbaly://config',\n {\n title: 'Project shape',\n description:\n 'The resolved Verbaly config: source locale, every locale, the catalog directory and where the language lives in the url. Read this before reasoning about anything else in the project.',\n mimeType: 'application/json',\n },\n async (uri) => {\n const cfg = await config();\n const shape = {\n root: cfg.root,\n sourceLocale: cfg.sourceLocale,\n locales: cfg.locales,\n localesDeclared: cfg.localesDeclared,\n dir: cfg.dir,\n routing: cfg.routing,\n include: cfg.include,\n };\n return {\n contents: [\n { uri: uri.href, mimeType: 'application/json', text: JSON.stringify(shape, null, 2) },\n ],\n };\n },\n );\n\n server.registerResource(\n 'verbaly-catalog',\n new ResourceTemplate('verbaly://catalog/{locale}', {\n list: async () => {\n const cfg = await config();\n return {\n resources: cfg.locales.map((locale) => ({\n name: `${locale} catalog`,\n uri: `verbaly://catalog/${locale}`,\n mimeType: 'application/json',\n })),\n };\n },\n }),\n {\n title: 'Locale catalog',\n description:\n 'Every message of one locale, keyed the way the runtime sees them: a nested catalog arrives flattened, and an empty value means untranslated. This is the only way to read what a message actually says.',\n mimeType: 'application/json',\n },\n async (uri, { locale }) => {\n const cfg = await config();\n const name = String(locale);\n if (!cfg.locales.includes(name)) {\n const have = cfg.locales.join(', ');\n throw new Error(`[verbaly] unknown locale \"${name}\": the project has ${have}`);\n }\n const catalog = loadCatalogs(cfg)[name] ?? {};\n return {\n contents: [\n { uri: uri.href, mimeType: 'application/json', text: JSON.stringify(catalog, null, 2) },\n ],\n };\n },\n );\n\n server.registerTool(\n 'verbaly_init',\n {\n title: 'Set up Verbaly in a project',\n description:\n 'Create the config file and the locale catalogs, and detect the bundler or meta-framework so the answer names the package to add and the line to wire (what `verbaly init` does). Writes files, and a file already there is kept rather than overwritten. Run this when doctor says there is no config.',\n inputSchema: {\n root: rootInput,\n dir: z.string().optional().describe('Directory for the catalogs (default: locales)'),\n sourceLocale: z.string().optional().describe('The language you write in (default: en)'),\n locales: z.array(z.string()).optional().describe('Every locale, source included'),\n },\n outputSchema: {\n created: z.array(z.string()).describe('Files written, relative to the project root'),\n skipped: z.array(z.string()).describe('Files already there, left untouched'),\n host: z\n .string()\n .optional()\n .describe('Bundler or meta-framework detected from the dependencies'),\n configFile: z.string(),\n next: z.array(z.string()).describe('What a human still has to do, in order'),\n renamed: z\n .array(z.object({ from: z.string(), to: z.string() }))\n .describe('Locales written with the hyphen a locale tag takes (pt_BR became pt-BR)'),\n refused: z\n .array(z.string())\n .describe('Locales left out: not a locale tag, and no sure way to fix one'),\n },\n },\n guarded(async ({ root, dir, sourceLocale, locales }) => {\n const result = await init({ root: root ?? options.root, dir, sourceLocale, locales });\n const lines: string[] = [];\n if (result.created.length) lines.push(`created: ${result.created.join(', ')}`);\n if (result.skipped.length) lines.push(`kept (already there): ${result.skipped.join(', ')}`);\n for (const { from, to } of result.renamed) lines.push(`wrote ${to} for ${from}`);\n for (const locale of result.refused) {\n lines.push(`left out \"${locale}\": it is not a locale tag, use one like es or pt-BR`);\n }\n if (result.host) lines.push(`detected: ${result.host}`);\n lines.push(...result.next.map((step, i) => `${i + 1}. ${step}`));\n return reply(lines.join('\\n'), { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_doctor',\n {\n title: 'Diagnose the setup',\n description:\n 'Diagnose a Verbaly project end to end (what `verbaly doctor` does): the config file, the catalog files and their JSON, the bundler plugin for the detected framework, the generated types, files the parser could not read, t imported from a package that never exports it, orphan keys, and every failure `verbaly check` would report. Run this first when something does not work. Read-only.',\n inputSchema: { root: rootInput },\n outputSchema: {\n ok: z.boolean().describe('False when an entry is an error, which is when the CLI exits 1'),\n entries: z.array(\n z.object({\n level: z.enum(['ok', 'warn', 'error']),\n check: z.string(),\n message: z.string(),\n fix: z.string().optional().describe('What to run or change, when there is one'),\n }),\n ),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root }) => {\n const cfg = await config(root);\n const result = await doctor(cfg);\n const health = result.ok ? 'setup looks healthy' : 'problems found';\n const head = `${counted(result.entries.length, 'check')}, ${health}`;\n return reply([head, ...result.entries.map(formatDoctorEntry)].join('\\n'), { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_wrap',\n {\n title: 'Wrap hardcoded JSX text',\n description:\n 'Find hardcoded user-visible text in JSX/TSX files and wrap it in a t tagged template so the compiler can extract it (what `verbaly wrap` does). This is how an existing codebase is onboarded. Reports only unless write is set. Text it cannot wrap safely (a sentence split across markup, an expression rendering JSX) is listed as needing a human and never rewritten. A file that does not bind t is never written either, because the rewrite would not compile: those come back in blocked, with whether the file is a client component, so you can add the binding and run again.',\n inputSchema: {\n root: rootInput,\n write: z.boolean().optional().describe('Apply the rewrites instead of only reporting'),\n },\n outputSchema: {\n files: z.number().describe('JSX/TSX files scanned'),\n write: z.boolean(),\n changed: z.array(z.string()).describe('Files the rewrite touched, or would touch'),\n wrapped: z.array(\n z.object({\n file: z.string(),\n line: z.number(),\n text: z.string(),\n kind: z.enum(['text', 'attribute']),\n attribute: z.string().optional(),\n }),\n ),\n skipped: z.array(\n z.object({ file: z.string(), line: z.number(), text: z.string(), reason: z.string() }),\n ),\n blocked: z.array(\n z.object({ file: z.string(), texts: z.number(), client: z.boolean() }),\n ),\n },\n },\n guarded(async ({ root, write }) => {\n const cfg = await config(root);\n const result = await wrapProject(cfg, { write });\n const blocked = new Set(result.blocked.map((entry) => entry.file));\n const done = result.changed.filter((file) => !blocked.has(file));\n const texts = result.wrapped.filter((entry) => !blocked.has(entry.file));\n const verb = write ? 'wrapped' : 'would wrap';\n const counts = write\n ? `${counted(texts.length, 'text')} in ${counted(done.length, 'file')}`\n : `${counted(result.wrapped.length, 'text')} in ${counted(result.changed.length, 'file')}`;\n const lines = [`${verb} ${counts} of ${counted(result.files, 'file')} scanned`];\n for (const entry of write ? texts : result.wrapped) {\n const attr = entry.kind === 'attribute' ? `${entry.attribute} -> ` : '';\n lines.push(` ${entry.file}:${entry.line} ${attr}\"${entry.text}\"`);\n }\n if (result.skipped.length > 0) {\n lines.push(' needs a human:');\n for (const entry of result.skipped) {\n lines.push(` ${entry.file}:${entry.line} \"${entry.text}\" (${entry.reason})`);\n }\n }\n if (result.blocked.length > 0) {\n lines.push(` nothing written in ${counted(result.blocked.length, 'file')} with no t in scope:`);\n for (const entry of result.blocked) {\n const how = entry.client ? '\"use client\", so const t = useT()' : 'no \"use client\"';\n lines.push(` ${entry.file} ${counted(entry.texts, 'text')}, ${how}`);\n }\n lines.push(' next: bind t there, run verbaly_wrap with write again, then verbaly_extract');\n } else if (write && done.length > 0) {\n lines.push(' next: run verbaly_extract');\n }\n return reply(lines.join('\\n'), { ...result, write: write === true });\n }),\n );\n\n server.registerTool(\n 'verbaly_extract',\n {\n title: 'Extract messages',\n description:\n 'Scan the source files, add new messages to the locale catalogs and refresh the generated types (what `verbaly extract` does). Writes catalog files unless dryRun is set. prune drops keys no longer referenced in the code, translations included.',\n inputSchema: {\n root: rootInput,\n prune: z\n .boolean()\n .optional()\n .describe('Drop keys no longer referenced (deletes their translations)'),\n dryRun: z.boolean().optional().describe('Report what would change, write nothing'),\n },\n outputSchema: {\n messages: z.number(),\n locales: z.array(z.string()),\n dryRun: z.boolean(),\n added: perLocale,\n pruned: perLocale,\n unparsed: z\n .array(z.object({ file: z.string(), message: z.string() }))\n .describe(\n 'Source files the parser could not read: their messages are not extracted, and prune drops nothing until they parse',\n ),\n collisions: z\n .array(z.object({ key: z.string(), sites: z.array(z.object({ file: z.string(), line: z.number().optional(), message: z.string() })) }))\n .describe(\n 'Keys written with more than one text: every place shows the text of the first site, so give each text its own key',\n ),\n renamed: z\n .array(z.object({ file: z.string(), line: z.number().optional(), name: z.string() }))\n .describe(\n 'Tagged templates on t under another name (const tr = useT()): never extracted, so they stay in the source language until the binding is named t',\n ),\n },\n },\n guarded(async ({ root, prune, dryRun }) => {\n const cfg = await config(root);\n const registry = await extractProject(cfg);\n const catalogs = loadCatalogs(cfg);\n // an agent sees no terminal, so what the CLI prints about these has to be in the answer\n const unparsed = registry.parseErrors().map(({ file, message }) => ({\n file: relative(cfg.root, file).replaceAll('\\\\', '/'),\n message,\n }));\n\n const lines: string[] = [];\n const pruned = prune ? byLocale(pruneCatalogs(cfg, catalogs, registry)) : [];\n if (prune && unparsed.length > 0) {\n lines.push(\n 'prune skipped: an unparsed file may read any key, so it waits until every file parses',\n );\n }\n for (const { locale, keys } of pruned) {\n lines.push(\n dryRun\n ? `${locale}: would prune ${keys.length}: ${keys.join(', ')}`\n : `${locale}: ${keys.length} pruned`,\n );\n }\n const added = byLocale(syncCatalogs(cfg, catalogs, registry).added);\n if (!dryRun) {\n for (const locale of cfg.locales) {\n writeCatalog(cfg, locale, catalogs[locale] ?? {});\n }\n writeDts(cfg, catalogs[cfg.sourceLocale] ?? {});\n // a pruned key takes its draft with it, so nobody has to clean the state file by hand\n updateState(cfg, catalogs);\n }\n const rel = (file: string): string => relative(cfg.root, file).replaceAll('\\\\', '/');\n const collisions = collisionEntries(registry).map(({ key, sites }) => ({\n key,\n sites: sites.map((at) => ({ ...at, file: rel(at.file) })),\n }));\n const renamed = registry.missed().map(({ name, file, start }) => ({\n file: rel(file),\n line: lineOf(file, start),\n name,\n }));\n const messages = registry.messages().size;\n lines.unshift(\n `${counted(messages, 'message')} · locales: ${cfg.locales.join(', ')}${dryRun ? ' (dry run, nothing written)' : ''}`,\n );\n for (const { locale, keys } of added) {\n lines.push(`${locale}: ${dryRun ? `would add ${keys.length}` : `+${keys.length} added`}`);\n }\n for (const { file, message } of unparsed) {\n lines.push(`${file}: could not be parsed (${message}), its messages were not extracted`);\n }\n for (const { key, sites } of collisions) {\n const where = sites.map((at) => (at.line ? `${at.file}:${at.line}` : at.file)).join(', ');\n lines.push(`${key}: one key with ${counted(sites.length, 'text')} (${where}), every place shows the first`);\n }\n for (const { file, line, name } of renamed) {\n lines.push(`${file}${line ? `:${line}` : ''}: ${name}\\`…\\` is never extracted, name the binding t`);\n }\n return reply(lines.join('\\n'), {\n messages,\n locales: cfg.locales,\n dryRun: dryRun === true,\n added,\n pruned,\n unparsed,\n collisions,\n renamed,\n });\n }),\n );\n\n server.registerTool(\n 'verbaly_status',\n {\n title: 'Translation coverage',\n description:\n 'Translation coverage of the Verbaly project: total messages, translated count per locale, machine translations awaiting review (drafts) and translations written for an older source text (outdated). Read-only.',\n inputSchema: { root: rootInput },\n outputSchema: {\n messages: z.number().describe('Messages the project has, source catalog plus code'),\n source: z.string().describe('Source locale'),\n locales: z.array(\n z.object({\n locale: z.string(),\n translated: z.number(),\n total: z.number(),\n drafts: z.number().describe('Machine translations awaiting human review'),\n broken: z.number().describe('Present but not rendering what the source renders'),\n outdated: z\n .number()\n .describe('Translated from an older source text: update them, or a human keeps them'),\n }),\n ),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root }) => {\n const cfg = await config(root);\n const registry = await extractProject(cfg);\n const state = loadState(cfg);\n const result = status(cfg, loadCatalogs(cfg), registry, state.drafts, state.fingerprints);\n return reply(formatStatusResult(result), { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_missing',\n {\n title: 'Missing and broken translations',\n description:\n 'List missing translations, unknown keys and translations that exist but cannot render what the source renders (a dropped {param}, a lost rich tag, a flattened plural block), the same gate `verbaly check` runs in CI. Warnings never fail the gate and are listed too: an incomplete plural set for the locale, keys a translation carries that the source catalog does not (extra), keys written with two texts (collisions), texts the code and the source catalog disagree on (divergent, the text in the code ships) and translations written for an older source text (outdated). Optionally also lists machine translations awaiting review. Read-only.',\n inputSchema: {\n root: rootInput,\n drafts: z\n .boolean()\n .optional()\n .describe('Also list machine translations awaiting human review'),\n },\n outputSchema: {\n ok: z.boolean().describe('Whether `verbaly check` would pass (warnings never fail it)'),\n missing: z.array(\n z.object({ locale: z.string(), key: z.string(), source: z.string().optional() }),\n ),\n unknown: z.array(z.object({ key: z.string(), files: z.array(z.string()) })),\n broken: z.array(\n z.object({\n locale: z.string(),\n key: z.string(),\n severity: z.enum(['error', 'warning']),\n issue: z.string(),\n }),\n ),\n extra: z\n .array(z.object({ locale: z.string(), key: z.string(), files: z.array(z.string()) }))\n .describe(\n 'Keys only a translation has; files are where the code reads one, which the source language then shows as the key itself. Never fails the gate',\n ),\n collisions: z\n .array(z.object({ key: z.string(), sites: z.array(z.object({ file: z.string(), line: z.number().optional(), message: z.string() })) }))\n .describe('One key, several texts: every place shows the first site. Never fails the gate'),\n divergent: z\n .array(z.object({ key: z.string(), catalog: z.string(), code: z.object({ file: z.string(), line: z.number().optional(), message: z.string() }) }))\n .describe(\n \"The source catalog says one text and the code another: the code's text ships. Never fails the gate\",\n ),\n outdated: perLocaleEntries.describe(\n 'Translations written for an older source text: rewrite them, or a human keeps them with verbaly review --approve. Never fails the gate',\n ),\n unreviewed: perLocale,\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root, drafts }) => {\n const cfg = await config(root);\n const registry = await extractProject(cfg);\n const catalogs = loadCatalogs(cfg);\n const state = loadState(cfg);\n const result = check(cfg, catalogs, registry, state.fingerprints);\n const unreviewed = drafts ? byLocale(effectiveDrafts(state.drafts, catalogs)) : [];\n\n const lines: string[] = [];\n if (!result.ok) lines.push(formatCheckResult(result, cfg.root));\n const warnings = formatCheckWarnings(result, cfg.root);\n if (warnings) lines.push(`warnings (the gate still passes):\\n${warnings}`);\n for (const { locale, keys } of unreviewed) {\n if (keys.length) lines.push(`[${locale}] ${keys.length} unreviewed: ${keys.join(', ')}`);\n }\n return reply(lines.length === 0 ? 'all translations complete' : lines.join('\\n'), {\n ...result,\n unreviewed,\n });\n }),\n );\n\n server.registerTool(\n 'verbaly_translate',\n {\n title: 'Machine-translate missing entries',\n description:\n 'Fill missing translations with the configured provider (default: Claude, needs @anthropic-ai/sdk and ANTHROPIC_API_KEY). New translations are saved as drafts awaiting human review (`verbaly review`), which no tool here can approve. A batch the provider never answers is reported in failed and leaves everything else written, so a retry only asks for what is left. dryRun lists what would be translated without calling the provider.',\n inputSchema: {\n root: rootInput,\n locales: z.array(z.string()).optional().describe('Target locales (default: all)'),\n dryRun: z\n .boolean()\n .optional()\n .describe('List missing entries per locale, call no provider'),\n },\n outputSchema: {\n dryRun: z.boolean(),\n translated: perLocale.describe('Saved as drafts, a human still has to approve them'),\n kept: perLocale.describe(\n 'Written on disk by someone else while the provider worked, so left as they were',\n ),\n invalid: perLocale.describe('Rejected: params or tags were not preserved'),\n failed: z\n .array(z.object({ locale: z.string(), keys: z.array(z.string()), error: z.string() }))\n .describe('Batches the provider never answered, safe to retry'),\n pending: perLocale.describe('dryRun only: what would be translated'),\n },\n },\n guarded(async ({ root, locales, dryRun }) => {\n const cfg = await config(root);\n const catalogs = loadCatalogs(cfg);\n const provider = await resolveProvider(cfg);\n const result = await translateCatalogs(cfg, catalogs, provider, {\n locales,\n batchSize: cfg.translate.batchSize,\n concurrency: cfg.translate.concurrency,\n retries: cfg.translate.retries,\n dryRun,\n origins: dryRun ? undefined : await collectOrigins(cfg),\n });\n\n if (dryRun) {\n const pending = byLocale(result.pending);\n const lines = pending.map(\n ({ locale, keys }) => `${locale}: ${keys.length} missing: ${keys.join(', ')}`,\n );\n const data = { dryRun: true, translated: [], kept: [], invalid: [], failed: [], pending };\n return reply(lines.length === 0 ? 'nothing to translate' : lines.join('\\n'), data);\n }\n\n // the file as it is now: what someone wrote while the provider worked is not overwritten\n const drafts = loadDrafts(cfg);\n const written: Record<string, string[]> = {};\n const kept: Record<string, string[]> = {};\n for (const [locale, keys] of Object.entries(result.translated)) {\n const landed = mergeTranslations(cfg, locale, catalogs[locale] ?? {}, keys);\n markDrafts(drafts, locale, landed);\n if (landed.length > 0) written[locale] = landed;\n const left = keys.filter((key) => !landed.includes(key));\n if (left.length > 0) kept[locale] = left;\n }\n if (Object.keys(written).length > 0) saveDrafts(cfg, drafts);\n\n const data = {\n dryRun: false,\n translated: byLocale(written),\n kept: byLocale(kept),\n invalid: byLocale(result.invalid),\n failed: result.failed,\n pending: [],\n };\n const lines: string[] = [];\n for (const { locale, keys } of data.translated) {\n lines.push(`${locale}: +${keys.length} translated (draft)`);\n }\n for (const { locale, keys } of data.kept) {\n lines.push(`${locale}: ${keys.length} kept as written while this ran: ${keys.join(', ')}`);\n }\n for (const { locale, keys } of data.invalid) {\n lines.push(\n `${locale}: ${keys.length} rejected (params/tags not preserved): ${keys.join(', ')}`,\n );\n }\n lines.push(...formatTranslateFailures(result.failed));\n if (lines.length === 0) return reply('nothing to translate', data);\n if (data.translated.length > 0) {\n lines.push('drafts await human review: verbaly review (--approve accepts them)');\n }\n return reply(lines.join('\\n'), data);\n }),\n );\n server.registerTool(\n 'verbaly_write_drafts',\n {\n title: 'Save translations an agent wrote',\n description:\n \"Save translations you wrote yourself, so neither a catalog nor the state file is ever edited by hand. Each one is checked the way `verbaly translate` checks a provider (params, rich tags and plural cases must survive), written only for keys the source catalog has, and marked as a draft awaiting human review. Existing translations are kept unless overwrite is set, which is how an outdated one gets rewritten. Approving is not a tool here: a human runs `verbaly review --approve`.\",\n inputSchema: {\n root: rootInput,\n locale: z.string().describe(\"Target locale, one of the project's non-source locales\"),\n entries: z\n .array(z.object({ key: z.string(), text: z.string() }))\n .describe('The translations, by catalog key'),\n overwrite: z\n .boolean()\n .optional()\n .describe('Replace translations that already exist, for example outdated ones'),\n },\n outputSchema: {\n written: z.array(z.string()).describe('Saved as drafts, a human still has to approve them'),\n kept: z\n .array(z.string())\n .describe('Already translated, left as they were (overwrite replaces them)'),\n invalid: z\n .array(z.string())\n .describe('Rejected: empty, or the params, tags or plural cases were not preserved'),\n unknown: z.array(z.string()).describe('Not in the source catalog, so nothing was written'),\n },\n },\n guarded(async ({ root, locale, entries, overwrite }) => {\n const cfg = await config(root);\n const result = writeDrafts(cfg, locale, entries, { overwrite });\n const lines: string[] = [];\n if (result.written.length > 0) {\n lines.push(`${locale}: +${result.written.length} saved as drafts, awaiting human review`);\n }\n if (result.kept.length > 0) {\n lines.push(`${locale}: ${result.kept.length} already translated, kept: ${result.kept.join(', ')}`);\n }\n if (result.invalid.length > 0) {\n lines.push(\n `${locale}: ${result.invalid.length} rejected (params/tags not preserved): ${result.invalid.join(', ')}`,\n );\n }\n if (result.unknown.length > 0) {\n lines.push(\n `${locale}: ${counted(result.unknown.length, 'unknown key')} not in the source catalog: ${result.unknown.join(', ')}`,\n );\n }\n return reply(lines.length > 0 ? lines.join('\\n') : 'nothing to save', { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_drafts',\n {\n title: 'Machine translations awaiting review',\n description:\n 'Every machine translation still waiting for a human, each with the source text and what the provider wrote, so a person can read both and decide. Read-only. Approving is deliberately not a tool here and never will be: a machine translation is unreviewed by definition, so accepting one is `verbaly review --approve`, run by a human.',\n inputSchema: {\n root: rootInput,\n locales: z.array(z.string()).optional().describe('Target locales (default: all)'),\n },\n outputSchema: {\n total: z.number(),\n entries: z.array(\n z.object({\n locale: z.string(),\n key: z.string(),\n source: z.string().describe('What the message says in the source locale'),\n translated: z.string().describe('What the provider wrote, still unreviewed'),\n }),\n ),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root, locales }) => {\n const cfg = await config(root);\n const catalogs = loadCatalogs(cfg);\n const source = catalogs[cfg.sourceLocale] ?? {};\n const pending = effectiveDrafts(loadDrafts(cfg), catalogs);\n const wanted = locales ?? cfg.locales;\n const entries = Object.entries(pending)\n .filter(([locale]) => wanted.includes(locale))\n .flatMap(([locale, keys]) =>\n keys.map((key) => ({\n locale,\n key,\n source: source[key] ?? '',\n translated: catalogs[locale]?.[key] ?? '',\n })),\n );\n const body = entries.length\n ? entries\n .map((e) => `[${e.locale}] ${e.key}\n source: ${e.source}\n draft: ${e.translated}`)\n .join('\\n')\n : 'nothing awaiting review';\n return reply(body, { total: entries.length, entries });\n }),\n );\n\n\n return server;\n}\n","#!/usr/bin/env node\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { parseArgs } from 'node:util';\nimport { createVerbalyMcp } from './server';\n\nconst { values } = parseArgs({ options: { root: { type: 'string' } } });\n\ntry {\n await createVerbalyMcp({ root: values.root }).connect(new StdioServerTransport());\n // stdout carries the protocol: any human-facing note goes to stderr\n console.error('[verbaly-mcp] ready (stdio)');\n} catch (error) {\n console.error('[verbaly-mcp]', error instanceof Error ? error.message : error);\n process.exitCode = 1;\n}\n"],"mappings":";;;;;;;;;;AAwCA,MAAM,EAAE,YAAY,cAAc,YAAY,GAAG,CAAC,CAAC,iBAAiB;AAOpE,MAAM,SAAS,MAAc,UAAmD;CAC9E,SAAS,CAAC;EAAE,MAAM;EAAQ,MAAM;CAAK,CAAC;CACtC,mBAAmB;AACrB;AAEA,MAAM,YAAY,EACf,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,gFAAgF;AAE5F,MAAM,YAAY,EAAE,MAAM,EAAE,OAAO;CAAE,QAAQ,EAAE,OAAO;CAAG,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;AAAE,CAAC,CAAC;AAErF,MAAM,mBAAmB,EAAE,MAAM,EAAE,OAAO;CAAE,QAAQ,EAAE,OAAO;CAAG,KAAK,EAAE,OAAO;AAAE,CAAC,CAAC;AAGlF,MAAM,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;EACJ,OAAO,MAAM,MAAM;GAAE,OAAO,QAAQ;GAAQ;EAAQ,CAAC;CACvD,CAAC,CACH;CAGA,OAAO;AACT;;;AC5rBA,MAAM,EAAE,WAAW,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,EAAE,EAAE,CAAC;AAEtE,IAAI;CACF,MAAM,iBAAiB,EAAE,MAAM,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,IAAI,qBAAqB,CAAC;CAEhF,QAAQ,MAAM,6BAA6B;AAC7C,SAAS,OAAO;CACd,QAAQ,MAAM,iBAAiB,iBAAiB,QAAQ,MAAM,UAAU,KAAK;CAC7E,QAAQ,WAAW;AACrB"}
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/server.ts","../src/cli.ts"],"sourcesContent":["import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport {\n check,\n collectOrigins,\n counted,\n doctor,\n effectiveDrafts,\n extractProject,\n formatCheckResult,\n formatCheckWarnings,\n formatDoctorEntry,\n formatFinding,\n formatStatusResult,\n formatTranslateFailures,\n init,\n loadCatalogs,\n loadConfig,\n loadState,\n mergeTranslations,\n readState,\n recordTranslations,\n resolveProvider,\n shippedCatalogs,\n status,\n syncProject,\n translateCatalogs,\n wrapProject,\n writeDrafts,\n type CheckResult,\n type ResolvedConfig,\n type TranslationWrite,\n} from '@verbaly/compiler';\nimport { createRequire } from 'node:module';\nimport { relative } from 'node:path';\nimport { z } from 'zod';\n\nconst { version } = createRequire(import.meta.url)('../package.json') as { version: string };\n\nexport interface VerbalyMcpOptions {\n root?: string;\n}\n\n// text stays the fallback for a client that reads no schema, structuredContent is what agents parse\nconst reply = (body: string, data: Record<string, unknown>): CallToolResult => ({\n content: [{ type: 'text', text: body }],\n structuredContent: data,\n});\n\nconst rootInput = z\n .string()\n .optional()\n .describe('Project root holding verbaly.config (defaults to the server working directory)');\n\nconst perLocale = z.array(z.object({ locale: z.string(), keys: z.array(z.string()) }));\n\nconst perLocaleEntries = z.array(z.object({ locale: z.string(), key: z.string() }));\n\n// a locale-keyed record is a dynamic schema an agent cannot read ahead: lists enumerate\nconst byLocale = (record: Record<string, string[]>): Array<{ locale: string; keys: string[] }> =>\n Object.entries(record).map(([locale, keys]) => ({ locale, keys }));\n\nconst sourceSite = z.object({ file: z.string(), line: z.number().optional(), message: z.string() });\n\n// an agent reads paths against the project, the same way every tool here writes them\nfunction relativeTo(root: string): (file: string) => string {\n return (file) => relative(root, file).replaceAll('\\\\', '/');\n}\n\nfunction relativeCheck(root: string, result: CheckResult): CheckResult {\n const rel = relativeTo(root);\n return {\n ...result,\n unknown: result.unknown.map((entry) => ({ ...entry, files: entry.files.map(rel) })),\n extra: result.extra.map((entry) => ({ ...entry, files: entry.files.map(rel) })),\n collisions: result.collisions.map((entry) => ({\n ...entry,\n sites: entry.sites.map((at) => ({ ...at, file: rel(at.file) })),\n })),\n divergent: result.divergent.map((entry) => ({\n ...entry,\n code: { ...entry.code, file: rel(entry.code.file) },\n })),\n };\n}\n\nexport function createVerbalyMcp(options: VerbalyMcpOptions = {}): McpServer {\n const server = new McpServer({ name: 'verbaly', version });\n\n const config = (root?: string): Promise<ResolvedConfig> =>\n loadConfig(root ?? options.root ?? process.cwd());\n\n // agents act on messages, not stack traces: every failure comes back as actionable text\n const guarded =\n <A>(run: (args: A) => Promise<CallToolResult>) =>\n async (args: A): Promise<CallToolResult> => {\n try {\n return await run(args);\n } catch (error) {\n return {\n content: [{ type: 'text', text: error instanceof Error ? error.message : String(error) }],\n isError: true,\n };\n }\n };\n\n // resources, not tools: reading the project is an address, and it must not spend a tool call\n server.registerResource(\n 'verbaly-config',\n 'verbaly://config',\n {\n title: 'Project shape',\n description:\n 'The resolved Verbaly config: source locale, every locale, the catalog directory and where the language lives in the url. Read this before reasoning about anything else in the project.',\n mimeType: 'application/json',\n },\n async (uri) => {\n const cfg = await config();\n const shape = {\n root: cfg.root,\n sourceLocale: cfg.sourceLocale,\n locales: cfg.locales,\n localesDeclared: cfg.localesDeclared,\n dir: cfg.dir,\n routing: cfg.routing,\n include: cfg.include,\n };\n return {\n contents: [\n { uri: uri.href, mimeType: 'application/json', text: JSON.stringify(shape, null, 2) },\n ],\n };\n },\n );\n\n server.registerResource(\n 'verbaly-catalog',\n new ResourceTemplate('verbaly://catalog/{locale}', {\n list: async () => {\n const cfg = await config();\n return {\n resources: cfg.locales.map((locale) => ({\n name: `${locale} catalog`,\n uri: `verbaly://catalog/${locale}`,\n mimeType: 'application/json',\n })),\n };\n },\n }),\n {\n title: 'Locale catalog',\n description:\n 'Every message of one locale, keyed the way the runtime sees them: a nested catalog arrives flattened, a text the code owns reads as the code has it, and an empty value means untranslated. This is the only way to read what a message actually says.',\n mimeType: 'application/json',\n },\n async (uri, { locale }) => {\n const cfg = await config();\n const name = String(locale);\n if (!cfg.locales.includes(name)) {\n const have = cfg.locales.join(', ');\n throw new Error(`[verbaly] unknown locale \"${name}\": the project has ${have}`);\n }\n // the text that ships: a catalog the code has moved past would hand an agent the old words\n const registry = await extractProject(cfg);\n const shipped = shippedCatalogs(cfg, loadCatalogs(cfg), registry, { newKeys: false });\n const catalog = shipped[name] ?? {};\n return {\n contents: [\n { uri: uri.href, mimeType: 'application/json', text: JSON.stringify(catalog, null, 2) },\n ],\n };\n },\n );\n\n server.registerTool(\n 'verbaly_init',\n {\n title: 'Set up Verbaly in a project',\n description:\n 'Create the config file and the locale catalogs, and detect the bundler or meta-framework so the answer names the package to add and the line to wire (what `verbaly init` does). Writes files, and a file already there is kept rather than overwritten. Run this when doctor says there is no config.',\n inputSchema: {\n root: rootInput,\n dir: z.string().optional().describe('Directory for the catalogs (default: locales)'),\n sourceLocale: z.string().optional().describe('The language you write in (default: en)'),\n locales: z.array(z.string()).optional().describe('Every locale, source included'),\n },\n outputSchema: {\n created: z.array(z.string()).describe('Files written, relative to the project root'),\n skipped: z.array(z.string()).describe('Files already there, left untouched'),\n host: z\n .string()\n .optional()\n .describe('Bundler or meta-framework detected from the dependencies'),\n configFile: z.string(),\n next: z.array(z.string()).describe('What a human still has to do, in order'),\n renamed: z\n .array(z.object({ from: z.string(), to: z.string() }))\n .describe('Locales written with the hyphen a locale tag takes (pt_BR became pt-BR)'),\n refused: z\n .array(z.string())\n .describe('Locales left out: not a locale tag, and no sure way to fix one'),\n },\n },\n guarded(async ({ root, dir, sourceLocale, locales }) => {\n const result = await init({ root: root ?? options.root, dir, sourceLocale, locales });\n const lines: string[] = [];\n if (result.created.length) lines.push(`created: ${result.created.join(', ')}`);\n if (result.skipped.length) lines.push(`kept (already there): ${result.skipped.join(', ')}`);\n for (const { from, to } of result.renamed) lines.push(`wrote ${to} for ${from}`);\n for (const locale of result.refused) {\n lines.push(`left out \"${locale}\": it is not a locale tag, use one like es or pt-BR`);\n }\n if (result.host) lines.push(`detected: ${result.host}`);\n lines.push(...result.next.map((step, i) => `${i + 1}. ${step}`));\n return reply(lines.join('\\n'), { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_doctor',\n {\n title: 'Diagnose the setup',\n description:\n 'Diagnose a Verbaly project end to end (what `verbaly doctor` does): the config file, the catalog files and their JSON, the bundler plugin for the detected framework, the generated types, files the parser could not read, t imported from a package that never exports it, orphan keys, and every failure `verbaly check` would report. Run this first when something does not work. Read-only.',\n inputSchema: { root: rootInput },\n outputSchema: {\n ok: z.boolean().describe('False when an entry is an error, which is when the CLI exits 1'),\n entries: z.array(\n z.object({\n level: z.enum(['ok', 'warn', 'error']),\n check: z.string(),\n message: z.string(),\n fix: z.string().optional().describe('What to run or change, when there is one'),\n }),\n ),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root }) => {\n const cfg = await config(root);\n const result = await doctor(cfg);\n const health = result.ok ? 'setup looks healthy' : 'problems found';\n const head = `${counted(result.entries.length, 'check')}, ${health}`;\n return reply([head, ...result.entries.map(formatDoctorEntry)].join('\\n'), { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_wrap',\n {\n title: 'Wrap hardcoded JSX text',\n description:\n 'Find hardcoded user-visible text in JSX/TSX files and wrap it in a t tagged template so the compiler can extract it (what `verbaly wrap` does). This is how an existing codebase is onboarded. Reports only unless write is set. Text it cannot wrap safely (a sentence split across markup, an expression rendering JSX) is listed as needing a human and never rewritten. A file that does not bind t is never written either, because the rewrite would not compile: those come back in blocked, with whether the file is a client component, so you can add the binding and run again.',\n inputSchema: {\n root: rootInput,\n write: z.boolean().optional().describe('Apply the rewrites instead of only reporting'),\n },\n outputSchema: {\n files: z.number().describe('JSX/TSX files scanned'),\n write: z.boolean(),\n changed: z.array(z.string()).describe('Files the rewrite touched, or would touch'),\n wrapped: z.array(\n z.object({\n file: z.string(),\n line: z.number(),\n text: z.string(),\n kind: z.enum(['text', 'attribute']),\n attribute: z.string().optional(),\n }),\n ),\n skipped: z.array(\n z.object({ file: z.string(), line: z.number(), text: z.string(), reason: z.string() }),\n ),\n blocked: z.array(\n z.object({ file: z.string(), texts: z.number(), client: z.boolean() }),\n ),\n },\n },\n guarded(async ({ root, write }) => {\n const cfg = await config(root);\n const result = await wrapProject(cfg, { write });\n const blocked = new Set(result.blocked.map((entry) => entry.file));\n const done = result.changed.filter((file) => !blocked.has(file));\n const texts = result.wrapped.filter((entry) => !blocked.has(entry.file));\n const verb = write ? 'wrapped' : 'would wrap';\n const counts = write\n ? `${counted(texts.length, 'text')} in ${counted(done.length, 'file')}`\n : `${counted(result.wrapped.length, 'text')} in ${counted(result.changed.length, 'file')}`;\n const lines = [`${verb} ${counts} of ${counted(result.files, 'file')} scanned`];\n for (const entry of write ? texts : result.wrapped) {\n const attr = entry.kind === 'attribute' ? `${entry.attribute} -> ` : '';\n lines.push(` ${entry.file}:${entry.line} ${attr}\"${entry.text}\"`);\n }\n if (result.skipped.length > 0) {\n lines.push(' needs a human:');\n for (const entry of result.skipped) {\n lines.push(` ${entry.file}:${entry.line} \"${entry.text}\" (${entry.reason})`);\n }\n }\n if (result.blocked.length > 0) {\n lines.push(` nothing written in ${counted(result.blocked.length, 'file')} with no t in scope:`);\n for (const entry of result.blocked) {\n const how = entry.client ? '\"use client\", so const t = useT()' : 'no \"use client\"';\n lines.push(` ${entry.file} ${counted(entry.texts, 'text')}, ${how}`);\n }\n lines.push(' next: bind t there, run verbaly_wrap with write again, then verbaly_extract');\n } else if (write && done.length > 0) {\n lines.push(' next: run verbaly_extract');\n }\n return reply(lines.join('\\n'), { ...result, write: write === true });\n }),\n );\n\n server.registerTool(\n 'verbaly_extract',\n {\n title: 'Extract messages',\n description:\n 'Scan the source files, add new messages to the locale catalogs and refresh the generated types (what `verbaly extract` does). Writes catalog files unless dryRun is set. prune drops keys no longer referenced in the code, translations included.',\n inputSchema: {\n root: rootInput,\n prune: z\n .boolean()\n .optional()\n .describe('Drop keys no longer referenced (deletes their translations)'),\n dryRun: z.boolean().optional().describe('Report what would change, write nothing'),\n },\n outputSchema: {\n messages: z.number(),\n locales: z.array(z.string()),\n dryRun: z.boolean(),\n added: perLocale,\n pruned: perLocale,\n unparsed: z\n .array(z.object({ file: z.string(), message: z.string() }))\n .describe(\n 'Source files the parser could not read: their messages are not extracted, and prune drops nothing until they parse',\n ),\n collisions: z\n .array(z.object({ key: z.string(), sites: z.array(sourceSite) }))\n .describe(\n 'Keys written with more than one text: every place shows the text of the first site, so give each text its own key',\n ),\n renamed: z\n .array(z.object({ file: z.string(), line: z.number().optional(), name: z.string() }))\n .describe(\n 'Tagged templates on t under another name (const tr = useT()): never extracted, so they stay in the source language until the binding is named t',\n ),\n replaced: z\n .array(z.object({ key: z.string(), before: z.string(), code: sourceSite }))\n .describe(\n 'Source texts the code wrote over: before is what the catalog said, code is the text that ships. An edit made in the code reads like this too',\n ),\n positional: z\n .array(z.object({ params: z.array(z.string()), code: sourceSite }))\n .describe(\n 'Messages that hand a translator a nameless value like {_0}: put the value in a named variable first',\n ),\n escaped: z\n .array(z.object({ slice: z.string(), code: sourceSite }))\n .describe(\n 'Plural or format blocks inside a tagged template, which render as literal text',\n ),\n stateProblem: z\n .string()\n .optional()\n .describe(\n 'The state file could not be read or written: the catalogs were written, drafts and outdated tracking were not',\n ),\n },\n },\n guarded(async ({ root, prune, dryRun }) => {\n const cfg = await config(root);\n const result = await syncProject(cfg, { prune, dryRun });\n const rel = relativeTo(cfg.root);\n const at = (code: { file: string; line?: number; message: string }) => ({\n ...code,\n file: rel(code.file),\n });\n // an agent sees no terminal, so what the CLI prints about these has to be in the answer\n const data = {\n messages: result.registry.messages().size,\n locales: cfg.locales,\n dryRun: dryRun === true,\n added: byLocale(result.added),\n pruned: byLocale(result.pruned),\n unparsed: [] as { file: string; message: string }[],\n collisions: [] as { key: string; sites: ReturnType<typeof at>[] }[],\n renamed: [] as { file: string; line?: number; name: string }[],\n replaced: [] as { key: string; before: string; code: ReturnType<typeof at> }[],\n positional: [] as { params: string[]; code: ReturnType<typeof at> }[],\n escaped: [] as { slice: string; code: ReturnType<typeof at> }[],\n ...(result.stateProblem && { stateProblem: result.stateProblem }),\n };\n for (const finding of result.findings) {\n if (finding.kind === 'unparsed')\n data.unparsed.push({ file: rel(finding.file), message: finding.message });\n else if (finding.kind === 'collision')\n data.collisions.push({ key: finding.key, sites: finding.sites.map(at) });\n else if (finding.kind === 'renamed')\n data.renamed.push({ ...finding, file: rel(finding.file) });\n else if (finding.kind === 'replaced')\n data.replaced.push({ key: finding.key, before: finding.before, code: at(finding.site) });\n else if (finding.kind === 'positional')\n data.positional.push({ params: finding.params, code: at(finding.site) });\n else if (finding.kind === 'escaped')\n data.escaped.push({ slice: finding.slice, code: at(finding.site) });\n }\n\n const lines = [\n `${counted(data.messages, 'message')} · locales: ${cfg.locales.join(', ')}${dryRun ? ' (dry run, nothing written)' : ''}`,\n ];\n if (result.pruneBlocked) {\n lines.push(\n 'prune skipped: an unparsed file may read any key, so it waits until every file parses',\n );\n }\n for (const { locale, keys } of data.pruned) {\n lines.push(\n dryRun\n ? `${locale}: would prune ${keys.length}: ${keys.join(', ')}`\n : `${locale}: ${keys.length} pruned`,\n );\n }\n for (const { locale, keys } of data.added) {\n lines.push(`${locale}: ${dryRun ? `would add ${keys.length}` : `+${keys.length} added`}`);\n }\n for (const finding of result.findings) lines.push(formatFinding(finding, cfg.root));\n if (result.stateProblem) {\n lines.push(`${result.stateProblem}, so drafts and outdated translations were not updated`);\n }\n return reply(lines.join('\\n'), data);\n }),\n );\n\n server.registerTool(\n 'verbaly_status',\n {\n title: 'Translation coverage',\n description:\n 'Translation coverage of the Verbaly project: total messages, translated count per locale, machine translations awaiting review (drafts) and translations written for an older source text (outdated). Read-only.',\n inputSchema: { root: rootInput },\n outputSchema: {\n messages: z.number().describe('Messages the project has, source catalog plus code'),\n source: z.string().describe('Source locale'),\n locales: z.array(\n z.object({\n locale: z.string(),\n translated: z.number(),\n total: z.number(),\n drafts: z.number().describe('Machine translations awaiting human review'),\n broken: z.number().describe('Present but not rendering what the source renders'),\n outdated: z\n .number()\n .describe('Translated from an older source text: update them, or a human keeps them'),\n }),\n ),\n stateProblem: z\n .string()\n .optional()\n .describe('The state file could not be read, so drafts and outdated are counted as zero'),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root }) => {\n const cfg = await config(root);\n const registry = await extractProject(cfg);\n // the state only feeds two counts: a broken one is said, never a failed call\n const { state, problem } = readState(cfg);\n const result = status(cfg, loadCatalogs(cfg), registry, state.drafts, state.fingerprints);\n const body = formatStatusResult(result);\n return reply(problem ? `${body}\\n${problem}, so drafts and outdated are not counted` : body, {\n ...result,\n ...(problem && { stateProblem: problem }),\n });\n }),\n );\n\n server.registerTool(\n 'verbaly_missing',\n {\n title: 'Missing and broken translations',\n description:\n 'List missing translations, unknown keys and translations that exist but cannot render what the source renders (a dropped {param}, a lost rich tag, a flattened plural block), the same gate `verbaly check` runs in CI. Warnings never fail the gate and are listed too: an incomplete plural set for the locale, keys a translation carries that the source catalog does not (extra), keys written with two texts (collisions), texts the code and the source catalog disagree on (divergent, the text in the code ships) and translations written for an older source text (outdated). Optionally also lists machine translations awaiting review. Read-only.',\n inputSchema: {\n root: rootInput,\n drafts: z\n .boolean()\n .optional()\n .describe('Also list machine translations awaiting human review'),\n },\n outputSchema: {\n ok: z.boolean().describe('Whether `verbaly check` would pass (warnings never fail it)'),\n missing: z.array(\n z.object({ locale: z.string(), key: z.string(), source: z.string().optional() }),\n ),\n unknown: z.array(z.object({ key: z.string(), files: z.array(z.string()) })),\n broken: z.array(\n z.object({\n locale: z.string(),\n key: z.string(),\n severity: z.enum(['error', 'warning']),\n issue: z.string(),\n }),\n ),\n extra: z\n .array(z.object({ locale: z.string(), key: z.string(), files: z.array(z.string()) }))\n .describe(\n 'Keys only a translation has; files are where the code reads one, which the source language then shows as the key itself. Never fails the gate',\n ),\n collisions: z\n .array(z.object({ key: z.string(), sites: z.array(sourceSite) }))\n .describe('One key, several texts: every place shows the first site. Never fails the gate'),\n divergent: z\n .array(z.object({ key: z.string(), catalog: z.string(), code: sourceSite }))\n .describe(\n \"The source catalog says one text and the code another: the code's text ships. Never fails the gate\",\n ),\n outdated: perLocaleEntries.describe(\n 'Translations written for an older source text: rewrite them, or a human keeps them with verbaly review --approve. Never fails the gate',\n ),\n unreviewed: perLocale,\n stateProblem: z\n .string()\n .optional()\n .describe('The state file could not be read, so outdated translations are not listed'),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root, drafts }) => {\n const cfg = await config(root);\n const registry = await extractProject(cfg);\n const catalogs = loadCatalogs(cfg);\n // asked for drafts, the state has to be readable; otherwise it only feeds a warning\n const { state, problem } = drafts\n ? { state: loadState(cfg), problem: undefined }\n : readState(cfg);\n const result = check(cfg, catalogs, registry, state.fingerprints);\n const unreviewed = drafts ? byLocale(effectiveDrafts(state.drafts, catalogs)) : [];\n\n const lines: string[] = [];\n if (!result.ok) lines.push(formatCheckResult(result, cfg.root));\n const warnings = formatCheckWarnings(result, cfg.root);\n if (warnings) lines.push(`warnings (the gate still passes):\\n${warnings}`);\n for (const { locale, keys } of unreviewed) {\n if (keys.length) lines.push(`[${locale}] ${keys.length} unreviewed: ${keys.join(', ')}`);\n }\n if (problem) lines.push(`${problem}, so outdated translations are not listed`);\n return reply(lines.length === 0 ? 'all translations complete' : lines.join('\\n'), {\n ...relativeCheck(cfg.root, result),\n unreviewed,\n ...(problem && { stateProblem: problem }),\n });\n }),\n );\n\n server.registerTool(\n 'verbaly_translate',\n {\n title: 'Machine-translate missing entries',\n description:\n 'Fill missing translations with the configured provider (default: Claude, needs @anthropic-ai/sdk and ANTHROPIC_API_KEY). New translations are saved as drafts awaiting human review (`verbaly review`), which no tool here can approve. A batch the provider never answers is reported in failed and leaves everything else written, so a retry only asks for what is left. dryRun lists what would be translated without calling the provider.',\n inputSchema: {\n root: rootInput,\n locales: z.array(z.string()).optional().describe('Target locales (default: all)'),\n dryRun: z\n .boolean()\n .optional()\n .describe('List missing entries per locale, call no provider'),\n },\n outputSchema: {\n dryRun: z.boolean(),\n translated: perLocale.describe('Saved as drafts, a human still has to approve them'),\n kept: perLocale.describe(\n 'Written on disk by someone else while the provider worked, so left as they were',\n ),\n invalid: perLocale.describe('Rejected: params or tags were not preserved'),\n failed: z\n .array(z.object({ locale: z.string(), keys: z.array(z.string()), error: z.string() }))\n .describe('Batches the provider never answered, safe to retry'),\n pending: perLocale.describe('dryRun only: what would be translated'),\n },\n },\n guarded(async ({ root, locales, dryRun }) => {\n const cfg = await config(root);\n // a machine translation that lost its draft flag passes as reviewed: read the state first\n if (!dryRun) loadState(cfg);\n const registry = await extractProject(cfg);\n // the provider reads the text that ships, which is the text its answer has to match\n const catalogs = shippedCatalogs(cfg, loadCatalogs(cfg), registry, { newKeys: false });\n const provider = await resolveProvider(cfg);\n const result = await translateCatalogs(cfg, catalogs, provider, {\n locales,\n batchSize: cfg.translate.batchSize,\n concurrency: cfg.translate.concurrency,\n retries: cfg.translate.retries,\n dryRun,\n origins: dryRun ? undefined : await collectOrigins(cfg, registry),\n });\n\n if (dryRun) {\n const pending = byLocale(result.pending);\n const lines = pending.map(\n ({ locale, keys }) => `${locale}: ${keys.length} missing: ${keys.join(', ')}`,\n );\n const data = { dryRun: true, translated: [], kept: [], invalid: [], failed: [], pending };\n return reply(lines.length === 0 ? 'nothing to translate' : lines.join('\\n'), data);\n }\n\n // the file as it is now: what someone wrote while the provider worked is not overwritten\n const written: Record<string, string[]> = {};\n const kept: Record<string, string[]> = {};\n const writes: TranslationWrite[] = [];\n for (const [locale, keys] of Object.entries(result.translated)) {\n const catalog = catalogs[locale] ?? {};\n const landed = mergeTranslations(cfg, locale, catalog, keys);\n writes.push({\n locale,\n draft: true,\n entries: landed.map((key) => ({ key, text: catalog[key]! })),\n });\n if (landed.length > 0) written[locale] = landed;\n const left = keys.filter((key) => !landed.includes(key));\n if (left.length > 0) kept[locale] = left;\n }\n if (writes.length > 0) recordTranslations(cfg, catalogs[cfg.sourceLocale] ?? {}, writes);\n\n const data = {\n dryRun: false,\n translated: byLocale(written),\n kept: byLocale(kept),\n invalid: byLocale(result.invalid),\n failed: result.failed,\n pending: [],\n };\n const lines: string[] = [];\n for (const { locale, keys } of data.translated) {\n lines.push(`${locale}: +${keys.length} translated (draft)`);\n }\n for (const { locale, keys } of data.kept) {\n lines.push(`${locale}: ${keys.length} kept as written while this ran: ${keys.join(', ')}`);\n }\n for (const { locale, keys } of data.invalid) {\n lines.push(\n `${locale}: ${keys.length} rejected (params/tags not preserved): ${keys.join(', ')}`,\n );\n }\n lines.push(...formatTranslateFailures(result.failed));\n if (lines.length === 0) return reply('nothing to translate', data);\n if (data.translated.length > 0) {\n lines.push('drafts await human review: verbaly review (--approve accepts them)');\n }\n return reply(lines.join('\\n'), data);\n }),\n );\n server.registerTool(\n 'verbaly_write_drafts',\n {\n title: 'Save translations an agent wrote',\n description:\n \"Save translations you wrote yourself, so neither a catalog nor the state file is ever edited by hand. Each one is checked the way `verbaly translate` checks a provider (params, rich tags and plural cases must survive), written only for keys the source catalog has, and marked as a draft awaiting human review. Existing translations are kept unless overwrite is set, which is how an outdated one gets rewritten. Approving is not a tool here: a human runs `verbaly review --approve`.\",\n inputSchema: {\n root: rootInput,\n locale: z.string().describe(\"Target locale, one of the project's non-source locales\"),\n entries: z\n .array(z.object({ key: z.string(), text: z.string() }))\n .describe('The translations, by catalog key'),\n overwrite: z\n .boolean()\n .optional()\n .describe('Replace translations that already exist, for example outdated ones'),\n },\n outputSchema: {\n written: z.array(z.string()).describe('Saved as drafts, a human still has to approve them'),\n kept: z\n .array(z.string())\n .describe('Already translated, left as they were (overwrite replaces them)'),\n invalid: z\n .array(z.string())\n .describe('Rejected: empty, or the params, tags or plural cases were not preserved'),\n unknown: z.array(z.string()).describe('Not in the source catalog, so nothing was written'),\n },\n },\n guarded(async ({ root, locale, entries, overwrite }) => {\n const cfg = await config(root);\n // checked against the text that ships, the one verbaly_missing reads it against\n const registry = await extractProject(cfg);\n const result = writeDrafts(cfg, locale, entries, { overwrite, registry });\n const lines: string[] = [];\n if (result.written.length > 0) {\n lines.push(`${locale}: +${result.written.length} saved as drafts, awaiting human review`);\n }\n if (result.kept.length > 0) {\n lines.push(`${locale}: ${result.kept.length} already translated, kept: ${result.kept.join(', ')}`);\n }\n if (result.invalid.length > 0) {\n lines.push(\n `${locale}: ${result.invalid.length} rejected (params/tags not preserved): ${result.invalid.join(', ')}`,\n );\n }\n if (result.unknown.length > 0) {\n lines.push(\n `${locale}: ${counted(result.unknown.length, 'unknown key')} not in the source catalog: ${result.unknown.join(', ')}`,\n );\n }\n return reply(lines.length > 0 ? lines.join('\\n') : 'nothing to save', { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_drafts',\n {\n title: 'Machine translations awaiting review',\n description:\n 'Every machine translation still waiting for a human, each with the source text and what the provider wrote, so a person can read both and decide. Read-only. Approving is deliberately not a tool here and never will be: a machine translation is unreviewed by definition, so accepting one is `verbaly review --approve`, run by a human.',\n inputSchema: {\n root: rootInput,\n locales: z.array(z.string()).optional().describe('Target locales (default: all)'),\n },\n outputSchema: {\n total: z.number(),\n entries: z.array(\n z.object({\n locale: z.string(),\n key: z.string(),\n source: z.string().describe('What the message says in the source locale'),\n translated: z.string().describe('What the provider wrote, still unreviewed'),\n }),\n ),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root, locales }) => {\n const cfg = await config(root);\n const catalogs = loadCatalogs(cfg);\n // the text that ships is the one a draft has to say again\n const shipped = shippedCatalogs(cfg, catalogs, await extractProject(cfg));\n const source = shipped[cfg.sourceLocale] ?? {};\n const pending = effectiveDrafts(loadState(cfg).drafts, catalogs);\n const wanted = locales ?? cfg.locales;\n const entries = Object.entries(pending)\n .filter(([locale]) => wanted.includes(locale))\n .flatMap(([locale, keys]) =>\n keys.map((key) => ({\n locale,\n key,\n source: source[key] ?? '',\n translated: catalogs[locale]?.[key] ?? '',\n })),\n );\n const body = entries.length\n ? entries\n .map((e) => `[${e.locale}] ${e.key}\n source: ${e.source}\n draft: ${e.translated}`)\n .join('\\n')\n : 'nothing awaiting review';\n return reply(body, { total: entries.length, entries });\n }),\n );\n\n\n return server;\n}\n","#!/usr/bin/env node\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { parseArgs } from 'node:util';\nimport { createVerbalyMcp } from './server';\n\nconst { values } = parseArgs({ options: { root: { type: 'string' } } });\n\ntry {\n await createVerbalyMcp({ root: values.root }).connect(new StdioServerTransport());\n // stdout carries the protocol: any human-facing note goes to stderr\n console.error('[verbaly-mcp] ready (stdio)');\n} catch (error) {\n console.error('[verbaly-mcp]', error instanceof Error ? error.message : error);\n process.exitCode = 1;\n}\n"],"mappings":";;;;;;;;;AAqCA,MAAM,EAAE,YAAY,cAAc,YAAY,GAAG,CAAC,CAAC,iBAAiB;AAOpE,MAAM,SAAS,MAAc,UAAmD;CAC9E,SAAS,CAAC;EAAE,MAAM;EAAQ,MAAM;CAAK,CAAC;CACtC,mBAAmB;AACrB;AAEA,MAAM,YAAY,EACf,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,gFAAgF;AAE5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Q;EAC/D,MAAM,SAAS,WAAW,IAAI;EAC9B,MAAM,UAAU,OAAO,QAAQ,OAAO,CAAC,CACpC,QAAQ,CAAC,YAAY,OAAO,SAAS,MAAM,CAAC,CAAC,CAC7C,SAAS,CAAC,QAAQ,UACjB,KAAK,KAAK,SAAS;GACjB;GACA;GACA,QAAQ,OAAO,QAAQ;GACvB,YAAY,SAAS,OAAO,GAAG,QAAQ;EACzC,EAAE,CACJ;EACF,MAAM,OAAO,QAAQ,SACjB,QACG,KAAK,MAAM,IAAI,EAAE,OAAO,IAAI,EAAE,IAAI;YACnC,EAAE,OAAO;YACT,EAAE,YAAY,CAAC,CACd,KAAK,IAAI,IACZ;EACJ,OAAO,MAAM,MAAM;GAAE,OAAO,QAAQ;GAAQ;EAAQ,CAAC;CACvD,CAAC,CACH;CAGA,OAAO;AACT;;;ACtvBA,MAAM,EAAE,WAAW,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,EAAE,EAAE,CAAC;AAEtE,IAAI;CACF,MAAM,iBAAiB,EAAE,MAAM,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,IAAI,qBAAqB,CAAC;CAEhF,QAAQ,MAAM,6BAA6B;AAC7C,SAAS,OAAO;CACd,QAAQ,MAAM,iBAAiB,iBAAiB,QAAQ,MAAM,UAAU,KAAK;CAC7E,QAAQ,WAAW;AACrB"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
-
import { check, collectOrigins,
|
|
4
|
-
import { readFileSync } from "node:fs";
|
|
3
|
+
import { check, collectOrigins, counted, doctor, effectiveDrafts, extractProject, formatCheckResult, formatCheckWarnings, formatDoctorEntry, formatFinding, formatStatusResult, formatTranslateFailures, init, loadCatalogs, loadConfig, loadState, mergeTranslations, readState, recordTranslations, resolveProvider, shippedCatalogs, status, syncProject, translateCatalogs, wrapProject, writeDrafts } from "@verbaly/compiler";
|
|
5
4
|
import { relative } from "node:path";
|
|
6
5
|
import { z } from "zod";
|
|
7
6
|
//#region src/server.ts
|
|
@@ -26,12 +25,41 @@ const byLocale = (record) => Object.entries(record).map(([locale, keys]) => ({
|
|
|
26
25
|
locale,
|
|
27
26
|
keys
|
|
28
27
|
}));
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const sourceSite = z.object({
|
|
29
|
+
file: z.string(),
|
|
30
|
+
line: z.number().optional(),
|
|
31
|
+
message: z.string()
|
|
32
|
+
});
|
|
33
|
+
function relativeTo(root) {
|
|
34
|
+
return (file) => relative(root, file).replaceAll("\\", "/");
|
|
35
|
+
}
|
|
36
|
+
function relativeCheck(root, result) {
|
|
37
|
+
const rel = relativeTo(root);
|
|
38
|
+
return {
|
|
39
|
+
...result,
|
|
40
|
+
unknown: result.unknown.map((entry) => ({
|
|
41
|
+
...entry,
|
|
42
|
+
files: entry.files.map(rel)
|
|
43
|
+
})),
|
|
44
|
+
extra: result.extra.map((entry) => ({
|
|
45
|
+
...entry,
|
|
46
|
+
files: entry.files.map(rel)
|
|
47
|
+
})),
|
|
48
|
+
collisions: result.collisions.map((entry) => ({
|
|
49
|
+
...entry,
|
|
50
|
+
sites: entry.sites.map((at) => ({
|
|
51
|
+
...at,
|
|
52
|
+
file: rel(at.file)
|
|
53
|
+
}))
|
|
54
|
+
})),
|
|
55
|
+
divergent: result.divergent.map((entry) => ({
|
|
56
|
+
...entry,
|
|
57
|
+
code: {
|
|
58
|
+
...entry.code,
|
|
59
|
+
file: rel(entry.code.file)
|
|
60
|
+
}
|
|
61
|
+
}))
|
|
62
|
+
};
|
|
35
63
|
}
|
|
36
64
|
function createVerbalyMcp(options = {}) {
|
|
37
65
|
const server = new McpServer({
|
|
@@ -81,7 +109,7 @@ function createVerbalyMcp(options = {}) {
|
|
|
81
109
|
})) };
|
|
82
110
|
} }), {
|
|
83
111
|
title: "Locale catalog",
|
|
84
|
-
description: "Every message of one locale, keyed the way the runtime sees them: a nested catalog arrives flattened, and an empty value means untranslated. This is the only way to read what a message actually says.",
|
|
112
|
+
description: "Every message of one locale, keyed the way the runtime sees them: a nested catalog arrives flattened, a text the code owns reads as the code has it, and an empty value means untranslated. This is the only way to read what a message actually says.",
|
|
85
113
|
mimeType: "application/json"
|
|
86
114
|
}, async (uri, { locale }) => {
|
|
87
115
|
const cfg = await config();
|
|
@@ -90,7 +118,8 @@ function createVerbalyMcp(options = {}) {
|
|
|
90
118
|
const have = cfg.locales.join(", ");
|
|
91
119
|
throw new Error(`[verbaly] unknown locale "${name}": the project has ${have}`);
|
|
92
120
|
}
|
|
93
|
-
const
|
|
121
|
+
const registry = await extractProject(cfg);
|
|
122
|
+
const catalog = shippedCatalogs(cfg, loadCatalogs(cfg), registry, { newKeys: false })[name] ?? {};
|
|
94
123
|
return { contents: [{
|
|
95
124
|
uri: uri.href,
|
|
96
125
|
mimeType: "application/json",
|
|
@@ -237,68 +266,85 @@ function createVerbalyMcp(options = {}) {
|
|
|
237
266
|
})).describe("Source files the parser could not read: their messages are not extracted, and prune drops nothing until they parse"),
|
|
238
267
|
collisions: z.array(z.object({
|
|
239
268
|
key: z.string(),
|
|
240
|
-
sites: z.array(
|
|
241
|
-
file: z.string(),
|
|
242
|
-
line: z.number().optional(),
|
|
243
|
-
message: z.string()
|
|
244
|
-
}))
|
|
269
|
+
sites: z.array(sourceSite)
|
|
245
270
|
})).describe("Keys written with more than one text: every place shows the text of the first site, so give each text its own key"),
|
|
246
271
|
renamed: z.array(z.object({
|
|
247
272
|
file: z.string(),
|
|
248
273
|
line: z.number().optional(),
|
|
249
274
|
name: z.string()
|
|
250
|
-
})).describe("Tagged templates on t under another name (const tr = useT()): never extracted, so they stay in the source language until the binding is named t")
|
|
275
|
+
})).describe("Tagged templates on t under another name (const tr = useT()): never extracted, so they stay in the source language until the binding is named t"),
|
|
276
|
+
replaced: z.array(z.object({
|
|
277
|
+
key: z.string(),
|
|
278
|
+
before: z.string(),
|
|
279
|
+
code: sourceSite
|
|
280
|
+
})).describe("Source texts the code wrote over: before is what the catalog said, code is the text that ships. An edit made in the code reads like this too"),
|
|
281
|
+
positional: z.array(z.object({
|
|
282
|
+
params: z.array(z.string()),
|
|
283
|
+
code: sourceSite
|
|
284
|
+
})).describe("Messages that hand a translator a nameless value like {_0}: put the value in a named variable first"),
|
|
285
|
+
escaped: z.array(z.object({
|
|
286
|
+
slice: z.string(),
|
|
287
|
+
code: sourceSite
|
|
288
|
+
})).describe("Plural or format blocks inside a tagged template, which render as literal text"),
|
|
289
|
+
stateProblem: z.string().optional().describe("The state file could not be read or written: the catalogs were written, drafts and outdated tracking were not")
|
|
251
290
|
}
|
|
252
291
|
}, guarded(async ({ root, prune, dryRun }) => {
|
|
253
292
|
const cfg = await config(root);
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if (!dryRun) {
|
|
266
|
-
for (const locale of cfg.locales) writeCatalog(cfg, locale, catalogs[locale] ?? {});
|
|
267
|
-
writeDts(cfg, catalogs[cfg.sourceLocale] ?? {});
|
|
268
|
-
updateState(cfg, catalogs);
|
|
269
|
-
}
|
|
270
|
-
const rel = (file) => relative(cfg.root, file).replaceAll("\\", "/");
|
|
271
|
-
const collisions = collisionEntries(registry).map(({ key, sites }) => ({
|
|
272
|
-
key,
|
|
273
|
-
sites: sites.map((at) => ({
|
|
274
|
-
...at,
|
|
275
|
-
file: rel(at.file)
|
|
276
|
-
}))
|
|
277
|
-
}));
|
|
278
|
-
const renamed = registry.missed().map(({ name, file, start }) => ({
|
|
279
|
-
file: rel(file),
|
|
280
|
-
line: lineOf(file, start),
|
|
281
|
-
name
|
|
282
|
-
}));
|
|
283
|
-
const messages = registry.messages().size;
|
|
284
|
-
lines.unshift(`${counted(messages, "message")} · locales: ${cfg.locales.join(", ")}${dryRun ? " (dry run, nothing written)" : ""}`);
|
|
285
|
-
for (const { locale, keys } of added) lines.push(`${locale}: ${dryRun ? `would add ${keys.length}` : `+${keys.length} added`}`);
|
|
286
|
-
for (const { file, message } of unparsed) lines.push(`${file}: could not be parsed (${message}), its messages were not extracted`);
|
|
287
|
-
for (const { key, sites } of collisions) {
|
|
288
|
-
const where = sites.map((at) => at.line ? `${at.file}:${at.line}` : at.file).join(", ");
|
|
289
|
-
lines.push(`${key}: one key with ${counted(sites.length, "text")} (${where}), every place shows the first`);
|
|
290
|
-
}
|
|
291
|
-
for (const { file, line, name } of renamed) lines.push(`${file}${line ? `:${line}` : ""}: ${name}\`…\` is never extracted, name the binding t`);
|
|
292
|
-
return reply(lines.join("\n"), {
|
|
293
|
-
messages,
|
|
293
|
+
const result = await syncProject(cfg, {
|
|
294
|
+
prune,
|
|
295
|
+
dryRun
|
|
296
|
+
});
|
|
297
|
+
const rel = relativeTo(cfg.root);
|
|
298
|
+
const at = (code) => ({
|
|
299
|
+
...code,
|
|
300
|
+
file: rel(code.file)
|
|
301
|
+
});
|
|
302
|
+
const data = {
|
|
303
|
+
messages: result.registry.messages().size,
|
|
294
304
|
locales: cfg.locales,
|
|
295
305
|
dryRun: dryRun === true,
|
|
296
|
-
added,
|
|
297
|
-
pruned,
|
|
298
|
-
unparsed,
|
|
299
|
-
collisions,
|
|
300
|
-
renamed
|
|
306
|
+
added: byLocale(result.added),
|
|
307
|
+
pruned: byLocale(result.pruned),
|
|
308
|
+
unparsed: [],
|
|
309
|
+
collisions: [],
|
|
310
|
+
renamed: [],
|
|
311
|
+
replaced: [],
|
|
312
|
+
positional: [],
|
|
313
|
+
escaped: [],
|
|
314
|
+
...result.stateProblem && { stateProblem: result.stateProblem }
|
|
315
|
+
};
|
|
316
|
+
for (const finding of result.findings) if (finding.kind === "unparsed") data.unparsed.push({
|
|
317
|
+
file: rel(finding.file),
|
|
318
|
+
message: finding.message
|
|
319
|
+
});
|
|
320
|
+
else if (finding.kind === "collision") data.collisions.push({
|
|
321
|
+
key: finding.key,
|
|
322
|
+
sites: finding.sites.map(at)
|
|
323
|
+
});
|
|
324
|
+
else if (finding.kind === "renamed") data.renamed.push({
|
|
325
|
+
...finding,
|
|
326
|
+
file: rel(finding.file)
|
|
301
327
|
});
|
|
328
|
+
else if (finding.kind === "replaced") data.replaced.push({
|
|
329
|
+
key: finding.key,
|
|
330
|
+
before: finding.before,
|
|
331
|
+
code: at(finding.site)
|
|
332
|
+
});
|
|
333
|
+
else if (finding.kind === "positional") data.positional.push({
|
|
334
|
+
params: finding.params,
|
|
335
|
+
code: at(finding.site)
|
|
336
|
+
});
|
|
337
|
+
else if (finding.kind === "escaped") data.escaped.push({
|
|
338
|
+
slice: finding.slice,
|
|
339
|
+
code: at(finding.site)
|
|
340
|
+
});
|
|
341
|
+
const lines = [`${counted(data.messages, "message")} · locales: ${cfg.locales.join(", ")}${dryRun ? " (dry run, nothing written)" : ""}`];
|
|
342
|
+
if (result.pruneBlocked) lines.push("prune skipped: an unparsed file may read any key, so it waits until every file parses");
|
|
343
|
+
for (const { locale, keys } of data.pruned) lines.push(dryRun ? `${locale}: would prune ${keys.length}: ${keys.join(", ")}` : `${locale}: ${keys.length} pruned`);
|
|
344
|
+
for (const { locale, keys } of data.added) lines.push(`${locale}: ${dryRun ? `would add ${keys.length}` : `+${keys.length} added`}`);
|
|
345
|
+
for (const finding of result.findings) lines.push(formatFinding(finding, cfg.root));
|
|
346
|
+
if (result.stateProblem) lines.push(`${result.stateProblem}, so drafts and outdated translations were not updated`);
|
|
347
|
+
return reply(lines.join("\n"), data);
|
|
302
348
|
}));
|
|
303
349
|
server.registerTool("verbaly_status", {
|
|
304
350
|
title: "Translation coverage",
|
|
@@ -314,15 +360,20 @@ function createVerbalyMcp(options = {}) {
|
|
|
314
360
|
drafts: z.number().describe("Machine translations awaiting human review"),
|
|
315
361
|
broken: z.number().describe("Present but not rendering what the source renders"),
|
|
316
362
|
outdated: z.number().describe("Translated from an older source text: update them, or a human keeps them")
|
|
317
|
-
}))
|
|
363
|
+
})),
|
|
364
|
+
stateProblem: z.string().optional().describe("The state file could not be read, so drafts and outdated are counted as zero")
|
|
318
365
|
},
|
|
319
366
|
annotations: { readOnlyHint: true }
|
|
320
367
|
}, guarded(async ({ root }) => {
|
|
321
368
|
const cfg = await config(root);
|
|
322
369
|
const registry = await extractProject(cfg);
|
|
323
|
-
const state =
|
|
370
|
+
const { state, problem } = readState(cfg);
|
|
324
371
|
const result = status(cfg, loadCatalogs(cfg), registry, state.drafts, state.fingerprints);
|
|
325
|
-
|
|
372
|
+
const body = formatStatusResult(result);
|
|
373
|
+
return reply(problem ? `${body}\n${problem}, so drafts and outdated are not counted` : body, {
|
|
374
|
+
...result,
|
|
375
|
+
...problem && { stateProblem: problem }
|
|
376
|
+
});
|
|
326
377
|
}));
|
|
327
378
|
server.registerTool("verbaly_missing", {
|
|
328
379
|
title: "Missing and broken translations",
|
|
@@ -355,30 +406,26 @@ function createVerbalyMcp(options = {}) {
|
|
|
355
406
|
})).describe("Keys only a translation has; files are where the code reads one, which the source language then shows as the key itself. Never fails the gate"),
|
|
356
407
|
collisions: z.array(z.object({
|
|
357
408
|
key: z.string(),
|
|
358
|
-
sites: z.array(
|
|
359
|
-
file: z.string(),
|
|
360
|
-
line: z.number().optional(),
|
|
361
|
-
message: z.string()
|
|
362
|
-
}))
|
|
409
|
+
sites: z.array(sourceSite)
|
|
363
410
|
})).describe("One key, several texts: every place shows the first site. Never fails the gate"),
|
|
364
411
|
divergent: z.array(z.object({
|
|
365
412
|
key: z.string(),
|
|
366
413
|
catalog: z.string(),
|
|
367
|
-
code:
|
|
368
|
-
file: z.string(),
|
|
369
|
-
line: z.number().optional(),
|
|
370
|
-
message: z.string()
|
|
371
|
-
})
|
|
414
|
+
code: sourceSite
|
|
372
415
|
})).describe("The source catalog says one text and the code another: the code's text ships. Never fails the gate"),
|
|
373
416
|
outdated: perLocaleEntries.describe("Translations written for an older source text: rewrite them, or a human keeps them with verbaly review --approve. Never fails the gate"),
|
|
374
|
-
unreviewed: perLocale
|
|
417
|
+
unreviewed: perLocale,
|
|
418
|
+
stateProblem: z.string().optional().describe("The state file could not be read, so outdated translations are not listed")
|
|
375
419
|
},
|
|
376
420
|
annotations: { readOnlyHint: true }
|
|
377
421
|
}, guarded(async ({ root, drafts }) => {
|
|
378
422
|
const cfg = await config(root);
|
|
379
423
|
const registry = await extractProject(cfg);
|
|
380
424
|
const catalogs = loadCatalogs(cfg);
|
|
381
|
-
const state =
|
|
425
|
+
const { state, problem } = drafts ? {
|
|
426
|
+
state: loadState(cfg),
|
|
427
|
+
problem: void 0
|
|
428
|
+
} : readState(cfg);
|
|
382
429
|
const result = check(cfg, catalogs, registry, state.fingerprints);
|
|
383
430
|
const unreviewed = drafts ? byLocale(effectiveDrafts(state.drafts, catalogs)) : [];
|
|
384
431
|
const lines = [];
|
|
@@ -386,9 +433,11 @@ function createVerbalyMcp(options = {}) {
|
|
|
386
433
|
const warnings = formatCheckWarnings(result, cfg.root);
|
|
387
434
|
if (warnings) lines.push(`warnings (the gate still passes):\n${warnings}`);
|
|
388
435
|
for (const { locale, keys } of unreviewed) if (keys.length) lines.push(`[${locale}] ${keys.length} unreviewed: ${keys.join(", ")}`);
|
|
436
|
+
if (problem) lines.push(`${problem}, so outdated translations are not listed`);
|
|
389
437
|
return reply(lines.length === 0 ? "all translations complete" : lines.join("\n"), {
|
|
390
|
-
...result,
|
|
391
|
-
unreviewed
|
|
438
|
+
...relativeCheck(cfg.root, result),
|
|
439
|
+
unreviewed,
|
|
440
|
+
...problem && { stateProblem: problem }
|
|
392
441
|
});
|
|
393
442
|
}));
|
|
394
443
|
server.registerTool("verbaly_translate", {
|
|
@@ -413,7 +462,9 @@ function createVerbalyMcp(options = {}) {
|
|
|
413
462
|
}
|
|
414
463
|
}, guarded(async ({ root, locales, dryRun }) => {
|
|
415
464
|
const cfg = await config(root);
|
|
416
|
-
|
|
465
|
+
if (!dryRun) loadState(cfg);
|
|
466
|
+
const registry = await extractProject(cfg);
|
|
467
|
+
const catalogs = shippedCatalogs(cfg, loadCatalogs(cfg), registry, { newKeys: false });
|
|
417
468
|
const provider = await resolveProvider(cfg);
|
|
418
469
|
const result = await translateCatalogs(cfg, catalogs, provider, {
|
|
419
470
|
locales,
|
|
@@ -421,7 +472,7 @@ function createVerbalyMcp(options = {}) {
|
|
|
421
472
|
concurrency: cfg.translate.concurrency,
|
|
422
473
|
retries: cfg.translate.retries,
|
|
423
474
|
dryRun,
|
|
424
|
-
origins: dryRun ? void 0 : await collectOrigins(cfg)
|
|
475
|
+
origins: dryRun ? void 0 : await collectOrigins(cfg, registry)
|
|
425
476
|
});
|
|
426
477
|
if (dryRun) {
|
|
427
478
|
const pending = byLocale(result.pending);
|
|
@@ -436,17 +487,25 @@ function createVerbalyMcp(options = {}) {
|
|
|
436
487
|
};
|
|
437
488
|
return reply(lines.length === 0 ? "nothing to translate" : lines.join("\n"), data);
|
|
438
489
|
}
|
|
439
|
-
const drafts = loadDrafts(cfg);
|
|
440
490
|
const written = {};
|
|
441
491
|
const kept = {};
|
|
492
|
+
const writes = [];
|
|
442
493
|
for (const [locale, keys] of Object.entries(result.translated)) {
|
|
443
|
-
const
|
|
444
|
-
|
|
494
|
+
const catalog = catalogs[locale] ?? {};
|
|
495
|
+
const landed = mergeTranslations(cfg, locale, catalog, keys);
|
|
496
|
+
writes.push({
|
|
497
|
+
locale,
|
|
498
|
+
draft: true,
|
|
499
|
+
entries: landed.map((key) => ({
|
|
500
|
+
key,
|
|
501
|
+
text: catalog[key]
|
|
502
|
+
}))
|
|
503
|
+
});
|
|
445
504
|
if (landed.length > 0) written[locale] = landed;
|
|
446
505
|
const left = keys.filter((key) => !landed.includes(key));
|
|
447
506
|
if (left.length > 0) kept[locale] = left;
|
|
448
507
|
}
|
|
449
|
-
if (
|
|
508
|
+
if (writes.length > 0) recordTranslations(cfg, catalogs[cfg.sourceLocale] ?? {}, writes);
|
|
450
509
|
const data = {
|
|
451
510
|
dryRun: false,
|
|
452
511
|
translated: byLocale(written),
|
|
@@ -484,7 +543,11 @@ function createVerbalyMcp(options = {}) {
|
|
|
484
543
|
}
|
|
485
544
|
}, guarded(async ({ root, locale, entries, overwrite }) => {
|
|
486
545
|
const cfg = await config(root);
|
|
487
|
-
const
|
|
546
|
+
const registry = await extractProject(cfg);
|
|
547
|
+
const result = writeDrafts(cfg, locale, entries, {
|
|
548
|
+
overwrite,
|
|
549
|
+
registry
|
|
550
|
+
});
|
|
488
551
|
const lines = [];
|
|
489
552
|
if (result.written.length > 0) lines.push(`${locale}: +${result.written.length} saved as drafts, awaiting human review`);
|
|
490
553
|
if (result.kept.length > 0) lines.push(`${locale}: ${result.kept.length} already translated, kept: ${result.kept.join(", ")}`);
|
|
@@ -512,8 +575,8 @@ function createVerbalyMcp(options = {}) {
|
|
|
512
575
|
}, guarded(async ({ root, locales }) => {
|
|
513
576
|
const cfg = await config(root);
|
|
514
577
|
const catalogs = loadCatalogs(cfg);
|
|
515
|
-
const source = catalogs[cfg.sourceLocale] ?? {};
|
|
516
|
-
const pending = effectiveDrafts(
|
|
578
|
+
const source = shippedCatalogs(cfg, catalogs, await extractProject(cfg))[cfg.sourceLocale] ?? {};
|
|
579
|
+
const pending = effectiveDrafts(loadState(cfg).drafts, catalogs);
|
|
517
580
|
const wanted = locales ?? cfg.locales;
|
|
518
581
|
const entries = Object.entries(pending).filter(([locale]) => wanted.includes(locale)).flatMap(([locale, keys]) => keys.map((key) => ({
|
|
519
582
|
locale,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport {\n check,\n collisionEntries,\n collectOrigins,\n counted,\n doctor,\n effectiveDrafts,\n extractProject,\n formatCheckResult,\n formatCheckWarnings,\n formatDoctorEntry,\n formatStatusResult,\n formatTranslateFailures,\n init,\n loadCatalogs,\n loadConfig,\n loadDrafts,\n loadState,\n markDrafts,\n mergeTranslations,\n pruneCatalogs,\n resolveProvider,\n saveDrafts,\n status,\n syncCatalogs,\n translateCatalogs,\n updateState,\n wrapProject,\n writeCatalog,\n writeDrafts,\n writeDts,\n type ResolvedConfig,\n} from '@verbaly/compiler';\nimport { readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { relative } from 'node:path';\nimport { z } from 'zod';\n\nconst { version } = createRequire(import.meta.url)('../package.json') as { version: string };\n\nexport interface VerbalyMcpOptions {\n root?: string;\n}\n\n// text stays the fallback for a client that reads no schema, structuredContent is what agents parse\nconst reply = (body: string, data: Record<string, unknown>): CallToolResult => ({\n content: [{ type: 'text', text: body }],\n structuredContent: data,\n});\n\nconst rootInput = z\n .string()\n .optional()\n .describe('Project root holding verbaly.config (defaults to the server working directory)');\n\nconst perLocale = z.array(z.object({ locale: z.string(), keys: z.array(z.string()) }));\n\nconst perLocaleEntries = z.array(z.object({ locale: z.string(), key: z.string() }));\n\n// a locale-keyed record is a dynamic schema an agent cannot read ahead: lists enumerate\nconst byLocale = (record: Record<string, string[]>): Array<{ locale: string; keys: string[] }> =>\n Object.entries(record).map(([locale, keys]) => ({ locale, keys }));\n\n// a line number from the source the scan read; a file gone since then has none\nfunction lineOf(file: string, offset: number): number | undefined {\n try {\n return readFileSync(file, 'utf8').slice(0, offset).split('\\n').length;\n } catch {\n return undefined;\n }\n}\n\nexport function createVerbalyMcp(options: VerbalyMcpOptions = {}): McpServer {\n const server = new McpServer({ name: 'verbaly', version });\n\n const config = (root?: string): Promise<ResolvedConfig> =>\n loadConfig(root ?? options.root ?? process.cwd());\n\n // agents act on messages, not stack traces: every failure comes back as actionable text\n const guarded =\n <A>(run: (args: A) => Promise<CallToolResult>) =>\n async (args: A): Promise<CallToolResult> => {\n try {\n return await run(args);\n } catch (error) {\n return {\n content: [{ type: 'text', text: error instanceof Error ? error.message : String(error) }],\n isError: true,\n };\n }\n };\n\n // resources, not tools: reading the project is an address, and it must not spend a tool call\n server.registerResource(\n 'verbaly-config',\n 'verbaly://config',\n {\n title: 'Project shape',\n description:\n 'The resolved Verbaly config: source locale, every locale, the catalog directory and where the language lives in the url. Read this before reasoning about anything else in the project.',\n mimeType: 'application/json',\n },\n async (uri) => {\n const cfg = await config();\n const shape = {\n root: cfg.root,\n sourceLocale: cfg.sourceLocale,\n locales: cfg.locales,\n localesDeclared: cfg.localesDeclared,\n dir: cfg.dir,\n routing: cfg.routing,\n include: cfg.include,\n };\n return {\n contents: [\n { uri: uri.href, mimeType: 'application/json', text: JSON.stringify(shape, null, 2) },\n ],\n };\n },\n );\n\n server.registerResource(\n 'verbaly-catalog',\n new ResourceTemplate('verbaly://catalog/{locale}', {\n list: async () => {\n const cfg = await config();\n return {\n resources: cfg.locales.map((locale) => ({\n name: `${locale} catalog`,\n uri: `verbaly://catalog/${locale}`,\n mimeType: 'application/json',\n })),\n };\n },\n }),\n {\n title: 'Locale catalog',\n description:\n 'Every message of one locale, keyed the way the runtime sees them: a nested catalog arrives flattened, and an empty value means untranslated. This is the only way to read what a message actually says.',\n mimeType: 'application/json',\n },\n async (uri, { locale }) => {\n const cfg = await config();\n const name = String(locale);\n if (!cfg.locales.includes(name)) {\n const have = cfg.locales.join(', ');\n throw new Error(`[verbaly] unknown locale \"${name}\": the project has ${have}`);\n }\n const catalog = loadCatalogs(cfg)[name] ?? {};\n return {\n contents: [\n { uri: uri.href, mimeType: 'application/json', text: JSON.stringify(catalog, null, 2) },\n ],\n };\n },\n );\n\n server.registerTool(\n 'verbaly_init',\n {\n title: 'Set up Verbaly in a project',\n description:\n 'Create the config file and the locale catalogs, and detect the bundler or meta-framework so the answer names the package to add and the line to wire (what `verbaly init` does). Writes files, and a file already there is kept rather than overwritten. Run this when doctor says there is no config.',\n inputSchema: {\n root: rootInput,\n dir: z.string().optional().describe('Directory for the catalogs (default: locales)'),\n sourceLocale: z.string().optional().describe('The language you write in (default: en)'),\n locales: z.array(z.string()).optional().describe('Every locale, source included'),\n },\n outputSchema: {\n created: z.array(z.string()).describe('Files written, relative to the project root'),\n skipped: z.array(z.string()).describe('Files already there, left untouched'),\n host: z\n .string()\n .optional()\n .describe('Bundler or meta-framework detected from the dependencies'),\n configFile: z.string(),\n next: z.array(z.string()).describe('What a human still has to do, in order'),\n renamed: z\n .array(z.object({ from: z.string(), to: z.string() }))\n .describe('Locales written with the hyphen a locale tag takes (pt_BR became pt-BR)'),\n refused: z\n .array(z.string())\n .describe('Locales left out: not a locale tag, and no sure way to fix one'),\n },\n },\n guarded(async ({ root, dir, sourceLocale, locales }) => {\n const result = await init({ root: root ?? options.root, dir, sourceLocale, locales });\n const lines: string[] = [];\n if (result.created.length) lines.push(`created: ${result.created.join(', ')}`);\n if (result.skipped.length) lines.push(`kept (already there): ${result.skipped.join(', ')}`);\n for (const { from, to } of result.renamed) lines.push(`wrote ${to} for ${from}`);\n for (const locale of result.refused) {\n lines.push(`left out \"${locale}\": it is not a locale tag, use one like es or pt-BR`);\n }\n if (result.host) lines.push(`detected: ${result.host}`);\n lines.push(...result.next.map((step, i) => `${i + 1}. ${step}`));\n return reply(lines.join('\\n'), { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_doctor',\n {\n title: 'Diagnose the setup',\n description:\n 'Diagnose a Verbaly project end to end (what `verbaly doctor` does): the config file, the catalog files and their JSON, the bundler plugin for the detected framework, the generated types, files the parser could not read, t imported from a package that never exports it, orphan keys, and every failure `verbaly check` would report. Run this first when something does not work. Read-only.',\n inputSchema: { root: rootInput },\n outputSchema: {\n ok: z.boolean().describe('False when an entry is an error, which is when the CLI exits 1'),\n entries: z.array(\n z.object({\n level: z.enum(['ok', 'warn', 'error']),\n check: z.string(),\n message: z.string(),\n fix: z.string().optional().describe('What to run or change, when there is one'),\n }),\n ),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root }) => {\n const cfg = await config(root);\n const result = await doctor(cfg);\n const health = result.ok ? 'setup looks healthy' : 'problems found';\n const head = `${counted(result.entries.length, 'check')}, ${health}`;\n return reply([head, ...result.entries.map(formatDoctorEntry)].join('\\n'), { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_wrap',\n {\n title: 'Wrap hardcoded JSX text',\n description:\n 'Find hardcoded user-visible text in JSX/TSX files and wrap it in a t tagged template so the compiler can extract it (what `verbaly wrap` does). This is how an existing codebase is onboarded. Reports only unless write is set. Text it cannot wrap safely (a sentence split across markup, an expression rendering JSX) is listed as needing a human and never rewritten. A file that does not bind t is never written either, because the rewrite would not compile: those come back in blocked, with whether the file is a client component, so you can add the binding and run again.',\n inputSchema: {\n root: rootInput,\n write: z.boolean().optional().describe('Apply the rewrites instead of only reporting'),\n },\n outputSchema: {\n files: z.number().describe('JSX/TSX files scanned'),\n write: z.boolean(),\n changed: z.array(z.string()).describe('Files the rewrite touched, or would touch'),\n wrapped: z.array(\n z.object({\n file: z.string(),\n line: z.number(),\n text: z.string(),\n kind: z.enum(['text', 'attribute']),\n attribute: z.string().optional(),\n }),\n ),\n skipped: z.array(\n z.object({ file: z.string(), line: z.number(), text: z.string(), reason: z.string() }),\n ),\n blocked: z.array(\n z.object({ file: z.string(), texts: z.number(), client: z.boolean() }),\n ),\n },\n },\n guarded(async ({ root, write }) => {\n const cfg = await config(root);\n const result = await wrapProject(cfg, { write });\n const blocked = new Set(result.blocked.map((entry) => entry.file));\n const done = result.changed.filter((file) => !blocked.has(file));\n const texts = result.wrapped.filter((entry) => !blocked.has(entry.file));\n const verb = write ? 'wrapped' : 'would wrap';\n const counts = write\n ? `${counted(texts.length, 'text')} in ${counted(done.length, 'file')}`\n : `${counted(result.wrapped.length, 'text')} in ${counted(result.changed.length, 'file')}`;\n const lines = [`${verb} ${counts} of ${counted(result.files, 'file')} scanned`];\n for (const entry of write ? texts : result.wrapped) {\n const attr = entry.kind === 'attribute' ? `${entry.attribute} -> ` : '';\n lines.push(` ${entry.file}:${entry.line} ${attr}\"${entry.text}\"`);\n }\n if (result.skipped.length > 0) {\n lines.push(' needs a human:');\n for (const entry of result.skipped) {\n lines.push(` ${entry.file}:${entry.line} \"${entry.text}\" (${entry.reason})`);\n }\n }\n if (result.blocked.length > 0) {\n lines.push(` nothing written in ${counted(result.blocked.length, 'file')} with no t in scope:`);\n for (const entry of result.blocked) {\n const how = entry.client ? '\"use client\", so const t = useT()' : 'no \"use client\"';\n lines.push(` ${entry.file} ${counted(entry.texts, 'text')}, ${how}`);\n }\n lines.push(' next: bind t there, run verbaly_wrap with write again, then verbaly_extract');\n } else if (write && done.length > 0) {\n lines.push(' next: run verbaly_extract');\n }\n return reply(lines.join('\\n'), { ...result, write: write === true });\n }),\n );\n\n server.registerTool(\n 'verbaly_extract',\n {\n title: 'Extract messages',\n description:\n 'Scan the source files, add new messages to the locale catalogs and refresh the generated types (what `verbaly extract` does). Writes catalog files unless dryRun is set. prune drops keys no longer referenced in the code, translations included.',\n inputSchema: {\n root: rootInput,\n prune: z\n .boolean()\n .optional()\n .describe('Drop keys no longer referenced (deletes their translations)'),\n dryRun: z.boolean().optional().describe('Report what would change, write nothing'),\n },\n outputSchema: {\n messages: z.number(),\n locales: z.array(z.string()),\n dryRun: z.boolean(),\n added: perLocale,\n pruned: perLocale,\n unparsed: z\n .array(z.object({ file: z.string(), message: z.string() }))\n .describe(\n 'Source files the parser could not read: their messages are not extracted, and prune drops nothing until they parse',\n ),\n collisions: z\n .array(z.object({ key: z.string(), sites: z.array(z.object({ file: z.string(), line: z.number().optional(), message: z.string() })) }))\n .describe(\n 'Keys written with more than one text: every place shows the text of the first site, so give each text its own key',\n ),\n renamed: z\n .array(z.object({ file: z.string(), line: z.number().optional(), name: z.string() }))\n .describe(\n 'Tagged templates on t under another name (const tr = useT()): never extracted, so they stay in the source language until the binding is named t',\n ),\n },\n },\n guarded(async ({ root, prune, dryRun }) => {\n const cfg = await config(root);\n const registry = await extractProject(cfg);\n const catalogs = loadCatalogs(cfg);\n // an agent sees no terminal, so what the CLI prints about these has to be in the answer\n const unparsed = registry.parseErrors().map(({ file, message }) => ({\n file: relative(cfg.root, file).replaceAll('\\\\', '/'),\n message,\n }));\n\n const lines: string[] = [];\n const pruned = prune ? byLocale(pruneCatalogs(cfg, catalogs, registry)) : [];\n if (prune && unparsed.length > 0) {\n lines.push(\n 'prune skipped: an unparsed file may read any key, so it waits until every file parses',\n );\n }\n for (const { locale, keys } of pruned) {\n lines.push(\n dryRun\n ? `${locale}: would prune ${keys.length}: ${keys.join(', ')}`\n : `${locale}: ${keys.length} pruned`,\n );\n }\n const added = byLocale(syncCatalogs(cfg, catalogs, registry).added);\n if (!dryRun) {\n for (const locale of cfg.locales) {\n writeCatalog(cfg, locale, catalogs[locale] ?? {});\n }\n writeDts(cfg, catalogs[cfg.sourceLocale] ?? {});\n // a pruned key takes its draft with it, so nobody has to clean the state file by hand\n updateState(cfg, catalogs);\n }\n const rel = (file: string): string => relative(cfg.root, file).replaceAll('\\\\', '/');\n const collisions = collisionEntries(registry).map(({ key, sites }) => ({\n key,\n sites: sites.map((at) => ({ ...at, file: rel(at.file) })),\n }));\n const renamed = registry.missed().map(({ name, file, start }) => ({\n file: rel(file),\n line: lineOf(file, start),\n name,\n }));\n const messages = registry.messages().size;\n lines.unshift(\n `${counted(messages, 'message')} · locales: ${cfg.locales.join(', ')}${dryRun ? ' (dry run, nothing written)' : ''}`,\n );\n for (const { locale, keys } of added) {\n lines.push(`${locale}: ${dryRun ? `would add ${keys.length}` : `+${keys.length} added`}`);\n }\n for (const { file, message } of unparsed) {\n lines.push(`${file}: could not be parsed (${message}), its messages were not extracted`);\n }\n for (const { key, sites } of collisions) {\n const where = sites.map((at) => (at.line ? `${at.file}:${at.line}` : at.file)).join(', ');\n lines.push(`${key}: one key with ${counted(sites.length, 'text')} (${where}), every place shows the first`);\n }\n for (const { file, line, name } of renamed) {\n lines.push(`${file}${line ? `:${line}` : ''}: ${name}\\`…\\` is never extracted, name the binding t`);\n }\n return reply(lines.join('\\n'), {\n messages,\n locales: cfg.locales,\n dryRun: dryRun === true,\n added,\n pruned,\n unparsed,\n collisions,\n renamed,\n });\n }),\n );\n\n server.registerTool(\n 'verbaly_status',\n {\n title: 'Translation coverage',\n description:\n 'Translation coverage of the Verbaly project: total messages, translated count per locale, machine translations awaiting review (drafts) and translations written for an older source text (outdated). Read-only.',\n inputSchema: { root: rootInput },\n outputSchema: {\n messages: z.number().describe('Messages the project has, source catalog plus code'),\n source: z.string().describe('Source locale'),\n locales: z.array(\n z.object({\n locale: z.string(),\n translated: z.number(),\n total: z.number(),\n drafts: z.number().describe('Machine translations awaiting human review'),\n broken: z.number().describe('Present but not rendering what the source renders'),\n outdated: z\n .number()\n .describe('Translated from an older source text: update them, or a human keeps them'),\n }),\n ),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root }) => {\n const cfg = await config(root);\n const registry = await extractProject(cfg);\n const state = loadState(cfg);\n const result = status(cfg, loadCatalogs(cfg), registry, state.drafts, state.fingerprints);\n return reply(formatStatusResult(result), { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_missing',\n {\n title: 'Missing and broken translations',\n description:\n 'List missing translations, unknown keys and translations that exist but cannot render what the source renders (a dropped {param}, a lost rich tag, a flattened plural block), the same gate `verbaly check` runs in CI. Warnings never fail the gate and are listed too: an incomplete plural set for the locale, keys a translation carries that the source catalog does not (extra), keys written with two texts (collisions), texts the code and the source catalog disagree on (divergent, the text in the code ships) and translations written for an older source text (outdated). Optionally also lists machine translations awaiting review. Read-only.',\n inputSchema: {\n root: rootInput,\n drafts: z\n .boolean()\n .optional()\n .describe('Also list machine translations awaiting human review'),\n },\n outputSchema: {\n ok: z.boolean().describe('Whether `verbaly check` would pass (warnings never fail it)'),\n missing: z.array(\n z.object({ locale: z.string(), key: z.string(), source: z.string().optional() }),\n ),\n unknown: z.array(z.object({ key: z.string(), files: z.array(z.string()) })),\n broken: z.array(\n z.object({\n locale: z.string(),\n key: z.string(),\n severity: z.enum(['error', 'warning']),\n issue: z.string(),\n }),\n ),\n extra: z\n .array(z.object({ locale: z.string(), key: z.string(), files: z.array(z.string()) }))\n .describe(\n 'Keys only a translation has; files are where the code reads one, which the source language then shows as the key itself. Never fails the gate',\n ),\n collisions: z\n .array(z.object({ key: z.string(), sites: z.array(z.object({ file: z.string(), line: z.number().optional(), message: z.string() })) }))\n .describe('One key, several texts: every place shows the first site. Never fails the gate'),\n divergent: z\n .array(z.object({ key: z.string(), catalog: z.string(), code: z.object({ file: z.string(), line: z.number().optional(), message: z.string() }) }))\n .describe(\n \"The source catalog says one text and the code another: the code's text ships. Never fails the gate\",\n ),\n outdated: perLocaleEntries.describe(\n 'Translations written for an older source text: rewrite them, or a human keeps them with verbaly review --approve. Never fails the gate',\n ),\n unreviewed: perLocale,\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root, drafts }) => {\n const cfg = await config(root);\n const registry = await extractProject(cfg);\n const catalogs = loadCatalogs(cfg);\n const state = loadState(cfg);\n const result = check(cfg, catalogs, registry, state.fingerprints);\n const unreviewed = drafts ? byLocale(effectiveDrafts(state.drafts, catalogs)) : [];\n\n const lines: string[] = [];\n if (!result.ok) lines.push(formatCheckResult(result, cfg.root));\n const warnings = formatCheckWarnings(result, cfg.root);\n if (warnings) lines.push(`warnings (the gate still passes):\\n${warnings}`);\n for (const { locale, keys } of unreviewed) {\n if (keys.length) lines.push(`[${locale}] ${keys.length} unreviewed: ${keys.join(', ')}`);\n }\n return reply(lines.length === 0 ? 'all translations complete' : lines.join('\\n'), {\n ...result,\n unreviewed,\n });\n }),\n );\n\n server.registerTool(\n 'verbaly_translate',\n {\n title: 'Machine-translate missing entries',\n description:\n 'Fill missing translations with the configured provider (default: Claude, needs @anthropic-ai/sdk and ANTHROPIC_API_KEY). New translations are saved as drafts awaiting human review (`verbaly review`), which no tool here can approve. A batch the provider never answers is reported in failed and leaves everything else written, so a retry only asks for what is left. dryRun lists what would be translated without calling the provider.',\n inputSchema: {\n root: rootInput,\n locales: z.array(z.string()).optional().describe('Target locales (default: all)'),\n dryRun: z\n .boolean()\n .optional()\n .describe('List missing entries per locale, call no provider'),\n },\n outputSchema: {\n dryRun: z.boolean(),\n translated: perLocale.describe('Saved as drafts, a human still has to approve them'),\n kept: perLocale.describe(\n 'Written on disk by someone else while the provider worked, so left as they were',\n ),\n invalid: perLocale.describe('Rejected: params or tags were not preserved'),\n failed: z\n .array(z.object({ locale: z.string(), keys: z.array(z.string()), error: z.string() }))\n .describe('Batches the provider never answered, safe to retry'),\n pending: perLocale.describe('dryRun only: what would be translated'),\n },\n },\n guarded(async ({ root, locales, dryRun }) => {\n const cfg = await config(root);\n const catalogs = loadCatalogs(cfg);\n const provider = await resolveProvider(cfg);\n const result = await translateCatalogs(cfg, catalogs, provider, {\n locales,\n batchSize: cfg.translate.batchSize,\n concurrency: cfg.translate.concurrency,\n retries: cfg.translate.retries,\n dryRun,\n origins: dryRun ? undefined : await collectOrigins(cfg),\n });\n\n if (dryRun) {\n const pending = byLocale(result.pending);\n const lines = pending.map(\n ({ locale, keys }) => `${locale}: ${keys.length} missing: ${keys.join(', ')}`,\n );\n const data = { dryRun: true, translated: [], kept: [], invalid: [], failed: [], pending };\n return reply(lines.length === 0 ? 'nothing to translate' : lines.join('\\n'), data);\n }\n\n // the file as it is now: what someone wrote while the provider worked is not overwritten\n const drafts = loadDrafts(cfg);\n const written: Record<string, string[]> = {};\n const kept: Record<string, string[]> = {};\n for (const [locale, keys] of Object.entries(result.translated)) {\n const landed = mergeTranslations(cfg, locale, catalogs[locale] ?? {}, keys);\n markDrafts(drafts, locale, landed);\n if (landed.length > 0) written[locale] = landed;\n const left = keys.filter((key) => !landed.includes(key));\n if (left.length > 0) kept[locale] = left;\n }\n if (Object.keys(written).length > 0) saveDrafts(cfg, drafts);\n\n const data = {\n dryRun: false,\n translated: byLocale(written),\n kept: byLocale(kept),\n invalid: byLocale(result.invalid),\n failed: result.failed,\n pending: [],\n };\n const lines: string[] = [];\n for (const { locale, keys } of data.translated) {\n lines.push(`${locale}: +${keys.length} translated (draft)`);\n }\n for (const { locale, keys } of data.kept) {\n lines.push(`${locale}: ${keys.length} kept as written while this ran: ${keys.join(', ')}`);\n }\n for (const { locale, keys } of data.invalid) {\n lines.push(\n `${locale}: ${keys.length} rejected (params/tags not preserved): ${keys.join(', ')}`,\n );\n }\n lines.push(...formatTranslateFailures(result.failed));\n if (lines.length === 0) return reply('nothing to translate', data);\n if (data.translated.length > 0) {\n lines.push('drafts await human review: verbaly review (--approve accepts them)');\n }\n return reply(lines.join('\\n'), data);\n }),\n );\n server.registerTool(\n 'verbaly_write_drafts',\n {\n title: 'Save translations an agent wrote',\n description:\n \"Save translations you wrote yourself, so neither a catalog nor the state file is ever edited by hand. Each one is checked the way `verbaly translate` checks a provider (params, rich tags and plural cases must survive), written only for keys the source catalog has, and marked as a draft awaiting human review. Existing translations are kept unless overwrite is set, which is how an outdated one gets rewritten. Approving is not a tool here: a human runs `verbaly review --approve`.\",\n inputSchema: {\n root: rootInput,\n locale: z.string().describe(\"Target locale, one of the project's non-source locales\"),\n entries: z\n .array(z.object({ key: z.string(), text: z.string() }))\n .describe('The translations, by catalog key'),\n overwrite: z\n .boolean()\n .optional()\n .describe('Replace translations that already exist, for example outdated ones'),\n },\n outputSchema: {\n written: z.array(z.string()).describe('Saved as drafts, a human still has to approve them'),\n kept: z\n .array(z.string())\n .describe('Already translated, left as they were (overwrite replaces them)'),\n invalid: z\n .array(z.string())\n .describe('Rejected: empty, or the params, tags or plural cases were not preserved'),\n unknown: z.array(z.string()).describe('Not in the source catalog, so nothing was written'),\n },\n },\n guarded(async ({ root, locale, entries, overwrite }) => {\n const cfg = await config(root);\n const result = writeDrafts(cfg, locale, entries, { overwrite });\n const lines: string[] = [];\n if (result.written.length > 0) {\n lines.push(`${locale}: +${result.written.length} saved as drafts, awaiting human review`);\n }\n if (result.kept.length > 0) {\n lines.push(`${locale}: ${result.kept.length} already translated, kept: ${result.kept.join(', ')}`);\n }\n if (result.invalid.length > 0) {\n lines.push(\n `${locale}: ${result.invalid.length} rejected (params/tags not preserved): ${result.invalid.join(', ')}`,\n );\n }\n if (result.unknown.length > 0) {\n lines.push(\n `${locale}: ${counted(result.unknown.length, 'unknown key')} not in the source catalog: ${result.unknown.join(', ')}`,\n );\n }\n return reply(lines.length > 0 ? lines.join('\\n') : 'nothing to save', { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_drafts',\n {\n title: 'Machine translations awaiting review',\n description:\n 'Every machine translation still waiting for a human, each with the source text and what the provider wrote, so a person can read both and decide. Read-only. Approving is deliberately not a tool here and never will be: a machine translation is unreviewed by definition, so accepting one is `verbaly review --approve`, run by a human.',\n inputSchema: {\n root: rootInput,\n locales: z.array(z.string()).optional().describe('Target locales (default: all)'),\n },\n outputSchema: {\n total: z.number(),\n entries: z.array(\n z.object({\n locale: z.string(),\n key: z.string(),\n source: z.string().describe('What the message says in the source locale'),\n translated: z.string().describe('What the provider wrote, still unreviewed'),\n }),\n ),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root, locales }) => {\n const cfg = await config(root);\n const catalogs = loadCatalogs(cfg);\n const source = catalogs[cfg.sourceLocale] ?? {};\n const pending = effectiveDrafts(loadDrafts(cfg), catalogs);\n const wanted = locales ?? cfg.locales;\n const entries = Object.entries(pending)\n .filter(([locale]) => wanted.includes(locale))\n .flatMap(([locale, keys]) =>\n keys.map((key) => ({\n locale,\n key,\n source: source[key] ?? '',\n translated: catalogs[locale]?.[key] ?? '',\n })),\n );\n const body = entries.length\n ? entries\n .map((e) => `[${e.locale}] ${e.key}\n source: ${e.source}\n draft: ${e.translated}`)\n .join('\\n')\n : 'nothing awaiting review';\n return reply(body, { total: entries.length, entries });\n }),\n );\n\n\n return server;\n}\n"],"mappings":";;;;;;;AAwCA,MAAM,EAAE,YAAY,cAAc,YAAY,GAAG,CAAC,CAAC,iBAAiB;AAOpE,MAAM,SAA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;EACzD,MAAM,SAAS,WAAW,IAAI;EAC9B,MAAM,UAAU,OAAO,QAAQ,OAAO,CAAC,CACpC,QAAQ,CAAC,YAAY,OAAO,SAAS,MAAM,CAAC,CAAC,CAC7C,SAAS,CAAC,QAAQ,UACjB,KAAK,KAAK,SAAS;GACjB;GACA;GACA,QAAQ,OAAO,QAAQ;GACvB,YAAY,SAAS,OAAO,GAAG,QAAQ;EACzC,EAAE,CACJ;EACF,MAAM,OAAO,QAAQ,SACjB,QACG,KAAK,MAAM,IAAI,EAAE,OAAO,IAAI,EAAE,IAAI;YACnC,EAAE,OAAO;YACT,EAAE,YAAY,CAAC,CACd,KAAK,IAAI,IACZ;EACJ,OAAO,MAAM,MAAM;GAAE,OAAO,QAAQ;GAAQ;EAAQ,CAAC;CACvD,CAAC,CACH;CAGA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport {\n check,\n collectOrigins,\n counted,\n doctor,\n effectiveDrafts,\n extractProject,\n formatCheckResult,\n formatCheckWarnings,\n formatDoctorEntry,\n formatFinding,\n formatStatusResult,\n formatTranslateFailures,\n init,\n loadCatalogs,\n loadConfig,\n loadState,\n mergeTranslations,\n readState,\n recordTranslations,\n resolveProvider,\n shippedCatalogs,\n status,\n syncProject,\n translateCatalogs,\n wrapProject,\n writeDrafts,\n type CheckResult,\n type ResolvedConfig,\n type TranslationWrite,\n} from '@verbaly/compiler';\nimport { createRequire } from 'node:module';\nimport { relative } from 'node:path';\nimport { z } from 'zod';\n\nconst { version } = createRequire(import.meta.url)('../package.json') as { version: string };\n\nexport interface VerbalyMcpOptions {\n root?: string;\n}\n\n// text stays the fallback for a client that reads no schema, structuredContent is what agents parse\nconst reply = (body: string, data: Record<string, unknown>): CallToolResult => ({\n content: [{ type: 'text', text: body }],\n structuredContent: data,\n});\n\nconst rootInput = z\n .string()\n .optional()\n .describe('Project root holding verbaly.config (defaults to the server working directory)');\n\nconst perLocale = z.array(z.object({ locale: z.string(), keys: z.array(z.string()) }));\n\nconst perLocaleEntries = z.array(z.object({ locale: z.string(), key: z.string() }));\n\n// a locale-keyed record is a dynamic schema an agent cannot read ahead: lists enumerate\nconst byLocale = (record: Record<string, string[]>): Array<{ locale: string; keys: string[] }> =>\n Object.entries(record).map(([locale, keys]) => ({ locale, keys }));\n\nconst sourceSite = z.object({ file: z.string(), line: z.number().optional(), message: z.string() });\n\n// an agent reads paths against the project, the same way every tool here writes them\nfunction relativeTo(root: string): (file: string) => string {\n return (file) => relative(root, file).replaceAll('\\\\', '/');\n}\n\nfunction relativeCheck(root: string, result: CheckResult): CheckResult {\n const rel = relativeTo(root);\n return {\n ...result,\n unknown: result.unknown.map((entry) => ({ ...entry, files: entry.files.map(rel) })),\n extra: result.extra.map((entry) => ({ ...entry, files: entry.files.map(rel) })),\n collisions: result.collisions.map((entry) => ({\n ...entry,\n sites: entry.sites.map((at) => ({ ...at, file: rel(at.file) })),\n })),\n divergent: result.divergent.map((entry) => ({\n ...entry,\n code: { ...entry.code, file: rel(entry.code.file) },\n })),\n };\n}\n\nexport function createVerbalyMcp(options: VerbalyMcpOptions = {}): McpServer {\n const server = new McpServer({ name: 'verbaly', version });\n\n const config = (root?: string): Promise<ResolvedConfig> =>\n loadConfig(root ?? options.root ?? process.cwd());\n\n // agents act on messages, not stack traces: every failure comes back as actionable text\n const guarded =\n <A>(run: (args: A) => Promise<CallToolResult>) =>\n async (args: A): Promise<CallToolResult> => {\n try {\n return await run(args);\n } catch (error) {\n return {\n content: [{ type: 'text', text: error instanceof Error ? error.message : String(error) }],\n isError: true,\n };\n }\n };\n\n // resources, not tools: reading the project is an address, and it must not spend a tool call\n server.registerResource(\n 'verbaly-config',\n 'verbaly://config',\n {\n title: 'Project shape',\n description:\n 'The resolved Verbaly config: source locale, every locale, the catalog directory and where the language lives in the url. Read this before reasoning about anything else in the project.',\n mimeType: 'application/json',\n },\n async (uri) => {\n const cfg = await config();\n const shape = {\n root: cfg.root,\n sourceLocale: cfg.sourceLocale,\n locales: cfg.locales,\n localesDeclared: cfg.localesDeclared,\n dir: cfg.dir,\n routing: cfg.routing,\n include: cfg.include,\n };\n return {\n contents: [\n { uri: uri.href, mimeType: 'application/json', text: JSON.stringify(shape, null, 2) },\n ],\n };\n },\n );\n\n server.registerResource(\n 'verbaly-catalog',\n new ResourceTemplate('verbaly://catalog/{locale}', {\n list: async () => {\n const cfg = await config();\n return {\n resources: cfg.locales.map((locale) => ({\n name: `${locale} catalog`,\n uri: `verbaly://catalog/${locale}`,\n mimeType: 'application/json',\n })),\n };\n },\n }),\n {\n title: 'Locale catalog',\n description:\n 'Every message of one locale, keyed the way the runtime sees them: a nested catalog arrives flattened, a text the code owns reads as the code has it, and an empty value means untranslated. This is the only way to read what a message actually says.',\n mimeType: 'application/json',\n },\n async (uri, { locale }) => {\n const cfg = await config();\n const name = String(locale);\n if (!cfg.locales.includes(name)) {\n const have = cfg.locales.join(', ');\n throw new Error(`[verbaly] unknown locale \"${name}\": the project has ${have}`);\n }\n // the text that ships: a catalog the code has moved past would hand an agent the old words\n const registry = await extractProject(cfg);\n const shipped = shippedCatalogs(cfg, loadCatalogs(cfg), registry, { newKeys: false });\n const catalog = shipped[name] ?? {};\n return {\n contents: [\n { uri: uri.href, mimeType: 'application/json', text: JSON.stringify(catalog, null, 2) },\n ],\n };\n },\n );\n\n server.registerTool(\n 'verbaly_init',\n {\n title: 'Set up Verbaly in a project',\n description:\n 'Create the config file and the locale catalogs, and detect the bundler or meta-framework so the answer names the package to add and the line to wire (what `verbaly init` does). Writes files, and a file already there is kept rather than overwritten. Run this when doctor says there is no config.',\n inputSchema: {\n root: rootInput,\n dir: z.string().optional().describe('Directory for the catalogs (default: locales)'),\n sourceLocale: z.string().optional().describe('The language you write in (default: en)'),\n locales: z.array(z.string()).optional().describe('Every locale, source included'),\n },\n outputSchema: {\n created: z.array(z.string()).describe('Files written, relative to the project root'),\n skipped: z.array(z.string()).describe('Files already there, left untouched'),\n host: z\n .string()\n .optional()\n .describe('Bundler or meta-framework detected from the dependencies'),\n configFile: z.string(),\n next: z.array(z.string()).describe('What a human still has to do, in order'),\n renamed: z\n .array(z.object({ from: z.string(), to: z.string() }))\n .describe('Locales written with the hyphen a locale tag takes (pt_BR became pt-BR)'),\n refused: z\n .array(z.string())\n .describe('Locales left out: not a locale tag, and no sure way to fix one'),\n },\n },\n guarded(async ({ root, dir, sourceLocale, locales }) => {\n const result = await init({ root: root ?? options.root, dir, sourceLocale, locales });\n const lines: string[] = [];\n if (result.created.length) lines.push(`created: ${result.created.join(', ')}`);\n if (result.skipped.length) lines.push(`kept (already there): ${result.skipped.join(', ')}`);\n for (const { from, to } of result.renamed) lines.push(`wrote ${to} for ${from}`);\n for (const locale of result.refused) {\n lines.push(`left out \"${locale}\": it is not a locale tag, use one like es or pt-BR`);\n }\n if (result.host) lines.push(`detected: ${result.host}`);\n lines.push(...result.next.map((step, i) => `${i + 1}. ${step}`));\n return reply(lines.join('\\n'), { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_doctor',\n {\n title: 'Diagnose the setup',\n description:\n 'Diagnose a Verbaly project end to end (what `verbaly doctor` does): the config file, the catalog files and their JSON, the bundler plugin for the detected framework, the generated types, files the parser could not read, t imported from a package that never exports it, orphan keys, and every failure `verbaly check` would report. Run this first when something does not work. Read-only.',\n inputSchema: { root: rootInput },\n outputSchema: {\n ok: z.boolean().describe('False when an entry is an error, which is when the CLI exits 1'),\n entries: z.array(\n z.object({\n level: z.enum(['ok', 'warn', 'error']),\n check: z.string(),\n message: z.string(),\n fix: z.string().optional().describe('What to run or change, when there is one'),\n }),\n ),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root }) => {\n const cfg = await config(root);\n const result = await doctor(cfg);\n const health = result.ok ? 'setup looks healthy' : 'problems found';\n const head = `${counted(result.entries.length, 'check')}, ${health}`;\n return reply([head, ...result.entries.map(formatDoctorEntry)].join('\\n'), { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_wrap',\n {\n title: 'Wrap hardcoded JSX text',\n description:\n 'Find hardcoded user-visible text in JSX/TSX files and wrap it in a t tagged template so the compiler can extract it (what `verbaly wrap` does). This is how an existing codebase is onboarded. Reports only unless write is set. Text it cannot wrap safely (a sentence split across markup, an expression rendering JSX) is listed as needing a human and never rewritten. A file that does not bind t is never written either, because the rewrite would not compile: those come back in blocked, with whether the file is a client component, so you can add the binding and run again.',\n inputSchema: {\n root: rootInput,\n write: z.boolean().optional().describe('Apply the rewrites instead of only reporting'),\n },\n outputSchema: {\n files: z.number().describe('JSX/TSX files scanned'),\n write: z.boolean(),\n changed: z.array(z.string()).describe('Files the rewrite touched, or would touch'),\n wrapped: z.array(\n z.object({\n file: z.string(),\n line: z.number(),\n text: z.string(),\n kind: z.enum(['text', 'attribute']),\n attribute: z.string().optional(),\n }),\n ),\n skipped: z.array(\n z.object({ file: z.string(), line: z.number(), text: z.string(), reason: z.string() }),\n ),\n blocked: z.array(\n z.object({ file: z.string(), texts: z.number(), client: z.boolean() }),\n ),\n },\n },\n guarded(async ({ root, write }) => {\n const cfg = await config(root);\n const result = await wrapProject(cfg, { write });\n const blocked = new Set(result.blocked.map((entry) => entry.file));\n const done = result.changed.filter((file) => !blocked.has(file));\n const texts = result.wrapped.filter((entry) => !blocked.has(entry.file));\n const verb = write ? 'wrapped' : 'would wrap';\n const counts = write\n ? `${counted(texts.length, 'text')} in ${counted(done.length, 'file')}`\n : `${counted(result.wrapped.length, 'text')} in ${counted(result.changed.length, 'file')}`;\n const lines = [`${verb} ${counts} of ${counted(result.files, 'file')} scanned`];\n for (const entry of write ? texts : result.wrapped) {\n const attr = entry.kind === 'attribute' ? `${entry.attribute} -> ` : '';\n lines.push(` ${entry.file}:${entry.line} ${attr}\"${entry.text}\"`);\n }\n if (result.skipped.length > 0) {\n lines.push(' needs a human:');\n for (const entry of result.skipped) {\n lines.push(` ${entry.file}:${entry.line} \"${entry.text}\" (${entry.reason})`);\n }\n }\n if (result.blocked.length > 0) {\n lines.push(` nothing written in ${counted(result.blocked.length, 'file')} with no t in scope:`);\n for (const entry of result.blocked) {\n const how = entry.client ? '\"use client\", so const t = useT()' : 'no \"use client\"';\n lines.push(` ${entry.file} ${counted(entry.texts, 'text')}, ${how}`);\n }\n lines.push(' next: bind t there, run verbaly_wrap with write again, then verbaly_extract');\n } else if (write && done.length > 0) {\n lines.push(' next: run verbaly_extract');\n }\n return reply(lines.join('\\n'), { ...result, write: write === true });\n }),\n );\n\n server.registerTool(\n 'verbaly_extract',\n {\n title: 'Extract messages',\n description:\n 'Scan the source files, add new messages to the locale catalogs and refresh the generated types (what `verbaly extract` does). Writes catalog files unless dryRun is set. prune drops keys no longer referenced in the code, translations included.',\n inputSchema: {\n root: rootInput,\n prune: z\n .boolean()\n .optional()\n .describe('Drop keys no longer referenced (deletes their translations)'),\n dryRun: z.boolean().optional().describe('Report what would change, write nothing'),\n },\n outputSchema: {\n messages: z.number(),\n locales: z.array(z.string()),\n dryRun: z.boolean(),\n added: perLocale,\n pruned: perLocale,\n unparsed: z\n .array(z.object({ file: z.string(), message: z.string() }))\n .describe(\n 'Source files the parser could not read: their messages are not extracted, and prune drops nothing until they parse',\n ),\n collisions: z\n .array(z.object({ key: z.string(), sites: z.array(sourceSite) }))\n .describe(\n 'Keys written with more than one text: every place shows the text of the first site, so give each text its own key',\n ),\n renamed: z\n .array(z.object({ file: z.string(), line: z.number().optional(), name: z.string() }))\n .describe(\n 'Tagged templates on t under another name (const tr = useT()): never extracted, so they stay in the source language until the binding is named t',\n ),\n replaced: z\n .array(z.object({ key: z.string(), before: z.string(), code: sourceSite }))\n .describe(\n 'Source texts the code wrote over: before is what the catalog said, code is the text that ships. An edit made in the code reads like this too',\n ),\n positional: z\n .array(z.object({ params: z.array(z.string()), code: sourceSite }))\n .describe(\n 'Messages that hand a translator a nameless value like {_0}: put the value in a named variable first',\n ),\n escaped: z\n .array(z.object({ slice: z.string(), code: sourceSite }))\n .describe(\n 'Plural or format blocks inside a tagged template, which render as literal text',\n ),\n stateProblem: z\n .string()\n .optional()\n .describe(\n 'The state file could not be read or written: the catalogs were written, drafts and outdated tracking were not',\n ),\n },\n },\n guarded(async ({ root, prune, dryRun }) => {\n const cfg = await config(root);\n const result = await syncProject(cfg, { prune, dryRun });\n const rel = relativeTo(cfg.root);\n const at = (code: { file: string; line?: number; message: string }) => ({\n ...code,\n file: rel(code.file),\n });\n // an agent sees no terminal, so what the CLI prints about these has to be in the answer\n const data = {\n messages: result.registry.messages().size,\n locales: cfg.locales,\n dryRun: dryRun === true,\n added: byLocale(result.added),\n pruned: byLocale(result.pruned),\n unparsed: [] as { file: string; message: string }[],\n collisions: [] as { key: string; sites: ReturnType<typeof at>[] }[],\n renamed: [] as { file: string; line?: number; name: string }[],\n replaced: [] as { key: string; before: string; code: ReturnType<typeof at> }[],\n positional: [] as { params: string[]; code: ReturnType<typeof at> }[],\n escaped: [] as { slice: string; code: ReturnType<typeof at> }[],\n ...(result.stateProblem && { stateProblem: result.stateProblem }),\n };\n for (const finding of result.findings) {\n if (finding.kind === 'unparsed')\n data.unparsed.push({ file: rel(finding.file), message: finding.message });\n else if (finding.kind === 'collision')\n data.collisions.push({ key: finding.key, sites: finding.sites.map(at) });\n else if (finding.kind === 'renamed')\n data.renamed.push({ ...finding, file: rel(finding.file) });\n else if (finding.kind === 'replaced')\n data.replaced.push({ key: finding.key, before: finding.before, code: at(finding.site) });\n else if (finding.kind === 'positional')\n data.positional.push({ params: finding.params, code: at(finding.site) });\n else if (finding.kind === 'escaped')\n data.escaped.push({ slice: finding.slice, code: at(finding.site) });\n }\n\n const lines = [\n `${counted(data.messages, 'message')} · locales: ${cfg.locales.join(', ')}${dryRun ? ' (dry run, nothing written)' : ''}`,\n ];\n if (result.pruneBlocked) {\n lines.push(\n 'prune skipped: an unparsed file may read any key, so it waits until every file parses',\n );\n }\n for (const { locale, keys } of data.pruned) {\n lines.push(\n dryRun\n ? `${locale}: would prune ${keys.length}: ${keys.join(', ')}`\n : `${locale}: ${keys.length} pruned`,\n );\n }\n for (const { locale, keys } of data.added) {\n lines.push(`${locale}: ${dryRun ? `would add ${keys.length}` : `+${keys.length} added`}`);\n }\n for (const finding of result.findings) lines.push(formatFinding(finding, cfg.root));\n if (result.stateProblem) {\n lines.push(`${result.stateProblem}, so drafts and outdated translations were not updated`);\n }\n return reply(lines.join('\\n'), data);\n }),\n );\n\n server.registerTool(\n 'verbaly_status',\n {\n title: 'Translation coverage',\n description:\n 'Translation coverage of the Verbaly project: total messages, translated count per locale, machine translations awaiting review (drafts) and translations written for an older source text (outdated). Read-only.',\n inputSchema: { root: rootInput },\n outputSchema: {\n messages: z.number().describe('Messages the project has, source catalog plus code'),\n source: z.string().describe('Source locale'),\n locales: z.array(\n z.object({\n locale: z.string(),\n translated: z.number(),\n total: z.number(),\n drafts: z.number().describe('Machine translations awaiting human review'),\n broken: z.number().describe('Present but not rendering what the source renders'),\n outdated: z\n .number()\n .describe('Translated from an older source text: update them, or a human keeps them'),\n }),\n ),\n stateProblem: z\n .string()\n .optional()\n .describe('The state file could not be read, so drafts and outdated are counted as zero'),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root }) => {\n const cfg = await config(root);\n const registry = await extractProject(cfg);\n // the state only feeds two counts: a broken one is said, never a failed call\n const { state, problem } = readState(cfg);\n const result = status(cfg, loadCatalogs(cfg), registry, state.drafts, state.fingerprints);\n const body = formatStatusResult(result);\n return reply(problem ? `${body}\\n${problem}, so drafts and outdated are not counted` : body, {\n ...result,\n ...(problem && { stateProblem: problem }),\n });\n }),\n );\n\n server.registerTool(\n 'verbaly_missing',\n {\n title: 'Missing and broken translations',\n description:\n 'List missing translations, unknown keys and translations that exist but cannot render what the source renders (a dropped {param}, a lost rich tag, a flattened plural block), the same gate `verbaly check` runs in CI. Warnings never fail the gate and are listed too: an incomplete plural set for the locale, keys a translation carries that the source catalog does not (extra), keys written with two texts (collisions), texts the code and the source catalog disagree on (divergent, the text in the code ships) and translations written for an older source text (outdated). Optionally also lists machine translations awaiting review. Read-only.',\n inputSchema: {\n root: rootInput,\n drafts: z\n .boolean()\n .optional()\n .describe('Also list machine translations awaiting human review'),\n },\n outputSchema: {\n ok: z.boolean().describe('Whether `verbaly check` would pass (warnings never fail it)'),\n missing: z.array(\n z.object({ locale: z.string(), key: z.string(), source: z.string().optional() }),\n ),\n unknown: z.array(z.object({ key: z.string(), files: z.array(z.string()) })),\n broken: z.array(\n z.object({\n locale: z.string(),\n key: z.string(),\n severity: z.enum(['error', 'warning']),\n issue: z.string(),\n }),\n ),\n extra: z\n .array(z.object({ locale: z.string(), key: z.string(), files: z.array(z.string()) }))\n .describe(\n 'Keys only a translation has; files are where the code reads one, which the source language then shows as the key itself. Never fails the gate',\n ),\n collisions: z\n .array(z.object({ key: z.string(), sites: z.array(sourceSite) }))\n .describe('One key, several texts: every place shows the first site. Never fails the gate'),\n divergent: z\n .array(z.object({ key: z.string(), catalog: z.string(), code: sourceSite }))\n .describe(\n \"The source catalog says one text and the code another: the code's text ships. Never fails the gate\",\n ),\n outdated: perLocaleEntries.describe(\n 'Translations written for an older source text: rewrite them, or a human keeps them with verbaly review --approve. Never fails the gate',\n ),\n unreviewed: perLocale,\n stateProblem: z\n .string()\n .optional()\n .describe('The state file could not be read, so outdated translations are not listed'),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root, drafts }) => {\n const cfg = await config(root);\n const registry = await extractProject(cfg);\n const catalogs = loadCatalogs(cfg);\n // asked for drafts, the state has to be readable; otherwise it only feeds a warning\n const { state, problem } = drafts\n ? { state: loadState(cfg), problem: undefined }\n : readState(cfg);\n const result = check(cfg, catalogs, registry, state.fingerprints);\n const unreviewed = drafts ? byLocale(effectiveDrafts(state.drafts, catalogs)) : [];\n\n const lines: string[] = [];\n if (!result.ok) lines.push(formatCheckResult(result, cfg.root));\n const warnings = formatCheckWarnings(result, cfg.root);\n if (warnings) lines.push(`warnings (the gate still passes):\\n${warnings}`);\n for (const { locale, keys } of unreviewed) {\n if (keys.length) lines.push(`[${locale}] ${keys.length} unreviewed: ${keys.join(', ')}`);\n }\n if (problem) lines.push(`${problem}, so outdated translations are not listed`);\n return reply(lines.length === 0 ? 'all translations complete' : lines.join('\\n'), {\n ...relativeCheck(cfg.root, result),\n unreviewed,\n ...(problem && { stateProblem: problem }),\n });\n }),\n );\n\n server.registerTool(\n 'verbaly_translate',\n {\n title: 'Machine-translate missing entries',\n description:\n 'Fill missing translations with the configured provider (default: Claude, needs @anthropic-ai/sdk and ANTHROPIC_API_KEY). New translations are saved as drafts awaiting human review (`verbaly review`), which no tool here can approve. A batch the provider never answers is reported in failed and leaves everything else written, so a retry only asks for what is left. dryRun lists what would be translated without calling the provider.',\n inputSchema: {\n root: rootInput,\n locales: z.array(z.string()).optional().describe('Target locales (default: all)'),\n dryRun: z\n .boolean()\n .optional()\n .describe('List missing entries per locale, call no provider'),\n },\n outputSchema: {\n dryRun: z.boolean(),\n translated: perLocale.describe('Saved as drafts, a human still has to approve them'),\n kept: perLocale.describe(\n 'Written on disk by someone else while the provider worked, so left as they were',\n ),\n invalid: perLocale.describe('Rejected: params or tags were not preserved'),\n failed: z\n .array(z.object({ locale: z.string(), keys: z.array(z.string()), error: z.string() }))\n .describe('Batches the provider never answered, safe to retry'),\n pending: perLocale.describe('dryRun only: what would be translated'),\n },\n },\n guarded(async ({ root, locales, dryRun }) => {\n const cfg = await config(root);\n // a machine translation that lost its draft flag passes as reviewed: read the state first\n if (!dryRun) loadState(cfg);\n const registry = await extractProject(cfg);\n // the provider reads the text that ships, which is the text its answer has to match\n const catalogs = shippedCatalogs(cfg, loadCatalogs(cfg), registry, { newKeys: false });\n const provider = await resolveProvider(cfg);\n const result = await translateCatalogs(cfg, catalogs, provider, {\n locales,\n batchSize: cfg.translate.batchSize,\n concurrency: cfg.translate.concurrency,\n retries: cfg.translate.retries,\n dryRun,\n origins: dryRun ? undefined : await collectOrigins(cfg, registry),\n });\n\n if (dryRun) {\n const pending = byLocale(result.pending);\n const lines = pending.map(\n ({ locale, keys }) => `${locale}: ${keys.length} missing: ${keys.join(', ')}`,\n );\n const data = { dryRun: true, translated: [], kept: [], invalid: [], failed: [], pending };\n return reply(lines.length === 0 ? 'nothing to translate' : lines.join('\\n'), data);\n }\n\n // the file as it is now: what someone wrote while the provider worked is not overwritten\n const written: Record<string, string[]> = {};\n const kept: Record<string, string[]> = {};\n const writes: TranslationWrite[] = [];\n for (const [locale, keys] of Object.entries(result.translated)) {\n const catalog = catalogs[locale] ?? {};\n const landed = mergeTranslations(cfg, locale, catalog, keys);\n writes.push({\n locale,\n draft: true,\n entries: landed.map((key) => ({ key, text: catalog[key]! })),\n });\n if (landed.length > 0) written[locale] = landed;\n const left = keys.filter((key) => !landed.includes(key));\n if (left.length > 0) kept[locale] = left;\n }\n if (writes.length > 0) recordTranslations(cfg, catalogs[cfg.sourceLocale] ?? {}, writes);\n\n const data = {\n dryRun: false,\n translated: byLocale(written),\n kept: byLocale(kept),\n invalid: byLocale(result.invalid),\n failed: result.failed,\n pending: [],\n };\n const lines: string[] = [];\n for (const { locale, keys } of data.translated) {\n lines.push(`${locale}: +${keys.length} translated (draft)`);\n }\n for (const { locale, keys } of data.kept) {\n lines.push(`${locale}: ${keys.length} kept as written while this ran: ${keys.join(', ')}`);\n }\n for (const { locale, keys } of data.invalid) {\n lines.push(\n `${locale}: ${keys.length} rejected (params/tags not preserved): ${keys.join(', ')}`,\n );\n }\n lines.push(...formatTranslateFailures(result.failed));\n if (lines.length === 0) return reply('nothing to translate', data);\n if (data.translated.length > 0) {\n lines.push('drafts await human review: verbaly review (--approve accepts them)');\n }\n return reply(lines.join('\\n'), data);\n }),\n );\n server.registerTool(\n 'verbaly_write_drafts',\n {\n title: 'Save translations an agent wrote',\n description:\n \"Save translations you wrote yourself, so neither a catalog nor the state file is ever edited by hand. Each one is checked the way `verbaly translate` checks a provider (params, rich tags and plural cases must survive), written only for keys the source catalog has, and marked as a draft awaiting human review. Existing translations are kept unless overwrite is set, which is how an outdated one gets rewritten. Approving is not a tool here: a human runs `verbaly review --approve`.\",\n inputSchema: {\n root: rootInput,\n locale: z.string().describe(\"Target locale, one of the project's non-source locales\"),\n entries: z\n .array(z.object({ key: z.string(), text: z.string() }))\n .describe('The translations, by catalog key'),\n overwrite: z\n .boolean()\n .optional()\n .describe('Replace translations that already exist, for example outdated ones'),\n },\n outputSchema: {\n written: z.array(z.string()).describe('Saved as drafts, a human still has to approve them'),\n kept: z\n .array(z.string())\n .describe('Already translated, left as they were (overwrite replaces them)'),\n invalid: z\n .array(z.string())\n .describe('Rejected: empty, or the params, tags or plural cases were not preserved'),\n unknown: z.array(z.string()).describe('Not in the source catalog, so nothing was written'),\n },\n },\n guarded(async ({ root, locale, entries, overwrite }) => {\n const cfg = await config(root);\n // checked against the text that ships, the one verbaly_missing reads it against\n const registry = await extractProject(cfg);\n const result = writeDrafts(cfg, locale, entries, { overwrite, registry });\n const lines: string[] = [];\n if (result.written.length > 0) {\n lines.push(`${locale}: +${result.written.length} saved as drafts, awaiting human review`);\n }\n if (result.kept.length > 0) {\n lines.push(`${locale}: ${result.kept.length} already translated, kept: ${result.kept.join(', ')}`);\n }\n if (result.invalid.length > 0) {\n lines.push(\n `${locale}: ${result.invalid.length} rejected (params/tags not preserved): ${result.invalid.join(', ')}`,\n );\n }\n if (result.unknown.length > 0) {\n lines.push(\n `${locale}: ${counted(result.unknown.length, 'unknown key')} not in the source catalog: ${result.unknown.join(', ')}`,\n );\n }\n return reply(lines.length > 0 ? lines.join('\\n') : 'nothing to save', { ...result });\n }),\n );\n\n server.registerTool(\n 'verbaly_drafts',\n {\n title: 'Machine translations awaiting review',\n description:\n 'Every machine translation still waiting for a human, each with the source text and what the provider wrote, so a person can read both and decide. Read-only. Approving is deliberately not a tool here and never will be: a machine translation is unreviewed by definition, so accepting one is `verbaly review --approve`, run by a human.',\n inputSchema: {\n root: rootInput,\n locales: z.array(z.string()).optional().describe('Target locales (default: all)'),\n },\n outputSchema: {\n total: z.number(),\n entries: z.array(\n z.object({\n locale: z.string(),\n key: z.string(),\n source: z.string().describe('What the message says in the source locale'),\n translated: z.string().describe('What the provider wrote, still unreviewed'),\n }),\n ),\n },\n annotations: { readOnlyHint: true },\n },\n guarded(async ({ root, locales }) => {\n const cfg = await config(root);\n const catalogs = loadCatalogs(cfg);\n // the text that ships is the one a draft has to say again\n const shipped = shippedCatalogs(cfg, catalogs, await extractProject(cfg));\n const source = shipped[cfg.sourceLocale] ?? {};\n const pending = effectiveDrafts(loadState(cfg).drafts, catalogs);\n const wanted = locales ?? cfg.locales;\n const entries = Object.entries(pending)\n .filter(([locale]) => wanted.includes(locale))\n .flatMap(([locale, keys]) =>\n keys.map((key) => ({\n locale,\n key,\n source: source[key] ?? '',\n translated: catalogs[locale]?.[key] ?? '',\n })),\n );\n const body = entries.length\n ? entries\n .map((e) => `[${e.locale}] ${e.key}\n source: ${e.source}\n draft: ${e.translated}`)\n .join('\\n')\n : 'nothing awaiting review';\n return reply(body, { total: entries.length, entries });\n }),\n );\n\n\n return server;\n}\n"],"mappings":";;;;;;AAqCA,MAAM,EAAE,YAAY,cAAc,YAAY,GAAG,CAAC,CAAC,iBAAiB;AAOpE,MAAM,SAAS,MAAc,UAAmD;CAC9E,SAAS,CAAC;EAAE,MAAM;EAAQ,MAAM;CAAK,CAAC;CACtC,mBAAmB;AACrB;AAEA,MAAM,YAAY,EACf,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,gFAAgF;AAE5F,MAAM,YAAY,EAAE,MAAM,EAAE,OAAO;CAAE,QAAQ,EAAE,OAAO;CAAG,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;AAAE,CAAC,CAAC;AAErF,MAAM,mBAAmB,EAAE,MAAM,EAAE,OAAO;CAAE,QAAQ,EAAE,OAAO;CAAG,KAAK,EAAE,OAAO;AAAE,CAAC,CAAC;AAGlF,MAAM,YAA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AAQ;EACzC,EAAE,CACJ;EACF,MAAM,OAAO,QAAQ,SACjB,QACG,KAAK,MAAM,IAAI,EAAE,OAAO,IAAI,EAAE,IAAI;YACnC,EAAE,OAAO;YACT,EAAE,YAAY,CAAC,CACd,KAAK,IAAI,IACZ;EACJ,OAAO,MAAM,MAAM;GAAE,OAAO,QAAQ;GAAQ;EAAQ,CAAC;CACvD,CAAC,CACH;CAGA,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbaly/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.69.0",
|
|
4
4
|
"description": "MCP server for Verbaly: diagnosis, onboarding, extraction, coverage and machine translation as tools for coding agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
47
|
-
"@verbaly/compiler": "^0.
|
|
47
|
+
"@verbaly/compiler": "^0.69.0",
|
|
48
48
|
"zod": "^4.6.5"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|