champollion 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +41 -26
  2. package/bin/cli.js +53 -5
  3. package/index.js +63 -2
  4. package/lib/api-key.js +17 -4
  5. package/lib/autofix.js +83 -36
  6. package/lib/bridge/method_bridge.py +15 -3
  7. package/lib/cards/reader.js +34 -0
  8. package/lib/cards/remote.js +15 -0
  9. package/lib/cards/search-names.js +178 -0
  10. package/lib/command-help.js +286 -85
  11. package/lib/commands/audit.js +10 -3
  12. package/lib/commands/card.js +583 -226
  13. package/lib/commands/doctor.js +54 -18
  14. package/lib/commands/help.js +37 -32
  15. package/lib/commands/init.js +1689 -87
  16. package/lib/commands/integrity.js +127 -40
  17. package/lib/commands/leaderboard.js +187 -67
  18. package/lib/commands/models.js +9 -2
  19. package/lib/commands/provenance.js +7 -2
  20. package/lib/commands/recommend.js +43 -14
  21. package/lib/commands/register-corpus.js +632 -125
  22. package/lib/commands/seal-corpus.js +1 -1
  23. package/lib/commands/status.js +564 -27
  24. package/lib/commands/submit.js +17 -12
  25. package/lib/commands/sync.js +31 -7
  26. package/lib/commands/tm.js +15 -9
  27. package/lib/commands/verify.js +27 -3
  28. package/lib/commands/wrap.js +63 -5
  29. package/lib/commands/xliff.js +135 -64
  30. package/lib/commercial-eligibility.js +1 -1
  31. package/lib/config.js +196 -14
  32. package/lib/content-estimate.js +96 -0
  33. package/lib/content-refusals.js +270 -0
  34. package/lib/content-review.js +372 -0
  35. package/lib/content-sync.js +1127 -344
  36. package/lib/content.js +94 -7
  37. package/lib/corpus-registration.mjs +194 -35
  38. package/lib/cost-label.js +29 -0
  39. package/lib/cost-report.js +726 -78
  40. package/lib/diff.js +38 -4
  41. package/lib/docusaurus-sync.js +965 -253
  42. package/lib/edit-distance.js +31 -0
  43. package/lib/fallback.js +964 -0
  44. package/lib/file-scope.js +106 -0
  45. package/lib/flatten.js +80 -3
  46. package/lib/flutter-locales.js +124 -0
  47. package/lib/format.js +266 -12
  48. package/lib/hash.js +146 -21
  49. package/lib/icu-structure.js +929 -0
  50. package/lib/integrity.js +223 -75
  51. package/lib/language-pair.js +157 -0
  52. package/lib/lint.js +78 -16
  53. package/lib/local-only-marks.js +106 -0
  54. package/lib/locale-layout.js +1103 -0
  55. package/lib/locale-state.js +571 -0
  56. package/lib/methods/anthropic.js +5 -0
  57. package/lib/methods/apertium.js +6 -3
  58. package/lib/methods/api.js +138 -25
  59. package/lib/methods/base.js +17 -0
  60. package/lib/methods/coaching-data.js +153 -0
  61. package/lib/methods/content-separator.js +43 -0
  62. package/lib/methods/deepl.js +1 -1
  63. package/lib/methods/direct-llm.js +252 -103
  64. package/lib/methods/external.js +146 -63
  65. package/lib/methods/gemini.js +1 -0
  66. package/lib/methods/google-translate.js +1 -0
  67. package/lib/methods/http-utils.js +41 -0
  68. package/lib/methods/libretranslate.js +7 -2
  69. package/lib/methods/llm-coached.js +68 -128
  70. package/lib/methods/llm.js +80 -31
  71. package/lib/methods/local.js +93 -10
  72. package/lib/methods/microsoft-translator.js +1 -2
  73. package/lib/methods/openai.js +4 -2
  74. package/lib/methods/openrouter-client.js +20 -19
  75. package/lib/methods/openrouter-pricing.js +150 -13
  76. package/lib/methods/prompt-methods.js +20 -0
  77. package/lib/methods/provider-pricing.js +42 -1
  78. package/lib/methods/request-capture.js +104 -0
  79. package/lib/methods/tilde.js +1 -1
  80. package/lib/methods/translated.js +1 -2
  81. package/lib/missing-key.js +93 -0
  82. package/lib/models.js +11 -0
  83. package/lib/name-rules.js +32 -0
  84. package/lib/named-keys.js +172 -0
  85. package/lib/no-translate.js +4 -3
  86. package/lib/output.js +160 -19
  87. package/lib/pairs.js +586 -30
  88. package/lib/placeholders.js +394 -0
  89. package/lib/plugins.js +8 -0
  90. package/lib/plural-gap-redo.js +109 -0
  91. package/lib/plurals.js +323 -0
  92. package/lib/po.js +1187 -0
  93. package/lib/public-catalogue.js +74 -0
  94. package/lib/recommend.js +527 -32
  95. package/lib/redo.js +95 -0
  96. package/lib/refusal-category.js +44 -0
  97. package/lib/registers.js +255 -11
  98. package/lib/repair-script.js +20 -13
  99. package/lib/scripts.js +6 -1
  100. package/lib/seal.mjs +4 -3
  101. package/lib/sealed-qualifier.mjs +1 -1
  102. package/lib/segment.js +2 -1
  103. package/lib/seo.js +19 -9
  104. package/lib/serve.js +43 -6
  105. package/lib/shared-output-seed.js +164 -0
  106. package/lib/source-contexts.js +39 -0
  107. package/lib/submit.mjs +57 -5
  108. package/lib/sync.js +2923 -474
  109. package/lib/terminology.js +13 -4
  110. package/lib/tm-evict.js +179 -0
  111. package/lib/tm-seed.js +5 -2
  112. package/lib/tm.js +818 -36
  113. package/lib/translate-pair.js +639 -34
  114. package/lib/translate.js +78 -5
  115. package/lib/types.js +22 -3
  116. package/lib/validate.js +880 -17
  117. package/lib/verify.js +1296 -104
  118. package/lib/watch.js +32 -13
  119. package/lib/xliff.js +44 -3
  120. package/package.json +1 -1
  121. package/shared/CORPORA-CARDS.md +2 -0
  122. package/shared/cards-fallback.json +1 -1
  123. package/shared/curated-orthography-conventions.json +26 -8
  124. package/shared/gettext-plural-forms.json +45 -0
  125. package/shared/method-registry.json +2 -0
  126. package/shared/metric-registry.json +96 -18
  127. package/shared/schemas/champollion-plugin.schema.json +4 -0
  128. package/shared/schemas/corpora-card.schema.json +8 -2
  129. package/shared/schemas/method-index-record.schema.json +67 -0
  130. package/shared/schemas/method-registry.schema.json +4 -0
  131. package/shared/schemas/metric-registry.schema.json +55 -1
  132. package/shared/docent/corpus.json +0 -11739
