dsh-enhance 0.3.5 → 0.3.6
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 +4 -3
- package/lib/client.js +163 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-enhance
|
|
2
2
|
|
|
3
|
-
DeepSeek Harness(DSH)增强插件:Markdown
|
|
3
|
+
DeepSeek Harness(DSH)增强插件:Markdown 主题统一、划词批注、文件与链接右键菜单、侧栏更窄、启动默认状态。
|
|
4
4
|
|
|
5
5
|
## 功能
|
|
6
6
|
|
|
@@ -14,7 +14,8 @@ DeepSeek Harness(DSH)增强插件:Markdown 主题统一、划词批注、
|
|
|
14
14
|
- 有批注挂起时发送按钮即刻可用,而输入框保持空白;发送瞬间才把引文拼进消息
|
|
15
15
|
- 弹窗输入框无内边距、贴合面板,高度随内容自动增长且不出现滚动条
|
|
16
16
|
- **侧栏提问** — 从同一面板把段落送到右侧栏的侧边对话,不打断当前对话。首次创建,之后复用同一标签页。
|
|
17
|
-
- **文件右键菜单** — 在对话消息里的文件链接(含行内代码形式的文件引用)上右键,弹出跟随深浅主题的菜单:用默认应用打开、打开方式(列出系统为该登记的应用)、另存为、复制路径、复制文件内容、在 Finder 中显示。打开/打开方式/Finder 定位走宿主 `ctx.remote.session.openWorkspacePath`,应用清单走 `workspacePathApplications`,读取内容走鉴权路由 `GET /api/file?path=`。路径取文件链接的 `title`,相对路径按当前会话 `cwd` 补全;另存为从 `/api/file` 取得字节后优先调用 `showSaveFilePicker`,不支持时退化为浏览器下载(DSH
|
|
17
|
+
- **文件右键菜单** — 在对话消息里的文件链接(含行内代码形式的文件引用)上右键,弹出跟随深浅主题的菜单:用默认应用打开、打开方式(列出系统为该登记的应用)、另存为、复制路径、复制文件内容、在 Finder 中显示。打开/打开方式/Finder 定位走宿主 `ctx.remote.session.openWorkspacePath`,应用清单走 `workspacePathApplications`,读取内容走鉴权路由 `GET /api/file?path=`。路径取文件链接的 `title`,相对路径按当前会话 `cwd` 补全;另存为从 `/api/file` 取得字节后优先调用 `showSaveFilePicker`,不支持时退化为浏览器下载(DSH 未提供原生保存对话框)。
|
|
18
|
+
- **网页链接右键菜单** — 在对话消息里的普通 HTTP(S) 链接上右键,弹出「打开方式」菜单:新标签页、新窗口、默认浏览器、复制链接、链接另存为…。新标签页优先打开宿主内置浏览器页签(`ctx.sidebarRight.openTab('browser', { url })`,未启用该页签时回退到新窗口);新窗口用浏览器弹窗;默认浏览器交给系统(桌面端主窗口把 `window.open` 的 http(s) 交给系统浏览器);链接另存为通过 `fetch` 取数据后以 `download` 下载,受跨域限制时提示无法下载。两个菜单都只在会话正文内拦截右键,其它位置保留宿主原生菜单;点击别处、滚动、Esc、失焦、窗口缩放都会关闭它。
|
|
18
19
|
- **侧栏更窄** — 侧栏可拖到 214px(上游限制 264px),文字相应缩小一档;文件夹图标换成展开/收起三角,文件夹标题与会话标题同字号、左端对齐。
|
|
19
20
|
- **面板图标置顶** — Plugins / 自动化等面板图标移到侧栏顶部、工作区列表之上,并排成一行;每行最多 5 个,超出换行。上游是带文字的竖排列表,此前本插件把它放在右下角。只改位置与排版,宿主的选中态、悬停态和那个「更多」菜单都照旧。
|
|
20
21
|
- **插件图标也置顶** — 新装的插件如果把图标注册到侧栏底部(`sidebar.footer.action`,比如「远程访问」的电话图标),它的按钮会被搬进同一行顶部列表,同样按 5 个一行、超出换行。搬的是宿主自己的容器而不是插件的按钮,所以插件自己的选中态、悬停态和弹层都照常工作;折叠成图标轨时交回宿主布局。
|
|
@@ -114,7 +115,7 @@ npx pnpm@11.28.5 remove dsh-enhance
|
|
|
114
115
|
| `src/client/turn-badge.ts` | Dock 未读会话角标(映射宿主 completionUnread,报到 Host 路由) |
|
|
115
116
|
| `src/index.ts` | Host 半边:`/dsh-enhance/badge` 路由,主进程画 Dock 角标 |
|
|
116
117
|
| `src/client/side-chat.ts` | 侧栏对话资源与标签页 |
|
|
117
|
-
| `src/client/file-menu.ts` |
|
|
118
|
+
| `src/client/file-menu.ts` | 会话内的右键菜单:文件链接(路径解析、打开方式子菜单、六项动作)与网页链接(新标签/新窗口/默认浏览器/复制/另存为) |
|
|
118
119
|
| `src/client/styles/file-menu.ts` | 右键菜单与结果提示的样式表 |
|
|
119
120
|
| `src/client/styles/` | 各样式表(每个文件导出一个 `String.raw` 模板);`running-spinner.ts` 负责侧栏运行中色环 |
|
|
120
121
|
| `lib/` | 构建产物,即 `npm pack` 打包内容 |
|
package/lib/client.js
CHANGED
|
@@ -2819,6 +2819,8 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
|
|
|
2819
2819
|
// src/client/file-menu.ts
|
|
2820
2820
|
/** Hashed CSS-module classes still contain these stable substrings. */
|
|
2821
2821
|
const FILE_MENTION_SELECTOR = "button[class*=\"fileMention\"][title], button[class*=\"fileLink\"][title]";
|
|
2822
|
+
/** Web links rendered inside chat messages (file mentions are buttons, not anchors). */
|
|
2823
|
+
const WEB_LINK_SELECTOR = "a[href]";
|
|
2822
2824
|
/** A file mention counts only inside rendered chat content. */
|
|
2823
2825
|
const TRANSCRIPT_ROOT_SELECTOR = `${CHAT_NODE_SELECTOR}, ${ASSISTANT_FLOW_SELECTOR}, [class*="_markdown"]`;
|
|
2824
2826
|
/** Marks both the menu and its submenu, so outside clicks can be recognised. */
|
|
@@ -2828,6 +2830,9 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
|
|
|
2828
2830
|
const MENU_HEIGHT = 268;
|
|
2829
2831
|
const SUBMENU_WIDTH = 210;
|
|
2830
2832
|
const SUBMENU_ROW = 30;
|
|
2833
|
+
/** Link menu footprint: header, three open rows, a separator, two copy/save rows. */
|
|
2834
|
+
const LINK_MENU_WIDTH = 232;
|
|
2835
|
+
const LINK_MENU_HEIGHT = 292;
|
|
2831
2836
|
/**
|
|
2832
2837
|
* Turn a mention's `title` into a usable path.
|
|
2833
2838
|
* Handles `file://` URLs and the `#L12` / `#L12-L20` line anchors the markdown
|
|
@@ -2911,6 +2916,38 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
|
|
|
2911
2916
|
return mention;
|
|
2912
2917
|
}
|
|
2913
2918
|
/**
|
|
2919
|
+
* Accept an HTTP(S) URL and nothing else.
|
|
2920
|
+
* @param href - raw href attribute.
|
|
2921
|
+
* @returns the URL string, or undefined for other schemes or empties.
|
|
2922
|
+
*/
|
|
2923
|
+
function normalizeWebLink(href) {
|
|
2924
|
+
const value = href.trim();
|
|
2925
|
+
if (!/^https?:\/\//i.test(value)) return void 0;
|
|
2926
|
+
try {
|
|
2927
|
+
const url = new URL(value);
|
|
2928
|
+
return url.protocol === "http:" || url.protocol === "https:" ? url.href : void 0;
|
|
2929
|
+
} catch {
|
|
2930
|
+
return;
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
/**
|
|
2934
|
+
* Find the web link a context-menu event landed on.
|
|
2935
|
+
* @param node - event target.
|
|
2936
|
+
* @returns the link URL, or undefined for non-links, other schemes, or outside chat.
|
|
2937
|
+
*/
|
|
2938
|
+
function webLinkFrom(node) {
|
|
2939
|
+
const element = node instanceof Element ? node : node?.parentElement ?? void 0;
|
|
2940
|
+
if (element === void 0) return void 0;
|
|
2941
|
+
const anchor = element.closest(WEB_LINK_SELECTOR);
|
|
2942
|
+
if (!(anchor instanceof HTMLAnchorElement)) return void 0;
|
|
2943
|
+
if (anchor.closest(TRANSCRIPT_ROOT_SELECTOR) === null) return void 0;
|
|
2944
|
+
const url = normalizeWebLink(anchor.getAttribute("href") ?? "");
|
|
2945
|
+
return url === void 0 ? void 0 : {
|
|
2946
|
+
anchor,
|
|
2947
|
+
url
|
|
2948
|
+
};
|
|
2949
|
+
}
|
|
2950
|
+
/**
|
|
2914
2951
|
* Copy text with the async clipboard API, falling back to a hidden textarea.
|
|
2915
2952
|
* @param text - text to copy.
|
|
2916
2953
|
*/
|
|
@@ -3172,22 +3209,115 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
|
|
|
3172
3209
|
menu = root;
|
|
3173
3210
|
loadApps();
|
|
3174
3211
|
};
|
|
3175
|
-
/**
|
|
3212
|
+
/** Open a web link in the app's in-app browser tab when one exists. */
|
|
3213
|
+
const openLinkInTab = (url) => {
|
|
3214
|
+
const tabs = ctx.sidebarRightTabs;
|
|
3215
|
+
const right = ctx.sidebarRight;
|
|
3216
|
+
if (tabs?.get?.("browser") !== void 0 && typeof right?.openTab === "function") {
|
|
3217
|
+
right.openTab("browser", { params: { url } });
|
|
3218
|
+
return t("linkMenu.done.opened");
|
|
3219
|
+
}
|
|
3220
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
3221
|
+
return "";
|
|
3222
|
+
};
|
|
3223
|
+
/** Open a web link in a separate window (browser popup; the desktop shell
|
|
3224
|
+
* hands external URLs to the system browser). */
|
|
3225
|
+
const openLinkNewWindow = (url) => {
|
|
3226
|
+
window.open(url, "_blank", "noopener,noreferrer,popup=yes,width=1024,height=768");
|
|
3227
|
+
return "";
|
|
3228
|
+
};
|
|
3229
|
+
/** Hand a web link to the environment's default browser. */
|
|
3230
|
+
const openLinkDefault = (url) => {
|
|
3231
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
3232
|
+
return "";
|
|
3233
|
+
};
|
|
3234
|
+
/** Save a web link's resource as a download, best-effort under CORS. */
|
|
3235
|
+
const saveLink = async (url) => {
|
|
3236
|
+
let blob;
|
|
3237
|
+
try {
|
|
3238
|
+
const response = await fetch(url);
|
|
3239
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
3240
|
+
blob = await response.blob();
|
|
3241
|
+
} catch {
|
|
3242
|
+
throw new Error(t("linkMenu.saveFailed"));
|
|
3243
|
+
}
|
|
3244
|
+
let name = "download";
|
|
3245
|
+
try {
|
|
3246
|
+
name = decodeURIComponent(new URL(url).pathname.split("/").pop() || "") || "download";
|
|
3247
|
+
} catch {}
|
|
3248
|
+
const href = URL.createObjectURL(blob);
|
|
3249
|
+
const anchor = doc.createElement("a");
|
|
3250
|
+
anchor.href = href;
|
|
3251
|
+
anchor.download = name;
|
|
3252
|
+
anchor.style.display = "none";
|
|
3253
|
+
doc.body.appendChild(anchor);
|
|
3254
|
+
anchor.click();
|
|
3255
|
+
anchor.remove();
|
|
3256
|
+
window.setTimeout(() => URL.revokeObjectURL(href), 1e3);
|
|
3257
|
+
return t("linkMenu.done.saved");
|
|
3258
|
+
};
|
|
3259
|
+
/** Build and show the menu for a web link. */
|
|
3260
|
+
const openLinkMenu = (x, y, url) => {
|
|
3261
|
+
close();
|
|
3262
|
+
const root = doc.createElement("div");
|
|
3263
|
+
root.className = "dsh-file-menu";
|
|
3264
|
+
root.setAttribute(MENU_ATTRIBUTE, "");
|
|
3265
|
+
root.setAttribute("role", "menu");
|
|
3266
|
+
const header = doc.createElement("div");
|
|
3267
|
+
header.className = "dsh-file-menu__header";
|
|
3268
|
+
header.textContent = t("linkMenu.header");
|
|
3269
|
+
const separator = doc.createElement("div");
|
|
3270
|
+
separator.className = "dsh-file-menu__separator";
|
|
3271
|
+
const row = (label, run) => {
|
|
3272
|
+
const button = doc.createElement("button");
|
|
3273
|
+
button.type = "button";
|
|
3274
|
+
button.className = "dsh-file-menu__item";
|
|
3275
|
+
button.setAttribute("role", "menuitem");
|
|
3276
|
+
const text = doc.createElement("span");
|
|
3277
|
+
text.textContent = label;
|
|
3278
|
+
button.append(text);
|
|
3279
|
+
button.addEventListener("click", (event) => {
|
|
3280
|
+
event.stopPropagation();
|
|
3281
|
+
act(async () => run());
|
|
3282
|
+
});
|
|
3283
|
+
return button;
|
|
3284
|
+
};
|
|
3285
|
+
root.append(header, row(t("linkMenu.newTab"), () => openLinkInTab(url)), row(t("linkMenu.newWindow"), () => openLinkNewWindow(url)), row(t("linkMenu.defaultBrowser"), () => openLinkDefault(url)), separator, row(t("linkMenu.copyLink"), async () => {
|
|
3286
|
+
await copy(url);
|
|
3287
|
+
return t("linkMenu.done.copied");
|
|
3288
|
+
}), row(t("linkMenu.saveLink"), () => saveLink(url)));
|
|
3289
|
+
const placed = placeMenu(x, y, LINK_MENU_WIDTH, LINK_MENU_HEIGHT, {
|
|
3290
|
+
width: window.innerWidth,
|
|
3291
|
+
height: window.innerHeight
|
|
3292
|
+
});
|
|
3293
|
+
root.style.left = `${placed.left}px`;
|
|
3294
|
+
root.style.top = `${placed.top}px`;
|
|
3295
|
+
doc.body.appendChild(root);
|
|
3296
|
+
menu = root;
|
|
3297
|
+
};
|
|
3298
|
+
/** The gesture: only file mentions and web links inside chat content are claimed. */
|
|
3176
3299
|
const onContextMenu = (event) => {
|
|
3177
|
-
const
|
|
3178
|
-
if (
|
|
3179
|
-
|
|
3300
|
+
const file = fileTargetFrom(event.target);
|
|
3301
|
+
if (file !== void 0) {
|
|
3302
|
+
const mention = normalizeMentionPath(file.getAttribute("title") ?? "");
|
|
3303
|
+
if (mention === void 0) {
|
|
3304
|
+
close();
|
|
3305
|
+
return;
|
|
3306
|
+
}
|
|
3307
|
+
const resolved = resolvePath(mention, cwdFor(ctx));
|
|
3308
|
+
event.preventDefault();
|
|
3309
|
+
event.stopPropagation();
|
|
3310
|
+
open(event.clientX, event.clientY, resolved ?? mention);
|
|
3180
3311
|
return;
|
|
3181
3312
|
}
|
|
3182
|
-
const
|
|
3183
|
-
if (
|
|
3184
|
-
|
|
3313
|
+
const link = webLinkFrom(event.target);
|
|
3314
|
+
if (link !== void 0) {
|
|
3315
|
+
event.preventDefault();
|
|
3316
|
+
event.stopPropagation();
|
|
3317
|
+
openLinkMenu(event.clientX, event.clientY, link.url);
|
|
3185
3318
|
return;
|
|
3186
3319
|
}
|
|
3187
|
-
|
|
3188
|
-
event.preventDefault();
|
|
3189
|
-
event.stopPropagation();
|
|
3190
|
-
open(event.clientX, event.clientY, resolved ?? mention);
|
|
3320
|
+
close();
|
|
3191
3321
|
};
|
|
3192
3322
|
/** Close on any press that is not inside one of our panels. */
|
|
3193
3323
|
const onPointerDown = (event) => {
|
|
@@ -3256,7 +3386,17 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
|
|
|
3256
3386
|
"fileMenu.done.copyPath": "已复制路径",
|
|
3257
3387
|
"fileMenu.done.copyContents": "已复制文件内容",
|
|
3258
3388
|
"fileMenu.done.saved": "已保存",
|
|
3259
|
-
"fileMenu.failed": "操作失败:{message}"
|
|
3389
|
+
"fileMenu.failed": "操作失败:{message}",
|
|
3390
|
+
"linkMenu.header": "打开方式",
|
|
3391
|
+
"linkMenu.newTab": "新标签页",
|
|
3392
|
+
"linkMenu.newWindow": "新窗口",
|
|
3393
|
+
"linkMenu.defaultBrowser": "默认浏览器",
|
|
3394
|
+
"linkMenu.copyLink": "复制链接",
|
|
3395
|
+
"linkMenu.saveLink": "链接另存为…",
|
|
3396
|
+
"linkMenu.done.opened": "已打开",
|
|
3397
|
+
"linkMenu.done.copied": "已复制链接",
|
|
3398
|
+
"linkMenu.done.saved": "已保存",
|
|
3399
|
+
"linkMenu.saveFailed": "无法下载该链接(可能受跨域限制)"
|
|
3260
3400
|
};
|
|
3261
3401
|
/** Toolbar copy, English. */
|
|
3262
3402
|
const en = {
|
|
@@ -3294,7 +3434,17 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
|
|
|
3294
3434
|
"fileMenu.done.copyPath": "Path copied",
|
|
3295
3435
|
"fileMenu.done.copyContents": "File contents copied",
|
|
3296
3436
|
"fileMenu.done.saved": "Saved",
|
|
3297
|
-
"fileMenu.failed": "Could not do that: {message}"
|
|
3437
|
+
"fileMenu.failed": "Could not do that: {message}",
|
|
3438
|
+
"linkMenu.header": "Open in",
|
|
3439
|
+
"linkMenu.newTab": "New tab",
|
|
3440
|
+
"linkMenu.newWindow": "New window",
|
|
3441
|
+
"linkMenu.defaultBrowser": "Default browser",
|
|
3442
|
+
"linkMenu.copyLink": "Copy link",
|
|
3443
|
+
"linkMenu.saveLink": "Save link as...",
|
|
3444
|
+
"linkMenu.done.opened": "Opened",
|
|
3445
|
+
"linkMenu.done.copied": "Link copied",
|
|
3446
|
+
"linkMenu.done.saved": "Saved",
|
|
3447
|
+
"linkMenu.saveFailed": "Could not download this link (cross-origin restrictions may apply)"
|
|
3298
3448
|
};
|
|
3299
3449
|
// src/client/anchors.ts
|
|
3300
3450
|
/** Any transcript row the plugin may anchor to. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-enhance",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "DeepSeek Harness enhancements: Markdown theme for every renderer, select-text annotations with pins, a file right-click menu, a narrower sidebar, and startup defaults (maximized window, narrowest sidebar, colourful running marker). 中文:DSH 增强插件——Markdown 主题、划词批注、文件右键菜单、侧栏宽度、启动默认状态。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|