cortico-world-feast 0.11.0 → 0.11.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/CHANGELOG.md CHANGED
@@ -1,10 +1,21 @@
1
1
  # 更新日志
2
2
 
3
+ ## 0.11.1
4
+
5
+ **持续工作排程开关**
6
+
7
+ - 修正工作开关的作用范围:改为持续生效的工作排程设置。关闭后上班日、加班日、摸鱼日的有效权重为 0,跨天、刷新、重启和清空日程均保持关闭,直到重新开启。
8
+ - 自动生成、模板兜底、重发/重写邀请、模型交回计划、临时调整、单日设置和撤销恢复均受该规则约束;伪装成 personal 分类也不能重新插入工作。
9
+ - 已有日程不自动覆盖;旧 `work:false` 不迁移成长期开关。原有按日预览、确认、清理和撤销保留在「仅修改今天的安排」折叠区。
10
+ - 回归验证:15 个测试文件、468 项通过;真实 Coo GUI 尚待验收。
11
+
3
12
  ## 0.11.0
4
13
 
14
+ - 修正上班开关的作用范围:主控改为持续生效的工作排程设置。关闭后上班日、加班日、摸鱼日的有效权重为 0,跨天和重启不恢复;重新打开才恢复原规则。自动生成、重发/重写和模板兜底均遵守,交回计划及调整不能绕过。已有日程保留,原单日预览、清理和撤销折叠到「仅修改今天的安排」。
15
+
5
16
  **今天更好读:分类时间轴、面板内工作预览、明天摘要与可选空档安排**
6
17
 
7
- 发布准备版本,尚未执行 npm 发布。前后端已接通,面板最终 56/56 通过;真实 Coo GUI 视觉与交互尚未验收。
18
+ 0.11.0 已发布(当前 registry latest 已进入后续版本)。前后端已接通,真实 Coo GUI 视觉与交互当时未验收。
8
19
 
9
20
  - 日程段增加可选 `category`:`sleep` / `work` / `commute` / `meal` / `personal`。`feast_life_plan` 的时段和 `feast_life_adjust` 支持该字段,adjust 的 `category: ""` 表示恢复自动推断。展示字段 `displayCategory` 为旧档推断分类,不把推断结果反写旧档。
10
21
  - 分类用于展示,不直接宣告空闲;`personal` 的「上课」仍为 busy,睡眠文字保护优先,不能用其他分类绕过睡眠保护。日程始终是计划,不算已发生事实。
@@ -13,7 +24,7 @@
13
24
  - 仅按钮主动发送一次既有 `EVENT_LIFE_PLAN`(`feast.life.plan`),`meta.reason = "fill-free"`;不定时自动发送,不新增工具。十分钟冷却跨重启保留,发送失败恢复为可重试状态。
14
25
  - 她可用既有 `feast_life_adjust` 带 `fillRequest` 请求编号回应,也可不理。回应强制检查请求区间仍为空且尚在未来,只能调整请求范围内的空档,不改其他计划、不覆盖后来安排,不记作事实;该限制不因普通过去调整开关而放开。
15
26
  - 本轮工具仍 18 个、事件仍 7 个,不加 ENV 常驻段。以相同本地估算方法对比工具 `name` / `description` / `parameters` JSON:约 2518 → 2664 token,净增约 146;不是精确 tokenizer 计数。
16
- - 本轮 life **59/59**、life-world **78/78**、state **35/35**、world **55/55**、panels **56/56** 通过;最终 `npm test` 全套 15 个文件、462 项通过,规范、自检、声明和离线发布检查通过。真实 Coo GUI 待验收。2026-11-18 发布准备时 npm 查询确认线上 latest 为 0.10.1,0.11.0 尚未占用;这不代表新版本已发布。
27
+ - 本轮 life **59/59**、life-world **78/78**、state **35/35**、world **55/55**、panels **56/56** 通过;最终 `npm test` 全套 15 个文件、462 项通过,规范、自检、声明和离线发布检查通过。真实 Coo GUI 待验收。2026-11-19 使用 npm 官方 registry 查询确认线上 latest 为 0.11.0;0.11.1 是否可发布须以发布前再次查询为准。
17
28
 
18
29
  ## 0.10.1
19
30
 
package/GUIDE.md CHANGED
@@ -125,7 +125,7 @@
125
125
 
126
126
  她有一份**自己给自己排的日程**。你不用管它,但知道它在哪儿、能改什么,用起来会顺很多。
127
127
 
128
- > 本节分类、首页重组、面板内工作确认和空档安排邀请随 `0.11.0` 提供。发布准备已通过本地测试(含面板 56/56),真实 Coo GUI 待验收;既有旧版安装不包含这些新增行为。
128
+ > 分类、首页重组、面板内工作确认和空档安排邀请随 `0.11.0` 提供;持续工作排程开关随 `0.11.1` 提供。`0.11.1` 本地回归 468 项通过,真实 Coo GUI 视觉及窄屏仍待验收;旧版安装不包含持续工作排程设置。
129
129
 
130
130
  ### 它是怎么来的
131
131
 
@@ -152,9 +152,17 @@
152
152
 
153
153
  旧日程没有分类也照常展示:`displayCategory` 只在展示时推断,不把推断结果反写旧档。**分类不代表空闲**:「上课」即使归 personal 仍然忙;文字明确说在睡觉时,睡眠保护优先,不能靠换个分类把她叫醒。
154
154
 
155
- ### 关闭上班与邀请她安排空档
155
+ ### 上不上班:持续生效的排程设置
156
156
 
