@maci0/dsh-alias 0.7.3 → 0.7.5
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 +8 -8
- package/lib/client.js +93 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# dsh-alias
|
|
2
2
|
|
|
3
|
-
Define your own slash commands in DeepSeek Harness, from the composer
|
|
4
|
-
the Plugins page.
|
|
3
|
+
Define your own slash commands in DeepSeek Harness, from the composer, the
|
|
4
|
+
**Aliases** panel in the sidebar, or the Alias card on the Plugins page.
|
|
5
5
|
|
|
6
6
|
## What you get
|
|
7
7
|
|
|
@@ -15,7 +15,9 @@ the Plugins page.
|
|
|
15
15
|
|
|
16
16
|
After that, `/gm`, `/rev src/app.ts`, and `/ship` are ordinary commands: they
|
|
17
17
|
show up in the composer's command directory and run without a model turn of
|
|
18
|
-
their own.
|
|
18
|
+
their own. Three surfaces edit the same set: the sidebar's **Aliases** panel,
|
|
19
|
+
the **Alias** card inside the plugin's row on the Plugins page, and `/alias`
|
|
20
|
+
itself.
|
|
19
21
|
|
|
20
22
|
## Install
|
|
21
23
|
|
|
@@ -28,14 +30,12 @@ Requires DeepSeek Harness `>=0.2.2-rc.4 <0.3.0`. Restart DSH and refresh the bro
|
|
|
28
30
|
> would win).
|
|
29
31
|
|
|
30
32
|
```sh
|
|
31
|
-
dsh plugin --profile web add --save-exact @maci0/dsh-alias@0.7.
|
|
33
|
+
dsh plugin --profile web add --save-exact @maci0/dsh-alias@0.7.5
|
|
32
34
|
```
|
|
33
35
|
|
|
34
36
|
Pin an exact npm version. To upgrade, run the same command with the newer
|
|
35
37
|
version, then restart `dsh web` (bundle layers compose at boot).
|
|
36
38
|
|
|
37
|
-
The bundled `cordis.patch.yml` inserts the `alias` row.
|
|
38
|
-
|
|
39
39
|
## Commands
|
|
40
40
|
|
|
41
41
|
`/alias add <name> <text>` registers `/<name>`. What `/<name>` does depends on
|
|
@@ -74,8 +74,8 @@ Aliases live in one settings field, the plugin's own row:
|
|
|
74
74
|
|
|
75
75
|
## How it works
|
|
76
76
|
|
|
77
|
-
The field is `volatile()`, so the Plugins page's **Alias** card, `/alias`, and
|
|
78
|
-
the profile patch are
|
|
77
|
+
The field is `volatile()`, so the sidebar's **Aliases** page, the Plugins page's **Alias** card, `/alias`, and
|
|
78
|
+
the profile patch are four views of one document: a write from any of them
|
|
79
79
|
lands on the running instance with no remount. A deployment whose settings
|
|
80
80
|
document refuses writes still gets working aliases in every current session
|
|
81
81
|
until dsh restarts, and the reply says so. The card reports a write the host refuses.
|
package/lib/client.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dsh-alias: browser half.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Two surfaces over one editor: the Alias card on the Plugins page (the
|
|
5
|
+
* `plugins.row.config` slot) and a global Aliases page behind the sidebar's
|
|
6
|
+
* panel list. Both are keyed on the `alias` settings namespace the host half
|
|
7
|
+
* declares as its row id. The page lists every
|
|
6
8
|
* defined alias with a Remove control and adds one through a name + text pair;
|
|
7
9
|
* every write goes through `ctx.configForms`, the same settings document
|
|
8
10
|
* `/alias` writes on the host, so the two surfaces cannot disagree.
|
|
9
11
|
*
|
|
10
|
-
* Chrome is a stylesheet, not inline style objects:
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Chrome is a stylesheet, not inline style objects: `apply` installs one
|
|
13
|
+
* `<style data-plugin>` tag through `ctx.effect`, and the plugin's dispose
|
|
14
|
+
* removes it. All classes are `da-`-prefixed because that sheet lands in the
|
|
15
|
+
* page's own document.
|
|
14
16
|
*
|
|
15
17
|
* This file is plain JavaScript on purpose. The client module system serves a
|
|
16
18
|
* package's `exports["./client"]` artifact as a lazy-CJS factory registered on
|
|
@@ -40,6 +42,9 @@ window.__ModuleLoader__.load({
|
|
|
40
42
|
/** Locale namespace for this plugin's copy. */
|
|
41
43
|
const LOCALE_NS = 'alias'
|
|
42
44
|
|
|
45
|
+
/** Global panel id shared by the sidebar entry and the page it opens. */
|
|
46
|
+
const PANEL_ID = 'alias'
|
|
47
|
+
|
|
43
48
|
/** The names the command registry accepts, mirroring the host half. */
|
|
44
49
|
const COMMAND_NAME = /^[a-z][a-z0-9_-]*$/u
|
|
45
50
|
|
|
@@ -63,22 +68,18 @@ window.__ModuleLoader__.load({
|
|
|
63
68
|
'.da-button-remove{flex:none;padding:3px 10px;font-size:12px;color:var(--dsw-alias-label-secondary)}',
|
|
64
69
|
'.da-status{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}',
|
|
65
70
|
'.da-error{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-error)}',
|
|
71
|
+
'.da-panel{display:flex;flex-direction:column;gap:16px;max-width:920px;padding:24px 32px;box-sizing:border-box}',
|
|
72
|
+
'.da-panel-title{font-size:20px;line-height:1.4;font-weight:600;margin:0;color:var(--dsw-alias-label-primary)}',
|
|
73
|
+
'.da-panel-subtitle{font-size:13px;line-height:1.5;margin:0;color:var(--dsw-alias-label-tertiary)}',
|
|
66
74
|
].join('')
|
|
67
75
|
|
|
68
|
-
// Appended while the factory materializes: the module system claims the tag
|
|
69
|
-
// for this package and disposes it on unload. Guarded because the node unit
|
|
70
|
-
// tests evaluate this file without a DOM.
|
|
71
|
-
if (typeof document !== 'undefined') {
|
|
72
|
-
const style = document.createElement('style')
|
|
73
|
-
style.textContent = CSS
|
|
74
|
-
document.head.append(style)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
76
|
/** Plugin version, shown in the card header. Kept in lockstep with package.json. */
|
|
78
|
-
const VERSION = '0.7.
|
|
77
|
+
const VERSION = '0.7.5'
|
|
79
78
|
|
|
80
79
|
const en = {
|
|
81
80
|
title: 'Alias',
|
|
81
|
+
panel: 'Aliases',
|
|
82
|
+
panelSubtitle: 'Define slash commands of your own. Each alias is a command like any other, in the composer and in the catalog.',
|
|
82
83
|
summaryEmpty: 'No aliases defined.',
|
|
83
84
|
summary: '{count} alias(es) defined.',
|
|
84
85
|
groupExisting: 'Defined aliases',
|
|
@@ -100,6 +101,8 @@ window.__ModuleLoader__.load({
|
|
|
100
101
|
|
|
101
102
|
const zh = {
|
|
102
103
|
title: '别名',
|
|
104
|
+
panel: '别名',
|
|
105
|
+
panelSubtitle: '定义你自己的斜杠命令。每个别名都和普通命令一样,出现在输入框和命令目录里。',
|
|
103
106
|
summaryEmpty: '未定义别名。',
|
|
104
107
|
summary: '已定义 {count} 个别名。',
|
|
105
108
|
groupExisting: '已定义的别名',
|
|
@@ -314,11 +317,68 @@ window.__ModuleLoader__.load({
|
|
|
314
317
|
}
|
|
315
318
|
}
|
|
316
319
|
|
|
320
|
+
/**
|
|
321
|
+
* Build the global page behind the sidebar entry: the same editor the row
|
|
322
|
+
* card renders, under a page title.
|
|
323
|
+
* @param Card - the row card component.
|
|
324
|
+
* @param t - translate function bound to this plugin's locale namespace.
|
|
325
|
+
* @returns the page component the `main` slot renders.
|
|
326
|
+
*/
|
|
327
|
+
function createPanel(Card, t) {
|
|
328
|
+
return function AliasPanel() {
|
|
329
|
+
return React.createElement(
|
|
330
|
+
'div',
|
|
331
|
+
{ className: 'da-panel' },
|
|
332
|
+
React.createElement('h1', { className: 'da-panel-title' }, t('panel')),
|
|
333
|
+
React.createElement('p', { className: 'da-panel-subtitle' }, t('panelSubtitle')),
|
|
334
|
+
React.createElement(Card, { view: 'page' }),
|
|
335
|
+
)
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Decorative occupant for the sidebar entry; the sidebar owns the
|
|
341
|
+
* accessible label.
|
|
342
|
+
* @param props - the sidebar's icon share: the requested edge size.
|
|
343
|
+
* @returns the alias glyph.
|
|
344
|
+
*/
|
|
345
|
+
function AliasPanelIcon(props) {
|
|
346
|
+
const size = props?.size ?? 16
|
|
347
|
+
return React.createElement(
|
|
348
|
+
'svg',
|
|
349
|
+
{
|
|
350
|
+
width: size,
|
|
351
|
+
height: size,
|
|
352
|
+
viewBox: '0 0 16 16',
|
|
353
|
+
fill: 'none',
|
|
354
|
+
stroke: 'currentColor',
|
|
355
|
+
strokeWidth: 1.5,
|
|
356
|
+
strokeLinecap: 'round',
|
|
357
|
+
strokeLinejoin: 'round',
|
|
358
|
+
'aria-hidden': 'true',
|
|
359
|
+
},
|
|
360
|
+
React.createElement('path', { d: 'M2.5 5.5h9m0 0-2.5-2.5m2.5 2.5L9 8' }),
|
|
361
|
+
React.createElement('path', { d: 'M13.5 10.5h-9m0 0L7 8m-2.5 2.5L7 13' }),
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
|
|
317
365
|
/**
|
|
318
366
|
* Mount the browser surface: the Alias card on the Plugins page.
|
|
319
367
|
* @param ctx - the browser plugin context.
|
|
320
368
|
*/
|
|
321
369
|
function apply(ctx) {
|
|
370
|
+
// One stylesheet per plugin instance, removed when the plugin disposes.
|
|
371
|
+
// Guarded because the node unit tests evaluate this file without a DOM.
|
|
372
|
+
if (typeof document !== 'undefined') {
|
|
373
|
+
ctx.effect(() => {
|
|
374
|
+
const style = document.createElement('style')
|
|
375
|
+
style.setAttribute('data-plugin', '@maci0/dsh-alias')
|
|
376
|
+
style.textContent = CSS
|
|
377
|
+
document.head.append(style)
|
|
378
|
+
return () => style.remove()
|
|
379
|
+
}, 'dsh-alias: stylesheet')
|
|
380
|
+
}
|
|
381
|
+
|
|
322
382
|
const t = ctx.locale.bind(LOCALE_NS)
|
|
323
383
|
ctx.effect(
|
|
324
384
|
() => ctx.locale.register(LOCALE_NS, { en, zh }),
|
|
@@ -337,6 +397,23 @@ window.__ModuleLoader__.load({
|
|
|
337
397
|
key: '@maci0/dsh-alias#alias',
|
|
338
398
|
locale: LOCALE_NS,
|
|
339
399
|
}, Card))
|
|
400
|
+
|
|
401
|
+
// The same editor as a global page behind the sidebar's panel list, so
|
|
402
|
+
// the aliases are reachable without opening the Plugins page and the
|
|
403
|
+
// row detail inside it.
|
|
404
|
+
ctx.slots.inject('main', () => ctx.slots.register({
|
|
405
|
+
name: 'main',
|
|
406
|
+
key: PANEL_ID,
|
|
407
|
+
locale: LOCALE_NS,
|
|
408
|
+
}, createPanel(Card, t)))
|
|
409
|
+
|
|
410
|
+
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
411
|
+
name: 'sidebar.panellist',
|
|
412
|
+
id: PANEL_ID,
|
|
413
|
+
order: 20,
|
|
414
|
+
locale: LOCALE_NS,
|
|
415
|
+
label: () => t('panel'),
|
|
416
|
+
}, AliasPanelIcon))
|
|
340
417
|
}
|
|
341
418
|
|
|
342
419
|
exports.apply = apply
|