cortico-world-feast 0.10.0 → 0.10.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 +10 -0
- package/describe.json +5 -5
- package/dist/webui.js +86 -5
- package/package.json +79 -79
- package/src/definition.js +2 -2
- package/src/life/kind.js +30 -0
- package/src/life/schedule.js +15 -0
- package/src/life/store.js +9 -0
- package/src/world.js +44 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## 0.10.1
|
|
4
|
+
|
|
5
|
+
**上不上班开关更保守:关前预览、一次撤销、冲突保护与主动清理**
|
|
6
|
+
|
|
7
|
+
- 关闭工作时只把**明确的工作事件**改成自由安排;「公司附近吃饭」「下班后看电影」「工作室画画」等只是发生在工作相关时间或地点的生活安排,不再被误清。
|
|
8
|
+
- 面板关闭工作前先给出受影响的时段预览,由主人确认后才执行;并发改动会让确认失效,避免按旧画面覆盖新内容。
|
|
9
|
+
- 关闭时保存一次撤销快照;关闭后若工作字段或时段又被改动,拒绝撤销以免覆盖后续编辑,只改饭点仍可撤销并保留改后的饭点。
|
|
10
|
+
- 旧 `work:false` 日程中残留的工作冲突只提示、不在读取或规范化时静默改盘;面板提供主动清理入口。
|
|
11
|
+
- `feast_life_day` 的 `work:false` 与面板 `today.work` 共用同一套规则,日程仍不凭空生成;饭点来源与低打扰默认值不变。
|
|
12
|
+
|
|
3
13
|
## 0.10.0
|
|
4
14
|
|
|
5
15
|
**今天上不上班的开关、饭点档位让她自己定;生活首页、记录恢复、跨天小事与低打扰默认值**
|
package/describe.json
CHANGED
|
@@ -313,7 +313,7 @@
|
|
|
313
313
|
},
|
|
314
314
|
"work": {
|
|
315
315
|
"type": "boolean",
|
|
316
|
-
"description": "这天要不要上班;可选。写 false
|
|
316
|
+
"description": "这天要不要上班;可选。写 false 会把日程里的工作事件改成自由安排。"
|
|
317
317
|
},
|
|
318
318
|
"mealSlots": {
|
|
319
319
|
"type": "array",
|
|
@@ -558,7 +558,7 @@
|
|
|
558
558
|
},
|
|
559
559
|
{
|
|
560
560
|
"name": "feast_life_day",
|
|
561
|
-
"description": "
|
|
561
|
+
"description": "定今天怎么过:上不上班、几点吃饭。不上班会移除日程中的工作事件并替换成自由安排,其余安排保留;不写日期就是今天。",
|
|
562
562
|
"parameters": {
|
|
563
563
|
"type": "object",
|
|
564
564
|
"properties": {
|
|
@@ -568,7 +568,7 @@
|
|
|
568
568
|
},
|
|
569
569
|
"work": {
|
|
570
570
|
"type": "boolean",
|
|
571
|
-
"description": "今天上不上班。写 false
|
|
571
|
+
"description": "今天上不上班。写 false 会把日程里的工作事件改成自由安排,保留其他安排。"
|
|
572
572
|
},
|
|
573
573
|
"mealSlots": {
|
|
574
574
|
"type": "array",
|
|
@@ -585,8 +585,8 @@
|
|
|
585
585
|
"write"
|
|
586
586
|
],
|
|
587
587
|
"summary": {
|
|
588
|
-
"zh": "
|
|
589
|
-
"en": "Settle
|
|
588
|
+
"zh": "定今天上不上班、几点吃饭;不上班会把工作事件改成自由安排,其余日程保留。",
|
|
589
|
+
"en": "Settle whether she works and when she eats. Turning work off replaces work events with free time and keeps the rest of the schedule."
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
592
|
],
|
package/dist/webui.js
CHANGED
|
@@ -138,6 +138,35 @@ const CSS = `
|
|
|
138
138
|
.feast-meal{font-size:10.5px;padding:1px 6px;border-radius:999px;border:1px dashed var(--fe-line);color:var(--fe-dim);flex:none;white-space:nowrap;font-variant-numeric:tabular-nums}
|
|
139
139
|
.feast-meal.is-done{border-style:solid;border-color:var(--fe-accent);color:var(--fe-accent)}
|
|
140
140
|
.feast-invite-note{flex:1;min-width:150px}
|
|
141
|
+
/* --- 今天:首页状态与分类时间轴 --- */
|
|
142
|
+
.feast-today-home{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,250px),1fr));gap:10px;margin-bottom:12px}
|
|
143
|
+
.feast-today-home .feast-stat{min-width:0}
|
|
144
|
+
.feast-today-status{grid-column:1/-1;display:flex;flex-direction:column;gap:5px;border-top:2px solid color-mix(in srgb,var(--fe-accent) 45%,var(--fe-line))}
|
|
145
|
+
.feast-today-status-h{display:flex;gap:8px;align-items:baseline;flex-wrap:wrap}
|
|
146
|
+
.feast-today-title{font-family:var(--fe-serif);font-size:16px;font-weight:600;color:var(--fe-title)}
|
|
147
|
+
.feast-today-mood{color:var(--fe-dim)}
|
|
148
|
+
.feast-status-line{display:flex;gap:7px;align-items:baseline;flex-wrap:wrap;font-size:12px;color:var(--fe-dim)}
|
|
149
|
+
.feast-work-pill{border:1px solid var(--fe-line);border-radius:999px;padding:1px 7px;color:var(--fe-dim);font-size:11px}
|
|
150
|
+
.feast-work-pill.is-on{border-color:var(--fe-accent);color:var(--fe-accent)}
|
|
151
|
+
.feast-actual-stream{display:flex;flex-direction:column;gap:0}
|
|
152
|
+
.feast-actual-row{display:flex;gap:8px;align-items:baseline;padding:5px 0;border-bottom:1px solid var(--fe-line)}
|
|
153
|
+
.feast-actual-row:last-child{border-bottom:0}
|
|
154
|
+
.feast-category{font-size:10.5px;line-height:1.5;padding:1px 6px;border:1px solid var(--fe-line);border-radius:999px;color:var(--fe-dim);white-space:nowrap;flex:none}
|
|
155
|
+
.feast-tl-row[data-category="sleep"]{border-left-color:#7183a8}
|
|
156
|
+
.feast-tl-row[data-category="work"]{border-left-color:#9a7447}
|
|
157
|
+
.feast-tl-row[data-category="commute"]{border-left-color:#6d9b92}
|
|
158
|
+
.feast-tl-row[data-category="meal"]{border-left-color:#bc8057}
|
|
159
|
+
.feast-tl-row[data-category="personal"]{border-left-color:#8c77a8}
|
|
160
|
+
.feast-tl-row.is-now[data-category]{background:color-mix(in srgb,var(--fe-accent) 10%,transparent)}
|
|
161
|
+
.feast-work-preview{border:1px solid var(--fe-accent);border-radius:var(--radius-md,10px);padding:9px 11px;margin-top:9px;background:color-mix(in srgb,var(--fe-accent) 5%,var(--fe-card))}
|
|
162
|
+
.feast-work-compare{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,190px),1fr));gap:8px}
|
|
163
|
+
.feast-work-side{border:1px solid var(--fe-line);border-radius:var(--radius-sm,6px);padding:7px 9px;min-width:0}
|
|
164
|
+
.feast-work-side ul{margin:5px 0 0;padding-left:19px;color:var(--fe-dim)}
|
|
165
|
+
.feast-work-actions{display:flex;gap:7px;flex-wrap:wrap;margin-top:8px}
|
|
166
|
+
.feast-tomorrow-state{margin:6px 0 10px;padding:7px 10px;border-left:2px solid var(--fe-line);background:color-mix(in srgb,var(--fe-ink) 3%,transparent);color:var(--fe-dim)}
|
|
167
|
+
.feast-free-plan{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:10px 0;padding:9px 11px;border:1px solid var(--fe-line);border-radius:var(--radius-md,10px);background:var(--fe-card)}
|
|
168
|
+
.feast-free-plan .feast-note{margin:0;flex:1;min-width:180px}
|
|
169
|
+
@media(max-width:480px){.feast-tl-row{gap:6px;padding:7px 5px}.feast-tl-t{width:5.5em;font-size:11px}.feast-tl-d{font-size:11px}.feast-today-title{font-size:15px}.feast-actual-row{gap:5px}}
|
|
141
170
|
`;
|
|
142
171
|
|
|
143
172
|
const TABLE = {
|
|
@@ -273,6 +302,18 @@ const TABLE = {
|
|
|
273
302
|
todayPlanTitle: '此刻的安排', todayActualTitle: '今天留下的事', todayNextTitle: '接下来',
|
|
274
303
|
todayPlanDisclaimer: '这是计划,不代表事情已经发生。', todayActualEmpty: '还没有记下事情。',
|
|
275
304
|
todayUpcoming: '接下来', todayPendingMeal: '有一份餐点还在等她', todayTogetherInvite: '她邀请你一起吃饭', todayTogetherActive: '你们正在一起吃饭',
|
|
305
|
+
todayDate: '日期', todayMood: (m) => `心情:${m}`, todayWorking: '今天上班', todayNotWorking: '今天休息', todayWorkUnknown: '还没有安排',
|
|
306
|
+
todayCategory: { sleep: '睡眠', work: '工作', commute: '通勤', meal: '用餐', personal: '个人' },
|
|
307
|
+
todayTomorrowEmpty: '明天还没有计划。', todayTomorrowPending: '已经请求她写明天,仍在等待回应。',
|
|
308
|
+
todayTomorrowPendingAt: (s) => `请求发出于 ${s}`, todayTomorrowCoo: '明天的计划由她写下。', todayTomorrowTemplate: '明天暂由日程模板安排。',
|
|
309
|
+
todayFreePlan: '请她想想空出来的时间', todayFreePending: '已经请她看看空出来的时间。', todayFreeNone: '今天没有明确留出的时间段。',
|
|
310
|
+
workCompareTitle: '确认今天不上班', workBefore: '当前安排', workAfter: '不上班后', workNoChanges: '没有识别到工作或通勤时段;只会更新上班状态。',
|
|
311
|
+
workCancel: '取消', workConfirm: '确认修改', workConflictNote: (n) => `仍有 ${n} 段工作安排未清理。`, workUndo: '撤销关闭上班', workUndoing: '正在撤销…',
|
|
312
|
+
todayPlanSendAt: (s) => `请求时间:${s}`, todayTimelineLabel: '分类时间轴',
|
|
313
|
+
workCategory: '工作', sleepCategory: '睡眠', commuteCategory: '通勤', mealCategory: '用餐', personalCategory: '个人',
|
|
314
|
+
workActivity: '上班', sleepActivity: '睡觉', commuteActivity: '通勤', mealActivity: '吃饭', personalActivity: '自己的时间',
|
|
315
|
+
workPreviewStale: '预览已过期,请重新预览后确认。',
|
|
316
|
+
todayActualMeal: '餐食', todayActualActivity: '活动',
|
|
276
317
|
todayStorage: '存储问题', todayReload: '重新读取', todayRestore: '从备份恢复', todayRestoreConfirm: (n) => `确认从备份恢复「${n}」?当前内容会被替换。`,
|
|
277
318
|
todayThreadTitle: '她留下的线索', todayThreadPh: '记下一个想法…', todayThreadAdd: '记下想法', todayThreadOwner: '主人记下', todayThreadCoo: '她留下', todayThreadDone: '完成', todayThreadDrop: '搁下', todayThreadDoneLabel: '已完成', todayThreadDropLabel: '已搁下',
|
|
278
319
|
todayPlanRetry: '重新发送', todayPlanRetryConfirm: '明天的计划还在等待中。要重新发送请求吗?',
|
|
@@ -280,7 +321,7 @@ const TABLE = {
|
|
|
280
321
|
workTitle: '今天上不上班',
|
|
281
322
|
workOn: '上班',
|
|
282
323
|
workOff: '不上班',
|
|
283
|
-
workHint: '
|
|
324
|
+
workHint: '说一声就改:不上班时会移除日程里的工作事件,其他安排保留。',
|
|
284
325
|
workNone: '这一天还没有日程,先请她写或等她自己写。',
|
|
285
326
|
mealByHer: '饭点由她定',
|
|
286
327
|
mealByConfig: '饭点走配置',
|
|
@@ -434,6 +475,18 @@ const TABLE = {
|
|
|
434
475
|
todayPlanTitle: 'Planned for now', todayActualTitle: 'What happened today', todayNextTitle: 'Up next',
|
|
435
476
|
todayPlanDisclaimer: 'This is a plan, not a record of what happened.', todayActualEmpty: 'Nothing has been noted yet.',
|
|
436
477
|
todayUpcoming: 'Coming up', todayPendingMeal: 'A meal is still waiting for her', todayTogetherInvite: 'She invited you to eat together', todayTogetherActive: 'You are eating together',
|
|
478
|
+
todayDate: 'Date', todayMood: (m) => `Mood: ${m}`, todayWorking: 'Working today', todayNotWorking: 'Off today', todayWorkUnknown: 'Not scheduled yet',
|
|
479
|
+
todayCategory: { sleep: 'Sleep', work: 'Work', commute: 'Commute', meal: 'Meal', personal: 'Personal' },
|
|
480
|
+
todayTomorrowEmpty: 'Tomorrow has no plan yet.', todayTomorrowPending: 'She has been asked to write tomorrow; waiting for her reply.',
|
|
481
|
+
todayTomorrowPendingAt: (s) => `Request sent at ${s}`, todayTomorrowCoo: 'Tomorrow’s plan was written by her.', todayTomorrowTemplate: 'Tomorrow is temporarily using the day template.',
|
|
482
|
+
todayFreePlan: 'Ask her to think about the open time', todayFreePending: 'She has been asked to look at the open time.', todayFreeNone: 'There are no clearly open stretches today.',
|
|
483
|
+
workCompareTitle: 'Confirm off work today', workBefore: 'Current schedule', workAfter: 'After switching off work', workNoChanges: 'No work or commute blocks were identified; only the work status will change.',
|
|
484
|
+
workCancel: 'Cancel', workConfirm: 'Confirm change', workConflictNote: (n) => `${n} work blocks remain in the schedule.`, workUndo: 'Undo off-work change', workUndoing: 'Undoing…',
|
|
485
|
+
todayPlanSendAt: (s) => `Request time: ${s}`, todayTimelineLabel: 'Category timeline',
|
|
486
|
+
workCategory: 'Work', sleepCategory: 'Sleep', commuteCategory: 'Commute', mealCategory: 'Meal', personalCategory: 'Personal',
|
|
487
|
+
workActivity: 'Work', sleepActivity: 'Sleep', commuteActivity: 'Commute', mealActivity: 'Meal', personalActivity: 'Own time',
|
|
488
|
+
workPreviewStale: 'This preview is out of date. Preview again before confirming.',
|
|
489
|
+
todayActualMeal: 'Meal', todayActualActivity: 'Activity',
|
|
437
490
|
todayStorage: 'Storage issues', todayReload: 'Reload', todayRestore: 'Restore from backup', todayRestoreConfirm: (n) => `Restore “${n}” from backup? This replaces the current contents.`,
|
|
438
491
|
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',
|
|
439
492
|
todayPlanRetry: 'Resend request', todayPlanRetryConfirm: 'Tomorrow’s plan is still pending. Resend the request?',
|
|
@@ -1351,12 +1404,24 @@ const todayPanel = {
|
|
|
1351
1404
|
for (const [on, label] of [[true, t.workOn], [false, t.workOff]]) {
|
|
1352
1405
|
const active = (data.work === true) === on;
|
|
1353
1406
|
const btn = el('button', active ? 'feast-btn-primary' : null, label);
|
|
1354
|
-
btn.disabled = operating || active;
|
|
1407
|
+
btn.disabled = operating || (active && (on || !data.workConflicts?.length));
|
|
1355
1408
|
btn.onclick = async () => {
|
|
1356
1409
|
btn.disabled = true;
|
|
1357
1410
|
try {
|
|
1358
|
-
|
|
1359
|
-
if (
|
|
1411
|
+
let revision;
|
|
1412
|
+
if (!on) {
|
|
1413
|
+
const preview = await ctx.invoke('work', [{ date: data.date, work: false, action: 'preview' }]);
|
|
1414
|
+
if (preview?.ok === false) throw new Error(preview.message);
|
|
1415
|
+
const affected = preview.affected ?? [];
|
|
1416
|
+
const lines = affected.map((it) => `${it.start}–${it.end} ${it.activity}`);
|
|
1417
|
+
const message = lines.length
|
|
1418
|
+
? `以下时段将改为居家自由安排:\n${lines.join('\n')}\n\n确认关闭上班?`
|
|
1419
|
+
: '没有识别到明确的工作事件,只修改上班状态。确认关闭上班?';
|
|
1420
|
+
if (!window.confirm(message)) { btn.disabled = false; return; }
|
|
1421
|
+
revision = preview.revision;
|
|
1422
|
+
}
|
|
1423
|
+
const r = await ctx.invoke('work', [{ date: data.date, work: on, ...(revision ? { revision } : {}) }]);
|
|
1424
|
+
if (r?.ok === false) { toast(root, ctx, r.message ?? t.sayNo, true); btn.disabled = false; }
|
|
1360
1425
|
else { toast(root, ctx, r.message ?? t.sayOk); await refresh(); }
|
|
1361
1426
|
} catch (err) {
|
|
1362
1427
|
toast(root, ctx, t.failed(err?.message ?? err), true);
|
|
@@ -1367,6 +1432,22 @@ const todayPanel = {
|
|
|
1367
1432
|
}
|
|
1368
1433
|
box.appendChild(row);
|
|
1369
1434
|
box.appendChild(el('div', 'feast-note', t.workHint));
|
|
1435
|
+
if (data.workConflicts?.length) {
|
|
1436
|
+
box.appendChild(el('div', 'feast-note', `不上班的日程仍有 ${data.workConflicts.length} 段工作安排。内容已保留,点击“不上班”可预览并清理。`));
|
|
1437
|
+
}
|
|
1438
|
+
if (data.workUndoAvailable) {
|
|
1439
|
+
const undo = el('button', 'feast-btn', '撤销关闭上班');
|
|
1440
|
+
undo.disabled = operating;
|
|
1441
|
+
undo.onclick = async () => {
|
|
1442
|
+
undo.disabled = true;
|
|
1443
|
+
try {
|
|
1444
|
+
const r = await ctx.invoke('work', [{ date: data.date, action: 'undo' }]);
|
|
1445
|
+
toast(root, ctx, r?.message ?? t.sayOk, r?.ok === false);
|
|
1446
|
+
await refresh();
|
|
1447
|
+
} catch (err) { toast(root, ctx, t.failed(err?.message ?? err), true); undo.disabled = false; }
|
|
1448
|
+
};
|
|
1449
|
+
box.appendChild(undo);
|
|
1450
|
+
}
|
|
1370
1451
|
}
|
|
1371
1452
|
|
|
1372
1453
|
// 饭点:她定了就说她定的,没定就说配置那组。不重画时间线——那一块已经标过饭点了。
|
|
@@ -1847,7 +1928,7 @@ const todayPanel = {
|
|
|
1847
1928
|
|
|
1848
1929
|
// 钟自己走:整点过后换一段了,「此刻」那个条该跟上(每 60 秒让服务端重算一遍)。
|
|
1849
1930
|
// 只在「此刻那一段」或「日期」真的变了才重画 —— 否则会把正在填的改主意表单打断。
|
|
1850
|
-
const refreshKey = (v) => JSON.stringify({ date: v?.date, start: v?.nowItem?.start, actual: v?.actual, threads: v?.threads, storage: v?.storageIssues, tomorrow: v?.tomorrow, pending: v?.pending, together: v?.together, upcoming: v?.upcoming, retry: v?.planRetryAvailable, work: v?.work, meals: v?.mealSlots, mealsByHer: v?.mealSlotsByHer });
|
|
1931
|
+
const refreshKey = (v) => JSON.stringify({ date: v?.date, start: v?.nowItem?.start, actual: v?.actual, threads: v?.threads, storage: v?.storageIssues, tomorrow: v?.tomorrow, pending: v?.pending, together: v?.together, upcoming: v?.upcoming, retry: v?.planRetryAvailable, work: v?.work, conflicts: v?.workConflicts, undo: v?.workUndoAvailable, meals: v?.mealSlots, mealsByHer: v?.mealSlotsByHer });
|
|
1851
1932
|
let lastKey = refreshKey(data);
|
|
1852
1933
|
const ticker = ctx.interval?.(() => {
|
|
1853
1934
|
if (ctx.signal?.aborted) return;
|
package/package.json
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cortico-world-feast",
|
|
3
|
-
"version": "0.10.
|
|
4
|
-
"description": "鱼的每一天 · 先给她一天,再给她一桌饭:她自己的日程(每晚自己写明天,可以按日型给她备一张「能做的事」清单,到点过自己的时间、做完记一笔)+ 824 道菜的桌子,能端一道、端一桌,也能和她一起吃一顿。可以跟「生图工作室」「娱乐时间」「鱼的小世界」各接一小截,不装也完整可用。",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "青",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/bailuhanyi/cortico-world-feast.git"
|
|
10
|
-
},
|
|
11
|
-
"homepage": "https://github.com/bailuhanyi/cortico-world-feast#readme",
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/bailuhanyi/cortico-world-feast/issues"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"cortico-world",
|
|
17
|
-
"cortico",
|
|
18
|
-
"coopanion",
|
|
19
|
-
"coo",
|
|
20
|
-
"food",
|
|
21
|
-
"eat",
|
|
22
|
-
"taste",
|
|
23
|
-
"flavor",
|
|
24
|
-
"dish",
|
|
25
|
-
"meal",
|
|
26
|
-
"hunger",
|
|
27
|
-
"companion"
|
|
28
|
-
],
|
|
29
|
-
"type": "module",
|
|
30
|
-
"main": "./src/index.js",
|
|
31
|
-
"exports": {
|
|
32
|
-
".": "./src/index.js"
|
|
33
|
-
},
|
|
34
|
-
"files": [
|
|
35
|
-
"src",
|
|
36
|
-
"dist",
|
|
37
|
-
"assets",
|
|
38
|
-
"describe.json",
|
|
39
|
-
"CHANGELOG.md",
|
|
40
|
-
"README.md",
|
|
41
|
-
"PUBLISHING.md",
|
|
42
|
-
"GUIDE.md"
|
|
43
|
-
],
|
|
44
|
-
"engines": {
|
|
45
|
-
"node": ">=22.6"
|
|
46
|
-
},
|
|
47
|
-
"scripts": {
|
|
48
|
-
"test": "node test/storage.test.mjs && node test/threads.test.mjs && node test/dishes.test.mjs && node test/eat.test.mjs && node test/state.test.mjs && node test/combos.test.mjs && node test/together.test.mjs && node test/life.test.mjs && node test/wardrobe.test.mjs && node test/life-world.test.mjs && node test/weather.test.mjs && node test/funlink.test.mjs && node test/maplink.test.mjs && node test/world.test.mjs && node test/panels.test.mjs",
|
|
49
|
-
"dishes": "node tools/validate-dishes.mjs",
|
|
50
|
-
"selfcheck": "node tools/selfcheck.mjs",
|
|
51
|
-
"check:install": "node tools/check-install.mjs",
|
|
52
|
-
"check:publish": "node tools/publish-check.mjs --online",
|
|
53
|
-
"describe": "node tools/make-describe.mjs",
|
|
54
|
-
"prepublishOnly": "node tools/validate-dishes.mjs && node tools/selfcheck.mjs && node tools/publish-check.mjs --online && node test/storage.test.mjs && node test/threads.test.mjs && node test/dishes.test.mjs && node test/eat.test.mjs && node test/state.test.mjs && node test/combos.test.mjs && node test/together.test.mjs && node test/life.test.mjs && node test/wardrobe.test.mjs && node test/life-world.test.mjs && node test/weather.test.mjs && node test/funlink.test.mjs && node test/maplink.test.mjs && node test/world.test.mjs && node test/panels.test.mjs && node tools/make-describe.mjs --check"
|
|
55
|
-
},
|
|
56
|
-
"cortico": {
|
|
57
|
-
"kind": "world",
|
|
58
|
-
"api": 6,
|
|
59
|
-
"displayName": "鱼的每一天",
|
|
60
|
-
"icon": "assets/icon.png",
|
|
61
|
-
"webUiClient": "dist/webui.js",
|
|
62
|
-
"describe": "describe.json",
|
|
63
|
-
"locales": {
|
|
64
|
-
"zh": {
|
|
65
|
-
"displayName": "鱼的每一天",
|
|
66
|
-
"description": "先给她一天,再给她一桌饭。每天晚上到点请她自己写明天怎么过(零 API Key,用已配的模型),第二天按它过;你还能按日型给她备一张「能做的事」清单,日程里就会写成真能做的一件事,而不是「在家玩」这种空白。上不上班可以一句话翻,几点吃也能由她自己按那天定;到点还有「她自己的时间」,让她挑件事做并记一笔——上班/通勤时段默认不叫,开了开关才照叫,但会换成报备的说法。主人能在「今天」面板看今天和明天的时间线、此刻她在做什么、她做过什么、往前翻往期,也能临时改掉某一段。桌上是 824 道菜(28 个菜系组),每道都有九维口味、香气、口感、余韵和一段实吃描写;她能自己按菜系挑,主人也能从面板端一道或整桌端过去(8 套内置套餐,也能自己勾几道攒成一桌存下来);还能和她一起吃一顿:邀请她、互相喂一口,你吃了什么她也知道。同一道菜每次吃到的都不一样,吃过什么、对什么反应、口味画像跨天攒着。饭点提醒、「她的一天」和自由时间都能在配置里单独关掉。\n\n能和这几个扩展联动,都是一个开关的事,不装就整段不出现、绝不报错:装了「生图工作室」,她写日程时会列出衣柜和场景,发图时穿着地点对得上;装了「娱乐时间」,「自己的时间」里会多一行,她能真出门逛;装了「鱼的小世界」,「自己的时间」里会多一行,她会想起周围那些地方。"
|
|
67
|
-
},
|
|
68
|
-
"en": {
|
|
69
|
-
"displayName": "Fish Every Day",
|
|
70
|
-
"description": "First a day of her own, then a table of food. Every evening she is asked to write tomorrow herself (no API key — it uses the model you already have), and the next day she lives it; you can also prepare a list of \"things she can actually do\" per day type, so the day she writes is made of real things instead of a blank \"hanging out at home\". On her own-time slots she picks something to do and logs it — while she is at work or commuting it stays quiet by default, and with one switch on it still speaks but as a check-in rather than \"this time is yours\". The Today panel shows today's and tomorrow's timeline, what she is doing right now, what she has been up to, past days, and lets you change a stretch of it. The table holds 824 dishes across 28 cuisines, each with a nine-axis flavour profile, aroma, texture, aftertaste and a full paragraph of how it actually eats. She can pick by cuisine, or you can put a dish down in front of her from the panel — or serve a whole table at once (8 built-in set meals, plus your own saved tables). You can also share a meal with her: invite her, feed each other a bite, and tell her what you are eating. The same dish never lands the same way twice, and what she ate, how it landed and her taste profile accumulate across days. Whether she works today can be flipped with one word, and she can set that day's meal times herself. Meal reminders, her day, and her own time can each be switched off in config.\n\nIt can also hook up to three other extensions, one switch each, and nothing breaks when they are absent: with the image studio installed she lists the wardrobe and scenes when writing her day, so the outfit and place match when she sends a picture; with Fun Time installed her own time gains one line and she can really go out; with Little World installed her own time gains another line and she remembers the places around her."
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
"tags": [
|
|
74
|
-
"companion",
|
|
75
|
-
"internal-state",
|
|
76
|
-
"experimental"
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "cortico-world-feast",
|
|
3
|
+
"version": "0.10.1",
|
|
4
|
+
"description": "鱼的每一天 · 先给她一天,再给她一桌饭:她自己的日程(每晚自己写明天,可以按日型给她备一张「能做的事」清单,到点过自己的时间、做完记一笔)+ 824 道菜的桌子,能端一道、端一桌,也能和她一起吃一顿。可以跟「生图工作室」「娱乐时间」「鱼的小世界」各接一小截,不装也完整可用。",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "青",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/bailuhanyi/cortico-world-feast.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/bailuhanyi/cortico-world-feast#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/bailuhanyi/cortico-world-feast/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"cortico-world",
|
|
17
|
+
"cortico",
|
|
18
|
+
"coopanion",
|
|
19
|
+
"coo",
|
|
20
|
+
"food",
|
|
21
|
+
"eat",
|
|
22
|
+
"taste",
|
|
23
|
+
"flavor",
|
|
24
|
+
"dish",
|
|
25
|
+
"meal",
|
|
26
|
+
"hunger",
|
|
27
|
+
"companion"
|
|
28
|
+
],
|
|
29
|
+
"type": "module",
|
|
30
|
+
"main": "./src/index.js",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": "./src/index.js"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"src",
|
|
36
|
+
"dist",
|
|
37
|
+
"assets",
|
|
38
|
+
"describe.json",
|
|
39
|
+
"CHANGELOG.md",
|
|
40
|
+
"README.md",
|
|
41
|
+
"PUBLISHING.md",
|
|
42
|
+
"GUIDE.md"
|
|
43
|
+
],
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=22.6"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"test": "node test/storage.test.mjs && node test/threads.test.mjs && node test/dishes.test.mjs && node test/eat.test.mjs && node test/state.test.mjs && node test/combos.test.mjs && node test/together.test.mjs && node test/life.test.mjs && node test/wardrobe.test.mjs && node test/life-world.test.mjs && node test/weather.test.mjs && node test/funlink.test.mjs && node test/maplink.test.mjs && node test/world.test.mjs && node test/panels.test.mjs",
|
|
49
|
+
"dishes": "node tools/validate-dishes.mjs",
|
|
50
|
+
"selfcheck": "node tools/selfcheck.mjs",
|
|
51
|
+
"check:install": "node tools/check-install.mjs",
|
|
52
|
+
"check:publish": "node tools/publish-check.mjs --online",
|
|
53
|
+
"describe": "node tools/make-describe.mjs",
|
|
54
|
+
"prepublishOnly": "node tools/validate-dishes.mjs && node tools/selfcheck.mjs && node tools/publish-check.mjs --online && node test/storage.test.mjs && node test/threads.test.mjs && node test/dishes.test.mjs && node test/eat.test.mjs && node test/state.test.mjs && node test/combos.test.mjs && node test/together.test.mjs && node test/life.test.mjs && node test/wardrobe.test.mjs && node test/life-world.test.mjs && node test/weather.test.mjs && node test/funlink.test.mjs && node test/maplink.test.mjs && node test/world.test.mjs && node test/panels.test.mjs && node tools/make-describe.mjs --check"
|
|
55
|
+
},
|
|
56
|
+
"cortico": {
|
|
57
|
+
"kind": "world",
|
|
58
|
+
"api": 6,
|
|
59
|
+
"displayName": "鱼的每一天",
|
|
60
|
+
"icon": "assets/icon.png",
|
|
61
|
+
"webUiClient": "dist/webui.js",
|
|
62
|
+
"describe": "describe.json",
|
|
63
|
+
"locales": {
|
|
64
|
+
"zh": {
|
|
65
|
+
"displayName": "鱼的每一天",
|
|
66
|
+
"description": "先给她一天,再给她一桌饭。每天晚上到点请她自己写明天怎么过(零 API Key,用已配的模型),第二天按它过;你还能按日型给她备一张「能做的事」清单,日程里就会写成真能做的一件事,而不是「在家玩」这种空白。上不上班可以一句话翻,几点吃也能由她自己按那天定;到点还有「她自己的时间」,让她挑件事做并记一笔——上班/通勤时段默认不叫,开了开关才照叫,但会换成报备的说法。主人能在「今天」面板看今天和明天的时间线、此刻她在做什么、她做过什么、往前翻往期,也能临时改掉某一段。桌上是 824 道菜(28 个菜系组),每道都有九维口味、香气、口感、余韵和一段实吃描写;她能自己按菜系挑,主人也能从面板端一道或整桌端过去(8 套内置套餐,也能自己勾几道攒成一桌存下来);还能和她一起吃一顿:邀请她、互相喂一口,你吃了什么她也知道。同一道菜每次吃到的都不一样,吃过什么、对什么反应、口味画像跨天攒着。饭点提醒、「她的一天」和自由时间都能在配置里单独关掉。\n\n能和这几个扩展联动,都是一个开关的事,不装就整段不出现、绝不报错:装了「生图工作室」,她写日程时会列出衣柜和场景,发图时穿着地点对得上;装了「娱乐时间」,「自己的时间」里会多一行,她能真出门逛;装了「鱼的小世界」,「自己的时间」里会多一行,她会想起周围那些地方。"
|
|
67
|
+
},
|
|
68
|
+
"en": {
|
|
69
|
+
"displayName": "Fish Every Day",
|
|
70
|
+
"description": "First a day of her own, then a table of food. Every evening she is asked to write tomorrow herself (no API key — it uses the model you already have), and the next day she lives it; you can also prepare a list of \"things she can actually do\" per day type, so the day she writes is made of real things instead of a blank \"hanging out at home\". On her own-time slots she picks something to do and logs it — while she is at work or commuting it stays quiet by default, and with one switch on it still speaks but as a check-in rather than \"this time is yours\". The Today panel shows today's and tomorrow's timeline, what she is doing right now, what she has been up to, past days, and lets you change a stretch of it. The table holds 824 dishes across 28 cuisines, each with a nine-axis flavour profile, aroma, texture, aftertaste and a full paragraph of how it actually eats. She can pick by cuisine, or you can put a dish down in front of her from the panel — or serve a whole table at once (8 built-in set meals, plus your own saved tables). You can also share a meal with her: invite her, feed each other a bite, and tell her what you are eating. The same dish never lands the same way twice, and what she ate, how it landed and her taste profile accumulate across days. Whether she works today can be flipped with one word, and she can set that day's meal times herself. Meal reminders, her day, and her own time can each be switched off in config.\n\nIt can also hook up to three other extensions, one switch each, and nothing breaks when they are absent: with the image studio installed she lists the wardrobe and scenes when writing her day, so the outfit and place match when she sends a picture; with Fun Time installed her own time gains one line and she can really go out; with Little World installed her own time gains another line and she remembers the places around her."
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"tags": [
|
|
74
|
+
"companion",
|
|
75
|
+
"internal-state",
|
|
76
|
+
"experimental"
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
package/src/definition.js
CHANGED
|
@@ -79,8 +79,8 @@ const TOOL_SUMMARIES = {
|
|
|
79
79
|
en: 'Start without waiting for a wake-up: hands her example ideas and how to log it.',
|
|
80
80
|
},
|
|
81
81
|
feast_life_day: {
|
|
82
|
-
zh: '
|
|
83
|
-
en: 'Settle
|
|
82
|
+
zh: '定今天上不上班、几点吃饭;不上班会把工作事件改成自由安排,其余日程保留。',
|
|
83
|
+
en: 'Settle whether she works and when she eats. Turning work off replaces work events with free time and keeps the rest of the schedule.',
|
|
84
84
|
},
|
|
85
85
|
};
|
|
86
86
|
|
package/src/life/kind.js
CHANGED
|
@@ -38,12 +38,42 @@ const activityOf = (item) => String((typeof item === 'string' ? item : item?.act
|
|
|
38
38
|
export function classifyItem(item) {
|
|
39
39
|
const act = activityOf(item);
|
|
40
40
|
if (!act) return 'none';
|
|
41
|
+
if (validCategory(item?.category)) {
|
|
42
|
+
if (item.category === 'sleep') return 'asleep';
|
|
43
|
+
if (item.category === 'work' || item.category === 'commute') return 'busy';
|
|
44
|
+
return 'free';
|
|
45
|
+
}
|
|
41
46
|
const hints = act.replace(NON_SLEEP, '').replace(PLACE_ONLY, '');
|
|
42
47
|
if (SLEEP_HINTS.test(hints)) return 'asleep';
|
|
43
48
|
if (BUSY_HINTS.test(hints)) return 'busy';
|
|
44
49
|
return 'free';
|
|
45
50
|
}
|
|
46
51
|
|
|
52
|
+
export const ACTIVITY_CATEGORIES = Object.freeze(['sleep', 'work', 'commute', 'meal', 'personal']);
|
|
53
|
+
export const validCategory = (value) => ACTIVITY_CATEGORIES.includes(value);
|
|
54
|
+
|
|
55
|
+
const WORK_EVENT_HINTS = /上班|通勤|下班回家|加班|办公|工作(?!室)|开会|值班|出差|赶工|搬砖/;
|
|
56
|
+
|
|
57
|
+
/** 显式分类优先;旧日程只识别明确工作动作,避免按地点名误删生活安排。 */
|
|
58
|
+
export function isWorkEvent(item) {
|
|
59
|
+
if (validCategory(item?.category)) return item.category === 'work' || item.category === 'commute';
|
|
60
|
+
const activity = activityOf(item)
|
|
61
|
+
.replace(/下班(?:后|以后|之后)/g, '')
|
|
62
|
+
.replace(/(?:不想|不用|不再|不去|无需|取消|不)(?:上班|加班|工作|开会|通勤)/g, '')
|
|
63
|
+
.replace(/工作室/g, '');
|
|
64
|
+
return WORK_EVENT_HINTS.test(activity)
|
|
65
|
+
|| /^(?:在)?(?:公司|办公室|工位)(?:里)?(?:待着|干活|摸鱼)?$/.test(activity);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** 展示分类与工作开关共用;推断结果不反写旧日程。 */
|
|
69
|
+
export function categoryOf(item) {
|
|
70
|
+
if (validCategory(item?.category)) return item.category;
|
|
71
|
+
if (classifyItem(item) === 'asleep') return 'sleep';
|
|
72
|
+
if (isWorkEvent(item)) return /通勤|下班回家/.test(activityOf(item)) ? 'commute' : 'work';
|
|
73
|
+
if (/吃(?:早|午|晚|夜|早午)?饭|用餐|早餐|午餐|晚餐/.test(activityOf(item))) return 'meal';
|
|
74
|
+
return 'personal';
|
|
75
|
+
}
|
|
76
|
+
|
|
47
77
|
/** 睡着了吗(「她自己的时间」和时段事件都用这个,别各写一份 /睡/)。 */
|
|
48
78
|
export const isAsleep = (item) => classifyItem(item) === 'asleep';
|
|
49
79
|
|
package/src/life/schedule.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* 库里有正名就归一,模型没填 outfit 时按习惯补。
|
|
12
12
|
*/
|
|
13
13
|
import { clock, parseClock, weekdayOf } from './time.js';
|
|
14
|
+
import { isWorkEvent, validCategory } from './kind.js';
|
|
15
|
+
export { categoryOf, isWorkEvent, validCategory } from './kind.js';
|
|
14
16
|
|
|
15
17
|
const text = (v, max) => String(v ?? '').replace(/\s+/g, ' ').trim().slice(0, max);
|
|
16
18
|
|
|
@@ -21,7 +23,9 @@ function cleanItem(raw) {
|
|
|
21
23
|
if (start === null || end === null) return null;
|
|
22
24
|
const activity = text(raw.activity, 40);
|
|
23
25
|
if (!activity) return null;
|
|
26
|
+
const category = validCategory(raw.category) ? raw.category : '';
|
|
24
27
|
const item = {
|
|
28
|
+
...(category ? { category } : {}),
|
|
25
29
|
s: start,
|
|
26
30
|
e: end === 0 && start > 0 ? 1440 : end,
|
|
27
31
|
activity,
|
|
@@ -47,6 +51,7 @@ function cleanItem(raw) {
|
|
|
47
51
|
if (props.length) item.props = props;
|
|
48
52
|
const withs = list(raw.with);
|
|
49
53
|
if (withs.length) item.with = withs;
|
|
54
|
+
if (raw.workFreed === true) item.workFreed = true;
|
|
50
55
|
return item;
|
|
51
56
|
}
|
|
52
57
|
|
|
@@ -120,6 +125,16 @@ export const DAY_SCOPES = ['weekday', 'weekend', 'any'];
|
|
|
120
125
|
/** 这几种日型都意味着「今天上班」。判据只此一处,别在别处再列一遍。 */
|
|
121
126
|
export const WORK_DAY_TYPES = Object.freeze(['workday', 'overtime', 'slacking']);
|
|
122
127
|
|
|
128
|
+
/** 撤销只比较工作状态、日型和时段;饭点变化不妨碍撤销。 */
|
|
129
|
+
export const workScheduleKey = (day) => JSON.stringify([day.work, day.dayType, day.items]);
|
|
130
|
+
|
|
131
|
+
/** 关闭上班后移除工作内容,以中性居家安排填回原时段。 */
|
|
132
|
+
export function removeWorkEvents(items) {
|
|
133
|
+
return (Array.isArray(items) ? items : []).map((item) => isWorkEvent(item)
|
|
134
|
+
? { start: item.start, end: item.end, activity: '自由安排', category: 'personal', workFreed: true, location: '家', detail: '' }
|
|
135
|
+
: item);
|
|
136
|
+
}
|
|
137
|
+
|
|
123
138
|
/** 这一天(按日型)是不是上班的日子。日型为空时按「不上班」算。 */
|
|
124
139
|
export function isWorkDayType(type) {
|
|
125
140
|
const id = typeof type === 'string' ? type : type?.id;
|
package/src/life/store.js
CHANGED
|
@@ -67,6 +67,15 @@ export function cleanDay(raw, date, opts = {}) {
|
|
|
67
67
|
mood: str(src.mood, 40),
|
|
68
68
|
items: source === 'pending' ? [] : normalizeItems(src.items, opts.maxItems ?? 40),
|
|
69
69
|
mealSlots: cleanMealSlots(src.mealSlots),
|
|
70
|
+
...(src.workUndo && typeof src.workUndo === 'object' && Array.isArray(src.workUndo.items)
|
|
71
|
+
&& typeof src.workUndo.expected === 'string' ? {
|
|
72
|
+
workUndo: {
|
|
73
|
+
work: src.workUndo.work === true,
|
|
74
|
+
dayType: { id: str(src.workUndo.dayType?.id, 40), name: str(src.workUndo.dayType?.name, 20) },
|
|
75
|
+
items: normalizeItems(src.workUndo.items, 40),
|
|
76
|
+
expected: src.workUndo.expected.slice(0, 100000),
|
|
77
|
+
},
|
|
78
|
+
} : {}),
|
|
70
79
|
source,
|
|
71
80
|
by: str(src.by, 20),
|
|
72
81
|
generatedAt: Number(src.generatedAt) || Date.now(),
|
package/src/world.js
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
LIFE_KEEP_DAYS, lifeDir, listDays, MAX_OWN_MEAL_SLOTS, mapMenuLine, markFreeNudged, markFreeSkipped,
|
|
32
32
|
momentLine, newPlay, nextFreeSlotText, normalizePlan, nowText, parseClock, parseDoings, parseSlots, pendingDay,
|
|
33
33
|
pickDayType, planEventText, planFreeTick, playDoneText, readDay, readFunEnabled, readMapEnabled, readPlay,
|
|
34
|
+
removeWorkEvents, isWorkEvent, workScheduleKey,
|
|
34
35
|
recentSummary, recordPlay, segmentKey, skipFreeToday, templateDay, withFunLine, withMapLine, writeDay, writePlay,
|
|
35
36
|
zonedNow,
|
|
36
37
|
} from './life/index.js';
|
|
@@ -225,7 +226,7 @@ export const FEAST_TOOL_DECLS = [
|
|
|
225
226
|
properties: {
|
|
226
227
|
date: { type: 'string', description: 'YYYY-MM-DD;留空 = 明天。' },
|
|
227
228
|
dayType: { type: 'string', description: '日型的 id 或名字,例如 restday / 休息日;留空按事件里给的那个。' },
|
|
228
|
-
work: { type: 'boolean', description: '这天要不要上班;可选。写 false
|
|
229
|
+
work: { type: 'boolean', description: '这天要不要上班;可选。写 false 会把日程里的工作事件改成自由安排。' },
|
|
229
230
|
mealSlots: {
|
|
230
231
|
type: 'array',
|
|
231
232
|
description: '这天想几点吃,HH:MM,1–4 档,例如 ["12:10","19:00"];可选,不写就用默认档位。',
|
|
@@ -330,12 +331,12 @@ export const FEAST_TOOL_DECLS = [
|
|
|
330
331
|
{
|
|
331
332
|
name: 'feast_life_day',
|
|
332
333
|
tags: ['write'],
|
|
333
|
-
description: '
|
|
334
|
+
description: '定今天怎么过:上不上班、几点吃饭。不上班会移除日程中的工作事件并替换成自由安排,其余安排保留;不写日期就是今天。',
|
|
334
335
|
parameters: {
|
|
335
336
|
type: 'object',
|
|
336
337
|
properties: {
|
|
337
338
|
date: { type: 'string', description: 'today / tomorrow / YYYY-MM-DD;留空 = 今天。' },
|
|
338
|
-
work: { type: 'boolean', description: '今天上不上班。写 false
|
|
339
|
+
work: { type: 'boolean', description: '今天上不上班。写 false 会把日程里的工作事件改成自由安排,保留其他安排。' },
|
|
339
340
|
mealSlots: {
|
|
340
341
|
type: 'array',
|
|
341
342
|
description: '今天几点吃,HH:MM,1–4 档,例如 ["12:10","19:00"]。只写今天想改的那几档;留空数组 = 不自己定,用默认档位。',
|
|
@@ -1977,7 +1978,11 @@ export class FeastWorld {
|
|
|
1977
1978
|
day = cleanDay({ ...day, mealSlots: slots }, date, { maxItems: this.#lifeMaxItems() });
|
|
1978
1979
|
}
|
|
1979
1980
|
if (typeof args?.work === 'boolean') {
|
|
1980
|
-
day = cleanDay({
|
|
1981
|
+
day = cleanDay({
|
|
1982
|
+
...day,
|
|
1983
|
+
work: args.work,
|
|
1984
|
+
items: args.work ? day.items : removeWorkEvents(day.items),
|
|
1985
|
+
}, date, { maxItems: this.#lifeMaxItems(), rand: this.#random });
|
|
1981
1986
|
}
|
|
1982
1987
|
day.by = 'coo';
|
|
1983
1988
|
await writeDay(this.dataDir, day);
|
|
@@ -2296,7 +2301,7 @@ export class FeastWorld {
|
|
|
2296
2301
|
*
|
|
2297
2302
|
* 为什么单独一个工具:这两件事原先都只能靠「改日程正文」或「改配置」。
|
|
2298
2303
|
* 前者是把一整天的 items 重写一遍(她只想说「今天不上班」,不该重写 13 段),
|
|
2299
|
-
*
|
|
2304
|
+
* 后者是主人的事,她伸不到。所以给一个只改上班状态(并清理工作事件)和饭点的窄口子。
|
|
2300
2305
|
*
|
|
2301
2306
|
* 两条都不写 = 什么都不改,如实说,不落盘。
|
|
2302
2307
|
* 日程还没有(还没写这一天)时也**不凭空造一天**:只回一句「等这天有了日程再来定」,
|
|
@@ -2333,7 +2338,8 @@ export class FeastWorld {
|
|
|
2333
2338
|
if (isWorkDayType(day.dayType) !== wantWork) {
|
|
2334
2339
|
next.dayType = pickDayType(DEFAULT_DAY_TYPES, date, '', this.#random, wantWork);
|
|
2335
2340
|
}
|
|
2336
|
-
|
|
2341
|
+
if (!wantWork) next.items = removeWorkEvents(day.items);
|
|
2342
|
+
said.push(wantWork ? '今天按上班过' : '今天不上班,已把工作事件改为自由安排');
|
|
2337
2343
|
}
|
|
2338
2344
|
|
|
2339
2345
|
if (rawSlots !== undefined) {
|
|
@@ -2356,6 +2362,12 @@ export class FeastWorld {
|
|
|
2356
2362
|
at: now, by: 'coo', note: said.join(','),
|
|
2357
2363
|
}],
|
|
2358
2364
|
}, date, { maxItems: this.#lifeMaxItems(), rand: this.#random });
|
|
2365
|
+
if (wantWork === false && workScheduleKey(written) !== workScheduleKey(day)) {
|
|
2366
|
+
written.workUndo = {
|
|
2367
|
+
work: day.work, dayType: day.dayType, items: day.items,
|
|
2368
|
+
expected: workScheduleKey(written),
|
|
2369
|
+
};
|
|
2370
|
+
}
|
|
2359
2371
|
await writeDay(this.dataDir, written);
|
|
2360
2372
|
this.#cacheLifeDay(written, now);
|
|
2361
2373
|
|
|
@@ -2365,7 +2377,9 @@ export class FeastWorld {
|
|
|
2365
2377
|
? '(饭点现在归主人那边定,你写的还没生效;想自己定可以请主人打开「饭点由她自己定」。)'
|
|
2366
2378
|
: '到点会按这个叫你;想改随时再说一句。');
|
|
2367
2379
|
}
|
|
2368
|
-
lines.push(
|
|
2380
|
+
lines.push(wantWork === false
|
|
2381
|
+
? '明确的通勤、上班、加班等工作事件已改成自由安排,其余日程保留。'
|
|
2382
|
+
: '日程正文没动,只是定下这两件事。');
|
|
2369
2383
|
return { text: lines.join('\n') };
|
|
2370
2384
|
}
|
|
2371
2385
|
|
|
@@ -2610,6 +2624,8 @@ export class FeastWorld {
|
|
|
2610
2624
|
mealSlots: this.cfg?.mealReminder === false ? [] : effectiveMealSlots(this.cfg, ownMeal),
|
|
2611
2625
|
mealSlotsByHer: ownMeal !== null,
|
|
2612
2626
|
work: today?.work === true,
|
|
2627
|
+
workConflicts: today?.work === false ? today.items.filter(isWorkEvent) : [],
|
|
2628
|
+
workUndoAvailable: Boolean(today?.workUndo && today.workUndo.expected === workScheduleKey(today)),
|
|
2613
2629
|
tomorrowWritten: Boolean(tomorrow?.items?.length),
|
|
2614
2630
|
eatenToday: eaten.map((e) => ({ at: e.at, name: e.name || e.id, by: e.by, bite: e.bite === true })),
|
|
2615
2631
|
free: {
|
|
@@ -2873,9 +2889,29 @@ export class FeastWorld {
|
|
|
2873
2889
|
const raw = opts && typeof opts === 'object' ? opts : {};
|
|
2874
2890
|
const date = this.#lifeDate(raw.date ?? 'today', this.#now());
|
|
2875
2891
|
if (!date) return { ok: false, message: '日期用 today / tomorrow 或 YYYY-MM-DD。' };
|
|
2876
|
-
if (
|
|
2892
|
+
if (!this.#lifeOn()) return { ok: false, message: '「她的一天」现在关着。' };
|
|
2877
2893
|
const day = await readDay(this.dataDir, date);
|
|
2878
2894
|
if (!day?.items?.length) return { ok: false, message: `${dateLabel(date)}还没有日程,可以先请她写,或等她写。` };
|
|
2895
|
+
if (raw.action === 'undo') {
|
|
2896
|
+
if (!day.workUndo || day.workUndo.expected !== workScheduleKey(day)) {
|
|
2897
|
+
return { ok: false, message: '日程已有后续修改或没有可撤销的关闭操作,不能覆盖现在的安排。' };
|
|
2898
|
+
}
|
|
2899
|
+
const restored = cleanDay({
|
|
2900
|
+
...day, work: day.workUndo.work, dayType: day.workUndo.dayType,
|
|
2901
|
+
items: day.workUndo.items, workUndo: null,
|
|
2902
|
+
changes: [...day.changes, { at: this.#now(), by: 'owner', note: '撤销关闭上班' }],
|
|
2903
|
+
}, date);
|
|
2904
|
+
await writeDay(this.dataDir, restored);
|
|
2905
|
+
this.#cacheLifeDay(restored, this.#now());
|
|
2906
|
+
return { ok: true, message: '已撤销关闭上班,饭点及其他记录保留。' };
|
|
2907
|
+
}
|
|
2908
|
+
if (typeof raw.work !== 'boolean') return { ok: false, message: '要说清今天上不上班。' };
|
|
2909
|
+
if (raw.action === 'preview') {
|
|
2910
|
+
return { ok: true, affected: raw.work ? [] : day.items.filter(isWorkEvent), revision: workScheduleKey(day) };
|
|
2911
|
+
}
|
|
2912
|
+
if (raw.revision !== undefined && raw.revision !== workScheduleKey(day)) {
|
|
2913
|
+
return { ok: false, message: '日程已经变化,请重新预览后再关闭上班。' };
|
|
2914
|
+
}
|
|
2879
2915
|
const out = await this.#lifeDayTool({ date, work: raw.work });
|
|
2880
2916
|
if (out.failed) return { ok: false, message: out.text };
|
|
2881
2917
|
this.#host?.log?.info?.('鱼的每一天:主人改了今天上不上班', { date, work: raw.work });
|