dsh-cait 1.0.5 → 1.1.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/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
  <p align="center">
17
17
  <a href="https://www.npmjs.com/package/dsh-cait"><img alt="npm version" src="https://img.shields.io/npm/v/dsh-cait.svg" /></a>
18
18
  <img alt="DSH 0.2.x" src="https://img.shields.io/badge/DSH-0.2.x-4d6bfe.svg" />
19
- <img alt="Tests: 15 suites" src="https://img.shields.io/badge/tests-15%20suites-brightgreen.svg" />
19
+ <img alt="Tests: 29 suites" src="https://img.shields.io/badge/tests-29%20suites-brightgreen.svg" />
20
20
  <img alt="No API key required" src="https://img.shields.io/badge/API%20key-not%20required-6b7280.svg" />
21
21
  </p>
22
22
 
@@ -34,7 +34,7 @@ translated document.
34
34
  | | |
35
35
  |---|---|
36
36
  | **Native to DSH** | A real sidebar panel, a main workbench, DSH theme tokens, and the same store for humans and agents. No iframe, no separate app. |
37
- | **TM that explains itself** | Multiple TM libraries, mounted-only lookup, exact / near-exact / high / medium / low fuzzy grades, and automatic write-back on confirm. |
37
+ | **TM that explains itself** | Multiple TM libraries, mounted-only lookup, 101% context (ICE) matches, exact / near-exact / high / medium / low fuzzy grades, and automatic write-back on confirm. |
38
38
  | **Glossary-aware editing** | Multiple term bases, source-language filtering, inline highlighting, click-to-insert terms, and per-term case sensitivity. |
39
39
  | **A document workflow** | Tabs, close/reopen, recent-document cleanup, duplicate-import reuse, and progress per document. |
40
40
  | **Real format coverage** | TXT, Markdown, DOCX, EPUB, TMX, CSV, SRT/VTT, PO, XLIFF 1.2/2.0/SDLXLIFF, HTML, JSON, XLSX, PPTX, and RTF. |
@@ -60,6 +60,10 @@ manual reload.
60
60
  ### Translation memory
61
61
 
62
62
  - Multiple TM libraries with id, name, mount state, and a default write library.
63
+ - **Context match (ICE) at 101%.** Each confirmation records the two neighbouring
64
+ source sentences. A later segment with the same neighbours scores 101% and is
65
+ graded `context`; identical text with different neighbours stays at 100%. A key
66
+ keeps up to 8 context variants and always keeps the context-free one.
63
67
  - Exact, near-exact, and three fuzzy bands:
64
68
  - `near_exact` compares a key that ignores digits, punctuation, and whitespace;
65
69
  it does not depend on a score cutoff.
@@ -74,7 +78,8 @@ manual reload.
74
78
  `bootstrap().tm.count` is the mounted count and `bootstrap().tm.total` is the
75
79
  all-library count. Use `cat_lookup_tm` or the library modal for full data.
76
80
  - TMX 1.4 `<tu>/<tuv>/<seg>` import/export. Inline TMX placeholders are flattened
77
- to plain text with an explicit warning.
81
+ to plain text with an explicit warning. Context travels as
82
+ `<prop type="x-context">`, so a CAIT round-trip keeps 101% matches.
78
83
 
79
84
  ### Glossary
80
85
 
@@ -83,11 +88,71 @@ manual reload.
83
88
  - CSV/TSV import, per-term notes, source-language filtering, and a
84
89
  `caseSensitive` flag honored by both the workbench and `cat_lookup_glossary`.
85
90
  - Language codes are canonicalized (`EN` → `en`, `ZH_cn` → `zh-CN`).
91
+ - Entries can be edited or deleted in any library, mounted or not; mount state
92
+ only decides what the workbench searches and writes.
93
+ - **Terminology mining**: *Mine terms from the document* in the glossary toolbar
94
+ lists candidates with occurrence counts, sample wording from memory, and a
95
+ marker when the term is already known. Counting finds the candidates and ranks
96
+ them (Latin n-grams, repeated CJK substrings filtered by boundary entropy);
97
+ a model only judges a shortlist, which is the part models are good at.
98
+
99
+ ### Library workspace
100
+
101
+ `Documents` / `Libraries` / `Align` in the topbar switches between the translator
102
+ and the library manager. The library view needs no open document.
103
+
104
+ - One table for translation memory, one for glossaries, with paging
105
+ (20/50/100/200, remembered), language filters, and a search that can be scoped
106
+ to any combination of libraries.
107
+ - A side panel edits the selected entry in place, adds entries, and shows when a
108
+ draft is unsaved.
109
+ - Translation memory exports to **TMX**; glossaries export to **TBX**, **CSV**, or
110
+ **JSON**. Import and clear stay available in the same toolbar.
111
+ - The right panel's library button opens this workspace with the panel's search
112
+ text already applied, so a lookup in the panel continues in the full list.
113
+
114
+ ### Alignment
115
+
116
+ `Documents` / `Libraries` / `Align` — the third view builds a translation
117
+ memory from two finished files: the source document and its translation, as
118
+ separate files in any supported format and any pair of languages.
119
+
120
+ - Cross-language scoring: shared anchors (numbers, `{0}` placeholders, URLs,
121
+ capitalised names), length normalised per language, and paragraph structure.
122
+ Word overlap is deliberately not used, because it cannot compare two languages.
123
+ - Blocked dynamic programming pairs 1:1, 1:0, 0:1, 2:1 and 1:2; rows are graded
124
+ high / to review / doubtful and start selected only when they are high.
125
+ - Each row can be merged with the next, split on line breaks, or removed before
126
+ writing; the target library is chosen in the toolbar, and identical entries are
127
+ skipped rather than duplicated.
86
128
 
