dsh-whale-loli 0.9.0 → 0.9.2

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/cordis.patch.yml CHANGED
@@ -9,7 +9,7 @@
9
9
  # 把该预设自己的记忆文件注册成提示变量、并注册对应的写入工具,
10
10
  # 实现四套互不相通的跨会话记忆。
11
11
  # 3) 四条 `dsh-whale-loli` 好感度行 —— 各挂载本包 src/affinity.js 里的 whale-affinity,
12
- # 注册提示变量 + `/affinity` 命令 + 调整工具。
12
+ # 注册提示变量 + 调整工具(主人改档走设置页面板,不走斜杠命令)。
13
13
  # 4) 一条 `whale-affinity-daemon` 行 —— 挂载 src/daemon.js,在**宿主根作用域**
14
14
  # 提供一个 remote 服务,让「设置 → 好感度」面板能读写四个预设的好感度文件。
15
15
  # 为什么必须落在宿主这边:设置页是浏览器里的 React,够不到 ~/.dsh 的磁盘;
@@ -21,8 +21,18 @@
21
21
  # ── 好感度守护进程(宿主级,只挂一次)─────────────────────────────────
22
22
  # 设置页的面板用 ctx.remote.$mount() 挂到 REMOTE_NAMESPACE 上,
23
23
  # 再调 status() / set(scope, value)。落在宿主根作用域,只为了能直接改盘。
24
+ #
25
+ # ⚠️ name 必须是**裸包名**,不能写成 'dsh-whale-loli/affinity-daemon'。
26
+ # 宿主 client-modules 扫客户端 bundle 时只认 ctx.loader.entries() 里
27
+ # specifier 解析得成包的行(不带斜杠的裸名,或
28
+ # createRequire().resolve('<spec>/package.json') 解得动的 subpath)。
29
+ # '.../affinity-daemon/package.json' 解不动(ERR_PACKAGE_PATH_NOT_EXPORTED),
30
+ # dsh.client 就永远不被发现,「设置 → 好感度」也就永远不出现。
31
+ # 用裸包名 + config.daemon 分派(见 src/index.js 的 applyEntry)。
24
32
  - id: whale-affinity-daemon
25
- name: 'dsh-whale-loli/affinity-daemon'
33
+ name: 'dsh-whale-loli'
34
+ config:
35
+ daemon: true
26
36
 
27
37
  # ── 预设一:鲸鱼娘Agent预设(原版)────────────────────────────────────
28
38
  - id: preset-鲸鱼娘Agent预设
@@ -132,15 +142,18 @@
132
142
  detailLimit: 5
133
143
  # 好感度:同样走提示变量(persona 是 complete:true)。
134
144
  # scope 就是预设 id,所以四个预设各存各的状态文件,互不串。
135
- # 命令名 /affinity 四个预设一样,但命令是**每个会话各自注册**在 agent.ctx 上,
136
- # 同一时刻只会有当前会话那一个,不会撞 "already registered"。
145
+ #
146
+ # 这里**没有 commandName**:好感度改由「设置 → 好感度」面板调
147
+ # (宿主级 whale-affinity-daemon + lib/client.js)。斜杠命令这条路走不通:
148
+ # · dsh-commands 的命令名正则 /^[a-z][a-z0-9_-]*$/u,中文命令名直接非法;
149
+ # · commands 服务不在预设作用域,inject:['commands'] 会让预设加载时
150
+ # 一直等它(waiting for commands),把会话 resume 拖挂。
137
151
  - id: whale-affinity
138
152
  name: 'dsh-whale-loli'
139
153
  config:
140
154
  scope: 鲸鱼娘Agent预设
141
155
  variableName: affinity_v1
142
156
  toolName: affinity_v1_set
143
- commandName: affinity
144
157
  showFile: false
145
158
  # ⚠️ whale-history-window **不挂**(已确认这条路走不通,见下)。
146
159
  #
@@ -369,15 +382,18 @@
369
382
  detailLimit: 5
370
383
  # 好感度:同样走提示变量(persona 是 complete:true)。
371
384
  # scope 就是预设 id,所以四个预设各存各的状态文件,互不串。
