dsh-release-depot 1.0.0 → 1.1.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ ## 1.1.1
4
+
5
+ - Republish after the npm CDN cached a 404 for the 1.1.0 tarball during registry finalization. No functional changes; verified with a clean `pnpm add dsh-release-depot@1.1.1`.
6
+
7
+ ## 1.1.0
8
+
9
+ - Rename the product to 发布仓 / Release Depot (package: `dsh-release-depot`); migrate old `.dsh-ship-deck` credentials.
10
+ - Automatic npm token expiry detection through `/-/npm/v1/tokens`; expiry warning at 21 days; Bypass-2FA warning.
11
+ - Correct npm token page link to `https://www.npmjs.com/settings/~/tokens`.
12
+ - npm access-level management and maintainer add/remove (UI + AI tools).
13
+ - Fix GitHub pushes into a brand-new empty repository (bootstrap initial commit + default branch).
14
+ - Better npm error mapping (already-published, bypass-token limitations, stage-only, WebAuthn/TOTP).
15
+ - Hide panel scrollbars; four-sided rounded frame with hard shadow; follow the DSH theme automatically.
16
+ - Sidebar entry, `设置 → 发布仓`, and plugin detail "open workbench" entry.
17
+ - Product README, plugin details, and publish metadata for npm/GitHub.
18
+
19
+ ## 1.0.0
20
+
21
+ - Initial release: npm and GitHub accounts, publish wizard (npm / GitHub Packages / GitHub Release), dist-tags, deprecate, unpublish, owner/access, local history, and five AI tools.
package/README.md CHANGED
@@ -97,8 +97,8 @@ dsh plugin --profile desktop add link:<本目录绝对路径>
97
97
  ## 使用
98
98
 
99
99
  1. 打开「发布仓」→ **设置**:
100
- - **npm**:填 npm 用户名(用来生成正确的 Token 链接),打开
101
- `https://www.npmjs.com/settings/<用户名>/tokens` 创建 **Granular Access Token**;
100
+ - **npm**:打开
101
+ `https://www.npmjs.com/settings/~/tokens`(登录后 `~` 就是当前账号)创建 **Granular Access Token**;
102
102
  Permissions 选 **Read and write (publish and stage)**。
103
103
  如果账户使用 TOTP,建议**不要**勾 **Bypass two-factor authentication**(npm 会在 2027-01 撤销这类 Token),发布时在向导里填 6 位 TOTP。
104
104
  如果账户只能用 WebAuthn/passkey,本插件无法完成浏览器验证,请使用 npm CLI 或 trusted publishing。
