@aiti-ai/aiti-configs 0.1.9 → 0.1.11

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
@@ -1,38 +1,29 @@
1
1
  # @aiti-ai/aiti-configs
2
2
 
3
- > 配置的安全网 —— AI/人改配置、改扩展改坏了,有锅可回、有 diff 可看、一键恢复;系统崩了,命令行哨兵不依赖出问题系统本身兜底恢复
3
+ > A safety net for configuration — when AI/humans or extension changes break the config, there is a commit to revert, a diff to inspect, one-click restore; if the system crashes, a command-line watchdog recovers without relying on the broken system itself
4
4
 
5
- ## 来源 · Origin
5
+ English · [简体中文](./README.zh-CN.md)
6
6
 
7
- 本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/pi-web) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
7
+ ## About aiti
8
8
 
9
- This package is part of the **aiti** ecosystem — a personal AI development workbench powered by [pi](https://pi.dev): **aiti-agent** (a self-hosted web workbench built on the open-source [pi-web](https://github.com/aiti-ai/pi-web)) plus debug injection into mainstream dev tools (aiti-devtools) and a rich extension system.
9
+ This package is part of the **aiti** ecosystem — a personal AI development workbench powered by [pi](https://pi.dev): **aiti-agent** (a self-hosted web workbench built on the open-source [pi-web](https://github.com/aiti-ai/aiti-ai)) plus debug injection into mainstream dev tools (aiti-devtools) and a rich extension system.
10
10
 
11
- - 工作台 / workbench: <https://github.com/aiti-ai/pi-web>
12
- - 生态仓库 / monorepo: <https://github.com/aiti-ai/aiti-ai>
13
- - 官网 / site: <https://aiti.pw>
11
+ - Workbench & monorepo: <https://github.com/aiti-ai/aiti-ai>
12
+ - Site: <https://aiti.pw>
14
13
 
15
- ## 功能定位(中文)
14
+ Category: AI capabilities · Tags: `config` · `versioning` · `git` · `watchdog` · `restore` · `safety`
16
15
 
17
- 配置的安全网 —— AI/人改配置、改扩展改坏了,有锅可回、有 diff 可看、一键恢复;系统崩了,命令行哨兵不依赖出问题系统本身兜底恢复
16
+ ## Install
18
17
 
19
- AI 能力 · tags: `config` · `versioning` · `git` · `watchdog` · `restore` · `safety`
18
+ Bundled with **aiti-agent** (`@aiti-ai/pi-web`) — enable it from the in-app extension manager (ExtMan / App Center).
20
19
 
21
- ## Positioning (English)
20
+ Manual install: place this package at `~/.pi/web/extensions/aiti-configs/` and reload pi-web.
22
21
 
23
- A safety net for configuration — when AI/humans or extension changes break the config, there is a commit to revert, a diff to inspect, one-click restore; if the system crashes, a command-line watchdog recovers without relying on the broken system itself
22
+ ## Documentation
24
23
 
25
- ## 安装 / 部署
26
-
27
- ```bash
28
- # 部署到 ~/.pi/web/extensions/aiti-configs/ 后 reload
29
- ```
30
-
31
- ## 文档 · Documentation
32
-
33
- - 中文完整文档(aiti-docs): <https://aiti.pw/extensions/aiti-configs.html>
34
- - English docs: <https://aiti.pw/en/extensions/aiti-configs.html>
35
- - 扩展注册表 / registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
24
+ - Documentation (English): <https://aiti.pw/en/extensions/aiti-configs.html>
25
+ - 文档(中文): <https://aiti.pw/extensions/aiti-configs.html>
26
+ - Extension registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
36
27
 
37
28
  ## License
38
29
 
@@ -0,0 +1,30 @@
1
+ # @aiti-ai/aiti-configs
2
+
3
+ > 配置的安全网 —— AI/人改配置、改扩展改坏了,有锅可回、有 diff 可看、一键恢复;系统崩了,命令行哨兵不依赖出问题系统本身兜底恢复
4
+
5
+ [English](./README.md) · 简体中文
6
+
7
+ ## 关于 aiti
8
+
9
+ 本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/aiti-ai) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
10
+
11
+ - 工作台 / 生态仓库(aiti-agent,基于 pi-web): <https://github.com/aiti-ai/aiti-ai>
12
+ - 官网: <https://aiti.pw>
13
+
14
+ 分类: AI 能力 · tags: `config` · `versioning` · `git` · `watchdog` · `restore` · `safety`
15
+
16
+ ## 安装
17
+
18
+ 随 **aiti-agent**(`@aiti-ai/pi-web`)捆绑发行——在工作台内的扩展管理器(ExtMan / 应用中心)启用即可。
19
+
20
+ 手动安装:把本包放到 `~/.pi/web/extensions/aiti-configs/` 后 reload。
21
+
22
+ ## 文档
23
+
24
+ - 中文文档: <https://aiti.pw/extensions/aiti-configs.html>
25
+ - Documentation (English): <https://aiti.pw/en/extensions/aiti-configs.html>
26
+ - 扩展注册表: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
27
+
28
+ ## 许可证
29
+
30
+ MIT
@@ -308,7 +308,7 @@ export default function register(ctx) {
308
308
  }
309
309
 
310
310
  // 渲染注册
311
- ctx.registerItems("toolbar", [{ id: "aiti-configs-open", render: ConfigsButton, meta: { label: "配置" } }]);
311
+ ctx.registerItems("toolbar", [{ id: "aiti-configs-open", render: ConfigsButton, meta: { label: "i18n:it.open.label" } }]);
312
312
  ctx.registerItems("pages", [{ id: "aiti-configs-dialog", render: ConfigsDialog }]);
313
313
  try { console.log("[aiti-configs] client 安全盾已挂载(toolbar 触发 → pages 渲染,状态/历史/自检/配置)"); } catch (e) {}
314
314
  }
