@twinsearth/dsh-fang 3.1.3 → 3.1.5

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/client.js CHANGED
@@ -725,6 +725,16 @@ window.__ModuleLoader__.load({
725
725
  .mother-control-title{display:flex;align-items:center;gap:6px;flex-wrap:wrap;font-size:12.5px;font-weight:600;color:var(--f-text)}
726
726
  .mother-control-sub{font-size:10.5px;color:var(--f-text-4);line-height:15px}
727
727
  .mother-list{display:flex;flex-direction:column;gap:2px;padding:0 2px}
728
+ .essence-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:10px;padding:6px 8px}
729
+ .essence-card{display:flex;flex-direction:column;gap:6px;box-sizing:border-box;min-width:0;
730
+ border:1px solid var(--f-border);border-radius:10px;background:var(--f-surface);
731
+ padding:9px 11px;box-shadow:0 1px 2px rgba(16,24,40,.04)}
732
+ .essence-card-head{display:flex;align-items:center;gap:6px;min-height:24px;flex-wrap:wrap}
733
+ .essence-card-name{font-family:"Microsoft YaHei","微软雅黑",sans-serif;font-size:16px;font-weight:600;
734
+ line-height:24px;color:var(--f-text);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
735
+ .essence-card-meta{display:flex;align-items:center;gap:10px;flex-wrap:wrap;font-size:12px;line-height:20px;color:var(--f-text-3)}
736
+ .essence-card-times{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}
737
+ .essence-card-actions{display:inline-flex;align-items:center;gap:2px;margin-left:auto}
728
738
  .mother-row{border:1px solid transparent;border-radius:14px;transition:background .12s ease,border-color .12s ease,box-shadow .12s ease}
729
739
  .mother-row:hover{background:var(--f-surface-2);border-color:var(--f-border)}
730
740
  .mother-row.is-open{background:var(--f-surface-2);border-color:var(--f-border)}
@@ -1394,6 +1404,15 @@ window.__ModuleLoader__.load({
1394
1404
 
1395
1405
  async function refresh(options = {}) {
1396
1406
  if (refreshingLock) return
1407
+ // 分身 Web UI 不请求任何母体 API;404 是预期,不应落成错误状态/横幅。
1408
+ const role = await detectRole()
1409
+ if (!alive) return
1410
+ if (role !== 'mother') {
1411
+ S.lastRefreshAt = Date.now()
1412
+ if (options.manual) S.refreshing = false
1413
+ if (!options.silent) schedule()
1414
+ return
1415
+ }
1397
1416
  refreshingLock = true
1398
1417
  const seq = ++refreshSeq
1399
1418
  if (options.manual) { S.refreshing = true; schedule() }
@@ -2605,7 +2624,7 @@ window.__ModuleLoader__.load({
2605
2624
  'aria-describedby': opts.describedBy,
2606
2625
  dataset: opts.dataKey ? { key: opts.dataKey } : undefined,
2607
2626
  onClick: opts.onClick,
2608
- }, leading, label, opts.spin ? icon('spinner', 13) : null, trailing)
2627
+ }, leading, opts.iconOnly ? null : label, opts.spin ? icon('spinner', 13) : null, trailing)
2609
2628
  if (opts.softDisabled) node.style.opacity = '.45'
2610
2629
  if (opts.iconOnly) {
2611
2630
  node.setAttribute('aria-label', opts.ariaLabel || opts.title || '')
@@ -2971,6 +2990,72 @@ window.__ModuleLoader__.load({
2971
2990
  .map((value) => String(value ?? '').toLowerCase()).join(' ')
2972
2991
  }
2973
2992
 
2993
+ /**
2994
+ * 元宝卡片:一个独立方框,两行信息(名称 / 生成+同步时间),操作图标收在第二行右侧。
2995
+ */
2996
+ function renderEssenceCard(S, app, essence, defaultEssenceId) {
2997
+ const name = essence.name || essence.id
2998
+ const created = Number(essence.createdAt) > 0 ? fmtClock(essence.createdAt) : '—'
2999
+ const synced = Number(essence.lastSyncAt ?? essence.lastMergedAt) > 0
3000
+ ? fmtClock(essence.lastSyncAt ?? essence.lastMergedAt)
3001
+ : '从未'
3002
+ const action = (label, iconName, options = {}) => button(label, {
3003
+ size: 'sm', variant: 'ghost', iconOnly: true, icon: icon(iconName, 12),
3004
+ ariaLabel: label, title: options.title || label, dataBtnId: options.dataBtnId,
3005
+ disabled: options.disabled, fk: options.fk, onClick: options.onClick,
3006
+ })
3007
+ const actions = [
3008
+ essence.stale && essence.locked !== true
3009
+ ? action('同步', 'refresh', { dataBtnId: 'E-03', title: '重放该元主的插件/设置到新母体(配置不变)', onClick: () => void app.syncEssence(essence.id) })
3010
+ : null,
3011
+ essence.archived === true ? null : action('派生', 'plus', { dataBtnId: 'E-05', title: '派生:以该元主为模板创建分身', onClick: () => void app.deriveFromEssence(essence) }),
3012
+ essence.archived === true
3013
+ ? action('还原', 'refresh', { dataBtnId: 'E-15', title: '解冻(恢复活跃态),不还原备份内容', onClick: () => void app.unfreezeEssence(essence) })
3014
+ : action(essence.runtime?.running === true ? '停止' : '打开', essence.runtime?.running === true ? 'disc' : 'play', {
3015
+ dataBtnId: 'E-06',
3016
+ title: essence.runtime?.running === true ? '停止该元主的运行实例' : '打开&设置:启动隔离配置态实例',
3017
+ onClick: () => essence.runtime?.running === true ? void app.stopEssenceRuntime(essence) : void app.openEssence(essence.id),
3018
+ }),
3019
+ essence.runtime?.running === true && essence.archived !== true
3020
+ ? action('进入', 'external', { dataBtnId: 'E-21', title: '在新标签打开运行中的实例', onClick: () => void app.openEssence(essence.id) })
3021
+ : null,
3022
+ essence.archived === true
3023
+ ? null
3024
+ : action('复制', 'copy', { dataBtnId: 'E-07', title: '深复制整份沙盒到新文件夹(不含凭据/备份)', disabled: essence.actions?.copy?.enabled === false, onClick: () => void app.copyEssence(essence) }),
3025
+ essence.archived === true
3026
+ ? null
3027
+ : action('归档', 'archive', { dataBtnId: 'E-08', title: '归档元主(冻结,只改元数据)', disabled: essence.actions?.archive?.enabled === false, onClick: () => void app.archiveEssence(essence) }),
3028
+ action('删除', 'trash', { dataBtnId: 'E-09', title: '永久删除 essences/<id>(须先归档;不删会话)', disabled: essence.actions?.delete?.enabled === false, onClick: () => void app.deleteEssence(essence) }),
3029
+ essence.archived === true
3030
+ ? null
3031
+ : action('备份', 'disc', { dataBtnId: 'E-12', title: '在 essences/<id>/Backup 存档(只保留一份)', onClick: () => void app.essenceBackup(essence) }),
3032
+ essence.archived === true
3033
+ ? null
3034
+ : action('还原备份', 'refresh', { dataBtnId: 'E-13', title: '用最新 Backup 覆盖当前 overlay/merged(需二次确认)', onClick: () => void app.essenceRestore(essence) }),
3035
+ essence.archived === true
3036
+ ? null
3037
+ : action('下载', 'download', { dataBtnId: 'E-10', title: '下载元主整包 JSON(不含凭据)', disabled: essence.actions?.download?.enabled === false, onClick: () => void app.downloadEssence(essence) }),
3038
+ ].filter(Boolean)
3039
+
3040
+ return h('div', { class: 'essence-card', 'data-essence-id': essence.id, role: 'listitem' },
3041
+ h('div', { class: 'essence-card-head' },
3042
+ h('span', { class: 'essence-card-name' },
3043
+ essence.locked
3044
+ ? h('span', { title: name }, name)
3045
+ : editableText(S, app, { key: 'essence:' + essence.id, label: '元主', value: name })),
3046
+ essence.id === defaultEssenceId ? chip('info', '默认', { dot: false }) : null,
3047
+ essence.locked ? chip('neutral', '锁定', { dot: false }) : null,
3048
+ essence.stale ? chip('warn', '🔼 待同步', { dot: false, title: '母体镜像已变化,此元主仍在旧镜像上' }) : null,
3049
+ essence.status === 'conflicted' ? chip('bad', '冲突', { dot: false }) : null,
3050
+ essence.archived === true ? chip('neutral', '冻结', { dot: false, title: '已归档(冻结):只能还原或删除' }) : null),
3051
+ h('div', { class: 'essence-card-meta' },
3052
+ h('span', { class: 'essence-card-times' },
3053
+ h('span', null, `生成 ${created}`),
3054
+ h('span', { title: '最后一次与母体同步时间' }, `同步 ${synced}`)),
3055
+ h('span', { style: { flex: '1' } }),
3056
+ h('div', { class: 'essence-card-actions' }, ...actions)))
3057
+ }
3058
+
2974
3059
  function renderMotherPanel(S, app) {
2975
3060
  const freshness = freshnessOf(S)
2976
3061
  const all = S.sessions.items
@@ -3124,84 +3209,11 @@ window.__ModuleLoader__.load({
3124
3209
  title: '克隆母体 profile 的可写层(插件补丁/依赖/设置)生成新元主;不复制凭据与会话',
3125
3210
  onClick: () => void app.captureEssence(),
3126
3211
  }))
3127
- const essenceList = h('div', { class: 'essence-list', 'data-zone': 'essence-list', style: { display: 'flex', flexWrap: 'wrap', gap: '8px', padding: '4px 8px' } },
3212
+ const essenceList = h('div', { class: 'essence-list', 'data-zone': 'essence-list' },
3128
3213
  essences.length === 0
3129
3214
  ? h('span', { class: 'hint' }, '还没有自定义元主;点上方「从母体生成元主」克隆当前母体配置。')
3130
3215
  : null,
3131
- ...essences.map((essence) => h('div', { class: 'essence-row', 'data-essence-id': essence.id, style: { display: 'inline-flex', alignItems: 'center', gap: '6px' } },
3132
- essence.locked
3133
- ? h('span', { class: 'hint' }, essence.name || essence.id)
3134
- : editableText(S, app, { key: 'essence:' + essence.id, label: '元主', value: essence.name || essence.id }),
3135
- essence.id === defaultEssenceId ? h('span', { class: 'chip' }, '默认') : null,
3136
- essence.locked ? h('span', { class: 'chip' }, '锁定') : null,
3137
- essence.stale ? h('span', { class: 'chip', title: '母体镜像已变化,此元主仍在旧镜像上' }, '🔼 待同步') : null,
3138
- essence.stale && essence.locked !== true
3139
- ? button('同步', {
3140
- size: 'sm', variant: 'ghost', dataBtnId: 'E-03',
3141
- title: '重放该元主的插件/设置到新母体(配置不变)',
3142
- onClick: () => void app.syncEssence(essence.id),
3143
- })
3144
- : null,
3145
- essence.status === 'conflicted' ? h('span', { class: 'chip' }, '冲突') : null,
3146
- essence.archived === true ? h('span', { class: 'chip', title: '已归档(冻结):只能还原或删除' }, '冻结') : null,
3147
- h('span', { style: { display: 'inline-flex', gap: 4 } },
3148
- essence.archived === true ? null : button('派生', {
3149
- size: 'sm', variant: 'ghost', dataBtnId: 'E-05',
3150
- title: '派生:以该元主为模板创建分身(继承其插件&配置),可复制一个现有会话进分身沙箱',
3151
- onClick: () => void app.deriveFromEssence(essence),
3152
- }),
3153
- essence.archived === true
3154
- ? button('还原', {
3155
- size: 'sm', variant: 'ghost', dataBtnId: 'E-15',
3156
- title: '解冻(恢复活跃态,可打开/设置/派生);不还原备份内容',
3157
- onClick: () => void app.unfreezeEssence(essence),
3158
- })
3159
- : button(essence.runtime?.running === true ? '停止' : '打开', {
3160
- size: 'sm', variant: 'ghost', dataBtnId: 'E-06',
3161
- title: essence.runtime?.running === true
3162
- ? '停止该元主的运行实例(端口释放;会话/沙盒文件保留)'
3163
- : '打开&设置:启动或打开该元主的隔离配置态实例(不写母体 sessions)',
3164
- onClick: () => essence.runtime?.running === true ? void app.stopEssenceRuntime(essence) : void app.openEssence(essence.id),
3165
- }),
3166
- essence.runtime?.running === true && essence.archived !== true ? button('进入', {
3167
- size: 'sm', variant: 'ghost', dataBtnId: 'E-21',
3168
- title: '在新标签打开运行中的实例(临时 token,不落盘)',
3169
- onClick: () => void app.openEssence(essence.id),
3170
- }) : null,
3171
- essence.archived === true ? null : button('复制', {
3172
- size: 'sm', variant: 'ghost', dataBtnId: 'E-07',
3173
- title: essence.actions?.copy?.reason || '深复制整份沙盒到新文件夹(不含凭据/运行态/备份)',
3174
- disabled: essence.actions?.copy?.enabled === false,
3175
- onClick: () => void app.copyEssence(essence),
3176
- }),
3177
- essence.archived === true ? null : button('归档', {
3178
- size: 'sm', variant: 'ghost', dataBtnId: 'E-08',
3179
- title: essence.actions?.archive?.reason || '归档元主(冻结,只改元数据)',
3180
- disabled: essence.actions?.archive?.enabled === false,
3181
- onClick: () => void app.archiveEssence(essence),
3182
- }),
3183
- button('删除', {
3184
- size: 'sm', variant: 'ghost', dataBtnId: 'E-09',
3185
- title: essence.actions?.delete?.reason || '永久删除 essences/<id>(须先归档;不删会话)',
3186
- disabled: essence.actions?.delete?.enabled === false,
3187
- onClick: () => void app.deleteEssence(essence),
3188
- }),
3189
- essence.archived === true ? null : button('备份', {
3190
- size: 'sm', variant: 'ghost', dataBtnId: 'E-12',
3191
- title: '在 essences/<id>/Backup 存档(只保留一份,旧备份覆盖)',
3192
- onClick: () => void app.essenceBackup(essence),
3193
- }),
3194
- essence.archived === true ? null : button('还原备份', {
3195
- size: 'sm', variant: 'ghost', dataBtnId: 'E-13',
3196
- title: '用最新 Backup 覆盖当前 overlay/merged(需二次确认)',
3197
- onClick: () => void app.essenceRestore(essence),
3198
- }),
3199
- essence.archived === true ? null : button('下载', {
3200
- size: 'sm', variant: 'ghost', dataBtnId: 'E-10',
3201
- title: essence.actions?.download?.reason || '下载元主整包 JSON(不含凭据)',
3202
- disabled: essence.actions?.download?.enabled === false,
3203
- onClick: () => void app.downloadEssence(essence),
3204
- })))))
3216
+ ...essences.map((essence) => renderEssenceCard(S, app, essence, defaultEssenceId)))
3205
3217
 
3206
3218
  return h('section', { class: 'panel', 'data-zone': 'mother', 'data-freshness': freshness, 'aria-labelledby': 'fang-mother-title' },
3207
3219
  head,
@@ -4262,6 +4274,11 @@ window.__ModuleLoader__.load({
4262
4274
 
4263
4275
  function renderApp(S, app) {
4264
4276
  const frag = document.createDocumentFragment()
4277
+ // 分身 Web UI 只有一条宿主机说明:母体 API 的 404 是预期,不渲染任何错误横幅/母体控件。
4278
+ if (S.role.value === 'fork') {
4279
+ frag.append(renderHostNotice(S, app))
4280
+ return frag
4281
+ }
4265
4282
  frag.append(renderHeader(S, app))
4266
4283
  for (const node of renderNotices(S, app)) frag.append(node)
4267
4284
  for (const node of renderApprovals(S, app)) frag.append(node)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/dsh-fang",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "dsh-Fang (瓮城) — mother/fork plugin development environment for DeepSeek Harness: one readonly mother, a disposable child dsh-Web per task.",
@@ -49,7 +49,7 @@
49
49
  "node": ">=22"
50
50
  },
51
51
  "optionalDependencies": {
52
- "@twinsearth/dsh-fang-queue-journal": "0.1.3",
52
+ "@twinsearth/dsh-fang-queue-journal": "0.1.4",
53
53
  "@twinsearth/dsh-fang-web-entry": "0.1.1"
54
54
  },
55
55
  "devDependencies": {
@@ -128,7 +128,7 @@ export const AUDIT = {
128
128
  RUNTIME_ERROR: 'runtime-error',
129
129
  }
130
130
 
131
- export const FANG_VERSION = '3.1.3'
131
+ export const FANG_VERSION = '3.1.5'
132
132
 
133
133
  /**
134
134
  * @typedef {object} ForkInfo
@@ -9,6 +9,10 @@ export const FORK_LOCKED_ENTRY_IDS = Object.freeze([
9
9
  // 禁用 config-editor / ui-settings 会移除 configForms 服务,导致 locale 及之后
10
10
  // 50 个客户端插件永久 pending(实测:web boot 50 entries did not activate)。
11
11
  'tool-plugin-manager',
12
+ // 分身=生产盘:隐藏侧边栏「插件」页和设置页的插件清单,避免用户点启用后
13
+ // 因 package.json 只读而收到 EPERM。
14
+ 'ui-plugin-manager',
15
+ 'ui-settings-plugin-inventory',
12
16
  ])
13
17
 
14
18
  /** DSH first-run notice needs a durable ui-settings-general config form in every fork profile. */
@@ -74,8 +78,7 @@ function withLockRows(entries, ids) {
74
78
  return { entries: out, added }
75
79
  }
76
80
 
77
- export function applyForkConfigLock(profileDir, options = {}) {
78
- if (String(process.env.DSH_FANG_FORK_CONFIG_LOCK ?? '1') === '0') return { ok: true, skipped: true }
81
+ export function applyForkConfigLock(profileDir, options = {}) { if (String(process.env.DSH_FANG_FORK_CONFIG_LOCK ?? '1') === '0') return { ok: true, skipped: true }
79
82
  const file = path.join(String(profileDir), 'cordis.patch.yml')
80
83
  let text = ''
81
84
  try { text = fs.readFileSync(file, 'utf8') } catch { text = '' }
@@ -115,3 +118,30 @@ export function applyForkConfigLock(profileDir, options = {}) {
115
118
  fs.writeFileSync(file, `${prefix}${comment}${lines.join('\n')}\n`, 'utf8')
116
119
  return { ok: true, entries: ids.length }
117
120
  }
121
+
122
+ /**
123
+ * 解除 fork 生产盘锁(只删 disabled:true 的锁定行,不碰其他配置)。
124
+ * 元宝运行态 essence-runtime 是配置实例,升级后需要清掉历史 provision 写入的锁。
125
+ */
126
+ export function clearForkConfigLock(profileDir, options = {}) {
127
+ const file = path.join(String(profileDir), 'cordis.patch.yml')
128
+ let text = ''
129
+ try { text = fs.readFileSync(file, 'utf8') } catch { return { ok: true, removed: 0 } }
130
+ const ids = options.ids ?? FORK_LOCKED_ENTRY_IDS
131
+ const jsonEntries = jsonPatchEntries(text)
132
+ if (jsonEntries !== null) {
133
+ const wanted = new Set(ids)
134
+ const kept = jsonEntries.filter((entry) => !(entry && typeof entry === 'object' && wanted.has(entry.id) && entry.disabled === true))
135
+ if (kept.length === jsonEntries.length) return { ok: true, removed: 0 }
136
+ fs.writeFileSync(file, `${JSON.stringify(kept, null, 2)}\n`, 'utf8')
137
+ return { ok: true, removed: jsonEntries.length - kept.length }
138
+ }
139
+ let removed = 0
140
+ for (const id of ids) {
141
+ const escaped = String(id).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
142
+ const re = new RegExp(`(^|\\n)\\s*-\\s*id:\\s*${escaped}\\s*\\n\\s*disabled:\\s*true\\s*(?=\\n|$)`, 'g')
143
+ text = text.replace(re, (match, lead) => { removed += 1; return lead })
144
+ }
145
+ if (removed > 0) fs.writeFileSync(file, text, 'utf8')
146
+ return { ok: true, removed }
147
+ }
@@ -57,7 +57,7 @@ import {
57
57
  z,
58
58
  } from '../kernel/index.mjs'
59
59
  import { computeBackoff, planRestart, reconcileOrphans, writeForkMeta, probeHttpAlive, SUPERVISION_DEFAULTS } from '../lib/fork-supervisor.mjs'
60
- import { applyForkConfigLock, setProfileConfigReadonly } from '../lib/fork-config-lock.mjs'
60
+ import { applyForkConfigLock, clearForkConfigLock, setProfileConfigReadonly } from '../lib/fork-config-lock.mjs'
61
61
 
62
62
  export const name = 'fang-forker'
63
63
  export const inject = []
@@ -788,7 +788,9 @@ export function apply(ctx, config) {
788
788
  cloned = cloneProfileConfig(sourceTemplateDir, profileDir)
789
789
  }
790
790
  // 生产盘锁定:关闭插件安装 / 设置 UI(派生时写入 profile patch)。
791
- const configLock = applyForkConfigLock(profileDir)
791
+ // essence-runtime 是元宝的“配置态实例”,必须保留插件管理能力,不能套生产盘锁。
792
+ const configInstance = path.basename(String(profileDir)) === 'essence-runtime'
793
+ const configLock = configInstance ? { ok: true, skipped: true, runtime: true } : applyForkConfigLock(profileDir)
792
794
  if (configLock.ok !== true) warnings.push('fork-config-lock-failed')
793
795
  // 配置文件只读:防误写(DSH_FANG_FORK_PROFILE_RO=0 可关)。
794
796
  const profileReadonly = setProfileConfigReadonly(profileDir, true)
@@ -924,8 +926,17 @@ export function apply(ctx, config) {
924
926
  rec.configSync = { at: nowMs(), ok: false, error: msgOf(e) }
925
927
  }
926
928
  }
927
- try { rec.configLock = applyForkConfigLock(rec.profileDir) } catch { rec.configLock = { ok: false } }
928
- try { rec.profileReadonly = setProfileConfigReadonly(rec.profileDir, true) } catch { rec.profileReadonly = { ok: false } }
929
+ const configInstance = path.basename(String(rec.profileDir)) === 'essence-runtime'
930
+ if (configInstance) {
931
+ // 配置态实例(元宝运行态)必须可写、可管理插件;spawn 不能再次套生产盘锁。
932
+ try { clearForkConfigLock(rec.profileDir) } catch { /* best effort */ }
933
+ try { setProfileConfigReadonly(rec.profileDir, false) } catch { /* ignore */ }
934
+ rec.configLock = { ok: true, skipped: true, runtime: true }
935
+ rec.profileReadonly = { ok: true, skipped: true, runtime: true }
936
+ } else {
937
+ try { rec.configLock = applyForkConfigLock(rec.profileDir) } catch { rec.configLock = { ok: false } }
938
+ try { rec.profileReadonly = setProfileConfigReadonly(rec.profileDir, true) } catch { rec.profileReadonly = { ok: false } }
939
+ }
929
940
  writeForkMetaOf(rec)
930
941
  // 广播新 token:首次派生 = 生成,重启 = 刷新;订阅者拿到的是「当前 token」,
931
942
  // 不是「进程就绪」信号(进程就绪以 fang/fork-started 为准)。
@@ -30,6 +30,7 @@ import { DEFAULT_ESSENCE_NAME, planDefaultEssence } from '../lib/default-essence
30
30
  import { MirrorUpgradeCoordinator } from '../lib/upgrade-coordinator.mjs'
31
31
  import { createBusinessProducers } from '../lib/business-producers.mjs'
32
32
  import { createManifestOfficialSource } from '../lib/mirror-official-source.mjs'
33
+ import { clearForkConfigLock } from '../lib/fork-config-lock.mjs'
33
34
  import { readForkSupervisionSettings, writeForkSupervisionSettings } from '../lib/fork-supervision-settings.mjs'
34
35
  import { DEFAULT_EXPECTED_ROUTE_COUNT, readCompatStatus, runCompatGate, writeCompatStatus } from '../lib/compat.mjs'
35
36
  import { buildUpgradeStatus } from '../lib/upgrade-status.mjs'
@@ -1928,8 +1929,19 @@ export function apply(ctx, config) {
1928
1929
  const stale = mirrorFingerprint.length > 0 && meta.archived !== true
1929
1930
  && String(meta.lastMergedFingerprint ?? '') !== mirrorFingerprint
1930
1931
  const sessionQuota = countEssenceSessions(meta.id, meta)
1932
+ // 元宝卡片第二行:生成时间 + 最后一次与母体同步时间(merged/fingerprint.json)。
1933
+ let lastMergedAt = null
1934
+ try {
1935
+ const fingerprint = readJson(path.join(essenceManager.essenceRoot(meta.id), 'merged', 'fingerprint.json'), null)
1936
+ const value = Number(fingerprint?.mergedAt)
1937
+ if (Number.isFinite(value) && value > 0) lastMergedAt = value
1938
+ } catch { /* profile 尚未物化 */ }
1939
+ if (!lastMergedAt && Number(meta.updatedAt) > 0) lastMergedAt = Number(meta.updatedAt)
1931
1940
  return {
1932
1941
  ...meta,
1942
+ createdAt: Number(meta.createdAt) || null,
1943
+ lastMergedAt,
1944
+ lastSyncAt: lastMergedAt,
1933
1945
  locked: meta.locked === true,
1934
1946
  official: meta.official === true,
1935
1947
  archived: meta.archived === true,
@@ -2195,6 +2207,8 @@ export function apply(ctx, config) {
2195
2207
  nodeModulesSource: essenceModules,
2196
2208
  })
2197
2209
  if (!provisioned.ok) throw new Error(String(provisioned.error ?? 'runtime-provision-failed'))
2210
+ // 历史版本把生产盘锁写进了 essence-runtime;配置实例必须能管理插件,升级后清掉。
2211
+ try { clearForkConfigLock(runtimeProfileDir) } catch { /* best effort */ }
2198
2212
  // provision 若看到旧 junction 可能不替换;这里以 essenceModules 为准做最后自愈。
2199
2213
  if (!exists(runtimeModules)) {
2200
2214
  try {