@ssamurias/dsh-fish 1.1.5 → 1.1.7
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/AGENTS.md +27 -4
- package/CHANGELOG.md +150 -0
- package/README.md +31 -4
- package/RELEASE-NOTES-1.1.6.md +57 -0
- package/RELEASE-NOTES-1.1.7.md +76 -0
- package/lib/ask.js +7 -1
- package/lib/capture.js +1 -0
- package/lib/claim.js +23 -0
- package/lib/client.js +329 -79
- package/lib/comment.js +18 -10
- package/lib/cue.js +99 -23
- package/lib/derive.js +215 -49
- package/lib/desk.js +5 -2
- package/lib/didclaim.js +307 -0
- package/lib/events.js +32 -4
- package/lib/handoff.js +13 -3
- package/lib/health.js +4 -0
- package/lib/hear.js +8 -1
- package/lib/herperson.js +33 -18
- package/lib/home.js +4 -0
- package/lib/inbox.js +23 -7
- package/lib/index.js +9 -3
- package/lib/loadgate.js +48 -0
- package/lib/memorymap-html.js +1 -1
- package/lib/memorymap.js +22 -2
- package/lib/move.js +68 -8
- package/lib/observe-bili.js +32 -2
- package/lib/observe-config.js +81 -6
- package/lib/observe-data.js +3 -1
- package/lib/observe-home.js +15 -4
- package/lib/observe-http.js +4 -0
- package/lib/observe-state.js +3 -2
- package/lib/people.js +78 -2
- package/lib/persona.js +8 -3
- package/lib/proactive.js +11 -4
- package/lib/quality.js +207 -48
- package/lib/recall.js +73 -24
- package/lib/redact.js +27 -0
- package/lib/reset-pending.js +15 -5
- package/lib/reset.js +78 -0
- package/lib/restrict.js +40 -2
- package/lib/retire.js +42 -1
- package/lib/say.js +60 -13
- package/lib/scheduler.js +32 -27
- package/lib/schema.js +1 -1
- package/lib/selfdoc.js +6 -0
- package/lib/settings.js +166 -31
- package/lib/status.js +1 -1
- package/lib/timeintent.js +178 -0
- package/lib/turns.js +86 -28
- package/lib/types.d.ts +1 -0
- package/lib/wiki.js +72 -9
- package/lib/works.js +5 -0
- package/media/feedback-qr.jpg +0 -0
- package/package.json +4 -1
- package/tools/README.md +69 -0
- package/tools/recall-bench.mjs +240 -0
- package/tools/recall-cases.json +64 -0
- package/tools/recall-live-cases.json +20 -0
- package/lib/client/00-shell.js +0 -630
- package/lib/client/01-state-load.js +0 -968
- package/lib/client/02-actions.js +0 -692
- package/lib/client/03-widgets-header.js +0 -749
- package/lib/client/04-pressure-lab.js +0 -906
- package/lib/client/05-pressure-charts.js +0 -431
- package/lib/client/06-tab-status-grow.js +0 -479
- package/lib/client/07-tab-home-bili.js +0 -610
- package/lib/client/08-tab-memory-plugins.js +0 -676
- package/lib/client/09-tab-outing.js +0 -797
- package/lib/client/10-data-handlers.js +0 -519
- package/lib/client/11-tab-data-frame.js +0 -812
- package/lib/client/12-pressure-chip-mount.js +0 -579
- package/scripts/build-client.mjs +0 -97
- package/scripts/sync-pressure-formulas.mjs +0 -14
package/lib/memorymap.js
CHANGED
|
@@ -129,12 +129,13 @@ export function buildViewData(events, model, stances, now = Date.now()) {
|
|
|
129
129
|
nodes.push({ id: e.id, kind: 'heard', text: e.text, at: at(e), from: whoName(e.who) })
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
// 3.
|
|
132
|
+
// 3. 人物(2026-12-01 用户 m01252:不预设「主人」——她怎么叫{T},节点就写什么;
|
|
133
|
+
// 还没有称呼时写「你」。改名不回写旧名字:`model.people` 的 name 取最近一次生效的称呼)
|
|
133
134
|
for (const p of model.people || []) {
|
|
134
135
|
const pid = 'person:' + (p.id || p.name)
|
|
135
136
|
nodes.push({
|
|
136
137
|
id: pid, kind: 'person',
|
|
137
|
-
text: p.id === 'owner' ? '
|
|
138
|
+
text: p.id === 'owner' ? (p.name || '你') : (p.name || '一个人'),
|
|
138
139
|
at: p.firstAt || t0,
|
|
139
140
|
judged: Number(p.judged || 0),
|
|
140
141
|
judgmentIds: p.judgmentIds || [],
|
|
@@ -187,6 +188,25 @@ export function buildViewData(events, model, stances, now = Date.now()) {
|
|
|
187
188
|
const bid = matByBvid.get(v.bvid)
|
|
188
189
|
if (bid) addEdge(v.id, bid, 'about')
|
|
189
190
|
}
|
|
191
|
+
// 2026-12-01(用户 m01484,A+C 的 C):听来的话连到人。
|
|
192
|
+
// 以前人物节点只有「判断」这一种边,`voice` / `heard` 只是带一行 `from` 的孤立点——
|
|
193
|
+
// 她在群里听来的、在评论区读到的,明明记在某个人名下,星图上却看不出和谁有关。
|
|
194
|
+
// 只在名字能唯一对上时连(人物名来自 `model.people`,同名的那一行本来就不猜)。
|
|
195
|
+
{
|
|
196
|
+
const byPersonName = new Map()
|
|
197
|
+
for (const p of model.people || []) {
|
|
198
|
+
const name = String(p?.name ?? '').trim()
|
|
199
|
+
if (!name) continue
|
|
200
|
+
const pid = 'person:' + (p.id || p.name)
|
|
201
|
+
// 同名多个人时不猜(与 people.js 的「同名不猜」同一条取舍)。
|
|
202
|
+
byPersonName.set(name, byPersonName.has(name) ? '' : pid)
|
|
203
|
+
}
|
|
204
|
+
for (const n of nodes) {
|
|
205
|
+
if (n.kind !== 'heard' || !n.from) continue
|
|
206
|
+
const pid = byPersonName.get(String(n.from).trim())
|
|
207
|
+
if (pid) addEdge(n.id, pid, 'hearsay')
|
|
208
|
+
}
|
|
209
|
+
}
|
|
190
210
|
// 同 topic / 同 who
|
|
191
211
|
const byTopic = new Map(), byWho = new Map()
|
|
192
212
|
for (const n of nodes.filter((x) => x.kind === 'belief')) {
|
package/lib/move.js
CHANGED
|
@@ -133,6 +133,49 @@ async function collect(base) {
|
|
|
133
133
|
return out
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* 只数文件、不逐件量大小。`readdir` 的目录项本身就带「是不是文件」,
|
|
138
|
+
* 少掉每条一次 `stat`——Windows 上那一次常被安全软件逐件扫,几千个文件就是十几秒。
|
|
139
|
+
* 数出来的是同一个数,只有大小得另算。
|
|
140
|
+
*/
|
|
141
|
+
async function countFiles(base) {
|
|
142
|
+
let n = 0
|
|
143
|
+
async function walk(dir) {
|
|
144
|
+
const entries = await fs.readdir(dir, { withFileTypes: true })
|
|
145
|
+
for (const e of entries) {
|
|
146
|
+
if (e.isDirectory()) {
|
|
147
|
+
if (!SKIP_DIRS.has(e.name)) await walk(join(dir, e.name))
|
|
148
|
+
continue
|
|
149
|
+
}
|
|
150
|
+
if (e.isFile()) n += 1
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
try { await walk(base) } catch { /* 目录还不存在就等于 0 */ }
|
|
154
|
+
return n
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** 大小十分钟内信得过:搬一次家要十几秒,没必要每开一次设置页重量一遍。 */
|
|
158
|
+
const SIZE_TTL_MS = 10 * 60 * 1000
|
|
159
|
+
let sizeCache = { root: '', at: 0, bytes: 0 }
|
|
160
|
+
let sizeJob = null
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 后台量一次大小(单飞,不挡请求):量完写进缓存,下次打开设置页就是现成的。
|
|
164
|
+
* 同一个根同时只跑一份;失败就当 0,不往外抛。
|
|
165
|
+
*/
|
|
166
|
+
function sizeInBackground(root, base) {
|
|
167
|
+
if (sizeJob) return sizeJob
|
|
168
|
+
sizeJob = collect(base)
|
|
169
|
+
.then((list) => {
|
|
170
|
+
const bytes = list.reduce((n, f) => n + f.size, 0)
|
|
171
|
+
sizeCache = { root, at: Date.now(), bytes }
|
|
172
|
+
return bytes
|
|
173
|
+
})
|
|
174
|
+
.catch(() => 0)
|
|
175
|
+
.finally(() => { sizeJob = null })
|
|
176
|
+
return sizeJob
|
|
177
|
+
}
|
|
178
|
+
|
|
136
179
|
const EVENTS_REL = 'events.jsonl'
|
|
137
180
|
/** 封住之后等这么久再量一次:让已经过了闸、正在落盘的那一条写完。 */
|
|
138
181
|
const SETTLE_MS = 30
|
|
@@ -397,15 +440,31 @@ export async function rootMovedAway(root, { since = 0 } = {}) {
|
|
|
397
440
|
}
|
|
398
441
|
|
|
399
442
|
/** 现在住在哪、能不能立刻搬(给 GET /move 用)。 */
|
|
400
|
-
|
|
443
|
+
/**
|
|
444
|
+
* 设置页「迁移」那张卡要的数字。
|
|
445
|
+
*
|
|
446
|
+
* 默认只数文件、不量大小(issue #184:几千个文件逐件 stat 在 Windows 上要十几秒,
|
|
447
|
+
* 这段时间磁盘被它占着,她回话也会跟着慢)。大小走缓存:十分钟内用过就直给,
|
|
448
|
+
* 过期了就在后台量一次,这一次先返回 `bytes: null` + `sizing: true`,前端写「正在量」。
|
|
449
|
+
* 传 `{ full: true }` 时仍走同步全量(`?full=1`,给「我就想现在看准数」用)。
|
|
450
|
+
*/
|
|
451
|
+
export async function moveStatus(root = rootDir(), { full = false } = {}) {
|
|
401
452
|
const p = paths(root)
|
|
402
|
-
|
|
403
|
-
let bytes =
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
453
|
+
const files = await countFiles(p.root)
|
|
454
|
+
let bytes = null
|
|
455
|
+
let sizing = false
|
|
456
|
+
if (full) {
|
|
457
|
+
try {
|
|
458
|
+
const list = await collect(p.root)
|
|
459
|
+
bytes = list.reduce((n, f) => n + f.size, 0)
|
|
460
|
+
sizeCache = { root: p.root, at: Date.now(), bytes }
|
|
461
|
+
} catch { bytes = 0 }
|
|
462
|
+
} else if (sizeCache.root === p.root && Date.now() - sizeCache.at < SIZE_TTL_MS) {
|
|
463
|
+
bytes = sizeCache.bytes
|
|
464
|
+
} else {
|
|
465
|
+
sizing = true
|
|
466
|
+
void sizeInBackground(p.root, p.root)
|
|
467
|
+
}
|
|
409
468
|
return {
|
|
410
469
|
root: p.root,
|
|
411
470
|
locationFile: locationFile(),
|
|
@@ -413,6 +472,7 @@ export async function moveStatus(root = rootDir()) {
|
|
|
413
472
|
moved: norm(p.root) !== norm(defaultRoot()),
|
|
414
473
|
files,
|
|
415
474
|
bytes,
|
|
475
|
+
sizing,
|
|
416
476
|
relative: relative(homedirOrEmpty(), p.root) || '',
|
|
417
477
|
}
|
|
418
478
|
}
|
package/lib/observe-bili.js
CHANGED
|
@@ -26,6 +26,26 @@ import { riskState, clearRisk } from './risk.js'
|
|
|
26
26
|
import { logLine } from './log.js'
|
|
27
27
|
import { send, sentTooLarge, readBody } from './observe-http.js'
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* 查一次登录态要现发一次 B 站(约 1 秒)。一分钟内重复打开设置页时复用同一个答案
|
|
31
|
+
* ——`/state` 与它并行之后,这一秒不再挡页面,但也没必要每次都打一趟(issue #184)。
|
|
32
|
+
*/
|
|
33
|
+
const BILI_STATE_TTL_MS = 60_000
|
|
34
|
+
let biliStateCache = { key: '', at: 0, body: /** @type {any} */ (null) }
|
|
35
|
+
|
|
36
|
+
/** 缓存键:同一个家 + 同一份 cookie 才算同一条答案。 */
|
|
37
|
+
function biliStateKey(root, cookie) {
|
|
38
|
+
return `${root}|${String(cookie ?? '').slice(-16)}`
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 这份缓存还够不够新。抽出来是为了能直接测,不用起 HTTP 服务。
|
|
43
|
+
* `?fresh=1` 时调用方自己绕过它。
|
|
44
|
+
*/
|
|
45
|
+
export function biliStateFresh(entry, key, now, ttl = BILI_STATE_TTL_MS) {
|
|
46
|
+
return Boolean(entry) && entry.key === key && Boolean(entry.body) && now - entry.at < ttl
|
|
47
|
+
}
|
|
48
|
+
|
|
29
49
|
/**
|
|
30
50
|
* 引导文案:别人第一次装,本机没有现成 cookie。
|
|
31
51
|
*/
|
|
@@ -132,13 +152,23 @@ export function buildBiliRoutes(env) {
|
|
|
132
152
|
if (req.method !== 'GET') return send(res, 405, { error: '只支持 GET' })
|
|
133
153
|
const ow = await readOwner(root)
|
|
134
154
|
if (!ow?.cookie) return send(res, 200, { ok: false, state: 'none', note: '还没存 B 站登录。' })
|
|
155
|
+
const fresh = /[?&]fresh=1(?:&|$)/.test(String(req.url ?? ''))
|
|
156
|
+
const key = biliStateKey(root, ow.cookie)
|
|
157
|
+
if (!fresh && biliStateFresh(biliStateCache, key, Date.now())) {
|
|
158
|
+
return send(res, 200, { ...biliStateCache.body, cached: true })
|
|
159
|
+
}
|
|
160
|
+
/** 只有「查到了」才记:没连上不缓存,下一次还能重试。 */
|
|
161
|
+
const remember = (body) => {
|
|
162
|
+
biliStateCache = { key, at: Date.now(), body }
|
|
163
|
+
return send(res, 200, body)
|
|
164
|
+
}
|
|
135
165
|
try {
|
|
136
166
|
const c = createClient({ cookie: ow.cookie, log: () => {} })
|
|
137
167
|
const me = /** @type {any} */ (await c.me())
|
|
138
168
|
if (!me?.isLogin) {
|
|
139
|
-
return
|
|
169
|
+
return remember({ ok: false, state: 'expired', note: 'B 站登录已过期,需要重新登录。', why: me?.why ?? '' })
|
|
140
170
|
}
|
|
141
|
-
return
|
|
171
|
+
return remember({ ok: true, state: 'ok', name: String(me.uname ?? ''), mid: String(me.mid ?? ''), canWrite: Boolean(me.canWrite) })
|
|
142
172
|
} catch (err) {
|
|
143
173
|
const msg = String(/** @type {any} */ (err)?.message ?? err)
|
|
144
174
|
logLine('warn', ['登录态:查状态时没连上 B 站', msg.slice(0, 160)], root)
|
package/lib/observe-config.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { readEvents } from './store.js'
|
|
10
|
-
import { loadConfig, updateConfig, configFileInfo, validateToolNames, sanitizeToolNames, windowProblem } from './settings.js'
|
|
10
|
+
import { loadConfig, updateConfig, configFileInfo, validateToolNames, sanitizeToolNames, windowProblem, windowsProblem } from './settings.js'
|
|
11
11
|
import { fillSelf, selfPronounFor } from './selfpronoun.js'
|
|
12
12
|
import { deriveSelf } from './derive.js'
|
|
13
13
|
import { noteSpeakEnabled, speakOn } from './speak.js'
|
|
@@ -57,8 +57,17 @@ export function buildConfigRoutes(env) {
|
|
|
57
57
|
try { patch = JSON.parse(body || '{}') } catch { return send(res, 400, { error: 'body 不是合法 JSON' }) }
|
|
58
58
|
const strictTools = patch.strictTools === true
|
|
59
59
|
delete patch.strictTools
|
|
60
|
+
// 收缩确认(issue #191 第九节,2026-12-02)。白名单是**整份替换**的放行名单,
|
|
61
|
+
// 少写一个名字就等于少放行一件工具。报告人那台机器一天里两次把 48 项提交成
|
|
62
|
+
// 玩具列表(想试某个名字认不认),两条会话当场失语、连 bash 都调不动,而它们
|
|
63
|
+
// 自己查不出原因——所以「真子集」这一种提交必须由调用方显式认一次。
|
|
64
|
+
//
|
|
65
|
+
// 认的方式是加 `allowShrink: 'confirm'`:设置页在用户**亲手删掉**某几个名字时带上它,
|
|
66
|
+
// 外部脚本拿一份小列表试形状不会带——那正是要挡住的那一下。
|
|
67
|
+
const allowShrink = patch.allowShrink === 'confirm'
|
|
68
|
+
delete patch.allowShrink
|
|
60
69
|
// 白名单:只允许改"环境",不允许任何指向她本人的键(test/p5.test.mjs 反查这张表)
|
|
61
|
-
const allowed = ['growthDays', 'wakesPerDay', 'window', 'daily', 'diary', 'absenceAfterDays', 'avoid', 'browse', 'bili', 'video', 'comment', 'at', 'people', 'notify', 'chat', 'rooms', 'memory', 'tools', 'observe', 'ui', 'proactive', 'drive', 'interest', 'dream', 'works', 'owner', 'self', 'backup', 'cloud', 'bridge']
|
|
70
|
+
const allowed = ['growthDays', 'wakesPerDay', 'window', 'windows', 'daily', 'diary', 'absenceAfterDays', 'avoid', 'browse', 'bili', 'video', 'comment', 'at', 'people', 'notify', 'chat', 'rooms', 'memory', 'tools', 'observe', 'ui', 'proactive', 'drive', 'interest', 'dream', 'works', 'owner', 'self', 'backup', 'cloud', 'bridge']
|
|
62
71
|
const bad = Object.keys(patch).filter((k) => !allowed.includes(k))
|
|
63
72
|
if (bad.length) {
|
|
64
73
|
logLine('warn', [
|
|
@@ -68,6 +77,14 @@ export function buildConfigRoutes(env) {
|
|
|
68
77
|
], root)
|
|
69
78
|
return send(res, 400, { error: `这一版还不支持保存:${bad.join('、')}` })
|
|
70
79
|
}
|
|
80
|
+
// 老客户端只发 `window`,新客户端两样都发。无论哪一样缺,都补齐另一份,
|
|
81
|
+
// 否则 normalizeConfig 会以 `windows` 为准、把只改 `window` 的保存吞掉。
|
|
82
|
+
if (patch.windows === undefined && Array.isArray(patch.window) && patch.window.length === 2) {
|
|
83
|
+
patch.windows = [patch.window]
|
|
84
|
+
}
|
|
85
|
+
if (patch.window === undefined && Array.isArray(patch.windows) && patch.windows[0]) {
|
|
86
|
+
patch.window = patch.windows[0]
|
|
87
|
+
}
|
|
71
88
|
/** @type {[string, unknown][]} */
|
|
72
89
|
const ranges = [
|
|
73
90
|
[fillSelf('{S}醒着的时间段', selfPronounFor(root)), patch.window],
|
|
@@ -79,6 +96,10 @@ export function buildConfigRoutes(env) {
|
|
|
79
96
|
const problem = windowProblem(w)
|
|
80
97
|
if (problem) return send(res, 400, { error: `${label}:${problem}` })
|
|
81
98
|
}
|
|
99
|
+
if (patch.windows !== undefined && patch.windows !== null) {
|
|
100
|
+
const problem = windowsProblem(patch.windows)
|
|
101
|
+
if (problem) return send(res, 400, { error: `${fillSelf('{S}醒着的时间段', selfPronounFor(root))}:${problem}` })
|
|
102
|
+
}
|
|
82
103
|
/** @type {string[]} */
|
|
83
104
|
let droppedTools = []
|
|
84
105
|
if (patch.tools && patch.tools.allow !== undefined) {
|
|
@@ -106,20 +127,74 @@ export function buildConfigRoutes(env) {
|
|
|
106
127
|
}
|
|
107
128
|
}
|
|
108
129
|
const before = await loadConfig(root).catch(() => null)
|
|
130
|
+
// 「少了的那几个里,哪些是这台机器上真有的工具」。两处都要用(挡回判据、留账判据),
|
|
131
|
+
// 所以先算一次:盘上留着的旧名字不算她的手,丢了不算收缩,也不该在日志里喊「少了」。
|
|
132
|
+
const knownNow = knownToolNames(ctx)
|
|
133
|
+
const knownNowSet = Array.isArray(knownNow) && knownNow.length ? new Set(knownNow.map(String)) : null
|
|
134
|
+
// ---- 收缩保护(issue #191 第九节,2026-12-02)----
|
|
135
|
+
// 判据只看**集合**,不看顺序、不看条数:提交的名单里少了盘上原有的任何一个名字,
|
|
136
|
+
// 就算一次收缩。真子集(少了东西又没多出来)最典型——报告人两次事故都是这种形状。
|
|
137
|
+
//
|
|
138
|
+
// 两种情况不算收缩:
|
|
139
|
+
// · 少了的那几个**本来就不是这台机器上的工具**(盘上留着的旧名字、或是这次被
|
|
140
|
+
// sanitize 丢掉的坏名字)——丢的是一行废字,不是一只手。2026-10-31 的 issue #14
|
|
141
|
+
// 那条用例要求这种提交必须能存进去,不能因此 409;
|
|
142
|
+
// · 提交的就是盘上那份(设置页自动保存每次整表回传,不能天天 409)。
|
|
143
|
+
if (patch.tools && patch.tools.allow !== undefined && !allowShrink) {
|
|
144
|
+
const prevAllow = (Array.isArray(before?.config?.tools?.allow) ? before.config.tools.allow : []).map(String)
|
|
145
|
+
const nextList = patch.tools.allow.map(String)
|
|
146
|
+
const nextSet = new Set(nextList)
|
|
147
|
+
const droppedSet = new Set(droppedTools.map(String))
|
|
148
|
+
const knownSet = knownNowSet
|
|
149
|
+
const gone = prevAllow.filter((n) => !nextSet.has(n) && !droppedSet.has(n) && (!knownSet || knownSet.has(n)))
|
|
150
|
+
if (gone.length) {
|
|
151
|
+
logLine('error', [
|
|
152
|
+
'白名单要收缩,已挡回(没有写盘、也没有换刀):',
|
|
153
|
+
`少了 ${gone.length} 项:${gone.join('、')}`,
|
|
154
|
+
`${prevAllow.length} → ${nextList.length}`,
|
|
155
|
+
'要真删,请带 allowShrink:"confirm" 再提交一次;设置页里亲手删名字会自动带上。',
|
|
156
|
+
], root)
|
|
157
|
+
return send(res, 409, {
|
|
158
|
+
error: `这次提交会把白名单从 ${prevAllow.length} 项缩到 ${nextList.length} 项(少了:${gone.join('、')})。没有保存。确实要删,请带 allowShrink:"confirm" 再提交一次。`,
|
|
159
|
+
shrinking: true,
|
|
160
|
+
removed: gone,
|
|
161
|
+
before: prevAllow.length,
|
|
162
|
+
after: nextList.length,
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
}
|
|
109
166
|
const next = await updateConfig(patch, root)
|
|
110
167
|
const beforeAllow = JSON.stringify(before?.config?.tools?.allow ?? [])
|
|
111
168
|
const nextAllow = JSON.stringify(next?.tools?.allow ?? [])
|
|
169
|
+
// 真的删掉了哪些(D3,issue #191 第九节):带 confirm 放行的那一次也要留下
|
|
170
|
+
// 一条**能事后查的**账。白名单缩水是「她突然少了半只手」这类事故的唯一线索,
|
|
171
|
+
// 过去只记一条 info、而且只有总数——两天后翻日志看不出少了什么。
|
|
172
|
+
let shrankFrom = 0
|
|
173
|
+
let shrankGone = []
|
|
174
|
+
{
|
|
175
|
+
const prev = (Array.isArray(before?.config?.tools?.allow) ? before.config.tools.allow : []).map(String)
|
|
176
|
+
const now = new Set((Array.isArray(next?.tools?.allow) ? next.tools.allow : []).map(String))
|
|
177
|
+
shrankGone = prev.filter((n) => !now.has(n) && (!knownNowSet || knownNowSet.has(n)))
|
|
178
|
+
if (shrankGone.length) shrankFrom = prev.length
|
|
179
|
+
}
|
|
112
180
|
let toolsLive = null
|
|
113
181
|
if (beforeAllow !== nextAllow) {
|
|
114
182
|
try {
|
|
115
183
|
const r = /** @type {any} */ (refreshToolRestrict({ extra: next?.tools?.allow ?? [] }))
|
|
116
184
|
toolsLive = { ok: r?.ok === true, deferred: r?.deferred?.length ?? 0 }
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
185
|
+
const shrunk = shrankGone.length > 0
|
|
186
|
+
const parts = shrunk
|
|
187
|
+
? [
|
|
188
|
+
'白名单被收缩(已按 confirm 放行):',
|
|
189
|
+
`${shrankFrom} → ${(next?.tools?.allow ?? []).length}`,
|
|
190
|
+
`少了 ${shrankGone.join('、')}`,
|
|
191
|
+
]
|
|
192
|
+
: ['tools.allow 已当场生效', `allow=${(next?.tools?.allow ?? []).join(',') || '(空)'}`]
|
|
193
|
+
logLine(shrunk ? 'error' : 'info', [
|
|
194
|
+
...parts,
|
|
120
195
|
`换刀=${r?.applied?.length ?? 0}`,
|
|
121
196
|
r?.deferred?.length ? `延后=${r.deferred.length}` : '',
|
|
122
|
-
], root)
|
|
197
|
+
].filter(Boolean), root)
|
|
123
198
|
} catch (err) {
|
|
124
199
|
logLine('warn', ['白名单热更新没成(下次新建会话照样生效):', String(/** @type {any} */ (err)?.message ?? err).slice(0, 200)], root)
|
|
125
200
|
}
|
package/lib/observe-data.js
CHANGED
|
@@ -240,7 +240,9 @@ export function buildDataRoutes(env) {
|
|
|
240
240
|
|
|
241
241
|
['/move', async (req, res) => {
|
|
242
242
|
if (req.method === 'GET') {
|
|
243
|
-
|
|
243
|
+
// 默认只数文件(快);?full=1 才连大小一起量(issue #184)
|
|
244
|
+
const full = /[?&]full=1(?:&|$)/.test(String(req.url ?? ''))
|
|
245
|
+
const st = await moveStatus(root, { full })
|
|
244
246
|
return send(res, 200, { ...st, canPick: true })
|
|
245
247
|
}
|
|
246
248
|
if (req.method !== 'POST') return send(res, 405, { error: 'method not allowed' })
|
package/lib/observe-home.js
CHANGED
|
@@ -13,6 +13,7 @@ import { timingSafeEqual } from 'node:crypto'
|
|
|
13
13
|
import { fileURLToPath } from 'node:url'
|
|
14
14
|
import { readEvents, paths } from './store.js'
|
|
15
15
|
import { claimBridgeSession, releaseBridgeSession } from './bridgeclaim.js'
|
|
16
|
+
import { setRetiredSessions } from './claim.js'
|
|
16
17
|
import { loadConfig, updateConfig, dateKey } from './settings.js'
|
|
17
18
|
import { selfPronounOf, fillSelf } from './selfpronoun.js'
|
|
18
19
|
import { deriveSelf } from './derive.js'
|
|
@@ -20,11 +21,11 @@ import { wakeNow } from './scheduler.js'
|
|
|
20
21
|
import { sayToHer } from './say.js'
|
|
21
22
|
import { readInbox, markRead, writeInboxFile } from './inbox.js'
|
|
22
23
|
import { avatarFile, avatarInfo, saveAvatar, removeAvatar } from './avatar.js'
|
|
23
|
-
import { describeState } from './reset.js'
|
|
24
|
+
import { describeState, markRetired, retiredSessionIds } from './reset.js'
|
|
24
25
|
import { armPending, attemptPending, cancelPending, clearPending, pendingSummary } from './reset-pending.js'
|
|
25
26
|
import { applyHandover, hasOwnStart, IMPORT_TEMPLATE } from './import.js'
|
|
26
27
|
import { bridgeUrl } from './bridgeserve.js'
|
|
27
|
-
import { readHomeRecord } from './retire.js'
|
|
28
|
+
import { otherHomeSessionIds, readHomeRecord } from './retire.js'
|
|
28
29
|
import { bootstrapHome, homeStatus, wakeIfBlank, rotateTalkSession } from './home.js'
|
|
29
30
|
import { selfDocStatus, refreshSelfDoc } from './selfdoc.js'
|
|
30
31
|
import { ensureDataReadme } from './readme.js'
|
|
@@ -182,7 +183,8 @@ export function buildHomeRoutes(env, bridgeHandlers) {
|
|
|
182
183
|
const url = new URL(req.url ?? '/', 'http://x')
|
|
183
184
|
const limit = Math.min(500, Number(url.searchParams.get('limit') ?? 200) || 200)
|
|
184
185
|
const box = await readInbox(root, { limit })
|
|
185
|
-
|
|
186
|
+
// 2026-12-02(issue #184 第四条):把刚读到的这份传进去,别再读一遍事件流。
|
|
187
|
+
await writeInboxFile(root, { limit: 60, box }).catch(() => null)
|
|
186
188
|
send(res, 200, box)
|
|
187
189
|
}],
|
|
188
190
|
|
|
@@ -344,7 +346,10 @@ export function buildHomeRoutes(env, bridgeHandlers) {
|
|
|
344
346
|
// 旧会话的登记(home.json)就在 root 里,搬走之后读不到了一并记进意向书。
|
|
345
347
|
const home = await readHomeRecord(root)
|
|
346
348
|
const before = await describeState(root)
|
|
347
|
-
|
|
349
|
+
// 2026-12-01(外部反馈):家门口那条之外,群房/私聊房、桥的会话、没认领的会话
|
|
350
|
+
// 也都住着上一局的话。先收 id,写进意向书——搬不成时下次启动也照样归档。
|
|
351
|
+
const extra = await otherHomeSessionIds(root).catch(() => [])
|
|
352
|
+
armPending({ root, expect: before, retire: home, extra })
|
|
348
353
|
const r = /** @type {any} */ (await awayFromBeat(() => attemptPending({
|
|
349
354
|
root,
|
|
350
355
|
ctx,
|
|
@@ -379,6 +384,12 @@ export function buildHomeRoutes(env, bridgeHandlers) {
|
|
|
379
384
|
: { woke: false }
|
|
380
385
|
// 搬完了:意向书收掉(boot 看到 done 也会收,这里收得更早一点)。
|
|
381
386
|
clearPending()
|
|
387
|
+
// 2026-12-01:把旧房间记成「上一局的会话」,并当场灌给认领判据——不用等重启,
|
|
388
|
+
// 桥下一秒拿着老 sessionId 再投也认不回来。归档失败的那几条也记上。
|
|
389
|
+
try {
|
|
390
|
+
await markRetired(root, [...(retired.archived ?? []), ...(retired.failed ?? []), ...extra])
|
|
391
|
+
setRetiredSessions(await retiredSessionIds(root))
|
|
392
|
+
} catch { /* 记不上只影响挡旧会话,不影响这一局已经开好 */ }
|
|
382
393
|
send(res, 200, {
|
|
383
394
|
ok: true,
|
|
384
395
|
movedTo: r.movedTo,
|
package/lib/observe-http.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { spawn } from 'node:child_process'
|
|
10
10
|
import { looksMojibake } from './guard.js'
|
|
11
11
|
import { logLine } from './log.js'
|
|
12
|
+
import { enterLoad, leaveLoad } from './loadgate.js'
|
|
12
13
|
|
|
13
14
|
export const PREFIX = '/dsh-fish'
|
|
14
15
|
|
|
@@ -223,6 +224,8 @@ export function makeGuarded(ctx, root, opts = {}) {
|
|
|
223
224
|
}
|
|
224
225
|
// 只量 handler 自己:信任校验是被挡掉的请求,和「这一页慢」是两件事。
|
|
225
226
|
const t0 = Date.now()
|
|
227
|
+
// 有人在等的时候,后台的重活(稳定指标)让路——见 lib/loadgate.js。
|
|
228
|
+
enterLoad()
|
|
226
229
|
try {
|
|
227
230
|
await handler(req, res)
|
|
228
231
|
} catch (err) {
|
|
@@ -235,6 +238,7 @@ export function makeGuarded(ctx, root, opts = {}) {
|
|
|
235
238
|
], root)
|
|
236
239
|
send(res, code, { error: String(/** @type {any} */ (err)?.message ?? err) })
|
|
237
240
|
} finally {
|
|
241
|
+
leaveLoad()
|
|
238
242
|
const ms = Date.now() - t0
|
|
239
243
|
if (ms >= slowMs) {
|
|
240
244
|
logLine('warn', ['route slow', `${req?.method ?? ''} ${req?.url ?? ''}`.trim(), { ms }], root)
|
package/lib/observe-state.js
CHANGED
|
@@ -15,7 +15,7 @@ import { selfPronounOf, fillSelf } from './selfpronoun.js'
|
|
|
15
15
|
import { deriveSelf, consistency, novelty, gateNeed } from './derive.js'
|
|
16
16
|
import { examine } from './health.js'
|
|
17
17
|
import { countEvents, isNoiseMeta } from './meta.js'
|
|
18
|
-
import {
|
|
18
|
+
import { stabilityLazy, stabilityBand } from './quality.js'
|
|
19
19
|
import { firedLog, CATALOG } from './events.js'
|
|
20
20
|
import { listReports, buildReport } from './report.js'
|
|
21
21
|
import { listWorks, worksSummary, readWorkText, worksDir, WORK_LIST_MAX } from './works.js'
|
|
@@ -148,7 +148,7 @@ export function buildStateRoutes(env) {
|
|
|
148
148
|
}
|
|
149
149
|
})(),
|
|
150
150
|
quality: (() => {
|
|
151
|
-
const st =
|
|
151
|
+
const st = stabilityLazy(events, { growthDays: config.growthDays }, {
|
|
152
152
|
shown: config?.memory?.beliefsShown,
|
|
153
153
|
budget: config?.memory?.docBudget,
|
|
154
154
|
withBans: m?.persona?.imported !== true,
|
|
@@ -170,6 +170,7 @@ export function buildStateRoutes(env) {
|
|
|
170
170
|
// 还可能把默认值写回盘上。加设置项时两边一起加;下面有 guard 测试盯着。
|
|
171
171
|
config: {
|
|
172
172
|
window: config.window,
|
|
173
|
+
windows: config.windows,
|
|
173
174
|
wakesPerDay: config.wakesPerDay,
|
|
174
175
|
daily: config.daily,
|
|
175
176
|
diary: { enabled: config.diary.enabled, visible: config.diary.visible },
|
package/lib/people.js
CHANGED
|
@@ -132,7 +132,9 @@ function atMs(v) {
|
|
|
132
132
|
* 从事件流算出「她认识哪些人」。
|
|
133
133
|
*
|
|
134
134
|
* @param {object[]} events 事件流(`readEvents(root).events`)
|
|
135
|
-
* @param {{ now?: number, max?: number, ownerNames?: string[] }} [opts]
|
|
135
|
+
* @param {{ now?: number, max?: number, ownerNames?: string[], audit?: Array }} [opts]
|
|
136
|
+
* `audit` 是可选的收集器:传一个数组进来,归属上「看着别扭」的条会 push 进去
|
|
137
|
+
* (记忆体检只读展示用,不改变任何挂法)。
|
|
136
138
|
* @returns {Array<{id:string,name:string,nameOnly:boolean,firstAt:number,lastAt:number,
|
|
137
139
|
* times:number,nightTimes:number,spanDays:number,judgmentIds:string[],judged:number,
|
|
138
140
|
* judgments:Array<{id:string,at:number,text:string,guess:boolean,verdict:string|null}>,
|
|
@@ -140,7 +142,7 @@ function atMs(v) {
|
|
|
140
142
|
* said:Array<{at:number,text:string}>,
|
|
141
143
|
* didTo:Array<{at:number,text:string}>}>}
|
|
142
144
|
*/
|
|
143
|
-
export function peopleOf(events = [], { max = PEOPLE_MAX, ownerNames = [] } = {}) {
|
|
145
|
+
export function peopleOf(events = [], { max = PEOPLE_MAX, ownerNames = [], audit = null } = {}) {
|
|
144
146
|
const list = Array.isArray(events) ? events : []
|
|
145
147
|
const byId = new Map()
|
|
146
148
|
for (const e of list) {
|
|
@@ -290,6 +292,25 @@ export function peopleOf(events = [], { max = PEOPLE_MAX, ownerNames = [] } = {}
|
|
|
290
292
|
const set = byName.get(String(name ?? '').trim())
|
|
291
293
|
return set && set.size === 1 ? [...set][0] : ''
|
|
292
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* 一段话里点名了哪些人,**连同命中的那个叫法**(取最长的那个)。
|
|
297
|
+
*
|
|
298
|
+
* 2026-12-01(用户 m01484):单字名(「猫」「鱼」)和普通词天然分不开——「猫粮」「鱼丸」
|
|
299
|
+
* 都会命中。下面的两处判断按叫法长度分档:两个字以上才算「点名」,单字只当弱线索。
|
|
300
|
+
*
|
|
301
|
+
* @returns {Map<string, string>} id → 命中的叫法
|
|
302
|
+
*/
|
|
303
|
+
const namedHits = (s) => {
|
|
304
|
+
const out = new Map()
|
|
305
|
+
for (const [name, set] of byName) {
|
|
306
|
+
if (!name || !s.includes(name)) continue
|
|
307
|
+
for (const id of set) {
|
|
308
|
+
const prev = out.get(id) || ''
|
|
309
|
+
if (name.length > prev.length) out.set(id, name)
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return out
|
|
313
|
+
}
|
|
293
314
|
for (const p of people.values()) if (p.name) addName(p.name, p.id)
|
|
294
315
|
// 登记时添的小名也走同一张表:`person_alias` 的别名绑在具体 id 上,不设全局别名表。
|
|
295
316
|
for (const { pid, alias } of aliasPairs) {
|
|
@@ -341,6 +362,33 @@ export function peopleOf(events = [], { max = PEOPLE_MAX, ownerNames = [] } = {}
|
|
|
341
362
|
let id = ''
|
|
342
363
|
const about = fold(normalizePid(e?.about))
|
|
343
364
|
if (about && people.has(about)) id = about
|
|
365
|
+
// 2026-12-01(用户转来真机截图):`about` 排第一、又不看正文,填错一次就静默挂错人。
|
|
366
|
+
// 起因是 `her_person` 记下人之后的回执写着「以后写判断时 about 填 p_…」,她当成通用要求,
|
|
367
|
+
// 于是讲主人的判断也填了那位朋友的编号——星图上就长出七根连错的线。
|
|
368
|
+
//
|
|
369
|
+
// 窄闸:正文里**点名了另一个**认识的人、而**没点 `about` 这个人**时,不信 `about`,
|
|
370
|
+
// 清空后照下面的 `who` / `topic` / `refs` 重算。撑不住的时候宁可不挂(漏挂看得见,
|
|
371
|
+
// 挂错看不见)。正文一个名字都没提、或同时提了两个人时不拦——那种时候 `about`
|
|
372
|
+
// 仍是唯一能说清是哪一个的信息。
|
|
373
|
+
//
|
|
374
|
+
// 2026-12-01(用户 m01484):单字名不参与这道闸。「猫粮」「鱼丸」这种词天天都有,
|
|
375
|
+
// 拿单字名当「点名」只会把正确的 `about` 误清掉——那次「猫今天很黏人」就因为
|
|
376
|
+
// 这个整条判断脱了钩。两个字以上的名字才算点名。
|
|
377
|
+
if (id) {
|
|
378
|
+
const named = [...namedHits(text)].filter(([, n]) => n.length >= 2).map(([pid]) => pid)
|
|
379
|
+
if (named.length === 1 && named[0] !== id) id = ''
|
|
380
|
+
}
|
|
381
|
+
// 2026-12-01(用户 m01484):单字名和普通词分不开,`about` 在它附近最不可靠。
|
|
382
|
+
// 正文点到单字名、而 `who` / `topic` 明确指向另一个人时,让那两样压过 `about`——
|
|
383
|
+
// 「我给猫倒猫粮」至少还能靠 topic 挂到猫身上,而不是挂到 `about` 里那位。
|
|
384
|
+
// 只在 `about` 指向的不是这个单字名的人时生效(他就是猫的时候没有歧义)。
|
|
385
|
+
if (id) {
|
|
386
|
+
const single = [...namedHits(text)].some(([, n]) => n.length === 1)
|
|
387
|
+
if (single && String(people.get(id)?.name ?? '').length >= 2) {
|
|
388
|
+
const alt = fold(personKeyOf(e?.who)) || nameId(String(e?.topic ?? '').trim())
|
|
389
|
+
if (alt && alt !== id && people.has(alt)) id = alt
|
|
390
|
+
}
|
|
391
|
+
}
|
|
344
392
|
if (!id) {
|
|
345
393
|
const whoKey = personKeyOf(e?.who)
|
|
346
394
|
if (whoKey) id = fold(whoKey)
|
|
@@ -377,6 +425,34 @@ export function peopleOf(events = [], { max = PEOPLE_MAX, ownerNames = [] } = {}
|
|
|
377
425
|
}
|
|
378
426
|
if (id === OWNER && !people.has(id)) person(OWNER)
|
|
379
427
|
if (!id || !people.has(id)) continue
|
|
428
|
+
// 2026-12-01(用户 m01484):记忆体检要一份「归属看着别扭」的只读清单。
|
|
429
|
+
// 只收**已经挂在这个人身上**的——被窄闸改挂过的那些,图上已经不在原处,不用再报。
|
|
430
|
+
// 不判断对错、不改任何挂法,`audit` 是调用方传进来的收集器。
|
|
431
|
+
if (Array.isArray(audit) && about && people.has(about) && id === about) {
|
|
432
|
+
const aboutName = String(people.get(about)?.name ?? '')
|
|
433
|
+
const otherName = (pid) => String(people.get(pid)?.name ?? pid)
|
|
434
|
+
const whoKey = fold(personKeyOf(e?.who))
|
|
435
|
+
if (whoKey && whoKey !== about && people.has(whoKey)) {
|
|
436
|
+
audit.push({
|
|
437
|
+
id: String(e.id ?? ''), text: text.slice(0, 80), person: aboutName || otherName(about),
|
|
438
|
+
other: otherName(whoKey), why: 'about 指的是这个人,但这句话的 who 是另一个人',
|
|
439
|
+
})
|
|
440
|
+
}
|
|
441
|
+
const topicId = nameId(String(e?.topic ?? '').trim())
|
|
442
|
+
if (topicId && topicId !== about) {
|
|
443
|
+
audit.push({
|
|
444
|
+
id: String(e.id ?? ''), text: text.slice(0, 80), person: aboutName || otherName(about),
|
|
445
|
+
other: otherName(topicId), why: 'about 指的是这个人,topic 写的却是另一个人',
|
|
446
|
+
})
|
|
447
|
+
}
|
|
448
|
+
const hits = [...namedHits(text)].filter(([, n]) => n.length >= 2).map(([pid]) => pid)
|
|
449
|
+
if (hits.length && !hits.includes(about) && aboutName && !text.includes(aboutName)) {
|
|
450
|
+
audit.push({
|
|
451
|
+
id: String(e.id ?? ''), text: text.slice(0, 80), person: aboutName,
|
|
452
|
+
other: otherName(hits[0]), why: '正文点名了另一个人,没点 about 指的这个人',
|
|
453
|
+
})
|
|
454
|
+
}
|
|
455
|
+
}
|
|
380
456
|
ownerOf.set(String(e.id ?? ''), id)
|
|
381
457
|
people.get(id).judgments.push({
|
|
382
458
|
id: String(e.id ?? ''),
|
package/lib/persona.js
CHANGED
|
@@ -605,11 +605,16 @@ export function buildSections(model, opts = {}) {
|
|
|
605
605
|
// 手上那件没弄完的(1.0.5,用户 m01433)。只写一句事实:不写第几版、不催、
|
|
606
606
|
// 不说「你该把它弄完」。没有没弄完的东西时这一句不出现——早期阶段她本来就
|
|
607
607
|
// 可能一件都没有,那是正常状态,不是缺一项。
|
|
608
|
+
// issue #190(2026-12-01):标题是那件东西的名字,不是她做过的事的名字。
|
|
609
|
+
// 只给标题时她会把「排了九帧」压成「折了剑」,所以把她当时写的那句
|
|
610
|
+
// 「想做成什么样」接着摆一小段(她自己写的原话,不缩写意思、不加评价)。
|
|
608
611
|
const wipWork = opts.works?.wip
|
|
609
612
|
if (wipWork?.title) {
|
|
613
|
+
const aim = clipText(String(wipWork.intent ?? ''), 24, '…')
|
|
614
|
+
const more = aim ? `你当时想做成的是「${aim}」。` : ''
|
|
610
615
|
days.push(wipWork.stale
|
|
611
|
-
? `你手上还有一件《${wipWork.title}
|
|
612
|
-
: `你上次弄的是《${wipWork.title}
|
|
616
|
+
? `你手上还有一件《${wipWork.title}》,有些天没动了。${more}`
|
|
617
|
+
: `你上次弄的是《${wipWork.title}》,还没弄完。${more}`)
|
|
613
618
|
}
|
|
614
619
|
if (days.length) push(['## 这些天', ...days].join('\n'), true, { id: 'days' })
|
|
615
620
|
|
|
@@ -1055,7 +1060,7 @@ export function toolBrief(extra = [], { restricted = true } = {}) {
|
|
|
1055
1060
|
'想细看谁就翻 her_people:你对这个人写过什么、这个人说过什么、你拒绝过什么。不给名字会回一份名单。',
|
|
1056
1061
|
// 1.1.4(issue #183):光有「翻」不够——他提过的人、你读到的人,得先有个地方记下来,
|
|
1057
1062
|
// 你写的判断才挂得到具体的人身上。处境写在前面。
|
|
1058
|
-
'哪天你把一个人从「大家」里分出来了——{T}
|
|
1063
|
+
'哪天你把一个人从「大家」里分出来了——{T}提过的朋友、你读到的作者、书里或视频里的人、群里那个人——就用 her_person 记下来:叫什么、是哪一种人、一句话说清这是谁。',
|
|
1059
1064
|
// 2026-10-29(用户 m01581,真机):原来是「上面这几样是你自己的屋子里的东西」。
|
|
1060
1065
|
// 这份文档会被出门那条会话原样带走,而那句话把工具和屋子黏在了一起——她据此
|
|
1061
1066
|
// 判定 growth_commit 属于屋子、出门这趟不该碰,于是拒绝写(整趟 0 条事件)。
|
package/lib/proactive.js
CHANGED
|
@@ -31,6 +31,7 @@ import { deriveSelf } from './derive.js'
|
|
|
31
31
|
import { toolArrived } from './wish.js'
|
|
32
32
|
import { doneAsksOf } from './ask.js'
|
|
33
33
|
import { fillOwner } from './pronoun.js'
|
|
34
|
+
import { clipText } from './clip.js'
|
|
34
35
|
|
|
35
36
|
/** 一天的默认上限。 */
|
|
36
37
|
export const PROACTIVE_DEFAULTS = Object.freeze({
|
|
@@ -303,8 +304,10 @@ export function proactiveState({ config = {}, events = [], now = Date.now(), awa
|
|
|
303
304
|
if (!cfg.enabled) return { ...base, ok: false, why: '主动说话是关着的' }
|
|
304
305
|
// 只在醒着的时间窗里:凌晨三点收到一句「我想你了」不是她自主,是她打乱了作息。
|
|
305
306
|
// 配置里没有 window 时(测试/老数据)不拦,保持纯函数可测。
|
|
306
|
-
|
|
307
|
-
|
|
307
|
+
// 多段(2026-11-30):任意一段命中都算醒着;只看第一段会把中午那一次醒判成「不在时段里」。
|
|
308
|
+
const hasWindow = Array.isArray(config?.windows)
|
|
309
|
+
|| (Array.isArray(config?.window) && config.window.length === 2)
|
|
310
|
+
if (hasWindow && !inWindow(config, new Date(now))) return { ...base, ok: false, why: '这个点不在她醒着的时段里' }
|
|
308
311
|
if (away?.kind) return { ...base, ok: false, why: '她不在家' }
|
|
309
312
|
if (rested) return { ...base, ok: false, why: '她今天请了假' }
|
|
310
313
|
if (turnsToday(events, dk) >= cfg.maxPerDay) return { ...base, ok: false, why: '今天已经到上限' }
|
|
@@ -448,10 +451,14 @@ export function proactiveSection({ now = Date.now(), state = {}, material = [],
|
|
|
448
451
|
// 只摆事实:不写第几版、不催、不说该做完了。
|
|
449
452
|
const wipTitle = String(works?.wip?.title ?? '').trim()
|
|
450
453
|
if (wipTitle) {
|
|
454
|
+
// issue #190:动手回合里也一样,名字之外要有她自己写的那句「想做成什么样」,
|
|
455
|
+
// 不然她接上的只是「一个叫面包剑的东西」,接下来会去改一把不存在的剑。
|
|
456
|
+
const aim = clipText(String(works?.wip?.intent ?? ''), 24, '…')
|
|
451
457
|
lines.push(
|
|
452
|
-
works?.wip?.stale
|
|
458
|
+
(works?.wip?.stale
|
|
453
459
|
? `你手上还有一件《${wipTitle}》,有些天没动了。`
|
|
454
|
-
: `你手上还有一件《${wipTitle}
|
|
460
|
+
: `你手上还有一件《${wipTitle}》,是你自己弄了一半的。`)
|
|
461
|
+
+ (aim ? `你当时想做成的是「${aim}」。` : ''),
|
|
455
462
|
)
|
|
456
463
|
}
|
|
457
464
|
// 2026-11-06(issue #41):原来写「他看得见」。宿主装了什么路由插件,这句就不一定成立
|