@jidekaixin2dian/dsh-file-actions 0.1.17 → 0.1.18
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/CHANGELOG.md +6 -0
- package/LICENSE +21 -21
- package/README.en.md +16 -3
- package/README.md +16 -3
- package/SECURITY.md +3 -1
- package/cordis.patch.yml +5 -5
- package/icon.svg +7 -7
- package/lib/client.js +108 -10
- package/lib/index.js +13 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.18 — 2026-10-30
|
|
4
|
+
|
|
5
|
+
- 新增「复制引用行」:带行号的文本引用可复制对应整行或行段;保留原始内部换行,沿用 UTF-8、2 MiB 与工作区外确认限制;超出文件范围时拒绝复制。
|
|
6
|
+
- 修复应用搜索框的光标按键与输入法确认、后台关联更新丢失搜索状态、键盘重复打开遗留菜单、绝对引用缺少相对路径复制,以及点击大图连带关闭菜单。
|
|
7
|
+
- Add **Copy referenced lines**, with the existing text-copy limits and explicit errors for invalid locations. Preserve application search state during validation and fix keyboard editing, duplicate menus, relative paths and preview dismissal.
|
|
8
|
+
|
|
3
9
|
## 0.1.17 — 2026-10-28
|
|
4
10
|
|
|
5
11
|
- 发布与更新维护:明确 npm 安装、GitHub 来源迁移、市场检测与重启步骤;保留既有运行时行为。
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 jidekaixin2dian
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jidekaixin2dian
|
|
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.en.md
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
**Turn a file reference in your conversation into the next action.**
|
|
4
4
|
|
|
5
|
-
[中文](README.md) · [Marketplace](https://awesome-dsh-plugin.com/p/jidekaixin2dian/dsh-file-actions/) · [Download](https://github.com/jidekaixin2dian/dsh-file-actions/releases/latest) · [Changelog](CHANGELOG.md)
|
|
5
|
+
[中文](README.md) · [npm](https://www.npmjs.com/package/@jidekaixin2dian/dsh-file-actions/v/0.1.18) · [Marketplace](https://awesome-dsh-plugin.com/p/jidekaixin2dian/dsh-file-actions/) · [Download](https://github.com/jidekaixin2dian/dsh-file-actions/releases/latest) · [Changelog](CHANGELOG.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Once a model gives you a file, the next step is usually to open it, keep editing or take its contents elsewhere. File Actions puts application choices, reveal, copy, preview and save into one context menu across chat references, delivery cards, tool results and sidebars that expose file paths.
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
|
+
## Continue from a file reference
|
|
12
|
+
|
|
11
13
|
| Your next step | Available actions |
|
|
12
14
|
|---|---|
|
|
13
15
|
| Keep editing | Open with the default app, search applications, save a preference per file type |
|
|
@@ -15,6 +17,14 @@ Right-click a file or link to open it, choose an application, reveal it, copy it
|
|
|
15
17
|
| View and export | Preview supported documents and media, copy text, save a local file |
|
|
16
18
|
| Share a link | Open, copy the URL or text, copy as Markdown |
|
|
17
19
|
|
|
20
|
+
## Downloads
|
|
21
|
+
|
|
22
|
+
| GitHub release assets · all releases | npm 0.1.17 · past 7 days |
|
|
23
|
+
|---|---|
|
|
24
|
+
| [**350 downloads**](https://api.github.com/repos/jidekaixin2dian/dsh-file-actions/releases?per_page=100) | [**191 downloads**](https://api.npmjs.org/versions/@jidekaixin2dian%2Fdsh-file-actions/last-week) |
|
|
25
|
+
|
|
26
|
+
Snapshot: **2026-10-29**. GitHub counts release-asset requests, including checksums; npm counts downloads of the named version. Requests can include repeat installs and automation, so these are not unique-user counts and the two columns are not added together. Click a number for its live source.
|
|
27
|
+
|
|
18
28
|
## Install and update
|
|
19
29
|
|
|
20
30
|
Requires **DSH >=0.2.1-rc.2 and Node >=24**. CI verifies DSH rc.2 / rc.3 / rc.4.
|
|
@@ -49,6 +59,9 @@ dsh plugin --profile desktop remove @jidekaixin2dian/dsh-file-actions
|
|
|
49
59
|
1. Right-click a file reference, delivery card or file tree. Explicit references open directly; guessed text paths are verified first.
|
|
50
60
|
2. Search **Open with** and star an application to remember it for that file type. OS defaults stay unchanged.
|
|
51
61
|
3. Enlarge image thumbnails or view supported documents, audio and video in the browser.
|
|
62
|
+
4. For text references such as `src/app.ts:42:7` or `notes.md#L42-L48`, choose **Copy referenced lines** to copy that line or range. Locations beyond the current file show an error instead of copying the whole file.
|
|
63
|
+
|
|
64
|
+
The option appears only when the reference retains its line numbers. If the host renders a link as a button exposing only its path, hidden line information cannot be recovered.
|
|
52
65
|
|
|
53
66
|
Keyboard: `Shift+F10` opens the menu, `↑ ↓` move, `→` enters a submenu, `Enter` runs and `Esc` closes. `Shift+right-click` gives the page's own handler priority.
|
|
54
67
|
|
|
@@ -57,7 +70,7 @@ The marketplace checks versions and installs after your click; it does not silen
|
|
|
57
70
|
## Boundaries
|
|
58
71
|
|
|
59
72
|
- File operations use official DSH APIs and path authorization. Application lists depend on system associations; the plugin does not repair registry entries.
|
|
60
|
-
-
|
|
73
|
+
- Copying contents or referenced lines requires **valid UTF-8 and a file no larger than 2 MiB**. Referenced lines are copied in full, retaining internal line endings; column numbers do not trim the text. Copies outside the workspace require explicit confirmation; unavailable confirmation cancels the read.
|
|
61
74
|
- Save and browser previews read up to **64 MiB** and stop on inconsistent chunks. This is not an atomic filesystem snapshot.
|
|
62
75
|
- HTML / SVG previews block scripts and external resources by default. Enable scripts and networking only for a trusted file; the preview remains isolated from DSH. Relative assets may not work. Clicking a document link is an explicit navigation.
|
|
63
76
|
- Editor actions do not jump to line/column positions. Save uses browser download behavior. The plugin needs the graphical / Web UI.
|
package/README.md
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
**从聊天里的文件引用,直接到你要做的操作。**
|
|
4
4
|
|
|
5
|
-
[English](README.en.md) · [插件市场](https://awesome-dsh-plugin.com/p/jidekaixin2dian/dsh-file-actions/) · [下载](https://github.com/jidekaixin2dian/dsh-file-actions/releases/latest) · [更新记录](CHANGELOG.md)
|
|
5
|
+
[English](README.en.md) · [npm](https://www.npmjs.com/package/@jidekaixin2dian/dsh-file-actions/v/0.1.18) · [插件市场](https://awesome-dsh-plugin.com/p/jidekaixin2dian/dsh-file-actions/) · [下载](https://github.com/jidekaixin2dian/dsh-file-actions/releases/latest) · [更新记录](CHANGELOG.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
模型给出文件后,下一步通常是打开、继续编辑,或把内容带走。File Actions 把打开方式、文件定位、路径与内容复制、预览和另存放进一个右键菜单,覆盖聊天引用、交付卡片、工具结果及提供文件路径的侧栏。
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
|
+
## 从文件引用接着做
|
|
12
|
+
|
|
11
13
|
| 想做什么 | 可以怎么做 |
|
|
12
14
|
|---|---|
|
|
13
15
|
| 接着编辑文件 | 用默认应用打开,或搜索「打开方式」并收藏首选应用 |
|
|
@@ -15,6 +17,14 @@
|
|
|
15
17
|
| 查看与带走内容 | 预览支持的文档、图片或媒体;复制文本;另存为本地文件 |
|
|
16
18
|
| 分享链接 | 打开网页,复制链接、链接文字或 Markdown |
|
|
17
19
|
|
|
20
|
+
## 下载情况
|
|
21
|
+
|
|
22
|
+
| GitHub Release 资源 · 历史累计 | npm 0.1.17 · 近 7 日 |
|
|
23
|
+
|---|---|
|
|
24
|
+
| [**350 次下载**](https://api.github.com/repos/jidekaixin2dian/dsh-file-actions/releases?per_page=100) | [**191 次下载**](https://api.npmjs.org/versions/@jidekaixin2dian%2Fdsh-file-actions/last-week) |
|
|
25
|
+
|
|
26
|
+
统计快照:**2026-10-29**。GitHub 包含安装包、校验文件等资源请求;npm 仅统计表中版本。下载可能包含重复安装和自动化请求,不代表独立用户数,两列不相加。点击数字可查看实时来源。
|
|
27
|
+
|
|
18
28
|
## 安装与更新
|
|
19
29
|
|
|
20
30
|
需要 **DSH >=0.2.1-rc.2、Node >=24**;持续验证 DSH rc.2 / rc.3 / rc.4。
|
|
@@ -51,6 +61,9 @@ dsh plugin --profile desktop remove @jidekaixin2dian/dsh-file-actions
|
|
|
51
61
|
1. 在聊天文件名、文件卡片或文件树上右键。明确引用可直接操作,普通文字里的疑似路径会先验证。
|
|
52
62
|
2. 选择「打开方式」可搜索应用,点击星标保存当前文件类型的首选;不会改变系统默认应用。
|
|
53
63
|
3. 图片支持缩略图与放大预览;支持的文档、音视频可在浏览器中查看。
|
|
64
|
+
4. 对 `src/app.ts:42:7` 或 `notes.md#L42-L48` 这类文本引用,可选「复制引用行」复制该行或该段,不必复制整个文件。行号超出当前文件范围时会提示,不会改为复制全文。
|
|
65
|
+
|
|
66
|
+
该选项仅在引用仍保留行号时出现;宿主若把链接渲染为仅暴露路径的按钮,插件无法恢复已隐藏的行号。
|
|
54
67
|
|
|
55
68
|
键盘:`Shift+F10` 打开菜单,`↑ ↓` 移动,`→` 进入子菜单,`Enter` 执行,`Esc` 关闭。`Shift+右键` 优先交给页面原有菜单。
|
|
56
69
|
|
|
@@ -59,7 +72,7 @@ dsh plugin --profile desktop remove @jidekaixin2dian/dsh-file-actions
|
|
|
59
72
|
## 使用边界
|
|
60
73
|
|
|
61
74
|
- 打开与定位沿用 DSH 官方接口和路径授权;应用列表取决于系统关联。失效关联可能导致列表不可用,插件不会修改注册表。
|
|
62
|
-
-
|
|
75
|
+
- 复制内容与引用行仅支持 **有效 UTF-8、文件最大 2 MiB**。引用行按整行复制,保留所选行之间的原始换行;列号不裁剪内容。工作区外复制需要明确确认;确认不可用时取消读取。
|
|
63
76
|
- 另存为和浏览器预览最多读取 **64 MiB**,分块内容不一致时中止;不是文件系统原子快照。
|
|
64
77
|
- HTML / SVG 默认静态预览并阻止脚本和外部资源。仅在信任文件后启用脚本与联网;预览仍与 DSH 页面隔离。相对资源可能不可用,点击文件内链接属于主动导航。
|
|
65
78
|
- 编辑器打开暂不跳到行列位置;另存为使用浏览器下载行为。插件用于 DSH 图形 / Web 界面,终端界面不适用。
|
package/SECURITY.md
CHANGED
|
@@ -6,7 +6,9 @@ can include paths outside a workspace when the host's composed filesystem permit
|
|
|
6
6
|
them; the workspace label is not a containment guarantee. Copying the contents of
|
|
7
7
|
a file outside the session workspace requires an explicit confirmation, because
|
|
8
8
|
chat text can plant absolute paths; a declined or unavailable confirmation reads
|
|
9
|
-
no bytes.
|
|
9
|
+
no bytes. The same gates apply to copying referenced lines: the file must fit the
|
|
10
|
+
2 MiB text-copy cap, and invalid or out-of-file line ranges never fall back to
|
|
11
|
+
copying the full file. Invalid UTF-8 is rejected rather than silently replaced. Chunked exports
|
|
10
12
|
check file identity, version, offsets and reported size, stopping on changes;
|
|
11
13
|
this detects inconsistent responses but does not create an atomic Host snapshot.
|
|
12
14
|
|
package/cordis.patch.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# Bundle patch: one row mounts the (stateless) host half; `dsh.client` in
|
|
2
|
-
# package.json makes the web app load ./client as the browser half.
|
|
3
|
-
- insert:
|
|
4
|
-
- id: dsh-file-actions
|
|
5
|
-
name: '@jidekaixin2dian/dsh-file-actions'
|
|
1
|
+
# Bundle patch: one row mounts the (stateless) host half; `dsh.client` in
|
|
2
|
+
# package.json makes the web app load ./client as the browser half.
|
|
3
|
+
- insert:
|
|
4
|
+
- id: dsh-file-actions
|
|
5
|
+
name: '@jidekaixin2dian/dsh-file-actions'
|
package/icon.svg
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="dsh-file-actions">
|
|
2
|
-
<rect width="64" height="64" rx="14" fill="#1b1d21"/>
|
|
3
|
-
<path d="M18 16h18l10 10v22a4 4 0 0 1-4 4H18a4 4 0 0 1-4-4V20a4 4 0 0 1 4-4z" fill="none" stroke="#e8e8e8" stroke-width="2.4" stroke-linejoin="round"/>
|
|
4
|
-
<path d="M36 16v10h10" fill="none" stroke="#e8e8e8" stroke-width="2.4" stroke-linejoin="round"/>
|
|
5
|
-
<circle cx="45" cy="45" r="11" fill="#c8f663"/>
|
|
6
|
-
<path d="M40.5 45h9M45 40.5v9" stroke="#1b1d21" stroke-width="2.6" stroke-linecap="round"/>
|
|
7
|
-
</svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="dsh-file-actions">
|
|
2
|
+
<rect width="64" height="64" rx="14" fill="#1b1d21"/>
|
|
3
|
+
<path d="M18 16h18l10 10v22a4 4 0 0 1-4 4H18a4 4 0 0 1-4-4V20a4 4 0 0 1 4-4z" fill="none" stroke="#e8e8e8" stroke-width="2.4" stroke-linejoin="round"/>
|
|
4
|
+
<path d="M36 16v10h10" fill="none" stroke="#e8e8e8" stroke-width="2.4" stroke-linejoin="round"/>
|
|
5
|
+
<circle cx="45" cy="45" r="11" fill="#c8f663"/>
|
|
6
|
+
<path d="M40.5 45h9M45 40.5v9" stroke="#1b1d21" stroke-width="2.6" stroke-linecap="round"/>
|
|
7
|
+
</svg>
|
package/lib/client.js
CHANGED
|
@@ -42,6 +42,7 @@ const factory = () => {
|
|
|
42
42
|
copyReference: '复制引用',
|
|
43
43
|
copyMarkdown: '复制为 Markdown',
|
|
44
44
|
copyContents: '复制文件内容',
|
|
45
|
+
copyLines: '复制引用行',
|
|
45
46
|
saveAs: '另存为…',
|
|
46
47
|
copiedPath: '路径已复制',
|
|
47
48
|
copiedRelPath: '相对路径已复制',
|
|
@@ -51,6 +52,8 @@ const factory = () => {
|
|
|
51
52
|
lineAt: '第 {line} 行',
|
|
52
53
|
lineRange: '第 {from}–{to} 行',
|
|
53
54
|
copiedContents: '文件内容已复制',
|
|
55
|
+
copiedLines: '引用行已复制',
|
|
56
|
+
invalidLines: '引用行超出文件范围或行号无效,请检查引用',
|
|
54
57
|
copyFailed: '复制失败',
|
|
55
58
|
readFailed: '读取失败',
|
|
56
59
|
fileChanged: '读取期间文件已变化,请重试',
|
|
@@ -138,6 +141,7 @@ const factory = () => {
|
|
|
138
141
|
copyReference: 'Copy reference',
|
|
139
142
|
copyMarkdown: 'Copy as Markdown',
|
|
140
143
|
copyContents: 'Copy file contents',
|
|
144
|
+
copyLines: 'Copy referenced lines',
|
|
141
145
|
saveAs: 'Save as…',
|
|
142
146
|
copiedPath: 'Path copied',
|
|
143
147
|
copiedRelPath: 'Relative path copied',
|
|
@@ -147,6 +151,8 @@ const factory = () => {
|
|
|
147
151
|
lineAt: 'line {line}',
|
|
148
152
|
lineRange: 'lines {from}–{to}',
|
|
149
153
|
copiedContents: 'File contents copied',
|
|
154
|
+
copiedLines: 'Referenced lines copied',
|
|
155
|
+
invalidLines: 'Referenced lines are invalid or outside the file; check the reference',
|
|
150
156
|
copyFailed: 'Copy failed',
|
|
151
157
|
readFailed: 'Read failed',
|
|
152
158
|
fileChanged: 'The file changed while reading; please retry',
|
|
@@ -582,6 +588,32 @@ const factory = () => {
|
|
|
582
588
|
return t.lineAt.replace('{line}', line)
|
|
583
589
|
}
|
|
584
590
|
|
|
591
|
+
function referenceRange(location) {
|
|
592
|
+
const line = location?.line
|
|
593
|
+
const endLine = location?.endLine ?? line
|
|
594
|
+
return Number.isSafeInteger(line) && line > 0 && Number.isSafeInteger(endLine) && endLine >= line
|
|
595
|
+
? { line, endLine } : null
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// Keep the file's own line breaks inside the selection; a final terminator
|
|
599
|
+
// ends its last line rather than inventing one more line to copy.
|
|
600
|
+
function referencedText(text, location) {
|
|
601
|
+
const range = referenceRange(location)
|
|
602
|
+
if (!range || !text) return null
|
|
603
|
+
const endings = /\r\n|\n|\r/g
|
|
604
|
+
let line = 1
|
|
605
|
+
let lineStart = 0
|
|
606
|
+
let start = range.line === 1 ? 0 : null
|
|
607
|
+
let match
|
|
608
|
+
while ((match = endings.exec(text))) {
|
|
609
|
+
if (line === range.endLine) return start === null ? null : text.slice(start, match.index)
|
|
610
|
+
line++
|
|
611
|
+
lineStart = endings.lastIndex
|
|
612
|
+
if (line === range.line) start = endings.lastIndex
|
|
613
|
+
}
|
|
614
|
+
return line === range.endLine && start !== null && lineStart < text.length ? text.slice(start) : null
|
|
615
|
+
}
|
|
616
|
+
|
|
585
617
|
function buildMenuModel(input) {
|
|
586
618
|
const t = input.t || ZH
|
|
587
619
|
const { absolutePath, displayPath, isDir, bytes } = input
|
|
@@ -668,6 +700,9 @@ const factory = () => {
|
|
|
668
700
|
transfer.push({ id: 'copyReference', label: t.copyReference, icon: 'bookmark', action: 'copyReference' })
|
|
669
701
|
}
|
|
670
702
|
if (!isDir && file.canCopyText) {
|
|
703
|
+
if (referenceRange(input.location)) {
|
|
704
|
+
transfer.push({ id: 'copyLines', label: t.copyLines, icon: 'clipboard', action: 'copyLines' })
|
|
705
|
+
}
|
|
671
706
|
transfer.push({ id: 'copyContents', label: t.copyContents, icon: 'clipboard', action: 'copyContents' })
|
|
672
707
|
}
|
|
673
708
|
if (!isDir) {
|
|
@@ -1246,6 +1281,19 @@ const factory = () => {
|
|
|
1246
1281
|
for (let depth = 0; depth < 5 && node && node !== doc.body; depth += 1, node = node.parentElement) {
|
|
1247
1282
|
const value = node.getAttribute && node.getAttribute('title')
|
|
1248
1283
|
if (value && looksLikePath(value) && softPath(value)) {
|
|
1284
|
+
const inline = node.closest('code')
|
|
1285
|
+
const reference = inline && !inline.closest('pre') ? stripDecorations(inline.textContent) : ''
|
|
1286
|
+
const location = stripLocationSuffix(reference)
|
|
1287
|
+
const normalize = text => /^(?:[A-Za-z]:|\\\\|\/\/)/.test(value)
|
|
1288
|
+
? normalizeSlashes(text).toLowerCase() : normalizeSlashes(text)
|
|
1289
|
+
const titledPath = normalize(value)
|
|
1290
|
+
const labelPath = normalize(location.path).replace(/^\.\//, '')
|
|
1291
|
+
// The Host keeps the resolved path in the tooltip but can leave the
|
|
1292
|
+
// location in the code label. Only combine labels naming this same file.
|
|
1293
|
+
if (labelPath && referenceRange(location) && (titledPath === labelPath || titledPath.endsWith(`/${labelPath}`))) {
|
|
1294
|
+
return { path: value + reference.slice(location.path.length), reference,
|
|
1295
|
+
source: 'title', element: node, explicit: true }
|
|
1296
|
+
}
|
|
1249
1297
|
// A file tree keeps the absolute path in the row tooltip: that is a real
|
|
1250
1298
|
// address, so a cold right-click may take it over immediately.
|
|
1251
1299
|
return { path: value, source: 'title', element: node, explicit: isAbsolutePath(value) }
|
|
@@ -1396,6 +1444,15 @@ const factory = () => {
|
|
|
1396
1444
|
*/
|
|
1397
1445
|
render() {
|
|
1398
1446
|
if (!this.root || !this.body) return
|
|
1447
|
+
const sub = this.submenu && {
|
|
1448
|
+
owner: this.submenuFor?.getAttribute(ITEM_ATTR),
|
|
1449
|
+
query: this.searchInput?.value || '',
|
|
1450
|
+
selected: this.subItems[this.subIndex]?.item.id,
|
|
1451
|
+
scrollTop: this.subBody?.scrollTop || 0,
|
|
1452
|
+
typing: document.activeElement === this.searchInput,
|
|
1453
|
+
start: this.searchInput?.selectionStart,
|
|
1454
|
+
end: this.searchInput?.selectionEnd,
|
|
1455
|
+
}
|
|
1399
1456
|
this.closeSubmenu()
|
|
1400
1457
|
const scrollTop = this.body.scrollTop
|
|
1401
1458
|
const painted = this.items.length > 0
|
|
@@ -1432,6 +1489,29 @@ const factory = () => {
|
|
|
1432
1489
|
this.captureAnchorOffset()
|
|
1433
1490
|
}
|
|
1434
1491
|
this.root.setAttribute('aria-label', this.model.title)
|
|
1492
|
+
if (sub) {
|
|
1493
|
+
const owner = this.items.find(entry => entry.item.id === sub.owner && entry.item.children?.length)
|
|
1494
|
+
// A removed selection must not turn Enter into an open of another app.
|
|
1495
|
+
const stillVisible = item => item.id === sub.selected
|
|
1496
|
+
&& String(item.label).toLowerCase().includes(sub.query.trim().toLowerCase())
|
|
1497
|
+
if (owner && (!sub.selected || owner.item.children.some(stillVisible))) {
|
|
1498
|
+
this.openSubmenu(owner)
|
|
1499
|
+
if (this.searchInput) this.searchInput.value = sub.query
|
|
1500
|
+
this.filterSubmenu()
|
|
1501
|
+
const selected = this.subVisible.findIndex(entry => entry.item.id === sub.selected)
|
|
1502
|
+
if (selected >= 0) this.focusSub(selected)
|
|
1503
|
+
if (this.subBody) this.subBody.scrollTop = sub.scrollTop
|
|
1504
|
+
if (sub.typing && this.searchInput) {
|
|
1505
|
+
this.searchInput.focus({ preventScroll: true })
|
|
1506
|
+
this.searchInput.setSelectionRange(sub.start, sub.end)
|
|
1507
|
+
}
|
|
1508
|
+
} else {
|
|
1509
|
+
// Repainting under a stationary pointer can fire mouseenter on the
|
|
1510
|
+
// replacement owner row. A removed selection must stay dismissed.
|
|
1511
|
+
this.blockHoverFor = owner?.item.id
|
|
1512
|
+
if (sub.typing) this.root.focus({ preventScroll: true })
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1435
1515
|
requestAnimationFrame(() => this.updateFade())
|
|
1436
1516
|
}
|
|
1437
1517
|
|
|
@@ -1550,10 +1630,14 @@ const factory = () => {
|
|
|
1550
1630
|
const entry = { element: row, item, disabled: item.disabled === true }
|
|
1551
1631
|
this.items.push(entry)
|
|
1552
1632
|
row.addEventListener('mouseenter', () => {
|
|
1633
|
+
if (this.blockHoverFor === item.id) return
|
|
1553
1634
|
this.focus(this.items.indexOf(entry))
|
|
1554
1635
|
if (item.children) this.openSubmenu(entry)
|
|
1555
1636
|
else this.closeSubmenu()
|
|
1556
1637
|
})
|
|
1638
|
+
row.addEventListener('mouseleave', () => {
|
|
1639
|
+
if (this.blockHoverFor === item.id) this.blockHoverFor = null
|
|
1640
|
+
})
|
|
1557
1641
|
row.addEventListener('click', (event) => {
|
|
1558
1642
|
event.preventDefault()
|
|
1559
1643
|
event.stopPropagation()
|
|
@@ -1846,6 +1930,7 @@ const factory = () => {
|
|
|
1846
1930
|
|
|
1847
1931
|
handleKeyDown(event) {
|
|
1848
1932
|
if (!this.root) return
|
|
1933
|
+
if (event.isComposing || event.keyCode === 229) return
|
|
1849
1934
|
// The lightbox is modal: Escape dismisses it. Every other key is left alone so
|
|
1850
1935
|
// the video transport (space, arrows) keeps working.
|
|
1851
1936
|
if (this.lightbox) {
|
|
@@ -1857,6 +1942,7 @@ const factory = () => {
|
|
|
1857
1942
|
return
|
|
1858
1943
|
}
|
|
1859
1944
|
const typing = this.searchInput && event.target === this.searchInput
|
|
1945
|
+
if (typing && !['ArrowDown', 'ArrowUp', 'Enter', 'Escape', 'Tab'].includes(event.key)) return
|
|
1860
1946
|
// While the submenu is open it owns the arrows, Enter and Escape, so a
|
|
1861
1947
|
// keyboard user can actually pick an application.
|
|
1862
1948
|
if (this.submenu) {
|
|
@@ -1951,6 +2037,7 @@ const factory = () => {
|
|
|
1951
2037
|
// menu when it opens. Only a real window blur may close it.
|
|
1952
2038
|
if (event.type === 'blur' && event.target !== window) return
|
|
1953
2039
|
const target = event.target
|
|
2040
|
+
if (target instanceof Node && this.lightbox?.contains(target)) return
|
|
1954
2041
|
if (target instanceof Node && (this.root.contains(target) || (this.submenu && this.submenu.contains(target)))) return
|
|
1955
2042
|
this.close()
|
|
1956
2043
|
}
|
|
@@ -2161,6 +2248,7 @@ const factory = () => {
|
|
|
2161
2248
|
async function dispatch(item, target, context) {
|
|
2162
2249
|
const { bridge, t, sessionId } = context
|
|
2163
2250
|
const path = target.absolutePath
|
|
2251
|
+
const copyingText = item.action === 'copyContents' || item.action === 'copyLines'
|
|
2164
2252
|
if (item.action === 'openLink' || item.action === 'copyLink' || item.action === 'copyLinkText') {
|
|
2165
2253
|
if (item.action === 'openLink') {
|
|
2166
2254
|
if (!openExternal(target.link)) toast(t.openFailed, { error: true })
|
|
@@ -2208,7 +2296,7 @@ const factory = () => {
|
|
|
2208
2296
|
toast(ok ? t.copiedMarkdown : t.copyFailed, { error: !ok })
|
|
2209
2297
|
return
|
|
2210
2298
|
}
|
|
2211
|
-
if (
|
|
2299
|
+
if (copyingText && typeof target.bytes === 'number' && target.bytes > MAX_COPY_BYTES) {
|
|
2212
2300
|
// The size is already known from the stat; never pull a huge file across
|
|
2213
2301
|
// the wire just to refuse it.
|
|
2214
2302
|
toast(t.tooLarge, { error: true })
|
|
@@ -2241,10 +2329,10 @@ const factory = () => {
|
|
|
2241
2329
|
downloadBytes(bytes, basename(path), mimeOf(path))
|
|
2242
2330
|
return
|
|
2243
2331
|
}
|
|
2244
|
-
if (
|
|
2332
|
+
if (copyingText) {
|
|
2245
2333
|
// Chat text can plant absolute paths from outside the workspace; require
|
|
2246
2334
|
// an explicit confirmation before its bytes reach the clipboard.
|
|
2247
|
-
if (
|
|
2335
|
+
if (target.outsideWorkspace === true) {
|
|
2248
2336
|
const ask = context.confirm || (typeof confirm === 'function' ? confirm : null)
|
|
2249
2337
|
let allowed = false
|
|
2250
2338
|
try {
|
|
@@ -2275,8 +2363,15 @@ const factory = () => {
|
|
|
2275
2363
|
toast(t.binary, { error: true })
|
|
2276
2364
|
return
|
|
2277
2365
|
}
|
|
2366
|
+
if (item.action === 'copyLines') {
|
|
2367
|
+
text = referencedText(text, target)
|
|
2368
|
+
if (text === null) {
|
|
2369
|
+
toast(t.invalidLines, { error: true })
|
|
2370
|
+
return
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2278
2373
|
const ok = await copyText(text)
|
|
2279
|
-
toast(ok ? t.copiedContents : t.copyFailed, { error: !ok })
|
|
2374
|
+
toast(ok ? (item.action === 'copyLines' ? t.copiedLines : t.copiedContents) : t.copyFailed, { error: !ok })
|
|
2280
2375
|
}
|
|
2281
2376
|
}
|
|
2282
2377
|
|
|
@@ -2363,6 +2458,7 @@ const factory = () => {
|
|
|
2363
2458
|
|
|
2364
2459
|
async function openAt(candidate, x, y, keyboard) {
|
|
2365
2460
|
if (disposed) return
|
|
2461
|
+
closeMenu()
|
|
2366
2462
|
const attempt = ++generation
|
|
2367
2463
|
let handle
|
|
2368
2464
|
try {
|
|
@@ -2380,7 +2476,7 @@ const factory = () => {
|
|
|
2380
2476
|
}
|
|
2381
2477
|
const { session, located, path } = locate(candidate)
|
|
2382
2478
|
const modelInput = { absolutePath: path, displayPath: located.path, apps: [], appsState: 'loading',
|
|
2383
|
-
location: located, reference: candidate.path, t }
|
|
2479
|
+
location: located, reference: candidate.reference || candidate.path, t }
|
|
2384
2480
|
let target
|
|
2385
2481
|
handle = new FileMenu({ model: buildStatusModel(path, t.checking, t),
|
|
2386
2482
|
x, y, keyboard, anchor: candidate.element, t,
|
|
@@ -2419,12 +2515,13 @@ const factory = () => {
|
|
|
2419
2515
|
handle.setModel(buildStatusModel(path, t[probe?.error] || t.probeFailed, t, true))
|
|
2420
2516
|
return
|
|
2421
2517
|
}
|
|
2422
|
-
|
|
2518
|
+
const displayPath = relativeTo(session.cwd, probe.absolutePath) || probe.absolutePath
|
|
2519
|
+
Object.assign(modelInput, { absolutePath: probe.absolutePath, displayPath, isDir: probe.isDir,
|
|
2423
2520
|
bytes: probe.bytes, outsideWorkspace: !isInside(session.cwd, probe.absolutePath),
|
|
2424
2521
|
cwd: session.cwd, preferredId: preferences.get(probe.absolutePath) })
|
|
2425
|
-
target = { absolutePath: probe.absolutePath, displayPath
|
|
2426
|
-
isDir: probe.isDir, line: located.line, column: located.column, bytes: probe.bytes,
|
|
2427
|
-
reference: candidate.path, outsideWorkspace: !isInside(session.cwd, probe.absolutePath) }
|
|
2522
|
+
target = { absolutePath: probe.absolutePath, displayPath,
|
|
2523
|
+
isDir: probe.isDir, line: located.line, endLine: located.endLine, column: located.column, bytes: probe.bytes,
|
|
2524
|
+
reference: candidate.reference || candidate.path, outsideWorkspace: !isInside(session.cwd, probe.absolutePath) }
|
|
2428
2525
|
handle.setModel(buildMenuModel(modelInput))
|
|
2429
2526
|
if (!probe.isDir) void enrich(handle, modelInput)
|
|
2430
2527
|
const previewKind = classify(probe.absolutePath, false).kind
|
|
@@ -2715,7 +2812,7 @@ const factory = () => {
|
|
|
2715
2812
|
|
|
2716
2813
|
function onPointerDown(event) {
|
|
2717
2814
|
const target = event.target
|
|
2718
|
-
if (target && target.closest && target.closest(`[${MENU_ATTR}]`)) return
|
|
2815
|
+
if (target && target.closest && target.closest(`[${MENU_ATTR}], .dfa-lightbox`)) return
|
|
2719
2816
|
closeMenu()
|
|
2720
2817
|
}
|
|
2721
2818
|
|
|
@@ -2833,6 +2930,7 @@ const factory = () => {
|
|
|
2833
2930
|
buildMenuModel,
|
|
2834
2931
|
buildLinkMenuModel,
|
|
2835
2932
|
formatLocation,
|
|
2933
|
+
referencedText,
|
|
2836
2934
|
linkFromHref,
|
|
2837
2935
|
candidateFromEvent,
|
|
2838
2936
|
createBridge,
|
package/lib/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
// dsh-file-actions — host half.
|
|
2
|
-
//
|
|
3
|
-
// The whole feature lives in the browser half: it reuses the Session Remote
|
|
4
|
-
// (`session.openWorkspacePath` / `session.workspacePathApplications`) and the
|
|
5
|
-
// workspace-files Remote (`stat` / `readBytes`) that the shipped Web bundle
|
|
6
|
-
// already serves. Nothing here touches the filesystem or the desktop, so this
|
|
7
|
-
// module only satisfies the bundle row and declares its identity.
|
|
8
|
-
|
|
9
|
-
export const name = 'dsh-file-actions'
|
|
10
|
-
|
|
11
|
-
export const inject = []
|
|
12
|
-
|
|
13
|
-
export function apply() {}
|
|
1
|
+
// dsh-file-actions — host half.
|
|
2
|
+
//
|
|
3
|
+
// The whole feature lives in the browser half: it reuses the Session Remote
|
|
4
|
+
// (`session.openWorkspacePath` / `session.workspacePathApplications`) and the
|
|
5
|
+
// workspace-files Remote (`stat` / `readBytes`) that the shipped Web bundle
|
|
6
|
+
// already serves. Nothing here touches the filesystem or the desktop, so this
|
|
7
|
+
// module only satisfies the bundle row and declares its identity.
|
|
8
|
+
|
|
9
|
+
export const name = 'dsh-file-actions'
|
|
10
|
+
|
|
11
|
+
export const inject = []
|
|
12
|
+
|
|
13
|
+
export function apply() {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jidekaixin2dian/dsh-file-actions",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "File and link actions for DeepSeek Harness: open, choose applications, reveal, copy paths or contents, and save files from the chat.",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"type": "module",
|