87
129
  ### Workbench
88
130
 
89
131
  - Paragraph/sentence segmentation with a per-segment target editor.
90
- - Draft saving, confirm-and-next, previous/next navigation, and progress.
132
+ - Segment states: **pending** → **translated** → **confirmed**, with the origin of
133
+ each translation (`tm`, `mt`, `agent`, `manual`) kept alongside the text. The
134
+ rail filters by state and search covers source, target, and suggestions.
135
+ - **Segment paging**: the rail pages through the filtered segments with a page
136
+ size of 20/50/100/200 and a box to jump straight to a segment number. Jumping
137
+ clears the filter when the target segment would otherwise be hidden.
138
+ - **Pre-translate** fills the whole document from exact TM matches and machine
139
+ translation in small blocks, shows `done/total`, and can be stopped between
140
+ blocks. Confirmed and already-translated segments are never overwritten.
141
+ - **Stacked review**: source, the machine/agent baseline, and the editable target
142
+ are laid out top to bottom, so each block gets the full pane width.
143
+ **Confirm all** accepts every segment awaiting review after one confirmation
144
+ dialog.
145
+ - Draft saving, confirm-and-next, previous/next navigation, and progress. The
146
+ selected segment and the draft are persisted (debounced) so a restart resumes
147
+ where you left off.
148
+ - **Repeated segments are mirrored**: confirming a sentence fills every other
149
+ unconfirmed copy with the same source (`origin: auto`), editing a draft keeps
150
+ them in sync, and *Fill repeated segments* does the whole document at once.
151
+ Confirmed segments are never touched.
152
+ - Advisory QA markers in the rail and an export-time summary: missing
153
+ placeholders/tags, mismatched numbers, unused glossary terms, empty targets,
154
+ an untouched copy of the source, and one source with several translations.
155
+ Nothing is blocked and nothing is stored.
91
156
  - Document tabs; closing a tab does not delete the document.
92
157
  - **Open existing document** reopens a closed document.
93
158
  - Interface language switch in **Settings → Interface**: *Follow DSH language*
@@ -100,9 +165,12 @@ manual reload.
100
165
  - Re-importing identical content in the same format reuses the existing document
101
166
  instead of creating a duplicate. The fingerprint covers languages, source,
102
167
  format, and exchange metadata.
103
- - Responsive density: the workbench measures its DSH panel and applies a
104
- `--cait-u` multiplier of 1×–1.8×. A 1600×900 panel renders at ~1.32× and a
105
- 2560×1440 panel at 1.8×; short windows stay at 1× rather than shrinking.
168
+ - Responsive density: the workbench measures its DSH panel and applies a damped
169
+ `--cait-u` multiplier of 1×–1.45×. A 1600×900 panel renders at ~1.17× and a
170
+ maximized 4K panel stops at 1.45×, which keeps large windows close to the host
171
+ UI and leaves room for the three review columns.
172
+ - The workbench follows the host light/dark theme, including native controls
173
+ (`color-scheme`), so selects, checkboxes, and scrollbars match the panel.
106
174
 
107
175
  ### Preprocessing
108
176
 
@@ -141,7 +209,7 @@ provider/model/code/status; the client receives only `MT_PROVIDER_FAILED`.
141
209
  | CSV | ✅ | ✅ | Comma, semicolon, tab, or pipe delimiter auto-detected; source/target column by header name or 1-based number; existing bilingual export |
142
210
  | DOCX | ✅ | ✅ | Body paragraphs; table blocks are excluded from import. Export patches the original package, keeping styles, numbering, images, headers, tables, and layout. |
