clawvault 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/register-core-commands.js +25 -2
- package/bin/register-task-commands.js +18 -2
- package/bin/register-task-commands.test.js +24 -0
- package/dist/{chunk-TB3BM2PQ.js → chunk-33GW63WK.js} +4 -35
- package/dist/{chunk-JVAWKNIZ.js → chunk-AHGUJG76.js} +1 -1
- package/dist/{chunk-TT3FXYCN.js → chunk-BI6SGGZP.js} +1 -1
- package/dist/{chunk-NGVAEFT2.js → chunk-DEFBIVQ3.js} +21 -0
- package/dist/{chunk-USZU5CBB.js → chunk-DHJPXGC7.js} +1 -1
- package/dist/{chunk-2AYPFUGX.js → chunk-FEFPBHH4.js} +286 -11
- package/dist/{chunk-K6XHCUFL.js → chunk-FHFUXL6G.js} +8 -1
- package/dist/{chunk-RARDNTUP.js → chunk-GBIDDDSL.js} +2 -2
- package/dist/chunk-IFTEGE4D.js +361 -0
- package/dist/{chunk-VBVEXNI5.js → chunk-JXY6T5R7.js} +1 -1
- package/dist/chunk-L3DJ36BZ.js +40 -0
- package/dist/{chunk-OTQW3OMC.js → chunk-Q3WBH4P4.js} +97 -0
- package/dist/{chunk-6AQZIPLV.js → chunk-SNEMCQP7.js} +12 -5
- package/dist/commands/backlog.js +9 -2
- package/dist/commands/blocked.js +9 -2
- package/dist/commands/canvas.d.ts +11 -3
- package/dist/commands/canvas.js +954 -20
- package/dist/commands/context.js +4 -3
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/migrate-observations.js +2 -2
- package/dist/commands/observe.d.ts +1 -0
- package/dist/commands/observe.js +4 -3
- package/dist/commands/rebuild.js +4 -3
- package/dist/commands/reflect.js +3 -3
- package/dist/commands/replay.js +5 -4
- package/dist/commands/setup.d.ts +10 -2
- package/dist/commands/setup.js +1 -1
- package/dist/commands/sleep.js +5 -4
- package/dist/commands/status.js +1 -1
- package/dist/commands/task.js +1 -1
- package/dist/commands/wake.js +3 -3
- package/dist/index.d.ts +5 -0
- package/dist/index.js +13 -11
- package/dist/lib/task-utils.d.ts +13 -1
- package/dist/lib/task-utils.js +3 -1
- package/package.json +1 -1
- package/dist/chunk-W463YRED.js +0 -97
package/dist/commands/context.js
CHANGED
|
@@ -3,11 +3,12 @@ import {
|
|
|
3
3
|
contextCommand,
|
|
4
4
|
formatContextMarkdown,
|
|
5
5
|
registerContextCommand
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-33GW63WK.js";
|
|
7
|
+
import "../chunk-Q3WBH4P4.js";
|
|
8
8
|
import "../chunk-FDJIZKCW.js";
|
|
9
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-L3DJ36BZ.js";
|
|
10
10
|
import "../chunk-ZZA73MFY.js";
|
|
11
|
+
import "../chunk-FHFUXL6G.js";
|
|
11
12
|
import "../chunk-NAMFB7ZA.js";
|
|
12
13
|
export {
|
|
13
14
|
buildContext,
|
package/dist/commands/doctor.js
CHANGED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
migrateObservations,
|
|
3
3
|
migrateObservationsCommand,
|
|
4
4
|
registerMigrateObservationsCommand
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-JXY6T5R7.js";
|
|
6
6
|
import "../chunk-MXSSG3QU.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-FHFUXL6G.js";
|
|
8
8
|
import "../chunk-NAMFB7ZA.js";
|
|
9
9
|
export {
|
|
10
10
|
migrateObservations,
|
package/dist/commands/observe.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
observeCommand,
|
|
3
3
|
registerObserveCommand
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-SNEMCQP7.js";
|
|
5
5
|
import "../chunk-HRLWZGMA.js";
|
|
6
6
|
import "../chunk-P5EPF6MB.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-FEFPBHH4.js";
|
|
8
8
|
import "../chunk-MXSSG3QU.js";
|
|
9
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-DEFBIVQ3.js";
|
|
10
|
+
import "../chunk-FHFUXL6G.js";
|
|
10
11
|
import "../chunk-NAMFB7ZA.js";
|
|
11
12
|
export {
|
|
12
13
|
observeCommand,
|
package/dist/commands/rebuild.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
rebuildCommand,
|
|
3
3
|
registerRebuildCommand
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-DHJPXGC7.js";
|
|
5
|
+
import "../chunk-FEFPBHH4.js";
|
|
6
6
|
import "../chunk-MXSSG3QU.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-DEFBIVQ3.js";
|
|
8
|
+
import "../chunk-FHFUXL6G.js";
|
|
8
9
|
import "../chunk-NAMFB7ZA.js";
|
|
9
10
|
export {
|
|
10
11
|
rebuildCommand,
|
package/dist/commands/reflect.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
reflectCommand,
|
|
3
3
|
registerReflectCommand
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-BI6SGGZP.js";
|
|
5
|
+
import "../chunk-AHGUJG76.js";
|
|
6
6
|
import "../chunk-QALB2V3E.js";
|
|
7
7
|
import "../chunk-MXSSG3QU.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-FHFUXL6G.js";
|
|
9
9
|
import "../chunk-NAMFB7ZA.js";
|
|
10
10
|
export {
|
|
11
11
|
reflectCommand,
|
package/dist/commands/replay.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
registerReplayCommand,
|
|
3
3
|
replayCommand
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-GBIDDDSL.js";
|
|
5
|
+
import "../chunk-AHGUJG76.js";
|
|
6
|
+
import "../chunk-FEFPBHH4.js";
|
|
7
7
|
import "../chunk-QALB2V3E.js";
|
|
8
8
|
import "../chunk-MXSSG3QU.js";
|
|
9
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-DEFBIVQ3.js";
|
|
10
|
+
import "../chunk-FHFUXL6G.js";
|
|
10
11
|
import "../chunk-NAMFB7ZA.js";
|
|
11
12
|
export {
|
|
12
13
|
registerReplayCommand,
|
package/dist/commands/setup.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
interface SetupOptions {
|
|
2
|
+
graphColors?: boolean;
|
|
3
|
+
bases?: boolean;
|
|
4
|
+
canvas?: boolean | string;
|
|
5
|
+
theme?: 'neural' | 'minimal' | 'none';
|
|
6
|
+
force?: boolean;
|
|
7
|
+
vault?: string;
|
|
8
|
+
}
|
|
9
|
+
declare function setupCommand(options?: SetupOptions): Promise<void>;
|
|
2
10
|
|
|
3
|
-
export { setupCommand };
|
|
11
|
+
export { type SetupOptions, setupCommand };
|
package/dist/commands/setup.js
CHANGED
package/dist/commands/sleep.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runReflection
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-AHGUJG76.js";
|
|
4
4
|
import {
|
|
5
5
|
parseSessionFile
|
|
6
6
|
} from "../chunk-P5EPF6MB.js";
|
|
7
7
|
import {
|
|
8
8
|
Observer
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-FEFPBHH4.js";
|
|
10
10
|
import "../chunk-QALB2V3E.js";
|
|
11
|
+
import "../chunk-DEFBIVQ3.js";
|
|
11
12
|
import {
|
|
12
13
|
clearDirtyFlag
|
|
13
14
|
} from "../chunk-MZZJLQNQ.js";
|
|
14
15
|
import {
|
|
15
16
|
ClawVault
|
|
16
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-Q3WBH4P4.js";
|
|
17
18
|
import {
|
|
18
19
|
qmdUpdate
|
|
19
20
|
} from "../chunk-FDJIZKCW.js";
|
|
20
|
-
import "../chunk-K6XHCUFL.js";
|
|
21
21
|
import "../chunk-ZZA73MFY.js";
|
|
22
|
+
import "../chunk-FHFUXL6G.js";
|
|
22
23
|
import "../chunk-NAMFB7ZA.js";
|
|
23
24
|
|
|
24
25
|
// src/commands/sleep.ts
|
package/dist/commands/status.js
CHANGED
package/dist/commands/task.js
CHANGED
package/dist/commands/wake.js
CHANGED
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
} from "../chunk-MZZJLQNQ.js";
|
|
8
8
|
import {
|
|
9
9
|
ClawVault
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-Q3WBH4P4.js";
|
|
11
11
|
import "../chunk-FDJIZKCW.js";
|
|
12
|
+
import "../chunk-ZZA73MFY.js";
|
|
12
13
|
import {
|
|
13
14
|
parseObservationMarkdown
|
|
14
|
-
} from "../chunk-
|
|
15
|
-
import "../chunk-ZZA73MFY.js";
|
|
15
|
+
} from "../chunk-FHFUXL6G.js";
|
|
16
16
|
import {
|
|
17
17
|
listObservationFiles
|
|
18
18
|
} from "../chunk-NAMFB7ZA.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ declare class ClawVault {
|
|
|
33
33
|
* Initialize a new vault
|
|
34
34
|
*/
|
|
35
35
|
init(options?: Partial<VaultConfig>): Promise<void>;
|
|
36
|
+
private createBasesFiles;
|
|
36
37
|
/**
|
|
37
38
|
* Load an existing vault
|
|
38
39
|
*/
|
|
@@ -349,6 +350,7 @@ interface ObserverOptions {
|
|
|
349
350
|
reflector?: ObserverReflector;
|
|
350
351
|
now?: () => Date;
|
|
351
352
|
rawCapture?: boolean;
|
|
353
|
+
extractTasks?: boolean;
|
|
352
354
|
}
|
|
353
355
|
interface ObserverProcessOptions {
|
|
354
356
|
source?: string;
|
|
@@ -366,6 +368,7 @@ declare class Observer {
|
|
|
366
368
|
private readonly rawCapture;
|
|
367
369
|
private readonly router;
|
|
368
370
|
private pendingMessages;
|
|
371
|
+
private pendingRouteContext;
|
|
369
372
|
private observationsCache;
|
|
370
373
|
private lastRoutingSummary;
|
|
371
374
|
constructor(vaultPath: string, options?: ObserverOptions);
|
|
@@ -387,6 +390,7 @@ declare class Observer {
|
|
|
387
390
|
private deduplicateObservationMarkdown;
|
|
388
391
|
private persistRawMessages;
|
|
389
392
|
private sanitizeSource;
|
|
393
|
+
private mergeRouteContext;
|
|
390
394
|
}
|
|
391
395
|
|
|
392
396
|
interface CompressorOptions {
|
|
@@ -425,6 +429,7 @@ declare class Compressor {
|
|
|
425
429
|
private inferConfidence;
|
|
426
430
|
private isCriticalContent;
|
|
427
431
|
private isNotableContent;
|
|
432
|
+
private inferTaskType;
|
|
428
433
|
private normalizeText;
|
|
429
434
|
private extractDate;
|
|
430
435
|
private extractTime;
|
package/dist/index.js
CHANGED
|
@@ -42,11 +42,11 @@ import {
|
|
|
42
42
|
import {
|
|
43
43
|
reflectCommand,
|
|
44
44
|
registerReflectCommand
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-BI6SGGZP.js";
|
|
46
46
|
import {
|
|
47
47
|
registerReplayCommand,
|
|
48
48
|
replayCommand
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-GBIDDDSL.js";
|
|
50
50
|
import {
|
|
51
51
|
buildSessionRecap,
|
|
52
52
|
formatSessionRecapMarkdown,
|
|
@@ -54,10 +54,10 @@ import {
|
|
|
54
54
|
} from "./chunk-ZKGY7WTT.js";
|
|
55
55
|
import {
|
|
56
56
|
setupCommand
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-IFTEGE4D.js";
|
|
58
58
|
import {
|
|
59
59
|
runReflection
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-AHGUJG76.js";
|
|
61
61
|
import {
|
|
62
62
|
graphCommand,
|
|
63
63
|
graphSummary
|
|
@@ -66,12 +66,12 @@ import {
|
|
|
66
66
|
migrateObservations,
|
|
67
67
|
migrateObservationsCommand,
|
|
68
68
|
registerMigrateObservationsCommand
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-JXY6T5R7.js";
|
|
70
70
|
import {
|
|
71
71
|
SessionWatcher,
|
|
72
72
|
observeCommand,
|
|
73
73
|
registerObserveCommand
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-SNEMCQP7.js";
|
|
75
75
|
import "./chunk-HRLWZGMA.js";
|
|
76
76
|
import {
|
|
77
77
|
parseSessionFile
|
|
@@ -79,12 +79,12 @@ import {
|
|
|
79
79
|
import {
|
|
80
80
|
rebuildCommand,
|
|
81
81
|
registerRebuildCommand
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-DHJPXGC7.js";
|
|
83
83
|
import {
|
|
84
84
|
Compressor,
|
|
85
85
|
Observer,
|
|
86
86
|
Reflector
|
|
87
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-FEFPBHH4.js";
|
|
88
88
|
import {
|
|
89
89
|
archiveCommand,
|
|
90
90
|
registerArchiveCommand
|
|
@@ -97,6 +97,7 @@ import {
|
|
|
97
97
|
getVaultPath,
|
|
98
98
|
resolveVaultPath
|
|
99
99
|
} from "./chunk-MXSSG3QU.js";
|
|
100
|
+
import "./chunk-DEFBIVQ3.js";
|
|
100
101
|
import {
|
|
101
102
|
checkOpenClawCompatibility,
|
|
102
103
|
compatCommand,
|
|
@@ -110,12 +111,12 @@ import {
|
|
|
110
111
|
normalizeContextProfileInput,
|
|
111
112
|
registerContextCommand,
|
|
112
113
|
resolveContextProfile
|
|
113
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-33GW63WK.js";
|
|
114
115
|
import {
|
|
115
116
|
ClawVault,
|
|
116
117
|
createVault,
|
|
117
118
|
findVault
|
|
118
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-Q3WBH4P4.js";
|
|
119
120
|
import {
|
|
120
121
|
DEFAULT_CATEGORIES,
|
|
121
122
|
DEFAULT_CONFIG,
|
|
@@ -131,13 +132,14 @@ import {
|
|
|
131
132
|
qmdEmbed,
|
|
132
133
|
qmdUpdate
|
|
133
134
|
} from "./chunk-FDJIZKCW.js";
|
|
134
|
-
import "./chunk-
|
|
135
|
+
import "./chunk-L3DJ36BZ.js";
|
|
135
136
|
import {
|
|
136
137
|
MEMORY_GRAPH_SCHEMA_VERSION,
|
|
137
138
|
buildOrUpdateMemoryGraphIndex,
|
|
138
139
|
getMemoryGraph,
|
|
139
140
|
loadMemoryGraphIndex
|
|
140
141
|
} from "./chunk-ZZA73MFY.js";
|
|
142
|
+
import "./chunk-FHFUXL6G.js";
|
|
141
143
|
import "./chunk-NAMFB7ZA.js";
|
|
142
144
|
|
|
143
145
|
// src/index.ts
|
package/dist/lib/task-utils.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ type TaskStatus = 'open' | 'in-progress' | 'blocked' | 'done';
|
|
|
6
6
|
type TaskPriority = 'critical' | 'high' | 'medium' | 'low';
|
|
7
7
|
interface TaskFrontmatter {
|
|
8
8
|
status: TaskStatus;
|
|
9
|
+
source?: string;
|
|
9
10
|
owner?: string;
|
|
10
11
|
project?: string;
|
|
11
12
|
priority?: TaskPriority;
|
|
@@ -27,6 +28,7 @@ interface BacklogFrontmatter {
|
|
|
27
28
|
source?: string;
|
|
28
29
|
project?: string;
|
|
29
30
|
created: string;
|
|
31
|
+
lastSeen?: string;
|
|
30
32
|
tags?: string[];
|
|
31
33
|
}
|
|
32
34
|
interface BacklogItem {
|
|
@@ -95,6 +97,7 @@ declare function listBacklogItems(vaultPath: string, filters?: BacklogFilterOpti
|
|
|
95
97
|
* Create a new task
|
|
96
98
|
*/
|
|
97
99
|
declare function createTask(vaultPath: string, title: string, options?: {
|
|
100
|
+
source?: string;
|
|
98
101
|
owner?: string;
|
|
99
102
|
project?: string;
|
|
100
103
|
priority?: TaskPriority;
|
|
@@ -127,6 +130,15 @@ declare function createBacklogItem(vaultPath: string, title: string, options?: {
|
|
|
127
130
|
content?: string;
|
|
128
131
|
tags?: string[];
|
|
129
132
|
}): BacklogItem;
|
|
133
|
+
/**
|
|
134
|
+
* Update an existing backlog item frontmatter.
|
|
135
|
+
*/
|
|
136
|
+
declare function updateBacklogItem(vaultPath: string, slug: string, updates: {
|
|
137
|
+
source?: string;
|
|
138
|
+
project?: string;
|
|
139
|
+
tags?: string[];
|
|
140
|
+
lastSeen?: string;
|
|
141
|
+
}): BacklogItem;
|
|
130
142
|
/**
|
|
131
143
|
* Promote a backlog item to a task
|
|
132
144
|
*/
|
|
@@ -156,4 +168,4 @@ declare function getStatusIcon(status: TaskStatus): string;
|
|
|
156
168
|
*/
|
|
157
169
|
declare function getStatusDisplay(status: TaskStatus): string;
|
|
158
170
|
|
|
159
|
-
export { type BacklogFilterOptions, type BacklogFrontmatter, type BacklogItem, type Task, type TaskFilterOptions, type TaskFrontmatter, type TaskPriority, type TaskStatus, completeTask, createBacklogItem, createTask, ensureBacklogDir, ensureTasksDir, getActiveTasks, getBacklogDir, getBacklogPath, getBlockedTasks, getRecentlyCompletedTasks, getStatusDisplay, getStatusIcon, getTaskPath, getTasksDir, listBacklogItems, listTasks, promoteBacklogItem, readBacklogItem, readTask, slugify, updateTask };
|
|
171
|
+
export { type BacklogFilterOptions, type BacklogFrontmatter, type BacklogItem, type Task, type TaskFilterOptions, type TaskFrontmatter, type TaskPriority, type TaskStatus, completeTask, createBacklogItem, createTask, ensureBacklogDir, ensureTasksDir, getActiveTasks, getBacklogDir, getBacklogPath, getBlockedTasks, getRecentlyCompletedTasks, getStatusDisplay, getStatusIcon, getTaskPath, getTasksDir, listBacklogItems, listTasks, promoteBacklogItem, readBacklogItem, readTask, slugify, updateBacklogItem, updateTask };
|
package/dist/lib/task-utils.js
CHANGED
|
@@ -19,8 +19,9 @@ import {
|
|
|
19
19
|
readBacklogItem,
|
|
20
20
|
readTask,
|
|
21
21
|
slugify,
|
|
22
|
+
updateBacklogItem,
|
|
22
23
|
updateTask
|
|
23
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-DEFBIVQ3.js";
|
|
24
25
|
export {
|
|
25
26
|
completeTask,
|
|
26
27
|
createBacklogItem,
|
|
@@ -42,5 +43,6 @@ export {
|
|
|
42
43
|
readBacklogItem,
|
|
43
44
|
readTask,
|
|
44
45
|
slugify,
|
|
46
|
+
updateBacklogItem,
|
|
45
47
|
updateTask
|
|
46
48
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clawvault",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "ClawVault™ - 🐘 An elephant never forgets. Structured memory for OpenClaw agents. Context death resilience, Obsidian-compatible markdown, local semantic search.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
package/dist/chunk-W463YRED.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_CATEGORIES,
|
|
3
|
-
hasQmd
|
|
4
|
-
} from "./chunk-FDJIZKCW.js";
|
|
5
|
-
|
|
6
|
-
// src/commands/setup.ts
|
|
7
|
-
import * as fs from "fs";
|
|
8
|
-
import * as os from "os";
|
|
9
|
-
import * as path from "path";
|
|
10
|
-
import { execFileSync } from "child_process";
|
|
11
|
-
var CONFIG_FILE = ".clawvault.json";
|
|
12
|
-
function resolveVaultTarget() {
|
|
13
|
-
const envPath = process.env.CLAWVAULT_PATH?.trim();
|
|
14
|
-
const home = os.homedir();
|
|
15
|
-
if (envPath) {
|
|
16
|
-
const vaultPath = path.resolve(envPath);
|
|
17
|
-
return { vaultPath, source: "CLAWVAULT_PATH", existed: fs.existsSync(vaultPath) };
|
|
18
|
-
}
|
|
19
|
-
const candidates = [
|
|
20
|
-
{ vaultPath: path.join(home, ".openclaw", "workspace", "memory"), source: "OpenClaw default" },
|
|
21
|
-
{ vaultPath: path.resolve(process.cwd(), "memory"), source: "./memory" },
|
|
22
|
-
{ vaultPath: path.join(home, "memory"), source: "~/memory" }
|
|
23
|
-
];
|
|
24
|
-
for (const candidate of candidates) {
|
|
25
|
-
if (fs.existsSync(candidate.vaultPath)) {
|
|
26
|
-
return { ...candidate, existed: true };
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const fallback = candidates[0];
|
|
30
|
-
return { ...fallback, existed: false };
|
|
31
|
-
}
|
|
32
|
-
function ensureVaultStructure(vaultPath) {
|
|
33
|
-
fs.mkdirSync(vaultPath, { recursive: true });
|
|
34
|
-
for (const category of DEFAULT_CATEGORIES) {
|
|
35
|
-
fs.mkdirSync(path.join(vaultPath, category), { recursive: true });
|
|
36
|
-
}
|
|
37
|
-
const configPath = path.join(vaultPath, CONFIG_FILE);
|
|
38
|
-
if (fs.existsSync(configPath)) return false;
|
|
39
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
40
|
-
const name = path.basename(vaultPath);
|
|
41
|
-
const meta = {
|
|
42
|
-
name,
|
|
43
|
-
version: "1.0.0",
|
|
44
|
-
created: now,
|
|
45
|
-
lastUpdated: now,
|
|
46
|
-
categories: DEFAULT_CATEGORIES,
|
|
47
|
-
documentCount: 0,
|
|
48
|
-
qmdCollection: name,
|
|
49
|
-
qmdRoot: vaultPath
|
|
50
|
-
};
|
|
51
|
-
fs.writeFileSync(configPath, JSON.stringify(meta, null, 2));
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
function getQmdConfig(vaultPath) {
|
|
55
|
-
const configPath = path.join(vaultPath, CONFIG_FILE);
|
|
56
|
-
if (fs.existsSync(configPath)) {
|
|
57
|
-
try {
|
|
58
|
-
const meta = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
59
|
-
return {
|
|
60
|
-
collection: meta.qmdCollection || meta.name || path.basename(vaultPath),
|
|
61
|
-
root: meta.qmdRoot || vaultPath
|
|
62
|
-
};
|
|
63
|
-
} catch {
|
|
64
|
-
return { collection: path.basename(vaultPath), root: vaultPath };
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return { collection: path.basename(vaultPath), root: vaultPath };
|
|
68
|
-
}
|
|
69
|
-
async function setupCommand() {
|
|
70
|
-
const target = resolveVaultTarget();
|
|
71
|
-
if (target.existed && !fs.statSync(target.vaultPath).isDirectory()) {
|
|
72
|
-
throw new Error(`Vault path is not a directory: ${target.vaultPath}`);
|
|
73
|
-
}
|
|
74
|
-
if (!target.existed) fs.mkdirSync(target.vaultPath, { recursive: true });
|
|
75
|
-
console.log(`${target.existed ? "Found" : "Created"} vault path (${target.source}): ${target.vaultPath}`);
|
|
76
|
-
const initialized = ensureVaultStructure(target.vaultPath);
|
|
77
|
-
console.log(initialized ? "Initialized vault structure." : "Vault structure already present.");
|
|
78
|
-
console.log("\nTip: add this to your shell config:");
|
|
79
|
-
console.log(` export CLAWVAULT_PATH="${target.vaultPath}"`);
|
|
80
|
-
if (hasQmd()) {
|
|
81
|
-
const { collection, root } = getQmdConfig(target.vaultPath);
|
|
82
|
-
try {
|
|
83
|
-
execFileSync("qmd", ["collection", "add", root, "--name", collection, "--mask", "**/*.md"], {
|
|
84
|
-
stdio: "ignore"
|
|
85
|
-
});
|
|
86
|
-
console.log(`qmd collection ready: ${collection}`);
|
|
87
|
-
} catch {
|
|
88
|
-
console.log("qmd collection already exists or could not be created.");
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
console.log("qmd not found; skipping collection setup.");
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export {
|
|
96
|
-
setupCommand
|
|
97
|
-
};
|