cortico-world-humanize 0.1.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ - 搭配「活人感 provider」0.2.0:装上 provider 重启就进入 provider 模式,不用再到「模型」页新建、切换端点。
6
+ - 还在用 0.1.0 时手动新建的「活人感」端点的,World 页会提示可以切回原来的端点;只有这种情况,卸载 provider 前才需要先切回去。
7
+ - 和 provider 之间的桥升到第 3 版:要和 `cortico-provider-humanize` 0.2.0 一起用。版本对不上时退回「先感受再开口」,不出错。
8
+
3
9
  ## 0.1.0
4
10
 
5
11
  第一个公开版本。
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  ## 安装
13
13
 
14
- 1. Coopanion 的「扩展」页搜 `cortico-world-humanize` 或「活人感」,安装。
14
+ 1. Coopanion 的「扩展」页搜「活人感」,安装 `cortico-world-humanize`。推荐把 `cortico-provider-humanize` 也装上(可选,装上就生效,不用设置)。
15
15
  2. 重启 Coopanion。
16
16
  3. World 页打开「活人感」。
17
17
 
@@ -35,7 +35,7 @@
35
35
 
36
36
  | 方式 | 什么时候 | 效果 |
37
37
  |---|---|---|
38
- | **provider 模式** | 装了活人感 provider,并把当前端点切到它包着的那个 | provider 在主模型请求发出前等心事,塞进请求再发。一轮就带着心事开口,最推荐 |
38
+ | **provider 模式** | 装了活人感 provider(装上就自动包住你现在用的端点) | provider 在主模型请求发出前等心事,塞进请求再发。一轮就带着心事开口,最推荐 |
39
39
  | 先感受再开口(默认) | 没用 provider | 桌宠先调用 `humanize_feel`,工具等副 API 想好再交回去。每次都赶得上,但主模型多一轮 |
40
40
  | 抢时间 | 没用 provider,且关掉「先感受再开口」 | 心事作为事件推进去,桌宠已经开口就作废 |
41
41
 
@@ -86,7 +86,7 @@ Coopanion 重启后沿用旧的系统前缀。换了模式或者活人感更新
86
86
  ## 停用和卸载
87
87
 
88
88
  - **暂时不用**:World 页关掉「活人感」。Coopanion 会立刻重建系统前缀,环境说明和 `humanize_feel` 工具一起拿掉。
89
- - **卸载**:用了 provider 的话,**先在「模型」页把当前端点切回原来那个**,再在「扩展」页卸掉两个包,然后重启。不切回去就卸 provider,桌宠会说不了话。
89
+ - **卸载**:在「扩展」页卸掉两个包,然后重启。只有一种情况要先做一步:你用 0.1.0 时在「模型」页新建过「活人感」端点,而且当前端点还是它,那要**先把当前端点切回原来那个**,不然卸掉 provider 后桌宠会说不了话。
90
90
  - **清干净**:想连数据一起去掉,删掉上面「数据和隐私」里列的两个文件夹和配置段即可。
91
91
 
92
92
  ## 开发
@@ -109,4 +109,4 @@ MIT
109
109
 
110
110
  **Humanize** is a Cortico World for the Coopanion desktop pet. When someone talks to the pet, it reads the situation, the person's mood and the pet's own persona and memory files, and hands the pet a short inner thought before it answers. It also watches the pet's recent lines for stock AI sentence patterns ("not X but Y", parroting the other person's words back, either-or questions, aphorisms, and similar) and reminds the pet to say it another way when one shows up. It only targets sentence patterns: catchphrases, tone and length are left to the character.
111
111
 
