clawvault 2.6.3 → 2.6.5
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 +351 -21
- package/bin/clawvault.js +8 -2
- package/bin/command-runtime.js +9 -1
- package/bin/register-maintenance-commands.js +19 -0
- package/bin/register-query-commands.js +58 -6
- package/bin/register-workgraph-commands.js +451 -0
- package/dist/chunk-2GKPENIR.js +66 -0
- package/dist/{chunk-VXEOHTSL.js → chunk-2JQ3O2YL.js} +1 -1
- package/dist/{chunk-VR5NE7PZ.js → chunk-2RAZ4ZFE.js} +1 -1
- package/dist/chunk-2ZDO52B4.js +52 -0
- package/dist/{chunk-ZZA73MFY.js → chunk-33DOSHTA.js} +176 -36
- package/dist/chunk-4BQTQMJP.js +93 -0
- package/dist/{chunk-MAKNAHAW.js → chunk-5PJ4STIC.js} +98 -8
- package/dist/{chunk-RVYA52PY.js → chunk-5UM4PMMM.js} +1 -1
- package/dist/{chunk-4VQTUVH7.js → chunk-7YZWHM36.js} +52 -26
- package/dist/{chunk-4VRIMU4O.js → chunk-A4EAUO7T.js} +5 -5
- package/dist/{chunk-R6SXNSFD.js → chunk-BV5KWZKR.js} +3 -3
- package/dist/chunk-FBITHIZF.js +351 -0
- package/dist/{chunk-Q2J5YTUF.js → chunk-FUSLEY6L.js} +751 -34
- package/dist/chunk-GNJL4YGR.js +79 -0
- package/dist/{chunk-42MXU7A6.js → chunk-K4GFGKFD.js} +51 -47
- package/dist/{chunk-PBEE567J.js → chunk-KSZROBFH.js} +2 -2
- package/dist/chunk-L4HSSQ6T.js +152 -0
- package/dist/{chunk-PZ2AUU2W.js → chunk-LMKQ7NIF.js} +206 -37
- package/dist/{chunk-6546Q4OR.js → chunk-M5O6FQ66.js} +6 -6
- package/dist/chunk-MM6QGW3P.js +207 -0
- package/dist/{chunk-T76H47ZS.js → chunk-MNPUYCHQ.js} +1 -1
- package/dist/{chunk-P5EPF6MB.js → chunk-MW5C6ZQA.js} +110 -13
- package/dist/{chunk-OZ7RIXTO.js → chunk-QSRRMEYM.js} +2 -2
- package/dist/chunk-RHISK3SZ.js +189 -0
- package/dist/{chunk-3BTHWPMB.js → chunk-S5OJEGFG.js} +2 -2
- package/dist/{chunk-MGDEINGP.js → chunk-SS4B7P7V.js} +1 -1
- package/dist/{chunk-ME37YNW3.js → chunk-SV7T4HRE.js} +4 -4
- package/dist/{chunk-IEVLHNLU.js → chunk-T3FKSZSN.js} +3 -3
- package/dist/{chunk-DTEHFAL7.js → chunk-TS6NDVOU.js} +2 -2
- package/dist/chunk-U4O6C46S.js +154 -0
- package/dist/{chunk-ITPEXLHA.js → chunk-URXDAUVH.js} +24 -5
- package/dist/chunk-WMGIIABP.js +15 -0
- package/dist/{chunk-QVMXF7FY.js → chunk-X3SPPUFG.js} +50 -0
- package/dist/{chunk-THRJVD4L.js → chunk-Y6VJKXGL.js} +1 -1
- package/dist/{chunk-RCBMXTWS.js → chunk-YD7SVXTF.js} +39 -7
- package/dist/{chunk-HIHOUSXS.js → chunk-YXQCA6B7.js} +105 -1
- package/dist/cli/index.js +20 -18
- package/dist/commands/archive.js +3 -2
- package/dist/commands/backlog.js +1 -0
- package/dist/commands/blocked.js +1 -0
- package/dist/commands/canvas.js +2 -1
- package/dist/commands/checkpoint.js +1 -0
- package/dist/commands/compat.js +2 -1
- package/dist/commands/context.js +6 -4
- package/dist/commands/doctor.d.ts +10 -1
- package/dist/commands/doctor.js +13 -10
- package/dist/commands/embed.js +5 -3
- package/dist/commands/entities.js +2 -1
- package/dist/commands/graph.js +4 -3
- package/dist/commands/inject.d.ts +1 -1
- package/dist/commands/inject.js +5 -4
- package/dist/commands/kanban.js +1 -0
- package/dist/commands/link.js +5 -4
- package/dist/commands/migrate-observations.js +3 -2
- package/dist/commands/observe.js +9 -7
- package/dist/commands/project.js +1 -0
- package/dist/commands/rebuild-embeddings.d.ts +21 -0
- package/dist/commands/rebuild-embeddings.js +91 -0
- package/dist/commands/rebuild.js +6 -4
- package/dist/commands/recover.js +1 -0
- package/dist/commands/reflect.js +5 -4
- package/dist/commands/repair-session.js +1 -0
- package/dist/commands/replay.js +7 -6
- package/dist/commands/session-recap.js +1 -0
- package/dist/commands/setup.js +3 -2
- package/dist/commands/shell-init.js +2 -0
- package/dist/commands/sleep.d.ts +1 -1
- package/dist/commands/sleep.js +10 -8
- package/dist/commands/status.js +13 -82
- package/dist/commands/sync-bd.js +3 -2
- package/dist/commands/tailscale.js +3 -2
- package/dist/commands/task.js +1 -0
- package/dist/commands/template.js +1 -0
- package/dist/commands/wake.d.ts +1 -1
- package/dist/commands/wake.js +5 -3
- package/dist/index.d.ts +254 -10
- package/dist/index.js +288 -155
- package/dist/{inject-x65KXWPk.d.ts → inject-DYUrDqQO.d.ts} +2 -2
- package/dist/ledger-B7g7jhqG.d.ts +44 -0
- package/dist/lib/auto-linker.js +2 -1
- package/dist/lib/canvas-layout.js +1 -0
- package/dist/lib/config.d.ts +27 -3
- package/dist/lib/config.js +4 -1
- package/dist/lib/entity-index.js +1 -0
- package/dist/lib/project-utils.js +1 -0
- package/dist/lib/session-repair.js +1 -0
- package/dist/lib/session-utils.js +1 -0
- package/dist/lib/tailscale.js +1 -0
- package/dist/lib/task-utils.js +1 -0
- package/dist/lib/template-engine.js +1 -0
- package/dist/lib/webdav.js +1 -0
- 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/registry-BR4326o0.d.ts +30 -0
- package/dist/store-CA-6sKCJ.d.ts +34 -0
- package/dist/thread-B9LhXNU0.d.ts +41 -0
- package/dist/transformers.node-A2ZRORSQ.js +46775 -0
- package/dist/{types-C74wgGL1.d.ts → types-BbWJoC1c.d.ts} +1 -1
- package/dist/workgraph/index.d.ts +5 -0
- package/dist/workgraph/index.js +23 -0
- package/dist/workgraph/ledger.d.ts +2 -0
- package/dist/workgraph/ledger.js +25 -0
- package/dist/workgraph/registry.d.ts +2 -0
- package/dist/workgraph/registry.js +19 -0
- package/dist/workgraph/store.d.ts +2 -0
- package/dist/workgraph/store.js +25 -0
- package/dist/workgraph/thread.d.ts +2 -0
- package/dist/workgraph/thread.js +25 -0
- package/dist/workgraph/types.d.ts +54 -0
- package/dist/workgraph/types.js +7 -0
- package/hooks/clawvault/handler.js +714 -2
- package/hooks/clawvault/handler.test.js +153 -0
- package/hooks/clawvault/openclaw.plugin.json +72 -0
- package/openclaw.plugin.json +14 -2
- package/package.json +5 -4
- package/dist/chunk-4QYGFWRM.js +0 -88
- package/dist/chunk-MXSSG3QU.js +0 -42
package/dist/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
registerReplayCommand,
|
|
3
|
+
replayCommand
|
|
4
|
+
} from "./chunk-BV5KWZKR.js";
|
|
1
5
|
import {
|
|
2
6
|
buildSessionRecap,
|
|
3
7
|
formatSessionRecapMarkdown,
|
|
@@ -5,32 +9,37 @@ import {
|
|
|
5
9
|
} from "./chunk-ZKGY7WTT.js";
|
|
6
10
|
import {
|
|
7
11
|
setupCommand
|
|
8
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-5UM4PMMM.js";
|
|
9
13
|
import {
|
|
10
14
|
registerSyncBdCommand,
|
|
11
15
|
syncBdCommand
|
|
12
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-SS4B7P7V.js";
|
|
13
17
|
import {
|
|
14
18
|
migrateObservations,
|
|
15
19
|
migrateObservationsCommand,
|
|
16
20
|
registerMigrateObservationsCommand
|
|
17
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-2JQ3O2YL.js";
|
|
22
|
+
import {
|
|
23
|
+
EmbeddingCache,
|
|
24
|
+
cosineSimilarity,
|
|
25
|
+
embed,
|
|
26
|
+
embedBatch,
|
|
27
|
+
hybridSearch,
|
|
28
|
+
reciprocalRankFusion,
|
|
29
|
+
semanticSearch
|
|
30
|
+
} from "./chunk-U4O6C46S.js";
|
|
18
31
|
import {
|
|
19
32
|
rebuildCommand,
|
|
20
33
|
registerRebuildCommand
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import {
|
|
23
|
-
registerReplayCommand,
|
|
24
|
-
replayCommand
|
|
25
|
-
} from "./chunk-R6SXNSFD.js";
|
|
34
|
+
} from "./chunk-KSZROBFH.js";
|
|
26
35
|
import {
|
|
27
36
|
doctor
|
|
28
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-LMKQ7NIF.js";
|
|
29
38
|
import "./chunk-7ZRP733D.js";
|
|
30
39
|
import {
|
|
31
40
|
graphCommand,
|
|
32
41
|
graphSummary
|
|
33
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-QSRRMEYM.js";
|
|
34
43
|
import {
|
|
35
44
|
buildKanbanLanes,
|
|
36
45
|
extractCardSlug,
|
|
@@ -41,11 +50,11 @@ import {
|
|
|
41
50
|
parseKanbanMarkdown,
|
|
42
51
|
syncKanbanBoard
|
|
43
52
|
} from "./chunk-4OXMU5S2.js";
|
|
44
|
-
import "./chunk-
|
|
53
|
+
import "./chunk-7YZWHM36.js";
|
|
45
54
|
import "./chunk-J7ZWCI2C.js";
|
|
46
55
|
import {
|
|
47
56
|
registerCliCommands
|
|
48
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-M5O6FQ66.js";
|
|
49
58
|
import {
|
|
50
59
|
registerTailscaleCommands,
|
|
51
60
|
registerTailscaleDiscoverCommand,
|
|
@@ -56,7 +65,7 @@ import {
|
|
|
56
65
|
tailscaleServeCommand,
|
|
57
66
|
tailscaleStatusCommand,
|
|
58
67
|
tailscaleSyncCommand
|
|
59
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-Y6VJKXGL.js";
|
|
60
69
|
import {
|
|
61
70
|
CLAWVAULT_SERVE_PATH,
|
|
62
71
|
DEFAULT_SERVE_PORT,
|
|
@@ -83,17 +92,17 @@ import {
|
|
|
83
92
|
SessionWatcher,
|
|
84
93
|
observeCommand,
|
|
85
94
|
registerObserveCommand
|
|
86
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-SV7T4HRE.js";
|
|
87
96
|
import {
|
|
88
97
|
parseSessionFile
|
|
89
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-MW5C6ZQA.js";
|
|
90
99
|
import {
|
|
91
100
|
reflectCommand,
|
|
92
101
|
registerReflectCommand
|
|
93
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-S5OJEGFG.js";
|
|
94
103
|
import {
|
|
95
104
|
runReflection
|
|
96
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-MNPUYCHQ.js";
|
|
97
106
|
import {
|
|
98
107
|
buildContext,
|
|
99
108
|
contextCommand,
|
|
@@ -102,19 +111,28 @@ import {
|
|
|
102
111
|
normalizeContextProfileInput,
|
|
103
112
|
registerContextCommand,
|
|
104
113
|
resolveContextProfile
|
|
105
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-TS6NDVOU.js";
|
|
106
115
|
import {
|
|
107
116
|
getObserverStaleness,
|
|
108
117
|
getScaledObservationThresholdBytes,
|
|
109
118
|
observeActiveSessions,
|
|
110
119
|
parseSessionSourceLabel
|
|
111
|
-
} from "./chunk-
|
|
112
|
-
import "./chunk-HRLWZGMA.js";
|
|
120
|
+
} from "./chunk-T3FKSZSN.js";
|
|
113
121
|
import {
|
|
114
122
|
Compressor,
|
|
123
|
+
FactStore,
|
|
115
124
|
Observer,
|
|
116
|
-
Reflector
|
|
117
|
-
|
|
125
|
+
Reflector,
|
|
126
|
+
createDefaultAdapter,
|
|
127
|
+
createFactExtractionAdapter,
|
|
128
|
+
createGeminiFlashAdapter,
|
|
129
|
+
createLlmFunction,
|
|
130
|
+
extractFactsLlm,
|
|
131
|
+
extractFactsRuleBased,
|
|
132
|
+
factId,
|
|
133
|
+
normalizeEntity,
|
|
134
|
+
resolveFactExtractionMode
|
|
135
|
+
} from "./chunk-FUSLEY6L.js";
|
|
118
136
|
import {
|
|
119
137
|
archiveProject,
|
|
120
138
|
createProject,
|
|
@@ -124,27 +142,34 @@ import {
|
|
|
124
142
|
readProject,
|
|
125
143
|
updateProject
|
|
126
144
|
} from "./chunk-AZYOKJYC.js";
|
|
145
|
+
import "./chunk-HRLWZGMA.js";
|
|
127
146
|
import {
|
|
128
147
|
ClawVault,
|
|
129
148
|
createVault,
|
|
130
149
|
findVault
|
|
131
|
-
} from "./chunk-
|
|
150
|
+
} from "./chunk-YD7SVXTF.js";
|
|
132
151
|
import "./chunk-FHFUXL6G.js";
|
|
133
152
|
import {
|
|
134
153
|
embedCommand,
|
|
135
154
|
registerEmbedCommand
|
|
136
|
-
} from "./chunk-
|
|
155
|
+
} from "./chunk-2GKPENIR.js";
|
|
156
|
+
import {
|
|
157
|
+
loadVaultQmdConfig,
|
|
158
|
+
removeQmdCollection
|
|
159
|
+
} from "./chunk-FBITHIZF.js";
|
|
137
160
|
import {
|
|
138
161
|
QMD_INSTALL_COMMAND,
|
|
139
162
|
QMD_INSTALL_URL,
|
|
163
|
+
QmdConfigurationError,
|
|
140
164
|
QmdUnavailableError,
|
|
141
165
|
SearchEngine,
|
|
142
166
|
extractTags,
|
|
143
167
|
extractWikiLinks,
|
|
168
|
+
getQmdErrorDetails,
|
|
144
169
|
hasQmd,
|
|
145
170
|
qmdEmbed,
|
|
146
171
|
qmdUpdate
|
|
147
|
-
} from "./chunk-
|
|
172
|
+
} from "./chunk-5PJ4STIC.js";
|
|
148
173
|
import {
|
|
149
174
|
buildInjectionResult,
|
|
150
175
|
deterministicInjectMatches,
|
|
@@ -152,11 +177,7 @@ import {
|
|
|
152
177
|
injectCommand,
|
|
153
178
|
registerInjectCommand,
|
|
154
179
|
runPromptInjection
|
|
155
|
-
} from "./chunk-
|
|
156
|
-
import {
|
|
157
|
-
requestLlmCompletion,
|
|
158
|
-
resolveLlmProvider
|
|
159
|
-
} from "./chunk-HIHOUSXS.js";
|
|
180
|
+
} from "./chunk-A4EAUO7T.js";
|
|
160
181
|
import {
|
|
161
182
|
SUPPORTED_CONFIG_KEYS,
|
|
162
183
|
addRouteRule,
|
|
@@ -169,7 +190,11 @@ import {
|
|
|
169
190
|
resetConfig,
|
|
170
191
|
setConfigValue,
|
|
171
192
|
testRouteRule
|
|
172
|
-
} from "./chunk-
|
|
193
|
+
} from "./chunk-URXDAUVH.js";
|
|
194
|
+
import {
|
|
195
|
+
requestLlmCompletion,
|
|
196
|
+
resolveLlmProvider
|
|
197
|
+
} from "./chunk-YXQCA6B7.js";
|
|
173
198
|
import {
|
|
174
199
|
DEFAULT_CATEGORIES,
|
|
175
200
|
DEFAULT_CONFIG,
|
|
@@ -179,7 +204,7 @@ import {
|
|
|
179
204
|
import {
|
|
180
205
|
archiveCommand,
|
|
181
206
|
registerArchiveCommand
|
|
182
|
-
} from "./chunk-
|
|
207
|
+
} from "./chunk-2RAZ4ZFE.js";
|
|
183
208
|
import {
|
|
184
209
|
archiveObservations
|
|
185
210
|
} from "./chunk-MQUJNOHK.js";
|
|
@@ -187,13 +212,13 @@ import {
|
|
|
187
212
|
findNearestVaultPath,
|
|
188
213
|
getVaultPath,
|
|
189
214
|
resolveVaultPath
|
|
190
|
-
} from "./chunk-
|
|
215
|
+
} from "./chunk-GNJL4YGR.js";
|
|
191
216
|
import {
|
|
192
217
|
MEMORY_GRAPH_SCHEMA_VERSION,
|
|
193
218
|
buildOrUpdateMemoryGraphIndex,
|
|
194
219
|
getMemoryGraph,
|
|
195
220
|
loadMemoryGraphIndex
|
|
196
|
-
} from "./chunk-
|
|
221
|
+
} from "./chunk-33DOSHTA.js";
|
|
197
222
|
import "./chunk-Z2XBWN7A.js";
|
|
198
223
|
import {
|
|
199
224
|
appendTransition,
|
|
@@ -217,153 +242,246 @@ import {
|
|
|
217
242
|
checkOpenClawCompatibility,
|
|
218
243
|
compatCommand,
|
|
219
244
|
compatibilityExitCode
|
|
220
|
-
} from "./chunk-
|
|
245
|
+
} from "./chunk-X3SPPUFG.js";
|
|
246
|
+
import "./chunk-2ZDO52B4.js";
|
|
221
247
|
|
|
222
248
|
// src/index.ts
|
|
223
249
|
import * as fs2 from "fs";
|
|
224
250
|
|
|
225
|
-
// src/
|
|
251
|
+
// src/commands/migrate.ts
|
|
226
252
|
import * as fs from "fs";
|
|
227
253
|
import * as path from "path";
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (embeddingPipeline) return embeddingPipeline;
|
|
232
|
-
if (pipelineLoading) return pipelineLoading;
|
|
233
|
-
pipelineLoading = (async () => {
|
|
234
|
-
const { pipeline } = await import("@huggingface/transformers");
|
|
235
|
-
embeddingPipeline = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2", {
|
|
236
|
-
dtype: "fp32"
|
|
237
|
-
});
|
|
238
|
-
return embeddingPipeline;
|
|
239
|
-
})();
|
|
240
|
-
return pipelineLoading;
|
|
241
|
-
}
|
|
242
|
-
async function embed(text) {
|
|
243
|
-
const pipe = await getEmbeddingPipeline();
|
|
244
|
-
const result = await pipe(text, { pooling: "mean", normalize: true });
|
|
245
|
-
return new Float32Array(result.data);
|
|
254
|
+
import { execFileSync } from "child_process";
|
|
255
|
+
function addQmdCollection(name, rootPath) {
|
|
256
|
+
execFileSync("qmd", ["collection", "add", name, rootPath], { stdio: "ignore" });
|
|
246
257
|
}
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
results.push(new Float32Array(result.data));
|
|
258
|
+
function updateVaultConfig(vaultPath, updates) {
|
|
259
|
+
const configPath = path.join(vaultPath, ".clawvault.json");
|
|
260
|
+
let config = {};
|
|
261
|
+
if (fs.existsSync(configPath)) {
|
|
262
|
+
try {
|
|
263
|
+
config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
264
|
+
} catch {
|
|
265
|
+
config = {};
|
|
256
266
|
}
|
|
257
267
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
dot += a[i] * b[i];
|
|
268
|
+
if (updates.qmdCollection !== void 0) {
|
|
269
|
+
config.qmdCollection = updates.qmdCollection;
|
|
270
|
+
}
|
|
271
|
+
if (updates.qmdRoot !== void 0) {
|
|
272
|
+
config.qmdRoot = updates.qmdRoot;
|
|
264
273
|
}
|
|
265
|
-
|
|
274
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
266
275
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
276
|
+
function fixStaleCollectionName(issue, dryRun) {
|
|
277
|
+
const details = issue.details;
|
|
278
|
+
const action = {
|
|
279
|
+
type: "stale_collection_name",
|
|
280
|
+
description: `Rename collection "${details.oldName}" to "${details.newName}"`,
|
|
281
|
+
success: false
|
|
282
|
+
};
|
|
283
|
+
if (dryRun) {
|
|
284
|
+
action.success = true;
|
|
285
|
+
action.description += " (dry run)";
|
|
286
|
+
return action;
|
|
273
287
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
const data = JSON.parse(fs.readFileSync(this.cachePath + ".json", "utf-8"));
|
|
281
|
-
for (const [key, arr] of Object.entries(data)) {
|
|
282
|
-
this.cache.set(key, new Float32Array(arr));
|
|
283
|
-
}
|
|
284
|
-
} catch {
|
|
285
|
-
}
|
|
288
|
+
try {
|
|
289
|
+
removeQmdCollection(details.oldName);
|
|
290
|
+
addQmdCollection(details.newName, details.root);
|
|
291
|
+
action.success = true;
|
|
292
|
+
} catch (err) {
|
|
293
|
+
action.error = err?.message || "Failed to rename collection";
|
|
286
294
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
295
|
+
return action;
|
|
296
|
+
}
|
|
297
|
+
function fixMissingQmdCollection(issue, dryRun) {
|
|
298
|
+
const details = issue.details;
|
|
299
|
+
const action = {
|
|
300
|
+
type: "missing_qmd_collection",
|
|
301
|
+
description: `Create qmd collection "${details.collectionName}" at "${details.expectedRoot}"`,
|
|
302
|
+
success: false
|
|
303
|
+
};
|
|
304
|
+
if (dryRun) {
|
|
305
|
+
action.success = true;
|
|
306
|
+
action.description += " (dry run)";
|
|
307
|
+
return action;
|
|
300
308
|
}
|
|
301
|
-
|
|
302
|
-
|
|
309
|
+
try {
|
|
310
|
+
addQmdCollection(details.collectionName, details.expectedRoot);
|
|
311
|
+
action.success = true;
|
|
312
|
+
} catch (err) {
|
|
313
|
+
action.error = err?.message || "Failed to create collection";
|
|
303
314
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
315
|
+
return action;
|
|
316
|
+
}
|
|
317
|
+
function fixWrongVaultPath(issue, dryRun) {
|
|
318
|
+
const details = issue.details;
|
|
319
|
+
const action = {
|
|
320
|
+
type: "wrong_vault_path",
|
|
321
|
+
description: `Update collection "${details.collectionName}" path from "${details.currentRoot}" to "${details.expectedRoot}"`,
|
|
322
|
+
success: false
|
|
323
|
+
};
|
|
324
|
+
if (dryRun) {
|
|
325
|
+
action.success = true;
|
|
326
|
+
action.description += " (dry run)";
|
|
327
|
+
return action;
|
|
307
328
|
}
|
|
308
|
-
|
|
309
|
-
|
|
329
|
+
try {
|
|
330
|
+
removeQmdCollection(details.collectionName);
|
|
331
|
+
addQmdCollection(details.collectionName, details.expectedRoot);
|
|
332
|
+
action.success = true;
|
|
333
|
+
} catch (err) {
|
|
334
|
+
action.error = err?.message || "Failed to update collection path";
|
|
310
335
|
}
|
|
311
|
-
|
|
312
|
-
|
|
336
|
+
return action;
|
|
337
|
+
}
|
|
338
|
+
function fixOrphanedCollection(issue, dryRun) {
|
|
339
|
+
const details = issue.details;
|
|
340
|
+
const action = {
|
|
341
|
+
type: "orphaned_collection",
|
|
342
|
+
description: `Remove orphaned collection "${details.collectionName}"`,
|
|
343
|
+
success: false
|
|
344
|
+
};
|
|
345
|
+
if (dryRun) {
|
|
346
|
+
action.success = true;
|
|
347
|
+
action.description += " (dry run)";
|
|
348
|
+
return action;
|
|
313
349
|
}
|
|
314
|
-
|
|
315
|
-
|
|
350
|
+
try {
|
|
351
|
+
removeQmdCollection(details.collectionName);
|
|
352
|
+
action.success = true;
|
|
353
|
+
} catch (err) {
|
|
354
|
+
action.error = err?.message || "Failed to remove orphaned collection";
|
|
316
355
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
356
|
+
return action;
|
|
357
|
+
}
|
|
358
|
+
function fixMissingQmdConfig(issue, vaultPath, dryRun) {
|
|
359
|
+
const vaultConfig = loadVaultQmdConfig(vaultPath);
|
|
360
|
+
const action = {
|
|
361
|
+
type: "missing_qmd_config",
|
|
362
|
+
description: `Add qmdCollection="${vaultConfig.qmdCollection}" and qmdRoot="${vaultConfig.qmdRoot}" to .clawvault.json`,
|
|
363
|
+
success: false
|
|
364
|
+
};
|
|
365
|
+
if (dryRun) {
|
|
366
|
+
action.success = true;
|
|
367
|
+
action.description += " (dry run)";
|
|
368
|
+
return action;
|
|
323
369
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
370
|
+
try {
|
|
371
|
+
updateVaultConfig(vaultPath, {
|
|
372
|
+
qmdCollection: vaultConfig.qmdCollection,
|
|
373
|
+
qmdRoot: vaultConfig.qmdRoot
|
|
374
|
+
});
|
|
375
|
+
action.success = true;
|
|
376
|
+
} catch (err) {
|
|
377
|
+
action.error = err?.message || "Failed to update vault config";
|
|
327
378
|
}
|
|
328
|
-
return
|
|
379
|
+
return action;
|
|
329
380
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
381
|
+
function fixIssue(issue, vaultPath, dryRun) {
|
|
382
|
+
if (!issue.autoFixable) {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
switch (issue.type) {
|
|
386
|
+
case "stale_collection_name":
|
|
387
|
+
return fixStaleCollectionName(issue, dryRun);
|
|
388
|
+
case "missing_qmd_collection":
|
|
389
|
+
return fixMissingQmdCollection(issue, dryRun);
|
|
390
|
+
case "wrong_vault_path":
|
|
391
|
+
return fixWrongVaultPath(issue, dryRun);
|
|
392
|
+
case "orphaned_collection":
|
|
393
|
+
return fixOrphanedCollection(issue, dryRun);
|
|
394
|
+
case "missing_qmd_config":
|
|
395
|
+
return fixMissingQmdConfig(issue, vaultPath, dryRun);
|
|
396
|
+
default:
|
|
397
|
+
return null;
|
|
335
398
|
}
|
|
336
|
-
results.sort((a, b) => b.score - a.score);
|
|
337
|
-
return results.slice(0, topK);
|
|
338
399
|
}
|
|
339
|
-
async function
|
|
340
|
-
const
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
const fused = reciprocalRankFusion(bm25Ranked, semanticRanked, rrfK);
|
|
344
|
-
const bm25Map = new Map(bm25Results.map((r) => [r.document.path || r.document.id, r]));
|
|
345
|
-
return fused.slice(0, topK).map(({ id, score }) => {
|
|
346
|
-
const existing = bm25Map.get(id);
|
|
347
|
-
if (existing) {
|
|
348
|
-
return { ...existing, score };
|
|
349
|
-
}
|
|
350
|
-
const minimalDoc = {
|
|
351
|
-
id: id.replace(/\.md$/, ""),
|
|
352
|
-
path: id.endsWith(".md") ? id : id + ".md",
|
|
353
|
-
title: (id.split("/").pop() || id).replace(/\.md$/, ""),
|
|
354
|
-
content: "",
|
|
355
|
-
category: id.split("/")[0] || "root",
|
|
356
|
-
frontmatter: {},
|
|
357
|
-
links: [],
|
|
358
|
-
tags: [],
|
|
359
|
-
modified: /* @__PURE__ */ new Date()
|
|
360
|
-
};
|
|
400
|
+
async function migrate(options = {}) {
|
|
401
|
+
const vaultPath = resolveVaultPath({ explicitPath: options.vaultPath });
|
|
402
|
+
const dryRun = options.dryRun ?? false;
|
|
403
|
+
if (!hasQmd()) {
|
|
361
404
|
return {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
405
|
+
vaultPath,
|
|
406
|
+
issuesFound: 1,
|
|
407
|
+
issuesFixed: 0,
|
|
408
|
+
actions: [{
|
|
409
|
+
type: "missing_qmd_collection",
|
|
410
|
+
description: "qmd is not installed",
|
|
411
|
+
success: false,
|
|
412
|
+
error: `Install qmd first: ${QMD_INSTALL_COMMAND}
|
|
413
|
+
More info: ${QMD_INSTALL_URL}`
|
|
414
|
+
}],
|
|
415
|
+
dryRun
|
|
366
416
|
};
|
|
417
|
+
}
|
|
418
|
+
const report = await doctor(vaultPath);
|
|
419
|
+
const issues = report.migrationIssues;
|
|
420
|
+
const actions = [];
|
|
421
|
+
for (const issue of issues) {
|
|
422
|
+
const action = fixIssue(issue, vaultPath, dryRun);
|
|
423
|
+
if (action) {
|
|
424
|
+
actions.push(action);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
const issuesFixed = actions.filter((a) => a.success).length;
|
|
428
|
+
return {
|
|
429
|
+
vaultPath,
|
|
430
|
+
issuesFound: issues.length,
|
|
431
|
+
issuesFixed,
|
|
432
|
+
actions,
|
|
433
|
+
dryRun
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function formatMigrateResult(result) {
|
|
437
|
+
const lines = [];
|
|
438
|
+
lines.push("ClawVault Migration Report");
|
|
439
|
+
lines.push("-".repeat(30));
|
|
440
|
+
lines.push(`Vault: ${result.vaultPath}`);
|
|
441
|
+
lines.push(`Mode: ${result.dryRun ? "Dry Run" : "Live"}`);
|
|
442
|
+
lines.push("");
|
|
443
|
+
if (result.issuesFound === 0) {
|
|
444
|
+
lines.push("\u2713 No migration issues found. Your vault is up to date.");
|
|
445
|
+
return lines.join("\n");
|
|
446
|
+
}
|
|
447
|
+
lines.push(`Found ${result.issuesFound} issue(s)`);
|
|
448
|
+
lines.push("");
|
|
449
|
+
for (const action of result.actions) {
|
|
450
|
+
const prefix = action.success ? "\u2713" : "\u2717";
|
|
451
|
+
lines.push(`${prefix} ${action.description}`);
|
|
452
|
+
if (action.error) {
|
|
453
|
+
lines.push(` Error: ${action.error}`);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
lines.push("");
|
|
457
|
+
if (result.dryRun) {
|
|
458
|
+
lines.push(`Would fix ${result.issuesFixed}/${result.issuesFound} issue(s).`);
|
|
459
|
+
lines.push("Run without --dry-run to apply changes.");
|
|
460
|
+
} else {
|
|
461
|
+
lines.push(`Fixed ${result.issuesFixed}/${result.issuesFound} issue(s).`);
|
|
462
|
+
if (result.issuesFixed < result.issuesFound) {
|
|
463
|
+
lines.push("Some issues require manual intervention.");
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return lines.join("\n");
|
|
467
|
+
}
|
|
468
|
+
async function migrateCommand(options = {}) {
|
|
469
|
+
const result = await migrate(options);
|
|
470
|
+
if (options.json) {
|
|
471
|
+
console.log(JSON.stringify(result, null, 2));
|
|
472
|
+
} else {
|
|
473
|
+
console.log(formatMigrateResult(result));
|
|
474
|
+
}
|
|
475
|
+
return result;
|
|
476
|
+
}
|
|
477
|
+
function registerMigrateCommand(program) {
|
|
478
|
+
program.command("migrate").description("Auto-fix common v2\u2192v3 migration issues (stale collections, missing qmd config, wrong paths)").option("-v, --vault <path>", "Vault path").option("--dry-run", "Preview changes without applying them").option("--force", "Force migration even if no issues detected").option("--json", "Output results as JSON").action(async (rawOptions) => {
|
|
479
|
+
await migrateCommand({
|
|
480
|
+
vaultPath: rawOptions.vault,
|
|
481
|
+
dryRun: rawOptions.dryRun,
|
|
482
|
+
force: rawOptions.force,
|
|
483
|
+
json: rawOptions.json
|
|
484
|
+
});
|
|
367
485
|
});
|
|
368
486
|
}
|
|
369
487
|
|
|
@@ -389,11 +507,13 @@ export {
|
|
|
389
507
|
DEFAULT_CONFIG,
|
|
390
508
|
DEFAULT_SERVE_PORT,
|
|
391
509
|
EmbeddingCache,
|
|
510
|
+
FactStore,
|
|
392
511
|
MEMORY_GRAPH_SCHEMA_VERSION,
|
|
393
512
|
MEMORY_TYPES,
|
|
394
513
|
Observer,
|
|
395
514
|
QMD_INSTALL_COMMAND,
|
|
396
515
|
QMD_INSTALL_URL,
|
|
516
|
+
QmdConfigurationError,
|
|
397
517
|
QmdUnavailableError,
|
|
398
518
|
Reflector,
|
|
399
519
|
SUPPORTED_CONFIG_KEYS,
|
|
@@ -423,6 +543,10 @@ export {
|
|
|
423
543
|
contextCommand,
|
|
424
544
|
cosineSimilarity,
|
|
425
545
|
countBlockedTransitions,
|
|
546
|
+
createDefaultAdapter,
|
|
547
|
+
createFactExtractionAdapter,
|
|
548
|
+
createGeminiFlashAdapter,
|
|
549
|
+
createLlmFunction,
|
|
426
550
|
createProject,
|
|
427
551
|
createVault,
|
|
428
552
|
deterministicInjectMatches,
|
|
@@ -432,8 +556,11 @@ export {
|
|
|
432
556
|
embedBatch,
|
|
433
557
|
embedCommand,
|
|
434
558
|
extractCardSlug,
|
|
559
|
+
extractFactsLlm,
|
|
560
|
+
extractFactsRuleBased,
|
|
435
561
|
extractTags,
|
|
436
562
|
extractWikiLinks,
|
|
563
|
+
factId,
|
|
437
564
|
fetchRemoteFile,
|
|
438
565
|
fetchRemoteManifest,
|
|
439
566
|
findNearestVaultPath,
|
|
@@ -452,6 +579,7 @@ export {
|
|
|
452
579
|
getOnlinePeers,
|
|
453
580
|
getProjectActivity,
|
|
454
581
|
getProjectTasks,
|
|
582
|
+
getQmdErrorDetails,
|
|
455
583
|
getScaledObservationThresholdBytes,
|
|
456
584
|
getTailscaleStatus,
|
|
457
585
|
getTailscaleVersion,
|
|
@@ -474,9 +602,12 @@ export {
|
|
|
474
602
|
listSubtasks,
|
|
475
603
|
loadMemoryGraphIndex,
|
|
476
604
|
matchRouteRule,
|
|
605
|
+
migrate,
|
|
606
|
+
migrateCommand,
|
|
477
607
|
migrateObservations,
|
|
478
608
|
migrateObservationsCommand,
|
|
479
609
|
normalizeContextProfileInput,
|
|
610
|
+
normalizeEntity,
|
|
480
611
|
observeActiveSessions,
|
|
481
612
|
observeCommand,
|
|
482
613
|
parseKanbanMarkdown,
|
|
@@ -497,6 +628,7 @@ export {
|
|
|
497
628
|
registerContextCommand,
|
|
498
629
|
registerEmbedCommand,
|
|
499
630
|
registerInjectCommand,
|
|
631
|
+
registerMigrateCommand,
|
|
500
632
|
registerMigrateObservationsCommand,
|
|
501
633
|
registerObserveCommand,
|
|
502
634
|
registerRebuildCommand,
|
|
@@ -514,6 +646,7 @@ export {
|
|
|
514
646
|
requestLlmCompletion,
|
|
515
647
|
resetConfig,
|
|
516
648
|
resolveContextProfile,
|
|
649
|
+
resolveFactExtractionMode,
|
|
517
650
|
resolveLlmProvider,
|
|
518
651
|
resolvePeerIP,
|
|
519
652
|
resolveVaultPath,
|
|
@@ -57,7 +57,7 @@ declare function getMemoryGraph(vaultPath: string, options?: {
|
|
|
57
57
|
refresh?: boolean;
|
|
58
58
|
}): Promise<MemoryGraph>;
|
|
59
59
|
|
|
60
|
-
type LlmProvider = 'anthropic' | 'openai' | 'gemini';
|
|
60
|
+
type LlmProvider = 'anthropic' | 'openai' | 'gemini' | 'xai' | 'openclaw';
|
|
61
61
|
interface LlmCompletionOptions {
|
|
62
62
|
prompt: string;
|
|
63
63
|
provider?: LlmProvider | null;
|
|
@@ -134,4 +134,4 @@ declare function buildInjectionResult(message: string, options: InjectCommandOpt
|
|
|
134
134
|
declare function injectCommand(message: string, options: InjectCommandOptions): Promise<void>;
|
|
135
135
|
declare function registerInjectCommand(program: Command): void;
|
|
136
136
|
|
|
137
|
-
export { runPromptInjection as A, type InjectCommandOptions as I, type
|
|
137
|
+
export { runPromptInjection as A, type InjectCommandOptions as I, type LlmProvider as L, MEMORY_GRAPH_SCHEMA_VERSION as M, type InjectFormat as a, type InjectMatch as b, type InjectMatchReason as c, type InjectMatchSource as d, type InjectResult as e, type InjectRuntimeOptions as f, type InjectSourceCategory as g, type InjectableItem as h, type LlmCompletionOptions as i, type MemoryGraph as j, type MemoryGraphEdge as k, type MemoryGraphEdgeType as l, type MemoryGraphIndex as m, type MemoryGraphNode as n, type MemoryGraphNodeType as o, type MemoryGraphStats as p, buildInjectionResult as q, buildOrUpdateMemoryGraphIndex as r, deterministicInjectMatches as s, getMemoryGraph as t, indexInjectableItems as u, injectCommand as v, loadMemoryGraphIndex as w, registerInjectCommand as x, requestLlmCompletion as y, resolveLlmProvider as z };
|