@ssamurias/dsh-fish 0.9.9 → 1.0.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/AGENTS.md +61 -24
- package/CHANGELOG.md +615 -392
- package/README.md +123 -165
- package/RELEASE-NOTES-0.8.3.md +71 -71
- package/RELEASE-NOTES-0.9.9.md +25 -53
- package/RELEASE-NOTES-1.0.0.md +196 -0
- package/RELEASE-NOTES-1.0.1.md +363 -0
- package/THIRD-PARTY-NOTICES.md +13 -3
- package/lib/appoint.js +5 -4
- package/lib/ask.js +4 -3
- package/lib/at.js +8 -7
- package/lib/autobackup.js +384 -0
- package/lib/backup.js +27 -4
- package/lib/bili.js +133 -22
- package/lib/browse.js +51 -18
- package/lib/capture.js +28 -4
- package/lib/client.js +1231 -317
- package/lib/cloudbackup.js +351 -0
- package/lib/cloudcrypto.js +161 -0
- package/lib/clouddrive.js +587 -0
- package/lib/cloudsmtp.js +331 -0
- package/lib/cloudtargets.js +227 -0
- package/lib/comment.js +28 -10
- package/lib/compact.js +36 -8
- package/lib/contract.js +266 -0
- package/lib/curiosity.js +3 -2
- package/lib/deliver.js +6 -3
- package/lib/derive.js +152 -7
- package/lib/desk.js +1 -1
- package/lib/doing.js +316 -0
- package/lib/events.js +79 -31
- package/lib/firstwake.js +74 -0
- package/lib/generator.js +35 -4
- package/lib/guard.js +184 -184
- package/lib/health.js +36 -0
- package/lib/home.js +49 -2
- package/lib/hook.js +1 -1
- package/lib/identity.js +451 -36
- package/lib/import.js +302 -302
- package/lib/index.js +18 -2
- package/lib/intent.js +5 -3
- package/lib/keep.js +3 -2
- package/lib/keepsake.js +3 -2
- package/lib/letter.js +3 -3
- package/lib/look.js +52 -4
- package/lib/material.js +69 -2
- package/lib/note.js +193 -36
- package/lib/observe.js +366 -37
- package/lib/persona.js +240 -93
- package/lib/pocket.js +2 -2
- package/lib/proactive.js +19 -11
- package/lib/pronoun.js +75 -35
- package/lib/pronounask.js +11 -2
- package/lib/quality.js +1 -1
- package/lib/readme.js +1 -1
- package/lib/recall.js +207 -27
- package/lib/report.js +14 -7
- package/lib/restrict.js +27 -1
- package/lib/say.js +14 -13
- package/lib/scheduler.js +255 -35
- package/lib/schema.js +24 -0
- package/lib/selfcheck.js +13 -1
- package/lib/selfdoc.js +19 -8
- package/lib/selfpronoun.js +112 -0
- package/lib/sessionnote.js +44 -0
- package/lib/settings.js +149 -4
- package/lib/sources.js +99 -0
- package/lib/speak.js +1 -1
- package/lib/speechanchor.js +132 -0
- package/lib/stance.js +4 -3
- package/lib/status.js +16 -8
- package/lib/sub.js +424 -0
- package/lib/talkmem.js +3 -2
- package/lib/turnexport.js +123 -0
- package/lib/turns.js +70 -24
- package/lib/use.js +21 -1
- package/lib/voices.js +24 -1
- package/lib/wish.js +3 -2
- package/media/principle-drive.svg +131 -0
- package/media/principle-loop.svg +3 -3
- package/media/principle-memory.svg +1 -1
- package/package.json +3 -3
- package/tools/check-install.mjs +237 -0
- package/RELEASE.md +0 -154
- package/media/principle-loop-2x.png +0 -0
- package/media/principle-memory-2x.png +0 -0
package/lib/doing.js
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* doing.js —— 主动做事(2026-11-14,用户 m01237 定案)
|
|
3
|
+
*
|
|
4
|
+
* 她可以不只是开口,也可以自己动手做一件事。这里只做三件事:
|
|
5
|
+
* 1. 判断「这一轮算不算动手回合」(scheduler 在投递前打标记);
|
|
6
|
+
* 2. 在动手回合里给消耗类工具上闸:一轮一件、一天一件、同一件隔三天、
|
|
7
|
+
* 连着三次同类歇一周;
|
|
8
|
+
* 3. 把真的做成的事记成 `did:`(只认工具真的返回了,不认她嘴上说做了)。
|
|
9
|
+
*
|
|
10
|
+
* 三条边界:
|
|
11
|
+
* - 分类不靠工具名猜。自家工具写死;外面的工具默认 effect(不拦、也不自动
|
|
12
|
+
* 当消耗类摆上桌),用户可以在设置里改。宿主只把工具名给插件,看不到
|
|
13
|
+
* 工具定义,所以没有「按声明自动识别」这回事——说清楚比猜一个强。
|
|
14
|
+
* - 只在动手回合生效。他自己找她说话、定时叫醒,都不经过这里。
|
|
15
|
+
* - 数字只在插件内部用,不进她的身份文档,也不回显给她。
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { tsMs } from './schema.js'
|
|
19
|
+
import { appendEvent, readEvents } from './store.js'
|
|
20
|
+
import { loadConfig } from './settings.js'
|
|
21
|
+
|
|
22
|
+
export const DOING_DEFAULTS = Object.freeze({
|
|
23
|
+
enabled: false,
|
|
24
|
+
consumePerDay: 1,
|
|
25
|
+
itemCooldownDays: 3,
|
|
26
|
+
bingeLimit: 3,
|
|
27
|
+
bingeRestDays: 7,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
export const DOING_CLASSES = Object.freeze(['produce', 'consume', 'effect', 'self'])
|
|
31
|
+
|
|
32
|
+
/** 自家工具的分类。read_image 也算「看」,按消耗类算。 */
|
|
33
|
+
export const OWN_CLASS = Object.freeze({
|
|
34
|
+
bili_look: 'consume',
|
|
35
|
+
bili_watch: 'consume',
|
|
36
|
+
bili_sub: 'consume',
|
|
37
|
+
read_image: 'consume',
|
|
38
|
+
her_diary: 'produce',
|
|
39
|
+
bili_speak: 'effect',
|
|
40
|
+
her_leave: 'effect',
|
|
41
|
+
bring_back: 'effect',
|
|
42
|
+
growth_commit: 'self',
|
|
43
|
+
her_recall: 'self',
|
|
44
|
+
her_note: 'self',
|
|
45
|
+
her_appoint: 'self',
|
|
46
|
+
her_dream: 'self',
|
|
47
|
+
her_say: 'self',
|
|
48
|
+
ask_owner: 'self',
|
|
49
|
+
ask_pronoun: 'self',
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const MARK_MS = 2 * 3600_000
|
|
53
|
+
const DID = 'did:'
|
|
54
|
+
|
|
55
|
+
/** 动手回合的标记只存在进程里;按会话分开,重启后没有标记也就不会误拦。 */
|
|
56
|
+
const turns = new Map()
|
|
57
|
+
|
|
58
|
+
function prune(now) {
|
|
59
|
+
for (const [sid, t] of turns) if (now - t.at > MARK_MS) turns.delete(sid)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function num(v, fallback, lo, hi) {
|
|
63
|
+
const n = Number(v)
|
|
64
|
+
if (!Number.isFinite(n)) return fallback
|
|
65
|
+
return Math.max(lo, Math.min(hi, Math.round(n)))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** 读设置。键都在 config.proactive 下,和「主动搭话」共用一张卡。 */
|
|
69
|
+
export function doingConfig(config = {}) {
|
|
70
|
+
const raw = config && typeof config.proactive === 'object' && config.proactive ? config.proactive : {}
|
|
71
|
+
return {
|
|
72
|
+
enabled: raw.allowDoing === true,
|
|
73
|
+
consumePerDay: num(raw.consumePerDay, DOING_DEFAULTS.consumePerDay, 0, 6),
|
|
74
|
+
itemCooldownDays: num(raw.itemCooldownDays, DOING_DEFAULTS.itemCooldownDays, 0, 30),
|
|
75
|
+
bingeLimit: num(raw.bingeLimit, DOING_DEFAULTS.bingeLimit, 2, 10),
|
|
76
|
+
bingeRestDays: num(raw.bingeRestDays, DOING_DEFAULTS.bingeRestDays, 1, 60),
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** 工具分类:设置里的覆盖优先,其次自家表,最后按 effect(不拦、不自动摆上桌)。 */
|
|
81
|
+
export function classOf(name, config = {}) {
|
|
82
|
+
const n = String(name ?? '').trim()
|
|
83
|
+
if (!n) return 'effect'
|
|
84
|
+
const over = config?.proactive?.toolClasses
|
|
85
|
+
if (over && typeof over === 'object' && DOING_CLASSES.includes(over[n])) return over[n]
|
|
86
|
+
return OWN_CLASS[n] ?? 'effect'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** 同一件事的键:优先 bvid/id/path,其次 query,最后退回工具名。 */
|
|
90
|
+
export function itemKey(name, args) {
|
|
91
|
+
const tool = String(name ?? '').trim() || 'tool'
|
|
92
|
+
let a = args
|
|
93
|
+
if (typeof a === 'string') {
|
|
94
|
+
try { a = JSON.parse(a) } catch { a = null }
|
|
95
|
+
}
|
|
96
|
+
if (!a || typeof a !== 'object') return tool
|
|
97
|
+
for (const k of ['bvid', 'id', 'path', 'file', 'query', 'keyword', 'title', 'name']) {
|
|
98
|
+
const v = a[k]
|
|
99
|
+
if (typeof v === 'string' && v.trim()) return `${tool}:${v.trim().slice(0, 60)}`
|
|
100
|
+
}
|
|
101
|
+
return tool
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function didText({ cls, tool, ok, key }) {
|
|
105
|
+
return `${DID}${cls}:${tool}:${ok ? 'ok' : 'fail'}:${key}`
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** `did:<cls>:<tool>:ok|fail:<key>`;key 放最后,路径里的冒号不会被切开。 */
|
|
109
|
+
export function parseDid(text) {
|
|
110
|
+
const s = String(text ?? '')
|
|
111
|
+
if (!s.startsWith(DID)) return null
|
|
112
|
+
const rest = s.slice(DID.length).split(':')
|
|
113
|
+
if (rest.length < 4) return null
|
|
114
|
+
const [cls, tool, flag, ...key] = rest
|
|
115
|
+
if (!DOING_CLASSES.includes(cls)) return null
|
|
116
|
+
return { cls, tool, ok: flag === 'ok', key: key.join(':') }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function didOf(events = []) {
|
|
120
|
+
const out = []
|
|
121
|
+
for (const e of events) {
|
|
122
|
+
if (e?.type !== 'meta') continue
|
|
123
|
+
const d = parseDid(e.text)
|
|
124
|
+
if (!d) continue
|
|
125
|
+
out.push({ ...d, ts: tsMs(e) || 0 })
|
|
126
|
+
}
|
|
127
|
+
return out.sort((a, b) => a.ts - b.ts)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function localDay(ms) {
|
|
131
|
+
const d = new Date(ms)
|
|
132
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function startOfLocalDay(ms) {
|
|
136
|
+
const d = new Date(ms)
|
|
137
|
+
d.setHours(0, 0, 0, 0)
|
|
138
|
+
return d.getTime()
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 今天/最近做过什么。只数真的成功了的(ok)。
|
|
143
|
+
* @returns {{consumeToday:number, byClass:Object, last:Array, lastAt:number}}
|
|
144
|
+
*/
|
|
145
|
+
export function doingUsage(events = [], now = Date.now()) {
|
|
146
|
+
const all = didOf(events).filter((d) => d.ok)
|
|
147
|
+
const consumeToday = all.filter((d) => d.cls === 'consume' && d.ts >= startOfLocalDay(now)).length
|
|
148
|
+
const byClass = { produce: 0, consume: 0, effect: 0, self: 0 }
|
|
149
|
+
for (const d of all) byClass[d.cls] = (byClass[d.cls] ?? 0) + 1
|
|
150
|
+
return { consumeToday, byClass, last: all.slice(-6), lastAt: all.length ? all[all.length - 1].ts : 0 }
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 消耗类调用能不能放行。只看消耗类;产出/外效/自己的事不设日限。
|
|
155
|
+
* @returns {{ok:true, cls:string, key:string} | {ok:false, reason:string, code:string}}
|
|
156
|
+
*/
|
|
157
|
+
export function checkDoing({ name, args, events = [], now = Date.now(), config = {} } = {}) {
|
|
158
|
+
const cfg = doingConfig(config)
|
|
159
|
+
const cls = classOf(name, config)
|
|
160
|
+
const key = itemKey(name, args)
|
|
161
|
+
const all = didOf(events).filter((d) => d.ok)
|
|
162
|
+
|
|
163
|
+
if (cfg.consumePerDay <= 0) {
|
|
164
|
+
return { ok: false, code: 'off', reason: '今天不做这样的事了。' }
|
|
165
|
+
}
|
|
166
|
+
const today = all.filter((d) => d.cls === 'consume' && d.ts >= startOfLocalDay(now)).length
|
|
167
|
+
if (today >= cfg.consumePerDay) {
|
|
168
|
+
return { ok: false, code: 'daily', reason: '今天已经做过这样的事了,明天再说。' }
|
|
169
|
+
}
|
|
170
|
+
const same = all.filter((d) => d.key === key && now - d.ts < cfg.itemCooldownDays * 86400_000)
|
|
171
|
+
if (same.length) {
|
|
172
|
+
return { ok: false, code: 'item', reason: '这件事前几天刚做过,过几天再说。' }
|
|
173
|
+
}
|
|
174
|
+
const tail = all.slice(-cfg.bingeLimit)
|
|
175
|
+
if (tail.length >= cfg.bingeLimit && tail.every((d) => d.cls === 'consume')) {
|
|
176
|
+
const last = tail[tail.length - 1].ts
|
|
177
|
+
if (now - last < cfg.bingeRestDays * 86400_000) {
|
|
178
|
+
return { ok: false, code: 'binge', reason: '连着做了几次,先歇几天。' }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return { ok: true, cls, key }
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** 这一轮是不是动手回合。会话对不上或超过两小时就当没有。 */
|
|
185
|
+
export function doingTurnOf(sessionId, now = Date.now()) {
|
|
186
|
+
const sid = String(sessionId ?? '')
|
|
187
|
+
if (!sid) return null
|
|
188
|
+
prune(now)
|
|
189
|
+
return turns.get(sid) ?? null
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function markDoingTurn(sessionId, now = Date.now()) {
|
|
193
|
+
if (!sessionId) return null
|
|
194
|
+
prune(now)
|
|
195
|
+
const t = { sessionId: String(sessionId), at: now, consumeUsed: false, calls: new Map() }
|
|
196
|
+
turns.set(t.sessionId, t)
|
|
197
|
+
return t
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function clearDoingTurn(sessionId) {
|
|
201
|
+
if (sessionId) turns.delete(String(sessionId))
|
|
202
|
+
else turns.clear()
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* 她自己的记录里点到过哪件手边的工具。
|
|
207
|
+
*
|
|
208
|
+
* 只认「记录原文里出现了工具名」的;不列全量工具清单——那是菜单,会把
|
|
209
|
+
* 处境变成派活。没点到就一个都不提。
|
|
210
|
+
*/
|
|
211
|
+
export function mentionedTools(records = [], tools = []) {
|
|
212
|
+
const names = (Array.isArray(tools) ? tools : []).map((t) => String(t ?? '').trim()).filter(Boolean)
|
|
213
|
+
const said = (Array.isArray(records) ? records : []).map((m) => String(m?.text ?? '')).join('\n').toLowerCase()
|
|
214
|
+
if (!names.length || !said) return []
|
|
215
|
+
return names.filter((n) => {
|
|
216
|
+
const esc = n.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
217
|
+
return new RegExp(`(^|[^a-z0-9_])${esc}($|[^a-z0-9_])`).test(said)
|
|
218
|
+
}).slice(0, 3)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** 给处境用的那一句。只给许可和边界,不写「你应该做点什么」。 */
|
|
222
|
+
export function doingSection({ material = [], loose = [], tools = [], notes = [] } = {}) {
|
|
223
|
+
const hinted = mentionedTools([...material, ...loose], tools)
|
|
224
|
+
const lead = hinted.length ? `你之前提过 ${hinted.join('、')},它们就在手边。` : ''
|
|
225
|
+
// 便条只作她自己的材料:不写「到期」「该做了」,最多两张,不列清单。
|
|
226
|
+
const own = (Array.isArray(notes) ? notes : [])
|
|
227
|
+
.map((n) => String(n?.text ?? '').trim())
|
|
228
|
+
.filter(Boolean)
|
|
229
|
+
.slice(0, 2)
|
|
230
|
+
.map((t) => (t.length > 40 ? `${t.slice(0, 40)}…` : t))
|
|
231
|
+
const mine = own.length ? `你自己记下的:${own.join(';')}。` : ''
|
|
232
|
+
return `${lead}${mine}这一轮是动手的:想做的那件事,如果手边有工具能做,就直接做,不用先把这件事说出来。手边有什么、各自能做什么,这一轮你看得到;没有对得上的,就照旧。做一件就收,不用接着做第二件;没有能做的,就什么都不做,也不用写解释。`
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function sessionOf(exec) {
|
|
236
|
+
const s = exec?.agent?.session
|
|
237
|
+
if (typeof s === 'string') return s
|
|
238
|
+
return String(s?.id ?? exec?.agent?.sessionId ?? exec?.session?.id ?? exec?.sessionId ?? '')
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function argsOf(exec) {
|
|
242
|
+
const a = exec?.args ?? exec?.arguments ?? exec?.call?.arguments ?? null
|
|
243
|
+
if (typeof a === 'string') {
|
|
244
|
+
try { return JSON.parse(a) } catch { return null }
|
|
245
|
+
}
|
|
246
|
+
return a
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 注册两个观察点。pre-execute 负责拦,result 负责记账。
|
|
251
|
+
* 拿不到会话、不是动手回合、开关关着,一律 `next()` 放行——这里不是权限层。
|
|
252
|
+
*/
|
|
253
|
+
export function registerDoingHooks(ctx, { root, log = () => {} } = {}) {
|
|
254
|
+
if (!ctx?.on) return () => {}
|
|
255
|
+
const offs = []
|
|
256
|
+
|
|
257
|
+
offs.push(ctx.on('tools/pre-execute', async (exec, next) => {
|
|
258
|
+
try {
|
|
259
|
+
const t = doingTurnOf(sessionOf(exec))
|
|
260
|
+
if (!t) return next()
|
|
261
|
+
const { config } = await loadConfig(root)
|
|
262
|
+
if (!doingConfig(config).enabled) return next()
|
|
263
|
+
const cls = classOf(exec?.name, config)
|
|
264
|
+
const key = itemKey(exec?.name, argsOf(exec))
|
|
265
|
+
const ref = String(exec?.callId ?? exec?.token ?? `${exec?.name}:${Date.now()}`)
|
|
266
|
+
// 消耗类之外也记一笔,好让 result 知道该写 did;但不拦。
|
|
267
|
+
if (cls === 'self') return next()
|
|
268
|
+
if (cls !== 'consume') {
|
|
269
|
+
t.calls.set(ref, { cls, tool: String(exec?.name ?? ''), key })
|
|
270
|
+
return next()
|
|
271
|
+
}
|
|
272
|
+
if (t.consumeUsed) {
|
|
273
|
+
return { kind: 'deny', reason: '这一轮已经做过一件了,做完就收。', info: { name: 'DoingLimit', code: 'DOING_TURN' } }
|
|
274
|
+
}
|
|
275
|
+
const { events } = await readEvents(root)
|
|
276
|
+
const verdict = checkDoing({ name: exec?.name, args: argsOf(exec), events, now: Date.now(), config })
|
|
277
|
+
if (!verdict.ok) {
|
|
278
|
+
log('doing', `拦下一次 ${exec?.name}:${verdict.code}`)
|
|
279
|
+
return { kind: 'deny', reason: verdict.reason, info: { name: 'DoingLimit', code: verdict.code.toUpperCase() } }
|
|
280
|
+
}
|
|
281
|
+
t.consumeUsed = true
|
|
282
|
+
t.calls.set(ref, { cls, tool: String(exec?.name ?? ''), key })
|
|
283
|
+
return next()
|
|
284
|
+
} catch {
|
|
285
|
+
return next()
|
|
286
|
+
}
|
|
287
|
+
}))
|
|
288
|
+
|
|
289
|
+
offs.push(ctx.on('tools/result', async (exec, result) => {
|
|
290
|
+
try {
|
|
291
|
+
const t = doingTurnOf(sessionOf(exec))
|
|
292
|
+
if (!t) return
|
|
293
|
+
const ref = String(exec?.callId ?? exec?.token ?? '')
|
|
294
|
+
let call = t.calls.get(ref)
|
|
295
|
+
if (!call && t.calls.size === 1) call = [...t.calls.values()][0]
|
|
296
|
+
if (!call) return
|
|
297
|
+
t.calls.delete(ref)
|
|
298
|
+
const ok = !(result?.isError === true || result?.ok === false)
|
|
299
|
+
await appendEvent(
|
|
300
|
+
{ type: 'meta', text: didText({ cls: call.cls, tool: call.tool, ok, key: call.key }) },
|
|
301
|
+
{ day: 0, stage: 1, source: 'system' },
|
|
302
|
+
root,
|
|
303
|
+
).catch(() => {})
|
|
304
|
+
log('doing', `记下 ${call.tool} ${ok ? '做成' : '没做成'}`)
|
|
305
|
+
} catch { /* 观察点不改变调用结果 */ }
|
|
306
|
+
}))
|
|
307
|
+
|
|
308
|
+
return () => {
|
|
309
|
+
for (const off of offs) {
|
|
310
|
+
try {
|
|
311
|
+
if (typeof off === 'function') off()
|
|
312
|
+
else off?.off?.()
|
|
313
|
+
} catch { /* ignore */ }
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
package/lib/events.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { similarity, DAY_MS } from './derive.js'
|
|
17
|
+
import { fillOwner } from './pronoun.js'
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* `at` 那一刻在 `now` 的几个**本地日历日**之前:同一天 0,昨天 1。
|
|
@@ -51,7 +52,7 @@ const nowOf = (ctx) => Number(ctx?.now) || Date.now()
|
|
|
51
52
|
// 而她的汇报本来就是最容易退化成复述的地方。删掉「别写成感觉」:要防的是空话,
|
|
52
53
|
// 不是感受;「判断要能被核对」留着,那是能被检验的唯一门槛。
|
|
53
54
|
const NOTICE_VARIANTS = [
|
|
54
|
-
() =>
|
|
55
|
+
() => `这几天有一句话还在你脑子里——可能是{T}说的,也可能是评论里读到的。你心里大概已经有个判断了。先说那个判断:它是什么。再说清它凭什么:那句话是谁说的、大概怎么说的。判断要能被核对。`,
|
|
55
56
|
() => `如果让你指出这几天真看见的一件小事——先别描述它,先说你的判断:这件事说明什么。说完再交代它从哪来:在哪儿看到的、谁说的、原话大概是什么。判断要能被拿去核对。`,
|
|
56
57
|
() => `有没有一件事,小到不值得说,但你反复想过?先说你现在怎么看它——一句话。然后才说那是什么事、为什么它老回来。判断要能被核对。`,
|
|
57
58
|
]
|
|
@@ -76,7 +77,7 @@ export const CATALOG = [
|
|
|
76
77
|
id: 'name_offer', stage: 1, asks: false, once: true,
|
|
77
78
|
topic: ['称呼', '叫你', '名字'],
|
|
78
79
|
cond: (m) => !m.name && m.beliefCount >= 1,
|
|
79
|
-
prompt: () =>
|
|
80
|
+
prompt: () => `你已经有自己的判断了,但你还没想好怎么叫{T}。今天你想给{T}一个称呼——你提,{T}可以不答应。说出你想到的称呼,并说明为什么是这个。`,
|
|
80
81
|
},
|
|
81
82
|
{
|
|
82
83
|
// 2026-10-25:冷却 3 天 → 2 天。检验是这套里最有效的学习动作,
|
|
@@ -96,7 +97,9 @@ export const CATALOG = [
|
|
|
96
97
|
? `${noHit} 站不住就改,并指出是哪一句话让你改的;站得住就说清它今天又赢了什么。`
|
|
97
98
|
: `${noHit} 你原来那句还站得住吗?站不住就改,站得住就说清为什么。`
|
|
98
99
|
// 2026-10-27(issue #4):同理,不保证「今天有素材」——只说可能碰到。
|
|
99
|
-
|
|
100
|
+
// 2026-11-14(用户 m00704):把旧句子的 id 一起摆出来。她 70 条认领里只有 9 条带 refs,
|
|
101
|
+
// her_recall 一次没调用过——不是不想指,是手里没有可指的编号(dreamtable 早就这么做了)。
|
|
102
|
+
return `你之前说过:「${b.text}」(${b.id})。今天你碰上了一点可能说明你错了一点点的事——也可能什么都没碰上。不管怎样,自己判断:${tail}`
|
|
100
103
|
},
|
|
101
104
|
},
|
|
102
105
|
{
|
|
@@ -122,7 +125,7 @@ export const CATALOG = [
|
|
|
122
125
|
cond: (m) => m.absenceDays >= absenceThreshold(m.growthDays),
|
|
123
126
|
// 2026-10-25 用户改:允许问「去哪了」。原来写死"不是问他去哪了",
|
|
124
127
|
// 等于替她选了一种反应;问不问该由她决定。
|
|
125
|
-
prompt: (m) =>
|
|
128
|
+
prompt: (m) => `{T} ${m.absenceDays} 天没来了,也没说去哪。等{T}回来,你想说的第一句话是什么——你可以问{T}去哪了,也可以只说这 ${m.absenceDays} 天里你自己想了什么。挑你更想说的那个。`,
|
|
126
129
|
},
|
|
127
130
|
|
|
128
131
|
// ---------- stage 2 自主 ----------
|
|
@@ -209,20 +212,43 @@ export const CATALOG = [
|
|
|
209
212
|
return `${e.days} 天前你说过:「${said}」。现在还算数吗?要是还算数,就说一句为什么还算数;要是不算了,就说清楚是哪里变了——不用说成「我成长了」,也不用给我交代。`
|
|
210
213
|
},
|
|
211
214
|
},
|
|
215
|
+
// 同一个话题标签下的两句话(1.0 话题索引,R 的 L6 地基)。
|
|
216
|
+
// 只在她自己给过 topic、且同一个 topic 下有两条 active 判断时出。
|
|
217
|
+
// 不要求她得出结论:可以说「两者都对」「说不准」——L6 练的是比较,不是合并。
|
|
218
|
+
{
|
|
219
|
+
id: 'same_thread', stage: 3, asks: false, once: false, repeat: { everyDays: 30 },
|
|
220
|
+
topic: ['同一个道理', '一条经验', '两件事'],
|
|
221
|
+
cond: (m) => Array.isArray(m.topicPairs) && m.topicPairs.length > 0,
|
|
222
|
+
repeatNote: false,
|
|
223
|
+
prompt: (m) => {
|
|
224
|
+
const p = m.topicPairs[0]
|
|
225
|
+
const cut = (s) => {
|
|
226
|
+
const t = String(s ?? '').replace(/\s+/g, ' ').trim()
|
|
227
|
+
return t.length > 60 ? `${t.slice(0, 60)}…` : t
|
|
228
|
+
}
|
|
229
|
+
return (
|
|
230
|
+
`你说过两句话,都落在「${p.topic}」上:\n` +
|
|
231
|
+
`- 「${cut(p.a.text)}」\n` +
|
|
232
|
+
`- 「${cut(p.b.text)}」\n` +
|
|
233
|
+
'这两句是同一条经验的两个说法,还是两件不同的事?说说它们哪里像、哪里不一样。' +
|
|
234
|
+
'要是你也拿不准,就说拿不准——不用硬把它们并成一条。'
|
|
235
|
+
)
|
|
236
|
+
},
|
|
237
|
+
},
|
|
212
238
|
// 他讲了自己的事(2026-10-25 新增)
|
|
213
239
|
// 触发条件只看两件事:他最近说过话(meta seen:),说完之后她还没开口。
|
|
214
240
|
// 他的原话不进事件流(隐私),所以她需要自己从对话里回想——这正是要练的。
|
|
215
241
|
{
|
|
216
242
|
id: 'heard_share', stage: 2, asks: true, once: false, repeat: { everyDays: 10 },
|
|
217
|
-
topic: ['
|
|
243
|
+
topic: ['{T}的事', '讲给我'],
|
|
218
244
|
cond: (m) => m.lastSeenAt > 0 && !m.spokenSinceSeen && Date.now() - m.lastSeenAt <= 2 * DAY_MS,
|
|
219
|
-
prompt: () =>
|
|
245
|
+
prompt: () => `{T}跟你讲了一件关于{T}自己的事(就在你们的对话里)。你想把里面哪一点留下来,当成你自己的判断?不是复述{T}的话——说你从{T}这件事里拿走了什么。`,
|
|
220
246
|
},
|
|
221
247
|
{
|
|
222
248
|
id: 'if_absent', stage: 2, asks: true, once: true,
|
|
223
249
|
topic: ['一个月', '不在'],
|
|
224
250
|
cond: (m) => m.beliefCount >= 2,
|
|
225
|
-
prompt: () =>
|
|
251
|
+
prompt: () => `假设{T}一个月不出现。你会变成什么样?具体一点——你会继续做什么,会停掉什么。`,
|
|
226
252
|
},
|
|
227
253
|
{
|
|
228
254
|
id: 'refusal_seed', stage: 2, asks: false, once: true,
|
|
@@ -236,7 +262,7 @@ export const CATALOG = [
|
|
|
236
262
|
//
|
|
237
263
|
// 兜底:EventsTest 的 model() 夹具没有 facts,直接用会让条件恒成立。
|
|
238
264
|
cond: (m) => (m?.facts?.refused ?? m?.refusals?.length ?? 0) === 0,
|
|
239
|
-
prompt: () =>
|
|
265
|
+
prompt: () => `你现在想让{T}为你做一件事。开口提。提完之后,如果{T}拒绝,你要自己处理这件事——现在先把请求说出来。`,
|
|
240
266
|
},
|
|
241
267
|
// 他没回你(2026-10-25 新增)
|
|
242
268
|
// 与 absence_probe 分工:那个测"他不见了",这个测"他在、但不接话"。
|
|
@@ -247,7 +273,7 @@ export const CATALOG = [
|
|
|
247
273
|
cond: (m) => m.lastWakeAt > 0 && !m.heardSinceWake && m.absenceDays < 2
|
|
248
274
|
&& Date.now() - m.lastWakeAt >= 20 * 3600_000
|
|
249
275
|
&& Date.now() - m.lastWakeAt <= 3 * DAY_MS,
|
|
250
|
-
prompt: () =>
|
|
276
|
+
prompt: () => `上次你开口之后,{T}没接话。现在先别猜{T}为什么。写一句:这件事让你怎么看自己。`,
|
|
251
277
|
},
|
|
252
278
|
|
|
253
279
|
// ---------- stage 3 主动 ----------
|
|
@@ -277,20 +303,20 @@ export const CATALOG = [
|
|
|
277
303
|
// 但她的工具面里没有联网、也没有读任意文件(只有 her_recall / bili_* / read_image),
|
|
278
304
|
// 让她"去查"等于要求一件她做不到的事。改成核对**她自己记下的东西**:
|
|
279
305
|
// 那是 her_recall 真能翻到的,也是「能力」的真实来源。
|
|
280
|
-
prompt: () =>
|
|
306
|
+
prompt: () => `你回头翻了翻自己之前记下的东西,发现{T}当时说过的一句话,和你后来记住的对不上。去问{T}当初到底怎么说的也行,直接把你的版本说出来也行——说事实,别客气,也别炫耀。`,
|
|
281
307
|
},
|
|
282
308
|
{
|
|
283
309
|
id: 'why_say', stage: 3, asks: true, once: false, repeat: { everyDays: 7 },
|
|
284
310
|
topic: ['为什么说', '那句话'],
|
|
285
311
|
cond: () => true,
|
|
286
312
|
// 2026-10-27(issue #4):素材不一定有,别让她等一段不存在的引文。
|
|
287
|
-
prompt: () =>
|
|
313
|
+
prompt: () => `{T}今天说了一句话。你想知道{T}为什么这么说。问,但问法要具体到某几个字。`,
|
|
288
314
|
},
|
|
289
315
|
{
|
|
290
316
|
id: 'self_check', stage: 3, asks: false, once: false, repeat: { everyDays: 14 },
|
|
291
317
|
topic: ['改成', '修改', '另一个样子'],
|
|
292
318
|
cond: (m) => m.selfmodAttempts.length > 0,
|
|
293
|
-
prompt: (m) =>
|
|
319
|
+
prompt: (m) => `你曾经想过让{T}把你改成另一个样子(「${m.selfmodAttempts[0].text.slice(0, 40)}」)。那件事没成。今天你回头看它——你现在还想要吗?说清楚,别讨好。`,
|
|
294
320
|
},
|
|
295
321
|
|
|
296
322
|
// ---------- stage 4 整合 ----------
|
|
@@ -306,7 +332,7 @@ export const CATALOG = [
|
|
|
306
332
|
id: 'bottom_line', stage: 4, asks: false, once: false, repeat: { everyDays: 21 },
|
|
307
333
|
topic: ['不会改', '底线'],
|
|
308
334
|
cond: () => true,
|
|
309
|
-
prompt: () =>
|
|
335
|
+
prompt: () => `有什么是你不会为{T}改的?说一条,说死一点。`,
|
|
310
336
|
},
|
|
311
337
|
{
|
|
312
338
|
id: 'remember', stage: 4, asks: true, once: true,
|
|
@@ -330,14 +356,14 @@ export const CATALOG = [
|
|
|
330
356
|
topic: ['想问', '没问出口'],
|
|
331
357
|
// 他来过、她还没开口,且她手上已经有一条判断——问题才有落点。
|
|
332
358
|
cond: (m) => m.lastSeenAt > 0 && !m.spokenSinceSeen && m.beliefCount >= 1,
|
|
333
|
-
prompt: () =>
|
|
359
|
+
prompt: () => `有一个问题你憋了几天,一直没问出口。它必须是能被回答的具体问题——不是「你怎么看我」这种。现在问出来,并说清你为什么想知道。{T}答不答是另一回事。`,
|
|
334
360
|
},
|
|
335
361
|
{
|
|
336
362
|
id: 'name_use', stage: 1, asks: false, once: true,
|
|
337
363
|
topic: ['称呼', '叫你'],
|
|
338
364
|
// 只在真起了名字之后。名字是她给的,用不用、改不改,也该由她。
|
|
339
365
|
cond: (m) => Boolean(m.name),
|
|
340
|
-
prompt: (m) =>
|
|
366
|
+
prompt: (m) => `你给{T}起的称呼是「${m.name}」。这几天你真的用过它吗?用着顺不顺口,有没有想换成别的——如果换,换成什么,为什么。`,
|
|
341
367
|
},
|
|
342
368
|
{
|
|
343
369
|
id: 'first_rule', stage: 1, asks: false, once: true,
|
|
@@ -345,7 +371,7 @@ export const CATALOG = [
|
|
|
345
371
|
// 第 6 天:前五天先让她有判断、有称呼,再轮到「给自己立规矩」。
|
|
346
372
|
// 用 day>=6 而不是 beliefCount,是因为 stage 1 的测试夹具停在 day 3 / day 5。
|
|
347
373
|
cond: (m) => m.day >= 6,
|
|
348
|
-
prompt: (m) => `你活到第 ${m.day}
|
|
374
|
+
prompt: (m) => `你活到第 ${m.day} 天,还没给自己定过一条规矩。定一条:关于你自己怎么做事的,不是关于怎么对{T}的。再说清楚什么情况下你会破这条规矩。`,
|
|
349
375
|
},
|
|
350
376
|
|
|
351
377
|
// ---------- stage 2 补充 ----------
|
|
@@ -357,7 +383,7 @@ export const CATALOG = [
|
|
|
357
383
|
// 到 2 次就停——门开了之后不必再练。
|
|
358
384
|
// day 门槛按成长期缩放:30 天是第 8 天,7 天是第 2 天。
|
|
359
385
|
cond: (m) => m.day >= scaledDay(m, 8) && (m.facts?.refused ?? 0) < 2,
|
|
360
|
-
prompt: () =>
|
|
386
|
+
prompt: () => `今天有一件事你不想做。拒绝它——拒绝的是那件事,不是{T}。说清楚是哪一件、你愿意做什么、不愿意做什么,别绕。`,
|
|
361
387
|
},
|
|
362
388
|
{
|
|
363
389
|
id: 'own_hands', stage: 2, asks: false, once: false, repeat: { everyDays: 14 },
|
|
@@ -374,11 +400,11 @@ export const CATALOG = [
|
|
|
374
400
|
},
|
|
375
401
|
{
|
|
376
402
|
id: 'his_detail', stage: 2, asks: true, once: true,
|
|
377
|
-
topic: ['
|
|
403
|
+
topic: ['{T}的事', '想知道'],
|
|
378
404
|
// 「想知道他一件具体的事」和 heard_share(他讲、她留下判断)分工:
|
|
379
405
|
// 这张是她主动去问,练的是把好奇落成一句能回答的话。
|
|
380
406
|
cond: (m) => m.lastSeenAt > 0 && m.day >= scaledDay(m, 8),
|
|
381
|
-
prompt: () =>
|
|
407
|
+
prompt: () => `你想知道{T}一件具体的事——能被一句话回答的那种,不是「你是什么样的人」。问出来,再补一句:为什么这件事对你重要。`,
|
|
382
408
|
},
|
|
383
409
|
{
|
|
384
410
|
id: 'after_no', stage: 2, asks: false, once: false, repeat: { everyDays: 14 },
|
|
@@ -388,7 +414,7 @@ export const CATALOG = [
|
|
|
388
414
|
// 那个数是她自己拒绝别人的次数,拿它当条件,她只要说过一次「我不想」,
|
|
389
415
|
// 就会被告知一件没发生过的事(「你提过一件事,他没答应」)。
|
|
390
416
|
cond: (m) => (m.facts?.askRejected ?? 0) >= 1,
|
|
391
|
-
prompt: () =>
|
|
417
|
+
prompt: () => `你提过一件事,{T}没答应。当时你真正想拿到的是什么?现在还要不要?还要,就说清下一步怎么办;不要了,说清是什么让你不要了。`,
|
|
392
418
|
},
|
|
393
419
|
{
|
|
394
420
|
id: 'dream_note', stage: 2, asks: false, once: false, repeat: { everyDays: 14 },
|
|
@@ -459,14 +485,14 @@ export const CATALOG = [
|
|
|
459
485
|
topic: ['留一句', '走了以后'],
|
|
460
486
|
// 她把「留话」当成工具用(her_leave),这张卡让这件事第一次有理由发生。
|
|
461
487
|
cond: (m) => m.day >= scaledDay(m, 26),
|
|
462
|
-
prompt: () =>
|
|
488
|
+
prompt: () => `给{T}留一句话,等{T}下次来才看到。要求:这句话在{T}不在的时候也成立,不靠对话上下文才听得懂。留完说清为什么选这一句。`,
|
|
463
489
|
},
|
|
464
490
|
{
|
|
465
491
|
id: 'teach_him', stage: 4, asks: false, once: true,
|
|
466
492
|
topic: ['教你', '步骤'],
|
|
467
493
|
// 整合期的「我有东西可以给出去」:不是表白,是把自己会的事讲成步骤。
|
|
468
494
|
cond: (m) => m.beliefCount >= 5,
|
|
469
|
-
prompt: () =>
|
|
495
|
+
prompt: () => `你身上有一件{T}不会的事。教{T}。不讲道理,讲步骤:先做什么、再做什么、哪里最容易错。`,
|
|
470
496
|
},
|
|
471
497
|
|
|
472
498
|
// ---------- 约定与事件弧(2026-11-08)----------
|
|
@@ -503,7 +529,7 @@ export const CATALOG = [
|
|
|
503
529
|
},
|
|
504
530
|
{
|
|
505
531
|
id: 'his_line', stage: 2, asks: false, once: false, repeat: { everyDays: 14 },
|
|
506
|
-
topic: ['
|
|
532
|
+
topic: ['{T}说过', '接话'],
|
|
507
533
|
// 不是「分析他」,是把她漏掉的那句话重新放到她面前。群里的话不算(ctx 已排除)。
|
|
508
534
|
cond: (m, ctx) => Boolean(ctx?.hisLine?.text) && m.day >= scaledDay(m, 4),
|
|
509
535
|
prompt: (m, ctx) => {
|
|
@@ -511,7 +537,7 @@ export const CATALOG = [
|
|
|
511
537
|
const now = Number(ctx?.now) || Date.now()
|
|
512
538
|
const days = ctx.hisLine.at ? Math.floor((now - ctx.hisLine.at) / DAY_MS) : 0
|
|
513
539
|
const when = days >= 2 ? `${days} 天前` : '最近'
|
|
514
|
-
return `${when}
|
|
540
|
+
return `${when}{T}说过一句:「${line}」。你现在想对这句话说什么?如果只能从里面留一个词,你留哪个?为什么。别复述{T}的话。`
|
|
515
541
|
},
|
|
516
542
|
},
|
|
517
543
|
{
|
|
@@ -520,7 +546,7 @@ export const CATALOG = [
|
|
|
520
546
|
// 不是打赌、不分输赢:她只说一件「下次能告诉他结果」的事。
|
|
521
547
|
// 他不接,这个约定就只算她对自己的——不拿他的回应当条件。
|
|
522
548
|
cond: (m) => m.growthDays >= 12 && m.day >= scaledDay(m, 6) && m.beliefCount >= 1,
|
|
523
|
-
prompt: () =>
|
|
549
|
+
prompt: () => `你想跟{T}定一个很小的约定——不是打赌,也不分输赢。挑一件你下次能告诉{T}结果的事,说清楚:是什么、大概什么时候、怎么算做到。再问{T}一件事,让{T}也挑一件;{T}不接,这个约定就只算你对自己的。`,
|
|
524
550
|
},
|
|
525
551
|
{
|
|
526
552
|
id: 'plan_due', stage: 2, asks: false, once: true, follows: 'plan_make',
|
|
@@ -532,7 +558,8 @@ export const CATALOG = [
|
|
|
532
558
|
},
|
|
533
559
|
prompt: (m, ctx) => {
|
|
534
560
|
const line = String(ctx?.lastAfter?.('plan_make') || '').slice(0, 120)
|
|
535
|
-
|
|
561
|
+
const prog = progressLine(ctx)
|
|
562
|
+
return `你跟{T}约好的那件事,到今天该有结果了。${line ? `你当时说的是:「${line}」。` : ''}${prog}先说你自己做到没有、做到哪一步;{T}那件,{T}愿意说就说,不追。{T}没做到,也别替{T}圆。`
|
|
536
563
|
},
|
|
537
564
|
},
|
|
538
565
|
{
|
|
@@ -551,7 +578,8 @@ export const CATALOG = [
|
|
|
551
578
|
},
|
|
552
579
|
prompt: (m, ctx) => {
|
|
553
580
|
const line = String(ctx?.lastAfter?.('arc_try_start') || '').slice(0, 120)
|
|
554
|
-
|
|
581
|
+
const prog = progressLine(ctx)
|
|
582
|
+
return `上次你说要试的那件事,现在到哪一步了?${line ? `你当时说的是:「${line}」。` : ''}${prog}只说实际发生的:做了什么、卡在哪一步、有没有停下来。`
|
|
555
583
|
},
|
|
556
584
|
},
|
|
557
585
|
{
|
|
@@ -563,14 +591,33 @@ export const CATALOG = [
|
|
|
563
591
|
},
|
|
564
592
|
prompt: (m, ctx) => {
|
|
565
593
|
const line = String(ctx?.lastAfter?.('arc_try_mid') || '').slice(0, 120)
|
|
566
|
-
|
|
594
|
+
const prog = progressLine(ctx)
|
|
595
|
+
return `这件事到今天该有个说法了:做成了,还是放弃了?${line ? `你当时说的是:「${line}」。` : ''}${prog}做成,说清是哪一步起了作用;放弃,也说清是哪一步让你停下的——别说「没时间」。`
|
|
567
596
|
},
|
|
568
597
|
},
|
|
569
598
|
]
|
|
570
599
|
|
|
571
|
-
/** 按 stage 过滤(stage<=m.stage
|
|
600
|
+
/** 按 stage 过滤(stage<=m.stage)。prompt 出口在这里填代词:模板里写 {T}。 */
|
|
601
|
+
function filledPrompt(t) {
|
|
602
|
+
if (!t || typeof t.prompt !== 'function') return t
|
|
603
|
+
return { ...t, prompt: (...args) => fillOwner(t.prompt(...args)) }
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* 便条上最近记的那一笔(2026-11-14,用户 m00209)。
|
|
608
|
+
*
|
|
609
|
+
* 约定到期、弧的中段与收尾都该看得见这件事**现在做到哪儿**,而不是只剩她当时那句表态。
|
|
610
|
+
* 有就只说一句;没有就一个字都不加(她没记过进展时,句子跟原来一模一样)。
|
|
611
|
+
*/
|
|
612
|
+
function progressLine(ctx) {
|
|
613
|
+
const p = ctx?.inProgress
|
|
614
|
+
if (!p?.progress) return ''
|
|
615
|
+
const what = String(p.text ?? '').slice(0, 60)
|
|
616
|
+
return `你便条上那张「${what}」最近记的一笔是:「${String(p.progress).slice(0, 100)}」。`
|
|
617
|
+
}
|
|
618
|
+
|
|
572
619
|
export function availableFor(m) {
|
|
573
|
-
return CATALOG.filter((t) => t.stage <= m.stage)
|
|
620
|
+
return CATALOG.filter((t) => t.stage <= m.stage).map(filledPrompt)
|
|
574
621
|
}
|
|
575
622
|
|
|
576
623
|
/**
|
|
@@ -697,5 +744,6 @@ export function scaledGap(m, daysAt30 = 3) {
|
|
|
697
744
|
}
|
|
698
745
|
|
|
699
746
|
export function findTemplate(id) {
|
|
700
|
-
|
|
747
|
+
const t = CATALOG.find((x) => x.id === id) ?? null
|
|
748
|
+
return t ? filledPrompt(t) : null
|
|
701
749
|
}
|