143
211
  | EPUB | ✅ | ✅ | EPUB 3 spine order; XHTML text blocks with inline markup kept as tokens and patched back into the retained package. DRM-protected, fixed-layout, and scripted EPUBs are not supported. |
144
- | TMX 1.4 | ✅ | ✅ | Common `<tu>/<tuv>/<seg>` subset; inline markup flattened with warning |
212
+ | TMX 1.4 | ✅ | ✅ | Common `<tu>/<tuv>/<seg>` subset; inline markup flattened with warning; context kept in `<prop type="x-context">` |
145
213
  | SRT / WebVTT | ✅ | ✅ | One cue per segment, timings/settings/identifier retained; semantic tags kept; invalid ranges rejected |
146
214
  | PO | ✅ | ✅ | Contexts, plural forms, translator comments, obsolete `#~` entries |
147
215
  | XLIFF 1.2 | ✅ | ✅ | Inline tags become `{n}` tokens; missing tokens block confirmation |
@@ -195,7 +263,7 @@ In DSH Desktop (or any profile with the `plugin_manager` tool):
195
263
  plugin_manager install_bundle target: dsh-cait
196
264
  ```
197
265
 
198
- Pin a release with `dsh-cait@1.0.5`, or ask for the newest one with
266
+ Pin a release with `dsh-cait@1.1.3`, or ask for the newest one with
199
267
  `dsh-cait@latest`. The manager resolves the registry package, applies the bundle
200
268
  patch, and activates the plugin — no hand-written profile rows.
201
269
 
@@ -276,8 +344,9 @@ confirmation. Other structural edits remain best-effort and surface
276
344
 
277
345
  If the snapshot is corrupt or has an unknown version, CAIT logs a warning, moves
278
346
  it to `store.json.corrupt-<timestamp>`, and starts empty instead of failing
279
- activation. Version-1 snapshots are migrated to version 2 with default TM and
280
- glossary libraries.
347
+ activation. Version-1 and version-2 snapshots are migrated to version 3 with
348
+ default TM and glossary libraries; a version-2 draft that had text but was never
349
+ confirmed becomes `translated` with `origin: manual`.
281
350
 
282
351
  ## Agent tools
283
352
 
@@ -290,6 +359,20 @@ glossary libraries.
290
359
  | `cat_list_documents` | List documents and progress |
291
360
  | `cat_switch_document` | Select the active document |
292
361
  | `cat_suggest_mt` | MT via the selected DSH route, or the explicit offline fallback |
362
+ | `cat_pre_translate` | Fill one block from TM + MT, skipping confirmed/translated segments; returns `next` |
363
+ | `cat_get_segments` | Bounded segment window with status, origin, and suggestions |
364
+ | `cat_confirm_segments` | Confirm a list of indices, a window, or everything awaiting review |
365
+ | `cat_propose_translation` | Leave a suggestion plus a reason without touching the confirmed target |
366
+ | `cat_align` | Align two texts and report high / to-review / doubtful pairs |
367
+ | `cat_consistency_report` | Group repeated sources that carry different translations |
368
+ | `cat_term_candidates` | Mining shortlist: frequency, sample sentences, existing memory wording |
369
+ | `cat_add_terms` | Add accepted terminology to a library in one batch |
370
+
371
+ An agent can therefore draft a whole document without clicking in the UI:
372
+ `cat_pre_translate` with `from: next` until `next` is `null`, then
373
+ `cat_get_segments` to review, then `cat_confirm_segments` to accept. For
374
+ terminology it reads `cat_term_candidates`, judges the shortlist, and writes the
375
+ result with `cat_add_terms`.
293
376
 
294
377
  The workbench and tools share one `CatStore`, so an agent can translate the same
295
378
  document the user has open.
@@ -300,7 +383,7 @@ document the user has open.
300
383
  flowchart LR
301
384
  UI["DSH Web UI<br/>(sidebar + workbench)"] --> Client["client.js<br/>generated Web bundle"]
302
385
  Client --> API["/cait/api/rpc<br/>same-origin JSON"]
303
- Tools["7 agent tools"] --> Store["CatStore"]
386
+ Tools["15 agent tools"] --> Store["CatStore"]
304
387
  API --> Store
305
388
  Store --> Snapshot[("store.json<br/>+ sources/")]
306
389
  ```
@@ -335,6 +418,8 @@ cait/
335
418
  │ ├─ errors.js
336
419
  │ ├─ store-utils.js
337
420
  │ ├─ libraries.js # TM/glossary registries + mounts
421
+ │ ├─ library-view.js # Library paging/search + export entry points
422
+ │ ├─ library-export.js # Glossary TBX / CSV / JSON builders
338
423
  │ ├─ tm.js
339
424
  │ ├─ glossary.js
340
425
  │ ├─ persistence.js
