clawvault 3.2.1 → 3.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 +56 -16
- package/bin/clawvault.js +0 -2
- package/bin/command-registration.test.js +15 -2
- package/bin/help-contract.test.js +16 -0
- package/bin/register-core-commands.js +88 -0
- package/bin/register-core-commands.test.js +80 -0
- package/bin/register-maintenance-commands.js +84 -7
- package/bin/register-query-commands.js +45 -28
- package/bin/register-query-commands.test.js +15 -0
- package/bin/test-helpers/cli-command-fixtures.js +1 -0
- package/dist/chunk-2PKBIKDH.js +130 -0
- package/dist/{chunk-U67V476Y.js → chunk-2ZDO52B4.js} +18 -1
- package/dist/{chunk-ZZA73MFY.js → chunk-33DOSHTA.js} +176 -36
- package/dist/chunk-35JCYSRR.js +158 -0
- package/dist/{chunk-AZYOKJYC.js → chunk-4PY655YM.js} +13 -1
- package/dist/{chunk-2JQ3O2YL.js → chunk-5EFSWZO6.js} +3 -3
- package/dist/{chunk-Y3TIJEBP.js → chunk-7SWP5FKU.js} +34 -613
- package/dist/{chunk-4VQTUVH7.js → chunk-7YZWHM36.js} +52 -26
- package/dist/{chunk-URXDAUVH.js → chunk-AXSJIFOJ.js} +174 -1
- package/dist/{chunk-4ITRXIVT.js → chunk-BLQXXX7Q.js} +6 -6
- package/dist/chunk-CSHO3PJB.js +684 -0
- package/dist/chunk-D5U3Q4N5.js +872 -0
- package/dist/chunk-DCF4KMFD.js +158 -0
- package/dist/{chunk-S5OJEGFG.js → chunk-DOIUYIXV.js} +2 -2
- package/dist/{chunk-YXQCA6B7.js → chunk-DVOUSOR3.js} +112 -7
- package/dist/{chunk-YDWHS4LJ.js → chunk-ECGJYWNA.js} +205 -33
- package/dist/{chunk-QMHPQYUV.js → chunk-EL6UBSX5.js} +7 -6
- package/dist/chunk-FZ5I2NF7.js +352 -0
- package/dist/{chunk-WJVWINEM.js → chunk-GFCHWMGD.js} +55 -6
- 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-UCQAOZHW.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-P5EPF6MB.js → chunk-MW5C6ZQA.js} +110 -13
- package/dist/chunk-NSXYM6EZ.js +255 -0
- package/dist/{chunk-YNIPYN4F.js → chunk-OFOCU2V4.js} +6 -5
- package/dist/{chunk-42MXU7A6.js → chunk-P62WHA27.js} +58 -47
- package/dist/chunk-PTWPPVC7.js +972 -0
- package/dist/{chunk-FAKNOB7Y.js → chunk-QFWERBDP.js} +2 -2
- package/dist/chunk-QYQAGBTM.js +2097 -0
- package/dist/chunk-RL2L6I6K.js +223 -0
- package/dist/{chunk-IIOU45CK.js → chunk-S7N7HI5E.js} +2 -2
- package/dist/{chunk-ECRZL5XR.js → chunk-T7E764W3.js} +23 -7
- package/dist/{chunk-MNPUYCHQ.js → chunk-TWMI3SNN.js} +6 -5
- package/dist/{chunk-2RAZ4ZFE.js → chunk-VBILES4B.js} +1 -1
- package/dist/{chunk-PI4WMLMG.js → chunk-VXAGOLDP.js} +1 -1
- package/dist/{chunk-SS4B7P7V.js → chunk-YIDV4VV2.js} +1 -1
- package/dist/chunk-YTRZNA64.js +37 -0
- package/dist/chunk-ZKWPCBYT.js +600 -0
- package/dist/cli/index.js +28 -21
- package/dist/commands/archive.js +3 -3
- package/dist/commands/backlog.js +1 -1
- package/dist/commands/benchmark.d.ts +12 -0
- package/dist/commands/benchmark.js +12 -0
- package/dist/commands/blocked.js +1 -1
- package/dist/commands/canvas.js +2 -2
- package/dist/commands/checkpoint.js +1 -1
- package/dist/commands/compat.js +1 -1
- package/dist/commands/context.js +8 -7
- package/dist/commands/doctor.d.ts +8 -3
- package/dist/commands/doctor.js +8 -22
- package/dist/commands/embed.js +6 -5
- package/dist/commands/entities.d.ts +8 -1
- package/dist/commands/entities.js +46 -3
- package/dist/commands/graph.js +4 -4
- 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 +5 -5
- package/dist/commands/kanban.js +1 -1
- package/dist/commands/link.js +5 -5
- package/dist/commands/maintain.d.ts +32 -0
- package/dist/commands/maintain.js +13 -0
- package/dist/commands/migrate-observations.js +3 -3
- package/dist/commands/observe.js +11 -10
- package/dist/commands/project.js +2 -2
- package/dist/commands/rebuild-embeddings.js +48 -17
- package/dist/commands/rebuild.js +9 -8
- package/dist/commands/recall.d.ts +14 -0
- package/dist/commands/recall.js +15 -0
- package/dist/commands/recover.js +1 -1
- package/dist/commands/reflect.js +6 -6
- package/dist/commands/repair-session.js +1 -1
- package/dist/commands/replay.js +10 -9
- package/dist/commands/session-recap.js +1 -1
- package/dist/commands/setup.js +4 -3
- package/dist/commands/shell-init.js +1 -1
- package/dist/commands/sleep.d.ts +1 -1
- package/dist/commands/sleep.js +20 -18
- package/dist/commands/status.js +40 -26
- package/dist/commands/sync-bd.js +3 -3
- package/dist/commands/tailscale.js +3 -3
- package/dist/commands/task.js +1 -1
- package/dist/commands/template.js +1 -1
- package/dist/commands/wake.d.ts +1 -1
- package/dist/commands/wake.js +10 -9
- package/dist/index.d.ts +233 -16
- package/dist/index.js +325 -111
- package/dist/{inject-DYUrDqQO.d.ts → inject-DEb_jpLi.d.ts} +3 -1
- package/dist/lib/auto-linker.js +2 -2
- package/dist/lib/canvas-layout.js +1 -1
- package/dist/lib/config.js +2 -2
- package/dist/lib/entity-index.js +1 -1
- package/dist/lib/project-utils.js +2 -2
- package/dist/lib/session-repair.js +1 -1
- package/dist/lib/session-utils.js +1 -1
- package/dist/lib/tailscale.js +1 -1
- package/dist/lib/task-utils.js +1 -1
- package/dist/lib/template-engine.js +1 -1
- package/dist/lib/webdav.js +1 -1
- package/dist/onnxruntime_binding-5QEF3SUC.node +0 -0
- package/dist/onnxruntime_binding-BKPKNEGC.node +0 -0
- package/dist/onnxruntime_binding-FMOXGIUT.node +0 -0
- package/dist/onnxruntime_binding-OI2KMXC5.node +0 -0
- package/dist/onnxruntime_binding-UX44MLAZ.node +0 -0
- package/dist/onnxruntime_binding-Y2W7N7WY.node +0 -0
- package/dist/openclaw-plugin--gqA2BZw.d.ts +267 -0
- package/dist/openclaw-plugin.d.ts +4 -0
- package/dist/openclaw-plugin.js +20 -0
- package/dist/transformers.node-A2ZRORSQ.js +46775 -0
- package/dist/types-CbL-wIKi.d.ts +36 -0
- package/dist/{types-BbWJoC1c.d.ts → types-DslKvCaj.d.ts} +51 -1
- package/hooks/clawvault/HOOK.md +25 -8
- package/hooks/clawvault/handler.js +215 -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 +161 -194
- package/package.json +8 -5
- package/bin/register-workgraph-commands.js +0 -451
- package/dist/chunk-5PJ4STIC.js +0 -465
- package/dist/chunk-ERNE2FZ5.js +0 -189
- package/dist/chunk-HR4KN6S2.js +0 -152
- package/dist/chunk-IJBFGPCS.js +0 -33
- package/dist/chunk-K7PNYS45.js +0 -93
- package/dist/chunk-NTOPJI7W.js +0 -207
- package/dist/chunk-PG56HX5T.js +0 -154
- package/dist/chunk-QPDDIHXE.js +0 -501
- package/dist/chunk-WIOLLGAD.js +0 -190
- package/dist/chunk-WMGIIABP.js +0 -15
- package/dist/ledger-B7g7jhqG.d.ts +0 -44
- package/dist/plugin/index.d.ts +0 -352
- package/dist/plugin/index.js +0 -4264
- 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,223 @@
|
|
|
1
|
+
// src/recall/strategies.ts
|
|
2
|
+
var VERIFICATION_PATTERN = /\b(verify|verification|source|citation|cite|proof|prove|where did|evidence)\b/i;
|
|
3
|
+
var TEMPORAL_PATTERN = /\b(today|yesterday|last\s+(?:day|week|month|year)|this\s+(?:week|month|year)|recent|recently|timeline|when)\b/i;
|
|
4
|
+
var RELATIONSHIP_PATTERN = /\b(relationship|relates?|connected|between|depends on|works with|reports to|interacts? with)\b/i;
|
|
5
|
+
function parseTemporalWindowDays(query) {
|
|
6
|
+
if (/\byesterday\b/i.test(query)) return 2;
|
|
7
|
+
if (/\btoday\b/i.test(query)) return 1;
|
|
8
|
+
if (/\blast\s+day\b/i.test(query)) return 1;
|
|
9
|
+
if (/\blast\s+week\b/i.test(query)) return 7;
|
|
10
|
+
if (/\bthis\s+week\b/i.test(query)) return 7;
|
|
11
|
+
if (/\blast\s+month\b/i.test(query)) return 31;
|
|
12
|
+
if (/\bthis\s+month\b/i.test(query)) return 31;
|
|
13
|
+
if (/\blast\s+year\b/i.test(query) || /\bthis\s+year\b/i.test(query)) return 366;
|
|
14
|
+
return void 0;
|
|
15
|
+
}
|
|
16
|
+
function inferEntityName(query, knownEntityNames) {
|
|
17
|
+
const wikiLink = query.match(/\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/);
|
|
18
|
+
if (wikiLink?.[1]) {
|
|
19
|
+
return wikiLink[1].trim();
|
|
20
|
+
}
|
|
21
|
+
const normalizedQuery = query.toLowerCase();
|
|
22
|
+
for (const entity of knownEntityNames) {
|
|
23
|
+
if (!entity.trim()) continue;
|
|
24
|
+
if (normalizedQuery.includes(entity.toLowerCase())) {
|
|
25
|
+
return entity;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const capSequence = query.match(/\b([A-Z][a-z]+(?:\s+[A-Z][a-z]+){0,2})\b/);
|
|
29
|
+
if (capSequence?.[1]) {
|
|
30
|
+
return capSequence[1].trim();
|
|
31
|
+
}
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
function classifyRecallQuery(query, knownEntityNames = [], forcedStrategy) {
|
|
35
|
+
if (forcedStrategy) {
|
|
36
|
+
return {
|
|
37
|
+
strategy: forcedStrategy,
|
|
38
|
+
entityName: forcedStrategy === "entity" ? inferEntityName(query, knownEntityNames) : void 0,
|
|
39
|
+
temporalDays: forcedStrategy === "temporal" ? parseTemporalWindowDays(query) : void 0
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const entityName = inferEntityName(query, knownEntityNames);
|
|
43
|
+
if (RELATIONSHIP_PATTERN.test(query)) {
|
|
44
|
+
return { strategy: "relationship", entityName };
|
|
45
|
+
}
|
|
46
|
+
if (VERIFICATION_PATTERN.test(query)) {
|
|
47
|
+
return { strategy: "verification", entityName };
|
|
48
|
+
}
|
|
49
|
+
if (TEMPORAL_PATTERN.test(query)) {
|
|
50
|
+
return {
|
|
51
|
+
strategy: "temporal",
|
|
52
|
+
entityName,
|
|
53
|
+
temporalDays: parseTemporalWindowDays(query)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (entityName) {
|
|
57
|
+
return { strategy: "entity", entityName };
|
|
58
|
+
}
|
|
59
|
+
return { strategy: "quick" };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/recall/service.ts
|
|
63
|
+
import * as fs from "fs";
|
|
64
|
+
import * as path from "path";
|
|
65
|
+
import matter from "gray-matter";
|
|
66
|
+
var DEFAULT_LIMIT = 6;
|
|
67
|
+
var DEFAULT_MAX_SNIPPET = 220;
|
|
68
|
+
function compactSnippet(value, maxChars = DEFAULT_MAX_SNIPPET) {
|
|
69
|
+
const normalized = value.replace(/\s+/g, " ").trim();
|
|
70
|
+
if (!normalized) return "No snippet available.";
|
|
71
|
+
return normalized.slice(0, maxChars);
|
|
72
|
+
}
|
|
73
|
+
function toIso(value) {
|
|
74
|
+
return value.toISOString();
|
|
75
|
+
}
|
|
76
|
+
function parseFrontmatterDate(raw) {
|
|
77
|
+
if (typeof raw !== "string" && !(raw instanceof Date)) return null;
|
|
78
|
+
const date = raw instanceof Date ? raw : new Date(raw);
|
|
79
|
+
if (Number.isNaN(date.getTime())) return null;
|
|
80
|
+
return date;
|
|
81
|
+
}
|
|
82
|
+
function formatContextHeader(strategy, query) {
|
|
83
|
+
return [
|
|
84
|
+
"[ClawVault memory recall]",
|
|
85
|
+
`strategy: ${strategy}`,
|
|
86
|
+
`query: ${query}`
|
|
87
|
+
].join(" | ");
|
|
88
|
+
}
|
|
89
|
+
function isRelationshipResult(result) {
|
|
90
|
+
const memoryType = typeof result.document.frontmatter.memoryType === "string" ? result.document.frontmatter.memoryType.toLowerCase() : "";
|
|
91
|
+
if (memoryType === "relationship") {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
const content = `${result.document.title}
|
|
95
|
+
${result.document.content}`;
|
|
96
|
+
return /\b(works with|reports to|related to|depends on|collaborates with|partnered with|between)\b/i.test(content) || (result.document.links?.length ?? 0) >= 2;
|
|
97
|
+
}
|
|
98
|
+
function filterTemporalResults(results, days) {
|
|
99
|
+
if (!days || !Number.isFinite(days) || days <= 0) {
|
|
100
|
+
return results;
|
|
101
|
+
}
|
|
102
|
+
const windowMs = days * 24 * 60 * 60 * 1e3;
|
|
103
|
+
const cutoff = Date.now() - windowMs;
|
|
104
|
+
return results.filter((result) => {
|
|
105
|
+
const fmDate = parseFrontmatterDate(result.document.frontmatter.date);
|
|
106
|
+
const reference = fmDate ?? result.document.modified;
|
|
107
|
+
return reference.getTime() >= cutoff;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function entityProfilePath(vaultPath, entityName) {
|
|
111
|
+
const slug = entityName.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").trim();
|
|
112
|
+
return path.join(vaultPath, "entities", `${slug}.md`);
|
|
113
|
+
}
|
|
114
|
+
function readEntityBrief(vaultPath, entityName) {
|
|
115
|
+
const filePath = entityProfilePath(vaultPath, entityName);
|
|
116
|
+
if (!fs.existsSync(filePath)) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const parsed = matter(fs.readFileSync(filePath, "utf-8"));
|
|
120
|
+
const kind = typeof parsed.data.kind === "string" ? parsed.data.kind : "unknown";
|
|
121
|
+
const summary = parsed.content.split(/\r?\n/).map((line) => line.trim()).find((line) => line && !line.startsWith("#") && !line.startsWith("-")) ?? "";
|
|
122
|
+
const relationships = Array.isArray(parsed.data.relationships) ? parsed.data.relationships.slice(0, 4).map((entry) => {
|
|
123
|
+
if (typeof entry === "string") return entry;
|
|
124
|
+
if (!entry || typeof entry !== "object") return "";
|
|
125
|
+
const record = entry;
|
|
126
|
+
return typeof record.target === "string" ? record.target : "";
|
|
127
|
+
}).filter(Boolean) : [];
|
|
128
|
+
const relationshipChunk = relationships.length > 0 ? ` Relationships: ${relationships.join(", ")}.` : "";
|
|
129
|
+
return `Entity brief: ${entityName} (${kind}). ${summary}${relationshipChunk}`.trim();
|
|
130
|
+
}
|
|
131
|
+
function toRecallSource(result) {
|
|
132
|
+
return {
|
|
133
|
+
title: result.document.title,
|
|
134
|
+
path: result.document.id,
|
|
135
|
+
category: result.document.category,
|
|
136
|
+
score: Number(result.score.toFixed(4)),
|
|
137
|
+
snippet: compactSnippet(result.snippet || result.document.content),
|
|
138
|
+
modified: toIso(result.document.modified)
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function uniqueEntityNames(results) {
|
|
142
|
+
const names = /* @__PURE__ */ new Set();
|
|
143
|
+
for (const result of results) {
|
|
144
|
+
if (result.document.category === "people" || result.document.category === "projects" || result.document.category === "entities") {
|
|
145
|
+
names.add(result.document.title);
|
|
146
|
+
}
|
|
147
|
+
for (const link of result.document.links) {
|
|
148
|
+
if (link.trim()) names.add(link.trim());
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return [...names];
|
|
152
|
+
}
|
|
153
|
+
function formatRecallContext(result, includeSources) {
|
|
154
|
+
const lines = [formatContextHeader(result.strategy, result.query), ""];
|
|
155
|
+
if (result.sources.length === 0) {
|
|
156
|
+
lines.push("No relevant memories found.");
|
|
157
|
+
return lines.join("\n");
|
|
158
|
+
}
|
|
159
|
+
if (result.strategy === "verification") {
|
|
160
|
+
lines.push("Verification-oriented evidence:");
|
|
161
|
+
} else if (result.strategy === "relationship") {
|
|
162
|
+
lines.push("Relationship-focused recall:");
|
|
163
|
+
} else if (result.strategy === "temporal") {
|
|
164
|
+
lines.push("Time-filtered recall:");
|
|
165
|
+
} else if (result.strategy === "entity" && result.entityName) {
|
|
166
|
+
lines.push(`Entity-focused recall for "${result.entityName}":`);
|
|
167
|
+
} else {
|
|
168
|
+
lines.push("Relevant recall:");
|
|
169
|
+
}
|
|
170
|
+
lines.push("");
|
|
171
|
+
for (const source of result.sources) {
|
|
172
|
+
const sourceTail = includeSources || result.strategy === "verification" ? ` [${source.path}]` : "";
|
|
173
|
+
lines.push(`- (${source.score.toFixed(2)}) ${source.title}${sourceTail}`);
|
|
174
|
+
lines.push(` ${source.snippet}`);
|
|
175
|
+
}
|
|
176
|
+
return lines.join("\n").trim();
|
|
177
|
+
}
|
|
178
|
+
async function buildRecallResult(vault, query, options = {}) {
|
|
179
|
+
const limit = options.limit ?? DEFAULT_LIMIT;
|
|
180
|
+
const broadLimit = Math.max(limit * 4, limit);
|
|
181
|
+
const seededResults = await vault.find(query, {
|
|
182
|
+
limit: broadLimit,
|
|
183
|
+
temporalBoost: true,
|
|
184
|
+
...options.searchOptions ?? {}
|
|
185
|
+
});
|
|
186
|
+
const knownEntityNames = uniqueEntityNames(seededResults);
|
|
187
|
+
const classification = classifyRecallQuery(query, knownEntityNames, options.strategy);
|
|
188
|
+
let scopedResults = seededResults;
|
|
189
|
+
if (classification.strategy === "entity" && classification.entityName) {
|
|
190
|
+
scopedResults = await vault.find(`"${classification.entityName}" ${query}`, {
|
|
191
|
+
limit: broadLimit,
|
|
192
|
+
temporalBoost: true,
|
|
193
|
+
...options.searchOptions ?? {}
|
|
194
|
+
});
|
|
195
|
+
} else if (classification.strategy === "temporal") {
|
|
196
|
+
scopedResults = filterTemporalResults(scopedResults, classification.temporalDays);
|
|
197
|
+
} else if (classification.strategy === "relationship") {
|
|
198
|
+
scopedResults = scopedResults.filter((result) => isRelationshipResult(result));
|
|
199
|
+
} else if (classification.strategy === "verification") {
|
|
200
|
+
scopedResults = [...scopedResults].sort((left, right) => right.score - left.score);
|
|
201
|
+
}
|
|
202
|
+
const selected = scopedResults.slice(0, limit);
|
|
203
|
+
const sources = selected.map(toRecallSource);
|
|
204
|
+
const entityBrief = classification.entityName ? readEntityBrief(vault.getPath(), classification.entityName) : null;
|
|
205
|
+
const provisionalResult = {
|
|
206
|
+
query,
|
|
207
|
+
strategy: classification.strategy,
|
|
208
|
+
entityName: classification.entityName,
|
|
209
|
+
context: "",
|
|
210
|
+
sources,
|
|
211
|
+
rawResults: selected
|
|
212
|
+
};
|
|
213
|
+
const baseContext = formatRecallContext(provisionalResult, options.includeSources ?? false);
|
|
214
|
+
provisionalResult.context = entityBrief ? `${baseContext}
|
|
215
|
+
|
|
216
|
+
${entityBrief}` : baseContext;
|
|
217
|
+
return provisionalResult;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export {
|
|
221
|
+
classifyRecallQuery,
|
|
222
|
+
buildRecallResult
|
|
223
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveVaultPath
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GJO3CFUN.js";
|
|
4
4
|
import {
|
|
5
5
|
buildOrUpdateMemoryGraphIndex,
|
|
6
6
|
loadMemoryGraphIndex
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-33DOSHTA.js";
|
|
8
8
|
|
|
9
9
|
// src/commands/graph.ts
|
|
10
10
|
function formatGraphSummary(summary) {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
loadVaultQmdConfig
|
|
3
|
-
|
|
2
|
+
loadVaultQmdConfig,
|
|
3
|
+
recoverQmdEmbeddingIfNeeded,
|
|
4
|
+
runCrashSafeQmdEmbed
|
|
5
|
+
} from "./chunk-FZ5I2NF7.js";
|
|
4
6
|
import {
|
|
5
7
|
QmdUnavailableError,
|
|
6
|
-
hasQmd
|
|
7
|
-
|
|
8
|
-
} from "./chunk-5PJ4STIC.js";
|
|
8
|
+
hasQmd
|
|
9
|
+
} from "./chunk-PTWPPVC7.js";
|
|
9
10
|
import {
|
|
10
11
|
resolveVaultPath
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GJO3CFUN.js";
|
|
12
13
|
|
|
13
14
|
// src/commands/embed.ts
|
|
14
15
|
async function embedCommand(options = {}) {
|
|
@@ -18,12 +19,27 @@ async function embedCommand(options = {}) {
|
|
|
18
19
|
const vaultPath = resolveVaultPath({ explicitPath: options.vaultPath });
|
|
19
20
|
const qmdConfig = loadVaultQmdConfig(vaultPath);
|
|
20
21
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
22
|
+
const recovery = recoverQmdEmbeddingIfNeeded({
|
|
23
|
+
vaultPath,
|
|
24
|
+
collection: qmdConfig.qmdCollection,
|
|
25
|
+
rootPath: qmdConfig.qmdRoot,
|
|
26
|
+
mode: "marker-or-empty",
|
|
27
|
+
onLog: options.quiet ? void 0 : (message) => console.log(message)
|
|
28
|
+
});
|
|
29
|
+
if (!options.quiet && recovery.recovered) {
|
|
30
|
+
const reasonLabel = recovery.reason === "interrupted_wal" ? "interrupted run" : "empty vector state";
|
|
31
|
+
console.log(`\u2713 Automatic qmd recovery completed (${reasonLabel}).`);
|
|
32
|
+
}
|
|
21
33
|
if (!options.quiet) {
|
|
22
34
|
console.log(
|
|
23
35
|
`Embedding pending documents for collection "${qmdConfig.qmdCollection}" (root: ${qmdConfig.qmdRoot})...`
|
|
24
36
|
);
|
|
25
37
|
}
|
|
26
|
-
|
|
38
|
+
runCrashSafeQmdEmbed({
|
|
39
|
+
vaultPath,
|
|
40
|
+
collection: qmdConfig.qmdCollection,
|
|
41
|
+
rootPath: qmdConfig.qmdRoot
|
|
42
|
+
});
|
|
27
43
|
const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
28
44
|
if (!options.quiet) {
|
|
29
45
|
console.log(`\u2713 Embedding complete for "${qmdConfig.qmdCollection}"`);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
normalizeObservationContent,
|
|
3
|
-
parseObservationMarkdown
|
|
4
|
-
} from "./chunk-FHFUXL6G.js";
|
|
5
1
|
import {
|
|
6
2
|
requestLlmCompletion,
|
|
7
3
|
resolveLlmProvider
|
|
8
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DVOUSOR3.js";
|
|
9
5
|
import {
|
|
10
6
|
archiveObservations
|
|
11
7
|
} from "./chunk-MQUJNOHK.js";
|
|
8
|
+
import {
|
|
9
|
+
normalizeObservationContent,
|
|
10
|
+
parseObservationMarkdown
|
|
11
|
+
} from "./chunk-FHFUXL6G.js";
|
|
12
12
|
import {
|
|
13
13
|
formatIsoWeekKey,
|
|
14
14
|
getIsoWeek,
|
|
@@ -235,6 +235,7 @@ async function maybeGenerateLlmReflection(weekKey, sections) {
|
|
|
235
235
|
const output = await requestLlmCompletion({
|
|
236
236
|
provider,
|
|
237
237
|
prompt,
|
|
238
|
+
tier: "default",
|
|
238
239
|
temperature: 0.1,
|
|
239
240
|
maxTokens: 1200
|
|
240
241
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildRecallResult
|
|
3
|
+
} from "./chunk-RL2L6I6K.js";
|
|
4
|
+
import {
|
|
5
|
+
ClawVault
|
|
6
|
+
} from "./chunk-ECGJYWNA.js";
|
|
7
|
+
import {
|
|
8
|
+
resolveVaultPath
|
|
9
|
+
} from "./chunk-GJO3CFUN.js";
|
|
10
|
+
|
|
11
|
+
// src/commands/recall.ts
|
|
12
|
+
async function recallCommand(query, options) {
|
|
13
|
+
const vaultPath = resolveVaultPath({ explicitPath: options.vaultPath });
|
|
14
|
+
const vault = new ClawVault(vaultPath);
|
|
15
|
+
await vault.load();
|
|
16
|
+
const recallOptions = {
|
|
17
|
+
limit: options.limit,
|
|
18
|
+
strategy: options.strategy,
|
|
19
|
+
includeSources: options.includeSources
|
|
20
|
+
};
|
|
21
|
+
const result = await buildRecallResult(vault, query, recallOptions);
|
|
22
|
+
if (options.json) {
|
|
23
|
+
console.log(JSON.stringify({
|
|
24
|
+
strategy: result.strategy,
|
|
25
|
+
query: result.query,
|
|
26
|
+
sources: result.sources,
|
|
27
|
+
context: result.context
|
|
28
|
+
}, null, 2));
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
console.log(result.context);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
recallCommand
|
|
37
|
+
};
|