clawvault 2.6.0 → 3.0.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/bin/command-registration.test.js +1 -3
- package/bin/register-core-commands.js +10 -23
- package/bin/register-maintenance-commands.js +3 -20
- package/bin/register-query-commands.js +23 -0
- package/bin/register-task-commands.js +1 -18
- package/bin/register-task-commands.test.js +0 -16
- package/bin/register-vault-operations-commands.js +1 -29
- package/dist/{chunk-QVMXF7FY.js → chunk-3D6BCTP6.js} +39 -1
- package/dist/{chunk-R2MIW5G7.js → chunk-3DHXQHYG.js} +1 -1
- package/dist/{chunk-Q2J5YTUF.js → chunk-3NSBOUT3.js} +73 -36
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/{chunk-AZYOKJYC.js → chunk-62YTUT6J.js} +2 -2
- package/dist/chunk-6U6MK36V.js +205 -0
- package/dist/{chunk-4QYGFWRM.js → chunk-7R7O6STJ.js} +4 -4
- package/dist/{chunk-VXEOHTSL.js → chunk-C7OK5WKP.js} +4 -4
- package/dist/chunk-CMB7UL7C.js +327 -0
- package/dist/chunk-DEFFDRVP.js +938 -0
- package/dist/{chunk-K3CDT7IH.js → chunk-E7MFQB6D.js} +61 -20
- package/dist/{chunk-ME37YNW3.js → chunk-F2JEUD4J.js} +6 -4
- package/dist/chunk-GAJV4IGR.js +82 -0
- package/dist/chunk-GQSLDZTS.js +560 -0
- package/dist/{chunk-4OXMU5S2.js → chunk-GUKMRGM7.js} +1 -1
- package/dist/{chunk-YOSEUUNB.js → chunk-H34S76MB.js} +6 -6
- package/dist/{chunk-4TE4JMLA.js → chunk-JY6FYXIT.js} +10 -5
- package/dist/chunk-K234IDRJ.js +1073 -0
- package/dist/{chunk-IEVLHNLU.js → chunk-LNJA2UGL.js} +86 -9
- package/dist/{chunk-MFAWT5O5.js → chunk-LYHGEHXG.js} +1 -0
- package/dist/chunk-MFM6K7PU.js +374 -0
- package/dist/{chunk-QWQ3TIKS.js → chunk-N2AXRYLC.js} +1 -1
- package/dist/chunk-PAH27GSN.js +108 -0
- package/dist/{chunk-OIWVQYQF.js → chunk-QBLMXKF2.js} +1 -1
- package/dist/{chunk-FHFUXL6G.js → chunk-QK3UCXWL.js} +2 -2
- package/dist/{chunk-2YDBJS7M.js → chunk-SJSFRIYS.js} +1 -1
- package/dist/{chunk-GSD4ALSI.js → chunk-U55BGUAU.js} +2 -2
- package/dist/{chunk-PBEE567J.js → chunk-VGLOTGAS.js} +1 -1
- package/dist/{chunk-F55HGNU4.js → chunk-WAZ3NLWL.js} +47 -0
- package/dist/{chunk-KL4NAOMO.js → chunk-WGRQ6HDV.js} +1 -1
- package/dist/{chunk-UEOUADMO.js → chunk-YKTA5JOJ.js} +13 -10
- package/dist/{chunk-XAVB4GB4.js → chunk-ZVVFWOLW.js} +4 -4
- package/dist/cli/index.cjs +10033 -0
- package/dist/cli/index.d.cts +5 -0
- package/dist/cli/index.js +20 -18
- package/dist/commands/archive.cjs +287 -0
- package/dist/commands/archive.d.cts +11 -0
- package/dist/commands/archive.js +1 -0
- package/dist/commands/backlog.cjs +721 -0
- package/dist/commands/backlog.d.cts +53 -0
- package/dist/commands/backlog.js +3 -2
- package/dist/commands/blocked.cjs +204 -0
- package/dist/commands/blocked.d.cts +26 -0
- package/dist/commands/blocked.js +3 -2
- package/dist/commands/checkpoint.cjs +244 -0
- package/dist/commands/checkpoint.d.cts +41 -0
- package/dist/commands/checkpoint.js +2 -1
- package/dist/commands/compat.cjs +369 -0
- package/dist/commands/compat.d.cts +28 -0
- package/dist/commands/compat.js +2 -1
- package/dist/commands/context.cjs +2989 -0
- package/dist/commands/context.d.cts +2 -0
- package/dist/commands/context.js +5 -4
- package/dist/commands/doctor.cjs +3062 -0
- package/dist/commands/doctor.d.cts +21 -0
- package/dist/commands/doctor.d.ts +6 -1
- package/dist/commands/doctor.js +13 -11
- package/dist/commands/embed.cjs +232 -0
- package/dist/commands/embed.d.cts +17 -0
- package/dist/commands/embed.js +5 -2
- package/dist/commands/entities.cjs +141 -0
- package/dist/commands/entities.d.cts +7 -0
- package/dist/commands/entities.js +1 -0
- package/dist/commands/graph.cjs +501 -0
- package/dist/commands/graph.d.cts +21 -0
- package/dist/commands/graph.js +1 -0
- package/dist/commands/inject.cjs +1636 -0
- package/dist/commands/inject.d.cts +2 -0
- package/dist/commands/inject.d.ts +1 -1
- package/dist/commands/inject.js +4 -2
- package/dist/commands/kanban.cjs +884 -0
- package/dist/commands/kanban.d.cts +63 -0
- package/dist/commands/kanban.js +4 -3
- package/dist/commands/link.cjs +965 -0
- package/dist/commands/link.d.cts +11 -0
- package/dist/commands/link.js +1 -0
- package/dist/commands/migrate-observations.cjs +362 -0
- package/dist/commands/migrate-observations.d.cts +19 -0
- package/dist/commands/migrate-observations.js +3 -2
- package/dist/commands/observe.cjs +4099 -0
- package/dist/commands/observe.d.cts +23 -0
- package/dist/commands/observe.d.ts +1 -0
- package/dist/commands/observe.js +11 -9
- package/dist/commands/project.cjs +1341 -0
- package/dist/commands/project.d.cts +85 -0
- package/dist/commands/project.js +5 -4
- package/dist/commands/rebuild.cjs +3136 -0
- package/dist/commands/rebuild.d.cts +11 -0
- package/dist/commands/rebuild.js +10 -8
- package/dist/commands/recover.cjs +361 -0
- package/dist/commands/recover.d.cts +38 -0
- package/dist/commands/recover.js +3 -2
- package/dist/commands/reflect.cjs +1008 -0
- package/dist/commands/reflect.d.cts +11 -0
- package/dist/commands/reflect.js +6 -4
- package/dist/commands/repair-session.cjs +457 -0
- package/dist/commands/repair-session.d.cts +38 -0
- package/dist/commands/repair-session.js +1 -0
- package/dist/commands/replay.cjs +4103 -0
- package/dist/commands/replay.d.cts +16 -0
- package/dist/commands/replay.js +12 -10
- package/dist/commands/session-recap.cjs +353 -0
- package/dist/commands/session-recap.d.cts +27 -0
- package/dist/commands/session-recap.js +1 -0
- package/dist/commands/setup.cjs +1345 -0
- package/dist/commands/setup.d.cts +100 -0
- package/dist/commands/setup.d.ts +90 -2
- package/dist/commands/setup.js +21 -2
- package/dist/commands/shell-init.cjs +75 -0
- package/dist/commands/shell-init.d.cts +7 -0
- package/dist/commands/shell-init.js +2 -0
- package/dist/commands/sleep.cjs +6028 -0
- package/dist/commands/sleep.d.cts +36 -0
- package/dist/commands/sleep.d.ts +1 -1
- package/dist/commands/sleep.js +17 -15
- package/dist/commands/status.cjs +2736 -0
- package/dist/commands/status.d.cts +52 -0
- package/dist/commands/status.js +12 -10
- package/dist/commands/tailscale.cjs +1532 -0
- package/dist/commands/tailscale.d.cts +52 -0
- package/dist/commands/tailscale.js +1 -0
- package/dist/commands/task.cjs +1236 -0
- package/dist/commands/task.d.cts +97 -0
- package/dist/commands/task.js +4 -3
- package/dist/commands/template.cjs +457 -0
- package/dist/commands/template.d.cts +36 -0
- package/dist/commands/template.js +2 -1
- package/dist/commands/wake.cjs +2626 -0
- package/dist/commands/wake.d.cts +22 -0
- package/dist/commands/wake.d.ts +1 -1
- package/dist/commands/wake.js +12 -11
- package/dist/context-BUGaWpyL.d.cts +46 -0
- package/dist/index.cjs +14526 -0
- package/dist/index.d.cts +858 -0
- package/dist/index.d.ts +192 -7
- package/dist/index.js +101 -75
- package/dist/{inject-x65KXWPk.d.ts → inject-Bzi5E-By.d.cts} +1 -1
- package/dist/inject-Bzi5E-By.d.ts +137 -0
- package/dist/lib/auto-linker.cjs +176 -0
- package/dist/lib/auto-linker.d.cts +26 -0
- package/dist/lib/auto-linker.js +1 -0
- package/dist/lib/canvas-layout.cjs +136 -0
- package/dist/lib/canvas-layout.d.cts +31 -0
- package/dist/lib/canvas-layout.d.ts +16 -100
- package/dist/lib/canvas-layout.js +78 -20
- package/dist/lib/config.cjs +78 -0
- package/dist/lib/config.d.cts +11 -0
- package/dist/lib/config.js +1 -0
- package/dist/lib/entity-index.cjs +84 -0
- package/dist/lib/entity-index.d.cts +26 -0
- package/dist/lib/entity-index.js +1 -0
- package/dist/lib/project-utils.cjs +864 -0
- package/dist/lib/project-utils.d.cts +97 -0
- package/dist/lib/project-utils.js +4 -3
- package/dist/lib/session-repair.cjs +239 -0
- package/dist/lib/session-repair.d.cts +110 -0
- package/dist/lib/session-repair.js +1 -0
- package/dist/lib/session-utils.cjs +209 -0
- package/dist/lib/session-utils.d.cts +63 -0
- package/dist/lib/session-utils.js +1 -0
- package/dist/lib/tailscale.cjs +1183 -0
- package/dist/lib/tailscale.d.cts +225 -0
- package/dist/lib/tailscale.js +1 -0
- package/dist/lib/task-utils.cjs +1137 -0
- package/dist/lib/task-utils.d.cts +208 -0
- package/dist/lib/task-utils.js +3 -2
- package/dist/lib/template-engine.cjs +47 -0
- package/dist/lib/template-engine.d.cts +11 -0
- package/dist/lib/template-engine.js +1 -0
- package/dist/lib/webdav.cjs +568 -0
- package/dist/lib/webdav.d.cts +109 -0
- package/dist/lib/webdav.js +1 -0
- package/dist/plugin/index.cjs +1907 -0
- package/dist/plugin/index.d.cts +36 -0
- package/dist/plugin/index.d.ts +36 -0
- package/dist/plugin/index.js +572 -0
- package/dist/plugin/inject.cjs +356 -0
- package/dist/plugin/inject.d.cts +54 -0
- package/dist/plugin/inject.d.ts +54 -0
- package/dist/plugin/inject.js +17 -0
- package/dist/plugin/observe.cjs +631 -0
- package/dist/plugin/observe.d.cts +39 -0
- package/dist/plugin/observe.d.ts +39 -0
- package/dist/plugin/observe.js +18 -0
- package/dist/plugin/templates.cjs +593 -0
- package/dist/plugin/templates.d.cts +52 -0
- package/dist/plugin/templates.d.ts +52 -0
- package/dist/plugin/templates.js +25 -0
- package/dist/plugin/types.cjs +18 -0
- package/dist/plugin/types.d.cts +209 -0
- package/dist/plugin/types.d.ts +209 -0
- package/dist/plugin/types.js +0 -0
- package/dist/plugin/vault.cjs +927 -0
- package/dist/plugin/vault.d.cts +68 -0
- package/dist/plugin/vault.d.ts +68 -0
- package/dist/plugin/vault.js +22 -0
- package/dist/{types-C74wgGL1.d.ts → types-Y2_Um2Ls.d.cts} +44 -1
- package/dist/types-Y2_Um2Ls.d.ts +205 -0
- package/hooks/clawvault/handler.js +70 -7
- package/hooks/clawvault/handler.test.js +91 -0
- package/openclaw.plugin.json +56 -0
- package/package.json +17 -7
- package/templates/memory-event.md +67 -0
- package/templates/party.md +63 -0
- package/templates/primitive-registry.yaml +551 -0
- package/templates/run.md +68 -0
- package/templates/trigger.md +68 -0
- package/templates/workspace.md +50 -0
- package/dashboard/lib/graph-diff.js +0 -104
- package/dashboard/lib/graph-diff.test.js +0 -75
- package/dashboard/lib/vault-parser.js +0 -556
- package/dashboard/lib/vault-parser.test.js +0 -254
- package/dashboard/public/app.js +0 -796
- package/dashboard/public/index.html +0 -52
- package/dashboard/public/styles.css +0 -221
- package/dashboard/server.js +0 -374
- package/dist/chunk-HA5M6KJB.js +0 -33
- package/dist/chunk-MAKNAHAW.js +0 -375
- package/dist/chunk-MDIH26GC.js +0 -183
- package/dist/chunk-MGDEINGP.js +0 -99
- package/dist/chunk-RVYA52PY.js +0 -363
- package/dist/commands/canvas.d.ts +0 -15
- package/dist/commands/canvas.js +0 -199
- package/dist/commands/sync-bd.d.ts +0 -10
- package/dist/commands/sync-bd.js +0 -9
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
|
|
3
|
+
interface RebuildCommandOptions {
|
|
4
|
+
vaultPath?: string;
|
|
5
|
+
from?: string;
|
|
6
|
+
to?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function rebuildCommand(options: RebuildCommandOptions): Promise<void>;
|
|
9
|
+
declare function registerRebuildCommand(program: Command): void;
|
|
10
|
+
|
|
11
|
+
export { type RebuildCommandOptions, rebuildCommand, registerRebuildCommand };
|
package/dist/commands/rebuild.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
rebuildCommand,
|
|
3
3
|
registerRebuildCommand
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-FHFUXL6G.js";
|
|
4
|
+
} from "../chunk-VGLOTGAS.js";
|
|
5
|
+
import "../chunk-3NSBOUT3.js";
|
|
6
|
+
import "../chunk-62YTUT6J.js";
|
|
8
7
|
import "../chunk-ITPEXLHA.js";
|
|
9
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-PAH27GSN.js";
|
|
10
9
|
import "../chunk-MXSSG3QU.js";
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-MFAWT5O5.js";
|
|
10
|
+
import "../chunk-N2AXRYLC.js";
|
|
11
|
+
import "../chunk-LYHGEHXG.js";
|
|
14
12
|
import "../chunk-7766SIJP.js";
|
|
13
|
+
import "../chunk-2CDEETQN.js";
|
|
14
|
+
import "../chunk-QK3UCXWL.js";
|
|
15
|
+
import "../chunk-Z2XBWN7A.js";
|
|
16
|
+
import "../chunk-3RG5ZIWI.js";
|
|
15
17
|
export {
|
|
16
18
|
rebuildCommand,
|
|
17
19
|
registerRebuildCommand
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/commands/recover.ts
|
|
31
|
+
var recover_exports = {};
|
|
32
|
+
__export(recover_exports, {
|
|
33
|
+
checkRecoveryStatus: () => checkRecoveryStatus,
|
|
34
|
+
formatCheckpointList: () => formatCheckpointList,
|
|
35
|
+
formatRecoveryCheckStatus: () => formatRecoveryCheckStatus,
|
|
36
|
+
formatRecoveryInfo: () => formatRecoveryInfo,
|
|
37
|
+
listCheckpoints: () => listCheckpoints,
|
|
38
|
+
recover: () => recover
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(recover_exports);
|
|
41
|
+
var fs2 = __toESM(require("fs"), 1);
|
|
42
|
+
var path2 = __toESM(require("path"), 1);
|
|
43
|
+
|
|
44
|
+
// src/commands/checkpoint.ts
|
|
45
|
+
var fs = __toESM(require("fs"), 1);
|
|
46
|
+
var path = __toESM(require("path"), 1);
|
|
47
|
+
var CLAWVAULT_DIR = ".clawvault";
|
|
48
|
+
var CHECKPOINT_FILE = "last-checkpoint.json";
|
|
49
|
+
var DIRTY_DEATH_FLAG = "dirty-death.flag";
|
|
50
|
+
var CHECKPOINT_RETENTION_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
51
|
+
async function clearDirtyFlag(vaultPath) {
|
|
52
|
+
const flagPath = path.join(vaultPath, CLAWVAULT_DIR, DIRTY_DEATH_FLAG);
|
|
53
|
+
if (fs.existsSync(flagPath)) {
|
|
54
|
+
fs.unlinkSync(flagPath);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function checkDirtyDeath(vaultPath) {
|
|
58
|
+
const dir = path.join(vaultPath, CLAWVAULT_DIR);
|
|
59
|
+
const flagPath = path.join(dir, DIRTY_DEATH_FLAG);
|
|
60
|
+
const checkpointPath = path.join(dir, CHECKPOINT_FILE);
|
|
61
|
+
if (!fs.existsSync(flagPath)) {
|
|
62
|
+
return { died: false, checkpoint: null, deathTime: null };
|
|
63
|
+
}
|
|
64
|
+
const deathTime = fs.readFileSync(flagPath, "utf-8").trim();
|
|
65
|
+
let checkpoint = null;
|
|
66
|
+
if (fs.existsSync(checkpointPath)) {
|
|
67
|
+
try {
|
|
68
|
+
checkpoint = JSON.parse(fs.readFileSync(checkpointPath, "utf-8"));
|
|
69
|
+
} catch {
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { died: true, checkpoint, deathTime };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/lib/time.ts
|
|
76
|
+
function formatAge(ms) {
|
|
77
|
+
if (!Number.isFinite(ms)) return "unknown";
|
|
78
|
+
const seconds = Math.max(0, Math.floor(ms / 1e3));
|
|
79
|
+
const minutes = Math.floor(seconds / 60);
|
|
80
|
+
const hours = Math.floor(minutes / 60);
|
|
81
|
+
const days = Math.floor(hours / 24);
|
|
82
|
+
if (days > 0) return `${days}d ${hours % 24}h`;
|
|
83
|
+
if (hours > 0) return `${hours}h ${minutes % 60}m`;
|
|
84
|
+
if (minutes > 0) return `${minutes}m ${seconds % 60}s`;
|
|
85
|
+
return `${seconds}s`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/commands/recover.ts
|
|
89
|
+
var CLAWVAULT_DIR2 = ".clawvault";
|
|
90
|
+
var CHECKPOINT_FILE2 = "last-checkpoint.json";
|
|
91
|
+
var CHECKPOINT_HISTORY_DIR = "checkpoints";
|
|
92
|
+
function parseCheckpointFile(filePath) {
|
|
93
|
+
try {
|
|
94
|
+
const parsed = JSON.parse(fs2.readFileSync(filePath, "utf-8"));
|
|
95
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const record = parsed;
|
|
99
|
+
const timestamp = typeof record.timestamp === "string" ? record.timestamp.trim() : "";
|
|
100
|
+
if (!timestamp) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
const checkpoint = {
|
|
104
|
+
timestamp,
|
|
105
|
+
workingOn: typeof record.workingOn === "string" ? record.workingOn : null,
|
|
106
|
+
focus: typeof record.focus === "string" ? record.focus : null,
|
|
107
|
+
blocked: typeof record.blocked === "string" ? record.blocked : null
|
|
108
|
+
};
|
|
109
|
+
if (typeof record.sessionId === "string") {
|
|
110
|
+
checkpoint.sessionId = record.sessionId;
|
|
111
|
+
}
|
|
112
|
+
if (typeof record.sessionKey === "string") {
|
|
113
|
+
checkpoint.sessionKey = record.sessionKey;
|
|
114
|
+
}
|
|
115
|
+
if (typeof record.model === "string") {
|
|
116
|
+
checkpoint.model = record.model;
|
|
117
|
+
}
|
|
118
|
+
if (typeof record.tokenEstimate === "number" && Number.isFinite(record.tokenEstimate)) {
|
|
119
|
+
checkpoint.tokenEstimate = record.tokenEstimate;
|
|
120
|
+
}
|
|
121
|
+
if (typeof record.sessionStartedAt === "string") {
|
|
122
|
+
checkpoint.sessionStartedAt = record.sessionStartedAt;
|
|
123
|
+
}
|
|
124
|
+
if (typeof record.urgent === "boolean") {
|
|
125
|
+
checkpoint.urgent = record.urgent;
|
|
126
|
+
}
|
|
127
|
+
return checkpoint;
|
|
128
|
+
} catch {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function compareByTimestampDesc(left, right) {
|
|
133
|
+
const leftTime = Date.parse(left.timestamp);
|
|
134
|
+
const rightTime = Date.parse(right.timestamp);
|
|
135
|
+
if (!Number.isNaN(leftTime) && !Number.isNaN(rightTime)) {
|
|
136
|
+
return rightTime - leftTime;
|
|
137
|
+
}
|
|
138
|
+
return right.timestamp.localeCompare(left.timestamp);
|
|
139
|
+
}
|
|
140
|
+
async function checkRecoveryStatus(vaultPath) {
|
|
141
|
+
const { died, checkpoint, deathTime } = await checkDirtyDeath(vaultPath);
|
|
142
|
+
return { died, checkpoint, deathTime };
|
|
143
|
+
}
|
|
144
|
+
function listCheckpoints(vaultPath) {
|
|
145
|
+
const resolvedVaultPath = path2.resolve(vaultPath);
|
|
146
|
+
const clawvaultDir = path2.join(resolvedVaultPath, CLAWVAULT_DIR2);
|
|
147
|
+
const historyDir = path2.join(clawvaultDir, CHECKPOINT_HISTORY_DIR);
|
|
148
|
+
const checkpoints = [];
|
|
149
|
+
if (fs2.existsSync(historyDir)) {
|
|
150
|
+
const files = fs2.readdirSync(historyDir).filter((entry) => entry.endsWith(".json")).sort().reverse();
|
|
151
|
+
for (const fileName of files) {
|
|
152
|
+
const absolutePath = path2.join(historyDir, fileName);
|
|
153
|
+
const parsed = parseCheckpointFile(absolutePath);
|
|
154
|
+
if (!parsed) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
checkpoints.push({
|
|
158
|
+
...parsed,
|
|
159
|
+
filePath: absolutePath
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (checkpoints.length === 0) {
|
|
164
|
+
const latestCheckpointPath = path2.join(clawvaultDir, CHECKPOINT_FILE2);
|
|
165
|
+
if (fs2.existsSync(latestCheckpointPath)) {
|
|
166
|
+
const fallback = parseCheckpointFile(latestCheckpointPath);
|
|
167
|
+
if (fallback) {
|
|
168
|
+
checkpoints.push({
|
|
169
|
+
...fallback,
|
|
170
|
+
filePath: latestCheckpointPath
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return checkpoints.sort(compareByTimestampDesc);
|
|
176
|
+
}
|
|
177
|
+
async function recover(vaultPath, options = {}) {
|
|
178
|
+
const { clearFlag = false } = options;
|
|
179
|
+
const { died, checkpoint, deathTime } = await checkRecoveryStatus(vaultPath);
|
|
180
|
+
if (!died) {
|
|
181
|
+
return {
|
|
182
|
+
died: false,
|
|
183
|
+
deathTime: null,
|
|
184
|
+
checkpoint: null,
|
|
185
|
+
handoffPath: null,
|
|
186
|
+
handoffContent: null,
|
|
187
|
+
recoveryMessage: "No context death detected. Clean startup."
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
const handoffsDir = path2.join(vaultPath, "handoffs");
|
|
191
|
+
let handoffPath = null;
|
|
192
|
+
let handoffContent = null;
|
|
193
|
+
if (fs2.existsSync(handoffsDir)) {
|
|
194
|
+
const files = fs2.readdirSync(handoffsDir).filter((f) => f.startsWith("handoff-") && f.endsWith(".md")).sort().reverse();
|
|
195
|
+
if (files.length > 0) {
|
|
196
|
+
handoffPath = path2.join(handoffsDir, files[0]);
|
|
197
|
+
handoffContent = fs2.readFileSync(handoffPath, "utf-8");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
let message = "\u26A0\uFE0F **CONTEXT DEATH DETECTED**\n\n";
|
|
201
|
+
message += `Your previous session died at ${deathTime}.
|
|
202
|
+
|
|
203
|
+
`;
|
|
204
|
+
if (checkpoint) {
|
|
205
|
+
message += "**Last known state:**\n";
|
|
206
|
+
if (checkpoint.workingOn) {
|
|
207
|
+
message += `- Working on: ${checkpoint.workingOn}
|
|
208
|
+
`;
|
|
209
|
+
}
|
|
210
|
+
if (checkpoint.focus) {
|
|
211
|
+
message += `- Focus: ${checkpoint.focus}
|
|
212
|
+
`;
|
|
213
|
+
}
|
|
214
|
+
if (checkpoint.blocked) {
|
|
215
|
+
message += `- Blocked: ${checkpoint.blocked}
|
|
216
|
+
`;
|
|
217
|
+
}
|
|
218
|
+
message += "\n";
|
|
219
|
+
}
|
|
220
|
+
if (handoffPath) {
|
|
221
|
+
message += `**Last handoff:** ${path2.basename(handoffPath)}
|
|
222
|
+
`;
|
|
223
|
+
message += "Review and resume from where you left off.\n";
|
|
224
|
+
} else {
|
|
225
|
+
message += "**No handoff found.** You may have lost context.\n";
|
|
226
|
+
}
|
|
227
|
+
if (clearFlag) {
|
|
228
|
+
await clearDirtyFlag(vaultPath);
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
died: true,
|
|
232
|
+
deathTime,
|
|
233
|
+
checkpoint,
|
|
234
|
+
handoffPath,
|
|
235
|
+
handoffContent,
|
|
236
|
+
recoveryMessage: message
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function formatRecoveryCheckStatus(info) {
|
|
240
|
+
if (!info.died) {
|
|
241
|
+
return "\u2713 Dirty death flag is clear.";
|
|
242
|
+
}
|
|
243
|
+
let output = "\u26A0\uFE0F Dirty death flag is set.\n";
|
|
244
|
+
output += `Death time: ${info.deathTime}
|
|
245
|
+
`;
|
|
246
|
+
if (info.checkpoint?.timestamp) {
|
|
247
|
+
const age = formatAge(Date.now() - new Date(info.checkpoint.timestamp).getTime());
|
|
248
|
+
output += `Last checkpoint: ${info.checkpoint.timestamp} (${age} ago)
|
|
249
|
+
`;
|
|
250
|
+
} else {
|
|
251
|
+
output += "Last checkpoint: unavailable\n";
|
|
252
|
+
}
|
|
253
|
+
output += "Use `clawvault recover --clear` after reviewing recovery details.";
|
|
254
|
+
return output;
|
|
255
|
+
}
|
|
256
|
+
function formatCheckpointList(checkpoints) {
|
|
257
|
+
if (checkpoints.length === 0) {
|
|
258
|
+
return "No checkpoints found.";
|
|
259
|
+
}
|
|
260
|
+
const headers = ["TIMESTAMP", "WORKING_ON", "FOCUS", "FILE"];
|
|
261
|
+
const rows = checkpoints.map((checkpoint) => ({
|
|
262
|
+
timestamp: checkpoint.timestamp,
|
|
263
|
+
workingOn: checkpoint.workingOn ?? "-",
|
|
264
|
+
focus: checkpoint.focus ?? "-",
|
|
265
|
+
file: path2.basename(checkpoint.filePath)
|
|
266
|
+
}));
|
|
267
|
+
const timestampWidth = Math.max(headers[0].length, ...rows.map((row) => row.timestamp.length));
|
|
268
|
+
const workingOnWidth = Math.max(headers[1].length, ...rows.map((row) => row.workingOn.length));
|
|
269
|
+
const focusWidth = Math.max(headers[2].length, ...rows.map((row) => row.focus.length));
|
|
270
|
+
const fileWidth = Math.max(headers[3].length, ...rows.map((row) => row.file.length));
|
|
271
|
+
const lines = [];
|
|
272
|
+
lines.push(
|
|
273
|
+
`${headers[0].padEnd(timestampWidth)} ${headers[1].padEnd(workingOnWidth)} ${headers[2].padEnd(focusWidth)} ${headers[3].padEnd(fileWidth)}`
|
|
274
|
+
);
|
|
275
|
+
lines.push(
|
|
276
|
+
`${"-".repeat(timestampWidth)} ${"-".repeat(workingOnWidth)} ${"-".repeat(focusWidth)} ${"-".repeat(fileWidth)}`
|
|
277
|
+
);
|
|
278
|
+
for (const row of rows) {
|
|
279
|
+
lines.push(
|
|
280
|
+
`${row.timestamp.padEnd(timestampWidth)} ${row.workingOn.padEnd(workingOnWidth)} ${row.focus.padEnd(focusWidth)} ${row.file}`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
return lines.join("\n");
|
|
284
|
+
}
|
|
285
|
+
function formatRecoveryInfo(info, options = {}) {
|
|
286
|
+
const { verbose = false } = options;
|
|
287
|
+
if (!info.died) {
|
|
288
|
+
return "\u2713 Clean startup - no context death detected.";
|
|
289
|
+
}
|
|
290
|
+
let output = "\n\u26A0\uFE0F CONTEXT DEATH DETECTED\n";
|
|
291
|
+
output += "\u2550".repeat(40) + "\n\n";
|
|
292
|
+
output += `Death time: ${info.deathTime}
|
|
293
|
+
`;
|
|
294
|
+
if (info.checkpoint?.timestamp) {
|
|
295
|
+
const age = formatAge(Date.now() - new Date(info.checkpoint.timestamp).getTime());
|
|
296
|
+
output += `Checkpoint: ${info.checkpoint.timestamp} (${age} ago)
|
|
297
|
+
`;
|
|
298
|
+
}
|
|
299
|
+
output += "\n";
|
|
300
|
+
if (info.checkpoint) {
|
|
301
|
+
output += "Last checkpoint:\n";
|
|
302
|
+
if (info.checkpoint.workingOn) {
|
|
303
|
+
output += ` \u2022 Working on: ${info.checkpoint.workingOn}
|
|
304
|
+
`;
|
|
305
|
+
}
|
|
306
|
+
if (info.checkpoint.focus) {
|
|
307
|
+
output += ` \u2022 Focus: ${info.checkpoint.focus}
|
|
308
|
+
`;
|
|
309
|
+
}
|
|
310
|
+
if (info.checkpoint.blocked) {
|
|
311
|
+
output += ` \u2022 Blocked: ${info.checkpoint.blocked}
|
|
312
|
+
`;
|
|
313
|
+
}
|
|
314
|
+
if (info.checkpoint.sessionKey || info.checkpoint.model || info.checkpoint.tokenEstimate !== void 0) {
|
|
315
|
+
output += " \u2022 Session:\n";
|
|
316
|
+
if (info.checkpoint.sessionKey) {
|
|
317
|
+
output += ` - Key: ${info.checkpoint.sessionKey}
|
|
318
|
+
`;
|
|
319
|
+
}
|
|
320
|
+
if (info.checkpoint.model) {
|
|
321
|
+
output += ` - Model: ${info.checkpoint.model}
|
|
322
|
+
`;
|
|
323
|
+
}
|
|
324
|
+
if (info.checkpoint.tokenEstimate !== void 0) {
|
|
325
|
+
output += ` - Token estimate: ${info.checkpoint.tokenEstimate}
|
|
326
|
+
`;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
output += "\n";
|
|
330
|
+
} else {
|
|
331
|
+
output += "No checkpoint data found.\n\n";
|
|
332
|
+
}
|
|
333
|
+
if (info.handoffPath) {
|
|
334
|
+
output += `Last handoff: ${path2.basename(info.handoffPath)}
|
|
335
|
+
`;
|
|
336
|
+
} else {
|
|
337
|
+
output += "No handoff found - context may be lost.\n";
|
|
338
|
+
}
|
|
339
|
+
if (verbose) {
|
|
340
|
+
if (info.checkpoint) {
|
|
341
|
+
output += "\nCheckpoint JSON:\n";
|
|
342
|
+
output += JSON.stringify(info.checkpoint, null, 2) + "\n";
|
|
343
|
+
}
|
|
344
|
+
if (info.handoffContent) {
|
|
345
|
+
output += "\nHandoff content:\n";
|
|
346
|
+
output += info.handoffContent.trim() + "\n";
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
output += "\n" + "\u2550".repeat(40) + "\n";
|
|
350
|
+
output += "Run `clawvault recap` to see full context.\n";
|
|
351
|
+
return output;
|
|
352
|
+
}
|
|
353
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
354
|
+
0 && (module.exports = {
|
|
355
|
+
checkRecoveryStatus,
|
|
356
|
+
formatCheckpointList,
|
|
357
|
+
formatRecoveryCheckStatus,
|
|
358
|
+
formatRecoveryInfo,
|
|
359
|
+
listCheckpoints,
|
|
360
|
+
recover
|
|
361
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CheckpointData } from './checkpoint.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Recovery command - detect dirty death and provide recovery info
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
interface RecoveryInfo {
|
|
8
|
+
died: boolean;
|
|
9
|
+
deathTime: string | null;
|
|
10
|
+
checkpoint: CheckpointData | null;
|
|
11
|
+
handoffPath: string | null;
|
|
12
|
+
handoffContent: string | null;
|
|
13
|
+
recoveryMessage: string;
|
|
14
|
+
}
|
|
15
|
+
interface RecoveryCheckInfo {
|
|
16
|
+
died: boolean;
|
|
17
|
+
deathTime: string | null;
|
|
18
|
+
checkpoint: CheckpointData | null;
|
|
19
|
+
}
|
|
20
|
+
interface ListedCheckpoint extends CheckpointData {
|
|
21
|
+
filePath: string;
|
|
22
|
+
}
|
|
23
|
+
declare function checkRecoveryStatus(vaultPath: string): Promise<RecoveryCheckInfo>;
|
|
24
|
+
declare function listCheckpoints(vaultPath: string): ListedCheckpoint[];
|
|
25
|
+
declare function recover(vaultPath: string, options?: {
|
|
26
|
+
clearFlag?: boolean;
|
|
27
|
+
verbose?: boolean;
|
|
28
|
+
}): Promise<RecoveryInfo>;
|
|
29
|
+
declare function formatRecoveryCheckStatus(info: RecoveryCheckInfo): string;
|
|
30
|
+
declare function formatCheckpointList(checkpoints: ListedCheckpoint[]): string;
|
|
31
|
+
/**
|
|
32
|
+
* Format recovery info for CLI output
|
|
33
|
+
*/
|
|
34
|
+
declare function formatRecoveryInfo(info: RecoveryInfo, options?: {
|
|
35
|
+
verbose?: boolean;
|
|
36
|
+
}): string;
|
|
37
|
+
|
|
38
|
+
export { type ListedCheckpoint, type RecoveryCheckInfo, type RecoveryInfo, checkRecoveryStatus, formatCheckpointList, formatRecoveryCheckStatus, formatRecoveryInfo, listCheckpoints, recover };
|
package/dist/commands/recover.js
CHANGED
|
@@ -5,9 +5,10 @@ import {
|
|
|
5
5
|
formatRecoveryInfo,
|
|
6
6
|
listCheckpoints,
|
|
7
7
|
recover
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-QBLMXKF2.js";
|
|
9
9
|
import "../chunk-7ZRP733D.js";
|
|
10
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-WAZ3NLWL.js";
|
|
11
|
+
import "../chunk-3RG5ZIWI.js";
|
|
11
12
|
export {
|
|
12
13
|
checkRecoveryStatus,
|
|
13
14
|
formatCheckpointList,
|