clawvault 3.2.0 → 3.3.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 +54 -14
- package/bin/clawvault.js +0 -2
- package/bin/command-registration.test.js +13 -1
- package/bin/help-contract.test.js +14 -0
- package/bin/register-core-commands.js +88 -0
- package/bin/register-core-commands.test.js +80 -0
- package/bin/register-maintenance-commands.js +57 -6
- package/bin/register-query-commands.js +10 -28
- package/bin/test-helpers/cli-command-fixtures.js +1 -0
- package/dist/chunk-2PKBIKDH.js +130 -0
- package/dist/{chunk-2JQ3O2YL.js → chunk-5EFSWZO6.js} +3 -3
- package/dist/{chunk-77Q5CSPJ.js → chunk-7SWP5FKU.js} +33 -701
- package/dist/{chunk-URXDAUVH.js → chunk-AXSJIFOJ.js} +174 -1
- package/dist/{chunk-23YDQ3QU.js → chunk-BLQXXX7Q.js} +6 -6
- package/dist/chunk-CSHO3PJB.js +684 -0
- package/dist/{chunk-SLXOR3CC.js → chunk-DOIUYIXV.js} +2 -2
- package/dist/{chunk-NCKFNBHJ.js → chunk-DVOUSOR3.js} +79 -5
- package/dist/{chunk-CLJTREDS.js → chunk-ECGJYWNA.js} +193 -41
- package/dist/{chunk-BUEW6IIK.js → chunk-EL6UBSX5.js} +5 -5
- package/dist/{chunk-6FH3IULF.js → chunk-FZ5I2NF7.js} +1 -1
- package/dist/{chunk-ZN54U2OZ.js → chunk-GFCHWMGD.js} +3 -3
- package/dist/{chunk-GNJL4YGR.js → chunk-GJO3CFUN.js} +30 -6
- package/dist/chunk-H3JZIB5O.js +322 -0
- package/dist/chunk-HEHO7SMV.js +51 -0
- package/dist/{chunk-STCQGCEQ.js → chunk-HGDDW24U.js} +3 -3
- package/dist/chunk-J3YUXVID.js +907 -0
- package/dist/{chunk-Y6VJKXGL.js → chunk-KCYWJDDW.js} +1 -1
- package/dist/{chunk-W4SPAEE7.js → chunk-OFOCU2V4.js} +5 -4
- package/dist/chunk-PTWPPVC7.js +972 -0
- package/dist/{chunk-QSHD36LH.js → chunk-QFWERBDP.js} +2 -2
- package/dist/{chunk-QSRRMEYM.js → chunk-S7N7HI5E.js} +1 -1
- package/dist/{chunk-PBACDKKP.js → chunk-T7E764W3.js} +3 -3
- package/dist/chunk-TDWFBDAQ.js +1016 -0
- package/dist/{chunk-ESVS6K2B.js → chunk-TWMI3SNN.js} +6 -5
- package/dist/{chunk-2RAZ4ZFE.js → chunk-VBILES4B.js} +1 -1
- package/dist/{chunk-ESFLMDRB.js → chunk-VXAGOLDP.js} +3 -3
- package/dist/chunk-YCUVAOFC.js +158 -0
- package/dist/{chunk-SS4B7P7V.js → chunk-YIDV4VV2.js} +1 -1
- package/dist/chunk-ZKWPCBYT.js +600 -0
- package/dist/cli/index.js +24 -24
- package/dist/commands/archive.js +2 -2
- package/dist/commands/benchmark.d.ts +12 -0
- package/dist/commands/benchmark.js +12 -0
- package/dist/commands/context.js +6 -5
- package/dist/commands/doctor.d.ts +8 -3
- package/dist/commands/doctor.js +6 -20
- package/dist/commands/embed.js +5 -4
- package/dist/commands/entities.js +1 -1
- package/dist/commands/graph.js +2 -2
- package/dist/commands/inbox.d.ts +23 -0
- package/dist/commands/inbox.js +11 -0
- package/dist/commands/inject.d.ts +1 -1
- package/dist/commands/inject.js +3 -3
- package/dist/commands/link.js +6 -6
- package/dist/commands/maintain.d.ts +32 -0
- package/dist/commands/maintain.js +12 -0
- package/dist/commands/migrate-observations.js +2 -2
- package/dist/commands/observe.js +9 -8
- package/dist/commands/rebuild-embeddings.js +47 -16
- package/dist/commands/rebuild.js +7 -6
- package/dist/commands/reflect.js +5 -5
- package/dist/commands/replay.js +8 -7
- package/dist/commands/setup.js +3 -2
- package/dist/commands/sleep.d.ts +1 -1
- package/dist/commands/sleep.js +17 -15
- package/dist/commands/status.js +26 -24
- package/dist/commands/sync-bd.js +2 -2
- package/dist/commands/tailscale.js +2 -2
- package/dist/commands/wake.d.ts +1 -1
- package/dist/commands/wake.js +8 -7
- package/dist/index.d.ts +168 -16
- package/dist/index.js +271 -108
- package/dist/{inject-DYUrDqQO.d.ts → inject-DEb_jpLi.d.ts} +3 -1
- package/dist/lib/config.js +1 -1
- package/dist/{types-BbWJoC1c.d.ts → types-DslKvCaj.d.ts} +51 -1
- package/hooks/clawvault/HOOK.md +22 -5
- package/hooks/clawvault/handler.js +213 -78
- package/hooks/clawvault/handler.test.js +109 -43
- package/hooks/clawvault/integrity.js +112 -0
- package/hooks/clawvault/integrity.test.js +32 -0
- package/hooks/clawvault/openclaw.plugin.json +133 -15
- package/openclaw.plugin.json +126 -20
- package/package.json +2 -2
- package/bin/register-workgraph-commands.js +0 -1368
- package/dist/chunk-33VSQP4J.js +0 -37
- package/dist/chunk-4BQTQMJP.js +0 -93
- package/dist/chunk-EK6S23ZB.js +0 -469
- package/dist/chunk-GAOWA7GR.js +0 -501
- package/dist/chunk-GGA32J2R.js +0 -784
- package/dist/chunk-MM6QGW3P.js +0 -207
- package/dist/chunk-QVEERJSP.js +0 -152
- package/dist/chunk-U4O6C46S.js +0 -154
- package/dist/chunk-VSL7KY3M.js +0 -189
- package/dist/chunk-WMGIIABP.js +0 -15
- package/dist/commands/workgraph.d.ts +0 -124
- package/dist/commands/workgraph.js +0 -38
- package/dist/ledger-B7g7jhqG.d.ts +0 -44
- package/dist/registry-BR4326o0.d.ts +0 -30
- package/dist/store-CA-6sKCJ.d.ts +0 -34
- package/dist/thread-B9LhXNU0.d.ts +0 -41
- package/dist/workgraph/index.d.ts +0 -5
- package/dist/workgraph/index.js +0 -23
- package/dist/workgraph/ledger.d.ts +0 -2
- package/dist/workgraph/ledger.js +0 -25
- package/dist/workgraph/registry.d.ts +0 -2
- package/dist/workgraph/registry.js +0 -19
- package/dist/workgraph/store.d.ts +0 -2
- package/dist/workgraph/store.js +0 -25
- package/dist/workgraph/thread.d.ts +0 -2
- package/dist/workgraph/thread.js +0 -25
- package/dist/workgraph/types.d.ts +0 -54
- package/dist/workgraph/types.js +0 -7
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// src/lib/inbox.ts
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { createHash } from "crypto";
|
|
5
|
+
import matter from "gray-matter";
|
|
6
|
+
import { globSync } from "glob";
|
|
7
|
+
function normalizeContentForHash(content) {
|
|
8
|
+
return content.replace(/\r\n/g, "\n").trim();
|
|
9
|
+
}
|
|
10
|
+
function hashContent(content) {
|
|
11
|
+
return createHash("sha256").update(normalizeContentForHash(content)).digest("hex");
|
|
12
|
+
}
|
|
13
|
+
function ensureInboxDir(vaultPath) {
|
|
14
|
+
const inboxPath = path.join(path.resolve(vaultPath), "inbox");
|
|
15
|
+
fs.mkdirSync(inboxPath, { recursive: true });
|
|
16
|
+
return inboxPath;
|
|
17
|
+
}
|
|
18
|
+
function toSlug(value) {
|
|
19
|
+
const normalized = value.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "").trim();
|
|
20
|
+
return normalized || "capture";
|
|
21
|
+
}
|
|
22
|
+
function compactTimestamp(date) {
|
|
23
|
+
return date.toISOString().replace(/[-:]/g, "").replace(/\..+$/, "").replace("T", "t");
|
|
24
|
+
}
|
|
25
|
+
function deriveTitle(content) {
|
|
26
|
+
const firstLine = content.split(/\r?\n/).map((line) => line.trim()).find(Boolean);
|
|
27
|
+
if (!firstLine) {
|
|
28
|
+
return "Inbox Capture";
|
|
29
|
+
}
|
|
30
|
+
return firstLine.slice(0, 80);
|
|
31
|
+
}
|
|
32
|
+
function addInboxItem(vaultPath, rawContent, options = {}) {
|
|
33
|
+
const content = rawContent.replace(/\r\n/g, "\n").trim();
|
|
34
|
+
if (!content) {
|
|
35
|
+
throw new Error("Inbox content is empty.");
|
|
36
|
+
}
|
|
37
|
+
const now = options.now ? options.now() : /* @__PURE__ */ new Date();
|
|
38
|
+
const source = options.source?.trim() || "manual";
|
|
39
|
+
const title = options.title?.trim() || deriveTitle(content);
|
|
40
|
+
const hash = hashContent(content);
|
|
41
|
+
const baseSlug = toSlug(title);
|
|
42
|
+
const timestamp = compactTimestamp(now);
|
|
43
|
+
const inboxDir = ensureInboxDir(vaultPath);
|
|
44
|
+
let fileName = `${baseSlug}-${timestamp}-${hash.slice(0, 8)}.md`;
|
|
45
|
+
let fullPath = path.join(inboxDir, fileName);
|
|
46
|
+
let counter = 1;
|
|
47
|
+
while (fs.existsSync(fullPath)) {
|
|
48
|
+
fileName = `${baseSlug}-${timestamp}-${hash.slice(0, 8)}-${counter}.md`;
|
|
49
|
+
fullPath = path.join(inboxDir, fileName);
|
|
50
|
+
counter += 1;
|
|
51
|
+
}
|
|
52
|
+
const doc = matter.stringify(`${content}
|
|
53
|
+
`, {
|
|
54
|
+
title,
|
|
55
|
+
date: now.toISOString().split("T")[0],
|
|
56
|
+
capturedAt: now.toISOString(),
|
|
57
|
+
source,
|
|
58
|
+
type: "inbox",
|
|
59
|
+
status: "pending",
|
|
60
|
+
hash
|
|
61
|
+
});
|
|
62
|
+
fs.writeFileSync(fullPath, doc, "utf-8");
|
|
63
|
+
return {
|
|
64
|
+
id: `inbox/${fileName.replace(/\.md$/, "")}`,
|
|
65
|
+
hash,
|
|
66
|
+
title,
|
|
67
|
+
path: fullPath,
|
|
68
|
+
relativePath: path.join("inbox", fileName),
|
|
69
|
+
source
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function parseInboxFile(vaultPath, fullPath) {
|
|
73
|
+
const stats = fs.statSync(fullPath);
|
|
74
|
+
const relativePath = path.relative(path.resolve(vaultPath), fullPath);
|
|
75
|
+
const ext = path.extname(fullPath).toLowerCase();
|
|
76
|
+
const raw = fs.readFileSync(fullPath, "utf-8");
|
|
77
|
+
if (ext === ".md") {
|
|
78
|
+
const parsed = matter(raw);
|
|
79
|
+
const title = typeof parsed.data.title === "string" ? parsed.data.title : path.basename(fullPath, ext);
|
|
80
|
+
const capturedAt = typeof parsed.data.capturedAt === "string" ? new Date(parsed.data.capturedAt) : stats.mtime;
|
|
81
|
+
const content2 = parsed.content.trim();
|
|
82
|
+
return {
|
|
83
|
+
id: relativePath.replace(/\\/g, "/").replace(/\.md$/, ""),
|
|
84
|
+
hash: hashContent(content2),
|
|
85
|
+
title,
|
|
86
|
+
content: content2,
|
|
87
|
+
path: fullPath,
|
|
88
|
+
relativePath: relativePath.replace(/\\/g, "/"),
|
|
89
|
+
capturedAt,
|
|
90
|
+
frontmatter: parsed.data
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const content = raw.trim();
|
|
94
|
+
return {
|
|
95
|
+
id: relativePath.replace(/\\/g, "/"),
|
|
96
|
+
hash: hashContent(content),
|
|
97
|
+
title: path.basename(fullPath),
|
|
98
|
+
content,
|
|
99
|
+
path: fullPath,
|
|
100
|
+
relativePath: relativePath.replace(/\\/g, "/"),
|
|
101
|
+
capturedAt: stats.mtime,
|
|
102
|
+
frontmatter: {}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function readInboxItems(vaultPath, options = {}) {
|
|
106
|
+
const inboxDir = path.join(path.resolve(vaultPath), "inbox");
|
|
107
|
+
if (!fs.existsSync(inboxDir)) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
const ignore = ["**/processed/**", "**/merged/**"];
|
|
111
|
+
if (!options.includeArchived) {
|
|
112
|
+
ignore.push("**/archive/**");
|
|
113
|
+
}
|
|
114
|
+
const files = globSync("**/*", {
|
|
115
|
+
cwd: inboxDir,
|
|
116
|
+
nodir: true,
|
|
117
|
+
absolute: true,
|
|
118
|
+
ignore
|
|
119
|
+
});
|
|
120
|
+
const items = files.map((filePath) => parseInboxFile(vaultPath, filePath)).sort((left, right) => left.capturedAt.getTime() - right.capturedAt.getTime());
|
|
121
|
+
if (options.limit && options.limit > 0) {
|
|
122
|
+
return items.slice(0, options.limit);
|
|
123
|
+
}
|
|
124
|
+
return items;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export {
|
|
128
|
+
addInboxItem,
|
|
129
|
+
readInboxItems
|
|
130
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveVaultPath
|
|
3
|
+
} from "./chunk-GJO3CFUN.js";
|
|
1
4
|
import {
|
|
2
5
|
DATE_HEADING_RE,
|
|
3
6
|
parseObservationLine,
|
|
4
7
|
renderScoredObservationLine
|
|
5
8
|
} from "./chunk-FHFUXL6G.js";
|
|
6
|
-
import {
|
|
7
|
-
resolveVaultPath
|
|
8
|
-
} from "./chunk-GNJL4YGR.js";
|
|
9
9
|
import {
|
|
10
10
|
listObservationFiles
|
|
11
11
|
} from "./chunk-Z2XBWN7A.js";
|