dsh-anime-bundle 1.0.2 → 1.0.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.
Files changed (4) hide show
  1. package/README.md +20 -2
  2. package/client.js +125 -3
  3. package/index.js +109 -4
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -13,6 +13,7 @@
13
13
  - **添加 / 移除插件**:「添加插件」列出**已安装但不在清单里**的第三方插件,可加入外观或功能组;每行的 `×` 只把条目从清单移除,**不卸载、不改开关**;「恢复默认清单」一键还原。
14
14
  - **一键下载缺失**:按清单里的锁定版本把缺的插件装回来,并把原本开着的重新打开。
15
15
  - **检查更新 / 更新全部**:走 npm 仓库比对最新版;更新时按 DSH 官方路径「先卸载、再安装」(宿主 `installBundle` 只用于新增,已在 profile 里的包会被拒绝),安装失败自动把旧版本装回去。
16
+ - **插件本体更新**:设置页底部显示本插件当前版本,一键比对 npm 上的 `latest`,附 GitHub / npm 链接;主「检查更新」也会顺带查一次本体。不会在运行中替换自身,更新走「设置 → 插件」卸载后重装。
16
17
  - **自检**:提示词、状态文件、插件清单各查一遍,结果直接显示在页面上。
17
18
 
18
19
  ## 安装
@@ -65,12 +66,27 @@ dsh plugin --profile desktop add "link:<克隆下来的目录>"
65
66
  > 文件名的 `dafy-mode` 是历史遗留标识(与内部路由 `/dafy-mode/*` 一起保留),为了从早期版本升级时不丢设置。
66
67
  > 包名、设置页显示名与它的含义无关。
67
68
 
69
+ ## 本体更新
70
+
71
+ 设置页底部「插件本体」显示的是**当前正在运行的** `package.json` 版本;点「检查本体更新」会去 npm 取
72
+ `dsh-anime-bundle@latest` 比对。有新版本时给出版本号、GitHub 与 npm 链接。
73
+
74
+ 本插件不会在运行中把自己卸载重装(那会先把提供这个页面的插件卸载掉)。更新请走官方路径:
75
+ **设置 → 插件 → 卸载 `dsh-anime-bundle` → 重新添加**,或命令行:
76
+
77
+ ```bash
78
+ dsh plugin --profile <profile> remove dsh-anime-bundle
79
+ dsh plugin --profile <profile> add dsh-anime-bundle@latest
80
+ ```
81
+
82
+ 上面的主「检查更新」也会顺带查一次本体,结果里会出现一条 `dsh-anime-bundle(本体)`。
83
+
68
84
  ## 它做了什么(安全说明)
69
85
 
70
86
  - 所有开关都走 DSH 官方的插件管理路径(`pluginManager.setBundleEnabled`),和「设置 → 插件」按钮等价。
71
87
  - 「一键下载缺失 / 更新全部」会让宿主用 pnpm 从 `registry.npmjs.org`(或你配置的镜像)安装清单里的包,
72
88
  安装内容完全由清单决定;不会执行清单以外的下载。
73
- - Host 侧只读写 `~/.dsh/dafy-mode.json`,不访问网络、不收集任何数据。
89
+ - Host 侧只读写 `~/.dsh/dafy-mode.json`;只有你点「检查更新 / 检查本体更新」时才会访问 npm registry(`registry.npmjs.org` 或你配置的镜像),不收集任何数据。
74
90
 
75
91
  ## 开发
76
92
 
@@ -95,7 +111,9 @@ MIT(只覆盖本插件自己的代码与文案)。
95
111
 
96
112
  A settings page that treats your anime skin stack as one switch: toggle the whole look, flip a
97
113
  persona prompt on/off, see every managed plugin's version, reinstall what's missing, and check for
98
- updates — all through DSH's own plugin-manager APIs.
114
+ updates — all through DSH's own plugin-manager APIs. The page also shows its own version and checks
115
+ npm for a newer `dsh-anime-bundle`; it never replaces itself while running, so update it from
116
+ **Settings → Plugins** (remove, then reinstall).
99
117
 
