@aiti-ai/aiti-doc-center 0.1.11 → 0.1.12

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,30 @@
1
1
  # @aiti-ai/aiti-doc-center
2
2
 
3
- > workspace md 收集/整理/检索——FTS5 trigram 中文全文 + tag 七来源两层 + 📚 float 弹窗四视图
3
+ > workspace markdown collection/organization/search — FTS5 trigram Chinese full-text + tag seven-source two-layer + 📚 float dialog four views
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
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.
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 (aiti-agent, built on pi-web): <https://github.com/aiti-ai/pi-web>
12
+ - Ecosystem monorepo: <https://github.com/aiti-ai/aiti-ai>
13
+ - Site: <https://aiti.pw>
14
14
 
15
- ## 功能定位(中文)
15
+ Category: Knowledge management · Tags: `docs` · `search` · `fts5` · `tag`
16
16
 
17
- workspace md 收集/整理/检索——FTS5 trigram 中文全文 + tag 七来源两层 + 📚 float 弹窗四视图
17
+ ## Install
18
18
 
19
- 知识管理 · tags: `docs` · `search` · `fts5` · `tag`
19
+ Bundled with **aiti-agent** (`@aiti-ai/pi-web`) — enable it from the in-app extension manager (ExtMan / App Center).
20
20
 
21
- ## Positioning (English)
21
+ Manual install: place this package at `~/.pi/web/extensions/aiti-doc-center/` and reload pi-web.
22
22
 
23
- workspace markdown collection/organization/search — FTS5 trigram Chinese full-text + tag seven-source two-layer + 📚 float dialog four views
23
+ ## Documentation
24
24
 
25
- ## 安装 / 部署
26
-
27
- 随 aiti-agent 扩展体系部署(extman 安装 / deploy 脚本拷贝到 `~/.pi/web/extensions/`),一般不单独 npm 安装;作为依赖被引用时经 extman reconcile 自动装入共享 node_modules。
28
-
29
- Deployed as part of the aiti-agent extension system (extman install / deploy scripts copy it to `~/.pi/web/extensions/`); usually not installed standalone.
30
-
31
- ## 文档 · Documentation
32
-
33
- - 中文完整文档(aiti-docs): <https://aiti.pw/extensions/aiti-doc-center.html>
34
- - English docs: <https://aiti.pw/en/extensions/aiti-doc-center.html>
35
- - 扩展注册表 / registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
25
+ - Documentation (English): <https://aiti.pw/en/extensions/aiti-doc-center.html>
26
+ - 文档(中文): <https://aiti.pw/extensions/aiti-doc-center.html>
27
+ - Extension registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
36
28
 
37
29
  ## License
38
30
 
@@ -0,0 +1,31 @@
1
+ # @aiti-ai/aiti-doc-center
2
+
3
+ > workspace md 收集/整理/检索——FTS5 trigram 中文全文 + tag 七来源两层 + 📚 float 弹窗四视图
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/pi-web) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
10
+
11
+ - 工作台(aiti-agent,基于 pi-web): <https://github.com/aiti-ai/pi-web>
12
+ - 生态仓库: <https://github.com/aiti-ai/aiti-ai>
13
+ - 官网: <https://aiti.pw>
14
+
15
+ 分类: 知识管理 · tags: `docs` · `search` · `fts5` · `tag`
16
+
17
+ ## 安装
18
+
19
+ 随 **aiti-agent**(`@aiti-ai/pi-web`)捆绑发行——在工作台内的扩展管理器(ExtMan / 应用中心)启用即可。
20
+
21
+ 手动安装:把本包放到 `~/.pi/web/extensions/aiti-doc-center/` 后 reload。
22
+
23
+ ## 文档
24
+
25
+ - 中文文档: <https://aiti.pw/extensions/aiti-doc-center.html>
26
+ - Documentation (English): <https://aiti.pw/en/extensions/aiti-doc-center.html>
27
+ - 扩展注册表: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
28
+
29
+ ## 许可证
30
+
31
+ MIT
@@ -12,6 +12,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
12
12
  import { apiUrl, appendText, openFile, extSvc, t } from "./host-shim";
13
13
  import { buildAtText, openNewSessionWithExtSvc } from "../../../_shared/new-session-cwd";
14
14
  import { usePresent, useGate, DockBody, openFloat, closePanel } from "../../../_shared/ext-float-dock";
15
+ import { zoomFactorOf } from "../../../_shared/popup-anchor";
15
16
 
16
17
  const API = (p: string) => apiUrl("/api/extensions/aiti-doc-center" + p);
17
18
 
