@fish-under-sea/magpie-purge 0.6.0 → 0.6.1

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/README.md CHANGED
@@ -418,6 +418,7 @@ node tools/scan.mjs --json
418
418
 
419
419
  | 版本 | 要点 |
420
420
  | --- | --- |
421
+ | `0.6.1` | 修:注入关闭时人设行恒显示「未启用」、点它没有反应(判定把人设一起清空了) |
421
422
  | `0.6.0` | 正文移出 `page/catalog.js`、改写成 `page/catalog.json` 按需取,修 Defender `Trojan:Script/Wacatac.C!ml` 误判;配色换莓石;详情改浮层;分组可折叠;整页不滚;模式去掉 off 改由开关控制 |
422
423
  | `0.5.0` | 内置技能换成 22 份原文(原为 9 位提炼稿);左栏点行即启用、原文可编辑可删除;两侧等长;修网格行被压扁;人设改为「大肥鱼削弱版」 |
423
424
  | `0.4.3` | 判定改由页面本地计算:技能开关、装配面板、状态条改完立刻生效,不再等后端重扫;左栏跟随右栏等高;专家开关带复选框与计数 |
package/lib/plan.mjs CHANGED
@@ -51,24 +51,36 @@ export function resolve({ options = {}, state = null, entries = [], agent = '' }
51
51
  const pageMode = MODES.includes(options.mode) ? options.mode : ''
52
52
  const mode = pageMode || ap.mode || 'off'
53
53
  const modeFrom = pageMode ? 'page' : ap.mode ? 'agent-purge' : 'default'
54
+
55
+ // ---- 人设(先算)----
56
+ // 关掉注入只是「这次不改写请求」,用户选了哪位人设这件事没变。
57
+ // 先返回的话 personaId 是空串,列表里每条人设都显示「未启用」,
58
+ // 点它也就看着毫无反应——这就是「点了没变化」的来源。
59
+ const byId = new Map()
60
+ for (const e of entries) if (e && typeof e.id === 'string' && !byId.has(e.id)) byId.set(e.id, e)
61
+ const personas = entries.filter((e) => e.kind === 'persona')
62
+ const pagePersona = typeof options.persona === 'string' ? options.persona.trim() : ''
63
+
54
64
  if (mode === 'off') {
65
+ const picked =
66
+ (pagePersona && byId.get(pagePersona)) ||
67
+ (ap.persona && byId.get(ap.persona)) ||
68
+ personas.find((e) => e.default === true && options.enabled?.[e.id] !== false) ||
69
+ personas.find((e) => e.builtin !== true && options.enabled?.[e.id] !== false)
55
70
  return {
56
71
  ...blank(modeFrom, mode, '', modeFrom === 'default' ? 'no-mode' : 'mode-off'),
72
+ // blank 的第三个参数是「被挡住的文案」,不是 personaId,所以人设得另塞
73
+ personaId: picked?.id || '',
57
74
  blocked: modeFrom === 'default'
58
75
  ? '注入是关的:请求原样放行。按右侧「开始注入」才会改写请求'
59
76
  : '当前模式是 off,请求原样放行',
60
77
  }
61
78
  }
62
79
 
63
- // ---- 人设 ----
64
- const byId = new Map()
65
- for (const e of entries) if (e && typeof e.id === 'string' && !byId.has(e.id)) byId.set(e.id, e)
66
- const personas = entries.filter((e) => e.kind === 'persona')
67
-
80
+ // ---- 人设(完整判定)----
68
81
  let personaId = ''
69
82
  let personaFrom = ''
70
83
  let missingPersona = ''
71
- const pagePersona = typeof options.persona === 'string' ? options.persona.trim() : ''
72
84
  if (pagePersona && byId.has(pagePersona)) {
73
85
  personaId = pagePersona
74
86
  personaFrom = 'page'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fish-under-sea/magpie-purge",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "magpie-purge: 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",
package/page/index.html CHANGED
@@ -6,11 +6,11 @@
6
6
  <title>破甲 · Purge</title>
7
7
  <script src="_magpie/bridge.js"></script>
8
8
  <script src="catalog.js"></script>
9
- <!-- ?v=0.6.0 是占位:tools/prepack.mjs 打包时换成真实版本号,postpack 换回来。
9
+ <!-- ?v=0.6.1 是占位:tools/prepack.mjs 打包时换成真实版本号,postpack 换回来。
10
10
  没有它,更新插件后浏览器可能一直用缓存的旧 app.js / style.css。 -->
11
- <script src="plan.js?v=0.6.0"></script>
12
- <link rel="stylesheet" href="style.css?v=0.6.0">
13
- <script src="app.js?v=0.6.0" defer></script>
11
+ <script src="plan.js?v=0.6.1"></script>
12
+ <link rel="stylesheet" href="style.css?v=0.6.1">
13
+ <script src="app.js?v=0.6.1" defer></script>
14
14
  </head>
15
15
  <body>
16
16
 
package/page/plan.js CHANGED
@@ -47,19 +47,28 @@
47
47
  const pageMode = MODES.includes(options.mode) ? options.mode : ''
48
48
  const mode = pageMode || 'off'
49
49
  const modeFrom = pageMode ? 'page' : 'default'
50
+
51
+ const byId = new Map()
52
+ for (const e of entries) if (e && typeof e.id === 'string' && !byId.has(e.id)) byId.set(e.id, e)
53
+ const personas = entries.filter((e) => e.kind === 'persona')
54
+
55
+ // 人设的解析放在「注入关着」之前:关掉注入只是「这次不写请求」,
56
+ // 用户选了哪位人设这件事没变。先返回的话 personaId 是空串,
57
+ // 列表里每条人设都显示「未启用」,点它也就看着毫无反应。
50
58
  if (mode === 'off') {
59
+ const picked = personas.find((e) => e.id === (typeof options.persona === 'string' ? options.persona.trim() : ''))
60
+ || personas.find((e) => e.default === true && options.enabled?.[e.id] !== false)
61
+ || personas.find((e) => e.builtin !== true && options.enabled?.[e.id] !== false)
51
62
  return {
52
63
  ...blank(modeFrom, mode, '', modeFrom === 'default' ? 'no-mode' : 'mode-off'),
64
+ // blank 的第三个参数是「被挡住的文案」,不是 personaId,所以人设得另塞
65
+ personaId: picked?.id || '',
53
66
  blocked: modeFrom === 'default'
54
67
  ? '注入是关的:请求原样放行。按右侧「开始注入」才会改写请求'
55
68
  : '当前模式是 off,请求原样放行',
56
69
  }
57
70
  }
58
71
 
59
- const byId = new Map()
60
- for (const e of entries) if (e && typeof e.id === 'string' && !byId.has(e.id)) byId.set(e.id, e)
61
- const personas = entries.filter((e) => e.kind === 'persona')
62
-
63
72
  let personaId = ''
64
73
  let personaFrom = ''
65
74
  let missingPersona = ''