cortico-world-fun 0.9.2 → 0.9.3
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 +6 -0
- package/describe.json +758 -610
- package/dist/webui.js +370 -63
- package/package.json +1 -1
- package/src/ENV_PROMPT.md +1 -0
- package/src/outing-service.js +11 -1
- package/src/place-service.js +94 -11
- package/src/story-venue-migration.js +2 -1
- package/src/venues.js +6 -0
- package/src/world-decls.js +30 -0
- package/src/world.js +4 -0
package/package.json
CHANGED
package/src/ENV_PROMPT.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
出游按 `fun_places` → `fun_go`(续逛带 tripId)→ `fun_wander` → `fun_home`;地点与收获以回执为准,行程/珍藏按需查 `fun_journal`。
|
|
4
4
|
|
|
5
|
+
- `fun_place_save` 只新建或修改自建地点,不可改内置预设;可按需 `setHome: true` 设住所。
|
|
5
6
|
- `fun_home_room` 是画面非经历;`pendingLine` 仅供复制。主对话开启或切换日常活动时,顺手调用 `fun_home_room` 同步姿势与备注:`sleeping` 睡觉休息、`reading` 看书学习、`watching` 看剧看片、`gaming` 打游戏、`painting` 画画、`cooking` 做饭泡茶、`cards` 玩牌桌游、`chatting` 聊天、`looking_outside` 看窗外、`idle` 发呆放空。仅同步活动开启或切换,不因同一活动延续而重复调用;以行程 id/runId 作 `sourceRef` 防重,不自动互写,也不写入出游经历。若会话同时有生活日程与房间画面,回家或换活动时也可同步姿势,或用 `feast_life_play` 记经历。
|
|
6
7
|
- 配图用 `imggen_draw`,`scene` / `outfits` 用正名,只画真实场景;库里没找到就省略。吃喝只记品类,不等于「鱼的每一天」的吃饭记账;开启联动且实际用 `feast_menu` → `feast_eat` 才形容味道,否则别形容味道。不会探测其他扩展,也不依赖其他 World。
|
|
7
8
|
- 出门可用 `feast_life_now` 查日程、`feast_life_adjust` 写当天;没联动就跳过。本插件无定时器,是否出门由日程和主对话决定。时段影响项目,历史不编造;预设删不掉,只能恢复。
|
package/src/outing-service.js
CHANGED
|
@@ -104,7 +104,14 @@ export class OutingService {
|
|
|
104
104
|
recommendationLine(pick, detailed = false) {
|
|
105
105
|
const { venue, state, phase, areas, revisitReason } = pick;
|
|
106
106
|
const bits = [`${venue.name}(${[STATE_LABEL[state], phase, CROWD_LABEL[venue.crowd] || '人不少'].filter(Boolean).join(',')})`];
|
|
107
|
-
if (detailed)
|
|
107
|
+
if (detailed) {
|
|
108
|
+
bits.push(`${venue.hours.open}–${venue.hours.close}`);
|
|
109
|
+
const nowMin = minutesIn(this.#ctx.getTimezone(), this.#ctx.now());
|
|
110
|
+
const first = descNow(venue, nowMin).split(/[;;。!?.!?]/)[0].trim();
|
|
111
|
+
const colon = first.startsWith(venue.name) ? first.search(/[::]/) : -1;
|
|
112
|
+
const scenery = colon >= 0 ? first.slice(colon + 1).trim() : first;
|
|
113
|
+
if (scenery) bits.push(`样子:${scenery.length > 60 ? scenery.slice(0, 59) + '…' : scenery}`);
|
|
114
|
+
}
|
|
108
115
|
if (areas.length && detailed) bits.push(`现在能逛:${areas.slice(0, 5).join('、')}`);
|
|
109
116
|
if (revisitReason) bits.push(revisitReason);
|
|
110
117
|
return `- ${bits.join(';')}`;
|
|
@@ -614,6 +621,9 @@ export class OutingService {
|
|
|
614
621
|
const summary = tripSummary(trip);
|
|
615
622
|
const terse = this.#ctx.getConfig()?.funTerseReceipts === true;
|
|
616
623
|
const lines = [`回家:这一趟在${summary}。`];
|
|
624
|
+
if (trip.souvenirs?.length && !terse) {
|
|
625
|
+
lines.push(`买回的纪念品(${trip.souvenirs.join('、')})已收进纪念册(可用 fun_journal view:"shelf" 查看,也可在「鱼的家」摆件槽位摆出来)。`);
|
|
626
|
+
}
|
|
617
627
|
if (route) {
|
|
618
628
|
const nextStop = route.stops?.[route.nextIndex];
|
|
619
629
|
if (route.status === 'between' && nextStop) {
|
package/src/place-service.js
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
import { copyFile, mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { dirname } from 'node:path';
|
|
3
3
|
import { KIND_LABEL, VENUES, allPlaces } from './venues.js';
|
|
4
|
-
import { cleanOverride, cleanUserVenue, idFromName, isPresetId, isUserPlaceId, mergeVenues, parseVenueFile, stringifyVenueFile } from './user-venues.js';
|
|
4
|
+
import { cleanOverride, cleanUserVenue, idFromName, isPresetId, isUserPlaceId, mergeVenues, OVERRIDABLE, parseVenueFile, stringifyVenueFile } from './user-venues.js';
|
|
5
5
|
import { storyFailure } from './story-panel.js';
|
|
6
6
|
import { markVenueMigration, markPromotedVenueMigration, migratePromotedVenues, migrateSampleVenue } from './story-venue-migration.js';
|
|
7
7
|
import { PlaceLibrary } from './place-library.js';
|
|
8
|
+
import { BASIC_FIELDS, editableFields, isObject, text } from './place-transfer.js';
|
|
8
9
|
import { msg } from './world-utils.js';
|
|
9
10
|
|
|
11
|
+
const OVERRIDE_LABELS = {
|
|
12
|
+
name: '名字', aliases: '别名', tags: '标签', desc: '描述', hours: '开放时段',
|
|
13
|
+
recommendedOutfit: '推荐穿搭', crowd: '人多不多', areas: '能逛的', souvenirs: '纪念品',
|
|
14
|
+
photoSpots: '拍照点', randomEvents: '可能碰上的小事', food: '能吃能喝',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const formatOverrideValue = (field, value) => {
|
|
18
|
+
if (field === 'food') {
|
|
19
|
+
const food = value ?? null;
|
|
20
|
+
if (!food || typeof food !== 'object' || !['吃', '喝'].includes(food.verb)
|
|
21
|
+
|| !Array.isArray(food.items) || !food.items.length) return '没有';
|
|
22
|
+
return `${food.verb}:${food.items.join('、')}`;
|
|
23
|
+
}
|
|
24
|
+
if (field === 'hours') {
|
|
25
|
+
const hours = value && typeof value === 'object' ? value : {};
|
|
26
|
+
const open = hours.open ?? '';
|
|
27
|
+
const close = hours.close ?? '';
|
|
28
|
+
return open || close ? `${open}–${close}` : '';
|
|
29
|
+
}
|
|
30
|
+
if (Array.isArray(value)) return value.join('、');
|
|
31
|
+
return value == null ? '' : String(value);
|
|
32
|
+
};
|
|
33
|
+
|
|
10
34
|
/** 地点目录、迁移及面板操作;不依赖 World 类或其他领域服务。 */
|
|
11
35
|
export class PlaceService {
|
|
12
36
|
#ctx;
|
|
@@ -176,6 +200,49 @@ export class PlaceService {
|
|
|
176
200
|
this.#ctx.getHost()?.log?.info?.('从0开始的肥鱼大冒险:旧地点库已并进地点表', { migrated: extras.length });
|
|
177
201
|
}
|
|
178
202
|
|
|
203
|
+
async savePlaceTool(args) {
|
|
204
|
+
const fail = (code, error) => ({ ok: false, code, error });
|
|
205
|
+
const fields = ['name', 'desc', 'aliases', 'tags', 'kind', 'hours', 'crowd', 'recommendedOutfit',
|
|
206
|
+
'areas', 'souvenirs', 'photoSpots', 'randomEvents', 'food', 'style'];
|
|
207
|
+
if (!isObject(args) || Object.keys(args).some((key) => !['id', 'setHome', ...fields].includes(key))) {
|
|
208
|
+
return fail('INVALID_INPUT', '只接受地点编辑字段,不支持删除或其他操作。');
|
|
209
|
+
}
|
|
210
|
+
if (Object.hasOwn(args, 'setHome') && typeof args.setHome !== 'boolean') {
|
|
211
|
+
return fail('INVALID_INPUT', 'setHome 必须是布尔值。');
|
|
212
|
+
}
|
|
213
|
+
const editing = args.id !== undefined;
|
|
214
|
+
const library = this.#locationLibrary;
|
|
215
|
+
try {
|
|
216
|
+
if (editing) {
|
|
217
|
+
if (isPresetId(VENUES, args.id) || !isUserPlaceId(args.id)) {
|
|
218
|
+
return fail('INVALID_PLACE', '只能修改用户自建地点,不可修改内置预设。');
|
|
219
|
+
}
|
|
220
|
+
if (!await library.get(args.id)) return fail('NOT_FOUND', '找不到这个自建地点,请确认 id。');
|
|
221
|
+
}
|
|
222
|
+
const input = Object.fromEntries(fields.filter((key) => Object.hasOwn(args, key)).map((key) => [key, args[key]]));
|
|
223
|
+
const basic = editableFields(input, args.id ?? '', { fields: BASIC_FIELDS });
|
|
224
|
+
Object.assign(input, basic);
|
|
225
|
+
for (const key of ['desc', 'style']) {
|
|
226
|
+
if (Object.hasOwn(input, key)) input[key] = text(input[key], key === 'desc' ? 400 : 160, key, { descriptive: true });
|
|
227
|
+
}
|
|
228
|
+
if (!editing && (!input.name || !input.desc)) return fail('INVALID_INPUT', '新建地点必须填写非空的 name 和 desc。');
|
|
229
|
+
let id = args.id;
|
|
230
|
+
if (editing) {
|
|
231
|
+
const { style, ...venue } = input;
|
|
232
|
+
if (Object.keys(venue).length) await library.updateVenue(id, venue);
|
|
233
|
+
if (Object.hasOwn(input, 'style')) await library.update(id, { style });
|
|
234
|
+
} else {
|
|
235
|
+
({ id } = await library.create(input));
|
|
236
|
+
}
|
|
237
|
+
if (args.setHome === true) await library.setHome(id);
|
|
238
|
+
this.#ctx.bumpCache();
|
|
239
|
+
const snapshot = await library.snapshot();
|
|
240
|
+
return { ok: true, place: snapshot.places.find((place) => place.id === id), homeId: snapshot.homeId, revision: snapshot.revision };
|
|
241
|
+
} catch (error) {
|
|
242
|
+
return fail(error?.code ?? 'INVALID_INPUT', msg(error));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
179
246
|
async invokeLocations(method, payload) {
|
|
180
247
|
return this.#ctx.serial(async () => {
|
|
181
248
|
this.#ctx.ensureStarted();
|
|
@@ -247,16 +314,32 @@ export class PlaceService {
|
|
|
247
314
|
if (!pack?.placeId) continue;
|
|
248
315
|
(isBuiltin ? builtin : custom).add(pack.placeId);
|
|
249
316
|
}
|
|
250
|
-
const places = snapshot.places.map((place) =>
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
317
|
+
const places = snapshot.places.map((place) => {
|
|
318
|
+
const preset = VENUES.find((venue) => venue.id === place.id);
|
|
319
|
+
const override = this.#overrides?.[place.id];
|
|
320
|
+
const overridden = Boolean(override && Object.keys(override).length);
|
|
321
|
+
const decorated = {
|
|
322
|
+
...place,
|
|
323
|
+
kindLabel: KIND_LABEL[place.kind] ?? '',
|
|
324
|
+
storyBound: builtin.has(place.id) || custom.has(place.id),
|
|
325
|
+
builtinStoryBound: builtin.has(place.id),
|
|
326
|
+
customStoryBound: custom.has(place.id),
|
|
327
|
+
userPlace: place.playable ? !isPresetId(VENUES, place.id) : true,
|
|
328
|
+
preset: Boolean(preset),
|
|
329
|
+
overridden,
|
|
330
|
+
};
|
|
331
|
+
if (overridden && preset) {
|
|
332
|
+
decorated.overrideDiff = OVERRIDABLE
|
|
333
|
+
.filter((field) => Object.hasOwn(override, field))
|
|
334
|
+
.map((field) => ({
|
|
335
|
+
field,
|
|
336
|
+
label: OVERRIDE_LABELS[field] ?? field,
|
|
337
|
+
before: formatOverrideValue(field, field === 'food' ? (preset[field] ?? null) : preset[field]),
|
|
338
|
+
after: formatOverrideValue(field, field === 'food' ? (override[field] ?? null) : override[field]),
|
|
339
|
+
}));
|
|
340
|
+
}
|
|
341
|
+
return decorated;
|
|
342
|
+
});
|
|
260
343
|
return { ...snapshot, places };
|
|
261
344
|
}
|
|
262
345
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
3
|
import { dirname } from 'node:path';
|
|
4
|
+
import { RETIRED_SAMPLE_VENUE_ID } from './creek-letter.js';
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
+
export { RETIRED_SAMPLE_VENUE_ID };
|
|
6
7
|
/** Places that shipped as user-written copies but are now built into the plugin.
|
|
7
8
|
* They are only removed when the stored copy is byte-equivalent to the built-in definition,
|
|
8
9
|
* so a place the user has since edited (or rebuilt later) is never touched. */
|
package/src/venues.js
CHANGED
|
@@ -51,6 +51,7 @@ export const VENUES = [
|
|
|
51
51
|
crowd: 'packed',
|
|
52
52
|
hours: { open: '09:00', close: '21:00' },
|
|
53
53
|
areas: ['过山车', '旋转木马', '摩天轮', '鬼屋', '碰碰车', '套圈摊位', '气球摊', '小吃车'],
|
|
54
|
+
food: { label: '吃的', items: ['热狗', '爆米花', '冰淇淋', '烤肠'], verb: '吃' },
|
|
54
55
|
souvenirs: ['气球', '棉花糖', '旋转木马票根', '一枚纪念币'],
|
|
55
56
|
photoSpots: ['摩天轮轿厢里', '旋转木马前', '彩灯亮起来的铁架下'],
|
|
56
57
|
randomEvents: [
|
|
@@ -115,6 +116,7 @@ export const VENUES = [
|
|
|
115
116
|
crowd: 'packed',
|
|
116
117
|
hours: { open: '17:00', close: '22:00' },
|
|
117
118
|
areas: ['参道摊位', '捞金鱼', '套圈', '抽签处', '小吃摊', '太鼓台'],
|
|
119
|
+
food: { label: '吃的', items: ['糖炒栗子', '烤鱿鱼', '章鱼小丸子', '热豆花'], verb: '吃' },
|
|
118
120
|
souvenirs: ['一支签', '御守', '捞到的金鱼', '苹果糖'],
|
|
119
121
|
photoSpots: ['鸟居正下方', '灯笼廊下', '太鼓台侧面'],
|
|
120
122
|
randomEvents: [
|
|
@@ -147,6 +149,7 @@ export const VENUES = [
|
|
|
147
149
|
crowd: 'packed',
|
|
148
150
|
hours: { open: '10:00', close: '18:00' },
|
|
149
151
|
areas: ['同人展台', '企业馆', '舞台区', '排队的通道', '海报墙', '餐饮区'],
|
|
152
|
+
food: { label: '喝的', items: ['瓶装水', '冰美式', '热奶茶', '运动饮料'], verb: '喝' },
|
|
150
153
|
souvenirs: ['同人本', '吧唧', '色纸', '文件夹', '立牌'],
|
|
151
154
|
photoSpots: ['海报墙前', '立牌旁边', '展馆门口的横幅下'],
|
|
152
155
|
randomEvents: [
|
|
@@ -181,6 +184,7 @@ export const VENUES = [
|
|
|
181
184
|
crowd: 'normal',
|
|
182
185
|
hours: { open: '10:00', close: '23:00' },
|
|
183
186
|
areas: ['取票厅', '影厅', '爆米花柜台', '走廊的海报墙', '最后一排', '散场通道'],
|
|
187
|
+
food: { label: '吃的', items: ['爆米花', '可乐', '玉米片', '矿泉水'], verb: '吃' },
|
|
184
188
|
souvenirs: ['电影票根', '爆米花桶', '海报', '联名饮料杯'],
|
|
185
189
|
photoSpots: ['大厅的立牌前', '空影厅里', '海报墙下面'],
|
|
186
190
|
randomEvents: [
|
|
@@ -213,6 +217,7 @@ export const VENUES = [
|
|
|
213
217
|
crowd: 'packed',
|
|
214
218
|
hours: { open: '08:30', close: '17:30' },
|
|
215
219
|
areas: ['熊猫馆', '长颈鹿区', '猴山', '爬行动物馆', '园内小火车', '儿童乐园'],
|
|
220
|
+
food: { label: '喝的', items: ['矿泉水', '酸梅汤', '冰镇汽水', '热豆浆'], verb: '喝' },
|
|
216
221
|
souvenirs: ['熊猫玩偶', '动物贴纸', '一张门票', '糖画'],
|
|
217
222
|
photoSpots: ['长颈鹿区的木栏前', '猴山旁的长椅上', '园区大门口'],
|
|
218
223
|
randomEvents: [
|
|
@@ -434,6 +439,7 @@ export const VENUES = [
|
|
|
434
439
|
crowd: 'quiet',
|
|
435
440
|
hours: { open: '11:00', close: '21:00' },
|
|
436
441
|
areas: ['靠窗的坐垫', '猫爬架', '吧台', '书架角', '猫咪休息区'],
|
|
442
|
+
food: { label: '喝的', items: ['手冲咖啡', '热可可', '抹茶拿铁', '蜂蜜柚子茶'], verb: '喝' },
|
|
437
443
|
souvenirs: ['一包猫条', '猫咪明信片', '店里的杯垫'],
|
|
438
444
|
photoSpots: ['猫爬架旁边', '靠窗的坐垫上', '吧台前的暖灯下'],
|
|
439
445
|
randomEvents: [
|
package/src/world-decls.js
CHANGED
|
@@ -30,6 +30,36 @@ export const FUN_TOOL_DECLS = [
|
|
|
30
30
|
additionalProperties: false,
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
|
+
{
|
|
34
|
+
name: 'fun_place_save',
|
|
35
|
+
tags: ['write'],
|
|
36
|
+
description: '新建或修改用户自建地点,不可修改内置预设,不支持删除。新建不传 id,name、desc 必填且不可重名;编辑须传已有自建地点 id,仅更新所传字段。areas 为可逛项目;可用 setHome:true 设为住所。描写只写场景,不写路线、坐标或方向。',
|
|
37
|
+
parameters: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
id: { type: 'string', description: '编辑时填已有自建地点 ID;新建省略。' },
|
|
41
|
+
name: { type: 'string', maxLength: 40, description: '地点名,新建必填。' },
|
|
42
|
+
desc: { type: 'string', maxLength: 400, description: '地点描写,新建必填。' },
|
|
43
|
+
aliases: { type: 'array', maxItems: 8, items: { type: 'string', maxLength: 40 } },
|
|
44
|
+
tags: { type: 'array', maxItems: 8, items: { type: 'string', maxLength: 20 } },
|
|
45
|
+
kind: { type: 'string', maxLength: 40 },
|
|
46
|
+
hours: { type: 'object', properties: { open: { type: 'string' }, close: { type: 'string' } }, required: ['open', 'close'], additionalProperties: false },
|
|
47
|
+
crowd: { type: 'string', enum: ['quiet', 'normal', 'packed'] },
|
|
48
|
+
recommendedOutfit: { type: 'string', maxLength: 40 },
|
|
49
|
+
areas: { type: 'array', maxItems: 30, items: { type: 'string', maxLength: 40 }, description: '可逛项目;非空时成为可玩场所,空数组清空项目。' },
|
|
50
|
+
souvenirs: { type: 'array', maxItems: 20, items: { type: 'string', maxLength: 40 } },
|
|
51
|
+
photoSpots: { type: 'array', maxItems: 20, items: { type: 'string', maxLength: 60 } },
|
|
52
|
+
randomEvents: { type: 'array', maxItems: 20, items: { type: 'string', maxLength: 120 } },
|
|
53
|
+
food: { anyOf: [
|
|
54
|
+
{ type: 'object', properties: { verb: { type: 'string', enum: ['吃', '喝'] }, items: { type: 'array', maxItems: 20, items: { type: 'string', maxLength: 30 } } }, required: ['verb', 'items'], additionalProperties: false },
|
|
55
|
+
{ type: 'null' },
|
|
56
|
+
] },
|
|
57
|
+
style: { type: 'string', maxLength: 160 },
|
|
58
|
+
setHome: { type: 'boolean', description: 'true = 保存成功后将该地点设为当前住所。' },
|
|
59
|
+
},
|
|
60
|
+
additionalProperties: false,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
33
63
|
{
|
|
34
64
|
name: 'fun_go',
|
|
35
65
|
tags: ['write'],
|
package/src/world.js
CHANGED
|
@@ -451,6 +451,10 @@ export class FunWorld {
|
|
|
451
451
|
this.#ensureStarted();
|
|
452
452
|
switch (name) {
|
|
453
453
|
case 'fun_places': return args?.now === true ? this.#outing.startTool() : this.#outing.placesTool(args);
|
|
454
|
+
case 'fun_place_save': {
|
|
455
|
+
const result = await this.#locations.savePlaceTool(args);
|
|
456
|
+
return { ...result, text: JSON.stringify(result), ...(result.ok ? {} : { failed: true }) };
|
|
457
|
+
}
|
|
454
458
|
case 'fun_go': return this.#outing.goOuting(args);
|
|
455
459
|
case 'fun_wander': return await this.#outing.wanderTool(args, this.#state.session?.storyRun?.participation === 'duo' ? 'fish' : undefined);
|
|
456
460
|
case 'fun_home': {
|