dsh-cmdk 0.0.0-stage → 0.3.1
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/LICENSE +21 -0
- package/README.md +121 -2
- package/client.js +2210 -0
- package/cordis.patch.yml +5 -0
- package/icon.svg +16 -0
- package/index.js +596 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +55 -4
- package/screenshot-actions.png +0 -0
- package/screenshot-ext.png +0 -0
- package/screenshot.png +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mumuhmumu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,122 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-cmdk — ⌘K 命令面板
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
当前版本 **0.3.1**:会话 / 工作区 / 插件 / 动作 / 外观一个入口,插件可扩展。
|
|
4
|
+
|
|
5
|
+
一个快捷键跳到任何东西:会话、工作区、常用动作,还能对选中的会话直接做事。
|
|
6
|
+
装完即用,无配置,零依赖。
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
## 能做什么
|
|
11
|
+
|
|
12
|
+
**打开**
|
|
13
|
+
|
|
14
|
+
| 输入 | 结果 |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| `⌘K` / `Ctrl+K` | 打开 / 关闭面板(侧栏底部也有「⌘K 搜索」按钮) |
|
|
17
|
+
| 输入会话标题 | 模糊匹配全部会话(前缀 > 子串 > 拼音首字母 > 子序列),回车直达 |
|
|
18
|
+
| 输入中文首字母 | `cj` → 「插件…」,`cjgc` → 「插件广场」 |
|
|
19
|
+
| 输入消息内容 | 宿主扫描最近 12 个会话的日志文本,带上下文片段 |
|
|
20
|
+
| 输入工作区名 | 直接切换工作区 |
|
|
21
|
+
| `深色` / `浅色` / `跟随系统` | 换主题 |
|
|
22
|
+
| `中文` / `English` | 换界面语言 |
|
|
23
|
+
|
|
24
|
+
**对一条会话按 `→`(或行尾的 `…`)可以**
|
|
25
|
+
|
|
26
|
+
打开 / 重命名 / Fork 到新会话 / 归档 / 复制会话 ID / 复制工作目录路径 /
|
|
27
|
+
在访达打开工作目录 / 导出为 Markdown(含图片轮与工具调用,落到下载目录)。
|
|
28
|
+
|
|
29
|
+
**插件**
|
|
30
|
+
|
|
31
|
+
面板里有一组「插件」:列出当前 profile 里所有已安装的插件,显示版本与启用状态;
|
|
32
|
+
回车切换启用 / 禁用(走 `pluginManager.setBundleEnabled`,失败自动回滚),
|
|
33
|
+
按 `→` 还能直接打开该插件在 `node_modules` 里的目录。
|
|
34
|
+
|
|
35
|
+
**对工作区按 `→` 可以**
|
|
36
|
+
|
|
37
|
+
切换、在此新建会话、在访达打开。
|
|
38
|
+
|
|
39
|
+
**系统**
|
|
40
|
+
|
|
41
|
+
打开 profile 目录、打开 sessions 目录、打开日志目录、刷新页面。
|
|
42
|
+
|
|
43
|
+
键盘:`↑` `↓` 选择、`↵` 执行、`→` 更多动作、`←`/`Esc` 返回上一层。
|
|
44
|
+
|
|
45
|
+
## 给别的插件用:注册自己的命令
|
|
46
|
+
|
|
47
|
+
任何 client 插件都可以往面板里塞一行(不用改本插件的代码):
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
window.__DSH_CMDK__?.register({
|
|
51
|
+
id: 'my-plugin.open-docs', // 唯一 id,重复注册会覆盖
|
|
52
|
+
title: '打开插件文档', // 会被模糊匹配 + 拼音首字母匹配
|
|
53
|
+
sub: 'my-plugin 说明书', // 副标题,也会参与匹配
|
|
54
|
+
run: (ctx) => ({ status: '已打开' }), // 返回 { status } 面板保持打开,返回空则关闭
|
|
55
|
+
});
|
|
56
|
+
// 需要时再撤销
|
|
57
|
+
window.__DSH_CMDK__?.unregister('my-plugin.open-docs');
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
也可以用事件注册(适合早于本插件加载的模块):
|
|
61
|
+
`window.dispatchEvent(new CustomEvent('dsh-cmdk:command', { detail: { id, title, run } }))`。
|
|
62
|
+
|
|
63
|
+
## 记忆
|
|
64
|
+
|
|
65
|
+
用过的动作会记在 `localStorage["dsh-cmdk/recent"]`(次数 + 时间,最多 60 条),
|
|
66
|
+
下次空查询时按使用频率排在最上面。纯本地,不上传。
|
|
67
|
+
|
|
68
|
+
## 设计取舍
|
|
69
|
+
|
|
70
|
+
- **跳转与动作走公开 Client 服务**:切会话、Fork、归档、重命名、换主题、换语言都用
|
|
71
|
+
`uiWorkspace` / `sessions` / `theme` / `locale`,不碰内部模块。
|
|
72
|
+
- **列表数据走宿主**:浏览器侧拿不到"全部历史会话"和工作区清单,所以宿主读
|
|
73
|
+
`sessionQuery.listSessions()` + `readTitleSnapshots()`(标题)与
|
|
74
|
+
`~/.dsh/storages/workspace.json`(工作区、已归档会话),客户端只做展示。
|
|
75
|
+
- **内容搜索不依赖 SQLite 索引**:用 `filterEvents({kind:'text'})` 扫正文——实测有些
|
|
76
|
+
机器上原生「搜索会话」本身就是空的(全文索引没建起来),照抄索引会一起空。
|
|
77
|
+
代价是只扫最近 12 个会话,且只跳到会话顶部而不是那一条消息(API 不返回消息序号)。
|
|
78
|
+
- **拼音只支持首字母**:内置 20992 字符的首字母表(U+4E00–U+9FFF),`chajian` 这种全拼
|
|
79
|
+
不匹配,`cj` 可以。全拼要 20 倍体积,先不做。
|
|
80
|
+
- **信任栅栏**:所有自定义路由都先过 `connection.requestRejection`,只在本机回环口可用。
|
|
81
|
+
- **插件开关复用宿主能力**:启用/禁用走 `pluginManager.setBundleEnabled`,不自己改
|
|
82
|
+
`package.json`、不自己跑 pnpm;需要重启的会直接告诉你「重启后生效」。
|
|
83
|
+
- **视觉分层**:搜索框、列表、底部提示是三块不同表面(header 面板底色 + 1px 硬分隔 +
|
|
84
|
+
内阴影输入框),分组标题吸顶,滚动时不会再和标题糊在一起。
|
|
85
|
+
|
|
86
|
+
## 路由
|
|
87
|
+
|
|
88
|
+
| 方法 | 路径 | 作用 |
|
|
89
|
+
| --- | --- | --- |
|
|
90
|
+
| GET | `/cmdk/info` | home / profile / platform |
|
|
91
|
+
| GET | `/cmdk/sessions?q=&limit=` | 会话目录 + 标题匹配 + 正文命中片段 |
|
|
92
|
+
| GET | `/cmdk/workspaces` | 工作区清单 + 已归档会话 ID |
|
|
93
|
+
| GET | `/cmdk/export?id=` | 把一段会话渲染成 Markdown |
|
|
94
|
+
| GET | `/cmdk/plugins` | 已安装插件(名称 / 版本 / 启用状态 / 目录) |
|
|
95
|
+
| POST | `/cmdk/plugin` | `{ name, enabled }` 启用或禁用某个插件 |
|
|
96
|
+
| POST | `/cmdk/open-profile` | 在访达/资源管理器打开目录(可选 `{path}`) |
|
|
97
|
+
|
|
98
|
+
## 安装
|
|
99
|
+
|
|
100
|
+
插件市场搜 `dsh-cmdk`,或命令行安装:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
dsh plugin add dsh-cmdk
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
装完重启桌面 app(或刷新页面)拿到新的 client 模块。
|
|
107
|
+
|
|
108
|
+
## 文件
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
package.json # dsh.bundle.patch + dsh.client(platform web, immediately)
|
|
112
|
+
cordis.patch.yml # insert: dsh-cmdk
|
|
113
|
+
index.js # Host:/cmdk/{info,sessions,workspaces,plugins,plugin,export,open-profile}
|
|
114
|
+
client.js # Client:shell.overlay 面板 + sidebar.footer.action 按钮
|
|
115
|
+
locale/zh.json # meta.title / meta.description
|
|
116
|
+
locale/en.json
|
|
117
|
+
icon.svg
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT
|