@ssamurias/dsh-fish 1.0.2 → 1.0.4
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 +64 -0
- package/README.md +103 -14
- package/RELEASE-NOTES-1.0.3.md +91 -0
- package/RELEASE-NOTES-1.0.4.md +80 -0
- package/docs/composite-pressure-v0.1.md +23 -0
- package/docs/composite-pressure-v0.2.md +18 -0
- package/docs/pressure-backtest-v0.1.md +19 -0
- package/docs/session-capacity-advice-v0.1.md +17 -0
- package/docs/session-pressure-design-v1.1.md +1173 -0
- package/docs/session-pressure-ui-v0.3.md +28 -0
- package/docs/tool-retention-diagnostics-v2.md +13 -0
- package/lib/autobackup.js +14 -2
- package/lib/backup.js +141 -12
- package/lib/bili.js +4 -2
- package/lib/browse.js +55 -11
- package/lib/capture.js +41 -9
- package/lib/client.js +2260 -55
- package/lib/cloudbackup.js +24 -1
- package/lib/clouddrive.js +4 -1
- package/lib/compact.js +28 -11
- package/lib/cue.js +114 -0
- package/lib/derive.js +48 -5
- package/lib/desk.js +19 -1
- package/lib/doing.js +1 -1
- package/lib/dreamtable.js +5 -4
- package/lib/drive.js +72 -13
- package/lib/generator.js +1 -1
- package/lib/handoff.js +34 -16
- package/lib/home.js +3 -1
- package/lib/identity.js +15 -0
- package/lib/index.js +7 -1
- package/lib/interest.js +38 -0
- package/lib/look.js +7 -0
- package/lib/make.js +214 -0
- package/lib/note.js +163 -39
- package/lib/observe.js +202 -4
- package/lib/persona.js +66 -13
- package/lib/proactive.js +17 -1
- package/lib/restrict.js +9 -2
- package/lib/sametopic.js +94 -0
- package/lib/scheduler.js +301 -16
- package/lib/selfdoc.js +12 -3
- package/lib/session-pressure-analysis.js +296 -0
- package/lib/session-pressure-data.js +239 -0
- package/lib/session-pressure-formulas.js +280 -0
- package/lib/session-pressure-load.js +110 -0
- package/lib/session-pressure.js +706 -0
- package/lib/settings.js +8 -1
- package/lib/sleepfact.js +110 -0
- package/lib/sub.js +9 -7
- package/lib/turns.js +8 -1
- package/lib/video.js +75 -42
- package/lib/whatseen.js +24 -2
- package/lib/wiki.js +1677 -0
- package/lib/wikiserve.js +148 -0
- package/lib/works.js +526 -0
- package/media/feedback-qr.jpg +0 -0
- package/media/principle-drive.svg +2 -2
- package/media/principle-memory.svg +1 -1
- package/package.json +1 -1
- package/scripts/sync-pressure-formulas.mjs +17 -0
package/lib/note.js
CHANGED
|
@@ -90,6 +90,10 @@ export function normalizeNote(raw) {
|
|
|
90
90
|
text: text.slice(0, NOTE_TEXT_MAX),
|
|
91
91
|
// 没日子就是空串,不是 null——落盘形状统一,人打开文件看得明白
|
|
92
92
|
due: isDue(raw.due) ? String(raw.due) : '',
|
|
93
|
+
// 在等某件事:写一句在等什么;这类便条不用日子也会在醒来时摆出来。
|
|
94
|
+
waiting: String(raw.waiting ?? '').replace(/\s+/g, ' ').trim().slice(0, NOTE_TEXT_MAX),
|
|
95
|
+
// 划掉时顺手写的一句「怎么算完的」;不写就是空串。
|
|
96
|
+
doneNote: String(raw.doneNote ?? '').replace(/\s+/g, ' ').trim().slice(0, NOTE_TEXT_MAX),
|
|
93
97
|
created: String(raw.created ?? '') || new Date().toISOString(),
|
|
94
98
|
status,
|
|
95
99
|
reason: raw.reason == null ? null : String(raw.reason).slice(0, 200),
|
|
@@ -133,6 +137,45 @@ export function newNoteId(now = Date.now()) {
|
|
|
133
137
|
return `note-${now}-${Math.random().toString(36).slice(2, 8)}`
|
|
134
138
|
}
|
|
135
139
|
|
|
140
|
+
/** 便条在界面上的短编号:`#a1b2`。她按这个指认,不用一字不差抄原话。 */
|
|
141
|
+
export function noteRef(n) {
|
|
142
|
+
const id = String(n?.id ?? '').replace(/^note-/, '')
|
|
143
|
+
return `#${(id || '?').slice(-4)}`
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** 最后动过:记下、改一句、记一笔进展、划掉,取最晚那次。 */
|
|
147
|
+
export function lastTouched(n) {
|
|
148
|
+
const stamps = [
|
|
149
|
+
n?.created,
|
|
150
|
+
n?.revisedAt,
|
|
151
|
+
...(Array.isArray(n?.progress) ? n.progress.map((p) => p?.at) : []),
|
|
152
|
+
n?.closedAt,
|
|
153
|
+
]
|
|
154
|
+
.map((s) => Date.parse(String(s ?? '')))
|
|
155
|
+
.filter((ms) => Number.isFinite(ms))
|
|
156
|
+
if (!stamps.length) return ''
|
|
157
|
+
return new Date(Math.max(...stamps)).toISOString()
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** 把时间写成她一眼能读的年龄:今天 / 昨天 / 3 天前 / 11-02。 */
|
|
161
|
+
export function ageLabel(at, now = Date.now()) {
|
|
162
|
+
const ms = Date.parse(String(at ?? ''))
|
|
163
|
+
if (!Number.isFinite(ms)) return ''
|
|
164
|
+
const then = dateKey(new Date(ms))
|
|
165
|
+
const today = dateKey(now instanceof Date ? now : new Date(now))
|
|
166
|
+
const days = daysBetween(then, today)
|
|
167
|
+
if (!Number.isFinite(days) || days <= 0) return '今天'
|
|
168
|
+
if (days === 1) return '昨天'
|
|
169
|
+
if (days < 7) return `${days} 天前`
|
|
170
|
+
return then.slice(5)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** 一张便条的年龄尾注;没有时间就一个字都不加。 */
|
|
174
|
+
export function touchedLabel(n, now = Date.now()) {
|
|
175
|
+
const age = ageLabel(lastTouched(n), now)
|
|
176
|
+
return age ? `(最后动过:${age})` : ''
|
|
177
|
+
}
|
|
178
|
+
|
|
136
179
|
/** 两个日期键之间差几天(按本地日历日,不做时区换算)。b - a。 */
|
|
137
180
|
export function daysBetween(a, b) {
|
|
138
181
|
const cut = (s) => {
|
|
@@ -214,7 +257,7 @@ export function pickNudge(notes, now = new Date(), seen = new Map()) {
|
|
|
214
257
|
const today = dateKey(now instanceof Date ? now : new Date(now))
|
|
215
258
|
const open = []
|
|
216
259
|
for (const n of notes ?? []) {
|
|
217
|
-
if (!n || n.status !== 'open' || isDue(n.due)) continue
|
|
260
|
+
if (!n || n.status !== 'open' || isDue(n.due) || n.waiting) continue
|
|
218
261
|
const created = String(n.created ?? '').slice(0, 10)
|
|
219
262
|
const from = seen.get(n.id) ?? created
|
|
220
263
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(from)) continue
|
|
@@ -246,42 +289,76 @@ export function pickNudge(notes, now = new Date(), seen = new Map()) {
|
|
|
246
289
|
export function renderNotes(notes, now = new Date(), { seen = new Map() } = {}) {
|
|
247
290
|
const today = dateKey(now instanceof Date ? now : new Date(now))
|
|
248
291
|
const due = []
|
|
292
|
+
const waiting = []
|
|
249
293
|
for (const n of notes ?? []) {
|
|
250
294
|
if (!n || n.status !== 'open') continue
|
|
295
|
+
if (n.waiting) {
|
|
296
|
+
waiting.push(n)
|
|
297
|
+
continue
|
|
298
|
+
}
|
|
251
299
|
if (!isDue(n.due)) continue
|
|
252
300
|
const late = daysBetween(n.due, today)
|
|
253
301
|
if (late < 0) continue // 还没到日子:不到期不上桌
|
|
254
302
|
due.push({ ...n, late })
|
|
255
303
|
}
|
|
256
304
|
|
|
257
|
-
//
|
|
258
|
-
const nudge = pickNudge(notes, now, seen)
|
|
259
|
-
if (!due.length && !nudge) return ''
|
|
305
|
+
// 有到期或在等的,就把没日子的收起来;一张都没有时,才提那张隔些天提一次的。
|
|
306
|
+
const nudge = due.length || waiting.length ? null : pickNudge(notes, now, seen)
|
|
307
|
+
if (!due.length && !waiting.length && !nudge) return ''
|
|
260
308
|
|
|
261
309
|
const lines = []
|
|
262
|
-
if (due.length) {
|
|
263
|
-
//
|
|
310
|
+
if (due.length || waiting.length) {
|
|
311
|
+
// 最欠的排最前:到期日早的在前,同一天按记下来的时间;在等的排在到期的后面。
|
|
264
312
|
due.sort((a, b) => (a.due < b.due ? -1 : a.due > b.due ? 1 : String(a.created).localeCompare(String(b.created))))
|
|
265
|
-
|
|
266
|
-
|
|
313
|
+
waiting.sort((a, b) => String(a.created).localeCompare(String(b.created)))
|
|
314
|
+
const all = [...due, ...waiting]
|
|
315
|
+
const shown = all.slice(0, NOTE_SHOW_MAX)
|
|
316
|
+
lines.push(`(压着${cnCount(all.length)}张便条)`)
|
|
267
317
|
for (const n of shown) {
|
|
318
|
+
const ref = noteRef(n)
|
|
319
|
+
const age = ageLabel(lastTouched(n), now)
|
|
320
|
+
const touched = age ? `最后动过:${age}` : ''
|
|
321
|
+
if (n.waiting) {
|
|
322
|
+
// 在等的事可能同时有到期日;两样都给她,不让她在「在等」和「到期」之间二选一。
|
|
323
|
+
const bits = []
|
|
324
|
+
if (touched) bits.push(touched)
|
|
325
|
+
if (isDue(n.due)) {
|
|
326
|
+
const late = daysBetween(n.due, today)
|
|
327
|
+
const mmdd = `${n.due.slice(5, 7)}-${n.due.slice(8, 10)}`
|
|
328
|
+
bits.push(
|
|
329
|
+
late < 0
|
|
330
|
+
? `到期:${mmdd}(还没到)`
|
|
331
|
+
: late === 0
|
|
332
|
+
? `到期:${mmdd}(今天)`
|
|
333
|
+
: `到期:${mmdd},晚了${cnNum(late)}天`,
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
const mark = bits.length ? `(${bits.join(';')})` : ''
|
|
337
|
+
lines.push(`${ref} 在等:${n.waiting}——${n.text}${mark}`)
|
|
338
|
+
continue
|
|
339
|
+
}
|
|
268
340
|
const mmdd = `${n.due.slice(5, 7)}-${n.due.slice(8, 10)}`
|
|
269
341
|
const tail = n.late === 0 ? '就是今天。' : `晚了${cnNum(n.late)}天。`
|
|
270
342
|
// 有进展的那张,把最近一笔缀在后面:她一眼看见的是「这十天走到哪儿」,
|
|
271
343
|
// 不是又从头读一遍这件事。只给最近一笔,不报条数(那是流水账,也是状态)。
|
|
272
344
|
const last = lastProgress(n)
|
|
273
|
-
const
|
|
274
|
-
|
|
345
|
+
const bits = []
|
|
346
|
+
if (last) bits.push(`最近:${last.text}`)
|
|
347
|
+
if (touched) bits.push(touched)
|
|
348
|
+
const mark = bits.length ? `(${bits.join(';')})` : ''
|
|
349
|
+
lines.push(`${ref} ${mmdd} ${n.text}${mark},${tail}`)
|
|
275
350
|
}
|
|
276
|
-
const rest =
|
|
351
|
+
const rest = all.length - shown.length
|
|
277
352
|
if (rest > 0) lines.push(`还有${cnCount(rest)}条没列出来,都在便条里。`)
|
|
278
353
|
}
|
|
279
354
|
|
|
280
355
|
if (nudge) {
|
|
281
356
|
if (lines.length) lines.push('')
|
|
282
357
|
const mmdd = String(nudge.created ?? '').slice(5, 10)
|
|
358
|
+
const age = ageLabel(lastTouched(nudge), now)
|
|
359
|
+
const touched = age ? `;最后动过:${age}` : ''
|
|
283
360
|
lines.push('(便条里有一张没写日子的)')
|
|
284
|
-
lines.push(`${mmdd} 你记着:${nudge.text}
|
|
361
|
+
lines.push(`${noteRef(nudge)} ${mmdd} 你记着:${nudge.text}(隔些天提一次${touched})`)
|
|
285
362
|
}
|
|
286
363
|
return lines.join('\n')
|
|
287
364
|
}
|
|
@@ -296,7 +373,7 @@ const mutateNotes = (root, fn) => mutateJson(notesPath(root), fn)
|
|
|
296
373
|
* 写一张纸条。永不抛(失败只回 note)。
|
|
297
374
|
* @returns {Promise<{ok:boolean, id:string, note:string}>}
|
|
298
375
|
*/
|
|
299
|
-
export async function addNote(root, { text, due } = {}) {
|
|
376
|
+
export async function addNote(root, { text, due, waiting } = {}) {
|
|
300
377
|
const body = String(text ?? '').replace(/\s+/g, ' ').trim()
|
|
301
378
|
if (!body) return { ok: false, id: '', note: '空白的,没记。' }
|
|
302
379
|
if (body.length > NOTE_TEXT_MAX) {
|
|
@@ -306,6 +383,10 @@ export async function addNote(root, { text, due } = {}) {
|
|
|
306
383
|
if (day && !isDue(day)) {
|
|
307
384
|
return { ok: false, id: '', note: '日子要写成 2026-11-05 这样,或者干脆不写。' }
|
|
308
385
|
}
|
|
386
|
+
const wait = String(waiting ?? '').replace(/\s+/g, ' ').trim()
|
|
387
|
+
if (wait.length > NOTE_TEXT_MAX) {
|
|
388
|
+
return { ok: false, id: '', note: `「在等什么」压到 ${NOTE_TEXT_MAX} 字以内。` }
|
|
389
|
+
}
|
|
309
390
|
|
|
310
391
|
try {
|
|
311
392
|
return await mutateNotes(root, async () => {
|
|
@@ -320,6 +401,7 @@ export async function addNote(root, { text, due } = {}) {
|
|
|
320
401
|
id: newNoteId(),
|
|
321
402
|
text: body,
|
|
322
403
|
due: day,
|
|
404
|
+
waiting: wait,
|
|
323
405
|
created: new Date().toISOString(),
|
|
324
406
|
status: 'open',
|
|
325
407
|
})
|
|
@@ -353,23 +435,28 @@ function findByText(notes, body) {
|
|
|
353
435
|
* 她有的只是自己写过的那句话,所以按原话找;id 这条路留着,value 里还拿得到。
|
|
354
436
|
* @returns {Promise<{ok:boolean, id:string, note:string}>}
|
|
355
437
|
*/
|
|
356
|
-
export async function closeNote(root, { id, text } = {}) {
|
|
438
|
+
export async function closeNote(root, { id, text, note } = {}) {
|
|
357
439
|
const key = String(id ?? '').trim()
|
|
358
440
|
// 和 addNote 同一个规整:落盘的字就是这么规整过的,多个空格、换行不该让她关不掉
|
|
359
441
|
const body = String(text ?? '').replace(/\s+/g, ' ').trim()
|
|
442
|
+
const how = String(note ?? '').replace(/\s+/g, ' ').trim()
|
|
360
443
|
if (!key && !body) return { ok: false, id: '', note: '要划掉哪一张?把当时记的那句话告诉我。' }
|
|
444
|
+
if (how.length > NOTE_TEXT_MAX) {
|
|
445
|
+
return { ok: false, id: '', note: `「怎么算完的」压到 ${NOTE_TEXT_MAX} 字以内。` }
|
|
446
|
+
}
|
|
361
447
|
try {
|
|
362
448
|
return await mutateNotes(root, async () => {
|
|
363
449
|
const notes = await readNotes(root)
|
|
364
|
-
const hit = notes
|
|
450
|
+
const hit = locate(notes, { id: key, text: body })
|
|
365
451
|
if (!hit) {
|
|
366
|
-
return { ok: false, id: '', note: '
|
|
452
|
+
return { ok: false, id: '', note: '便条里没有这一张。可以用 #编号 指认;没有编号就把当时记的那句原话(或它开头的一段)给我。' }
|
|
367
453
|
}
|
|
368
454
|
if (hit.status === 'done') return { ok: true, id: hit.id, note: '已经划掉过了。' }
|
|
369
455
|
// 放下了的不是「做完了」,别把「放下」改写成「划掉」(issue #82)。
|
|
370
456
|
if (hit.status === 'dropped') return { ok: false, id: '', note: '这张已经放下了,不用再划。' }
|
|
371
457
|
hit.status = 'done'
|
|
372
458
|
hit.closedAt = new Date().toISOString()
|
|
459
|
+
if (how) hit.doneNote = how
|
|
373
460
|
await writeNotes(root, notes)
|
|
374
461
|
// issue #133 的 C:回执原来只有一句「已划掉。」,进回忆(lib/use.js 记的
|
|
375
462
|
// `use:her_note ok …`)就是一行没有内容的账——她翻到只知道「我那天划过一张」,
|
|
@@ -386,25 +473,34 @@ export async function closeNote(root, { id, text } = {}) {
|
|
|
386
473
|
// 所以对外只认原话;id 这条路留着给代码用,不进说明书。
|
|
387
474
|
|
|
388
475
|
/** list 里的一行。关掉的那几种带上关掉的日期,放下的还要带上那句为什么。 */
|
|
389
|
-
function listLine(n) {
|
|
476
|
+
function listLine(n, now = Date.now()) {
|
|
390
477
|
// closedAt 是带 Z 的 UTC 时刻,日期要按本地日历取(同 issue #19):直接切前 10 位,
|
|
391
478
|
// 东八区凌晨到早上 8 点前关掉的会写成前一天。解析不出就不写日期。
|
|
392
479
|
const md = (iso) => {
|
|
393
480
|
const ms = Date.parse(String(iso ?? ''))
|
|
394
481
|
return Number.isFinite(ms) ? dateKey(new Date(ms)).slice(5) : ''
|
|
395
482
|
}
|
|
483
|
+
const ref = noteRef(n)
|
|
484
|
+
const age = ageLabel(lastTouched(n), now)
|
|
485
|
+
const touched = age ? `最后动过:${age}` : ''
|
|
396
486
|
if (n.status === 'done') {
|
|
397
487
|
const at = md(n.closedAt)
|
|
398
|
-
|
|
488
|
+
const how = String(n.doneNote ?? '').trim()
|
|
489
|
+
const tail = [at ? `${at} 划掉` : '', how].filter(Boolean).join(':')
|
|
490
|
+
return `${ref} ✓ ${n.text}${tail ? `(${tail})` : ''}`
|
|
399
491
|
}
|
|
400
492
|
if (n.status === 'dropped') {
|
|
401
493
|
const at = md(n.closedAt)
|
|
402
|
-
return
|
|
494
|
+
return `${ref} ✗ ${n.text}${at ? `(${at} 放下)` : ''}${n.reason ? `—— ${n.reason}` : ''}`
|
|
403
495
|
}
|
|
404
496
|
// 翻到一张做了一半的:把最近一笔缀在后面,才看得出「它不是又摆回来了,是往前走了」。
|
|
405
497
|
const last = lastProgress(n)
|
|
406
|
-
const
|
|
407
|
-
|
|
498
|
+
const bits = []
|
|
499
|
+
if (last) bits.push(`最近:${last.text}`)
|
|
500
|
+
if (touched) bits.push(touched)
|
|
501
|
+
const mark = bits.length ? `(${bits.join(';')})` : ''
|
|
502
|
+
const head = n.waiting ? `(在等:${n.waiting}${n.due ? `;到期 ${n.due.slice(5)}` : ''})` : n.due ? n.due.slice(5) : '(没日子)'
|
|
503
|
+
return `${ref} ${head} ${n.text}${mark}`
|
|
408
504
|
}
|
|
409
505
|
|
|
410
506
|
/** 还没关掉的先按到期日(没日子的排最后),关掉的按关掉的时间倒序。 */
|
|
@@ -459,7 +555,8 @@ export async function listNotes(root, { filter = 'open', offset = 0, limit = NOT
|
|
|
459
555
|
if (!all.length) return { ok: true, text: EMPTY_LIST[f], note: '' }
|
|
460
556
|
const page = all.slice(off, off + lim)
|
|
461
557
|
if (!page.length) return { ok: true, text: '后面没有了。', note: '' }
|
|
462
|
-
const
|
|
558
|
+
const now = Date.now()
|
|
559
|
+
const lines = page.map((n) => listLine(n, now))
|
|
463
560
|
const rest = all.length - (off + page.length)
|
|
464
561
|
if (off > 0) lines.unshift(`(从第${cnNum(off + 1)}张接着看)`)
|
|
465
562
|
if (rest > 0) lines.push('……后面还有,没一次列完(offset 往后翻)。')
|
|
@@ -475,8 +572,19 @@ function locate(notes, { id, text } = {}) {
|
|
|
475
572
|
if (key) {
|
|
476
573
|
const byId = notes.find((n) => n.id === key)
|
|
477
574
|
if (byId) return byId
|
|
575
|
+
// `#abcd` 是她从 list / 醒来那行看到的短编号;按它指认,不用抄原话。
|
|
576
|
+
const ref = key.startsWith('#') ? key.slice(1).toLowerCase() : ''
|
|
577
|
+
if (ref) {
|
|
578
|
+
const byRef = notes.find((n) => noteRef(n).slice(1).toLowerCase() === ref)
|
|
579
|
+
if (byRef) return byRef
|
|
580
|
+
}
|
|
478
581
|
}
|
|
479
582
|
const body = String(text ?? '').replace(/\s+/g, ' ').trim()
|
|
583
|
+
if (body.startsWith('#')) {
|
|
584
|
+
const ref = body.slice(1).toLowerCase()
|
|
585
|
+
const byRef = notes.find((n) => noteRef(n).slice(1).toLowerCase() === ref)
|
|
586
|
+
if (byRef) return byRef
|
|
587
|
+
}
|
|
480
588
|
return body ? findByText(notes, body) ?? null : null
|
|
481
589
|
}
|
|
482
590
|
|
|
@@ -487,15 +595,21 @@ function locate(notes, { id, text } = {}) {
|
|
|
487
595
|
* `due` 不给就不动日子,给空串是去掉日子,给日期是改期。
|
|
488
596
|
* @returns {Promise<{ok:boolean, id:string, note:string, echo?:string}>}
|
|
489
597
|
*/
|
|
490
|
-
export async function updateNote(root, { id, text, newText, due } = {}) {
|
|
598
|
+
export async function updateNote(root, { id, text, newText, due, waiting } = {}) {
|
|
491
599
|
const key = String(id ?? '').trim()
|
|
492
600
|
const body = String(text ?? '').replace(/\s+/g, ' ').trim()
|
|
493
601
|
const next = String(newText ?? '').replace(/\s+/g, ' ').trim()
|
|
494
|
-
if (!key && !body) return { ok: false, id: '', note: '
|
|
495
|
-
if (!next
|
|
602
|
+
if (!key && !body) return { ok: false, id: '', note: '要改哪一张?可以用 #编号,或把当时记的那句话告诉我。' }
|
|
603
|
+
if (!next && waiting === undefined && due === undefined) {
|
|
604
|
+
return { ok: false, id: '', note: '改成什么?把新的那句话告诉我。' }
|
|
605
|
+
}
|
|
496
606
|
if (next.length > NOTE_TEXT_MAX) {
|
|
497
607
|
return { ok: false, id: '', note: `太长了,压到 ${NOTE_TEXT_MAX} 字以内。` }
|
|
498
608
|
}
|
|
609
|
+
const wait = waiting === undefined ? undefined : String(waiting ?? '').replace(/\s+/g, ' ').trim()
|
|
610
|
+
if (wait !== undefined && wait.length > NOTE_TEXT_MAX) {
|
|
611
|
+
return { ok: false, id: '', note: `「在等什么」压到 ${NOTE_TEXT_MAX} 字以内。` }
|
|
612
|
+
}
|
|
499
613
|
const day = due === undefined ? undefined : String(due ?? '').trim()
|
|
500
614
|
if (day !== undefined && day && !isDue(day)) {
|
|
501
615
|
return { ok: false, id: '', note: '日子要写成 2026-11-05 这样,或者给空串把日子去掉。' }
|
|
@@ -505,11 +619,12 @@ export async function updateNote(root, { id, text, newText, due } = {}) {
|
|
|
505
619
|
const notes = await readNotes(root)
|
|
506
620
|
const hit = locate(notes, { id: key, text: body })
|
|
507
621
|
if (!hit) {
|
|
508
|
-
return { ok: false, id: '', note: '
|
|
622
|
+
return { ok: false, id: '', note: '便条里没有这一张。可以用 #编号 指认,或用当时记的原话。' }
|
|
509
623
|
}
|
|
510
624
|
if (hit.status === 'done') return { ok: false, id: '', note: '这张已经划掉了,改不了。' }
|
|
511
625
|
if (hit.status === 'dropped') return { ok: false, id: '', note: '这张已经放下了,改不了。' }
|
|
512
|
-
hit.text = next.slice(0, NOTE_TEXT_MAX)
|
|
626
|
+
if (next) hit.text = next.slice(0, NOTE_TEXT_MAX)
|
|
627
|
+
if (wait !== undefined) hit.waiting = wait
|
|
513
628
|
if (day !== undefined) hit.due = day
|
|
514
629
|
hit.revisedAt = new Date().toISOString()
|
|
515
630
|
await writeNotes(root, notes)
|
|
@@ -544,7 +659,7 @@ export async function logProgress(root, { id, text, progress } = {}) {
|
|
|
544
659
|
const notes = await readNotes(root)
|
|
545
660
|
const hit = locate(notes, { id: key, text: body })
|
|
546
661
|
if (!hit) {
|
|
547
|
-
return { ok: false, id: '', note: '
|
|
662
|
+
return { ok: false, id: '', note: '便条里没有这一张。可以用 #编号 指认,或把当时记的那句原话(或开头一段)给我。' }
|
|
548
663
|
}
|
|
549
664
|
if (hit.status === 'done') return { ok: false, id: '', note: '这张已经划掉了,记不上进展。要接着做就重新记一张。' }
|
|
550
665
|
if (hit.status === 'dropped') return { ok: false, id: '', note: '这张已经放下了,记不上进展。' }
|
|
@@ -580,7 +695,7 @@ export async function dropNote(root, { id, text, reason } = {}) {
|
|
|
580
695
|
const notes = await readNotes(root)
|
|
581
696
|
const hit = locate(notes, { id: key, text: body })
|
|
582
697
|
if (!hit) {
|
|
583
|
-
return { ok: false, id: '', note: '
|
|
698
|
+
return { ok: false, id: '', note: '便条里没有这一张。可以用 #编号 指认,或把当时记的那句原话(或开头一段)给我。' }
|
|
584
699
|
}
|
|
585
700
|
if (hit.status === 'dropped') return { ok: true, id: hit.id, note: '之前就放下了。' }
|
|
586
701
|
if (hit.status === 'done') return { ok: false, id: '', note: '这张已经划掉了,不用再放下。' }
|
|
@@ -615,11 +730,12 @@ export function registerNote(ctx, deps = {}) {
|
|
|
615
730
|
name: 'her_note',
|
|
616
731
|
description:
|
|
617
732
|
'醒来时摆在你最前面的那叠便条:记一张还没做的事、翻一翻有哪些、往一张上面记进展、改那一句、划掉做完的、或者放下决定不做的。' +
|
|
618
|
-
'记的时候给 text(和日子 due
|
|
733
|
+
'记的时候给 text(和日子 due,可以不给);划掉、改、放下都可以用 list 里看到的 #编号 指认,不必一字不差抄原话;' +
|
|
734
|
+
'划掉时还可以顺手写一句 note,记下「怎么算完的」;' +
|
|
619
735
|
'看便条有哪些给 action:"list"(filter 可以选 open / due / done / dropped / all,列不完用 offset 往后翻);' +
|
|
620
|
-
'一件事做了一半,给 action:"log"
|
|
621
|
-
'事情本身变了(目标改了、只剩最后一段),给 action:"update"
|
|
622
|
-
'
|
|
736
|
+
'一件事做了一半,给 action:"log":用 #编号 或原话指认是哪一张,progress 写这一回做到哪儿了(只追一笔,不覆盖之前那些);' +
|
|
737
|
+
'事情本身变了(目标改了、只剩最后一段),给 action:"update":用 #编号 或原话指认,newText 写新的;只改 waiting/due 时可以不给 newText;' +
|
|
738
|
+
'放下的给 action:"drop"(同样用 #编号 或原话指认,reason 写一句为什么)。',
|
|
623
739
|
parameters: toJsonSchema({
|
|
624
740
|
action: {
|
|
625
741
|
type: 'string',
|
|
@@ -629,14 +745,18 @@ export function registerNote(ctx, deps = {}) {
|
|
|
629
745
|
},
|
|
630
746
|
text: {
|
|
631
747
|
type: 'string',
|
|
632
|
-
description: '
|
|
748
|
+
description: '要记下来的那件事,一句话。划掉、改、放下的时候用 #编号 或当时记的那句话指认。',
|
|
749
|
+
},
|
|
750
|
+
waiting: {
|
|
751
|
+
type: 'string',
|
|
752
|
+
description: '在等什么(比如「等快递」「等他回话」)。写了就先摆「在等」,日子 due 可以不给。',
|
|
633
753
|
},
|
|
634
754
|
due: {
|
|
635
755
|
type: 'string',
|
|
636
756
|
description:
|
|
637
757
|
'哪天该做,写成 2026-11-05。不写就不会在醒来时出现,只能自己 list 看;改一句时给空串是把日子去掉。',
|
|
638
758
|
},
|
|
639
|
-
id: { type: 'string', description: '
|
|
759
|
+
id: { type: 'string', description: '这张纸条的编号,形如 #abcd。手里没有就用 text 的原话。' },
|
|
640
760
|
status: { type: 'string', enum: ['done'], description: '划掉的时候给 done。' },
|
|
641
761
|
filter: {
|
|
642
762
|
type: 'string',
|
|
@@ -645,7 +765,11 @@ export function registerNote(ctx, deps = {}) {
|
|
|
645
765
|
},
|
|
646
766
|
offset: { type: 'integer', description: 'list 时从第几张往后翻,默认从最前面。' },
|
|
647
767
|
limit: { type: 'integer', description: 'list 时一次最多列几张,默认 20。' },
|
|
648
|
-
newText: { type: 'string', description: 'update
|
|
768
|
+
newText: { type: 'string', description: 'update 时改成哪句话;只改 waiting/due 时可以不给。' },
|
|
769
|
+
note: {
|
|
770
|
+
type: 'string',
|
|
771
|
+
description: 'done 时可选:顺手写一句「怎么算完的」,以后翻到才知道当时是怎么解决的。',
|
|
772
|
+
},
|
|
649
773
|
progress: {
|
|
650
774
|
type: 'string',
|
|
651
775
|
description: 'log 时这一回做到哪儿了,一句话(不超过 120 字)。只说这一步,别重述整件事。',
|
|
@@ -699,7 +823,7 @@ export function registerNote(ctx, deps = {}) {
|
|
|
699
823
|
return { ok: r.ok, id: '', note: r.note, text: r.text }
|
|
700
824
|
}
|
|
701
825
|
if (act === 'update') {
|
|
702
|
-
return updateNote(root, { id: args?.id, text: args?.text, newText: args?.newText, due: args?.due })
|
|
826
|
+
return updateNote(root, { id: args?.id, text: args?.text, newText: args?.newText, due: args?.due, waiting: args?.waiting })
|
|
703
827
|
}
|
|
704
828
|
if (act === 'log') {
|
|
705
829
|
return logProgress(root, { id: args?.id, text: args?.text, progress: args?.progress })
|
|
@@ -708,9 +832,9 @@ export function registerNote(ctx, deps = {}) {
|
|
|
708
832
|
return dropNote(root, { id: args?.id, text: args?.text, reason: args?.reason })
|
|
709
833
|
}
|
|
710
834
|
if (act === 'done') {
|
|
711
|
-
return closeNote(root, { id: args?.id, text: args?.text })
|
|
835
|
+
return closeNote(root, { id: args?.id, text: args?.text, note: args?.note })
|
|
712
836
|
}
|
|
713
|
-
return addNote(root, { text: args?.text, due: args?.due })
|
|
837
|
+
return addNote(root, { text: args?.text, due: args?.due, waiting: args?.waiting })
|
|
714
838
|
},
|
|
715
839
|
}),
|
|
716
840
|
)
|