pi-model-manager 0.3.0 → 0.3.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/README.en.md CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  English · [简体中文](./README.md)
4
4
 
5
- [![Pi](https://img.shields.io/badge/Pi-%3E%3D0.82.0-6f42c1)](https://github.com/earendil-works/pi)
5
+ [![Pi](https://img.shields.io/badge/Pi-%3E%3D0.84.2-6f42c1)](https://github.com/earendil-works/pi)
6
6
  [![License](https://img.shields.io/badge/license-AGPL--3.0-blue.svg)](./LICENSE)
7
- [![Version](https://img.shields.io/badge/version-0.3.0-2f81f7.svg)](https://github.com/Qihuanxishini/pi-model-manager)
7
+ [![Version](https://img.shields.io/badge/version-0.3.2-2f81f7.svg)](https://github.com/Qihuanxishini/pi-model-manager)
8
8
 
9
9
  A TUI model and provider manager for [Pi](https://github.com/earendil-works/pi). It keeps Pi's native `models.json` as the single source of truth for model configuration while adding provider/model editing, client-header identities, proxy routing, and protocol compatibility controls.
10
10
 
11
- > The current stable version is `0.3.0` and requires Pi `>=0.82.0`.
11
+ > The current stable version is `0.3.2` and requires Pi `>=0.84.2`.
12
12
 
13
13
  ## Interface preview
14
14
 
15
- The screens below are rendered by the real components at 88 columns. In practice column widths adapt to your data, the selected row is highlighted with a background colour, and column values are semantically coloured. The TUI copy itself is Simplified Chinese.
15
+ The screens below are rendered by the real components at 88 columns. In practice column widths adapt to your data, the selected row is highlighted with a background colour, and column values are semantically coloured. This preview uses Simplified Chinese; the live UI can switch between Simplified Chinese and English from the dashboard.
16
16
 
17
17
  ```text
18
18
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -30,7 +30,7 @@ OpenAI (openai)
30
30
  endpoint https://api.openai.com/v1
31
31
  proxy direct
32
32
  api Responses · headers Auto→Codex · auth env
33
- models gpt-5.1, gpt-5.1-mini
33
+ models gpt-5.6-sol, gpt-5.6-terra
34
34
 
35
35
  ↑↓ 选择 Enter 进入 N 新建接入 D 删除接入 H 请求头 Esc 退出 / 搜索
36
36
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -48,8 +48,8 @@ Responses · 2 模型 · headers Auto→Codex · proxy direct · auth env
48
48
  endpoint https://api.openai.com/v1
49
49
 
50
50
  模型 ID 显示名 输入 Thinking 上下文
51
- ❯ gpt-5.1 默认 文本,视觉 开 400K
52
- gpt-5.1-mini 默认 文本,视觉 开 400K
51
+ ❯ gpt-5.6-sol 默认 文本,视觉 开 1.1M
52
+ gpt-5.6-terra 默认 文本,视觉 开 1.1M
53
53
 
54
54
  ↑↓ 选择 Enter 编辑模型 A 添加模型 E 编辑接入 D 删除模型 Esc 返回 / 搜索
55
55
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -82,17 +82,17 @@ Ctrl+S 保存并同步 models.json;不切换当前会话模型
82
82
 
83
83
  ```text
84
84
  ────────────────────────────────────────────────────────────────────────────────────────
85
- 编辑模型 gpt-5.1
85
+ 编辑模型 gpt-5.6-sol
86
86
  接入 openai · API Responses
87
87
  Ctrl+S 保存并启用模型;不切换当前会话模型
88
88
 
89
- 模型 ID gpt-5.1
89
+ 模型 ID gpt-5.6-sol
90
90
  重新拉取 上游模型列表
91
91
  显示名称 默认 = 模型 ID
92
92
  ❯ 视觉支持 开启
93
93
  Thinking 开启
94
94
  Fast mode 关闭
95
- 上下文窗口 400000
95
+ 上下文窗口 1050000
96
96
  最大输出 128000
97
97
  请求头 跟随接入(Auto→Codex)
98
98
 
@@ -108,14 +108,14 @@ Ctrl+S 保存并启用模型;不切换当前会话模型
108
108
  搜索: <直接输入搜索>
109
109
  匹配 9 / 9 · 页码 1 / 2
110
110
 
111
- dall-e-3
112
- gpt-4.1
113
- gpt-4.1-mini
114
- ❯ gpt-5.1 ← 当前
115
- gpt-5.1-codex
116
- gpt-5.1-mini
117
- o4-mini
118
- text-embedding-3-large
111
+ gpt-5.3
112
+ gpt-5.4
113
+ gpt-5.4-mini
114
+ gpt-5.5
115
+ gpt-5.6-luna
116
+ ❯ gpt-5.6-sol ← 当前
117
+ gpt-5.6-terra
118
+ gpt-image-2
119
119
 
120
120
  ↑↓ 选择 · ←→/PgUp/PgDn 翻页 · 输入搜索 · Backspace 删除 · Enter 确认 · Esc 取消
121
121
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -126,6 +126,7 @@ Ctrl+S 保存并启用模型;不切换当前会话模型
126
126
  ## Features
127
127
 
128
128
  - Create, edit, and delete providers and models from the `/model-manager` TUI.
129
+ - Start in Simplified Chinese and press `L` on the dashboard to switch to English; the language preference is saved.
129
130
  - Supports `openai-completions`, `openai-responses`, `anthropic-messages`, and `google-generative-ai`.
130
131
  - Fetch model IDs from compatible upstream APIs or enter them manually.
131
132
  - Configure context window, maximum output, vision support, and reasoning support.
@@ -181,6 +182,7 @@ pi install npm:pi-model-manager
181
182
  | `N` | Create a provider and its first model |
182
183
  | `D` | Delete the selected provider |
183
184
  | `H` | Manage reusable header profiles |
185
+ | `L` | Switch the UI language (Simplified Chinese / English); the choice applies immediately and is saved |
184
186
  | `/` | Search the current list; `Tab` leaves the input while keeping the filter, `Esc` clears it |
185
187
  | `Esc` | Go back or exit |
186
188
 
@@ -225,8 +227,8 @@ Model capabilities include:
225
227
 
226
228
  The current built-in values were derived from real client requests with authentication fields removed:
227
229
 
228
- - Claude Code `2.1.232`
229
- - Codex TUI `0.147.0`
230
+ - Claude Code `2.1.243`
231
+ - Codex TUI `0.149.1`
230
232
 
231
233
  These headers only help API gateways that require a recognized client identity; they do not replace an API key. The public repository and npm package contain **no request-capture tooling, user captures, authentication headers, or machine-local state**. Disable identity headers or create a custom profile if a built-in profile does not fit your endpoint.
232
234
 
@@ -266,11 +268,11 @@ Additional considerations:
266
268
 
267
269
  | Component | Requirement |
268
270
  | --- | --- |
269
- | `@earendil-works/pi-coding-agent` | `>=0.82.0` |
271
+ | `@earendil-works/pi-coding-agent` | `>=0.84.2` |
270
272
  | `@earendil-works/pi-tui` | `>=0.75.0` |
271
273
  | Runtime mode | `/model-manager` requires the Pi TUI |
272
274
 
273
- The current TUI copy is Simplified Chinese.
275
+ The TUI copy defaults to Simplified Chinese; press `L` on the dashboard to switch to English.
274
276
 
275
277
  ## Local development
276
278
 
@@ -293,9 +295,9 @@ npm pack --dry-run
293
295
 
294
296
  Open a reproducible report in [GitHub Issues](https://github.com/Qihuanxishini/pi-model-manager/issues). Remove API keys, authentication headers, proxy credentials, and private endpoints before sharing configuration or logs.
295
297
 
296
- ## Acknowledgements
298
+ ## Friendly links
297
299
 
298
- Thanks to the [LINUX DO](https://linux.do/) community for discussion, sharing, and feedback.
300
+ * [Linux DO](https://linux.do)
299
301
 
300
302
  ## License
301
303
 
package/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  [English](./README.en.md) · 简体中文
4
4
 
5
- [![Pi](https://img.shields.io/badge/Pi-%3E%3D0.82.0-6f42c1)](https://github.com/earendil-works/pi)
5
+ [![Pi](https://img.shields.io/badge/Pi-%3E%3D0.84.2-6f42c1)](https://github.com/earendil-works/pi)
6
6
  [![License](https://img.shields.io/badge/license-AGPL--3.0-blue.svg)](./LICENSE)
7
- [![Version](https://img.shields.io/badge/version-0.3.0-2f81f7.svg)](https://github.com/Qihuanxishini/pi-model-manager)
7
+ [![Version](https://img.shields.io/badge/version-0.3.2-2f81f7.svg)](https://github.com/Qihuanxishini/pi-model-manager)
8
8
 
9
9
  一个面向 [Pi](https://github.com/earendil-works/pi) 的 TUI 模型与接入管理扩展。它以 Pi 原生 `models.json` 为模型配置的唯一权威来源,并提供接入/模型编辑、请求头身份、代理路由和协议兼容配置。
10
10
 
11
- > 当前稳定版为 `0.3.0`,要求 Pi `>=0.82.0`。
11
+ > 当前稳定版为 `0.3.2`,要求 Pi `>=0.84.2`。
12
12
 
13
13
  ## 界面预览
14
14
 
@@ -30,7 +30,7 @@ OpenAI (openai)
30
30
  endpoint https://api.openai.com/v1
31
31
  proxy direct
32
32
  api Responses · headers Auto→Codex · auth env
33
- models gpt-5.1, gpt-5.1-mini
33
+ models gpt-5.6-sol, gpt-5.6-terra
34
34
 
35
35
  ↑↓ 选择 Enter 进入 N 新建接入 D 删除接入 H 请求头 Esc 退出 / 搜索
36
36
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -48,8 +48,8 @@ Responses · 2 模型 · headers Auto→Codex · proxy direct · auth env
48
48
  endpoint https://api.openai.com/v1
49
49
 
50
50
  模型 ID 显示名 输入 Thinking 上下文
51
- ❯ gpt-5.1 默认 文本,视觉 开 400K
52
- gpt-5.1-mini 默认 文本,视觉 开 400K
51
+ ❯ gpt-5.6-sol 默认 文本,视觉 开 1.1M
52
+ gpt-5.6-terra 默认 文本,视觉 开 1.1M
53
53
 
54
54
  ↑↓ 选择 Enter 编辑模型 A 添加模型 E 编辑接入 D 删除模型 Esc 返回 / 搜索
55
55
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -82,17 +82,17 @@ Ctrl+S 保存并同步 models.json;不切换当前会话模型
82
82
 
83
83
  ```text
84
84
  ────────────────────────────────────────────────────────────────────────────────────────
85
- 编辑模型 gpt-5.1
85
+ 编辑模型 gpt-5.6-sol
86
86
  接入 openai · API Responses
87
87
  Ctrl+S 保存并启用模型;不切换当前会话模型
88
88
 
89
- 模型 ID gpt-5.1
89
+ 模型 ID gpt-5.6-sol
90
90
  重新拉取 上游模型列表
91
91
  显示名称 默认 = 模型 ID
92
92
  ❯ 视觉支持 开启
93
93
  Thinking 开启
94
94
  Fast mode 关闭
95
- 上下文窗口 400000
95
+ 上下文窗口 1050000
96
96
  最大输出 128000
97
97
  请求头 跟随接入(Auto→Codex)
98
98
 
@@ -108,14 +108,14 @@ Ctrl+S 保存并启用模型;不切换当前会话模型
108
108
  搜索: <直接输入搜索>
109
109
  匹配 9 / 9 · 页码 1 / 2
110
110
 
111
- dall-e-3
112
- gpt-4.1
113
- gpt-4.1-mini
114
- ❯ gpt-5.1 ← 当前
115
- gpt-5.1-codex
116
- gpt-5.1-mini
117
- o4-mini
118
- text-embedding-3-large
111
+ gpt-5.3
112
+ gpt-5.4
113
+ gpt-5.4-mini
114
+ gpt-5.5
115
+ gpt-5.6-luna
116
+ ❯ gpt-5.6-sol ← 当前
117
+ gpt-5.6-terra
118
+ gpt-image-2
119
119
 
120
120
  ↑↓ 选择 · ←→/PgUp/PgDn 翻页 · 输入搜索 · Backspace 删除 · Enter 确认 · Esc 取消
121
121
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -126,6 +126,7 @@ Ctrl+S 保存并启用模型;不切换当前会话模型
126
126
  ## 功能
127
127
 
128
128
  - 在 `/model-manager` TUI 中新增、编辑和删除接入与模型。
129
+ - 界面默认使用简体中文;可在主面板按 `L` 切换为 English,语言选择会持久保存。
129
130
  - 原生支持 `openai-completions`、`openai-responses`、`anthropic-messages` 和 `google-generative-ai`。
130
131
  - 从兼容上游拉取模型 ID,也可手动填写模型。
131
132
  - 配置上下文窗口、最大输出、视觉支持和 Thinking。
@@ -181,6 +182,7 @@ pi install npm:pi-model-manager
181
182
  | `N` | 新建接入及其第一个模型 |
182
183
  | `D` | 删除所选接入 |
183
184
  | `H` | 管理可复用请求头 |
185
+ | `L` | 切换界面语言(简体中文 / English),选择后立即生效并持久保存 |
184
186
  | `/` | 搜索当前列表;`Tab` 退出输入但保留过滤,`Esc` 清空 |
185
187
  | `Esc` | 返回或退出 |
186
188
 
@@ -229,8 +231,8 @@ Base URL 在填入时就会归一化为各协议 SDK 可直接使用的根地址
229
231
 
230
232
  当前内置值来自真实客户端请求并已移除认证信息:
231
233
 
232
- - Claude Code `2.1.232`
233
- - Codex TUI `0.147.0`
234
+ - Claude Code `2.1.243`
235
+ - Codex TUI `0.149.1`
234
236
 
235
237
  这些值只用于兼容需要识别客户端身份的 API 中转,不代替 API key。公开仓库和 npm 包**不包含请求捕获工具、用户抓包、认证头或本机状态**。如果内置值不适合你的服务,请关闭身份头或创建自定义请求头。
236
238
 
@@ -270,11 +272,11 @@ ${ANTHROPIC_API_KEY}
270
272
 
271
273
  | 组件 | 要求 |
272
274
  | --- | --- |
273
- | `@earendil-works/pi-coding-agent` | `>=0.82.0` |
275
+ | `@earendil-works/pi-coding-agent` | `>=0.84.2` |
274
276
  | `@earendil-works/pi-tui` | `>=0.75.0` |
275
277
  | 运行模式 | `/model-manager` 需要 Pi TUI |
276
278
 
277
- 当前 TUI 文案为简体中文。
279
+ 默认 TUI 文案为简体中文;可在主面板按 `L` 切换为 English。
278
280
 
279
281
  ## 本地开发
280
282
 
@@ -297,9 +299,9 @@ npm pack --dry-run
297
299
 
298
300
  请通过 [GitHub Issues](https://github.com/Qihuanxishini/pi-model-manager/issues) 提交可复现的问题。报告配置问题时,请删除 API key、认证头、代理凭据和私有 endpoint。
299
301
 
300
- ## 致谢
302
+ ## 友情链接
301
303
 
302
- 感谢 [LINUX DO](https://linux.do/) 社区的讨论、分享和反馈。
304
+ * [Linux DO](https://linux.do)
303
305
 
304
306
  ## 许可证
305
307
 
package/atomic-write.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  import { randomUUID } from "node:crypto";
8
8
  import { mkdir, rename, unlink, writeFile } from "node:fs/promises";
9
9
  import { dirname } from "node:path";
10
+ import { t } from "./i18n.ts";
10
11
 
11
12
  const REPLACE_RETRY_DELAYS_MS = [25, 50, 100, 200, 400, 800] as const;
12
13
  const TRANSIENT_REPLACE_ERROR_CODES = new Set(["EACCES", "EPERM", "EBUSY", "ENOTEMPTY"]);
@@ -66,7 +67,8 @@ export async function atomicWriteText(targetPath: string, content: string): Prom
66
67
  await renameWithRetry(tempPath, targetPath);
67
68
  } catch (error) {
68
69
  if (!tempHasCompleteContent) await removeTempFile(tempPath);
69
- const recoveryNote = tempHasCompleteContent ? `;完整内容已保留在临时文件:${tempPath}` : "";
70
- throw new Error(`写入 ${targetPath} 失败${recoveryNote}:${formatError(error)}`);
70
+ throw new Error(tempHasCompleteContent
71
+ ? t("写入 {targetPath} 失败;完整内容已保留在临时文件:{tempPath}:{error}", { targetPath, tempPath, error: formatError(error) })
72
+ : t("写入 {targetPath} 失败:{error}", { targetPath, error: formatError(error) }));
71
73
  }
72
74
  }
package/common.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // 通用小工具:JSON 解析、字符串处理、错误格式化、克隆。
2
2
  // 与 pi-model-add/common.ts 等价;后续 step 不再依赖旧插件。
3
3
 
4
+ import { t } from "./i18n.ts";
4
5
  export function isObjectRecord(value: unknown): value is Record<string, unknown> {
5
6
  return value !== null && typeof value === "object" && !Array.isArray(value);
6
7
  }
@@ -30,10 +31,10 @@ export function hasStringRecordEntries(record: Record<string, string> | undefine
30
31
 
31
32
  export function parseStringRecordJson(source: string, label: string): Record<string, string> {
32
33
  const parsed = JSON.parse(stripJsonNoise(source));
33
- if (!isObjectRecord(parsed)) throw new Error(`${label} JSON 必须是对象`);
34
+ if (!isObjectRecord(parsed)) throw new Error(t("{label} JSON 必须是对象", { label }));
34
35
  const record: Record<string, string> = {};
35
36
  for (const [key, value] of Object.entries(parsed)) {
36
- if (typeof value !== "string") throw new Error(`${label} ${key} 的值必须是字符串`);
37
+ if (typeof value !== "string") throw new Error(t("{label} {key} 的值必须是字符串", { label, key }));
37
38
  const trimmedKey = key.trim();
38
39
  if (trimmedKey) record[trimmedKey] = value;
39
40
  }
@@ -4,6 +4,7 @@ import { hostname } from "node:os";
4
4
  import { open, mkdir, readFile, stat, unlink, type FileHandle } from "node:fs/promises";
5
5
  import { join } from "node:path";
6
6
  import { randomUUID } from "node:crypto";
7
+ import { t } from "./i18n.ts";
7
8
  import { STATE_DIR } from "./state-metadata-store.ts";
8
9
 
9
10
  interface ConfigurationLockRecord {
@@ -108,7 +109,7 @@ async function acquireConfigurationLock(): Promise<HeldConfigurationLock> {
108
109
  await sleep(LOCK_RETRY_DELAYS_MS[attempt]!);
109
110
  }
110
111
  }
111
- throw new Error(`另一个 Pi 进程正在保存模型配置;无法在限定时间内获取锁:${LOCK_PATH}`);
112
+ throw new Error(t("另一个 Pi 进程正在保存模型配置;无法在限定时间内获取锁:{path}", { path: LOCK_PATH }));
112
113
  }
113
114
 
114
115
  async function releaseConfigurationLock(lock: HeldConfigurationLock): Promise<void> {
@@ -121,7 +122,7 @@ async function releaseConfigurationLock(lock: HeldConfigurationLock): Promise<vo
121
122
  throw error;
122
123
  }
123
124
  if (current?.token !== lock.record.token) {
124
- throw new Error(`配置锁所有权在释放前发生变化,已保留锁文件供检查:${LOCK_PATH}`);
125
+ throw new Error(t("配置锁所有权在释放前发生变化,已保留锁文件供检查:{path}", { path: LOCK_PATH }));
125
126
  }
126
127
  await unlink(LOCK_PATH);
127
128
  }
@@ -11,6 +11,7 @@ import { atomicWriteText } from "./atomic-write.ts";
11
11
  import { formatUnknownError, isObjectRecord, stringifyJson } from "./common.ts";
12
12
  import { withConfigurationLock } from "./configuration-lock.ts";
13
13
  import { hashTextContent, readStableTextFileSnapshot } from "./file-snapshot.ts";
14
+ import { t } from "./i18n.ts";
14
15
  import {
15
16
  MODELS_JSON_PATH,
16
17
  markManagedProvidersInDoc,
@@ -74,18 +75,18 @@ function createTransition(oldSource: string | undefined, targetSource: string):
74
75
  }
75
76
 
76
77
  function readTransition(raw: unknown, path: string): FileTransition {
77
- if (!isObjectRecord(raw)) throw new Error(`${path} 必须是对象`);
78
+ if (!isObjectRecord(raw)) throw new Error(t("{path} 必须是对象", { path }));
78
79
  const oldSource = raw.oldSource;
79
80
  const oldHash = raw.oldHash;
80
81
  const targetSource = raw.targetSource;
81
82
  const targetHash = raw.targetHash;
82
- if (oldSource !== null && typeof oldSource !== "string") throw new Error(`${path}.oldSource 必须是字符串或 null`);
83
+ if (oldSource !== null && typeof oldSource !== "string") throw new Error(t("{path}.oldSource 必须是字符串或 null", { path }));
83
84
  if (typeof oldHash !== "string" || typeof targetSource !== "string" || typeof targetHash !== "string") {
84
- throw new Error(`${path} 缺少有效内容或签名`);
85
+ throw new Error(t("{path} 缺少有效内容或签名", { path }));
85
86
  }
86
87
  const normalizedOldSource = oldSource === null ? undefined : oldSource;
87
88
  if (hashTextContent(normalizedOldSource) !== oldHash || hashTextContent(targetSource) !== targetHash) {
88
- throw new Error(`${path} 内容签名校验失败`);
89
+ throw new Error(t("{path} 内容签名校验失败", { path }));
89
90
  }
90
91
  return { oldSource, oldHash, targetSource, targetHash };
91
92
  }
@@ -93,7 +94,7 @@ function readTransition(raw: unknown, path: string): FileTransition {
93
94
  function parseTransactionJournal(source: string): ConfigurationTransactionJournal {
94
95
  const raw = JSON.parse(source);
95
96
  if (!isObjectRecord(raw) || raw.version !== 1 || typeof raw.createdAt !== "string") {
96
- throw new Error("事务意图文件格式无效");
97
+ throw new Error(t("事务意图文件格式无效"));
97
98
  }
98
99
  return {
99
100
  version: 1,
@@ -115,14 +116,14 @@ async function classifyTransition(path: string, transition: FileTransition): Pro
115
116
  const current = await readStableTextFileSnapshot(path);
116
117
  if (current.contentHash === transition.targetHash) return "target";
117
118
  if (current.contentHash === transition.oldHash) return "old";
118
- throw new Error(`${path} 的当前内容既不是事务旧版本,也不是目标版本;已保留 ${TRANSACTION_PATH},不会覆盖外部修改。`);
119
+ throw new Error(t("{path} 的当前内容既不是事务旧版本,也不是目标版本;已保留 {transactionPath},不会覆盖外部修改。", { path, transactionPath: TRANSACTION_PATH }));
119
120
  }
120
121
 
121
122
  async function finishTransition(path: string, transition: FileTransition, status: "old" | "target"): Promise<void> {
122
123
  if (status === "old") await atomicWriteText(path, transition.targetSource);
123
124
  const completed = await readStableTextFileSnapshot(path);
124
125
  if (completed.contentHash !== transition.targetHash) {
125
- throw new Error(`${path} 写入后内容签名不匹配;已保留 ${TRANSACTION_PATH} 供恢复。`);
126
+ throw new Error(t("{path} 写入后内容签名不匹配;已保留 {transactionPath} 供恢复。", { path, transactionPath: TRANSACTION_PATH }));
126
127
  }
127
128
  }
128
129
 
@@ -133,7 +134,7 @@ async function recoverPendingConfigurationTransactionInsideLock(): Promise<boole
133
134
  try {
134
135
  journal = parseTransactionJournal(journalSnapshot.source);
135
136
  } catch (error) {
136
- throw new Error(`无法解析未完成事务 ${TRANSACTION_PATH}:${formatUnknownError(error)}`);
137
+ throw new Error(t("无法解析未完成事务 {transactionPath}:{error}", { transactionPath: TRANSACTION_PATH, error: formatUnknownError(error) }));
137
138
  }
138
139
 
139
140
  // 先同时判定两端,任何一端存在外部修改时都不继续写另一端。
@@ -155,7 +156,7 @@ export async function recoverPendingConfigurationTransaction(): Promise<boolean>
155
156
  async function assertSnapshotStillCurrent(path: string, expectedHash: string): Promise<void> {
156
157
  const current = await readStableTextFileSnapshot(path);
157
158
  if (current.contentHash !== expectedHash) {
158
- throw new Error(`${path} 已被其它进程或编辑器修改;已取消本次保存,请重新打开 /model-manager 后重试。`);
159
+ throw new Error(t("{path} 已被其它进程或编辑器修改;已取消本次保存,请重新打开 /model-manager 后重试。", { path }));
159
160
  }
160
161
  }
161
162
 
@@ -186,7 +187,7 @@ async function writeConfigurationTransaction(
186
187
  await finishTransition(STATE_PATH, journal.metadataState, metadataStatus);
187
188
  await removeTransactionJournal();
188
189
  } catch (error) {
189
- throw new Error(`配置事务未完成:${formatUnknownError(error)}。下次启动或保存会尝试恢复。`);
190
+ throw new Error(t("配置事务未完成:{error}。下次启动或保存会尝试恢复。", { error: formatUnknownError(error) }));
190
191
  }
191
192
  }
192
193
 
@@ -232,12 +233,12 @@ async function refreshRegistryAfterPersistence(
232
233
  document = await withConfigurationLock(persist);
233
234
  invalidateStateCache();
234
235
  } catch (error) {
235
- throw new Error(`models.json/state.json 未完整保存:${formatUnknownError(error)}`);
236
+ throw new Error(t("models.json/state.json 未完整保存:{error}", { error: formatUnknownError(error) }));
236
237
  }
237
238
  try {
238
239
  await ctx.modelRegistry.refresh();
239
240
  } catch (error) {
240
- throw new Error(`models.json/state.json 已写入,但当前会话 registry 重载失败:${formatUnknownError(error)}。可执行 /reload 重试。`);
241
+ throw new Error(t("models.json/state.json 已写入,但当前会话 registry 重载失败:{error}。可执行 /reload 重试。", { error: formatUnknownError(error) }));
241
242
  }
242
243
  return document;
243
244
  }
package/file-snapshot.ts CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { createHash } from "node:crypto";
4
4
  import { readFile, stat } from "node:fs/promises";
5
+ import { t } from "./i18n.ts";
5
6
 
6
7
  export interface FileSignature {
7
8
  exists: boolean;
@@ -72,5 +73,5 @@ export async function readStableTextFileSnapshot(path: string): Promise<StableTe
72
73
  return { source, signature: after, contentHash: hashTextContent(source) };
73
74
  }
74
75
  }
75
- throw new Error(`${path} 在读取期间持续变化;请停止其它写入后重试。`);
76
+ throw new Error(t("{path} 在读取期间持续变化;请停止其它写入后重试。", { path }));
76
77
  }
@@ -4,6 +4,7 @@
4
4
 
5
5
  import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
6
6
  import { persistManagedConfiguration } from "./configuration-persistence.ts";
7
+ import { t } from "./i18n.ts";
7
8
  import { registerAllFromState } from "./provider-registrar.ts";
8
9
  import { deleteRequestHeaderProfileFromDocument, upsertRequestHeaderProfileInDocument } from "./state-document.ts";
9
10
  import type { RequestHeaderProfileDraft, StateDocument, StoredProvider } from "./types.ts";
@@ -32,7 +33,7 @@ function notifyHeaderProfileRefresh(
32
33
  ctx.ui.notify(successMessage, "info");
33
34
  return;
34
35
  }
35
- ctx.ui.notify(`${successMessage},但以下接入未能刷新,已保留上一版 runtime:\n- ${warnings.join("\n- ")}`, "warning");
36
+ ctx.ui.notify(t("{successMessage},但以下接入未能刷新,已保留上一版 runtime:\n- {warnings}", { successMessage, warnings: warnings.join("\n- ") }), "warning");
36
37
  }
37
38
 
38
39
  export async function saveRequestHeaderProfileConfiguration(
@@ -49,7 +50,7 @@ export async function saveRequestHeaderProfileConfiguration(
49
50
  removedProviderIds: [],
50
51
  }));
51
52
  const warnings = await registerAllFromState(pi, nextState);
52
- notifyHeaderProfileRefresh(ctx, `已保存请求头 ${draft.profileId.trim()}`, warnings);
53
+ notifyHeaderProfileRefresh(ctx, t("已保存请求头 {profileId}", { profileId: draft.profileId.trim() }), warnings);
53
54
  }
54
55
 
55
56
  export async function deleteRequestHeaderProfileConfiguration(
@@ -64,5 +65,5 @@ export async function deleteRequestHeaderProfileConfiguration(
64
65
  removedProviderIds: [],
65
66
  }));
66
67
  const warnings = await registerAllFromState(pi, nextState);
67
- notifyHeaderProfileRefresh(ctx, `已删除请求头 ${profileId}`, warnings);
68
+ notifyHeaderProfileRefresh(ctx, t("已删除请求头 {profileId}", { profileId }), warnings);
68
69
  }