pi-extensions-i18n 0.3.0 → 0.4.0

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
@@ -11,7 +11,7 @@ Independent Pi extensions still need the same operational pieces: a portable con
11
11
  - `zh-CN`, `en-US`, and `auto` locale preferences.
12
12
  - Persistent setting at `~/.pi/agent/extensions/pi-extensions-i18n/config.json`.
13
13
  - `PI_EXTENSIONS_LOCALE` environment-variable override.
14
- - `/pi-language` interactive command, plus `/pi-language en-US` direct selection.
14
+ - `/config:language` interactive command, plus `/config:language en-US` direct selection.
15
15
  - Catalog loading and validation requiring both language entries for every message key.
16
16
  - Translator interpolation for user-facing UI, command descriptions, and agent prompts.
17
17
 
@@ -21,7 +21,7 @@ Independent Pi extensions still need the same operational pieces: a portable con
21
21
  pi install npm:pi-extensions-i18n
22
22
  ```
23
23
 
24
- Feature packages such as `pi-distill` and `pi-tool-supervisor` use it as a shared dependency. Install it explicitly when you want the locale command by itself.
24
+ Feature packages use it as a shared dependency and load its extension entry automatically, so installing a feature package is enough to provide the locale command. Install this package directly only when you want the locale command without another feature package.
25
25
 
26
26
  Reload Pi after installation:
27
27
 
@@ -46,7 +46,7 @@ PI_EXTENSIONS_LOCALE=en-US pi
46
46
  ```
47
47
 
48
48
  ```text
49
- /pi-language en-US
49
+ /config:language en-US
50
50
  ```
51
51
 
52
52
  ## Extension author API
@@ -83,7 +83,7 @@ Invalid catalogs fail during loading, which makes missing translations visible i
83
83
  ## Requirements
84
84
 
85
85
  - Node.js 22 or newer.
86
- - Pi's extension runtime when using the `/pi-language` command.
86
+ - Pi's extension runtime when using the `/config:language` command. `/pi-language` remains available as a compatibility alias.
87
87
 
88
88
  ## License
89
89
 
package/README.zh-CN.md CHANGED
@@ -11,7 +11,7 @@ Pi 扩展公共国际化运行时。它提供基于 catalog 的小型 API,支
11
11
  - 支持 `zh-CN`、`en-US` 和 `auto` 语言偏好。
12
12
  - 将设置持久化到 `~/.pi/agent/extensions/pi-extensions-i18n/config.json`。
13
13
  - 支持 `PI_EXTENSIONS_LOCALE` 环境变量覆盖。
14
- - 提供 `/pi-language` 交互式命令,也支持 `/pi-language en-US` 直接设置。
14
+ - 提供 `/config:language` 交互式命令,也支持 `/config:language en-US` 直接设置。
15
15
  - 加载并校验 catalog,要求每个消息 key 同时提供两种语言。
16
16
  - 为 UI、命令描述和 Agent prompt 提供用户文案插值。
17
17
 
@@ -21,7 +21,7 @@ Pi 扩展公共国际化运行时。它提供基于 catalog 的小型 API,支
21
21
  pi install npm:pi-extensions-i18n
22
22
  ```
23
23
 
24
- `pi-distill`、`pi-tool-supervisor` 等功能包会把它作为公共依赖使用。如果只需要语言命令,也可以单独安装本包。
24
+ 各功能包会自动安装并加载这个公共依赖,因此安装任意使用它的功能包即可使用语言命令。只有不安装其他功能包、想单独使用语言命令时,才需要直接安装本包。
25
25
 
26
26
  安装后重新加载 Pi:
27
27
 
@@ -46,7 +46,7 @@ PI_EXTENSIONS_LOCALE=en-US pi
46
46
  ```
47
47
 
48
48
  ```text
49
- /pi-language en-US
49
+ /config:language en-US
50
50
  ```
51
51
 
52
52
  ## 扩展作者 API
@@ -83,7 +83,7 @@ catalog 条目必须同时包含两种语言:
83
83
  ## 要求
84
84
 
85
85
  - Node.js 22 或更高版本。
86
- - 使用 `/pi-language` 命令时需要 Pi 扩展运行时。
86
+ - 使用 `/config:language` 命令时需要 Pi 扩展运行时;`/pi-language` 仍作为兼容别名保留。
87
87
 
88
88
  ## 许可证
89
89
 
package/SKILL.md ADDED
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: configure-pi-extensions-i18n
3
+ description: "配置 Pi 扩展共享语言并排查 locale 优先级、持久化设置和 catalog。Use when changing zh-CN/en-US/auto language behavior."
4
+ ---
5
+
6
+ # 配置 pi-extensions-i18n
7
+
8
+ ## 修改语言
9
+
10
+ 优先使用 `/config:language zh-CN|en-US|auto`;不带参数时使用交互界面。设置持久化到实际 Pi agent 目录的 `extensions/pi-extensions-i18n/config.json`。
11
+
12
+ 语言优先级:
13
+
14
+ 1. `PI_EXTENSIONS_LOCALE`;
15
+ 2. 持久化配置;
16
+ 3. 默认 `zh-CN`。
17
+
18
+ `auto` 根据 `LC_ALL`、`LC_MESSAGES`、`LANG` 选择中文或英文。`/pi-language` 只是兼容别名。
19
+
20
+ ## 验证
21
+
22
+ 执行语言命令后观察下一个使用共享 i18n 的扩展文案。若环境变量存在,它会覆盖持久化值;必须先报告这个覆盖关系,不能反复改 JSON。修改 catalog 时,每个 key 必须同时有 `zh-CN` 与 `en-US`,缺失翻译应作为加载错误修复,不能静默 fallback。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-extensions-i18n",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Shared i18n catalog loader & translator for pi extensions",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -13,6 +13,7 @@
13
13
  "locales",
14
14
  "README.md",
15
15
  "README.zh-CN.md",
16
+ "SKILL.md",
16
17
  "tsconfig.json"
17
18
  ],
18
19
  "scripts": {
@@ -24,6 +25,9 @@
24
25
  "pi": {
25
26
  "extensions": [
26
27
  "./index.ts"
28
+ ],
29
+ "skills": [
30
+ "./SKILL.md"
27
31
  ]
28
32
  },
29
33
  "engines": {
package/src/index.ts CHANGED
@@ -192,7 +192,7 @@ const commandMessages = loadCatalog(
192
192
 
193
193
  function registerLocaleCommand(pi: ExtensionAPI): void {
194
194
  const i18n = createTranslator(commandMessages);
195
- pi.registerCommand("pi-language", {
195
+ const command = {
196
196
  description: i18n.t("description"),
197
197
  handler: async (args: string, ctx: ExtensionCommandContext) => {
198
198
  if (!ctx.hasUI) {
@@ -246,7 +246,10 @@ function registerLocaleCommand(pi: ExtensionAPI): void {
246
246
  ctx.ui.notify(i18n.t("failed", { error: String(error) }), "error");
247
247
  }
248
248
  },
249
- });
249
+ };
250
+ for (const name of ["config:language", "pi-language"] as const) {
251
+ pi.registerCommand(name, command);
252
+ }
250
253
  }
251
254
 
252
255
  export default function piI18n(pi: ExtensionAPI): void {