157
- 关闭上班前,本轮改为在面板内列出受影响时段的**修改前 / 修改后**对照,由你确认后执行(替换系统确认弹窗,前端待验收)。明确工作时段才改成「自由安排」;公司附近吃饭、下班后看电影、工作室画画等生活安排会保留。旧的「不上班但仍留着工作段」只提示,可由你主动清理,不在读旧档时悄悄改掉。
157
+ 状态卡的「上不上班(持续生效)」控制之后的工作排程。选择「不上班」后,上班日、加班日和摸鱼日的有效权重均为 0,每个未来工作日也按不上班安排;跨天、刷新、重启和清空日程都不会自动恢复。选择「上班」才恢复原有抽选规则,并不强制每天上班。即使配置固定为上班类日型,也不能绕过关闭设置。
158
+
159
+ 写明天、重写邀请和缺失日程的模板兜底都会遵守此规则。关闭时会明确告诉她不要排上班、加班或工作通勤;交回计划及临时改动也会校验,不能换成 personal 分类后重新插入工作。
160
+
161
+ 规则单独保存在 `feast/work-policy.json`,不覆盖已写好的日程,也不把旧档的 `work:false` 自动升级成长期开关。已经写好的明天可按新规则请她重新想想;今天需要清理时展开「仅修改今天的安排」。设置读取失败会显示恢复入口,不会静默回到上班。
162
+
163
+ ### 仅修改今天与邀请她安排空档
164
+
165
+ 在「仅修改今天的安排」里,关闭上班前,本轮改为在面板内列出受影响时段的**修改前 / 修改后**对照,由你确认后执行(替换系统确认弹窗,前端待验收)。明确工作时段才改成「自由安排」;公司附近吃饭、下班后看电影、工作室画画等生活安排会保留。旧的「不上班但仍留着工作段」只提示,可由你主动清理,不在读旧档时悄悄改掉。
158
166
 
159
167
  关闭后保留一次撤销;后续工作字段或时段被改动就拒绝旧撤销,只改饭点仍能撤销并保留新饭点。预览后若有人改了计划,旧确认会失效,需重新预览。
160
168
 
package/PUBLISHING.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # 发布到 Coo 扩展市场
2
2
 
3
- ## 本次发布:0.11.0
3
+ ## 本次发布:0.11.1
4
4
 
5
- 包名:`cortico-world-feast`。本次更新包含首页层级和分类时间轴、面板内上班变更对照、明天摘要、活动分类,以及主动补充关闭上班后空出来的时段。
5
+ 包名:`cortico-world-feast`。本次更新将「上不上班」改为持续生效的工作排程设置:关闭后工作类日型有效权重为 0,直至重新开启;旧日程保留,按日预览、确认、清理和撤销仍可单独使用。
6
6
 
7
- 2026-11-18 发布准备时,通过 npm 官方 registry 查询:线上 `latest` 为 `0.10.1`,`0.11.0` 尚未占用。版本占用以发布时再次查询为准。准备发布不等于已发布;git 提交、推送和 npm 发布均需实际执行后才算完成。
7
+ 2026-11-19 使用 npm 官方 registry 确认 `latest` 为 `0.11.0`,`0.11.1` 查询返回未发布(E404)。正式发布前再次确认版本占用。准备发布不等于已发布;git 提交、推送和 npm 发布均需实际执行后才算完成。
8
8
 
9
- 本地回归基线:15 个测试文件、462 项通过,含面板 56/56。真实 Coo GUI 的视觉、窄屏布局和交互尚未验收;当前使用 `experimental` 标签。新版本不会自动改写旧日程;缺失分类只推断展示。
9
+ 本地回归:15 个测试文件、468 项通过,面板 58/58。真实 Coo GUI 的视觉与窄屏交互尚未验收;当前使用 `experimental` 标签。旧版日程不自动改写;持续开关独立存储于 `feast/work-policy.json`。
10
10
 
11
11
  ## 1. 在项目目录执行发布校验
12
12
 
@@ -45,7 +45,7 @@ New-Item -ItemType Directory -Force '.tmp/release' | Out-Null
45
45
  npm pack --json --pack-destination .tmp/release
46
46
  ```
47
47
 
48
- 归档位于忽略目录,避免误提交。本轮发布准备若生成归档,其文件名为 `cortico-world-feast-0.11.0.tgz`。
48
+ 归档位于忽略目录,避免误提交。本轮发布准备若生成归档,其文件名为 `cortico-world-feast-0.11.1.tgz`。
49
49
 
50
50
  ### Windows 下的缓存目录
51
51
 
@@ -62,7 +62,7 @@ npm pack --json --pack-destination .tmp/release --cache .tmp/npm-release-cache
62
62
 
63
63
  发布前核对 `git diff`,只提交本次发布相关文件。不要使用 `git restore` 或 `git checkout --` 丢弃工作区改动,也不要盲目 `git add -A` 收进无关文件。
64
64
 
65
- 当前版本已在 `package.json` 中准备为 `0.11.0`,`CHANGELOG.md` 有同名二级标题。无需再次运行会改变版本号的 `npm version`。
65
+ 当前版本已在 `package.json` 中准备为 `0.11.1`,`CHANGELOG.md` 有同名二级标题。无需再次运行会改变版本号的 `npm version`。
66
66
 
67
67
  需要提交/打标签时,在审阅差异后由维护者执行;提交和标签成功后再推送。本轮自动准备不会替维护者创建提交或远程推送。
68
68
 
@@ -81,18 +81,18 @@ npm publish
81
81
 
82
82
  尚未登录时运行 `npm login`。按 npm 当前返回的账号认证或二次验证提示操作;不要把密码、token、OTP 或恢复码粘贴进聊天或仓库文件。不要预先写入占位验证码。账号权限或认证失败不等于代码检查失败。
83
83
 
84
- `npm publish` 是正式对外发布,版本发布后不能用同名同版本覆盖。若发布前查询发现 `0.11.0` 已存在,停止发布并选择新的版本号,同时更新版本说明和重新校验。
84
+ `npm publish` 是正式对外发布,版本发布后不能用同名同版本覆盖。若发布前查询发现 `0.11.1` 已存在,停止发布并选择新的版本号,同时更新版本说明和重新校验。
85
85
 
86
86
  ## 5. 发布后验证
87
87
 
88
88
  只有 `npm publish` 成功后,才进行以下确认:
89
89
 
90
90
  ```powershell
91
- npm view cortico-world-feast@0.11.0 version dist.integrity --json --registry=https://registry.npmjs.org
91
+ npm view cortico-world-feast@0.11.1 version dist.integrity --json --registry=https://registry.npmjs.org
92
92
  npm view cortico-world-feast dist-tags --json --registry=https://registry.npmjs.org
