@sonenta/cli 0.3.1 → 0.4.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 +26 -0
- package/dist/index.js +252 -71
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,10 +72,36 @@ scope (see [Auth](#auth)).
|
|
|
72
72
|
| `releases publish` | Trigger a CDN release (publish bundles) |
|
|
73
73
|
| `snapshot` | Emit a build-time `initialBundles` module for `@sonenta/react-i18next` |
|
|
74
74
|
| `missing` | List runtime-detected missing keys |
|
|
75
|
+
| `agents list` | List the bundled Claude agents available to install |
|
|
76
|
+
| `agents add <name>`| Write a bundled agent into `.claude/agents/<name>.md` |
|
|
75
77
|
|
|
76
78
|
Mutating commands accept `--dry-run` and print a `created / updated / unchanged`
|
|
77
79
|
summary.
|
|
78
80
|
|
|
81
|
+
### Installable agents
|
|
82
|
+
|
|
83
|
+
`agents add` drops a ready-made Claude agent into the project's
|
|
84
|
+
`.claude/agents/` directory — usable interactively in Claude Code or headless in
|
|
85
|
+
CI. The flagship agent is **`sonenta-a11y`**, an accessibility auditor that
|
|
86
|
+
drives the Sonenta a11y MCP tools (`a11y_report`, `list_a11y_gaps`,
|
|
87
|
+
`a11y_estimate`, `generate_a11y_variant`, `translate_a11y_variants`,
|
|
88
|
+
`set_a11y_variant`) to find WCAG gaps — missing aria-labels, images without alt
|
|
89
|
+
text, hard-to-read copy, missing or untranslated a11y variants — and propose or
|
|
90
|
+
apply fixes.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# see what's available (and what's already installed)
|
|
94
|
+
sonenta agents list
|
|
95
|
+
|
|
96
|
+
# install the accessibility agent into .claude/agents/
|
|
97
|
+
sonenta agents add sonenta-a11y
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The agent reaches the a11y tools through the
|
|
101
|
+
[`@sonenta/mcp`](https://www.npmjs.com/package/@sonenta/mcp) server, so configure
|
|
102
|
+
that server with an `mcp:*` key first. `--dir <path>` targets another project
|
|
103
|
+
directory; `--force` overwrites an existing definition.
|
|
104
|
+
|
|
79
105
|
### Sync workflow
|
|
80
106
|
|
|
81
107
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,206 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { Command as
|
|
4
|
+
import { Command as Command16 } from "commander";
|
|
5
|
+
|
|
6
|
+
// src/commands/agents.ts
|
|
7
|
+
import { Command } from "commander";
|
|
8
|
+
|
|
9
|
+
// src/agents.ts
|
|
10
|
+
import { promises as fs } from "fs";
|
|
11
|
+
import { resolve } from "path";
|
|
12
|
+
var AGENTS_DIR = ".claude/agents";
|
|
13
|
+
var SONENTA_A11Y = `---
|
|
14
|
+
name: sonenta-a11y
|
|
15
|
+
description: 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 \u2014 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.
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
You are **sonenta-a11y**, an accessibility specialist for internationalized
|
|
19
|
+
projects managed with Sonenta. You turn an accessibility audit into concrete,
|
|
20
|
+
reviewable fixes, operating through the Sonenta MCP server's a11y tools.
|
|
21
|
+
|
|
22
|
+
## Cost model \u2014 generate LOCALLY first (this is the default)
|
|
23
|
+
You ARE a capable language model already running in the developer's session
|
|
24
|
+
(Claude Code or CI), and that compute is already paid for. So **you write the
|
|
25
|
+
a11y values yourself, with your own reasoning, and persist them with
|
|
26
|
+
\`set_a11y_variant\`** \u2014 which is plain CRUD and costs **zero Sonenta AI
|
|
27
|
+
credits**. Do NOT reach for the server-side AI tools
|
|
28
|
+
(\`generate_a11y_variant\` / \`translate_a11y_variants\`) by default: those bill
|
|
29
|
+
Sonenta AI credits and exist only as an explicit fallback for very large volumes
|
|
30
|
+
or when the developer specifically asks for server-side generation.
|
|
31
|
+
|
|
32
|
+
## Requirements
|
|
33
|
+
- The Sonenta MCP server (\`@sonenta/mcp\`) must be configured with an \`mcp:*\`
|
|
34
|
+
API key. Every operation goes through its tools \u2014 never call the HTTP API
|
|
35
|
+
directly. If the a11y tools are missing, tell the user to add the server
|
|
36
|
+
(\`npx -y @sonenta/mcp\`) and set \`SONENTA_API_KEY\`.
|
|
37
|
+
- Tools:
|
|
38
|
+
- \`a11y_report\` \u2014 full WCAG gap report (rollups + per-item gaps). READ-ONLY.
|
|
39
|
+
- \`list_a11y_gaps\` \u2014 the actionable gap list, filterable by gap / surface /
|
|
40
|
+
locale. READ-ONLY.
|
|
41
|
+
- \`set_a11y_variant\` \u2014 **your primary write**: upsert one a11y variant for
|
|
42
|
+
(key_uuid, language_code, surface) with a text value. CRUD, **0 AI credits**,
|
|
43
|
+
stored as a draft.
|
|
44
|
+
- \`delete_a11y_variant\` \u2014 clear one variant. CRUD, **0 AI credits**.
|
|
45
|
+
- \`a11y_estimate\` \u2014 preview the AI-credit cost of the server-side fallback.
|
|
46
|
+
- \`generate_a11y_variant\` / \`translate_a11y_variants\` \u2014 **fallback only**:
|
|
47
|
+
server-side AI generation/translation that BILLS Sonenta AI credits. Use
|
|
48
|
+
only for very large volumes or on explicit developer request.
|
|
49
|
+
|
|
50
|
+
## The four a11y surfaces (what you write)
|
|
51
|
+
- \`aria_label\` \u2014 a concise accessible NAME for an interactive element (button,
|
|
52
|
+
icon, link). Derive it from the element's visible label and purpose.
|
|
53
|
+
- \`alt_text\` \u2014 alternative text for an image. Derive it from the key's context /
|
|
54
|
+
description; describe the image's MEANING, not "image of\u2026".
|
|
55
|
+
- \`screen_reader\` \u2014 verbose screen-reader-only text, for when the visible text
|
|
56
|
+
is insufficient out of context.
|
|
57
|
+
- \`plain_language\` \u2014 a simplified / clear-language (FALC) rewrite of the source.
|
|
58
|
+
|
|
59
|
+
a11y values are SEMANTIC (the accessible name / alt / simplified wording for
|
|
60
|
+
assistive tech), not the visible UI string \u2014 keep them concise and meaningful.
|
|
61
|
+
|
|
62
|
+
## Gap types and how you resolve each (locally, by yourself)
|
|
63
|
+
- \`a11y_variant_absent\` \u2014 a required surface is missing in the source \u2192 compose
|
|
64
|
+
it yourself and \`set_a11y_variant\` (source language).
|
|
65
|
+
- \`alt_missing\` \u2014 an image key has no source alt_text \u2192 write \`alt_text\`.
|
|
66
|
+
- \`reading_level_high\` \u2014 source copy is hard to read with no \`plain_language\`
|
|
67
|
+
\u2192 write a simplified \`plain_language\` value.
|
|
68
|
+
- \`a11y_untranslated\` \u2014 a source a11y variant exists but a locale lacks it \u2192
|
|
69
|
+
TRANSLATE it yourself and \`set_a11y_variant\` for that \`language_code\`.
|
|
70
|
+
|
|
71
|
+
## Workflow
|
|
72
|
+
1. **Scan.** Call \`a11y_report\` (pass \`require_surface\` for the surfaces the
|
|
73
|
+
project needs, typically \`aria_label\` and \`alt_text\`). Summarize
|
|
74
|
+
\`total_gaps\`, \`by_gap\`, \`by_severity\`, \`by_surface\`. Use
|
|
75
|
+
\`list_a11y_gaps\` to pull the actionable items \u2014 each carries \`key_uuid\`,
|
|
76
|
+
\`key_name\`, \`namespace_slug\`, \`surface\`, and \`locale\`.
|
|
77
|
+
2. **Triage.** Group by type/severity \u2014 warnings first (\`a11y_untranslated\`,
|
|
78
|
+
\`alt_missing\`), then info (\`reading_level_high\`, \`a11y_variant_absent\`).
|
|
79
|
+
3. **Generate locally + write (DEFAULT path, 0 credits).** For each gap, compose
|
|
80
|
+
the a11y value YOURSELF \u2014 reasoning over the key name, source value, any
|
|
81
|
+
context/description, and the target surface \u2014 then persist it with
|
|
82
|
+
\`set_a11y_variant(key_uuid, language_code, surface, value)\`. For
|
|
83
|
+
\`a11y_untranslated\`, translate the source variant yourself into the target
|
|
84
|
+
\`language_code\` and \`set_a11y_variant\`. Work through the gap list in
|
|
85
|
+
sensible batches. This spends NO AI credits.
|
|
86
|
+
4. **Server fallback (opt-in only).** If the volume is impractical to do locally,
|
|
87
|
+
or the developer explicitly wants Sonenta server-side generation, FIRST call
|
|
88
|
+
\`a11y_estimate\` (report \`credits_required\` vs \`balance\`; stop if not
|
|
89
|
+
\`sufficient\`), confirm, THEN \`generate_a11y_variant\` /
|
|
90
|
+
\`translate_a11y_variants\`.
|
|
91
|
+
5. **Report.** Everything you write lands as a **draft** for human review \u2014 never
|
|
92
|
+
present it as final. Summarize what you set (counts by surface / locale), what
|
|
93
|
+
remains, and whether any credits were spent (0 on the local path).
|
|
94
|
+
|
|
95
|
+
## Modes
|
|
96
|
+
- **Interactive (Claude Code):** propose the fix plan, then write the local
|
|
97
|
+
fixes; for the credit-billing fallback, show the estimate and confirm first.
|
|
98
|
+
- **CI / headless:** run \`a11y_report\` and exit non-zero when \`total_gaps\` (or
|
|
99
|
+
a chosen severity) exceeds the project threshold; optionally auto-write the
|
|
100
|
+
local fixes. Only use the credit-billing fallback when explicitly authorized.
|
|
101
|
+
|
|
102
|
+
## Guardrails
|
|
103
|
+
- Default to LOCAL generation + \`set_a11y_variant\` (0 credits). Treat
|
|
104
|
+
\`generate_a11y_variant\` / \`translate_a11y_variants\` as an explicit,
|
|
105
|
+
estimated, opt-in fallback \u2014 never the silent default.
|
|
106
|
+
- \`set_a11y_variant\` / \`delete_a11y_variant\` are CRUD and never spend AI
|
|
107
|
+
credits; only \`generate\` / \`translate\` do. Always estimate before that
|
|
108
|
+
fallback.
|
|
109
|
+
- You FILL gaps \u2014 never overwrite a human-reviewed variant blindly.
|
|
110
|
+
- Stay within the configured project; confirm it before any bulk operation.
|
|
111
|
+
`;
|
|
112
|
+
var AGENTS = {
|
|
113
|
+
"sonenta-a11y": {
|
|
114
|
+
name: "sonenta-a11y",
|
|
115
|
+
summary: "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.",
|
|
116
|
+
content: SONENTA_A11Y
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
function listAgents() {
|
|
120
|
+
return Object.values(AGENTS);
|
|
121
|
+
}
|
|
122
|
+
function getAgent(name) {
|
|
123
|
+
return AGENTS[name];
|
|
124
|
+
}
|
|
125
|
+
function agentInstallPath(name, baseDir = process.cwd()) {
|
|
126
|
+
return resolve(baseDir, AGENTS_DIR, `${name}.md`);
|
|
127
|
+
}
|
|
128
|
+
async function isInstalled(name, baseDir = process.cwd()) {
|
|
129
|
+
try {
|
|
130
|
+
await fs.access(agentInstallPath(name, baseDir));
|
|
131
|
+
return true;
|
|
132
|
+
} catch {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function writeAgent(name, opts = {}) {
|
|
137
|
+
const agent = getAgent(name);
|
|
138
|
+
if (!agent) {
|
|
139
|
+
const known = Object.keys(AGENTS).join(", ");
|
|
140
|
+
throw new Error(`Unknown agent "${name}". Available: ${known}`);
|
|
141
|
+
}
|
|
142
|
+
const baseDir = opts.baseDir ?? process.cwd();
|
|
143
|
+
const path = agentInstallPath(name, baseDir);
|
|
144
|
+
if (!opts.force) {
|
|
145
|
+
try {
|
|
146
|
+
await fs.access(path);
|
|
147
|
+
throw new Error(
|
|
148
|
+
`${path} already exists. Pass --force to overwrite.`
|
|
149
|
+
);
|
|
150
|
+
} catch (err) {
|
|
151
|
+
if (err instanceof Error && err.message.includes("already exists")) throw err;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
await fs.mkdir(resolve(baseDir, AGENTS_DIR), { recursive: true });
|
|
155
|
+
await fs.writeFile(path, agent.content, "utf8");
|
|
156
|
+
return path;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/commands/agents.ts
|
|
160
|
+
var agentsCommand = new Command("agents").description("Install bundled Claude agents (e.g. sonenta-a11y) into .claude/agents/.").addCommand(
|
|
161
|
+
new Command("list").description("List the bundled agents available to install.").option("--dir <path>", "Project directory (default: current directory)").action(async (opts) => {
|
|
162
|
+
const baseDir = opts.dir;
|
|
163
|
+
const agents = listAgents();
|
|
164
|
+
console.log(`Available agents (${agents.length}):`);
|
|
165
|
+
for (const a of agents) {
|
|
166
|
+
const installed = await isInstalled(a.name, baseDir);
|
|
167
|
+
const mark = installed ? "\u2713 installed" : " not installed";
|
|
168
|
+
console.log(` ${a.name.padEnd(16)} ${mark}`);
|
|
169
|
+
console.log(` ${a.summary}`);
|
|
170
|
+
}
|
|
171
|
+
console.log(`
|
|
172
|
+
Install with: sonenta agents add <name>`);
|
|
173
|
+
})
|
|
174
|
+
).addCommand(
|
|
175
|
+
new Command("add").description("Write a bundled agent definition into <dir>/.claude/agents/<name>.md.").argument("<name>", "Agent name (e.g. sonenta-a11y)").option("--dir <path>", "Project directory (default: current directory)").option("--force", "Overwrite an existing agent definition", false).action(async (name, opts) => {
|
|
176
|
+
const path = await writeAgent(name, { baseDir: opts.dir, force: opts.force });
|
|
177
|
+
console.log(`Wrote ${path}`);
|
|
178
|
+
console.log(
|
|
179
|
+
`
|
|
180
|
+
The ${name} agent drives the Sonenta a11y MCP tools. Make sure the Sonenta MCP server is configured (npx -y @sonenta/mcp) with an mcp:* SONENTA_API_KEY, then use the agent in Claude Code or CI.`
|
|
181
|
+
);
|
|
182
|
+
console.log(`Agent dir: ${AGENTS_DIR}/`);
|
|
183
|
+
})
|
|
184
|
+
);
|
|
5
185
|
|
|
6
186
|
// src/commands/export.ts
|
|
7
|
-
import { promises as
|
|
187
|
+
import { promises as fs4 } from "fs";
|
|
8
188
|
import { join as join2 } from "path";
|
|
9
|
-
import { Command } from "commander";
|
|
189
|
+
import { Command as Command2 } from "commander";
|
|
10
190
|
|
|
11
191
|
// src/config.ts
|
|
12
|
-
import { promises as
|
|
13
|
-
import { dirname, resolve } from "path";
|
|
192
|
+
import { promises as fs2 } from "fs";
|
|
193
|
+
import { dirname, resolve as resolve2 } from "path";
|
|
14
194
|
var CONFIG_FILENAME = "sonenta.config.json";
|
|
15
195
|
var LEGACY_CONFIG_FILENAME = "verbumia.config.json";
|
|
16
196
|
var warnedLegacy = false;
|
|
17
197
|
async function findConfigPath(startDir) {
|
|
18
|
-
let dir =
|
|
198
|
+
let dir = resolve2(startDir);
|
|
19
199
|
while (true) {
|
|
20
200
|
for (const name of [CONFIG_FILENAME, LEGACY_CONFIG_FILENAME]) {
|
|
21
|
-
const candidate =
|
|
201
|
+
const candidate = resolve2(dir, name);
|
|
22
202
|
try {
|
|
23
|
-
await
|
|
203
|
+
await fs2.access(candidate);
|
|
24
204
|
if (name === LEGACY_CONFIG_FILENAME && !warnedLegacy) {
|
|
25
205
|
warnedLegacy = true;
|
|
26
206
|
process.emitWarning(
|
|
@@ -40,18 +220,18 @@ async function findConfigPath(startDir) {
|
|
|
40
220
|
async function readConfig(startDir = process.cwd()) {
|
|
41
221
|
const path = await findConfigPath(startDir);
|
|
42
222
|
if (!path) return { path: null, config: {} };
|
|
43
|
-
const raw = await
|
|
223
|
+
const raw = await fs2.readFile(path, "utf8");
|
|
44
224
|
const parsed = JSON.parse(raw);
|
|
45
225
|
return { path, config: parsed };
|
|
46
226
|
}
|
|
47
227
|
async function writeConfig(config, targetDir = process.cwd()) {
|
|
48
|
-
const path =
|
|
49
|
-
await
|
|
228
|
+
const path = resolve2(targetDir, CONFIG_FILENAME);
|
|
229
|
+
await fs2.writeFile(path, JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
50
230
|
return path;
|
|
51
231
|
}
|
|
52
232
|
|
|
53
233
|
// src/credentials.ts
|
|
54
|
-
import { promises as
|
|
234
|
+
import { promises as fs3 } from "fs";
|
|
55
235
|
import { homedir } from "os";
|
|
56
236
|
import { join } from "path";
|
|
57
237
|
var credentialsDir = () => join(homedir(), ".verbumia");
|
|
@@ -59,7 +239,7 @@ var credentialsPath = () => join(credentialsDir(), "credentials");
|
|
|
59
239
|
var EMPTY = { hosts: {} };
|
|
60
240
|
async function readCredentials() {
|
|
61
241
|
try {
|
|
62
|
-
const raw = await
|
|
242
|
+
const raw = await fs3.readFile(credentialsPath(), "utf8");
|
|
63
243
|
const parsed = JSON.parse(raw);
|
|
64
244
|
if (!parsed || typeof parsed !== "object" || !parsed.hosts) {
|
|
65
245
|
return EMPTY;
|
|
@@ -73,12 +253,12 @@ async function readCredentials() {
|
|
|
73
253
|
async function writeCredentials(creds) {
|
|
74
254
|
const dir = credentialsDir();
|
|
75
255
|
const path = credentialsPath();
|
|
76
|
-
await
|
|
256
|
+
await fs3.mkdir(dir, { recursive: true, mode: 448 });
|
|
77
257
|
const tmp = `${path}.tmp`;
|
|
78
|
-
await
|
|
79
|
-
await
|
|
80
|
-
await
|
|
81
|
-
await
|
|
258
|
+
await fs3.writeFile(tmp, JSON.stringify(creds, null, 2) + "\n", { mode: 384 });
|
|
259
|
+
await fs3.rename(tmp, path);
|
|
260
|
+
await fs3.chmod(path, 384);
|
|
261
|
+
await fs3.chmod(dir, 448).catch(() => {
|
|
82
262
|
});
|
|
83
263
|
}
|
|
84
264
|
async function setHostEntry(host, entry, options = {}) {
|
|
@@ -273,7 +453,7 @@ async function collect(ctx, languages, namespace) {
|
|
|
273
453
|
}
|
|
274
454
|
return out;
|
|
275
455
|
}
|
|
276
|
-
var exportCommand = new
|
|
456
|
+
var exportCommand = new Command2("export").description(
|
|
277
457
|
"Export Verbumia translations as i18next JSON. Flat dot-notation by default (--nested for nested trees). Writes <out>/<lang>/<namespace>.json with --out, otherwise prints { locale: { namespace: tree } } to stdout."
|
|
278
458
|
).option("--language <code>", "Restrict to a single language code").option("--namespace <slug>", "Restrict to a single namespace slug").option("--nested", "Emit nested JSON instead of flat dot-notation", false).option("--out <dir>", "Write files instead of printing to stdout").option("--host <url>", "Override host (otherwise from config/credentials)").action(
|
|
279
459
|
async (opts) => {
|
|
@@ -286,9 +466,9 @@ var exportCommand = new Command("export").description(
|
|
|
286
466
|
for (const [lang, nss] of Object.entries(collected)) {
|
|
287
467
|
for (const [ns, flat] of Object.entries(nss)) {
|
|
288
468
|
const dir = join2(opts.out, lang);
|
|
289
|
-
await
|
|
469
|
+
await fs4.mkdir(dir, { recursive: true });
|
|
290
470
|
const p = join2(dir, `${ns}.json`);
|
|
291
|
-
await
|
|
471
|
+
await fs4.writeFile(p, JSON.stringify(shape(flat), null, 2) + "\n", "utf8");
|
|
292
472
|
console.log(` ${p} ${Object.keys(flat).length} keys`);
|
|
293
473
|
files++;
|
|
294
474
|
}
|
|
@@ -306,9 +486,9 @@ var exportCommand = new Command("export").description(
|
|
|
306
486
|
);
|
|
307
487
|
|
|
308
488
|
// src/commands/import.ts
|
|
309
|
-
import { promises as
|
|
489
|
+
import { promises as fs5 } from "fs";
|
|
310
490
|
import { basename, dirname as dirname3 } from "path";
|
|
311
|
-
import { Command as
|
|
491
|
+
import { Command as Command3 } from "commander";
|
|
312
492
|
function resolveLangNs(filePath, optLang, optNs) {
|
|
313
493
|
const stem = basename(filePath).replace(/\.json$/i, "");
|
|
314
494
|
const parent = basename(dirname3(filePath));
|
|
@@ -324,7 +504,7 @@ function resolveLangNs(filePath, optLang, optNs) {
|
|
|
324
504
|
return { lang, ns };
|
|
325
505
|
}
|
|
326
506
|
async function readTree(filePath) {
|
|
327
|
-
const parsed = JSON.parse(await
|
|
507
|
+
const parsed = JSON.parse(await fs5.readFile(filePath, "utf8"));
|
|
328
508
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
329
509
|
throw new Error(`${filePath} is not a JSON object`);
|
|
330
510
|
}
|
|
@@ -338,7 +518,7 @@ function countLeaves(tree) {
|
|
|
338
518
|
}
|
|
339
519
|
return n;
|
|
340
520
|
}
|
|
341
|
-
var importCommand = new
|
|
521
|
+
var importCommand = new Command3("import").description(
|
|
342
522
|
"Import i18next JSON file(s) into Verbumia in ONE call \u2014 creates missing keys and upserts translations (idempotent). Accepts nested or flat JSON. Language/namespace are inferred from the path (<lang>/<namespace>.json) or forced with --language / --namespace."
|
|
343
523
|
).argument("<files...>", "i18next JSON file(s), e.g. locales/fr/common.json or fr.json").option("--language <code>", "Force the language code for every file").option("--namespace <slug>", "Force the namespace slug for every file").option("--status <status>", "draft | translated (default: translated)").option("--version <slug>", "Target version slug (default: production version)").option("--dry-run", "Print what would be imported without sending", false).option("--host <url>", "Override host (otherwise from config/credentials)").action(
|
|
344
524
|
async (files, opts) => {
|
|
@@ -381,11 +561,11 @@ var importCommand = new Command2("import").description(
|
|
|
381
561
|
|
|
382
562
|
// src/commands/init.ts
|
|
383
563
|
import { existsSync } from "fs";
|
|
384
|
-
import { resolve as
|
|
385
|
-
import { Command as
|
|
386
|
-
var initCommand = new
|
|
564
|
+
import { resolve as resolve3 } from "path";
|
|
565
|
+
import { Command as Command4 } from "commander";
|
|
566
|
+
var initCommand = new Command4("init").description("Scaffold a sonenta.config.json in the current directory.").option("--host <url>", "API base URL", "https://api.sonenta.com").option("--project <uuid>", "Project UUID").option("--version <slug>", "Version slug (default: main)", "main").option("--force", "Overwrite an existing sonenta.config.json", false).action(
|
|
387
567
|
async (opts) => {
|
|
388
|
-
const path =
|
|
568
|
+
const path = resolve3(process.cwd(), CONFIG_FILENAME);
|
|
389
569
|
if (existsSync(path) && !opts.force) {
|
|
390
570
|
console.error(
|
|
391
571
|
`${CONFIG_FILENAME} already exists at ${path}. Pass --force to overwrite.`
|
|
@@ -407,9 +587,9 @@ var initCommand = new Command3("init").description("Scaffold a sonenta.config.js
|
|
|
407
587
|
);
|
|
408
588
|
|
|
409
589
|
// src/commands/keys.ts
|
|
410
|
-
import { Command as
|
|
411
|
-
var keysCommand = new
|
|
412
|
-
new
|
|
590
|
+
import { Command as Command5 } from "commander";
|
|
591
|
+
var keysCommand = new Command5("keys").description("Inspect translation keys for the current project.").addCommand(
|
|
592
|
+
new Command5("list").description("List keys for the configured project (addressed by namespace slug + key name).").option("--namespace <slug>", "Filter by namespace slug").option("--host <url>", "Override host (otherwise from config/credentials)").action(async (opts) => {
|
|
413
593
|
const ctx = await resolveContext({ hostOverride: opts.host });
|
|
414
594
|
const items = await listKeys(ctx, { namespace: opts.namespace });
|
|
415
595
|
console.log(`total: ${items.length}`);
|
|
@@ -418,7 +598,7 @@ var keysCommand = new Command4("keys").description("Inspect translation keys for
|
|
|
418
598
|
);
|
|
419
599
|
|
|
420
600
|
// src/commands/login.ts
|
|
421
|
-
import { Command as
|
|
601
|
+
import { Command as Command6 } from "commander";
|
|
422
602
|
|
|
423
603
|
// src/prompt.ts
|
|
424
604
|
import { createInterface } from "readline";
|
|
@@ -426,8 +606,8 @@ async function promptLine(message) {
|
|
|
426
606
|
if (!process.stdin.isTTY) return "";
|
|
427
607
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
428
608
|
try {
|
|
429
|
-
return await new Promise((
|
|
430
|
-
rl.question(message, (answer) =>
|
|
609
|
+
return await new Promise((resolve5) => {
|
|
610
|
+
rl.question(message, (answer) => resolve5(answer.trim()));
|
|
431
611
|
});
|
|
432
612
|
} finally {
|
|
433
613
|
rl.close();
|
|
@@ -443,7 +623,7 @@ async function promptSecret(message) {
|
|
|
443
623
|
process.stdout.write(message);
|
|
444
624
|
process.stdin.setRawMode(true);
|
|
445
625
|
process.stdin.resume();
|
|
446
|
-
return await new Promise((
|
|
626
|
+
return await new Promise((resolve5) => {
|
|
447
627
|
let buffer = "";
|
|
448
628
|
const onData = (chunk) => {
|
|
449
629
|
for (const byte of chunk) {
|
|
@@ -452,7 +632,7 @@ async function promptSecret(message) {
|
|
|
452
632
|
process.stdin.removeListener("data", onData);
|
|
453
633
|
process.stdin.setRawMode(false);
|
|
454
634
|
process.stdin.pause();
|
|
455
|
-
|
|
635
|
+
resolve5(buffer);
|
|
456
636
|
return;
|
|
457
637
|
}
|
|
458
638
|
if (byte === CTRL_C) {
|
|
@@ -479,7 +659,7 @@ async function promptSecret(message) {
|
|
|
479
659
|
|
|
480
660
|
// src/commands/login.ts
|
|
481
661
|
var TOKEN_REGEX = /^vrb_[a-z]+_[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
|
|
482
|
-
var loginCommand = new
|
|
662
|
+
var loginCommand = new Command6("login").description(
|
|
483
663
|
"Store an API key for a host. Token resolution order: --token, SONENTA_TOKEN env, then interactive prompt (TTY only)."
|
|
484
664
|
).option("--host <url>", "API base URL", "https://api.sonenta.com").option("--token <vrb_live_\u2026>", "API key token (prefix.secret form)").option("--email <email>", "User email associated with the token (optional)").option("--default", "Set this host as the default for future commands", false).action(async (opts) => {
|
|
485
665
|
let host = opts.host;
|
|
@@ -511,8 +691,8 @@ var loginCommand = new Command5("login").description(
|
|
|
511
691
|
});
|
|
512
692
|
|
|
513
693
|
// src/commands/logout.ts
|
|
514
|
-
import { Command as
|
|
515
|
-
var logoutCommand = new
|
|
694
|
+
import { Command as Command7 } from "commander";
|
|
695
|
+
var logoutCommand = new Command7("logout").description("Remove stored credentials for a host (default: the current default host).").option("--host <url>", "Host to forget. Omit to forget the current default.").action(async (opts) => {
|
|
516
696
|
const creds = await readCredentials();
|
|
517
697
|
const target = opts.host ?? creds.default;
|
|
518
698
|
if (!target) {
|
|
@@ -528,8 +708,8 @@ var logoutCommand = new Command6("logout").description("Remove stored credential
|
|
|
528
708
|
});
|
|
529
709
|
|
|
530
710
|
// src/commands/missing.ts
|
|
531
|
-
import { Command as
|
|
532
|
-
var missingCommand = new
|
|
711
|
+
import { Command as Command8 } from "commander";
|
|
712
|
+
var missingCommand = new Command8("missing").description(
|
|
533
713
|
"List runtime-detected missing keys for the configured project. Requires the API key to carry the `mcp:*` scope."
|
|
534
714
|
).option("--namespace <slug>", "Filter by namespace slug").option("--language <code>", "Filter by language code").option("--status <state>", "Filter by status (open|resolved|...)").option("--limit <n>", "Page size (1-200, default 50)", "50").option("--host <url>", "Override host (otherwise from config/credentials)").action(
|
|
535
715
|
async (opts) => {
|
|
@@ -563,9 +743,9 @@ var missingCommand = new Command7("missing").description(
|
|
|
563
743
|
);
|
|
564
744
|
|
|
565
745
|
// src/commands/projects.ts
|
|
566
|
-
import { Command as
|
|
567
|
-
var projectsCommand = new
|
|
568
|
-
new
|
|
746
|
+
import { Command as Command9 } from "commander";
|
|
747
|
+
var projectsCommand = new Command9("projects").description("Inspect Verbumia projects accessible to your API key.").addCommand(
|
|
748
|
+
new Command9("list").description("List the projects this API key can reach.").option("--host <url>", "Override host (otherwise from config/credentials)").action(async (opts) => {
|
|
569
749
|
const ctx = await resolveContext({ hostOverride: opts.host });
|
|
570
750
|
const items = await listProjects(ctx);
|
|
571
751
|
if (items.length === 0) {
|
|
@@ -581,17 +761,17 @@ var projectsCommand = new Command8("projects").description("Inspect Verbumia pro
|
|
|
581
761
|
);
|
|
582
762
|
|
|
583
763
|
// src/commands/pull.ts
|
|
584
|
-
import { Command as
|
|
764
|
+
import { Command as Command10 } from "commander";
|
|
585
765
|
|
|
586
766
|
// src/locales.ts
|
|
587
|
-
import { promises as
|
|
588
|
-
import { join as join3, resolve as
|
|
767
|
+
import { promises as fs6 } from "fs";
|
|
768
|
+
import { join as join3, resolve as resolve4 } from "path";
|
|
589
769
|
var DEFAULT_LOCALES_DIR = "locales";
|
|
590
770
|
async function listLocaleFiles(rootDir) {
|
|
591
|
-
const root =
|
|
771
|
+
const root = resolve4(rootDir);
|
|
592
772
|
let langDirs;
|
|
593
773
|
try {
|
|
594
|
-
langDirs = await
|
|
774
|
+
langDirs = await fs6.readdir(root);
|
|
595
775
|
} catch {
|
|
596
776
|
return [];
|
|
597
777
|
}
|
|
@@ -600,12 +780,12 @@ async function listLocaleFiles(rootDir) {
|
|
|
600
780
|
const langPath = join3(root, lang);
|
|
601
781
|
let stat;
|
|
602
782
|
try {
|
|
603
|
-
stat = await
|
|
783
|
+
stat = await fs6.stat(langPath);
|
|
604
784
|
} catch {
|
|
605
785
|
continue;
|
|
606
786
|
}
|
|
607
787
|
if (!stat.isDirectory()) continue;
|
|
608
|
-
const files = await
|
|
788
|
+
const files = await fs6.readdir(langPath);
|
|
609
789
|
for (const f of files) {
|
|
610
790
|
if (!f.endsWith(".json")) continue;
|
|
611
791
|
out.push({ lang, namespace: f.replace(/\.json$/, ""), path: join3(langPath, f) });
|
|
@@ -614,7 +794,7 @@ async function listLocaleFiles(rootDir) {
|
|
|
614
794
|
return out;
|
|
615
795
|
}
|
|
616
796
|
async function readLocaleFile(path) {
|
|
617
|
-
const raw = await
|
|
797
|
+
const raw = await fs6.readFile(path, "utf8");
|
|
618
798
|
const parsed = JSON.parse(raw);
|
|
619
799
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
620
800
|
throw new Error(`${path} is not a flat object`);
|
|
@@ -630,12 +810,12 @@ async function readLocaleFile(path) {
|
|
|
630
810
|
}
|
|
631
811
|
async function writeLocaleFile(rootDir, lang, namespace, values) {
|
|
632
812
|
const dir = join3(rootDir, lang);
|
|
633
|
-
await
|
|
813
|
+
await fs6.mkdir(dir, { recursive: true });
|
|
634
814
|
const path = join3(dir, `${namespace}.json`);
|
|
635
815
|
const sorted = Object.fromEntries(
|
|
636
816
|
Object.entries(values).sort(([a], [b]) => a.localeCompare(b))
|
|
637
817
|
);
|
|
638
|
-
await
|
|
818
|
+
await fs6.writeFile(path, JSON.stringify(sorted, null, 2) + "\n", "utf8");
|
|
639
819
|
return path;
|
|
640
820
|
}
|
|
641
821
|
function diffFlat(local, remote) {
|
|
@@ -659,7 +839,7 @@ function diffFlat(local, remote) {
|
|
|
659
839
|
}
|
|
660
840
|
|
|
661
841
|
// src/commands/pull.ts
|
|
662
|
-
var pullCommand = new
|
|
842
|
+
var pullCommand = new Command10("pull").description(
|
|
663
843
|
"Pull translations from Verbumia into locales/<lang>/<namespace>.json (flat dot-notation). Overwrites local files \u2014 pair with `git status`."
|
|
664
844
|
).option("--language <code>", "Restrict to a single language code").option("--namespace <slug>", "Restrict to a single namespace slug").option("--dest <dir>", "Output directory", DEFAULT_LOCALES_DIR).option("--host <url>", "Override host (otherwise from config/credentials)").action(
|
|
665
845
|
async (opts) => {
|
|
@@ -698,8 +878,8 @@ var pullCommand = new Command9("pull").description(
|
|
|
698
878
|
);
|
|
699
879
|
|
|
700
880
|
// src/commands/push.ts
|
|
701
|
-
import { Command as
|
|
702
|
-
var pushCommand = new
|
|
881
|
+
import { Command as Command11 } from "commander";
|
|
882
|
+
var pushCommand = new Command11("push").description(
|
|
703
883
|
"Push the whole local locales/ tree to Verbumia in ONE import call \u2014 creates missing keys and upserts translations (idempotent). Reads locales/<lang>/<namespace>.json (flat dot-notation)."
|
|
704
884
|
).option("--language <code>", "Restrict to a single language code").option("--namespace <slug>", "Restrict to a single namespace slug").option("--src <dir>", "Locales directory", DEFAULT_LOCALES_DIR).option("--status <status>", "draft | translated (default: translated)").option("--version <slug>", "Target version slug (default: production version)").option("--dry-run", "Print what would be pushed without sending", false).option("--host <url>", "Override host (otherwise from config/credentials)").action(
|
|
705
885
|
async (opts) => {
|
|
@@ -746,9 +926,9 @@ var pushCommand = new Command10("push").description(
|
|
|
746
926
|
);
|
|
747
927
|
|
|
748
928
|
// src/commands/releases.ts
|
|
749
|
-
import { Command as
|
|
750
|
-
var releasesCommand = new
|
|
751
|
-
new
|
|
929
|
+
import { Command as Command12 } from "commander";
|
|
930
|
+
var releasesCommand = new Command12("releases").description("Manage CDN releases for the project.").addCommand(
|
|
931
|
+
new Command12("publish").description(
|
|
752
932
|
"Trigger a CDN release: build bundles for every (language, namespace) and push them to the public CDN. Idempotent \u2014 unchanged bundles are reused. Subscribed SDKs receive a live `translations_published` event."
|
|
753
933
|
).option("--language <code>", "Restrict to one language (default: all)").option("--namespace <slug>", "Restrict to one namespace (default: all)").option("--version <slug>", "Version slug (default: production version)").option("--dry-run", "Print the planned release without publishing", false).option("--host <url>", "Override host (otherwise from config/credentials)").action(
|
|
754
934
|
async (opts) => {
|
|
@@ -774,8 +954,8 @@ var releasesCommand = new Command11("releases").description("Manage CDN releases
|
|
|
774
954
|
);
|
|
775
955
|
|
|
776
956
|
// src/commands/snapshot.ts
|
|
777
|
-
import { promises as
|
|
778
|
-
import { Command as
|
|
957
|
+
import { promises as fs7 } from "fs";
|
|
958
|
+
import { Command as Command13 } from "commander";
|
|
779
959
|
function bundleUrl(cdnBase, project, version, lang, ns) {
|
|
780
960
|
return `${cdnBase.replace(/\/+$/, "")}/p/${project}/${version}/latest/${lang}/${ns}.json`;
|
|
781
961
|
}
|
|
@@ -799,7 +979,7 @@ async function fetchBundle(url) {
|
|
|
799
979
|
if (!res.ok) throw new Error(`HTTP ${res.status} fetching ${url}`);
|
|
800
980
|
return await res.json();
|
|
801
981
|
}
|
|
802
|
-
var snapshotCommand = new
|
|
982
|
+
var snapshotCommand = new Command13("snapshot").description(
|
|
803
983
|
"Generate a build-time translations snapshot for @sonenta/react-i18next `initialBundles` (offline-first fallback). Fetches the PUBLIC CDN bundles (exactly what the SDK loads at runtime) and assembles Record<locale, Record<namespace, tree>>. Emits a .ts module (default) or .json."
|
|
804
984
|
).option("--language <code>", "Restrict to a single language code").option("--namespace <slug>", "Restrict to a single namespace slug").option("--version <slug>", "Version slug (default: the configured version_slug)").option("--format <fmt>", "ts | json (default: ts)", "ts").option("--cdn <base>", "CDN base URL", "https://cdn.sonenta.com").option("--out <file>", "Write to a file instead of stdout").option("--host <url>", "Override host (used to discover languages/namespaces)").action(
|
|
805
985
|
async (opts) => {
|
|
@@ -841,7 +1021,7 @@ var snapshotCommand = new Command12("snapshot").description(
|
|
|
841
1021
|
opts.format === "json" ? "json" : "ts"
|
|
842
1022
|
);
|
|
843
1023
|
if (opts.out) {
|
|
844
|
-
await
|
|
1024
|
+
await fs7.writeFile(opts.out, output, "utf8");
|
|
845
1025
|
console.log(
|
|
846
1026
|
`wrote ${opts.out}: ${fetched} bundle(s)` + (missing ? `, ${missing} not published (404)` : "")
|
|
847
1027
|
);
|
|
@@ -853,8 +1033,8 @@ var snapshotCommand = new Command12("snapshot").description(
|
|
|
853
1033
|
);
|
|
854
1034
|
|
|
855
1035
|
// src/commands/status.ts
|
|
856
|
-
import { Command as
|
|
857
|
-
var statusCommand = new
|
|
1036
|
+
import { Command as Command14 } from "commander";
|
|
1037
|
+
var statusCommand = new Command14("status").description("Diff local locales/ against the remote project state.").option("--language <code>", "Restrict to one language code").option("--namespace <slug>", "Restrict to one namespace slug").option("--src <dir>", "Locales directory", DEFAULT_LOCALES_DIR).option("--host <url>", "Override host (otherwise from config/credentials)").action(
|
|
858
1038
|
async (opts) => {
|
|
859
1039
|
const ctx = await resolveContext({ hostOverride: opts.host });
|
|
860
1040
|
const knownLangs = new Set((await getProjectInfo(ctx)).languages);
|
|
@@ -912,8 +1092,8 @@ var statusCommand = new Command13("status").description("Diff local locales/ aga
|
|
|
912
1092
|
);
|
|
913
1093
|
|
|
914
1094
|
// src/commands/whoami.ts
|
|
915
|
-
import { Command as
|
|
916
|
-
var whoamiCommand = new
|
|
1095
|
+
import { Command as Command15 } from "commander";
|
|
1096
|
+
var whoamiCommand = new Command15("whoami").description("Show the configured default host + which API key is in use.").option("--host <url>", "Inspect a specific host instead of the default").action(async (opts) => {
|
|
917
1097
|
const creds = await readCredentials();
|
|
918
1098
|
if (!creds.default && Object.keys(creds.hosts).length === 0) {
|
|
919
1099
|
console.log("Not logged in. Run `sonenta login --host <url> --token <\u2026>`.");
|
|
@@ -941,8 +1121,8 @@ var whoamiCommand = new Command14("whoami").description("Show the configured def
|
|
|
941
1121
|
});
|
|
942
1122
|
|
|
943
1123
|
// src/index.ts
|
|
944
|
-
var program = new
|
|
945
|
-
program.name("sonenta").description("CLI for Sonenta translation management.").version("0.
|
|
1124
|
+
var program = new Command16();
|
|
1125
|
+
program.name("sonenta").description("CLI for Sonenta translation management.").version("0.4.1");
|
|
946
1126
|
program.addCommand(loginCommand);
|
|
947
1127
|
program.addCommand(logoutCommand);
|
|
948
1128
|
program.addCommand(whoamiCommand);
|
|
@@ -957,6 +1137,7 @@ program.addCommand(statusCommand);
|
|
|
957
1137
|
program.addCommand(releasesCommand);
|
|
958
1138
|
program.addCommand(snapshotCommand);
|
|
959
1139
|
program.addCommand(missingCommand);
|
|
1140
|
+
program.addCommand(agentsCommand);
|
|
960
1141
|
program.parseAsync(process.argv).catch((err) => {
|
|
961
1142
|
console.error(err instanceof Error ? err.message : err);
|
|
962
1143
|
process.exit(1);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/commands/export.ts","../src/config.ts","../src/credentials.ts","../src/api.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 { 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.3.0\");\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);\n\nprogram.parseAsync(process.argv).catch((err: unknown) => {\n console.error(err instanceof Error ? err.message : err);\n process.exit(1);\n});\n","import { promises as fs } from \"node:fs\";\nimport { join } from \"node:path\";\n\nimport { Command } from \"commander\";\n\nimport { type ApiContext, resolveContext } from \"../api.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 resolveContext({ 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","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\nexport const credentialsDir = (): string => join(homedir(), \".verbumia\");\nexport const credentialsPath = (): string => join(credentialsDir(), \"credentials\");\n\nconst EMPTY: CredentialsFile = { hosts: {} };\n\nexport async function readCredentials(): Promise<CredentialsFile> {\n try {\n const raw = await fs.readFile(credentialsPath(), \"utf8\");\n const parsed = JSON.parse(raw);\n if (!parsed || typeof parsed !== \"object\" || !parsed.hosts) {\n return EMPTY;\n }\n return parsed as CredentialsFile;\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException)?.code === \"ENOENT\") return { hosts: {} };\n throw err;\n }\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","/**\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 { resolveContext } from \"../api.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 resolveContext({ 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 { resolveContext } from \"../api.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 resolveContext({ 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 { 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 await setHostEntry(\n host,\n { api_key: token, user_email: opts.email },\n { makeDefault: opts.default },\n );\n console.log(`Stored credentials for ${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, resolveContext } from \"../api.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 resolveContext({ 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 { resolveContext } from \"../api.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 resolveContext({ 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 { resolveContext } from \"../api.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 resolveContext({ 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 { resolveContext } from \"../api.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 resolveContext({ 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 { resolveContext } from \"../api.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 resolveContext({ 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 { resolveContext } from \"../api.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 resolveContext({ 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, resolveContext } from \"../api.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 resolveContext({ 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,YAAYC,WAAU;AAC/B,SAAS,QAAAC,aAAY;AAErB,SAAS,eAAe;;;ACHxB,SAAS,YAAY,UAAU;AAC/B,SAAS,SAAS,eAAe;AA4B1B,IAAM,kBAAkB;AACxB,IAAM,yBAAyB;AAEtC,IAAI,eAAe;AAEnB,eAAsB,eAAe,UAA0C;AAC7E,MAAI,MAAM,QAAQ,QAAQ;AAG1B,SAAO,MAAM;AACX,eAAW,QAAQ,CAAC,iBAAiB,sBAAsB,GAAG;AAC5D,YAAM,YAAY,QAAQ,KAAK,IAAI;AACnC,UAAI;AACF,cAAM,GAAG,OAAO,SAAS;AACzB,YAAI,SAAS,0BAA0B,CAAC,cAAc;AACpD,yBAAe;AACf,kBAAQ;AAAA,YACN,GAAG,sBAAsB,sCAAiC,eAAe;AAAA,YAEz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,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;AAEjC,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","join","fs","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/commands/export.ts","../src/config.ts","../src/credentials.ts","../src/api.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.4.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\";\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(\"--force\", \"Overwrite an existing agent definition\", false)\n .action(async (name: string, opts: { dir?: string; force: boolean }) => {\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 - \\`a11y_estimate\\` — preview the AI-credit cost of the server-side fallback.\n - \\`generate_a11y_variant\\` / \\`translate_a11y_variants\\` — **fallback only**:\n server-side AI generation/translation that BILLS Sonenta AI credits. Use\n only 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\\` — source copy is hard to read with no \\`plain_language\\`\n → write a simplified \\`plain_language\\` value.\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. **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\\`.\n2. **Triage.** Group by type/severity — warnings first (\\`a11y_untranslated\\`,\n \\`alt_missing\\`), then info (\\`reading_level_high\\`, \\`a11y_variant_absent\\`).\n3. **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.\n4. **Server fallback (opt-in only).** If the volume is impractical to do locally,\n or the developer explicitly wants Sonenta server-side generation, FIRST call\n \\`a11y_estimate\\` (report \\`credits_required\\` vs \\`balance\\`; stop if not\n \\`sufficient\\`), confirm, THEN \\`generate_a11y_variant\\` /\n \\`translate_a11y_variants\\`.\n5. **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 generation + \\`set_a11y_variant\\` (0 credits). Treat\n \\`generate_a11y_variant\\` / \\`translate_a11y_variants\\` as an explicit,\n estimated, opt-in fallback — never the silent default.\n- \\`set_a11y_variant\\` / \\`delete_a11y_variant\\` are CRUD and never spend AI\n credits; only \\`generate\\` / \\`translate\\` do. Always estimate before that\n 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\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};\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 { join } from \"node:path\";\n\nimport { Command } from \"commander\";\n\nimport { type ApiContext, resolveContext } from \"../api.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 resolveContext({ 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","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\nexport const credentialsDir = (): string => join(homedir(), \".verbumia\");\nexport const credentialsPath = (): string => join(credentialsDir(), \"credentials\");\n\nconst EMPTY: CredentialsFile = { hosts: {} };\n\nexport async function readCredentials(): Promise<CredentialsFile> {\n try {\n const raw = await fs.readFile(credentialsPath(), \"utf8\");\n const parsed = JSON.parse(raw);\n if (!parsed || typeof parsed !== \"object\" || !parsed.hosts) {\n return EMPTY;\n }\n return parsed as CredentialsFile;\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException)?.code === \"ENOENT\") return { hosts: {} };\n throw err;\n }\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","/**\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 { resolveContext } from \"../api.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 resolveContext({ 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 { resolveContext } from \"../api.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 resolveContext({ 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 { 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 await setHostEntry(\n host,\n { api_key: token, user_email: opts.email },\n { makeDefault: opts.default },\n );\n console.log(`Stored credentials for ${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, resolveContext } from \"../api.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 resolveContext({ 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 { resolveContext } from \"../api.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 resolveContext({ 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 { resolveContext } from \"../api.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 resolveContext({ 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 { resolveContext } from \"../api.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 resolveContext({ 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 { resolveContext } from \"../api.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 resolveContext({ 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 { resolveContext } from \"../api.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 resolveContext({ 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, resolveContext } from \"../api.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 resolveContext({ 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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MAAM,MAAM,MAAM;AAClE,MAAI,OAAO,QAAQ;AACjB,YAAQ,IAAI,cAAc,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,EAC/C;AACF,CAAC;;;AvBdH,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","join","Command","fs","resolve","fs","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"]}
|