@verbaly/mcp 0.80.0 → 0.82.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 CHANGED
@@ -61,7 +61,7 @@ Reading the project is an address, not a call, so these cost no tool invocation:
61
61
 
62
62
  **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.
63
63
 
64
- `verbaly_translate` never loses work it already paid for: a batch the provider does not answer is retried, and if it still fails it comes back in `failed` with its keys while everything else is written. Retrying asks only for what is left. It never loses a person's work either: a message someone wrote on disk while the provider was working is left as written and comes back in `kept`.
64
+ `verbaly_translate` never loses work it already paid for: a batch the provider does not answer is retried, and if it still fails it comes back in `failed` with its keys while everything else is written. Retrying asks only for what is left. It never loses a person's work either: a message someone wrote on disk while the provider was working is left as written and comes back in `kept`. When a save brings `verbaly.lock` into being, `verbaly_translate` and `verbaly_write_drafts` say so in `lock`, as `verbaly_extract` does, so the agent can tell its user to commit the file.
65
65
 
66
66
  ## 📚 Docs
67
67
 
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as createVerbalyMcp } from "./server-DLz42N1C.js";
2
+ import { t as createVerbalyMcp } from "./server-DuHEfzpG.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { parseArgs } from "node:util";
5
5
  // src/cli.ts
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { t as createVerbalyMcp } from "./server-DLz42N1C.js";
1
+ export { t as createVerbalyMcp } from "./server-DuHEfzpG.js";
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import { check, collectOrigins, counted, doctor, effectiveDrafts, extractProject, formatCheckResult, formatCheckWarnings, formatDoctorEntry, formatDoctorHealth, formatFinding, formatStatusResult, formatTranslateFailures, init, loadCatalogs, loadConfig, loadState, mergeTranslations, readState, recordTranslations, resolveProvider, shippedCatalogs, status, syncProject, translateCatalogs, wrapProject, writeDrafts } from "@verbaly/compiler";
3
+ import { check, counted, doctor, effectiveDrafts, extractProject, formatCheckResult, formatCheckWarnings, formatDoctorEntry, formatDoctorHealth, formatFinding, formatStatusResult, formatTranslateFailures, formatWrapResult, init, loadCatalogs, loadConfig, loadState, readState, relativeCheck, shippedCatalogs, status, syncProject, translateProject, wrapProject, writeDrafts } from "@verbaly/compiler";
4
4
  import { z } from "zod";
5
5
  import { relative } from "node:path";
6
6
  // src/tools/shared.ts