93
93
  ```
94
94
 
95
- 确认版本为 `0.11.0`、`latest` 指向预期版本。registry 或市场索引可能有缓存,查询失败时先保留错误输出,不要立即再次改版本发布。
95
+ 确认版本为 `0.11.1`、`latest` 指向预期版本。registry 或市场索引可能有缓存,查询失败时先保留错误输出,不要立即再次改版本发布。
96
96
 
97
97
  Coo 扩展市场的收录流程以索引仓当前说明为准。本项目保留 `cortico-world` 关键字和仓库信息;不要将“已发到 npm”直接写成“市场已收录”。
98
98
 
@@ -102,7 +102,8 @@ Coo 扩展市场的收录流程以索引仓当前说明为准。本项目保留
102
102
 
103
103
  - 今天状态卡、当前/接下来和实际记录区分清楚;明暗主题、窄屏无溢出。
104
104
  - 分类时间轴当前高亮、细节展开、分类修正和草稿保留正常。
105
- - 关闭上班的前后对照、取消、确认、撤销和过期预览拒绝正常。
105
+ - 长期工作排程开关跨天与重启保持状态;关闭后未来日型不排工作,重新开启恢复原规则。
106
+ - 长期关闭时仍可在「仅修改今天的安排」里清理今天;按日撤销不得恢复长期禁止的工作日程。原有预览、确认、撤销和过期预览拒绝正常。
106
107
  - 明天摘要区分等待、她写的计划和模板来源,完整时间线可展开。
107
108
  - 空档邀请只在用户点击后发送;冷却、拒绝越界回应、保留其他计划正常。
108
109
  - 饮食、跨天小事和恢复入口仍可使用,计划不会变成实际活动记录。
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  先给她一天,再给她一桌饭。
4
4
 
5
+ 当前准备版本:`0.11.1`。在 `0.11.0` 上修正「上不上班」为持续工作排程开关;发布状态以 npm registry 为准。
6
+
5
7
  0.10.0 的「今天」是生活首页:当前安排、实际记下的活动与饮食、接下来分开呈现,过去的计划不会自动算成完成。她或主人可以明确留下最多 8 件「还想继续的小事」,跨天保留,写明天时供她选择;完成或放下都要明确操作,不催促。她用 `feast_life_thread` 的 `list/add/done/drop`,主人在首页操作。小事独立保存在 `feast/threads.json`,不随清日程删除。
6
8
 
7
9
  记录正常更新时保留一份上次有效内容的 `.bak`。损坏记录在首页显示异常,支持重新读取;有有效备份才显示恢复,恢复前另存原文件为 `.corrupt-时间戳-标识`。主记录损坏时仍能打开首页恢复,吃饭相关写入暂停。等待她写明天超过十分钟后,可以手动重发邀请,原日程保留。
@@ -16,8 +18,8 @@
16
18
  | 扩展 | 联动内容 | 开关 |
17
19
  | --- | --- | --- |
18
20
  | 「生图工作室」`cortico-world-imggen` | 写日程时列出衣柜/场景,发图时穿着、地点对得上 | `lifeWardrobeOn` |
19
- | 「娱乐时间」`cortico-world-fun` | 「自己的时间」里多一行,她能真出门逛 | `lifeFreeFunOn` |
20
- | 「鱼的小世界」`cortico-world-map` | 「自己的时间」里多一行,她会想起周围那些地方 | `lifeFreeMapOn` |
21
+ | 「娱乐时间」`cortico-world-fun` | 写日程时可查场所、营业时段和可逛项目,「自己的时间」里也会提示她去逛 | `lifeFreeFunOn` |
22
+ | 「鱼的小世界」`cortico-world-map` | 写日程时可查登记地点并沿用正名,「自己的时间」里也会提示她看看周围 | `lifeFreeMapOn` |
21
23
  | 「鱼的每一天」(别的扩展反过来用它) | 它们通过 `lifeFreeMenu` 这个官方配置槽被叫到 | — |
22
24
 
23
25
  前三个都是**自动检测**:读 `config.json` 里对方那一个 `enabled` 字段,没装就不提;详情见下面各自那一节。
package/dist/webui.js CHANGED
@@ -320,7 +320,7 @@ const TABLE = {
320
320
  todayFreePlan: '请她想想空出来的时间', todayFreePending: '已经请她看看空出来的时间。', todayFreeNone: '今天没有明确留出的时间段。',
321
321
  workCompareTitle: '确认今天不上班', workBefore: '当前安排', workAfter: '不上班后', workNoChanges: '没有识别到工作或通勤时段;只会更新上班状态。',
322
322
  workCancel: '取消', workConfirm: '确认修改', workConflictNote: (n) => `仍有 ${n} 段工作安排未清理。`, workUndo: '撤销关闭上班', workUndoing: '正在撤销…',
323
- todayPlanSendAt: (s) => `请求时间:${s}`, todayPlanUpdatedAt: (s) => `更新时间:${s}`, todayTimelineLabel: '分类时间轴', todayTimelineOpen: '展开完整时间线', todayTimelineClose: '收起完整时间线', todayCategoryAuto: '自动分类', todayCategoryLabel: '活动分类', workPreviewTitle: '原安排与自由安排', workPreviewCancel: '取消', workPreviewConfirm: '确认不上班',
323
+ todayPlanSendAt: (s) => `请求时间:${s}`, todayPlanUpdatedAt: (s) => `更新时间:${s}`, todayTimelineLabel: '分类时间轴', todayTimelineOpen: '展开完整时间线', todayTimelineClose: '收起完整时间线', todayCategoryAuto: '自动分类', todayCategoryLabel: '活动分类', workPreviewTitle: '原安排与自由安排', workPreviewCancel: '取消', workPreviewConfirm: '确认今天不上班',
324
324
  workCategory: '工作', sleepCategory: '睡眠', commuteCategory: '通勤', mealCategory: '用餐', personalCategory: '个人',
325
325
  workActivity: '上班', sleepActivity: '睡觉', commuteActivity: '通勤', mealActivity: '吃饭', personalActivity: '自己的时间',
326
326
  workPreviewStale: '预览已过期,请重新预览后确认。',
@@ -328,12 +328,14 @@ const TABLE = {
328
328
  todayStorage: '存储问题', todayReload: '重新读取', todayRestore: '从备份恢复', todayRestoreConfirm: (n) => `确认从备份恢复「${n}」?当前内容会被替换。`,
329
329
  todayThreadTitle: '她留下的线索', todayThreadPh: '记下一个想法…', todayThreadAdd: '记下想法', todayThreadOwner: '主人记下', todayThreadCoo: '她留下', todayThreadDone: '完成', todayThreadDrop: '搁下', todayThreadDoneLabel: '已完成', todayThreadDropLabel: '已搁下',
330
330
  todayPlanRetry: '重新发送', todayPlanRetryConfirm: '明天的计划还在等待中。要重新发送请求吗?',
331
- /* --- 今天上不上班 / 饭点归谁定(0.10.0)--- */
332
- workTitle: '今天上不上班',
333
- workOn: '上班',
334
- workOff: '不上班',
335
- workHint: '说一声就改:不上班时会移除日程里的工作事件,其他安排保留。',
336
- workNone: '这一天还没有日程,先请她写或等她自己写。',
331
+ /* --- 长期工作排程 / 仅修改今天的安排 --- */
332
+ workTitle: '上不上班(持续生效)', workOn: '开启长期工作排程', workOff: '关闭长期工作排程',
333
+ workPolicyEnabled: '长期工作排程:开启', workPolicyDisabled: '长期工作排程:关闭',
334
+ workPolicyHint: '关闭后,上班、加班、摸鱼日型权重都会变为 0,直到重新开启。已有计划不会自动更改,可在下方另行调整。',
335
+ workPolicyError: '工作排程规则读取或保存失败,暂时无法切换。', workPolicySaving: '正在保存…',
336
+ workDailyTitle: '仅修改今天的安排', workTodayOn: '今天照原安排上班', workTodayOff: '今天不上班(仅今天)',
337
+ workHint: '这里只改今天的日程,不影响长期工作排程。不上班会先显示预览,确认后移除日程里的工作事件,其他安排保留。',
338
+ workNone: '今天还没有可修改的日程;长期工作排程开关仍可使用。',
337
339
  mealByHer: '饭点由她定',
338
340
  mealByConfig: '饭点走配置',
339
341
  mealHerSlots: (s) => `她定的是 ${s}`,
@@ -501,12 +503,14 @@ const TABLE = {
501
503
  todayStorage: 'Storage issues', todayReload: 'Reload', todayRestore: 'Restore from backup', todayRestoreConfirm: (n) => `Restore “${n}” from backup? This replaces the current contents.`,
502
504
  todayThreadTitle: 'Threads she left', todayThreadPh: 'Note an idea…', todayThreadAdd: 'Add note', todayThreadOwner: 'Noted by you', todayThreadCoo: 'Left by her', todayThreadDone: 'Done', todayThreadDrop: 'Drop', todayThreadDoneLabel: 'Done', todayThreadDropLabel: 'Dropped',
503
505
  todayPlanRetry: 'Resend request', todayPlanRetryConfirm: 'Tomorrow’s plan is still pending. Resend the request?',
504
- /* --- work today / who sets the meal times (0.10.0) --- */
505
- workTitle: 'Working today?',
506
- workOn: 'Working',
507
- workOff: 'Off work',
508
- workHint: 'One tap changes just this: on a day off the schedule should not still say commute. Nothing else in the day is touched.',
509
- workNone: 'This day has no schedule yet — ask her for one, or wait for her to write it.',
506
+ /* --- persistent work scheduling / today-only changes --- */
507
+ workTitle: 'Working or not (ongoing schedule)', workOn: 'Work schedule on', workOff: 'Work schedule off',
508
+ workPolicyEnabled: 'Ongoing work schedule: on', workPolicyDisabled: 'Ongoing work schedule: off',
509
+ workPolicyHint: 'When disabled, work, overtime, and slacking-off day types all have weight 0 until re-enabled. Existing plans are not changed automatically; adjust them below if needed.',
510
+ workPolicyError: 'The work-scheduling rule could not be loaded or saved. Switching is temporarily unavailable.', workPolicySaving: 'Saving…',
511
+ workDailyTitle: 'Change today’s schedule only', workTodayOn: 'Work as planned today', workTodayOff: 'Off work today (today only)',
512
+ workHint: 'This only changes today’s schedule, not the ongoing work rule. Turning work off previews the changes first; confirming removes work events while keeping other arrangements.',
513
+ workNone: 'There is no schedule to change today. The ongoing work-schedule switch is still available.',
510
514
  mealByHer: 'Her own meal times',
511
515
  mealByConfig: 'Meal times from config',
512
516
  mealHerSlots: (s) => `she set ${s}`,
@@ -1416,15 +1420,10 @@ const todayPanel = {
1416
1420
  return head;
1417
1421
  }
1418
1422
 
1419
- /**
1420
- * 「今天上不上班」+ 饭点归谁定(0.10.0)。
1421
- *
1422
- * 只有两件事,所以做成**一块**而不是两个面板:主人想改的就是「今天算不算上班」,
1423
- * 顺带一眼看到今天几点吃、这组档位是她定的还是配置兜底的。
1424
- * 两个按钮而不是一个 checkbox:翻开关时点错一次也算改,两个键各自表达一个意思更不容易点错。
1425
- */
1423
+ /** Persistent work-policy switch plus the existing, date-scoped preview/undo controls. */
1426
1424
  let workPreview = null;
1427
1425
  let workPreviewDate = null;
1426
+ let workDailyOpen = false;
1428
1427
  async function setWork(on, button, revision = null) {
1429
1428
  button.disabled = true; operating = true;
1430
1429
  try {
@@ -1444,30 +1443,62 @@ const todayPanel = {
1444
1443
  } catch (err) { toast(root, ctx, t.failed(err?.message ?? err), true); }
1445
1444
  finally { operating = false; render(); }
1446
1445
  }
1446
+ async function setWorkScheduling(enabled, button) {
1447
+ if (operating || data.workSchedulingError || typeof data.workSchedulingEnabled !== 'boolean') return;
1448
+ button.disabled = true; operating = true;
1449
+ try {
1450
+ const r = await ctx.invoke('workPolicy', [{ enabled }]);
1451
+ if (r?.ok === false) toast(root, ctx, r.message ?? t.sayNo, true);
1452
+ else toast(root, ctx, r?.message ?? t.sayOk);
1453
+ await refresh();
1454
+ } catch (err) {
1455
+ toast(root, ctx, t.failed(err?.message ?? err), true);
1456
+ await refresh();
1457
+ } finally { operating = false; render(); }
1458
+ }
1447
1459
 
1448
1460
  function workSection() {
1449
1461
  if (!data?.enabled) return el('div');
1450
1462
  const box = el('div', 'feast-block');
1451
1463
  box.appendChild(el('div', 'feast-block-t', t.workTitle));
1464
+
1465
+ const scheduleError = Boolean(data.workSchedulingError) || typeof data.workSchedulingEnabled !== 'boolean';
1466
+ const policyRow = el('div', 'feast-act');
1467
+ const onBtn = el('button', data.workSchedulingEnabled === true ? 'feast-btn-primary' : null, t.workOn);
1468
+ const offBtn = el('button', data.workSchedulingEnabled === false ? 'feast-btn-primary' : null, t.workOff);
1469
+ onBtn.disabled = operating || scheduleError || data.workSchedulingEnabled === true;
1470
+ offBtn.disabled = operating || scheduleError || data.workSchedulingEnabled === false;
1471
+ onBtn.onclick = () => void setWorkScheduling(true, onBtn);
1472
+ offBtn.onclick = () => void setWorkScheduling(false, offBtn);
1473
+ policyRow.appendChild(onBtn); policyRow.appendChild(offBtn);
1474
+ box.appendChild(policyRow);
1475
+ box.appendChild(el('div', 'feast-note', data.workSchedulingEnabled ? t.workPolicyEnabled : t.workPolicyDisabled));
1476
+ box.appendChild(el('div', 'feast-note', t.workPolicyHint));
1477
+ if (scheduleError) box.appendChild(el('div', 'feast-note is-bad', t.workPolicyError));
1478
+
1479
+ const daily = el('details', 'feast-work-daily');
1480
+ daily.open = Boolean(workDailyOpen || workPreview);
1481
+ daily.addEventListener('toggle', () => { workDailyOpen = daily.open; });
1482
+ daily.appendChild(el('summary', null, t.workDailyTitle));
1452
1483
  const day = data.today;
1453
1484
  const ready = Boolean(day?.items?.length) && day.source !== 'pending';
1454
1485
  if (!ready) {
1455
- box.appendChild(el('div', 'feast-empty', t.workNone));
1486
+ daily.appendChild(el('div', 'feast-empty', t.workNone));
1456
1487
  } else {
1457
1488
  const row = el('div', 'feast-act');
1458
- const onBtn = el('button', data.work ? 'feast-btn-primary' : null, t.workOn);
1459
- const offBtn = el('button', !data.work ? 'feast-btn-primary' : null, t.workOff);
1460
- onBtn.disabled = operating || data.work === true;
1461
- offBtn.disabled = operating || (data.work === false && !data.workConflicts?.length);
1462
- onBtn.onclick = () => void setWork(true, onBtn);
1463
- offBtn.onclick = () => void previewWork(offBtn);
1464
- row.appendChild(onBtn); row.appendChild(offBtn);
1465
- box.appendChild(row);
1466
- box.appendChild(el('div', 'feast-note', t.workHint));
1467
- if (data.workConflicts?.length) box.appendChild(el('div', 'feast-note', t.workConflictNote(data.workConflicts.length)));
1489
+ const todayOn = el('button', data.work ? 'feast-btn-primary' : null, t.workTodayOn);
1490
+ const todayOff = el('button', !data.work ? 'feast-btn-primary' : null, t.workTodayOff);
1491
+ todayOn.disabled = operating || scheduleError || data.workSchedulingEnabled === false || data.work === true;
1492
+ todayOff.disabled = operating || scheduleError || (data.work === false && !data.workConflicts?.length);
1493
+ todayOn.onclick = () => void setWork(true, todayOn);
1494
+ todayOff.onclick = () => void previewWork(todayOff);
1495
+ row.appendChild(todayOn); row.appendChild(todayOff);
1496
+ daily.appendChild(row);
1497
+ daily.appendChild(el('div', 'feast-note', t.workHint));
1498
+ if (data.workConflicts?.length) daily.appendChild(el('div', 'feast-note', t.workConflictNote(data.workConflicts.length)));
1468
1499
  if (data.workUndoAvailable) {
1469
1500
  const undo = el('button', 'feast-btn', t.workUndo);
1470
- undo.disabled = operating;
1501
+ undo.disabled = operating || data.workSchedulingEnabled === false || scheduleError;
1471
1502
  undo.onclick = async () => {
1472
1503
  undo.disabled = true;
1473
1504
  try {
@@ -1476,7 +1507,7 @@ const todayPanel = {
1476
1507
  await refresh();
1477
1508
  } catch (err) { toast(root, ctx, t.failed(err?.message ?? err), true); undo.disabled = false; }
1478
1509
  };
1479
- box.appendChild(undo);
1510
+ daily.appendChild(undo);
1480
1511
  }
1481
1512
  }
1482
1513
 
@@ -1502,9 +1533,11 @@ const todayPanel = {
1502
1533
  if (!workPreview?.revision) { workPreview = null; toast(root, ctx, t.workPreviewStale, true); render(); return; }
1503
1534
  void setWork(false, confirm, workPreview.revision);
1504
1535
  };
1505
- actions.appendChild(cancel); actions.appendChild(confirm); panel.appendChild(actions); box.appendChild(panel);
1536
+ actions.appendChild(cancel); actions.appendChild(confirm); panel.appendChild(actions); daily.appendChild(panel);
1506
1537
  }
1507
- // 饭点:她定了就说她定的,没定就说配置那组。不重画时间线——那一块已经标过饭点了。
1538
+ box.appendChild(daily);
1539
+
1540
+ // Meal times are informational and remain visible outside the collapsed day-only editor.
1508
1541
  const slots = data.mealSlots ?? [];
1509
1542
  if (slots.length) {
1510
1543
  const line = el('div', 'feast-day');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-feast",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "鱼的每一天 · 先给她一天,再给她一桌饭:她自己的日程(每晚自己写明天,可以按日型给她备一张「能做的事」清单,到点过自己的时间、做完记一笔)+ 824 道菜的桌子,能端一道、端一桌,也能和她一起吃一顿。可以跟「生图工作室」「娱乐时间」「鱼的小世界」各接一小截,不装也完整可用。",
5
5
  "license": "MIT",
6
6
  "author": "青",
package/src/life/plan.js CHANGED
@@ -28,7 +28,7 @@ import { doingsLines } from './doings.js';
28
28
  */
29
29
  export function planEventText({
30
30
  date, type, recent = '', mealSlots = '11:30,18:00', who = {}, wardrobe = '', doings = [],
31
- rewrite = false, mealByHer = false,
31
+ rewrite = false, mealByHer = false, mapOn = false, funOn = false, noWork = false,
32
32
  } = {}) {
33
33
  const name = who.name || '她';
34
34
  const lines = [
@@ -37,11 +37,19 @@ export function planEventText({
37
37
  : `【鱼的每一天 · 她的一天】想想 ${dateLabel(date)}(${date})怎么过:这是你自己的日子,不是待办。`,
38
38
  `这一天按「${type?.name || '普通的一天'}」来:${type?.guide || '照你平常的样子过一天。'}`,
39
39
  ];
40
+ if (noWork) lines.push('主人已持续关闭工作排程:上班日、加班日、摸鱼日的权重为 0。不要安排上班、加班或工作通勤;work 写 false。此规则持续到主人重新开启,不能用单日决定绕过。');
40
41
  if (rewrite) {
41
42
  lines.push('(之前那一版已经收了;不想改就用 feast_life_view 看一眼再照着交回一遍,改主意也完全可以。)');
42
43
  }
43
44
  // 主人备的「能做的事」:紧跟在日型后面,让她写每一段时手边有具体的事可选。
44
45
  lines.push(...doingsLines(doings));
46
+ if (mapOn || funOn) {
47
+ lines.push('如果想安排外出,交回日程前先按需查一下要去的地方:');
48
+ if (mapOn) lines.push('- 附近散步、去常去的地方或回家:用 map_places 找登记地点,需要详情时用 map_look,location 用地图正名。');
49
+ if (funOn) lines.push('- 想安排一趟娱乐出游:用 fun_places 查场所和可逛项目,按计划时段参考营业时间,location 写实际打算去的场所正名,activity / detail 写想做的事。现在只做计划,到了那天真要出发时再用 fun_go。');
50
+ if (mapOn && funOn) lines.push('- 如果 map_look 提到娱乐时间里相近的场所,先用 fun_places 核对。选定去哪儿,location 就写哪一处的正名。');
51
+ lines.push('没有合适的地点,或想在家休息,就照自己的想法排。');
52
+ }
45
53
  if (recent) lines.push(`最近几天:\n${recent}`);
46
54
  if (wardrobe) lines.push(wardrobe);
47
55
  lines.push(mealByHer
package/src/world.js CHANGED
@@ -515,6 +515,37 @@ export class FeastWorld {
515
515
  return typeof this.cfg?.lifeDayType === 'string' ? this.cfg.lifeDayType.trim() : '';
516
516
  }
517
517
 
518
+ #workPolicyFile() {
519
+ return join(this.dataDir, 'feast', 'work-policy.json');
520
+ }
521
+
522
+ async #workSchedulingEnabled() {
523
+ const policy = await readStoredJson(this.#workPolicyFile());
524
+ if (policy === null) return true;
525
+ if (typeof policy.enabled !== 'boolean') throw new Error('工作排程设置损坏。');
526
+ return policy.enabled;
527
+ }
528
+
529
+ async #workBlocked(date, now) {
530
+ return date >= dayIn(this.timezone, now) && !(await this.#workSchedulingEnabled());
531
+ }
532
+
533
+ #isScheduledWork(item) {
534
+ return isWorkEvent(item) || isWorkEvent({ ...item, category: undefined });
535
+ }
536
+
537
+ #workBlockedResult() {
538
+ return { text: '主人已关闭工作排程。请从日程中去掉上班、加班和工作通勤,再提交。', failed: true };
539
+ }
540
+
541
+ #pickLifeDayType(date, noWork) {
542
+ const forced = this.#lifeDayType();
543
+ const type = pickDayType(DEFAULT_DAY_TYPES, date, forced, this.#random, noWork ? false : null);
544
+ return noWork && isWorkDayType(type)
545
+ ? pickDayType(DEFAULT_DAY_TYPES, date, '', this.#random, false)
546
+ : type;
547
+ }
548
+
518
549
  #lifeOn() {
519
550
  return this.cfg?.lifeEnabled !== false;
520
551
  }
@@ -1777,7 +1808,7 @@ export class FeastWorld {
1777
1808
  const today = await readDay(this.dataDir, z.date);
1778
1809
  if (!today || today.source === 'pending' || !today.items.length) {
1779
1810
  let filled = templateDay(z.date, {
1780
- dayTypeId: this.#lifeDayType(), rand: this.#random, now,
1811
+ dayTypeId: this.#pickLifeDayType(z.date, await this.#workBlocked(z.date, now)).id, now,
1781
1812
  by: 'catch-up', maxItems: this.#lifeMaxItems(),
1782
1813
  });
1783
1814
  // 模板日程也补 outfit(库非空时)——否则模板兜底的日子永远没穿着,联动断在兜底上。
@@ -1797,11 +1828,12 @@ export class FeastWorld {
1797
1828
  const at = parseClock(this.cfg?.lifeGenerateAt ?? DEFAULTS.lifeGenerateAt);
1798
1829
  if (at === null || z.minute < at || tomorrow) return;
1799
1830
  // 先落占位再推:重启、tick 重入都不会重复叫她写同一天。
1800
- const type = pickDayType(DEFAULT_DAY_TYPES, tomorrowDate, this.#lifeDayType(), this.#random);
1831
+ const noWork = await this.#workBlocked(tomorrowDate, now);
1832
+ const type = this.#pickLifeDayType(tomorrowDate, noWork);
1801
1833
  try {
1802
1834
  await writeDay(this.dataDir, pendingDay(tomorrowDate, type, now));
1803
1835
  this.#lifeTomorrow = await readDay(this.dataDir, tomorrowDate);
1804
- await this.#pushLifePlan(tomorrowDate, type, z.date, now);
1836
+ await this.#pushLifePlan(tomorrowDate, type, z.date, now, { noWork });
1805
1837
  } catch (err) {
1806
1838
  // 发不出去就撤掉占位,下一拍再试;不然这一天会永远停在「等她写」。
1807
1839
  this.#lifeTomorrow = null;
@@ -1810,7 +1842,7 @@ export class FeastWorld {
1810
1842
  }
1811
1843
  }
1812
1844
 
1813
- async #pushLifePlan(date, type, fromDate, now, { rewrite = false } = {}) {
1845
+ async #pushLifePlan(date, type, fromDate, now, { rewrite = false, noWork = false } = {}) {
1814
1846
  const host = this.#host;
1815
1847
  if (!host?.pushEvent) throw new Error('宿主没有 pushEvent');
1816
1848
  const recent = await recentSummary(this.dataDir, fromDate, 3);
@@ -1818,6 +1850,11 @@ export class FeastWorld {
1818
1850
  const wardrobe = this.#wardrobeOn() ? wardrobeText(this.#wardrobe) : '';
1819
1851
  // 主人按日型备的「能做的事」:留空就是空数组,那段整段不出现。
1820
1852
  const doings = doingsFor(parseDoings(this.cfg?.lifeDoings), type);
1853
+ // 写日程的地点联动不依赖自由时间提醒。
1854
+ const [mapOn, funOn] = await Promise.all([
1855
+ this.cfg?.lifeFreeMapOn !== false && readMapEnabled(this.dataDir),
1856
+ this.cfg?.lifeFreeFunOn !== false && readFunEnabled(this.dataDir),
1857
+ ]);
1821
1858
  let continuation = '';
1822
1859
  try { continuation = threadHint(await readThreads(this.dataDir)); }
1823
1860
  catch (err) { host.log?.warn?.('鱼的每一天:小事记录未读到,邀请仍正常发送', { err: msg(err) }); }
@@ -1828,7 +1865,7 @@ export class FeastWorld {
1828
1865
  origin: 'internal',
1829
1866
  ts: new Date(now).toISOString(),
1830
1867
  text: [planEventText({
1831
- date, type, recent, mealSlots: slots, wardrobe, doings, rewrite,
1868
+ date, type, recent, mealSlots: slots, wardrobe, doings, rewrite, noWork, mapOn, funOn,
1832
1869
  mealByHer: this.cfg?.mealSlotsByHer !== false && this.#lifeOn(),
1833
1870
  }), continuation].filter(Boolean).join('\n\n'),
1834
1871
  meta: { date, dayType: type.id, ...(rewrite ? { rewrite: true } : {}) },
@@ -1851,18 +1888,21 @@ export class FeastWorld {
1851
1888
  const date = addDays(z.date, 1);
1852
1889
  const existing = await readDay(this.dataDir, date);
1853
1890
  const written = Boolean(existing?.items?.length) && existing.source !== 'pending';
1891
+ const noWork = await this.#workBlocked(date, now);
1854
1892
 
1855
1893
  if (existing?.source === 'pending') {
1856
1894
  const last = Math.max(existing.generatedAt || 0, this.#lifeRewriteAt[date] || 0);
1857
1895
  if (!retry || now - last < REWRITE_COOLDOWN_MS) {
1858
1896
  return `已经在等她想 ${dateLabel(date)} 了;十分钟后可以手动重新发送,她不写时仍用模板兜底。`;
1859
1897
  }
1860
- await this.#pushLifePlan(date, existing.dayType, z.date, now);
1898
+ const type = noWork && isWorkDayType(existing.dayType)
1899
+ ? this.#pickLifeDayType(date, true) : existing.dayType;
1900
+ await this.#pushLifePlan(date, type, z.date, now, { noWork });
1861
1901
  this.#lifeRewriteAt[date] = now;
1862
1902
  return `已重新发送 ${dateLabel(date)} 的邀请,原来的记录已保留。`;
1863
1903
  }
1864
1904
 
1865
- const type = pickDayType(DEFAULT_DAY_TYPES, date, this.#lifeDayType(), this.#random);
1905
+ const type = this.#pickLifeDayType(date, noWork);
1866
1906
  let placeholder = false;
1867
1907
  if (!written) {
1868
1908
  // 没东西可覆盖才落占位:占位是为了防重复叫她,不是用来抹掉她已经写好的。
@@ -1878,7 +1918,7 @@ export class FeastWorld {
1878
1918
  this.#lifeRewriteAt[date] = now;
1879
1919
  }
1880
1920
  try {
1881
- await this.#pushLifePlan(date, type, z.date, now, { rewrite: written });
1921
+ await this.#pushLifePlan(date, type, z.date, now, { rewrite: written, noWork });
1882
1922
  } catch (err) {
1883
1923
  if (placeholder) {
1884
1924
  this.#lifeTomorrow = null;
@@ -2009,7 +2049,16 @@ export class FeastWorld {
2009
2049
  }
2010
2050
  let day;
2011
2051
  try {
2012
- day = normalizePlan(raw, date, { maxItems: this.#lifeMaxItems(), rand: this.#random });
2052
+ const noWork = await this.#workBlocked(date, now);
2053
+ const requestedType = raw?.dayType?.id ?? raw?.dayType ?? raw?.dayTypeId;
2054
+ const requestsWork = DEFAULT_DAY_TYPES.some((type) => isWorkDayType(type)
2055
+ && (type.id === requestedType || type.name === requestedType));
2056
+ if (noWork && (raw?.work === true || requestsWork
2057
+ || (Array.isArray(raw?.items) && raw.items.some((item) => this.#isScheduledWork(item))))) {
2058
+ return this.#workBlockedResult();
2059
+ }
2060
+ day = normalizePlan(noWork ? { ...raw, work: false } : raw, date,
2061
+ { maxItems: this.#lifeMaxItems(), rand: this.#random });
2013
2062
  } catch (err) {
2014
2063
  return { text: `[记日程失败] ${msg(err)}`, failed: true };
2015
2064
  }
@@ -2097,6 +2146,9 @@ export class FeastWorld {
2097
2146
  ? day.items.find((item) => item.start === args.start && item.end === args.end
2098
2147
  && item.activity === String(args.activity).trim()) : null;
2099
2148
  const change = categoryOnly ? { ...categoryOnly, ...args } : args;
2149
+ if (!cancel && this.#isScheduledWork(change) && await this.#workBlocked(date, now)) {
2150
+ return this.#workBlockedResult();
2151
+ }
2100
2152
  let items;
2101
2153
  try {
2102
2154
  items = applyChange(day.items, change);
@@ -2388,6 +2440,7 @@ export class FeastWorld {
2388
2440
  if (!date) return { text: 'date 要用 today / tomorrow 或 YYYY-MM-DD。', failed: true };
2389
2441
 
2390
2442
  const wantWork = typeof args?.work === 'boolean' ? args.work : null;
2443
+ if (wantWork === true && await this.#workBlocked(date, now)) return this.#workBlockedResult();
2391
2444
  const rawSlots = args?.mealSlots;
2392
2445
  const touched = wantWork !== null || rawSlots !== undefined;
2393
2446
  if (!touched) {
@@ -2493,7 +2546,7 @@ export class FeastWorld {
2493
2546
  { label: t.badgeNext, value: nextMealText(state, this.cfg, now, this.timezone, this.#ownMealSlots()), tone: 'plain' },
2494
2547
  ],
2495
2548
  panels: [
2496
- { id: 'today', title: p.today.title, description: p.today.description, getMethods: ['list', 'day', 'work'] },
2549
+ { id: 'today', title: p.today.title, description: p.today.description, getMethods: ['list', 'day', 'work', 'workPolicy'] },
2497
2550
  { id: 'menu', title: p.menu.title, description: p.menu.description, getMethods: ['list', 'dish', 'random', 'pending', 'together'] },
2498
2551
  { id: 'combo', title: p.combo.title, description: p.combo.description, getMethods: ['list'] },
2499
2552
  { id: 'history', title: p.history.title, description: p.history.description, getMethods: ['list'] },
@@ -2587,6 +2640,7 @@ export class FeastWorld {
2587
2640
  return [
2588
2641
  { key: 'state', label: '吃过的记录', file: this.stateFile() },
2589
2642
  { key: 'combos', label: '保存的套餐', file: this.combosFile() },
2643
+ { key: 'workPolicy', label: '工作排程设置', file: this.#workPolicyFile() },
2590
2644
  { key: 'today', label: '今天的安排', file: join(this.lifeDirectory(), `${date}.json`) },
2591
2645
  { key: 'tomorrow', label: '明天的安排', file: join(this.lifeDirectory(), `${addDays(date, 1)}.json`) },
2592
2646
  { key: 'play', label: '今天留下的事', file: join(this.lifeDirectory(), `play-${date}.json`) },
@@ -2611,6 +2665,8 @@ export class FeastWorld {
2611
2665
  this.#play = loaded ?? newPlay(zonedNow(this.timezone, this.#now()).date);
2612
2666
  if (opts.action === 'restore') this.#freePendingSave = null;
2613
2667
  else await this.#flushFreeReminder();
2668
+ } else if (target.key === 'workPolicy') {
2669
+ await this.#workSchedulingEnabled();
2614
2670
  } else if (target.key === 'threads') {
2615
2671
  await readThreads(this.dataDir);
2616
2672
  } else {
@@ -2653,6 +2709,7 @@ export class FeastWorld {
2653
2709
  return fallback;
2654
2710
  }
2655
2711
  };
2712
+ const workSchedulingEnabled = await safeRead('workPolicy', () => this.#workSchedulingEnabled(), false);
2656
2713
  const today = await safeRead('today', () => readDay(this.dataDir, z.date), null);
2657
2714
  const tomorrow = await safeRead('tomorrow', () => readDay(this.dataDir, addDays(z.date, 1)), null);
2658
2715
  const play = await safeRead('play', async () => {
@@ -2706,6 +2763,8 @@ export class FeastWorld {
2706
2763
  && now - (this.#lifeRewriteAt[tomorrow.date] ?? 0) >= REWRITE_COOLDOWN_MS,
2707
2764
  mealSlots: this.cfg?.mealReminder === false ? [] : effectiveMealSlots(this.cfg, ownMeal),
2708
2765
  mealSlotsByHer: ownMeal !== null,
2766
+ workSchedulingEnabled,
2767
+ workSchedulingError: issues.some((issue) => issue.key === 'workPolicy'),
2709
2768
  work: today?.work === true,
2710
2769
  workConflicts: today?.work === false ? today.items.filter(isWorkEvent) : [],
2711
2770
  workUndoAvailable: Boolean(today?.workUndo && today.workUndo.expected === workScheduleKey(today)),
@@ -2966,6 +3025,19 @@ export class FeastWorld {
2966
3025
  const out = await this.#lifeAdjustTool(opts ?? {}, { fromOwner: true });
2967
3026
  return { ok: !out.failed, message: out.text };
2968
3027
  }
3028
+ case 'workPolicy': {
3029
+ const enabled = args[0]?.enabled;
3030
+ if (typeof enabled !== 'boolean') return { ok: false, message: '请指定是否启用工作排程。' };
3031
+ try {
3032
+ // 规则与每日记录分开保存:跨天、重启和清空日程都不会重置。
3033
+ await this.#workSchedulingEnabled();
3034
+ await mkdir(dirname(this.#workPolicyFile()), { recursive: true });
3035
+ await writeStoredJson(this.#workPolicyFile(), { enabled });
3036
+ return { ok: true, message: enabled
3037
+ ? '已恢复工作类日型的原有权重,之后按原规则安排。'
3038
+ : '已关闭工作排程:之后上班日、加班日、摸鱼日的权重为 0,直到重新开启。已有日程保留。' };
3039
+ } catch (err) { return { ok: false, message: msg(err) }; }
3040
+ }
2969
3041
  case 'work': {
2970
3042
  // 面板上翻「今天上不上班」。走的是和她同一个窄口子(feast_life_day 那条路),
2971
3043
  // 所以规矩只有一份:日程没有就不凭空造一天、只动 work 和 mealSlots 两件事。
@@ -2977,6 +3049,10 @@ export class FeastWorld {
2977
3049
  const day = await readDay(this.dataDir, date);
2978
3050
  if (!day?.items?.length) return { ok: false, message: `${dateLabel(date)}还没有日程,可以先请她写,或等她写。` };
2979
3051
  if (raw.action === 'undo') {
3052
+ if (await this.#workBlocked(date, this.#now())
3053
+ && (day.workUndo?.work || day.workUndo?.items?.some((item) => this.#isScheduledWork(item)))) {
3054
+ return { ok: false, message: '工作排程已关闭,请先重新开启,再恢复工作安排。' };
3055
+ }
2980
3056
  if (!day.workUndo || day.workUndo.expected !== workScheduleKey(day)) {
2981
3057
  return { ok: false, message: '日程已有后续修改或没有可撤销的关闭操作,不能覆盖现在的安排。' };
2982
3058
  }