@@ -2,11 +2,11 @@
2
2
  * aiti-configs · 安全盾 UI(🛡)—— JSX 版(自手写 h() 版迁移,功能一比一)。
3
3
  *
4
4
  * 设计:docs/aiti-configs-extension-plan.md §4.2
5
- * 功能:状态(变更清单 + 提交)/ 历史(版本列表 + diff 预览 + 恢复)/ 自检报告 / 配置查看编辑
5
+ * Features: status (change list + commit) / history (version list + diff preview + restore action) / self-check report / config view & edit
6
6
  * 架构:toolbar 🛡 按钮 → 独立置顶 dialog(pages slot,不随 session 切换关闭)
7
7
  */
8
8
  import { useState, useEffect, useCallback } from "react";
9
- import { apiUrl } from "./host-shim";
9
+ import { apiUrl, t } from "./host-shim";
10
10
  import { uiConfirm, uiPrompt } from "../../../_shared/ui-dialogs";
11
11
 
12
12
  declare global {
@@ -80,7 +80,7 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
80
80
  const r = await api(ep);
81
81
  setData(await r.json());
82
82
  if (t === "config") { try { setEncStatus(await (await api("/key")).json()); } catch {} }
83
- } catch (e: any) { setMsg("加载失败:" + (e.message || e)); }
83
+ } catch (e: any) { setMsg(t("加载失败:") + (e.message || e)); }
84
84
  setBusy(false);
85
85
  }, [open]);
86
86
 
@@ -93,8 +93,8 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
93
93
  try {
94
94
  const r = await api("/diff", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ version: "HEAD", path }) });
95
95
  const d = await r.json();
96
- setFileDiff({ path, diff: d.diff || d.error || "(无差异)" });
97
- } catch (e: any) { setFileDiff({ path, diff: "加载失败:" + (e.message || e) }); }
96
+ setFileDiff({ path, diff: d.diff || d.error || t("(无差异)") });
97
+ } catch (e: any) { setFileDiff({ path, diff: t("加载失败:") + (e.message || e) }); }
98
98
  setBusy(false);
99
99
  };
100
100
 
@@ -103,20 +103,20 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
103
103
  try {
104
104
  const r = await api("/commit", { method: "POST", ...jsonBody({}) });
105
105
  const d = await r.json();
106
- setMsg(d.noop ? "无可提交变更" : "已提交 " + d.hash + " · " + String(d.message || "").split("\n")[0]);
106
+ setMsg(d.noop ? t("无可提交变更") : t("已提交 ") + d.hash + " · " + String(d.message || "").split("\n")[0]);
107
107
  load("status");
108
- } catch (e: any) { setMsg("提交失败:" + (e.message || e)); }
108
+ } catch (e: any) { setMsg(t("提交失败:") + (e.message || e)); }
109
109
  setBusy(false);
110
110
  };
111
111
  const doRestore = async (version: string) => {
112
- if (!(await uiConfirm({ message: "恢复至 " + version + "?恢复协议五步走:先固化现场+打 tag,可回退,不丢数据。", danger: true }))) return;
112
+ if (!(await uiConfirm({ message: t("恢复至 ") + version + "?恢复协议五步走:先固化现场+打 tag,可回退,不丢数据。", danger: true }))) return;
113
113
  setBusy(true); setMsg("");
114
114
  try {
115
115
  const r = await api("/restore", { method: "POST", ...jsonBody({ version, confirm: "确认恢复" }) });
116
116
  const d = await r.json();
117
- setMsg(d.ok ? "恢复完成(tag=" + d.tag + ")" : "❌ " + (d.error || d.hint || JSON.stringify(d.steps || "")));
117
+ setMsg(d.ok ? t("恢复完成(tag=") + d.tag + ")" : "❌ " + (d.error || d.hint || JSON.stringify(d.steps || "")));
118
118
  if (d.ok) { load("log"); setDiff(null); }
119
- } catch (e: any) { setMsg("恢复失败:" + (e.message || e)); }
119
+ } catch (e: any) { setMsg(t("恢复失败:") + (e.message || e)); }
120
120
  setBusy(false);