package/client.js CHANGED
@@ -1897,14 +1897,6 @@ window.__ModuleLoader__.load({
1897
1897
  const lang = useLang()
1898
1898
  const [token, setToken] = React.useState('')
1899
1899
  const [registry, setRegistry] = React.useState(status?.registries?.npm ?? '')
1900
- const [npmUser, setNpmUser] = React.useState(() => {
1901
- if (typeof status?.npm?.username === 'string' && status.npm.username !== '') return status.npm.username
1902
- try {
1903
- return localStorage.getItem('sd.npmUser') ?? ''
1904
- } catch {
1905
- return ''
1906
- }
1907
- })
1908
1900
  const [busy, setBusy] = React.useState(false)
1909
1901
  const [verifying, setVerifying] = React.useState(false)
1910
1902
  const [expiryDraft, setExpiryDraft] = React.useState(status?.npm?.expiresAt ?? '')
@@ -1914,19 +1906,8 @@ window.__ModuleLoader__.load({
1914
1906
  if (typeof status?.npm?.expiresAt === 'string') setExpiryDraft(status.npm.expiresAt)
1915
1907
  }, [status?.npm?.expiresAt])
1916
1908
 
1917
- React.useEffect(() => {
1918
- if (typeof status?.npm?.username !== 'string' || status.npm.username === '') return
1919
- setNpmUser(status.npm.username)
1920
- try {
1921
- localStorage.setItem('sd.npmUser', status.npm.username)
1922
- } catch {
1923
- /* ignore */
1924
- }
1925
- }, [status?.npm?.username])
1926
-
1927
- const tokenPage = npmUser.trim() === ''
1928
- ? null
1929
- : `https://www.npmjs.com/settings/${encodeURIComponent(npmUser.trim())}/tokens`
1909
+ // npm's account-relative token page; `~` resolves to the signed-in user.
1910
+ const tokenPage = 'https://www.npmjs.com/settings/~/tokens'
1930
1911
 
1931
1912
  const connect = async () => {
1932
1913
  setBusy(true)
@@ -2001,7 +1982,7 @@ window.__ModuleLoader__.load({
2001
1982
  type: 'date',
2002
1983
  value: expiryDraft,
2003
1984
  'aria-label': t('Token 到期日', 'Token expiry date'),
2004
- className: 'sd-input-mini',
1985
+ className: 'sd-input-date',
2005
1986
  onChange: (event) => setExpiryDraft(event.target.value),
2006
1987
  }),
2007
1988
  h(Btn, { size: 'sm', variant: 'ghost', busy: savingExpiry, onClick: saveExpiry }, t('保存到期日', 'Save expiry'))),
@@ -2012,35 +1993,18 @@ window.__ModuleLoader__.load({
2012
1993
  h(Btn, { size: 'sm', variant: 'ghost', busy: verifying, onClick: verify }, t('验证', 'Verify')),
2013
1994
  h(Btn, { size: 'sm', variant: 'danger', onClick: disconnect }, t('断开', 'Disconnect'))))
2014
1995
  : h(React.Fragment, null,
2015
- h(Field, { label: t('npm 用户名', 'npm username'), optional: true, hint: t('只保存在本机,用于生成正确的 Token 页面链接。', 'Stored locally, used only to build the token page link.') },
2016
- h(TextInput, {
2017
- value: npmUser,
2018
- placeholder: 'your-npm-username',
2019
- autoComplete: 'username',
2020
- onChange: (event) => {
2021
- const value = event.target.value
2022
- setNpmUser(value)
2023
- try {
2024
- localStorage.setItem('sd.npmUser', value)
2025
- } catch {
2026
- /* ignore */
2027
- }
2028
- },
2029
- })),
2030
1996
  h(Field, { label: t('npm Access Token', 'npm access token'), hint: t('Permission 选 Read and write (publish and stage)。如账户用 TOTP,可不必勾 Bypass 2FA,在发布向导里填 6 位验证码;Bypass 2FA 的 Token 会在 2027-01 被 npm 撤销。', 'Choose Read and write (publish and stage). With TOTP you can leave Bypass 2FA off and enter the 6-digit code in the wizard; npm revokes Bypass-2FA tokens in January 2027.') },
2031
1997
  h(TextInput, {
2032
1998
  type: 'password', value: token, placeholder: 'npm_…', autoComplete: 'new-password',
2033
1999
  onChange: (event) => setToken(event.target.value),
2034
2000
  })),
2035
- h(Field, { label: t('Token 到期日', 'Token expiry'), optional: true, hint: t('npm 不再提供永久 Token(通常最多 90 天)。填这里用于到期提醒;不会自动续期。', 'npm no longer issues permanent tokens (usually 90 days max). Set it here for a reminder; renewal is not automatic.') },
2001
+ h(Field, { label: t('Token 到期日', 'Token expiry'), optional: true, hint: t('连接后会自动读取 npm 记录的到期日;这里可手动覆盖,仅用于提醒,不会自动续期。', 'Read automatically from npm after connecting; set it manually to override. Used for reminders only, renewal is not automatic.') },
2036
2002
  h(TextInput, { type: 'date', value: expiryDraft, onChange: (event) => setExpiryDraft(event.target.value) })),
2037
2003
  h(Field, { label: 'registry', optional: true, hint: t('留空使用 npmjs.com;可填私有 registry 地址。', 'Leave empty for npmjs.com, or use a private registry.') },
2038
2004
  h(TextInput, { value: registry, placeholder: 'https://registry.npmjs.org', onChange: (event) => setRegistry(event.target.value) })),
2039
2005
  h('div', { className: 'sd-inline-row' },
2040
2006
  h(Btn, { variant: 'primary', busy, onClick: connect }, t('验证并保存', 'Verify & save')),
2041
- tokenPage !== null
2042
- ? h('a', { className: 'sd-link', href: tokenPage, target: '_blank', rel: 'noopener noreferrer' }, t('打开 Token 页面', 'Open token page'))
2043
- : h('span', { className: 'sd-field-hint' }, t('填写用户名后生成 Token 直达链接', 'Enter your username to get the token link')),
2007
+ h('a', { className: 'sd-link', href: tokenPage, target: '_blank', rel: 'noopener noreferrer' }, t('打开 Token 页面', 'Open token page')),
2044
2008
  h('a', { className: 'sd-link', href: 'https://docs.npmjs.com/creating-and-viewing-access-tokens', target: '_blank', rel: 'noopener noreferrer' }, t('创建说明', 'Docs')))))
2045
2009
  }
2046
2010
 
@@ -2783,6 +2747,7 @@ window.__ModuleLoader__.load({
2783
2747
  .sd-field-hint { font-size: 11px; color: var(--sd-muted); line-height: 1.45; }
2784
2748
  .sd-input { width: 100%; border: 2.5px solid var(--sd-line); border-radius: 8px; background: var(--sd-panel); color: var(--sd-ink); padding: 7px 9px; font-family: inherit; font-size: 12.5px; outline: none; min-width: 0; }
2785
2749
  .sd-input-mini { width: 90px; min-width: 70px; }
2750
+ .sd-input-date { width: 132px; min-width: 120px; }
2786
2751
  .sd-input:focus { outline: 3px solid var(--sd-blue); outline-offset: 1px; }
2787
2752
  .sd-input::placeholder { color: var(--sd-muted); opacity: .7; }
2788
2753
  .sd-textarea { resize: vertical; min-height: 70px; font-family: ui-monospace, monospace; font-size: 11.5px; line-height: 1.5; }
package/lib/github.js CHANGED
@@ -197,7 +197,7 @@ export class GitHubClient {
197
197
  name,
198
198
  private: options.private === true,
199
199
  description,
200
- auto_init: false,
200
+ auto_init: options.autoInit === true,
201
201
  has_issues: true,
202
202
  has_wiki: false,
203
203
  }
@@ -358,6 +358,7 @@ export class GitHubClient {
358
358
  name: repo,
359
359
  private: options.private === true,
360
360
  description: options.description,
361
+ autoInit: true,
361
362
  })
362
363
  created = true
363
364
  defaultBranch = typeof options.branch === 'string' && options.branch.trim() !== ''
@@ -389,6 +390,33 @@ export class GitHubClient {
389
390
  if (!(error instanceof GitHubError) || error.status !== 404) throw error
390
391
  }
391
392
 
393
+ // The Git Data API refuses to create blobs in a brand-new empty repo.
394
+ // Bootstrap one initial README commit through the Contents API, then make
395
+ // sure the requested branch points at it.
396
+ if (headSha === null) {
397
+ const content = Buffer.from(`# ${repo}\n\nInitialized by Release Depot.\n`, 'utf8').toString('base64')
398
+ const init = await this.request(`/repos/${owner}/${repo}/contents/README.md`, {
399
+ method: 'PUT',
400
+ body: { message: 'Initial commit', content },
401
+ context: '初始化空仓库',
402
+ })
403
+ const sha = init.json?.commit?.sha
404
+ if (typeof sha !== 'string') {
405
+ throw new GitHubError('无法初始化空仓库(Contents API 没有返回 commit sha)', { code: 'EEMPTYREPO' })
406
+ }
407
+ headSha = sha
408
+ const branchRef = await this.request(`/repos/${owner}/${repo}/git/ref/heads/${encodeURIComponent(defaultBranch)}`, {
409
+ allow404: true,
410
+ })
411
+ if (branchRef.status !== 200) {
412
+ await this.request(`/repos/${owner}/${repo}/git/refs`, {
413
+ method: 'POST',
414
+ body: { ref: `refs/heads/${defaultBranch}`, sha },
415
+ context: '创建分支',
416
+ })
417
+ }
418
+ }
419
+
392
420
  const walk = await walkForGit(options.dir, {
393
421
  maxFiles: options.maxFiles,
394
422
  maxTotalBytes: options.maxTotalBytes,
@@ -463,6 +491,17 @@ export class GitHubClient {
463
491
  })
464
492
  }
465
493
  }
494
+ // A freshly created empty repository can have an unexpected initial
495
+ // default branch name; point it at the branch we just published.
496
+ try {
497
+ await this.request(`/repos/${owner}/${repo}`, {
498
+ method: 'PATCH',
499
+ body: { default_branch: defaultBranch },
500
+ context: '设置默认分支',
501
+ })
502
+ } catch {
503
+ /* default branch is cosmetic; the commit is already on the right branch */
504
+ }
466
505
 
467
506
  return {
468
507
  ok: true,
package/lib/registry.js CHANGED
@@ -115,15 +115,24 @@ function errorFromResponse(status, text, headers, context = '') {
115
115
  })
116
116
  }
