dsh-composer-send-key 0.0.0-stage → 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Licheung228
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,61 @@
1
- # Temporary Holding Version
1
+ # Composer send key
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Switch the DeepSeek Harness message box send shortcut between two modes:
4
+
5
+ | Mode | Enter | Shift+Enter |
6
+ |---|---|---|
7
+ | Default | Send | New line |
8
+ | Edit-friendly | New line | Send |
9
+
10
+ ## Install
11
+
12
+ In DeepSeek Harness, open **Plugins → Add plugin** and install
13
+ `dsh-composer-send-key`. You can also install it from the command line:
14
+
15
+ ```sh
16
+ dsh plugin --profile <profile> add dsh-composer-send-key
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ Open **Settings → General → Send shortcut** and pick a mode. The change
22
+ applies immediately (no restart) and persists in your profile's settings
23
+ document through the volatile `mode` field of the `composer-send-key` entry.
24
+
25
+ You can also set it directly in the profile patch:
26
+
27
+ ```yaml
28
+ - id: composer-send-key
29
+ name: 'dsh-composer-send-key'
30
+ config:
31
+ mode: edit-friendly # or: default
32
+ ```
33
+
34
+ ## Behavior notes
35
+
36
+ - Ctrl/⌘+Enter keeps the built-in accelerated delivery; other modifiers are
37
+ never rewritten.
38
+ - The busy-state Composer Enter preference (queue/steer) keeps working in
39
+ both modes.
40
+ - In edit-friendly mode the two keys swap completely: with the suggestion
41
+ menu open, Enter inserts a newline and Shift+Enter confirms the highlighted
42
+ item (exactly the other gesture's stock behavior).
43
+ - IME composition is left untouched: a composition-closing Enter never
44
+ submits or inserts a stray newline.
45
+ - The Send button, the shortcuts reference page and its fixed Enter bindings
46
+ keep their shipped appearance and wording.
47
+ - Disabling or removing the plugin restores the default behavior.
48
+
49
+ ## How it works
50
+
51
+ The shipped composer hardcodes Enter/Shift+Enter in its Lexical keymap and
52
+ exposes no extension point for it. In edit-friendly mode this plugin swaps
53
+ the `shiftKey` modifier of the original keydown event in the capture phase,
54
+ before the composer's own handler runs, so every shipped guard (busy state,
55
+ command-menu arbitration, IME window, held-key repeat) is preserved. In
56
+ default mode the listener does nothing.
57
+
58
+ Because this relies on the composer's internal DOM (`[data-composer-card]`)
59
+ and keyboard handling, re-verify the plugin after a DeepSeek Harness
60
+ upgrade; if the internals change, the plugin falls back to the stock
61
+ behavior rather than breaking the input.
package/client.js ADDED
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Client half of composer-send-key.
3
+ *
4
+ * Two contributions:
5
+ * 1. A Settings → General preference row (`settings.general.item`) switching
6
+ * between `default` (Enter sends, Shift+Enter newlines) and
7
+ * `edit-friendly` (Enter newlines, Shift+Enter sends). The value lives in
8
+ * the volatile `mode` field of this entry's settings namespace, so writes
9
+ * persist in the profile and apply live.
10
+ * 2. A capture-phase keydown listener that, only in edit-friendly mode and
11
+ * only inside the composer's contenteditable, swaps the Shift modifier of
12
+ * plain Enter / Shift+Enter before the composer's own Lexical keymap sees
13
+ * the event. Every downstream guard (busy state, command-menu arbitration,
14
+ * IME composition, held-key repeat) keeps its shipped behavior because the
15
+ * original event continues unchanged otherwise; in default mode the
16
+ * listener never touches anything.
17
+ */
18
+ window.__ModuleLoader__.load({
19
+ id: 'dsh-composer-send-key',
20
+ factory(require) {
21
+ const React = require('react')
22
+ const h = React.createElement
23
+
24
+ const NS = 'composer-send-key'
25
+ const MODE_FIELD = 'mode'
26
+ const DEFAULT_MODE = 'default'
27
+ const EDIT_FRIENDLY_MODE = 'edit-friendly'
28
+
29
+ const dictionaries = {
30
+ en: {
31
+ 'row.title': 'Send shortcut',
32
+ 'mode.default': 'Default (Enter sends)',
33
+ 'mode.editFriendly': 'Edit-friendly (Shift+Enter sends)',
34
+ 'row.saveFailed': 'Could not save; the change applies to this session only.',
35
+ },
36
+ zh: {
37
+ 'row.title': '发送快捷键',
38
+ 'mode.default': '默认模式(Enter 发送)',
39
+ 'mode.editFriendly': '编辑友好模式(Shift+Enter 发送)',
40
+ 'row.saveFailed': '保存失败,本次修改仅在当前会话生效。',
41
+ },
42
+ }
43
+
44
+ const CSS = `
45
+ .dsh-csk-row{display:flex;align-items:center;gap:8px;padding:16px 0;border-bottom:.5px solid var(--dsw-alias-border-l2);}
46
+ .dsh-csk-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px;padding-right:48px;}
47
+ @media (max-width:767px){html:not([data-windows-titlebar]):not([data-platform='darwin']) .dsh-csk-text{padding-right:16px;}}
48
+ .dsh-csk-title{font-size:14px;font-weight:400;line-height:22px;color:var(--dsw-alias-label-primary);}
49
+ .dsh-csk-select{flex:none;height:36px;max-width:260px;padding:0 10px;border:none;border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);font:inherit;font-size:14px;line-height:22px;color:var(--dsw-alias-label-primary);cursor:pointer;}
50
+ @media (hover:hover){.dsh-csk-select:hover{background:var(--dsw-alias-interactive-bg-hover);}}
51
+ .dsh-csk-error{font-size:12px;font-weight:400;line-height:18px;color:var(--dsw-alias-state-error-primary);}
52
+ `
53
+
54
+ /** Translation fallback when the slot does not project a `t` prop. */
55
+ let fallbackTranslate = (key) => key
56
+
57
+ function SendKeyModeRow(props) {
58
+ const useMode = props.useMode
59
+ const useSaveError = props.useSaveError
60
+ const setMode = props.setMode
61
+ const t = props.t ?? fallbackTranslate
62
+ const mode = useMode((value) => value)
63
+ const saveError = useSaveError((value) => value)
64
+ return h(React.Fragment, null,
65
+ h('style', null, CSS),
66
+ h('div', { className: 'dsh-csk-row' },
67
+ h('div', { className: 'dsh-csk-text' },
68
+ h('div', { className: 'dsh-csk-title' }, t('row.title')),
69
+ saveError ? h('div', { className: 'dsh-csk-error', role: 'status' }, saveError) : null),
70
+ h('select', {
71
+ className: 'dsh-csk-select',
72
+ value: mode,
73
+ 'aria-label': t('row.title'),
74
+ onChange: (event) => setMode(event.target.value),
75
+ },
76
+ h('option', { value: DEFAULT_MODE }, t('mode.default')),
77
+ h('option', { value: EDIT_FRIENDLY_MODE }, t('mode.editFriendly')))))
78
+ }
79
+
80
+ /** The composer's contenteditable root, identified without reading any other plugin's DOM. */
81
+ function isComposerEditable(target) {
82
+ if (!(target instanceof HTMLElement)) return false
83
+ if (!target.isContentEditable) return false
84
+ return target.closest('[data-composer-card]') !== null
85
+ }
86
+
87
+ return {
88
+ inject: ['slots', 'locale', 'configForms'],
89
+ apply(ctx) {
90
+ ctx.effect(() => ctx.locale.register(NS, dictionaries), 'composer-send-key: dictionaries')
91
+ const t = ctx.locale.bind(NS)
92
+ fallbackTranslate = t
93
+
94
+ // Live `mode` snapshot over the Host settings document; browser-local
95
+ // default when the namespace is not exposed to this client.
96
+ const form = typeof ctx.configForms?.get === 'function' ? ctx.configForms.get(NS) : undefined
97
+ let mode = DEFAULT_MODE
98
+ const listeners = new Set()
99
+ const publish = () => { for (const listener of [...listeners]) listener() }
100
+ const store = {
101
+ getSnapshot: () => mode,
102
+ subscribe: (listener) => {
103
+ listeners.add(listener)
104
+ return () => { listeners.delete(listener) }
105
+ },
106
+ }
107
+ const adopt = () => {
108
+ const value = form?.getSnapshot().value
109
+ const next = value !== undefined && value !== null && value.mode === EDIT_FRIENDLY_MODE
110
+ ? EDIT_FRIENDLY_MODE
111
+ : DEFAULT_MODE
112
+ if (next !== mode) {
113
+ mode = next
114
+ publish()
115
+ }
116
+ }
117
+ ctx.effect(() => {
118
+ const unsubscribe = form?.subscribe(adopt)
119
+ adopt()
120
+ return unsubscribe
121
+ }, 'composer-send-key: mode adoption')
122
+ let saveError = ''
123
+ const errorListeners = new Set()
124
+ const publishError = () => { for (const listener of [...errorListeners]) listener() }
125
+ const setSaveError = (text) => { if (text !== saveError) { saveError = text; publishError() } }
126
+ const errorStore = {
127
+ getSnapshot: () => saveError,
128
+ subscribe: (listener) => {
129
+ errorListeners.add(listener)
130
+ return () => { errorListeners.delete(listener) }
131
+ },
132
+ }
133
+ const setMode = (next) => {
134
+ if (next !== DEFAULT_MODE && next !== EDIT_FRIENDLY_MODE) return
135
+ if (next === mode) return
136
+ mode = next
137
+ publish()
138
+ if (form === undefined) {
139
+ setSaveError(t('row.saveFailed'))
140
+ return
141
+ }
142
+ void form.set(MODE_FIELD, next).then((accepted) => {
143
+ adopt()
144
+ setSaveError(accepted ? '' : t('row.saveFailed'))
145
+ }, () => {
146
+ adopt()
147
+ setSaveError(t('row.saveFailed'))
148
+ })
149
+ }
150
+
151
+ // Capture-phase modifier swap; see the module doc for why this is the
152
+ // only interception point the shipped composer leaves a plugin.
153
+ let composing = false
154
+ let composingUntil = 0
155
+ const isComposing = (event) =>
156
+ event.isComposing || event.keyCode === 229 || composing || Date.now() < composingUntil
157
+ let warnedShiftSwap = false
158
+ const setShift = (event, value) => {
159
+ try {
160
+ Object.defineProperty(event, 'shiftKey', { configurable: true, enumerable: true, get: () => value })
161
+ } catch {
162
+ // An exotic event without a configurable shiftKey would leave the
163
+ // stock behavior in place; surface that once instead of silently
164
+ // keeping Enter = send in edit-friendly mode.
165
+ if (!warnedShiftSwap) {
166
+ warnedShiftSwap = true
167
+ console.warn('[composer-send-key] shiftKey is not configurable; edit-friendly mode is inactive for this event')
168
+ }
169
+ }
170
+ }
171
+ const onCompositionStart = (event) => { if (isComposerEditable(event.target)) composing = true }
172
+ const onCompositionEnd = () => {
173
+ if (!composing) return
174
+ composing = false
175
+ // Safari delivers the composition-closing keydown just after
176
+ // compositionend; hold the guard for one tick, mirroring the
177
+ // composer's own IME window.
178
+ composingUntil = Date.now() + 10
179
+ }
180
+ const onKeyDown = (event) => {
181
+ if (mode !== EDIT_FRIENDLY_MODE) return
182
+ if (event.key !== 'Enter') return
183
+ if (!isComposerEditable(event.target)) return
184
+ if (event.ctrlKey || event.metaKey || event.altKey) return
185
+ if (typeof event.getModifierState === 'function' && event.getModifierState('AltGraph')) return
186
+ // An IME-closing Enter must reach the candidate window unchanged.
187
+ if (isComposing(event)) return
188
+ setShift(event, !event.shiftKey)
189
+ }
190
+ ctx.effect(() => {
191
+ const options = { capture: true }
192
+ document.addEventListener('keydown', onKeyDown, options)
193
+ document.addEventListener('compositionstart', onCompositionStart, options)
194
+ document.addEventListener('compositionend', onCompositionEnd, options)
195
+ return () => {
196
+ document.removeEventListener('keydown', onKeyDown, options)
197
+ document.removeEventListener('compositionstart', onCompositionStart, options)
198
+ document.removeEventListener('compositionend', onCompositionEnd, options)
199
+ }
200
+ }, 'composer-send-key: modifier swap')
201
+
202
+ ctx.slots.inject('settings.general.item', () => ctx.slots.register({
203
+ name: 'settings.general.item',
204
+ id: 'composer-send-key-mode',
205
+ order: 21,
206
+ locale: NS,
207
+ inject: () => ({ hooks: { mode: store, saveError: errorStore }, setMode }),
208
+ }, SendKeyModeRow))
209
+ },
210
+ }
211
+ },
212
+ })
@@ -0,0 +1,5 @@
1
+ - insert:
2
+ - id: composer-send-key
3
+ name: 'dsh-composer-send-key'
4
+ config:
5
+ mode: default
package/icon.svg ADDED
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36">
2
+ <path d="M18 2.5 14.5 7.5h7z" fill="#247bbf"/>
3
+ <rect x="4" y="10" width="28" height="19" rx="4.5" fill="#eaf2fc" stroke="#247bbf" stroke-width="1.8"/>
4
+ <path d="M23 15v5a2 2 0 0 1-2 2H12.5" fill="none" stroke="#247bbf" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
5
+ <path d="M16 18.5 12.5 22 16 25.5" fill="none" stroke="#247bbf" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
6
+ </svg>
package/index.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Host half of composer-send-key.
3
+ *
4
+ * Declares one volatile preference, `mode`, persisted through the profile's
5
+ * settings document (the same mechanism the built-in Composer Enter row uses).
6
+ * The Client half reads and writes it through `ctx.configForms` under this
7
+ * entry's profile id, `composer-send-key`; volatile writes apply live without
8
+ * restarting the plugin.
9
+ */
10
+ import z from '@deepseek-ai/schemastery'
11
+
12
+ export const Config = z.object({
13
+ mode: z.union(['default', 'edit-friendly']).default('default').volatile(),
14
+ })
15
+
16
+ /** Register the settings persistence policy; run without Settings when absent. */
17
+ export function apply(ctx) {
18
+ ctx.inject(['settings'], (child) => {
19
+ child.effect(() => child.settings.configure({ auto: false }, ctx.fiber))
20
+ })
21
+ }
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Composer send key",
4
+ "description": "Switch the message box send shortcut between two modes. Default: Enter sends and Shift+Enter inserts a new line; Edit-friendly: Enter inserts a new line and Shift+Enter sends. Switch anytime under Settings → General → Send shortcut; the change applies immediately and persists in your profile. Ctrl/⌘+Enter keeps its built-in accelerated delivery, and the busy-state Composer Enter preference (queue/steer) is unaffected. In edit-friendly mode the two keys swap completely: with the suggestion menu open, Enter inserts a new line and Shift+Enter confirms the highlighted item. The keyboard shortcuts reference still lists the fixed Enter bindings, and the Send button keeps its current look. Disabling the plugin restores the default behavior. This plugin adapts the composer's internal keyboard handling, so re-check it after a DeepSeek Harness upgrade."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "发送快捷键",
4
+ "description": "在两种模式间切换消息框的发送快捷键。默认模式:Enter 发送,Shift+Enter 换行;编辑友好模式:Enter 换行,Shift+Enter 发送。可随时在 设置 → 通用 → 发送快捷键 中切换,即时生效并保存在你的配置档案中。Ctrl/⌘+Enter 保持内置的加速发送行为,运行中 Enter 的排队/插话偏好不受影响。编辑友好模式下两个键完全互换:候选/命令菜单打开时,Enter 换行,Shift+Enter 确认高亮项。快捷键参考页仍显示内置的固定 Enter 绑定,发送按钮外观不变。停用本插件即恢复默认行为。本插件依赖消息框的内部键盘处理,DeepSeek Harness 升级后请重新验证。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "dsh-composer-send-key",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Switch the DeepSeek Harness message box send shortcut between default (Enter sends) and edit-friendly (Shift+Enter sends) modes.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./index.js",
8
+ "./client": "./client.js",
9
+ "./locale/*.json": "./locale/*.json",
10
+ "./icon": "./icon.svg"
11
+ },
12
+ "files": ["index.js", "client.js", "cordis.patch.yml", "locale/*.json", "README.md", "icon.svg"],
13
+ "license": "MIT",
14
+ "author": "Licheung228",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/Licheung228/dsh-composer-send-key.git"
18
+ },
19
+ "homepage": "https://github.com/Licheung228/dsh-composer-send-key#readme",
20
+ "bugs": "https://github.com/Licheung228/dsh-composer-send-key/issues",
21
+ "keywords": [
22
+ "deepseek-harness",
23
+ "dsh",
24
+ "dsh-plugin",
25
+ "composer",
26
+ "keyboard-shortcuts",
27
+ "enter",
28
+ "shift-enter"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "dependencies": {
34
+ "@deepseek-ai/schemastery": "3.19.0"
35
+ },
36
+ "dsh": {
37
+ "bundle": { "patch": "./cordis.patch.yml" },
38
+ "client": {
39
+ "platform": "web",
40
+ "immediately": true,
41
+ "inject": [
42
+ "@deepseek-ai/dsh-client-ui-renderer",
43
+ "@deepseek-ai/dsh-client-ui-settings"
44
+ ]
45
+ }
46
+ }
47
+ }