@verbaly/mcp 0.81.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-CZVD3Se-.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-CZVD3Se-.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
  }));
@@ -536,23 +485,11 @@ function registerWrap(server, ctx) {
536
485
  }, ctx.guarded(async ({ root, write }) => {
537
486
  const cfg = await ctx.config(root);
538
487
  const result = await wrapProject(cfg, { write });
539
- const blocked = new Set(result.blocked.map((entry) => entry.file));
540
- const done = result.changed.filter((file) => !blocked.has(file));
541
- const texts = result.wrapped.filter((entry) => !blocked.has(entry.file));
542
- 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`];
543
- for (const entry of write ? texts : result.wrapped) {
544
- const attr = entry.kind === "attribute" ? `${entry.attribute} -> ` : "";
545
- lines.push(` ${entry.file}:${entry.line} ${attr}"${entry.text}"`);
546
- }
547
- if (result.skipped.length > 0) {
548
- lines.push(" needs a human:");
549
- for (const entry of result.skipped) lines.push(` ${entry.file}:${entry.line} "${entry.text}" (${entry.reason})`);
550
- }
551
- if (result.blocked.length > 0) {
552
- lines.push(` nothing written in ${counted(result.blocked.length, "file")} with no t in scope:`);
553
- for (const entry of result.blocked) lines.push(` ${entry.file} ${counted(entry.texts, "text")}, ${entry.binding}`);
554
- lines.push(" next: bind t there, run verbaly_wrap with write again, then verbaly_extract");
555
- } 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");
556
493
  return reply(lines.join("\n"), {
557
494
  ...result,
558
495
  write: write === true
@@ -577,13 +514,14 @@ function registerWriteDrafts(server, ctx) {
577
514
  written: z.array(z.string()).describe("Saved as drafts, a human still has to approve them"),
578
515
  kept: z.array(z.string()).describe("Already translated, left as they were (overwrite replaces them)"),
579
516
  invalid: z.array(z.string()).describe("Rejected: empty, or the params, tags or plural cases were not preserved"),
580
- 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
581
519
  },
582
520
  annotations: writes(true)
583
521
  }, ctx.guarded(async ({ root, locale, entries, overwrite }) => {
584
522
  const cfg = await ctx.config(root);
585
523
  const registry = await extractProject(cfg);
586
- const result = writeDrafts(cfg, locale, entries, {
524
+ const { lock, ...result } = writeDrafts(cfg, locale, entries, {
587
525
  overwrite,
588
526
  registry
589
527
  });
@@ -592,7 +530,12 @@ function registerWriteDrafts(server, ctx) {
592
530
  if (result.kept.length > 0) lines.push(`${locale}: ${result.kept.length} already translated, kept: ${result.kept.join(", ")}`);
593
531
  if (result.invalid.length > 0) lines.push(`${locale}: ${result.invalid.length} rejected (params/tags not preserved): ${result.invalid.join(", ")}`);
594
532
  if (result.unknown.length > 0) lines.push(`${locale}: ${counted(result.unknown.length, "unknown key")} not in the source catalog: ${result.unknown.join(", ")}`);
595
- 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);
596
539
  }));
597
540
  }
598
541
  // src/server.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbaly/mcp",
3
- "version": "0.81.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.81.0",
52
+ "@verbaly/compiler": "^0.82.0",
53
53
  "zod": "^4.6.7"
54
54
  },
55
55
  "devDependencies": {