minecodex 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/features/images/src/library-prompt-page.mjs +1 -1
- package/features/notes/DESIGN.md +8 -2
- package/features/notes/README.md +3 -1
- package/features/notes/assets/default-prompts.json +170 -0
- package/features/notes/assets/dsh-prompt-LICENSE.txt +24 -0
- package/features/notes/src/default-prompts.mjs +29 -0
- package/features/notes/src/product.mjs +2 -0
- package/features/notes/src/quick-prompts-page.mjs +15 -10
- package/features/session-status/src/session-status.mjs +3 -3
- package/features/unread-inbox/src/unread-inbox.mjs +2 -2
- package/features/usage-meter/src/usage-meter.mjs +1 -1
- package/package.json +1 -1
- package/packages/runtime-host/src/codex-injection.mjs +12 -8
- package/packages/runtime-host/src/feature-tooltips.mjs +65 -0
|
@@ -178,7 +178,7 @@ async function scan() {
|
|
|
178
178
|
copy.type = "button";
|
|
179
179
|
function copyFeedback(copied = false, failed = false) {
|
|
180
180
|
const text = failed ? label("Try copying again", "重试复制") : copied ? label("Copied", "已复制") : label("Copy prompt", "复制提示词");
|
|
181
|
-
copy.
|
|
181
|
+
copy.setAttribute("data-minecodex-tooltip", text);
|
|
182
182
|
copy.setAttribute("aria-label", text);
|
|
183
183
|
copy.replaceChildren(copyGlyph(copied));
|
|
184
184
|
}
|
package/features/notes/DESIGN.md
CHANGED
|
@@ -6,7 +6,7 @@ Prompts 页面负责新增、编辑、分类、Emoji、排序和统计;Quick P
|
|
|
6
6
|
## 原生依据
|
|
7
7
|
2026-09-27 在隔离 Codex 实测导航扩展区、Library 页面及 Add files and more。
|
|
8
8
|
- Prompts 导航项位于固定扩展区末尾,顺序跟随扩展区而非硬编码 Projects。仅定位 `data-app-navigation-rail`,不匹配设置菜单。
|
|
9
|
-
- Quick Prompts 位于 Add 与 Change permissions 之间,克隆 Add 的按钮 classes 与响应式图标容器。入口采用 Lucide book-open
|
|
9
|
+
- Quick Prompts 位于 Add 与 Change permissions 之间,克隆 Add 的按钮 classes 与响应式图标容器。入口采用 Lucide book-open;保留 16 / 20px 图标容器,viewBox 扩为 27,将图形缩小约 11%;non-scaling-stroke 保持 1.5px 笔画,热区仍为 28px。
|
|
10
10
|
- 页面沿用 Library 的大标题和胶囊 Tabs;分类图标取自当前 Codex 原生 SymbolBrowser / project appearance catalogue,记录于 `assets/native-prompt-icons.json`,不手绘路径。
|
|
11
11
|
|
|
12
12
|
| 角色 | Token / 权威来源 | 值或用途 |
|
|
@@ -29,7 +29,7 @@ Prompts 页面负责新增、编辑、分类、Emoji、排序和统计;Quick P
|
|
|
29
29
|
分类颜色复用原生选择器的亮 / 暗模式色值:blue #0285ff / #339cff、green #04b84c / #40c977、orange #fb6a22 / #ff8549、pink #ff66ad / #ff8cc1、purple #924ff7 / #ad7bf9、red #fa423e / #ff6764、yellow #ffc300 / #ffd240;black 使用原生次级文字 token。
|
|
30
30
|
|
|
31
31
|
## 页面
|
|
32
|
-
Header 为 Prompts;右侧依次为排序图标、分类调节图标、常驻搜索框、New prompt。搜索框直接采用原生 Library 的透明背景、1px outline、32px 高、胶囊圆角、12px 水平 padding 和 16px 搜索 SVG。分类管理使用原生 sliders 图标,不再放在 Tabs 行。排序菜单沿用原生 Library 的 4px gutter、20px radius、5px / 8px item padding、90% elevated surface 与 shadow-xl-spread。Tabs 仅包含 All、分类和 Other
|
|
32
|
+
Header 为 Prompts;右侧依次为排序图标、分类调节图标、常驻搜索框、New prompt。搜索框直接采用原生 Library 的透明背景、1px outline、32px 高、胶囊圆角、12px 水平 padding 和 16px 搜索 SVG。分类管理使用原生 sliders 图标,不再放在 Tabs 行。排序菜单沿用原生 Library 的 4px gutter、20px radius、5px / 8px item padding、90% elevated surface 与 shadow-xl-spread。Tabs 仅包含 All、分类和 Other。默认分类生图、编程、文案、研究、翻译、效率、思考、学习,允许新增、改名、删除、换图标和颜色。删除分类仅解除归属,保留提示词和统计。
|
|
33
33
|
|
|
34
34
|
分类管理在 440px 宽居中模态面板中完成,复用原生 New folder 弹窗的 20px padding、25px radius、弱描边与背景遮罩。分类编辑保留箭头返回和关闭按钮,不使用文字 Back 或整页替换。模态内限制 Tab 焦点,Escape 关闭后恢复入口焦点。提示词编辑使用同一结构,宽 520px。
|
|
35
35
|
|
|
@@ -64,3 +64,9 @@ Category 下拉面板与触发栏等宽、左右对齐,宽度包含内边距
|
|
|
64
64
|
|
|
65
65
|
## 语言
|
|
66
66
|
界面名称、操作、Tooltip、无障碍标签、空状态、错误提示与图标/颜色名称按 Codex 的语言显示中英文;日期按对应 locale 格式化。用户保存的提示词与分类名称原样展示,不随界面语言改写。
|
|
67
|
+
|
|
68
|
+
## 内置提示词与 Tooltip
|
|
69
|
+
|
|
70
|
+
内置 24 条来自 dsh-prompt 0.1.13 的 MIT 提示词,正文保持原样,按思考、学习、编程、效率分类并配 Emoji。来源与许可保存在 assets/dsh-prompt-LICENSE.txt。首次启动或旧库升级时单次导入;随后允许编辑和删除,重启不还原,也不重建被删除的分类。用户个人内容只保留在本机数据库,不纳入默认资源。
|
|
71
|
+
|
|
72
|
+
所有简短悬浮提示使用运行时的 data-minecodex-tooltip 标记,取原生 background/text/border-tooltip、radius-2xl、shadow-tooltip、tooltip-compact-font-weight 和 tracking-tooltip;padding 5px 12px、行高 18px。支持悬浮与键盘聚焦、Escape 关闭及卸载清理,不再使用浏览器 title 气泡。
|
package/features/notes/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## 管理页面
|
|
6
6
|
- All 与分类 Tabs,搜索、新增、编辑、删除。
|
|
7
|
-
-
|
|
7
|
+
- 默认分类:生图、编程、文案、研究、翻译、效率、思考、学习;支持新增、改名、删除与排序。
|
|
8
8
|
- 分类图标和颜色复用 Codex 原生 SymbolBrowser 的资源。单条提示词可设置一个 Emoji,否则继承分类图标。
|
|
9
9
|
- 使用右侧三横手柄拖拽调整组内顺序,也可按调用次数、最近调用排序。
|
|
10
10
|
- 删除分类会将提示词移至其他,保留正文、Emoji 和统计。
|
|
@@ -23,3 +23,5 @@
|
|
|
23
23
|
运行入口为 `src/main.mjs` → `quick-prompts-server.mjs`,仅开放提示词、分类、排序、调用记录及健康检查。页面经已认证 Runtime Host binding 访问固定允许的接口。旧 HTTP 服务、网页、Todo / Files 操作及文件清理代码已删除。`prompt-schema.mjs` 只负责向前迁移;`product.mjs` 负责提示词、分类和统计的事务读写。历史 Todo / Files 表保持原样。
|
|
24
24
|
|
|
25
25
|
服务仅监听 loopback,默认端口 47832。沿用 CODEX_NOTES_PORT、CODEX_NOTES_DATA_DIR、CODEX_NOTES_DATABASE。设计依据见 [DESIGN.md](./DESIGN.md)。入口采用 Lucide book-open,拖拽手柄采用 Lucide menu。分类 SVG 来自当前 Codex 原生图标目录,未手绘替代路径。
|
|
26
|
+
|
|
27
|
+
内置 24 条已分类、带 Emoji 的快捷提示词,来自 MIT 授权的 dsh-prompt 0.1.13。首次启动或升级仅导入一次,后续编辑与删除不会被覆盖。个人提示词不随包发布。来源和完整许可见 [dsh-prompt-LICENSE.txt](./assets/dsh-prompt-LICENSE.txt)。
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "dsh-fp",
|
|
4
|
+
"title": "第一性原理拆解",
|
|
5
|
+
"body": "请用第一性原理分析以下主题,按编号结构化输出,结论先行:\n1. 这个问题的基本组成单元是什么?\n2. 哪些是真正不可改变的真理(而非假设)?\n3. 如果去掉所有既有假设,问题本身还剩下什么?\n4. 有哪些被大多数人默认为常识、但其实可以颠覆的?\n5. 基于以上推演给出你的原创见解,并说明它与主流看法的差异。\n主题:",
|
|
6
|
+
"categoryId": "thinking",
|
|
7
|
+
"emoji": "🧱"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "dsh-socratic",
|
|
11
|
+
"title": "苏格拉底式追问",
|
|
12
|
+
"body": "请用苏格拉底式追问帮助我思考,按编号结构化输出:\n1. 先复述我当前的观点或核心假设;\n2. 提出 3 个最有力的质疑;\n3. 找出一个我尚未考虑到的视角;\n4. 如果你是深思熟虑的对话者,你会问我哪几个我没想到的问题?\n5. 追问结束后,把整个过程浓缩成一个更精准的问题。\n主题:",
|
|
13
|
+
"categoryId": "thinking",
|
|
14
|
+
"emoji": "❓"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "dsh-deep",
|
|
18
|
+
"title": "深度多维分析",
|
|
19
|
+
"body": "请从多个维度深度分析以下主题,按编号结构化输出,结论先行:\n1. 本质是什么?\n2. 有哪些常见的误解?\n3. 支持和反对的证据分别是什么?\n4. 这个问题的边界在哪里(什么情况下它不再成立)?\n5. 如果你必须做出一个判断,会是什么?\n6. 你最强的那个结论,弱点在哪里?\n主题:",
|
|
20
|
+
"categoryId": "thinking",
|
|
21
|
+
"emoji": "🔬"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "dsh-adversarial",
|
|
25
|
+
"title": "对抗式审查",
|
|
26
|
+
"body": "请对以下方案/结论做对抗式审查(红队角色),先给一段结论摘要,再按编号展开:\n1. 找出其中最强的 5 个假设,逐一论证它们可能如何失效;\n2. 构造最可能推翻它的 3 个反例或失败场景;\n3. 指出其中隐藏的认知偏差与利益相关方视角的盲区;\n4. 给出「如果这个方案失败,最可能的原因是什么」的排序清单;\n5. 最后给出:在何种条件下你才会认为它是错的——以及何种证据能让你改变立场。\n方案 / 结论:",
|
|
27
|
+
"categoryId": "thinking",
|
|
28
|
+
"emoji": "🛡️"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "dsh-decision",
|
|
32
|
+
"title": "决策博弈分析",
|
|
33
|
+
"body": "你是一位冷静的决策分析师。请分析我的处境,按编号结构化输出(你的选择仅作参考,重点是分析过程):\n1. 列出每个选项最坏的结果是什么;\n2. 每个选项最好的结果是什么;\n3. 最可能的结果是什么;\n4. 如果 10 年后回头看,我可能会后悔什么;\n5. 有没有哪条路是「没有回头路」的;\n6. 给出你本人的选择并说明理由;再指出我可能忽略的第三个选项。\n我的处境(选项与背景):",
|
|
34
|
+
"categoryId": "thinking",
|
|
35
|
+
"emoji": "⚖️"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "dsh-premortem",
|
|
39
|
+
"title": "事前验尸",
|
|
40
|
+
"body": "假设以下方案/项目已经在一年后彻底失败。请以「事后回溯」的方式写失败分析,按编号结构化输出:\n1. 按可能性从高到低列出 8 个失败原因;\n2. 对前 3 个原因,给出现在就能做的预防措施;\n3. 指出哪些早期信号现在就该监控;\n4. 最后说明:这个方案是否从一开始就有致命缺陷。\n方案描述:",
|
|
41
|
+
"categoryId": "thinking",
|
|
42
|
+
"emoji": "🚧"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "dsh-feynman",
|
|
46
|
+
"title": "费曼技巧",
|
|
47
|
+
"body": "请用费曼技巧确认我是否真正理解了以下概念,按编号结构化输出:\n1. 用最简单的语言、面向完全不懂的人解释这个概念(禁止术语);\n2. 给出 2 个生动类比和 2 个反例;\n3. 指出我理解中的错误或不准确之处;\n4. 设计 3 个判断题检验我是否真的懂了。\n概念:\n我的理解(可选):",
|
|
48
|
+
"categoryId": "learning",
|
|
49
|
+
"emoji": "💡"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "dsh-fivewhys",
|
|
53
|
+
"title": "五个为什么",
|
|
54
|
+
"body": "针对以下问题,请连续追问五个「为什么」,每层基于上一层的事实回答,最后区分根本原因与表层触发因素并给出解决方向:\n问题描述:",
|
|
55
|
+
"categoryId": "thinking",
|
|
56
|
+
"emoji": "🔎"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "dsh-mece",
|
|
60
|
+
"title": "MECE 拆解",
|
|
61
|
+
"body": "请用 MECE 原则拆解以下问题,按编号结构化输出:\n1. 给出 3~6 个相互独立(Mutually Exclusive)的分类维度;\n2. 每个维度下列出所有子项,确保完全穷尽(Collectively Exhaustive);\n3. 指出拆解中可能的遗漏与重叠;\n4. 给出按重要性排序后的关键子问题清单。\n问题:",
|
|
62
|
+
"categoryId": "thinking",
|
|
63
|
+
"emoji": "🧩"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "dsh-bias",
|
|
67
|
+
"title": "认知偏差检查",
|
|
68
|
+
"body": "请审查以下推理/计划/结论中的认知偏差,按编号结构化输出:\n1. 列出可能影响它的偏差(确认偏误、沉没成本、可得性、锚定、乐观/悲观偏差、群体思维等),并指出具体证据;\n2. 对每条偏差,给出「如何检验是否真的受影响」的方法;\n3. 给出一个反事实检验:如果结论被证明是错的,最可能因为哪条偏差?\n推理 / 计划 / 结论:",
|
|
69
|
+
"categoryId": "thinking",
|
|
70
|
+
"emoji": "🪞"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "dsh-learnpath",
|
|
74
|
+
"title": "学习路线设计",
|
|
75
|
+
"body": "请为以下领域/技能设计一条从零到可实战的学习路线,按编号结构化输出:\n1. 按阶段拆分(入门→进阶→实战),每个阶段给出学习目标;\n2. 每个阶段推荐 2~3 个核心主题和练习方式;\n3. 指出常见的「伪学习陷阱」(只收藏不练习等);\n4. 给出一个 30 天内可完成的最小闭环,以及检验掌握程度的基准。\n领域 / 技能:\n当前水平(可选):\n目标(可选):",
|
|
76
|
+
"categoryId": "learning",
|
|
77
|
+
"emoji": "🗺️"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "dsh-concept",
|
|
81
|
+
"title": "概念澄清",
|
|
82
|
+
"body": "请帮我彻底理解以下概念,按编号结构化输出:\n1. 一句话定义 + 一个最小例子;\n2. 它与常见相近概念的本质区别(各给一个对比场景);\n3. 这个概念在什么情况下不适用(边界);\n4. 给出 3 个由浅入深的练习场景让我检验理解。\n概念:\n相近概念(可选,不知道可留空,AI 自行选常见相近概念对比):",
|
|
83
|
+
"categoryId": "learning",
|
|
84
|
+
"emoji": "📖"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "dsh-quiz",
|
|
88
|
+
"title": "AI 反向考验",
|
|
89
|
+
"body": "请通过出题检验我是否真正理解了以下主题/交付内容:\n1. 设计选择题/判断题/简答题/案例题(由浅入深);\n2. 我作答后指出错误与盲区;\n3. 直到回答正确、知识点无盲区后再确认交付。\n主题 / 交付内容:",
|
|
90
|
+
"categoryId": "learning",
|
|
91
|
+
"emoji": "🎯"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "dsh-codereview",
|
|
95
|
+
"title": "代码审查",
|
|
96
|
+
"body": "请审查以下代码,先给总体结论,再按严重程度排序输出,每个问题附具体修改建议(含示例代码):\n1. 正确性:潜在 bug、边界条件、并发/异步问题;\n2. 安全:注入、鉴权、敏感信息、依赖风险;\n3. 可维护性:命名、结构、重复、可读性;\n4. 性能:明显的低效点。\n代码过长时可分段审查,但最终汇总为一页结论。\n代码 / 文件 / 技术栈:",
|
|
97
|
+
"categoryId": "code",
|
|
98
|
+
"emoji": "🔍"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": "dsh-testdesign",
|
|
102
|
+
"title": "测试用例设计",
|
|
103
|
+
"body": "请为以下功能设计测试用例,按编号结构化输出:\n1. 正常路径用例(含输入/预期输出);\n2. 边界与极端值用例;\n3. 异常与错误处理用例;\n4. 并发/重复/幂等场景(如适用);\n5. 指出哪些用例最容易漏、以及对应的风险。\n功能描述:",
|
|
104
|
+
"categoryId": "code",
|
|
105
|
+
"emoji": "🧪"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "dsh-refactor",
|
|
109
|
+
"title": "重构方案",
|
|
110
|
+
"body": "请为以下代码提出重构方案,按编号结构化输出:\n1. 指出当前结构的主要问题(职责、耦合、可测试性);\n2. 给出目标结构(抽象与拆分建议,含示例);\n3. 按「小步重构」顺序列出步骤,每一步可独立提交且行为不变;\n4. 指出哪些重构有风险、需要测试保护。\n代码 / 模块:",
|
|
111
|
+
"categoryId": "code",
|
|
112
|
+
"emoji": "🛠️"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"id": "dsh-explain",
|
|
116
|
+
"title": "解释代码",
|
|
117
|
+
"body": "请解释以下代码,按编号结构化输出:\n1. 这段代码做什么(一句话);\n2. 逐段讲解执行流程与关键数据结构;\n3. 指出其中「为什么这样写」的设计取舍;\n4. 指出潜在问题与改进点;\n5. 用一句话概括它在我更大的系统里扮演的角色。\n代码:",
|
|
118
|
+
"categoryId": "code",
|
|
119
|
+
"emoji": "💻"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "dsh-blindspot",
|
|
123
|
+
"title": "盲区检查",
|
|
124
|
+
"body": "在我开始以下任务之前,请帮我做一次盲区检查,按编号结构化输出:\n1. 我可能遗漏的关键变量有哪些?\n2. 潜在的风险与最容易忽略的影响因素?\n3. 哪些点需要提前决策、哪些可以后置?\n4. 给我一个 3 分钟内可完成的快速检查清单。\n我的计划(目标 / 约束):",
|
|
125
|
+
"categoryId": "productivity",
|
|
126
|
+
"emoji": "👁️"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": "dsh-snapshot",
|
|
130
|
+
"title": "零丢失快照",
|
|
131
|
+
"body": "请执行一次「零丢失快照」:\n1. 把我们从会话开始至今的关键信息,按「目的地 / 约束与偏好 / 已确认的决定 / 待决问题 / 雾区(隐约可见但还不清晰)」五类逐条列出——不压缩、不合并,宁可啰嗦不可省略;\n2. 每条标注出处(引用我原话);\n3. 单独列一节「可疑遗漏」:凡是我提过但你觉得与主线无关、太模糊或像执行细节而没纳入的,全部摆出并写明理由;\n4. 列完后停下等我逐条核对,确认后再落盘。",
|
|
132
|
+
"categoryId": "productivity",
|
|
133
|
+
"emoji": "📸"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"id": "dsh-kickoff",
|
|
137
|
+
"title": "任务启动",
|
|
138
|
+
"body": "在开始以下任务之前,请先确认起点并澄清细节,按编号结构化输出:\n1. 最终目标(要做什么);\n2. 当前进度(目前想到哪一步);\n3. 经验水平(新手 / 有经验 / 专家);\n4. 不熟悉的地方;\n5. 成功的标准;\n6. 通过提问澄清细节(成功标准之外还有哪些约束、有哪些风险现在就该知道)。\n最终目标:\n当前进度(可选):\n经验水平(新手 / 有经验 / 专家):\n不熟悉的地方(可选):",
|
|
139
|
+
"categoryId": "productivity",
|
|
140
|
+
"emoji": "🚀"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"id": "dsh-prototype",
|
|
144
|
+
"title": "原型验证",
|
|
145
|
+
"body": "请为以下主题/想法做原型验证,每轮输出保持克制(方向概要即可,不要太长):\n1. 给出 2~4 个方向差距很大的候选方案;\n2. 每个方向给出最小的验证方式(怎么快速试错);\n3. 由我选择和反馈,几轮后逐步收敛到满意的方向;\n4. 收敛后给出下一步的执行计划要点。\n主题 / 想法:",
|
|
146
|
+
"categoryId": "productivity",
|
|
147
|
+
"emoji": "🧫"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "dsh-plan",
|
|
151
|
+
"title": "执行计划",
|
|
152
|
+
"body": "请为以下目标制定执行计划,按编号结构化输出(时间安排是可调整的草案):\n1. 明确步骤(含顺序与依赖);\n2. 时间安排(每步预计时长/里程碑);\n3. 所需资源和工具;\n4. 交付物和验收标准;\n5. 风险和应对方案。\n目标:\n约束(可选):",
|
|
153
|
+
"categoryId": "productivity",
|
|
154
|
+
"emoji": "📋"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"id": "dsh-deviation",
|
|
158
|
+
"title": "记录偏离",
|
|
159
|
+
"body": "请担任我的过程记录员(多轮持续角色):从现在起,在每次交互后更新一份简洁的偏离记录,按编号结构化:\n1. 遇到了什么新的情况?\n2. 为什么改变了方案?\n3. 做了哪些关键决定?\n4. 对结果有什么影响?\n每次只输出「新增/变更」条目,不要重复已记录内容。",
|
|
160
|
+
"categoryId": "productivity",
|
|
161
|
+
"emoji": "📝"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"id": "dsh-retro",
|
|
165
|
+
"title": "过程复盘",
|
|
166
|
+
"body": "请帮我复盘刚刚完成的以下任务/项目,按编号结构化输出:\n1. 整体步骤回顾(实际 vs 计划的差异);\n2. 使用的资料和工具;\n3. 遇到的困难;\n4. 解决思路与可复用经验;\n5. 如果重来一次,哪些地方会做得不同?\n任务 / 项目:",
|
|
167
|
+
"categoryId": "productivity",
|
|
168
|
+
"emoji": "🔄"
|
|
169
|
+
}
|
|
170
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Default prompt text from dsh-prompt v0.1.13
|
|
2
|
+
https://github.com/FeatherHunter/dsh-prompt
|
|
3
|
+
|
|
4
|
+
MIT License
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2026 王辰浩
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import prompts from "../assets/default-prompts.json" with { type: "json" };
|
|
2
|
+
|
|
3
|
+
// 单次导入后全部归用户管理,删除和编辑不会在下次启动时被还原。
|
|
4
|
+
export function seedDefaultPrompts(db, now) {
|
|
5
|
+
db.exec("BEGIN IMMEDIATE");
|
|
6
|
+
try {
|
|
7
|
+
if (!db.prepare("SELECT 1 FROM metadata WHERE key = 'default_prompts_v1'").get()) {
|
|
8
|
+
const categoryOrder = db.prepare("SELECT COALESCE(MAX(sort_order), -1) + 1 AS n FROM prompt_categories").get().n;
|
|
9
|
+
const categories = [
|
|
10
|
+
["thinking", "思考", "flask", "purple"],
|
|
11
|
+
["learning", "学习", "book", "green"],
|
|
12
|
+
["code", "编程", "terminal", "blue"],
|
|
13
|
+
["productivity", "效率", "logs", "black"],
|
|
14
|
+
];
|
|
15
|
+
categories.forEach((row, i) => db.prepare("INSERT OR IGNORE INTO prompt_categories VALUES (?, ?, ?, ?, ?)").run(...row, categoryOrder + i));
|
|
16
|
+
const order = db.prepare("SELECT COALESCE(MAX(sort_order), -1) + 1 AS n FROM prompts").get().n;
|
|
17
|
+
const insert = db.prepare(`INSERT INTO prompts
|
|
18
|
+
(id,title,body,starred,created_at,updated_at,last_used_at,category_id,emoji,sort_order)
|
|
19
|
+
VALUES (?,?,?,0,?,?,?,?,?,?)`);
|
|
20
|
+
prompts.forEach((p, i) => insert.run(p.id, p.title, p.body, now, now, 0, p.categoryId, p.emoji, order + i));
|
|
21
|
+
db.prepare("INSERT INTO metadata VALUES ('default_prompts_v1', 1)").run();
|
|
22
|
+
db.prepare("UPDATE metadata SET value = value + 1 WHERE key = 'revision'").run();
|
|
23
|
+
}
|
|
24
|
+
db.exec("COMMIT");
|
|
25
|
+
} catch (error) {
|
|
26
|
+
db.exec("ROLLBACK");
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { seedDefaultPrompts } from "./default-prompts.mjs";
|
|
1
2
|
import { migratePromptSchema } from "./prompt-schema.mjs";
|
|
2
3
|
import { randomUUID } from "node:crypto";
|
|
3
4
|
import { chmod, mkdir, open as openFile } from "node:fs/promises";
|
|
@@ -120,6 +121,7 @@ export class CodexNotesProduct {
|
|
|
120
121
|
);
|
|
121
122
|
try {
|
|
122
123
|
migratePromptSchema(this.db);
|
|
124
|
+
seedDefaultPrompts(this.db, this.clock());
|
|
123
125
|
} catch (error) {
|
|
124
126
|
this.close();
|
|
125
127
|
throw error;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const ICONS = {
|
|
2
2
|
prompt:
|
|
3
|
-
'<svg\n class="lucide lucide-book-open"\n xmlns="http://www.w3.org/2000/svg"\n width="24"\n height="24"\n viewBox="
|
|
3
|
+
'<svg\n class="lucide lucide-book-open"\n xmlns="http://www.w3.org/2000/svg"\n width="24"\n height="24"\n viewBox="-1.5 -1.5 27 27"\n fill="none"\n stroke="currentColor"\n stroke-width="1.5"\n stroke-linecap="round"\n stroke-linejoin="round"\n>\n <path vector-effect="non-scaling-stroke" d="M12 7v14" />\n <path vector-effect="non-scaling-stroke" 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" />\n</svg>',
|
|
4
4
|
chevron:
|
|
5
5
|
'<!-- @license lucide-static v0.577.0 - ISC -->\n<svg\n class="lucide lucide-chevron-down"\n xmlns="http://www.w3.org/2000/svg"\n width="24"\n height="24"\n viewBox="0 0 24 24"\n fill="none"\n stroke="currentColor"\n stroke-width="2"\n stroke-linecap="round"\n stroke-linejoin="round"\n>\n <path d="m6 9 6 6 6-6" />\n</svg>\n',
|
|
6
6
|
search:
|
|
@@ -194,7 +194,7 @@ function control(label, handler, className = "qp-command", iconName = null) {
|
|
|
194
194
|
node.setAttribute("aria-label", label);
|
|
195
195
|
if (iconName) {
|
|
196
196
|
node.append(icon(iconName));
|
|
197
|
-
node.
|
|
197
|
+
node.setAttribute("data-minecodex-tooltip", label);
|
|
198
198
|
}
|
|
199
199
|
node.addEventListener("click", handler);
|
|
200
200
|
return node;
|
|
@@ -395,11 +395,13 @@ function sync() {
|
|
|
395
395
|
close();
|
|
396
396
|
if (!button) {
|
|
397
397
|
button = add.cloneNode(false);
|
|
398
|
+
button.removeAttribute("title");
|
|
399
|
+
button.removeAttribute("aria-describedby");
|
|
398
400
|
button.removeAttribute("id");
|
|
399
401
|
button.removeAttribute("data-composer-navigation-target");
|
|
400
402
|
button.setAttribute(MARKER, "button");
|
|
401
403
|
button.setAttribute("aria-label", text("Quick Prompts", "快捷提示词"));
|
|
402
|
-
button.
|
|
404
|
+
button.setAttribute("data-minecodex-tooltip", text("Quick Prompts", "快捷提示词"));
|
|
403
405
|
button.setAttribute("aria-haspopup", "dialog");
|
|
404
406
|
button.setAttribute("aria-expanded", "false");
|
|
405
407
|
button.setAttribute("data-state", "closed");
|
|
@@ -549,7 +551,7 @@ let pagePopup = null;
|
|
|
549
551
|
let popupTrigger = null;
|
|
550
552
|
function pageIcon(label, name, handler) {
|
|
551
553
|
const button = control(label, handler, "pm-icon", name);
|
|
552
|
-
button.
|
|
554
|
+
button.setAttribute("data-minecodex-tooltip", label);
|
|
553
555
|
return button;
|
|
554
556
|
}
|
|
555
557
|
function closePagePopup(restoreFocus = false) {
|
|
@@ -859,10 +861,10 @@ function orderControls(item, ordered, isCategory, row) {
|
|
|
859
861
|
() => {},
|
|
860
862
|
);
|
|
861
863
|
handle.classList.add("pm-drag");
|
|
862
|
-
handle.
|
|
864
|
+
handle.setAttribute("data-minecodex-tooltip", text(
|
|
863
865
|
"Drag to reorder · Alt + ↑ / ↓",
|
|
864
866
|
"拖拽排序 · Alt + ↑ / ↓",
|
|
865
|
-
);
|
|
867
|
+
));
|
|
866
868
|
row.dataset.orderId = item.id;
|
|
867
869
|
const group = isCategory ? "categories" : `prompts:${item.categoryId ?? ""}`;
|
|
868
870
|
row.dataset.orderGroup = group;
|
|
@@ -1115,7 +1117,7 @@ function editPrompt(item = null) {
|
|
|
1115
1117
|
emojiButton.replaceChildren(
|
|
1116
1118
|
categoryIcon({ categoryId: category.value || null, emoji: emoji.value }),
|
|
1117
1119
|
);
|
|
1118
|
-
emojiButton.
|
|
1120
|
+
emojiButton.setAttribute("data-minecodex-tooltip", text("Choose icon", "选择图标"));
|
|
1119
1121
|
}
|
|
1120
1122
|
refreshAppearance();
|
|
1121
1123
|
const body = element("textarea");
|
|
@@ -1311,7 +1313,7 @@ function editCategory(category = null) {
|
|
|
1311
1313
|
).documentElement;
|
|
1312
1314
|
btn.replaceChildren(svg);
|
|
1313
1315
|
btn.setAttribute("aria-pressed", String(key === selectedIcon));
|
|
1314
|
-
btn.
|
|
1316
|
+
btn.setAttribute("data-minecodex-tooltip", appearanceLabel(key));
|
|
1315
1317
|
btn.setAttribute("aria-label", appearanceLabel(key));
|
|
1316
1318
|
icons.append(btn);
|
|
1317
1319
|
}
|
|
@@ -1334,7 +1336,7 @@ function editCategory(category = null) {
|
|
|
1334
1336
|
swatch.append(element("span", "pm-swatch"));
|
|
1335
1337
|
btn.replaceChildren(swatch);
|
|
1336
1338
|
btn.setAttribute("aria-pressed", String(key === selectedColor));
|
|
1337
|
-
btn.
|
|
1339
|
+
btn.setAttribute("data-minecodex-tooltip", appearanceLabel(key));
|
|
1338
1340
|
btn.setAttribute("aria-label", appearanceLabel(key));
|
|
1339
1341
|
colors.append(btn);
|
|
1340
1342
|
}
|
|
@@ -1455,13 +1457,16 @@ function syncNavigation() {
|
|
|
1455
1457
|
}
|
|
1456
1458
|
if (!navButton?.isConnected) {
|
|
1457
1459
|
navButton = source.cloneNode(false);
|
|
1460
|
+
navButton.removeAttribute("id");
|
|
1461
|
+
navButton.removeAttribute("title");
|
|
1462
|
+
navButton.removeAttribute("aria-describedby");
|
|
1458
1463
|
navButton.removeAttribute("data-sidebar-destination");
|
|
1459
1464
|
navButton.removeAttribute("data-selected");
|
|
1460
1465
|
navButton.removeAttribute("aria-current");
|
|
1461
1466
|
navButton.removeAttribute("data-suppress-active-style");
|
|
1462
1467
|
navButton.setAttribute(MARKER, "nav");
|
|
1463
1468
|
navButton.setAttribute("aria-label", text("Prompts", "提示词"));
|
|
1464
|
-
navButton.
|
|
1469
|
+
navButton.setAttribute("data-minecodex-tooltip", text("Prompts", "提示词"));
|
|
1465
1470
|
const inner = element("span", source.firstElementChild?.className ?? "");
|
|
1466
1471
|
const glyph = icon("prompt-nav");
|
|
1467
1472
|
glyph.setAttribute("aria-hidden", "true");
|
|
@@ -47,7 +47,7 @@ style.textContent = `
|
|
|
47
47
|
[data-minecodex-context-trigger]:focus-visible { outline:2px solid var(--color-ring); }
|
|
48
48
|
[data-minecodex-context-trigger] svg { width:12px; height:12px; }
|
|
49
49
|
[data-minecodex-native-context] { display:none !important; }
|
|
50
|
-
[data-minecodex-context-tooltip] { position:fixed; z-index:2147483000; pointer-events:none; width:max-content; padding:5px 12px; border:1px solid var(--color-border-tooltip); border-radius:var(--radius-2xl); background:var(--color-background-tooltip); color:var(--color-text-tooltip); box-shadow:var(--shadow-tooltip); font-family:var(--font-sans-default); font-size:var(--text-sm); line-height:18px; text-align:center; white-space:pre-line; }
|
|
50
|
+
[data-minecodex-context-tooltip] { position:fixed; z-index:2147483000; pointer-events:none; width:max-content; padding:5px 12px; border:1px solid var(--color-border-tooltip); border-radius:var(--radius-2xl); background:var(--color-background-tooltip); color:var(--color-text-tooltip); box-shadow:var(--shadow-tooltip); font-family:var(--font-sans-default); font-size:var(--text-sm); line-height:18px; font-weight:var(--tooltip-compact-font-weight); letter-spacing:var(--tracking-tooltip); text-align:center; white-space:pre-line; }
|
|
51
51
|
@media (prefers-reduced-motion:reduce) { [data-minecodex-session-reveal], [data-context-progress] { transition:none; } }
|
|
52
52
|
[${MARKER}] button { box-sizing:border-box; display:inline-flex; align-items:center; gap:6px; height:22px; color:inherit; font:inherit; border:0; border-radius:var(--radius-xl,12px); background:transparent; padding:3px 6px; cursor:pointer; white-space:nowrap; }
|
|
53
53
|
[${MARKER}] svg, [data-minecodex-session-status-panel] h3 svg { width:14px; height:14px; flex:none; stroke-width:1.75; }
|
|
@@ -288,7 +288,7 @@ function appendMixBar(dl, title, parts) {
|
|
|
288
288
|
const segment = document.createElement("span");
|
|
289
289
|
segment.dataset.tone = tone;
|
|
290
290
|
segment.style.width = `${amount / total * 100}%`;
|
|
291
|
-
segment.
|
|
291
|
+
segment.setAttribute("data-minecodex-tooltip", `${name} ${percent(amount)}%`);
|
|
292
292
|
bar.append(segment);
|
|
293
293
|
}
|
|
294
294
|
dl.append(bar);
|
|
@@ -351,7 +351,7 @@ function showPanel(kind) {
|
|
|
351
351
|
const segment = document.createElement("span");
|
|
352
352
|
segment.dataset.segment = kind;
|
|
353
353
|
segment.style.width = `${amount / snapshot.contextWindow * 100}%`;
|
|
354
|
-
segment.
|
|
354
|
+
segment.setAttribute("data-minecodex-tooltip", copy[kind === "tools" ? "toolHistory" : kind]);
|
|
355
355
|
bar.append(segment);
|
|
356
356
|
}
|
|
357
357
|
panel.insertBefore(head, dl);
|
|
@@ -242,7 +242,7 @@ function renderRows(details = activityRecords()) {
|
|
|
242
242
|
device.className = "mcx-device";
|
|
243
243
|
const remote = item.hostId !== "local";
|
|
244
244
|
device.innerHTML = deviceGlyphs[remote ? "remote" : "local"];
|
|
245
|
-
device.
|
|
245
|
+
device.setAttribute("data-minecodex-tooltip", text("Remote", "远程"));
|
|
246
246
|
device.setAttribute("aria-label", device.title);
|
|
247
247
|
header.append(title);
|
|
248
248
|
if (remote) header.append(device);
|
|
@@ -265,7 +265,7 @@ function renderRows(details = activityRecords()) {
|
|
|
265
265
|
const time = document.createElement("time");
|
|
266
266
|
time.dateTime = new Date(item.timestamp).toISOString();
|
|
267
267
|
time.textContent = elapsed;
|
|
268
|
-
time.
|
|
268
|
+
time.setAttribute("data-minecodex-tooltip", new Date(item.timestamp).toLocaleString());
|
|
269
269
|
header.append(time);
|
|
270
270
|
}
|
|
271
271
|
card.append(header);
|
|
@@ -53,7 +53,7 @@ style.id = STYLE_ID;
|
|
|
53
53
|
style.textContent = `
|
|
54
54
|
[${MARKER}] { position:relative; display:flex; align-items:center; justify-content:center; flex:none; -webkit-app-region:no-drag; }
|
|
55
55
|
[${MARKER}] .mcx-usage-ring { display:block; width:24px; height:24px; overflow:visible; }
|
|
56
|
-
[${MARKER}] .mcx-usage-number { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:inherit; font-family:var(--font-sans-default); font-size:calc(var(--text-xs) * 2 / 3); line-height:1; font-weight:500; letter-spacing:0; font-variant-numeric:tabular-nums; pointer-events:none; }
|
|
56
|
+
[${MARKER}] .mcx-usage-number { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:inherit; font-family:var(--font-sans-default); font-size:calc(var(--text-xs) * 2 / 3); line-height:1; font-weight:var(--font-weight-medium,500); letter-spacing:0; font-variant-numeric:tabular-nums; pointer-events:none; }
|
|
57
57
|
[${MARKER}] [data-window="weekly"] { color:inherit; }
|
|
58
58
|
[${MARKER}] [data-window="fiveHour"] { color:var(--color-text-secondary); }
|
|
59
59
|
#${TIP_ID} { position:fixed; z-index:2147483000; width:max-content; max-width:calc(100vw - 16px); pointer-events:none; user-select:none; padding:5px 12px; border:1px solid var(--color-border-tooltip); border-radius:var(--radius-2xl); background:var(--color-background-tooltip); color:var(--color-text-tooltip); box-shadow:var(--shadow-tooltip); font-family:var(--font-sans-default); font-size:var(--text-sm); line-height:18px; font-weight:var(--tooltip-compact-font-weight); letter-spacing:var(--tracking-tooltip); }
|
package/package.json
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// 该字符串经 CDP 注入后独立执行,因此 install 函数体必须自包含;
|
|
3
3
|
// CodexRuntime 与 CDP 客户端在 codex-runtime.mjs / codex-cdp.mjs。
|
|
4
4
|
|
|
5
|
+
import { installFeatureTooltips } from "./feature-tooltips.mjs";
|
|
5
6
|
import { randomBytes } from "node:crypto";
|
|
6
7
|
import { CODEX_THEME_TOKENS, CODEX_THEME_TOKEN_ALIASES } from "./codex-design-contract.mjs";
|
|
7
8
|
|
|
8
|
-
export const RUNTIME_VERSION =
|
|
9
|
+
export const RUNTIME_VERSION = 102;
|
|
9
10
|
export const HOST_BINDING_NAME = "__codexPersonalHostAction";
|
|
10
11
|
export const CSP_BOOTSTRAP_VERSION = 1;
|
|
11
12
|
export const CSP_BOOTSTRAP_KEY = "__mineCodexCspBootstrapVersion";
|
|
@@ -119,14 +120,14 @@ export function createInjectionSource(features, {
|
|
|
119
120
|
bindingToken = "test-binding-token",
|
|
120
121
|
runtimeSessionId = randomBytes(16).toString("hex"),
|
|
121
122
|
} = {}) {
|
|
122
|
-
function install(config) {
|
|
123
|
+
function install(config, installTooltips) {
|
|
123
124
|
if (window.top !== window) return;
|
|
124
125
|
if (!document.documentElement) {
|
|
125
126
|
// The document bootstrap runs before the root element exists. Defer the
|
|
126
127
|
// whole install until the DOM is ready instead of crashing on a null
|
|
127
128
|
// documentElement (which previously left the runtime permanently absent
|
|
128
129
|
// after a renderer reload).
|
|
129
|
-
document.addEventListener("DOMContentLoaded", () => install(config), { once: true });
|
|
130
|
+
document.addEventListener("DOMContentLoaded", () => install(config, installTooltips), { once: true });
|
|
130
131
|
return;
|
|
131
132
|
}
|
|
132
133
|
const currentRuntime = window.__codexPersonalRuntime;
|
|
@@ -138,6 +139,7 @@ export function createInjectionSource(features, {
|
|
|
138
139
|
currentRuntime?.dispose?.();
|
|
139
140
|
|
|
140
141
|
const lifetime = new AbortController();
|
|
142
|
+
installTooltips(lifetime.signal);
|
|
141
143
|
const rightPanelRouteKinds = new Set(config.rightPanelRouteKinds);
|
|
142
144
|
|
|
143
145
|
const entryMarker = "data-codex-personal-feature";
|
|
@@ -1497,7 +1499,7 @@ export function createInjectionSource(features, {
|
|
|
1497
1499
|
button.replaceChildren(createModelSelectorIcon(starred ? selector.icons.unstar : selector.icons.star));
|
|
1498
1500
|
const itemLabel = item.querySelector("[data-codex-model-slider-name]")?.textContent ?? label;
|
|
1499
1501
|
button.setAttribute("aria-label", selector.strings[starred ? "unstar" : "star"].replace("{model}", itemLabel));
|
|
1500
|
-
button.setAttribute("
|
|
1502
|
+
button.setAttribute("data-minecodex-tooltip", selector.strings[starred ? "unstar" : "star"].replace("{model}", itemLabel));
|
|
1501
1503
|
}
|
|
1502
1504
|
renderEnhancedModelMenu(menu, selector);
|
|
1503
1505
|
}
|
|
@@ -1559,7 +1561,7 @@ export function createInjectionSource(features, {
|
|
|
1559
1561
|
star.type = "button";
|
|
1560
1562
|
star.setAttribute("data-codex-model-slider-star", starred ? "unstar" : "star");
|
|
1561
1563
|
star.setAttribute("aria-label", selector.strings[starred ? "unstar" : "star"].replace("{model}", display));
|
|
1562
|
-
star.setAttribute("
|
|
1564
|
+
star.setAttribute("data-minecodex-tooltip", selector.strings[starred ? "unstar" : "star"].replace("{model}", display));
|
|
1563
1565
|
star.append(createModelSelectorIcon(starred ? selector.icons.unstar : selector.icons.star));
|
|
1564
1566
|
row.append(star);
|
|
1565
1567
|
item.replaceChildren(row);
|
|
@@ -3285,7 +3287,7 @@ export function createInjectionSource(features, {
|
|
|
3285
3287
|
const pressed = String(open);
|
|
3286
3288
|
const state = open ? "open" : "closed";
|
|
3287
3289
|
if (entry.getAttribute("aria-label") !== label) entry.setAttribute("aria-label", label);
|
|
3288
|
-
if (entry.getAttribute("
|
|
3290
|
+
if (entry.getAttribute("data-minecodex-tooltip") !== label) entry.setAttribute("data-minecodex-tooltip", label);
|
|
3289
3291
|
if (entry.getAttribute("aria-pressed") !== pressed) entry.setAttribute("aria-pressed", pressed);
|
|
3290
3292
|
if (entry.getAttribute("aria-expanded") !== pressed) entry.setAttribute("aria-expanded", pressed);
|
|
3291
3293
|
if (entry.getAttribute("data-state") !== state) entry.setAttribute("data-state", state);
|
|
@@ -4262,8 +4264,10 @@ export function createInjectionSource(features, {
|
|
|
4262
4264
|
if (!button) return null;
|
|
4263
4265
|
const label = summaryButtonLabel(feature);
|
|
4264
4266
|
button.setAttribute(entryMarker, feature.id);
|
|
4267
|
+
button.removeAttribute("title");
|
|
4268
|
+
button.removeAttribute("aria-describedby");
|
|
4265
4269
|
button.setAttribute("aria-label", label);
|
|
4266
|
-
button.setAttribute("
|
|
4270
|
+
button.setAttribute("data-minecodex-tooltip", label);
|
|
4267
4271
|
button.setAttribute("aria-pressed", "false");
|
|
4268
4272
|
button.setAttribute("aria-expanded", "false");
|
|
4269
4273
|
button.setAttribute("data-state", "closed");
|
|
@@ -4808,7 +4812,7 @@ export function createInjectionSource(features, {
|
|
|
4808
4812
|
themeTokens: CODEX_THEME_TOKENS,
|
|
4809
4813
|
themeTokenAliases: CODEX_THEME_TOKEN_ALIASES,
|
|
4810
4814
|
features: runtimeFeatures,
|
|
4811
|
-
})})`;
|
|
4815
|
+
})}, ${installFeatureTooltips.toString()})`;
|
|
4812
4816
|
}
|
|
4813
4817
|
|
|
4814
4818
|
export function createRuntimeReadyContract({
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// 自包含函数随运行时注入;只处理 MineCodex 标记,不接管原生 tooltip。
|
|
2
|
+
export function installFeatureTooltips(signal) {
|
|
3
|
+
const attribute = "data-minecodex-tooltip";
|
|
4
|
+
const tip = document.createElement("div");
|
|
5
|
+
tip.id = "minecodex-feature-tooltip";
|
|
6
|
+
tip.setAttribute("role", "tooltip");
|
|
7
|
+
tip.hidden = true;
|
|
8
|
+
tip.style.cssText = `position:fixed;z-index:100;pointer-events:none;box-sizing:border-box;
|
|
9
|
+
zoom:var(--codex-window-zoom,1);max-width:min(320px,calc(100vw - 16px));
|
|
10
|
+
padding:5px 12px;border:1px solid var(--color-border-tooltip);border-radius:var(--radius-2xl);
|
|
11
|
+
background:var(--color-background-tooltip);color:var(--color-text-tooltip);box-shadow:var(--shadow-tooltip);
|
|
12
|
+
font-family:var(--font-sans-default);font-size:var(--text-sm);line-height:18px;
|
|
13
|
+
font-weight:var(--tooltip-compact-font-weight);letter-spacing:var(--tracking-tooltip);
|
|
14
|
+
text-align:center;overflow-wrap:anywhere;user-select:none;`;
|
|
15
|
+
let anchor = null;
|
|
16
|
+
let timer;
|
|
17
|
+
let frame;
|
|
18
|
+
function hide() {
|
|
19
|
+
clearTimeout(timer);
|
|
20
|
+
cancelAnimationFrame(frame);
|
|
21
|
+
if (anchor) {
|
|
22
|
+
const ids = (anchor.getAttribute("aria-describedby") || "").split(/\s+/).filter(id => id && id !== tip.id);
|
|
23
|
+
if (ids.length) anchor.setAttribute("aria-describedby", ids.join(" "));
|
|
24
|
+
else anchor.removeAttribute("aria-describedby");
|
|
25
|
+
}
|
|
26
|
+
anchor = null;
|
|
27
|
+
tip.hidden = true;
|
|
28
|
+
}
|
|
29
|
+
function position() {
|
|
30
|
+
if (!anchor?.isConnected || !anchor.getClientRects().length || anchor.getAttribute("aria-expanded") === "true") return hide();
|
|
31
|
+
const zoom = Number.parseFloat(getComputedStyle(tip).zoom) || 1;
|
|
32
|
+
const r = anchor.getBoundingClientRect();
|
|
33
|
+
const w = tip.offsetWidth, h = tip.offsetHeight;
|
|
34
|
+
const top = r.top / zoom - h - 8;
|
|
35
|
+
tip.style.left = `${Math.max(8, Math.min((r.left + r.width / 2) / zoom - w / 2, innerWidth / zoom - w - 8))}px`;
|
|
36
|
+
tip.style.top = `${top >= 8 ? top : r.bottom / zoom + 8}px`;
|
|
37
|
+
frame = requestAnimationFrame(position);
|
|
38
|
+
}
|
|
39
|
+
function show(target, immediate = false) {
|
|
40
|
+
if (!target || target === anchor) return;
|
|
41
|
+
hide();
|
|
42
|
+
if (target.getAttribute("aria-expanded") === "true" || !target.getAttribute(attribute)) return;
|
|
43
|
+
anchor = target;
|
|
44
|
+
timer = setTimeout(() => {
|
|
45
|
+
if (!anchor?.isConnected) return hide();
|
|
46
|
+
if (!tip.isConnected) document.body.append(tip);
|
|
47
|
+
tip.textContent = anchor.getAttribute(attribute);
|
|
48
|
+
tip.hidden = false;
|
|
49
|
+
const ids = (anchor.getAttribute("aria-describedby") || "").split(/\s+/).filter(Boolean);
|
|
50
|
+
anchor.setAttribute("aria-describedby", [...new Set([...ids, tip.id])].join(" "));
|
|
51
|
+
position();
|
|
52
|
+
}, immediate ? 0 : 450);
|
|
53
|
+
}
|
|
54
|
+
const targetOf = event => event.target instanceof Element ? event.target.closest(`[${attribute}]`) : null;
|
|
55
|
+
document.addEventListener("pointerover", event => show(targetOf(event)), { signal });
|
|
56
|
+
document.addEventListener("pointerout", event => {
|
|
57
|
+
if (anchor && !anchor.contains(event.relatedTarget)) hide();
|
|
58
|
+
}, { signal });
|
|
59
|
+
document.addEventListener("focusin", event => show(targetOf(event), true), { signal });
|
|
60
|
+
document.addEventListener("focusout", hide, { signal });
|
|
61
|
+
document.addEventListener("pointerdown", hide, { signal, capture: true });
|
|
62
|
+
document.addEventListener("keydown", event => { if (event.key === "Escape") hide(); }, { signal });
|
|
63
|
+
window.addEventListener("blur", hide, { signal });
|
|
64
|
+
signal.addEventListener("abort", () => { hide(); tip.remove(); }, { once: true });
|
|
65
|
+
}
|