@geolonia/yuuhitsu 0.1.0 → 0.1.2
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 +0 -0
- package/README.md +114 -0
- package/dist/cli/commands/glossary.d.ts +3 -0
- package/dist/cli/commands/glossary.d.ts.map +1 -0
- package/dist/cli/commands/glossary.js +110 -0
- package/dist/cli/commands/glossary.js.map +1 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +82 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/translate.d.ts +0 -0
- package/dist/cli/commands/translate.d.ts.map +1 -1
- package/dist/cli/commands/translate.js +53 -26
- package/dist/cli/commands/translate.js.map +1 -1
- package/dist/cli/index.d.ts +0 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -0
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +0 -0
- package/dist/errors.d.ts.map +0 -0
- package/dist/errors.js +0 -0
- package/dist/errors.js.map +0 -0
- package/dist/logger.d.ts +0 -0
- package/dist/logger.d.ts.map +0 -0
- package/dist/logger.js +0 -0
- package/dist/logger.js.map +0 -0
- package/dist/provider/claude.d.ts +0 -0
- package/dist/provider/claude.d.ts.map +0 -0
- package/dist/provider/claude.js +0 -0
- package/dist/provider/claude.js.map +0 -0
- package/dist/provider/gemini.d.ts +0 -0
- package/dist/provider/gemini.d.ts.map +0 -0
- package/dist/provider/gemini.js +0 -0
- package/dist/provider/gemini.js.map +0 -0
- package/dist/provider/index.d.ts +0 -0
- package/dist/provider/index.d.ts.map +0 -0
- package/dist/provider/index.js +0 -0
- package/dist/provider/index.js.map +0 -0
- package/dist/provider/interface.d.ts +0 -0
- package/dist/provider/interface.d.ts.map +0 -0
- package/dist/provider/interface.js +0 -0
- package/dist/provider/interface.js.map +0 -0
- package/dist/provider/ollama.d.ts +0 -0
- package/dist/provider/ollama.d.ts.map +0 -0
- package/dist/provider/ollama.js +0 -0
- package/dist/provider/ollama.js.map +0 -0
- package/dist/tasks/batch-translate.d.ts +46 -0
- package/dist/tasks/batch-translate.d.ts.map +1 -0
- package/dist/tasks/batch-translate.js +174 -0
- package/dist/tasks/batch-translate.js.map +1 -0
- package/dist/tasks/glossary.d.ts +41 -0
- package/dist/tasks/glossary.d.ts.map +1 -0
- package/dist/tasks/glossary.js +273 -0
- package/dist/tasks/glossary.js.map +1 -0
- package/dist/tasks/stream.d.ts +0 -0
- package/dist/tasks/stream.d.ts.map +0 -0
- package/dist/tasks/stream.js +0 -0
- package/dist/tasks/stream.js.map +0 -0
- package/dist/tasks/translate.d.ts +27 -0
- package/dist/tasks/translate.d.ts.map +1 -1
- package/dist/tasks/translate.js +101 -7
- package/dist/tasks/translate.js.map +1 -1
- package/package.json +14 -8
- package/src/templates/fix-links.md +0 -0
- package/src/templates/generate-docs.md +0 -0
- package/src/templates/generate-tests.md +0 -0
- package/src/templates/research.md +0 -0
- package/src/templates/sync-docs.md +0 -0
- package/src/templates/translate.md +8 -0
|
File without changes
|
package/dist/provider/ollama.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AIProvider } from "../provider/index.js";
|
|
2
|
+
export interface BatchProgress {
|
|
3
|
+
total: number;
|
|
4
|
+
current: number;
|
|
5
|
+
succeeded: number;
|
|
6
|
+
failed: number;
|
|
7
|
+
skipped: number;
|
|
8
|
+
}
|
|
9
|
+
export interface BatchTranslateOptions {
|
|
10
|
+
pattern: string;
|
|
11
|
+
targetLang: string;
|
|
12
|
+
provider?: AIProvider;
|
|
13
|
+
outputDir?: string;
|
|
14
|
+
inputBase?: string;
|
|
15
|
+
onProgress?: (progress: BatchProgress) => void;
|
|
16
|
+
dryRun: boolean;
|
|
17
|
+
verbose?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface BatchResult {
|
|
20
|
+
total: number;
|
|
21
|
+
succeeded: number;
|
|
22
|
+
failed: number;
|
|
23
|
+
errors: Array<{
|
|
24
|
+
file: string;
|
|
25
|
+
error: string;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Check if a string contains glob pattern characters
|
|
30
|
+
*/
|
|
31
|
+
export declare function isGlobPattern(input: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Generate output path for a translated file
|
|
34
|
+
*/
|
|
35
|
+
export declare function generateOutputPath(opts: {
|
|
36
|
+
inputPath: string;
|
|
37
|
+
targetLang: string;
|
|
38
|
+
outputDir?: string;
|
|
39
|
+
inputBase?: string;
|
|
40
|
+
explicitOutput?: string;
|
|
41
|
+
}): string;
|
|
42
|
+
/**
|
|
43
|
+
* Execute batch translation
|
|
44
|
+
*/
|
|
45
|
+
export declare function batchTranslate(opts: BatchTranslateOptions): Promise<BatchResult>;
|
|
46
|
+
//# sourceMappingURL=batch-translate.d.ts.map
|
|
@@ -0,0 +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,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,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,CAqHtB"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import fg from "fast-glob";
|
|
2
|
+
import { dirname, join, relative, parse, isAbsolute, sep } from "path";
|
|
3
|
+
import { mkdirSync } from "fs";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { translateFile } from "./translate.js";
|
|
6
|
+
/**
|
|
7
|
+
* Check if a string contains glob pattern characters
|
|
8
|
+
*/
|
|
9
|
+
export function isGlobPattern(input) {
|
|
10
|
+
return /[*?[\]{}]/.test(input);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Generate output path for a translated file
|
|
14
|
+
*/
|
|
15
|
+
export function generateOutputPath(opts) {
|
|
16
|
+
const { inputPath, targetLang, outputDir, inputBase, explicitOutput } = opts;
|
|
17
|
+
// If explicit output is provided, use it
|
|
18
|
+
if (explicitOutput) {
|
|
19
|
+
return explicitOutput;
|
|
20
|
+
}
|
|
21
|
+
// If outputDir is provided, preserve directory structure
|
|
22
|
+
if (outputDir && inputBase) {
|
|
23
|
+
const relativePath = relative(inputBase, inputPath);
|
|
24
|
+
// Security: Prevent path traversal
|
|
25
|
+
// Reject paths that are absolute or try to escape via ".."
|
|
26
|
+
if (isAbsolute(relativePath)) {
|
|
27
|
+
throw new Error(`Path traversal detected: ${inputPath} is outside ${inputBase} (absolute path)`);
|
|
28
|
+
}
|
|
29
|
+
if (relativePath.startsWith(`..${sep}`) || relativePath === "..") {
|
|
30
|
+
throw new Error(`Path traversal detected: ${inputPath} tries to escape ${inputBase}`);
|
|
31
|
+
}
|
|
32
|
+
// Check for ".." in path segments
|
|
33
|
+
const segments = relativePath.split(sep);
|
|
34
|
+
if (segments.includes("..")) {
|
|
35
|
+
throw new Error(`Path traversal detected: ${inputPath} contains ".." segments`);
|
|
36
|
+
}
|
|
37
|
+
return join(outputDir, relativePath);
|
|
38
|
+
}
|
|
39
|
+
// Default: add language code before extension
|
|
40
|
+
const parsed = parse(inputPath);
|
|
41
|
+
const ext = parsed.ext || "";
|
|
42
|
+
const base = parsed.name;
|
|
43
|
+
const dir = parsed.dir;
|
|
44
|
+
return join(dir, `${base}.${targetLang}${ext}`);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Determine the base path for --input-dir calculation
|
|
48
|
+
*/
|
|
49
|
+
function determineInputBase(pattern, matchedFiles) {
|
|
50
|
+
// Extract the static prefix from the glob pattern
|
|
51
|
+
// e.g., "docs/en/**/*.md" -> "docs/en"
|
|
52
|
+
const staticPrefix = pattern.split(/[*?[\]{}]/)[0];
|
|
53
|
+
// If there's a static directory prefix, use it
|
|
54
|
+
if (staticPrefix && staticPrefix.includes("/")) {
|
|
55
|
+
// Remove trailing slash and return as-is (it's already a directory path)
|
|
56
|
+
return staticPrefix.replace(/\/$/, "");
|
|
57
|
+
}
|
|
58
|
+
// If no static prefix, find common base from matched files
|
|
59
|
+
if (matchedFiles.length === 0) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
// Find the common directory prefix of all matched files
|
|
63
|
+
const dirs = matchedFiles.map(f => dirname(f));
|
|
64
|
+
const commonDir = dirs.reduce((acc, dir) => {
|
|
65
|
+
if (!acc)
|
|
66
|
+
return dir;
|
|
67
|
+
const accParts = acc.split("/");
|
|
68
|
+
const dirParts = dir.split("/");
|
|
69
|
+
const common = [];
|
|
70
|
+
for (let i = 0; i < Math.min(accParts.length, dirParts.length); i++) {
|
|
71
|
+
if (accParts[i] === dirParts[i]) {
|
|
72
|
+
common.push(accParts[i]);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return common.join("/") || ".";
|
|
79
|
+
});
|
|
80
|
+
return commonDir === "." ? undefined : commonDir;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Execute batch translation
|
|
84
|
+
*/
|
|
85
|
+
export async function batchTranslate(opts) {
|
|
86
|
+
const { pattern, targetLang, provider, outputDir, onProgress, dryRun, verbose } = opts;
|
|
87
|
+
// Match files using fast-glob
|
|
88
|
+
const matchedFiles = await fg(pattern, {
|
|
89
|
+
onlyFiles: true,
|
|
90
|
+
absolute: false,
|
|
91
|
+
});
|
|
92
|
+
if (matchedFiles.length === 0) {
|
|
93
|
+
throw new Error(`No files matched pattern: ${pattern}`);
|
|
94
|
+
}
|
|
95
|
+
// Determine input base for directory structure preservation
|
|
96
|
+
const inputBase = outputDir ? determineInputBase(pattern, matchedFiles) : undefined;
|
|
97
|
+
// Initialize progress
|
|
98
|
+
const progress = {
|
|
99
|
+
total: matchedFiles.length,
|
|
100
|
+
current: 0,
|
|
101
|
+
succeeded: 0,
|
|
102
|
+
failed: 0,
|
|
103
|
+
skipped: 0,
|
|
104
|
+
};
|
|
105
|
+
const errors = [];
|
|
106
|
+
// Process each file
|
|
107
|
+
for (let i = 0; i < matchedFiles.length; i++) {
|
|
108
|
+
const inputPath = matchedFiles[i];
|
|
109
|
+
progress.current = i + 1;
|
|
110
|
+
const outputPath = generateOutputPath({
|
|
111
|
+
inputPath,
|
|
112
|
+
targetLang,
|
|
113
|
+
outputDir,
|
|
114
|
+
inputBase,
|
|
115
|
+
});
|
|
116
|
+
// Show progress
|
|
117
|
+
const progressPrefix = chalk.cyan(`[${progress.current}/${progress.total}]`);
|
|
118
|
+
if (dryRun) {
|
|
119
|
+
process.stdout.write(`${progressPrefix} Would translate:\n` +
|
|
120
|
+
` Input: ${inputPath}\n` +
|
|
121
|
+
` Output: ${outputPath}\n`);
|
|
122
|
+
progress.succeeded++;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
if (!provider) {
|
|
126
|
+
throw new Error("Provider is required when dryRun is false");
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
process.stdout.write(`${progressPrefix} Translating ${inputPath}...\n`);
|
|
130
|
+
// Ensure output directory exists
|
|
131
|
+
const outputDirPath = dirname(outputPath);
|
|
132
|
+
mkdirSync(outputDirPath, { recursive: true });
|
|
133
|
+
// Translate the file
|
|
134
|
+
const result = await translateFile({
|
|
135
|
+
provider,
|
|
136
|
+
inputPath,
|
|
137
|
+
outputPath,
|
|
138
|
+
targetLang,
|
|
139
|
+
});
|
|
140
|
+
process.stdout.write(`${chalk.green("✓")} Translated to ${result.outputPath}\n` +
|
|
141
|
+
(verbose ? ` Tokens: ${result.usage.totalTokens} (${result.chunks} chunk${result.chunks > 1 ? "s" : ""})\n` : ""));
|
|
142
|
+
progress.succeeded++;
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
146
|
+
process.stderr.write(`${chalk.red("✗")} Failed to translate ${inputPath}: ${errorMsg}\n`);
|
|
147
|
+
errors.push({ file: inputPath, error: errorMsg });
|
|
148
|
+
progress.failed++;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// Call progress callback
|
|
152
|
+
if (onProgress) {
|
|
153
|
+
onProgress(progress);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// Print summary
|
|
157
|
+
const summaryColor = progress.failed > 0 ? chalk.yellow : chalk.green;
|
|
158
|
+
process.stdout.write(`\n` +
|
|
159
|
+
summaryColor("Summary:\n") +
|
|
160
|
+
` Total: ${progress.total}\n` +
|
|
161
|
+
` Succeeded: ${progress.succeeded}\n` +
|
|
162
|
+
` Failed: ${progress.failed}\n`);
|
|
163
|
+
if (errors.length > 0) {
|
|
164
|
+
process.stderr.write(`\n${chalk.red("Errors:")}\n` +
|
|
165
|
+
errors.map(e => ` ${e.file}: ${e.error}`).join("\n") + "\n");
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
total: progress.total,
|
|
169
|
+
succeeded: progress.succeeded,
|
|
170
|
+
failed: progress.failed,
|
|
171
|
+
errors,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=batch-translate.js.map
|
|
@@ -0,0 +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;AA4B/C;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,U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AM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAC7D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface GlossaryTerm {
|
|
2
|
+
canonical: string;
|
|
3
|
+
type: string;
|
|
4
|
+
translations: Record<string, string>;
|
|
5
|
+
do_not_use?: Record<string, string[]>;
|
|
6
|
+
}
|
|
7
|
+
export interface GlossaryConfig {
|
|
8
|
+
version: number;
|
|
9
|
+
languages: string[];
|
|
10
|
+
terms: GlossaryTerm[];
|
|
11
|
+
}
|
|
12
|
+
export interface GlossaryIssue {
|
|
13
|
+
forbidden: string;
|
|
14
|
+
canonical: string;
|
|
15
|
+
line: number;
|
|
16
|
+
}
|
|
17
|
+
export interface MissingTranslation {
|
|
18
|
+
canonical: string;
|
|
19
|
+
missingLanguages: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface SyncResult {
|
|
22
|
+
totalTerms: number;
|
|
23
|
+
termsByLanguage: Record<string, GlossaryTerm[]>;
|
|
24
|
+
missingTranslations: MissingTranslation[];
|
|
25
|
+
stubsCreated: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ReviewReport {
|
|
28
|
+
terms: GlossaryTerm[];
|
|
29
|
+
summary: {
|
|
30
|
+
totalTerms: number;
|
|
31
|
+
languages: string[];
|
|
32
|
+
};
|
|
33
|
+
toMarkdown(): string;
|
|
34
|
+
}
|
|
35
|
+
export declare function loadGlossary(glossaryPath: string): GlossaryConfig | null;
|
|
36
|
+
export declare function initGlossary(outputPath: string, force?: boolean): void;
|
|
37
|
+
export declare function checkGlossary(docPath: string, glossaryPath: string, lang: string): GlossaryIssue[];
|
|
38
|
+
export declare function syncGlossary(glossaryPath: string): SyncResult;
|
|
39
|
+
export declare function reviewGlossary(glossaryPath: string): ReviewReport;
|
|
40
|
+
export declare function buildGlossaryPrompt(glossaryConfig: GlossaryConfig, targetLang: string): string;
|
|
41
|
+
//# sourceMappingURL=glossary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glossary.d.ts","sourceRoot":"","sources":["../../src/tasks/glossary.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IAChD,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IACF,UAAU,IAAI,MAAM,CAAC;CACtB;AA+BD,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAqBxE;AAMD,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAQtE;AAMD,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,GACX,aAAa,EAAE,CAuDjB;AAgED,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,CAoD7D;AAMD,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY,CA6CjE;AAMD,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,MAAM,GACjB,MAAM,CAyBR"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
2
|
+
import { parse, stringify } from "yaml";
|
|
3
|
+
import { separateFrontmatter, protectCodeBlocks } from "./translate.js";
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Skeleton template
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
const SKELETON_TEMPLATE = `version: 1
|
|
8
|
+
languages: [ja, en]
|
|
9
|
+
terms:
|
|
10
|
+
- canonical: "API"
|
|
11
|
+
type: noun
|
|
12
|
+
translations:
|
|
13
|
+
ja: "API"
|
|
14
|
+
en: "API"
|
|
15
|
+
do_not_use:
|
|
16
|
+
ja: ["API", "えーぴーあい"]
|
|
17
|
+
# Add more terms below:
|
|
18
|
+
# - canonical: "webhook"
|
|
19
|
+
# type: noun
|
|
20
|
+
# translations:
|
|
21
|
+
# ja: "Webhook"
|
|
22
|
+
# en: "webhook"
|
|
23
|
+
# do_not_use:
|
|
24
|
+
# ja: ["ウェブフック"]
|
|
25
|
+
# en: ["web hook"]
|
|
26
|
+
`;
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// loadGlossary
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
export function loadGlossary(glossaryPath) {
|
|
31
|
+
if (!existsSync(glossaryPath)) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const content = readFileSync(glossaryPath, "utf-8");
|
|
35
|
+
const raw = parse(content);
|
|
36
|
+
if (!raw || typeof raw !== "object") {
|
|
37
|
+
throw new Error(`Invalid glossary file: ${glossaryPath}`);
|
|
38
|
+
}
|
|
39
|
+
const schema = raw;
|
|
40
|
+
if (!Array.isArray(schema.terms)) {
|
|
41
|
+
throw new Error(`Glossary file must have a "terms" array: ${glossaryPath}`);
|
|
42
|
+
}
|
|
43
|
+
if (!Array.isArray(schema.languages)) {
|
|
44
|
+
throw new Error(`Glossary file must have a "languages" array: ${glossaryPath}`);
|
|
45
|
+
}
|
|
46
|
+
return raw;
|
|
47
|
+
}
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// initGlossary
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
export function initGlossary(outputPath, force) {
|
|
52
|
+
if (existsSync(outputPath) && !force) {
|
|
53
|
+
throw new Error(`Glossary file already exists: ${outputPath}\nUse --force to overwrite.`);
|
|
54
|
+
}
|
|
55
|
+
writeFileSync(outputPath, SKELETON_TEMPLATE, "utf-8");
|
|
56
|
+
}
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
// checkGlossary
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
export function checkGlossary(docPath, glossaryPath, lang) {
|
|
61
|
+
// Load glossary (throws if not found)
|
|
62
|
+
const glossary = loadGlossary(glossaryPath);
|
|
63
|
+
if (!glossary) {
|
|
64
|
+
throw new Error(`Glossary file not found: ${glossaryPath}`);
|
|
65
|
+
}
|
|
66
|
+
// Validate lang parameter
|
|
67
|
+
if (!glossary.languages.includes(lang)) {
|
|
68
|
+
throw new Error(`Language "${lang}" is not defined in glossary. Available: ${glossary.languages.join(", ")}`);
|
|
69
|
+
}
|
|
70
|
+
// Read document (throws if not found)
|
|
71
|
+
let docContent;
|
|
72
|
+
try {
|
|
73
|
+
docContent = readFileSync(docPath, "utf-8");
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
if (err instanceof Error && "code" in err && err.code === "ENOENT") {
|
|
77
|
+
throw new Error(`Document not found: ${docPath}`);
|
|
78
|
+
}
|
|
79
|
+
throw err;
|
|
80
|
+
}
|
|
81
|
+
// Separate frontmatter (skip it) and get body
|
|
82
|
+
const { frontmatter, body } = separateFrontmatter(docContent);
|
|
83
|
+
const frontmatterLineCount = frontmatter ? frontmatter.split("\n").length - 1 : 0;
|
|
84
|
+
// Protect code blocks and inline code with placeholders to avoid false positives
|
|
85
|
+
const { text: protectedBody } = protectCodeBlocks(body);
|
|
86
|
+
const lines = protectedBody.split("\n");
|
|
87
|
+
const issues = [];
|
|
88
|
+
for (const term of glossary.terms) {
|
|
89
|
+
const forbidden = term.do_not_use?.[lang] ?? [];
|
|
90
|
+
const canonicalTranslation = term.translations[lang];
|
|
91
|
+
for (const forbiddenWord of forbidden) {
|
|
92
|
+
if (forbiddenWord.length === 0)
|
|
93
|
+
continue;
|
|
94
|
+
for (let i = 0; i < lines.length; i++) {
|
|
95
|
+
// Remove URL content before checking to avoid false positives inside URLs
|
|
96
|
+
const lineWithoutUrls = lines[i].replace(/https?:\/\/\S+/g, "");
|
|
97
|
+
if (hasUncoveredOccurrence(lineWithoutUrls, forbiddenWord, canonicalTranslation)) {
|
|
98
|
+
issues.push({
|
|
99
|
+
forbidden: forbiddenWord,
|
|
100
|
+
canonical: term.canonical,
|
|
101
|
+
line: i + 1 + frontmatterLineCount,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return issues;
|
|
108
|
+
}
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
// Substring-match helpers for checkGlossary
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
/**
|
|
113
|
+
* Returns true if `canonicalTranslation` appears in `line` at a position
|
|
114
|
+
* that "covers" the occurrence of `forbiddenWord` starting at `forbiddenIdx`.
|
|
115
|
+
*
|
|
116
|
+
* Example: canonicalTranslation = "サブスクリプション", forbiddenWord = "サブスク"
|
|
117
|
+
* If "サブスクリプション" appears at position 0 in the line, the "サブスク" occurrence
|
|
118
|
+
* at position 0 is covered and should not be reported as a violation.
|
|
119
|
+
*/
|
|
120
|
+
function isOccurrenceCoveredByCanonical(line, forbiddenIdx, forbiddenWord, canonicalTranslation) {
|
|
121
|
+
if (!canonicalTranslation)
|
|
122
|
+
return false;
|
|
123
|
+
// For each position of forbiddenWord within canonicalTranslation, check
|
|
124
|
+
// whether canonicalTranslation appears at the corresponding position in line.
|
|
125
|
+
let posInCanonical = canonicalTranslation.indexOf(forbiddenWord);
|
|
126
|
+
while (posInCanonical !== -1) {
|
|
127
|
+
const canonicalStart = forbiddenIdx - posInCanonical;
|
|
128
|
+
if (canonicalStart >= 0 &&
|
|
129
|
+
line.slice(canonicalStart, canonicalStart + canonicalTranslation.length) === canonicalTranslation) {
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
posInCanonical = canonicalTranslation.indexOf(forbiddenWord, posInCanonical + 1);
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Returns true if `line` contains at least one occurrence of `forbiddenWord`
|
|
138
|
+
* that is NOT covered by `canonicalTranslation` appearing at the same position.
|
|
139
|
+
*/
|
|
140
|
+
function hasUncoveredOccurrence(line, forbiddenWord, canonicalTranslation) {
|
|
141
|
+
if (forbiddenWord.length === 0)
|
|
142
|
+
return false;
|
|
143
|
+
let searchPos = 0;
|
|
144
|
+
while (true) {
|
|
145
|
+
const idx = line.indexOf(forbiddenWord, searchPos);
|
|
146
|
+
if (idx === -1)
|
|
147
|
+
break;
|
|
148
|
+
if (!isOccurrenceCoveredByCanonical(line, idx, forbiddenWord, canonicalTranslation)) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
searchPos = idx + 1;
|
|
152
|
+
}
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
// ---------------------------------------------------------------------------
|
|
156
|
+
// syncGlossary
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
export function syncGlossary(glossaryPath) {
|
|
159
|
+
const glossary = loadGlossary(glossaryPath);
|
|
160
|
+
if (!glossary) {
|
|
161
|
+
throw new Error(`Glossary file not found: ${glossaryPath}`);
|
|
162
|
+
}
|
|
163
|
+
const termsByLanguage = {};
|
|
164
|
+
for (const lang of glossary.languages) {
|
|
165
|
+
termsByLanguage[lang] = [];
|
|
166
|
+
}
|
|
167
|
+
const missingTranslations = [];
|
|
168
|
+
for (const term of glossary.terms) {
|
|
169
|
+
const missingLangs = [];
|
|
170
|
+
for (const lang of glossary.languages) {
|
|
171
|
+
if (term.translations[lang]) {
|
|
172
|
+
termsByLanguage[lang].push(term);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
missingLangs.push(lang);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (missingLangs.length > 0) {
|
|
179
|
+
missingTranslations.push({
|
|
180
|
+
canonical: term.canonical,
|
|
181
|
+
missingLanguages: missingLangs,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Write stub placeholders for missing translations
|
|
186
|
+
let stubsCreated = 0;
|
|
187
|
+
if (missingTranslations.length > 0) {
|
|
188
|
+
for (const term of glossary.terms) {
|
|
189
|
+
for (const lang of glossary.languages) {
|
|
190
|
+
if (!term.translations[lang]) {
|
|
191
|
+
term.translations[lang] = "";
|
|
192
|
+
stubsCreated++;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
writeFileSync(glossaryPath, stringify(glossary), "utf-8");
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
totalTerms: glossary.terms.length,
|
|
200
|
+
termsByLanguage,
|
|
201
|
+
missingTranslations,
|
|
202
|
+
stubsCreated,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
// ---------------------------------------------------------------------------
|
|
206
|
+
// reviewGlossary
|
|
207
|
+
// ---------------------------------------------------------------------------
|
|
208
|
+
export function reviewGlossary(glossaryPath) {
|
|
209
|
+
const glossary = loadGlossary(glossaryPath);
|
|
210
|
+
if (!glossary) {
|
|
211
|
+
throw new Error(`Glossary file not found: ${glossaryPath}`);
|
|
212
|
+
}
|
|
213
|
+
const report = {
|
|
214
|
+
terms: glossary.terms,
|
|
215
|
+
summary: {
|
|
216
|
+
totalTerms: glossary.terms.length,
|
|
217
|
+
languages: glossary.languages,
|
|
218
|
+
},
|
|
219
|
+
toMarkdown() {
|
|
220
|
+
const lines = [
|
|
221
|
+
"# Glossary Review Report",
|
|
222
|
+
"",
|
|
223
|
+
`**Total Terms:** ${glossary.terms.length}`,
|
|
224
|
+
`**Languages:** ${glossary.languages.join(", ")}`,
|
|
225
|
+
"",
|
|
226
|
+
"## Terms",
|
|
227
|
+
"",
|
|
228
|
+
];
|
|
229
|
+
for (const term of glossary.terms) {
|
|
230
|
+
lines.push(`### ${term.canonical}`);
|
|
231
|
+
lines.push("");
|
|
232
|
+
lines.push(`- **Type:** ${term.type}`);
|
|
233
|
+
lines.push("- **Translations:**");
|
|
234
|
+
for (const [lang, translation] of Object.entries(term.translations)) {
|
|
235
|
+
lines.push(` - \`${lang}\`: ${translation}`);
|
|
236
|
+
}
|
|
237
|
+
if (term.do_not_use && Object.keys(term.do_not_use).length > 0) {
|
|
238
|
+
lines.push("- **Do not use:**");
|
|
239
|
+
for (const [lang, words] of Object.entries(term.do_not_use)) {
|
|
240
|
+
lines.push(` - \`${lang}\`: ${words.join(", ")}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
lines.push("");
|
|
244
|
+
}
|
|
245
|
+
return lines.join("\n");
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
return report;
|
|
249
|
+
}
|
|
250
|
+
// ---------------------------------------------------------------------------
|
|
251
|
+
// buildGlossaryPrompt — helper for translate integration
|
|
252
|
+
// ---------------------------------------------------------------------------
|
|
253
|
+
export function buildGlossaryPrompt(glossaryConfig, targetLang) {
|
|
254
|
+
const relevantTerms = glossaryConfig.terms.filter((t) => t.translations[targetLang] || t.do_not_use?.[targetLang]);
|
|
255
|
+
if (relevantTerms.length === 0) {
|
|
256
|
+
return "";
|
|
257
|
+
}
|
|
258
|
+
const lines = [
|
|
259
|
+
"",
|
|
260
|
+
"Glossary — use these canonical translations and avoid forbidden terms:",
|
|
261
|
+
];
|
|
262
|
+
for (const term of relevantTerms) {
|
|
263
|
+
const canonical = term.translations[targetLang] ?? term.canonical;
|
|
264
|
+
const forbidden = term.do_not_use?.[targetLang] ?? [];
|
|
265
|
+
let line = `- "${term.canonical}" → "${canonical}"`;
|
|
266
|
+
if (forbidden.length > 0) {
|
|
267
|
+
line += ` (do NOT use: ${forbidden.map((f) => `"${f}"`).join(", ")})`;
|
|
268
|
+
}
|
|
269
|
+
lines.push(line);
|
|
270
|
+
}
|
|
271
|
+
return lines.join("\n");
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=glossary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glossary.js","sourceRoot":"","sources":["../../src/tasks/glossary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AA8CxE,8EAA8E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;QAClE,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACtD,IAAI,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,QAAQ,SAAS,GAAG,CAAC;QACpD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,IAAI,IAAI,iBAAiB,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QACxE,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/tasks/stream.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/tasks/stream.js
CHANGED
|
File without changes
|
package/dist/tasks/stream.js.map
CHANGED
|
File without changes
|
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
import type { AIProvider } from "../provider/interface.js";
|
|
2
|
+
import type { GlossaryConfig } from "./glossary.js";
|
|
3
|
+
interface FrontmatterSeparation {
|
|
4
|
+
frontmatter: string | null;
|
|
5
|
+
body: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Separate frontmatter from Markdown content
|
|
9
|
+
* Handles: LF, CRLF, no trailing newline after closing ---, trailing spaces, empty frontmatter
|
|
10
|
+
* @param content - Full Markdown content
|
|
11
|
+
* @returns Object with separated frontmatter and body
|
|
12
|
+
*/
|
|
13
|
+
export declare function separateFrontmatter(content: string): FrontmatterSeparation;
|
|
14
|
+
interface CodeProtection {
|
|
15
|
+
text: string;
|
|
16
|
+
map: Map<string, string>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Replace fenced code blocks and inline code with placeholders.
|
|
20
|
+
* Fenced blocks (``` or ````+) take priority over inline code.
|
|
21
|
+
*/
|
|
22
|
+
export declare function protectCodeBlocks(content: string): CodeProtection;
|
|
23
|
+
/**
|
|
24
|
+
* Restore placeholders back to original code blocks/inline code.
|
|
25
|
+
*/
|
|
26
|
+
export declare function restoreCodeBlocks(content: string, map: Map<string, string>): string;
|
|
2
27
|
export interface TranslateOptions {
|
|
3
28
|
provider: AIProvider;
|
|
4
29
|
inputPath: string;
|
|
5
30
|
outputPath?: string;
|
|
6
31
|
targetLang: string;
|
|
7
32
|
templateContent?: string;
|
|
33
|
+
glossaryConfig?: GlossaryConfig;
|
|
8
34
|
}
|
|
9
35
|
export interface TranslateResult {
|
|
10
36
|
outputPath: string;
|
|
@@ -16,4 +42,5 @@ export interface TranslateResult {
|
|
|
16
42
|
chunks: number;
|
|
17
43
|
}
|
|
18
44
|
export declare function translateFile(options: TranslateOptions): Promise<TranslateResult>;
|
|
45
|
+
export {};
|
|
19
46
|
//# sourceMappingURL=translate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/tasks/translate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/tasks/translate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,0BAA0B,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAKpD,UAAU,qBAAqB;IAC7B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,qBAAqB,CAmB1E;AAED,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1B;AAED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