121
121
  };
122
122
  const showDiff = async (version: string) => {
@@ -129,35 +129,35 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
129
129
  try {
130
130
  const r = await api("/config", { method: "POST", ...jsonBody({ set: setObj }) });
131
131
  const d = await r.json();
132
- setMsg(d.ok ? "已更新配置" : "失败:" + d.error);
132
+ setMsg(d.ok ? t("已更新配置") : t("失败:") + d.error);
133
133
  if (d.ok) load("config");
134
- } catch (e: any) { setMsg("保存失败:" + (e.message || e)); }
134
+ } catch (e: any) { setMsg(t("保存失败:") + (e.message || e)); }
135
135
  setBusy(false);
136
136
  };
137
137
  const loadTags = async () => {
138
138
  try { const r = await api("/tag"); setTagList(await r.json()); } catch {}
139
139
  };
140
140
  const doTag = async (hash: string) => {
141
- const name = await uiPrompt({ message: "给此版本打 tag(标记'好用版本',如 good-v1):", value: "good-v" + hash.slice(0, 4) });
141
+ const name = await uiPrompt({ message: t("给此版本打 tag(标记'好用版本',如 good-v1):"), value: "good-v" + hash.slice(0, 4) });
142
142
  if (!name) return;
143
143
  setBusy(true); setMsg("");
144
144
  try {
145
145
  const r = await api("/tag", { method: "POST", ...jsonBody({ name: name.trim() }) });
146
146
  const d = await r.json();
147
- setMsg(d.ok ? "已打 tag: " + d.name : "失败:" + (d.error || ""));
147
+ setMsg(d.ok ? t("已打 tag: ") + d.name : t("失败:") + (d.error || ""));
148
148
  load("log"); loadTags();
149
- } catch (e: any) { setMsg("打 tag 失败:" + (e.message || e)); }
149
+ } catch (e: any) { setMsg(t("打 tag 失败:") + (e.message || e)); }
150
150
  setBusy(false);
151
151
  };
152
152
  const doDelTag = async (name: string) => {
153
- if (!(await uiConfirm({ message: "删除 tag: " + name + "?", danger: true }))) return;
153
+ if (!(await uiConfirm({ message: t("删除 tag: ") + name + "?", danger: true }))) return;
154
154
  setBusy(true); setMsg("");
155
155
  try {
156
156
  const r = await api("/tag?name=" + encodeURIComponent(name), { method: "DELETE" });
157
157
  const d = await r.json();
158
- setMsg(d.ok ? "已删 tag: " + name : "失败:" + (d.error || ""));
158
+ setMsg(d.ok ? t("已删 tag: ") + name : t("失败:") + (d.error || ""));
159
159
  loadTags();
160
- } catch (e: any) { setMsg("删 tag 失败:" + (e.message || e)); }
160
+ } catch (e: any) { setMsg(t("删 tag 失败:") + (e.message || e)); }
161
161
  setBusy(false);
162
162
  };
163
163
  const doSnapshot = async () => {
@@ -165,9 +165,9 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
165
165
  try {
166
166
  const r = await api("/snapshot", { method: "POST", ...jsonBody({}) });
167
167
  const d = await r.json();
168
- setMsg(d.noop ? "已是最新(无变更可固化)" : "已固化现场:" + d.hash);
168
+ setMsg(d.noop ? t("已是最新(无变更可固化)") : t("已固化现场:") + d.hash);
169
169
  load("status"); load("log");
170
- } catch (e: any) { setMsg("快照失败:" + (e.message || e)); }
170
+ } catch (e: any) { setMsg(t("快照失败:") + (e.message || e)); }
171
171
  setBusy(false);
172
172
  };
173
173
 
@@ -178,23 +178,23 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
178
178
  <div>
179
179
  {rs && rs.url ? (
180
180
  <div style={{ fontSize: 12, marginBottom: 8, padding: "6px 8px", borderRadius: 8, background: "#eff6ff", border: "1px solid #bfdbfe", color: "#1d4ed8" }}>
181
- {"远端同步:" + (rs.push ? "启用" : "停用") + " · " + rs.url + (rs.autoPull ? " · pull --rebase" : "") + " · branch=" + (rs.branch || "main")}
181
+ {t("远端同步:") + (rs.push ? t("启用") : t("停用")) + " · " + rs.url + (rs.autoPull ? " · pull --rebase" : "") + " · branch=" + (rs.branch || "main")}
182
182
  </div>
183
183
  ) : null}