@@ -44,45 +44,28 @@ const sourceSite = z.object({
44
44
  function relativeTo(root) {
45
45
  return (file) => relative(root, file).replaceAll("\\", "/");
46
46
  }
47
+ const lockOutput = z.object({
48
+ file: z.string(),
49
+ from: z.string().optional(),
50
+ merged: z.boolean().optional()
51
+ }).optional().describe("This run created verbaly.lock, moved an older state file (from) into it, or rewrote it whole after a merge conflict (merged): it belongs in git with the catalogs, so tell the user to commit it");
52
+ function lockData(news, rel) {
53
+ if (!news) return {};
54
+ const from = news.from && { from: rel(news.from) };
55
+ return { lock: {
56
+ file: rel(news.file),
57
+ ...from,
58
+ ...news.merged && { merged: true }
59
+ } };
60
+ }
47
61
  function lockOf(findings, rel) {
48
- for (const finding of findings) {
49
- if (finding.kind !== "lock") continue;
50
- const from = finding.from && { from: rel(finding.from) };
51
- return { lock: {
52
- file: rel(finding.file),
53
- ...from,
54
- ...finding.merged && { merged: true }
55
- } };
56
- }
57
- return {};
62
+ return lockData(findings.find((finding) => finding.kind === "lock"), rel);
58
63
  }
59
- function relativeCheck(root, result) {
60
- const rel = relativeTo(root);
61
- return {
62
- ...result,
63
- unknown: result.unknown.map((entry) => ({
64
- ...entry,
65
- files: entry.files.map(rel)
66
- })),
67
- extra: result.extra.map((entry) => ({
68
- ...entry,
69
- files: entry.files.map(rel)
70
- })),
71
- collisions: result.collisions.map((entry) => ({
72
- ...entry,
73
- sites: entry.sites.map((at) => ({
74
- ...at,
75
- file: rel(at.file)
76
- }))
77
- })),
78
- divergent: result.divergent.map((entry) => ({
79
- ...entry,
80
- code: {
81
- ...entry.code,
82
- file: rel(entry.code.file)
83
- }
84
- }))
85
- };
64
+ function lockLine(news, root) {
65
+ return news ? [formatFinding({
66
+ kind: "lock",
67
+ ...news
68
+ }, root)] : [];
86
69
  }
87
70
  // src/tools/doctor.ts
88
71
  function registerDoctor(server, ctx) {
@@ -195,11 +178,7 @@ function registerExtract(server, ctx) {
195
178
  code: sourceSite
196
179
  })).describe("Plural or format blocks inside a tagged template, which render as literal text"),
197
180
  stateProblem: z.string().optional().describe("The state file could not be read or written: the catalogs were written, drafts and outdated tracking were not"),
198
- lock: z.object({
199
- file: z.string(),
200
- from: z.string().optional(),
201
- merged: z.boolean().optional()
202
- }).optional().describe("This run created verbaly.lock, moved an older state file (from) into it, or rewrote it whole after a merge conflict (merged): it belongs in git with the catalogs, so tell the user to commit it")
181
+ lock: lockOutput
203
182
  },
204
183
  annotations: writes(true)
205
184
  }, ctx.guarded(async ({ root, prune, dryRun }) => {
@@ -426,22 +405,15 @@ function registerTranslate(server, ctx) {
426
405
  keys: z.array(z.string()),
427
406
  error: z.string()
428
407
  })).describe("Batches the provider never answered, safe to retry"),
429
- pending: perLocale.describe("dryRun only: what would be translated")
408
+ pending: perLocale.describe("dryRun only: what would be translated"),
409
+ lock: lockOutput
430
410
  },
431
411
  annotations: writes(false, true)
