dsh-gai-name 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 dsh-gai-name contributors
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
+ # dsh-gai-name
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
+ Choose the name DSH shows at the bottom of the sidebar.
4
+
5
+ The sidebar account row renders the name DeepSeek Platform returns for your
6
+ account, and Platform has no control for renaming it — the **Username** line in
7
+ `platform.deepseek.com` → account settings is read-only. This bundle keeps the
8
+ original account row (avatar, menu, actions, Account settings card) and only
9
+ replaces the name it displays.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npx -p @deepseek-ai/dsh dsh plugin --profile desktop add github:<owner>/dsh-gai-name
15
+ ```
16
+
17
+ Replace `desktop` with your profile name, and `<owner>` with the GitHub account
18
+ that hosts this repository. You can also install a local checkout from
19
+ **Plugins** → **Add plugin**.
20
+
21
+ Requires DSH `>=0.2.2-rc.5`; the bundle declares that in
22
+ `package.json` → `dsh.engines`, so older releases refuse to install it instead
23
+ of failing quietly.
24
+
25
+ ## Use
26
+
27
+ 1. Open **Settings** → **General**.
28
+ 2. Type a name in **Display name** and press **Save** (Enter saves too).
29
+ 3. Reload the page to re-read the account profile.
30
+
31
+ Leave the box empty and save to show the account nickname again. The value is
32
+ stored in your own DSH profile configuration (row `account-display-name`), never
33
+ in this repository, and applies to every session in that profile.
34
+
35
+ ## How it works
36
+
37
+ - **Host** (`index.js`) wraps `DeepSeekAccount#getProfile` and replaces the
38
+ projected `name` with the configured display name. The service's `id`,
39
+ `contact`, and `avatarUrl` are untouched, so account notifications, identity
40
+ checks, and the avatar keep working.
41
+ - **Client** (`client.js`) contributes one `settings.general.item` row that
42
+ writes the volatile `displayName` field through the shared configuration form.
43
+ - Unloading the plugin removes both halves: the wrap is deleted from the service
44
+ instance and the settings row unregisters.
45
+
46
+ ## Limits
47
+
48
+ - The display name reaches the sidebar on the next profile read, which the page
49
+ performs when it loads. A reload is the reliable way to see a change.
50
+ - DSH's own account menu and Account settings page read the same wrapped value,
51
+ so they show the display name too. DeepSeek Platform itself still shows the
52
+ original nickname.
53
+ - This overrides a display string inside DSH; it does not rename the account
54
+ anywhere else.
55
+ - The wrap sits on an internal service method rather than a documented slot, so
56
+ a future DSH release may change that surface. The version requirement above
57
+ is how this package stays honest about that.
58
+
59
+ ## License
60
+
61
+ [MIT](LICENSE)
package/client.js ADDED
@@ -0,0 +1,204 @@
1
+ /**
2
+ * Browser half of `dsh-gai-name`.
3
+ *
4
+ * Adds one row to Settings → General with a text box for the name shown at the
5
+ * bottom of the sidebar. The value lives in this bundle's Host configuration
6
+ * (row `account-display-name`), so it survives restarts and every session in
7
+ * this profile sees it; writing it goes through the shared configuration form,
8
+ * which validates the write on the Host.
9
+ */
10
+
11
+ window.__ModuleLoader__.load({
12
+ id: 'dsh-gai-name',
13
+ factory(require) {
14
+ const React = require('react')
15
+ const h = React.createElement
16
+
17
+ /** Locale namespace of this row's copy. */
18
+ const NS = 'settings.accountDisplayName'
19
+ /** Host configuration namespace; equals the row id in this bundle's patch. */
20
+ const NAMESPACE = 'account-display-name'
21
+
22
+ const rowStyle = {
23
+ display: 'flex',
24
+ alignItems: 'center',
25
+ justifyContent: 'space-between',
26
+ gap: '24px',
27
+ padding: '16px 0',
28
+ borderBottom: '0.5px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.24))',
29
+ }
30
+
31
+ const titleStyle = {
32
+ fontSize: '14px',
33
+ lineHeight: '20px',
34
+ color: 'var(--dsw-alias-label-primary, inherit)',
35
+ }
36
+
37
+ const descriptionStyle = {
38
+ marginTop: '4px',
39
+ color: 'var(--dsw-alias-label-secondary, #6b7280)',
40
+ fontSize: '12px',
41
+ lineHeight: '18px',
42
+ maxWidth: '38ch',
43
+ }
44
+
45
+ const controlStyle = {
46
+ display: 'flex',
47
+ alignItems: 'center',
48
+ gap: '8px',
49
+ flex: 'none',
50
+ }
51
+
52
+ const inputStyle = {
53
+ boxSizing: 'border-box',
54
+ width: '180px',
55
+ padding: '6px 8px',
56
+ borderRadius: '8px',
57
+ border: '1px solid var(--dsw-alias-border-l1, rgba(128, 128, 128, 0.32))',
58
+ background: 'var(--dsw-alias-bg-layer-1, transparent)',
59
+ color: 'var(--dsw-alias-label-primary, inherit)',
60
+ font: 'inherit',
61
+ fontSize: '13px',
62
+ lineHeight: '18px',
63
+ outline: 'none',
64
+ }
65
+
66
+ const buttonStyle = (disabled) => ({
67
+ flex: 'none',
68
+ padding: '6px 12px',
69
+ borderRadius: '8px',
70
+ border: '1px solid var(--dsw-alias-border-l1, rgba(128, 128, 128, 0.32))',
71
+ background: 'var(--dsw-alias-bg-layer-2, transparent)',
72
+ color: disabled
73
+ ? 'var(--dsw-alias-label-tertiary, #9ca3af)'
74
+ : 'var(--dsw-alias-label-primary, inherit)',
75
+ font: 'inherit',
76
+ fontSize: '13px',
77
+ lineHeight: '18px',
78
+ cursor: disabled ? 'default' : 'pointer',
79
+ opacity: disabled ? '0.6' : '1',
80
+ })
81
+
82
+ /**
83
+ * Render the General-settings row that edits the sidebar display name.
84
+ * @param props - accepted configuration snapshot, save action, and copy.
85
+ * @returns the preference row.
86
+ */
87
+ function AccountDisplayNameRow(props) {
88
+ const { t, save } = props
89
+ const snapshot = props.useForm(value => value)
90
+ const accepted = typeof snapshot.value?.displayName === 'string' ? snapshot.value.displayName : ''
91
+ const [draft, setDraft] = React.useState(accepted)
92
+ const [status, setStatus] = React.useState(null)
93
+ const seen = React.useRef(accepted)
94
+
95
+ React.useEffect(() => {
96
+ if (seen.current === accepted) return
97
+ seen.current = accepted
98
+ setDraft(accepted)
99
+ setStatus(null)
100
+ }, [accepted])
101
+
102
+ const busy = status === 'saving'
103
+ const disabled = busy || snapshot.status !== 'ready' || !snapshot.writable
104
+ const dirty = draft !== accepted
105
+
106
+ const commit = React.useCallback(async () => {
107
+ if (busy || !dirty) return
108
+ setStatus('saving')
109
+ let saved = false
110
+ try {
111
+ saved = await save(draft.trim())
112
+ } catch {
113
+ saved = false
114
+ }
115
+ setStatus(saved ? 'saved' : 'failed')
116
+ }, [busy, dirty, draft, save])
117
+
118
+ const hint = status === 'saved' ? t('saved') : status === 'failed' ? t('failed') : null
119
+
120
+ return h('div', { style: rowStyle },
121
+ h('div', null,
122
+ h('div', { style: titleStyle }, t('title')),
123
+ h('div', { style: descriptionStyle }, t('description')),
124
+ ),
125
+ h('div', { style: controlStyle },
126
+ h('input', {
127
+ type: 'text',
128
+ style: inputStyle,
129
+ value: draft,
130
+ placeholder: t('placeholder'),
131
+ maxLength: 64,
132
+ disabled: busy,
133
+ 'aria-label': t('title'),
134
+ onChange: (event) => { setDraft(event.target.value); setStatus(null) },
135
+ onKeyDown: (event) => {
136
+ if (event.key !== 'Enter') return
137
+ event.preventDefault()
138
+ void commit()
139
+ },
140
+ }),
141
+ h('button', {
142
+ type: 'button',
143
+ style: buttonStyle(disabled || !dirty),
144
+ disabled: disabled || !dirty,
145
+ onClick: () => { void commit() },
146
+ }, busy ? t('saving') : t('save')),
147
+ hint === null
148
+ ? null
149
+ : h('span', {
150
+ role: 'status',
151
+ 'aria-live': 'polite',
152
+ style: {
153
+ flex: 'none',
154
+ fontSize: '12px',
155
+ lineHeight: '18px',
156
+ color: status === 'failed'
157
+ ? 'var(--dsw-alias-label-secondary, #b91c1c)'
158
+ : 'var(--dsw-alias-label-tertiary, #6b7280)',
159
+ },
160
+ }, hint),
161
+ ),
162
+ )
163
+ }
164
+
165
+ return {
166
+ inject: ['slots', 'locale', 'configForms'],
167
+ apply(ctx) {
168
+ const form = ctx.configForms.get(NAMESPACE)
169
+ ctx.effect(() => ctx.locale.register(NS, {
170
+ en: {
171
+ title: 'Display name',
172
+ description: 'Shown at the bottom of the sidebar instead of the DeepSeek account nickname. Leave it empty to show the account nickname again.',
173
+ placeholder: 'Account nickname',
174
+ save: 'Save',
175
+ saving: 'Saving…',
176
+ saved: 'Saved',
177
+ failed: 'Not saved',
178
+ },
179
+ zh: {
180
+ title: '显示名称',
181
+ description: '左下角账户入口显示的名字,用来替代 DeepSeek 账号昵称;留空则恢复显示账号昵称。',
182
+ placeholder: '账号昵称',
183
+ save: '保存',
184
+ saving: '保存中…',
185
+ saved: '已保存',
186
+ failed: '未保存',
187
+ },
188
+ }))
189
+ const save = async (displayName) => {
190
+ try {
191
+ return await form.set('displayName', displayName)
192
+ } catch {
193
+ return false
194
+ }
195
+ }
196
+ const face = () => ({ hooks: { form }, save })
197
+ ctx.effect(() => ctx.configForms.whileServed([NAMESPACE], () =>
198
+ ctx.slots.inject('settings.general.item', () => ctx.slots.register({
199
+ name: 'settings.general.item', id: NAMESPACE, order: 95, locale: NS, inject: face,
200
+ }, AccountDisplayNameRow))))
201
+ },
202
+ }
203
+ },
204
+ })
@@ -0,0 +1,5 @@
1
+ - insert:
2
+ - id: account-display-name
3
+ name: dsh-gai-name
4
+ config:
5
+ displayName: ''
package/icon.svg ADDED
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36" fill="none">
2
+ <rect x="4.5" y="8.5" width="27" height="19" rx="4.5" stroke="#5F6B7A" stroke-width="2"/>
3
+ <circle cx="13" cy="18" r="3.1" stroke="#5F6B7A" stroke-width="2"/>
4
+ <path d="M19.5 16h7.5M19.5 21h5" stroke="#8A96A6" stroke-width="2" stroke-linecap="round"/>
5
+ </svg>
package/index.js ADDED
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Host half of `dsh-gai-name`.
3
+ *
4
+ * The sidebar account row (`@deepseek-ai/dsh-client-ui-settings-account`, slot
5
+ * `settings.launcher`) renders `profile.name`, which the Host projects from
6
+ * Platform's `id_profile.name` in `@deepseek-ai/dsh-deepseek-account`
7
+ * (`src/details.ts`, `projectProfile`). Platform offers no way to rename that
8
+ * account, so this bundle rewrites the projected name on its way out of
9
+ * `DeepseekAccount#getProfile`: the account menu itself, its avatar, its
10
+ * actions and the Account settings card stay the original components; they
11
+ * simply receive the configured name.
12
+ *
13
+ * The row's `Config` carries one volatile field. A volatile write updates in
14
+ * place (no plugin restart) and is re-read on every call, so a rename in
15
+ * Settings takes effect on the next profile read.
16
+ */
17
+
18
+ import Schema from '@deepseek-ai/schemastery'
19
+
20
+ /** Cordis diagnostic name. */
21
+ export const name = 'account-display-name'
22
+
23
+ /** The account service must be mounted before the projection can be wrapped. */
24
+ export const inject = ['deepseekAccount']
25
+
26
+ /** Longest display name accepted; longer input is truncated rather than rejected. */
27
+ const MAX_LENGTH = 64
28
+
29
+ /** Settings field edited from the Settings → General row of the client half. */
30
+ export const Config = Schema.object({
31
+ displayName: Schema.string()
32
+ .default('')
33
+ .description('Shown at the bottom of the sidebar instead of the DeepSeek account nickname. Leave it empty to keep the account nickname.')
34
+ .volatile(),
35
+ })
36
+
37
+ /**
38
+ * Read the current volatile value, tolerating a plain (non-volatile) value too.
39
+ * @param config - the row config handed to `apply`.
40
+ * @returns the trimmed name, or an empty string for "keep the account nickname".
41
+ */
42
+ function readDisplayName(config) {
43
+ const field = config === null || config === undefined ? undefined : config.displayName
44
+ const value = field !== null && typeof field === 'object' && typeof field.get === 'function'
45
+ ? field.get()
46
+ : field
47
+ if (typeof value !== 'string') return ''
48
+ return value.trim().slice(0, MAX_LENGTH)
49
+ }
50
+
51
+ /**
52
+ * Wrap the account profile projection with the configured display name.
53
+ * @param ctx - plugin context with the account service.
54
+ * @param config - validated row config.
55
+ */
56
+ export function apply(ctx, config) {
57
+ const service = ctx.deepseekAccount
58
+ const prototype = service === null || service === undefined ? undefined : Object.getPrototypeOf(service)
59
+ const original = prototype === null || prototype === undefined ? undefined : prototype.getProfile
60
+ if (typeof original !== 'function') {
61
+ ctx.logger?.warn?.('account-display-name: account profile reader is unavailable; the display name stays inactive')
62
+ return
63
+ }
64
+
65
+ /**
66
+ * Replace the projected name on a ready profile result.
67
+ * @param result - the value the account service would return.
68
+ * @returns the result with the configured name applied.
69
+ */
70
+ function rename(result) {
71
+ const displayName = readDisplayName(config)
72
+ if (displayName === '') return result
73
+ if (result === null || typeof result !== 'object' || result.status !== 'ready') return result
74
+ const profile = result.value
75
+ if (profile === null || typeof profile !== 'object') return result
76
+ if (profile.name === displayName) return result
77
+ return { ...result, value: { ...profile, name: displayName } }
78
+ }
79
+
80
+ const patched = async function patchedGetProfile(...args) {
81
+ return rename(await original.apply(this, args))
82
+ }
83
+
84
+ // An own property shadows the prototype method, so a reload never stacks
85
+ // wrappers on top of an earlier one and disposal restores the original.
86
+ Object.defineProperty(service, 'getProfile', {
87
+ value: patched, configurable: true, writable: true, enumerable: false,
88
+ })
89
+ ctx.effect(() => () => {
90
+ delete service.getProfile
91
+ }, 'account-display-name: profile projection')
92
+ }
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Account display name",
4
+ "description": "Type the name shown at the bottom of the sidebar instead of the DeepSeek account nickname; leave it empty to show the account nickname again."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "账户显示名称",
4
+ "description": "在设置里填写左下角账户入口显示的名字,用来替代 DeepSeek 账号昵称;留空则恢复显示账号昵称。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "dsh-gai-name",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "Choose the name shown at the bottom of the DSH sidebar instead of the DeepSeek account nickname.",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "dsh",
8
+ "dsh-plugin",
9
+ "deepseek-harness",
10
+ "sidebar",
11
+ "display-name"
12
+ ],
13
+ "type": "module",
14
+ "exports": {
15
+ ".": "./index.js",
16
+ "./client": "./client.js",
17
+ "./locale/*.json": "./locale/*.json",
18
+ "./icon": "./icon.svg"
19
+ },
20
+ "files": [
21
+ "index.js",
22
+ "client.js",
23
+ "cordis.patch.yml",
24
+ "locale/*.json",
25
+ "icon.svg",
26
+ "LICENSE",
27
+ "README.md"
28
+ ],
29
+ "dsh": {
30
+ "engines": {
31
+ "dsh": ">=0.2.2-rc.5"
32
+ },
33
+ "bundle": {
34
+ "patch": "./cordis.patch.yml"
35
+ },
36
+ "client": {
37
+ "platform": "web",
38
+ "immediately": true,
39
+ "inject": []
40
+ }
41
+ },
42
+ "peerDependencies": {
43
+ "@deepseek-ai/schemastery": ">=3.19.0"
44
+ }
6
45
  }