@geolonia/yuuhitsu 0.2.4 → 0.3.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.ja.md +383 -0
- package/README.md +141 -63
- package/dist/cli/commands/translate.d.ts.map +1 -1
- package/dist/cli/commands/translate.js +6 -3
- package/dist/cli/commands/translate.js.map +1 -1
- package/dist/tasks/batch-translate.d.ts +2 -1
- package/dist/tasks/batch-translate.d.ts.map +1 -1
- package/dist/tasks/batch-translate.js +3 -2
- package/dist/tasks/batch-translate.js.map +1 -1
- package/dist/tasks/translate.d.ts +4 -2
- package/dist/tasks/translate.d.ts.map +1 -1
- package/dist/tasks/translate.js +159 -54
- package/dist/tasks/translate.js.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -11,52 +11,100 @@ AI-powered document operations CLI
|
|
|
11
11
|
- **Markdown Translation**: Translate documents while preserving structure, code blocks, and formatting
|
|
12
12
|
- **Glossary Management**: Maintain consistent terminology across all translations with a project-level glossary
|
|
13
13
|
- **Multi-Provider Support**: Switch between Claude (Anthropic), Gemini (Google), and Ollama (local) with a single config line change
|
|
14
|
-
- **
|
|
14
|
+
- **Local Quality Control**: Automated pre-publish QC with syntax, semantic, and LLM-judge checks
|
|
15
15
|
- **Dry-Run Mode**: Preview operations without making API calls
|
|
16
|
-
- **Prompt Templates**: Customize AI behavior with configurable templates
|
|
17
16
|
|
|
18
17
|
## Features
|
|
19
18
|
|
|
20
|
-
### Translation
|
|
19
|
+
### Translation
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
- Preserve document structure (headings, links, code blocks, tables)
|
|
24
|
-
- Support for large files with automatic chunking
|
|
25
|
-
- Real-time streaming output
|
|
26
|
-
- Retry logic with exponential backoff for API failures
|
|
27
|
-
- Automatic glossary lookup during translation (when `glossary` is configured)
|
|
21
|
+
yuuhitsu translates Markdown documents at the paragraph level using an AST (remark) pipeline:
|
|
28
22
|
|
|
29
|
-
**
|
|
23
|
+
1. **Parse** — remark parses the Markdown into an mdast AST
|
|
24
|
+
2. **Extract** — `extractBlockNodes()` collects whole paragraph and heading nodes as markdown units, preserving inline elements (code spans, bold, italic, links) within each block
|
|
25
|
+
3. **Batch** — nodes are grouped into API batches by estimated token count (`--max-tokens-per-batch`, default: 4000 chars ÷ 4)
|
|
26
|
+
4. **Translate** — Claude's structured output (tool_use) returns a guaranteed 1:1 ID-mapped JSON response; Gemini and Ollama use text-mode JSON
|
|
27
|
+
5. **Apply** — translated text is re-parsed through remark and written back into the AST; the full document is then serialized
|
|
30
28
|
|
|
31
|
-
-
|
|
32
|
-
- Inline code (`` `...` ``): preserved as-is
|
|
33
|
-
- Table structure, headings, and links: structure is preserved; only the text content is translated
|
|
29
|
+
**Why paragraph-level chunks?**
|
|
34
30
|
|
|
35
|
-
|
|
31
|
+
Earlier releases (0.1.x) split text at inline-element boundaries — for example, splitting `"When \`AUTH_ENABLED=true\`, a token is required."` into `"When "` and `", a token is required."`. The LLM had no context for each fragment, causing EN/JA mixing, duplicate phrases, and semantic inversions. Paragraph-level chunking (0.3.0) eliminates this class of error.
|
|
32
|
+
|
|
33
|
+
**What is preserved (never sent to LLM):**
|
|
34
|
+
|
|
35
|
+
- Fenced code blocks (`` ``` ``...`` ``` ``): preserved as-is via AST
|
|
36
|
+
- Inline code (`` `...` ``): preserved within each paragraph block
|
|
37
|
+
- Document structure (headings, lists, tables, HR, links): handled deterministically by the AST round-trip
|
|
38
|
+
|
|
39
|
+
### Glossary Management
|
|
36
40
|
|
|
37
41
|
Maintain a project-level glossary to enforce consistent terminology across all translations.
|
|
38
42
|
|
|
39
43
|
- **`glossary init`**: Generate a `glossary.yaml` skeleton with example terms
|
|
40
|
-
- **`glossary check`**: Detect forbidden or inconsistent terms in a document — supports
|
|
44
|
+
- **`glossary check`**: Detect forbidden or inconsistent terms in a document — supports Markdown (`.md`) and JSON i18n files (`.json`); violations are reported with line numbers or key paths
|
|
45
|
+
- **`glossary fix`**: Auto-replace `severity: auto-fix` terms in a document
|
|
41
46
|
- **`glossary sync`**: Report translation coverage across all configured languages and create stubs for missing entries
|
|
42
47
|
- **`glossary review`**: Generate a Markdown report of all glossary terms and their translations
|
|
43
48
|
|
|
44
49
|
When a `glossary` path is set in `yuuhitsu.config.yaml`, the `translate` command automatically injects the glossary into the AI prompt, ensuring canonical terms are used and forbidden variants are avoided.
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
**Severity levels** (set per-term in `glossary.yaml`):
|
|
52
|
+
|
|
53
|
+
| Level | Behaviour |
|
|
54
|
+
|-------|-----------|
|
|
55
|
+
| `block` | Hard error — CI fails |
|
|
56
|
+
| `warn` | Warning — CI passes, human review required |
|
|
57
|
+
| `auto-fix` | Automatically replaced by `glossary fix` |
|
|
58
|
+
|
|
59
|
+
### Local Quality Control
|
|
60
|
+
|
|
61
|
+
yuuhitsu ships a pre-publish QC script (`scripts/local-qc.ts`) that runs against a real translated fixture repository before every `npm publish`. This catches both syntax regressions and semantic quality drops that unit tests cannot detect.
|
|
62
|
+
|
|
63
|
+
**Syntax checks:**
|
|
64
|
+
|
|
65
|
+
| Check | Description |
|
|
66
|
+
|-------|-------------|
|
|
67
|
+
| bare-fence | Fenced code blocks without a language tag |
|
|
68
|
+
| five-axis | EN/JA mix, duplicate phrase, heading integrity, anchor validity across fixture files |
|
|
69
|
+
| markdownlint | Common Markdown lint rules |
|
|
70
|
+
| vitepress-build | VitePress build succeeds on the fixture repo |
|
|
71
|
+
|
|
72
|
+
**Semantic checks:**
|
|
73
|
+
|
|
74
|
+
| Check | Description |
|
|
75
|
+
|-------|-------------|
|
|
76
|
+
| en-ja-mix | Paragraphs that mix English and Japanese unexpectedly |
|
|
77
|
+
| duplicate-phrase | Same phrase repeated twice within one paragraph |
|
|
78
|
+
| heading-integrity | Headings match between EN and JA versions |
|
|
79
|
+
| anchor-validity | Internal anchor links resolve correctly |
|
|
80
|
+
|
|
81
|
+
**LLM Judge:**
|
|
82
|
+
|
|
83
|
+
- Model: `claude-sonnet-4-6`
|
|
84
|
+
- Threshold: average score ≥ 4.0 per fixture, minimum per fixture ≥ 3.5 (scale 1–5)
|
|
85
|
+
- Covers all 7 default fixture files in `LOCAL_QC_FIXTURE_REPO`
|
|
86
|
+
|
|
87
|
+
**Configuration:**
|
|
47
88
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
|
|
89
|
+
```bash
|
|
90
|
+
# Point to your translated fixture repository
|
|
91
|
+
export LOCAL_QC_FIXTURE_REPO=/home/user/workspace/my-docs # default: /home/hal/workspace/geonicdb-docs
|
|
92
|
+
|
|
93
|
+
# Run QC manually
|
|
94
|
+
npm run local-qc
|
|
95
|
+
|
|
96
|
+
# QC runs automatically before publish
|
|
97
|
+
npm publish # triggers prepublishOnly → local-qc.ts
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The QC script also runs in GitHub Actions CI via `.github/workflows/local-qc.yml` on every pull request.
|
|
53
101
|
|
|
54
102
|
## Quick Start
|
|
55
103
|
|
|
56
104
|
### Installation
|
|
57
105
|
|
|
58
106
|
```bash
|
|
59
|
-
npm install -g yuuhitsu
|
|
107
|
+
npm install -g @geolonia/yuuhitsu
|
|
60
108
|
```
|
|
61
109
|
|
|
62
110
|
### Basic Usage
|
|
@@ -82,7 +130,7 @@ Create a `yuuhitsu.config.yaml` file in your project root:
|
|
|
82
130
|
```yaml
|
|
83
131
|
# AI Provider Selection
|
|
84
132
|
provider: claude # Options: claude, gemini, ollama
|
|
85
|
-
model: claude-sonnet-4-
|
|
133
|
+
model: claude-sonnet-4-6
|
|
86
134
|
|
|
87
135
|
# Optional Settings
|
|
88
136
|
outputDir: ./translated
|
|
@@ -98,20 +146,23 @@ log:
|
|
|
98
146
|
Create a `.env` file or set environment variables for API authentication:
|
|
99
147
|
|
|
100
148
|
```bash
|
|
101
|
-
# For Claude (Anthropic)
|
|
149
|
+
# For Claude (Anthropic) — recommended
|
|
102
150
|
ANTHROPIC_API_KEY=your_api_key_here
|
|
103
151
|
|
|
104
152
|
# For Gemini (Google)
|
|
105
153
|
GOOGLE_API_KEY=your_api_key_here
|
|
106
154
|
|
|
107
155
|
# Ollama requires no API key (runs locally)
|
|
156
|
+
|
|
157
|
+
# For Local QC
|
|
158
|
+
LOCAL_QC_FIXTURE_REPO=/path/to/your/translated-docs-repo
|
|
108
159
|
```
|
|
109
160
|
|
|
110
161
|
### Supported Providers
|
|
111
162
|
|
|
112
163
|
| Provider | SDK | Environment Variable | Use Case |
|
|
113
164
|
|----------|-----|---------------------|----------|
|
|
114
|
-
| Claude | `@anthropic-ai/sdk` | `ANTHROPIC_API_KEY` | High-quality translation,
|
|
165
|
+
| Claude | `@anthropic-ai/sdk` | `ANTHROPIC_API_KEY` | High-quality translation, structured output |
|
|
115
166
|
| Gemini | `@google/genai` | `GOOGLE_API_KEY` | Fast processing, cost-effective |
|
|
116
167
|
| Ollama | `openai` (compatible) | *(none)* | Local execution, privacy, offline use |
|
|
117
168
|
|
|
@@ -121,27 +172,38 @@ GOOGLE_API_KEY=your_api_key_here
|
|
|
121
172
|
|
|
122
173
|
Translate Markdown documents between languages.
|
|
123
174
|
|
|
124
|
-
**
|
|
175
|
+
**Global options** (before subcommand):
|
|
125
176
|
|
|
126
|
-
- `--input <path>` (required): Input Markdown file path
|
|
127
|
-
- `--output <path>`: Output file path (defaults to input file with `.{lang}.md` suffix)
|
|
128
|
-
- `--lang <code>` (required): Target language code (e.g., `en`, `ja`, `zh`, `es`)
|
|
129
|
-
- `--provider <name>`: Override config provider (claude, gemini, ollama)
|
|
130
|
-
- `--model <name>`: Override config model
|
|
131
|
-
- `--dry-run`: Show what would be done without making API calls
|
|
132
|
-
- `--stream`: Enable streaming output (default: true)
|
|
133
177
|
- `--config <path>`: Config file path (default: `./yuuhitsu.config.yaml`)
|
|
178
|
+
- `--dry-run`: Show what would be done without making API calls
|
|
134
179
|
- `--verbose`: Enable verbose output
|
|
135
180
|
|
|
136
|
-
**
|
|
181
|
+
**Options:**
|
|
182
|
+
|
|
183
|
+
- `--input <path>` (required): Input Markdown file path or glob pattern (e.g., `docs/en/**/*.md`)
|
|
184
|
+
- `--output <path>`: Output file path (defaults to `<input>.<lang>.md`)
|
|
185
|
+
- `--output-dir <dir>`: Output directory for batch translation (preserves directory structure)
|
|
186
|
+
- `--lang <code>` (required): Target language code (e.g., `en`, `ja`, `zh`, `es`)
|
|
187
|
+
- `--max-tokens-per-batch <N>`: Maximum estimated tokens per API batch call (default: `4000`). Increase for large documents with few headings; decrease if you hit API context limits.
|
|
188
|
+
- `--max-chunk-lines <N>`: Maximum lines per translation chunk (legacy fallback; default: `150`). Used only when the AST path is bypassed.
|
|
189
|
+
|
|
190
|
+
**Single file example:**
|
|
137
191
|
|
|
138
192
|
```bash
|
|
139
193
|
yuuhitsu translate \
|
|
140
194
|
--input ./docs/guide.md \
|
|
141
195
|
--output ./docs/guide.ja.md \
|
|
142
196
|
--lang ja \
|
|
143
|
-
--
|
|
144
|
-
|
|
197
|
+
--max-tokens-per-batch 4000
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Batch translation example:**
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
yuuhitsu translate \
|
|
204
|
+
--input "docs/en/**/*.md" \
|
|
205
|
+
--output-dir docs/ja \
|
|
206
|
+
--lang ja
|
|
145
207
|
```
|
|
146
208
|
|
|
147
209
|
### `glossary`
|
|
@@ -157,8 +219,6 @@ Generate a `glossary.yaml` skeleton in the current directory.
|
|
|
157
219
|
- `--output <path>`: Output path for the glossary file (default: `glossary.yaml`)
|
|
158
220
|
- `--force`: Overwrite an existing glossary file
|
|
159
221
|
|
|
160
|
-
**Example:**
|
|
161
|
-
|
|
162
222
|
```bash
|
|
163
223
|
yuuhitsu glossary init
|
|
164
224
|
yuuhitsu glossary init --output ./docs/glossary.yaml
|
|
@@ -168,48 +228,57 @@ yuuhitsu glossary init --output ./docs/glossary.yaml
|
|
|
168
228
|
|
|
169
229
|
Detect forbidden or inconsistent terminology in a document.
|
|
170
230
|
|
|
171
|
-
Supports both Markdown (`.md`) and JSON i18n files (`.json`). When a `.json` file is provided,
|
|
231
|
+
Supports both Markdown (`.md`) and JSON i18n files (`.json`). When a `.json` file is provided, violations are reported as key paths (e.g., `dashboard.title`).
|
|
172
232
|
|
|
173
233
|
**What is skipped (not checked):**
|
|
174
234
|
|
|
175
|
-
-
|
|
235
|
+
- Fenced code blocks (`` ``` ``...`` ``` ``)
|
|
176
236
|
- Inline code (`` `...` ``)
|
|
177
237
|
- URLs (`http://` / `https://`)
|
|
178
238
|
- Frontmatter (`---`...`---`)
|
|
179
|
-
- URL path portions of Markdown links
|
|
239
|
+
- URL path portions of Markdown links
|
|
180
240
|
|
|
181
241
|
**Options:**
|
|
182
242
|
|
|
183
243
|
- `--input <file>` (required): Document file to check (Markdown or JSON i18n file)
|
|
184
244
|
- `--glossary <path>` (required): Glossary file path
|
|
185
245
|
- `--lang <code>` (required): Language code to check (e.g., `ja`, `en`)
|
|
186
|
-
|
|
187
|
-
|
|
246
|
+
- `--severity-filter <levels>`: Comma-separated severity levels to report (e.g., `block,warn`). Default: all levels.
|
|
247
|
+
- `--format <format>`: Output format: `text`, `json`, `sarif` (default: `text`)
|
|
188
248
|
|
|
189
249
|
```bash
|
|
190
250
|
# Check a Markdown document
|
|
191
251
|
yuuhitsu glossary check --input README.md --glossary glossary.yaml --lang ja
|
|
192
252
|
|
|
193
|
-
# Check
|
|
194
|
-
yuuhitsu glossary check --input
|
|
195
|
-
```
|
|
253
|
+
# Check only block-level violations
|
|
254
|
+
yuuhitsu glossary check --input README.md --glossary glossary.yaml --lang ja --severity-filter block
|
|
196
255
|
|
|
197
|
-
|
|
256
|
+
# Output SARIF for GitHub Code Scanning
|
|
257
|
+
yuuhitsu glossary check --input README.md --glossary glossary.yaml --lang ja --format sarif
|
|
198
258
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
✗ navigation.menu.api: found forbidden term "API" (use "API" instead)
|
|
259
|
+
# Check a JSON i18n file
|
|
260
|
+
yuuhitsu glossary check --input locales/ja/common.json --glossary glossary.yaml --lang ja
|
|
202
261
|
```
|
|
203
262
|
|
|
204
|
-
#### `glossary
|
|
263
|
+
#### `glossary fix`
|
|
205
264
|
|
|
206
|
-
|
|
265
|
+
Auto-replace `severity: auto-fix` terms in a document.
|
|
207
266
|
|
|
208
267
|
**Options:**
|
|
209
268
|
|
|
269
|
+
- `--input <file>` (required): Document file to fix
|
|
210
270
|
- `--glossary <path>` (required): Glossary file path
|
|
271
|
+
- `--lang <code>` (required): Language code
|
|
272
|
+
- `--dry-run`: Show what would be replaced without modifying the file
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
yuuhitsu glossary fix --input README.md --glossary glossary.yaml --lang ja
|
|
276
|
+
yuuhitsu glossary fix --input README.md --glossary glossary.yaml --lang ja --dry-run
|
|
277
|
+
```
|
|
211
278
|
|
|
212
|
-
|
|
279
|
+
#### `glossary sync`
|
|
280
|
+
|
|
281
|
+
Report translation coverage and create stubs for missing entries.
|
|
213
282
|
|
|
214
283
|
```bash
|
|
215
284
|
yuuhitsu glossary sync --glossary glossary.yaml
|
|
@@ -219,13 +288,6 @@ yuuhitsu glossary sync --glossary glossary.yaml
|
|
|
219
288
|
|
|
220
289
|
Generate a Markdown report of all glossary terms and their translations.
|
|
221
290
|
|
|
222
|
-
**Options:**
|
|
223
|
-
|
|
224
|
-
- `--glossary <path>` (required): Glossary file path
|
|
225
|
-
- `--output <path>`: Save the report to a file (Markdown)
|
|
226
|
-
|
|
227
|
-
**Example:**
|
|
228
|
-
|
|
229
291
|
```bash
|
|
230
292
|
yuuhitsu glossary review --glossary glossary.yaml
|
|
231
293
|
yuuhitsu glossary review --glossary glossary.yaml --output glossary-report.md
|
|
@@ -233,8 +295,6 @@ yuuhitsu glossary review --glossary glossary.yaml --output glossary-report.md
|
|
|
233
295
|
|
|
234
296
|
### Glossary File Format
|
|
235
297
|
|
|
236
|
-
The `glossary.yaml` file defines canonical terms, their translations, and forbidden variants:
|
|
237
|
-
|
|
238
298
|
```yaml
|
|
239
299
|
version: 1
|
|
240
300
|
languages: [ja, en]
|
|
@@ -248,6 +308,7 @@ terms:
|
|
|
248
308
|
ja: ["API", "えーぴーあい"]
|
|
249
309
|
- canonical: "webhook"
|
|
250
310
|
type: noun
|
|
311
|
+
severity: warn # block | warn | auto-fix (default: block)
|
|
251
312
|
translations:
|
|
252
313
|
ja: "Webhook"
|
|
253
314
|
en: "webhook"
|
|
@@ -262,6 +323,7 @@ terms:
|
|
|
262
323
|
| `languages` | List of language codes managed by this glossary |
|
|
263
324
|
| `terms[].canonical` | The authoritative (source-language) term |
|
|
264
325
|
| `terms[].type` | Term type (e.g., `noun`, `verb`) |
|
|
326
|
+
| `terms[].severity` | `block` (default), `warn`, or `auto-fix` |
|
|
265
327
|
| `terms[].translations` | Map of language code → translated term |
|
|
266
328
|
| `terms[].do_not_use` | Map of language code → list of forbidden variants |
|
|
267
329
|
|
|
@@ -288,16 +350,32 @@ npm run dev -- translate --input test.md --lang ja
|
|
|
288
350
|
### Running Tests
|
|
289
351
|
|
|
290
352
|
```bash
|
|
291
|
-
# Run all tests
|
|
353
|
+
# Run all unit tests
|
|
292
354
|
npm test
|
|
293
355
|
|
|
294
356
|
# Watch mode
|
|
295
357
|
npm run test:watch
|
|
296
358
|
|
|
359
|
+
# Integration tests (requires ANTHROPIC_API_KEY)
|
|
360
|
+
npm run test:integration
|
|
361
|
+
|
|
297
362
|
# Type checking
|
|
298
363
|
npm run lint
|
|
364
|
+
|
|
365
|
+
# Local QC (requires LOCAL_QC_FIXTURE_REPO)
|
|
366
|
+
npm run local-qc
|
|
299
367
|
```
|
|
300
368
|
|
|
369
|
+
## Changelog
|
|
370
|
+
|
|
371
|
+
See [CHANGELOG.md](./CHANGELOG.md) for full version history.
|
|
372
|
+
|
|
373
|
+
**0.3.0 highlights:**
|
|
374
|
+
|
|
375
|
+
- Paragraph-level chunk redesign (`extractBlockNodes`) — eliminates EN/JA mixing, duplicate phrases, and semantic inversions caused by inline-element splitting
|
|
376
|
+
- Token-count-based batching (`--max-tokens-per-batch`, default: 4000) — replaces line-count-based `--max-nodes-per-batch`
|
|
377
|
+
- Local QC (`scripts/local-qc.ts`) — prepublishOnly hook + GitHub Actions CI with LLM-judge (`claude-sonnet-4-6`, avg ≥ 4.0)
|
|
378
|
+
|
|
301
379
|
## License
|
|
302
380
|
|
|
303
381
|
MIT — See [LICENSE](./LICENSE)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/translate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/translate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,eAAO,MAAM,gBAAgB,SAoGzB,CAAC"}
|
|
@@ -13,7 +13,8 @@ export const translateCommand = new Command("translate")
|
|
|
13
13
|
.option("--output <file>", "Output file path (default: <input>.<lang>.md)")
|
|
14
14
|
.option("--output-dir <dir>", "Output directory for batch translation (preserves directory structure)")
|
|
15
15
|
.option("--max-chunk-lines <number>", "Maximum lines per translation chunk (default: 300)", parseInt)
|
|
16
|
-
.option("--max-
|
|
16
|
+
.option("--max-tokens-per-batch <number>", "Maximum estimated tokens per API batch call (default: 4000)", parseInt)
|
|
17
|
+
.option("--system-prompt-suffix <text>", "Append text to the system prompt (e.g. contextual retry hints)")
|
|
17
18
|
.action(async (opts, cmd) => {
|
|
18
19
|
const globalOpts = cmd.parent?.opts() ?? {};
|
|
19
20
|
const configPath = globalOpts.config ?? "./yuuhitsu.config.yaml";
|
|
@@ -45,7 +46,8 @@ export const translateCommand = new Command("translate")
|
|
|
45
46
|
outputDir: opts.outputDir,
|
|
46
47
|
dryRun,
|
|
47
48
|
verbose,
|
|
48
|
-
|
|
49
|
+
maxTokensPerBatch: opts.maxTokensPerBatch,
|
|
50
|
+
systemPromptSuffix: opts.systemPromptSuffix,
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
else {
|
|
@@ -74,7 +76,8 @@ export const translateCommand = new Command("translate")
|
|
|
74
76
|
outputPath: opts.output,
|
|
75
77
|
targetLang: opts.lang,
|
|
76
78
|
maxChunkLines: opts.maxChunkLines,
|
|
77
|
-
|
|
79
|
+
maxTokensPerBatch: opts.maxTokensPerBatch,
|
|
80
|
+
systemPromptSuffix: opts.systemPromptSuffix,
|
|
78
81
|
});
|
|
79
82
|
process.stdout.write(`${chalk.green("✓")} Translated to ${result.outputPath}\n` +
|
|
80
83
|
` Tokens: ${result.usage.totalTokens} (${result.chunks} chunk${result.chunks > 1 ? "s" : ""})\n`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translate.js","sourceRoot":"","sources":["../../../src/cli/commands/translate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;KACrD,WAAW,CAAC,mDAAmD,CAAC;KAChE,cAAc,CAAC,gBAAgB,EAAE,qCAAqC,CAAC;KACvE,cAAc,CAAC,eAAe,EAAE,6CAA6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Aa,EAAE,IAAI,CAAC,aAAa;gBACjC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;gBACzC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;aAC5C,CAAC,CAAC;YAEH,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,UAAU,IAAI;gBAC1D,aAAa,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,MAAM,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAClG,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -15,7 +15,8 @@ export interface BatchTranslateOptions {
|
|
|
15
15
|
onProgress?: (progress: BatchProgress) => void;
|
|
16
16
|
dryRun: boolean;
|
|
17
17
|
verbose?: boolean;
|
|
18
|
-
|
|
18
|
+
maxTokensPerBatch?: number;
|
|
19
|
+
systemPromptSuffix?: string;
|
|
19
20
|
}
|
|
20
21
|
export interface BatchResult {
|
|
21
22
|
total: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-translate.d.ts","sourceRoot":"","sources":["../../src/tasks/batch-translate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGvD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE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CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,MAAM,CAsCT;AA4CD;;GAEG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAuHtB"}
|
|
@@ -83,7 +83,7 @@ function determineInputBase(pattern, matchedFiles) {
|
|
|
83
83
|
* Execute batch translation
|
|
84
84
|
*/
|
|
85
85
|
export async function batchTranslate(opts) {
|
|
86
|
-
const { pattern, targetLang, provider, outputDir, onProgress, dryRun, verbose,
|
|
86
|
+
const { pattern, targetLang, provider, outputDir, onProgress, dryRun, verbose, maxTokensPerBatch, systemPromptSuffix } = opts;
|
|
87
87
|
// Match files using fast-glob
|
|
88
88
|
const matchedFiles = await fg(pattern, {
|
|
89
89
|
onlyFiles: true,
|
|
@@ -136,7 +136,8 @@ export async function batchTranslate(opts) {
|
|
|
136
136
|
inputPath,
|
|
137
137
|
outputPath,
|
|
138
138
|
targetLang,
|
|
139
|
-
|
|
139
|
+
maxTokensPerBatch,
|
|
140
|
+
systemPromptSuffix,
|
|
140
141
|
});
|
|
141
142
|
process.stdout.write(`${chalk.green("✓")} Translated to ${result.outputPath}\n` +
|
|
142
143
|
(verbose ? ` Tokens: ${result.usage.totalTokens} (${result.chunks} chunk${result.chunks > 1 ? "s" : ""})\n` : ""));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-translate.js","sourceRoot":"","sources":["../../src/tasks/batch-translate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"batch-translate.js","sourceRoot":"","sources":["../../src/tasks/batch-translate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AA8B/C;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAMlC;IACC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAE7E,yCAAyC;IACzC,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,yDAAyD;IACzD,IAAI,SAAS,IAAI,SAAS,EAAE,CAAC;QAC3B,MAAM,YAAY,GAAG,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAEpD,mCAAmC;QACnC,2DAA2D;QAC3D,IAAI,UAAU,CAAC,YA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CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AIProvider } from "../provider/interface.js";
|
|
2
2
|
import type { GlossaryConfig } from "./glossary.js";
|
|
3
3
|
export declare const DEFAULT_MAX_CHUNK_LINES = 150;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const DEFAULT_MAX_TOKENS_PER_BATCH = 4000;
|
|
5
5
|
interface FrontmatterSeparation {
|
|
6
6
|
frontmatter: string | null;
|
|
7
7
|
body: string;
|
|
@@ -19,7 +19,9 @@ export interface TranslateOptions {
|
|
|
19
19
|
templateContent?: string;
|
|
20
20
|
glossaryConfig?: GlossaryConfig;
|
|
21
21
|
maxChunkLines?: number;
|
|
22
|
-
|
|
22
|
+
maxTokensPerBatch?: number;
|
|
23
|
+
/** Optional suffix appended to the system prompt (e.g. contextual retry hints). */
|
|
24
|
+
systemPromptSuffix?: string;
|
|
23
25
|
}
|
|
24
26
|
export interface TranslateResult {
|
|
25
27
|
outputPath: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/tasks/translate.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,0BAA0B,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/tasks/translate.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,0BAA0B,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAKjD,UAAU,qBAAqB;IAC7B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EA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