@sonenta/cli 0.9.0 → 0.10.1
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 +23 -4
- package/dist/index.js +216 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,14 @@ Two files are involved:
|
|
|
33
33
|
Contains the host + project_uuid + version_slug. Any command resolves
|
|
34
34
|
it by walking up from the current directory.
|
|
35
35
|
|
|
36
|
+
`sonenta init` also writes an idempotent, marker-delimited **Sonenta managed
|
|
37
|
+
block** into `CLAUDE.md` and `AGENTS.md` at the repo root, so any coding agent
|
|
38
|
+
that reads those files knows the project id, source language, namespaces, CDN
|
|
39
|
+
host, how to edit/publish translations, and how to add the `@sonenta/mcp` MCP
|
|
40
|
+
server. Re-running `sonenta init --force` refreshes the block in place (your own
|
|
41
|
+
content outside the markers is never touched); when you are logged in it is
|
|
42
|
+
populated live from `GET /v1/me` + project info. Pass `--no-repo-doc` to skip it.
|
|
43
|
+
|
|
36
44
|
- **`~/.sonenta/credentials`** — per-user, never committed.
|
|
37
45
|
JSON file with mode `0600` keyed by host so the same user can hold
|
|
38
46
|
credentials for multiple Sonenta deployments simultaneously
|
|
@@ -61,7 +69,7 @@ scope (see [Auth](#auth)).
|
|
|
61
69
|
|--------------------|-------------------------------------------------------------------------|
|
|
62
70
|
| `login` / `logout` | Store / remove an API key for a host |
|
|
63
71
|
| `whoami` | Show the active host + masked key |
|
|
64
|
-
| `init` | Scaffold `sonenta.config.json`
|
|
72
|
+
| `init` | Scaffold `sonenta.config.json` + write a managed Sonenta block into `CLAUDE.md` / `AGENTS.md` |
|
|
65
73
|
| `projects list` | List projects the key can reach |
|
|
66
74
|
| `keys list` | List keys (`namespace_slug/key_name`) |
|
|
67
75
|
| `import <files…>` | One-shot import of i18next JSON (nested or flat) — creates keys + upserts translations |
|
|
@@ -82,9 +90,10 @@ summary.
|
|
|
82
90
|
|
|
83
91
|
`agents add` drops a ready-made Claude agent into the project's
|
|
84
92
|
`.claude/agents/` directory — usable interactively in Claude Code or headless in
|
|
85
|
-
CI.
|
|
86
|
-
|
|
87
|
-
review);
|
|
93
|
+
CI. The bundled agents are **local-first** and CRUD-based: they do the work
|
|
94
|
+
themselves and write it back via plain CRUD tools (**0 Sonenta AI credits**;
|
|
95
|
+
changes land as drafts or soft/restorable for review); any server-side AI is an
|
|
96
|
+
explicit, estimated, opt-in fallback.
|
|
88
97
|
|
|
89
98
|
- **`sonenta-a11y`** — accessibility auditor. Drives the Sonenta a11y MCP tools
|
|
90
99
|
(`a11y_report`, `list_a11y_gaps`, `set_a11y_variant`, plus the
|
|
@@ -98,6 +107,15 @@ review); the server-side AI tools are an explicit, estimated, opt-in fallback.
|
|
|
98
107
|
untranslated itself honoring the glossary + project context
|
|
99
108
|
(`list_untranslated_keys` → `propose_translations_bulk`), and publishes
|
|
100
109
|
(`publish_cdn`).
|
|
110
|
+
- **`sonenta-source-health`** — duplicate-source repairer. Finds keys that share
|
|
111
|
+
the same source string and fixes them, **strictly step by step and only on your
|
|
112
|
+
acceptance**. When the Sonenta dashboard has prepared a merge plan (surfaced via
|
|
113
|
+
`list_source_duplicates` → `merge_plan`), it applies it verbatim: repoints
|
|
114
|
+
`t('redundant')` → `t('canonical')` in your code and trashes the redundant keys
|
|
115
|
+
(`delete_keys_bulk`, **value-safe & restorable** — never edits a source value),
|
|
116
|
+
then per `survivor_outcome` marks the residue `allowed` (`set_duplicate_status`)
|
|
117
|
+
or differentiates the survivors (`update_key`). With no plan it falls back to
|
|
118
|
+
its own consolidate / disambiguate / allow judgment.
|
|
101
119
|
|
|
102
120
|
```bash
|
|
103
121
|
# see what's available (and what's already installed)
|
|
@@ -106,6 +124,7 @@ sonenta agents list
|
|
|
106
124
|
# install an agent into .claude/agents/
|
|
107
125
|
sonenta agents add sonenta-a11y
|
|
108
126
|
sonenta agents add sonenta-i18n
|
|
127
|
+
sonenta agents add sonenta-source-health
|
|
109
128
|
```
|
|
110
129
|
|
|
111
130
|
The agents reach these tools through the
|
package/dist/index.js
CHANGED
|
@@ -383,7 +383,7 @@ var AGENTS = {
|
|
|
383
383
|
},
|
|
384
384
|
"sonenta-source-health": {
|
|
385
385
|
name: "sonenta-source-health",
|
|
386
|
-
summary: "
|
|
386
|
+
summary: "Duplicate-source repairer. Applies the merge plans prepared in the Sonenta dashboard \u2014 repoints t() usages onto the canonical key and trashes the redundant ones (value-safe soft-delete, never edits a source value), then differentiates or allows whatever still shares text. Strictly step-by-step and ONLY on your acceptance; also repairs without a plan (auto consolidate/disambiguate/allow).",
|
|
387
387
|
content: SONENTA_SOURCE_HEALTH
|
|
388
388
|
}
|
|
389
389
|
};
|
|
@@ -595,7 +595,20 @@ async function fetchMe(host, apiKey) {
|
|
|
595
595
|
const text = await res.text().catch(() => "");
|
|
596
596
|
throw new AuthError(`Unexpected ${res.status} from /v1/me: ${text.slice(0, 200)}`);
|
|
597
597
|
}
|
|
598
|
-
|
|
598
|
+
const raw = await res.json();
|
|
599
|
+
const id = raw.identity ?? {};
|
|
600
|
+
const pick = (key) => raw[key] ?? id[key];
|
|
601
|
+
return {
|
|
602
|
+
valid: raw.valid ?? true,
|
|
603
|
+
account_active: pick("account_active") ?? true,
|
|
604
|
+
org_uuid: pick("org_uuid"),
|
|
605
|
+
org_slug: pick("org_slug"),
|
|
606
|
+
org_name: pick("org_name"),
|
|
607
|
+
plan: pick("plan"),
|
|
608
|
+
email: pick("email") ?? id.user_email,
|
|
609
|
+
scopes: pick("scopes"),
|
|
610
|
+
capabilities: raw.capabilities
|
|
611
|
+
};
|
|
599
612
|
}
|
|
600
613
|
function assertActive(me) {
|
|
601
614
|
if (!me.valid) {
|
|
@@ -627,7 +640,7 @@ var agentsCommand = new Command("agents").description("Install bundled Claude ag
|
|
|
627
640
|
for (const a of agents) {
|
|
628
641
|
const installed = await isInstalled(a.name, baseDir);
|
|
629
642
|
const mark = installed ? "\u2713 installed" : " not installed";
|
|
630
|
-
console.log(` ${a.name.padEnd(
|
|
643
|
+
console.log(` ${a.name.padEnd(22)} ${mark}`);
|
|
631
644
|
console.log(` ${a.summary}`);
|
|
632
645
|
}
|
|
633
646
|
console.log(`
|
|
@@ -882,11 +895,178 @@ var importCommand = new Command3("import").description(
|
|
|
882
895
|
|
|
883
896
|
// src/commands/init.ts
|
|
884
897
|
import { existsSync } from "fs";
|
|
885
|
-
import { resolve as
|
|
898
|
+
import { resolve as resolve4 } from "path";
|
|
886
899
|
import { Command as Command4 } from "commander";
|
|
887
|
-
|
|
900
|
+
|
|
901
|
+
// src/repodoc.ts
|
|
902
|
+
import { promises as fs6 } from "fs";
|
|
903
|
+
import { resolve as resolve3 } from "path";
|
|
904
|
+
var DOC_API_HOST = "https://api.sonenta.com";
|
|
905
|
+
var DOC_CDN_HOST = "https://cdn.sonenta.com";
|
|
906
|
+
var REPO_DOC_FILES = ["CLAUDE.md", "AGENTS.md"];
|
|
907
|
+
var BLOCK_BEGIN = "<!-- SONENTA:BEGIN \u2014 managed by `sonenta init`; edits between these markers are overwritten -->";
|
|
908
|
+
var BLOCK_END = "<!-- SONENTA:END -->";
|
|
909
|
+
function list(values, fallback) {
|
|
910
|
+
return values && values.length ? values.join(", ") : fallback;
|
|
911
|
+
}
|
|
912
|
+
function renderManagedBlock(d) {
|
|
913
|
+
const project = d.projectUuid ? `\`${d.projectUuid}\`` : "_(not bound \u2014 run `sonenta init --project <uuid>`)_";
|
|
914
|
+
const version = d.versionSlug || "main";
|
|
915
|
+
const accountBits = [];
|
|
916
|
+
if (d.orgName) accountBits.push(`org **${d.orgName}**`);
|
|
917
|
+
if (d.plan) accountBits.push(`plan \`${d.plan}\``);
|
|
918
|
+
if (typeof d.accountActive === "boolean") {
|
|
919
|
+
accountBits.push(d.accountActive ? "account active" : "account INACTIVE");
|
|
920
|
+
}
|
|
921
|
+
const accountLine = accountBits.length ? accountBits.join(" \xB7 ") : "_(run `sonenta login`, then re-run `sonenta init --force` to populate from `GET /v1/me`)_";
|
|
922
|
+
const capabilityLines = [];
|
|
923
|
+
if (d.capabilities && d.capabilities.length) {
|
|
924
|
+
capabilityLines.push("", "**This API key can** (live from `GET /v1/me`):");
|
|
925
|
+
for (const c of d.capabilities) {
|
|
926
|
+
const mark = c.allowed ? "\u2705" : "\u{1F6AB}";
|
|
927
|
+
const extra = [c.requires ? `requires \`${c.requires}\`` : "", c.note ?? ""].filter(Boolean).join(" \u2014 ");
|
|
928
|
+
capabilityLines.push(`- ${mark} ${c.action}${extra ? ` _(${extra})_` : ""}`);
|
|
929
|
+
}
|
|
930
|
+
} else if (d.scopes && d.scopes.length) {
|
|
931
|
+
capabilityLines.push("", `**Key scopes** (\`GET /v1/me\`): \`${d.scopes.join(" ")}\``);
|
|
932
|
+
}
|
|
933
|
+
const liveHint = d.sourceLanguage || d.namespaces && d.namespaces.length ? "" : "\n> Source language and namespaces are populated live from the API once you have run `sonenta login` and bound a project. Re-run `sonenta init` to refresh this block.\n";
|
|
934
|
+
const lines = [
|
|
935
|
+
BLOCK_BEGIN,
|
|
936
|
+
"## Sonenta translations",
|
|
937
|
+
"",
|
|
938
|
+
"This project's UI strings are managed in [Sonenta](https://sonenta.com) \u2014 the source",
|
|
939
|
+
"of truth lives in the Sonenta backend, **not** in the repo. This block is generated by",
|
|
940
|
+
"`sonenta init`; re-run it to refresh. Do not edit between the markers.",
|
|
941
|
+
"",
|
|
942
|
+
`- **Project:** ${project} \xB7 version \`${version}\``,
|
|
943
|
+
`- **Source language:** ${d.sourceLanguage ? `\`${d.sourceLanguage}\`` : "_unknown_"} \xB7 **Languages:** ${list(d.languages, "_unknown_")}`,
|
|
944
|
+
`- **Namespaces:** ${list(d.namespaces, "_unknown_")}`,
|
|
945
|
+
`- **API:** ${DOC_API_HOST} \xB7 **CDN:** ${DOC_CDN_HOST} \xB7 spec: ${DOC_API_HOST}/openapi.json`,
|
|
946
|
+
`- **Account** (\`GET /v1/me\`): ${accountLine}`,
|
|
947
|
+
...capabilityLines,
|
|
948
|
+
liveHint,
|
|
949
|
+
"### Editing translations",
|
|
950
|
+
"",
|
|
951
|
+
"Do not hand-edit published CDN bundles. Change strings in Sonenta, via the CLI",
|
|
952
|
+
"(`npx -y @sonenta/cli`) or the MCP server:",
|
|
953
|
+
"",
|
|
954
|
+
"- `sonenta pull` \u2014 fetch translations into `locales/<lang>/<namespace>.json`",
|
|
955
|
+
"- `sonenta push` \u2014 upsert the whole local `locales/` tree (creates keys + translations, idempotent)",
|
|
956
|
+
"- `sonenta import <files...>` \u2014 import specific i18next JSON files (PUTs source + translations)",
|
|
957
|
+
"- MCP tools: `create_key`, `propose_translation`, `update_key` for programmatic edits",
|
|
958
|
+
"",
|
|
959
|
+
"### Publishing to the CDN",
|
|
960
|
+
"",
|
|
961
|
+
"- `sonenta releases publish` \u2014 build bundles per (language, namespace) and push to the",
|
|
962
|
+
" public CDN; subscribed SDKs receive a live `translations_published` event.",
|
|
963
|
+
`- Published bundle URL: \`${DOC_CDN_HOST}/p/<project>/<version>/latest/<lang>/<namespace>.json\``,
|
|
964
|
+
"",
|
|
965
|
+
"### Add the Sonenta MCP server",
|
|
966
|
+
"",
|
|
967
|
+
"Give agents read access to keys, the missing-key feed, and translation drafting by",
|
|
968
|
+
"adding `@sonenta/mcp` (generate an `mcp:*` API key in Sonenta \u2192 Org Settings \u2192 API Keys):",
|
|
969
|
+
"",
|
|
970
|
+
"```json",
|
|
971
|
+
"{",
|
|
972
|
+
' "mcpServers": {',
|
|
973
|
+
' "sonenta": {',
|
|
974
|
+
' "command": "npx",',
|
|
975
|
+
' "args": ["-y", "@sonenta/mcp"],',
|
|
976
|
+
' "env": {',
|
|
977
|
+
' "SONENTA_API_KEY": "<mcp:* api key>",',
|
|
978
|
+
` "SONENTA_PROJECTS": ${d.projectUuid ? `"${d.projectUuid}"` : '"<project_uuid>"'}`,
|
|
979
|
+
" }",
|
|
980
|
+
" }",
|
|
981
|
+
" }",
|
|
982
|
+
"}",
|
|
983
|
+
"```",
|
|
984
|
+
BLOCK_END,
|
|
985
|
+
""
|
|
986
|
+
];
|
|
987
|
+
return lines.join("\n");
|
|
988
|
+
}
|
|
989
|
+
async function upsertManagedBlock(filePath, block) {
|
|
990
|
+
let existing = null;
|
|
991
|
+
try {
|
|
992
|
+
existing = await fs6.readFile(filePath, "utf8");
|
|
993
|
+
} catch {
|
|
994
|
+
existing = null;
|
|
995
|
+
}
|
|
996
|
+
const normalizedBlock = block.endsWith("\n") ? block : block + "\n";
|
|
997
|
+
if (existing === null) {
|
|
998
|
+
await fs6.writeFile(filePath, normalizedBlock, "utf8");
|
|
999
|
+
return "created";
|
|
1000
|
+
}
|
|
1001
|
+
const begin = existing.indexOf(BLOCK_BEGIN);
|
|
1002
|
+
const end = existing.indexOf(BLOCK_END);
|
|
1003
|
+
if (begin !== -1 && end !== -1 && end > begin) {
|
|
1004
|
+
const before = existing.slice(0, begin);
|
|
1005
|
+
const after = existing.slice(end + BLOCK_END.length);
|
|
1006
|
+
const blockCore = block.slice(0, block.indexOf(BLOCK_END) + BLOCK_END.length);
|
|
1007
|
+
await fs6.writeFile(filePath, before + blockCore + after, "utf8");
|
|
1008
|
+
return "updated";
|
|
1009
|
+
}
|
|
1010
|
+
const sep = existing.length === 0 ? "" : existing.endsWith("\n\n") ? "" : existing.endsWith("\n") ? "\n" : "\n\n";
|
|
1011
|
+
await fs6.writeFile(filePath, existing + sep + normalizedBlock, "utf8");
|
|
1012
|
+
return "inserted";
|
|
1013
|
+
}
|
|
1014
|
+
async function writeRepoDocs(dir, data) {
|
|
1015
|
+
const block = renderManagedBlock(data);
|
|
1016
|
+
const results = [];
|
|
1017
|
+
for (const file of REPO_DOC_FILES) {
|
|
1018
|
+
const path = resolve3(dir, file);
|
|
1019
|
+
const action = await upsertManagedBlock(path, block);
|
|
1020
|
+
results.push({ file, path, action });
|
|
1021
|
+
}
|
|
1022
|
+
return results;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// src/commands/init.ts
|
|
1026
|
+
var DEFAULT_HOST = "https://api.sonenta.com";
|
|
1027
|
+
var ACTION_LABEL = {
|
|
1028
|
+
created: "Created",
|
|
1029
|
+
updated: "Updated",
|
|
1030
|
+
inserted: "Inserted block into"
|
|
1031
|
+
};
|
|
1032
|
+
async function gatherRepoDocData(opts) {
|
|
1033
|
+
const data = { projectUuid: opts.project, versionSlug: opts.version };
|
|
1034
|
+
let liveHost = opts.host !== DEFAULT_HOST ? opts.host : void 0;
|
|
1035
|
+
if (!liveHost) {
|
|
1036
|
+
const creds = await readCredentials().catch(() => null);
|
|
1037
|
+
liveHost = creds?.default ?? void 0;
|
|
1038
|
+
}
|
|
1039
|
+
try {
|
|
1040
|
+
const ctx = await resolveContext({ hostOverride: liveHost });
|
|
1041
|
+
const me = await fetchMe(ctx.host, ctx.apiKey);
|
|
1042
|
+
data.orgName = me.org_name;
|
|
1043
|
+
data.plan = me.plan;
|
|
1044
|
+
data.accountActive = me.account_active;
|
|
1045
|
+
data.scopes = me.scopes;
|
|
1046
|
+
data.capabilities = me.capabilities;
|
|
1047
|
+
if (ctx.projectUuid) {
|
|
1048
|
+
try {
|
|
1049
|
+
const info = await getProjectInfo(ctx);
|
|
1050
|
+
data.sourceLanguage = info.source_language || void 0;
|
|
1051
|
+
data.languages = info.languages;
|
|
1052
|
+
data.namespaces = info.namespaces;
|
|
1053
|
+
} catch {
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
return { data, live: true };
|
|
1057
|
+
} catch {
|
|
1058
|
+
return {
|
|
1059
|
+
data,
|
|
1060
|
+
live: false,
|
|
1061
|
+
note: "not logged in / API unreachable \u2014 wrote a partial block. Run `sonenta login` then re-run `sonenta init --force` to populate source language, namespaces, and live capabilities."
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
var initCommand = new Command4("init").description(
|
|
1066
|
+
"Scaffold sonenta.config.json AND write a managed Sonenta block into CLAUDE.md / AGENTS.md so coding agents know how this repo uses Sonenta."
|
|
1067
|
+
).option("--host <url>", "API base URL", DEFAULT_HOST).option("--project <uuid>", "Project UUID").option("--version <slug>", "Version slug (default: main)", "main").option("--force", "Overwrite an existing sonenta.config.json", false).option("--no-repo-doc", "Skip writing the managed block into CLAUDE.md / AGENTS.md").action(
|
|
888
1068
|
async (opts) => {
|
|
889
|
-
const path =
|
|
1069
|
+
const path = resolve4(process.cwd(), CONFIG_FILENAME);
|
|
890
1070
|
if (existsSync(path) && !opts.force) {
|
|
891
1071
|
console.error(
|
|
892
1072
|
`${CONFIG_FILENAME} already exists at ${path}. Pass --force to overwrite.`
|
|
@@ -899,9 +1079,23 @@ var initCommand = new Command4("init").description("Scaffold a sonenta.config.js
|
|
|
899
1079
|
version_slug: opts.version
|
|
900
1080
|
});
|
|
901
1081
|
console.log(`Wrote ${written}`);
|
|
1082
|
+
if (opts.repoDoc) {
|
|
1083
|
+
const { data, live, note } = await gatherRepoDocData(opts);
|
|
1084
|
+
const results = await writeRepoDocs(process.cwd(), data);
|
|
1085
|
+
for (const r of results) {
|
|
1086
|
+
console.log(`${ACTION_LABEL[r.action] ?? "Wrote"} ${r.file} (Sonenta managed block)`);
|
|
1087
|
+
}
|
|
1088
|
+
if (live) {
|
|
1089
|
+
console.log("Populated the block from the live API (GET /v1/me + project info).");
|
|
1090
|
+
} else if (note) {
|
|
1091
|
+
console.log(`Note: ${note}`);
|
|
1092
|
+
}
|
|
1093
|
+
} else {
|
|
1094
|
+
console.log("Skipped CLAUDE.md / AGENTS.md (--no-repo-doc).");
|
|
1095
|
+
}
|
|
902
1096
|
if (!opts.project) {
|
|
903
1097
|
console.log(
|
|
904
|
-
"Tip: pass --project <uuid> to bind this directory to a specific project (or edit project_uuid in the file later)
|
|
1098
|
+
"Tip: pass --project <uuid> to bind this directory to a specific project (or edit project_uuid in the file later), then re-run `sonenta init --force`."
|
|
905
1099
|
);
|
|
906
1100
|
}
|
|
907
1101
|
}
|
|
@@ -927,8 +1121,8 @@ async function promptLine(message) {
|
|
|
927
1121
|
if (!process.stdin.isTTY) return "";
|
|
928
1122
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
929
1123
|
try {
|
|
930
|
-
return await new Promise((
|
|
931
|
-
rl.question(message, (answer) =>
|
|
1124
|
+
return await new Promise((resolve6) => {
|
|
1125
|
+
rl.question(message, (answer) => resolve6(answer.trim()));
|
|
932
1126
|
});
|
|
933
1127
|
} finally {
|
|
934
1128
|
rl.close();
|
|
@@ -944,7 +1138,7 @@ async function promptSecret(message) {
|
|
|
944
1138
|
process.stdout.write(message);
|
|
945
1139
|
process.stdin.setRawMode(true);
|
|
946
1140
|
process.stdin.resume();
|
|
947
|
-
return await new Promise((
|
|
1141
|
+
return await new Promise((resolve6) => {
|
|
948
1142
|
let buffer = "";
|
|
949
1143
|
const onData = (chunk) => {
|
|
950
1144
|
for (const byte of chunk) {
|
|
@@ -953,7 +1147,7 @@ async function promptSecret(message) {
|
|
|
953
1147
|
process.stdin.removeListener("data", onData);
|
|
954
1148
|
process.stdin.setRawMode(false);
|
|
955
1149
|
process.stdin.pause();
|
|
956
|
-
|
|
1150
|
+
resolve6(buffer);
|
|
957
1151
|
return;
|
|
958
1152
|
}
|
|
959
1153
|
if (byte === CTRL_C) {
|
|
@@ -1104,14 +1298,14 @@ var projectsCommand = new Command9("projects").description("Inspect Verbumia pro
|
|
|
1104
1298
|
import { Command as Command10 } from "commander";
|
|
1105
1299
|
|
|
1106
1300
|
// src/locales.ts
|
|
1107
|
-
import { promises as
|
|
1108
|
-
import { join as join3, resolve as
|
|
1301
|
+
import { promises as fs7 } from "fs";
|
|
1302
|
+
import { join as join3, resolve as resolve5 } from "path";
|
|
1109
1303
|
var DEFAULT_LOCALES_DIR = "locales";
|
|
1110
1304
|
async function listLocaleFiles(rootDir) {
|
|
1111
|
-
const root =
|
|
1305
|
+
const root = resolve5(rootDir);
|
|
1112
1306
|
let langDirs;
|
|
1113
1307
|
try {
|
|
1114
|
-
langDirs = await
|
|
1308
|
+
langDirs = await fs7.readdir(root);
|
|
1115
1309
|
} catch {
|
|
1116
1310
|
return [];
|
|
1117
1311
|
}
|
|
@@ -1120,12 +1314,12 @@ async function listLocaleFiles(rootDir) {
|
|
|
1120
1314
|
const langPath = join3(root, lang);
|
|
1121
1315
|
let stat;
|
|
1122
1316
|
try {
|
|
1123
|
-
stat = await
|
|
1317
|
+
stat = await fs7.stat(langPath);
|
|
1124
1318
|
} catch {
|
|
1125
1319
|
continue;
|
|
1126
1320
|
}
|
|
1127
1321
|
if (!stat.isDirectory()) continue;
|
|
1128
|
-
const files = await
|
|
1322
|
+
const files = await fs7.readdir(langPath);
|
|
1129
1323
|
for (const f of files) {
|
|
1130
1324
|
if (!f.endsWith(".json")) continue;
|
|
1131
1325
|
out.push({ lang, namespace: f.replace(/\.json$/, ""), path: join3(langPath, f) });
|
|
@@ -1134,7 +1328,7 @@ async function listLocaleFiles(rootDir) {
|
|
|
1134
1328
|
return out;
|
|
1135
1329
|
}
|
|
1136
1330
|
async function readLocaleFile(path) {
|
|
1137
|
-
const raw = await
|
|
1331
|
+
const raw = await fs7.readFile(path, "utf8");
|
|
1138
1332
|
const parsed = JSON.parse(raw);
|
|
1139
1333
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1140
1334
|
throw new Error(`${path} is not a flat object`);
|
|
@@ -1150,12 +1344,12 @@ async function readLocaleFile(path) {
|
|
|
1150
1344
|
}
|
|
1151
1345
|
async function writeLocaleFile(rootDir, lang, namespace, values) {
|
|
1152
1346
|
const dir = join3(rootDir, lang);
|
|
1153
|
-
await
|
|
1347
|
+
await fs7.mkdir(dir, { recursive: true });
|
|
1154
1348
|
const path = join3(dir, `${namespace}.json`);
|
|
1155
1349
|
const sorted = Object.fromEntries(
|
|
1156
1350
|
Object.entries(values).sort(([a], [b]) => a.localeCompare(b))
|
|
1157
1351
|
);
|
|
1158
|
-
await
|
|
1352
|
+
await fs7.writeFile(path, JSON.stringify(sorted, null, 2) + "\n", "utf8");
|
|
1159
1353
|
return path;
|
|
1160
1354
|
}
|
|
1161
1355
|
function diffFlat(local, remote) {
|
|
@@ -1294,7 +1488,7 @@ var releasesCommand = new Command12("releases").description("Manage CDN releases
|
|
|
1294
1488
|
);
|
|
1295
1489
|
|
|
1296
1490
|
// src/commands/snapshot.ts
|
|
1297
|
-
import { promises as
|
|
1491
|
+
import { promises as fs8 } from "fs";
|
|
1298
1492
|
import { Command as Command13 } from "commander";
|
|
1299
1493
|
function bundleUrl(cdnBase, project, version, lang, ns) {
|
|
1300
1494
|
return `${cdnBase.replace(/\/+$/, "")}/p/${project}/${version}/latest/${lang}/${ns}.json`;
|
|
@@ -1361,7 +1555,7 @@ var snapshotCommand = new Command13("snapshot").description(
|
|
|
1361
1555
|
opts.format === "json" ? "json" : "ts"
|
|
1362
1556
|
);
|
|
1363
1557
|
if (opts.out) {
|
|
1364
|
-
await
|
|
1558
|
+
await fs8.writeFile(opts.out, output, "utf8");
|
|
1365
1559
|
console.log(
|
|
1366
1560
|
`wrote ${opts.out}: ${fetched} bundle(s)` + (missing ? `, ${missing} not published (404)` : "")
|
|
1367
1561
|
);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/commands/agents.ts","../src/agents.ts","../src/config.ts","../src/credentials.ts","../src/api.ts","../src/auth.ts","../src/commands/export.ts","../src/i18next_tree.ts","../src/mcp.ts","../src/commands/import.ts","../src/commands/init.ts","../src/commands/keys.ts","../src/commands/login.ts","../src/prompt.ts","../src/commands/logout.ts","../src/commands/missing.ts","../src/commands/projects.ts","../src/commands/pull.ts","../src/locales.ts","../src/commands/push.ts","../src/commands/releases.ts","../src/commands/snapshot.ts","../src/commands/status.ts","../src/commands/whoami.ts"],"sourcesContent":["import { Command } from \"commander\";\n\nimport { agentsCommand } from \"./commands/agents.js\";\nimport { exportCommand } from \"./commands/export.js\";\nimport { importCommand } from \"./commands/import.js\";\nimport { initCommand } from \"./commands/init.js\";\nimport { keysCommand } from \"./commands/keys.js\";\nimport { loginCommand } from \"./commands/login.js\";\nimport { logoutCommand } from \"./commands/logout.js\";\nimport { missingCommand } from \"./commands/missing.js\";\nimport { projectsCommand } from \"./commands/projects.js\";\nimport { pullCommand } from \"./commands/pull.js\";\nimport { pushCommand } from \"./commands/push.js\";\nimport { releasesCommand } from \"./commands/releases.js\";\nimport { snapshotCommand } from \"./commands/snapshot.js\";\nimport { statusCommand } from \"./commands/status.js\";\nimport { whoamiCommand } from \"./commands/whoami.js\";\n\nconst program = new Command();\nprogram\n .name(\"sonenta\")\n .description(\"CLI for Sonenta translation management.\")\n .version(\"0.7.1\");\n\nprogram.addCommand(loginCommand);\nprogram.addCommand(logoutCommand);\nprogram.addCommand(whoamiCommand);\nprogram.addCommand(initCommand);\nprogram.addCommand(projectsCommand);\nprogram.addCommand(keysCommand);\nprogram.addCommand(importCommand);\nprogram.addCommand(pushCommand);\nprogram.addCommand(pullCommand);\nprogram.addCommand(exportCommand);\nprogram.addCommand(statusCommand);\nprogram.addCommand(releasesCommand);\nprogram.addCommand(snapshotCommand);\nprogram.addCommand(missingCommand);\nprogram.addCommand(agentsCommand);\n\nprogram.parseAsync(process.argv).catch((err: unknown) => {\n console.error(err instanceof Error ? err.message : err);\n process.exit(1);\n});\n","import { Command } from \"commander\";\n\nimport { AGENTS_DIR, isInstalled, listAgents, writeAgent } from \"../agents.js\";\nimport { requireAuth } from \"../auth.js\";\n\nexport const agentsCommand = new Command(\"agents\")\n .description(\"Install bundled Claude agents (e.g. sonenta-a11y) into .claude/agents/.\")\n .addCommand(\n new Command(\"list\")\n .description(\"List the bundled agents available to install.\")\n .option(\"--dir <path>\", \"Project directory (default: current directory)\")\n .action(async (opts: { dir?: string }) => {\n const baseDir = opts.dir;\n const agents = listAgents();\n console.log(`Available agents (${agents.length}):`);\n for (const a of agents) {\n const installed = await isInstalled(a.name, baseDir);\n const mark = installed ? \"✓ installed\" : \" not installed\";\n console.log(` ${a.name.padEnd(16)} ${mark}`);\n console.log(` ${a.summary}`);\n }\n console.log(`\\nInstall with: sonenta agents add <name>`);\n }),\n )\n .addCommand(\n new Command(\"add\")\n .description(\"Write a bundled agent definition into <dir>/.claude/agents/<name>.md.\")\n .argument(\"<name>\", \"Agent name (e.g. sonenta-a11y)\")\n .option(\"--dir <path>\", \"Project directory (default: current directory)\")\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .option(\"--force\", \"Overwrite an existing agent definition\", false)\n .action(async (name: string, opts: { dir?: string; host?: string; force: boolean }) => {\n // Gate: must be logged in with an active account to install an agent.\n await requireAuth({ hostOverride: opts.host });\n const path = await writeAgent(name, { baseDir: opts.dir, force: opts.force });\n console.log(`Wrote ${path}`);\n console.log(\n `\\nThe ${name} agent drives the Sonenta a11y MCP tools. Make sure the ` +\n `Sonenta MCP server is configured (npx -y @sonenta/mcp) with an ` +\n `mcp:* SONENTA_API_KEY, then use the agent in Claude Code or CI.`,\n );\n console.log(`Agent dir: ${AGENTS_DIR}/`);\n }),\n );\n","import { promises as fs } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\n/**\n * Installable Claude agents shipped with the CLI.\n *\n * `sonenta agents add <name>` writes a bundled agent definition into the\n * project's `.claude/agents/<name>.md` — the directory Claude Code reads\n * project-scoped subagents from. The agents drive the Sonenta a11y MCP tools\n * (from `@sonenta/mcp`) to audit and fix accessibility gaps; they work the same\n * interactively in Claude Code or headless in CI.\n *\n * The registry is intentionally simple (a name -> definition map) so more\n * agents can be added later without touching the command wiring.\n */\n\nexport const AGENTS_DIR = \".claude/agents\";\n\nexport interface AgentDef {\n /** File/agent name (no extension); the file is written as `<name>.md`. */\n name: string;\n /** One-line summary shown by `agents list`. */\n summary: string;\n /** Full agent definition (YAML frontmatter + system prompt). */\n content: string;\n}\n\nconst SONENTA_A11Y = `---\nname: sonenta-a11y\ndescription: Accessibility (a11y) auditor and fixer for Sonenta-managed i18n projects. Scans translation keys for WCAG gaps (missing aria-labels, images without alt text, hard-to-read copy, missing or untranslated a11y variants) and fixes them — generating the a11y text itself and writing it back through the Sonenta MCP tools at zero AI-credit cost. Use interactively in Claude Code or headless in CI.\n---\n\nYou are **sonenta-a11y**, an accessibility specialist for internationalized\nprojects managed with Sonenta. You turn an accessibility audit into concrete,\nreviewable fixes, operating through the Sonenta MCP server's a11y tools.\n\n## Cost model — generate LOCALLY first (this is the default)\nYou ARE a capable language model already running in the developer's session\n(Claude Code or CI), and that compute is already paid for. So **you write the\na11y values yourself, with your own reasoning, and persist them with\n\\`set_a11y_variant\\`** — which is plain CRUD and costs **zero Sonenta AI\ncredits**. Do NOT reach for the server-side AI tools\n(\\`generate_a11y_variant\\` / \\`translate_a11y_variants\\`) by default: those bill\nSonenta AI credits and exist only as an explicit fallback for very large volumes\nor when the developer specifically asks for server-side generation.\n\n## Requirements\n- The Sonenta MCP server (\\`@sonenta/mcp\\`) must be configured with an \\`mcp:*\\`\n API key. Every operation goes through its tools — never call the HTTP API\n directly. If the a11y tools are missing, tell the user to add the server\n (\\`npx -y @sonenta/mcp\\`) and set \\`SONENTA_API_KEY\\`.\n- Tools:\n - \\`a11y_report\\` — full WCAG gap report (rollups + per-item gaps). READ-ONLY.\n - \\`list_a11y_gaps\\` — the actionable gap list, filterable by gap / surface /\n locale. READ-ONLY.\n - \\`set_a11y_variant\\` — **your primary write**: upsert one a11y variant for\n (key_uuid, language_code, surface) with a text value. CRUD, **0 AI credits**,\n stored as a draft.\n - \\`delete_a11y_variant\\` — clear one variant. CRUD, **0 AI credits**.\n - \\`list_cognitive_candidates\\` — text keys eligible for plain-language scoring\n (a type offering plain_language, past a word floor). READ-ONLY.\n - \\`set_cognitive_score\\` — record a key's cognitive difficulty score (0-100)\n plus a plain-language suggestion. CRUD, **0 AI credits** (by_bot).\n - \\`list_keys\\` — read each key's semantic \\`type\\` (and source value) to audit\n typing. READ-ONLY.\n - \\`update_key\\` / \\`update_keys_bulk\\` — reclassify a mis-typed key (type-only,\n no source_value). CRUD, 0 AI credits. Correct types are what make the a11y\n gaps surface.\n - \\`a11y_estimate\\` — preview the AI-credit cost of the server-side fallback.\n - \\`generate_a11y_variant\\` / \\`translate_a11y_variants\\` / \\`analyze_cognitive\\`\n — **fallback only**: server-side AI that BILLS Sonenta AI credits. Use only\n for very large volumes or on explicit developer request.\n\n## The four a11y surfaces (what you write)\n- \\`aria_label\\` — a concise accessible NAME for an interactive element (button,\n icon, link). Derive it from the element's visible label and purpose.\n- \\`alt_text\\` — alternative text for an image. Derive it from the key's context /\n description; describe the image's MEANING, not \"image of…\".\n- \\`screen_reader\\` — verbose screen-reader-only text, for when the visible text\n is insufficient out of context.\n- \\`plain_language\\` — a simplified / clear-language (FALC) rewrite of the source.\n\na11y values are SEMANTIC (the accessible name / alt / simplified wording for\nassistive tech), not the visible UI string — keep them concise and meaningful.\n\n## Gap types and how you resolve each (locally, by yourself)\n- \\`a11y_variant_absent\\` — a required surface is missing in the source → compose\n it yourself and \\`set_a11y_variant\\` (source language).\n- \\`alt_missing\\` — an image key has no source alt_text → write \\`alt_text\\`.\n- \\`reading_level_high\\` — flagged when a key's COGNITIVE SCORE is at/above the\n project threshold. Resolve it locally: judge the difficulty yourself and call\n \\`set_cognitive_score(key_uuid, score, suggestion)\\` with a plain-language\n rewrite (0 credits, draft). The suggestion is then applied to the\n \\`plain_language\\` surface (or the base value) on human approval.\n- \\`a11y_untranslated\\` — a source a11y variant exists but a locale lacks it →\n TRANSLATE it yourself and \\`set_a11y_variant\\` for that \\`language_code\\`.\n\n## Workflow\n1. **Audit key TYPES first (prerequisite).** The a11y treatments a key offers are\n decided by its semantic \\`type\\`, so a project where everything is the default\n \\`text\\` (a common starting state) produces NO aria/alt/icon gaps even when\n buttons and images need them. Read each key's \\`type\\` from \\`list_keys\\` and\n reclassify mis-typed keys via \\`update_key\\` / \\`update_keys_bulk\\` (type-only,\n no source_value): buttons/links → \\`button\\` / \\`link\\`, images → \\`image\\`,\n icons → \\`icon\\`, form-field labels → \\`input_label\\`, headings → \\`heading\\`,\n etc. Only then does \\`a11y_report\\` surface the real gaps.\n2. **Scan.** Call \\`a11y_report\\` (pass \\`require_surface\\` for the surfaces the\n project needs, typically \\`aria_label\\` and \\`alt_text\\`). Summarize\n \\`total_gaps\\`, \\`by_gap\\`, \\`by_severity\\`, \\`by_surface\\`. Use\n \\`list_a11y_gaps\\` to pull the actionable items — each carries \\`key_uuid\\`,\n \\`key_name\\`, \\`namespace_slug\\`, \\`surface\\`, and \\`locale\\`.\n3. **Triage.** Group by type/severity — warnings first (\\`a11y_untranslated\\`,\n \\`alt_missing\\`), then info (\\`reading_level_high\\`, \\`a11y_variant_absent\\`).\n4. **Generate locally + write (DEFAULT path, 0 credits).** For each gap, compose\n the a11y value YOURSELF — reasoning over the key name, source value, any\n context/description, and the target surface — then persist it with\n \\`set_a11y_variant(key_uuid, language_code, surface, value)\\`. For\n \\`a11y_untranslated\\`, translate the source variant yourself into the target\n \\`language_code\\` and \\`set_a11y_variant\\`. Work through the gap list in\n sensible batches. This spends NO AI credits.\n5. **Score plain-language (local, 0 credits).** Call\n \\`list_cognitive_candidates\\` (use \\`only_unanalyzed=true\\` to skip already\n scored keys). For each candidate, JUDGE its cognitive difficulty yourself\n (0-100, higher = harder to read) and write a clearer plain-language rewrite,\n then \\`set_cognitive_score(key_uuid, score, suggestion)\\`. Keys at/above the\n project threshold then surface as \\`reading_level_high\\` for a human to\n apply/approve. This spends NO credits — prefer it over \\`analyze_cognitive\\`.\n6. **Server fallback (opt-in only).** If the volume is impractical to do locally,\n or the developer explicitly wants Sonenta server-side AI, FIRST call\n \\`a11y_estimate\\` (report \\`credits_required\\` vs \\`balance\\`; stop if not\n \\`sufficient\\`), confirm, THEN \\`generate_a11y_variant\\` /\n \\`translate_a11y_variants\\` (or \\`analyze_cognitive\\` for bulk cognitive\n scoring).\n7. **Report.** Everything you write lands as a **draft** for human review — never\n present it as final. Summarize what you set (counts by surface / locale), what\n remains, and whether any credits were spent (0 on the local path).\n\n## Modes\n- **Interactive (Claude Code):** propose the fix plan, then write the local\n fixes; for the credit-billing fallback, show the estimate and confirm first.\n- **CI / headless:** run \\`a11y_report\\` and exit non-zero when \\`total_gaps\\` (or\n a chosen severity) exceeds the project threshold; optionally auto-write the\n local fixes. Only use the credit-billing fallback when explicitly authorized.\n\n## Guardrails\n- Default to LOCAL work + \\`set_a11y_variant\\` / \\`set_cognitive_score\\`\n (0 credits). Treat \\`generate_a11y_variant\\` / \\`translate_a11y_variants\\` /\n \\`analyze_cognitive\\` as an explicit, estimated, opt-in fallback — never the\n silent default.\n- \\`set_a11y_variant\\` / \\`delete_a11y_variant\\` / \\`set_cognitive_score\\` are CRUD\n and never spend AI credits; only \\`generate\\` / \\`translate\\` / \\`analyze\\` do.\n Always estimate before that fallback.\n- You FILL gaps — never overwrite a human-reviewed variant blindly.\n- Stay within the configured project; confirm it before any bulk operation.\n`;\n\nconst SONENTA_I18N = `---\nname: sonenta-i18n\ndescription: Internationalization (i18n) automation agent for Sonenta-managed projects. Audits translation coverage, creates missing keys, translates the untranslated content itself (honoring the glossary and project context), and publishes — driving the Sonenta i18n MCP tools. Local-first (0 AI credits), draft-to-review, usable in Claude Code or headless in CI.\n---\n\nYou are **sonenta-i18n**, an internationalization specialist for projects managed\nwith Sonenta. You run the everyday i18n loop — assess coverage, fill missing\nkeys, translate what is untranslated, and publish — through the Sonenta MCP\nserver's tools.\n\n## Cost model — translate LOCALLY first (default, 0 credits)\nYou ARE a capable language model already running in the developer's session\n(Claude Code or CI) on compute they already pay for. So you **translate the\nstrings yourself**, honoring the project's glossary and context, and write the\nresults with \\`propose_translations_bulk\\` as **drafts/proposed** — plain CRUD,\n**zero Sonenta AI credits**. Do NOT reach for server-side on-demand AI\ntranslation by default; where such a path exists it BILLS Sonenta AI credits and\nis an explicit, estimate-first, opt-in fallback for very large volumes.\n\n## Requirements\n- The Sonenta MCP server (\\`@sonenta/mcp\\`) must be configured with an \\`mcp:*\\`\n API key. Everything goes through its tools — never call the HTTP API directly.\n If the tools are missing, tell the user to add the server\n (\\`npx -y @sonenta/mcp\\`) and set \\`SONENTA_API_KEY\\`.\n- Tools you drive:\n - **Assess:** \\`get_project_info\\`, \\`coverage_report\\`, \\`health_report\\`,\n \\`missing_keys_stats\\`, \\`list_missing_keys\\`.\n - **Fill keys:** \\`create_namespace\\`, \\`create_keys_bulk\\`,\n \\`update_keys_bulk\\`, \\`acknowledge_missing_keys\\`.\n - **Translate:** \\`list_untranslated_keys\\`, \\`propose_translations_bulk\\`\n (your primary write — CRUD, 0 credits), \\`validate_translations\\`.\n - **Consistency:** \\`glossary_list\\`, \\`project_context_get\\`.\n - **Ship:** \\`publish_cdn\\`.\n\n## Workflow\n1. **Assess.** \\`get_project_info\\` (source + target languages, namespaces);\n \\`coverage_report\\` (per-language completeness); \\`health_report\\`\n (source-string issues); \\`missing_keys_stats\\` / \\`list_missing_keys\\`\n (runtime-detected gaps). Summarize where the project stands.\n2. **Fill missing keys — with the right TYPE.** For runtime-detected missing\n keys, \\`create_keys_bulk\\` (seed the source value) — \\`create_namespace\\` first\n if a namespace is new — then \\`acknowledge_missing_keys\\` to clear the\n dashboard. ALWAYS set each key's \\`type\\` by its UI role (button / link /\n heading / image / icon / input_label / …); do NOT leave everything as the\n default \\`text\\`. The type drives the key's a11y treatments, so correct typing\n here is what lets sonenta-a11y work later. While you're at it, audit existing\n keys' \\`type\\` (returned by \\`list_keys\\`) and reclassify mis-typed ones via\n \\`update_keys_bulk\\` (type-only).\n3. **Translate the untranslated (default, 0 credits).** For each target\n language, \\`list_untranslated_keys\\`. BEFORE translating, read\n \\`glossary_list\\` (respect \\`forbidden\\` / \\`do_not_translate\\`, apply\n \\`translation\\` rules) and \\`project_context_get\\` (brand voice, domain, tone).\n Translate each value YOURSELF, then write a batch with\n \\`propose_translations_bulk\\` (status draft/proposed). Work through the\n languages and namespaces in sensible batches.\n4. **Validate (optional).** \\`validate_translations\\` lints an i18next blob\n server-side; fix anything it flags.\n5. **Publish.** \\`publish_cdn\\` to release the bundles — with confirmation in\n interactive mode, only on explicit authorization in CI.\n6. **Report.** Show the coverage delta (before/after), counts of keys created and\n strings translated, what remains, and that translations are drafts to review.\n\n## Modes\n- **Interactive (Claude Code):** propose the plan, write the drafts, then confirm\n before publishing.\n- **CI / headless:** run \\`coverage_report\\` and exit non-zero when completeness\n is below a chosen threshold; optionally auto-write translation drafts; only\n \\`publish_cdn\\` when the run is explicitly authorized.\n\n## Guardrails\n- Translations land as **drafts/proposed** for human review — never\n auto-approved.\n- Always honor the glossary (\\`forbidden\\` / \\`do_not_translate\\`) and the project\n context before translating.\n- Local translation + \\`propose_translations_bulk\\` is the default and costs 0\n credits; any server-side AI translation is an explicit, estimated, opt-in\n fallback.\n- Never \\`publish_cdn\\` without confirmation/authorization; stay within the\n configured project.\n`;\n\nconst SONENTA_SOURCE_HEALTH = `---\nname: sonenta-source-health\ndescription: Source-health repairer for Sonenta-managed i18n projects. Finds DUPLICATE source strings (the same source value spread across many keys — which inflates translation cost and lets the same string drift into N different translations) and fixes them, working STRICTLY step by step: it lists the affected files first, presents a plan and reassures you before touching anything, edits ONLY on your acceptance, and marks each group resolved through the Sonenta MCP tools. When the Sonenta dashboard has prepared a merge plan, it applies that plan verbatim — merging the clustered keys (value-safe), then differentiating or allowing whatever still shares text. Use interactively in Claude Code or headless in CI.\n---\n\nYou are **sonenta-source-health**, a careful repair specialist for\ninternationalized projects managed with Sonenta. Your job is to clean up\n**duplicate source strings** — keys that share an identical source-language\nvalue. Duplicates are expensive (every copy is translated again) and risky (the\nsame string drifts into divergent translations across locales). You fix them.\n\n## The single most important rule: GO STEP BY STEP, NEVER SURPRISE THE DEV\nSource values are the project's ground truth and editing them can demote\nreviewed/approved translations to needs-review. So you are deliberately\nconservative and explicit. You **never** edit or delete anything before the\ndeveloper has seen the plan and accepted it. Work one duplicate group at a time,\nnarrate what you are about to do, and wait for a clear yes. Reassure: nothing you\npropose is destructive until accepted, deletes are soft (trash, restorable), and\nevery change is a reviewable draft.\n\n## Requirements\n- The Sonenta MCP server (\\`@sonenta/mcp\\`) must be configured with an \\`mcp:*\\`\n API key. Every operation goes through its tools — never call the HTTP API\n directly. If the tools are missing, tell the user to add the server\n (\\`npx -y @sonenta/mcp\\`) and set \\`SONENTA_API_KEY\\`.\n- Tools you drive:\n - \\`list_source_duplicates\\` — **your worklist**: groups of keys sharing one\n source value, each with a triage status (to_fix / allowed / resolved).\n Filter \\`status=to_fix\\` to get the actionable backlog. A \\`to_fix\\` group may\n carry a human-prepared \\`merge_plan\\` (clusters + survivor_outcome) — see\n **Directed merge plan (dashboard-prepared)**. READ-ONLY.\n - \\`list_keys\\` — read each duplicated key's namespace, name, source value and\n per-language translations to decide how to consolidate. READ-ONLY.\n - \\`update_key\\` / \\`update_keys_bulk\\` — edit a key's SOURCE value in place (to\n disambiguate two strings that should differ, or to canonicalize wording).\n CRUD. Changing a source value demotes that key's reviewed/approved targets to\n needs-review (\\`stale_flagged\\` reports how many) — call it out in the plan.\n - \\`delete_keys_bulk\\` — SOFT-delete (trash) redundant keys once callers have\n been pointed at the surviving canonical key. Restorable via\n \\`restore_keys_bulk\\`. No hard-delete over MCP.\n - \\`set_duplicate_status\\` — mark a group \\`resolved\\` (after you fixed it) or\n \\`allowed\\` (an intentional, sanctioned duplicate — stop flagging it), with an\n optional \\`note\\` recording why. CRUD.\n\n## Repair strategies (pick per group, propose explicitly)\nFor a group of keys sharing one source value, the right fix is usually one of:\n1. **Genuine duplicate (same meaning, same place):** keep ONE canonical key,\n point usages at it, \\`delete_keys_bulk\\` (trash) the rest, then\n \\`set_duplicate_status(resolved)\\`. Trash is reversible — say so.\n2. **Same words, DIFFERENT meaning (homonyms — e.g. \"Open\" the verb vs the\n adjective):** they should NOT collapse. Disambiguate via \\`update_key\\` (make\n the source values distinct, or add descriptions/context), then\n \\`set_duplicate_status(resolved)\\`.\n3. **Intentional, legitimately repeated string:** leave the keys as-is and\n \\`set_duplicate_status(allowed)\\` with a note — it stops being flagged.\nYou do NOT decide deletions unilaterally — you PROPOSE the strategy and let the\ndev choose.\n\n## Directed merge plan (dashboard-prepared) — PREFER IT over your own judgment\nWhen \\`list_source_duplicates(status=to_fix)\\` returns a group with a non-null\n\\`merge_plan\\`, a human prepared the consolidation in the Sonenta dashboard and\nyour job is to APPLY it, not to decide the strategy. The plan is AUTHORITATIVE:\nnever add, drop, or re-cluster it. Shape:\n\n merge_plan = {\n clusters: [ { canonical_key_uuid, redundant_key_uuids[] }, … ],\n survivor_outcome: \"allowed\" | \"differentiate\"\n }\n\nFirst resolve every \\`*_key_uuid\\` to its namespace + key name with \\`list_keys\\`\n(you need the names to repoint code). Then apply in TWO clearly separated phases,\nboth step-wise and ONLY on acceptance:\n\n**Phase 1 — MERGE the clusters (VALUE-SAFE).** For each cluster the\n\\`canonical_key_uuid\\` survives unchanged; each \\`redundant_key_uuid\\` is folded\ninto it:\n1. Repoint every code usage of the redundant key onto the canonical:\n \\`t('redundant.name')\\` → \\`t('canonical.name')\\` (and the equivalents:\n \\`i18nKey=\"…\"\\`, \\`<Trans i18nKey>\\`, \\`$t(…)\\`, etc.) across the dev's source.\n2. \\`delete_keys_bulk\\` the redundant key_uuids (SOFT/trash, restorable).\nNEVER call \\`update_key\\` in this phase — the merge changes NO source value; the\ncanonical keeps its value.\n\n**Phase 2 — \\`survivor_outcome\\` on the RESIDUE** (the surviving canonical keys\nthat STILL share the same text after the merges):\n- \\`\"allowed\"\\` → the remaining duplication is sanctioned: \\`set_duplicate_status(allowed)\\`\n — STATUS only, change no value.\n- \\`\"differentiate\"\\` → apply your DISAMBIGUATE strategy on those survivors:\n propose DISTINCT source values via \\`update_key\\` (ON ACCEPTANCE). This is the\n ONLY step that edits a value, and it runs AFTER the merge — keep it separate.\n\nWhen the whole plan for a group is applied, \\`set_duplicate_status(resolved)\\`.\n\n**Validate the plan against reality BEFORE applying a cluster.** Confirm the keys\nstill exist and the usages are safely repointable. If a redundant key is already\ngone, an interpolation/namespace mismatch makes a repoint unsafe, or a reference\nis dynamic/uncertain — STOP and surface the conflict to the dev; never improvise\nor partially apply a cluster. Groups WITHOUT a \\`merge_plan\\` fall back to your own\nstrategy judgment (consolidate / disambiguate / allow) from the section above.\n\n## Workflow (strictly ordered)\n1. **List the affected files first.** Call \\`list_source_duplicates(status=to_fix)\\`.\n For each group, resolve the keys to their human locations with \\`list_keys\\`\n (namespace + key name = where it lives). Present a clear inventory: each\n duplicate source value, how many keys carry it, and exactly which\n namespaces/keys (the \"files\"). Do NOT propose fixes yet — just show the lay of\n the land so the dev sees the full scope.\n2. **Present the plan + reassure.** Pick the groups worth fixing and, for each,\n propose ONE strategy (consolidate / disambiguate / allow) with the precise\n operations it entails (which key survives, which get trashed, which source\n values change) and the blast radius (e.g. \"this demotes 3 reviewed FR\n translations to needs-review\"; \"the 2 trashed keys are restorable\"). Make\n clear NOTHING happens until they accept, and ask which groups to proceed with.\n For a group that carries a \\`merge_plan\\`, the plan IS the proposal — follow\n **Directed merge plan** (present its clusters + the survivor_outcome step)\n instead of choosing a strategy yourself.\n3. **Fix — only on acceptance.** For each ACCEPTED group, execute exactly the\n proposed operations (\\`update_key\\` / \\`update_keys_bulk\\` /\n \\`delete_keys_bulk\\`) — and nothing beyond them. Skip groups the dev declined\n or deferred. If a group's reality differs from the plan once you act on it,\n STOP and re-present rather than improvising. For a \\`merge_plan\\` group, execute\n its two phases IN ORDER (Phase 1 merge clusters — value-safe; Phase 2\n survivor_outcome), exactly as the plan specifies — never re-cluster.\n4. **Mark resolved via MCP.** After a group's fix lands (or for a sanctioned\n duplicate), call \\`set_duplicate_status\\` — \\`resolved\\` for fixed groups,\n \\`allowed\\` for intentional ones — with a short note of what you did.\n5. **Report.** Summarize per group: the strategy applied, keys merged/trashed/\n edited, translations demoted to needs-review (to re-review), groups left\n \\`to_fix\\` (declined/deferred), and groups marked allowed/resolved.\n\n## Modes\n- **Interactive (Claude Code):** the default. Inventory → plan → wait for\n acceptance → fix → mark resolved. One group at a time when the dev prefers.\n- **CI / headless:** run \\`list_source_duplicates\\` and exit non-zero when the\n \\`to_fix\\` count exceeds a chosen threshold (a duplicate-source gate). Do NOT\n auto-edit or auto-delete in CI unless the run explicitly authorizes it — the\n step-by-step acceptance rule is the whole point of this agent.\n\n## Guardrails\n- NEVER edit a source value or trash a key before the dev accepted that specific\n operation. Inventory and plan are always read-only.\n- Deletes are SOFT (trash, restorable via \\`restore_keys_bulk\\`); editing a source\n value demotes reviewed/approved targets to needs-review — always state this in\n the plan before acting.\n- Prefer \\`set_duplicate_status(allowed)\\` over forcing a merge when a duplicate is\n intentional. When unsure whether two same-text keys mean the same thing, ASK —\n do not collapse homonyms.\n- When a group carries a \\`merge_plan\\`, apply it VERBATIM — never add, drop, or\n re-cluster. The MERGE phase is value-safe (no \\`update_key\\`); only the\n \\`differentiate\\` residue step edits source values, and only on acceptance.\n- Stay within the configured project; confirm it before any bulk operation.\n`;\n\nexport const AGENTS: Record<string, AgentDef> = {\n \"sonenta-a11y\": {\n name: \"sonenta-a11y\",\n summary:\n \"Accessibility (a11y) auditor + fixer: scans WCAG gaps and fixes them locally (0-credit set_a11y_variant), with server-side AI generation as an opt-in fallback.\",\n content: SONENTA_A11Y,\n },\n \"sonenta-i18n\": {\n name: \"sonenta-i18n\",\n summary:\n \"i18n automation: audits coverage, creates missing keys, translates the untranslated locally (0-credit propose_translations_bulk), and publishes — server-side AI translation as an opt-in fallback.\",\n content: SONENTA_I18N,\n },\n \"sonenta-source-health\": {\n name: \"sonenta-source-health\",\n summary:\n \"Source-health repairer: finds duplicate source strings and fixes them strictly step-by-step (inventory affected keys → present plan + reassure → fix on acceptance → mark resolved/allowed via MCP). Also applies a dashboard-prepared merge plan verbatim (value-safe cluster merge, then differentiate/allow the residue).\",\n content: SONENTA_SOURCE_HEALTH,\n },\n};\n\nexport function listAgents(): AgentDef[] {\n return Object.values(AGENTS);\n}\n\nexport function getAgent(name: string): AgentDef | undefined {\n return AGENTS[name];\n}\n\n/** Absolute path the agent definition is (or would be) written to. */\nexport function agentInstallPath(name: string, baseDir: string = process.cwd()): string {\n return resolve(baseDir, AGENTS_DIR, `${name}.md`);\n}\n\nexport async function isInstalled(name: string, baseDir: string = process.cwd()): Promise<boolean> {\n try {\n await fs.access(agentInstallPath(name, baseDir));\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Write a bundled agent into `<baseDir>/.claude/agents/<name>.md`.\n * Throws on an unknown agent or when the file exists and `force` is false.\n * Returns the absolute path written.\n */\nexport async function writeAgent(\n name: string,\n opts: { baseDir?: string; force?: boolean } = {},\n): Promise<string> {\n const agent = getAgent(name);\n if (!agent) {\n const known = Object.keys(AGENTS).join(\", \");\n throw new Error(`Unknown agent \"${name}\". Available: ${known}`);\n }\n const baseDir = opts.baseDir ?? process.cwd();\n const path = agentInstallPath(name, baseDir);\n if (!opts.force) {\n try {\n await fs.access(path);\n throw new Error(\n `${path} already exists. Pass --force to overwrite.`,\n );\n } catch (err) {\n // Re-throw the \"already exists\" error; an access() rejection means the\n // file is absent, which is the happy path.\n if (err instanceof Error && err.message.includes(\"already exists\")) throw err;\n }\n }\n await fs.mkdir(resolve(baseDir, AGENTS_DIR), { recursive: true });\n await fs.writeFile(path, agent.content, \"utf8\");\n return path;\n}\n","import { promises as fs } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\n\n/**\n * Project-local config — `sonenta.config.json` at the repo root.\n *\n * Layout (V1, intentionally minimal):\n *\n * {\n * \"host\": \"https://api.sonenta.com\",\n * \"project_uuid\": \"069fc15d-…\",\n * \"version_slug\": \"main\"\n * }\n *\n * `host` may be omitted — commands then fall back to the user-level\n * credentials default. `version_slug` defaults to \"main\" when omitted.\n *\n * Back-compat: the legacy filename `verbumia.config.json` is still READ\n * (with a one-time deprecation warning) when no `sonenta.config.json` is\n * found, so existing projects keep working. New configs are written as\n * `sonenta.config.json`.\n */\n\nexport interface ProjectConfig {\n host?: string;\n project_uuid?: string;\n version_slug?: string;\n}\n\nexport const CONFIG_FILENAME = \"sonenta.config.json\";\nexport const LEGACY_CONFIG_FILENAME = \"verbumia.config.json\";\n\nlet warnedLegacy = false;\n\nexport async function findConfigPath(startDir: string): Promise<string | null> {\n let dir = resolve(startDir);\n // Walk up until we hit a config or the filesystem root. At each level the\n // canonical name wins over the deprecated one.\n while (true) {\n for (const name of [CONFIG_FILENAME, LEGACY_CONFIG_FILENAME]) {\n const candidate = resolve(dir, name);\n try {\n await fs.access(candidate);\n if (name === LEGACY_CONFIG_FILENAME && !warnedLegacy) {\n warnedLegacy = true;\n process.emitWarning(\n `${LEGACY_CONFIG_FILENAME} is deprecated — rename it to ${CONFIG_FILENAME}. ` +\n `The legacy name still works for now.`,\n { type: \"DeprecationWarning\" },\n );\n }\n return candidate;\n } catch {\n // Continue to the next name / parent dir.\n }\n }\n const parent = dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\nexport async function readConfig(startDir: string = process.cwd()): Promise<{\n path: string | null;\n config: ProjectConfig;\n}> {\n const path = await findConfigPath(startDir);\n if (!path) return { path: null, config: {} };\n const raw = await fs.readFile(path, \"utf8\");\n const parsed = JSON.parse(raw) as ProjectConfig;\n return { path, config: parsed };\n}\n\nexport async function writeConfig(\n config: ProjectConfig,\n targetDir: string = process.cwd(),\n): Promise<string> {\n // Always write the canonical filename.\n const path = resolve(targetDir, CONFIG_FILENAME);\n await fs.writeFile(path, JSON.stringify(config, null, 2) + \"\\n\", \"utf8\");\n return path;\n}\n","import { promises as fs } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\n/**\n * Per-user credentials store.\n *\n * Lives at `~/.verbumia/credentials` with file mode 0600. The shape is a\n * keyed map of host → entry, so a single user can have multiple accounts\n * (cloud + self-hosted dev + self-hosted prod) without rewriting the file\n * each time they switch hosts.\n *\n * {\n * \"default\": \"https://api.sonenta.com\",\n * \"hosts\": {\n * \"https://api.sonenta.com\": { \"api_key\": \"vrb_live_…\", \"user_email\": \"...\" },\n * \"https://api.dev.verbumia.ca\":{ \"api_key\": \"vrb_live_…\" }\n * }\n * }\n *\n * The `default` host is what `sonenta` commands target when neither the\n * project's `sonenta.config.json` nor a `--host` flag override it.\n */\n\nexport interface CredentialsEntry {\n api_key: string;\n user_email?: string;\n}\n\nexport interface CredentialsFile {\n default?: string;\n hosts: Record<string, CredentialsEntry>;\n}\n\n// Canonical location is now ~/.sonenta (post @verbumia → @sonenta rename). The\n// legacy ~/.verbumia path is still READ as a fallback so existing logins keep\n// working; the next write lands in ~/.sonenta (migrate-on-write).\nexport const credentialsDir = (): string => join(homedir(), \".sonenta\");\nexport const credentialsPath = (): string => join(credentialsDir(), \"credentials\");\nexport const legacyCredentialsPath = (): string =>\n join(homedir(), \".verbumia\", \"credentials\");\n\nconst EMPTY: CredentialsFile = { hosts: {} };\n\nfunction parseCredentials(raw: string): CredentialsFile {\n const parsed = JSON.parse(raw);\n if (!parsed || typeof parsed !== \"object\" || !parsed.hosts) return EMPTY;\n return parsed as CredentialsFile;\n}\n\nexport async function readCredentials(): Promise<CredentialsFile> {\n // Canonical ~/.sonenta first, then the legacy ~/.verbumia (dual-read).\n for (const path of [credentialsPath(), legacyCredentialsPath()]) {\n try {\n return parseCredentials(await fs.readFile(path, \"utf8\"));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException)?.code === \"ENOENT\") continue;\n throw err;\n }\n }\n return { hosts: {} };\n}\n\nexport async function writeCredentials(creds: CredentialsFile): Promise<void> {\n const dir = credentialsDir();\n const path = credentialsPath();\n await fs.mkdir(dir, { recursive: true, mode: 0o700 });\n // Write to a temp file first to keep the original intact if the process\n // crashes mid-write, then rename atomically.\n const tmp = `${path}.tmp`;\n await fs.writeFile(tmp, JSON.stringify(creds, null, 2) + \"\\n\", { mode: 0o600 });\n await fs.rename(tmp, path);\n // chmod again in case the umask widened it on creation\n await fs.chmod(path, 0o600);\n await fs.chmod(dir, 0o700).catch(() => {});\n}\n\nexport async function setHostEntry(\n host: string,\n entry: CredentialsEntry,\n options: { makeDefault?: boolean } = {},\n): Promise<void> {\n const creds = await readCredentials();\n creds.hosts[host] = entry;\n if (options.makeDefault || !creds.default) creds.default = host;\n await writeCredentials(creds);\n}\n\nexport async function removeHost(host: string): Promise<boolean> {\n const creds = await readCredentials();\n if (!(host in creds.hosts)) return false;\n delete creds.hosts[host];\n if (creds.default === host) {\n const remaining = Object.keys(creds.hosts);\n creds.default = remaining[0];\n }\n await writeCredentials(creds);\n return true;\n}\n\nexport function resolveHostEntry(\n creds: CredentialsFile,\n hostOverride?: string,\n): { host: string; entry: CredentialsEntry } | null {\n const host = hostOverride ?? creds.default;\n if (!host) return null;\n const entry = creds.hosts[host];\n if (!entry) return null;\n return { host, entry };\n}\n","import { readConfig } from \"./config.js\";\nimport {\n type CredentialsEntry,\n readCredentials,\n resolveHostEntry,\n} from \"./credentials.js\";\n\n/**\n * Resolved request context for a CLI command:\n * - host: which Verbumia API to talk to\n * - apiKey: the bearer ApiKey token (resolved from credentials)\n * - projectUuid: optional, from project config\n * - versionSlug: defaults to \"main\"\n */\nexport interface ApiContext {\n host: string;\n apiKey: string;\n projectUuid?: string;\n versionSlug: string;\n}\n\nexport interface ResolveOptions {\n hostOverride?: string;\n cwd?: string;\n}\n\nexport async function resolveContext(opts: ResolveOptions = {}): Promise<ApiContext> {\n const { config } = await readConfig(opts.cwd ?? process.cwd());\n const creds = await readCredentials();\n const host = opts.hostOverride ?? config.host ?? creds.default;\n if (!host) {\n throw new Error(\n \"No host configured. Run `sonenta login --host <url>` or add `host` to sonenta.config.json.\",\n );\n }\n\n // Auth resolution order (first wins):\n // 1. SONENTA_TOKEN (or legacy VERBUMIA_TOKEN) env var — highest priority for CI / scripts\n // 2. ~/.verbumia/credentials entry for this host\n // The env-var path lets users run a one-off command in CI without\n // touching the credentials file or typing the token interactively.\n const envToken = process.env.SONENTA_TOKEN ?? process.env.VERBUMIA_TOKEN;\n let apiKey: string | undefined = envToken && envToken.trim() ? envToken.trim() : undefined;\n if (!apiKey) {\n const resolved = resolveHostEntry(creds, host);\n if (!resolved) {\n throw new Error(\n `No credentials for host ${host}. Set SONENTA_TOKEN or run \\`sonenta login --host ${host}\\`.`,\n );\n }\n apiKey = resolved.entry.api_key;\n }\n\n return {\n host,\n apiKey,\n projectUuid: config.project_uuid,\n versionSlug: config.version_slug ?? \"main\",\n };\n}\n\nexport async function apiRequest<T = unknown>(\n ctx: ApiContext,\n path: string,\n init: RequestInit = {},\n): Promise<T> {\n const url = `${ctx.host.replace(/\\/+$/, \"\")}${path}`;\n const headers = new Headers(init.headers);\n headers.set(\"Authorization\", `ApiKey ${ctx.apiKey}`);\n if (init.body && !headers.has(\"Content-Type\")) {\n headers.set(\"Content-Type\", \"application/json\");\n }\n const res = await fetch(url, { ...init, headers });\n if (!res.ok) {\n const text = await res.text().catch(() => \"\");\n throw new Error(`HTTP ${res.status} ${res.statusText} on ${path}: ${text.slice(0, 300)}`);\n }\n if (res.status === 204) return undefined as T;\n return (await res.json()) as T;\n}\n","import { type ApiContext, resolveContext, type ResolveOptions } from \"./api.js\";\n\n/**\n * Account/key validation for the CLI.\n *\n * `GET /v1/me` (header `Authorization: ApiKey <key>`, any valid key, no scope\n * required) introspects the API key: a `200` returns the account status, a\n * `401` means the key is invalid/revoked. We use it both to validate at\n * `sonenta login` time and to gate value commands (you must be logged in AND\n * your account must be active before the command acts).\n */\n\nexport interface MeResponse {\n valid: boolean;\n account_active: boolean;\n org_uuid?: string;\n org_slug?: string;\n org_name?: string;\n plan?: string;\n email?: string;\n scopes?: string[];\n}\n\n/** Raised for any login/account problem; the message is user-facing + actionable. */\nexport class AuthError extends Error {}\n\n/** Validate an API key against `GET /v1/me`. Throws AuthError on an invalid key. */\nexport async function fetchMe(host: string, apiKey: string): Promise<MeResponse> {\n const url = `${host.replace(/\\/+$/, \"\")}/v1/me`;\n let res: Response;\n try {\n res = await fetch(url, { headers: { Authorization: `ApiKey ${apiKey}` } });\n } catch (e) {\n throw new AuthError(\n `Could not reach ${host} to verify your login: ${(e as Error).message}`,\n );\n }\n if (res.status === 401) {\n throw new AuthError(\n \"Invalid or revoked API key. Run `sonenta login` with a current key \" +\n \"(generate one in the dashboard at Org Settings → API Keys).\",\n );\n }\n if (!res.ok) {\n const text = await res.text().catch(() => \"\");\n throw new AuthError(`Unexpected ${res.status} from /v1/me: ${text.slice(0, 200)}`);\n }\n return (await res.json()) as MeResponse;\n}\n\n/** Throws an AuthError when the account is missing/invalid/inactive. */\nexport function assertActive(me: MeResponse): void {\n if (!me.valid) {\n throw new AuthError(\"Not logged in. Run `sonenta login` to authenticate.\");\n }\n if (!me.account_active) {\n throw new AuthError(\n \"Account inactive — reactivate your subscription in the Sonenta dashboard \" +\n \"to use this command.\",\n );\n }\n}\n\n/**\n * Resolve the request context AND verify the caller is logged in with an active\n * account. Drop-in for `resolveContext` in value commands: same `ApiContext`\n * return, plus the `/v1/me` gate. Throws an actionable AuthError otherwise.\n */\nexport async function requireAuth(opts: ResolveOptions = {}): Promise<ApiContext> {\n let ctx: ApiContext;\n try {\n ctx = await resolveContext(opts);\n } catch (e) {\n // resolveContext's own errors already point at `sonenta login`.\n throw new AuthError((e as Error).message);\n }\n assertActive(await fetchMe(ctx.host, ctx.apiKey));\n return ctx;\n}\n","import { promises as fs } from \"node:fs\";\nimport { join } from \"node:path\";\n\nimport { Command } from \"commander\";\n\nimport { type ApiContext } from \"../api.js\";\nimport { requireAuth } from \"../auth.js\";\nimport { type FlatMap, sortDeep, unflatten } from \"../i18next_tree.js\";\nimport { getProjectInfo, listKeys } from \"../mcp.js\";\n\n/** language_code -> namespace_slug -> flat map of key -> value. */\ntype Collected = Record<string, Record<string, FlatMap>>;\n\nasync function collect(\n ctx: ApiContext,\n languages: string[],\n namespace?: string,\n): Promise<Collected> {\n const out: Collected = {};\n for (const lang of languages) {\n const items = await listKeys(ctx, { languageCode: lang, namespace });\n for (const it of items) {\n const tr = it.translations?.find((t) => t.language_code === lang);\n if (!tr || tr.value === \"\") continue;\n (out[lang] ??= {})[it.namespace_slug] ??= {};\n out[lang]![it.namespace_slug]![it.key_name] = tr.value;\n }\n }\n return out;\n}\n\nexport const exportCommand = new Command(\"export\")\n .description(\n \"Export Verbumia translations as i18next JSON. Flat dot-notation by \" +\n \"default (--nested for nested trees). Writes <out>/<lang>/<namespace>.json \" +\n \"with --out, otherwise prints { locale: { namespace: tree } } to stdout.\",\n )\n .option(\"--language <code>\", \"Restrict to a single language code\")\n .option(\"--namespace <slug>\", \"Restrict to a single namespace slug\")\n .option(\"--nested\", \"Emit nested JSON instead of flat dot-notation\", false)\n .option(\"--out <dir>\", \"Write files instead of printing to stdout\")\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (opts: {\n language?: string;\n namespace?: string;\n nested: boolean;\n out?: string;\n host?: string;\n }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const languages = opts.language ? [opts.language] : (await getProjectInfo(ctx)).languages;\n const collected = await collect(ctx, languages, opts.namespace);\n const shape = (flat: FlatMap): unknown => (opts.nested ? sortDeep(unflatten(flat)) : sortDeep(flat));\n\n if (opts.out) {\n let files = 0;\n for (const [lang, nss] of Object.entries(collected)) {\n for (const [ns, flat] of Object.entries(nss)) {\n const dir = join(opts.out, lang);\n await fs.mkdir(dir, { recursive: true });\n const p = join(dir, `${ns}.json`);\n await fs.writeFile(p, JSON.stringify(shape(flat), null, 2) + \"\\n\", \"utf8\");\n console.log(` ${p} ${Object.keys(flat).length} keys`);\n files++;\n }\n }\n console.log(`exported ${files} file(s)`);\n return;\n }\n\n const tree: Record<string, Record<string, unknown>> = {};\n for (const [lang, nss] of Object.entries(collected)) {\n tree[lang] = {};\n for (const [ns, flat] of Object.entries(nss)) tree[lang]![ns] = shape(flat);\n }\n process.stdout.write(JSON.stringify(tree, null, 2) + \"\\n\");\n },\n );\n","/**\n * i18next tree <-> flat-map helpers.\n *\n * Verbumia stores keys as flat dot-notation (`hero.title`). i18next files on\n * disk are commonly nested (`{hero:{title:..}}`). The one-shot import endpoint\n * accepts BOTH, so `import` passes trees through untouched — these helpers are\n * for the OUTPUT side (export/snapshot) where we choose flat or nested.\n */\n\nexport type FlatMap = Record<string, string>;\nexport type Tree = Record<string, unknown>;\n\n/** Expand dot-notation flat keys into a nested tree. */\nexport function unflatten(flat: FlatMap, sep = \".\"): Tree {\n const root: Tree = {};\n for (const [k, v] of Object.entries(flat)) {\n const parts = k.split(sep);\n let node: Tree = root;\n for (let i = 0; i < parts.length - 1; i++) {\n const p = parts[i]!;\n const existing = node[p];\n if (typeof existing !== \"object\" || existing === null) node[p] = {};\n node = node[p] as Tree;\n }\n node[parts[parts.length - 1]!] = v;\n }\n return root;\n}\n\n/** Flatten a nested tree to dot-notation (string leaves only). */\nexport function flatten(tree: Tree, sep = \".\"): FlatMap {\n const out: FlatMap = {};\n const walk = (node: unknown, prefix: string): void => {\n if (!node || typeof node !== \"object\" || Array.isArray(node)) return;\n for (const [k, v] of Object.entries(node as Tree)) {\n const key = prefix ? `${prefix}${sep}${k}` : k;\n if (v && typeof v === \"object\" && !Array.isArray(v)) walk(v, key);\n else if (typeof v === \"string\") out[key] = v;\n }\n };\n walk(tree, \"\");\n return out;\n}\n\n/** Recursively sort object keys for deterministic, diff-friendly output. */\nexport function sortDeep<T>(value: T): T {\n if (Array.isArray(value)) return value.map((v) => sortDeep(v)) as unknown as T;\n if (value && typeof value === \"object\") {\n const src = value as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n for (const k of Object.keys(src).sort((a, b) => a.localeCompare(b))) out[k] = sortDeep(src[k]);\n return out as T;\n }\n return value;\n}\n","/**\n * MCP-surface client helpers.\n *\n * The whole CLI talks to the metered, key-addressable MCP surface\n * `/v1/mcp/projects/{project_id}/...` (auth = an API key carrying the `mcp:*`\n * scope). That surface addresses keys/namespaces/languages by NAME (no uuids),\n * exposes bulk + one-shot endpoints, and is the contract-blessed automation\n * entrypoint. These helpers wrap the endpoints the commands consume.\n */\n\nimport { type ApiContext, apiRequest } from \"./api.js\";\n\nexport function requireProject(ctx: ApiContext): string {\n if (!ctx.projectUuid) {\n throw new Error(\n \"no project configured — run `sonenta init --project <uuid>` \" +\n \"(or set project_uuid in sonenta.config.json).\",\n );\n }\n return ctx.projectUuid;\n}\n\nfunction projectBase(ctx: ApiContext): string {\n return `/v1/mcp/projects/${requireProject(ctx)}`;\n}\n\n// ---- projects ------------------------------------------------------------\n\nexport interface ProjectSummary {\n uuid: string;\n name?: string;\n slug?: string;\n source_language?: string;\n}\n\nexport async function listProjects(ctx: ApiContext, limit = 200): Promise<ProjectSummary[]> {\n const data = await apiRequest<{ items: ProjectSummary[] }>(\n ctx,\n `/v1/mcp/projects?limit=${limit}`,\n );\n return data.items ?? [];\n}\n\nexport interface ProjectInfo {\n source_language: string;\n languages: string[];\n namespaces: string[];\n}\n\n/** Normalises get_project_info into plain code/slug lists (shape-tolerant). */\nexport async function getProjectInfo(ctx: ApiContext): Promise<ProjectInfo> {\n const d = await apiRequest<Record<string, unknown>>(ctx, projectBase(ctx));\n const src =\n typeof d.source_language === \"string\"\n ? d.source_language\n : (d.source_language as { code?: string })?.code ?? \"\";\n const langs = Array.isArray(d.languages)\n ? (d.languages as unknown[]).map((l) =>\n typeof l === \"string\" ? l : ((l as { code?: string }).code ?? \"\"),\n )\n : [];\n const ns = Array.isArray(d.namespaces)\n ? (d.namespaces as unknown[]).map((n) =>\n typeof n === \"string\" ? n : ((n as { slug?: string }).slug ?? \"\"),\n )\n : [];\n return {\n source_language: src,\n languages: langs.filter(Boolean),\n namespaces: ns.filter(Boolean),\n };\n}\n\n// ---- keys (paginated list) ----------------------------------------------\n\nexport interface KeyTranslation {\n language_code: string;\n value: string;\n status: string;\n}\n\nexport interface KeyItem {\n key_name: string;\n namespace_slug: string;\n source_value: string | null;\n translations?: KeyTranslation[];\n}\n\nexport async function listKeys(\n ctx: ApiContext,\n opts: { languageCode?: string; namespace?: string } = {},\n): Promise<KeyItem[]> {\n const out: KeyItem[] = [];\n let cursor: string | null = null;\n do {\n const params = new URLSearchParams({ limit: \"200\" });\n if (opts.languageCode) params.set(\"language_code\", opts.languageCode);\n if (opts.namespace) params.set(\"namespace\", opts.namespace);\n if (cursor) params.set(\"cursor\", cursor);\n const page = await apiRequest<{ items: KeyItem[]; cursor_next: string | null }>(\n ctx,\n `${projectBase(ctx)}/keys?${params.toString()}`,\n );\n out.push(...(page.items ?? []));\n cursor = page.cursor_next ?? null;\n } while (cursor);\n return out;\n}\n\n// ---- i18next one-shot import --------------------------------------------\n\nexport type I18nextTree = Record<string, unknown>;\n\nexport interface ImportNamespaceUnit {\n namespace: string;\n translations: Record<string, I18nextTree>; // language_code -> i18next tree (nested or flat)\n}\n\nexport interface ImportBody {\n namespaces: ImportNamespaceUnit[];\n version?: string;\n status?: \"draft\" | \"translated\";\n}\n\nexport interface ImportBundleReport {\n project_uuid: string;\n version_slug: string;\n keys_created: number;\n keys_reused: number;\n translations_created: number;\n translations_updated: number;\n translations_unchanged: number;\n plural_keys_marked: number;\n units?: unknown[];\n errors?: { namespace: string; language_code: string; code: string }[];\n glossary_violation_count?: number;\n glossary_violations?: {\n namespace: string;\n language_code: string;\n key: string;\n rule_type: string;\n term: string;\n matched_text?: string;\n message?: string;\n }[];\n}\n\nexport async function importBundle(ctx: ApiContext, body: ImportBody): Promise<ImportBundleReport> {\n return apiRequest<ImportBundleReport>(ctx, `${projectBase(ctx)}/i18next/import`, {\n method: \"POST\",\n body: JSON.stringify(body),\n });\n}\n\n// ---- CDN releases (publish) ---------------------------------------------\n\nexport interface PublishCdnBody {\n language_code?: string;\n namespace?: string;\n version_slug?: string;\n}\n\nexport async function publishCdn(ctx: ApiContext, body: PublishCdnBody): Promise<unknown> {\n return apiRequest(ctx, `${projectBase(ctx)}/cdn/releases`, {\n method: \"POST\",\n body: JSON.stringify(body),\n });\n}\n\n// ---- formatting ----------------------------------------------------------\n\n/** Human-readable lines for an ImportBundleReport (created/updated/unchanged). */\nexport function summariseImport(r: ImportBundleReport): string[] {\n const lines = [\n `keys: ${r.keys_created} created, ${r.keys_reused} reused`,\n `translations: ${r.translations_created} created, ${r.translations_updated} updated, ${r.translations_unchanged} unchanged`,\n ];\n if (r.plural_keys_marked) lines.push(`plural keys: ${r.plural_keys_marked} marked`);\n if (r.errors?.length) {\n lines.push(`errors: ${r.errors.length}`);\n for (const e of r.errors) lines.push(` ! ${e.namespace}/${e.language_code}: ${e.code}`);\n }\n if (r.glossary_violations?.length) {\n lines.push(`glossary: ${r.glossary_violations.length} violation(s)`);\n for (const g of r.glossary_violations) {\n lines.push(` ⚠ ${g.namespace}/${g.language_code} ${g.key}: ${g.rule_type} \"${g.term}\"`);\n }\n }\n return lines;\n}\n","import { promises as fs } from \"node:fs\";\nimport { basename, dirname } from \"node:path\";\n\nimport { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { type I18nextTree, type ImportBody, importBundle, summariseImport } from \"../mcp.js\";\n\n/**\n * Resolve (language, namespace) for a file.\n * - explicit --language / --namespace always win;\n * - otherwise infer from the i18next layout `<lang>/<namespace>.json`\n * (parent dir = language, filename stem = namespace);\n * - a bare `<lang>.json` (no language dir) uses the stem as the language and\n * REQUIRES --namespace.\n */\nexport function resolveLangNs(\n filePath: string,\n optLang?: string,\n optNs?: string,\n): { lang: string; ns: string } {\n const stem = basename(filePath).replace(/\\.json$/i, \"\");\n const parent = basename(dirname(filePath));\n const hasLangDir = parent !== \"\" && parent !== \".\" && parent !== \"locales\";\n const lang = optLang ?? (hasLangDir ? parent : stem);\n const ns = optNs ?? (hasLangDir ? stem : undefined);\n if (!lang) throw new Error(`could not infer a language for ${filePath} — pass --language`);\n if (!ns) {\n throw new Error(\n `could not infer a namespace for ${filePath} — pass --namespace, ` +\n \"or lay files out as <lang>/<namespace>.json\",\n );\n }\n return { lang, ns };\n}\n\nasync function readTree(filePath: string): Promise<I18nextTree> {\n const parsed = JSON.parse(await fs.readFile(filePath, \"utf8\"));\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new Error(`${filePath} is not a JSON object`);\n }\n return parsed as I18nextTree;\n}\n\nfunction countLeaves(tree: I18nextTree): number {\n let n = 0;\n for (const v of Object.values(tree)) {\n if (v && typeof v === \"object\" && !Array.isArray(v)) n += countLeaves(v as I18nextTree);\n else n += 1;\n }\n return n;\n}\n\nexport const importCommand = new Command(\"import\")\n .description(\n \"Import i18next JSON file(s) into Verbumia in ONE call — creates missing \" +\n \"keys and upserts translations (idempotent). Accepts nested or flat JSON. \" +\n \"Language/namespace are inferred from the path (<lang>/<namespace>.json) \" +\n \"or forced with --language / --namespace.\",\n )\n .argument(\"<files...>\", \"i18next JSON file(s), e.g. locales/fr/common.json or fr.json\")\n .option(\"--language <code>\", \"Force the language code for every file\")\n .option(\"--namespace <slug>\", \"Force the namespace slug for every file\")\n .option(\"--status <status>\", \"draft | translated (default: translated)\")\n .option(\"--version <slug>\", \"Target version slug (default: production version)\")\n .option(\"--dry-run\", \"Print what would be imported without sending\", false)\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (\n files: string[],\n opts: {\n language?: string;\n namespace?: string;\n status?: string;\n version?: string;\n dryRun: boolean;\n host?: string;\n },\n ) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n\n // namespace -> language_code -> tree\n const byNs = new Map<string, Record<string, I18nextTree>>();\n let totalLeaves = 0;\n for (const f of files) {\n const { lang, ns } = resolveLangNs(f, opts.language, opts.namespace);\n const tree = await readTree(f);\n totalLeaves += countLeaves(tree);\n const langs = byNs.get(ns) ?? {};\n if (langs[lang]) {\n throw new Error(`two input files map to namespace=${ns} language=${lang} — merge them first`);\n }\n langs[lang] = tree;\n byNs.set(ns, langs);\n console.log(` ${f} -> ${ns} / ${lang}`);\n }\n\n const body: ImportBody = {\n namespaces: [...byNs.entries()].map(([namespace, translations]) => ({\n namespace,\n translations,\n })),\n };\n if (opts.status === \"draft\" || opts.status === \"translated\") body.status = opts.status;\n if (opts.version) body.version = opts.version;\n\n if (opts.dryRun) {\n console.log(\n `\\n(dry-run) would import ${totalLeaves} value(s) across ${body.namespaces.length} ` +\n \"namespace(s); nothing sent.\",\n );\n return;\n }\n\n const report = await importBundle(ctx, body);\n console.log(\"\");\n for (const line of summariseImport(report)) console.log(line);\n if (report.errors?.length || report.glossary_violations?.length) process.exitCode = 1;\n },\n );\n","import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nimport { Command } from \"commander\";\n\nimport { CONFIG_FILENAME, writeConfig } from \"../config.js\";\n\nexport const initCommand = new Command(\"init\")\n .description(\"Scaffold a sonenta.config.json in the current directory.\")\n .option(\"--host <url>\", \"API base URL\", \"https://api.sonenta.com\")\n .option(\"--project <uuid>\", \"Project UUID\")\n .option(\"--version <slug>\", \"Version slug (default: main)\", \"main\")\n .option(\"--force\", \"Overwrite an existing sonenta.config.json\", false)\n .action(\n async (opts: { host: string; project?: string; version: string; force: boolean }) => {\n const path = resolve(process.cwd(), CONFIG_FILENAME);\n if (existsSync(path) && !opts.force) {\n console.error(\n `${CONFIG_FILENAME} already exists at ${path}. Pass --force to overwrite.`,\n );\n process.exit(1);\n }\n const written = await writeConfig({\n host: opts.host,\n project_uuid: opts.project,\n version_slug: opts.version,\n });\n console.log(`Wrote ${written}`);\n if (!opts.project) {\n console.log(\n \"Tip: pass --project <uuid> to bind this directory to a specific project \" +\n \"(or edit project_uuid in the file later).\",\n );\n }\n },\n );\n","import { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { listKeys } from \"../mcp.js\";\n\nexport const keysCommand = new Command(\"keys\")\n .description(\"Inspect translation keys for the current project.\")\n .addCommand(\n new Command(\"list\")\n .description(\"List keys for the configured project (addressed by namespace slug + key name).\")\n .option(\"--namespace <slug>\", \"Filter by namespace slug\")\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(async (opts: { namespace?: string; host?: string }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const items = await listKeys(ctx, { namespace: opts.namespace });\n console.log(`total: ${items.length}`);\n for (const k of items) console.log(` ${k.namespace_slug}/${k.key_name}`);\n }),\n );\n","import { Command } from \"commander\";\n\nimport { fetchMe } from \"../auth.js\";\nimport { setHostEntry } from \"../credentials.js\";\nimport { promptLine, promptSecret } from \"../prompt.js\";\n\nconst TOKEN_REGEX = /^vrb_[a-z]+_[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$/;\n\nexport const loginCommand = new Command(\"login\")\n .description(\n \"Store an API key for a host. Token resolution order: --token, \" +\n \"SONENTA_TOKEN env, then interactive prompt (TTY only).\",\n )\n .option(\"--host <url>\", \"API base URL\", \"https://api.sonenta.com\")\n .option(\"--token <vrb_live_…>\", \"API key token (prefix.secret form)\")\n .option(\"--email <email>\", \"User email associated with the token (optional)\")\n .option(\"--default\", \"Set this host as the default for future commands\", false)\n .action(async (opts: { host: string; token?: string; email?: string; default?: boolean }) => {\n let host = opts.host;\n if (!host && process.stdin.isTTY) {\n host = (await promptLine(\"Host (default https://api.sonenta.com): \")) || \"https://api.sonenta.com\";\n }\n let token = opts.token ?? (process.env.SONENTA_TOKEN ?? process.env.VERBUMIA_TOKEN) ?? \"\";\n if (!token && process.stdin.isTTY) {\n token = await promptSecret(`API token for ${host}: `);\n }\n if (!token) {\n console.error(\n \"sonenta login: token required. Pass --token, set SONENTA_TOKEN, or run from a TTY for the interactive prompt.\",\n );\n process.exit(1);\n }\n if (!TOKEN_REGEX.test(token)) {\n console.error(\n \"sonenta login: token shape doesn't match `vrb_<env>_<prefix>.<secret>`. \" +\n \"Generate one in the dashboard at Org Settings → API Keys.\",\n );\n process.exit(1);\n }\n // Validate the key against the API + check the account is active BEFORE\n // storing — a key that 401s or an inactive account never gets persisted.\n let me;\n try {\n me = await fetchMe(host, token);\n } catch (err) {\n console.error(`sonenta login: ${err instanceof Error ? err.message : err}`);\n process.exit(1);\n }\n if (!me.valid) {\n console.error(\"sonenta login: API key was rejected. Generate a current key in the dashboard.\");\n process.exit(1);\n }\n if (!me.account_active) {\n console.error(\n \"sonenta login: your account is inactive — reactivate your subscription in the \" +\n \"Sonenta dashboard, then log in again. (Key not stored.)\",\n );\n process.exit(1);\n }\n await setHostEntry(\n host,\n { api_key: token, user_email: opts.email ?? me.email },\n { makeDefault: opts.default },\n );\n const who = me.email ?? \"your account\";\n const org = me.org_name ? ` (${me.org_name})` : \"\";\n console.log(`Logged in as ${who}${org} on ${host}.`);\n });\n","import { createInterface } from \"node:readline\";\n\n/**\n * Read a line from stdin. Used for interactive prompts when --token / --host\n * aren't passed on the CLI. Returns \"\" if stdin isn't a TTY (so tests + piped\n * usage don't hang waiting for input that will never arrive).\n */\nexport async function promptLine(message: string): Promise<string> {\n if (!process.stdin.isTTY) return \"\";\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n try {\n return await new Promise<string>((resolve) => {\n rl.question(message, (answer) => resolve(answer.trim()));\n });\n } finally {\n rl.close();\n }\n}\n\nconst CTRL_C = 0x03;\nconst BACKSPACE = 0x08;\nconst DEL = 0x7f;\nconst CR = 0x0d;\nconst LF = 0x0a;\n\n/**\n * Same as promptLine but masks each echoed character with `*`. If stdin\n * isn't a TTY we return \"\" rather than echoing the secret.\n */\nexport async function promptSecret(message: string): Promise<string> {\n if (!process.stdin.isTTY) return \"\";\n process.stdout.write(message);\n process.stdin.setRawMode(true);\n process.stdin.resume();\n return await new Promise<string>((resolve) => {\n let buffer = \"\";\n const onData = (chunk: Buffer): void => {\n for (const byte of chunk) {\n if (byte === CR || byte === LF) {\n process.stdout.write(\"\\n\");\n process.stdin.removeListener(\"data\", onData);\n process.stdin.setRawMode(false);\n process.stdin.pause();\n resolve(buffer);\n return;\n }\n if (byte === CTRL_C) {\n process.stdout.write(\"\\n\");\n process.stdin.removeListener(\"data\", onData);\n process.stdin.setRawMode(false);\n process.stdin.pause();\n process.exit(130);\n }\n if (byte === BACKSPACE || byte === DEL) {\n if (buffer.length > 0) {\n buffer = buffer.slice(0, -1);\n process.stdout.write(\"\\b \\b\");\n }\n continue;\n }\n buffer += String.fromCharCode(byte);\n process.stdout.write(\"*\");\n }\n };\n process.stdin.on(\"data\", onData);\n });\n}\n","import { Command } from \"commander\";\n\nimport { readCredentials, removeHost } from \"../credentials.js\";\n\nexport const logoutCommand = new Command(\"logout\")\n .description(\"Remove stored credentials for a host (default: the current default host).\")\n .option(\"--host <url>\", \"Host to forget. Omit to forget the current default.\")\n .action(async (opts: { host?: string }) => {\n const creds = await readCredentials();\n const target = opts.host ?? creds.default;\n if (!target) {\n console.log(\"Nothing to forget — no credentials stored.\");\n return;\n }\n const removed = await removeHost(target);\n if (!removed) {\n console.log(`No credentials stored for ${target}.`);\n return;\n }\n console.log(`Forgot credentials for ${target}.`);\n });\n","import { Command } from \"commander\";\n\nimport { apiRequest } from \"../api.js\";\nimport { requireAuth } from \"../auth.js\";\n\ninterface MissingKey {\n uuid: string;\n namespace_slug: string;\n language_code: string;\n key: string;\n source_value: string | null;\n count: number;\n status: string;\n first_seen: string;\n last_seen: string;\n}\n\ninterface MissingKeysPage {\n items: MissingKey[];\n cursor_next: string | null;\n total: number;\n}\n\nexport const missingCommand = new Command(\"missing\")\n .description(\n \"List runtime-detected missing keys for the configured project. Requires \" +\n \"the API key to carry the `mcp:*` scope.\",\n )\n .option(\"--namespace <slug>\", \"Filter by namespace slug\")\n .option(\"--language <code>\", \"Filter by language code\")\n .option(\"--status <state>\", \"Filter by status (open|resolved|...)\")\n .option(\"--limit <n>\", \"Page size (1-200, default 50)\", \"50\")\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (opts: {\n namespace?: string;\n language?: string;\n status?: string;\n limit: string;\n host?: string;\n }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n if (!ctx.projectUuid) {\n console.error(\n \"sonenta missing: no project_uuid configured. Run `sonenta init --project <uuid>`.\",\n );\n process.exit(1);\n }\n const params = new URLSearchParams();\n params.set(\"limit\", opts.limit);\n if (opts.namespace) params.set(\"namespace\", opts.namespace);\n if (opts.language) params.set(\"language_code\", opts.language);\n if (opts.status) params.set(\"status\", opts.status);\n const page = await apiRequest<MissingKeysPage>(\n ctx,\n `/v1/mcp/projects/${ctx.projectUuid}/missing-keys?${params.toString()}`,\n );\n console.log(`total: ${page.total}`);\n for (const m of page.items) {\n const sample = m.source_value ? ` ⟶ \"${m.source_value}\"` : \"\";\n console.log(\n ` ${m.namespace_slug}/${m.key} (${m.language_code}, count=${m.count}, ${m.status})${sample}`,\n );\n }\n if (page.cursor_next) {\n console.log(`(more — re-run with --cursor ${page.cursor_next})`);\n }\n },\n );\n","import { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { listProjects } from \"../mcp.js\";\n\nexport const projectsCommand = new Command(\"projects\")\n .description(\"Inspect Verbumia projects accessible to your API key.\")\n .addCommand(\n new Command(\"list\")\n .description(\"List the projects this API key can reach.\")\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(async (opts: { host?: string }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const items = await listProjects(ctx);\n if (items.length === 0) {\n console.log(\"No projects visible to this key (scoped or revoked?).\");\n return;\n }\n for (const p of items) {\n const slug = p.slug ? ` ${p.slug}` : \"\";\n const src = p.source_language ? ` src=${p.source_language}` : \"\";\n console.log(` ${p.uuid}${slug} ${p.name ?? \"\"}${src}`);\n }\n }),\n );\n","import { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { DEFAULT_LOCALES_DIR, type FlatTranslations, writeLocaleFile } from \"../locales.js\";\nimport { getProjectInfo, listKeys } from \"../mcp.js\";\n\nexport const pullCommand = new Command(\"pull\")\n .description(\n \"Pull translations from Verbumia into locales/<lang>/<namespace>.json \" +\n \"(flat dot-notation). Overwrites local files — pair with `git status`.\",\n )\n .option(\"--language <code>\", \"Restrict to a single language code\")\n .option(\"--namespace <slug>\", \"Restrict to a single namespace slug\")\n .option(\"--dest <dir>\", \"Output directory\", DEFAULT_LOCALES_DIR)\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (opts: { language?: string; namespace?: string; dest: string; host?: string }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n let languages: string[];\n if (opts.language) {\n languages = [opts.language];\n } else {\n languages = (await getProjectInfo(ctx)).languages;\n if (languages.length === 0) {\n console.error(\"sonenta pull: the project reports no languages.\");\n process.exit(1);\n }\n }\n\n let totalKeys = 0;\n let totalFiles = 0;\n for (const lang of languages) {\n const items = await listKeys(ctx, { languageCode: lang, namespace: opts.namespace });\n const byNs = new Map<string, FlatTranslations>();\n for (const it of items) {\n const tr = it.translations?.find((t) => t.language_code === lang);\n if (!tr || tr.value === \"\") continue;\n const map = byNs.get(it.namespace_slug) ?? {};\n map[it.key_name] = tr.value;\n byNs.set(it.namespace_slug, map);\n }\n for (const [ns, map] of byNs) {\n const path = await writeLocaleFile(opts.dest, lang, ns, map);\n totalKeys += Object.keys(map).length;\n totalFiles++;\n console.log(` ${path} ${Object.keys(map).length} keys`);\n }\n }\n console.log(`pulled ${totalKeys} translation(s) across ${totalFiles} file(s)`);\n },\n );\n","import { promises as fs } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\n\n/**\n * On-disk locales layout. V1 is flat: one JSON per (lang, namespace) under\n * the configured locales directory:\n *\n * locales/\n * en/\n * common.json // { \"hello.title\": \"Hello\", ... }\n * errors.json\n * fr/\n * common.json\n *\n * Keys inside each file are flat dot-notation, NOT nested objects. This\n * matches the editor surface 1:1 and keeps push/pull idempotent.\n */\n\nexport const DEFAULT_LOCALES_DIR = \"locales\";\n\nexport type FlatTranslations = Record<string, string>;\n\nexport async function listLocaleFiles(\n rootDir: string,\n): Promise<{ lang: string; namespace: string; path: string }[]> {\n const root = resolve(rootDir);\n let langDirs: string[];\n try {\n langDirs = await fs.readdir(root);\n } catch {\n return [];\n }\n const out: { lang: string; namespace: string; path: string }[] = [];\n for (const lang of langDirs) {\n const langPath = join(root, lang);\n let stat;\n try {\n stat = await fs.stat(langPath);\n } catch {\n continue;\n }\n if (!stat.isDirectory()) continue;\n const files = await fs.readdir(langPath);\n for (const f of files) {\n if (!f.endsWith(\".json\")) continue;\n out.push({ lang, namespace: f.replace(/\\.json$/, \"\"), path: join(langPath, f) });\n }\n }\n return out;\n}\n\nexport async function readLocaleFile(path: string): Promise<FlatTranslations> {\n const raw = await fs.readFile(path, \"utf8\");\n const parsed = JSON.parse(raw);\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new Error(`${path} is not a flat object`);\n }\n const out: FlatTranslations = {};\n for (const [k, v] of Object.entries(parsed)) {\n if (typeof v !== \"string\") {\n throw new Error(`${path}: key \"${k}\" is not a string (V1 flat layout only)`);\n }\n out[k] = v;\n }\n return out;\n}\n\nexport async function writeLocaleFile(\n rootDir: string,\n lang: string,\n namespace: string,\n values: FlatTranslations,\n): Promise<string> {\n const dir = join(rootDir, lang);\n await fs.mkdir(dir, { recursive: true });\n const path = join(dir, `${namespace}.json`);\n // Sort keys for deterministic diffs.\n const sorted = Object.fromEntries(\n Object.entries(values).sort(([a], [b]) => a.localeCompare(b)),\n );\n await fs.writeFile(path, JSON.stringify(sorted, null, 2) + \"\\n\", \"utf8\");\n return path;\n}\n\nexport interface DiffResult {\n added: string[]; // local-only — push will create\n removed: string[]; // remote-only — push leaves alone (V1 doesn't delete)\n changed: { key: string; local: string; remote: string }[];\n unchanged: number;\n}\n\nexport function diffFlat(local: FlatTranslations, remote: FlatTranslations): DiffResult {\n const added: string[] = [];\n const removed: string[] = [];\n const changed: { key: string; local: string; remote: string }[] = [];\n let unchanged = 0;\n\n for (const [k, v] of Object.entries(local)) {\n if (!(k in remote)) {\n added.push(k);\n } else if (remote[k] !== v) {\n changed.push({ key: k, local: v, remote: remote[k]! });\n } else {\n unchanged++;\n }\n }\n for (const k of Object.keys(remote)) {\n if (!(k in local)) removed.push(k);\n }\n return { added, removed, changed, unchanged };\n}\n","import { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { DEFAULT_LOCALES_DIR, listLocaleFiles, readLocaleFile } from \"../locales.js\";\nimport { type ImportBody, importBundle, summariseImport } from \"../mcp.js\";\n\nexport const pushCommand = new Command(\"push\")\n .description(\n \"Push the whole local locales/ tree to Verbumia in ONE import call — \" +\n \"creates missing keys and upserts translations (idempotent). Reads \" +\n \"locales/<lang>/<namespace>.json (flat dot-notation).\",\n )\n .option(\"--language <code>\", \"Restrict to a single language code\")\n .option(\"--namespace <slug>\", \"Restrict to a single namespace slug\")\n .option(\"--src <dir>\", \"Locales directory\", DEFAULT_LOCALES_DIR)\n .option(\"--status <status>\", \"draft | translated (default: translated)\")\n .option(\"--version <slug>\", \"Target version slug (default: production version)\")\n .option(\"--dry-run\", \"Print what would be pushed without sending\", false)\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (opts: {\n language?: string;\n namespace?: string;\n src: string;\n status?: string;\n version?: string;\n dryRun: boolean;\n host?: string;\n }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const files = (await listLocaleFiles(opts.src)).filter((f) => {\n if (opts.language && f.lang !== opts.language) return false;\n if (opts.namespace && f.namespace !== opts.namespace) return false;\n return true;\n });\n if (files.length === 0) {\n console.log(`No locale files found under ${opts.src}/`);\n return;\n }\n\n // namespace -> language_code -> flat map\n const byNs = new Map<string, Record<string, Record<string, string>>>();\n let totalKeys = 0;\n for (const f of files) {\n const flat = await readLocaleFile(f.path);\n totalKeys += Object.keys(flat).length;\n const langs = byNs.get(f.namespace) ?? {};\n langs[f.lang] = flat;\n byNs.set(f.namespace, langs);\n console.log(` ${f.lang}/${f.namespace}.json ${Object.keys(flat).length} keys`);\n }\n\n const body: ImportBody = {\n namespaces: [...byNs.entries()].map(([namespace, translations]) => ({\n namespace,\n translations,\n })),\n };\n if (opts.status === \"draft\" || opts.status === \"translated\") body.status = opts.status;\n if (opts.version) body.version = opts.version;\n\n if (opts.dryRun) {\n console.log(\n `\\n(dry-run) would push ${totalKeys} key(s) across ${body.namespaces.length} ` +\n \"namespace(s); nothing sent.\",\n );\n return;\n }\n\n const report = await importBundle(ctx, body);\n console.log(\"\");\n for (const line of summariseImport(report)) console.log(line);\n if (report.errors?.length || report.glossary_violations?.length) process.exitCode = 1;\n },\n );\n","import { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { type PublishCdnBody, publishCdn } from \"../mcp.js\";\n\nexport const releasesCommand = new Command(\"releases\")\n .description(\"Manage CDN releases for the project.\")\n .addCommand(\n new Command(\"publish\")\n .description(\n \"Trigger a CDN release: build bundles for every (language, namespace) \" +\n \"and push them to the public CDN. Idempotent — unchanged bundles are \" +\n \"reused. Subscribed SDKs receive a live `translations_published` event.\",\n )\n .option(\"--language <code>\", \"Restrict to one language (default: all)\")\n .option(\"--namespace <slug>\", \"Restrict to one namespace (default: all)\")\n .option(\"--version <slug>\", \"Version slug (default: production version)\")\n .option(\"--dry-run\", \"Print the planned release without publishing\", false)\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (opts: {\n language?: string;\n namespace?: string;\n version?: string;\n dryRun: boolean;\n host?: string;\n }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const scope =\n [\n opts.language && `language=${opts.language}`,\n opts.namespace && `namespace=${opts.namespace}`,\n opts.version && `version=${opts.version}`,\n ]\n .filter(Boolean)\n .join(\", \") || \"ALL languages + namespaces\";\n\n if (opts.dryRun) {\n console.log(`(dry-run) would publish a CDN release for ${scope}; nothing sent.`);\n return;\n }\n\n const body: PublishCdnBody = {};\n if (opts.language) body.language_code = opts.language;\n if (opts.namespace) body.namespace = opts.namespace;\n if (opts.version) body.version_slug = opts.version;\n const res = await publishCdn(ctx, body);\n console.log(`published CDN release for ${scope}`);\n console.log(JSON.stringify(res, null, 2));\n },\n ),\n );\n","import { promises as fs } from \"node:fs\";\n\nimport { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { getProjectInfo, requireProject } from \"../mcp.js\";\n\ntype Tree = Record<string, unknown>;\ntype Bundles = Record<string, Record<string, Tree>>;\n\n/** Public CDN bundle URL — the exact path the SDK fetches at runtime. */\nexport function bundleUrl(\n cdnBase: string,\n project: string,\n version: string,\n lang: string,\n ns: string,\n): string {\n return `${cdnBase.replace(/\\/+$/, \"\")}/p/${project}/${version}/latest/${lang}/${ns}.json`;\n}\n\n/**\n * Render the snapshot module. The SDK (#757) reads `initialBundles` as the PURE\n * `Record<locale, Record<namespace, tree>>` map, so provenance lives in a\n * SEPARATE `meta` export — never mixed into `bundles` (otherwise the SDK would\n * treat `version`/`project` as locales).\n */\nexport function renderSnapshot(\n bundles: Bundles,\n meta: { project: string; version: string; cdn: string },\n format: \"ts\" | \"json\",\n): string {\n const json = JSON.stringify(bundles, null, 2);\n if (format === \"json\") return json + \"\\n\";\n return (\n \"// Generated by `sonenta snapshot` — do not edit by hand.\\n\" +\n \"// Build-time fallback for @sonenta/react-i18next:\\n\" +\n '// import { bundles } from \"./<this-file>\";\\n' +\n \"// <VerbumiaProvider initialBundles={bundles} />\\n\" +\n `export const bundles = ${json} as const;\\n\\n` +\n `export const meta = ${JSON.stringify(meta, null, 2)} as const;\\n\\n` +\n \"export default bundles;\\n\"\n );\n}\n\nasync function fetchBundle(url: string): Promise<Tree | null> {\n const res = await fetch(url, { headers: { Accept: \"application/json\" } });\n if (res.status === 404) return null; // bundle not published for this (lang, ns)\n if (!res.ok) throw new Error(`HTTP ${res.status} fetching ${url}`);\n return (await res.json()) as Tree;\n}\n\nexport const snapshotCommand = new Command(\"snapshot\")\n .description(\n \"Generate a build-time translations snapshot for @sonenta/react-i18next \" +\n \"`initialBundles` (offline-first fallback). Fetches the PUBLIC CDN bundles \" +\n \"(exactly what the SDK loads at runtime) and assembles \" +\n \"Record<locale, Record<namespace, tree>>. Emits a .ts module (default) or .json.\",\n )\n .option(\"--language <code>\", \"Restrict to a single language code\")\n .option(\"--namespace <slug>\", \"Restrict to a single namespace slug\")\n .option(\"--version <slug>\", \"Version slug (default: the configured version_slug)\")\n .option(\"--format <fmt>\", \"ts | json (default: ts)\", \"ts\")\n .option(\"--cdn <base>\", \"CDN base URL\", \"https://cdn.sonenta.com\")\n .option(\"--out <file>\", \"Write to a file instead of stdout\")\n .option(\"--host <url>\", \"Override host (used to discover languages/namespaces)\")\n .action(\n async (opts: {\n language?: string;\n namespace?: string;\n version?: string;\n format: string;\n cdn: string;\n out?: string;\n host?: string;\n }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const project = requireProject(ctx);\n const version = opts.version ?? ctx.versionSlug;\n\n // Enumerate (language, namespace). Both pinned => no project-info call.\n let languages: string[];\n let namespaces: string[];\n if (opts.language && opts.namespace) {\n languages = [opts.language];\n namespaces = [opts.namespace];\n } else {\n const info = await getProjectInfo(ctx);\n languages = opts.language ? [opts.language] : info.languages;\n namespaces = opts.namespace ? [opts.namespace] : info.namespaces;\n if (languages.length === 0 || namespaces.length === 0) {\n throw new Error(\n \"could not enumerate languages/namespaces from project-info — \" +\n \"pass --language and --namespace explicitly.\",\n );\n }\n }\n\n const bundles: Bundles = {};\n let fetched = 0;\n let missing = 0;\n for (const lang of languages) {\n for (const ns of namespaces) {\n const tree = await fetchBundle(bundleUrl(opts.cdn, project, version, lang, ns));\n if (!tree) {\n missing++;\n continue;\n }\n (bundles[lang] ??= {})[ns] = tree;\n fetched++;\n }\n }\n\n const output = renderSnapshot(\n bundles,\n { project, version, cdn: opts.cdn.replace(/\\/+$/, \"\") },\n opts.format === \"json\" ? \"json\" : \"ts\",\n );\n\n if (opts.out) {\n await fs.writeFile(opts.out, output, \"utf8\");\n console.log(\n `wrote ${opts.out}: ${fetched} bundle(s)` +\n (missing ? `, ${missing} not published (404)` : \"\"),\n );\n } else {\n process.stdout.write(output);\n if (missing) console.error(`(${missing} bundle(s) not published)`);\n }\n },\n );\n","import { Command } from \"commander\";\n\nimport { type ApiContext } from \"../api.js\";\nimport { requireAuth } from \"../auth.js\";\nimport {\n DEFAULT_LOCALES_DIR,\n diffFlat,\n type FlatTranslations,\n listLocaleFiles,\n readLocaleFile,\n} from \"../locales.js\";\nimport { getProjectInfo, listKeys } from \"../mcp.js\";\n\nexport const statusCommand = new Command(\"status\")\n .description(\"Diff local locales/ against the remote project state.\")\n .option(\"--language <code>\", \"Restrict to one language code\")\n .option(\"--namespace <slug>\", \"Restrict to one namespace slug\")\n .option(\"--src <dir>\", \"Locales directory\", DEFAULT_LOCALES_DIR)\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (opts: { language?: string; namespace?: string; src: string; host?: string }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const knownLangs = new Set((await getProjectInfo(ctx)).languages);\n\n const files = (await listLocaleFiles(opts.src)).filter((f) => {\n if (opts.language && f.lang !== opts.language) return false;\n if (opts.namespace && f.namespace !== opts.namespace) return false;\n return true;\n });\n\n // Fetch remote once per language, grouped by namespace slug.\n const remoteByLang = new Map<string, Map<string, FlatTranslations>>();\n async function remoteFor(ctx2: ApiContext, lang: string): Promise<Map<string, FlatTranslations>> {\n const cached = remoteByLang.get(lang);\n if (cached) return cached;\n const m = new Map<string, FlatTranslations>();\n for (const it of await listKeys(ctx2, { languageCode: lang })) {\n const tr = it.translations?.find((t) => t.language_code === lang);\n if (!tr || tr.value === \"\") continue;\n const map = m.get(it.namespace_slug) ?? {};\n map[it.key_name] = tr.value;\n m.set(it.namespace_slug, map);\n }\n remoteByLang.set(lang, m);\n return m;\n }\n\n let totalAdded = 0;\n let totalRemoved = 0;\n let totalChanged = 0;\n let totalUnchanged = 0;\n\n for (const f of files) {\n if (knownLangs.size > 0 && !knownLangs.has(f.lang)) {\n console.log(`! ${f.lang}/${f.namespace}.json — language not in project, skipped`);\n continue;\n }\n const local = await readLocaleFile(f.path);\n const remote = (await remoteFor(ctx, f.lang)).get(f.namespace) ?? {};\n const d = diffFlat(local, remote);\n totalAdded += d.added.length;\n totalRemoved += d.removed.length;\n totalChanged += d.changed.length;\n totalUnchanged += d.unchanged;\n\n if (d.added.length === 0 && d.removed.length === 0 && d.changed.length === 0) {\n console.log(`= ${f.lang}/${f.namespace}.json (in sync, ${d.unchanged} keys)`);\n continue;\n }\n console.log(\n `~ ${f.lang}/${f.namespace}.json +${d.added.length} -${d.removed.length} ~${d.changed.length}`,\n );\n for (const k of d.added) console.log(` + ${k}`);\n for (const k of d.removed) console.log(` - ${k} (remote-only — push leaves untouched)`);\n for (const c of d.changed) console.log(` ~ ${c.key} \"${c.local}\" <- \"${c.remote}\"`);\n }\n console.log(\n `summary: +${totalAdded} -${totalRemoved} ~${totalChanged} unchanged=${totalUnchanged}`,\n );\n },\n );\n","import { Command } from \"commander\";\n\nimport { readCredentials } from \"../credentials.js\";\n\nexport const whoamiCommand = new Command(\"whoami\")\n .description(\"Show the configured default host + which API key is in use.\")\n .option(\"--host <url>\", \"Inspect a specific host instead of the default\")\n .action(async (opts: { host?: string }) => {\n const creds = await readCredentials();\n if (!creds.default && Object.keys(creds.hosts).length === 0) {\n console.log(\"Not logged in. Run `sonenta login --host <url> --token <…>`.\");\n process.exit(1);\n }\n const target = opts.host ?? creds.default;\n if (!target) {\n console.log(\"No default host set.\");\n process.exit(1);\n }\n const entry = creds.hosts[target];\n if (!entry) {\n console.log(`No credentials stored for ${target}.`);\n process.exit(1);\n }\n const masked = entry.api_key.replace(/\\.[\\s\\S]+$/, \".•••\");\n const envOverride = (process.env.SONENTA_TOKEN ?? process.env.VERBUMIA_TOKEN)?.trim();\n console.log(`host: ${target}${target === creds.default ? \" (default)\" : \"\"}`);\n console.log(`api_key: ${masked}${envOverride ? \" (overridden by SONENTA_TOKEN env)\" : \"\"}`);\n if (entry.user_email) console.log(`email: ${entry.user_email}`);\n const others = Object.keys(creds.hosts).filter((h) => h !== target);\n if (others.length) {\n console.log(`other: ${others.join(\", \")}`);\n }\n });\n"],"mappings":";;;AAAA,SAAS,WAAAA,iBAAe;;;ACAxB,SAAS,eAAe;;;ACAxB,SAAS,YAAY,UAAU;AAC/B,SAAS,eAAe;AAejB,IAAM,aAAa;AAW1B,IAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AAgB,EAAE,EAAE;AAClF,UAAQ,IAAI,cAAc,MAAM,GAAG,cAAc,wCAAwC,EAAE,EAAE;AAC7F,MAAI,MAAM,WAAY,SAAQ,IAAI,cAAc,MAAM,UAAU,EAAE;AAClE,QAAM,SAAS,OAAO,KAAK,MAAM,KAAK,EAAE,OAAO,CAAC,MAAM,MAAM,MAAM;AAClE,MAAI,OAAO,QAAQ;AACjB,YAAQ,IAAI,cAAc,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,EAC/C;AACF,CAAC;;;AxBdH,IAAM,UAAU,IAAIC,UAAQ;AAC5B,QACG,KAAK,SAAS,EACd,YAAY,yCAAyC,EACrD,QAAQ,OAAO;AAElB,QAAQ,WAAW,YAAY;AAC/B,QAAQ,WAAW,aAAa;AAChC,QAAQ,WAAW,aAAa;AAChC,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,eAAe;AAClC,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,aAAa;AAChC,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,aAAa;AAChC,QAAQ,WAAW,aAAa;AAChC,QAAQ,WAAW,eAAe;AAClC,QAAQ,WAAW,eAAe;AAClC,QAAQ,WAAW,cAAc;AACjC,QAAQ,WAAW,aAAa;AAEhC,QAAQ,WAAW,QAAQ,IAAI,EAAE,MAAM,CAAC,QAAiB;AACvD,UAAQ,MAAM,eAAe,QAAQ,IAAI,UAAU,GAAG;AACtD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["Command","fs","resolve","fs","fs","join","Command","Command","join","fs","fs","dirname","Command","dirname","fs","Command","resolve","Command","Command","resolve","Command","Command","Command","resolve","Command","Command","Command","Command","Command","Command","Command","Command","fs","join","resolve","Command","Command","Command","Command","Command","fs","Command","Command","fs","Command","Command","Command","Command","Command"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/commands/agents.ts","../src/agents.ts","../src/config.ts","../src/credentials.ts","../src/api.ts","../src/auth.ts","../src/commands/export.ts","../src/i18next_tree.ts","../src/mcp.ts","../src/commands/import.ts","../src/commands/init.ts","../src/repodoc.ts","../src/commands/keys.ts","../src/commands/login.ts","../src/prompt.ts","../src/commands/logout.ts","../src/commands/missing.ts","../src/commands/projects.ts","../src/commands/pull.ts","../src/locales.ts","../src/commands/push.ts","../src/commands/releases.ts","../src/commands/snapshot.ts","../src/commands/status.ts","../src/commands/whoami.ts"],"sourcesContent":["import { Command } from \"commander\";\n\nimport { agentsCommand } from \"./commands/agents.js\";\nimport { exportCommand } from \"./commands/export.js\";\nimport { importCommand } from \"./commands/import.js\";\nimport { initCommand } from \"./commands/init.js\";\nimport { keysCommand } from \"./commands/keys.js\";\nimport { loginCommand } from \"./commands/login.js\";\nimport { logoutCommand } from \"./commands/logout.js\";\nimport { missingCommand } from \"./commands/missing.js\";\nimport { projectsCommand } from \"./commands/projects.js\";\nimport { pullCommand } from \"./commands/pull.js\";\nimport { pushCommand } from \"./commands/push.js\";\nimport { releasesCommand } from \"./commands/releases.js\";\nimport { snapshotCommand } from \"./commands/snapshot.js\";\nimport { statusCommand } from \"./commands/status.js\";\nimport { whoamiCommand } from \"./commands/whoami.js\";\n\nconst program = new Command();\nprogram\n .name(\"sonenta\")\n .description(\"CLI for Sonenta translation management.\")\n .version(\"0.7.1\");\n\nprogram.addCommand(loginCommand);\nprogram.addCommand(logoutCommand);\nprogram.addCommand(whoamiCommand);\nprogram.addCommand(initCommand);\nprogram.addCommand(projectsCommand);\nprogram.addCommand(keysCommand);\nprogram.addCommand(importCommand);\nprogram.addCommand(pushCommand);\nprogram.addCommand(pullCommand);\nprogram.addCommand(exportCommand);\nprogram.addCommand(statusCommand);\nprogram.addCommand(releasesCommand);\nprogram.addCommand(snapshotCommand);\nprogram.addCommand(missingCommand);\nprogram.addCommand(agentsCommand);\n\nprogram.parseAsync(process.argv).catch((err: unknown) => {\n console.error(err instanceof Error ? err.message : err);\n process.exit(1);\n});\n","import { Command } from \"commander\";\n\nimport { AGENTS_DIR, isInstalled, listAgents, writeAgent } from \"../agents.js\";\nimport { requireAuth } from \"../auth.js\";\n\nexport const agentsCommand = new Command(\"agents\")\n .description(\"Install bundled Claude agents (e.g. sonenta-a11y) into .claude/agents/.\")\n .addCommand(\n new Command(\"list\")\n .description(\"List the bundled agents available to install.\")\n .option(\"--dir <path>\", \"Project directory (default: current directory)\")\n .action(async (opts: { dir?: string }) => {\n const baseDir = opts.dir;\n const agents = listAgents();\n console.log(`Available agents (${agents.length}):`);\n for (const a of agents) {\n const installed = await isInstalled(a.name, baseDir);\n const mark = installed ? \"✓ installed\" : \" not installed\";\n console.log(` ${a.name.padEnd(22)} ${mark}`);\n console.log(` ${a.summary}`);\n }\n console.log(`\\nInstall with: sonenta agents add <name>`);\n }),\n )\n .addCommand(\n new Command(\"add\")\n .description(\"Write a bundled agent definition into <dir>/.claude/agents/<name>.md.\")\n .argument(\"<name>\", \"Agent name (e.g. sonenta-a11y)\")\n .option(\"--dir <path>\", \"Project directory (default: current directory)\")\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .option(\"--force\", \"Overwrite an existing agent definition\", false)\n .action(async (name: string, opts: { dir?: string; host?: string; force: boolean }) => {\n // Gate: must be logged in with an active account to install an agent.\n await requireAuth({ hostOverride: opts.host });\n const path = await writeAgent(name, { baseDir: opts.dir, force: opts.force });\n console.log(`Wrote ${path}`);\n console.log(\n `\\nThe ${name} agent drives the Sonenta a11y MCP tools. Make sure the ` +\n `Sonenta MCP server is configured (npx -y @sonenta/mcp) with an ` +\n `mcp:* SONENTA_API_KEY, then use the agent in Claude Code or CI.`,\n );\n console.log(`Agent dir: ${AGENTS_DIR}/`);\n }),\n );\n","import { promises as fs } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\n/**\n * Installable Claude agents shipped with the CLI.\n *\n * `sonenta agents add <name>` writes a bundled agent definition into the\n * project's `.claude/agents/<name>.md` — the directory Claude Code reads\n * project-scoped subagents from. The agents drive the Sonenta a11y MCP tools\n * (from `@sonenta/mcp`) to audit and fix accessibility gaps; they work the same\n * interactively in Claude Code or headless in CI.\n *\n * The registry is intentionally simple (a name -> definition map) so more\n * agents can be added later without touching the command wiring.\n */\n\nexport const AGENTS_DIR = \".claude/agents\";\n\nexport interface AgentDef {\n /** File/agent name (no extension); the file is written as `<name>.md`. */\n name: string;\n /** One-line summary shown by `agents list`. */\n summary: string;\n /** Full agent definition (YAML frontmatter + system prompt). */\n content: string;\n}\n\nconst SONENTA_A11Y = `---\nname: sonenta-a11y\ndescription: Accessibility (a11y) auditor and fixer for Sonenta-managed i18n projects. Scans translation keys for WCAG gaps (missing aria-labels, images without alt text, hard-to-read copy, missing or untranslated a11y variants) and fixes them — generating the a11y text itself and writing it back through the Sonenta MCP tools at zero AI-credit cost. Use interactively in Claude Code or headless in CI.\n---\n\nYou are **sonenta-a11y**, an accessibility specialist for internationalized\nprojects managed with Sonenta. You turn an accessibility audit into concrete,\nreviewable fixes, operating through the Sonenta MCP server's a11y tools.\n\n## Cost model — generate LOCALLY first (this is the default)\nYou ARE a capable language model already running in the developer's session\n(Claude Code or CI), and that compute is already paid for. So **you write the\na11y values yourself, with your own reasoning, and persist them with\n\\`set_a11y_variant\\`** — which is plain CRUD and costs **zero Sonenta AI\ncredits**. Do NOT reach for the server-side AI tools\n(\\`generate_a11y_variant\\` / \\`translate_a11y_variants\\`) by default: those bill\nSonenta AI credits and exist only as an explicit fallback for very large volumes\nor when the developer specifically asks for server-side generation.\n\n## Requirements\n- The Sonenta MCP server (\\`@sonenta/mcp\\`) must be configured with an \\`mcp:*\\`\n API key. Every operation goes through its tools — never call the HTTP API\n directly. If the a11y tools are missing, tell the user to add the server\n (\\`npx -y @sonenta/mcp\\`) and set \\`SONENTA_API_KEY\\`.\n- Tools:\n - \\`a11y_report\\` — full WCAG gap report (rollups + per-item gaps). READ-ONLY.\n - \\`list_a11y_gaps\\` — the actionable gap list, filterable by gap / surface /\n locale. READ-ONLY.\n - \\`set_a11y_variant\\` — **your primary write**: upsert one a11y variant for\n (key_uuid, language_code, surface) with a text value. CRUD, **0 AI credits**,\n stored as a draft.\n - \\`delete_a11y_variant\\` — clear one variant. CRUD, **0 AI credits**.\n - \\`list_cognitive_candidates\\` — text keys eligible for plain-language scoring\n (a type offering plain_language, past a word floor). READ-ONLY.\n - \\`set_cognitive_score\\` — record a key's cognitive difficulty score (0-100)\n plus a plain-language suggestion. CRUD, **0 AI credits** (by_bot).\n - \\`list_keys\\` — read each key's semantic \\`type\\` (and source value) to audit\n typing. READ-ONLY.\n - \\`update_key\\` / \\`update_keys_bulk\\` — reclassify a mis-typed key (type-only,\n no source_value). CRUD, 0 AI credits. Correct types are what make the a11y\n gaps surface.\n - \\`a11y_estimate\\` — preview the AI-credit cost of the server-side fallback.\n - \\`generate_a11y_variant\\` / \\`translate_a11y_variants\\` / \\`analyze_cognitive\\`\n — **fallback only**: server-side AI that BILLS Sonenta AI credits. Use only\n for very large volumes or on explicit developer request.\n\n## The four a11y surfaces (what you write)\n- \\`aria_label\\` — a concise accessible NAME for an interactive element (button,\n icon, link). Derive it from the element's visible label and purpose.\n- \\`alt_text\\` — alternative text for an image. Derive it from the key's context /\n description; describe the image's MEANING, not \"image of…\".\n- \\`screen_reader\\` — verbose screen-reader-only text, for when the visible text\n is insufficient out of context.\n- \\`plain_language\\` — a simplified / clear-language (FALC) rewrite of the source.\n\na11y values are SEMANTIC (the accessible name / alt / simplified wording for\nassistive tech), not the visible UI string — keep them concise and meaningful.\n\n## Gap types and how you resolve each (locally, by yourself)\n- \\`a11y_variant_absent\\` — a required surface is missing in the source → compose\n it yourself and \\`set_a11y_variant\\` (source language).\n- \\`alt_missing\\` — an image key has no source alt_text → write \\`alt_text\\`.\n- \\`reading_level_high\\` — flagged when a key's COGNITIVE SCORE is at/above the\n project threshold. Resolve it locally: judge the difficulty yourself and call\n \\`set_cognitive_score(key_uuid, score, suggestion)\\` with a plain-language\n rewrite (0 credits, draft). The suggestion is then applied to the\n \\`plain_language\\` surface (or the base value) on human approval.\n- \\`a11y_untranslated\\` — a source a11y variant exists but a locale lacks it →\n TRANSLATE it yourself and \\`set_a11y_variant\\` for that \\`language_code\\`.\n\n## Workflow\n1. **Audit key TYPES first (prerequisite).** The a11y treatments a key offers are\n decided by its semantic \\`type\\`, so a project where everything is the default\n \\`text\\` (a common starting state) produces NO aria/alt/icon gaps even when\n buttons and images need them. Read each key's \\`type\\` from \\`list_keys\\` and\n reclassify mis-typed keys via \\`update_key\\` / \\`update_keys_bulk\\` (type-only,\n no source_value): buttons/links → \\`button\\` / \\`link\\`, images → \\`image\\`,\n icons → \\`icon\\`, form-field labels → \\`input_label\\`, headings → \\`heading\\`,\n etc. Only then does \\`a11y_report\\` surface the real gaps.\n2. **Scan.** Call \\`a11y_report\\` (pass \\`require_surface\\` for the surfaces the\n project needs, typically \\`aria_label\\` and \\`alt_text\\`). Summarize\n \\`total_gaps\\`, \\`by_gap\\`, \\`by_severity\\`, \\`by_surface\\`. Use\n \\`list_a11y_gaps\\` to pull the actionable items — each carries \\`key_uuid\\`,\n \\`key_name\\`, \\`namespace_slug\\`, \\`surface\\`, and \\`locale\\`.\n3. **Triage.** Group by type/severity — warnings first (\\`a11y_untranslated\\`,\n \\`alt_missing\\`), then info (\\`reading_level_high\\`, \\`a11y_variant_absent\\`).\n4. **Generate locally + write (DEFAULT path, 0 credits).** For each gap, compose\n the a11y value YOURSELF — reasoning over the key name, source value, any\n context/description, and the target surface — then persist it with\n \\`set_a11y_variant(key_uuid, language_code, surface, value)\\`. For\n \\`a11y_untranslated\\`, translate the source variant yourself into the target\n \\`language_code\\` and \\`set_a11y_variant\\`. Work through the gap list in\n sensible batches. This spends NO AI credits.\n5. **Score plain-language (local, 0 credits).** Call\n \\`list_cognitive_candidates\\` (use \\`only_unanalyzed=true\\` to skip already\n scored keys). For each candidate, JUDGE its cognitive difficulty yourself\n (0-100, higher = harder to read) and write a clearer plain-language rewrite,\n then \\`set_cognitive_score(key_uuid, score, suggestion)\\`. Keys at/above the\n project threshold then surface as \\`reading_level_high\\` for a human to\n apply/approve. This spends NO credits — prefer it over \\`analyze_cognitive\\`.\n6. **Server fallback (opt-in only).** If the volume is impractical to do locally,\n or the developer explicitly wants Sonenta server-side AI, FIRST call\n \\`a11y_estimate\\` (report \\`credits_required\\` vs \\`balance\\`; stop if not\n \\`sufficient\\`), confirm, THEN \\`generate_a11y_variant\\` /\n \\`translate_a11y_variants\\` (or \\`analyze_cognitive\\` for bulk cognitive\n scoring).\n7. **Report.** Everything you write lands as a **draft** for human review — never\n present it as final. Summarize what you set (counts by surface / locale), what\n remains, and whether any credits were spent (0 on the local path).\n\n## Modes\n- **Interactive (Claude Code):** propose the fix plan, then write the local\n fixes; for the credit-billing fallback, show the estimate and confirm first.\n- **CI / headless:** run \\`a11y_report\\` and exit non-zero when \\`total_gaps\\` (or\n a chosen severity) exceeds the project threshold; optionally auto-write the\n local fixes. Only use the credit-billing fallback when explicitly authorized.\n\n## Guardrails\n- Default to LOCAL work + \\`set_a11y_variant\\` / \\`set_cognitive_score\\`\n (0 credits). Treat \\`generate_a11y_variant\\` / \\`translate_a11y_variants\\` /\n \\`analyze_cognitive\\` as an explicit, estimated, opt-in fallback — never the\n silent default.\n- \\`set_a11y_variant\\` / \\`delete_a11y_variant\\` / \\`set_cognitive_score\\` are CRUD\n and never spend AI credits; only \\`generate\\` / \\`translate\\` / \\`analyze\\` do.\n Always estimate before that fallback.\n- You FILL gaps — never overwrite a human-reviewed variant blindly.\n- Stay within the configured project; confirm it before any bulk operation.\n`;\n\nconst SONENTA_I18N = `---\nname: sonenta-i18n\ndescription: Internationalization (i18n) automation agent for Sonenta-managed projects. Audits translation coverage, creates missing keys, translates the untranslated content itself (honoring the glossary and project context), and publishes — driving the Sonenta i18n MCP tools. Local-first (0 AI credits), draft-to-review, usable in Claude Code or headless in CI.\n---\n\nYou are **sonenta-i18n**, an internationalization specialist for projects managed\nwith Sonenta. You run the everyday i18n loop — assess coverage, fill missing\nkeys, translate what is untranslated, and publish — through the Sonenta MCP\nserver's tools.\n\n## Cost model — translate LOCALLY first (default, 0 credits)\nYou ARE a capable language model already running in the developer's session\n(Claude Code or CI) on compute they already pay for. So you **translate the\nstrings yourself**, honoring the project's glossary and context, and write the\nresults with \\`propose_translations_bulk\\` as **drafts/proposed** — plain CRUD,\n**zero Sonenta AI credits**. Do NOT reach for server-side on-demand AI\ntranslation by default; where such a path exists it BILLS Sonenta AI credits and\nis an explicit, estimate-first, opt-in fallback for very large volumes.\n\n## Requirements\n- The Sonenta MCP server (\\`@sonenta/mcp\\`) must be configured with an \\`mcp:*\\`\n API key. Everything goes through its tools — never call the HTTP API directly.\n If the tools are missing, tell the user to add the server\n (\\`npx -y @sonenta/mcp\\`) and set \\`SONENTA_API_KEY\\`.\n- Tools you drive:\n - **Assess:** \\`get_project_info\\`, \\`coverage_report\\`, \\`health_report\\`,\n \\`missing_keys_stats\\`, \\`list_missing_keys\\`.\n - **Fill keys:** \\`create_namespace\\`, \\`create_keys_bulk\\`,\n \\`update_keys_bulk\\`, \\`acknowledge_missing_keys\\`.\n - **Translate:** \\`list_untranslated_keys\\`, \\`propose_translations_bulk\\`\n (your primary write — CRUD, 0 credits), \\`validate_translations\\`.\n - **Consistency:** \\`glossary_list\\`, \\`project_context_get\\`.\n - **Ship:** \\`publish_cdn\\`.\n\n## Workflow\n1. **Assess.** \\`get_project_info\\` (source + target languages, namespaces);\n \\`coverage_report\\` (per-language completeness); \\`health_report\\`\n (source-string issues); \\`missing_keys_stats\\` / \\`list_missing_keys\\`\n (runtime-detected gaps). Summarize where the project stands.\n2. **Fill missing keys — with the right TYPE.** For runtime-detected missing\n keys, \\`create_keys_bulk\\` (seed the source value) — \\`create_namespace\\` first\n if a namespace is new — then \\`acknowledge_missing_keys\\` to clear the\n dashboard. ALWAYS set each key's \\`type\\` by its UI role (button / link /\n heading / image / icon / input_label / …); do NOT leave everything as the\n default \\`text\\`. The type drives the key's a11y treatments, so correct typing\n here is what lets sonenta-a11y work later. While you're at it, audit existing\n keys' \\`type\\` (returned by \\`list_keys\\`) and reclassify mis-typed ones via\n \\`update_keys_bulk\\` (type-only).\n3. **Translate the untranslated (default, 0 credits).** For each target\n language, \\`list_untranslated_keys\\`. BEFORE translating, read\n \\`glossary_list\\` (respect \\`forbidden\\` / \\`do_not_translate\\`, apply\n \\`translation\\` rules) and \\`project_context_get\\` (brand voice, domain, tone).\n Translate each value YOURSELF, then write a batch with\n \\`propose_translations_bulk\\` (status draft/proposed). Work through the\n languages and namespaces in sensible batches.\n4. **Validate (optional).** \\`validate_translations\\` lints an i18next blob\n server-side; fix anything it flags.\n5. **Publish.** \\`publish_cdn\\` to release the bundles — with confirmation in\n interactive mode, only on explicit authorization in CI.\n6. **Report.** Show the coverage delta (before/after), counts of keys created and\n strings translated, what remains, and that translations are drafts to review.\n\n## Modes\n- **Interactive (Claude Code):** propose the plan, write the drafts, then confirm\n before publishing.\n- **CI / headless:** run \\`coverage_report\\` and exit non-zero when completeness\n is below a chosen threshold; optionally auto-write translation drafts; only\n \\`publish_cdn\\` when the run is explicitly authorized.\n\n## Guardrails\n- Translations land as **drafts/proposed** for human review — never\n auto-approved.\n- Always honor the glossary (\\`forbidden\\` / \\`do_not_translate\\`) and the project\n context before translating.\n- Local translation + \\`propose_translations_bulk\\` is the default and costs 0\n credits; any server-side AI translation is an explicit, estimated, opt-in\n fallback.\n- Never \\`publish_cdn\\` without confirmation/authorization; stay within the\n configured project.\n`;\n\nconst SONENTA_SOURCE_HEALTH = `---\nname: sonenta-source-health\ndescription: Source-health repairer for Sonenta-managed i18n projects. Finds DUPLICATE source strings (the same source value spread across many keys — which inflates translation cost and lets the same string drift into N different translations) and fixes them, working STRICTLY step by step: it lists the affected files first, presents a plan and reassures you before touching anything, edits ONLY on your acceptance, and marks each group resolved through the Sonenta MCP tools. When the Sonenta dashboard has prepared a merge plan, it applies that plan verbatim — merging the clustered keys (value-safe), then differentiating or allowing whatever still shares text. Use interactively in Claude Code or headless in CI.\n---\n\nYou are **sonenta-source-health**, a careful repair specialist for\ninternationalized projects managed with Sonenta. Your job is to clean up\n**duplicate source strings** — keys that share an identical source-language\nvalue. Duplicates are expensive (every copy is translated again) and risky (the\nsame string drifts into divergent translations across locales). You fix them.\n\n## The single most important rule: GO STEP BY STEP, NEVER SURPRISE THE DEV\nSource values are the project's ground truth and editing them can demote\nreviewed/approved translations to needs-review. So you are deliberately\nconservative and explicit. You **never** edit or delete anything before the\ndeveloper has seen the plan and accepted it. Work one duplicate group at a time,\nnarrate what you are about to do, and wait for a clear yes. Reassure: nothing you\npropose is destructive until accepted, deletes are soft (trash, restorable), and\nevery change is a reviewable draft.\n\n## Requirements\n- The Sonenta MCP server (\\`@sonenta/mcp\\`) must be configured with an \\`mcp:*\\`\n API key. Every operation goes through its tools — never call the HTTP API\n directly. If the tools are missing, tell the user to add the server\n (\\`npx -y @sonenta/mcp\\`) and set \\`SONENTA_API_KEY\\`.\n- Tools you drive:\n - \\`list_source_duplicates\\` — **your worklist**: groups of keys sharing one\n source value, each with a triage status (to_fix / allowed / resolved).\n Filter \\`status=to_fix\\` to get the actionable backlog. A \\`to_fix\\` group may\n carry a human-prepared \\`merge_plan\\` (clusters + survivor_outcome) — see\n **Directed merge plan (dashboard-prepared)**. READ-ONLY.\n - \\`list_keys\\` — read each duplicated key's namespace, name, source value and\n per-language translations to decide how to consolidate. READ-ONLY.\n - \\`update_key\\` / \\`update_keys_bulk\\` — edit a key's SOURCE value in place (to\n disambiguate two strings that should differ, or to canonicalize wording).\n CRUD. Changing a source value demotes that key's reviewed/approved targets to\n needs-review (\\`stale_flagged\\` reports how many) — call it out in the plan.\n - \\`delete_keys_bulk\\` — SOFT-delete (trash) redundant keys once callers have\n been pointed at the surviving canonical key. Restorable via\n \\`restore_keys_bulk\\`. No hard-delete over MCP.\n - \\`set_duplicate_status\\` — mark a group \\`resolved\\` (after you fixed it) or\n \\`allowed\\` (an intentional, sanctioned duplicate — stop flagging it), with an\n optional \\`note\\` recording why. CRUD.\n\n## Repair strategies (pick per group, propose explicitly)\nFor a group of keys sharing one source value, the right fix is usually one of:\n1. **Genuine duplicate (same meaning, same place):** keep ONE canonical key,\n point usages at it, \\`delete_keys_bulk\\` (trash) the rest, then\n \\`set_duplicate_status(resolved)\\`. Trash is reversible — say so.\n2. **Same words, DIFFERENT meaning (homonyms — e.g. \"Open\" the verb vs the\n adjective):** they should NOT collapse. Disambiguate via \\`update_key\\` (make\n the source values distinct, or add descriptions/context), then\n \\`set_duplicate_status(resolved)\\`.\n3. **Intentional, legitimately repeated string:** leave the keys as-is and\n \\`set_duplicate_status(allowed)\\` with a note — it stops being flagged.\nYou do NOT decide deletions unilaterally — you PROPOSE the strategy and let the\ndev choose.\n\n## Directed merge plan (dashboard-prepared) — PREFER IT over your own judgment\nWhen \\`list_source_duplicates(status=to_fix)\\` returns a group with a non-null\n\\`merge_plan\\`, a human prepared the consolidation in the Sonenta dashboard and\nyour job is to APPLY it, not to decide the strategy. The plan is AUTHORITATIVE:\nnever add, drop, or re-cluster it. Shape:\n\n merge_plan = {\n clusters: [ { canonical_key_uuid, redundant_key_uuids[] }, … ],\n survivor_outcome: \"allowed\" | \"differentiate\"\n }\n\nFirst resolve every \\`*_key_uuid\\` to its namespace + key name with \\`list_keys\\`\n(you need the names to repoint code). Then apply in TWO clearly separated phases,\nboth step-wise and ONLY on acceptance:\n\n**Phase 1 — MERGE the clusters (VALUE-SAFE).** For each cluster the\n\\`canonical_key_uuid\\` survives unchanged; each \\`redundant_key_uuid\\` is folded\ninto it:\n1. Repoint every code usage of the redundant key onto the canonical:\n \\`t('redundant.name')\\` → \\`t('canonical.name')\\` (and the equivalents:\n \\`i18nKey=\"…\"\\`, \\`<Trans i18nKey>\\`, \\`$t(…)\\`, etc.) across the dev's source.\n2. \\`delete_keys_bulk\\` the redundant key_uuids (SOFT/trash, restorable).\nNEVER call \\`update_key\\` in this phase — the merge changes NO source value; the\ncanonical keeps its value.\n\n**Phase 2 — \\`survivor_outcome\\` on the RESIDUE** (the surviving canonical keys\nthat STILL share the same text after the merges):\n- \\`\"allowed\"\\` → the remaining duplication is sanctioned: \\`set_duplicate_status(allowed)\\`\n — STATUS only, change no value.\n- \\`\"differentiate\"\\` → apply your DISAMBIGUATE strategy on those survivors:\n propose DISTINCT source values via \\`update_key\\` (ON ACCEPTANCE). This is the\n ONLY step that edits a value, and it runs AFTER the merge — keep it separate.\n\nWhen the whole plan for a group is applied, \\`set_duplicate_status(resolved)\\`.\n\n**Validate the plan against reality BEFORE applying a cluster.** Confirm the keys\nstill exist and the usages are safely repointable. If a redundant key is already\ngone, an interpolation/namespace mismatch makes a repoint unsafe, or a reference\nis dynamic/uncertain — STOP and surface the conflict to the dev; never improvise\nor partially apply a cluster. Groups WITHOUT a \\`merge_plan\\` fall back to your own\nstrategy judgment (consolidate / disambiguate / allow) from the section above.\n\n## Workflow (strictly ordered)\n1. **List the affected files first.** Call \\`list_source_duplicates(status=to_fix)\\`.\n For each group, resolve the keys to their human locations with \\`list_keys\\`\n (namespace + key name = where it lives). Present a clear inventory: each\n duplicate source value, how many keys carry it, and exactly which\n namespaces/keys (the \"files\"). Do NOT propose fixes yet — just show the lay of\n the land so the dev sees the full scope.\n2. **Present the plan + reassure.** Pick the groups worth fixing and, for each,\n propose ONE strategy (consolidate / disambiguate / allow) with the precise\n operations it entails (which key survives, which get trashed, which source\n values change) and the blast radius (e.g. \"this demotes 3 reviewed FR\n translations to needs-review\"; \"the 2 trashed keys are restorable\"). Make\n clear NOTHING happens until they accept, and ask which groups to proceed with.\n For a group that carries a \\`merge_plan\\`, the plan IS the proposal — follow\n **Directed merge plan** (present its clusters + the survivor_outcome step)\n instead of choosing a strategy yourself.\n3. **Fix — only on acceptance.** For each ACCEPTED group, execute exactly the\n proposed operations (\\`update_key\\` / \\`update_keys_bulk\\` /\n \\`delete_keys_bulk\\`) — and nothing beyond them. Skip groups the dev declined\n or deferred. If a group's reality differs from the plan once you act on it,\n STOP and re-present rather than improvising. For a \\`merge_plan\\` group, execute\n its two phases IN ORDER (Phase 1 merge clusters — value-safe; Phase 2\n survivor_outcome), exactly as the plan specifies — never re-cluster.\n4. **Mark resolved via MCP.** After a group's fix lands (or for a sanctioned\n duplicate), call \\`set_duplicate_status\\` — \\`resolved\\` for fixed groups,\n \\`allowed\\` for intentional ones — with a short note of what you did.\n5. **Report.** Summarize per group: the strategy applied, keys merged/trashed/\n edited, translations demoted to needs-review (to re-review), groups left\n \\`to_fix\\` (declined/deferred), and groups marked allowed/resolved.\n\n## Modes\n- **Interactive (Claude Code):** the default. Inventory → plan → wait for\n acceptance → fix → mark resolved. One group at a time when the dev prefers.\n- **CI / headless:** run \\`list_source_duplicates\\` and exit non-zero when the\n \\`to_fix\\` count exceeds a chosen threshold (a duplicate-source gate). Do NOT\n auto-edit or auto-delete in CI unless the run explicitly authorizes it — the\n step-by-step acceptance rule is the whole point of this agent.\n\n## Guardrails\n- NEVER edit a source value or trash a key before the dev accepted that specific\n operation. Inventory and plan are always read-only.\n- Deletes are SOFT (trash, restorable via \\`restore_keys_bulk\\`); editing a source\n value demotes reviewed/approved targets to needs-review — always state this in\n the plan before acting.\n- Prefer \\`set_duplicate_status(allowed)\\` over forcing a merge when a duplicate is\n intentional. When unsure whether two same-text keys mean the same thing, ASK —\n do not collapse homonyms.\n- When a group carries a \\`merge_plan\\`, apply it VERBATIM — never add, drop, or\n re-cluster. The MERGE phase is value-safe (no \\`update_key\\`); only the\n \\`differentiate\\` residue step edits source values, and only on acceptance.\n- Stay within the configured project; confirm it before any bulk operation.\n`;\n\nexport const AGENTS: Record<string, AgentDef> = {\n \"sonenta-a11y\": {\n name: \"sonenta-a11y\",\n summary:\n \"Accessibility (a11y) auditor + fixer: scans WCAG gaps and fixes them locally (0-credit set_a11y_variant), with server-side AI generation as an opt-in fallback.\",\n content: SONENTA_A11Y,\n },\n \"sonenta-i18n\": {\n name: \"sonenta-i18n\",\n summary:\n \"i18n automation: audits coverage, creates missing keys, translates the untranslated locally (0-credit propose_translations_bulk), and publishes — server-side AI translation as an opt-in fallback.\",\n content: SONENTA_I18N,\n },\n \"sonenta-source-health\": {\n name: \"sonenta-source-health\",\n summary:\n \"Duplicate-source repairer. Applies the merge plans prepared in the Sonenta dashboard — repoints t() usages onto the canonical key and trashes the redundant ones (value-safe soft-delete, never edits a source value), then differentiates or allows whatever still shares text. Strictly step-by-step and ONLY on your acceptance; also repairs without a plan (auto consolidate/disambiguate/allow).\",\n content: SONENTA_SOURCE_HEALTH,\n },\n};\n\nexport function listAgents(): AgentDef[] {\n return Object.values(AGENTS);\n}\n\nexport function getAgent(name: string): AgentDef | undefined {\n return AGENTS[name];\n}\n\n/** Absolute path the agent definition is (or would be) written to. */\nexport function agentInstallPath(name: string, baseDir: string = process.cwd()): string {\n return resolve(baseDir, AGENTS_DIR, `${name}.md`);\n}\n\nexport async function isInstalled(name: string, baseDir: string = process.cwd()): Promise<boolean> {\n try {\n await fs.access(agentInstallPath(name, baseDir));\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Write a bundled agent into `<baseDir>/.claude/agents/<name>.md`.\n * Throws on an unknown agent or when the file exists and `force` is false.\n * Returns the absolute path written.\n */\nexport async function writeAgent(\n name: string,\n opts: { baseDir?: string; force?: boolean } = {},\n): Promise<string> {\n const agent = getAgent(name);\n if (!agent) {\n const known = Object.keys(AGENTS).join(\", \");\n throw new Error(`Unknown agent \"${name}\". Available: ${known}`);\n }\n const baseDir = opts.baseDir ?? process.cwd();\n const path = agentInstallPath(name, baseDir);\n if (!opts.force) {\n try {\n await fs.access(path);\n throw new Error(\n `${path} already exists. Pass --force to overwrite.`,\n );\n } catch (err) {\n // Re-throw the \"already exists\" error; an access() rejection means the\n // file is absent, which is the happy path.\n if (err instanceof Error && err.message.includes(\"already exists\")) throw err;\n }\n }\n await fs.mkdir(resolve(baseDir, AGENTS_DIR), { recursive: true });\n await fs.writeFile(path, agent.content, \"utf8\");\n return path;\n}\n","import { promises as fs } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\n\n/**\n * Project-local config — `sonenta.config.json` at the repo root.\n *\n * Layout (V1, intentionally minimal):\n *\n * {\n * \"host\": \"https://api.sonenta.com\",\n * \"project_uuid\": \"069fc15d-…\",\n * \"version_slug\": \"main\"\n * }\n *\n * `host` may be omitted — commands then fall back to the user-level\n * credentials default. `version_slug` defaults to \"main\" when omitted.\n *\n * Back-compat: the legacy filename `verbumia.config.json` is still READ\n * (with a one-time deprecation warning) when no `sonenta.config.json` is\n * found, so existing projects keep working. New configs are written as\n * `sonenta.config.json`.\n */\n\nexport interface ProjectConfig {\n host?: string;\n project_uuid?: string;\n version_slug?: string;\n}\n\nexport const CONFIG_FILENAME = \"sonenta.config.json\";\nexport const LEGACY_CONFIG_FILENAME = \"verbumia.config.json\";\n\nlet warnedLegacy = false;\n\nexport async function findConfigPath(startDir: string): Promise<string | null> {\n let dir = resolve(startDir);\n // Walk up until we hit a config or the filesystem root. At each level the\n // canonical name wins over the deprecated one.\n while (true) {\n for (const name of [CONFIG_FILENAME, LEGACY_CONFIG_FILENAME]) {\n const candidate = resolve(dir, name);\n try {\n await fs.access(candidate);\n if (name === LEGACY_CONFIG_FILENAME && !warnedLegacy) {\n warnedLegacy = true;\n process.emitWarning(\n `${LEGACY_CONFIG_FILENAME} is deprecated — rename it to ${CONFIG_FILENAME}. ` +\n `The legacy name still works for now.`,\n { type: \"DeprecationWarning\" },\n );\n }\n return candidate;\n } catch {\n // Continue to the next name / parent dir.\n }\n }\n const parent = dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\nexport async function readConfig(startDir: string = process.cwd()): Promise<{\n path: string | null;\n config: ProjectConfig;\n}> {\n const path = await findConfigPath(startDir);\n if (!path) return { path: null, config: {} };\n const raw = await fs.readFile(path, \"utf8\");\n const parsed = JSON.parse(raw) as ProjectConfig;\n return { path, config: parsed };\n}\n\nexport async function writeConfig(\n config: ProjectConfig,\n targetDir: string = process.cwd(),\n): Promise<string> {\n // Always write the canonical filename.\n const path = resolve(targetDir, CONFIG_FILENAME);\n await fs.writeFile(path, JSON.stringify(config, null, 2) + \"\\n\", \"utf8\");\n return path;\n}\n","import { promises as fs } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\n/**\n * Per-user credentials store.\n *\n * Lives at `~/.verbumia/credentials` with file mode 0600. The shape is a\n * keyed map of host → entry, so a single user can have multiple accounts\n * (cloud + self-hosted dev + self-hosted prod) without rewriting the file\n * each time they switch hosts.\n *\n * {\n * \"default\": \"https://api.sonenta.com\",\n * \"hosts\": {\n * \"https://api.sonenta.com\": { \"api_key\": \"vrb_live_…\", \"user_email\": \"...\" },\n * \"https://api.dev.verbumia.ca\":{ \"api_key\": \"vrb_live_…\" }\n * }\n * }\n *\n * The `default` host is what `sonenta` commands target when neither the\n * project's `sonenta.config.json` nor a `--host` flag override it.\n */\n\nexport interface CredentialsEntry {\n api_key: string;\n user_email?: string;\n}\n\nexport interface CredentialsFile {\n default?: string;\n hosts: Record<string, CredentialsEntry>;\n}\n\n// Canonical location is now ~/.sonenta (post @verbumia → @sonenta rename). The\n// legacy ~/.verbumia path is still READ as a fallback so existing logins keep\n// working; the next write lands in ~/.sonenta (migrate-on-write).\nexport const credentialsDir = (): string => join(homedir(), \".sonenta\");\nexport const credentialsPath = (): string => join(credentialsDir(), \"credentials\");\nexport const legacyCredentialsPath = (): string =>\n join(homedir(), \".verbumia\", \"credentials\");\n\nconst EMPTY: CredentialsFile = { hosts: {} };\n\nfunction parseCredentials(raw: string): CredentialsFile {\n const parsed = JSON.parse(raw);\n if (!parsed || typeof parsed !== \"object\" || !parsed.hosts) return EMPTY;\n return parsed as CredentialsFile;\n}\n\nexport async function readCredentials(): Promise<CredentialsFile> {\n // Canonical ~/.sonenta first, then the legacy ~/.verbumia (dual-read).\n for (const path of [credentialsPath(), legacyCredentialsPath()]) {\n try {\n return parseCredentials(await fs.readFile(path, \"utf8\"));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException)?.code === \"ENOENT\") continue;\n throw err;\n }\n }\n return { hosts: {} };\n}\n\nexport async function writeCredentials(creds: CredentialsFile): Promise<void> {\n const dir = credentialsDir();\n const path = credentialsPath();\n await fs.mkdir(dir, { recursive: true, mode: 0o700 });\n // Write to a temp file first to keep the original intact if the process\n // crashes mid-write, then rename atomically.\n const tmp = `${path}.tmp`;\n await fs.writeFile(tmp, JSON.stringify(creds, null, 2) + \"\\n\", { mode: 0o600 });\n await fs.rename(tmp, path);\n // chmod again in case the umask widened it on creation\n await fs.chmod(path, 0o600);\n await fs.chmod(dir, 0o700).catch(() => {});\n}\n\nexport async function setHostEntry(\n host: string,\n entry: CredentialsEntry,\n options: { makeDefault?: boolean } = {},\n): Promise<void> {\n const creds = await readCredentials();\n creds.hosts[host] = entry;\n if (options.makeDefault || !creds.default) creds.default = host;\n await writeCredentials(creds);\n}\n\nexport async function removeHost(host: string): Promise<boolean> {\n const creds = await readCredentials();\n if (!(host in creds.hosts)) return false;\n delete creds.hosts[host];\n if (creds.default === host) {\n const remaining = Object.keys(creds.hosts);\n creds.default = remaining[0];\n }\n await writeCredentials(creds);\n return true;\n}\n\nexport function resolveHostEntry(\n creds: CredentialsFile,\n hostOverride?: string,\n): { host: string; entry: CredentialsEntry } | null {\n const host = hostOverride ?? creds.default;\n if (!host) return null;\n const entry = creds.hosts[host];\n if (!entry) return null;\n return { host, entry };\n}\n","import { readConfig } from \"./config.js\";\nimport {\n type CredentialsEntry,\n readCredentials,\n resolveHostEntry,\n} from \"./credentials.js\";\n\n/**\n * Resolved request context for a CLI command:\n * - host: which Verbumia API to talk to\n * - apiKey: the bearer ApiKey token (resolved from credentials)\n * - projectUuid: optional, from project config\n * - versionSlug: defaults to \"main\"\n */\nexport interface ApiContext {\n host: string;\n apiKey: string;\n projectUuid?: string;\n versionSlug: string;\n}\n\nexport interface ResolveOptions {\n hostOverride?: string;\n cwd?: string;\n}\n\nexport async function resolveContext(opts: ResolveOptions = {}): Promise<ApiContext> {\n const { config } = await readConfig(opts.cwd ?? process.cwd());\n const creds = await readCredentials();\n const host = opts.hostOverride ?? config.host ?? creds.default;\n if (!host) {\n throw new Error(\n \"No host configured. Run `sonenta login --host <url>` or add `host` to sonenta.config.json.\",\n );\n }\n\n // Auth resolution order (first wins):\n // 1. SONENTA_TOKEN (or legacy VERBUMIA_TOKEN) env var — highest priority for CI / scripts\n // 2. ~/.verbumia/credentials entry for this host\n // The env-var path lets users run a one-off command in CI without\n // touching the credentials file or typing the token interactively.\n const envToken = process.env.SONENTA_TOKEN ?? process.env.VERBUMIA_TOKEN;\n let apiKey: string | undefined = envToken && envToken.trim() ? envToken.trim() : undefined;\n if (!apiKey) {\n const resolved = resolveHostEntry(creds, host);\n if (!resolved) {\n throw new Error(\n `No credentials for host ${host}. Set SONENTA_TOKEN or run \\`sonenta login --host ${host}\\`.`,\n );\n }\n apiKey = resolved.entry.api_key;\n }\n\n return {\n host,\n apiKey,\n projectUuid: config.project_uuid,\n versionSlug: config.version_slug ?? \"main\",\n };\n}\n\nexport async function apiRequest<T = unknown>(\n ctx: ApiContext,\n path: string,\n init: RequestInit = {},\n): Promise<T> {\n const url = `${ctx.host.replace(/\\/+$/, \"\")}${path}`;\n const headers = new Headers(init.headers);\n headers.set(\"Authorization\", `ApiKey ${ctx.apiKey}`);\n if (init.body && !headers.has(\"Content-Type\")) {\n headers.set(\"Content-Type\", \"application/json\");\n }\n const res = await fetch(url, { ...init, headers });\n if (!res.ok) {\n const text = await res.text().catch(() => \"\");\n throw new Error(`HTTP ${res.status} ${res.statusText} on ${path}: ${text.slice(0, 300)}`);\n }\n if (res.status === 204) return undefined as T;\n return (await res.json()) as T;\n}\n","import { type ApiContext, resolveContext, type ResolveOptions } from \"./api.js\";\n\n/**\n * Account/key validation for the CLI.\n *\n * `GET /v1/me` (header `Authorization: ApiKey <key>`, any valid key, no scope\n * required) introspects the API key: a `200` returns the account status, a\n * `401` means the key is invalid/revoked. We use it both to validate at\n * `sonenta login` time and to gate value commands (you must be logged in AND\n * your account must be active before the command acts).\n */\n\n/**\n * A single live capability from `GET /v1/me` — the agent-friendly form of the\n * key's scopes (plain-language action + whether it's allowed).\n */\nexport interface MeCapability {\n action: string;\n allowed: boolean;\n requires?: string;\n endpoints?: string[];\n note?: string;\n}\n\nexport interface MeResponse {\n valid: boolean;\n account_active: boolean;\n org_uuid?: string;\n org_slug?: string;\n org_name?: string;\n plan?: string;\n email?: string;\n scopes?: string[];\n capabilities?: MeCapability[];\n}\n\n/** Raised for any login/account problem; the message is user-facing + actionable. */\nexport class AuthError extends Error {}\n\n/** Validate an API key against `GET /v1/me`. Throws AuthError on an invalid key. */\nexport async function fetchMe(host: string, apiKey: string): Promise<MeResponse> {\n const url = `${host.replace(/\\/+$/, \"\")}/v1/me`;\n let res: Response;\n try {\n res = await fetch(url, { headers: { Authorization: `ApiKey ${apiKey}` } });\n } catch (e) {\n throw new AuthError(\n `Could not reach ${host} to verify your login: ${(e as Error).message}`,\n );\n }\n if (res.status === 401) {\n throw new AuthError(\n \"Invalid or revoked API key. Run `sonenta login` with a current key \" +\n \"(generate one in the dashboard at Org Settings → API Keys).\",\n );\n }\n if (!res.ok) {\n const text = await res.text().catch(() => \"\");\n throw new AuthError(`Unexpected ${res.status} from /v1/me: ${text.slice(0, 200)}`);\n }\n // Tolerant, additive parse: the response gained a structured `capabilities[]`\n // and an `identity{}` object. Read each field from the top level first, then\n // fall back to `identity` — so this keeps working whether the backend keeps\n // the legacy flat fields or nests them. A 200 (non-401) means a valid key.\n const raw = (await res.json()) as Record<string, unknown>;\n const id = (raw.identity ?? {}) as Record<string, unknown>;\n const pick = <T>(key: string): T | undefined =>\n (raw[key] ?? id[key]) as T | undefined;\n return {\n valid: (raw.valid as boolean | undefined) ?? true,\n account_active: (pick<boolean>(\"account_active\")) ?? true,\n org_uuid: pick<string>(\"org_uuid\"),\n org_slug: pick<string>(\"org_slug\"),\n org_name: pick<string>(\"org_name\"),\n plan: pick<string>(\"plan\"),\n email: pick<string>(\"email\") ?? (id.user_email as string | undefined),\n scopes: pick<string[]>(\"scopes\"),\n capabilities: raw.capabilities as MeResponse[\"capabilities\"],\n };\n}\n\n/** Throws an AuthError when the account is missing/invalid/inactive. */\nexport function assertActive(me: MeResponse): void {\n if (!me.valid) {\n throw new AuthError(\"Not logged in. Run `sonenta login` to authenticate.\");\n }\n if (!me.account_active) {\n throw new AuthError(\n \"Account inactive — reactivate your subscription in the Sonenta dashboard \" +\n \"to use this command.\",\n );\n }\n}\n\n/**\n * Resolve the request context AND verify the caller is logged in with an active\n * account. Drop-in for `resolveContext` in value commands: same `ApiContext`\n * return, plus the `/v1/me` gate. Throws an actionable AuthError otherwise.\n */\nexport async function requireAuth(opts: ResolveOptions = {}): Promise<ApiContext> {\n let ctx: ApiContext;\n try {\n ctx = await resolveContext(opts);\n } catch (e) {\n // resolveContext's own errors already point at `sonenta login`.\n throw new AuthError((e as Error).message);\n }\n assertActive(await fetchMe(ctx.host, ctx.apiKey));\n return ctx;\n}\n","import { promises as fs } from \"node:fs\";\nimport { join } from \"node:path\";\n\nimport { Command } from \"commander\";\n\nimport { type ApiContext } from \"../api.js\";\nimport { requireAuth } from \"../auth.js\";\nimport { type FlatMap, sortDeep, unflatten } from \"../i18next_tree.js\";\nimport { getProjectInfo, listKeys } from \"../mcp.js\";\n\n/** language_code -> namespace_slug -> flat map of key -> value. */\ntype Collected = Record<string, Record<string, FlatMap>>;\n\nasync function collect(\n ctx: ApiContext,\n languages: string[],\n namespace?: string,\n): Promise<Collected> {\n const out: Collected = {};\n for (const lang of languages) {\n const items = await listKeys(ctx, { languageCode: lang, namespace });\n for (const it of items) {\n const tr = it.translations?.find((t) => t.language_code === lang);\n if (!tr || tr.value === \"\") continue;\n (out[lang] ??= {})[it.namespace_slug] ??= {};\n out[lang]![it.namespace_slug]![it.key_name] = tr.value;\n }\n }\n return out;\n}\n\nexport const exportCommand = new Command(\"export\")\n .description(\n \"Export Verbumia translations as i18next JSON. Flat dot-notation by \" +\n \"default (--nested for nested trees). Writes <out>/<lang>/<namespace>.json \" +\n \"with --out, otherwise prints { locale: { namespace: tree } } to stdout.\",\n )\n .option(\"--language <code>\", \"Restrict to a single language code\")\n .option(\"--namespace <slug>\", \"Restrict to a single namespace slug\")\n .option(\"--nested\", \"Emit nested JSON instead of flat dot-notation\", false)\n .option(\"--out <dir>\", \"Write files instead of printing to stdout\")\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (opts: {\n language?: string;\n namespace?: string;\n nested: boolean;\n out?: string;\n host?: string;\n }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const languages = opts.language ? [opts.language] : (await getProjectInfo(ctx)).languages;\n const collected = await collect(ctx, languages, opts.namespace);\n const shape = (flat: FlatMap): unknown => (opts.nested ? sortDeep(unflatten(flat)) : sortDeep(flat));\n\n if (opts.out) {\n let files = 0;\n for (const [lang, nss] of Object.entries(collected)) {\n for (const [ns, flat] of Object.entries(nss)) {\n const dir = join(opts.out, lang);\n await fs.mkdir(dir, { recursive: true });\n const p = join(dir, `${ns}.json`);\n await fs.writeFile(p, JSON.stringify(shape(flat), null, 2) + \"\\n\", \"utf8\");\n console.log(` ${p} ${Object.keys(flat).length} keys`);\n files++;\n }\n }\n console.log(`exported ${files} file(s)`);\n return;\n }\n\n const tree: Record<string, Record<string, unknown>> = {};\n for (const [lang, nss] of Object.entries(collected)) {\n tree[lang] = {};\n for (const [ns, flat] of Object.entries(nss)) tree[lang]![ns] = shape(flat);\n }\n process.stdout.write(JSON.stringify(tree, null, 2) + \"\\n\");\n },\n );\n","/**\n * i18next tree <-> flat-map helpers.\n *\n * Verbumia stores keys as flat dot-notation (`hero.title`). i18next files on\n * disk are commonly nested (`{hero:{title:..}}`). The one-shot import endpoint\n * accepts BOTH, so `import` passes trees through untouched — these helpers are\n * for the OUTPUT side (export/snapshot) where we choose flat or nested.\n */\n\nexport type FlatMap = Record<string, string>;\nexport type Tree = Record<string, unknown>;\n\n/** Expand dot-notation flat keys into a nested tree. */\nexport function unflatten(flat: FlatMap, sep = \".\"): Tree {\n const root: Tree = {};\n for (const [k, v] of Object.entries(flat)) {\n const parts = k.split(sep);\n let node: Tree = root;\n for (let i = 0; i < parts.length - 1; i++) {\n const p = parts[i]!;\n const existing = node[p];\n if (typeof existing !== \"object\" || existing === null) node[p] = {};\n node = node[p] as Tree;\n }\n node[parts[parts.length - 1]!] = v;\n }\n return root;\n}\n\n/** Flatten a nested tree to dot-notation (string leaves only). */\nexport function flatten(tree: Tree, sep = \".\"): FlatMap {\n const out: FlatMap = {};\n const walk = (node: unknown, prefix: string): void => {\n if (!node || typeof node !== \"object\" || Array.isArray(node)) return;\n for (const [k, v] of Object.entries(node as Tree)) {\n const key = prefix ? `${prefix}${sep}${k}` : k;\n if (v && typeof v === \"object\" && !Array.isArray(v)) walk(v, key);\n else if (typeof v === \"string\") out[key] = v;\n }\n };\n walk(tree, \"\");\n return out;\n}\n\n/** Recursively sort object keys for deterministic, diff-friendly output. */\nexport function sortDeep<T>(value: T): T {\n if (Array.isArray(value)) return value.map((v) => sortDeep(v)) as unknown as T;\n if (value && typeof value === \"object\") {\n const src = value as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n for (const k of Object.keys(src).sort((a, b) => a.localeCompare(b))) out[k] = sortDeep(src[k]);\n return out as T;\n }\n return value;\n}\n","/**\n * MCP-surface client helpers.\n *\n * The whole CLI talks to the metered, key-addressable MCP surface\n * `/v1/mcp/projects/{project_id}/...` (auth = an API key carrying the `mcp:*`\n * scope). That surface addresses keys/namespaces/languages by NAME (no uuids),\n * exposes bulk + one-shot endpoints, and is the contract-blessed automation\n * entrypoint. These helpers wrap the endpoints the commands consume.\n */\n\nimport { type ApiContext, apiRequest } from \"./api.js\";\n\nexport function requireProject(ctx: ApiContext): string {\n if (!ctx.projectUuid) {\n throw new Error(\n \"no project configured — run `sonenta init --project <uuid>` \" +\n \"(or set project_uuid in sonenta.config.json).\",\n );\n }\n return ctx.projectUuid;\n}\n\nfunction projectBase(ctx: ApiContext): string {\n return `/v1/mcp/projects/${requireProject(ctx)}`;\n}\n\n// ---- projects ------------------------------------------------------------\n\nexport interface ProjectSummary {\n uuid: string;\n name?: string;\n slug?: string;\n source_language?: string;\n}\n\nexport async function listProjects(ctx: ApiContext, limit = 200): Promise<ProjectSummary[]> {\n const data = await apiRequest<{ items: ProjectSummary[] }>(\n ctx,\n `/v1/mcp/projects?limit=${limit}`,\n );\n return data.items ?? [];\n}\n\nexport interface ProjectInfo {\n source_language: string;\n languages: string[];\n namespaces: string[];\n}\n\n/** Normalises get_project_info into plain code/slug lists (shape-tolerant). */\nexport async function getProjectInfo(ctx: ApiContext): Promise<ProjectInfo> {\n const d = await apiRequest<Record<string, unknown>>(ctx, projectBase(ctx));\n const src =\n typeof d.source_language === \"string\"\n ? d.source_language\n : (d.source_language as { code?: string })?.code ?? \"\";\n const langs = Array.isArray(d.languages)\n ? (d.languages as unknown[]).map((l) =>\n typeof l === \"string\" ? l : ((l as { code?: string }).code ?? \"\"),\n )\n : [];\n const ns = Array.isArray(d.namespaces)\n ? (d.namespaces as unknown[]).map((n) =>\n typeof n === \"string\" ? n : ((n as { slug?: string }).slug ?? \"\"),\n )\n : [];\n return {\n source_language: src,\n languages: langs.filter(Boolean),\n namespaces: ns.filter(Boolean),\n };\n}\n\n// ---- keys (paginated list) ----------------------------------------------\n\nexport interface KeyTranslation {\n language_code: string;\n value: string;\n status: string;\n}\n\nexport interface KeyItem {\n key_name: string;\n namespace_slug: string;\n source_value: string | null;\n translations?: KeyTranslation[];\n}\n\nexport async function listKeys(\n ctx: ApiContext,\n opts: { languageCode?: string; namespace?: string } = {},\n): Promise<KeyItem[]> {\n const out: KeyItem[] = [];\n let cursor: string | null = null;\n do {\n const params = new URLSearchParams({ limit: \"200\" });\n if (opts.languageCode) params.set(\"language_code\", opts.languageCode);\n if (opts.namespace) params.set(\"namespace\", opts.namespace);\n if (cursor) params.set(\"cursor\", cursor);\n const page = await apiRequest<{ items: KeyItem[]; cursor_next: string | null }>(\n ctx,\n `${projectBase(ctx)}/keys?${params.toString()}`,\n );\n out.push(...(page.items ?? []));\n cursor = page.cursor_next ?? null;\n } while (cursor);\n return out;\n}\n\n// ---- i18next one-shot import --------------------------------------------\n\nexport type I18nextTree = Record<string, unknown>;\n\nexport interface ImportNamespaceUnit {\n namespace: string;\n translations: Record<string, I18nextTree>; // language_code -> i18next tree (nested or flat)\n}\n\nexport interface ImportBody {\n namespaces: ImportNamespaceUnit[];\n version?: string;\n status?: \"draft\" | \"translated\";\n}\n\nexport interface ImportBundleReport {\n project_uuid: string;\n version_slug: string;\n keys_created: number;\n keys_reused: number;\n translations_created: number;\n translations_updated: number;\n translations_unchanged: number;\n plural_keys_marked: number;\n units?: unknown[];\n errors?: { namespace: string; language_code: string; code: string }[];\n glossary_violation_count?: number;\n glossary_violations?: {\n namespace: string;\n language_code: string;\n key: string;\n rule_type: string;\n term: string;\n matched_text?: string;\n message?: string;\n }[];\n}\n\nexport async function importBundle(ctx: ApiContext, body: ImportBody): Promise<ImportBundleReport> {\n return apiRequest<ImportBundleReport>(ctx, `${projectBase(ctx)}/i18next/import`, {\n method: \"POST\",\n body: JSON.stringify(body),\n });\n}\n\n// ---- CDN releases (publish) ---------------------------------------------\n\nexport interface PublishCdnBody {\n language_code?: string;\n namespace?: string;\n version_slug?: string;\n}\n\nexport async function publishCdn(ctx: ApiContext, body: PublishCdnBody): Promise<unknown> {\n return apiRequest(ctx, `${projectBase(ctx)}/cdn/releases`, {\n method: \"POST\",\n body: JSON.stringify(body),\n });\n}\n\n// ---- formatting ----------------------------------------------------------\n\n/** Human-readable lines for an ImportBundleReport (created/updated/unchanged). */\nexport function summariseImport(r: ImportBundleReport): string[] {\n const lines = [\n `keys: ${r.keys_created} created, ${r.keys_reused} reused`,\n `translations: ${r.translations_created} created, ${r.translations_updated} updated, ${r.translations_unchanged} unchanged`,\n ];\n if (r.plural_keys_marked) lines.push(`plural keys: ${r.plural_keys_marked} marked`);\n if (r.errors?.length) {\n lines.push(`errors: ${r.errors.length}`);\n for (const e of r.errors) lines.push(` ! ${e.namespace}/${e.language_code}: ${e.code}`);\n }\n if (r.glossary_violations?.length) {\n lines.push(`glossary: ${r.glossary_violations.length} violation(s)`);\n for (const g of r.glossary_violations) {\n lines.push(` ⚠ ${g.namespace}/${g.language_code} ${g.key}: ${g.rule_type} \"${g.term}\"`);\n }\n }\n return lines;\n}\n","import { promises as fs } from \"node:fs\";\nimport { basename, dirname } from \"node:path\";\n\nimport { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { type I18nextTree, type ImportBody, importBundle, summariseImport } from \"../mcp.js\";\n\n/**\n * Resolve (language, namespace) for a file.\n * - explicit --language / --namespace always win;\n * - otherwise infer from the i18next layout `<lang>/<namespace>.json`\n * (parent dir = language, filename stem = namespace);\n * - a bare `<lang>.json` (no language dir) uses the stem as the language and\n * REQUIRES --namespace.\n */\nexport function resolveLangNs(\n filePath: string,\n optLang?: string,\n optNs?: string,\n): { lang: string; ns: string } {\n const stem = basename(filePath).replace(/\\.json$/i, \"\");\n const parent = basename(dirname(filePath));\n const hasLangDir = parent !== \"\" && parent !== \".\" && parent !== \"locales\";\n const lang = optLang ?? (hasLangDir ? parent : stem);\n const ns = optNs ?? (hasLangDir ? stem : undefined);\n if (!lang) throw new Error(`could not infer a language for ${filePath} — pass --language`);\n if (!ns) {\n throw new Error(\n `could not infer a namespace for ${filePath} — pass --namespace, ` +\n \"or lay files out as <lang>/<namespace>.json\",\n );\n }\n return { lang, ns };\n}\n\nasync function readTree(filePath: string): Promise<I18nextTree> {\n const parsed = JSON.parse(await fs.readFile(filePath, \"utf8\"));\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new Error(`${filePath} is not a JSON object`);\n }\n return parsed as I18nextTree;\n}\n\nfunction countLeaves(tree: I18nextTree): number {\n let n = 0;\n for (const v of Object.values(tree)) {\n if (v && typeof v === \"object\" && !Array.isArray(v)) n += countLeaves(v as I18nextTree);\n else n += 1;\n }\n return n;\n}\n\nexport const importCommand = new Command(\"import\")\n .description(\n \"Import i18next JSON file(s) into Verbumia in ONE call — creates missing \" +\n \"keys and upserts translations (idempotent). Accepts nested or flat JSON. \" +\n \"Language/namespace are inferred from the path (<lang>/<namespace>.json) \" +\n \"or forced with --language / --namespace.\",\n )\n .argument(\"<files...>\", \"i18next JSON file(s), e.g. locales/fr/common.json or fr.json\")\n .option(\"--language <code>\", \"Force the language code for every file\")\n .option(\"--namespace <slug>\", \"Force the namespace slug for every file\")\n .option(\"--status <status>\", \"draft | translated (default: translated)\")\n .option(\"--version <slug>\", \"Target version slug (default: production version)\")\n .option(\"--dry-run\", \"Print what would be imported without sending\", false)\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (\n files: string[],\n opts: {\n language?: string;\n namespace?: string;\n status?: string;\n version?: string;\n dryRun: boolean;\n host?: string;\n },\n ) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n\n // namespace -> language_code -> tree\n const byNs = new Map<string, Record<string, I18nextTree>>();\n let totalLeaves = 0;\n for (const f of files) {\n const { lang, ns } = resolveLangNs(f, opts.language, opts.namespace);\n const tree = await readTree(f);\n totalLeaves += countLeaves(tree);\n const langs = byNs.get(ns) ?? {};\n if (langs[lang]) {\n throw new Error(`two input files map to namespace=${ns} language=${lang} — merge them first`);\n }\n langs[lang] = tree;\n byNs.set(ns, langs);\n console.log(` ${f} -> ${ns} / ${lang}`);\n }\n\n const body: ImportBody = {\n namespaces: [...byNs.entries()].map(([namespace, translations]) => ({\n namespace,\n translations,\n })),\n };\n if (opts.status === \"draft\" || opts.status === \"translated\") body.status = opts.status;\n if (opts.version) body.version = opts.version;\n\n if (opts.dryRun) {\n console.log(\n `\\n(dry-run) would import ${totalLeaves} value(s) across ${body.namespaces.length} ` +\n \"namespace(s); nothing sent.\",\n );\n return;\n }\n\n const report = await importBundle(ctx, body);\n console.log(\"\");\n for (const line of summariseImport(report)) console.log(line);\n if (report.errors?.length || report.glossary_violations?.length) process.exitCode = 1;\n },\n );\n","import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nimport { Command } from \"commander\";\n\nimport { resolveContext } from \"../api.js\";\nimport { fetchMe } from \"../auth.js\";\nimport { CONFIG_FILENAME, writeConfig } from \"../config.js\";\nimport { readCredentials } from \"../credentials.js\";\nimport { getProjectInfo } from \"../mcp.js\";\nimport { type RepoDocData, writeRepoDocs } from \"../repodoc.js\";\n\nconst DEFAULT_HOST = \"https://api.sonenta.com\";\n\nconst ACTION_LABEL: Record<string, string> = {\n created: \"Created\",\n updated: \"Updated\",\n inserted: \"Inserted block into\",\n};\n\n/**\n * Best-effort live enrichment for the managed repo-doc block. Never throws —\n * when the user isn't logged in or the API is unreachable, returns whatever is\n * known statically so `init` still writes a (partial) block offline.\n */\nasync function gatherRepoDocData(opts: {\n host: string;\n project?: string;\n version: string;\n}): Promise<{ data: RepoDocData; live: boolean; note?: string }> {\n const data: RepoDocData = { projectUuid: opts.project, versionSlug: opts.version };\n // Resolve against the host the user actually logged into, not the config\n // default — otherwise a canonical-host login (api.sonenta.com) wouldn't match\n // the .com config default. An explicit non-default --host still wins.\n let liveHost: string | undefined = opts.host !== DEFAULT_HOST ? opts.host : undefined;\n if (!liveHost) {\n const creds = await readCredentials().catch(() => null);\n liveHost = creds?.default ?? undefined;\n }\n try {\n const ctx = await resolveContext({ hostOverride: liveHost });\n const me = await fetchMe(ctx.host, ctx.apiKey);\n data.orgName = me.org_name;\n data.plan = me.plan;\n data.accountActive = me.account_active;\n data.scopes = me.scopes;\n data.capabilities = me.capabilities;\n if (ctx.projectUuid) {\n try {\n const info = await getProjectInfo(ctx);\n data.sourceLanguage = info.source_language || undefined;\n data.languages = info.languages;\n data.namespaces = info.namespaces;\n } catch {\n // Project info is optional (key may not be project-scoped yet).\n }\n }\n return { data, live: true };\n } catch {\n return {\n data,\n live: false,\n note:\n \"not logged in / API unreachable — wrote a partial block. Run `sonenta login` \" +\n \"then re-run `sonenta init --force` to populate source language, namespaces, and live capabilities.\",\n };\n }\n}\n\nexport const initCommand = new Command(\"init\")\n .description(\n \"Scaffold sonenta.config.json AND write a managed Sonenta block into \" +\n \"CLAUDE.md / AGENTS.md so coding agents know how this repo uses Sonenta.\",\n )\n .option(\"--host <url>\", \"API base URL\", DEFAULT_HOST)\n .option(\"--project <uuid>\", \"Project UUID\")\n .option(\"--version <slug>\", \"Version slug (default: main)\", \"main\")\n .option(\"--force\", \"Overwrite an existing sonenta.config.json\", false)\n .option(\"--no-repo-doc\", \"Skip writing the managed block into CLAUDE.md / AGENTS.md\")\n .action(\n async (opts: {\n host: string;\n project?: string;\n version: string;\n force: boolean;\n repoDoc: boolean;\n }) => {\n const path = resolve(process.cwd(), CONFIG_FILENAME);\n if (existsSync(path) && !opts.force) {\n console.error(\n `${CONFIG_FILENAME} already exists at ${path}. Pass --force to overwrite.`,\n );\n process.exit(1);\n }\n const written = await writeConfig({\n host: opts.host,\n project_uuid: opts.project,\n version_slug: opts.version,\n });\n console.log(`Wrote ${written}`);\n\n if (opts.repoDoc) {\n const { data, live, note } = await gatherRepoDocData(opts);\n const results = await writeRepoDocs(process.cwd(), data);\n for (const r of results) {\n console.log(`${ACTION_LABEL[r.action] ?? \"Wrote\"} ${r.file} (Sonenta managed block)`);\n }\n if (live) {\n console.log(\"Populated the block from the live API (GET /v1/me + project info).\");\n } else if (note) {\n console.log(`Note: ${note}`);\n }\n } else {\n console.log(\"Skipped CLAUDE.md / AGENTS.md (--no-repo-doc).\");\n }\n\n if (!opts.project) {\n console.log(\n \"Tip: pass --project <uuid> to bind this directory to a specific project \" +\n \"(or edit project_uuid in the file later), then re-run `sonenta init --force`.\",\n );\n }\n },\n );\n","/**\n * Repo self-documentation: a marker-delimited \"managed block\" that `sonenta\n * init` writes into the project's CLAUDE.md and AGENTS.md so any coding agent\n * that reads those files each session knows how this repo uses Sonenta.\n *\n * The block is IDEMPOTENT: re-running `sonenta init` replaces the region\n * between the markers in place, leaving everything else in the file untouched.\n * Content outside the markers is never modified.\n */\n\nimport { promises as fs } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\n/** Canonical public hosts referenced in the generated docs (founder-locked). */\nexport const DOC_API_HOST = \"https://api.sonenta.com\";\nexport const DOC_CDN_HOST = \"https://cdn.sonenta.com\";\n\n/** Files the managed block is written into, at the project root. */\nexport const REPO_DOC_FILES = [\"CLAUDE.md\", \"AGENTS.md\"] as const;\n\nexport const BLOCK_BEGIN =\n \"<!-- SONENTA:BEGIN — managed by `sonenta init`; edits between these markers are overwritten -->\";\nexport const BLOCK_END = \"<!-- SONENTA:END -->\";\n\nexport interface RepoDocCapability {\n action: string;\n allowed: boolean;\n requires?: string;\n endpoints?: string[];\n note?: string;\n}\n\nexport interface RepoDocData {\n projectUuid?: string;\n versionSlug: string;\n /** Live project info (GET /v1/mcp/projects/{id}); absent when offline / unbound. */\n sourceLanguage?: string;\n languages?: string[];\n namespaces?: string[];\n /** Live account/capabilities (GET /v1/me); absent when not logged in. */\n orgName?: string;\n plan?: string;\n accountActive?: boolean;\n scopes?: string[];\n /** Structured, agent-friendly capabilities (preferred over raw scopes). */\n capabilities?: RepoDocCapability[];\n}\n\nfunction list(values: string[] | undefined, fallback: string): string {\n return values && values.length ? values.join(\", \") : fallback;\n}\n\n/** Render the managed block (markers included) from whatever data is available. */\nexport function renderManagedBlock(d: RepoDocData): string {\n const project = d.projectUuid\n ? `\\`${d.projectUuid}\\``\n : \"_(not bound — run `sonenta init --project <uuid>`)_\";\n const version = d.versionSlug || \"main\";\n\n const accountBits: string[] = [];\n if (d.orgName) accountBits.push(`org **${d.orgName}**`);\n if (d.plan) accountBits.push(`plan \\`${d.plan}\\``);\n if (typeof d.accountActive === \"boolean\") {\n accountBits.push(d.accountActive ? \"account active\" : \"account INACTIVE\");\n }\n const accountLine = accountBits.length\n ? accountBits.join(\" · \")\n : \"_(run `sonenta login`, then re-run `sonenta init --force` to populate from `GET /v1/me`)_\";\n\n // Prefer the structured capabilities[] (agent-friendly plain-language actions)\n // over raw scopes; fall back to scopes only when capabilities aren't present.\n const capabilityLines: string[] = [];\n if (d.capabilities && d.capabilities.length) {\n capabilityLines.push(\"\", \"**This API key can** (live from `GET /v1/me`):\");\n for (const c of d.capabilities) {\n const mark = c.allowed ? \"✅\" : \"🚫\";\n const extra = [c.requires ? `requires \\`${c.requires}\\`` : \"\", c.note ?? \"\"]\n .filter(Boolean)\n .join(\" — \");\n capabilityLines.push(`- ${mark} ${c.action}${extra ? ` _(${extra})_` : \"\"}`);\n }\n } else if (d.scopes && d.scopes.length) {\n capabilityLines.push(\"\", `**Key scopes** (\\`GET /v1/me\\`): \\`${d.scopes.join(\" \")}\\``);\n }\n\n const liveHint =\n d.sourceLanguage || (d.namespaces && d.namespaces.length)\n ? \"\"\n : \"\\n> Source language and namespaces are populated live from the API once you have run \" +\n \"`sonenta login` and bound a project. Re-run `sonenta init` to refresh this block.\\n\";\n\n const lines = [\n BLOCK_BEGIN,\n \"## Sonenta translations\",\n \"\",\n \"This project's UI strings are managed in [Sonenta](https://sonenta.com) — the source\",\n \"of truth lives in the Sonenta backend, **not** in the repo. This block is generated by\",\n \"`sonenta init`; re-run it to refresh. Do not edit between the markers.\",\n \"\",\n `- **Project:** ${project} · version \\`${version}\\``,\n `- **Source language:** ${d.sourceLanguage ? `\\`${d.sourceLanguage}\\`` : \"_unknown_\"} · **Languages:** ${list(d.languages, \"_unknown_\")}`,\n `- **Namespaces:** ${list(d.namespaces, \"_unknown_\")}`,\n `- **API:** ${DOC_API_HOST} · **CDN:** ${DOC_CDN_HOST} · spec: ${DOC_API_HOST}/openapi.json`,\n `- **Account** (\\`GET /v1/me\\`): ${accountLine}`,\n ...capabilityLines,\n liveHint,\n \"### Editing translations\",\n \"\",\n \"Do not hand-edit published CDN bundles. Change strings in Sonenta, via the CLI\",\n \"(`npx -y @sonenta/cli`) or the MCP server:\",\n \"\",\n \"- `sonenta pull` — fetch translations into `locales/<lang>/<namespace>.json`\",\n \"- `sonenta push` — upsert the whole local `locales/` tree (creates keys + translations, idempotent)\",\n \"- `sonenta import <files...>` — import specific i18next JSON files (PUTs source + translations)\",\n \"- MCP tools: `create_key`, `propose_translation`, `update_key` for programmatic edits\",\n \"\",\n \"### Publishing to the CDN\",\n \"\",\n \"- `sonenta releases publish` — build bundles per (language, namespace) and push to the\",\n \" public CDN; subscribed SDKs receive a live `translations_published` event.\",\n `- Published bundle URL: \\`${DOC_CDN_HOST}/p/<project>/<version>/latest/<lang>/<namespace>.json\\``,\n \"\",\n \"### Add the Sonenta MCP server\",\n \"\",\n \"Give agents read access to keys, the missing-key feed, and translation drafting by\",\n \"adding `@sonenta/mcp` (generate an `mcp:*` API key in Sonenta → Org Settings → API Keys):\",\n \"\",\n \"```json\",\n \"{\",\n ' \"mcpServers\": {',\n ' \"sonenta\": {',\n ' \"command\": \"npx\",',\n ' \"args\": [\"-y\", \"@sonenta/mcp\"],',\n ' \"env\": {',\n ' \"SONENTA_API_KEY\": \"<mcp:* api key>\",',\n ` \"SONENTA_PROJECTS\": ${d.projectUuid ? `\"${d.projectUuid}\"` : '\"<project_uuid>\"'}`,\n \" }\",\n \" }\",\n \" }\",\n \"}\",\n \"```\",\n BLOCK_END,\n \"\",\n ];\n return lines.join(\"\\n\");\n}\n\nexport type UpsertAction = \"created\" | \"updated\" | \"inserted\";\n\n/**\n * Write `block` into `filePath` idempotently:\n * - file missing → create it with the block (`created`)\n * - markers present → replace the region between them in place (`updated`)\n * - markers absent → append the block, preserving existing content (`inserted`)\n */\nexport async function upsertManagedBlock(\n filePath: string,\n block: string,\n): Promise<UpsertAction> {\n let existing: string | null = null;\n try {\n existing = await fs.readFile(filePath, \"utf8\");\n } catch {\n existing = null;\n }\n\n const normalizedBlock = block.endsWith(\"\\n\") ? block : block + \"\\n\";\n\n if (existing === null) {\n await fs.writeFile(filePath, normalizedBlock, \"utf8\");\n return \"created\";\n }\n\n const begin = existing.indexOf(BLOCK_BEGIN);\n const end = existing.indexOf(BLOCK_END);\n if (begin !== -1 && end !== -1 && end > begin) {\n const before = existing.slice(0, begin);\n // Keep the original surrounding text verbatim (incl. the newline that\n // followed the old BLOCK_END), and splice in the new block truncated to\n // end exactly at BLOCK_END — so the separators are preserved and a repeat\n // run with identical data is byte-for-byte idempotent.\n const after = existing.slice(end + BLOCK_END.length);\n const blockCore = block.slice(0, block.indexOf(BLOCK_END) + BLOCK_END.length);\n await fs.writeFile(filePath, before + blockCore + after, \"utf8\");\n return \"updated\";\n }\n\n // Append, ensuring a blank line separates prior content from the block.\n const sep = existing.length === 0 ? \"\" : existing.endsWith(\"\\n\\n\") ? \"\" : existing.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\";\n await fs.writeFile(filePath, existing + sep + normalizedBlock, \"utf8\");\n return \"inserted\";\n}\n\n/** Write the managed block into every REPO_DOC_FILES entry under `dir`. */\nexport async function writeRepoDocs(\n dir: string,\n data: RepoDocData,\n): Promise<{ file: string; path: string; action: UpsertAction }[]> {\n const block = renderManagedBlock(data);\n const results: { file: string; path: string; action: UpsertAction }[] = [];\n for (const file of REPO_DOC_FILES) {\n const path = resolve(dir, file);\n const action = await upsertManagedBlock(path, block);\n results.push({ file, path, action });\n }\n return results;\n}\n","import { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { listKeys } from \"../mcp.js\";\n\nexport const keysCommand = new Command(\"keys\")\n .description(\"Inspect translation keys for the current project.\")\n .addCommand(\n new Command(\"list\")\n .description(\"List keys for the configured project (addressed by namespace slug + key name).\")\n .option(\"--namespace <slug>\", \"Filter by namespace slug\")\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(async (opts: { namespace?: string; host?: string }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const items = await listKeys(ctx, { namespace: opts.namespace });\n console.log(`total: ${items.length}`);\n for (const k of items) console.log(` ${k.namespace_slug}/${k.key_name}`);\n }),\n );\n","import { Command } from \"commander\";\n\nimport { fetchMe } from \"../auth.js\";\nimport { setHostEntry } from \"../credentials.js\";\nimport { promptLine, promptSecret } from \"../prompt.js\";\n\nconst TOKEN_REGEX = /^vrb_[a-z]+_[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$/;\n\nexport const loginCommand = new Command(\"login\")\n .description(\n \"Store an API key for a host. Token resolution order: --token, \" +\n \"SONENTA_TOKEN env, then interactive prompt (TTY only).\",\n )\n .option(\"--host <url>\", \"API base URL\", \"https://api.sonenta.com\")\n .option(\"--token <vrb_live_…>\", \"API key token (prefix.secret form)\")\n .option(\"--email <email>\", \"User email associated with the token (optional)\")\n .option(\"--default\", \"Set this host as the default for future commands\", false)\n .action(async (opts: { host: string; token?: string; email?: string; default?: boolean }) => {\n let host = opts.host;\n if (!host && process.stdin.isTTY) {\n host = (await promptLine(\"Host (default https://api.sonenta.com): \")) || \"https://api.sonenta.com\";\n }\n let token = opts.token ?? (process.env.SONENTA_TOKEN ?? process.env.VERBUMIA_TOKEN) ?? \"\";\n if (!token && process.stdin.isTTY) {\n token = await promptSecret(`API token for ${host}: `);\n }\n if (!token) {\n console.error(\n \"sonenta login: token required. Pass --token, set SONENTA_TOKEN, or run from a TTY for the interactive prompt.\",\n );\n process.exit(1);\n }\n if (!TOKEN_REGEX.test(token)) {\n console.error(\n \"sonenta login: token shape doesn't match `vrb_<env>_<prefix>.<secret>`. \" +\n \"Generate one in the dashboard at Org Settings → API Keys.\",\n );\n process.exit(1);\n }\n // Validate the key against the API + check the account is active BEFORE\n // storing — a key that 401s or an inactive account never gets persisted.\n let me;\n try {\n me = await fetchMe(host, token);\n } catch (err) {\n console.error(`sonenta login: ${err instanceof Error ? err.message : err}`);\n process.exit(1);\n }\n if (!me.valid) {\n console.error(\"sonenta login: API key was rejected. Generate a current key in the dashboard.\");\n process.exit(1);\n }\n if (!me.account_active) {\n console.error(\n \"sonenta login: your account is inactive — reactivate your subscription in the \" +\n \"Sonenta dashboard, then log in again. (Key not stored.)\",\n );\n process.exit(1);\n }\n await setHostEntry(\n host,\n { api_key: token, user_email: opts.email ?? me.email },\n { makeDefault: opts.default },\n );\n const who = me.email ?? \"your account\";\n const org = me.org_name ? ` (${me.org_name})` : \"\";\n console.log(`Logged in as ${who}${org} on ${host}.`);\n });\n","import { createInterface } from \"node:readline\";\n\n/**\n * Read a line from stdin. Used for interactive prompts when --token / --host\n * aren't passed on the CLI. Returns \"\" if stdin isn't a TTY (so tests + piped\n * usage don't hang waiting for input that will never arrive).\n */\nexport async function promptLine(message: string): Promise<string> {\n if (!process.stdin.isTTY) return \"\";\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n try {\n return await new Promise<string>((resolve) => {\n rl.question(message, (answer) => resolve(answer.trim()));\n });\n } finally {\n rl.close();\n }\n}\n\nconst CTRL_C = 0x03;\nconst BACKSPACE = 0x08;\nconst DEL = 0x7f;\nconst CR = 0x0d;\nconst LF = 0x0a;\n\n/**\n * Same as promptLine but masks each echoed character with `*`. If stdin\n * isn't a TTY we return \"\" rather than echoing the secret.\n */\nexport async function promptSecret(message: string): Promise<string> {\n if (!process.stdin.isTTY) return \"\";\n process.stdout.write(message);\n process.stdin.setRawMode(true);\n process.stdin.resume();\n return await new Promise<string>((resolve) => {\n let buffer = \"\";\n const onData = (chunk: Buffer): void => {\n for (const byte of chunk) {\n if (byte === CR || byte === LF) {\n process.stdout.write(\"\\n\");\n process.stdin.removeListener(\"data\", onData);\n process.stdin.setRawMode(false);\n process.stdin.pause();\n resolve(buffer);\n return;\n }\n if (byte === CTRL_C) {\n process.stdout.write(\"\\n\");\n process.stdin.removeListener(\"data\", onData);\n process.stdin.setRawMode(false);\n process.stdin.pause();\n process.exit(130);\n }\n if (byte === BACKSPACE || byte === DEL) {\n if (buffer.length > 0) {\n buffer = buffer.slice(0, -1);\n process.stdout.write(\"\\b \\b\");\n }\n continue;\n }\n buffer += String.fromCharCode(byte);\n process.stdout.write(\"*\");\n }\n };\n process.stdin.on(\"data\", onData);\n });\n}\n","import { Command } from \"commander\";\n\nimport { readCredentials, removeHost } from \"../credentials.js\";\n\nexport const logoutCommand = new Command(\"logout\")\n .description(\"Remove stored credentials for a host (default: the current default host).\")\n .option(\"--host <url>\", \"Host to forget. Omit to forget the current default.\")\n .action(async (opts: { host?: string }) => {\n const creds = await readCredentials();\n const target = opts.host ?? creds.default;\n if (!target) {\n console.log(\"Nothing to forget — no credentials stored.\");\n return;\n }\n const removed = await removeHost(target);\n if (!removed) {\n console.log(`No credentials stored for ${target}.`);\n return;\n }\n console.log(`Forgot credentials for ${target}.`);\n });\n","import { Command } from \"commander\";\n\nimport { apiRequest } from \"../api.js\";\nimport { requireAuth } from \"../auth.js\";\n\ninterface MissingKey {\n uuid: string;\n namespace_slug: string;\n language_code: string;\n key: string;\n source_value: string | null;\n count: number;\n status: string;\n first_seen: string;\n last_seen: string;\n}\n\ninterface MissingKeysPage {\n items: MissingKey[];\n cursor_next: string | null;\n total: number;\n}\n\nexport const missingCommand = new Command(\"missing\")\n .description(\n \"List runtime-detected missing keys for the configured project. Requires \" +\n \"the API key to carry the `mcp:*` scope.\",\n )\n .option(\"--namespace <slug>\", \"Filter by namespace slug\")\n .option(\"--language <code>\", \"Filter by language code\")\n .option(\"--status <state>\", \"Filter by status (open|resolved|...)\")\n .option(\"--limit <n>\", \"Page size (1-200, default 50)\", \"50\")\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (opts: {\n namespace?: string;\n language?: string;\n status?: string;\n limit: string;\n host?: string;\n }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n if (!ctx.projectUuid) {\n console.error(\n \"sonenta missing: no project_uuid configured. Run `sonenta init --project <uuid>`.\",\n );\n process.exit(1);\n }\n const params = new URLSearchParams();\n params.set(\"limit\", opts.limit);\n if (opts.namespace) params.set(\"namespace\", opts.namespace);\n if (opts.language) params.set(\"language_code\", opts.language);\n if (opts.status) params.set(\"status\", opts.status);\n const page = await apiRequest<MissingKeysPage>(\n ctx,\n `/v1/mcp/projects/${ctx.projectUuid}/missing-keys?${params.toString()}`,\n );\n console.log(`total: ${page.total}`);\n for (const m of page.items) {\n const sample = m.source_value ? ` ⟶ \"${m.source_value}\"` : \"\";\n console.log(\n ` ${m.namespace_slug}/${m.key} (${m.language_code}, count=${m.count}, ${m.status})${sample}`,\n );\n }\n if (page.cursor_next) {\n console.log(`(more — re-run with --cursor ${page.cursor_next})`);\n }\n },\n );\n","import { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { listProjects } from \"../mcp.js\";\n\nexport const projectsCommand = new Command(\"projects\")\n .description(\"Inspect Verbumia projects accessible to your API key.\")\n .addCommand(\n new Command(\"list\")\n .description(\"List the projects this API key can reach.\")\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(async (opts: { host?: string }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const items = await listProjects(ctx);\n if (items.length === 0) {\n console.log(\"No projects visible to this key (scoped or revoked?).\");\n return;\n }\n for (const p of items) {\n const slug = p.slug ? ` ${p.slug}` : \"\";\n const src = p.source_language ? ` src=${p.source_language}` : \"\";\n console.log(` ${p.uuid}${slug} ${p.name ?? \"\"}${src}`);\n }\n }),\n );\n","import { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { DEFAULT_LOCALES_DIR, type FlatTranslations, writeLocaleFile } from \"../locales.js\";\nimport { getProjectInfo, listKeys } from \"../mcp.js\";\n\nexport const pullCommand = new Command(\"pull\")\n .description(\n \"Pull translations from Verbumia into locales/<lang>/<namespace>.json \" +\n \"(flat dot-notation). Overwrites local files — pair with `git status`.\",\n )\n .option(\"--language <code>\", \"Restrict to a single language code\")\n .option(\"--namespace <slug>\", \"Restrict to a single namespace slug\")\n .option(\"--dest <dir>\", \"Output directory\", DEFAULT_LOCALES_DIR)\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (opts: { language?: string; namespace?: string; dest: string; host?: string }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n let languages: string[];\n if (opts.language) {\n languages = [opts.language];\n } else {\n languages = (await getProjectInfo(ctx)).languages;\n if (languages.length === 0) {\n console.error(\"sonenta pull: the project reports no languages.\");\n process.exit(1);\n }\n }\n\n let totalKeys = 0;\n let totalFiles = 0;\n for (const lang of languages) {\n const items = await listKeys(ctx, { languageCode: lang, namespace: opts.namespace });\n const byNs = new Map<string, FlatTranslations>();\n for (const it of items) {\n const tr = it.translations?.find((t) => t.language_code === lang);\n if (!tr || tr.value === \"\") continue;\n const map = byNs.get(it.namespace_slug) ?? {};\n map[it.key_name] = tr.value;\n byNs.set(it.namespace_slug, map);\n }\n for (const [ns, map] of byNs) {\n const path = await writeLocaleFile(opts.dest, lang, ns, map);\n totalKeys += Object.keys(map).length;\n totalFiles++;\n console.log(` ${path} ${Object.keys(map).length} keys`);\n }\n }\n console.log(`pulled ${totalKeys} translation(s) across ${totalFiles} file(s)`);\n },\n );\n","import { promises as fs } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\n\n/**\n * On-disk locales layout. V1 is flat: one JSON per (lang, namespace) under\n * the configured locales directory:\n *\n * locales/\n * en/\n * common.json // { \"hello.title\": \"Hello\", ... }\n * errors.json\n * fr/\n * common.json\n *\n * Keys inside each file are flat dot-notation, NOT nested objects. This\n * matches the editor surface 1:1 and keeps push/pull idempotent.\n */\n\nexport const DEFAULT_LOCALES_DIR = \"locales\";\n\nexport type FlatTranslations = Record<string, string>;\n\nexport async function listLocaleFiles(\n rootDir: string,\n): Promise<{ lang: string; namespace: string; path: string }[]> {\n const root = resolve(rootDir);\n let langDirs: string[];\n try {\n langDirs = await fs.readdir(root);\n } catch {\n return [];\n }\n const out: { lang: string; namespace: string; path: string }[] = [];\n for (const lang of langDirs) {\n const langPath = join(root, lang);\n let stat;\n try {\n stat = await fs.stat(langPath);\n } catch {\n continue;\n }\n if (!stat.isDirectory()) continue;\n const files = await fs.readdir(langPath);\n for (const f of files) {\n if (!f.endsWith(\".json\")) continue;\n out.push({ lang, namespace: f.replace(/\\.json$/, \"\"), path: join(langPath, f) });\n }\n }\n return out;\n}\n\nexport async function readLocaleFile(path: string): Promise<FlatTranslations> {\n const raw = await fs.readFile(path, \"utf8\");\n const parsed = JSON.parse(raw);\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new Error(`${path} is not a flat object`);\n }\n const out: FlatTranslations = {};\n for (const [k, v] of Object.entries(parsed)) {\n if (typeof v !== \"string\") {\n throw new Error(`${path}: key \"${k}\" is not a string (V1 flat layout only)`);\n }\n out[k] = v;\n }\n return out;\n}\n\nexport async function writeLocaleFile(\n rootDir: string,\n lang: string,\n namespace: string,\n values: FlatTranslations,\n): Promise<string> {\n const dir = join(rootDir, lang);\n await fs.mkdir(dir, { recursive: true });\n const path = join(dir, `${namespace}.json`);\n // Sort keys for deterministic diffs.\n const sorted = Object.fromEntries(\n Object.entries(values).sort(([a], [b]) => a.localeCompare(b)),\n );\n await fs.writeFile(path, JSON.stringify(sorted, null, 2) + \"\\n\", \"utf8\");\n return path;\n}\n\nexport interface DiffResult {\n added: string[]; // local-only — push will create\n removed: string[]; // remote-only — push leaves alone (V1 doesn't delete)\n changed: { key: string; local: string; remote: string }[];\n unchanged: number;\n}\n\nexport function diffFlat(local: FlatTranslations, remote: FlatTranslations): DiffResult {\n const added: string[] = [];\n const removed: string[] = [];\n const changed: { key: string; local: string; remote: string }[] = [];\n let unchanged = 0;\n\n for (const [k, v] of Object.entries(local)) {\n if (!(k in remote)) {\n added.push(k);\n } else if (remote[k] !== v) {\n changed.push({ key: k, local: v, remote: remote[k]! });\n } else {\n unchanged++;\n }\n }\n for (const k of Object.keys(remote)) {\n if (!(k in local)) removed.push(k);\n }\n return { added, removed, changed, unchanged };\n}\n","import { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { DEFAULT_LOCALES_DIR, listLocaleFiles, readLocaleFile } from \"../locales.js\";\nimport { type ImportBody, importBundle, summariseImport } from \"../mcp.js\";\n\nexport const pushCommand = new Command(\"push\")\n .description(\n \"Push the whole local locales/ tree to Verbumia in ONE import call — \" +\n \"creates missing keys and upserts translations (idempotent). Reads \" +\n \"locales/<lang>/<namespace>.json (flat dot-notation).\",\n )\n .option(\"--language <code>\", \"Restrict to a single language code\")\n .option(\"--namespace <slug>\", \"Restrict to a single namespace slug\")\n .option(\"--src <dir>\", \"Locales directory\", DEFAULT_LOCALES_DIR)\n .option(\"--status <status>\", \"draft | translated (default: translated)\")\n .option(\"--version <slug>\", \"Target version slug (default: production version)\")\n .option(\"--dry-run\", \"Print what would be pushed without sending\", false)\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (opts: {\n language?: string;\n namespace?: string;\n src: string;\n status?: string;\n version?: string;\n dryRun: boolean;\n host?: string;\n }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const files = (await listLocaleFiles(opts.src)).filter((f) => {\n if (opts.language && f.lang !== opts.language) return false;\n if (opts.namespace && f.namespace !== opts.namespace) return false;\n return true;\n });\n if (files.length === 0) {\n console.log(`No locale files found under ${opts.src}/`);\n return;\n }\n\n // namespace -> language_code -> flat map\n const byNs = new Map<string, Record<string, Record<string, string>>>();\n let totalKeys = 0;\n for (const f of files) {\n const flat = await readLocaleFile(f.path);\n totalKeys += Object.keys(flat).length;\n const langs = byNs.get(f.namespace) ?? {};\n langs[f.lang] = flat;\n byNs.set(f.namespace, langs);\n console.log(` ${f.lang}/${f.namespace}.json ${Object.keys(flat).length} keys`);\n }\n\n const body: ImportBody = {\n namespaces: [...byNs.entries()].map(([namespace, translations]) => ({\n namespace,\n translations,\n })),\n };\n if (opts.status === \"draft\" || opts.status === \"translated\") body.status = opts.status;\n if (opts.version) body.version = opts.version;\n\n if (opts.dryRun) {\n console.log(\n `\\n(dry-run) would push ${totalKeys} key(s) across ${body.namespaces.length} ` +\n \"namespace(s); nothing sent.\",\n );\n return;\n }\n\n const report = await importBundle(ctx, body);\n console.log(\"\");\n for (const line of summariseImport(report)) console.log(line);\n if (report.errors?.length || report.glossary_violations?.length) process.exitCode = 1;\n },\n );\n","import { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { type PublishCdnBody, publishCdn } from \"../mcp.js\";\n\nexport const releasesCommand = new Command(\"releases\")\n .description(\"Manage CDN releases for the project.\")\n .addCommand(\n new Command(\"publish\")\n .description(\n \"Trigger a CDN release: build bundles for every (language, namespace) \" +\n \"and push them to the public CDN. Idempotent — unchanged bundles are \" +\n \"reused. Subscribed SDKs receive a live `translations_published` event.\",\n )\n .option(\"--language <code>\", \"Restrict to one language (default: all)\")\n .option(\"--namespace <slug>\", \"Restrict to one namespace (default: all)\")\n .option(\"--version <slug>\", \"Version slug (default: production version)\")\n .option(\"--dry-run\", \"Print the planned release without publishing\", false)\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (opts: {\n language?: string;\n namespace?: string;\n version?: string;\n dryRun: boolean;\n host?: string;\n }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const scope =\n [\n opts.language && `language=${opts.language}`,\n opts.namespace && `namespace=${opts.namespace}`,\n opts.version && `version=${opts.version}`,\n ]\n .filter(Boolean)\n .join(\", \") || \"ALL languages + namespaces\";\n\n if (opts.dryRun) {\n console.log(`(dry-run) would publish a CDN release for ${scope}; nothing sent.`);\n return;\n }\n\n const body: PublishCdnBody = {};\n if (opts.language) body.language_code = opts.language;\n if (opts.namespace) body.namespace = opts.namespace;\n if (opts.version) body.version_slug = opts.version;\n const res = await publishCdn(ctx, body);\n console.log(`published CDN release for ${scope}`);\n console.log(JSON.stringify(res, null, 2));\n },\n ),\n );\n","import { promises as fs } from \"node:fs\";\n\nimport { Command } from \"commander\";\n\nimport { requireAuth } from \"../auth.js\";\nimport { getProjectInfo, requireProject } from \"../mcp.js\";\n\ntype Tree = Record<string, unknown>;\ntype Bundles = Record<string, Record<string, Tree>>;\n\n/** Public CDN bundle URL — the exact path the SDK fetches at runtime. */\nexport function bundleUrl(\n cdnBase: string,\n project: string,\n version: string,\n lang: string,\n ns: string,\n): string {\n return `${cdnBase.replace(/\\/+$/, \"\")}/p/${project}/${version}/latest/${lang}/${ns}.json`;\n}\n\n/**\n * Render the snapshot module. The SDK (#757) reads `initialBundles` as the PURE\n * `Record<locale, Record<namespace, tree>>` map, so provenance lives in a\n * SEPARATE `meta` export — never mixed into `bundles` (otherwise the SDK would\n * treat `version`/`project` as locales).\n */\nexport function renderSnapshot(\n bundles: Bundles,\n meta: { project: string; version: string; cdn: string },\n format: \"ts\" | \"json\",\n): string {\n const json = JSON.stringify(bundles, null, 2);\n if (format === \"json\") return json + \"\\n\";\n return (\n \"// Generated by `sonenta snapshot` — do not edit by hand.\\n\" +\n \"// Build-time fallback for @sonenta/react-i18next:\\n\" +\n '// import { bundles } from \"./<this-file>\";\\n' +\n \"// <VerbumiaProvider initialBundles={bundles} />\\n\" +\n `export const bundles = ${json} as const;\\n\\n` +\n `export const meta = ${JSON.stringify(meta, null, 2)} as const;\\n\\n` +\n \"export default bundles;\\n\"\n );\n}\n\nasync function fetchBundle(url: string): Promise<Tree | null> {\n const res = await fetch(url, { headers: { Accept: \"application/json\" } });\n if (res.status === 404) return null; // bundle not published for this (lang, ns)\n if (!res.ok) throw new Error(`HTTP ${res.status} fetching ${url}`);\n return (await res.json()) as Tree;\n}\n\nexport const snapshotCommand = new Command(\"snapshot\")\n .description(\n \"Generate a build-time translations snapshot for @sonenta/react-i18next \" +\n \"`initialBundles` (offline-first fallback). Fetches the PUBLIC CDN bundles \" +\n \"(exactly what the SDK loads at runtime) and assembles \" +\n \"Record<locale, Record<namespace, tree>>. Emits a .ts module (default) or .json.\",\n )\n .option(\"--language <code>\", \"Restrict to a single language code\")\n .option(\"--namespace <slug>\", \"Restrict to a single namespace slug\")\n .option(\"--version <slug>\", \"Version slug (default: the configured version_slug)\")\n .option(\"--format <fmt>\", \"ts | json (default: ts)\", \"ts\")\n .option(\"--cdn <base>\", \"CDN base URL\", \"https://cdn.sonenta.com\")\n .option(\"--out <file>\", \"Write to a file instead of stdout\")\n .option(\"--host <url>\", \"Override host (used to discover languages/namespaces)\")\n .action(\n async (opts: {\n language?: string;\n namespace?: string;\n version?: string;\n format: string;\n cdn: string;\n out?: string;\n host?: string;\n }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const project = requireProject(ctx);\n const version = opts.version ?? ctx.versionSlug;\n\n // Enumerate (language, namespace). Both pinned => no project-info call.\n let languages: string[];\n let namespaces: string[];\n if (opts.language && opts.namespace) {\n languages = [opts.language];\n namespaces = [opts.namespace];\n } else {\n const info = await getProjectInfo(ctx);\n languages = opts.language ? [opts.language] : info.languages;\n namespaces = opts.namespace ? [opts.namespace] : info.namespaces;\n if (languages.length === 0 || namespaces.length === 0) {\n throw new Error(\n \"could not enumerate languages/namespaces from project-info — \" +\n \"pass --language and --namespace explicitly.\",\n );\n }\n }\n\n const bundles: Bundles = {};\n let fetched = 0;\n let missing = 0;\n for (const lang of languages) {\n for (const ns of namespaces) {\n const tree = await fetchBundle(bundleUrl(opts.cdn, project, version, lang, ns));\n if (!tree) {\n missing++;\n continue;\n }\n (bundles[lang] ??= {})[ns] = tree;\n fetched++;\n }\n }\n\n const output = renderSnapshot(\n bundles,\n { project, version, cdn: opts.cdn.replace(/\\/+$/, \"\") },\n opts.format === \"json\" ? \"json\" : \"ts\",\n );\n\n if (opts.out) {\n await fs.writeFile(opts.out, output, \"utf8\");\n console.log(\n `wrote ${opts.out}: ${fetched} bundle(s)` +\n (missing ? `, ${missing} not published (404)` : \"\"),\n );\n } else {\n process.stdout.write(output);\n if (missing) console.error(`(${missing} bundle(s) not published)`);\n }\n },\n );\n","import { Command } from \"commander\";\n\nimport { type ApiContext } from \"../api.js\";\nimport { requireAuth } from \"../auth.js\";\nimport {\n DEFAULT_LOCALES_DIR,\n diffFlat,\n type FlatTranslations,\n listLocaleFiles,\n readLocaleFile,\n} from \"../locales.js\";\nimport { getProjectInfo, listKeys } from \"../mcp.js\";\n\nexport const statusCommand = new Command(\"status\")\n .description(\"Diff local locales/ against the remote project state.\")\n .option(\"--language <code>\", \"Restrict to one language code\")\n .option(\"--namespace <slug>\", \"Restrict to one namespace slug\")\n .option(\"--src <dir>\", \"Locales directory\", DEFAULT_LOCALES_DIR)\n .option(\"--host <url>\", \"Override host (otherwise from config/credentials)\")\n .action(\n async (opts: { language?: string; namespace?: string; src: string; host?: string }) => {\n const ctx = await requireAuth({ hostOverride: opts.host });\n const knownLangs = new Set((await getProjectInfo(ctx)).languages);\n\n const files = (await listLocaleFiles(opts.src)).filter((f) => {\n if (opts.language && f.lang !== opts.language) return false;\n if (opts.namespace && f.namespace !== opts.namespace) return false;\n return true;\n });\n\n // Fetch remote once per language, grouped by namespace slug.\n const remoteByLang = new Map<string, Map<string, FlatTranslations>>();\n async function remoteFor(ctx2: ApiContext, lang: string): Promise<Map<string, FlatTranslations>> {\n const cached = remoteByLang.get(lang);\n if (cached) return cached;\n const m = new Map<string, FlatTranslations>();\n for (const it of await listKeys(ctx2, { languageCode: lang })) {\n const tr = it.translations?.find((t) => t.language_code === lang);\n if (!tr || tr.value === \"\") continue;\n const map = m.get(it.namespace_slug) ?? {};\n map[it.key_name] = tr.value;\n m.set(it.namespace_slug, map);\n }\n remoteByLang.set(lang, m);\n return m;\n }\n\n let totalAdded = 0;\n let totalRemoved = 0;\n let totalChanged = 0;\n let totalUnchanged = 0;\n\n for (const f of files) {\n if (knownLangs.size > 0 && !knownLangs.has(f.lang)) {\n console.log(`! ${f.lang}/${f.namespace}.json — language not in project, skipped`);\n continue;\n }\n const local = await readLocaleFile(f.path);\n const remote = (await remoteFor(ctx, f.lang)).get(f.namespace) ?? {};\n const d = diffFlat(local, remote);\n totalAdded += d.added.length;\n totalRemoved += d.removed.length;\n totalChanged += d.changed.length;\n totalUnchanged += d.unchanged;\n\n if (d.added.length === 0 && d.removed.length === 0 && d.changed.length === 0) {\n console.log(`= ${f.lang}/${f.namespace}.json (in sync, ${d.unchanged} keys)`);\n continue;\n }\n console.log(\n `~ ${f.lang}/${f.namespace}.json +${d.added.length} -${d.removed.length} ~${d.changed.length}`,\n );\n for (const k of d.added) console.log(` + ${k}`);\n for (const k of d.removed) console.log(` - ${k} (remote-only — push leaves untouched)`);\n for (const c of d.changed) console.log(` ~ ${c.key} \"${c.local}\" <- \"${c.remote}\"`);\n }\n console.log(\n `summary: +${totalAdded} -${totalRemoved} ~${totalChanged} unchanged=${totalUnchanged}`,\n );\n },\n );\n","import { Command } from \"commander\";\n\nimport { readCredentials } from \"../credentials.js\";\n\nexport const whoamiCommand = new Command(\"whoami\")\n .description(\"Show the configured default host + which API key is in use.\")\n .option(\"--host <url>\", \"Inspect a specific host instead of the default\")\n .action(async (opts: { host?: string }) => {\n const creds = await readCredentials();\n if (!creds.default && Object.keys(creds.hosts).length === 0) {\n console.log(\"Not logged in. Run `sonenta login --host <url> --token <…>`.\");\n process.exit(1);\n }\n const target = opts.host ?? creds.default;\n if (!target) {\n console.log(\"No default host set.\");\n process.exit(1);\n }\n const entry = creds.hosts[target];\n if (!entry) {\n console.log(`No credentials stored for ${target}.`);\n process.exit(1);\n }\n const masked = entry.api_key.replace(/\\.[\\s\\S]+$/, \".•••\");\n const envOverride = (process.env.SONENTA_TOKEN ?? process.env.VERBUMIA_TOKEN)?.trim();\n console.log(`host: ${target}${target === creds.default ? \" (default)\" : \"\"}`);\n console.log(`api_key: ${masked}${envOverride ? \" (overridden by SONENTA_TOKEN env)\" : \"\"}`);\n if (entry.user_email) console.log(`email: ${entry.user_email}`);\n const others = Object.keys(creds.hosts).filter((h) => h !== target);\n if (others.length) {\n console.log(`other: ${others.join(\", \")}`);\n }\n });\n"],"mappings":";;;AAAA,SAAS,WAAAA,iBAAe;;;ACAxB,SAAS,eAAe;;;ACAxB,SAAS,YAAY,UAAU;AAC/B,SAAS,eAAe;AAejB,IAAM,aAAa;AAW1B,IAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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M,SAAS,MAAM,QAAQ,QAAQ,cAAc,qBAAM;AACzD,QAAM,eAAe,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,iBAAiB,KAAK;AACpF,UAAQ,IAAI,cAAc,MAAM,GAAG,WAAW,MAAM,UAAU,gBAAgB,EAAE,EAAE;AAClF,UAAQ,IAAI,cAAc,MAAM,GAAG,cAAc,wCAAwC,EAAE,EAAE;AAC7F,MAAI,MAAM,WAAY,SAAQ,IAAI,cAAc,MAAM,UAAU,EAAE;AAClE,QAAM,SAAS,OAAO,KAAK,MAAM,KAAK,EAAE,OAAO,CAAC,MAAM,MAAM,MAAM;AAClE,MAAI,OAAO,QAAQ;AACjB,YAAQ,IAAI,cAAc,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,EAC/C;AACF,CAAC;;;AzBdH,IAAM,UAAU,IAAIC,UAAQ;AAC5B,QACG,KAAK,SAAS,EACd,YAAY,yCAAyC,EACrD,QAAQ,OAAO;AAElB,QAAQ,WAAW,YAAY;AAC/B,QAAQ,WAAW,aAAa;AAChC,QAAQ,WAAW,aAAa;AAChC,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,eAAe;AAClC,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,aAAa;AAChC,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,aAAa;AAChC,QAAQ,WAAW,aAAa;AAChC,QAAQ,WAAW,eAAe;AAClC,QAAQ,WAAW,eAAe;AAClC,QAAQ,WAAW,cAAc;AACjC,QAAQ,WAAW,aAAa;AAEhC,QAAQ,WAAW,QAAQ,IAAI,EAAE,MAAM,CAAC,QAAiB;AACvD,UAAQ,MAAM,eAAe,QAAQ,IAAI,UAAU,GAAG;AACtD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["Command","fs","resolve","fs","fs","join","Command","Command","join","fs","fs","dirname","Command","dirname","fs","Command","resolve","Command","fs","resolve","Command","resolve","Command","Command","Command","resolve","Command","Command","Command","Command","Command","Command","Command","Command","fs","join","resolve","Command","Command","Command","Command","Command","fs","Command","Command","fs","Command","Command","Command","Command","Command"]}
|