dsh-sideby-note 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/CHANGELOG.md +331 -0
- package/LICENSE +21 -0
- package/README.en.md +302 -0
- package/README.md +301 -2
- package/client/client.js +4425 -0
- package/cordis.patch.yml +6 -0
- package/docs/assets/features/actions-dark.png +0 -0
- package/docs/assets/features/actions.png +0 -0
- package/docs/assets/features/clear-dark.png +0 -0
- package/docs/assets/features/clear.png +0 -0
- package/docs/assets/features/empty-dark.png +0 -0
- package/docs/assets/features/empty.png +0 -0
- package/docs/assets/features/panel-dark.png +0 -0
- package/docs/assets/features/panel.png +0 -0
- package/docs/assets/features/settings-dark.png +0 -0
- package/docs/assets/features/settings.png +0 -0
- package/docs/assets/preview-badge-dark.png +0 -0
- package/docs/assets/preview-badge.png +0 -0
- package/docs/assets/preview-right-dark.png +0 -0
- package/docs/assets/preview-right.png +0 -0
- package/docs/assets/storefront-icon.svg +22 -0
- package/docs/panel-ui-rules.md +77 -0
- package/host/apply-update.js +204 -0
- package/host/exec.js +68 -0
- package/host/profile.js +99 -0
- package/host/route.js +360 -0
- package/host/versions.js +92 -0
- package/icon.svg +12 -0
- package/index.js +28 -0
- package/locale/de.json +6 -0
- package/locale/en.json +6 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +94 -4
- package/scripts/install.mjs +281 -0
package/host/route.js
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host endpoints the panel's update card talks to.
|
|
3
|
+
*
|
|
4
|
+
* These exist because the browser cannot install a package: the plugin's own
|
|
5
|
+
* client half used to delegate to the plugin market, whose update removes the
|
|
6
|
+
* bundle first and is therefore refused by Desktop while the panel is open.
|
|
7
|
+
* This route runs inside the host, where DSH's installer and the profile's
|
|
8
|
+
* package manager are both reachable.
|
|
9
|
+
*
|
|
10
|
+
* The surface is deliberately tiny and same-origin: one read, one mutation.
|
|
11
|
+
*/
|
|
12
|
+
import { UpdateError, applyUpdate, manualCommand } from './apply-update.js'
|
|
13
|
+
import { runProcess } from './exec.js'
|
|
14
|
+
import { PACKAGE, dependencySpec, installMode, installedVersion, isProfileDir, profileDirOf } from './profile.js'
|
|
15
|
+
import { compareVersions, isExactVersion, isPrerelease } from './versions.js'
|
|
16
|
+
|
|
17
|
+
export const PROBE_PATH = '/dsh-sideby-note/update/probe'
|
|
18
|
+
export const APPLY_PATH = '/dsh-sideby-note/update/apply'
|
|
19
|
+
|
|
20
|
+
const REGISTRIES = ['https://registry.npmjs.org', 'https://registry.npmmirror.com']
|
|
21
|
+
/** Failures a terminal command can get past; the card shows the exact command for these. */
|
|
22
|
+
const MANUAL_HINT_CODES = new Set([
|
|
23
|
+
'AUTO_UPDATE_UNAVAILABLE',
|
|
24
|
+
'bundle-in-use',
|
|
25
|
+
'already-installed',
|
|
26
|
+
'management-required',
|
|
27
|
+
'not-removable',
|
|
28
|
+
'stop-profile',
|
|
29
|
+
])
|
|
30
|
+
const CHECK_TIMEOUT_MS = 8_000
|
|
31
|
+
const BODY_LIMIT = 4 * 1024
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Read one JSON response with a deadline; undefined when it is unreachable.
|
|
35
|
+
* @param {string} url
|
|
36
|
+
* @returns {Promise<any>}
|
|
37
|
+
*/
|
|
38
|
+
async function readJson(url) {
|
|
39
|
+
const controller = new AbortController()
|
|
40
|
+
const timer = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS)
|
|
41
|
+
try {
|
|
42
|
+
const response = await fetch(url, {
|
|
43
|
+
signal: controller.signal,
|
|
44
|
+
headers: { accept: 'application/json', 'user-agent': 'dsh-sideby-note-host' },
|
|
45
|
+
})
|
|
46
|
+
if (!response.ok) return undefined
|
|
47
|
+
return await response.json()
|
|
48
|
+
} catch {
|
|
49
|
+
return undefined
|
|
50
|
+
} finally {
|
|
51
|
+
clearTimeout(timer)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The version npm publishes for this package, trying the mirror when npmjs
|
|
57
|
+
* does not answer. Undefined means "could not check", which the panel shows
|
|
58
|
+
* as such rather than as "up to date".
|
|
59
|
+
*
|
|
60
|
+
* A prerelease build also reads `next` — that is where every prerelease is
|
|
61
|
+
* published, and `latest` never carries one — and a stable build reads
|
|
62
|
+
* `latest` alone, so a prerelease cannot reach a regular user.
|
|
63
|
+
*
|
|
64
|
+
* @param {string | undefined} current the installed version
|
|
65
|
+
* @returns {Promise<string | undefined>}
|
|
66
|
+
*/
|
|
67
|
+
export async function fetchLatestVersion(current) {
|
|
68
|
+
const channels = isPrerelease(current) ? ['latest', 'next'] : ['latest']
|
|
69
|
+
for (const registry of REGISTRIES) {
|
|
70
|
+
const versions = await Promise.all(channels.map(channel =>
|
|
71
|
+
readJson(`${registry}/${encodeURIComponent(PACKAGE)}/${encodeURIComponent(channel)}`).then(body =>
|
|
72
|
+
typeof body?.version === 'string' ? { channel, version: body.version } : undefined,
|
|
73
|
+
),
|
|
74
|
+
))
|
|
75
|
+
const found = versions.filter(Boolean)
|
|
76
|
+
if (found.length === 0) continue
|
|
77
|
+
let best
|
|
78
|
+
for (const entry of found) {
|
|
79
|
+
// `next` is prerelease-only by contract; a release tagged there would
|
|
80
|
+
// otherwise be promoted silently.
|
|
81
|
+
if (entry.channel !== 'latest' && !isPrerelease(entry.version)) continue
|
|
82
|
+
if (best === undefined || compareVersions(entry.version, best) > 0) best = entry.version
|
|
83
|
+
}
|
|
84
|
+
if (best !== undefined) return best
|
|
85
|
+
}
|
|
86
|
+
return undefined
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param {import('node:http').ServerResponse} response
|
|
91
|
+
* @param {number} status
|
|
92
|
+
* @param {unknown} body
|
|
93
|
+
*/
|
|
94
|
+
function sendJson(response, status, body) {
|
|
95
|
+
response.writeHead(status, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' })
|
|
96
|
+
response.end(JSON.stringify(body))
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Reject requests that a page other than this host's could have made.
|
|
101
|
+
*
|
|
102
|
+
* Same rule the plugin market applies: a cross-site hint is refused outright, a
|
|
103
|
+
* present Origin must name this Host, and an absent Origin is allowed because
|
|
104
|
+
* the Desktop shell's proxy strips it (#648).
|
|
105
|
+
* @param {import('node:http').IncomingMessage} request
|
|
106
|
+
* @returns {boolean}
|
|
107
|
+
*/
|
|
108
|
+
export function sameOrigin(request) {
|
|
109
|
+
if (request.headers['sec-fetch-site'] === 'cross-site') return false
|
|
110
|
+
const origin = request.headers.origin
|
|
111
|
+
if (origin === undefined) return true
|
|
112
|
+
try {
|
|
113
|
+
return new URL(origin).host === request.headers.host
|
|
114
|
+
} catch {
|
|
115
|
+
return false
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @param {import('node:http').IncomingMessage} request
|
|
121
|
+
* @returns {Promise<any>}
|
|
122
|
+
*/
|
|
123
|
+
async function readBody(request) {
|
|
124
|
+
const chunks = []
|
|
125
|
+
let size = 0
|
|
126
|
+
for await (const chunk of request) {
|
|
127
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)
|
|
128
|
+
size += buffer.length
|
|
129
|
+
if (size > BODY_LIMIT) throw new UpdateError('UPDATE_REJECTED', 'request body too large')
|
|
130
|
+
chunks.push(buffer)
|
|
131
|
+
}
|
|
132
|
+
if (chunks.length === 0) return {}
|
|
133
|
+
try {
|
|
134
|
+
return JSON.parse(Buffer.concat(chunks).toString('utf8'))
|
|
135
|
+
} catch {
|
|
136
|
+
throw new UpdateError('UPDATE_REJECTED', 'invalid JSON body')
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* DSH's own `dsh plugin add`, bound to the profile this host runs in — the same
|
|
142
|
+
* command the plugin market uses to replace a package in place.
|
|
143
|
+
* @param {any} profileContext
|
|
144
|
+
* @returns {Promise<((args: readonly string[]) => Promise<any>) | undefined>}
|
|
145
|
+
*/
|
|
146
|
+
async function pluginCommandOf(profileContext) {
|
|
147
|
+
const profile = profileContextOf(profileContext)
|
|
148
|
+
if (profile === undefined) return undefined
|
|
149
|
+
// A variable specifier keeps the import out of the bundler's graph.
|
|
150
|
+
const specifier = '@deepseek-ai/dsh-plugin-manager/operations'
|
|
151
|
+
let operations
|
|
152
|
+
try {
|
|
153
|
+
operations = await import(specifier)
|
|
154
|
+
} catch {
|
|
155
|
+
return undefined
|
|
156
|
+
}
|
|
157
|
+
const run = operations?.runPluginCommand
|
|
158
|
+
if (typeof run !== 'function') return undefined
|
|
159
|
+
return args =>
|
|
160
|
+
run(
|
|
161
|
+
{ profile: profile.name, dir: profile.dir, installAnchor: profile.installAnchor, cwd: profile.cwd, home: profile.home },
|
|
162
|
+
args,
|
|
163
|
+
{
|
|
164
|
+
execution: 'service',
|
|
165
|
+
...(profile.packageManager === undefined ? {} : profile.packageManager),
|
|
166
|
+
outputBytes: 16 * 1024,
|
|
167
|
+
activateNewBundles: false,
|
|
168
|
+
signal: AbortSignal.timeout(10 * 60_000),
|
|
169
|
+
},
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The launcher's record of the profile it runs, or undefined when this host
|
|
175
|
+
* does not have one.
|
|
176
|
+
* @param {any} value
|
|
177
|
+
*/
|
|
178
|
+
function profileContextOf(value) {
|
|
179
|
+
if (value === null || typeof value !== 'object') return undefined
|
|
180
|
+
const required = ['name', 'dir', 'installAnchor', 'cwd', 'home']
|
|
181
|
+
if (!required.every(key => typeof value[key] === 'string')) return undefined
|
|
182
|
+
return {
|
|
183
|
+
name: value.name,
|
|
184
|
+
dir: value.dir,
|
|
185
|
+
installAnchor: value.installAnchor,
|
|
186
|
+
cwd: value.cwd,
|
|
187
|
+
home: value.home,
|
|
188
|
+
packageManager: typeof value.packageManager === 'object' && value.packageManager !== null ? value.packageManager : undefined,
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Register the update endpoints on the host's web server.
|
|
194
|
+
*
|
|
195
|
+
* @param {{ register?: (route: { kind: 'exact', path: string, handler: (request: any, response: any) => unknown }) => unknown }} server
|
|
196
|
+
* @param {{ ctx: any, config?: any }} options
|
|
197
|
+
* @returns {(() => void) | undefined}
|
|
198
|
+
*/
|
|
199
|
+
export function registerUpdateRoutes(server, options) {
|
|
200
|
+
if (typeof server?.register !== 'function') return undefined
|
|
201
|
+
const ctx = options.ctx
|
|
202
|
+
/** @type {{ promise?: Promise<unknown> }} */
|
|
203
|
+
const state = {}
|
|
204
|
+
|
|
205
|
+
const resolveProfile = () => {
|
|
206
|
+
const dir = profileDirOf(ctx.get('profileContext'))
|
|
207
|
+
return isProfileDir(dir) ? dir : undefined
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const installerOf = () => {
|
|
211
|
+
const manager = ctx.get('pluginManager')
|
|
212
|
+
return typeof manager?.installBundle === 'function' ? manager : undefined
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const packageManagerOf = () => {
|
|
216
|
+
const profile = ctx.get('profileContext')
|
|
217
|
+
const packageManager = profile?.packageManager
|
|
218
|
+
return typeof packageManager?.command === 'string' ? packageManager : undefined
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const disposeProbe = server.register({
|
|
222
|
+
kind: 'exact',
|
|
223
|
+
path: PROBE_PATH,
|
|
224
|
+
handler: async (request, response) => {
|
|
225
|
+
if (request.method !== 'GET') {
|
|
226
|
+
sendJson(response, 405, { ok: false, code: 'METHOD_NOT_ALLOWED' })
|
|
227
|
+
return
|
|
228
|
+
}
|
|
229
|
+
if (!sameOrigin(request)) {
|
|
230
|
+
sendJson(response, 403, { ok: false, code: 'UPDATE_FORBIDDEN' })
|
|
231
|
+
return
|
|
232
|
+
}
|
|
233
|
+
const dir = resolveProfile()
|
|
234
|
+
if (dir === undefined) {
|
|
235
|
+
sendJson(response, 200, { ok: true, installed: null, latest: null, mode: 'manual', updateSupported: false, reason: 'no-profile' })
|
|
236
|
+
return
|
|
237
|
+
}
|
|
238
|
+
const mode = installMode(dependencySpec(dir))
|
|
239
|
+
const installed = installedVersion(dir)
|
|
240
|
+
const latest = await fetchLatestVersion(installed)
|
|
241
|
+
const supported = mode === 'npm' && installed !== undefined && (
|
|
242
|
+
installerOf() !== undefined || packageManagerOf() !== undefined
|
|
243
|
+
)
|
|
244
|
+
sendJson(response, 200, {
|
|
245
|
+
ok: true,
|
|
246
|
+
profile: dir,
|
|
247
|
+
installed: installed ?? null,
|
|
248
|
+
latest: latest ?? null,
|
|
249
|
+
mode,
|
|
250
|
+
updateSupported: supported,
|
|
251
|
+
reason: supported ? null : mode !== 'npm' ? 'linked-or-manual' : installed === undefined ? 'not-installed' : 'no-installer',
|
|
252
|
+
checkedAt: new Date().toISOString(),
|
|
253
|
+
})
|
|
254
|
+
},
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
// No running-agent guard here, on purpose. The plugin market refuses an
|
|
258
|
+
// update while any agent runs; this package is UI-only — agents never import
|
|
259
|
+
// it and this host half is already in memory — so replacing its files cannot
|
|
260
|
+
// disturb a working turn. Blocking a panel update behind an unrelated agent
|
|
261
|
+
// run costs more than it protects. docs/architecture.md §8 records the
|
|
262
|
+
// decision and the condition that would reverse it; read that before adding
|
|
263
|
+
// an `agents` check.
|
|
264
|
+
const disposeApply = server.register({
|
|
265
|
+
kind: 'exact',
|
|
266
|
+
path: APPLY_PATH,
|
|
267
|
+
handler: async (request, response) => {
|
|
268
|
+
if (request.method !== 'POST') {
|
|
269
|
+
sendJson(response, 405, { ok: false, code: 'METHOD_NOT_ALLOWED' })
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
if (!sameOrigin(request)) {
|
|
273
|
+
sendJson(response, 403, { ok: false, code: 'UPDATE_FORBIDDEN' })
|
|
274
|
+
return
|
|
275
|
+
}
|
|
276
|
+
if (state.promise !== undefined) {
|
|
277
|
+
sendJson(response, 409, { ok: false, code: 'OPERATION_BUSY', message: 'another update is already running', retryable: true })
|
|
278
|
+
return
|
|
279
|
+
}
|
|
280
|
+
const dir = resolveProfile()
|
|
281
|
+
if (dir === undefined) {
|
|
282
|
+
sendJson(response, 409, { ok: false, code: 'PLUGIN_NOT_INSTALLED', message: 'no DSH profile here to update', retryable: false })
|
|
283
|
+
return
|
|
284
|
+
}
|
|
285
|
+
let body
|
|
286
|
+
try {
|
|
287
|
+
body = await readBody(request)
|
|
288
|
+
} catch (error) {
|
|
289
|
+
sendJson(response, 400, { ok: false, code: 'UPDATE_REJECTED', message: error instanceof Error ? error.message : String(error) })
|
|
290
|
+
return
|
|
291
|
+
}
|
|
292
|
+
const target = body?.target
|
|
293
|
+
if (!isExactVersion(target)) {
|
|
294
|
+
sendJson(response, 400, { ok: false, code: 'UPDATE_REJECTED', message: 'target must be an exact version', retryable: false })
|
|
295
|
+
return
|
|
296
|
+
}
|
|
297
|
+
// A checkout is updated by its own owner; replacing its `link:` spec with
|
|
298
|
+
// a registry version would silently detach the working copy.
|
|
299
|
+
const mode = installMode(dependencySpec(dir))
|
|
300
|
+
if (mode !== 'npm') {
|
|
301
|
+
sendJson(response, 409, {
|
|
302
|
+
ok: false,
|
|
303
|
+
code: 'UPDATE_REJECTED',
|
|
304
|
+
message: mode === 'link'
|
|
305
|
+
? 'this profile installs the plugin from a checkout; update it there and reload'
|
|
306
|
+
: 'this profile records no plugin dependency to replace',
|
|
307
|
+
retryable: false,
|
|
308
|
+
})
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
const installed = installedVersion(dir)
|
|
312
|
+
if (installed !== undefined && compareVersions(target, installed) < 0) {
|
|
313
|
+
sendJson(response, 409, {
|
|
314
|
+
ok: false,
|
|
315
|
+
code: 'DOWNGRADE_DETECTED',
|
|
316
|
+
message: `refusing to downgrade ${installed} to ${target}`,
|
|
317
|
+
retryable: false,
|
|
318
|
+
})
|
|
319
|
+
return
|
|
320
|
+
}
|
|
321
|
+
const task = applyUpdate({
|
|
322
|
+
target,
|
|
323
|
+
profileDir: dir,
|
|
324
|
+
installer: installerOf(),
|
|
325
|
+
pluginCommand: await pluginCommandOf(ctx.get('profileContext')),
|
|
326
|
+
packageManager: packageManagerOf(),
|
|
327
|
+
runner: runProcess,
|
|
328
|
+
})
|
|
329
|
+
state.promise = task
|
|
330
|
+
try {
|
|
331
|
+
const result = await task
|
|
332
|
+
sendJson(response, 200, { ok: true, ...result })
|
|
333
|
+
} catch (error) {
|
|
334
|
+
const failure = error instanceof UpdateError
|
|
335
|
+
? error
|
|
336
|
+
: new UpdateError('UPDATE_FAILED', error instanceof Error ? error.message : String(error))
|
|
337
|
+
sendJson(response, failure.code === 'AUTO_UPDATE_UNAVAILABLE' ? 501 : 502, {
|
|
338
|
+
ok: false,
|
|
339
|
+
code: failure.code,
|
|
340
|
+
message: failure.message,
|
|
341
|
+
retryable: failure.retryable,
|
|
342
|
+
...(failure.diagnostic === undefined ? {} : { diagnostic: failure.diagnostic }),
|
|
343
|
+
...(MANUAL_HINT_CODES.has(failure.code) ? { hint: manualCommand(dir, target) } : {}),
|
|
344
|
+
})
|
|
345
|
+
} finally {
|
|
346
|
+
state.promise = undefined
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
})
|
|
350
|
+
|
|
351
|
+
return () => {
|
|
352
|
+
for (const dispose of [disposeProbe, disposeApply]) {
|
|
353
|
+
try {
|
|
354
|
+
if (typeof dispose === 'function') dispose()
|
|
355
|
+
} catch {
|
|
356
|
+
// A route that already went away is not a failure to report.
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
package/host/versions.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version comparison for the host-side update path.
|
|
3
|
+
*
|
|
4
|
+
* The panel asks npm for a published version and compares it with what is on
|
|
5
|
+
* disk before offering anything. A string sort would order `1.10.0` below
|
|
6
|
+
* `1.9.0`, and a prerelease must rank below the release it leads to, so the
|
|
7
|
+
* comparison lives here and is tested on its own.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Split a version into its numeric parts and prerelease identifiers.
|
|
12
|
+
* @param {string} value
|
|
13
|
+
* @returns {{ major: number, minor: number, patch: number, prerelease: string[] } | undefined}
|
|
14
|
+
*/
|
|
15
|
+
export function parseSemver(value) {
|
|
16
|
+
if (typeof value !== 'string') return undefined
|
|
17
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(value.trim())
|
|
18
|
+
if (match === null) return undefined
|
|
19
|
+
return {
|
|
20
|
+
major: Number(match[1]),
|
|
21
|
+
minor: Number(match[2]),
|
|
22
|
+
patch: Number(match[3]),
|
|
23
|
+
prerelease: match[4] === undefined ? [] : match[4].split('.'),
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Order two versions. An unparsable version sorts below a parsable one, which
|
|
29
|
+
* keeps a malformed registry answer from ever reading as "newer".
|
|
30
|
+
* @param {string} a
|
|
31
|
+
* @param {string} b
|
|
32
|
+
* @returns {number} negative when a < b, 0 when equal, positive when a > b
|
|
33
|
+
*/
|
|
34
|
+
export function compareVersions(a, b) {
|
|
35
|
+
const left = parseSemver(a)
|
|
36
|
+
const right = parseSemver(b)
|
|
37
|
+
if (left === undefined && right === undefined) return 0
|
|
38
|
+
if (left === undefined) return -1
|
|
39
|
+
if (right === undefined) return 1
|
|
40
|
+
for (const field of /** @type {const} */ (['major', 'minor', 'patch'])) {
|
|
41
|
+
if (left[field] !== right[field]) return left[field] < right[field] ? -1 : 1
|
|
42
|
+
}
|
|
43
|
+
// A release outranks any prerelease on the same core (`1.2.0` > `1.2.0-rc.1`).
|
|
44
|
+
if (left.prerelease.length === 0 && right.prerelease.length === 0) return 0
|
|
45
|
+
if (left.prerelease.length === 0) return 1
|
|
46
|
+
if (right.prerelease.length === 0) return -1
|
|
47
|
+
for (let index = 0; index < Math.max(left.prerelease.length, right.prerelease.length); index += 1) {
|
|
48
|
+
const aPart = left.prerelease[index]
|
|
49
|
+
const bPart = right.prerelease[index]
|
|
50
|
+
if (aPart === undefined) return -1
|
|
51
|
+
if (bPart === undefined) return 1
|
|
52
|
+
if (aPart === bPart) continue
|
|
53
|
+
const aNumeric = /^\d+$/.test(aPart)
|
|
54
|
+
const bNumeric = /^\d+$/.test(bPart)
|
|
55
|
+
if (aNumeric && bNumeric) return Number(aPart) < Number(bPart) ? -1 : 1
|
|
56
|
+
// Numeric identifiers rank below alphanumeric ones, as semver requires.
|
|
57
|
+
if (aNumeric) return -1
|
|
58
|
+
if (bNumeric) return 1
|
|
59
|
+
return aPart < bPart ? -1 : 1
|
|
60
|
+
}
|
|
61
|
+
return 0
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Whether `latest` is a strictly newer release than `current`.
|
|
66
|
+
* @param {string} latest
|
|
67
|
+
* @param {string} current
|
|
68
|
+
* @returns {boolean}
|
|
69
|
+
*/
|
|
70
|
+
export function isNewer(latest, current) {
|
|
71
|
+
return compareVersions(latest, current) > 0
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Whether a version carries a prerelease part, e.g. `1.2.0-beta.1`.
|
|
76
|
+
* @param {unknown} value
|
|
77
|
+
* @returns {boolean}
|
|
78
|
+
*/
|
|
79
|
+
export function isPrerelease(value) {
|
|
80
|
+
return /^\D*\d+\.\d+\.\d+-/.test(String(value ?? '').trim())
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Whether a string can be used as an install target without shell access.
|
|
85
|
+
* The update path passes it to a package manager, so it must be a plain
|
|
86
|
+
* version and never a spec, a range or a path.
|
|
87
|
+
* @param {unknown} value
|
|
88
|
+
* @returns {value is string}
|
|
89
|
+
*/
|
|
90
|
+
export function isExactVersion(value) {
|
|
91
|
+
return typeof value === 'string' && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(value)
|
|
92
|
+
}
|
package/icon.svg
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36" fill="none">
|
|
2
|
+
<path d="M9.5 7H17.5C19.71 7 21.5 8.79 21.5 11V16C21.5 18.21 19.71 20 17.5 20H13.6L9.35 23.85C8.83 24.32 8 23.95 8 23.25V19.72C6.53 19.16 5.5 17.7 5.5 16V11C5.5 8.79 7.29 7 9.5 7Z" fill="#7CB7FF" fill-opacity="0.55"/>
|
|
3
|
+
<path d="M18 12H27C28.93 12 30.5 13.57 30.5 15.5V24.5L25 30H18C16.07 30 14.5 28.43 14.5 26.5V15.5C14.5 13.57 16.07 12 18 12Z" fill="url(#sideby-note-card)"/>
|
|
4
|
+
<path d="M30.5 24.5H26.6C25.72 24.5 25 25.22 25 26.1V30L30.5 24.5Z" fill="#BCD5FD"/>
|
|
5
|
+
<path d="M18.25 17.25H26.75M18.25 21.5H22.75" stroke="#FFFFFF" stroke-width="2" stroke-linecap="round"/>
|
|
6
|
+
<defs>
|
|
7
|
+
<linearGradient id="sideby-note-card" x1="16" y1="12" x2="28" y2="30" gradientUnits="userSpaceOnUse">
|
|
8
|
+
<stop stop-color="#7AC2FF"/>
|
|
9
|
+
<stop offset="1" stop-color="#4A65E8"/>
|
|
10
|
+
</linearGradient>
|
|
11
|
+
</defs>
|
|
12
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host half of the Sideby Note panel.
|
|
3
|
+
*
|
|
4
|
+
* Notes stay in the browser: they are small, human-authored records scoped to
|
|
5
|
+
* one session or workspace. What lives here is only what a page cannot do —
|
|
6
|
+
* installing a newer build of this same plugin into the profile, which used to
|
|
7
|
+
* be delegated to the plugin market and was refused there whenever the panel
|
|
8
|
+
* was open (`bundle-in-use`). The routes carry no note data and read no store.
|
|
9
|
+
*/
|
|
10
|
+
import { registerUpdateRoutes } from './host/route.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {import('@deepseek-ai/cordis').Context} ctx
|
|
14
|
+
* @param {{ updateEnabled?: boolean } | undefined} config
|
|
15
|
+
*/
|
|
16
|
+
export function apply(ctx, config) {
|
|
17
|
+
// Headless and ACP hosts compose no web server. The panel then keeps its
|
|
18
|
+
// previous market path, so a missing service is not an error worth raising.
|
|
19
|
+
if (config?.updateEnabled === false) return
|
|
20
|
+
ctx.inject(['webServer'], hostCtx => {
|
|
21
|
+
hostCtx.effect(() => {
|
|
22
|
+
const dispose = registerUpdateRoutes(hostCtx.webServer, { ctx, config })
|
|
23
|
+
return () => {
|
|
24
|
+
if (typeof dispose === 'function') dispose()
|
|
25
|
+
}
|
|
26
|
+
}, 'dsh-sideby-note: update routes')
|
|
27
|
+
})
|
|
28
|
+
}
|
package/locale/de.json
ADDED
package/locale/en.json
ADDED
package/locale/es.json
ADDED
package/locale/fr.json
ADDED
package/locale/ja.json
ADDED
package/locale/pt.json
ADDED
package/locale/ru.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,96 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-sideby-note",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Sideby Note (边记部) — asynchronously draft your ideas while the agent is working: a lightweight per-session notes button and right-side panel for the DeepSeek Harness Web GUI. Based and inspired by dsh-aside-note.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Rayle8",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/LighghtEeloo/dsh-sideby-note.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/LighghtEeloo/dsh-sideby-note#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/LighghtEeloo/dsh-sideby-note/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"dsh",
|
|
18
|
+
"deepseek-harness",
|
|
19
|
+
"dsh-plugin",
|
|
20
|
+
"notes",
|
|
21
|
+
"session-notes",
|
|
22
|
+
"todo",
|
|
23
|
+
"productivity"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": "^22.18.0 || >=24.11.0"
|
|
27
|
+
},
|
|
28
|
+
"main": "index.js",
|
|
29
|
+
"bin": {
|
|
30
|
+
"dsh-sideby-note": "scripts/install.mjs"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./index.js",
|
|
34
|
+
"./client": "./client/client.js",
|
|
35
|
+
"./locale/*.json": "./locale/*.json",
|
|
36
|
+
"./icon": "./icon.svg"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"index.js",
|
|
40
|
+
"host",
|
|
41
|
+
"client/client.js",
|
|
42
|
+
"scripts/install.mjs",
|
|
43
|
+
"cordis.patch.yml",
|
|
44
|
+
"locale/*.json",
|
|
45
|
+
"icon.svg",
|
|
46
|
+
"docs/assets",
|
|
47
|
+
"docs/panel-ui-rules.md",
|
|
48
|
+
"README.md",
|
|
49
|
+
"README.en.md",
|
|
50
|
+
"LICENSE",
|
|
51
|
+
"CHANGELOG.md"
|
|
52
|
+
],
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsdown",
|
|
55
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
56
|
+
"lint": "oxlint src",
|
|
57
|
+
"test": "node --test tests/*.test.mjs",
|
|
58
|
+
"check": "npm run lint && npm run typecheck && npm run build && npm run test",
|
|
59
|
+
"release": "node tools/release.mjs",
|
|
60
|
+
"prepack": "npm run build"
|
|
61
|
+
},
|
|
62
|
+
"dsh": {
|
|
63
|
+
"bundle": {
|
|
64
|
+
"patch": "./cordis.patch.yml"
|
|
65
|
+
},
|
|
66
|
+
"client": {
|
|
67
|
+
"platform": "web",
|
|
68
|
+
"immediately": true,
|
|
69
|
+
"inject": [
|
|
70
|
+
"@deepseek-ai/dsh-client-locale",
|
|
71
|
+
"@deepseek-ai/dsh-client-ui-chat",
|
|
72
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
73
|
+
"@deepseek-ai/dsh-client-ui-layout",
|
|
74
|
+
"@deepseek-ai/dsh-client-ui-sidebar",
|
|
75
|
+
"@deepseek-ai/dsh-client-ui-workspace"
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"publishConfig": {
|
|
80
|
+
"registry": "https://registry.npmjs.org/"
|
|
81
|
+
},
|
|
82
|
+
"devDependencies": {
|
|
83
|
+
"@testing-library/dom": "^10.4.2",
|
|
84
|
+
"@testing-library/react": "^16.3.3",
|
|
85
|
+
"@types/node": "^22.20.5",
|
|
86
|
+
"@types/react": "~18.3.31",
|
|
87
|
+
"@types/react-dom": "~18.3.7",
|
|
88
|
+
"jsdom": "^29.1.1",
|
|
89
|
+
"oxlint": "^1.90.0",
|
|
90
|
+
"react": "^18.3.1",
|
|
91
|
+
"react-dom": "~18.3.1",
|
|
92
|
+
"tsdown": "^0.23.4",
|
|
93
|
+
"typescript": "~5.7.3",
|
|
94
|
+
"vitest": "^4.1.12"
|
|
95
|
+
}
|
|
96
|
+
}
|