@@ -1,36 +1,65 @@
1
1
  /**
2
2
  * Command: recommend
3
3
  *
4
- * Method guidance for a language pair — availability + cited evidence.
5
- * CLI port of `mt-eval recommend` (arena/mt_eval_harness/recommend.py); the
6
- * assembly/honesty logic lives in lib/recommend.js.
4
+ * Method guidance for a language pair — availability + cited evidence, and
5
+ * the open models whose own model card declares the target (runnable via
6
+ * local-model, no published evidence: a claim to benchmark — the same
7
+ * candidates the MCP language_overview suggests). CLI port of `mt-eval
8
+ * recommend` (arena/mt_eval_harness/recommend.py); the assembly/honesty
9
+ * logic lives in lib/recommend.js.
7
10
  *
8
11
  * Usage:
9
- * champollion recommend eng yor # Human-readable guidance
10
- * champollion recommend eng yor --use commercial # STRICT commercial lane
11
- * champollion recommend eng yor --json # Machine-readable payload
12
+ * champollion network recommend eng yor # Human-readable guidance
13
+ * champollion network recommend eng-yor # the same pair, written as one
14
+ * champollion network recommend "eng>yor" # (or --pair "eng>yor")
15
+ * champollion network recommend eng yor --use commercial # STRICT commercial lane
16
+ * champollion network recommend eng yor --json # Machine-readable payload
12
17
  */
13
18
 
14
19
  import { output } from '../output.js';
15
20
  import { recommend, renderText } from '../recommend.js';
16
21
  import { resolveCode } from '../registers.js';
22
+ import { parseLanguagePair } from '../language-pair.js';
17
23
 
18
24
  const USE_CONTEXTS = ['non-commercial', 'commercial'];
19
25
 
26
+ function usageError(why) {
27
+ output.error(why);
28
+ output.error('Usage: champollion network recommend <src> <tgt> [--use commercial] [--json]');
29
+ output.error(' or: champollion network recommend eng-yor (or "eng>yor", or --pair "eng>yor")');
30
+ output.error('Example: champollion network recommend eng yor');
31
+ return 1;
32
+ }
33
+
34
+ /**
35
+ * The pair, from two codes (`recommend eng yor`) or one pair in any spelling
36
+ * lib/language-pair.js reads (`recommend eng-yor`, `recommend "eng>yor"`,
37
+ * `--pair eng-yor`) — Round 10: the other network commands took a pair as
38
+ * one value, and `recommend eng-crk` answered "requires a source and target".
39
+ *
40
+ * @returns {{ok: true, source: string, target: string} | {ok: false, error: string}}
41
+ */
42
+ function readPairArgs(args) {
43
+ const words = args._.slice(1);
44
+ if (args.pair !== undefined && args.pair !== false) {
45
+ if (words.length > 0) return { ok: false, error: `Give the pair once: --pair ${args.pair === true ? '' : args.pair} or ${words.join(' ')}, not both.` };
46
+ return parseLanguagePair(args.pair, { label: '--pair' });
47
+ }
48
+ if (words.length >= 2) return { ok: true, source: words[0], target: words[1] };
49
+ if (words.length === 1) return parseLanguagePair(words[0], { label: 'recommend' });
50
+ return { ok: false, error: 'recommend requires a source and target language code.' };
51
+ }
52
+
20
53
  /**
21
54
  * @param {import('../types.js').CLIArgs} args - Parsed CLI arguments
22
55
  * @param {string} cwd - Working directory
23
56
  * @returns {Promise<number>} Exit code (0 = success, 1 = error)
24
57
  */
25
58
  async function run(args, cwd) {
26
- const srcInput = args._[1];
27
- const tgtInput = args._[2];
28
- if (!srcInput || !tgtInput) {
29
- output.error('recommend requires a source and target language code.');
30
- output.error('Usage: champollion recommend <src> <tgt> [--use commercial] [--json]');
31
- output.error('Example: champollion recommend eng yor');
32
- return 1;
33
- }
59
+ const pairIn = readPairArgs(args);
60
+ if (!pairIn.ok) return usageError(pairIn.error);
61
+ const srcInput = pairIn.source;
62
+ const tgtInput = pairIn.target;
34
63
 
35
64
  // The evidence indexes are keyed by ISO 639-3; accept the 2-letter codes a
36
65
  // champollion.config.json uses (en → eng, zh → cmn) via the language-card