@@ -343,6 +428,8 @@ cait/
343
428
  │ ├─ html.js # Shared HTML/XHTML run scanner + patcher
344
429
  │ ├─ epub.js # EPUB package read / spine import / patch export
345
430
  │ ├─ preprocess.js # Import-time source cleaning stage
431
+ │ ├─ pre-translate.js # Block pre-translation methods
432
+ │ ├─ qa.js # Derived QA report (never persisted)
346
433
  │ ├─ xlsx.js
347
434
  │ ├─ pptx.js
348
435
  │ ├─ segmenter.js
@@ -383,11 +470,20 @@ node _dev/test-libraries.mjs
383
470
  node _dev/test-mounts.mjs
384
471
  node _dev/test-ui-scale.mjs
385
472
  node _dev/test-mt.mjs
473
+ node _dev/test-mt-routes.mjs
474
+ node _dev/test-three-state.mjs
475
+ node _dev/test-pretranslate.mjs
476
+ node _dev/test-qa.mjs
477
+ node _dev/test-library-crud.mjs
478
+ node _dev/test-library-view.mjs
479
+ node _dev/test-pagination.mjs
480
+ node _dev/test-theme-tokens.mjs
481
+ node _dev/test-e2e-1.1.mjs
386
482
  ```
387
483
 
388
484
  The import/export fixtures are `_dev/sample.docx`, `_dev/sample-table.docx`, and
389
485
  `_dev/sample-format.docx`; regenerate them with the matching
390
- `python _dev/make-*.py` scripts. All 15 suites should pass.
486
+ `python _dev/make-*.py` scripts. All 29 suites should pass.
391
487
 
392
488
  ### Releasing
393
489
 
@@ -444,13 +540,18 @@ GitHub with a release.
444
540
  - HTML/RTF export does not round-trip original styling; JSON translates string
445
541
  values only.
446
542
  - TM matching is lexical, not semantic; no stemming, synonyms, or embeddings.
447
- - Library rename/delete and per-tab mount state are not implemented yet.
543
+ - One translation per source text per context: a repeated sentence keeps a
544
+ separate variant for each surrounding pair, capped at 8 variants per key, and
545
+ reuses the generic entry when the neighbours differ.
546
+ - Context is the two neighbouring source sentences only; document, customer, or
547
+ project metadata is not part of the match.
548
+ - TBX and JSON glossary exports are one-way; only TMX and CSV import back.
448
549
  - The workbench UI ships in Chinese, English, and Japanese, switchable in
449
550
  Settings; this README ships in English, Simplified Chinese, and Japanese, and
450
551
  the English version is the source of truth.
451
552
 
452
- Planned next: image/vision input through a multimodal DSH route, richer library
453
- management, style-preserving XLSX output, and XLIFF `<alt-trans>` / notes support.
553
+ Planned next: image/vision input through a multimodal DSH route,
554
+ style-preserving XLSX output, and XLIFF `<alt-trans>` / notes support.
454
555
 
455
556
  ## Changelog and versioning
456
557
 
@@ -458,9 +559,15 @@ See [CHANGELOG.md](CHANGELOG.md). `v1.0.0` was the first public release;
458
559
  `v1.0.1` adds the Japanese UI and the in-app interface language switch,
459
560
  `v1.0.2` makes *Follow DSH language* honour the DSH locale, `v1.0.3`
460
561
  publishes the package to npm, `v1.0.4` moves later releases to the
461
- provenance-publishing workflow, and `v1.0.5` adds EPUB, import preprocessing,
462
- and the PDF policy. The project was developed as `0.1.0` and
463
- renumbered for the GitHub release.
562
+ provenance-publishing workflow, `v1.0.5` adds EPUB, import preprocessing,
563
+ and the PDF policy, `v1.1.0` adds agent-driven pre-translation, the
564
+ three-state segment model, stacked review, and advisory QA, `v1.1.1` adds
565
+ the library workspace with TMX/TBX/CSV/JSON export, segment paging, and the
566
+ panel-to-library jump, `v1.1.2` adds context-aware memory with 101% (ICE)
567
+ matches, and `v1.1.3` adds two-file alignment, automatic propagation of
568
+ repeated segments, terminology mining, and the proposal primitive agents use.
569
+ The project
570
+ was developed as `0.1.0` and renumbered for the GitHub release.
464
571
 
465
572
  > **License:** Apache License 2.0 — see [LICENSE](LICENSE). Redistributions must
466
573
  > retain the attribution in [NOTICE](NOTICE).
package/README.zh-CN.md CHANGED
@@ -16,12 +16,12 @@
16
16
  <p align="center">
17
17
  <a href="https://www.npmjs.com/package/dsh-cait"><img alt="npm 版本" src="https://img.shields.io/npm/v/dsh-cait.svg" /></a>
18
18
  <img alt="DSH 0.2.x" src="https://img.shields.io/badge/DSH-0.2.x-4d6bfe.svg" />
19
- <img alt="15 套测试" src="https://img.shields.io/badge/tests-15%20suites-brightgreen.svg" />
19
+ <img alt="29 套测试" src="https://img.shields.io/badge/tests-29%20suites-brightgreen.svg" />
20
20
  <img alt="无需 API Key" src="https://img.shields.io/badge/API%20key-not%20required-6b7280.svg" />
21
21
  </p>
22
22
 
23
23
  CAIT 为 DSH Web UI 和 DSH 桌面端增加一个 CAT 翻译工作台。它从左侧栏入口打开,
24
- 工作台与七个 Agent 工具共用一个数据存储,覆盖从导入源文件到导出译文的完整流程。
24
+ 工作台与十五个 Agent 工具共用一个数据存储,覆盖从导入源文件到导出译文的完整流程。
25
25
 
26
26
  > **已在 DSH `0.2.2-rc.1` 中验证。** CAIT 使用 DSH 自己的模型路由和凭据,
27
27
  > 不会要求用户填写 API Key。内部回退提供方仍叫 `mock`,界面显示为
@@ -32,11 +32,11 @@ CAIT 为 DSH Web UI 和 DSH 桌面端增加一个 CAT 翻译工作台。它从
32
32
  | | |
33
33
  |---|---|
34
34
  | **原生集成 DSH** | 真正的侧栏入口、主工作台、DSH 主题令牌,以及人和 Agent 共用的同一份数据。不是 iframe,也不是另一个独立应用。 |
35
- | **可解释的翻译记忆** | 支持多个 TM 库、仅检索已挂载库、精确/近似精确/高/中/低模糊等级,确认句段时自动写回。 |
35
+ | **可解释的翻译记忆** | 支持多个 TM 库、仅检索已挂载库、上下文 101%、精确/近似精确/高/中/低模糊等级,确认句段时自动写回。 |
36
36
  | **术语感知编辑** | 支持多个术语库、按源语言过滤、行内高亮、点击插入术语,以及按术语设置是否区分大小写。 |
37
37
  | **完整文档流程** | 文档标签页、关闭/重新打开、最近文档清理、重复导入复用、逐文档进度。 |
38
38
  | **真实格式覆盖** | TXT、Markdown、DOCX、EPUB、TMX、CSV、SRT/VTT、PO、XLIFF 1.2/2.0/SDLXLIFF、HTML、JSON、XLSX、PPTX、RTF。 |
39
- | **面向 Agent** | 七个工具共享当前文档和存储,Agent 可以与用户同时翻译。 |
39
+ | **面向 Agent** | 十个工具共享当前文档和存储,Agent 可以与用户同时翻译。 |
40
40
 
41
41
  ## 快速开始
42
42
 
@@ -56,6 +56,9 @@ CAIT 为 DSH Web UI 和 DSH 桌面端增加一个 CAT 翻译工作台。它从
56
56
  ### 翻译记忆
57
57
 
58
58
  - 支持多个 TM 库,每个库有 id、名称、挂载状态和默认写入库。
59
+ - **上下文匹配(ICE)为 101%。** 每次确认都会记录前后两句源文;之后相邻句相同的
60
+ 句段得 101%,等级为 `context`;文本相同但相邻句不同仍为 100%。每个 key 最多保留
61
+ 8 条上下文变体,并且始终保留无上下文的那一条。
59
62
  - 支持精确、近似精确和三个模糊等级:
60
63
  - `near_exact` 使用忽略数字、标点和空白后的 key 比较,不依赖分数阈值。
61
64
  - `high_fuzzy` 为 `>= 0.85`,`medium_fuzzy` 为 `0.75–0.85`,
@@ -68,7 +71,8 @@ CAIT 为 DSH Web UI 和 DSH 桌面端增加一个 CAT 翻译工作台。它从
68
71
  `bootstrap().tm.count` 是已挂载数量,`bootstrap().tm.total` 是所有库的总数。
69
72
  完整数据请使用 `cat_lookup_tm` 或库面板。
70
73
  - 支持 TMX 1.4 `<tu>/<tuv>/<seg>` 导入/导出。TMX 内联占位符会扁平化为
71
- 纯文本,并给出明确警告。
74
+ 纯文本,并给出明确警告。上下文以 `<prop type="x-context">` 往返,所以 CAIT
75
+ 自己导出的文件再导入后仍保留 101% 匹配。
72
76
 
73
77
  ### 术语库
74
78
 
@@ -77,11 +81,57 @@ CAIT 为 DSH Web UI 和 DSH 桌面端增加一个 CAT 翻译工作台。它从
77
81
  - 支持 CSV/TSV 导入、术语备注、源语言过滤,以及工作台和
78
82
  `cat_lookup_glossary` 都遵循的 `caseSensitive` 标记。
79
83
  - 语言代码会规范化(`EN` → `en`,`ZH_cn` → `zh-CN`)。
84
+ - 任何库(无论是否挂载)里的条目都能编辑或删除;挂载状态只决定工作台搜索
85
+ 和写入哪些库。
86
+ - **术语提取**:术语库工具栏的「从文档提取术语」会列出候选词,带出现次数、
87
+ 记忆库里已有的译法和「已有」标记。统计负责找候选并排序(拉丁 n-gram;
88
+ 中日韩重复子串用左右邻接熵过滤),模型只判断一份短名单——这正是模型擅长
89
+ 的部分。
90
+
91
+ ### 库页面
92
+
93
+ 顶栏的「文档 / 库 / 对齐」在三个工作区之间切换,库页面不需要打开文档。
94
+
95
+ - TM 一张表、术语一张表,支持分页(20/50/100/200,会记住)、语言筛选,以及
96
+ 可限定在任意若干库内的搜索。
97
+ - 右侧边栏直接编辑选中的条目、新增条目,并在有未保存改动时提示。
98
+ - TM 导出 **TMX**;术语库导出 **TBX**、**CSV** 或 **JSON**。导入与清空仍在同一
99
+ 个工具栏里。
100
+ - 右侧面板的库按钮会把面板当前的搜索词一起带进库页面,在面板里查到的东西
101
+ 可以接着在完整列表里看。
102
+
103
+ ### 对齐
104
+
105
+ 顶栏的「文档 / 库 / 对齐」第三个视图用两份成品文件建记忆库:源文一份、
106
+ 译文一份,可以是完全不同的语言,格式任选。
107
+
108
+ - 跨语言打分:共享锚点(数字、`{0}` 占位符、URL、首字母大写的名字)、按语言
109
+ 归一化的长度比例、段落结构。刻意不用字面相似度,因为它比不了两种语言。
110
+ - 分块动态规划可以配对 1:1、1:0、0:1、2:1、1:2;每行分高置信 / 待确认 / 可疑
111
+ 三档,只有高置信默认勾选。
112
+ - 写入前每行都能与下一行合并、按换行拆开或删除;目标库在工具栏里选,完全
113
+ 相同的条目会被跳过而不是重复写入。
80
114
 
81
115
  ### 工作台
82
116
 
83
117
  - 按段落/句子切分,并逐句编辑译文。
84
- - 支持保存草稿、确认并下一句、上一句/下一句导航和进度。
118
+ - 句段三态:**待译** → **待审** → **已确认**,同时记录每句译文的来源
119
+ (`tm`、`mt`、`agent`、`manual`)。句段栏可按状态筛选,搜索覆盖原文、
120
+ 译文和建议。
121
+ - **句段分页**:句段栏按 20/50/100/200 的页大小分页,并有一个输入框可直接
122
+ 跳到某个编号。如果目标句段被当前筛选隐藏,跳转时会先清空筛选。
123
+ - **预翻译** 用 TM 精确命中加机器翻译把整篇铺底:按小块推进,显示
124
+ `已完成/总数`,可在块与块之间停止;已确认或已有译文的句段永远不会被覆盖。
125
+ - **上下排列的审校区**:原文、机器/agent 基线、可编辑译文从上到下依次排列,
126
+ 每一块都占满面板宽度。**全部确认** 在一次确认弹窗后接受所有待审句段。
127
+ - 支持保存草稿、确认并下一句、上一句/下一句导航和进度。当前句段与草稿会
128
+ 防抖落盘,重启后能回到原位。
129
+ - **重复句段自动同步**:确认一句后,本文档里其它相同原文的未确认句段会填上
130
+ 同一译文(来源 `auto`),编辑草稿也会同步;「铺满重复句段」可一次性处理整篇。
131
+ 已确认的句段永远不动。
132
+ - 句段栏里的 QA 提醒与导出前的汇总:占位符/标签缺失、数字不一致、
133
+ 术语未使用、空译文、译文仍是原文、同一原文多种译法。只提醒,不阻挡导出,
134
+ 也不写盘。
85
135
  - 文档标签页;关闭标签页不会删除文档。
86
136
  - **打开已有文档** 可重新打开已关闭的文档。
87
137
  - **设置 → 界面** 提供界面语言切换:跟随 DSH 语言(默认)、简体中文、English、
@@ -91,9 +141,11 @@ CAIT 为 DSH Web UI 和 DSH 桌面端增加一个 CAT 翻译工作台。它从
91
141
  不会影响 TM、术语库或其他文档。
92
142
  - 同格式、同内容的再次导入会复用已有文档,而不是新建重复文档。
93
143
  指纹覆盖语言、源文、格式和交换元数据。
94
- - 响应式密度:工作台测量自身 DSH 面板,并应用 1×–1.8× 的 `--cait-u`
95
- 缩放系数。1600×900 面板约为 1.32×,2560×1440 面板为 1.8×;
96
- 窗口较矮时保持 1×,不会继续缩小。
144
+ - 响应式密度:工作台测量自身 DSH 面板,并应用经过衰减的 1×–1.45× `--cait-u`
145
+ 缩放系数。1600×900 面板约为 1.17×,最大化的 4K 面板停在 1.45×:
146
+ 大窗口贴近 DSH 自带界面,不再比宿主明显放大。
147
+ - 工作台跟随 DSH 的亮/暗主题,包括原生控件(`color-scheme`),
148
+ 下拉框、复选框和滚动条都与面板一致。
97
149
 
98
150
  ### 预处理
99
151
 
@@ -128,7 +180,7 @@ provider/model/code/status,客户端只会收到 `MT_PROVIDER_FAILED`。
128
180
  | CSV | ✅ | ✅ | 自动识别逗号、分号、制表符或竖线分隔;可通过表头名称或从 1 开始的列号指定源/目标列;现有双语导出 |
129
181
  | DOCX | ✅ | ✅ | 正文段落;导入时排除表格块。导出会修改原包,保留样式、编号、图片、页眉、表格和版式。 |
130
182
  | EPUB | ✅ | ✅ | 按 EPUB 3 spine 顺序读取 XHTML 文本块,内联标记保留为 token 并回写到保留的源包。不支持 DRM、固定版式和脚本化 EPUB。 |
131
- | TMX 1.4 | ✅ | ✅ | 常见 `<tu>/<tuv>/<seg>` 子集;内联标记扁平化并警告 |
183
+ | TMX 1.4 | ✅ | ✅ | 常见 `<tu>/<tuv>/<seg>` 子集;内联标记扁平化并警告;上下文用 `<prop type="x-context">` 往返 |
132
184
  | SRT / WebVTT | ✅ | ✅ | 一个字幕 cue 对应一个句段;保留时间轴/设置/标识;保留语义标签;非法时间范围会拒绝 |
133
185
  | PO | ✅ | ✅ | 支持上下文、复数形式、译者注释和废弃 `#~` 条目 |