100
118
  **Unofficial.** Not affiliated with or endorsed by DeepSeek, DSH, or the authors of the plugins in
101
119
  the default list (`dafy-whale-theme`, `dsh-boot-suite`, the whale skins). Those packages keep their
package/client.js CHANGED
@@ -73,6 +73,21 @@ window.__ModuleLoader__.load({
73
73
  addedGroupMode: '二次元外观',
74
74
  addedGroupUtil: '功能插件',
75
75
  resetDone: '已恢复默认清单。',
76
+ selfTitle: '插件本体',
77
+ selfDesc: '检查 dsh-anime-bundle 在 npm 上有没有新版本。',
78
+ selfCheck: '检查本体更新',
79
+ selfUpToDate: '已是最新',
80
+ selfNewer: '可更新 {v}',
81
+ selfCurrent: '当前 v{v}',
82
+ selfLatest: '最新 v{v}',
83
+ selfNever: '还没检查过本体更新',
84
+ selfLast: '上次检查:{time}',
85
+ selfNoCheck: '未检查',
86
+ selfFound: '发现本体新版本 v{v}(当前 v{c})。',
87
+ selfLatestMsg: '本体已是最新 v{v}。',
88
+ selfHint: '更新方法:设置 → 插件 → 卸载 dsh-anime-bundle 后重装;或命令行 dsh plugin remove dsh-anime-bundle 再 dsh plugin add dsh-anime-bundle@latest。',
89
+ githubLink: 'GitHub 仓库',
90
+ npmLink: 'npm 页面',
76
91
  confirmDisableAll: '这会停用清单里的所有插件(包括记忆、MCP 面板)。确定吗?',
77
92
  jobModeOn: '正在开启大肥鱼模式',
78
93
  jobModeOff: '正在关闭大肥鱼模式',
@@ -108,7 +123,7 @@ window.__ModuleLoader__.load({
108
123
  noticeTitle: '完成',
109
124
  dismiss: '知道了',
110
125
  progress: '{done}/{total}',
111
- footer: 'dsh-anime-bundle v1.0.0 · 所有开关即时保存,改完不用重启',
126
+ footer: 'dsh-anime-bundle v{v} · 所有开关即时保存,改完不用重启',
112
127
  autoNote: '人格来自插件内置文案,可在 persona.js 里换成你自己的。',
113
128
  busy: '有任务在跑,先等它结束。',
114
129
  phaseEnable: '启用',
@@ -174,6 +189,21 @@ window.__ModuleLoader__.load({
174
189
  addedGroupMode: 'visuals',
175
190
  addedGroupUtil: 'utilities',
176
191
  resetDone: 'Default list restored.',
192
+ selfTitle: 'This plugin',
193
+ selfDesc: 'Check npm for a newer version of dsh-anime-bundle.',
194
+ selfCheck: 'Check plugin update',
195
+ selfUpToDate: 'Up to date',
196
+ selfNewer: 'Update {v}',
197
+ selfCurrent: 'Current v{v}',
198
+ selfLatest: 'Latest v{v}',
199
+ selfNever: 'Never checked this plugin for updates',
200
+ selfLast: 'Last check: {time}',
201
+ selfNoCheck: 'Not checked',
202
+ selfFound: 'A newer version v{v} is available (current v{c}).',
203
+ selfLatestMsg: 'This plugin is up to date at v{v}.',
204
+ selfHint: 'To update: Settings → Plugins → remove dsh-anime-bundle, then reinstall; or run dsh plugin remove dsh-anime-bundle followed by dsh plugin add dsh-anime-bundle@latest.',
205
+ githubLink: 'GitHub repo',
206
+ npmLink: 'npm page',
177
207
  confirmDisableAll: 'This disables every plugin in the list, including memory and the MCP panel. Continue?',
178
208
  jobModeOn: 'Turning Big Fish Mode on',
179
209
  jobModeOff: 'Turning Big Fish Mode off',
@@ -209,7 +239,7 @@ window.__ModuleLoader__.load({
209
239
  noticeTitle: 'Done',
210
240
  dismiss: 'Got it',
211
241
  progress: '{done}/{total}',
212
- footer: 'dsh-anime-bundle v1.0.0 · every switch saves immediately, no restart needed',
242
+ footer: 'dsh-anime-bundle v{v} · every switch saves immediately, no restart needed',
213
243
  autoNote: 'The persona ships in persona.js — edit it to make the fish sound like yours.',
214
244
  busy: 'A task is running. Wait for it to finish.',
215
245
  phaseEnable: 'Enable',
@@ -302,6 +332,11 @@ window.__ModuleLoader__.load({
302
332
  .dfm-details summary { cursor: pointer; font-size: 12px; color: var(--dsw-alias-label-secondary); user-select: none; }
303
333
  .dfm-details summary:hover { color: var(--dsw-alias-label-primary); }
304
334
  .dfm-persona-text { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--dsw-alias-bg-layer-2); border: 1px solid var(--dsw-alias-border-l1); font-size: 12px; color: var(--dsw-alias-label-secondary); white-space: pre-wrap; max-height: 220px; overflow: auto; }
335
+ .dfm-self { margin-top: 14px; }
336
+ .dfm-self-version { font-size: 12px; color: var(--dsw-alias-label-secondary); }
337
+ .dfm-self-links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 11.5px; }
338
+ .dfm-self-links a { color: var(--dsw-alias-brand-primary); text-decoration: none; }
339
+ .dfm-self-links a:hover { text-decoration: underline; }
305
340
  .dfm-foot { margin-top: 18px; font-size: 11px; color: var(--dsw-alias-label-secondary); text-align: center; }
306
341
  .dfm-loading { padding: 40px 0; text-align: center; color: var(--dsw-alias-label-secondary); font-size: 12.5px; }
307
342
  @media (max-width: 560px) { .dfm-hero { align-items: flex-start; } .dfm-tag { display: none; } .dfm-section-head--row { flex-direction: column; align-items: stretch; } .dfm-section-tools { justify-content: flex-end; } }
@@ -775,6 +810,17 @@ window.__ModuleLoader__.load({
775
810
  await post('/action', { action: 'set-mode', enabled: true })
776
811
  }, [post])
777
812
 
813
+ const checkSelf = useCallback(async () => {
814
+ const payload = await post('/action', { action: 'check-self-update' })
815
+ if (!payload || !payload.result) return
816
+ const result = payload.result
817
+ showNotice(
818
+ result.newer
819
+ ? fmt(t('selfFound'), { v: result.latest, c: result.current })
820
+ : fmt(t('selfLatestMsg'), { v: result.latest }),
821
+ )
822
+ }, [post, showNotice, t])
823
+
778
824
  if (!data) {
779
825
  return h(
780
826
  'div',
@@ -798,6 +844,15 @@ window.__ModuleLoader__.load({
798
844
  : t('modeDescOff')
799
845
  const modeRows = data.plugins.filter((row) => row.group === 'mode')
800
846
  const utilRows = data.plugins.filter((row) => row.group === 'util')
847
+ const selfInfo = data.self || {
848
+ name: 'dsh-anime-bundle',
849
+ version: '?',
850
+ latest: null,
851
+ checkedAt: 0,
852
+ newer: false,
853
+ repoUrl: null,
854
+ npmUrl: 'https://www.npmjs.com/package/dsh-anime-bundle',
855
+ }
801
856
  const lastCheck = data.updates.checkedAt
802
857
  ? fmt(t('lastCheckAt'), { time: timeText(data.updates.checkedAt) })
803
858
  : t('lastCheckNever')
@@ -981,7 +1036,74 @@ window.__ModuleLoader__.load({
981
1036
  }))),
982
1037
  ),
983
1038
 
984
- h('div', { className: 'dfm-foot' }, t('footer')),
1039
+ h(
1040
+ 'section',
1041
+ { className: 'dfm-card dfm-self' },
1042
+ h(
1043
+ 'div',
1044
+ { className: 'dfm-mode-head' },
1045
+ h(
1046
+ 'div',
1047
+ { className: 'dfm-mode-text' },
1048
+ h(
1049
+ 'div',
1050
+ { className: 'dfm-card-title' },
1051
+ t('selfTitle'),
1052
+ ' ',
1053
+ h('span', { className: 'dfm-pkg' }, selfInfo.name),
1054
+ ),
1055
+ h('div', { className: 'dfm-muted' }, t('selfDesc')),
1056
+ ),
1057
+ h(
1058
+ 'button',
1059
+ { type: 'button', className: 'dfm-btn', disabled: busy, onClick: checkSelf },
1060
+ t('selfCheck'),
1061
+ ),
1062
+ ),
1063
+ h(
1064
+ 'div',
1065
+ { className: 'dfm-mode-meta' },
1066
+ h(
1067
+ Badge,
1068
+ { tone: selfInfo.newer ? 'update' : selfInfo.latest ? 'on' : undefined },
1069
+ selfInfo.newer
1070
+ ? fmt(t('selfNewer'), { v: selfInfo.latest })
1071
+ : selfInfo.latest
1072
+ ? t('selfUpToDate')
1073
+ : t('selfNoCheck'),
1074
+ ),
1075
+ h('span', { className: 'dfm-self-version' }, fmt(t('selfCurrent'), { v: selfInfo.version })),
1076
+ selfInfo.latest
1077
+ ? h('span', { className: 'dfm-self-version' }, fmt(t('selfLatest'), { v: selfInfo.latest }))
1078
+ : null,
1079
+ h(
1080
+ 'span',
1081
+ { className: 'dfm-count' },
1082
+ selfInfo.checkedAt
1083
+ ? fmt(t('selfLast'), { time: timeText(selfInfo.checkedAt) })
1084
+ : t('selfNever'),
1085
+ ),
1086
+ ),
1087
+ selfInfo.newer ? h('div', { className: 'dfm-note', style: { marginTop: '8px' } }, t('selfHint')) : null,
1088
+ h(
1089
+ 'div',
1090
+ { className: 'dfm-self-links' },
1091
+ selfInfo.repoUrl
1092
+ ? h(
1093
+ 'a',
1094
+ { href: selfInfo.repoUrl, target: '_blank', rel: 'noreferrer' },
1095
+ `${t('githubLink')} ↗`,
1096
+ )
1097
+ : null,
1098
+ h(
1099
+ 'a',
1100
+ { href: selfInfo.npmUrl, target: '_blank', rel: 'noreferrer' },
1101
+ `${t('npmLink')} ↗`,
1102
+ ),
1103
+ ),
1104
+ ),
1105
+
1106
+ h('div', { className: 'dfm-foot' }, fmt(t('footer'), { v: selfInfo.version })),
985
1107
  )
986
1108
  }
987
1109
 
package/index.js CHANGED
@@ -7,9 +7,10 @@
7
7
  * 3. 用 ctx.systemPrompt.section 注入「大肥鱼人格」,开 / 关都不需要重启。
8
8
  */
9
9
  import { randomUUID } from 'node:crypto'
10
- import { promises as fsp } from 'node:fs'
10
+ import { promises as fsp, readFileSync } from 'node:fs'
11
11
  import { homedir } from 'node:os'
12
- import { join } from 'node:path'
12
+ import { dirname, join } from 'node:path'
13
+ import { fileURLToPath } from 'node:url'
13
14
  import { MANAGED } from './catalog.js'
14
15
  import { PERSONA_PREVIEW, PERSONA_TEXT } from './persona.js'
15
16
 
@@ -24,6 +25,30 @@ const STATE_FILE = join(DSH_HOME, 'dafy-mode.json')
24
25
  const VERIFY_ROUNDS = 3
25
26
  const CATALOG_NAMES = new Set(MANAGED.map((entry) => entry.name))
26
27
 
28
+ /** 本插件自己的清单:用来显示本体版本、仓库和 npm 页面。 */
29
+ const PACKAGE_ROOT = dirname(fileURLToPath(import.meta.url))
30
+ const SELF_MANIFEST = readSelfManifest()
31
+ const SELF_PACKAGE = typeof SELF_MANIFEST.name === 'string' && SELF_MANIFEST.name ? SELF_MANIFEST.name : SELF_NAME
32
+ const SELF_VERSION = typeof SELF_MANIFEST.version === 'string' && SELF_MANIFEST.version ? SELF_MANIFEST.version : '0.0.0'
33
+ const SELF_REPO_URL = normalizeRepoUrl(SELF_MANIFEST.repository)
34
+ const SELF_NPM_URL = `https://www.npmjs.com/package/${SELF_PACKAGE}`
35
+
36
+ function readSelfManifest() {
37
+ try {
38
+ return JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf8'))
39
+ } catch {
40
+ return {}
41
+ }
42
+ }
43
+
44
+ function normalizeRepoUrl(repository) {
45
+ const raw = typeof repository === 'string' ? repository : repository && repository.url
46
+ if (typeof raw !== 'string' || !raw.trim()) return null
47
+ let url = raw.trim().replace(/^git\+/, '').replace(/\.git$/, '')
48
+ if (url.startsWith('git@github.com:')) url = `https://github.com/${url.slice('git@github.com:'.length)}`
49
+ return /^https?:\/\//.test(url) ? url : null
50
+ }
51
+
27
52
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
28
53
 
29
54
  function defaultState() {
@@ -37,6 +62,7 @@ function defaultState() {
37
62
  registry: null,
38
63
  added: [],
39
64
  removed: [],
65
+ selfUpdate: null,
40
66
  }
41
67
  }
42
68
 
@@ -146,6 +172,12 @@ async function loadState() {
146
172
  registry: typeof parsed.registry === 'string' ? parsed.registry : null,
147
173
  added,
148
174
  removed,
175
+ selfUpdate: parsed.selfUpdate && typeof parsed.selfUpdate === 'object'
176
+ ? {
177
+ latest: typeof parsed.selfUpdate.latest === 'string' ? parsed.selfUpdate.latest : null,
178
+ checkedAt: Number(parsed.selfUpdate.checkedAt) || 0,
179
+ }
180
+ : null,
149
181
  }
150
182
  } catch (error) {
151
183
  if (error && error.code !== 'ENOENT') {
@@ -272,6 +304,7 @@ function createApi(ctx, state) {
272
304
  registry: state.registry,
273
305
  added: state.added,
274
306
  removed: state.removed,
307
+ selfUpdate: state.selfUpdate,
275
308
  },
276
309
  null,
277
310
  2,
@@ -404,6 +437,17 @@ function createApi(ctx, state) {
404
437
  text: PERSONA_TEXT,
405
438
  chars: PERSONA_TEXT.length,
406
439
  },
440
+ self: {
441
+ name: SELF_PACKAGE,
442
+ version: SELF_VERSION,
443
+ latest: state.selfUpdate && state.selfUpdate.latest ? state.selfUpdate.latest : null,
444
+ checkedAt: state.selfUpdate && state.selfUpdate.checkedAt ? state.selfUpdate.checkedAt : 0,
445
+ newer: Boolean(
446
+ state.selfUpdate && state.selfUpdate.latest && isNewer(state.selfUpdate.latest, SELF_VERSION),
447
+ ),
448
+ repoUrl: SELF_REPO_URL,
449
+ npmUrl: SELF_NPM_URL,
450
+ },
407
451
  plugins,
408
452
  available,
409
453
  list: {
@@ -657,6 +701,12 @@ function createApi(ctx, state) {
657
701
  checks.push({ id: 'persona', ok: false, message: `提示词自检失败:${String((error && error.message) || error)}` })
658
702
  }
659
703
 
704
+ checks.push({
705
+ id: 'self',
706
+ ok: Boolean(SELF_PACKAGE && SELF_VERSION),
707
+ message: `本体 ${SELF_PACKAGE}@${SELF_VERSION}`,
708
+ })
709
+
660
710
  try {
661
711
  const raw = await fsp.readFile(STATE_FILE, 'utf8')
662
712
  const saved = JSON.parse(raw)
@@ -689,6 +739,25 @@ function createApi(ctx, state) {
689
739
  return { ok: passed === checks.length, checks, passed, total: checks.length }
690
740
  }
691
741
 
742
+ /** 检查插件本体:拿本地 package.json 的版本和 npm 上的 latest 比。 */
743
+ async function actionCheckSelf() {
744
+ const registry = await resolveRegistry()
745
+ const latest = await fetchLatest(registry, SELF_PACKAGE)
746
+ state.selfUpdate = { latest, checkedAt: Date.now() }
747
+ await persist()
748
+ return {
749
+ ok: true,
750
+ name: SELF_PACKAGE,
751
+ current: SELF_VERSION,
752
+ latest,
753
+ newer: isNewer(latest, SELF_VERSION),
754
+ checkedAt: state.selfUpdate.checkedAt,
755
+ registry,
756
+ repoUrl: SELF_REPO_URL,
757
+ npmUrl: SELF_NPM_URL,
758
+ }
759
+ }
760
+
692
761
  /* ---------------- 任务入口 ---------------- */
693
762
 
694
763
  function startSetMode(body) {
@@ -832,11 +901,11 @@ function createApi(ctx, state) {
832
901
 
833
902
  function startCheckUpdates() {
834
903
  const npmEntries = effectiveEntries(state).filter((entry) => entry.kind === 'npm')
835
- return startJob('check', npmEntries.length, async (job) => {
904
+ return startJob('check', npmEntries.length + 1, async (job) => {
836
905
  const registry = await resolveRegistry()
837
906
  state.registry = registry
838
907
  const map = await listBundleMap()
839
- job.total = npmEntries.length
908
+ job.total = npmEntries.length + 1
840
909
  for (const entry of npmEntries) {
841
910
  job.current = entry.name
842
911
  job.phase = 'check'
@@ -862,6 +931,29 @@ function createApi(ctx, state) {
862
931
  })
863
932
  }
864
933
  }
934
+ // 顺手把插件本体也查一遍,主「检查更新」一次看全。
935
+ job.current = SELF_PACKAGE
936
+ job.phase = 'check'
937
+ try {
938
+ const latest = await fetchLatest(registry, SELF_PACKAGE)
939
+ state.selfUpdate = { latest, checkedAt: Date.now() }
940
+ const newer = isNewer(latest, SELF_VERSION)
941
+ pushResult(job, {
942
+ name: `${SELF_PACKAGE}(本体)`,
943
+ ok: true,
944
+ message: newer ? `可更新:${SELF_VERSION} → ${latest}` : `已是最新 ${latest}`,
945
+ latest,
946
+ current: SELF_VERSION,
947
+ newer,
948
+ self: true,
949
+ })
950
+ } catch (error) {
951
+ pushResult(job, {
952
+ name: `${SELF_PACKAGE}(本体)`,
953
+ ok: false,
954
+ message: `查询失败:${String((error && error.message) || error)}`,
955
+ })
956
+ }
865
957
  state.checkedAt = Date.now()
866
958
  await persist()
867
959
  })
@@ -1034,6 +1126,19 @@ function createApi(ctx, state) {
1034
1126
  sendJson(res, started.ok ? 200 : 409, { ...started, state: await buildState() })
1035
1127
  return
1036
1128
  }
1129
+ if (action === 'check-self-update') {
1130
+ try {
1131
+ const result = await actionCheckSelf()
1132
+ sendJson(res, 200, { ok: true, result, state: await buildState() })
1133
+ } catch (error) {
1134
+ sendJson(res, 200, {
1135
+ ok: false,
1136
+ error: `检查本体更新失败:${String((error && error.message) || error)}`,
1137
+ state: await buildState(),
1138
+ })
1139
+ }
1140
+ return
1141
+ }
1037
1142
  if (action === 'check-updates') {
1038
1143
  const started = startCheckUpdates()
1039
1144
  sendJson(res, started.ok ? 200 : 409, { ...started, state: await buildState() })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-anime-bundle",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "description": "二次元大肥鱼模式:一键开关整套二次元外观插件、检查更新、装回缺失的插件,并带一个可随时开关的「肥鱼娘」人格。",
6
6
  "keywords": [