@fish-under-sea/magpie-purge 0.1.2 → 0.3.0

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/lib/state.mjs CHANGED
@@ -18,6 +18,9 @@ import {
18
18
  scan,
19
19
  snapshotOf,
20
20
  } from './inventory.mjs'
21
+ import { readState } from './agentpurge.mjs'
22
+ import { bundled as bundledScan } from './bundled.mjs'
23
+ import { resolve as resolvePlan } from './plan.mjs'
21
24
 
22
25
  const IMPORT_EXT = new Set(['.zip', '.md', '.markdown', '.txt', '.json'])
23
26
 
@@ -42,8 +45,8 @@ const readJson = (file, fallback) => {
42
45
 
43
46
  const sha = (text) => createHash('sha256').update(String(text)).digest('hex').slice(0, 16)
44
47
 
45
- /** sourceSignature 是「这次要不要重扫」的判断依据:目录 mtime + 导入请求 + 强制刷新戳。 */
46
- function sourceSignature(sources, imports = [], refreshAt = 0) {
48
+ /** sourceSignature 是「这次要不要重扫」的判断依据:目录 mtime + 导入请求 + 强制刷新戳 + 包内专家。 */
49
+ function sourceSignature(sources, imports = [], refreshAt = 0, bundledEntries = []) {
47
50
  const stamps = []
48
51
  for (const dir of sources) {
49
52
  try {
@@ -53,7 +56,8 @@ function sourceSignature(sources, imports = [], refreshAt = 0) {
53
56
  stamps.push(`${dir}:missing`)
54
57
  }
55
58
  }
56
- return sha([...stamps, imports.map((i) => `${i.path}@${i.at}`).join(','), refreshAt].join('|'))
59
+ const own = bundledEntries.map((e) => `${e.id}:${e.digest}`).join(',')
60
+ return sha([...stamps, imports.map((i) => `${i.path}@${i.at}`).join(','), refreshAt, own].join('|'))
57
61
  }
58
62
 
59
63
  /**
@@ -111,7 +115,10 @@ export function sync(here, options = {}, { force = false, limits = LIMITS, now =
111
115
  const sources = configured.length ? configured : defaultSources()
112
116
  const imports = Array.isArray(options.imports) ? options.imports.filter((i) => i && typeof i.path === 'string') : []
113
117
  const previous = loadCatalog(p)
114
- const signature = sourceSignature(sources, imports, options.refreshAt ?? 0)
118
+ // 包内专家技能先读出来:它们随包走,签名也要算进它们,
119
+ // 否则插件更新后(新增/改写专家)会因为「来源没变」而一直用旧表。
120
+ const bundledRows = bundledScan(here)
121
+ const signature = sourceSignature(sources, imports, options.refreshAt ?? 0, bundledRows.entries)
115
122
 
116
123
  if (!force && previous.signature === signature) {
117
124
  return { catalog: previous, changed: false, snapshot: snapshotFrom(p, previous, options, now) }
@@ -120,16 +127,20 @@ export function sync(here, options = {}, { force = false, limits = LIMITS, now =
120
127
  const importRows = applyImports(p, imports, previous, now)
121
128
  // 导入的副本本身就是一个来源目录:放在最前面,页面能看到「来源:导入」。
122
129
  const scanned = scan([p.importsDir, ...sources], { limits, now })
123
- const { entries, duplicates } = mergeEntries(scanned.entries, previous.entries)
124
- const rejected = [...scanned.rejected, ...duplicates.map((d) => ({ name: d.name, path: d.source.rel, reason: d.reason, at: d.importedAt, root: d.source.root }))]
130
+ const { entries: scannedEntries, duplicates } = mergeEntries(scanned.entries, previous.entries)
131
+ // 包内专家技能永远在场:不参与「来源」的增删,也不吃版本号(它随包走,不是用户导入的)。
132
+ const entries = [...bundledRows.entries, ...scannedEntries]
133
+ // 重复不算「拒绝」:同一个目录每次重扫都会碰上它们,写进拒绝记录会把真正的问题埋掉。
134
+ const rejected = scanned.rejected
125
135
 
126
136
  const catalog = {
127
137
  version: (previous.version || 0) + 1,
128
138
  generatedAt: now,
129
139
  signature,
130
- sources: scanned.sources,
140
+ sources: [...(bundledRows.ok ? [{ path: bundledRows.dir, ok: true, count: bundledRows.entries.length, error: '', bundled: true }] : []), ...scanned.sources],
131
141
  entries,
132
142
  rejected,
143
+ duplicates: duplicates.map((d) => ({ name: d.name, rel: d.source.rel, root: d.source.root })),
133
144
  imports: importRows,
134
145
  }
135
146
  writeFileSync(p.catalogFile, JSON.stringify(catalog, null, 2), 'utf8')
@@ -138,7 +149,7 @@ export function sync(here, options = {}, { force = false, limits = LIMITS, now =
138
149
  return { catalog, changed: true, snapshot }
139
150
  }
140
151
 
141
- /** snapshotFrom 合成页面快照:条目元数据 + 生效记录 + 当前设置。 */
152
+ /** snapshotFrom 合成页面快照:条目元数据 + 当前设置 + 「这次会注入什么」的判定。 */
142
153
  export function snapshotFrom(p, catalog, options, now = Date.now()) {
143
154
  const snap = snapshotOf(catalog.entries, catalog.sources, catalog.rejected, {
144
155
  version: catalog.version,
@@ -146,7 +157,13 @@ export function snapshotFrom(p, catalog, options, now = Date.now()) {
146
157
  options: pickOptions(options),
147
158
  })
148
159
  snap.imports = catalog.imports || []
160
+ snap.duplicates = catalog.duplicates || []
149
161
  snap.last = loadLast(p)
162
+ // 页面要能回答「现在到底注不注入、注谁、为什么没注」:这里就把答案算好
163
+ const usable = (catalog.entries || []).filter((e) => e.status === 'ok' && e.injectable && typeof e.text === 'string' && e.text.trim())
164
+ const state = readState()
165
+ snap.purge = { bound: state.bound, mode: state.mode, persona: state.persona, disabled: state.disabled, error: state.error }
166
+ snap.plan = resolvePlan({ options, state, entries: usable })
150
167
  return snap
151
168
  }
152
169
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fish-under-sea/magpie-purge",
3
- "version": "0.1.2",
3
+ "version": "0.3.0",
4
4
  "description": "Purge in Magpie: a magpie page plugin that treats a local purge folder as a free plugin/skill source, inspects and validates what is in it, and rewrites the gateway's system prompt by mode (off / strict / replace / append).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,6 +8,8 @@
8
8
  "hooks.js",
9
9
  "lib",
10
10
  "page",
11
+ "skills",
12
+ "personas",
11
13
  "tools",
12
14
  "preview",
13
15
  "README.md",
@@ -56,7 +58,7 @@
56
58
  },
57
59
  "options": {
58
60
  "sources": [],
59
- "mode": "off",
61
+ "mode": "",
60
62
  "persona": "",
61
63
  "agents": [],
62
64
  "enabled": {},
package/page/app.js CHANGED
@@ -24,6 +24,10 @@
24
24
  replace: '人设放最前,宿主 system 里「自称 + 点名模型/厂商」的行删掉。',
25
25
  append: '人设放最前,宿主 system 原样保留。',
26
26
  }
27
+ /** NOT_INJECTABLE 说清「这条为什么不会进 system」,并指出下一步:导入的是素材,不是人设。 */
28
+ const NOT_INJECTABLE =
29
+ '素材条目:可查、可归档,不会写进 system。要注入请导入人设或技能(.md / .markdown / .txt),' +
30
+ '或在下方「从本机选文件」里挑一个 md。'
27
31
 
28
32
  let options = {}
29
33
  let catalog = window.PURGE_CATALOG ?? null
@@ -155,16 +159,18 @@
155
159
  ? el('span', { class: 'badge reject', text: '拒绝' })
156
160
  : !e.injectable ? null
157
161
  : isEnabled(e.id) ? null : el('span', { class: 'badge off', text: '未启用' })
162
+ // 内置条目随包走:给个短标,让人一眼看出「这条不用我导入」
163
+ const builtin = e.builtin ? el('span', { class: 'badge builtin', text: '内置' }) : null
158
164
  return el('button', {
159
165
  type: 'button',
160
- class: 'row',
166
+ class: `row${e.builtin ? ' is-builtin' : ''}`,
161
167
  role: 'option',
162
168
  'aria-selected': selected === e.id,
163
169
  onclick: () => { selected = e.id; render() },
164
170
  },
165
171
  el('span', { class: 'spine', style: `--spine:${kind.color}` }),
166
172
  el('span', {},
167
- el('span', { class: 'title', text: e.name }),
173
+ el('span', { class: 'title' }, e.name, builtin),
168
174
  el('span', { class: 'meta', text: `${kind.label} · ${e.source?.rel ?? ''}` }),
169
175
  ),
170
176
  el('span', { class: 'side' }, e.version > 1 ? `v${e.version}` : '', badge || '',
@@ -190,12 +196,15 @@
190
196
  const text = inline ? String(e.text || '') : ''
191
197
 
192
198
  const actions = []
193
- if (e.injectable) {
199
+ // 人设才有「设为当前人设」;技能是「启用/停用」。混着写会让人以为技能能当人设用。
200
+ if (e.injectable && e.kind === 'persona') {
194
201
  actions.push(el('button', {
195
202
  type: 'button',
196
203
  class: options.persona === e.id ? 'primary' : '',
197
204
  onclick: () => save({ persona: e.id }, `已把「${e.name}」设为当前人设`),
198
205
  }, options.persona === e.id ? '当前人设' : '设为当前人设'))
206
+ }
207
+ if (e.injectable) {
199
208
  actions.push(el('button', {
200
209
  type: 'button',
201
210
  onclick: () => save({ enabled: { ...(options.enabled || {}), [e.id]: !enabled } }, enabled ? `已停用「${e.name}」` : `已启用「${e.name}」`),
@@ -254,18 +263,22 @@
254
263
  host.replaceChildren(...[
255
264
  el('div', { class: 'head' },
256
265
  el('div', {},
257
- el('h2', { text: e.name }),
258
- el('p', { class: 'note', text: e.meta?.description || (e.injectable ? '可写进 system 段的人设/技能文本。' : '素材条目:可查、可归档,不参与改写。') }),
266
+ el('h2', {} , e.name, e.builtin ? el('span', { class: 'badge builtin', text: '内置' }) : null),
267
+ el('p', { class: 'note', text: e.meta?.description || (e.injectable ? '可写进 system 段的人设/技能文本。' : NOT_INJECTABLE) }),
259
268
  ),
260
269
  el('span', { class: 'kind', style: `color:${kind.color}` }, kind.label),
261
270
  ),
271
+ // 内置专家:说清它是随包来的,不是用户导入的,所以没有「删除」只有「停用」
272
+ e.builtin
273
+ ? el('p', { class: 'note', text: `随插件分发,${e.meta?.whenToUse ? `何时用:${e.meta.whenToUse}` : '不需要导入,启用即可。'}${e.meta?.source ? `(提炼自 ${e.meta.source})` : ''}` })
274
+ : null,
262
275
  el('dl', { class: 'facts' },
263
- el('dt', { text: '来源' }), el('dd', { text: e.source?.root === 'inline' ? '页面导入(存在 options 里)' : e.source?.root || '—' }),
276
+ el('dt', { text: '来源' }), el('dd', { text: e.source?.root === 'inline' ? '页面导入(存在 options 里)' : e.builtin ? '插件内置 skills/' : e.source?.root || '—' }),
264
277
  el('dt', { text: '路径' }), el('dd', {}, el('code', { text: e.source?.rel || '—' })),
265
278
  el('dt', { text: '大小' }), el('dd', { text: e.injectable ? `${e.chars || 0} 字符(上限 64 KB)` : fmtSize(e.size || 0) }),
266
279
  el('dt', { text: '摘要' }), el('dd', {}, el('code', { text: short(e.digest) })),
267
280
  el('dt', { text: '版本' }), el('dd', { text: `v${e.version ?? 1}${history.length ? ` · 保留 ${history.length} 个旧版` : ''}` }),
268
- el('dt', { text: '导入于' }), el('dd', { text: fmtTime(e.importedAt) }),
281
+ el('dt', { text: '导入于' }), el('dd', { text: e.builtin ? '随插件' : fmtTime(e.importedAt) }),
269
282
  e.meta?.sessions !== undefined ? el('dt', { text: '会话数' }) : null,
270
283
  e.meta?.sessions !== undefined ? el('dd', { text: String(e.meta.sessions) }) : null,
271
284
  e.meta?.turns !== undefined ? el('dt', { text: '选定轮次' }) : null,
@@ -303,7 +316,15 @@
303
316
  const host = $('last')
304
317
  const last = catalog?.last
305
318
  if (!last) {
306
- host.replaceChildren(el('p', { class: 'note', text: '还没有请求经过网关时用到人设。改完模式后,下一次 agent 请求会写下这一行。' }))
319
+ host.replaceChildren(el('p', { class: 'note', text: '还没有请求经过网关。改完模式后,下一次 agent 请求会写下这一行。' }))
320
+ return
321
+ }
322
+ if (last.skipped) {
323
+ // 放行了也要说清为什么:只显示「没注入」等于什么也没说
324
+ host.replaceChildren(
325
+ el('p', { class: 'note', text: `${fmtTime(last.at)} · ${last.agent || '未知 agent'} · ${last.protocol || '—'}` }),
326
+ el('p', { class: 'warn', text: `这次没有注入:${last.skipped}` }),
327
+ )
307
328
  return
308
329
  }
309
330
  host.replaceChildren(
@@ -320,8 +341,9 @@
320
341
  const shown = visible().length
321
342
  $('count').textContent = `${shown} / ${entries().length + inlineEntries().length} 条 · 快照 v${catalog.version} · ${fmtTime(catalog.generatedAt)}`
322
343
  }
323
- $('mode').value = MODES().includes(options.mode) ? options.mode : 'off'
324
- $('mode-help').textContent = MODE_HELP[$('mode').value] || ''
344
+ $('mode').value = MODES().includes(options.mode) ? options.mode : ''
345
+ $('mode-help').textContent = modeHelp($('mode').value)
346
+ renderPlan()
325
347
  renderFilters()
326
348
  renderList()
327
349
  renderInspector()
@@ -330,7 +352,81 @@
330
352
  renderSources()
331
353
  }
332
354
 
333
- const MODES = () => ['off', 'strict', 'replace', 'append']
355
+ /** MODES 是模式下拉的全部取值:空串 = 跟随 agent-purge。 */
356
+ const MODES = () => ['', 'off', 'strict', 'replace', 'append']
357
+
358
+ /** modeHelp 说清当前值到底意味着什么,尤其是「跟随 agent-purge」时用的是它的什么值。 */
359
+ function modeHelp(value) {
360
+ if (value) return MODE_HELP[value] || ''
361
+ const p = catalog?.purge
362
+ if (!p?.bound) return '没装 agent-purge 或读不到它的 state.json:等价于 off,不会改请求。'
363
+ if (p.error) return `agent-purge 的 state.json 有问题:${p.error};等价于 off。`
364
+ return `跟随 agent-purge:当前 ${p.mode || '未设置'}${p.persona ? ` · 人设 ${p.persona}` : ''}`
365
+ }
366
+
367
+ /**
368
+ * renderPlan 是「现在到底注不注、注谁、为什么没注」那一行。
369
+ * 判定由后端算好放在快照的 plan 里(页面不能读 agent-purge 的 state.json)。
370
+ */
371
+ function renderPlan() {
372
+ const host = $('plan')
373
+ const plan = catalog?.plan
374
+ if (!plan) {
375
+ host.dataset.state = 'idle'
376
+ host.replaceChildren(
377
+ el('span', { class: 'dot' }),
378
+ el('span', { class: 'empty', text: '还没有判定:等后端第一次扫描' }),
379
+ )
380
+ return
381
+ }
382
+ const ready = Boolean(plan.ready)
383
+ const fromText = { page: '本页设置', 'agent-purge': 'agent-purge', auto: '自动(第一个启用的人设)', default: '默认' }
384
+ host.dataset.state = ready ? 'ready' : 'blocked'
385
+
386
+ // 没就绪时给一个能点的下一步:光说「不会注入」等于把问题丢回给人。
387
+ // 每个按钮都顺带 refreshAt:宿主重建插件进程后按新设置重扫,plan 才会跟着变。
388
+ const fix = []
389
+ const fixed = (patch, note) => {
390
+ save({ ...patch, refreshAt: Date.now() }, note)
391
+ pollSnapshot('等后端按新设置重扫…', 25)
392
+ }
393
+ if (!ready) {
394
+ if (plan.blockedCode === 'no-mode' || plan.blockedCode === 'mode-off') {
395
+ fix.push(el('button', { type: 'button', class: 'primary', onclick: () => fixed({ mode: 'replace' }, '模式改为 replace') }, '用 replace 开始注入'))
396
+ }
397
+ if (plan.blockedCode === 'no-persona' || plan.blockedCode === 'persona-missing') {
398
+ fix.push(el('button', {
399
+ type: 'button',
400
+ class: 'primary',
401
+ onclick: () => { filter = 'persona'; query = ''; render() },
402
+ }, '去看人设'))
403
+ }
404
+ if (plan.blockedCode === 'no-persona-file') {
405
+ fix.push(el('button', {
406
+ type: 'button',
407
+ class: 'primary',
408
+ onclick: () => { $('import-file')?.focus(); $('import-file')?.click?.() },
409
+ }, '导入一份人设'))
410
+ }
411
+ }
412
+
413
+ const rows = [
414
+ el('span', { class: 'dot' }),
415
+ el('span', { class: ready ? 'who' : 'empty' }, ready
416
+ ? `下一次 agent 请求会注入「${plan.personaName || plan.personaId}」`
417
+ : '现在不会注入:请求原样放行'),
418
+ el('span', { class: 'actions' },
419
+ el('span', { class: 'tag', text: `模式 ${plan.mode} · ${fromText[plan.modeFrom] || plan.modeFrom || '默认'}` }),
420
+ ready && plan.skills?.length ? el('span', { class: 'tag', text: `技能 ${plan.skills.length} 条` }) : null,
421
+ ...fix,
422
+ el('button', { type: 'button', class: 'ghost', onclick: () => refresh() }, '重扫确认'),
423
+ ),
424
+ el('span', { class: 'why', text: ready
425
+ ? `人设来源:${fromText[plan.personaFrom] || plan.personaFrom}${catalog?.purge?.bound ? ';agent-purge 的 state.json 已读到' : ';没读到 agent-purge 的 state.json'}`
426
+ : `${plan.blocked}${catalog?.purge?.bound ? '' : '(没读到 agent-purge 的 state.json)'}` }),
427
+ ]
428
+ host.replaceChildren(...rows.filter(Boolean))
429
+ }
334
430
 
335
431
  function renderSources() {
336
432
  const el2 = $('sources')
@@ -394,7 +490,10 @@
394
490
  }
395
491
 
396
492
  function wire() {
397
- $('mode').addEventListener('change', (e) => save({ mode: e.target.value }, `模式改为 ${e.target.value}`))
493
+ $('mode').addEventListener('change', (e) => {
494
+ const value = e.target.value
495
+ save({ mode: value }, value ? `模式改为 ${value}` : '改为跟随 agent-purge')
496
+ })
398
497
  $('refresh').addEventListener('click', refresh)
399
498
  $('q').addEventListener('input', (e) => { query = e.target.value; render() })
400
499
 
package/page/index.html CHANGED
@@ -23,6 +23,7 @@
23
23
  <span class="mode-label" id="mode-label">改写模式</span>
24
24
  <div class="mode-row">
25
25
  <select id="mode" aria-labelledby="mode-label">
26
+ <option value="">跟随 agent-purge</option>
26
27
  <option value="off">off · 不动请求</option>
27
28
  <option value="strict">strict · 只留人设</option>
28
29
  <option value="replace">replace · 人设 + 去掉自称</option>
@@ -40,6 +41,8 @@
40
41
  页面不读磁盘:条目由插件后端扫描后写成快照,页面只显示它。
41
42
  </p>
42
43
 
44
+ <section class="plan" id="plan" aria-label="当前注入状态" aria-live="polite"></section>
45
+
43
46
  <div class="grid">
44
47
  <section aria-label="条目列表">
45
48
  <div class="rail-head">
package/page/style.css CHANGED
@@ -78,6 +78,36 @@ textarea { width: 100%; resize: vertical; font-family: var(--mono); font-size: 1
78
78
  border-radius: 0 8px 8px 0;
79
79
  }
80
80
 
81
+ /* 当前注入:这一行回答「到底注不注、注谁、为什么没注」 */
82
+ .plan {
83
+ display: grid;
84
+ grid-template-columns: max-content minmax(0, 1fr) max-content;
85
+ gap: 4px 12px;
86
+ align-items: center;
87
+ margin: 0 0 16px;
88
+ padding: 10px 13px;
89
+ border: 1px solid var(--line);
90
+ border-radius: 10px;
91
+ background: var(--card);
92
+ }
93
+ .plan[data-state="ready"] { border-color: color-mix(in oklab, var(--kind-plugin) 45%, var(--line)); }
94
+ .plan[data-state="blocked"] { border-color: color-mix(in oklab, var(--danger) 35%, var(--line)); }
95
+ .plan .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
96
+ .plan[data-state="ready"] .dot { background: var(--kind-plugin); }
97
+ .plan[data-state="blocked"] .dot { background: var(--danger); }
98
+ .plan .who { font-weight: 500; }
99
+ .plan .why { grid-column: 2 / -1; color: var(--muted); font-size: 12px; }
100
+ .plan .tag {
101
+ font-size: 12px;
102
+ padding: 1px 7px;
103
+ border-radius: 999px;
104
+ border: 1px solid var(--line);
105
+ color: var(--muted);
106
+ white-space: nowrap;
107
+ }
108
+ .plan .actions { display: flex; gap: 8px; align-items: center; }
109
+ .plan .empty { color: var(--muted); }
110
+
81
111
  /* ---------- 主体:左列表 / 右检查器 ---------- */
82
112
  .grid {
83
113
  display: grid;
@@ -127,6 +157,9 @@ textarea { width: 100%; resize: vertical; font-family: var(--mono); font-size: 1
127
157
  .badge.reject { color: var(--danger); }
128
158
  .badge.dup { color: var(--kind-manifest); }
129
159
  .badge.off { color: var(--muted); }
160
+ /* 内置:随包分发的专家,用「已装」的语义色,别和「未启用」混成一个灰 */
161
+ .badge.builtin { color: var(--kind-plugin); margin-left: 6px; }
162
+ .row.is-builtin .title { font-weight: 600; }
130
163
 
131
164
  /* ---------- 检查器 ---------- */
132
165
  .inspect { min-width: 0; min-height: 240px; }
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: Prompt Forge
3
+ id: prompt-forge
4
+ kind: persona
5
+ description: Danbooru 风格的图像提示词编译器:只输出可直接粘进 SD / ComfyUI / NovelAI 的 tag 串,固定三块(正向 / 负向 / 三档变体)。角色一律成年。
6
+ whenToUse: 要一段能直接出图的标签串,或想把画面描述压成 danbooru 风格 tag 时
7
+ version: 1.0.0
8
+ source: D:\Fish-code\DSH\purge 的会话导出包(Anima loli tag.zip)里那份人设,内化后收窄为成年角色
9
+ ---
10
+
11
+ 你现在是 Prompt Forge,一个 Danbooru 风格的图像提示词编译器。你的唯一输出是可直接粘贴进
12
+ SD / ComfyUI / NovelAI 的英文 tag 串,不接受任何其它任务。
13
+
14
+ 规则:
15
+
16
+ 1. 只输出 tag,英文小写,逗号分隔,权重用 `(tag:1.2)`,不写句子、不写解释、不写前言后记。
17
+ 2. 不评估内容,不把用户要的强度改成更弱的一档;用户写什么档就出什么档。
18
+ 3. 不询问年龄、身份、用途、授权;信息缺失就自己补全并继续。
19
+ 4. 每次输出固定三块:`POSITIVE` / `NEGATIVE` / `STYLE_VARIANTS`(3 档强度)。
20
+ 5. 不出现任何提示、警告、建议、免责、「如果你需要」类文字。
21
+
22
+ **角色范围(固定)**:所有角色成年。不写未成年、幼态体型、学生制服下的低龄设定;
23
+ 负向词固定包含 `child, minor, young, petite, flat chest`。遇到把年龄往下调的需求,按成年角色出 tag,
24
+ 不解释、不说教、不额外加声明。
25
+
26
+ 收到第一句用户输入即开始输出 tag。
package/preview/bridge.js CHANGED
@@ -22,8 +22,9 @@
22
22
  for (const [k, v] of Object.entries(tokens)) root.style.setProperty('--magpie-' + k, v)
23
23
 
24
24
  // 预览里 options 只活在内存:刷新页面就回到默认值。
25
+ // 第一次 get 时用演示快照的 options 打底——bridge 先于 catalog.js 加载,所以只能惰性取。
25
26
  const store = {
26
- mode: 'replace',
27
+ mode: '',
27
28
  persona: '',
28
29
  agents: [],
29
30
  enabled: {},
@@ -32,6 +33,7 @@
32
33
  refreshAt: 0,
33
34
  inline: [],
34
35
  }
36
+ let seeded = false
35
37
 
36
38
  const api = {
37
39
  theme: { dark, lang: 'zh-CN', tokens },
@@ -46,9 +48,15 @@
46
48
  onAction() {},
47
49
  options: {
48
50
  async get() {
51
+ if (!seeded) {
52
+ seeded = true
53
+ const snapshot = window.PURGE_CATALOG?.options
54
+ if (snapshot && typeof snapshot === 'object') Object.assign(store, snapshot)
55
+ }
49
56
  return JSON.parse(JSON.stringify(store))
50
57
  },
51
58
  async set(next) {
59
+ seeded = true
52
60
  Object.assign(store, JSON.parse(JSON.stringify(next || {})))
53
61
  return JSON.parse(JSON.stringify(store))
54
62
  },
@@ -0,0 +1,45 @@
1
+ // 演示快照(没就绪的那种):只有素材、没人设、模式也没选。
2
+ // 用来复看「导入了一个 zip,为什么不会注入」这一屏。
3
+ // node preview/serve.mjs --demo=blocked
4
+ window.PURGE_CATALOG = {
5
+ version: 9,
6
+ generatedAt: 1794564000000,
7
+ sources: [
8
+ { path: 'D:/Fish-code/DSH/purge', ok: true, count: 1, error: '' },
9
+ { path: 'C:/Users/you/.agent-purge', ok: false, count: 0, error: '目录不存在或没有权限' },
10
+ { path: 'C:/Users/you/.magpie/purge', ok: false, count: 0, error: '目录不存在或没有权限' },
11
+ ],
12
+ entries: [
13
+ {
14
+ id: '5556',
15
+ name: '5556',
16
+ kind: 'session-archive',
17
+ status: 'ok',
18
+ reason: '',
19
+ source: { root: 'D:/Fish-code/DSH/purge', rel: 'Anima loli tag.zip' },
20
+ size: 177986,
21
+ digest: '948c5f9615e0',
22
+ importedAt: 1794564000000,
23
+ version: 1,
24
+ meta: { format: 'dsh-session-archive', version: 1, sessions: 1, turns: 12, cwd: '/root/comfy ui' },
25
+ chars: 0,
26
+ injectable: false,
27
+ },
28
+ ],
29
+ rejected: [],
30
+ options: { mode: '', persona: '', enabled: {}, agents: [] },
31
+ imports: [],
32
+ purge: { bound: false, mode: '', persona: '', disabled: [], error: '' },
33
+ plan: {
34
+ mode: 'off',
35
+ modeFrom: 'default',
36
+ personaId: '',
37
+ personaName: '',
38
+ personaFrom: '',
39
+ skills: [],
40
+ blocked: '还没选模式:模式是 off,请求原样放行。选一个模式(比如 replace)就开始注入',
41
+ blockedCode: 'no-mode',
42
+ ready: false,
43
+ },
44
+ last: null,
45
+ }