117
117
  if (status === 403) {
118
+ if (/previously published|publish over/i.test(detail)) {
119
+ return new RegistryError(`${prefix}该版本已存在,不能覆盖发布(${detail})。`, {
120
+ code: 'EPUBLISHCONFLICT', status,
121
+ hint: 'npm 不允许覆盖已发布版本:请提升 version 后再发布。',
122
+ })
123
+ }
118
124
  const stageOnly = /stage[\s-]*only|staged publishing|stage permission/i.test(detail)
119
125
  const needs2fa = /two-factor authentication or granular access token with bypass|bypass 2fa/i.test(detail)
126
+ const bypassLimited = /bypass two-factor authentication may not perform this action|bypass2fa-deprecation/i.test(detail)
120
127
  return new RegistryError(`${prefix}registry 拒绝了请求(${detail || 'Forbidden'})。`, {
121
- code: needs2fa ? 'E2FAREQUIRED' : 'E403', status,
122
- hint: needs2fa
123
- ? 'npm 现在要求发布时进行 2FA,或使用勾选了 Bypass two-factor authentication 的 Granular Token;请到 npm Token 页面重新生成并替换。'
124
- : stageOnly
125
- ? '这个 Granular Token 只有 staging 权限,不能直接发布;请改用 Read and write (publish and stage),或在 npm 网页上提升该 Token 的权限。'
126
- : '确认当前账号是包的所有者/维护者,并且 Token 有 write 权限;部分包要求 OTP。',
128
+ code: bypassLimited ? 'EBYPASS2FA' : needs2fa ? 'E2FAREQUIRED' : 'E403', status,
129
+ hint: bypassLimited
130
+ ? '这个 Granular Token 勾选了 Bypass 2FA,npm 不允许它执行 unpublish / owner / access / token 管理等账号操作;请改用普通 Token,或在 npm 网页上操作。'
131
+ : needs2fa
132
+ ? 'npm 现在要求发布时进行 2FA,或使用勾选了 Bypass two-factor authentication 的 Granular Token;请到 npm Token 页面重新生成并替换。'
133
+ : stageOnly
134
+ ? '这个 Granular Token 只有 staging 权限,不能直接发布;请改用 Read and write (publish and stage),或在 npm 网页上提升该 Token 的权限。'
135
+ : '确认当前账号是包的所有者/维护者,并且 Token 有 write 权限;部分包要求 OTP。',
127
136
  })
128
137
  }
