dsh-fish-soul 0.13.5 → 0.13.6

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  让一个 QQ 小号背后有"同一个人":固定人格、按人记记忆、有自己的生活节奏、会主动开口;同一个"她"同时出现在 QQ、B站、抖音。
4
4
 
5
- DSH 插件(单角色 `feiyu`)。版本 **0.13.5**。
5
+ DSH 插件(单角色 `feiyu`)。版本 **0.13.6**。
6
6
 
7
7
  ## 能力
8
8
 
@@ -207,16 +207,19 @@ window.__ModuleLoader__.load({
207
207
  const [data, setData] = useLoad(api, "/persona/state");
208
208
  const [open, setOpen] = react.useState(null);
209
209
  const [editing, setEditing] = react.useState(null);
210
- const [fresh, setFresh] = react.useState(true);
210
+ const [fresh, setFresh] = react.useState(null);
211
211
  const [busy, setBusy] = react.useState(false);
212
212
  const fileRef = react.useRef(null);
213
213
  if (data === null) return Empty(Dot("ongoing"));
214
214
  if (data.error) return h("div", { className: "fs-notice", role: "alert" }, h("b", null, "人格读不到"), h("span", null, data.error));
215
215
  const cur = data.current ?? {};
216
+ // 开关跟着人走(服务端 kv 持久化),进页面带回来;没到手的写入前不发请求
217
+ const freshOn = fresh ?? data.freshDefault === true;
218
+ const toggleFresh = (on) => { setFresh(on); api("POST", "/persona/fresh", { enabled: on === true }); };
216
219
 
217
220
  async function post(path, body, okText) {
218
221
  setBusy(true);
219
- const r = await api("POST", path, { ...body, fresh });
222
+ const r = await api("POST", path, { ...body, fresh: freshOn });
220
223
  setBusy(false);
221
224
  if (r?.ok) { setData(r); setEditing(null); notify(okText(r)); } else notify(r?.error ?? "保存失败");
222
225
  return r?.ok === true;
@@ -273,8 +276,8 @@ window.__ModuleLoader__.load({
273
276
  Button({ onClick: () => fileRef.current?.click(), disabled: busy }, "导入角色卡"),
274
277
  cur.card ? Button({ variant: "ghost", onClick: exportCard }, "导出") : null,
275
278
  h("input", { ref: fileRef, type: "file", accept: ".json,.png,application/json,image/png", hidden: true, onChange: pickFile })),
276
- Row({ title: "正在聊的也马上换", desc: fresh ? "下一条消息起开新会话,旧聊天的口吻不带过来;记忆和关系都还在" : "沿用旧会话:新人格下一轮生效,但口吻可能要几轮才转过来" },
277
- h(Switch, { label: "正在聊的也马上换", checked: fresh, onChange: setFresh }))),
279
+ Row({ title: "正在聊的也马上换", desc: freshOn ? "下一条消息起开新会话,旧聊天的口吻不带过来;记忆和关系都还在" : "沿用旧会话:新人格下一轮生效,但口吻可能要几轮才转过来" },
280
+ h(Switch, { label: "正在聊的也马上换", checked: freshOn, onChange: toggleFresh }))),
278
281
  Group({ title: "人格模板", aside: Muted("都是 SillyTavern V2 卡,换上以后还能接着改") },
279
282
  ...(data.templates ?? []).map((t) => h(Template, {
280
283
  key: t.id, t, h, ui, open: open === t.id, current: cur.template === t.id && cur.source === "persona.json",
@@ -4,7 +4,7 @@
4
4
  * 还有「她慢慢长出来的变化」(growth.js):看 / 确认 / 删 / 自己加 / 清空 / 开关。
5
5
  * 换完立刻热加载(下一轮就用新人格);fresh = 正在聊的聊天下一条消息起开新会话(记忆在 soul.db,不受影响)。
6
6
  */
7
- import { fishSoulDir, setKv } from './db.js';
7
+ import { fishSoulDir, getKv, setKv } from './db.js';
8
8
  import { editGrowth, growthConfig, growthState } from './growth.js';
9
9
  import { PERSONA_TEMPLATES, personaTemplate } from './persona-templates.js';
10
10
  import { canUndoPersona, normalizeCard, parsePngCard, readPersonaCard, savePersonaCard, undoPersona } from './persona.js';
@@ -32,6 +32,7 @@ export async function handlePersonaRoute({ method, path, req, send, readBody, sa
32
32
  },
33
33
  templates: PERSONA_TEMPLATES.map(({ id, title, tagline, tags, card }) => ({ id, title, tagline, tags, card })),
34
34
  canUndo: canUndoPersona(dir),
35
+ freshDefault: getKv(db, 'persona.freshDefault', false) === true,
35
36
  growth: { config: growthConfig(getConfig().growth), items: growthState(db) }
36
37
  };
37
38
  };
@@ -44,6 +45,19 @@ export async function handlePersonaRoute({ method, path, req, send, readBody, sa
44
45
 
45
46
  if (path === '/persona/state' && method === 'GET') { send(200, state()); return true; }
46
47
 
48
+ // 「正在聊的也马上换」开关:跟着人走(存 kv),不是跟着这次打开的页面走
49
+ if (path === '/persona/fresh' && method === 'POST') {
50
+ if (!guard()) return true;
51
+ try {
52
+ const b = await body();
53
+ setKv(db, 'persona.freshDefault', b.enabled === true);
54
+ send(200, state());
55
+ } catch (error) {
56
+ send(400, { ok: false, error: String(error instanceof Error ? error.message : error) });
57
+ }
58
+ return true;
59
+ }
60
+
47
61
  if (path === '/persona/apply' && method === 'POST') {
48
62
  if (!guard()) return true;
49
63
  let card;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-fish-soul",
3
- "version": "0.13.5",
3
+ "version": "0.13.6",
4
4
  "description": "鱼 · 人格、按人记忆(可纠正、有印象、能导入旧聊天记录)、日程自走与主动开口,直连 SnowLuma 收发 QQ(群里会自己插话),B站 / 抖音小号私信与自己刷视频;按功能选模型并统计用量花费,能听会说 QQ 语音、收藏表情包、学群里的梗,可选上网查;心情影响说话、去 AI 味、每个群的设定、按聊天选模型、每晚写日记(DSH 插件,单角色 feiyu)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",