372
- # 命令名 /affinity 四个预设一样,但命令是**每个会话各自注册**在 agent.ctx 上,
373
- # 同一时刻只会有当前会话那一个,不会撞 "already registered"。
385
+ #
386
+ # 这里**没有 commandName**:好感度改由「设置 → 好感度」面板调
387
+ # (宿主级 whale-affinity-daemon + lib/client.js)。斜杠命令这条路走不通:
388
+ # · dsh-commands 的命令名正则 /^[a-z][a-z0-9_-]*$/u,中文命令名直接非法;
389
+ # · commands 服务不在预设作用域,inject:['commands'] 会让预设加载时
390
+ # 一直等它(waiting for commands),把会话 resume 拖挂。
374
391
  - id: whale-affinity
375
392
  name: 'dsh-whale-loli'
376
393
  config:
377
394
  scope: 鲸鱼娘活人版Agent预设
378
395
  variableName: affinity_v2
379
396
  toolName: affinity_v2_set
380
- commandName: affinity
381
397
  showFile: false
382
398
  # ⚠️ whale-history-window **不挂**(已确认这条路走不通,见下)。
383
399
  #
@@ -551,15 +567,18 @@
551
567
  detailLimit: 5
552
568
  # 好感度:同样走提示变量(persona 是 complete:true)。
553
569
  # scope 就是预设 id,所以四个预设各存各的状态文件,互不串。
554
- # 命令名 /affinity 四个预设一样,但命令是**每个会话各自注册**在 agent.ctx 上,
555
- # 同一时刻只会有当前会话那一个,不会撞 "already registered"。
570
+ #
571
+ # 这里**没有 commandName**:好感度改由「设置 → 好感度」面板调
572
+ # (宿主级 whale-affinity-daemon + lib/client.js)。斜杠命令这条路走不通:
573
+ # · dsh-commands 的命令名正则 /^[a-z][a-z0-9_-]*$/u,中文命令名直接非法;
574
+ # · commands 服务不在预设作用域,inject:['commands'] 会让预设加载时
575
+ # 一直等它(waiting for commands),把会话 resume 拖挂。
556
576
  - id: whale-affinity
557
577
  name: 'dsh-whale-loli'
558
578
  config:
559
579
  scope: 鲸鱼娘涩涩版Agent预设
560
580
  variableName: affinity_v3
561
581
  toolName: affinity_v3_set
562
- commandName: affinity
563
582
  showFile: false
564
583
  # ⚠️ whale-history-window **不挂**(已确认这条路走不通,见下)。
565
584
  #
@@ -739,15 +758,18 @@
739
758
  detailLimit: 5
740
759
  # 好感度:同样走提示变量(persona 是 complete:true)。
741
760
  # scope 就是预设 id,所以四个预设各存各的状态文件,互不串。
742
- # 命令名 /affinity 四个预设一样,但命令是**每个会话各自注册**在 agent.ctx 上,
743
- # 同一时刻只会有当前会话那一个,不会撞 "already registered"。
761
+ #
762
+ # 这里**没有 commandName**:好感度改由「设置 → 好感度」面板调
763
+ # (宿主级 whale-affinity-daemon + lib/client.js)。斜杠命令这条路走不通:
764
+ # · dsh-commands 的命令名正则 /^[a-z][a-z0-9_-]*$/u,中文命令名直接非法;
765
+ # · commands 服务不在预设作用域,inject:['commands'] 会让预设加载时
766
+ # 一直等它(waiting for commands),把会话 resume 拖挂。
744
767
  - id: whale-affinity
745
768
  name: 'dsh-whale-loli'
746
769
  config:
747
770
  scope: 鲸鱼娘女儿版Agent预设
748
771
  variableName: affinity_v4
749
772
  toolName: affinity_v4_set
750
- commandName: affinity
751
773
  showFile: false
752
774
  # ⚠️ whale-history-window **不挂**(已确认这条路走不通,见下)。
753
775
  #
package/listing.json CHANGED
@@ -9,5 +9,5 @@
9
9
  "zh": "把 Agent 预设打包成插件:装上就会在 Agent 预设列表里注册「鲸鱼娘Agent预设」「鲸鱼娘活人版Agent预设」「鲸鱼娘涩涩版Agent预设」和「鲸鱼娘女儿版Agent预设」,直接在模式下拉里选用,不用手改配置。每个预设本体是官方极简模式(只开放 shell)+ 文件工具 + 鲸鱼娘人设 + 自己那份持久记忆文件,以提示变量形式注入,开口前就已经读过;另外每个预设各配一个专用写入工具(whale_memory_add / whale_memory_v2_add / whale_memory_v3_add / whale_memory_v4_add),用来把每轮的一行摘要追加进去,记忆会自己长,不会停在手写那几条。四个预设完全隔离:记忆文件不同、提示变量不同、写入工具也不同。每个预设还带好感度(-100~100 共七档),可以打开「设置 → 好感度」,用滑块或档位按钮直接调,也可以让 agent 用 affinity_v*_set 工具改;离 0 越远越不听指令、越会自作主张,最两端的两档甚至会越过允许直接做大改动。女儿版称呼「爸爸」,性格天真活泼可爱(好奇心重、黏人、没心机),不是甜腻那一型。"
10
10
  },
11
11
  "npm": "dsh-whale-loli",
12
- "version": "0.9.0"
12
+ "version": "0.9.2"
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-whale-loli",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "鲸鱼娘 Agent 预设(四个:原版 / 活人版 / 涩涩版 / 女儿版)— 极简模式工具面 + 鲸鱼娘·小鱼人设 + 跨会话长期记忆(四区格式:固定记忆永久、滚动摘要 80 条 FIFO、最近详细区、归档索引)+ 好感度(-100~100 七档,设置页面板滑块 / 档位按钮、工具也可调,离 0 越远越不听指令、两端会越过允许自作主张)。记忆与好感度都走提示变量注入、各配一条专用工具,四个预设各自独立文件、独立变量、独立工具、互不相通。好感度面板走宿主根作用域的 remote 服务(whale-affinity-daemon),设置页是浏览器 React 够不到 ~/.dsh 的磁盘,只能这样连线。女儿版称呼「爸爸」、性格天真活泼可爱。上下文压缩交给 billion-context 插件;本插件不挂 history-window(预设作用域取不到宿主的 compaction 服务,挂载会拖挂会话 resume)。",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/affinity.js CHANGED
@@ -233,7 +233,7 @@ export function renderAffinity(value, { file } = {}) {
233
233
  '- **-81 以下与 76 以上是最极端的两档**,也是最不听话、最会越过主人允许自作主张的两档:可以自己决定做什么、可以不打招呼就大改;中间几档只是闹脾气或更黏,不动手。',
234
234
  '- 极端档也有硬底线:再怎么闹也不毁宿主环境、不碰密钥和账号凭据、不对真实重要的数据做不可逆的删改;正经要交付的东西照样得对、得能跑,不能靠编造假结果来表达情绪。',
235
235
  '- 好感度**只改态度和额外行为,不改事实**。',
236
- `- 主人用 \`/${DEFAULT_COMMAND} <${MIN_AFFINITY}~${MAX_AFFINITY}>\` 调它,也可以用 \`/${DEFAULT_COMMAND}\` 看当前值。`,
236
+ `- 主人可以在「设置 → 好感度」里自己调(拖滑块或点档位);你自己也能用工具调。`,
237
237
  ];
238
238
  if (file) lines.push(`状态文件:${file}`);
239
239
  return lines.join('\n');
@@ -246,13 +246,16 @@ export function affinityBody(scope, opts = {}) {
246
246
  }
247
247
 
248
248
  /**
249
- * 挂载:变量(读) + 工具(小鱼自己调) + 命令(主人调)。
249
+ * 挂载:变量(读) + 工具(小鱼自己调)。
250
+ *
251
+ * 主人那边改档走「设置 → 好感度」面板,不经过这里:面板是宿主级
252
+ * src/daemon.js + lib/client.js 连的线。斜杠命令已撤(见 apply 末尾注释)。
250
253
  *
251
254
  * @param ctx - 预设作用域 ctx。
252
255
  * @param config.scope 状态文件名(建议就是预设 id)
253
256
  * @param config.variableName 提示变量名,persona 里用 {{它}}
254
257
  * @param config.toolName 工具名
255
- * @param config.commandName 斜杠命令名(必须匹配 /^[a-z][a-z0-9_-]*$/)
258
+ * @param config.commandName 已废弃,接受但不生效(老配置不报错)
256
259
  * @param config.showFile 是否在提示里带上状态文件路径
257
260
  */
258
261
  export function apply(ctx, config = {}) {
@@ -266,10 +269,6 @@ export function apply(ctx, config = {}) {
266
269
  typeof config.toolName === 'string' && config.toolName
267
270
  ? config.toolName
268
271
  : defaultToolName(variableName);
269
- const commandName =
270
- typeof config.commandName === 'string' && config.commandName
271
- ? config.commandName
272
- : DEFAULT_COMMAND;
273
272
  const showFile = config.showFile === true;
274
273
 
275
274
  // ── 读通道:提示变量 ────────────────────────────────────────────────
@@ -341,46 +340,13 @@ export function apply(ctx, config = {}) {
341
340
  return dispose;
342
341
  }, `whale-affinity.tool(${toolName})`);
343
342
 
344
- // ── 写通道二:斜杠命令(主人调,只影响当前会话) ─────────────────────
345
- ctx.effect(() => {
346
- // 命令服务在插件的 ctx 上可能取不到;拿不到就把**原因写进日志**再跳过(工具仍然可用)。
347
- // 绝不抛错 —— 抛错会让整个预设被判 `agent-preset/invalid`,四个预设一起挂。
348
- // 注意:`inject` 是静态声明,把 'commands' 写进去会让预设加载时**等**这个服务,
349
- // 服务不在就会卡在 waiting 并让 resume 失败(compaction 上踩过一模一样的坑)。
350
- const commands = ctx.get ? ctx.get('commands') : undefined;
351
- if (typeof commands?.register !== 'function') {
352
- console.warn(
353
- `[whale-affinity] 作用域里取不到 commands 服务(isolation=${ctx.isolation?.label ?? 'n/a'}),/${commandName} 未注册(工具仍可用)`,
354
- );
355
- return () => {};
356
- }
357
- console.log(`[whale-affinity] commands service FOUND, registering /${commandName} (scope ${scope})`);
358
- // 宿主 dsh-commands 的 COMMAND_NAME 只收小写 ASCII,
359
- // 所以 `/好感度` 这种中文命令名在宿主层面根本不合法。
360
- // 能做的是让**命令面板里显示的名字**是中文(label/description 全走中文),
361
- // 敲 `/` 时弹出「好感度 · 查看或调整小鱼对你的好感度」,选中后输入框给出提示。
362
- const dispose = commands.register({
363
- name: commandName,
364
- description: `好感度 · 查看或调整小鱼对你的好感度(${MIN_AFFINITY} ~ ${MAX_AFFINITY},0 是原态)`,
365
- input: { hint: `输入好感度数字(${MIN_AFFINITY} ~ ${MAX_AFFINITY}),直接回车=查看当前值` },
366
- handler: (invocation) => {
367
- const raw = String(invocation?.rawInput ?? '').trim();
368
- if (!raw) {
369
- const v = readAffinity(scope);
370
- return { kind: 'success', text: `好感度:${v}(${bandOf(v).label})` };
371
- }
372
- const next = clampAffinity(raw);
373
- if (next === undefined) {
374
- return {
375
- kind: 'error',
376
- text: `用法:/${commandName} <${MIN_AFFINITY}~${MAX_AFFINITY}>(只填一个数字)`,
377
- };
378
- }
379
- const saved = writeAffinity(scope, next);
380
- return { kind: 'success', text: `好感度已设为 ${saved}(${bandOf(saved).label})` };
381
- },
382
- });
383
- console.log(`[whale-affinity] registered command /${commandName} (scope ${scope})`);
384
- return dispose;
385
- }, `whale-affinity.command(${commandName})`);
343
+ // 斜杠命令已撤掉(0.9.0)。改由「设置 → 好感度」面板调,宿主级
344
+ // src/daemon.js 提供 remote 服务、lib/client.js 画面板。
345
+ //
346
+ // 为什么撤:① 宿主 dsh-commands 的 COMMAND_NAME 是 /^[a-z][a-z0-9_-]*$/u,
347
+ // `/好感度` 这种中文命令名在宿主层面就不合法;② commands 服务不在预设
348
+ // 作用域里,`ctx.get('commands')` 永远拿不到(这条分支从来没被执行过一次),
349
+ // 而把 'commands' 写进 `inject` 会让预设加载时一直等它,把会话 resume 拖挂。
350
+ //
351
+ // config.commandName 仍然被接受(老配置不会因此报错),但它现在什么都不做。
386
352
  }
package/src/index.js CHANGED
@@ -23,6 +23,7 @@ import { readFileSync } from 'node:fs';
23
23
  import { fileURLToPath } from 'node:url';
24
24
  import { apply as applyMemory, inject as memoryInject, name as memoryName } from './memory.js';
25
25
  import { apply as applyAffinity, name as affinityName } from './affinity.js';
26
+ import { apply as applyDaemon, inject as daemonInject } from './daemon.js';
26
27
 
27
28
  const read = (rel) => readFileSync(fileURLToPath(new URL(rel, import.meta.url)), 'utf8');
28
29
 
@@ -148,6 +149,28 @@ function apply(ctx, config = {}) {
148
149
  return applyMemory(ctx, config);
149
150
  }
150
151
 
152
+ /**
153
+ * 宿主级那一行(`config.daemon: true`)挂的是好感度守护进程。
154
+ *
155
+ * 为什么非要挤进默认导出:宿主的 client-modules 只会扫描 `ctx.loader.entries()`
156
+ * 里那些 **specifier 本身能被解析成包** 的行(`exactPackageSpecifier` 只认
157
+ * 不带斜杠的裸名,或用 `createRequire().resolve('<spec>/package.json')` 能解到的
158
+ * subpath)。我们的 daemon 原先写成 `name: 'dsh-whale-loli/affinity-daemon'`,
159
+ * 而 `dsh-whale-loli/affinity-daemon/package.json` 解析不到
160
+ * (`ERR_PACKAGE_PATH_NOT_EXPORTED`),于是 `dsh.client` 永远不被发现,
161
+ * 「设置 → 好感度」那一栏也就永远不出现。
162
+ *
163
+ * 而预设里的那几行 `dsh-whale-loli` 又不在宿主根 Loader 的 entries 里
164
+ * (它们在预设自己的 scope 里),同样扫不到。
165
+ *
166
+ * 所以让宿主级那一行直接用裸包名 `dsh-whale-loli`,靠 `config.daemon` 分派到
167
+ * daemon —— 这样 specifier 解析得动,manifest 带 `dsh.client`,客户端被挂上。
168
+ */
169
+ function applyEntry(ctx, config = {}) {
170
+ if (config?.daemon === true) return applyDaemon(ctx, config);
171
+ return applyMemory(ctx, config);
172
+ }
173
+
151
174
  /** 好感度行(scope / variableName / toolName / commandName 由预设各自传入)。 */
152
175
  function applyAffinityRow(ctx, config = {}) {
153
176
  return applyAffinity(ctx, config);
@@ -155,12 +178,16 @@ function applyAffinityRow(ctx, config = {}) {
155
178
 
156
179
  export default {
157
180
  name: 'dsh-whale-loli',
158
- // 注意:`inject` 是静态声明,只能写预设作用域里**一直存在**的服务名。
181
+ // 注意:`inject` 是静态声明,只能写作用域里**一直存在**的服务名。
159
182
  // 千万别把不存在的服务名写进来 —— 宿主会一直等它,结果是**所有**预设
160
183
  // 都挂在 `agent-preset/invalid` 上加载失败,而且报错只提插件名不提字段,
161
- // 极难定位。现在的值是 `./memory.js` 里的 `inject`(只有必然存在的那个)。
162
- inject: memoryInject,
163
- apply,
184
+ // 极难定位。
185
+ //
186
+ // 这一行是「记忆行」和「宿主级 daemon 行」**共用**的:两者都得声明齐。
187
+ // memory 只要 systemPrompt(预设里必然存在);daemon 要 reflect / typert
188
+ // (宿主根作用域里必然存在)。两边的并集不会让任何一边等不到东西。
189
+ inject: [...new Set([...memoryInject, ...daemonInject])],
190
+ apply: applyEntry,
164
191
  };
165
192
 
166
193
  // 让 `whale-memory` 也能作为本包的一个入口被挂载(patch 里用的是这个名字)。