184
184
  <div style={{ display: "flex", gap: 8, marginBottom: 8 }}>
185
185
  <button style={{ ...C.btn, ...C.btnPrimary, display: "inline-flex", alignItems: "center", gap: 5 }} onClick={doCommit}>
186
- <Ic size={13} paths={ICONS.package} />提交变更
186
+ <Ic size={13} paths={ICONS.package} />{t("提交变更")}
187
187
  </button>
188
- <button style={C.btn} onClick={() => load("status")}>↻ 刷新</button>
188
+ <button style={C.btn} onClick={() => load("status")}>{t("↻ 刷新")}</button>
189
189
  </div>
190
190
  {d.clean === true ? (
191
- <div style={{ color: "#16a34a", fontWeight: 600 }}>工作区干净(无可提交变更)</div>
191
+ <div style={{ color: "#16a34a", fontWeight: 600 }}>{t("工作区干净(无可提交变更)")}</div>
192
192
  ) : (d.changed && d.changed.length ? (
193
193
  <div>
194
- <div style={{ fontWeight: 600, marginBottom: 6 }}>{"待提交 " + d.changed.length + " 个文件:"}</div>
194
+ <div style={{ fontWeight: 600, marginBottom: 6 }}>{t("待提交 ") + d.changed.length + t(" 个文件:")}</div>
195
195
  {d.changed.map((c: any, i: number) => (
196
196
  <div key={i} style={{ ...C.row, background: fileDiff?.path === c.path ? "var(--bg-subtle,#f5f5f5)" : undefined }}
197
- onClick={() => showFileDiff(c.path)} title="点击查看该文件未提交 diff">
197
+ onClick={() => showFileDiff(c.path)} title={t("点击查看该文件未提交 diff")}>
198
198
  <span style={{ color: c.status === "D" ? "#dc2626" : c.status === "??" ? "#16a34a" : "#2563eb", fontWeight: 700, marginRight: 6 }}>
199
199
  {c.status === "D" ? "DEL" : c.status === "??" ? "NEW" : "MOD"}
200
200
  </span>
@@ -203,7 +203,7 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
203
203
  ))}
204
204
  {fileDiff ? (
205
205
  <div style={{ marginTop: 8 }}>
206
- <div style={{ fontWeight: 600, marginBottom: 4 }}>{"未提交变更:" + fileDiff.path}</div>
206
+ <div style={{ fontWeight: 600, marginBottom: 4 }}>{t("未提交变更:") + fileDiff.path}</div>
207
207
  <pre style={C.pre}>{String(fileDiff.diff).slice(0, 3000)}</pre>
208
208
  </div>
209
209
  ) : null}
@@ -211,7 +211,7 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
211
211
  ) : null)}
212
212
  {d.skipped && d.skipped.length > 0 ? (
213
213
  <div style={{ marginTop: 8, fontSize: 12, color: "#d97706" }}>
214
- {"拦截 " + d.skipped.length + " 项:" + d.skipped.map((s: any) => s.reason).slice(0, 5).join(";") + (d.skipped.length > 5 ? "…" : "")}
214
+ {t("拦截 ") + d.skipped.length + t(" 项:") + d.skipped.map((s: any) => s.reason).slice(0, 5).join(";") + (d.skipped.length > 5 ? "…" : "")}
215
215
  </div>
216
216
  ) : null}
217
217
  </div>
@@ -227,15 +227,15 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
227
227
  <Ic size={12} paths={ICONS.tag} />tags
228
228
  </button>
229
229
  <button style={{ ...C.btn, padding: "3px 10px", display: "inline-flex", alignItems: "center", gap: 4 }} onClick={doSnapshot}>
230
- <Ic size={12} paths={ICONS.camera} />固化现场
230
+ <Ic size={12} paths={ICONS.camera} />{t("固化现场")}
231
231
  </button>
232
232
  </div>
