feat(m2-m3): adapter, text pipeline, double-copy capture and Services (T2.1-T2.7, T3.1-T3.4)

M2: TranslationAdapter/AdapterRegistry with documented Hy-MT3 prompts and publisher sampling; all 102 languages with BCP-47 variants, RTL and dense-script flags; normalisation, NLLanguage detection, content classification and exact-join script-aware chunking; protected-token scanning and output validation; prompt policy with one documented fallback; shared TranslationPipeline with Core error mapping. The CLI now reports sourceLanguage and warning codes.

M3: pure DoubleCopyDetector, 120 ms PasteboardWatcher with 750 ms own-write suppression, SystemPasteboard snapshot/restore and markers, CapturePolicy for the 4000/2000 limits, ServicesProvider and the menu-bar action. T3.5 (10-app manual matrix) remains intentionally open.

Docs: ARCHITECTURE, TRANSLATION_OUTPUT, HYMT3_MODEL (§7 spike), SELECTION_AND_CLIPBOARD, PROGRESS; ADR-016 superseded by ADR-017/018.

Verified: make verify green (format, strict lint, scripts, privacy, Debug+Release signatures, package tests); live 7B CLI en→de/de→en/Markdown/JSON/placeholders; empty input exits 2 and unreachable exits 3.
This commit is contained in:
schihei committed 2026-11-26 13:30:32 +01:00
1 parent 26b493e7e5
commit 64078e2f04
80 files changed
+4090 -325

No files matched your search

@@ -0,0 +1,41 @@
/// Dense-script detection for the chunk limit (`docs/TRANSLATION_OUTPUT.md` §3).
///
/// The limit is script-based, not language-based: one CJK, Arabic, Thai or Indic character is
/// enough to select the smaller limit. Latin, Cyrillic and Greek stay on the larger limit.
public enum TextScript {
private static let denseRanges: [ClosedRange<UInt32>] = [
0x0590 ... 0x05FF, // Hebrew
0x0600 ... 0x06FF, // Arabic
0x0750 ... 0x077F, // Arabic Supplement
0x0900 ... 0x097F, // Devanagari
0x0980 ... 0x09FF, // Bengali
0x0A00 ... 0x0A7F, // Gurmukhi
0x0A80 ... 0x0AFF, // Gujarati
0x0B00 ... 0x0B7F, // Oriya
0x0B80 ... 0x0BFF, // Tamil
0x0C00 ... 0x0C7F, // Telugu
0x0C80 ... 0x0CFF, // Kannada
0x0D00 ... 0x0D7F, // Malayalam
0x0D80 ... 0x0DFF, // Sinhala
0x0E00 ... 0x0E7F, // Thai
0x0E80 ... 0x0EFF, // Lao
0x0F00 ... 0x0FFF, // Tibetan
0x1000 ... 0x109F, // Myanmar
0x1200 ... 0x137F, // Ethiopic
0x1780 ... 0x17FF, // Khmer
0x1800 ... 0x18AF, // Mongolian
0x2E80 ... 0x9FFF, // CJK, Hiragana, Katakana and Hangul compatibility
0xA960 ... 0xA97F, // Hangul Jamo Extended-A
0xAC00 ... 0xD7AF, // Hangul syllables
0xF900 ... 0xFAFF, // CJK compatibility ideographs
0xFE30 ... 0xFE4F, // CJK compatibility forms
0xFF66 ... 0xFFDC, // Half-width Katakana and Hangul
]
/// True when `text` contains at least one dense-script scalar.
public static func isDense(_ text: String) -> Bool {
text.unicodeScalars.contains { scalar in
denseRanges.contains { $0.contains(scalar.value) }
}
}
}