@kanadego/dsh-heartbeat 2.2.1 → 2.4.0
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/README.md +105 -311
- package/USAGE-GUIDE.md +357 -0
- package/client.js +186 -24
- package/dist/{bili-login-XQVEE4M6.js → bili-login-KDDU63Z2.js} +4 -4
- package/dist/{bindings-U2M3CO2D.js → bindings-LTSGGNIH.js} +3 -3
- package/dist/{chunk-LQKOYTRL.js → chunk-4OQXAHU5.js} +2 -2
- package/dist/{chunk-3QJJRXIR.js → chunk-5CVAW5AS.js} +11 -2
- package/dist/chunk-5CVAW5AS.js.map +1 -0
- package/dist/{chunk-IBBAISSW.js → chunk-66IUDHCY.js} +50 -1
- package/dist/chunk-66IUDHCY.js.map +1 -0
- package/dist/{chunk-3DNGY4DS.js → chunk-77UYDI2A.js} +2 -2
- package/dist/{chunk-AT32XCCI.js → chunk-AJ5JAQVB.js} +20 -3
- package/dist/chunk-AJ5JAQVB.js.map +1 -0
- package/dist/chunk-CRRN6UD3.js +389 -0
- package/dist/chunk-CRRN6UD3.js.map +1 -0
- package/dist/{chunk-ECXYNTEV.js → chunk-ERRPMYKB.js} +164 -152
- package/dist/chunk-ERRPMYKB.js.map +1 -0
- package/dist/{chunk-M72T5MZU.js → chunk-GOLMRQRW.js} +3 -2
- package/dist/{chunk-KZLVR4J7.js → chunk-IPTNSXOY.js} +2 -2
- package/dist/chunk-L54R23O2.js +262 -0
- package/dist/chunk-L54R23O2.js.map +1 -0
- package/dist/chunk-MHRAPKES.js +1081 -0
- package/dist/chunk-MHRAPKES.js.map +1 -0
- package/dist/{chunk-SIY3YHFY.js → chunk-MMI6OBEC.js} +2 -2
- package/dist/{chunk-CJK6RTMH.js → chunk-RPWQZYNW.js} +1485 -310
- package/dist/chunk-RPWQZYNW.js.map +1 -0
- package/dist/cli/index.js +244 -36
- package/dist/cli/index.js.map +1 -1
- package/dist/{focus-store-RNHBAFYS.js → focus-store-XGTPIVF6.js} +3 -3
- package/dist/{inbox-ZLX2MH7A.js → inbox-7GGEMBUD.js} +4 -4
- package/dist/index.d.ts +66 -1
- package/dist/index.js +556 -167
- package/dist/index.js.map +1 -1
- package/dist/{migrate-XFZU5EBE.js → migrate-25F53XIC.js} +6 -4
- package/dist/{orchestrator-5BHYQ77Y.js → orchestrator-4PJD7QYO.js} +25 -11
- package/dist/runtime-RGZKOFP3.js +15 -0
- package/dist/snapshot-J6LKNY57.js +27 -0
- package/dist/store-HM6ZMFKS.js +45 -0
- package/package.json +6 -3
- package/dist/chunk-3QJJRXIR.js.map +0 -1
- package/dist/chunk-AT32XCCI.js.map +0 -1
- package/dist/chunk-CJK6RTMH.js.map +0 -1
- package/dist/chunk-DLOYERAK.js +0 -87
- package/dist/chunk-DLOYERAK.js.map +0 -1
- package/dist/chunk-ECXYNTEV.js.map +0 -1
- package/dist/chunk-F2XVKX55.js +0 -413
- package/dist/chunk-F2XVKX55.js.map +0 -1
- package/dist/chunk-IBBAISSW.js.map +0 -1
- package/dist/chunk-N6SMIGYJ.js +0 -393
- package/dist/chunk-N6SMIGYJ.js.map +0 -1
- package/dist/chunk-XYBII5PR.js +0 -602
- package/dist/chunk-XYBII5PR.js.map +0 -1
- package/dist/pool-76VLAZER.js +0 -49
- package/dist/runtime-W2OWJIHY.js +0 -11
- package/dist/snapshot-SU2VGM4C.js +0 -16
- /package/dist/{bili-login-XQVEE4M6.js.map → bili-login-KDDU63Z2.js.map} +0 -0
- /package/dist/{bindings-U2M3CO2D.js.map → bindings-LTSGGNIH.js.map} +0 -0
- /package/dist/{chunk-LQKOYTRL.js.map → chunk-4OQXAHU5.js.map} +0 -0
- /package/dist/{chunk-3DNGY4DS.js.map → chunk-77UYDI2A.js.map} +0 -0
- /package/dist/{chunk-M72T5MZU.js.map → chunk-GOLMRQRW.js.map} +0 -0
- /package/dist/{chunk-KZLVR4J7.js.map → chunk-IPTNSXOY.js.map} +0 -0
- /package/dist/{chunk-SIY3YHFY.js.map → chunk-MMI6OBEC.js.map} +0 -0
- /package/dist/{focus-store-RNHBAFYS.js.map → focus-store-XGTPIVF6.js.map} +0 -0
- /package/dist/{inbox-ZLX2MH7A.js.map → inbox-7GGEMBUD.js.map} +0 -0
- /package/dist/{migrate-XFZU5EBE.js.map → migrate-25F53XIC.js.map} +0 -0
- /package/dist/{orchestrator-5BHYQ77Y.js.map → orchestrator-4PJD7QYO.js.map} +0 -0
- /package/dist/{pool-76VLAZER.js.map → runtime-RGZKOFP3.js.map} +0 -0
- /package/dist/{runtime-W2OWJIHY.js.map → snapshot-J6LKNY57.js.map} +0 -0
- /package/dist/{snapshot-SU2VGM4C.js.map → store-HM6ZMFKS.js.map} +0 -0
package/dist/cli/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
collectMigrationEntries,
|
|
4
4
|
decryptContainer,
|
|
5
5
|
encryptContainer
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-AJ5JAQVB.js";
|
|
7
7
|
import {
|
|
8
8
|
BUNDLED_PRESET_ID,
|
|
9
9
|
EXCERPT_HEADER,
|
|
@@ -13,50 +13,58 @@ import {
|
|
|
13
13
|
describeInstall,
|
|
14
14
|
excerptFilePath,
|
|
15
15
|
installBundledPreset,
|
|
16
|
-
loadPolicy,
|
|
17
16
|
presetStatus,
|
|
18
17
|
readExcerpts,
|
|
19
18
|
removeExcerpt
|
|
20
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-L54R23O2.js";
|
|
21
20
|
import {
|
|
21
|
+
CORRECTIONS_DONE_HEADER,
|
|
22
|
+
CORRECTIONS_HEADER,
|
|
23
|
+
LEDGER_DONE_HEADER,
|
|
24
|
+
activeSeeds,
|
|
25
|
+
addSeed,
|
|
22
26
|
adviseWander,
|
|
23
27
|
appendEntry,
|
|
28
|
+
archiveSeedById,
|
|
29
|
+
archivedSeeds,
|
|
24
30
|
browseStatus,
|
|
25
31
|
completeWander,
|
|
32
|
+
correctionsDoneFilePath,
|
|
33
|
+
correctionsFilePath,
|
|
26
34
|
ensureRegistered,
|
|
35
|
+
gcPool,
|
|
36
|
+
ledgerDoneFilePath,
|
|
27
37
|
ledgerFilePath,
|
|
28
38
|
listWeeklyReports,
|
|
29
39
|
loadInterests,
|
|
30
|
-
|
|
40
|
+
loadPool,
|
|
31
41
|
markDone,
|
|
32
42
|
readLedger,
|
|
33
43
|
readWeeklyReport,
|
|
34
44
|
scanPending,
|
|
45
|
+
seedBookFile,
|
|
46
|
+
seedsFilePath,
|
|
35
47
|
sendNewMessageHint,
|
|
48
|
+
surfaceSeed,
|
|
36
49
|
weeklyDirPath
|
|
37
|
-
} from "../chunk-
|
|
50
|
+
} from "../chunk-MHRAPKES.js";
|
|
38
51
|
import {
|
|
39
52
|
openPath
|
|
40
53
|
} from "../chunk-OCBE2AKW.js";
|
|
41
|
-
import {
|
|
42
|
-
activeSeeds,
|
|
43
|
-
addSeed,
|
|
44
|
-
archiveSeedById,
|
|
45
|
-
archivedSeeds,
|
|
46
|
-
gcPool,
|
|
47
|
-
loadPool,
|
|
48
|
-
seedsFilePath,
|
|
49
|
-
surfaceSeed
|
|
50
|
-
} from "../chunk-N6SMIGYJ.js";
|
|
51
54
|
import {
|
|
52
55
|
appendAuditLine,
|
|
56
|
+
loadPolicy,
|
|
57
|
+
localDayKey,
|
|
58
|
+
pruneAuditFile
|
|
59
|
+
} from "../chunk-CRRN6UD3.js";
|
|
60
|
+
import {
|
|
61
|
+
SNAPSHOT_ARCHIVE_NAME_RE,
|
|
53
62
|
loadProfile,
|
|
54
63
|
profileFilePath,
|
|
55
|
-
pruneAuditFile,
|
|
56
64
|
rebuildProfile,
|
|
57
65
|
verifyProfile,
|
|
58
66
|
wipeProfile
|
|
59
|
-
} from "../chunk-
|
|
67
|
+
} from "../chunk-ERRPMYKB.js";
|
|
60
68
|
import {
|
|
61
69
|
containerKind,
|
|
62
70
|
dshHomeDir,
|
|
@@ -65,11 +73,11 @@ import {
|
|
|
65
73
|
upgradeVaultTree,
|
|
66
74
|
vaultKeyPath,
|
|
67
75
|
writeText
|
|
68
|
-
} from "../chunk-
|
|
76
|
+
} from "../chunk-GOLMRQRW.js";
|
|
69
77
|
import {
|
|
70
78
|
atomicWriteFileSync,
|
|
71
79
|
shredFileSync
|
|
72
|
-
} from "../chunk-
|
|
80
|
+
} from "../chunk-66IUDHCY.js";
|
|
73
81
|
|
|
74
82
|
// src/cli/index.ts
|
|
75
83
|
import fs2 from "fs";
|
|
@@ -92,6 +100,9 @@ var BURN_LIST = [
|
|
|
92
100
|
// `.incoming-` staging files are the same data, only younger.
|
|
93
101
|
{ match: /\.bak-migrate-\d{14}$/, note: "\u8FC1\u79FB\u5907\u4EFD\uFF08\u8FC1\u79FB\u5BFC\u5165\u65F6\u7684\u539F\u6587\u4EF6\u526F\u672C\uFF09" },
|
|
94
102
|
{ match: /\.incoming-\d{14}$/, note: "\u8FC1\u79FB\u6682\u5B58\u6B8B\u7559\uFF08\u5D29\u6E83\u9057\u7559\u7684\u5BFC\u5165\u526F\u672C\uFF09" },
|
|
103
|
+
// 2.3.0: the ledger/corrections migration writes `<book>.md.bak-YYYYMMDD-HHMMSS`
|
|
104
|
+
// (with `-N` on a same-second collision) — a full plaintext copy of the book.
|
|
105
|
+
{ match: /\.bak-\d{8}-\d{6}(-\d+)?$/, note: "\u4E66\u7C4D\u8FC1\u79FB\u5907\u4EFD\uFF08\u8D26\u672C/\u9519\u9898\u672C\u660E\u6587\u526F\u672C\uFF09" },
|
|
95
106
|
{ file: "profile_rhythm.json", note: "\u4F5C\u606F\u805A\u5408\uFF08\u7EAF\u7EDF\u8BA1\uFF09" },
|
|
96
107
|
{ file: "screen.json", note: "\u5C4F\u5E55\u5FEB\u7167\uFF08\u52A0\u5BC6\uFF09" },
|
|
97
108
|
{ file: "screen.jpg", note: "\u622A\u56FE\uFF08\u52A0\u5BC6\uFF09" },
|
|
@@ -99,12 +110,27 @@ var BURN_LIST = [
|
|
|
99
110
|
{ file: "browse.json", note: "\u6D4F\u89C8\u6D41\u72B6\u6001\uFF08\u52A0\u5BC6\uFF09" },
|
|
100
111
|
{ file: "seeds.jsonl", note: "\u7D20\u6750\u6C60\uFF08\u52A0\u5BC6\uFF09" },
|
|
101
112
|
{ file: "ledger.md", note: "\u8D26\u672C\uFF08\u660E\u6587\uFF0C\u4EBA\u53EF\u8BFB\u662F\u8BBE\u8BA1\u76EE\u6807\uFF09" },
|
|
113
|
+
// 2.3.0: done rows live in the archive now, and the corrections book is the
|
|
114
|
+
// same memory in another file — a burn that leaves them behind leaves the
|
|
115
|
+
// completions / the user's 错题本 readable.
|
|
116
|
+
{ file: "ledger-done.md", note: "\u8D26\u672C\u5F52\u6863\uFF08\u5DF2\u5B8C\u6210\u6761\u76EE\uFF09" },
|
|
117
|
+
{ file: "corrections.md", note: "\u9519\u9898\u672C\uFF08\u660E\u6587\uFF09" },
|
|
118
|
+
{ file: "corrections-done.md", note: "\u9519\u9898\u672C\u5F52\u6863\uFF08\u5DF2\u590D\u76D8\u6761\u76EE\uFF09" },
|
|
102
119
|
{ file: "envpulse.json", note: "\u73AF\u5883\u6E29\u5EA6\u8BA1\u5FEB\u7167" },
|
|
103
120
|
{ file: "gate.json", note: "\u95F8\u95E8\u8FD0\u884C\u65F6\u8BA1\u6570" },
|
|
104
121
|
// v1.9.0 completion (H-19): these carry memory just as much as the rows
|
|
105
122
|
// above — the persona report log records WHAT SHE SAID (spoken / seed_ids /
|
|
106
123
|
// profile_ids / reason), so a burn that skips it is a burn that lies.
|
|
107
124
|
{ file: "profile_snapshot.json", note: "\u753B\u50CF\u5FEB\u7167\uFF08journal \u8F6E\u8F6C\u57FA\u7EBF\uFF09" },
|
|
125
|
+
// v2.4.0: dated snapshot archives (profile restore 的还原点) each hold one
|
|
126
|
+
// fold's full doc — same memory as the canonical file above, so a burn that
|
|
127
|
+
// skipped them would leave the profile restorable. The regex (not a prefix)
|
|
128
|
+
// so the canonical `profile_snapshot.json` is only matched by its own row.
|
|
129
|
+
{ match: SNAPSHOT_ARCHIVE_NAME_RE, note: "\u753B\u50CF\u5FEB\u7167\u5F52\u6863\uFF08\u6BCF\u65E5\u8FD8\u539F\u70B9\uFF0Cprofile_snapshot.<ts>.json\uFF09" },
|
|
130
|
+
// v2.4.0: `profile restore` backs the current view up before overwriting
|
|
131
|
+
// (profile.json.before-restore-<ts>) — a full copy of the pre-restore
|
|
132
|
+
// memory, so it burns with the rest (same reasoning as .bak-migrate above).
|
|
133
|
+
{ match: /^profile\.json\.before-restore-\d{14}(-\d+)?$/, note: "\u753B\u50CF\u6062\u590D\u524D\u5907\u4EFD\uFF08profile restore \u4EA7\u7269\uFF09" },
|
|
108
134
|
{ file: "cursors.json", note: "\u89C2\u5BDF\u6E38\u6807\uFF08\u4F1A\u8BDD\u4E8B\u4EF6\u4F4D\u70B9\uFF09" },
|
|
109
135
|
{ file: "seed_report.jsonl", note: "\u6295\u9012\u62A5\u8D26\u65E5\u5FD7\uFF08\u52A0\u5BC6\uFF09" },
|
|
110
136
|
{ file: "preference.json", note: "\u8BDD\u9898\u504F\u597D\u7EDF\u8BA1" },
|
|
@@ -238,8 +264,12 @@ function usage() {
|
|
|
238
264
|
" seeds stats pool status JSON",
|
|
239
265
|
" ledger add <text> register an open item",
|
|
240
266
|
" ledger list [--pending] list entries",
|
|
241
|
-
" ledger done <id|substring> mark an entry done",
|
|
242
|
-
" ledger open
|
|
267
|
+
" ledger done <id|substring> mark an entry done (moves it to the archive)",
|
|
268
|
+
" ledger open [--done] open ledger.md (or its archive) in the default editor",
|
|
269
|
+
" corrections add <text> record a correction (\u9519\u9898\u672C)",
|
|
270
|
+
" corrections list [--pending] list unreviewed corrections",
|
|
271
|
+
" corrections done <id|substring> mark a correction reviewed (moves it to the archive)",
|
|
272
|
+
" corrections open [--done] open corrections.md (or its archive) in the default editor",
|
|
243
273
|
" excerpt add <text> keep a line in the notebook",
|
|
244
274
|
" excerpt list [n] list entries (newest n if given)",
|
|
245
275
|
" excerpt remove <id|substring> tear a page out",
|
|
@@ -261,6 +291,9 @@ function usage() {
|
|
|
261
291
|
" profile verify journal replay vs disk (report only)",
|
|
262
292
|
" profile rebuild [--check] rebuild materialized view from journal",
|
|
263
293
|
" profile snapshot [--force] fold the journal into a snapshot + archive shard",
|
|
294
|
+
" profile snapshots [--days n] list restore points (snapshot archives)",
|
|
295
|
+
" profile restore --at <ISO> restore the profile view to a past instant [--dry-run]",
|
|
296
|
+
" profile log --id <entryId> print the journal history of one entry",
|
|
264
297
|
" profile wipe wipe profile data (asks --yes)",
|
|
265
298
|
" weekly list list generated weekly reports",
|
|
266
299
|
" weekly show [file] print a report (default: newest)",
|
|
@@ -384,7 +417,7 @@ async function verbSeeds(c) {
|
|
|
384
417
|
}
|
|
385
418
|
}
|
|
386
419
|
async function verbLedger(c) {
|
|
387
|
-
const { guard, sub, rest, ledgerFile } = c;
|
|
420
|
+
const { guard, sub, rest, ledgerFile, seedAudit } = c;
|
|
388
421
|
switch (sub) {
|
|
389
422
|
case "add": {
|
|
390
423
|
let text = rest.join(" ").trim();
|
|
@@ -410,7 +443,7 @@ async function verbLedger(c) {
|
|
|
410
443
|
console.error("usage: ledger done <id|substring>");
|
|
411
444
|
return 1;
|
|
412
445
|
}
|
|
413
|
-
const e = markDone(guard, ledgerFile, key);
|
|
446
|
+
const e = markDone(guard, ledgerFile, key, Date.now(), void 0, void 0, seedAudit);
|
|
414
447
|
if (!e) {
|
|
415
448
|
console.log("NOT_FOUND");
|
|
416
449
|
return 1;
|
|
@@ -419,10 +452,10 @@ async function verbLedger(c) {
|
|
|
419
452
|
return 0;
|
|
420
453
|
}
|
|
421
454
|
case "open": {
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
455
|
+
const done = rest.includes("--done");
|
|
456
|
+
const f = done ? ledgerDoneFilePath(c.paths.dataDir) : ledgerFile;
|
|
457
|
+
if (done) seedBookFile(guard, f, LEDGER_DONE_HEADER);
|
|
458
|
+
else if (!fs2.existsSync(f)) console.log(`(ledger will be created at ${f})`);
|
|
426
459
|
openPath(f);
|
|
427
460
|
console.log(`opened ${f}`);
|
|
428
461
|
return 0;
|
|
@@ -432,6 +465,55 @@ async function verbLedger(c) {
|
|
|
432
465
|
return 1;
|
|
433
466
|
}
|
|
434
467
|
}
|
|
468
|
+
async function verbCorrections(c) {
|
|
469
|
+
const { guard, sub, rest, correctionsFile, seedAudit } = c;
|
|
470
|
+
switch (sub) {
|
|
471
|
+
case "add": {
|
|
472
|
+
let text = rest.join(" ").trim();
|
|
473
|
+
if (text === "-") text = readStdinText();
|
|
474
|
+
if (!text) {
|
|
475
|
+
console.error("usage: corrections add <text|->");
|
|
476
|
+
return 1;
|
|
477
|
+
}
|
|
478
|
+
const e = appendEntry(guard, correctionsFile, text, Date.now(), CORRECTIONS_HEADER);
|
|
479
|
+
console.log(`OPEN #${e.id} ${e.text.slice(0, 60)}`);
|
|
480
|
+
return 0;
|
|
481
|
+
}
|
|
482
|
+
case "list": {
|
|
483
|
+
const { entries } = readLedger(guard, correctionsFile, CORRECTIONS_HEADER);
|
|
484
|
+
const items = rest.includes("--pending") ? scanPending(guard, correctionsFile) : entries;
|
|
485
|
+
for (const e of items) console.log(`${e.status === "open" ? " " : "x"} #${e.id} ${e.date} ${e.text.slice(0, 60)}`);
|
|
486
|
+
if (items.length === 0) console.log("(empty)");
|
|
487
|
+
return 0;
|
|
488
|
+
}
|
|
489
|
+
case "done": {
|
|
490
|
+
const key = rest.join(" ").trim();
|
|
491
|
+
if (!key) {
|
|
492
|
+
console.error("usage: corrections done <id|substring>");
|
|
493
|
+
return 1;
|
|
494
|
+
}
|
|
495
|
+
const e = markDone(guard, correctionsFile, key, Date.now(), void 0, void 0, seedAudit);
|
|
496
|
+
if (!e) {
|
|
497
|
+
console.log("NOT_FOUND");
|
|
498
|
+
return 1;
|
|
499
|
+
}
|
|
500
|
+
console.log(`DONE #${e.id}`);
|
|
501
|
+
return 0;
|
|
502
|
+
}
|
|
503
|
+
case "open": {
|
|
504
|
+
const done = rest.includes("--done");
|
|
505
|
+
const f = done ? correctionsDoneFilePath(c.paths.dataDir) : correctionsFile;
|
|
506
|
+
if (done) seedBookFile(guard, f, CORRECTIONS_DONE_HEADER);
|
|
507
|
+
else if (!fs2.existsSync(f)) console.log(`(corrections will be created at ${f})`);
|
|
508
|
+
openPath(f);
|
|
509
|
+
console.log(`opened ${f}`);
|
|
510
|
+
return 0;
|
|
511
|
+
}
|
|
512
|
+
default:
|
|
513
|
+
console.error(`unknown corrections subcommand: ${sub}`);
|
|
514
|
+
return 1;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
435
517
|
async function verbExcerpt(c) {
|
|
436
518
|
const { guard, sub, rest, excerptFile } = c;
|
|
437
519
|
switch (sub) {
|
|
@@ -583,7 +665,7 @@ async function verbNotify(c) {
|
|
|
583
665
|
}
|
|
584
666
|
}
|
|
585
667
|
async function verbProfile(c) {
|
|
586
|
-
const { guard, paths, sub, rest } = c;
|
|
668
|
+
const { guard, paths, policy, sub, rest } = c;
|
|
587
669
|
const doc = loadProfile(guard, profileFilePath(paths.dataDir));
|
|
588
670
|
const all = rest.includes("--all");
|
|
589
671
|
switch (sub) {
|
|
@@ -634,7 +716,7 @@ async function verbProfile(c) {
|
|
|
634
716
|
return 0;
|
|
635
717
|
}
|
|
636
718
|
case "snapshot": {
|
|
637
|
-
const { snapshotDue, snapshotProfile, SNAPSHOT_THRESHOLD } = await import("../snapshot-
|
|
719
|
+
const { snapshotDue, snapshotProfile, SNAPSHOT_THRESHOLD } = await import("../snapshot-J6LKNY57.js");
|
|
638
720
|
const { needed, lines } = snapshotDue(guard, paths.dataDir);
|
|
639
721
|
console.log(`journal ${lines} \u6761\uFF08\u9608\u503C ${SNAPSHOT_THRESHOLD}\uFF09`);
|
|
640
722
|
if (!needed && !rest.includes("--force")) {
|
|
@@ -650,6 +732,130 @@ async function verbProfile(c) {
|
|
|
650
732
|
console.log("verify/rebuild \u81EA\u52A8\u4ECE\u5FEB\u7167\u57FA\u70B9\u91CD\u653E\uFF0C\u65E0\u9700\u989D\u5916\u64CD\u4F5C\u3002");
|
|
651
733
|
return 0;
|
|
652
734
|
}
|
|
735
|
+
case "snapshots": {
|
|
736
|
+
const { listSnapshots, readSnapshotFile } = await import("../store-HM6ZMFKS.js");
|
|
737
|
+
const { resolveRetentionDays } = await import("../snapshot-J6LKNY57.js");
|
|
738
|
+
const days = Number(flag(rest, "--days")) || resolveRetentionDays(guard, paths.dataDir);
|
|
739
|
+
if (!(days > 0)) {
|
|
740
|
+
console.error("--days must be a positive number");
|
|
741
|
+
return 1;
|
|
742
|
+
}
|
|
743
|
+
const cutoff = Date.now() - days * 864e5;
|
|
744
|
+
const refs = listSnapshots(guard, paths.dataDir).filter((r) => r.baselineTs >= cutoff);
|
|
745
|
+
if (refs.length === 0) {
|
|
746
|
+
console.log(`(${days} \u5929\u5185\u6CA1\u6709\u8FD8\u539F\u70B9\uFF1B\u6298\u53E0\u4E00\u6B21\u753B\u50CF\u5FEB\u7167\u5373\u53EF\u751F\u6210\uFF0C\u89C1 profile snapshot\uFF09`);
|
|
747
|
+
return 0;
|
|
748
|
+
}
|
|
749
|
+
for (const ref of refs) {
|
|
750
|
+
const snap = readSnapshotFile(guard, ref.path);
|
|
751
|
+
const entries = snap ? Object.values(snap.doc.partitions).reduce((n, b) => n + b.entries.length, 0) : null;
|
|
752
|
+
const at = new Date(ref.baselineTs);
|
|
753
|
+
console.log(`${at.toISOString()} \u6761\u76EE ${entries ?? "?"} ${ref.path}`);
|
|
754
|
+
}
|
|
755
|
+
return 0;
|
|
756
|
+
}
|
|
757
|
+
case "restore": {
|
|
758
|
+
const { restoreAt } = await import("../store-HM6ZMFKS.js");
|
|
759
|
+
const at = flag(rest, "--at");
|
|
760
|
+
if (!at) {
|
|
761
|
+
console.error("usage: profile restore --at <ISO> [--dry-run]");
|
|
762
|
+
return 1;
|
|
763
|
+
}
|
|
764
|
+
if (!Number.isFinite(Date.parse(at))) {
|
|
765
|
+
console.error(`invalid --at timestamp: ${at}`);
|
|
766
|
+
return 1;
|
|
767
|
+
}
|
|
768
|
+
const dry = rest.includes("--dry-run");
|
|
769
|
+
let r;
|
|
770
|
+
try {
|
|
771
|
+
r = restoreAt(guard, paths.dataDir, at, { dryRun: dry });
|
|
772
|
+
} catch (e) {
|
|
773
|
+
console.error(String(e instanceof Error ? e.message : e));
|
|
774
|
+
return 1;
|
|
775
|
+
}
|
|
776
|
+
const atIso = r.restoredTo > 0 ? new Date(r.restoredTo).toISOString() : String(r.restoredTo);
|
|
777
|
+
console.log(JSON.stringify({
|
|
778
|
+
mode: dry ? "dry-run" : "restore",
|
|
779
|
+
restoredTo: atIso,
|
|
780
|
+
backupPath: r.backupPath || "(none)",
|
|
781
|
+
wrote: r.wrote,
|
|
782
|
+
diff: r.diff
|
|
783
|
+
}, null, 2));
|
|
784
|
+
if (!r.wrote && dry) {
|
|
785
|
+
console.log("\uFF08dry-run\uFF1A\u672A\u5199\u76D8\u3002\u786E\u8BA4\u5DEE\u5F02\u540E\u53BB\u6389 --dry-run \u771F\u8DD1\u3002\uFF09");
|
|
786
|
+
} else if (!r.wrote) {
|
|
787
|
+
console.log("\u76EE\u6807\u4E3A\u6700\u65B0\u8BB0\u5F55\u4E14\u753B\u50CF\u5DF2\u4E0E\u4E4B\u4E00\u81F4\u2014\u2014\u5DF2\u662F\u5F53\u524D\u72B6\u6001\uFF0C\u672A\u5199\u76D8\u3002");
|
|
788
|
+
} else if (r.toNow) {
|
|
789
|
+
console.log(`\u5DF2\u6062\u590D\u5230\u6700\u65B0\u8BB0\u5F55\uFF08${atIso}\uFF09\uFF1B\u78C1\u76D8\u89C6\u56FE\u6B64\u524D\u843D\u540E\u4E8E journal\uFF0C\u5DF2\u6309\u6700\u65B0\u72B6\u6001\u5199\u56DE${r.backupPath ? `\uFF0C\u6062\u590D\u524D\u89C6\u56FE\u5907\u4EFD\u5728 ${r.backupPath}` : ""}\u3002`);
|
|
790
|
+
console.log("\u6CE8\u610F\uFF1Ajournal \u4ECD\u662F\u5B8C\u6574\u5386\u53F2\uFF0C\u73B0\u5728 verify \u5E94\u5F53\u4E00\u81F4\uFF1B\u5982\u4ECD\u5F02\u5E38\u53EF\u8DD1 rebuild\u3002");
|
|
791
|
+
} else if (r.backupPath) {
|
|
792
|
+
console.log(`\u5DF2\u6062\u590D\u81F3 ${atIso}\uFF1B\u6062\u590D\u524D\u7684\u753B\u50CF\u5907\u4EFD\u5728 ${r.backupPath}`);
|
|
793
|
+
console.log("\u6CE8\u610F\uFF1Ajournal \u4ECD\u4FDD\u5B58\u5B8C\u6574\u5386\u53F2\uFF0Cverify \u4F1A\u62A5\u544A\u4E0E\u5F53\u524D\u89C6\u56FE\u7684\u5DEE\u5F02\uFF08\u8FD9\u662F\u56DE\u6EDA\u7684\u9884\u671F\u884C\u4E3A\uFF09\uFF1Brebuild \u53EF\u56DE\u5230\u6700\u65B0\u3002");
|
|
794
|
+
} else {
|
|
795
|
+
console.log(`\u5DF2\u6062\u590D\u81F3 ${atIso}\uFF08\u6B64\u524D\u6CA1\u6709 profile.json\uFF0C\u672A\u751F\u6210\u6062\u590D\u524D\u5907\u4EFD\uFF09\u3002`);
|
|
796
|
+
console.log("\u6CE8\u610F\uFF1Ajournal \u4ECD\u4FDD\u5B58\u5B8C\u6574\u5386\u53F2\uFF0Cverify \u4F1A\u62A5\u544A\u4E0E\u5F53\u524D\u89C6\u56FE\u7684\u5DEE\u5F02\uFF08\u8FD9\u662F\u56DE\u6EDA\u7684\u9884\u671F\u884C\u4E3A\uFF09\uFF1Brebuild \u53EF\u56DE\u5230\u6700\u65B0\u3002");
|
|
797
|
+
}
|
|
798
|
+
return 0;
|
|
799
|
+
}
|
|
800
|
+
case "log": {
|
|
801
|
+
const id = flag(rest, "--id");
|
|
802
|
+
if (!id) {
|
|
803
|
+
console.error("usage: profile log --id <entryId>");
|
|
804
|
+
return 1;
|
|
805
|
+
}
|
|
806
|
+
const { readJournalTexts } = await import("../store-HM6ZMFKS.js");
|
|
807
|
+
const touches = [];
|
|
808
|
+
let prevContent = null;
|
|
809
|
+
let prevValidTo = void 0;
|
|
810
|
+
for (const text of readJournalTexts(guard, paths.dataDir)) {
|
|
811
|
+
for (const line of text.split("\n")) {
|
|
812
|
+
const s = line.trim();
|
|
813
|
+
if (!s) continue;
|
|
814
|
+
let rec;
|
|
815
|
+
try {
|
|
816
|
+
rec = JSON.parse(s);
|
|
817
|
+
} catch {
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
const ts = String(rec.ts ?? "");
|
|
821
|
+
if (rec.v === 2 && Array.isArray(rec.entries)) {
|
|
822
|
+
for (const e of rec.entries) {
|
|
823
|
+
if (e?.id !== id) continue;
|
|
824
|
+
const entry = e;
|
|
825
|
+
const content = typeof entry.content === "string" ? entry.content : null;
|
|
826
|
+
const op = prevValidTo === void 0 ? "ADD" : prevValidTo === null && entry.validTo != null ? "INVALIDATE" : "UPDATE";
|
|
827
|
+
touches.push({ ts, op, contentChanged: prevContent !== null && content !== prevContent, content });
|
|
828
|
+
prevContent = content;
|
|
829
|
+
prevValidTo = entry.validTo ?? null;
|
|
830
|
+
}
|
|
831
|
+
} else if (Array.isArray(rec.applied)) {
|
|
832
|
+
for (const op of rec.applied) {
|
|
833
|
+
const matches = op?.op === "ADD" ? op.assignedId === id : op?.id === id;
|
|
834
|
+
if (!matches) continue;
|
|
835
|
+
const content = op?.op === "ADD" && typeof op.content === "string" ? op.content : op?.op === "UPDATE" && typeof op.changes?.content === "string" ? op.changes.content : prevContent;
|
|
836
|
+
touches.push({
|
|
837
|
+
ts,
|
|
838
|
+
op: String(op?.op ?? "?"),
|
|
839
|
+
contentChanged: op?.op === "UPDATE" && op.changes?.content !== void 0 && content !== prevContent,
|
|
840
|
+
content
|
|
841
|
+
});
|
|
842
|
+
if (content != null) prevContent = content;
|
|
843
|
+
if (op?.op === "INVALIDATE") prevValidTo = ts;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
if (touches.length === 0) {
|
|
849
|
+
console.log(`(no history for ${id})`);
|
|
850
|
+
return 0;
|
|
851
|
+
}
|
|
852
|
+
for (const t of touches) {
|
|
853
|
+
const body = t.content != null ? ` ${t.content.slice(0, 60)}` : "";
|
|
854
|
+
console.log(`${t.ts} ${t.op.padEnd(10)} content ${t.contentChanged ? "changed" : "same"}${body}`);
|
|
855
|
+
}
|
|
856
|
+
console.log(`\u5171 ${touches.length} \u6B21\u53D8\u66F4\uFF08\u65F6\u95F4\u5347\u5E8F\uFF1B\u6B63\u6587\u6309 profile list \u7684 60 \u5B57\u622A\u65AD\u53E3\u5F84\u5C55\u793A\uFF09\u3002`);
|
|
857
|
+
return 0;
|
|
858
|
+
}
|
|
653
859
|
default:
|
|
654
860
|
console.error(`unknown profile subcommand: ${sub}`);
|
|
655
861
|
return 1;
|
|
@@ -739,7 +945,7 @@ async function verbSessions(c) {
|
|
|
739
945
|
const root = path2.join(dshHomeDir(), "sessions");
|
|
740
946
|
let found = 0;
|
|
741
947
|
if (fs2.existsSync(root)) {
|
|
742
|
-
const { homeSessionId } = await import("../orchestrator-
|
|
948
|
+
const { homeSessionId } = await import("../orchestrator-4PJD7QYO.js");
|
|
743
949
|
const own = homeSessionId(guard, paths);
|
|
744
950
|
for (const slug of fs2.readdirSync(root)) {
|
|
745
951
|
for (const id of fs2.readdirSync(path2.join(root, slug))) {
|
|
@@ -754,11 +960,11 @@ async function verbSessions(c) {
|
|
|
754
960
|
}
|
|
755
961
|
async function verbBind(c) {
|
|
756
962
|
const { guard, paths, sub, rest } = c;
|
|
757
|
-
const { loadBindings, addBinding, removeBinding } = await import("../bindings-
|
|
963
|
+
const { loadBindings, addBinding, removeBinding } = await import("../bindings-LTSGGNIH.js");
|
|
758
964
|
switch (sub) {
|
|
759
965
|
case "list": {
|
|
760
966
|
const data = loadBindings(guard, paths.settingsDir);
|
|
761
|
-
const { homeSessionId } = await import("../orchestrator-
|
|
967
|
+
const { homeSessionId } = await import("../orchestrator-4PJD7QYO.js");
|
|
762
968
|
const own = homeSessionId(guard, paths);
|
|
763
969
|
if (own) console.log(`\u5FC3\u8DF3\u6B63\u8EAB: ${own}\uFF08\u51B3\u7B56\u8F6E\u6B21\u53D1\u751F\u5730\uFF1Bbind remove \u5B83 = \u91CD\u7F6E\u6B63\u8EAB\uFF09`);
|
|
764
970
|
for (const b of data.bindings) {
|
|
@@ -786,7 +992,7 @@ async function verbBind(c) {
|
|
|
786
992
|
return 1;
|
|
787
993
|
}
|
|
788
994
|
console.log(removeBinding(guard, paths.settingsDir, id) ? `UNBOUND ${id}` : "NOT_FOUND");
|
|
789
|
-
const { resetHomeSession } = await import("../orchestrator-
|
|
995
|
+
const { resetHomeSession } = await import("../orchestrator-4PJD7QYO.js");
|
|
790
996
|
if (resetHomeSession(guard, paths, id)) {
|
|
791
997
|
console.log("\u6CE8\u610F\uFF1A\u8FD9\u662F\u5FC3\u8DF3\u6B63\u8EAB\u4F1A\u8BDD\u3002\u5DF2\u91CD\u7F6E\u2014\u2014\u4E0B\u6B21\u5FC3\u8DF3\u5C06\u521B\u5EFA\u65B0\u7684\u6B63\u8EAB\u4F1A\u8BDD\uFF08\u65E7\u4F1A\u8BDD\u4E0D\u518D\u6709\u5FC3\u8DF3\uFF09");
|
|
792
998
|
}
|
|
@@ -859,8 +1065,8 @@ async function verbVault(c) {
|
|
|
859
1065
|
}
|
|
860
1066
|
async function verbFocus(c) {
|
|
861
1067
|
const { sub, rest, decisionLog } = c;
|
|
862
|
-
const { readFocusState, writeFocusState, clearFocusState } = await import("../focus-store-
|
|
863
|
-
const { formatFocusClock } = await import("../orchestrator-
|
|
1068
|
+
const { readFocusState, writeFocusState, clearFocusState } = await import("../focus-store-XGTPIVF6.js");
|
|
1069
|
+
const { formatFocusClock } = await import("../orchestrator-4PJD7QYO.js");
|
|
864
1070
|
const audit = (entry) => {
|
|
865
1071
|
try {
|
|
866
1072
|
appendAuditLine(decisionLog, entry);
|
|
@@ -903,7 +1109,7 @@ async function verbBili(c) {
|
|
|
903
1109
|
openImageProduction,
|
|
904
1110
|
renderQrPngProduction,
|
|
905
1111
|
saveBiliSession
|
|
906
|
-
} = await import("../bili-login-
|
|
1112
|
+
} = await import("../bili-login-KDDU63Z2.js");
|
|
907
1113
|
const outcome = await runBiliLogin({
|
|
908
1114
|
fetchImpl: fetch,
|
|
909
1115
|
renderQrPng: renderQrPngProduction,
|
|
@@ -924,6 +1130,7 @@ var VERBS = {
|
|
|
924
1130
|
status: verbStatus,
|
|
925
1131
|
seeds: verbSeeds,
|
|
926
1132
|
ledger: verbLedger,
|
|
1133
|
+
corrections: verbCorrections,
|
|
927
1134
|
excerpt: verbExcerpt,
|
|
928
1135
|
weekly: verbWeekly,
|
|
929
1136
|
logs: verbLogs,
|
|
@@ -970,6 +1177,7 @@ async function main(argv) {
|
|
|
970
1177
|
argv,
|
|
971
1178
|
seedsFile: seedsFilePath(paths.dataDir),
|
|
972
1179
|
ledgerFile: ledgerFilePath(paths.dataDir),
|
|
1180
|
+
correctionsFile: correctionsFilePath(paths.dataDir),
|
|
973
1181
|
excerptFile: excerptFilePath(paths.dataDir),
|
|
974
1182
|
decisionLog,
|
|
975
1183
|
seedAudit
|