@xi-ix/dsh-multi-sync 0.0.0-stage → 0.1.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 +62 -2
- package/client.js +567 -0
- package/cordis.patch.yml +3 -0
- package/docs/DETAIL.md +61 -0
- package/icon.svg +13 -0
- package/index.js +551 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +49 -4
package/README.md
CHANGED
|
@@ -1,3 +1,63 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Multi-machine plugin sync
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Carries the plugin set from one machine to another as a single pinned list, without
|
|
4
|
+
moving `node_modules`, a lockfile, or a credentials file between them.
|
|
5
|
+
|
|
6
|
+
## What it does
|
|
7
|
+
|
|
8
|
+
The plugin state that actually travels is small: which packages are installed and
|
|
9
|
+
which exact version each one has. This plugin reads that from the running profile
|
|
10
|
+
and writes it to one portable JSON document.
|
|
11
|
+
|
|
12
|
+
- **Scan** reads the profile's direct `dependencies`, keeps every entry that a
|
|
13
|
+
registry can serve, and asks the installed package on disk for its real version —
|
|
14
|
+
not the `^0.4.2` range in `package.json`. Entries that cannot be fetched
|
|
15
|
+
(`file:`, `link:`, `workspace:`, `git+`, `http:`) are listed separately as
|
|
16
|
+
skipped, with the reason, so a difference between two machines is visible
|
|
17
|
+
instead of silent.
|
|
18
|
+
- **Export** writes the scan as `dsh-plugins.json`. Each entry carries its exact
|
|
19
|
+
version and, when the profile lockfile records one, the tarball's `integrity`
|
|
20
|
+
hash — the value that makes "same plugin" mean the same bytes rather than the
|
|
21
|
+
same version number.
|
|
22
|
+
- **Import** reads a list back (file, drag-and-drop, or pasted text), compares each
|
|
23
|
+
entry with what this machine already has, and shows one row per plugin with the
|
|
24
|
+
action it would take: new, upgrade, already installed, or unavailable.
|
|
25
|
+
- **Install** sends the selected `name@version` specifications to
|
|
26
|
+
`dsh plugin --profile <name> add …` in one call. The DSH plugin manager installs
|
|
27
|
+
them, registers new bundles in `dsh.profile.bundles`, runs its compatibility
|
|
28
|
+
checks, and writes the lockfile.
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
1. Open **Settings → Multi-sync**.
|
|
33
|
+
2. On the machine that already has the plugins, choose **Source**, press
|
|
34
|
+
**Scan installed plugins**, then **Export** (or copy the text).
|
|
35
|
+
3. Move the file to the other machine however you like.
|
|
36
|
+
4. There, choose **Follower**, drop the file in, pick the entries to install, and
|
|
37
|
+
press **Install selected**.
|
|
38
|
+
5. Restart DeepSeek Harness so the newly installed plugins load.
|
|
39
|
+
|
|
40
|
+
The first time, the follower has no copy of this plugin yet, so install it by hand
|
|
41
|
+
once: `dsh plugin --profile desktop add @xi-ix/dsh-multi-sync@<version>`.
|
|
42
|
+
|
|
43
|
+
## What it deliberately does not do
|
|
44
|
+
|
|
45
|
+
- **It does not restart the harness.** Restarting belongs to the desktop shell, and a
|
|
46
|
+
plugin cannot reach it: the shell accepts no restart request from a host, and every
|
|
47
|
+
process this plugin starts is reaped with the app. Restart with the tray icon on
|
|
48
|
+
Windows (right-click → Quit DeepSeek Harness, then reopen) or the menu on macOS.
|
|
49
|
+
- **It does not touch enable/disable state or per-plugin configuration.** Those
|
|
50
|
+
live in `cordis.patch.yml` and the plugin market's `state.json`, which the market
|
|
51
|
+
owns and rewrites; a second writer there gets reverted. A plugin installed here
|
|
52
|
+
keeps its own default on/off state on the follower.
|
|
53
|
+
- **It does not mirror deletions.** Installing never removes a plugin that the list
|
|
54
|
+
does not mention.
|
|
55
|
+
- **It does not pin transitive dependencies.** Each listed plugin's own
|
|
56
|
+
`dependencies` still resolve at install time, so two machines can differ below
|
|
57
|
+
the top level if a plugin dependency allows a range.
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
|
|
61
|
+
DeepSeek Harness with its bundled `dsh` CLI available either through
|
|
62
|
+
`DSH_NODE_EXECUTABLE`/`DSH_INSTALL_DIR` or on `PATH`, and network access to the
|
|
63
|
+
registry that serves the listed packages.
|
package/client.js
ADDED
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: '@xi-ix/dsh-multi-sync',
|
|
3
|
+
factory(require) {
|
|
4
|
+
const React = require('react')
|
|
5
|
+
const h = React.createElement
|
|
6
|
+
const { useState, useEffect, useCallback, useRef } = React
|
|
7
|
+
|
|
8
|
+
const BASE = '/dsh-multi-sync'
|
|
9
|
+
|
|
10
|
+
const zh =
|
|
11
|
+
(typeof navigator !== 'undefined' && /^zh/i.test(navigator.language || '')) ||
|
|
12
|
+
(typeof document !== 'undefined' && /^zh/i.test(document.documentElement.lang || ''))
|
|
13
|
+
|
|
14
|
+
const L = zh
|
|
15
|
+
? {
|
|
16
|
+
title: '多端插件同步',
|
|
17
|
+
subtitle: '把这台机器装好的插件,按精确版本带到另一台机器。',
|
|
18
|
+
role: '这台机器的角色',
|
|
19
|
+
source: '源机',
|
|
20
|
+
follower: '从属机',
|
|
21
|
+
sourceHint: '扫描本机插件,导出一份清单,用任意方式传到另一台机器。',
|
|
22
|
+
followerHint: '载入清单,勾选要装的插件,一次性安装。',
|
|
23
|
+
scan: '扫描本机插件',
|
|
24
|
+
scanning: '扫描中…',
|
|
25
|
+
export: '导出 dsh-plugins.json',
|
|
26
|
+
copy: '复制清单',
|
|
27
|
+
copied: '已复制',
|
|
28
|
+
profile: 'profile',
|
|
29
|
+
version: 'DSH',
|
|
30
|
+
plugins: '插件',
|
|
31
|
+
skipped: '跳过',
|
|
32
|
+
name: '包名',
|
|
33
|
+
pinned: '版本',
|
|
34
|
+
kind: '类型',
|
|
35
|
+
drop: '把清单文件拖到这里,或',
|
|
36
|
+
choose: '选择文件',
|
|
37
|
+
orPaste: '也可以直接粘贴内容',
|
|
38
|
+
parse: '解析清单',
|
|
39
|
+
install: '安装选中的',
|
|
40
|
+
installing: '安装中…',
|
|
41
|
+
cancel: '取消',
|
|
42
|
+
selectAll: '全选可安装',
|
|
43
|
+
empty: '还没有扫描结果。',
|
|
44
|
+
noRows: '清单里没有可安装的 npm 插件。',
|
|
45
|
+
from: '清单来源',
|
|
46
|
+
generatedAt: '生成时间',
|
|
47
|
+
mismatch: '清单来自另一台机器,DSH 版本不同,安装前请留意。',
|
|
48
|
+
localConflict: '本机是本地挂载',
|
|
49
|
+
done: '完成',
|
|
50
|
+
failed: '失败',
|
|
51
|
+
same: '已装',
|
|
52
|
+
upgrade: '升级',
|
|
53
|
+
downgrade: '降级',
|
|
54
|
+
linked: '本地挂载',
|
|
55
|
+
added: '新增',
|
|
56
|
+
local: '本地',
|
|
57
|
+
remote: '非 registry',
|
|
58
|
+
unknown: '未知',
|
|
59
|
+
alreadyTitle: '这些已经装过,不会重复处理',
|
|
60
|
+
linkedHint: '本机是本地挂载(file:/link:),装上会用 registry 里的包替换它。',
|
|
61
|
+
downgradeHint: '本机版本比清单里的新,勾选会降级。',
|
|
62
|
+
restartHintWindows: '装完或更新完插件后需要重启:右下角托盘图标 → 右键 → 退出 DeepSeek Harness,再重新打开。',
|
|
63
|
+
restartHintMac: '装完或更新完插件后需要重启:菜单栏 DeepSeek Harness → 重启应用与 Host。',
|
|
64
|
+
restartHintWeb: '装完插件后需要重启:退出当前进程,重新运行 dsh web。',
|
|
65
|
+
restartAfterInstall: '安装完成,重启后生效。',
|
|
66
|
+
}
|
|
67
|
+
: {
|
|
68
|
+
title: 'Multi-machine plugin sync',
|
|
69
|
+
subtitle: 'Carry the plugins installed here to the other machine, pinned to exact versions.',
|
|
70
|
+
role: 'Role of this machine',
|
|
71
|
+
source: 'Source',
|
|
72
|
+
follower: 'Follower',
|
|
73
|
+
sourceHint: 'Scan this machine, export one list, move it however you like.',
|
|
74
|
+
followerHint: 'Load a list, pick what to install, install once.',
|
|
75
|
+
scan: 'Scan installed plugins',
|
|
76
|
+
scanning: 'Scanning…',
|
|
77
|
+
export: 'Export dsh-plugins.json',
|
|
78
|
+
copy: 'Copy list',
|
|
79
|
+
copied: 'Copied',
|
|
80
|
+
profile: 'profile',
|
|
81
|
+
version: 'DSH',
|
|
82
|
+
plugins: 'plugins',
|
|
83
|
+
skipped: 'skipped',
|
|
84
|
+
name: 'Package',
|
|
85
|
+
pinned: 'Version',
|
|
86
|
+
kind: 'Kind',
|
|
87
|
+
drop: 'Drop the list file here, or',
|
|
88
|
+
choose: 'choose a file',
|
|
89
|
+
orPaste: 'or paste it',
|
|
90
|
+
parse: 'Read list',
|
|
91
|
+
install: 'Install selected',
|
|
92
|
+
installing: 'Installing…',
|
|
93
|
+
cancel: 'Cancel',
|
|
94
|
+
selectAll: 'Select installable',
|
|
95
|
+
empty: 'Nothing scanned yet.',
|
|
96
|
+
noRows: 'The list has no installable npm plugin.',
|
|
97
|
+
from: 'List from',
|
|
98
|
+
generatedAt: 'Generated',
|
|
99
|
+
mismatch: 'This list came from a machine running a different DSH version — check before installing.',
|
|
100
|
+
localConflict: 'locally linked here',
|
|
101
|
+
done: 'done',
|
|
102
|
+
failed: 'failed',
|
|
103
|
+
same: 'installed',
|
|
104
|
+
upgrade: 'upgrade',
|
|
105
|
+
downgrade: 'downgrade',
|
|
106
|
+
linked: 'local link',
|
|
107
|
+
added: 'new',
|
|
108
|
+
local: 'local',
|
|
109
|
+
remote: 'non-registry',
|
|
110
|
+
unknown: 'unknown',
|
|
111
|
+
alreadyTitle: 'Already installed — left untouched',
|
|
112
|
+
linkedHint: 'This machine links it locally (file:/link:); installing replaces that mount with the registry package.',
|
|
113
|
+
downgradeHint: 'This machine has a newer version; selecting it would downgrade.',
|
|
114
|
+
restartHintWindows: 'After installing or updating plugins, restart: right-click the tray icon and choose Quit DeepSeek Harness, then reopen it.',
|
|
115
|
+
restartHintMac: 'After installing or updating plugins, restart from the menu bar: DeepSeek Harness → Restart App and Host.',
|
|
116
|
+
restartHintWeb: 'After installing plugins, restart by stopping this process and running dsh web again.',
|
|
117
|
+
restartAfterInstall: 'Installed — takes effect after a restart.',
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const CSS = `
|
|
121
|
+
.dms { display: flex; flex-direction: column; gap: 14px; color: var(--dsw-alias-label-primary); }
|
|
122
|
+
.dms h2 { margin: 0; font-size: 15px; font-weight: 600; }
|
|
123
|
+
.dms .sub { font-size: 12px; opacity: .7; margin: 0; }
|
|
124
|
+
.dms .card { border: 1px solid var(--dsw-alias-border-l2, #ddd); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
|
|
125
|
+
.dms .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
126
|
+
.dms .grow { flex: 1; }
|
|
127
|
+
.dms button { padding: 5px 11px; border: 1px solid var(--dsw-alias-border-l2, #ddd); border-radius: 7px; background: transparent; color: inherit; cursor: pointer; font-size: 13px; }
|
|
128
|
+
.dms button:hover:not(:disabled) { background: var(--dsw-alias-bg-layer-2, #f3f3f3); }
|
|
129
|
+
.dms button.primary { background: var(--dsw-alias-brand-primary, #4f46e5); border-color: transparent; color: #fff; }
|
|
130
|
+
/* Keep the filled button filled on hover: the generic rule above would swap its
|
|
131
|
+
background for a light layer while the label stays white. */
|
|
132
|
+
.dms button.primary:hover:not(:disabled) { background: var(--dsw-alias-brand-primary, #4f46e5); filter: brightness(1.12); }
|
|
133
|
+
.dms button.active { background: var(--dsw-alias-interactive-bg, #ececf5); font-weight: 600; }
|
|
134
|
+
.dms button:disabled { opacity: .5; cursor: default; }
|
|
135
|
+
.dms table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
|
136
|
+
.dms th, .dms td { text-align: left; padding: 5px 7px; border-bottom: 1px solid var(--dsw-alias-border-l1, #eee); }
|
|
137
|
+
.dms th { font-weight: 600; opacity: .7; }
|
|
138
|
+
.dms .muted { opacity: .65; font-size: 11px; }
|
|
139
|
+
.dms .msg { font-size: 12px; padding: 8px 10px; border-radius: 7px; background: var(--dsw-alias-bg-layer-2, #f5f5f5); white-space: pre-wrap; word-break: break-word; }
|
|
140
|
+
.dms .msg.err { background: var(--dsw-alias-state-error-soft, #fdecec); }
|
|
141
|
+
.dms .msg.ok { background: var(--dsw-alias-state-success-soft, #eaf7ee); }
|
|
142
|
+
.dms textarea { width: 100%; min-height: 120px; font-family: ui-monospace, monospace; font-size: 12px; padding: 8px; border-radius: 8px; border: 1px solid var(--dsw-alias-border-l2, #ddd); background: var(--dsw-alias-bg-layer-1, #fff); color: inherit; }
|
|
143
|
+
.dms .drop { border: 1px dashed var(--dsw-alias-border-l2, #ccc); border-radius: 9px; padding: 14px; text-align: center; font-size: 12px; }
|
|
144
|
+
.dms .overlay { position: fixed; inset: 0; background: rgba(0,0,0,.42); display: flex; align-items: center; justify-content: center; z-index: 60; }
|
|
145
|
+
.dms .modal { background: var(--dsw-alias-bg-layer-1, #fff); color: var(--dsw-alias-label-primary, #111); border-radius: 14px; padding: 16px; width: min(680px, 92vw); max-height: 84vh; overflow: auto; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
|
|
146
|
+
.dms .badge { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 11px; background: var(--dsw-alias-bg-layer-2, #f0f0f0); }
|
|
147
|
+
.dms .badge.new { background: var(--dsw-alias-state-success-soft, #e7f6ec); }
|
|
148
|
+
.dms .badge.upgrade { background: var(--dsw-alias-state-info-soft, #e8f0fe); }
|
|
149
|
+
.dms .file { display: inline-block; }
|
|
150
|
+
.dms .file input { display: none; }
|
|
151
|
+
`
|
|
152
|
+
|
|
153
|
+
async function api(path, options) {
|
|
154
|
+
const response = await fetch(BASE + path, {
|
|
155
|
+
cache: 'no-store',
|
|
156
|
+
credentials: 'same-origin',
|
|
157
|
+
...options,
|
|
158
|
+
})
|
|
159
|
+
const body = await response.json().catch(() => null)
|
|
160
|
+
if (!response.ok || body === null || body.ok === false) {
|
|
161
|
+
throw new Error((body && body.error) || `HTTP ${response.status}`)
|
|
162
|
+
}
|
|
163
|
+
return body
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function post(path, value) {
|
|
167
|
+
return api(path, {
|
|
168
|
+
method: 'POST',
|
|
169
|
+
headers: { 'content-type': 'application/json' },
|
|
170
|
+
body: JSON.stringify(value),
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function download(text, filename) {
|
|
175
|
+
try {
|
|
176
|
+
const blob = new Blob([text], { type: 'application/json' })
|
|
177
|
+
const href = URL.createObjectURL(blob)
|
|
178
|
+
const anchor = document.createElement('a')
|
|
179
|
+
anchor.href = href
|
|
180
|
+
anchor.download = filename
|
|
181
|
+
document.body.appendChild(anchor)
|
|
182
|
+
anchor.click()
|
|
183
|
+
anchor.remove()
|
|
184
|
+
setTimeout(() => URL.revokeObjectURL(href), 4000)
|
|
185
|
+
return true
|
|
186
|
+
} catch {
|
|
187
|
+
return false
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function Panel() {
|
|
192
|
+
const [info, setInfo] = useState(null)
|
|
193
|
+
const [role, setRole] = useState('source')
|
|
194
|
+
const [list, setList] = useState(null)
|
|
195
|
+
const [text, setText] = useState('')
|
|
196
|
+
const [rows, setRows] = useState(null)
|
|
197
|
+
const [header, setHeader] = useState(null)
|
|
198
|
+
const [selected, setSelected] = useState({})
|
|
199
|
+
const [busy, setBusy] = useState('')
|
|
200
|
+
const [message, setMessage] = useState(null)
|
|
201
|
+
const [result, setResult] = useState(null)
|
|
202
|
+
const fileInput = useRef(null)
|
|
203
|
+
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
let alive = true
|
|
206
|
+
api('/state')
|
|
207
|
+
.then((body) => {
|
|
208
|
+
if (!alive) return
|
|
209
|
+
setInfo(body)
|
|
210
|
+
setRole(body.role)
|
|
211
|
+
})
|
|
212
|
+
.catch((error) => alive && setMessage({ kind: 'err', text: String(error.message || error) }))
|
|
213
|
+
return () => {
|
|
214
|
+
alive = false
|
|
215
|
+
}
|
|
216
|
+
}, [])
|
|
217
|
+
|
|
218
|
+
const asJson = useCallback(() => {
|
|
219
|
+
if (list === null) return ''
|
|
220
|
+
return JSON.stringify(list, undefined, 2) + '\n'
|
|
221
|
+
}, [list])
|
|
222
|
+
|
|
223
|
+
const changeRole = useCallback(async (next) => {
|
|
224
|
+
setBusy('role')
|
|
225
|
+
try {
|
|
226
|
+
const body = await post('/role', { role: next })
|
|
227
|
+
setRole(body.role)
|
|
228
|
+
} catch (error) {
|
|
229
|
+
setMessage({ kind: 'err', text: String(error.message || error) })
|
|
230
|
+
} finally {
|
|
231
|
+
setBusy('')
|
|
232
|
+
}
|
|
233
|
+
}, [])
|
|
234
|
+
|
|
235
|
+
const runScan = useCallback(async () => {
|
|
236
|
+
setBusy('scan')
|
|
237
|
+
setMessage(null)
|
|
238
|
+
try {
|
|
239
|
+
const body = await api('/scan')
|
|
240
|
+
setList(body.list)
|
|
241
|
+
setText(JSON.stringify(body.list, undefined, 2) + '\n')
|
|
242
|
+
} catch (error) {
|
|
243
|
+
setMessage({ kind: 'err', text: String(error.message || error) })
|
|
244
|
+
} finally {
|
|
245
|
+
setBusy('')
|
|
246
|
+
}
|
|
247
|
+
}, [])
|
|
248
|
+
|
|
249
|
+
const doExport = useCallback(() => {
|
|
250
|
+
const json = asJson()
|
|
251
|
+
if (json === '') return
|
|
252
|
+
const saved = download(json, 'dsh-plugins.json')
|
|
253
|
+
setMessage(
|
|
254
|
+
saved
|
|
255
|
+
? { kind: 'ok', text: zh ? '已开始下载 dsh-plugins.json(也可以复制下面的内容)' : 'Download started (you can also copy the text below)' }
|
|
256
|
+
: { kind: 'ok', text: zh ? '无法下载,请复制下面的内容' : 'Download unavailable — copy the text below' },
|
|
257
|
+
)
|
|
258
|
+
}, [asJson])
|
|
259
|
+
|
|
260
|
+
const doCopy = useCallback(async () => {
|
|
261
|
+
const json = asJson()
|
|
262
|
+
if (json === '') return
|
|
263
|
+
try {
|
|
264
|
+
await navigator.clipboard.writeText(json)
|
|
265
|
+
setMessage({ kind: 'ok', text: L.copied })
|
|
266
|
+
} catch {
|
|
267
|
+
setMessage({ kind: 'err', text: zh ? '复制失败,请手动选中复制' : 'Copy failed — select the text manually' })
|
|
268
|
+
}
|
|
269
|
+
}, [asJson])
|
|
270
|
+
|
|
271
|
+
const readList = useCallback(async (value) => {
|
|
272
|
+
setBusy('parse')
|
|
273
|
+
setMessage(null)
|
|
274
|
+
try {
|
|
275
|
+
const body = await post('/parse', { text: value })
|
|
276
|
+
const next = {}
|
|
277
|
+
for (const row of body.rows) {
|
|
278
|
+
if (row.state === 'new' || row.state === 'upgrade') next[row.name] = true
|
|
279
|
+
}
|
|
280
|
+
setRows(body.rows)
|
|
281
|
+
setHeader(body.header)
|
|
282
|
+
setSelected(next)
|
|
283
|
+
} catch (error) {
|
|
284
|
+
setMessage({ kind: 'err', text: String(error.message || error) })
|
|
285
|
+
} finally {
|
|
286
|
+
setBusy('')
|
|
287
|
+
}
|
|
288
|
+
}, [])
|
|
289
|
+
|
|
290
|
+
const onFile = useCallback(
|
|
291
|
+
(file) => {
|
|
292
|
+
if (!file) return
|
|
293
|
+
const reader = new FileReader()
|
|
294
|
+
reader.onload = () => {
|
|
295
|
+
const value = String(reader.result || '')
|
|
296
|
+
setText(value)
|
|
297
|
+
void readList(value)
|
|
298
|
+
}
|
|
299
|
+
reader.readAsText(file)
|
|
300
|
+
},
|
|
301
|
+
[readList],
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
const install = useCallback(async () => {
|
|
305
|
+
const items = (rows || []).filter((row) => selected[row.name]).map((row) => ({ name: row.name, version: row.version }))
|
|
306
|
+
if (items.length === 0) return
|
|
307
|
+
setBusy('install')
|
|
308
|
+
setMessage(null)
|
|
309
|
+
try {
|
|
310
|
+
const body = await post('/apply', { items })
|
|
311
|
+
setResult(body.result)
|
|
312
|
+
setRows(null)
|
|
313
|
+
if (body.result.ok) {
|
|
314
|
+
setMessage({ kind: 'ok', text: L.restartAfterInstall })
|
|
315
|
+
const state = await api('/scan').catch(() => null)
|
|
316
|
+
if (state) setList(state.list)
|
|
317
|
+
} else {
|
|
318
|
+
setMessage({ kind: 'err', text: body.result.stderr || body.result.message || 'install failed' })
|
|
319
|
+
}
|
|
320
|
+
} catch (error) {
|
|
321
|
+
setMessage({ kind: 'err', text: String(error.message || error) })
|
|
322
|
+
} finally {
|
|
323
|
+
setBusy('')
|
|
324
|
+
}
|
|
325
|
+
}, [rows, selected])
|
|
326
|
+
|
|
327
|
+
const checkbox = (row) =>
|
|
328
|
+
h('input', {
|
|
329
|
+
type: 'checkbox',
|
|
330
|
+
checked: selected[row.name] === true,
|
|
331
|
+
disabled: row.state === 'same',
|
|
332
|
+
onChange: (event) => setSelected((current) => ({ ...current, [row.name]: event.target.checked })),
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
const counts = { new: 0, upgrade: 0, same: 0, downgrade: 0, linked: 0 }
|
|
336
|
+
for (const row of rows || []) counts[row.state] = (counts[row.state] || 0) + 1
|
|
337
|
+
|
|
338
|
+
const modal =
|
|
339
|
+
rows === null
|
|
340
|
+
? null
|
|
341
|
+
: h(
|
|
342
|
+
'div',
|
|
343
|
+
{ className: 'overlay', onClick: (event) => event.target === event.currentTarget && busy !== 'install' && setRows(null) },
|
|
344
|
+
h(
|
|
345
|
+
'div',
|
|
346
|
+
{ className: 'modal' },
|
|
347
|
+
h('h2', null, zh ? '选择要安装的插件' : 'Choose plugins to install'),
|
|
348
|
+
header && (header.dsh || header.generatedAt)
|
|
349
|
+
? h(
|
|
350
|
+
'div',
|
|
351
|
+
{ className: 'muted' },
|
|
352
|
+
`${L.from}: ${header.profile || '—'} / ${L.generatedAt}: ${header.generatedAt || '—'} / ${L.version}: ${header.dsh || '—'}`,
|
|
353
|
+
)
|
|
354
|
+
: null,
|
|
355
|
+
header && info && header.dsh && info.dsh && header.dsh !== info.dsh
|
|
356
|
+
? h('div', { className: 'msg err' }, L.mismatch)
|
|
357
|
+
: null,
|
|
358
|
+
rows.length === 0
|
|
359
|
+
? h('div', { className: 'muted' }, L.noRows)
|
|
360
|
+
: h(
|
|
361
|
+
'table',
|
|
362
|
+
null,
|
|
363
|
+
h(
|
|
364
|
+
'thead',
|
|
365
|
+
null,
|
|
366
|
+
h('tr', null, h('th', null, ''), h('th', null, L.name), h('th', null, L.pinned), h('th', null, 'now'), h('th', null, '')),
|
|
367
|
+
),
|
|
368
|
+
h(
|
|
369
|
+
'tbody',
|
|
370
|
+
null,
|
|
371
|
+
rows.map((row) =>
|
|
372
|
+
h(
|
|
373
|
+
'tr',
|
|
374
|
+
{ key: row.name },
|
|
375
|
+
h('td', null, checkbox(row)),
|
|
376
|
+
h('td', null, row.name),
|
|
377
|
+
h('td', null, row.version),
|
|
378
|
+
h('td', null, row.installed || '—'),
|
|
379
|
+
h(
|
|
380
|
+
'td',
|
|
381
|
+
null,
|
|
382
|
+
h('span', { className: 'badge ' + row.state }, L[row.state] || row.state),
|
|
383
|
+
),
|
|
384
|
+
),
|
|
385
|
+
),
|
|
386
|
+
),
|
|
387
|
+
),
|
|
388
|
+
h(
|
|
389
|
+
'div',
|
|
390
|
+
{ className: 'muted' },
|
|
391
|
+
[
|
|
392
|
+
counts.new ? `${counts.new} ${L.added}` : '',
|
|
393
|
+
counts.upgrade ? `${counts.upgrade} ${L.upgrade}` : '',
|
|
394
|
+
counts.same ? `${counts.same} ${L.same}` : '',
|
|
395
|
+
counts.downgrade ? `${counts.downgrade} ${L.downgrade}` : '',
|
|
396
|
+
counts.linked ? `${counts.linked} ${L.linked}` : '',
|
|
397
|
+
]
|
|
398
|
+
.filter(Boolean)
|
|
399
|
+
.join(' · '),
|
|
400
|
+
),
|
|
401
|
+
counts.same ? h('div', { className: 'muted' }, `${L.alreadyTitle}: ${rows.filter((row) => row.state === 'same').map((row) => row.name).join(', ')}`) : null,
|
|
402
|
+
counts.linked ? h('div', { className: 'msg' }, L.linkedHint) : null,
|
|
403
|
+
counts.downgrade ? h('div', { className: 'msg' }, L.downgradeHint) : null,
|
|
404
|
+
h(
|
|
405
|
+
'div',
|
|
406
|
+
{ className: 'row' },
|
|
407
|
+
h(
|
|
408
|
+
'button',
|
|
409
|
+
{
|
|
410
|
+
onClick: () => {
|
|
411
|
+
const next = {}
|
|
412
|
+
for (const row of rows) if (row.state === 'new' || row.state === 'upgrade') next[row.name] = true
|
|
413
|
+
setSelected(next)
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
L.selectAll,
|
|
417
|
+
),
|
|
418
|
+
h('span', { className: 'grow' }),
|
|
419
|
+
h('button', { onClick: () => setRows(null), disabled: busy === 'install' }, L.cancel),
|
|
420
|
+
h(
|
|
421
|
+
'button',
|
|
422
|
+
{ className: 'primary', onClick: install, disabled: busy === 'install' },
|
|
423
|
+
busy === 'install' ? L.installing : L.install,
|
|
424
|
+
),
|
|
425
|
+
),
|
|
426
|
+
),
|
|
427
|
+
)
|
|
428
|
+
|
|
429
|
+
const sourceBody = h(
|
|
430
|
+
React.Fragment,
|
|
431
|
+
null,
|
|
432
|
+
h(
|
|
433
|
+
'div',
|
|
434
|
+
{ className: 'card' },
|
|
435
|
+
h('p', { className: 'sub' }, L.sourceHint),
|
|
436
|
+
h(
|
|
437
|
+
'div',
|
|
438
|
+
{ className: 'row' },
|
|
439
|
+
h('button', { className: 'primary', onClick: runScan, disabled: busy !== '' }, busy === 'scan' ? L.scanning : L.scan),
|
|
440
|
+
h('button', { onClick: doExport, disabled: list === null }, L.export),
|
|
441
|
+
h('button', { onClick: doCopy, disabled: list === null }, L.copy),
|
|
442
|
+
),
|
|
443
|
+
list === null
|
|
444
|
+
? h('div', { className: 'muted' }, L.empty)
|
|
445
|
+
: h(
|
|
446
|
+
React.Fragment,
|
|
447
|
+
null,
|
|
448
|
+
h('div', { className: 'muted' }, `${L.plugins}: ${list.plugins.length} · ${L.skipped}: ${list.skipped.length} · ${L.profile}: ${list.profile} · ${L.version}: ${list.dsh || '—'}`),
|
|
449
|
+
h(
|
|
450
|
+
'table',
|
|
451
|
+
null,
|
|
452
|
+
h('thead', null, h('tr', null, h('th', null, L.name), h('th', null, L.pinned), h('th', null, L.kind))),
|
|
453
|
+
h(
|
|
454
|
+
'tbody',
|
|
455
|
+
null,
|
|
456
|
+
list.plugins.map((row) =>
|
|
457
|
+
h(
|
|
458
|
+
'tr',
|
|
459
|
+
{ key: row.name },
|
|
460
|
+
h('td', null, row.name),
|
|
461
|
+
h('td', null, row.version || '—'),
|
|
462
|
+
h('td', null, row.bundle ? 'bundle' : 'dep'),
|
|
463
|
+
),
|
|
464
|
+
),
|
|
465
|
+
list.skipped.map((row) =>
|
|
466
|
+
h(
|
|
467
|
+
'tr',
|
|
468
|
+
{ key: row.name },
|
|
469
|
+
h('td', null, row.name),
|
|
470
|
+
h('td', { className: 'muted' }, row.spec),
|
|
471
|
+
h('td', null, h('span', { className: 'badge' }, L[row.reason] || row.reason)),
|
|
472
|
+
),
|
|
473
|
+
),
|
|
474
|
+
),
|
|
475
|
+
),
|
|
476
|
+
),
|
|
477
|
+
),
|
|
478
|
+
list === null
|
|
479
|
+
? null
|
|
480
|
+
: h('textarea', {
|
|
481
|
+
value: asJson(),
|
|
482
|
+
readOnly: true,
|
|
483
|
+
spellCheck: false,
|
|
484
|
+
onFocus: (event) => event.target.select(),
|
|
485
|
+
}),
|
|
486
|
+
)
|
|
487
|
+
|
|
488
|
+
const followerBody = h(
|
|
489
|
+
React.Fragment,
|
|
490
|
+
null,
|
|
491
|
+
h(
|
|
492
|
+
'div',
|
|
493
|
+
{ className: 'card' },
|
|
494
|
+
h('p', { className: 'sub' }, L.followerHint),
|
|
495
|
+
h(
|
|
496
|
+
'div',
|
|
497
|
+
{
|
|
498
|
+
className: 'drop',
|
|
499
|
+
onDragOver: (event) => event.preventDefault(),
|
|
500
|
+
onDrop: (event) => {
|
|
501
|
+
event.preventDefault()
|
|
502
|
+
onFile(event.dataTransfer.files && event.dataTransfer.files[0])
|
|
503
|
+
},
|
|
504
|
+
},
|
|
505
|
+
L.drop,
|
|
506
|
+
' ',
|
|
507
|
+
h('label', { className: 'file' }, h('input', { type: 'file', accept: '.json,.txt', onChange: (event) => onFile(event.target.files && event.target.files[0]) }), h('u', null, L.choose)),
|
|
508
|
+
),
|
|
509
|
+
h('div', { className: 'muted' }, L.orPaste),
|
|
510
|
+
h('textarea', { value: text, spellCheck: false, placeholder: '[\n { "name": "dsh-webpage", "version": "0.1.1" }\n]', onChange: (event) => setText(event.target.value) }),
|
|
511
|
+
h(
|
|
512
|
+
'div',
|
|
513
|
+
{ className: 'row' },
|
|
514
|
+
h('button', { className: 'primary', onClick: () => readList(text), disabled: text.trim() === '' || busy !== '' }, busy === 'parse' ? '…' : L.parse),
|
|
515
|
+
),
|
|
516
|
+
),
|
|
517
|
+
)
|
|
518
|
+
|
|
519
|
+
// Windows has no application menu at all (the shell registers only hidden
|
|
520
|
+
// devtools accelerators there), so the documented restart route differs by
|
|
521
|
+
// platform instead of pretending one label exists everywhere.
|
|
522
|
+
const restartHint =
|
|
523
|
+
info && info.platform === 'darwin'
|
|
524
|
+
? L.restartHintMac
|
|
525
|
+
: info && info.desktop === false
|
|
526
|
+
? L.restartHintWeb
|
|
527
|
+
: L.restartHintWindows
|
|
528
|
+
|
|
529
|
+
return h(
|
|
530
|
+
'div',
|
|
531
|
+
{ className: 'dms' },
|
|
532
|
+
h('style', null, CSS),
|
|
533
|
+
h('h2', null, L.title),
|
|
534
|
+
h('p', { className: 'sub' }, L.subtitle),
|
|
535
|
+
h(
|
|
536
|
+
'div',
|
|
537
|
+
{ className: 'card' },
|
|
538
|
+
h(
|
|
539
|
+
'div',
|
|
540
|
+
{ className: 'row' },
|
|
541
|
+
h('span', { className: 'muted' }, L.role),
|
|
542
|
+
h('button', { className: role === 'source' ? 'active' : '', onClick: () => changeRole('source'), disabled: busy === 'role' }, L.source),
|
|
543
|
+
h('button', { className: role === 'follower' ? 'active' : '', onClick: () => changeRole('follower'), disabled: busy === 'role' }, L.follower),
|
|
544
|
+
h('span', { className: 'grow' }),
|
|
545
|
+
h('span', { className: 'muted' }, info ? `${info.profile} · ${info.dsh || ''}` : ''),
|
|
546
|
+
),
|
|
547
|
+
h('div', { className: 'muted' }, restartHint),
|
|
548
|
+
),
|
|
549
|
+
role === 'source' ? sourceBody : followerBody,
|
|
550
|
+
message === null ? null : h('div', { className: 'msg ' + (message.kind === 'ok' ? 'ok' : 'err') }, message.text),
|
|
551
|
+
result && result.stdout ? h('div', { className: 'msg' }, result.stdout) : null,
|
|
552
|
+
modal,
|
|
553
|
+
)
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function apply(ctx) {
|
|
557
|
+
ctx.slots.inject('settings.section', () =>
|
|
558
|
+
ctx.slots.register(
|
|
559
|
+
{ name: 'settings.section', id: 'dsh-multi-sync', order: 70, label: zh ? '多端同步' : 'Multi-sync' },
|
|
560
|
+
Panel,
|
|
561
|
+
),
|
|
562
|
+
)
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
return { inject: ['slots'], apply }
|
|
566
|
+
},
|
|
567
|
+
})
|
package/cordis.patch.yml
ADDED
package/docs/DETAIL.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Multi-machine plugin sync
|
|
2
|
+
|
|
3
|
+
Move the plugin set from one machine to another as one pinned list.
|
|
4
|
+
|
|
5
|
+
## The problem
|
|
6
|
+
|
|
7
|
+
Two machines running DeepSeek Harness drift apart: one has a plugin at `1.2.2`,
|
|
8
|
+
the other at `1.3.0`; one has a locally linked package the other has never heard of.
|
|
9
|
+
Copying `node_modules` across platforms does not work, and copying the whole
|
|
10
|
+
profile drags sessions, credentials and 100 MB of install output along.
|
|
11
|
+
|
|
12
|
+
What actually has to travel is small — which packages are installed, at which
|
|
13
|
+
exact version.
|
|
14
|
+
|
|
15
|
+
## How it works
|
|
16
|
+
|
|
17
|
+
The page has two roles.
|
|
18
|
+
|
|
19
|
+
**Source** scans the running profile. For each direct dependency it keeps the
|
|
20
|
+
package name, the version the installed copy really has (not the range in
|
|
21
|
+
`package.json`), whether the package is a bundle that registers loader rows, and
|
|
22
|
+
the tarball `integrity` from the profile lockfile when one is recorded. Entries a
|
|
23
|
+
registry cannot serve — `file:`, `link:`, `workspace:`, `git+`, `http:` — are moved
|
|
24
|
+
to a separate skipped list with the reason, so the difference between the two
|
|
25
|
+
machines is visible instead of silently dropped.
|
|
26
|
+
|
|
27
|
+
The result is exported as `dsh-plugins.json`, either downloaded or copied from the
|
|
28
|
+
text box, and moved to the other machine by any means: a USB stick, a chat message,
|
|
29
|
+
a synced folder.
|
|
30
|
+
|
|
31
|
+
**Follower** reads that document back — dropped in, chosen from disk, or pasted —
|
|
32
|
+
and compares every entry against what this machine already has. The dialog lists
|
|
33
|
+
one row per plugin with the action that would be taken: new, upgrade, already
|
|
34
|
+
installed, or unavailable. Only the checked entries are installed, in a single
|
|
35
|
+
`dsh plugin --profile <name> add name@version …` call, so the plugin manager does
|
|
36
|
+
one resolution, one lockfile write, and one bundle registration pass.
|
|
37
|
+
|
|
38
|
+
## Limits worth knowing
|
|
39
|
+
|
|
40
|
+
- The harness is never restarted by this plugin, and it cannot be: restarting belongs to
|
|
41
|
+
the desktop shell, which accepts no restart request from a host, and every process
|
|
42
|
+
this plugin starts is reaped together with the app. Restart from the tray icon on
|
|
43
|
+
Windows, or from the menu on macOS.
|
|
44
|
+
- Enable/disable state and per-plugin configuration are not carried. Those belong
|
|
45
|
+
to `cordis.patch.yml` and the plugin market's own state file, which the market
|
|
46
|
+
rewrites; a second writer there is reverted by its self-heal logic.
|
|
47
|
+
- Installations are additive. A plugin installed on this machine but absent from
|
|
48
|
+
the list is never removed.
|
|
49
|
+
- Transitive dependencies are not pinned. A listed plugin's own dependencies
|
|
50
|
+
resolve at install time on each machine.
|
|
51
|
+
|
|
52
|
+
## First run on the new machine
|
|
53
|
+
|
|
54
|
+
This plugin cannot install itself before it exists on that machine, so install it
|
|
55
|
+
once by hand:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
dsh plugin --profile desktop add @xi-ix/dsh-multi-sync@0.1.0
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Then restart, open Settings → Multi-sync, and choose **Follower**.
|
package/icon.svg
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Multi-machine plugin sync">
|
|
2
|
+
<rect x="2" y="2" width="60" height="60" rx="14" fill="#334155"/>
|
|
3
|
+
<g fill="none" stroke="#93c5fd" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round">
|
|
4
|
+
<path d="M18 26h20a8 8 0 0 1 8 8"/>
|
|
5
|
+
<path d="M46 38H26a8 8 0 0 1-8-8"/>
|
|
6
|
+
</g>
|
|
7
|
+
<g fill="#93c5fd">
|
|
8
|
+
<path d="M21 20.5 28.5 26 21 31.5z"/>
|
|
9
|
+
<path d="M43 32.5 35.5 38 43 43.5z"/>
|
|
10
|
+
</g>
|
|
11
|
+
<rect x="24" y="45" width="16" height="7" rx="2.5" fill="#e2e8f0"/>
|
|
12
|
+
<rect x="29" y="51.5" width="6" height="5" rx="1.5" fill="#e2e8f0"/>
|
|
13
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host half of @xi-ix/dsh-multi-sync.
|
|
3
|
+
*
|
|
4
|
+
* It owns three things and nothing else:
|
|
5
|
+
* - scan: read the running profile's direct dependencies, drop everything that
|
|
6
|
+
* cannot be fetched from a registry, and report the version each one actually
|
|
7
|
+
* has on disk;
|
|
8
|
+
* - export/parse: turn that scan into one portable JSON document and read one
|
|
9
|
+
* back, so the other machine never has to reach the same registry twice;
|
|
10
|
+
* - apply: hand a set of exact `name@version` specs to `dsh plugin add`, once,
|
|
11
|
+
* and report what happened.
|
|
12
|
+
*
|
|
13
|
+
* It never writes package.json, cordis.patch.yml or the market's state: bundle
|
|
14
|
+
* registration is the plugin manager's job, and enable/disable belongs to the
|
|
15
|
+
* market. That boundary is deliberate — two writers on those files fight.
|
|
16
|
+
*/
|
|
17
|
+
import { existsSync, readdirSync } from 'node:fs'
|
|
18
|
+
import { readFile, writeFile } from 'node:fs/promises'
|
|
19
|
+
import { execFile } from 'node:child_process'
|
|
20
|
+
import { homedir, platform } from 'node:os'
|
|
21
|
+
import { basename, join } from 'node:path'
|
|
22
|
+
|
|
23
|
+
export const name = '@xi-ix/dsh-multi-sync'
|
|
24
|
+
export const inject = ['webServer']
|
|
25
|
+
|
|
26
|
+
const PREFIX = '/dsh-multi-sync'
|
|
27
|
+
const STATE_FILE = '.dsh-multi-sync.json'
|
|
28
|
+
const BODY_LIMIT = 1024 * 1024
|
|
29
|
+
const SEMVER = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/
|
|
30
|
+
const PACKAGE_NAME = /^(?:@[a-z0-9][a-z0-9-._~]*\/)?[a-z0-9][a-z0-9-._~]*$/i
|
|
31
|
+
|
|
32
|
+
/** Non-registry dependency specs: local links, git, tarball URLs, workspace protocols. */
|
|
33
|
+
const LOCAL_SPEC = /^(?:file:|link:|workspace:|portal:|\.{0,2}\/|[a-zA-Z]:[\\/])/
|
|
34
|
+
const REMOTE_SPEC = /^(?:git\+|git:|github:|gitlab:|bitbucket:|https?:|npm:|patch:)/
|
|
35
|
+
|
|
36
|
+
export function apply(ctx) {
|
|
37
|
+
const service = createService(ctx)
|
|
38
|
+
ctx.effect(
|
|
39
|
+
() => ctx.webServer.register({ kind: 'prefix', path: PREFIX, handler: service.handle }),
|
|
40
|
+
'dsh-multi-sync: routes',
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ---------------------------------------------------------------- helpers
|
|
45
|
+
|
|
46
|
+
function reply(res, status, value) {
|
|
47
|
+
const body = JSON.stringify(value)
|
|
48
|
+
res.writeHead(status, {
|
|
49
|
+
'content-type': 'application/json; charset=utf-8',
|
|
50
|
+
'content-length': Buffer.byteLength(body),
|
|
51
|
+
'cache-control': 'no-store',
|
|
52
|
+
})
|
|
53
|
+
res.end(body)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function readBody(req) {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
const chunks = []
|
|
59
|
+
let size = 0
|
|
60
|
+
req.on('data', (chunk) => {
|
|
61
|
+
size += chunk.length
|
|
62
|
+
if (size > BODY_LIMIT) {
|
|
63
|
+
reject(new Error('request body is larger than 1 MiB'))
|
|
64
|
+
req.destroy()
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
chunks.push(chunk)
|
|
68
|
+
})
|
|
69
|
+
req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')))
|
|
70
|
+
req.on('error', reject)
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Reject a cross-origin browser request; same-origin and non-browser callers pass. */
|
|
75
|
+
function trusted(request) {
|
|
76
|
+
const origin = request.headers.origin
|
|
77
|
+
if (!origin) return true
|
|
78
|
+
try {
|
|
79
|
+
return new URL(origin).host === request.headers.host
|
|
80
|
+
} catch {
|
|
81
|
+
return false
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function loopback(address) {
|
|
86
|
+
if (typeof address !== 'string') return false
|
|
87
|
+
return address === '127.0.0.1' || address === '::1' || /^::ffff:127\./.test(address)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function escapeRegExp(text) {
|
|
91
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function readJson(file) {
|
|
95
|
+
return JSON.parse(await readFile(file, 'utf8'))
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function tryReadJson(file) {
|
|
99
|
+
try {
|
|
100
|
+
return await readJson(file)
|
|
101
|
+
} catch {
|
|
102
|
+
return undefined
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function dshHome() {
|
|
107
|
+
return process.env.DSH_HOME || join(homedir(), '.dsh')
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Locate the active profile directory.
|
|
112
|
+
*
|
|
113
|
+
* `DSH_PROFILE_DIR` is set for shell calls of a profile-launched harness, which
|
|
114
|
+
* need not reach the host process itself; the rest of the candidates cover the
|
|
115
|
+
* layouts a Desktop or CLI launch leaves behind.
|
|
116
|
+
*/
|
|
117
|
+
function resolveProfile() {
|
|
118
|
+
const explicit = process.env.DSH_PROFILE_DIR
|
|
119
|
+
if (explicit && existsSync(join(explicit, 'package.json'))) {
|
|
120
|
+
return { name: process.env.DSH_PROFILE || basename(explicit), dir: explicit }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const profiles = join(dshHome(), 'profiles')
|
|
124
|
+
const wanted = process.env.DSH_PROFILE || 'desktop'
|
|
125
|
+
const preferred = join(profiles, wanted)
|
|
126
|
+
if (existsSync(join(preferred, 'package.json'))) return { name: wanted, dir: preferred }
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
for (const entry of readdirSync(profiles)) {
|
|
130
|
+
const candidate = join(profiles, entry)
|
|
131
|
+
if (existsSync(join(candidate, 'package.json'))) return { name: entry, dir: candidate }
|
|
132
|
+
}
|
|
133
|
+
} catch {
|
|
134
|
+
// fall through to the error below
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
throw new Error(`cannot find a DSH profile under ${profiles}; set DSH_PROFILE or DSH_PROFILE_DIR`)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function runningDshVersion() {
|
|
141
|
+
// The host process need not inherit DSH_INSTALL_DIR, so fall back to the
|
|
142
|
+
// packaged layout relative to the running executable's resources directory.
|
|
143
|
+
const candidates = []
|
|
144
|
+
if (process.env.DSH_INSTALL_DIR) candidates.push(join(process.env.DSH_INSTALL_DIR, 'package.json'))
|
|
145
|
+
if (process.resourcesPath) {
|
|
146
|
+
candidates.push(join(process.resourcesPath, 'app.asar', 'dsh', 'node_modules', '@deepseek-ai', 'dsh', 'package.json'))
|
|
147
|
+
candidates.push(join(process.resourcesPath, 'app', 'dsh', 'node_modules', '@deepseek-ai', 'dsh', 'package.json'))
|
|
148
|
+
}
|
|
149
|
+
for (const candidate of candidates) {
|
|
150
|
+
const manifest = await tryReadJson(candidate)
|
|
151
|
+
if (typeof manifest?.version === 'string' && manifest.name === '@deepseek-ai/dsh') return manifest.version
|
|
152
|
+
}
|
|
153
|
+
return null
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The version actually installed on disk, which is what both machines must match. */
|
|
157
|
+
async function installedFacts(dir, packageName) {
|
|
158
|
+
const manifest = await tryReadJson(join(dir, 'node_modules', packageName, 'package.json'))
|
|
159
|
+
if (manifest === undefined) return undefined
|
|
160
|
+
return {
|
|
161
|
+
version: typeof manifest.version === 'string' ? manifest.version : null,
|
|
162
|
+
bundle: manifest.dsh?.bundle !== undefined,
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Best-effort tarball hash from the profile lockfile; absent when the layout is unfamiliar. */
|
|
167
|
+
async function lockIntegrity(dir, packageName, version) {
|
|
168
|
+
let text
|
|
169
|
+
try {
|
|
170
|
+
text = await readFile(join(dir, 'pnpm-lock.yaml'), 'utf8')
|
|
171
|
+
} catch {
|
|
172
|
+
return undefined
|
|
173
|
+
}
|
|
174
|
+
const key = new RegExp(
|
|
175
|
+
`(?:^|\\n)[ \\t]{2,}['"]?${escapeRegExp(packageName)}@${escapeRegExp(version)}['"]?:[\\s\\S]{0,600}?integrity:[ \\t]*['"]?(sha512-[A-Za-z0-9+/=]+)`,
|
|
176
|
+
)
|
|
177
|
+
return key.exec(text)?.[1]
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function specKind(spec) {
|
|
181
|
+
if (LOCAL_SPEC.test(spec)) return 'local'
|
|
182
|
+
if (REMOTE_SPEC.test(spec)) return 'remote'
|
|
183
|
+
return 'registry'
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function cleanRange(range) {
|
|
187
|
+
return range.replace(/^[\^~>=<\s]+/, '').trim()
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Compare two versions well enough to name an action: release beats prerelease,
|
|
192
|
+
* numeric identifiers compare numerically, the rest lexically. Build metadata is
|
|
193
|
+
* ignored, as SemVer says it should be.
|
|
194
|
+
*/
|
|
195
|
+
function compareVersions(a, b) {
|
|
196
|
+
const split = (value) => {
|
|
197
|
+
const [core, rest = ''] = String(value).split('+')[0].split('-', 2)
|
|
198
|
+
const numbers = core.split('.').map((part) => Number.parseInt(part, 10) || 0)
|
|
199
|
+
while (numbers.length < 3) numbers.push(0)
|
|
200
|
+
return { numbers, prerelease: rest === '' ? [] : rest.split('.') }
|
|
201
|
+
}
|
|
202
|
+
const left = split(a)
|
|
203
|
+
const right = split(b)
|
|
204
|
+
for (let index = 0; index < 3; index += 1) {
|
|
205
|
+
if (left.numbers[index] !== right.numbers[index]) return left.numbers[index] > right.numbers[index] ? 1 : -1
|
|
206
|
+
}
|
|
207
|
+
if (left.prerelease.length === 0 && right.prerelease.length === 0) return 0
|
|
208
|
+
if (left.prerelease.length === 0) return 1
|
|
209
|
+
if (right.prerelease.length === 0) return -1
|
|
210
|
+
const length = Math.max(left.prerelease.length, right.prerelease.length)
|
|
211
|
+
for (let index = 0; index < length; index += 1) {
|
|
212
|
+
const one = left.prerelease[index]
|
|
213
|
+
const two = right.prerelease[index]
|
|
214
|
+
if (one === undefined) return -1
|
|
215
|
+
if (two === undefined) return 1
|
|
216
|
+
if (one === two) continue
|
|
217
|
+
const oneNumber = /^\d+$/.test(one)
|
|
218
|
+
const twoNumber = /^\d+$/.test(two)
|
|
219
|
+
if (oneNumber && twoNumber) return Number(one) > Number(two) ? 1 : -1
|
|
220
|
+
if (oneNumber !== twoNumber) return oneNumber ? -1 : 1
|
|
221
|
+
return one > two ? 1 : -1
|
|
222
|
+
}
|
|
223
|
+
return 0
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// ---------------------------------------------------------------- operations
|
|
227
|
+
|
|
228
|
+
async function scan() {
|
|
229
|
+
const profile = resolveProfile()
|
|
230
|
+
const manifest = await readJson(join(profile.dir, 'package.json'))
|
|
231
|
+
const dependencies = manifest.dependencies ?? {}
|
|
232
|
+
const bundles = new Set(manifest.dsh?.profile?.bundles ?? [])
|
|
233
|
+
const plugins = []
|
|
234
|
+
const skipped = []
|
|
235
|
+
|
|
236
|
+
for (const [packageName, spec] of Object.entries(dependencies)) {
|
|
237
|
+
const kind = specKind(String(spec))
|
|
238
|
+
if (kind !== 'registry') {
|
|
239
|
+
skipped.push({ name: packageName, spec: String(spec), reason: kind })
|
|
240
|
+
continue
|
|
241
|
+
}
|
|
242
|
+
if (!PACKAGE_NAME.test(packageName)) {
|
|
243
|
+
skipped.push({ name: packageName, spec: String(spec), reason: 'invalid-name' })
|
|
244
|
+
continue
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const facts = await installedFacts(profile.dir, packageName)
|
|
248
|
+
const version = facts?.version ?? (SEMVER.test(cleanRange(String(spec))) ? cleanRange(String(spec)) : null)
|
|
249
|
+
const entry = {
|
|
250
|
+
name: packageName,
|
|
251
|
+
version,
|
|
252
|
+
spec: String(spec),
|
|
253
|
+
bundle: facts?.bundle ?? bundles.has(packageName),
|
|
254
|
+
present: facts !== undefined,
|
|
255
|
+
}
|
|
256
|
+
if (version) {
|
|
257
|
+
const integrity = await lockIntegrity(profile.dir, packageName, version)
|
|
258
|
+
if (integrity) entry.integrity = integrity
|
|
259
|
+
}
|
|
260
|
+
plugins.push(entry)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
plugins.sort((a, b) => a.name.localeCompare(b.name))
|
|
264
|
+
return {
|
|
265
|
+
format: 1,
|
|
266
|
+
generatedAt: new Date().toISOString(),
|
|
267
|
+
dsh: await runningDshVersion(),
|
|
268
|
+
profile: profile.name,
|
|
269
|
+
platform: platform(),
|
|
270
|
+
plugins,
|
|
271
|
+
skipped,
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async function readState(dir) {
|
|
276
|
+
const state = await tryReadJson(join(dir, STATE_FILE))
|
|
277
|
+
return { role: state?.role === 'follower' ? 'follower' : 'source' }
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async function writeState(dir, state) {
|
|
281
|
+
const value = { role: state?.role === 'follower' ? 'follower' : 'source' }
|
|
282
|
+
await writeFile(join(dir, STATE_FILE), JSON.stringify(value, undefined, 2) + '\n', { mode: 0o600 })
|
|
283
|
+
return value
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** Accept the export format, a bare array of entries, or one `name[@version]` per line. */
|
|
287
|
+
function parseList(text) {
|
|
288
|
+
const trimmed = String(text ?? '').trim()
|
|
289
|
+
if (trimmed === '') throw new Error('empty list')
|
|
290
|
+
|
|
291
|
+
let document
|
|
292
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
293
|
+
let parsed
|
|
294
|
+
try {
|
|
295
|
+
parsed = JSON.parse(trimmed)
|
|
296
|
+
} catch (error) {
|
|
297
|
+
throw new Error(`invalid JSON: ${error.message}`)
|
|
298
|
+
}
|
|
299
|
+
if (Array.isArray(parsed)) document = { plugins: parsed }
|
|
300
|
+
else if (Array.isArray(parsed.plugins)) document = parsed
|
|
301
|
+
else throw new Error('JSON has no "plugins" array')
|
|
302
|
+
} else {
|
|
303
|
+
const plugins = []
|
|
304
|
+
const skipped = []
|
|
305
|
+
for (const line of trimmed.split(/\r?\n/)) {
|
|
306
|
+
const item = line.replace(/#.*$/, '').trim()
|
|
307
|
+
if (item === '') continue
|
|
308
|
+
const at = item.lastIndexOf('@')
|
|
309
|
+
if (at > 0) plugins.push({ name: item.slice(0, at), version: item.slice(at + 1) })
|
|
310
|
+
else plugins.push({ name: item })
|
|
311
|
+
}
|
|
312
|
+
document = { plugins, skipped }
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const plugins = []
|
|
316
|
+
for (const raw of document.plugins ?? []) {
|
|
317
|
+
if (typeof raw?.name !== 'string' || !PACKAGE_NAME.test(raw.name)) continue
|
|
318
|
+
const version = typeof raw?.version === 'string' && SEMVER.test(raw.version) ? raw.version : null
|
|
319
|
+
if (version === null) continue
|
|
320
|
+
const entry = { name: raw.name, version }
|
|
321
|
+
if (typeof raw.integrity === 'string' && raw.integrity.startsWith('sha512-')) entry.integrity = raw.integrity
|
|
322
|
+
if (typeof raw.bundle === 'boolean') entry.bundle = raw.bundle
|
|
323
|
+
plugins.push(entry)
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// One row per package: a hand-edited list may repeat a name, and installing the
|
|
327
|
+
// same package twice in one command is never what the user meant.
|
|
328
|
+
const unique = new Map()
|
|
329
|
+
for (const entry of plugins) unique.set(entry.name, entry)
|
|
330
|
+
|
|
331
|
+
return {
|
|
332
|
+
header: {
|
|
333
|
+
format: document.format ?? null,
|
|
334
|
+
generatedAt: document.generatedAt ?? null,
|
|
335
|
+
dsh: document.dsh ?? null,
|
|
336
|
+
profile: document.profile ?? null,
|
|
337
|
+
platform: document.platform ?? null,
|
|
338
|
+
},
|
|
339
|
+
plugins: [...unique.values()],
|
|
340
|
+
skipped: Array.isArray(document.skipped) ? document.skipped : [],
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function runOnce(command, argv, options) {
|
|
345
|
+
return new Promise((resolve) => {
|
|
346
|
+
execFile(
|
|
347
|
+
command,
|
|
348
|
+
argv,
|
|
349
|
+
{ timeout: 15 * 60 * 1000, maxBuffer: 16 * 1024 * 1024, windowsHide: true, ...options },
|
|
350
|
+
(error, stdout, stderr) => {
|
|
351
|
+
resolve({
|
|
352
|
+
ok: error === null || error === undefined,
|
|
353
|
+
code: error?.code ?? 0,
|
|
354
|
+
stdout: String(stdout ?? ''),
|
|
355
|
+
stderr: String(stderr ?? ''),
|
|
356
|
+
message: error?.message,
|
|
357
|
+
})
|
|
358
|
+
},
|
|
359
|
+
)
|
|
360
|
+
})
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Run the DSH CLI, preferring the installation this process belongs to.
|
|
365
|
+
*
|
|
366
|
+
* The packaged CLI lives inside app.asar, which only the Electron runtime can
|
|
367
|
+
* read; that attempt therefore goes through the running executable with
|
|
368
|
+
* ELECTRON_RUN_AS_NODE. `dsh` on PATH is the fallback.
|
|
369
|
+
*/
|
|
370
|
+
async function runDsh(args) {
|
|
371
|
+
const nodeExecutable = process.env.DSH_NODE_EXECUTABLE
|
|
372
|
+
const installDir = process.env.DSH_INSTALL_DIR
|
|
373
|
+
const attempts = []
|
|
374
|
+
|
|
375
|
+
if (nodeExecutable && installDir) {
|
|
376
|
+
attempts.push({
|
|
377
|
+
command: nodeExecutable,
|
|
378
|
+
argv: [join(installDir, 'lib', 'bin.js'), ...args],
|
|
379
|
+
options: { env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' } },
|
|
380
|
+
label: `${nodeExecutable} lib/bin.js ${args.join(' ')}`,
|
|
381
|
+
})
|
|
382
|
+
}
|
|
383
|
+
attempts.push({
|
|
384
|
+
command: 'dsh',
|
|
385
|
+
argv: args,
|
|
386
|
+
options: { shell: platform() === 'win32' },
|
|
387
|
+
label: `dsh ${args.join(' ')}`,
|
|
388
|
+
})
|
|
389
|
+
|
|
390
|
+
let last
|
|
391
|
+
for (const attempt of attempts) {
|
|
392
|
+
last = await runOnce(attempt.command, attempt.argv, attempt.options)
|
|
393
|
+
const missing = last.code === 'ENOENT' || /not found|不是内部或外部命令|cannot find/i.test(last.stderr)
|
|
394
|
+
if (missing) continue
|
|
395
|
+
return { ...last, command: attempt.label }
|
|
396
|
+
}
|
|
397
|
+
return { ...last, command: 'none', ok: false }
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
async function applyList(items) {
|
|
401
|
+
const profile = resolveProfile()
|
|
402
|
+
const specs = []
|
|
403
|
+
for (const item of items ?? []) {
|
|
404
|
+
if (typeof item?.name !== 'string' || !PACKAGE_NAME.test(item.name)) continue
|
|
405
|
+
if (typeof item.version !== 'string' || !SEMVER.test(item.version)) continue
|
|
406
|
+
specs.push(`${item.name}@${item.version}`)
|
|
407
|
+
}
|
|
408
|
+
if (specs.length === 0) throw new Error('nothing to install: need name@version entries')
|
|
409
|
+
|
|
410
|
+
const run = await runDsh(['plugin', '--profile', profile.name, 'add', ...specs])
|
|
411
|
+
const tail = (text) => text.trim().split(/\r?\n/).slice(-40).join('\n')
|
|
412
|
+
return {
|
|
413
|
+
ok: run.ok,
|
|
414
|
+
specs,
|
|
415
|
+
command: run.command,
|
|
416
|
+
exitCode: typeof run.code === 'number' ? run.code : null,
|
|
417
|
+
stdout: tail(run.stdout),
|
|
418
|
+
stderr: tail(run.stderr),
|
|
419
|
+
message: run.ok ? null : run.message ?? 'dsh plugin add failed',
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// ---------------------------------------------------------------- environment
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Whether this host is the Desktop shell's child process.
|
|
427
|
+
*
|
|
428
|
+
* The shell owns restarting the application: the only messages it accepts from a
|
|
429
|
+
* host are `starting`, `ready`, `platform-session`, `shutdown-complete`, `fatal`
|
|
430
|
+
* and control answers, and none of them asks for a restart. A plugin that stops
|
|
431
|
+
* the host only raises the shell's own failure prompt, so this plugin points at
|
|
432
|
+
* the shell's "Restart App and Host" menu item instead of pretending to restart.
|
|
433
|
+
*/
|
|
434
|
+
function isDesktopHost() {
|
|
435
|
+
return typeof process.send === 'function'
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// ---------------------------------------------------------------- routing
|
|
439
|
+
|
|
440
|
+
function createService(ctx) {
|
|
441
|
+
/**
|
|
442
|
+
* A request from this machine is allowed; anything arriving from the network has
|
|
443
|
+
* to pass the host connection gate when one is mounted, so exposing `dsh web`
|
|
444
|
+
* does not also expose "install arbitrary packages".
|
|
445
|
+
*/
|
|
446
|
+
function admitted(request) {
|
|
447
|
+
if (!trusted(request)) return false
|
|
448
|
+
if (loopback(request.socket?.remoteAddress)) return true
|
|
449
|
+
try {
|
|
450
|
+
const connection = ctx.get('connection')
|
|
451
|
+
if (connection && typeof connection.requestRejection === 'function') {
|
|
452
|
+
return connection.requestRejection(request) === undefined
|
|
453
|
+
}
|
|
454
|
+
} catch {
|
|
455
|
+
// no connection service in this composition
|
|
456
|
+
}
|
|
457
|
+
return false
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
async function route(request, response, path) {
|
|
461
|
+
if (!admitted(request)) {
|
|
462
|
+
reply(response, 403, { ok: false, error: 'request refused' })
|
|
463
|
+
return true
|
|
464
|
+
}
|
|
465
|
+
const method = request.method ?? 'GET'
|
|
466
|
+
|
|
467
|
+
if (path === '/state' && (method === 'GET' || method === 'HEAD')) {
|
|
468
|
+
const profile = resolveProfile()
|
|
469
|
+
const state = await readState(profile.dir)
|
|
470
|
+
reply(response, 200, {
|
|
471
|
+
ok: true,
|
|
472
|
+
role: state.role,
|
|
473
|
+
profile: profile.name,
|
|
474
|
+
profileDir: profile.dir,
|
|
475
|
+
dsh: await runningDshVersion(),
|
|
476
|
+
platform: platform(),
|
|
477
|
+
desktop: isDesktopHost(),
|
|
478
|
+
})
|
|
479
|
+
return true
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
if (path === '/scan' && method === 'GET') {
|
|
483
|
+
reply(response, 200, { ok: true, list: await scan() })
|
|
484
|
+
return true
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
if (path === '/role' && method === 'POST') {
|
|
488
|
+
const body = JSON.parse((await readBody(request)) || '{}')
|
|
489
|
+
const profile = resolveProfile()
|
|
490
|
+
const current = await readState(profile.dir)
|
|
491
|
+
const state = await writeState(profile.dir, { ...current, role: body.role })
|
|
492
|
+
reply(response, 200, { ok: true, role: state.role })
|
|
493
|
+
return true
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (path === '/parse' && method === 'POST') {
|
|
497
|
+
const body = JSON.parse((await readBody(request)) || '{}')
|
|
498
|
+
const parsed = parseList(body.text)
|
|
499
|
+
const profile = resolveProfile()
|
|
500
|
+
const manifest = await readJson(join(profile.dir, 'package.json'))
|
|
501
|
+
const dependencies = manifest.dependencies ?? {}
|
|
502
|
+
const rows = []
|
|
503
|
+
for (const entry of parsed.plugins) {
|
|
504
|
+
const facts = await installedFacts(profile.dir, entry.name)
|
|
505
|
+
const spec = typeof dependencies[entry.name] === 'string' ? dependencies[entry.name] : null
|
|
506
|
+
// A local mount is never "already installed" for this purpose: keeping it
|
|
507
|
+
// and replacing it are different outcomes, so it gets its own state.
|
|
508
|
+
const local = spec !== null && specKind(spec) !== 'registry'
|
|
509
|
+
let state = 'new'
|
|
510
|
+
if (facts?.version) {
|
|
511
|
+
const order = compareVersions(facts.version, entry.version)
|
|
512
|
+
state = order === 0 ? 'same' : order > 0 ? 'downgrade' : 'upgrade'
|
|
513
|
+
}
|
|
514
|
+
if (local) state = 'linked'
|
|
515
|
+
rows.push({
|
|
516
|
+
...entry,
|
|
517
|
+
spec,
|
|
518
|
+
installed: facts?.version ?? null,
|
|
519
|
+
state,
|
|
520
|
+
})
|
|
521
|
+
}
|
|
522
|
+
reply(response, 200, { ok: true, header: parsed.header, rows, skipped: parsed.skipped })
|
|
523
|
+
return true
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (path === '/apply' && method === 'POST') {
|
|
527
|
+
const body = JSON.parse((await readBody(request)) || '{}')
|
|
528
|
+
reply(response, 200, { ok: true, result: await applyList(body.items) })
|
|
529
|
+
return true
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
return false
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
async function handle(request, response) {
|
|
536
|
+
const url = new URL(request.url ?? '/', 'http://localhost')
|
|
537
|
+
const path = url.pathname.startsWith(PREFIX) ? url.pathname.slice(PREFIX.length) || '/' : null
|
|
538
|
+
if (path === null) {
|
|
539
|
+
reply(response, 404, { ok: false, error: 'not found' })
|
|
540
|
+
return
|
|
541
|
+
}
|
|
542
|
+
try {
|
|
543
|
+
const claimed = await route(request, response, path)
|
|
544
|
+
if (!claimed) reply(response, 404, { ok: false, error: `unknown route ${path}` })
|
|
545
|
+
} catch (error) {
|
|
546
|
+
reply(response, 500, { ok: false, error: String(error?.message ?? error) })
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
return { handle }
|
|
551
|
+
}
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xi-ix/dsh-multi-sync",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Copy one machine's installed DSH plugin list to another: scan the profile, export a pinned list, then install the selected entries on the other machine.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./client": "./client.js",
|
|
10
|
+
"./locale/*.json": "./locale/*.json",
|
|
11
|
+
"./icon": "./icon.svg",
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"index.js",
|
|
16
|
+
"client.js",
|
|
17
|
+
"cordis.patch.yml",
|
|
18
|
+
"locale/*.json",
|
|
19
|
+
"docs",
|
|
20
|
+
"icon.svg",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"dsh",
|
|
30
|
+
"dsh-plugin",
|
|
31
|
+
"deepseek-harness",
|
|
32
|
+
"plugin-sync",
|
|
33
|
+
"multi-machine"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
37
|
+
},
|
|
38
|
+
"dsh": {
|
|
39
|
+
"bundle": {
|
|
40
|
+
"patch": "./cordis.patch.yml"
|
|
41
|
+
},
|
|
42
|
+
"client": {
|
|
43
|
+
"platform": "web",
|
|
44
|
+
"inject": [
|
|
45
|
+
"@deepseek-ai/dsh-client-runtime",
|
|
46
|
+
"@deepseek-ai/dsh-client-ui-slots",
|
|
47
|
+
"@deepseek-ai/dsh-client-ui-settings"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|