432
412
  }, ctx.guarded(async ({ root, locales, dryRun }) => {
433
413
  const cfg = await ctx.config(root);
434
- if (!dryRun) loadState(cfg);
435
- const registry = await extractProject(cfg);
436
- const catalogs = shippedCatalogs(cfg, loadCatalogs(cfg), registry, { newKeys: false });
437
- const provider = await resolveProvider(cfg);
438
- const result = await translateCatalogs(cfg, catalogs, provider, {
414
+ const result = await translateProject(cfg, {
439
415
  locales,
440
- batchSize: cfg.translate.batchSize,
441
- concurrency: cfg.translate.concurrency,
442
- retries: cfg.translate.retries,
443
- dryRun,
444
- origins: dryRun ? void 0 : await collectOrigins(cfg, registry)
416
+ dryRun
445
417
  });
446
418
  if (dryRun) {
447
419
  const pending = byLocale(result.pending);
@@ -456,38 +428,14 @@ function registerTranslate(server, ctx) {
456
428
  };
457
429
  return reply(lines.length === 0 ? "nothing to translate" : lines.join("\n"), data);
458
430
  }
459
- const written = [];
460
- const kept = [];
461
- const writes = [];
462
- for (const [locale, keys] of Object.entries(result.translated)) {
463
- const catalog = catalogs[locale] ?? {};
464
- const landed = mergeTranslations(cfg, locale, catalog, keys);
465
- writes.push({
466
- locale,
467
- draft: true,
468
- entries: landed.map((key) => ({
469
- key,
470
- text: catalog[key]
471
- }))
472
- });
473
- if (landed.length > 0) written.push({
474
- locale,
475
- keys: landed
476
- });
477
- const left = keys.filter((key) => !landed.includes(key));
478
- if (left.length > 0) kept.push({
479
- locale,
480
- keys: left
481
- });
482
- }
483
- if (writes.length > 0) recordTranslations(cfg, catalogs[cfg.sourceLocale] ?? {}, writes);
484
431
  const data = {
485
432
  dryRun: false,
486
- translated: written,
487
- kept,
433
+ translated: byLocale(result.written),
434
+ kept: byLocale(result.kept),
488
435
  invalid: byLocale(result.invalid),
489
436
  failed: result.failed,
490
- pending: []
437
+ pending: [],
438
+ ...lockData(result.lock, relativeTo(cfg.root))
491
439
  };
492
440
  const lines = [];
493
441
  for (const { locale, keys } of data.translated) lines.push(`${locale}: +${keys.length} translated (draft)`);
@@ -495,6 +443,7 @@ function registerTranslate(server, ctx) {
495
443
  for (const { locale, keys } of data.invalid) lines.push(`${locale}: ${keys.length} rejected (params/tags not preserved): ${keys.join(", ")}`);
496
444
  lines.push(...formatTranslateFailures(result.failed));
497
445
  if (lines.length === 0) return reply("nothing to translate", data);
446
+ lines.push(...lockLine(result.lock, cfg.root));
498
447
  if (data.translated.length > 0) lines.push("drafts await human review: verbaly review (--approve accepts them)");
499
448
  return reply(lines.join("\n"), data);
500
449
  }));
@@ -503,7 +452,7 @@ function registerTranslate(server, ctx) {
503
452
  function registerWrap(server, ctx) {
504
453
  server.registerTool("verbaly_wrap", {
505
454
  title: "Wrap hardcoded JSX text",
506
- description: "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, and verbaly_extract then adds the wrapped texts to the catalogs. It only reports unless write is set, and text already wrapped is skipped, so running it again is safe. Text it cannot wrap safely (a sentence split across markup, an expression rendering JSX) is listed as needing a human. A file that does not bind t is never written, because the rewrite would not compile. It comes back in blocked, with whether it is a client component, so you can add the binding and run again.",
455
+ description: "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, and verbaly_extract then adds the wrapped texts to the catalogs. It only reports unless write is set, and text already wrapped is skipped, so running it again is safe. Text it cannot wrap safely (a sentence split across markup, an expression rendering JSX) is listed as needing a human. A file that does not bind t is never written, because the rewrite would not compile. It comes back in blocked, with the binding this project needs there, so you can add it and run again.",
507
456
  inputSchema: {
508
457
  root: rootInput,
509
458
  write: z.boolean().optional().describe("Apply the rewrites instead of only reporting")
@@ -528,33 +477,19 @@ function registerWrap(server, ctx) {
528
477
  blocked: z.array(z.object({
529
478
  file: z.string(),
530
479
  texts: z.number(),
531
- client: z.boolean()
480
+ client: z.boolean(),
481
+ binding: z.string().describe("What to add so t is in scope, for this framework")
532
482
  }))
533
483
  },
534
484
  annotations: writes(true)
535
485
  }, ctx.guarded(async ({ root, write }) => {
536
486
  const cfg = await ctx.config(root);
537
487
  const result = await wrapProject(cfg, { write });
538
- const blocked = new Set(result.blocked.map((entry) => entry.file));
539
- const done = result.changed.filter((file) => !blocked.has(file));
540
- const texts = result.wrapped.filter((entry) => !blocked.has(entry.file));
541
- const lines = [`${write ? "wrapped" : "would wrap"} ${write ? `${counted(texts.length, "text")} in ${counted(done.length, "file")}` : `${counted(result.wrapped.length, "text")} in ${counted(result.changed.length, "file")}`} of ${counted(result.files, "file")} scanned`];
542
- for (const entry of write ? texts : result.wrapped) {
543
- const attr = entry.kind === "attribute" ? `${entry.attribute} -> ` : "";
544
- lines.push(` ${entry.file}:${entry.line} ${attr}"${entry.text}"`);
545
- }
546
- if (result.skipped.length > 0) {
547
- lines.push(" needs a human:");
548
- for (const entry of result.skipped) lines.push(` ${entry.file}:${entry.line} "${entry.text}" (${entry.reason})`);
549
- }
550
- if (result.blocked.length > 0) {
551
- lines.push(` nothing written in ${counted(result.blocked.length, "file")} with no t in scope:`);
552
- for (const entry of result.blocked) {
553
- const how = entry.client ? "\"use client\", so const t = useT()" : "no \"use client\"";
554
- lines.push(` ${entry.file} ${counted(entry.texts, "text")}, ${how}`);
555
- }
556
- lines.push(" next: bind t there, run verbaly_wrap with write again, then verbaly_extract");
557
- } else if (write && done.length > 0) lines.push(" next: run verbaly_extract");
488
+ const report = formatWrapResult(result, write === true);
489
+ const scanned = `, of ${counted(result.files, "file")} scanned`;
490
+ const lines = [`${report.counts}${scanned}`, ...report.lines];
491
+ if (result.blocked.length > 0) lines.push(" next: bind t there, run verbaly_wrap with write again, then verbaly_extract");
492
+ else if (write && report.files > 0) lines.push(" next: run verbaly_extract");
558
493
  return reply(lines.join("\n"), {
559
494
  ...result,
560
495
  write: write === true
@@ -579,13 +514,14 @@ function registerWriteDrafts(server, ctx) {
579
514
  written: z.array(z.string()).describe("Saved as drafts, a human still has to approve them"),
580
515
  kept: z.array(z.string()).describe("Already translated, left as they were (overwrite replaces them)"),
581
516
  invalid: z.array(z.string()).describe("Rejected: empty, or the params, tags or plural cases were not preserved"),
582
- unknown: z.array(z.string()).describe("Not in the source catalog, so nothing was written")
517
+ unknown: z.array(z.string()).describe("Not in the source catalog, so nothing was written"),
518
+ lock: lockOutput
583
519
  },
584
520
  annotations: writes(true)
585
521
  }, ctx.guarded(async ({ root, locale, entries, overwrite }) => {
586
522
  const cfg = await ctx.config(root);
587
523
  const registry = await extractProject(cfg);
588
- const result = writeDrafts(cfg, locale, entries, {
524
+ const { lock, ...result } = writeDrafts(cfg, locale, entries, {
589
525
  overwrite,
590
526
  registry
591
527
  });
@@ -594,7 +530,12 @@ function registerWriteDrafts(server, ctx) {
594
530
  if (result.kept.length > 0) lines.push(`${locale}: ${result.kept.length} already translated, kept: ${result.kept.join(", ")}`);
595
531
  if (result.invalid.length > 0) lines.push(`${locale}: ${result.invalid.length} rejected (params/tags not preserved): ${result.invalid.join(", ")}`);
596
532
  if (result.unknown.length > 0) lines.push(`${locale}: ${counted(result.unknown.length, "unknown key")} not in the source catalog: ${result.unknown.join(", ")}`);
597
- return reply(lines.length > 0 ? lines.join("\n") : "nothing to save", { ...result });
533
+ lines.push(...lockLine(lock, cfg.root));
534
+ const data = {
535
+ ...result,
536
+ ...lockData(lock, relativeTo(cfg.root))
537
+ };
538
+ return reply(lines.length > 0 ? lines.join("\n") : "nothing to save", data);
598
539
  }));
599
540
  }
600
541
  // src/server.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbaly/mcp",
3
- "version": "0.80.0",
3
+ "version": "0.82.0",
4
4
  "description": "MCP server for Verbaly: diagnosis, onboarding, extraction, coverage and machine translation as tools for coding agents.",
5
5
  "mcpName": "io.github.AronSoto/verbaly",
6
6
  "keywords": [
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@modelcontextprotocol/sdk": "^1.32.2",
52
- "@verbaly/compiler": "^0.80.0",
52
+ "@verbaly/compiler": "^0.82.0",
53
53
  "zod": "^4.6.7"
54
54
  },
55
55
  "devDependencies": {