@ninkch/dsh-artcraft 0.2.9 → 0.2.10

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 (3) hide show
  1. package/client.js +16 -8
  2. package/index.js +13 -1
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -83,9 +83,12 @@ window.__ModuleLoader__.load({
83
83
  const u = await api('/update/check');
84
84
  if (!alive.current) return;
85
85
  setUpd(u);
86
- setOut(u.updateAvailable
87
- ? `有新版本:v${u.latest}(当前 v${u.current}),安装方式:${u.mode === 'git' ? 'git 仓库' : 'npm 安装'}`
88
- : `已是最新${u.latest ? '(npm latest v' + u.latest + ')' : ''}${u.note ? ' · ' + u.note : ''}`);
86
+ // 待重启优先于"有新版本":新包已在磁盘、运行中的还是旧代码,重启前不再误导
87
+ setOut(u.pendingRestart
88
+ ? `✅ 已更新到 v${u.pendingVersion ?? u.diskVersion ?? '?'},请重启 Harness 完成更新(运行中的仍是 v${u.current},页面刷新不够)`
89
+ : u.updateAvailable
90
+ ? `有新版本:v${u.latest}(当前 v${u.current}),安装方式:${u.mode === 'git' ? 'git 仓库' : 'npm 安装'}`
91
+ : `已是最新${u.latest ? '(npm latest v' + u.latest + ')' : ''}${u.note ? ' · ' + u.note : ''}`);
89
92
  } catch (e) { if (alive.current) setOut('检查失败:' + String(e.message || e)); }
90
93
  finally { if (alive.current) setBusy(''); }
91
94
  }, []);
@@ -99,7 +102,11 @@ window.__ModuleLoader__.load({
99
102
  // 不自动刷新/重启任何东西:本插件是 Host 半侧代码,生效 = 重启 Harness 进程
100
103
  if (r.needRestart) {
101
104
  setDone(true);
102
- setOut((r.output || '') + '\n\n✅ 更新已写入磁盘。生效方式:重启 DeepSeek Harness(进程级重启,页面刷新不够)。何时重启由你决定。');
105
+ // 立即把"待重启"写进 upd(服务端事实),后续任何 checkUpdate/重挂载都会保持常驻横幅
106
+ setUpd((u) => (u
107
+ ? { ...u, pendingRestart: true, pendingVersion: r.latest ?? u.pendingVersion, diskVersion: r.latest ?? u.diskVersion, updateAvailable: false }
108
+ : u));
109
+ setOut((r.output || '') + '\n\n✅ 更新已写入磁盘(v' + (r.latest ?? '?') + ')。生效方式:重启 DeepSeek Harness(进程级重启,页面刷新不够)。何时重启由你决定。');
103
110
  }
104
111
  } catch (e) { if (alive.current) setOut('更新失败:' + String(e.message || e)); }
105
112
  finally { if (alive.current) setBusy(''); }
@@ -134,6 +141,7 @@ window.__ModuleLoader__.load({
134
141
  h('div', { className: 'dshac-row', style: { marginTop: '10px' } },
135
142
  h('span', { className: 'dshac-muted' },
136
143
  '当前 v' + (status?.version ?? upd?.current ?? '?') +
144
+ (upd?.pendingRestart ? '(磁盘已是 v' + (upd.pendingVersion ?? upd.diskVersion ?? '?') + ',待重启)' : '') +
137
145
  (upd ? ' · npm latest v' + (upd.latest ?? '—') : '') +
138
146
  (upd?.mode ? '(' + (upd.mode === 'git' ? 'git 仓库' + (upd.gitClean === false ? ' · 有本地改动' : '') : 'npm 安装') + ')' : '')),
139
147
  h('button', { className: 'dshac-btn primary', onClick: checkUpdate, disabled: busy !== '' },
@@ -141,11 +149,11 @@ window.__ModuleLoader__.load({
141
149
  h('button', {
142
150
  className: 'dshac-btn',
143
151
  onClick: applyUpdate,
144
- disabled: busy !== '' || !upd?.updateAvailable,
145
- title: upd?.updateAvailable ? '' : '有新版本时才可应用',
152
+ disabled: busy !== '' || !upd?.updateAvailable || upd?.pendingRestart,
153
+ title: upd?.pendingRestart ? '更新已写入磁盘,重启 Harness 后生效' : (upd?.updateAvailable ? '' : '有新版本时才可应用'),
146
154
  }, busy === 'apply' ? '更新中…' : '一键更新')),
147
- done ? h('div', { className: 'dshac-note' },
148
- '更新已写入磁盘。生效方式:重启 DeepSeek Harness(进程级重启,页面刷新不够)。何时重启由你决定 —— 更新不会打断正在运行的任务。') : null,
155
+ (upd?.pendingRestart || done) ? h('div', { className: 'dshac-note' },
156
+ '✅ 新版已写入磁盘,请重启 DeepSeek Harness 以完成更新(进程级重启,页面刷新不够)。重启后这里会显示新版本,何时重启由你决定 —— 更新不会打断正在运行的任务。') : null,
149
157
  out ? h('div', { className: 'dshac-out' }, out) : null,
150
158
  );
151
159
  }
package/index.js CHANGED
@@ -46,7 +46,7 @@ import crypto from 'node:crypto';
46
46
  import { fileURLToPath } from 'node:url';
47
47
 
48
48
  const NAME = 'artcraft';
49
- const VERSION = '0.2.9';
49
+ const VERSION = '0.2.10';
50
50
  const HERE = path.dirname(fileURLToPath(import.meta.url));
51
51
 
52
52
  const BINS = [
@@ -620,10 +620,22 @@ async function updateCheck() {
620
620
  const current = VERSION;
621
621
  const { latest, note } = await fetchLatestVersion();
622
622
  const info = await detectInstall();
623
+ // 磁盘版本 vs 运行版本:apply 已把新包写进磁盘(换目录 / git pull),但运行中的进程还是旧代码 ——
624
+ // 只对比 npm 版本号会让"一键更新后"看起来又回到有新版本。把"待重启"作为服务端事实返回,
625
+ // 前端据此常驻提示,卡片重挂载/页面刷新都不丢,真重启后(磁盘=运行)自动消失。
626
+ let diskVersion = null;
627
+ try {
628
+ const pj = JSON.parse(await fs.readFile(path.join(HERE, 'package.json'), 'utf8'));
629
+ diskVersion = typeof pj?.version === 'string' ? pj.version : null;
630
+ } catch { /* 非关键 */ }
631
+ const pendingRestart = !!(diskVersion && diskVersion !== current);
623
632
  return {
624
633
  current,
625
634
  latest,
635
+ diskVersion,
626
636
  updateAvailable: !!(latest && semverGt(latest, current)),
637
+ pendingRestart,
638
+ pendingVersion: pendingRestart ? diskVersion : null,
627
639
  mode: info.mode,
628
640
  repoDir: info.repoDir,
629
641
  gitClean: info.gitClean,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninkch/dsh-artcraft",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "type": "module",
5
5
  "description": "Drive the open-source ArtCraft studio suite (12 family apps: PhotoCraft, VectorCraft, FilmCraft, LightCraft, PdfCraft, EffectCraft, DesignCraft, WordCraft, DeckCraft, GridCraft, CADCraft, SoundCraft) from DeepSeek Harness: agent tools, a same-origin HTTP API, and plugins-page status with self-update.",
6
6
  "keywords": [