134
186
  | XLIFF 1.2 | ✅ | ✅ | 内联标签转换为 `{n}` token;缺少 token 时阻止确认 |
@@ -178,7 +230,7 @@ CAIT 以 DSH bundle 的形式安装;发布的 npm 包名为 `dsh-cait`,插
178
230
  plugin_manager install_bundle target: dsh-cait
179
231
  ```
180
232
 
181
- 需要固定版本时写 `dsh-cait@1.0.5`,需要最新版时写 `dsh-cait@latest`。管理器会解析 registry
233
+ 需要固定版本时写 `dsh-cait@1.1.3`,需要最新版时写 `dsh-cait@latest`。管理器会解析 registry
182
234
  上的包、应用 bundle patch 并激活插件,不需要手工在配置档里加行。
183
235
 
184
236
  使用 CLI 管理的配置档:
@@ -255,7 +307,8 @@ TM 返回条数、MT 路由/模型/温度,以及界面语言(`uiLang`:`aut
255
307
 
256
308
  如果快照损坏或版本未知,CAIT 会记录警告,将其移动到
257
309
  `store.json.corrupt-<timestamp>`,然后以空状态启动,而不是让插件激活失败。
258
- 版本 1 快照会迁移到版本 2,并创建默认 TM 和术语库。
310
+ 版本 1、2 快照会迁移到版本 3,并创建默认 TM 和术语库;版本 2 里「有译文但未
311
+ 确认」的草稿会变成 `translated`,来源记为 `manual`。
259
312
 