233
233
  {tagList && tagList.tags && tagList.tags.length > 0 ? (
234
234
  <div style={{ marginBottom: 8 }}>
235
- {tagList.tags.map((t: any) => (
236
- <span key={t.name} style={{ display: "inline-flex", alignItems: "center", gap: 4, margin: "0 6px 4px 0", padding: "2px 8px", borderRadius: 10, background: "#fef3c7", color: "#92400e", fontSize: 11, border: "1px solid #fcd34d" }}>
237
- <Ic size={11} paths={ICONS.tag} />{" "}{t.name}
238
- <button style={{ border: "none", background: "transparent", cursor: "pointer", color: "#92400e", display: "flex" }} onClick={() => doDelTag(t.name)} aria-label="删除 tag">
235
+ {tagList.tags.map((tag: any) => (
236
+ <span key={tag.name} style={{ display: "inline-flex", alignItems: "center", gap: 4, margin: "0 6px 4px 0", padding: "2px 8px", borderRadius: 10, background: "#fef3c7", color: "#92400e", fontSize: 11, border: "1px solid #fcd34d" }}>
237
+ <Ic size={11} paths={ICONS.tag} />{" "}{tag.name}
238
+ <button style={{ border: "none", background: "transparent", cursor: "pointer", color: "#92400e", display: "flex" }} onClick={() => doDelTag(t.name)} aria-label={t("删除 tag")}>
239
239
  <Ic size={10} paths={ICONS.x} />
240
240
  </button>
241
241
  </span>
@@ -247,15 +247,15 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
247
247
  <div>
248
248
  <span style={{ color: "var(--accent,#2563eb)", fontWeight: 700, marginRight: 6 }}>{r.hash}</span>
249
249
  <span style={{ color: "var(--text-subtle,#666)", marginRight: 6 }}>{String(r.date || "").slice(5, 16)}</span>
250
- {(r.tags || []).map((t: string) => (
251
- <span key={t} style={{ marginRight: 4, padding: "1px 6px", borderRadius: 8, background: "#fef3c7", color: "#92400e", fontSize: 10 }}>
252
- <Ic size={10} paths={ICONS.tag} />{t}
250
+ {(r.tags || []).map((tag: string) => (
251
+ <span key={tag} style={{ marginRight: 4, padding: "1px 6px", borderRadius: 8, background: "#fef3c7", color: "#92400e", fontSize: 10 }}>
252
+ <Ic size={10} paths={ICONS.tag} />{tag}
253
253
  </span>
254
254
  ))}
255
255
  <span>{r.subject}</span>
256
256
  </div>
257
257
  <div style={{ marginTop: 4, display: "flex", gap: 6 }}>
258
- <button style={{ ...C.btn, padding: "2px 8px" }} onClick={(e) => { e.stopPropagation(); doRestore(r.hash); }}>↩ 恢复</button>
258
+ <button style={{ ...C.btn, padding: "2px 8px" }} onClick={(e) => { e.stopPropagation(); doRestore(r.hash); }}>↩ {t("恢复")}</button>
259
259
  <button style={{ ...C.btn, padding: "2px 8px", display: "inline-flex", alignItems: "center", gap: 4 }} onClick={(e) => { e.stopPropagation(); doTag(r.hash); }}>
260
260
  <Ic size={11} paths={ICONS.tag} />tag
261
261
  </button>
@@ -264,7 +264,7 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
264
264
  ))}
265
265
  {diff ? (
266
266
  <div style={{ marginTop: 10 }}>
267
- <div style={{ fontWeight: 600, marginBottom: 4 }}>版本 diff 预览</div>
267
+ <div style={{ fontWeight: 600, marginBottom: 4 }}>{t("版本 diff 预览")}</div>
268
268
  <pre style={C.pre}>{String((diff.show || "") + "\n" + (diff.diff || diff.error || "")).slice(0, 3000)}</pre>
269
269
  </div>
270
270
  ) : null}
@@ -277,7 +277,7 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
277
277
  return (
278
278
  <div>
279
279
  <div style={{ fontWeight: 600, marginBottom: 6, color: d.ok ? "#16a34a" : "#dc2626" }}>
280
- {d.ok ? "自检通过" : "自检未通过(" + ((d.bad || []).length) + " 项)"}
280
+ {d.ok ? t("自检通过") : t("自检未通过(") + ((d.bad || []).length) + t(" 项)")}
281
281
  </div>
282
282
  {(d.rows || []).map((r: any, i: number) => (
283
283
  <div key={i} style={C.row}>
@@ -286,7 +286,7 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
286
286
  <span style={{ color: "var(--text-subtle,#666)", marginLeft: 6 }}>{r.detail}</span>
287
287
  </div>
288
288
  ))}
289
- <button style={{ ...C.btn, marginTop: 8 }} onClick={() => load("selfcheck")}>↻ 重新自检</button>
289
+ <button style={{ ...C.btn, marginTop: 8 }} onClick={() => load("selfcheck")}>{t("↻ 重新自检")}</button>
290
290
  </div>
291
291
  );
292
292
  };
@@ -296,9 +296,9 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
296
296
  try {
297
297
  const r = await api("/key", { method: "POST", ...jsonBody({}) });
298
298
  const d = await r.json();
299
- setMsg(d.ok ? "已生成密钥:" + d.keyFile + "(请立即备份!)" : "生成失败:" + d.error);
299
+ setMsg(d.ok ? t("已生成密钥:") + d.keyFile + t("(请立即备份!)") : t("生成失败:") + d.error);
300
300
  load("config");
301
- } catch (e: any) { setMsg("生成失败:" + (e.message || e)); }
301
+ } catch (e: any) { setMsg(t("生成失败:") + (e.message || e)); }
302
302
  setBusy(false);
303
303
  };
304
304
 
@@ -313,15 +313,15 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
313
313
  return (
314
314
  <div>
315
315
  <div style={warn}>
316
- ⚠ 本仓包含 settings/models.json 等含 API Key 的敏感配置——<b>严禁配置为公开仓库(GitHub/Gitee 公开仓、任意公网可见仓)</b>!只能配私有/自建 git 仓;url 内嵌 token 仅存本机,不写日志不展示明文。
316
+ ⚠ {t("本仓包含 settings/models.json 等含 API Key 的敏感配置——")}<b>{t("严禁配置为公开仓库(GitHub/Gitee 公开仓、任意公网可见仓)")}</b>{t("!只能配私有/自建 git 仓;url 内嵌 token 仅存本机,不写日志不展示明文。")}
317
317
  </div>
318
- <div style={{ fontSize: 12, fontWeight: 600, marginBottom: 4, marginTop: 4 }}>远端同步(remote)</div>
318
+ <div style={{ fontSize: 12, fontWeight: 600, marginBottom: 4, marginTop: 4 }}>{t("远端同步(remote)")}</div>
319
319
  <div style={{ display: "flex", gap: 6, marginBottom: 6, alignItems: "center" }}>
320
- <input id="cfg-remote-url" type="text" placeholder="git@github.com:user/private-configs.git 或 https://token@…" defaultValue={rc.url || ""} style={{ flex: 1, ...inp }} />
320
+ <input id="cfg-remote-url" type="text" placeholder={t("git@github.com:user/private-configs.git 或 https://token@…")} defaultValue={rc.url || ""} style={{ flex: 1, ...inp }} />
321
321
  </div>
322
322
  <div style={{ display: "flex", gap: 14, marginBottom: 8, fontSize: 12 }}>
323
- <label style={{ display: "flex", alignItems: "center", gap: 4 }}><input id="cfg-remote-push" type="checkbox" defaultChecked={rc.push === true} />提交后自动 push</label>
324
- <label style={{ display: "flex", alignItems: "center", gap: 4 }}><input id="cfg-remote-pull" type="checkbox" defaultChecked={rc.autoPull !== false} />push 前 pull --rebase</label>
323
+ <label style={{ display: "flex", alignItems: "center", gap: 4 }}><input id="cfg-remote-push" type="checkbox" defaultChecked={rc.push === true} />{t("提交后自动 push")}</label>
324
+ <label style={{ display: "flex", alignItems: "center", gap: 4 }}><input id="cfg-remote-pull" type="checkbox" defaultChecked={rc.autoPull !== false} />push {t("前")} pull --rebase</label>
325
325
  </div>
326
326
  <div style={{ display: "flex", gap: 8, marginBottom: 8 }}>
327
327
  <button style={{ ...C.btn, ...C.btnPrimary }} onClick={() => {
@@ -329,19 +329,19 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
329
329
  const push = g("cfg-remote-push") ? g("cfg-remote-push")!.checked : false;
330
330
  const autoPull = g("cfg-remote-pull") ? g("cfg-remote-pull")!.checked : true;
331
331
  doSaveConfig({ remote: { url, push, autoPull } });
332
- }}>保存 remote</button>
333
- <button style={C.btn} onClick={() => doSaveConfig({ remote: { url: "", push: false, autoPull: true } })}>清除 remote</button>
332
+ }}>{t("保存 remote")}</button>
333
+ <button style={C.btn} onClick={() => doSaveConfig({ remote: { url: "", push: false, autoPull: true } })}>{t("清除 remote")}</button>
334
334
  </div>
335
- <div style={{ fontSize: 12, fontWeight: 600, marginBottom: 4, marginTop: 10 }}>密文 commit(encrypt)</div>
335
+ <div style={{ fontSize: 12, fontWeight: 600, marginBottom: 4, marginTop: 10 }}>{t("密文 commit(encrypt)")}</div>
336
336
  <div style={warn}>
337
- 🔑 开启后仓内为密文,push 到任何仓库(含公开仓)都安全;但密钥文件({en.keyFile || "{repo}/.git/configs-key"})<b>丢失则永远无法恢复</b>!请备份密钥;密钥文件在 .git 下,git 永不跟踪、不入仓。
337
+ 🔑 {t("开启后仓内为密文,push 到任何仓库(含公开仓)都安全;但密钥文件")}({en.keyFile || "{repo}/.git/configs-key"})<b>{t("丢失则永远无法恢复")}</b>{t("!请备份密钥;密钥文件在 .git 下,git 永不跟踪、不入仓。")}
338
338
  </div>
339
339
  <div style={{ display: "flex", gap: 14, marginBottom: 6, fontSize: 12, alignItems: "center" }}>
340
- <label style={{ display: "flex", alignItems: "center", gap: 4 }}><input id="cfg-enc-enabled" type="checkbox" defaultChecked={en.enabled === true} />启用密文 commit</label>
341
- <span style={{ color: es.keyExists === true ? "#16a34a" : "#dc2626" }}>{es.keyExists === true ? "密钥已生成(" + (es.keyFile || "") + ")" : "密钥未生成(先点生成密钥)"}</span>
340
+ <label style={{ display: "flex", alignItems: "center", gap: 4 }}><input id="cfg-enc-enabled" type="checkbox" defaultChecked={en.enabled === true} />{t("启用密文")} commit</label>
341
+ <span style={{ color: es.keyExists === true ? "#16a34a" : "#dc2626" }}>{es.keyExists === true ? t("密钥已生成(") + (es.keyFile || "") + ")" : t("密钥未生成(先点生成密钥)")}</span>
342
342
  </div>
343
343
  <div style={{ display: "flex", gap: 6, marginBottom: 6 }}>
344
- <input id="cfg-enc-patterns" type="text" defaultValue={(en.patterns || ["pi/agent/**"]).join(",")} placeholder="加密文件 glob(逗号分隔,如 pi/agent/**)" style={{ flex: 1, ...inp }} />
344
+ <input id="cfg-enc-patterns" type="text" defaultValue={(en.patterns || ["pi/agent/**"]).join(",")} placeholder={t("加密文件 glob(逗号分隔,如 pi/agent/**)")} style={{ flex: 1, ...inp }} />
345
345
  </div>
346
346
  <div style={{ display: "flex", gap: 8, marginBottom: 8 }}>
347
347
  <button style={{ ...C.btn, ...C.btnPrimary }} onClick={() => {
@@ -349,13 +349,13 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
349
349
  const raw = g("cfg-enc-patterns")?.value;
350
350
  const patterns = raw ? String(raw).split(",").map((s) => s.trim()).filter(Boolean) : ["pi/agent/**"];
351
351
  doSaveConfig({ encrypt: { enabled, algo: en.algo || "aes-256-gcm", keyFile: en.keyFile || "", patterns } });
352
- }}>保存 encrypt</button>
353
- <button style={C.btn} onClick={doGenKey}>生成密钥</button>
352
+ }}>{t("保存 encrypt")}</button>
353
+ <button style={C.btn} onClick={doGenKey}>{t("生成密钥")}</button>
354
354
  </div>
355
355
  <pre style={{ ...C.pre, maxHeight: 320 }}>{JSON.stringify(d.config || {}, null, 2)}</pre>
356
356
  <div style={{ display: "flex", gap: 8, marginTop: 8 }}>
357
- <button style={{ ...C.btn, ...C.btnPrimary }} onClick={() => doSaveConfig({ sentry: { enabled: true } })}>开启自动哨兵</button>
358
- <button style={C.btn} onClick={() => load("config")}>↻ 刷新</button>
357
+ <button style={{ ...C.btn, ...C.btnPrimary }} onClick={() => doSaveConfig({ sentry: { enabled: true } })}>{t("开启自动哨兵")}</button>
358
+ <button style={C.btn} onClick={() => load("config")}>{t("↻ 刷新")}</button>
359
359
  </div>
360
360
  </div>
361
361
  );
@@ -372,17 +372,17 @@ function App({ open, onClose }: { open: boolean; onClose: () => void }) {
372
372
  >
373
373
  <div style={headStyle}>
374
374
  <span style={{ fontWeight: 700, fontSize: 14, display: "flex", alignItems: "center", gap: 6 }}>
375
- <Ic size={15} paths={ICONS.shield} />配置安全盾
375
+ <Ic size={15} paths={ICONS.shield} />{t("配置安全盾")}
376
376
  </span>
377
377
  <div style={C.tabs}>
378
- {[["status", "状态"], ["log", "历史"], ["selfcheck", "自检"], ["config", "配置"]].map(([k, label]) => (
378
+ {[["status", t("状态")], ["log", t("历史")], ["selfcheck", t("自检")], ["config", t("配置")]].map(([k, label]) => (
379
379
  <button key={k} style={{ ...C.tab, ...(tab === k ? C.tabOn : {}) }} onClick={() => { setTab(k); setDiff(null); setFileDiff(null); }}>{label}</button>
380
380
  ))}
381
381
  </div>
382
- <button style={C.btn} onClick={() => onClose()} aria-label="关闭"><Ic size={12} paths={ICONS.x} /></button>
382
+ <button style={C.btn} onClick={() => onClose()} aria-label={t("关闭")}><Ic size={12} paths={ICONS.x} /></button>
383
383
  </div>
384
384
  <div style={bodyStyle}>
385
- {busy ? <div style={{ color: "var(--text-subtle,#666)", marginBottom: 6 }}>处理中…</div> : null}
385
+ {busy ? <div style={{ color: "var(--text-subtle,#666)", marginBottom: 6 }}>{t("处理中…")}</div> : null}
386
386
  {msg ? (<div style={C.msg}>{msg.startsWith("❌") || msg.startsWith("⚠") || msg.startsWith("错误") || msg.startsWith("失败") || msg.startsWith("\u274c") ? <div style={C.errorMsg}>{msg}</div> : <div style={C.msg}>{msg}</div>}</div>) : null}
387
387
  {tab === "status" ? renderStatus() : tab === "log" ? renderLog() : tab === "selfcheck" ? renderSelfcheck() : renderConfig()}
388
388
  </div>
@@ -396,7 +396,7 @@ export function ConfigsButton() {
396
396
  // 顶栏按钮样式与系统内建按钮一致(AppShell topbarRowBtnStyle:flex 居中 + fixed 36×36)
397
397
  return (
398
398
  <button
399
- title="aiti-configs:配置版本化 + 自检"
399
+ title={t("aiti-configs:配置版本化 + 自检")}
400
400
  onClick={open}
401
401
  onMouseEnter={(e) => { e.currentTarget.style.color = "var(--text)"; }}
402
402
  onMouseLeave={(e) => { e.currentTarget.style.color = "var(--text-muted)"; }}
@@ -19,8 +19,8 @@ export default function register(ctx: Record<string, unknown>) {
19
19
  ctx.registerItems?.("toolbar", [{
20
20
  id: "aiti-configs-open",
21
21
  meta: {
22
- label: "配置",
23
- title: "aiti-configs:配置版本化 + 自检",
22
+ label: "i18n:cfg.open.label",
23
+ title: "i18n:cfg.open.title",
24
24
  icon: "icons/shield.svg",
25
25
  onClick: () => { try { window.__aitiConfigsOpen && window.__aitiConfigsOpen(); } catch { /* noop */ } },
26
26
  },
package/dev-pack.mjs CHANGED
@@ -77,7 +77,7 @@ export function agentsMdTemplate(extId) {
77
77
 
78
78
  /** 默认 tools/build.mjs(esbuild 单包零配置;扩展自带 tools/build.mjs 则不走到这里)。 */
79
79
  function buildMjsTemplate(extId, extRoot, clientOut, entryRel) {
80
- const repoHint = "/home/pi/workspace/aiti-ai"; // 现场构建探测源码仓 node_modules 用(三机各不同,缺失时走 npm exec)
80
+ // No hardcoded checkout path: candidates are resolved at run time (see repoCandidates below).
81
81
  return `/**
82
82
  * ${extId} · 现场构建入口(dev-pack 默认模板,esbuild 单包零配置)
83
83
  * 用法:node tools/build.mjs
@@ -96,12 +96,25 @@ const entryRel = ${JSON.stringify(entryRel || "")};
96
96
 
97
97
  // esbuild 解析:部署目录 node_modules → 源码仓 node_modules(本机开发场景)→ PATH 上的 esbuild → npm exec 现拉。
98
98
  // 注意:node_modules/esbuild/bin/esbuild 是原生二进制(ELF/Mach-O),必须直接执行(不能当 JS 跑)。
99
+ // Checkout roots are discovered by walking up from the extension dir (a root has node_modules/),
100
+ // plus AITI_REPO_ROOT when set — no machine-specific absolute paths baked into generated files.
101
+ function repoCandidates() {
102
+ const out = [];
103
+ if (process.env.AITI_REPO_ROOT) out.push(process.env.AITI_REPO_ROOT.split(pathSep).join("/") + "/node_modules/esbuild/bin/esbuild");
104
+ let d = extRoot;
105
+ for (let i = 0; i < 8; i++) {
106
+ out.push(d.split(pathSep).join("/") + "/node_modules/esbuild/bin/esbuild");
107
+ const up = dirname(d);
108
+ if (up === d) break;
109
+ d = up;
110
+ }
111
+ return out;
112
+ }
99
113
  function findEsbuild() {
100
114
  const home = (process.env.HOME || process.env.USERPROFILE || "").split(pathSep).join("/");
101
115
  const candidates = [
102
116
  extRoot + "/node_modules/esbuild/bin/esbuild",
103
- home + "/workspace/aiti-ai/node_modules/esbuild/bin/esbuild",
104
- "C:/workspace/aiti-ai/node_modules/esbuild/bin/esbuild", // windows dev box(源码在 D 盘)
117
+ ...repoCandidates(),
105
118
  ];
106
119
  for (const c of candidates) {
107
120
  if (!existsSync(c)) continue;