@makuraryu/yonde 0.3.1 → 0.3.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 +2 -4
- package/package.json +1 -1
- package/src/config.ts +3 -6
- package/src/main.ts +6 -2
package/README.md
CHANGED
|
@@ -64,13 +64,11 @@ Yonde 支持以下环境变量:
|
|
|
64
64
|
| 变量 | 用途 |
|
|
65
65
|
| --- | --- |
|
|
66
66
|
| `YONDE_API_KEY` | 默认翻译 API Key |
|
|
67
|
-
| `DEEPSEEK_API_KEY` | API Key 兼容变量 |
|
|
68
67
|
| `YONDE_API_ENDPOINT` | 覆盖翻译 API 地址 |
|
|
69
|
-
| `
|
|
70
|
-
| `YONDE_MODEL` / `DEEPSEEK_MODEL` | 覆盖模型 |
|
|
68
|
+
| `YONDE_MODEL` | 覆盖模型 |
|
|
71
69
|
| `YONDE_TTS_CONCURRENCY` | 覆盖 TTS 并发数 |
|
|
72
70
|
|
|
73
|
-
也可以用 `translation.api.api_key_env`
|
|
71
|
+
也可以用 `translation.api.api_key_env` 明确指定一个 API Key 环境变量。若 TOML 中直接设置了 `translation.api.api_key`,它优先于环境变量;未设置时只读取 `api_key_env` 指定的变量(默认 `YONDE_API_KEY`)。Yonde 不会隐式读取 `DEEPSEEK_API_KEY` 或任何其他 Key 变量。Yonde 会提示检查含明文 Key 的文件权限。API Key 不会写入检查点、日志或音频清单。
|
|
74
72
|
|
|
75
73
|
## TOML 配置
|
|
76
74
|
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -241,8 +241,7 @@ function environmentOverrides(): UnknownRecord {
|
|
|
241
241
|
const translation: UnknownRecord = { api };
|
|
242
242
|
const audio: UnknownRecord = {};
|
|
243
243
|
if (process.env.YONDE_API_ENDPOINT) api.endpoint = process.env.YONDE_API_ENDPOINT;
|
|
244
|
-
|
|
245
|
-
if (process.env.YONDE_MODEL ?? process.env.DEEPSEEK_MODEL) api.model = process.env.YONDE_MODEL ?? process.env.DEEPSEEK_MODEL;
|
|
244
|
+
if (process.env.YONDE_MODEL) api.model = process.env.YONDE_MODEL;
|
|
246
245
|
if (process.env.YONDE_TTS_CONCURRENCY) audio.concurrency = Number(process.env.YONDE_TTS_CONCURRENCY);
|
|
247
246
|
return { translation, audio };
|
|
248
247
|
}
|
|
@@ -284,10 +283,8 @@ export async function loadConfig(explicitPath?: string, cwd = process.cwd()): Pr
|
|
|
284
283
|
}
|
|
285
284
|
|
|
286
285
|
export function resolveApiKey(config: AppConfig): string | undefined {
|
|
287
|
-
return
|
|
288
|
-
?? process.env.
|
|
289
|
-
?? process.env.DEEPSEEK_API_KEY
|
|
290
|
-
?? config.translation.api.apiKey;
|
|
286
|
+
return config.translation.api.apiKey
|
|
287
|
+
?? process.env[config.translation.api.apiKeyEnv];
|
|
291
288
|
}
|
|
292
289
|
|
|
293
290
|
export function translationFingerprint(config: AppConfig): string {
|
package/src/main.ts
CHANGED
|
@@ -11,7 +11,7 @@ type Stage = "translate" | "audio" | "all";
|
|
|
11
11
|
type RunArgs = { command: "run"; input: string; stage: Stage; outputDir?: string; configPath?: string };
|
|
12
12
|
type CliArgs = RunArgs | { command: "init"; path: string } | { command: "config-check"; configPath?: string } | { command: "help" } | { command: "version" };
|
|
13
13
|
|
|
14
|
-
const VERSION = "0.3.
|
|
14
|
+
const VERSION = "0.3.3";
|
|
15
15
|
|
|
16
16
|
export const HELP_TEXT = `Yonde ${VERSION} — 配置驱动的双语听力材料生成器
|
|
17
17
|
|
|
@@ -47,7 +47,11 @@ export const HELP_TEXT = `Yonde ${VERSION} — 配置驱动的双语听力材料
|
|
|
47
47
|
YONDE_API_KEY 默认翻译 API Key
|
|
48
48
|
YONDE_API_ENDPOINT 覆盖翻译 API 地址
|
|
49
49
|
YONDE_MODEL 覆盖翻译模型
|
|
50
|
-
YONDE_TTS_CONCURRENCY 覆盖 TTS
|
|
50
|
+
YONDE_TTS_CONCURRENCY 覆盖 TTS 并发数
|
|
51
|
+
|
|
52
|
+
API Key 优先级:
|
|
53
|
+
translation.api.api_key > api_key_env 明确指定的环境变量
|
|
54
|
+
默认 api_key_env 为 YONDE_API_KEY;不会读取其他 Key 变量`;
|
|
51
55
|
|
|
52
56
|
function usage(exitCode = 1): never {
|
|
53
57
|
const output = exitCode === 0 ? console.log : console.error;
|