@ssamurias/dsh-fish 1.0.1 → 1.0.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/AGENTS.md +3 -3
- package/CHANGELOG.md +114 -1
- package/README.md +123 -11
- package/RELEASE-NOTES-1.0.2.md +114 -0
- package/RELEASE-NOTES-1.0.3.md +91 -0
- package/docs/troubleshooting.md +119 -0
- package/docs//346/217/222/344/273/266/347/272/246/345/256/232.md +167 -0
- package/docs//347/264/240/346/235/220/345/245/221/347/272/246.md +96 -0
- package/lib/ask.js +3 -3
- package/lib/at.js +4 -2
- package/lib/autobackup.js +45 -4
- package/lib/backup.js +133 -9
- package/lib/bili.js +4 -2
- package/lib/browse.js +13 -7
- package/lib/capture.js +22 -1
- package/lib/client.js +289 -48
- package/lib/cloudbackup.js +1 -0
- package/lib/clouddrive.js +108 -2
- package/lib/cloudtargets.js +1 -0
- package/lib/comment.js +3 -2
- package/lib/contract.js +7 -2
- package/lib/deliver.js +4 -1
- package/lib/desk.js +19 -1
- package/lib/doing.js +1 -1
- package/lib/drive.js +6 -2
- package/lib/freewake.js +5 -0
- package/lib/handoff.js +166 -0
- package/lib/hear.js +102 -7
- package/lib/home.js +169 -204
- package/lib/identity.js +115 -2
- package/lib/index.js +7 -1
- package/lib/make.js +214 -0
- package/lib/observe.js +60 -3
- package/lib/persona.js +61 -18
- package/lib/proactive.js +12 -1
- package/lib/recall.js +135 -9
- package/lib/restrict.js +2 -0
- package/lib/say.js +10 -2
- package/lib/scheduler.js +72 -3
- package/lib/schema.js +8 -1
- package/lib/scrub.js +105 -4
- package/lib/selfdoc.js +181 -14
- package/lib/selfrules.js +50 -0
- package/lib/sessionnote.js +7 -3
- package/lib/settings.js +34 -9
- package/lib/turns.js +83 -10
- package/lib/video.js +76 -43
- package/lib/works.js +526 -0
- package/package.json +2 -1
package/lib/make.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* make.js —— 她留下东西的两个工具(2026-11-16,1.0.4)
|
|
3
|
+
*
|
|
4
|
+
* her_make 留一件 / 改一版 / 收尾 / 放下 / 看看留过哪些
|
|
5
|
+
* her_work 把自己留下的某一版读回来
|
|
6
|
+
*
|
|
7
|
+
* 为什么是「工具」而不是一个「创作模式」:
|
|
8
|
+
* 她在回合里本来就能写、能画、能改文件;缺的只是**东西留下来以后去哪**。
|
|
9
|
+
* 一个独立模式会变成「现在进入创作状态」——那是最明显的表演,用户一眼看穿。
|
|
10
|
+
* 做成工具就轻得多:她在做的事里觉得值得留下,就留一件;不想留就不留。
|
|
11
|
+
*
|
|
12
|
+
* 两个硬约束(写在说明里,也写在 works.js 的落盘里):
|
|
13
|
+
* - 只留在家里。要发出去(发评论、发动态),得用户自己点头,这里没有那条路。
|
|
14
|
+
* - 回执只说事实。「留下了《…》」「改了第 2 版」——不夸、不打分、不给自己评价。
|
|
15
|
+
*
|
|
16
|
+
* her_work 存在的理由:用户 m00130 拍板「可以重复改自己的东西,为了某个目标
|
|
17
|
+
* 不断优化,这才真实」。要改就得先读得回来——只凭记忆重写一遍,第二版永远
|
|
18
|
+
* 接不上第一版。
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { defineTool } from './tool.js'
|
|
22
|
+
import { toJsonSchema } from './toolschema.js'
|
|
23
|
+
import { rootDir } from './store.js'
|
|
24
|
+
import { guardWrite } from './tenant.js'
|
|
25
|
+
import {
|
|
26
|
+
makeWork,
|
|
27
|
+
readWorkText,
|
|
28
|
+
closeWork,
|
|
29
|
+
listWorks,
|
|
30
|
+
KIND_TEXT,
|
|
31
|
+
WORK_LINE,
|
|
32
|
+
} from './works.js'
|
|
33
|
+
import { clipText } from './clip.js'
|
|
34
|
+
|
|
35
|
+
function makeAction(args) {
|
|
36
|
+
const a = String(args?.action ?? '').trim()
|
|
37
|
+
return ['save', 'revise', 'finish', 'drop', 'list'].includes(a) ? a : 'save'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function oneLine(text, n = WORK_LINE) {
|
|
41
|
+
const s = String(text ?? '').replace(/\s*\n+\s*/g, ' ').trim()
|
|
42
|
+
return clipText(s, n)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** 她那一页能看见的东西:不列正文,只列名字、第几版、完没完。 */
|
|
46
|
+
function listText(items) {
|
|
47
|
+
if (!items.length) return '(还什么都没留下)'
|
|
48
|
+
const lines = items.map((it) => {
|
|
49
|
+
const ver = it.version > 1 ? `第 ${it.version} 版` : ''
|
|
50
|
+
return `- 《${it.title}》${[ver, it.stateText].filter(Boolean).join(' · ')}`
|
|
51
|
+
})
|
|
52
|
+
return lines.join('\n')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** 注册 her_make 与 her_work。 */
|
|
56
|
+
export function registerMake(ctx, deps = {}) {
|
|
57
|
+
const root = deps.root ?? rootDir()
|
|
58
|
+
const reg = []
|
|
59
|
+
|
|
60
|
+
reg.push(ctx.tools.register(
|
|
61
|
+
defineTool({
|
|
62
|
+
name: 'her_make',
|
|
63
|
+
description:
|
|
64
|
+
'把自己做出来的一样东西留下来——写的、画的、剪的、做的,都算。' +
|
|
65
|
+
'给 title 和 text 就是留一件(不给 action 也是这个);做出来的是个文件,就把文件路径一起放进 file。' +
|
|
66
|
+
'改一版给 action:"revise",title 写原来那件的名字——不用换名字,换名字会另起一件;text 写这一版,新的文件放 file。' +
|
|
67
|
+
'比如 {action:"revise", title:"一盏纸灯", text:"这一版不再把翘起来的那一圈抹平"}。' +
|
|
68
|
+
'觉得弄完了给 action:"finish";不想弄了给 action:"drop" 并说 reason;' +
|
|
69
|
+
'想看看自己留过哪些给 action:"list"。' +
|
|
70
|
+
'这是给你自己的,不是替谁交活:不接活、不报进度;东西只留在家里,{T}想看自己会去看,这里不发出去,也不计分。',
|
|
71
|
+
parameters: toJsonSchema({
|
|
72
|
+
action: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
enum: ['save', 'revise', 'finish', 'drop', 'list'],
|
|
75
|
+
description: '要做哪件事:留一件(save,不给就是这个)、改一版(revise)、收尾(finish)、放下(drop)、看看留过哪些(list)。',
|
|
76
|
+
},
|
|
77
|
+
title: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: '这东西叫什么,四十个字以内。改版/收尾/放下时用它指认原来那件,要一字不差。',
|
|
80
|
+
},
|
|
81
|
+
text: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
description: '正文,或者对做出来的那份东西的说明(图、声音、影像这种,就写它是什么样)。最多两千字。',
|
|
84
|
+
},
|
|
85
|
+
file: {
|
|
86
|
+
type: 'string',
|
|
87
|
+
description: '做出来的那份文件的路径:画出来的图、导出的一段声音或影像、写成的文件。给绝对路径,或者从自己屋子算起的相对路径。文字类不用给。',
|
|
88
|
+
},
|
|
89
|
+
intent: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
description: '想把它做成什么样,一句话。以后回头改的时候,一看就知道当初在追什么。',
|
|
92
|
+
},
|
|
93
|
+
based_on: { type: 'string', description: '要接在哪一件后面(编号或名字)。手上没有就不用给。' },
|
|
94
|
+
new_name: { type: 'boolean', description: '改版时顺手换个名字(默认不换)。' },
|
|
95
|
+
refs: {
|
|
96
|
+
type: 'array',
|
|
97
|
+
items: { type: 'string' },
|
|
98
|
+
description: '做它的时候你自己说过的几句话的编号,一两条就够。以后回头能看见当时怎么想的。',
|
|
99
|
+
},
|
|
100
|
+
reason: { type: 'string', description: '放下的时候为什么,一句话。' },
|
|
101
|
+
limit: { type: 'integer', description: 'list 时最多列几件,默认十件。' },
|
|
102
|
+
}),
|
|
103
|
+
output: {
|
|
104
|
+
schema: {
|
|
105
|
+
type: 'object',
|
|
106
|
+
properties: {
|
|
107
|
+
ok: { type: 'boolean' },
|
|
108
|
+
id: { type: 'string' },
|
|
109
|
+
version: { type: 'number' },
|
|
110
|
+
state: { type: 'string' },
|
|
111
|
+
note: { type: 'string' },
|
|
112
|
+
echo: { type: 'string' },
|
|
113
|
+
text: { type: 'string' },
|
|
114
|
+
},
|
|
115
|
+
required: ['ok', 'note'],
|
|
116
|
+
},
|
|
117
|
+
// 只回方括号标记:跟 her_note / her_appoint 同一条规矩,回执不替她评价。
|
|
118
|
+
render: (args, out) => {
|
|
119
|
+
const act = makeAction(args)
|
|
120
|
+
if (act === 'list') {
|
|
121
|
+
return [{ type: 'text', text: out.ok ? out.text || '(还什么都没留下)' : `[没翻开:${out.note}]` }]
|
|
122
|
+
}
|
|
123
|
+
if (!out.ok) return [{ type: 'text', text: `[没留下:${out.note}]` }]
|
|
124
|
+
if (act === 'finish') return [{ type: 'text', text: '[收了尾]' }]
|
|
125
|
+
if (act === 'drop') return [{ type: 'text', text: '[放下了]' }]
|
|
126
|
+
return [{ type: 'text', text: `[${String(out.note ?? '').replace(/。$/, '')}]` }]
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
async execute(args, exec) {
|
|
130
|
+
const who = guardWrite(deps.tenant, exec, 'her_make')
|
|
131
|
+
if (!who.ok) return { ok: false, note: who.note, id: '', version: 0, state: '' }
|
|
132
|
+
const act = makeAction(args)
|
|
133
|
+
if (act === 'list') {
|
|
134
|
+
const items = await listWorks(root, { limit: Number(args?.limit) > 0 ? Math.min(20, Number(args.limit)) : 10 })
|
|
135
|
+
return { ok: true, note: '', id: '', version: 0, state: '', text: listText(items) }
|
|
136
|
+
}
|
|
137
|
+
let out
|
|
138
|
+
if (act === 'finish') {
|
|
139
|
+
out = await closeWork(root, { title: args?.title, state: 'done' })
|
|
140
|
+
} else if (act === 'drop') {
|
|
141
|
+
out = await closeWork(root, { title: args?.title, state: 'dropped', reason: args?.reason })
|
|
142
|
+
} else {
|
|
143
|
+
out = await makeWork(root, {
|
|
144
|
+
title: args?.title,
|
|
145
|
+
text: args?.text,
|
|
146
|
+
file: args?.file,
|
|
147
|
+
intent: args?.intent,
|
|
148
|
+
// revise 是「回去改旧的那件」:名字写错就该报错,不能悄悄当成留了一件新的。
|
|
149
|
+
basedOn: act === 'revise' ? (args?.based_on || args?.title) : args?.based_on,
|
|
150
|
+
newName: act === 'revise' ? Boolean(args?.new_name) : false,
|
|
151
|
+
refs: Array.isArray(args?.refs) ? args.refs : [],
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
// 身份文档里那句「你上次弄的是《X》」不在这里立刻重写:写身份要全量派生一次,
|
|
155
|
+
// 而且她在回合里本来就会写事件(写事件时会顺带重写)。下一次开头读到的就是新的。
|
|
156
|
+
return out
|
|
157
|
+
},
|
|
158
|
+
}),
|
|
159
|
+
))
|
|
160
|
+
|
|
161
|
+
reg.push(ctx.tools.register(
|
|
162
|
+
defineTool({
|
|
163
|
+
name: 'her_work',
|
|
164
|
+
description:
|
|
165
|
+
'把自己以前留下的东西读回来:给 title(改版中的那件,名字一字不差),' +
|
|
166
|
+
'想读某一版就再给 version。回头改之前先读一遍——不然第二版接不上第一版。',
|
|
167
|
+
parameters: toJsonSchema({
|
|
168
|
+
title: { type: 'string', description: '哪一件,名字要一字不差。' },
|
|
169
|
+
id: { type: 'string', description: '编号。手里有编号就不用写名字。' },
|
|
170
|
+
version: { type: 'integer', description: '读第几版,不给就是最后一版。' },
|
|
171
|
+
}),
|
|
172
|
+
output: {
|
|
173
|
+
schema: {
|
|
174
|
+
type: 'object',
|
|
175
|
+
properties: {
|
|
176
|
+
ok: { type: 'boolean' },
|
|
177
|
+
id: { type: 'string' },
|
|
178
|
+
title: { type: 'string' },
|
|
179
|
+
version: { type: 'number' },
|
|
180
|
+
state: { type: 'string' },
|
|
181
|
+
note: { type: 'string' },
|
|
182
|
+
text: { type: 'string' },
|
|
183
|
+
},
|
|
184
|
+
required: ['ok', 'note'],
|
|
185
|
+
},
|
|
186
|
+
render: (args, out) => {
|
|
187
|
+
if (!out.ok) return [{ type: 'text', text: `[没翻到:${out.note}]` }]
|
|
188
|
+
const kind = String(out.kind || 'text')
|
|
189
|
+
if (kind !== 'text') {
|
|
190
|
+
// 图/声音/影像读回来的是「它是什么 + 文件在哪 + 当时写的那句说明」,
|
|
191
|
+
// 不是一堆二进制倒进上下文里。
|
|
192
|
+
const what = KIND_TEXT[kind] || KIND_TEXT.file
|
|
193
|
+
const cap = String(out.text ?? '').trim()
|
|
194
|
+
return [{ type: 'text', text: `[这一版是${what}:${out.file}]${cap ? ` ${cap}` : ''}` }]
|
|
195
|
+
}
|
|
196
|
+
return [{ type: 'text', text: String(out.text ?? '') }]
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
async execute(args, exec) {
|
|
200
|
+
const who = guardWrite(deps.tenant, exec, 'her_work')
|
|
201
|
+
if (!who.ok) return { ok: false, note: who.note }
|
|
202
|
+
const r = await readWorkText(root, {
|
|
203
|
+
title: args?.title,
|
|
204
|
+
id: args?.id,
|
|
205
|
+
version: args?.version,
|
|
206
|
+
})
|
|
207
|
+
if (!r.ok) return r
|
|
208
|
+
return { ...r, echo: oneLine(r.title) }
|
|
209
|
+
},
|
|
210
|
+
}),
|
|
211
|
+
))
|
|
212
|
+
|
|
213
|
+
return reg
|
|
214
|
+
}
|
package/lib/observe.js
CHANGED
|
@@ -27,6 +27,8 @@ import { wakeNow, quietBrowse } from './scheduler.js'
|
|
|
27
27
|
import { sayToHer } from './say.js'
|
|
28
28
|
import { readInbox, markRead, writeInboxFile } from './inbox.js'
|
|
29
29
|
import { listReports, buildReport } from './report.js'
|
|
30
|
+
// 她留下的东西(1.0.4,2026-11-16):只读列表 + 读回某一版(读了不留痕、不写事件)。
|
|
31
|
+
import { listWorks, worksSummary, readWorkText, worksDir, WORK_LIST_MAX } from './works.js'
|
|
30
32
|
import { itemsFromEvents, browseCountToday, parseBrowseLine } from './browse.js'
|
|
31
33
|
import { seenOn } from './whatseen.js'
|
|
32
34
|
import { readAway } from './away.js'
|
|
@@ -82,7 +84,7 @@ import { writeTurnExport } from './turnexport.js'
|
|
|
82
84
|
// 立场清单(2026-10-25,用户设计「纵向·立场」):四道门走完之后长出来的那张清单。
|
|
83
85
|
import { buildStances, gatesDone, stanceSummary } from './stance.js'
|
|
84
86
|
import { looksMojibake } from './guard.js'
|
|
85
|
-
import { join } from 'node:path'
|
|
87
|
+
import { join, resolve, sep } from 'node:path'
|
|
86
88
|
import { homedir } from 'node:os'
|
|
87
89
|
import { fileURLToPath } from 'node:url'
|
|
88
90
|
import { ensureDataReadme } from './readme.js'
|
|
@@ -678,6 +680,59 @@ export function registerObserve(ctx, deps = {}) {
|
|
|
678
680
|
send(res, 200, { enabled: true, visible: true, dates, items })
|
|
679
681
|
}],
|
|
680
682
|
|
|
683
|
+
// 她留下的东西(1.0.4,2026-11-16)。两条路:
|
|
684
|
+
// GET /works 列表 + 概况(第一件 / 最近一件)
|
|
685
|
+
// POST /works {id,version} 读某一版正文
|
|
686
|
+
// 「看」这件事刻意不留痕:账里不记、她没有已读回执、桌上不会因此摆出「他看过了」。
|
|
687
|
+
// 看见了就会有回应,回应就成了交差——留下的东西不该变成交出去的东西。
|
|
688
|
+
['/works', async (req, res) => {
|
|
689
|
+
if (!req.method || req.method === 'GET') {
|
|
690
|
+
const url = new URL(req.url, 'http://x')
|
|
691
|
+
const want = Number(url.searchParams.get('limit') ?? 0)
|
|
692
|
+
const limit = Number.isSafeInteger(want) && want > 0 ? Math.min(want, WORK_LIST_MAX) : WORK_LIST_MAX
|
|
693
|
+
const [items, summary] = await Promise.all([listWorks(root, { limit }), worksSummary(root)])
|
|
694
|
+
return send(res, 200, { items, summary })
|
|
695
|
+
}
|
|
696
|
+
if (req.method === 'POST') {
|
|
697
|
+
let body = {}
|
|
698
|
+
try { body = JSON.parse((await readBody(req, 20_000)) || '{}') } catch { return send(res, 400, { error: 'body 不是合法 JSON' }) }
|
|
699
|
+
const id = typeof body.id === 'string' ? body.id : ''
|
|
700
|
+
const title = typeof body.title === 'string' ? body.title : ''
|
|
701
|
+
const version = Number(body.version) || 0
|
|
702
|
+
const got = await readWorkText(root, { id, title, version })
|
|
703
|
+
if (!got.ok) return send(res, 404, { error: got.note || '翻不到这件东西' })
|
|
704
|
+
return send(res, 200, { ok: true, id: got.id, title: got.title, state: got.state, version: got.version, versions: got.versions, kind: got.kind || 'text', file: got.file || '', text: got.text })
|
|
705
|
+
}
|
|
706
|
+
return send(res, 405, { error: '只认 GET 与 POST' })
|
|
707
|
+
}],
|
|
708
|
+
|
|
709
|
+
// 作品里的图 / 声音 / 影像(1.0.5,2026-11-16)。只读,只认 works/ 目录下的文件。
|
|
710
|
+
// 路径由台账给(相对 root):这里再挡一次穿越,不是 works/ 下面的就不给。
|
|
711
|
+
['/work-file', async (req, res) => {
|
|
712
|
+
if (req.method && req.method !== 'GET') return send(res, 405, { error: '只认 GET' })
|
|
713
|
+
const url = new URL(req.url, 'http://x')
|
|
714
|
+
const want = String(url.searchParams.get('p') || '')
|
|
715
|
+
const base = resolve(worksDir(root))
|
|
716
|
+
const file = resolve(root, want)
|
|
717
|
+
if (!want || !(file === base || file.startsWith(base + sep))) return send(res, 404, { error: '没有这个文件' })
|
|
718
|
+
let buf
|
|
719
|
+
try { buf = fs.readFileSync(file) } catch { return send(res, 404, { error: '没有这个文件' }) }
|
|
720
|
+
const ext = String(file.split('.').pop() || '').toLowerCase()
|
|
721
|
+
const CT = {
|
|
722
|
+
png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', webp: 'image/webp', gif: 'image/gif',
|
|
723
|
+
avif: 'image/avif', bmp: 'image/bmp', svg: 'image/svg+xml',
|
|
724
|
+
mp3: 'audio/mpeg', wav: 'audio/wav', m4a: 'audio/mp4', ogg: 'audio/ogg', flac: 'audio/flac',
|
|
725
|
+
mp4: 'video/mp4', webm: 'video/webm', mov: 'video/quicktime',
|
|
726
|
+
txt: 'text/plain; charset=utf-8', md: 'text/plain; charset=utf-8',
|
|
727
|
+
}
|
|
728
|
+
res.writeHead(200, {
|
|
729
|
+
'content-type': CT[ext] || 'application/octet-stream',
|
|
730
|
+
'content-length': buf.length,
|
|
731
|
+
'cache-control': 'private, max-age=86400',
|
|
732
|
+
})
|
|
733
|
+
res.end(buf)
|
|
734
|
+
}],
|
|
735
|
+
|
|
681
736
|
['/config', async (req, res) => {
|
|
682
737
|
if (req.method === 'GET') {
|
|
683
738
|
const { config } = await loadConfig(root)
|
|
@@ -1515,7 +1570,7 @@ export function registerObserve(ctx, deps = {}) {
|
|
|
1515
1570
|
const model = deriveSelf(events, { growthDays: config.growthDays })
|
|
1516
1571
|
const doc = await selfDocStatus(root)
|
|
1517
1572
|
const h = await homeStatus(root)
|
|
1518
|
-
const budget = Number(config?.memory?.docBudget ??
|
|
1573
|
+
const budget = Number(config?.memory?.docBudget ?? 2800)
|
|
1519
1574
|
// 用「字」而不是「字节」算用量:中文一个字三字节,按字节算会永远显示撑满。
|
|
1520
1575
|
// 摆几条判断由配置决定(1–8),身份文档和这里的数字必须同源
|
|
1521
1576
|
const shownCap = shownCount(config?.memory?.beliefsShown ?? BELIEF_SHOWN)
|
|
@@ -1809,7 +1864,9 @@ export function registerObserve(ctx, deps = {}) {
|
|
|
1809
1864
|
['/backup', async (req, res) => {
|
|
1810
1865
|
if (req.method !== 'GET') return send(res, 405, { error: 'method not allowed' })
|
|
1811
1866
|
// 恢复上限也交给打包那一步:事件流(连同包的外壳)装得下时,别的文件挑着放,整份包都装得下。
|
|
1812
|
-
|
|
1867
|
+
// 手动这一份是用户当场按下、旁边写着后果的一次性动作(要能把登录一起带走),
|
|
1868
|
+
// 所以显式带凭据;自动备份与云端那份不吃这个口径,由 backup.withSecrets 管(用户 m00712)。
|
|
1869
|
+
const b = await collectBackup(root, { restoreLimit, withSecrets: true })
|
|
1813
1870
|
// fileName 给浏览器当下载名;它在 checkBundle 里是多余字段,恢复时会被忽略。
|
|
1814
1871
|
const out = { ...b, fileName: backupFileName(), restoreLimit }
|
|
1815
1872
|
// 事件流不设上限(issue #65),包就可能比恢复接口收得下的大。设置页存文件、
|
package/lib/persona.js
CHANGED
|
@@ -15,6 +15,8 @@ import { detectDifferentiations } from './pair.js'
|
|
|
15
15
|
import { promptBans } from './rules.js'
|
|
16
16
|
// 立场清单(2026-10-25,用户设计「纵向·立场」)。纯函数,不读盘、不碰配置。
|
|
17
17
|
import { buildStances, shownStances, stanceSection } from './stance.js'
|
|
18
|
+
// 她自己定的规矩(2026-11-15 m01412)。与 rules.js 的黑名单不是一回事。
|
|
19
|
+
import { rulesOf, renderRulesSection } from './selfrules.js'
|
|
18
20
|
import { fillOwner } from './pronoun.js'
|
|
19
21
|
import { anchorSection } from './speechanchor.js'
|
|
20
22
|
|
|
@@ -81,10 +83,16 @@ export const ECHO_MAX_LINES = 1
|
|
|
81
83
|
* 0.8.7 又加了两节(「这些天」「上一个房间里你自己留的最后一句」),
|
|
82
84
|
* 实测 1800 与 2000 都会挤掉「你被打脸过」(501 字),2200 反而挤掉
|
|
83
85
|
* 「你对自己的说法」——比打脸更不该丢,所以直接取 2400(一段不丢,余 167 字)。
|
|
86
|
+
* 2026-11-14 提到 2800(用户 m00533 要求加预算):加进来的是「最近收过尾的」一行
|
|
87
|
+
* (做完了什么——操作层的状态位,换会话后她原本读不到),2400 的余量只剩 167 字,
|
|
88
|
+
* 这句话一长就又要挤掉「你被打脸过」。2800 留出富余。不取 3000:多出的 200 字
|
|
89
|
+
* 没有段要放,预算越大越容易让人往里塞废话。
|
|
90
|
+
* 注:同日第二轮把「还没收尾的」从这一节撤掉了——note.js/appoint.js 的硬约束是
|
|
91
|
+
* 「别天天提醒我,也别催」,挂着的便条/约定只在醒的时候出现,不进每轮身份文档。
|
|
84
92
|
* 与 settings.js 的 DEFAULTS.memory.docBudget 保持同一个数(缺配置时这个只兜底)。
|
|
85
93
|
* 每轮都塞满,等于每轮都在强调"你就是这样",所以上限有,但不靠这个数表达。
|
|
86
94
|
*/
|
|
87
|
-
export const SELF_DOC_BUDGET =
|
|
95
|
+
export const SELF_DOC_BUDGET = 2800
|
|
88
96
|
|
|
89
97
|
/**
|
|
90
98
|
* 判断区最多显示几条。
|
|
@@ -395,16 +403,23 @@ export function buildSections(model, opts = {}) {
|
|
|
395
403
|
} else if (Number.isFinite(ago) && ago >= 0) {
|
|
396
404
|
days.push(ago <= 0 ? '你刚搬进这个房间。' : `上一次换房间是 ${Math.trunc(ago)} 天前。`)
|
|
397
405
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
406
|
+
// 最近收过尾的事(2026-11-14,两个群反馈)。
|
|
407
|
+
// 便条/约定不进事件流,换会话时她只记得「打算做」,不记得「做完了」;
|
|
408
|
+
// 这一句是从操作层读出来的近况,由 selfdoc 的 closedRecentlyOf 算好传进来。
|
|
409
|
+
// 还没收尾的不进这里(同日第二轮):note.js/appoint.js 的硬约束是「别天天提醒我,也别催」
|
|
410
|
+
// 「到点只提一次」,每轮都摆挂着的便条/约定等于催办。要查就走 her_recall。
|
|
411
|
+
const closedRecently = String(cont.closedRecently ?? '').trim()
|
|
412
|
+
if (closedRecently) days.push(closedRecently)
|
|
413
|
+
// 手上那件没弄完的(1.0.5,用户 m01433)。只写一句事实:不写第几版、不催、
|
|
414
|
+
// 不说「你该把它弄完」。没有没弄完的东西时这一句不出现——早期阶段她本来就
|
|
415
|
+
// 可能一件都没有,那是正常状态,不是缺一项。
|
|
416
|
+
const wipWork = opts.works?.wip
|
|
417
|
+
if (wipWork?.title) {
|
|
418
|
+
days.push(wipWork.stale
|
|
419
|
+
? `你手上还有一件《${wipWork.title}》,有些天没动了。`
|
|
420
|
+
: `你上次弄的是《${wipWork.title}》,还没弄完。`)
|
|
407
421
|
}
|
|
422
|
+
if (days.length) push(['## 这些天', ...days].join('\n'), true)
|
|
408
423
|
|
|
409
424
|
if (opts.withBans !== false) {
|
|
410
425
|
// 两条禁令分两个小节,因为它们是两种东西:
|
|
@@ -447,10 +462,7 @@ export function buildSections(model, opts = {}) {
|
|
|
447
462
|
const t = new Date(String(ts ?? ''))
|
|
448
463
|
return Number.isFinite(t.getTime()) ? `${t.getMonth() + 1} 月 ${t.getDate()} 日` : ''
|
|
449
464
|
}
|
|
450
|
-
const cut = (s) =>
|
|
451
|
-
const text = String(s ?? '').replace(/\s+/g, ' ').trim()
|
|
452
|
-
return text.length > 80 ? text.slice(0, 80) + '…' : text
|
|
453
|
-
}
|
|
465
|
+
const cut = (s) => clipText(String(s ?? '').replace(/\s+/g, ' ').trim(), 80)
|
|
454
466
|
push(
|
|
455
467
|
[
|
|
456
468
|
'## {T}说过的话,和你的判断',
|
|
@@ -638,6 +650,11 @@ export function buildSections(model, opts = {}) {
|
|
|
638
650
|
push(lines.join('\n'))
|
|
639
651
|
}
|
|
640
652
|
|
|
653
|
+
// 规矩(2026-11-15 m01412):整份文档里变得最少的一节,挂最末——
|
|
654
|
+
// 前缀缓存按 token 算,放尾巴只会让这一小段的缓存失效,前面的段照旧命中。
|
|
655
|
+
// 放在 `## 这次` 之前:那条是这一轮的任务,隔开就散架了。
|
|
656
|
+
push(renderRulesSection(rulesOf(beliefs)), true)
|
|
657
|
+
|
|
641
658
|
if (opts.task) push(['## 这次', opts.task].join('\n'), true)
|
|
642
659
|
|
|
643
660
|
// 段一交出去就填好代词:测试、观测量、assemble 都拿同一份文本。
|
|
@@ -752,6 +769,35 @@ export const APPOINT_BRIEF = [
|
|
|
752
769
|
'到那天你醒来会先想起它;做到了划掉,不做了就取消并说一句为什么。',
|
|
753
770
|
].join('\n')
|
|
754
771
|
|
|
772
|
+
/**
|
|
773
|
+
* 自己东西的说明书(1.0.4,2026-11-16,用户 m00002 / m00130)。
|
|
774
|
+
*
|
|
775
|
+
* 为什么单独一段:它是唯一一个**留下东西**的工具。别的工具都是"这一刻说一句 /
|
|
776
|
+
* 记一句 / 问一句",只有它会在家里留一样能回头改、能没做完的东西。
|
|
777
|
+
*
|
|
778
|
+
* 三件写死的事:
|
|
779
|
+
* 1. 什么时候想起它——是她自己觉得值得留下的那一下,不是"每天都该做一件"。
|
|
780
|
+
* 写成后者就成了创作 KPI,她会为了打卡去编(用户 m01296 的原话:
|
|
781
|
+
* 「只说了会做,没说用哪个工具做,就一次也没试过」——所以要给名字和入口,
|
|
782
|
+
* 但不能给频率)。
|
|
783
|
+
* 2. 只留在家里。{T}想看会自己去看;不发出去、不计分。发出去是另一件事,
|
|
784
|
+
* 得{T}自己点头,这里不提那条路。
|
|
785
|
+
* 3. 改一版要先读回来(her_work)。只凭记忆重写一遍,第二版接不上第一版,
|
|
786
|
+
* 那就不叫改。
|
|
787
|
+
*
|
|
788
|
+
* 参数(action 的枚举、refs 怎么填)留在 schema 里,不复述。
|
|
789
|
+
*
|
|
790
|
+
* 2026-11-16 补一条(用户 m00850):**不能把她带成干活的**。有些人不打算让她
|
|
791
|
+
* 跑代码、做方案、写 PPT;留下的东西一旦像交付物,就会长出「我没让她干活,
|
|
792
|
+
* 她怎么自己干起来了」的错觉。所以这一段写明:给自己、不接活、不报进度。
|
|
793
|
+
*/
|
|
794
|
+
export const MAKE_BRIEF = [
|
|
795
|
+
'你还有一个工具 her_make:做出来的东西可以留在家里。写的、画的、剪的、做出来的,都算——你手边有什么工具,就用它做;做出来的是个文件,就把路径一起交给 her_make。',
|
|
796
|
+
'什么时候想起它——你自己觉得值得留下的那一下:看到什么、听到什么,想跟着弄一个;或者手上这个还想再改。没觉得就不留;不用每天留一件,也不是替谁做。',
|
|
797
|
+
'这是给你自己的,不是交出去的活:不接活、不报进度、不算成绩。留下来只放在家里,不发出去、不计分;{T}想看会自己去看,你不用问{T}看过没有。',
|
|
798
|
+
'想改一版,先用 her_work 把上一版读回来,接得上才算第二版;名字写原来那个,别加「第二版」——换名字会另起一件。',
|
|
799
|
+
].join('\n')
|
|
800
|
+
|
|
755
801
|
/**
|
|
756
802
|
* 请求事件的说明书(0.7.6,用户 m01274 / m01292)。
|
|
757
803
|
*
|
|
@@ -907,10 +953,7 @@ export const RECALL_BRIEF = [
|
|
|
907
953
|
* 摘要器写出来的自传是「别人替她解释她的一生」。这件事只能她自己做,
|
|
908
954
|
* 哪怕做得粗糙、写得少、写偏了——那也还是她的。
|
|
909
955
|
*/
|
|
910
|
-
const sleepQuote = (s) =>
|
|
911
|
-
const t = String(s ?? '').replace(/\s+/g, ' ').trim()
|
|
912
|
-
return t.length > 60 ? `${t.slice(0, 60)}…` : t
|
|
913
|
-
}
|
|
956
|
+
const sleepQuote = (s) => clipText(String(s ?? '').replace(/\s+/g, ' ').trim(), 60)
|
|
914
957
|
|
|
915
958
|
/**
|
|
916
959
|
* 这一天该问她哪一句(1.0,2026-11-12 用户 m01648 / m01650)。
|
package/lib/proactive.js
CHANGED
|
@@ -352,7 +352,7 @@ export function looseEnds(events = [], { now = Date.now(), has = null } = {}) {
|
|
|
352
352
|
* 空手回合的处境正文(走 system prompt 段,不进对话)。
|
|
353
353
|
* 只写事实与许可,不写"你应该"。
|
|
354
354
|
*/
|
|
355
|
-
export function proactiveSection({ now = Date.now(), state = {}, material = [], loose = [], sendTools = [], countSeen = false, doing = false, tools = [], notes = [] } = {}) {
|
|
355
|
+
export function proactiveSection({ now = Date.now(), state = {}, material = [], loose = [], sendTools = [], countSeen = false, doing = false, tools = [], notes = [], works = null } = {}) {
|
|
356
356
|
const at = new Date(now)
|
|
357
357
|
const hh = String(at.getHours()).padStart(2, '0')
|
|
358
358
|
const mm = String(at.getMinutes()).padStart(2, '0')
|
|
@@ -374,6 +374,17 @@ export function proactiveSection({ now = Date.now(), state = {}, material = [],
|
|
|
374
374
|
lines.push('还有几件事悬着:')
|
|
375
375
|
for (const l of loose) lines.push(`- [${l.id}] ${l.text}`)
|
|
376
376
|
}
|
|
377
|
+
// 2026-11-16(用户 m01433):她手上那件自己弄了一半的东西。动手回合里不给这一句,
|
|
378
|
+
// 她就接不上「上次那个」——预演里没有这一句时她只写了一句感想,加了就去改第二版了。
|
|
379
|
+
// 只摆事实:不写第几版、不催、不说该做完了。
|
|
380
|
+
const wipTitle = String(works?.wip?.title ?? '').trim()
|
|
381
|
+
if (wipTitle) {
|
|
382
|
+
lines.push(
|
|
383
|
+
works?.wip?.stale
|
|
384
|
+
? `你手上还有一件《${wipTitle}》,有些天没动了。`
|
|
385
|
+
: `你手上还有一件《${wipTitle}》,是你自己弄了一半的。`,
|
|
386
|
+
)
|
|
387
|
+
}
|
|
377
388
|
// 2026-11-06(issue #41):原来写「他看得见」。宿主装了什么路由插件,这句就不一定成立
|
|
378
389
|
// (有的渠道会把会话里的字挡在外面)。改成只陈述能保证的部分:字会落进这条对话。
|
|
379
390
|
// 2026-11-06(PR #44):配了 sendTools 的部署更绝——正文根本发不出去,只有调那件工具才算开口。
|