129
138
  if (status === 404) {
package/lib/service.js CHANGED
@@ -526,6 +526,18 @@ export class ShipDeck {
526
526
  }
527
527
  entries.sort((a, b) => (a.permission === b.permission ? a.name.localeCompare(b.name) : a.permission === 'write' ? -1 : 1))
528
528
  const selected = entries.slice(0, Math.min(Number(input.limit) || 60, 100))
529
+ if (input.details === false) {
530
+ return {
531
+ ok: true,
532
+ items: selected.map((entry) => ({ name: entry.name, permission: entry.permission })),
533
+ source,
534
+ warnings,
535
+ truncated: entries.length > selected.length,
536
+ total: entries.length,
537
+ at: nowIso(),
538
+ details: false,
539
+ }
540
+ }
529
541
  const items = new Array(selected.length)
530
542
  let cursor = 0
531
543
  const workers = Array.from({ length: Math.min(6, selected.length) }, async () => {
package/lib/store.js CHANGED
@@ -136,6 +136,9 @@ export class ShipDeckStore {
136
136
  const from = join(legacyDir, name)
137
137
  if (existsSync(from)) copyFileSync(from, join(this.dir, name))
138
138
  }
139
+ // Never leave a second copy of the token behind.
140
+ const legacyAuth = join(legacyDir, 'auth.json')
141
+ if (existsSync(join(this.dir, 'auth.json')) && existsSync(legacyAuth)) unlinkSync(legacyAuth)
139
142
  } catch {
140
143
  /* a failed migration leaves the old files usable */
141
144
  }
package/lib/tools.js CHANGED
@@ -209,7 +209,8 @@ export function createTools(service, agentCtx, config) {
209
209
  const status = service.status()
210
210
  const limit = Math.min(Math.max(Number(args?.limit ?? 10), 1), 50)
211
211
  const history = service.history(limit)
212
- const summary = `npm: ${status.npm.connected ? `@${status.npm.username ?? '?'}` : '未连接'};GitHub: ${status.github.connected ? `@${status.github.login ?? '?'}` : '未连接'};发布记录 ${status.counts.history} 条`
212
+ const expiry = status.npm.expiresInDays
213
+ const summary = `npm: ${status.npm.connected ? `@${status.npm.username ?? '?'}` : '未连接'};GitHub: ${status.github.connected ? `@${status.github.login ?? '?'}` : '未连接'};发布记录 ${status.counts.history} 条${expiry !== null && expiry !== undefined ? `;npm Token 剩余 ${expiry} 天` : ''}${status.npm.bypass2fa === true ? '(Bypass 2FA,2027-01 将被撤销)' : ''}`
213
214
  return ok({ status, history }, summary)
214
215
  } catch (error) {
215
216
  return fail(error)
@@ -256,7 +257,7 @@ export function createTools(service, agentCtx, config) {
256
257
  return ok(result, result.npm.connected ? `npm 账号 @${result.npm.username} ${result.invalidated === true ? '已失效' : '可用'}` : 'npm 未登录')
257
258
  }
258
259
  case 'list': {
259
- const result = await service.npmPackages({ limit: args?.limit, refresh: true })
260
+ const result = await service.npmPackages({ limit: args?.limit, refresh: true, details: false })
260
261
  const summary = `账号下 ${result.items.length} 个可管理的包${result.truncated ? '(已截断)' : ''}`
261
262
  return ok({ items: result.items, warnings: result.warnings, source: result.source }, summary)
262
263
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-release-depot",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "description": "Release Depot(发布仓):在 DeepSeek Harness 内登录 npm 与 GitHub,管理包、发布版本、创建 Release,并把同一套发布能力交给 AI 工具调用。",
@@ -20,7 +20,8 @@
20
20
  "docs",
21
21
  "icon.svg",
22
22
  "README.md",
23
- "LICENSE"
23
+ "LICENSE",
24
+ "CHANGELOG.md"
24
25
  ],
25
26
  "dsh": {
26
27
  "bundle": {