112
- Install it from Coopanion's Extensions page, restart, and turn it on in the World page. It works best together with [cortico-provider-humanize](https://github.com/abbabanana/cortico-provider-humanize), which puts the inner thought straight into the main model's request. Prompts, presets and detection are Chinese only for now. Licensed under MIT.
112
+ Install it from Coopanion's Extensions page, restart, and turn it on in the World page. It works best together with [cortico-provider-humanize](https://github.com/abbabanana/cortico-provider-humanize), which puts the inner thought straight into the main model's request; install it and restart, there is nothing to configure. Prompts, presets and detection are Chinese only for now. Licensed under MIT.
package/describe.json CHANGED
@@ -29,8 +29,8 @@
29
29
  {
30
30
  "type": "humanize.notice",
31
31
  "description": {
32
- "zh": "请桌宠转告对方的提醒:换了模式或扩展更新后,系统前缀需要刷新;切到 provider 端点后,卸载前要先切回原端点。每种变化一次。",
33
- "en": "A reminder the pet passes on: the system prefix needs a refresh after a mode change or an update; with the provider endpoint active, switch back before uninstalling it. Once per change."
32
+ "zh": "请桌宠转告对方的提醒:换了模式或扩展更新后,系统前缀需要刷新;还在用旧版「活人感」端点时,卸载 provider 前要先切回原端点。每种变化一次。",
33
+ "en": "A reminder the pet passes on: the system prefix needs a refresh after a mode change or an update; on a legacy Humanize endpoint, switch back before uninstalling the provider. Once per change."
34
34
  },
35
35
  "trigger": "flush"
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-humanize",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "Cortico World for Coopanion: before the pet answers, reads the situation, mood and the pet's own memory and hands it a short inner thought, and reminds it when it slips into stock AI sentence patterns",
6
6
  "author": "abbabanana",
@@ -23,11 +23,11 @@
23
23
  "locales": {
24
24
  "zh": {
25
25
  "displayName": "活人感",
26
- "description": "桌宠开口前,先读一下情境、心情和它自己的记忆,递给它一句「此刻心里的想法」;它要是用了「不是……而是……」、先复述你的话这类 AI 固定句式,下次就提醒它换个说法。口癖、语气、长短都不碰。搭配「活人感 provider」效果最好。"
26
+ "description": "让桌宠开口前先「想一想」,说话更像个人,少一点 AI 腔。单独装就能用,搭配「活人感 provider」更快。\n\n**它做什么**\n\n- 你对桌宠说话时,先读一下情境、你的心情和桌宠自己的记忆,递给它一句「此刻心里的想法」,再让它开口。\n- 桌宠要是用了「不是……而是……」、先复述你的话这类 AI 固定句式,下次就提醒它换个说法。口癖、语气、长短都不碰。\n\n**两个扩展怎么配合**\n\n- **活人感**(就是本扩展,必装):负责想心事、查句式。单独装就能用。\n- **活人感 provider**(可选,推荐):把心事直接放进发给模型的请求里。不装的话,桌宠每次要先调一次工具读心事再开口,多跑一轮,稍慢一点。\n- 只装 provider、不装本扩展,没有任何作用。\n\n**怎么用**\n\n1. 在扩展页装上本扩展,推荐把「活人感 provider」一起装上。\n2. 重启 Coopanion。\n3. 到 World 页打开「活人感」。\n\n主模型用的是 DeepSeek 的话,什么都不用填。用别家的话,在活人感的「配置 → 副 API」里填地址、模型和 Key。\n\n如果活人感已经开着、之后才装 provider,World 页会提示「系统前缀需要刷新」:把活人感关掉再打开一次就好,聊天记录会保留。\n\n**要知道的**\n\n- 你每说一句话,会多调用一次副 API(默认 DeepSeek,约 1–2 秒,花费很少)。\n- 默认读桌宠、控制台、QQ 私聊和 @桌宠的消息。QQ 群里别人的话会经过副 API 影响心事,介意的话可以在配置里关掉。\n- 只支持中文,目前只在 Windows + DeepSeek 上测过。\n- 不想用了:World 页关掉即可。卸载:扩展页卸掉,重启。"
27
27
  },
28
28
  "en": {
29
29
  "displayName": "Humanize",
30
- "description": "Before the pet answers, reads the situation, mood and the pet's own memory and hands it a short inner thought; when it slips into stock AI sentence patterns (\"not X but Y\", parroting your words back), it is reminded to say it another way next time. Catchphrases, tone and length are left alone. Works best with the Humanize provider."
30
+ "description": "Lets the pet think for a moment before it speaks, so it sounds more like a person and less like an AI. Works on its own; faster with the Humanize provider.\n\n**What it does**\n\n- When you talk to the pet, it reads the situation, your mood and the pet's own memory, and hands the pet a short inner thought before it answers.\n- When the pet slips into stock AI sentence patterns (\"not X but Y\", parroting your words back), it is reminded to say it another way next time. Catchphrases, tone and length are left alone.\n\n**How the two extensions fit together**\n\n- **Humanize** (this one, required): writes the inner thought and checks sentence patterns. Works on its own.\n- **Humanize provider** (optional, recommended): puts the thought straight into the request sent to the model. Without it, the pet first calls a tool to read the thought, which costs one extra round.\n- The provider alone does nothing.\n\n**Getting started**\n\n1. Install this extension on the Extensions page, ideally together with the Humanize provider.\n2. Restart Coopanion.\n3. Turn on Humanize on the World page.\n\nIf your main model is DeepSeek, there is nothing to fill in. Otherwise enter the address, model and key under Config → Side API.\n\n**Good to know**\n\n- Each message you send adds one side-API call (DeepSeek by default, about 1–2 seconds, very cheap).\n- Prompts, presets and pattern checks are Chinese only. Tested on Windows with DeepSeek only.\n- To stop: turn it off on the World page. To uninstall: remove it on the Extensions page and restart."
31
31
  }
32
32
  },
33
33
  "tags": ["companion", "internal-state", "qq", "im", "high-cost", "injection-risk", "experimental"],
package/src/bridge.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  /**
2
- * World 与「活人感」provider 之间的桥:两个包装在同一个进程里,靠 globalThis 上一个约定好的
3
- * Symbol 碰头,谁也不 import 谁。World 启动时挂上,停用时摘掉;provider 找不到桥就原样转发。
2
+ * World 与「活人感」provider 之间的桥:两个包装在同一个进程里,靠 globalThis 上约定好的
3
+ * Symbol 碰头,谁也不 import 谁。
4
+ * - BRIDGE_KEY:World 启动时挂上,停用时摘掉;provider 找不到就原样转发。
5
+ * - PROVIDER_KEY:provider 加载时挂上,说明它包住了哪些端点模块;World 据此判断走不走 provider 模式。
4
6
  * 改这里的形状要同时改 cortico-provider-humanize/src/bridge.ts,并把 version 加一。
5
7
  */
6
8
  export const BRIDGE_KEY = Symbol.for('cortico-humanize.bridge');
7
- export const BRIDGE_VERSION = 2;
9
+ export const PROVIDER_KEY = Symbol.for('cortico-humanize.provider');
10
+ export const BRIDGE_VERSION = 3;
8
11
 
9
12
  /** 主模型这次请求里看到的东西,provider 原样转述(已截短)。 */
10
13
  export interface MainContext {
@@ -28,6 +31,13 @@ export interface HumanizeBridge {
28
31
  touch(): void;
29
32
  }
30
33
 
34
+ /** provider 挂的牌子。 */
35
+ export interface ProviderMarker {
36
+ version: typeof BRIDGE_VERSION;
37
+ /** 这种端点模块(端点配置里的 kind)是不是被活人感包着。 */
38
+ wraps(kind: string): boolean;
39
+ }
40
+
31
41
  export function installBridge(bridge: HumanizeBridge): void {
32
42
  (globalThis as Record<symbol, unknown>)[BRIDGE_KEY] = bridge;
33
43
  }
@@ -36,3 +46,9 @@ export function removeBridge(bridge: HumanizeBridge): void {
36
46
  const g = globalThis as Record<symbol, unknown>;
37
47
  if (g[BRIDGE_KEY] === bridge) delete g[BRIDGE_KEY];
38
48
  }
49
+
50
+ /** 装着的、版本对得上的 provider;没有给 null。 */
51
+ export function providerMarker(): ProviderMarker | null {
52
+ const m = (globalThis as Record<symbol, unknown>)[PROVIDER_KEY] as ProviderMarker | undefined;
53
+ return m && m.version === BRIDGE_VERSION && typeof m.wraps === 'function' ? m : null;
54
+ }
package/src/config.ts CHANGED
@@ -175,7 +175,7 @@ export function configGroups(keyStatus: string, notes: string[] = [], seen: Seen
175
175
  },
176
176
  [`${K}.notify`]: {
177
177
  type: 'boolean', title: '前缀需要刷新时让桌宠提醒我', 'x-hot': true,
178
- description: '换了模式(比如切到 provider 端点、开关「先感受再开口」),或者活人感更新了说明之后,桌宠会用气泡说一次。每种变化只提醒一次。',
178
+ description: '换了模式(比如装上或卸掉 provider、开关「先感受再开口」),或者活人感更新了说明之后,桌宠会用气泡说一次。每种变化只提醒一次。',
179
179
  },
180
180
  [`${K}.autoRefresh`]: {
181
181
  type: 'boolean', title: '前缀需要刷新时自动刷新', 'x-hot': true,
package/src/definition.ts CHANGED
@@ -35,8 +35,8 @@ export const HUMANIZE: WorldDefinition<HumanizeConfigSection> = {
35
35
  }, {
36
36
  type: NOTICE_EVENT,
37
37
  description: {
38
- zh: '请桌宠转告对方的提醒:换了模式或扩展更新后,系统前缀需要刷新;切到 provider 端点后,卸载前要先切回原端点。每种变化一次。',
39
- en: 'A reminder the pet passes on: the system prefix needs a refresh after a mode change or an update; with the provider endpoint active, switch back before uninstalling it. Once per change.',
38
+ zh: '请桌宠转告对方的提醒:换了模式或扩展更新后,系统前缀需要刷新;还在用旧版「活人感」端点时,卸载 provider 前要先切回原端点。每种变化一次。',
39
+ en: 'A reminder the pet passes on: the system prefix needs a refresh after a mode change or an update; on a legacy Humanize endpoint, switch back before uninstalling the provider. Once per change.',
40
40
  },
41
41
  trigger: 'flush',
42
42
  }],
@@ -4,12 +4,14 @@
4
4
  * 改了环境说明之后,前缀会旧一阵。这里记下最近一次拼前缀时的模式和环境说明的指纹(落盘,
5
5
  * 重启也在),和此刻该有的比一比,不一样就提醒人去 World 页关开一次。
6
6
  *
7
- * provider 模式按当前端点的配置判断(部署 config.json 的 activeProvider → 那个端点的 kind),
8
- * 不看「最近有没有转发过请求」:重启后第一次拼前缀时 provider 还没转发过,看时间会误判。
7
+ * provider 模式按当前端点的配置判断(部署 config.json 的 activeProvider → 那个端点的 kind,
8
+ * 再问 provider 挂的牌子包没包这种 kind),不看「最近有没有转发过请求」:重启后第一次拼前缀时
9
+ * provider 还没转发过,看时间会误判。
9
10
  */
10
11
  import { createHash } from 'node:crypto';
11
12
  import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
12
13
  import { dirname, join } from 'node:path';
14
+ import { providerMarker } from './bridge.ts';
13
15
 
14
16
  export type Mode = 'provider' | 'tool' | 'push';
15
17
 
@@ -19,7 +21,8 @@ export const MODE_LABEL: Record<Mode, string> = {
19
21
  push: '抢时间模式(心事作为事件推送)',
20
22
  };
21
23
 
22
- const PROVIDER_KIND = 'humanize';
24
+ /** 0.1.0 时要手动新建的那种端点。 */
25
+ const LEGACY_KIND = 'humanize';
23
26
 
24
27
  interface Saved {
25
28
  prefix?: { mode: Mode; sig: string };
@@ -73,9 +76,21 @@ export class PrefixState {
73
76
  return typeof name === 'string' ? name : '';
74
77
  }
75
78
 
76
- /** 当前端点是不是「活人感」provider 包着的那种。 */
79
+ /** 当前端点的模块(kind);读不到给空串。 */
80
+ activeKind(): string {
81
+ const kind = this.endpoint.read()?.kind;
82
+ return typeof kind === 'string' ? kind : '';
83
+ }
84
+
85
+ /** 当前端点有没有被「活人感」provider 包着:装了 provider,且它包住了这种端点。 */
77
86
  providerConfigured(): boolean {
78
- return this.endpoint.read()?.kind === PROVIDER_KIND;
87
+ const kind = this.activeKind();
88
+ return !!kind && !!providerMarker()?.wraps(kind);
89
+ }
90
+
91
+ /** 当前端点是不是 0.1.0 时手动新建的那种(卸 provider 前要先切回原端点)。 */
92
+ legacyEndpoint(): boolean {
93
+ return this.activeKind() === LEGACY_KIND;
79
94
  }
80
95
 
81
96
  /** 拼前缀时记下当时的模式和指纹。 */
package/src/world.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * - 有人对桌宠说话(桌宠、控制台、适配过的 QQ 扩展、勾上的其他来源):调副 API 读情境、写一句
5
5
  * 内心引导,后面跟上「说话提醒」(桌宠最近真用过的套路句式)。交给桌宠有三条路:
6
- * - provider 模式(当前端点是「活人感」provider 包着的那个):provider 在主模型请求发出前来认领,
6
+ * - provider 模式(装了「活人感」provider,它包着当前端点):provider 在主模型请求发出前来认领,
7
7
  * 顺带递来主模型的上下文;心事想好后由它塞进请求。主模型这一轮就带着心事开口。
8
8
  * - 先感受再开口(`wait`,默认):环境提示词让模型先调用 `humanize_feel`,工具等副 API 的结果
9
9
  * 回来,把内心交回给模型,模型读完再说话。
@@ -757,8 +757,8 @@ export class HumanizeWorld implements World {
757
757
  const what = stale.from !== stale.to
758
758
  ? `换成了${MODE_LABEL[stale.to]}`
759
759
  : '更新了给桌宠的说明';
760
- const uninstall = stale.to === 'provider'
761
- ? '另外记一下:以后要卸载「活人感 provider」的话,先在「模型」页把端点切回原来那个,不然我会说不了话。'
760
+ const uninstall = stale.to === 'provider' && this.prefixState.legacyEndpoint()
761
+ ? '另外记一下:现在用的是旧版的「活人感」端点,以后要卸载「活人感 provider」的话,先在「模型」页把端点切回原来那个,不然我会说不了话。'
762
762
  : '';
763
763
  if (this.cfg.autoRefresh) {
764
764
  if (this.phase !== 'idle' || !this.prefixState.firstTime(`refresh:${key}`)) return;
@@ -808,8 +808,8 @@ export class HumanizeWorld implements World {
808
808
  if (this.cfg.voice && voice.outdated && voice.edited) {
809
809
  notes.push('人设改过了,但口吻样本是按旧人设写的(你改过它,所以没有自动重写):想按新人设重写,勾一下下面的「重写口吻样本」。');
810
810
  }
811
- if (this.prefixState.providerConfigured()) {
812
- notes.push(`当前端点「${this.prefixState.activeEndpoint()}」由活人感 provider 包着。以后要卸载 provider,先在「模型」页把端点切回原来的那个,不然桌宠会说不了话。`);
811
+ if (this.prefixState.legacyEndpoint()) {
812
+ notes.push(`当前端点「${this.prefixState.activeEndpoint()}」是旧版的「活人感」端点。现在不用它了:装着活人感 provider 时,你原来的端点会自动带上活人感。建议在「模型」页切回原来的端点;以后要卸载 provider,也一定要先切回去,不然桌宠会说不了话。`);
813
813
  }
814
814
  return notes;
815
815
  }