@@ -391,7 +392,8 @@ function DocCenterDialog({ onClose, initialUnder, embedded }: { onClose: () => v
391
392
  <button onClick={(e) => {
392
393
  const r = e.currentTarget.getBoundingClientRect();
393
394
  const w = Math.min(320, window.innerWidth * 0.8);
394
- setWsRect({ left: Math.max(8, Math.min(r.right - w, window.innerWidth - w - 8)), top: r.bottom + 4 });
395
+ const zf = zoomFactorOf(e.currentTarget); // panel UI scale: divide viewport-space back
396
+ setWsRect({ left: Math.max(8, Math.min(r.right - w, window.innerWidth - w - 8)) / zf, top: (r.bottom + 4) / zf });
395
397
  setWsOpen((v) => !v);
396
398
  }}
397
399
  title={under ? t("dc.wsTipUnder", { dir: under }) : t("dc.wsTipAll")}
@@ -505,7 +507,8 @@ function DocCenterDialog({ onClose, initialUnder, embedded }: { onClose: () => v
505
507
  <button onClick={(e) => {
506
508
  const r = e.currentTarget.getBoundingClientRect();
507
509
  const w = Math.min(340, window.innerWidth * 0.86);
508
- setTagSelRect({ left: Math.max(8, Math.min(r.left, window.innerWidth - w - 8)), top: r.bottom + 4 });
510
+ const zf = zoomFactorOf(e.currentTarget); // panel UI scale: divide viewport-space back
511
+ setTagSelRect({ left: Math.max(8, Math.min(r.left, window.innerWidth - w - 8)) / zf, top: (r.bottom + 4) / zf });
509
512
  setTagSelOpen((v) => !v);
510
513
  }}
511
514
  title={view === "dir" ? t("dc.dirFilterTip") : t("dc.tagFilterTip")}
@@ -536,10 +539,10 @@ function DocCenterDialog({ onClose, initialUnder, embedded }: { onClose: () => v
536
539
  <div style={{ width: 224, flexShrink: 0, borderRight: "1px solid var(--border)", overflowY: "auto", padding: "8px 6px" }}>
537
540
  {(tagSel.length > 0 || dirFilter) && (
538
541
  <div style={{ display: "flex", flexWrap: "wrap", alignItems: "center", gap: 4, padding: "2px 4px 6px", borderBottom: "1px solid var(--border)", marginBottom: 6 }}>
539
- {sortTags(tagSel.map((k) => ({ key: k, display: (flatTags.find((f) => f.key === k) || { display: k }).display, source: "ui" }))).map((t: any) => (
540
- <span key={t.key} style={{ fontSize: 10.5, padding: "1px 6px", borderRadius: 5, background: "#6366f122", color: "#6366f1", display: "inline-flex", alignItems: "center", gap: 3, minWidth: 0 }}>
541
- #{t.display}
542
- <span onClick={() => setTagSel((s) => s.filter((x) => x !== t.key))} title={t("dc.remove")} style={{ cursor: "pointer", fontWeight: 700 }}>×</span>
542
+ {sortTags(tagSel.map((k) => ({ key: k, display: (flatTags.find((f) => f.key === k) || { display: k }).display, source: "ui" }))).map((tg: any) => (
543
+ <span key={tg.key} style={{ fontSize: 10.5, padding: "1px 6px", borderRadius: 5, background: "#6366f122", color: "#6366f1", display: "inline-flex", alignItems: "center", gap: 3, minWidth: 0 }}>
544
+ #{tg.display}
545
+ <span onClick={() => setTagSel((s) => s.filter((x) => x !== tg.key))} title={t("dc.remove")} style={{ cursor: "pointer", fontWeight: 700 }}>×</span>
543
546
  </span>
544
547
  ))}
545
548
  {dirFilter && (
@@ -41,17 +41,17 @@ export default function register(ctx: Record<string, any>) {
41
41
  ctx.registerItems?.("toolbar", [{
42
42
  id: "aiti-doc-center-open",
43
43
  meta: {
44
- label: "文档",
45
- title: "文档中心:workspace 文档收集与全文检索",
44
+ label: "i18n:dc.app.label",
45
+ title: "i18n:it.docs.title",
46
46
  icon: { svg: '<path d="M12 7v14"/><path d="M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"/>' },
47
47
  onClick: () => requestOpen(),
48
48
  },
49
49
  }]);
50
- ctx.registerItems?.("pages", [{ id: "aiti-doc-center-page", render: DocCenterPageSlot, meta: { label: "文档中心" } }]);
50
+ ctx.registerItems?.("pages", [{ id: "aiti-doc-center-page", render: DocCenterPageSlot, meta: { label: "i18n:it.aiti-doc-center-page.label" } }]);
51
51
  // aiti-float dock v0.5.x(§1.1 文档 tab):右栏停靠 face——与 pages 浮窗经状态机互斥 gate
52
52
  // ⚠ 注册 raw itemId,宿主自动拼 extId:itemId = itemKey——必须与状态机 key "aiti-doc-center:docs" 的
53
53
  // itemId 段一致(拼后链路:镜像/联动/TabBody only 全按复合 id 匹配)
54
- ctx.registerItems?.("rightFileDock", [{ id: "docs", render: DockDocs, meta: { title: "文档" } }]);
54
+ ctx.registerItems?.("rightFileDock", [{ id: "docs", render: DockDocs, meta: { title: "i18n:it.docs.title" } }]);
55
55
  // M6-B 编辑器联动:aiti-editor ⋯ 菜单「🏷 标签」入口(查看/增删任意文件 tag;非 md 打 tag 即进索引)
56
56
  const unregTags = registerEditorFileTags();
57
57
  if (unregTags) { try { (ctx as any).registerCleanup?.(unregTags); } catch { /* 旧宿主无此口:模块随页面生命周期 */ } }
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;
@@ -65,6 +65,8 @@ function t(key, params) {
65
65
  return typeof fn === "function" ? fn(key, params) : key;
66
66
  }
67
67
  function isFixedContainingBlock(cs) {
68
+ const zoomValue = parseFloat(cs.zoom || "");
69
+ if (Number.isFinite(zoomValue) && zoomValue !== 1) return true;
68
70
  if (cs.transform !== "none" || cs.perspective !== "none" || cs.filter !== "none") return true;
69
71
  if (/transform|perspective|filter/.test(cs.willChange || "")) return true;
70
72
  const c2 = cs.contain;
@@ -84,6 +86,19 @@ function fixedOrigin(el2) {
84
86
  }
85
87
  return { x: 0, y: 0 };
86
88
  }
89
+ function zoomFactorOf(el2) {
90
+ let z = 1;
91
+ let n = el2.parentElement;
92
+ while (n && n !== document.documentElement) {
93
+ try {
94
+ const zoomValue = parseFloat(getComputedStyle(n).zoom || "");
95
+ if (Number.isFinite(zoomValue) && zoomValue > 0 && zoomValue !== 1) z *= zoomValue;
96
+ } catch {
97
+ }
98
+ n = n.parentElement;
99
+ }
100
+ return z;
101
+ }
87
102
  function clampToViewport(left, top, width, height, pad = 8) {
88
103
  const vw = window.innerWidth;
89
104
  const vh = window.innerHeight;
@@ -94,6 +109,7 @@ function clampToViewport(left, top, width, height, pad = 8) {
94
109
  }
95
110
  const P = (d) => ({ tag: "path", attrs: { d } });
96
111
  const R = (x, y, width, height, rx = 2) => ({ tag: "rect", attrs: { x, y, width, height, rx } });
112
+ const thin = (n) => ({ ...n, attrs: { ...n.attrs, "stroke-width": 1.5 } });
97
113
  const DOCK_ICON_NODES = {
98
114
  /** 浮窗:圆角框 + 标题栏 + 圆点(app-window;用户 2026-09-15 定稿 C)。 */
99
115
  float: [
@@ -127,6 +143,12 @@ const DOCK_ICON_NODES = {
127
143
  ],
128
144
  /** 关闭:×(lucide x;⋮ 区块操作「关闭」)。 */
129
145
  x: [P("M18 6 6 18"), P("m6 6 12 12")],
146
+ /** 取消钉住态:图钉 + 斜删除线(lucide pin-off;移动行钉住钮已钉态,与 MiPin 同语义族)。 */
147
+ "pin-off": [
148
+ { tag: "line", attrs: { x1: 12, y1: 17, x2: 12, y2: 22 } },
149
+ P("M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16h14v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"),
150
+ { tag: "line", attrs: { x1: 2, y1: 2, x2: 22, y2: 22 } }
151
+ ],
130
152
  /** 移除本实例:垃圾桶(lucide trash;多实例区块 ⋮「移除本实例」,与 aiti-folder MiTrash 同形)。 */
131
153
  trash: [
132
154
  { tag: "polyline", attrs: { points: "3 6 5 6 21 6" } },
@@ -139,6 +161,89 @@ const DOCK_ICON_NODES = {
139
161
  P("M5 11V5h6"),
140
162
  P("M19 13v6h-6"),
141
163
  P("M5 5l14 14")
164
+ ],
165
+ /* ── Block semantic icons (collapsed-header icons; lucide line style) ── */
166
+ /** Projects block (session-manager projects): the aiti-ai logo as line art (chosen by
167
+ * the user 2026-11-26 from the icon candidates preview; prototype = aiti-docs
168
+ * docs/.vuepress/public/logo.svg). Three brand elements: large-rounded square (the
169
+ * gradient tile) + geometric letter a (circle + stem) + top-right spark (from the
170
+ * logo's yellow dot). Visual weight kept on par with the folder/file glyph family:
171
+ * the spark dot is stroked, not filled (a filled node reads much heavier at 13px),
172
+ * and the letter circle stays small so line density matches single-outline glyphs. */
173
+ "aiti-ai-logo": [
174
+ thin(R(3, 3, 18, 18, 4)),
175
+ thin({ tag: "circle", attrs: { cx: 10, cy: 14, r: 2.8 } }),
176
+ thin(P("M12.8 11.2v5.6")),
177
+ thin({ tag: "circle", attrs: { cx: 16.8, cy: 7.2, r: 1.2 } }),
178
+ thin(P("m18.8 5.3 1.5-1.6")),
179
+ thin(P("m19.2 8.2 2.1-.4"))
180
+ ],
181
+ /** Folder block (aiti-folder faces): single folder (lucide folder). */
182
+ folder: [
183
+ P("M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z")
184
+ ],
185
+ /** Scheduled tasks block (aiti-ai-schedule tasks): clock (lucide clock). */
186
+ clock: [
187
+ { tag: "circle", attrs: { cx: 12, cy: 12, r: 10 } },
188
+ { tag: "polyline", attrs: { points: "12 6 12 12 16 14" } }
189
+ ],
190
+ /** Subagent fleet block (aiti-subagents fleet): robot (lucide bot). */
191
+ bot: [
192
+ P("M12 8V4H8"),
193
+ R(4, 8, 16, 12),
194
+ P("M2 14h2"),
195
+ P("M20 14h2"),
196
+ P("M15 13v2"),
197
+ P("M9 13v2")
198
+ ],
199
+ /** Prompt library block (aiti-prompts panel): bookshelf lines (lucide library). */
200
+ library: [
201
+ P("m16 6 4 14"),
202
+ P("M12 6v14"),
203
+ P("M8 8v12"),
204
+ P("M4 4v16")
205
+ ],
206
+ /** Model availability block (aiti-model-check panel): shield + check (lucide shield-check). */
207
+ "shield-check": [
208
+ P("M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"),
209
+ P("m9 12 2 2 4-4")
210
+ ],
211
+ /** Watch paths block (aiti-git-trace watch): branch (lucide git-branch). */
212
+ "git-branch": [
213
+ { tag: "line", attrs: { x1: 6, y1: 3, x2: 6, y2: 15 } },
214
+ { tag: "circle", attrs: { cx: 18, cy: 6, r: 3 } },
215
+ { tag: "circle", attrs: { cx: 6, cy: 18, r: 3 } },
216
+ P("M18 9a9 9 0 0 1-9 9")
217
+ ],
218
+ /** Timeline block (aiti-git-trace timeline): clock + counterclockwise arrow (lucide history). */
219
+ history: [
220
+ P("M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"),
221
+ P("M3 3v5h5"),
222
+ P("M12 7v5l4 2")
223
+ ],
224
+ /** File panel block (aiti-editor file faces): document (lucide file). */
225
+ file: [
226
+ P("M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"),
227
+ P("M14 2v4a2 2 0 0 0 2 2h4")
228
+ ],
229
+ /** ACP management block (aiti-acp-agent manage): plug (lucide plug). */
230
+ plug: [
231
+ P("M12 22v-5"),
232
+ P("M9 8V2"),
233
+ P("M15 8V2"),
234
+ P("M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z")
235
+ ],
236
+ /** Speech recognition block (aiti-ai-input asr): microphone (lucide mic). */
237
+ mic: [
238
+ P("M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"),
239
+ P("M19 10v2a7 7 0 0 1-14 0v-2"),
240
+ { tag: "line", attrs: { x1: 12, y1: 19, x2: 12, y2: 22 } }
241
+ ],
242
+ /** Dock demo block (demo): 3D box (lucide box). */
243
+ box: [
244
+ P("M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"),
245
+ P("m3.3 7 8.7 5 8.7-5"),
246
+ P("M12 22V12")
142
247
  ]
143
248
  };
144
249
  function dockIconOfZone(zone) {
@@ -174,6 +279,13 @@ const DOCK_ICON_SVG_ROOT_PROPS = {
174
279
  strokeLinecap: "round",
175
280
  strokeLinejoin: "round"
176
281
  };
282
+ function dockIconReactAttrs(attrs) {
283
+ const out = {};
284
+ for (const [k, v] of Object.entries(attrs)) {
285
+ out[!k.includes("-") || k.startsWith("aria-") || k.startsWith("data-") ? k : k.replace(/-([a-z])/g, (_, c2) => c2.toUpperCase())] = v;
286
+ }
287
+ return out;
288
+ }
177
289
  function sidebarZoneOf(itemKey) {
178
290
  return `sidebar:${itemKey}`;
179
291
  }
@@ -201,6 +313,14 @@ function writeBlockCollapsed(blockKey, collapsed) {
201
313
  } catch {
202
314
  }
203
315
  }
316
+ const SIDEBAR_DISMISS_PREFIX = "pi:sidebar-dock:dismissed:";
317
+ function writeBlockDismissed(blockKey, dismissed) {
318
+ try {
319
+ if (dismissed) localStorage.setItem(SIDEBAR_DISMISS_PREFIX + blockKey, "1");
320
+ else localStorage.removeItem(SIDEBAR_DISMISS_PREFIX + blockKey);
321
+ } catch {
322
+ }
323
+ }
204
324
  const FLOAT_INSTALLED_EVENT = "piwe-float-installed";
205
325
  const DOCK_HEADER_PENDING_TTL = 1e4;
206
326
  function actionSig(list) {
@@ -209,7 +329,7 @@ function actionSig(list) {
209
329
  }
210
330
  function menuSig(list) {
211
331
  if (!list) return "";
212
- return list.map((m) => m.kind === "item" ? `i:${m.id ?? m.label}:${m.label}:${m.hint ?? ""}:${m.active ? 1 : 0}:${m.alwaysRun ? 1 : 0}:${m.disabled ? 1 : 0}` : m.kind === "head" ? `h:${m.label}` : "s").join("§");
332
+ return list.map((m) => m.kind === "item" ? `i:${m.id ?? m.label}:${m.label}:${m.hint ?? ""}:${m.active ? 1 : 0}:${m.alwaysRun ? 1 : 0}:${m.disabled ? 1 : 0}` : m.kind === "head" ? `h:${m.label}` : m.kind === "iconsRow" ? `r:${m.label ?? ""}:${m.items.map((i) => i.key).join(",")}` : m.kind === "moveRow" ? "mv-row" : "s").join("§");
213
333
  }
214
334
  function stateSig(s) {
215
335
  try {
@@ -420,8 +540,10 @@ function localPresent(k, mode, opts) {
420
540
  next = zone ? `docked:${zone}` : "floating";
421
541
  }
422
542
  } else if (mode === "float") next = "floating";
423
- else if (mode === "close") next = "closed";
424
- else if (mode.startsWith("dock:")) {
543
+ else if (mode === "close") {
544
+ next = "closed";
545
+ writeBlockDismissed(k, true);
546
+ } else if (mode.startsWith("dock:")) {
425
547
  const zone = mode.slice(5);
426
548
  try {
427
549
  localStorage.setItem(DOCKPREF_KEY(k), zone);
@@ -429,6 +551,7 @@ function localPresent(k, mode, opts) {
429
551
  }
430
552
  next = `docked:${zone}`;
431
553
  }
554
+ if (next !== "closed" && isSidebarDockState(next)) writeBlockDismissed(k, false);
432
555
  if (next === prev) {
433
556
  if (prev.startsWith("docked:")) {
434
557
  try {
@@ -583,9 +706,24 @@ if (typeof window !== "undefined") {
583
706
  } catch {
584
707
  }
585
708
  }
709
+ const DOCK_WORDS = {
710
+ newWindow: { "zh-CN": "新窗口打开", en: "Open in new window" },
711
+ float: { "zh-CN": "浮窗", en: "Float" },
712
+ zoneSidebar: { "zh-CN": "左栏 · 区块", en: "Left · blocks" },
713
+ zoneRight: { "zh-CN": "右栏 · 面板", en: "Right · panels" }
714
+ };
715
+ function dockWord(key) {
716
+ let loc = "en";
717
+ try {
718
+ loc = window.localStorage.getItem("pi-locale") || "en";
719
+ } catch {
720
+ }
721
+ const w = DOCK_WORDS[key];
722
+ return w[loc === "zh-CN" ? "zh-CN" : "en"] ?? w.en;
723
+ }
586
724
  const DOCK_ZONE_LABELS = {
587
- "sidebar-explorer": "左栏 · 区块",
588
- "right-panel": "右栏 · 面板"
725
+ "sidebar-explorer": dockWord("zoneSidebar"),
726
+ "right-panel": dockWord("zoneRight")
589
727
  };
590
728
  function positionMenuItems(k, zones, defaultZone, cur) {
591
729
  const hasSidebar = zones.some((z) => z === "sidebar-explorer" || z.startsWith("sidebar:"));
@@ -619,8 +757,8 @@ function positionMenuItems(k, zones, defaultZone, cur) {
619
757
  function positionMenuModel(k, zones, defaultZone, cur, opts) {
620
758
  const newWindow = opts?.onNewWindow ?? dockWindowOpenerOf(k);
621
759
  return [
622
- ...newWindow ? [{ key: "new-window", icon: "new-window", label: "新窗口打开", run: newWindow }] : [],
623
- { key: "float", icon: "float", label: "浮窗", active: cur === "floating", run: () => undockToFloat(k) },
760
+ ...newWindow ? [{ key: "new-window", icon: "new-window", label: dockWord("newWindow"), run: newWindow }] : [],
761
+ { key: "float", icon: "float", label: dockWord("float"), active: cur === "floating", run: () => undockToFloat(k) },
624
762
  ...positionMenuItems(k, zones, defaultZone, cur)
625
763
  ];
626
764
  }
@@ -716,13 +854,83 @@ function useGate(itemKey, face) {
716
854
  if (face === "float") return state === "floating";
717
855
  return state === `docked:${face.dock}`;
718
856
  }
857
+ const DOCK_MENU_WORDS = {
858
+ expand: { "zh-CN": "展开", en: "Expand" },
859
+ collapse: { "zh-CN": "折叠", en: "Collapse" },
860
+ block: { "zh-CN": "区块", en: "Block" },
861
+ position: { "zh-CN": "切换停靠位置", en: "Change dock position" },
862
+ actions: { "zh-CN": "区块操作", en: "Block actions" },
863
+ move: { "zh-CN": "移动", en: "Move" },
864
+ pin: { "zh-CN": "钉住", en: "Pin" },
865
+ unpin: { "zh-CN": "取消钉住", en: "Unpin" },
866
+ moveUp: { "zh-CN": "上移", en: "Move up" },
867
+ moveDown: { "zh-CN": "下移", en: "Move down" },
868
+ tools: { "zh-CN": "工具", en: "Tools" },
869
+ removeInstance: { "zh-CN": "移除本实例", en: "Remove this instance" },
870
+ close: { "zh-CN": "关闭", en: "Close" },
871
+ zones: { "zh-CN": "停靠方位", en: "Dock zones" },
872
+ defaultSuffix: { "zh-CN": "(默认)", en: " (default)" }
873
+ };
874
+ function menuWord(key) {
875
+ let loc = "en";
876
+ try {
877
+ loc = window.localStorage.getItem("pi-locale") || "en";
878
+ } catch {
879
+ }
880
+ const w = DOCK_MENU_WORDS[key];
881
+ return w[loc === "zh-CN" ? "zh-CN" : "en"] ?? w.en;
882
+ }
719
883
  function dockIconEl(name, size = 16) {
720
884
  return createElement(
721
885
  "svg",
722
886
  { width: size, height: size, ...DOCK_ICON_SVG_ROOT_PROPS, "aria-hidden": "true" },
723
- ...DOCK_ICON_NODES[name].map((n, i) => createElement(n.tag, { key: i, ...n.attrs }))
887
+ ...DOCK_ICON_NODES[name].map((n, i) => createElement(n.tag, { key: i, ...dockIconReactAttrs(n.attrs) }))
724
888
  );
725
889
  }
890
+ function maskedIconSpan(url, size) {
891
+ return createElement("span", { "aria-hidden": "true", style: {
892
+ display: "inline-block",
893
+ width: size,
894
+ height: size,
895
+ flexShrink: 0,
896
+ background: "currentColor",
897
+ WebkitMaskImage: `url("${url}")`,
898
+ maskImage: `url("${url}")`,
899
+ WebkitMaskRepeat: "no-repeat",
900
+ maskRepeat: "no-repeat",
901
+ WebkitMaskPosition: "center",
902
+ maskPosition: "center",
903
+ WebkitMaskSize: "contain",
904
+ maskSize: "contain"
905
+ } });
906
+ }
907
+ function dockIconFromDecl(icon, size = 13) {
908
+ if (icon == null) return null;
909
+ if (typeof icon === "object") {
910
+ const o = icon;
911
+ if (typeof o.svg === "string") {
912
+ return createElement("svg", {
913
+ width: size,
914
+ height: size,
915
+ viewBox: "0 0 24 24",
916
+ fill: "none",
917
+ stroke: "currentColor",
918
+ strokeWidth: 2,
919
+ strokeLinecap: "round",
920
+ strokeLinejoin: "round",
921
+ "aria-hidden": "true",
922
+ dangerouslySetInnerHTML: { __html: o.svg }
923
+ });
924
+ }
925
+ if (typeof o.url === "string") return maskedIconSpan(o.url, size);
926
+ return null;
927
+ }
928
+ if (typeof icon !== "string" || !icon) return null;
929
+ if (/^https?:\/\//.test(icon)) return maskedIconSpan(icon, size);
930
+ if (DOCK_ICON_NODES[icon]) return dockIconEl(icon, size);
931
+ if (icon.endsWith(".svg")) return null;
932
+ return createElement("span", { style: { fontSize: size, lineHeight: 1 } }, icon);
933
+ }
726
934
  function headerStore() {
727
935
  const api2 = floatApi();
728
936
  const svc = api2?.dockHeader;
@@ -796,7 +1004,8 @@ function DockBody(props) {
796
1004
  if (m.height > below && above > below) top = b.top - gap - m.height;
797
1005
  const c2 = clampToViewport(b.right - m.width, top, m.width, m.height, pad);
798
1006
  const o = fixedOrigin(menuEl);
799
- const next = { left: c2.left - o.x, top: c2.top - o.y };
1007
+ const z = zoomFactorOf(menuEl);
1008
+ const next = { left: (c2.left - o.x) / z, top: (c2.top - o.y) / z };
800
1009
  setMenuPos((cur) => cur && cur.left === next.left && cur.top === next.top ? cur : next);
801
1010
  }, [menu, menuEl]);
802
1011
  useEffect(() => {
@@ -807,8 +1016,23 @@ function DockBody(props) {
807
1016
  if (t2 && menu.anchor?.contains(t2)) return;
808
1017
  setMenu(null);
809
1018
  };
1019
+ let anchorTop = null;
1020
+ let anchorLeft = null;
1021
+ try {
1022
+ const a = menu.anchor?.getBoundingClientRect?.();
1023
+ if (a) {
1024
+ anchorTop = a.top;
1025
+ anchorLeft = a.left;
1026
+ }
1027
+ } catch {
1028
+ }
810
1029
  const onScroll = (e) => {
811
1030
  if (menuEl && e.target instanceof Node && menuEl.contains(e.target)) return;
1031
+ try {
1032
+ const a = menu.anchor?.getBoundingClientRect?.();
1033
+ if (a && anchorTop !== null && anchorLeft !== null && Math.abs(a.top - anchorTop) < 4 && Math.abs(a.left - anchorLeft) < 4) return;
1034
+ } catch {
1035
+ }
812
1036
  setMenu(null);
813
1037
  };
814
1038
  document.addEventListener("mousedown", onDown);
@@ -891,42 +1115,63 @@ function DockBody(props) {
891
1115
  );
892
1116
  const buildMainMenu = () => {
893
1117
  const out = [];
1118
+ const sortable = kind !== "reserved";
1119
+ const buildMoveRow = () => ({
1120
+ type: "icons",
1121
+ label: menuWord("move"),
1122
+ icon: dockIconEl("move-diagonal-2", 13),
1123
+ items: [
1124
+ ...props.moveRowPin ? [{
1125
+ key: "pin",
1126
+ icon: props.moveRowPin.isPinned() ? "pin-off" : "pin",
1127
+ label: props.moveRowPin.isPinned() ? menuWord("unpin") : menuWord("pin"),
1128
+ run: () => props.moveRowPin.toggle()
1129
+ }] : [],
1130
+ { key: "move-up", icon: "chevron-up", label: menuWord("moveUp"), run: () => requestBlockMove(blockKey, -1) },
1131
+ { key: "move-down", icon: "chevron-down", label: menuWord("moveDown"), run: () => requestBlockMove(blockKey, 1) }
1132
+ ]
1133
+ });
894
1134
  if (overflowActions.length > 0) {
895
- out.push({ type: "head", label: "工具" });
1135
+ out.push({ type: "head", label: menuWord("tools") });
896
1136
  for (const a of overflowActions) out.push({ type: "item", label: a.title, icon: a.icon, badge: a.badge, active: a.active, alwaysRun: true, disabled: a.disabled, run: a.onClick });
897
1137
  }
898
1138
  if (storeData.menuItems && storeData.menuItems.length > 0) {
899
1139
  if (out.length > 0) out.push({ type: "sep" });
1140
+ let moveRowInserted = false;
900
1141
  for (const m of storeData.menuItems) {
1142
+ if (m.kind === "moveRow" && sortable && !moveRowInserted) {
1143
+ moveRowInserted = true;
1144
+ out.push(buildMoveRow());
1145
+ continue;
1146
+ }
901
1147
  if (m.kind === "head") out.push({ type: "head", label: m.label });
902
1148
  else if (m.kind === "sep") out.push({ type: "sep" });
1149
+ else if (m.kind === "iconsRow") out.push({ type: "icons", label: m.label, items: m.items });
903
1150
  else out.push({ type: "item", label: m.label, icon: m.icon, hint: m.hint, active: m.active, alwaysRun: m.alwaysRun, disabled: m.disabled, run: m.run });
904
1151
  }
1152
+ if (chrome === "section" && sortable && !moveRowInserted) out.push(buildMoveRow());
905
1153
  }
906
1154
  const ops = [];
907
- if (chrome === "section") {
908
- ops.push({ type: "icons", label: "移动", icon: dockIconEl("move-diagonal-2", 13), items: [
909
- { key: "move-up", icon: "chevron-up", label: "上移", run: () => requestBlockMove(blockKey, -1) },
910
- { key: "move-down", icon: "chevron-down", label: "下移", run: () => requestBlockMove(blockKey, 1) }
911
- ] });
1155
+ if (chrome === "section" && sortable && !(storeData.menuItems || []).some((m) => m.kind === "moveRow")) {
1156
+ ops.push(buildMoveRow());
912
1157
  }
913
1158
  if (kind === "reserved" && typeof props.onRemove === "function") {
914
- ops.push({ type: "item", label: "移除本实例", icon: dockIconEl("trash", 13), run: () => props.onRemove() });
1159
+ ops.push({ type: "item", label: menuWord("removeInstance"), icon: dockIconEl("trash", 13), run: () => props.onRemove() });
915
1160
  }
916
1161
  if (Array.isArray(props.extraMenuItems)) {
917
1162
  for (const m of props.extraMenuItems) ops.push({ type: "item", label: m.label, icon: m.icon, hint: m.hint, active: m.active, alwaysRun: m.alwaysRun, run: m.run });
918
1163
  }
919
- if (kind === "dockable" && chrome === "section") {
920
- ops.push({ type: "item", label: "关闭", icon: dockIconEl("x", 13), run: () => props.onClose ? props.onClose() : closePanel(itemKey) });
1164
+ if (kind === "dockable" && chrome === "section" && props.hideCloseItem !== true) {
1165
+ ops.push({ type: "item", label: menuWord("close"), icon: dockIconEl("x", 13), run: () => props.onClose ? props.onClose() : closePanel(itemKey) });
921
1166
  }
922
1167
  if (ops.length > 0) {
923
1168
  if (out.length > 0) out.push({ type: "sep" });
924
- out.push({ type: "head", label: "区块" });
1169
+ out.push({ type: "head", label: menuWord("block") });
925
1170
  out.push(...ops);
926
1171
  }
927
1172
  return out;
928
1173
  };
929
- const positionRows = menu?.kind === "position" ? [{ type: "icons", label: "停靠方位", items: positionMenuModel(itemKey, allZones, defaultZone, state, { onNewWindow: props.onNewWindow }) }] : [];
1174
+ const positionRows = menu?.kind === "position" ? [{ type: "icons", label: menuWord("zones"), items: positionMenuModel(itemKey, allZones, defaultZone, state, { onNewWindow: props.onNewWindow }) }] : [];
930
1175
  const menuRows = menu?.kind === "position" ? positionRows : menu?.kind === "main" ? buildMainMenu() : [];
931
1176
  const renderMenuRow = (it, i) => {
932
1177
  if (it.type === "sep") return createElement("div", { key: `sep-${i}`, style: { height: 1, background: "var(--border, #444)", margin: "3px 4px", opacity: 0.7, flexShrink: 0 } });
@@ -969,7 +1214,7 @@ function DockBody(props) {
969
1214
  },
970
1215
  ...it.items.map((x, j) => {
971
1216
  const isRadio = x.active === true || x.active === false;
972
- const tip = x.isDefault ? `${x.label}(默认)` : x.label;
1217
+ const tip = x.isDefault ? `${x.label}${menuWord("defaultSuffix")}` : x.label;
973
1218
  return createElement(
974
1219
  "button",
975
1220
  {
@@ -1013,7 +1258,7 @@ function DockBody(props) {
1013
1258
  }
1014
1259
  }
1015
1260
  },
1016
- dockIconEl(x.icon, 16),
1261
+ typeof x.icon === "string" ? dockIconEl(x.icon, 16) : x.icon,
1017
1262
  x.isDefault ? createElement("span", { key: "dot", "data-ext-dock-icon-default": "1", style: { position: "absolute", top: 3, right: 3, width: 4, height: 4, borderRadius: "50%", background: "var(--accent, #2563eb)", pointerEvents: "none" } }) : null
1018
1263
  );
1019
1264
  })
@@ -1081,7 +1326,16 @@ function DockBody(props) {
1081
1326
  // 首帧离屏(布局期测量后落位,绘制前同步无闪烁)
1082
1327
  ...menuPos ? { left: menuPos.left, top: menuPos.top } : { left: -99999, top: -99999 }
1083
1328
  },
1084
- onMouseLeave: () => setMenu(null)
1329
+ // hover 关闭仅限真 hover 设备(2026-11-15 小屏反馈「菜单经常自己关掉」):手机上手指
1330
+ // 滑动浏览菜单项时浏览器合成 mouse 事件(touchmove 目标变化 → 合成 mouseleave),
1331
+ // 无条件关闭等于「一滑就关」;触屏(hover:none)忽略 mouseleave,改由外点/滚动关闭。
1332
+ onMouseLeave: () => {
1333
+ try {
1334
+ if (!window.matchMedia("(hover: hover) and (pointer: fine)").matches) return;
1335
+ } catch {
1336
+ }
1337
+ setMenu(null);
1338
+ }
1085
1339
  }, menuRows.map(renderMenuRow)) : null;
1086
1340
  const toggleCollapsed = () => setCollapsed(!collapsed);
1087
1341
  const onDragStart = (e) => {
@@ -1128,9 +1382,9 @@ function DockBody(props) {
1128
1382
  if (e.target && typeof e.target.closest === "function" && e.target.closest("button")) return;
1129
1383
  toggleCollapsed();
1130
1384
  } };
1131
- if (chrome === "section") {
1385
+ if (chrome === "section" && kind !== "reserved") {
1132
1386
  headerProps.draggable = true;
1133
- headerProps.title = "拖动排序";
1387
+ headerProps.title = props.headerHint ?? "拖动排序";
1134
1388
  headerProps.onDragStart = onDragStart;
1135
1389
  headerProps.onDragOver = (e) => {
1136
1390
  if (isDockDrag(e) && dragKey !== blockKey) {
@@ -1151,8 +1405,16 @@ function DockBody(props) {
1151
1405
  dragKey = null;
1152
1406
  document.querySelectorAll(".pi-dock-drop-before, .pi-dock-drop-after").forEach((el2) => el2.classList.remove("pi-dock-drop-before", "pi-dock-drop-after"));
1153
1407
  };
1408
+ } else if (chrome === "section" && props.headerHint) {
1409
+ headerProps.title = props.headerHint;
1154
1410
  }
1155
- const titleNode = props.renderTitle ? createElement("span", { style: { minWidth: 0, flex: "0 1 auto", display: "inline-flex", alignItems: "center" } }, props.renderTitle()) : createElement("span", { style: { fontSize: 11, fontWeight: 600, color: "var(--text-muted, #999)", letterSpacing: "0.04em", textTransform: "uppercase", flex: "0 1 auto", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", minWidth: 0 } }, title ?? "");
1411
+ const iconNode = dockIconFromDecl(props.icon, 13);
1412
+ const titleNode = createElement(
1413
+ "span",
1414
+ { style: { minWidth: 0, flex: "0 1 auto", display: "inline-flex", alignItems: "center", gap: 5 } },
1415
+ iconNode,
1416
+ props.renderTitle ? props.renderTitle() : createElement("span", { style: { fontSize: 13, fontWeight: 500, color: "var(--text, #222)", flex: "0 1 auto", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", minWidth: 0 } }, title ?? "")
1417
+ );
1156
1418
  const keepAlive = collapsed && storeData.hasCommands;
1157
1419
  return createElement(
1158
1420
  "div",
@@ -1175,8 +1437,8 @@ function DockBody(props) {
1175
1437
  "button",
1176
1438
  {
1177
1439
  type: "button",
1178
- title: collapsed ? "展开" : "折叠",
1179
- "aria-label": (title ?? "区块") + (collapsed ? " 展开" : " 折叠"),
1440
+ title: collapsed ? menuWord("expand") : menuWord("collapse"),
1441
+ "aria-label": (title ?? menuWord("block")) + (collapsed ? " " + menuWord("expand") : " " + menuWord("collapse")),
1180
1442
  "aria-expanded": collapsed ? "false" : "true",
1181
1443
  style: { ...btnBase, display: "flex", alignItems: "center" },
1182
1444
  onClick: toggleCollapsed
@@ -1207,8 +1469,8 @@ function DockBody(props) {
1207
1469
  createElement("button", {
1208
1470
  ref: setPosBtnEl,
1209
1471
  type: "button",
1210
- title: "切换停靠位置",
1211
- "aria-label": "切换停靠位置",
1472
+ title: menuWord("position"),
1473
+ "aria-label": menuWord("position"),
1212
1474
  "aria-haspopup": "menu",
1213
1475
  "aria-expanded": menu?.kind === "position" ? "true" : "false",
1214
1476
  style: { ...btnBase, fontSize: 12 },
@@ -1228,8 +1490,8 @@ function DockBody(props) {
1228
1490
  createElement("button", {
1229
1491
  ref: setMenuBtnEl,
1230
1492
  type: "button",
1231
- title: "区块操作",
1232
- "aria-label": "区块操作",
1493
+ title: menuWord("actions"),
1494
+ "aria-label": menuWord("actions"),
1233
1495
  "aria-haspopup": "menu",
1234
1496
  "aria-expanded": menu?.kind === "main" ? "true" : "false",
1235
1497
  style: { ...btnBase, fontSize: 12, fontWeight: 700 },
@@ -1884,7 +2146,8 @@ function DocCenterDialog({ onClose, initialUnder, embedded }) {
1884
2146
  onClick: (e) => {
1885
2147
  const r = e.currentTarget.getBoundingClientRect();
1886
2148
  const w = Math.min(320, window.innerWidth * 0.8);
1887
- setWsRect({ left: Math.max(8, Math.min(r.right - w, window.innerWidth - w - 8)), top: r.bottom + 4 });
2149
+ const zf = zoomFactorOf(e.currentTarget);
2150
+ setWsRect({ left: Math.max(8, Math.min(r.right - w, window.innerWidth - w - 8)) / zf, top: (r.bottom + 4) / zf });
1888
2151
  setWsOpen((v) => !v);
1889
2152
  },
1890
2153
  title: under ? t("dc.wsTipUnder", { dir: under }) : t("dc.wsTipAll"),
@@ -2063,7 +2326,8 @@ function DocCenterDialog({ onClose, initialUnder, embedded }) {
2063
2326
  onClick: (e) => {
2064
2327
  const r = e.currentTarget.getBoundingClientRect();
2065
2328
  const w = Math.min(340, window.innerWidth * 0.86);
2066
- setTagSelRect({ left: Math.max(8, Math.min(r.left, window.innerWidth - w - 8)), top: r.bottom + 4 });
2329
+ const zf = zoomFactorOf(e.currentTarget);
2330
+ setTagSelRect({ left: Math.max(8, Math.min(r.left, window.innerWidth - w - 8)) / zf, top: (r.bottom + 4) / zf });
2067
2331
  setTagSelOpen((v) => !v);
2068
2332
  },
2069
2333
  title: view === "dir" ? t("dc.dirFilterTip") : t("dc.tagFilterTip"),
@@ -2107,11 +2371,11 @@ function DocCenterDialog({ onClose, initialUnder, embedded }) {
2107
2371
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", flex: 1, minHeight: 0 }, children: [
2108
2372
  (view === "tags" || view === "dir") && !narrow && /* @__PURE__ */ jsxs("div", { style: { width: 224, flexShrink: 0, borderRight: "1px solid var(--border)", overflowY: "auto", padding: "8px 6px" }, children: [
2109
2373
  (tagSel.length > 0 || dirFilter) && /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: 4, padding: "2px 4px 6px", borderBottom: "1px solid var(--border)", marginBottom: 6 }, children: [
2110
- sortTags(tagSel.map((k) => ({ key: k, display: (flatTags.find((f) => f.key === k) || { display: k }).display, source: "ui" }))).map((t2) => /* @__PURE__ */ jsxs("span", { style: { fontSize: 10.5, padding: "1px 6px", borderRadius: 5, background: "#6366f122", color: "#6366f1", display: "inline-flex", alignItems: "center", gap: 3, minWidth: 0 }, children: [
2374
+ sortTags(tagSel.map((k) => ({ key: k, display: (flatTags.find((f) => f.key === k) || { display: k }).display, source: "ui" }))).map((tg) => /* @__PURE__ */ jsxs("span", { style: { fontSize: 10.5, padding: "1px 6px", borderRadius: 5, background: "#6366f122", color: "#6366f1", display: "inline-flex", alignItems: "center", gap: 3, minWidth: 0 }, children: [
2111
2375
  "#",
2112
- t2.display,
2113
- /* @__PURE__ */ jsx("span", { onClick: () => setTagSel((s) => s.filter((x) => x !== t2.key)), title: t2("dc.remove"), style: { cursor: "pointer", fontWeight: 700 }, children: "×" })
2114
- ] }, t2.key)),
2376
+ tg.display,
2377
+ /* @__PURE__ */ jsx("span", { onClick: () => setTagSel((s) => s.filter((x) => x !== tg.key)), title: t("dc.remove"), style: { cursor: "pointer", fontWeight: 700 }, children: "×" })
2378
+ ] }, tg.key)),
2115
2379
  dirFilter && /* @__PURE__ */ jsxs("span", { title: dirFilter, style: { fontSize: 10.5, padding: "1px 6px", borderRadius: 5, background: "#6366f122", color: "#6366f1", display: "inline-flex", alignItems: "center", gap: 3, maxWidth: "100%", minWidth: 0 }, children: [
2116
2380
  /* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: dirFilter }),
2117
2381
  /* @__PURE__ */ jsx("span", { onClick: () => setDirFilter(""), title: t("dc.remove"), style: { cursor: "pointer", fontWeight: 700, flexShrink: 0 }, children: "×" })
@@ -2842,14 +3106,14 @@ function register(ctx) {
2842
3106
  ctx.registerItems?.("toolbar", [{
2843
3107
  id: "aiti-doc-center-open",
2844
3108
  meta: {
2845
- label: "文档",
2846
- title: "文档中心:workspace 文档收集与全文检索",
3109
+ label: "i18n:dc.app.label",
3110
+ title: "i18n:it.docs.title",
2847
3111
  icon: { svg: '<path d="M12 7v14"/><path d="M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"/>' },
2848
3112
  onClick: () => requestOpen()
2849
3113
  }
2850
3114
  }]);
2851
- ctx.registerItems?.("pages", [{ id: "aiti-doc-center-page", render: DocCenterPageSlot, meta: { label: "文档中心" } }]);
2852
- ctx.registerItems?.("rightFileDock", [{ id: "docs", render: DockDocs, meta: { title: "文档" } }]);
3115
+ ctx.registerItems?.("pages", [{ id: "aiti-doc-center-page", render: DocCenterPageSlot, meta: { label: "i18n:it.aiti-doc-center-page.label" } }]);
3116
+ ctx.registerItems?.("rightFileDock", [{ id: "docs", render: DockDocs, meta: { title: "i18n:it.docs.title" } }]);
2853
3117
  const unregTags = registerEditorFileTags();
2854
3118
  if (unregTags) {
2855
3119
  try {
package/doc-core.ts CHANGED
@@ -281,7 +281,7 @@ export function isRandomDirName(name: string): boolean {
281
281
 
282
282
  /**
283
283
  * 路径派生 tag(v2,迭代 2026-08-31):**逐段单名、倒排**——离文件越近越优先。
284
- * 例 pi-work/docs/plans/x.md → ["plans", "docs", "pi-work"](docs/design/plan 类名字直接可过滤);
284
+ * e.g. <repo>/docs/plans/x.md -> ["plans", "docs", "demo-repo"] (names like docs/design/plan are directly filterable);
285
285
  * 随机目录名(isRandomDirName)与非法字符段跳过;去重;上限 maxDepth 段。
286
286
  */
287
287
  export function derivePathTags(rel: string, maxDepth = 6): string[] {
package/index.ts CHANGED
@@ -602,17 +602,18 @@ function writeTagsToPath(root: string, rel: string, add: string[], remove: strin
602
602
  const ext = {
603
603
  id: "aiti-doc-center",
604
604
  name: "文档中心",
605
- version: "0.3.0",
606
605
  icon: "icon.svg",
607
606
  client: "dist/aiti-doc-center-client.mjs",
608
607
  ui: {
609
608
  clientImmediately: false, // [懒加载 v2] M1 已同步生产,懒化重启用
610
609
  // 懒加载 v2 M3批①:静态条目与 client 注册 id/icon 对齐(物化前后零闪变)
611
- toolbar: [{ id: "aiti-doc-center-open", label: "文档", title: "文档中心:workspace 文档收集与全文检索", icon: { svg: '<path d="M12 7v14"/><path d="M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"/>' } }],
612
- rightFileDock: [{ id: "docs", label: "文档" }],
613
- pages: [{ id: "aiti-doc-center-page", label: "文档中心", title: "aiti-doc-center:文档中心" }],
610
+ toolbar: [{ id: "aiti-doc-center-open", label: "i18n:dc.app.label", title: "i18n:dc.app.title", icon: { svg: '<path d="M12 7v14"/><path d="M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"/>' } }],
611
+ rightFileDock: [{ id: "docs", label: "i18n:dc.app.label" }],
612
+ pages: [{ id: "aiti-doc-center-page", label: "i18n:it.aiti-doc-center-page.label", title: "i18n:it.aiti-doc-center-page.label" }],
614
613
  i18n: {
615
- zh: {
614
+ "zh-CN": {
615
+ "dc.app.label": "文档",
616
+ "dc.app.title": "文档中心:workspace 文档收集与全文检索",
616
617
  "dc.tabsDir": "目录",
617
618
  "dc.tabsTime": "时间",
618
619
  "dc.tabsSession": "会话",
@@ -701,8 +702,31 @@ const ext = {
701
702
  "dc.ftAddPh": "新增标签(回车确认;/ 分层级)",
702
703
  "dc.ftAdd": "添加",
703
704
  "dc.ftActionTitle": "标签(文档中心:查看/增删,非 md 文件打 tag 后进索引)",
705
+ "it.docs.title": "文档",
706
+ "it.aiti-doc-center-page.label": "文档中心",
707
+ "ext.displayName": "文档中心",
704
708
  },
705
709
  en: {
710
+ "it.docs.title": "Doc Center: workspace doc collection & full-text search",
711
+ "feat.scan.roots.desc": "Comma/newline separated (supports ~). For precise tag layering use root|alias form; scans all workspace roots when empty",
712
+ "feat.scan.excludes.desc": "Comma-separated dir names or globs (*.tmp); also honors .gitignore automatically",
713
+ "feat.scan.maxFileKB.desc": "Above this size only metadata is indexed, not the body",
714
+ "feat.watch.enabled.desc": "fs.watch event-driven near-real-time re-indexing; falls back automatically when dir count exceeds 50k",
715
+ "feat.tags.planTag.desc": "Namespace word for plan-status tags (plan/reviewing/adopted…); drives the plan review panel",
716
+ "feat.agentTools.enabled.desc": "Injects aiti_doc_* tools into sessions (off by default; enable temporarily via the AI helper 🤖 or the extension manager)",
717
+ "it.aiti-doc-center-page.label": "Doc Center",
718
+ "it.docs.title": "Docs",
719
+ "ext.displayName": "Doc Center",
720
+ "ext.description": "Searches the workspace doc center (FTS full-text + weighted fusion ranking). Params: query (required, ≥3 chars works best), tag (optional, e.g. plan, docs), limit (optional, default 8). Returns docs with snippet highlights (path/title/updated/tags).",
721
+ "feat.aiti-doc-center-page": "Doc Center",
722
+ "feat.scan.roots": "Scan roots",
723
+ "feat.scan.excludes": "Excluded dirs",
724
+ "feat.scan.maxFileKB": "Per-file cap (KB)",
725
+ "feat.watch.enabled": "Live watching",
726
+ "feat.tags.planTag": "Plan tag word",
727
+ "feat.agentTools.enabled": "AI tool (M4)",
728
+ "dc.app.label": "Docs",
729
+ "dc.app.title": "Doc center: workspace doc collection & full-text search",
706
730
  "dc.tabsDir": "Folder",
707
731
  "dc.tabsTime": "Time",
708
732
  "dc.tabsSession": "Sessions",
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@aiti-ai/aiti-doc-center",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
- "description": "文档中心扩展(workspace md 收集/整理/FTS5 trigram 全文检索 + tag 六来源两层 + PageRank)—— 方案 docs/aiti-doc-center-plan.md",
5
+ "description": "workspace markdown collection/organization/search — FTS5 trigram Chinese full-text + tag seven-source two-layer + 📚 float dialog four views",
6
6
  "scripts": {
7
7
  "test": "node --experimental-strip-types --test doc-core.test.mjs",
8
8
  "deploy": "node tools/deploy.mjs",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "aitiExtProtocol": "1.0",
20
20
  "license": "MIT",
21
- "contentHash": "f4101e103f35891b",
21
+ "contentHash": "fd3a7b49a13556cd",
22
22
  "repository": {
23
23
  "type": "git",
24
24
  "url": "git+https://github.com/aiti-ai/aiti-ai.git",
@@ -1,8 +1,11 @@
1
1
  ---
2
2
  name: doc-search
3
3
  title: 搜索文档中心
4
+ title.en: "Search the doc center"
4
5
  placeholder: 想找什么文档?给关键词(如:方案、git-trace、全文检索)
6
+ placeholder.en: "What to find? Keywords (e.g. plan, git-trace, full-text search)"
5
7
  summary: 在 workspace 文档中心做全文检索(FTS5 + 权重融合排序),返回带 snippet 高亮的文档清单(路径/标题/更新时间/tags)。支持 tag 过滤(如 方案、docs、design)。
8
+ summary.en: "Full-text search over the workspace doc center (FTS5 + weighted ranking); returns a doc list with highlighted snippets (path/title/updated time/tags). Supports tag filters (e.g. plans, docs, design)."
6
9
  outputs:
7
10
  format: json-obj
8
11
  schema: