cortico-world-fun 0.7.5 → 0.7.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/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  市场按 `##` 标题里的版本号切段,显示在「历史版本」里。
4
4
 
5
+ ## 0.7.6
6
+
7
+ 共同决定(两席同票)的修复:**异票不再吞掉对方那一票**。没有数据迁移,故事包格式、存储键与面板 id 都不变。
8
+
9
+ - **行为变更:空票面时两席都能先投**。以前共同决定刚出现、还没有任何票时,聊天通道默认把这一票记成 `owner`,鱼先开口也会落到主人名下;现在空票面两席都能先投,`fun_story_act` 带 `as: "fish"` 就把那一票记在鱼名下。只剩一席没投时仍由那一席自己投,两票不同时两席都能改自己那一票——规则收窄成一句:**先投不限先后;一票在面时等缺的那一席;两票不同时各自可改;一致才前进**。
10
+ - **收口:规则只有一份实现**。新增 `src/joint.js`(阶段 / 该谁投 / 谁能投 / 文案的纯函数),世界、面板、`fun_story_current` 与文字通道都只从它取;规格写在 `docs/JOINT-DECISION-SPEC.md`。除上一条外没有行为变化。
11
+ - 测试:`test/story-text.test.mjs` 新增表驱动矩阵(3 种 `jointResolution` × 主人/鱼先投 × 第二票同/不同)与「被拒必须是纯拒绝」「三个入口一个答案」「面板文案跟阶段走」三组一致性用例。
12
+
13
+ - **修:两边票不一样时会静默删掉一票**。原来的异票分支「只保留后投的那一票」:主人投 A、鱼投 B 之后,主人那一票被删;主人再投,鱼的又被删——两个人只能互相清票,永远凑不出「两边一致」,面板就一直停在「现在轮到你 / 轮到鱼」,看着像卡死。现在异票时**两票都留在票面上**,谁都可以改自己那一票,改成一致才递交。
14
+ - **文字通道可以显式声明这一票是谁的**:`fun_story_act` 支持 `as: "fish"` / `"owner"`,鱼改自己那一票时不会被记到主人名下;只差一席时仍按「缺哪一席」把关,声明错了会被明确拒绝。
15
+ - **面板文案**:提示改成「两边票不一样(你:… / 鱼:…):这一轮不前进,也不清掉任何一席的票。谁都可以改自己那一票,两边一致才递交;也可以先回家。」异票时标题旁的小字显示「两边票不一样」。
16
+ - **回家仍然可用**:异票僵住时点「先回家」按已发生的片段收尾(有回归测试钉住)。
17
+ - 测试:`test/story-text.test.mjs` 新增三条——异票不吞任何一席、鱼改自己那一票不会顶掉主人、异票僵住时回得了家。
18
+ - 版本号升到 0.7.6;简介重写成产品介绍(不再逐版罗列历史,版本细节看本文件)。
19
+
5
20
  ## 0.7.5
6
21
 
7
22
  故事工坊版式收口:**一个创建入口 + 三个起点**,导入支持选文件。没有数据迁移,故事包格式、校验、隔离试玩、草稿保护与 `describe.json` 都不变。
package/README.md CHANGED
@@ -21,7 +21,7 @@
21
21
  - **出门时只读**:显示「出门中 · 某地(逛了 1/3)」,在房间里换姿势不会影响正在走的行程。
22
22
  - 素材规格、命名与十张贴图的对齐坐标见 [素材单](<E:/deep seek/素材单-鱼的家2D房间/素材单.md>)。
23
23
 
24
- ## 版本:0.4.4 → 0.7.5
24
+ ## 版本:0.4.4 → 0.7.6
25
25
 
26
26
  下游文档(用户手册、市场描述)一度停在 0.4.4,这里补一条线,细节仍以 [CHANGELOG.md](CHANGELOG.md) 为准:
27
27
 
@@ -32,6 +32,7 @@
32
32
  - **0.7.2** 是代码体检整改:六个只读故事查询加 10 分钟记忆化(重复问只回「没变化」,写操作立即失效,`full:true` 重取);工具说明与提示词瘦身(实发 schema 9,472 → 9,216,`ENV_PROMPT` 1,202 → 903);文字通道默认开,聊天里六个查询与开局推进都在,作者工具另有一个开关 `funStoryAuthorInChat`;`hmToMin` / `el()` / `feedback` 抽成共享模块,只读查询拆到 `src/story-read.js`。
33
33
  - **0.7.3** 是设置重组:故事长度、主持接口地址与模型、剧情图片来源搬进配置页(热改),旧 `story-node-limit.json` / `story-secrets.json` 密文里的地址与模型 / `story-images/settings.json` 的来源在首次启动时一次性迁移;「自动配图」开关移到出游页顶部;本地插画搬到「地点册 → 本地插画」;出游「设置」只剩「高级设置」(API Key、直连手动出图、自定义工作流)。面板 id 与页签名不变。
34
34
  - **0.7.4** 把地点册改成「左栏分组 + 右侧封面列表」:左栏「我的地点册」六项带计数(全部 / 可玩 / 只是地点 / 故事 / 我的 / 住所),「整理与设置」三项(住所与默认画风 / 本地插画 / 从小世界迁入);右栏搜索 + 分类 + 列表/卡片切换 + 封面缩略图行 + 「编辑地点」,窄屏左栏折成横向筛选。数据层、面板 id、编辑器与四个既有视图都不变。同一版把「允许她自己出门」改成只留许可:**不再有 `funHomeAutoSlots`,也不再推 `fun.home.free`**——几点算她自己的时间跟着「鱼的每一天」的「她自己的时间」走,那边叫醒她时她再按日程决定出不出门。`describe.json` 因此从 1 个事件变成 0 个。
35
+ - **0.7.6** 修共同决定(两席同票):异票时不再「只保留后投的那一票」,两票都留在票面上;空票面时两席都能先投,只剩一席没投时仍等那一席自己投,两票不一样时两席都能改自己那一票,改成一致才前进;异票僵住时也能直接回家。文字通道支持 `as: "fish"` 显式声明这一票是谁的(鱼先开口就记在她名下)。存储与故事包格式不变。
35
36
  - **0.7.5** 收掉故事工坊里重复的创建入口:标题条只留「+ 编写故事」,展开后是「选项式故事 / 自由场景包 / 从文件导入」三个起点;右侧「从一个小片段开始」栏删除(窄屏本来也看不到),「展开 / 收起」降成标题旁的小箭头。导入主路径改成选 `.json` 文件(单个 ≤ 32 KB,读完填进原文本框,可继续校验 / 预览 / 导入),粘贴保留;内容列收窄到 1040 居中。数据层、校验、隔离试玩与草稿保护不变。
36
37
  - **工具面**:共 24 个;默认只挂 23 个——文字通道默认开着,作者工具 `fun_story` 要另开「聊天里也能管故事」。关掉文字通道则只剩 17 个。六个只读故事查询有 10 分钟记忆化,同一参数重复问只回 `{ok:true, unchanged:true}` 短回执,任何写操作立即失效,`full:true` 可强制重取。
37
38
 
@@ -71,7 +72,7 @@ v2 可在高级 JSON 中附加 `references`(最多 24 条)。每条使用 `{
71
72
 
72
73
  公开只读工具为 `fun_story_places`、`fun_story_candidates`、`fun_story_detail`、`fun_story_current`、`fun_story_recap`、`fun_story_schedule`。它们不开始故事、不推进事件、不写入每一天或长期记忆;作者管理工具 `fun_story` 仍标为写权限。指定作品从故事面板明确出发,并重新验证作品版本和条件;普通 `fun_go` 不等于启动指定故事。
73
74
 
74
- v2 节点可声明 owner/fish/joint,鱼自主只控制 fish,owner 必须通过用户按钮提交;共同选择按作者声明处理分歧,等待与超时不会变成同意。单人旧故事保持兼容;0.3.3 已移除双人预设故事,不影响作者自己编写双人作品。
75
+ v2 节点可声明 owner/fish/joint,鱼自主只控制 fish,owner 必须通过用户按钮提交;共同选择按作者声明处理分歧,等待与超时不会变成同意。共同决定那一步:空票面时两席都能先投;只剩一席没投时,那一票只能由那一席自己投;两票不一样时两席都能改自己那一票,改成一致才前进。单人旧故事保持兼容;0.3.3 已移除双人预设故事,不影响作者自己编写双人作品。
75
76
 
76
77
  可选文本主持 `funStoryDM` 默认关闭。接口地址与模型名在配置页(`funStoryDmUrl` / `funStoryDmModel`,热改),API Key 在「出游 → 设置 → 高级 → 文本主持密钥」里填,是密码输入,失焦和保存后只显示掩码与「已保存 / 未设置」。地址与 Key 两项留空使用宿主 `cognition.request`;都填写则由本插件直连 OpenAI 兼容 `POST /chat/completions`(填写 `https://服务地址/v1` 或完整 `/chat/completions` 路径,不含 URL 凭据、查询或片段)。模型名按你的服务商填,例如 `deepseek-chat`、`qwen-plus`、`gpt-4o-mini`;留空则不发送 `model` 字段,由接口使用它自己的默认模型,宿主配置不受影响。仅 Windows 使用 DPAPI CurrentUser 加密密钥,密文单独保存在 `<dataDir>/fun/story-secrets.json`,地址与模型不在密文里;密钥由 Windows 用户环境保护,不与密文同文件。其他平台禁用自定义凭据保存,仍可使用宿主模型。密钥明文不进入 config/state、日志、工具回执、describe、提示词或作品导出。密钥只发送至配置里填写的接口,不发给宿主或其他插件;换机器或重装后需重填。「清除密钥」立即撤销旧请求和提议,随后删除密文;之后回到宿主模型,宿主不可用则明确提示,手动游玩始终可用。
77
78
 
package/dist/webui.js CHANGED
@@ -2569,8 +2569,9 @@ function mountPanel(root, ctx) {
2569
2569
  const pending = current.pending;
2570
2570
  const isDraft = current.state === "draft";
2571
2571
  const manually = canAct(state) && !state.snapshot.autonomy.enabled;
2572
- const ownerTurn = manually && current.actor !== "fish";
2573
- const canSubstitute = !isDraft && current.step === "choose" && !state.autoAuthorized && state.snapshot.autonomy.canSubstitute === true;
2572
+ const joint = pending?.actor === "joint" ? current.joint : null;
2573
+ const ownerTurn = manually && (joint ? joint.canVote?.owner === true : current.actor !== "fish");
2574
+ const canSubstitute = !joint && !isDraft && current.step === "choose" && !state.autoAuthorized && state.snapshot.autonomy.canSubstitute === true;
2574
2575
  const pick = async (option) => {
2575
2576
  if (!canSubstitute) return controller.mutate("choose", { choiceId: pending.id, optionId: option.id });
2576
2577
  const label2 = text(option.label, option.id);
@@ -2597,29 +2598,18 @@ function mountPanel(root, ctx) {
2597
2598
  function optionsHint(state, current, canSubstitute) {
2598
2599
  if (current.state === "draft") return "先继续行程,再选择下一步。";
2599
2600
  if (state.autoAuthorized) return "鱼正在考虑这些有效选项。你可以随时关闭右侧开关接管。";
2601
+ if (current.pending?.actor === "joint" && current.joint?.hint) return current.joint.hint;
2600
2602
  if (canSubstitute) return "鱼这一步没法自己决定:你可以替她选一个,点下去会先问你确认;也可以先收尾,或者点右侧「再来一段」。";
2601
- const pending = current.pending;
2602
- if (pending?.actor === "joint") {
2603
- const votes = pending.votes ?? {};
2604
- if (!votes.owner) return "两席各投一票,同票才出发:你先选,选完等鱼自己投她那一票。";
2605
- if (!votes.fish) return "你这一票已经记下了。这一票要鱼自己投:到聊天里让她说,或者打开右侧「鱼自己游玩」由她决定。两票相同才会前进。";
2606
- return "两边的票不一样,这一轮重新来:你可以改选,鱼也会被要求重选。同票才前进,等待不算同意。";
2607
- }
2608
2603
  return "选一条你想走的路。点击后会等待保存确认。";
2609
2604
  }
2610
- function jointBoard(pending) {
2611
- const votes = pending?.votes ?? {};
2612
- const labelOf = (id) => list(pending?.options).find((option) => option.id === id)?.label ?? "";
2613
- const seat = (who, name) => {
2614
- const picked = labelOf(votes[who]);
2615
- return node(
2616
- "div",
2617
- { class: `sw-vote${picked ? " sw-vote-done" : ""}` },
2618
- node("small", {}, name),
2619
- node("strong", {}, picked || "还没投")
2620
- );
2621
- };
2622
- return node("div", { class: "sw-votes", "aria-label": "共同决定的两席票" }, seat("owner", "你这一席"), seat("fish", "鱼那一席"));
2605
+ function jointBoard(joint) {
2606
+ const seats = list(joint?.seats);
2607
+ return node("div", { class: "sw-votes", "aria-label": "共同决定的两席票" }, seats.map((seat) => node(
2608
+ "div",
2609
+ { class: `sw-vote${seat.voted ? " sw-vote-done" : ""}` },
2610
+ node("small", {}, seat.name),
2611
+ node("strong", {}, seat.label || "还没投")
2612
+ )));
2623
2613
  }
2624
2614
  function advanceButton(state, current, opts = {}) {
2625
2615
  const manually = canAct(state) && !state.snapshot.autonomy.enabled;
@@ -2846,7 +2836,8 @@ function mountPanel(root, ctx) {
2846
2836
  const isDraft = current.state === "draft";
2847
2837
  const pending = current.pending;
2848
2838
  const manually = canAct(state) && !snapshot.autonomy.enabled;
2849
- const ownerTurn = manually && current.actor !== "fish";
2839
+ const joint = pending?.actor === "joint" ? current.joint : null;
2840
+ const ownerTurn = manually && (joint ? joint.canVote?.owner === true : current.actor !== "fish");
2850
2841
  const left = node("article", { class: "sw-card sw-play-main" });
2851
2842
  left.append(node("div", { class: "sw-play-head" }, node(
2852
2843
  "div",
@@ -2877,10 +2868,9 @@ function mountPanel(root, ctx) {
2877
2868
  reading.append(node("ul", { class: "sw-event-history" }, events.slice(-3).map((event) => node("li", {}, node("p", { class: "sw-prose" }, text(event))))));
2878
2869
  } else reading.append(node("p", { class: "sw-prose" }, current.step === "move" ? "路就在眼前。走近一点,看看会遇见什么。" : "这一趟的故事,将随着真实的行动在这里展开。"));
2879
2870
  if (current.actor) {
2880
- const joint = pending?.actor === "joint" ? pending : null;
2881
- const picked = (id) => list(joint?.options).find((option) => option.id === id)?.label ?? "";
2882
- const seats = joint ? ` · 你${joint.votes?.owner ? `已选「${picked(joint.votes.owner)}」` : "还没投"},鱼${joint.votes?.fish ? `已选「${picked(joint.votes.fish)}」` : "还没投"}` : "";
2883
- reading.append(note(`当前行动者:${current.actor === "fish" ? "鱼" : "你"}${pending?.actor === "joint" ? ` · 共同决定:${pending.jointResolution === "require-agreement" ? "双方必须明确同意;分歧保持待定" : pending.jointResolution === "owner-final" ? "分歧按你的明确选择" : "分歧按鱼的明确选择"}` : ""}${seats}。等待不会当作同意。`));
2871
+ const who = (joint?.seat ?? current.actor) === "fish" ? "鱼" : "你";
2872
+ const jointLine = joint ? ` · 共同决定:${joint.resolutionNote}${joint.seatsText ? ` · ${joint.seatsText}` : ""}` : "";
2873
+ reading.append(note(`当前行动者:${who}${jointLine}。等待不会当作同意。`));
2884
2874
  }
2885
2875
  for (const reference of list(current.references)) reading.append(note(reference));
2886
2876
  if (current.blocked) reading.append(node("div", { class: "sw-notice sw-notice-error" }, icon("info"), node("p", {}, text(current.blocked, "当前无法推进,请核对场所与故事条件。"))));
@@ -2889,12 +2879,11 @@ function mountPanel(root, ctx) {
2889
2879
  const action = node("div", { class: "sw-play-action", "aria-label": "当前这一步" });
2890
2880
  if (pending) {
2891
2881
  const { block, canSubstitute } = pendingPicker(state, current, "sw-choices");
2892
- const joint = pending.actor === "joint";
2893
- action.append(node("div", { class: "sw-kicker" }, joint && current.actor === "fish" ? "现在轮到鱼" : "现在轮到你了"));
2882
+ action.append(node("div", { class: "sw-kicker" }, joint ? joint.headline : "现在轮到你了"));
2894
2883
  if (pending.prompt) action.append(node("p", { class: "sw-prose" }, text(pending.prompt)));
2895
- if (joint) action.append(jointBoard(pending));
2884
+ if (joint) action.append(jointBoard(joint));
2896
2885
  action.append(block, note(optionsHint(state, current, canSubstitute)));
2897
- if (joint && current.actor === "fish" && canAct(state)) {
2886
+ if (joint?.seat === "fish" && canAct(state)) {
2898
2887
  action.append(actionRow(button(
2899
2888
  "刷新,看鱼投了没",
2900
2889
  () => {
@@ -2921,7 +2910,7 @@ function mountPanel(root, ctx) {
2921
2910
  const checked = state.autoplay === true;
2922
2911
  const running = state.autoAuthorized === true;
2923
2912
  const stopped = Boolean(snapshot.autonomy.stop);
2924
- const modeSubtitle = stopped ? snapshot.autonomy.canContinue ? "这一段走完了,可以再来一段" : "这一段走完了,等你收尾" : running ? "这一趟,由鱼自己决定" : checked ? current.actor === "owner" ? "轮到你选择;选完鱼会接着走" : "鱼会接着往下走" : current.actor === "fish" ? "这一步等鱼提交,可以去聊天里让她说" : "下一步,等你来选择";
2913
+ const modeSubtitle = stopped ? snapshot.autonomy.canContinue ? "这一段走完了,可以再来一段" : "这一段走完了,等你收尾" : running ? "这一趟,由鱼自己决定" : checked ? (joint?.seat ?? current.actor) === "owner" ? "轮到你选择;选完鱼会接着走" : "鱼会接着往下走" : (joint?.seat ?? current.actor) === "fish" ? "这一步等鱼提交,可以去聊天里让她说" : "下一步,等你来选择";
2925
2914
  modeCard.append(node(
2926
2915
  "div",
2927
2916
  { class: "sw-mode" },
@@ -2991,6 +2980,7 @@ function mountPanel(root, ctx) {
2991
2980
  function playImmersive(state, current) {
2992
2981
  const isDraft = current.state === "draft";
2993
2982
  const pending = current.pending;
2983
+ const joint = pending?.actor === "joint" ? current.joint : null;
2994
2984
  const events = list(current.events);
2995
2985
  const wrap = node("div", { class: "sw-imm" });
2996
2986
  wrap.append(scene(null, text(current.area, current.placeName), "", { location: current.locationArt, class: "sw-imm-scene", tag: text(current.placeName, "当前地点") }));
@@ -3000,11 +2990,11 @@ function mountPanel(root, ctx) {
3000
2990
  node("div", { class: "sw-kicker" }, isDraft ? "等待继续" : `此刻 · ${text(current.area, current.placeName)}`),
3001
2991
  node("p", { class: "sw-imm-lead" }, text(events.at(-1), current.step === "move" ? "路就在眼前。走近一点,看看会遇见什么。" : "这一趟的故事,将随着真实的行动在这里展开。")),
3002
2992
  pending?.prompt ? node("p", { class: "sw-imm-ask" }, text(pending.prompt)) : null,
3003
- current.actor === "joint" || pending?.actor === "joint" ? note(`共同决定:${current.actor === "fish" ? "现在轮到鱼投她那一票" : "现在等你投这一票"};两边同票才会前进,等待与超时都不算同意。`) : null
2993
+ joint ? note(joint.note) : null
3004
2994
  ));
3005
2995
  if (pending) {
3006
2996
  const { block, canSubstitute } = pendingPicker(state, current, "sw-imm-choices");
3007
- if (pending.actor === "joint") wrap.append(jointBoard(pending));
2997
+ if (joint) wrap.append(jointBoard(joint));
3008
2998
  wrap.append(block, note(optionsHint(state, current, canSubstitute)));
3009
2999
  } else {
3010
3000
  const advance = advanceButton(state, current, { block: true });
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "cortico-world-fun",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "type": "module",
5
- "description": "从0开始的肥鱼大冒险 —— 给 Coopanion 桌宠二十处真能去逛的地方:游乐场、海洋馆、庙会、漫展、电影院、动物园、公园、电玩城、KTV、博物馆、猫咖、爬山、咖啡店、奶茶店、餐厅、图书馆、夜市、澡堂、旧货市场、江边。进门、逛摊位、买纪念品、拍张照、吃喝点什么,回家记一笔。能和「鱼的每一天」「生图工作室」联动,但都不依赖。\n\n「鱼的小世界」(cortico-world-map)已经并入这里:它原来的地点与房间现在就是本插件的「地点册」与「家」——场所、画风、关联、封面都在地点册里编辑,不必再装两个包;从旧版导出的备份可以在「地点册 → 整理与设置 → 从小世界迁入」一次性搬过来。\n\n0.7.5 把故事工坊收成一个创建入口(三个起点 + 从文件导入),去掉重复的右侧栏;0.7.4 把地点册改成「左栏分组 + 右侧封面列表」(六项计数 + 整理与设置,窄屏折成横向筛选),并把「允许她自己出门」改成只留许可、时间跟随「鱼的每一天」的「她自己的时间」(不再有自己的时段、定时器与 fun.home.free 事件)。\n\n0.7.3 是设置重组:故事长度、主持接口地址与模型、剧情图片来源搬进配置页(热改,旧值一次性迁移);「自动配图」开关移到出游页顶部;本地插画搬到「地点册 → 本地插画」;出游「设置」只剩「高级设置」(API Key、直连手动出图、自定义工作流)。面板 id 与页签名不变。",
5
+ "description": "从0开始的肥鱼大冒险 —— 给 Coopanion 桌宠二十处真能去逛的地方:游乐场、海洋馆、庙会、漫展、电影院、动物园、公园、电玩城、KTV、博物馆、猫咖、爬山、咖啡店、奶茶店、餐厅、图书馆、夜市、澡堂、旧货市场、江边。进门、逛摊位、买纪念品、拍张照、吃喝点什么,回家记一笔。\n\n七个面板:家(2D 房间、十个活动)、去哪儿(此刻推荐)、地点册(唯一的编辑器)、出游(当前这一趟与故事)、纪念册、纪念品架、故事工坊。故事可以自己写:选项式一步一选,自由场景包交给主持即兴演;双人故事里的共同决定要两席同票才前进。24 个工具、0 个事件,数据全部存在本机 fun/ 目录。\n\n能和「鱼的每一天」「生图工作室」联动,但都不依赖;「鱼的小世界」已并入这里,地点与房间就是本插件的「地点册」与「家」,不必再装两个包。",
6
6
  "license": "MIT",
7
7
  "author": "青",
8
8
  "repository": {
@@ -63,11 +63,11 @@
63
63
  "locales": {
64
64
  "zh": {
65
65
  "displayName": "从0开始的肥鱼大冒险",
66
- "description": "给 Coo 二十处能真去逛的地方:游乐场、海洋馆、庙会、漫展、电影院、动物园、公园、电玩城、KTV、博物馆、猫咖、爬山、咖啡店、奶茶店、餐厅、图书馆、夜市、澡堂、旧货市场、江边。她说一声进门,一处一处地逛项目、抽个签、买点纪念品、拍张照、喝杯奶茶,回家时回执把这一趟收成一句话,接着去记进自己的日程。\n\n能和别的插件联动,但都不依赖:装了「鱼的每一天」时,日程叫醒里会顺手提到这块、回家回执也会提醒她去 feast_life_play 记一笔;咖啡店、奶茶店、餐厅、夜市吃的东西去「鱼的每一天」点一道,那里才有九维口感、香气和余韵——没装就只知道喝了杯奶茶,不编味道。装了「生图工作室」时,回家回执会告诉她发图该填哪个 scene、哪身衣服;素材库里没有的那几处会明说不用填,绝不替她编一个不存在的场景名。这些插件一个都不装也照样能逛,库挪走了也不影响。\n\n「鱼的小世界」(cortico-world-map)已经并入:它原来的地点与房间现在就是这里的「地点册」与「家」,不必再装两个包;旧版导出的备份可以在「地点册 → 整理与设置 → 从小世界迁入」一次性搬进来。\n\n0.3.3 提供默认收起的故事编辑器、本机加密的可选主持接口与可选图片来源;六个面板保留故事创作、隔离试玩、地点册、行程回忆与探索档案。随版本内置《折潮港的第七封回信·简编版》《雨停前的小小清单》《桥底下的回声》《被换掉的说明牌》四篇故事及折潮港、折角巷两个地点;旧五篇与样章场所已移除,升级先备份且只移除与内置内容完全一致的历史副本,用户其他创作、已出发行程和回忆保留。自填地点无剧情也可正常游玩。\n\n0.4.3 把六个面板统一成「旅行手账」:纸色版式与统一圆角、地点册按四组编辑并带固定保存栏、纪念册多一栏心愿、纪念品架排成展示柜、故事工坊按作品库浏览。不改存储模型,也不动已有行程与回忆。\n\n0.4.4 新增第七个面板「家」:一张 2D 房间、十个活动、可换背景与每个姿势的图;房间状态单独存在 fun/home/,不写行程、不读别的插件,没图也能用。\n\n0.7.0 把「家」推到 P5:站位按 Q 版实测落地板、随时段变色、可点热点、快照、画架、导出与导入房间,家同时成了入口(最近纪念品、未逛完的行程、第一个心愿、「今天想做什么」);新增只读 fun_home_state 与写 fun_home_activity,工具到 24 个。\n\n0.7.1 把「自己出门」改成方案 B:许可与时段两个键都开才叫醒,到点只推一条 internal 事件叫她先看当天日程(feast_life_now),不读「鱼的每一天」的日程、不挑地方、不替她出门;没上传角色图时改用随包内置的十张 Q 版立绘;修了画架选图必报 400;纪念品摆件因图标压字先不摆。\n\n0.7.2 是体检整改:六个只读故事查询加 10 分钟记忆化,重复问只回「没变化」,任何写操作立即失效,full:true 可重取;工具说明与提示词瘦身;文字通道默认开,聊天里六个查询都在、能直接开局推进,作者工具另有一个开关(默认关),关掉文字通道则只留候选与详情两个查询。\n\n0.7.3 是设置重组:故事长度、主持接口地址与模型、剧情图片来源搬进配置页(热改,旧值一次性迁移);「自动配图」开关移到出游页顶部;本地插画搬到「地点册 → 本地插画」;出游「设置」只剩「高级设置」(API Key、直连手动出图、自定义工作流)。面板 id 与页签名不变。\n\n0.7.4 把地点册改成「左栏分组 + 右侧封面列表」(六项计数 + 整理与设置,窄屏折成横向筛选);「允许她自己出门」改成只留许可、时间跟随「鱼的每一天」的「她自己的时间」,不再有自己的时段、定时器与 fun.home.free 事件。\n\n0.7.5 把故事工坊收成一个创建入口:展开后是「选项式故事 / 自由场景包 / 从文件导入」三个起点,删掉重复的右侧栏;导入可以选 .json 文件(≤ 32 KB),粘贴保留。"
66
+ "description": "给 Coo 二十处能真去逛的地方:游乐场、海洋馆、庙会、漫展、电影院、动物园、公园、电玩城、KTV、博物馆、猫咖、爬山、咖啡店、奶茶店、餐厅、图书馆、夜市、澡堂、旧货市场、江边。她说一声进门,一处一处地逛项目、抽个签、买点纪念品、拍张照、喝杯奶茶,回家时回执把这一趟收成一句话,接着去记进自己的日程。\n\n七个面板各管一段:**家**是一张 2D 房间、十个活动,能换背景、能摆她买回来的东西;**去哪儿**推荐此刻能去的地方;**地点册**是唯一的编辑器,场所、画风、关联、封面都在这里改;**出游**管当前这一趟、故事与进度;**纪念册**把每一趟收成一张票笺;**纪念品架**排成展示柜;**故事工坊**写故事。\n\n故事有两种写法:**选项式**一步一选,像翻分支小说;**自由场景包**只写大方向、正史、人物与收尾条件,每一回合交给主持即兴演。可以在面板里玩,也可以在聊天里开局推进。双人故事里的共同决定要两席各投一票、两边一致才前进,分歧不替任何一席作主。\n\n「鱼的小世界」(cortico-world-map)已经并入:它原来的地点与房间就是这里的「地点册」与「家」,不必再装两个包;旧版导出的备份可以在「地点册 → 整理与设置 → 从小世界迁入」一次性搬进来。\n\n能和别的插件联动,但都不依赖:装了「鱼的每一天」时,日程叫醒里会顺手提到这块、回家回执也会提醒她去 feast_life_play 记一笔;咖啡店、奶茶店、餐厅、夜市吃的东西去「鱼的每一天」点一道,那里才有九维口感、香气和余韵——没装就只知道喝了杯奶茶,不编味道。装了「生图工作室」时,回家回执会告诉她发图该填哪个 scene、哪身衣服;素材库里没有的那几处会明说不用填,绝不替她编一个不存在的场景名。这些插件一个都不装也照样能逛,库挪走了也不影响。"
67
67
  },
68
68
  "en": {
69
69
  "displayName": "Adventures of Fat Fish from Scratch",
70
- "description": "Twenty places she can actually go: an amusement park, an aquarium, a temple fair, a fan convention, a cinema, a zoo, a park, an arcade, a karaoke box, a museum, a cat cafe, a hike, a coffee shop, a bubble-tea stand, a restaurant, a library, a night market, a bathhouse, a flea market and a riverside walk. She walks in, wanders one spot at a time, buys a souvenir, takes a photo, has something to eat or drink, and the closing receipt sums the trip up in one line she can log into her own day.\n\nWorks alongside other plugins but depends on none. With Fish Every Day installed, the own-time menu points at this world and the closing receipt reminds her to log the trip with feast_life_play; food and drink at the coffee shop, tea stand and restaurant are meant to be ordered from Fish Every Day, where the nine-axis flavour profile and aroma actually live — without it she only knows she had a bubble tea, and she is told not to invent how it tasted. With the image studio installed, the receipt names the scene and outfit to draw; venues the library does not have are marked as such instead of inventing a name. None of them are required, and it still works if the image library is gone.\n\nLittle World (cortico-world-map) is now folded in: its places and rooms are this plugin's Place Book and Home, so there is no need to keep both installed; a backup exported from the old version can be moved over in one go from Place Book → Tidy & settings → Import from Little World.\n\nVersion 0.3.3 adds a collapsed story editor, locally encrypted optional DM credentials and optional image sources. Six panels retain authoring, isolated playtests, places, trip memories and exploration. Four approved stories ship with the plugin (The Seventh Unsent Reply of Foldtide Harbour, A Small List Before the Rain Stops, Echo Under the Bridge, The Swapped Plaque), together with their harbour and alley places; all five old presets and the sample venue are gone. Upgrades back up originals and remove only byte-identical copies of the newly built-in content. Other user creations, active trips and memories remain. Custom places work without stories.\n\nVersion 0.4.3 unifies the six panels into one travel-journal look: paper tones and a single radius scale, a grouped place editor with a sticky save bar, a wish sidebar in the trip book, a display-cabinet shelf grid, and a library view in the story workshop. No storage changes; existing trips and memories are untouched.\n\nVersion 0.4.4 adds a seventh panel, Home: a 2D room with ten activities, replaceable background and pose art. Room state lives in fun/home/ and never writes trips or reads other plugins; it works with no art at all.\n\nVersion 0.7.0 takes Home to P5: placements measured against the chibi art, time-of-day tint, clickable hotspots, snapshots, an easel, room export and import, and Home as an entry point (recent souvenirs, unfinished trips, the first open wish, a \"what I want to do today\" note). Two tools join the roster: read-only fun_home_state and writing fun_home_activity, bringing it to 24.\n\nVersion 0.7.1 replaces auto-going-out with plan B: an allow switch plus time slots, and when both are on the World only pushes one internal event at that slot asking her to check the day's schedule (feast_life_now) first. It never reads Fish Every Day, never picks a place and never sends her out. Bundled chibi art now backs the room when no pose art is uploaded; the easel picker no longer fails with a 400; souvenir decorations stay off for now because their icons covered the room text.\n\nVersion 0.7.2 is the audit pass: the six read-only story queries are memoised for ten minutes (a repeat returns a short \"unchanged\" receipt, any write invalidates it, full:true forces a fresh copy), tool and prompt text is trimmed, and the text channel is on by default — chat has all six queries and can start and advance stories, while the author tool sits behind its own switch and turning the text channel off leaves just the candidate and detail queries.\n\nVersion 0.7.3 reorganises settings: story length, DM endpoint and model, and the story image source move into configuration (hot-applied, with a one-time migration of old values); the auto-image switch moves to the top of the Outing panel; local artwork moves to Place Book → Local artwork; Outing → Settings keeps only Advanced (API key, direct manual generation, custom workflow). Panel ids and page titles are unchanged.\n\n0.7.4 rebuilds the Place Book as a grouped left rail plus a cover-thumbnail list on the right (six counted filters, settings entries, horizontal filters on narrow screens), and turns 'let her go out on her own' into a permission only: its timing follows Her Own Time in Fish Every Day, with no local slots, timer or fun.home.free event.\n\n0.7.5 collapses the Story Workshop to one create entry: three starting points (choice story, free scene pack, import from file) replace the duplicated side rail, and importing can pick a .json file (up to 32 KB) while paste stays available."
70
+ "description": "Twenty places she can actually go: an amusement park, an aquarium, a temple fair, a fan convention, a cinema, a zoo, a park, an arcade, a karaoke box, a museum, a cat cafe, a hike, a coffee shop, a bubble-tea stand, a restaurant, a library, a night market, a bathhouse, a flea market and a riverside walk. She says the word, wanders one spot at a time, buys a souvenir, takes a photo, has something to eat or drink, and the closing receipt sums the trip up in one line she can log into her own day.\n\nSeven panels: Home (a 2D room with ten activities), Where to (what is open right now), Place Book (the only editor for places, styles, links and covers), Outing (this trip and its story), Trip Book, Souvenir Shelf, and the Story Workshop. Stories are authored here too: choice stories go one step at a time like a branching novel, free scene packs hand every turn to a DM to improvise, and a duo story only moves on when both seats vote the same. 24 tools, 0 events, everything stored locally under fun/.\n\nLittle World (cortico-world-map) is now folded in: its places and rooms are this plugin's Place Book and Home, so there is no need to keep both installed; a backup exported from the old version can be moved over in one go from Place Book → Tidy & settings → Import from Little World.\n\nWorks alongside other plugins but depends on none: with Fish Every Day the own-time menu points here and the closing receipt reminds her to log the trip with feast_life_play, and food is ordered there where the nine-axis flavour profile lives; with the image studio the receipt names the scene and outfit to draw. None of them are required."
71
71
  }
72
72
  }
73
73
  },
package/src/joint.js ADDED
@@ -0,0 +1,230 @@
1
+ /**
2
+ * 共同决定(两席同票)的**唯一派生**。
3
+ *
4
+ * 规格在 `docs/JOINT-DECISION-SPEC.md`;这里只做纯函数:读入参、不修改 `pending`、
5
+ * 不依赖 `this` / 时间 / 文件系统。谁可以投、什么时候前进、给人看什么字,全部从这里取,
6
+ * 世界、面板、只读查询都不许再自己比对票面——0.7.6 的卡死 bug 就是三份实现各长各的。
7
+ *
8
+ * 规则(2026-11-23 拍板的收窄版):
9
+ * - 空票面:两席都能先投,不限先后;
10
+ * - 只剩一席没投:只有那一席能投(已投的那一席此刻不能改票、也不能连投第二次);
11
+ * - 两票都在且不同:两席都能改自己那一票,只写自己这一席,改成一致才前进;
12
+ * - `skip` 在 joint 里永远非法;`substitute`(代投)不适用于 joint。
13
+ *
14
+ * 入参缺字段(老存档、半截数据)按「没有那一票」处理:不抛错。
15
+ */
16
+
17
+ const SEATS = ['owner', 'fish'];
18
+ const RESOLUTIONS = new Set(['require-agreement', 'owner-final', 'fish-final']);
19
+ const DEFAULT_RESOLUTION = 'require-agreement';
20
+
21
+ /** 本步合法选项 id 的集合;`options` 缺失或坏掉时为空集。 */
22
+ function optionIds(pending) {
23
+ const options = Array.isArray(pending?.options) ? pending.options : [];
24
+ return new Set(options.map((option) => option?.id).filter((id) => typeof id === 'string' && id));
25
+ }
26
+
27
+ /**
28
+ * 票面的规整副本:只留「该席真的投了、且投的是本步合法选项」的项。
29
+ * `src/state.js` 归一化时已经过滤过一遍,这里再挡一次手写的半截数据。
30
+ */
31
+ export function jointVotes(pending) {
32
+ if (pending?.actor !== 'joint') return {};
33
+ const ids = optionIds(pending);
34
+ const votes = {};
35
+ for (const seat of SEATS) {
36
+ const id = pending?.votes?.[seat];
37
+ if (typeof id === 'string' && ids.has(id)) votes[seat] = id;
38
+ }
39
+ return votes;
40
+ }
41
+
42
+ /** 异票怎么办;缺失或非法一律按 `require-agreement`(不静默拿某一席的票当共识)。 */
43
+ export function jointResolutionOf(pending) {
44
+ const resolution = pending?.jointResolution;
45
+ return RESOLUTIONS.has(resolution) ? resolution : DEFAULT_RESOLUTION;
46
+ }
47
+
48
+ /** 阶段:'empty' | 'waiting-owner' | 'waiting-fish' | 'disagree' | 'agreed';非 joint 返回 null。 */
49
+ export function jointStage(pending) {
50
+ if (pending?.actor !== 'joint') return null;
51
+ const votes = jointVotes(pending);
52
+ const owner = Boolean(votes.owner);
53
+ const fish = Boolean(votes.fish);
54
+ if (owner && fish) return votes.owner === votes.fish ? 'agreed' : 'disagree';
55
+ if (owner) return 'waiting-fish';
56
+ if (fish) return 'waiting-owner';
57
+ return 'empty';
58
+ }
59
+
60
+ /**
61
+ * 现在该提示谁:'owner' | 'fish';非 joint 返回 null。**只用于文案,不是权限。**
62
+ * 空票面默认主人(聊天里通常是主人在说话),但两席都能先投。
63
+ */
64
+ export function jointActor(pending) {
65
+ const stage = jointStage(pending);
66
+ if (!stage) return null;
67
+ return stage === 'waiting-fish' ? 'fish' : 'owner';
68
+ }
69
+
70
+ /** 这一席此刻能不能提交:权限只认这里。 */
71
+ export function jointCanVote(pending, seat) {
72
+ const stage = jointStage(pending);
73
+ if (!stage || !SEATS.includes(seat) || !optionIds(pending).size) return false;
74
+ if (stage === 'empty' || stage === 'disagree') return true;
75
+ if (stage === 'waiting-owner') return seat === 'owner';
76
+ if (stage === 'waiting-fish') return seat === 'fish';
77
+ // agreed:两票都在且相同,下一步就是提交,不再收新的票。
78
+ return false;
79
+ }
80
+
81
+ /**
82
+ * 这一提交的结果:要不要前进、按哪一票。
83
+ * 异票且 `require-agreement` 时 `advance: false`(两票都留);`owner-final` / `fish-final` 直接前进。
84
+ */
85
+ export function jointDecision(pending) {
86
+ const stage = jointStage(pending);
87
+ const votes = jointVotes(pending);
88
+ if (stage === 'agreed') return { stage, advance: true, optionId: votes.owner ?? null };
89
+ if (stage === 'disagree') {
90
+ const resolution = jointResolutionOf(pending);
91
+ if (resolution === 'require-agreement') return { stage, advance: false, optionId: null };
92
+ return { stage, advance: true, optionId: resolution === 'owner-final' ? votes.owner ?? null : votes.fish ?? null };
93
+ }
94
+ return { stage, advance: false, optionId: null };
95
+ }
96
+
97
+ const ZH = {
98
+ seatName: { owner: '你这一席', fish: '鱼那一席' },
99
+ headline: {
100
+ empty: '两席各选一项',
101
+ 'waiting-owner': '现在轮到你了',
102
+ 'waiting-fish': '现在轮到鱼',
103
+ disagree: '两边票不一样',
104
+ agreed: '两票一致',
105
+ },
106
+ resolutionNote: {
107
+ 'require-agreement': '双方必须明确同意;分歧保持待定',
108
+ 'owner-final': '分歧按你的明确选择',
109
+ 'fish-final': '分歧按鱼的明确选择',
110
+ },
111
+ hint: {
112
+ empty: () => '两席各投一票,同票才出发:谁先投都行;两票一致才前进。',
113
+ 'waiting-owner': ({ fish }) => `鱼那一票已经记下了(${fish})。现在轮到你投这一票(鱼不能代投);两票相同才会前进。`,
114
+ 'waiting-fish': ({ owner }) => `你这一票已经记下了(${owner})。这一票要鱼自己投;两票相同才会前进。`,
115
+ disagree: ({ owner, fish }) => `两边票不一样(你:${owner} / 鱼:${fish}):这一轮不前进,也不清掉任何一席的票。谁都可以改自己那一票,两边一致才递交;也可以先回家。`,
116
+ agreed: ({ owner }) => `两票已经一致(${owner});提交就会前进。`,
117
+ },
118
+ note: {
119
+ empty: () => '共同决定:两席各投一票,谁先投都行;两边同票才会前进,等待与超时都不算同意。',
120
+ 'waiting-owner': () => '共同决定:现在等你投这一票;两边同票才会前进,等待与超时都不算同意。',
121
+ 'waiting-fish': () => '共同决定:现在轮到鱼投她那一票;两边同票才会前进,等待与超时都不算同意。',
122
+ disagree: ({ owner, fish }) => `共同决定:两边票不一样(你:${owner} / 鱼:${fish}),这一轮不前进,两票都留着。谁都可以改自己那一票;也可以先回家。等待与超时都不算同意。`,
123
+ agreed: () => '共同决定:两票已经一致。',
124
+ },
125
+ saved: {
126
+ owner: ({ label }) => `你的选择已保存(${label})。现在等鱼自己提交她那一票;没有以等待或超时当作同意。`,
127
+ fish: ({ label }) => `鱼的选择已保存(${label})。现在等你(主人)自己投这一票;没有以等待或超时当作同意。`,
128
+ },
129
+ seatsText: ({ owner, fish, hasOwner, hasFish }) => `你${hasOwner ? `已选「${owner}」` : '还没投'},鱼${hasFish ? `已选「${fish}」` : '还没投'}`,
130
+ blocked: {
131
+ owner: ({ owner }) => `你那一票已经记下了(${owner});这一步等鱼自己投她那一票,你不能代投。`,
132
+ fish: ({ fish }) => `鱼那一票已经记下了(${fish});这一步等你(主人)自己投,鱼不能代投。`,
133
+ },
134
+ agreedBlocked: '两票已经一致,这一步不再收新的票。',
135
+ invalid: '共同选择需要用户或鱼分别提交有效选项。',
136
+ skip: '共同选择不能用略过代替双方决定。',
137
+ substitute: '共同决定要两席各投自己那一票,不能由一席代投。',
138
+ };
139
+
140
+ const EN = {
141
+ seatName: { owner: 'Your seat', fish: 'Fish’s seat' },
142
+ headline: {
143
+ empty: 'Each seat picks one',
144
+ 'waiting-owner': 'Your turn now',
145
+ 'waiting-fish': 'Waiting for the fish',
146
+ disagree: 'The votes differ',
147
+ agreed: 'Both votes match',
148
+ },
149
+ resolutionNote: {
150
+ 'require-agreement': 'Both seats must agree; a split stays pending',
151
+ 'owner-final': 'A split follows your explicit choice',
152
+ 'fish-final': 'A split follows the fish’s explicit choice',
153
+ },
154
+ hint: {
155
+ empty: () => 'Both seats vote and the choice only moves on when the votes match: either seat may go first.',
156
+ 'waiting-owner': ({ fish }) => `The fish's vote is saved (${fish}). Now cast your own vote; the fish cannot vote for you, and the choice moves on only when both votes match.`,
157
+ 'waiting-fish': ({ owner }) => `Your vote is saved (${owner}). The fish has to cast hers herself; the choice moves on only when both votes match.`,
158
+ disagree: ({ owner, fish }) => `The votes differ (you: ${owner} / fish: ${fish}): nothing advances and neither vote is cleared. Either seat may change its own vote, and it moves on once they match. You can also head home.`,
159
+ agreed: ({ owner }) => `Both votes already match (${owner}); submitting will move on.`,
160
+ },
161
+ note: {
162
+ empty: () => 'Joint decision: both seats vote, either may go first; it only moves on when the votes match, and waiting or a timeout is never consent.',
163
+ 'waiting-owner': () => 'Joint decision: your vote is the one still missing; it only moves on when the votes match, and waiting or a timeout is never consent.',
164
+ 'waiting-fish': () => 'Joint decision: the fish still has to cast her vote; it only moves on when the votes match, and waiting or a timeout is never consent.',
165
+ disagree: ({ owner, fish }) => `Joint decision: the votes differ (you: ${owner} / fish: ${fish}); nothing advances and both votes stay. Either seat may change its own vote, or you can head home. Waiting or a timeout is never consent.`,
166
+ agreed: () => 'Joint decision: both votes already match.',
167
+ },
168
+ saved: {
169
+ owner: ({ label }) => `Your choice was saved (${label}). Now wait for the fish to submit hers herself; waiting or a timeout is never consent.`,
170
+ fish: ({ label }) => `The fish's choice was saved (${label}). Now cast your own vote; waiting or a timeout is never consent.`,
171
+ },
172
+ seatsText: ({ owner, fish, hasOwner, hasFish }) => `you ${hasOwner ? `picked “${owner}”` : 'have not voted'}, fish ${hasFish ? `picked “${fish}”` : 'has not voted'}`,
173
+ blocked: {
174
+ owner: ({ owner }) => `Your vote is already recorded (${owner}); this vote has to be the fish's own, and you cannot cast it for her.`,
175
+ fish: ({ fish }) => `The fish's vote is already recorded (${fish}); this vote has to be yours, and the fish cannot cast it for you.`,
176
+ },
177
+ agreedBlocked: 'Both votes already match; this step takes no new votes.',
178
+ invalid: 'A joint choice needs a valid option submitted by the owner or the fish.',
179
+ skip: 'A joint choice cannot use skip in place of both decisions.',
180
+ substitute: 'A joint decision takes one vote from each seat; neither seat may vote for the other.',
181
+ };
182
+
183
+ const TEXT = { zh: ZH, en: EN };
184
+
185
+ /**
186
+ * 给人看的那一份:阶段、该提示谁、两席票面、以及各处共用的文案。
187
+ * `optionLabel(id)` 用来把选项 id 换成作者写的选项文字;`language` 跟随现有机制(默认中文)。
188
+ * 非 joint 步返回 null。
189
+ */
190
+ export function jointView(pending, optionLabel, language = 'zh') {
191
+ const stage = jointStage(pending);
192
+ if (!stage) return null;
193
+ const copy = language === 'en' ? TEXT.en : TEXT.zh;
194
+ const labelOf = typeof optionLabel === 'function' ? optionLabel : (id) => (typeof id === 'string' ? id : '');
195
+ const votes = jointVotes(pending);
196
+ const label = (seat) => {
197
+ const id = votes[seat];
198
+ if (typeof id !== 'string') return '';
199
+ const text = labelOf(id);
200
+ return typeof text === 'string' && text ? text : id;
201
+ };
202
+ const ctx = { owner: label('owner'), fish: label('fish'), hasOwner: Boolean(votes.owner), hasFish: Boolean(votes.fish) };
203
+ const canVote = { owner: jointCanVote(pending, 'owner'), fish: jointCanVote(pending, 'fish') };
204
+ const resolution = jointResolutionOf(pending);
205
+ const blocked = {};
206
+ for (const seat of SEATS) {
207
+ if (canVote[seat]) { blocked[seat] = null; continue; }
208
+ if (stage === 'agreed') { blocked[seat] = copy.agreedBlocked; continue; }
209
+ const other = votes[seat === 'owner' ? 'fish' : 'owner'];
210
+ blocked[seat] = other ? copy.blocked[seat](ctx) : copy.invalid;
211
+ }
212
+ return {
213
+ stage,
214
+ seat: jointActor(pending),
215
+ resolution,
216
+ votes,
217
+ canVote,
218
+ seats: SEATS.map((seat) => ({ seat, name: copy.seatName[seat], voted: Boolean(votes[seat]), optionId: votes[seat] ?? null, label: label(seat) })),
219
+ headline: copy.headline[stage],
220
+ hint: copy.hint[stage](ctx),
221
+ note: copy.note[stage](ctx),
222
+ resolutionNote: copy.resolutionNote[resolution],
223
+ seatsText: copy.seatsText(ctx),
224
+ saved: { owner: copy.saved.owner({ label: ctx.owner }), fish: copy.saved.fish({ label: ctx.fish }) },
225
+ blocked,
226
+ skipText: copy.skip,
227
+ substituteText: copy.substitute,
228
+ invalidText: copy.invalid,
229
+ };
230
+ }
@@ -1,6 +1,7 @@
1
1
  import { createHash, randomUUID } from 'node:crypto';
2
2
  import { pickStory, storyAvailability, storyReferences, storyStepBlock } from './story-packs.js';
3
3
  import { effectiveMaxTurns, evaluateWhen, freeCanContinue, freeSegmentsLeft, freeTurnsLeft, isFreePack, normalizeFreeState } from './story-free.js';
4
+ import { jointActor, jointView } from './joint.js';
4
5
 
5
6
  export const STORY_ACTIONS = ['start', 'move', 'choose', 'resume', 'close', 'mode', 'pause', 'decide', 'auto', 'fork', 'segment'];
6
7
  import { AUTO_SEGMENTS, autoLimits, budgetStop, storyBudget } from './story-reliability.js';
@@ -112,7 +113,7 @@ export function freeTripView(outing, row, venue, isDraft, freeTurnLimit) {
112
113
  };
113
114
  }
114
115
 
115
- export function describeStoryTrip(outing, isDraft, catalog, venue, nowMin, visits, completedStoryIds = [], freeTurnLimit) {
116
+ export function describeStoryTrip(outing, isDraft, catalog, venue, nowMin, visits, completedStoryIds = [], freeTurnLimit, language = 'zh') {
116
117
  const run = outing?.storyRun;
117
118
  if (!run) return null;
118
119
  const row = catalog.find(({ pack }) => pack.id === run.packId && pack.revision === run.revision);
@@ -132,9 +133,10 @@ export function describeStoryTrip(outing, isDraft, catalog, venue, nowMin, visit
132
133
  else if (pickStory([row], venue, nextNode.area, nowMin, outing, visits, completedStoryIds)) step = 'move';
133
134
  else blocked = storyStepBlock(row.pack, nextNode, venue, nowMin, visits) || '现在不满足下一处区域的开放或触发条件。可以稍后再试,或按已有记录回家。';
134
135
  const duo = row?.pack.version === 2 && row.pack.metadata?.participation === 'duo';
136
+ // 「现在该提示谁」只从 joint.js 取;面板显示与权限分开:能投不能投看 trip.joint.canVote。
135
137
  const currentActor = duo
136
138
  ? step === 'close' ? 'owner'
137
- : pending?.actor === 'joint' ? (!pending.votes?.owner ? 'owner' : !pending.votes?.fish ? 'fish' : 'owner')
139
+ : pending?.actor === 'joint' ? jointActor(pending)
138
140
  : pending?.actor ?? (step === 'move' ? nextNode?.actor === 'fish' ? 'fish' : 'owner' : 'owner')
139
141
  : null;
140
142
  return {
@@ -144,6 +146,8 @@ export function describeStoryTrip(outing, isDraft, catalog, venue, nowMin, visit
144
146
  actor: currentActor,
145
147
  jointVotes: pending?.actor === 'joint' ? { ...(pending.votes ?? {}) } : undefined,
146
148
  jointResolution: pending?.jointResolution ?? null,
149
+ // 面板只读这一份:阶段、谁能投、两席票面与各处文案都在里面(joint.js 单一派生)。
150
+ joint: pending?.actor === 'joint' ? jointView(pending, (id) => pending.options.find(({ id: value }) => value === id)?.label ?? id, language) : null,
147
151
  pending: pending ? { id: pending.id, event: pending.event, prompt: pending.prompt, actor: pending.actor ?? null,
148
152
  jointResolution: pending.jointResolution ?? null, votes: { ...(pending.votes ?? {}) },
149
153
  options: pending.options.map(({ id, label }) => ({ id, label })) } : null,
package/src/story-read.js CHANGED
@@ -12,6 +12,7 @@ import { areasNow, descNow } from './phases.js';
12
12
  import { hoursState } from './venues.js';
13
13
  import { minutesIn } from './state.js';
14
14
  import { describeMemory, describePack } from './story-panel.js';
15
+ import { jointView } from './joint.js';
15
16
 
16
17
  /** 一篇故事的公开卡:只有元数据与「能不能玩」,不返回节点内容或未来分支。 */
17
18
  function publicCard(ctx, row) {
@@ -80,6 +81,10 @@ export async function readStoryQuery(ctx) {
80
81
  const status = ctx.status();
81
82
  if (!status.ok) return status;
82
83
  const trip = status.trip;
84
+ const pending = trip?.pending ?? null;
85
+ const labelOf = (id) => pending?.options?.find(({ id: value }) => value === id)?.label ?? id;
86
+ // 共同决定只从 joint.js 取一份:阶段、该谁投、谁能投、文案全在里面。
87
+ const joint = pending?.actor === 'joint' ? jointView(pending, labelOf, ctx.language) : null;
83
88
  return { ok: true, queryAt, state: trip ? trip.state : 'none', startStamp: status.startStamp, trip: trip ? {
84
89
  id: trip.id, runId: ctx.runId,
85
90
  title: trip.title, packId: trip.packId, revision: trip.revision, placeId: trip.placeId, placeName: trip.placeName,
@@ -89,10 +94,13 @@ export async function readStoryQuery(ctx) {
89
94
  prompt: trip.pending.prompt, actor: trip.pending.actor ?? 'owner',
90
95
  jointResolution: trip.pending.jointResolution ?? null, votes: { ...(trip.pending.votes ?? {}) },
91
96
  options: trip.pending.options.map(({ id, label }) => ({ id, label })) } : null,
92
- // 文字通道只看这一行就知道该谁投:共同决定缺哪一席,就是那一席的回合。
93
- hint: trip.step !== 'choose' ? null : trip.actor === 'fish'
94
- ? '这一票轮到鱼(你)自己提交:把她的选择用 say 交进来即可,不要等用户替她选。'
95
- : trip.actor === 'owner' ? '这一票等用户(主人)自己提交;鱼不能代投。' : null,
97
+ // 文字通道只看这一行就知道该谁投:共同决定里空票面两席都能先投,只剩一席时才是那一席的回合。
98
+ joint: joint ? { stage: joint.stage, seat: joint.seat, resolution: joint.resolution, canVote: joint.canVote,
99
+ votes: joint.votes, seats: joint.seats, hint: joint.hint } : null,
100
+ hint: trip.step !== 'choose' ? null : joint ? joint.hint
101
+ : trip.actor === 'fish'
102
+ ? '这一票轮到鱼(你)自己提交:把她的选择用 say 交进来即可,不要等用户替她选。'
103
+ : trip.actor === 'owner' ? '这一票等用户(主人)自己提交;鱼不能代投。' : null,
96
104
  timeline: [...trip.timeline],
97
105
  } : null };
98
106
  }
package/src/world.js CHANGED
@@ -54,6 +54,7 @@ import { readStoryQuery } from './story-read.js';
54
54
  import { randomUUID } from 'node:crypto';
55
55
  import { pickStory, advanceStoryChoice, normalizeStoryProgress, storyReferences } from './story-packs.js';
56
56
  import { describeMemory, describePack, describeStoryTrip, requestStoryDecision, STORY_ACTIONS, storyFailure, storyStamp, StoryAutonomy } from './story-panel.js';
57
+ import { jointActor, jointCanVote, jointDecision, jointView } from './joint.js';
57
58
  import {
58
59
  continueFreeSegment, effectiveMaxTurns, freeCanContinue, freePromptPayload, freeSummaryText, freeTurn, freeTurnsLeft,
59
60
  isFreePack, newFreeState, normalizeFreeState, requestFreeTurn,
@@ -966,36 +967,27 @@ export class FunWorld {
966
967
  substituted = true;
967
968
  }
968
969
  if (choice.actor === 'joint') {
969
- if (!['owner', 'fish'].includes(submitter)) return { text: '共同选择需要用户或鱼分别提交有效选项。', failed: true };
970
- // 两席各自一票:先补缺的那一席;两票都在而不同时,才回到用户重选。
971
- const expectedVoter = !choice.votes?.owner ? 'owner' : !choice.votes?.fish ? 'fish' : 'owner';
970
+ // 规则、权限与文案都从 src/joint.js 取:空票面两席都能先投;只剩一席没投时只有那一席
971
+ // 能投;异票时两席都能改自己那一票,只写自己这一席。世界不再自己比对票面。
972
972
  const optionLabel = (id) => choice.options.find(({ id: value }) => value === id)?.label ?? id;
973
- if (submitter !== expectedVoter) {
974
- return { text: expectedVoter === 'owner'
975
- ? `鱼那一票已经记下了(${optionLabel(choice.votes?.fish)});这一步等你(主人)自己投,鱼不能代投。`
976
- : `你那一票已经记下了(${optionLabel(choice.votes?.owner)});这一步等鱼自己投她那一票,你不能代投。`, failed: true };
977
- }
978
- if (optionId === 'skip') return { text: '共同选择不能用略过代替双方决定。', failed: true };
979
- const valid = choice.options.some(({ id }) => id === optionId);
980
- if (!valid) return { text: this.#choiceHint(choice), failed: true };
973
+ const before = jointView(choice, optionLabel, this.language);
974
+ if (!['owner', 'fish'].includes(submitter)) return { text: before.invalidText, failed: true };
975
+ if (args?.substitute === true) return { text: before.substituteText, failed: true };
976
+ if (!jointCanVote(choice, submitter)) return { text: before.blocked[submitter] ?? before.invalidText, failed: true };
977
+ if (optionId === 'skip') return { text: before.skipText, failed: true };
978
+ if (!choice.options.some(({ id }) => id === optionId)) return { text: this.#choiceHint(choice), failed: true };
981
979
  const votes = { ...(choice.votes ?? {}), [submitter]: optionId };
982
- if (!votes.owner || !votes.fish) {
980
+ const after = jointView({ ...choice, votes }, optionLabel, this.language);
981
+ const decision = jointDecision({ ...choice, votes });
982
+ if (!decision.advance) {
983
+ // 异票不清任何一席:两票都留在票面上,谁都可以改自己那一票,两边一致才前进。
984
+ // (此前是「只保留后投的那一票」,会静默吞掉对方刚投的票,两个人只能互相清票。)
983
985
  session.pendingChoice = { ...choice, votes };
984
986
  session.lastAt = this.#now();
985
987
  await this.#commitState(next);
986
- return { text: submitter === 'owner'
987
- ? `你的选择已保存(${optionLabel(optionId)})。现在等鱼自己提交她那一票;没有以等待或超时当作同意。`
988
- : `鱼的选择已保存(${optionLabel(optionId)})。现在等你(主人)自己投这一票;没有以等待或超时当作同意。` };
989
- }
990
- if (votes.owner !== votes.fish && choice.jointResolution === 'require-agreement') {
991
- session.choices.push({ event: choice.event, option: `${votes.owner}|${votes.fish}`, result: '双方意见不同,决定仍待确认', at: this.#now(), actor: 'joint', votes: [{ actor: 'owner', option: votes.owner }, { actor: 'fish', option: votes.fish }] });
992
- session.pendingChoice = { ...choice, votes: { [submitter]: optionId } };
993
- session.lastAt = this.#now();
994
- await this.#commitState(next);
995
- return { text: `双方选择不同(${optionLabel(votes.owner)} / ${optionLabel(votes.fish)});这一轮重新来:只保留${submitter === 'owner' ? '你' : '鱼'}刚才那一票(${optionLabel(optionId)}),另一方要重新明确选一次。不会按超时视为同意。` };
988
+ return { text: decision.stage === 'disagree' ? after.hint : after.saved[submitter] };
996
989
  }
997
- optionId = votes.owner === votes.fish ? votes.owner
998
- : choice.jointResolution === 'owner-final' ? votes.owner : votes.fish;
990
+ optionId = decision.optionId;
999
991
  jointVotes = [{ actor: 'owner', option: votes.owner }, { actor: 'fish', option: votes.fish }];
1000
992
  submitter = 'joint';
1001
993
  }
@@ -1296,7 +1288,7 @@ export class FunWorld {
1296
1288
  if (rows.some(({ pack }) => isFreePack(pack))) {
1297
1289
  return { text: '这一段是自由模式,用 fun_story_act 说一句来推进;想收尾就用 intent: close。', failed: true };
1298
1290
  }
1299
- const step = describeStoryTrip(session, false, rows, venue, nowMin, visitsBefore, [], this.cfg?.funStoryFreeTurns);
1291
+ const step = describeStoryTrip(session, false, rows, venue, nowMin, visitsBefore, [], this.cfg?.funStoryFreeTurns, this.language);
1300
1292
  if (step.step !== 'move' || (wanted && wanted !== step.nextArea)) {
1301
1293
  return { text: step.blocked || (step.nextArea ? `下一处是「${step.nextArea}」。` : '故事已经走完,可以回家。'), failed: true };
1302
1294
  }
@@ -2004,6 +1996,7 @@ export class FunWorld {
2004
1996
  visitCount: (id) => this.#history(id)?.visitCount ?? 0,
2005
1997
  completedStoryIds: () => this.#completedStoryIds(),
2006
1998
  freeEnabled: this.cfg?.funStoryFree === true,
1999
+ language: this.language,
2007
2000
  runId: this.#state.session?.storyRun?.runId ?? this.#state.draft?.storyRun?.runId ?? null,
2008
2001
  });
2009
2002
  }
@@ -2025,7 +2018,7 @@ export class FunWorld {
2025
2018
  const place = (id) => places.find((venue) => venue.id === id);
2026
2019
  const visits = (id) => this.#history(id)?.visitCount ?? 0;
2027
2020
  const completed = this.#completedStoryIds();
2028
- const trip = describeStoryTrip(outing, Boolean(state.draft), catalog, place(outing?.placeId), nowMin, visits(outing?.placeId), completed, this.cfg?.funStoryFreeTurns);
2021
+ const trip = describeStoryTrip(outing, Boolean(state.draft), catalog, place(outing?.placeId), nowMin, visits(outing?.placeId), completed, this.cfg?.funStoryFreeTurns, this.language);
2029
2022
  if (trip) trip.dmBudget = dmBudget(outing.storyRun.dmBudget);
2030
2023
  // 新的一屏 = 一次「要不要配图」的机会;同一个进度戳只准备一次,不会反复刷。
2031
2024
  this.#maybeAutoImageRequest(trip, outing);
@@ -2293,16 +2286,12 @@ export class FunWorld {
2293
2286
  }
2294
2287
 
2295
2288
  /**
2296
- * 文字通道里这一票是谁的。
2297
- * 普通回合看节点 actor;共同决定看**还缺哪一席的票**——缺鱼就是鱼投,
2298
- * 两票都在(异票要重选)才回到用户。不能只看 `pending.actor === 'joint'` 就当成用户。
2289
+ * 文字通道里这一票默认记在谁名下。
2290
+ * 普通回合看节点 actor;共同决定只看 `jointActor`(空票面与异票回主人,缺鱼那一票才是鱼)。
2291
+ * 这不是权限:空票面时鱼也能先投,调用方带 `as: "fish"` 即可(规则见 src/joint.js)。
2299
2292
  */
2300
2293
  #textVoter(pending) {
2301
- if (pending?.actor === 'joint') {
2302
- if (!pending.votes?.owner) return 'owner';
2303
- return pending.votes?.fish ? 'owner' : 'fish';
2304
- }
2305
- return pending?.actor === 'fish' ? 'fish' : 'owner';
2294
+ return jointActor(pending) ?? (pending?.actor === 'fish' ? 'fish' : 'owner');
2306
2295
  }
2307
2296
 
2308
2297
  async #storyTextStatic(args, trip) {
@@ -2320,7 +2309,10 @@ export class FunWorld {
2320
2309
  }
2321
2310
  const pending = trip.pending;
2322
2311
  if (!pending) return { text: '现在没有待选择的节点,这一步不需要 say。', failed: true };
2323
- const voter = this.#textVoter(pending);
2312
+ // 空票面时两席都能先投,两票不同时两席都能改自己那一票:这两种状态允许调用方显式声明
2313
+ // `as`。只剩一席没投时,声明成另一席会被 #choiceTool 的 jointCanVote 明确拒绝。
2314
+ const declared = args.as === 'fish' ? 'fish' : args.as === 'owner' ? 'owner' : null;
2315
+ const voter = declared ?? this.#textVoter(pending);
2324
2316
  const say = typeof args.say === 'string' ? args.say.replace(/\s+/g, ' ').trim().slice(0, 200) : '';
2325
2317
  if (args.proposalId || args.optionId) {
2326
2318
  const proposal = this.#textProposal;
@@ -2363,14 +2355,15 @@ export class FunWorld {
2363
2355
  #textStaticPayload(trip, extra = {}) {
2364
2356
  const pending = trip?.pending ?? null;
2365
2357
  const joint = pending?.actor === 'joint';
2366
- const votes = joint ? { ...(pending.votes ?? {}) } : null;
2367
- const waitingFor = joint ? (trip?.actor ?? 'owner') : null;
2358
+ const labelOf = (id) => pending?.options?.find(({ id: value }) => value === id)?.label ?? id;
2359
+ const view = joint ? jointView(pending, labelOf, this.language) : null;
2368
2360
  return {
2369
2361
  ok: true, ...extra, step: trip?.step ?? '', stamp: trip?.stamp ?? '', nextArea: trip?.nextArea ?? null,
2370
2362
  pending, narration: trip?.events?.at(-1) ?? '',
2371
- ...(joint ? { joint: { resolution: pending.jointResolution ?? null, votes, waitingFor } } : {}),
2363
+ // stage / seat / canVote 与面板、只读查询同源,主持不用自己比对票面。
2364
+ ...(view ? { joint: { stage: view.stage, resolution: view.resolution, votes: view.votes, waitingFor: view.seat, disagree: view.stage === 'disagree', canVote: view.canVote } } : {}),
2372
2365
  hint: !pending ? '故事已经走完,可以用 intent: close 收尾。'
2373
- : joint ? `共同决定:${waitingFor === 'fish' ? '现在轮到你(鱼)明确提交这一票' : '现在等用户自己提交这一票'};同票才前进,异票只会重来,等待不算同意。`
2366
+ : view ? view.hint
2374
2367
  : '把事件和选项告诉用户;用户说完再用 say 交进来(原话命中选项会直接生效)。',
2375
2368
  };
2376
2369
  }