dsh-release-depot 1.1.1 → 1.1.3

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 CHANGED
@@ -1,21 +1,74 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.3
4
+
5
+ ### 修复
6
+
7
+ - npm publish 返回 `202 Accepted` 时,面板和 AI 工具明确显示“已受理,registry 同步中”,不再直接称为“发布完成”。
8
+ - GitHub Release 的自动安装段只在 npm 目标确实成功时出现,避免链接到不存在的包版本。
9
+ - 删除整个 npm 包现在在 `version: '*'` 和“仅剩一个版本”两种情况下都强制要求 `confirmName`,防止误删整包。
10
+ - 修复 AI 工具 `add-owner` / `remove-owner` 的变量遮蔽错误(之前两个动作都会抛 ReferenceError)。
11
+ - npm 访问级别统一为 `public` / `restricted`,与 npm `access set status` 协议一致;面板、工具、协议不再出现 private/restricted 混用。
12
+ - 代理 URL 中的用户名/密码在诊断信息中打码,不再进入面板或 AI 工具输出。
13
+ - 工具结果改为结构化 `data` 对象,去掉重复 JSON 编码;超长文本附带截断标记。
14
+ - npm Token 列表改为跟随分页,Token 数量超过一页时仍能匹配到期日。
15
+ - 修复 GitHub 仓库列表缓存忽略 `limit` 的问题;dist-tag/access/owner 操作后 npm 包列表缓存会失效。
16
+ - 发布预检在“仓库不存在且未勾选自动创建”时返回失败,不再让向导误判为可发布。
17
+ - 发布更新日志支持 `## [1.2.3]`、`## v1.2.3`、`## 1.2.3 — date` 等标题格式。
18
+ - 无效 dist-tag 直接报错,不再静默替换为 latest;`v1.2.3` 这类不规范 package version 在打包阶段拒绝。
19
+ - 删除 GitHub Release 现在需要 `force: true`;同时删除 tag 时必须提供 tag 名称。
20
+ - 主题与目录选择器改为注入服务,避免一次性读取导致深色主题或目录选择器失效。
21
+ - `npm_registry info` 支持按 `version` 查询指定版本;`github_publish release` 增加 `generateNotes`。
22
+ - README 增加版本更新日志入口。
23
+
24
+ ### 说明
25
+
26
+ - 补丁版本,发布协议与目标不变。
27
+
28
+ ## 1.1.2
29
+
30
+ ### 修复
31
+
32
+ - GitHub Release 自动文案不再包含本地目录、用户名或维护者信息,改为版本更新日志 + 安装命令。
33
+ - 面板底栏、HTTP User-Agent、服务默认版本统一到 `1.1.2`,不再出现版本号不一致。
34
+ - AI 工具返回结果会移除 `dir` / `storage` / `lastDir` 等本机路径,避免模型输出泄露机器路径。
35
+
36
+ ### 说明
37
+
38
+ - 这是补丁版本,不新增发布目标,不改变 npm / GitHub 协议行为。
39
+
3
40
  ## 1.1.1
4
41
 
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`.
42
+ ### 修复
43
+
44
+ - 重新发布 1.1.0:首次发布时 npm CDN 在产物就绪前缓存了 tarball 404,导致 `npm install dsh-release-depot@1.1.0` 短暂失败。
45
+ - 1.1.1 与 1.1.0 功能一致;已用 `pnpm add dsh-release-depot@1.1.1` 验证安装。
6
46
 
7
47
  ## 1.1.0
8
48
 
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.
49
+ ### 新增
50
+
51
+ - 产品更名为 **发布仓 / Release Depot**,包名 `dsh-release-depot`;旧 `.dsh-ship-deck` 凭据自动迁移。
52
+ - npm Token 到期日自动读取(`/-/npm/v1/tokens`),剩余 21 天提醒,并提示 Bypass 2FA Token 将在 2027-01 被撤销。
53
+ - npm 访问级别管理(public/private)与 maintainer 添加/移除,面板与 AI 工具均可操作。
54
+ - 发布目标新增/完善:npm、GitHub Packages、GitHub Release(可自动建仓、推送目录、附带 tarball)。
55
+ - 发布向导支持 dry run 预检、OTP、GitHub 仓库自动创建、Release 附件。
56
+
57
+ ### 优化
58
+
59
+ - GitHub 空仓库推送修复:自动初始化首个提交、创建 `main` 并设为默认分支。
60
+ - npm 错误分类:版本已存在、Bypass Token 账号操作限制、stage-only、WebAuthn/TOTP。
61
+ - 面板:自动跟随 DSH 日间/夜间主题、四边圆角与硬阴影、隐藏滚动条。
62
+ - 入口:左侧栏、设置 → 发布仓、插件详情页均可打开工作台。
63
+ - AI 工具 `npm_registry list` 改为快速列表,不再逐个拉取 packument。
18
64
 
19
65
  ## 1.0.0
20
66
 
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.
67
+ ### 首个版本
68
+
69
+ - 在 DeepSeek Harness 内连接 npm 与 GitHub 账号。
70
+ - 发布向导:npm / GitHub Packages / GitHub Release,4 步确认 + 强制预检。
71
+ - npm 包管理:dist-tags、废弃/取消废弃、删除单版本/整包。
72
+ - GitHub 仓库/Release:列表、创建仓库、通过 Git Data API 推送目录、创建/删除 Release。
73
+ - 本地发布记录(最多 200 条)。
74
+ - 5 个 AI 工具:`release_status`、`npm_registry`、`npm_publish`、`github_publish`、`publish_package`。
package/README.md CHANGED
@@ -220,6 +220,12 @@ dsh-release-depot/
220
220
 
221
221
  ---
222
222
 
223
+ ## 更新日志
224
+
225
+ 每个版本的变更见 [CHANGELOG.md](CHANGELOG.md)。
226
+
227
+ ---
228
+
223
229
  ## English
224
230
 
225
231
  **Release Depot** connects npm and GitHub inside DeepSeek Harness and gives both the panel and the agent one shared publishing service: publish to npm / GitHub Packages, push a directory and create a GitHub Release with the tarball attached, manage dist-tags, access, maintainers and versions, and review a local publish log.
package/client.js CHANGED
@@ -520,7 +520,7 @@ window.__ModuleLoader__.load({
520
520
  h('div', null,
521
521
  h('strong', null, t('仅本机凭据', 'Local credentials only')),
522
522
  h('span', null, t('令牌只保存在 DSH home。', 'Tokens stay in your DSH home.')))),
523
- h('div', { className: 'sd-side-foot' }, h('span', null, `v${status?.version ?? '1.0.0'}`), h('span', null, t('本地运行', 'local runtime')))),
523
+ h('div', { className: 'sd-side-foot' }, h('span', null, `v${status?.version ?? '1.1.3'}`), h('span', null, t('本地运行', 'local runtime')))),
524
524
  h('main', { className: 'sd-main' },
525
525
  h('header', { className: 'sd-top' },
526
526
  h('div', { className: 'sd-crumb' },
@@ -531,9 +531,9 @@ window.__ModuleLoader__.load({
531
531
  h('span', { className: 'sd-pill ' + (status?.npm?.connected || status?.github?.connected ? 'sd-pill-ok' : 'sd-pill-warn') },
532
532
  h('span', { className: 'sd-dot' }),
533
533
  status?.npm?.connected && status?.github?.connected
534
- ? t('实时数据 · 双账号就绪', 'Live · both accounts ready')
534
+ ? t('双账号已连接', 'Both accounts connected')
535
535
  : status?.npm?.connected || status?.github?.connected
536
- ? t('实时数据 · 单账号', 'Live · one account')
536
+ ? t('单账号已连接', 'One account connected')
537
537
  : t('账号未连接', 'No account yet')))),
538
538
  h('div', { className: 'sd-hazard', 'aria-hidden': 'true' }),
539
539
  h('div', { className: 'sd-content' },
@@ -1284,7 +1284,7 @@ window.__ModuleLoader__.load({
1284
1284
  onChange: (event) => setAccessForm({ ...accessForm, access: event.target.value }),
1285
1285
  },
1286
1286
  h('option', { value: 'public' }, 'public'),
1287
- h('option', { value: 'private' }, t('private(仅 scoped 包)', 'private (scoped only)'))),
1287
+ h('option', { value: 'restricted' }, t('private(仅 scoped 包)', 'private (scoped only)'))),
1288
1288
  h(TextInput, { placeholder: 'OTP', 'aria-label': t('一次性验证码', 'one-time code'), value: accessForm.otp, maxLength: 6, className: 'sd-input-mini', onChange: (event) => setAccessForm({ ...accessForm, otp: event.target.value }) }),
1289
1289
  h(Btn, { size: 'sm', variant: 'primary', busy: accessBusy, onClick: saveAccess }, t('更新', 'Update'))),
1290
1290
  h('div', { className: 'sd-field-hint' }, t('只有 scoped 包(@scope/name)可以设为 private;私有包可能需要付费账户。', 'Only scoped packages can be private; private packages may require a paid account.'))),
@@ -1644,7 +1644,7 @@ window.__ModuleLoader__.load({
1644
1644
  danger: true,
1645
1645
  confirmLabel: t('删除', 'Delete'),
1646
1646
  onConfirm: async () => {
1647
- await call('github.delete-release', { owner: repo.owner, repo: repo.name, releaseId: release.id })
1647
+ await call('github.delete-release', { owner: repo.owner, repo: repo.name, releaseId: release.id, force: true })
1648
1648
  toast(t('Release 已删除(tag 仍保留)', 'Release deleted (tag kept)'), 'ok')
1649
1649
  await load()
1650
1650
  },
@@ -1665,7 +1665,7 @@ window.__ModuleLoader__.load({
1665
1665
  form.open
1666
1666
  ? h('div', { className: 'sd-inline-form sd-inline-card' },
1667
1667
  h('div', { className: 'sd-field-grid' },
1668
- h(Field, { label: 'Tag' }, h(TextInput, { value: form.tag, placeholder: 'v1.0.0', onChange: (event) => setForm({ ...form, tag: event.target.value }) })),
1668
+ h(Field, { label: 'Tag' }, h(TextInput, { value: form.tag, placeholder: 'v1.1.3', onChange: (event) => setForm({ ...form, tag: event.target.value }) })),
1669
1669
  h(Field, { label: t('标题', 'Title'), optional: true }, h(TextInput, { value: form.name, onChange: (event) => setForm({ ...form, name: event.target.value }) }))),
1670
1670
  h(Field, { label: t('说明', 'Notes'), optional: true },
1671
1671
  h('textarea', { className: 'sd-input sd-textarea', rows: 3, value: form.body, onChange: (event) => setForm({ ...form, body: event.target.value }) })),
@@ -2364,7 +2364,10 @@ window.__ModuleLoader__.load({
2364
2364
  setResult(value)
2365
2365
  setStep(4)
2366
2366
  refreshStatus()
2367
- toast(value.ok ? t('发布完成', 'Publish complete') : t('部分目标失败,请查看结果', 'Some targets failed; see results'), value.ok ? 'ok' : 'error')
2367
+ const pending = Array.isArray(value.record?.targets) && value.record.targets.some((target) => target.pending === true)
2368
+ toast(value.ok
2369
+ ? pending ? t('npm 已受理,registry 正在同步', 'npm accepted; registry is syncing') : t('发布完成', 'Publish complete')
2370
+ : t('部分目标失败,请查看结果', 'Some targets failed; see results'), value.ok ? 'ok' : 'error')
2368
2371
  } catch (error) {
2369
2372
  fail(error)
2370
2373
  } finally {
@@ -2529,13 +2532,18 @@ window.__ModuleLoader__.load({
2529
2532
  h('div', { className: 'sd-result-hero' + (result.ok ? ' is-ok' : ' is-fail') },
2530
2533
  h('div', { className: 'sd-result-hero-icon' }, result.ok ? h(Icons.check, null) : h(Icons.warn, null)),
2531
2534
  h('div', null,
2532
- h('div', { className: 'sd-result-hero-title' }, result.ok ? t('发布完成', 'Published') : t('部分目标失败', 'Partly failed')),
2535
+ h('div', { className: 'sd-result-hero-title' }, result.ok
2536
+ ? (Array.isArray(result.record.targets) && result.record.targets.some((target) => target.pending === true)
2537
+ ? t('已受理 · registry 同步中', 'Accepted · registry syncing')
2538
+ : t('发布完成', 'Published'))
2539
+ : t('部分目标失败', 'Partly failed')),
2533
2540
  h('div', { className: 'sd-result-hero-sub' }, `${result.record.package}@${result.record.version} · ${result.record.dryRun ? 'dry run' : formatTime(result.record.at, lang)}`))),
2534
2541
  h('div', { className: 'sd-purposes' },
2535
2542
  result.record.targets.map((target) => h('div', { key: target.target, className: 'sd-purpose' + (target.ok ? ' is-ok' : ' is-fail') },
2536
2543
  h('div', { className: 'sd-purpose-head' },
2537
2544
  h('strong', null, target.target),
2538
- h(Chip, { tone: target.ok ? 'ok' : 'danger' }, target.ok ? 'ok' : 'fail')),
2545
+ h(Chip, { tone: target.ok ? 'ok' : 'danger' }, target.ok ? 'ok' : 'fail'),
2546
+ target.pending === true ? h(Chip, { tone: 'warn' }, t('同步中', 'syncing')) : null),
2539
2547
  h('div', { className: 'sd-record-links' },
2540
2548
  target.url ? h('a', { className: 'sd-link', href: target.url, target: '_blank', rel: 'noopener noreferrer' }, 'npm package') : null,
2541
2549
  target.release?.htmlUrl ? h('a', { className: 'sd-link', href: target.release.htmlUrl, target: '_blank', rel: 'noopener noreferrer' }, `Release ${target.release.tag}`) : null,
@@ -3054,15 +3062,20 @@ window.__ModuleLoader__.load({
3054
3062
  apply(ctx) {
3055
3063
  const locale = ctx.get?.('locale')
3056
3064
  if (locale !== null && locale !== undefined) localeService = locale
3057
- hostServices.uiWorkspace = ctx.get?.('uiWorkspace')
3065
+ ctx.inject(['uiWorkspace'], (scoped) => {
3066
+ hostServices.uiWorkspace = scoped.uiWorkspace
3067
+ return () => {
3068
+ if (hostServices.uiWorkspace === scoped.uiWorkspace) hostServices.uiWorkspace = undefined
3069
+ }
3070
+ })
3058
3071
  ctx.inject(['layout'], (scoped) => {
3059
3072
  hostServices.layout = scoped.layout
3060
3073
  return () => {
3061
3074
  if (hostServices.layout === scoped.layout) hostServices.layout = undefined
3062
3075
  }
3063
3076
  })
3064
- const theme = ctx.get?.('theme')
3065
- if (theme !== undefined && theme !== null) {
3077
+ ctx.inject(['theme'], (scoped) => {
3078
+ const theme = scoped.theme
3066
3079
  const readTheme = () => {
3067
3080
  try {
3068
3081
  setThemeScheme(theme.getTheme()?.active?.colorScheme)
@@ -3071,8 +3084,9 @@ window.__ModuleLoader__.load({
3071
3084
  }
3072
3085
  }
3073
3086
  readTheme()
3074
- ctx.effect(() => ctx.on('theme/change', readTheme), `${NS}: theme`)
3075
- }
3087
+ const off = scoped.on('theme/change', readTheme)
3088
+ return () => off()
3089
+ })
3076
3090
  ctx.effect(() => {
3077
3091
  const tag = document.createElement('style')
3078
3092
  tag.setAttribute('data-plugin', NS)
package/index.js CHANGED
@@ -13,7 +13,7 @@ import { createTools, SHIP_DECK_PROMPT } from './lib/tools.js'
13
13
 
14
14
  export const name = 'dsh-release-depot'
15
15
 
16
- const VERSION = '1.0.0'
16
+ const VERSION = '1.1.3'
17
17
  const MAX_BODY_BYTES = 1024 * 1024
18
18
 
19
19
  function normalizeConfig(raw) {
package/lib/github.js CHANGED
@@ -12,7 +12,7 @@ import { parseGitHubRepo } from './semver.js'
12
12
 
13
13
  const DEVICE_CODE_URL = 'https://github.com/login/device/code'
14
14
  const ACCESS_TOKEN_URL = 'https://github.com/login/oauth/access_token'
15
- const USER_AGENT = 'dsh-release-depot/1.0.0'
15
+ const USER_AGENT = 'dsh-release-depot/1.1.3'
16
16
 
17
17
  export class GitHubError extends Error {
18
18
  constructor(message, options = {}) {
package/lib/net.js CHANGED
@@ -184,6 +184,20 @@ $sb.ToString()
184
184
  return undefined
185
185
  }
186
186
 
187
+ function redactProxyUrl(value) {
188
+ if (typeof value !== 'string' || value === '') return null
189
+ try {
190
+ const url = new URL(value)
191
+ if (url.username !== '' || url.password !== '') {
192
+ url.username = ''
193
+ url.password = ''
194
+ }
195
+ return url.href
196
+ } catch {
197
+ return value.replace(/\/\/[^/@]*@/, '//')
198
+ }
199
+ }
200
+
187
201
  export class Network {
188
202
  /**
189
203
  * @param {object} options
@@ -292,8 +306,8 @@ export class Network {
292
306
  const proxy = await resolveProxy('registry.npmjs.org', this.config)
293
307
  return {
294
308
  mode: this.config.proxy,
295
- proxy: proxy ?? null,
296
- envProxy: env.https ?? env.http ?? env.all ?? null,
309
+ proxy: redactProxyUrl(proxy),
310
+ envProxy: redactProxyUrl(env.https ?? env.http ?? env.all ?? null),
297
311
  noProxy: parseNoProxy(this.config.noProxy),
298
312
  undici: (await loadUndici()) !== null,
299
313
  systemCa: this.caCache !== null && this.caCache !== undefined,
package/lib/registry.js CHANGED
@@ -29,7 +29,7 @@ import {
29
29
 
30
30
  export const NPM_REGISTRY = 'https://registry.npmjs.org'
31
31
  export const GITHUB_REGISTRY = 'https://npm.pkg.github.com'
32
- const USER_AGENT = 'dsh-release-depot/1.0.0 (npm registry client)'
32
+ const USER_AGENT = 'dsh-release-depot/1.1.3 (npm registry client)'
33
33
 
34
34
  export class RegistryError extends Error {
35
35
  constructor(message, options = {}) {
@@ -371,9 +371,16 @@ export class NpmRegistry {
371
371
  })
372
372
  }
373
373
 
374
- const tag = typeof options.tag === 'string' && /^[A-Za-z][A-Za-z0-9._-]{0,31}$/.test(options.tag)
375
- ? options.tag
376
- : 'latest'
374
+ let tag = 'latest'
375
+ if (options.tag !== undefined && options.tag !== null && String(options.tag).trim() !== '') {
376
+ tag = String(options.tag).trim()
377
+ if (!/^[A-Za-z][A-Za-z0-9._-]{0,31}$/.test(tag)) {
378
+ throw new RegistryError(`不是合法的 dist-tag:${tag}`, {
379
+ code: 'ETAGINVALID',
380
+ hint: 'tag 必须以字母开头,只含字母、数字、点、下划线或连字符,最长 32 位。',
381
+ })
382
+ }
383
+ }
377
384
  const tarballName = pack.tarballName
378
385
  const tarballUrl = joinPath(this.registry, `${name}/-/${tarballName}`)
379
386
  const manifest = { ...pack.publishedManifest }
@@ -414,6 +421,7 @@ export class NpmRegistry {
414
421
  return {
415
422
  ok: true,
416
423
  status,
424
+ pending: status === 202,
417
425
  registry: this.registry,
418
426
  name,
419
427
  version,
@@ -462,8 +470,8 @@ export class NpmRegistry {
462
470
  /** Change package visibility (npm access set status). */
463
471
  async setAccess(name, access) {
464
472
  if (!isValidPackageName(name)) throw new RegistryError(`不是合法的包名:${name}`, { code: 'ENAME' })
465
- const value = access === 'private' || access === 'restricted' ? 'private' : 'public'
466
- if (value === 'private' && splitPackageName(name).scope === null) {
473
+ const value = access === 'private' || access === 'restricted' ? 'restricted' : 'public'
474
+ if (value === 'restricted' && splitPackageName(name).scope === null) {
467
475
  throw new RegistryError('只有 scoped 包可以设为 private', { code: 'EUNSCOPED' })
468
476
  }
469
477
  await this.request(`/-/package/${escapedPackageName(name)}/access`, {
@@ -476,11 +484,17 @@ export class NpmRegistry {
476
484
 
477
485
  /** The account's token metadata; token values stay masked. */
478
486
  async tokenInfo() {
479
- const { payload } = await this.request('/-/npm/v1/tokens', {
480
- context: '读取 npm Token 信息',
481
- timeoutMs: 20000,
482
- })
483
- const objects = Array.isArray(payload?.objects) ? payload.objects : []
487
+ const objects = []
488
+ let path = '/-/npm/v1/tokens'
489
+ for (let page = 0; page < 20 && path !== null; page += 1) {
490
+ const { payload } = await this.request(path, {
491
+ context: '读取 npm Token 信息',
492
+ timeoutMs: 20000,
493
+ })
494
+ if (Array.isArray(payload?.objects)) objects.push(...payload.objects)
495
+ const next = payload?.urls?.next
496
+ path = typeof next === 'string' && next !== '' ? next : null
497
+ }
484
498
  return objects.map((entry) => ({
485
499
  name: typeof entry?.name === 'string' ? entry.name : '',
486
500
  token: typeof entry?.token === 'string' ? entry.token : '',
@@ -601,7 +615,7 @@ export class NpmRegistry {
601
615
  * a whole-package removal deletes `/<pkg>/-rev/<rev>`, a single-version
602
616
  * removal rewrites the packument then deletes the tarball document.
603
617
  */
604
- async unpublish(name, version) {
618
+ async unpublish(name, version, options = {}) {
605
619
  if (!isValidPackageName(name)) throw new RegistryError(`不是合法的包名:${name}`, { code: 'ENAME' })
606
620
  let doc
607
621
  try {
@@ -617,6 +631,12 @@ export class NpmRegistry {
617
631
  throw new RegistryError(`不是合法的版本:${target}`, { code: 'EVERSION' })
618
632
  }
619
633
  if (target === '' || target === '*' || allVersions.length <= 1) {
634
+ if (options.confirmWhole !== true) {
635
+ throw new RegistryError('删除整个包需要 confirmName 与包名完全一致', {
636
+ code: 'EWHOLECONFIRM',
637
+ hint: 'npm 会把没有版本或仅剩一个版本的删除视为整包删除;请显式确认包名。',
638
+ })
639
+ }
620
640
  const rev = doc._rev
621
641
  if (typeof rev !== 'string' || rev === '') {
622
642
  throw new RegistryError('registry 没有返回 _rev,无法删除整个包', { code: 'EREV' })
package/lib/semver.js CHANGED
@@ -28,8 +28,10 @@ export function parseVersion(input) {
28
28
  }
29
29
  }
30
30
 
31
- /** True when the string is a plain, complete SemVer version. */
31
+ /** True when the string is a plain, complete SemVer version (no v/=/space). */
32
32
  export function isValidVersion(input) {
33
+ if (typeof input !== 'string' || input.trim() !== input) return false
34
+ if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.test(input)) return false
33
35
  return parseVersion(input) !== null
34
36
  }
35
37
 
package/lib/service.js CHANGED
@@ -8,6 +8,7 @@
8
8
  * in any returned value.
9
9
  */
10
10
  import { randomBytes } from 'node:crypto'
11
+ import { readFile } from 'node:fs/promises'
11
12
  import { join } from 'node:path'
12
13
  import { GitHubClient, GitHubError, repoNameFromPackage } from './github.js'
13
14
  import { PackError, packProject, readAssetFile } from './pack.js'
@@ -27,7 +28,7 @@ import { ShipDeckStore } from './store.js'
27
28
 
28
29
  const TARGETS = ['npm', 'github-packages', 'github-release']
29
30
  const CACHE_TTL_MS = 120000
30
- const USER_AGENT = 'dsh-release-depot/1.0.0'
31
+ const USER_AGENT = 'dsh-release-depot/1.1.3'
31
32
 
32
33
  export class ShipDeckError extends Error {
33
34
  constructor(message, options = {}) {
@@ -131,6 +132,45 @@ function releaseAssetName(pack) {
131
132
  return base.length <= 200 ? base : `${base.slice(0, 196)}.tgz`
132
133
  }
133
134
 
135
+ /** Read the changelog section for one version, without package boilerplate. */
136
+ async function readChangelogSection(dir, version) {
137
+ try {
138
+ const text = await readFile(join(dir, 'CHANGELOG.md'), 'utf8')
139
+ const lines = text.replace(/^\uFEFF/, '').split(/\r?\n/)
140
+ const escaped = version.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
141
+ const heading = new RegExp(`^##\\s+\\[?v?${escaped}\\]?(?:\\s|$)`, 'i')
142
+ const start = lines.findIndex((line) => heading.test(line.trim()))
143
+ if (start === -1) return ''
144
+ const collected = []
145
+ for (let index = start + 1; index < lines.length; index += 1) {
146
+ if (/^##\s+/.test(lines[index])) break
147
+ collected.push(lines[index])
148
+ }
149
+ return collected.join('\n').trim()
150
+ } catch {
151
+ return ''
152
+ }
153
+ }
154
+
155
+ /** User-facing release notes: version changelog + install, no local paths. */
156
+ function defaultReleaseBody(pack, targets, changelog, npmAvailable = false) {
157
+ const lines = []
158
+ const notes = typeof changelog === 'string' ? changelog.trim() : ''
159
+ const description = typeof pack.description === 'string' ? pack.description.trim() : ''
160
+ if (notes !== '') {
161
+ lines.push("### 更新内容 / What's changed", '', notes)
162
+ } else if (description !== '') {
163
+ lines.push(description)
164
+ }
165
+ if (npmAvailable) {
166
+ lines.push('', '### Install / 安装', '', '```sh', `npm install ${pack.name}@${pack.version}`, '```')
167
+ if (Array.isArray(targets) && targets.includes('npm')) {
168
+ lines.push('', `- npm: https://www.npmjs.com/package/${pack.name}/v/${pack.version}`)
169
+ }
170
+ }
171
+ return lines.join('\n')
172
+ }
173
+
134
174
  /** Match the stored secret against npm's masked token list (`npm_abcd...wxyz`). */
135
175
  function tokenMatches(fullToken, entry) {
136
176
  const masked = typeof entry?.token === 'string' ? entry.token : ''
@@ -151,7 +191,7 @@ function tokenExpiryDate(entry) {
151
191
 
152
192
  export class ShipDeck {
153
193
  constructor(options) {
154
- this.version = options.version ?? '1.0.0'
194
+ this.version = options.version ?? '1.1.3'
155
195
  this.network = options.network
156
196
  this.store = options.store ?? new ShipDeckStore({ authFile: options.config?.authFile })
157
197
  this.config = options.config ?? {}
@@ -589,6 +629,16 @@ export class ShipDeck {
589
629
  if (!isValidPackageName(name)) throw new ShipDeckError(`不是合法的包名:${name}`, { code: 'ENAME' })
590
630
  const client = this.npmClientOptional(assertOtp(input?.otp))
591
631
  const info = await client.packageInfo(name)
632
+ const requestedVersion = typeof input?.version === 'string' && input.version.trim() !== ''
633
+ ? input.version.trim()
634
+ : null
635
+ if (requestedVersion !== null) {
636
+ const selected = info.versions.find((version) => version.version === requestedVersion)
637
+ if (selected === undefined) {
638
+ throw new ShipDeckError(`${name} 不存在版本 ${requestedVersion}`, { code: 'ENOVERSION' })
639
+ }
640
+ return { ok: true, ...info, requestedVersion, requested: selected }
641
+ }
592
642
  return { ok: true, ...info }
593
643
  }
594
644
 
@@ -620,6 +670,7 @@ export class ShipDeck {
620
670
  const version = String(input?.version ?? '')
621
671
  const result = await client.setDistTag(name, tag, version)
622
672
  this.invalidate('npm:')
673
+ this.invalidate('packages')
623
674
  return { ok: true, ...result }
624
675
  }
625
676
 
@@ -627,6 +678,7 @@ export class ShipDeck {
627
678
  const client = this.npmClient(assertOtp(input?.otp))
628
679
  const result = await client.deleteDistTag(String(input?.name ?? ''), String(input?.tag ?? ''))
629
680
  this.invalidate('npm:')
681
+ this.invalidate('packages')
630
682
  return { ok: true, ...result }
631
683
  }
632
684
 
@@ -671,15 +723,16 @@ export class ShipDeck {
671
723
 
672
724
  async npmUnpublish(input) {
673
725
  const name = String(input?.name ?? '')
674
- const version = input?.version === undefined || input?.version === null ? '' : String(input.version)
726
+ const version = input?.version === undefined || input?.version === null ? '' : String(input.version).trim()
675
727
  if (input?.force !== true) {
676
728
  throw new ShipDeckError('删除包或版本属于不可逆操作,需要显式传入 force: true 确认。', { code: 'ECONFIRM' })
677
729
  }
678
- if (version === '' && input?.confirmName !== name) {
730
+ const wholeRequested = version === '' || version === '*'
731
+ if (wholeRequested && input?.confirmName !== name) {
679
732
  throw new ShipDeckError('删除整个包需要 confirmName 与包名完全一致,以防误操作。', { code: 'ECONFIRM' })
680
733
  }
681
734
  const client = this.npmClient(assertOtp(input?.otp))
682
- const result = await client.unpublish(name, version)
735
+ const result = await client.unpublish(name, version, { confirmWhole: input?.confirmName === name })
683
736
  this.invalidate('npm:')
684
737
  this.invalidate('packages')
685
738
  return { ok: true, ...result }
@@ -791,13 +844,15 @@ export class ShipDeck {
791
844
 
792
845
  async githubRepos(input = {}) {
793
846
  const auth = this.requireGitHub()
847
+ const limit = Math.min(Math.max(Number(input.limit) || 50, 1), 100)
848
+ const cacheKey = `repos:${limit}`
794
849
  if (input.refresh !== true) {
795
- const cached = this.cacheGet('repos')
850
+ const cached = this.cacheGet(cacheKey)
796
851
  if (cached !== null) return { ok: true, items: cached, cached: true }
797
852
  }
798
853
  const client = this.githubClient(auth)
799
- const items = await client.listRepos({ perPage: Math.min(Number(input.limit) || 50, 100) })
800
- this.cacheSet('repos', items)
854
+ const items = await client.listRepos({ perPage: limit })
855
+ this.cacheSet(cacheKey, items)
801
856
  return { ok: true, items, cached: false }
802
857
  }
803
858
 
@@ -873,6 +928,12 @@ export class ShipDeck {
873
928
  }
874
929
 
875
930
  async githubDeleteRelease(input) {
931
+ if (input?.force !== true) {
932
+ throw new ShipDeckError('删除 Release 属于不可逆操作,需要显式传入 force: true 确认。', { code: 'ECONFIRM' })
933
+ }
934
+ if (input?.deleteTag === true && (typeof input?.tag !== 'string' || input.tag.trim() === '')) {
935
+ throw new ShipDeckError('同时删除 tag 时必须提供 tag 名称。', { code: 'EINVALIDTAG' })
936
+ }
876
937
  const client = this.githubClient()
877
938
  const owner = String(input?.owner ?? '').trim()
878
939
  const repo = String(input?.repo ?? '').trim()
@@ -1089,18 +1150,18 @@ export class ShipDeck {
1089
1150
  const releaseName = typeof githubOptions.releaseName === 'string' && githubOptions.releaseName.trim() !== ''
1090
1151
  ? githubOptions.releaseName.trim()
1091
1152
  : `${pack.name} v${pack.version}`
1153
+ const npmResult = results.find((item) => item.target === 'npm')
1154
+ const npmAvailable = targets.includes('npm') && npmResult?.ok === true
1092
1155
  const releaseBody = typeof githubOptions.body === 'string' && githubOptions.body.trim() !== ''
1093
1156
  ? githubOptions.body
1094
- : [
1095
- pack.description === '' ? '' : `${pack.description}\n`,
1096
- `## Install\n\n\`\`\`sh\nnpm i ${pack.name}@${pack.version}\n\`\`\`\n`,
1097
- `Published from \`${pack.dir}\`.`,
1098
- ].filter((part) => part !== '').join('\n')
1157
+ : defaultReleaseBody(pack, targets, await readChangelogSection(pack.dir, pack.version), npmAvailable)
1099
1158
 
1100
1159
  if (dryRun) {
1101
1160
  const existing = await client.getRepo(owner, repo)
1102
1161
  results.push({
1103
- target, ok: true, dryRun: true,
1162
+ target,
1163
+ ok: existing !== null || githubOptions.create === true,
1164
+ dryRun: true,
1104
1165
  owner, repo, branch: branch ?? existing?.default_branch ?? 'main',
1105
1166
  releaseTag, create: existing === null,
1106
1167
  repoExists: existing !== null,
package/lib/tools.js CHANGED
@@ -37,14 +37,15 @@ const ACTIONS = [
37
37
  function textResult(value, limit = 12000) {
38
38
  const summary = typeof value?.summary === 'string' ? value.summary : ''
39
39
  const data = value?.data === undefined ? '' : JSON.stringify(value.data, null, 2)
40
- return [{ type: 'text', text: `${value?.ok === true ? '' : 'FAILED: '}${summary}${data === '' ? '' : `\n${data}`}`.slice(0, limit) }]
40
+ const text = `${value?.ok === true ? '' : 'FAILED: '}${summary}${data === '' ? '' : `\n${data}`}`
41
+ return [{ type: 'text', text: text.length > limit ? `${text.slice(0, limit)}\n…(truncated)` : text }]
41
42
  }
42
43
 
43
44
  function ok(value, summary) {
44
45
  return {
45
46
  ok: true,
46
47
  summary,
47
- data: JSON.stringify(value),
48
+ data: withoutLocalPaths(value),
48
49
  }
49
50
  }
50
51
 
@@ -53,10 +54,22 @@ function fail(error) {
53
54
  return {
54
55
  ok: false,
55
56
  summary: `${serialized.message}${serialized.hint === '' ? '' : ` 提示:${serialized.hint}`}`,
56
- data: JSON.stringify(serialized),
57
+ data: withoutLocalPaths(serialized),
57
58
  }
58
59
  }
59
60
 
61
+ /** Keep local filesystem paths out of model-visible publish/status payloads. */
62
+ function withoutLocalPaths(value) {
63
+ if (Array.isArray(value)) return value.map(withoutLocalPaths)
64
+ if (value === null || typeof value !== 'object') return value
65
+ const copy = {}
66
+ for (const [key, item] of Object.entries(value)) {
67
+ if (key === 'dir' || key === 'lastDir' || key === 'storage' || key === 'dshHome') continue
68
+ copy[key] = withoutLocalPaths(item)
69
+ }
70
+ return copy
71
+ }
72
+
60
73
  const output = {
61
74
  schema: {
62
75
  type: 'object',
@@ -64,7 +77,7 @@ const output = {
64
77
  properties: {
65
78
  ok: { type: 'boolean' },
66
79
  summary: { type: 'string' },
67
- data: { type: 'string' },
80
+ data: { type: 'object', additionalProperties: true },
68
81
  },
69
82
  required: ['ok', 'summary'],
70
83
  },
@@ -175,6 +188,7 @@ function summarizePublish(result) {
175
188
  if (target.ok === false) return `${target.target}: 失败 — ${target.error?.message ?? '未知错误'}`
176
189
  if (target.dryRun === true) return `${target.target}: 预检通过`
177
190
  const link = target.url ?? target.release?.htmlUrl ?? target.repoUrl ?? ''
191
+ if (target.pending === true) return `${target.target}: 已受理,registry 同步中${link === '' ? '' : ` — ${link}`}`
178
192
  return `${target.target}: 成功${link === '' ? '' : ` — ${link}`}`
179
193
  })
180
194
  return `${result.ok === true ? '发布成功' : '发布部分失败'}:${record.package}@${record.version}${result.dryRun === true ? '(dry run,未推送)' : ''}\n${lines.join('\n')}`
@@ -211,7 +225,7 @@ export function createTools(service, agentCtx, config) {
211
225
  const history = service.history(limit)
212
226
  const expiry = status.npm.expiresInDays
213
227
  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 将被撤销)' : ''}`
214
- return ok({ status, history }, summary)
228
+ return ok(withoutLocalPaths({ status, history }), summary)
215
229
  } catch (error) {
216
230
  return fail(error)
217
231
  }
@@ -235,12 +249,12 @@ export function createTools(service, agentCtx, config) {
235
249
  tag: { type: 'string', description: 'Distribution tag for dist-tag actions, e.g. latest, next.' },
236
250
  range: { type: 'string', description: 'SemVer range for deprecate, e.g. <1.2.3 or ^2.0.0. Defaults to *.' },
237
251
  message: { type: 'string', description: 'Deprecation text; empty string undeprecates.' },
238
- access: { type: 'string', enum: ['public', 'private'], description: 'Package visibility for set-access. Only scoped packages can be private.' },
252
+ access: { type: 'string', enum: ['public', 'restricted'], description: 'Package visibility for set-access. Only scoped packages can be restricted/private.' },
239
253
  user: { type: 'string', description: 'npm username for add-owner / remove-owner.' },
240
254
  query: { type: 'string', description: 'Search text for the search action.' },
241
255
  limit: { type: 'integer', description: 'Result limit for list/search, 1-100.' },
242
256
  otp: { type: 'string', description: 'Six-digit npm two-factor code, when the account requires one.' },
243
- force: { type: 'boolean', description: 'Must be true for unpublish.' },
257
+ force: { type: 'boolean', description: 'Must be true for unpublish or delete-release.' },
244
258
  confirmName: { type: 'string', description: 'Must equal the package name when unpublishing a whole package.' },
245
259
  },
246
260
  required: ['action'],
@@ -262,8 +276,8 @@ export function createTools(service, agentCtx, config) {
262
276
  return ok({ items: result.items, warnings: result.warnings, source: result.source }, summary)
263
277
  }
264
278
  case 'info': {
265
- const result = await service.npmInfo({ name: args?.name, otp: args?.otp })
266
- return ok(result, `${result.name} 最新 ${result.latest ?? '?'},共 ${result.versions.length} 个版本`)
279
+ const result = await service.npmInfo({ name: args?.name, version: args?.version, otp: args?.otp })
280
+ return ok(result, `${result.name} 最新 ${result.latest ?? '?'},共 ${result.versions.length} 个版本${result.requestedVersion ? `;已选 ${result.requestedVersion}` : ''}`)
267
281
  }
268
282
  case 'search': {
269
283
  const result = await service.npmSearch({ query: args?.query, limit: args?.limit })
@@ -277,10 +291,10 @@ export function createTools(service, agentCtx, config) {
277
291
  const result = await service.npmSetTag({
278
292
  name: args?.name,
279
293
  tag: args?.tag,
280
- version: args?.version ?? args?.range,
294
+ version: args?.version,
281
295
  otp: args?.otp,
282
296
  })
283
- return ok(result, `已设置 ${args?.name} 的 ${args?.tag} → ${args?.version ?? args?.range}`)
297
+ return ok(result, `已设置 ${args?.name} 的 ${args?.tag} → ${args?.version}`)
284
298
  }
285
299
  case 'delete-dist-tag': {
286
300
  const result = await service.npmDeleteTag({ name: args?.name, tag: args?.tag, otp: args?.otp })
@@ -311,16 +325,16 @@ export function createTools(service, agentCtx, config) {
311
325
  }
312
326
  case 'add-owner':
313
327
  case 'remove-owner': {
314
- const action = action === 'add-owner' ? 'add' : 'remove'
328
+ const verb = action === 'add-owner' ? 'add' : 'remove'
315
329
  const result = await service.npmChangeOwner({
316
330
  name: args?.name,
317
331
  user: args?.user,
318
- action,
332
+ action: verb,
319
333
  otp: args?.otp,
320
334
  })
321
335
  return ok(result, result.unchanged === true
322
336
  ? `${args?.user} 已经是维护者`
323
- : `已${action === 'add' ? '添加' : '移除'}维护者 ${args?.user}`)
337
+ : `已${verb === 'add' ? '添加' : '移除'}维护者 ${args?.user}`)
324
338
  }
325
339
  case 'unpublish': {
326
340
  const result = await service.npmUnpublish({
@@ -420,6 +434,8 @@ export function createTools(service, agentCtx, config) {
420
434
  prerelease: { type: 'boolean', description: 'Mark the release as a prerelease.' },
421
435
  releaseId: { type: 'integer', description: 'Release id for delete-release.' },
422
436
  deleteTag: { type: 'boolean', description: 'Also delete the git tag when deleting a release.' },
437
+ force: { type: 'boolean', description: 'Must be true for delete-release.' },
438
+ generateNotes: { type: 'boolean', description: 'Let GitHub generate release notes from commits.' },
423
439
  assetPath: { type: 'string', description: 'Absolute path of a single file to attach to the release.' },
424
440
  assetDir: { type: 'string', description: 'Package directory to pack; its .tgz is attached to the release.' },
425
441
  syncMode: { type: 'string', enum: ['replace', 'merge'], description: 'replace mirrors the directory; merge keeps existing files not present locally. Defaults to replace.' },
@@ -480,6 +496,7 @@ export function createTools(service, agentCtx, config) {
480
496
  body: args?.body,
481
497
  draft: args?.draft === true,
482
498
  prerelease: args?.prerelease === true,
499
+ generateNotes: args?.generateNotes === true,
483
500
  assetPath,
484
501
  assetDir,
485
502
  })
@@ -492,6 +509,7 @@ export function createTools(service, agentCtx, config) {
492
509
  releaseId: args?.releaseId,
493
510
  deleteTag: args?.deleteTag === true,
494
511
  tag: args?.tag,
512
+ force: args?.force === true,
495
513
  })
496
514
  return ok(result, `已删除 release #${result.id}`)
497
515
  }
package/locale/en.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Release Depot",
4
- "description": "Connects your npm and GitHub accounts inside DeepSeek Harness, then manages packages and releases from a neubrutalist workbench in the main panel: publish a local package to npm or GitHub Packages, push a directory and create a GitHub Release with the tarball attached, edit dist-tags, deprecate or unpublish versions, and review a local publish log. Also gives the agent five tools (release_status, npm_registry, npm_publish, github_publish, publish_package) that call the same operations. Open it with the 发布仓 entry in the left sidebar, then sign in under 设置. Tokens are stored only in .dsh-release-depot/auth.json under your DSH home and are sent only to the registry and GitHub; nothing is uploaded to a third party. Publishing is a real, irreversible side effect, and npm versions cannot be overwritten; the panel requires a preflight before the final confirmation. Lifecycle build scripts (prepack/prepare) are not run; build before publishing. Provenance/attestation signing and npm token creation are not implemented, and the GitHub device flow targets github.com only.",
4
+ "description": "Connects your npm and GitHub accounts inside DeepSeek Harness, then manages packages and releases from a neubrutalist workbench in the main panel: publish a local package to npm or GitHub Packages, push a directory and create a GitHub Release with the tarball attached, edit dist-tags, deprecate or unpublish versions, and review a local publish log. Also gives the agent five tools (release_status, npm_registry, npm_publish, github_publish, publish_package) that call the same operations. Open it with the Release Depot entry in the left sidebar, then sign in under Settings. Tokens are stored only in .dsh-release-depot/auth.json under your DSH home and are sent only to the registry and GitHub; nothing is uploaded to a third party. Publishing is a real, irreversible side effect, and npm versions cannot be overwritten; the panel requires a preflight before the final confirmation. Lifecycle build scripts (prepack/prepare) are not run; build before publishing. Provenance/attestation signing and npm token creation are not implemented, and the GitHub device flow targets github.com only.",
5
5
  "detail": "docs/DETAIL.md"
6
6
  }
7
7
  }
package/locale/zh.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "发布仓",
4
- "description": "在 DeepSeek Harness 里连接你的 npm 与 GitHub 账号,并用一个粗野主义工作台管理包与发布:把本地包发布到 npm 或 GitHub Packages、把目录推送到 GitHub 并创建附带 tarball 的 Release、修改 dist-tag、废弃或删除版本、查看本地发布记录。同时给 AI 提供 release_status、npm_registry、npm_publish、github_publish、publish_package 五个工具,与面板共用同一套操作。从左侧栏的「发布仓」入口打开,在「设置」里登录。令牌只保存在 DSH home 的 .dsh-release-depot/auth.json,且只发送给 registry 与 GitHub,不经过任何第三方。发布是真实且不可撤销的副作用,npm 版本发布后不能覆盖;面板在最终确认前强制预检。不会执行 prepack/prepare 等生命周期构建脚本,请先自行构建。未实现 provenance/attestation 签名与 npm Token 自动创建;GitHub 设备流仅支持 github.com。",
4
+ "description": "在 DeepSeek Harness 里连接你的 npm 与 GitHub 账号,并用一个粗野主义工作台管理包与发布:把本地包发布到 npm 或 GitHub Packages、把目录推送到 GitHub 并创建附带 tarball 的 Release、修改 dist-tag、设置访问级别、维护 maintainer、废弃或删除版本、查看本地发布记录。同时给 AI 提供 release_status、npm_registry、npm_publish、github_publish、publish_package 五个工具,与面板共用同一套操作。从左侧栏的「发布仓」入口打开,在「设置」里登录。令牌只保存在 DSH home 的 .dsh-release-depot/auth.json,且只发送给 registry 与 GitHub,不经过任何第三方。发布是真实且不可撤销的副作用,npm 版本发布后不能覆盖;面板在最终确认前强制预检。不会执行 prepack/prepare 等生命周期构建脚本,请先自行构建。npm Token 到期日会自动读取,但不会自动续期;未实现 provenance/attestation 签名与 npm Token 自动创建。GitHub 设备流仅支持 github.com。",
5
5
  "detail": "docs/DETAIL.zh.md"
6
6
  }
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-release-depot",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "description": "Release Depot(发布仓):在 DeepSeek Harness 内登录 npm 与 GitHub,管理包、发布版本、创建 Release,并把同一套发布能力交给 AI 工具调用。",
@@ -42,11 +42,13 @@
42
42
  "dsh",
43
43
  "cordis",
44
44
  "plugin",
45
+ "release-depot",
45
46
  "npm",
46
47
  "publish",
47
48
  "github",
48
49
  "release"
49
50
  ],
51
+ "author": "5115qwq",
50
52
  "license": "MIT",
51
53
  "repository": {
52
54
  "type": "git",