champollion 0.3.3
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/LICENSE +133 -0
- package/README.md +387 -0
- package/bin/cli.js +278 -0
- package/index.js +135 -0
- package/lib/api-key.js +127 -0
- package/lib/autofix.js +432 -0
- package/lib/bridge/method_bridge.py +430 -0
- package/lib/card-source-resolution.mjs +284 -0
- package/lib/cards/cache.js +169 -0
- package/lib/cards/env.js +82 -0
- package/lib/cards/fetch-card-child.js +38 -0
- package/lib/cards/reader.js +435 -0
- package/lib/cards/refresh.js +111 -0
- package/lib/cards/remote.js +387 -0
- package/lib/cldf-export.mjs +540 -0
- package/lib/cldf-terms.mjs +62 -0
- package/lib/command-help.js +790 -0
- package/lib/commands/audit.js +49 -0
- package/lib/commands/card.js +454 -0
- package/lib/commands/doctor.js +559 -0
- package/lib/commands/fonts.js +489 -0
- package/lib/commands/help.js +91 -0
- package/lib/commands/init.js +1259 -0
- package/lib/commands/integrity.js +148 -0
- package/lib/commands/leaderboard.js +478 -0
- package/lib/commands/lint.js +30 -0
- package/lib/commands/models.js +177 -0
- package/lib/commands/plugin.js +103 -0
- package/lib/commands/provenance.js +45 -0
- package/lib/commands/recommend.js +75 -0
- package/lib/commands/register-corpus.js +678 -0
- package/lib/commands/repair-script.js +42 -0
- package/lib/commands/seal-corpus.js +355 -0
- package/lib/commands/seo.js +72 -0
- package/lib/commands/serve.js +147 -0
- package/lib/commands/status.js +265 -0
- package/lib/commands/submit.js +332 -0
- package/lib/commands/sync.js +89 -0
- package/lib/commands/tm.js +573 -0
- package/lib/commands/verify.js +39 -0
- package/lib/commands/watch.js +20 -0
- package/lib/commands/wrap.js +138 -0
- package/lib/commands/xliff.js +327 -0
- package/lib/commercial-eligibility.js +235 -0
- package/lib/concurrent.js +87 -0
- package/lib/config.js +523 -0
- package/lib/contamination-lane.js +76 -0
- package/lib/content-sync.js +731 -0
- package/lib/content.js +733 -0
- package/lib/corpus-registration.mjs +608 -0
- package/lib/cost-report.js +346 -0
- package/lib/diff.js +155 -0
- package/lib/docusaurus-sync.js +1256 -0
- package/lib/flatten.js +55 -0
- package/lib/format.js +954 -0
- package/lib/hash.js +159 -0
- package/lib/icu.js +473 -0
- package/lib/integrity.js +689 -0
- package/lib/license-gate.mjs +478 -0
- package/lib/license-identify.mjs +229 -0
- package/lib/lint.js +629 -0
- package/lib/method-manifest.js +60 -0
- package/lib/methods/anthropic.js +140 -0
- package/lib/methods/apertium.js +163 -0
- package/lib/methods/api.js +316 -0
- package/lib/methods/base.js +184 -0
- package/lib/methods/content-separator.js +45 -0
- package/lib/methods/deepl.js +426 -0
- package/lib/methods/direct-llm.js +586 -0
- package/lib/methods/external.js +332 -0
- package/lib/methods/fetch-with-retry.js +124 -0
- package/lib/methods/gemini.js +147 -0
- package/lib/methods/google-translate.js +402 -0
- package/lib/methods/http-utils.js +122 -0
- package/lib/methods/libretranslate.js +314 -0
- package/lib/methods/llm-coached.js +670 -0
- package/lib/methods/llm.js +592 -0
- package/lib/methods/local.js +76 -0
- package/lib/methods/microsoft-translator.js +331 -0
- package/lib/methods/openai.js +131 -0
- package/lib/methods/openrouter-client.js +327 -0
- package/lib/methods/openrouter-pricing.js +156 -0
- package/lib/methods/provider-env.js +115 -0
- package/lib/methods/provider-pricing.js +310 -0
- package/lib/methods/tilde.js +150 -0
- package/lib/methods/translated.js +229 -0
- package/lib/methods/translation-error.js +80 -0
- package/lib/models.js +258 -0
- package/lib/no-translate.js +233 -0
- package/lib/output.js +238 -0
- package/lib/pairs.js +547 -0
- package/lib/plugins.js +447 -0
- package/lib/provenance.js +323 -0
- package/lib/recommend.js +648 -0
- package/lib/registers.js +1185 -0
- package/lib/repair-script.js +266 -0
- package/lib/scripts.js +994 -0
- package/lib/seal.mjs +464 -0
- package/lib/sealed-qualifier.mjs +211 -0
- package/lib/security.js +59 -0
- package/lib/segment.js +369 -0
- package/lib/seo.js +275 -0
- package/lib/serve.js +854 -0
- package/lib/string-classify.js +85 -0
- package/lib/submit.mjs +344 -0
- package/lib/sync.js +969 -0
- package/lib/tags/bcp47.js +202 -0
- package/lib/tags/resolve.js +314 -0
- package/lib/terminology.js +111 -0
- package/lib/tm-seed.js +294 -0
- package/lib/tm.js +515 -0
- package/lib/translate-pair.js +197 -0
- package/lib/translate.js +203 -0
- package/lib/types.js +230 -0
- package/lib/validate.js +510 -0
- package/lib/verify.js +451 -0
- package/lib/watch.js +145 -0
- package/lib/xliff.js +184 -0
- package/package.json +93 -0
- package/shared/ATTRIBUTION.md +145 -0
- package/shared/CORPORA-CARDS.md +288 -0
- package/shared/DATA-SOVEREIGNTY.md +500 -0
- package/shared/LANGUAGE-CARD-FIELDS.md +532 -0
- package/shared/card-lint-baseline.json +3189 -0
- package/shared/cards-fallback.json +1 -0
- package/shared/catalogue/card-config.json +6091 -0
- package/shared/catalogue/external-results.json +3888 -0
- package/shared/catalogue/gender-guidance.json +1038 -0
- package/shared/catalogue/method-coverage.json +1751 -0
- package/shared/catalogue/metric-coverage.json +170 -0
- package/shared/catalogue/metric-reliability.json +1 -0
- package/shared/catalogue/register-presets.json +3180 -0
- package/shared/catalogue/vitality-scales.json +55 -0
- package/shared/cldr-index.json +1115 -0
- package/shared/code-bridge.json +253 -0
- package/shared/corpora-cards-v1-reference.md +281 -0
- package/shared/curated-dictionary-flags.json +35 -0
- package/shared/curated-endonyms.json +35 -0
- package/shared/curated-fsts.json +51 -0
- package/shared/curated-orthography-conventions.json +26 -0
- package/shared/curated-sil-resources.json +374 -0
- package/shared/curated-tools.json +41 -0
- package/shared/docent/corpus.json +11333 -0
- package/shared/docent/faq.en.json +564 -0
- package/shared/docent/register-blocks.json +60 -0
- package/shared/docent/system-prompt.md +144 -0
- package/shared/domain-taxonomy.json +35 -0
- package/shared/explainers/glossary.json +2975 -0
- package/shared/explainers/tc-features.json +20112 -0
- package/shared/explainers/term-watchlist.json +147 -0
- package/shared/human-services.json +59 -0
- package/shared/license-corrections.json +261 -0
- package/shared/license-evidence.json +13452 -0
- package/shared/licenses.json +6781 -0
- package/shared/method-registry.json +236 -0
- package/shared/metric-registry.json +620 -0
- package/shared/model-aliases.json +7 -0
- package/shared/schemas/champollion-plugin.schema.json +206 -0
- package/shared/schemas/corpora-card.schema.json +957 -0
- package/shared/schemas/domain-taxonomy.schema.json +64 -0
- package/shared/schemas/external-results.schema.json +314 -0
- package/shared/schemas/human-services.schema.json +90 -0
- package/shared/schemas/language-card.schema.json +1308 -0
- package/shared/schemas/licenses.schema.json +155 -0
- package/shared/schemas/method-card.schema.json +412 -0
- package/shared/schemas/method-registry.schema.json +85 -0
- package/shared/schemas/metric-registry.schema.json +96 -0
- package/shared/schemas/metric-reliability.schema.json +178 -0
- package/shared/schemas/model-aliases.schema.json +27 -0
- package/shared/schemas/source-snapshot.schema.json +96 -0
package/lib/output.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central output controller — routes all CLI messages through a single interface.
|
|
3
|
+
*
|
|
4
|
+
* WHY: Without a central controller, every lib file does its own console.log
|
|
5
|
+
* with inconsistent formatting (emoji prefixes, ad-hoc colors, mixed stderr/stdout).
|
|
6
|
+
* This module provides a single point of control for:
|
|
7
|
+
* - Mode switching: default (clean text), json (machine-readable), quiet (errors only)
|
|
8
|
+
* - Consistent prefixes: [INFO], [OK], [WARN], [ERR]
|
|
9
|
+
* - Stderr routing: warnings and errors always go to stderr
|
|
10
|
+
* - Structured output: --json mode produces parseable JSON objects
|
|
11
|
+
* - Version banner: banner(version) prints startup header
|
|
12
|
+
* - Progress bar: progressBar(completed, total) renders inline █░ progress
|
|
13
|
+
*
|
|
14
|
+
* USAGE:
|
|
15
|
+
* import { output } from './output.js';
|
|
16
|
+
* output.banner('3.4.0'); // startup header
|
|
17
|
+
* output.info('Source file loaded', { keys: 42 });
|
|
18
|
+
* output.ok('Sync complete');
|
|
19
|
+
* output.warn('Missing API key');
|
|
20
|
+
* output.error('Translation failed', { pair: 'en:fr' });
|
|
21
|
+
* output.progressBar(100, 2847); // inline progress
|
|
22
|
+
* output.progressBar(2847, 2847, { done: true }); // finalize with newline
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Output modes:
|
|
27
|
+
* - 'default': Human-readable text with [PREFIX] labels
|
|
28
|
+
* - 'json': Machine-readable JSON objects, one per line
|
|
29
|
+
* - 'quiet': Errors and warnings only (suppress info/ok/progress)
|
|
30
|
+
* - 'verbose': Full detail including debug-level messages
|
|
31
|
+
*/
|
|
32
|
+
let mode = 'default';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Set the output mode. Call once during CLI bootstrap.
|
|
36
|
+
*
|
|
37
|
+
* @param {'default'|'json'|'quiet'|'verbose'} newMode
|
|
38
|
+
*/
|
|
39
|
+
function setMode(newMode) {
|
|
40
|
+
const valid = ['default', 'json', 'quiet', 'verbose'];
|
|
41
|
+
if (!valid.includes(newMode)) {
|
|
42
|
+
console.error(`[ERR] Invalid output mode "${newMode}" — expected one of: ${valid.join(', ')}`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
mode = newMode;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the current output mode.
|
|
50
|
+
*
|
|
51
|
+
* @returns {string}
|
|
52
|
+
*/
|
|
53
|
+
function getMode() {
|
|
54
|
+
return mode;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Informational message — general status updates.
|
|
59
|
+
* Suppressed in quiet mode.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} msg - Human-readable message
|
|
62
|
+
* @param {object} [data] - Structured data (emitted in json mode)
|
|
63
|
+
*/
|
|
64
|
+
function info(msg, data) {
|
|
65
|
+
if (mode === 'quiet') return;
|
|
66
|
+
if (mode === 'json') {
|
|
67
|
+
console.log(JSON.stringify({ level: 'info', message: msg, ...data }));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
console.log(`[INFO] ${msg}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Success message — operation completed correctly.
|
|
75
|
+
* Suppressed in quiet mode.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} msg - Human-readable message
|
|
78
|
+
* @param {object} [data] - Structured data (emitted in json mode)
|
|
79
|
+
*/
|
|
80
|
+
function ok(msg, data) {
|
|
81
|
+
if (mode === 'quiet') return;
|
|
82
|
+
if (mode === 'json') {
|
|
83
|
+
console.log(JSON.stringify({ level: 'ok', message: msg, ...data }));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
console.log(`[OK] ${msg}`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Warning — something is off but not fatal.
|
|
91
|
+
* Always emitted (even in quiet mode). Goes to stderr.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} msg - Human-readable message
|
|
94
|
+
* @param {object} [data] - Structured data (emitted in json mode)
|
|
95
|
+
*/
|
|
96
|
+
function warn(msg, data) {
|
|
97
|
+
if (mode === 'json') {
|
|
98
|
+
console.error(JSON.stringify({ level: 'warn', message: msg, ...data }));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
console.error(`[WARN] ${msg}`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Error — operation failed.
|
|
106
|
+
* Always emitted. Goes to stderr.
|
|
107
|
+
*
|
|
108
|
+
* @param {string} msg - Human-readable message
|
|
109
|
+
* @param {object} [data] - Structured data (emitted in json mode)
|
|
110
|
+
*/
|
|
111
|
+
function error(msg, data) {
|
|
112
|
+
if (mode === 'json') {
|
|
113
|
+
console.error(JSON.stringify({ level: 'error', message: msg, ...data }));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
console.error(`[ERR] ${msg}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Progress message — inline status for long-running operations.
|
|
121
|
+
* Suppressed in quiet and json modes.
|
|
122
|
+
*
|
|
123
|
+
* @param {string} msg - Progress description
|
|
124
|
+
*/
|
|
125
|
+
function progress(msg) {
|
|
126
|
+
if (mode === 'quiet' || mode === 'json') return;
|
|
127
|
+
process.stdout.write(msg);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Debug message — verbose detail, only shown in verbose mode.
|
|
132
|
+
*
|
|
133
|
+
* @param {string} msg - Debug message
|
|
134
|
+
* @param {object} [data] - Structured data
|
|
135
|
+
*/
|
|
136
|
+
function debug(msg, data) {
|
|
137
|
+
if (mode !== 'verbose') return;
|
|
138
|
+
console.log(`[DEBUG] ${msg}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Summary — end-of-command structured report.
|
|
143
|
+
* In json mode, emits a single JSON summary object.
|
|
144
|
+
* In default/verbose mode, prints a formatted summary.
|
|
145
|
+
*
|
|
146
|
+
* @param {object} data - Summary data
|
|
147
|
+
* @param {string} [data.title] - Summary title
|
|
148
|
+
*/
|
|
149
|
+
function summary(data) {
|
|
150
|
+
if (mode === 'quiet') return;
|
|
151
|
+
if (mode === 'json') {
|
|
152
|
+
console.log(JSON.stringify({ level: 'summary', ...data }));
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (data.title) {
|
|
156
|
+
console.log(`\n${data.title}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Version banner — printed once at CLI startup.
|
|
162
|
+
* Suppressed in quiet and json modes.
|
|
163
|
+
*
|
|
164
|
+
* @param {string} version - Package version string
|
|
165
|
+
*/
|
|
166
|
+
function banner(version) {
|
|
167
|
+
if (mode === 'quiet' || mode === 'json') return;
|
|
168
|
+
console.log(`champollion v${version}\n`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Progress bar — inline key-count progress indicator.
|
|
173
|
+
*
|
|
174
|
+
* Renders a bar like: ` ████████░░░░░░░░ 1,440/2,847 keys`
|
|
175
|
+
* Uses carriage return (\r) to overwrite the current line in-place.
|
|
176
|
+
* Call with `done = true` to finalize the line with a newline.
|
|
177
|
+
*
|
|
178
|
+
* Suppressed in quiet and json modes.
|
|
179
|
+
*
|
|
180
|
+
* @param {number} completed - Number of items completed
|
|
181
|
+
* @param {number} total - Total number of items
|
|
182
|
+
* @param {object} [opts] - Options
|
|
183
|
+
* @param {string} [opts.label='keys'] - Unit label
|
|
184
|
+
* @param {boolean} [opts.done=false] - Whether this is the final update (appends newline)
|
|
185
|
+
*/
|
|
186
|
+
function progressBar(completed, total, opts = {}) {
|
|
187
|
+
if (mode === 'quiet' || mode === 'json') return;
|
|
188
|
+
const { label = 'keys', done = false } = opts;
|
|
189
|
+
|
|
190
|
+
// Calculate bar width based on terminal width, with sane defaults
|
|
191
|
+
const termWidth = process.stdout.columns || 80;
|
|
192
|
+
const barWidth = Math.max(10, Math.min(termWidth - 30, 32));
|
|
193
|
+
|
|
194
|
+
const ratio = total > 0 ? completed / total : 0;
|
|
195
|
+
const filled = Math.round(ratio * barWidth);
|
|
196
|
+
const bar = '█'.repeat(filled) + '░'.repeat(barWidth - filled);
|
|
197
|
+
const nums = `${completed.toLocaleString()}/${total.toLocaleString()} ${label}`;
|
|
198
|
+
|
|
199
|
+
if (done) {
|
|
200
|
+
process.stdout.write(`\r ${bar} ${nums}\n`);
|
|
201
|
+
} else {
|
|
202
|
+
process.stdout.write(`\r ${bar} ${nums}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Raw output — bypasses all formatting. Use sparingly for
|
|
208
|
+
* pre-formatted content like tables, ASCII art, or help text.
|
|
209
|
+
*
|
|
210
|
+
* Suppressed in quiet AND json modes: raw is human-facing decoration
|
|
211
|
+
* (separators, banners, tables) that never belongs in a machine-readable
|
|
212
|
+
* stream. Emitting it in json mode would interleave non-JSON lines and
|
|
213
|
+
* break `champollion <cmd> --json | jq`. Structured output goes through
|
|
214
|
+
* info()/ok()/warn()/error()/summary(), which json-encode themselves.
|
|
215
|
+
*
|
|
216
|
+
* @param {string} msg - Raw text to output
|
|
217
|
+
*/
|
|
218
|
+
function raw(msg) {
|
|
219
|
+
if (mode === 'quiet' || mode === 'json') return;
|
|
220
|
+
console.log(msg);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const output = {
|
|
224
|
+
setMode,
|
|
225
|
+
getMode,
|
|
226
|
+
info,
|
|
227
|
+
ok,
|
|
228
|
+
warn,
|
|
229
|
+
error,
|
|
230
|
+
progress,
|
|
231
|
+
debug,
|
|
232
|
+
summary,
|
|
233
|
+
banner,
|
|
234
|
+
progressBar,
|
|
235
|
+
raw,
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export { output };
|