260
313
  ## Agent 工具
261
314
 
@@ -268,6 +321,19 @@ TM 返回条数、MT 路由/模型/温度,以及界面语言(`uiLang`:`aut
268
321
  | `cat_list_documents` | 列出文档和进度 |
269
322
  | `cat_switch_document` | 选择活动文档 |
270
323
  | `cat_suggest_mt` | 通过所选 DSH 路由调用 MT,或使用明确的离线回退 |
324
+ | `cat_pre_translate` | 用 TM + MT 填一块,跳过已确认/已有译文的句段,返回 `next` |
325
+ | `cat_get_segments` | 取一段有界句段窗口,含状态、来源和建议 |
326
+ | `cat_confirm_segments` | 确认索引列表、一段窗口,或全部待审句段 |
327
+ | `cat_propose_translation` | 只留下建议和理由,不动已确认的译文 |
328
+ | `cat_align` | 对齐两段文本,报告高置信 / 待确认 / 可疑的配对 |
329
+ | `cat_consistency_report` | 按原文分组列出译文不一致的句段 |
330
+ | `cat_term_candidates` | 术语候选短名单:频次、例句、记忆库里已有的译法 |
331
+ | `cat_add_terms` | 一次性把选中的术语写进术语库 |
332
+
333
+ 因此 Agent 可以完全不点界面就把整篇铺底:反复调用 `cat_pre_translate`
334
+ (`from: next`)直到 `next` 为 `null`,用 `cat_get_segments` 查看,再用
335
+ `cat_confirm_segments` 批量接受。做术语时读 `cat_term_candidates`,判断这份
336
+ 短名单,再用 `cat_add_terms` 写入。
271
337
 
272
338
  工作台和工具共用一个 `CatStore`,因此 Agent 可以翻译用户当前打开的同一份文档。
273
339
 
@@ -277,7 +343,7 @@ TM 返回条数、MT 路由/模型/温度,以及界面语言(`uiLang`:`aut
277
343
  flowchart LR
278
344
  UI["DSH Web UI<br/>(侧栏 + 工作台)"] --> Client["client.js<br/>生成的 Web bundle"]
279
345
  Client --> API["/cait/api/rpc<br/>同源 JSON"]
280
- Tools["7 个 Agent 工具"] --> Store["CatStore"]
346
+ Tools["15 个 Agent 工具"] --> Store["CatStore"]
281
347
  API --> Store
282
348
  Store --> Snapshot[("store.json<br/>+ sources/")]
283
349
  ```
@@ -411,18 +477,25 @@ GitHub release 发布。
411
477
  - XLSX 导入/导出是两列表格;不保留单元格样式、公式、合并单元格、图片和额外工作表。
412
478
  - HTML/RTF 导出不往返原始样式;JSON 只翻译字符串值。
413
479
  - TM 匹配是词法级的,不是语义级;没有词干、同义词或向量。
414
- - 库重命名/删除和逐标签页挂载状态尚未实现。
480
+ - 每个上下文下,同一原文存一条译文:重复的句子会为每种相邻句组合保留一条变体,
481
+ 每个 key 上限 8 条;相邻句不同时回落到无上下文的通用条目。
482
+ - 上下文只取前后两句源文,不包含文档、客户或项目元数据。
483
+ - TBX 与 JSON 术语导出是单向的;只有 TMX 和 CSV 能再导入回来。
415
484
  - 工作台界面提供中文、English、日本語三种语言,可在设置中切换;README 提供英文、简体中文和日文三个版本,以英文版为准。
416
485
 
417
- 后续计划:通过多模态 DSH 路由支持图片/视觉输入、更完整的库管理、
418
- 保留样式的 XLSX 输出,以及 XLIFF `<alt-trans>` / 注释支持。
486
+ 后续计划:通过多模态 DSH 路由支持图片/视觉输入、保留样式的 XLSX 输出,
487
+ 以及 XLIFF `<alt-trans>` / 注释支持。
419
488
 
420
489
  ## 变更日志与版本
421
490
 
422
491
  见 [CHANGELOG.md](CHANGELOG.md)。`v1.0.0` 是首个公开发布版本,`v1.0.1` 增加了
423
492
  日语界面和界面内语言切换,`v1.0.2` 让「跟随 DSH 语言」真正跟随 DSH 的语言设置,
424
493
  `v1.0.3` 把包发布到 npm,`v1.0.4` 起后续版本改由带 provenance 的发布流水线产出,
425
- `v1.0.5` 增加 EPUB、导入预处理和 PDF 政策;项目在开发阶段使用 `0.1.0`,
494
+ `v1.0.5` 增加 EPUB、导入预处理和 PDF 政策,`v1.1.0` 增加 agent 驱动的预翻译、
495
+ 句段三态、上下排列的审校区和轻量 QA,`v1.1.1` 增加带 TMX/TBX/CSV/JSON 导出的
496
+ 库页面、句段分页,以及从右侧面板跳进库页面,`v1.1.2` 增加带 101%(ICE)
497
+ 匹配的上下文记忆,`v1.1.3` 增加双文件对齐、重复句段自动同步、术语提取,
498
+ 以及 agent 写建议用的原语;项目在开发阶段使用 `0.1.0`,
426
499
  发布到 GitHub 前统一改为 `1.0.0`。
427
500
 
428
501
  > **License:** Apache License 2.0,见 [LICENSE](LICENSE)。再分发时需保留