holy-agents-kits 0.4.0 → 0.5.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
@@ -1,6 +1,6 @@
1
1
  # holy-agents-kits
2
2
 
3
- > 一组可直接加载的 Agent Skill:Jenkins 流水线与控制器、基于 new-api 的应用开发与命令行运维、代码图谱检索、选择性分支同步、规则层治理、文档内容管理、Skill 本身怎么开发与校验。
3
+ > 一组可直接加载的 Agent Skill:Jenkins 流水线与控制器、基于 new-api 的应用开发与命令行运维、代码图谱检索、选择性分支同步、规则层治理、文档内容管理、知识可视化、Skill 本身怎么开发与校验。
4
4
  > 一条命令装进你的 agent。
5
5
 
6
6
  ```bash
@@ -51,6 +51,11 @@ mindmap
51
51
  图形与伪代码表达
52
52
  过程产物禁入
53
53
  agent 手记与时效分层
54
+ knowledge-surface
55
+ Markdown 库一眼全图
56
+ canvas 树披露式明细
57
+ 关联边有据可查
58
+ 单文件离线交付
54
59
  skill-creator-v2
55
60
  Skill 骨架生成
56
61
  正文拆分 references
@@ -68,6 +73,7 @@ mindmap
68
73
  | `fy-newapi-cli` | 在终端运维 new-api:用户、渠道、Token、日志、套餐 | 「登进 new-api 看下渠道」「给它建个 API key」 |
69
74
  | `rules-layer-governance` | 给 AGENTS.md / SKILL.md 这类规则文件做立法、瘦身、下沉门禁与独立复核 | 「AGENTS.md 太肥了」「把规则下沉成脚本门禁」 |
70
75
  | `human-docs` | 文档按读者分离:给人看的表达层 + 给 agent 的记忆层 | 「写份给人看的文档」「这笔记下个上下文就忘了」 |
76
+ | `knowledge-surface` | 把 Markdown 文档库变成一眼全图 + 披露式明细的可探索界面 | 「把这堆文档做成脑图」「给我个能钻进去的知识图谱」 |
71
77
  | `skill-creator-v2` | 开发、拆分、校验、评测 Skill 本身 | 「写一个 skill」「SKILL.md 太长」 |
72
78
 
73
79
  两个 Jenkins 技能互为边界:`jenkins-cli` 只管流水线,`jenkins-controller` 只管控制器本身,触发时不会互相抢。
@@ -104,7 +110,7 @@ npx holy-agents-kits install jenkins-cli --force
104
110
 
105
111
  **卸载**:删除 `~/.agents/skills/<skill-name>` 目录即可。安装器不会写注册表,不会留残留。
106
112
 
107
- ## 九个技能分别做什么
113
+ ## 十个技能分别做什么
108
114
 
109
115
  ### analysis-codegraph —— 按符号查代码
110
116
 
@@ -170,6 +176,14 @@ npx holy-agents-kits install jenkins-cli --force
170
176
 
171
177
  **边界**:不管文档内容的正确性,也不替项目决定文档放哪;它管的是表达方式与记忆结构。
172
178
 
179
+ ### knowledge-surface —— 文档库变成一眼全图的可探索界面
180
+
181
+ **可观察行为**:一条命令把 Markdown 目录构建成单文件 HTML(数据内嵌、双击即开)——canvas 树布局、分组配色、hover 出一句话摘要、点开见渲染后的全文、Esc 关闭;关联边只由共享概念词推出,位置关系的边明确标注「同文件相邻」;自带构建自检(摘要缺失、孤儿节点必须为 0)。
182
+
183
+ **用法**:说「把这堆文档做成能点的知识图谱」,agent 先盘结构写 `surface.config.json`(分组 / 摘要段),再跑 `scripts/build_surface.mjs`,按 QA 清单全图体检 + 披露体检后交付。
184
+
185
+ **边界**:只管「结构 → 图 → 披露」的呈现范式;不做检索索引、不产出内容。语料超过 800 节点要按组拆多张图,不是硬塞一张画布。
186
+
173
187
  ### skill-creator-v2 —— 技能本身的开发与评测
174
188
 
175
189
  **可观察行为**:生成三段式技能骨架;把超长正文拆到 `references/` 并在原处留指针;跑规范校验(行数、frontmatter、引用完整性、代码外泄);按反馈迭代 `description`。
@@ -191,6 +205,7 @@ holy-agents-kits/
191
205
  │ ├── fy-newapi-cli/ SKILL.md
192
206
  │ ├── rules-layer-governance/ SKILL.md + references/ + templates/
193
207
  │ ├── human-docs/ SKILL.md + references/
208
+ │ ├── knowledge-surface/ SKILL.md + references/ + scripts/ + assets/
194
209
  │ └── skill-creator-v2/ SKILL.md + references/ + scripts/
195
210
  ├── bin/cli.js 安装器(零依赖)
196
211
  ├── FEEDBACK.md issue 上报入口与必填信息
@@ -227,6 +242,7 @@ npx holy-agents-kits feedback
227
242
  - `git-selective-branch-sync` 针对同一仓库内的两个分支,跨仓库搬运不适用。
228
243
  - `skill-creator-v2` 的触发率评测脚本依赖 `claude` CLI;本机没有时走人工跑用例的降级路径,技能里写明了。
229
244
  - `rules-layer-governance` 与 `human-docs` 是纯方法论技能,不需要外部服务、机器或凭据;`rules-layer-governance` 的门禁脚本由技能内的 `templates/` 生成,落到项目里再按项目自己的路径改。
245
+ - `knowledge-surface` 的构建脚本零依赖,只需 Node ≥ 18;`--echarts` 指定本地 `echarts.min.js` 则产物离线自包含,不给则走 CDN(需联网打开)。
230
246
  - 本仓库只放技能与方法,不含业务代码、部署包和任何真实凭据。
231
247
 
232
248
  ## 许可
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "holy-agents-kits",
3
- "version": "0.4.0",
4
- "description": "Agent Skills 合集:Jenkins 流水线、Jenkins 控制器、new-api 应用与 CLI、代码图谱分析、选择性分支同步、规则层治理、文档内容管理、Skill 开发与校验。一条命令装进你的 agent。",
3
+ "version": "0.5.0",
4
+ "description": "Agent Skills 合集:Jenkins 流水线、Jenkins 控制器、new-api 应用与 CLI、代码图谱分析、选择性分支同步、规则层治理、文档内容管理、知识可视化、Skill 开发与校验。一条命令装进你的 agent。",
5
5
  "bin": {
6
6
  "holy-agents-kits": "bin/cli.js"
7
7
  },
@@ -32,6 +32,8 @@
32
32
  "ci",
33
33
  "rules-governance",
34
34
  "documentation",
35
+ "knowledge-graph",
36
+ "visualization",
35
37
  "claude",
36
38
  "trae"
37
39
  ],
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: knowledge-surface
3
+ description: 把 Markdown 文档库变成「一眼全图 + 披露式明细」的可探索界面——解析结构成节点树、推断关联、渲染成图型(canvas 树/力导向),hover 见摘要、点开见全文,配统一的层级与配色审美。适合语料大到线性阅读会迷路、读者需要先看全局再钻细节的场合。触发词:脑图、知识图谱、可视化导航、把文档做成界面、图型化、结构图、一眼全图、文档可视化。
4
+ ---
5
+
6
+ # 知识表面 · 一眼全图的披露式可视化
7
+
8
+ 把「一摞 Markdown」变成一个**能一眼看完、并且能逐层钻进去**的界面。
9
+
10
+ 核心范式四步,缺一步就退化成「把 md 渲染成大号列表」:
11
+
12
+ | 步 | 做什么 | 判据 |
13
+ |---|---|---|
14
+ | 1 结构化 | 文档 → 节点树 | 标题层级即结构;容器节点带分组色,叶节点带一句话摘要 |
15
+ | 2 图型化 | 节点 → 图形 | canvas 树 / 力导向,不是列表、不是表格、不是目录页 |
16
+ | 3 一眼全图 | 全貌进一次视野 | 全展开时节点不重叠、标签自动降级、规模数字可读 |
17
+ | 4 披露式明细 | 概览 → 摘要 → 全文 三级 | hover 出一句话,点开出全文,Esc 关闭,明细可滚动 |
18
+
19
+ 审美不是装饰:配色、字号梯度、对比度、密度策略是「一眼全图」能否成立的前提 → `references/disclosure-and-style.md`。
20
+
21
+ **边界**:只管「结构 → 图 → 披露」的呈现范式。不产出内容、不做检索索引与文档地图、不判分与出题、不做文档治理(`human-docs`)、不写学习材料。
22
+
23
+ ## §1 骨架流程
24
+
25
+ 1. **盘结构** —— 数一下语料:几个文件、标题几级、什么算叶节点、分组怎么切 → 落一份 `surface.config.json`(分组映射 / 摘要段 / 叶节点正则)。语料若已有既定分组(人工校定的领域划分),照抄不重造。
26
+ 2. **解析** —— `node scripts/build_surface.mjs --in <语料目录> --out <产物>.html` → 出单文件界面(内嵌数据,双击可开)。自检:节点数合理、叶节点摘要非空、孤儿节点为 0。
27
+ 3. **全图体检** —— 打开产物第一件事是**全展开**:节点平铺无重叠?标签密度自动降级了?分组色可辨?规模数字可读?不合格先调分组/配色/密度阈值,别急着加功能。
28
+ 4. **披露体检** —— hover 出摘要?点开出全文?Esc 关闭?长文能滚?关联节点可点跳转?明细排版(标题/引用/列表/代码)读得下去?
29
+ 5. **接外部数据** —— 明细需要外部内容(深挖层、音频、进度接口)时,在 viewer 里接 `/api/*`;写清「谁消费、是否已接线」,未接线就别留按钮。
30
+ 6. **交付** —— 交付物→消费方对照表 + 启动指令 + 已知限制(不写过程产物、不写内部路径)。
31
+
32
+ ## §2 核心逻辑
33
+
34
+ - **结构默认取标题层级** —— md 的 H1→H4 天然是树;「卡片」写法(`### 卡 1 · 标题`)本来就是 H3,不用另写解析器。只有当标记出现在正文而非标题时,才用 `--leaf-pattern` 正则。
35
+ - **分组不靠猜** —— 默认按目录切;目录拍平时写 `config.groups`(正则匹配文件名 → 域)。人工校准过的分组信息比自动聚类可信。
36
+ - **叶节点要有摘要** —— 摘要缺失 = 界面退化成目录。取 designated 段,没有就取正文第一段实质内容(跳过纯标签行、表格行、代码块),**在句边界截断**。
37
+ - **关联要诚实** —— 关键词交集是实关联;同组/相邻只是位置关系,UI 上必须标成「同组」而不是编一个关键词。详见 `references/relations.md`。
38
+ - **规模超限要拆** —— 单元 > 800 或全展开标签必然重叠时,按组切成多个 surface,而不是硬塞一张画布。
39
+ - **要精确行号就别建图** —— 读者要「跳到第 N 行」时,图不如索引;这类需求交给文档索引类技能。
40
+
41
+ ## §3 核心循环
42
+
43
+ ```
44
+ 盘结构 → 解析 → 全图体检 → 披露体检 → (不合格) 回解析 / 调阈值
45
+ └──── 全通过 → 接数据 → 交付
46
+ ```
47
+
48
+ **退出条件**:全展开一屏可读(无重叠、无 NaN 坐标)+ 叶节点摘要非空 + 搜索能定位 + 明细三段齐全(标题/摘要/正文)+ 关联边有来源标注。
49
+
50
+ ## §4 脚本
51
+
52
+ ```bash
53
+ node scripts/build_surface.mjs --help # 参数与用法
54
+ node scripts/build_surface.mjs --in ./docs --out ./surface.html \
55
+ --config ./docs/surface.config.json --echarts ./vendor/echarts.min.js
56
+ ```
57
+
58
+ 产出单文件 HTML(数据内嵌,双击即开);`--echarts` 给本地文件则离线自包含,不给则走 CDN 并在页面上给出失败提示。
59
+
60
+ ## §5 参考文件
61
+
62
+ - `references/parsing.md` —— 盘结构与写 `surface.config.json` 时读:分组映射、摘要段、叶节点正则、摘要截断规则
63
+ - `references/relations.md` —— 调关联质量或解释边来源时读:关键词抽取、加权计分、honesty 约束
64
+ - `references/rendering.md` —— 画布不听话时读:ECharts 配方 + **必须避开的坑清单**(状态残留、展开态归属、坐标 NaN、密度阈值)
65
+ - `references/disclosure-and-style.md` —— 做明细排版或调观感时读:三级披露、色板、字号梯度、密度策略
66
+ - `references/qa.md` —— 交付前逐条过:全图、披露、搜索、性能、自检
67
+
68
+ > 反馈:本技能来自 [holy-agents-kits](https://github.com/monsterbude123/holy-agents-kits)。发现错误、缺步骤或命令跑不通,直接开 issue:https://github.com/monsterbude123/holy-agents-kits/issues/new
@@ -0,0 +1,401 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>知识表面</title>
7
+ <style>
8
+ :root {
9
+ --bg:#0F172A; --panel:#1B2336; --muted-bg:#272F42; --line:#475569;
10
+ --fg:#F8FAFC; --dim:#94A3B8; --accent:#22C55E; --gold:#F59E0B; --bad:#EF4444; --link:#5B9DFF;
11
+ }
12
+ * { box-sizing:border-box; margin:0; }
13
+ html,body { height:100%; }
14
+ body { background:var(--bg); color:var(--fg); font:14px/1.6 "IBM Plex Sans","Segoe UI",system-ui,"Microsoft YaHei",sans-serif; overflow:hidden; }
15
+ #topbar { display:flex; align-items:center; gap:12px; padding:10px 16px; border-bottom:1px solid var(--line); background:var(--panel); }
16
+ #topbar h1 { font-size:16px; font-weight:600; white-space:nowrap; }
17
+ #search { flex:0 1 320px; background:#111A2E; border:1px solid var(--line); border-radius:8px; color:var(--fg); padding:7px 12px; font:inherit; }
18
+ #search:focus { outline:1px solid var(--accent); }
19
+ #hitcount, #scale { color:var(--dim); font-size:12px; white-space:nowrap; }
20
+ button.tb { background:transparent; color:var(--dim); border:1px solid var(--line); border-radius:8px; padding:6px 12px; cursor:pointer; font-size:12px; white-space:nowrap; }
21
+ button.tb:hover { color:var(--fg); border-color:var(--accent); }
22
+ .hint { color:var(--dim); font-size:11px; white-space:nowrap; }
23
+ #stage { position:absolute; top:53px; bottom:0; left:0; right:0; }
24
+ #loading { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:var(--dim); }
25
+ #legend { position:fixed; right:14px; top:66px; display:flex; flex-direction:column; gap:7px; z-index:10; background:rgba(15,23,42,.82); padding:10px 12px; border-radius:10px; border:1px solid var(--line); }
26
+ .lg { display:flex; align-items:center; gap:5px; font-size:12px; color:var(--dim); cursor:pointer; }
27
+ .lg:hover { color:var(--fg); }
28
+ .lg i { width:10px; height:10px; border-radius:3px; display:inline-block; }
29
+ #warn { position:fixed; left:50%; transform:translateX(-50%); top:62px; z-index:20; background:#2A1F12; border:1px solid var(--gold); color:#FCD9A4; border-radius:10px; padding:8px 14px; font-size:12px; max-width:82vw; display:none; }
30
+ #pop { position:fixed; display:none; width:min(600px, 92vw); max-height:min(78vh, 760px); background:var(--panel); border:1px solid var(--line); border-radius:14px; box-shadow:0 18px 50px rgba(0,0,0,.55); z-index:30; flex-direction:column; overflow:hidden; }
31
+ #pop.open { display:flex; }
32
+ #pophead { display:flex; align-items:flex-start; gap:10px; padding:14px 16px 10px; border-bottom:1px solid var(--line); background:var(--muted-bg); }
33
+ #ptitle { flex:1; font-size:15px; font-weight:600; line-height:1.5; }
34
+ #popclose { background:transparent; border:1px solid var(--line); color:var(--dim); border-radius:8px; width:30px; height:30px; cursor:pointer; font-size:14px; flex:none; }
35
+ #popclose:hover { color:var(--fg); border-color:var(--bad); }
36
+ #popmeta { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:6px; }
37
+ .badge { font-size:11px; padding:2px 10px; border-radius:999px; border:1px solid var(--line); color:var(--dim); }
38
+ #popbody { flex:1; overflow:auto; padding:12px 16px 16px; }
39
+ #popbody h4 { color:var(--link); margin:14px 0 6px; font-size:13.5px; }
40
+ #popbody h4:first-child { margin-top:2px; }
41
+ #popbody blockquote { border-left:3px solid var(--accent); background:#12291E; color:#CFEEDB; padding:9px 13px; margin:8px 0; border-radius:6px; font-size:13px; }
42
+ #popbody li { margin:4px 0 4px 18px; color:#D6DCE8; }
43
+ #popbody p { margin:6px 0; }
44
+ #popbody code { background:#111A2E; padding:1px 6px; border-radius:4px; font-size:12px; color:#A5D6FF; }
45
+ #popbody hr { border:0; border-top:1px solid var(--line); margin:12px 0; }
46
+ #popbody .essence { color:#E2E8F0; background:#1F2A3E; border-left:3px solid var(--gold); padding:8px 12px; border-radius:6px; margin-bottom:6px; }
47
+ .chips { display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
48
+ .chip { background:#111A2E; border:1px solid var(--line); color:var(--fg); border-radius:999px; padding:4px 12px; font-size:12px; cursor:pointer; }
49
+ .chip:hover { border-color:var(--accent); }
50
+ .chip b { color:var(--link); font-weight:500; }
51
+ .chip i { color:var(--dim); font-style:normal; }
52
+ </style>
53
+ </head>
54
+ <body>
55
+ <div id="topbar">
56
+ <h1 id="ttl">知识表面</h1>
57
+ <input id="search" placeholder="搜标题 / 摘要 / 关键词" autocomplete="off">
58
+ <span id="hitcount"></span>
59
+ <span id="scale"></span>
60
+ <button class="tb" id="expandall">展开全部</button>
61
+ <button class="tb" id="collapseall">收起</button>
62
+ <span class="hint">滚轮缩放 · 拖拽平移 · 点节点展开/收起 · 悬浮看摘要 · 点卡片出明细</span>
63
+ </div>
64
+ <div id="stage"><div id="loading">载入图谱…</div></div>
65
+ <div id="legend"></div>
66
+ <div id="warn"></div>
67
+
68
+ <div id="pop">
69
+ <div id="pophead">
70
+ <div style="flex:1">
71
+ <div id="popmeta"></div>
72
+ <div id="ptitle"></div>
73
+ </div>
74
+ <button id="popclose" title="关闭 (Esc)">✕</button>
75
+ </div>
76
+ <div id="popbody"></div>
77
+ </div>
78
+
79
+ __ECHARTS_TAG__
80
+ <script>const SURFACE = __SURFACE_JSON__;</script>
81
+ <script>
82
+ const $ = s => document.querySelector(s);
83
+ const S = SURFACE;
84
+ const byId = new Map(S.nodes.map(n => [n.id, n]));
85
+ /* 同名节点计数:标题撞车时,明细卡的关联条目必须带上下文,否则用户分不清跳到哪个 */
86
+ const titleCount = new Map();
87
+ for (const n of S.nodes) titleCount.set(n.title, (titleCount.get(n.title) || 0) + 1);
88
+ const parentTitle = id => { const p = byId.get(id); const q = p && p.parentId ? byId.get(p.parentId) : null; return q ? q.title : ''; };
89
+ const kidsOf = new Map();
90
+ for (const n of S.nodes) {
91
+ if (!n.parentId) continue;
92
+ if (!kidsOf.has(n.parentId)) kidsOf.set(n.parentId, []);
93
+ kidsOf.get(n.parentId).push(n);
94
+ }
95
+ const GCOLOR = new Map(S.groups.map(g => [g.id, g.color]));
96
+ const collapsed = new Map(); // 用户展开态(id -> collapsed):唯一真相源,重建时从这里读回
97
+ const LABEL_LIMIT = 40; // 可见叶节点超过这个数 → 只画点不画标签
98
+ let query = '', chart = null, treeCache = null, hitSet = new Set();
99
+
100
+ const esc = s => String(s == null ? '' : s)
101
+ .replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
102
+
103
+ /* ---------- markdown(明细正文) ---------- */
104
+ function md2html(src) {
105
+ const lines = String(src || '').split(/\r?\n/);
106
+ const inline = s => esc(s)
107
+ .replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>').replace(/`([^`]+)`/g, '<code>$1</code>');
108
+ let out = '', list = false;
109
+ const closeList = () => { if (list) { out += '</ul>'; list = false; } };
110
+ for (const raw of lines) {
111
+ if (/^###\s/.test(raw)) { closeList(); out += '<h4>' + inline(raw.replace(/^###\s*/, '')) + '</h4>'; }
112
+ else if (/^####\s/.test(raw)) { closeList(); out += '<h4>' + inline(raw.replace(/^####\s*/, '')) + '</h4>'; }
113
+ else if (/^>\s?/.test(raw)) { closeList(); out += '<blockquote>' + inline(raw.replace(/^>\s?/, '')) + '</blockquote>'; }
114
+ else if (/^[-*]\s+/.test(raw)) { if (!list) { out += '<ul>'; list = true; } out += '<li>' + inline(raw.replace(/^[-*]\s+/, '')) + '</li>'; }
115
+ else if (/^---+$/.test(raw.trim())) { closeList(); out += '<hr>'; }
116
+ else if (!raw.trim()) { closeList(); }
117
+ else { closeList(); out += '<p>' + inline(raw) + '</p>'; }
118
+ }
119
+ closeList();
120
+ return out;
121
+ }
122
+
123
+ /* ---------- 命中判定 ---------- */
124
+ function hitText(n) {
125
+ return (n.title + ' ' + (n.summary || '') + ' ' + (n.keywords || []).join(' ') + ' '
126
+ + (n.body || '') + ' ' + (n.file || '')).toLowerCase();
127
+ }
128
+ function computeHits() {
129
+ hitSet = new Set();
130
+ const q = query.toLowerCase();
131
+ if (!q) return;
132
+ for (const n of S.nodes) if (n.type !== 'root' && hitText(n).includes(q)) hitSet.add(n.id);
133
+ }
134
+ /* ---------- 树构建 ---------- */
135
+ /**
136
+ * 默认展开到第几层:在「可见节点数 ≤ 预算」的前提下的最深一层。
137
+ * 文档库动辄几百个叶子,全展开就是一团毛线;骨架全图才是一眼能看懂的地图。
138
+ */
139
+ const NODE_BUDGET = 120;
140
+ function autoLevel() {
141
+ const byDepth = new Map();
142
+ let maxDepth = 0;
143
+ for (const n of S.nodes) {
144
+ const d = n.depth || 0;
145
+ if (d > maxDepth) maxDepth = d;
146
+ byDepth.set(d, (byDepth.get(d) || 0) + 1);
147
+ }
148
+ let level = 0, sum = 0;
149
+ for (let d = 0; d <= maxDepth; d++) {
150
+ sum += byDepth.get(d) || 0;
151
+ if (sum <= NODE_BUDGET) level = d; else break;
152
+ }
153
+ return level;
154
+ }
155
+ const AUTO_LEVEL = autoLevel();
156
+ function defaultCollapsed(n) {
157
+ const kids = kidsOf.get(n.id) || [];
158
+ if (!kids.length) return false;
159
+ return (n.depth || 0) >= AUTO_LEVEL; // 这一层往下默认收起
160
+ }
161
+ function visibleLeafCount() {
162
+ let c = 0;
163
+ const walk = n => {
164
+ const isCollapsed = collapsed.has(n.id) ? collapsed.get(n.id) : defaultCollapsed(n);
165
+ if (isCollapsed) return;
166
+ if (n.type === 'leaf') { c++; return; }
167
+ (kidsOf.get(n.id) || []).forEach(walk);
168
+ };
169
+ (kidsOf.get('root') || []).forEach(walk);
170
+ return c;
171
+ }
172
+ function buildTree() {
173
+ computeHits();
174
+ const vis = visibleLeafCount();
175
+ const searching = !!query;
176
+ const showLeafLabels = searching ? true : vis <= LABEL_LIMIT;
177
+ const colorOf = n => GCOLOR.get(n.group) || '#64748B';
178
+ const mk = n => {
179
+ const t = { id: n.id, name: n.title, raw: n, children: (kidsOf.get(n.id) || []).map(mk) };
180
+ const isHit = searching && hitSet.has(n.id);
181
+ const dim = searching && !isHit && n.type !== 'root' && n.type !== 'group';
182
+ if (n.type === 'root') {
183
+ t.symbolSize = 14;
184
+ t.itemStyle = { color: '#F8FAFC' };
185
+ t.label = { position: 'right', distance: 10, fontSize: 15, fontWeight: 700, color: '#F8FAFC' };
186
+ } else if (n.type === 'group') {
187
+ t.symbolSize = 12;
188
+ t.itemStyle = { color: colorOf(n) };
189
+ t.label = { position: 'right', distance: 9, fontSize: 14, fontWeight: 700, color: colorOf(n) };
190
+ } else if (n.type === 'file') {
191
+ t.symbolSize = 9;
192
+ t.itemStyle = { color: colorOf(n) };
193
+ t.label = {
194
+ position: 'right', distance: 8, fontSize: 12.5, fontWeight: 600,
195
+ color: isHit ? '#F59E0B' : '#F8FAFC',
196
+ backgroundColor: 'rgba(15,23,42,.72)', padding: [1, 3], borderRadius: 3, // 长标题互相压字时仍可读
197
+ };
198
+ } else {
199
+ t.symbolSize = n.type === 'section' ? 6.5 : 5.5;
200
+ t.itemStyle = { color: n.type === 'empty' ? '#64748B' : colorOf(n) + 'CC' };
201
+ t.label = {
202
+ show: showLeafLabels, position: 'right', distance: 6, fontSize: 11.5,
203
+ color: isHit ? '#F59E0B' : '#C7CFDC', fontWeight: isHit ? 700 : 400,
204
+ opacity: dim ? .35 : 1,
205
+ };
206
+ }
207
+ // 搜索态:命中项及其祖先链强制展开,其余收起(根节点永远展开,否则整图消失)
208
+ if (searching) {
209
+ t.collapsed = !(isHit || hasHitDescendant(n.id));
210
+ } else {
211
+ t.collapsed = collapsed.has(n.id) ? collapsed.get(n.id) : defaultCollapsed(n);
212
+ }
213
+ return t;
214
+ };
215
+ const rootNode = byId.get('root');
216
+ return [mk(rootNode)];
217
+ }
218
+ function hasHitDescendant(id) {
219
+ for (const k of (kidsOf.get(id) || [])) {
220
+ if (hitSet.has(k.id)) return true;
221
+ if (hasHitDescendant(k.id)) return true;
222
+ }
223
+ return false;
224
+ }
225
+
226
+ /* ---------- 渲染 ---------- */
227
+ function fullOption() {
228
+ return {
229
+ backgroundColor: 'transparent',
230
+ tooltip: {
231
+ trigger: 'item', triggerOn: 'mousemove', enterable: false,
232
+ backgroundColor: '#1B2336', borderColor: '#475569', borderWidth: 1,
233
+ padding: [10, 14], textStyle: { color: '#F8FAFC', fontSize: 12 },
234
+ extraCssText: 'border-radius:10px;box-shadow:0 10px 30px rgba(0,0,0,.5);',
235
+ formatter: tooltipHtml,
236
+ },
237
+ series: [{
238
+ type: 'tree', data: JSON.parse(JSON.stringify(treeCache)), orient: 'LR', edgeShape: 'curve',
239
+ expandAndCollapse: true, roam: true,
240
+ top: '2%', left: '5%', bottom: '2%', right: '28%',
241
+ lineStyle: { width: 1.1, color: '#33415C' },
242
+ emphasis: { focus: 'none', itemStyle: { shadowBlur: 12, shadowColor: 'rgba(34,197,94,.35)' } },
243
+ }],
244
+ };
245
+ }
246
+ function renderTree() {
247
+ treeCache = buildTree();
248
+ chart.setOption(fullOption(), true); // notMerge:tree 系列的 merge 会残留旧内部状态
249
+ }
250
+
251
+ /* ---------- tooltip:摘要(一句话) ---------- */
252
+ function tooltipHtml(params) {
253
+ const d = params.data && params.data.raw;
254
+ if (!d) return '';
255
+ const color = GCOLOR.get(d.group) || '#94A3B8';
256
+ if (d.type === 'root') {
257
+ return `<div><b>${esc(d.title)}</b><br><span style="color:#94A3B8">${S.counts.files} 文件 · ${S.counts.groups} 组 · ${S.counts.leaves} 叶节点</span></div>`;
258
+ }
259
+ if (d.type === 'group') {
260
+ const kids = (kidsOf.get(d.id) || []).length;
261
+ return `<div><b style="color:${color}">${esc(d.title)}</b><br><span style="color:#94A3B8">${kids} 个文件 · 点开看内容</span></div>`;
262
+ }
263
+ const sum = d.summary ? `<div style="color:#C7CFDC">${esc(d.summary)}</div>` : '<div style="color:#EF4444">(无摘要)</div>';
264
+ return `<div style="max-width:340px;white-space:normal;line-height:1.6">
265
+ <div style="color:${color};font-size:11px;margin-bottom:4px">${esc(d.file || d.title)}</div>
266
+ <div style="font-weight:600;margin-bottom:6px">${esc(d.title)}</div>
267
+ ${sum}
268
+ <div style="color:#94A3B8;font-size:11px;margin-top:6px">点击查看完整内容</div></div>`;
269
+ }
270
+
271
+ /* ---------- 明细卡(披露第二层) ---------- */
272
+ function showPop(n, px, py) {
273
+ const color = GCOLOR.get(n.group) || '#94A3B8';
274
+ $('#popmeta').innerHTML =
275
+ `<span class="badge" style="border-color:${color};color:${color}">${esc((S.groups.find(g => g.id === n.group) || {}).name || '—')}</span>` +
276
+ (n.file ? `<span class="badge">${esc(n.file)}</span>` : '') +
277
+ `<span class="badge">${esc(n.type)}</span>`;
278
+ $('#ptitle').textContent = n.title;
279
+ const rel = (n.links || []).map(l => {
280
+ const r = byId.get(l.id); if (!r) return '';
281
+ const why = l.basis === 'kw' ? (l.shared && l.shared[0] ? l.shared[0] : '关键词') : '同文件相邻';
282
+ const t = r.title.length > 24 ? r.title.slice(0, 24) + '…' : r.title;
283
+ // 标题在语料里不唯一 → 补一段上下文(父级小节名),否则关联条目指代不清
284
+ const ctx = (titleCount.get(r.title) || 0) > 1 ? ` <i>· ${esc(parentTitle(l.id) || r.file || '')}</i>` : '';
285
+ return `<span class="chip" data-rel="${esc(l.id)}">${esc(t)}${ctx} <i>· ${esc(why)}</i></span>`;
286
+ }).join('');
287
+ const body = n.body ? md2html(n.body) : '<p style="color:#94A3B8">(该节点无正文)</p>';
288
+ $('#popbody').innerHTML =
289
+ (n.summary ? `<h4>一句话</h4><div class="essence">${esc(n.summary)}</div>` : '') +
290
+ `<h4>全文</h4>${body}` +
291
+ (rel ? `<h4>关联</h4><div class="chips">${rel}</div>` : '');
292
+ document.querySelectorAll('.chip').forEach(c => c.onclick = () => jumpTo(c.dataset.rel));
293
+ const pop = $('#pop');
294
+ pop.classList.add('open');
295
+ const w = Math.min(600, innerWidth * .92), h = Math.min(760, innerHeight * .78);
296
+ pop.style.left = Math.max(10, Math.min(px + 20, innerWidth - w - 12)) + 'px';
297
+ pop.style.top = Math.max(60, Math.min(py - 20, innerHeight - h - 12)) + 'px';
298
+ $('#popbody').scrollTop = 0;
299
+ }
300
+ const hidePop = () => $('#pop').classList.remove('open');
301
+
302
+ /* ---------- 跳转:展开祖先 + 高亮 ---------- */
303
+ function jumpTo(id) {
304
+ const n = byId.get(id); if (!n) return;
305
+ const targets = new Set([id]);
306
+ let p = n.parentId;
307
+ while (p) { targets.add(p); const x = byId.get(p); p = x ? x.parentId : null; }
308
+ const walk = node => {
309
+ node.children && node.children.forEach(walk);
310
+ if (targets.has(node.id)) { node.collapsed = false; collapsed.set(node.id, false); }
311
+ };
312
+ walk(treeCache[0]);
313
+ renderTree();
314
+ flash(id);
315
+ hidePop();
316
+ }
317
+ function flash(id) {
318
+ const paint = arr => arr.forEach(n => {
319
+ if (n.id === id) { n.__saved = n.label; n.label = Object.assign({}, n.label || {}, { color: '#F59E0B', fontWeight: 800, fontSize: 13 }); }
320
+ if (n.children) paint(n.children);
321
+ });
322
+ paint(treeCache);
323
+ renderTree();
324
+ setTimeout(() => {
325
+ const restore = arr => arr.forEach(n => {
326
+ if (n.id === id && n.__saved) { n.label = n.__saved; delete n.__saved; }
327
+ if (n.children) restore(n.children);
328
+ });
329
+ restore(treeCache);
330
+ renderTree();
331
+ }, 1600);
332
+ }
333
+
334
+ /* ---------- 顶栏 / 图例 ---------- */
335
+ function paintCounts() {
336
+ const c = S.counts;
337
+ $('#scale').textContent = `${c.files} 文件 · ${c.groups} 组 · ${c.leaves} 叶节点 · ${c.linked} 有关联 · 默认展开 ${AUTO_LEVEL + 1} 层`;
338
+ $('#hitcount').textContent = query ? `${hitSet.size} 个命中` : '';
339
+ }
340
+ function renderLegend() {
341
+ $('#legend').innerHTML = S.groups.map(g => `<span class="lg" data-g="${esc(g.id)}"><i style="background:${g.color}"></i>${esc(g.name)}</span>`).join('');
342
+ document.querySelectorAll('.lg').forEach(el => el.onclick = () => {
343
+ const g = byId.get('g:' + el.dataset.g);
344
+ if (g) jumpTo(g.id);
345
+ });
346
+ }
347
+
348
+ /* ---------- 启动 ---------- */
349
+ function start() {
350
+ if (!window.echarts) {
351
+ $('#loading').innerHTML = '<span style="color:#EF4444">ECharts 未加载(离线环境请用 --echarts 指定本地 echarts.min.js)</span>';
352
+ return;
353
+ }
354
+ document.title = S.title || '知识表面';
355
+ $('#ttl').textContent = S.title || '知识表面';
356
+ renderLegend();
357
+ paintCounts();
358
+ if (S.warnings && S.warnings.length) {
359
+ const w = $('#warn');
360
+ w.textContent = '⚠ ' + S.warnings.join(' · ');
361
+ w.style.display = 'block';
362
+ w.onclick = () => { w.style.display = 'none'; };
363
+ }
364
+ const load = $('#loading');
365
+ load && load.remove(); // echarts.init 会清空容器 → 先移除,再 init
366
+ chart = echarts.init($('#stage'));
367
+ renderTree();
368
+ chart.on('click', params => {
369
+ const d = params.data && params.data.raw; if (!d) return;
370
+ if (d.type === 'leaf' || d.type === 'empty') {
371
+ showPop(d, params.event.offsetX, params.event.offsetY);
372
+ return;
373
+ }
374
+ // 非叶节点 = 展开/收起。params.collapsed 是「切换后」的状态,必须回写,否则重建时丢
375
+ collapsed.set(d.id, !!params.collapsed);
376
+ renderTree();
377
+ });
378
+ chart.getZr().on('click', e => { if (!e.target) hidePop(); });
379
+ window.addEventListener('resize', () => chart.resize());
380
+ $('#search').oninput = e => { query = e.target.value.trim(); renderTree(); paintCounts(); };
381
+ $('#expandall').onclick = () => {
382
+ const walk = n => { collapsed.set(n.id, false); (kidsOf.get(n.id) || []).forEach(walk); };
383
+ walk(byId.get('root'));
384
+ renderTree();
385
+ };
386
+ $('#collapseall').onclick = () => {
387
+ const walk = n => {
388
+ const kids = kidsOf.get(n.id) || [];
389
+ collapsed.set(n.id, n.type !== 'root' && kids.length > 0);
390
+ kids.forEach(walk);
391
+ };
392
+ walk(byId.get('root'));
393
+ renderTree();
394
+ };
395
+ $('#popclose').onclick = hidePop;
396
+ document.addEventListener('keydown', e => { if (e.key === 'Escape') hidePop(); });
397
+ }
398
+ start();
399
+ </script>
400
+ </body>
401
+ </html>
@@ -0,0 +1,9 @@
1
+ # references 索引
2
+
3
+ 本目录下每个文件都是 SKILL.md 正文的溢出内容,按需读取。
4
+
5
+ - `parsing.md` —— 盘语料结构、写 `surface.config.json`、调摘要与叶节点规则时读
6
+ - `relations.md` —— 调关联质量、解释边的来源、判断一条边该不该存在时读
7
+ - `rendering.md` —— 画布不听话(节点不显示、状态丢失、标签压字)时读,含 16 条坑清单
8
+ - `disclosure-and-style.md` —— 做明细排版、调配色/字号/密度时读
9
+ - `qa.md` —— 交付前逐条过:全图、披露、搜索、性能、自检、交付口径
@@ -0,0 +1,78 @@
1
+ # 披露与审美
2
+
3
+ 「一眼全图」和「披露式明细」是同一个动作的两端:图负责让人知道**有什么、在哪、叫什么**;明细负责让人**读下去**。审美不是装饰——配色、字号梯度、对比度、密度策略直接决定「一眼全图」能不能成立。
4
+
5
+ ## 1. 三级披露
6
+
7
+ | 级 | 载体 | 内容 | 触发 |
8
+ |---|---|---|---|
9
+ | 概览 | 画布节点 + 顶栏计数 | 分组色、标题、规模数字 | 打开页面 |
10
+ | 摘要 | tooltip | 一句话(≤140 字)+ 文件名 | 悬浮 |
11
+ | 全文 | 明细面板 | 标题 / 一句话 / 正文(渲染后的 md) | 点叶节点 |
12
+
13
+ 明细面板的段序固定:**标签 chips(分组 / 文件名 / 节点类型) → 标题 → 一句话 → 正文**。先给定位,再给内容。
14
+
15
+ - 正文渲染要保留 md 结构:标题、列表、引用块、行内代码、代码块。
16
+ - 长文必须可滚动,面板本身不撑破视口。
17
+ - `Esc` 关闭,点空白关闭;关掉后不残留遮罩。
18
+
19
+ ## 2. 色板(深色 OLED)
20
+
21
+ ```
22
+ --bg #0F172A 页面底
23
+ --panel #1B2336 面板 / tooltip
24
+ --muted #272F42 次级底
25
+ --line #475569 分隔线
26
+ --fg #F8FAFC 主文字
27
+ --dim #94A3B8 次要文字
28
+ --accent #22C55E 强调 / 命中态边框
29
+ --gold #F59E0B 搜索命中
30
+ --bad #EF4444 缺内容(无摘要)
31
+ --link #5B9DFF 关联链接
32
+ ```
33
+
34
+ 规则:
35
+
36
+ - 正文对底色对比度 ≥ 4.5:1;次要文字 ≥ 3:1。深色底上纯白刺眼,用 `#F8FAFC` 而非 `#FFFFFF`。
37
+ - **分组色是身份**,不是装饰:同一分组在全图、明细 chips、图例里必须是同一个颜色。
38
+ - 分组色要互相可辨(10 色板已按色相拉开),并且在深色底上都有足够亮度。
39
+ - 命中金色只给「被搜到」的东西,不要大面积用。
40
+ - 缺失信息用 `--bad` 明说「(无摘要)」,不要留空——留空会被当成「加载中」。
41
+
42
+ ## 3. 字号梯度
43
+
44
+ | 对象 | 字号 | 字重 |
45
+ |---|---|---|
46
+ | 根节点 | 15 | 700 |
47
+ | 分组 | 14 | 700 |
48
+ | 文件 | 12.5 | 600 |
49
+ | 叶/段 | 11.5 | 400(命中 700) |
50
+ | tooltip | 12 | 400 |
51
+
52
+ 层级靠**字号 + 字重 + 颜色**三重区分,不能只靠颜色(色盲、投影、截图都吃亏)。
53
+
54
+ ## 4. 密度策略
55
+
56
+ - 可见叶节点 ≤ 40:全标签。
57
+ - 超过 40:叶/段只画点不画标签,文件标签保留并加半透明底衬。
58
+ - 搜索态:**强制显示标签**(否则「搜到了却看不见」)。
59
+ - 点开一个分支只多展开那一支,其余保持收起——不要因为点开一个就把整棵树摊平。
60
+ - 图例放**右上竖排**,不要放左下浮层:左下是树的叶子密集区。
61
+
62
+ ## 5. 排版细节
63
+
64
+ - 标题不换行超过两行;过长时截断并在 tooltip/明细里给全名。
65
+ - tooltip 宽度封顶(`max-width:340px`),`white-space:normal`,多行可读。
66
+ - 正文里的表格、代码块要横向可滚,不要撑破面板。
67
+ - 明细里的**关联 chips**:显示目标标题,点了能跳到那个节点(跳过去后目标要展开并高亮)。
68
+ - 顶栏放规模数字(文件 / 组 / 叶节点 / 有关联 / 搜索命中数)——读者第一眼要知道这图有多大。
69
+
70
+ ## 6. 自检(审美向)
71
+
72
+ 改完配色/密度后,逐条对:
73
+
74
+ 1. 缩小窗口看分组色还认得出来吗?
75
+ 2. 截图给一个「不熟这个领域」的人看,他能说出「有哪些大块」吗?
76
+ 3. 悬浮时 tooltip 里的第一句话,单独看能懂吗?
77
+ 4. 点开明细后,正文里有没有跟图上一模一样的重复段落(有 = ownBody 规则没生效,见 parsing.md §2)?
78
+ 5. 全展开一次,标签有没有互相压字?压了就调 `LABEL_LIMIT`,别调字号到 9px 以下。